[Scummvm-cvs-logs] scummvm master -> 3c2ac653b2ee2c7f2efd2684516a13eb47cbf102

dreammaster dreammaster at scummvm.org
Fri Dec 19 13:35:28 CET 2014


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

Summary:
8480f53d60 ACCESS: Initial engine skeleton
83f55f737b ACCESS: Main engine skeleton and events manager
c2451b57bc ACCESS: Added resources for cursors
4d24209eae ACCESS: Add Amazon floppy detection and skeleton for Amazon engine
857f94423f ACCESS: Implement decoding of game cursors
a94bf197ef ACCESS: Implement fading routines
a35ba4caf9 ACCESS: Adding file loading
7a63e12edb ACCESS: Added screen loading and file index load fixes
d41c5cd740 ACCESS: Added decompression code
04d42638cd ACCESS: Fleshed out beginning of title sequence, added Screen::clip
bb48a153a6 ACCESS: Remove graphics manager, and added more skeleton for Amazon intro
e6b1d148ce ACCESS: Added Globals classes
c4fb766811 ACCESS: Moved globals into the main engine classes
f1309a7b0b ACCESS: Remainder of Amazon game initialization added
7d605ce573 ACCESS: Implement outer room handler
8e43a6c528 ACCESS: Add scripts classes and Amazon room setup
c4d6dc3763 ACCESS: Added room clearing
3bd0f0f339 ACCESS: Split resources into a seperate file just for Amazon resources
3645aad6fb ACCESS: Add Amazon character and room resource lists
031cc32c84 ACCESS: Implemented room data loading
bea93f3441 ACCESS: Implemented setupRoom method
010ba5b126 ACCESS: Fix reading last resource of container files
0183007d0b ACCESS: Fixes for loading room data
0c38730f3f ACCESS: Implement buildScreen
6715bb0864 ACCESS: Move playField and tile data to Room class
52721cf2cb ACCESS: General cleanup of Room class
745aa3daf9 ACCESS: Implemented skeleton script command method list
9aefd90939 ACCESS: Fix opening files by name
80c8fbe024 ACCESS: Simplify command list array to use a virtual method
fb0a1f5597 ACCESS: Implemented cmdGoto script command
a9b8369274 ACCESS: Implemented several script commands
c930c7e6ed ACCESS: Implement some script opcodes
5a3dfb1a7b ACCESS: Fix implementation of cmdCheckLoc()
814d4ebdd0 ACCESS: Add detection entry and subfolder adding for CD version
3fb6c99017 ACCESS: Add missing CMDOBJECT method to script command list
1171400ccb ACCESS: Beginnings of animation manager
00633b94be ACCESS: Convert Scripts class to use a MemoryReadStream
d04a6d2d7a ACCESS: Beginnings of inventory management
127a0eeadd ACCESS: Cleanup of Amazon game flags
33f432d989 ACCESS: Fix skipping bytes in executeScript method
f495d39099 ACCESS: Implement some more opcodes
c1613178c3 ACCESS: Implemented player loading
9d590687e9 ACCESS: Implemented roomMenu
00901b200b ACCESS: Fix bug in reloadRoom1
cce0c2ff97 ACCESS: Adding sprite resources and screen saving
00f7a3404d ACCESS: Implement 3 more opcodes
ba1f8b2f6b ACCESS: Fix typo in variable name
0e3f9e983d ACCESS: Changed _objectsTable from raw data array to SpriteResource array
47d75ae128 ACCESS: Beginnings of logic for drawing sprite frames
6801cb0855 ACCESS: Decompress sprite resource frames immediately on creation
b2596cab0e ACCESS: Implement loadPlayField
6f2bc7fc1f ACCESS: Implement 2 opcodes
e833ae66e2 ACCESS: Fix loop in buildScreen
b6c9460031 ACCESS: Fix palette translation during loading
69ecc15c02 ACCESS: Add decoding of animation resources
a0b9afded3 ACCESS: Implemented animation anim methods
5344143027 ACCESS: Implement cmdCheckFrame
69c7f989b1 ACCESS: Fix the implementation of cmdCheckAnim
5c7699799d ACCESS: Implement 3 more opcodes, fix a typo
617aa98ede ACCESS: Implement cmdSnd()
768e144683 ACCESS: Properly implement Animation calcFrame/calcFrame1 methods
7d4180c3e2 ACCESS: Implemented Animation setFrame code
eee84b8760 ACCESS: Implemented plotList
c0cb03cea2 ACCESS: Implemented copyBlocks
94eda108eb ACCESS: Fix incorrect decrementing of _startup
9107cc103f ACCESS: Added a temporary frame delay and screen update
b579dbb71b ACCESS: Fixes for clipping
483bc1eb03 ACCESS: Implemented setBufferScan and copyRects
89772d55a5 ACCESS: Implemented window size fields setup and copyBF2Vid
146f6b5df4 ACCESS: Fix rendering of scene background
ed645e435a ACCESS: Fix clearing pending images list each frame
28bfe73749 ACCESS: Implemented cmdSpecial script opcode
d6404a10ad ACCESS: Fix compiler warnings and deallocation crash on exit
79e743ba82 ACCESS: Fix more gcc compiler warnings
cf901ae142 ACCESS: Give default draw implementations for sprite drawing routines
f66f01bf89 ACCESS: Implemented player walk methods
9547efad77 ACCESS: Implemented player plotting methods
66b2d471cf ACCESS: Change walking errors to TODO comments
4a3ce2d27d ACCESS: Implementing checkScroll
e3687ea123 ACCESS: Refactored scroll direction code into separate methods
f8d64ae6bc ACCESS: Added code to update animations each frame
3475fda076 ACCESS: Fixes for updating animation frames
a347435f26 ACCESS: Added extra mouse handling to pollEvents
fab6d7883e ACCESS: Update TODOs
0b0d16d6a5 ACCESS: Add details in executeSpecial TODO
8648480258 ACCESS: Add a second parameter to doEstablish()
b3ab8a42a6 ACCESS: Implementing doCommand
dc5500e246 ACCESS: Cleanup of timer flags and some inventory logic
5ff004b2d8 ACCESS: Fix initialisation of player positioning and scaling values
fa099b8480 ACCESS: Implement routine for scaled drawing of player
bca9f14719 ACCESS: Fix display of mouse cursor
0b70783974 ACCESS: Fix selecting buttons from the bottom of the screen
a42e52fb5b ACCESS: Implemented code for clicking in room area
8d6c8ed452 ACCESS: Beginnings of code for text bubble drawing
f784b4efba ACCESS: Added data for font2 and font6x6
ff01ee6807 ACCESS: Added code for bubble box size calculations
1ab89400e5 ACCESS: Remove two unused variables
3e61eb9cc3 ACCESS: Implement some opcodes
404c7cd5d3 ACCESS: Split the bubble box code from Room into it's own file
77626b72a5 ACCESS: Add missing string parameters to bubble box methods
1b69da3d17 ACCESS: Implement some more opcodes
4ea9339d18 ACCESS: Implement cmdSetTex()
9393f6d755 ACCESS: Implemented bubble box drawing code
483bca3d96 ACCESS: Fixes for drawing bubble box backgrounds
be4639802c ACCESS: Fix positioning of bubble boxes
c576b201f6 ACCESS: Fix decoding of font data
a8a7018926 ACCESS: Fix showing bubble box text correctly
38acce33fd ACCESS: Add updateTimers so bubble boxes can be removed
9e98a1edcc ACCESS: Correct drawing the vertical edges of bubble boxes
7fef53b68c ACCESS: Implemented cmdEndObject
9150e1816c ACCESS: Shifted some Amazon specific opcodes to the AmazonScripts class
d31b27ba1b ACCESS: Partially implement cmdHelp
5ec8c445bd ACCESS: Fix player flickering
d570da065e ACCESS: Fix selecting location for player to walk to
17315a4dd7 ACCESS: Implemented wall checks for pathfinding
080a030116 ACCESS: Some initial pathfinding bugfixes
b6dc7a1dd4 ACCESS: Implement two more opcodes
ad0be89459 ACCESS: Simplified surface creation, added drawing for scaled flipped images
c4a3770cfe ACCESS: Bugfixes for walking
8d45ad265d ACCESS: Fix walking right
992ea95cd7 ACCESS: Implement two opcodes
b4f74b9b5e ACCESS: Use a variable delay of up to 20ms instead of a fix 50ms
6066afb020 ACCESS: Fix z ordering of sprites on the screen
23a442443f ACCESS: Implemented cmdNewRoom opcode
70b8efacfb ACCESS: Finish moving timer flag from bool to byte based on the assembly, modify some comments and TODOs
c7d4958984 ACCESS: Implement partially doEstablish
5870b18e17 ACCESS: Fix for collision detection
4e5eb04e47 ACCESS: Fix freeing player sprites when the scene changes
a8dd2defaa ACCESS: Added scene debugger command
afc41c7eec ACCESS: Added initial resources and detection entry for Martian Memorandum
966515a7d0 ACCESS: Fix room data loading for MM
8d1d1f6739 ACCESS: Fix displaying background in scrolling rooms
41df7734db ACCESS: Standardise plotting methods and added comments
e5130bcc6c ACCESS: Remapping of plotting methods
b4d2484633 ACCESS: Fixes for drawing scrolling scenes
44436def83 ACCESS: Stop player moving when scene changes
6343ff72c4 ACCESS: Fix cursor positioning in scrolled screens, and background restores
7aa2c7fe5c ACCESS: Beginnings of character/converse manager
31c8a524a3 ACCESS: More implementation of CharManager
1e2d79eb59 ACCESS: Implement more opcodes, stubbed beginning of video player
148eb972ab ACCESS: Fix fade outs
ec70f3feaf ACCESS: Fix graphic glitch when scrolling up
f98d4668d7 ACCESS: Improvements for horizontal scrolling
955df7a94c ACCESS: Start implementing loadEstablish
ee62d6c1cf ACCESS: In progress inventory display screen
7b1d0064fe ACCESS: Fix the loading of text in doEstablish
1073646c8e ACCESS: Fix negative seek in cmdSetVideoSound
89a3c43da1 ACCESS: More work on inventory screen setup
6774dd4246 ACCESS: Implement speakText()
e53417f91a ACCESS: Fix loading of inventory screen background
ce97ba5587 ACCeSS: Fix display of items in inventory screen
3e14e7b966 ACCESS: Fix selection of inventory items
d97cc677e1 ACCESS: Fix mapping of _useItem onto flags array
b7ea1133b4 ACCESS: Set hotspot for inventory item cursors to be their center
f993c8dd46 ACCESS: Improved right scrolling
89993e128f ACCESS: Split font code into a separate file
707a01cb38 ACCESS: Change font method parameter types
33cdeb7a40 ACCESS: Stub for printText method
8c059add8b ACCESS: Modify speakText so it takes a string array as parameter
7d0392aa83 ACCESS: Move _maxChars to asurface
a47b10c1c0 ACCESS: Add destination surface in speakText parameters
1568b4a433 ACCESS: Move Establish functions to Amazon engine, start implementing init4Quads
610644c4a1 ACCESS: Implement tileScreen
ff05b42e02 ACCESS: Implement updateSummary
1590f29d14 ACCESS: Use the hires version in Amazon CD
941b443195 ACCESS: Fix a crash in the intro
a0e54db081 ACCESS: Set Vesa mode when using the CD
455011c37e ACCESS: Fix typo in detection comment
c0a7852662 ACCESS: Refactor the file manager to return resource structures
35923890cc ACCESS: Fix incorrect use of delete[] on Resources
3bbec487a5 ACCESS: Fixes for memory leaks
5abe5b8993 ACCESS: Fix loading of room playfield data
819cad3a17 ACCESS: Implemented setVideo
e57d7e8782 ACCESS: Implemented playVideo
1d8f23985a ACCESS: Implement loadSounds
729f03f42c ACCESS: Fixes for playVideo
661a5694b4 ACCESS: Implemented cmdVideoEnded
a47457084f ACCESS: Add event polling to cmdVideoEnded to make videos play correctly
d31a0f152f ACCESS: Fix background display during character conversations
d2cb9d4c43 ACCESS: Implemented cmdFreeSound
bbe7616a19 ACCESS: Add event polling to cmdTexChoice so conversations work
0ef365ab02 ACCESS: Fix errors in loadScreen since resource refactoring
8b9faf7de5 ACCESS: Add synchronize method for savegames
8352808322 ACCESS: Added code for reading/writing savegame headers and list saves
f12fa2de07 ACCESS: Implement saving and loading savegames
949033ea92 ACCESS: Implement loading savegames from launcher
2cca520465 ACCESS: Add new support for mouse wheel for cycling through cursors
d38839d642 ACCESS: Fix selecting the help cursor
67e52da359 ACCESS: Fix non-scaled sprites appearing on-screen in scrolling scenes
be8d719a1a ACCESS: Fix ending game when a conversation is active
f869019d30 ACCESS: Implemented cmdDead
adddb1377d ACCESS: Fix loading sound in cmdLoadSound
aa755b9f3f ACCESS: Fix loadEstablish for the CD version
2cc6d9299a ACCESS: Add a check to work around a difference in hardcoded data between the CD and the floppy version
469e327360 ACCESS: Add a safeguard to avoid a potential issue when alternating stream and raw data use
36b87d39ca ACCESS: Add a missing ->data() on _eseg
b39d7df7cb ACCESS: Fix background loading in doEstablish
9d3460e9f7 ACCESS: Implement printText()
c092e06652 ACCESS: Fix parameter usage in doEstablish
78bf011a8b ACCESS: Fix playSound stub
2f5fb206d3 ACCESS: Further cleanup of doEstablish parameters
b5b298a5d5 ACCESS: Fix playSound call
f8778a5e04 ACCESS: Fix getLine when \r occurs just after maximum line width reached
e854ec1bc9 ACCESS: Fix freeing _eseg correctly
984858b638 ACCESS: Fix an issue in checkCode
6f03127512 ACCESS: Implement setInactive and mWhile
5016b2e768 ACCESS: Implement a coupld of special commands
7a1650b3d3 ACCESS: Add missing call to boatWalls
d37534fa9b ACCESS: Implement mWhile1
9accfdab6f ACCESS: Implement mWhile2 and plotInactive, change _inactive from Resource* to ImageEntry
2afca5a06e ACCESS: Fix bool/int comparisons and assignments
a597838490 ACCESS: Implement guard()
5a6a44f1c6 ACCESS: Wait for keypress in speakText if voice is turned off
374669d7c3 ACCESS: Fix scene establishment paging when there are multiple pages
e9c003f306 ACCESS: Fix display of paged text in doEstablish calls
59c4c93c00 ACCESS: Add needed event polling to cmdCheckTimer
3627ff51aa ACCESS: Implemented code for cmdChapter
fb6d9230dc ACCESS: Add missing table to savegames
386aae3ffa ACCESS: Workaround for background column rendering bug in original
21c1d0f920 ACCESS: Workaround for background rendering bug in original
ae24bf54b4 ACCESS: Fixes for startChapter
48edbf1e34 ACCESS: Fixed clearing talk bubbles during conversations
7e4d76b1fb ACCESS: Implemented cmdWait
f3063a13f0 ACCESS: Implement palette cycling script commands
c038452588 ACCESS: Add missing _startup checks to palette cycling opcodes
335acfac89 ACCESS: Implement newMusic()
2805dcaa7b ACCESS: Implement freeSounds
7a178098a7 ACCESS: Remove a useless check, comment out some code related to original debugging
32bbfe3f60 ACCESS: Fix a little bug in walkUpRight()
958dd0b77b ACCESS: Hood newMusic in cmdSpecial
e46c0ac66a ACCESS: Fix resetting cursor after conversations
38f010f96f ACCESS: Implement mWhileFly
43e8e90590 ACCESS: Don't show inventory items that have been used
d5ddd22681 ACCESS: Implement mWhileFall
a7d88af24d ACCESS: Fix tiny bug in mWhileFly
fb686191a8 ACCESS: Fix initialisation of Y positioning in rooms with vertical scrolling
2c700cc6cd ACCESS: Start implementing mWhileJWalk()
b8c95e653d ACCESS: Implement pan()
6ceda069c7 ACCESS: Beginnings of inventory dragging for combining items
b0653e1c92 ACCESS: Fix redrawing during inventory item dragging
b5ad2b9db5 ACCESS: Inventory item merge zoom partially working
0a8b8d9e94 ACCESS: Fix inventory item combining zoom logic
8a31fca61e ACCESS: Implement mWhileDoOpen
47304849c7 ACCESS: Fix malformed inventory item description
712261f02a ACCESS: Fix entire inventory disappearing after combining items
63bacba2d9 ACCESS: Add enum for inventory item states
dc218d53ef ACCESS: Merge the sound resource and priority lists
6434ace3b6 ACCESS: Fix not being able to save in room 9
fddff687da ACCESS: Workaround for original game vertical room scrolling
e7818639af ACCESS: Workaround not being able to leave scene 9 in Amazon to the south
aea906f7d3 ACCESS: Implemented chapter debug command
d23d95b912 ACCESS: Fix display of cutscene at the end of chapter 3
d6963d8d09 ACCESS: Simplification of logic for selectively applying loaded palettes
876ce794a1 ACCESS: Fix crash when exiting game in the middle of a chapter start
6f39c07324 ACCESS: Fix crash when starting scene 16
8ef3d55151 ACCESS: Fix scene fade ins
985ad55559 ACCESS: Airplane flight cutscene is now partially working
bbaea32386 ACCESS: Fixes for flying plane cutscene
d7cf570132 ACCESS: Fix restoring talk bubbles where right edge is a bit over screen edge
4448929812 ACCESS: Fixes for selecting bottom buttons in conversation screen
4ce87a51a0 ACCESS: Fix restoring screen after offering a character an inventory item
6390f54d4b ACCESS: Fix crash at end of cmdDead
304db8ee6f ACCESS: Add some code to display scene number & description
dd2bfdd47f ACCESS: Fix compilation warning by adding a dummy inventory combo array for Martian
0df4c903c7 ACCESS: Add some safeguards in LoadScene debugger command
ea20633081 ACCESS: Fix cutscene of pilot falling out of plane
7ce1da3ba4 ACCESS: Some cleanup of remaining game cutscenes code
0ed120b9ff ACCESS: Fix buffer source when clearing speech bubbles
38edbfb4bc ACCESS: Little cleanup in roomMenu
26b632a9eb ACCESS: Fix display in cmdDeath()
0e01c3623a ACCESS: Fixes to pan method
878038fe07 ACCESS: Fix redundant pointer references in adding items to _images list
340a3fa91b ACCESS: Fix player walking in jungle cutscene
4d82191f34 ACCESS: Fix crashes for scene debugger command when launched from cmdCheckTimer
a97bbb86c4 ACCESS: Fix incorrect screen draw during setup of bubble boxes
fa46257a77 ACCESS: Fix item Z ordering issue causing flickering in airplane rear scene
2fe5957393 ACCESS: Start working on ANT()
b874ddd315 ACCESS: Refactor ANT
c3660acf63 ACCESS: Implement plotPit()
15da1cc639 ACCESS: Fix some parameters in ANT
ba8f4941b5 ACCESS: Add missing code in guard()
37431dcedf ACCESS: Implement guardSee and setGuardFrame
c74821161b ACCESS: Fix some issues in plotTorchSpear(), in plotPit() and in ANT()
4ca5cc5ab4 ACCESS: Implement chkVLine and chkHLine
c4a5c36290 ACCESS: Fix crash when talking to pilot on the plane
2daa96e284 ACCESS: Fix crash in conversation screen when clicking outside response boxes
96cc1e3ac9 ACCESS: Implement setVerticalCode and setHorizontalCode used by the guard scene
bacb9badf8 ACCESS: Fix compilation warning
339847872b ACCESS: Fix the call of doIntroduction
4e1394c8e3 ACCESS: Fix intro countdown, add splashscreen and loading of scene 0
731d7d2039 ACCESS: Add more intro code, including credit scrolling
1ad11d091f ACCESS: Simplify doIntroduction()
f70012a115 ACCESS: Replace doOpening by mWhileDoOpen, move openObj to Amazon Resources
a0294b6338 ACCESS: Move setupGame before doIntroduction to fix a crash
44e7051b95 ACCESS: Fix display height of text in chapter introduction
8e483e037f ACCESS: Fix the handling of the very last line of a text in getLine
31fc8fdaa1 ACCESS: Add a hack in order to make the first screen visible
8939d657f7 ACCESS: Fix loading animation data in mWhileDoOpen
a01ddaeb1b ACCESS: Fix loading correct sprite resource in mWhileDoOpen
b2e67a69c6 ACCESS: Fix incorrect loading of exra cells during room load
8e45582492 ACCESS: Add extra shouldQuit checks during title sequence
e9e19446d8 ACCESS: Implement doTent
bc050a549c ACCESS: Implemented cmdCheckVFrame opcode
43f7fe9182 ACCESS: Implement doCast
690bea4c88 ACCESS: Trigger quit game at the end of doCast
7427f29e85 ACCESS: Implement mWhileJWalk2 (WIP)
60ee5456c9 ACCESS: Implement jungleMove
968bfec067 ACCESS: Workaround for original setting animations when none is loaded
5de214dfc4 ACCESS: Implement mWhileDownRiver
e1e97ec9ff ACCESS: Start the implementation of RIVER (WIP)
5cfdc983c3 ACCESS: Fix loading of animation at end of mWhileDoOpen
237404fa70 ACCESS: Some more work on RIVER (still WIP)
1d70d61d2b ACCESS: Implement setRiverPan
1d60368724 ACCESS: Tweaks to mWhileDoOpen and fixes to pan method
30f602b6cb ACCESS: Further fixes for panning
c1b3db90c4 ACCESS: Implement riverSound
7fbd145f5d ACCESS: Use a new structure instead of a byte array for River Objects
ff003f3b65 ACCESS: Fix the jungle walk 2 cutscene
ada5ca20f9 ACCESS: Reorganise Amazon game-specific variables that are saved
1cbaab55cd ACCESS: Split cmdDead in order to use it in RIVER
a0beb08984 ACCESS: Refactor _inactive from AccessEngine to AmazonEngine
9e84be664c ACCESS: Implement a couple of script functions
80ec09d0ae ACCESS: Rename a function
74a61d1118 ACCESS: Fix the ability to switch between players
ddfe739554 ACCESS: Implement copyVideo
08c6539900 ACCESS: Implement cmdEndVideo
d2d75dd4a7 ACCESS: Workaround for original game bug doing inventory check
a9131a93c3 ACCESS: Fix freeing alternate player sprites resource
cdb2159ba2 ACCESS: Workaround for original Amazon bug trying to draw player in
36a3c5d234 ACCESS: Implement riverJumpTest
74a15d6599 ACCESS: Fix the mWhileDownRiver cutscene
cc07c2e5a2 ACCESS: Implement two more RIVER related functions
68dc425cd4 ACCESS: Implemented buildRow for vertical screen scrolling
0c4fdc6a48 ACCESS: Implement some more RIVER functions
51ccd0c1fb ACCESS: Implement moveCanoe
f1b99b0ede ACCESS: Implement plotRiver
8eeb5bd8e6 ACCESS: Refine scene 9 workaround to stop movement problems on ship
b01f5d61d7 ACCESS: Fix vertically scrolling up the screen
9fa0fc845e ACCESS: Fix 'bounce' when reaching left end of a horizontal scrolling scene
5674bed27b ACCESS: Implement updateObstacles
6e2d63e4cd ACCESS: Implement checkRiverCollide()
a8c99d1986 ACCESS: Some work on drawHelp (WIP)
cc8a8bfddd ACCESS: Refactored Amazon specific player loading into new AmazonPlayer class
7a691f38cf ACCESS: Fix guard movement logic on slaver boat
2ea4601589 ACCESS: Implement helpTitle
79fa346ca0 ACCESS: Implement calcIQ
451a29ada5 ACCESS: Fix character in first screen when the intro is played
0a28a77e1a ACCESS: Silent warning
486b7d7e04 ACCESS: Add detection for Amazon English Demo
9cd2bbf6bd ACCESS: Move slaver guard functions into the Guard class
84d500a35a ACCESS: Fix flickering slaver guard
0cafe2719d ACCESS: Fix for proper vertical scrolling on the ship
953321cc26 ACCESS: Fix a glitch in the intro, add a workaround for a crash, fix a logic flaw
fde1ea9d0e ACCESS: Improve usage of ImageEntry _flags IMGFLAG enum
d8c97d259b ACCESS: add code to replace the checks on KEYBUFCNT
89b20c618f ACCESS: Fix to correctly draw partly off-screen sprites
7434c764c6 ACCESS: gcc compilation fixes
f75fa68c05 ACCESS: Add a replacement of configSelect, currently just initializing _hintLevel
4c71b12e02 ACCESS: Fix memory leaks
abb4b9d1e6 ACCESS: Fix regression in bd004bd6f3b960e36756248d8e44bfdf955fdb52
f0f19dbea0 ACCESS: Fix for vertical scrolling after using inventory screen
bb93268ee2 ACCESS: Fix left button flag beig stuck after saving & loading games
f6a1faa5e4 ACCESS: Fix check for scene area that can be clicked in
64b45e68aa ACCESS: Fix loading or exiting game when Maya is active player
3be3cb1ac2 ACCESS: Cleanup of room _function and river canoe movement
c6042e2e25 ACCESS: Minor cleanups of canoe code
b1ea7879f3 ACCESS: Fix saving/loading using ScummVM GMM in the river scene
3f44538441 ACCESS: Fix array sizes for panning objects fields
2735101179 ACCESS: Finish the implementation of cmdHelp (still a redraw issue)
62a7619017 ACCESS: Better fix for drawing partially off-screen sprites
bfbce8c6a6 ACCESS: Cleanup of updateObstacles
abecac94d4 ACCESS: Fix to restrict river canoe to 7 allowable 'lanes'
eeb9d63a19 ACCESS: Don't decrease timers whilst text dialogs are showing
740df9b42a ACCESS: Further tweaks to timer skipping
e332218568 ACCESS: Workaround for Exit/walk icon in massacre site scene
1716cd9b30 ACCESS: Major refactoring of Amazon logic into their own classes
01e9214c7d ACCESS: Only save river scene fields when actually in the river scene
2151919434 ACCESS: Remove accidental resetting of _vm pointers
b478b05df2 ACCESS: Move _saveRiver from engine to River class
ec44c0504f ACCESS: Remove unneeded dummy field syncs from serializer
01124c3378 ACCESS: Moved help table data from AccessEngine to AmazonEngine
eadaf53486 ACCESS: Remove unused _travel and _ask fields
16a8d705ba ACCESS: Fix restoring game scene after using help
c42666f3d2 ACCESS: Add some code for VGA mode in cmdHelp
a8e111fae4 ACCESS: Refactor opening scenes logic into Opening class
d37593d5c1 ACCESS: Replaced delayMilli calls to use pollEventsAndWait
63bcd2ebcb ACCESS: Remove second character sprite in Dead command
a3801df518 ACCESS: First implementation of Sound playback for both CD and Floppy version. Courtesy of m_kiewitz
11e920f427 ACCESS: Split SoundManager and MusicManager
0277d1654d ACCESS: Remove two unused variables
9604da9da3 ACCESS: Rename _Eseg
6e8f29c15b ACCESS: Implement stopSound
f364782d05 ACCESS: Some rework in MusicManager
11870c4144 ACCESS: Implement music player (WIP)
0028556d6c ACCESS: improve the sound during the title countdown
0eeb5b5bf3 ACCESS: Fix the horizontal scrolling in intro, add some calls to clearEvents
954a0d0f9f ACCESS: Remove useless (and commented) code
66f9d71f1d ACCESS: Add some code for the intro (WIP)
f968553329 ACCESS: Fix RoomInfo for the demo version, fix a typo in a comment
8267b5d2ab ACCESS: Skip the unknown midi file format used by the demo
860f7c717c ACCESS: Implement the demo logic in doTitle
2413fd0798 ACCESS: Skip the end of the full intro in the demo
c6322702e6 ACCESS: Fix doEstablish for the floppy and for the demo versions
cbd772ea5f ACCESS: Avoid the call to loadScreen in mWhileDownRiver
771bcc8efd ACCESS: Add warnings about opcodes changed in the demo version
580fec468f ACCESS: Implement loadNSound, add a warning about another special opcode used by the demo
e35e6df93a ACCESS: Rename cmdObject
7571fdd4b1 ACCESS: Add some more Demo opcodes
889a564e73 ACCESS: Fix definition of river data structures
4c2ab8b297 ACCESS: Remove misnamed duplicate _screenVirtX field
c1e80440b5 ACCESS: Fix the formatting of a bunch of else statements
93b1516f9f ACCESS: Fix display of rocks in the river arcade scene
f2cd2ee5b3 ACCESS: Move river death flags from engine to River class
06f99158f0 ACCESS: Debounce any mouse press when showing death screen
3c97961fd2 ACCESS: Fix the display in the floppy and demo version by removing the inventory pre-rendering
84ba0df9b2 ACCESS: Janitorial
1f42800e0c ACCESS: Further cleanup of river obstacles checks
c41d7bab2b ACCESS: Add some data for the character info used by the demo
59099a7205 ACCESS: Fix cmdDead for the demo
84d77b7daf ACCESS: Fix the inventory behavior in the floppy and demo version
67b3304f71 ACCESS: Clean up keyboard control
7cd7bb9b54 ACCESS: Implement player keyboard movement
40b8417296 ACCESS: Correct down-right player movement
a1e5e8be94 ACCESS: Cleaned up event handling for scene establish text display
bf361715e0 ACCESS: Simply river savegame fields
b864b84635 ACCESS: Fix the end of the demo
3cf0893979 ACCESS: Add a cheat mode which currently skips the guard in chapter 8
07456932d4 ACCESS: Add a debug channel for the sound & music handling
8e90ef2ec7 ACCESS: Minor river code clean up and saving fix
86bee5b48e ACCESS: Fix function key mapping for game icons
7508e7b5f8 ACCESS: Minor River cleanup
960a787c03 ACCESS: Reduce the scope of a variable in Inventory
9ef60f3f33 ACCESS: Fix a bug in plotInactive
35922c28c8 ACCESS: Add a hack to fake queueing
b20c755f46 ACCESS: Fix progressing within the river
c69480f6bf ACCESS: Fix event pollig in death flashing loop
8ee8444779 ACCESS: Skip chapter speech for the non-CD versions
8d97dc9891 ACCESS: stops the SFX sounds in the intro at the end of the countdown
98685b9358 ACCESS: Add some more checks for the floppy version
1870e31e25 ACCESS: Add a comment related to the CD specific files
beba0b40d5 ACCESS: Minor cleanup of _saveRiver flag
cdc27778c0 ACCESS: Add a button to allow skipping the river scene
80dfc3537d ACCESS: Fix _help3 initialization
538782e14e ACCESS: Get rid of the use of 'this' in constructor
8517209bcb ACCESS: Implement restart after death
b1d5359fc6 ACCESS: Minor formatting for debugger error messages
781c6ff8c4 ACCESS: Initial enum cleanup for Ant fields
547f3debb2 ACCESS: Separate timer updates from frame updates, and overall delay cleanup
c2e5dd8487 ACCESS: Fix positioning of Ant in pit scene
41d0908606 ACCESS: Fix death cell list data
a6cc9250d3 ACCESS: Remove a useless variable, some renaming
c82fb8c957 ACCESS: Reduce screen pointer usage in amazon logic
5520a76384 ACCESS: Fix speakText behavior
b1f63a9985 ACCESS: Fix for player movement and stab action in pit scene
712a18d050 ACCESS: Fix compilation errors reported by Criezy
de63e2afbc ACCESS: Properly indent some code in playSound
330cb5fb07 ACCESS: Remove old dummy unused fields from savegame
98889efae5 ACCESS: Beginnings of dirty rect handling for screen
9314daa11c ACCESS: Dirty rect handling for bubble boxes
310853a285 ACCESS: Add dirty rects when plotting images to the screen
2cdd05306c ACCESS: Dirty rect handling for conversation videos
93979484f6 ACCESS: Fix for background redraws during conversations
924f2abdf4 ACCESS: Dirty rect handling for intro screens
fda4ef620f ACCESS: Add dirty rect handling for font display
831a3f7f35 ACCESS: Implement dirty rect merging
27ed5246b8 ACCESS: Use the same (weird) key mapping than in the original game
dcc6ceb117 ACCESS: Fix icon when unselecting a menu button
66bf0ec741 ACCESS: Some refactoring concerning the mouse cursor
450deabd45 ACCESS: Fix a couple of typos in comments
37aefd08f2 ACCESS: Add enum for inventory items referred in hardcoded logic
e806c63332 ACCESS: Formatting fixes
0e4a4a28ad ACCESS: Fix distortion occurring at left edge of jungle scrolling in introduction
8120cbfde3 ACCESS: Remove extra qualification stupidly accepted by MSVC
64435ef25f ACCESS: Fix cmdFreeSound, which fixes the sound played during the death animation
c3312749ff ACCESS: Fix crash when getting randomly shot in the cabin
7ae4fca38e ACCESS: Fix foreground parallex in opening scene
3a1203ff73 ACCESS: Use a while statement as suggested by _sev in the merge request
56d28bc4c8 ACCESS: Split doCredit in two, putting demo code in a separate function
1496ad9717 ACCESS: Split mouse data per line
82dfe2a5bc ACCESS: Use writeString in writeSavegameHeader
c8d6370edf ACCESS: Fix broken file header
492d974550 ACCESS: Some more polishing in the file headers
7d73acbccc ACCESS: Remove useless defines
9daf9a30c0 ACCESS: Modify the indentation of constructor when it's multiline
67a40fd9b0 ACCESS: Add missing space before semicolumn in constructors
df7fa78a86 ACCESS: Fix three out of bounds
ce1f04b1d5 ACCESS: Get rid of hardcoded size when using Common::Fill
fe627c5ce1 ACCESS: Fix spacing around semicolumn in class definitions
e141da25e8 ACCESS: Use a uint instead of a int in a loop based on size()
bb01fa31f8 ACCESS: Constify some resources
c57f191960 ACCESS: Constify some resources in MM too
223038924b ACCESS: Get rid of a goto
240b9dcaeb ACCESS: Format Direction enum as suggested by LordHoto
207c4012ad ACCESS: replace an assert by an error as suggested by LordHoto
79b51f20e4 ACCESS: Use clear to empty Common::String variables
cd4183a463 ACCESS: Fix indentation of METHODS in animate()
a990323703 ACCESS: Format the definition of ImagerFlag
beba3cd3f2 ACCESS: Fix indentation issue pointed out by _sev
c11b6e3eb3 ACCESS: Add original engine dates
8fe8cf8e43 ACCESS: Use AD_ENTRY1s in detection tables
20bcc7f7aa ACCESS: Rename CMDPUSHLOCATION
7895c5408c ACCESS: Constify general messages
3fca9d42f3 ACCESS: Use  Common::String to display bubble box text
864cab5e47 ACCESS: Fix issue related to demo-only (and unused afawk) opcodes
95aa9a13a6 ACCESS: Refactor most of ASurface statics to instance variables
93bbe3a45e ACCESS: Manually implement ASurface::copyFrom for performance
3c2ac653b2 Merge pull request #548 from dreammaster/access


Commit: 8480f53d6005b5873964ca1015644ae6925e6ede
    https://github.com/scummvm/scummvm/commit/8480f53d6005b5873964ca1015644ae6925e6ede
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-07-29T21:02:28-04:00

Commit Message:
ACCESS: Initial engine skeleton

Changed paths:
  A engines/access/access.cpp
  A engines/access/access.h
  A engines/access/configure.engine
  A engines/access/debugger.cpp
  A engines/access/debugger.h
  A engines/access/detection.cpp
  A engines/access/detection_tables.h
  A engines/access/module.mk



diff --git a/engines/access/access.cpp b/engines/access/access.cpp
new file mode 100644
index 0000000..f3615e1
--- /dev/null
+++ b/engines/access/access.cpp
@@ -0,0 +1,61 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "common/scummsys.h"
+#include "common/config-manager.h"
+#include "common/debug-channels.h"
+#include "common/events.h"
+#include "engines/util.h"
+#include "access/access.h"
+
+namespace Access {
+
+AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc) :
+		_gameDescription(gameDesc), Engine(syst), _randomSource("Access") {
+	_debugger = nullptr;
+}
+
+AccessEngine::~AccessEngine() {
+	delete _debugger;
+}
+
+void AccessEngine::initialize() {
+	// Set up debug channels
+	DebugMan.addDebugChannel(kDebugPath, "Path", "Pathfinding debug level");
+	DebugMan.addDebugChannel(kDebugScripts, "scripts", "Game scripts");
+	DebugMan.addDebugChannel(kDebugGraphics, "graphics", "Graphics handling");
+
+	_debugger = new Debugger(this);
+}
+
+Common::Error AccessEngine::run() {
+	initGraphics(320, 200, false);
+	initialize();
+
+	return Common::kNoError;
+}
+
+int AccessEngine::getRandomNumber(int maxNumber) {
+	return _randomSource.getRandomNumber(maxNumber);
+}
+
+} // End of namespace Access
diff --git a/engines/access/access.h b/engines/access/access.h
new file mode 100644
index 0000000..f46cf00
--- /dev/null
+++ b/engines/access/access.h
@@ -0,0 +1,94 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef ACCESS_ACCESS_H
+#define ACCESS_ACCESS_H
+
+#include "common/scummsys.h"
+#include "common/system.h"
+#include "common/error.h"
+#include "common/random.h"
+#include "common/util.h"
+#include "engines/engine.h"
+#include "graphics/surface.h"
+#include "access/debugger.h"
+
+/**
+ * This is the namespace of the Access engine.
+ *
+ * Status of this engine: In Development
+ *
+ * Games using this engine:
+ * - Amazon: Guardians of Eden
+ */
+namespace Access {
+
+#define DEBUG_BASIC 1
+#define DEBUG_INTERMEDIATE 2
+#define DEBUG_DETAILED 3
+
+enum AccessDebugChannels {
+	kDebugPath      = 1 << 0,
+	kDebugScripts	= 1 << 1,
+	kDebugGraphics	= 1 << 2
+};
+
+enum {
+	GType_Amazon = 0,
+	GType_MeanStreets = 1
+};
+
+struct AccessGameDescription;
+
+
+class AccessEngine : public Engine {
+private:
+	const AccessGameDescription *_gameDescription;
+	Common::RandomSource _randomSource;
+
+	/**
+	 * Handles basic initialisation
+	 */
+	void initialize();
+protected:
+	// Engine APIs
+	virtual Common::Error run();
+	virtual bool hasFeature(EngineFeature f) const;
+public:
+	Debugger *_debugger;
+public:
+	AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc);
+	virtual ~AccessEngine();
+
+	uint32 getFeatures() const;
+	Common::Language getLanguage() const;
+	Common::Platform getPlatform() const;
+	uint16 getVersion() const;
+	uint32 getGameID() const;
+	uint32 getGameFeatures() const;
+
+	int getRandomNumber(int maxNumber);
+};
+
+} // End of namespace Access
+
+#endif /* ACCESS_ACCESS_H */
diff --git a/engines/access/configure.engine b/engines/access/configure.engine
new file mode 100644
index 0000000..b1defce
--- /dev/null
+++ b/engines/access/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 access "Access" no
diff --git a/engines/access/debugger.cpp b/engines/access/debugger.cpp
new file mode 100644
index 0000000..e92e340
--- /dev/null
+++ b/engines/access/debugger.cpp
@@ -0,0 +1,33 @@
+/* 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 "common/file.h"
+#include "access/access.h"
+#include "access/debugger.h"
+
+namespace Access {
+
+Debugger::Debugger(AccessEngine *vm) : GUI::Debugger(), _vm(vm) {
+	registerCmd("continue",		WRAP_METHOD(Debugger, cmdExit));
+}
+
+} // End of namespace Access
diff --git a/engines/access/debugger.h b/engines/access/debugger.h
new file mode 100644
index 0000000..dcf49c4
--- /dev/null
+++ b/engines/access/debugger.h
@@ -0,0 +1,45 @@
+/* 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 ACCESS_DEBUGGER_H
+#define ACCESS_DEBUGGER_H
+
+#include "common/scummsys.h"
+#include "gui/debugger.h"
+
+namespace Access {
+
+class AccessEngine;
+
+class Debugger : public GUI::Debugger {
+private:
+	AccessEngine *_vm;
+protected:
+public:
+public:
+	Debugger(AccessEngine *vm);
+	virtual ~Debugger() {}
+};
+
+} // End of namespace Access
+
+#endif	/* ACCESS_DEBUGGER_H */
diff --git a/engines/access/detection.cpp b/engines/access/detection.cpp
new file mode 100644
index 0000000..aca594d
--- /dev/null
+++ b/engines/access/detection.cpp
@@ -0,0 +1,146 @@
+/* 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 "access/access.h"
+
+#include "base/plugins.h"
+#include "common/savefile.h"
+#include "common/str-array.h"
+#include "common/memstream.h"
+#include "engines/advancedDetector.h"
+#include "common/system.h"
+#include "graphics/colormasks.h"
+#include "graphics/surface.h"
+
+#define MAX_SAVES 99
+
+namespace Access {
+
+struct AccessGameDescription {
+	ADGameDescription desc;
+
+	int gameID;
+	uint32 features;
+};
+
+uint32 AccessEngine::getGameID() const {
+	return _gameDescription->gameID;
+}
+
+uint32 AccessEngine::getGameFeatures() const {
+	return _gameDescription->features;
+}
+
+uint32 AccessEngine::getFeatures() const {
+	return _gameDescription->desc.flags;
+}
+
+Common::Language AccessEngine::getLanguage() const {
+	return _gameDescription->desc.language;
+}
+
+Common::Platform AccessEngine::getPlatform() const {
+	return _gameDescription->desc.platform;
+}
+
+} // End of namespace Access
+
+static const PlainGameDescriptor AccessGames[] = {
+	{"Access", "Access"},
+	{"amazon", "Amazon: Guardians of Eden"},
+	{0, 0}
+};
+
+#include "access/detection_tables.h"
+
+class AccessMetaEngine : public AdvancedMetaEngine {
+public:
+	AccessMetaEngine() : AdvancedMetaEngine(Access::gameDescriptions, sizeof(Access::AccessGameDescription), AccessGames) {
+		_maxScanDepth = 3;
+	}
+
+	virtual const char *getName() const {
+		return "Access Engine";
+	}
+
+	virtual const char *getOriginalCopyright() const {
+		return "Access (c)";
+	}
+
+	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;
+	SaveStateDescriptor querySaveMetaInfos(const char *target, int slot) const;
+};
+
+bool AccessMetaEngine::hasFeature(MetaEngineFeature f) const {
+	return
+	    (f == kSupportsListSaves) ||
+		(f == kSupportsLoadingDuringStartup) ||
+		(f == kSupportsDeleteSave) ||
+		(f == kSavesSupportMetaInfo) ||
+		(f == kSavesSupportThumbnail);
+}
+
+bool Access::AccessEngine::hasFeature(EngineFeature f) const {
+	return
+		(f == kSupportsRTL) ||
+		(f == kSupportsLoadingDuringRuntime) ||
+		(f == kSupportsSavingDuringRuntime);
+}
+
+bool AccessMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const {
+	const Access::AccessGameDescription *gd = (const Access::AccessGameDescription *)desc;
+	if (gd) {
+		*engine = new Access::AccessEngine(syst, gd);
+	}
+	return gd != 0;
+}
+
+SaveStateList AccessMetaEngine::listSaves(const char *target) const {
+	SaveStateList saveList;
+
+	return saveList;
+}
+
+int AccessMetaEngine::getMaximumSaveSlot() const {
+	return MAX_SAVES;
+}
+
+void AccessMetaEngine::removeSaveState(const char *target, int slot) const {
+	Common::String filename = Common::String::format("%s.%03d", target, slot);
+	g_system->getSavefileManager()->removeSavefile(filename);
+}
+
+SaveStateDescriptor AccessMetaEngine::querySaveMetaInfos(const char *target, int slot) const {
+	return SaveStateDescriptor();
+}
+
+
+#if PLUGIN_ENABLED_DYNAMIC(ACCESS)
+	REGISTER_PLUGIN_DYNAMIC(ACCESS, PLUGIN_TYPE_ENGINE, AccessMetaEngine);
+#else
+	REGISTER_PLUGIN_STATIC(ACCESS, PLUGIN_TYPE_ENGINE, AccessMetaEngine);
+#endif
diff --git a/engines/access/detection_tables.h b/engines/access/detection_tables.h
new file mode 100644
index 0000000..9100e52
--- /dev/null
+++ b/engines/access/detection_tables.h
@@ -0,0 +1,47 @@
+/* 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.
+ *
+ */
+
+namespace Access {
+
+static const AccessGameDescription gameDescriptions[] = {
+	{
+		// Amazon Guadians of Eden
+		{
+			"amazon",
+			0,
+			{
+				{"amazon", 0, "00000000000000000000000000000000", 1},
+				AD_LISTEND
+			},
+			Common::EN_ANY,
+			Common::kPlatformDOS,
+			ADGF_NO_FLAGS,
+			GUIO1(GUIO_NONE)
+		},
+		GType_Amazon,
+		0
+	},
+
+	{ AD_TABLE_END_MARKER, 0, 0 }
+};
+
+} // End of namespace Access
diff --git a/engines/access/module.mk b/engines/access/module.mk
new file mode 100644
index 0000000..c61ab50
--- /dev/null
+++ b/engines/access/module.mk
@@ -0,0 +1,14 @@
+MODULE := engines/access
+
+MODULE_OBJS := \
+	access.o \
+	debugger.o \
+	detection.o
+
+# This module can be built as a plugin
+ifeq ($(ENABLE_ACCESS), DYNAMIC_PLUGIN)
+PLUGIN := 1
+endif
+
+# Include common rules
+include $(srcdir)/rules.mk


Commit: 83f55f737b3eab7be2236de1bf31035024400e43
    https://github.com/scummvm/scummvm/commit/83f55f737b3eab7be2236de1bf31035024400e43
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-07-29T22:49:45-04:00

Commit Message:
ACCESS: Main engine skeleton and events manager

Changed paths:
  A engines/access/events.cpp
  A engines/access/events.h
    engines/access/access.cpp
    engines/access/access.h
    engines/access/module.mk



diff --git a/engines/access/access.cpp b/engines/access/access.cpp
index f3615e1..23b8fb9 100644
--- a/engines/access/access.cpp
+++ b/engines/access/access.cpp
@@ -32,10 +32,12 @@ namespace Access {
 AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc) :
 		_gameDescription(gameDesc), Engine(syst), _randomSource("Access") {
 	_debugger = nullptr;
+	_events = nullptr;
 }
 
 AccessEngine::~AccessEngine() {
 	delete _debugger;
+	delete _events;
 }
 
 void AccessEngine::initialize() {
@@ -45,6 +47,7 @@ void AccessEngine::initialize() {
 	DebugMan.addDebugChannel(kDebugGraphics, "graphics", "Graphics handling");
 
 	_debugger = new Debugger(this);
+	_events = new EventsManager(this);
 }
 
 Common::Error AccessEngine::run() {
diff --git a/engines/access/access.h b/engines/access/access.h
index f46cf00..ef9960e 100644
--- a/engines/access/access.h
+++ b/engines/access/access.h
@@ -31,6 +31,7 @@
 #include "engines/engine.h"
 #include "graphics/surface.h"
 #include "access/debugger.h"
+#include "access/events.h"
 
 /**
  * This is the namespace of the Access engine.
@@ -64,6 +65,11 @@ class AccessEngine : public Engine {
 private:
 	const AccessGameDescription *_gameDescription;
 	Common::RandomSource _randomSource;
+	
+	Graphics::Surface _buffer1;
+	Graphics::Surface _buffer2;
+	Graphics::Surface _vidbuf;
+	Graphics::Surface _plotBuf;
 
 	/**
 	 * Handles basic initialisation
@@ -75,6 +81,7 @@ protected:
 	virtual bool hasFeature(EngineFeature f) const;
 public:
 	Debugger *_debugger;
+	EventsManager *_events;
 public:
 	AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc);
 	virtual ~AccessEngine();
diff --git a/engines/access/events.cpp b/engines/access/events.cpp
new file mode 100644
index 0000000..47908ff
--- /dev/null
+++ b/engines/access/events.cpp
@@ -0,0 +1,106 @@
+/* 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 "common/scummsys.h"
+#include "graphics/cursorman.h"
+#include "common/events.h"
+#include "engines/util.h"
+#include "access/access.h"
+#include "access/events.h"
+
+namespace Access {
+
+EventsManager::EventsManager(AccessEngine *vm): _vm(vm) {
+	_cursorId = CURSOR_NONE;
+	_frameCounter = 10;
+	_priorFrameTime = 0;
+	_leftButton = false;
+}
+
+EventsManager::~EventsManager() {
+}
+
+void EventsManager::setCursor(CursorType cursorId) {
+	_cursorId = cursorId;
+}
+
+void EventsManager::showCursor() {
+	CursorMan.showMouse(true);
+}
+
+void EventsManager::hideCursor() {
+	CursorMan.showMouse(false);
+}
+
+bool EventsManager::isCursorVisible() {
+	return CursorMan.isVisible();
+}
+
+void EventsManager::pollEvents() {
+	checkForNextFrameCounter();
+
+	Common::Event event;
+	while (g_system->getEventManager()->pollEvent(event)) {
+		// Handle keypress
+		switch (event.type) {
+		case Common::EVENT_QUIT:
+		case Common::EVENT_RTL:
+			return;
+
+		case Common::EVENT_KEYDOWN:
+			// Check for debugger
+			if (event.kbd.keycode == Common::KEYCODE_d && (event.kbd.flags & Common::KBD_CTRL)) {
+				// Attach to the debugger
+				_vm->_debugger->attach();
+				_vm->_debugger->onFrame();
+			}
+			return;
+		case Common::EVENT_KEYUP:
+			return;
+		case Common::EVENT_LBUTTONDOWN:
+			_leftButton = true;
+			break;
+		case Common::EVENT_LBUTTONUP:
+			_leftButton = false;
+			break;
+		default:
+ 			break;
+		}
+	}
+}
+
+void EventsManager::checkForNextFrameCounter() {
+	// Check for next game frame
+	uint32 milli = g_system->getMillis();
+	if ((milli - _priorFrameTime) >= GAME_FRAME_TIME) {
+		++_frameCounter;
+		_priorFrameTime = milli;
+
+		// Give time to the debugger
+		_vm->_debugger->onFrame();
+
+		// Signal the ScummVM debugger
+		_vm->_debugger->onFrame();
+	}
+}
+
+} // End of namespace Access
diff --git a/engines/access/events.h b/engines/access/events.h
new file mode 100644
index 0000000..b30670c
--- /dev/null
+++ b/engines/access/events.h
@@ -0,0 +1,86 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be 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 ACCESS_EVENTS_H
+#define ACCESS_EVENTS_H
+
+#include "common/scummsys.h"
+#include "common/events.h"
+#include "common/stack.h"
+
+namespace Access {
+
+enum CursorType { CURSOR_NONE = 0 };
+
+#define GAME_FRAME_RATE 50
+#define GAME_FRAME_TIME (1000 / GAME_FRAME_RATE)
+
+class AccessEngine;
+
+class EventsManager {
+private:
+	AccessEngine *_vm;
+	uint32 _frameCounter;
+	uint32 _priorFrameTime;
+	Common::Point _mousePos;
+
+	void checkForNextFrameCounter();
+public:
+	CursorType _cursorId;
+	bool _leftButton;
+public:
+	/**
+	 * Constructor
+	 */
+	EventsManager(AccessEngine *vm);
+
+	/**
+	 * Destructor
+	 */
+	~EventsManager();
+
+	/**
+	 * Sets the cursor
+	 */
+	void setCursor(CursorType cursorId);
+
+	/**
+	 * Show the mouse cursor
+	 */
+	void showCursor();
+
+	/**
+	 * Hide the mouse cursor
+	 */
+	void hideCursor();
+
+	/**
+	 * Returns if the mouse cursor is visible
+	 */
+	bool isCursorVisible();
+
+	void pollEvents();
+};
+
+} // End of namespace Access
+
+#endif /* ACCESS_EVENTS_H */
diff --git a/engines/access/module.mk b/engines/access/module.mk
index c61ab50..a6f352f 100644
--- a/engines/access/module.mk
+++ b/engines/access/module.mk
@@ -3,7 +3,8 @@ MODULE := engines/access
 MODULE_OBJS := \
 	access.o \
 	debugger.o \
-	detection.o
+	detection.o \
+	events.o
 
 # This module can be built as a plugin
 ifeq ($(ENABLE_ACCESS), DYNAMIC_PLUGIN)


Commit: c2451b57bccc2a425a6e1376c2a116df48b1fcc6
    https://github.com/scummvm/scummvm/commit/c2451b57bccc2a425a6e1376c2a116df48b1fcc6
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-01T15:21:21-04:00

Commit Message:
ACCESS: Added resources for cursors

Changed paths:
  A engines/access/resources.cpp
  A engines/access/resources.h
    engines/access/module.mk



diff --git a/engines/access/module.mk b/engines/access/module.mk
index a6f352f..1163033 100644
--- a/engines/access/module.mk
+++ b/engines/access/module.mk
@@ -4,7 +4,8 @@ MODULE_OBJS := \
 	access.o \
 	debugger.o \
 	detection.o \
-	events.o
+	events.o \
+	resources.o \
 
 # This module can be built as a plugin
 ifeq ($(ENABLE_ACCESS), DYNAMIC_PLUGIN)
diff --git a/engines/access/resources.cpp b/engines/access/resources.cpp
new file mode 100644
index 0000000..4ab3dd9
--- /dev/null
+++ b/engines/access/resources.cpp
@@ -0,0 +1,156 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, 0xwhose 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, 0xor (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, 0xwrite to the Free Software
+ * Foundation, 0xInc., 0x51 Franklin Street, 0xFifth Floor, 0xBoston, 0xMA 02110-1301, 0xUSA.
+ *
+ */
+
+#include "access/resources.h"
+
+namespace Access {
+
+namespace Amazon {
+
+const byte *CURSORS[10] = {
+	MOUSE0, MOUSE1, MOUSE2, MOUSE3, CURSEYE, CURSHAND, CURSGET, CURSCLIMB, CURSTALK, CURSHELP
+};
+
+const byte MOUSE0[] = {
+	0, 0, 0, 0, 0, 2, 6, 1, 0, 3, 6, 6, 1, 0, 3, 6, 6, 1,
+	0, 4, 6, 6, 6, 1, 0, 4, 6, 6, 6, 1, 0, 5, 6, 6, 6, 6,
+	1, 0, 5, 6, 6, 6, 6, 1, 0, 6, 6, 6, 6, 6, 6, 1, 0, 6,
+	6, 6, 6, 6, 6, 1, 0, 7, 6, 6, 6, 6, 6, 6, 1, 0, 6, 6,
+	6, 6, 6, 6, 1, 0, 5, 6, 6, 6, 6, 1, 2, 3, 6, 6, 1, 3,
+	3, 6, 6, 1, 3, 3, 6, 6, 1, 4, 2, 6, 1
+};
+const byte MOUSE1[] = {
+	0x07, 0x00, 0x07, 0x00, 0x06, 0x01, 0x05, 0x04, 0x05, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x03, 0x07,
+	0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x02, 0x09, 0xFF, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00,
+	0x00, 0xFF, 0x01, 0x0B, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x01,
+	0x0B, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x0D, 0x05, 0x00,
+	0x00, 0x05, 0x00, 0x05, 0x00, 0x05, 0x00, 0x05, 0x00, 0x00, 0x05, 0x01, 0x0B, 0xFF, 0x00, 0x00,
+	0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x01, 0x0B, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0xFF, 0x02, 0x09, 0xFF, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0xFF,
+	0x03, 0x07, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x04, 0x05, 0xFF, 0xFF, 0x00, 0xFF, 0xFF,
+	0x06, 0x01, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+};
+const byte MOUSE2[] = {
+	0x08, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x02, 0x04, 0x05, 0x07, 0x02, 0x04, 0x05,
+	0x07, 0x02, 0x04, 0x05, 0x07, 0x02, 0x04, 0x05, 0x07, 0x02, 0x04, 0x05, 0x02, 0x0C, 0x04, 0x04,
+	0x04, 0x04, 0x04, 0x00, 0x04, 0x04, 0x04, 0x04, 0x04, 0x05, 0x07, 0x02, 0x04, 0x05, 0x07, 0x02,
+	0x04, 0x05, 0x07, 0x02, 0x04, 0x05, 0x07, 0x02, 0x04, 0x05, 0x07, 0x02, 0x04, 0x05, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00
+};
+const byte MOUSE3[] = {
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x0B, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06,
+	0x06, 0x00, 0x0C, 0x06, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x06, 0x06, 0x05, 0x00,
+	0x0C, 0x06, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x06, 0x05, 0x05, 0x00, 0x0C, 0x06,
+	0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x05, 0x00, 0x0C, 0x06, 0x06, 0x06,
+	0x06, 0x06, 0x05, 0x06, 0x06, 0x06, 0x06, 0x06, 0x05, 0x00, 0x0C, 0x06, 0x06, 0x06, 0x06, 0x05,
+	0x00, 0x00, 0x06, 0x06, 0x06, 0x06, 0x05, 0x00, 0x0C, 0x06, 0x06, 0x06, 0x06, 0x06, 0x00, 0x06,
+	0x06, 0x06, 0x06, 0x06, 0x05, 0x00, 0x0C, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06,
+	0x06, 0x06, 0x05, 0x00, 0x0C, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06,
+	0x05, 0x00, 0x0C, 0x06, 0x06, 0x06, 0x06, 0x06, 0x05, 0x06, 0x06, 0x06, 0x06, 0x06, 0x05, 0x00,
+	0x0C, 0x06, 0x06, 0x06, 0x06, 0x06, 0x05, 0x06, 0x06, 0x06, 0x06, 0x06, 0x05, 0x00, 0x0C, 0x06,
+	0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x05, 0x01, 0x0B, 0x05, 0x05, 0x05,
+	0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+};
+const byte CURSEYE[] = {
+	0x01, 0x00, 0x08, 0x00, 0x04, 0x06, 0x0E, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x03, 0x09, 0x0E, 0x01,
+	0x01, 0x01, 0x01, 0x01, 0x01, 0x0D, 0x0D, 0x02, 0x0B, 0x0E, 0x01, 0x33, 0x33, 0x01, 0x01, 0x33,
+	0x34, 0x01, 0x01, 0x0D, 0x01, 0x0D, 0x0E, 0x01, 0x04, 0x34, 0x01, 0x01, 0x01, 0x07, 0x33, 0x04,
+	0x04, 0x01, 0x0D, 0x00, 0x0F, 0x0E, 0x0E, 0x01, 0x07, 0x33, 0x33, 0x01, 0x01, 0x33, 0x34, 0x07,
+	0x07, 0x06, 0x01, 0x0E, 0x01, 0x0D, 0x0F, 0x0F, 0x06, 0x07, 0x34, 0x33, 0x33, 0x34, 0x07, 0x07,
+	0x06, 0x0F, 0x0E, 0x03, 0x09, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0E, 0x01, 0x01,
+	0x07, 0x00, 0x03, 0x07, 0x01, 0x07, 0x01, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00
+};
+const byte CURSHAND[] = {
+	0x02, 0x00, 0x03, 0x00, 0x07, 0x02, 0x17, 0x0E, 0x05, 0x07, 0x0E, 0x12, 0x17, 0x0E, 0x13, 0x17,
+	0x0E, 0x02, 0x0C, 0x07, 0x00, 0x17, 0x0E, 0x11, 0x0F, 0x0E, 0x11, 0x17, 0x0E, 0x00, 0x17, 0x01,
+	0x0E, 0x07, 0x01, 0x07, 0x0F, 0x0E, 0x11, 0x17, 0x0E, 0x11, 0x0F, 0x0E, 0x12, 0x17, 0x0E, 0x02,
+	0x0D, 0x07, 0x00, 0x17, 0x0F, 0x12, 0x0F, 0x0F, 0x11, 0x17, 0x0E, 0x12, 0x0F, 0x0E, 0x04, 0x0B,
+	0x0F, 0x0E, 0x11, 0x17, 0x0E, 0x12, 0x0F, 0x0F, 0x11, 0x17, 0x0E, 0x04, 0x0B, 0x17, 0x0E, 0x12,
+	0x17, 0x0E, 0x12, 0x17, 0x0E, 0x11, 0x0F, 0x0E, 0x00, 0x0F, 0x0E, 0x0D, 0x12, 0x00, 0x17, 0x0F,
+	0x0F, 0x0F, 0x0F, 0x12, 0x0F, 0x0E, 0x12, 0x17, 0x0F, 0x00, 0x0F, 0x0F, 0x17, 0x0D, 0x11, 0x0F,
+	0x0E, 0x0D, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0E, 0x0D, 0x01, 0x0E, 0x0F, 0x17, 0x0F, 0x0E,
+	0x0F, 0x0D, 0x0D, 0x0D, 0x0D, 0x0E, 0x0F, 0x0F, 0x0E, 0x0D, 0x02, 0x0D, 0x0F, 0x17, 0x0F, 0x0E,
+	0x0D, 0x0D, 0x0F, 0x0F, 0x0E, 0x0F, 0x0E, 0x0E, 0x12, 0x03, 0x0C, 0x0F, 0x17, 0x0F, 0x0F, 0x0F,
+	0x0E, 0x0F, 0x0F, 0x0F, 0x0E, 0x0D, 0x12, 0x04, 0x0A, 0x0F, 0x17, 0x0F, 0x0F, 0x0F, 0x0E, 0x0F,
+	0x0F, 0x0E, 0x0D, 0x05, 0x09, 0x0F, 0x17, 0x0F, 0x0F, 0x0F, 0x0F, 0x0E, 0x0D, 0x12, 0x06, 0x08,
+	0x17, 0x0F, 0x0F, 0x0F, 0x0F, 0x0E, 0x0D, 0x12, 0x06, 0x07, 0x17, 0x0F, 0x0F, 0x0F, 0x3D, 0x0E,
+	0x0D
+};
+const byte CURSGET[] = {
+	0x07, 0x00, 0x0E, 0x00, 0x0A, 0x05, 0x1C, 0x07, 0x0F, 0x0F, 0x0F, 0x08, 0x08, 0x1C, 0x07, 0x0F,
+	0x0F, 0x0F, 0x0F, 0x0F, 0x0C, 0x06, 0x0A, 0x1C, 0x07, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F,
+	0x0C, 0x05, 0x0A, 0x07, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0C, 0x03, 0x0C, 0x07,
+	0x1C, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0C, 0x02, 0x0D, 0x1C, 0x0F, 0x0E,
+	0x0E, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0C, 0x01, 0x0E, 0x07, 0x0F, 0x0E, 0x0D,
+	0x0F, 0x0E, 0x0D, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0C, 0x00, 0x0F, 0x1C, 0x0F, 0x0E, 0x0D,
+	0x0F, 0x0E, 0x0D, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0C, 0x00, 0x0F, 0x1C, 0x0E, 0x0D,
+	0x0F, 0x0E, 0x0D, 0x0F, 0x0F, 0x0C, 0x0C, 0x0E, 0x0F, 0x0F, 0x0F, 0x0C, 0x00, 0x0E, 0x1C, 0x0D,
+	0x0F, 0x0E, 0x0D, 0x0F, 0x0F, 0x0C, 0x00, 0x00, 0x0E, 0x0F, 0x0F, 0x0C, 0x00, 0x0E, 0x1C, 0x0E,
+	0x0F, 0x0D, 0x0F, 0x0F, 0x0C, 0x00, 0x00, 0x0E, 0x1C, 0x0F, 0x0F, 0x0C, 0x00, 0x0D, 0x1C, 0x0D,
+	0x0F, 0x0D, 0x0F, 0x0C, 0x00, 0x00, 0x00, 0x0E, 0x1C, 0x0F, 0x0C, 0x01, 0x0B, 0x0E, 0x0F, 0x0E,
+	0x0F, 0x0C, 0x00, 0x00, 0x0E, 0x07, 0x0F, 0x0C, 0x02, 0x09, 0x0E, 0x0D, 0x0F, 0x0C, 0x00, 0x07,
+	0x0E, 0x0F, 0x0C, 0x03, 0x06, 0x0E, 0x0F, 0x0E, 0x07, 0x01, 0x07, 0x07, 0x01, 0x07
+};
+const byte CURSCLIMB[] = {
+	0x03, 0x00, 0x0E, 0x00, 0x06, 0x04, 0x01, 0x01, 0x01, 0x01, 0x06, 0x04, 0x0F, 0x0E, 0x01, 0x01,
+	0x06, 0x04, 0x0F, 0x0E, 0x0D, 0x01, 0x07, 0x02, 0x0F, 0x0D, 0x00, 0x0C, 0x0F, 0x00, 0x00, 0x00,
+	0x00, 0x13, 0x12, 0x12, 0x12, 0x12, 0x11, 0x11, 0x00, 0x0D, 0x0D, 0x0E, 0x00, 0x00, 0x13, 0x14,
+	0x13, 0x12, 0x12, 0x12, 0x11, 0x11, 0x0E, 0x01, 0x0C, 0x0D, 0x0D, 0x0D, 0x0E, 0x11, 0x13, 0x13,
+	0x12, 0x11, 0x11, 0x0E, 0x0D, 0x02, 0x0C, 0x0E, 0x0E, 0x00, 0x00, 0x00, 0x13, 0x12, 0x11, 0x00,
+	0x00, 0x0E, 0x0D, 0x03, 0x0B, 0x04, 0x04, 0x04, 0x22, 0x21, 0x21, 0x20, 0x00, 0x00, 0x00, 0x0D,
+	0x02, 0x0D, 0x22, 0x04, 0x20, 0x22, 0x04, 0x21, 0x04, 0x20, 0x00, 0x00, 0x00, 0x0E, 0x0E, 0x03,
+	0x07, 0x22, 0x21, 0x20, 0x20, 0x22, 0x04, 0x20, 0x04, 0x06, 0x01, 0x01, 0x00, 0x04, 0x22, 0x20,
+	0x02, 0x09, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x04, 0x20, 0x03, 0x09, 0x07, 0x01, 0x01,
+	0x00, 0x00, 0x00, 0x22, 0x04, 0x20, 0x02, 0x0B, 0x07, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x01, 0x01, 0x20, 0x03, 0x0A, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01
+};
+const byte CURSTALK[] = {
+	0x02, 0x00, 0x0B, 0x00, 0x03, 0x08, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x01, 0x0C,
+	0x06, 0x06, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x06, 0x06, 0x00, 0x0E, 0x06, 0x06,
+	0x06, 0x06, 0x07, 0x06, 0x07, 0x07, 0x06, 0x07, 0x07, 0x06, 0x07, 0x06, 0x00, 0x0F, 0x06, 0x08,
+	0x08, 0x08, 0x06, 0x08, 0x06, 0x06, 0x08, 0x06, 0x06, 0x08, 0x06, 0x08, 0x06, 0x00, 0x0F, 0x06,
+	0x06, 0x08, 0x06, 0x08, 0x06, 0x08, 0x06, 0x08, 0x06, 0x06, 0x08, 0x08, 0x06, 0x06, 0x00, 0x0F,
+	0x06, 0x06, 0x08, 0x06, 0x08, 0x08, 0x08, 0x06, 0x08, 0x06, 0x06, 0x08, 0x06, 0x08, 0x06, 0x01,
+	0x0E, 0x06, 0x08, 0x06, 0x08, 0x06, 0x08, 0x06, 0x08, 0x08, 0x06, 0x08, 0x06, 0x08, 0x06, 0x02,
+	0x0C, 0x06, 0x06, 0x06, 0x07, 0x06, 0x07, 0x06, 0x06, 0x07, 0x06, 0x07, 0x06, 0x04, 0x09, 0x06,
+	0x06, 0x06, 0x07, 0x07, 0x07, 0x07, 0x06, 0x06, 0x07, 0x04, 0x06, 0x07, 0x07, 0x06, 0x02, 0x08,
+	0x07, 0x00, 0x00, 0x06, 0x06, 0x06, 0x06, 0x06, 0x01, 0x06, 0x07, 0x01, 0x07, 0x06, 0x06, 0x06,
+	0x02, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+};
+const byte CURSHELP[] = {
+	0x02, 0x00, 0x0B, 0x00, 0x04, 0x06, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x02, 0x0A, 0x24, 0x24,
+	0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x20, 0x20, 0x01, 0x0C, 0x24, 0x22, 0x22, 0x22, 0x20, 0x20,
+	0x20, 0x22, 0x22, 0x22, 0x22, 0x20, 0x00, 0x0E, 0x24, 0x22, 0x22, 0x22, 0x20, 0x00, 0x00, 0x00,
+	0x24, 0x22, 0x22, 0x22, 0x22, 0x20, 0x00, 0x0E, 0x24, 0x22, 0x22, 0x22, 0x22, 0x20, 0x00, 0x00,
+	0x00, 0x24, 0x22, 0x22, 0x22, 0x20, 0x00, 0x0E, 0x24, 0x22, 0x22, 0x22, 0x22, 0x20, 0x00, 0x00,
+	0x00, 0x24, 0x22, 0x22, 0x22, 0x20, 0x01, 0x0D, 0x24, 0x20, 0x20, 0x20, 0x00, 0x00, 0x00, 0x24,
+	0x22, 0x22, 0x22, 0x22, 0x20, 0x07, 0x06, 0x24, 0x22, 0x22, 0x22, 0x22, 0x20, 0x05, 0x07, 0x24,
+	0x22, 0x22, 0x22, 0x22, 0x20, 0x20, 0x04, 0x05, 0x24, 0x22, 0x22, 0x22, 0x20, 0x02, 0x07, 0x07,
+	0x00, 0x24, 0x20, 0x20, 0x20, 0x20, 0x01, 0x03, 0x07, 0x01, 0x07, 0x02, 0x07, 0x07, 0x00, 0x00,
+	0x24, 0x24, 0x24, 0x24, 0x04, 0x06, 0x24, 0x22, 0x22, 0x22, 0x22, 0x20, 0x04, 0x06, 0x24, 0x22,
+	0x22, 0x22, 0x22, 0x20, 0x05, 0x04, 0x20, 0x20, 0x20, 0x20
+};
+
+} // End of namespace Amazon
+
+} // End of namespace Access
diff --git a/engines/access/resources.h b/engines/access/resources.h
new file mode 100644
index 0000000..cabaac9
--- /dev/null
+++ b/engines/access/resources.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.
+ *
+ */
+
+#ifndef ACCESS_RESOURCES_H
+#define ACCESS_RESOURCES_H
+
+#include "common/scummsys.h"
+
+namespace Access {
+
+namespace Amazon {
+
+extern const byte MOUSE0[];
+extern const byte MOUSE1[];
+extern const byte MOUSE2[];
+extern const byte MOUSE3[];
+extern const byte CURSEYE[];
+extern const byte CURSHAND[];
+extern const byte CURSGET[];
+extern const byte CURSCLIMB[];
+extern const byte CURSTALK[];
+extern const byte CURSHELP[];
+
+extern const byte *CURSORS[10];
+
+} // End of namespace Amazon
+
+} // End of namespace Access
+
+#endif /* ACCESS_EVENTS_H */


Commit: 4d24209eae5e776fe150775771e7cd70579a518e
    https://github.com/scummvm/scummvm/commit/4d24209eae5e776fe150775771e7cd70579a518e
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-01T16:20:24-04:00

Commit Message:
ACCESS: Add Amazon floppy detection and skeleton for Amazon engine

Changed paths:
  A engines/access/amazon/amazon_game.cpp
  A engines/access/amazon/amazon_game.h
    engines/access/access.cpp
    engines/access/access.h
    engines/access/detection.cpp
    engines/access/detection_tables.h
    engines/access/module.mk



diff --git a/engines/access/access.cpp b/engines/access/access.cpp
index 23b8fb9..e4b4159 100644
--- a/engines/access/access.cpp
+++ b/engines/access/access.cpp
@@ -51,7 +51,6 @@ void AccessEngine::initialize() {
 }
 
 Common::Error AccessEngine::run() {
-	initGraphics(320, 200, false);
 	initialize();
 
 	return Common::kNoError;
@@ -61,4 +60,9 @@ int AccessEngine::getRandomNumber(int maxNumber) {
 	return _randomSource.getRandomNumber(maxNumber);
 }
 
+void AccessEngine::SETVGA() {
+	initGraphics(320, 200, false);
+}
+
+
 } // End of namespace Access
diff --git a/engines/access/access.h b/engines/access/access.h
index ef9960e..5c9207d 100644
--- a/engines/access/access.h
+++ b/engines/access/access.h
@@ -53,11 +53,6 @@ enum AccessDebugChannels {
 	kDebugGraphics	= 1 << 2
 };
 
-enum {
-	GType_Amazon = 0,
-	GType_MeanStreets = 1
-};
-
 struct AccessGameDescription;
 
 
@@ -75,6 +70,8 @@ private:
 	 * Handles basic initialisation
 	 */
 	void initialize();
+
+	void SETVGA();
 protected:
 	// Engine APIs
 	virtual Common::Error run();
diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp
new file mode 100644
index 0000000..2b4196a
--- /dev/null
+++ b/engines/access/amazon/amazon_game.cpp
@@ -0,0 +1,35 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "access/amazon/amazon_game.h"
+
+namespace Access {
+
+namespace Amazon {
+
+AmazonEngine::AmazonEngine(OSystem *syst, const AccessGameDescription *gameDesc) :
+		AccessEngine(syst, gameDesc) {
+}
+
+} // End of namespace Amazon
+
+} // End of namespace Access
diff --git a/engines/access/amazon/amazon_game.h b/engines/access/amazon/amazon_game.h
new file mode 100644
index 0000000..1bccd1c
--- /dev/null
+++ b/engines/access/amazon/amazon_game.h
@@ -0,0 +1,43 @@
+/* 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 ACCESS_AMAZON_GAME_H
+#define ACCESS_AMAZON_GAME_H
+
+#include "access/access.h"
+
+namespace Access {
+
+namespace Amazon {
+
+class AmazonEngine : public AccessEngine {
+public:
+	AmazonEngine(OSystem *syst, const AccessGameDescription *gameDesc);
+
+	virtual ~AmazonEngine() {}
+};
+
+} // End of namespace Amazon
+
+} // End of namespace Access
+
+#endif /* ACCESS_ACCESS_H */
diff --git a/engines/access/detection.cpp b/engines/access/detection.cpp
index aca594d..ca04a64 100644
--- a/engines/access/detection.cpp
+++ b/engines/access/detection.cpp
@@ -22,6 +22,7 @@
  */
 
 #include "access/access.h"
+#include "access/amazon/amazon_game.h"
 
 #include "base/plugins.h"
 #include "common/savefile.h"
@@ -114,7 +115,13 @@ bool Access::AccessEngine::hasFeature(EngineFeature f) const {
 bool AccessMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const {
 	const Access::AccessGameDescription *gd = (const Access::AccessGameDescription *)desc;
 	if (gd) {
-		*engine = new Access::AccessEngine(syst, gd);
+		switch (gd->gameID) {
+		case Access::GType_Amazon:
+			*engine = new Access::Amazon::AmazonEngine(syst, gd);
+			break;
+		default:
+			error("Unknown game");
+		}
 	}
 	return gd != 0;
 }
diff --git a/engines/access/detection_tables.h b/engines/access/detection_tables.h
index 9100e52..9030429 100644
--- a/engines/access/detection_tables.h
+++ b/engines/access/detection_tables.h
@@ -22,14 +22,19 @@
 
 namespace Access {
 
+enum {
+	GType_Amazon = 1,
+	GType_MeanStreets = 2
+};
+
 static const AccessGameDescription gameDescriptions[] = {
 	{
-		// Amazon Guadians of Eden
+		// Amazon Guadians of Eden - Floppy English
 		{
 			"amazon",
 			0,
 			{
-				{"amazon", 0, "00000000000000000000000000000000", 1},
+				{ "c00.ap", 0, "dcabf69d5a0d911168cb73511ebaead0", 331481 },
 				AD_LISTEND
 			},
 			Common::EN_ANY,
diff --git a/engines/access/module.mk b/engines/access/module.mk
index 1163033..f04e516 100644
--- a/engines/access/module.mk
+++ b/engines/access/module.mk
@@ -6,6 +6,7 @@ MODULE_OBJS := \
 	detection.o \
 	events.o \
 	resources.o \
+	amazon\amazon_game.o
 
 # This module can be built as a plugin
 ifeq ($(ENABLE_ACCESS), DYNAMIC_PLUGIN)


Commit: 857f94423fcf4464df44e5b46241f68e33f800a3
    https://github.com/scummvm/scummvm/commit/857f94423fcf4464df44e5b46241f68e33f800a3
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-01T21:32:05-04:00

Commit Message:
ACCESS: Implement decoding of game cursors

Changed paths:
  A engines/access/graphics.cpp
  A engines/access/graphics.h
    engines/access/access.cpp
    engines/access/access.h
    engines/access/events.cpp
    engines/access/events.h
    engines/access/module.mk
    engines/access/resources.cpp
    engines/access/resources.h



diff --git a/engines/access/access.cpp b/engines/access/access.cpp
index e4b4159..8aabac2 100644
--- a/engines/access/access.cpp
+++ b/engines/access/access.cpp
@@ -33,11 +33,13 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc)
 		_gameDescription(gameDesc), Engine(syst), _randomSource("Access") {
 	_debugger = nullptr;
 	_events = nullptr;
+	_graphics = nullptr;
 }
 
 AccessEngine::~AccessEngine() {
 	delete _debugger;
 	delete _events;
+	delete _graphics;
 }
 
 void AccessEngine::initialize() {
@@ -48,19 +50,42 @@ void AccessEngine::initialize() {
 
 	_debugger = new Debugger(this);
 	_events = new EventsManager(this);
+	_graphics = new GraphicsManager(this);
 }
 
 Common::Error AccessEngine::run() {
 	initialize();
 
+	setVGA();
+	_graphics->setPalettte();
+	_graphics->setPanel(0);
+	_events->setCursor(CURSOR_0);
+	_events->showCursor();
+
+	dummyLoop();
 	return Common::kNoError;
 }
 
+void AccessEngine::dummyLoop() {
+	// Dummy game loop
+	while (!shouldQuit()) {
+		_events->pollEvents();
+		g_system->delayMillis(50);
+		g_system->updateScreen();
+
+		if (_events->_leftButton) {
+			CursorType cursorId = _events->getCursor();
+			_events->setCursor((cursorId == CURSOR_HELP) ? CURSOR_0 : (CursorType)(cursorId + 1));
+		}
+	}
+
+}
+
 int AccessEngine::getRandomNumber(int maxNumber) {
 	return _randomSource.getRandomNumber(maxNumber);
 }
 
-void AccessEngine::SETVGA() {
+void AccessEngine::setVGA() {
 	initGraphics(320, 200, false);
 }
 
diff --git a/engines/access/access.h b/engines/access/access.h
index 5c9207d..16487ea 100644
--- a/engines/access/access.h
+++ b/engines/access/access.h
@@ -32,6 +32,7 @@
 #include "graphics/surface.h"
 #include "access/debugger.h"
 #include "access/events.h"
+#include "access/graphics.h"
 
 /**
  * This is the namespace of the Access engine.
@@ -58,27 +59,28 @@ struct AccessGameDescription;
 
 class AccessEngine : public Engine {
 private:
-	const AccessGameDescription *_gameDescription;
-	Common::RandomSource _randomSource;
-	
-	Graphics::Surface _buffer1;
-	Graphics::Surface _buffer2;
-	Graphics::Surface _vidbuf;
-	Graphics::Surface _plotBuf;
-
 	/**
 	 * Handles basic initialisation
 	 */
 	void initialize();
 
-	void SETVGA();
+	/**
+	 * Set VGA mode
+	 */
+	void setVGA();
+
+	void dummyLoop();
 protected:
+	const AccessGameDescription *_gameDescription;
+	Common::RandomSource _randomSource;
+
 	// Engine APIs
 	virtual Common::Error run();
 	virtual bool hasFeature(EngineFeature f) const;
 public:
 	Debugger *_debugger;
 	EventsManager *_events;
+	GraphicsManager *_graphics;
 public:
 	AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc);
 	virtual ~AccessEngine();
diff --git a/engines/access/events.cpp b/engines/access/events.cpp
index 47908ff..29f6270 100644
--- a/engines/access/events.cpp
+++ b/engines/access/events.cpp
@@ -23,9 +23,14 @@
 #include "common/scummsys.h"
 #include "graphics/cursorman.h"
 #include "common/events.h"
+#include "common/endian.h"
 #include "engines/util.h"
 #include "access/access.h"
 #include "access/events.h"
+#include "access/resources.h"
+
+#define CURSOR_WIDTH 16
+#define CURSOR_HEIGHT 16
 
 namespace Access {
 
@@ -40,7 +45,49 @@ EventsManager::~EventsManager() {
 }
 
 void EventsManager::setCursor(CursorType cursorId) {
+	if (cursorId == _cursorId)
+		return;	
 	_cursorId = cursorId;
+	
+	// Get a pointer to the mouse data to use, and get the cursor hotspot
+	const byte *srcP = Amazon::CURSORS[cursorId];
+	int hotspotX = (int16)READ_LE_UINT16(srcP);
+	int hotspotY = (int16)READ_LE_UINT16(srcP + 2);
+	srcP += 4;
+
+	// Create a surface to build up the cursor on
+	Graphics::Surface cursorSurface;
+	cursorSurface.create(16, 16, Graphics::PixelFormat::createFormatCLUT8());
+	byte *destP = (byte *)cursorSurface.getPixels();
+	Common::fill(destP, destP + CURSOR_WIDTH * CURSOR_HEIGHT, 0);
+
+	// Loop to build up the cursor
+	for (int y = 0; y < CURSOR_HEIGHT; ++y) {
+		destP = (byte *)cursorSurface.getBasePtr(0, y);
+		int width = CURSOR_WIDTH;
+		int skip = *srcP++;
+		int plot = *srcP++;
+		if (skip >= width)
+			break;
+
+		// Skip over pixels
+		destP += skip;
+		width -= skip;
+
+		// Write out the pixels to plot
+		while (plot > 0 && width > 0) {
+			*destP++ = *srcP++;
+			--plot;
+			--width;
+		}
+	}
+
+	// Set the cursor
+	CursorMan.replaceCursor(cursorSurface.getPixels(), CURSOR_WIDTH, CURSOR_HEIGHT,
+		hotspotX, hotspotY, 0);
+
+	// Free the cursor surface
+	cursorSurface.free();
 }
 
 void EventsManager::showCursor() {
@@ -58,6 +105,8 @@ bool EventsManager::isCursorVisible() {
 void EventsManager::pollEvents() {
 	checkForNextFrameCounter();
 
+	_leftButton = false;
+
 	Common::Event event;
 	while (g_system->getEventManager()->pollEvent(event)) {
 		// Handle keypress
@@ -78,10 +127,9 @@ void EventsManager::pollEvents() {
 			return;
 		case Common::EVENT_LBUTTONDOWN:
 			_leftButton = true;
-			break;
+			return;
 		case Common::EVENT_LBUTTONUP:
-			_leftButton = false;
-			break;
+			return;
 		default:
  			break;
 		}
diff --git a/engines/access/events.h b/engines/access/events.h
index b30670c..3cf610e 100644
--- a/engines/access/events.h
+++ b/engines/access/events.h
@@ -29,7 +29,11 @@
 
 namespace Access {
 
-enum CursorType { CURSOR_NONE = 0 };
+enum CursorType { 
+	CURSOR_NONE = -1,
+	CURSOR_0 = 0, CURSOR_1, CURSOR_2, CURSOR_3, CURSOR_EYE, CURSOR_HAND, 
+	CURSOR_GET, CURSOR_CLIMB, CURSOR_TALK, CURSOR_HELP
+};
 
 #define GAME_FRAME_RATE 50
 #define GAME_FRAME_TIME (1000 / GAME_FRAME_RATE)
@@ -64,6 +68,11 @@ public:
 	void setCursor(CursorType cursorId);
 
 	/**
+	 * Return the current cursor Id
+	 */
+	CursorType getCursor() const { return _cursorId; }
+
+	/**
 	 * Show the mouse cursor
 	 */
 	void showCursor();
diff --git a/engines/access/graphics.cpp b/engines/access/graphics.cpp
new file mode 100644
index 0000000..8f0e22f
--- /dev/null
+++ b/engines/access/graphics.cpp
@@ -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.
+ *
+ */
+
+#include "graphics/palette.h"
+#include "access/access.h"
+#include "access/graphics.h"
+#include "access/resources.h"
+
+namespace Access {
+
+GraphicsManager::GraphicsManager(AccessEngine *vm) : _vm(vm) {
+	_vesaCurrentWin = 0;
+	_currentPanel = 0;
+	_hideFlag = true;
+}
+
+void GraphicsManager::setPanel(int num) {
+	assert(num < 4);
+	_currentPanel = num;
+	_msVirtualOffset = _virtualOffsetsTable[num];
+}
+
+void GraphicsManager::setPalettte() {
+	g_system->getPaletteManager()->setPalette(INITIAL_PALETTE, 0, 18);
+}
+
+} // End of namespace Access
diff --git a/engines/access/graphics.h b/engines/access/graphics.h
new file mode 100644
index 0000000..c7d2acd
--- /dev/null
+++ b/engines/access/graphics.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.
+ *
+ */
+
+#ifndef ACCESS_GRAPHICS_H
+#define ACCESS_GRAPHICS_H
+
+#include "common/rect.h"
+#include "graphics/surface.h"
+
+namespace Access {
+
+class AccessEngine;
+
+class GraphicsManager {
+private:
+	AccessEngine *_vm;
+public:
+	int _vesaCurrentWin;
+	int _currentPanel;
+	Common::Point _msVirtualOffset;
+	Common::Point _virtualOffsetsTable[4];
+	bool _hideFlag;
+public:
+	GraphicsManager(AccessEngine *vm);
+
+	void setPanel(int num);
+	void setPalettte();
+};
+
+} // End of namespace Access
+
+#endif /* ACCESS_GRAPHICS_H */
diff --git a/engines/access/module.mk b/engines/access/module.mk
index f04e516..d8867bc 100644
--- a/engines/access/module.mk
+++ b/engines/access/module.mk
@@ -5,6 +5,7 @@ MODULE_OBJS := \
 	debugger.o \
 	detection.o \
 	events.o \
+	graphics.o \
 	resources.o \
 	amazon\amazon_game.o
 
diff --git a/engines/access/resources.cpp b/engines/access/resources.cpp
index 4ab3dd9..cf8b491 100644
--- a/engines/access/resources.cpp
+++ b/engines/access/resources.cpp
@@ -24,6 +24,27 @@
 
 namespace Access {
 
+const byte INITIAL_PALETTE[18 * 3] = {
+	0x00, 0x00, 0x00, 
+	0xff, 0xff, 0xff,
+	0xf0, 0xf0, 0xf0,
+	0xe0, 0xe0, 0xe0,
+	0xd0, 0xd0, 0xd0,
+	0xc0, 0xc0, 0xc0,
+	0xb0, 0xb0, 0xb0,
+	0xa0, 0xa0, 0xa0,
+	0x90, 0x90, 0x90,
+	0x80, 0x80, 0x80,
+	0x70, 0x70, 0x70,
+	0x60, 0x60, 0x60,
+	0x50, 0x50, 0x50,
+	0x40, 0x40, 0x40,
+	0x30, 0x30, 0x30,
+	0x20, 0x20, 0x20,
+	0x10, 0x10, 0x10,
+	0x00, 0x00, 0x00
+};
+
 namespace Amazon {
 
 const byte *CURSORS[10] = {
@@ -31,7 +52,8 @@ const byte *CURSORS[10] = {
 };
 
 const byte MOUSE0[] = {
-	0, 0, 0, 0, 0, 2, 6, 1, 0, 3, 6, 6, 1, 0, 3, 6, 6, 1,
+	0, 0, 0, 0, 
+	0, 2, 6, 1, 0, 3, 6, 6, 1, 0, 3, 6, 6, 1,
 	0, 4, 6, 6, 6, 1, 0, 4, 6, 6, 6, 1, 0, 5, 6, 6, 6, 6,
 	1, 0, 5, 6, 6, 6, 6, 1, 0, 6, 6, 6, 6, 6, 6, 1, 0, 6,
 	6, 6, 6, 6, 6, 1, 0, 7, 6, 6, 6, 6, 6, 6, 1, 0, 6, 6,
diff --git a/engines/access/resources.h b/engines/access/resources.h
index cabaac9..7bd2354 100644
--- a/engines/access/resources.h
+++ b/engines/access/resources.h
@@ -27,6 +27,8 @@
 
 namespace Access {
 
+extern const byte INITIAL_PALETTE[18 * 3];
+
 namespace Amazon {
 
 extern const byte MOUSE0[];


Commit: a94bf197ef512eb7bf4dcb96ffcd459959c0d57c
    https://github.com/scummvm/scummvm/commit/a94bf197ef512eb7bf4dcb96ffcd459959c0d57c
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-02T10:07:54-04:00

Commit Message:
ACCESS: Implement fading routines

Changed paths:
  A engines/access/screen.cpp
  A engines/access/screen.h
    engines/access/access.cpp
    engines/access/access.h
    engines/access/amazon/amazon_game.cpp
    engines/access/amazon/amazon_game.h
    engines/access/graphics.cpp
    engines/access/graphics.h
    engines/access/module.mk



diff --git a/engines/access/access.cpp b/engines/access/access.cpp
index 8aabac2..3acd4c5 100644
--- a/engines/access/access.cpp
+++ b/engines/access/access.cpp
@@ -34,12 +34,14 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc)
 	_debugger = nullptr;
 	_events = nullptr;
 	_graphics = nullptr;
+	_screen = nullptr;
 }
 
 AccessEngine::~AccessEngine() {
 	delete _debugger;
 	delete _events;
 	delete _graphics;
+	delete _screen;
 }
 
 void AccessEngine::initialize() {
@@ -51,16 +53,18 @@ void AccessEngine::initialize() {
 	_debugger = new Debugger(this);
 	_events = new EventsManager(this);
 	_graphics = new GraphicsManager(this);
+	_screen = new Screen(this);
 }
 
 Common::Error AccessEngine::run() {
 	initialize();
 
 	setVGA();
-	_graphics->setPalettte();
-	_graphics->setPanel(0);
+	_screen->setInitialPalettte();
 	_events->setCursor(CURSOR_0);
 	_events->showCursor();
+	_graphics->setPanel(0);
+	doTitle();
 
 	dummyLoop();
 	return Common::kNoError;
diff --git a/engines/access/access.h b/engines/access/access.h
index 16487ea..4676d73 100644
--- a/engines/access/access.h
+++ b/engines/access/access.h
@@ -33,6 +33,7 @@
 #include "access/debugger.h"
 #include "access/events.h"
 #include "access/graphics.h"
+#include "access/screen.h"
 
 /**
  * This is the namespace of the Access engine.
@@ -77,10 +78,16 @@ protected:
 	// Engine APIs
 	virtual Common::Error run();
 	virtual bool hasFeature(EngineFeature f) const;
+protected:
+	/**
+	 * Show game title
+	 */
+	virtual void doTitle() = 0;
 public:
 	Debugger *_debugger;
 	EventsManager *_events;
 	GraphicsManager *_graphics;
+	Screen *_screen;
 public:
 	AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc);
 	virtual ~AccessEngine();
diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp
index 2b4196a..3744141 100644
--- a/engines/access/amazon/amazon_game.cpp
+++ b/engines/access/amazon/amazon_game.cpp
@@ -30,6 +30,13 @@ AmazonEngine::AmazonEngine(OSystem *syst, const AccessGameDescription *gameDesc)
 		AccessEngine(syst, gameDesc) {
 }
 
+void AmazonEngine::doTitle() {
+	_screen->setDisplayScan();
+	_screen->forceFadeOut();
+	_events->hideCursor();
+
+}
+
 } // End of namespace Amazon
 
 } // End of namespace Access
diff --git a/engines/access/amazon/amazon_game.h b/engines/access/amazon/amazon_game.h
index 1bccd1c..30ec2c6 100644
--- a/engines/access/amazon/amazon_game.h
+++ b/engines/access/amazon/amazon_game.h
@@ -30,6 +30,8 @@ namespace Access {
 namespace Amazon {
 
 class AmazonEngine : public AccessEngine {
+protected:
+	virtual void doTitle();
 public:
 	AmazonEngine(OSystem *syst, const AccessGameDescription *gameDesc);
 
diff --git a/engines/access/graphics.cpp b/engines/access/graphics.cpp
index 8f0e22f..c1187f2 100644
--- a/engines/access/graphics.cpp
+++ b/engines/access/graphics.cpp
@@ -39,8 +39,4 @@ void GraphicsManager::setPanel(int num) {
 	_msVirtualOffset = _virtualOffsetsTable[num];
 }
 
-void GraphicsManager::setPalettte() {
-	g_system->getPaletteManager()->setPalette(INITIAL_PALETTE, 0, 18);
-}
-
 } // End of namespace Access
diff --git a/engines/access/graphics.h b/engines/access/graphics.h
index c7d2acd..df62617 100644
--- a/engines/access/graphics.h
+++ b/engines/access/graphics.h
@@ -43,7 +43,6 @@ public:
 	GraphicsManager(AccessEngine *vm);
 
 	void setPanel(int num);
-	void setPalettte();
 };
 
 } // End of namespace Access
diff --git a/engines/access/module.mk b/engines/access/module.mk
index d8867bc..a4fb864 100644
--- a/engines/access/module.mk
+++ b/engines/access/module.mk
@@ -7,6 +7,7 @@ MODULE_OBJS := \
 	events.o \
 	graphics.o \
 	resources.o \
+	screen.o \
 	amazon\amazon_game.o
 
 # This module can be built as a plugin
diff --git a/engines/access/screen.cpp b/engines/access/screen.cpp
new file mode 100644
index 0000000..3f8dc4e
--- /dev/null
+++ b/engines/access/screen.cpp
@@ -0,0 +1,100 @@
+/* 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 "common/algorithm.h"
+#include "common/textconsole.h"
+#include "common/system.h"
+#include "graphics/palette.h"
+#include "access/screen.h"
+#include "access/resources.h"
+
+namespace Access {
+
+Screen::Screen(AccessEngine *vm) : _vm(vm) {
+	create(320, 200, Graphics::PixelFormat::createFormatCLUT8());
+	Common::fill(&_tempPalette[0], &_tempPalette[PALETTE_SIZE], 0);
+}
+
+void Screen::setDisplayScan() {
+	warning("TODO: setDisplayScan");
+}
+
+void Screen::updateScreen() {
+	g_system->updateScreen();
+}
+
+void Screen::setInitialPalettte() {
+	Common::copy(&INITIAL_PALETTE[0], &INITIAL_PALETTE[18 * 3], _rawPalette);
+	Common::fill(&_rawPalette[18 * 3], &_rawPalette[PALETTE_SIZE], 0);
+
+	g_system->getPaletteManager()->setPalette(INITIAL_PALETTE, 0, 18);
+}
+
+void Screen::updatePalette() {
+	g_system->getPaletteManager()->setPalette(&_tempPalette[0], 0, PALETTE_COUNT);
+	updateScreen();
+}
+
+void Screen::forceFadeOut() {
+	const int FADE_AMOUNT = 2;
+	bool repeatFlag;
+	byte *srcP;
+	int count;
+
+	do {
+		repeatFlag = false;
+		for (srcP = &_tempPalette[0], count = 0; count < PALETTE_COUNT; ++count, ++srcP) {
+			int v = *srcP;
+			if (v) {
+				repeatFlag = true;
+				*srcP = MAX(*srcP - FADE_AMOUNT, 0);
+			}
+		}
+
+		updatePalette();
+		g_system->delayMillis(10);
+	} while (repeatFlag);
+}
+
+void Screen::forceFadeIn() {
+	Common::fill(&_tempPalette[0], &_tempPalette[PALETTE_SIZE], 0);
+
+	const int FADE_AMOUNT = 2;
+	bool repeatFlag;
+	do {
+		repeatFlag = false;
+		const byte *srcP = &_rawPalette[0];
+		byte *destP = &_tempPalette[0];
+
+		for (int idx = 0; idx < PALETTE_SIZE; ++idx, ++srcP, ++destP) {
+			if (*destP != *srcP) {
+				repeatFlag = true;
+				*destP = MAX((int)*destP + FADE_AMOUNT, (int)*srcP);
+			}
+		}
+
+		updatePalette();
+		g_system->delayMillis(10);
+	} while (repeatFlag);
+}
+
+} // End of namespace Access
diff --git a/engines/access/screen.h b/engines/access/screen.h
new file mode 100644
index 0000000..f8e0dab
--- /dev/null
+++ b/engines/access/screen.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.
+ *
+ */
+
+#ifndef ACCESS_SCREEN_H
+#define ACCESS_SCREEN_H
+
+#include "common/scummsys.h"
+#include "common/rect.h"
+#include "graphics/surface.h"
+
+namespace Access {
+
+class AccessEngine;
+
+#define PALETTE_COUNT 256
+#define PALETTE_SIZE (256 * 3)
+
+class Screen: public Graphics::Surface {
+private:
+	AccessEngine *_vm;
+	byte _tempPalette[PALETTE_SIZE];
+	byte _rawPalette[PALETTE_SIZE];
+
+	void updatePalette();
+public:
+	Screen(AccessEngine *vm);
+
+	void setDisplayScan();
+
+	/**
+	 * Update the underlying screen
+	 */
+	void updateScreen();
+
+	/**
+	 * Fade out screen
+	 */
+	void forceFadeOut();
+
+	/**
+	 * Fade in screen
+	 */
+	void forceFadeIn();
+
+	/**
+	 * Set the initial palette
+	 */
+	void setInitialPalettte();
+};
+
+} // End of namespace Access
+
+#endif /* ACCESS_SCREEN_H */


Commit: a35ba4caf96ab29a184787a859aea2918a74975c
    https://github.com/scummvm/scummvm/commit/a35ba4caf96ab29a184787a859aea2918a74975c
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-02T15:14:42-04:00

Commit Message:
ACCESS: Adding file loading

Changed paths:
  A engines/access/files.cpp
  A engines/access/files.h
  A engines/access/sound.cpp
  A engines/access/sound.h
    engines/access/access.cpp
    engines/access/access.h
    engines/access/amazon/amazon_game.cpp
    engines/access/detection_tables.h
    engines/access/module.mk
    engines/access/resources.cpp
    engines/access/resources.h



diff --git a/engines/access/access.cpp b/engines/access/access.cpp
index 3acd4c5..25d9fcc 100644
--- a/engines/access/access.cpp
+++ b/engines/access/access.cpp
@@ -33,15 +33,19 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc)
 		_gameDescription(gameDesc), Engine(syst), _randomSource("Access") {
 	_debugger = nullptr;
 	_events = nullptr;
+	_files = nullptr;
 	_graphics = nullptr;
 	_screen = nullptr;
+	_sound = nullptr;
 }
 
 AccessEngine::~AccessEngine() {
 	delete _debugger;
 	delete _events;
+	delete _files;
 	delete _graphics;
 	delete _screen;
+	delete _sound;
 }
 
 void AccessEngine::initialize() {
@@ -52,8 +56,10 @@ void AccessEngine::initialize() {
 
 	_debugger = new Debugger(this);
 	_events = new EventsManager(this);
+	_files = new FileManager(this);
 	_graphics = new GraphicsManager(this);
 	_screen = new Screen(this);
+	_sound = new SoundManager(this);
 }
 
 Common::Error AccessEngine::run() {
diff --git a/engines/access/access.h b/engines/access/access.h
index 4676d73..3386cd9 100644
--- a/engines/access/access.h
+++ b/engines/access/access.h
@@ -32,8 +32,10 @@
 #include "graphics/surface.h"
 #include "access/debugger.h"
 #include "access/events.h"
+#include "access/files.h"
 #include "access/graphics.h"
 #include "access/screen.h"
+#include "access/sound.h"
 
 /**
  * This is the namespace of the Access engine.
@@ -49,6 +51,11 @@ namespace Access {
 #define DEBUG_INTERMEDIATE 2
 #define DEBUG_DETAILED 3
 
+enum {
+	GType_Amazon = 1,
+	GType_MeanStreets = 2
+};
+
 enum AccessDebugChannels {
 	kDebugPath      = 1 << 0,
 	kDebugScripts	= 1 << 1,
@@ -86,8 +93,10 @@ protected:
 public:
 	Debugger *_debugger;
 	EventsManager *_events;
+	FileManager *_files;
 	GraphicsManager *_graphics;
 	Screen *_screen;
+	SoundManager *_sound;
 public:
 	AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc);
 	virtual ~AccessEngine();
diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp
index 3744141..53ddde9 100644
--- a/engines/access/amazon/amazon_game.cpp
+++ b/engines/access/amazon/amazon_game.cpp
@@ -35,6 +35,8 @@ void AmazonEngine::doTitle() {
 	_screen->forceFadeOut();
 	_events->hideCursor();
 
+	_sound->loadSound(98, 30);
+
 }
 
 } // End of namespace Amazon
diff --git a/engines/access/detection_tables.h b/engines/access/detection_tables.h
index 9030429..cbef1d3 100644
--- a/engines/access/detection_tables.h
+++ b/engines/access/detection_tables.h
@@ -22,11 +22,6 @@
 
 namespace Access {
 
-enum {
-	GType_Amazon = 1,
-	GType_MeanStreets = 2
-};
-
 static const AccessGameDescription gameDescriptions[] = {
 	{
 		// Amazon Guadians of Eden - Floppy English
diff --git a/engines/access/files.cpp b/engines/access/files.cpp
new file mode 100644
index 0000000..7da7574
--- /dev/null
+++ b/engines/access/files.cpp
@@ -0,0 +1,111 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, 0xwhose 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, 0xor (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, 0xwrite to the Free Software
+ * Foundation, 0xInc., 0x51 Franklin Street, 0xFifth Floor, 0xBoston, 0xMA 02110-1301, 0xUSA.
+ *
+ */
+
+#include "access/files.h"
+#include "access/resources.h"
+#include "access/access.h"
+
+namespace Access {
+
+FileManager::FileManager(AccessEngine *vm): _vm(vm) {
+	switch (vm->getGameID()) {
+	case GType_Amazon:
+		_filenames = &Amazon::FILENAMES[0];
+		break;
+	default:
+		error("Unknown game");
+	}
+
+	_fileNumber = -1;
+	_stream = nullptr;
+}
+
+FileManager::~FileManager() {
+	delete _stream;
+	_file.close();
+}
+
+void FileManager::loadFile(int fileNum, int subfile) {
+	setAppended(fileNum);
+	gotoAppended(subfile);
+
+	handleFile();
+}
+
+void FileManager::loadFile(const Common::String &filename) {
+	// Open up the file
+	_fileNumber = -1;
+	_file.close();
+	if (_file.open(filename))
+		error("Could not open file - %s", filename.c_str());
+
+	// Get a stream for the entire file
+	delete _stream;
+	_stream = _file.readStream(_file.size());
+
+	handleFile();
+}
+
+void FileManager::handleFile() {
+	char header[3];
+	_stream->read(&header[0], 3);
+
+	if (!strncmp(header, "BDE", 3))
+		// Decompress the resource
+		decompressFile();
+	else
+		// Not compressed, so move back to start of data
+		_stream->seek(0);
+}
+
+void FileManager::decompressFile() {
+	// TODO
+}
+
+void FileManager::setAppended(int fileNum) {
+	if (_fileNumber != fileNum) {
+		_fileNumber = fileNum;
+
+		_file.close();
+		if (!_file.open(_filenames[fileNum]))
+			error("Could not open file %s", _filenames[fileNum]);
+
+		// Read in the file index
+		_fileIndex.resize(50);
+		for (int i = 0; i < 50; ++i) {
+			_fileIndex[i]._offset = _file.readUint32LE();
+			_fileIndex[i]._nextOffset = _file.readUint32LE();
+		}
+	}
+}
+
+void FileManager::gotoAppended(int subfile) {
+	uint32 offset = _fileIndex[subfile]._offset;
+	uint32 size = _fileIndex[subfile]._nextOffset - offset;
+
+	_file.seek(offset);
+	delete _stream;
+	_stream = _file.readStream(size);
+}
+
+
+} // End of namespace Access
diff --git a/engines/access/files.h b/engines/access/files.h
new file mode 100644
index 0000000..fcd2480
--- /dev/null
+++ b/engines/access/files.h
@@ -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.
+ *
+ */
+
+#ifndef ACCESS_FILES_H
+#define ACCESS_FILES_H
+
+#include "common/scummsys.h"
+#include "common/file.h"
+
+namespace Access {
+
+class AccessEngine;
+
+struct FileEntry {
+	uint32 _offset;
+	uint32 _nextOffset;
+};
+
+class FileManager {
+private:
+	AccessEngine *_vm;
+	const char * const *_filenames;
+
+	void handleFile();
+
+	void decompressFile();
+
+public:
+	int _fileNumber;
+	Common::File _file;
+	Common::SeekableReadStream *_stream;
+	Common::Array<FileEntry> _fileIndex;
+	uint32 _entryOffset;
+	uint32 _nextOffset;
+public:
+	FileManager(AccessEngine *vm);
+	~FileManager();
+
+	void loadFile(int fileNum, int subfile);
+
+	void loadFile(const Common::String &filename);
+
+	/**
+	 * Open up a sub-file container file
+	 */
+	void setAppended(int fileNum);
+
+
+	/**
+	 * Open up a sub-file resource within an alrady opened container file.
+	 */
+	void gotoAppended(int subfile);
+};
+
+} // End of namespace Access
+
+#endif /* ACCESS_FILES_H */
diff --git a/engines/access/module.mk b/engines/access/module.mk
index a4fb864..7e23ede 100644
--- a/engines/access/module.mk
+++ b/engines/access/module.mk
@@ -5,9 +5,11 @@ MODULE_OBJS := \
 	debugger.o \
 	detection.o \
 	events.o \
+	files.o \
 	graphics.o \
 	resources.o \
 	screen.o \
+	sound.o \
 	amazon\amazon_game.o
 
 # This module can be built as a plugin
diff --git a/engines/access/resources.cpp b/engines/access/resources.cpp
index cf8b491..a47abf2 100644
--- a/engines/access/resources.cpp
+++ b/engines/access/resources.cpp
@@ -21,6 +21,7 @@
  */
 
 #include "access/resources.h"
+#include "access/access.h"
 
 namespace Access {
 
@@ -47,6 +48,30 @@ const byte INITIAL_PALETTE[18 * 3] = {
 
 namespace Amazon {
 
+const char *const FILENAMES[] = {
+	"S00.AP", "S01.AP", "S02.AP", "R03.AP", "S04.AP", "S05.AP",
+	"S06.AP", "S07.AP", "S08.AP", "S09.AP", "S10.AP", "S11.AP",
+	"S12.AP", "S13.AP", "S14.AP", "S15.AP", "S16.AP", "S17.AP",
+	"S18.AP", "S19.AP", "S20.AP", "S21.AP", "S22.AP", "S23.AP",
+	"S24.AP", "S25.AP", "S26.AP", "S27.AP", "S28.AP", "S29.AP",
+	"S30.AP", "S31.AP", "S32.AP", "S33.AP", "S34.AP", "R35.AP",
+	"S36.AP", "S37.AP", "S38.AP", "S39.AP", "S40.AP", "C26.AP",
+	"S42.AP", "S01.AP", "S44.AP", "S45.AP", "S46.AP", "S47.AP",
+	"C36.AP", nullptr,  "S50.AP", nullptr,  nullptr,  "S53.AP",
+	"S54.AP", "S55.AP", "C35.AP", "S57.AP", "S58.AP", nullptr,
+	nullptr,  "S61.AP", nullptr,  nullptr,  "S64.AP", "C00.AP",
+	"C01.AP", "C06.AP", "C07.AP", "C08.AP", "C05.AP", "C09.AP",
+	"C12.AP", "C03.AP", "C13.AP", "C15.AP", "C14.AP", "C16.AP",
+	"C17.AP", "C19.AP", "C20.AP", "C21.AP", "C22.AP", "C23.AP",
+	"C24.AP", "C25.AP", "C29.AP", "C30.AP", "C32.AP", "C33.AP",
+	"C34.AP", "CREDITS.AP", "MIDIDRV.AP", "SUMMARY.AP", "DEAD.AP",
+	"EST.AP", "CHAPTER.AP", "MIDI.AP", "SOUND.AP", "INV.AP",
+	"NARATE01.AP", "NARATE02.AP", "NARATE03.AP", "NARATE04.AP",
+	"NARATE05.AP", "NARATE06.AP", "NARATE07.AP", "NARATE08.AP",
+	"NARATE09.AP", "NARATE10.AP", "NARATE11.AP", "NARATE12.AP",
+	"NARATE13.AP", "NARATE14.AP"
+};
+
 const byte *CURSORS[10] = {
 	MOUSE0, MOUSE1, MOUSE2, MOUSE3, CURSEYE, CURSHAND, CURSGET, CURSCLIMB, CURSTALK, CURSHELP
 };
diff --git a/engines/access/resources.h b/engines/access/resources.h
index 7bd2354..ba335cd 100644
--- a/engines/access/resources.h
+++ b/engines/access/resources.h
@@ -31,6 +31,8 @@ extern const byte INITIAL_PALETTE[18 * 3];
 
 namespace Amazon {
 
+extern const char *const FILENAMES[];
+
 extern const byte MOUSE0[];
 extern const byte MOUSE1[];
 extern const byte MOUSE2[];
diff --git a/engines/access/sound.cpp b/engines/access/sound.cpp
new file mode 100644
index 0000000..d04d915
--- /dev/null
+++ b/engines/access/sound.cpp
@@ -0,0 +1,29 @@
+/* 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 "access/sound.h"
+
+namespace Access {
+
+SoundManager::SoundManager(AccessEngine *vm) : _vm(vm) {}
+
+} // End of namespace Access
diff --git a/engines/access/sound.h b/engines/access/sound.h
new file mode 100644
index 0000000..e35e647
--- /dev/null
+++ b/engines/access/sound.h
@@ -0,0 +1,43 @@
+/* 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 ACCESS_SOUND_H
+#define ACCESS_SOUND_H
+
+namespace Access {
+
+class AccessEngine;
+
+class SoundManager {
+private:
+	AccessEngine *_vm;
+public:
+	int _soundPriority;
+public:
+	SoundManager(AccessEngine *vm);
+
+	void loadSound(int fileNum, int subfile) {}
+};
+
+} // End of namespace Access
+
+#endif /* ACCESS_SOUND_H*/


Commit: 7a63e12edb98f47d9a262601d9d26d9444975314
    https://github.com/scummvm/scummvm/commit/7a63e12edb98f47d9a262601d9d26d9444975314
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-02T17:09:28-04:00

Commit Message:
ACCESS: Added screen loading and file index load fixes

Changed paths:
    engines/access/amazon/amazon_game.cpp
    engines/access/files.cpp
    engines/access/files.h
    engines/access/screen.cpp
    engines/access/screen.h
    engines/access/sound.cpp
    engines/access/sound.h



diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp
index 53ddde9..3f8ae73 100644
--- a/engines/access/amazon/amazon_game.cpp
+++ b/engines/access/amazon/amazon_game.cpp
@@ -35,8 +35,14 @@ void AmazonEngine::doTitle() {
 	_screen->forceFadeOut();
 	_events->hideCursor();
 
-	_sound->loadSound(98, 30);
-
+	_sound->_soundTable[0] = _sound->loadSound(98, 30);
+	_sound->_soundPriority[0] = 1;
+	_sound->_soundTable[1] = _sound->loadSound(98, 8);
+	_sound->_soundPriority[1] = 2;
+
+	_screen->_loadPalFlag = false;
+	byte *scr = _files->loadScreen(0, 3);
+	_screen->copyBuffer(scr);
 }
 
 } // End of namespace Amazon
diff --git a/engines/access/files.cpp b/engines/access/files.cpp
index 7da7574..549429b 100644
--- a/engines/access/files.cpp
+++ b/engines/access/files.cpp
@@ -44,41 +44,72 @@ FileManager::~FileManager() {
 	_file.close();
 }
 
-void FileManager::loadFile(int fileNum, int subfile) {
+byte *FileManager::loadFile(int fileNum, int subfile) {
 	setAppended(fileNum);
 	gotoAppended(subfile);
 
-	handleFile();
+	return handleFile();
 }
 
-void FileManager::loadFile(const Common::String &filename) {
+byte *FileManager::loadFile(const Common::String &filename) {
+	// Open the file
+	openFile(filename);
+
+	// Get a stream for the entire file
+	delete _stream;
+	_stream = _file.readStream(_file.size());
+
+	return handleFile();
+}
+
+void FileManager::openFile(const Common::String &filename) {
 	// Open up the file
 	_fileNumber = -1;
 	_file.close();
 	if (_file.open(filename))
 		error("Could not open file - %s", filename.c_str());
+}
 
-	// Get a stream for the entire file
+byte *FileManager::loadScreen(int fileNum, int subfile) {
+	setAppended(fileNum);
+	gotoAppended(subfile);
+	_vm->_screen->loadPalette(_stream);
+
+	return handleFile();
+}
+
+byte *FileManager::loadScreen(const Common::String &filename) {
+	// Open the file
+	openFile(filename);
+
+	// Get the palette
+	_vm->_screen->loadPalette(_stream);
+
+	// Get a stream for the remainder of the file
 	delete _stream;
 	_stream = _file.readStream(_file.size());
 
-	handleFile();
+	return handleFile();
 }
 
-void FileManager::handleFile() {
+byte *FileManager::handleFile() {
 	char header[3];
 	_stream->read(&header[0], 3);
 
-	if (!strncmp(header, "BDE", 3))
+	if (!strncmp(header, "DBE", 3))
 		// Decompress the resource
-		decompressFile();
-	else
-		// Not compressed, so move back to start of data
-		_stream->seek(0);
+		return decompressFile();
+	
+	// Not compressed, so pass out all of the file
+	_stream->seek(0);
+	byte *data = new byte[_stream->size()];
+	_stream->read(data, _stream->size());
+
+	return data;
 }
 
-void FileManager::decompressFile() {
-	// TODO
+byte *FileManager::decompressFile() {
+	error("TODO: decompression");
 }
 
 void FileManager::setAppended(int fileNum) {
@@ -90,17 +121,17 @@ void FileManager::setAppended(int fileNum) {
 			error("Could not open file %s", _filenames[fileNum]);
 
 		// Read in the file index
-		_fileIndex.resize(50);
-		for (int i = 0; i < 50; ++i) {
-			_fileIndex[i]._offset = _file.readUint32LE();
-			_fileIndex[i]._nextOffset = _file.readUint32LE();
-		}
+		int count = _file.readUint16LE();
+		assert(count <= 100);
+		_fileIndex.resize(count);
+		for (int i = 0; i < count; ++i)
+			_fileIndex[i] = _file.readUint32LE();
 	}
 }
 
 void FileManager::gotoAppended(int subfile) {
-	uint32 offset = _fileIndex[subfile]._offset;
-	uint32 size = _fileIndex[subfile]._nextOffset - offset;
+	uint32 offset = _fileIndex[subfile];
+	uint32 size = _fileIndex[subfile + 1] - offset;
 
 	_file.seek(offset);
 	delete _stream;
diff --git a/engines/access/files.h b/engines/access/files.h
index fcd2480..42b439c 100644
--- a/engines/access/files.h
+++ b/engines/access/files.h
@@ -24,47 +24,60 @@
 #define ACCESS_FILES_H
 
 #include "common/scummsys.h"
+#include "common/array.h"
 #include "common/file.h"
 
 namespace Access {
 
 class AccessEngine;
 
-struct FileEntry {
-	uint32 _offset;
-	uint32 _nextOffset;
-};
-
 class FileManager {
 private:
 	AccessEngine *_vm;
 	const char * const *_filenames;
 
-	void handleFile();
+	void openFile(const Common::String &filename);
+
+	byte *handleFile();
 
-	void decompressFile();
+	byte *decompressFile();
 
 public:
 	int _fileNumber;
 	Common::File _file;
 	Common::SeekableReadStream *_stream;
-	Common::Array<FileEntry> _fileIndex;
+	Common::Array<uint32> _fileIndex;
 	uint32 _entryOffset;
 	uint32 _nextOffset;
 public:
 	FileManager(AccessEngine *vm);
 	~FileManager();
 
-	void loadFile(int fileNum, int subfile);
+	/**
+	 * Load a given subfile from a container file
+	 */
+	byte *loadFile(int fileNum, int subfile);
+
+	/**
+	 * Load a given file by name
+	 */
+	byte *loadFile(const Common::String &filename);
 
-	void loadFile(const Common::String &filename);
+	/**
+	 * Load a given scren from a container file
+	 */
+	byte *loadScreen(int fileNum, int subfile);
+
+	/**
+	* Load a given screen by name
+	*/
+	byte *loadScreen(const Common::String &filename);
 
 	/**
 	 * Open up a sub-file container file
 	 */
 	void setAppended(int fileNum);
 
-
 	/**
 	 * Open up a sub-file resource within an alrady opened container file.
 	 */
diff --git a/engines/access/screen.cpp b/engines/access/screen.cpp
index 3f8dc4e..4059cab 100644
--- a/engines/access/screen.cpp
+++ b/engines/access/screen.cpp
@@ -32,6 +32,7 @@ namespace Access {
 Screen::Screen(AccessEngine *vm) : _vm(vm) {
 	create(320, 200, Graphics::PixelFormat::createFormatCLUT8());
 	Common::fill(&_tempPalette[0], &_tempPalette[PALETTE_SIZE], 0);
+	_loadPalFlag = false;
 }
 
 void Screen::setDisplayScan() {
@@ -49,6 +50,16 @@ void Screen::setInitialPalettte() {
 	g_system->getPaletteManager()->setPalette(INITIAL_PALETTE, 0, 18);
 }
 
+void Screen::loadPalette(Common::SeekableReadStream *stream) {
+	stream->read(&_rawPalette[0], PALETTE_SIZE);
+	setPalette();
+	_loadPalFlag = true;
+}
+
+void Screen::setPalette() {
+	g_system->getPaletteManager()->setPalette(&_rawPalette[0], 0, PALETTE_COUNT);
+}
+
 void Screen::updatePalette() {
 	g_system->getPaletteManager()->setPalette(&_tempPalette[0], 0, PALETTE_COUNT);
 	updateScreen();
@@ -97,4 +108,10 @@ void Screen::forceFadeIn() {
 	} while (repeatFlag);
 }
 
+void Screen::copyBuffer(const byte *data) {
+	byte *destP = (byte *)getPixels();
+	Common::copy(data, data + (h * w), destP);
+	g_system->copyRectToScreen(destP, w, 0, 0, w, h);
+}
+
 } // End of namespace Access
diff --git a/engines/access/screen.h b/engines/access/screen.h
index f8e0dab..d16333c 100644
--- a/engines/access/screen.h
+++ b/engines/access/screen.h
@@ -25,6 +25,7 @@
 
 #include "common/scummsys.h"
 #include "common/rect.h"
+#include "common/stream.h"
 #include "graphics/surface.h"
 
 namespace Access {
@@ -40,8 +41,12 @@ private:
 	byte _tempPalette[PALETTE_SIZE];
 	byte _rawPalette[PALETTE_SIZE];
 
+	void setPalette();
+
 	void updatePalette();
 public:
+	bool _loadPalFlag;
+public:
 	Screen(AccessEngine *vm);
 
 	void setDisplayScan();
@@ -65,6 +70,13 @@ public:
 	 * Set the initial palette
 	 */
 	void setInitialPalettte();
+
+	void loadPalette(Common::SeekableReadStream *stream);
+
+	/**
+	 * Copy a buffer to the screen
+	 */
+	void copyBuffer(const byte *data);
 };
 
 } // End of namespace Access
diff --git a/engines/access/sound.cpp b/engines/access/sound.cpp
index d04d915..baad635 100644
--- a/engines/access/sound.cpp
+++ b/engines/access/sound.cpp
@@ -20,10 +20,25 @@
  *
  */
 
+#include "common/algorithm.h"
+#include "access/access.h"
 #include "access/sound.h"
 
 namespace Access {
 
-SoundManager::SoundManager(AccessEngine *vm) : _vm(vm) {}
+SoundManager::SoundManager(AccessEngine *vm) : _vm(vm) {
+	Common::fill(&_soundTable[0], &_soundTable[MAX_SOUNDS], (byte *)nullptr);
+	Common::fill(&_soundPriority[0], &_soundPriority[MAX_SOUNDS], 0);
+}
+
+SoundManager::~SoundManager() {
+	for (int i = 0; i < MAX_SOUNDS; ++i)
+		delete _soundTable[i];
+}
+
+byte *SoundManager::loadSound(int fileNum, int subfile) {
+	return _vm->_files->loadFile(fileNum, subfile);
+}
+
 
 } // End of namespace Access
diff --git a/engines/access/sound.h b/engines/access/sound.h
index e35e647..5d173e2 100644
--- a/engines/access/sound.h
+++ b/engines/access/sound.h
@@ -23,6 +23,10 @@
 #ifndef ACCESS_SOUND_H
 #define ACCESS_SOUND_H
 
+#include "common/scummsys.h"
+
+#define MAX_SOUNDS 20
+
 namespace Access {
 
 class AccessEngine;
@@ -31,11 +35,13 @@ class SoundManager {
 private:
 	AccessEngine *_vm;
 public:
-	int _soundPriority;
+	byte *_soundTable[MAX_SOUNDS];
+	int _soundPriority[MAX_SOUNDS];
 public:
 	SoundManager(AccessEngine *vm);
+	~SoundManager();
 
-	void loadSound(int fileNum, int subfile) {}
+	byte *loadSound(int fileNum, int subfile);
 };
 
 } // End of namespace Access


Commit: d41c5cd7407a99fde350f2c9fbe9b4d6e73d1ba6
    https://github.com/scummvm/scummvm/commit/d41c5cd7407a99fde350f2c9fbe9b4d6e73d1ba6
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-03T16:59:22-04:00

Commit Message:
ACCESS: Added decompression code

Changed paths:
  A engines/access/decompress.cpp
  A engines/access/decompress.h
    engines/access/files.cpp
    engines/access/files.h
    engines/access/module.mk



diff --git a/engines/access/decompress.cpp b/engines/access/decompress.cpp
new file mode 100644
index 0000000..45ae07d
--- /dev/null
+++ b/engines/access/decompress.cpp
@@ -0,0 +1,127 @@
+/* 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 "common/debug.h"
+#include "common/endian.h"
+#include "common/util.h"
+
+#include "access/decompress.h"
+
+namespace Access {
+
+void LzwDecompressor::decompress(byte *source, byte *dest) {
+
+	_source = source;
+	
+	byte litByte;
+	uint16 copyLength, maxCodeValue, code, nextCode, lastCode, oldCode;
+
+	byte *copyBuf = new byte[8192];
+
+	struct { uint16 code; byte value; } codeTable[8192];
+	memset(codeTable, 0, sizeof(codeTable));
+
+	_codeLength = 9;
+	nextCode = 258;
+	maxCodeValue = 512;
+
+	copyLength = 0;
+	_bitPos = 0;
+
+	while (1) {
+
+		code = getCode();
+
+		if (code == 257)
+			break;
+
+		if (code == 256) {
+			_codeLength = 9;
+			nextCode = 258;
+			maxCodeValue = 512;
+			lastCode = getCode();
+			oldCode = lastCode;
+			litByte = lastCode;
+			*dest++ = litByte;
+		} else {
+			lastCode = code;
+			if (code >= nextCode) {
+				lastCode = oldCode;
+				copyBuf[copyLength++] = litByte;
+			}
+			while (lastCode > 255) {
+				copyBuf[copyLength++] = codeTable[lastCode].value;
+				lastCode = codeTable[lastCode].code;
+			}
+			litByte = lastCode;
+			copyBuf[copyLength++] = lastCode;
+			while (copyLength > 0)
+				*dest++ = copyBuf[--copyLength];
+			codeTable[nextCode].value = lastCode;
+			codeTable[nextCode].code = oldCode;
+			nextCode++;
+			oldCode = code;
+			if (nextCode >= maxCodeValue && _codeLength <= 12) {
+				_codeLength++;
+				maxCodeValue <<= 1;
+			}
+		}
+
+	}
+
+	delete[] copyBuf;
+
+}
+
+uint16 LzwDecompressor::getCode() {
+	const byte bitMasks[9] = {
+		0x00, 0x01, 0x03, 0x07, 0x0F, 0x1F, 0x3F, 0x7F, 0x0FF
+	};
+	uint16 bits, loCode, hiCode;
+	loCode = (READ_LE_UINT16(_source) >> _bitPos) & 0xFF;
+	_source++;
+	bits = _codeLength - 8;
+	hiCode = (READ_LE_UINT16(_source) >> _bitPos) & bitMasks[bits];
+	_bitPos += bits;
+	if (_bitPos > 8) {
+		_source++;
+		_bitPos -= 8;
+	}
+	return (hiCode << 8) | loCode;
+}
+
+uint32 decompressDBE(byte *source, byte **dest) {
+
+	uint32 destSize = READ_LE_UINT32(source + 4);
+	*dest = new byte[destSize];
+
+	debug(1, "decompressDBE() destSize = %d", destSize);
+
+	LzwDecompressor dec;
+	dec.decompress(source + 16, *dest);
+
+	debug(1, "decompressDBE() ok");
+
+	return destSize;
+}
+
+} // End of namespace Access
diff --git a/engines/access/decompress.h b/engines/access/decompress.h
new file mode 100644
index 0000000..522bfb2
--- /dev/null
+++ b/engines/access/decompress.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.
+/* 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 ACCESS_DECOMPRESS_H
+#define ACCESS_DECOMPRESS_H
+
+#include "common/scummsys.h"
+
+namespace Access {
+
+class LzwDecompressor {
+public:
+	void decompress(byte *source, byte *dest);
+private:
+	byte *_source;
+	byte _codeLength, _bitPos;
+	uint16 getCode();
+};
+
+uint32 decompressDBE(byte *source, byte **dest);
+
+} // End of namespace Access
+
+#endif
diff --git a/engines/access/files.cpp b/engines/access/files.cpp
index 549429b..7b4a23d 100644
--- a/engines/access/files.cpp
+++ b/engines/access/files.cpp
@@ -68,6 +68,8 @@ void FileManager::openFile(const Common::String &filename) {
 	_file.close();
 	if (_file.open(filename))
 		error("Could not open file - %s", filename.c_str());
+
+	_filesize = _file.size();
 }
 
 byte *FileManager::loadScreen(int fileNum, int subfile) {
@@ -83,11 +85,11 @@ byte *FileManager::loadScreen(const Common::String &filename) {
 	openFile(filename);
 
 	// Get the palette
-	_vm->_screen->loadPalette(_stream);
+	_vm->_screen->loadPalette(&_file);
 
 	// Get a stream for the remainder of the file
 	delete _stream;
-	_stream = _file.readStream(_file.size());
+	_stream = _file.readStream(_file.size() - _file.pos());
 
 	return handleFile();
 }
@@ -95,21 +97,23 @@ byte *FileManager::loadScreen(const Common::String &filename) {
 byte *FileManager::handleFile() {
 	char header[3];
 	_stream->read(&header[0], 3);
+	_stream->seek(-3, SEEK_CUR);
 
-	if (!strncmp(header, "DBE", 3))
-		// Decompress the resource
-		return decompressFile();
-	
-	// Not compressed, so pass out all of the file
-	_stream->seek(0);
-	byte *data = new byte[_stream->size()];
-	_stream->read(data, _stream->size());
+	bool isCompressed = !strncmp(header, "DBE", 3);
 
-	return data;
-}
+	// Get the data from the file or resource
+	_filesize = _stream->size() - _stream->pos();
+	byte *data = new byte[_filesize];
+	_stream->read(data, _filesize);
 
-byte *FileManager::decompressFile() {
-	error("TODO: decompression");
+	// If the data is compressed, uncompress it
+	if (isCompressed) {
+		byte *src = data;
+		_filesize = decompressDBE(src, &data);
+		delete[] src;
+	}
+
+	return data;
 }
 
 void FileManager::setAppended(int fileNum) {
@@ -138,5 +142,4 @@ void FileManager::gotoAppended(int subfile) {
 	_stream = _file.readStream(size);
 }
 
-
 } // End of namespace Access
diff --git a/engines/access/files.h b/engines/access/files.h
index 42b439c..9224b29 100644
--- a/engines/access/files.h
+++ b/engines/access/files.h
@@ -26,6 +26,7 @@
 #include "common/scummsys.h"
 #include "common/array.h"
 #include "common/file.h"
+#include "access/decompress.h"
 
 namespace Access {
 
@@ -39,16 +40,12 @@ private:
 	void openFile(const Common::String &filename);
 
 	byte *handleFile();
-
-	byte *decompressFile();
-
 public:
 	int _fileNumber;
 	Common::File _file;
 	Common::SeekableReadStream *_stream;
 	Common::Array<uint32> _fileIndex;
-	uint32 _entryOffset;
-	uint32 _nextOffset;
+	uint32 _filesize;
 public:
 	FileManager(AccessEngine *vm);
 	~FileManager();
diff --git a/engines/access/module.mk b/engines/access/module.mk
index 7e23ede..c9d593d 100644
--- a/engines/access/module.mk
+++ b/engines/access/module.mk
@@ -3,6 +3,7 @@ MODULE := engines/access
 MODULE_OBJS := \
 	access.o \
 	debugger.o \
+	decompress.o \
 	detection.o \
 	events.o \
 	files.o \


Commit: 04d42638cde9022523910b9ec75130bd85ec1fa5
    https://github.com/scummvm/scummvm/commit/04d42638cde9022523910b9ec75130bd85ec1fa5
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-04T09:21:39-04:00

Commit Message:
ACCESS: Fleshed out beginning of title sequence, added Screen::clip

Changed paths:
    engines/access/access.cpp
    engines/access/access.h
    engines/access/amazon/amazon_game.cpp
    engines/access/amazon/amazon_game.h
    engines/access/files.cpp
    engines/access/files.h
    engines/access/screen.cpp
    engines/access/screen.h
    engines/access/sound.cpp
    engines/access/sound.h



diff --git a/engines/access/access.cpp b/engines/access/access.cpp
index 25d9fcc..1470842 100644
--- a/engines/access/access.cpp
+++ b/engines/access/access.cpp
@@ -37,6 +37,9 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc)
 	_graphics = nullptr;
 	_screen = nullptr;
 	_sound = nullptr;
+
+	_destIn = nullptr;
+	_objectsTable = nullptr;
 }
 
 AccessEngine::~AccessEngine() {
@@ -46,6 +49,14 @@ AccessEngine::~AccessEngine() {
 	delete _graphics;
 	delete _screen;
 	delete _sound;
+
+	_buffer1.free();
+	_buffer2.free();
+	delete[] _objectsTable;
+}
+
+void AccessEngine::setVGA() {
+	initGraphics(320, 200, false);
 }
 
 void AccessEngine::initialize() {
@@ -59,13 +70,16 @@ void AccessEngine::initialize() {
 	_files = new FileManager(this);
 	_graphics = new GraphicsManager(this);
 	_screen = new Screen(this);
-	_sound = new SoundManager(this);
+	_sound = new SoundManager(this, _mixer);
+
+	_buffer1.create(g_system->getWidth(), g_system->getHeight(), Graphics::PixelFormat::createFormatCLUT8());
+	_buffer2.create(g_system->getWidth(), g_system->getHeight(), Graphics::PixelFormat::createFormatCLUT8());
 }
 
 Common::Error AccessEngine::run() {
+	setVGA();
 	initialize();
 
-	setVGA();
 	_screen->setInitialPalettte();
 	_events->setCursor(CURSOR_0);
 	_events->showCursor();
@@ -95,9 +109,4 @@ int AccessEngine::getRandomNumber(int maxNumber) {
 	return _randomSource.getRandomNumber(maxNumber);
 }
 
-void AccessEngine::setVGA() {
-	initGraphics(320, 200, false);
-}
-
-
 } // End of namespace Access
diff --git a/engines/access/access.h b/engines/access/access.h
index 3386cd9..05ef545 100644
--- a/engines/access/access.h
+++ b/engines/access/access.h
@@ -97,6 +97,13 @@ public:
 	GraphicsManager *_graphics;
 	Screen *_screen;
 	SoundManager *_sound;
+
+	byte *_destIn;
+	Graphics::Surface _buffer1;
+	Graphics::Surface _buffer2;
+	byte *_objectsTable;
+	int _pCount;
+
 public:
 	AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc);
 	virtual ~AccessEngine();
diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp
index 3f8ae73..3073308 100644
--- a/engines/access/amazon/amazon_game.cpp
+++ b/engines/access/amazon/amazon_game.cpp
@@ -30,19 +30,46 @@ AmazonEngine::AmazonEngine(OSystem *syst, const AccessGameDescription *gameDesc)
 		AccessEngine(syst, gameDesc) {
 }
 
+AmazonEngine::~AmazonEngine() {
+}
+
+
 void AmazonEngine::doTitle() {
 	_screen->setDisplayScan();
+	_destIn = (byte *)_buffer2.getPixels();
+
 	_screen->forceFadeOut();
 	_events->hideCursor();
 
-	_sound->_soundTable[0] = _sound->loadSound(98, 30);
+	_sound->queueSound(0, 98, 30);
 	_sound->_soundPriority[0] = 1;
-	_sound->_soundTable[1] = _sound->loadSound(98, 8);
-	_sound->_soundPriority[1] = 2;
 
 	_screen->_loadPalFlag = false;
-	byte *scr = _files->loadScreen(0, 3);
-	_screen->copyBuffer(scr);
+	_files->loadScreen(0, 3);
+	
+	_buffer2.copyFrom(*_screen);
+	_buffer1.copyFrom(*_screen);
+	_screen->forceFadeIn();
+	_sound->playSound(1);
+
+	_objectsTable = _files->loadFile(0, 2);
+	_sound->playSound(1);
+
+	_screen->_loadPalFlag = false;
+	_files->loadScreen(0, 4);
+	_sound->playSound(1);
+
+	_buffer2.copyFrom(*_screen);
+	_buffer1.copyFrom(*_screen);
+	_sound->playSound(1);
+
+	const int COUNTDOWN[6] = { 2, 0x80, 1, 0x7d, 0, 0x87 };
+	for (int _pCount = 0; _pCount < 3; ++_pCount) {
+		_buffer2.copyFrom(_buffer1);
+		int id = READ_LE_UINT16(COUNTDOWN + _pCount * 4);
+		int xp = READ_LE_UINT16(COUNTDOWN + _pCount * 4 + 2);
+		_screen->plotImage(_objectsTable, id, Common::Point(xp, 71));
+	}
 }
 
 } // End of namespace Amazon
diff --git a/engines/access/amazon/amazon_game.h b/engines/access/amazon/amazon_game.h
index 30ec2c6..33d7833 100644
--- a/engines/access/amazon/amazon_game.h
+++ b/engines/access/amazon/amazon_game.h
@@ -35,7 +35,7 @@ protected:
 public:
 	AmazonEngine(OSystem *syst, const AccessGameDescription *gameDesc);
 
-	virtual ~AmazonEngine() {}
+	virtual ~AmazonEngine();
 };
 
 } // End of namespace Amazon
diff --git a/engines/access/files.cpp b/engines/access/files.cpp
index 7b4a23d..37b2578 100644
--- a/engines/access/files.cpp
+++ b/engines/access/files.cpp
@@ -72,15 +72,18 @@ void FileManager::openFile(const Common::String &filename) {
 	_filesize = _file.size();
 }
 
-byte *FileManager::loadScreen(int fileNum, int subfile) {
+void FileManager::loadScreen(int fileNum, int subfile) {
 	setAppended(fileNum);
 	gotoAppended(subfile);
 	_vm->_screen->loadPalette(_stream);
 
-	return handleFile();
+	// Get the data for the screen, and copy it over
+	byte *pSrc = handleFile();
+	Common::copy(pSrc, pSrc + _filesize, (byte *)_vm->_screen->getPixels());
+	delete[] pSrc;
 }
 
-byte *FileManager::loadScreen(const Common::String &filename) {
+void FileManager::loadScreen(const Common::String &filename) {
 	// Open the file
 	openFile(filename);
 
@@ -91,7 +94,10 @@ byte *FileManager::loadScreen(const Common::String &filename) {
 	delete _stream;
 	_stream = _file.readStream(_file.size() - _file.pos());
 
-	return handleFile();
+	// Get the data for the screen, and copy it over
+	byte *pSrc = handleFile();
+	Common::copy(pSrc, pSrc + _filesize, (byte *)_vm->_screen->getPixels());
+	delete[] pSrc;
 }
 
 byte *FileManager::handleFile() {
diff --git a/engines/access/files.h b/engines/access/files.h
index 9224b29..848ee0d 100644
--- a/engines/access/files.h
+++ b/engines/access/files.h
@@ -63,12 +63,12 @@ public:
 	/**
 	 * Load a given scren from a container file
 	 */
-	byte *loadScreen(int fileNum, int subfile);
+	void loadScreen(int fileNum, int subfile);
 
 	/**
 	* Load a given screen by name
 	*/
-	byte *loadScreen(const Common::String &filename);
+	void loadScreen(const Common::String &filename);
 
 	/**
 	 * Open up a sub-file container file
diff --git a/engines/access/screen.cpp b/engines/access/screen.cpp
index 4059cab..cb0154d 100644
--- a/engines/access/screen.cpp
+++ b/engines/access/screen.cpp
@@ -21,6 +21,8 @@
  */
 
 #include "common/algorithm.h"
+#include "common/endian.h"
+#include "common/rect.h"
 #include "common/textconsole.h"
 #include "common/system.h"
 #include "graphics/palette.h"
@@ -33,6 +35,9 @@ Screen::Screen(AccessEngine *vm) : _vm(vm) {
 	create(320, 200, Graphics::PixelFormat::createFormatCLUT8());
 	Common::fill(&_tempPalette[0], &_tempPalette[PALETTE_SIZE], 0);
 	_loadPalFlag = false;
+	_leftSkip = _rightSkip = 0;
+	_topSkip = _bottomSkip = 0;
+	_clipWidth = _clipHeight = 0;
 }
 
 void Screen::setDisplayScan() {
@@ -114,4 +119,58 @@ void Screen::copyBuffer(const byte *data) {
 	g_system->copyRectToScreen(destP, w, 0, 0, w, h);
 }
 
+void Screen::plotImage(const byte *pData, int idx, const Common::Point &pt) {
+	const byte *sizeP = pData + READ_LE_UINT16(pData + idx * 4);
+	int w = READ_LE_UINT16(sizeP);
+	int h = READ_LE_UINT16(sizeP + 2);
+	Common::Rect r(pt.x, pt.y, pt.x + w, pt.y + h);
+
+	if (!clip(r)) {
+		_lastBounds = r;
+		//plotf();
+	}
+}
+
+bool Screen::clip(Common::Rect &r) {
+	int skip;
+	_leftSkip = _rightSkip = 0;
+	_topSkip = _bottomSkip = 0;
+
+	if (r.left > _clipWidth) {
+		skip = -r.left;
+		r.setWidth(r.width() - skip);
+		_leftSkip = skip;
+		r.moveTo(0, r.top);
+	} else if (r.left >= 0)
+		return true;
+
+	int right = r.right - 1;
+	if (right < 0)
+		return true;
+	else if (right > _clipWidth) {
+		skip = right - _clipWidth;
+		r.setWidth(r.width() - skip);
+		_rightSkip = skip;
+	}
+
+	if (r.top > _clipHeight) {
+		skip = -r.top;
+		r.setHeight(r.height() - skip);
+		_topSkip = skip;
+		r.moveTo(r.left, 0);
+	} else if (r.top >= 0)
+		return true;
+
+	int bottom = r.bottom - 1;
+	if (bottom < 0)
+		return true;
+	else if (bottom > _clipHeight) {
+		skip = bottom - _clipHeight;
+		_bottomSkip = skip;
+		r.setHeight(r.height() - skip);
+	}
+
+	return false;
+}
+
 } // End of namespace Access
diff --git a/engines/access/screen.h b/engines/access/screen.h
index d16333c..0d68c1b 100644
--- a/engines/access/screen.h
+++ b/engines/access/screen.h
@@ -40,10 +40,16 @@ private:
 	AccessEngine *_vm;
 	byte _tempPalette[PALETTE_SIZE];
 	byte _rawPalette[PALETTE_SIZE];
+	Common::Rect _lastBounds;
+	int _leftSkip, _rightSkip;
+	int _topSkip, _bottomSkip;
+	int _clipWidth, _clipHeight;
 
 	void setPalette();
 
 	void updatePalette();
+
+	bool clip(Common::Rect &r);
 public:
 	bool _loadPalFlag;
 public:
@@ -77,6 +83,8 @@ public:
 	 * Copy a buffer to the screen
 	 */
 	void copyBuffer(const byte *data);
+
+	void plotImage(const byte *pData, int idx, const Common::Point &pt);
 };
 
 } // End of namespace Access
diff --git a/engines/access/sound.cpp b/engines/access/sound.cpp
index baad635..5375485 100644
--- a/engines/access/sound.cpp
+++ b/engines/access/sound.cpp
@@ -21,24 +21,47 @@
  */
 
 #include "common/algorithm.h"
+#include "audio/audiostream.h"
 #include "access/access.h"
 #include "access/sound.h"
 
 namespace Access {
 
-SoundManager::SoundManager(AccessEngine *vm) : _vm(vm) {
-	Common::fill(&_soundTable[0], &_soundTable[MAX_SOUNDS], (byte *)nullptr);
+SoundManager::SoundManager(AccessEngine *vm, Audio::Mixer *mixer) : 
+		_vm(vm), _mixer(mixer) {
 	Common::fill(&_soundPriority[0], &_soundPriority[MAX_SOUNDS], 0);
+	for (int i = 0; i < MAX_SOUNDS; ++i)
+		_soundTable[i]._data = nullptr;
 }
 
 SoundManager::~SoundManager() {
 	for (int i = 0; i < MAX_SOUNDS; ++i)
-		delete _soundTable[i];
+		delete _soundTable[i]._data;
+}
+
+void SoundManager::queueSound(int idx, int fileNum, int subfile) {
+	/*
+	_soundTable[idx]._data = _vm->_files->loadFile(fileNum, subfile);
+	_soundTable[idx]._size = _vm->_files->_filesize;
+	*/
 }
 
 byte *SoundManager::loadSound(int fileNum, int subfile) {
 	return _vm->_files->loadFile(fileNum, subfile);
 }
 
+void SoundManager::playSound(int soundIndex) {
+	int idx = _soundPriority[soundIndex - 1] - 1;
+	playSound(_soundTable[idx]._data, _soundTable[idx]._size);
+}
+
+void SoundManager::playSound(byte *data, uint32 size) {
+	/*
+	Audio::QueuingAudioStream *audioStream = Audio::makeQueuingAudioStream(22050, false);
+	audioStream->queueBuffer(data, size, DisposeAfterUse::YES, 0);
+	_mixer->playStream(Audio::Mixer::kPlainSoundType, &_soundHandle, audioStream, -1, 
+		Audio::Mixer::kMaxChannelVolume, 0, DisposeAfterUse::YES, false);
+		*/
+}
 
 } // End of namespace Access
diff --git a/engines/access/sound.h b/engines/access/sound.h
index 5d173e2..d3d5052 100644
--- a/engines/access/sound.h
+++ b/engines/access/sound.h
@@ -24,6 +24,7 @@
 #define ACCESS_SOUND_H
 
 #include "common/scummsys.h"
+#include "audio/mixer.h"
 
 #define MAX_SOUNDS 20
 
@@ -32,16 +33,28 @@ namespace Access {
 class AccessEngine;
 
 class SoundManager {
+	struct SoundEntry {
+		byte *_data;
+		uint32 _size;
+	};
 private:
 	AccessEngine *_vm;
+	Audio::Mixer *_mixer;
+	Audio::SoundHandle _soundHandle;
+
+	byte *loadSound(int fileNum, int subfile);
+
+	void playSound(byte *data, uint32 size);
 public:
-	byte *_soundTable[MAX_SOUNDS];
+	SoundEntry _soundTable[MAX_SOUNDS];
 	int _soundPriority[MAX_SOUNDS];
 public:
-	SoundManager(AccessEngine *vm);
+	SoundManager(AccessEngine *vm, Audio::Mixer *mixer);
 	~SoundManager();
 
-	byte *loadSound(int fileNum, int subfile);
+	void queueSound(int idx, int fileNum, int subfile);
+
+	void playSound(int soundIndex);
 };
 
 } // End of namespace Access


Commit: bb48a153a6479e08fe37c3547e14622226efeeb2
    https://github.com/scummvm/scummvm/commit/bb48a153a6479e08fe37c3547e14622226efeeb2
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-04T21:35:49-04:00

Commit Message:
ACCESS: Remove graphics manager, and added more skeleton for Amazon intro

Changed paths:
  A engines/access/asurface.cpp
  A engines/access/asurface.h
  R engines/access/graphics.cpp
  R engines/access/graphics.h
    engines/access/access.cpp
    engines/access/access.h
    engines/access/amazon/amazon_game.cpp
    engines/access/amazon/amazon_game.h
    engines/access/module.mk
    engines/access/screen.cpp
    engines/access/screen.h



diff --git a/engines/access/access.cpp b/engines/access/access.cpp
index 1470842..af64612 100644
--- a/engines/access/access.cpp
+++ b/engines/access/access.cpp
@@ -34,7 +34,6 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc)
 	_debugger = nullptr;
 	_events = nullptr;
 	_files = nullptr;
-	_graphics = nullptr;
 	_screen = nullptr;
 	_sound = nullptr;
 
@@ -46,7 +45,6 @@ AccessEngine::~AccessEngine() {
 	delete _debugger;
 	delete _events;
 	delete _files;
-	delete _graphics;
 	delete _screen;
 	delete _sound;
 
@@ -68,7 +66,6 @@ void AccessEngine::initialize() {
 	_debugger = new Debugger(this);
 	_events = new EventsManager(this);
 	_files = new FileManager(this);
-	_graphics = new GraphicsManager(this);
 	_screen = new Screen(this);
 	_sound = new SoundManager(this, _mixer);
 
@@ -80,11 +77,7 @@ Common::Error AccessEngine::run() {
 	setVGA();
 	initialize();
 
-	_screen->setInitialPalettte();
-	_events->setCursor(CURSOR_0);
-	_events->showCursor();
-	_graphics->setPanel(0);
-	doTitle();
+	playGame();
 
 	dummyLoop();
 	return Common::kNoError;
diff --git a/engines/access/access.h b/engines/access/access.h
index 05ef545..f6d51cc 100644
--- a/engines/access/access.h
+++ b/engines/access/access.h
@@ -33,7 +33,6 @@
 #include "access/debugger.h"
 #include "access/events.h"
 #include "access/files.h"
-#include "access/graphics.h"
 #include "access/screen.h"
 #include "access/sound.h"
 
@@ -87,14 +86,13 @@ protected:
 	virtual bool hasFeature(EngineFeature f) const;
 protected:
 	/**
-	 * Show game title
+	 * Play the game
 	 */
-	virtual void doTitle() = 0;
+	virtual void playGame() = 0;
 public:
 	Debugger *_debugger;
 	EventsManager *_events;
 	FileManager *_files;
-	GraphicsManager *_graphics;
 	Screen *_screen;
 	SoundManager *_sound;
 
diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp
index 3073308..681819f 100644
--- a/engines/access/amazon/amazon_game.cpp
+++ b/engines/access/amazon/amazon_game.cpp
@@ -28,11 +28,41 @@ namespace Amazon {
 
 AmazonEngine::AmazonEngine(OSystem *syst, const AccessGameDescription *gameDesc) :
 		AccessEngine(syst, gameDesc) {
+	_skipStart = false;
 }
 
 AmazonEngine::~AmazonEngine() {
 }
 
+void AmazonEngine::playGame() {
+	_screen->setInitialPalettte();
+	_events->setCursor(CURSOR_0);
+	_events->showCursor();
+	_screen->setPanel(0);
+	
+	doTitle();
+	if (shouldQuit())
+		return;
+
+	if (!_skipStart) {
+		_screen->setPanel(3);
+		doOpening();
+		if (shouldQuit())
+			return;
+
+		if (!_skipStart) {
+			doTent();
+			if (shouldQuit())
+				return;
+		}
+	}
+
+	doTitle();
+	if (shouldQuit())
+		return;
+
+	_screen->clearScreen();
+}
 
 void AmazonEngine::doTitle() {
 	_screen->setDisplayScan();
@@ -70,6 +100,15 @@ void AmazonEngine::doTitle() {
 		int xp = READ_LE_UINT16(COUNTDOWN + _pCount * 4 + 2);
 		_screen->plotImage(_objectsTable, id, Common::Point(xp, 71));
 	}
+	// TODO: More to do
+}
+
+void AmazonEngine::doOpening() {
+	// TODO
+}
+
+void AmazonEngine::doTent() {
+	// TODO
 }
 
 } // End of namespace Amazon
diff --git a/engines/access/amazon/amazon_game.h b/engines/access/amazon/amazon_game.h
index 33d7833..79a74b3 100644
--- a/engines/access/amazon/amazon_game.h
+++ b/engines/access/amazon/amazon_game.h
@@ -30,8 +30,28 @@ namespace Access {
 namespace Amazon {
 
 class AmazonEngine : public AccessEngine {
+private:
+	bool _skipStart;
+
+	/**
+	 * Do title sequence
+	 */
+	void doTitle();
+
+	/**
+	 * Do opening sequence
+	 */
+	void doOpening();
+
+	/**
+	 * Do tent scene of introduction
+	 */
+	void doTent();
 protected:
-	virtual void doTitle();
+	/**
+	 * Play the game
+	 */
+	virtual void playGame();
 public:
 	AmazonEngine(OSystem *syst, const AccessGameDescription *gameDesc);
 
diff --git a/engines/access/asurface.cpp b/engines/access/asurface.cpp
new file mode 100644
index 0000000..a0a790d
--- /dev/null
+++ b/engines/access/asurface.cpp
@@ -0,0 +1,33 @@
+/* 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 "common/algorithm.h"
+#include "access/asurface.h"
+
+namespace Access {
+
+void ASurface::clearBuffer() {
+	byte *pSrc = (byte *)getPixels();
+	Common::fill(pSrc, pSrc + w * h, 0);
+}
+
+} // End of namespace Access
diff --git a/engines/access/asurface.h b/engines/access/asurface.h
new file mode 100644
index 0000000..ecd04b9
--- /dev/null
+++ b/engines/access/asurface.h
@@ -0,0 +1,38 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef ACCESS_ASURFACE_H
+#define ACCESS_ASURFACE_H
+
+#include "common/rect.h"
+#include "graphics/surface.h"
+
+namespace Access {
+
+class ASurface : public Graphics::Surface {
+public:
+	void clearBuffer();
+};
+
+} // End of namespace Access
+
+#endif /* ACCESS_ASURFACE_H */
diff --git a/engines/access/graphics.cpp b/engines/access/graphics.cpp
deleted file mode 100644
index c1187f2..0000000
--- a/engines/access/graphics.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.
- *
- */
-
-#include "graphics/palette.h"
-#include "access/access.h"
-#include "access/graphics.h"
-#include "access/resources.h"
-
-namespace Access {
-
-GraphicsManager::GraphicsManager(AccessEngine *vm) : _vm(vm) {
-	_vesaCurrentWin = 0;
-	_currentPanel = 0;
-	_hideFlag = true;
-}
-
-void GraphicsManager::setPanel(int num) {
-	assert(num < 4);
-	_currentPanel = num;
-	_msVirtualOffset = _virtualOffsetsTable[num];
-}
-
-} // End of namespace Access
diff --git a/engines/access/graphics.h b/engines/access/graphics.h
deleted file mode 100644
index df62617..0000000
--- a/engines/access/graphics.h
+++ /dev/null
@@ -1,50 +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 ACCESS_GRAPHICS_H
-#define ACCESS_GRAPHICS_H
-
-#include "common/rect.h"
-#include "graphics/surface.h"
-
-namespace Access {
-
-class AccessEngine;
-
-class GraphicsManager {
-private:
-	AccessEngine *_vm;
-public:
-	int _vesaCurrentWin;
-	int _currentPanel;
-	Common::Point _msVirtualOffset;
-	Common::Point _virtualOffsetsTable[4];
-	bool _hideFlag;
-public:
-	GraphicsManager(AccessEngine *vm);
-
-	void setPanel(int num);
-};
-
-} // End of namespace Access
-
-#endif /* ACCESS_GRAPHICS_H */
diff --git a/engines/access/module.mk b/engines/access/module.mk
index c9d593d..ff4cedb 100644
--- a/engines/access/module.mk
+++ b/engines/access/module.mk
@@ -1,13 +1,13 @@
 MODULE := engines/access
 
 MODULE_OBJS := \
+	asurface.o \
 	access.o \
 	debugger.o \
 	decompress.o \
 	detection.o \
 	events.o \
 	files.o \
-	graphics.o \
 	resources.o \
 	screen.o \
 	sound.o \
diff --git a/engines/access/screen.cpp b/engines/access/screen.cpp
index cb0154d..591bb67 100644
--- a/engines/access/screen.cpp
+++ b/engines/access/screen.cpp
@@ -34,6 +34,9 @@ namespace Access {
 Screen::Screen(AccessEngine *vm) : _vm(vm) {
 	create(320, 200, Graphics::PixelFormat::createFormatCLUT8());
 	Common::fill(&_tempPalette[0], &_tempPalette[PALETTE_SIZE], 0);
+	_vesaCurrentWin = 0;
+	_currentPanel = 0;
+	_hideFlag = true;
 	_loadPalFlag = false;
 	_leftSkip = _rightSkip = 0;
 	_topSkip = _bottomSkip = 0;
@@ -44,6 +47,12 @@ void Screen::setDisplayScan() {
 	warning("TODO: setDisplayScan");
 }
 
+void Screen::setPanel(int num) {
+	assert(num < 4);
+	_currentPanel = num;
+	_msVirtualOffset = _virtualOffsetsTable[num];
+}
+
 void Screen::updateScreen() {
 	g_system->updateScreen();
 }
diff --git a/engines/access/screen.h b/engines/access/screen.h
index 0d68c1b..2953727 100644
--- a/engines/access/screen.h
+++ b/engines/access/screen.h
@@ -26,7 +26,7 @@
 #include "common/scummsys.h"
 #include "common/rect.h"
 #include "common/stream.h"
-#include "graphics/surface.h"
+#include "access/asurface.h"
 
 namespace Access {
 
@@ -35,11 +35,16 @@ class AccessEngine;
 #define PALETTE_COUNT 256
 #define PALETTE_SIZE (256 * 3)
 
-class Screen: public Graphics::Surface {
+class Screen: public ASurface {
 private:
 	AccessEngine *_vm;
 	byte _tempPalette[PALETTE_SIZE];
 	byte _rawPalette[PALETTE_SIZE];
+	int _vesaCurrentWin;
+	int _currentPanel;
+	Common::Point _msVirtualOffset;
+	Common::Point _virtualOffsetsTable[4];
+	bool _hideFlag;
 	Common::Rect _lastBounds;
 	int _leftSkip, _rightSkip;
 	int _topSkip, _bottomSkip;
@@ -57,6 +62,8 @@ public:
 
 	void setDisplayScan();
 
+	void setPanel(int num);
+
 	/**
 	 * Update the underlying screen
 	 */
@@ -72,6 +79,8 @@ public:
 	 */
 	void forceFadeIn();
 
+	void clearScreen() { clearBuffer(); }
+
 	/**
 	 * Set the initial palette
 	 */


Commit: e6b1d148ce184a53598fbf9cefa28689678b47a9
    https://github.com/scummvm/scummvm/commit/e6b1d148ce184a53598fbf9cefa28689678b47a9
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-04T22:38:50-04:00

Commit Message:
ACCESS: Added Globals classes

Changed paths:
  A engines/access/amazon/amazon_globals.cpp
  A engines/access/amazon/amazon_globals.h
  A engines/access/globals.cpp
  A engines/access/globals.h
    engines/access/access.cpp
    engines/access/access.h
    engines/access/amazon/amazon_game.cpp
    engines/access/amazon/amazon_game.h
    engines/access/module.mk



diff --git a/engines/access/access.cpp b/engines/access/access.cpp
index af64612..3639115 100644
--- a/engines/access/access.cpp
+++ b/engines/access/access.cpp
@@ -34,11 +34,30 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc)
 	_debugger = nullptr;
 	_events = nullptr;
 	_files = nullptr;
+	_globals = nullptr;
 	_screen = nullptr;
 	_sound = nullptr;
 
 	_destIn = nullptr;
 	_objectsTable = nullptr;
+	_pCount = 0;
+	_currentMan = 0;
+	_currentManOld = -1;
+	_man1 = nullptr;
+	_manPal1 = nullptr;
+	_music = nullptr;
+	_playField = nullptr;
+	_script = nullptr;
+	_anim = nullptr;
+	_title = nullptr;
+	_converseMode = 0;
+	_startInvItem = 0;
+	_startAboutItem = 0;
+	_startTravelItem = 0;
+	_startInvBox = 0;
+	_startAboutBox = 0;
+	_startTravelBox = 0;
+
 }
 
 AccessEngine::~AccessEngine() {
diff --git a/engines/access/access.h b/engines/access/access.h
index f6d51cc..3428711 100644
--- a/engines/access/access.h
+++ b/engines/access/access.h
@@ -33,6 +33,7 @@
 #include "access/debugger.h"
 #include "access/events.h"
 #include "access/files.h"
+#include "access/globals.h"
 #include "access/screen.h"
 #include "access/sound.h"
 
@@ -93,6 +94,7 @@ public:
 	Debugger *_debugger;
 	EventsManager *_events;
 	FileManager *_files;
+	Globals *_globals;
 	Screen *_screen;
 	SoundManager *_sound;
 
@@ -102,6 +104,23 @@ public:
 	byte *_objectsTable;
 	int _pCount;
 
+	int _currentMan;
+	int _currentManOld;
+	byte *_man1;
+	byte *_manPal1;
+	byte *_music;
+	byte *_playField;
+	byte *_script;
+	byte *_anim;
+	byte *_title;
+	int _converseMode;
+	int _startInvItem;
+	int _startAboutItem;
+	int _startTravelItem;
+	int _startInvBox;
+	int _startAboutBox;
+	int _startTravelBox;
+
 public:
 	AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc);
 	virtual ~AccessEngine();
diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp
index 681819f..af7b77e 100644
--- a/engines/access/amazon/amazon_game.cpp
+++ b/engines/access/amazon/amazon_game.cpp
@@ -21,6 +21,7 @@
  */
 
 #include "access/amazon/amazon_game.h"
+#include "access/amazon/amazon_globals.h"
 
 namespace Access {
 
@@ -28,10 +29,12 @@ namespace Amazon {
 
 AmazonEngine::AmazonEngine(OSystem *syst, const AccessGameDescription *gameDesc) :
 		AccessEngine(syst, gameDesc) {
+	_globals = new AmazonGlobals();
 	_skipStart = false;
 }
 
 AmazonEngine::~AmazonEngine() {
+	delete _globals;
 }
 
 void AmazonEngine::playGame() {
@@ -62,6 +65,10 @@ void AmazonEngine::playGame() {
 		return;
 
 	_screen->clearScreen();
+	_screen->setPanel(0);
+	_screen->forceFadeOut();
+
+
 }
 
 void AmazonEngine::doTitle() {
@@ -111,6 +118,7 @@ void AmazonEngine::doTent() {
 	// TODO
 }
 
+
 } // End of namespace Amazon
 
 } // End of namespace Access
diff --git a/engines/access/amazon/amazon_game.h b/engines/access/amazon/amazon_game.h
index 79a74b3..42fc31d 100644
--- a/engines/access/amazon/amazon_game.h
+++ b/engines/access/amazon/amazon_game.h
@@ -24,6 +24,7 @@
 #define ACCESS_AMAZON_GAME_H
 
 #include "access/access.h"
+#include "access/amazon/amazon_globals.h"
 
 namespace Access {
 
@@ -47,6 +48,11 @@ private:
 	 * Do tent scene of introduction
 	 */
 	void doTent();
+
+	/**
+	 * Get globals reference
+	 */
+	AmazonGlobals &globals() { return *(AmazonGlobals *)_globals; }
 protected:
 	/**
 	 * Play the game
diff --git a/engines/access/amazon/amazon_globals.cpp b/engines/access/amazon/amazon_globals.cpp
new file mode 100644
index 0000000..7982233
--- /dev/null
+++ b/engines/access/amazon/amazon_globals.cpp
@@ -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 = 0; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation = 0; 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 = 0; 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 = 0; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "common/algorithm.h"
+#include "access/amazon/amazon_globals.h"
+
+namespace Access {
+
+namespace Amazon {
+
+AmazonGlobals::AmazonGlobals() : Globals() {
+	_canoeLane = 0;
+	_canoeYPos = 0;
+	_hitCount = 0;
+	_saveRiver = 0;
+	_hitSafe = 0;
+	_chapter = 0;
+	_topList = 0;
+	_botList = 0;
+	_riverIndex = 0;
+	_rawInactiveX = 0;
+	_rawInactiveY = 0;
+	_inactiveYOff = 0;
+	Common::fill(&_esTabTable[0], &_esTabTable[100], 0);
+}
+
+} // End of namespace Amazon
+
+} // End of namespace Access
diff --git a/engines/access/amazon/amazon_globals.h b/engines/access/amazon/amazon_globals.h
new file mode 100644
index 0000000..d9631f7
--- /dev/null
+++ b/engines/access/amazon/amazon_globals.h
@@ -0,0 +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.
+ *
+ */
+
+#ifndef ACCESS_AMAZON_GLOBALS_H
+#define ACCESS_AMAZON_GLOBALS_H
+
+#include "common/scummsys.h"
+#include "access/globals.h"
+
+namespace Access {
+
+namespace Amazon {
+
+class AmazonGlobals: public Globals {
+public:
+	int _canoeLane;
+	int _canoeYPos;
+	int _hitCount;
+	int _saveRiver;
+	int _hitSafe;
+	int _chapter;
+	int _topList;
+	int _botList;
+	int _riverIndex;
+	int _rawInactiveX;
+	int _rawInactiveY;
+	int _inactiveYOff;
+	int _esTabTable[100];
+public:
+	AmazonGlobals();
+
+	virtual ~AmazonGlobals() {}
+};
+
+} // End of namespace Amazon
+
+} // End of namespace Access
+
+#endif /* ACCESS_AMAZON_GLOBALS_H */
diff --git a/engines/access/globals.cpp b/engines/access/globals.cpp
new file mode 100644
index 0000000..ab0c37b1
--- /dev/null
+++ b/engines/access/globals.cpp
@@ -0,0 +1,75 @@
+/* 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 = 0; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation = 0; 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 = 0; 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 = 0; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "common/algorithm.h"
+#include "access/globals.h"
+
+namespace Access {
+
+Globals::Globals() {
+	_startData = 0;
+	_rawPlayerXLow = 0;
+	_rawPlayerX = 0;
+	_rawPlayerYLow = 0;
+	_rawPlayerY = 0;
+	_conversation = 0;
+	_currentMan = 0;
+	_newTime = 0;
+	_newDate = 0;
+	_intTim[3] = 0;
+	_timer[3] = 0;
+	_timerFlag = false;
+	Common::fill(&_flags[0], &_flags[99], 0);
+	Common::fill(&_useItem[0], &_useItem[23], 0);
+	_guardLoc = 0;
+	_guardFind = 0;
+	_helpLevel = 0;
+	_jasMayaFlag = 0;
+	_moreHelp = 0;
+	_startup = 0;
+	_flashbackFlag = false;
+	_manScaleOff = 0;
+	_riverFlag = false;
+	_antOutFlag = false;
+	_badEnd = 0;
+	_noHints = false;
+	_antFlag = false;
+	_allenFlag = false;
+	_noSound = false;
+	Common::fill(&inv[0], &inv[85], 0);
+	Common::fill(&_help1[0], &_help1[366], 0);
+	Common::fill(&_help2[0], &_help2[366], 0);
+	Common::fill(&_help1[0], &_help3[366], 0);
+	_travel = 0;
+	_ask = 0;
+	_rScrollRow = 0;
+	_rScrollCol = 0;
+	_rSrcollX = 0;
+	_rScrollY = 0;
+	_rOldRectCount = 0;
+	_rNewRectCount = 0;
+	_rKeyFlag = 0;
+	_mapOffset = 0;
+	_screenVirtX = 0;
+}
+
+} // End of namespace Access
diff --git a/engines/access/globals.h b/engines/access/globals.h
new file mode 100644
index 0000000..30dbd46
--- /dev/null
+++ b/engines/access/globals.h
@@ -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.
+ *
+ */
+
+#ifndef ACCESS_GLOBALS_H
+#define ACCESS_GLOBALS_H
+
+#include "common/scummsys.h"
+
+namespace Access {
+
+class Globals {
+public:
+	int _startData;
+	int _rawPlayerXLow;
+	int _rawPlayerX;
+	int _rawPlayerYLow;
+	int _rawPlayerY;
+	int _conversation;
+	int _currentMan;
+	uint32 _newTime;
+	uint32 _newDate;
+	int _intTim[3];
+	int _timer[3];
+	bool _timerFlag;
+	byte _flags[99];
+	byte _useItem[23];
+	int _guardLoc;
+	int _guardFind;
+	int _helpLevel;
+	int _jasMayaFlag;
+	int _moreHelp;
+	int _startup;
+	bool _flashbackFlag;
+	int _manScaleOff;
+	bool _riverFlag;
+	bool _antOutFlag;
+	int _badEnd;
+	bool _noHints;
+	bool _antFlag;
+	bool _allenFlag;
+	bool _noSound;
+	int inv[85];
+	byte _help1[366];
+	byte _help2[366];
+	byte _help3[366];
+	int _travel;
+	int _ask;
+	int _rScrollRow;
+	int _rScrollCol;
+	int _rSrcollX;
+	int _rScrollY;
+	int _rOldRectCount;
+	int _rNewRectCount;
+	int _rKeyFlag;
+	int _mapOffset;
+	int _screenVirtX;
+public:
+	Globals();
+
+	virtual ~Globals() {}
+};
+
+} // End of namespace Access
+
+#endif /* ACCESS_GLOBALS_H */
diff --git a/engines/access/module.mk b/engines/access/module.mk
index ff4cedb..e49a11b 100644
--- a/engines/access/module.mk
+++ b/engines/access/module.mk
@@ -8,10 +8,12 @@ MODULE_OBJS := \
 	detection.o \
 	events.o \
 	files.o \
+	globals.o \
 	resources.o \
 	screen.o \
 	sound.o \
-	amazon\amazon_game.o
+	amazon\amazon_game.o \
+	amazon\amazon_globals.o
 
 # This module can be built as a plugin
 ifeq ($(ENABLE_ACCESS), DYNAMIC_PLUGIN)


Commit: c4fb766811d523a28630c98ca535cb9c6000acf5
    https://github.com/scummvm/scummvm/commit/c4fb766811d523a28630c98ca535cb9c6000acf5
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-05T20:04:41-04:00

Commit Message:
ACCESS: Moved globals into the main engine classes

Changed paths:
  R engines/access/amazon/amazon_globals.cpp
  R engines/access/amazon/amazon_globals.h
  R engines/access/globals.cpp
  R engines/access/globals.h
    engines/access/access.cpp
    engines/access/access.h
    engines/access/amazon/amazon_game.cpp
    engines/access/amazon/amazon_game.h
    engines/access/module.mk



diff --git a/engines/access/access.cpp b/engines/access/access.cpp
index 3639115..fdf6cd0 100644
--- a/engines/access/access.cpp
+++ b/engines/access/access.cpp
@@ -34,7 +34,6 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc)
 	_debugger = nullptr;
 	_events = nullptr;
 	_files = nullptr;
-	_globals = nullptr;
 	_screen = nullptr;
 	_sound = nullptr;
 
@@ -58,6 +57,50 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc)
 	_startAboutBox = 0;
 	_startTravelBox = 0;
 
+	_startData = 0;
+	_rawPlayerXLow = 0;
+	_rawPlayerX = 0;
+	_rawPlayerYLow = 0;
+	_rawPlayerY = 0;
+	_conversation = 0;
+	_currentMan = 0;
+	_newTime = 0;
+	_newDate = 0;
+	_intTim[3] = 0;
+	_timer[3] = 0;
+	_timerFlag = false;
+	Common::fill(&_flags[0], &_flags[99], 0);
+	Common::fill(&_useItem[0], &_useItem[23], 0);
+	_guardLoc = 0;
+	_guardFind = 0;
+	_helpLevel = 0;
+	_jasMayaFlag = 0;
+	_moreHelp = 0;
+	_startup = 0;
+	_flashbackFlag = false;
+	_manScaleOff = 0;
+	_riverFlag = false;
+	_antOutFlag = false;
+	_badEnd = 0;
+	_noHints = false;
+	_antFlag = false;
+	_allenFlag = false;
+	_noSound = false;
+	Common::fill(&inv[0], &inv[85], 0);
+	Common::fill(&_help1[0], &_help1[366], 0);
+	Common::fill(&_help2[0], &_help2[366], 0);
+	Common::fill(&_help1[0], &_help3[366], 0);
+	_travel = 0;
+	_ask = 0;
+	_rScrollRow = 0;
+	_rScrollCol = 0;
+	_rSrcollX = 0;
+	_rScrollY = 0;
+	_rOldRectCount = 0;
+	_rNewRectCount = 0;
+	_rKeyFlag = 0;
+	_mapOffset = 0;
+	_screenVirtX = 0;
 }
 
 AccessEngine::~AccessEngine() {
diff --git a/engines/access/access.h b/engines/access/access.h
index 3428711..fd95c91 100644
--- a/engines/access/access.h
+++ b/engines/access/access.h
@@ -33,7 +33,6 @@
 #include "access/debugger.h"
 #include "access/events.h"
 #include "access/files.h"
-#include "access/globals.h"
 #include "access/screen.h"
 #include "access/sound.h"
 
@@ -94,7 +93,6 @@ public:
 	Debugger *_debugger;
 	EventsManager *_events;
 	FileManager *_files;
-	Globals *_globals;
 	Screen *_screen;
 	SoundManager *_sound;
 
@@ -104,7 +102,6 @@ public:
 	byte *_objectsTable;
 	int _pCount;
 
-	int _currentMan;
 	int _currentManOld;
 	byte *_man1;
 	byte *_manPal1;
@@ -121,6 +118,51 @@ public:
 	int _startAboutBox;
 	int _startTravelBox;
 
+	// Fields that are included in savegames
+	int _startData;
+	int _rawPlayerXLow;
+	int _rawPlayerX;
+	int _rawPlayerYLow;
+	int _rawPlayerY;
+	int _conversation;
+	int _currentMan;
+	uint32 _newTime;
+	uint32 _newDate;
+	int _intTim[3];
+	int _timer[3];
+	bool _timerFlag;
+	byte _flags[99];
+	byte _useItem[23];
+	int _guardLoc;
+	int _guardFind;
+	int _helpLevel;
+	int _jasMayaFlag;
+	int _moreHelp;
+	int _startup;
+	bool _flashbackFlag;
+	int _manScaleOff;
+	bool _riverFlag;
+	bool _antOutFlag;
+	int _badEnd;
+	bool _noHints;
+	bool _antFlag;
+	bool _allenFlag;
+	bool _noSound;
+	int inv[85];
+	byte _help1[366];
+	byte _help2[366];
+	byte _help3[366];
+	int _travel;
+	int _ask;
+	int _rScrollRow;
+	int _rScrollCol;
+	int _rSrcollX;
+	int _rScrollY;
+	int _rOldRectCount;
+	int _rNewRectCount;
+	int _rKeyFlag;
+	int _mapOffset;
+	int _screenVirtX;
 public:
 	AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc);
 	virtual ~AccessEngine();
diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp
index af7b77e..068d3bf 100644
--- a/engines/access/amazon/amazon_game.cpp
+++ b/engines/access/amazon/amazon_game.cpp
@@ -21,7 +21,6 @@
  */
 
 #include "access/amazon/amazon_game.h"
-#include "access/amazon/amazon_globals.h"
 
 namespace Access {
 
@@ -29,12 +28,24 @@ namespace Amazon {
 
 AmazonEngine::AmazonEngine(OSystem *syst, const AccessGameDescription *gameDesc) :
 		AccessEngine(syst, gameDesc) {
-	_globals = new AmazonGlobals();
 	_skipStart = false;
+
+	_canoeLane = 0;
+	_canoeYPos = 0;
+	_hitCount = 0;
+	_saveRiver = 0;
+	_hitSafe = 0;
+	_chapter = 0;
+	_topList = 0;
+	_botList = 0;
+	_riverIndex = 0;
+	_rawInactiveX = 0;
+	_rawInactiveY = 0;
+	_inactiveYOff = 0;
+	Common::fill(&_esTabTable[0], &_esTabTable[100], 0);
 }
 
 AmazonEngine::~AmazonEngine() {
-	delete _globals;
 }
 
 void AmazonEngine::playGame() {
diff --git a/engines/access/amazon/amazon_game.h b/engines/access/amazon/amazon_game.h
index 42fc31d..1b5397b 100644
--- a/engines/access/amazon/amazon_game.h
+++ b/engines/access/amazon/amazon_game.h
@@ -24,7 +24,6 @@
 #define ACCESS_AMAZON_GAME_H
 
 #include "access/access.h"
-#include "access/amazon/amazon_globals.h"
 
 namespace Access {
 
@@ -34,6 +33,22 @@ class AmazonEngine : public AccessEngine {
 private:
 	bool _skipStart;
 
+	// Fields that are included in savegames
+	int _canoeLane;
+	int _canoeYPos;
+	int _hitCount;
+	int _saveRiver;
+	int _hitSafe;
+	int _chapter;
+	int _topList;
+	int _botList;
+	int _riverIndex;
+	int _rawInactiveX;
+	int _rawInactiveY;
+	int _inactiveYOff;
+	int _esTabTable[100];
+
+
 	/**
 	 * Do title sequence
 	 */
@@ -48,11 +63,6 @@ private:
 	 * Do tent scene of introduction
 	 */
 	void doTent();
-
-	/**
-	 * Get globals reference
-	 */
-	AmazonGlobals &globals() { return *(AmazonGlobals *)_globals; }
 protected:
 	/**
 	 * Play the game
diff --git a/engines/access/amazon/amazon_globals.cpp b/engines/access/amazon/amazon_globals.cpp
deleted file mode 100644
index 7982233..0000000
--- a/engines/access/amazon/amazon_globals.cpp
+++ /dev/null
@@ -1,48 +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 = 0; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation = 0; 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 = 0; 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 = 0; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#include "common/algorithm.h"
-#include "access/amazon/amazon_globals.h"
-
-namespace Access {
-
-namespace Amazon {
-
-AmazonGlobals::AmazonGlobals() : Globals() {
-	_canoeLane = 0;
-	_canoeYPos = 0;
-	_hitCount = 0;
-	_saveRiver = 0;
-	_hitSafe = 0;
-	_chapter = 0;
-	_topList = 0;
-	_botList = 0;
-	_riverIndex = 0;
-	_rawInactiveX = 0;
-	_rawInactiveY = 0;
-	_inactiveYOff = 0;
-	Common::fill(&_esTabTable[0], &_esTabTable[100], 0);
-}
-
-} // End of namespace Amazon
-
-} // End of namespace Access
diff --git a/engines/access/amazon/amazon_globals.h b/engines/access/amazon/amazon_globals.h
deleted file mode 100644
index d9631f7..0000000
--- a/engines/access/amazon/amazon_globals.h
+++ /dev/null
@@ -1,58 +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 ACCESS_AMAZON_GLOBALS_H
-#define ACCESS_AMAZON_GLOBALS_H
-
-#include "common/scummsys.h"
-#include "access/globals.h"
-
-namespace Access {
-
-namespace Amazon {
-
-class AmazonGlobals: public Globals {
-public:
-	int _canoeLane;
-	int _canoeYPos;
-	int _hitCount;
-	int _saveRiver;
-	int _hitSafe;
-	int _chapter;
-	int _topList;
-	int _botList;
-	int _riverIndex;
-	int _rawInactiveX;
-	int _rawInactiveY;
-	int _inactiveYOff;
-	int _esTabTable[100];
-public:
-	AmazonGlobals();
-
-	virtual ~AmazonGlobals() {}
-};
-
-} // End of namespace Amazon
-
-} // End of namespace Access
-
-#endif /* ACCESS_AMAZON_GLOBALS_H */
diff --git a/engines/access/globals.cpp b/engines/access/globals.cpp
deleted file mode 100644
index ab0c37b1..0000000
--- a/engines/access/globals.cpp
+++ /dev/null
@@ -1,75 +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 = 0; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation = 0; 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 = 0; 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 = 0; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#include "common/algorithm.h"
-#include "access/globals.h"
-
-namespace Access {
-
-Globals::Globals() {
-	_startData = 0;
-	_rawPlayerXLow = 0;
-	_rawPlayerX = 0;
-	_rawPlayerYLow = 0;
-	_rawPlayerY = 0;
-	_conversation = 0;
-	_currentMan = 0;
-	_newTime = 0;
-	_newDate = 0;
-	_intTim[3] = 0;
-	_timer[3] = 0;
-	_timerFlag = false;
-	Common::fill(&_flags[0], &_flags[99], 0);
-	Common::fill(&_useItem[0], &_useItem[23], 0);
-	_guardLoc = 0;
-	_guardFind = 0;
-	_helpLevel = 0;
-	_jasMayaFlag = 0;
-	_moreHelp = 0;
-	_startup = 0;
-	_flashbackFlag = false;
-	_manScaleOff = 0;
-	_riverFlag = false;
-	_antOutFlag = false;
-	_badEnd = 0;
-	_noHints = false;
-	_antFlag = false;
-	_allenFlag = false;
-	_noSound = false;
-	Common::fill(&inv[0], &inv[85], 0);
-	Common::fill(&_help1[0], &_help1[366], 0);
-	Common::fill(&_help2[0], &_help2[366], 0);
-	Common::fill(&_help1[0], &_help3[366], 0);
-	_travel = 0;
-	_ask = 0;
-	_rScrollRow = 0;
-	_rScrollCol = 0;
-	_rSrcollX = 0;
-	_rScrollY = 0;
-	_rOldRectCount = 0;
-	_rNewRectCount = 0;
-	_rKeyFlag = 0;
-	_mapOffset = 0;
-	_screenVirtX = 0;
-}
-
-} // End of namespace Access
diff --git a/engines/access/globals.h b/engines/access/globals.h
deleted file mode 100644
index 30dbd46..0000000
--- a/engines/access/globals.h
+++ /dev/null
@@ -1,84 +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 ACCESS_GLOBALS_H
-#define ACCESS_GLOBALS_H
-
-#include "common/scummsys.h"
-
-namespace Access {
-
-class Globals {
-public:
-	int _startData;
-	int _rawPlayerXLow;
-	int _rawPlayerX;
-	int _rawPlayerYLow;
-	int _rawPlayerY;
-	int _conversation;
-	int _currentMan;
-	uint32 _newTime;
-	uint32 _newDate;
-	int _intTim[3];
-	int _timer[3];
-	bool _timerFlag;
-	byte _flags[99];
-	byte _useItem[23];
-	int _guardLoc;
-	int _guardFind;
-	int _helpLevel;
-	int _jasMayaFlag;
-	int _moreHelp;
-	int _startup;
-	bool _flashbackFlag;
-	int _manScaleOff;
-	bool _riverFlag;
-	bool _antOutFlag;
-	int _badEnd;
-	bool _noHints;
-	bool _antFlag;
-	bool _allenFlag;
-	bool _noSound;
-	int inv[85];
-	byte _help1[366];
-	byte _help2[366];
-	byte _help3[366];
-	int _travel;
-	int _ask;
-	int _rScrollRow;
-	int _rScrollCol;
-	int _rSrcollX;
-	int _rScrollY;
-	int _rOldRectCount;
-	int _rNewRectCount;
-	int _rKeyFlag;
-	int _mapOffset;
-	int _screenVirtX;
-public:
-	Globals();
-
-	virtual ~Globals() {}
-};
-
-} // End of namespace Access
-
-#endif /* ACCESS_GLOBALS_H */
diff --git a/engines/access/module.mk b/engines/access/module.mk
index e49a11b..ff4cedb 100644
--- a/engines/access/module.mk
+++ b/engines/access/module.mk
@@ -8,12 +8,10 @@ MODULE_OBJS := \
 	detection.o \
 	events.o \
 	files.o \
-	globals.o \
 	resources.o \
 	screen.o \
 	sound.o \
-	amazon\amazon_game.o \
-	amazon\amazon_globals.o
+	amazon\amazon_game.o
 
 # This module can be built as a plugin
 ifeq ($(ENABLE_ACCESS), DYNAMIC_PLUGIN)


Commit: f1309a7b0b7e98256b45e9977c62f040452d54c4
    https://github.com/scummvm/scummvm/commit/f1309a7b0b7e98256b45e9977c62f040452d54c4
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-05T20:59:44-04:00

Commit Message:
ACCESS: Remainder of Amazon game initialization added

Changed paths:
  A engines/access/data.cpp
  A engines/access/data.h
    engines/access/access.cpp
    engines/access/access.h
    engines/access/amazon/amazon_game.cpp
    engines/access/amazon/amazon_game.h
    engines/access/module.mk
    engines/access/resources.cpp
    engines/access/resources.h



diff --git a/engines/access/access.cpp b/engines/access/access.cpp
index fdf6cd0..2a61a8f 100644
--- a/engines/access/access.cpp
+++ b/engines/access/access.cpp
@@ -38,8 +38,11 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc)
 	_sound = nullptr;
 
 	_destIn = nullptr;
-	_objectsTable = nullptr;
+	clearCellTable();
 	_pCount = 0;
+	_selectCommand = 0;
+	_normalMouse = true;
+	_mouseMode = 0;
 	_currentMan = 0;
 	_currentManOld = -1;
 	_man1 = nullptr;
@@ -57,7 +60,7 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc)
 	_startAboutBox = 0;
 	_startTravelBox = 0;
 
-	_startData = 0;
+	_roomNumber = 0;
 	_rawPlayerXLow = 0;
 	_rawPlayerX = 0;
 	_rawPlayerYLow = 0;
@@ -112,7 +115,6 @@ AccessEngine::~AccessEngine() {
 
 	_buffer1.free();
 	_buffer2.free();
-	delete[] _objectsTable;
 }
 
 void AccessEngine::setVGA() {
@@ -164,4 +166,12 @@ int AccessEngine::getRandomNumber(int maxNumber) {
 	return _randomSource.getRandomNumber(maxNumber);
 }
 
+void AccessEngine::clearCellTable() {
+	Common::fill(&_objectsTable[0], &_objectsTable[100], (byte *)nullptr);
+}
+
+void AccessEngine::doRoom() {
+	// TODO
+}
+
 } // End of namespace Access
diff --git a/engines/access/access.h b/engines/access/access.h
index fd95c91..869441e 100644
--- a/engines/access/access.h
+++ b/engines/access/access.h
@@ -30,6 +30,7 @@
 #include "common/util.h"
 #include "engines/engine.h"
 #include "graphics/surface.h"
+#include "access/data.h"
 #include "access/debugger.h"
 #include "access/events.h"
 #include "access/files.h"
@@ -63,7 +64,6 @@ enum AccessDebugChannels {
 
 struct AccessGameDescription;
 
-
 class AccessEngine : public Engine {
 private:
 	/**
@@ -81,6 +81,16 @@ protected:
 	const AccessGameDescription *_gameDescription;
 	Common::RandomSource _randomSource;
 
+	/**
+	 * Clear the cell table
+	 */
+	void clearCellTable();
+
+	/**
+	 * Main handler for showing game rooms
+	 */
+	void doRoom();
+
 	// Engine APIs
 	virtual Common::Error run();
 	virtual bool hasFeature(EngineFeature f) const;
@@ -99,8 +109,13 @@ public:
 	byte *_destIn;
 	Graphics::Surface _buffer1;
 	Graphics::Surface _buffer2;
-	byte *_objectsTable;
+	byte *_objectsTable[100];
+	Common::Array<TimerEntry> _timers;
+	Player _player;
 	int _pCount;
+	int _selectCommand;
+	bool _normalMouse;
+	int _mouseMode;
 
 	int _currentManOld;
 	byte *_man1;
@@ -119,7 +134,7 @@ public:
 	int _startTravelBox;
 
 	// Fields that are included in savegames
-	int _startData;
+	int _roomNumber;
 	int _rawPlayerXLow;
 	int _rawPlayerX;
 	int _rawPlayerYLow;
diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp
index 068d3bf..6eef2cf 100644
--- a/engines/access/amazon/amazon_game.cpp
+++ b/engines/access/amazon/amazon_game.cpp
@@ -21,6 +21,7 @@
  */
 
 #include "access/amazon/amazon_game.h"
+#include "access/resources.h"
 
 namespace Access {
 
@@ -49,11 +50,30 @@ AmazonEngine::~AmazonEngine() {
 }
 
 void AmazonEngine::playGame() {
+	doIntroduction();
+	if (shouldQuit())
+		return;
+
+	// Setup the game
+	setupGame();
+
+	_screen->clearScreen();
+	_screen->setPanel(0);
+	_screen->forceFadeOut();
+
+	_events->showCursor();
+	doRoom();
+}
+
+void AmazonEngine::doIntroduction() {
 	_screen->setInitialPalettte();
 	_events->setCursor(CURSOR_0);
 	_events->showCursor();
 	_screen->setPanel(0);
-	
+
+	// TODO: Worry about implementing full intro sequence later
+	return;
+
 	doTitle();
 	if (shouldQuit())
 		return;
@@ -72,14 +92,6 @@ void AmazonEngine::playGame() {
 	}
 
 	doTitle();
-	if (shouldQuit())
-		return;
-
-	_screen->clearScreen();
-	_screen->setPanel(0);
-	_screen->forceFadeOut();
-
-
 }
 
 void AmazonEngine::doTitle() {
@@ -100,7 +112,7 @@ void AmazonEngine::doTitle() {
 	_screen->forceFadeIn();
 	_sound->playSound(1);
 
-	_objectsTable = _files->loadFile(0, 2);
+	_objectsTable[0] = _files->loadFile(0, 2);
 	_sound->playSound(1);
 
 	_screen->_loadPalFlag = false;
@@ -116,7 +128,7 @@ void AmazonEngine::doTitle() {
 		_buffer2.copyFrom(_buffer1);
 		int id = READ_LE_UINT16(COUNTDOWN + _pCount * 4);
 		int xp = READ_LE_UINT16(COUNTDOWN + _pCount * 4 + 2);
-		_screen->plotImage(_objectsTable, id, Common::Point(xp, 71));
+		_screen->plotImage(_objectsTable[0], id, Common::Point(xp, 71));
 	}
 	// TODO: More to do
 }
@@ -129,6 +141,26 @@ void AmazonEngine::doTent() {
 	// TODO
 }
 
+void AmazonEngine::setupGame() {
+	_chapter = 1;
+	clearCellTable();
+
+	// Setup timers
+	const int TIMER_DEFAULTS[] = { 3, 10, 8, 1, 1, 1, 1, 2 };
+	for (int i = 0; i < 32; ++i) {
+		TimerEntry te;
+		te._initTm = te._timer = (i < 8) ? TIMER_DEFAULTS[i] : 1;
+		te._flag = true;
+
+		_timers.push_back(te);
+	}
+
+	// Set miscellaneous fields
+	_roomNumber = 4;
+	_player._playerX = _rawPlayerX = TRAVEL_POS[_roomNumber][0];
+	_player._playerY = _rawPlayerY = TRAVEL_POS[_roomNumber][1];
+	_selectCommand = -1;
+}
 
 } // End of namespace Amazon
 
diff --git a/engines/access/amazon/amazon_game.h b/engines/access/amazon/amazon_game.h
index 1b5397b..b998b1d 100644
--- a/engines/access/amazon/amazon_game.h
+++ b/engines/access/amazon/amazon_game.h
@@ -48,6 +48,10 @@ private:
 	int _inactiveYOff;
 	int _esTabTable[100];
 
+	/**
+	 * Do the game introduction
+	 */
+	void doIntroduction();
 
 	/**
 	 * Do title sequence
@@ -63,6 +67,12 @@ private:
 	 * Do tent scene of introduction
 	 */
 	void doTent();
+
+	/**
+	 * Setup variables for the game
+	 */
+	void setupGame();
+
 protected:
 	/**
 	 * Play the game
diff --git a/engines/access/data.cpp b/engines/access/data.cpp
new file mode 100644
index 0000000..e5ee1e1
--- /dev/null
+++ b/engines/access/data.cpp
@@ -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.
+ *
+ */
+
+#include "access/data.h"
+#include "common/algorithm.h"
+
+namespace Access {
+
+Player::Player() {
+	_field0 = 0;
+	_monData = nullptr;
+	Common::fill(&_walkOffRight[0], &_walkOffRight[PLAYER_DATA_COUNT], 0);
+	Common::fill(&_walkOffLeft[0], &_walkOffLeft[PLAYER_DATA_COUNT], 0);
+	Common::fill(&_walkOffUp[0], &_walkOffUp[PLAYER_DATA_COUNT], 0);
+	Common::fill(&_walkOffDown[0], &_walkOffDown[PLAYER_DATA_COUNT], 0);
+	_rawTempL = 0;
+	_rawXTemp = 0;
+	_rawYTempL = 0;
+	_rawYTemp = 0;
+	_playerXLow = 0;
+	_playerX = 0;
+	_playerYLow = 0;
+	_playerY = 0;
+	_frame = 0;
+}
+
+} // End of namespace Access
diff --git a/engines/access/data.h b/engines/access/data.h
new file mode 100644
index 0000000..069d543
--- /dev/null
+++ b/engines/access/data.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.
+ *
+ */
+
+#ifndef ACCESS_DATA_H
+#define ACCESS_DATA_H
+
+#include "common/scummsys.h"
+#include "common/rect.h"
+
+namespace Access {
+
+struct TimerEntry {
+	int _initTm;
+	int _timer;
+	bool _flag;
+
+	TimerEntry() {
+		_initTm = _timer = 0;
+		_flag = false;
+	}
+};
+
+#define PLAYER_DATA_COUNT 8
+
+class Player {
+public:
+	int _field0;
+	byte *_monData;
+	int _walkOffRight[PLAYER_DATA_COUNT];
+	int _walkOffLeft[PLAYER_DATA_COUNT];
+	int _walkOffUp[PLAYER_DATA_COUNT];
+	int _walkOffDown[PLAYER_DATA_COUNT];
+	Common::Point _walkOffUR[PLAYER_DATA_COUNT];
+	Common::Point _walkOffDR[PLAYER_DATA_COUNT];
+	Common::Point _walkOffUL[PLAYER_DATA_COUNT];
+	Common::Point _walkOffDL[PLAYER_DATA_COUNT];
+	int _rawTempL;
+	int _rawXTemp;
+	int _rawYTempL;
+	int _rawYTemp;
+	Common::Point _playerOffset;
+	int _playerXLow;
+	int _playerX;
+	int _playerYLow;
+	int _playerY;
+	int _frame;
+public:
+	Player();
+};
+
+} // End of namespace Access
+
+#endif /* ACCESS_DATA_H */
diff --git a/engines/access/module.mk b/engines/access/module.mk
index ff4cedb..bab2476 100644
--- a/engines/access/module.mk
+++ b/engines/access/module.mk
@@ -3,6 +3,7 @@ MODULE := engines/access
 MODULE_OBJS := \
 	asurface.o \
 	access.o \
+	data.o \
 	debugger.o \
 	decompress.o \
 	detection.o \
diff --git a/engines/access/resources.cpp b/engines/access/resources.cpp
index a47abf2..70d4a69 100644
--- a/engines/access/resources.cpp
+++ b/engines/access/resources.cpp
@@ -198,6 +198,75 @@ const byte CURSHELP[] = {
 	0x22, 0x22, 0x22, 0x20, 0x05, 0x04, 0x20, 0x20, 0x20, 0x20
 };
 
+const int TRAVEL_POS[][2] = {
+	{ -1, 0 },
+	{ 228, 117 },
+	{ 28, 98 },
+	{ 161, 140 },
+	{ 130, 139 },
+	{ 884, 95 },
+	{ 0, 0 },
+	{ 0, 0 },
+	{ 0, 0 },
+	{ 41, 185 },
+	{ 60, 138 },
+	{ 0, 0 },
+	{ 0, 0 },
+	{ 0, 0 },
+	{ 0, 0 },
+	{ 0, 0 },
+	{ 170, 155 },
+	{ 0, 0 },
+	{ 0, 0 },
+	{ 0, 0 },
+	{ 108, 95 },
+	{ 0, 0 },
+	{ 0, 0 },
+	{ 0, 0 },
+	{ 100, 115 },
+	{ 480, 90 },
+	{ 154, 63 },
+	{ 0, 0 },
+	{ 145, 85 },
+	{ 0, 0 },
+	{ 110, 107 },
+	{ 0, 0 },
+	{ 105, 154 },
+	{ 0, 0 },
+	{ 0, 0 },
+	{ 0, 0 },
+	{ 0, 0 },
+	{ 20, 160 },
+	{ 130, 314 },
+	{ 0, 0 },
+	{ 50, 125 },
+	{ 0, 0 },
+	{ 0, 0 },
+	{ 123, 123 },
+	{ -1, 7 },
+	{ 266, 168 },
+	{ 0, 0 },
+	{ 0, 0 },
+	{ 0, 0 },
+	{ -1, 18 },
+	{ -1, 19 },
+	{ 0, 0 },
+	{ 0, 0 },
+	{ 0, 0 },
+	{ 0, 0 },
+	{ 0, 0 },
+	{ 203, 160 },
+	{ 0, 0 },
+	{ 283, 163 },
+	{ 0, 0 },
+	{ 0, 0 },
+	{ 0, 0 },
+	{ 180, 165 },
+	{ 0, 0 },
+	{ 0, 0 },
+	{ 0, 0 }
+};
+
 } // End of namespace Amazon
 
 } // End of namespace Access
diff --git a/engines/access/resources.h b/engines/access/resources.h
index ba335cd..e730881 100644
--- a/engines/access/resources.h
+++ b/engines/access/resources.h
@@ -46,6 +46,8 @@ extern const byte CURSHELP[];
 
 extern const byte *CURSORS[10];
 
+extern const int TRAVEL_POS[][2];
+
 } // End of namespace Amazon
 
 } // End of namespace Access


Commit: 7d605ce57316c86a247cf978e6b123b23045659c
    https://github.com/scummvm/scummvm/commit/7d605ce57316c86a247cf978e6b123b23045659c
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-05T22:17:30-04:00

Commit Message:
ACCESS: Implement outer room handler

Changed paths:
  A engines/access/player.cpp
  A engines/access/player.h
  A engines/access/room.cpp
  A engines/access/room.h
    engines/access/access.cpp
    engines/access/access.h
    engines/access/amazon/amazon_game.cpp
    engines/access/data.cpp
    engines/access/data.h
    engines/access/events.h
    engines/access/module.mk
    engines/access/screen.cpp
    engines/access/screen.h
    engines/access/sound.cpp
    engines/access/sound.h



diff --git a/engines/access/access.cpp b/engines/access/access.cpp
index 2a61a8f..fa1775f 100644
--- a/engines/access/access.cpp
+++ b/engines/access/access.cpp
@@ -34,6 +34,8 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc)
 	_debugger = nullptr;
 	_events = nullptr;
 	_files = nullptr;
+	_player = nullptr;
+	_room = nullptr;
 	_screen = nullptr;
 	_sound = nullptr;
 
@@ -59,6 +61,10 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc)
 	_startInvBox = 0;
 	_startAboutBox = 0;
 	_startTravelBox = 0;
+	_numImages = 0;
+	_nextImage = 0;
+	_numAnimTimers = 0;
+	_startup = 0;
 
 	_roomNumber = 0;
 	_rawPlayerXLow = 0;
@@ -110,6 +116,8 @@ AccessEngine::~AccessEngine() {
 	delete _debugger;
 	delete _events;
 	delete _files;
+	delete _player;
+	delete _room;
 	delete _screen;
 	delete _sound;
 
@@ -130,6 +138,7 @@ void AccessEngine::initialize() {
 	_debugger = new Debugger(this);
 	_events = new EventsManager(this);
 	_files = new FileManager(this);
+	_player = new Player(this);
 	_screen = new Screen(this);
 	_sound = new SoundManager(this, _mixer);
 
@@ -170,8 +179,4 @@ void AccessEngine::clearCellTable() {
 	Common::fill(&_objectsTable[0], &_objectsTable[100], (byte *)nullptr);
 }
 
-void AccessEngine::doRoom() {
-	// TODO
-}
-
 } // End of namespace Access
diff --git a/engines/access/access.h b/engines/access/access.h
index 869441e..fce6c44 100644
--- a/engines/access/access.h
+++ b/engines/access/access.h
@@ -34,6 +34,8 @@
 #include "access/debugger.h"
 #include "access/events.h"
 #include "access/files.h"
+#include "access/player.h"
+#include "access/room.h"
 #include "access/screen.h"
 #include "access/sound.h"
 
@@ -103,6 +105,8 @@ public:
 	Debugger *_debugger;
 	EventsManager *_events;
 	FileManager *_files;
+	Player *_player;
+	Room *_room;
 	Screen *_screen;
 	SoundManager *_sound;
 
@@ -110,12 +114,16 @@ public:
 	Graphics::Surface _buffer1;
 	Graphics::Surface _buffer2;
 	byte *_objectsTable[100];
+	int _numAnimTimers;
 	Common::Array<TimerEntry> _timers;
-	Player _player;
+	Common::Array<Common::Rect> _newRect;
+	Common::Array<Common::Rect> _oldRect;
 	int _pCount;
 	int _selectCommand;
 	bool _normalMouse;
 	int _mouseMode;
+	int _numImages;
+	int _nextImage;
 
 	int _currentManOld;
 	byte *_man1;
diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp
index 6eef2cf..8cbd076 100644
--- a/engines/access/amazon/amazon_game.cpp
+++ b/engines/access/amazon/amazon_game.cpp
@@ -62,7 +62,7 @@ void AmazonEngine::playGame() {
 	_screen->forceFadeOut();
 
 	_events->showCursor();
-	doRoom();
+	_room->doRoom();
 }
 
 void AmazonEngine::doIntroduction() {
@@ -157,8 +157,8 @@ void AmazonEngine::setupGame() {
 
 	// Set miscellaneous fields
 	_roomNumber = 4;
-	_player._playerX = _rawPlayerX = TRAVEL_POS[_roomNumber][0];
-	_player._playerY = _rawPlayerY = TRAVEL_POS[_roomNumber][1];
+	_player->_playerX = _rawPlayerX = TRAVEL_POS[_roomNumber][0];
+	_player->_playerY = _rawPlayerY = TRAVEL_POS[_roomNumber][1];
 	_selectCommand = -1;
 }
 
diff --git a/engines/access/data.cpp b/engines/access/data.cpp
index e5ee1e1..0ef1845 100644
--- a/engines/access/data.cpp
+++ b/engines/access/data.cpp
@@ -25,22 +25,5 @@
 
 namespace Access {
 
-Player::Player() {
-	_field0 = 0;
-	_monData = nullptr;
-	Common::fill(&_walkOffRight[0], &_walkOffRight[PLAYER_DATA_COUNT], 0);
-	Common::fill(&_walkOffLeft[0], &_walkOffLeft[PLAYER_DATA_COUNT], 0);
-	Common::fill(&_walkOffUp[0], &_walkOffUp[PLAYER_DATA_COUNT], 0);
-	Common::fill(&_walkOffDown[0], &_walkOffDown[PLAYER_DATA_COUNT], 0);
-	_rawTempL = 0;
-	_rawXTemp = 0;
-	_rawYTempL = 0;
-	_rawYTemp = 0;
-	_playerXLow = 0;
-	_playerX = 0;
-	_playerYLow = 0;
-	_playerY = 0;
-	_frame = 0;
-}
 
 } // End of namespace Access
diff --git a/engines/access/data.h b/engines/access/data.h
index 069d543..7e10e99 100644
--- a/engines/access/data.h
+++ b/engines/access/data.h
@@ -39,34 +39,6 @@ struct TimerEntry {
 	}
 };
 
-#define PLAYER_DATA_COUNT 8
-
-class Player {
-public:
-	int _field0;
-	byte *_monData;
-	int _walkOffRight[PLAYER_DATA_COUNT];
-	int _walkOffLeft[PLAYER_DATA_COUNT];
-	int _walkOffUp[PLAYER_DATA_COUNT];
-	int _walkOffDown[PLAYER_DATA_COUNT];
-	Common::Point _walkOffUR[PLAYER_DATA_COUNT];
-	Common::Point _walkOffDR[PLAYER_DATA_COUNT];
-	Common::Point _walkOffUL[PLAYER_DATA_COUNT];
-	Common::Point _walkOffDL[PLAYER_DATA_COUNT];
-	int _rawTempL;
-	int _rawXTemp;
-	int _rawYTempL;
-	int _rawYTemp;
-	Common::Point _playerOffset;
-	int _playerXLow;
-	int _playerX;
-	int _playerYLow;
-	int _playerY;
-	int _frame;
-public:
-	Player();
-};
-
 } // End of namespace Access
 
 #endif /* ACCESS_DATA_H */
diff --git a/engines/access/events.h b/engines/access/events.h
index 3cf610e..2e6b06b 100644
--- a/engines/access/events.h
+++ b/engines/access/events.h
@@ -45,12 +45,12 @@ private:
 	AccessEngine *_vm;
 	uint32 _frameCounter;
 	uint32 _priorFrameTime;
-	Common::Point _mousePos;
 
 	void checkForNextFrameCounter();
 public:
 	CursorType _cursorId;
 	bool _leftButton;
+	Common::Point _mousePos;
 public:
 	/**
 	 * Constructor
diff --git a/engines/access/module.mk b/engines/access/module.mk
index bab2476..791abcc 100644
--- a/engines/access/module.mk
+++ b/engines/access/module.mk
@@ -9,7 +9,9 @@ MODULE_OBJS := \
 	detection.o \
 	events.o \
 	files.o \
+	player.o \
 	resources.o \
+	room.o \
 	screen.o \
 	sound.o \
 	amazon\amazon_game.o
diff --git a/engines/access/player.cpp b/engines/access/player.cpp
new file mode 100644
index 0000000..f7429bd
--- /dev/null
+++ b/engines/access/player.cpp
@@ -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.
+ *
+ */
+
+#include "access/player.h"
+#include "common/algorithm.h"
+#include "common/textconsole.h"
+
+namespace Access {
+
+Player::Player(AccessEngine *vm): _vm(vm) {
+	_field0 = 0;
+	_monData = nullptr;
+	Common::fill(&_walkOffRight[0], &_walkOffRight[PLAYER_DATA_COUNT], 0);
+	Common::fill(&_walkOffLeft[0], &_walkOffLeft[PLAYER_DATA_COUNT], 0);
+	Common::fill(&_walkOffUp[0], &_walkOffUp[PLAYER_DATA_COUNT], 0);
+	Common::fill(&_walkOffDown[0], &_walkOffDown[PLAYER_DATA_COUNT], 0);
+	_rawTempL = 0;
+	_rawXTemp = 0;
+	_rawYTempL = 0;
+	_rawYTemp = 0;
+	_playerXLow = 0;
+	_playerX = 0;
+	_playerYLow = 0;
+	_playerY = 0;
+	_frame = 0;
+
+	_playerOff = false;
+}
+
+void Player::walk() {
+	warning("TODO: Player::walk");
+}
+
+} // End of namespace Access
diff --git a/engines/access/player.h b/engines/access/player.h
new file mode 100644
index 0000000..94ae987
--- /dev/null
+++ b/engines/access/player.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.
+ *
+ */
+
+#ifndef ACCESS_PLAYER_H
+#define ACCESS_PLAYER_H
+
+#include "common/scummsys.h"
+#include "common/rect.h"
+
+namespace Access {
+
+#define PLAYER_DATA_COUNT 8
+
+class AccessEngine;
+
+class Player {
+private:
+	AccessEngine *_vm;
+public:
+	// Fields in original Player structure
+	int _field0;
+	byte *_monData;
+	int _walkOffRight[PLAYER_DATA_COUNT];
+	int _walkOffLeft[PLAYER_DATA_COUNT];
+	int _walkOffUp[PLAYER_DATA_COUNT];
+	int _walkOffDown[PLAYER_DATA_COUNT];
+	Common::Point _walkOffUR[PLAYER_DATA_COUNT];
+	Common::Point _walkOffDR[PLAYER_DATA_COUNT];
+	Common::Point _walkOffUL[PLAYER_DATA_COUNT];
+	Common::Point _walkOffDL[PLAYER_DATA_COUNT];
+	int _rawTempL;
+	int _rawXTemp;
+	int _rawYTempL;
+	int _rawYTemp;
+	Common::Point _playerOffset;
+	int _playerXLow;
+	int _playerX;
+	int _playerYLow;
+	int _playerY;
+	int _frame;
+
+	// Additional globals we've added to new Player class
+	bool _playerOff;
+public:
+	Player(AccessEngine *vm);
+
+	void walk();
+};
+
+} // End of namespace Access
+
+#endif /* ACCESS_PLAYER_H */
diff --git a/engines/access/room.cpp b/engines/access/room.cpp
new file mode 100644
index 0000000..25d3584
--- /dev/null
+++ b/engines/access/room.cpp
@@ -0,0 +1,130 @@
+/* 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 "common/scummsys.h"
+#include "access/access.h"
+#include "access/room.h"
+
+namespace Access {
+
+Room::Room(AccessEngine *vm) : _vm(vm) {
+	_function = 0;
+}
+
+void Room::doRoom() {
+	bool reloadFlag = false;
+
+	while (!_vm->shouldQuit()) {
+		if (!reloadFlag) {
+			_vm->_numImages = 0;
+			_vm->_newRect.clear();
+			_vm->_oldRect.clear();
+			_vm->_nextImage = 0;
+			_vm->_numAnimTimers = 0;
+		}
+
+		reloadFlag = false;
+		_vm->_startup = 0;
+		_function = 0;
+
+		while (!_vm->shouldQuit()) {
+			_vm->_numImages = 0;
+			if (_vm->_startup != -1 && --_vm->_startup != 0) {
+				--_vm->_startup;
+				_vm->_events->showCursor();
+				_vm->_screen->fadeIn();
+			}
+
+			_vm->_events->pollEvents();
+			_vm->_nextImage = 0;
+			_vm->_player->walk();
+			_vm->_sound->midiRepeat();
+			_vm->_screen->checkScroll();
+			doCommands();
+
+			// DOROOMFLASHBACK jump point
+			if (_function == 1) {
+				clearRoom();
+				break;
+			} else if (_function == 2) {
+				clearRoom();
+				return;
+			} else if (_function == 3) {
+				reloadRoom1();
+				reloadFlag = true;
+				break;
+			} else if (_function == 4) {
+				break;
+			}
+
+			if (_vm->_screen->_scrollFlag) {
+				_vm->_screen->copyBF1BF2();
+				_vm->_newRect.clear();
+				_function = 0;
+				roomLoop();
+
+				if (_function == 1) {
+					clearRoom();
+					break;
+				} else {
+					_vm->_screen->plotList();
+					_vm->_screen->copyRects();
+
+					_vm->_screen->copyBF2Vid();
+				}
+			} else {
+				_vm->_screen->copyBF1BF2();
+				_vm->_newRect.clear();
+				_function = 0;
+				roomLoop();
+
+				if (_function == 1) {
+					clearRoom();
+					break;
+				} else {
+					_vm->_screen->plotList();
+					_vm->_screen->copyBlocks();
+				}
+			}
+		}
+	}
+}
+
+void Room::clearRoom() {
+	// TODO
+}
+
+void Room::reloadRoom1() {
+	// TODO
+}
+
+void Room::roomLoop() {
+	// TODO
+}
+
+
+void Room::doCommands() {
+
+}
+
+
+} // End of namespace Access
diff --git a/engines/access/room.h b/engines/access/room.h
new file mode 100644
index 0000000..3b1a334
--- /dev/null
+++ b/engines/access/room.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.
+ *
+ */
+
+#ifndef ACCESS_ROOM_H
+#define ACCESS_ROOM_H
+
+#include "common/scummsys.h"
+
+namespace Access {
+
+class AccessEngine;
+
+class Room {
+private:
+	AccessEngine *_vm;
+
+	void roomLoop();
+public:
+	int _function;
+public:
+	Room(AccessEngine *vm);
+
+	void doRoom();
+
+	void doCommands();
+
+	void clearRoom();
+
+	void reloadRoom1();
+};
+
+} // End of namespace Access
+
+#endif /* ACCESS_ROOM_H */
diff --git a/engines/access/screen.cpp b/engines/access/screen.cpp
index 591bb67..8c87638 100644
--- a/engines/access/screen.cpp
+++ b/engines/access/screen.cpp
@@ -41,6 +41,7 @@ Screen::Screen(AccessEngine *vm) : _vm(vm) {
 	_leftSkip = _rightSkip = 0;
 	_topSkip = _bottomSkip = 0;
 	_clipWidth = _clipHeight = 0;
+	_scrollFlag = false;
 }
 
 void Screen::setDisplayScan() {
@@ -182,4 +183,28 @@ bool Screen::clip(Common::Rect &r) {
 	return false;
 }
 
+void Screen::checkScroll() {
+	// TODO
+}
+
+void Screen::copyBF1BF2() {
+	// TODO
+}
+
+void Screen::copyBF2Vid() {
+	// TODO
+}
+
+void Screen::plotList() {
+	// TODO
+}
+
+void Screen::copyBlocks() {
+	// TODO
+}
+
+void Screen::copyRects() {
+	// TODO
+}
+
 } // End of namespace Access
diff --git a/engines/access/screen.h b/engines/access/screen.h
index 2953727..5f9fff0 100644
--- a/engines/access/screen.h
+++ b/engines/access/screen.h
@@ -57,6 +57,7 @@ private:
 	bool clip(Common::Rect &r);
 public:
 	bool _loadPalFlag;
+	bool _scrollFlag;
 public:
 	Screen(AccessEngine *vm);
 
@@ -79,6 +80,8 @@ public:
 	 */
 	void forceFadeIn();
 
+	void fadeOut() { forceFadeOut(); }
+	void fadeIn() { forceFadeIn(); }
 	void clearScreen() { clearBuffer(); }
 
 	/**
@@ -94,6 +97,18 @@ public:
 	void copyBuffer(const byte *data);
 
 	void plotImage(const byte *pData, int idx, const Common::Point &pt);
+
+	void checkScroll();
+
+	void copyBF1BF2();
+
+	void copyBF2Vid();
+
+	void plotList();
+
+	void copyBlocks();
+
+	void copyRects();
 };
 
 } // End of namespace Access
diff --git a/engines/access/sound.cpp b/engines/access/sound.cpp
index 5375485..2a008d8 100644
--- a/engines/access/sound.cpp
+++ b/engines/access/sound.cpp
@@ -64,4 +64,9 @@ void SoundManager::playSound(byte *data, uint32 size) {
 		*/
 }
 
+void SoundManager::midiRepeat() {
+	// TODO
+}
+
+
 } // End of namespace Access
diff --git a/engines/access/sound.h b/engines/access/sound.h
index d3d5052..613eca4 100644
--- a/engines/access/sound.h
+++ b/engines/access/sound.h
@@ -55,6 +55,8 @@ public:
 	void queueSound(int idx, int fileNum, int subfile);
 
 	void playSound(int soundIndex);
+
+	void midiRepeat();
 };
 
 } // End of namespace Access


Commit: 8e43a6c5280e2b695753d4a0b6810811f1bd393f
    https://github.com/scummvm/scummvm/commit/8e43a6c5280e2b695753d4a0b6810811f1bd393f
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-05T23:23:49-04:00

Commit Message:
ACCESS: Add scripts classes and Amazon room setup

Changed paths:
  A engines/access/amazon/amazon_room.cpp
  A engines/access/amazon/amazon_room.h
  A engines/access/amazon/amazon_scripts.cpp
  A engines/access/amazon/amazon_scripts.h
  A engines/access/scripts.cpp
  A engines/access/scripts.h
    engines/access/access.cpp
    engines/access/access.h
    engines/access/amazon/amazon_game.cpp
    engines/access/module.mk
    engines/access/player.cpp
    engines/access/player.h
    engines/access/room.cpp
    engines/access/room.h
    engines/access/screen.cpp
    engines/access/screen.h



diff --git a/engines/access/access.cpp b/engines/access/access.cpp
index fa1775f..e175b1c 100644
--- a/engines/access/access.cpp
+++ b/engines/access/access.cpp
@@ -37,6 +37,7 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc)
 	_player = nullptr;
 	_room = nullptr;
 	_screen = nullptr;
+	_scripts = nullptr;
 	_sound = nullptr;
 
 	_destIn = nullptr;
@@ -48,10 +49,10 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc)
 	_currentMan = 0;
 	_currentManOld = -1;
 	_man1 = nullptr;
+	_inactive = nullptr;
 	_manPal1 = nullptr;
 	_music = nullptr;
 	_playField = nullptr;
-	_script = nullptr;
 	_anim = nullptr;
 	_title = nullptr;
 	_converseMode = 0;
@@ -65,6 +66,8 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc)
 	_nextImage = 0;
 	_numAnimTimers = 0;
 	_startup = 0;
+	_currentCharFlag = false;
+	_boxSelect = false;
 
 	_roomNumber = 0;
 	_rawPlayerXLow = 0;
@@ -119,6 +122,7 @@ AccessEngine::~AccessEngine() {
 	delete _player;
 	delete _room;
 	delete _screen;
+	delete _scripts;
 	delete _sound;
 
 	_buffer1.free();
diff --git a/engines/access/access.h b/engines/access/access.h
index fce6c44..21f8072 100644
--- a/engines/access/access.h
+++ b/engines/access/access.h
@@ -37,6 +37,7 @@
 #include "access/player.h"
 #include "access/room.h"
 #include "access/screen.h"
+#include "access/scripts.h"
 #include "access/sound.h"
 
 /**
@@ -108,6 +109,7 @@ public:
 	Player *_player;
 	Room *_room;
 	Screen *_screen;
+	Scripts *_scripts;
 	SoundManager *_sound;
 
 	byte *_destIn;
@@ -127,10 +129,10 @@ public:
 
 	int _currentManOld;
 	byte *_man1;
+	byte *_inactive;
 	byte *_manPal1;
 	byte *_music;
 	byte *_playField;
-	byte *_script;
 	byte *_anim;
 	byte *_title;
 	int _converseMode;
@@ -140,6 +142,8 @@ public:
 	int _startInvBox;
 	int _startAboutBox;
 	int _startTravelBox;
+	bool _currentCharFlag;
+	bool _boxSelect;
 
 	// Fields that are included in savegames
 	int _roomNumber;
diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp
index 8cbd076..ffe4cb5 100644
--- a/engines/access/amazon/amazon_game.cpp
+++ b/engines/access/amazon/amazon_game.cpp
@@ -20,8 +20,10 @@
  *
  */
 
-#include "access/amazon/amazon_game.h"
 #include "access/resources.h"
+#include "access/amazon/amazon_game.h"
+#include "access/amazon/amazon_room.h"
+#include "access/amazon/amazon_scripts.h"
 
 namespace Access {
 
@@ -50,6 +52,7 @@ AmazonEngine::~AmazonEngine() {
 }
 
 void AmazonEngine::playGame() {
+	// Do introduction
 	doIntroduction();
 	if (shouldQuit())
 		return;
@@ -62,6 +65,10 @@ void AmazonEngine::playGame() {
 	_screen->forceFadeOut();
 
 	_events->showCursor();
+
+	// Setup and execute the room
+	_room = new AmazonRoom(this);
+	_scripts = new AmazonScripts(this);
 	_room->doRoom();
 }
 
diff --git a/engines/access/amazon/amazon_room.cpp b/engines/access/amazon/amazon_room.cpp
new file mode 100644
index 0000000..ce0683f
--- /dev/null
+++ b/engines/access/amazon/amazon_room.cpp
@@ -0,0 +1,121 @@
+/* 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 "common/scummsys.h"
+#include "access/access.h"
+#include "access/amazon/amazon_room.h"
+
+namespace Access {
+
+namespace Amazon {
+
+AmazonRoom::AmazonRoom(AccessEngine *vm): Room(vm) {
+	_antOutFlag = false;
+}
+
+void AmazonRoom::reloadRoom() {
+	loadRoom(_vm->_roomNumber);
+
+	if (_roomFlag != 1) {
+		_vm->_currentMan = _roomFlag;
+		_vm->_currentManOld = _roomFlag;
+		_vm->_manScaleOff = 0;
+		
+		switch (_vm->_currentMan) {
+		case 0:
+			_vm->_man1 = _vm->_files->loadFile("MAN.LZ");
+			break;
+
+		case 2:
+			_vm->_man1 = _vm->_files->loadFile("JMAN.LZ");
+			break;
+
+		case 3:
+			_vm->_man1 = _vm->_files->loadFile("OVERHEAD.LZ");
+			_vm->_manScaleOff = 1;
+			break;
+
+		default:
+			break;
+		}
+	}
+
+	reloadRoom1();
+}
+
+void AmazonRoom::reloadRoom1() {
+	if (_vm->_roomNumber == 22 || _vm->_roomNumber == 31 
+			|| _vm->_roomNumber == 42 || _vm->_roomNumber == 44) {
+		_vm->_inactive = _vm->_files->loadFile("MAYA.LZ");
+		_vm->_currentCharFlag = false;
+	}
+
+	_vm->_selectCommand = -1;
+	_vm->_normalMouse = 1;
+	_vm->_mouseMode = 0;
+	_vm->_boxSelect = true;
+	_vm->_player->_playerOff = 0;
+
+	_vm->_screen->fadeOut();
+	_vm->_screen->clearScreen();
+	roomSet();
+
+	if (!_roomFlag && (_vm->_roomNumber != 61 || !_antOutFlag)) {
+		_vm->_player->load();
+		_vm->_player->calcManScale();
+	}
+
+	if (_vm->_roomNumber != 20 && _vm->_roomNumber != 24
+			&& _vm->_roomNumber != 33 && _vm->_roomNumber != 45) {
+		roomMenu();
+	}
+
+	_vm->_screen->setBufferScan();
+	setupRoom();
+	setWallCodes();
+	buildScreen();
+
+	if (_vm->_roomNumber != 20 && _vm->_roomNumber != 24
+			&& _vm->_roomNumber != 33) {
+		_vm->_screen->setPalette();
+		_vm->_screen->copyBF2Vid();
+	}
+
+	_vm->_player->_frame = 0;
+	_vm->_oldRect.clear();
+	_vm->_newRect.clear();
+}
+
+void AmazonRoom::roomSet() {
+	_vm->_numAnimTimers = 0;
+	_vm->_scripts->_sequence = 1000;
+	_vm->_scripts->searchForSeq();
+	_vm->_scripts->executeCommand();
+}
+
+void AmazonRoom::roomMenu() {
+	// TODO
+}
+
+} // End of namespace Amazon
+
+} // End of namespace Access
diff --git a/engines/access/amazon/amazon_room.h b/engines/access/amazon/amazon_room.h
new file mode 100644
index 0000000..6d13a4e
--- /dev/null
+++ b/engines/access/amazon/amazon_room.h
@@ -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.
+ *
+ */
+
+#ifndef ACCESS_AMAZON_ROOM_H
+#define ACCESS_AMAZON_ROOM_H
+
+#include "common/scummsys.h"
+#include "access/room.h"
+
+namespace Access {
+
+class AccessEngine;
+
+namespace Amazon {
+
+class AmazonRoom : public Room {
+private:
+	bool _antOutFlag;
+
+	void roomSet();
+
+	void roomMenu();
+protected:
+	virtual void reloadRoom();
+
+	virtual void reloadRoom1();
+public:
+	AmazonRoom(AccessEngine *vm);
+};
+
+} // End of namespace Amazon
+
+} // End of namespace Access
+
+#endif /* ACCESS_AMAZON_ROOM_H */
diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp
new file mode 100644
index 0000000..1d3e7b4
--- /dev/null
+++ b/engines/access/amazon/amazon_scripts.cpp
@@ -0,0 +1,36 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "common/scummsys.h"
+#include "access/access.h"
+#include "access/amazon/amazon_scripts.h"
+
+namespace Access {
+
+namespace Amazon {
+
+AmazonScripts::AmazonScripts(AccessEngine *vm) : Scripts(vm) {
+}
+
+} // End of namespace Amazon
+
+} // End of namespace Access
diff --git a/engines/access/amazon/amazon_scripts.h b/engines/access/amazon/amazon_scripts.h
new file mode 100644
index 0000000..08fbc3a
--- /dev/null
+++ b/engines/access/amazon/amazon_scripts.h
@@ -0,0 +1,42 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef ACCESS_AMAZON_SCRIPTS_H
+#define ACCESS_AMAZON_SCRIPTS_H
+
+#include "common/scummsys.h"
+#include "access/scripts.h"
+
+namespace Access {
+
+namespace Amazon {
+
+class AmazonScripts: public Scripts {
+public:
+	AmazonScripts(AccessEngine *vm);
+};
+
+} // End of namespace Amazon
+
+} // End of namespace Access
+
+#endif /* ACCESS_AMAZON_SCRIPTS_H */
diff --git a/engines/access/module.mk b/engines/access/module.mk
index 791abcc..5c9203f 100644
--- a/engines/access/module.mk
+++ b/engines/access/module.mk
@@ -13,8 +13,11 @@ MODULE_OBJS := \
 	resources.o \
 	room.o \
 	screen.o \
+	scripts.o \
 	sound.o \
-	amazon\amazon_game.o
+	amazon\amazon_game.o \
+	amazon\amazon_room.o \
+	amazon\amazon_scripts.o
 
 # This module can be built as a plugin
 ifeq ($(ENABLE_ACCESS), DYNAMIC_PLUGIN)
diff --git a/engines/access/player.cpp b/engines/access/player.cpp
index f7429bd..a85df03 100644
--- a/engines/access/player.cpp
+++ b/engines/access/player.cpp
@@ -46,6 +46,14 @@ Player::Player(AccessEngine *vm): _vm(vm) {
 	_playerOff = false;
 }
 
+void Player::load() {
+	// TODO
+}
+
+void Player::calcManScale() {
+	// TODO
+}
+
 void Player::walk() {
 	warning("TODO: Player::walk");
 }
diff --git a/engines/access/player.h b/engines/access/player.h
index 94ae987..4d19601 100644
--- a/engines/access/player.h
+++ b/engines/access/player.h
@@ -63,6 +63,10 @@ public:
 public:
 	Player(AccessEngine *vm);
 
+	void load();
+
+	void calcManScale();
+
 	void walk();
 };
 
diff --git a/engines/access/room.cpp b/engines/access/room.cpp
index 25d3584..c3a3a9f 100644
--- a/engines/access/room.cpp
+++ b/engines/access/room.cpp
@@ -28,6 +28,7 @@ namespace Access {
 
 Room::Room(AccessEngine *vm) : _vm(vm) {
 	_function = 0;
+	_roomFlag = 0;
 }
 
 void Room::doRoom() {
@@ -40,6 +41,8 @@ void Room::doRoom() {
 			_vm->_oldRect.clear();
 			_vm->_nextImage = 0;
 			_vm->_numAnimTimers = 0;
+
+			reloadRoom();
 		}
 
 		reloadFlag = false;
@@ -113,18 +116,63 @@ void Room::clearRoom() {
 	// TODO
 }
 
+void Room::reloadRoom() {
+	loadRoom(_vm->_roomNumber);
+
+	if (_roomFlag != 1) {
+		_vm->_currentMan = _roomFlag;
+		_vm->_currentManOld = _roomFlag;
+		_vm->_manScaleOff = 0;
+		
+		switch (_vm->_currentMan) {
+		case 0:
+			_vm->_man1 = _vm->_files->loadFile("MAN.LZ");
+			break;
+
+		case 2:
+			_vm->_man1 = _vm->_files->loadFile("JMAN.LZ");
+			break;
+
+		case 3:
+			_vm->_man1 = _vm->_files->loadFile("OVERHEAD.LZ");
+			_vm->_manScaleOff = 1;
+			break;
+
+		default:
+			break;
+		}
+	}
+
+	reloadRoom1();
+}
+
 void Room::reloadRoom1() {
 	// TODO
 }
 
+void Room::loadRoom(int room) {
+	// TODO
+}
+
 void Room::roomLoop() {
 	// TODO
 }
 
 
 void Room::doCommands() {
+	// TODO
+}
+
+void Room::setupRoom() {
+	// TODO
+}
 
+void Room::setWallCodes() {
+	// TODO
 }
 
+void Room::buildScreen() {
+	// TODO
+}
 
 } // End of namespace Access
diff --git a/engines/access/room.h b/engines/access/room.h
index 3b1a334..fd5e602 100644
--- a/engines/access/room.h
+++ b/engines/access/room.h
@@ -31,11 +31,20 @@ class AccessEngine;
 
 class Room {
 private:
+	void roomLoop();
+protected:
 	AccessEngine *_vm;
 
-	void roomLoop();
+	void setupRoom();
+	void setWallCodes();
+	void buildScreen();
+
+	virtual void reloadRoom() = 0;
+
+	virtual void reloadRoom1() = 0;
 public:
 	int _function;
+	int _roomFlag;
 public:
 	Room(AccessEngine *vm);
 
@@ -45,7 +54,7 @@ public:
 
 	void clearRoom();
 
-	void reloadRoom1();
+	void loadRoom(int room);
 };
 
 } // End of namespace Access
diff --git a/engines/access/screen.cpp b/engines/access/screen.cpp
index 8c87638..8dcc9f1 100644
--- a/engines/access/screen.cpp
+++ b/engines/access/screen.cpp
@@ -207,4 +207,8 @@ void Screen::copyRects() {
 	// TODO
 }
 
+void Screen::setBufferScan() {
+	// TODO
+}
+
 } // End of namespace Access
diff --git a/engines/access/screen.h b/engines/access/screen.h
index 5f9fff0..1b03d26 100644
--- a/engines/access/screen.h
+++ b/engines/access/screen.h
@@ -50,8 +50,6 @@ private:
 	int _topSkip, _bottomSkip;
 	int _clipWidth, _clipHeight;
 
-	void setPalette();
-
 	void updatePalette();
 
 	bool clip(Common::Rect &r);
@@ -91,6 +89,8 @@ public:
 
 	void loadPalette(Common::SeekableReadStream *stream);
 
+	void setPalette();
+
 	/**
 	 * Copy a buffer to the screen
 	 */
@@ -109,6 +109,8 @@ public:
 	void copyBlocks();
 
 	void copyRects();
+
+	void setBufferScan();
 };
 
 } // End of namespace Access
diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp
new file mode 100644
index 0000000..e31cd0c
--- /dev/null
+++ b/engines/access/scripts.cpp
@@ -0,0 +1,42 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "common/scummsys.h"
+#include "access/access.h"
+#include "access/scripts.h"
+
+namespace Access {
+
+Scripts::Scripts(AccessEngine *vm) : _vm(vm) {
+	_script = nullptr;
+	_sequence = 0;
+}
+
+void Scripts::searchForSeq() {
+	// TODO
+}
+
+void Scripts::executeCommand() {
+	// TODO
+}
+
+} // End of namespace Access
diff --git a/engines/access/scripts.h b/engines/access/scripts.h
new file mode 100644
index 0000000..b3e898f
--- /dev/null
+++ b/engines/access/scripts.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.
+ *
+ */
+
+#ifndef ACCESS_SCRIPTS_H
+#define ACCESS_SCRIPTS_H
+
+#include "common/scummsys.h"
+
+namespace Access {
+
+class AccessEngine;
+
+class Scripts {
+protected:
+	AccessEngine *_vm;
+public:
+	byte *_script;
+	int _sequence;
+public:
+	Scripts(AccessEngine *vm);
+
+	void searchForSeq();
+	
+	void executeCommand();
+};
+
+} // End of namespace Access
+
+#endif /* ACCESS_SCRIPTS_H */


Commit: c4d6dc376382de9b2d91d93ac9061f600b6a8696
    https://github.com/scummvm/scummvm/commit/c4d6dc376382de9b2d91d93ac9061f600b6a8696
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-06T08:28:20-04:00

Commit Message:
ACCESS: Added room clearing

Changed paths:
    engines/access/access.cpp
    engines/access/access.h
    engines/access/room.cpp
    engines/access/room.h
    engines/access/scripts.cpp
    engines/access/scripts.h
    engines/access/sound.cpp
    engines/access/sound.h



diff --git a/engines/access/access.cpp b/engines/access/access.cpp
index e175b1c..6b805e4 100644
--- a/engines/access/access.cpp
+++ b/engines/access/access.cpp
@@ -48,11 +48,13 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc)
 	_mouseMode = 0;
 	_currentMan = 0;
 	_currentManOld = -1;
+	_man = nullptr;
 	_man1 = nullptr;
 	_inactive = nullptr;
 	_manPal1 = nullptr;
 	_music = nullptr;
 	_playField = nullptr;
+	_tile = nullptr;
 	_anim = nullptr;
 	_title = nullptr;
 	_converseMode = 0;
@@ -127,6 +129,17 @@ AccessEngine::~AccessEngine() {
 
 	_buffer1.free();
 	_buffer2.free();
+
+	freeCells();
+	delete[] _man;
+	delete[] _man1;
+	delete[] _inactive;
+	delete[] _manPal1;
+	delete[] _music;
+	delete[] _playField;
+	delete[] _tile;
+	delete[] _anim;
+	delete[] _title;
 }
 
 void AccessEngine::setVGA() {
@@ -183,4 +196,36 @@ void AccessEngine::clearCellTable() {
 	Common::fill(&_objectsTable[0], &_objectsTable[100], (byte *)nullptr);
 }
 
+void AccessEngine::freeCells() {
+	for (int i = 0; i < 100; ++i) {
+		delete[] _objectsTable[i];
+		_objectsTable[i] = nullptr;
+	}
+}
+
+void AccessEngine::freeAnimationData() {
+	delete[] _anim;
+	_anim = nullptr;
+}
+
+void AccessEngine::freePlayField() {
+	delete[] _playField;
+	_playField = nullptr;
+}
+
+void AccessEngine::freeTileData() {
+	delete[] _tile;
+	_tile = nullptr;
+}
+
+void AccessEngine::freeInactiveData() {
+	delete[] _inactive;
+	_inactive = nullptr;
+}
+
+void AccessEngine::freeManData() {
+	delete[] _man;
+	_man = nullptr;
+}
+
 } // End of namespace Access
diff --git a/engines/access/access.h b/engines/access/access.h
index 21f8072..2e605e4 100644
--- a/engines/access/access.h
+++ b/engines/access/access.h
@@ -85,11 +85,6 @@ protected:
 	Common::RandomSource _randomSource;
 
 	/**
-	 * Clear the cell table
-	 */
-	void clearCellTable();
-
-	/**
 	 * Main handler for showing game rooms
 	 */
 	void doRoom();
@@ -128,11 +123,13 @@ public:
 	int _nextImage;
 
 	int _currentManOld;
+	byte *_man;
 	byte *_man1;
 	byte *_inactive;
 	byte *_manPal1;
 	byte *_music;
 	byte *_playField;
+	byte *_tile;
 	byte *_anim;
 	byte *_title;
 	int _converseMode;
@@ -202,6 +199,38 @@ public:
 	uint32 getGameFeatures() const;
 
 	int getRandomNumber(int maxNumber);
+
+	void freeAnimationData();
+
+	/**
+	* Clear the cell table
+	*/
+	void clearCellTable();
+
+	/**
+	* Free the cell data
+	*/
+	void freeCells();
+
+	/**
+	 * Free the playfield data
+	 */
+	void freePlayField();
+
+	/**
+	 * Free tile data
+	 */
+	void freeTileData();
+
+	/**
+	 * Free the inactive data
+	 */
+	void freeInactiveData();
+
+	/**
+	 * Free animation data
+	 */
+	void freeManData();
 };
 
 } // End of namespace Access
diff --git a/engines/access/room.cpp b/engines/access/room.cpp
index c3a3a9f..0515b50 100644
--- a/engines/access/room.cpp
+++ b/engines/access/room.cpp
@@ -113,41 +113,21 @@ void Room::doRoom() {
 }
 
 void Room::clearRoom() {
-	// TODO
-}
-
-void Room::reloadRoom() {
-	loadRoom(_vm->_roomNumber);
-
-	if (_roomFlag != 1) {
-		_vm->_currentMan = _roomFlag;
-		_vm->_currentManOld = _roomFlag;
-		_vm->_manScaleOff = 0;
-		
-		switch (_vm->_currentMan) {
-		case 0:
-			_vm->_man1 = _vm->_files->loadFile("MAN.LZ");
-			break;
-
-		case 2:
-			_vm->_man1 = _vm->_files->loadFile("JMAN.LZ");
-			break;
-
-		case 3:
-			_vm->_man1 = _vm->_files->loadFile("OVERHEAD.LZ");
-			_vm->_manScaleOff = 1;
-			break;
-
-		default:
-			break;
-		}
+	if (_vm->_sound->_music) {
+		_vm->_sound->stopSong();
+		delete[] _vm->_sound->_music;
+		_vm->_sound->_music = nullptr;
 	}
 
-	reloadRoom1();
-}
+	_vm->_sound->freeSounds();
+	_vm->_numAnimTimers = 0;
 
-void Room::reloadRoom1() {
-	// TODO
+	_vm->freeAnimationData();
+	_vm->_scripts->freeScriptData();
+	_vm->freeCells();
+	_vm->freePlayField();
+	_vm->freeInactiveData();
+	_vm->freeManData();
 }
 
 void Room::loadRoom(int room) {
diff --git a/engines/access/room.h b/engines/access/room.h
index fd5e602..28506db 100644
--- a/engines/access/room.h
+++ b/engines/access/room.h
@@ -52,6 +52,9 @@ public:
 
 	void doCommands();
 
+	/**
+	 * Clear all the data used by the room
+	 */
 	void clearRoom();
 
 	void loadRoom(int room);
diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp
index e31cd0c..bd480b8 100644
--- a/engines/access/scripts.cpp
+++ b/engines/access/scripts.cpp
@@ -31,6 +31,10 @@ Scripts::Scripts(AccessEngine *vm) : _vm(vm) {
 	_sequence = 0;
 }
 
+Scripts::~Scripts() {
+	freeScriptData();
+}
+
 void Scripts::searchForSeq() {
 	// TODO
 }
@@ -39,4 +43,9 @@ void Scripts::executeCommand() {
 	// TODO
 }
 
+void Scripts::freeScriptData() {
+	delete[] _script;
+	_script = nullptr;
+}
+
 } // End of namespace Access
diff --git a/engines/access/scripts.h b/engines/access/scripts.h
index b3e898f..995f129 100644
--- a/engines/access/scripts.h
+++ b/engines/access/scripts.h
@@ -38,9 +38,13 @@ public:
 public:
 	Scripts(AccessEngine *vm);
 
+	virtual ~Scripts();
+
 	void searchForSeq();
 	
 	void executeCommand();
+
+	void freeScriptData();
 };
 
 } // End of namespace Access
diff --git a/engines/access/sound.cpp b/engines/access/sound.cpp
index 2a008d8..2f64465 100644
--- a/engines/access/sound.cpp
+++ b/engines/access/sound.cpp
@@ -32,6 +32,8 @@ SoundManager::SoundManager(AccessEngine *vm, Audio::Mixer *mixer) :
 	Common::fill(&_soundPriority[0], &_soundPriority[MAX_SOUNDS], 0);
 	for (int i = 0; i < MAX_SOUNDS; ++i)
 		_soundTable[i]._data = nullptr;
+
+	_music = nullptr;
 }
 
 SoundManager::~SoundManager() {
@@ -68,5 +70,12 @@ void SoundManager::midiRepeat() {
 	// TODO
 }
 
+void SoundManager::stopSong() {
+	// TODO
+}
+
+void SoundManager::freeSounds() {
+	// TODO
+}
 
 } // End of namespace Access
diff --git a/engines/access/sound.h b/engines/access/sound.h
index 613eca4..37d263e 100644
--- a/engines/access/sound.h
+++ b/engines/access/sound.h
@@ -48,6 +48,7 @@ private:
 public:
 	SoundEntry _soundTable[MAX_SOUNDS];
 	int _soundPriority[MAX_SOUNDS];
+	byte *_music;
 public:
 	SoundManager(AccessEngine *vm, Audio::Mixer *mixer);
 	~SoundManager();
@@ -57,6 +58,10 @@ public:
 	void playSound(int soundIndex);
 
 	void midiRepeat();
+
+	void stopSong();
+
+	void freeSounds();
 };
 
 } // End of namespace Access


Commit: 3bd0f0f3394e87ee3e18c1bfda80a99ccc31c61c
    https://github.com/scummvm/scummvm/commit/3bd0f0f3394e87ee3e18c1bfda80a99ccc31c61c
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-06T08:55:56-04:00

Commit Message:
ACCESS: Split resources into a seperate file just for Amazon resources

Changed paths:
  A engines/access/amazon/amazon_resources.cpp
  A engines/access/amazon/amazon_resources.h
    engines/access/amazon/amazon_game.cpp
    engines/access/events.cpp
    engines/access/files.cpp
    engines/access/module.mk
    engines/access/resources.cpp
    engines/access/resources.h
    engines/access/room.cpp



diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp
index ffe4cb5..eccfc4d 100644
--- a/engines/access/amazon/amazon_game.cpp
+++ b/engines/access/amazon/amazon_game.cpp
@@ -22,6 +22,7 @@
 
 #include "access/resources.h"
 #include "access/amazon/amazon_game.h"
+#include "access/amazon/amazon_resources.h"
 #include "access/amazon/amazon_room.h"
 #include "access/amazon/amazon_scripts.h"
 
diff --git a/engines/access/amazon/amazon_resources.cpp b/engines/access/amazon/amazon_resources.cpp
new file mode 100644
index 0000000..4d798db
--- /dev/null
+++ b/engines/access/amazon/amazon_resources.cpp
@@ -0,0 +1,250 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, 0xwhose 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, 0xor (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, 0xwrite to the Free Software
+ * Foundation, 0xInc., 0x51 Franklin Street, 0xFifth Floor, 0xBoston, 0xMA 02110-1301, 0xUSA.
+ *
+ */
+
+#include "access/amazon/amazon_resources.h"
+#include "access/access.h"
+
+namespace Access {
+
+namespace Amazon {
+
+const char *const FILENAMES[] = {
+	"S00.AP", "S01.AP", "S02.AP", "R03.AP", "S04.AP", "S05.AP",
+	"S06.AP", "S07.AP", "S08.AP", "S09.AP", "S10.AP", "S11.AP",
+	"S12.AP", "S13.AP", "S14.AP", "S15.AP", "S16.AP", "S17.AP",
+	"S18.AP", "S19.AP", "S20.AP", "S21.AP", "S22.AP", "S23.AP",
+	"S24.AP", "S25.AP", "S26.AP", "S27.AP", "S28.AP", "S29.AP",
+	"S30.AP", "S31.AP", "S32.AP", "S33.AP", "S34.AP", "R35.AP",
+	"S36.AP", "S37.AP", "S38.AP", "S39.AP", "S40.AP", "C26.AP",
+	"S42.AP", "S01.AP", "S44.AP", "S45.AP", "S46.AP", "S47.AP",
+	"C36.AP", nullptr,  "S50.AP", nullptr,  nullptr,  "S53.AP",
+	"S54.AP", "S55.AP", "C35.AP", "S57.AP", "S58.AP", nullptr,
+	nullptr,  "S61.AP", nullptr,  nullptr,  "S64.AP", "C00.AP",
+	"C01.AP", "C06.AP", "C07.AP", "C08.AP", "C05.AP", "C09.AP",
+	"C12.AP", "C03.AP", "C13.AP", "C15.AP", "C14.AP", "C16.AP",
+	"C17.AP", "C19.AP", "C20.AP", "C21.AP", "C22.AP", "C23.AP",
+	"C24.AP", "C25.AP", "C29.AP", "C30.AP", "C32.AP", "C33.AP",
+	"C34.AP", "CREDITS.AP", "MIDIDRV.AP", "SUMMARY.AP", "DEAD.AP",
+	"EST.AP", "CHAPTER.AP", "MIDI.AP", "SOUND.AP", "INV.AP",
+	"NARATE01.AP", "NARATE02.AP", "NARATE03.AP", "NARATE04.AP",
+	"NARATE05.AP", "NARATE06.AP", "NARATE07.AP", "NARATE08.AP",
+	"NARATE09.AP", "NARATE10.AP", "NARATE11.AP", "NARATE12.AP",
+	"NARATE13.AP", "NARATE14.AP"
+};
+
+const byte MOUSE0[] = {
+	0, 0, 0, 0, 
+	0, 2, 6, 1, 0, 3, 6, 6, 1, 0, 3, 6, 6, 1,
+	0, 4, 6, 6, 6, 1, 0, 4, 6, 6, 6, 1, 0, 5, 6, 6, 6, 6,
+	1, 0, 5, 6, 6, 6, 6, 1, 0, 6, 6, 6, 6, 6, 6, 1, 0, 6,
+	6, 6, 6, 6, 6, 1, 0, 7, 6, 6, 6, 6, 6, 6, 1, 0, 6, 6,
+	6, 6, 6, 6, 1, 0, 5, 6, 6, 6, 6, 1, 2, 3, 6, 6, 1, 3,
+	3, 6, 6, 1, 3, 3, 6, 6, 1, 4, 2, 6, 1
+};
+const byte MOUSE1[] = {
+	0x07, 0x00, 0x07, 0x00, 0x06, 0x01, 0x05, 0x04, 0x05, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x03, 0x07,
+	0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x02, 0x09, 0xFF, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00,
+	0x00, 0xFF, 0x01, 0x0B, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x01,
+	0x0B, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x0D, 0x05, 0x00,
+	0x00, 0x05, 0x00, 0x05, 0x00, 0x05, 0x00, 0x05, 0x00, 0x00, 0x05, 0x01, 0x0B, 0xFF, 0x00, 0x00,
+	0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x01, 0x0B, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0xFF, 0x02, 0x09, 0xFF, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0xFF,
+	0x03, 0x07, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x04, 0x05, 0xFF, 0xFF, 0x00, 0xFF, 0xFF,
+	0x06, 0x01, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+};
+const byte MOUSE2[] = {
+	0x08, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x02, 0x04, 0x05, 0x07, 0x02, 0x04, 0x05,
+	0x07, 0x02, 0x04, 0x05, 0x07, 0x02, 0x04, 0x05, 0x07, 0x02, 0x04, 0x05, 0x02, 0x0C, 0x04, 0x04,
+	0x04, 0x04, 0x04, 0x00, 0x04, 0x04, 0x04, 0x04, 0x04, 0x05, 0x07, 0x02, 0x04, 0x05, 0x07, 0x02,
+	0x04, 0x05, 0x07, 0x02, 0x04, 0x05, 0x07, 0x02, 0x04, 0x05, 0x07, 0x02, 0x04, 0x05, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00
+};
+const byte MOUSE3[] = {
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x0B, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06,
+	0x06, 0x00, 0x0C, 0x06, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x06, 0x06, 0x05, 0x00,
+	0x0C, 0x06, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x06, 0x05, 0x05, 0x00, 0x0C, 0x06,
+	0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x05, 0x00, 0x0C, 0x06, 0x06, 0x06,
+	0x06, 0x06, 0x05, 0x06, 0x06, 0x06, 0x06, 0x06, 0x05, 0x00, 0x0C, 0x06, 0x06, 0x06, 0x06, 0x05,
+	0x00, 0x00, 0x06, 0x06, 0x06, 0x06, 0x05, 0x00, 0x0C, 0x06, 0x06, 0x06, 0x06, 0x06, 0x00, 0x06,
+	0x06, 0x06, 0x06, 0x06, 0x05, 0x00, 0x0C, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06,
+	0x06, 0x06, 0x05, 0x00, 0x0C, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06,
+	0x05, 0x00, 0x0C, 0x06, 0x06, 0x06, 0x06, 0x06, 0x05, 0x06, 0x06, 0x06, 0x06, 0x06, 0x05, 0x00,
+	0x0C, 0x06, 0x06, 0x06, 0x06, 0x06, 0x05, 0x06, 0x06, 0x06, 0x06, 0x06, 0x05, 0x00, 0x0C, 0x06,
+	0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x05, 0x01, 0x0B, 0x05, 0x05, 0x05,
+	0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+};
+const byte CURSEYE[] = {
+	0x01, 0x00, 0x08, 0x00, 0x04, 0x06, 0x0E, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x03, 0x09, 0x0E, 0x01,
+	0x01, 0x01, 0x01, 0x01, 0x01, 0x0D, 0x0D, 0x02, 0x0B, 0x0E, 0x01, 0x33, 0x33, 0x01, 0x01, 0x33,
+	0x34, 0x01, 0x01, 0x0D, 0x01, 0x0D, 0x0E, 0x01, 0x04, 0x34, 0x01, 0x01, 0x01, 0x07, 0x33, 0x04,
+	0x04, 0x01, 0x0D, 0x00, 0x0F, 0x0E, 0x0E, 0x01, 0x07, 0x33, 0x33, 0x01, 0x01, 0x33, 0x34, 0x07,
+	0x07, 0x06, 0x01, 0x0E, 0x01, 0x0D, 0x0F, 0x0F, 0x06, 0x07, 0x34, 0x33, 0x33, 0x34, 0x07, 0x07,
+	0x06, 0x0F, 0x0E, 0x03, 0x09, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0E, 0x01, 0x01,
+	0x07, 0x00, 0x03, 0x07, 0x01, 0x07, 0x01, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00
+};
+const byte CURSHAND[] = {
+	0x02, 0x00, 0x03, 0x00, 0x07, 0x02, 0x17, 0x0E, 0x05, 0x07, 0x0E, 0x12, 0x17, 0x0E, 0x13, 0x17,
+	0x0E, 0x02, 0x0C, 0x07, 0x00, 0x17, 0x0E, 0x11, 0x0F, 0x0E, 0x11, 0x17, 0x0E, 0x00, 0x17, 0x01,
+	0x0E, 0x07, 0x01, 0x07, 0x0F, 0x0E, 0x11, 0x17, 0x0E, 0x11, 0x0F, 0x0E, 0x12, 0x17, 0x0E, 0x02,
+	0x0D, 0x07, 0x00, 0x17, 0x0F, 0x12, 0x0F, 0x0F, 0x11, 0x17, 0x0E, 0x12, 0x0F, 0x0E, 0x04, 0x0B,
+	0x0F, 0x0E, 0x11, 0x17, 0x0E, 0x12, 0x0F, 0x0F, 0x11, 0x17, 0x0E, 0x04, 0x0B, 0x17, 0x0E, 0x12,
+	0x17, 0x0E, 0x12, 0x17, 0x0E, 0x11, 0x0F, 0x0E, 0x00, 0x0F, 0x0E, 0x0D, 0x12, 0x00, 0x17, 0x0F,
+	0x0F, 0x0F, 0x0F, 0x12, 0x0F, 0x0E, 0x12, 0x17, 0x0F, 0x00, 0x0F, 0x0F, 0x17, 0x0D, 0x11, 0x0F,
+	0x0E, 0x0D, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0E, 0x0D, 0x01, 0x0E, 0x0F, 0x17, 0x0F, 0x0E,
+	0x0F, 0x0D, 0x0D, 0x0D, 0x0D, 0x0E, 0x0F, 0x0F, 0x0E, 0x0D, 0x02, 0x0D, 0x0F, 0x17, 0x0F, 0x0E,
+	0x0D, 0x0D, 0x0F, 0x0F, 0x0E, 0x0F, 0x0E, 0x0E, 0x12, 0x03, 0x0C, 0x0F, 0x17, 0x0F, 0x0F, 0x0F,
+	0x0E, 0x0F, 0x0F, 0x0F, 0x0E, 0x0D, 0x12, 0x04, 0x0A, 0x0F, 0x17, 0x0F, 0x0F, 0x0F, 0x0E, 0x0F,
+	0x0F, 0x0E, 0x0D, 0x05, 0x09, 0x0F, 0x17, 0x0F, 0x0F, 0x0F, 0x0F, 0x0E, 0x0D, 0x12, 0x06, 0x08,
+	0x17, 0x0F, 0x0F, 0x0F, 0x0F, 0x0E, 0x0D, 0x12, 0x06, 0x07, 0x17, 0x0F, 0x0F, 0x0F, 0x3D, 0x0E,
+	0x0D
+};
+const byte CURSGET[] = {
+	0x07, 0x00, 0x0E, 0x00, 0x0A, 0x05, 0x1C, 0x07, 0x0F, 0x0F, 0x0F, 0x08, 0x08, 0x1C, 0x07, 0x0F,
+	0x0F, 0x0F, 0x0F, 0x0F, 0x0C, 0x06, 0x0A, 0x1C, 0x07, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F,
+	0x0C, 0x05, 0x0A, 0x07, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0C, 0x03, 0x0C, 0x07,
+	0x1C, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0C, 0x02, 0x0D, 0x1C, 0x0F, 0x0E,
+	0x0E, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0C, 0x01, 0x0E, 0x07, 0x0F, 0x0E, 0x0D,
+	0x0F, 0x0E, 0x0D, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0C, 0x00, 0x0F, 0x1C, 0x0F, 0x0E, 0x0D,
+	0x0F, 0x0E, 0x0D, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0C, 0x00, 0x0F, 0x1C, 0x0E, 0x0D,
+	0x0F, 0x0E, 0x0D, 0x0F, 0x0F, 0x0C, 0x0C, 0x0E, 0x0F, 0x0F, 0x0F, 0x0C, 0x00, 0x0E, 0x1C, 0x0D,
+	0x0F, 0x0E, 0x0D, 0x0F, 0x0F, 0x0C, 0x00, 0x00, 0x0E, 0x0F, 0x0F, 0x0C, 0x00, 0x0E, 0x1C, 0x0E,
+	0x0F, 0x0D, 0x0F, 0x0F, 0x0C, 0x00, 0x00, 0x0E, 0x1C, 0x0F, 0x0F, 0x0C, 0x00, 0x0D, 0x1C, 0x0D,
+	0x0F, 0x0D, 0x0F, 0x0C, 0x00, 0x00, 0x00, 0x0E, 0x1C, 0x0F, 0x0C, 0x01, 0x0B, 0x0E, 0x0F, 0x0E,
+	0x0F, 0x0C, 0x00, 0x00, 0x0E, 0x07, 0x0F, 0x0C, 0x02, 0x09, 0x0E, 0x0D, 0x0F, 0x0C, 0x00, 0x07,
+	0x0E, 0x0F, 0x0C, 0x03, 0x06, 0x0E, 0x0F, 0x0E, 0x07, 0x01, 0x07, 0x07, 0x01, 0x07
+};
+const byte CURSCLIMB[] = {
+	0x03, 0x00, 0x0E, 0x00, 0x06, 0x04, 0x01, 0x01, 0x01, 0x01, 0x06, 0x04, 0x0F, 0x0E, 0x01, 0x01,
+	0x06, 0x04, 0x0F, 0x0E, 0x0D, 0x01, 0x07, 0x02, 0x0F, 0x0D, 0x00, 0x0C, 0x0F, 0x00, 0x00, 0x00,
+	0x00, 0x13, 0x12, 0x12, 0x12, 0x12, 0x11, 0x11, 0x00, 0x0D, 0x0D, 0x0E, 0x00, 0x00, 0x13, 0x14,
+	0x13, 0x12, 0x12, 0x12, 0x11, 0x11, 0x0E, 0x01, 0x0C, 0x0D, 0x0D, 0x0D, 0x0E, 0x11, 0x13, 0x13,
+	0x12, 0x11, 0x11, 0x0E, 0x0D, 0x02, 0x0C, 0x0E, 0x0E, 0x00, 0x00, 0x00, 0x13, 0x12, 0x11, 0x00,
+	0x00, 0x0E, 0x0D, 0x03, 0x0B, 0x04, 0x04, 0x04, 0x22, 0x21, 0x21, 0x20, 0x00, 0x00, 0x00, 0x0D,
+	0x02, 0x0D, 0x22, 0x04, 0x20, 0x22, 0x04, 0x21, 0x04, 0x20, 0x00, 0x00, 0x00, 0x0E, 0x0E, 0x03,
+	0x07, 0x22, 0x21, 0x20, 0x20, 0x22, 0x04, 0x20, 0x04, 0x06, 0x01, 0x01, 0x00, 0x04, 0x22, 0x20,
+	0x02, 0x09, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x04, 0x20, 0x03, 0x09, 0x07, 0x01, 0x01,
+	0x00, 0x00, 0x00, 0x22, 0x04, 0x20, 0x02, 0x0B, 0x07, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x01, 0x01, 0x20, 0x03, 0x0A, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01
+};
+const byte CURSTALK[] = {
+	0x02, 0x00, 0x0B, 0x00, 0x03, 0x08, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x01, 0x0C,
+	0x06, 0x06, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x06, 0x06, 0x00, 0x0E, 0x06, 0x06,
+	0x06, 0x06, 0x07, 0x06, 0x07, 0x07, 0x06, 0x07, 0x07, 0x06, 0x07, 0x06, 0x00, 0x0F, 0x06, 0x08,
+	0x08, 0x08, 0x06, 0x08, 0x06, 0x06, 0x08, 0x06, 0x06, 0x08, 0x06, 0x08, 0x06, 0x00, 0x0F, 0x06,
+	0x06, 0x08, 0x06, 0x08, 0x06, 0x08, 0x06, 0x08, 0x06, 0x06, 0x08, 0x08, 0x06, 0x06, 0x00, 0x0F,
+	0x06, 0x06, 0x08, 0x06, 0x08, 0x08, 0x08, 0x06, 0x08, 0x06, 0x06, 0x08, 0x06, 0x08, 0x06, 0x01,
+	0x0E, 0x06, 0x08, 0x06, 0x08, 0x06, 0x08, 0x06, 0x08, 0x08, 0x06, 0x08, 0x06, 0x08, 0x06, 0x02,
+	0x0C, 0x06, 0x06, 0x06, 0x07, 0x06, 0x07, 0x06, 0x06, 0x07, 0x06, 0x07, 0x06, 0x04, 0x09, 0x06,
+	0x06, 0x06, 0x07, 0x07, 0x07, 0x07, 0x06, 0x06, 0x07, 0x04, 0x06, 0x07, 0x07, 0x06, 0x02, 0x08,
+	0x07, 0x00, 0x00, 0x06, 0x06, 0x06, 0x06, 0x06, 0x01, 0x06, 0x07, 0x01, 0x07, 0x06, 0x06, 0x06,
+	0x02, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+};
+const byte CURSHELP[] = {
+	0x02, 0x00, 0x0B, 0x00, 0x04, 0x06, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x02, 0x0A, 0x24, 0x24,
+	0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x20, 0x20, 0x01, 0x0C, 0x24, 0x22, 0x22, 0x22, 0x20, 0x20,
+	0x20, 0x22, 0x22, 0x22, 0x22, 0x20, 0x00, 0x0E, 0x24, 0x22, 0x22, 0x22, 0x20, 0x00, 0x00, 0x00,
+	0x24, 0x22, 0x22, 0x22, 0x22, 0x20, 0x00, 0x0E, 0x24, 0x22, 0x22, 0x22, 0x22, 0x20, 0x00, 0x00,
+	0x00, 0x24, 0x22, 0x22, 0x22, 0x20, 0x00, 0x0E, 0x24, 0x22, 0x22, 0x22, 0x22, 0x20, 0x00, 0x00,
+	0x00, 0x24, 0x22, 0x22, 0x22, 0x20, 0x01, 0x0D, 0x24, 0x20, 0x20, 0x20, 0x00, 0x00, 0x00, 0x24,
+	0x22, 0x22, 0x22, 0x22, 0x20, 0x07, 0x06, 0x24, 0x22, 0x22, 0x22, 0x22, 0x20, 0x05, 0x07, 0x24,
+	0x22, 0x22, 0x22, 0x22, 0x20, 0x20, 0x04, 0x05, 0x24, 0x22, 0x22, 0x22, 0x20, 0x02, 0x07, 0x07,
+	0x00, 0x24, 0x20, 0x20, 0x20, 0x20, 0x01, 0x03, 0x07, 0x01, 0x07, 0x02, 0x07, 0x07, 0x00, 0x00,
+	0x24, 0x24, 0x24, 0x24, 0x04, 0x06, 0x24, 0x22, 0x22, 0x22, 0x22, 0x20, 0x04, 0x06, 0x24, 0x22,
+	0x22, 0x22, 0x22, 0x20, 0x05, 0x04, 0x20, 0x20, 0x20, 0x20
+};
+const byte *CURSORS[10] = {
+	MOUSE0, MOUSE1, MOUSE2, MOUSE3, CURSEYE, CURSHAND, CURSGET, CURSCLIMB, CURSTALK, CURSHELP
+};
+
+const int TRAVEL_POS[][2] = {
+	{ -1, 0 },
+	{ 228, 117 },
+	{ 28, 98 },
+	{ 161, 140 },
+	{ 130, 139 },
+	{ 884, 95 },
+	{ 0, 0 },
+	{ 0, 0 },
+	{ 0, 0 },
+	{ 41, 185 },
+	{ 60, 138 },
+	{ 0, 0 },
+	{ 0, 0 },
+	{ 0, 0 },
+	{ 0, 0 },
+	{ 0, 0 },
+	{ 170, 155 },
+	{ 0, 0 },
+	{ 0, 0 },
+	{ 0, 0 },
+	{ 108, 95 },
+	{ 0, 0 },
+	{ 0, 0 },
+	{ 0, 0 },
+	{ 100, 115 },
+	{ 480, 90 },
+	{ 154, 63 },
+	{ 0, 0 },
+	{ 145, 85 },
+	{ 0, 0 },
+	{ 110, 107 },
+	{ 0, 0 },
+	{ 105, 154 },
+	{ 0, 0 },
+	{ 0, 0 },
+	{ 0, 0 },
+	{ 0, 0 },
+	{ 20, 160 },
+	{ 130, 314 },
+	{ 0, 0 },
+	{ 50, 125 },
+	{ 0, 0 },
+	{ 0, 0 },
+	{ 123, 123 },
+	{ -1, 7 },
+	{ 266, 168 },
+	{ 0, 0 },
+	{ 0, 0 },
+	{ 0, 0 },
+	{ -1, 18 },
+	{ -1, 19 },
+	{ 0, 0 },
+	{ 0, 0 },
+	{ 0, 0 },
+	{ 0, 0 },
+	{ 0, 0 },
+	{ 203, 160 },
+	{ 0, 0 },
+	{ 283, 163 },
+	{ 0, 0 },
+	{ 0, 0 },
+	{ 0, 0 },
+	{ 180, 165 },
+	{ 0, 0 },
+	{ 0, 0 },
+	{ 0, 0 }
+};
+
+} // End of namespace Amazon
+
+} // End of namespace Access
diff --git a/engines/access/amazon/amazon_resources.h b/engines/access/amazon/amazon_resources.h
new file mode 100644
index 0000000..fba3bc2
--- /dev/null
+++ b/engines/access/amazon/amazon_resources.h
@@ -0,0 +1,42 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef ACCESS_AMAZON_RESOURCES_H
+#define ACCESS_AMAZON_RESOURCES_H
+
+#include "common/scummsys.h"
+
+namespace Access {
+
+namespace Amazon {
+
+extern const char *const FILENAMES[];
+
+extern const byte *CURSORS[10];
+
+extern const int TRAVEL_POS[][2];
+
+} // End of namespace Amazon
+
+} // End of namespace Access
+
+#endif /* ACCESS_AMAZON_RESOURCES_H */
diff --git a/engines/access/events.cpp b/engines/access/events.cpp
index 29f6270..1184128 100644
--- a/engines/access/events.cpp
+++ b/engines/access/events.cpp
@@ -27,7 +27,7 @@
 #include "engines/util.h"
 #include "access/access.h"
 #include "access/events.h"
-#include "access/resources.h"
+#include "access/amazon/amazon_resources.h"
 
 #define CURSOR_WIDTH 16
 #define CURSOR_HEIGHT 16
diff --git a/engines/access/files.cpp b/engines/access/files.cpp
index 37b2578..c72d0ad 100644
--- a/engines/access/files.cpp
+++ b/engines/access/files.cpp
@@ -21,7 +21,7 @@
  */
 
 #include "access/files.h"
-#include "access/resources.h"
+#include "access/amazon/amazon_resources.h"
 #include "access/access.h"
 
 namespace Access {
diff --git a/engines/access/module.mk b/engines/access/module.mk
index 5c9203f..042e84a 100644
--- a/engines/access/module.mk
+++ b/engines/access/module.mk
@@ -16,6 +16,7 @@ MODULE_OBJS := \
 	scripts.o \
 	sound.o \
 	amazon\amazon_game.o \
+	amazon\amazon_resources.o \
 	amazon\amazon_room.o \
 	amazon\amazon_scripts.o
 
diff --git a/engines/access/resources.cpp b/engines/access/resources.cpp
index 70d4a69..8aa44b4 100644
--- a/engines/access/resources.cpp
+++ b/engines/access/resources.cpp
@@ -46,227 +46,4 @@ const byte INITIAL_PALETTE[18 * 3] = {
 	0x00, 0x00, 0x00
 };
 
-namespace Amazon {
-
-const char *const FILENAMES[] = {
-	"S00.AP", "S01.AP", "S02.AP", "R03.AP", "S04.AP", "S05.AP",
-	"S06.AP", "S07.AP", "S08.AP", "S09.AP", "S10.AP", "S11.AP",
-	"S12.AP", "S13.AP", "S14.AP", "S15.AP", "S16.AP", "S17.AP",
-	"S18.AP", "S19.AP", "S20.AP", "S21.AP", "S22.AP", "S23.AP",
-	"S24.AP", "S25.AP", "S26.AP", "S27.AP", "S28.AP", "S29.AP",
-	"S30.AP", "S31.AP", "S32.AP", "S33.AP", "S34.AP", "R35.AP",
-	"S36.AP", "S37.AP", "S38.AP", "S39.AP", "S40.AP", "C26.AP",
-	"S42.AP", "S01.AP", "S44.AP", "S45.AP", "S46.AP", "S47.AP",
-	"C36.AP", nullptr,  "S50.AP", nullptr,  nullptr,  "S53.AP",
-	"S54.AP", "S55.AP", "C35.AP", "S57.AP", "S58.AP", nullptr,
-	nullptr,  "S61.AP", nullptr,  nullptr,  "S64.AP", "C00.AP",
-	"C01.AP", "C06.AP", "C07.AP", "C08.AP", "C05.AP", "C09.AP",
-	"C12.AP", "C03.AP", "C13.AP", "C15.AP", "C14.AP", "C16.AP",
-	"C17.AP", "C19.AP", "C20.AP", "C21.AP", "C22.AP", "C23.AP",
-	"C24.AP", "C25.AP", "C29.AP", "C30.AP", "C32.AP", "C33.AP",
-	"C34.AP", "CREDITS.AP", "MIDIDRV.AP", "SUMMARY.AP", "DEAD.AP",
-	"EST.AP", "CHAPTER.AP", "MIDI.AP", "SOUND.AP", "INV.AP",
-	"NARATE01.AP", "NARATE02.AP", "NARATE03.AP", "NARATE04.AP",
-	"NARATE05.AP", "NARATE06.AP", "NARATE07.AP", "NARATE08.AP",
-	"NARATE09.AP", "NARATE10.AP", "NARATE11.AP", "NARATE12.AP",
-	"NARATE13.AP", "NARATE14.AP"
-};
-
-const byte *CURSORS[10] = {
-	MOUSE0, MOUSE1, MOUSE2, MOUSE3, CURSEYE, CURSHAND, CURSGET, CURSCLIMB, CURSTALK, CURSHELP
-};
-
-const byte MOUSE0[] = {
-	0, 0, 0, 0, 
-	0, 2, 6, 1, 0, 3, 6, 6, 1, 0, 3, 6, 6, 1,
-	0, 4, 6, 6, 6, 1, 0, 4, 6, 6, 6, 1, 0, 5, 6, 6, 6, 6,
-	1, 0, 5, 6, 6, 6, 6, 1, 0, 6, 6, 6, 6, 6, 6, 1, 0, 6,
-	6, 6, 6, 6, 6, 1, 0, 7, 6, 6, 6, 6, 6, 6, 1, 0, 6, 6,
-	6, 6, 6, 6, 1, 0, 5, 6, 6, 6, 6, 1, 2, 3, 6, 6, 1, 3,
-	3, 6, 6, 1, 3, 3, 6, 6, 1, 4, 2, 6, 1
-};
-const byte MOUSE1[] = {
-	0x07, 0x00, 0x07, 0x00, 0x06, 0x01, 0x05, 0x04, 0x05, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x03, 0x07,
-	0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x02, 0x09, 0xFF, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00,
-	0x00, 0xFF, 0x01, 0x0B, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x01,
-	0x0B, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x0D, 0x05, 0x00,
-	0x00, 0x05, 0x00, 0x05, 0x00, 0x05, 0x00, 0x05, 0x00, 0x00, 0x05, 0x01, 0x0B, 0xFF, 0x00, 0x00,
-	0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x01, 0x0B, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0xFF, 0x02, 0x09, 0xFF, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0xFF,
-	0x03, 0x07, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x04, 0x05, 0xFF, 0xFF, 0x00, 0xFF, 0xFF,
-	0x06, 0x01, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
-};
-const byte MOUSE2[] = {
-	0x08, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x02, 0x04, 0x05, 0x07, 0x02, 0x04, 0x05,
-	0x07, 0x02, 0x04, 0x05, 0x07, 0x02, 0x04, 0x05, 0x07, 0x02, 0x04, 0x05, 0x02, 0x0C, 0x04, 0x04,
-	0x04, 0x04, 0x04, 0x00, 0x04, 0x04, 0x04, 0x04, 0x04, 0x05, 0x07, 0x02, 0x04, 0x05, 0x07, 0x02,
-	0x04, 0x05, 0x07, 0x02, 0x04, 0x05, 0x07, 0x02, 0x04, 0x05, 0x07, 0x02, 0x04, 0x05, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00
-};
-const byte MOUSE3[] = {
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x0B, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06,
-	0x06, 0x00, 0x0C, 0x06, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x06, 0x06, 0x05, 0x00,
-	0x0C, 0x06, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x06, 0x05, 0x05, 0x00, 0x0C, 0x06,
-	0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x05, 0x00, 0x0C, 0x06, 0x06, 0x06,
-	0x06, 0x06, 0x05, 0x06, 0x06, 0x06, 0x06, 0x06, 0x05, 0x00, 0x0C, 0x06, 0x06, 0x06, 0x06, 0x05,
-	0x00, 0x00, 0x06, 0x06, 0x06, 0x06, 0x05, 0x00, 0x0C, 0x06, 0x06, 0x06, 0x06, 0x06, 0x00, 0x06,
-	0x06, 0x06, 0x06, 0x06, 0x05, 0x00, 0x0C, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06,
-	0x06, 0x06, 0x05, 0x00, 0x0C, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06,
-	0x05, 0x00, 0x0C, 0x06, 0x06, 0x06, 0x06, 0x06, 0x05, 0x06, 0x06, 0x06, 0x06, 0x06, 0x05, 0x00,
-	0x0C, 0x06, 0x06, 0x06, 0x06, 0x06, 0x05, 0x06, 0x06, 0x06, 0x06, 0x06, 0x05, 0x00, 0x0C, 0x06,
-	0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x05, 0x01, 0x0B, 0x05, 0x05, 0x05,
-	0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
-};
-const byte CURSEYE[] = {
-	0x01, 0x00, 0x08, 0x00, 0x04, 0x06, 0x0E, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x03, 0x09, 0x0E, 0x01,
-	0x01, 0x01, 0x01, 0x01, 0x01, 0x0D, 0x0D, 0x02, 0x0B, 0x0E, 0x01, 0x33, 0x33, 0x01, 0x01, 0x33,
-	0x34, 0x01, 0x01, 0x0D, 0x01, 0x0D, 0x0E, 0x01, 0x04, 0x34, 0x01, 0x01, 0x01, 0x07, 0x33, 0x04,
-	0x04, 0x01, 0x0D, 0x00, 0x0F, 0x0E, 0x0E, 0x01, 0x07, 0x33, 0x33, 0x01, 0x01, 0x33, 0x34, 0x07,
-	0x07, 0x06, 0x01, 0x0E, 0x01, 0x0D, 0x0F, 0x0F, 0x06, 0x07, 0x34, 0x33, 0x33, 0x34, 0x07, 0x07,
-	0x06, 0x0F, 0x0E, 0x03, 0x09, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0E, 0x01, 0x01,
-	0x07, 0x00, 0x03, 0x07, 0x01, 0x07, 0x01, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00
-};
-const byte CURSHAND[] = {
-	0x02, 0x00, 0x03, 0x00, 0x07, 0x02, 0x17, 0x0E, 0x05, 0x07, 0x0E, 0x12, 0x17, 0x0E, 0x13, 0x17,
-	0x0E, 0x02, 0x0C, 0x07, 0x00, 0x17, 0x0E, 0x11, 0x0F, 0x0E, 0x11, 0x17, 0x0E, 0x00, 0x17, 0x01,
-	0x0E, 0x07, 0x01, 0x07, 0x0F, 0x0E, 0x11, 0x17, 0x0E, 0x11, 0x0F, 0x0E, 0x12, 0x17, 0x0E, 0x02,
-	0x0D, 0x07, 0x00, 0x17, 0x0F, 0x12, 0x0F, 0x0F, 0x11, 0x17, 0x0E, 0x12, 0x0F, 0x0E, 0x04, 0x0B,
-	0x0F, 0x0E, 0x11, 0x17, 0x0E, 0x12, 0x0F, 0x0F, 0x11, 0x17, 0x0E, 0x04, 0x0B, 0x17, 0x0E, 0x12,
-	0x17, 0x0E, 0x12, 0x17, 0x0E, 0x11, 0x0F, 0x0E, 0x00, 0x0F, 0x0E, 0x0D, 0x12, 0x00, 0x17, 0x0F,
-	0x0F, 0x0F, 0x0F, 0x12, 0x0F, 0x0E, 0x12, 0x17, 0x0F, 0x00, 0x0F, 0x0F, 0x17, 0x0D, 0x11, 0x0F,
-	0x0E, 0x0D, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0E, 0x0D, 0x01, 0x0E, 0x0F, 0x17, 0x0F, 0x0E,
-	0x0F, 0x0D, 0x0D, 0x0D, 0x0D, 0x0E, 0x0F, 0x0F, 0x0E, 0x0D, 0x02, 0x0D, 0x0F, 0x17, 0x0F, 0x0E,
-	0x0D, 0x0D, 0x0F, 0x0F, 0x0E, 0x0F, 0x0E, 0x0E, 0x12, 0x03, 0x0C, 0x0F, 0x17, 0x0F, 0x0F, 0x0F,
-	0x0E, 0x0F, 0x0F, 0x0F, 0x0E, 0x0D, 0x12, 0x04, 0x0A, 0x0F, 0x17, 0x0F, 0x0F, 0x0F, 0x0E, 0x0F,
-	0x0F, 0x0E, 0x0D, 0x05, 0x09, 0x0F, 0x17, 0x0F, 0x0F, 0x0F, 0x0F, 0x0E, 0x0D, 0x12, 0x06, 0x08,
-	0x17, 0x0F, 0x0F, 0x0F, 0x0F, 0x0E, 0x0D, 0x12, 0x06, 0x07, 0x17, 0x0F, 0x0F, 0x0F, 0x3D, 0x0E,
-	0x0D
-};
-const byte CURSGET[] = {
-	0x07, 0x00, 0x0E, 0x00, 0x0A, 0x05, 0x1C, 0x07, 0x0F, 0x0F, 0x0F, 0x08, 0x08, 0x1C, 0x07, 0x0F,
-	0x0F, 0x0F, 0x0F, 0x0F, 0x0C, 0x06, 0x0A, 0x1C, 0x07, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F,
-	0x0C, 0x05, 0x0A, 0x07, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0C, 0x03, 0x0C, 0x07,
-	0x1C, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0C, 0x02, 0x0D, 0x1C, 0x0F, 0x0E,
-	0x0E, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0C, 0x01, 0x0E, 0x07, 0x0F, 0x0E, 0x0D,
-	0x0F, 0x0E, 0x0D, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0C, 0x00, 0x0F, 0x1C, 0x0F, 0x0E, 0x0D,
-	0x0F, 0x0E, 0x0D, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0C, 0x00, 0x0F, 0x1C, 0x0E, 0x0D,
-	0x0F, 0x0E, 0x0D, 0x0F, 0x0F, 0x0C, 0x0C, 0x0E, 0x0F, 0x0F, 0x0F, 0x0C, 0x00, 0x0E, 0x1C, 0x0D,
-	0x0F, 0x0E, 0x0D, 0x0F, 0x0F, 0x0C, 0x00, 0x00, 0x0E, 0x0F, 0x0F, 0x0C, 0x00, 0x0E, 0x1C, 0x0E,
-	0x0F, 0x0D, 0x0F, 0x0F, 0x0C, 0x00, 0x00, 0x0E, 0x1C, 0x0F, 0x0F, 0x0C, 0x00, 0x0D, 0x1C, 0x0D,
-	0x0F, 0x0D, 0x0F, 0x0C, 0x00, 0x00, 0x00, 0x0E, 0x1C, 0x0F, 0x0C, 0x01, 0x0B, 0x0E, 0x0F, 0x0E,
-	0x0F, 0x0C, 0x00, 0x00, 0x0E, 0x07, 0x0F, 0x0C, 0x02, 0x09, 0x0E, 0x0D, 0x0F, 0x0C, 0x00, 0x07,
-	0x0E, 0x0F, 0x0C, 0x03, 0x06, 0x0E, 0x0F, 0x0E, 0x07, 0x01, 0x07, 0x07, 0x01, 0x07
-};
-const byte CURSCLIMB[] = {
-	0x03, 0x00, 0x0E, 0x00, 0x06, 0x04, 0x01, 0x01, 0x01, 0x01, 0x06, 0x04, 0x0F, 0x0E, 0x01, 0x01,
-	0x06, 0x04, 0x0F, 0x0E, 0x0D, 0x01, 0x07, 0x02, 0x0F, 0x0D, 0x00, 0x0C, 0x0F, 0x00, 0x00, 0x00,
-	0x00, 0x13, 0x12, 0x12, 0x12, 0x12, 0x11, 0x11, 0x00, 0x0D, 0x0D, 0x0E, 0x00, 0x00, 0x13, 0x14,
-	0x13, 0x12, 0x12, 0x12, 0x11, 0x11, 0x0E, 0x01, 0x0C, 0x0D, 0x0D, 0x0D, 0x0E, 0x11, 0x13, 0x13,
-	0x12, 0x11, 0x11, 0x0E, 0x0D, 0x02, 0x0C, 0x0E, 0x0E, 0x00, 0x00, 0x00, 0x13, 0x12, 0x11, 0x00,
-	0x00, 0x0E, 0x0D, 0x03, 0x0B, 0x04, 0x04, 0x04, 0x22, 0x21, 0x21, 0x20, 0x00, 0x00, 0x00, 0x0D,
-	0x02, 0x0D, 0x22, 0x04, 0x20, 0x22, 0x04, 0x21, 0x04, 0x20, 0x00, 0x00, 0x00, 0x0E, 0x0E, 0x03,
-	0x07, 0x22, 0x21, 0x20, 0x20, 0x22, 0x04, 0x20, 0x04, 0x06, 0x01, 0x01, 0x00, 0x04, 0x22, 0x20,
-	0x02, 0x09, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x04, 0x20, 0x03, 0x09, 0x07, 0x01, 0x01,
-	0x00, 0x00, 0x00, 0x22, 0x04, 0x20, 0x02, 0x0B, 0x07, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x01, 0x01, 0x20, 0x03, 0x0A, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01
-};
-const byte CURSTALK[] = {
-	0x02, 0x00, 0x0B, 0x00, 0x03, 0x08, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x01, 0x0C,
-	0x06, 0x06, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x06, 0x06, 0x00, 0x0E, 0x06, 0x06,
-	0x06, 0x06, 0x07, 0x06, 0x07, 0x07, 0x06, 0x07, 0x07, 0x06, 0x07, 0x06, 0x00, 0x0F, 0x06, 0x08,
-	0x08, 0x08, 0x06, 0x08, 0x06, 0x06, 0x08, 0x06, 0x06, 0x08, 0x06, 0x08, 0x06, 0x00, 0x0F, 0x06,
-	0x06, 0x08, 0x06, 0x08, 0x06, 0x08, 0x06, 0x08, 0x06, 0x06, 0x08, 0x08, 0x06, 0x06, 0x00, 0x0F,
-	0x06, 0x06, 0x08, 0x06, 0x08, 0x08, 0x08, 0x06, 0x08, 0x06, 0x06, 0x08, 0x06, 0x08, 0x06, 0x01,
-	0x0E, 0x06, 0x08, 0x06, 0x08, 0x06, 0x08, 0x06, 0x08, 0x08, 0x06, 0x08, 0x06, 0x08, 0x06, 0x02,
-	0x0C, 0x06, 0x06, 0x06, 0x07, 0x06, 0x07, 0x06, 0x06, 0x07, 0x06, 0x07, 0x06, 0x04, 0x09, 0x06,
-	0x06, 0x06, 0x07, 0x07, 0x07, 0x07, 0x06, 0x06, 0x07, 0x04, 0x06, 0x07, 0x07, 0x06, 0x02, 0x08,
-	0x07, 0x00, 0x00, 0x06, 0x06, 0x06, 0x06, 0x06, 0x01, 0x06, 0x07, 0x01, 0x07, 0x06, 0x06, 0x06,
-	0x02, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
-};
-const byte CURSHELP[] = {
-	0x02, 0x00, 0x0B, 0x00, 0x04, 0x06, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x02, 0x0A, 0x24, 0x24,
-	0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x20, 0x20, 0x01, 0x0C, 0x24, 0x22, 0x22, 0x22, 0x20, 0x20,
-	0x20, 0x22, 0x22, 0x22, 0x22, 0x20, 0x00, 0x0E, 0x24, 0x22, 0x22, 0x22, 0x20, 0x00, 0x00, 0x00,
-	0x24, 0x22, 0x22, 0x22, 0x22, 0x20, 0x00, 0x0E, 0x24, 0x22, 0x22, 0x22, 0x22, 0x20, 0x00, 0x00,
-	0x00, 0x24, 0x22, 0x22, 0x22, 0x20, 0x00, 0x0E, 0x24, 0x22, 0x22, 0x22, 0x22, 0x20, 0x00, 0x00,
-	0x00, 0x24, 0x22, 0x22, 0x22, 0x20, 0x01, 0x0D, 0x24, 0x20, 0x20, 0x20, 0x00, 0x00, 0x00, 0x24,
-	0x22, 0x22, 0x22, 0x22, 0x20, 0x07, 0x06, 0x24, 0x22, 0x22, 0x22, 0x22, 0x20, 0x05, 0x07, 0x24,
-	0x22, 0x22, 0x22, 0x22, 0x20, 0x20, 0x04, 0x05, 0x24, 0x22, 0x22, 0x22, 0x20, 0x02, 0x07, 0x07,
-	0x00, 0x24, 0x20, 0x20, 0x20, 0x20, 0x01, 0x03, 0x07, 0x01, 0x07, 0x02, 0x07, 0x07, 0x00, 0x00,
-	0x24, 0x24, 0x24, 0x24, 0x04, 0x06, 0x24, 0x22, 0x22, 0x22, 0x22, 0x20, 0x04, 0x06, 0x24, 0x22,
-	0x22, 0x22, 0x22, 0x20, 0x05, 0x04, 0x20, 0x20, 0x20, 0x20
-};
-
-const int TRAVEL_POS[][2] = {
-	{ -1, 0 },
-	{ 228, 117 },
-	{ 28, 98 },
-	{ 161, 140 },
-	{ 130, 139 },
-	{ 884, 95 },
-	{ 0, 0 },
-	{ 0, 0 },
-	{ 0, 0 },
-	{ 41, 185 },
-	{ 60, 138 },
-	{ 0, 0 },
-	{ 0, 0 },
-	{ 0, 0 },
-	{ 0, 0 },
-	{ 0, 0 },
-	{ 170, 155 },
-	{ 0, 0 },
-	{ 0, 0 },
-	{ 0, 0 },
-	{ 108, 95 },
-	{ 0, 0 },
-	{ 0, 0 },
-	{ 0, 0 },
-	{ 100, 115 },
-	{ 480, 90 },
-	{ 154, 63 },
-	{ 0, 0 },
-	{ 145, 85 },
-	{ 0, 0 },
-	{ 110, 107 },
-	{ 0, 0 },
-	{ 105, 154 },
-	{ 0, 0 },
-	{ 0, 0 },
-	{ 0, 0 },
-	{ 0, 0 },
-	{ 20, 160 },
-	{ 130, 314 },
-	{ 0, 0 },
-	{ 50, 125 },
-	{ 0, 0 },
-	{ 0, 0 },
-	{ 123, 123 },
-	{ -1, 7 },
-	{ 266, 168 },
-	{ 0, 0 },
-	{ 0, 0 },
-	{ 0, 0 },
-	{ -1, 18 },
-	{ -1, 19 },
-	{ 0, 0 },
-	{ 0, 0 },
-	{ 0, 0 },
-	{ 0, 0 },
-	{ 0, 0 },
-	{ 203, 160 },
-	{ 0, 0 },
-	{ 283, 163 },
-	{ 0, 0 },
-	{ 0, 0 },
-	{ 0, 0 },
-	{ 180, 165 },
-	{ 0, 0 },
-	{ 0, 0 },
-	{ 0, 0 }
-};
-
-} // End of namespace Amazon
-
 } // End of namespace Access
diff --git a/engines/access/resources.h b/engines/access/resources.h
index e730881..47d4e3a 100644
--- a/engines/access/resources.h
+++ b/engines/access/resources.h
@@ -29,27 +29,6 @@ namespace Access {
 
 extern const byte INITIAL_PALETTE[18 * 3];
 
-namespace Amazon {
-
-extern const char *const FILENAMES[];
-
-extern const byte MOUSE0[];
-extern const byte MOUSE1[];
-extern const byte MOUSE2[];
-extern const byte MOUSE3[];
-extern const byte CURSEYE[];
-extern const byte CURSHAND[];
-extern const byte CURSGET[];
-extern const byte CURSCLIMB[];
-extern const byte CURSTALK[];
-extern const byte CURSHELP[];
-
-extern const byte *CURSORS[10];
-
-extern const int TRAVEL_POS[][2];
-
-} // End of namespace Amazon
-
 } // End of namespace Access
 
-#endif /* ACCESS_EVENTS_H */
+#endif /* ACCESS_RESOURCES_H */
diff --git a/engines/access/room.cpp b/engines/access/room.cpp
index 0515b50..f735fdb 100644
--- a/engines/access/room.cpp
+++ b/engines/access/room.cpp
@@ -22,6 +22,7 @@
 
 #include "common/scummsys.h"
 #include "access/access.h"
+#include "access/resources.h"
 #include "access/room.h"
 
 namespace Access {


Commit: 3645aad6fb02e0430c4ff3b325e1c0012042f4b7
    https://github.com/scummvm/scummvm/commit/3645aad6fb02e0430c4ff3b325e1c0012042f4b7
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-06T20:19:15-04:00

Commit Message:
ACCESS: Add Amazon character and room resource lists

Changed paths:
    engines/access/amazon/amazon_resources.cpp
    engines/access/amazon/amazon_resources.h



diff --git a/engines/access/amazon/amazon_resources.cpp b/engines/access/amazon/amazon_resources.cpp
index 4d798db..2f9fe02 100644
--- a/engines/access/amazon/amazon_resources.cpp
+++ b/engines/access/amazon/amazon_resources.cpp
@@ -245,6 +245,747 @@ const int TRAVEL_POS[][2] = {
 	{ 0, 0 }
 };
 
+const byte CREDITS[] = {
+	0x2, 0xFF, 0xFF, 0x61, 0x0, 0x3, 0x0, 0x30, 0x22, 0x30, 0x0, 0x0, 0x0,
+	0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0xFF, 0xFF, 0xFF, 0x0, 0x0, 0xFF, 0xFF,
+	0x0, 0x0, 0xFF, 0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF
+};
+
+const byte ALLISTER[] = {
+	0x0, 0xFF, 0xFF, 0x61, 0x0, 0x0, 0x0, 0x36, 0x0F, 0x5E, 0x4, 0x0, 0x0,
+	0x0, 0x4, 0x4, 0x0, 0x3, 0x0, 0xFF, 0x4, 0x0, 0x2, 0x0, 0x4, 0x0, 0x1, 0x0, 0x8C,
+	0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x62, 0x0, 0x0, 0x0,
+	0x1, 0x0, 0x62, 0x0, 0x0B, 0x0, 0x1, 0x0, 0x62, 0x0, 0x0C, 0x0, 0x1, 0x0, 0x62,
+	0x0, 0x0D, 0x0, 0x1, 0x0, 0xFF, 0xFF
+};
+
+const byte HALL[] = {
+	0x0, 0xFF, 0xFF, 0x61, 0x0, 0x0, 0x0, 0x40, 0x3E, 0x1A, 0x5, 0x0, 0x0,
+	0x0, 0x5, 0x5, 0x0, 0x3, 0x0, 0xFF, 0x5, 0x0, 0x2, 0x0, 0x5, 0x0, 0x1, 0x0, 0xFF,
+	0x30, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x62, 0x0, 0x0,
+	0x0, 0x2, 0x0, 0x62, 0x0, 0x0D, 0x0, 0x1, 0x0, 0x62, 0x0, 0x13, 0x0, 0x1, 0x0,
+	0x62, 0x0, 0x14, 0x0, 0x2, 0x0, 0x62, 0x0, 0x4, 0x0, 0x1, 0x0, 0xFF, 0xFF
+};
+
+const byte JASONLAB[] = {
+	0x1, 0x6, 0x0, 0x61, 0x0, 0x0D, 0x0, 0x40, 0x20, 0x0C4, 0x6, 0x0, 0x0, 0x0,
+	0x6, 0x6, 0x0, 0x3, 0x0, 0xFF, 0x6, 0x0, 0x2, 0x0, 0x6, 0x0, 0x1, 0x0, 0xFF, 0x0,
+	0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x62, 0x0, 0x0, 0x0, 0x1,
+	0x0, 0x62, 0x0, 0x1, 0x0, 0x1, 0x0, 0x62, 0x0, 0x2, 0x0, 0x1, 0x0, 0x62, 0x0, 0x3,
+	0x0, 0x2, 0x0, 0x62, 0x0, 0x26, 0x0, 0x1, 0x0, 0x62, 0x0, 0x0D, 0x0, 0x1, 0x0,
+	0x62, 0x0, 0x35, 0x0, 0x2, 0x0, 0xFF, 0xFF
+};
+
+const byte ALLENLAB[] = {
+	0x1, 0x8, 0x0, 0x61, 0x0, 0x0D, 0x0, 0x40, 0x20, 0x0C4, 0x8, 0x0, 0x0, 0x0,
+	0x8, 0x8, 0x0, 0x3, 0x0, 0xFF, 0x8, 0x0, 0x2, 0x0, 0x8, 0x0, 0x1, 0x0, 0xFF, 0x0,
+	0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x62, 0x0, 0x0, 0x0, 0x1,
+	0x0, 0x62, 0x0, 0x7, 0x0, 0x1, 0x0, 0x62, 0x0, 0x8, 0x0, 0x2, 0x0, 0x62, 0x0, 0x9,
+	0x0, 0x1, 0x0, 0x62, 0x0, 0x0A, 0x0, 0x1, 0x0, 0x62, 0x0, 0x0D, 0x0, 0x1, 0x0,
+	0xFF, 0xFF
+};
+
+const byte OUTVAULT[] = {
+	0x0, 0x9, 0x0, 0x61, 0x0, 0x2B, 0x0, 0x30, 0x18, 0x9B, 0x9, 0x0, 0x0, 0x0,
+	0x9, 0x9, 0x0, 0x3, 0x0, 0xFF, 0x9, 0x0, 0x2, 0x0, 0x9, 0x0, 0x1, 0x0, 0x0B4, 0x10,
+	0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x62, 0x0, 0x0, 0x0, 0x3,
+	0x0, 0x62, 0x0, 0x4, 0x0, 0x1, 0x0, 0x62, 0x0, 0x5, 0x0, 0x2, 0x0, 0x62, 0x0, 0x6,
+	0x0, 0x2, 0x0, 0x62, 0x0, 0x36, 0x0, 0x1, 0x0, 0x62, 0x0, 0x47, 0x0, 0x1, 0x0,
+	0xFF, 0xFF
+};
+
+const byte VAULT[] = {
+	0x0, 0xFF, 0xFF, 0x61, 0x0, 0x29, 0x0, 0x40, 0x3A, 0x37, 0x0A, 0x0,
+	0x0, 0x0, 0x0A, 0x0A, 0x0, 0x3, 0x0, 0xFF, 0x0A, 0x0, 0x2, 0x0, 0x0A, 0x0,
+	0x1, 0x0, 0xFF, 0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x62,
+	0x0, 0x0, 0x0, 0x1, 0x0, 0x62, 0x0, 0x37, 0x0, 0x2, 0x0, 0x62, 0x0, 0x39, 0x0,
+	0x1, 0x0, 0x62, 0x0, 0x38, 0x0, 0x2, 0x0, 0x62, 0x0, 0x15, 0x0, 0x2, 0x0, 0xFF,
+	0xFF
+};
+
+const byte LIBRARY[] = {
+	0x1, 0xFF, 0xFF, 0x61, 0x0, 0x0C, 0x0, 0x40, 0x3A, 0x22, 0x0B, 0x0,
+	0x0, 0x0, 0x0B, 0x0B, 0x0, 0x3, 0x0, 0xFF, 0x0B, 0x0, 0x2, 0x0, 0x0B, 0x0,
+	0x1, 0x0, 0xFF, 0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x62,
+	0x0, 0x0, 0x0, 0x1, 0x0, 0x62, 0x0, 0x1, 0x0, 0x1, 0x0, 0xFF, 0xFF,
+};
+
+const byte JASAPT[] = {
+	0x1, 0x0C, 0x0, 0x61, 0x0, 0x19, 0x0, 0x40, 0x30, 0x14, 0x0C, 0x0, 0x0,
+	0x0, 0x0C, 0x0C, 0x0, 0x3, 0x0, 0xFF, 0x0C, 0x0, 0x2, 0x0, 0x0C, 0x0, 0x1,
+	0x0, 0xFF, 0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x62,
+	0x0, 0x18, 0x0, 0x2, 0x0, 0x62, 0x0, 0x17, 0x0, 0x1, 0x0, 0x62, 0x0, 0x11,
+	0x0, 0x1, 0x0, 0x62, 0x0, 0x0D, 0x0, 0x1, 0x0, 0xFF, 0xFF
+};
+
+const byte RANSACKED[] = {
+	0x1, 0x0D, 0x0, 0x61, 0x0, 0x2D, 0x0, 0x40, 0x36, 0x2C, 0x0D, 0x0, 0x0,
+	0x0, 0x0D, 0x0D, 0x0, 0x3, 0x0, 0xFF, 0x0D, 0x0, 0x2, 0x0, 0x0D, 0x0, 0x1,
+	0x0, 0xFF, 0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x62,
+	0x0, 0x17, 0x0, 0x1, 0x0, 0xFF, 0xFF
+};
+
+const byte MEAN1[] = {
+	0x1, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x40, 0x3E, 0x33,
+	0xFF, 0xFF, 0x0, 0x0, 0xFF, 0x0E, 0x0, 0x5, 0x0, 0x0E, 0x0, 0x4, 0x0,
+	0xFF, 0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF
+};
+
+const byte FLYSOUTH[] = {
+	0x1, 0xFF, 0xFF, 0x61, 0x0, 0x10, 0x0, 0x28, 0x0C, 0x5E, 0x0F, 0x0,
+	0x0, 0x0, 0x0F, 0x0F, 0x0, 0x2, 0x0, 0xFF, 0x0F, 0x0, 0x1, 0x0, 0xFF, 0xFF,
+	0x1, 0x0, 0xFF, 0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x62,
+	0x0, 0x44, 0x0, 0x1, 0x0, 0xFF, 0xFF
+};
+
+const byte CUZCO[] = {
+	0x2, 0x10, 0x0, 0x61, 0x0, 0x10, 0x0, 0x40, 0x20, 0x30, 0x10, 0x0, 0x0,
+	0x0, 0x10, 0x10, 0x0, 0x3, 0x0, 0xFF, 0x10, 0x0, 0x2, 0x0, 0x10, 0x0, 0x1,
+	0x0, 0x6E, 0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x62,
+	0x0, 0x0, 0x0, 0x2, 0x0, 0x62, 0x0, 0x44, 0x0, 0x1, 0x0, 0xFF, 0xFF
+};
+
+const byte INAIR[] = {
+	0x1, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x28, 0x19, 0x2B,
+	0x11, 0x0, 0x0, 0x0, 0x11, 0x11, 0x0, 0x3, 0x0, 0xFF, 0x11, 0x0, 0x2, 0x0,
+	0x11, 0x0, 0x1, 0x0, 0xFF, 0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
+	0xFF, 0xFF, 0xFF
+};
+
+const byte GREENMONKEY[] = {
+	0x1, 0xFF, 0xFF, 0x61, 0x0, 0x11, 0x0, 0x2D, 0x14, 0x3C, 0x12, 0x0,
+	0x0, 0x0, 0x12, 0x12, 0x0, 0x3, 0x0, 0xFF, 0x12, 0x0, 0x2, 0x0, 0x12, 0x0,
+	0x1, 0x0, 0xFF, 0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF
+};
+
+const byte INPLANE[] = {
+	0x2, 0x13, 0x0, 0x61, 0x0, 0x26, 0x0, 0x2D, 0x28, 0x28, 0x13, 0x0, 0x0,
+	0x0, 0x13, 0x13, 0x0, 0x3, 0x0, 0xFF, 0x13, 0x0, 0x2, 0x0, 0x13, 0x0, 0x1,
+	0x0, 0xFF, 0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x62, 0x0, 0x0, 0x0,
+	0x2, 0x0, 0x62, 0x0, 0x29, 0x0, 0x2, 0x0, 0x62, 0x0, 0x1F, 0x0, 0x1, 0x0,
+	0x62, 0x0, 0x38, 0x0, 0x2, 0x0, 0x62, 0x0, 0x33, 0x0, 0x1, 0x0, 0xFF, 0xFF
+};
+
+const byte PILFALL[] = {
+	0x1, 0xFF, 0xFF, 0x61, 0x0, 0x16, 0x0, 0x28, 0x0C, 0x5E, 0x14, 0x0,
+	0x0, 0x0, 0x14, 0x14, 0x0, 0x2, 0x0, 0xFF, 0x14, 0x0, 0x1, 0x0, 0xFF, 0xFF,
+	0x1, 0x0, 0xFF, 0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x62,
+	0x0, 0x3A, 0x0, 0x1, 0x0, 0xFF, 0xFF
+};
+
+const byte COCKPIT[] = {
+	0x1, 0xFF, 0xFF, 0x61, 0x0, 0x12, 0x0, 0x3C, 0x2A, 0x29, 0x15, 0x0,
+	0x0, 0x0, 0x15, 0x15, 0x0, 0x3, 0x0, 0xFF, 0x15, 0x0, 0x2, 0x0, 0x15, 0x0,
+	0x1, 0x0, 0xFF, 0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x62,
+	0x0, 0x23, 0x0, 0x1, 0x0, 0xFF, 0xFF
+};
+
+const byte CRASH[] = {
+	0x1, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x40, 0x2D, 0x64,
+	0x16, 0x0, 0x0, 0x0, 0xFF, 0x16, 0x0, 0x1, 0x0, 0xFF, 0xFF, 0x0, 0x0,
+	0xFF, 0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0x16, 0x0, 0x2, 0x0, 0xFF,
+	0xFF, 0x62, 0x0, 0x2A, 0x0, 0x1, 0x0, 0xFF, 0xFF
+};
+
+const byte SINKING[] = {
+	0x2, 0xFF, 0xFF, 0x61, 0x0, 0x14, 0x0, 0x40, 0x3C, 0x19, 0x17, 0x0,
+	0x0, 0x0, 0x17, 0x17, 0x0, 0x3, 0x0, 0xFF, 0x17, 0x0, 0x2, 0x0, 0x17, 0x0,
+	0x1, 0x0, 0xFF, 0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x62,
+	0x0, 0x0, 0x0, 0x1, 0x0, 0x62, 0x0, 0x48, 0x0, 0x1, 0x0, 0x62, 0x0, 0x17, 0x0,
+	0x1, 0x0, 0xFF, 0xFF
+};
+
+const byte JNGLWLK[] = {
+	0x2, 0xFF, 0xFF, 0x61, 0x0, 0x17, 0x0, 0x40, 0x3F, 0x5A, 0x18, 0x0,
+	0x0, 0x0, 0x18, 0x18, 0x0, 0x2, 0x0, 0xFF, 0x18, 0x0, 0x1, 0x0, 0xFF, 0xFF,
+	0x0, 0x0, 0x0DC, 0x0A0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
+	0x62, 0x0, 0x0, 0x0, 0x1, 0x0, 0xFF, 0xFF
+};
+
+const byte TOWN[] = {
+	0x2, 0x19, 0x0, 0x61, 0x0, 0x18, 0x0, 0x3E, 0x32, 0x80, 0x19, 0x0, 0x0,
+	0x0, 0x19, 0x19, 0x0, 0x3, 0x0, 0xFF, 0x19, 0x0, 0x2, 0x0, 0x19, 0x0, 0x1,
+	0x0, 0x64, 0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x62,
+	0x0, 0x0, 0x0, 0x1, 0x0, 0x62, 0x0, 0x3D, 0x0, 0x1, 0x0, 0x62, 0x0, 0x3B, 0x0,
+	0x2, 0x0, 0xFF, 0xFF
+};
+
+const byte HOTEL[] = {
+	0x1, 0xFF, 0xFF, 0x61, 0x0, 0x19, 0x0, 0x34, 0x28, 0x28, 0x1A, 0x0,
+	0x0, 0x0, 0x1A, 0x1A, 0x0, 0x3, 0x0, 0xFF, 0x1A, 0x0, 0x2, 0x0, 0x1A, 0x0,
+	0x1, 0x0, 0xFF, 0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x62,
+	0x0, 0x28, 0x0, 0x1, 0x0, 0x62, 0x0, 0x2B, 0x0, 0x1, 0x0, 0x62, 0x0, 0x46,
+	0x0, 0x2, 0x0, 0x62, 0x0, 0x45, 0x0, 0x1, 0x0, 0x62, 0x0, 0x0E, 0x0, 0x1, 0x0,
+	0xFF, 0xFF
+};
+
+const byte CANTINA[] = {
+	0x2, 0xFF, 0xFF, 0x61, 0x0, 0x27, 0x0, 0x40, 0x3A, 0x6C, 0x1B, 0x0,
+	0x0, 0x0, 0x1B, 0x1B, 0x0, 0x3, 0x0, 0xFF, 0x1B, 0x0, 0x2, 0x0, 0x1B, 0x0,
+	0x1, 0x0, 0x0C8, 0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x62,
+	0x0, 0x0, 0x0, 0x1, 0x0, 0xFF, 0xFF
+};
+
+const byte MASSACRE[] = {
+	0x2, 0x1D, 0x0, 0x61, 0x0, 0x32, 0x0, 0x20, 0x18, 0x73, 0x1D, 0x0, 0x0,
+	0x0, 0x1D, 0x1D, 0x0, 0x3, 0x0, 0xFF, 0x1D, 0x0, 0x2, 0x0, 0x1D, 0x0, 0x1,
+	0x0, 0x96, 0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x62,
+	0x0, 0x0, 0x0, 0x1, 0x0, 0x62, 0x0, 0x0C, 0x0, 0x1, 0x0, 0x62, 0x0, 0x3, 0x0, 0x2,
+	0x0, 0x62, 0x0, 0x49, 0x0, 0x2, 0x0, 0x62, 0x0, 0x4A, 0x0, 0x2, 0x0, 0xFF, 0xFF
+};
+
+const byte TRADE[] = {
+	0x1, 0xFF, 0xFF, 0x61, 0x0, 0x18, 0x0, 0x3F, 0x1C, 0x27, 0x1E, 0x0,
+	0x0, 0x0, 0x1E, 0x1E, 0x0, 0x3, 0x0, 0xFF, 0x1E, 0x0, 0x2, 0x0, 0x1E, 0x0,
+	0x1, 0x0, 0xFF, 0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF
+};
+
+const byte BRIDGE[] = {
+	0x2, 0x1F, 0x0, 0x61, 0x0, 0x1B, 0x0, 0x40, 0x3F, 0x78, 0x1F, 0x0, 0x0,
+	0x0, 0x1F, 0x1F, 0x0, 0x3, 0x0, 0xFF, 0x1F, 0x0, 0x2, 0x0, 0x1F, 0x0, 0x1,
+	0x0, 0xFF, 0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x62,
+	0x0, 0x0, 0x0, 0x2, 0x0, 0x62, 0x0, 0x1F, 0x0, 0x1, 0x0, 0xFF, 0xFF
+};
+
+const byte DOCK[] = {
+	0x1, 0xFF, 0xFF, 0x61, 0x0, 0x1E, 0x0, 0x40, 0x3B, 0x4B, 0x20, 0x0,
+	0x0, 0x0, 0xFF, 0x20, 0x0, 0x1, 0x0, 0xFF, 0xFF, 0x1, 0x0, 0xFF, 0x0,
+	0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF
+};
+
+const byte DRIVER[] = {
+	0x1, 0x21, 0x0, 0x61, 0x0, 0x28, 0x0, 0x30, 0x10, 0x51, 0x21, 0x0, 0x0,
+	0x0, 0x21, 0x21, 0x0, 0x2, 0x0, 0xFF, 0x21, 0x0, 0x1, 0x0, 0xFF, 0xFF,
+	0x0, 0x0, 0xFF, 0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x62,
+	0x0, 0x2E, 0x0, 0x1, 0x0, 0x62, 0x0, 0x2F, 0x0, 0x1, 0x0, 0xFF, 0xFF
+};
+
+const byte SHORE[] = {
+	0x2, 0x24, 0x0, 0x61, 0x0, 0x4, 0x0, 0x3E, 0x3A, 0x32, 0x24, 0x0, 0x0, 0x0,
+	0x24, 0x24, 0x0, 0x3, 0x0, 0xFF, 0x24, 0x0, 0x2, 0x0, 0x24, 0x0, 0x1, 0x0,
+	0x0B4, 0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x62, 0x0,
+	0x2D, 0x0, 0x2, 0x0, 0x62, 0x0, 0x1F, 0x0, 0x1, 0x0, 0x62, 0x0, 0x2E, 0x0,
+	0x1, 0x0, 0x62, 0x0, 0x2F, 0x0, 0x1, 0x0, 0xFF, 0xFF
+};
+
+const byte BOAT[] = {
+	0x3, 0xFF, 0xFF, 0x61, 0x0, 0x8, 0x0, 0x3F, 0x3F, 0xFF, 0x25, 0x0,
+	0x0, 0x0, 0x25, 0x25, 0x0, 0x3, 0x0, 0xFF, 0x25, 0x0, 0x2, 0x0, 0x25, 0x0,
+	0x1, 0x0, 0xFF, 0x40, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
+	0x62, 0x0, 0x0, 0x0, 0x2, 0x0, 0x62, 0x0, 0x21, 0x0, 0x1, 0x0, 0x62, 0x0, 0x25,
+	0x0, 0x1, 0x0, 0x62, 0x0, 0x1F, 0x0, 0x1, 0x0, 0x62, 0x0, 0x30, 0x0, 0x1, 0x0,
+	0x62, 0x0, 0x32, 0x0, 0x1, 0x0, 0xFF, 0xFF
+};
+
+const byte CABIN[] = {
+	0x1, 0xFF, 0xFF, 0x61, 0x0, 0x8, 0x0, 0x40, 0x32, 0x50, 0x26, 0x0,
+	0x0, 0x0, 0x26, 0x26, 0x0, 0x3, 0x0, 0xFF, 0x26, 0x0, 0x2, 0x0, 0x26, 0x0,
+	0x1, 0x0, 0xFF, 0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x62,
+	0x0, 0x0, 0x0, 0x1, 0x0, 0x62, 0x0, 0x22, 0x0, 0x2, 0x0, 0x62, 0x0, 0x31, 0x0,
+	0x1, 0x0, 0xFF, 0xFF
+};
+
+const byte CAPTIVE[] = {
+	0x2, 0x27, 0x0, 0x61, 0x0, 0x9, 0x0, 0x40, 0x3F, 0x37, 0x27, 0x0, 0x0, 0x0,
+	0x27, 0x27, 0x0, 0x3, 0x0, 0xFF, 0x27, 0x0, 0x2, 0x0, 0x27, 0x0, 0x1, 0x0,
+	0xFF, 0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x62, 0x0,
+	0x0, 0x0, 0x4, 0x0, 0x62, 0x0, 0x1B, 0x0, 0x3, 0x0, 0x62, 0x0, 0x1C, 0x0, 0x1,
+	0x0, 0x62, 0x0, 0x1F, 0x0, 0x2, 0x0, 0x62, 0x0, 0x23, 0x0, 0x1, 0x0, 0x62,
+	0x0, 0x32, 0x0, 0x1, 0x0, 0x62, 0x0, 0x33, 0x0, 0x1, 0x0, 0xFF, 0xFF
+};
+
+const byte VILLAGE[] = {
+	0x2, 0x2A, 0x0, 0x61, 0x0, 0x2E, 0x0, 0x1E, 0x1B, 0x6E, 0x2A, 0x0, 0x0,
+	0x0, 0x2A, 0x2A, 0x0, 0x3, 0x0, 0xFF, 0x2A, 0x0, 0x2, 0x0, 0x2A, 0x0, 0x1,
+	0x0, 0x0A5, 0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x62,
+	0x0, 0x2D, 0x0, 0x3, 0x0, 0x62, 0x0, 0x3F, 0x0, 0x1, 0x0, 0x62, 0x0, 0x40,
+	0x0, 0x2, 0x0, 0xFF, 0xFF
+};
+
+const byte TREE[] = {
+	0x2, 0x2C, 0x0, 0x61, 0x0, 0x31, 0x0, 0x1E, 0x1D, 0x0BE, 0x2C, 0x0, 0x0,
+	0x0, 0x2C, 0x2C, 0x0, 0x3, 0x0, 0xFF, 0x2C, 0x0, 0x2, 0x0, 0x2C, 0x0, 0x1,
+	0x0, 0x50, 0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x62,
+	0x0, 0x0, 0x0, 0x2, 0x0, 0x62, 0x0, 0x2E, 0x0, 0x1, 0x0, 0x62, 0x0, 0x2F, 0x0,
+	0x1, 0x0, 0x62, 0x0, 0x4, 0x0, 0x1, 0x0, 0x62, 0x0, 0x42, 0x0, 0x1, 0x0, 0xFF,
+	0xFF
+};
+
+const byte CANOE[] = {
+	0x1, 0x2D, 0x0, 0x61, 0x0, 0x2F, 0x0, 0x1E, 0x1D, 0x78, 0x2D, 0x0, 0x0,
+	0x0, 0x2D, 0x2D, 0x0, 0x3, 0x0, 0xFF, 0x2D, 0x0, 0x2, 0x0, 0x2D, 0x0, 0x1,
+	0x0, 0xFF, 0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x62,
+	0x0, 0x40, 0x0, 0x3, 0x0, 0x62, 0x0, 0x41, 0x0, 0x2, 0x0, 0x62, 0x0, 0x2E,
+	0x0, 0x2, 0x0, 0x62, 0x0, 0x2F, 0x0, 0x2, 0x0, 0x62, 0x0, 0x16, 0x0, 0x1, 0x0,
+	0xFF, 0xFF
+};
+
+const byte INTREE[] = {
+	0x1, 0xFF, 0xFF, 0x61, 0x0, 0x33, 0x0, 0x28, 0x1E, 0x32, 0x2E, 0x0,
+	0x0, 0x0, 0x2E, 0x2E, 0x0, 0x3, 0x0, 0xFF, 0x2E, 0x0, 0x2, 0x0, 0x2E, 0x0,
+	0x1, 0x0, 0x0F0, 0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF
+};
+
+const byte FALLS[] = {
+	0x1, 0xFF, 0xFF, 0x61, 0x0, 0x3B, 0x0, 0x28, 0x1E, 0x32, 0x2F, 0x0,
+	0x0, 0x0, 0x2F, 0x2F, 0x0, 0x3, 0x0, 0xFF, 0x2F, 0x0, 0x2, 0x0, 0x2F, 0x0,
+	0x1, 0x0, 0xFF, 0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x62,
+	0x0, 0x4, 0x0, 0x1, 0x0, 0x62, 0x0, 0x2A, 0x0, 0x1, 0x0, 0xFF, 0xFF
+};
+
+const byte WATERFALL[] = {
+	0x1, 0x36, 0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0x28, 0x1E, 0x6E, 0x36,
+	0x0, 0x0, 0x0, 0x36, 0x36, 0x0, 0x3, 0x0, 0xFF, 0x36, 0x0, 0x2, 0x0, 0x36,
+	0x0, 0x1, 0x0, 0xFF, 0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0x36, 0x0, 0x4,
+	0x0, 0xFF, 0xFF, 0x62, 0x0, 0x1F, 0x0, 0x1, 0x0, 0xFF, 0xFF
+};
+
+const byte INWATER[] = {
+	0x2, 0xFF, 0xFF, 0x61, 0x0, 0x36, 0x0, 0x40, 0x3F, 0x2A, 0x37, 0x0,
+	0x0, 0x0, 0x37, 0x37, 0x0, 0x3, 0x0, 0xFF, 0x37, 0x0, 0x2, 0x0, 0x37, 0x0,
+	0x1, 0x0, 0xFF, 0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x62,
+	0x0, 0x0, 0x0, 0x1, 0x0, 0x62, 0x0, 0x38, 0x0, 0x1, 0x0, 0xFF, 0xFF
+};
+
+const byte CAVE[] = {
+	0x2, 0x39, 0x0, 0x61, 0x0, 0x37, 0x0, 0x32, 0x14, 0x73, 0x39, 0x0, 0x0,
+	0x0, 0x39, 0x39, 0x0, 0x3, 0x0, 0xFF, 0x39, 0x0, 0x2, 0x0, 0x39, 0x0, 0x1,
+	0x0, 0x0B4, 0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x62,
+	0x0, 0x0, 0x0, 0x1, 0x0, 0x62, 0x0, 0x1F, 0x0, 0x1, 0x0, 0x62, 0x0, 0x4B, 0x0,
+	0x2, 0x0, 0x62, 0x0, 0x4C, 0x0, 0x2, 0x0, 0xFF, 0xFF
+};
+
+const byte PIT[] = {
+	0x2, 0xFF, 0xFF, 0x61, 0x0, 0x38, 0x0, 0x41, 0x3F, 0x19, 0x3D, 0x0,
+	0x0, 0x0, 0x3D, 0x3D, 0x0, 0x3, 0x0, 0x3E, 0x3D, 0x0, 0x4, 0x0, 0xFF, 0x3D,
+	0x0, 0x2, 0x0, 0x3D, 0x0, 0x1, 0x0, 0x0BE, 0x0, 0xFF, 0xFF, 0xFF, 0xFF,
+	0xFF, 0xFF, 0x62, 0x0, 0x0, 0x0, 0x2, 0x0, 0x62, 0x0, 0x27, 0x0, 0x1, 0x0,
+	0x62, 0x0, 0x4D, 0x0, 0x2, 0x0, 0xFF, 0xFF, 0x0
+};
+
+const byte *ROOM_TABLE[] = {
+	CREDITS, nullptr, nullptr, nullptr, ALLISTER, HALL, JASONLAB, nullptr,
+	ALLENLAB, OUTVAULT, VAULT, LIBRARY, JASAPT, RANSACKED, MEAN1, FLYSOUTH,
+	CUZCO, INAIR, GREENMONKEY, INPLANE, PILFALL, COCKPIT, CRASH, SINKING,
+	JNGLWLK, TOWN, HOTEL, CANTINA, nullptr, MASSACRE, TRADE, BRIDGE, DOCK,
+	DRIVER, nullptr, nullptr, SHORE, BOAT, CABIN, CAPTIVE, nullptr,
+	nullptr, VILLAGE, nullptr, TREE, CANOE, INTREE, FALLS, nullptr,
+	nullptr, nullptr, nullptr, nullptr, nullptr, WATERFALL, INWATER, nullptr,
+	CAVE, nullptr, nullptr, nullptr, PIT, nullptr, nullptr
+};
+
+const byte ELAINE[] = {
+	0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
+	0xFF, 0x0, 0x0, 0x0, 0x0, 0x41, 0x41, 0x0, 0x1, 0x0, 0xFF, 0x41, 0x0, 0x2,
+	0x0, 0x41, 0x0, 0x0, 0x0, 0x41, 0x0, 0x3, 0x0, 0x41, 0x0, 0x25, 0x0, 0x41,
+	0x0, 0x4, 0x0, 0x41, 0x0, 0x26, 0x0, 0x41, 0x0, 0x5, 0x0, 0x41, 0x0, 0x27,
+	0x0, 0x41, 0x0, 0x6, 0x0, 0x41, 0x0, 0x28, 0x0, 0x41, 0x0, 0x7, 0x0, 0x41,
+	0x0, 0x29, 0x0, 0x41, 0x0, 0x8, 0x0, 0x41, 0x0, 0x2A, 0x0, 0x41, 0x0, 0x9,
+	0x0, 0x41, 0x0, 0x2B, 0x0, 0x41, 0x0, 0x0A, 0x0, 0x41, 0x0, 0x2C, 0x0, 0x41,
+	0x0, 0x0B, 0x0, 0x41, 0x0, 0x2D, 0x0, 0x41, 0x0, 0x0C, 0x0, 0x41, 0x0, 0x2E,
+	0x0, 0x41, 0x0, 0x0D, 0x0, 0x41, 0x0, 0x2F, 0x0, 0x41, 0x0, 0x0E, 0x0, 0x41,
+	0x0, 0x30, 0x0, 0x41, 0x0, 0x0F, 0x0, 0x41, 0x0, 0x31, 0x0, 0x41, 0x0, 0x10,
+	0x0, 0x41, 0x0, 0x32, 0x0, 0x41, 0x0, 0x11, 0x0, 0x41, 0x0, 0x33, 0x0, 0x41,
+	0x0, 0x12, 0x0, 0x41, 0x0, 0x34, 0x0, 0x41, 0x0, 0x13, 0x0, 0x41, 0x0, 0x35,
+	0x0, 0x41, 0x0, 0x14, 0x0, 0x41, 0x0, 0x36, 0x0, 0x41, 0x0, 0x15, 0x0, 0x41,
+	0x0, 0x37, 0x0, 0x41, 0x0, 0x16, 0x0, 0x41, 0x0, 0x38, 0x0, 0x41, 0x0, 0x17,
+	0x0, 0x41, 0x0, 0x39, 0x0, 0x41, 0x0, 0x18, 0x0, 0x41, 0x0, 0x3A, 0x0, 0x41,
+	0x0, 0x19, 0x0, 0x41, 0x0, 0x3B, 0x0, 0x41, 0x0, 0x1A, 0x0, 0x41, 0x0, 0x3C,
+	0x0, 0x41, 0x0, 0x1B, 0x0, 0x41, 0x0, 0x3D, 0x0, 0x41, 0x0, 0x1C, 0x0, 0x41,
+	0x0, 0x3E, 0x0, 0x41, 0x0, 0x1D, 0x0, 0x41, 0x0, 0x3F, 0x0, 0x41, 0x0, 0x1E,
+	0x0, 0x41, 0x0, 0x40, 0x0, 0x41, 0x0, 0x1F, 0x0, 0x41, 0x0, 0x41, 0x0, 0x41,
+	0x0, 0x20, 0x0, 0x41, 0x0, 0x42, 0x0, 0x41, 0x0, 0x21, 0x0, 0x41, 0x0, 0x43,
+	0x0, 0x41, 0x0, 0x22, 0x0, 0x41, 0x0, 0x44, 0x0, 0x41, 0x0, 0x23, 0x0, 0x41,
+	0x0, 0x45, 0x0, 0x41, 0x0, 0x24, 0x0, 0x41, 0x0, 0x46, 0x0, 0xFF, 0xFF
+};
+
+const byte LIB[] = {
+	0x1, 0xFF, 0xFF, 0x42, 0x0, 0x2, 0x0, 0xFF, 0xFF, 0xFF, 0xFF,
+	0x0, 0x0, 0x0, 0x0, 0x42, 0x42, 0x0, 0x1, 0x0, 0xFF, 0xFF, 0xFF, 0x2,
+	0x0, 0x42, 0x0, 0x0, 0x0, 0x42, 0x0, 0x3, 0x0, 0x42, 0x0, 0x18, 0x0, 0x42,
+	0x0, 0x4, 0x0, 0x42, 0x0, 0x19, 0x0, 0x42, 0x0, 0x5, 0x0, 0x42, 0x0, 0x1A,
+	0x0, 0x42, 0x0, 0x6, 0x0, 0x42, 0x0, 0x1B, 0x0, 0x42, 0x0, 0x7, 0x0, 0x42,
+	0x0, 0x1C, 0x0, 0x42, 0x0, 0x8, 0x0, 0x42, 0x0, 0x1D, 0x0, 0x42, 0x0, 0x9,
+	0x0, 0x42, 0x0, 0x1E, 0x0, 0x42, 0x0, 0x0A, 0x0, 0x42, 0x0, 0x1F, 0x0, 0x42,
+	0x0, 0x0B, 0x0, 0x42, 0x0, 0x20, 0x0, 0x42, 0x0, 0x0C, 0x0, 0x42, 0x0, 0x21,
+	0x0, 0x42, 0x0, 0x0D, 0x0, 0x42, 0x0, 0x22, 0x0, 0x42, 0x0, 0x0E, 0x0, 0x42,
+	0x0, 0x23, 0x0, 0x42, 0x0, 0x0F, 0x0, 0x42, 0x0, 0x24, 0x0, 0x42, 0x0, 0x10,
+	0x0, 0x42, 0x0, 0x25, 0x0, 0x42, 0x0, 0x11, 0x0, 0x42, 0x0, 0x26, 0x0, 0x42,
+	0x0, 0x12, 0x0, 0x42, 0x0, 0x27, 0x0, 0x42, 0x0, 0x13, 0x0, 0x42, 0x0, 0x28,
+	0x0, 0x42, 0x0, 0x14, 0x0, 0x42, 0x0, 0x29, 0x0, 0x42, 0x0, 0x15, 0x0, 0x42,
+	0x0, 0x2A, 0x0, 0x42, 0x0, 0x16, 0x0, 0x42, 0x0, 0x2B, 0x0, 0x42, 0x0, 0x17,
+	0x0, 0x42, 0x0, 0x2C, 0x0, 0xFF, 0xFF
+};
+
+const byte FLASHBACK[] = {
+	0x2, 0x1B, 0x0, 0x1C, 0x0, 0x1, 0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0x0,
+	0x0, 0x0, 0x0, 0xFF, 0xFF, 0xFF, 0x26, 0x0, 0x1C, 0x0, 0x0, 0x0, 0x1C,
+	0x0, 0x5, 0x0, 0x1C, 0x0, 0x0E, 0x0, 0x1C, 0x0, 0x6, 0x0, 0x1C, 0x0, 0x0F,
+	0x0, 0x1C, 0x0, 0x7, 0x0, 0x1C, 0x0, 0x0C, 0x0, 0x1C, 0x0, 0x8, 0x0, 0x1C,
+	0x0, 0x0D, 0x0, 0x2, 0x0, 0x1, 0x0, 0x1C, 0x0, 0x10, 0x0, 0x2, 0x0, 0x2, 0x0, 0x1C,
+	0x0, 0x11, 0x0, 0x1C, 0x0, 0x9, 0x0, 0x1C, 0x0, 0x12, 0x0, 0x1C, 0x0, 0x0A,
+	0x0, 0x1C, 0x0, 0x13, 0x0, 0x1C, 0x0, 0x0B, 0x0, 0x1C, 0x0, 0x14, 0x0, 0x1C,
+	0x0, 0x0B, 0x0, 0x1C, 0x0, 0x15, 0x0, 0x1C, 0x0, 0x0B, 0x0, 0x1C, 0x0, 0x16,
+	0x0, 0x1C, 0x0, 0x0B, 0x0, 0x1C, 0x0, 0x17, 0x0, 0x1C, 0x0, 0x0B, 0x0, 0x1C,
+	0x0, 0x18, 0x0, 0x1C, 0x0, 0x0B, 0x0, 0x1C, 0x0, 0x19, 0x0, 0x1C, 0x0, 0x0B,
+	0x0, 0x1C, 0x0, 0x1A, 0x0, 0x1C, 0x0, 0x0B, 0x0, 0x1C, 0x0, 0x1B, 0x0, 0x1C,
+	0x0, 0x0B, 0x0, 0x1C, 0x0, 0x1C, 0x0, 0x1C, 0x0, 0x0B, 0x0, 0x1C, 0x0, 0x1D,
+	0x0, 0x1C, 0x0, 0x0B, 0x0, 0x1C, 0x0, 0x1E, 0x0, 0x1C, 0x0, 0x0B, 0x0, 0x1C,
+	0x0, 0x1F, 0x0, 0x1C, 0x0, 0x0B, 0x0, 0x1C, 0x0, 0x20, 0x0, 0x1C, 0x0, 0x0B,
+	0x0, 0x1C, 0x0, 0x21, 0x0, 0x1C, 0x0, 0x0B, 0x0, 0x1C, 0x0, 0x22, 0x0, 0x1C,
+	0x0, 0x0B, 0x0, 0x1C, 0x0, 0x23, 0x0, 0x1C, 0x0, 0x0B, 0x0, 0x1C, 0x0, 0x24,
+	0x0, 0xFF, 0xFF
+};
+
+const byte ALLENDIE[] = {
+	0x2, 0xFF, 0xFF, 0x49, 0x0, 0x1, 0x0, 0xFF, 0xFF, 0xFF, 0xFF,
+	0x0, 0x0, 0x0, 0x0, 0xFF, 0xFF, 0xFF, 0x0, 0x0, 0x49, 0x0, 0x0, 0x0, 0x49,
+	0x0, 0x4, 0x0, 0x62, 0x0, 0x1F, 0x0, 0x49, 0x0, 0x5, 0x0, 0x62, 0x0, 0x3A,
+	0x0, 0x49, 0x0, 0x6, 0x0, 0x49, 0x0, 0x7, 0x0, 0xFF, 0xFF
+};
+
+const byte OVERBOARD[] = {
+	0x2, 0xFF, 0xFF, 0x22, 0x0, 0x1, 0x0, 0xFF, 0xFF, 0xFF, 0xFF,
+	0x0, 0x0, 0x0, 0x0, 0x22, 0x22, 0x0, 0x2, 0x0, 0xFF, 0xFF, 0xFF, 0xFF,
+	0xFF, 0x22, 0x0, 0x0, 0x0, 0x22, 0x0, 0x3, 0x0, 0x22, 0x0, 0x6, 0x0, 0x22,
+	0x0, 0x4, 0x0, 0x22, 0x0, 0x7, 0x0, 0x22, 0x0, 0x5, 0x0, 0x62, 0x0, 0x1D, 0x0,
+	0x22, 0x0, 0x5, 0x0, 0x62, 0x0, 0x24, 0x0, 0xFF, 0xFF
+};
+
+const byte PILOT2[] = {
+	0x0, 0x12, 0x0, 0xFF, 0xFF, 0x0, 0x0, 0xFF, 0xFF, 0xFF, 0xFF,
+	0x0, 0x0, 0x0, 0x0, 0x46, 0x46, 0x0, 0x1, 0x0, 0xFF, 0xFF, 0xFF, 0xFF,
+	0xFF, 0x46, 0x0, 0x0, 0x0, 0x46, 0x0, 0x2, 0x0, 0x46, 0x0, 0x0A, 0x0, 0x46,
+	0x0, 0x3, 0x0, 0x46, 0x0, 0x0B, 0x0, 0x46, 0x0, 0x4, 0x0, 0x46, 0x0, 0x0C,
+	0x0, 0x46, 0x0, 0x5, 0x0, 0x46, 0x0, 0x0D, 0x0, 0x46, 0x0, 0x6, 0x0, 0x46,
+	0x0, 0x0E, 0x0, 0x46, 0x0, 0x7, 0x0, 0x46, 0x0, 0x0F, 0x0, 0x46, 0x0, 0x8,
+	0x0, 0x46, 0x0, 0x10, 0x0, 0x46, 0x0, 0x9, 0x0, 0x46, 0x0, 0x11, 0x0, 0x46,
+	0x0, 0x9, 0x0, 0x62, 0x0, 0x1F, 0x0, 0xFF, 0xFF
+};
+
+const byte TIKAGENT[] = {
+	0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0x0, 0x0, 0xFF, 0xFF, 0xFF, 0xFF,
+	0x0, 0x0, 0x0, 0x0, 0x43, 0x43, 0x0, 0x1, 0x0, 0xFF, 0xFF, 0xFF, 0x2,
+	0x0, 0x43, 0x0, 0x0, 0x0, 0x43, 0x0, 0x2, 0x0, 0x43, 0x0, 0x12, 0x0, 0x43,
+	0x0, 0x3, 0x0, 0x43, 0x0, 0x13, 0x0, 0x43, 0x0, 0x4, 0x0, 0x43, 0x0, 0x14,
+	0x0, 0x43, 0x0, 0x5, 0x0, 0x43, 0x0, 0x15, 0x0, 0x43, 0x0, 0x6, 0x0, 0x43,
+	0x0, 0x16, 0x0, 0x43, 0x0, 0x7, 0x0, 0x43, 0x0, 0x17, 0x0, 0x43, 0x0, 0x8,
+	0x0, 0x43, 0x0, 0x18, 0x0, 0x43, 0x0, 0x9, 0x0, 0x43, 0x0, 0x19, 0x0, 0x43,
+	0x0, 0x0A, 0x0, 0x43, 0x0, 0x1A, 0x0, 0x43, 0x0, 0x0B, 0x0, 0x43, 0x0, 0x1B,
+	0x0, 0x43, 0x0, 0x0C, 0x0, 0x43, 0x0, 0x1C, 0x0, 0x43, 0x0, 0x0D, 0x0, 0x43,
+	0x0, 0x1D, 0x0, 0x43, 0x0, 0x0E, 0x0, 0x43, 0x0, 0x1E, 0x0, 0x43, 0x0, 0x0F,
+	0x0, 0x43, 0x0, 0x1F, 0x0, 0x43, 0x0, 0x10, 0x0, 0x43, 0x0, 0x20, 0x0, 0x43,
+	0x0, 0x11, 0x0, 0x43, 0x0, 0x21, 0x0, 0xFF, 0xFF
+};
+
+const byte BARTENDER[] = {
+	0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0x0, 0x0, 0xFF, 0xFF, 0xFF, 0xFF,
+	0x0, 0x0, 0x0, 0x0, 0x44, 0x44, 0x0, 0x1, 0x0, 0xFF, 0xFF, 0xFF, 0x0,
+	0x0, 0x44, 0x0, 0x0, 0x0, 0x44, 0x0, 0x2, 0x0, 0x44, 0x0, 0x8, 0x0, 0x44, 0x0,
+	0x3, 0x0, 0x44, 0x0, 0x9, 0x0, 0x44, 0x0, 0x4, 0x0, 0x44, 0x0, 0x0A, 0x0, 0x44,
+	0x0, 0x5, 0x0, 0x44, 0x0, 0x0B, 0x0, 0x44, 0x0, 0x6, 0x0, 0x44, 0x0, 0x0C,
+	0x0, 0x44, 0x0, 0x7, 0x0, 0x44, 0x0, 0x0D, 0x0, 0xFF, 0xFF
+};
+
+const byte PILOT1[] = {
+	0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
+	0xFF, 0x0, 0x0, 0x0, 0x0, 0x45, 0x45, 0x0, 0x1, 0x0, 0xFF, 0xFF, 0xFF, 0x0,
+	0x0, 0x45, 0x0, 0x0, 0x0, 0x45, 0x0, 0x2, 0x0, 0x45, 0x0, 0x3, 0x0, 0xFF, 0xFF
+};
+
+const byte COOK[] = {
+	0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
+	0xFF, 0x0, 0x0, 0x0, 0x0, 0x47, 0x47, 0x0, 0x1, 0x0, 0xFF, 0xFF, 0xFF,
+	0x2, 0x0, 0x47, 0x0, 0x0, 0x0, 0x47, 0x0, 0x2, 0x0, 0x47, 0x0, 0x10, 0x0, 0x47,
+	0x0, 0x3, 0x0, 0x47, 0x0, 0x11, 0x0, 0x47, 0x0, 0x4, 0x0, 0x47, 0x0, 0x12,
+	0x0, 0x47, 0x0, 0x5, 0x0, 0x47, 0x0, 0x13, 0x0, 0x47, 0x0, 0x6, 0x0, 0x47,
+	0x0, 0x14, 0x0, 0x47, 0x0, 0x7, 0x0, 0x47, 0x0, 0x15, 0x0, 0x47, 0x0, 0x8,
+	0x0, 0x47, 0x0, 0x16, 0x0, 0x47, 0x0, 0x9, 0x0, 0x47, 0x0, 0x17, 0x0, 0x47,
+	0x0, 0x0A, 0x0, 0x47, 0x0, 0x18, 0x0, 0x47, 0x0, 0x0B, 0x0, 0x47, 0x0, 0x19,
+	0x0, 0x47, 0x0, 0x0C, 0x0, 0x47, 0x0, 0x1A, 0x0, 0x47, 0x0, 0x0D, 0x0, 0x47,
+	0x0, 0x1B, 0x0, 0x47, 0x0, 0x0E, 0x0, 0x47, 0x0, 0x1C, 0x0, 0x47, 0x0, 0x0F,
+	0x0, 0x47, 0x0, 0x1D, 0x0, 0xFF, 0xFF
+};
+
+const byte BEXPLODE[] = {
+	0x2, 0xFF, 0xFF, 0x28, 0x0, 0x1, 0x0, 0xFF, 0xFF, 0xFF, 0xFF,
+	0x0, 0x0, 0x0, 0x0, 0x28, 0x28, 0x0, 0x2, 0x0, 0xFF, 0xFF, 0xFF, 0xFF,
+	0xFF, 0x28, 0x0, 0x0, 0x0, 0x28, 0x0, 0x3, 0x0, 0x28, 0x0, 0x9, 0x0, 0x28,
+	0x0, 0x4, 0x0, 0x28, 0x0, 0x0A, 0x0, 0x28, 0x0, 0x5, 0x0, 0x28, 0x0, 0x0B,
+	0x0, 0x28, 0x0, 0x6, 0x0, 0x62, 0x0, 0x23, 0x0, 0x28, 0x0, 0x7, 0x0, 0x62,
+	0x0, 0x23, 0x0, 0x28, 0x0, 0x8, 0x0, 0x62, 0x0, 0x23, 0x0, 0xFF, 0xFF
+};
+
+const byte THORNICK[] = {
+	0x2, 0x7, 0x0, 0x7, 0x0, 0x1, 0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0x0, 0x0, 0x0,
+	0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7, 0x0, 0x0, 0x0, 0x7, 0x0, 0x2, 0x0, 
+	0x7, 0x0, 0x5, 0x0, 0x7, 0x0, 0x3, 0x0, 0x7, 0x0, 0x6, 0x0, 0x7, 0x0, 0x3, 
+	0x0, 0x7, 0x0, 0x7, 0x0, 0x7, 0x0, 0x4, 0x0, 0x7, 0x0, 0x8, 0x0, 0xFF, 0xFF
+};
+
+const byte MAYA[] = {
+	0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x0, 
+	0x0, 0x0, 0x0, 0x48, 0x48, 0x0, 0x1, 0x0, 0xFF, 0xFF, 0xFF, 0x2, 0x0, 
+	0x48, 0x0, 0x0, 0x0, 0x48, 0x0, 0x2, 0x0, 0x48, 0x0, 0x13, 0x0, 0x48,
+	0x0, 0x3, 0x0, 0x48, 0x0, 0x14, 0x0, 0x48, 0x0, 0x4, 0x0, 0x48, 0x0, 0x15,
+	0x0, 0x48, 0x0, 0x5, 0x0, 0x48, 0x0, 0x16, 0x0, 0x48, 0x0, 0x6, 0x0, 0x48,
+	0x0, 0x17, 0x0, 0x48, 0x0, 0x7, 0x0, 0x48, 0x0, 0x18, 0x0, 0x48, 0x0, 0x8,
+	0x0, 0x48, 0x0, 0x19, 0x0, 0x48, 0x0, 0x9, 0x0, 0x48, 0x0, 0x1A, 0x0, 0x48,
+	0x0, 0x0A, 0x0, 0x48, 0x0, 0x1B, 0x0, 0x48, 0x0, 0x0B, 0x0, 0x48, 0x0, 0x1C,
+	0x0, 0x48, 0x0, 0x0C, 0x0, 0x48, 0x0, 0x1D, 0x0, 0x48, 0x0, 0x0D, 0x0, 0x48,
+	0x0, 0x1E, 0x0, 0x48, 0x0, 0x0E, 0x0, 0x48, 0x0, 0x1F, 0x0, 0x48, 0x0, 0x0F,
+	0x0, 0x48, 0x0, 0x20, 0x0, 0x48, 0x0, 0x10, 0x0, 0x48, 0x0, 0x21, 0x0, 0x48,
+	0x0, 0x11, 0x0, 0x48, 0x0, 0x22, 0x0, 0x48, 0x0, 0x12, 0x0, 0x48, 0x0, 0x23,
+	0x0, 0xFF, 0xFF
+};
+
+const byte CAPTAIN[] = {
+	0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
+	0xFF, 0x0, 0x0, 0x0, 0x0, 0x4A, 0x4A, 0x0, 0x1, 0x0, 0xFF, 0xFF, 0xFF,
+	0x2, 0x0, 0x4A, 0x0, 0x0, 0x0, 0x4A, 0x0, 0x2, 0x0, 0x4A, 0x0, 0x0E, 0x0, 0x4A,
+	0x0, 0x3, 0x0, 0x4A, 0x0, 0x0F, 0x0, 0x4A, 0x0, 0x4, 0x0, 0x4A, 0x0, 0x10,
+	0x0, 0x4A, 0x0, 0x5, 0x0, 0x4A, 0x0, 0x11, 0x0, 0x4A, 0x0, 0x6, 0x0, 0x4A,
+	0x0, 0x12, 0x0, 0x4A, 0x0, 0x7, 0x0, 0x4A, 0x0, 0x13, 0x0, 0x4A, 0x0, 0x8,
+	0x0, 0x4A, 0x0, 0x14, 0x0, 0x4A, 0x0, 0x9, 0x0, 0x4A, 0x0, 0x15, 0x0, 0x4A,
+	0x0, 0x0A, 0x0, 0x4A, 0x0, 0x16, 0x0, 0x4A, 0x0, 0x0B, 0x0, 0x4A, 0x0, 0x17,
+	0x0, 0x4A, 0x0, 0x0C, 0x0, 0x4A, 0x0, 0x18, 0x0, 0x4A, 0x0, 0x0D, 0x0, 0x4A,
+	0x0, 0x19, 0x0, 0xFF, 0xFF
+};
+
+const byte ALLEN[] = {
+	0x3, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
+	0xFF, 0x0, 0x0, 0x0, 0x0, 0x1E, 0x4C, 0x0, 0x1, 0x0, 0xFF, 0xFF, 0xFF,
+	0xFF, 0xFF, 0x4C, 0x0, 0x0, 0x0, 0x4C, 0x0, 0x2, 0x0, 0x4C, 0x0, 0x3, 0x0,
+	0xFF, 0xFF
+};
+
+const byte ARCH[] = {
+	0x1, 0x2B, 0x0, 0x4B, 0x0, 0x1, 0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0x0,
+	0x0, 0x0, 0x0, 0x2B, 0x4B, 0x0, 0x40, 0x0, 0xFF, 0x4B, 0x0, 0x41, 0x0,
+	0x4B, 0x0, 0x0, 0x0, 0x4B, 0x0, 0x2, 0x0, 0x4B, 0x0, 0x4, 0x0, 0x4B, 0x0, 0x3,
+	0x0, 0x4B, 0x0, 0x5, 0x0, 0x4B, 0x0, 0x3, 0x0, 0x4B, 0x0, 0x6, 0x0, 0x4B, 0x0,
+	0x3, 0x0, 0x4B, 0x0, 0x7, 0x0, 0x4B, 0x0, 0x3, 0x0, 0x4B, 0x0, 0x8, 0x0, 0x4B,
+	0x0, 0x3, 0x0, 0x4B, 0x0, 0x9, 0x0, 0x4B, 0x0, 0x3, 0x0, 0x4B, 0x0, 0x0A, 0x0,
+	0x4B, 0x0, 0x3, 0x0, 0x4B, 0x0, 0x0B, 0x0, 0x4B, 0x0, 0x3, 0x0, 0x4B, 0x0,
+	0x0C, 0x0, 0x4B, 0x0, 0x3, 0x0, 0x4B, 0x0, 0x0D, 0x0, 0x4B, 0x0, 0x3, 0x0,
+	0x4B, 0x0, 0x0E, 0x0, 0x4B, 0x0, 0x3, 0x0, 0x4B, 0x0, 0x0F, 0x0, 0x4B, 0x0,
+	0x3, 0x0, 0x4B, 0x0, 0x10, 0x0, 0x4B, 0x0, 0x3, 0x0, 0x4B, 0x0, 0x11, 0x0,
+	0x4B, 0x0, 0x3, 0x0, 0x4B, 0x0, 0x12, 0x0, 0x4B, 0x0, 0x3, 0x0, 0x4B, 0x0,
+	0x13, 0x0, 0x4B, 0x0, 0x3, 0x0, 0x4B, 0x0, 0x14, 0x0, 0x4B, 0x0, 0x3, 0x0,
+	0x4B, 0x0, 0x15, 0x0, 0x4B, 0x0, 0x3, 0x0, 0x4B, 0x0, 0x16, 0x0, 0x4B, 0x0,
+	0x3, 0x0, 0x4B, 0x0, 0x17, 0x0, 0x4B, 0x0, 0x3, 0x0, 0x4B, 0x0, 0x18, 0x0,
+	0x4B, 0x0, 0x3, 0x0, 0x4B, 0x0, 0x19, 0x0, 0x4B, 0x0, 0x3, 0x0, 0x4B, 0x0,
+	0x1A, 0x0, 0x4B, 0x0, 0x3, 0x0, 0x4B, 0x0, 0x1B, 0x0, 0x4B, 0x0, 0x3, 0x0,
+	0x4B, 0x0, 0x1C, 0x0, 0x4B, 0x0, 0x3, 0x0, 0x4B, 0x0, 0x1D, 0x0, 0x4B, 0x0,
+	0x3, 0x0, 0x4B, 0x0, 0x1E, 0x0, 0x4B, 0x0, 0x3, 0x0, 0x4B, 0x0, 0x1F, 0x0,
+	0x4B, 0x0, 0x3, 0x0, 0x4B, 0x0, 0x20, 0x0, 0x4B, 0x0, 0x3, 0x0, 0x4B, 0x0,
+	0x21, 0x0, 0x4B, 0x0, 0x3, 0x0, 0x4B, 0x0, 0x22, 0x0, 0x4B, 0x0, 0x3, 0x0,
+	0x4B, 0x0, 0x23, 0x0, 0x4B, 0x0, 0x3, 0x0, 0x4B, 0x0, 0x24, 0x0, 0x4B, 0x0,
+	0x3, 0x0, 0x4B, 0x0, 0x25, 0x0, 0x4B, 0x0, 0x3, 0x0, 0x4B, 0x0, 0x26, 0x0,
+	0x4B, 0x0, 0x3, 0x0, 0x4B, 0x0, 0x27, 0x0, 0x4B, 0x0, 0x3, 0x0, 0x4B, 0x0,
+	0x28, 0x0, 0x4B, 0x0, 0x3, 0x0, 0x4B, 0x0, 0x29, 0x0, 0x4B, 0x0, 0x3, 0x0,
+	0x4B, 0x0, 0x2A, 0x0, 0x4B, 0x0, 0x3, 0x0, 0x4B, 0x0, 0x2B, 0x0, 0x4B, 0x0,
+	0x3, 0x0, 0x4B, 0x0, 0x2C, 0x0, 0x4B, 0x0, 0x3, 0x0, 0x4B, 0x0, 0x2D, 0x0,
+	0x4B, 0x0, 0x3, 0x0, 0x4B, 0x0, 0x2E, 0x0, 0x4B, 0x0, 0x3, 0x0, 0x4B, 0x0,
+	0x2F, 0x0, 0x4B, 0x0, 0x3, 0x0, 0x4B, 0x0, 0x30, 0x0, 0x4B, 0x0, 0x3, 0x0,
+	0x4B, 0x0, 0x31, 0x0, 0x4B, 0x0, 0x3, 0x0, 0x4B, 0x0, 0x32, 0x0, 0x4B, 0x0,
+	0x3, 0x0, 0x4B, 0x0, 0x33, 0x0, 0x4B, 0x0, 0x3, 0x0, 0x4B, 0x0, 0x34, 0x0,
+	0x4B, 0x0, 0x3, 0x0, 0x4B, 0x0, 0x35, 0x0, 0x4B, 0x0, 0x3, 0x0, 0x4B, 0x0,
+	0x36, 0x0, 0x4B, 0x0, 0x3, 0x0, 0x4B, 0x0, 0x37, 0x0, 0x4B, 0x0, 0x3, 0x0,
+	0x4B, 0x0, 0x38, 0x0, 0x4B, 0x0, 0x3, 0x0, 0x4B, 0x0, 0x39, 0x0, 0x4B, 0x0,
+	0x3, 0x0, 0x4B, 0x0, 0x3A, 0x0, 0x4B, 0x0, 0x3, 0x0, 0x4B, 0x0, 0x3B, 0x0,
+	0x4B, 0x0, 0x3, 0x0, 0x4B, 0x0, 0x3C, 0x0, 0x4B, 0x0, 0x3, 0x0, 0x4B, 0x0,
+	0x3D, 0x0, 0x4B, 0x0, 0x3, 0x0, 0x4B, 0x0, 0x3E, 0x0, 0x4B, 0x0, 0x3, 0x0,
+	0x4B, 0x0, 0x3F, 0x0, 0xFF, 0xFF
+};
+
+const byte GUARD1[] = {
+	0x3, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
+	0xFF, 0x0, 0x0, 0x0, 0x0, 0x4D, 0x4D, 0x0, 0x1, 0x0, 0xFF, 0xFF, 0xFF,
+	0xFF, 0xFF, 0x4D, 0x0, 0x0, 0x0, 0x4D, 0x0, 0x2, 0x0, 0x4D, 0x0, 0x3, 0x0,
+	0xFF, 0xFF
+};
+
+const byte MCANOE[] = {
+	0x3, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
+	0xFF, 0x0, 0x0, 0x0, 0x0, 0x4E, 0x4E, 0x0, 0x1, 0x0, 0xFF, 0xFF, 0xFF,
+	0xFF, 0xFF, 0x4E, 0x0, 0x0, 0x0, 0x4E, 0x0, 0x2, 0x0, 0x4E, 0x0, 0x3, 0x0,
+	0xFF, 0xFF
+};
+
+const byte CAMPFIRE[] = {
+	0x2, 0x35, 0x0, 0x35, 0x0, 0x3, 0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0x0,
+	0x0, 0x0, 0x0, 0x35, 0x35, 0x0, 0x1, 0x0, 0xFF, 0x35, 0x0, 0x2, 0x0, 0x35,
+	0x0, 0x0, 0x0, 0x35, 0x0, 0x4, 0x0, 0x35, 0x0, 0x18, 0x0, 0x35, 0x0, 0x5, 0x0,
+	0x35, 0x0, 0x19, 0x0, 0x35, 0x0, 0x6, 0x0, 0x35, 0x0, 0x1A, 0x0, 0x35, 0x0,
+	0x7, 0x0, 0x35, 0x0, 0x1B, 0x0, 0x35, 0x0, 0x8, 0x0, 0x35, 0x0, 0x1C, 0x0,
+	0x35, 0x0, 0x9, 0x0, 0x35, 0x0, 0x1D, 0x0, 0x35, 0x0, 0x0A, 0x0, 0x35, 0x0,
+	0x1E, 0x0, 0x35, 0x0, 0x0B, 0x0, 0x35, 0x0, 0x1F, 0x0, 0x35, 0x0, 0x0C,
+	0x0, 0x35, 0x0, 0x20, 0x0, 0x35, 0x0, 0x0D, 0x0, 0x35, 0x0, 0x21, 0x0, 0x35,
+	0x0, 0x0E, 0x0, 0x35, 0x0, 0x22, 0x0, 0x35, 0x0, 0x0F, 0x0, 0x35, 0x0, 0x23,
+	0x0, 0x35, 0x0, 0x10, 0x0, 0x35, 0x0, 0x24, 0x0, 0x35, 0x0, 0x11, 0x0, 0x35,
+	0x0, 0x25, 0x0, 0x35, 0x0, 0x12, 0x0, 0x35, 0x0, 0x26, 0x0, 0x35, 0x0, 0x13,
+	0x0, 0x35, 0x0, 0x27, 0x0, 0x35, 0x0, 0x14, 0x0, 0x35, 0x0, 0x28, 0x0, 0x35,
+	0x0, 0x15, 0x0, 0x35, 0x0, 0x29, 0x0, 0x35, 0x0, 0x16, 0x0, 0x35, 0x0, 0x2A,
+	0x0, 0x35, 0x0, 0x17, 0x0, 0x35, 0x0, 0x2B, 0x0, 0xFF, 0xFF
+};
+
+const byte COLONEL[] = {
+	0x2, 0xFF, 0xFF, 0x0E, 0x0, 0x1, 0x0, 0xFF, 0xFF, 0xFF, 0xFF,
+	0x0, 0x0, 0x0, 0x0, 0x0E, 0x0E, 0x0, 0x5, 0x0, 0xFF, 0xFF, 0xFF, 0x2,
+	0x0, 0x4F, 0x0, 0x0, 0x0, 0x4F, 0x0, 0x1, 0x0, 0x4F, 0x0, 0x2, 0x0, 0x0E, 0x0,
+	0x8, 0x0, 0x4F, 0x0, 0x3, 0x0, 0xFF, 0xFF
+};
+
+const byte SOLDIERS[] = {
+	0x2, 0xFF, 0xFF, 0x50, 0x0, 0x1, 0x0, 0xFF, 0xFF, 0xFF, 0xFF,
+	0x0, 0x0, 0x0, 0x0, 0xFF, 0xFF, 0xFF, 0x0, 0x0, 0x50, 0x0, 0x0, 0x0, 0x50,
+	0x0, 0x2, 0x0, 0x50, 0x0, 0x0, 0x0, 0xFF, 0xFF
+};
+
+const byte JWATER[] = {
+	0x2, 0xFF, 0xFF, 0x51, 0x0, 0x1, 0x0, 0xFF, 0xFF, 0xFF, 0xFF,
+	0x0, 0x0, 0x0, 0x0, 0xFF, 0xFF, 0xFF, 0x0, 0x0, 0x51, 0x0, 0x0, 0x0, 0x51,
+	0x0, 0x2, 0x0, 0x51, 0x0, 0x3, 0x0, 0xFF, 0xFF
+};
+
+const byte SHOOT[] = {
+	0x2, 0xFF, 0xFF, 0x52, 0x0, 0x2, 0x0, 0xFF, 0xFF, 0xFF, 0xFF,
+	0x0, 0x0, 0x0, 0x0, 0x38, 0x52, 0x0, 0x1, 0x0, 0xFF, 0xFF, 0xFF, 0x0,
+	0x0, 0x52, 0x0, 0x0, 0x0, 0x52, 0x0, 0x3, 0x0, 0x52, 0x0, 0x5, 0x0, 0x52, 
+	0x0, 0x4, 0x0, 0x62, 0x0, 0x1F, 0x0, 0xFF, 0xFF
+};
+
+const byte ADIE[] = {
+	0x2, 0xFF, 0xFF, 0x53, 0x0, 0x1, 0x0, 0xFF, 0xFF, 0xFF, 0xFF,
+	0x0, 0x0, 0x0, 0x0, 0xFF, 0xFF, 0xFF, 0x2, 0x0, 0x53, 0x0, 0x0, 0x0, 0x53,
+	0x0, 0x2, 0x0, 0x62, 0x0, 0x4, 0x0, 0x53, 0x0, 0x3, 0x0, 0x62, 0x0, 0x4, 
+	0x0, 0x53, 0x0, 0x4, 0x0, 0x62, 0x0, 0x4, 0x0, 0xFF, 0xFF
+};
+
+const byte DYNAMITE[] = {
+	0x2, 0xFF, 0xFF, 0x54, 0x0, 0x1, 0x0, 0xFF, 0xFF, 0xFF, 0xFF,
+	0x0, 0x0, 0x0, 0x0, 0xFF, 0xFF, 0xFF, 0x2, 0x0, 0x54, 0x0, 0x0, 0x0, 0x54,
+	0x0, 0x2, 0x0, 0x62, 0x0, 0x23, 0x0, 0xFF, 0xFF
+};
+
+const byte MAYASHOT[] = {
+	0x3, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
+	0xFF, 0x0, 0x0, 0x0, 0x0, 0x36, 0x55, 0x0, 0x1, 0x0, 0xFF, 0xFF, 0xFF,
+	0x3, 0x0, 0x55, 0x0, 0x0, 0x0, 0x55, 0x0, 0x2, 0x0, 0x62, 0x0, 0x1F, 
+	0x0, 0xFF, 0xFF
+};
+
+const byte OFFKEV[] = {
+	0x3, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x0, 
+	0x0, 0x0, 0x0, 0x4D, 0x29, 0x0, 0x1, 0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 
+	0x29, 0x0, 0x0, 0x0, 0x29, 0x0, 0x2, 0x0, 0x29, 0x0, 0x3, 0x0, 0xFF, 0xFF
+};
+
+const byte VALLEY[] = {
+	0x2, 0x3A, 0x0, 0x3A, 0x0, 0x1, 0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0x0,
+	0x0, 0x0, 0x0, 0x3A, 0x3A, 0x0, 0x2, 0x0, 0xFF, 0xFF, 0xFF, 0x3, 0x0,
+	0x3A, 0x0, 0x0, 0x0, 0x3A, 0x0, 0x3, 0x0, 0x3A, 0x0, 0x5, 0x0, 0x3A, 0x0, 
+	0x4, 0x0, 0x62, 0x0, 0x27, 0x0, 0xFF, 0xFF
+};
+
+const byte MEANWHILE1[] = {
+	0x2, 0xFF, 0xFF, 0x0E, 0x0, 0x1, 0x0, 0xFF, 0xFF, 0xFF, 0xFF,
+	0x0, 0x0, 0x0, 0x0, 0x0E, 0x0E, 0x0, 0x5, 0x0, 0xFF, 0xFF, 0xFF, 0x3,
+	0x0, 0x0E, 0x0, 0x0, 0x0, 0x0E, 0x0, 0x6, 0x0, 0x0E, 0x0, 0x0A, 0x0, 0x0E,
+	0x0, 0x7, 0x0, 0x0E, 0x0, 0x0B, 0x0, 0x0E, 0x0, 0x8, 0x0, 0x0E, 0x0, 0x0C,
+	0x0, 0x0E, 0x0, 0x8, 0x0, 0x0E, 0x0, 0x0D, 0x0, 0x0E, 0x0, 0x8, 0x0, 0x0E,
+	0x0, 0x0E, 0x0, 0x0E, 0x0, 0x9, 0x0, 0x0E, 0x0, 0x0F, 0x0, 0x0E, 0x0, 0x9,
+	0x0, 0x0E, 0x0, 0x10, 0x0, 0x0E, 0x0, 0x9, 0x0, 0x0E, 0x0, 0x11, 0x0, 0x0E,
+	0x0, 0x9, 0x0, 0x0E, 0x0, 0x12, 0x0, 0x0E, 0x0, 0x9, 0x0, 0x62, 0x0, 0x1A,
+	0x0, 0xFF, 0xFF
+};
+
+const byte MAYATREE[] = {
+	0x3, 0xFF, 0xFF, 0xFF, 0xFF, 0x1, 0x0, 0xFF, 0xFF, 0xFF, 0xFF,
+	0x0, 0x0, 0x0, 0x0, 0x30, 0x56, 0x0, 0x1, 0x0, 0xFF, 0xFF, 0xFF, 0x0,
+	0x0, 0x56, 0x0, 0x0, 0x0, 0x56, 0x0, 0x2, 0x0, 0x56, 0x0, 0x3, 0x0, 0xFF, 0xFF
+};
+
+const byte LOCO[] = {
+	0x3, 0xFF, 0xFF, 0xFF, 0xFF, 0x1, 0x0, 0xFF, 0xFF, 0xFF, 0xFF,
+	0x0, 0x0, 0x0, 0x0, 0x31, 0x57, 0x0, 0x1, 0x0, 0xFF, 0xFF, 0xFF, 0x0,
+	0x0, 0x57, 0x0, 0x0, 0x0, 0x57, 0x0, 0x2, 0x0, 0x57, 0x0, 0x3, 0x0, 0xFF, 0xFF
+};
+
+const byte KISS[] = {
+	0x2, 0xFF, 0xFF, 0x3A, 0x0, 0x1, 0x0, 0xFF, 0xFF, 0xFF, 0xFF,
+	0x0, 0x0, 0x0, 0x0, 0x40, 0x40, 0x0, 0x5, 0x0, 0xFF, 0xFF, 0xFF, 0x0,
+	0x0, 0x40, 0x0, 0x0, 0x0, 0x40, 0x0, 0x6, 0x0, 0x40, 0x0, 0x26, 0x0, 0x40,
+	0x0, 0x7, 0x0, 0x40, 0x0, 0x27, 0x0, 0x40, 0x0, 0x8, 0x0, 0x40, 0x0, 0x28,
+	0x0, 0x40, 0x0, 0x9, 0x0, 0x62, 0x0, 0x4E, 0x0, 0x40, 0x0, 0x0A, 0x0, 0x40,
+	0x0, 0x29, 0x0, 0x40, 0x0, 0x0B, 0x0, 0x40, 0x0, 0x2A, 0x0, 0x40, 0x0, 0x0C,
+	0x0, 0x40, 0x0, 0x2B, 0x0, 0x40, 0x0, 0x0D, 0x0, 0x40, 0x0, 0x2C, 0x0, 0x40,
+	0x0, 0x0E, 0x0, 0x40, 0x0, 0x2D, 0x0, 0x40, 0x0, 0x0F, 0x0, 0x40, 0x0, 0x2E,
+	0x0, 0x40, 0x0, 0x10, 0x0, 0x40, 0x0, 0x2F, 0x0, 0x40, 0x0, 0x11, 0x0, 0x40,
+	0x0, 0x30, 0x0, 0x40, 0x0, 0x12, 0x0, 0x40, 0x0, 0x31, 0x0, 0x40, 0x0, 0x13,
+	0x0, 0x40, 0x0, 0x32, 0x0, 0x40, 0x0, 0x14, 0x0, 0x40, 0x0, 0x33, 0x0, 0x40,
+	0x0, 0x15, 0x0, 0x40, 0x0, 0x34, 0x0, 0x40, 0x0, 0x16, 0x0, 0x40, 0x0, 0x35,
+	0x0, 0x40, 0x0, 0x17, 0x0, 0x40, 0x0, 0x36, 0x0, 0x40, 0x0, 0x18, 0x0, 0x40,
+	0x0, 0x37, 0x0, 0x40, 0x0, 0x19, 0x0, 0x40, 0x0, 0x38, 0x0, 0x40, 0x0, 0x1A,
+	0x0, 0x40, 0x0, 0x39, 0x0, 0x40, 0x0, 0x1B, 0x0, 0x40, 0x0, 0x3A, 0x0, 0x40,
+	0x0, 0x1C, 0x0, 0x40, 0x0, 0x3B, 0x0, 0x40, 0x0, 0x1D, 0x0, 0x40, 0x0, 0x3C,
+	0x0, 0x40, 0x0, 0x1E, 0x0, 0x40, 0x0, 0x3D, 0x0, 0x40, 0x0, 0x1F, 0x0, 0x40,
+	0x0, 0x3E, 0x0, 0x40, 0x0, 0x20, 0x0, 0x40, 0x0, 0x3F, 0x0, 0x40, 0x0, 0x21,
+	0x0, 0x40, 0x0, 0x40, 0x0, 0x40, 0x0, 0x22, 0x0, 0x40, 0x0, 0x41, 0x0, 0x40,
+	0x0, 0x23, 0x0, 0x40, 0x0, 0x42, 0x0, 0x40, 0x0, 0x24, 0x0, 0x40, 0x0, 0x43,
+	0x0, 0x40, 0x0, 0x25, 0x0, 0x40, 0x0, 0x44, 0x0, 0x40, 0x0, 0x25, 0x0, 0x40,
+	0x0, 0x45, 0x0, 0x40, 0x0, 0x25, 0x0, 0x40, 0x0, 0x46, 0x0, 0x40, 0x0, 0x25,
+	0x0, 0x40, 0x0, 0x47, 0x0, 0xFF, 0xFF
+};
+
+const byte ROBOT[] = {
+	0x3, 0xFF, 0xFF, 0xFF, 0xFF, 0x1, 0x0, 0xFF, 0xFF, 0xFF, 0xFF,
+	0x0, 0x0, 0x0, 0x0, 0x9, 0x58, 0x0, 0x1, 0x0, 0xFF, 0xFF, 0xFF, 0x0, 0x0,
+	0x58, 0x0, 0x0, 0x0, 0x58, 0x0, 0x0, 0x0, 0x58, 0x0, 0x2, 0x0, 0xFF, 0xFF
+};
+
+const byte ANTKILL[] = {
+	0x3, 0xFF, 0xFF, 0xFF, 0xFF, 0x1, 0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0x0, 0x0, 
+	0x0, 0x0, 0x3C, 0x59, 0x0, 0x1, 0x0, 0xFF, 0xFF, 0xFF, 0x0, 0x0, 0x59, 
+	0x0, 0x0, 0x0, 0x59, 0x0, 0x2, 0x0, 0x62, 0x0, 0x0E, 0x0, 0xFF, 0xFF
+};
+
+const byte LOCOHOT[] = {
+	0x3, 0xFF, 0xFF, 0xFF, 0xFF, 0x1, 0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0x0, 0x0, 
+	0x0, 0x0, 0x19, 0x5A, 0x0, 0x1, 0x0, 0xFF, 0xFF, 0xFF, 0x0, 0x0, 0x5A, 
+	0x0, 0x0, 0x0, 0x5A, 0x0, 0x2, 0x0, 0x62, 0x0, 0x3C, 0x0, 0xFF, 0xFF
+};
+
+const byte CRACK[] = {
+	0x2, 0x38, 0x0, 0x38, 0x0, 0x1, 0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0x0,
+	0x0, 0x0, 0x0, 0xFF, 0xFF, 0xFF, 0x0, 0x0, 0x38, 0x0, 0x0, 0x0, 0x38,
+	0x0, 0x0, 0x0, 0x38, 0x0, 0x2, 0x0, 0xFF, 0xFF
+};
+
+const byte LETTER[] = {
+	0x3, 0xFF, 0xFF, 0xFF, 0xFF, 0x1, 0x0, 0xFF, 0xFF, 0xFF, 0xFF,
+	0x0, 0x0, 0x0, 0x0, 0xFF, 0xFF, 0xFF, 0x0, 0x0, 0x30, 0x0, 0x0, 0x0, 0x30,
+	0x0, 0x0, 0x0, 0x30, 0x0, 0x1, 0x0, 0x30, 0x0, 0x0, 0x0, 0x30, 0x0, 0x6, 0x0, 0x30,
+	0x0, 0x0, 0x0, 0x30, 0x0, 0x7, 0x0, 0x30, 0x0, 0x0, 0x0, 0x30, 0x0, 0x8, 0x0, 0x30,
+	0x0, 0x0, 0x0, 0x30, 0x0, 0x9, 0x0, 0x30, 0x0, 0x0, 0x0, 0x30, 0x0, 0x0A, 0x0,
+	0x30, 0x0, 0x0, 0x0, 0x30, 0x0, 0x0B, 0x0, 0x30, 0x0, 0x0, 0x0, 0x30, 0x0,
+	0x0C, 0x0, 0x30, 0x0, 0x0, 0x0, 0x30, 0x0, 0x0D, 0x0, 0x30, 0x0, 0x0, 0x0,
+	0x30, 0x0, 0x0E, 0x0, 0x30, 0x0, 0x0, 0x0, 0x30, 0x0, 0x0F, 0x0, 0x30, 0x0,
+	0x0, 0x0, 0x30, 0x0, 0x10, 0x0, 0x30, 0x0, 0x0, 0x0, 0x30, 0x0, 0x2, 0x0, 0x30,
+	0x0, 0x0, 0x0, 0x30, 0x0, 0x3, 0x0, 0x30, 0x0, 0x0, 0x0, 0x30, 0x0, 0x4, 0x0, 0x30,
+	0x0, 0x0, 0x0, 0x30, 0x0, 0x5, 0x0, 0xFF, 0xFF
+};
+
+extern const byte *CHARTBL[] = {
+	ELAINE, LIB, FLASHBACK, ALLENDIE, OVERBOARD, PILOT2, TIKAGENT,
+	BARTENDER, PILOT1, COOK, BEXPLODE, THORNICK, MAYA, CAPTAIN,
+	ALLEN, ARCH, GUARD1, MCANOE, CAMPFIRE, COLONEL, SOLDIERS,
+	JWATER, SHOOT, ADIE, DYNAMITE, MAYASHOT, OFFKEV, VALLEY,
+	MEANWHILE1, MAYATREE, LOCO, KISS, ROBOT, ANTKILL, LOCOHOT,
+	CRACK, LETTER
+};
+
 } // End of namespace Amazon
 
 } // End of namespace Access
diff --git a/engines/access/amazon/amazon_resources.h b/engines/access/amazon/amazon_resources.h
index fba3bc2..7601138 100644
--- a/engines/access/amazon/amazon_resources.h
+++ b/engines/access/amazon/amazon_resources.h
@@ -35,6 +35,10 @@ extern const byte *CURSORS[10];
 
 extern const int TRAVEL_POS[][2];
 
+extern const byte *ROOM_TABLE[];
+
+extern const byte *CHARTBL[];
+
 } // End of namespace Amazon
 
 } // End of namespace Access


Commit: 031cc32c847bf7387859e273069f8efd3b6d4ed0
    https://github.com/scummvm/scummvm/commit/031cc32c847bf7387859e273069f8efd3b6d4ed0
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-06T22:43:40-04:00

Commit Message:
ACCESS: Implemented room data loading

Changed paths:
    engines/access/access.cpp
    engines/access/access.h
    engines/access/amazon/amazon_room.cpp
    engines/access/amazon/amazon_room.h
    engines/access/asurface.h
    engines/access/data.h
    engines/access/room.cpp
    engines/access/room.h
    engines/access/screen.cpp
    engines/access/screen.h
    engines/access/sound.cpp
    engines/access/sound.h



diff --git a/engines/access/access.cpp b/engines/access/access.cpp
index 6b805e4..98f5529 100644
--- a/engines/access/access.cpp
+++ b/engines/access/access.cpp
@@ -70,6 +70,13 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc)
 	_startup = 0;
 	_currentCharFlag = false;
 	_boxSelect = false;
+	_charFlag = 0;
+	_scaleH1 = _scaleH2 = 0;
+	_scaleN1 = 0;
+	_scaleT1 = 0;
+	_scaleMaxY = 0;
+	_scaleI = 0;
+	_playFieldHeight = 0;
 
 	_roomNumber = 0;
 	_rawPlayerXLow = 0;
@@ -85,6 +92,10 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc)
 	_timerFlag = false;
 	Common::fill(&_flags[0], &_flags[99], 0);
 	Common::fill(&_useItem[0], &_useItem[23], 0);
+	Common::fill(&_establishTable[0], &_establishTable[100], 0);
+	_establishFlag = false;
+	_establishMode = 0;
+	_establishGroup = 0;
 	_guardLoc = 0;
 	_guardFind = 0;
 	_helpLevel = 0;
@@ -192,6 +203,13 @@ int AccessEngine::getRandomNumber(int maxNumber) {
 	return _randomSource.getRandomNumber(maxNumber);
 }
 
+void AccessEngine::loadCells(Common::Array<CellIdent> &cells) {
+	for (uint i = 0; i < cells.size(); ++i) {
+		_objectsTable[cells[i]._cell] = _files->loadFile(
+			cells[i]._fileNum, cells[i]._subfile);
+	}
+}
+
 void AccessEngine::clearCellTable() {
 	Common::fill(&_objectsTable[0], &_objectsTable[100], (byte *)nullptr);
 }
@@ -228,4 +246,34 @@ void AccessEngine::freeManData() {
 	_man = nullptr;
 }
 
+void AccessEngine::establish(int v) {
+	_establishMode = 0;
+	_establishGroup = 0;
+	doEstablish(v);
+}
+
+void AccessEngine::establishCenter(int v) {
+	_establishMode = 1;
+	doEstablish(v);
+}
+
+void AccessEngine::doEstablish(int v) {
+	_screen->forceFadeOut();
+	_screen->clearScreen();
+	_screen->setPanel(3);
+
+	if (v != -1) {
+		_files->loadScreen(95, v);
+		_buffer2.copyBuffer(_screen);
+	}
+
+	warning("TODO: doEstablish");
+}
+
+void AccessEngine::loadPlayField(int fileNum, int subfile) {
+	// TODO
+}
+
+
+
 } // End of namespace Access
diff --git a/engines/access/access.h b/engines/access/access.h
index 2e605e4..1451e21 100644
--- a/engines/access/access.h
+++ b/engines/access/access.h
@@ -80,6 +80,8 @@ private:
 	void setVGA();
 
 	void dummyLoop();
+
+	void doEstablish(int v);
 protected:
 	const AccessGameDescription *_gameDescription;
 	Common::RandomSource _randomSource;
@@ -108,13 +110,18 @@ public:
 	SoundManager *_sound;
 
 	byte *_destIn;
-	Graphics::Surface _buffer1;
-	Graphics::Surface _buffer2;
+	ASurface _buffer1;
+	ASurface _buffer2;
 	byte *_objectsTable[100];
+	int _establishTable[100];
+	bool _establishFlag;
+	int _establishMode;
+	int _establishGroup;
 	int _numAnimTimers;
 	Common::Array<TimerEntry> _timers;
 	Common::Array<Common::Rect> _newRect;
 	Common::Array<Common::Rect> _oldRect;
+	Common::Array<ExtraCell> _extraCells;
 	int _pCount;
 	int _selectCommand;
 	bool _normalMouse;
@@ -141,6 +148,13 @@ public:
 	int _startTravelBox;
 	bool _currentCharFlag;
 	bool _boxSelect;
+	int _charFlag;
+	int _scaleH1, _scaleH2;
+	int _scaleN1;
+	int _scaleT1;
+	int _scaleMaxY;
+	int _scaleI;
+	int _playFieldHeight;
 
 	// Fields that are included in savegames
 	int _roomNumber;
@@ -202,6 +216,8 @@ public:
 
 	void freeAnimationData();
 
+	void loadCells(Common::Array<CellIdent> &cells);
+
 	/**
 	* Clear the cell table
 	*/
@@ -231,6 +247,12 @@ public:
 	 * Free animation data
 	 */
 	void freeManData();
+
+	void establish(int v);
+
+	void establishCenter(int v);
+
+	void loadPlayField(int fileNum, int subfile);
 };
 
 } // End of namespace Access
diff --git a/engines/access/amazon/amazon_room.cpp b/engines/access/amazon/amazon_room.cpp
index ce0683f..21d9c60 100644
--- a/engines/access/amazon/amazon_room.cpp
+++ b/engines/access/amazon/amazon_room.cpp
@@ -22,6 +22,7 @@
 
 #include "common/scummsys.h"
 #include "access/access.h"
+#include "access/amazon/amazon_resources.h"
 #include "access/amazon/amazon_room.h"
 
 namespace Access {
@@ -32,6 +33,10 @@ AmazonRoom::AmazonRoom(AccessEngine *vm): Room(vm) {
 	_antOutFlag = false;
 }
 
+void AmazonRoom::loadRoom(int roomNumber) {
+	loadRoomData(ROOM_TABLE[roomNumber]);
+}
+
 void AmazonRoom::reloadRoom() {
 	loadRoom(_vm->_roomNumber);
 
diff --git a/engines/access/amazon/amazon_room.h b/engines/access/amazon/amazon_room.h
index 6d13a4e..006aef5 100644
--- a/engines/access/amazon/amazon_room.h
+++ b/engines/access/amazon/amazon_room.h
@@ -40,6 +40,8 @@ private:
 
 	void roomMenu();
 protected:
+	virtual void loadRoom(int roomNumber);
+
 	virtual void reloadRoom();
 
 	virtual void reloadRoom1();
diff --git a/engines/access/asurface.h b/engines/access/asurface.h
index ecd04b9..830a493 100644
--- a/engines/access/asurface.h
+++ b/engines/access/asurface.h
@@ -31,6 +31,8 @@ namespace Access {
 class ASurface : public Graphics::Surface {
 public:
 	void clearBuffer();
+
+	void copyBuffer(Graphics::Surface *src) { copyFrom(*src); }
 };
 
 } // End of namespace Access
diff --git a/engines/access/data.h b/engines/access/data.h
index 7e10e99..8b77e7c 100644
--- a/engines/access/data.h
+++ b/engines/access/data.h
@@ -39,6 +39,14 @@ struct TimerEntry {
 	}
 };
 
+class ExtraCell {
+public:
+	int _vidTable;
+	int _vidTable1;
+	int _vidSTable;
+	int _vidSTable1;
+};
+
 } // End of namespace Access
 
 #endif /* ACCESS_DATA_H */
diff --git a/engines/access/room.cpp b/engines/access/room.cpp
index f735fdb..1e9eec7 100644
--- a/engines/access/room.cpp
+++ b/engines/access/room.cpp
@@ -21,6 +21,7 @@
  */
 
 #include "common/scummsys.h"
+#include "common/memstream.h"
 #include "access/access.h"
 #include "access/resources.h"
 #include "access/room.h"
@@ -131,8 +132,77 @@ void Room::clearRoom() {
 	_vm->freeManData();
 }
 
-void Room::loadRoom(int room) {
-	// TODO
+void Room::loadRoomData(const byte *roomData) {
+	RoomInfo roomInfo(roomData);
+
+	_roomFlag = roomInfo._roomFlag;
+
+	_vm->_establishFlag = false;
+	if (roomInfo._estIndex != -1) {
+		_vm->_establishFlag = true;
+		if (_vm->_establishTable[roomInfo._estIndex] != 1) {
+			_vm->_establishTable[roomInfo._estIndex] = 1;
+			_vm->establish(0);
+		}
+	}
+
+	_vm->_sound->freeMusic();
+	if (roomInfo._musicFile._fileNum != -1) {
+		_vm->_sound->_music = _vm->_files->loadFile(roomInfo._musicFile._fileNum,
+			roomInfo._musicFile._subfile);
+		_vm->_sound->_midiSize = _vm->_files->_filesize;
+		_vm->_sound->midiPlay();
+		_vm->_sound->_musicRepeat = true;
+	}
+
+	_vm->_scaleH1 = roomInfo._scaleH1;
+	_vm->_scaleH2 = roomInfo._scaleH2;
+	_vm->_scaleN1 = roomInfo._scaleN1;
+	_vm->_scaleT1 = ((_vm->_scaleH2 - _vm->_scaleH1) << 8) / _vm->_scaleN1;
+
+	if (roomInfo._playFieldFile._fileNum != -1) {
+		_vm->loadPlayField(roomInfo._playFieldFile._fileNum,
+			roomInfo._playFieldFile._subfile);
+		setupRoom();
+
+		_vm->_scaleMaxY = _vm->_playFieldHeight << 4;
+	}
+
+	// Load cells
+	_vm->loadCells(roomInfo._cells);
+
+	// Load script data
+	_vm->_scripts->freeScriptData();
+	if (roomInfo._scriptFile._fileNum != -1)
+		_vm->_scripts->_script = _vm->_files->loadFile(roomInfo._scriptFile._fileNum,
+		roomInfo._scriptFile._subfile);
+
+	// Load animation data
+	_vm->freeAnimationData();
+	if (roomInfo._animFile._fileNum != -1)
+		_vm->_anim = _vm->_files->loadFile(roomInfo._animFile._fileNum,
+		roomInfo._animFile._subfile);
+
+	_vm->_scaleI = roomInfo._scaleI;
+	_vm->_screen->_scrollThreshold = roomInfo._scrollThreshold;
+
+	_vm->_screen->_startColor = roomInfo._startColor;
+	_vm->_screen->_numColors = roomInfo._numColors;
+	_vm->_screen->loadPalette(roomInfo._paletteFile._fileNum,
+		roomInfo._paletteFile._subfile);
+
+	// Load extra cells
+	_vm->_extraCells.clear();
+	for (uint i = 0; i < roomInfo._vidTable.size(); ++i) {
+		ExtraCell ec;
+		ec._vidTable = roomInfo._vidTable[i] & 0xffff;
+		ec._vidTable1 = roomInfo._vidTable[i] >> 16;
+
+		_vm->_extraCells.push_back(ec);
+	}
+
+	// Load sounds for the scene
+	_vm->_sound->loadSounds(roomInfo._sounds);
 }
 
 void Room::roomLoop() {
@@ -156,4 +226,57 @@ void Room::buildScreen() {
 	// TODO
 }
 
+/*------------------------------------------------------------------------*/
+
+RoomInfo::RoomInfo(const byte *data) {
+	Common::MemoryReadStream stream(data, 999);
+
+	_roomFlag = stream.readByte() != 0;
+	_estIndex = (int16)stream.readUint16LE();
+	_musicFile._fileNum = (int16)stream.readUint16LE();
+	_musicFile._subfile = stream.readUint16LE();
+	_scaleH1 = stream.readByte();
+	_scaleH2 = stream.readByte();
+	_scaleN1 = stream.readByte();
+	_playFieldFile._fileNum = (int16)stream.readUint16LE();
+	_playFieldFile._subfile = stream.readUint16LE();
+
+	for (byte cell = stream.readByte(); cell != 0xff; cell = stream.readByte()) {
+		CellIdent ci;
+		ci._cell = cell;
+		ci._fileNum = (int16)stream.readUint16LE();
+		ci._subfile = stream.readUint16LE();
+
+		_cells.push_back(ci);
+	}
+
+	_scriptFile._fileNum = (int16)stream.readUint16LE();
+	_scriptFile._subfile = stream.readUint16LE();
+	_animFile._fileNum = (int16)stream.readUint16LE();
+	_animFile._subfile = stream.readUint16LE();
+	_scaleI = stream.readByte();
+	_scrollThreshold = stream.readByte();
+	_paletteFile._fileNum = (int16)stream.readUint16LE();
+	_paletteFile._subfile = stream.readUint16LE();
+	_startColor = stream.readUint16LE();
+	_numColors = stream.readUint16LE();
+
+	for (int16 v = (int16)stream.readUint16LE(); v != -1;
+			v = (int16)stream.readUint16LE()) {
+		uint16 v2 = stream.readUint16LE();
+
+		_vidTable.push_back(v | ((uint32)v2 << 16));
+	}
+
+	for (int16 fileNum = (int16)stream.readUint16LE(); fileNum != -1;
+			fileNum = (int16)stream.readUint16LE()) {
+		FileIdent fi;
+		fi._fileNum = fileNum;
+		fi._subfile = stream.readUint16LE();
+
+		_sounds.push_back(fi);
+	}
+};
+
+
 } // End of namespace Access
diff --git a/engines/access/room.h b/engines/access/room.h
index 28506db..1b80366 100644
--- a/engines/access/room.h
+++ b/engines/access/room.h
@@ -35,10 +35,13 @@ private:
 protected:
 	AccessEngine *_vm;
 
+	void loadRoomData(const byte *roomData);
 	void setupRoom();
 	void setWallCodes();
 	void buildScreen();
 
+	virtual void loadRoom(int roomNumber) = 0;
+
 	virtual void reloadRoom() = 0;
 
 	virtual void reloadRoom1() = 0;
@@ -56,8 +59,38 @@ public:
 	 * Clear all the data used by the room
 	 */
 	void clearRoom();
+};
+
+struct FileIdent {
+	int _fileNum;
+	int _subfile;
+};
 
-	void loadRoom(int room);
+struct CellIdent : FileIdent {
+	byte _cell;
+};
+
+class RoomInfo {
+public:
+	bool _roomFlag;
+	int _estIndex;
+	FileIdent _musicFile;
+	int _scaleH1;
+	int _scaleH2;
+	int _scaleN1;
+	FileIdent _playFieldFile;
+	Common::Array<CellIdent> _cells;
+	FileIdent _scriptFile;
+	FileIdent _animFile;
+	int _scaleI;
+	int _scrollThreshold;
+	FileIdent _paletteFile;
+	int _startColor;
+	int _numColors;
+	Common::Array<uint32> _vidTable;
+	Common::Array<FileIdent> _sounds;
+public:
+	RoomInfo(const byte *data);
 };
 
 } // End of namespace Access
diff --git a/engines/access/screen.cpp b/engines/access/screen.cpp
index 8dcc9f1..3823267 100644
--- a/engines/access/screen.cpp
+++ b/engines/access/screen.cpp
@@ -26,6 +26,7 @@
 #include "common/textconsole.h"
 #include "common/system.h"
 #include "graphics/palette.h"
+#include "access/access.h"
 #include "access/screen.h"
 #include "access/resources.h"
 
@@ -42,6 +43,8 @@ Screen::Screen(AccessEngine *vm) : _vm(vm) {
 	_topSkip = _bottomSkip = 0;
 	_clipWidth = _clipHeight = 0;
 	_scrollFlag = false;
+	_scrollThreshold = 0;
+	_startColor = _numColors = 0;
 }
 
 void Screen::setDisplayScan() {
@@ -71,6 +74,12 @@ void Screen::loadPalette(Common::SeekableReadStream *stream) {
 	_loadPalFlag = true;
 }
 
+void Screen::loadPalette(int fileNum, int subfile) {
+	byte *palette = _vm->_files->loadFile(fileNum, subfile);
+	Common::copy(palette, palette + (_numColors * 3), &_rawPalette[_startColor * 3]);
+	delete[] palette;
+}
+
 void Screen::setPalette() {
 	g_system->getPaletteManager()->setPalette(&_rawPalette[0], 0, PALETTE_COUNT);
 }
diff --git a/engines/access/screen.h b/engines/access/screen.h
index 1b03d26..57d7735 100644
--- a/engines/access/screen.h
+++ b/engines/access/screen.h
@@ -56,6 +56,8 @@ private:
 public:
 	bool _loadPalFlag;
 	bool _scrollFlag;
+	int _scrollThreshold;
+	int _startColor, _numColors;
 public:
 	Screen(AccessEngine *vm);
 
@@ -89,6 +91,8 @@ public:
 
 	void loadPalette(Common::SeekableReadStream *stream);
 
+	void loadPalette(int fileNum, int subfile);
+
 	void setPalette();
 
 	/**
diff --git a/engines/access/sound.cpp b/engines/access/sound.cpp
index 2f64465..7ac0e4d 100644
--- a/engines/access/sound.cpp
+++ b/engines/access/sound.cpp
@@ -34,6 +34,8 @@ SoundManager::SoundManager(AccessEngine *vm, Audio::Mixer *mixer) :
 		_soundTable[i]._data = nullptr;
 
 	_music = nullptr;
+	_midiSize = 0;
+	_musicRepeat = false;
 }
 
 SoundManager::~SoundManager() {
@@ -66,6 +68,14 @@ void SoundManager::playSound(byte *data, uint32 size) {
 		*/
 }
 
+void SoundManager::loadSounds(Common::Array<FileIdent> &sounds) {
+	// TODO
+}
+
+void SoundManager::midiPlay() {
+	// TODO
+}
+
 void SoundManager::midiRepeat() {
 	// TODO
 }
@@ -78,4 +88,9 @@ void SoundManager::freeSounds() {
 	// TODO
 }
 
+void SoundManager::freeMusic() {
+	delete[] _music;
+	_music = nullptr;
+}
+
 } // End of namespace Access
diff --git a/engines/access/sound.h b/engines/access/sound.h
index 37d263e..a127051 100644
--- a/engines/access/sound.h
+++ b/engines/access/sound.h
@@ -49,6 +49,9 @@ public:
 	SoundEntry _soundTable[MAX_SOUNDS];
 	int _soundPriority[MAX_SOUNDS];
 	byte *_music;
+	int _midiSize;
+	bool _musicRepeat;
+
 public:
 	SoundManager(AccessEngine *vm, Audio::Mixer *mixer);
 	~SoundManager();
@@ -57,11 +60,17 @@ public:
 
 	void playSound(int soundIndex);
 
+	void loadSounds(Common::Array<FileIdent> &sounds);
+
+	void midiPlay();
+
 	void midiRepeat();
 
 	void stopSong();
 
 	void freeSounds();
+
+	void freeMusic();
 };
 
 } // End of namespace Access


Commit: bea93f3441154197a8f599912a1102ac11688d7f
    https://github.com/scummvm/scummvm/commit/bea93f3441154197a8f599912a1102ac11688d7f
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-07T09:23:31-04:00

Commit Message:
ACCESS: Implemented setupRoom method

Changed paths:
    engines/access/access.cpp
    engines/access/access.h
    engines/access/amazon/amazon_game.cpp
    engines/access/amazon/amazon_room.cpp
    engines/access/asurface.cpp
    engines/access/asurface.h
    engines/access/player.cpp
    engines/access/player.h
    engines/access/room.cpp
    engines/access/room.h
    engines/access/screen.cpp
    engines/access/screen.h



diff --git a/engines/access/access.cpp b/engines/access/access.cpp
index 98f5529..c263ae8 100644
--- a/engines/access/access.cpp
+++ b/engines/access/access.cpp
@@ -71,18 +71,13 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc)
 	_currentCharFlag = false;
 	_boxSelect = false;
 	_charFlag = 0;
+	_scale = 0;
 	_scaleH1 = _scaleH2 = 0;
 	_scaleN1 = 0;
 	_scaleT1 = 0;
 	_scaleMaxY = 0;
 	_scaleI = 0;
-	_playFieldHeight = 0;
 
-	_roomNumber = 0;
-	_rawPlayerXLow = 0;
-	_rawPlayerX = 0;
-	_rawPlayerYLow = 0;
-	_rawPlayerY = 0;
 	_conversation = 0;
 	_currentMan = 0;
 	_newTime = 0;
diff --git a/engines/access/access.h b/engines/access/access.h
index 1451e21..87de9ee 100644
--- a/engines/access/access.h
+++ b/engines/access/access.h
@@ -136,6 +136,7 @@ public:
 	byte *_manPal1;
 	byte *_music;
 	byte *_playField;
+	Common::Point _playFieldSize;
 	byte *_tile;
 	byte *_anim;
 	byte *_title;
@@ -149,6 +150,7 @@ public:
 	bool _currentCharFlag;
 	bool _boxSelect;
 	int _charFlag;
+	int _scale;
 	int _scaleH1, _scaleH2;
 	int _scaleN1;
 	int _scaleT1;
@@ -157,11 +159,6 @@ public:
 	int _playFieldHeight;
 
 	// Fields that are included in savegames
-	int _roomNumber;
-	int _rawPlayerXLow;
-	int _rawPlayerX;
-	int _rawPlayerYLow;
-	int _rawPlayerY;
 	int _conversation;
 	int _currentMan;
 	uint32 _newTime;
diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp
index eccfc4d..7a16036 100644
--- a/engines/access/amazon/amazon_game.cpp
+++ b/engines/access/amazon/amazon_game.cpp
@@ -164,9 +164,9 @@ void AmazonEngine::setupGame() {
 	}
 
 	// Set miscellaneous fields
-	_roomNumber = 4;
-	_player->_playerX = _rawPlayerX = TRAVEL_POS[_roomNumber][0];
-	_player->_playerY = _rawPlayerY = TRAVEL_POS[_roomNumber][1];
+	_player->_roomNumber = 4;
+	_player->_playerX = _player->_rawPlayer.x = TRAVEL_POS[_player->_roomNumber][0];
+	_player->_playerY = _player->_rawPlayer.y = TRAVEL_POS[_player->_roomNumber][1];
 	_selectCommand = -1;
 }
 
diff --git a/engines/access/amazon/amazon_room.cpp b/engines/access/amazon/amazon_room.cpp
index 21d9c60..c2a0332 100644
--- a/engines/access/amazon/amazon_room.cpp
+++ b/engines/access/amazon/amazon_room.cpp
@@ -38,7 +38,7 @@ void AmazonRoom::loadRoom(int roomNumber) {
 }
 
 void AmazonRoom::reloadRoom() {
-	loadRoom(_vm->_roomNumber);
+	loadRoom(_vm->_player->_roomNumber);
 
 	if (_roomFlag != 1) {
 		_vm->_currentMan = _roomFlag;
@@ -68,8 +68,8 @@ void AmazonRoom::reloadRoom() {
 }
 
 void AmazonRoom::reloadRoom1() {
-	if (_vm->_roomNumber == 22 || _vm->_roomNumber == 31 
-			|| _vm->_roomNumber == 42 || _vm->_roomNumber == 44) {
+	if (_vm->_player->_roomNumber == 22 || _vm->_player->_roomNumber == 31 
+			|| _vm->_player->_roomNumber == 42 || _vm->_player->_roomNumber == 44) {
 		_vm->_inactive = _vm->_files->loadFile("MAYA.LZ");
 		_vm->_currentCharFlag = false;
 	}
@@ -84,13 +84,13 @@ void AmazonRoom::reloadRoom1() {
 	_vm->_screen->clearScreen();
 	roomSet();
 
-	if (!_roomFlag && (_vm->_roomNumber != 61 || !_antOutFlag)) {
+	if (!_roomFlag && (_vm->_player->_roomNumber != 61 || !_antOutFlag)) {
 		_vm->_player->load();
 		_vm->_player->calcManScale();
 	}
 
-	if (_vm->_roomNumber != 20 && _vm->_roomNumber != 24
-			&& _vm->_roomNumber != 33 && _vm->_roomNumber != 45) {
+	if (_vm->_player->_roomNumber != 20 && _vm->_player->_roomNumber != 24
+			&& _vm->_player->_roomNumber != 33 && _vm->_player->_roomNumber != 45) {
 		roomMenu();
 	}
 
@@ -99,8 +99,8 @@ void AmazonRoom::reloadRoom1() {
 	setWallCodes();
 	buildScreen();
 
-	if (_vm->_roomNumber != 20 && _vm->_roomNumber != 24
-			&& _vm->_roomNumber != 33) {
+	if (_vm->_player->_roomNumber != 20 && _vm->_player->_roomNumber != 24
+			&& _vm->_player->_roomNumber != 33) {
 		_vm->_screen->setPalette();
 		_vm->_screen->copyBF2Vid();
 	}
diff --git a/engines/access/asurface.cpp b/engines/access/asurface.cpp
index a0a790d..b791186 100644
--- a/engines/access/asurface.cpp
+++ b/engines/access/asurface.cpp
@@ -30,4 +30,13 @@ void ASurface::clearBuffer() {
 	Common::fill(pSrc, pSrc + w * h, 0);
 }
 
+void ASurface::setScaleTable(int scale) {
+	int total = 0;
+	for (int idx = 0; idx < 256; ++idx) {
+		_scaleTable1[idx] = total >> 8;
+		_scaleTable2[idx] = total & 0xff;
+		total += scale;
+	}
+}
+
 } // End of namespace Access
diff --git a/engines/access/asurface.h b/engines/access/asurface.h
index 830a493..8570676 100644
--- a/engines/access/asurface.h
+++ b/engines/access/asurface.h
@@ -23,16 +23,22 @@
 #ifndef ACCESS_ASURFACE_H
 #define ACCESS_ASURFACE_H
 
+#include "common/scummsys.h"
 #include "common/rect.h"
 #include "graphics/surface.h"
 
 namespace Access {
 
 class ASurface : public Graphics::Surface {
+private:
+	byte _scaleTable1[256];
+	byte _scaleTable2[256];
 public:
 	void clearBuffer();
 
 	void copyBuffer(Graphics::Surface *src) { copyFrom(*src); }
+
+	void setScaleTable(int scale);
 };
 
 } // End of namespace Access
diff --git a/engines/access/player.cpp b/engines/access/player.cpp
index a85df03..e4ef0eb 100644
--- a/engines/access/player.cpp
+++ b/engines/access/player.cpp
@@ -44,6 +44,8 @@ Player::Player(AccessEngine *vm): _vm(vm) {
 	_frame = 0;
 
 	_playerOff = false;
+
+	_roomNumber = 0;
 }
 
 void Player::load() {
diff --git a/engines/access/player.h b/engines/access/player.h
index 4d19601..ec6b53f 100644
--- a/engines/access/player.h
+++ b/engines/access/player.h
@@ -60,6 +60,11 @@ public:
 
 	// Additional globals we've added to new Player class
 	bool _playerOff;
+
+	// Additional globals that need to be saved
+	int _roomNumber;
+	Common::Point _rawPlayerLow;
+	Common::Point _rawPlayer;
 public:
 	Player(AccessEngine *vm);
 
diff --git a/engines/access/room.cpp b/engines/access/room.cpp
index 1e9eec7..9ead04b 100644
--- a/engines/access/room.cpp
+++ b/engines/access/room.cpp
@@ -206,7 +206,9 @@ void Room::loadRoomData(const byte *roomData) {
 }
 
 void Room::roomLoop() {
-	// TODO
+	_vm->_scripts->_sequence = 2000;
+	_vm->_scripts->searchForSeq();
+	_vm->_scripts->executeCommand();
 }
 
 
@@ -215,7 +217,44 @@ void Room::doCommands() {
 }
 
 void Room::setupRoom() {
-	// TODO
+	_vm->_screen->setScaleTable(_vm->_scale);
+	_vm->_screen->setBufferScan();
+
+	if (_roomFlag != 2)
+		setIconPalette();
+
+	if (_vm->_screen->_vWindowSize.x == _vm->_playFieldSize.x) {
+		_vm->_screen->_scrollX = 0;
+		_vm->_screen->_scrollCol = 0;
+	} else {
+		_vm->_screen->_scrollX = _vm->_player->_rawPlayer.x -
+			(_vm->_player->_rawPlayer.x >> 4);
+		int xp = MAX((_vm->_player->_rawPlayer.x >> 4) -
+			(_vm->_screen->_vWindowSize.x / 2), 0);
+		_vm->_screen->_scrollCol = xp;
+
+		xp = xp + _vm->_screen->_vWindowSize.x - _vm->_playFieldSize.x;
+		if (xp >= 0) {
+			_vm->_screen->_scrollCol = xp + 1;
+		}
+	}
+	
+	if (_vm->_screen->_vWindowSize.y == _vm->_playFieldSize.y) {
+		_vm->_screen->_scrollY = 0;
+		_vm->_screen->_scrollRow = 0;
+	}
+	else {
+		_vm->_screen->_scrollY = _vm->_player->_rawPlayer.y -
+			(_vm->_player->_rawPlayer.y >> 4);
+		int yp = MAX((_vm->_player->_rawPlayer.y >> 4) -
+			(_vm->_screen->_vWindowSize.y / 2), 0);
+		_vm->_screen->_scrollRow = yp;
+
+		yp = yp + _vm->_screen->_vWindowSize.y - _vm->_playFieldSize.y;
+		if (yp >= 0) {
+			_vm->_screen->_scrollRow = yp + 1;
+		}
+	}
 }
 
 void Room::setWallCodes() {
diff --git a/engines/access/room.h b/engines/access/room.h
index 1b80366..70803b4 100644
--- a/engines/access/room.h
+++ b/engines/access/room.h
@@ -45,6 +45,8 @@ protected:
 	virtual void reloadRoom() = 0;
 
 	virtual void reloadRoom1() = 0;
+
+	virtual void setIconPalette() {}
 public:
 	int _function;
 	int _roomFlag;
diff --git a/engines/access/screen.cpp b/engines/access/screen.cpp
index 3823267..1974b1a 100644
--- a/engines/access/screen.cpp
+++ b/engines/access/screen.cpp
@@ -45,6 +45,9 @@ Screen::Screen(AccessEngine *vm) : _vm(vm) {
 	_scrollFlag = false;
 	_scrollThreshold = 0;
 	_startColor = _numColors = 0;
+	_scrollX = _scrollY = 0;
+	_scrollCol = _scrollRow = 0;
+
 }
 
 void Screen::setDisplayScan() {
diff --git a/engines/access/screen.h b/engines/access/screen.h
index 57d7735..c32ae18 100644
--- a/engines/access/screen.h
+++ b/engines/access/screen.h
@@ -58,6 +58,9 @@ public:
 	bool _scrollFlag;
 	int _scrollThreshold;
 	int _startColor, _numColors;
+	Common::Point _vWindowSize;
+	int _scrollX, _scrollY;
+	int _scrollCol, _scrollRow;
 public:
 	Screen(AccessEngine *vm);
 


Commit: 010ba5b1262f58eabd6e8fbca710309cf7e2c003
    https://github.com/scummvm/scummvm/commit/010ba5b1262f58eabd6e8fbca710309cf7e2c003
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-07T19:43:42-04:00

Commit Message:
ACCESS: Fix reading last resource of container files

Changed paths:
    engines/access/files.cpp



diff --git a/engines/access/files.cpp b/engines/access/files.cpp
index c72d0ad..23171dc 100644
--- a/engines/access/files.cpp
+++ b/engines/access/files.cpp
@@ -141,7 +141,8 @@ void FileManager::setAppended(int fileNum) {
 
 void FileManager::gotoAppended(int subfile) {
 	uint32 offset = _fileIndex[subfile];
-	uint32 size = _fileIndex[subfile + 1] - offset;
+	uint32 size = (subfile == _fileIndex.size() - 1) ? _file.size() - offset :
+		_fileIndex[subfile + 1] - offset;
 
 	_file.seek(offset);
 	delete _stream;


Commit: 0183007d0b4f3b951ef2c704894655e894ce4a71
    https://github.com/scummvm/scummvm/commit/0183007d0b4f3b951ef2c704894655e894ce4a71
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-07T20:31:42-04:00

Commit Message:
ACCESS: Fixes for loading room data

Changed paths:
    engines/access/access.cpp
    engines/access/access.h
    engines/access/files.cpp
    engines/access/room.cpp
    engines/access/room.h
    engines/access/sound.cpp
    engines/access/sound.h



diff --git a/engines/access/access.cpp b/engines/access/access.cpp
index c263ae8..ce5d864 100644
--- a/engines/access/access.cpp
+++ b/engines/access/access.cpp
@@ -198,7 +198,7 @@ int AccessEngine::getRandomNumber(int maxNumber) {
 	return _randomSource.getRandomNumber(maxNumber);
 }
 
-void AccessEngine::loadCells(Common::Array<CellIdent> &cells) {
+void AccessEngine::loadCells(Common::Array<RoomInfo::CellIdent> &cells) {
 	for (uint i = 0; i < cells.size(); ++i) {
 		_objectsTable[cells[i]._cell] = _files->loadFile(
 			cells[i]._fileNum, cells[i]._subfile);
diff --git a/engines/access/access.h b/engines/access/access.h
index 87de9ee..a30c905 100644
--- a/engines/access/access.h
+++ b/engines/access/access.h
@@ -213,7 +213,7 @@ public:
 
 	void freeAnimationData();
 
-	void loadCells(Common::Array<CellIdent> &cells);
+	void loadCells(Common::Array<RoomInfo::CellIdent> &cells);
 
 	/**
 	* Clear the cell table
diff --git a/engines/access/files.cpp b/engines/access/files.cpp
index 23171dc..017102b 100644
--- a/engines/access/files.cpp
+++ b/engines/access/files.cpp
@@ -141,7 +141,7 @@ void FileManager::setAppended(int fileNum) {
 
 void FileManager::gotoAppended(int subfile) {
 	uint32 offset = _fileIndex[subfile];
-	uint32 size = (subfile == _fileIndex.size() - 1) ? _file.size() - offset :
+	uint32 size = (subfile == (int)_fileIndex.size() - 1) ? _file.size() - offset :
 		_fileIndex[subfile + 1] - offset;
 
 	_file.seek(offset);
diff --git a/engines/access/room.cpp b/engines/access/room.cpp
index 9ead04b..afa42c8 100644
--- a/engines/access/room.cpp
+++ b/engines/access/room.cpp
@@ -186,10 +186,13 @@ void Room::loadRoomData(const byte *roomData) {
 	_vm->_scaleI = roomInfo._scaleI;
 	_vm->_screen->_scrollThreshold = roomInfo._scrollThreshold;
 
-	_vm->_screen->_startColor = roomInfo._startColor;
-	_vm->_screen->_numColors = roomInfo._numColors;
-	_vm->_screen->loadPalette(roomInfo._paletteFile._fileNum,
-		roomInfo._paletteFile._subfile);
+	// Handle loading scene palette data
+	if (roomInfo._paletteFile._fileNum != -1) {
+		_vm->_screen->_startColor = roomInfo._startColor;
+		_vm->_screen->_numColors = roomInfo._numColors;
+		_vm->_screen->loadPalette(roomInfo._paletteFile._fileNum,
+			roomInfo._paletteFile._subfile);
+	}
 
 	// Load extra cells
 	_vm->_extraCells.clear();
@@ -270,7 +273,7 @@ void Room::buildScreen() {
 RoomInfo::RoomInfo(const byte *data) {
 	Common::MemoryReadStream stream(data, 999);
 
-	_roomFlag = stream.readByte() != 0;
+	_roomFlag = stream.readByte();
 	_estIndex = (int16)stream.readUint16LE();
 	_musicFile._fileNum = (int16)stream.readUint16LE();
 	_musicFile._subfile = stream.readUint16LE();
@@ -297,8 +300,12 @@ RoomInfo::RoomInfo(const byte *data) {
 	_scrollThreshold = stream.readByte();
 	_paletteFile._fileNum = (int16)stream.readUint16LE();
 	_paletteFile._subfile = stream.readUint16LE();
-	_startColor = stream.readUint16LE();
-	_numColors = stream.readUint16LE();
+	if (_paletteFile._fileNum == -1) {
+		_startColor = _numColors = 0;
+	} else {
+		_startColor = stream.readUint16LE();
+		_numColors = stream.readUint16LE();
+	}
 
 	for (int16 v = (int16)stream.readUint16LE(); v != -1;
 			v = (int16)stream.readUint16LE()) {
@@ -309,9 +316,10 @@ RoomInfo::RoomInfo(const byte *data) {
 
 	for (int16 fileNum = (int16)stream.readUint16LE(); fileNum != -1;
 			fileNum = (int16)stream.readUint16LE()) {
-		FileIdent fi;
+		SoundIdent fi;
 		fi._fileNum = fileNum;
 		fi._subfile = stream.readUint16LE();
+		fi._priority = stream.readUint16LE();
 
 		_sounds.push_back(fi);
 	}
diff --git a/engines/access/room.h b/engines/access/room.h
index 70803b4..c42c3f1 100644
--- a/engines/access/room.h
+++ b/engines/access/room.h
@@ -63,18 +63,23 @@ public:
 	void clearRoom();
 };
 
-struct FileIdent {
-	int _fileNum;
-	int _subfile;
-};
-
-struct CellIdent : FileIdent {
-	byte _cell;
-};
 
 class RoomInfo {
 public:
-	bool _roomFlag;
+	struct FileIdent {
+		int _fileNum;
+		int _subfile;
+	};
+
+	struct CellIdent : FileIdent {
+		byte _cell;
+	};
+	
+	struct SoundIdent : FileIdent {
+		int _priority;
+	};
+public:
+	int _roomFlag;
 	int _estIndex;
 	FileIdent _musicFile;
 	int _scaleH1;
@@ -90,7 +95,7 @@ public:
 	int _startColor;
 	int _numColors;
 	Common::Array<uint32> _vidTable;
-	Common::Array<FileIdent> _sounds;
+	Common::Array<SoundIdent> _sounds;
 public:
 	RoomInfo(const byte *data);
 };
diff --git a/engines/access/sound.cpp b/engines/access/sound.cpp
index 7ac0e4d..c689728 100644
--- a/engines/access/sound.cpp
+++ b/engines/access/sound.cpp
@@ -68,7 +68,7 @@ void SoundManager::playSound(byte *data, uint32 size) {
 		*/
 }
 
-void SoundManager::loadSounds(Common::Array<FileIdent> &sounds) {
+void SoundManager::loadSounds(Common::Array<RoomInfo::SoundIdent> &sounds) {
 	// TODO
 }
 
diff --git a/engines/access/sound.h b/engines/access/sound.h
index a127051..dd94396 100644
--- a/engines/access/sound.h
+++ b/engines/access/sound.h
@@ -60,7 +60,7 @@ public:
 
 	void playSound(int soundIndex);
 
-	void loadSounds(Common::Array<FileIdent> &sounds);
+	void loadSounds(Common::Array<RoomInfo::SoundIdent> &sounds);
 
 	void midiPlay();
 


Commit: 0c38730f3fd4965fbf1b854f76ff936dddf9f931
    https://github.com/scummvm/scummvm/commit/0c38730f3fd4965fbf1b854f76ff936dddf9f931
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-07T21:54:22-04:00

Commit Message:
ACCESS: Implement buildScreen

Changed paths:
    engines/access/data.h
    engines/access/room.cpp
    engines/access/room.h



diff --git a/engines/access/data.h b/engines/access/data.h
index 8b77e7c..cf8394b 100644
--- a/engines/access/data.h
+++ b/engines/access/data.h
@@ -28,6 +28,15 @@
 
 namespace Access {
 
+class AccessEngine;
+
+class Manager {
+protected:
+	AccessEngine *_vm;
+public:
+	Manager(AccessEngine *vm) : _vm(vm) {}
+};
+
 struct TimerEntry {
 	int _initTm;
 	int _timer;
diff --git a/engines/access/room.cpp b/engines/access/room.cpp
index afa42c8..7a07f58 100644
--- a/engines/access/room.cpp
+++ b/engines/access/room.cpp
@@ -26,9 +26,12 @@
 #include "access/resources.h"
 #include "access/room.h"
 
+#define TILE_WIDTH 16
+#define TILE_HEIGHT 16
+
 namespace Access {
 
-Room::Room(AccessEngine *vm) : _vm(vm) {
+Room::Room(AccessEngine *vm) : Manager(vm) {
 	_function = 0;
 	_roomFlag = 0;
 }
@@ -261,11 +264,40 @@ void Room::setupRoom() {
 }
 
 void Room::setWallCodes() {
-	// TODO
+	_jetFrame.clear();
+	_jetFrame.resize(_plotter._walls.size());
+
+	_vm->_player->_rawXTemp = _vm->_player->_rawPlayer.x;
+	_vm->_player->_rawYTemp = _vm->_player->_rawPlayer.y;
 }
 
 void Room::buildScreen() {
-	// TODO
+	int scrollCol = _vm->_screen->_scrollCol;
+	int cnt = _vm->_screen->_vWindowSize.x + 1;
+	int offset = 0;
+
+	for (int idx = 0; idx < cnt, offset += TILE_WIDTH; ++idx) {
+		buildColumn(_vm->_screen->_scrollCol, offset);
+		++_vm->_screen->_scrollCol;
+	}
+
+	_vm->_screen->_scrollCol = scrollCol;
+	_vm->_screen->copyBF1BF2();
+}
+
+void Room::buildColumn(int playX, int screenX) {
+	const byte *pSrc = _vm->_playField + _vm->_screen->_scrollRow * 
+		_vm->_playFieldSize.x + playX;
+	byte *pDest = (byte *)_vm->_buffer1.getPixels();
+
+	for (int y = 0; y <= _vm->_screen->_vWindowSize.y; ++y) {
+		byte *pTile = _vm->_tile + (*pSrc << 8);
+
+		for (int tileY = 0; tileY < TILE_HEIGHT; ++tileY) {
+			Common::copy(pTile, pTile + TILE_WIDTH, pDest);
+			pDest += _vm->_screen->_vWindowSize.x;
+		}
+	}
 }
 
 /*------------------------------------------------------------------------*/
diff --git a/engines/access/room.h b/engines/access/room.h
index c42c3f1..fa41d32 100644
--- a/engines/access/room.h
+++ b/engines/access/room.h
@@ -24,12 +24,34 @@
 #define ACCESS_ROOM_H
 
 #include "common/scummsys.h"
+#include "common/array.h"
+#include "common/rect.h"
+#include "access/data.h"
 
 namespace Access {
 
-class AccessEngine;
+class Plotter {
+public:
+	Common::Array<Common::Rect> _walls;
+	Common::Array<Common::Rect> _blocks;
+	int _blockIn;
+	int _delta;
+};
+
+class JetFrame {
+public:
+	int _wallCode;
+	int _wallCodeOld;
+	int _wallCode1;
+	int _wallCode1Old;
+
+	JetFrame() {
+		_wallCode = _wallCodeOld = 0;
+		_wallCode1 = _wallCode1Old = 0;
+	}
+};
 
-class Room {
+class Room: public Manager {
 private:
 	void roomLoop();
 protected:
@@ -48,6 +70,8 @@ protected:
 
 	virtual void setIconPalette() {}
 public:
+	Plotter _plotter;
+	Common::Array<JetFrame> _jetFrame;
 	int _function;
 	int _roomFlag;
 public:
@@ -61,6 +85,8 @@ public:
 	 * Clear all the data used by the room
 	 */
 	void clearRoom();
+
+	void buildColumn(int playX, int screenX);
 };
 
 


Commit: 6715bb0864212edaf88076dce88e5df1138333da
    https://github.com/scummvm/scummvm/commit/6715bb0864212edaf88076dce88e5df1138333da
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-07T21:59:45-04:00

Commit Message:
ACCESS: Move playField and tile data to Room class

Changed paths:
    engines/access/access.cpp
    engines/access/access.h
    engines/access/room.cpp
    engines/access/room.h



diff --git a/engines/access/access.cpp b/engines/access/access.cpp
index ce5d864..78274f1 100644
--- a/engines/access/access.cpp
+++ b/engines/access/access.cpp
@@ -53,8 +53,6 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc)
 	_inactive = nullptr;
 	_manPal1 = nullptr;
 	_music = nullptr;
-	_playField = nullptr;
-	_tile = nullptr;
 	_anim = nullptr;
 	_title = nullptr;
 	_converseMode = 0;
@@ -142,8 +140,6 @@ AccessEngine::~AccessEngine() {
 	delete[] _inactive;
 	delete[] _manPal1;
 	delete[] _music;
-	delete[] _playField;
-	delete[] _tile;
 	delete[] _anim;
 	delete[] _title;
 }
@@ -221,16 +217,6 @@ void AccessEngine::freeAnimationData() {
 	_anim = nullptr;
 }
 
-void AccessEngine::freePlayField() {
-	delete[] _playField;
-	_playField = nullptr;
-}
-
-void AccessEngine::freeTileData() {
-	delete[] _tile;
-	_tile = nullptr;
-}
-
 void AccessEngine::freeInactiveData() {
 	delete[] _inactive;
 	_inactive = nullptr;
diff --git a/engines/access/access.h b/engines/access/access.h
index a30c905..a009940 100644
--- a/engines/access/access.h
+++ b/engines/access/access.h
@@ -135,9 +135,6 @@ public:
 	byte *_inactive;
 	byte *_manPal1;
 	byte *_music;
-	byte *_playField;
-	Common::Point _playFieldSize;
-	byte *_tile;
 	byte *_anim;
 	byte *_title;
 	int _converseMode;
@@ -226,16 +223,6 @@ public:
 	void freeCells();
 
 	/**
-	 * Free the playfield data
-	 */
-	void freePlayField();
-
-	/**
-	 * Free tile data
-	 */
-	void freeTileData();
-
-	/**
 	 * Free the inactive data
 	 */
 	void freeInactiveData();
diff --git a/engines/access/room.cpp b/engines/access/room.cpp
index 7a07f58..136d602 100644
--- a/engines/access/room.cpp
+++ b/engines/access/room.cpp
@@ -34,6 +34,23 @@ namespace Access {
 Room::Room(AccessEngine *vm) : Manager(vm) {
 	_function = 0;
 	_roomFlag = 0;
+	_playField = nullptr;
+	_tile = nullptr;
+}
+
+Room::~Room() {
+	delete[] _playField;
+	delete[] _tile;
+}
+
+void Room::freePlayField() {
+	delete[] _playField;
+	_playField = nullptr;
+}
+
+void Room::freeTileData() {
+	delete[] _tile;
+	_tile = nullptr;
 }
 
 void Room::doRoom() {
@@ -130,7 +147,7 @@ void Room::clearRoom() {
 	_vm->freeAnimationData();
 	_vm->_scripts->freeScriptData();
 	_vm->freeCells();
-	_vm->freePlayField();
+	freePlayField();
 	_vm->freeInactiveData();
 	_vm->freeManData();
 }
@@ -229,7 +246,7 @@ void Room::setupRoom() {
 	if (_roomFlag != 2)
 		setIconPalette();
 
-	if (_vm->_screen->_vWindowSize.x == _vm->_playFieldSize.x) {
+	if (_vm->_screen->_vWindowSize.x == _playFieldSize.x) {
 		_vm->_screen->_scrollX = 0;
 		_vm->_screen->_scrollCol = 0;
 	} else {
@@ -239,13 +256,13 @@ void Room::setupRoom() {
 			(_vm->_screen->_vWindowSize.x / 2), 0);
 		_vm->_screen->_scrollCol = xp;
 
-		xp = xp + _vm->_screen->_vWindowSize.x - _vm->_playFieldSize.x;
+		xp = xp + _vm->_screen->_vWindowSize.x - _playFieldSize.x;
 		if (xp >= 0) {
 			_vm->_screen->_scrollCol = xp + 1;
 		}
 	}
 	
-	if (_vm->_screen->_vWindowSize.y == _vm->_playFieldSize.y) {
+	if (_vm->_screen->_vWindowSize.y == _playFieldSize.y) {
 		_vm->_screen->_scrollY = 0;
 		_vm->_screen->_scrollRow = 0;
 	}
@@ -256,7 +273,7 @@ void Room::setupRoom() {
 			(_vm->_screen->_vWindowSize.y / 2), 0);
 		_vm->_screen->_scrollRow = yp;
 
-		yp = yp + _vm->_screen->_vWindowSize.y - _vm->_playFieldSize.y;
+		yp = yp + _vm->_screen->_vWindowSize.y - _playFieldSize.y;
 		if (yp >= 0) {
 			_vm->_screen->_scrollRow = yp + 1;
 		}
@@ -286,12 +303,12 @@ void Room::buildScreen() {
 }
 
 void Room::buildColumn(int playX, int screenX) {
-	const byte *pSrc = _vm->_playField + _vm->_screen->_scrollRow * 
-		_vm->_playFieldSize.x + playX;
+	const byte *pSrc = _playField + _vm->_screen->_scrollRow * 
+		_playFieldSize.x + playX;
 	byte *pDest = (byte *)_vm->_buffer1.getPixels();
 
 	for (int y = 0; y <= _vm->_screen->_vWindowSize.y; ++y) {
-		byte *pTile = _vm->_tile + (*pSrc << 8);
+		byte *pTile = _tile + (*pSrc << 8);
 
 		for (int tileY = 0; tileY < TILE_HEIGHT; ++tileY) {
 			Common::copy(pTile, pTile + TILE_WIDTH, pDest);
diff --git a/engines/access/room.h b/engines/access/room.h
index fa41d32..a202e43 100644
--- a/engines/access/room.h
+++ b/engines/access/room.h
@@ -62,6 +62,17 @@ protected:
 	void setWallCodes();
 	void buildScreen();
 
+	/**
+	* Free the playfield data
+	*/
+	void freePlayField();
+
+	/**
+	* Free tile data
+	*/
+	void freeTileData();
+
+
 	virtual void loadRoom(int roomNumber) = 0;
 
 	virtual void reloadRoom() = 0;
@@ -74,9 +85,14 @@ public:
 	Common::Array<JetFrame> _jetFrame;
 	int _function;
 	int _roomFlag;
+	byte *_playField;
+	Common::Point _playFieldSize;
+	byte *_tile;
 public:
 	Room(AccessEngine *vm);
 
+	virtual ~Room();
+
 	void doRoom();
 
 	void doCommands();


Commit: 52721cf2cb666affa7ae7ab952987d51c35fe0e7
    https://github.com/scummvm/scummvm/commit/52721cf2cb666affa7ae7ab952987d51c35fe0e7
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-07T22:04:01-04:00

Commit Message:
ACCESS: General cleanup of Room class

Changed paths:
    engines/access/room.cpp
    engines/access/room.h



diff --git a/engines/access/room.cpp b/engines/access/room.cpp
index 136d602..de9a41c 100644
--- a/engines/access/room.cpp
+++ b/engines/access/room.cpp
@@ -234,11 +234,6 @@ void Room::roomLoop() {
 	_vm->_scripts->executeCommand();
 }
 
-
-void Room::doCommands() {
-	// TODO
-}
-
 void Room::setupRoom() {
 	_vm->_screen->setScaleTable(_vm->_scale);
 	_vm->_screen->setBufferScan();
@@ -374,5 +369,4 @@ RoomInfo::RoomInfo(const byte *data) {
 	}
 };
 
-
 } // End of namespace Access
diff --git a/engines/access/room.h b/engines/access/room.h
index a202e43..c01a753 100644
--- a/engines/access/room.h
+++ b/engines/access/room.h
@@ -55,8 +55,6 @@ class Room: public Manager {
 private:
 	void roomLoop();
 protected:
-	AccessEngine *_vm;
-
 	void loadRoomData(const byte *roomData);
 	void setupRoom();
 	void setWallCodes();
@@ -80,6 +78,8 @@ protected:
 	virtual void reloadRoom1() = 0;
 
 	virtual void setIconPalette() {}
+
+	virtual void doCommands() {}
 public:
 	Plotter _plotter;
 	Common::Array<JetFrame> _jetFrame;
@@ -95,8 +95,6 @@ public:
 
 	void doRoom();
 
-	void doCommands();
-
 	/**
 	 * Clear all the data used by the room
 	 */


Commit: 745aa3daf9934846e183d5c5034d1ec8801fa5bc
    https://github.com/scummvm/scummvm/commit/745aa3daf9934846e183d5c5034d1ec8801fa5bc
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-07T22:53:02-04:00

Commit Message:
ACCESS: Implemented skeleton script command method list

Changed paths:
    engines/access/amazon/amazon_room.cpp
    engines/access/room.cpp
    engines/access/scripts.cpp
    engines/access/scripts.h



diff --git a/engines/access/amazon/amazon_room.cpp b/engines/access/amazon/amazon_room.cpp
index c2a0332..da7b7e1 100644
--- a/engines/access/amazon/amazon_room.cpp
+++ b/engines/access/amazon/amazon_room.cpp
@@ -113,7 +113,7 @@ void AmazonRoom::reloadRoom1() {
 void AmazonRoom::roomSet() {
 	_vm->_numAnimTimers = 0;
 	_vm->_scripts->_sequence = 1000;
-	_vm->_scripts->searchForSeq();
+	_vm->_scripts->searchForSequence();
 	_vm->_scripts->executeCommand();
 }
 
diff --git a/engines/access/room.cpp b/engines/access/room.cpp
index de9a41c..e3e3700 100644
--- a/engines/access/room.cpp
+++ b/engines/access/room.cpp
@@ -230,7 +230,7 @@ void Room::loadRoomData(const byte *roomData) {
 
 void Room::roomLoop() {
 	_vm->_scripts->_sequence = 2000;
-	_vm->_scripts->searchForSeq();
+	_vm->_scripts->searchForSequence();
 	_vm->_scripts->executeCommand();
 }
 
diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp
index bd480b8..6652b29 100644
--- a/engines/access/scripts.cpp
+++ b/engines/access/scripts.cpp
@@ -24,28 +24,146 @@
 #include "access/access.h"
 #include "access/scripts.h"
 
+#define SCRIPT_START_BYTE 0xE0
+
 namespace Access {
 
+const ScriptMethodPtr COMMAND_LIST[] = {
+	&Scripts::CMDENDOBJECT, &Scripts::CMDJUMPLOOK, &Scripts::CMDJUMPHELP, &Scripts::CMDJUMPGET, &Scripts::CMDJUMPMOVE, 
+	&Scripts::CMDJUMPUSE, &Scripts::CMDJUMPTALK, &Scripts::CMDNULL, &Scripts::CMDPRINT, &Scripts::CMDRETPOS, &Scripts::CMDANIM, 
+	&Scripts::CMDSETFLAG, &Scripts::CMDCHECKFLAG, &Scripts::CMDGOTO, &Scripts::CMDSETINV, &Scripts::CMDSETINV, 
+	&Scripts::CMDCHECKINV, &Scripts::CMDSETTEX, &Scripts::CMDNEWROOM, &Scripts::CMDCONVERSE, &Scripts::CMDCHECKFRAME, 
+	&Scripts::CMDCHECKANIM, &Scripts::CMDSND, &Scripts::CMDRETNEG, &Scripts::CMDRETPOS, &Scripts::CMDCHECKLOC, &Scripts::CMDSETANIM, 
+	&Scripts::CMDDISPINV, &Scripts::CMDSETTIMER, &Scripts::CMDSETTIMER, &Scripts::CMDCHECKTIMER, &Scripts::CMDSETTRAVEL, 
+	&Scripts::CMDSETTRAVEL, &Scripts::CMDSETVID, &Scripts::CMDPLAYVID, &Scripts::CMDPLOTIMAGE, &Scripts::CMDSETDISPLAY, 
+	&Scripts::CMDSETBUFFER, &Scripts::CMDSETSCROLL, &Scripts::CMDSAVERECT, &Scripts::CMDSAVERECT, &Scripts::CMDSETBUFVID, 
+	&Scripts::CMDPLAYBUFVID, &Scripts::CMDREMOVELAST, &Scripts::CMDSPECIAL, &Scripts::CMDSPECIAL, &Scripts::CMDSPECIAL, 
+	&Scripts::CMDSETCYCLE, &Scripts::CMDCYCLE, &Scripts::CMDCHARSPEAK, &Scripts::CMDTEXSPEAK, &Scripts::CMDTEXCHOICE, 
+	&Scripts::CMDWAIT, &Scripts::CMDSETCONPOS, &Scripts::CMDCHECKVFRAME, &Scripts::CMDJUMPCHOICE, &Scripts::CMDRETURNCHOICE, 
+	&Scripts::CMDCLEARBLOCK, &Scripts::CMDLOADSOUND, &Scripts::CMDFREESOUND, &Scripts::CMDSETVIDSND, &Scripts::CMDPLAYVIDSND, 
+	&Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, 
+	&Scripts::CMDPUSHLOCATION, &Scripts::CMDPLAYEROFF, &Scripts::CMDPLAYERON, &Scripts::CMDDEAD, &Scripts::CMDFADEOUT, 
+	&Scripts::CMDENDVID, &Scripts::CMDHELP, &Scripts::CMDCYCLEBACK, &Scripts::CMDCHAPTER, &Scripts::CMDSETHELP, &Scripts::CMDCENTERPANEL, 
+	&Scripts::CMDMAINPANEL, &Scripts::CMDRETFLASH
+};
+
 Scripts::Scripts(AccessEngine *vm) : _vm(vm) {
+	_commandList = COMMAND_LIST;
+
 	_script = nullptr;
+	_scriptLoc = nullptr;
 	_sequence = 0;
+	_endFlag = false;
+	_returnCode = 0;
 }
 
 Scripts::~Scripts() {
 	freeScriptData();
 }
 
-void Scripts::searchForSeq() {
-	// TODO
+void Scripts::freeScriptData() {
+	delete[] _script;
+	_script = nullptr;
 }
 
-void Scripts::executeCommand() {
-	// TODO
+void Scripts::searchForSequence() {
+	assert(_script);
+	byte *pSrc = _script;
+	int sequenceId;
+	do {
+		while (*pSrc++ != SCRIPT_START_BYTE) ;
+		sequenceId = READ_LE_UINT16(pSrc);
+		pSrc += 2;
+	} while (sequenceId != _sequence);
+
+	_scriptLoc = pSrc;
 }
 
-void Scripts::freeScriptData() {
-	delete[] _script;
-	_script = nullptr;
+int Scripts::executeCommand() {
+	assert(_scriptLoc);
+	_endFlag = 0;
+	_returnCode = 0;
+
+	do {
+		byte *pSrc = _scriptLoc;
+		for (pSrc = _scriptLoc; *pSrc == SCRIPT_START_BYTE; pSrc += 3) ;	
+		_scriptCommand = *pSrc++;
+
+		(this->*_commandList[_scriptCommand - 0x80])();
+		_scriptLoc = pSrc;
+	} while (!_endFlag);
+
+	return _returnCode;
 }
 
+void Scripts::CMDENDOBJECT() { }
+void Scripts::CMDJUMPLOOK() { }
+void Scripts::CMDJUMPHELP() { }
+void Scripts::CMDJUMPGET() { }
+void Scripts::CMDJUMPMOVE() { }
+void Scripts::CMDJUMPUSE() { }
+void Scripts::CMDJUMPTALK() { }
+void Scripts::CMDNULL() { }
+void Scripts::CMDPRINT() { }
+void Scripts::CMDRETPOS() { }
+void Scripts::CMDANIM() { }
+void Scripts::CMDSETFLAG() { }
+void Scripts::CMDCHECKFLAG() { }
+void Scripts::CMDGOTO() { }
+void Scripts::CMDSETINV() { }
+void Scripts::CMDCHECKINV() { }
+void Scripts::CMDSETTEX() { }
+void Scripts::CMDNEWROOM() { }
+void Scripts::CMDCONVERSE() { }
+void Scripts::CMDCHECKFRAME() { }
+void Scripts::CMDCHECKANIM() { }
+void Scripts::CMDSND() { }
+void Scripts::CMDRETNEG() { }
+void Scripts::CMDCHECKLOC() { }
+void Scripts::CMDSETANIM() { }
+void Scripts::CMDDISPINV() { }
+void Scripts::CMDSETTIMER() { }
+void Scripts::CMDCHECKTIMER() { }
+void Scripts::CMDSETTRAVEL() { }
+void Scripts::CMDSETVID() { }
+void Scripts::CMDPLAYVID() { }
+void Scripts::CMDPLOTIMAGE() { }
+void Scripts::CMDSETDISPLAY() { }
+void Scripts::CMDSETBUFFER() { }
+void Scripts::CMDSETSCROLL() { }
+void Scripts::CMDSAVERECT() { }
+void Scripts::CMDSETBUFVID() { }
+void Scripts::CMDPLAYBUFVID() { }
+void Scripts::CMDREMOVELAST() { }
+void Scripts::CMDSPECIAL() { }
+void Scripts::CMDSETCYCLE() { }
+void Scripts::CMDCYCLE() { }
+void Scripts::CMDCHARSPEAK() { }
+void Scripts::CMDTEXSPEAK() { }
+void Scripts::CMDTEXCHOICE() { }
+void Scripts::CMDWAIT() { }
+void Scripts::CMDSETCONPOS() { }
+void Scripts::CMDCHECKVFRAME() { }
+void Scripts::CMDJUMPCHOICE() { }
+void Scripts::CMDRETURNCHOICE() { }
+void Scripts::CMDCLEARBLOCK() { }
+void Scripts::CMDLOADSOUND() { }
+void Scripts::CMDFREESOUND() { }
+void Scripts::CMDSETVIDSND() { }
+void Scripts::CMDPLAYVIDSND() { }
+void Scripts::CMDPUSHLOCATION() { }
+void Scripts::CMDPLAYEROFF() { }
+void Scripts::CMDPLAYERON() { }
+void Scripts::CMDDEAD() { }
+void Scripts::CMDFADEOUT() { }
+void Scripts::CMDENDVID() { }
+void Scripts::CMDHELP() { }
+void Scripts::CMDCYCLEBACK() { }
+void Scripts::CMDCHAPTER() { }
+void Scripts::CMDSETHELP() { }
+void Scripts::CMDCENTERPANEL() { }
+void Scripts::CMDMAINPANEL() { }
+void Scripts::CMDRETFLASH() { }
+
+
 } // End of namespace Access
diff --git a/engines/access/scripts.h b/engines/access/scripts.h
index 995f129..99e3538 100644
--- a/engines/access/scripts.h
+++ b/engines/access/scripts.h
@@ -28,23 +28,100 @@
 namespace Access {
 
 class AccessEngine;
+class Scripts;
+
+typedef void(Scripts::*ScriptMethodPtr)();
 
 class Scripts {
 protected:
 	AccessEngine *_vm;
+	const ScriptMethodPtr *_commandList;
+public:
+	void CMDENDOBJECT();
+	void CMDJUMPLOOK();
+	void CMDJUMPHELP();
+	void CMDJUMPGET();
+	void CMDJUMPMOVE();
+	void CMDJUMPUSE();
+	void CMDJUMPTALK();
+	void CMDNULL();
+	void CMDPRINT();
+	void CMDRETPOS();
+	void CMDANIM();
+	void CMDSETFLAG();
+	void CMDCHECKFLAG();
+	void CMDGOTO();
+	void CMDSETINV();
+	void CMDCHECKINV();
+	void CMDSETTEX();
+	void CMDNEWROOM();
+	void CMDCONVERSE();
+	void CMDCHECKFRAME();
+	void CMDCHECKANIM();
+	void CMDSND();
+	void CMDRETNEG();
+	void CMDCHECKLOC();
+	void CMDSETANIM();
+	void CMDDISPINV();
+	void CMDSETTIMER();
+	void CMDCHECKTIMER();
+	void CMDSETTRAVEL();
+	void CMDSETVID();
+	void CMDPLAYVID();
+	void CMDPLOTIMAGE();
+	void CMDSETDISPLAY();
+	void CMDSETBUFFER();
+	void CMDSETSCROLL();
+	void CMDSAVERECT();
+	void CMDSETBUFVID();
+	void CMDPLAYBUFVID();
+	void CMDREMOVELAST();
+	void CMDSPECIAL();
+	void CMDSETCYCLE();
+	void CMDCYCLE();
+	void CMDCHARSPEAK();
+	void CMDTEXSPEAK();
+	void CMDTEXCHOICE();
+	void CMDWAIT();
+	void CMDSETCONPOS();
+	void CMDCHECKVFRAME();
+	void CMDJUMPCHOICE();
+	void CMDRETURNCHOICE();
+	void CMDCLEARBLOCK();
+	void CMDLOADSOUND();
+	void CMDFREESOUND();
+	void CMDSETVIDSND();
+	void CMDPLAYVIDSND();
+	void CMDPUSHLOCATION();
+	void CMDPLAYEROFF();
+	void CMDPLAYERON();
+	void CMDDEAD();
+	void CMDFADEOUT();
+	void CMDENDVID();
+	void CMDHELP();
+	void CMDCYCLEBACK();
+	void CMDCHAPTER();
+	void CMDSETHELP();
+	void CMDCENTERPANEL();
+	void CMDMAINPANEL();
+	void CMDRETFLASH();
 public:
 	byte *_script;
+	byte *_scriptLoc;
 	int _sequence;
+	bool _endFlag;
+	int _returnCode;
+	int _scriptCommand;
 public:
 	Scripts(AccessEngine *vm);
 
 	virtual ~Scripts();
 
-	void searchForSeq();
-	
-	void executeCommand();
-
 	void freeScriptData();
+
+	void searchForSequence();
+	
+	int executeCommand();
 };
 
 } // End of namespace Access


Commit: 9aefd90939de855fa5533a9501b0d23e109cc385
    https://github.com/scummvm/scummvm/commit/9aefd90939de855fa5533a9501b0d23e109cc385
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-08T09:13:41-04:00

Commit Message:
ACCESS: Fix opening files by name

Changed paths:
    engines/access/files.cpp



diff --git a/engines/access/files.cpp b/engines/access/files.cpp
index 017102b..1ebc2fa 100644
--- a/engines/access/files.cpp
+++ b/engines/access/files.cpp
@@ -66,7 +66,7 @@ void FileManager::openFile(const Common::String &filename) {
 	// Open up the file
 	_fileNumber = -1;
 	_file.close();
-	if (_file.open(filename))
+	if (!_file.open(filename))
 		error("Could not open file - %s", filename.c_str());
 
 	_filesize = _file.size();


Commit: 80c8fbe024230aaba63d93f9a2ff1c1bf25ae922
    https://github.com/scummvm/scummvm/commit/80c8fbe024230aaba63d93f9a2ff1c1bf25ae922
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-08T09:19:38-04:00

Commit Message:
ACCESS: Simplify command list array to use a virtual method

Changed paths:
    engines/access/amazon/amazon_room.cpp
    engines/access/room.cpp
    engines/access/scripts.cpp
    engines/access/scripts.h



diff --git a/engines/access/amazon/amazon_room.cpp b/engines/access/amazon/amazon_room.cpp
index da7b7e1..df2a6b7 100644
--- a/engines/access/amazon/amazon_room.cpp
+++ b/engines/access/amazon/amazon_room.cpp
@@ -114,7 +114,7 @@ void AmazonRoom::roomSet() {
 	_vm->_numAnimTimers = 0;
 	_vm->_scripts->_sequence = 1000;
 	_vm->_scripts->searchForSequence();
-	_vm->_scripts->executeCommand();
+	_vm->_scripts->executeScript();
 }
 
 void AmazonRoom::roomMenu() {
diff --git a/engines/access/room.cpp b/engines/access/room.cpp
index e3e3700..80ab332 100644
--- a/engines/access/room.cpp
+++ b/engines/access/room.cpp
@@ -231,7 +231,7 @@ void Room::loadRoomData(const byte *roomData) {
 void Room::roomLoop() {
 	_vm->_scripts->_sequence = 2000;
 	_vm->_scripts->searchForSequence();
-	_vm->_scripts->executeCommand();
+	_vm->_scripts->executeScript();
 }
 
 void Room::setupRoom() {
diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp
index 6652b29..6513f34 100644
--- a/engines/access/scripts.cpp
+++ b/engines/access/scripts.cpp
@@ -28,28 +28,7 @@
 
 namespace Access {
 
-const ScriptMethodPtr COMMAND_LIST[] = {
-	&Scripts::CMDENDOBJECT, &Scripts::CMDJUMPLOOK, &Scripts::CMDJUMPHELP, &Scripts::CMDJUMPGET, &Scripts::CMDJUMPMOVE, 
-	&Scripts::CMDJUMPUSE, &Scripts::CMDJUMPTALK, &Scripts::CMDNULL, &Scripts::CMDPRINT, &Scripts::CMDRETPOS, &Scripts::CMDANIM, 
-	&Scripts::CMDSETFLAG, &Scripts::CMDCHECKFLAG, &Scripts::CMDGOTO, &Scripts::CMDSETINV, &Scripts::CMDSETINV, 
-	&Scripts::CMDCHECKINV, &Scripts::CMDSETTEX, &Scripts::CMDNEWROOM, &Scripts::CMDCONVERSE, &Scripts::CMDCHECKFRAME, 
-	&Scripts::CMDCHECKANIM, &Scripts::CMDSND, &Scripts::CMDRETNEG, &Scripts::CMDRETPOS, &Scripts::CMDCHECKLOC, &Scripts::CMDSETANIM, 
-	&Scripts::CMDDISPINV, &Scripts::CMDSETTIMER, &Scripts::CMDSETTIMER, &Scripts::CMDCHECKTIMER, &Scripts::CMDSETTRAVEL, 
-	&Scripts::CMDSETTRAVEL, &Scripts::CMDSETVID, &Scripts::CMDPLAYVID, &Scripts::CMDPLOTIMAGE, &Scripts::CMDSETDISPLAY, 
-	&Scripts::CMDSETBUFFER, &Scripts::CMDSETSCROLL, &Scripts::CMDSAVERECT, &Scripts::CMDSAVERECT, &Scripts::CMDSETBUFVID, 
-	&Scripts::CMDPLAYBUFVID, &Scripts::CMDREMOVELAST, &Scripts::CMDSPECIAL, &Scripts::CMDSPECIAL, &Scripts::CMDSPECIAL, 
-	&Scripts::CMDSETCYCLE, &Scripts::CMDCYCLE, &Scripts::CMDCHARSPEAK, &Scripts::CMDTEXSPEAK, &Scripts::CMDTEXCHOICE, 
-	&Scripts::CMDWAIT, &Scripts::CMDSETCONPOS, &Scripts::CMDCHECKVFRAME, &Scripts::CMDJUMPCHOICE, &Scripts::CMDRETURNCHOICE, 
-	&Scripts::CMDCLEARBLOCK, &Scripts::CMDLOADSOUND, &Scripts::CMDFREESOUND, &Scripts::CMDSETVIDSND, &Scripts::CMDPLAYVIDSND, 
-	&Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, 
-	&Scripts::CMDPUSHLOCATION, &Scripts::CMDPLAYEROFF, &Scripts::CMDPLAYERON, &Scripts::CMDDEAD, &Scripts::CMDFADEOUT, 
-	&Scripts::CMDENDVID, &Scripts::CMDHELP, &Scripts::CMDCYCLEBACK, &Scripts::CMDCHAPTER, &Scripts::CMDSETHELP, &Scripts::CMDCENTERPANEL, 
-	&Scripts::CMDMAINPANEL, &Scripts::CMDRETFLASH
-};
-
 Scripts::Scripts(AccessEngine *vm) : _vm(vm) {
-	_commandList = COMMAND_LIST;
-
 	_script = nullptr;
 	_scriptLoc = nullptr;
 	_sequence = 0;
@@ -79,7 +58,7 @@ void Scripts::searchForSequence() {
 	_scriptLoc = pSrc;
 }
 
-int Scripts::executeCommand() {
+int Scripts::executeScript() {
 	assert(_scriptLoc);
 	_endFlag = 0;
 	_returnCode = 0;
@@ -89,13 +68,36 @@ int Scripts::executeCommand() {
 		for (pSrc = _scriptLoc; *pSrc == SCRIPT_START_BYTE; pSrc += 3) ;	
 		_scriptCommand = *pSrc++;
 
-		(this->*_commandList[_scriptCommand - 0x80])();
+		executeCommand(_scriptCommand - 0x80);
 		_scriptLoc = pSrc;
 	} while (!_endFlag);
 
 	return _returnCode;
 }
 
+void Scripts::executeCommand(int commandIndex) {
+	static const ScriptMethodPtr COMMAND_LIST[] = {
+		&Scripts::CMDENDOBJECT, &Scripts::CMDJUMPLOOK, &Scripts::CMDJUMPHELP, &Scripts::CMDJUMPGET, &Scripts::CMDJUMPMOVE,
+		&Scripts::CMDJUMPUSE, &Scripts::CMDJUMPTALK, &Scripts::CMDNULL, &Scripts::CMDPRINT, &Scripts::CMDRETPOS, &Scripts::CMDANIM,
+		&Scripts::CMDSETFLAG, &Scripts::CMDCHECKFLAG, &Scripts::CMDGOTO, &Scripts::CMDSETINV, &Scripts::CMDSETINV,
+		&Scripts::CMDCHECKINV, &Scripts::CMDSETTEX, &Scripts::CMDNEWROOM, &Scripts::CMDCONVERSE, &Scripts::CMDCHECKFRAME,
+		&Scripts::CMDCHECKANIM, &Scripts::CMDSND, &Scripts::CMDRETNEG, &Scripts::CMDRETPOS, &Scripts::CMDCHECKLOC, &Scripts::CMDSETANIM,
+		&Scripts::CMDDISPINV, &Scripts::CMDSETTIMER, &Scripts::CMDSETTIMER, &Scripts::CMDCHECKTIMER, &Scripts::CMDSETTRAVEL,
+		&Scripts::CMDSETTRAVEL, &Scripts::CMDSETVID, &Scripts::CMDPLAYVID, &Scripts::CMDPLOTIMAGE, &Scripts::CMDSETDISPLAY,
+		&Scripts::CMDSETBUFFER, &Scripts::CMDSETSCROLL, &Scripts::CMDSAVERECT, &Scripts::CMDSAVERECT, &Scripts::CMDSETBUFVID,
+		&Scripts::CMDPLAYBUFVID, &Scripts::CMDREMOVELAST, &Scripts::CMDSPECIAL, &Scripts::CMDSPECIAL, &Scripts::CMDSPECIAL,
+		&Scripts::CMDSETCYCLE, &Scripts::CMDCYCLE, &Scripts::CMDCHARSPEAK, &Scripts::CMDTEXSPEAK, &Scripts::CMDTEXCHOICE,
+		&Scripts::CMDWAIT, &Scripts::CMDSETCONPOS, &Scripts::CMDCHECKVFRAME, &Scripts::CMDJUMPCHOICE, &Scripts::CMDRETURNCHOICE,
+		&Scripts::CMDCLEARBLOCK, &Scripts::CMDLOADSOUND, &Scripts::CMDFREESOUND, &Scripts::CMDSETVIDSND, &Scripts::CMDPLAYVIDSND,
+		&Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION,
+		&Scripts::CMDPUSHLOCATION, &Scripts::CMDPLAYEROFF, &Scripts::CMDPLAYERON, &Scripts::CMDDEAD, &Scripts::CMDFADEOUT,
+		&Scripts::CMDENDVID, &Scripts::CMDHELP, &Scripts::CMDCYCLEBACK, &Scripts::CMDCHAPTER, &Scripts::CMDSETHELP, &Scripts::CMDCENTERPANEL,
+		&Scripts::CMDMAINPANEL, &Scripts::CMDRETFLASH
+	};
+
+	(this->*COMMAND_LIST[commandIndex])();
+}
+
 void Scripts::CMDENDOBJECT() { }
 void Scripts::CMDJUMPLOOK() { }
 void Scripts::CMDJUMPHELP() { }
diff --git a/engines/access/scripts.h b/engines/access/scripts.h
index 99e3538..b9c8b2c 100644
--- a/engines/access/scripts.h
+++ b/engines/access/scripts.h
@@ -35,8 +35,8 @@ typedef void(Scripts::*ScriptMethodPtr)();
 class Scripts {
 protected:
 	AccessEngine *_vm;
-	const ScriptMethodPtr *_commandList;
-public:
+
+	virtual void executeCommand(int commandIndex);
 	void CMDENDOBJECT();
 	void CMDJUMPLOOK();
 	void CMDJUMPHELP();
@@ -121,7 +121,7 @@ public:
 
 	void searchForSequence();
 	
-	int executeCommand();
+	int executeScript();
 };
 
 } // End of namespace Access


Commit: fb0a1f5597145581cf082f0ef3ffcf9bea141cc9
    https://github.com/scummvm/scummvm/commit/fb0a1f5597145581cf082f0ef3ffcf9bea141cc9
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-08T09:30:16-04:00

Commit Message:
ACCESS: Implemented cmdGoto script command

Changed paths:
    engines/access/scripts.cpp
    engines/access/scripts.h



diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp
index 6513f34..337aa43 100644
--- a/engines/access/scripts.cpp
+++ b/engines/access/scripts.cpp
@@ -45,9 +45,9 @@ void Scripts::freeScriptData() {
 	_script = nullptr;
 }
 
-void Scripts::searchForSequence() {
+const byte *Scripts::searchForSequence() {
 	assert(_script);
-	byte *pSrc = _script;
+	const byte *pSrc = _script;
 	int sequenceId;
 	do {
 		while (*pSrc++ != SCRIPT_START_BYTE) ;
@@ -56,6 +56,7 @@ void Scripts::searchForSequence() {
 	} while (sequenceId != _sequence);
 
 	_scriptLoc = pSrc;
+	return pSrc;
 }
 
 int Scripts::executeScript() {
@@ -64,22 +65,22 @@ int Scripts::executeScript() {
 	_returnCode = 0;
 
 	do {
-		byte *pSrc = _scriptLoc;
+		const byte *pSrc = _scriptLoc;
 		for (pSrc = _scriptLoc; *pSrc == SCRIPT_START_BYTE; pSrc += 3) ;	
 		_scriptCommand = *pSrc++;
 
-		executeCommand(_scriptCommand - 0x80);
+		executeCommand(_scriptCommand - 0x80, pSrc);
 		_scriptLoc = pSrc;
 	} while (!_endFlag);
 
 	return _returnCode;
 }
 
-void Scripts::executeCommand(int commandIndex) {
+void Scripts::executeCommand(int commandIndex, const byte *&pScript) {
 	static const ScriptMethodPtr COMMAND_LIST[] = {
 		&Scripts::CMDENDOBJECT, &Scripts::CMDJUMPLOOK, &Scripts::CMDJUMPHELP, &Scripts::CMDJUMPGET, &Scripts::CMDJUMPMOVE,
 		&Scripts::CMDJUMPUSE, &Scripts::CMDJUMPTALK, &Scripts::CMDNULL, &Scripts::CMDPRINT, &Scripts::CMDRETPOS, &Scripts::CMDANIM,
-		&Scripts::CMDSETFLAG, &Scripts::CMDCHECKFLAG, &Scripts::CMDGOTO, &Scripts::CMDSETINV, &Scripts::CMDSETINV,
+		&Scripts::CMDSETFLAG, &Scripts::CMDCHECKFLAG, &Scripts::cmdGoto, &Scripts::CMDSETINV, &Scripts::CMDSETINV,
 		&Scripts::CMDCHECKINV, &Scripts::CMDSETTEX, &Scripts::CMDNEWROOM, &Scripts::CMDCONVERSE, &Scripts::CMDCHECKFRAME,
 		&Scripts::CMDCHECKANIM, &Scripts::CMDSND, &Scripts::CMDRETNEG, &Scripts::CMDRETPOS, &Scripts::CMDCHECKLOC, &Scripts::CMDSETANIM,
 		&Scripts::CMDDISPINV, &Scripts::CMDSETTIMER, &Scripts::CMDSETTIMER, &Scripts::CMDCHECKTIMER, &Scripts::CMDSETTRAVEL,
@@ -95,77 +96,82 @@ void Scripts::executeCommand(int commandIndex) {
 		&Scripts::CMDMAINPANEL, &Scripts::CMDRETFLASH
 	};
 
-	(this->*COMMAND_LIST[commandIndex])();
+	(this->*COMMAND_LIST[commandIndex])(pScript);
 }
 
-void Scripts::CMDENDOBJECT() { }
-void Scripts::CMDJUMPLOOK() { }
-void Scripts::CMDJUMPHELP() { }
-void Scripts::CMDJUMPGET() { }
-void Scripts::CMDJUMPMOVE() { }
-void Scripts::CMDJUMPUSE() { }
-void Scripts::CMDJUMPTALK() { }
-void Scripts::CMDNULL() { }
-void Scripts::CMDPRINT() { }
-void Scripts::CMDRETPOS() { }
-void Scripts::CMDANIM() { }
-void Scripts::CMDSETFLAG() { }
-void Scripts::CMDCHECKFLAG() { }
-void Scripts::CMDGOTO() { }
-void Scripts::CMDSETINV() { }
-void Scripts::CMDCHECKINV() { }
-void Scripts::CMDSETTEX() { }
-void Scripts::CMDNEWROOM() { }
-void Scripts::CMDCONVERSE() { }
-void Scripts::CMDCHECKFRAME() { }
-void Scripts::CMDCHECKANIM() { }
-void Scripts::CMDSND() { }
-void Scripts::CMDRETNEG() { }
-void Scripts::CMDCHECKLOC() { }
-void Scripts::CMDSETANIM() { }
-void Scripts::CMDDISPINV() { }
-void Scripts::CMDSETTIMER() { }
-void Scripts::CMDCHECKTIMER() { }
-void Scripts::CMDSETTRAVEL() { }
-void Scripts::CMDSETVID() { }
-void Scripts::CMDPLAYVID() { }
-void Scripts::CMDPLOTIMAGE() { }
-void Scripts::CMDSETDISPLAY() { }
-void Scripts::CMDSETBUFFER() { }
-void Scripts::CMDSETSCROLL() { }
-void Scripts::CMDSAVERECT() { }
-void Scripts::CMDSETBUFVID() { }
-void Scripts::CMDPLAYBUFVID() { }
-void Scripts::CMDREMOVELAST() { }
-void Scripts::CMDSPECIAL() { }
-void Scripts::CMDSETCYCLE() { }
-void Scripts::CMDCYCLE() { }
-void Scripts::CMDCHARSPEAK() { }
-void Scripts::CMDTEXSPEAK() { }
-void Scripts::CMDTEXCHOICE() { }
-void Scripts::CMDWAIT() { }
-void Scripts::CMDSETCONPOS() { }
-void Scripts::CMDCHECKVFRAME() { }
-void Scripts::CMDJUMPCHOICE() { }
-void Scripts::CMDRETURNCHOICE() { }
-void Scripts::CMDCLEARBLOCK() { }
-void Scripts::CMDLOADSOUND() { }
-void Scripts::CMDFREESOUND() { }
-void Scripts::CMDSETVIDSND() { }
-void Scripts::CMDPLAYVIDSND() { }
-void Scripts::CMDPUSHLOCATION() { }
-void Scripts::CMDPLAYEROFF() { }
-void Scripts::CMDPLAYERON() { }
-void Scripts::CMDDEAD() { }
-void Scripts::CMDFADEOUT() { }
-void Scripts::CMDENDVID() { }
-void Scripts::CMDHELP() { }
-void Scripts::CMDCYCLEBACK() { }
-void Scripts::CMDCHAPTER() { }
-void Scripts::CMDSETHELP() { }
-void Scripts::CMDCENTERPANEL() { }
-void Scripts::CMDMAINPANEL() { }
-void Scripts::CMDRETFLASH() { }
+void Scripts::CMDENDOBJECT(const byte *&pScript) { }
+void Scripts::CMDJUMPLOOK(const byte *&pScript) { }
+void Scripts::CMDJUMPHELP(const byte *&pScript) { }
+void Scripts::CMDJUMPGET(const byte *&pScript) { }
+void Scripts::CMDJUMPMOVE(const byte *&pScript) { }
+void Scripts::CMDJUMPUSE(const byte *&pScript) { }
+void Scripts::CMDJUMPTALK(const byte *&pScript) { }
+void Scripts::CMDNULL(const byte *&pScript) { }
+void Scripts::CMDPRINT(const byte *&pScript) { }
+void Scripts::CMDRETPOS(const byte *&pScript) { }
+void Scripts::CMDANIM(const byte *&pScript) { }
+void Scripts::CMDSETFLAG(const byte *&pScript) { }
+void Scripts::CMDCHECKFLAG(const byte *&pScript) { }
+
+void Scripts::cmdGoto(const byte *&pScript) { 
+	_sequence = READ_LE_UINT16(pScript);
+	pScript = searchForSequence();
+}
+
+void Scripts::CMDSETINV(const byte *&pScript) { }
+void Scripts::CMDCHECKINV(const byte *&pScript) { }
+void Scripts::CMDSETTEX(const byte *&pScript) { }
+void Scripts::CMDNEWROOM(const byte *&pScript) { }
+void Scripts::CMDCONVERSE(const byte *&pScript) { }
+void Scripts::CMDCHECKFRAME(const byte *&pScript) { }
+void Scripts::CMDCHECKANIM(const byte *&pScript) { }
+void Scripts::CMDSND(const byte *&pScript) { }
+void Scripts::CMDRETNEG(const byte *&pScript) { }
+void Scripts::CMDCHECKLOC(const byte *&pScript) { }
+void Scripts::CMDSETANIM(const byte *&pScript) { }
+void Scripts::CMDDISPINV(const byte *&pScript) { }
+void Scripts::CMDSETTIMER(const byte *&pScript) { }
+void Scripts::CMDCHECKTIMER(const byte *&pScript) { }
+void Scripts::CMDSETTRAVEL(const byte *&pScript) { }
+void Scripts::CMDSETVID(const byte *&pScript) { }
+void Scripts::CMDPLAYVID(const byte *&pScript) { }
+void Scripts::CMDPLOTIMAGE(const byte *&pScript) { }
+void Scripts::CMDSETDISPLAY(const byte *&pScript) { }
+void Scripts::CMDSETBUFFER(const byte *&pScript) { }
+void Scripts::CMDSETSCROLL(const byte *&pScript) { }
+void Scripts::CMDSAVERECT(const byte *&pScript) { }
+void Scripts::CMDSETBUFVID(const byte *&pScript) { }
+void Scripts::CMDPLAYBUFVID(const byte *&pScript) { }
+void Scripts::CMDREMOVELAST(const byte *&pScript) { }
+void Scripts::CMDSPECIAL(const byte *&pScript) { }
+void Scripts::CMDSETCYCLE(const byte *&pScript) { }
+void Scripts::CMDCYCLE(const byte *&pScript) { }
+void Scripts::CMDCHARSPEAK(const byte *&pScript) { }
+void Scripts::CMDTEXSPEAK(const byte *&pScript) { }
+void Scripts::CMDTEXCHOICE(const byte *&pScript) { }
+void Scripts::CMDWAIT(const byte *&pScript) { }
+void Scripts::CMDSETCONPOS(const byte *&pScript) { }
+void Scripts::CMDCHECKVFRAME(const byte *&pScript) { }
+void Scripts::CMDJUMPCHOICE(const byte *&pScript) { }
+void Scripts::CMDRETURNCHOICE(const byte *&pScript) { }
+void Scripts::CMDCLEARBLOCK(const byte *&pScript) { }
+void Scripts::CMDLOADSOUND(const byte *&pScript) { }
+void Scripts::CMDFREESOUND(const byte *&pScript) { }
+void Scripts::CMDSETVIDSND(const byte *&pScript) { }
+void Scripts::CMDPLAYVIDSND(const byte *&pScript) { }
+void Scripts::CMDPUSHLOCATION(const byte *&pScript) { }
+void Scripts::CMDPLAYEROFF(const byte *&pScript) { }
+void Scripts::CMDPLAYERON(const byte *&pScript) { }
+void Scripts::CMDDEAD(const byte *&pScript) { }
+void Scripts::CMDFADEOUT(const byte *&pScript) { }
+void Scripts::CMDENDVID(const byte *&pScript) { }
+void Scripts::CMDHELP(const byte *&pScript) { }
+void Scripts::CMDCYCLEBACK(const byte *&pScript) { }
+void Scripts::CMDCHAPTER(const byte *&pScript) { }
+void Scripts::CMDSETHELP(const byte *&pScript) { }
+void Scripts::CMDCENTERPANEL(const byte *&pScript) { }
+void Scripts::CMDMAINPANEL(const byte *&pScript) { }
+void Scripts::CMDRETFLASH(const byte *&pScript) { }
 
 
 } // End of namespace Access
diff --git a/engines/access/scripts.h b/engines/access/scripts.h
index b9c8b2c..fc75e9e 100644
--- a/engines/access/scripts.h
+++ b/engines/access/scripts.h
@@ -30,84 +30,89 @@ namespace Access {
 class AccessEngine;
 class Scripts;
 
-typedef void(Scripts::*ScriptMethodPtr)();
+typedef void(Scripts::*ScriptMethodPtr)(const byte *&pScript);
 
 class Scripts {
 protected:
 	AccessEngine *_vm;
 
-	virtual void executeCommand(int commandIndex);
-	void CMDENDOBJECT();
-	void CMDJUMPLOOK();
-	void CMDJUMPHELP();
-	void CMDJUMPGET();
-	void CMDJUMPMOVE();
-	void CMDJUMPUSE();
-	void CMDJUMPTALK();
-	void CMDNULL();
-	void CMDPRINT();
-	void CMDRETPOS();
-	void CMDANIM();
-	void CMDSETFLAG();
-	void CMDCHECKFLAG();
-	void CMDGOTO();
-	void CMDSETINV();
-	void CMDCHECKINV();
-	void CMDSETTEX();
-	void CMDNEWROOM();
-	void CMDCONVERSE();
-	void CMDCHECKFRAME();
-	void CMDCHECKANIM();
-	void CMDSND();
-	void CMDRETNEG();
-	void CMDCHECKLOC();
-	void CMDSETANIM();
-	void CMDDISPINV();
-	void CMDSETTIMER();
-	void CMDCHECKTIMER();
-	void CMDSETTRAVEL();
-	void CMDSETVID();
-	void CMDPLAYVID();
-	void CMDPLOTIMAGE();
-	void CMDSETDISPLAY();
-	void CMDSETBUFFER();
-	void CMDSETSCROLL();
-	void CMDSAVERECT();
-	void CMDSETBUFVID();
-	void CMDPLAYBUFVID();
-	void CMDREMOVELAST();
-	void CMDSPECIAL();
-	void CMDSETCYCLE();
-	void CMDCYCLE();
-	void CMDCHARSPEAK();
-	void CMDTEXSPEAK();
-	void CMDTEXCHOICE();
-	void CMDWAIT();
-	void CMDSETCONPOS();
-	void CMDCHECKVFRAME();
-	void CMDJUMPCHOICE();
-	void CMDRETURNCHOICE();
-	void CMDCLEARBLOCK();
-	void CMDLOADSOUND();
-	void CMDFREESOUND();
-	void CMDSETVIDSND();
-	void CMDPLAYVIDSND();
-	void CMDPUSHLOCATION();
-	void CMDPLAYEROFF();
-	void CMDPLAYERON();
-	void CMDDEAD();
-	void CMDFADEOUT();
-	void CMDENDVID();
-	void CMDHELP();
-	void CMDCYCLEBACK();
-	void CMDCHAPTER();
-	void CMDSETHELP();
-	void CMDCENTERPANEL();
-	void CMDMAINPANEL();
-	void CMDRETFLASH();
+	virtual void executeCommand(int commandIndex, const byte *&pScript);
+	void CMDENDOBJECT(const byte *&pScript);
+	void CMDJUMPLOOK(const byte *&pScript);
+	void CMDJUMPHELP(const byte *&pScript);
+	void CMDJUMPGET(const byte *&pScript);
+	void CMDJUMPMOVE(const byte *&pScript);
+	void CMDJUMPUSE(const byte *&pScript);
+	void CMDJUMPTALK(const byte *&pScript);
+	void CMDNULL(const byte *&pScript);
+	void CMDPRINT(const byte *&pScript);
+	void CMDRETPOS(const byte *&pScript);
+	void CMDANIM(const byte *&pScript);
+	void CMDSETFLAG(const byte *&pScript);
+	void CMDCHECKFLAG(const byte *&pScript);
+	
+	/**
+	 * Jump to another script
+	 */
+	void cmdGoto(const byte *&pScript);
+	
+	void CMDSETINV(const byte *&pScript);
+	void CMDCHECKINV(const byte *&pScript);
+	void CMDSETTEX(const byte *&pScript);
+	void CMDNEWROOM(const byte *&pScript);
+	void CMDCONVERSE(const byte *&pScript);
+	void CMDCHECKFRAME(const byte *&pScript);
+	void CMDCHECKANIM(const byte *&pScript);
+	void CMDSND(const byte *&pScript);
+	void CMDRETNEG(const byte *&pScript);
+	void CMDCHECKLOC(const byte *&pScript);
+	void CMDSETANIM(const byte *&pScript);
+	void CMDDISPINV(const byte *&pScript);
+	void CMDSETTIMER(const byte *&pScript);
+	void CMDCHECKTIMER(const byte *&pScript);
+	void CMDSETTRAVEL(const byte *&pScript);
+	void CMDSETVID(const byte *&pScript);
+	void CMDPLAYVID(const byte *&pScript);
+	void CMDPLOTIMAGE(const byte *&pScript);
+	void CMDSETDISPLAY(const byte *&pScript);
+	void CMDSETBUFFER(const byte *&pScript);
+	void CMDSETSCROLL(const byte *&pScript);
+	void CMDSAVERECT(const byte *&pScript);
+	void CMDSETBUFVID(const byte *&pScript);
+	void CMDPLAYBUFVID(const byte *&pScript);
+	void CMDREMOVELAST(const byte *&pScript);
+	void CMDSPECIAL(const byte *&pScript);
+	void CMDSETCYCLE(const byte *&pScript);
+	void CMDCYCLE(const byte *&pScript);
+	void CMDCHARSPEAK(const byte *&pScript);
+	void CMDTEXSPEAK(const byte *&pScript);
+	void CMDTEXCHOICE(const byte *&pScript);
+	void CMDWAIT(const byte *&pScript);
+	void CMDSETCONPOS(const byte *&pScript);
+	void CMDCHECKVFRAME(const byte *&pScript);
+	void CMDJUMPCHOICE(const byte *&pScript);
+	void CMDRETURNCHOICE(const byte *&pScript);
+	void CMDCLEARBLOCK(const byte *&pScript);
+	void CMDLOADSOUND(const byte *&pScript);
+	void CMDFREESOUND(const byte *&pScript);
+	void CMDSETVIDSND(const byte *&pScript);
+	void CMDPLAYVIDSND(const byte *&pScript);
+	void CMDPUSHLOCATION(const byte *&pScript);
+	void CMDPLAYEROFF(const byte *&pScript);
+	void CMDPLAYERON(const byte *&pScript);
+	void CMDDEAD(const byte *&pScript);
+	void CMDFADEOUT(const byte *&pScript);
+	void CMDENDVID(const byte *&pScript);
+	void CMDHELP(const byte *&pScript);
+	void CMDCYCLEBACK(const byte *&pScript);
+	void CMDCHAPTER(const byte *&pScript);
+	void CMDSETHELP(const byte *&pScript);
+	void CMDCENTERPANEL(const byte *&pScript);
+	void CMDMAINPANEL(const byte *&pScript);
+	void CMDRETFLASH(const byte *&pScript);
 public:
-	byte *_script;
-	byte *_scriptLoc;
+	const byte *_script;
+	const byte *_scriptLoc;
 	int _sequence;
 	bool _endFlag;
 	int _returnCode;
@@ -119,7 +124,7 @@ public:
 
 	void freeScriptData();
 
-	void searchForSequence();
+	const byte *searchForSequence();
 	
 	int executeScript();
 };


Commit: a9b8369274c74e2364e40b8ac3e0fb735443ae51
    https://github.com/scummvm/scummvm/commit/a9b8369274c74e2364e40b8ac3e0fb735443ae51
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-08T23:29:17-04:00

Commit Message:
ACCESS: Implemented several script commands

Changed paths:
    engines/access/scripts.cpp
    engines/access/scripts.h



diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp
index 337aa43..38f9f92 100644
--- a/engines/access/scripts.cpp
+++ b/engines/access/scripts.cpp
@@ -78,9 +78,9 @@ int Scripts::executeScript() {
 
 void Scripts::executeCommand(int commandIndex, const byte *&pScript) {
 	static const ScriptMethodPtr COMMAND_LIST[] = {
-		&Scripts::CMDENDOBJECT, &Scripts::CMDJUMPLOOK, &Scripts::CMDJUMPHELP, &Scripts::CMDJUMPGET, &Scripts::CMDJUMPMOVE,
-		&Scripts::CMDJUMPUSE, &Scripts::CMDJUMPTALK, &Scripts::CMDNULL, &Scripts::CMDPRINT, &Scripts::CMDRETPOS, &Scripts::CMDANIM,
-		&Scripts::CMDSETFLAG, &Scripts::CMDCHECKFLAG, &Scripts::cmdGoto, &Scripts::CMDSETINV, &Scripts::CMDSETINV,
+		&Scripts::CMDENDOBJECT, &Scripts::cmdJumpLook, &Scripts::cmdJumpHelp, &Scripts::cmdJumpGet, &Scripts::cmdJumpMove,
+		&Scripts::cmdJumpUse, &Scripts::cmdJumpTalk, &Scripts::CMDNULL, &Scripts::CMDPRINT, &Scripts::CMDRETPOS, &Scripts::CMDANIM,
+		&Scripts::cmdSetFlag, &Scripts::CMDCHECKFLAG, &Scripts::cmdGoto, &Scripts::CMDSETINV, &Scripts::CMDSETINV,
 		&Scripts::CMDCHECKINV, &Scripts::CMDSETTEX, &Scripts::CMDNEWROOM, &Scripts::CMDCONVERSE, &Scripts::CMDCHECKFRAME,
 		&Scripts::CMDCHECKANIM, &Scripts::CMDSND, &Scripts::CMDRETNEG, &Scripts::CMDRETPOS, &Scripts::CMDCHECKLOC, &Scripts::CMDSETANIM,
 		&Scripts::CMDDISPINV, &Scripts::CMDSETTIMER, &Scripts::CMDSETTIMER, &Scripts::CMDCHECKTIMER, &Scripts::CMDSETTRAVEL,
@@ -100,18 +100,72 @@ void Scripts::executeCommand(int commandIndex, const byte *&pScript) {
 }
 
 void Scripts::CMDENDOBJECT(const byte *&pScript) { }
-void Scripts::CMDJUMPLOOK(const byte *&pScript) { }
-void Scripts::CMDJUMPHELP(const byte *&pScript) { }
-void Scripts::CMDJUMPGET(const byte *&pScript) { }
-void Scripts::CMDJUMPMOVE(const byte *&pScript) { }
-void Scripts::CMDJUMPUSE(const byte *&pScript) { }
-void Scripts::CMDJUMPTALK(const byte *&pScript) { }
+
+void Scripts::cmdJumpLook(const byte *&pScript) {
+	if (_vm->_selectCommand == 0)
+		cmdGoto(pScript);
+	else
+		pScript += 2;
+}
+
+void Scripts::cmdJumpHelp(const byte *&pScript) { 
+	if (_vm->_selectCommand == 8)
+		cmdGoto(pScript);
+	else
+		pScript += 2;
+}
+
+void Scripts::cmdJumpGet(const byte *&pScript) { 
+	if (_vm->_selectCommand == 3)
+		cmdGoto(pScript);
+	else
+		pScript += 2;
+}
+
+void Scripts::cmdJumpMove(const byte *&pScript) { 
+	if (_vm->_selectCommand == 2)
+		cmdGoto(pScript);
+	else
+		pScript += 2;
+}
+
+void Scripts::cmdJumpUse(const byte *&pScript) { 
+	if (_vm->_selectCommand == 4)
+		cmdGoto(pScript);
+	else
+		pScript += 2;
+}
+
+void Scripts::cmdJumpTalk(const byte *&pScript) { 
+	if (_vm->_selectCommand == 6)
+		cmdGoto(pScript);
+	else
+		pScript += 2;
+}
+
 void Scripts::CMDNULL(const byte *&pScript) { }
 void Scripts::CMDPRINT(const byte *&pScript) { }
 void Scripts::CMDRETPOS(const byte *&pScript) { }
 void Scripts::CMDANIM(const byte *&pScript) { }
-void Scripts::CMDSETFLAG(const byte *&pScript) { }
-void Scripts::CMDCHECKFLAG(const byte *&pScript) { }
+
+void Scripts::cmdSetFlag(const byte *&pScript) { 
+	int flagNum = *pScript++;
+	byte flagVal = *pScript++;
+	assert(flagNum < 100);
+	_vm->_flags[flagNum] = flagVal;
+}
+
+void Scripts::CMDCHECKFLAG(const byte *&pScript) { 
+	int flagNum = READ_LE_UINT16(pScript);
+	int flagVal = READ_LE_UINT16(pScript + 2);
+	pScript += 4;
+	assert(flagNum < 100);
+
+	if (_vm->_flags[flagNum] == (flagVal & 0xff))
+		cmdGoto(pScript);
+	else
+		pScript += 2;
+}
 
 void Scripts::cmdGoto(const byte *&pScript) { 
 	_sequence = READ_LE_UINT16(pScript);
diff --git a/engines/access/scripts.h b/engines/access/scripts.h
index fc75e9e..5e733db 100644
--- a/engines/access/scripts.h
+++ b/engines/access/scripts.h
@@ -38,17 +38,17 @@ protected:
 
 	virtual void executeCommand(int commandIndex, const byte *&pScript);
 	void CMDENDOBJECT(const byte *&pScript);
-	void CMDJUMPLOOK(const byte *&pScript);
-	void CMDJUMPHELP(const byte *&pScript);
-	void CMDJUMPGET(const byte *&pScript);
-	void CMDJUMPMOVE(const byte *&pScript);
-	void CMDJUMPUSE(const byte *&pScript);
-	void CMDJUMPTALK(const byte *&pScript);
+	void cmdJumpLook(const byte *&pScript);
+	void cmdJumpHelp(const byte *&pScript);
+	void cmdJumpGet(const byte *&pScript);
+	void cmdJumpMove(const byte *&pScript);
+	void cmdJumpUse(const byte *&pScript);
+	void cmdJumpTalk(const byte *&pScript);
 	void CMDNULL(const byte *&pScript);
 	void CMDPRINT(const byte *&pScript);
 	void CMDRETPOS(const byte *&pScript);
 	void CMDANIM(const byte *&pScript);
-	void CMDSETFLAG(const byte *&pScript);
+	void cmdSetFlag(const byte *&pScript);
 	void CMDCHECKFLAG(const byte *&pScript);
 	
 	/**


Commit: c930c7e6ed0128ea012d7cc09ce855e7a06b6c3c
    https://github.com/scummvm/scummvm/commit/c930c7e6ed0128ea012d7cc09ce855e7a06b6c3c
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-08-09T15:38:40+02:00

Commit Message:
ACCESS: Implement some script opcodes

Changed paths:
    engines/access/scripts.cpp
    engines/access/scripts.h



diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp
index 38f9f92..c78ecf5 100644
--- a/engines/access/scripts.cpp
+++ b/engines/access/scripts.cpp
@@ -79,10 +79,10 @@ int Scripts::executeScript() {
 void Scripts::executeCommand(int commandIndex, const byte *&pScript) {
 	static const ScriptMethodPtr COMMAND_LIST[] = {
 		&Scripts::CMDENDOBJECT, &Scripts::cmdJumpLook, &Scripts::cmdJumpHelp, &Scripts::cmdJumpGet, &Scripts::cmdJumpMove,
-		&Scripts::cmdJumpUse, &Scripts::cmdJumpTalk, &Scripts::CMDNULL, &Scripts::CMDPRINT, &Scripts::CMDRETPOS, &Scripts::CMDANIM,
+		&Scripts::cmdJumpUse, &Scripts::cmdJumpTalk, &Scripts::cmdNull, &Scripts::CMDPRINT, &Scripts::cmdRetPos, &Scripts::CMDANIM,
 		&Scripts::cmdSetFlag, &Scripts::CMDCHECKFLAG, &Scripts::cmdGoto, &Scripts::CMDSETINV, &Scripts::CMDSETINV,
 		&Scripts::CMDCHECKINV, &Scripts::CMDSETTEX, &Scripts::CMDNEWROOM, &Scripts::CMDCONVERSE, &Scripts::CMDCHECKFRAME,
-		&Scripts::CMDCHECKANIM, &Scripts::CMDSND, &Scripts::CMDRETNEG, &Scripts::CMDRETPOS, &Scripts::CMDCHECKLOC, &Scripts::CMDSETANIM,
+		&Scripts::CMDCHECKANIM, &Scripts::CMDSND, &Scripts::CMDRETNEG, &Scripts::cmdRetPos, &Scripts::cmdCheckLoc, &Scripts::CMDSETANIM,
 		&Scripts::CMDDISPINV, &Scripts::CMDSETTIMER, &Scripts::CMDSETTIMER, &Scripts::CMDCHECKTIMER, &Scripts::CMDSETTRAVEL,
 		&Scripts::CMDSETTRAVEL, &Scripts::CMDSETVID, &Scripts::CMDPLAYVID, &Scripts::CMDPLOTIMAGE, &Scripts::CMDSETDISPLAY,
 		&Scripts::CMDSETBUFFER, &Scripts::CMDSETSCROLL, &Scripts::CMDSAVERECT, &Scripts::CMDSAVERECT, &Scripts::CMDSETBUFVID,
@@ -91,7 +91,7 @@ void Scripts::executeCommand(int commandIndex, const byte *&pScript) {
 		&Scripts::CMDWAIT, &Scripts::CMDSETCONPOS, &Scripts::CMDCHECKVFRAME, &Scripts::CMDJUMPCHOICE, &Scripts::CMDRETURNCHOICE,
 		&Scripts::CMDCLEARBLOCK, &Scripts::CMDLOADSOUND, &Scripts::CMDFREESOUND, &Scripts::CMDSETVIDSND, &Scripts::CMDPLAYVIDSND,
 		&Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION,
-		&Scripts::CMDPUSHLOCATION, &Scripts::CMDPLAYEROFF, &Scripts::CMDPLAYERON, &Scripts::CMDDEAD, &Scripts::CMDFADEOUT,
+		&Scripts::CMDPUSHLOCATION, &Scripts::cmdPlayerOff, &Scripts::cmdPlayerOn, &Scripts::CMDDEAD, &Scripts::CMDFADEOUT,
 		&Scripts::CMDENDVID, &Scripts::CMDHELP, &Scripts::CMDCYCLEBACK, &Scripts::CMDCHAPTER, &Scripts::CMDSETHELP, &Scripts::CMDCENTERPANEL,
 		&Scripts::CMDMAINPANEL, &Scripts::CMDRETFLASH
 	};
@@ -143,9 +143,16 @@ void Scripts::cmdJumpTalk(const byte *&pScript) {
 		pScript += 2;
 }
 
-void Scripts::CMDNULL(const byte *&pScript) { }
+void Scripts::cmdNull(const byte *&pScript) {
+}
+
 void Scripts::CMDPRINT(const byte *&pScript) { }
-void Scripts::CMDRETPOS(const byte *&pScript) { }
+
+void Scripts::cmdRetPos(const byte *&pScript) {
+	_endFlag = true;
+	_returnCode = 0;
+}
+
 void Scripts::CMDANIM(const byte *&pScript) { }
 
 void Scripts::cmdSetFlag(const byte *&pScript) { 
@@ -181,7 +188,22 @@ void Scripts::CMDCHECKFRAME(const byte *&pScript) { }
 void Scripts::CMDCHECKANIM(const byte *&pScript) { }
 void Scripts::CMDSND(const byte *&pScript) { }
 void Scripts::CMDRETNEG(const byte *&pScript) { }
-void Scripts::CMDCHECKLOC(const byte *&pScript) { }
+
+void Scripts::cmdCheckLoc(const byte *&pScript) {
+	int minX = READ_LE_UINT16(pScript);
+	int minY = READ_LE_UINT16(pScript);
+	int maxX = READ_LE_UINT16(pScript);
+	int maxY = READ_LE_UINT16(pScript);
+
+	int curX = _vm->_player->_rawPlayer.x + _vm->_player->_playerOffset.x;
+	int curY = _vm->_player->_rawPlayer.y;
+
+	if ((curX > minX) && (curX < maxX) && (curY > minY) && (curY < maxY))
+		cmdGoto(pScript);
+	else
+		pScript += 2;
+}
+
 void Scripts::CMDSETANIM(const byte *&pScript) { }
 void Scripts::CMDDISPINV(const byte *&pScript) { }
 void Scripts::CMDSETTIMER(const byte *&pScript) { }
@@ -214,8 +236,15 @@ void Scripts::CMDFREESOUND(const byte *&pScript) { }
 void Scripts::CMDSETVIDSND(const byte *&pScript) { }
 void Scripts::CMDPLAYVIDSND(const byte *&pScript) { }
 void Scripts::CMDPUSHLOCATION(const byte *&pScript) { }
-void Scripts::CMDPLAYEROFF(const byte *&pScript) { }
-void Scripts::CMDPLAYERON(const byte *&pScript) { }
+
+void Scripts::cmdPlayerOff(const byte *&pScript) {
+	_vm->_player->_playerOff = true;
+}
+
+void Scripts::cmdPlayerOn(const byte *&pScript) {
+	_vm->_player->_playerOff = false;
+}
+
 void Scripts::CMDDEAD(const byte *&pScript) { }
 void Scripts::CMDFADEOUT(const byte *&pScript) { }
 void Scripts::CMDENDVID(const byte *&pScript) { }
diff --git a/engines/access/scripts.h b/engines/access/scripts.h
index 5e733db..a65c365 100644
--- a/engines/access/scripts.h
+++ b/engines/access/scripts.h
@@ -44,9 +44,9 @@ protected:
 	void cmdJumpMove(const byte *&pScript);
 	void cmdJumpUse(const byte *&pScript);
 	void cmdJumpTalk(const byte *&pScript);
-	void CMDNULL(const byte *&pScript);
+	void cmdNull(const byte *&pScript);
 	void CMDPRINT(const byte *&pScript);
-	void CMDRETPOS(const byte *&pScript);
+	void cmdRetPos(const byte *&pScript);
 	void CMDANIM(const byte *&pScript);
 	void cmdSetFlag(const byte *&pScript);
 	void CMDCHECKFLAG(const byte *&pScript);
@@ -65,7 +65,7 @@ protected:
 	void CMDCHECKANIM(const byte *&pScript);
 	void CMDSND(const byte *&pScript);
 	void CMDRETNEG(const byte *&pScript);
-	void CMDCHECKLOC(const byte *&pScript);
+	void cmdCheckLoc(const byte *&pScript);
 	void CMDSETANIM(const byte *&pScript);
 	void CMDDISPINV(const byte *&pScript);
 	void CMDSETTIMER(const byte *&pScript);
@@ -98,8 +98,8 @@ protected:
 	void CMDSETVIDSND(const byte *&pScript);
 	void CMDPLAYVIDSND(const byte *&pScript);
 	void CMDPUSHLOCATION(const byte *&pScript);
-	void CMDPLAYEROFF(const byte *&pScript);
-	void CMDPLAYERON(const byte *&pScript);
+	void cmdPlayerOff(const byte *&pScript);
+	void cmdPlayerOn(const byte *&pScript);
 	void CMDDEAD(const byte *&pScript);
 	void CMDFADEOUT(const byte *&pScript);
 	void CMDENDVID(const byte *&pScript);


Commit: 5a3dfb1a7bd27bef578479b3666a6dbf9a08ce3b
    https://github.com/scummvm/scummvm/commit/5a3dfb1a7bd27bef578479b3666a6dbf9a08ce3b
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-08-09T15:54:08+02:00

Commit Message:
ACCESS: Fix implementation of cmdCheckLoc()

Changed paths:
    engines/access/scripts.cpp



diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp
index c78ecf5..01fb73e 100644
--- a/engines/access/scripts.cpp
+++ b/engines/access/scripts.cpp
@@ -198,7 +198,7 @@ void Scripts::cmdCheckLoc(const byte *&pScript) {
 	int curX = _vm->_player->_rawPlayer.x + _vm->_player->_playerOffset.x;
 	int curY = _vm->_player->_rawPlayer.y;
 
-	if ((curX > minX) && (curX < maxX) && (curY > minY) && (curY < maxY))
+	if ((curX >= minX) && (curX <= maxX) && (curY >= minY) && (curY <= maxY))
 		cmdGoto(pScript);
 	else
 		pScript += 2;


Commit: 814d4ebdd01163f0a21d8eb4d04f8201e98cf57f
    https://github.com/scummvm/scummvm/commit/814d4ebdd01163f0a21d8eb4d04f8201e98cf57f
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-09T12:12:39-04:00

Commit Message:
ACCESS: Add detection entry and subfolder adding for CD version

Changed paths:
    engines/access/access.cpp
    engines/access/access.h
    engines/access/detection.cpp
    engines/access/detection_tables.h



diff --git a/engines/access/access.cpp b/engines/access/access.cpp
index 78274f1..cb1977a 100644
--- a/engines/access/access.cpp
+++ b/engines/access/access.cpp
@@ -154,6 +154,18 @@ void AccessEngine::initialize() {
 	DebugMan.addDebugChannel(kDebugScripts, "scripts", "Game scripts");
 	DebugMan.addDebugChannel(kDebugGraphics, "graphics", "Graphics handling");
 
+	if (isCD()) {
+		const Common::FSNode gameDataDir(ConfMan.get("path"));
+		const Common::FSNode cdromDir = gameDataDir.getChild("cdrom");
+
+		for (int idx = 0; idx < 15; ++idx) {
+			Common::String folder = (idx == 0) ? "game" :
+				Common::String::format("chap%.2d", idx);
+			SearchMan.addSubDirectoryMatching(cdromDir, folder);
+		}
+	}
+
+	// Create sub-objects of the engine
 	_debugger = new Debugger(this);
 	_events = new EventsManager(this);
 	_files = new FileManager(this);
diff --git a/engines/access/access.h b/engines/access/access.h
index a009940..18278bf 100644
--- a/engines/access/access.h
+++ b/engines/access/access.h
@@ -200,6 +200,7 @@ public:
 	virtual ~AccessEngine();
 
 	uint32 getFeatures() const;
+	bool isCD() const;
 	Common::Language getLanguage() const;
 	Common::Platform getPlatform() const;
 	uint16 getVersion() const;
diff --git a/engines/access/detection.cpp b/engines/access/detection.cpp
index ca04a64..47f7af6 100644
--- a/engines/access/detection.cpp
+++ b/engines/access/detection.cpp
@@ -56,6 +56,10 @@ uint32 AccessEngine::getFeatures() const {
 	return _gameDescription->desc.flags;
 }
 
+bool AccessEngine::isCD() const {
+	return (bool)(_gameDescription->desc.flags & ADGF_CD);
+}
+
 Common::Language AccessEngine::getLanguage() const {
 	return _gameDescription->desc.language;
 }
diff --git a/engines/access/detection_tables.h b/engines/access/detection_tables.h
index cbef1d3..ad962f4 100644
--- a/engines/access/detection_tables.h
+++ b/engines/access/detection_tables.h
@@ -41,6 +41,24 @@ static const AccessGameDescription gameDescriptions[] = {
 		0
 	},
 
+	{
+		// Amazon Guadians of Eden - CD English
+		{
+			"amazon",
+			"CD",
+			{
+				{ "checksum.crc", 0, "bef85478132fec74cb5d9067f3a37d24", 8 },
+				AD_LISTEND
+			},
+			Common::EN_ANY,
+			Common::kPlatformDOS,
+			ADGF_CD,
+			GUIO1(GUIO_NONE)
+		},
+		GType_Amazon,
+		0
+	},
+
 	{ AD_TABLE_END_MARKER, 0, 0 }
 };
 


Commit: 3fb6c99017a0dd1502f3f01352a401c30ee3132b
    https://github.com/scummvm/scummvm/commit/3fb6c99017a0dd1502f3f01352a401c30ee3132b
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-09T12:25:52-04:00

Commit Message:
ACCESS: Add missing CMDOBJECT method to script command list

Changed paths:
    engines/access/scripts.cpp
    engines/access/scripts.h



diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp
index 01fb73e..98ab7f8 100644
--- a/engines/access/scripts.cpp
+++ b/engines/access/scripts.cpp
@@ -78,27 +78,40 @@ int Scripts::executeScript() {
 
 void Scripts::executeCommand(int commandIndex, const byte *&pScript) {
 	static const ScriptMethodPtr COMMAND_LIST[] = {
-		&Scripts::CMDENDOBJECT, &Scripts::cmdJumpLook, &Scripts::cmdJumpHelp, &Scripts::cmdJumpGet, &Scripts::cmdJumpMove,
-		&Scripts::cmdJumpUse, &Scripts::cmdJumpTalk, &Scripts::cmdNull, &Scripts::CMDPRINT, &Scripts::cmdRetPos, &Scripts::CMDANIM,
-		&Scripts::cmdSetFlag, &Scripts::CMDCHECKFLAG, &Scripts::cmdGoto, &Scripts::CMDSETINV, &Scripts::CMDSETINV,
-		&Scripts::CMDCHECKINV, &Scripts::CMDSETTEX, &Scripts::CMDNEWROOM, &Scripts::CMDCONVERSE, &Scripts::CMDCHECKFRAME,
-		&Scripts::CMDCHECKANIM, &Scripts::CMDSND, &Scripts::CMDRETNEG, &Scripts::cmdRetPos, &Scripts::cmdCheckLoc, &Scripts::CMDSETANIM,
-		&Scripts::CMDDISPINV, &Scripts::CMDSETTIMER, &Scripts::CMDSETTIMER, &Scripts::CMDCHECKTIMER, &Scripts::CMDSETTRAVEL,
-		&Scripts::CMDSETTRAVEL, &Scripts::CMDSETVID, &Scripts::CMDPLAYVID, &Scripts::CMDPLOTIMAGE, &Scripts::CMDSETDISPLAY,
-		&Scripts::CMDSETBUFFER, &Scripts::CMDSETSCROLL, &Scripts::CMDSAVERECT, &Scripts::CMDSAVERECT, &Scripts::CMDSETBUFVID,
-		&Scripts::CMDPLAYBUFVID, &Scripts::CMDREMOVELAST, &Scripts::CMDSPECIAL, &Scripts::CMDSPECIAL, &Scripts::CMDSPECIAL,
-		&Scripts::CMDSETCYCLE, &Scripts::CMDCYCLE, &Scripts::CMDCHARSPEAK, &Scripts::CMDTEXSPEAK, &Scripts::CMDTEXCHOICE,
-		&Scripts::CMDWAIT, &Scripts::CMDSETCONPOS, &Scripts::CMDCHECKVFRAME, &Scripts::CMDJUMPCHOICE, &Scripts::CMDRETURNCHOICE,
-		&Scripts::CMDCLEARBLOCK, &Scripts::CMDLOADSOUND, &Scripts::CMDFREESOUND, &Scripts::CMDSETVIDSND, &Scripts::CMDPLAYVIDSND,
-		&Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION,
-		&Scripts::CMDPUSHLOCATION, &Scripts::cmdPlayerOff, &Scripts::cmdPlayerOn, &Scripts::CMDDEAD, &Scripts::CMDFADEOUT,
-		&Scripts::CMDENDVID, &Scripts::CMDHELP, &Scripts::CMDCYCLEBACK, &Scripts::CMDCHAPTER, &Scripts::CMDSETHELP, &Scripts::CMDCENTERPANEL,
+		&Scripts::CMDOBJECT, &Scripts::CMDENDOBJECT, &Scripts::cmdJumpLook, 
+		&Scripts::cmdJumpHelp, &Scripts::cmdJumpGet, &Scripts::cmdJumpMove,
+		&Scripts::cmdJumpUse, &Scripts::cmdJumpTalk, &Scripts::cmdNull, 
+		&Scripts::CMDPRINT, &Scripts::cmdRetPos, &Scripts::CMDANIM,
+		&Scripts::cmdSetFlag, &Scripts::CMDCHECKFLAG, &Scripts::cmdGoto, 
+		&Scripts::CMDSETINV, &Scripts::CMDSETINV, &Scripts::CMDCHECKINV, 
+		&Scripts::CMDSETTEX, &Scripts::CMDNEWROOM, &Scripts::CMDCONVERSE, 
+		&Scripts::CMDCHECKFRAME, &Scripts::CMDCHECKANIM, &Scripts::CMDSND, 
+		&Scripts::CMDRETNEG, &Scripts::cmdRetPos, &Scripts::cmdCheckLoc, 
+		&Scripts::CMDSETANIM, &Scripts::CMDDISPINV, &Scripts::CMDSETTIMER, 
+		&Scripts::CMDSETTIMER, &Scripts::CMDCHECKTIMER, &Scripts::CMDSETTRAVEL,
+		&Scripts::CMDSETTRAVEL, &Scripts::CMDSETVID, &Scripts::CMDPLAYVID, 
+		&Scripts::CMDPLOTIMAGE, &Scripts::CMDSETDISPLAY, &Scripts::CMDSETBUFFER, 
+		&Scripts::CMDSETSCROLL, &Scripts::CMDSAVERECT, &Scripts::CMDSAVERECT, 
+		&Scripts::CMDSETBUFVID, &Scripts::CMDPLAYBUFVID, &Scripts::CMDREMOVELAST, 
+		&Scripts::CMDSPECIAL, &Scripts::CMDSPECIAL, &Scripts::CMDSPECIAL,
+		&Scripts::CMDSETCYCLE, &Scripts::CMDCYCLE, &Scripts::CMDCHARSPEAK, 
+		&Scripts::CMDTEXSPEAK, &Scripts::CMDTEXCHOICE, &Scripts::CMDWAIT, 
+		&Scripts::CMDSETCONPOS, &Scripts::CMDCHECKVFRAME, &Scripts::CMDJUMPCHOICE, 
+		&Scripts::CMDRETURNCHOICE, &Scripts::CMDCLEARBLOCK, &Scripts::CMDLOADSOUND, 
+		&Scripts::CMDFREESOUND, &Scripts::CMDSETVIDSND, &Scripts::CMDPLAYVIDSND,
+		&Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, 
+		&Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, &Scripts::cmdPlayerOff, 
+		&Scripts::cmdPlayerOn, &Scripts::CMDDEAD, &Scripts::CMDFADEOUT,
+		&Scripts::CMDENDVID, &Scripts::CMDHELP, &Scripts::CMDCYCLEBACK, 
+		&Scripts::CMDCHAPTER, &Scripts::CMDSETHELP, &Scripts::CMDCENTERPANEL,
 		&Scripts::CMDMAINPANEL, &Scripts::CMDRETFLASH
 	};
 
 	(this->*COMMAND_LIST[commandIndex])(pScript);
 }
 
+void Scripts::CMDOBJECT(const byte *&pScript) { }
+
 void Scripts::CMDENDOBJECT(const byte *&pScript) { }
 
 void Scripts::cmdJumpLook(const byte *&pScript) {
diff --git a/engines/access/scripts.h b/engines/access/scripts.h
index a65c365..8035450 100644
--- a/engines/access/scripts.h
+++ b/engines/access/scripts.h
@@ -37,6 +37,7 @@ protected:
 	AccessEngine *_vm;
 
 	virtual void executeCommand(int commandIndex, const byte *&pScript);
+	void CMDOBJECT(const byte *&pScript);
 	void CMDENDOBJECT(const byte *&pScript);
 	void cmdJumpLook(const byte *&pScript);
 	void cmdJumpHelp(const byte *&pScript);


Commit: 1171400ccb65025a77f04dae3a224a3aec5920a3
    https://github.com/scummvm/scummvm/commit/1171400ccb65025a77f04dae3a224a3aec5920a3
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-09T15:54:35-04:00

Commit Message:
ACCESS: Beginnings of animation manager

Changed paths:
  A engines/access/animation.cpp
  A engines/access/animation.h
    engines/access/access.cpp
    engines/access/access.h
    engines/access/module.mk
    engines/access/room.cpp
    engines/access/room.h
    engines/access/screen.cpp
    engines/access/screen.h
    engines/access/scripts.cpp
    engines/access/scripts.h



diff --git a/engines/access/access.cpp b/engines/access/access.cpp
index cb1977a..c98588f 100644
--- a/engines/access/access.cpp
+++ b/engines/access/access.cpp
@@ -31,6 +31,7 @@ namespace Access {
 
 AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc) :
 		_gameDescription(gameDesc), Engine(syst), _randomSource("Access") {
+	_animation = nullptr;
 	_debugger = nullptr;
 	_events = nullptr;
 	_files = nullptr;
@@ -53,7 +54,6 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc)
 	_inactive = nullptr;
 	_manPal1 = nullptr;
 	_music = nullptr;
-	_anim = nullptr;
 	_title = nullptr;
 	_converseMode = 0;
 	_startInvItem = 0;
@@ -122,6 +122,7 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc)
 }
 
 AccessEngine::~AccessEngine() {
+	delete _animation;
 	delete _debugger;
 	delete _events;
 	delete _files;
@@ -140,7 +141,6 @@ AccessEngine::~AccessEngine() {
 	delete[] _inactive;
 	delete[] _manPal1;
 	delete[] _music;
-	delete[] _anim;
 	delete[] _title;
 }
 
@@ -166,6 +166,7 @@ void AccessEngine::initialize() {
 	}
 
 	// Create sub-objects of the engine
+	_animation = new AnimationManager(this);
 	_debugger = new Debugger(this);
 	_events = new EventsManager(this);
 	_files = new FileManager(this);
@@ -224,11 +225,6 @@ void AccessEngine::freeCells() {
 	}
 }
 
-void AccessEngine::freeAnimationData() {
-	delete[] _anim;
-	_anim = nullptr;
-}
-
 void AccessEngine::freeInactiveData() {
 	delete[] _inactive;
 	_inactive = nullptr;
diff --git a/engines/access/access.h b/engines/access/access.h
index 18278bf..56600e4 100644
--- a/engines/access/access.h
+++ b/engines/access/access.h
@@ -30,6 +30,7 @@
 #include "common/util.h"
 #include "engines/engine.h"
 #include "graphics/surface.h"
+#include "access\/animation.h"
 #include "access/data.h"
 #include "access/debugger.h"
 #include "access/events.h"
@@ -100,6 +101,7 @@ protected:
 	 */
 	virtual void playGame() = 0;
 public:
+	AnimationManager *_animation;
 	Debugger *_debugger;
 	EventsManager *_events;
 	FileManager *_files;
@@ -135,7 +137,6 @@ public:
 	byte *_inactive;
 	byte *_manPal1;
 	byte *_music;
-	byte *_anim;
 	byte *_title;
 	int _converseMode;
 	int _startInvItem;
@@ -209,8 +210,6 @@ public:
 
 	int getRandomNumber(int maxNumber);
 
-	void freeAnimationData();
-
 	void loadCells(Common::Array<RoomInfo::CellIdent> &cells);
 
 	/**
diff --git a/engines/access/animation.cpp b/engines/access/animation.cpp
new file mode 100644
index 0000000..4d73801
--- /dev/null
+++ b/engines/access/animation.cpp
@@ -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.
+ *
+ */
+
+#include "common/endian.h"
+#include "access/animation.h"
+
+namespace Access {
+
+AnimationManager::AnimationManager(AccessEngine *vm) : Manager(vm) {
+	_anim = nullptr;
+	_animation = nullptr;
+}
+
+AnimationManager::~AnimationManager() {
+	delete[] _anim;
+	delete _animation;
+}
+
+void AnimationManager::freeAnimationData() {
+	delete[] _anim;
+	_anim = nullptr;
+	_animation = nullptr;
+}
+
+void AnimationManager::clearTimers() {
+	for (uint i = 0; i < _animationTimers.size(); ++i)
+		delete _animationTimers[i];
+
+	_animationTimers.clear();
+}
+
+Animation *AnimationManager::setAnimation(int animId) {
+	Animation *anim = findAnimation(animId);
+
+	anim->_countdownTicks = anim->_ticks;
+	anim->_frameNumber = 0;
+
+	anim->_currentLoopCount = (anim->_type != 3 && anim->_type != 4) ? 0 : 
+		anim->_loopCount;
+	anim->_field10 = 0;
+		
+	return anim;
+}
+
+void AnimationManager::setAnimTimer(Animation *anim) {
+
+}
+
+Animation *AnimationManager::findAnimation(int animId) {
+	_animation = new Animation(_anim + READ_LE_UINT16(_anim + animId * 4 + 2));
+	return _animation;
+}
+
+/*------------------------------------------------------------------------*/
+
+Animation::Animation(const byte *data) {
+
+}
+
+} // End of namespace Access
diff --git a/engines/access/animation.h b/engines/access/animation.h
new file mode 100644
index 0000000..010fab9
--- /dev/null
+++ b/engines/access/animation.h
@@ -0,0 +1,68 @@
+/* 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 ACCESS_ANIMATION_H
+#define ACCESS_ANIMATION_H
+
+#include "common/scummsys.h"
+#include "common/array.h"
+#include "access/data.h"
+
+namespace Access {
+
+class Animation;
+
+class AnimationManager : public Manager {
+private:
+	Animation *findAnimation(int animId);
+public:
+	const byte *_anim;
+	Animation *_animation;
+	Common::Array<Animation *> _animationTimers;
+public:
+	AnimationManager(AccessEngine *vm);
+	~AnimationManager();
+	void freeAnimationData();
+	void clearTimers();
+
+	Animation *setAnimation(int animId);
+
+	void setAnimTimer(Animation *anim);
+};
+
+class Animation {
+public:
+	int _type;
+	int _scaling;
+	int _frameNumber;
+	int _ticks;
+	int _loopCount;
+	int _countdownTicks;
+	int _currentLoopCount;
+	int _field10;
+public:
+	Animation(const byte *data);
+};
+
+} // End of namespace Access
+
+#endif /* ACCESS_ANIMATION_H */
diff --git a/engines/access/module.mk b/engines/access/module.mk
index 042e84a..24c237a 100644
--- a/engines/access/module.mk
+++ b/engines/access/module.mk
@@ -1,6 +1,7 @@
 MODULE := engines/access
 
 MODULE_OBJS := \
+	animation.o \
 	asurface.o \
 	access.o \
 	data.o \
diff --git a/engines/access/room.cpp b/engines/access/room.cpp
index 80ab332..fb70e35 100644
--- a/engines/access/room.cpp
+++ b/engines/access/room.cpp
@@ -144,7 +144,7 @@ void Room::clearRoom() {
 	_vm->_sound->freeSounds();
 	_vm->_numAnimTimers = 0;
 
-	_vm->freeAnimationData();
+	_vm->_animation->freeAnimationData();
 	_vm->_scripts->freeScriptData();
 	_vm->freeCells();
 	freePlayField();
@@ -198,9 +198,9 @@ void Room::loadRoomData(const byte *roomData) {
 		roomInfo._scriptFile._subfile);
 
 	// Load animation data
-	_vm->freeAnimationData();
+	_vm->_animation->freeAnimationData();
 	if (roomInfo._animFile._fileNum != -1)
-		_vm->_anim = _vm->_files->loadFile(roomInfo._animFile._fileNum,
+		_vm->_animation->_anim = _vm->_files->loadFile(roomInfo._animFile._fileNum,
 		roomInfo._animFile._subfile);
 
 	_vm->_scaleI = roomInfo._scaleI;
@@ -312,6 +312,10 @@ void Room::buildColumn(int playX, int screenX) {
 	}
 }
 
+void Room::init4Quads() {
+	error("TODO: init4Quads");
+}
+
 /*------------------------------------------------------------------------*/
 
 RoomInfo::RoomInfo(const byte *data) {
diff --git a/engines/access/room.h b/engines/access/room.h
index c01a753..7296337 100644
--- a/engines/access/room.h
+++ b/engines/access/room.h
@@ -101,6 +101,8 @@ public:
 	void clearRoom();
 
 	void buildColumn(int playX, int screenX);
+
+	void init4Quads();
 };
 
 
diff --git a/engines/access/screen.cpp b/engines/access/screen.cpp
index 1974b1a..428c3d5 100644
--- a/engines/access/screen.cpp
+++ b/engines/access/screen.cpp
@@ -35,6 +35,7 @@ namespace Access {
 Screen::Screen(AccessEngine *vm) : _vm(vm) {
 	create(320, 200, Graphics::PixelFormat::createFormatCLUT8());
 	Common::fill(&_tempPalette[0], &_tempPalette[PALETTE_SIZE], 0);
+	_vesaMode = 0;
 	_vesaCurrentWin = 0;
 	_currentPanel = 0;
 	_hideFlag = true;
diff --git a/engines/access/screen.h b/engines/access/screen.h
index c32ae18..c4beacf 100644
--- a/engines/access/screen.h
+++ b/engines/access/screen.h
@@ -54,6 +54,7 @@ private:
 
 	bool clip(Common::Rect &r);
 public:
+	int _vesaMode;
 	bool _loadPalFlag;
 	bool _scrollFlag;
 	int _scrollThreshold;
diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp
index 98ab7f8..2705d70 100644
--- a/engines/access/scripts.cpp
+++ b/engines/access/scripts.cpp
@@ -87,7 +87,7 @@ void Scripts::executeCommand(int commandIndex, const byte *&pScript) {
 		&Scripts::CMDSETTEX, &Scripts::CMDNEWROOM, &Scripts::CMDCONVERSE, 
 		&Scripts::CMDCHECKFRAME, &Scripts::CMDCHECKANIM, &Scripts::CMDSND, 
 		&Scripts::CMDRETNEG, &Scripts::cmdRetPos, &Scripts::cmdCheckLoc, 
-		&Scripts::CMDSETANIM, &Scripts::CMDDISPINV, &Scripts::CMDSETTIMER, 
+		&Scripts::cmdSetAnim, &Scripts::CMDDISPINV, &Scripts::CMDSETTIMER, 
 		&Scripts::CMDSETTIMER, &Scripts::CMDCHECKTIMER, &Scripts::CMDSETTRAVEL,
 		&Scripts::CMDSETTRAVEL, &Scripts::CMDSETVID, &Scripts::CMDPLAYVID, 
 		&Scripts::CMDPLOTIMAGE, &Scripts::CMDSETDISPLAY, &Scripts::CMDSETBUFFER, 
@@ -104,7 +104,7 @@ void Scripts::executeCommand(int commandIndex, const byte *&pScript) {
 		&Scripts::cmdPlayerOn, &Scripts::CMDDEAD, &Scripts::CMDFADEOUT,
 		&Scripts::CMDENDVID, &Scripts::CMDHELP, &Scripts::CMDCYCLEBACK, 
 		&Scripts::CMDCHAPTER, &Scripts::CMDSETHELP, &Scripts::CMDCENTERPANEL,
-		&Scripts::CMDMAINPANEL, &Scripts::CMDRETFLASH
+		&Scripts::cmdMainPanel, &Scripts::CMDRETFLASH
 	};
 
 	(this->*COMMAND_LIST[commandIndex])(pScript);
@@ -217,7 +217,12 @@ void Scripts::cmdCheckLoc(const byte *&pScript) {
 		pScript += 2;
 }
 
-void Scripts::CMDSETANIM(const byte *&pScript) { }
+void Scripts::cmdSetAnim(const byte *&pScript) { 
+	int animId = *pScript++;
+	Animation *anim = _vm->_animation->setAnimation(animId);
+	_vm->_animation->setAnimTimer(anim);
+}
+
 void Scripts::CMDDISPINV(const byte *&pScript) { }
 void Scripts::CMDSETTIMER(const byte *&pScript) { }
 void Scripts::CMDCHECKTIMER(const byte *&pScript) { }
@@ -266,7 +271,14 @@ void Scripts::CMDCYCLEBACK(const byte *&pScript) { }
 void Scripts::CMDCHAPTER(const byte *&pScript) { }
 void Scripts::CMDSETHELP(const byte *&pScript) { }
 void Scripts::CMDCENTERPANEL(const byte *&pScript) { }
-void Scripts::CMDMAINPANEL(const byte *&pScript) { }
+
+void Scripts::cmdMainPanel(const byte *&pScript) { 
+	if (_vm->_screen->_vesaMode) {
+		_vm->_room->init4Quads();
+		_vm->_screen->setPanel(0);
+	}
+}
+
 void Scripts::CMDRETFLASH(const byte *&pScript) { }
 
 
diff --git a/engines/access/scripts.h b/engines/access/scripts.h
index 8035450..d78b748 100644
--- a/engines/access/scripts.h
+++ b/engines/access/scripts.h
@@ -67,7 +67,7 @@ protected:
 	void CMDSND(const byte *&pScript);
 	void CMDRETNEG(const byte *&pScript);
 	void cmdCheckLoc(const byte *&pScript);
-	void CMDSETANIM(const byte *&pScript);
+	void cmdSetAnim(const byte *&pScript);
 	void CMDDISPINV(const byte *&pScript);
 	void CMDSETTIMER(const byte *&pScript);
 	void CMDCHECKTIMER(const byte *&pScript);
@@ -109,7 +109,7 @@ protected:
 	void CMDCHAPTER(const byte *&pScript);
 	void CMDSETHELP(const byte *&pScript);
 	void CMDCENTERPANEL(const byte *&pScript);
-	void CMDMAINPANEL(const byte *&pScript);
+	void cmdMainPanel(const byte *&pScript);
 	void CMDRETFLASH(const byte *&pScript);
 public:
 	const byte *_script;


Commit: 00633b94be93bd80fc8d1244f59647002f12fbe1
    https://github.com/scummvm/scummvm/commit/00633b94be93bd80fc8d1244f59647002f12fbe1
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-09T16:31:23-04:00

Commit Message:
ACCESS: Convert Scripts class to use a MemoryReadStream

Changed paths:
    engines/access/room.cpp
    engines/access/scripts.cpp
    engines/access/scripts.h



diff --git a/engines/access/room.cpp b/engines/access/room.cpp
index fb70e35..e0acf1c 100644
--- a/engines/access/room.cpp
+++ b/engines/access/room.cpp
@@ -193,9 +193,11 @@ void Room::loadRoomData(const byte *roomData) {
 
 	// Load script data
 	_vm->_scripts->freeScriptData();
-	if (roomInfo._scriptFile._fileNum != -1)
-		_vm->_scripts->_script = _vm->_files->loadFile(roomInfo._scriptFile._fileNum,
-		roomInfo._scriptFile._subfile);
+	if (roomInfo._scriptFile._fileNum != -1) {
+		const byte *data = _vm->_files->loadFile(roomInfo._scriptFile._fileNum,
+			roomInfo._scriptFile._subfile);
+		_vm->_scripts->setScript(data, _vm->_files->_filesize);
+	}
 
 	// Load animation data
 	_vm->_animation->freeAnimationData();
diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp
index 2705d70..bc86e09 100644
--- a/engines/access/scripts.cpp
+++ b/engines/access/scripts.cpp
@@ -29,8 +29,8 @@
 namespace Access {
 
 Scripts::Scripts(AccessEngine *vm) : _vm(vm) {
-	_script = nullptr;
-	_scriptLoc = nullptr;
+	_rawData = nullptr;
+	_data = nullptr;
 	_sequence = 0;
 	_endFlag = false;
 	_returnCode = 0;
@@ -40,43 +40,47 @@ Scripts::~Scripts() {
 	freeScriptData();
 }
 
+void Scripts::setScript(const byte *data, int size) {
+	_rawData = data;
+	_data = new Common::MemoryReadStream(data, size, DisposeAfterUse::NO);
+}
+
 void Scripts::freeScriptData() {
-	delete[] _script;
-	_script = nullptr;
+	delete[] _rawData;
+	delete _data;
+	_data = nullptr;
+	_rawData = nullptr;
 }
 
-const byte *Scripts::searchForSequence() {
-	assert(_script);
-	const byte *pSrc = _script;
+void Scripts::searchForSequence() {
+	assert(_data);
+
+	_data->seek(0);
 	int sequenceId;
 	do {
-		while (*pSrc++ != SCRIPT_START_BYTE) ;
-		sequenceId = READ_LE_UINT16(pSrc);
-		pSrc += 2;
+		while (_data->readByte() != SCRIPT_START_BYTE) ;
+		sequenceId = _data->readUint16LE();
 	} while (sequenceId != _sequence);
-
-	_scriptLoc = pSrc;
-	return pSrc;
 }
 
 int Scripts::executeScript() {
-	assert(_scriptLoc);
-	_endFlag = 0;
+	assert(_data);
+	_endFlag = false;
 	_returnCode = 0;
 
 	do {
-		const byte *pSrc = _scriptLoc;
-		for (pSrc = _scriptLoc; *pSrc == SCRIPT_START_BYTE; pSrc += 3) ;	
-		_scriptCommand = *pSrc++;
+		// Get next command, skipping over script start start if it's being pointed to
+		for (_scriptCommand = _data->readByte(); _scriptCommand == SCRIPT_START_BYTE;
+			_data->skip(2));
 
-		executeCommand(_scriptCommand - 0x80, pSrc);
-		_scriptLoc = pSrc;
+		assert(_scriptCommand >= 0x80);
+		executeCommand(_scriptCommand - 0x80);
 	} while (!_endFlag);
 
 	return _returnCode;
 }
 
-void Scripts::executeCommand(int commandIndex, const byte *&pScript) {
+void Scripts::executeCommand(int commandIndex) {
 	static const ScriptMethodPtr COMMAND_LIST[] = {
 		&Scripts::CMDOBJECT, &Scripts::CMDENDOBJECT, &Scripts::cmdJumpLook, 
 		&Scripts::cmdJumpHelp, &Scripts::cmdJumpGet, &Scripts::cmdJumpMove,
@@ -107,179 +111,178 @@ void Scripts::executeCommand(int commandIndex, const byte *&pScript) {
 		&Scripts::cmdMainPanel, &Scripts::CMDRETFLASH
 	};
 
-	(this->*COMMAND_LIST[commandIndex])(pScript);
+	(this->*COMMAND_LIST[commandIndex])();
 }
 
-void Scripts::CMDOBJECT(const byte *&pScript) { }
+void Scripts::CMDOBJECT() { }
 
-void Scripts::CMDENDOBJECT(const byte *&pScript) { }
+void Scripts::CMDENDOBJECT() { }
 
-void Scripts::cmdJumpLook(const byte *&pScript) {
+void Scripts::cmdJumpLook() {
 	if (_vm->_selectCommand == 0)
-		cmdGoto(pScript);
+		cmdGoto();
 	else
-		pScript += 2;
+		_data->skip(2);
 }
 
-void Scripts::cmdJumpHelp(const byte *&pScript) { 
+void Scripts::cmdJumpHelp() { 
 	if (_vm->_selectCommand == 8)
-		cmdGoto(pScript);
+		cmdGoto();
 	else
-		pScript += 2;
+		_data->skip(2);
 }
 
-void Scripts::cmdJumpGet(const byte *&pScript) { 
+void Scripts::cmdJumpGet() { 
 	if (_vm->_selectCommand == 3)
-		cmdGoto(pScript);
+		cmdGoto();
 	else
-		pScript += 2;
+		_data->skip(2);
 }
 
-void Scripts::cmdJumpMove(const byte *&pScript) { 
+void Scripts::cmdJumpMove() { 
 	if (_vm->_selectCommand == 2)
-		cmdGoto(pScript);
+		cmdGoto();
 	else
-		pScript += 2;
+		_data->skip(2);
 }
 
-void Scripts::cmdJumpUse(const byte *&pScript) { 
+void Scripts::cmdJumpUse() { 
 	if (_vm->_selectCommand == 4)
-		cmdGoto(pScript);
+		cmdGoto();
 	else
-		pScript += 2;
+		_data->skip(2);
 }
 
-void Scripts::cmdJumpTalk(const byte *&pScript) { 
+void Scripts::cmdJumpTalk() { 
 	if (_vm->_selectCommand == 6)
-		cmdGoto(pScript);
+		cmdGoto();
 	else
-		pScript += 2;
+		_data->skip(2);
 }
 
-void Scripts::cmdNull(const byte *&pScript) {
+void Scripts::cmdNull() {
 }
 
-void Scripts::CMDPRINT(const byte *&pScript) { }
+void Scripts::CMDPRINT() { }
 
-void Scripts::cmdRetPos(const byte *&pScript) {
+void Scripts::cmdRetPos() {
 	_endFlag = true;
 	_returnCode = 0;
 }
 
-void Scripts::CMDANIM(const byte *&pScript) { }
+void Scripts::CMDANIM() { }
 
-void Scripts::cmdSetFlag(const byte *&pScript) { 
-	int flagNum = *pScript++;
-	byte flagVal = *pScript++;
+void Scripts::cmdSetFlag() { 
+	int flagNum = _data->readByte();
+	byte flagVal = _data->readByte();
 	assert(flagNum < 100);
 	_vm->_flags[flagNum] = flagVal;
 }
 
-void Scripts::CMDCHECKFLAG(const byte *&pScript) { 
-	int flagNum = READ_LE_UINT16(pScript);
-	int flagVal = READ_LE_UINT16(pScript + 2);
-	pScript += 4;
+void Scripts::CMDCHECKFLAG() { 
+	int flagNum = _data->readUint16LE();
+	int flagVal = _data->readUint16LE();
 	assert(flagNum < 100);
 
 	if (_vm->_flags[flagNum] == (flagVal & 0xff))
-		cmdGoto(pScript);
+		cmdGoto();
 	else
-		pScript += 2;
+		_data->skip(2);
 }
 
-void Scripts::cmdGoto(const byte *&pScript) { 
-	_sequence = READ_LE_UINT16(pScript);
-	pScript = searchForSequence();
+void Scripts::cmdGoto() { 
+	_sequence = _data->readUint16LE();
+	searchForSequence();
 }
 
-void Scripts::CMDSETINV(const byte *&pScript) { }
-void Scripts::CMDCHECKINV(const byte *&pScript) { }
-void Scripts::CMDSETTEX(const byte *&pScript) { }
-void Scripts::CMDNEWROOM(const byte *&pScript) { }
-void Scripts::CMDCONVERSE(const byte *&pScript) { }
-void Scripts::CMDCHECKFRAME(const byte *&pScript) { }
-void Scripts::CMDCHECKANIM(const byte *&pScript) { }
-void Scripts::CMDSND(const byte *&pScript) { }
-void Scripts::CMDRETNEG(const byte *&pScript) { }
-
-void Scripts::cmdCheckLoc(const byte *&pScript) {
-	int minX = READ_LE_UINT16(pScript);
-	int minY = READ_LE_UINT16(pScript);
-	int maxX = READ_LE_UINT16(pScript);
-	int maxY = READ_LE_UINT16(pScript);
+void Scripts::CMDSETINV() { }
+void Scripts::CMDCHECKINV() { }
+void Scripts::CMDSETTEX() { }
+void Scripts::CMDNEWROOM() { }
+void Scripts::CMDCONVERSE() { }
+void Scripts::CMDCHECKFRAME() { }
+void Scripts::CMDCHECKANIM() { }
+void Scripts::CMDSND() { }
+void Scripts::CMDRETNEG() { }
+
+void Scripts::cmdCheckLoc() {
+	int minX = _data->readUint16LE();
+	int minY = _data->readUint16LE();
+	int maxX = _data->readUint16LE();
+	int maxY = _data->readUint16LE();
 
 	int curX = _vm->_player->_rawPlayer.x + _vm->_player->_playerOffset.x;
 	int curY = _vm->_player->_rawPlayer.y;
 
 	if ((curX >= minX) && (curX <= maxX) && (curY >= minY) && (curY <= maxY))
-		cmdGoto(pScript);
+		cmdGoto();
 	else
-		pScript += 2;
+		_data->skip(2);
 }
 
-void Scripts::cmdSetAnim(const byte *&pScript) { 
-	int animId = *pScript++;
+void Scripts::cmdSetAnim() { 
+	int animId = _data->readByte();
 	Animation *anim = _vm->_animation->setAnimation(animId);
 	_vm->_animation->setAnimTimer(anim);
 }
 
-void Scripts::CMDDISPINV(const byte *&pScript) { }
-void Scripts::CMDSETTIMER(const byte *&pScript) { }
-void Scripts::CMDCHECKTIMER(const byte *&pScript) { }
-void Scripts::CMDSETTRAVEL(const byte *&pScript) { }
-void Scripts::CMDSETVID(const byte *&pScript) { }
-void Scripts::CMDPLAYVID(const byte *&pScript) { }
-void Scripts::CMDPLOTIMAGE(const byte *&pScript) { }
-void Scripts::CMDSETDISPLAY(const byte *&pScript) { }
-void Scripts::CMDSETBUFFER(const byte *&pScript) { }
-void Scripts::CMDSETSCROLL(const byte *&pScript) { }
-void Scripts::CMDSAVERECT(const byte *&pScript) { }
-void Scripts::CMDSETBUFVID(const byte *&pScript) { }
-void Scripts::CMDPLAYBUFVID(const byte *&pScript) { }
-void Scripts::CMDREMOVELAST(const byte *&pScript) { }
-void Scripts::CMDSPECIAL(const byte *&pScript) { }
-void Scripts::CMDSETCYCLE(const byte *&pScript) { }
-void Scripts::CMDCYCLE(const byte *&pScript) { }
-void Scripts::CMDCHARSPEAK(const byte *&pScript) { }
-void Scripts::CMDTEXSPEAK(const byte *&pScript) { }
-void Scripts::CMDTEXCHOICE(const byte *&pScript) { }
-void Scripts::CMDWAIT(const byte *&pScript) { }
-void Scripts::CMDSETCONPOS(const byte *&pScript) { }
-void Scripts::CMDCHECKVFRAME(const byte *&pScript) { }
-void Scripts::CMDJUMPCHOICE(const byte *&pScript) { }
-void Scripts::CMDRETURNCHOICE(const byte *&pScript) { }
-void Scripts::CMDCLEARBLOCK(const byte *&pScript) { }
-void Scripts::CMDLOADSOUND(const byte *&pScript) { }
-void Scripts::CMDFREESOUND(const byte *&pScript) { }
-void Scripts::CMDSETVIDSND(const byte *&pScript) { }
-void Scripts::CMDPLAYVIDSND(const byte *&pScript) { }
-void Scripts::CMDPUSHLOCATION(const byte *&pScript) { }
-
-void Scripts::cmdPlayerOff(const byte *&pScript) {
+void Scripts::CMDDISPINV() { }
+void Scripts::CMDSETTIMER() { }
+void Scripts::CMDCHECKTIMER() { }
+void Scripts::CMDSETTRAVEL() { }
+void Scripts::CMDSETVID() { }
+void Scripts::CMDPLAYVID() { }
+void Scripts::CMDPLOTIMAGE() { }
+void Scripts::CMDSETDISPLAY() { }
+void Scripts::CMDSETBUFFER() { }
+void Scripts::CMDSETSCROLL() { }
+void Scripts::CMDSAVERECT() { }
+void Scripts::CMDSETBUFVID() { }
+void Scripts::CMDPLAYBUFVID() { }
+void Scripts::CMDREMOVELAST() { }
+void Scripts::CMDSPECIAL() { }
+void Scripts::CMDSETCYCLE() { }
+void Scripts::CMDCYCLE() { }
+void Scripts::CMDCHARSPEAK() { }
+void Scripts::CMDTEXSPEAK() { }
+void Scripts::CMDTEXCHOICE() { }
+void Scripts::CMDWAIT() { }
+void Scripts::CMDSETCONPOS() { }
+void Scripts::CMDCHECKVFRAME() { }
+void Scripts::CMDJUMPCHOICE() { }
+void Scripts::CMDRETURNCHOICE() { }
+void Scripts::CMDCLEARBLOCK() { }
+void Scripts::CMDLOADSOUND() { }
+void Scripts::CMDFREESOUND() { }
+void Scripts::CMDSETVIDSND() { }
+void Scripts::CMDPLAYVIDSND() { }
+void Scripts::CMDPUSHLOCATION() { }
+
+void Scripts::cmdPlayerOff() {
 	_vm->_player->_playerOff = true;
 }
 
-void Scripts::cmdPlayerOn(const byte *&pScript) {
+void Scripts::cmdPlayerOn() {
 	_vm->_player->_playerOff = false;
 }
 
-void Scripts::CMDDEAD(const byte *&pScript) { }
-void Scripts::CMDFADEOUT(const byte *&pScript) { }
-void Scripts::CMDENDVID(const byte *&pScript) { }
-void Scripts::CMDHELP(const byte *&pScript) { }
-void Scripts::CMDCYCLEBACK(const byte *&pScript) { }
-void Scripts::CMDCHAPTER(const byte *&pScript) { }
-void Scripts::CMDSETHELP(const byte *&pScript) { }
-void Scripts::CMDCENTERPANEL(const byte *&pScript) { }
+void Scripts::CMDDEAD() { }
+void Scripts::CMDFADEOUT() { }
+void Scripts::CMDENDVID() { }
+void Scripts::CMDHELP() { }
+void Scripts::CMDCYCLEBACK() { }
+void Scripts::CMDCHAPTER() { }
+void Scripts::CMDSETHELP() { }
+void Scripts::CMDCENTERPANEL() { }
 
-void Scripts::cmdMainPanel(const byte *&pScript) { 
+void Scripts::cmdMainPanel() { 
 	if (_vm->_screen->_vesaMode) {
 		_vm->_room->init4Quads();
 		_vm->_screen->setPanel(0);
 	}
 }
 
-void Scripts::CMDRETFLASH(const byte *&pScript) { }
+void Scripts::CMDRETFLASH() { }
 
 
 } // End of namespace Access
diff --git a/engines/access/scripts.h b/engines/access/scripts.h
index d78b748..4375934 100644
--- a/engines/access/scripts.h
+++ b/engines/access/scripts.h
@@ -24,96 +24,98 @@
 #define ACCESS_SCRIPTS_H
 
 #include "common/scummsys.h"
+#include "common/memstream.h"
 
 namespace Access {
 
 class AccessEngine;
 class Scripts;
 
-typedef void(Scripts::*ScriptMethodPtr)(const byte *&pScript);
+typedef void(Scripts::*ScriptMethodPtr)();
 
 class Scripts {
+private:
+	const byte *_rawData;
+	Common::MemoryReadStream *_data;
 protected:
 	AccessEngine *_vm;
 
-	virtual void executeCommand(int commandIndex, const byte *&pScript);
-	void CMDOBJECT(const byte *&pScript);
-	void CMDENDOBJECT(const byte *&pScript);
-	void cmdJumpLook(const byte *&pScript);
-	void cmdJumpHelp(const byte *&pScript);
-	void cmdJumpGet(const byte *&pScript);
-	void cmdJumpMove(const byte *&pScript);
-	void cmdJumpUse(const byte *&pScript);
-	void cmdJumpTalk(const byte *&pScript);
-	void cmdNull(const byte *&pScript);
-	void CMDPRINT(const byte *&pScript);
-	void cmdRetPos(const byte *&pScript);
-	void CMDANIM(const byte *&pScript);
-	void cmdSetFlag(const byte *&pScript);
-	void CMDCHECKFLAG(const byte *&pScript);
+	virtual void executeCommand(int commandIndex);
+	void CMDOBJECT();
+	void CMDENDOBJECT();
+	void cmdJumpLook();
+	void cmdJumpHelp();
+	void cmdJumpGet();
+	void cmdJumpMove();
+	void cmdJumpUse();
+	void cmdJumpTalk();
+	void cmdNull();
+	void CMDPRINT();
+	void cmdRetPos();
+	void CMDANIM();
+	void cmdSetFlag();
+	void CMDCHECKFLAG();
 	
 	/**
 	 * Jump to another script
 	 */
-	void cmdGoto(const byte *&pScript);
+	void cmdGoto();
 	
-	void CMDSETINV(const byte *&pScript);
-	void CMDCHECKINV(const byte *&pScript);
-	void CMDSETTEX(const byte *&pScript);
-	void CMDNEWROOM(const byte *&pScript);
-	void CMDCONVERSE(const byte *&pScript);
-	void CMDCHECKFRAME(const byte *&pScript);
-	void CMDCHECKANIM(const byte *&pScript);
-	void CMDSND(const byte *&pScript);
-	void CMDRETNEG(const byte *&pScript);
-	void cmdCheckLoc(const byte *&pScript);
-	void cmdSetAnim(const byte *&pScript);
-	void CMDDISPINV(const byte *&pScript);
-	void CMDSETTIMER(const byte *&pScript);
-	void CMDCHECKTIMER(const byte *&pScript);
-	void CMDSETTRAVEL(const byte *&pScript);
-	void CMDSETVID(const byte *&pScript);
-	void CMDPLAYVID(const byte *&pScript);
-	void CMDPLOTIMAGE(const byte *&pScript);
-	void CMDSETDISPLAY(const byte *&pScript);
-	void CMDSETBUFFER(const byte *&pScript);
-	void CMDSETSCROLL(const byte *&pScript);
-	void CMDSAVERECT(const byte *&pScript);
-	void CMDSETBUFVID(const byte *&pScript);
-	void CMDPLAYBUFVID(const byte *&pScript);
-	void CMDREMOVELAST(const byte *&pScript);
-	void CMDSPECIAL(const byte *&pScript);
-	void CMDSETCYCLE(const byte *&pScript);
-	void CMDCYCLE(const byte *&pScript);
-	void CMDCHARSPEAK(const byte *&pScript);
-	void CMDTEXSPEAK(const byte *&pScript);
-	void CMDTEXCHOICE(const byte *&pScript);
-	void CMDWAIT(const byte *&pScript);
-	void CMDSETCONPOS(const byte *&pScript);
-	void CMDCHECKVFRAME(const byte *&pScript);
-	void CMDJUMPCHOICE(const byte *&pScript);
-	void CMDRETURNCHOICE(const byte *&pScript);
-	void CMDCLEARBLOCK(const byte *&pScript);
-	void CMDLOADSOUND(const byte *&pScript);
-	void CMDFREESOUND(const byte *&pScript);
-	void CMDSETVIDSND(const byte *&pScript);
-	void CMDPLAYVIDSND(const byte *&pScript);
-	void CMDPUSHLOCATION(const byte *&pScript);
-	void cmdPlayerOff(const byte *&pScript);
-	void cmdPlayerOn(const byte *&pScript);
-	void CMDDEAD(const byte *&pScript);
-	void CMDFADEOUT(const byte *&pScript);
-	void CMDENDVID(const byte *&pScript);
-	void CMDHELP(const byte *&pScript);
-	void CMDCYCLEBACK(const byte *&pScript);
-	void CMDCHAPTER(const byte *&pScript);
-	void CMDSETHELP(const byte *&pScript);
-	void CMDCENTERPANEL(const byte *&pScript);
-	void cmdMainPanel(const byte *&pScript);
-	void CMDRETFLASH(const byte *&pScript);
+	void CMDSETINV();
+	void CMDCHECKINV();
+	void CMDSETTEX();
+	void CMDNEWROOM();
+	void CMDCONVERSE();
+	void CMDCHECKFRAME();
+	void CMDCHECKANIM();
+	void CMDSND();
+	void CMDRETNEG();
+	void cmdCheckLoc();
+	void cmdSetAnim();
+	void CMDDISPINV();
+	void CMDSETTIMER();
+	void CMDCHECKTIMER();
+	void CMDSETTRAVEL();
+	void CMDSETVID();
+	void CMDPLAYVID();
+	void CMDPLOTIMAGE();
+	void CMDSETDISPLAY();
+	void CMDSETBUFFER();
+	void CMDSETSCROLL();
+	void CMDSAVERECT();
+	void CMDSETBUFVID();
+	void CMDPLAYBUFVID();
+	void CMDREMOVELAST();
+	void CMDSPECIAL();
+	void CMDSETCYCLE();
+	void CMDCYCLE();
+	void CMDCHARSPEAK();
+	void CMDTEXSPEAK();
+	void CMDTEXCHOICE();
+	void CMDWAIT();
+	void CMDSETCONPOS();
+	void CMDCHECKVFRAME();
+	void CMDJUMPCHOICE();
+	void CMDRETURNCHOICE();
+	void CMDCLEARBLOCK();
+	void CMDLOADSOUND();
+	void CMDFREESOUND();
+	void CMDSETVIDSND();
+	void CMDPLAYVIDSND();
+	void CMDPUSHLOCATION();
+	void cmdPlayerOff();
+	void cmdPlayerOn();
+	void CMDDEAD();
+	void CMDFADEOUT();
+	void CMDENDVID();
+	void CMDHELP();
+	void CMDCYCLEBACK();
+	void CMDCHAPTER();
+	void CMDSETHELP();
+	void CMDCENTERPANEL();
+	void cmdMainPanel();
+	void CMDRETFLASH();
 public:
-	const byte *_script;
-	const byte *_scriptLoc;
 	int _sequence;
 	bool _endFlag;
 	int _returnCode;
@@ -123,9 +125,11 @@ public:
 
 	virtual ~Scripts();
 
+	void setScript(const byte *data, int size);
+
 	void freeScriptData();
 
-	const byte *searchForSequence();
+	void searchForSequence();
 	
 	int executeScript();
 };


Commit: d04a6d2d7a9bfc3bcfd3ad94c48f878d1143ee32
    https://github.com/scummvm/scummvm/commit/d04a6d2d7a9bfc3bcfd3ad94c48f878d1143ee32
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-09T17:57:34-04:00

Commit Message:
ACCESS: Beginnings of inventory management

Changed paths:
  A engines/access/inventory.cpp
  A engines/access/inventory.h
    engines/access/access.cpp
    engines/access/access.h
    engines/access/amazon/amazon_game.cpp
    engines/access/amazon/amazon_resources.cpp
    engines/access/amazon/amazon_resources.h
    engines/access/module.mk
    engines/access/scripts.cpp
    engines/access/scripts.h



diff --git a/engines/access/access.cpp b/engines/access/access.cpp
index c98588f..ee524d7 100644
--- a/engines/access/access.cpp
+++ b/engines/access/access.cpp
@@ -35,6 +35,7 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc)
 	_debugger = nullptr;
 	_events = nullptr;
 	_files = nullptr;
+	_inventory = nullptr;
 	_player = nullptr;
 	_room = nullptr;
 	_screen = nullptr;
@@ -56,10 +57,6 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc)
 	_music = nullptr;
 	_title = nullptr;
 	_converseMode = 0;
-	_startInvItem = 0;
-	_startAboutItem = 0;
-	_startTravelItem = 0;
-	_startInvBox = 0;
 	_startAboutBox = 0;
 	_startTravelBox = 0;
 	_numImages = 0;
@@ -104,7 +101,6 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc)
 	_antFlag = false;
 	_allenFlag = false;
 	_noSound = false;
-	Common::fill(&inv[0], &inv[85], 0);
 	Common::fill(&_help1[0], &_help1[366], 0);
 	Common::fill(&_help2[0], &_help2[366], 0);
 	Common::fill(&_help1[0], &_help3[366], 0);
@@ -126,6 +122,7 @@ AccessEngine::~AccessEngine() {
 	delete _debugger;
 	delete _events;
 	delete _files;
+	delete _inventory;
 	delete _player;
 	delete _room;
 	delete _screen;
@@ -170,6 +167,7 @@ void AccessEngine::initialize() {
 	_debugger = new Debugger(this);
 	_events = new EventsManager(this);
 	_files = new FileManager(this);
+	_inventory = new InventoryManager(this);
 	_player = new Player(this);
 	_screen = new Screen(this);
 	_sound = new SoundManager(this, _mixer);
diff --git a/engines/access/access.h b/engines/access/access.h
index 56600e4..0fa2c14 100644
--- a/engines/access/access.h
+++ b/engines/access/access.h
@@ -35,6 +35,7 @@
 #include "access/debugger.h"
 #include "access/events.h"
 #include "access/files.h"
+#include "access/inventory.h"
 #include "access/player.h"
 #include "access/room.h"
 #include "access/screen.h"
@@ -105,6 +106,7 @@ public:
 	Debugger *_debugger;
 	EventsManager *_events;
 	FileManager *_files;
+	InventoryManager *_inventory;
 	Player *_player;
 	Room *_room;
 	Screen *_screen;
@@ -139,10 +141,8 @@ public:
 	byte *_music;
 	byte *_title;
 	int _converseMode;
-	int _startInvItem;
 	int _startAboutItem;
 	int _startTravelItem;
-	int _startInvBox;
 	int _startAboutBox;
 	int _startTravelBox;
 	bool _currentCharFlag;
@@ -164,7 +164,7 @@ public:
 	int _intTim[3];
 	int _timer[3];
 	bool _timerFlag;
-	byte _flags[99];
+	Common::Array<int> _flags;
 	byte _useItem[23];
 	int _guardLoc;
 	int _guardFind;
@@ -181,7 +181,6 @@ public:
 	bool _antFlag;
 	bool _allenFlag;
 	bool _noSound;
-	int inv[85];
 	byte _help1[366];
 	byte _help2[366];
 	byte _help3[366];
diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp
index 7a16036..8267c85 100644
--- a/engines/access/amazon/amazon_game.cpp
+++ b/engines/access/amazon/amazon_game.cpp
@@ -47,6 +47,7 @@ AmazonEngine::AmazonEngine(OSystem *syst, const AccessGameDescription *gameDesc)
 	_rawInactiveY = 0;
 	_inactiveYOff = 0;
 	Common::fill(&_esTabTable[0], &_esTabTable[100], 0);
+	_flags.resize(122);
 }
 
 AmazonEngine::~AmazonEngine() {
diff --git a/engines/access/amazon/amazon_resources.cpp b/engines/access/amazon/amazon_resources.cpp
index 2f9fe02..87f2966 100644
--- a/engines/access/amazon/amazon_resources.cpp
+++ b/engines/access/amazon/amazon_resources.cpp
@@ -986,6 +986,27 @@ extern const byte *CHARTBL[] = {
 	CRACK, LETTER
 };
 
+const char *const INVENTORY_NAMES[] = {
+	"RAT", "ALCOHOL", "SAFE COMBINATION", "BEAKER", "MICROFILM",
+	"VAULT KEY", "BOLT CUTTERS", "BLOWGUN", "LOVE POTION", "MONEY",
+	"DARTS", "TAPE", "JUNGLE POTION", "MOVIE", "CABINET KEY",
+	"DISPLAY CASE KEY", "FLITCH', 27h, 'S CAR KEYS", "COAT HANGER",
+	"CROWBAR", "COMPASS", "MAP", "LETTER OPENER", "LETTER",
+	"DECODER", "DIPPED DART", "LOADED BLOWGUN", "CARD", "JERRYCAN",
+	"CIGARETTES", "BIKE PUMP", "PARACHUTE", "PESO", "PEPPERS",
+	"MACHETE", "POISON ROOT", "AMMUNITION", "PADDLE", "FISHING NET",
+	"RAT TRAP", "CHEESE", "LOADED TRAP", "KNIFE", "CHOPPED PEPPERS",
+	"LIGHTER", "LADDER", "SMALL POLE", "JEEP KEY", "CHAIN", "ARROW",
+	"FILLED JERRY CAN", "EXPLOSIVES", "GEIGER COUNTER", "VINE",
+	"GOLD NUGGET", "HOLLOW REED", "AMAZON QUEEN KEYS", "FISHING POLE",
+	"HARPOON", "RAG", "BOTTLE OF RUM", "RAG IN BOTTLE", "MOLOTOV COCKTAIL",
+	"JUNGLE PLANT", "LADLE", "WORM", "FISH", "FIREWORKS", "BAITED POLE",
+	"FILLED LADLE", "EMERALD", "SMALL KEY", "SCROLL", "LIT EXPLOSIVES",
+	"LIGHTER", "BROKEN SPEAR", "SHOE LACES", "TORCH", "LACES AND SPEAR",
+	"KNIFE SPEAR", "GARBAGE CAN", "RAFT", "INFLATED RAFT",
+	"JASON'S CAR KEYS", "PESO BILLS", "PLANK"
+};
+
 } // End of namespace Amazon
 
 } // End of namespace Access
diff --git a/engines/access/amazon/amazon_resources.h b/engines/access/amazon/amazon_resources.h
index 7601138..c9e3fe9 100644
--- a/engines/access/amazon/amazon_resources.h
+++ b/engines/access/amazon/amazon_resources.h
@@ -39,6 +39,8 @@ extern const byte *ROOM_TABLE[];
 
 extern const byte *CHARTBL[];
 
+extern const char *const INVENTORY_NAMES[];
+
 } // End of namespace Amazon
 
 } // End of namespace Access
diff --git a/engines/access/inventory.cpp b/engines/access/inventory.cpp
new file mode 100644
index 0000000..b36c534
--- /dev/null
+++ b/engines/access/inventory.cpp
@@ -0,0 +1,61 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "access/inventory.h"
+#include "access/access.h"
+#include "access/amazon/amazon_resources.h"
+
+namespace Access {
+
+InventoryManager::InventoryManager(AccessEngine *vm) : Manager(vm) {
+	_startInvItem = 0;
+	_startInvBox = 0;
+	_invChangeFlag = true;
+	_startAboutItem = 0;
+	_startTravelItem = 0;
+
+	const char *const *names = Amazon::INVENTORY_NAMES;
+	switch (vm->getGameID()) {
+	case GType_Amazon:
+		_inv.resize(85);
+		break;
+	default:
+		error("Unknown game");
+	}
+
+	for (uint i = 0; i < _inv.size(); ++i)
+		_names.push_back(names[i]);
+}
+
+int &InventoryManager::operator[](int idx) {
+	return _inv[idx];
+}
+
+int InventoryManager::useItem() { 
+	return _vm->_flags[USE_ITEM_FLAG_INDEX]; 
+}
+
+void InventoryManager::setUseItem(int itemId) { 
+	_vm->_flags[USE_ITEM_FLAG_INDEX] = itemId; 
+}
+
+} // End of namespace Access
diff --git a/engines/access/inventory.h b/engines/access/inventory.h
new file mode 100644
index 0000000..2f1248e
--- /dev/null
+++ b/engines/access/inventory.h
@@ -0,0 +1,56 @@
+/* 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 ACCESS_INVENTORY_H
+#define ACCESS_INVENTORY_H
+
+#include "common/scummsys.h"
+#include "common/array.h"
+#include "common/rect.h"
+#include "common/str-array.h"
+#include "access/data.h"
+
+namespace Access {
+
+#define USE_ITEM_FLAG_INDEX 100
+
+class InventoryManager : public Manager {
+public:
+	Common::Array<int> _inv;
+	Common::StringArray _names;
+	int _startInvItem;
+	int _startInvBox;
+	bool _invChangeFlag;
+	int _startAboutItem;
+	int _startTravelItem;
+public:
+	InventoryManager(AccessEngine *vm);
+	
+	int &operator[](int idx);
+
+	int useItem();
+	void setUseItem(int itemId);
+};
+
+} // End of namespace Access
+
+#endif /* ACCESS_INVENTORY_H */
diff --git a/engines/access/module.mk b/engines/access/module.mk
index 24c237a..7c089fe 100644
--- a/engines/access/module.mk
+++ b/engines/access/module.mk
@@ -10,6 +10,7 @@ MODULE_OBJS := \
 	detection.o \
 	events.o \
 	files.o \
+	inventory.o \
 	player.o \
 	resources.o \
 	room.o \
diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp
index bc86e09..66b16e9 100644
--- a/engines/access/scripts.cpp
+++ b/engines/access/scripts.cpp
@@ -87,7 +87,7 @@ void Scripts::executeCommand(int commandIndex) {
 		&Scripts::cmdJumpUse, &Scripts::cmdJumpTalk, &Scripts::cmdNull, 
 		&Scripts::CMDPRINT, &Scripts::cmdRetPos, &Scripts::CMDANIM,
 		&Scripts::cmdSetFlag, &Scripts::CMDCHECKFLAG, &Scripts::cmdGoto, 
-		&Scripts::CMDSETINV, &Scripts::CMDSETINV, &Scripts::CMDCHECKINV, 
+		&Scripts::cmdSetInventory, &Scripts::cmdSetInventory, &Scripts::cmdCheckInventory, 
 		&Scripts::CMDSETTEX, &Scripts::CMDNEWROOM, &Scripts::CMDCONVERSE, 
 		&Scripts::CMDCHECKFRAME, &Scripts::CMDCHECKANIM, &Scripts::CMDSND, 
 		&Scripts::CMDRETNEG, &Scripts::cmdRetPos, &Scripts::cmdCheckLoc, 
@@ -175,7 +175,7 @@ void Scripts::CMDANIM() { }
 void Scripts::cmdSetFlag() { 
 	int flagNum = _data->readByte();
 	byte flagVal = _data->readByte();
-	assert(flagNum < 100);
+
 	_vm->_flags[flagNum] = flagVal;
 }
 
@@ -195,8 +195,26 @@ void Scripts::cmdGoto() {
 	searchForSequence();
 }
 
-void Scripts::CMDSETINV() { }
-void Scripts::CMDCHECKINV() { }
+void Scripts::cmdSetInventory() { 
+	int itemId = _data->readByte();
+	int itemVal = _data->readByte();
+
+	(*_vm->_inventory)[itemId] = itemVal;
+	_vm->_inventory->_startInvItem = 0;
+	_vm->_inventory->_startInvBox = 0;
+	_vm->_inventory->_invChangeFlag = true;
+}
+
+void Scripts::cmdCheckInventory() { 
+	int itemId = _data->readUint16LE();
+	int itemVal = _data->readUint16LE();
+
+	if ((*_vm->_inventory)[itemId] == itemVal)
+		cmdGoto();
+	else
+		_data->skip(2);
+}
+
 void Scripts::CMDSETTEX() { }
 void Scripts::CMDNEWROOM() { }
 void Scripts::CMDCONVERSE() { }
diff --git a/engines/access/scripts.h b/engines/access/scripts.h
index 4375934..6bf69c4 100644
--- a/engines/access/scripts.h
+++ b/engines/access/scripts.h
@@ -61,8 +61,8 @@ protected:
 	 */
 	void cmdGoto();
 	
-	void CMDSETINV();
-	void CMDCHECKINV();
+	void cmdSetInventory();
+	void cmdCheckInventory();
 	void CMDSETTEX();
 	void CMDNEWROOM();
 	void CMDCONVERSE();


Commit: 127a0eeadd16719e212c19d7938158d75f51568e
    https://github.com/scummvm/scummvm/commit/127a0eeadd16719e212c19d7938158d75f51568e
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-09T18:28:33-04:00

Commit Message:
ACCESS: Cleanup of Amazon game flags

Changed paths:
    engines/access/access.cpp
    engines/access/access.h
    engines/access/amazon/amazon_game.cpp
    engines/access/amazon/amazon_game.h
    engines/access/inventory.cpp
    engines/access/inventory.h



diff --git a/engines/access/access.cpp b/engines/access/access.cpp
index ee524d7..122a8a0 100644
--- a/engines/access/access.cpp
+++ b/engines/access/access.cpp
@@ -30,7 +30,8 @@
 namespace Access {
 
 AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc) :
-		_gameDescription(gameDesc), Engine(syst), _randomSource("Access") {
+		_gameDescription(gameDesc), Engine(syst), _randomSource("Access"),
+		_useItem(_flags[100]), _startup(_flags[170]), _manScaleOff(_flags[172]) {
 	_animation = nullptr;
 	_debugger = nullptr;
 	_events = nullptr;
@@ -80,27 +81,11 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc)
 	_intTim[3] = 0;
 	_timer[3] = 0;
 	_timerFlag = false;
-	Common::fill(&_flags[0], &_flags[99], 0);
-	Common::fill(&_useItem[0], &_useItem[23], 0);
 	Common::fill(&_establishTable[0], &_establishTable[100], 0);
+	Common::fill(&_flags[0], &_flags[256], 0);
 	_establishFlag = false;
 	_establishMode = 0;
 	_establishGroup = 0;
-	_guardLoc = 0;
-	_guardFind = 0;
-	_helpLevel = 0;
-	_jasMayaFlag = 0;
-	_moreHelp = 0;
-	_startup = 0;
-	_flashbackFlag = false;
-	_manScaleOff = 0;
-	_riverFlag = false;
-	_antOutFlag = false;
-	_badEnd = 0;
-	_noHints = false;
-	_antFlag = false;
-	_allenFlag = false;
-	_noSound = false;
 	Common::fill(&_help1[0], &_help1[366], 0);
 	Common::fill(&_help2[0], &_help2[366], 0);
 	Common::fill(&_help1[0], &_help3[366], 0);
diff --git a/engines/access/access.h b/engines/access/access.h
index 0fa2c14..99bc201 100644
--- a/engines/access/access.h
+++ b/engines/access/access.h
@@ -164,23 +164,7 @@ public:
 	int _intTim[3];
 	int _timer[3];
 	bool _timerFlag;
-	Common::Array<int> _flags;
-	byte _useItem[23];
-	int _guardLoc;
-	int _guardFind;
-	int _helpLevel;
-	int _jasMayaFlag;
-	int _moreHelp;
-	int _startup;
-	bool _flashbackFlag;
-	int _manScaleOff;
-	bool _riverFlag;
-	bool _antOutFlag;
-	int _badEnd;
-	bool _noHints;
-	bool _antFlag;
-	bool _allenFlag;
-	bool _noSound;
+	int _flags[256];
 	byte _help1[366];
 	byte _help2[366];
 	byte _help3[366];
@@ -195,6 +179,12 @@ public:
 	int _rKeyFlag;
 	int _mapOffset;
 	int _screenVirtX;
+
+	// Fields mapped into the flags array
+	int &_useItem;
+	int &_startup;
+	int &_manScaleOff;
+
 public:
 	AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc);
 	virtual ~AccessEngine();
diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp
index 8267c85..9c51616 100644
--- a/engines/access/amazon/amazon_game.cpp
+++ b/engines/access/amazon/amazon_game.cpp
@@ -31,7 +31,12 @@ namespace Access {
 namespace Amazon {
 
 AmazonEngine::AmazonEngine(OSystem *syst, const AccessGameDescription *gameDesc) :
-		AccessEngine(syst, gameDesc) {
+		AccessEngine(syst, gameDesc),
+		_guardLocation(_flags[122]), _guardFind(_flags[128]), _helpLevel(_flags[167]), 
+		_jasMayaFlag(_flags[168]), _moreHelp(_flags[169]), _flashbackFlag(_flags[171]),
+		_riverFlag(_flags[185]), _aniOutFlag(_flags[195]), _badEnd(_flags[218]), 
+		_noHints(_flags[219]), _aniFlag(_flags[229]), _allenFlag(_flags[237]), 
+		_noSound(_flags[239]) {
 	_skipStart = false;
 
 	_canoeLane = 0;
@@ -47,7 +52,6 @@ AmazonEngine::AmazonEngine(OSystem *syst, const AccessGameDescription *gameDesc)
 	_rawInactiveY = 0;
 	_inactiveYOff = 0;
 	Common::fill(&_esTabTable[0], &_esTabTable[100], 0);
-	_flags.resize(122);
 }
 
 AmazonEngine::~AmazonEngine() {
diff --git a/engines/access/amazon/amazon_game.h b/engines/access/amazon/amazon_game.h
index b998b1d..c927ad9 100644
--- a/engines/access/amazon/amazon_game.h
+++ b/engines/access/amazon/amazon_game.h
@@ -48,6 +48,21 @@ private:
 	int _inactiveYOff;
 	int _esTabTable[100];
 
+	// Fields that are mapped to flags
+	int &_guardLocation;
+	int &_guardFind;
+	int &_helpLevel;
+	int &_jasMayaFlag;
+	int &_moreHelp;
+	int &_flashbackFlag;
+	int &_riverFlag;
+	int &_aniOutFlag;
+	int &_badEnd;
+	int &_noHints;
+	int &_aniFlag;
+	int &_allenFlag;
+	int &_noSound;
+
 	/**
 	 * Do the game introduction
 	 */
diff --git a/engines/access/inventory.cpp b/engines/access/inventory.cpp
index b36c534..5d2957b 100644
--- a/engines/access/inventory.cpp
+++ b/engines/access/inventory.cpp
@@ -51,11 +51,11 @@ int &InventoryManager::operator[](int idx) {
 }
 
 int InventoryManager::useItem() { 
-	return _vm->_flags[USE_ITEM_FLAG_INDEX]; 
+	return _vm->_useItem;
 }
 
 void InventoryManager::setUseItem(int itemId) { 
-	_vm->_flags[USE_ITEM_FLAG_INDEX] = itemId; 
+	_vm->_useItem = itemId; 
 }
 
 } // End of namespace Access
diff --git a/engines/access/inventory.h b/engines/access/inventory.h
index 2f1248e..1f229dd 100644
--- a/engines/access/inventory.h
+++ b/engines/access/inventory.h
@@ -31,8 +31,6 @@
 
 namespace Access {
 
-#define USE_ITEM_FLAG_INDEX 100
-
 class InventoryManager : public Manager {
 public:
 	Common::Array<int> _inv;


Commit: 33f432d9891fd07a9d8d6130ef76a8bb14b13a4b
    https://github.com/scummvm/scummvm/commit/33f432d9891fd07a9d8d6130ef76a8bb14b13a4b
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-09T19:18:10-04:00

Commit Message:
ACCESS: Fix skipping bytes in executeScript method

Changed paths:
    engines/access/scripts.cpp
    engines/access/scripts.h



diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp
index 66b16e9..dc3c62a 100644
--- a/engines/access/scripts.cpp
+++ b/engines/access/scripts.cpp
@@ -70,8 +70,8 @@ int Scripts::executeScript() {
 
 	do {
 		// Get next command, skipping over script start start if it's being pointed to
-		for (_scriptCommand = _data->readByte(); _scriptCommand == SCRIPT_START_BYTE;
-			_data->skip(2));
+		while ((_scriptCommand = _data->readByte()) == SCRIPT_START_BYTE)
+			_data->skip(2);
 
 		assert(_scriptCommand >= 0x80);
 		executeCommand(_scriptCommand - 0x80);
@@ -86,7 +86,7 @@ void Scripts::executeCommand(int commandIndex) {
 		&Scripts::cmdJumpHelp, &Scripts::cmdJumpGet, &Scripts::cmdJumpMove,
 		&Scripts::cmdJumpUse, &Scripts::cmdJumpTalk, &Scripts::cmdNull, 
 		&Scripts::CMDPRINT, &Scripts::cmdRetPos, &Scripts::CMDANIM,
-		&Scripts::cmdSetFlag, &Scripts::CMDCHECKFLAG, &Scripts::cmdGoto, 
+		&Scripts::cmdSetFlag, &Scripts::cmdCheckFlag, &Scripts::cmdGoto, 
 		&Scripts::cmdSetInventory, &Scripts::cmdSetInventory, &Scripts::cmdCheckInventory, 
 		&Scripts::CMDSETTEX, &Scripts::CMDNEWROOM, &Scripts::CMDCONVERSE, 
 		&Scripts::CMDCHECKFRAME, &Scripts::CMDCHECKANIM, &Scripts::CMDSND, 
@@ -176,15 +176,16 @@ void Scripts::cmdSetFlag() {
 	int flagNum = _data->readByte();
 	byte flagVal = _data->readByte();
 
+	assert(flagNum < 256);
 	_vm->_flags[flagNum] = flagVal;
 }
 
-void Scripts::CMDCHECKFLAG() { 
+void Scripts::cmdCheckFlag() { 
 	int flagNum = _data->readUint16LE();
 	int flagVal = _data->readUint16LE();
 	assert(flagNum < 100);
 
-	if (_vm->_flags[flagNum] == (flagVal & 0xff))
+	if (_vm->_flags[flagNum] == flagVal)
 		cmdGoto();
 	else
 		_data->skip(2);
diff --git a/engines/access/scripts.h b/engines/access/scripts.h
index 6bf69c4..30bffe8 100644
--- a/engines/access/scripts.h
+++ b/engines/access/scripts.h
@@ -54,7 +54,7 @@ protected:
 	void cmdRetPos();
 	void CMDANIM();
 	void cmdSetFlag();
-	void CMDCHECKFLAG();
+	void cmdCheckFlag();
 	
 	/**
 	 * Jump to another script


Commit: f495d390993a8a0d1e785c71fa36553fab17f90b
    https://github.com/scummvm/scummvm/commit/f495d390993a8a0d1e785c71fa36553fab17f90b
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-08-10T01:44:24+02:00

Commit Message:
ACCESS: Implement some more opcodes

Changed paths:
    engines/access/animation.h
    engines/access/scripts.cpp
    engines/access/scripts.h



diff --git a/engines/access/animation.h b/engines/access/animation.h
index 010fab9..879d1e9 100644
--- a/engines/access/animation.h
+++ b/engines/access/animation.h
@@ -32,8 +32,6 @@ namespace Access {
 class Animation;
 
 class AnimationManager : public Manager {
-private:
-	Animation *findAnimation(int animId);
 public:
 	const byte *_anim;
 	Animation *_animation;
@@ -44,6 +42,7 @@ public:
 	void freeAnimationData();
 	void clearTimers();
 
+	Animation *findAnimation(int animId);
 	Animation *setAnimation(int animId);
 
 	void setAnimTimer(Animation *anim);
diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp
index dc3c62a..fe53c67 100644
--- a/engines/access/scripts.cpp
+++ b/engines/access/scripts.cpp
@@ -89,14 +89,14 @@ void Scripts::executeCommand(int commandIndex) {
 		&Scripts::cmdSetFlag, &Scripts::cmdCheckFlag, &Scripts::cmdGoto, 
 		&Scripts::cmdSetInventory, &Scripts::cmdSetInventory, &Scripts::cmdCheckInventory, 
 		&Scripts::CMDSETTEX, &Scripts::CMDNEWROOM, &Scripts::CMDCONVERSE, 
-		&Scripts::CMDCHECKFRAME, &Scripts::CMDCHECKANIM, &Scripts::CMDSND, 
+		&Scripts::CMDCHECKFRAME, &Scripts::cmdCheckAnim, &Scripts::CMDSND, 
 		&Scripts::CMDRETNEG, &Scripts::cmdRetPos, &Scripts::cmdCheckLoc, 
 		&Scripts::cmdSetAnim, &Scripts::CMDDISPINV, &Scripts::CMDSETTIMER, 
 		&Scripts::CMDSETTIMER, &Scripts::CMDCHECKTIMER, &Scripts::CMDSETTRAVEL,
 		&Scripts::CMDSETTRAVEL, &Scripts::CMDSETVID, &Scripts::CMDPLAYVID, 
 		&Scripts::CMDPLOTIMAGE, &Scripts::CMDSETDISPLAY, &Scripts::CMDSETBUFFER, 
 		&Scripts::CMDSETSCROLL, &Scripts::CMDSAVERECT, &Scripts::CMDSAVERECT, 
-		&Scripts::CMDSETBUFVID, &Scripts::CMDPLAYBUFVID, &Scripts::CMDREMOVELAST, 
+		&Scripts::CMDSETBUFVID, &Scripts::CMDPLAYBUFVID, &Scripts::cmeRemoveLast, 
 		&Scripts::CMDSPECIAL, &Scripts::CMDSPECIAL, &Scripts::CMDSPECIAL,
 		&Scripts::CMDSETCYCLE, &Scripts::CMDCYCLE, &Scripts::CMDCHARSPEAK, 
 		&Scripts::CMDTEXSPEAK, &Scripts::CMDTEXCHOICE, &Scripts::CMDWAIT, 
@@ -105,7 +105,7 @@ void Scripts::executeCommand(int commandIndex) {
 		&Scripts::CMDFREESOUND, &Scripts::CMDSETVIDSND, &Scripts::CMDPLAYVIDSND,
 		&Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, 
 		&Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, &Scripts::cmdPlayerOff, 
-		&Scripts::cmdPlayerOn, &Scripts::CMDDEAD, &Scripts::CMDFADEOUT,
+		&Scripts::cmdPlayerOn, &Scripts::CMDDEAD, &Scripts::cmdFadeOut,
 		&Scripts::CMDENDVID, &Scripts::CMDHELP, &Scripts::CMDCYCLEBACK, 
 		&Scripts::CMDCHAPTER, &Scripts::CMDSETHELP, &Scripts::CMDCENTERPANEL,
 		&Scripts::cmdMainPanel, &Scripts::CMDRETFLASH
@@ -220,7 +220,18 @@ void Scripts::CMDSETTEX() { }
 void Scripts::CMDNEWROOM() { }
 void Scripts::CMDCONVERSE() { }
 void Scripts::CMDCHECKFRAME() { }
-void Scripts::CMDCHECKANIM() { }
+
+void Scripts::cmdCheckAnim() {
+	int id = _data->readUint16LE();
+	Animation *anim = _vm->_animation->findAnimation(id);
+
+	if (anim->_currentLoopCount == -1) {
+		_data->skip(2);
+		cmdGoto();
+	} else
+		_data->skip(4);
+}
+
 void Scripts::CMDSND() { }
 void Scripts::CMDRETNEG() { }
 
@@ -258,7 +269,11 @@ void Scripts::CMDSETSCROLL() { }
 void Scripts::CMDSAVERECT() { }
 void Scripts::CMDSETBUFVID() { }
 void Scripts::CMDPLAYBUFVID() { }
-void Scripts::CMDREMOVELAST() { }
+
+void Scripts::cmeRemoveLast() {
+	--_vm->_numAnimTimers;
+}
+
 void Scripts::CMDSPECIAL() { }
 void Scripts::CMDSETCYCLE() { }
 void Scripts::CMDCYCLE() { }
@@ -286,7 +301,11 @@ void Scripts::cmdPlayerOn() {
 }
 
 void Scripts::CMDDEAD() { }
-void Scripts::CMDFADEOUT() { }
+
+void Scripts::cmdFadeOut() {
+	_vm->_screen->forceFadeOut();
+}
+
 void Scripts::CMDENDVID() { }
 void Scripts::CMDHELP() { }
 void Scripts::CMDCYCLEBACK() { }
diff --git a/engines/access/scripts.h b/engines/access/scripts.h
index 30bffe8..79ae478 100644
--- a/engines/access/scripts.h
+++ b/engines/access/scripts.h
@@ -67,7 +67,7 @@ protected:
 	void CMDNEWROOM();
 	void CMDCONVERSE();
 	void CMDCHECKFRAME();
-	void CMDCHECKANIM();
+	void cmdCheckAnim();
 	void CMDSND();
 	void CMDRETNEG();
 	void cmdCheckLoc();
@@ -85,7 +85,7 @@ protected:
 	void CMDSAVERECT();
 	void CMDSETBUFVID();
 	void CMDPLAYBUFVID();
-	void CMDREMOVELAST();
+	void cmeRemoveLast();
 	void CMDSPECIAL();
 	void CMDSETCYCLE();
 	void CMDCYCLE();
@@ -106,7 +106,7 @@ protected:
 	void cmdPlayerOff();
 	void cmdPlayerOn();
 	void CMDDEAD();
-	void CMDFADEOUT();
+	void cmdFadeOut();
 	void CMDENDVID();
 	void CMDHELP();
 	void CMDCYCLEBACK();


Commit: c1613178c3c89d6a088814eeeeffc6935852140f
    https://github.com/scummvm/scummvm/commit/c1613178c3c89d6a088814eeeeffc6935852140f
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-09T22:07:28-04:00

Commit Message:
ACCESS: Implemented player loading

Changed paths:
    engines/access/access.cpp
    engines/access/asurface.cpp
    engines/access/asurface.h
    engines/access/player.cpp
    engines/access/player.h
    engines/access/resources.cpp
    engines/access/resources.h
    engines/access/screen.cpp
    engines/access/screen.h



diff --git a/engines/access/access.cpp b/engines/access/access.cpp
index 122a8a0..d0bc1a8 100644
--- a/engines/access/access.cpp
+++ b/engines/access/access.cpp
@@ -118,7 +118,6 @@ AccessEngine::~AccessEngine() {
 	_buffer2.free();
 
 	freeCells();
-	delete[] _man;
 	delete[] _man1;
 	delete[] _inactive;
 	delete[] _manPal1;
diff --git a/engines/access/asurface.cpp b/engines/access/asurface.cpp
index b791186..a0a790d 100644
--- a/engines/access/asurface.cpp
+++ b/engines/access/asurface.cpp
@@ -30,13 +30,4 @@ void ASurface::clearBuffer() {
 	Common::fill(pSrc, pSrc + w * h, 0);
 }
 
-void ASurface::setScaleTable(int scale) {
-	int total = 0;
-	for (int idx = 0; idx < 256; ++idx) {
-		_scaleTable1[idx] = total >> 8;
-		_scaleTable2[idx] = total & 0xff;
-		total += scale;
-	}
-}
-
 } // End of namespace Access
diff --git a/engines/access/asurface.h b/engines/access/asurface.h
index 8570676..ace1b23 100644
--- a/engines/access/asurface.h
+++ b/engines/access/asurface.h
@@ -30,15 +30,10 @@
 namespace Access {
 
 class ASurface : public Graphics::Surface {
-private:
-	byte _scaleTable1[256];
-	byte _scaleTable2[256];
 public:
 	void clearBuffer();
 
 	void copyBuffer(Graphics::Surface *src) { copyFrom(*src); }
-
-	void setScaleTable(int scale);
 };
 
 } // End of namespace Access
diff --git a/engines/access/player.cpp b/engines/access/player.cpp
index e4ef0eb..f0cceb7 100644
--- a/engines/access/player.cpp
+++ b/engines/access/player.cpp
@@ -20,19 +20,22 @@
  *
  */
 
-#include "access/player.h"
 #include "common/algorithm.h"
 #include "common/textconsole.h"
+#include "access/player.h"
+#include "access/access.h"
+#include "access/resources.h"
 
 namespace Access {
 
-Player::Player(AccessEngine *vm): _vm(vm) {
-	_field0 = 0;
-	_monData = nullptr;
+Player::Player(AccessEngine *vm): Manager(vm) {
 	Common::fill(&_walkOffRight[0], &_walkOffRight[PLAYER_DATA_COUNT], 0);
 	Common::fill(&_walkOffLeft[0], &_walkOffLeft[PLAYER_DATA_COUNT], 0);
 	Common::fill(&_walkOffUp[0], &_walkOffUp[PLAYER_DATA_COUNT], 0);
 	Common::fill(&_walkOffDown[0], &_walkOffDown[PLAYER_DATA_COUNT], 0);
+
+	_field0 = 0;
+	_monData = nullptr;
 	_rawTempL = 0;
 	_rawXTemp = 0;
 	_rawYTempL = 0;
@@ -42,18 +45,102 @@ Player::Player(AccessEngine *vm): _vm(vm) {
 	_playerYLow = 0;
 	_playerY = 0;
 	_frame = 0;
-
 	_playerOff = false;
-
+	_leftDelta = _rightDelta = 0;
+	_upDelta = _downDelta = 0;
+	_scrollConst = 0;
 	_roomNumber = 0;
 }
 
 void Player::load() {
-	// TODO
+	if (_vm->_room->_roomFlag == 3) {
+		_playerOffset.x = _vm->_screen->_scaleTable1[8];
+		_playerOffset.y = _vm->_screen->_scaleTable1[11];
+		_leftDelta = 0;
+		_rightDelta = 8;
+		_upDelta = 2;
+		_downDelta = -2;
+		_scrollConst = 2;
+
+		for (int i = 0; i < PLAYER_DATA_COUNT; ++i) {
+			_walkOffRight[i] = OVEROFFR[i];
+			_walkOffLeft[i] = OVEROFFL[i];
+			_walkOffUp[i] = OVEROFFU[i];
+			_walkOffDown[i] = OVEROFFD[i];
+			_walkOffUR[i].x = OVEROFFURX[i];
+			_walkOffUR[i].y = OVEROFFURY[i];
+			_walkOffDR[i].x = OVEROFFDRX[i];
+			_walkOffDR[i].y = OVEROFFDRY[i];
+			_walkOffUL[i].x = OVEROFFULX[i];
+			_walkOffUL[i].y = OVEROFFULY[i];
+			_walkOffDL[i].x = OVEROFFDLX[i];
+			_walkOffDL[i].y = OVEROFFDLY[i];
+		}
+
+		_vm->_timers[8]._initTm = 7;
+		_vm->_timers[8]._timer = 7;
+		_vm->_timers[8]._flag = true;
+
+		_sideWalkMin = 0;
+		_sideWalkMax = 5;
+		_upWalkMin = 12;
+		_upWalkMax = 17;
+		_downWalkMin = 6;
+		_downWalkMax = 11;
+		_diagUpWalkMin = 0;
+		_diagUpWalkMax = 5;
+		_diagDownWalkMin = 0;
+		_diagDownWalkMax = 5;
+		_guard = Common::Point(56, 190);
+	} else {
+		_playerOffset.x = _vm->_screen->_scaleTable1[25];
+		_playerOffset.y = _vm->_screen->_scaleTable1[67];
+		_leftDelta = -3;
+		_rightDelta = 33;
+		_upDelta = 5;
+		_downDelta = -10;
+		_scrollConst = 5;
+
+		for (int i = 0; i < PLAYER_DATA_COUNT; ++i) {
+			_walkOffRight[i] = SIDEOFFR[i];
+			_walkOffLeft[i] = SIDEOFFL[i];
+			_walkOffUp[i] = SIDEOFFU[i];
+			_walkOffDown[i] = SIDEOFFD[i];
+			_walkOffUR[i].x = DIAGOFFURX[i];
+			_walkOffUR[i].y = DIAGOFFURY[i];
+			_walkOffDR[i].x = DIAGOFFDRX[i];
+			_walkOffDR[i].y = DIAGOFFDRY[i];
+			_walkOffUL[i].x = DIAGOFFULX[i];
+			_walkOffUL[i].y = DIAGOFFULY[i];
+			_walkOffDL[i].x = DIAGOFFDLX[i];
+			_walkOffDL[i].y = DIAGOFFDLY[i];
+		}
+
+		_sideWalkMin = 0;
+		_sideWalkMax = 7;
+		_upWalkMin = 16;
+		_upWalkMax = 23;
+		_downWalkMin = 8;
+		_downWalkMax = 15;
+		_diagUpWalkMin = 0;
+		_diagUpWalkMax = 7;
+		_diagDownWalkMin = 0;
+		_diagDownWalkMax = 7;
+	}
+
+	_vm->_man = _vm->_man1;
+	Common::copy(_vm->_manPal1 + 0x270, _vm->_manPal1 + 0x270 + 0x60, _vm->_screen->_manPal);
 }
 
 void Player::calcManScale() {
-	// TODO
+	if (!_vm->_manScaleOff) {
+		_vm->_scale = (((_rawPlayer.y - _vm->_scaleMaxY + _vm->_scaleN1) * 
+			_vm->_scaleT1 + (_vm->_scaleH2 << 8)) / _vm->_scaleH1 * _vm->_scaleI) >> 8;
+		_vm->_screen->setScaleTable(_vm->_scale);
+
+		_playerOffset.x = _vm->_screen->_scaleTable1[20];
+		_playerOffset.y = _vm->_screen->_scaleTable1[67];
+	}
 }
 
 void Player::walk() {
diff --git a/engines/access/player.h b/engines/access/player.h
index ec6b53f..7625fa2 100644
--- a/engines/access/player.h
+++ b/engines/access/player.h
@@ -25,6 +25,7 @@
 
 #include "common/scummsys.h"
 #include "common/rect.h"
+#include "access/data.h"
 
 namespace Access {
 
@@ -32,9 +33,17 @@ namespace Access {
 
 class AccessEngine;
 
-class Player {
+class Player: public Manager {
 private:
-	AccessEngine *_vm;
+	int _leftDelta, _rightDelta;
+	int _upDelta, _downDelta;
+	int _scrollConst;
+	int _sideWalkMin, _sideWalkMax;
+	int _upWalkMin, _upWalkMax;
+	int _downWalkMin, _downWalkMax;
+	int _diagUpWalkMin, _diagUpWalkMax;
+	int _diagDownWalkMin, _diagDownWalkMax;
+	Common::Point _guard;
 public:
 	// Fields in original Player structure
 	int _field0;
diff --git a/engines/access/resources.cpp b/engines/access/resources.cpp
index 8aa44b4..841ab70 100644
--- a/engines/access/resources.cpp
+++ b/engines/access/resources.cpp
@@ -46,4 +46,29 @@ const byte INITIAL_PALETTE[18 * 3] = {
 	0x00, 0x00, 0x00
 };
 
+const int SIDEOFFR[] = { 5, 5, 5, 5, 5, 5, 5, 5, 0 };
+const int SIDEOFFL[] = { 5, 5, 5, 5, 5, 5, 5, 5, 0 };
+const int SIDEOFFU[] = { 2, 2, 2, 2, 2, 2, 2, 2, 0 };
+const int SIDEOFFD[] = { 2, 2, 2, 2, 2, 2, 2, 2, 0 };
+const int DIAGOFFURX[] = { 4, 5, 2, 2, 3, 4, 2, 2, 0 };
+const int DIAGOFFURY[] = { 2, 3, 2, 2, 2, 3, 1, 1, 0 };
+const int DIAGOFFDRX[] = { 4, 5, 4, 3, 5, 4, 5, 1, 0 };
+const int DIAGOFFDRY[] = { 3, 2, 1, 2, 2, 1, 2, 1, 0 };
+const int DIAGOFFULX[] = { 4, 5, 4, 3, 3, 2, 2, 2, 0 };
+const int DIAGOFFULY[] = { 3, 3, 1, 2, 2, 1, 1, 1, 0 };
+const int DIAGOFFDLX[] = { 4, 5, 3, 3, 5, 4, 6, 1, 0 };
+const int DIAGOFFDLY[] = { 2, 2, 1, 2, 3, 1, 2, 1, 0 };
+const int OVEROFFR[] = { 2, 2, 1, 2, 2, 1, 0, 0, 0 };
+const int OVEROFFL[] = { 2, 2, 1, 2, 2, 1, 0, 0, 0 };
+const int OVEROFFU[] = { 1, 1, 1, 1, 1, 1, 0, 0, 0 };
+const int OVEROFFD[] = { 1, 1, 1, 1, 1, 1, 0, 0, 0 };
+const int OVEROFFURX[] = { 3, 1, 1, 2, 2, 1, 0, 0, 0 };
+const int OVEROFFURY[] = { 1, 0, 0, 1, 1, 0, 0, 0, 0 };
+const int OVEROFFDRX[] = { 1, 2, 1, 1, 2, 1, 0, 0, 0 };
+const int OVEROFFDRY[] = { 0, 1, 0, 0, 1, 1, 0, 0, 0 };
+const int OVEROFFULX[] = { 2, 1, 1, 1, 2, 1, 0, 0, 0 };
+const int OVEROFFULY[] = { 1, 0, 0, 2, 1, 0, 0, 0, 0 };
+const int OVEROFFDLX[] = { 1, 2, 1, 1, 2, 1, 0, 0, 0 };
+const int OVEROFFDLY[] = { 0, 1, 0, 0, 1, 1, 0, 0, 0 };
+
 } // End of namespace Access
diff --git a/engines/access/resources.h b/engines/access/resources.h
index 47d4e3a..1b49b59 100644
--- a/engines/access/resources.h
+++ b/engines/access/resources.h
@@ -29,6 +29,31 @@ namespace Access {
 
 extern const byte INITIAL_PALETTE[18 * 3];
 
+extern const int SIDEOFFR[];
+extern const int SIDEOFFL[];
+extern const int SIDEOFFU[];
+extern const int SIDEOFFD[];
+extern const int DIAGOFFURX[];
+extern const int DIAGOFFURY[];
+extern const int DIAGOFFDRX[];
+extern const int DIAGOFFDRY[];
+extern const int DIAGOFFULX[];
+extern const int DIAGOFFULY[];
+extern const int DIAGOFFDLX[];
+extern const int DIAGOFFDLY[];
+extern const int OVEROFFR[];
+extern const int OVEROFFL[];
+extern const int OVEROFFU[];
+extern const int OVEROFFD[];
+extern const int OVEROFFURX[];
+extern const int OVEROFFURY[];
+extern const int OVEROFFDRX[];
+extern const int OVEROFFDRY[];
+extern const int OVEROFFULX[];
+extern const int OVEROFFULY[];
+extern const int OVEROFFDLX[];
+extern const int OVEROFFDLY[];
+
 } // End of namespace Access
 
 #endif /* ACCESS_RESOURCES_H */
diff --git a/engines/access/screen.cpp b/engines/access/screen.cpp
index 428c3d5..45379b6 100644
--- a/engines/access/screen.cpp
+++ b/engines/access/screen.cpp
@@ -35,6 +35,9 @@ namespace Access {
 Screen::Screen(AccessEngine *vm) : _vm(vm) {
 	create(320, 200, Graphics::PixelFormat::createFormatCLUT8());
 	Common::fill(&_tempPalette[0], &_tempPalette[PALETTE_SIZE], 0);
+	Common::fill(&_manPal[0], &_manPal[0x60], 0);
+	Common::fill(&_scaleTable1[0], &_scaleTable1[256], 0);
+	Common::fill(&_scaleTable2[0], &_scaleTable2[256], 0);
 	_vesaMode = 0;
 	_vesaCurrentWin = 0;
 	_currentPanel = 0;
@@ -224,4 +227,13 @@ void Screen::setBufferScan() {
 	// TODO
 }
 
+void Screen::setScaleTable(int scale) {
+	int total = 0;
+	for (int idx = 0; idx < 256; ++idx) {
+		_scaleTable1[idx] = total >> 8;
+		_scaleTable2[idx] = total & 0xff;
+		total += scale;
+	}
+}
+
 } // End of namespace Access
diff --git a/engines/access/screen.h b/engines/access/screen.h
index c4beacf..69a28bd 100644
--- a/engines/access/screen.h
+++ b/engines/access/screen.h
@@ -62,6 +62,9 @@ public:
 	Common::Point _vWindowSize;
 	int _scrollX, _scrollY;
 	int _scrollCol, _scrollRow;
+	byte _manPal[0x60];
+	byte _scaleTable1[256];
+	byte _scaleTable2[256];
 public:
 	Screen(AccessEngine *vm);
 
@@ -119,6 +122,8 @@ public:
 	void copyRects();
 
 	void setBufferScan();
+
+	void setScaleTable(int scale);
 };
 
 } // End of namespace Access


Commit: 9d590687e99cfee4b20dce5224edd78b33d61fd5
    https://github.com/scummvm/scummvm/commit/9d590687e99cfee4b20dce5224edd78b33d61fd5
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-09T22:24:35-04:00

Commit Message:
ACCESS: Implemented roomMenu

Changed paths:
    engines/access/access.h
    engines/access/amazon/amazon_game.cpp
    engines/access/amazon/amazon_room.cpp
    engines/access/amazon/amazon_room.h
    engines/access/screen.cpp
    engines/access/screen.h



diff --git a/engines/access/access.h b/engines/access/access.h
index 99bc201..e6a3f33 100644
--- a/engines/access/access.h
+++ b/engines/access/access.h
@@ -113,7 +113,7 @@ public:
 	Scripts *_scripts;
 	SoundManager *_sound;
 
-	byte *_destIn;
+	ASurface *_destIn;
 	ASurface _buffer1;
 	ASurface _buffer2;
 	byte *_objectsTable[100];
diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp
index 9c51616..d1ba0e0 100644
--- a/engines/access/amazon/amazon_game.cpp
+++ b/engines/access/amazon/amazon_game.cpp
@@ -109,7 +109,7 @@ void AmazonEngine::doIntroduction() {
 
 void AmazonEngine::doTitle() {
 	_screen->setDisplayScan();
-	_destIn = (byte *)_buffer2.getPixels();
+	_destIn = &_buffer2;
 
 	_screen->forceFadeOut();
 	_events->hideCursor();
diff --git a/engines/access/amazon/amazon_room.cpp b/engines/access/amazon/amazon_room.cpp
index df2a6b7..565b1cc 100644
--- a/engines/access/amazon/amazon_room.cpp
+++ b/engines/access/amazon/amazon_room.cpp
@@ -31,6 +31,10 @@ namespace Amazon {
 
 AmazonRoom::AmazonRoom(AccessEngine *vm): Room(vm) {
 	_antOutFlag = false;
+	_icon = nullptr;
+}
+
+AmazonRoom::~AmazonRoom() {
 }
 
 void AmazonRoom::loadRoom(int roomNumber) {
@@ -118,7 +122,16 @@ void AmazonRoom::roomSet() {
 }
 
 void AmazonRoom::roomMenu() {
-	// TODO
+	_icon = _vm->_files->loadFile("ICONS.LZ");
+	_vm->_screen->saveScreen();
+	_vm->_screen->setDisplayScan();
+	_vm->_destIn = _vm->_screen;
+	_vm->_screen->plotImage(_icon, 0, Common::Point(0, 177));
+	_vm->_screen->plotImage(_icon, 1, Common::Point(143, 177));
+
+	_vm->_screen->restoreScan();
+	delete[] _icon;
+	_icon = nullptr;
 }
 
 } // End of namespace Amazon
diff --git a/engines/access/amazon/amazon_room.h b/engines/access/amazon/amazon_room.h
index 006aef5..546ea96 100644
--- a/engines/access/amazon/amazon_room.h
+++ b/engines/access/amazon/amazon_room.h
@@ -35,6 +35,7 @@ namespace Amazon {
 class AmazonRoom : public Room {
 private:
 	bool _antOutFlag;
+	const byte *_icon;
 
 	void roomSet();
 
@@ -47,6 +48,8 @@ protected:
 	virtual void reloadRoom1();
 public:
 	AmazonRoom(AccessEngine *vm);
+
+	virtual ~AmazonRoom();
 };
 
 } // End of namespace Amazon
diff --git a/engines/access/screen.cpp b/engines/access/screen.cpp
index 45379b6..6a241d0 100644
--- a/engines/access/screen.cpp
+++ b/engines/access/screen.cpp
@@ -200,31 +200,35 @@ bool Screen::clip(Common::Rect &r) {
 }
 
 void Screen::checkScroll() {
-	// TODO
+	warning("TODO");
 }
 
 void Screen::copyBF1BF2() {
-	// TODO
+	warning("TODO");
 }
 
 void Screen::copyBF2Vid() {
-	// TODO
+	warning("TODO");
 }
 
 void Screen::plotList() {
-	// TODO
+	warning("TODO: plotList");
 }
 
 void Screen::copyBlocks() {
-	// TODO
+	warning("TODO: copyBlocks");
 }
 
 void Screen::copyRects() {
-	// TODO
+	warning("TODO: copyRects");
 }
 
 void Screen::setBufferScan() {
-	// TODO
+	warning("TODO: setBufferScan");
+}
+
+void Screen::restoreScan() {
+	warning("TODO: restoreScan");
 }
 
 void Screen::setScaleTable(int scale) {
@@ -236,4 +240,8 @@ void Screen::setScaleTable(int scale) {
 	}
 }
 
+void Screen::saveScreen() {
+	warning("TODO: saveScreen");
+}
+
 } // End of namespace Access
diff --git a/engines/access/screen.h b/engines/access/screen.h
index 69a28bd..a2eac29 100644
--- a/engines/access/screen.h
+++ b/engines/access/screen.h
@@ -70,6 +70,8 @@ public:
 
 	void setDisplayScan();
 
+	void restoreScan();
+
 	void setPanel(int num);
 
 	/**
@@ -124,6 +126,8 @@ public:
 	void setBufferScan();
 
 	void setScaleTable(int scale);
+
+	void saveScreen();
 };
 
 } // End of namespace Access


Commit: 00901b200bffcbff69694ff6b54d55908fd74180
    https://github.com/scummvm/scummvm/commit/00901b200bffcbff69694ff6b54d55908fd74180
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-08-10T14:49:46+02:00

Commit Message:
ACCESS: Fix bug in reloadRoom1

Changed paths:
    engines/access/amazon/amazon_room.cpp



diff --git a/engines/access/amazon/amazon_room.cpp b/engines/access/amazon/amazon_room.cpp
index 565b1cc..5627325 100644
--- a/engines/access/amazon/amazon_room.cpp
+++ b/engines/access/amazon/amazon_room.cpp
@@ -72,7 +72,7 @@ void AmazonRoom::reloadRoom() {
 }
 
 void AmazonRoom::reloadRoom1() {
-	if (_vm->_player->_roomNumber == 22 || _vm->_player->_roomNumber == 31 
+	if (_vm->_player->_roomNumber == 29 || _vm->_player->_roomNumber == 31 
 			|| _vm->_player->_roomNumber == 42 || _vm->_player->_roomNumber == 44) {
 		_vm->_inactive = _vm->_files->loadFile("MAYA.LZ");
 		_vm->_currentCharFlag = false;


Commit: cce0c2ff97878b2b0b8a87e25395c3ef98bc584e
    https://github.com/scummvm/scummvm/commit/cce0c2ff97878b2b0b8a87e25395c3ef98bc584e
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-10T11:47:15-04:00

Commit Message:
ACCESS: Adding sprite resources and screen saving

Changed paths:
    engines/access/access.h
    engines/access/amazon/amazon_game.cpp
    engines/access/amazon/amazon_room.cpp
    engines/access/asurface.cpp
    engines/access/asurface.h
    engines/access/data.cpp
    engines/access/data.h
    engines/access/player.cpp
    engines/access/screen.cpp
    engines/access/screen.h



diff --git a/engines/access/access.h b/engines/access/access.h
index e6a3f33..c93a1b3 100644
--- a/engines/access/access.h
+++ b/engines/access/access.h
@@ -58,7 +58,8 @@ namespace Access {
 
 enum {
 	GType_Amazon = 1,
-	GType_MeanStreets = 2
+	GType_MeanStreets = 2,
+	GType_Noctropolis = 3
 };
 
 enum AccessDebugChannels {
diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp
index d1ba0e0..5c2cda6 100644
--- a/engines/access/amazon/amazon_game.cpp
+++ b/engines/access/amazon/amazon_game.cpp
@@ -126,6 +126,8 @@ void AmazonEngine::doTitle() {
 	_sound->playSound(1);
 
 	_objectsTable[0] = _files->loadFile(0, 2);
+	SpriteResource *spr = new SpriteResource(this, _objectsTable[0], _files->_filesize);
+
 	_sound->playSound(1);
 
 	_screen->_loadPalFlag = false;
@@ -141,9 +143,11 @@ void AmazonEngine::doTitle() {
 		_buffer2.copyFrom(_buffer1);
 		int id = READ_LE_UINT16(COUNTDOWN + _pCount * 4);
 		int xp = READ_LE_UINT16(COUNTDOWN + _pCount * 4 + 2);
-		_screen->plotImage(_objectsTable[0], id, Common::Point(xp, 71));
+		_screen->plotImage(spr, id, Common::Point(xp, 71));
 	}
 	// TODO: More to do
+
+	delete spr;
 }
 
 void AmazonEngine::doOpening() {
diff --git a/engines/access/amazon/amazon_room.cpp b/engines/access/amazon/amazon_room.cpp
index 5627325..056fa8f 100644
--- a/engines/access/amazon/amazon_room.cpp
+++ b/engines/access/amazon/amazon_room.cpp
@@ -122,16 +122,18 @@ void AmazonRoom::roomSet() {
 }
 
 void AmazonRoom::roomMenu() {
-	_icon = _vm->_files->loadFile("ICONS.LZ");
+	byte *iconData = _vm->_files->loadFile("ICONS.LZ");
+	SpriteResource *spr = new SpriteResource(_vm, _icon, _vm->_files->_filesize);
+	delete[] iconData;
+
 	_vm->_screen->saveScreen();
 	_vm->_screen->setDisplayScan();
-	_vm->_destIn = _vm->_screen;
-	_vm->_screen->plotImage(_icon, 0, Common::Point(0, 177));
-	_vm->_screen->plotImage(_icon, 1, Common::Point(143, 177));
+	_vm->_destIn = _vm->_screen;	// TODO: Redundant
+	_vm->_screen->plotImage(spr, 0, Common::Point(0, 177));
+	_vm->_screen->plotImage(spr, 1, Common::Point(143, 177));
 
-	_vm->_screen->restoreScan();
-	delete[] _icon;
-	_icon = nullptr;
+	_vm->_screen->restoreScreen();
+	delete spr;
 }
 
 } // End of namespace Amazon
diff --git a/engines/access/asurface.cpp b/engines/access/asurface.cpp
index a0a790d..0fb8f7d 100644
--- a/engines/access/asurface.cpp
+++ b/engines/access/asurface.cpp
@@ -25,9 +25,85 @@
 
 namespace Access {
 
+
+/*------------------------------------------------------------------------*/
+
+int ASurface::_leftSkip;
+int ASurface::_rightSkip;
+int ASurface::_topSkip;
+int ASurface::_bottomSkip;
+int ASurface::_clipWidth;
+int ASurface::_clipHeight;
+int ASurface::_lastBoundsX;
+int ASurface::_lastBoundsY;
+int ASurface::_lastBoundsW;
+int ASurface::_lastBoundsH;
+
 void ASurface::clearBuffer() {
 	byte *pSrc = (byte *)getPixels();
 	Common::fill(pSrc, pSrc + w * h, 0);
 }
 
+bool ASurface::clip(Common::Rect &r) {
+	int skip;
+	_leftSkip = _rightSkip = 0;
+	_topSkip = _bottomSkip = 0;
+
+	if (r.left > _clipWidth) {
+		skip = -r.left;
+		r.setWidth(r.width() - skip);
+		_leftSkip = skip;
+		r.moveTo(0, r.top);
+	}
+	else if (r.left >= 0)
+		return true;
+
+	int right = r.right - 1;
+	if (right < 0)
+		return true;
+	else if (right > _clipWidth) {
+		skip = right - _clipWidth;
+		r.setWidth(r.width() - skip);
+		_rightSkip = skip;
+	}
+
+	if (r.top > _clipHeight) {
+		skip = -r.top;
+		r.setHeight(r.height() - skip);
+		_topSkip = skip;
+		r.moveTo(r.left, 0);
+	}
+	else if (r.top >= 0)
+		return true;
+
+	int bottom = r.bottom - 1;
+	if (bottom < 0)
+		return true;
+	else if (bottom > _clipHeight) {
+		skip = bottom - _clipHeight;
+		_bottomSkip = skip;
+		r.setHeight(r.height() - skip);
+	}
+
+	return false;
+}
+
+void ASurface::plotImage(SpriteResource *sprite, int frameNum, const Common::Point &pt) {
+	SpriteFrame *frame = sprite->getFrame(frameNum);
+	Common::Rect r(pt.x, pt.y, pt.x + frame->w, pt.y + frame->h);
+
+	if (!clip(r)) {
+		_lastBoundsX = r.left;
+		_lastBoundsY = r.top;
+		_lastBoundsW = r.width();
+		_lastBoundsH = r.height();
+
+//		plotImage(frame, , )
+	}
+}
+
+void ASurface::plotF(SpriteFrame *frame, const Common::Point &pt) {
+
+}
+
 } // End of namespace Access
diff --git a/engines/access/asurface.h b/engines/access/asurface.h
index ace1b23..7d1ee6c 100644
--- a/engines/access/asurface.h
+++ b/engines/access/asurface.h
@@ -24,16 +24,30 @@
 #define ACCESS_ASURFACE_H
 
 #include "common/scummsys.h"
+#include "common/array.h"
 #include "common/rect.h"
 #include "graphics/surface.h"
+#include "access/data.h"
 
 namespace Access {
 
 class ASurface : public Graphics::Surface {
 public:
+	static int _leftSkip, _rightSkip;
+	static int _topSkip, _bottomSkip;
+	static int _clipWidth, _clipHeight;
+	static int _lastBoundsX, _lastBoundsY;
+	static int _lastBoundsW, _lastBoundsH;
+protected:
+	virtual void ASurface::plotF(SpriteFrame *frame, const Common::Point &pt);
+public:
 	void clearBuffer();
 
 	void copyBuffer(Graphics::Surface *src) { copyFrom(*src); }
+
+	bool clip(Common::Rect &r);
+
+	void plotImage(SpriteResource *sprite, int frameNum, const Common::Point &pt);
 };
 
 } // End of namespace Access
diff --git a/engines/access/data.cpp b/engines/access/data.cpp
index 0ef1845..ed913c9 100644
--- a/engines/access/data.cpp
+++ b/engines/access/data.cpp
@@ -20,10 +20,47 @@
  *
  */
 
-#include "access/data.h"
 #include "common/algorithm.h"
+#include "common/endian.h"
+#include "common/memstream.h"
+#include "access/access.h"
+#include "access/data.h"
 
 namespace Access {
 
+SpriteResource::SpriteResource(AccessEngine *vm, const byte *data, uint32 size) {
+	Common::MemoryReadStream stream(data, size);
+	Common::Array<uint32> offsets;
+	int count = stream.readUint16LE();
+
+	for (int i = 0; i < count; i++)
+		offsets.push_back(stream.readUint32LE());
+	offsets.push_back(size);	// For easier calculations of Noctropolis sizes
+
+	// Build up the frames
+	for (int i = 0; i < count; ++i) {
+		stream.seek(offsets[i]);
+
+		SpriteFrame *frame = new SpriteFrame();
+		frame->_width = stream.readUint16LE();
+		frame->_height = stream.readUint16LE();
+		frame->_size = (vm->getGameID() == GType_MeanStreets) ? stream.readUint16LE() :
+			offsets[i + 1] - offsets[i];
+
+		frame->_data = new byte[frame->_size];
+		stream.read(frame->_data, frame->_size);
+
+		_frames.push_back(frame);
+	}
+}
+
+SpriteResource::~SpriteResource() {
+	for (uint i = 0; i < _frames.size(); ++i)
+		delete _frames[i];
+}
+
+SpriteFrame::~SpriteFrame() {
+	delete[] _data;
+}
 
 } // End of namespace Access
diff --git a/engines/access/data.h b/engines/access/data.h
index cf8394b..bd1e156 100644
--- a/engines/access/data.h
+++ b/engines/access/data.h
@@ -24,7 +24,9 @@
 #define ACCESS_DATA_H
 
 #include "common/scummsys.h"
+#include "common/array.h"
 #include "common/rect.h"
+#include "graphics/surface.h"
 
 namespace Access {
 
@@ -56,6 +58,27 @@ public:
 	int _vidSTable1;
 };
 
+class SpriteFrame : public Graphics::Surface {
+public:
+	uint16 _width, _height;
+	byte *_data;
+	uint32 _size;
+
+	~SpriteFrame();
+};
+
+class SpriteResource {
+public:
+	Common::Array<SpriteFrame *> _frames;
+public:
+	SpriteResource(AccessEngine *vm, const byte *data, uint32 size);
+	~SpriteResource();
+
+	int getCount() { return _frames.size(); }
+
+	SpriteFrame *getFrame(int idx) { return _frames[idx]; }
+};
+
 } // End of namespace Access
 
 #endif /* ACCESS_DATA_H */
diff --git a/engines/access/player.cpp b/engines/access/player.cpp
index f0cceb7..b28e6c9 100644
--- a/engines/access/player.cpp
+++ b/engines/access/player.cpp
@@ -129,7 +129,11 @@ void Player::load() {
 	}
 
 	_vm->_man = _vm->_man1;
-	Common::copy(_vm->_manPal1 + 0x270, _vm->_manPal1 + 0x270 + 0x60, _vm->_screen->_manPal);
+	if (_vm->_manPal1) {
+		Common::copy(_vm->_manPal1 + 0x270, _vm->_manPal1 + 0x270 + 0x60, _vm->_screen->_manPal);
+	} else {
+		Common::fill(_vm->_screen->_manPal + 0x270, _vm->_screen->_manPal + 0x270 + 0x60, 0);
+	}
 }
 
 void Player::calcManScale() {
diff --git a/engines/access/screen.cpp b/engines/access/screen.cpp
index 6a241d0..c1a4d91 100644
--- a/engines/access/screen.cpp
+++ b/engines/access/screen.cpp
@@ -43,15 +43,13 @@ Screen::Screen(AccessEngine *vm) : _vm(vm) {
 	_currentPanel = 0;
 	_hideFlag = true;
 	_loadPalFlag = false;
-	_leftSkip = _rightSkip = 0;
-	_topSkip = _bottomSkip = 0;
-	_clipWidth = _clipHeight = 0;
 	_scrollFlag = false;
 	_scrollThreshold = 0;
 	_startColor = _numColors = 0;
 	_scrollX = _scrollY = 0;
 	_scrollCol = _scrollRow = 0;
-
+	_windowXAdd = _windowYAdd = 0;
+	_screenYOff = 0;
 }
 
 void Screen::setDisplayScan() {
@@ -145,60 +143,6 @@ void Screen::copyBuffer(const byte *data) {
 	g_system->copyRectToScreen(destP, w, 0, 0, w, h);
 }
 
-void Screen::plotImage(const byte *pData, int idx, const Common::Point &pt) {
-	const byte *sizeP = pData + READ_LE_UINT16(pData + idx * 4);
-	int w = READ_LE_UINT16(sizeP);
-	int h = READ_LE_UINT16(sizeP + 2);
-	Common::Rect r(pt.x, pt.y, pt.x + w, pt.y + h);
-
-	if (!clip(r)) {
-		_lastBounds = r;
-		//plotf();
-	}
-}
-
-bool Screen::clip(Common::Rect &r) {
-	int skip;
-	_leftSkip = _rightSkip = 0;
-	_topSkip = _bottomSkip = 0;
-
-	if (r.left > _clipWidth) {
-		skip = -r.left;
-		r.setWidth(r.width() - skip);
-		_leftSkip = skip;
-		r.moveTo(0, r.top);
-	} else if (r.left >= 0)
-		return true;
-
-	int right = r.right - 1;
-	if (right < 0)
-		return true;
-	else if (right > _clipWidth) {
-		skip = right - _clipWidth;
-		r.setWidth(r.width() - skip);
-		_rightSkip = skip;
-	}
-
-	if (r.top > _clipHeight) {
-		skip = -r.top;
-		r.setHeight(r.height() - skip);
-		_topSkip = skip;
-		r.moveTo(r.left, 0);
-	} else if (r.top >= 0)
-		return true;
-
-	int bottom = r.bottom - 1;
-	if (bottom < 0)
-		return true;
-	else if (bottom > _clipHeight) {
-		skip = bottom - _clipHeight;
-		_bottomSkip = skip;
-		r.setHeight(r.height() - skip);
-	}
-
-	return false;
-}
-
 void Screen::checkScroll() {
 	warning("TODO");
 }
@@ -227,10 +171,6 @@ void Screen::setBufferScan() {
 	warning("TODO: setBufferScan");
 }
 
-void Screen::restoreScan() {
-	warning("TODO: restoreScan");
-}
-
 void Screen::setScaleTable(int scale) {
 	int total = 0;
 	for (int idx = 0; idx < 256; ++idx) {
@@ -241,7 +181,31 @@ void Screen::setScaleTable(int scale) {
 }
 
 void Screen::saveScreen() {
-	warning("TODO: saveScreen");
+	_screenSave._clipWidth = _clipWidth;
+	_screenSave._clipHeight = _clipHeight;
+	_screenSave._windowXAdd = _windowXAdd;
+	_screenSave._windowYAdd = _windowYAdd;
+	_screenSave._scroll.x = _scrollX;
+	_screenSave._scroll.y = _scrollY;
+	_screenSave._scrollCol = _scrollCol;
+	_screenSave._scrollRow = _scrollRow;
+	_screenSave._bufferStart.x = _bufferStart.x;
+	_screenSave._bufferStart.y = _bufferStart.y;
+	_screenSave._screenYOff = _screenYOff;
+}
+
+void Screen::restoreScreen() {
+	_clipWidth = _screenSave._clipWidth;
+	_clipHeight = _screenSave._clipHeight;
+	_windowXAdd = _screenSave._windowXAdd;
+	_windowYAdd = _screenSave._windowYAdd;
+	_scrollX = _screenSave._scroll.x;
+	_scrollY = _screenSave._scroll.y;
+	_scrollCol = _screenSave._scrollCol;
+	_scrollRow = _screenSave._scrollRow;
+	_bufferStart.x = _screenSave._bufferStart.x;
+	_bufferStart.y = _screenSave._bufferStart.y;
+	_screenYOff = _screenSave._screenYOff;
 }
 
 } // End of namespace Access
diff --git a/engines/access/screen.h b/engines/access/screen.h
index a2eac29..8dc56d2 100644
--- a/engines/access/screen.h
+++ b/engines/access/screen.h
@@ -35,6 +35,18 @@ class AccessEngine;
 #define PALETTE_COUNT 256
 #define PALETTE_SIZE (256 * 3)
 
+struct ScreenSave {
+	int _clipWidth;
+	int _clipHeight;
+	int _windowXAdd;
+	int _windowYAdd;
+	Common::Point _scroll;
+	int _scrollCol;
+	int _scrollRow;
+	Common::Point _bufferStart;
+	int _screenYOff;
+};
+
 class Screen: public ASurface {
 private:
 	AccessEngine *_vm;
@@ -45,14 +57,9 @@ private:
 	Common::Point _msVirtualOffset;
 	Common::Point _virtualOffsetsTable[4];
 	bool _hideFlag;
-	Common::Rect _lastBounds;
-	int _leftSkip, _rightSkip;
-	int _topSkip, _bottomSkip;
-	int _clipWidth, _clipHeight;
+	ScreenSave _screenSave;
 
 	void updatePalette();
-
-	bool clip(Common::Rect &r);
 public:
 	int _vesaMode;
 	bool _loadPalFlag;
@@ -60,8 +67,11 @@ public:
 	int _scrollThreshold;
 	int _startColor, _numColors;
 	Common::Point _vWindowSize;
+	Common::Point _bufferStart;
 	int _scrollX, _scrollY;
 	int _scrollCol, _scrollRow;
+	int _windowXAdd, _windowYAdd;
+	int _screenYOff;
 	byte _manPal[0x60];
 	byte _scaleTable1[256];
 	byte _scaleTable2[256];
@@ -70,8 +80,6 @@ public:
 
 	void setDisplayScan();
 
-	void restoreScan();
-
 	void setPanel(int num);
 
 	/**
@@ -109,8 +117,6 @@ public:
 	 */
 	void copyBuffer(const byte *data);
 
-	void plotImage(const byte *pData, int idx, const Common::Point &pt);
-
 	void checkScroll();
 
 	void copyBF1BF2();
@@ -127,7 +133,15 @@ public:
 
 	void setScaleTable(int scale);
 
+	/**
+	 * Save all the screen display state variables
+	 */
 	void saveScreen();
+
+	/**
+	 * Restores previously saved screen display state variables
+	 */
+	void restoreScreen();
 };
 
 } // End of namespace Access


Commit: 00f7a3404db0598429f6c733a15d766675624b36
    https://github.com/scummvm/scummvm/commit/00f7a3404db0598429f6c733a15d766675624b36
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-08-10T17:50:28+02:00

Commit Message:
ACCESS: Implement 3 more opcodes

Changed paths:
    engines/access/access.cpp
    engines/access/access.h
    engines/access/scripts.cpp
    engines/access/scripts.h



diff --git a/engines/access/access.cpp b/engines/access/access.cpp
index d0bc1a8..dc9bf52 100644
--- a/engines/access/access.cpp
+++ b/engines/access/access.cpp
@@ -44,6 +44,7 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc)
 	_sound = nullptr;
 
 	_destIn = nullptr;
+	_current = nullptr;
 	clearCellTable();
 	_pCount = 0;
 	_selectCommand = 0;
diff --git a/engines/access/access.h b/engines/access/access.h
index c93a1b3..0733ab4 100644
--- a/engines/access/access.h
+++ b/engines/access/access.h
@@ -115,6 +115,7 @@ public:
 	SoundManager *_sound;
 
 	ASurface *_destIn;
+	ASurface *_current;
 	ASurface _buffer1;
 	ASurface _buffer2;
 	byte *_objectsTable[100];
diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp
index fe53c67..2a82521 100644
--- a/engines/access/scripts.cpp
+++ b/engines/access/scripts.cpp
@@ -90,11 +90,11 @@ void Scripts::executeCommand(int commandIndex) {
 		&Scripts::cmdSetInventory, &Scripts::cmdSetInventory, &Scripts::cmdCheckInventory, 
 		&Scripts::CMDSETTEX, &Scripts::CMDNEWROOM, &Scripts::CMDCONVERSE, 
 		&Scripts::CMDCHECKFRAME, &Scripts::cmdCheckAnim, &Scripts::CMDSND, 
-		&Scripts::CMDRETNEG, &Scripts::cmdRetPos, &Scripts::cmdCheckLoc, 
+		&Scripts::cmdRetNeg, &Scripts::cmdRetPos, &Scripts::cmdCheckLoc, 
 		&Scripts::cmdSetAnim, &Scripts::CMDDISPINV, &Scripts::CMDSETTIMER, 
 		&Scripts::CMDSETTIMER, &Scripts::CMDCHECKTIMER, &Scripts::CMDSETTRAVEL,
 		&Scripts::CMDSETTRAVEL, &Scripts::CMDSETVID, &Scripts::CMDPLAYVID, 
-		&Scripts::CMDPLOTIMAGE, &Scripts::CMDSETDISPLAY, &Scripts::CMDSETBUFFER, 
+		&Scripts::cmdPlotImage, &Scripts::cmdSetDisplay, &Scripts::CMDSETBUFFER, 
 		&Scripts::CMDSETSCROLL, &Scripts::CMDSAVERECT, &Scripts::CMDSAVERECT, 
 		&Scripts::CMDSETBUFVID, &Scripts::CMDPLAYBUFVID, &Scripts::cmeRemoveLast, 
 		&Scripts::CMDSPECIAL, &Scripts::CMDSPECIAL, &Scripts::CMDSPECIAL,
@@ -233,7 +233,11 @@ void Scripts::cmdCheckAnim() {
 }
 
 void Scripts::CMDSND() { }
-void Scripts::CMDRETNEG() { }
+
+void Scripts::cmdRetNeg() {
+	_endFlag = true;
+	_returnCode = -1;
+}
 
 void Scripts::cmdCheckLoc() {
 	int minX = _data->readUint16LE();
@@ -262,8 +266,23 @@ void Scripts::CMDCHECKTIMER() { }
 void Scripts::CMDSETTRAVEL() { }
 void Scripts::CMDSETVID() { }
 void Scripts::CMDPLAYVID() { }
-void Scripts::CMDPLOTIMAGE() { }
-void Scripts::CMDSETDISPLAY() { }
+
+void Scripts::cmdPlotImage() {
+	_vm->_destIn = _vm->_current;
+
+	int destX = _data->readUint16LE();
+	int destY = _data->readUint16LE();
+	int objId = _data->readUint16LE();
+	int imgId = _data->readUint16LE();
+
+	_vm->_screen->plotImage(_vm->_objectsTable[objId], imgId, Common::Point(destX, destY));
+}
+
+void Scripts::cmdSetDisplay() {
+	_vm->_screen->setDisplayScan();
+	_vm->_current = _vm->_screen;
+}
+
 void Scripts::CMDSETBUFFER() { }
 void Scripts::CMDSETSCROLL() { }
 void Scripts::CMDSAVERECT() { }
diff --git a/engines/access/scripts.h b/engines/access/scripts.h
index 79ae478..0bdc746 100644
--- a/engines/access/scripts.h
+++ b/engines/access/scripts.h
@@ -69,7 +69,7 @@ protected:
 	void CMDCHECKFRAME();
 	void cmdCheckAnim();
 	void CMDSND();
-	void CMDRETNEG();
+	void cmdRetNeg();
 	void cmdCheckLoc();
 	void cmdSetAnim();
 	void CMDDISPINV();
@@ -78,8 +78,8 @@ protected:
 	void CMDSETTRAVEL();
 	void CMDSETVID();
 	void CMDPLAYVID();
-	void CMDPLOTIMAGE();
-	void CMDSETDISPLAY();
+	void cmdPlotImage();
+	void cmdSetDisplay();
 	void CMDSETBUFFER();
 	void CMDSETSCROLL();
 	void CMDSAVERECT();


Commit: ba1f8b2f6bf7362d011d01aa7106e5bd6d38366d
    https://github.com/scummvm/scummvm/commit/ba1f8b2f6bf7362d011d01aa7106e5bd6d38366d
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-08-10T17:52:34+02:00

Commit Message:
ACCESS: Fix typo in variable name

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



diff --git a/engines/access/access.cpp b/engines/access/access.cpp
index dc9bf52..d194d84 100644
--- a/engines/access/access.cpp
+++ b/engines/access/access.cpp
@@ -94,7 +94,7 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc)
 	_ask = 0;
 	_rScrollRow = 0;
 	_rScrollCol = 0;
-	_rSrcollX = 0;
+	_rScrollX = 0;
 	_rScrollY = 0;
 	_rOldRectCount = 0;
 	_rNewRectCount = 0;
diff --git a/engines/access/access.h b/engines/access/access.h
index 0733ab4..873eb3d 100644
--- a/engines/access/access.h
+++ b/engines/access/access.h
@@ -174,7 +174,7 @@ public:
 	int _ask;
 	int _rScrollRow;
 	int _rScrollCol;
-	int _rSrcollX;
+	int _rScrollX;
 	int _rScrollY;
 	int _rOldRectCount;
 	int _rNewRectCount;


Commit: 0e3f9e983d51759e0d6373e95c71b2130e7f181c
    https://github.com/scummvm/scummvm/commit/0e3f9e983d51759e0d6373e95c71b2130e7f181c
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-10T11:56:14-04:00

Commit Message:
ACCESS: Changed _objectsTable from raw data array to SpriteResource array

Changed paths:
    engines/access/access.cpp
    engines/access/access.h
    engines/access/amazon/amazon_game.cpp
    engines/access/data.cpp
    engines/access/data.h



diff --git a/engines/access/access.cpp b/engines/access/access.cpp
index d194d84..27300f8 100644
--- a/engines/access/access.cpp
+++ b/engines/access/access.cpp
@@ -192,13 +192,17 @@ int AccessEngine::getRandomNumber(int maxNumber) {
 
 void AccessEngine::loadCells(Common::Array<RoomInfo::CellIdent> &cells) {
 	for (uint i = 0; i < cells.size(); ++i) {
-		_objectsTable[cells[i]._cell] = _files->loadFile(
-			cells[i]._fileNum, cells[i]._subfile);
+		byte *spriteData = _files->loadFile(cells[i]._fileNum, cells[i]._subfile);
+		_objectsTable[cells[i]._cell] = new SpriteResource(this, 
+			spriteData, _files->_filesize, DisposeAfterUse::YES);
 	}
 }
 
 void AccessEngine::clearCellTable() {
-	Common::fill(&_objectsTable[0], &_objectsTable[100], (byte *)nullptr);
+	for (int i = 0; i < 100; ++i) {
+		delete _objectsTable[i];
+		_objectsTable[i] = nullptr;
+	}
 }
 
 void AccessEngine::freeCells() {
diff --git a/engines/access/access.h b/engines/access/access.h
index 873eb3d..5fa0aed 100644
--- a/engines/access/access.h
+++ b/engines/access/access.h
@@ -118,7 +118,7 @@ public:
 	ASurface *_current;
 	ASurface _buffer1;
 	ASurface _buffer2;
-	byte *_objectsTable[100];
+	SpriteResource *_objectsTable[100];
 	int _establishTable[100];
 	bool _establishFlag;
 	int _establishMode;
diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp
index 5c2cda6..fe15812 100644
--- a/engines/access/amazon/amazon_game.cpp
+++ b/engines/access/amazon/amazon_game.cpp
@@ -125,8 +125,9 @@ void AmazonEngine::doTitle() {
 	_screen->forceFadeIn();
 	_sound->playSound(1);
 
-	_objectsTable[0] = _files->loadFile(0, 2);
-	SpriteResource *spr = new SpriteResource(this, _objectsTable[0], _files->_filesize);
+	byte *spriteData = _files->loadFile(0, 2);
+	_objectsTable[0] = new SpriteResource(this, spriteData, _files->_filesize,
+		DisposeAfterUse::YES);
 
 	_sound->playSound(1);
 
@@ -143,11 +144,11 @@ void AmazonEngine::doTitle() {
 		_buffer2.copyFrom(_buffer1);
 		int id = READ_LE_UINT16(COUNTDOWN + _pCount * 4);
 		int xp = READ_LE_UINT16(COUNTDOWN + _pCount * 4 + 2);
-		_screen->plotImage(spr, id, Common::Point(xp, 71));
+		_screen->plotImage(_objectsTable[0], id, Common::Point(xp, 71));
 	}
 	// TODO: More to do
 
-	delete spr;
+	delete _objectsTable[0];
 }
 
 void AmazonEngine::doOpening() {
diff --git a/engines/access/data.cpp b/engines/access/data.cpp
index ed913c9..3203020 100644
--- a/engines/access/data.cpp
+++ b/engines/access/data.cpp
@@ -28,7 +28,8 @@
 
 namespace Access {
 
-SpriteResource::SpriteResource(AccessEngine *vm, const byte *data, uint32 size) {
+SpriteResource::SpriteResource(AccessEngine *vm, const byte *data, uint32 size,
+		DisposeAfterUse::Flag disposeMemory) {
 	Common::MemoryReadStream stream(data, size);
 	Common::Array<uint32> offsets;
 	int count = stream.readUint16LE();
@@ -52,6 +53,9 @@ SpriteResource::SpriteResource(AccessEngine *vm, const byte *data, uint32 size)
 
 		_frames.push_back(frame);
 	}
+
+	if (disposeMemory == DisposeAfterUse::YES)
+		delete[] data;
 }
 
 SpriteResource::~SpriteResource() {
diff --git a/engines/access/data.h b/engines/access/data.h
index bd1e156..bb5ef90 100644
--- a/engines/access/data.h
+++ b/engines/access/data.h
@@ -26,6 +26,7 @@
 #include "common/scummsys.h"
 #include "common/array.h"
 #include "common/rect.h"
+#include "common/types.h"
 #include "graphics/surface.h"
 
 namespace Access {
@@ -71,7 +72,8 @@ class SpriteResource {
 public:
 	Common::Array<SpriteFrame *> _frames;
 public:
-	SpriteResource(AccessEngine *vm, const byte *data, uint32 size);
+	SpriteResource(AccessEngine *vm, const byte *data, uint32 size, 
+		DisposeAfterUse::Flag disposeMemory = DisposeAfterUse::NO);
 	~SpriteResource();
 
 	int getCount() { return _frames.size(); }


Commit: 47d75ae128d2b29ace73925373901cf7bbc6325d
    https://github.com/scummvm/scummvm/commit/47d75ae128d2b29ace73925373901cf7bbc6325d
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-10T15:50:22-04:00

Commit Message:
ACCESS: Beginnings of logic for drawing sprite frames

Changed paths:
    engines/access/access.cpp
    engines/access/asurface.cpp
    engines/access/asurface.h
    engines/access/screen.cpp
    engines/access/screen.h



diff --git a/engines/access/access.cpp b/engines/access/access.cpp
index 27300f8..f625fa0 100644
--- a/engines/access/access.cpp
+++ b/engines/access/access.cpp
@@ -148,6 +148,7 @@ void AccessEngine::initialize() {
 	}
 
 	// Create sub-objects of the engine
+	ASurface::init();
 	_animation = new AnimationManager(this);
 	_debugger = new Debugger(this);
 	_events = new EventsManager(this);
diff --git a/engines/access/asurface.cpp b/engines/access/asurface.cpp
index 0fb8f7d..438bfbf 100644
--- a/engines/access/asurface.cpp
+++ b/engines/access/asurface.cpp
@@ -38,6 +38,17 @@ int ASurface::_lastBoundsX;
 int ASurface::_lastBoundsY;
 int ASurface::_lastBoundsW;
 int ASurface::_lastBoundsH;
+int ASurface::_scrollX;
+int ASurface::_scrollY;
+
+void ASurface::init() {
+	_leftSkip = _rightSkip = 0;
+	_topSkip = _bottomSkip = 0;
+	_clipWidth = _clipHeight = 0;
+	_lastBoundsX = _lastBoundsY = 0;
+	_lastBoundsW = _lastBoundsH = 0;
+	_scrollX = _scrollY = 0;
+}
 
 void ASurface::clearBuffer() {
 	byte *pSrc = (byte *)getPixels();
@@ -98,12 +109,41 @@ void ASurface::plotImage(SpriteResource *sprite, int frameNum, const Common::Poi
 		_lastBoundsW = r.width();
 		_lastBoundsH = r.height();
 
-//		plotImage(frame, , )
+		plotFrame(frame, pt);
 	}
 }
 
-void ASurface::plotF(SpriteFrame *frame, const Common::Point &pt) {
+void ASurface::plotFrame(SpriteFrame *frame, const Common::Point &pt) {
+	byte *destP = (byte *)getBasePtr(pt.x, _scrollY + pt.y);
+	byte *srcP = frame->_data;
+	
+	int8 leftVal1 = 18;
+	int8 leftVal2 = -8;
+	if (_leftSkip) {
+		++leftVal2;
+		leftVal1 = -12;
+	}
+	int8 rightVal = (_rightSkip) ? -7 : -8;
 
+	// Skip over any lines of the frame
+	for (int yp = 0; yp < _topSkip; ++yp) {
+		srcP += *(srcP + 1) + 2;
+	}
+	
+	byte *srcLineP = srcP;
+	byte *destLineP = destP;
+	for (int yp = 0; yp < frame->h; ++yp, srcP = srcLineP, destP = destLineP) {
+		// Get length of line
+		int v = *srcP++;
+		int len = *srcP++;
+		srcLineP = srcP + len;
+		destLineP = destP + this->pitch;
+
+		// Draw the line of the frame
+		if (v != 0 || len != 0) {
+			warning("TODO: Line draw");
+		}
+	}
 }
 
 } // End of namespace Access
diff --git a/engines/access/asurface.h b/engines/access/asurface.h
index 7d1ee6c..d1e6b64 100644
--- a/engines/access/asurface.h
+++ b/engines/access/asurface.h
@@ -38,8 +38,11 @@ public:
 	static int _clipWidth, _clipHeight;
 	static int _lastBoundsX, _lastBoundsY;
 	static int _lastBoundsW, _lastBoundsH;
+	static int _scrollX, _scrollY;
+
+	static void init();
 protected:
-	virtual void ASurface::plotF(SpriteFrame *frame, const Common::Point &pt);
+	virtual void ASurface::plotFrame(SpriteFrame *frame, const Common::Point &pt);
 public:
 	void clearBuffer();
 
diff --git a/engines/access/screen.cpp b/engines/access/screen.cpp
index c1a4d91..63fd98b 100644
--- a/engines/access/screen.cpp
+++ b/engines/access/screen.cpp
@@ -46,7 +46,6 @@ Screen::Screen(AccessEngine *vm) : _vm(vm) {
 	_scrollFlag = false;
 	_scrollThreshold = 0;
 	_startColor = _numColors = 0;
-	_scrollX = _scrollY = 0;
 	_scrollCol = _scrollRow = 0;
 	_windowXAdd = _windowYAdd = 0;
 	_screenYOff = 0;
diff --git a/engines/access/screen.h b/engines/access/screen.h
index 8dc56d2..f327613 100644
--- a/engines/access/screen.h
+++ b/engines/access/screen.h
@@ -68,7 +68,6 @@ public:
 	int _startColor, _numColors;
 	Common::Point _vWindowSize;
 	Common::Point _bufferStart;
-	int _scrollX, _scrollY;
 	int _scrollCol, _scrollRow;
 	int _windowXAdd, _windowYAdd;
 	int _screenYOff;


Commit: 6801cb0855cef796ea22c969c9c9f25866cdfa72
    https://github.com/scummvm/scummvm/commit/6801cb0855cef796ea22c969c9c9f25866cdfa72
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-10T16:55:06-04:00

Commit Message:
ACCESS: Decompress sprite resource frames immediately on creation

Changed paths:
    engines/access/access.cpp
    engines/access/amazon/amazon_room.cpp
    engines/access/asurface.cpp
    engines/access/asurface.h
    engines/access/data.cpp
    engines/access/data.h



diff --git a/engines/access/access.cpp b/engines/access/access.cpp
index f625fa0..2f505c2 100644
--- a/engines/access/access.cpp
+++ b/engines/access/access.cpp
@@ -45,7 +45,6 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc)
 
 	_destIn = nullptr;
 	_current = nullptr;
-	clearCellTable();
 	_pCount = 0;
 	_selectCommand = 0;
 	_normalMouse = true;
@@ -82,6 +81,7 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc)
 	_intTim[3] = 0;
 	_timer[3] = 0;
 	_timerFlag = false;
+	Common::fill(&_objectsTable[0], &_objectsTable[100], (SpriteResource *)nullptr);
 	Common::fill(&_establishTable[0], &_establishTable[100], 0);
 	Common::fill(&_flags[0], &_flags[256], 0);
 	_establishFlag = false;
diff --git a/engines/access/amazon/amazon_room.cpp b/engines/access/amazon/amazon_room.cpp
index 056fa8f..5b840af 100644
--- a/engines/access/amazon/amazon_room.cpp
+++ b/engines/access/amazon/amazon_room.cpp
@@ -123,7 +123,7 @@ void AmazonRoom::roomSet() {
 
 void AmazonRoom::roomMenu() {
 	byte *iconData = _vm->_files->loadFile("ICONS.LZ");
-	SpriteResource *spr = new SpriteResource(_vm, _icon, _vm->_files->_filesize);
+	SpriteResource *spr = new SpriteResource(_vm, iconData, _vm->_files->_filesize);
 	delete[] iconData;
 
 	_vm->_screen->saveScreen();
diff --git a/engines/access/asurface.cpp b/engines/access/asurface.cpp
index 438bfbf..a9d97aa 100644
--- a/engines/access/asurface.cpp
+++ b/engines/access/asurface.cpp
@@ -21,10 +21,64 @@
  */
 
 #include "common/algorithm.h"
+#include "common/endian.h"
+#include "common/memstream.h"
+#include "access/access.h"
 #include "access/asurface.h"
 
 namespace Access {
 
+SpriteResource::SpriteResource(AccessEngine *vm, const byte *data, uint32 size,
+		DisposeAfterUse::Flag disposeMemory) {
+	Common::MemoryReadStream stream(data, size);
+	Common::Array<uint32> offsets;
+	int count = stream.readUint16LE();
+
+	for (int i = 0; i < count; i++)
+		offsets.push_back(stream.readUint32LE());
+	offsets.push_back(size);	// For easier calculations of Noctropolis sizes
+
+	// Build up the frames
+	for (int i = 0; i < count; ++i) {
+		stream.seek(offsets[i]);
+		int frameSize = offsets[i + 1] - offsets[i];
+
+		SpriteFrame *frame = new SpriteFrame(vm, stream, frameSize);
+		_frames.push_back(frame);
+	}
+
+	if (disposeMemory == DisposeAfterUse::YES)
+		delete[] data;
+}
+
+SpriteResource::~SpriteResource() {
+	for (uint i = 0; i < _frames.size(); ++i)
+		delete _frames[i];
+}
+
+SpriteFrame::SpriteFrame(AccessEngine *vm, Common::MemoryReadStream &stream, int frameSize) {
+	int w = stream.readUint16LE();
+	int h = stream.readUint16LE();
+	create(w, h, Graphics::PixelFormat::createFormatCLUT8());
+	
+	// Empty surface
+	byte *data = (byte *)getPixels();
+	Common::fill(data, data + w * h, 0);
+	
+	// Decode the data
+	for (int y = 0; y < h; ++y) {
+		int offset = stream.readByte();
+		int len = stream.readByte();
+		assert((offset + len) <= w);
+
+		byte *destP = (byte *)getBasePtr(offset, y);
+		stream.read(destP, len);
+	}
+}
+
+SpriteFrame::~SpriteFrame() {
+	free();
+}
 
 /*------------------------------------------------------------------------*/
 
@@ -114,6 +168,9 @@ void ASurface::plotImage(SpriteResource *sprite, int frameNum, const Common::Poi
 }
 
 void ASurface::plotFrame(SpriteFrame *frame, const Common::Point &pt) {
+	return;
+
+/*
 	byte *destP = (byte *)getBasePtr(pt.x, _scrollY + pt.y);
 	byte *srcP = frame->_data;
 	
@@ -144,6 +201,7 @@ void ASurface::plotFrame(SpriteFrame *frame, const Common::Point &pt) {
 			warning("TODO: Line draw");
 		}
 	}
+	*/
 }
 
 } // End of namespace Access
diff --git a/engines/access/asurface.h b/engines/access/asurface.h
index d1e6b64..d726e6a 100644
--- a/engines/access/asurface.h
+++ b/engines/access/asurface.h
@@ -25,12 +25,32 @@
 
 #include "common/scummsys.h"
 #include "common/array.h"
+#include "common/memstream.h"
 #include "common/rect.h"
 #include "graphics/surface.h"
 #include "access/data.h"
 
 namespace Access {
 
+class SpriteFrame : public Graphics::Surface {
+public:
+	SpriteFrame(AccessEngine *vm, Common::MemoryReadStream &stream, int frameSize);
+	~SpriteFrame();
+};
+
+class SpriteResource {
+public:
+	Common::Array<SpriteFrame *> _frames;
+public:
+	SpriteResource(AccessEngine *vm, const byte *data, uint32 size,
+		DisposeAfterUse::Flag disposeMemory = DisposeAfterUse::NO);
+	~SpriteResource();
+
+	int getCount() { return _frames.size(); }
+
+	SpriteFrame *getFrame(int idx) { return _frames[idx]; }
+};
+
 class ASurface : public Graphics::Surface {
 public:
 	static int _leftSkip, _rightSkip;
diff --git a/engines/access/data.cpp b/engines/access/data.cpp
index 3203020..c3a6bb3 100644
--- a/engines/access/data.cpp
+++ b/engines/access/data.cpp
@@ -21,50 +21,8 @@
  */
 
 #include "common/algorithm.h"
-#include "common/endian.h"
-#include "common/memstream.h"
-#include "access/access.h"
 #include "access/data.h"
 
 namespace Access {
 
-SpriteResource::SpriteResource(AccessEngine *vm, const byte *data, uint32 size,
-		DisposeAfterUse::Flag disposeMemory) {
-	Common::MemoryReadStream stream(data, size);
-	Common::Array<uint32> offsets;
-	int count = stream.readUint16LE();
-
-	for (int i = 0; i < count; i++)
-		offsets.push_back(stream.readUint32LE());
-	offsets.push_back(size);	// For easier calculations of Noctropolis sizes
-
-	// Build up the frames
-	for (int i = 0; i < count; ++i) {
-		stream.seek(offsets[i]);
-
-		SpriteFrame *frame = new SpriteFrame();
-		frame->_width = stream.readUint16LE();
-		frame->_height = stream.readUint16LE();
-		frame->_size = (vm->getGameID() == GType_MeanStreets) ? stream.readUint16LE() :
-			offsets[i + 1] - offsets[i];
-
-		frame->_data = new byte[frame->_size];
-		stream.read(frame->_data, frame->_size);
-
-		_frames.push_back(frame);
-	}
-
-	if (disposeMemory == DisposeAfterUse::YES)
-		delete[] data;
-}
-
-SpriteResource::~SpriteResource() {
-	for (uint i = 0; i < _frames.size(); ++i)
-		delete _frames[i];
-}
-
-SpriteFrame::~SpriteFrame() {
-	delete[] _data;
-}
-
 } // End of namespace Access
diff --git a/engines/access/data.h b/engines/access/data.h
index bb5ef90..b9da858 100644
--- a/engines/access/data.h
+++ b/engines/access/data.h
@@ -59,28 +59,6 @@ public:
 	int _vidSTable1;
 };
 
-class SpriteFrame : public Graphics::Surface {
-public:
-	uint16 _width, _height;
-	byte *_data;
-	uint32 _size;
-
-	~SpriteFrame();
-};
-
-class SpriteResource {
-public:
-	Common::Array<SpriteFrame *> _frames;
-public:
-	SpriteResource(AccessEngine *vm, const byte *data, uint32 size, 
-		DisposeAfterUse::Flag disposeMemory = DisposeAfterUse::NO);
-	~SpriteResource();
-
-	int getCount() { return _frames.size(); }
-
-	SpriteFrame *getFrame(int idx) { return _frames[idx]; }
-};
-
 } // End of namespace Access
 
 #endif /* ACCESS_DATA_H */


Commit: b2596cab0edc0a4709fba872ca0c20a782caabe4
    https://github.com/scummvm/scummvm/commit/b2596cab0edc0a4709fba872ca0c20a782caabe4
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-10T18:36:34-04:00

Commit Message:
ACCESS: Implement loadPlayField

Changed paths:
    engines/access/access.cpp
    engines/access/access.h
    engines/access/room.cpp
    engines/access/room.h
    engines/access/screen.cpp
    engines/access/screen.h



diff --git a/engines/access/access.cpp b/engines/access/access.cpp
index 2f505c2..a21a97c 100644
--- a/engines/access/access.cpp
+++ b/engines/access/access.cpp
@@ -247,10 +247,4 @@ void AccessEngine::doEstablish(int v) {
 	warning("TODO: doEstablish");
 }
 
-void AccessEngine::loadPlayField(int fileNum, int subfile) {
-	// TODO
-}
-
-
-
 } // End of namespace Access
diff --git a/engines/access/access.h b/engines/access/access.h
index 5fa0aed..26ae88e 100644
--- a/engines/access/access.h
+++ b/engines/access/access.h
@@ -226,8 +226,6 @@ public:
 	void establish(int v);
 
 	void establishCenter(int v);
-
-	void loadPlayField(int fileNum, int subfile);
 };
 
 } // End of namespace Access
diff --git a/engines/access/room.cpp b/engines/access/room.cpp
index e0acf1c..6f44926 100644
--- a/engines/access/room.cpp
+++ b/engines/access/room.cpp
@@ -35,7 +35,13 @@ Room::Room(AccessEngine *vm) : Manager(vm) {
 	_function = 0;
 	_roomFlag = 0;
 	_playField = nullptr;
+	_playFieldWidth = _playFieldHeight = 0;
+	_matrixSize = 0;
 	_tile = nullptr;
+	_vWindowWidth = _vWindowHeight = 0;
+	_vWindowBytesWide = 0;
+	_bufferBytesWide = 0;
+	_vWindowLinesTall = 0;
 }
 
 Room::~Room() {
@@ -181,7 +187,7 @@ void Room::loadRoomData(const byte *roomData) {
 	_vm->_scaleT1 = ((_vm->_scaleH2 - _vm->_scaleH1) << 8) / _vm->_scaleN1;
 
 	if (roomInfo._playFieldFile._fileNum != -1) {
-		_vm->loadPlayField(roomInfo._playFieldFile._fileNum,
+		loadPlayField(roomInfo._playFieldFile._fileNum,
 			roomInfo._playFieldFile._subfile);
 		setupRoom();
 
@@ -243,23 +249,23 @@ void Room::setupRoom() {
 	if (_roomFlag != 2)
 		setIconPalette();
 
-	if (_vm->_screen->_vWindowSize.x == _playFieldSize.x) {
+	if (_vWindowWidth == _playFieldWidth) {
 		_vm->_screen->_scrollX = 0;
 		_vm->_screen->_scrollCol = 0;
 	} else {
 		_vm->_screen->_scrollX = _vm->_player->_rawPlayer.x -
 			(_vm->_player->_rawPlayer.x >> 4);
 		int xp = MAX((_vm->_player->_rawPlayer.x >> 4) -
-			(_vm->_screen->_vWindowSize.x / 2), 0);
+			(_vWindowWidth / 2), 0);
 		_vm->_screen->_scrollCol = xp;
 
-		xp = xp + _vm->_screen->_vWindowSize.x - _playFieldSize.x;
+		xp = xp + _vWindowWidth - _playFieldWidth;
 		if (xp >= 0) {
 			_vm->_screen->_scrollCol = xp + 1;
 		}
 	}
 	
-	if (_vm->_screen->_vWindowSize.y == _playFieldSize.y) {
+	if (_vWindowHeight == _playFieldHeight) {
 		_vm->_screen->_scrollY = 0;
 		_vm->_screen->_scrollRow = 0;
 	}
@@ -267,10 +273,10 @@ void Room::setupRoom() {
 		_vm->_screen->_scrollY = _vm->_player->_rawPlayer.y -
 			(_vm->_player->_rawPlayer.y >> 4);
 		int yp = MAX((_vm->_player->_rawPlayer.y >> 4) -
-			(_vm->_screen->_vWindowSize.y / 2), 0);
+			(_vWindowHeight / 2), 0);
 		_vm->_screen->_scrollRow = yp;
 
-		yp = yp + _vm->_screen->_vWindowSize.y - _playFieldSize.y;
+		yp = yp + _vWindowHeight - _playFieldHeight;
 		if (yp >= 0) {
 			_vm->_screen->_scrollRow = yp + 1;
 		}
@@ -287,7 +293,7 @@ void Room::setWallCodes() {
 
 void Room::buildScreen() {
 	int scrollCol = _vm->_screen->_scrollCol;
-	int cnt = _vm->_screen->_vWindowSize.x + 1;
+	int cnt = _vWindowWidth + 1;
 	int offset = 0;
 
 	for (int idx = 0; idx < cnt, offset += TILE_WIDTH; ++idx) {
@@ -301,15 +307,15 @@ void Room::buildScreen() {
 
 void Room::buildColumn(int playX, int screenX) {
 	const byte *pSrc = _playField + _vm->_screen->_scrollRow * 
-		_playFieldSize.x + playX;
+		_playFieldWidth + playX;
 	byte *pDest = (byte *)_vm->_buffer1.getPixels();
 
-	for (int y = 0; y <= _vm->_screen->_vWindowSize.y; ++y) {
+	for (int y = 0; y <= _vWindowHeight; ++y) {
 		byte *pTile = _tile + (*pSrc << 8);
 
 		for (int tileY = 0; tileY < TILE_HEIGHT; ++tileY) {
 			Common::copy(pTile, pTile + TILE_WIDTH, pDest);
-			pDest += _vm->_screen->_vWindowSize.x;
+			pDest += _vWindowWidth;
 		}
 	}
 }
@@ -318,6 +324,70 @@ void Room::init4Quads() {
 	error("TODO: init4Quads");
 }
 
+void Room::loadPlayField(int fileNum, int subfile) {
+	byte *playData = _vm->_files->loadFile(fileNum, subfile);
+	Common::MemoryReadStream stream(playData + 0x10, _vm->_files->_filesize - 0x10);
+
+	// Copy the new palette
+	_vm->_screen->loadRawPalette(&stream);
+
+	// Copy off the tile data
+	_tileSize = playData[2] << 8;
+	_tile = new byte[_tileSize];
+	stream.read(_tile, _tileSize);
+
+	// Copy off the playfield data
+	_matrixSize = playData[0] * playData[1];
+	_playField = new byte[_matrixSize];
+	stream.read(_playField, _matrixSize);
+
+	// Load the plotter data
+	int numWalls = READ_LE_UINT16(playData + 6);
+	int numBlocks = playData[8];
+	_plotter.load(&stream, numWalls, numBlocks);
+
+	_vWindowWidth = playData[3];
+	_vWindowBytesWide = _vWindowWidth << 4;
+	_bufferBytesWide = _vWindowBytesWide + 16;
+	_vWindowHeight = playData[4];
+	_vWindowLinesTall = _vWindowHeight << 4;
+
+	_vm->_screen->setBufferScan();
+	delete[] playData;
+}
+
+/*------------------------------------------------------------------------*/
+
+Plotter::Plotter() {
+	_delta = _blockIn = 0;
+}
+
+void Plotter::load(Common::SeekableReadStream *stream, int wallCount, int blockCount) {
+	// Load the wall count
+	_walls.resize(wallCount);
+	
+	for (int i = 0; i < wallCount; ++i)
+		_walls[i].left = stream->readSint16LE();
+	for (int i = 0; i < wallCount; ++i)
+		_walls[i].top = stream->readSint16LE();
+	for (int i = 0; i < wallCount; ++i)
+		_walls[i].right = stream->readSint16LE();
+	for (int i = 0; i < wallCount; ++i)
+		_walls[i].bottom = stream->readSint16LE();
+
+	// Load the block list
+	_blocks.resize(blockCount);
+
+	for (int i = 0; i < blockCount; ++i)
+		_blocks[i].left = stream->readSint16LE();
+	for (int i = 0; i < blockCount; ++i)
+		_blocks[i].top = stream->readSint16LE();
+	for (int i = 0; i < blockCount; ++i)
+		_blocks[i].right = stream->readSint16LE();
+	for (int i = 0; i < blockCount; ++i)
+		_blocks[i].bottom = stream->readSint16LE();
+}
+
 /*------------------------------------------------------------------------*/
 
 RoomInfo::RoomInfo(const byte *data) {
diff --git a/engines/access/room.h b/engines/access/room.h
index 7296337..0c19308 100644
--- a/engines/access/room.h
+++ b/engines/access/room.h
@@ -36,6 +36,10 @@ public:
 	Common::Array<Common::Rect> _blocks;
 	int _blockIn;
 	int _delta;
+public:
+	Plotter();
+
+	void load(Common::SeekableReadStream *stream, int wallCount, int blockCount);
 };
 
 class JetFrame {
@@ -54,6 +58,8 @@ public:
 class Room: public Manager {
 private:
 	void roomLoop();
+
+	void loadPlayField(int fileNum, int subfile);
 protected:
 	void loadRoomData(const byte *roomData);
 	void setupRoom();
@@ -86,8 +92,16 @@ public:
 	int _function;
 	int _roomFlag;
 	byte *_playField;
-	Common::Point _playFieldSize;
+	int _matrixSize;
+	int _playFieldWidth;
+	int _playFieldHeight;
 	byte *_tile;
+	int _tileSize;
+	int _vWindowWidth;
+	int _vWindowHeight;
+	int _vWindowBytesWide;
+	int _bufferBytesWide;
+	int _vWindowLinesTall;
 public:
 	Room(AccessEngine *vm);
 
diff --git a/engines/access/screen.cpp b/engines/access/screen.cpp
index 63fd98b..b2cb7da 100644
--- a/engines/access/screen.cpp
+++ b/engines/access/screen.cpp
@@ -73,7 +73,7 @@ void Screen::setInitialPalettte() {
 }
 
 void Screen::loadPalette(Common::SeekableReadStream *stream) {
-	stream->read(&_rawPalette[0], PALETTE_SIZE);
+	loadRawPalette(stream);
 	setPalette();
 	_loadPalFlag = true;
 }
@@ -88,6 +88,10 @@ void Screen::setPalette() {
 	g_system->getPaletteManager()->setPalette(&_rawPalette[0], 0, PALETTE_COUNT);
 }
 
+void Screen::loadRawPalette(Common::SeekableReadStream *stream) {
+	stream->read(&_rawPalette[0], PALETTE_SIZE);
+}
+
 void Screen::updatePalette() {
 	g_system->getPaletteManager()->setPalette(&_tempPalette[0], 0, PALETTE_COUNT);
 	updateScreen();
diff --git a/engines/access/screen.h b/engines/access/screen.h
index f327613..45db7d0 100644
--- a/engines/access/screen.h
+++ b/engines/access/screen.h
@@ -66,7 +66,6 @@ public:
 	bool _scrollFlag;
 	int _scrollThreshold;
 	int _startColor, _numColors;
-	Common::Point _vWindowSize;
 	Common::Point _bufferStart;
 	int _scrollCol, _scrollRow;
 	int _windowXAdd, _windowYAdd;
@@ -111,6 +110,8 @@ public:
 
 	void setPalette();
 
+	void loadRawPalette(Common::SeekableReadStream *stream);
+
 	/**
 	 * Copy a buffer to the screen
 	 */


Commit: 6f2bc7fc1f5426a01d196e5a61faafbb7b40ad13
    https://github.com/scummvm/scummvm/commit/6f2bc7fc1f5426a01d196e5a61faafbb7b40ad13
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-08-11T00:52:47+02:00

Commit Message:
ACCESS: Implement 2 opcodes

Changed paths:
    engines/access/scripts.cpp
    engines/access/scripts.h



diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp
index 2a82521..a6ecfa3 100644
--- a/engines/access/scripts.cpp
+++ b/engines/access/scripts.cpp
@@ -92,10 +92,10 @@ void Scripts::executeCommand(int commandIndex) {
 		&Scripts::CMDCHECKFRAME, &Scripts::cmdCheckAnim, &Scripts::CMDSND, 
 		&Scripts::cmdRetNeg, &Scripts::cmdRetPos, &Scripts::cmdCheckLoc, 
 		&Scripts::cmdSetAnim, &Scripts::CMDDISPINV, &Scripts::CMDSETTIMER, 
-		&Scripts::CMDSETTIMER, &Scripts::CMDCHECKTIMER, &Scripts::CMDSETTRAVEL,
-		&Scripts::CMDSETTRAVEL, &Scripts::CMDSETVID, &Scripts::CMDPLAYVID, 
+		&Scripts::CMDSETTIMER, &Scripts::CMDCHECKTIMER, &Scripts::cmdSetTravel,
+		&Scripts::cmdSetTravel, &Scripts::CMDSETVID, &Scripts::CMDPLAYVID, 
 		&Scripts::cmdPlotImage, &Scripts::cmdSetDisplay, &Scripts::CMDSETBUFFER, 
-		&Scripts::CMDSETSCROLL, &Scripts::CMDSAVERECT, &Scripts::CMDSAVERECT, 
+		&Scripts::cmdSetScroll, &Scripts::CMDSAVERECT, &Scripts::CMDSAVERECT, 
 		&Scripts::CMDSETBUFVID, &Scripts::CMDPLAYBUFVID, &Scripts::cmeRemoveLast, 
 		&Scripts::CMDSPECIAL, &Scripts::CMDSPECIAL, &Scripts::CMDSPECIAL,
 		&Scripts::CMDSETCYCLE, &Scripts::CMDCYCLE, &Scripts::CMDCHARSPEAK, 
@@ -263,7 +263,14 @@ void Scripts::cmdSetAnim() {
 void Scripts::CMDDISPINV() { }
 void Scripts::CMDSETTIMER() { }
 void Scripts::CMDCHECKTIMER() { }
-void Scripts::CMDSETTRAVEL() { }
+
+void Scripts::cmdSetTravel() {
+	if (_vm->_selectCommand == 5)
+		cmdGoto();
+	else
+		_data->skip(2);
+}
+
 void Scripts::CMDSETVID() { }
 void Scripts::CMDPLAYVID() { }
 
@@ -284,7 +291,14 @@ void Scripts::cmdSetDisplay() {
 }
 
 void Scripts::CMDSETBUFFER() { }
-void Scripts::CMDSETSCROLL() { }
+
+void Scripts::cmdSetScroll() {
+	_vm->_screen->_scrollCol = _data->readUint16LE();
+	_vm->_screen->_scrollRow = _data->readUint16LE();
+	_vm->_screen->_scrollX = 0;
+	_vm->_screen->_scrollY = 0;
+}
+
 void Scripts::CMDSAVERECT() { }
 void Scripts::CMDSETBUFVID() { }
 void Scripts::CMDPLAYBUFVID() { }
diff --git a/engines/access/scripts.h b/engines/access/scripts.h
index 0bdc746..3173c8a 100644
--- a/engines/access/scripts.h
+++ b/engines/access/scripts.h
@@ -75,13 +75,13 @@ protected:
 	void CMDDISPINV();
 	void CMDSETTIMER();
 	void CMDCHECKTIMER();
-	void CMDSETTRAVEL();
+	void cmdSetTravel();
 	void CMDSETVID();
 	void CMDPLAYVID();
 	void cmdPlotImage();
 	void cmdSetDisplay();
 	void CMDSETBUFFER();
-	void CMDSETSCROLL();
+	void cmdSetScroll();
 	void CMDSAVERECT();
 	void CMDSETBUFVID();
 	void CMDPLAYBUFVID();


Commit: e833ae66e2a90e539ad004983acbdae2e4ee94f3
    https://github.com/scummvm/scummvm/commit/e833ae66e2a90e539ad004983acbdae2e4ee94f3
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-10T19:19:32-04:00

Commit Message:
ACCESS: Fix loop in buildScreen

Changed paths:
    engines/access/asurface.cpp
    engines/access/asurface.h
    engines/access/room.cpp



diff --git a/engines/access/asurface.cpp b/engines/access/asurface.cpp
index a9d97aa..3a381a1 100644
--- a/engines/access/asurface.cpp
+++ b/engines/access/asurface.cpp
@@ -168,7 +168,10 @@ void ASurface::plotImage(SpriteResource *sprite, int frameNum, const Common::Poi
 }
 
 void ASurface::plotFrame(SpriteFrame *frame, const Common::Point &pt) {
-	return;
+	frame->copyTo(this, pt);
+//	g_system->copyRectToScreen((byte *)getPixels(), 320, 0, 0, 320, 200);
+//	g_system->updateScreen();
+
 
 /*
 	byte *destP = (byte *)getBasePtr(pt.x, _scrollY + pt.y);
@@ -204,4 +207,17 @@ void ASurface::plotFrame(SpriteFrame *frame, const Common::Point &pt) {
 	*/
 }
 
+void ASurface::copyTo(ASurface *dest, const Common::Point &destPos) {
+	for (int yp = 0; yp < h; ++yp) {
+		byte *srcP = (byte *)getBasePtr(0, yp);
+		byte *destP = (byte *)dest->getBasePtr(destPos.x, destPos.y + yp);
+
+		for (int xp = 0; xp < this->w; ++xp, ++srcP, ++destP) {
+			if (*srcP != 0)
+				*destP = *srcP;
+		}
+	}
+}
+
+
 } // End of namespace Access
diff --git a/engines/access/asurface.h b/engines/access/asurface.h
index d726e6a..c4dfc54 100644
--- a/engines/access/asurface.h
+++ b/engines/access/asurface.h
@@ -32,24 +32,8 @@
 
 namespace Access {
 
-class SpriteFrame : public Graphics::Surface {
-public:
-	SpriteFrame(AccessEngine *vm, Common::MemoryReadStream &stream, int frameSize);
-	~SpriteFrame();
-};
-
-class SpriteResource {
-public:
-	Common::Array<SpriteFrame *> _frames;
-public:
-	SpriteResource(AccessEngine *vm, const byte *data, uint32 size,
-		DisposeAfterUse::Flag disposeMemory = DisposeAfterUse::NO);
-	~SpriteResource();
-
-	int getCount() { return _frames.size(); }
-
-	SpriteFrame *getFrame(int idx) { return _frames[idx]; }
-};
+class SpriteResource;
+class SpriteFrame;
 
 class ASurface : public Graphics::Surface {
 public:
@@ -71,8 +55,30 @@ public:
 	bool clip(Common::Rect &r);
 
 	void plotImage(SpriteResource *sprite, int frameNum, const Common::Point &pt);
+
+	void copyTo(ASurface *dest, const Common::Point &destPos);
 };
 
+class SpriteFrame : public ASurface {
+public:
+	SpriteFrame(AccessEngine *vm, Common::MemoryReadStream &stream, int frameSize);
+	~SpriteFrame();
+};
+
+class SpriteResource {
+public:
+	Common::Array<SpriteFrame *> _frames;
+public:
+	SpriteResource(AccessEngine *vm, const byte *data, uint32 size,
+		DisposeAfterUse::Flag disposeMemory = DisposeAfterUse::NO);
+	~SpriteResource();
+
+	int getCount() { return _frames.size(); }
+
+	SpriteFrame *getFrame(int idx) { return _frames[idx]; }
+};
+
+
 } // End of namespace Access
 
 #endif /* ACCESS_ASURFACE_H */
diff --git a/engines/access/room.cpp b/engines/access/room.cpp
index 6f44926..371b714 100644
--- a/engines/access/room.cpp
+++ b/engines/access/room.cpp
@@ -296,7 +296,7 @@ void Room::buildScreen() {
 	int cnt = _vWindowWidth + 1;
 	int offset = 0;
 
-	for (int idx = 0; idx < cnt, offset += TILE_WIDTH; ++idx) {
+	for (int idx = 0; idx < cnt; offset += TILE_WIDTH, ++idx) {
 		buildColumn(_vm->_screen->_scrollCol, offset);
 		++_vm->_screen->_scrollCol;
 	}


Commit: b6c946003198d84112e87cc2974eac6e9dc7c4f4
    https://github.com/scummvm/scummvm/commit/b6c946003198d84112e87cc2974eac6e9dc7c4f4
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-10T19:42:33-04:00

Commit Message:
ACCESS: Fix palette translation during loading

Changed paths:
    engines/access/screen.cpp



diff --git a/engines/access/screen.cpp b/engines/access/screen.cpp
index b2cb7da..bc913c5 100644
--- a/engines/access/screen.cpp
+++ b/engines/access/screen.cpp
@@ -32,6 +32,8 @@
 
 namespace Access {
 
+#define VGA_COLOR_TRANS(x) ((x) * 255 / 63)
+
 Screen::Screen(AccessEngine *vm) : _vm(vm) {
 	create(320, 200, Graphics::PixelFormat::createFormatCLUT8());
 	Common::fill(&_tempPalette[0], &_tempPalette[PALETTE_SIZE], 0);
@@ -90,6 +92,8 @@ void Screen::setPalette() {
 
 void Screen::loadRawPalette(Common::SeekableReadStream *stream) {
 	stream->read(&_rawPalette[0], PALETTE_SIZE);
+	for (byte *p = &_rawPalette[0]; p < &_rawPalette[PALETTE_SIZE]; ++p)
+		*p = VGA_COLOR_TRANS(*p);
 }
 
 void Screen::updatePalette() {


Commit: 69ecc15c028208f6b0f28d6df4d86d1a8ba7e26a
    https://github.com/scummvm/scummvm/commit/69ecc15c028208f6b0f28d6df4d86d1a8ba7e26a
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-10T22:25:30-04:00

Commit Message:
ACCESS: Add decoding of animation resources

Changed paths:
    engines/access/animation.cpp
    engines/access/animation.h
    engines/access/room.cpp
    engines/access/scripts.cpp
    engines/access/scripts.h



diff --git a/engines/access/animation.cpp b/engines/access/animation.cpp
index 4d73801..0d8589d 100644
--- a/engines/access/animation.cpp
+++ b/engines/access/animation.cpp
@@ -21,24 +21,123 @@
  */
 
 #include "common/endian.h"
+#include "common/memstream.h"
 #include "access/animation.h"
 
 namespace Access {
 
+AnimationResource::AnimationResource(const byte *data, int size) {
+	Common::MemoryReadStream stream(data, size);
+	int count = stream.readUint16LE();
+
+	Common::Array<int> offsets;
+	for (int i = 0; i < count; ++i)
+		offsets.push_back(stream.readUint32LE());
+
+	_animations.reserve(count);
+	for (int i = 0; i < count; ++i) {
+		stream.seek(offsets[i]);
+		Animation *anim = new Animation(stream);
+		_animations.push_back(anim);
+	}
+}
+
+AnimationResource::~AnimationResource() {
+	for (int i = 0; i < (int)_animations.size(); ++i)
+		delete _animations[i];
+}
+
+/*------------------------------------------------------------------------*/
+
+Animation::Animation(Common::MemoryReadStream &stream) {
+	uint32 startOfs = stream.pos();
+
+	_type = stream.readByte();
+	_scaling = stream.readByte();
+	stream.readByte(); // unk
+	_frameNumber = stream.readByte();
+	_initialTicks = stream.readUint16LE();
+	stream.readUint16LE(); // unk
+	stream.readUint16LE(); // unk
+	_loopCount = stream.readUint16LE();
+	_countdownTicks = stream.readUint16LE();
+	_currentLoopCount = stream.readUint16LE();
+	stream.readUint16LE(); // unk
+
+	Common::Array<uint16> frameOffsets;
+	uint16 ofs;
+	while ((ofs = stream.readUint16LE()) != 0)
+		frameOffsets.push_back(ofs);
+
+	for (int i = 0; i < (int)frameOffsets.size(); i++) {
+		stream.seek(startOfs + frameOffsets[i]);
+
+		AnimationFrame *frame = new AnimationFrame(stream, startOfs);
+		_frames.push_back(frame);
+	}
+}
+
+Animation::~Animation() {
+	for (int i = 0; i < (int)_frames.size(); ++i)
+		delete _frames[i];
+}
+
+void Animation::animate() {
+	error("TODO");
+}
+
+/*------------------------------------------------------------------------*/
+
+AnimationFrame::AnimationFrame(Common::MemoryReadStream &stream, int startOffset) {
+	uint16 nextOffset;
+
+	stream.readByte(); // unk
+	_baseX = stream.readUint16LE();
+	_baseY = stream.readUint16LE();
+	_frameDelay = stream.readUint16LE();
+	nextOffset = stream.readUint16LE();
+
+	while (nextOffset != 0) {
+		stream.seek(startOffset + nextOffset);
+
+		AnimationFramePart *framePart = new AnimationFramePart(stream);
+		_parts.push_back(framePart);
+
+		nextOffset = stream.readUint16LE();
+	}
+}
+
+AnimationFrame::~AnimationFrame() {
+	for (int i = 0; i < (int)_parts.size(); ++i)
+		delete _parts[i];
+}
+
+/*------------------------------------------------------------------------*/
+
+AnimationFramePart::AnimationFramePart(Common::MemoryReadStream &stream) {
+	_flags = stream.readByte();
+	_slotIndex = stream.readByte();
+	_spriteIndex = stream.readByte();
+	_position.x = stream.readUint16LE();
+	_position.y = stream.readUint16LE();
+	_priority = stream.readUint16LE();
+}
+
+/*------------------------------------------------------------------------*/
+
 AnimationManager::AnimationManager(AccessEngine *vm) : Manager(vm) {
-	_anim = nullptr;
 	_animation = nullptr;
+	_animStart = nullptr;
 }
 
 AnimationManager::~AnimationManager() {
-	delete[] _anim;
 	delete _animation;
 }
 
 void AnimationManager::freeAnimationData() {
-	delete[] _anim;
-	_anim = nullptr;
+	delete _animation;
 	_animation = nullptr;
+	_animStart = nullptr;
 }
 
 void AnimationManager::clearTimers() {
@@ -48,10 +147,17 @@ void AnimationManager::clearTimers() {
 	_animationTimers.clear();
 }
 
+void AnimationManager::loadAnimations(const byte *data, int size) {
+	_animationTimers.clear();
+	delete _animation;
+	_animation = new AnimationResource(data,  size);
+}
+
+
 Animation *AnimationManager::setAnimation(int animId) {
 	Animation *anim = findAnimation(animId);
 
-	anim->_countdownTicks = anim->_ticks;
+	anim->_countdownTicks = anim->_initialTicks;
 	anim->_frameNumber = 0;
 
 	anim->_currentLoopCount = (anim->_type != 3 && anim->_type != 4) ? 0 : 
@@ -62,18 +168,17 @@ Animation *AnimationManager::setAnimation(int animId) {
 }
 
 void AnimationManager::setAnimTimer(Animation *anim) {
-
+	_animationTimers.push_back(anim);
 }
 
 Animation *AnimationManager::findAnimation(int animId) {
-	_animation = new Animation(_anim + READ_LE_UINT16(_anim + animId * 4 + 2));
-	return _animation;
+	_animStart = _animation->getAnimation(animId);
+	return _animStart;
 }
 
-/*------------------------------------------------------------------------*/
-
-Animation::Animation(const byte *data) {
-
+void AnimationManager::animate(int animId) {
+	Animation *anim = findAnimation(animId);
+	anim->animate();
 }
 
 } // End of namespace Access
diff --git a/engines/access/animation.h b/engines/access/animation.h
index 879d1e9..45a59ef 100644
--- a/engines/access/animation.h
+++ b/engines/access/animation.h
@@ -25,41 +25,86 @@
 
 #include "common/scummsys.h"
 #include "common/array.h"
+#include "common/memstream.h"
 #include "access/data.h"
 
 namespace Access {
 
+class AnimationResource;
 class Animation;
+class AnimationFrame;
+class AnimationFramePart;
 
 class AnimationManager : public Manager {
 public:
-	const byte *_anim;
-	Animation *_animation;
 	Common::Array<Animation *> _animationTimers;
+	AnimationResource *_animation;
+	Animation *_animStart;
 public:
 	AnimationManager(AccessEngine *vm);
 	~AnimationManager();
 	void freeAnimationData();
+	void loadAnimations(const byte *data, int size);
+	
 	void clearTimers();
 
 	Animation *findAnimation(int animId);
 	Animation *setAnimation(int animId);
 
 	void setAnimTimer(Animation *anim);
+
+	void animate(int animId);
+};
+
+class AnimationResource {
+private:
+	Common::Array<Animation *> _animations;
+public:
+	AnimationResource(const byte *data, int size);
+	~AnimationResource();
+
+	int getCount() { return _animations.size(); }
+	Animation *getAnimation(int idx) { return _animations[idx]; }
 };
 
 class Animation {
+private:
+	Common::Array<AnimationFrame *> _frames;
 public:
 	int _type;
 	int _scaling;
 	int _frameNumber;
-	int _ticks;
+	int _initialTicks;
 	int _loopCount;
 	int _countdownTicks;
 	int _currentLoopCount;
 	int _field10;
 public:
-	Animation(const byte *data);
+	Animation(Common::MemoryReadStream &stream);
+	~Animation();
+
+	void animate();
+};
+
+class AnimationFrame {
+public:
+	int _baseX, _baseY;
+	int _frameDelay;
+	Common::Array<AnimationFramePart *> _parts;
+public:
+	AnimationFrame(Common::MemoryReadStream &stream, int startOffset);
+	~AnimationFrame();
+};
+
+class AnimationFramePart {
+public:
+	byte _flags;
+	int _slotIndex;
+	int _spriteIndex;
+	Common::Point _position;
+	int _priority;
+public:
+	AnimationFramePart(Common::MemoryReadStream &stream);
 };
 
 } // End of namespace Access
diff --git a/engines/access/room.cpp b/engines/access/room.cpp
index 371b714..98e9d5e 100644
--- a/engines/access/room.cpp
+++ b/engines/access/room.cpp
@@ -207,9 +207,11 @@ void Room::loadRoomData(const byte *roomData) {
 
 	// Load animation data
 	_vm->_animation->freeAnimationData();
-	if (roomInfo._animFile._fileNum != -1)
-		_vm->_animation->_anim = _vm->_files->loadFile(roomInfo._animFile._fileNum,
-		roomInfo._animFile._subfile);
+	if (roomInfo._animFile._fileNum != -1) {
+		byte *data = _vm->_files->loadFile(roomInfo._animFile._fileNum,
+			roomInfo._animFile._subfile);
+		_vm->_animation->loadAnimations(data, _vm->_files->_filesize);
+	}
 
 	_vm->_scaleI = roomInfo._scaleI;
 	_vm->_screen->_scrollThreshold = roomInfo._scrollThreshold;
diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp
index a6ecfa3..fd42530 100644
--- a/engines/access/scripts.cpp
+++ b/engines/access/scripts.cpp
@@ -85,7 +85,7 @@ void Scripts::executeCommand(int commandIndex) {
 		&Scripts::CMDOBJECT, &Scripts::CMDENDOBJECT, &Scripts::cmdJumpLook, 
 		&Scripts::cmdJumpHelp, &Scripts::cmdJumpGet, &Scripts::cmdJumpMove,
 		&Scripts::cmdJumpUse, &Scripts::cmdJumpTalk, &Scripts::cmdNull, 
-		&Scripts::CMDPRINT, &Scripts::cmdRetPos, &Scripts::CMDANIM,
+		&Scripts::CMDPRINT, &Scripts::cmdRetPos, &Scripts::cmdAnim,
 		&Scripts::cmdSetFlag, &Scripts::cmdCheckFlag, &Scripts::cmdGoto, 
 		&Scripts::cmdSetInventory, &Scripts::cmdSetInventory, &Scripts::cmdCheckInventory, 
 		&Scripts::CMDSETTEX, &Scripts::CMDNEWROOM, &Scripts::CMDCONVERSE, 
@@ -114,9 +114,9 @@ void Scripts::executeCommand(int commandIndex) {
 	(this->*COMMAND_LIST[commandIndex])();
 }
 
-void Scripts::CMDOBJECT() { }
+void Scripts::CMDOBJECT() { error("TODO"); }
 
-void Scripts::CMDENDOBJECT() { }
+void Scripts::CMDENDOBJECT() { error("TODO"); }
 
 void Scripts::cmdJumpLook() {
 	if (_vm->_selectCommand == 0)
@@ -163,14 +163,17 @@ void Scripts::cmdJumpTalk() {
 void Scripts::cmdNull() {
 }
 
-void Scripts::CMDPRINT() { }
+void Scripts::CMDPRINT() { error("TODO"); }
 
 void Scripts::cmdRetPos() {
 	_endFlag = true;
 	_returnCode = 0;
 }
 
-void Scripts::CMDANIM() { }
+void Scripts::cmdAnim() { 
+	int animId = _data->readUint16LE();
+	_vm->_animation->animate(animId);
+}
 
 void Scripts::cmdSetFlag() { 
 	int flagNum = _data->readByte();
@@ -216,10 +219,10 @@ void Scripts::cmdCheckInventory() {
 		_data->skip(2);
 }
 
-void Scripts::CMDSETTEX() { }
-void Scripts::CMDNEWROOM() { }
-void Scripts::CMDCONVERSE() { }
-void Scripts::CMDCHECKFRAME() { }
+void Scripts::CMDSETTEX() { error("TODO"); }
+void Scripts::CMDNEWROOM() { error("TODO"); }
+void Scripts::CMDCONVERSE() { error("TODO"); }
+void Scripts::CMDCHECKFRAME() { error("TODO"); }
 
 void Scripts::cmdCheckAnim() {
 	int id = _data->readUint16LE();
@@ -232,7 +235,7 @@ void Scripts::cmdCheckAnim() {
 		_data->skip(4);
 }
 
-void Scripts::CMDSND() { }
+void Scripts::CMDSND() { error("TODO"); }
 
 void Scripts::cmdRetNeg() {
 	_endFlag = true;
@@ -260,9 +263,9 @@ void Scripts::cmdSetAnim() {
 	_vm->_animation->setAnimTimer(anim);
 }
 
-void Scripts::CMDDISPINV() { }
-void Scripts::CMDSETTIMER() { }
-void Scripts::CMDCHECKTIMER() { }
+void Scripts::CMDDISPINV() { error("TODO"); }
+void Scripts::CMDSETTIMER() { error("TODO"); }
+void Scripts::CMDCHECKTIMER() { error("TODO"); }
 
 void Scripts::cmdSetTravel() {
 	if (_vm->_selectCommand == 5)
@@ -271,8 +274,8 @@ void Scripts::cmdSetTravel() {
 		_data->skip(2);
 }
 
-void Scripts::CMDSETVID() { }
-void Scripts::CMDPLAYVID() { }
+void Scripts::CMDSETVID() { error("TODO"); }
+void Scripts::CMDPLAYVID() { error("TODO"); }
 
 void Scripts::cmdPlotImage() {
 	_vm->_destIn = _vm->_current;
@@ -290,7 +293,7 @@ void Scripts::cmdSetDisplay() {
 	_vm->_current = _vm->_screen;
 }
 
-void Scripts::CMDSETBUFFER() { }
+void Scripts::CMDSETBUFFER() { error("TODO"); }
 
 void Scripts::cmdSetScroll() {
 	_vm->_screen->_scrollCol = _data->readUint16LE();
@@ -299,31 +302,31 @@ void Scripts::cmdSetScroll() {
 	_vm->_screen->_scrollY = 0;
 }
 
-void Scripts::CMDSAVERECT() { }
-void Scripts::CMDSETBUFVID() { }
-void Scripts::CMDPLAYBUFVID() { }
+void Scripts::CMDSAVERECT() { error("TODO"); }
+void Scripts::CMDSETBUFVID() { error("TODO"); }
+void Scripts::CMDPLAYBUFVID() { error("TODO"); }
 
 void Scripts::cmeRemoveLast() {
 	--_vm->_numAnimTimers;
 }
 
-void Scripts::CMDSPECIAL() { }
-void Scripts::CMDSETCYCLE() { }
-void Scripts::CMDCYCLE() { }
-void Scripts::CMDCHARSPEAK() { }
-void Scripts::CMDTEXSPEAK() { }
-void Scripts::CMDTEXCHOICE() { }
-void Scripts::CMDWAIT() { }
-void Scripts::CMDSETCONPOS() { }
-void Scripts::CMDCHECKVFRAME() { }
-void Scripts::CMDJUMPCHOICE() { }
-void Scripts::CMDRETURNCHOICE() { }
-void Scripts::CMDCLEARBLOCK() { }
-void Scripts::CMDLOADSOUND() { }
-void Scripts::CMDFREESOUND() { }
-void Scripts::CMDSETVIDSND() { }
-void Scripts::CMDPLAYVIDSND() { }
-void Scripts::CMDPUSHLOCATION() { }
+void Scripts::CMDSPECIAL() { error("TODO"); }
+void Scripts::CMDSETCYCLE() { error("TODO"); }
+void Scripts::CMDCYCLE() { error("TODO"); }
+void Scripts::CMDCHARSPEAK() { error("TODO"); }
+void Scripts::CMDTEXSPEAK() { error("TODO"); }
+void Scripts::CMDTEXCHOICE() { error("TODO"); }
+void Scripts::CMDWAIT() { error("TODO"); }
+void Scripts::CMDSETCONPOS() { error("TODO"); }
+void Scripts::CMDCHECKVFRAME() { error("TODO"); }
+void Scripts::CMDJUMPCHOICE() { error("TODO"); }
+void Scripts::CMDRETURNCHOICE() { error("TODO"); }
+void Scripts::CMDCLEARBLOCK() { error("TODO"); }
+void Scripts::CMDLOADSOUND() { error("TODO"); }
+void Scripts::CMDFREESOUND() { error("TODO"); }
+void Scripts::CMDSETVIDSND() { error("TODO"); }
+void Scripts::CMDPLAYVIDSND() { error("TODO"); }
+void Scripts::CMDPUSHLOCATION() { error("TODO"); }
 
 void Scripts::cmdPlayerOff() {
 	_vm->_player->_playerOff = true;
@@ -333,18 +336,18 @@ void Scripts::cmdPlayerOn() {
 	_vm->_player->_playerOff = false;
 }
 
-void Scripts::CMDDEAD() { }
+void Scripts::CMDDEAD() { error("TODO"); }
 
 void Scripts::cmdFadeOut() {
 	_vm->_screen->forceFadeOut();
 }
 
-void Scripts::CMDENDVID() { }
-void Scripts::CMDHELP() { }
-void Scripts::CMDCYCLEBACK() { }
-void Scripts::CMDCHAPTER() { }
-void Scripts::CMDSETHELP() { }
-void Scripts::CMDCENTERPANEL() { }
+void Scripts::CMDENDVID() { error("TODO"); }
+void Scripts::CMDHELP() { error("TODO"); }
+void Scripts::CMDCYCLEBACK() { error("TODO"); }
+void Scripts::CMDCHAPTER() { error("TODO"); }
+void Scripts::CMDSETHELP() { error("TODO"); }
+void Scripts::CMDCENTERPANEL() { error("TODO"); }
 
 void Scripts::cmdMainPanel() { 
 	if (_vm->_screen->_vesaMode) {
@@ -353,7 +356,7 @@ void Scripts::cmdMainPanel() {
 	}
 }
 
-void Scripts::CMDRETFLASH() { }
+void Scripts::CMDRETFLASH() { error("TODO"); }
 
 
 } // End of namespace Access
diff --git a/engines/access/scripts.h b/engines/access/scripts.h
index 3173c8a..c8f951d 100644
--- a/engines/access/scripts.h
+++ b/engines/access/scripts.h
@@ -52,7 +52,7 @@ protected:
 	void cmdNull();
 	void CMDPRINT();
 	void cmdRetPos();
-	void CMDANIM();
+	void cmdAnim();
 	void cmdSetFlag();
 	void cmdCheckFlag();
 	


Commit: a0b9afded37693673485549d41d3b3513bcb2dab
    https://github.com/scummvm/scummvm/commit/a0b9afded37693673485549d41d3b3513bcb2dab
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-10T23:17:53-04:00

Commit Message:
ACCESS: Implemented animation anim methods

Changed paths:
    engines/access/animation.cpp
    engines/access/animation.h
    engines/access/scripts.cpp



diff --git a/engines/access/animation.cpp b/engines/access/animation.cpp
index 0d8589d..705fd7b 100644
--- a/engines/access/animation.cpp
+++ b/engines/access/animation.cpp
@@ -22,11 +22,12 @@
 
 #include "common/endian.h"
 #include "common/memstream.h"
+#include "access/access.h"
 #include "access/animation.h"
 
 namespace Access {
 
-AnimationResource::AnimationResource(const byte *data, int size) {
+AnimationResource::AnimationResource(AccessEngine *vm, const byte *data, int size) {
 	Common::MemoryReadStream stream(data, size);
 	int count = stream.readUint16LE();
 
@@ -37,7 +38,7 @@ AnimationResource::AnimationResource(const byte *data, int size) {
 	_animations.reserve(count);
 	for (int i = 0; i < count; ++i) {
 		stream.seek(offsets[i]);
-		Animation *anim = new Animation(stream);
+		Animation *anim = new Animation(vm, stream);
 		_animations.push_back(anim);
 	}
 }
@@ -49,7 +50,8 @@ AnimationResource::~AnimationResource() {
 
 /*------------------------------------------------------------------------*/
 
-Animation::Animation(Common::MemoryReadStream &stream) {
+Animation::Animation(AccessEngine *vm, Common::MemoryReadStream &stream):
+		Manager(vm) {
 	uint32 startOfs = stream.pos();
 
 	_type = stream.readByte();
@@ -82,10 +84,143 @@ Animation::~Animation() {
 		delete _frames[i];
 }
 
+typedef void(Animation::*AnimationMethodPtr)();
+
 void Animation::animate() {
+	static const AnimationMethodPtr METHODS[8] =
+	{ &Animation::anim0, &Animation::anim1, &Animation::anim2, &Animation::anim3, 
+	&Animation::anim4, &Animation::animNone, &Animation::animNone, &Animation::anim7 };
+
+	(this->*METHODS[_type])();
+}
+
+void Animation::anim0() {
+	if (_currentLoopCount != -1) {
+		if (_countdownTicks != 0) {
+			calcFrame();
+			setFrame1();
+		} else {
+			_countdownTicks = _initialTicks;
+			++_frameNumber;
+			calcFrame();
+
+			if (this == _vm->_animation->_animStart) {
+				_frameNumber = 0;
+				_currentLoopCount = -1;
+			}
+
+			setFrame();
+		}
+	}
+}
+
+void Animation::anim1() {
+	if (_currentLoopCount == -1 || _countdownTicks != 0) {
+		calcFrame();
+		setFrame1();
+	} else {
+		_countdownTicks = _initialTicks;
+		++_frameNumber;
+		calcFrame();
+
+		if (this == _vm->_animation->_animStart) {
+			--_frameNumber;
+			_currentLoopCount = -1;
+		}
+
+		setFrame();
+	}
+}
+
+void Animation::anim2() {
+	if (_countdownTicks != 0) {
+		calcFrame();
+		setFrame1();
+	} else {
+		_countdownTicks = _initialTicks;
+		++_frameNumber;
+		calcFrame();
+
+		if (this == _vm->_animation->_animStart) {
+			_frameNumber = 0;
+			calcFrame();
+		}
+
+		setFrame();
+	}
+}
+
+void Animation::anim3() {
+	if (_currentLoopCount != -1) {
+		if (_countdownTicks != 0) {
+			calcFrame();
+			setFrame1();
+		} else {
+			_countdownTicks = _initialTicks;
+			++_frameNumber;
+			calcFrame();
+
+			if (this == _vm->_animation->_animStart) {
+				--_currentLoopCount;
+				_frameNumber = 0;
+				calcFrame();
+			}
+
+			setFrame();
+		}
+	}
+}
+
+void Animation::anim4() {
+	if (_currentLoopCount == -1 || _countdownTicks != 0) {
+		calcFrame();
+		setFrame1();
+	} else {
+		_countdownTicks = _initialTicks;
+		++_frameNumber;
+		calcFrame();
+
+		if (this == _vm->_animation->_animStart) {
+			if (--_currentLoopCount == -1) {
+				calcFrame();
+				setFrame1();
+				return;
+			} else {
+				_frameNumber = 0;
+				calcFrame();
+			}
+		}
+
+		setFrame();
+	}
+}
+
+void Animation::animNone() {
+	// No implementation
+}
+
+void Animation::anim7() {
+	calcFrame1();
+	setFrame();
+}
+
+void Animation::calcFrame() {
+	error("TODO");
+}
+
+void Animation::calcFrame1() {
+	error("TODO");
+}
+
+void Animation::setFrame() {
 	error("TODO");
 }
 
+void Animation::setFrame1() {
+	error("TODO");
+}
+
+
 /*------------------------------------------------------------------------*/
 
 AnimationFrame::AnimationFrame(Common::MemoryReadStream &stream, int startOffset) {
@@ -150,7 +285,7 @@ void AnimationManager::clearTimers() {
 void AnimationManager::loadAnimations(const byte *data, int size) {
 	_animationTimers.clear();
 	delete _animation;
-	_animation = new AnimationResource(data,  size);
+	_animation = new AnimationResource(_vm, data,  size);
 }
 
 
diff --git a/engines/access/animation.h b/engines/access/animation.h
index 45a59ef..38065bb 100644
--- a/engines/access/animation.h
+++ b/engines/access/animation.h
@@ -36,9 +36,10 @@ class AnimationFrame;
 class AnimationFramePart;
 
 class AnimationManager : public Manager {
-public:
+private:
 	Common::Array<Animation *> _animationTimers;
 	AnimationResource *_animation;
+public:
 	Animation *_animStart;
 public:
 	AnimationManager(AccessEngine *vm);
@@ -60,16 +61,29 @@ class AnimationResource {
 private:
 	Common::Array<Animation *> _animations;
 public:
-	AnimationResource(const byte *data, int size);
+	AnimationResource(AccessEngine *vm, const byte *data, int size);
 	~AnimationResource();
 
 	int getCount() { return _animations.size(); }
 	Animation *getAnimation(int idx) { return _animations[idx]; }
 };
 
-class Animation {
+class Animation: public Manager {
 private:
 	Common::Array<AnimationFrame *> _frames;
+
+	void anim0();
+	void anim1();
+	void anim2();
+	void anim3();
+	void anim4();
+	void animNone();
+	void anim7();
+
+	void calcFrame();
+	void calcFrame1();
+	void setFrame();
+	void setFrame1();
 public:
 	int _type;
 	int _scaling;
@@ -80,7 +94,7 @@ public:
 	int _currentLoopCount;
 	int _field10;
 public:
-	Animation(Common::MemoryReadStream &stream);
+	Animation(AccessEngine *vm, Common::MemoryReadStream &stream);
 	~Animation();
 
 	void animate();
diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp
index fd42530..8018f50 100644
--- a/engines/access/scripts.cpp
+++ b/engines/access/scripts.cpp
@@ -171,7 +171,7 @@ void Scripts::cmdRetPos() {
 }
 
 void Scripts::cmdAnim() { 
-	int animId = _data->readUint16LE();
+	int animId = _data->readByte();
 	_vm->_animation->animate(animId);
 }
 


Commit: 5344143027b87fa38203dbdd97f2f6fd68a566b2
    https://github.com/scummvm/scummvm/commit/5344143027b87fa38203dbdd97f2f6fd68a566b2
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-08-11T23:03:49+02:00

Commit Message:
ACCESS: Implement cmdCheckFrame

Changed paths:
    engines/access/scripts.cpp
    engines/access/scripts.h



diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp
index 8018f50..aa1bfcd 100644
--- a/engines/access/scripts.cpp
+++ b/engines/access/scripts.cpp
@@ -89,7 +89,7 @@ void Scripts::executeCommand(int commandIndex) {
 		&Scripts::cmdSetFlag, &Scripts::cmdCheckFlag, &Scripts::cmdGoto, 
 		&Scripts::cmdSetInventory, &Scripts::cmdSetInventory, &Scripts::cmdCheckInventory, 
 		&Scripts::CMDSETTEX, &Scripts::CMDNEWROOM, &Scripts::CMDCONVERSE, 
-		&Scripts::CMDCHECKFRAME, &Scripts::cmdCheckAnim, &Scripts::CMDSND, 
+		&Scripts::cmdCheckFrame, &Scripts::cmdCheckAnim, &Scripts::CMDSND, 
 		&Scripts::cmdRetNeg, &Scripts::cmdRetPos, &Scripts::cmdCheckLoc, 
 		&Scripts::cmdSetAnim, &Scripts::CMDDISPINV, &Scripts::CMDSETTIMER, 
 		&Scripts::CMDSETTIMER, &Scripts::CMDCHECKTIMER, &Scripts::cmdSetTravel,
@@ -222,7 +222,17 @@ void Scripts::cmdCheckInventory() {
 void Scripts::CMDSETTEX() { error("TODO"); }
 void Scripts::CMDNEWROOM() { error("TODO"); }
 void Scripts::CMDCONVERSE() { error("TODO"); }
-void Scripts::CMDCHECKFRAME() { error("TODO"); }
+
+void Scripts::cmdCheckFrame() {
+	int id = _data->readUint16LE();
+	Animation *anim = _vm->_animation->findAnimation(id);
+
+	int frame = _data->readUint16LE();
+	if (anim->_frameNumber == frame)
+		cmdGoto();
+	else
+		_data->skip(2);
+}
 
 void Scripts::cmdCheckAnim() {
 	int id = _data->readUint16LE();
diff --git a/engines/access/scripts.h b/engines/access/scripts.h
index c8f951d..3832f0d 100644
--- a/engines/access/scripts.h
+++ b/engines/access/scripts.h
@@ -66,7 +66,7 @@ protected:
 	void CMDSETTEX();
 	void CMDNEWROOM();
 	void CMDCONVERSE();
-	void CMDCHECKFRAME();
+	void cmdCheckFrame();
 	void cmdCheckAnim();
 	void CMDSND();
 	void cmdRetNeg();


Commit: 69c7f989b12de26ada8d399233e95777421ee65b
    https://github.com/scummvm/scummvm/commit/69c7f989b12de26ada8d399233e95777421ee65b
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-08-11T23:05:48+02:00

Commit Message:
ACCESS: Fix the implementation of cmdCheckAnim

Changed paths:
    engines/access/scripts.cpp



diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp
index aa1bfcd..e7827fb 100644
--- a/engines/access/scripts.cpp
+++ b/engines/access/scripts.cpp
@@ -238,11 +238,10 @@ void Scripts::cmdCheckAnim() {
 	int id = _data->readUint16LE();
 	Animation *anim = _vm->_animation->findAnimation(id);
 
-	if (anim->_currentLoopCount == -1) {
-		_data->skip(2);
+	if (anim->_currentLoopCount == -1)
 		cmdGoto();
-	} else
-		_data->skip(4);
+	else
+		_data->skip(2);
 }
 
 void Scripts::CMDSND() { error("TODO"); }


Commit: 5c7699799d4d35ac863470b0ad52817de170f4f9
    https://github.com/scummvm/scummvm/commit/5c7699799d4d35ac863470b0ad52817de170f4f9
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-08-11T23:43:27+02:00

Commit Message:
ACCESS: Implement 3 more opcodes, fix a typo

Changed paths:
    engines/access/scripts.cpp
    engines/access/scripts.h



diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp
index e7827fb..bb45cd4 100644
--- a/engines/access/scripts.cpp
+++ b/engines/access/scripts.cpp
@@ -34,6 +34,8 @@ Scripts::Scripts(AccessEngine *vm) : _vm(vm) {
 	_sequence = 0;
 	_endFlag = false;
 	_returnCode = 0;
+	_choice = 0;
+	_choiceStart = 0;
 }
 
 Scripts::~Scripts() {
@@ -94,14 +96,14 @@ void Scripts::executeCommand(int commandIndex) {
 		&Scripts::cmdSetAnim, &Scripts::CMDDISPINV, &Scripts::CMDSETTIMER, 
 		&Scripts::CMDSETTIMER, &Scripts::CMDCHECKTIMER, &Scripts::cmdSetTravel,
 		&Scripts::cmdSetTravel, &Scripts::CMDSETVID, &Scripts::CMDPLAYVID, 
-		&Scripts::cmdPlotImage, &Scripts::cmdSetDisplay, &Scripts::CMDSETBUFFER, 
+		&Scripts::cmdPlotImage, &Scripts::cmdSetDisplay, &Scripts::cmdSetBuffer, 
 		&Scripts::cmdSetScroll, &Scripts::CMDSAVERECT, &Scripts::CMDSAVERECT, 
-		&Scripts::CMDSETBUFVID, &Scripts::CMDPLAYBUFVID, &Scripts::cmeRemoveLast, 
+		&Scripts::CMDSETBUFVID, &Scripts::CMDPLAYBUFVID, &Scripts::cmdRemoveLast, 
 		&Scripts::CMDSPECIAL, &Scripts::CMDSPECIAL, &Scripts::CMDSPECIAL,
 		&Scripts::CMDSETCYCLE, &Scripts::CMDCYCLE, &Scripts::CMDCHARSPEAK, 
 		&Scripts::CMDTEXSPEAK, &Scripts::CMDTEXCHOICE, &Scripts::CMDWAIT, 
-		&Scripts::CMDSETCONPOS, &Scripts::CMDCHECKVFRAME, &Scripts::CMDJUMPCHOICE, 
-		&Scripts::CMDRETURNCHOICE, &Scripts::CMDCLEARBLOCK, &Scripts::CMDLOADSOUND, 
+		&Scripts::CMDSETCONPOS, &Scripts::CMDCHECKVFRAME, &Scripts::cmdJumpChoice, 
+		&Scripts::cmdReturnChoice, &Scripts::CMDCLEARBLOCK, &Scripts::CMDLOADSOUND, 
 		&Scripts::CMDFREESOUND, &Scripts::CMDSETVIDSND, &Scripts::CMDPLAYVIDSND,
 		&Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, 
 		&Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, &Scripts::cmdPlayerOff, 
@@ -302,7 +304,9 @@ void Scripts::cmdSetDisplay() {
 	_vm->_current = _vm->_screen;
 }
 
-void Scripts::CMDSETBUFFER() { error("TODO"); }
+void Scripts::cmdSetBuffer() {
+	_vm->_current = &_vm->_buffer2;
+}
 
 void Scripts::cmdSetScroll() {
 	_vm->_screen->_scrollCol = _data->readUint16LE();
@@ -315,7 +319,7 @@ void Scripts::CMDSAVERECT() { error("TODO"); }
 void Scripts::CMDSETBUFVID() { error("TODO"); }
 void Scripts::CMDPLAYBUFVID() { error("TODO"); }
 
-void Scripts::cmeRemoveLast() {
+void Scripts::cmdRemoveLast() {
 	--_vm->_numAnimTimers;
 }
 
@@ -324,12 +328,25 @@ void Scripts::CMDSETCYCLE() { error("TODO"); }
 void Scripts::CMDCYCLE() { error("TODO"); }
 void Scripts::CMDCHARSPEAK() { error("TODO"); }
 void Scripts::CMDTEXSPEAK() { error("TODO"); }
-void Scripts::CMDTEXCHOICE() { error("TODO"); }
+void Scripts::CMDTEXCHOICE() { error("TODO"); } // _choiceStart = _data->pos() - 1;
 void Scripts::CMDWAIT() { error("TODO"); }
 void Scripts::CMDSETCONPOS() { error("TODO"); }
 void Scripts::CMDCHECKVFRAME() { error("TODO"); }
-void Scripts::CMDJUMPCHOICE() { error("TODO"); }
-void Scripts::CMDRETURNCHOICE() { error("TODO"); }
+
+void Scripts::cmdJumpChoice() {
+	int val = (_data->readUint16LE() && 0xFF);
+	
+	if (val == _choice) {
+		_sequence = _data->readUint16LE();
+		searchForSequence();
+	} else
+		_data->skip(2);
+}
+
+void Scripts::cmdReturnChoice() {
+	_data->seek(_choiceStart);
+}
+
 void Scripts::CMDCLEARBLOCK() { error("TODO"); }
 void Scripts::CMDLOADSOUND() { error("TODO"); }
 void Scripts::CMDFREESOUND() { error("TODO"); }
diff --git a/engines/access/scripts.h b/engines/access/scripts.h
index 3832f0d..25f4dc1 100644
--- a/engines/access/scripts.h
+++ b/engines/access/scripts.h
@@ -80,12 +80,12 @@ protected:
 	void CMDPLAYVID();
 	void cmdPlotImage();
 	void cmdSetDisplay();
-	void CMDSETBUFFER();
+	void cmdSetBuffer();
 	void cmdSetScroll();
 	void CMDSAVERECT();
 	void CMDSETBUFVID();
 	void CMDPLAYBUFVID();
-	void cmeRemoveLast();
+	void cmdRemoveLast();
 	void CMDSPECIAL();
 	void CMDSETCYCLE();
 	void CMDCYCLE();
@@ -95,8 +95,8 @@ protected:
 	void CMDWAIT();
 	void CMDSETCONPOS();
 	void CMDCHECKVFRAME();
-	void CMDJUMPCHOICE();
-	void CMDRETURNCHOICE();
+	void cmdJumpChoice();
+	void cmdReturnChoice();
 	void CMDCLEARBLOCK();
 	void CMDLOADSOUND();
 	void CMDFREESOUND();
@@ -120,6 +120,8 @@ public:
 	bool _endFlag;
 	int _returnCode;
 	int _scriptCommand;
+	int _choice;
+	int32 _choiceStart;
 public:
 	Scripts(AccessEngine *vm);
 


Commit: 617aa98ede4167fe2f9a7a419738d0030d8c48ff
    https://github.com/scummvm/scummvm/commit/617aa98ede4167fe2f9a7a419738d0030d8c48ff
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-08-11T23:57:06+02:00

Commit Message:
ACCESS: Implement cmdSnd()

Changed paths:
    engines/access/scripts.cpp
    engines/access/scripts.h



diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp
index bb45cd4..1963354 100644
--- a/engines/access/scripts.cpp
+++ b/engines/access/scripts.cpp
@@ -91,7 +91,7 @@ void Scripts::executeCommand(int commandIndex) {
 		&Scripts::cmdSetFlag, &Scripts::cmdCheckFlag, &Scripts::cmdGoto, 
 		&Scripts::cmdSetInventory, &Scripts::cmdSetInventory, &Scripts::cmdCheckInventory, 
 		&Scripts::CMDSETTEX, &Scripts::CMDNEWROOM, &Scripts::CMDCONVERSE, 
-		&Scripts::cmdCheckFrame, &Scripts::cmdCheckAnim, &Scripts::CMDSND, 
+		&Scripts::cmdCheckFrame, &Scripts::cmdCheckAnim, &Scripts::cmdSnd, 
 		&Scripts::cmdRetNeg, &Scripts::cmdRetPos, &Scripts::cmdCheckLoc, 
 		&Scripts::cmdSetAnim, &Scripts::CMDDISPINV, &Scripts::CMDSETTIMER, 
 		&Scripts::CMDSETTIMER, &Scripts::CMDCHECKTIMER, &Scripts::cmdSetTravel,
@@ -246,7 +246,10 @@ void Scripts::cmdCheckAnim() {
 		_data->skip(2);
 }
 
-void Scripts::CMDSND() { error("TODO"); }
+void Scripts::cmdSnd() {
+	int id = _data->readByte();
+	_vm->_sound->playSound(id);
+}
 
 void Scripts::cmdRetNeg() {
 	_endFlag = true;
diff --git a/engines/access/scripts.h b/engines/access/scripts.h
index 25f4dc1..495c4c5 100644
--- a/engines/access/scripts.h
+++ b/engines/access/scripts.h
@@ -68,7 +68,7 @@ protected:
 	void CMDCONVERSE();
 	void cmdCheckFrame();
 	void cmdCheckAnim();
-	void CMDSND();
+	void cmdSnd();
 	void cmdRetNeg();
 	void cmdCheckLoc();
 	void cmdSetAnim();


Commit: 768e144683847734cc16c9a7ec786379be6301e2
    https://github.com/scummvm/scummvm/commit/768e144683847734cc16c9a7ec786379be6301e2
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-11T20:27:19-04:00

Commit Message:
ACCESS: Properly implement Animation calcFrame/calcFrame1 methods

Changed paths:
    engines/access/animation.cpp
    engines/access/animation.h



diff --git a/engines/access/animation.cpp b/engines/access/animation.cpp
index 705fd7b..6c9f300 100644
--- a/engines/access/animation.cpp
+++ b/engines/access/animation.cpp
@@ -97,101 +97,95 @@ void Animation::animate() {
 void Animation::anim0() {
 	if (_currentLoopCount != -1) {
 		if (_countdownTicks != 0) {
-			calcFrame();
-			setFrame1();
+			setFrame1(calcFrame());
 		} else {
 			_countdownTicks = _initialTicks;
 			++_frameNumber;
-			calcFrame();
+			AnimationFrame *frame = calcFrame();
 
-			if (this == _vm->_animation->_animStart) {
+			if (frame == nullptr) {
 				_frameNumber = 0;
 				_currentLoopCount = -1;
 			}
 
-			setFrame();
+			setFrame(frame);
 		}
 	}
 }
 
 void Animation::anim1() {
 	if (_currentLoopCount == -1 || _countdownTicks != 0) {
-		calcFrame();
-		setFrame1();
+		setFrame1(calcFrame());
 	} else {
 		_countdownTicks = _initialTicks;
 		++_frameNumber;
-		calcFrame();
+		AnimationFrame *frame = calcFrame();
 
-		if (this == _vm->_animation->_animStart) {
+		if (frame == nullptr) {
 			--_frameNumber;
 			_currentLoopCount = -1;
 		}
 
-		setFrame();
+		setFrame(frame);
 	}
 }
 
 void Animation::anim2() {
 	if (_countdownTicks != 0) {
-		calcFrame();
-		setFrame1();
+		setFrame1(calcFrame());
 	} else {
 		_countdownTicks = _initialTicks;
 		++_frameNumber;
-		calcFrame();
+		AnimationFrame *frame = calcFrame();
 
-		if (this == _vm->_animation->_animStart) {
+		if (frame == nullptr) {
 			_frameNumber = 0;
-			calcFrame();
+			frame = calcFrame();
 		}
 
-		setFrame();
+		setFrame(frame);
 	}
 }
 
 void Animation::anim3() {
 	if (_currentLoopCount != -1) {
 		if (_countdownTicks != 0) {
-			calcFrame();
-			setFrame1();
+			setFrame1(calcFrame());
 		} else {
 			_countdownTicks = _initialTicks;
 			++_frameNumber;
-			calcFrame();
+			AnimationFrame *frame = calcFrame();
 
-			if (this == _vm->_animation->_animStart) {
+			if (frame == nullptr) {
 				--_currentLoopCount;
 				_frameNumber = 0;
-				calcFrame();
+				frame = calcFrame();
 			}
 
-			setFrame();
+			setFrame(frame);
 		}
 	}
 }
 
 void Animation::anim4() {
 	if (_currentLoopCount == -1 || _countdownTicks != 0) {
-		calcFrame();
-		setFrame1();
+		setFrame1(calcFrame());
 	} else {
 		_countdownTicks = _initialTicks;
 		++_frameNumber;
-		calcFrame();
+		AnimationFrame *frame = calcFrame();
 
-		if (this == _vm->_animation->_animStart) {
+		if (frame == nullptr) {
 			if (--_currentLoopCount == -1) {
-				calcFrame();
-				setFrame1();
+				setFrame1(calcFrame());
 				return;
 			} else {
 				_frameNumber = 0;
-				calcFrame();
+				frame = calcFrame();
 			}
 		}
 
-		setFrame();
+		setFrame(frame);
 	}
 }
 
@@ -200,23 +194,22 @@ void Animation::animNone() {
 }
 
 void Animation::anim7() {
-	calcFrame1();
-	setFrame();
+	setFrame(calcFrame1());
 }
 
-void Animation::calcFrame() {
-	error("TODO");
+AnimationFrame *Animation::calcFrame() {
+	return _frames[_frameNumber];
 }
 
-void Animation::calcFrame1() {
-	error("TODO");
+AnimationFrame *Animation::calcFrame1() {
+	return _frames[0];
 }
 
-void Animation::setFrame() {
+void Animation::setFrame(AnimationFrame *frame) {
 	error("TODO");
 }
 
-void Animation::setFrame1() {
+void Animation::setFrame1(AnimationFrame *frame) {
 	error("TODO");
 }
 
diff --git a/engines/access/animation.h b/engines/access/animation.h
index 38065bb..d9b1008 100644
--- a/engines/access/animation.h
+++ b/engines/access/animation.h
@@ -80,10 +80,10 @@ private:
 	void animNone();
 	void anim7();
 
-	void calcFrame();
-	void calcFrame1();
-	void setFrame();
-	void setFrame1();
+	AnimationFrame *calcFrame();
+	AnimationFrame *calcFrame1();
+	void setFrame(AnimationFrame *frame);
+	void setFrame1(AnimationFrame *frame);
 public:
 	int _type;
 	int _scaling;


Commit: 7d4180c3e2b70ab3efa8d82f071e427a71adb1f0
    https://github.com/scummvm/scummvm/commit/7d4180c3e2b70ab3efa8d82f071e427a71adb1f0
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-11T21:34:39-04:00

Commit Message:
ACCESS: Implemented Animation setFrame code

Changed paths:
    engines/access/access.h
    engines/access/animation.cpp
    engines/access/animation.h



diff --git a/engines/access/access.h b/engines/access/access.h
index 26ae88e..f84a7bd 100644
--- a/engines/access/access.h
+++ b/engines/access/access.h
@@ -70,6 +70,15 @@ enum AccessDebugChannels {
 
 struct AccessGameDescription;
 
+class ImageEntry {
+public:
+	int _field0;
+	SpriteResource *_spritesPtr;
+	int _priority;
+	Common::Point _position;
+	int _flags;
+};
+
 class AccessEngine : public Engine {
 private:
 	/**
@@ -128,6 +137,7 @@ public:
 	Common::Array<Common::Rect> _newRect;
 	Common::Array<Common::Rect> _oldRect;
 	Common::Array<ExtraCell> _extraCells;
+	Common::Array<ImageEntry> _images;
 	int _pCount;
 	int _selectCommand;
 	bool _normalMouse;
diff --git a/engines/access/animation.cpp b/engines/access/animation.cpp
index 6c9f300..a17c30f 100644
--- a/engines/access/animation.cpp
+++ b/engines/access/animation.cpp
@@ -55,15 +55,15 @@ Animation::Animation(AccessEngine *vm, Common::MemoryReadStream &stream):
 	uint32 startOfs = stream.pos();
 
 	_type = stream.readByte();
-	_scaling = stream.readByte();
+	_scaling = stream.readSByte();
 	stream.readByte(); // unk
 	_frameNumber = stream.readByte();
 	_initialTicks = stream.readUint16LE();
 	stream.readUint16LE(); // unk
 	stream.readUint16LE(); // unk
-	_loopCount = stream.readUint16LE();
+	_loopCount = stream.readSint16LE();
 	_countdownTicks = stream.readUint16LE();
-	_currentLoopCount = stream.readUint16LE();
+	_currentLoopCount = stream.readSint16LE();
 	stream.readUint16LE(); // unk
 
 	Common::Array<uint16> frameOffsets;
@@ -206,13 +206,39 @@ AnimationFrame *Animation::calcFrame1() {
 }
 
 void Animation::setFrame(AnimationFrame *frame) {
-	error("TODO");
+	_countdownTicks += frame->_frameDelay;
+	setFrame1(frame);
 }
 
-void Animation::setFrame1(AnimationFrame *frame) {
-	error("TODO");
+static bool sortImagesY(const ImageEntry &ie1, const ImageEntry &ie2) {
+	return ie1._priority < ie2._priority;
 }
 
+void Animation::setFrame1(AnimationFrame *frame) {
+	_vm->_animation->_base.x = frame->_baseX;
+	_vm->_animation->_base.y = frame->_baseY;
+
+	// Loop to add image draw requests for the parts of the frame
+	for (uint i = 0; i < frame->_parts.size(); ++i) {
+		AnimationFramePart *part = frame->_parts[i];
+		ImageEntry ie;
+
+		// Set the flags
+		ie._flags = part->_flags & 0xF7;
+		if (_vm->_animation->_frameScale == -1)
+			ie._flags |= 8;
+
+		// Set the other fields
+		ie._spritesPtr = _vm->_objectsTable[part->_spritesIndex];
+		ie._field0 = part->_frameIndex;
+		ie._position = part->_position + _vm->_animation->_base;
+		ie._priority = part->_priority - ie._position.y;
+
+		assert(_vm->_images.size() < 35);
+		_vm->_images.push_back(ie);
+		Common::sort(_vm->_images.begin(), _vm->_images.end(), sortImagesY);
+	}
+}
 
 /*------------------------------------------------------------------------*/
 
@@ -244,8 +270,8 @@ AnimationFrame::~AnimationFrame() {
 
 AnimationFramePart::AnimationFramePart(Common::MemoryReadStream &stream) {
 	_flags = stream.readByte();
-	_slotIndex = stream.readByte();
-	_spriteIndex = stream.readByte();
+	_spritesIndex = stream.readByte();
+	_frameIndex = stream.readByte();
 	_position.x = stream.readUint16LE();
 	_position.y = stream.readUint16LE();
 	_priority = stream.readUint16LE();
@@ -256,6 +282,7 @@ AnimationFramePart::AnimationFramePart(Common::MemoryReadStream &stream) {
 AnimationManager::AnimationManager(AccessEngine *vm) : Manager(vm) {
 	_animation = nullptr;
 	_animStart = nullptr;
+	_frameScale = 0;
 }
 
 AnimationManager::~AnimationManager() {
@@ -306,6 +333,7 @@ Animation *AnimationManager::findAnimation(int animId) {
 
 void AnimationManager::animate(int animId) {
 	Animation *anim = findAnimation(animId);
+	_frameScale = anim->_scaling;
 	anim->animate();
 }
 
diff --git a/engines/access/animation.h b/engines/access/animation.h
index d9b1008..c1b44a5 100644
--- a/engines/access/animation.h
+++ b/engines/access/animation.h
@@ -41,6 +41,8 @@ private:
 	AnimationResource *_animation;
 public:
 	Animation *_animStart;
+	Common::Point _base;
+	int _frameScale;
 public:
 	AnimationManager(AccessEngine *vm);
 	~AnimationManager();
@@ -113,8 +115,8 @@ public:
 class AnimationFramePart {
 public:
 	byte _flags;
-	int _slotIndex;
-	int _spriteIndex;
+	int _spritesIndex;
+	int _frameIndex;
 	Common::Point _position;
 	int _priority;
 public:


Commit: eee84b8760dd38079fe97f263a6fa9361ad5696f
    https://github.com/scummvm/scummvm/commit/eee84b8760dd38079fe97f263a6fa9361ad5696f
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-11T23:12:53-04:00

Commit Message:
ACCESS: Implemented plotList

Changed paths:
    engines/access/access.cpp
    engines/access/access.h
    engines/access/animation.cpp
    engines/access/asurface.cpp
    engines/access/asurface.h
    engines/access/player.cpp
    engines/access/player.h
    engines/access/room.cpp
    engines/access/screen.cpp
    engines/access/screen.h



diff --git a/engines/access/access.cpp b/engines/access/access.cpp
index a21a97c..9fb0287 100644
--- a/engines/access/access.cpp
+++ b/engines/access/access.cpp
@@ -73,6 +73,7 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc)
 	_scaleT1 = 0;
 	_scaleMaxY = 0;
 	_scaleI = 0;
+	_scaleFlag = false;
 
 	_conversation = 0;
 	_currentMan = 0;
@@ -247,4 +248,54 @@ void AccessEngine::doEstablish(int v) {
 	warning("TODO: doEstablish");
 }
 
+void AccessEngine::plotList() {
+	_player->calcPlayer();
+	plotList1();
+}
+
+void AccessEngine::plotList1() {
+	for (uint idx = 0; idx < _images.size(); ++idx) {
+		ImageEntry &ie = _images[idx];
+
+		_scaleFlag = (ie._flags & 8) != 0;
+		Common::Point pt = ie._position - _screen->_bufferStart;
+		SpriteResource *sprites = ie._spritesPtr;
+		SpriteFrame *frame = sprites->getFrame(ie._frameNumber);
+
+		Common::Rect bounds(pt.x, pt.y, pt.x + frame->w, pt.y + frame->h);
+		if (!_scaleFlag) {
+			bounds.setWidth(_screen->_scaleTable1[frame->w]);
+			bounds.setHeight(_screen->_scaleTable1[frame->h]);
+		}
+
+		if (_buffer2.clip(bounds)) {
+			ie._flags |= 1;
+		} else {
+			ie._flags &= ~1;
+			if (_buffer2._leftSkip != 0 ||  _buffer2._rightSkip != 0
+				|| _buffer2._topSkip != 0 || _buffer2._bottomSkip != 0)
+				ie._flags |= 1;
+
+			_newRect.push_back(bounds);
+
+			if (!_scaleFlag) {
+				_buffer2._rightSkip /= _scale;
+				bounds.setWidth(bounds.width() / _scale);
+
+				if (ie._flags & 2) {
+					_buffer2.sPlotB(frame, Common::Point(bounds.left, bounds.top));
+				} else {
+					_buffer2.sPlotF(frame, Common::Point(bounds.left, bounds.top));
+				}
+			} else {
+				if (ie._flags & 2) {
+					_buffer2.plotB(frame, Common::Point(bounds.left, bounds.top));
+				} else {
+					_buffer2.plotFrame(frame, Common::Point(bounds.left, bounds.top));
+				}
+			}
+		}
+	}
+}
+
 } // End of namespace Access
diff --git a/engines/access/access.h b/engines/access/access.h
index f84a7bd..819f7fa 100644
--- a/engines/access/access.h
+++ b/engines/access/access.h
@@ -72,7 +72,7 @@ struct AccessGameDescription;
 
 class ImageEntry {
 public:
-	int _field0;
+	int _frameNumber;
 	SpriteResource *_spritesPtr;
 	int _priority;
 	Common::Point _position;
@@ -166,6 +166,7 @@ public:
 	int _scaleT1;
 	int _scaleMaxY;
 	int _scaleI;
+	bool _scaleFlag;
 	int _playFieldHeight;
 
 	// Fields that are included in savegames
@@ -236,6 +237,9 @@ public:
 	void establish(int v);
 
 	void establishCenter(int v);
+
+	void plotList();
+	void plotList1();
 };
 
 } // End of namespace Access
diff --git a/engines/access/animation.cpp b/engines/access/animation.cpp
index a17c30f..20772af 100644
--- a/engines/access/animation.cpp
+++ b/engines/access/animation.cpp
@@ -230,7 +230,7 @@ void Animation::setFrame1(AnimationFrame *frame) {
 
 		// Set the other fields
 		ie._spritesPtr = _vm->_objectsTable[part->_spritesIndex];
-		ie._field0 = part->_frameIndex;
+		ie._frameNumber = part->_frameIndex;
 		ie._position = part->_position + _vm->_animation->_base;
 		ie._priority = part->_priority - ie._position.y;
 
diff --git a/engines/access/asurface.cpp b/engines/access/asurface.cpp
index 3a381a1..fe11612 100644
--- a/engines/access/asurface.cpp
+++ b/engines/access/asurface.cpp
@@ -219,5 +219,16 @@ void ASurface::copyTo(ASurface *dest, const Common::Point &destPos) {
 	}
 }
 
+void ASurface::sPlotB(SpriteFrame *frame, const Common::Point &pt) {
+	error("TODO");
+}
+
+void ASurface::sPlotF(SpriteFrame *frame, const Common::Point &pt) {
+	error("TODO");
+}
+
+void ASurface::plotB(SpriteFrame *frame, const Common::Point &pt) {
+	error("TODO");
+}
 
 } // End of namespace Access
diff --git a/engines/access/asurface.h b/engines/access/asurface.h
index c4dfc54..99f99ae 100644
--- a/engines/access/asurface.h
+++ b/engines/access/asurface.h
@@ -45,7 +45,7 @@ public:
 	static int _scrollX, _scrollY;
 
 	static void init();
-protected:
+public:
 	virtual void ASurface::plotFrame(SpriteFrame *frame, const Common::Point &pt);
 public:
 	void clearBuffer();
@@ -56,6 +56,12 @@ public:
 
 	void plotImage(SpriteResource *sprite, int frameNum, const Common::Point &pt);
 
+	void sPlotB(SpriteFrame *frame, const Common::Point &pt);
+
+	void sPlotF(SpriteFrame *frame, const Common::Point &pt);
+
+	void plotB(SpriteFrame *frame, const Common::Point &pt);
+
 	void copyTo(ASurface *dest, const Common::Point &destPos);
 };
 
diff --git a/engines/access/player.cpp b/engines/access/player.cpp
index b28e6c9..794fc08 100644
--- a/engines/access/player.cpp
+++ b/engines/access/player.cpp
@@ -151,4 +151,12 @@ void Player::walk() {
 	warning("TODO: Player::walk");
 }
 
+void Player::calcPlayer() {
+	Screen &scr = *_vm->_screen;
+	scr._bufferStart.x = (scr._scrollCol << 4) + scr._scrollX;
+	scr._bufferStart.y = (scr._scrollRow << 4) + scr._scrollY;
+	_playerX = _rawPlayer.x - scr._bufferStart.x;
+	_playerY = _rawPlayer.y - scr._bufferStart.y;
+}
+
 } // End of namespace Access
diff --git a/engines/access/player.h b/engines/access/player.h
index 7625fa2..b491ed7 100644
--- a/engines/access/player.h
+++ b/engines/access/player.h
@@ -82,6 +82,8 @@ public:
 	void calcManScale();
 
 	void walk();
+
+	void calcPlayer();
 };
 
 } // End of namespace Access
diff --git a/engines/access/room.cpp b/engines/access/room.cpp
index 98e9d5e..b39e998 100644
--- a/engines/access/room.cpp
+++ b/engines/access/room.cpp
@@ -117,7 +117,7 @@ void Room::doRoom() {
 					clearRoom();
 					break;
 				} else {
-					_vm->_screen->plotList();
+					_vm->plotList();
 					_vm->_screen->copyRects();
 
 					_vm->_screen->copyBF2Vid();
@@ -132,7 +132,7 @@ void Room::doRoom() {
 					clearRoom();
 					break;
 				} else {
-					_vm->_screen->plotList();
+					_vm->plotList();
 					_vm->_screen->copyBlocks();
 				}
 			}
diff --git a/engines/access/screen.cpp b/engines/access/screen.cpp
index bc913c5..2dc8698 100644
--- a/engines/access/screen.cpp
+++ b/engines/access/screen.cpp
@@ -162,10 +162,6 @@ void Screen::copyBF2Vid() {
 	warning("TODO");
 }
 
-void Screen::plotList() {
-	warning("TODO: plotList");
-}
-
 void Screen::copyBlocks() {
 	warning("TODO: copyBlocks");
 }
diff --git a/engines/access/screen.h b/engines/access/screen.h
index 45db7d0..6c1d96e 100644
--- a/engines/access/screen.h
+++ b/engines/access/screen.h
@@ -123,8 +123,6 @@ public:
 
 	void copyBF2Vid();
 
-	void plotList();
-
 	void copyBlocks();
 
 	void copyRects();


Commit: c0cb03cea276832b2d178155786c0418eccfd21d
    https://github.com/scummvm/scummvm/commit/c0cb03cea276832b2d178155786c0418eccfd21d
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-12T08:38:12-04:00

Commit Message:
ACCESS: Implemented copyBlocks

Changed paths:
    engines/access/access.cpp
    engines/access/access.h
    engines/access/amazon/amazon_room.cpp
    engines/access/asurface.cpp
    engines/access/asurface.h
    engines/access/room.cpp
    engines/access/screen.cpp
    engines/access/screen.h



diff --git a/engines/access/access.cpp b/engines/access/access.cpp
index 9fb0287..29e5188 100644
--- a/engines/access/access.cpp
+++ b/engines/access/access.cpp
@@ -276,7 +276,7 @@ void AccessEngine::plotList1() {
 				|| _buffer2._topSkip != 0 || _buffer2._bottomSkip != 0)
 				ie._flags |= 1;
 
-			_newRect.push_back(bounds);
+			_newRects.push_back(bounds);
 
 			if (!_scaleFlag) {
 				_buffer2._rightSkip /= _scale;
@@ -298,4 +298,18 @@ void AccessEngine::plotList1() {
 	}
 }
 
+void AccessEngine::copyBlocks() {
+	// Copy the block list from the previous frame
+	for (uint i = 0; i < _oldRects.size(); ++i) {
+		_screen->copyBlock(&_buffer2, _oldRects[i]);
+	}
+
+	// Copy the new block list, replacing the old one at the same time
+	_oldRects.clear();
+	for (uint i = 0; i < _newRects.size(); ++i) {
+		_screen->copyBlock(&_buffer2, _newRects[i]);
+		_oldRects.push_back(_newRects[i]);
+	}
+}
+
 } // End of namespace Access
diff --git a/engines/access/access.h b/engines/access/access.h
index 819f7fa..3cd98f0 100644
--- a/engines/access/access.h
+++ b/engines/access/access.h
@@ -134,8 +134,8 @@ public:
 	int _establishGroup;
 	int _numAnimTimers;
 	Common::Array<TimerEntry> _timers;
-	Common::Array<Common::Rect> _newRect;
-	Common::Array<Common::Rect> _oldRect;
+	Common::Array<Common::Rect> _newRects;
+	Common::Array<Common::Rect> _oldRects;
 	Common::Array<ExtraCell> _extraCells;
 	Common::Array<ImageEntry> _images;
 	int _pCount;
@@ -240,6 +240,8 @@ public:
 
 	void plotList();
 	void plotList1();
+
+	void copyBlocks();
 };
 
 } // End of namespace Access
diff --git a/engines/access/amazon/amazon_room.cpp b/engines/access/amazon/amazon_room.cpp
index 5b840af..b8ed0d2 100644
--- a/engines/access/amazon/amazon_room.cpp
+++ b/engines/access/amazon/amazon_room.cpp
@@ -110,8 +110,8 @@ void AmazonRoom::reloadRoom1() {
 	}
 
 	_vm->_player->_frame = 0;
-	_vm->_oldRect.clear();
-	_vm->_newRect.clear();
+	_vm->_oldRects.clear();
+	_vm->_newRects.clear();
 }
 
 void AmazonRoom::roomSet() {
diff --git a/engines/access/asurface.cpp b/engines/access/asurface.cpp
index fe11612..5a090af 100644
--- a/engines/access/asurface.cpp
+++ b/engines/access/asurface.cpp
@@ -231,4 +231,15 @@ void ASurface::plotB(SpriteFrame *frame, const Common::Point &pt) {
 	error("TODO");
 }
 
+void ASurface::copyBlock(ASurface *src, const Common::Rect &bounds) {
+	byte *srcP = (byte *)getBasePtr(bounds.left, bounds.top + _scrollY);
+	byte *destP = (byte *)getBasePtr(bounds.left, bounds.top); /* + _windowYAdd */
+
+	for (int y = 0; y < bounds.height(); ++y) {
+		Common::copy(srcP, srcP + bounds.width(), destP);
+		srcP += src->pitch;
+		destP += this->pitch;
+	}
+}
+
 } // End of namespace Access
diff --git a/engines/access/asurface.h b/engines/access/asurface.h
index 99f99ae..776b950 100644
--- a/engines/access/asurface.h
+++ b/engines/access/asurface.h
@@ -62,6 +62,8 @@ public:
 
 	void plotB(SpriteFrame *frame, const Common::Point &pt);
 
+	void copyBlock(ASurface *src, const Common::Rect &bounds);
+
 	void copyTo(ASurface *dest, const Common::Point &destPos);
 };
 
diff --git a/engines/access/room.cpp b/engines/access/room.cpp
index b39e998..ab3592a 100644
--- a/engines/access/room.cpp
+++ b/engines/access/room.cpp
@@ -65,8 +65,8 @@ void Room::doRoom() {
 	while (!_vm->shouldQuit()) {
 		if (!reloadFlag) {
 			_vm->_numImages = 0;
-			_vm->_newRect.clear();
-			_vm->_oldRect.clear();
+			_vm->_newRects.clear();
+			_vm->_oldRects.clear();
 			_vm->_nextImage = 0;
 			_vm->_numAnimTimers = 0;
 
@@ -109,7 +109,7 @@ void Room::doRoom() {
 
 			if (_vm->_screen->_scrollFlag) {
 				_vm->_screen->copyBF1BF2();
-				_vm->_newRect.clear();
+				_vm->_newRects.clear();
 				_function = 0;
 				roomLoop();
 
@@ -124,7 +124,7 @@ void Room::doRoom() {
 				}
 			} else {
 				_vm->_screen->copyBF1BF2();
-				_vm->_newRect.clear();
+				_vm->_newRects.clear();
 				_function = 0;
 				roomLoop();
 
@@ -133,7 +133,7 @@ void Room::doRoom() {
 					break;
 				} else {
 					_vm->plotList();
-					_vm->_screen->copyBlocks();
+					_vm->copyBlocks();
 				}
 			}
 		}
diff --git a/engines/access/screen.cpp b/engines/access/screen.cpp
index 2dc8698..b47cd3e 100644
--- a/engines/access/screen.cpp
+++ b/engines/access/screen.cpp
@@ -162,10 +162,6 @@ void Screen::copyBF2Vid() {
 	warning("TODO");
 }
 
-void Screen::copyBlocks() {
-	warning("TODO: copyBlocks");
-}
-
 void Screen::copyRects() {
 	warning("TODO: copyRects");
 }
diff --git a/engines/access/screen.h b/engines/access/screen.h
index 6c1d96e..670da82 100644
--- a/engines/access/screen.h
+++ b/engines/access/screen.h
@@ -123,8 +123,6 @@ public:
 
 	void copyBF2Vid();
 
-	void copyBlocks();
-
 	void copyRects();
 
 	void setBufferScan();


Commit: 94eda108eb36594329c20ecbc525d9934083e535
    https://github.com/scummvm/scummvm/commit/94eda108eb36594329c20ecbc525d9934083e535
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-12T09:01:29-04:00

Commit Message:
ACCESS: Fix incorrect decrementing of _startup

Changed paths:
    engines/access/room.cpp



diff --git a/engines/access/room.cpp b/engines/access/room.cpp
index ab3592a..4996527 100644
--- a/engines/access/room.cpp
+++ b/engines/access/room.cpp
@@ -80,12 +80,13 @@ void Room::doRoom() {
 		while (!_vm->shouldQuit()) {
 			_vm->_numImages = 0;
 			if (_vm->_startup != -1 && --_vm->_startup != 0) {
-				--_vm->_startup;
 				_vm->_events->showCursor();
 				_vm->_screen->fadeIn();
 			}
 
+			// Handle any events
 			_vm->_events->pollEvents();
+
 			_vm->_nextImage = 0;
 			_vm->_player->walk();
 			_vm->_sound->midiRepeat();


Commit: 9107cc103fa8ca65e12d0213c7b915ec990fb6cf
    https://github.com/scummvm/scummvm/commit/9107cc103fa8ca65e12d0213c7b915ec990fb6cf
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-12T09:16:14-04:00

Commit Message:
ACCESS: Added a temporary frame delay and screen update

Changed paths:
    engines/access/events.cpp
    engines/access/events.h
    engines/access/room.cpp
    engines/access/screen.cpp



diff --git a/engines/access/events.cpp b/engines/access/events.cpp
index 1184128..73feefe 100644
--- a/engines/access/events.cpp
+++ b/engines/access/events.cpp
@@ -148,7 +148,15 @@ void EventsManager::checkForNextFrameCounter() {
 
 		// Signal the ScummVM debugger
 		_vm->_debugger->onFrame();
+
+		// TODO: Refactor for dirty rects
+		_vm->_screen->updateScreen();
 	}
 }
 
+void EventsManager::delay(int time) {
+	g_system->delayMillis(time);
+}
+
+
 } // End of namespace Access
diff --git a/engines/access/events.h b/engines/access/events.h
index 2e6b06b..55f04f1 100644
--- a/engines/access/events.h
+++ b/engines/access/events.h
@@ -88,6 +88,8 @@ public:
 	bool isCursorVisible();
 
 	void pollEvents();
+
+	void delay(int time);
 };
 
 } // End of namespace Access
diff --git a/engines/access/room.cpp b/engines/access/room.cpp
index 4996527..d3f0f8f 100644
--- a/engines/access/room.cpp
+++ b/engines/access/room.cpp
@@ -84,6 +84,10 @@ void Room::doRoom() {
 				_vm->_screen->fadeIn();
 			}
 
+			// TODO: Game loop doesn't seem to have any delay. For now,
+			// introduce a slight delay here
+			_vm->_events->delay(50);
+
 			// Handle any events
 			_vm->_events->pollEvents();
 
diff --git a/engines/access/screen.cpp b/engines/access/screen.cpp
index b47cd3e..cdd5f20 100644
--- a/engines/access/screen.cpp
+++ b/engines/access/screen.cpp
@@ -64,6 +64,8 @@ void Screen::setPanel(int num) {
 }
 
 void Screen::updateScreen() {
+	g_system->copyRectToScreen((byte *)getPixels(), this->pitch, 0, 0,
+		this->w, this->h);
 	g_system->updateScreen();
 }
 


Commit: b579dbb71b4aafa533b06589ced928d788a1c2e6
    https://github.com/scummvm/scummvm/commit/b579dbb71b4aafa533b06589ced928d788a1c2e6
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-12T21:12:11-04:00

Commit Message:
ACCESS: Fixes for clipping

Changed paths:
    engines/access/asurface.cpp
    engines/access/screen.cpp



diff --git a/engines/access/asurface.cpp b/engines/access/asurface.cpp
index 5a090af..ba75607 100644
--- a/engines/access/asurface.cpp
+++ b/engines/access/asurface.cpp
@@ -115,13 +115,14 @@ bool ASurface::clip(Common::Rect &r) {
 	_topSkip = _bottomSkip = 0;
 
 	if (r.left > _clipWidth) {
+		if (r.left >= 0)
+			return true;
+
 		skip = -r.left;
 		r.setWidth(r.width() - skip);
 		_leftSkip = skip;
 		r.moveTo(0, r.top);
 	}
-	else if (r.left >= 0)
-		return true;
 
 	int right = r.right - 1;
 	if (right < 0)
@@ -133,13 +134,14 @@ bool ASurface::clip(Common::Rect &r) {
 	}
 
 	if (r.top > _clipHeight) {
+		if (r.top >= 0)
+			return true;
+
 		skip = -r.top;
 		r.setHeight(r.height() - skip);
 		_topSkip = skip;
 		r.moveTo(r.left, 0);
 	}
-	else if (r.top >= 0)
-		return true;
 
 	int bottom = r.bottom - 1;
 	if (bottom < 0)
diff --git a/engines/access/screen.cpp b/engines/access/screen.cpp
index cdd5f20..9cefa35 100644
--- a/engines/access/screen.cpp
+++ b/engines/access/screen.cpp
@@ -51,10 +51,18 @@ Screen::Screen(AccessEngine *vm) : _vm(vm) {
 	_scrollCol = _scrollRow = 0;
 	_windowXAdd = _windowYAdd = 0;
 	_screenYOff = 0;
+
+	setDisplayScan();
 }
 
 void Screen::setDisplayScan() {
-	warning("TODO: setDisplayScan");
+	_clipWidth = this->w - 1;
+	_clipHeight = this->h - 1;
+	_windowXAdd = _windowYAdd = 0;
+	_scrollX = _scrollY = 0;
+	_scrollCol = _scrollRow = 0;
+	_bufferStart.x = _bufferStart.y = 0;
+	_screenYOff = 0;
 }
 
 void Screen::setPanel(int num) {


Commit: 483bc1eb03b54db70d3136f3265fca1989b5b417
    https://github.com/scummvm/scummvm/commit/483bc1eb03b54db70d3136f3265fca1989b5b417
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-12T21:40:14-04:00

Commit Message:
ACCESS: Implemented setBufferScan and copyRects

Changed paths:
    engines/access/access.cpp
    engines/access/access.h
    engines/access/room.cpp
    engines/access/screen.cpp
    engines/access/screen.h



diff --git a/engines/access/access.cpp b/engines/access/access.cpp
index 29e5188..75a3b8d 100644
--- a/engines/access/access.cpp
+++ b/engines/access/access.cpp
@@ -304,7 +304,10 @@ void AccessEngine::copyBlocks() {
 		_screen->copyBlock(&_buffer2, _oldRects[i]);
 	}
 
-	// Copy the new block list, replacing the old one at the same time
+	copyRects();
+}
+
+void AccessEngine::copyRects() {
 	_oldRects.clear();
 	for (uint i = 0; i < _newRects.size(); ++i) {
 		_screen->copyBlock(&_buffer2, _newRects[i]);
diff --git a/engines/access/access.h b/engines/access/access.h
index 3cd98f0..4efe1b4 100644
--- a/engines/access/access.h
+++ b/engines/access/access.h
@@ -242,6 +242,8 @@ public:
 	void plotList1();
 
 	void copyBlocks();
+
+	void copyRects();
 };
 
 } // End of namespace Access
diff --git a/engines/access/room.cpp b/engines/access/room.cpp
index d3f0f8f..22ced20 100644
--- a/engines/access/room.cpp
+++ b/engines/access/room.cpp
@@ -123,8 +123,7 @@ void Room::doRoom() {
 					break;
 				} else {
 					_vm->plotList();
-					_vm->_screen->copyRects();
-
+					_vm->copyRects();
 					_vm->_screen->copyBF2Vid();
 				}
 			} else {
diff --git a/engines/access/screen.cpp b/engines/access/screen.cpp
index 9cefa35..d450cc1 100644
--- a/engines/access/screen.cpp
+++ b/engines/access/screen.cpp
@@ -172,12 +172,11 @@ void Screen::copyBF2Vid() {
 	warning("TODO");
 }
 
-void Screen::copyRects() {
-	warning("TODO: copyRects");
-}
-
 void Screen::setBufferScan() {
-	warning("TODO: setBufferScan");
+	_clipWidth = _vm->_room->_vWindowBytesWide - 1;
+	_windowXAdd = (320 - _clipWidth) >> 1;
+	_clipHeight = _vm->_room->_vWindowLinesTall - 1;
+	_windowYAdd = (176 - _clipHeight) >> 1;
 }
 
 void Screen::setScaleTable(int scale) {
diff --git a/engines/access/screen.h b/engines/access/screen.h
index 670da82..875b665 100644
--- a/engines/access/screen.h
+++ b/engines/access/screen.h
@@ -123,8 +123,6 @@ public:
 
 	void copyBF2Vid();
 
-	void copyRects();
-
 	void setBufferScan();
 
 	void setScaleTable(int scale);


Commit: 89772d55a5c97b3c58bdf685e2419e78335ba02d
    https://github.com/scummvm/scummvm/commit/89772d55a5c97b3c58bdf685e2419e78335ba02d
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-12T23:34:23-04:00

Commit Message:
ACCESS: Implemented window size fields setup and copyBF2Vid

Changed paths:
    engines/access/access.cpp
    engines/access/access.h
    engines/access/amazon/amazon_room.cpp
    engines/access/player.cpp
    engines/access/room.cpp
    engines/access/room.h
    engines/access/screen.cpp
    engines/access/screen.h



diff --git a/engines/access/access.cpp b/engines/access/access.cpp
index 75a3b8d..9c0df1a 100644
--- a/engines/access/access.cpp
+++ b/engines/access/access.cpp
@@ -315,4 +315,20 @@ void AccessEngine::copyRects() {
 	}
 }
 
+void AccessEngine::copyBF1BF2() {
+	_buffer2.copyFrom(_buffer1);
+}
+
+void AccessEngine::copyBF2Vid() {
+	const byte *srcP = (const byte *)_buffer2.getPixels();
+	byte *destP = (byte *)_screen->getBasePtr(_screen->_windowXAdd, 
+		_screen->_windowYAdd + _screen->_screenYOff);
+
+	for (int yp = 0; yp < _screen->_vWindowLinesTall; ++yp) {
+		Common::copy(srcP, srcP + _screen->_vWindowBytesWide, destP);
+		srcP += _buffer2.pitch;
+		destP += _screen->pitch;
+	}
+}
+
 } // End of namespace Access
diff --git a/engines/access/access.h b/engines/access/access.h
index 4efe1b4..770bd03 100644
--- a/engines/access/access.h
+++ b/engines/access/access.h
@@ -244,6 +244,10 @@ public:
 	void copyBlocks();
 
 	void copyRects();
+
+	void copyBF1BF2();
+
+	void copyBF2Vid();
 };
 
 } // End of namespace Access
diff --git a/engines/access/amazon/amazon_room.cpp b/engines/access/amazon/amazon_room.cpp
index b8ed0d2..db16397 100644
--- a/engines/access/amazon/amazon_room.cpp
+++ b/engines/access/amazon/amazon_room.cpp
@@ -103,10 +103,12 @@ void AmazonRoom::reloadRoom1() {
 	setWallCodes();
 	buildScreen();
 
-	if (_vm->_player->_roomNumber != 20 && _vm->_player->_roomNumber != 24
+	if (!_vm->_screen->_vesaMode) {
+		_vm->copyBF2Vid();
+	} else if (_vm->_player->_roomNumber != 20 && _vm->_player->_roomNumber != 24
 			&& _vm->_player->_roomNumber != 33) {
 		_vm->_screen->setPalette();
-		_vm->_screen->copyBF2Vid();
+		_vm->copyBF2Vid();
 	}
 
 	_vm->_player->_frame = 0;
diff --git a/engines/access/player.cpp b/engines/access/player.cpp
index 794fc08..969df00 100644
--- a/engines/access/player.cpp
+++ b/engines/access/player.cpp
@@ -132,7 +132,7 @@ void Player::load() {
 	if (_vm->_manPal1) {
 		Common::copy(_vm->_manPal1 + 0x270, _vm->_manPal1 + 0x270 + 0x60, _vm->_screen->_manPal);
 	} else {
-		Common::fill(_vm->_screen->_manPal + 0x270, _vm->_screen->_manPal + 0x270 + 0x60, 0);
+		Common::fill(_vm->_screen->_manPal, _vm->_screen->_manPal + 0x60, 0);
 	}
 }
 
diff --git a/engines/access/room.cpp b/engines/access/room.cpp
index 22ced20..c258e07 100644
--- a/engines/access/room.cpp
+++ b/engines/access/room.cpp
@@ -38,10 +38,6 @@ Room::Room(AccessEngine *vm) : Manager(vm) {
 	_playFieldWidth = _playFieldHeight = 0;
 	_matrixSize = 0;
 	_tile = nullptr;
-	_vWindowWidth = _vWindowHeight = 0;
-	_vWindowBytesWide = 0;
-	_bufferBytesWide = 0;
-	_vWindowLinesTall = 0;
 }
 
 Room::~Room() {
@@ -113,7 +109,7 @@ void Room::doRoom() {
 			}
 
 			if (_vm->_screen->_scrollFlag) {
-				_vm->_screen->copyBF1BF2();
+				_vm->copyBF1BF2();
 				_vm->_newRects.clear();
 				_function = 0;
 				roomLoop();
@@ -124,10 +120,10 @@ void Room::doRoom() {
 				} else {
 					_vm->plotList();
 					_vm->copyRects();
-					_vm->_screen->copyBF2Vid();
+					_vm->copyBF2Vid();
 				}
 			} else {
-				_vm->_screen->copyBF1BF2();
+				_vm->copyBF1BF2();
 				_vm->_newRects.clear();
 				_function = 0;
 				roomLoop();
@@ -255,34 +251,33 @@ void Room::setupRoom() {
 	if (_roomFlag != 2)
 		setIconPalette();
 
-	if (_vWindowWidth == _playFieldWidth) {
+	if (_vm->_screen->_vWindowWidth == _playFieldWidth) {
 		_vm->_screen->_scrollX = 0;
 		_vm->_screen->_scrollCol = 0;
 	} else {
 		_vm->_screen->_scrollX = _vm->_player->_rawPlayer.x -
 			(_vm->_player->_rawPlayer.x >> 4);
 		int xp = MAX((_vm->_player->_rawPlayer.x >> 4) -
-			(_vWindowWidth / 2), 0);
+			(_vm->_screen->_vWindowWidth / 2), 0);
 		_vm->_screen->_scrollCol = xp;
 
-		xp = xp + _vWindowWidth - _playFieldWidth;
+		xp = xp + _vm->_screen->_vWindowWidth - _playFieldWidth;
 		if (xp >= 0) {
 			_vm->_screen->_scrollCol = xp + 1;
 		}
 	}
 	
-	if (_vWindowHeight == _playFieldHeight) {
+	if (_vm->_screen->_vWindowHeight == _playFieldHeight) {
 		_vm->_screen->_scrollY = 0;
 		_vm->_screen->_scrollRow = 0;
-	}
-	else {
+	} else {
 		_vm->_screen->_scrollY = _vm->_player->_rawPlayer.y -
 			(_vm->_player->_rawPlayer.y >> 4);
 		int yp = MAX((_vm->_player->_rawPlayer.y >> 4) -
-			(_vWindowHeight / 2), 0);
+			(_vm->_screen->_vWindowHeight / 2), 0);
 		_vm->_screen->_scrollRow = yp;
 
-		yp = yp + _vWindowHeight - _playFieldHeight;
+		yp = yp + _vm->_screen->_vWindowHeight - _playFieldHeight;
 		if (yp >= 0) {
 			_vm->_screen->_scrollRow = yp + 1;
 		}
@@ -299,7 +294,7 @@ void Room::setWallCodes() {
 
 void Room::buildScreen() {
 	int scrollCol = _vm->_screen->_scrollCol;
-	int cnt = _vWindowWidth + 1;
+	int cnt = _vm->_screen->_vWindowWidth + 1;
 	int offset = 0;
 
 	for (int idx = 0; idx < cnt; offset += TILE_WIDTH, ++idx) {
@@ -308,7 +303,7 @@ void Room::buildScreen() {
 	}
 
 	_vm->_screen->_scrollCol = scrollCol;
-	_vm->_screen->copyBF1BF2();
+	_vm->copyBF1BF2();
 }
 
 void Room::buildColumn(int playX, int screenX) {
@@ -316,12 +311,12 @@ void Room::buildColumn(int playX, int screenX) {
 		_playFieldWidth + playX;
 	byte *pDest = (byte *)_vm->_buffer1.getPixels();
 
-	for (int y = 0; y <= _vWindowHeight; ++y) {
+	for (int y = 0; y <= _vm->_screen->_vWindowHeight; ++y) {
 		byte *pTile = _tile + (*pSrc << 8);
 
 		for (int tileY = 0; tileY < TILE_HEIGHT; ++tileY) {
 			Common::copy(pTile, pTile + TILE_WIDTH, pDest);
-			pDest += _vWindowWidth;
+			pDest += _vm->_screen->_vWindowWidth;
 		}
 	}
 }
@@ -333,9 +328,10 @@ void Room::init4Quads() {
 void Room::loadPlayField(int fileNum, int subfile) {
 	byte *playData = _vm->_files->loadFile(fileNum, subfile);
 	Common::MemoryReadStream stream(playData + 0x10, _vm->_files->_filesize - 0x10);
+	Screen &screen = *_vm->_screen;
 
 	// Copy the new palette
-	_vm->_screen->loadRawPalette(&stream);
+	screen.loadRawPalette(&stream);
 
 	// Copy off the tile data
 	_tileSize = playData[2] << 8;
@@ -352,11 +348,11 @@ void Room::loadPlayField(int fileNum, int subfile) {
 	int numBlocks = playData[8];
 	_plotter.load(&stream, numWalls, numBlocks);
 
-	_vWindowWidth = playData[3];
-	_vWindowBytesWide = _vWindowWidth << 4;
-	_bufferBytesWide = _vWindowBytesWide + 16;
-	_vWindowHeight = playData[4];
-	_vWindowLinesTall = _vWindowHeight << 4;
+	screen._vWindowWidth = playData[3];
+	screen._vWindowBytesWide = screen._vWindowWidth << 4;
+	screen._bufferBytesWide = screen._vWindowBytesWide + 16;
+	screen._vWindowHeight = playData[4];
+	screen._vWindowLinesTall = screen._vWindowHeight << 4;
 
 	_vm->_screen->setBufferScan();
 	delete[] playData;
diff --git a/engines/access/room.h b/engines/access/room.h
index 0c19308..ce3c4dc 100644
--- a/engines/access/room.h
+++ b/engines/access/room.h
@@ -97,11 +97,6 @@ public:
 	int _playFieldHeight;
 	byte *_tile;
 	int _tileSize;
-	int _vWindowWidth;
-	int _vWindowHeight;
-	int _vWindowBytesWide;
-	int _bufferBytesWide;
-	int _vWindowLinesTall;
 public:
 	Room(AccessEngine *vm);
 
diff --git a/engines/access/screen.cpp b/engines/access/screen.cpp
index d450cc1..6f9b539 100644
--- a/engines/access/screen.cpp
+++ b/engines/access/screen.cpp
@@ -52,7 +52,10 @@ Screen::Screen(AccessEngine *vm) : _vm(vm) {
 	_windowXAdd = _windowYAdd = 0;
 	_screenYOff = 0;
 
-	setDisplayScan();
+	_bufferBytesWide = _vWindowBytesWide = this->w;
+	_vWindowLinesTall = this->h;
+	_clipWidth = _vWindowBytesWide - 1;
+	_clipHeight = _vWindowLinesTall - 1;
 }
 
 void Screen::setDisplayScan() {
@@ -164,18 +167,10 @@ void Screen::checkScroll() {
 	warning("TODO");
 }
 
-void Screen::copyBF1BF2() {
-	warning("TODO");
-}
-
-void Screen::copyBF2Vid() {
-	warning("TODO");
-}
-
 void Screen::setBufferScan() {
-	_clipWidth = _vm->_room->_vWindowBytesWide - 1;
+	_clipWidth = _vWindowBytesWide - 1;
 	_windowXAdd = (320 - _clipWidth) >> 1;
-	_clipHeight = _vm->_room->_vWindowLinesTall - 1;
+	_clipHeight = _vWindowLinesTall - 1;
 	_windowYAdd = (176 - _clipHeight) >> 1;
 }
 
diff --git a/engines/access/screen.h b/engines/access/screen.h
index 875b665..6ede482 100644
--- a/engines/access/screen.h
+++ b/engines/access/screen.h
@@ -73,6 +73,11 @@ public:
 	byte _manPal[0x60];
 	byte _scaleTable1[256];
 	byte _scaleTable2[256];
+	int _vWindowWidth;
+	int _vWindowHeight;
+	int _vWindowBytesWide;
+	int _bufferBytesWide;
+	int _vWindowLinesTall;
 public:
 	Screen(AccessEngine *vm);
 
@@ -119,10 +124,6 @@ public:
 
 	void checkScroll();
 
-	void copyBF1BF2();
-
-	void copyBF2Vid();
-
 	void setBufferScan();
 
 	void setScaleTable(int scale);


Commit: 146f6b5df40d2800432866389f549838921203d2
    https://github.com/scummvm/scummvm/commit/146f6b5df40d2800432866389f549838921203d2
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-13T20:56:06-04:00

Commit Message:
ACCESS: Fix rendering of scene background

Changed paths:
    engines/access/access.cpp
    engines/access/room.cpp
    engines/access/room.h



diff --git a/engines/access/access.cpp b/engines/access/access.cpp
index 9c0df1a..9b10e4f 100644
--- a/engines/access/access.cpp
+++ b/engines/access/access.cpp
@@ -159,7 +159,7 @@ void AccessEngine::initialize() {
 	_screen = new Screen(this);
 	_sound = new SoundManager(this, _mixer);
 
-	_buffer1.create(g_system->getWidth(), g_system->getHeight(), Graphics::PixelFormat::createFormatCLUT8());
+	_buffer1.create(g_system->getWidth() + TILE_WIDTH, g_system->getHeight(), Graphics::PixelFormat::createFormatCLUT8());
 	_buffer2.create(g_system->getWidth(), g_system->getHeight(), Graphics::PixelFormat::createFormatCLUT8());
 }
 
@@ -316,7 +316,10 @@ void AccessEngine::copyRects() {
 }
 
 void AccessEngine::copyBF1BF2() {
-	_buffer2.copyFrom(_buffer1);
+	_buffer2.copyRectToSurface(_buffer1, 0, 0,
+		Common::Rect(_buffer1._scrollX, _buffer1._scrollY,
+		_buffer1._scrollX + _screen->_vWindowBytesWide,
+		_buffer1._scrollY + _screen->_vWindowLinesTall));
 }
 
 void AccessEngine::copyBF2Vid() {
diff --git a/engines/access/room.cpp b/engines/access/room.cpp
index c258e07..cd39109 100644
--- a/engines/access/room.cpp
+++ b/engines/access/room.cpp
@@ -26,9 +26,6 @@
 #include "access/resources.h"
 #include "access/room.h"
 
-#define TILE_WIDTH 16
-#define TILE_HEIGHT 16
-
 namespace Access {
 
 Room::Room(AccessEngine *vm) : Manager(vm) {
@@ -309,15 +306,18 @@ void Room::buildScreen() {
 void Room::buildColumn(int playX, int screenX) {
 	const byte *pSrc = _playField + _vm->_screen->_scrollRow * 
 		_playFieldWidth + playX;
-	byte *pDest = (byte *)_vm->_buffer1.getPixels();
 
 	for (int y = 0; y <= _vm->_screen->_vWindowHeight; ++y) {
 		byte *pTile = _tile + (*pSrc << 8);
+		byte *pDest = (byte *)_vm->_buffer1.getBasePtr(screenX, y * TILE_HEIGHT);
 
 		for (int tileY = 0; tileY < TILE_HEIGHT; ++tileY) {
 			Common::copy(pTile, pTile + TILE_WIDTH, pDest);
-			pDest += _vm->_screen->_vWindowWidth;
+			pTile += TILE_WIDTH;
+			pDest += _vm->_buffer1.pitch;
 		}
+
+		pSrc += _playFieldWidth;
 	}
 }
 
@@ -348,6 +348,8 @@ void Room::loadPlayField(int fileNum, int subfile) {
 	int numBlocks = playData[8];
 	_plotter.load(&stream, numWalls, numBlocks);
 
+	_playFieldWidth = playData[0];
+	_playFieldHeight = playData[1];
 	screen._vWindowWidth = playData[3];
 	screen._vWindowBytesWide = screen._vWindowWidth << 4;
 	screen._bufferBytesWide = screen._vWindowBytesWide + 16;
diff --git a/engines/access/room.h b/engines/access/room.h
index ce3c4dc..18637e4 100644
--- a/engines/access/room.h
+++ b/engines/access/room.h
@@ -28,6 +28,9 @@
 #include "common/rect.h"
 #include "access/data.h"
 
+#define TILE_WIDTH 16
+#define TILE_HEIGHT 16
+
 namespace Access {
 
 class Plotter {


Commit: ed645e435a641cc3be95bfe946d2c08d2ab3836b
    https://github.com/scummvm/scummvm/commit/ed645e435a641cc3be95bfe946d2c08d2ab3836b
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-13T21:07:27-04:00

Commit Message:
ACCESS: Fix clearing pending images list each frame

Changed paths:
    engines/access/access.cpp
    engines/access/access.h
    engines/access/room.cpp



diff --git a/engines/access/access.cpp b/engines/access/access.cpp
index 9b10e4f..3a773a9 100644
--- a/engines/access/access.cpp
+++ b/engines/access/access.cpp
@@ -60,8 +60,6 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc)
 	_converseMode = 0;
 	_startAboutBox = 0;
 	_startTravelBox = 0;
-	_numImages = 0;
-	_nextImage = 0;
 	_numAnimTimers = 0;
 	_startup = 0;
 	_currentCharFlag = false;
diff --git a/engines/access/access.h b/engines/access/access.h
index 770bd03..08b5ae3 100644
--- a/engines/access/access.h
+++ b/engines/access/access.h
@@ -142,8 +142,6 @@ public:
 	int _selectCommand;
 	bool _normalMouse;
 	int _mouseMode;
-	int _numImages;
-	int _nextImage;
 
 	int _currentManOld;
 	byte *_man;
diff --git a/engines/access/room.cpp b/engines/access/room.cpp
index cd39109..3e9e9e6 100644
--- a/engines/access/room.cpp
+++ b/engines/access/room.cpp
@@ -57,10 +57,9 @@ void Room::doRoom() {
 
 	while (!_vm->shouldQuit()) {
 		if (!reloadFlag) {
-			_vm->_numImages = 0;
+			_vm->_images.clear();
 			_vm->_newRects.clear();
 			_vm->_oldRects.clear();
-			_vm->_nextImage = 0;
 			_vm->_numAnimTimers = 0;
 
 			reloadRoom();
@@ -71,7 +70,7 @@ void Room::doRoom() {
 		_function = 0;
 
 		while (!_vm->shouldQuit()) {
-			_vm->_numImages = 0;
+			_vm->_images.clear();
 			if (_vm->_startup != -1 && --_vm->_startup != 0) {
 				_vm->_events->showCursor();
 				_vm->_screen->fadeIn();
@@ -84,7 +83,6 @@ void Room::doRoom() {
 			// Handle any events
 			_vm->_events->pollEvents();
 
-			_vm->_nextImage = 0;
 			_vm->_player->walk();
 			_vm->_sound->midiRepeat();
 			_vm->_screen->checkScroll();


Commit: 28bfe7374930cd78f722451b8754822a11dd500d
    https://github.com/scummvm/scummvm/commit/28bfe7374930cd78f722451b8754822a11dd500d
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-13T22:23:08-04:00

Commit Message:
ACCESS: Implemented cmdSpecial script opcode

Changed paths:
    engines/access/amazon/amazon_scripts.cpp
    engines/access/amazon/amazon_scripts.h
    engines/access/screen.cpp
    engines/access/screen.h
    engines/access/scripts.cpp
    engines/access/scripts.h



diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp
index 1d3e7b4..d7e8439 100644
--- a/engines/access/amazon/amazon_scripts.cpp
+++ b/engines/access/amazon/amazon_scripts.cpp
@@ -31,6 +31,11 @@ namespace Amazon {
 AmazonScripts::AmazonScripts(AccessEngine *vm) : Scripts(vm) {
 }
 
+void AmazonScripts::executeSpecial(int commandIndex, int param1, int param2) {
+	warning("TODO");
+}
+
+
 } // End of namespace Amazon
 
 } // End of namespace Access
diff --git a/engines/access/amazon/amazon_scripts.h b/engines/access/amazon/amazon_scripts.h
index 08fbc3a..b8fdaaa 100644
--- a/engines/access/amazon/amazon_scripts.h
+++ b/engines/access/amazon/amazon_scripts.h
@@ -31,6 +31,8 @@ namespace Access {
 namespace Amazon {
 
 class AmazonScripts: public Scripts {
+protected:
+	virtual void executeSpecial(int commandIndex, int param1, int param2);
 public:
 	AmazonScripts(AccessEngine *vm);
 };
diff --git a/engines/access/screen.cpp b/engines/access/screen.cpp
index 6f9b539..4673bb6 100644
--- a/engines/access/screen.cpp
+++ b/engines/access/screen.cpp
@@ -40,6 +40,7 @@ Screen::Screen(AccessEngine *vm) : _vm(vm) {
 	Common::fill(&_manPal[0], &_manPal[0x60], 0);
 	Common::fill(&_scaleTable1[0], &_scaleTable1[256], 0);
 	Common::fill(&_scaleTable2[0], &_scaleTable2[256], 0);
+	_savedPaletteCount = 0;
 	_vesaMode = 0;
 	_vesaCurrentWin = 0;
 	_currentPanel = 0;
@@ -114,6 +115,23 @@ void Screen::updatePalette() {
 	updateScreen();
 }
 
+void Screen::savePalette() {
+	Common::copy(&_rawPalette[0], &_rawPalette[PALETTE_SIZE],
+		&_savedPalettes[_savedPaletteCount][0]);
+
+	if (++_savedPaletteCount == 2)
+		_savedPaletteCount = 1;
+}
+
+void Screen::restorePalette() {
+	if (--_savedPaletteCount < 0)
+		_savedPaletteCount = 0;
+
+	Common::copy(&_savedPalettes[_savedPaletteCount][0],
+		&_savedPalettes[_savedPaletteCount][PALETTE_SIZE], &_rawPalette[0]);
+}
+
+
 void Screen::forceFadeOut() {
 	const int FADE_AMOUNT = 2;
 	bool repeatFlag;
diff --git a/engines/access/screen.h b/engines/access/screen.h
index 6ede482..d759ae1 100644
--- a/engines/access/screen.h
+++ b/engines/access/screen.h
@@ -52,6 +52,8 @@ private:
 	AccessEngine *_vm;
 	byte _tempPalette[PALETTE_SIZE];
 	byte _rawPalette[PALETTE_SIZE];
+	byte _savedPalettes[2][PALETTE_SIZE];
+	int _savedPaletteCount;
 	int _vesaCurrentWin;
 	int _currentPanel;
 	Common::Point _msVirtualOffset;
@@ -117,6 +119,10 @@ public:
 
 	void loadRawPalette(Common::SeekableReadStream *stream);
 
+	void savePalette();
+
+	void restorePalette();
+
 	/**
 	 * Copy a buffer to the screen
 	 */
diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp
index 1963354..0e1d421 100644
--- a/engines/access/scripts.cpp
+++ b/engines/access/scripts.cpp
@@ -326,7 +326,26 @@ void Scripts::cmdRemoveLast() {
 	--_vm->_numAnimTimers;
 }
 
-void Scripts::CMDSPECIAL() { error("TODO"); }
+void Scripts::CMDSPECIAL() { 
+	_specialFunction = _data->readUint16LE();
+	int p1 = _data->readUint16LE();
+	int p2 = _data->readUint16LE();
+
+	if (_specialFunction == 1) {
+		if (_vm->_establishTable[p2] == 1)
+			return;
+
+		_vm->_screen->savePalette();
+	}
+
+	executeSpecial(_specialFunction, p1, p2);
+
+	if (_specialFunction == 1) {
+		_vm->_screen->restorePalette();
+		_vm->_room->_function = 3;
+	}
+}
+
 void Scripts::CMDSETCYCLE() { error("TODO"); }
 void Scripts::CMDCYCLE() { error("TODO"); }
 void Scripts::CMDCHARSPEAK() { error("TODO"); }
diff --git a/engines/access/scripts.h b/engines/access/scripts.h
index 495c4c5..0916b9e 100644
--- a/engines/access/scripts.h
+++ b/engines/access/scripts.h
@@ -37,9 +37,11 @@ class Scripts {
 private:
 	const byte *_rawData;
 	Common::MemoryReadStream *_data;
+	int _specialFunction;
 protected:
 	AccessEngine *_vm;
 
+	virtual void executeSpecial(int commandIndex, int param1, int param2) = 0;
 	virtual void executeCommand(int commandIndex);
 	void CMDOBJECT();
 	void CMDENDOBJECT();


Commit: d6404a10adc4a1b6973894291ffbc6d87ac96071
    https://github.com/scummvm/scummvm/commit/d6404a10adc4a1b6973894291ffbc6d87ac96071
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-13T22:45:15-04:00

Commit Message:
ACCESS: Fix compiler warnings and deallocation crash on exit

Changed paths:
    engines/access/access.cpp
    engines/access/access.h
    engines/access/amazon/amazon_game.cpp
    engines/access/asurface.cpp
    engines/access/asurface.h
    engines/access/screen.h



diff --git a/engines/access/access.cpp b/engines/access/access.cpp
index 3a773a9..2ffc479 100644
--- a/engines/access/access.cpp
+++ b/engines/access/access.cpp
@@ -114,9 +114,6 @@ AccessEngine::~AccessEngine() {
 	delete _scripts;
 	delete _sound;
 
-	_buffer1.free();
-	_buffer2.free();
-
 	freeCells();
 	delete[] _man1;
 	delete[] _inactive;
@@ -198,16 +195,9 @@ void AccessEngine::loadCells(Common::Array<RoomInfo::CellIdent> &cells) {
 	}
 }
 
-void AccessEngine::clearCellTable() {
-	for (int i = 0; i < 100; ++i) {
-		delete _objectsTable[i];
-		_objectsTable[i] = nullptr;
-	}
-}
-
 void AccessEngine::freeCells() {
 	for (int i = 0; i < 100; ++i) {
-		delete[] _objectsTable[i];
+		delete _objectsTable[i];
 		_objectsTable[i] = nullptr;
 	}
 }
diff --git a/engines/access/access.h b/engines/access/access.h
index 08b5ae3..d919ae8 100644
--- a/engines/access/access.h
+++ b/engines/access/access.h
@@ -30,7 +30,7 @@
 #include "common/util.h"
 #include "engines/engine.h"
 #include "graphics/surface.h"
-#include "access\/animation.h"
+#include "access/animation.h"
 #include "access/data.h"
 #include "access/debugger.h"
 #include "access/events.h"
@@ -213,12 +213,7 @@ public:
 	void loadCells(Common::Array<RoomInfo::CellIdent> &cells);
 
 	/**
-	* Clear the cell table
-	*/
-	void clearCellTable();
-
-	/**
-	* Free the cell data
+	* Free the sprites list
 	*/
 	void freeCells();
 
diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp
index fe15812..d0a5b6e 100644
--- a/engines/access/amazon/amazon_game.cpp
+++ b/engines/access/amazon/amazon_game.cpp
@@ -161,7 +161,6 @@ void AmazonEngine::doTent() {
 
 void AmazonEngine::setupGame() {
 	_chapter = 1;
-	clearCellTable();
 
 	// Setup timers
 	const int TIMER_DEFAULTS[] = { 3, 10, 8, 1, 1, 1, 1, 2 };
diff --git a/engines/access/asurface.cpp b/engines/access/asurface.cpp
index ba75607..619c449 100644
--- a/engines/access/asurface.cpp
+++ b/engines/access/asurface.cpp
@@ -104,6 +104,10 @@ void ASurface::init() {
 	_scrollX = _scrollY = 0;
 }
 
+ASurface::~ASurface() {
+	free();
+}
+
 void ASurface::clearBuffer() {
 	byte *pSrc = (byte *)getPixels();
 	Common::fill(pSrc, pSrc + w * h, 0);
diff --git a/engines/access/asurface.h b/engines/access/asurface.h
index 776b950..4f172ae 100644
--- a/engines/access/asurface.h
+++ b/engines/access/asurface.h
@@ -46,8 +46,10 @@ public:
 
 	static void init();
 public:
-	virtual void ASurface::plotFrame(SpriteFrame *frame, const Common::Point &pt);
+	virtual void plotFrame(SpriteFrame *frame, const Common::Point &pt);
 public:
+	virtual ~ASurface();
+
 	void clearBuffer();
 
 	void copyBuffer(Graphics::Surface *src) { copyFrom(*src); }
diff --git a/engines/access/screen.h b/engines/access/screen.h
index d759ae1..ba1c229 100644
--- a/engines/access/screen.h
+++ b/engines/access/screen.h
@@ -83,6 +83,8 @@ public:
 public:
 	Screen(AccessEngine *vm);
 
+	virtual ~Screen() {}
+
 	void setDisplayScan();
 
 	void setPanel(int num);


Commit: 79e743ba82b14dce808f3dcda6e173fa6f138137
    https://github.com/scummvm/scummvm/commit/79e743ba82b14dce808f3dcda6e173fa6f138137
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-13T22:54:04-04:00

Commit Message:
ACCESS: Fix more gcc compiler warnings

Changed paths:
    engines/access/amazon/amazon_game.cpp
    engines/access/amazon/amazon_resources.cpp
    engines/access/asurface.cpp
    engines/access/decompress.h
    engines/access/module.mk
    engines/access/room.cpp



diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp
index d0a5b6e..49ae766 100644
--- a/engines/access/amazon/amazon_game.cpp
+++ b/engines/access/amazon/amazon_game.cpp
@@ -140,7 +140,7 @@ void AmazonEngine::doTitle() {
 	_sound->playSound(1);
 
 	const int COUNTDOWN[6] = { 2, 0x80, 1, 0x7d, 0, 0x87 };
-	for (int _pCount = 0; _pCount < 3; ++_pCount) {
+	for (_pCount = 0; _pCount < 3; ++_pCount) {
 		_buffer2.copyFrom(_buffer1);
 		int id = READ_LE_UINT16(COUNTDOWN + _pCount * 4);
 		int xp = READ_LE_UINT16(COUNTDOWN + _pCount * 4 + 2);
diff --git a/engines/access/amazon/amazon_resources.cpp b/engines/access/amazon/amazon_resources.cpp
index 87f2966..15cf190 100644
--- a/engines/access/amazon/amazon_resources.cpp
+++ b/engines/access/amazon/amazon_resources.cpp
@@ -977,7 +977,7 @@ const byte LETTER[] = {
 	0x0, 0x0, 0x0, 0x30, 0x0, 0x5, 0x0, 0xFF, 0xFF
 };
 
-extern const byte *CHARTBL[] = {
+const byte *CHARTBL[] = {
 	ELAINE, LIB, FLASHBACK, ALLENDIE, OVERBOARD, PILOT2, TIKAGENT,
 	BARTENDER, PILOT1, COOK, BEXPLODE, THORNICK, MAYA, CAPTAIN,
 	ALLEN, ARCH, GUARD1, MCANOE, CAMPFIRE, COLONEL, SOLDIERS,
diff --git a/engines/access/asurface.cpp b/engines/access/asurface.cpp
index 619c449..6df8a4a 100644
--- a/engines/access/asurface.cpp
+++ b/engines/access/asurface.cpp
@@ -57,9 +57,9 @@ SpriteResource::~SpriteResource() {
 }
 
 SpriteFrame::SpriteFrame(AccessEngine *vm, Common::MemoryReadStream &stream, int frameSize) {
-	int w = stream.readUint16LE();
-	int h = stream.readUint16LE();
-	create(w, h, Graphics::PixelFormat::createFormatCLUT8());
+	int xSize = stream.readUint16LE();
+	int ySize = stream.readUint16LE();
+	create(xSize, ySize, Graphics::PixelFormat::createFormatCLUT8());
 	
 	// Empty surface
 	byte *data = (byte *)getPixels();
diff --git a/engines/access/decompress.h b/engines/access/decompress.h
index 522bfb2..400aee4 100644
--- a/engines/access/decompress.h
+++ b/engines/access/decompress.h
@@ -1,9 +1,4 @@
 /* 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.
-/* 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
diff --git a/engines/access/module.mk b/engines/access/module.mk
index 7c089fe..6f906a9 100644
--- a/engines/access/module.mk
+++ b/engines/access/module.mk
@@ -17,10 +17,10 @@ MODULE_OBJS := \
 	screen.o \
 	scripts.o \
 	sound.o \
-	amazon\amazon_game.o \
-	amazon\amazon_resources.o \
-	amazon\amazon_room.o \
-	amazon\amazon_scripts.o
+	amazon/amazon_game.o \
+	amazon/amazon_resources.o \
+	amazon/amazon_room.o \
+	amazon/amazon_scripts.o
 
 # This module can be built as a plugin
 ifeq ($(ENABLE_ACCESS), DYNAMIC_PLUGIN)
diff --git a/engines/access/room.cpp b/engines/access/room.cpp
index 3e9e9e6..66231e6 100644
--- a/engines/access/room.cpp
+++ b/engines/access/room.cpp
@@ -445,6 +445,6 @@ RoomInfo::RoomInfo(const byte *data) {
 
 		_sounds.push_back(fi);
 	}
-};
+}
 
 } // End of namespace Access


Commit: cf901ae142044227f5c34c33ab45eb8a0351ce93
    https://github.com/scummvm/scummvm/commit/cf901ae142044227f5c34c33ab45eb8a0351ce93
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-13T23:03:18-04:00

Commit Message:
ACCESS: Give default draw implementations for sprite drawing routines

Changed paths:
    engines/access/asurface.cpp



diff --git a/engines/access/asurface.cpp b/engines/access/asurface.cpp
index 6df8a4a..5824545 100644
--- a/engines/access/asurface.cpp
+++ b/engines/access/asurface.cpp
@@ -226,26 +226,19 @@ void ASurface::copyTo(ASurface *dest, const Common::Point &destPos) {
 }
 
 void ASurface::sPlotB(SpriteFrame *frame, const Common::Point &pt) {
-	error("TODO");
+	frame->copyTo(this, pt);
 }
 
 void ASurface::sPlotF(SpriteFrame *frame, const Common::Point &pt) {
-	error("TODO");
+	frame->copyTo(this, pt);
 }
 
 void ASurface::plotB(SpriteFrame *frame, const Common::Point &pt) {
-	error("TODO");
+	frame->copyTo(this, pt);
 }
 
 void ASurface::copyBlock(ASurface *src, const Common::Rect &bounds) {
-	byte *srcP = (byte *)getBasePtr(bounds.left, bounds.top + _scrollY);
-	byte *destP = (byte *)getBasePtr(bounds.left, bounds.top); /* + _windowYAdd */
-
-	for (int y = 0; y < bounds.height(); ++y) {
-		Common::copy(srcP, srcP + bounds.width(), destP);
-		srcP += src->pitch;
-		destP += this->pitch;
-	}
+	copyRectToSurface(*src, bounds.left, bounds.top, bounds);
 }
 
 } // End of namespace Access


Commit: f66f01bf89b4ae071bdb299e43fd34c1bcb8a3ea
    https://github.com/scummvm/scummvm/commit/f66f01bf89b4ae071bdb299e43fd34c1bcb8a3ea
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-14T20:49:30-04:00

Commit Message:
ACCESS: Implemented player walk methods

Changed paths:
    engines/access/events.cpp
    engines/access/events.h
    engines/access/player.cpp
    engines/access/player.h
    engines/access/screen.cpp
    engines/access/screen.h



diff --git a/engines/access/events.cpp b/engines/access/events.cpp
index 73feefe..88e783e 100644
--- a/engines/access/events.cpp
+++ b/engines/access/events.cpp
@@ -39,6 +39,7 @@ EventsManager::EventsManager(AccessEngine *vm): _vm(vm) {
 	_frameCounter = 10;
 	_priorFrameTime = 0;
 	_leftButton = false;
+	_mouseMove = false;
 }
 
 EventsManager::~EventsManager() {
diff --git a/engines/access/events.h b/engines/access/events.h
index 55f04f1..aa01543 100644
--- a/engines/access/events.h
+++ b/engines/access/events.h
@@ -51,6 +51,7 @@ public:
 	CursorType _cursorId;
 	bool _leftButton;
 	Common::Point _mousePos;
+	bool _mouseMove;
 public:
 	/**
 	 * Constructor
diff --git a/engines/access/player.cpp b/engines/access/player.cpp
index 969df00..6fab689 100644
--- a/engines/access/player.cpp
+++ b/engines/access/player.cpp
@@ -50,6 +50,9 @@ Player::Player(AccessEngine *vm): Manager(vm) {
 	_upDelta = _downDelta = 0;
 	_scrollConst = 0;
 	_roomNumber = 0;
+	_collideFlag = false;
+	_move = NONE;
+	_playerDirection = NONE;
 }
 
 void Player::load() {
@@ -148,7 +151,53 @@ void Player::calcManScale() {
 }
 
 void Player::walk() {
-	warning("TODO: Player::walk");
+	_collideFlag = false;
+	_playerDirection = NONE;
+	
+	if (_playerOff != 0)
+		return;
+	else if (_vm->_timerFlag) {
+		plotCom3();
+		return;
+	}
+
+	switch (_move) {
+	case UP:
+		_vm->_events->_mouseMove = false;
+		walkUp();
+		break;
+	case DOWN:
+		_vm->_events->_mouseMove = false;
+		walkDown();
+		break;
+	case LEFT:
+		_vm->_events->_mouseMove = false;
+		walkLeft();
+		break;
+	case RIGHT:
+		_vm->_events->_mouseMove = false;
+		walkRight();
+		break;
+	case UPLEFT:
+		_vm->_events->_mouseMove = false;
+		walkUpLeft();
+		break;
+	case DOWNLEFT:
+		_vm->_events->_mouseMove = false;
+		walkDownLeft();
+		break;
+	case UPRIGHT:
+		_vm->_events->_mouseMove = false;
+		walkUpRight();
+		break;
+	case DOWNRIGHT:
+		_vm->_events->_mouseMove = false;
+		walkDownRight();
+		break;
+	default:
+		checkMove();
+		break;
+	}
 }
 
 void Player::calcPlayer() {
@@ -159,4 +208,353 @@ void Player::calcPlayer() {
 	_playerY = _rawPlayer.y - scr._bufferStart.y;
 }
 
+void Player::walkUp() {
+	if (_frame > _upWalkMax || _frame < _upWalkMin)
+		_frame = _upWalkMin;
+
+	_playerDirection = UP;
+	int walkOff = _walkOffUp[_frame - _upWalkMin];
+	_rawYTempL = _vm->_screen->_scaleTable2[walkOff];
+	_rawYTemp = _rawPlayer.y - _vm->_screen->_scaleTable1[walkOff];
+	_rawXTemp = _rawPlayer.x;
+
+	if (codeWalls()) {
+		plotCom2();
+	} else {
+		_rawPlayer.y = _rawYTemp;
+		_rawPlayerLow.y = _rawYTempL;
+		
+		calcManScale();
+		if (_vm->_currentMan != 3 && (_frame == 17 || _frame == 21)) {
+			error("TODO: si = 0?");
+			// si = 0
+		}
+
+		if (++_frame > _upWalkMax)
+			_frame = _upWalkMin;
+
+		plotCom(0);
+	}
+}
+
+void Player::walkDown() {
+	if (_frame > _downWalkMax || _frame < _downWalkMin)
+		_frame = _downWalkMin;
+
+	_playerDirection = DOWN;
+	int walkOff = _walkOffDown[_frame - _downWalkMin];
+	_rawYTempL = _vm->_screen->_scaleTable2[walkOff];
+	_rawYTemp = _rawPlayer.y - _vm->_screen->_scaleTable1[walkOff];
+	_rawXTemp = _rawPlayer.x;
+
+	if (codeWalls()) {
+		plotCom2();
+	} else {
+		_rawPlayer.y = _rawYTemp;
+		_rawPlayerLow.y = _rawYTempL;
+
+		calcManScale();
+		if (_vm->_currentMan != 3 && (_frame == 10 || _frame == 14)) {
+			error("TODO: si = 0?");
+			// si = 0
+		}
+
+		if (++_frame > _upWalkMax)
+			_frame = _upWalkMin;
+
+		plotCom(0);
+	}
+}
+
+void Player::walkLeft() {
+	if (_frame > _sideWalkMax || _frame < _sideWalkMin)
+		_frame = _sideWalkMin;
+
+	_playerDirection = LEFT;
+
+	bool flag = _vm->_screen->_scrollEnd == 1;
+	if (!flag) {
+		calcPlayer();
+		flag = (_playerX - _vm->_screen->_scaleTable1[_scrollConst] -
+			_vm->_screen->_scrollThreshold) > 0;
+	}
+	if (flag) {
+		int walkOffset = _walkOffLeft[_frame - _sideWalkMin];
+		_rawTempL = _rawPlayerLow.x - _vm->_screen->_scaleTable2[walkOffset];
+		_rawXTemp = _rawPlayer.x - _vm->_screen->_scaleTable1[walkOffset];
+	} else {
+		_rawXTemp = _rawPlayer.x - _vm->_screen->_scaleTable1[_scrollConst];
+	}	
+	_rawYTemp = _rawPlayer.y;
+
+	if (codeWalls()) {
+		plotCom2();
+	} else {
+		_rawPlayer.x = _rawXTemp;
+		_rawPlayerLow.x = _rawTempL;
+		++_frame;
+
+		if (_vm->_currentMan != 3 && (_frame == 1 || _frame == 5)) {
+			error("TODO: si = 0?");
+		}
+
+		if (_frame > _sideWalkMax)
+			_frame = _sideWalkMin;
+
+		plotCom1();
+	}
+}
+
+void Player::walkRight() {
+	if (_frame > _sideWalkMax || _frame < _sideWalkMin)
+		_frame = _sideWalkMin;
+
+	_playerDirection = RIGHT;
+
+	bool flag = _vm->_screen->_scrollEnd == 2;
+	if (!flag) {
+		calcPlayer();
+		flag = (_vm->_screen->_clipWidth - _playerX - _vm->_screen->_scaleTable1[_scrollConst] -
+			_vm->_screen->_scrollThreshold) > 0;
+	}
+	if (flag) {
+		int walkOffset = _walkOffLeft[_frame - _sideWalkMin];
+		_rawTempL = _rawPlayerLow.x - _vm->_screen->_scaleTable2[walkOffset];
+		_rawXTemp = _rawPlayer.x - _vm->_screen->_scaleTable1[walkOffset];
+	} else {
+		_rawXTemp = _rawPlayer.x - _vm->_screen->_scaleTable1[_scrollConst];
+	}
+	_rawYTemp = _rawPlayer.y;
+
+	if (codeWalls()) {
+		plotCom2();
+	} else {
+		_rawPlayer.x = _rawXTemp;
+		_rawPlayerLow.x = _rawTempL;
+		++_frame;
+
+		if (_vm->_currentMan != 3 && (_frame == 1 || _frame == 5)) {
+			error("TODO: si = 0?");
+		}
+
+		if (_frame > _sideWalkMax)
+			_frame = _sideWalkMin;
+
+		plotCom1();
+	}
+}
+
+void Player::walkUpLeft() {
+	if (_frame > _diagUpWalkMax || _frame < _diagUpWalkMin)
+		_frame = _diagUpWalkMin;
+
+	_playerDirection = UPLEFT;
+
+	int walkOffset;
+	bool flag = _vm->_screen->_scrollEnd == 1;
+	if (!flag) {
+		calcPlayer();
+		flag = (_playerX - _vm->_screen->_scaleTable1[_scrollConst] -
+			_vm->_screen->_scrollThreshold) > 0;
+	}
+	if (flag) {
+		walkOffset = _walkOffUL[_frame - _diagUpWalkMin].x;
+		_rawTempL = _rawPlayerLow.x - _vm->_screen->_scaleTable2[walkOffset];
+		_rawXTemp = _rawPlayer.x - _vm->_screen->_scaleTable1[walkOffset];
+	} else {
+		_rawXTemp = _rawPlayer.x - _vm->_screen->_scaleTable1[_scrollConst];
+	}
+	
+	walkOffset = _walkOffUL[_frame - _diagUpWalkMin].y;
+	_rawYTempL = _rawPlayerLow.y - _vm->_screen->_scaleTable2[walkOffset];
+	_rawYTemp = _rawPlayer.y - _vm->_screen->_scaleTable1[walkOffset];
+
+	if (codeWalls()) {
+		plotCom2();
+	} else {
+		_rawPlayer.x = _rawXTemp;
+		_rawPlayer.y = _rawYTemp;
+		_rawPlayerLow.x = _rawTempL;
+		_rawPlayerLow.y = _rawYTempL;
+
+		++_frame;
+		calcManScale();
+
+		if (_vm->_currentMan != 3 && (_frame == 1 || _frame == 5)) {
+			error("TODO: si = 0?");
+		}
+
+		if (_frame > _diagUpWalkMax)
+			_frame = _diagUpWalkMin;
+
+		plotCom1();
+	}
+}
+
+void Player::walkDownLeft() {
+	if (_frame > _diagDownWalkMax || _frame < _diagDownWalkMin)
+		_frame = _diagDownWalkMin;
+
+	_playerDirection = DOWNLEFT;
+
+	int walkOffset;
+	bool flag = _vm->_screen->_scrollEnd == 1;
+	if (!flag) {
+		calcPlayer();
+		flag = (_playerX - _vm->_screen->_scaleTable1[_scrollConst] -
+			_vm->_screen->_scrollThreshold) > 0;
+	}
+	if (flag) {
+		walkOffset = _walkOffDL[_frame - _sideWalkMin].x;
+		_rawTempL = _rawPlayerLow.x - _vm->_screen->_scaleTable2[walkOffset];
+		_rawXTemp = _rawPlayer.x - _vm->_screen->_scaleTable1[walkOffset];
+	} else {
+		_rawXTemp = _rawPlayer.x - _vm->_screen->_scaleTable1[_scrollConst];
+	}
+
+	walkOffset = _walkOffDL[_frame - _diagDownWalkMin].y;
+	_rawYTempL = _rawPlayerLow.y - _vm->_screen->_scaleTable2[walkOffset];
+	_rawYTemp = _rawPlayer.y - _vm->_screen->_scaleTable1[walkOffset];
+
+	if (codeWalls()) {
+		plotCom2();
+	} else {
+		_rawPlayer.x = _rawXTemp;
+		_rawPlayer.y = _rawYTemp;
+		_rawPlayerLow.x = _rawTempL;
+		_rawPlayerLow.y = _rawYTempL;
+
+		++_frame;
+		calcManScale();
+		
+		if (_vm->_currentMan != 3 && (_frame == 1 || _frame == 5)) {
+			error("TODO: si = 0?");
+		}
+
+		if (_frame > _diagDownWalkMax)
+			_frame = _diagDownWalkMin;
+
+		plotCom1();
+	}
+}
+
+void Player::walkUpRight() {
+	if (_frame > _diagUpWalkMax || _frame < _diagUpWalkMin)
+		_frame = _diagUpWalkMin;
+
+	_playerDirection = UPLEFT;
+
+	int walkOffset;
+	bool flag = _vm->_screen->_scrollEnd == 1;
+	if (!flag) {
+		calcPlayer();
+		flag = (_vm->_screen->_clipWidth - _playerX - _vm->_screen->_scaleTable1[_scrollConst] -
+			_vm->_screen->_scrollThreshold) > 0;
+	}
+	if (flag) {
+		walkOffset = _walkOffUR[_frame - _diagUpWalkMin].x;
+		_rawTempL = _rawPlayerLow.x - _vm->_screen->_scaleTable2[walkOffset];
+		_rawXTemp = _rawPlayer.x - _vm->_screen->_scaleTable1[walkOffset];
+	} else {
+		_rawXTemp = _rawPlayer.x - _vm->_screen->_scaleTable1[_scrollConst];
+	}
+
+	walkOffset = _walkOffUL[_frame - _diagUpWalkMin].y;
+	_rawYTempL = _rawPlayerLow.y - _vm->_screen->_scaleTable2[walkOffset];
+	_rawYTemp = _rawPlayer.y - _vm->_screen->_scaleTable1[walkOffset];
+
+	if (codeWalls()) {
+		plotCom2();
+	} else {
+		_rawPlayer.x = _rawXTemp;
+		_rawPlayer.y = _rawYTemp;
+		_rawPlayerLow.x = _rawTempL;
+		_rawPlayerLow.y = _rawYTempL;
+
+		++_frame;
+		calcManScale();
+
+		if (_vm->_currentMan != 3 && (_frame == 1 || _frame == 5)) {
+			error("TODO: si = 0?");
+		}
+
+		if (_frame > _diagUpWalkMax)
+			_frame = _diagUpWalkMin;
+
+		plotCom(0);
+	}
+}
+
+void Player::walkDownRight() {
+	if (_frame > _diagDownWalkMax || _frame < _diagDownWalkMin)
+		_frame = _diagDownWalkMin;
+
+	_playerDirection = DOWNRIGHT;
+
+	int walkOffset;
+	bool flag = _vm->_screen->_scrollEnd == 1;
+	if (!flag) {
+		calcPlayer();
+		flag = (_playerX - _vm->_screen->_scaleTable1[_scrollConst] -
+			_vm->_screen->_scrollThreshold) > 0;
+	}
+	if (flag) {
+		walkOffset = _walkOffUR[_frame - _sideWalkMin].x;
+		_rawTempL = _rawPlayerLow.x - _vm->_screen->_scaleTable2[walkOffset];
+		_rawXTemp = _rawPlayer.x - _vm->_screen->_scaleTable1[walkOffset];
+	}
+	else {
+		_rawXTemp = _rawPlayer.x - _vm->_screen->_scaleTable1[_scrollConst];
+	}
+
+	walkOffset = _walkOffDR[_frame - _diagDownWalkMin].y;
+	_rawYTempL = _rawPlayerLow.y - _vm->_screen->_scaleTable2[walkOffset];
+	_rawYTemp = _rawPlayer.y - _vm->_screen->_scaleTable1[walkOffset];
+
+	if (codeWalls()) {
+		plotCom2();
+	} else {
+		_rawPlayer.x = _rawXTemp;
+		_rawPlayer.y = _rawYTemp;
+		_rawPlayerLow.x = _rawTempL;
+		_rawPlayerLow.y = _rawYTempL;
+
+		++_frame;
+		calcManScale();
+
+		if (_vm->_currentMan != 3 && (_frame == 1 || _frame == 5)) {
+			error("TODO: si = 0?");
+		}
+
+		if (_frame > _diagDownWalkMax)
+			_frame = _diagDownWalkMin;
+
+		plotCom1();
+	}
+}
+
+void Player::checkMove() {
+	error("TODO");
+}
+
+void Player::plotCom(int v) {
+	error("TODO");
+}
+
+void Player::plotCom1() {
+	plotCom(2);
+}
+
+void Player::plotCom2() {
+	error("TODO");
+}
+
+void Player::plotCom3() {
+	error("TODO");
+}
+
+bool Player::codeWalls() {
+	error("TODO");
+}
+
 } // End of namespace Access
diff --git a/engines/access/player.h b/engines/access/player.h
index b491ed7..2818970 100644
--- a/engines/access/player.h
+++ b/engines/access/player.h
@@ -31,6 +31,9 @@ namespace Access {
 
 #define PLAYER_DATA_COUNT 8
 
+enum Direction { NONE = 0, UP = 1, DOWN = 2, LEFT = 3, RIGHT = 4,
+	UPRIGHT = 5, DOWNRIGHT = 6, UPLEFT = 7, DOWNLEFT = 8 };
+
 class AccessEngine;
 
 class Player: public Manager {
@@ -44,6 +47,25 @@ private:
 	int _diagUpWalkMin, _diagUpWalkMax;
 	int _diagDownWalkMin, _diagDownWalkMax;
 	Common::Point _guard;
+	bool _collideFlag;
+	Direction _playerDirection;
+	Direction _move;
+
+	bool codeWalls();
+	void checkMove();
+	void plotCom(int v1);
+	void plotCom1();
+	void plotCom2();
+	void plotCom3();
+
+	void walkUp();
+	void walkDown();
+	void walkLeft();
+	void walkRight();
+	void walkUpLeft();
+	void walkDownLeft();
+	void walkUpRight();
+	void walkDownRight();
 public:
 	// Fields in original Player structure
 	int _field0;
diff --git a/engines/access/screen.cpp b/engines/access/screen.cpp
index 4673bb6..ca87784 100644
--- a/engines/access/screen.cpp
+++ b/engines/access/screen.cpp
@@ -52,6 +52,7 @@ Screen::Screen(AccessEngine *vm) : _vm(vm) {
 	_scrollCol = _scrollRow = 0;
 	_windowXAdd = _windowYAdd = 0;
 	_screenYOff = 0;
+	_scrollEnd = 0;
 
 	_bufferBytesWide = _vWindowBytesWide = this->w;
 	_vWindowLinesTall = this->h;
diff --git a/engines/access/screen.h b/engines/access/screen.h
index ba1c229..5ac6931 100644
--- a/engines/access/screen.h
+++ b/engines/access/screen.h
@@ -80,6 +80,7 @@ public:
 	int _vWindowBytesWide;
 	int _bufferBytesWide;
 	int _vWindowLinesTall;
+	int _scrollEnd;
 public:
 	Screen(AccessEngine *vm);
 


Commit: 9547efad776899d1ff49a22e1baa5893080e5830
    https://github.com/scummvm/scummvm/commit/9547efad776899d1ff49a22e1baa5893080e5830
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-14T22:02:47-04:00

Commit Message:
ACCESS: Implemented player plotting methods

Changed paths:
    engines/access/access.cpp
    engines/access/access.h
    engines/access/amazon/amazon_room.cpp
    engines/access/animation.cpp
    engines/access/asurface.cpp
    engines/access/asurface.h
    engines/access/player.cpp
    engines/access/player.h
    engines/access/room.cpp



diff --git a/engines/access/access.cpp b/engines/access/access.cpp
index 2ffc479..ad84058 100644
--- a/engines/access/access.cpp
+++ b/engines/access/access.cpp
@@ -51,10 +51,7 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc)
 	_mouseMode = 0;
 	_currentMan = 0;
 	_currentManOld = -1;
-	_man = nullptr;
-	_man1 = nullptr;
 	_inactive = nullptr;
-	_manPal1 = nullptr;
 	_music = nullptr;
 	_title = nullptr;
 	_converseMode = 0;
@@ -115,9 +112,7 @@ AccessEngine::~AccessEngine() {
 	delete _sound;
 
 	freeCells();
-	delete[] _man1;
 	delete[] _inactive;
-	delete[] _manPal1;
 	delete[] _music;
 	delete[] _title;
 }
@@ -207,11 +202,6 @@ void AccessEngine::freeInactiveData() {
 	_inactive = nullptr;
 }
 
-void AccessEngine::freeManData() {
-	delete[] _man;
-	_man = nullptr;
-}
-
 void AccessEngine::establish(int v) {
 	_establishMode = 0;
 	_establishGroup = 0;
diff --git a/engines/access/access.h b/engines/access/access.h
index d919ae8..1e83c6e 100644
--- a/engines/access/access.h
+++ b/engines/access/access.h
@@ -70,15 +70,6 @@ enum AccessDebugChannels {
 
 struct AccessGameDescription;
 
-class ImageEntry {
-public:
-	int _frameNumber;
-	SpriteResource *_spritesPtr;
-	int _priority;
-	Common::Point _position;
-	int _flags;
-};
-
 class AccessEngine : public Engine {
 private:
 	/**
@@ -137,17 +128,14 @@ public:
 	Common::Array<Common::Rect> _newRects;
 	Common::Array<Common::Rect> _oldRects;
 	Common::Array<ExtraCell> _extraCells;
-	Common::Array<ImageEntry> _images;
+	ImageEntryList _images;
 	int _pCount;
 	int _selectCommand;
 	bool _normalMouse;
 	int _mouseMode;
 
 	int _currentManOld;
-	byte *_man;
-	byte *_man1;
 	byte *_inactive;
-	byte *_manPal1;
 	byte *_music;
 	byte *_title;
 	int _converseMode;
@@ -222,11 +210,6 @@ public:
 	 */
 	void freeInactiveData();
 
-	/**
-	 * Free animation data
-	 */
-	void freeManData();
-
 	void establish(int v);
 
 	void establishCenter(int v);
diff --git a/engines/access/amazon/amazon_room.cpp b/engines/access/amazon/amazon_room.cpp
index db16397..5cb1dfe 100644
--- a/engines/access/amazon/amazon_room.cpp
+++ b/engines/access/amazon/amazon_room.cpp
@@ -51,15 +51,15 @@ void AmazonRoom::reloadRoom() {
 		
 		switch (_vm->_currentMan) {
 		case 0:
-			_vm->_man1 = _vm->_files->loadFile("MAN.LZ");
+			_vm->_player->loadSprites("MAN.LZ");
 			break;
 
 		case 2:
-			_vm->_man1 = _vm->_files->loadFile("JMAN.LZ");
+			_vm->_player->loadSprites("JMAN.LZ");
 			break;
 
 		case 3:
-			_vm->_man1 = _vm->_files->loadFile("OVERHEAD.LZ");
+			_vm->_player->loadSprites("OVERHEAD.LZ");
 			_vm->_manScaleOff = 1;
 			break;
 
diff --git a/engines/access/animation.cpp b/engines/access/animation.cpp
index 20772af..4965f41 100644
--- a/engines/access/animation.cpp
+++ b/engines/access/animation.cpp
@@ -210,10 +210,6 @@ void Animation::setFrame(AnimationFrame *frame) {
 	setFrame1(frame);
 }
 
-static bool sortImagesY(const ImageEntry &ie1, const ImageEntry &ie2) {
-	return ie1._priority < ie2._priority;
-}
-
 void Animation::setFrame1(AnimationFrame *frame) {
 	_vm->_animation->_base.x = frame->_baseX;
 	_vm->_animation->_base.y = frame->_baseY;
@@ -234,9 +230,7 @@ void Animation::setFrame1(AnimationFrame *frame) {
 		ie._position = part->_position + _vm->_animation->_base;
 		ie._priority = part->_priority - ie._position.y;
 
-		assert(_vm->_images.size() < 35);
-		_vm->_images.push_back(ie);
-		Common::sort(_vm->_images.begin(), _vm->_images.end(), sortImagesY);
+		_vm->_images.addToList(&ie);
 	}
 }
 
diff --git a/engines/access/asurface.cpp b/engines/access/asurface.cpp
index 5824545..ed614df 100644
--- a/engines/access/asurface.cpp
+++ b/engines/access/asurface.cpp
@@ -82,6 +82,18 @@ SpriteFrame::~SpriteFrame() {
 
 /*------------------------------------------------------------------------*/
 
+static bool sortImagesY(const ImageEntry &ie1, const ImageEntry &ie2) {
+	return ie1._priority < ie2._priority;
+}
+
+void ImageEntryList::addToList(ImageEntry *ie) {
+	assert(size() < 35);
+	push_back(*ie);
+	Common::sort(begin(), end(), sortImagesY);
+}
+
+/*------------------------------------------------------------------------*/
+
 int ASurface::_leftSkip;
 int ASurface::_rightSkip;
 int ASurface::_topSkip;
diff --git a/engines/access/asurface.h b/engines/access/asurface.h
index 4f172ae..d660ff6 100644
--- a/engines/access/asurface.h
+++ b/engines/access/asurface.h
@@ -88,6 +88,19 @@ public:
 	SpriteFrame *getFrame(int idx) { return _frames[idx]; }
 };
 
+class ImageEntry {
+public:
+	int _frameNumber;
+	SpriteResource *_spritesPtr;
+	int _priority;
+	Common::Point _position;
+	int _flags;
+};
+
+class ImageEntryList : public Common::Array<ImageEntry> {
+public:
+	void addToList(ImageEntry *ie);
+};
 
 } // End of namespace Access
 
diff --git a/engines/access/player.cpp b/engines/access/player.cpp
index 6fab689..7c07c69 100644
--- a/engines/access/player.cpp
+++ b/engines/access/player.cpp
@@ -28,13 +28,16 @@
 
 namespace Access {
 
-Player::Player(AccessEngine *vm): Manager(vm) {
+Player::Player(AccessEngine *vm): Manager(vm), ImageEntry() {
 	Common::fill(&_walkOffRight[0], &_walkOffRight[PLAYER_DATA_COUNT], 0);
 	Common::fill(&_walkOffLeft[0], &_walkOffLeft[PLAYER_DATA_COUNT], 0);
 	Common::fill(&_walkOffUp[0], &_walkOffUp[PLAYER_DATA_COUNT], 0);
 	Common::fill(&_walkOffDown[0], &_walkOffDown[PLAYER_DATA_COUNT], 0);
 
-	_field0 = 0;
+	_playerSprites = nullptr;
+	_playerSprites1 = nullptr;
+	_manPal1 = nullptr;
+	_frameNumber = 0;
 	_monData = nullptr;
 	_rawTempL = 0;
 	_rawXTemp = 0;
@@ -53,6 +56,12 @@ Player::Player(AccessEngine *vm): Manager(vm) {
 	_collideFlag = false;
 	_move = NONE;
 	_playerDirection = NONE;
+	_xFlag = _yFlag = 0;
+}
+
+Player::~Player() {
+	delete _playerSprites1;
+	delete[] _manPal1;
 }
 
 void Player::load() {
@@ -131,14 +140,28 @@ void Player::load() {
 		_diagDownWalkMax = 7;
 	}
 
-	_vm->_man = _vm->_man1;
-	if (_vm->_manPal1) {
-		Common::copy(_vm->_manPal1 + 0x270, _vm->_manPal1 + 0x270 + 0x60, _vm->_screen->_manPal);
+	_playerSprites = _playerSprites1;
+	if (_manPal1) {
+		Common::copy(_manPal1 + 0x270, _manPal1 + 0x270 + 0x60, _vm->_screen->_manPal);
 	} else {
 		Common::fill(_vm->_screen->_manPal, _vm->_screen->_manPal + 0x60, 0);
 	}
 }
 
+void Player::loadSprites(const Common::String &name) {
+	delete _playerSprites1;
+	_playerSprites = nullptr;
+
+	const byte *data = _vm->_files->loadFile(name);
+	_playerSprites1 = new SpriteResource(_vm, data, _vm->_files->_filesize,
+		DisposeAfterUse::YES);
+}
+
+void Player::freeSprites() {
+	delete _playerSprites;
+	_playerSprites = nullptr;
+}
+
 void Player::calcManScale() {
 	if (!_vm->_manScaleOff) {
 		_vm->_scale = (((_rawPlayer.y - _vm->_scaleMaxY + _vm->_scaleN1) * 
@@ -534,11 +557,80 @@ void Player::walkDownRight() {
 }
 
 void Player::checkMove() {
-	error("TODO");
+	if (!_vm->_events->_mouseMove)
+		return;
+
+	if (_xFlag == 0 && _yFlag == 0) {
+		int xp = (_playerOffset.x / 2) + _rawPlayer.x - _moveTo.x;
+		if (xp < 0)
+			xp = -xp;
+		int yp = _rawPlayer.y - _moveTo.y;
+		if (yp < 0)
+			yp = -yp;
+
+		if (xp < yp)
+			_xFlag = 1;
+		else
+			_yFlag = 1;
+	}
+
+	if (_yFlag == 1) {
+		int yd = _rawPlayer.y - _moveTo.y;
+		if ((yd >= 0 && yd <= _upDelta) || (yd < 0 && -yd <= _upDelta)) {
+			++_yFlag;
+			if (_xFlag) {
+				_vm->_events->_mouseMove = false;
+				_xFlag = _yFlag = 0;
+			} else {
+				++_xFlag;
+			}
+		} else {
+			if (yd >= 0)
+				walkUp();
+			else
+				walkDown();
+
+			if (_collideFlag) {
+				_vm->_events->_mouseMove = false;
+				_xFlag = _yFlag = 0;
+			}
+		}
+	} else if (_xFlag == 1) {
+		int xd = _rawPlayer.x - _moveTo.x;
+		if ((xd >= 0 && xd <= -_leftDelta) || (xd < 0 && -xd <= -_leftDelta)) {
+			++_xFlag;
+
+			if (_yFlag) {
+				_vm->_events->_mouseMove = false;
+				_xFlag = _yFlag = 0;
+			}
+		} else {
+			if (xd >= 0)
+				walkLeft();
+			else
+				walkRight();
+
+			if (_collideFlag) {
+				_vm->_events->_mouseMove = false;
+				_xFlag = _yFlag = 0;
+			}
+		}
+	} else if (!_yFlag) {
+		++_yFlag;
+	} else {
+		_vm->_events->_mouseMove = false;
+		_xFlag = _yFlag = 0;
+	}
+	
+	plotCom3();
 }
 
-void Player::plotCom(int v) {
-	error("TODO");
+void Player::plotCom(int flags) {
+	_flags &= ~2;
+	_flags &= ~8;
+	_flags |= flags;
+
+	plotCom3();
 }
 
 void Player::plotCom1() {
@@ -546,11 +638,18 @@ void Player::plotCom1() {
 }
 
 void Player::plotCom2() {
-	error("TODO");
+	if (_playerOff != 1)
+		_vm->_images.addToList(this);
 }
 
 void Player::plotCom3() {
-	error("TODO");
+	// Update the base ImageEntry fields for the player
+	_position = _rawPlayer;
+	_priority = _playerOffset.y;
+	_spritesPtr = _playerSprites;
+	_frameNumber = _frame;
+
+	plotCom2();
 }
 
 bool Player::codeWalls() {
diff --git a/engines/access/player.h b/engines/access/player.h
index 2818970..a016783 100644
--- a/engines/access/player.h
+++ b/engines/access/player.h
@@ -25,6 +25,7 @@
 
 #include "common/scummsys.h"
 #include "common/rect.h"
+#include "access/asurface.h"
 #include "access/data.h"
 
 namespace Access {
@@ -36,7 +37,7 @@ enum Direction { NONE = 0, UP = 1, DOWN = 2, LEFT = 3, RIGHT = 4,
 
 class AccessEngine;
 
-class Player: public Manager {
+class Player: public ImageEntry, Manager {
 private:
 	int _leftDelta, _rightDelta;
 	int _upDelta, _downDelta;
@@ -50,6 +51,11 @@ private:
 	bool _collideFlag;
 	Direction _playerDirection;
 	Direction _move;
+	int _xFlag, _yFlag;
+	Common::Point _moveTo;
+	SpriteResource *_playerSprites;
+	SpriteResource *_playerSprites1;
+	byte *_manPal1;
 
 	bool codeWalls();
 	void checkMove();
@@ -68,7 +74,6 @@ private:
 	void walkDownRight();
 public:
 	// Fields in original Player structure
-	int _field0;
 	byte *_monData;
 	int _walkOffRight[PLAYER_DATA_COUNT];
 	int _walkOffLeft[PLAYER_DATA_COUNT];
@@ -98,9 +103,14 @@ public:
 	Common::Point _rawPlayer;
 public:
 	Player(AccessEngine *vm);
+	~Player();
 
 	void load();
 
+	void loadSprites(const Common::String &name);
+
+	void freeSprites();
+
 	void calcManScale();
 
 	void walk();
diff --git a/engines/access/room.cpp b/engines/access/room.cpp
index 66231e6..80bcc00 100644
--- a/engines/access/room.cpp
+++ b/engines/access/room.cpp
@@ -150,7 +150,7 @@ void Room::clearRoom() {
 	_vm->freeCells();
 	freePlayField();
 	_vm->freeInactiveData();
-	_vm->freeManData();
+	_vm->_player->freeSprites();
 }
 
 void Room::loadRoomData(const byte *roomData) {


Commit: 66b2d471cf9cd23afe7b9d409a1cc5bd9f92464b
    https://github.com/scummvm/scummvm/commit/66b2d471cf9cd23afe7b9d409a1cc5bd9f92464b
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-14T22:06:19-04:00

Commit Message:
ACCESS: Change walking errors to TODO comments

Changed paths:
    engines/access/player.cpp



diff --git a/engines/access/player.cpp b/engines/access/player.cpp
index 7c07c69..8cd129f 100644
--- a/engines/access/player.cpp
+++ b/engines/access/player.cpp
@@ -249,8 +249,7 @@ void Player::walkUp() {
 		
 		calcManScale();
 		if (_vm->_currentMan != 3 && (_frame == 17 || _frame == 21)) {
-			error("TODO: si = 0?");
-			// si = 0
+			// TODO: si = 0?
 		}
 
 		if (++_frame > _upWalkMax)
@@ -278,8 +277,7 @@ void Player::walkDown() {
 
 		calcManScale();
 		if (_vm->_currentMan != 3 && (_frame == 10 || _frame == 14)) {
-			error("TODO: si = 0?");
-			// si = 0
+			// TODO: si = 0?
 		}
 
 		if (++_frame > _upWalkMax)
@@ -318,7 +316,7 @@ void Player::walkLeft() {
 		++_frame;
 
 		if (_vm->_currentMan != 3 && (_frame == 1 || _frame == 5)) {
-			error("TODO: si = 0?");
+			// TODO: si = 0?
 		}
 
 		if (_frame > _sideWalkMax)
@@ -357,7 +355,7 @@ void Player::walkRight() {
 		++_frame;
 
 		if (_vm->_currentMan != 3 && (_frame == 1 || _frame == 5)) {
-			error("TODO: si = 0?");
+			// TODO: si = 0?
 		}
 
 		if (_frame > _sideWalkMax)
@@ -404,7 +402,7 @@ void Player::walkUpLeft() {
 		calcManScale();
 
 		if (_vm->_currentMan != 3 && (_frame == 1 || _frame == 5)) {
-			error("TODO: si = 0?");
+			// TODO: si = 0?
 		}
 
 		if (_frame > _diagUpWalkMax)
@@ -451,7 +449,7 @@ void Player::walkDownLeft() {
 		calcManScale();
 		
 		if (_vm->_currentMan != 3 && (_frame == 1 || _frame == 5)) {
-			error("TODO: si = 0?");
+			// TODO: si = 0?
 		}
 
 		if (_frame > _diagDownWalkMax)
@@ -498,7 +496,7 @@ void Player::walkUpRight() {
 		calcManScale();
 
 		if (_vm->_currentMan != 3 && (_frame == 1 || _frame == 5)) {
-			error("TODO: si = 0?");
+			// TODO: si = 0?
 		}
 
 		if (_frame > _diagUpWalkMax)
@@ -546,7 +544,7 @@ void Player::walkDownRight() {
 		calcManScale();
 
 		if (_vm->_currentMan != 3 && (_frame == 1 || _frame == 5)) {
-			error("TODO: si = 0?");
+			// TODO: si = 0?
 		}
 
 		if (_frame > _diagDownWalkMax)


Commit: 4a3ce2d27dabc2abe6e562089df4f37859e410f9
    https://github.com/scummvm/scummvm/commit/4a3ce2d27dabc2abe6e562089df4f37859e410f9
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-15T09:27:05-04:00

Commit Message:
ACCESS: Implementing checkScroll

Changed paths:
    engines/access/player.cpp
    engines/access/player.h
    engines/access/room.cpp
    engines/access/room.h
    engines/access/screen.cpp
    engines/access/screen.h



diff --git a/engines/access/player.cpp b/engines/access/player.cpp
index 8cd129f..a50b835 100644
--- a/engines/access/player.cpp
+++ b/engines/access/player.cpp
@@ -52,6 +52,10 @@ Player::Player(AccessEngine *vm): Manager(vm), ImageEntry() {
 	_leftDelta = _rightDelta = 0;
 	_upDelta = _downDelta = 0;
 	_scrollConst = 0;
+	_scrollFlag = false;
+	_scrollThreshold = 0;
+	_scrollAmount = 0;
+	_scrollEnd = 0;
 	_roomNumber = 0;
 	_collideFlag = false;
 	_move = NONE;
@@ -293,11 +297,11 @@ void Player::walkLeft() {
 
 	_playerDirection = LEFT;
 
-	bool flag = _vm->_screen->_scrollEnd == 1;
+	bool flag = _scrollEnd == 1;
 	if (!flag) {
 		calcPlayer();
 		flag = (_playerX - _vm->_screen->_scaleTable1[_scrollConst] -
-			_vm->_screen->_scrollThreshold) > 0;
+			_vm->_player->_scrollThreshold) > 0;
 	}
 	if (flag) {
 		int walkOffset = _walkOffLeft[_frame - _sideWalkMin];
@@ -332,11 +336,11 @@ void Player::walkRight() {
 
 	_playerDirection = RIGHT;
 
-	bool flag = _vm->_screen->_scrollEnd == 2;
+	bool flag = _scrollEnd == 2;
 	if (!flag) {
 		calcPlayer();
 		flag = (_vm->_screen->_clipWidth - _playerX - _vm->_screen->_scaleTable1[_scrollConst] -
-			_vm->_screen->_scrollThreshold) > 0;
+			_vm->_player->_scrollThreshold) > 0;
 	}
 	if (flag) {
 		int walkOffset = _walkOffLeft[_frame - _sideWalkMin];
@@ -372,11 +376,11 @@ void Player::walkUpLeft() {
 	_playerDirection = UPLEFT;
 
 	int walkOffset;
-	bool flag = _vm->_screen->_scrollEnd == 1;
+	bool flag = _scrollEnd == 1;
 	if (!flag) {
 		calcPlayer();
 		flag = (_playerX - _vm->_screen->_scaleTable1[_scrollConst] -
-			_vm->_screen->_scrollThreshold) > 0;
+			_vm->_player->_scrollThreshold) > 0;
 	}
 	if (flag) {
 		walkOffset = _walkOffUL[_frame - _diagUpWalkMin].x;
@@ -419,11 +423,11 @@ void Player::walkDownLeft() {
 	_playerDirection = DOWNLEFT;
 
 	int walkOffset;
-	bool flag = _vm->_screen->_scrollEnd == 1;
+	bool flag = _scrollEnd == 1;
 	if (!flag) {
 		calcPlayer();
 		flag = (_playerX - _vm->_screen->_scaleTable1[_scrollConst] -
-			_vm->_screen->_scrollThreshold) > 0;
+			_vm->_player->_scrollThreshold) > 0;
 	}
 	if (flag) {
 		walkOffset = _walkOffDL[_frame - _sideWalkMin].x;
@@ -466,11 +470,11 @@ void Player::walkUpRight() {
 	_playerDirection = UPLEFT;
 
 	int walkOffset;
-	bool flag = _vm->_screen->_scrollEnd == 1;
+	bool flag = _scrollEnd == 1;
 	if (!flag) {
 		calcPlayer();
 		flag = (_vm->_screen->_clipWidth - _playerX - _vm->_screen->_scaleTable1[_scrollConst] -
-			_vm->_screen->_scrollThreshold) > 0;
+			_vm->_player->_scrollThreshold) > 0;
 	}
 	if (flag) {
 		walkOffset = _walkOffUR[_frame - _diagUpWalkMin].x;
@@ -513,11 +517,11 @@ void Player::walkDownRight() {
 	_playerDirection = DOWNRIGHT;
 
 	int walkOffset;
-	bool flag = _vm->_screen->_scrollEnd == 1;
+	bool flag = _scrollEnd == 1;
 	if (!flag) {
 		calcPlayer();
 		flag = (_playerX - _vm->_screen->_scaleTable1[_scrollConst] -
-			_vm->_screen->_scrollThreshold) > 0;
+			_vm->_player->_scrollThreshold) > 0;
 	}
 	if (flag) {
 		walkOffset = _walkOffUR[_frame - _sideWalkMin].x;
@@ -654,4 +658,151 @@ bool Player::codeWalls() {
 	error("TODO");
 }
 
+void Player::checkScroll() {
+	_scrollFlag = false;
+	if (_playerDirection == NONE)
+		return;
+
+	if ((_playerDirection == UPLEFT || _playerDirection == DOWNLEFT ||
+			_playerDirection == LEFT) && _playerX <= _scrollThreshold) {
+		// Scroll right
+		_scrollAmount = -(_playerX - _scrollThreshold);
+		_scrollFlag = true;
+		_vm->_screen->_scrollX -= _scrollAmount;
+		if (_vm->_screen->_scrollX < 0) {
+			_scrollFlag = true;
+			_vm->_screen->_scrollX += _scrollAmount;
+
+			while (_vm->_screen->_scrollX >= TILE_WIDTH && !_vm->shouldQuit()) {
+				_vm->_screen->_scrollX -= TILE_WIDTH;
+				_vm->_screen->moveBufferLeft();
+				_vm->_room->buildColumn(_vm->_screen->_scrollCol -
+					_vm->_screen->_vWindowWidth, _vm->_screen->_vWindowBytesWide);
+
+				if (_vm->_screen->_scrollX < TILE_WIDTH && _playerDirection != UPRIGHT) {
+					if (_playerDirection != DOWNRIGHT)
+						return;
+					goto finish;
+				}
+			}
+
+			_scrollEnd = 1;
+			_vm->_screen->_scrollX = 0;
+			_vm->_screen->_scrollCol = 0;
+		}
+	} else if ((_playerDirection == UPRIGHT || _playerDirection == DOWNRIGHT ||
+			_playerDirection == RIGHT) && (_vm->_screen->_clipWidth -
+			_playerX - _scrollThreshold) <= 0) {
+		// Scroll left
+		_scrollAmount = -(_vm->_screen->_clipWidth - _playerX - _scrollThreshold);
+		if ((_vm->_rScrollCol + _vm->_screen->_vWindowWidth) == _vm->_room->_playFieldWidth) {
+			_scrollEnd = 2;
+			_vm->_screen->_scrollX = 0;
+			_scrollFlag = true;
+		} else {
+			_scrollFlag = true;
+			_vm->_screen->_scrollX = _vm->_screen->_scrollX + _scrollAmount;
+
+			while (_vm->_screen->_scrollX >= TILE_WIDTH && !_vm->shouldQuit()) {
+				_vm->_screen->_scrollX -= TILE_WIDTH;
+				++_vm->_screen->_scrollCol;
+				_vm->_screen->moveBufferLeft();
+				_vm->_room->buildColumn(_vm->_screen->_scrollCol +
+					_vm->_screen->_vWindowWidth, _vm->_screen->_vWindowBytesWide);
+
+				if (_vm->_screen->_scrollX < TILE_WIDTH && _playerDirection != UPRIGHT) {
+					if (_playerDirection != DOWNRIGHT)
+						return;
+					goto finish;
+				}
+			}
+
+			_scrollEnd = 2;
+			_vm->_screen->_scrollX = 0;
+			_scrollFlag = true;
+		}
+	}
+
+	if ((_playerDirection == UPRIGHT || _playerDirection == UPLEFT ||
+			_playerDirection == UP) && _playerY <= _scrollThreshold) {
+		_scrollAmount = -(_playerY - _scrollThreshold);
+		_scrollFlag = true;
+		_vm->_screen->_scrollY -= _scrollAmount;
+		if (_vm->_screen->_scrollY >= 0)
+			return;
+
+		do {
+			_vm->_screen->_scrollY += TILE_HEIGHT;
+			if (--_vm->_screen->_scrollRow < 0)
+				break;
+
+			_vm->_screen->moveBufferDown();
+			_vm->_room->buildRow(_vm->_screen->_scrollRow, 0);
+
+			if (_vm->_screen->_scrollY >= 0)
+				return;
+		} while (!_vm->shouldQuit());
+
+		_scrollEnd = 3;
+		_vm->_screen->_scrollY = 0;
+		_vm->_screen->_scrollRow = 0;
+		return;
+	}
+
+finish:
+	if ((_playerDirection == DOWNRIGHT || _playerDirection == DOWNLEFT ||
+			_playerDirection == DOWN) && (_vm->_screen->_clipHeight -
+			_playerY - _scrollThreshold) <= 0) {
+		// Scroll up
+		if (scrollUp()) {
+			_scrollEnd = 4;
+			_vm->_screen->_scrollY = TILE_HEIGHT;
+			_scrollFlag = true;
+		}
+	}
+}
+
+bool Player::scrollUp() {
+	_scrollAmount = -(_vm->_screen->_clipHeight - _playerY - _scrollThreshold);
+	if ((_vm->_screen->_scrollRow + _vm->_screen->_vWindowHeight) >=
+			_vm->_room->_playFieldHeight)
+		return true;
+
+	_scrollFlag = true;
+	_vm->_screen->_scrollY = _vm->_screen->_scrollY + _scrollAmount;
+
+	while (_vm->_screen->_scrollY >= TILE_HEIGHT && !_vm->shouldQuit()) {
+			_vm->_screen->_scrollY -= TILE_HEIGHT;
+		++_vm->_screen->_scrollRow;
+		_vm->_screen->moveBufferUp();
+
+		_vm->_room->buildRow(_vm->_screen->_scrollRow + _vm->_screen->_vWindowHeight,
+			_vm->_screen->_vWindowLinesTall * _vm->_screen->_bufferBytesWide);
+
+		if ((_vm->_screen->_scrollRow + _vm->_screen->_vWindowHeight) >=
+			_vm->_room->_playFieldHeight)
+			return true;
+
+		if (_vm->_screen->_scrollY <= TILE_HEIGHT)
+			return false;
+	}
+
+	return false;
+}
+
+bool Player::scrollDown() {
+	// TODO: Refactor checkScroll code here
+	return false;
+}
+
+bool Player::scrollLeft() {
+	// TODO: Refactor checkScroll code here
+	return false;
+}
+
+bool Player::scrollRight() {
+	// TODO: Refactor checkScroll code here
+	return false;
+}
+
 } // End of namespace Access
diff --git a/engines/access/player.h b/engines/access/player.h
index a016783..a291f45 100644
--- a/engines/access/player.h
+++ b/engines/access/player.h
@@ -56,6 +56,7 @@ private:
 	SpriteResource *_playerSprites;
 	SpriteResource *_playerSprites1;
 	byte *_manPal1;
+	int _scrollEnd;
 
 	bool codeWalls();
 	void checkMove();
@@ -72,6 +73,10 @@ private:
 	void walkDownLeft();
 	void walkUpRight();
 	void walkDownRight();
+	bool scrollUp();
+	bool scrollDown();
+	bool scrollLeft();
+	bool scrollRight();
 public:
 	// Fields in original Player structure
 	byte *_monData;
@@ -94,8 +99,11 @@ public:
 	int _playerY;
 	int _frame;
 
-	// Additional globals we've added to new Player class
+	// Additional public globals we've added to new Player class
 	bool _playerOff;
+	bool _scrollFlag;
+	int _scrollThreshold;
+	int _scrollAmount;
 
 	// Additional globals that need to be saved
 	int _roomNumber;
@@ -116,6 +124,8 @@ public:
 	void walk();
 
 	void calcPlayer();
+
+	void checkScroll();
 };
 
 } // End of namespace Access
diff --git a/engines/access/room.cpp b/engines/access/room.cpp
index 80bcc00..1eeedb7 100644
--- a/engines/access/room.cpp
+++ b/engines/access/room.cpp
@@ -85,7 +85,7 @@ void Room::doRoom() {
 
 			_vm->_player->walk();
 			_vm->_sound->midiRepeat();
-			_vm->_screen->checkScroll();
+			_vm->_player->checkScroll();
 			doCommands();
 
 			// DOROOMFLASHBACK jump point
@@ -103,7 +103,7 @@ void Room::doRoom() {
 				break;
 			}
 
-			if (_vm->_screen->_scrollFlag) {
+			if (_vm->_player->_scrollFlag) {
 				_vm->copyBF1BF2();
 				_vm->_newRects.clear();
 				_function = 0;
@@ -209,7 +209,7 @@ void Room::loadRoomData(const byte *roomData) {
 	}
 
 	_vm->_scaleI = roomInfo._scaleI;
-	_vm->_screen->_scrollThreshold = roomInfo._scrollThreshold;
+	_vm->_player->_scrollThreshold = roomInfo._scrollThreshold;
 
 	// Handle loading scene palette data
 	if (roomInfo._paletteFile._fileNum != -1) {
@@ -319,6 +319,10 @@ void Room::buildColumn(int playX, int screenX) {
 	}
 }
 
+void Room::buildRow(int playY, int screenY) {
+	error("TODO: buildRow");
+}
+
 void Room::init4Quads() {
 	error("TODO: init4Quads");
 }
diff --git a/engines/access/room.h b/engines/access/room.h
index 18637e4..0569a92 100644
--- a/engines/access/room.h
+++ b/engines/access/room.h
@@ -114,6 +114,8 @@ public:
 
 	void buildColumn(int playX, int screenX);
 
+	void buildRow(int playY, int screenY);
+
 	void init4Quads();
 };
 
diff --git a/engines/access/screen.cpp b/engines/access/screen.cpp
index ca87784..771cfef 100644
--- a/engines/access/screen.cpp
+++ b/engines/access/screen.cpp
@@ -46,13 +46,10 @@ Screen::Screen(AccessEngine *vm) : _vm(vm) {
 	_currentPanel = 0;
 	_hideFlag = true;
 	_loadPalFlag = false;
-	_scrollFlag = false;
-	_scrollThreshold = 0;
 	_startColor = _numColors = 0;
 	_scrollCol = _scrollRow = 0;
 	_windowXAdd = _windowYAdd = 0;
 	_screenYOff = 0;
-	_scrollEnd = 0;
 
 	_bufferBytesWide = _vWindowBytesWide = this->w;
 	_vWindowLinesTall = this->h;
@@ -182,10 +179,6 @@ void Screen::copyBuffer(const byte *data) {
 	g_system->copyRectToScreen(destP, w, 0, 0, w, h);
 }
 
-void Screen::checkScroll() {
-	warning("TODO");
-}
-
 void Screen::setBufferScan() {
 	_clipWidth = _vWindowBytesWide - 1;
 	_windowXAdd = (320 - _clipWidth) >> 1;
@@ -230,4 +223,16 @@ void Screen::restoreScreen() {
 	_screenYOff = _screenSave._screenYOff;
 }
 
+void Screen::moveBufferLeft() {
+	error("TODO: LEFT");
+}
+
+void Screen::moveBufferDown() {
+	error("TODO: LEFT");
+}
+
+void Screen::moveBufferUp() {
+	error("TODO: UP");
+}
+
 } // End of namespace Access
diff --git a/engines/access/screen.h b/engines/access/screen.h
index 5ac6931..79c978f 100644
--- a/engines/access/screen.h
+++ b/engines/access/screen.h
@@ -65,8 +65,6 @@ private:
 public:
 	int _vesaMode;
 	bool _loadPalFlag;
-	bool _scrollFlag;
-	int _scrollThreshold;
 	int _startColor, _numColors;
 	Common::Point _bufferStart;
 	int _scrollCol, _scrollRow;
@@ -80,7 +78,6 @@ public:
 	int _vWindowBytesWide;
 	int _bufferBytesWide;
 	int _vWindowLinesTall;
-	int _scrollEnd;
 public:
 	Screen(AccessEngine *vm);
 
@@ -131,8 +128,6 @@ public:
 	 */
 	void copyBuffer(const byte *data);
 
-	void checkScroll();
-
 	void setBufferScan();
 
 	void setScaleTable(int scale);
@@ -146,6 +141,12 @@ public:
 	 * Restores previously saved screen display state variables
 	 */
 	void restoreScreen();
+
+	void moveBufferLeft();
+
+	void moveBufferDown();
+
+	void moveBufferUp();
 };
 
 } // End of namespace Access


Commit: e3687ea12347f65d3e6e9927e161e076774ad252
    https://github.com/scummvm/scummvm/commit/e3687ea12347f65d3e6e9927e161e076774ad252
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-15T20:09:56-04:00

Commit Message:
ACCESS: Refactored scroll direction code into separate methods

Changed paths:
    engines/access/player.cpp



diff --git a/engines/access/player.cpp b/engines/access/player.cpp
index a50b835..6f1df97 100644
--- a/engines/access/player.cpp
+++ b/engines/access/player.cpp
@@ -666,98 +666,38 @@ void Player::checkScroll() {
 	if ((_playerDirection == UPLEFT || _playerDirection == DOWNLEFT ||
 			_playerDirection == LEFT) && _playerX <= _scrollThreshold) {
 		// Scroll right
-		_scrollAmount = -(_playerX - _scrollThreshold);
-		_scrollFlag = true;
-		_vm->_screen->_scrollX -= _scrollAmount;
-		if (_vm->_screen->_scrollX < 0) {
-			_scrollFlag = true;
-			_vm->_screen->_scrollX += _scrollAmount;
-
-			while (_vm->_screen->_scrollX >= TILE_WIDTH && !_vm->shouldQuit()) {
-				_vm->_screen->_scrollX -= TILE_WIDTH;
-				_vm->_screen->moveBufferLeft();
-				_vm->_room->buildColumn(_vm->_screen->_scrollCol -
-					_vm->_screen->_vWindowWidth, _vm->_screen->_vWindowBytesWide);
-
-				if (_vm->_screen->_scrollX < TILE_WIDTH && _playerDirection != UPRIGHT) {
-					if (_playerDirection != DOWNRIGHT)
-						return;
-					goto finish;
-				}
-			}
-
-			_scrollEnd = 1;
-			_vm->_screen->_scrollX = 0;
-			_vm->_screen->_scrollCol = 0;
+		if (!scrollRight()) {
+			if (_playerDirection == DOWNLEFT)
+				goto scrollUp;
+			
+			return;
 		}
 	} else if ((_playerDirection == UPRIGHT || _playerDirection == DOWNRIGHT ||
 			_playerDirection == RIGHT) && (_vm->_screen->_clipWidth -
 			_playerX - _scrollThreshold) <= 0) {
 		// Scroll left
-		_scrollAmount = -(_vm->_screen->_clipWidth - _playerX - _scrollThreshold);
-		if ((_vm->_rScrollCol + _vm->_screen->_vWindowWidth) == _vm->_room->_playFieldWidth) {
-			_scrollEnd = 2;
-			_vm->_screen->_scrollX = 0;
-			_scrollFlag = true;
-		} else {
-			_scrollFlag = true;
-			_vm->_screen->_scrollX = _vm->_screen->_scrollX + _scrollAmount;
-
-			while (_vm->_screen->_scrollX >= TILE_WIDTH && !_vm->shouldQuit()) {
-				_vm->_screen->_scrollX -= TILE_WIDTH;
-				++_vm->_screen->_scrollCol;
-				_vm->_screen->moveBufferLeft();
-				_vm->_room->buildColumn(_vm->_screen->_scrollCol +
-					_vm->_screen->_vWindowWidth, _vm->_screen->_vWindowBytesWide);
-
-				if (_vm->_screen->_scrollX < TILE_WIDTH && _playerDirection != UPRIGHT) {
-					if (_playerDirection != DOWNRIGHT)
-						return;
-					goto finish;
-				}
-			}
-
-			_scrollEnd = 2;
-			_vm->_screen->_scrollX = 0;
-			_scrollFlag = true;
+		if (!scrollLeft()) {
+			if (_playerDirection == DOWNRIGHT)
+				goto scrollUp;
+	
+			return;
 		}
 	}
 
 	if ((_playerDirection == UPRIGHT || _playerDirection == UPLEFT ||
 			_playerDirection == UP) && _playerY <= _scrollThreshold) {
-		_scrollAmount = -(_playerY - _scrollThreshold);
-		_scrollFlag = true;
-		_vm->_screen->_scrollY -= _scrollAmount;
-		if (_vm->_screen->_scrollY >= 0)
-			return;
-
-		do {
-			_vm->_screen->_scrollY += TILE_HEIGHT;
-			if (--_vm->_screen->_scrollRow < 0)
-				break;
-
-			_vm->_screen->moveBufferDown();
-			_vm->_room->buildRow(_vm->_screen->_scrollRow, 0);
-
-			if (_vm->_screen->_scrollY >= 0)
-				return;
-		} while (!_vm->shouldQuit());
-
-		_scrollEnd = 3;
-		_vm->_screen->_scrollY = 0;
-		_vm->_screen->_scrollRow = 0;
-		return;
-	}
-
-finish:
-	if ((_playerDirection == DOWNRIGHT || _playerDirection == DOWNLEFT ||
+		scrollDown();
+	} else {
+scrollUp:
+		if ((_playerDirection == DOWNRIGHT || _playerDirection == DOWNLEFT ||
 			_playerDirection == DOWN) && (_vm->_screen->_clipHeight -
 			_playerY - _scrollThreshold) <= 0) {
-		// Scroll up
-		if (scrollUp()) {
-			_scrollEnd = 4;
-			_vm->_screen->_scrollY = TILE_HEIGHT;
-			_scrollFlag = true;
+			// Scroll up
+			if (scrollUp()) {
+				_scrollEnd = 4;
+				_vm->_screen->_scrollY = TILE_HEIGHT;
+				_scrollFlag = true;
+			}
 		}
 	}
 }
@@ -791,18 +731,77 @@ bool Player::scrollUp() {
 }
 
 bool Player::scrollDown() {
-	// TODO: Refactor checkScroll code here
-	return false;
+	_scrollAmount = -(_playerY - _scrollThreshold);
+	_scrollFlag = true;
+	_vm->_screen->_scrollY -= _scrollAmount;
+	if (_vm->_screen->_scrollY >= 0)
+		return true;
+
+	do {
+		_vm->_screen->_scrollY += TILE_HEIGHT;
+		if (--_vm->_screen->_scrollRow < 0)
+			break;
+
+		_vm->_screen->moveBufferDown();
+		_vm->_room->buildRow(_vm->_screen->_scrollRow, 0);
+
+		if (_vm->_screen->_scrollY >= 0)
+			return false;
+	} while (!_vm->shouldQuit());
+
+	_scrollEnd = 3;
+	_vm->_screen->_scrollY = 0;
+	_vm->_screen->_scrollRow = 0;
+	return true;
 }
 
 bool Player::scrollLeft() {
-	// TODO: Refactor checkScroll code here
-	return false;
+	_scrollAmount = -(_vm->_screen->_clipWidth - _playerX - _scrollThreshold);
+	if ((_vm->_rScrollCol + _vm->_screen->_vWindowWidth) == _vm->_room->_playFieldWidth) {
+		_scrollEnd = 2;
+		_vm->_screen->_scrollX = 0;
+		_scrollFlag = true;
+		return true;
+	} else {
+		_scrollFlag = true;
+		_vm->_screen->_scrollX = _vm->_screen->_scrollX + _scrollAmount;
+
+		while (_vm->_screen->_scrollX >= TILE_WIDTH && !_vm->shouldQuit()) {
+			_vm->_screen->_scrollX -= TILE_WIDTH;
+			++_vm->_screen->_scrollCol;
+			_vm->_screen->moveBufferLeft();
+			_vm->_room->buildColumn(_vm->_screen->_scrollCol +
+				_vm->_screen->_vWindowWidth, _vm->_screen->_vWindowBytesWide);
+
+			if (_vm->_screen->_scrollX < TILE_WIDTH)
+				return _playerDirection == UPRIGHT;
+		}
+
+		return true;
+	}
 }
 
 bool Player::scrollRight() {
-	// TODO: Refactor checkScroll code here
-	return false;
+	_scrollAmount = -(_playerX - _scrollThreshold);
+	_scrollFlag = true;
+	_vm->_screen->_scrollX -= _scrollAmount;
+
+	if (_vm->_screen->_scrollX < 0) {
+		_scrollFlag = true;
+		_vm->_screen->_scrollX += _scrollAmount;
+
+		while (_vm->_screen->_scrollX >= TILE_WIDTH && !_vm->shouldQuit()) {
+			_vm->_screen->_scrollX -= TILE_WIDTH;
+			_vm->_screen->moveBufferLeft();
+			_vm->_room->buildColumn(_vm->_screen->_scrollCol -
+				_vm->_screen->_vWindowWidth, _vm->_screen->_vWindowBytesWide);
+
+			if (_vm->_screen->_scrollX < TILE_WIDTH)
+				return _playerDirection == UPLEFT;
+		}
+	}
+
+	return true;
 }
 
 } // End of namespace Access


Commit: f8d64ae6bc47c0d1ea6efea45c28dd4902780ecb
    https://github.com/scummvm/scummvm/commit/f8d64ae6bc47c0d1ea6efea45c28dd4902780ecb
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-15T20:26:09-04:00

Commit Message:
ACCESS: Added code to update animations each frame

Changed paths:
    engines/access/animation.cpp
    engines/access/animation.h
    engines/access/events.cpp
    engines/access/events.h



diff --git a/engines/access/animation.cpp b/engines/access/animation.cpp
index 4965f41..31e53e5 100644
--- a/engines/access/animation.cpp
+++ b/engines/access/animation.cpp
@@ -331,4 +331,11 @@ void AnimationManager::animate(int animId) {
 	anim->animate();
 }
 
+void AnimationManager::updateTimers() {
+	for (uint idx = 0; idx < _animationTimers.size(); ++idx) {
+		if (_animationTimers[idx]->_countdownTicks > 0)
+			_animationTimers[idx]->_countdownTicks--;
+	}
+}
+
 } // End of namespace Access
diff --git a/engines/access/animation.h b/engines/access/animation.h
index c1b44a5..f70aa32 100644
--- a/engines/access/animation.h
+++ b/engines/access/animation.h
@@ -49,14 +49,25 @@ public:
 	void freeAnimationData();
 	void loadAnimations(const byte *data, int size);
 	
-	void clearTimers();
-
 	Animation *findAnimation(int animId);
 	Animation *setAnimation(int animId);
 
+	void animate(int animId);
+
+	/**
+	 * Clear the list of currently active animations
+	 */
+	void clearTimers();
+
+	/**
+	 * Add an animation to the list of currently animating ones
+	 */
 	void setAnimTimer(Animation *anim);
 
-	void animate(int animId);
+	/**
+	 * Update the timing of all currently active animation
+	 */
+	void updateTimers();
 };
 
 class AnimationResource {
diff --git a/engines/access/events.cpp b/engines/access/events.cpp
index 88e783e..db69f7b 100644
--- a/engines/access/events.cpp
+++ b/engines/access/events.cpp
@@ -144,15 +144,20 @@ void EventsManager::checkForNextFrameCounter() {
 		++_frameCounter;
 		_priorFrameTime = milli;
 
-		// Give time to the debugger
-		_vm->_debugger->onFrame();
+		nextFrame();
+	}
+}
 
-		// Signal the ScummVM debugger
-		_vm->_debugger->onFrame();
+void EventsManager::nextFrame() {
 
-		// TODO: Refactor for dirty rects
-		_vm->_screen->updateScreen();
-	}
+	// Give time to the debugger
+	_vm->_debugger->onFrame();
+
+	// Update timers
+	_vm->_animation->updateTimers();
+
+	// TODO: Refactor for dirty rects
+	_vm->_screen->updateScreen();
 }
 
 void EventsManager::delay(int time) {
diff --git a/engines/access/events.h b/engines/access/events.h
index aa01543..c3faf63 100644
--- a/engines/access/events.h
+++ b/engines/access/events.h
@@ -47,6 +47,8 @@ private:
 	uint32 _priorFrameTime;
 
 	void checkForNextFrameCounter();
+
+	void nextFrame();
 public:
 	CursorType _cursorId;
 	bool _leftButton;


Commit: 3475fda076779fa79f931b98d24e300fc02b479b
    https://github.com/scummvm/scummvm/commit/3475fda076779fa79f931b98d24e300fc02b479b
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-15T20:34:09-04:00

Commit Message:
ACCESS: Fixes for updating animation frames

Changed paths:
    engines/access/animation.cpp



diff --git a/engines/access/animation.cpp b/engines/access/animation.cpp
index 31e53e5..3a7424f 100644
--- a/engines/access/animation.cpp
+++ b/engines/access/animation.cpp
@@ -106,6 +106,7 @@ void Animation::anim0() {
 			if (frame == nullptr) {
 				_frameNumber = 0;
 				_currentLoopCount = -1;
+				frame = calcFrame();
 			}
 
 			setFrame(frame);
@@ -124,6 +125,7 @@ void Animation::anim1() {
 		if (frame == nullptr) {
 			--_frameNumber;
 			_currentLoopCount = -1;
+			frame = calcFrame();
 		}
 
 		setFrame(frame);
@@ -198,7 +200,7 @@ void Animation::anim7() {
 }
 
 AnimationFrame *Animation::calcFrame() {
-	return _frames[_frameNumber];
+	return (_frameNumber < (int)_frames.size()) ? _frames[_frameNumber] : nullptr;
 }
 
 AnimationFrame *Animation::calcFrame1() {
@@ -206,6 +208,7 @@ AnimationFrame *Animation::calcFrame1() {
 }
 
 void Animation::setFrame(AnimationFrame *frame) {
+	assert(frame);
 	_countdownTicks += frame->_frameDelay;
 	setFrame1(frame);
 }


Commit: a347435f26b32464944c3e304369c4c7df663478
    https://github.com/scummvm/scummvm/commit/a347435f26b32464944c3e304369c4c7df663478
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-15T21:32:16-04:00

Commit Message:
ACCESS: Added extra mouse handling to pollEvents

Changed paths:
    engines/access/events.cpp
    engines/access/events.h



diff --git a/engines/access/events.cpp b/engines/access/events.cpp
index db69f7b..f373c8b 100644
--- a/engines/access/events.cpp
+++ b/engines/access/events.cpp
@@ -38,7 +38,7 @@ EventsManager::EventsManager(AccessEngine *vm): _vm(vm) {
 	_cursorId = CURSOR_NONE;
 	_frameCounter = 10;
 	_priorFrameTime = 0;
-	_leftButton = false;
+	_leftButton = _rightButton = false;
 	_mouseMove = false;
 }
 
@@ -126,10 +126,20 @@ void EventsManager::pollEvents() {
 			return;
 		case Common::EVENT_KEYUP:
 			return;
+		case Common::EVENT_MOUSEMOVE:
+			_mousePos = event.mouse;
+			break;
 		case Common::EVENT_LBUTTONDOWN:
 			_leftButton = true;
 			return;
 		case Common::EVENT_LBUTTONUP:
+			_leftButton = false;
+			return;
+		case Common::EVENT_RBUTTONDOWN:
+			_rightButton = true;
+			return;
+		case Common::EVENT_RBUTTONUP:
+			_rightButton = false;
 			return;
 		default:
  			break;
diff --git a/engines/access/events.h b/engines/access/events.h
index c3faf63..7ee03ac 100644
--- a/engines/access/events.h
+++ b/engines/access/events.h
@@ -51,7 +51,7 @@ private:
 	void nextFrame();
 public:
 	CursorType _cursorId;
-	bool _leftButton;
+	bool _leftButton, _rightButton;
 	Common::Point _mousePos;
 	bool _mouseMove;
 public:


Commit: fab6d7883e56a4fdebcabaaf0f911265fbd06a30
    https://github.com/scummvm/scummvm/commit/fab6d7883e56a4fdebcabaaf0f911265fbd06a30
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-08-16T11:29:37+02:00

Commit Message:
ACCESS: Update TODOs

Changed paths:
    engines/access/amazon/amazon_game.cpp
    engines/access/amazon/amazon_scripts.cpp
    engines/access/player.cpp
    engines/access/screen.cpp
    engines/access/scripts.cpp



diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp
index 49ae766..0497dd8 100644
--- a/engines/access/amazon/amazon_game.cpp
+++ b/engines/access/amazon/amazon_game.cpp
@@ -152,11 +152,11 @@ void AmazonEngine::doTitle() {
 }
 
 void AmazonEngine::doOpening() {
-	// TODO
+	warning("TODO doOpening");
 }
 
 void AmazonEngine::doTent() {
-	// TODO
+	warning("TODO doTent");
 }
 
 void AmazonEngine::setupGame() {
diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp
index d7e8439..bc86c95 100644
--- a/engines/access/amazon/amazon_scripts.cpp
+++ b/engines/access/amazon/amazon_scripts.cpp
@@ -32,7 +32,7 @@ AmazonScripts::AmazonScripts(AccessEngine *vm) : Scripts(vm) {
 }
 
 void AmazonScripts::executeSpecial(int commandIndex, int param1, int param2) {
-	warning("TODO");
+	warning("TODO executeSpecial");
 }
 
 
diff --git a/engines/access/player.cpp b/engines/access/player.cpp
index 6f1df97..0e005f9 100644
--- a/engines/access/player.cpp
+++ b/engines/access/player.cpp
@@ -655,7 +655,7 @@ void Player::plotCom3() {
 }
 
 bool Player::codeWalls() {
-	error("TODO");
+	error("TODO codeWalls");
 }
 
 void Player::checkScroll() {
diff --git a/engines/access/screen.cpp b/engines/access/screen.cpp
index 771cfef..9871fb1 100644
--- a/engines/access/screen.cpp
+++ b/engines/access/screen.cpp
@@ -228,7 +228,7 @@ void Screen::moveBufferLeft() {
 }
 
 void Screen::moveBufferDown() {
-	error("TODO: LEFT");
+	error("TODO: DOWN");
 }
 
 void Screen::moveBufferUp() {
diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp
index 0e1d421..ea93a04 100644
--- a/engines/access/scripts.cpp
+++ b/engines/access/scripts.cpp
@@ -116,9 +116,9 @@ void Scripts::executeCommand(int commandIndex) {
 	(this->*COMMAND_LIST[commandIndex])();
 }
 
-void Scripts::CMDOBJECT() { error("TODO"); }
+void Scripts::CMDOBJECT() { error("TODO CMDOBJECT"); }
 
-void Scripts::CMDENDOBJECT() { error("TODO"); }
+void Scripts::CMDENDOBJECT() { error("TODO ENDOBJECT"); }
 
 void Scripts::cmdJumpLook() {
 	if (_vm->_selectCommand == 0)
@@ -165,7 +165,7 @@ void Scripts::cmdJumpTalk() {
 void Scripts::cmdNull() {
 }
 
-void Scripts::CMDPRINT() { error("TODO"); }
+void Scripts::CMDPRINT() { error("TODO CMDPRINT"); }
 
 void Scripts::cmdRetPos() {
 	_endFlag = true;
@@ -221,9 +221,9 @@ void Scripts::cmdCheckInventory() {
 		_data->skip(2);
 }
 
-void Scripts::CMDSETTEX() { error("TODO"); }
-void Scripts::CMDNEWROOM() { error("TODO"); }
-void Scripts::CMDCONVERSE() { error("TODO"); }
+void Scripts::CMDSETTEX() { error("TODO CMDSETTEX"); }
+void Scripts::CMDNEWROOM() { error("TODO CMDNEWROOM"); }
+void Scripts::CMDCONVERSE() { error("TODO CMDCONVERSE"); }
 
 void Scripts::cmdCheckFrame() {
 	int id = _data->readUint16LE();
@@ -277,9 +277,9 @@ void Scripts::cmdSetAnim() {
 	_vm->_animation->setAnimTimer(anim);
 }
 
-void Scripts::CMDDISPINV() { error("TODO"); }
-void Scripts::CMDSETTIMER() { error("TODO"); }
-void Scripts::CMDCHECKTIMER() { error("TODO"); }
+void Scripts::CMDDISPINV() { error("TODO CMDDISPINV"); }
+void Scripts::CMDSETTIMER() { error("TODO CMDSETTIMER"); }
+void Scripts::CMDCHECKTIMER() { error("TODO CMDCHECKTIMER"); }
 
 void Scripts::cmdSetTravel() {
 	if (_vm->_selectCommand == 5)
@@ -288,8 +288,8 @@ void Scripts::cmdSetTravel() {
 		_data->skip(2);
 }
 
-void Scripts::CMDSETVID() { error("TODO"); }
-void Scripts::CMDPLAYVID() { error("TODO"); }
+void Scripts::CMDSETVID() { error("TODO CMDSETVID"); }
+void Scripts::CMDPLAYVID() { error("TODO CMDPLAYVID"); }
 
 void Scripts::cmdPlotImage() {
 	_vm->_destIn = _vm->_current;
@@ -318,9 +318,9 @@ void Scripts::cmdSetScroll() {
 	_vm->_screen->_scrollY = 0;
 }
 
-void Scripts::CMDSAVERECT() { error("TODO"); }
-void Scripts::CMDSETBUFVID() { error("TODO"); }
-void Scripts::CMDPLAYBUFVID() { error("TODO"); }
+void Scripts::CMDSAVERECT() { error("TODO CMDSAVERECT"); }
+void Scripts::CMDSETBUFVID() { error("TODO CMDSETBUFVID"); }
+void Scripts::CMDPLAYBUFVID() { error("TODO CMDPLAYBUFVID"); }
 
 void Scripts::cmdRemoveLast() {
 	--_vm->_numAnimTimers;
@@ -346,14 +346,14 @@ void Scripts::CMDSPECIAL() {
 	}
 }
 
-void Scripts::CMDSETCYCLE() { error("TODO"); }
-void Scripts::CMDCYCLE() { error("TODO"); }
-void Scripts::CMDCHARSPEAK() { error("TODO"); }
-void Scripts::CMDTEXSPEAK() { error("TODO"); }
-void Scripts::CMDTEXCHOICE() { error("TODO"); } // _choiceStart = _data->pos() - 1;
-void Scripts::CMDWAIT() { error("TODO"); }
-void Scripts::CMDSETCONPOS() { error("TODO"); }
-void Scripts::CMDCHECKVFRAME() { error("TODO"); }
+void Scripts::CMDSETCYCLE() { error("TODO CMDSETCYCLE"); }
+void Scripts::CMDCYCLE() { error("TODO CMDCYCLE"); }
+void Scripts::CMDCHARSPEAK() { error("TODO CMDCHARSPEAK"); }
+void Scripts::CMDTEXSPEAK() { error("TODO CMDTEXSPEAK"); }
+void Scripts::CMDTEXCHOICE() { error("TODO CMDTEXCHOICE"); } // _choiceStart = _data->pos() - 1;
+void Scripts::CMDWAIT() { error("TODO CMDWAIT"); }
+void Scripts::CMDSETCONPOS() { error("TODO CMDSETCONPOS"); }
+void Scripts::CMDCHECKVFRAME() { error("TODO CMDCHECKVFRAME"); }
 
 void Scripts::cmdJumpChoice() {
 	int val = (_data->readUint16LE() && 0xFF);
@@ -369,12 +369,12 @@ void Scripts::cmdReturnChoice() {
 	_data->seek(_choiceStart);
 }
 
-void Scripts::CMDCLEARBLOCK() { error("TODO"); }
-void Scripts::CMDLOADSOUND() { error("TODO"); }
-void Scripts::CMDFREESOUND() { error("TODO"); }
-void Scripts::CMDSETVIDSND() { error("TODO"); }
-void Scripts::CMDPLAYVIDSND() { error("TODO"); }
-void Scripts::CMDPUSHLOCATION() { error("TODO"); }
+void Scripts::CMDCLEARBLOCK() { error("TODO CMDCLEARBLOCK"); }
+void Scripts::CMDLOADSOUND() { error("TODO CMDLOADSOUND"); }
+void Scripts::CMDFREESOUND() { error("TODO CMDFREESOUND"); }
+void Scripts::CMDSETVIDSND() { error("TODO CMDSETVIDSND"); }
+void Scripts::CMDPLAYVIDSND() { error("TODO CMDPLAYVIDSND"); }
+void Scripts::CMDPUSHLOCATION() { error("TODO CMDPUSHLOCATION"); }
 
 void Scripts::cmdPlayerOff() {
 	_vm->_player->_playerOff = true;
@@ -384,18 +384,18 @@ void Scripts::cmdPlayerOn() {
 	_vm->_player->_playerOff = false;
 }
 
-void Scripts::CMDDEAD() { error("TODO"); }
+void Scripts::CMDDEAD() { error("TODO CMDDEAD"); }
 
 void Scripts::cmdFadeOut() {
 	_vm->_screen->forceFadeOut();
 }
 
-void Scripts::CMDENDVID() { error("TODO"); }
-void Scripts::CMDHELP() { error("TODO"); }
-void Scripts::CMDCYCLEBACK() { error("TODO"); }
-void Scripts::CMDCHAPTER() { error("TODO"); }
-void Scripts::CMDSETHELP() { error("TODO"); }
-void Scripts::CMDCENTERPANEL() { error("TODO"); }
+void Scripts::CMDENDVID() { error("TODO CMDENDVID"); }
+void Scripts::CMDHELP() { error("TODO CMDHELP"); }
+void Scripts::CMDCYCLEBACK() { error("TODO CMDCYCLEBACK"); }
+void Scripts::CMDCHAPTER() { error("TODO CMDCHAPTER"); }
+void Scripts::CMDSETHELP() { error("TODO CMDSETHELP"); }
+void Scripts::CMDCENTERPANEL() { error("TODO CMDCENTERPANEL"); }
 
 void Scripts::cmdMainPanel() { 
 	if (_vm->_screen->_vesaMode) {
@@ -404,7 +404,7 @@ void Scripts::cmdMainPanel() {
 	}
 }
 
-void Scripts::CMDRETFLASH() { error("TODO"); }
+void Scripts::CMDRETFLASH() { error("TODO CMDRETFLASH"); }
 
 
 } // End of namespace Access


Commit: 0b0d16d6a5793f8ae73da9c64527cda05850416e
    https://github.com/scummvm/scummvm/commit/0b0d16d6a5793f8ae73da9c64527cda05850416e
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-08-16T11:47:13+02:00

Commit Message:
ACCESS: Add details in executeSpecial TODO

Changed paths:
    engines/access/amazon/amazon_scripts.cpp



diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp
index bc86c95..f0c580e 100644
--- a/engines/access/amazon/amazon_scripts.cpp
+++ b/engines/access/amazon/amazon_scripts.cpp
@@ -32,7 +32,43 @@ AmazonScripts::AmazonScripts(AccessEngine *vm) : Scripts(vm) {
 }
 
 void AmazonScripts::executeSpecial(int commandIndex, int param1, int param2) {
-	warning("TODO executeSpecial");
+	switch (commandIndex) {
+	case 1:
+		warning("TODO ESTABLISH");
+		break;
+	case 2:
+		warning("TODO LOADBACKGROUND");
+		break;
+	case 3:
+		warning("TODO DOCAST");
+		break;
+	case 4:
+		warning("TODO SETINACTIVE");
+		break;
+	case 6:
+		warning("TODO MWHILE");
+		break;
+	case 9:
+		warning("TODO GUARD");
+		break;
+	case 10:
+		warning("TODO NEWMUSIC");
+		break;
+	case 11:
+		warning("TODO PLOTINACTIVE");
+		break;
+	case 13:
+		warning("TODO RIVER");
+		break;
+	case 14:
+		warning("TODO ANT");
+		break;
+	case 15:
+		warning("TODO BOATWALLS");
+		break;
+	default:
+		warning("Unexpected Special code %d - Skipped", commandIndex);
+	}
 }
 
 


Commit: 86484802589f547348ca9ff7fc771801c5b7123e
    https://github.com/scummvm/scummvm/commit/86484802589f547348ca9ff7fc771801c5b7123e
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-08-16T12:24:26+02:00

Commit Message:
ACCESS: Add a second parameter to doEstablish()

Changed paths:
    engines/access/access.cpp
    engines/access/access.h
    engines/access/amazon/amazon_scripts.cpp
    engines/access/room.cpp



diff --git a/engines/access/access.cpp b/engines/access/access.cpp
index ad84058..eaa65c7 100644
--- a/engines/access/access.cpp
+++ b/engines/access/access.cpp
@@ -202,24 +202,24 @@ void AccessEngine::freeInactiveData() {
 	_inactive = nullptr;
 }
 
-void AccessEngine::establish(int v) {
+void AccessEngine::establish(int v1, int v2) {
 	_establishMode = 0;
 	_establishGroup = 0;
-	doEstablish(v);
+	doEstablish(v1, v2);
 }
 
-void AccessEngine::establishCenter(int v) {
+void AccessEngine::establishCenter(int v1, int v2) {
 	_establishMode = 1;
-	doEstablish(v);
+	doEstablish(v1, v2);
 }
 
-void AccessEngine::doEstablish(int v) {
+void AccessEngine::doEstablish(int v1, int v2) {
 	_screen->forceFadeOut();
 	_screen->clearScreen();
 	_screen->setPanel(3);
 
-	if (v != -1) {
-		_files->loadScreen(95, v);
+	if (v1 != -1) {
+		_files->loadScreen(95, v1);
 		_buffer2.copyBuffer(_screen);
 	}
 
diff --git a/engines/access/access.h b/engines/access/access.h
index 1e83c6e..921d064 100644
--- a/engines/access/access.h
+++ b/engines/access/access.h
@@ -84,7 +84,7 @@ private:
 
 	void dummyLoop();
 
-	void doEstablish(int v);
+	void doEstablish(int v1, int v2);
 protected:
 	const AccessGameDescription *_gameDescription;
 	Common::RandomSource _randomSource;
@@ -210,9 +210,9 @@ public:
 	 */
 	void freeInactiveData();
 
-	void establish(int v);
+	void establish(int v1, int v2);
 
-	void establishCenter(int v);
+	void establishCenter(int v1, int v2);
 
 	void plotList();
 	void plotList1();
diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp
index f0c580e..2fdbcc9 100644
--- a/engines/access/amazon/amazon_scripts.cpp
+++ b/engines/access/amazon/amazon_scripts.cpp
@@ -34,7 +34,7 @@ AmazonScripts::AmazonScripts(AccessEngine *vm) : Scripts(vm) {
 void AmazonScripts::executeSpecial(int commandIndex, int param1, int param2) {
 	switch (commandIndex) {
 	case 1:
-		warning("TODO ESTABLISH");
+		_vm->establish(param1, param2);
 		break;
 	case 2:
 		warning("TODO LOADBACKGROUND");
diff --git a/engines/access/room.cpp b/engines/access/room.cpp
index 1eeedb7..f42c8b0 100644
--- a/engines/access/room.cpp
+++ b/engines/access/room.cpp
@@ -163,7 +163,7 @@ void Room::loadRoomData(const byte *roomData) {
 		_vm->_establishFlag = true;
 		if (_vm->_establishTable[roomInfo._estIndex] != 1) {
 			_vm->_establishTable[roomInfo._estIndex] = 1;
-			_vm->establish(0);
+			_vm->establish(0, roomInfo._estIndex);
 		}
 	}
 


Commit: b3ab8a42a6bf77d99b6b349793f1fa7393359d24
    https://github.com/scummvm/scummvm/commit/b3ab8a42a6bf77d99b6b349793f1fa7393359d24
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-16T09:35:38-04:00

Commit Message:
ACCESS: Implementing doCommand

Changed paths:
    engines/access/access.cpp
    engines/access/access.h
    engines/access/amazon/amazon_game.cpp
    engines/access/amazon/amazon_room.cpp
    engines/access/amazon/amazon_room.h
    engines/access/events.cpp
    engines/access/events.h
    engines/access/inventory.cpp
    engines/access/inventory.h
    engines/access/resources.cpp
    engines/access/resources.h
    engines/access/room.cpp
    engines/access/room.h
    engines/access/screen.cpp
    engines/access/screen.h
    engines/access/scripts.cpp



diff --git a/engines/access/access.cpp b/engines/access/access.cpp
index eaa65c7..d6f1992 100644
--- a/engines/access/access.cpp
+++ b/engines/access/access.cpp
@@ -46,7 +46,6 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc)
 	_destIn = nullptr;
 	_current = nullptr;
 	_pCount = 0;
-	_selectCommand = 0;
 	_normalMouse = true;
 	_mouseMode = 0;
 	_currentMan = 0;
@@ -312,4 +311,8 @@ void AccessEngine::copyBF2Vid() {
 	}
 }
 
+void AccessEngine::doLoadSave() {
+	error("TODO: doLoadSave");
+}
+
 } // End of namespace Access
diff --git a/engines/access/access.h b/engines/access/access.h
index 921d064..81b1185 100644
--- a/engines/access/access.h
+++ b/engines/access/access.h
@@ -130,7 +130,6 @@ public:
 	Common::Array<ExtraCell> _extraCells;
 	ImageEntryList _images;
 	int _pCount;
-	int _selectCommand;
 	bool _normalMouse;
 	int _mouseMode;
 
@@ -224,6 +223,8 @@ public:
 	void copyBF1BF2();
 
 	void copyBF2Vid();
+
+	void doLoadSave();
 };
 
 } // End of namespace Access
diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp
index 0497dd8..36d6d80 100644
--- a/engines/access/amazon/amazon_game.cpp
+++ b/engines/access/amazon/amazon_game.cpp
@@ -176,7 +176,7 @@ void AmazonEngine::setupGame() {
 	_player->_roomNumber = 4;
 	_player->_playerX = _player->_rawPlayer.x = TRAVEL_POS[_player->_roomNumber][0];
 	_player->_playerY = _player->_rawPlayer.y = TRAVEL_POS[_player->_roomNumber][1];
-	_selectCommand = -1;
+	_room->_selectCommand = -1;
 }
 
 } // End of namespace Amazon
diff --git a/engines/access/amazon/amazon_room.cpp b/engines/access/amazon/amazon_room.cpp
index 5cb1dfe..cb6c814 100644
--- a/engines/access/amazon/amazon_room.cpp
+++ b/engines/access/amazon/amazon_room.cpp
@@ -22,6 +22,7 @@
 
 #include "common/scummsys.h"
 #include "access/access.h"
+#include "access/resources.h"
 #include "access/amazon/amazon_resources.h"
 #include "access/amazon/amazon_room.h"
 
@@ -78,7 +79,7 @@ void AmazonRoom::reloadRoom1() {
 		_vm->_currentCharFlag = false;
 	}
 
-	_vm->_selectCommand = -1;
+	_selectCommand = -1;
 	_vm->_normalMouse = 1;
 	_vm->_mouseMode = 0;
 	_vm->_boxSelect = true;
@@ -138,6 +139,10 @@ void AmazonRoom::roomMenu() {
 	delete spr;
 }
 
+void AmazonRoom::mainAreaClick() {
+
+}
+
 } // End of namespace Amazon
 
 } // End of namespace Access
diff --git a/engines/access/amazon/amazon_room.h b/engines/access/amazon/amazon_room.h
index 546ea96..838b108 100644
--- a/engines/access/amazon/amazon_room.h
+++ b/engines/access/amazon/amazon_room.h
@@ -38,14 +38,16 @@ private:
 	const byte *_icon;
 
 	void roomSet();
-
-	void roomMenu();
 protected:
 	virtual void loadRoom(int roomNumber);
 
 	virtual void reloadRoom();
 
 	virtual void reloadRoom1();
+
+	virtual void roomMenu();
+
+	virtual void mainAreaClick();
 public:
 	AmazonRoom(AccessEngine *vm);
 
diff --git a/engines/access/events.cpp b/engines/access/events.cpp
index f373c8b..8f02d41 100644
--- a/engines/access/events.cpp
+++ b/engines/access/events.cpp
@@ -40,6 +40,10 @@ EventsManager::EventsManager(AccessEngine *vm): _vm(vm) {
 	_priorFrameTime = 0;
 	_leftButton = _rightButton = false;
 	_mouseMove = false;
+	_mouseCol = _mouseRow = 0;
+	_normalMouse = 0;
+	_mouseMode = 0;
+	_cursorExitFlag = false;
 }
 
 EventsManager::~EventsManager() {
@@ -103,10 +107,9 @@ bool EventsManager::isCursorVisible() {
 	return CursorMan.isVisible();
 }
 
-void EventsManager::pollEvents() {
-	checkForNextFrameCounter();
-
-	_leftButton = false;
+void EventsManager::pollEvents(bool suppressFrames) {
+	if (!suppressFrames)
+		checkForNextFrameCounter();
 
 	Common::Event event;
 	while (g_system->getEventManager()->pollEvent(event)) {
@@ -122,6 +125,8 @@ void EventsManager::pollEvents() {
 				// Attach to the debugger
 				_vm->_debugger->attach();
 				_vm->_debugger->onFrame();
+			} else {
+				
 			}
 			return;
 		case Common::EVENT_KEYUP:
@@ -174,5 +179,25 @@ void EventsManager::delay(int time) {
 	g_system->delayMillis(time);
 }
 
+void EventsManager::zeroKeys() {
+	_keypresses.clear();
+}
+
+bool EventsManager::getKey(Common::KeyState &key) {
+	if (_keypresses.empty()) {
+		return false;
+	} else {
+		key = _keypresses.pop();
+		return true;
+	}
+}
+
+void EventsManager::debounceLeft() {
+	while (_leftButton && !_vm->shouldQuit()) {
+		pollEvents(true);
+		g_system->delayMillis(10);
+	}
+}
+
 
 } // End of namespace Access
diff --git a/engines/access/events.h b/engines/access/events.h
index 7ee03ac..5ca0806 100644
--- a/engines/access/events.h
+++ b/engines/access/events.h
@@ -53,7 +53,12 @@ public:
 	CursorType _cursorId;
 	bool _leftButton, _rightButton;
 	Common::Point _mousePos;
+	int _mouseCol, _mouseRow;
 	bool _mouseMove;
+	int _normalMouse;
+	int _mouseMode;
+	bool _cursorExitFlag;
+	Common::FixedStack<Common::KeyState> _keypresses;
 public:
 	/**
 	 * Constructor
@@ -90,9 +95,15 @@ public:
 	 */
 	bool isCursorVisible();
 
-	void pollEvents();
+	void pollEvents(bool suppressFrames = false);
+
+	void zeroKeys();
+
+	bool getKey(Common::KeyState &key);
 
 	void delay(int time);
+
+	void debounceLeft();
 };
 
 } // End of namespace Access
diff --git a/engines/access/inventory.cpp b/engines/access/inventory.cpp
index 5d2957b..e784b87 100644
--- a/engines/access/inventory.cpp
+++ b/engines/access/inventory.cpp
@@ -58,4 +58,13 @@ void InventoryManager::setUseItem(int itemId) {
 	_vm->_useItem = itemId; 
 }
 
+void InventoryManager::refreshInventory() {
+	error("TODO: refreshInventory");
+}
+
+int InventoryManager::newDisplayInv() {
+	error("TODO: newDisplayInv");
+}
+
+
 } // End of namespace Access
diff --git a/engines/access/inventory.h b/engines/access/inventory.h
index 1f229dd..399c763 100644
--- a/engines/access/inventory.h
+++ b/engines/access/inventory.h
@@ -47,6 +47,10 @@ public:
 
 	int useItem();
 	void setUseItem(int itemId);
+
+	void refreshInventory();
+
+	int newDisplayInv();
 };
 
 } // End of namespace Access
diff --git a/engines/access/resources.cpp b/engines/access/resources.cpp
index 841ab70..40daf2b 100644
--- a/engines/access/resources.cpp
+++ b/engines/access/resources.cpp
@@ -71,4 +71,9 @@ const int OVEROFFULY[] = { 1, 0, 0, 2, 1, 0, 0, 0, 0 };
 const int OVEROFFDLX[] = { 1, 2, 1, 1, 2, 1, 0, 0, 0 };
 const int OVEROFFDLY[] = { 0, 1, 0, 0, 1, 1, 0, 0, 0 };
 
+const int RMOUSE[10][2] = {
+	{ 0, 35 }, { 0, 0 }, { 36, 70 }, { 71, 106 }, { 107, 141 },
+	{ 142, 177 }, { 178, 212 }, { 213, 248 }, { 249, 283 }, { 284, 318 }
+};
+
 } // End of namespace Access
diff --git a/engines/access/resources.h b/engines/access/resources.h
index 1b49b59..678cbc0 100644
--- a/engines/access/resources.h
+++ b/engines/access/resources.h
@@ -54,6 +54,8 @@ extern const int OVEROFFULY[];
 extern const int OVEROFFDLX[];
 extern const int OVEROFFDLY[];
 
+extern const int RMOUSE[10][2];
+
 } // End of namespace Access
 
 #endif /* ACCESS_RESOURCES_H */
diff --git a/engines/access/room.cpp b/engines/access/room.cpp
index f42c8b0..773a42b 100644
--- a/engines/access/room.cpp
+++ b/engines/access/room.cpp
@@ -35,6 +35,8 @@ Room::Room(AccessEngine *vm) : Manager(vm) {
 	_playFieldWidth = _playFieldHeight = 0;
 	_matrixSize = 0;
 	_tile = nullptr;
+	_selectCommand = 0;
+	_conFlag = false;
 }
 
 Room::~Room() {
@@ -394,6 +396,138 @@ void Plotter::load(Common::SeekableReadStream *stream, int wallCount, int blockC
 		_blocks[i].bottom = stream->readSint16LE();
 }
 
+void Room::doCommands() {
+	int commandId = 0;
+	Common::KeyState keyState;
+
+	if (_vm->_startup != -1)
+		return;
+
+	if (_vm->_inventory->_invChangeFlag)
+		_vm->_inventory->refreshInventory();
+
+	if (_vm->_screen->_screenChangeFlag) {
+		_vm->_screen->_screenChangeFlag = false;
+		_vm->_events->_cursorExitFlag = true;
+		executeCommand(4);
+	} else if (_vm->_events->_leftButton) {
+		if (_vm->_events->_mouseRow >= 22) {
+			// Mouse in user interface area
+			for (commandId = 0; commandId < 10; ++commandId) {
+				if (_vm->_events->_mousePos.x >= RMOUSE[commandId][0] &&
+					_vm->_events->_mousePos.x < RMOUSE[commandId][1])
+					break;
+			}
+			if (commandId < 10)
+				handleCommand(commandId);
+
+		} else {
+			// Mouse click in main game area
+			mainAreaClick();
+		}
+	} else if (_vm->_events->getKey(keyState)) {
+		if (keyState.ascii >= ';' && keyState.ascii <= 'D') {
+			handleCommand((int)keyState.ascii - ';');
+		}
+	}
+}
+
+void Room::handleCommand(int commandId) {
+	if (commandId == 1)
+		--commandId;
+
+	if (commandId == 9)
+		_vm->doLoadSave();
+	else if (commandId == _selectCommand) {
+		_vm->_events->debounceLeft();
+		commandOff();
+	} else {
+		_vm->_events->debounceLeft();
+		executeCommand(commandId);
+	}
+}
+
+void Room::executeCommand(int commandId) {
+	_selectCommand = commandId;
+
+	switch (commandId) {
+	case 0:
+		_vm->_events->_normalMouse = 4;
+		_vm->_events->_mouseMode = 0;
+		break;
+	case 2:
+		_vm->_events->_normalMouse = 5;
+		_vm->_events->_mouseMode = 0;
+		break;
+	case 3:
+		_vm->_events->_normalMouse = 6;
+		_vm->_events->_mouseMode = 0;
+		break;
+	case 4:
+		_vm->_events->_normalMouse = 1;
+		_vm->_events->setCursor(CURSOR_0);
+		if (_vm->_inventory->newDisplayInv() == 2) {
+			commandOff();
+			return;
+		} else {
+			warning("TODO: al = _useItem");
+		}
+		break;
+	case 5:
+		_vm->_events->_normalMouse = 7;
+		_vm->_events->_mouseMode = 0;
+		break;
+	case 6:
+		_vm->_events->_normalMouse = 8;
+		_vm->_events->_mouseMode = 0;
+		break;
+	case 7:
+		_vm->_events->_normalMouse = 1;
+		_vm->_scripts->_sequence = 5000;
+		_vm->_scripts->searchForSequence();
+		roomMenu();
+		_selectCommand = -1;
+		_vm->_events->_normalMouse = 1;
+		_vm->_events->_mouseMode = 0;
+
+		_conFlag = true;
+		while (_conFlag && !_vm->shouldQuit()) {
+			_conFlag = false;
+			_vm->_scripts->executeScript();
+		}
+		_vm->_boxSelect = true;
+		break;
+	case 8:
+		_vm->_events->_normalMouse = 9;
+		_vm->_events->_mouseMode = 0;
+		break;
+	default:
+		break;
+	}
+
+	roomMenu();
+	_vm->_screen->saveScreen();
+	_vm->_screen->setDisplayScan();
+
+	byte *iconData = _vm->_files->loadFile("ICONS.LZ");
+	SpriteResource *spr = new SpriteResource(_vm, iconData, _vm->_files->_filesize);
+	delete[] iconData;
+
+	// Draw the button as selected
+	_vm->_screen->plotImage(spr, _selectCommand + 2, 
+		Common::Point(RMOUSE[_selectCommand][0], 176));
+
+	_vm->_screen->restoreScreen();
+	_vm->_boxSelect = true;
+}
+
+void Room::commandOff() {
+	_selectCommand = -1;
+	_vm->_events->_normalMouse = 1;
+	_vm->_events->_mouseMode = 4;
+	roomMenu();
+}
+
 /*------------------------------------------------------------------------*/
 
 RoomInfo::RoomInfo(const byte *data) {
@@ -428,20 +562,21 @@ RoomInfo::RoomInfo(const byte *data) {
 	_paletteFile._subfile = stream.readUint16LE();
 	if (_paletteFile._fileNum == -1) {
 		_startColor = _numColors = 0;
-	} else {
+	}
+	else {
 		_startColor = stream.readUint16LE();
 		_numColors = stream.readUint16LE();
 	}
 
 	for (int16 v = (int16)stream.readUint16LE(); v != -1;
-			v = (int16)stream.readUint16LE()) {
+		v = (int16)stream.readUint16LE()) {
 		uint16 v2 = stream.readUint16LE();
 
 		_vidTable.push_back(v | ((uint32)v2 << 16));
 	}
 
 	for (int16 fileNum = (int16)stream.readUint16LE(); fileNum != -1;
-			fileNum = (int16)stream.readUint16LE()) {
+		fileNum = (int16)stream.readUint16LE()) {
 		SoundIdent fi;
 		fi._fileNum = fileNum;
 		fi._subfile = stream.readUint16LE();
diff --git a/engines/access/room.h b/engines/access/room.h
index 0569a92..00de53f 100644
--- a/engines/access/room.h
+++ b/engines/access/room.h
@@ -63,6 +63,8 @@ private:
 	void roomLoop();
 
 	void loadPlayField(int fileNum, int subfile);
+
+	void commandOff();
 protected:
 	void loadRoomData(const byte *roomData);
 	void setupRoom();
@@ -79,6 +81,15 @@ protected:
 	*/
 	void freeTileData();
 
+	/**
+	* Switch to a given command mode
+	*/
+	void handleCommand(int commandId);
+
+	/**
+	 * Inner handler for switching to a given command mode
+	 */
+	void executeCommand(int commandId);
 
 	virtual void loadRoom(int roomNumber) = 0;
 
@@ -88,7 +99,11 @@ protected:
 
 	virtual void setIconPalette() {}
 
-	virtual void doCommands() {}
+	virtual void doCommands();
+
+	virtual void roomMenu() = 0;
+
+	virtual void mainAreaClick() = 0;
 public:
 	Plotter _plotter;
 	Common::Array<JetFrame> _jetFrame;
@@ -100,6 +115,8 @@ public:
 	int _playFieldHeight;
 	byte *_tile;
 	int _tileSize;
+	int _selectCommand;
+	bool _conFlag;
 public:
 	Room(AccessEngine *vm);
 
diff --git a/engines/access/screen.cpp b/engines/access/screen.cpp
index 9871fb1..8e9b082 100644
--- a/engines/access/screen.cpp
+++ b/engines/access/screen.cpp
@@ -50,6 +50,7 @@ Screen::Screen(AccessEngine *vm) : _vm(vm) {
 	_scrollCol = _scrollRow = 0;
 	_windowXAdd = _windowYAdd = 0;
 	_screenYOff = 0;
+	_screenChangeFlag = false;
 
 	_bufferBytesWide = _vWindowBytesWide = this->w;
 	_vWindowLinesTall = this->h;
diff --git a/engines/access/screen.h b/engines/access/screen.h
index 79c978f..98e77b4 100644
--- a/engines/access/screen.h
+++ b/engines/access/screen.h
@@ -78,6 +78,7 @@ public:
 	int _vWindowBytesWide;
 	int _bufferBytesWide;
 	int _vWindowLinesTall;
+	bool _screenChangeFlag;
 public:
 	Screen(AccessEngine *vm);
 
diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp
index ea93a04..0cfce78 100644
--- a/engines/access/scripts.cpp
+++ b/engines/access/scripts.cpp
@@ -121,42 +121,42 @@ void Scripts::CMDOBJECT() { error("TODO CMDOBJECT"); }
 void Scripts::CMDENDOBJECT() { error("TODO ENDOBJECT"); }
 
 void Scripts::cmdJumpLook() {
-	if (_vm->_selectCommand == 0)
+	if (_vm->_room->_selectCommand == 0)
 		cmdGoto();
 	else
 		_data->skip(2);
 }
 
 void Scripts::cmdJumpHelp() { 
-	if (_vm->_selectCommand == 8)
+	if (_vm->_room->_selectCommand == 8)
 		cmdGoto();
 	else
 		_data->skip(2);
 }
 
 void Scripts::cmdJumpGet() { 
-	if (_vm->_selectCommand == 3)
+	if (_vm->_room->_selectCommand == 3)
 		cmdGoto();
 	else
 		_data->skip(2);
 }
 
 void Scripts::cmdJumpMove() { 
-	if (_vm->_selectCommand == 2)
+	if (_vm->_room->_selectCommand == 2)
 		cmdGoto();
 	else
 		_data->skip(2);
 }
 
 void Scripts::cmdJumpUse() { 
-	if (_vm->_selectCommand == 4)
+	if (_vm->_room->_selectCommand == 4)
 		cmdGoto();
 	else
 		_data->skip(2);
 }
 
 void Scripts::cmdJumpTalk() { 
-	if (_vm->_selectCommand == 6)
+	if (_vm->_room->_selectCommand == 6)
 		cmdGoto();
 	else
 		_data->skip(2);
@@ -180,15 +180,15 @@ void Scripts::cmdAnim() {
 void Scripts::cmdSetFlag() { 
 	int flagNum = _data->readByte();
 	byte flagVal = _data->readByte();
-
 	assert(flagNum < 256);
+
 	_vm->_flags[flagNum] = flagVal;
 }
 
 void Scripts::cmdCheckFlag() { 
 	int flagNum = _data->readUint16LE();
 	int flagVal = _data->readUint16LE();
-	assert(flagNum < 100);
+	assert(flagNum < 256);
 
 	if (_vm->_flags[flagNum] == flagVal)
 		cmdGoto();
@@ -282,7 +282,7 @@ void Scripts::CMDSETTIMER() { error("TODO CMDSETTIMER"); }
 void Scripts::CMDCHECKTIMER() { error("TODO CMDCHECKTIMER"); }
 
 void Scripts::cmdSetTravel() {
-	if (_vm->_selectCommand == 5)
+	if (_vm->_room->_selectCommand == 5)
 		cmdGoto();
 	else
 		_data->skip(2);


Commit: dc5500e2464d3457d9dee70993ecd4340963946e
    https://github.com/scummvm/scummvm/commit/dc5500e2464d3457d9dee70993ecd4340963946e
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-16T10:33:03-04:00

Commit Message:
ACCESS: Cleanup of timer flags and some inventory logic

Changed paths:
    engines/access/access.cpp
    engines/access/access.h
    engines/access/amazon/amazon_game.cpp
    engines/access/amazon/amazon_room.cpp
    engines/access/data.cpp
    engines/access/data.h
    engines/access/inventory.cpp
    engines/access/inventory.h
    engines/access/player.cpp
    engines/access/room.cpp



diff --git a/engines/access/access.cpp b/engines/access/access.cpp
index d6f1992..6a61527 100644
--- a/engines/access/access.cpp
+++ b/engines/access/access.cpp
@@ -75,7 +75,6 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc)
 	_newDate = 0;
 	_intTim[3] = 0;
 	_timer[3] = 0;
-	_timerFlag = false;
 	Common::fill(&_objectsTable[0], &_objectsTable[100], (SpriteResource *)nullptr);
 	Common::fill(&_establishTable[0], &_establishTable[100], 0);
 	Common::fill(&_flags[0], &_flags[256], 0);
diff --git a/engines/access/access.h b/engines/access/access.h
index 81b1185..105b00b 100644
--- a/engines/access/access.h
+++ b/engines/access/access.h
@@ -124,7 +124,7 @@ public:
 	int _establishMode;
 	int _establishGroup;
 	int _numAnimTimers;
-	Common::Array<TimerEntry> _timers;
+	TimerList _timers;
 	Common::Array<Common::Rect> _newRects;
 	Common::Array<Common::Rect> _oldRects;
 	Common::Array<ExtraCell> _extraCells;
@@ -161,7 +161,6 @@ public:
 	uint32 _newDate;
 	int _intTim[3];
 	int _timer[3];
-	bool _timerFlag;
 	int _flags[256];
 	byte _help1[366];
 	byte _help2[366];
diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp
index 36d6d80..1b824ac 100644
--- a/engines/access/amazon/amazon_game.cpp
+++ b/engines/access/amazon/amazon_game.cpp
@@ -176,7 +176,6 @@ void AmazonEngine::setupGame() {
 	_player->_roomNumber = 4;
 	_player->_playerX = _player->_rawPlayer.x = TRAVEL_POS[_player->_roomNumber][0];
 	_player->_playerY = _player->_rawPlayer.y = TRAVEL_POS[_player->_roomNumber][1];
-	_room->_selectCommand = -1;
 }
 
 } // End of namespace Amazon
diff --git a/engines/access/amazon/amazon_room.cpp b/engines/access/amazon/amazon_room.cpp
index cb6c814..405889f 100644
--- a/engines/access/amazon/amazon_room.cpp
+++ b/engines/access/amazon/amazon_room.cpp
@@ -83,7 +83,7 @@ void AmazonRoom::reloadRoom1() {
 	_vm->_normalMouse = 1;
 	_vm->_mouseMode = 0;
 	_vm->_boxSelect = true;
-	_vm->_player->_playerOff = 0;
+	_vm->_player->_playerOff = false;
 
 	_vm->_screen->fadeOut();
 	_vm->_screen->clearScreen();
diff --git a/engines/access/data.cpp b/engines/access/data.cpp
index c3a6bb3..f5dbbb3 100644
--- a/engines/access/data.cpp
+++ b/engines/access/data.cpp
@@ -25,4 +25,23 @@
 
 namespace Access {
 
+TimerList::TimerList() : Common::Array<TimerEntry>() {
+	_timersSavedFlag = false;
+}
+
+void TimerList::saveTimers() {
+	if (!_timersSavedFlag /* && !_flashbackFlag */) {
+		_savedTimers = *this;
+		_timersSavedFlag = true;
+	}
+}
+
+void TimerList::restoreTimers() {
+	if (_timersSavedFlag /* && !_flashbackFlag */) {
+		clear();
+		*static_cast<Common::Array<TimerEntry> *>(this) = _savedTimers;
+		_timersSavedFlag = false;
+	}
+}
+
 } // End of namespace Access
diff --git a/engines/access/data.h b/engines/access/data.h
index b9da858..67b9cfe 100644
--- a/engines/access/data.h
+++ b/engines/access/data.h
@@ -51,6 +51,25 @@ struct TimerEntry {
 	}
 };
 
+class TimerList : public Common::Array<TimerEntry> {
+private:
+	Common::Array<TimerEntry> _savedTimers;
+public:
+	bool _timersSavedFlag;
+public:
+	TimerList();
+
+	/**
+	 * Save a copy of all current timers
+	 */
+	void saveTimers();
+
+	/**
+	 * Resetore the set of previously saved timers
+	 */
+	void restoreTimers();
+};
+
 class ExtraCell {
 public:
 	int _vidTable;
diff --git a/engines/access/inventory.cpp b/engines/access/inventory.cpp
index e784b87..15668b0 100644
--- a/engines/access/inventory.cpp
+++ b/engines/access/inventory.cpp
@@ -30,6 +30,8 @@ InventoryManager::InventoryManager(AccessEngine *vm) : Manager(vm) {
 	_startInvItem = 0;
 	_startInvBox = 0;
 	_invChangeFlag = true;
+	_invRefreshFlag = false;
+	_invModeFlag = false;
 	_startAboutItem = 0;
 	_startTravelItem = 0;
 
@@ -59,11 +61,15 @@ void InventoryManager::setUseItem(int itemId) {
 }
 
 void InventoryManager::refreshInventory() {
-	error("TODO: refreshInventory");
+	if (_vm->_screen->_vesaMode) {
+		_invRefreshFlag = true;
+		newDisplayInv();
+	}
 }
 
 int InventoryManager::newDisplayInv() {
-	error("TODO: newDisplayInv");
+	warning("TODO: newDisplayInv");
+	return 0;
 }
 
 
diff --git a/engines/access/inventory.h b/engines/access/inventory.h
index 399c763..dddfe2e 100644
--- a/engines/access/inventory.h
+++ b/engines/access/inventory.h
@@ -38,6 +38,8 @@ public:
 	int _startInvItem;
 	int _startInvBox;
 	bool _invChangeFlag;
+	bool _invRefreshFlag;
+	bool _invModeFlag;
 	int _startAboutItem;
 	int _startTravelItem;
 public:
diff --git a/engines/access/player.cpp b/engines/access/player.cpp
index 0e005f9..72cafde 100644
--- a/engines/access/player.cpp
+++ b/engines/access/player.cpp
@@ -181,9 +181,9 @@ void Player::walk() {
 	_collideFlag = false;
 	_playerDirection = NONE;
 	
-	if (_playerOff != 0)
+	if (_playerOff)
 		return;
-	else if (_vm->_timerFlag) {
+	else if (_vm->_timers[0]._flag) {
 		plotCom3();
 		return;
 	}
@@ -640,7 +640,7 @@ void Player::plotCom1() {
 }
 
 void Player::plotCom2() {
-	if (_playerOff != 1)
+	if (!_playerOff)
 		_vm->_images.addToList(this);
 }
 
diff --git a/engines/access/room.cpp b/engines/access/room.cpp
index 773a42b..cf8da17 100644
--- a/engines/access/room.cpp
+++ b/engines/access/room.cpp
@@ -37,6 +37,7 @@ Room::Room(AccessEngine *vm) : Manager(vm) {
 	_tile = nullptr;
 	_selectCommand = 0;
 	_conFlag = false;
+	_selectCommand = -1;
 }
 
 Room::~Room() {


Commit: 5ff004b2d839a4e3a06112916efe0412a5112903
    https://github.com/scummvm/scummvm/commit/5ff004b2d839a4e3a06112916efe0412a5112903
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-16T11:58:59-04:00

Commit Message:
ACCESS: Fix initialisation of player positioning and scaling values

Changed paths:
    engines/access/access.h
    engines/access/player.cpp
    engines/access/player.h
    engines/access/room.cpp



diff --git a/engines/access/access.h b/engines/access/access.h
index 105b00b..32be053 100644
--- a/engines/access/access.h
+++ b/engines/access/access.h
@@ -138,8 +138,6 @@ public:
 	byte *_music;
 	byte *_title;
 	int _converseMode;
-	int _startAboutItem;
-	int _startTravelItem;
 	int _startAboutBox;
 	int _startTravelBox;
 	bool _currentCharFlag;
@@ -152,7 +150,6 @@ public:
 	int _scaleMaxY;
 	int _scaleI;
 	bool _scaleFlag;
-	int _playFieldHeight;
 
 	// Fields that are included in savegames
 	int _conversation;
diff --git a/engines/access/player.cpp b/engines/access/player.cpp
index 72cafde..79ce219 100644
--- a/engines/access/player.cpp
+++ b/engines/access/player.cpp
@@ -61,6 +61,7 @@ Player::Player(AccessEngine *vm): Manager(vm), ImageEntry() {
 	_move = NONE;
 	_playerDirection = NONE;
 	_xFlag = _yFlag = 0;
+	_inactiveYOff = 0;
 }
 
 Player::~Player() {
@@ -168,12 +169,13 @@ void Player::freeSprites() {
 
 void Player::calcManScale() {
 	if (!_vm->_manScaleOff) {
-		_vm->_scale = (((_rawPlayer.y - _vm->_scaleMaxY + _vm->_scaleN1) * 
-			_vm->_scaleT1 + (_vm->_scaleH2 << 8)) / _vm->_scaleH1 * _vm->_scaleI) >> 8;
+		_vm->_scale = ((((_rawPlayer.y - _vm->_scaleMaxY + _vm->_scaleN1) * 
+			_vm->_scaleT1 + (_vm->_scaleH2 << 8)) & 0xff00) / _vm->_scaleH1 * _vm->_scaleI) >> 8;
 		_vm->_screen->setScaleTable(_vm->_scale);
 
 		_playerOffset.x = _vm->_screen->_scaleTable1[20];
 		_playerOffset.y = _vm->_screen->_scaleTable1[67];
+		_inactiveYOff = _playerOffset.y;
 	}
 }
 
@@ -188,6 +190,7 @@ void Player::walk() {
 		return;
 	}
 
+	_vm->_timers[0]._flag = true;
 	switch (_move) {
 	case UP:
 		_vm->_events->_mouseMove = false;
@@ -646,7 +649,8 @@ void Player::plotCom2() {
 
 void Player::plotCom3() {
 	// Update the base ImageEntry fields for the player
-	_position = _rawPlayer;
+	_position.x = _rawPlayer.x;
+	_position.y = _rawPlayer.y - _playerOffset.y;
 	_priority = _playerOffset.y;
 	_spritesPtr = _playerSprites;
 	_frameNumber = _frame;
diff --git a/engines/access/player.h b/engines/access/player.h
index a291f45..a9efff2 100644
--- a/engines/access/player.h
+++ b/engines/access/player.h
@@ -57,6 +57,7 @@ private:
 	SpriteResource *_playerSprites1;
 	byte *_manPal1;
 	int _scrollEnd;
+	int _inactiveYOff;
 
 	bool codeWalls();
 	void checkMove();
diff --git a/engines/access/room.cpp b/engines/access/room.cpp
index cf8da17..ccd19b0 100644
--- a/engines/access/room.cpp
+++ b/engines/access/room.cpp
@@ -182,14 +182,14 @@ void Room::loadRoomData(const byte *roomData) {
 	_vm->_scaleH1 = roomInfo._scaleH1;
 	_vm->_scaleH2 = roomInfo._scaleH2;
 	_vm->_scaleN1 = roomInfo._scaleN1;
-	_vm->_scaleT1 = ((_vm->_scaleH2 - _vm->_scaleH1) << 8) / _vm->_scaleN1;
+	_vm->_scaleT1 = ((_vm->_scaleH1 - _vm->_scaleH2) << 8) / _vm->_scaleN1;
 
 	if (roomInfo._playFieldFile._fileNum != -1) {
 		loadPlayField(roomInfo._playFieldFile._fileNum,
 			roomInfo._playFieldFile._subfile);
 		setupRoom();
 
-		_vm->_scaleMaxY = _vm->_playFieldHeight << 4;
+		_vm->_scaleMaxY = _playFieldHeight << 4;
 	}
 
 	// Load cells
@@ -211,7 +211,8 @@ void Room::loadRoomData(const byte *roomData) {
 		_vm->_animation->loadAnimations(data, _vm->_files->_filesize);
 	}
 
-	_vm->_scaleI = roomInfo._scaleI;
+	_vm->_scale = _vm->_scaleI = roomInfo._scaleI;
+	_vm->_screen->setScaleTable(_vm->_scale);
 	_vm->_player->_scrollThreshold = roomInfo._scrollThreshold;
 
 	// Handle loading scene palette data


Commit: fa099b848094388225b4f7e84ad4a15d7c42ce34
    https://github.com/scummvm/scummvm/commit/fa099b848094388225b4f7e84ad4a15d7c42ce34
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-16T15:47:25-04:00

Commit Message:
ACCESS: Implement routine for scaled drawing of player

Changed paths:
    engines/access/access.cpp
    engines/access/asurface.cpp
    engines/access/asurface.h



diff --git a/engines/access/access.cpp b/engines/access/access.cpp
index 6a61527..1503e38 100644
--- a/engines/access/access.cpp
+++ b/engines/access/access.cpp
@@ -244,6 +244,10 @@ void AccessEngine::plotList1() {
 			bounds.setHeight(_screen->_scaleTable1[frame->h]);
 		}
 
+		// Make a copy - some of the drawing methods I've adapted need the full
+		// scaled dimensions on-screen, and handle clipping themselves
+		Common::Rect destBounds = bounds;
+
 		if (_buffer2.clip(bounds)) {
 			ie._flags |= 1;
 		} else {
@@ -261,7 +265,7 @@ void AccessEngine::plotList1() {
 				if (ie._flags & 2) {
 					_buffer2.sPlotB(frame, Common::Point(bounds.left, bounds.top));
 				} else {
-					_buffer2.sPlotF(frame, Common::Point(bounds.left, bounds.top));
+					_buffer2.sPlotF(frame, destBounds);
 				}
 			} else {
 				if (ie._flags & 2) {
diff --git a/engines/access/asurface.cpp b/engines/access/asurface.cpp
index ed614df..4abd1aa 100644
--- a/engines/access/asurface.cpp
+++ b/engines/access/asurface.cpp
@@ -82,6 +82,15 @@ SpriteFrame::~SpriteFrame() {
 
 /*------------------------------------------------------------------------*/
 
+ImageEntry::ImageEntry() {
+	_frameNumber = 0;
+	_spritesPtr = nullptr;
+	_priority = 0;
+	_flags = 0;
+}
+
+/*------------------------------------------------------------------------*/
+
 static bool sortImagesY(const ImageEntry &ie1, const ImageEntry &ie2) {
 	return ie1._priority < ie2._priority;
 }
@@ -237,12 +246,59 @@ void ASurface::copyTo(ASurface *dest, const Common::Point &destPos) {
 	}
 }
 
+void ASurface::copyTo(ASurface *dest, const Common::Rect &bounds) {
+	const int SCALE_LIMIT = 0x100;
+	int scaleX = SCALE_LIMIT * bounds.width() / this->w;
+	int scaleY = SCALE_LIMIT * bounds.height() / this->h;
+	int scaleXCtr = 0, scaleYCtr = 0;
+
+	int y = bounds.top;
+	for (int yCtr = 0, y = bounds.top; yCtr < this->h; ++yCtr) {
+		// Handle skipping lines if Y scaling 
+		scaleYCtr += scaleY;
+		if (scaleYCtr < SCALE_LIMIT)
+			continue;
+		scaleYCtr -= SCALE_LIMIT;
+
+		// Handle off-screen lines
+		if (y < 0)
+			continue;
+		else if (y >= dest->h)
+			break;
+
+		// Handle drawing the line
+		byte *pSrc = (byte *)getBasePtr(0, yCtr);
+		byte *pDest = (byte *)dest->getBasePtr(bounds.left, y);
+		scaleXCtr = 0;
+		int x = bounds.left;
+
+		for (int xCtr = 0; xCtr < this->w; ++xCtr, ++pSrc) {
+			// Handle horizontal scaling
+			scaleXCtr += scaleX;
+			if (scaleXCtr < SCALE_LIMIT)
+				continue;
+			scaleXCtr -= SCALE_LIMIT;
+
+			// Only handle on-scren pixels
+			if (x >= dest->w)
+				break;	
+			if (x >= 0 && *pSrc != 0)
+				*pDest = *pSrc;
+			
+			++pDest;
+			++x;
+		}
+
+		++y;
+	}
+}
+
 void ASurface::sPlotB(SpriteFrame *frame, const Common::Point &pt) {
 	frame->copyTo(this, pt);
 }
 
-void ASurface::sPlotF(SpriteFrame *frame, const Common::Point &pt) {
-	frame->copyTo(this, pt);
+void ASurface::sPlotF(SpriteFrame *frame, const Common::Rect &bounds) {
+	frame->copyTo(this, bounds);
 }
 
 void ASurface::plotB(SpriteFrame *frame, const Common::Point &pt) {
diff --git a/engines/access/asurface.h b/engines/access/asurface.h
index d660ff6..365852d 100644
--- a/engines/access/asurface.h
+++ b/engines/access/asurface.h
@@ -60,13 +60,15 @@ public:
 
 	void sPlotB(SpriteFrame *frame, const Common::Point &pt);
 
-	void sPlotF(SpriteFrame *frame, const Common::Point &pt);
+	void sPlotF(SpriteFrame *frame, const Common::Rect &bounds);
 
 	void plotB(SpriteFrame *frame, const Common::Point &pt);
 
 	void copyBlock(ASurface *src, const Common::Rect &bounds);
 
 	void copyTo(ASurface *dest, const Common::Point &destPos);
+
+	void copyTo(ASurface *dest, const Common::Rect &bounds);
 };
 
 class SpriteFrame : public ASurface {
@@ -95,6 +97,8 @@ public:
 	int _priority;
 	Common::Point _position;
 	int _flags;
+public:
+	ImageEntry();
 };
 
 class ImageEntryList : public Common::Array<ImageEntry> {


Commit: bca9f14719dda5185c443cae6c16b6a374f50ab2
    https://github.com/scummvm/scummvm/commit/bca9f14719dda5185c443cae6c16b6a374f50ab2
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-16T16:04:09-04:00

Commit Message:
ACCESS: Fix display of mouse cursor

Changed paths:
    engines/access/access.cpp
    engines/access/amazon/amazon_game.cpp
    engines/access/events.cpp
    engines/access/events.h
    engines/access/room.cpp



diff --git a/engines/access/access.cpp b/engines/access/access.cpp
index 1503e38..fde5ab8 100644
--- a/engines/access/access.cpp
+++ b/engines/access/access.cpp
@@ -170,7 +170,7 @@ void AccessEngine::dummyLoop() {
 
 		if (_events->_leftButton) {
 			CursorType cursorId = _events->getCursor();
-			_events->setCursor((cursorId == CURSOR_HELP) ? CURSOR_0 : (CursorType)(cursorId + 1));
+			_events->setCursor((cursorId == CURSOR_HELP) ? CURSOR_ARROW : (CursorType)(cursorId + 1));
 		}
 	}
 
diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp
index 1b824ac..042fd41 100644
--- a/engines/access/amazon/amazon_game.cpp
+++ b/engines/access/amazon/amazon_game.cpp
@@ -80,7 +80,7 @@ void AmazonEngine::playGame() {
 
 void AmazonEngine::doIntroduction() {
 	_screen->setInitialPalettte();
-	_events->setCursor(CURSOR_0);
+	_events->setCursor(CURSOR_ARROW);
 	_events->showCursor();
 	_screen->setPanel(0);
 
diff --git a/engines/access/events.cpp b/engines/access/events.cpp
index 8f02d41..9c6b457 100644
--- a/engines/access/events.cpp
+++ b/engines/access/events.cpp
@@ -36,12 +36,12 @@ namespace Access {
 
 EventsManager::EventsManager(AccessEngine *vm): _vm(vm) {
 	_cursorId = CURSOR_NONE;
+	_normalMouse = CURSOR_CROSSHAIRS;
 	_frameCounter = 10;
 	_priorFrameTime = 0;
 	_leftButton = _rightButton = false;
 	_mouseMove = false;
 	_mouseCol = _mouseRow = 0;
-	_normalMouse = 0;
 	_mouseMode = 0;
 	_cursorExitFlag = false;
 }
@@ -54,6 +54,11 @@ void EventsManager::setCursor(CursorType cursorId) {
 		return;	
 	_cursorId = cursorId;
 	
+	if (_mouseMode == 1 && cursorId == CURSOR_ARROW)
+		_mouseMode = 2;
+	else if (_mouseMode == 2 && cursorId != CURSOR_ARROW)
+		_mouseMode = 1;
+
 	// Get a pointer to the mouse data to use, and get the cursor hotspot
 	const byte *srcP = Amazon::CURSORS[cursorId];
 	int hotspotX = (int16)READ_LE_UINT16(srcP);
diff --git a/engines/access/events.h b/engines/access/events.h
index 5ca0806..c76f62b 100644
--- a/engines/access/events.h
+++ b/engines/access/events.h
@@ -31,8 +31,8 @@ namespace Access {
 
 enum CursorType { 
 	CURSOR_NONE = -1,
-	CURSOR_0 = 0, CURSOR_1, CURSOR_2, CURSOR_3, CURSOR_EYE, CURSOR_HAND, 
-	CURSOR_GET, CURSOR_CLIMB, CURSOR_TALK, CURSOR_HELP
+	CURSOR_ARROW = 0, CURSOR_CROSSHAIRS, CURSOR_2, CURSOR_3, CURSOR_EYE, 
+	CURSOR_HAND, CURSOR_GET, CURSOR_CLIMB, CURSOR_TALK, CURSOR_HELP
 };
 
 #define GAME_FRAME_RATE 50
@@ -51,11 +51,11 @@ private:
 	void nextFrame();
 public:
 	CursorType _cursorId;
+	CursorType _normalMouse;
 	bool _leftButton, _rightButton;
 	Common::Point _mousePos;
 	int _mouseCol, _mouseRow;
 	bool _mouseMove;
-	int _normalMouse;
 	int _mouseMode;
 	bool _cursorExitFlag;
 	Common::FixedStack<Common::KeyState> _keypresses;
diff --git a/engines/access/room.cpp b/engines/access/room.cpp
index ccd19b0..dd6f218 100644
--- a/engines/access/room.cpp
+++ b/engines/access/room.cpp
@@ -131,6 +131,12 @@ void Room::doRoom() {
 					break;
 				} else {
 					_vm->plotList();
+
+					if (_vm->_events->_mousePos.y < 177) {
+						_vm->_events->setCursor(_vm->_events->_normalMouse);
+					} else {
+						_vm->_events->setCursor(CURSOR_ARROW);
+					}
 					_vm->copyBlocks();
 				}
 			}
@@ -454,20 +460,20 @@ void Room::executeCommand(int commandId) {
 
 	switch (commandId) {
 	case 0:
-		_vm->_events->_normalMouse = 4;
+		_vm->_events->_normalMouse = CURSOR_EYE;
 		_vm->_events->_mouseMode = 0;
 		break;
 	case 2:
-		_vm->_events->_normalMouse = 5;
+		_vm->_events->_normalMouse = CURSOR_HAND;
 		_vm->_events->_mouseMode = 0;
 		break;
 	case 3:
-		_vm->_events->_normalMouse = 6;
+		_vm->_events->_normalMouse = CURSOR_GET;
 		_vm->_events->_mouseMode = 0;
 		break;
 	case 4:
-		_vm->_events->_normalMouse = 1;
-		_vm->_events->setCursor(CURSOR_0);
+		_vm->_events->_normalMouse = CURSOR_CROSSHAIRS;
+		_vm->_events->setCursor(CURSOR_ARROW);
 		if (_vm->_inventory->newDisplayInv() == 2) {
 			commandOff();
 			return;
@@ -476,20 +482,20 @@ void Room::executeCommand(int commandId) {
 		}
 		break;
 	case 5:
-		_vm->_events->_normalMouse = 7;
+		_vm->_events->_normalMouse = CURSOR_CLIMB;
 		_vm->_events->_mouseMode = 0;
 		break;
 	case 6:
-		_vm->_events->_normalMouse = 8;
+		_vm->_events->_normalMouse = CURSOR_TALK;
 		_vm->_events->_mouseMode = 0;
 		break;
 	case 7:
-		_vm->_events->_normalMouse = 1;
+		_vm->_events->_normalMouse = CURSOR_CROSSHAIRS;
 		_vm->_scripts->_sequence = 5000;
 		_vm->_scripts->searchForSequence();
 		roomMenu();
 		_selectCommand = -1;
-		_vm->_events->_normalMouse = 1;
+		_vm->_events->_normalMouse = CURSOR_CROSSHAIRS;
 		_vm->_events->_mouseMode = 0;
 
 		_conFlag = true;
@@ -500,7 +506,7 @@ void Room::executeCommand(int commandId) {
 		_vm->_boxSelect = true;
 		break;
 	case 8:
-		_vm->_events->_normalMouse = 9;
+		_vm->_events->_normalMouse = CURSOR_HELP;
 		_vm->_events->_mouseMode = 0;
 		break;
 	default:
@@ -525,7 +531,7 @@ void Room::executeCommand(int commandId) {
 
 void Room::commandOff() {
 	_selectCommand = -1;
-	_vm->_events->_normalMouse = 1;
+	_vm->_events->_normalMouse = CURSOR_CROSSHAIRS;
 	_vm->_events->_mouseMode = 4;
 	roomMenu();
 }


Commit: 0b7078397417a3f54d33cebcd602034c8d0d1a1e
    https://github.com/scummvm/scummvm/commit/0b7078397417a3f54d33cebcd602034c8d0d1a1e
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-16T16:15:48-04:00

Commit Message:
ACCESS: Fix selecting buttons from the bottom of the screen

Changed paths:
    engines/access/events.cpp
    engines/access/events.h
    engines/access/room.cpp



diff --git a/engines/access/events.cpp b/engines/access/events.cpp
index 9c6b457..765d57c 100644
--- a/engines/access/events.cpp
+++ b/engines/access/events.cpp
@@ -118,7 +118,6 @@ void EventsManager::pollEvents(bool suppressFrames) {
 
 	Common::Event event;
 	while (g_system->getEventManager()->pollEvent(event)) {
-		// Handle keypress
 		switch (event.type) {
 		case Common::EVENT_QUIT:
 		case Common::EVENT_RTL:
@@ -131,13 +130,15 @@ void EventsManager::pollEvents(bool suppressFrames) {
 				_vm->_debugger->attach();
 				_vm->_debugger->onFrame();
 			} else {
-				
+				_keypresses.push(event.kbd);
 			}
 			return;
 		case Common::EVENT_KEYUP:
 			return;
 		case Common::EVENT_MOUSEMOVE:
 			_mousePos = event.mouse;
+			_mouseCol = _mousePos.x / 8;
+			_mouseRow = _mousePos.y / 8;
 			break;
 		case Common::EVENT_LBUTTONDOWN:
 			_leftButton = true;
@@ -169,7 +170,6 @@ void EventsManager::checkForNextFrameCounter() {
 }
 
 void EventsManager::nextFrame() {
-
 	// Give time to the debugger
 	_vm->_debugger->onFrame();
 
diff --git a/engines/access/events.h b/engines/access/events.h
index c76f62b..b442b15 100644
--- a/engines/access/events.h
+++ b/engines/access/events.h
@@ -31,11 +31,11 @@ namespace Access {
 
 enum CursorType { 
 	CURSOR_NONE = -1,
-	CURSOR_ARROW = 0, CURSOR_CROSSHAIRS, CURSOR_2, CURSOR_3, CURSOR_EYE, 
-	CURSOR_HAND, CURSOR_GET, CURSOR_CLIMB, CURSOR_TALK, CURSOR_HELP
+	CURSOR_ARROW = 0, CURSOR_CROSSHAIRS, CURSOR_2, CURSOR_3, CURSOR_LOOK, 
+	CURSOR_USE, CURSOR_TAKE, CURSOR_CLIMB, CURSOR_TALK, CURSOR_HELP
 };
 
-#define GAME_FRAME_RATE 50
+#define GAME_FRAME_RATE 40
 #define GAME_FRAME_TIME (1000 / GAME_FRAME_RATE)
 
 class AccessEngine;
diff --git a/engines/access/room.cpp b/engines/access/room.cpp
index dd6f218..796a441 100644
--- a/engines/access/room.cpp
+++ b/engines/access/room.cpp
@@ -460,15 +460,15 @@ void Room::executeCommand(int commandId) {
 
 	switch (commandId) {
 	case 0:
-		_vm->_events->_normalMouse = CURSOR_EYE;
+		_vm->_events->_normalMouse = CURSOR_LOOK;
 		_vm->_events->_mouseMode = 0;
 		break;
 	case 2:
-		_vm->_events->_normalMouse = CURSOR_HAND;
+		_vm->_events->_normalMouse = CURSOR_USE;
 		_vm->_events->_mouseMode = 0;
 		break;
 	case 3:
-		_vm->_events->_normalMouse = CURSOR_GET;
+		_vm->_events->_normalMouse = CURSOR_TAKE;
 		_vm->_events->_mouseMode = 0;
 		break;
 	case 4:
@@ -513,10 +513,12 @@ void Room::executeCommand(int commandId) {
 		break;
 	}
 
+	// Draw the default toolbar menu at the bottom of the screen
 	roomMenu();
 	_vm->_screen->saveScreen();
 	_vm->_screen->setDisplayScan();
 
+	// Get the toolbar icons resource
 	byte *iconData = _vm->_files->loadFile("ICONS.LZ");
 	SpriteResource *spr = new SpriteResource(_vm, iconData, _vm->_files->_filesize);
 	delete[] iconData;


Commit: a42e52fb5baa2d9ed9e2d726cfdf0365acd15472
    https://github.com/scummvm/scummvm/commit/a42e52fb5baa2d9ed9e2d726cfdf0365acd15472
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-16T17:24:22-04:00

Commit Message:
ACCESS: Implemented code for clicking in room area

Changed paths:
    engines/access/amazon/amazon_game.h
    engines/access/amazon/amazon_room.cpp
    engines/access/amazon/amazon_room.h
    engines/access/room.cpp
    engines/access/room.h



diff --git a/engines/access/amazon/amazon_game.h b/engines/access/amazon/amazon_game.h
index c927ad9..848af85 100644
--- a/engines/access/amazon/amazon_game.h
+++ b/engines/access/amazon/amazon_game.h
@@ -48,21 +48,6 @@ private:
 	int _inactiveYOff;
 	int _esTabTable[100];
 
-	// Fields that are mapped to flags
-	int &_guardLocation;
-	int &_guardFind;
-	int &_helpLevel;
-	int &_jasMayaFlag;
-	int &_moreHelp;
-	int &_flashbackFlag;
-	int &_riverFlag;
-	int &_aniOutFlag;
-	int &_badEnd;
-	int &_noHints;
-	int &_aniFlag;
-	int &_allenFlag;
-	int &_noSound;
-
 	/**
 	 * Do the game introduction
 	 */
@@ -94,6 +79,21 @@ protected:
 	 */
 	virtual void playGame();
 public:
+	// Fields that are mapped to flags
+	int &_guardLocation;
+	int &_guardFind;
+	int &_helpLevel;
+	int &_jasMayaFlag;
+	int &_moreHelp;
+	int &_flashbackFlag;
+	int &_riverFlag;
+	int &_aniOutFlag;
+	int &_badEnd;
+	int &_noHints;
+	int &_aniFlag;
+	int &_allenFlag;
+	int &_noSound;
+public:
 	AmazonEngine(OSystem *syst, const AccessGameDescription *gameDesc);
 
 	virtual ~AmazonEngine();
diff --git a/engines/access/amazon/amazon_room.cpp b/engines/access/amazon/amazon_room.cpp
index 405889f..bf3c250 100644
--- a/engines/access/amazon/amazon_room.cpp
+++ b/engines/access/amazon/amazon_room.cpp
@@ -23,6 +23,7 @@
 #include "common/scummsys.h"
 #include "access/access.h"
 #include "access/resources.h"
+#include "access/amazon/amazon_game.h"
 #include "access/amazon/amazon_resources.h"
 #include "access/amazon/amazon_room.h"
 
@@ -31,6 +32,7 @@ namespace Access {
 namespace Amazon {
 
 AmazonRoom::AmazonRoom(AccessEngine *vm): Room(vm) {
+	_game = (AmazonEngine *)vm;
 	_antOutFlag = false;
 	_icon = nullptr;
 }
@@ -140,7 +142,28 @@ void AmazonRoom::roomMenu() {
 }
 
 void AmazonRoom::mainAreaClick() {
-
+	if (_selectCommand == -1) {
+		if (_vm->_player->_roomNumber == 42 || _vm->_player->_roomNumber == 44 ||
+				_vm->_player->_roomNumber == 31 || _vm->_player->_roomNumber == 29) {
+			switch (checkBoxes1(_vm->_events->_mousePos)) {
+			case 0:
+				_game->_jasMayaFlag = 0;
+				break;
+			case 1:
+				_game->_jasMayaFlag = 1;
+				break;
+			default:
+				break;
+			}
+		}
+	} else if (_vm->_events->_mousePos.x >= _vm->_screen->_windowXAdd &&
+			_vm->_events->_mousePos.x <= _vm->_screen->_vWindowBytesWide &&
+			_vm->_events->_mousePos.y >= _vm->_screen->_windowYAdd &&
+			_vm->_events->_mousePos.y <= _vm->_screen->_vWindowLinesTall) {
+		if (checkBoxes1(_vm->_events->_mousePos) >= 0) {
+			checkBoxes3();
+		}
+	}
 }
 
 } // End of namespace Amazon
diff --git a/engines/access/amazon/amazon_room.h b/engines/access/amazon/amazon_room.h
index 838b108..c7d8e0c 100644
--- a/engines/access/amazon/amazon_room.h
+++ b/engines/access/amazon/amazon_room.h
@@ -32,8 +32,11 @@ class AccessEngine;
 
 namespace Amazon {
 
+class AmazonEngine;
+
 class AmazonRoom : public Room {
 private:
+	AmazonEngine *_game;
 	bool _antOutFlag;
 	const byte *_icon;
 
diff --git a/engines/access/room.cpp b/engines/access/room.cpp
index 796a441..4da207b 100644
--- a/engines/access/room.cpp
+++ b/engines/access/room.cpp
@@ -538,6 +538,52 @@ void Room::commandOff() {
 	roomMenu();
 }
 
+int Room::checkBoxes() {
+	return checkBoxes1(_vm->_player->_rawPlayer);
+}
+
+int Room::checkBoxes1(const Common::Point &pt) {
+	return checkBoxes2(pt, 0, _plotter._blocks.size());
+}
+
+int Room::checkBoxes2(const Common::Point &pt, int start, int count) {
+	for (; count > 0; --count, ++start) {
+		if (_plotter._blocks[start].contains(pt)) {
+			_plotter._blockIn = start;
+			return start;
+		}
+	}
+
+	return -1;
+}
+
+void Room::checkBoxes3() {
+	for (int start = 0; start < _plotter._blocks.size(); ++start) {
+		if (_plotter._blocks[start].contains(_vm->_events->_mousePos)) {
+			_plotter._blockIn = start;
+			if (!(validateBox(start) & 0x80)) {
+				_vm->_events->debounceLeft();
+				_vm->_boxSelect = start;
+
+				_conFlag = true;
+				while (_conFlag && !_vm->shouldQuit()) {
+					_conFlag = false;
+					_vm->_scripts->executeScript();
+				}
+
+				_vm->_boxSelect = -1;
+				return;
+			}
+		}
+	}
+}
+
+int Room::validateBox(int boxId) {
+	_vm->_scripts->_sequence = boxId;
+	_vm->_scripts->searchForSequence();
+	return _vm->_scripts->executeScript();
+}
+
 /*------------------------------------------------------------------------*/
 
 RoomInfo::RoomInfo(const byte *data) {
diff --git a/engines/access/room.h b/engines/access/room.h
index 00de53f..19c3cc4 100644
--- a/engines/access/room.h
+++ b/engines/access/room.h
@@ -86,6 +86,13 @@ protected:
 	*/
 	void handleCommand(int commandId);
 
+	int checkBoxes();
+	int checkBoxes1(const Common::Point &pt);
+	int checkBoxes2(const Common::Point &pt, int start, int count);
+	void checkBoxes3();
+
+	int validateBox(int boxId);
+
 	/**
 	 * Inner handler for switching to a given command mode
 	 */


Commit: 8d6c8ed452bc60a963774ea7a26ff92472752d63
    https://github.com/scummvm/scummvm/commit/8d6c8ed452bc60a963774ea7a26ff92472752d63
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-16T20:26:17-04:00

Commit Message:
ACCESS: Beginnings of code for text bubble drawing

Changed paths:
    engines/access/access.h
    engines/access/asurface.cpp
    engines/access/asurface.h
    engines/access/data.h
    engines/access/events.cpp
    engines/access/events.h
    engines/access/room.cpp
    engines/access/room.h
    engines/access/scripts.cpp
    engines/access/scripts.h



diff --git a/engines/access/access.h b/engines/access/access.h
index 32be053..511cce8 100644
--- a/engines/access/access.h
+++ b/engines/access/access.h
@@ -125,6 +125,7 @@ public:
 	int _establishGroup;
 	int _numAnimTimers;
 	TimerList _timers;
+	Font _font;
 	Common::Array<Common::Rect> _newRects;
 	Common::Array<Common::Rect> _oldRects;
 	Common::Array<ExtraCell> _extraCells;
diff --git a/engines/access/asurface.cpp b/engines/access/asurface.cpp
index 4abd1aa..32e5403 100644
--- a/engines/access/asurface.cpp
+++ b/engines/access/asurface.cpp
@@ -127,6 +127,7 @@ void ASurface::init() {
 
 ASurface::~ASurface() {
 	free();
+	_savedBlock.free();
 }
 
 void ASurface::clearBuffer() {
@@ -309,4 +310,24 @@ void ASurface::copyBlock(ASurface *src, const Common::Rect &bounds) {
 	copyRectToSurface(*src, bounds.left, bounds.top, bounds);
 }
 
+void ASurface::saveBlock(const Common::Rect &bounds) {
+	_savedBounds = bounds;
+	_savedBounds.clip(Common::Rect(0, 0, this->w, this->h));
+
+	_savedBlock.free();
+	_savedBlock.create(bounds.width(), bounds.height(),
+		Graphics::PixelFormat::createFormatCLUT8());
+	_savedBlock.copyRectToSurface(*this, 0, 0, _savedBounds);
+}
+
+void ASurface::restoreBlock() {
+	if (!_savedBounds.isEmpty()) {
+		copyRectToSurface(_savedBlock, _savedBounds.left, _savedBounds.top,
+			Common::Rect(0, 0, _savedBlock.w, _savedBlock.h));
+
+		_savedBlock.free();
+		_savedBounds = Common::Rect(0, 0, 0, 0);
+	}
+}
+
 } // End of namespace Access
diff --git a/engines/access/asurface.h b/engines/access/asurface.h
index 365852d..1efee28 100644
--- a/engines/access/asurface.h
+++ b/engines/access/asurface.h
@@ -36,6 +36,9 @@ class SpriteResource;
 class SpriteFrame;
 
 class ASurface : public Graphics::Surface {
+private:
+	Graphics::Surface _savedBlock;
+	Common::Rect _savedBounds;
 public:
 	static int _leftSkip, _rightSkip;
 	static int _topSkip, _bottomSkip;
@@ -46,7 +49,8 @@ public:
 
 	static void init();
 public:
-	virtual void plotFrame(SpriteFrame *frame, const Common::Point &pt);
+	Common::Point _printOrg;
+	Common::Point _printStart;
 public:
 	virtual ~ASurface();
 
@@ -69,6 +73,12 @@ public:
 	void copyTo(ASurface *dest, const Common::Point &destPos);
 
 	void copyTo(ASurface *dest, const Common::Rect &bounds);
+
+	void saveBlock(const Common::Rect &bounds);
+
+	void restoreBlock();
+
+	virtual void plotFrame(SpriteFrame *frame, const Common::Point &pt);
 };
 
 class SpriteFrame : public ASurface {
diff --git a/engines/access/data.h b/engines/access/data.h
index 67b9cfe..9318456 100644
--- a/engines/access/data.h
+++ b/engines/access/data.h
@@ -78,6 +78,19 @@ public:
 	int _vidSTable1;
 };
 
+struct FontVal {
+public:
+	int _lo, _hi;
+
+	FontVal() { _lo = _hi = 0; }
+};
+
+class Font {
+public:
+	FontVal _charSet;
+	FontVal _charFor;
+};
+
 } // End of namespace Access
 
 #endif /* ACCESS_DATA_H */
diff --git a/engines/access/events.cpp b/engines/access/events.cpp
index 765d57c..521e889 100644
--- a/engines/access/events.cpp
+++ b/engines/access/events.cpp
@@ -204,5 +204,8 @@ void EventsManager::debounceLeft() {
 	}
 }
 
+void EventsManager::waitKeyMouse() {
+	error("TODO: waitKeyPress");
+}
 
 } // End of namespace Access
diff --git a/engines/access/events.h b/engines/access/events.h
index b442b15..dc89829 100644
--- a/engines/access/events.h
+++ b/engines/access/events.h
@@ -104,6 +104,8 @@ public:
 	void delay(int time);
 
 	void debounceLeft();
+
+	void waitKeyMouse();
 };
 
 } // End of namespace Access
diff --git a/engines/access/room.cpp b/engines/access/room.cpp
index 4da207b..9969f33 100644
--- a/engines/access/room.cpp
+++ b/engines/access/room.cpp
@@ -584,6 +584,34 @@ int Room::validateBox(int boxId) {
 	return _vm->_scripts->executeScript();
 }
 
+void Room::placeBubble() {
+	_bubbleBox._maxChars = 27;
+	placeBubble1();
+}
+
+void Room::placeBubble1() {
+	_bubbleBox.clearBubbles();
+	_vm->_font._charSet._lo = 1;
+	_vm->_font._charSet._hi = 8;
+	_vm->_font._charFor._lo = 29;
+	_vm->_font._charFor._hi = 32;
+	
+	calcBubble();
+
+	Common::Rect r = _bubbleBox._bubbles[0];
+	r.translate(-2, 0);
+	_vm->_screen->saveBlock(r);
+	printBubble();
+}
+
+void Room::calcBubble() {
+	error("TODO: calcBubble");
+}
+
+void Room::printBubble() {
+	error("TODO: printBubble");
+}
+
 /*------------------------------------------------------------------------*/
 
 RoomInfo::RoomInfo(const byte *data) {
@@ -642,4 +670,30 @@ RoomInfo::RoomInfo(const byte *data) {
 	}
 }
 
+/*------------------------------------------------------------------------*/
+
+BubbleBox::BubbleBox() {
+	_field0 = 2;
+	_bounds = Common::Rect(64, 32, 130, 122);
+	_bubblePtr = -1;
+	_maxChars = 0;
+}
+
+void BubbleBox::load(Common::SeekableReadStream *stream) {
+	_bubbleTit.clear();
+
+	byte v;
+	do {
+		v = stream->readByte();
+		_bubbleTit.push_back(v);
+	} while (v != 0);
+
+	_bubblePtr = 0;
+}
+
+void BubbleBox::clearBubbles() {
+	_bubbles.clear();
+}
+
+
 } // End of namespace Access
diff --git a/engines/access/room.h b/engines/access/room.h
index 19c3cc4..9b26ed2 100644
--- a/engines/access/room.h
+++ b/engines/access/room.h
@@ -58,6 +58,22 @@ public:
 	}
 };
 
+class BubbleBox {
+public:
+	int _field0;
+	Common::Rect _bounds;
+	Common::Array<int> _bubbleTit;
+	int _bubblePtr;
+	int _maxChars;
+	Common::Array<Common::Rect> _bubbles;
+public:
+	BubbleBox();
+
+	void load(Common::SeekableReadStream *stream);
+
+	void clearBubbles();
+};
+
 class Room: public Manager {
 private:
 	void roomLoop();
@@ -114,6 +130,7 @@ protected:
 public:
 	Plotter _plotter;
 	Common::Array<JetFrame> _jetFrame;
+	BubbleBox _bubbleBox;
 	int _function;
 	int _roomFlag;
 	byte *_playField;
@@ -141,6 +158,13 @@ public:
 	void buildRow(int playY, int screenY);
 
 	void init4Quads();
+
+	void placeBubble();
+	void placeBubble1();
+
+	void calcBubble();
+
+	void printBubble();
 };
 
 
diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp
index 0cfce78..0c3cd2e 100644
--- a/engines/access/scripts.cpp
+++ b/engines/access/scripts.cpp
@@ -87,7 +87,7 @@ void Scripts::executeCommand(int commandIndex) {
 		&Scripts::CMDOBJECT, &Scripts::CMDENDOBJECT, &Scripts::cmdJumpLook, 
 		&Scripts::cmdJumpHelp, &Scripts::cmdJumpGet, &Scripts::cmdJumpMove,
 		&Scripts::cmdJumpUse, &Scripts::cmdJumpTalk, &Scripts::cmdNull, 
-		&Scripts::CMDPRINT, &Scripts::cmdRetPos, &Scripts::cmdAnim,
+		&Scripts::cmdPrint, &Scripts::cmdRetPos, &Scripts::cmdAnim,
 		&Scripts::cmdSetFlag, &Scripts::cmdCheckFlag, &Scripts::cmdGoto, 
 		&Scripts::cmdSetInventory, &Scripts::cmdSetInventory, &Scripts::cmdCheckInventory, 
 		&Scripts::CMDSETTEX, &Scripts::CMDNEWROOM, &Scripts::CMDCONVERSE, 
@@ -116,7 +116,11 @@ void Scripts::executeCommand(int commandIndex) {
 	(this->*COMMAND_LIST[commandIndex])();
 }
 
-void Scripts::CMDOBJECT() { error("TODO CMDOBJECT"); }
+void Scripts::CMDOBJECT() { 
+	byte id;
+	
+	_vm->_room->_bubbleBox.load(_data);
+}
 
 void Scripts::CMDENDOBJECT() { error("TODO ENDOBJECT"); }
 
@@ -165,7 +169,24 @@ void Scripts::cmdJumpTalk() {
 void Scripts::cmdNull() {
 }
 
-void Scripts::CMDPRINT() { error("TODO CMDPRINT"); }
+#define PRINT_TIMER 25
+
+void Scripts::cmdPrint() { 
+	_vm->_screen->_printOrg = Common::Point(20, 42);
+	_vm->_screen->_printStart = Common::Point(20, 42);
+	_vm->_timers[PRINT_TIMER]._timer = 50;
+	_vm->_timers[PRINT_TIMER]._initTm = 50;
+	_vm->_timers[PRINT_TIMER]._flag = true;
+
+	_vm->_room->placeBubble();
+	_vm->_events->waitKeyMouse();
+
+	while (_vm->_timers[PRINT_TIMER]._flag) {
+		_vm->_events->pollEvents();
+	}
+
+	_vm->_screen->restoreBlock();
+}
 
 void Scripts::cmdRetPos() {
 	_endFlag = true;
diff --git a/engines/access/scripts.h b/engines/access/scripts.h
index 0916b9e..78e54f5 100644
--- a/engines/access/scripts.h
+++ b/engines/access/scripts.h
@@ -52,7 +52,7 @@ protected:
 	void cmdJumpUse();
 	void cmdJumpTalk();
 	void cmdNull();
-	void CMDPRINT();
+	void cmdPrint();
 	void cmdRetPos();
 	void cmdAnim();
 	void cmdSetFlag();


Commit: f784b4efba7518806195f96d0177ccdc6e2dbaf8
    https://github.com/scummvm/scummvm/commit/f784b4efba7518806195f96d0177ccdc6e2dbaf8
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-16T22:18:53-04:00

Commit Message:
ACCESS: Added data for font2 and font6x6

Changed paths:
    engines/access/access.h
    engines/access/amazon/amazon_game.cpp
    engines/access/amazon/amazon_resources.cpp
    engines/access/amazon/amazon_resources.h
    engines/access/asurface.h
    engines/access/data.cpp
    engines/access/data.h
    engines/access/room.cpp
    engines/access/scripts.cpp



diff --git a/engines/access/access.h b/engines/access/access.h
index 511cce8..fa2d24e 100644
--- a/engines/access/access.h
+++ b/engines/access/access.h
@@ -125,7 +125,7 @@ public:
 	int _establishGroup;
 	int _numAnimTimers;
 	TimerList _timers;
-	Font _font;
+	FontManager _fonts;
 	Common::Array<Common::Rect> _newRects;
 	Common::Array<Common::Rect> _oldRects;
 	Common::Array<ExtraCell> _extraCells;
diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp
index 042fd41..072675c 100644
--- a/engines/access/amazon/amazon_game.cpp
+++ b/engines/access/amazon/amazon_game.cpp
@@ -172,7 +172,11 @@ void AmazonEngine::setupGame() {
 		_timers.push_back(te);
 	}
 
-	// Set miscellaneous fields
+	// Miscellaenous
+	_fonts._font6x6.load(FONT6x6_INDEX, FONT6x6_DATA);
+	_fonts._font2.load(FONT2_INDEX, FONT2_DATA);
+
+	// Set player room and position
 	_player->_roomNumber = 4;
 	_player->_playerX = _player->_rawPlayer.x = TRAVEL_POS[_player->_roomNumber][0];
 	_player->_playerY = _player->_rawPlayer.y = TRAVEL_POS[_player->_roomNumber][1];
diff --git a/engines/access/amazon/amazon_resources.cpp b/engines/access/amazon/amazon_resources.cpp
index 15cf190..b7a2472 100644
--- a/engines/access/amazon/amazon_resources.cpp
+++ b/engines/access/amazon/amazon_resources.cpp
@@ -1007,6 +1007,186 @@ const char *const INVENTORY_NAMES[] = {
 	"JASON'S CAR KEYS", "PESO BILLS", "PLANK"
 };
 
+const int FONT2_INDEX[] = {
+	62, 2, 6,
+	0x0000, 0x0019, 0x0021, 0x002e, 0x0041, 0x005a, 0x0073, 0x008c, 0x0093, 0x009b,
+	0x00a3, 0x00bc, 0x00d5, 0x00dd, 0x00ea, 0x00f1, 0x00fe, 0x010b, 0x0118, 0x0125,
+	0x0132, 0x013f, 0x014c, 0x0159, 0x0166, 0x0173, 0x0180, 0x0187, 0x018e, 0x01a7,
+	0x01b4, 0x01cd, 0x01dc, 0x01f5, 0x0208, 0x0215, 0x0222, 0x022f, 0x023c, 0x0249,
+	0x025c, 0x0269, 0x0276, 0x0285, 0x0292, 0x029f, 0x02b2, 0x02c5, 0x02d2, 0x02df,
+	0x02ee, 0x02fb, 0x0308, 0x0315, 0x0322, 0x032f, 0x0342, 0x034f, 0x0362, 0x036f,
+	0x0388, 0x03a1,
+};
+
+const byte FONT2_DATA[] = {
+	0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xf0, 0xf0, 0xf0, 0xf0,
+	0x00, 0xf0, 0x00, 0x06, 0xf3, 0xc0, 0xc3, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x07, 0x1c, 0x00,
+	0x67, 0x9e, 0xc0, 0x07, 0x1c, 0x00, 0x67, 0x9e, 0xc0, 0x07,
+	0x1c, 0x00, 0x00, 0x00, 0x00, 0x09, 0x02, 0xc0, 0x00, 0x3f,
+	0xfc, 0x00, 0xb2, 0xc0, 0x00, 0x3f, 0xfc, 0x00, 0x02, 0xcb,
+	0x00, 0x3f, 0xfc, 0x00, 0x03, 0xc0, 0x00, 0x00, 0x00, 0x00,
+	0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x03, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x18, 0x60,
+	0x70, 0x70, 0x60, 0x1c, 0x00, 0x04, 0x60, 0x18, 0x1c, 0x1c,
+	0x1c, 0x70, 0x00, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x30,
+	0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xc0,
+	0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0xf0, 0xf0,
+	0x00, 0x07, 0x00, 0xf0, 0x03, 0xc0, 0x0f, 0x00, 0x3c, 0x00,
+	0xf0, 0x00, 0x00, 0x00, 0x07, 0x3f, 0xc0, 0x70, 0x70, 0x70,
+	0x70, 0x70, 0x70, 0x3f, 0xc0, 0x00, 0x00, 0x07, 0x1f, 0x00,
+	0x07, 0x00, 0x07, 0x00, 0x07, 0x00, 0xff, 0xf0, 0x00, 0x00,
+	0x08, 0x2b, 0xf0, 0xb0, 0x2c, 0x00, 0xa0, 0x0a, 0x00, 0xff,
+	0xfc, 0x00, 0x00, 0x07, 0xff, 0xc0, 0x00, 0x70, 0x03, 0xc0,
+	0x00, 0x70, 0xff, 0xc0, 0x00, 0x00, 0x07, 0x0b, 0xc0, 0x2d,
+	0xc0, 0xb1, 0xc0, 0xaa, 0xa0, 0x01, 0xc0, 0x00, 0x00, 0x07,
+	0xff, 0xf0, 0x70, 0x00, 0x7f, 0xc0, 0x00, 0xb0, 0xbf, 0xc0,
+	0x00, 0x00, 0x07, 0x2f, 0xc0, 0x70, 0x00, 0x7f, 0xc0, 0x70,
+	0x70, 0x3f, 0xc0, 0x00, 0x00, 0x08, 0xff, 0xfc, 0x00, 0xb0,
+	0x02, 0xc0, 0x02, 0xc0, 0x0b, 0x00, 0x00, 0x00, 0x08, 0x2f,
+	0xf0, 0xb0, 0x1c, 0x2f, 0xf0, 0xb0, 0x1c, 0x2f, 0xf0, 0x00,
+	0x00, 0x07, 0x3f, 0xc0, 0x70, 0x70, 0x3f, 0xf0, 0x00, 0x70,
+	0x3f, 0xc0, 0x00, 0x00, 0x03, 0xf0, 0xf0, 0x00, 0xf0, 0xf0,
+	0x00, 0x03, 0xf0, 0xf0, 0x00, 0xf0, 0x30, 0x00, 0x09, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0xff, 0xc0, 0x00, 0x00,
+	0xff, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x06, 0xff, 0x00, 0x03, 0xc0, 0x0f, 0x00, 0x3c, 0x00,
+	0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x0a, 0x00, 0x40, 0x00, 0x01, 0xf0, 0x00, 0x07, 0x1c,
+	0x00, 0x1f, 0xff, 0x00, 0x70, 0x01, 0xc0, 0x00, 0x00, 0x00,
+	0x08, 0x7f, 0xf0, 0x70, 0x1c, 0x7f, 0xf0, 0x70, 0x1c, 0x6a,
+	0xb0, 0x00, 0x00, 0x08, 0x2f, 0xfc, 0x70, 0x00, 0x70, 0x00,
+	0x70, 0x00, 0x2a, 0xa8, 0x00, 0x00, 0x08, 0x7f, 0xf0, 0x70,
+	0x1c, 0x70, 0x1c, 0x70, 0x1c, 0x6a, 0xb0, 0x00, 0x00, 0x07,
+	0x7f, 0xf0, 0x70, 0x00, 0x7f, 0xc0, 0x70, 0x00, 0x6a, 0xa0,
+	0x00, 0x00, 0x07, 0x7f, 0xf0, 0x70, 0x00, 0x7f, 0xc0, 0x70,
+	0x00, 0x60, 0x00, 0x00, 0x00, 0x09, 0x3f, 0xfc, 0x00, 0x70,
+	0x00, 0x00, 0x70, 0xff, 0x00, 0x70, 0x1c, 0x00, 0x2a, 0xbc,
+	0x00, 0x00, 0x00, 0x00, 0x08, 0x70, 0x1c, 0x70, 0x1c, 0x7f,
+	0xfc, 0x70, 0x1c, 0x70, 0x1c, 0x00, 0x00, 0x07, 0xff, 0xf0,
+	0x07, 0x00, 0x07, 0x00, 0x07, 0x00, 0xaa, 0xa0, 0x00, 0x00,
+	0x08, 0x0f, 0xfc, 0x00, 0x70, 0x00, 0x70, 0x00, 0x70, 0x70,
+	0x70, 0x2a, 0x40, 0x00, 0x00, 0x08, 0x70, 0x2c, 0x72, 0xc0,
+	0x7f, 0x00, 0x72, 0xc0, 0x70, 0x28, 0x00, 0x00, 0x07, 0x70,
+	0x00, 0x70, 0x00, 0x70, 0x00, 0x70, 0x00, 0x6a, 0xa0, 0x00,
+	0x00, 0x0a, 0x70, 0x02, 0xc0, 0x7c, 0x09, 0xc0, 0x77, 0x2d,
+	0xc0, 0x71, 0xb1, 0xc0, 0x60, 0xc1, 0x80, 0x00, 0x00, 0x00,
+	0x09, 0x70, 0x07, 0x00, 0x77, 0x07, 0x00, 0x71, 0xc7, 0x00,
+	0x70, 0x77, 0x00, 0x60, 0x06, 0x00, 0x00, 0x00, 0x00, 0x08,
+	0x2f, 0xf0, 0x70, 0x1c, 0x70, 0x1c, 0x70, 0x1c, 0x2a, 0xa0,
+	0x00, 0x00, 0x08, 0x7f, 0xf0, 0x70, 0x1c, 0x7f, 0xf0, 0x70,
+	0x00, 0x60, 0x00, 0x00, 0x00, 0x08, 0x2f, 0xf0, 0x70, 0x1c,
+	0x70, 0x1c, 0x71, 0xdc, 0x2a, 0xa0, 0x00, 0x1c, 0x00, 0x00,
+	0x08, 0x7f, 0xf0, 0x70, 0x1c, 0x7f, 0xc0, 0x70, 0x70, 0x60,
+	0x18, 0x00, 0x00, 0x07, 0x2f, 0xf0, 0x70, 0x00, 0x2f, 0xc0,
+	0x00, 0xb0, 0xbf, 0xc0, 0x00, 0x00, 0x07, 0xff, 0xf0, 0x0b,
+	0x00, 0x07, 0x00, 0x07, 0x00, 0x07, 0x00, 0x00, 0x00, 0x08,
+	0x70, 0x1c, 0x70, 0x1c, 0x70, 0x1c, 0x70, 0xdc, 0x1f, 0x1c,
+	0x00, 0x00, 0x08, 0xf0, 0x1c, 0xb0, 0x1c, 0x70, 0xb0, 0x72,
+	0xc0, 0x7f, 0x00, 0x00, 0x00, 0x0b, 0xf0, 0x00, 0xb0, 0xb0,
+	0x00, 0x70, 0x70, 0xc0, 0x70, 0x72, 0x72, 0xc0, 0x7c, 0x1f,
+	0x00, 0x00, 0x00, 0x00, 0x08, 0xf0, 0x3c, 0x1c, 0xe0, 0x07,
+	0xc0, 0x1c, 0x70, 0x70, 0x1c, 0x00, 0x00, 0x09, 0x70, 0x07,
+	0x00, 0x1c, 0x1c, 0x00, 0x07, 0xf0, 0x00, 0x01, 0xc0, 0x00,
+	0x01, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x08, 0xff, 0xfc, 0x00,
+	0x70, 0x07, 0x00, 0x1c, 0x00, 0xaa, 0xac, 0x00, 0x00, 0x09,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00,
+};
+
+const int FONT6x6_INDEX[] = {
+	62, 1, 6,
+	0x0000, 0x0007, 0x000e, 0x0015, 0x001c, 0x0023, 0x002a, 0x0031, 0x0038, 0x003f,
+	0x0046, 0x004d, 0x0054, 0x005b, 0x0062, 0x0069, 0x0070, 0x0077, 0x007e, 0x0085,
+	0x008c, 0x0093, 0x009a, 0x00a1, 0x00a8, 0x00af, 0x00b6, 0x00bd, 0x00c4, 0x00cb,
+	0x00d2, 0x00d9, 0x00e0, 0x00e7, 0x00ee, 0x00f5, 0x00fc, 0x0103, 0x010a, 0x0111,
+	0x0118, 0x011f, 0x0126, 0x012d, 0x0134, 0x013b, 0x0142, 0x0149, 0x0150, 0x0157,
+	0x015e, 0x0165, 0x016c, 0x0173, 0x017a, 0x0181, 0x0188, 0x018f, 0x0196, 0x019d,
+	0x01a4, 0x01ab,
+};
+
+const byte FONT6x6_DATA[] = {
+	0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x30, 0x30,
+	0x30, 0x30, 0x00, 0x30, 0x06, 0xd8, 0xd8, 0x90, 0x00, 0x00,
+	0x00, 0x06, 0x50, 0xf8, 0x50, 0xf8, 0x50, 0x00, 0x06, 0x78,
+	0xa0, 0x70, 0x28, 0xf0, 0x20, 0x06, 0xc8, 0xd0, 0x20, 0x58,
+	0x98, 0x00, 0x06, 0x60, 0xd0, 0x60, 0xe8, 0xd0, 0x68, 0x06,
+	0x30, 0x30, 0x60, 0x00, 0x00, 0x00, 0x06, 0x30, 0x60, 0x60,
+	0x60, 0x30, 0x00, 0x07, 0x30, 0x18, 0x18, 0x18, 0x30, 0x00,
+	0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x20, 0x20,
+	0xf8, 0x20, 0x20, 0x00, 0x06, 0x00, 0x00, 0x00, 0x30, 0x30,
+	0x60, 0x06, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0x06, 0x00,
+	0x00, 0x00, 0x60, 0x60, 0x00, 0x06, 0x18, 0x30, 0x60, 0xc0,
+	0x80, 0x00, 0x06, 0x70, 0x98, 0xa8, 0xc8, 0x70, 0x00, 0x06,
+	0x10, 0x30, 0x10, 0x10, 0x10, 0x00, 0x06, 0xf0, 0x08, 0x70,
+	0x80, 0xf8, 0x00, 0x06, 0xf0, 0x08, 0x70, 0x08, 0xf0, 0x00,
+	0x06, 0x30, 0x50, 0x90, 0xf8, 0x10, 0x00, 0x06, 0xf0, 0x80,
+	0xf0, 0x08, 0xf0, 0x00, 0x06, 0x70, 0x80, 0xf0, 0x88, 0x70,
+	0x00, 0x06, 0xf8, 0x08, 0x10, 0x20, 0x20, 0x00, 0x06, 0x70,
+	0x88, 0x70, 0x88, 0x70, 0x00, 0x06, 0x70, 0x88, 0x78, 0x08,
+	0x70, 0x00, 0x06, 0x60, 0x60, 0x00, 0x60, 0x60, 0x00, 0x06,
+	0x60, 0x60, 0x00, 0x60, 0x20, 0x40, 0x06, 0x18, 0x30, 0x60,
+	0x30, 0x18, 0x00, 0x06, 0x00, 0x78, 0x00, 0x78, 0x00, 0x00,
+	0x06, 0x60, 0x30, 0x18, 0x30, 0x60, 0x00, 0x06, 0x70, 0x98,
+	0x30, 0x30, 0x00, 0x30, 0x06, 0x70, 0x88, 0xb8, 0xb0, 0x80,
+	0x78, 0x06, 0x70, 0x88, 0xf8, 0x88, 0x88, 0x00, 0x06, 0xf0,
+	0x88, 0xf0, 0x88, 0xf0, 0x00, 0x06, 0x78, 0x80, 0x80, 0x80,
+	0x78, 0x00, 0x06, 0xf0, 0x88, 0x88, 0x88, 0xf0, 0x00, 0x06,
+	0xf8, 0x80, 0xf0, 0x80, 0xf8, 0x00, 0x06, 0xf8, 0x80, 0xf0,
+	0x80, 0x80, 0x00, 0x06, 0x78, 0x80, 0x98, 0x88, 0x78, 0x00,
+	0x06, 0x88, 0x88, 0xf8, 0x88, 0x88, 0x00, 0x06, 0x70, 0x20,
+	0x20, 0x20, 0x70, 0x00, 0x06, 0x08, 0x08, 0x08, 0x88, 0x70,
+	0x00, 0x06, 0x90, 0xa0, 0xc0, 0xa0, 0x90, 0x00, 0x06, 0x80,
+	0x80, 0x80, 0x80, 0xf0, 0x00, 0x06, 0x88, 0xd8, 0xa8, 0x88,
+	0x88, 0x00, 0x06, 0x88, 0xc8, 0xa8, 0x98, 0x88, 0x00, 0x06,
+	0x70, 0x88, 0x88, 0x88, 0x70, 0x00, 0x06, 0xf0, 0x88, 0xf0,
+	0x80, 0x80, 0x00, 0x06, 0x70, 0x88, 0x88, 0x88, 0x70, 0x18,
+	0x06, 0xf0, 0x88, 0xf0, 0xa0, 0x98, 0x00, 0x06, 0x78, 0x80,
+	0x70, 0x08, 0xf0, 0x00, 0x06, 0xf8, 0x20, 0x20, 0x20, 0x20,
+	0x00, 0x06, 0x88, 0x88, 0x88, 0x88, 0x78, 0x00, 0x06, 0x88,
+	0x88, 0x88, 0x50, 0x20, 0x00, 0x06, 0x88, 0x88, 0xa8, 0xd8,
+	0x88, 0x00, 0x06, 0x88, 0x50, 0x20, 0x50, 0x88, 0x00, 0x06,
+	0x88, 0x88, 0x50, 0x20, 0x20, 0x00, 0x06, 0xf8, 0x10, 0x20,
+	0x40, 0xf8, 0x00, 0x06, 0x78, 0x60, 0x60, 0x60, 0x78, 0x00,
+	0x06, 0xc0, 0x60, 0x30, 0x18, 0x08, 0x00, 0x06, 0x78, 0x18,
+	0x18, 0x18, 0x78, 0x00, 0x00, 0x52, 0x41, 0x54, 0x00, 0x41,
+	0x4c, 0x43, 0x4f, 0x48, 0x4f, 0x4c, 0x00, 0x53, 0x41, 0x46,
+	0x45, 0x20, 0x43, 0x4f, 0x4d, 0x42, 0x49, 0x4e, 0x41, 0x54,
+	0x49, 0x4f, 0x4e, 0x00, 0x42, 0x45, 0x41, 0x4b, 0x45, 0x52,
+	0x00, 0x4d, 0x49, 0x43, 0x52, 0x4f, 0x46, 0x49, 0x4c, 0x4d,
+	0x00, 0x56, 0x41, 0x55, 0x4c, 0x54, 0x20, 0x4b, 0x45, 0x59,
+	0x00, 0x42, 0x4f, 0x4c, 0x54, 0x20, 0x43, 0x55, 0x54, 0x54,
+	0x45, 0x52, 0x53, 0x00, 0x42, 0x4c, 0x4f, 0x57, 0x47, 0x55,
+	0x4e, 0x00, 0x4c, 0x4f, 0x56, 0x45, 0x20, 0x50, 0x4f, 0x54,
+	0x49, 0x4f, 0x4e, 0x00, 0x4d, 0x4f, 0x4e, 0x45, 0x59, 0x00,
+	0x44, 0x41, 0x52, 0x54, 0x53, 0x00, 0x54, 0x41, 0x50, 0x45,
+	0x00, 0x4a, 0x55, 0x4e, 0x47, 0x4c, 0x45, 0x20, 0x50, 0x4f,
+	0x54, 0x49, 0x4f, 0x4e, 0x00, 0x4d, 0x4f, 0x56, 0x49,
+};
+
 } // End of namespace Amazon
 
 } // End of namespace Access
diff --git a/engines/access/amazon/amazon_resources.h b/engines/access/amazon/amazon_resources.h
index c9e3fe9..838bd29 100644
--- a/engines/access/amazon/amazon_resources.h
+++ b/engines/access/amazon/amazon_resources.h
@@ -41,6 +41,14 @@ extern const byte *CHARTBL[];
 
 extern const char *const INVENTORY_NAMES[];
 
+extern const int FONT2_INDEX[];
+
+extern const byte FONT2_DATA[];
+
+extern const int FONT6x6_INDEX[];
+
+extern const byte FONT6x6_DATA[];
+
 } // End of namespace Amazon
 
 } // End of namespace Access
diff --git a/engines/access/asurface.h b/engines/access/asurface.h
index 1efee28..85550d9 100644
--- a/engines/access/asurface.h
+++ b/engines/access/asurface.h
@@ -49,9 +49,6 @@ public:
 
 	static void init();
 public:
-	Common::Point _printOrg;
-	Common::Point _printStart;
-public:
 	virtual ~ASurface();
 
 	void clearBuffer();
diff --git a/engines/access/data.cpp b/engines/access/data.cpp
index f5dbbb3..1f8b33e 100644
--- a/engines/access/data.cpp
+++ b/engines/access/data.cpp
@@ -44,4 +44,38 @@ void TimerList::restoreTimers() {
 	}
 }
 
+/*------------------------------------------------------------------------*/
+
+Font::Font() {
+}
+
+void Font::load(const int *index, const byte *data) {
+	int count = index[0];
+	_v1 = index[1];
+	_v2 = index[2];
+
+	_chars.clear();
+	for (int idx = 0; idx < count; ++idx)
+		_chars.push_back(data + index[idx + 3]);
+}
+
+int Font::charWidth(char c) {
+	error("TODO");
+}
+
+int Font::stringWidth(const Common::String &msg) {
+	int total = 0;
+
+	for (const char *c = msg.c_str(); *c != '\0'; ++c)
+		total += charWidth(*c);
+
+	return 0;
+}
+
+/*------------------------------------------------------------------------*/
+
+FontManager::FontManager() {
+	_printMaxX = 0;
+}
+
 } // End of namespace Access
diff --git a/engines/access/data.h b/engines/access/data.h
index 9318456..6d783b1 100644
--- a/engines/access/data.h
+++ b/engines/access/data.h
@@ -86,9 +86,40 @@ public:
 };
 
 class Font {
+private:
+	int _v1;
+	int _v2;
+	Common::Array<const byte *> _chars;
+public:
+	Font();
+
+	/**
+	 * Load the given font data
+	 */
+	void load(const int *index, const byte *data);
+
+	/**
+	 * Get the width of a given character
+	 */
+	int charWidth(char c);
+
+	/**
+	 * Get the width of a given string
+	 */
+	int stringWidth(const Common::String &msg);
+};
+
+class FontManager {
 public:
 	FontVal _charSet;
 	FontVal _charFor;
+	Common::Point _printOrg;
+	Common::Point _printStart;
+	int _printMaxX;
+	Font _font6x6;
+	Font _font2;
+public:
+	FontManager();
 };
 
 } // End of namespace Access
diff --git a/engines/access/room.cpp b/engines/access/room.cpp
index 9969f33..74a30d8 100644
--- a/engines/access/room.cpp
+++ b/engines/access/room.cpp
@@ -591,10 +591,10 @@ void Room::placeBubble() {
 
 void Room::placeBubble1() {
 	_bubbleBox.clearBubbles();
-	_vm->_font._charSet._lo = 1;
-	_vm->_font._charSet._hi = 8;
-	_vm->_font._charFor._lo = 29;
-	_vm->_font._charFor._hi = 32;
+	_vm->_fonts._charSet._lo = 1;
+	_vm->_fonts._charSet._hi = 8;
+	_vm->_fonts._charFor._lo = 29;
+	_vm->_fonts._charFor._hi = 32;
 	
 	calcBubble();
 
@@ -605,10 +605,25 @@ void Room::placeBubble1() {
 }
 
 void Room::calcBubble() {
-	error("TODO: calcBubble");
+	Common::Point printOrg = _vm->_fonts._printOrg;
+	Common::Point printStart = _vm->_fonts._printStart;
+
+	Common::Rect bounds(printOrg.x - 2, printOrg.y, printOrg.x - 2, printOrg.y);
+
+	if (_bubbleBox._field0 == 4) {
+		_vm->_fonts._printMaxX = 110;
+	} else {
+
+	}
+
+
+
+	_vm->_fonts._printOrg = printOrg;
+	_vm->_fonts._printStart = printStart;
 }
 
 void Room::printBubble() {
+	//drawBubble(_bubbleBox._bubbles.size() - 1);
 	error("TODO: printBubble");
 }
 
diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp
index 0c3cd2e..2f221d9 100644
--- a/engines/access/scripts.cpp
+++ b/engines/access/scripts.cpp
@@ -172,8 +172,8 @@ void Scripts::cmdNull() {
 #define PRINT_TIMER 25
 
 void Scripts::cmdPrint() { 
-	_vm->_screen->_printOrg = Common::Point(20, 42);
-	_vm->_screen->_printStart = Common::Point(20, 42);
+	_vm->_fonts._printOrg = Common::Point(20, 42);
+	_vm->_fonts._printStart = Common::Point(20, 42);
 	_vm->_timers[PRINT_TIMER]._timer = 50;
 	_vm->_timers[PRINT_TIMER]._initTm = 50;
 	_vm->_timers[PRINT_TIMER]._flag = true;


Commit: ff01ee6807ccd6e5a71ddc945196d68b87f3aa65
    https://github.com/scummvm/scummvm/commit/ff01ee6807ccd6e5a71ddc945196d68b87f3aa65
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-16T23:18:53-04:00

Commit Message:
ACCESS: Added code for bubble box size calculations

Changed paths:
    engines/access/data.cpp
    engines/access/data.h
    engines/access/room.cpp
    engines/access/room.h



diff --git a/engines/access/data.cpp b/engines/access/data.cpp
index 1f8b33e..65702db 100644
--- a/engines/access/data.cpp
+++ b/engines/access/data.cpp
@@ -60,7 +60,7 @@ void Font::load(const int *index, const byte *data) {
 }
 
 int Font::charWidth(char c) {
-	error("TODO");
+	return *_chars[c - ' '];
 }
 
 int Font::stringWidth(const Common::String &msg) {
@@ -72,6 +72,45 @@ int Font::stringWidth(const Common::String &msg) {
 	return 0;
 }
 
+bool Font::getLine(Common::String &s, int maxWidth, Common::String &line, int &width) {
+	width = 0;
+	const char *src = s.c_str();
+	char c;
+
+	while ((c = *src) != '\0') {
+		if (c == '\r') {
+			// End of line, so return calculated line
+			line = Common::String(s.c_str(), src - 1);
+			s = Common::String(src + 1);
+			return false;
+		}
+
+		++src;
+		width += charWidth(c);
+		if (width < maxWidth)
+			continue;
+
+		// Reached maximum allowed. Work backwards to find space at the
+		// start of the current word as a point to split the line on
+		while (*src != ' ' && src >= s.c_str()) {
+			width -= charWidth(*src);
+			--src;
+		}
+		if (src < s.c_str())
+			error("Could not fit line");
+
+		// Split the line around the space
+		line = Common::String(s.c_str(), src - 1);
+		s = Common::String(src + 1);
+		return false;
+	}
+
+	// Return entire string
+	line = s;
+	s = Common::String();
+	return true;
+}
+
 /*------------------------------------------------------------------------*/
 
 FontManager::FontManager() {
diff --git a/engines/access/data.h b/engines/access/data.h
index 6d783b1..910e252 100644
--- a/engines/access/data.h
+++ b/engines/access/data.h
@@ -107,6 +107,17 @@ public:
 	 * Get the width of a given string
 	 */
 	int stringWidth(const Common::String &msg);
+
+	/**
+	 * Get a partial string that will fit in a given width
+	 * @param s			Source string. Modified to remove line
+	 * @param maxWidth	Maximum width allowed
+	 * @param line		Output line
+	 * @param width		Calculated width of returned line
+	 * @returns			True if last line
+	 */
+	bool getLine(Common::String &s, int maxWidth, Common::String &line, int &width);
+
 };
 
 class FontManager {
diff --git a/engines/access/room.cpp b/engines/access/room.cpp
index 74a30d8..b46363b 100644
--- a/engines/access/room.cpp
+++ b/engines/access/room.cpp
@@ -558,7 +558,7 @@ int Room::checkBoxes2(const Common::Point &pt, int start, int count) {
 }
 
 void Room::checkBoxes3() {
-	for (int start = 0; start < _plotter._blocks.size(); ++start) {
+	for (uint start = 0; start < _plotter._blocks.size(); ++start) {
 		if (_plotter._blocks[start].contains(_vm->_events->_mousePos)) {
 			_plotter._blockIn = start;
 			if (!(validateBox(start) & 0x80)) {
@@ -571,7 +571,7 @@ void Room::checkBoxes3() {
 					_vm->_scripts->executeScript();
 				}
 
-				_vm->_boxSelect = -1;
+				_vm->_boxSelect = true;
 				return;
 			}
 		}
@@ -605,19 +605,57 @@ void Room::placeBubble1() {
 }
 
 void Room::calcBubble() {
+	// Save points
 	Common::Point printOrg = _vm->_fonts._printOrg;
 	Common::Point printStart = _vm->_fonts._printStart;
 
-	Common::Rect bounds(printOrg.x - 2, printOrg.y, printOrg.x - 2, printOrg.y);
-
-	if (_bubbleBox._field0 == 4) {
+	// Figure out maximum width allowed
+	if (_bubbleBox._type == 4) {
 		_vm->_fonts._printMaxX = 110;
 	} else {
-
+		_vm->_fonts._printMaxX = _vm->_fonts._font2.stringWidth(_bubbleBox._bubblePtr);
 	}
 
+	// Start of with a rect with the given starting x and y
+	Common::Rect bounds(printOrg.x - 2, printOrg.y, printOrg.x - 2, printOrg.y);
+
+	// Loop through getting lines
+	Common::String msg(_bubbleBox._bubblePtr);
+	Common::String line;
+	int width = 0;
+	bool lastLine;
+	do {
+		lastLine = _vm->_fonts._font2.getLine(msg, _vm->_fonts._printMaxX, line, width);
+		width = MIN(width, _vm->_fonts._printMaxX);
+
+		_vm->_fonts._printOrg.y += 6;
+		_vm->_fonts._printOrg.x = _vm->_fonts._printStart.x;
+	} while (!lastLine);
+
+	if (_bubbleBox._type == 4)
+		++_vm->_fonts._printOrg.y += 6;
 
+	// Determine the width for the area
+	width = (((_vm->_fonts._printMaxX >> 4) + 1) << 4) + 5;
+	if (width >= 24)
+		width += 20 - ((width - 24) % 20);
+	bounds.setWidth(width);
 
+	// Determine the height for area
+	int y = _vm->_fonts._printOrg.y + 6;
+	if (_bubbleBox._type == 4)
+		y += 6;
+	int height = y - bounds.top;
+	bounds.setHeight(height);
+
+	height -= (_bubbleBox._type == 4) ? 30 : 24;
+	if (height >= 0)
+		bounds.setHeight(bounds.height() + 13 - (height % 13));
+
+	// Add the new bounds to the bubbles list
+	_bubbleBox._bubbles.push_back(bounds);
+
+	// Restore points
 	_vm->_fonts._printOrg = printOrg;
 	_vm->_fonts._printStart = printStart;
 }
@@ -627,6 +665,15 @@ void Room::printBubble() {
 	error("TODO: printBubble");
 }
 
+void Room::drawBubble(int index) {
+	_bubbleBox._bounds = _bubbleBox._bubbles[index];
+	doBox();
+}
+
+void Room::doBox() {
+	error("TODO: doBox");
+}
+
 /*------------------------------------------------------------------------*/
 
 RoomInfo::RoomInfo(const byte *data) {
@@ -688,22 +735,20 @@ RoomInfo::RoomInfo(const byte *data) {
 /*------------------------------------------------------------------------*/
 
 BubbleBox::BubbleBox() {
-	_field0 = 2;
+	_type = 2;
 	_bounds = Common::Rect(64, 32, 130, 122);
-	_bubblePtr = -1;
+	_bubblePtr = nullptr;
 	_maxChars = 0;
 }
 
 void BubbleBox::load(Common::SeekableReadStream *stream) {
-	_bubbleTit.clear();
+	_bubbleTitle.clear();
 
 	byte v;
-	do {
-		v = stream->readByte();
-		_bubbleTit.push_back(v);
-	} while (v != 0);
+	while ((v = stream->readByte()) != 0)
+		_bubbleTitle += (char)v;
 
-	_bubblePtr = 0;
+	_bubblePtr = _bubbleTitle.c_str();
 }
 
 void BubbleBox::clearBubbles() {
diff --git a/engines/access/room.h b/engines/access/room.h
index 9b26ed2..3035561 100644
--- a/engines/access/room.h
+++ b/engines/access/room.h
@@ -60,10 +60,10 @@ public:
 
 class BubbleBox {
 public:
-	int _field0;
+	int _type;
 	Common::Rect _bounds;
-	Common::Array<int> _bubbleTit;
-	int _bubblePtr;
+	Common::String _bubbleTitle;
+	const char *_bubblePtr;
 	int _maxChars;
 	Common::Array<Common::Rect> _bubbles;
 public:
@@ -165,6 +165,10 @@ public:
 	void calcBubble();
 
 	void printBubble();
+
+	void drawBubble(int index);
+
+	void doBox();
 };
 
 


Commit: 1ab89400e52da33207a14051410fad01c257d14c
    https://github.com/scummvm/scummvm/commit/1ab89400e52da33207a14051410fad01c257d14c
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-08-17T10:39:00+02:00

Commit Message:
ACCESS: Remove two unused variables

Changed paths:
    engines/access/asurface.cpp
    engines/access/scripts.cpp



diff --git a/engines/access/asurface.cpp b/engines/access/asurface.cpp
index 32e5403..08caa8a 100644
--- a/engines/access/asurface.cpp
+++ b/engines/access/asurface.cpp
@@ -253,7 +253,6 @@ void ASurface::copyTo(ASurface *dest, const Common::Rect &bounds) {
 	int scaleY = SCALE_LIMIT * bounds.height() / this->h;
 	int scaleXCtr = 0, scaleYCtr = 0;
 
-	int y = bounds.top;
 	for (int yCtr = 0, y = bounds.top; yCtr < this->h; ++yCtr) {
 		// Handle skipping lines if Y scaling 
 		scaleYCtr += scaleY;
diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp
index 2f221d9..a4d67c8 100644
--- a/engines/access/scripts.cpp
+++ b/engines/access/scripts.cpp
@@ -117,8 +117,6 @@ void Scripts::executeCommand(int commandIndex) {
 }
 
 void Scripts::CMDOBJECT() { 
-	byte id;
-	
 	_vm->_room->_bubbleBox.load(_data);
 }
 


Commit: 3e61eb9cc3f233fabf34f54069a1a1209e257008
    https://github.com/scummvm/scummvm/commit/3e61eb9cc3f233fabf34f54069a1a1209e257008
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-08-17T11:16:31+02:00

Commit Message:
ACCESS: Implement some opcodes

Changed paths:
    engines/access/access.cpp
    engines/access/access.h
    engines/access/room.h
    engines/access/scripts.cpp
    engines/access/scripts.h



diff --git a/engines/access/access.cpp b/engines/access/access.cpp
index fde5ab8..d2967c0 100644
--- a/engines/access/access.cpp
+++ b/engines/access/access.cpp
@@ -84,6 +84,9 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc)
 	Common::fill(&_help1[0], &_help1[366], 0);
 	Common::fill(&_help2[0], &_help2[366], 0);
 	Common::fill(&_help1[0], &_help3[366], 0);
+	_helpTbl[0] = _help1;
+	_helpTbl[1] = _help2;
+	_helpTbl[2] = _help3;
 	_travel = 0;
 	_ask = 0;
 	_rScrollRow = 0;
@@ -221,6 +224,9 @@ void AccessEngine::doEstablish(int v1, int v2) {
 		_buffer2.copyBuffer(_screen);
 	}
 
+	_room->setIconPalette();
+	_screen->forceFadeIn();
+
 	warning("TODO: doEstablish");
 }
 
diff --git a/engines/access/access.h b/engines/access/access.h
index fa2d24e..37be9cf 100644
--- a/engines/access/access.h
+++ b/engines/access/access.h
@@ -163,6 +163,7 @@ public:
 	byte _help1[366];
 	byte _help2[366];
 	byte _help3[366];
+	byte *_helpTbl[3];
 	int _travel;
 	int _ask;
 	int _rScrollRow;
diff --git a/engines/access/room.h b/engines/access/room.h
index 3035561..22dbd16 100644
--- a/engines/access/room.h
+++ b/engines/access/room.h
@@ -120,8 +120,6 @@ protected:
 
 	virtual void reloadRoom1() = 0;
 
-	virtual void setIconPalette() {}
-
 	virtual void doCommands();
 
 	virtual void roomMenu() = 0;
@@ -159,6 +157,7 @@ public:
 
 	void init4Quads();
 
+	virtual void setIconPalette() {}
 	void placeBubble();
 	void placeBubble1();
 
diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp
index a4d67c8..f781ec1 100644
--- a/engines/access/scripts.cpp
+++ b/engines/access/scripts.cpp
@@ -93,7 +93,7 @@ void Scripts::executeCommand(int commandIndex) {
 		&Scripts::CMDSETTEX, &Scripts::CMDNEWROOM, &Scripts::CMDCONVERSE, 
 		&Scripts::cmdCheckFrame, &Scripts::cmdCheckAnim, &Scripts::cmdSnd, 
 		&Scripts::cmdRetNeg, &Scripts::cmdRetPos, &Scripts::cmdCheckLoc, 
-		&Scripts::cmdSetAnim, &Scripts::CMDDISPINV, &Scripts::CMDSETTIMER, 
+		&Scripts::cmdSetAnim, &Scripts::cmdDispInv, &Scripts::CMDSETTIMER, 
 		&Scripts::CMDSETTIMER, &Scripts::CMDCHECKTIMER, &Scripts::cmdSetTravel,
 		&Scripts::cmdSetTravel, &Scripts::CMDSETVID, &Scripts::CMDPLAYVID, 
 		&Scripts::cmdPlotImage, &Scripts::cmdSetDisplay, &Scripts::cmdSetBuffer, 
@@ -103,13 +103,13 @@ void Scripts::executeCommand(int commandIndex) {
 		&Scripts::CMDSETCYCLE, &Scripts::CMDCYCLE, &Scripts::CMDCHARSPEAK, 
 		&Scripts::CMDTEXSPEAK, &Scripts::CMDTEXCHOICE, &Scripts::CMDWAIT, 
 		&Scripts::CMDSETCONPOS, &Scripts::CMDCHECKVFRAME, &Scripts::cmdJumpChoice, 
-		&Scripts::cmdReturnChoice, &Scripts::CMDCLEARBLOCK, &Scripts::CMDLOADSOUND, 
+		&Scripts::cmdReturnChoice, &Scripts::cmdClearBlock, &Scripts::CMDLOADSOUND, 
 		&Scripts::CMDFREESOUND, &Scripts::CMDSETVIDSND, &Scripts::CMDPLAYVIDSND,
 		&Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, 
 		&Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, &Scripts::cmdPlayerOff, 
 		&Scripts::cmdPlayerOn, &Scripts::CMDDEAD, &Scripts::cmdFadeOut,
 		&Scripts::CMDENDVID, &Scripts::CMDHELP, &Scripts::CMDCYCLEBACK, 
-		&Scripts::CMDCHAPTER, &Scripts::CMDSETHELP, &Scripts::CMDCENTERPANEL,
+		&Scripts::CMDCHAPTER, &Scripts::cmdSetHelp, &Scripts::cmdCenterPanel,
 		&Scripts::cmdMainPanel, &Scripts::CMDRETFLASH
 	};
 
@@ -296,7 +296,10 @@ void Scripts::cmdSetAnim() {
 	_vm->_animation->setAnimTimer(anim);
 }
 
-void Scripts::CMDDISPINV() { error("TODO CMDDISPINV"); }
+void Scripts::cmdDispInv() {
+	_vm->_inventory->newDisplayInv();
+}
+
 void Scripts::CMDSETTIMER() { error("TODO CMDSETTIMER"); }
 void Scripts::CMDCHECKTIMER() { error("TODO CMDCHECKTIMER"); }
 
@@ -388,7 +391,10 @@ void Scripts::cmdReturnChoice() {
 	_data->seek(_choiceStart);
 }
 
-void Scripts::CMDCLEARBLOCK() { error("TODO CMDCLEARBLOCK"); }
+void Scripts::cmdClearBlock() {
+	_vm->_screen->restoreBlock();
+}
+
 void Scripts::CMDLOADSOUND() { error("TODO CMDLOADSOUND"); }
 void Scripts::CMDFREESOUND() { error("TODO CMDFREESOUND"); }
 void Scripts::CMDSETVIDSND() { error("TODO CMDSETVIDSND"); }
@@ -413,8 +419,26 @@ void Scripts::CMDENDVID() { error("TODO CMDENDVID"); }
 void Scripts::CMDHELP() { error("TODO CMDHELP"); }
 void Scripts::CMDCYCLEBACK() { error("TODO CMDCYCLEBACK"); }
 void Scripts::CMDCHAPTER() { error("TODO CMDCHAPTER"); }
-void Scripts::CMDSETHELP() { error("TODO CMDSETHELP"); }
-void Scripts::CMDCENTERPANEL() { error("TODO CMDCENTERPANEL"); }
+
+void Scripts::cmdSetHelp() {
+	int arrayId = (_data->readUint16LE() && 0xFF) - 1;
+	int helpId = _data->readUint16LE() && 0xFF;
+
+	byte *help = _vm->_helpTbl[arrayId];
+	help[helpId] = 1;
+
+	if (_vm->_useItem == 0) {
+		_sequence = 11000;
+		searchForSequence();
+	}
+}
+
+void Scripts::cmdCenterPanel() {
+	if (_vm->_screen->_vesaMode) {
+		_vm->_screen->clearScreen();
+		_vm->_screen->setPanel(3);
+	}
+}
 
 void Scripts::cmdMainPanel() { 
 	if (_vm->_screen->_vesaMode) {
diff --git a/engines/access/scripts.h b/engines/access/scripts.h
index 78e54f5..4cf969e 100644
--- a/engines/access/scripts.h
+++ b/engines/access/scripts.h
@@ -74,7 +74,7 @@ protected:
 	void cmdRetNeg();
 	void cmdCheckLoc();
 	void cmdSetAnim();
-	void CMDDISPINV();
+	void cmdDispInv();
 	void CMDSETTIMER();
 	void CMDCHECKTIMER();
 	void cmdSetTravel();
@@ -99,7 +99,7 @@ protected:
 	void CMDCHECKVFRAME();
 	void cmdJumpChoice();
 	void cmdReturnChoice();
-	void CMDCLEARBLOCK();
+	void cmdClearBlock();
 	void CMDLOADSOUND();
 	void CMDFREESOUND();
 	void CMDSETVIDSND();
@@ -113,8 +113,8 @@ protected:
 	void CMDHELP();
 	void CMDCYCLEBACK();
 	void CMDCHAPTER();
-	void CMDSETHELP();
-	void CMDCENTERPANEL();
+	void cmdSetHelp();
+	void cmdCenterPanel();
 	void cmdMainPanel();
 	void CMDRETFLASH();
 public:


Commit: 404c7cd5d33e81c7724cb78dfce5701b26b4659b
    https://github.com/scummvm/scummvm/commit/404c7cd5d33e81c7724cb78dfce5701b26b4659b
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-17T11:14:30-04:00

Commit Message:
ACCESS: Split the bubble box code from Room into it's own file

Changed paths:
  A engines/access/bubble_box.cpp
  A engines/access/bubble_box.h
    engines/access/access.cpp
    engines/access/access.h
    engines/access/module.mk
    engines/access/room.cpp
    engines/access/room.h
    engines/access/scripts.cpp



diff --git a/engines/access/access.cpp b/engines/access/access.cpp
index d2967c0..7d12ba5 100644
--- a/engines/access/access.cpp
+++ b/engines/access/access.cpp
@@ -33,6 +33,7 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc)
 		_gameDescription(gameDesc), Engine(syst), _randomSource("Access"),
 		_useItem(_flags[100]), _startup(_flags[170]), _manScaleOff(_flags[172]) {
 	_animation = nullptr;
+	_bubbleBox = nullptr;
 	_debugger = nullptr;
 	_events = nullptr;
 	_files = nullptr;
@@ -102,6 +103,7 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc)
 
 AccessEngine::~AccessEngine() {
 	delete _animation;
+	delete _bubbleBox;
 	delete _debugger;
 	delete _events;
 	delete _files;
@@ -142,6 +144,7 @@ void AccessEngine::initialize() {
 	// Create sub-objects of the engine
 	ASurface::init();
 	_animation = new AnimationManager(this);
+	_bubbleBox = new BubbleBox(this);
 	_debugger = new Debugger(this);
 	_events = new EventsManager(this);
 	_files = new FileManager(this);
diff --git a/engines/access/access.h b/engines/access/access.h
index 37be9cf..88b6c83 100644
--- a/engines/access/access.h
+++ b/engines/access/access.h
@@ -31,6 +31,7 @@
 #include "engines/engine.h"
 #include "graphics/surface.h"
 #include "access/animation.h"
+#include "access/bubble_box.h"
 #include "access/data.h"
 #include "access/debugger.h"
 #include "access/events.h"
@@ -104,6 +105,7 @@ protected:
 	virtual void playGame() = 0;
 public:
 	AnimationManager *_animation;
+	BubbleBox *_bubbleBox;
 	Debugger *_debugger;
 	EventsManager *_events;
 	FileManager *_files;
diff --git a/engines/access/bubble_box.cpp b/engines/access/bubble_box.cpp
new file mode 100644
index 0000000..2b6d9dd
--- /dev/null
+++ b/engines/access/bubble_box.cpp
@@ -0,0 +1,144 @@
+/* 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 "common/algorithm.h"
+#include "access/bubble_box.h"
+#include "access/access.h"
+
+namespace Access {
+
+Box::Box(AccessEngine *vm) : Manager(vm) {
+	_edgeSize = 0;
+}
+
+void Box::doBox(int item, int box) {
+	error("TODO: doBox");
+}
+
+/*------------------------------------------------------------------------*/
+
+BubbleBox::BubbleBox(AccessEngine *vm) : Box(vm) {
+	_bubblePtr = nullptr;
+	_maxChars = 0;
+}
+
+void BubbleBox::load(Common::SeekableReadStream *stream) {
+	_bubbleTitle.clear();
+
+	byte v;
+	while ((v = stream->readByte()) != 0)
+		_bubbleTitle += (char)v;
+
+	_bubblePtr = _bubbleTitle.c_str();
+}
+
+void BubbleBox::clearBubbles() {
+	_bubbles.clear();
+}
+
+void BubbleBox::placeBubble() {
+	BubbleBox::_maxChars = 27;
+	placeBubble1();
+}
+
+void BubbleBox::placeBubble1() {
+	BubbleBox::clearBubbles();
+	_vm->_fonts._charSet._lo = 1;
+	_vm->_fonts._charSet._hi = 8;
+	_vm->_fonts._charFor._lo = 29;
+	_vm->_fonts._charFor._hi = 32;
+
+	calcBubble();
+
+	Common::Rect r = BubbleBox::_bubbles[0];
+	r.translate(-2, 0);
+	_vm->_screen->saveBlock(r);
+	printBubble();
+}
+
+void BubbleBox::calcBubble() {
+	// Save points
+	Common::Point printOrg = _vm->_fonts._printOrg;
+	Common::Point printStart = _vm->_fonts._printStart;
+
+	// Figure out maximum width allowed
+	if (_edgeSize == 4) {
+		_vm->_fonts._printMaxX = 110;
+	} else {
+		_vm->_fonts._printMaxX = _vm->_fonts._font2.stringWidth(BubbleBox::_bubblePtr);
+	}
+
+	// Start of with a rect with the given starting x and y
+	Common::Rect bounds(printOrg.x - 2, printOrg.y, printOrg.x - 2, printOrg.y);
+
+	// Loop through getting lines
+	Common::String msg(BubbleBox::_bubblePtr);
+	Common::String line;
+	int width = 0;
+	bool lastLine;
+	do {
+		lastLine = _vm->_fonts._font2.getLine(msg, _vm->_fonts._printMaxX, line, width);
+		width = MIN(width, _vm->_fonts._printMaxX);
+
+		_vm->_fonts._printOrg.y += 6;
+		_vm->_fonts._printOrg.x = _vm->_fonts._printStart.x;
+	} while (!lastLine);
+
+	if (_edgeSize == 4)
+		++_vm->_fonts._printOrg.y += 6;
+
+	// Determine the width for the area
+	width = (((_vm->_fonts._printMaxX >> 4) + 1) << 4) + 5;
+	if (width >= 24)
+		width += 20 - ((width - 24) % 20);
+	bounds.setWidth(width);
+
+	// Determine the height for area
+	int y = _vm->_fonts._printOrg.y + 6;
+	if (_edgeSize == 4)
+		y += 6;
+	int height = y - bounds.top;
+	bounds.setHeight(height);
+
+	height -= (_edgeSize == 4) ? 30 : 24;
+	if (height >= 0)
+		bounds.setHeight(bounds.height() + 13 - (height % 13));
+
+	// Add the new bounds to the bubbles list
+	BubbleBox::_bubbles.push_back(bounds);
+
+	// Restore points
+	_vm->_fonts._printOrg = printOrg;
+	_vm->_fonts._printStart = printStart;
+}
+
+void BubbleBox::printBubble() {
+	//drawBubble(BubbleBox::_bubbles.size() - 1);
+	error("TODO: printBubble");
+}
+
+void BubbleBox::drawBubble(int index) {
+	_bounds = BubbleBox::_bubbles[index];
+	doBox(0, 0);
+}
+
+} // End of namespace Access
diff --git a/engines/access/bubble_box.h b/engines/access/bubble_box.h
new file mode 100644
index 0000000..e02fa7c
--- /dev/null
+++ b/engines/access/bubble_box.h
@@ -0,0 +1,75 @@
+/* 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 ACCESS_BUBBLE_BOX_H
+#define ACCESS_BUBBLE_BOX_H
+
+#include "common/scummsys.h"
+#include "common/array.h"
+#include "common/rect.h"
+#include "common/stream.h"
+#include "common/types.h"
+#include "graphics/surface.h"
+#include "access/data.h"
+
+namespace Access {
+
+class AccessEngine;
+
+class Box: public Manager {
+public:
+	int _edgeSize;
+	Common::Rect _bounds;
+public:
+	Box(AccessEngine *vm);
+
+	void doBox(int item, int box);
+};
+
+class BubbleBox: public Box {
+public:
+	Common::String _bubbleTitle;
+	const char *_bubblePtr;
+	int _maxChars;
+	Common::Array<Common::Rect> _bubbles;
+public:
+	BubbleBox(AccessEngine *vm);
+
+	void load(Common::SeekableReadStream *stream);
+
+	void clearBubbles();
+
+	void placeBubble();
+	void placeBubble1();
+
+	void calcBubble();
+
+	void printBubble();
+
+	void drawBubble(int index);
+
+
+};
+
+} // End of namespace Access
+
+#endif /* ACCESS_BUBBLE_BOX_H */
diff --git a/engines/access/module.mk b/engines/access/module.mk
index 6f906a9..d74892c 100644
--- a/engines/access/module.mk
+++ b/engines/access/module.mk
@@ -4,6 +4,7 @@ MODULE_OBJS := \
 	animation.o \
 	asurface.o \
 	access.o \
+	bubble_box.o \
 	data.o \
 	debugger.o \
 	decompress.o \
diff --git a/engines/access/room.cpp b/engines/access/room.cpp
index b46363b..0405e7c 100644
--- a/engines/access/room.cpp
+++ b/engines/access/room.cpp
@@ -584,96 +584,6 @@ int Room::validateBox(int boxId) {
 	return _vm->_scripts->executeScript();
 }
 
-void Room::placeBubble() {
-	_bubbleBox._maxChars = 27;
-	placeBubble1();
-}
-
-void Room::placeBubble1() {
-	_bubbleBox.clearBubbles();
-	_vm->_fonts._charSet._lo = 1;
-	_vm->_fonts._charSet._hi = 8;
-	_vm->_fonts._charFor._lo = 29;
-	_vm->_fonts._charFor._hi = 32;
-	
-	calcBubble();
-
-	Common::Rect r = _bubbleBox._bubbles[0];
-	r.translate(-2, 0);
-	_vm->_screen->saveBlock(r);
-	printBubble();
-}
-
-void Room::calcBubble() {
-	// Save points
-	Common::Point printOrg = _vm->_fonts._printOrg;
-	Common::Point printStart = _vm->_fonts._printStart;
-
-	// Figure out maximum width allowed
-	if (_bubbleBox._type == 4) {
-		_vm->_fonts._printMaxX = 110;
-	} else {
-		_vm->_fonts._printMaxX = _vm->_fonts._font2.stringWidth(_bubbleBox._bubblePtr);
-	}
-
-	// Start of with a rect with the given starting x and y
-	Common::Rect bounds(printOrg.x - 2, printOrg.y, printOrg.x - 2, printOrg.y);
-
-	// Loop through getting lines
-	Common::String msg(_bubbleBox._bubblePtr);
-	Common::String line;
-	int width = 0;
-	bool lastLine;
-	do {
-		lastLine = _vm->_fonts._font2.getLine(msg, _vm->_fonts._printMaxX, line, width);
-		width = MIN(width, _vm->_fonts._printMaxX);
-
-		_vm->_fonts._printOrg.y += 6;
-		_vm->_fonts._printOrg.x = _vm->_fonts._printStart.x;
-	} while (!lastLine);
-
-	if (_bubbleBox._type == 4)
-		++_vm->_fonts._printOrg.y += 6;
-
-	// Determine the width for the area
-	width = (((_vm->_fonts._printMaxX >> 4) + 1) << 4) + 5;
-	if (width >= 24)
-		width += 20 - ((width - 24) % 20);
-	bounds.setWidth(width);
-
-	// Determine the height for area
-	int y = _vm->_fonts._printOrg.y + 6;
-	if (_bubbleBox._type == 4)
-		y += 6;
-	int height = y - bounds.top;
-	bounds.setHeight(height);
-
-	height -= (_bubbleBox._type == 4) ? 30 : 24;
-	if (height >= 0)
-		bounds.setHeight(bounds.height() + 13 - (height % 13));
-
-	// Add the new bounds to the bubbles list
-	_bubbleBox._bubbles.push_back(bounds);
-
-	// Restore points
-	_vm->_fonts._printOrg = printOrg;
-	_vm->_fonts._printStart = printStart;
-}
-
-void Room::printBubble() {
-	//drawBubble(_bubbleBox._bubbles.size() - 1);
-	error("TODO: printBubble");
-}
-
-void Room::drawBubble(int index) {
-	_bubbleBox._bounds = _bubbleBox._bubbles[index];
-	doBox();
-}
-
-void Room::doBox() {
-	error("TODO: doBox");
-}
-
 /*------------------------------------------------------------------------*/
 
 RoomInfo::RoomInfo(const byte *data) {
@@ -732,28 +642,4 @@ RoomInfo::RoomInfo(const byte *data) {
 	}
 }
 
-/*------------------------------------------------------------------------*/
-
-BubbleBox::BubbleBox() {
-	_type = 2;
-	_bounds = Common::Rect(64, 32, 130, 122);
-	_bubblePtr = nullptr;
-	_maxChars = 0;
-}
-
-void BubbleBox::load(Common::SeekableReadStream *stream) {
-	_bubbleTitle.clear();
-
-	byte v;
-	while ((v = stream->readByte()) != 0)
-		_bubbleTitle += (char)v;
-
-	_bubblePtr = _bubbleTitle.c_str();
-}
-
-void BubbleBox::clearBubbles() {
-	_bubbles.clear();
-}
-
-
 } // End of namespace Access
diff --git a/engines/access/room.h b/engines/access/room.h
index 22dbd16..f76db6f 100644
--- a/engines/access/room.h
+++ b/engines/access/room.h
@@ -58,22 +58,6 @@ public:
 	}
 };
 
-class BubbleBox {
-public:
-	int _type;
-	Common::Rect _bounds;
-	Common::String _bubbleTitle;
-	const char *_bubblePtr;
-	int _maxChars;
-	Common::Array<Common::Rect> _bubbles;
-public:
-	BubbleBox();
-
-	void load(Common::SeekableReadStream *stream);
-
-	void clearBubbles();
-};
-
 class Room: public Manager {
 private:
 	void roomLoop();
@@ -126,9 +110,10 @@ protected:
 
 	virtual void mainAreaClick() = 0;
 public:
+	virtual void setIconPalette() {}
+public:
 	Plotter _plotter;
 	Common::Array<JetFrame> _jetFrame;
-	BubbleBox _bubbleBox;
 	int _function;
 	int _roomFlag;
 	byte *_playField;
@@ -156,21 +141,8 @@ public:
 	void buildRow(int playY, int screenY);
 
 	void init4Quads();
-
-	virtual void setIconPalette() {}
-	void placeBubble();
-	void placeBubble1();
-
-	void calcBubble();
-
-	void printBubble();
-
-	void drawBubble(int index);
-
-	void doBox();
 };
 
-
 class RoomInfo {
 public:
 	struct FileIdent {
diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp
index f781ec1..f91b49c 100644
--- a/engines/access/scripts.cpp
+++ b/engines/access/scripts.cpp
@@ -117,7 +117,7 @@ void Scripts::executeCommand(int commandIndex) {
 }
 
 void Scripts::CMDOBJECT() { 
-	_vm->_room->_bubbleBox.load(_data);
+	_vm->_bubbleBox->load(_data);
 }
 
 void Scripts::CMDENDOBJECT() { error("TODO ENDOBJECT"); }
@@ -176,7 +176,7 @@ void Scripts::cmdPrint() {
 	_vm->_timers[PRINT_TIMER]._initTm = 50;
 	_vm->_timers[PRINT_TIMER]._flag = true;
 
-	_vm->_room->placeBubble();
+	_vm->_bubbleBox->placeBubble();
 	_vm->_events->waitKeyMouse();
 
 	while (_vm->_timers[PRINT_TIMER]._flag) {


Commit: 77626b72a59f0a9bf35da3f77032c018fe5d7963
    https://github.com/scummvm/scummvm/commit/77626b72a59f0a9bf35da3f77032c018fe5d7963
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-17T12:01:28-04:00

Commit Message:
ACCESS: Add missing string parameters to bubble box methods

Changed paths:
    engines/access/bubble_box.cpp
    engines/access/bubble_box.h
    engines/access/scripts.cpp



diff --git a/engines/access/bubble_box.cpp b/engines/access/bubble_box.cpp
index 2b6d9dd..5f0cb94 100644
--- a/engines/access/bubble_box.cpp
+++ b/engines/access/bubble_box.cpp
@@ -55,27 +55,27 @@ void BubbleBox::clearBubbles() {
 	_bubbles.clear();
 }
 
-void BubbleBox::placeBubble() {
+void BubbleBox::placeBubble(const Common::String &msg) {
 	BubbleBox::_maxChars = 27;
-	placeBubble1();
+	placeBubble1(msg);
 }
 
-void BubbleBox::placeBubble1() {
+void BubbleBox::placeBubble1(const Common::String &msg) {
 	BubbleBox::clearBubbles();
 	_vm->_fonts._charSet._lo = 1;
 	_vm->_fonts._charSet._hi = 8;
 	_vm->_fonts._charFor._lo = 29;
 	_vm->_fonts._charFor._hi = 32;
 
-	calcBubble();
+	calcBubble(msg);
 
 	Common::Rect r = BubbleBox::_bubbles[0];
 	r.translate(-2, 0);
 	_vm->_screen->saveBlock(r);
-	printBubble();
+	printBubble(msg);
 }
 
-void BubbleBox::calcBubble() {
+void BubbleBox::calcBubble(const Common::String &msg) {
 	// Save points
 	Common::Point printOrg = _vm->_fonts._printOrg;
 	Common::Point printStart = _vm->_fonts._printStart;
@@ -84,19 +84,19 @@ void BubbleBox::calcBubble() {
 	if (_edgeSize == 4) {
 		_vm->_fonts._printMaxX = 110;
 	} else {
-		_vm->_fonts._printMaxX = _vm->_fonts._font2.stringWidth(BubbleBox::_bubblePtr);
+		_vm->_fonts._printMaxX = _vm->_fonts._font2.stringWidth(_bubblePtr);
 	}
 
 	// Start of with a rect with the given starting x and y
 	Common::Rect bounds(printOrg.x - 2, printOrg.y, printOrg.x - 2, printOrg.y);
 
 	// Loop through getting lines
-	Common::String msg(BubbleBox::_bubblePtr);
+	Common::String s = msg;
 	Common::String line;
 	int width = 0;
 	bool lastLine;
 	do {
-		lastLine = _vm->_fonts._font2.getLine(msg, _vm->_fonts._printMaxX, line, width);
+		lastLine = _vm->_fonts._font2.getLine(s, _vm->_fonts._printMaxX, line, width);
 		width = MIN(width, _vm->_fonts._printMaxX);
 
 		_vm->_fonts._printOrg.y += 6;
@@ -131,8 +131,8 @@ void BubbleBox::calcBubble() {
 	_vm->_fonts._printStart = printStart;
 }
 
-void BubbleBox::printBubble() {
-	//drawBubble(BubbleBox::_bubbles.size() - 1);
+void BubbleBox::printBubble(const Common::String &msg) {
+	drawBubble(BubbleBox::_bubbles.size() - 1);
 	error("TODO: printBubble");
 }
 
diff --git a/engines/access/bubble_box.h b/engines/access/bubble_box.h
index e02fa7c..189e0b1 100644
--- a/engines/access/bubble_box.h
+++ b/engines/access/bubble_box.h
@@ -58,13 +58,23 @@ public:
 
 	void clearBubbles();
 
-	void placeBubble();
-	void placeBubble1();
-
-	void calcBubble();
-
-	void printBubble();
-
+	void placeBubble(const Common::String &msg);
+	void placeBubble1(const Common::String &msg);
+
+	/**
+	 * Calculate the size of a bubble needed to hold a given string
+	 */
+	void calcBubble(const Common::String &msg);
+
+	/**
+	 * Prints a text bubble and it's contents 
+	 */
+	void printBubble(const Common::String &msg);
+
+	/*
+	 * Draws the background for a text bubble
+	 * @param index		Index of bounds in _bubbles array
+	 */
 	void drawBubble(int index);
 
 
diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp
index f91b49c..640514a 100644
--- a/engines/access/scripts.cpp
+++ b/engines/access/scripts.cpp
@@ -176,13 +176,22 @@ void Scripts::cmdPrint() {
 	_vm->_timers[PRINT_TIMER]._initTm = 50;
 	_vm->_timers[PRINT_TIMER]._flag = true;
 
-	_vm->_bubbleBox->placeBubble();
+	// Get a text line for display
+	Common::String msg;
+	byte c;
+	while ((c = (char)_data->readByte()) != '\0')
+		msg += c;
+
+	// Display the text in a bubble, and wait for a keypress or mouse click
+	_vm->_bubbleBox->placeBubble(msg);
 	_vm->_events->waitKeyMouse();
 
+	// Wait until the bubble display is expired
 	while (_vm->_timers[PRINT_TIMER]._flag) {
 		_vm->_events->pollEvents();
 	}
 
+	// Restore the original screen over the text bubble
 	_vm->_screen->restoreBlock();
 }
 


Commit: 1b69da3d17c7dce0c64eb23e7c5499a20c60cd47
    https://github.com/scummvm/scummvm/commit/1b69da3d17c7dce0c64eb23e7c5499a20c60cd47
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-08-17T21:49:07+02:00

Commit Message:
ACCESS: Implement some more opcodes

Changed paths:
    engines/access/scripts.cpp
    engines/access/scripts.h



diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp
index 640514a..a209efc 100644
--- a/engines/access/scripts.cpp
+++ b/engines/access/scripts.cpp
@@ -36,6 +36,8 @@ Scripts::Scripts(AccessEngine *vm) : _vm(vm) {
 	_returnCode = 0;
 	_choice = 0;
 	_choiceStart = 0;
+	_charsOrg = Common::Point(0, 0);
+	_texsOrg = Common::Point(0, 0);
 }
 
 Scripts::~Scripts() {
@@ -65,6 +67,10 @@ void Scripts::searchForSequence() {
 	} while (sequenceId != _sequence);
 }
 
+void Scripts::findNull() {
+	// No implementation required in ScummVM, the strings in the script files are already skipped by the use of readByte()
+}
+
 int Scripts::executeScript() {
 	assert(_data);
 	_endFlag = false;
@@ -100,9 +106,9 @@ void Scripts::executeCommand(int commandIndex) {
 		&Scripts::cmdSetScroll, &Scripts::CMDSAVERECT, &Scripts::CMDSAVERECT, 
 		&Scripts::CMDSETBUFVID, &Scripts::CMDPLAYBUFVID, &Scripts::cmdRemoveLast, 
 		&Scripts::CMDSPECIAL, &Scripts::CMDSPECIAL, &Scripts::CMDSPECIAL,
-		&Scripts::CMDSETCYCLE, &Scripts::CMDCYCLE, &Scripts::CMDCHARSPEAK, 
-		&Scripts::CMDTEXSPEAK, &Scripts::CMDTEXCHOICE, &Scripts::CMDWAIT, 
-		&Scripts::CMDSETCONPOS, &Scripts::CMDCHECKVFRAME, &Scripts::cmdJumpChoice, 
+		&Scripts::CMDSETCYCLE, &Scripts::CMDCYCLE, &Scripts::cmdCharSpeak, 
+		&Scripts::cmdTexSpeak, &Scripts::CMDTEXCHOICE, &Scripts::CMDWAIT, 
+		&Scripts::cmdSetConPos, &Scripts::CMDCHECKVFRAME, &Scripts::cmdJumpChoice, 
 		&Scripts::cmdReturnChoice, &Scripts::cmdClearBlock, &Scripts::CMDLOADSOUND, 
 		&Scripts::CMDFREESOUND, &Scripts::CMDSETVIDSND, &Scripts::CMDPLAYVIDSND,
 		&Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, 
@@ -379,11 +385,48 @@ void Scripts::CMDSPECIAL() {
 
 void Scripts::CMDSETCYCLE() { error("TODO CMDSETCYCLE"); }
 void Scripts::CMDCYCLE() { error("TODO CMDCYCLE"); }
-void Scripts::CMDCHARSPEAK() { error("TODO CMDCHARSPEAK"); }
-void Scripts::CMDTEXSPEAK() { error("TODO CMDTEXSPEAK"); }
+
+void Scripts::cmdCharSpeak() {
+	_vm->_fonts._printOrg = _charsOrg;
+	_vm->_fonts._printStart = _charsOrg;
+
+	byte v;
+	Common::String tmpStr = "";
+	while ((v = _data->readByte()) != 0)
+		tmpStr += (char)v;
+
+	_vm->_bubbleBox->placeBubble(tmpStr);
+	findNull();
+}
+
+void Scripts::cmdTexSpeak() {
+	_vm->_fonts._printOrg = _texsOrg;
+	_vm->_fonts._printStart = _texsOrg;
+	_vm->_bubbleBox->_maxChars = 20;
+
+	byte v;
+	Common::String tmpStr = "";
+	while ((v = _data->readByte()) != 0)
+		tmpStr += (char)v;
+
+	_vm->_bubbleBox->_bubblePtr = Common::String("JASON").c_str();
+	_vm->_bubbleBox->placeBubble1(tmpStr);
+	findNull();
+}
+
 void Scripts::CMDTEXCHOICE() { error("TODO CMDTEXCHOICE"); } // _choiceStart = _data->pos() - 1;
 void Scripts::CMDWAIT() { error("TODO CMDWAIT"); }
-void Scripts::CMDSETCONPOS() { error("TODO CMDSETCONPOS"); }
+
+void Scripts::cmdSetConPos() {
+	int x = _data->readSint16LE();
+	int y = _data->readSint16LE();
+	_charsOrg = Common::Point(x, y);
+
+	x = _data->readSint16LE();
+	y = _data->readSint16LE();
+	_texsOrg = Common::Point(x, y);
+}
+
 void Scripts::CMDCHECKVFRAME() { error("TODO CMDCHECKVFRAME"); }
 
 void Scripts::cmdJumpChoice() {
diff --git a/engines/access/scripts.h b/engines/access/scripts.h
index 4cf969e..aae3146 100644
--- a/engines/access/scripts.h
+++ b/engines/access/scripts.h
@@ -91,11 +91,11 @@ protected:
 	void CMDSPECIAL();
 	void CMDSETCYCLE();
 	void CMDCYCLE();
-	void CMDCHARSPEAK();
-	void CMDTEXSPEAK();
+	void cmdCharSpeak();
+	void cmdTexSpeak();
 	void CMDTEXCHOICE();
 	void CMDWAIT();
-	void CMDSETCONPOS();
+	void cmdSetConPos();
 	void CMDCHECKVFRAME();
 	void cmdJumpChoice();
 	void cmdReturnChoice();
@@ -124,6 +124,7 @@ public:
 	int _scriptCommand;
 	int _choice;
 	int32 _choiceStart;
+	Common::Point _charsOrg, _texsOrg;
 public:
 	Scripts(AccessEngine *vm);
 
@@ -136,6 +137,8 @@ public:
 	void searchForSequence();
 	
 	int executeScript();
+
+	void findNull();
 };
 
 } // End of namespace Access


Commit: 4ea9339d183cb53f465d7752e739cf8a153a7978
    https://github.com/scummvm/scummvm/commit/4ea9339d183cb53f465d7752e739cf8a153a7978
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-08-17T22:42:28+02:00

Commit Message:
ACCESS: Implement cmdSetTex()

Changed paths:
    engines/access/player.h
    engines/access/room.h
    engines/access/scripts.cpp
    engines/access/scripts.h



diff --git a/engines/access/player.h b/engines/access/player.h
index a9efff2..b904e46 100644
--- a/engines/access/player.h
+++ b/engines/access/player.h
@@ -49,11 +49,9 @@ private:
 	int _diagDownWalkMin, _diagDownWalkMax;
 	Common::Point _guard;
 	bool _collideFlag;
-	Direction _playerDirection;
 	Direction _move;
 	int _xFlag, _yFlag;
 	Common::Point _moveTo;
-	SpriteResource *_playerSprites;
 	SpriteResource *_playerSprites1;
 	byte *_manPal1;
 	int _scrollEnd;
@@ -79,6 +77,8 @@ private:
 	bool scrollLeft();
 	bool scrollRight();
 public:
+	Direction _playerDirection;
+	SpriteResource *_playerSprites;
 	// Fields in original Player structure
 	byte *_monData;
 	int _walkOffRight[PLAYER_DATA_COUNT];
diff --git a/engines/access/room.h b/engines/access/room.h
index f76db6f..a90c6e4 100644
--- a/engines/access/room.h
+++ b/engines/access/room.h
@@ -68,7 +68,6 @@ private:
 protected:
 	void loadRoomData(const byte *roomData);
 	void setupRoom();
-	void setWallCodes();
 	void buildScreen();
 
 	/**
@@ -110,6 +109,8 @@ protected:
 
 	virtual void mainAreaClick() = 0;
 public:
+	void setWallCodes();
+
 	virtual void setIconPalette() {}
 public:
 	Plotter _plotter;
diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp
index a209efc..0d232cc 100644
--- a/engines/access/scripts.cpp
+++ b/engines/access/scripts.cpp
@@ -96,7 +96,7 @@ void Scripts::executeCommand(int commandIndex) {
 		&Scripts::cmdPrint, &Scripts::cmdRetPos, &Scripts::cmdAnim,
 		&Scripts::cmdSetFlag, &Scripts::cmdCheckFlag, &Scripts::cmdGoto, 
 		&Scripts::cmdSetInventory, &Scripts::cmdSetInventory, &Scripts::cmdCheckInventory, 
-		&Scripts::CMDSETTEX, &Scripts::CMDNEWROOM, &Scripts::CMDCONVERSE, 
+		&Scripts::cmdSetTex, &Scripts::CMDNEWROOM, &Scripts::CMDCONVERSE, 
 		&Scripts::cmdCheckFrame, &Scripts::cmdCheckAnim, &Scripts::cmdSnd, 
 		&Scripts::cmdRetNeg, &Scripts::cmdRetPos, &Scripts::cmdCheckLoc, 
 		&Scripts::cmdSetAnim, &Scripts::cmdDispInv, &Scripts::CMDSETTIMER, 
@@ -105,7 +105,7 @@ void Scripts::executeCommand(int commandIndex) {
 		&Scripts::cmdPlotImage, &Scripts::cmdSetDisplay, &Scripts::cmdSetBuffer, 
 		&Scripts::cmdSetScroll, &Scripts::CMDSAVERECT, &Scripts::CMDSAVERECT, 
 		&Scripts::CMDSETBUFVID, &Scripts::CMDPLAYBUFVID, &Scripts::cmdRemoveLast, 
-		&Scripts::CMDSPECIAL, &Scripts::CMDSPECIAL, &Scripts::CMDSPECIAL,
+		&Scripts::cmdSpecial, &Scripts::cmdSpecial, &Scripts::cmdSpecial,
 		&Scripts::CMDSETCYCLE, &Scripts::CMDCYCLE, &Scripts::cmdCharSpeak, 
 		&Scripts::cmdTexSpeak, &Scripts::CMDTEXCHOICE, &Scripts::CMDWAIT, 
 		&Scripts::cmdSetConPos, &Scripts::CMDCHECKVFRAME, &Scripts::cmdJumpChoice, 
@@ -255,7 +255,35 @@ void Scripts::cmdCheckInventory() {
 		_data->skip(2);
 }
 
-void Scripts::CMDSETTEX() { error("TODO CMDSETTEX"); }
+void Scripts::cmdSetTex() {
+	_vm->_player->_playerDirection = RIGHT;
+	int posX = _data->readSint16LE() - (_vm->_player->_playerOffset.x / 2);
+	if (posX <= _vm->_player->_rawPlayer.x)
+		_vm->_player->_playerDirection = LEFT;
+
+	_vm->_player->_rawPlayer.x = posX;
+	_vm->_player->checkScroll();
+	bool scrlTemp = _vm->_player->_scrollFlag;
+
+	_vm->_player->_playerDirection = UP;
+	int posY = _data->readSint16LE();
+	if (posY <= _vm->_player->_rawPlayer.y)
+		_vm->_player->_playerDirection = DOWN;
+
+	_vm->_player->_rawPlayer.y = posY;
+	_vm->_player->_frame = 5;
+	_vm->_player->checkScroll();
+
+	_vm->_player->_scrollFlag |= scrlTemp;
+
+	_vm->_player->_position = Common::Point(_vm->_player->_rawPlayer.x, _vm->_player->_rawPlayer.y - _vm->_player->_playerOffset.y);
+	_vm->_player->_priority = _vm->_player->_playerOffset.y;
+	_vm->_player->_spritesPtr = _vm->_player->_playerSprites;
+	_vm->_player->_frameNumber = _vm->_player->_frame;
+
+	_vm->_room->setWallCodes();
+}
+
 void Scripts::CMDNEWROOM() { error("TODO CMDNEWROOM"); }
 void Scripts::CMDCONVERSE() { error("TODO CMDCONVERSE"); }
 
@@ -363,7 +391,7 @@ void Scripts::cmdRemoveLast() {
 	--_vm->_numAnimTimers;
 }
 
-void Scripts::CMDSPECIAL() { 
+void Scripts::cmdSpecial() { 
 	_specialFunction = _data->readUint16LE();
 	int p1 = _data->readUint16LE();
 	int p2 = _data->readUint16LE();
diff --git a/engines/access/scripts.h b/engines/access/scripts.h
index aae3146..70d79c4 100644
--- a/engines/access/scripts.h
+++ b/engines/access/scripts.h
@@ -65,7 +65,7 @@ protected:
 	
 	void cmdSetInventory();
 	void cmdCheckInventory();
-	void CMDSETTEX();
+	void cmdSetTex();
 	void CMDNEWROOM();
 	void CMDCONVERSE();
 	void cmdCheckFrame();
@@ -88,7 +88,7 @@ protected:
 	void CMDSETBUFVID();
 	void CMDPLAYBUFVID();
 	void cmdRemoveLast();
-	void CMDSPECIAL();
+	void cmdSpecial();
 	void CMDSETCYCLE();
 	void CMDCYCLE();
 	void cmdCharSpeak();


Commit: 9393f6d7559653a28166fe74da9745e95b76f85b
    https://github.com/scummvm/scummvm/commit/9393f6d7559653a28166fe74da9745e95b76f85b
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-17T18:56:05-04:00

Commit Message:
ACCESS: Implemented bubble box drawing code

Changed paths:
    engines/access/asurface.cpp
    engines/access/asurface.h
    engines/access/bubble_box.cpp
    engines/access/bubble_box.h
    engines/access/data.cpp
    engines/access/data.h



diff --git a/engines/access/asurface.cpp b/engines/access/asurface.cpp
index 08caa8a..9929227 100644
--- a/engines/access/asurface.cpp
+++ b/engines/access/asurface.cpp
@@ -115,6 +115,11 @@ int ASurface::_lastBoundsW;
 int ASurface::_lastBoundsH;
 int ASurface::_scrollX;
 int ASurface::_scrollY;
+int ASurface::_orgX1;
+int ASurface::_orgY1;
+int ASurface::_orgX2;
+int ASurface::_orgY2;
+int ASurface::_lColor;
 
 void ASurface::init() {
 	_leftSkip = _rightSkip = 0;
@@ -123,6 +128,9 @@ void ASurface::init() {
 	_lastBoundsX = _lastBoundsY = 0;
 	_lastBoundsW = _lastBoundsH = 0;
 	_scrollX = _scrollY = 0;
+	_orgX1 = _orgY1 = 0;
+	_orgX2 = _orgY2 = 0;
+	_lColor = 0;
 }
 
 ASurface::~ASurface() {
@@ -329,4 +337,8 @@ void ASurface::restoreBlock() {
 	}
 }
 
+void ASurface::drawRect() {
+	Graphics::Surface::fillRect(Common::Rect(_orgX1, _orgY1, _orgX2, _orgY2), _lColor);
+}
+
 } // End of namespace Access
diff --git a/engines/access/asurface.h b/engines/access/asurface.h
index 85550d9..400dd07 100644
--- a/engines/access/asurface.h
+++ b/engines/access/asurface.h
@@ -46,9 +46,14 @@ public:
 	static int _lastBoundsX, _lastBoundsY;
 	static int _lastBoundsW, _lastBoundsH;
 	static int _scrollX, _scrollY;
+	static int _orgX1, _orgY1;
+	static int _orgX2, _orgY2;
+	static int _lColor;
 
 	static void init();
 public:
+	virtual void plotFrame(SpriteFrame *frame, const Common::Point &pt);
+public:
 	virtual ~ASurface();
 
 	void clearBuffer();
@@ -75,7 +80,7 @@ public:
 
 	void restoreBlock();
 
-	virtual void plotFrame(SpriteFrame *frame, const Common::Point &pt);
+	void drawRect();
 };
 
 class SpriteFrame : public ASurface {
diff --git a/engines/access/bubble_box.cpp b/engines/access/bubble_box.cpp
index 5f0cb94..f910028 100644
--- a/engines/access/bubble_box.cpp
+++ b/engines/access/bubble_box.cpp
@@ -26,18 +26,15 @@
 
 namespace Access {
 
-Box::Box(AccessEngine *vm) : Manager(vm) {
-	_edgeSize = 0;
-}
-
-void Box::doBox(int item, int box) {
-	error("TODO: doBox");
-}
-
-/*------------------------------------------------------------------------*/
-
-BubbleBox::BubbleBox(AccessEngine *vm) : Box(vm) {
+BubbleBox::BubbleBox(AccessEngine *vm) : Manager(vm) {
+	_type = TYPE_2;
+	_bounds = Common::Rect(64, 32, 64 + 130, 32 + 122);
 	_bubblePtr = nullptr;
+	_fieldD = 0;
+	_fieldE = 0;
+	_fieldF = 0;
+	_field10 = 0;
+
 	_maxChars = 0;
 }
 
@@ -69,7 +66,7 @@ void BubbleBox::placeBubble1(const Common::String &msg) {
 
 	calcBubble(msg);
 
-	Common::Rect r = BubbleBox::_bubbles[0];
+	Common::Rect r = _bubbles[0];
 	r.translate(-2, 0);
 	_vm->_screen->saveBlock(r);
 	printBubble(msg);
@@ -81,7 +78,7 @@ void BubbleBox::calcBubble(const Common::String &msg) {
 	Common::Point printStart = _vm->_fonts._printStart;
 
 	// Figure out maximum width allowed
-	if (_edgeSize == 4) {
+	if (_type == TYPE_4) {
 		_vm->_fonts._printMaxX = 110;
 	} else {
 		_vm->_fonts._printMaxX = _vm->_fonts._font2.stringWidth(_bubblePtr);
@@ -96,14 +93,14 @@ void BubbleBox::calcBubble(const Common::String &msg) {
 	int width = 0;
 	bool lastLine;
 	do {
-		lastLine = _vm->_fonts._font2.getLine(s, _vm->_fonts._printMaxX, line, width);
-		width = MIN(width, _vm->_fonts._printMaxX);
+		lastLine = _vm->_fonts._font2.getLine(s, _maxChars * 6, line, width);
+		width = MAX(width, _vm->_fonts._printMaxX);
 
 		_vm->_fonts._printOrg.y += 6;
 		_vm->_fonts._printOrg.x = _vm->_fonts._printStart.x;
 	} while (!lastLine);
 
-	if (_edgeSize == 4)
+	if (_type == TYPE_4)
 		++_vm->_fonts._printOrg.y += 6;
 
 	// Determine the width for the area
@@ -114,17 +111,17 @@ void BubbleBox::calcBubble(const Common::String &msg) {
 
 	// Determine the height for area
 	int y = _vm->_fonts._printOrg.y + 6;
-	if (_edgeSize == 4)
+	if (_type == TYPE_4)
 		y += 6;
 	int height = y - bounds.top;
 	bounds.setHeight(height);
 
-	height -= (_edgeSize == 4) ? 30 : 24;
+	height -= (_type == TYPE_4) ? 30 : 24;
 	if (height >= 0)
 		bounds.setHeight(bounds.height() + 13 - (height % 13));
 
 	// Add the new bounds to the bubbles list
-	BubbleBox::_bubbles.push_back(bounds);
+	_bubbles.push_back(bounds);
 
 	// Restore points
 	_vm->_fonts._printOrg = printOrg;
@@ -132,13 +129,139 @@ void BubbleBox::calcBubble(const Common::String &msg) {
 }
 
 void BubbleBox::printBubble(const Common::String &msg) {
-	drawBubble(BubbleBox::_bubbles.size() - 1);
-	error("TODO: printBubble");
+	drawBubble(_bubbles.size() - 1);
+
+	// Loop through drawing the lines
+	Common::String s = msg;
+	Common::String line;
+	int width = 0;
+	bool lastLine;
+	do {
+		// Get next line
+		Font &font2 = _vm->_fonts._font2;
+		lastLine = font2.getLine(s, _maxChars * 6, line, width);
+
+		// Set font colors
+		font2._fontColors[0] = 0;
+		font2._fontColors[1] = 0;
+		font2._fontColors[2] = 0;
+		font2._fontColors[3] = 0;
+
+		int xp = _vm->_fonts._printOrg.x;
+		if (_type == TYPE_4)
+			xp = (_bounds.width() - width) / 2 + _bounds.left - 4;
+
+		// Draw the text
+		font2.drawString(_vm->_screen, line, Common::Point(xp, _vm->_fonts._printOrg.y));
+
+		// Move print position
+		_vm->_fonts._printOrg.y += 6;
+		_vm->_fonts._printOrg.x = _vm->_fonts._printStart.x;
+	} while (!lastLine);
 }
 
 void BubbleBox::drawBubble(int index) {
-	_bounds = BubbleBox::_bubbles[index];
+	_bounds = _bubbles[index];
 	doBox(0, 0);
 }
 
+void BubbleBox::doBox(int item, int box) {
+	FontManager &fonts = _vm->_fonts;
+	ASurface &screen = *_vm->_screen;
+
+	_startItem = item;
+	_startBox = box;
+
+	// Save state information
+	FontVal charSet = fonts._charSet;
+	FontVal charFor = fonts._charFor;
+	Common::Point printOrg = fonts._printOrg;
+	Common::Point printStart = fonts._printStart;
+	int charCol = _charCol;
+	int rowOff = _rowOff;
+
+	_vm->_screen->saveScreen();
+	_vm->_screen->setDisplayScan();
+	fonts._charFor._hi = 0xff;
+	fonts._charSet._lo = 1;
+	fonts._charSet._hi = 0;
+
+	if (_type == TYPE_4) {
+		fonts._charFor._lo = 0xFF;
+		error("TODO: filename listing");
+		return;
+	}
+
+	// Get icons data
+	byte *iconData = _vm->_files->loadFile("ICONS.LZ");
+	SpriteResource *icons = new SpriteResource(_vm, iconData, _vm->_files->_filesize);
+	delete[] iconData;
+
+	// Set the up boundaries and color to use for the box background
+	_vm->_screen->_orgX1 = _bounds.left;
+	_vm->_screen->_orgY1 = _bounds.top;
+	_vm->_screen->_orgX2 = _bounds.right;
+	_vm->_screen->_orgY2 = _bounds.bottom;
+	_vm->_screen->_lColor = 1;
+
+	int h = _bounds.height() - (_type == TYPE_4) ? 30 : 24;
+	int ySize = (h < 0) ? 0 : (h + 12) / 13;
+	int w = _bounds.width() - 24;
+	int xSize = (w < 0) ? 0 : (w + 19) / 20;
+
+	// Draw a background for the entire area
+	screen.drawRect();
+
+	// Draw images to form the top border
+	int xp, yp;
+	screen.plotImage(icons, 20, Common::Point(screen._orgX1, screen._orgY1));
+	xp = screen._orgX1 + 12;
+	for (int x = 0; x < xSize; ++x, xp += 20)
+		screen.plotImage(icons, 24 + x, Common::Point(xp, screen._orgY1));
+	screen.plotImage(icons, 21, Common::Point(xp, screen._orgY1));
+
+	// Draw images to form the bottom border
+	yp = screen._orgY2 - (_type == TYPE_4) ? 18 : 12;
+	screen.plotImage(icons, (_type == TYPE_4) ? 72 : 22,
+		Common::Point(screen._orgX1, yp));
+	xp = screen._orgX1 + 12;
+	yp += (_type == TYPE_4) ? 4 : 8;
+
+	for (int x = 0; x < xSize; ++x, xp += 20) {
+		screen.plotImage(icons, (_type == TYPE_4 ? 62 : 34) + x, 
+			Common::Point(xp, yp));
+	}
+	
+	yp -= (_type == TYPE_4) ? 18 : 12;
+	screen.plotImage(icons, (_type == TYPE_4) ? 73 : 23,
+		Common::Point(screen._orgX1, yp));
+
+	if (_type == TYPE_4) {
+		// Further stuff
+		warning("YSIZE not yet used %d", ySize);
+		error("TODO: Box type 4");
+	}
+
+	// Handle drawing title
+	int titleWidth = _vm->_fonts._font2.stringWidth(_bubblePtr);
+	Font &font2 = _vm->_fonts._font2;
+	font2._fontColors[0] = 0;
+	font2._fontColors[1] = 3;
+	font2._fontColors[2] = 2;
+	font2._fontColors[3] = 1;
+	font2.drawString(_vm->_screen, _bubblePtr, Common::Point(
+		_bounds.left + (_bounds.width() / 2) - (titleWidth / 2), _bounds.top + 1));
+
+	// Restore positional state
+	fonts._charSet = charSet;
+	fonts._charFor = charFor;
+	fonts._printOrg = printOrg;
+	fonts._printStart = printStart;
+	_charCol = charCol;
+	_rowOff = rowOff;
+	
+	// Free icons data
+	delete icons;
+}
+
 } // End of namespace Access
diff --git a/engines/access/bubble_box.h b/engines/access/bubble_box.h
index 189e0b1..3ddb2f7 100644
--- a/engines/access/bubble_box.h
+++ b/engines/access/bubble_box.h
@@ -26,6 +26,7 @@
 #include "common/scummsys.h"
 #include "common/array.h"
 #include "common/rect.h"
+#include "common/str-array.h"
 #include "common/stream.h"
 #include "common/types.h"
 #include "graphics/surface.h"
@@ -35,20 +36,24 @@ namespace Access {
 
 class AccessEngine;
 
-class Box: public Manager {
-public:
-	int _edgeSize;
-	Common::Rect _bounds;
-public:
-	Box(AccessEngine *vm);
-
-	void doBox(int item, int box);
-};
+enum BoxType { TYPE_2 = 2, TYPE_4 = 4 };
 
-class BubbleBox: public Box {
+class BubbleBox: public Manager {
+private:
+	int _startItem, _startBox;
+	int _charCol, _rowOff;
+	Common::Point _fileStart;
 public:
+	BoxType _type;
+	Common::Rect _bounds;
+	Common::StringArray _nameIndex;
 	Common::String _bubbleTitle;
 	const char *_bubblePtr;
+	int _fieldD;
+	int _fieldE;
+	int _fieldF;
+	int _field10;
+
 	int _maxChars;
 	Common::Array<Common::Rect> _bubbles;
 public:
@@ -77,7 +82,7 @@ public:
 	 */
 	void drawBubble(int index);
 
-
+	void doBox(int item, int box);
 };
 
 } // End of namespace Access
diff --git a/engines/access/data.cpp b/engines/access/data.cpp
index 65702db..1fba854 100644
--- a/engines/access/data.cpp
+++ b/engines/access/data.cpp
@@ -46,21 +46,57 @@ void TimerList::restoreTimers() {
 
 /*------------------------------------------------------------------------*/
 
+byte Font::_fontColors[4];
+
 Font::Font() {
 }
 
+Font::~Font() {
+	for (uint i = 0; i < _chars.size(); ++i)
+		_chars[i].free();
+}
+
 void Font::load(const int *index, const byte *data) {
+	assert(_chars.size() == 0);
 	int count = index[0];
-	_v1 = index[1];
-	_v2 = index[2];
-
-	_chars.clear();
-	for (int idx = 0; idx < count; ++idx)
-		_chars.push_back(data + index[idx + 3]);
+	_bitWidth = index[1];
+	_height = index[2];
+
+	_chars.resize(count);
+
+	for (int i = 0; i < count; ++i) {
+		const byte *pData = data + index[i + 3];
+		_chars[i].create(*pData++, _height, Graphics::PixelFormat::createFormatCLUT8());
+
+		for (int y = 0; y < _height; ++y) {
+			int bitsLeft = 0;
+			byte srcByte = 0;
+			byte pixel;
+			
+			byte *pDest = (byte *)_chars[i].getBasePtr(0, y);
+			for (int x = 0; x < _chars[i].w; ++x, ++pDest) {
+				// Get the pixel
+				pixel = 0;
+				for (int pixelCtr = 0; pixelCtr < _bitWidth; ++pixelCtr) {
+					// No bits in current byte left, so get next byte
+					if (bitsLeft == 0) {
+						bitsLeft = 8;
+						srcByte = *pData++;
+					}
+
+					pixel = (pixel << 1) | (srcByte >> 7);
+					srcByte <<= 1;
+				}
+
+				// Write out the pixel
+				*pDest = pixel;
+			}
+		}
+	}
 }
 
 int Font::charWidth(char c) {
-	return *_chars[c - ' '];
+	return _chars[c - ' '].w;
 }
 
 int Font::stringWidth(const Common::String &msg) {
@@ -69,10 +105,11 @@ int Font::stringWidth(const Common::String &msg) {
 	for (const char *c = msg.c_str(); *c != '\0'; ++c)
 		total += charWidth(*c);
 
-	return 0;
+	return total;
 }
 
 bool Font::getLine(Common::String &s, int maxWidth, Common::String &line, int &width) {
+	assert(maxWidth > 0);
 	width = 0;
 	const char *src = s.c_str();
 	char c;
@@ -92,7 +129,8 @@ bool Font::getLine(Common::String &s, int maxWidth, Common::String &line, int &w
 
 		// Reached maximum allowed. Work backwards to find space at the
 		// start of the current word as a point to split the line on
-		while (*src != ' ' && src >= s.c_str()) {
+		--src;
+		while (src >= s.c_str() && *src != ' ') {
 			width -= charWidth(*src);
 			--src;
 		}
@@ -111,10 +149,39 @@ bool Font::getLine(Common::String &s, int maxWidth, Common::String &line, int &w
 	return true;
 }
 
+void Font::drawString(Graphics::Surface *s, const Common::String &msg, const Common::Point &pt) {
+	Common::Point currPt = pt;
+	const char *msgP = msg.c_str();
+
+	while (*msgP) {
+		currPt.x += drawChar(s, *msgP, currPt);
+		++msgP;
+	}
+}
+
+int Font::drawChar(Graphics::Surface *s, char c, Common::Point &pt) {
+	Graphics::Surface &ch = _chars[c - ' '];
+
+	// Loop through the lines of the character
+	for (int y = 0; y < ch.h; ++y) {
+		byte *pSrc = (byte *)ch.getBasePtr(0, y);
+		byte *pDest = (byte *)s->getBasePtr(pt.x, pt.y + y);
+
+		// Loop through the horizontal pixels of the line
+		for (int x = 0; x < ch.w; ++x, ++pSrc, ++pDest) {
+			if (*pSrc != 0)
+				*pDest = _fontColors[*pSrc];
+		}
+	}
+
+	return ch.w;
+}
+
 /*------------------------------------------------------------------------*/
 
 FontManager::FontManager() {
 	_printMaxX = 0;
+	Common::fill(&Font::_fontColors[0], &Font::_fontColors[4], 0);
 }
 
 } // End of namespace Access
diff --git a/engines/access/data.h b/engines/access/data.h
index 910e252..fd3c889 100644
--- a/engines/access/data.h
+++ b/engines/access/data.h
@@ -87,12 +87,16 @@ public:
 
 class Font {
 private:
-	int _v1;
-	int _v2;
-	Common::Array<const byte *> _chars;
+	int _bitWidth;
+	int _height;
+	Common::Array<Graphics::Surface> _chars;
+public:
+	static byte _fontColors[4];
 public:
 	Font();
 
+	~Font();
+
 	/**
 	 * Load the given font data
 	 */
@@ -118,6 +122,15 @@ public:
 	 */
 	bool getLine(Common::String &s, int maxWidth, Common::String &line, int &width);
 
+	/**
+	 * Draw a string on a given surface
+	 */
+	void drawString(Graphics::Surface *s, const Common::String &msg, const Common::Point &pt);
+
+	/**
+	 * Draw a character on a given surface
+	 */
+	int drawChar(Graphics::Surface *s, char c, Common::Point &pt);
 };
 
 class FontManager {


Commit: 483bca3d96b7012774d13875e78cfd8b649657f7
    https://github.com/scummvm/scummvm/commit/483bca3d96b7012774d13875e78cfd8b649657f7
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-17T20:17:38-04:00

Commit Message:
ACCESS: Fixes for drawing bubble box backgrounds

Changed paths:
    engines/access/bubble_box.cpp
    engines/access/events.cpp
    engines/access/events.h
    engines/access/scripts.cpp



diff --git a/engines/access/bubble_box.cpp b/engines/access/bubble_box.cpp
index f910028..b896e5e 100644
--- a/engines/access/bubble_box.cpp
+++ b/engines/access/bubble_box.cpp
@@ -94,7 +94,7 @@ void BubbleBox::calcBubble(const Common::String &msg) {
 	bool lastLine;
 	do {
 		lastLine = _vm->_fonts._font2.getLine(s, _maxChars * 6, line, width);
-		width = MAX(width, _vm->_fonts._printMaxX);
+		_vm->_fonts._printMaxX = MAX(width, _vm->_fonts._printMaxX);
 
 		_vm->_fonts._printOrg.y += 6;
 		_vm->_fonts._printOrg.x = _vm->_fonts._printStart.x;
@@ -150,10 +150,10 @@ void BubbleBox::printBubble(const Common::String &msg) {
 		int xp = _vm->_fonts._printOrg.x;
 		if (_type == TYPE_4)
 			xp = (_bounds.width() - width) / 2 + _bounds.left - 4;
-
+		
 		// Draw the text
 		font2.drawString(_vm->_screen, line, Common::Point(xp, _vm->_fonts._printOrg.y));
-
+		
 		// Move print position
 		_vm->_fonts._printOrg.y += 6;
 		_vm->_fonts._printOrg.x = _vm->_fonts._printStart.x;
@@ -221,7 +221,7 @@ void BubbleBox::doBox(int item, int box) {
 	screen.plotImage(icons, 21, Common::Point(xp, screen._orgY1));
 
 	// Draw images to form the bottom border
-	yp = screen._orgY2 - (_type == TYPE_4) ? 18 : 12;
+	yp = screen._orgY2 - (_type == TYPE_4 ? 18 : 12);
 	screen.plotImage(icons, (_type == TYPE_4) ? 72 : 22,
 		Common::Point(screen._orgX1, yp));
 	xp = screen._orgX1 + 12;
@@ -232,16 +232,21 @@ void BubbleBox::doBox(int item, int box) {
 			Common::Point(xp, yp));
 	}
 	
-	yp -= (_type == TYPE_4) ? 18 : 12;
-	screen.plotImage(icons, (_type == TYPE_4) ? 73 : 23,
-		Common::Point(screen._orgX1, yp));
+	yp = screen._orgY2 - (_type == TYPE_4 ? 18 : 12);
+	screen.plotImage(icons, (_type == TYPE_4) ? 73 : 23, Common::Point(xp, yp));
 
 	if (_type == TYPE_4) {
 		// Further stuff
-		warning("YSIZE not yet used %d", ySize);
 		error("TODO: Box type 4");
 	}
 
+	// Draw images to form the sides
+	yp = screen._orgY1 + 12;
+	for (int y = 0; y < ySize; ++y) {
+		screen.plotImage(icons, 44 + y, Common::Point(screen._orgX1, yp));
+		screen.plotImage(icons, 53 + y, Common::Point(screen._orgX2 - 4, yp));
+	}
+
 	// Handle drawing title
 	int titleWidth = _vm->_fonts._font2.stringWidth(_bubblePtr);
 	Font &font2 = _vm->_fonts._font2;
diff --git a/engines/access/events.cpp b/engines/access/events.cpp
index 521e889..71ed5f4 100644
--- a/engines/access/events.cpp
+++ b/engines/access/events.cpp
@@ -112,9 +112,10 @@ bool EventsManager::isCursorVisible() {
 	return CursorMan.isVisible();
 }
 
-void EventsManager::pollEvents(bool suppressFrames) {
-	if (!suppressFrames)
-		checkForNextFrameCounter();
+void EventsManager::pollEvents() {
+	if (checkForNextFrameCounter()) {
+		nextFrame();
+	}
 
 	Common::Event event;
 	while (g_system->getEventManager()->pollEvent(event)) {
@@ -158,24 +159,26 @@ void EventsManager::pollEvents(bool suppressFrames) {
 	}
 }
 
-void EventsManager::checkForNextFrameCounter() {
+bool EventsManager::checkForNextFrameCounter() {
 	// Check for next game frame
 	uint32 milli = g_system->getMillis();
 	if ((milli - _priorFrameTime) >= GAME_FRAME_TIME) {
 		++_frameCounter;
 		_priorFrameTime = milli;
 
-		nextFrame();
+		return true;
 	}
+
+	return false;
 }
 
 void EventsManager::nextFrame() {
-	// Give time to the debugger
-	_vm->_debugger->onFrame();
-
 	// Update timers
 	_vm->_animation->updateTimers();
 
+	// Give time to the debugger
+	_vm->_debugger->onFrame();
+
 	// TODO: Refactor for dirty rects
 	_vm->_screen->updateScreen();
 }
@@ -199,13 +202,19 @@ bool EventsManager::getKey(Common::KeyState &key) {
 
 void EventsManager::debounceLeft() {
 	while (_leftButton && !_vm->shouldQuit()) {
-		pollEvents(true);
+		pollEvents();
 		g_system->delayMillis(10);
 	}
 }
 
 void EventsManager::waitKeyMouse() {
-	error("TODO: waitKeyPress");
+	while (!_vm->shouldQuit() && !_leftButton && _keypresses.size() == 0) {
+		pollEvents();
+		g_system->delayMillis(10);
+	}
+
+	zeroKeys();
+	debounceLeft();
 }
 
 } // End of namespace Access
diff --git a/engines/access/events.h b/engines/access/events.h
index dc89829..c6702ec 100644
--- a/engines/access/events.h
+++ b/engines/access/events.h
@@ -46,7 +46,7 @@ private:
 	uint32 _frameCounter;
 	uint32 _priorFrameTime;
 
-	void checkForNextFrameCounter();
+	bool checkForNextFrameCounter();
 
 	void nextFrame();
 public:
@@ -95,7 +95,7 @@ public:
 	 */
 	bool isCursorVisible();
 
-	void pollEvents(bool suppressFrames = false);
+	void pollEvents();
 
 	void zeroKeys();
 
diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp
index 0d232cc..2e4e2ad 100644
--- a/engines/access/scripts.cpp
+++ b/engines/access/scripts.cpp
@@ -193,7 +193,7 @@ void Scripts::cmdPrint() {
 	_vm->_events->waitKeyMouse();
 
 	// Wait until the bubble display is expired
-	while (_vm->_timers[PRINT_TIMER]._flag) {
+	while (!_vm->shouldQuit() && _vm->_timers[PRINT_TIMER]._flag) {
 		_vm->_events->pollEvents();
 	}
 


Commit: be4639802c469c8b85e1f801a7cac1897a18863b
    https://github.com/scummvm/scummvm/commit/be4639802c469c8b85e1f801a7cac1897a18863b
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-17T20:32:25-04:00

Commit Message:
ACCESS: Fix positioning of bubble boxes

Changed paths:
    engines/access/bubble_box.cpp



diff --git a/engines/access/bubble_box.cpp b/engines/access/bubble_box.cpp
index b896e5e..4bd4b74 100644
--- a/engines/access/bubble_box.cpp
+++ b/engines/access/bubble_box.cpp
@@ -85,7 +85,7 @@ void BubbleBox::calcBubble(const Common::String &msg) {
 	}
 
 	// Start of with a rect with the given starting x and y
-	Common::Rect bounds(printOrg.x - 2, printOrg.y, printOrg.x - 2, printOrg.y);
+	Common::Rect bounds(printOrg.x - 2, printOrg.y - 10, printOrg.x - 2, printOrg.y - 10);
 
 	// Loop through getting lines
 	Common::String s = msg;


Commit: c576b201f6638fa3702593cdb45cff64057d35ef
    https://github.com/scummvm/scummvm/commit/c576b201f6638fa3702593cdb45cff64057d35ef
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-17T21:08:58-04:00

Commit Message:
ACCESS: Fix decoding of font data

Changed paths:
    engines/access/amazon/amazon_game.cpp
    engines/access/data.cpp
    engines/access/data.h



diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp
index 072675c..663d699 100644
--- a/engines/access/amazon/amazon_game.cpp
+++ b/engines/access/amazon/amazon_game.cpp
@@ -173,8 +173,8 @@ void AmazonEngine::setupGame() {
 	}
 
 	// Miscellaenous
-	_fonts._font6x6.load(FONT6x6_INDEX, FONT6x6_DATA);
 	_fonts._font2.load(FONT2_INDEX, FONT2_DATA);
+	_fonts._font6x6.load(FONT6x6_INDEX, FONT6x6_DATA);
 
 	// Set player room and position
 	_player->_roomNumber = 4;
diff --git a/engines/access/data.cpp b/engines/access/data.cpp
index 1fba854..36797b6 100644
--- a/engines/access/data.cpp
+++ b/engines/access/data.cpp
@@ -56,16 +56,16 @@ Font::~Font() {
 		_chars[i].free();
 }
 
-void Font::load(const int *index, const byte *data) {
+void Font::load(const int *fontIndex, const byte *fontData) {
 	assert(_chars.size() == 0);
-	int count = index[0];
-	_bitWidth = index[1];
-	_height = index[2];
+	int count = fontIndex[0];
+	_bitWidth = fontIndex[1];
+	_height = fontIndex[2];
 
 	_chars.resize(count);
 
 	for (int i = 0; i < count; ++i) {
-		const byte *pData = data + index[i + 3];
+		const byte *pData = fontData + fontIndex[i + 3];
 		_chars[i].create(*pData++, _height, Graphics::PixelFormat::createFormatCLUT8());
 
 		for (int y = 0; y < _height; ++y) {
@@ -77,7 +77,7 @@ void Font::load(const int *index, const byte *data) {
 			for (int x = 0; x < _chars[i].w; ++x, ++pDest) {
 				// Get the pixel
 				pixel = 0;
-				for (int pixelCtr = 0; pixelCtr < _bitWidth; ++pixelCtr) {
+				for (int pixelCtr = 0; pixelCtr < _bitWidth; ++pixelCtr, --bitsLeft) {
 					// No bits in current byte left, so get next byte
 					if (bitsLeft == 0) {
 						bitsLeft = 8;
diff --git a/engines/access/data.h b/engines/access/data.h
index fd3c889..7ddc5d6 100644
--- a/engines/access/data.h
+++ b/engines/access/data.h
@@ -100,7 +100,7 @@ public:
 	/**
 	 * Load the given font data
 	 */
-	void load(const int *index, const byte *data);
+	void load(const int *fontIndex, const byte *fontData);
 
 	/**
 	 * Get the width of a given character


Commit: a8a7018926f68d4792f3114ea8496ae721c2490c
    https://github.com/scummvm/scummvm/commit/a8a7018926f68d4792f3114ea8496ae721c2490c
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-17T21:53:46-04:00

Commit Message:
ACCESS: Fix showing bubble box text correctly

Changed paths:
    engines/access/bubble_box.cpp
    engines/access/data.cpp



diff --git a/engines/access/bubble_box.cpp b/engines/access/bubble_box.cpp
index 4bd4b74..5a17b3b 100644
--- a/engines/access/bubble_box.cpp
+++ b/engines/access/bubble_box.cpp
@@ -143,9 +143,9 @@ void BubbleBox::printBubble(const Common::String &msg) {
 
 		// Set font colors
 		font2._fontColors[0] = 0;
-		font2._fontColors[1] = 0;
-		font2._fontColors[2] = 0;
-		font2._fontColors[3] = 0;
+		font2._fontColors[1] = 27;
+		font2._fontColors[2] = 28;
+		font2._fontColors[3] = 29;
 
 		int xp = _vm->_fonts._printOrg.x;
 		if (_type == TYPE_4)
diff --git a/engines/access/data.cpp b/engines/access/data.cpp
index 36797b6..90f712a 100644
--- a/engines/access/data.cpp
+++ b/engines/access/data.cpp
@@ -22,6 +22,8 @@
 
 #include "common/algorithm.h"
 #include "access/data.h"
+#include "graphics/palette.h"
+#include "common/system.h"
 
 namespace Access {
 
@@ -127,9 +129,13 @@ bool Font::getLine(Common::String &s, int maxWidth, Common::String &line, int &w
 		if (width < maxWidth)
 			continue;
 
-		// Reached maximum allowed. Work backwards to find space at the
-		// start of the current word as a point to split the line on
-		--src;
+		// Reached maximum allowed size
+		// If this was the last character of the string, let it go
+		if (*src == '\0')
+			break;
+		
+		// Work backwards to find space at the start of the current word 
+		// as a point to split the line on
 		while (src >= s.c_str() && *src != ' ') {
 			width -= charWidth(*src);
 			--src;
@@ -138,7 +144,7 @@ bool Font::getLine(Common::String &s, int maxWidth, Common::String &line, int &w
 			error("Could not fit line");
 
 		// Split the line around the space
-		line = Common::String(s.c_str(), src - 1);
+		line = Common::String(s.c_str(), src);
 		s = Common::String(src + 1);
 		return false;
 	}


Commit: 38acce33fd95171a5d3a7a00cad57bb4a5711bad
    https://github.com/scummvm/scummvm/commit/38acce33fd95171a5d3a7a00cad57bb4a5711bad
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-17T22:09:03-04:00

Commit Message:
ACCESS: Add updateTimers so bubble boxes can be removed

Changed paths:
    engines/access/bubble_box.cpp
    engines/access/data.cpp
    engines/access/data.h
    engines/access/events.cpp



diff --git a/engines/access/bubble_box.cpp b/engines/access/bubble_box.cpp
index 5a17b3b..6ea7ed8 100644
--- a/engines/access/bubble_box.cpp
+++ b/engines/access/bubble_box.cpp
@@ -198,9 +198,9 @@ void BubbleBox::doBox(int item, int box) {
 	delete[] iconData;
 
 	// Set the up boundaries and color to use for the box background
-	_vm->_screen->_orgX1 = _bounds.left;
+	_vm->_screen->_orgX1 = _bounds.left - 2;
 	_vm->_screen->_orgY1 = _bounds.top;
-	_vm->_screen->_orgX2 = _bounds.right;
+	_vm->_screen->_orgX2 = _bounds.right - 2;
 	_vm->_screen->_orgY2 = _bounds.bottom;
 	_vm->_screen->_lColor = 1;
 
diff --git a/engines/access/data.cpp b/engines/access/data.cpp
index 90f712a..124bfbc 100644
--- a/engines/access/data.cpp
+++ b/engines/access/data.cpp
@@ -46,6 +46,18 @@ void TimerList::restoreTimers() {
 	}
 }
 
+void TimerList::updateTimers() {
+	for (uint i = 0; i < size(); ++i) {
+		TimerEntry &te = (*this)[i];
+		if (te._flag) {
+			if (!--te._timer) {
+				te._timer = te._initTm;
+				te._flag = false;
+			}
+		}
+	}
+}
+
 /*------------------------------------------------------------------------*/
 
 byte Font::_fontColors[4];
diff --git a/engines/access/data.h b/engines/access/data.h
index 7ddc5d6..8ba3c58 100644
--- a/engines/access/data.h
+++ b/engines/access/data.h
@@ -68,6 +68,11 @@ public:
 	 * Resetore the set of previously saved timers
 	 */
 	void restoreTimers();
+
+	/**
+	 * Update the timer list
+	 */
+	void updateTimers();
 };
 
 class ExtraCell {
diff --git a/engines/access/events.cpp b/engines/access/events.cpp
index 71ed5f4..25a77f8 100644
--- a/engines/access/events.cpp
+++ b/engines/access/events.cpp
@@ -175,6 +175,7 @@ bool EventsManager::checkForNextFrameCounter() {
 void EventsManager::nextFrame() {
 	// Update timers
 	_vm->_animation->updateTimers();
+	_vm->_timers.updateTimers();
 
 	// Give time to the debugger
 	_vm->_debugger->onFrame();


Commit: 9e98a1edcc7610e9ccdb00026a7d9eb349b0c2ee
    https://github.com/scummvm/scummvm/commit/9e98a1edcc7610e9ccdb00026a7d9eb349b0c2ee
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-17T22:13:45-04:00

Commit Message:
ACCESS: Correct drawing the vertical edges of bubble boxes

Changed paths:
    engines/access/bubble_box.cpp



diff --git a/engines/access/bubble_box.cpp b/engines/access/bubble_box.cpp
index 6ea7ed8..21e1040 100644
--- a/engines/access/bubble_box.cpp
+++ b/engines/access/bubble_box.cpp
@@ -204,7 +204,7 @@ void BubbleBox::doBox(int item, int box) {
 	_vm->_screen->_orgY2 = _bounds.bottom;
 	_vm->_screen->_lColor = 1;
 
-	int h = _bounds.height() - (_type == TYPE_4) ? 30 : 24;
+	int h = _bounds.height() - (_type == TYPE_4 ? 30 : 24);
 	int ySize = (h < 0) ? 0 : (h + 12) / 13;
 	int w = _bounds.width() - 24;
 	int xSize = (w < 0) ? 0 : (w + 19) / 20;
@@ -242,7 +242,7 @@ void BubbleBox::doBox(int item, int box) {
 
 	// Draw images to form the sides
 	yp = screen._orgY1 + 12;
-	for (int y = 0; y < ySize; ++y) {
+	for (int y = 0; y < ySize; ++y, yp += 13) {
 		screen.plotImage(icons, 44 + y, Common::Point(screen._orgX1, yp));
 		screen.plotImage(icons, 53 + y, Common::Point(screen._orgX2 - 4, yp));
 	}


Commit: 7fef53b68ccddcb8ed93c567456c73fe503ee006
    https://github.com/scummvm/scummvm/commit/7fef53b68ccddcb8ed93c567456c73fe503ee006
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-17T22:32:26-04:00

Commit Message:
ACCESS: Implemented cmdEndObject

Changed paths:
    engines/access/resources.cpp
    engines/access/resources.h
    engines/access/scripts.cpp
    engines/access/scripts.h



diff --git a/engines/access/resources.cpp b/engines/access/resources.cpp
index 40daf2b..f0d74cc 100644
--- a/engines/access/resources.cpp
+++ b/engines/access/resources.cpp
@@ -76,4 +76,17 @@ const int RMOUSE[10][2] = {
 	{ 142, 177 }, { 178, 212 }, { 213, 248 }, { 249, 283 }, { 284, 318 }
 };
 
+const char *LOOK_MESSAGE = "LOOKING THERE REVEALS NOTHING OF INTEREST.";
+const char *GET_MESSAGE = "YOU CAN'T TAKE THAT.";
+const char *OPEN_MESSAGE = "THAT DOESN'T OPEN.";
+const char *MOVE_MESSAGE = "THAT WON'T MOVE.";
+const char *USE_MESSAGE = "THAT DOESN'T SEEM TO WORK.";
+const char *GO_MESSAGE = "YOU CAN'T CLIMB THAT.";
+const char *HELP_MESSAGE = "THIS OBJECT REQUIRES NO HINTS";
+const char *TALK_MESSAGE      = "THERE SEEMS TO BE NO RESPONSE.";
+const char *const GENERAL_MESSAGES[] = {
+	LOOK_MESSAGE, OPEN_MESSAGE, MOVE_MESSAGE, GET_MESSAGE, USE_MESSAGE, 
+	GO_MESSAGE, TALK_MESSAGE, HELP_MESSAGE, HELP_MESSAGE, USE_MESSAGE
+};
+
 } // End of namespace Access
diff --git a/engines/access/resources.h b/engines/access/resources.h
index 678cbc0..241ed3a 100644
--- a/engines/access/resources.h
+++ b/engines/access/resources.h
@@ -56,6 +56,8 @@ extern const int OVEROFFDLY[];
 
 extern const int RMOUSE[10][2];
 
+extern const char *const GENERAL_MESSAGES[];
+
 } // End of namespace Access
 
 #endif /* ACCESS_RESOURCES_H */
diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp
index 2e4e2ad..fba947a 100644
--- a/engines/access/scripts.cpp
+++ b/engines/access/scripts.cpp
@@ -22,6 +22,7 @@
 
 #include "common/scummsys.h"
 #include "access/access.h"
+#include "access/resources.h"
 #include "access/scripts.h"
 
 #define SCRIPT_START_BYTE 0xE0
@@ -90,7 +91,7 @@ int Scripts::executeScript() {
 
 void Scripts::executeCommand(int commandIndex) {
 	static const ScriptMethodPtr COMMAND_LIST[] = {
-		&Scripts::CMDOBJECT, &Scripts::CMDENDOBJECT, &Scripts::cmdJumpLook, 
+		&Scripts::CMDOBJECT, &Scripts::cmdEndObject, &Scripts::cmdJumpLook, 
 		&Scripts::cmdJumpHelp, &Scripts::cmdJumpGet, &Scripts::cmdJumpMove,
 		&Scripts::cmdJumpUse, &Scripts::cmdJumpTalk, &Scripts::cmdNull, 
 		&Scripts::cmdPrint, &Scripts::cmdRetPos, &Scripts::cmdAnim,
@@ -126,7 +127,9 @@ void Scripts::CMDOBJECT() {
 	_vm->_bubbleBox->load(_data);
 }
 
-void Scripts::CMDENDOBJECT() { error("TODO ENDOBJECT"); }
+void Scripts::cmdEndObject() { 
+	printString(GENERAL_MESSAGES[_vm->_room->_selectCommand]);
+}
 
 void Scripts::cmdJumpLook() {
 	if (_vm->_room->_selectCommand == 0)
@@ -175,18 +178,22 @@ void Scripts::cmdNull() {
 
 #define PRINT_TIMER 25
 
-void Scripts::cmdPrint() { 
-	_vm->_fonts._printOrg = Common::Point(20, 42);
-	_vm->_fonts._printStart = Common::Point(20, 42);
-	_vm->_timers[PRINT_TIMER]._timer = 50;
-	_vm->_timers[PRINT_TIMER]._initTm = 50;
-	_vm->_timers[PRINT_TIMER]._flag = true;
-
+void Scripts::cmdPrint() {
 	// Get a text line for display
 	Common::String msg;
 	byte c;
 	while ((c = (char)_data->readByte()) != '\0')
 		msg += c;
+	
+	printString(msg);
+}
+
+void Scripts::printString(const Common::String &msg) {
+	_vm->_fonts._printOrg = Common::Point(20, 42);
+	_vm->_fonts._printStart = Common::Point(20, 42);
+	_vm->_timers[PRINT_TIMER]._timer = 50;
+	_vm->_timers[PRINT_TIMER]._initTm = 50;
+	_vm->_timers[PRINT_TIMER]._flag = true;
 
 	// Display the text in a bubble, and wait for a keypress or mouse click
 	_vm->_bubbleBox->placeBubble(msg);
diff --git a/engines/access/scripts.h b/engines/access/scripts.h
index 70d79c4..ac2bae0 100644
--- a/engines/access/scripts.h
+++ b/engines/access/scripts.h
@@ -38,13 +38,15 @@ private:
 	const byte *_rawData;
 	Common::MemoryReadStream *_data;
 	int _specialFunction;
+
+	void printString(const Common::String &msg);
 protected:
 	AccessEngine *_vm;
 
 	virtual void executeSpecial(int commandIndex, int param1, int param2) = 0;
 	virtual void executeCommand(int commandIndex);
 	void CMDOBJECT();
-	void CMDENDOBJECT();
+	void cmdEndObject();
 	void cmdJumpLook();
 	void cmdJumpHelp();
 	void cmdJumpGet();


Commit: 9150e1816c57e3852fd86123ba8e0d1c9dee8ff4
    https://github.com/scummvm/scummvm/commit/9150e1816c57e3852fd86123ba8e0d1c9dee8ff4
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-17T22:44:31-04:00

Commit Message:
ACCESS: Shifted some Amazon specific opcodes to the AmazonScripts class

Changed paths:
    engines/access/amazon/amazon_scripts.cpp
    engines/access/amazon/amazon_scripts.h
    engines/access/scripts.cpp
    engines/access/scripts.h



diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp
index 2fdbcc9..38cf9d6 100644
--- a/engines/access/amazon/amazon_scripts.cpp
+++ b/engines/access/amazon/amazon_scripts.cpp
@@ -71,6 +71,63 @@ void AmazonScripts::executeSpecial(int commandIndex, int param1, int param2) {
 	}
 }
 
+typedef void(AmazonScripts::*AmazonScriptMethodPtr)();
+
+void AmazonScripts::executeCommand(int commandIndex) {
+	static const AmazonScriptMethodPtr COMMAND_LIST[] = {
+		&AmazonScripts::CMDHELP, &AmazonScripts::CMDCYCLEBACK,
+		&AmazonScripts::CMDCHAPTER, &AmazonScripts::cmdSetHelp,
+		&AmazonScripts::cmdCenterPanel, &AmazonScripts::cmdMainPanel,
+		&AmazonScripts::CMDRETFLASH
+	};
+
+	if (commandIndex >= 73)
+		(this->*COMMAND_LIST[commandIndex - 73])();
+	else
+		Scripts::executeCommand(commandIndex);
+}
+
+void AmazonScripts::CMDHELP() { 
+	error("TODO CMDHELP"); 
+}
+
+void AmazonScripts::CMDCYCLEBACK() { 
+	error("TODO CMDCYCLEBACK"); 
+}
+void AmazonScripts::CMDCHAPTER() { 
+	error("TODO CMDCHAPTER"); 
+}
+
+void AmazonScripts::cmdSetHelp() {
+	int arrayId = (_data->readUint16LE() && 0xFF) - 1;
+	int helpId = _data->readUint16LE() && 0xFF;
+
+	byte *help = _vm->_helpTbl[arrayId];
+	help[helpId] = 1;
+
+	if (_vm->_useItem == 0) {
+		_sequence = 11000;
+		searchForSequence();
+	}
+}
+
+void AmazonScripts::cmdCenterPanel() {
+	if (_vm->_screen->_vesaMode) {
+		_vm->_screen->clearScreen();
+		_vm->_screen->setPanel(3);
+	}
+}
+
+void AmazonScripts::cmdMainPanel() {
+	if (_vm->_screen->_vesaMode) {
+		_vm->_room->init4Quads();
+		_vm->_screen->setPanel(0);
+	}
+}
+
+void AmazonScripts::CMDRETFLASH() { 
+	error("TODO CMDRETFLASH"); 
+}
 
 } // End of namespace Amazon
 
diff --git a/engines/access/amazon/amazon_scripts.h b/engines/access/amazon/amazon_scripts.h
index b8fdaaa..c9a889e 100644
--- a/engines/access/amazon/amazon_scripts.h
+++ b/engines/access/amazon/amazon_scripts.h
@@ -33,6 +33,15 @@ namespace Amazon {
 class AmazonScripts: public Scripts {
 protected:
 	virtual void executeSpecial(int commandIndex, int param1, int param2);
+	virtual void executeCommand(int commandIndex);
+
+	void CMDHELP();
+	void CMDCYCLEBACK();
+	void CMDCHAPTER();
+	void cmdSetHelp();
+	void cmdCenterPanel();
+	void cmdMainPanel();
+	void CMDRETFLASH();
 public:
 	AmazonScripts(AccessEngine *vm);
 };
diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp
index fba947a..3c60065 100644
--- a/engines/access/scripts.cpp
+++ b/engines/access/scripts.cpp
@@ -29,7 +29,7 @@
 
 namespace Access {
 
-Scripts::Scripts(AccessEngine *vm) : _vm(vm) {
+Scripts::Scripts(AccessEngine *vm) : Manager(vm) {
 	_rawData = nullptr;
 	_data = nullptr;
 	_sequence = 0;
@@ -89,6 +89,8 @@ int Scripts::executeScript() {
 	return _returnCode;
 }
 
+typedef void(Scripts::*ScriptMethodPtr)();
+
 void Scripts::executeCommand(int commandIndex) {
 	static const ScriptMethodPtr COMMAND_LIST[] = {
 		&Scripts::CMDOBJECT, &Scripts::cmdEndObject, &Scripts::cmdJumpLook, 
@@ -115,9 +117,7 @@ void Scripts::executeCommand(int commandIndex) {
 		&Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, 
 		&Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, &Scripts::cmdPlayerOff, 
 		&Scripts::cmdPlayerOn, &Scripts::CMDDEAD, &Scripts::cmdFadeOut,
-		&Scripts::CMDENDVID, &Scripts::CMDHELP, &Scripts::CMDCYCLEBACK, 
-		&Scripts::CMDCHAPTER, &Scripts::cmdSetHelp, &Scripts::cmdCenterPanel,
-		&Scripts::cmdMainPanel, &Scripts::CMDRETFLASH
+		&Scripts::CMDENDVID
 	};
 
 	(this->*COMMAND_LIST[commandIndex])();
@@ -503,38 +503,5 @@ void Scripts::cmdFadeOut() {
 }
 
 void Scripts::CMDENDVID() { error("TODO CMDENDVID"); }
-void Scripts::CMDHELP() { error("TODO CMDHELP"); }
-void Scripts::CMDCYCLEBACK() { error("TODO CMDCYCLEBACK"); }
-void Scripts::CMDCHAPTER() { error("TODO CMDCHAPTER"); }
-
-void Scripts::cmdSetHelp() {
-	int arrayId = (_data->readUint16LE() && 0xFF) - 1;
-	int helpId = _data->readUint16LE() && 0xFF;
-
-	byte *help = _vm->_helpTbl[arrayId];
-	help[helpId] = 1;
-
-	if (_vm->_useItem == 0) {
-		_sequence = 11000;
-		searchForSequence();
-	}
-}
-
-void Scripts::cmdCenterPanel() {
-	if (_vm->_screen->_vesaMode) {
-		_vm->_screen->clearScreen();
-		_vm->_screen->setPanel(3);
-	}
-}
-
-void Scripts::cmdMainPanel() { 
-	if (_vm->_screen->_vesaMode) {
-		_vm->_room->init4Quads();
-		_vm->_screen->setPanel(0);
-	}
-}
-
-void Scripts::CMDRETFLASH() { error("TODO CMDRETFLASH"); }
-
 
 } // End of namespace Access
diff --git a/engines/access/scripts.h b/engines/access/scripts.h
index ac2bae0..1f0bf84 100644
--- a/engines/access/scripts.h
+++ b/engines/access/scripts.h
@@ -25,23 +25,21 @@
 
 #include "common/scummsys.h"
 #include "common/memstream.h"
+#include "access/data.h"
 
 namespace Access {
 
 class AccessEngine;
 class Scripts;
 
-typedef void(Scripts::*ScriptMethodPtr)();
-
-class Scripts {
+class Scripts: public Manager {
 private:
 	const byte *_rawData;
-	Common::MemoryReadStream *_data;
 	int _specialFunction;
 
 	void printString(const Common::String &msg);
 protected:
-	AccessEngine *_vm;
+	Common::MemoryReadStream *_data;
 
 	virtual void executeSpecial(int commandIndex, int param1, int param2) = 0;
 	virtual void executeCommand(int commandIndex);
@@ -112,13 +110,6 @@ protected:
 	void CMDDEAD();
 	void cmdFadeOut();
 	void CMDENDVID();
-	void CMDHELP();
-	void CMDCYCLEBACK();
-	void CMDCHAPTER();
-	void cmdSetHelp();
-	void cmdCenterPanel();
-	void cmdMainPanel();
-	void CMDRETFLASH();
 public:
 	int _sequence;
 	bool _endFlag;


Commit: d31b27ba1b26a38401387f85ca2ce46be455d0a2
    https://github.com/scummvm/scummvm/commit/d31b27ba1b26a38401387f85ca2ce46be455d0a2
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-17T23:04:05-04:00

Commit Message:
ACCESS: Partially implement cmdHelp

Changed paths:
    engines/access/amazon/amazon_game.cpp
    engines/access/amazon/amazon_game.h
    engines/access/amazon/amazon_resources.cpp
    engines/access/amazon/amazon_resources.h
    engines/access/amazon/amazon_scripts.cpp
    engines/access/amazon/amazon_scripts.h
    engines/access/scripts.cpp
    engines/access/scripts.h



diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp
index 663d699..857d1b3 100644
--- a/engines/access/amazon/amazon_game.cpp
+++ b/engines/access/amazon/amazon_game.cpp
@@ -51,7 +51,9 @@ AmazonEngine::AmazonEngine(OSystem *syst, const AccessGameDescription *gameDesc)
 	_rawInactiveX = 0;
 	_rawInactiveY = 0;
 	_inactiveYOff = 0;
+
 	Common::fill(&_esTabTable[0], &_esTabTable[100], 0);
+	_hintLevel = 0;
 }
 
 AmazonEngine::~AmazonEngine() {
@@ -182,6 +184,10 @@ void AmazonEngine::setupGame() {
 	_player->_playerY = _player->_rawPlayer.y = TRAVEL_POS[_player->_roomNumber][1];
 }
 
+void AmazonEngine::drawHelp() {
+	error("TODO: drawHelp");
+}
+
 } // End of namespace Amazon
 
 } // End of namespace Access
diff --git a/engines/access/amazon/amazon_game.h b/engines/access/amazon/amazon_game.h
index 848af85..c331830 100644
--- a/engines/access/amazon/amazon_game.h
+++ b/engines/access/amazon/amazon_game.h
@@ -93,10 +93,15 @@ public:
 	int &_aniFlag;
 	int &_allenFlag;
 	int &_noSound;
+
+	// Other game specific fields
+	int _hintLevel;
 public:
 	AmazonEngine(OSystem *syst, const AccessGameDescription *gameDesc);
 
 	virtual ~AmazonEngine();
+
+	void drawHelp();
 };
 
 } // End of namespace Amazon
diff --git a/engines/access/amazon/amazon_resources.cpp b/engines/access/amazon/amazon_resources.cpp
index b7a2472..1f666e1 100644
--- a/engines/access/amazon/amazon_resources.cpp
+++ b/engines/access/amazon/amazon_resources.cpp
@@ -1187,6 +1187,13 @@ const byte FONT6x6_DATA[] = {
 	0x54, 0x49, 0x4f, 0x4e, 0x00, 0x4d, 0x4f, 0x56, 0x49,
 };
 
+const char *const NO_HELP_MESSAGE = 
+	"WE ARE UNABLE TO PROVIDE YOU WITH ANY MORE HINTS.  YOUR IQ \
+HAS DECREASED SO FAR THAT WE CAN NO LONGER PUT THE HINTS IN TERMS \
+YOU CAN UNDERSTAND.";
+const char *const NO_HINTS_MESSAGE =
+	"THE HELP SYSTEM HAS BEEN TURNED OFF FOR THIS GAME.";
+
 } // End of namespace Amazon
 
 } // End of namespace Access
diff --git a/engines/access/amazon/amazon_resources.h b/engines/access/amazon/amazon_resources.h
index 838bd29..d618ca5 100644
--- a/engines/access/amazon/amazon_resources.h
+++ b/engines/access/amazon/amazon_resources.h
@@ -49,6 +49,9 @@ extern const int FONT6x6_INDEX[];
 
 extern const byte FONT6x6_DATA[];
 
+extern const char *const NO_HELP_MESSAGE;
+extern const char *const NO_HINTS_MESSAGE;
+
 } // End of namespace Amazon
 
 } // End of namespace Access
diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp
index 38cf9d6..104473a 100644
--- a/engines/access/amazon/amazon_scripts.cpp
+++ b/engines/access/amazon/amazon_scripts.cpp
@@ -22,6 +22,8 @@
 
 #include "common/scummsys.h"
 #include "access/access.h"
+#include "access/amazon/amazon_game.h"
+#include "access/amazon/amazon_resources.h"
 #include "access/amazon/amazon_scripts.h"
 
 namespace Access {
@@ -29,6 +31,7 @@ namespace Access {
 namespace Amazon {
 
 AmazonScripts::AmazonScripts(AccessEngine *vm) : Scripts(vm) {
+	_game = (AmazonEngine *)_vm;
 }
 
 void AmazonScripts::executeSpecial(int commandIndex, int param1, int param2) {
@@ -75,7 +78,7 @@ typedef void(AmazonScripts::*AmazonScriptMethodPtr)();
 
 void AmazonScripts::executeCommand(int commandIndex) {
 	static const AmazonScriptMethodPtr COMMAND_LIST[] = {
-		&AmazonScripts::CMDHELP, &AmazonScripts::CMDCYCLEBACK,
+		&AmazonScripts::cmdHelp, &AmazonScripts::CMDCYCLEBACK,
 		&AmazonScripts::CMDCHAPTER, &AmazonScripts::cmdSetHelp,
 		&AmazonScripts::cmdCenterPanel, &AmazonScripts::cmdMainPanel,
 		&AmazonScripts::CMDRETFLASH
@@ -87,8 +90,28 @@ void AmazonScripts::executeCommand(int commandIndex) {
 		Scripts::executeCommand(commandIndex);
 }
 
-void AmazonScripts::CMDHELP() { 
-	error("TODO CMDHELP"); 
+void AmazonScripts::cmdHelp() {
+	Common::String helpMessage = readString();
+
+	if (_game->_helpLevel == 0) {
+		_game->_timers.saveTimers();
+		_game->_useItem = 0;
+
+		if (_game->_noHints) {
+			printString(NO_HELP_MESSAGE);
+			return;
+		} else if (_game->_hintLevel == 0) {
+			printString(NO_HINTS_MESSAGE);
+			return;
+		}
+	}
+
+	int level = _game->_hintLevel - 1;
+	if (level < _game->_helpLevel)
+		_game->_moreHelp = 0;
+
+	_game->drawHelp();
+	error("TODO: more cmdHelp");
 }
 
 void AmazonScripts::CMDCYCLEBACK() { 
diff --git a/engines/access/amazon/amazon_scripts.h b/engines/access/amazon/amazon_scripts.h
index c9a889e..978ef01 100644
--- a/engines/access/amazon/amazon_scripts.h
+++ b/engines/access/amazon/amazon_scripts.h
@@ -30,12 +30,16 @@ namespace Access {
 
 namespace Amazon {
 
+class AmazonEngine;
+
 class AmazonScripts: public Scripts {
+private:
+	AmazonEngine *_game;
 protected:
 	virtual void executeSpecial(int commandIndex, int param1, int param2);
 	virtual void executeCommand(int commandIndex);
 
-	void CMDHELP();
+	void cmdHelp();
 	void CMDCYCLEBACK();
 	void CMDCHAPTER();
 	void cmdSetHelp();
diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp
index 3c60065..958696e 100644
--- a/engines/access/scripts.cpp
+++ b/engines/access/scripts.cpp
@@ -180,11 +180,7 @@ void Scripts::cmdNull() {
 
 void Scripts::cmdPrint() {
 	// Get a text line for display
-	Common::String msg;
-	byte c;
-	while ((c = (char)_data->readByte()) != '\0')
-		msg += c;
-	
+	Common::String msg = readString();
 	printString(msg);
 }
 
@@ -208,6 +204,15 @@ void Scripts::printString(const Common::String &msg) {
 	_vm->_screen->restoreBlock();
 }
 
+Common::String Scripts::readString() {
+	Common::String msg;
+	byte c;
+	while ((c = (char)_data->readByte()) != '\0')
+		msg += c;
+
+	return msg;
+}
+
 void Scripts::cmdRetPos() {
 	_endFlag = true;
 	_returnCode = 0;
diff --git a/engines/access/scripts.h b/engines/access/scripts.h
index 1f0bf84..5f84941 100644
--- a/engines/access/scripts.h
+++ b/engines/access/scripts.h
@@ -37,12 +37,22 @@ private:
 	const byte *_rawData;
 	int _specialFunction;
 
-	void printString(const Common::String &msg);
 protected:
 	Common::MemoryReadStream *_data;
 
 	virtual void executeSpecial(int commandIndex, int param1, int param2) = 0;
 	virtual void executeCommand(int commandIndex);
+
+	/**
+	 * Print a given message to the screen in a bubble box
+	 */
+	void printString(const Common::String &msg);
+
+	/**
+	 * Read a null terminated string from the script
+	 */
+	Common::String readString();
+
 	void CMDOBJECT();
 	void cmdEndObject();
 	void cmdJumpLook();


Commit: 5ec8c445bd21e9b7fd592bf1cc8785a0d44bde23
    https://github.com/scummvm/scummvm/commit/5ec8c445bd21e9b7fd592bf1cc8785a0d44bde23
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-17T23:08:14-04:00

Commit Message:
ACCESS: Fix player flickering

Changed paths:
    engines/access/player.cpp



diff --git a/engines/access/player.cpp b/engines/access/player.cpp
index 79ce219..dfbee48 100644
--- a/engines/access/player.cpp
+++ b/engines/access/player.cpp
@@ -562,71 +562,70 @@ void Player::walkDownRight() {
 }
 
 void Player::checkMove() {
-	if (!_vm->_events->_mouseMove)
-		return;
-
-	if (_xFlag == 0 && _yFlag == 0) {
-		int xp = (_playerOffset.x / 2) + _rawPlayer.x - _moveTo.x;
-		if (xp < 0)
-			xp = -xp;
-		int yp = _rawPlayer.y - _moveTo.y;
-		if (yp < 0)
-			yp = -yp;
-
-		if (xp < yp)
-			_xFlag = 1;
-		else
-			_yFlag = 1;
-	}
+	if (_vm->_events->_mouseMove) {
+		if (_xFlag == 0 && _yFlag == 0) {
+			int xp = (_playerOffset.x / 2) + _rawPlayer.x - _moveTo.x;
+			if (xp < 0)
+				xp = -xp;
+			int yp = _rawPlayer.y - _moveTo.y;
+			if (yp < 0)
+				yp = -yp;
+
+			if (xp < yp)
+				_xFlag = 1;
+			else
+				_yFlag = 1;
+		}
 
-	if (_yFlag == 1) {
-		int yd = _rawPlayer.y - _moveTo.y;
-		if ((yd >= 0 && yd <= _upDelta) || (yd < 0 && -yd <= _upDelta)) {
-			++_yFlag;
-			if (_xFlag) {
-				_vm->_events->_mouseMove = false;
-				_xFlag = _yFlag = 0;
+		if (_yFlag == 1) {
+			int yd = _rawPlayer.y - _moveTo.y;
+			if ((yd >= 0 && yd <= _upDelta) || (yd < 0 && -yd <= _upDelta)) {
+				++_yFlag;
+				if (_xFlag) {
+					_vm->_events->_mouseMove = false;
+					_xFlag = _yFlag = 0;
+				} else {
+					++_xFlag;
+				}
 			} else {
-				++_xFlag;
+				if (yd >= 0)
+					walkUp();
+				else
+					walkDown();
+
+				if (_collideFlag) {
+					_vm->_events->_mouseMove = false;
+					_xFlag = _yFlag = 0;
+				}
 			}
-		} else {
-			if (yd >= 0)
-				walkUp();
-			else
-				walkDown();
+		} else if (_xFlag == 1) {
+			int xd = _rawPlayer.x - _moveTo.x;
+			if ((xd >= 0 && xd <= -_leftDelta) || (xd < 0 && -xd <= -_leftDelta)) {
+				++_xFlag;
 
-			if (_collideFlag) {
-				_vm->_events->_mouseMove = false;
-				_xFlag = _yFlag = 0;
-			}
-		}
-	} else if (_xFlag == 1) {
-		int xd = _rawPlayer.x - _moveTo.x;
-		if ((xd >= 0 && xd <= -_leftDelta) || (xd < 0 && -xd <= -_leftDelta)) {
-			++_xFlag;
-
-			if (_yFlag) {
-				_vm->_events->_mouseMove = false;
-				_xFlag = _yFlag = 0;
+				if (_yFlag) {
+					_vm->_events->_mouseMove = false;
+					_xFlag = _yFlag = 0;
+				}
+			} else {
+				if (xd >= 0)
+					walkLeft();
+				else
+					walkRight();
+
+				if (_collideFlag) {
+					_vm->_events->_mouseMove = false;
+					_xFlag = _yFlag = 0;
+				}
 			}
+		} else if (!_yFlag) {
+			++_yFlag;
 		} else {
-			if (xd >= 0)
-				walkLeft();
-			else
-				walkRight();
-
-			if (_collideFlag) {
-				_vm->_events->_mouseMove = false;
-				_xFlag = _yFlag = 0;
-			}
+			_vm->_events->_mouseMove = false;
+			_xFlag = _yFlag = 0;
 		}
-	} else if (!_yFlag) {
-		++_yFlag;
-	} else {
-		_vm->_events->_mouseMove = false;
-		_xFlag = _yFlag = 0;
 	}
-	
+
 	plotCom3();
 }
 


Commit: d570da065ec422132b4dd409b9b4ecf9cea92fc8
    https://github.com/scummvm/scummvm/commit/d570da065ec422132b4dd409b9b4ecf9cea92fc8
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-17T23:15:32-04:00

Commit Message:
ACCESS: Fix selecting location for player to walk to

Changed paths:
    engines/access/amazon/amazon_room.cpp
    engines/access/events.cpp
    engines/access/events.h
    engines/access/player.cpp
    engines/access/player.h



diff --git a/engines/access/amazon/amazon_room.cpp b/engines/access/amazon/amazon_room.cpp
index bf3c250..79c70c0 100644
--- a/engines/access/amazon/amazon_room.cpp
+++ b/engines/access/amazon/amazon_room.cpp
@@ -148,14 +148,17 @@ void AmazonRoom::mainAreaClick() {
 			switch (checkBoxes1(_vm->_events->_mousePos)) {
 			case 0:
 				_game->_jasMayaFlag = 0;
-				break;
+				return;
 			case 1:
 				_game->_jasMayaFlag = 1;
-				break;
+				return;
 			default:
 				break;
 			}
-		}
+		} 
+
+		_vm->_player->_moveTo = _vm->_events->_mousePos;
+		_vm->_player->_playerMove = true;
 	} else if (_vm->_events->_mousePos.x >= _vm->_screen->_windowXAdd &&
 			_vm->_events->_mousePos.x <= _vm->_screen->_vWindowBytesWide &&
 			_vm->_events->_mousePos.y >= _vm->_screen->_windowYAdd &&
diff --git a/engines/access/events.cpp b/engines/access/events.cpp
index 25a77f8..1afc551 100644
--- a/engines/access/events.cpp
+++ b/engines/access/events.cpp
@@ -40,7 +40,6 @@ EventsManager::EventsManager(AccessEngine *vm): _vm(vm) {
 	_frameCounter = 10;
 	_priorFrameTime = 0;
 	_leftButton = _rightButton = false;
-	_mouseMove = false;
 	_mouseCol = _mouseRow = 0;
 	_mouseMode = 0;
 	_cursorExitFlag = false;
diff --git a/engines/access/events.h b/engines/access/events.h
index c6702ec..4c052f9 100644
--- a/engines/access/events.h
+++ b/engines/access/events.h
@@ -55,7 +55,6 @@ public:
 	bool _leftButton, _rightButton;
 	Common::Point _mousePos;
 	int _mouseCol, _mouseRow;
-	bool _mouseMove;
 	int _mouseMode;
 	bool _cursorExitFlag;
 	Common::FixedStack<Common::KeyState> _keypresses;
diff --git a/engines/access/player.cpp b/engines/access/player.cpp
index dfbee48..cde1a74 100644
--- a/engines/access/player.cpp
+++ b/engines/access/player.cpp
@@ -49,6 +49,7 @@ Player::Player(AccessEngine *vm): Manager(vm), ImageEntry() {
 	_playerY = 0;
 	_frame = 0;
 	_playerOff = false;
+	_playerMove = false;
 	_leftDelta = _rightDelta = 0;
 	_upDelta = _downDelta = 0;
 	_scrollConst = 0;
@@ -193,35 +194,35 @@ void Player::walk() {
 	_vm->_timers[0]._flag = true;
 	switch (_move) {
 	case UP:
-		_vm->_events->_mouseMove = false;
+		_playerMove = false;
 		walkUp();
 		break;
 	case DOWN:
-		_vm->_events->_mouseMove = false;
+		_playerMove = false;
 		walkDown();
 		break;
 	case LEFT:
-		_vm->_events->_mouseMove = false;
+		_playerMove = false;
 		walkLeft();
 		break;
 	case RIGHT:
-		_vm->_events->_mouseMove = false;
+		_playerMove = false;
 		walkRight();
 		break;
 	case UPLEFT:
-		_vm->_events->_mouseMove = false;
+		_playerMove = false;
 		walkUpLeft();
 		break;
 	case DOWNLEFT:
-		_vm->_events->_mouseMove = false;
+		_playerMove = false;
 		walkDownLeft();
 		break;
 	case UPRIGHT:
-		_vm->_events->_mouseMove = false;
+		_playerMove = false;
 		walkUpRight();
 		break;
 	case DOWNRIGHT:
-		_vm->_events->_mouseMove = false;
+		_playerMove = false;
 		walkDownRight();
 		break;
 	default:
@@ -562,7 +563,7 @@ void Player::walkDownRight() {
 }
 
 void Player::checkMove() {
-	if (_vm->_events->_mouseMove) {
+	if (_playerMove) {
 		if (_xFlag == 0 && _yFlag == 0) {
 			int xp = (_playerOffset.x / 2) + _rawPlayer.x - _moveTo.x;
 			if (xp < 0)
@@ -582,7 +583,7 @@ void Player::checkMove() {
 			if ((yd >= 0 && yd <= _upDelta) || (yd < 0 && -yd <= _upDelta)) {
 				++_yFlag;
 				if (_xFlag) {
-					_vm->_events->_mouseMove = false;
+					_playerMove = false;
 					_xFlag = _yFlag = 0;
 				} else {
 					++_xFlag;
@@ -594,7 +595,7 @@ void Player::checkMove() {
 					walkDown();
 
 				if (_collideFlag) {
-					_vm->_events->_mouseMove = false;
+					_playerMove = false;
 					_xFlag = _yFlag = 0;
 				}
 			}
@@ -604,7 +605,7 @@ void Player::checkMove() {
 				++_xFlag;
 
 				if (_yFlag) {
-					_vm->_events->_mouseMove = false;
+					_playerMove = false;
 					_xFlag = _yFlag = 0;
 				}
 			} else {
@@ -614,14 +615,14 @@ void Player::checkMove() {
 					walkRight();
 
 				if (_collideFlag) {
-					_vm->_events->_mouseMove = false;
+					_playerMove = false;
 					_xFlag = _yFlag = 0;
 				}
 			}
 		} else if (!_yFlag) {
 			++_yFlag;
 		} else {
-			_vm->_events->_mouseMove = false;
+			_playerMove = false;
 			_xFlag = _yFlag = 0;
 		}
 	}
diff --git a/engines/access/player.h b/engines/access/player.h
index b904e46..b11cc4a 100644
--- a/engines/access/player.h
+++ b/engines/access/player.h
@@ -51,7 +51,6 @@ private:
 	bool _collideFlag;
 	Direction _move;
 	int _xFlag, _yFlag;
-	Common::Point _moveTo;
 	SpriteResource *_playerSprites1;
 	byte *_manPal1;
 	int _scrollEnd;
@@ -102,6 +101,8 @@ public:
 
 	// Additional public globals we've added to new Player class
 	bool _playerOff;
+	bool _playerMove;
+	Common::Point _moveTo;
 	bool _scrollFlag;
 	int _scrollThreshold;
 	int _scrollAmount;


Commit: 17315a4dd71d4f9151724166bb5ddd7fdc0074f7
    https://github.com/scummvm/scummvm/commit/17315a4dd71d4f9151724166bb5ddd7fdc0074f7
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-18T00:29:01-04:00

Commit Message:
ACCESS: Implemented wall checks for pathfinding

Changed paths:
    engines/access/player.cpp
    engines/access/player.h
    engines/access/room.cpp
    engines/access/room.h



diff --git a/engines/access/player.cpp b/engines/access/player.cpp
index cde1a74..0733e80 100644
--- a/engines/access/player.cpp
+++ b/engines/access/player.cpp
@@ -249,7 +249,7 @@ void Player::walkUp() {
 	_rawYTemp = _rawPlayer.y - _vm->_screen->_scaleTable1[walkOff];
 	_rawXTemp = _rawPlayer.x;
 
-	if (codeWalls()) {
+	if (_vm->_room->codeWalls()) {
 		plotCom2();
 	} else {
 		_rawPlayer.y = _rawYTemp;
@@ -277,7 +277,7 @@ void Player::walkDown() {
 	_rawYTemp = _rawPlayer.y - _vm->_screen->_scaleTable1[walkOff];
 	_rawXTemp = _rawPlayer.x;
 
-	if (codeWalls()) {
+	if (_vm->_room->codeWalls()) {
 		plotCom2();
 	} else {
 		_rawPlayer.y = _rawYTemp;
@@ -316,7 +316,7 @@ void Player::walkLeft() {
 	}	
 	_rawYTemp = _rawPlayer.y;
 
-	if (codeWalls()) {
+	if (_vm->_room->codeWalls()) {
 		plotCom2();
 	} else {
 		_rawPlayer.x = _rawXTemp;
@@ -355,7 +355,7 @@ void Player::walkRight() {
 	}
 	_rawYTemp = _rawPlayer.y;
 
-	if (codeWalls()) {
+	if (_vm->_room->codeWalls()) {
 		plotCom2();
 	} else {
 		_rawPlayer.x = _rawXTemp;
@@ -398,7 +398,7 @@ void Player::walkUpLeft() {
 	_rawYTempL = _rawPlayerLow.y - _vm->_screen->_scaleTable2[walkOffset];
 	_rawYTemp = _rawPlayer.y - _vm->_screen->_scaleTable1[walkOffset];
 
-	if (codeWalls()) {
+	if (_vm->_room->codeWalls()) {
 		plotCom2();
 	} else {
 		_rawPlayer.x = _rawXTemp;
@@ -445,7 +445,7 @@ void Player::walkDownLeft() {
 	_rawYTempL = _rawPlayerLow.y - _vm->_screen->_scaleTable2[walkOffset];
 	_rawYTemp = _rawPlayer.y - _vm->_screen->_scaleTable1[walkOffset];
 
-	if (codeWalls()) {
+	if (_vm->_room->codeWalls()) {
 		plotCom2();
 	} else {
 		_rawPlayer.x = _rawXTemp;
@@ -492,7 +492,7 @@ void Player::walkUpRight() {
 	_rawYTempL = _rawPlayerLow.y - _vm->_screen->_scaleTable2[walkOffset];
 	_rawYTemp = _rawPlayer.y - _vm->_screen->_scaleTable1[walkOffset];
 
-	if (codeWalls()) {
+	if (_vm->_room->codeWalls()) {
 		plotCom2();
 	} else {
 		_rawPlayer.x = _rawXTemp;
@@ -540,7 +540,7 @@ void Player::walkDownRight() {
 	_rawYTempL = _rawPlayerLow.y - _vm->_screen->_scaleTable2[walkOffset];
 	_rawYTemp = _rawPlayer.y - _vm->_screen->_scaleTable1[walkOffset];
 
-	if (codeWalls()) {
+	if (_vm->_room->codeWalls()) {
 		plotCom2();
 	} else {
 		_rawPlayer.x = _rawXTemp;
@@ -658,10 +658,6 @@ void Player::plotCom3() {
 	plotCom2();
 }
 
-bool Player::codeWalls() {
-	error("TODO codeWalls");
-}
-
 void Player::checkScroll() {
 	_scrollFlag = false;
 	if (_playerDirection == NONE)
diff --git a/engines/access/player.h b/engines/access/player.h
index b11cc4a..876c0e5 100644
--- a/engines/access/player.h
+++ b/engines/access/player.h
@@ -48,7 +48,6 @@ private:
 	int _diagUpWalkMin, _diagUpWalkMax;
 	int _diagDownWalkMin, _diagDownWalkMax;
 	Common::Point _guard;
-	bool _collideFlag;
 	Direction _move;
 	int _xFlag, _yFlag;
 	SpriteResource *_playerSprites1;
@@ -56,7 +55,6 @@ private:
 	int _scrollEnd;
 	int _inactiveYOff;
 
-	bool codeWalls();
 	void checkMove();
 	void plotCom(int v1);
 	void plotCom1();
@@ -103,6 +101,7 @@ public:
 	bool _playerOff;
 	bool _playerMove;
 	Common::Point _moveTo;
+	bool _collideFlag;
 	bool _scrollFlag;
 	int _scrollThreshold;
 	int _scrollAmount;
diff --git a/engines/access/room.cpp b/engines/access/room.cpp
index 0405e7c..9c2bd01 100644
--- a/engines/access/room.cpp
+++ b/engines/access/room.cpp
@@ -584,6 +584,141 @@ int Room::validateBox(int boxId) {
 	return _vm->_scripts->executeScript();
 }
 
+void Room::swapOrg() {
+	SWAP<int>(_vm->_screen->_orgX1, _vm->_screen->_orgX2);
+	SWAP<int>(_vm->_screen->_orgY1, _vm->_screen->_orgY2);
+}
+
+int Room::calcLR(int yp) {
+	const Screen &screen = *_vm->_screen;
+
+	int yv = (yp - screen._orgY1) * (screen._orgX2 - screen._orgX1);
+	int yd = screen._orgY2 - screen._orgY1;
+
+	int rem = (yv % yd) << 1;
+	yv /= yd;
+	if (rem >= yd)
+		++yv;
+
+	return yv + screen._orgX1;
+}
+
+int Room::calcUD(int xp) {
+	const Screen &screen = *_vm->_screen;
+
+	int xv = (xp - screen._orgX1) * (screen._orgY2 - screen._orgY1);
+	int xd = screen._orgX2 - screen._orgX1;
+
+	int rem = (xv % xd) << 1;
+	xv /= xd;
+	if (rem >= xd)
+		++xv;
+
+	return xv + screen._orgY1;
+}
+
+bool Room::codeWalls() {
+	Screen &screen = *_vm->_screen;
+	Player &player = *_vm->_player;
+
+	if (_plotter._walls.size() == 0)
+		return false;
+
+	for (uint i = 0; i < _plotter._walls.size(); ++i) {
+		Common::Rect &r = _plotter._walls[i];
+		JetFrame &jf = _jetFrame[i];
+
+		jf._wallCode = 0;
+		jf._wallCode1 = 0;
+		screen._orgX1 = r.left;
+		screen._orgY1 = r.top;
+		screen._orgX2 = r.right;
+		screen._orgY2 = r.bottom;
+
+		if (screen._orgY2 != screen._orgY1) {
+			if (screen._orgY2 < screen._orgY1)
+				swapOrg();
+
+			if ((player._rawYTemp >= screen._orgY1) &&
+					(player._rawYTemp <= screen._orgY2)) {
+				jf._wallCode |= (calcLR(player._rawYTemp) - player._rawXTemp) < 0 ? 2 : 1;
+				jf._wallCode1 |= (calcLR(player._rawYTemp) - player._playerOffset.x) < 0 ? 2 : 1;
+			}
+		}
+
+		if (screen._orgX2 != screen._orgX1) {
+			if (screen._orgX2 < screen._orgX1)
+				swapOrg();
+
+			if ((player._rawXTemp >= screen._orgX1) &&
+					(player._rawXTemp <= screen._orgX2)) {
+				int y = screen._orgY2;
+				if (y == screen._orgY1)
+					y = calcUD(player._rawXTemp);
+
+				jf._wallCode |= (player._rawYTemp - y) < 0 ? 4 : 8;
+			}
+
+			int x = player._rawXTemp + player._playerOffset.x;
+			if ((x >= screen._orgX1) && (x <= screen._orgX2)) {
+				int y = screen._orgY2;
+				if (screen._orgY2 != screen._orgY1)
+					y = calcUD(player._rawXTemp + player._playerOffset.x);
+
+				jf._wallCode1 |= (player._rawYTemp - y) < 0 ? 4 : 8;
+			}
+		}
+	}
+
+	for (uint i = 0; i < _jetFrame.size(); ++i) {
+		JetFrame &jf = _jetFrame[i];
+		if (checkCode(jf._wallCode, jf._wallCodeOld) ||
+			checkCode(jf._wallCode1, jf._wallCode1Old))
+			return true;
+	}
+
+	// Copy the current wall calculations to the old properties
+	for (uint i = 0; i < _jetFrame.size(); ++i) {
+		JetFrame &jf = _jetFrame[i];
+		jf._wallCodeOld = jf._wallCode;
+		jf._wallCode1Old = jf._wallCode1;
+	}
+
+	return false;
+}
+
+bool Room::checkCode(int v1, int v2) {
+	Player &p = *_vm->_player;
+
+	if (!v1) {
+		p._collideFlag = true;
+		return true;
+	} if (!v2 || (v1 == v2)) {
+	} else if (v1 & 1) {
+		if (v2 & 2) {
+			p._collideFlag = true;
+			return true;
+		}
+	} else if (v1 & 2) {
+		if (v2 & 1) {
+			p._collideFlag = true;
+			return true;
+		}
+	} else if (v1 & 4) {
+		if (v2 & 8) {
+			p._collideFlag = true;
+			return true;
+		}
+	} else if (v1 & 8) {
+		if (v2 & 4) {
+			p._collideFlag = true;
+			return true;
+		}
+	}
+
+	return false;
+}
+
 /*------------------------------------------------------------------------*/
 
 RoomInfo::RoomInfo(const byte *data) {
diff --git a/engines/access/room.h b/engines/access/room.h
index a90c6e4..c76bd70 100644
--- a/engines/access/room.h
+++ b/engines/access/room.h
@@ -65,6 +65,12 @@ private:
 	void loadPlayField(int fileNum, int subfile);
 
 	void commandOff();
+
+	void swapOrg();
+	int calcLR(int yp);
+	int calcUD(int xp);
+
+	bool checkCode(int v1, int v2);
 protected:
 	void loadRoomData(const byte *roomData);
 	void setupRoom();
@@ -109,8 +115,6 @@ protected:
 
 	virtual void mainAreaClick() = 0;
 public:
-	void setWallCodes();
-
 	virtual void setIconPalette() {}
 public:
 	Plotter _plotter;
@@ -142,6 +146,10 @@ public:
 	void buildRow(int playY, int screenY);
 
 	void init4Quads();
+
+	void setWallCodes();
+
+	bool codeWalls();
 };
 
 class RoomInfo {


Commit: 080a030116862ee21e0ebcec019fdc3f8e073650
    https://github.com/scummvm/scummvm/commit/080a030116862ee21e0ebcec019fdc3f8e073650
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-18T07:32:17-04:00

Commit Message:
ACCESS: Some initial pathfinding bugfixes

Changed paths:
    engines/access/player.cpp
    engines/access/player.h
    engines/access/room.cpp



diff --git a/engines/access/player.cpp b/engines/access/player.cpp
index 0733e80..44dd0d2 100644
--- a/engines/access/player.cpp
+++ b/engines/access/player.cpp
@@ -565,6 +565,8 @@ void Player::walkDownRight() {
 void Player::checkMove() {
 	if (_playerMove) {
 		if (_xFlag == 0 && _yFlag == 0) {
+			// Figure out whether a greater horizontal movement than vertical
+			// movement will be required, or vice versa
 			int xp = (_playerOffset.x / 2) + _rawPlayer.x - _moveTo.x;
 			if (xp < 0)
 				xp = -xp;
@@ -572,7 +574,7 @@ void Player::checkMove() {
 			if (yp < 0)
 				yp = -yp;
 
-			if (xp < yp)
+			if (xp > yp)
 				_xFlag = 1;
 			else
 				_yFlag = 1;
@@ -600,7 +602,7 @@ void Player::checkMove() {
 				}
 			}
 		} else if (_xFlag == 1) {
-			int xd = _rawPlayer.x - _moveTo.x;
+			int xd = _playerOffset.x / 2 +  _rawPlayer.x - _moveTo.x;
 			if ((xd >= 0 && xd <= -_leftDelta) || (xd < 0 && -xd <= -_leftDelta)) {
 				++_xFlag;
 
diff --git a/engines/access/player.h b/engines/access/player.h
index 876c0e5..7ba0c05 100644
--- a/engines/access/player.h
+++ b/engines/access/player.h
@@ -86,9 +86,9 @@ public:
 	Common::Point _walkOffDR[PLAYER_DATA_COUNT];
 	Common::Point _walkOffUL[PLAYER_DATA_COUNT];
 	Common::Point _walkOffDL[PLAYER_DATA_COUNT];
-	int _rawTempL;
+	byte _rawTempL;
 	int _rawXTemp;
-	int _rawYTempL;
+	byte _rawYTempL;
 	int _rawYTemp;
 	Common::Point _playerOffset;
 	int _playerXLow;
diff --git a/engines/access/room.cpp b/engines/access/room.cpp
index 9c2bd01..5e3a4d7 100644
--- a/engines/access/room.cpp
+++ b/engines/access/room.cpp
@@ -653,7 +653,7 @@ bool Room::codeWalls() {
 			if ((player._rawXTemp >= screen._orgX1) &&
 					(player._rawXTemp <= screen._orgX2)) {
 				int y = screen._orgY2;
-				if (y == screen._orgY1)
+				if (y != screen._orgY1)
 					y = calcUD(player._rawXTemp);
 
 				jf._wallCode |= (player._rawYTemp - y) < 0 ? 4 : 8;
@@ -691,8 +691,6 @@ bool Room::checkCode(int v1, int v2) {
 	Player &p = *_vm->_player;
 
 	if (!v1) {
-		p._collideFlag = true;
-		return true;
 	} if (!v2 || (v1 == v2)) {
 	} else if (v1 & 1) {
 		if (v2 & 2) {


Commit: b6dc7a1dd4bdbc020254943e73355a17d521487c
    https://github.com/scummvm/scummvm/commit/b6dc7a1dd4bdbc020254943e73355a17d521487c
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-08-19T00:18:42+02:00

Commit Message:
ACCESS: Implement two more opcodes

Changed paths:
    engines/access/scripts.cpp
    engines/access/scripts.h



diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp
index 958696e..1e5bbc8 100644
--- a/engines/access/scripts.cpp
+++ b/engines/access/scripts.cpp
@@ -110,9 +110,9 @@ void Scripts::executeCommand(int commandIndex) {
 		&Scripts::CMDSETBUFVID, &Scripts::CMDPLAYBUFVID, &Scripts::cmdRemoveLast, 
 		&Scripts::cmdSpecial, &Scripts::cmdSpecial, &Scripts::cmdSpecial,
 		&Scripts::CMDSETCYCLE, &Scripts::CMDCYCLE, &Scripts::cmdCharSpeak, 
-		&Scripts::cmdTexSpeak, &Scripts::CMDTEXCHOICE, &Scripts::CMDWAIT, 
+		&Scripts::cmdTexSpeak, &Scripts::cmdTexChoice, &Scripts::CMDWAIT, 
 		&Scripts::cmdSetConPos, &Scripts::CMDCHECKVFRAME, &Scripts::cmdJumpChoice, 
-		&Scripts::cmdReturnChoice, &Scripts::cmdClearBlock, &Scripts::CMDLOADSOUND, 
+		&Scripts::cmdReturnChoice, &Scripts::cmdClearBlock, &Scripts::cmdLoadSound, 
 		&Scripts::CMDFREESOUND, &Scripts::CMDSETVIDSND, &Scripts::CMDPLAYVIDSND,
 		&Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, 
 		&Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, &Scripts::cmdPlayerOff, 
@@ -454,7 +454,111 @@ void Scripts::cmdTexSpeak() {
 	findNull();
 }
 
-void Scripts::CMDTEXCHOICE() { error("TODO CMDTEXCHOICE"); } // _choiceStart = _data->pos() - 1;
+int Scripts::checkMouseBox1(Common::Rect *rectArr) {
+	int i = 0;
+	for (i = 0; ; i++){
+		if (rectArr[i].left == -1)
+			return -1;
+
+		if ((_vm->_events->_mousePos.x > rectArr[i].left) && (_vm->_events->_mousePos.x < rectArr[i].right) 
+			&& (_vm->_events->_mousePos.y > rectArr[i].top) && (_vm->_events->_mousePos.y < rectArr[i].bottom))
+			return i;
+	}
+}
+
+void Scripts::cmdTexChoice() {
+	static Common::Point cMouse[7] = {
+		Common::Point(0, 76), Common::Point(77, 154), Common::Point(155, 232),
+		Common::Point(233, 276), Common::Point(0, 0), Common::Point(277, 319),
+		Common::Point(297, 319)
+	};
+
+	_vm->_oldRects.clear();
+	_choiceStart = _data->pos() - 1;
+	_vm->_fonts._charSet._lo = 1;
+	_vm->_fonts._charSet._hi = 8;
+	_vm->_fonts._charFor._lo = 55;
+	_vm->_fonts._charFor._hi = 255;
+	_vm->_bubbleBox->_maxChars = 20;
+
+	_vm->_fonts._printOrg = _texsOrg;
+	_vm->_fonts._printStart = _texsOrg;
+
+	_vm->_bubbleBox->clearBubbles();
+	_vm->_bubbleBox->_bubblePtr = Common::String("RESPONSE 1").c_str();
+
+	byte v;
+	Common::String tmpStr = "";
+	while ((v = _data->readByte()) != 0)
+		tmpStr += (char)v;
+
+	_vm->_bubbleBox->calcBubble(tmpStr);
+	_vm->_bubbleBox->printBubble(tmpStr);
+
+	Common::Rect responseCoords[2];
+	responseCoords[0] = _vm->_bubbleBox->_bounds;
+	responseCoords[1] = Common::Rect(0, 0, 0, 0);
+	_vm->_fonts._printOrg.y = _vm->_bubbleBox->_bounds.bottom + 11;
+
+	findNull();
+
+	bool choice2Fl = false;
+	tmpStr = "";
+	while ((v = _data->readByte()) != 0)
+		tmpStr += (char)v;
+
+	Common::Rect termResponse2 = Common::Rect(-1, 0, 0, 0);
+	if (tmpStr.size() != 0) {
+		choice2Fl = true;
+		_vm->_bubbleBox->_bubblePtr = Common::String("RESPONSE 2").c_str();
+		_vm->_bubbleBox->calcBubble(tmpStr);
+		_vm->_bubbleBox->printBubble(tmpStr);
+		responseCoords[1] = _vm->_bubbleBox->_bounds;
+		_vm->_fonts._printOrg.y = _vm->_bubbleBox->_bounds.bottom + 11;
+	}
+
+	findNull();
+
+	bool choice3Fl = false;
+	tmpStr = "";
+	while ((v = _data->readByte()) != 0)
+		tmpStr += (char)v;
+
+	if (tmpStr.size() != 0) {
+		_vm->_bubbleBox->_bubblePtr = Common::String("RESPONSE 3").c_str();
+		_vm->_bubbleBox->calcBubble(tmpStr);
+		_vm->_bubbleBox->printBubble(tmpStr);
+		termResponse2 = _vm->_bubbleBox->_bounds;
+		_vm->_fonts._printOrg.y = _vm->_bubbleBox->_bounds.bottom + 11;
+	}
+
+	findNull();
+
+	int choice = -1;
+	do {
+		warning("TODO CHARLOOP");
+		_vm->_bubbleBox->_bubblePtr = _vm->_bubbleBox->_bubbleTitle.c_str();
+		if (_vm->_events->_leftButton) {
+			if (_vm->_events->_mouseRow >= 22) {
+				_vm->_events->debounceLeft();
+				int x = _vm->_events->_mousePos.x;
+				for (int i = 0; i < 7; i++) {
+					if ((x >= cMouse->x) && (x < cMouse->y)) {
+						choice = i;
+						break;
+					}
+				}
+			} else {
+				_vm->_events->debounceLeft();
+				choice = checkMouseBox1(responseCoords);
+			}
+		}
+	} while ((choice == -1) || ((choice == 2) && choice3Fl));
+	
+	_choice = choice + 1;
+	_vm->_bubbleBox->clearBubbles();
+}
+
 void Scripts::CMDWAIT() { error("TODO CMDWAIT"); }
 
 void Scripts::cmdSetConPos() {
@@ -487,7 +591,12 @@ void Scripts::cmdClearBlock() {
 	_vm->_screen->restoreBlock();
 }
 
-void Scripts::CMDLOADSOUND() { error("TODO CMDLOADSOUND"); }
+void Scripts::cmdLoadSound() {
+	int idx = _data->readSint16LE();
+	_vm->_sound->_soundTable[0]._data = _vm->_files->loadFile(_vm->_extraCells[idx]._vidSTable, _vm->_extraCells[idx]._vidSTable1);
+	_vm->_sound->_soundPriority[0] = 1;
+}
+
 void Scripts::CMDFREESOUND() { error("TODO CMDFREESOUND"); }
 void Scripts::CMDSETVIDSND() { error("TODO CMDSETVIDSND"); }
 void Scripts::CMDPLAYVIDSND() { error("TODO CMDPLAYVIDSND"); }
diff --git a/engines/access/scripts.h b/engines/access/scripts.h
index 5f84941..6941c04 100644
--- a/engines/access/scripts.h
+++ b/engines/access/scripts.h
@@ -43,6 +43,8 @@ protected:
 	virtual void executeSpecial(int commandIndex, int param1, int param2) = 0;
 	virtual void executeCommand(int commandIndex);
 
+	int checkMouseBox1(Common::Rect *rectArr);
+
 	/**
 	 * Print a given message to the screen in a bubble box
 	 */
@@ -103,14 +105,14 @@ protected:
 	void CMDCYCLE();
 	void cmdCharSpeak();
 	void cmdTexSpeak();
-	void CMDTEXCHOICE();
+	void cmdTexChoice();
 	void CMDWAIT();
 	void cmdSetConPos();
 	void CMDCHECKVFRAME();
 	void cmdJumpChoice();
 	void cmdReturnChoice();
 	void cmdClearBlock();
-	void CMDLOADSOUND();
+	void cmdLoadSound();
 	void CMDFREESOUND();
 	void CMDSETVIDSND();
 	void CMDPLAYVIDSND();


Commit: ad0be89459f318147f47e9c2bda29583a64592aa
    https://github.com/scummvm/scummvm/commit/ad0be89459f318147f47e9c2bda29583a64592aa
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-18T20:15:43-04:00

Commit Message:
ACCESS: Simplified surface creation, added drawing for scaled flipped images

Changed paths:
    engines/access/access.cpp
    engines/access/asurface.cpp
    engines/access/asurface.h
    engines/access/screen.cpp



diff --git a/engines/access/access.cpp b/engines/access/access.cpp
index 7d12ba5..ab58f8e 100644
--- a/engines/access/access.cpp
+++ b/engines/access/access.cpp
@@ -153,8 +153,8 @@ void AccessEngine::initialize() {
 	_screen = new Screen(this);
 	_sound = new SoundManager(this, _mixer);
 
-	_buffer1.create(g_system->getWidth() + TILE_WIDTH, g_system->getHeight(), Graphics::PixelFormat::createFormatCLUT8());
-	_buffer2.create(g_system->getWidth(), g_system->getHeight(), Graphics::PixelFormat::createFormatCLUT8());
+	_buffer1.create(g_system->getWidth() + TILE_WIDTH, g_system->getHeight());
+	_buffer2.create(g_system->getWidth(), g_system->getHeight());
 }
 
 Common::Error AccessEngine::run() {
@@ -272,7 +272,7 @@ void AccessEngine::plotList1() {
 				bounds.setWidth(bounds.width() / _scale);
 
 				if (ie._flags & 2) {
-					_buffer2.sPlotB(frame, Common::Point(bounds.left, bounds.top));
+					_buffer2.sPlotB(frame, destBounds);
 				} else {
 					_buffer2.sPlotF(frame, destBounds);
 				}
diff --git a/engines/access/asurface.cpp b/engines/access/asurface.cpp
index 9929227..746e8d0 100644
--- a/engines/access/asurface.cpp
+++ b/engines/access/asurface.cpp
@@ -59,7 +59,7 @@ SpriteResource::~SpriteResource() {
 SpriteFrame::SpriteFrame(AccessEngine *vm, Common::MemoryReadStream &stream, int frameSize) {
 	int xSize = stream.readUint16LE();
 	int ySize = stream.readUint16LE();
-	create(xSize, ySize, Graphics::PixelFormat::createFormatCLUT8());
+	create(xSize, ySize);
 	
 	// Empty surface
 	byte *data = (byte *)getPixels();
@@ -138,6 +138,10 @@ ASurface::~ASurface() {
 	_savedBlock.free();
 }
 
+void ASurface::create(uint16 width, uint16 height) {
+	Graphics::Surface::create(width, height, Graphics::PixelFormat::createFormatCLUT8());
+}
+
 void ASurface::clearBuffer() {
 	byte *pSrc = (byte *)getPixels();
 	Common::fill(pSrc, pSrc + w * h, 0);
@@ -301,8 +305,10 @@ void ASurface::copyTo(ASurface *dest, const Common::Rect &bounds) {
 	}
 }
 
-void ASurface::sPlotB(SpriteFrame *frame, const Common::Point &pt) {
-	frame->copyTo(this, pt);
+void ASurface::sPlotB(SpriteFrame *frame, const Common::Rect &bounds) {
+	ASurface flippedFrame;
+	frame->flipHorizontal(flippedFrame);
+	flippedFrame.copyTo(this, bounds);
 }
 
 void ASurface::sPlotF(SpriteFrame *frame, const Common::Rect &bounds) {
@@ -341,4 +347,16 @@ void ASurface::drawRect() {
 	Graphics::Surface::fillRect(Common::Rect(_orgX1, _orgY1, _orgX2, _orgY2), _lColor);
 }
 
+void ASurface::flipHorizontal(ASurface &dest) {
+	dest.create(this->w, this->h);
+	for (int y = 0; y < h; ++y) {
+		const byte *pSrc = (const byte *)getBasePtr(this->w - 1, y);
+		byte *pDest = (byte *)dest.getBasePtr(0, y);
+
+		for (int x = 0; x < w; ++x, --pSrc, ++pDest)
+			*pDest = *pSrc;
+	}
+}
+
+
 } // End of namespace Access
diff --git a/engines/access/asurface.h b/engines/access/asurface.h
index 400dd07..460f73d 100644
--- a/engines/access/asurface.h
+++ b/engines/access/asurface.h
@@ -39,6 +39,8 @@ class ASurface : public Graphics::Surface {
 private:
 	Graphics::Surface _savedBlock;
 	Common::Rect _savedBounds;
+
+	void flipHorizontal(ASurface &dest);
 public:
 	static int _leftSkip, _rightSkip;
 	static int _topSkip, _bottomSkip;
@@ -56,6 +58,8 @@ public:
 public:
 	virtual ~ASurface();
 
+	void create(uint16 width, uint16 height);
+
 	void clearBuffer();
 
 	void copyBuffer(Graphics::Surface *src) { copyFrom(*src); }
@@ -64,10 +68,16 @@ public:
 
 	void plotImage(SpriteResource *sprite, int frameNum, const Common::Point &pt);
 
-	void sPlotB(SpriteFrame *frame, const Common::Point &pt);
-
+	/**
+	 * Scaled draw frame
+	 */
 	void sPlotF(SpriteFrame *frame, const Common::Rect &bounds);
 
+	/**
+	 * Scaled flipped horizontal draw frame
+	 */
+	void sPlotB(SpriteFrame *frame, const Common::Rect &bounds);
+
 	void plotB(SpriteFrame *frame, const Common::Point &pt);
 
 	void copyBlock(ASurface *src, const Common::Rect &bounds);
diff --git a/engines/access/screen.cpp b/engines/access/screen.cpp
index 8e9b082..3092d7e 100644
--- a/engines/access/screen.cpp
+++ b/engines/access/screen.cpp
@@ -35,7 +35,7 @@ namespace Access {
 #define VGA_COLOR_TRANS(x) ((x) * 255 / 63)
 
 Screen::Screen(AccessEngine *vm) : _vm(vm) {
-	create(320, 200, Graphics::PixelFormat::createFormatCLUT8());
+	create(320, 200);
 	Common::fill(&_tempPalette[0], &_tempPalette[PALETTE_SIZE], 0);
 	Common::fill(&_manPal[0], &_manPal[0x60], 0);
 	Common::fill(&_scaleTable1[0], &_scaleTable1[256], 0);


Commit: c4a3770cfea0169b24ff46317febaa5ba82a5359
    https://github.com/scummvm/scummvm/commit/c4a3770cfea0169b24ff46317febaa5ba82a5359
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-18T22:15:23-04:00

Commit Message:
ACCESS: Bugfixes for walking

Changed paths:
    engines/access/player.cpp



diff --git a/engines/access/player.cpp b/engines/access/player.cpp
index 44dd0d2..13c99ee 100644
--- a/engines/access/player.cpp
+++ b/engines/access/player.cpp
@@ -245,8 +245,11 @@ void Player::walkUp() {
 
 	_playerDirection = UP;
 	int walkOff = _walkOffUp[_frame - _upWalkMin];
-	_rawYTempL = _vm->_screen->_scaleTable2[walkOff];
-	_rawYTemp = _rawPlayer.y - _vm->_screen->_scaleTable1[walkOff];
+	int tempL = _rawPlayerLow.y - _vm->_screen->_scaleTable2[walkOff];
+	_rawYTempL = (byte)tempL;
+	int yTemp = _rawPlayer.y - _vm->_screen->_scaleTable1[walkOff] - 
+		(tempL < 0 ? 1 : 0);
+	_rawYTemp = yTemp;
 	_rawXTemp = _rawPlayer.x;
 
 	if (_vm->_room->codeWalls()) {
@@ -273,8 +276,9 @@ void Player::walkDown() {
 
 	_playerDirection = DOWN;
 	int walkOff = _walkOffDown[_frame - _downWalkMin];
-	_rawYTempL = _vm->_screen->_scaleTable2[walkOff];
-	_rawYTemp = _rawPlayer.y - _vm->_screen->_scaleTable1[walkOff];
+	int tempL = _vm->_screen->_scaleTable2[walkOff] + _rawPlayerLow.y;
+	_rawYTempL = (byte)tempL;
+	_rawYTemp = _vm->_screen->_scaleTable1[walkOff] + _rawPlayer.y + (tempL >= 0x100 ? 1 : 0);
 	_rawXTemp = _rawPlayer.x;
 
 	if (_vm->_room->codeWalls()) {
@@ -288,8 +292,8 @@ void Player::walkDown() {
 			// TODO: si = 0?
 		}
 
-		if (++_frame > _upWalkMax)
-			_frame = _upWalkMin;
+		if (++_frame > _downWalkMax)
+			_frame = _downWalkMin;
 
 		plotCom(0);
 	}
@@ -309,8 +313,10 @@ void Player::walkLeft() {
 	}
 	if (flag) {
 		int walkOffset = _walkOffLeft[_frame - _sideWalkMin];
-		_rawTempL = _rawPlayerLow.x - _vm->_screen->_scaleTable2[walkOffset];
-		_rawXTemp = _rawPlayer.x - _vm->_screen->_scaleTable1[walkOffset];
+		int tempL = _rawPlayerLow.x - _vm->_screen->_scaleTable2[walkOffset];
+		_rawTempL = (byte)tempL;
+		_rawXTemp = _rawPlayer.x - _vm->_screen->_scaleTable1[walkOffset] -
+			(tempL < 0 ? 1 : 0);
 	} else {
 		_rawXTemp = _rawPlayer.x - _vm->_screen->_scaleTable1[_scrollConst];
 	}	
@@ -347,11 +353,13 @@ void Player::walkRight() {
 			_vm->_player->_scrollThreshold) > 0;
 	}
 	if (flag) {
-		int walkOffset = _walkOffLeft[_frame - _sideWalkMin];
-		_rawTempL = _rawPlayerLow.x - _vm->_screen->_scaleTable2[walkOffset];
-		_rawXTemp = _rawPlayer.x - _vm->_screen->_scaleTable1[walkOffset];
+		int walkOffset = _walkOffRight[_frame - _sideWalkMin];
+		int tempL = _rawPlayerLow.x + _vm->_screen->_scaleTable2[walkOffset];
+		_rawTempL = (byte)tempL;
+		_rawXTemp = _rawPlayer.x + _vm->_screen->_scaleTable1[walkOffset] -
+			(tempL >= 0x100 ? 1 : 0);
 	} else {
-		_rawXTemp = _rawPlayer.x - _vm->_screen->_scaleTable1[_scrollConst];
+		_rawXTemp = _rawPlayer.x + _vm->_screen->_scaleTable1[_scrollConst];
 	}
 	_rawYTemp = _rawPlayer.y;
 
@@ -379,7 +387,7 @@ void Player::walkUpLeft() {
 
 	_playerDirection = UPLEFT;
 
-	int walkOffset;
+	int walkOffset, tempL;
 	bool flag = _scrollEnd == 1;
 	if (!flag) {
 		calcPlayer();
@@ -388,15 +396,19 @@ void Player::walkUpLeft() {
 	}
 	if (flag) {
 		walkOffset = _walkOffUL[_frame - _diagUpWalkMin].x;
-		_rawTempL = _rawPlayerLow.x - _vm->_screen->_scaleTable2[walkOffset];
-		_rawXTemp = _rawPlayer.x - _vm->_screen->_scaleTable1[walkOffset];
+		tempL = _rawPlayerLow.x - _vm->_screen->_scaleTable2[walkOffset];
+		_rawTempL = (byte)tempL;
+		_rawXTemp = _rawPlayer.x - _vm->_screen->_scaleTable1[walkOffset] -
+			(tempL < 0 ? 1 : 0);
 	} else {
 		_rawXTemp = _rawPlayer.x - _vm->_screen->_scaleTable1[_scrollConst];
 	}
 	
 	walkOffset = _walkOffUL[_frame - _diagUpWalkMin].y;
-	_rawYTempL = _rawPlayerLow.y - _vm->_screen->_scaleTable2[walkOffset];
-	_rawYTemp = _rawPlayer.y - _vm->_screen->_scaleTable1[walkOffset];
+	tempL = _rawPlayerLow.y - _vm->_screen->_scaleTable2[walkOffset];
+	_rawYTempL = (byte)tempL;
+	_rawYTemp = _rawPlayer.y - _vm->_screen->_scaleTable1[walkOffset] -
+		(tempL < 0 ? 1 : 0);;
 
 	if (_vm->_room->codeWalls()) {
 		plotCom2();
@@ -426,7 +438,7 @@ void Player::walkDownLeft() {
 
 	_playerDirection = DOWNLEFT;
 
-	int walkOffset;
+	int walkOffset, tempL;
 	bool flag = _scrollEnd == 1;
 	if (!flag) {
 		calcPlayer();
@@ -435,15 +447,19 @@ void Player::walkDownLeft() {
 	}
 	if (flag) {
 		walkOffset = _walkOffDL[_frame - _sideWalkMin].x;
-		_rawTempL = _rawPlayerLow.x - _vm->_screen->_scaleTable2[walkOffset];
-		_rawXTemp = _rawPlayer.x - _vm->_screen->_scaleTable1[walkOffset];
+		tempL = _rawPlayerLow.x - _vm->_screen->_scaleTable2[walkOffset];
+		_rawTempL = (byte)tempL;
+		_rawXTemp = _rawPlayer.x - _vm->_screen->_scaleTable1[walkOffset] -
+			(tempL < 0 ? 1 : 0);
 	} else {
 		_rawXTemp = _rawPlayer.x - _vm->_screen->_scaleTable1[_scrollConst];
 	}
 
 	walkOffset = _walkOffDL[_frame - _diagDownWalkMin].y;
-	_rawYTempL = _rawPlayerLow.y - _vm->_screen->_scaleTable2[walkOffset];
-	_rawYTemp = _rawPlayer.y - _vm->_screen->_scaleTable1[walkOffset];
+	tempL = _rawPlayerLow.y + _vm->_screen->_scaleTable2[walkOffset];
+	_rawYTempL = (byte)tempL;
+	_rawYTemp = _rawPlayer.y + _vm->_screen->_scaleTable1[walkOffset] +
+		(tempL >= 0x100 ? 1 : 0);
 
 	if (_vm->_room->codeWalls()) {
 		plotCom2();
@@ -473,7 +489,7 @@ void Player::walkUpRight() {
 
 	_playerDirection = UPLEFT;
 
-	int walkOffset;
+	int walkOffset, tempL;
 	bool flag = _scrollEnd == 1;
 	if (!flag) {
 		calcPlayer();
@@ -482,15 +498,19 @@ void Player::walkUpRight() {
 	}
 	if (flag) {
 		walkOffset = _walkOffUR[_frame - _diagUpWalkMin].x;
-		_rawTempL = _rawPlayerLow.x - _vm->_screen->_scaleTable2[walkOffset];
-		_rawXTemp = _rawPlayer.x - _vm->_screen->_scaleTable1[walkOffset];
+		tempL = _rawPlayerLow.x + _vm->_screen->_scaleTable2[walkOffset];
+		_rawTempL = (byte)tempL;
+		_rawXTemp = _rawPlayer.x + _vm->_screen->_scaleTable1[walkOffset] +
+			(tempL >= 0x100 ? 1 : 0);
 	} else {
-		_rawXTemp = _rawPlayer.x - _vm->_screen->_scaleTable1[_scrollConst];
+		_rawXTemp = _rawPlayer.x + _vm->_screen->_scaleTable1[_scrollConst];
 	}
 
 	walkOffset = _walkOffUL[_frame - _diagUpWalkMin].y;
-	_rawYTempL = _rawPlayerLow.y - _vm->_screen->_scaleTable2[walkOffset];
-	_rawYTemp = _rawPlayer.y - _vm->_screen->_scaleTable1[walkOffset];
+	tempL = _rawPlayerLow.y - _vm->_screen->_scaleTable2[walkOffset];
+	_rawYTempL = (byte)tempL;
+	_rawYTemp = _rawPlayer.y - _vm->_screen->_scaleTable1[walkOffset] -
+		(tempL < 0 ? 1 : 0);
 
 	if (_vm->_room->codeWalls()) {
 		plotCom2();
@@ -520,7 +540,7 @@ void Player::walkDownRight() {
 
 	_playerDirection = DOWNRIGHT;
 
-	int walkOffset;
+	int walkOffset, tempL;
 	bool flag = _scrollEnd == 1;
 	if (!flag) {
 		calcPlayer();
@@ -529,16 +549,20 @@ void Player::walkDownRight() {
 	}
 	if (flag) {
 		walkOffset = _walkOffUR[_frame - _sideWalkMin].x;
-		_rawTempL = _rawPlayerLow.x - _vm->_screen->_scaleTable2[walkOffset];
-		_rawXTemp = _rawPlayer.x - _vm->_screen->_scaleTable1[walkOffset];
+		tempL = _rawPlayerLow.x + _vm->_screen->_scaleTable2[walkOffset];
+		_rawTempL = (byte)tempL;
+		_rawXTemp = _rawPlayer.x + _vm->_screen->_scaleTable1[walkOffset] +
+			(tempL >= 0x100 ? 1 : 0);
 	}
 	else {
-		_rawXTemp = _rawPlayer.x - _vm->_screen->_scaleTable1[_scrollConst];
+		_rawXTemp = _rawPlayer.x + _vm->_screen->_scaleTable1[_scrollConst];
 	}
 
 	walkOffset = _walkOffDR[_frame - _diagDownWalkMin].y;
-	_rawYTempL = _rawPlayerLow.y - _vm->_screen->_scaleTable2[walkOffset];
-	_rawYTemp = _rawPlayer.y - _vm->_screen->_scaleTable1[walkOffset];
+	tempL = _rawPlayerLow.y - _vm->_screen->_scaleTable2[walkOffset];
+	_rawYTempL = (byte)tempL;
+	_rawYTemp = _rawPlayer.y + _vm->_screen->_scaleTable1[walkOffset] +
+		(tempL >= 0x100 ? 1 : 0);
 
 	if (_vm->_room->codeWalls()) {
 		plotCom2();
@@ -565,8 +589,6 @@ void Player::walkDownRight() {
 void Player::checkMove() {
 	if (_playerMove) {
 		if (_xFlag == 0 && _yFlag == 0) {
-			// Figure out whether a greater horizontal movement than vertical
-			// movement will be required, or vice versa
 			int xp = (_playerOffset.x / 2) + _rawPlayer.x - _moveTo.x;
 			if (xp < 0)
 				xp = -xp;
@@ -574,7 +596,7 @@ void Player::checkMove() {
 			if (yp < 0)
 				yp = -yp;
 
-			if (xp > yp)
+			if (xp >= yp)
 				_xFlag = 1;
 			else
 				_yFlag = 1;
@@ -602,7 +624,7 @@ void Player::checkMove() {
 				}
 			}
 		} else if (_xFlag == 1) {
-			int xd = _playerOffset.x / 2 +  _rawPlayer.x - _moveTo.x;
+			int xd = _rawPlayer.x - _moveTo.x;
 			if ((xd >= 0 && xd <= -_leftDelta) || (xd < 0 && -xd <= -_leftDelta)) {
 				++_xFlag;
 


Commit: 8d45ad265d0da07a1d2541cb74140185a8847417
    https://github.com/scummvm/scummvm/commit/8d45ad265d0da07a1d2541cb74140185a8847417
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-18T22:53:58-04:00

Commit Message:
ACCESS: Fix walking right

Changed paths:
    engines/access/player.cpp



diff --git a/engines/access/player.cpp b/engines/access/player.cpp
index 13c99ee..72d6389 100644
--- a/engines/access/player.cpp
+++ b/engines/access/player.cpp
@@ -356,7 +356,7 @@ void Player::walkRight() {
 		int walkOffset = _walkOffRight[_frame - _sideWalkMin];
 		int tempL = _rawPlayerLow.x + _vm->_screen->_scaleTable2[walkOffset];
 		_rawTempL = (byte)tempL;
-		_rawXTemp = _rawPlayer.x + _vm->_screen->_scaleTable1[walkOffset] -
+		_rawXTemp = _rawPlayer.x + _vm->_screen->_scaleTable1[walkOffset] +
 			(tempL >= 0x100 ? 1 : 0);
 	} else {
 		_rawXTemp = _rawPlayer.x + _vm->_screen->_scaleTable1[_scrollConst];
@@ -377,7 +377,7 @@ void Player::walkRight() {
 		if (_frame > _sideWalkMax)
 			_frame = _sideWalkMin;
 
-		plotCom1();
+		plotCom(0);
 	}
 }
 


Commit: 992ea95cd796aafeb1a1c61fcf29d57c7ecba8db
    https://github.com/scummvm/scummvm/commit/992ea95cd796aafeb1a1c61fcf29d57c7ecba8db
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-08-19T07:48:00+02:00

Commit Message:
ACCESS: Implement two opcodes

Changed paths:
    engines/access/data.h
    engines/access/scripts.cpp
    engines/access/scripts.h



diff --git a/engines/access/data.h b/engines/access/data.h
index 8ba3c58..1d1f859 100644
--- a/engines/access/data.h
+++ b/engines/access/data.h
@@ -43,7 +43,7 @@ public:
 struct TimerEntry {
 	int _initTm;
 	int _timer;
-	bool _flag;
+	byte _flag;
 
 	TimerEntry() {
 		_initTm = _timer = 0;
diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp
index 1e5bbc8..b4a231c 100644
--- a/engines/access/scripts.cpp
+++ b/engines/access/scripts.cpp
@@ -102,8 +102,8 @@ void Scripts::executeCommand(int commandIndex) {
 		&Scripts::cmdSetTex, &Scripts::CMDNEWROOM, &Scripts::CMDCONVERSE, 
 		&Scripts::cmdCheckFrame, &Scripts::cmdCheckAnim, &Scripts::cmdSnd, 
 		&Scripts::cmdRetNeg, &Scripts::cmdRetPos, &Scripts::cmdCheckLoc, 
-		&Scripts::cmdSetAnim, &Scripts::cmdDispInv, &Scripts::CMDSETTIMER, 
-		&Scripts::CMDSETTIMER, &Scripts::CMDCHECKTIMER, &Scripts::cmdSetTravel,
+		&Scripts::cmdSetAnim, &Scripts::cmdDispInv, &Scripts::cmdSetTimer, 
+		&Scripts::cmdSetTimer, &Scripts::cmdCheckTimer, &Scripts::cmdSetTravel,
 		&Scripts::cmdSetTravel, &Scripts::CMDSETVID, &Scripts::CMDPLAYVID, 
 		&Scripts::cmdPlotImage, &Scripts::cmdSetDisplay, &Scripts::cmdSetBuffer, 
 		&Scripts::cmdSetScroll, &Scripts::CMDSAVERECT, &Scripts::CMDSAVERECT, 
@@ -355,8 +355,33 @@ void Scripts::cmdDispInv() {
 	_vm->_inventory->newDisplayInv();
 }
 
-void Scripts::CMDSETTIMER() { error("TODO CMDSETTIMER"); }
-void Scripts::CMDCHECKTIMER() { error("TODO CMDCHECKTIMER"); }
+void Scripts::cmdSetTimer() {
+	int idx = _data->readUint16LE();
+	int val = _data->readUint16LE();
+
+	++_vm->_timers[idx]._flag;
+	_vm->_timers[idx]._timer = val;
+	_vm->_timers[idx]._initTm = val;
+
+	_vm->_events->debounceLeft();
+	_vm->_events->zeroKeys();
+}
+
+void Scripts::cmdCheckTimer() {
+	int idx = _data->readUint16LE();
+
+	if ((idx == 9) && (_vm->_events->_keypresses.size() > 0)) {
+		_vm->_events->zeroKeys();
+		_vm->_timers[9]._timer = 0;
+		_vm->_timers[9]._flag = 0;
+	}
+
+	int val = _data->readUint16LE() & 0xFF;
+	if (_vm->_timers[idx]._flag == val)
+		cmdGoto();
+	else
+		_data->skip(2);
+}
 
 void Scripts::cmdSetTravel() {
 	if (_vm->_room->_selectCommand == 5)
diff --git a/engines/access/scripts.h b/engines/access/scripts.h
index 6941c04..40f667a 100644
--- a/engines/access/scripts.h
+++ b/engines/access/scripts.h
@@ -87,8 +87,8 @@ protected:
 	void cmdCheckLoc();
 	void cmdSetAnim();
 	void cmdDispInv();
-	void CMDSETTIMER();
-	void CMDCHECKTIMER();
+	void cmdSetTimer();
+	void cmdCheckTimer();
 	void cmdSetTravel();
 	void CMDSETVID();
 	void CMDPLAYVID();


Commit: b4f74b9b5e3b5eebcd695f8c07dd2d78e6a53a61
    https://github.com/scummvm/scummvm/commit/b4f74b9b5e3b5eebcd695f8c07dd2d78e6a53a61
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-08-20T01:46:46+02:00

Commit Message:
ACCESS: Use a variable delay of up to 20ms instead of a fix 50ms

Changed paths:
    engines/access/access.cpp
    engines/access/access.h
    engines/access/room.cpp



diff --git a/engines/access/access.cpp b/engines/access/access.cpp
index ab58f8e..7127123 100644
--- a/engines/access/access.cpp
+++ b/engines/access/access.cpp
@@ -99,6 +99,8 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc)
 	_rKeyFlag = 0;
 	_mapOffset = 0;
 	_screenVirtX = 0;
+	_lastTime = g_system->getMillis();
+	_curTime = 0;
 }
 
 AccessEngine::~AccessEngine() {
@@ -171,7 +173,16 @@ void AccessEngine::dummyLoop() {
 	// Dummy game loop
 	while (!shouldQuit()) {
 		_events->pollEvents();
-		g_system->delayMillis(50);
+
+		_curTime = g_system->getMillis();
+		// Process machine once every tick
+		while (_curTime - _lastTime < 20) {
+			g_system->delayMillis(5);
+			_curTime = g_system->getMillis();
+		}
+
+		_lastTime = _curTime;
+
 		g_system->updateScreen();
 
 		if (_events->_leftButton) {
diff --git a/engines/access/access.h b/engines/access/access.h
index 88b6c83..f775310 100644
--- a/engines/access/access.h
+++ b/engines/access/access.h
@@ -73,6 +73,8 @@ struct AccessGameDescription;
 
 class AccessEngine : public Engine {
 private:
+	uint32 _lastTime, _curTime;
+
 	/**
 	 * Handles basic initialisation
 	 */
diff --git a/engines/access/room.cpp b/engines/access/room.cpp
index 5e3a4d7..e40c6b7 100644
--- a/engines/access/room.cpp
+++ b/engines/access/room.cpp
@@ -79,10 +79,6 @@ void Room::doRoom() {
 				_vm->_screen->fadeIn();
 			}
 
-			// TODO: Game loop doesn't seem to have any delay. For now,
-			// introduce a slight delay here
-			_vm->_events->delay(50);
-
 			// Handle any events
 			_vm->_events->pollEvents();
 


Commit: 6066afb020b6213bc6f9ef5ba5c3d7171c695340
    https://github.com/scummvm/scummvm/commit/6066afb020b6213bc6f9ef5ba5c3d7171c695340
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-19T20:31:23-04:00

Commit Message:
ACCESS: Fix z ordering of sprites on the screen

Changed paths:
    engines/access/animation.cpp
    engines/access/animation.h
    engines/access/asurface.cpp
    engines/access/asurface.h
    engines/access/events.h
    engines/access/player.cpp
    engines/access/scripts.cpp



diff --git a/engines/access/animation.cpp b/engines/access/animation.cpp
index 3a7424f..d9a24e7 100644
--- a/engines/access/animation.cpp
+++ b/engines/access/animation.cpp
@@ -231,7 +231,7 @@ void Animation::setFrame1(AnimationFrame *frame) {
 		ie._spritesPtr = _vm->_objectsTable[part->_spritesIndex];
 		ie._frameNumber = part->_frameIndex;
 		ie._position = part->_position + _vm->_animation->_base;
-		ie._priority = part->_priority - ie._position.y;
+		ie._offsetY = part->_offsetY - ie._position.y;
 
 		_vm->_images.addToList(&ie);
 	}
@@ -271,7 +271,7 @@ AnimationFramePart::AnimationFramePart(Common::MemoryReadStream &stream) {
 	_frameIndex = stream.readByte();
 	_position.x = stream.readUint16LE();
 	_position.y = stream.readUint16LE();
-	_priority = stream.readUint16LE();
+	_offsetY = stream.readUint16LE();
 }
 
 /*------------------------------------------------------------------------*/
diff --git a/engines/access/animation.h b/engines/access/animation.h
index f70aa32..7e94f58 100644
--- a/engines/access/animation.h
+++ b/engines/access/animation.h
@@ -129,7 +129,7 @@ public:
 	int _spritesIndex;
 	int _frameIndex;
 	Common::Point _position;
-	int _priority;
+	int _offsetY;
 public:
 	AnimationFramePart(Common::MemoryReadStream &stream);
 };
diff --git a/engines/access/asurface.cpp b/engines/access/asurface.cpp
index 746e8d0..44686ab 100644
--- a/engines/access/asurface.cpp
+++ b/engines/access/asurface.cpp
@@ -85,14 +85,14 @@ SpriteFrame::~SpriteFrame() {
 ImageEntry::ImageEntry() {
 	_frameNumber = 0;
 	_spritesPtr = nullptr;
-	_priority = 0;
+	_offsetY = 0;
 	_flags = 0;
 }
 
 /*------------------------------------------------------------------------*/
 
 static bool sortImagesY(const ImageEntry &ie1, const ImageEntry &ie2) {
-	return ie1._priority < ie2._priority;
+	return (ie1._position.y + ie1._offsetY) < (ie2._position.y + ie2._offsetY);
 }
 
 void ImageEntryList::addToList(ImageEntry *ie) {
diff --git a/engines/access/asurface.h b/engines/access/asurface.h
index 460f73d..88e1561 100644
--- a/engines/access/asurface.h
+++ b/engines/access/asurface.h
@@ -116,7 +116,7 @@ class ImageEntry {
 public:
 	int _frameNumber;
 	SpriteResource *_spritesPtr;
-	int _priority;
+	int _offsetY;
 	Common::Point _position;
 	int _flags;
 public:
diff --git a/engines/access/events.h b/engines/access/events.h
index 4c052f9..f7a5e9c 100644
--- a/engines/access/events.h
+++ b/engines/access/events.h
@@ -35,7 +35,7 @@ enum CursorType {
 	CURSOR_USE, CURSOR_TAKE, CURSOR_CLIMB, CURSOR_TALK, CURSOR_HELP
 };
 
-#define GAME_FRAME_RATE 40
+#define GAME_FRAME_RATE 100
 #define GAME_FRAME_TIME (1000 / GAME_FRAME_RATE)
 
 class AccessEngine;
diff --git a/engines/access/player.cpp b/engines/access/player.cpp
index 72d6389..f3593d5 100644
--- a/engines/access/player.cpp
+++ b/engines/access/player.cpp
@@ -675,7 +675,7 @@ void Player::plotCom3() {
 	// Update the base ImageEntry fields for the player
 	_position.x = _rawPlayer.x;
 	_position.y = _rawPlayer.y - _playerOffset.y;
-	_priority = _playerOffset.y;
+	_offsetY = _playerOffset.y;
 	_spritesPtr = _playerSprites;
 	_frameNumber = _frame;
 
diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp
index b4a231c..57f5788 100644
--- a/engines/access/scripts.cpp
+++ b/engines/access/scripts.cpp
@@ -289,7 +289,7 @@ void Scripts::cmdSetTex() {
 	_vm->_player->_scrollFlag |= scrlTemp;
 
 	_vm->_player->_position = Common::Point(_vm->_player->_rawPlayer.x, _vm->_player->_rawPlayer.y - _vm->_player->_playerOffset.y);
-	_vm->_player->_priority = _vm->_player->_playerOffset.y;
+	_vm->_player->_offsetY = _vm->_player->_playerOffset.y;
 	_vm->_player->_spritesPtr = _vm->_player->_playerSprites;
 	_vm->_player->_frameNumber = _vm->_player->_frame;
 


Commit: 23a442443f22f63a32e602b4e796981dbb9ee561
    https://github.com/scummvm/scummvm/commit/23a442443f22f63a32e602b4e796981dbb9ee561
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-19T20:43:32-04:00

Commit Message:
ACCESS: Implemented cmdNewRoom opcode

Changed paths:
    engines/access/access.cpp
    engines/access/access.h
    engines/access/scripts.cpp
    engines/access/scripts.h



diff --git a/engines/access/access.cpp b/engines/access/access.cpp
index 7127123..6fcd64e 100644
--- a/engines/access/access.cpp
+++ b/engines/access/access.cpp
@@ -338,4 +338,10 @@ void AccessEngine::doLoadSave() {
 	error("TODO: doLoadSave");
 }
 
+void AccessEngine::freeChar() {
+	_scripts->freeScriptData();
+	_animation->clearTimers();
+	_animation->freeAnimationData();
+}
+
 } // End of namespace Access
diff --git a/engines/access/access.h b/engines/access/access.h
index f775310..8cb1e72 100644
--- a/engines/access/access.h
+++ b/engines/access/access.h
@@ -227,6 +227,8 @@ public:
 	void copyBF2Vid();
 
 	void doLoadSave();
+
+	void freeChar();
 };
 
 } // End of namespace Access
diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp
index 57f5788..3a3fb06 100644
--- a/engines/access/scripts.cpp
+++ b/engines/access/scripts.cpp
@@ -99,7 +99,7 @@ void Scripts::executeCommand(int commandIndex) {
 		&Scripts::cmdPrint, &Scripts::cmdRetPos, &Scripts::cmdAnim,
 		&Scripts::cmdSetFlag, &Scripts::cmdCheckFlag, &Scripts::cmdGoto, 
 		&Scripts::cmdSetInventory, &Scripts::cmdSetInventory, &Scripts::cmdCheckInventory, 
-		&Scripts::cmdSetTex, &Scripts::CMDNEWROOM, &Scripts::CMDCONVERSE, 
+		&Scripts::cmdSetTex, &Scripts::cmdNewRoom, &Scripts::CMDCONVERSE, 
 		&Scripts::cmdCheckFrame, &Scripts::cmdCheckAnim, &Scripts::cmdSnd, 
 		&Scripts::cmdRetNeg, &Scripts::cmdRetPos, &Scripts::cmdCheckLoc, 
 		&Scripts::cmdSetAnim, &Scripts::cmdDispInv, &Scripts::cmdSetTimer, 
@@ -296,7 +296,19 @@ void Scripts::cmdSetTex() {
 	_vm->_room->setWallCodes();
 }
 
-void Scripts::CMDNEWROOM() { error("TODO CMDNEWROOM"); }
+#define CURRENT_ROOM 0xFF
+
+void Scripts::cmdNewRoom() { 
+	int roomNumber = _data->readByte();
+	if (roomNumber != CURRENT_ROOM)
+		_vm->_player->_roomNumber = roomNumber;
+
+	_vm->_room->_function = 1;
+	_vm->freeChar();
+	_vm->_converseMode = 0;
+	cmdRetPos();
+}
+
 void Scripts::CMDCONVERSE() { error("TODO CMDCONVERSE"); }
 
 void Scripts::cmdCheckFrame() {
diff --git a/engines/access/scripts.h b/engines/access/scripts.h
index 40f667a..4b224c3 100644
--- a/engines/access/scripts.h
+++ b/engines/access/scripts.h
@@ -78,7 +78,7 @@ protected:
 	void cmdSetInventory();
 	void cmdCheckInventory();
 	void cmdSetTex();
-	void CMDNEWROOM();
+	void cmdNewRoom();
 	void CMDCONVERSE();
 	void cmdCheckFrame();
 	void cmdCheckAnim();


Commit: 70b8efacfbe4c314e73dcb946f16db4c49eab85b
    https://github.com/scummvm/scummvm/commit/70b8efacfbe4c314e73dcb946f16db4c49eab85b
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-08-20T23:04:04+02:00

Commit Message:
ACCESS: Finish moving timer flag from bool to byte based on the assembly, modify some comments and TODOs

Changed paths:
    engines/access/amazon/amazon_game.cpp
    engines/access/data.cpp
    engines/access/data.h
    engines/access/player.cpp
    engines/access/scripts.cpp



diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp
index 857d1b3..c7fa6a7 100644
--- a/engines/access/amazon/amazon_game.cpp
+++ b/engines/access/amazon/amazon_game.cpp
@@ -169,12 +169,12 @@ void AmazonEngine::setupGame() {
 	for (int i = 0; i < 32; ++i) {
 		TimerEntry te;
 		te._initTm = te._timer = (i < 8) ? TIMER_DEFAULTS[i] : 1;
-		te._flag = true;
+		te._flag = 1;
 
 		_timers.push_back(te);
 	}
 
-	// Miscellaenous
+	// Miscellaneous
 	_fonts._font2.load(FONT2_INDEX, FONT2_DATA);
 	_fonts._font6x6.load(FONT6x6_INDEX, FONT6x6_DATA);
 
diff --git a/engines/access/data.cpp b/engines/access/data.cpp
index 124bfbc..094272b 100644
--- a/engines/access/data.cpp
+++ b/engines/access/data.cpp
@@ -52,7 +52,7 @@ void TimerList::updateTimers() {
 		if (te._flag) {
 			if (!--te._timer) {
 				te._timer = te._initTm;
-				te._flag = false;
+				te._flag = 0;
 			}
 		}
 	}
diff --git a/engines/access/data.h b/engines/access/data.h
index 1d1f859..e7a6d13 100644
--- a/engines/access/data.h
+++ b/engines/access/data.h
@@ -47,7 +47,7 @@ struct TimerEntry {
 
 	TimerEntry() {
 		_initTm = _timer = 0;
-		_flag = false;
+		_flag = 0;
 	}
 };
 
diff --git a/engines/access/player.cpp b/engines/access/player.cpp
index f3593d5..420404b 100644
--- a/engines/access/player.cpp
+++ b/engines/access/player.cpp
@@ -97,7 +97,7 @@ void Player::load() {
 
 		_vm->_timers[8]._initTm = 7;
 		_vm->_timers[8]._timer = 7;
-		_vm->_timers[8]._flag = true;
+		++_vm->_timers[8]._flag;
 
 		_sideWalkMin = 0;
 		_sideWalkMax = 5;
@@ -191,7 +191,7 @@ void Player::walk() {
 		return;
 	}
 
-	_vm->_timers[0]._flag = true;
+	++_vm->_timers[0]._flag;
 	switch (_move) {
 	case UP:
 		_playerMove = false;
@@ -260,7 +260,7 @@ void Player::walkUp() {
 		
 		calcManScale();
 		if (_vm->_currentMan != 3 && (_frame == 17 || _frame == 21)) {
-			// TODO: si = 0?
+			warning("TODO: walkUp - si = 0?");
 		}
 
 		if (++_frame > _upWalkMax)
@@ -289,7 +289,7 @@ void Player::walkDown() {
 
 		calcManScale();
 		if (_vm->_currentMan != 3 && (_frame == 10 || _frame == 14)) {
-			// TODO: si = 0?
+			warning("TODO: walkDown - si = 0?");
 		}
 
 		if (++_frame > _downWalkMax)
@@ -330,7 +330,7 @@ void Player::walkLeft() {
 		++_frame;
 
 		if (_vm->_currentMan != 3 && (_frame == 1 || _frame == 5)) {
-			// TODO: si = 0?
+			warning("TODO: walkLeft - si = 0?");
 		}
 
 		if (_frame > _sideWalkMax)
@@ -371,7 +371,7 @@ void Player::walkRight() {
 		++_frame;
 
 		if (_vm->_currentMan != 3 && (_frame == 1 || _frame == 5)) {
-			// TODO: si = 0?
+			warning("TODO: walkRight - si = 0?");
 		}
 
 		if (_frame > _sideWalkMax)
@@ -422,7 +422,7 @@ void Player::walkUpLeft() {
 		calcManScale();
 
 		if (_vm->_currentMan != 3 && (_frame == 1 || _frame == 5)) {
-			// TODO: si = 0?
+			warning("TODO: walkUpLeft - si = 0?");
 		}
 
 		if (_frame > _diagUpWalkMax)
@@ -473,7 +473,7 @@ void Player::walkDownLeft() {
 		calcManScale();
 		
 		if (_vm->_currentMan != 3 && (_frame == 1 || _frame == 5)) {
-			// TODO: si = 0?
+			warning("TODO: walkDownLeft - si = 0?");
 		}
 
 		if (_frame > _diagDownWalkMax)
@@ -524,7 +524,7 @@ void Player::walkUpRight() {
 		calcManScale();
 
 		if (_vm->_currentMan != 3 && (_frame == 1 || _frame == 5)) {
-			// TODO: si = 0?
+			warning("TODO: walkUpRight - si = 0?");
 		}
 
 		if (_frame > _diagUpWalkMax)
@@ -576,7 +576,7 @@ void Player::walkDownRight() {
 		calcManScale();
 
 		if (_vm->_currentMan != 3 && (_frame == 1 || _frame == 5)) {
-			// TODO: si = 0?
+			warning("TODO: walkDownRight - si = 0?");
 		}
 
 		if (_frame > _diagDownWalkMax)
diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp
index 3a3fb06..70a8d6a 100644
--- a/engines/access/scripts.cpp
+++ b/engines/access/scripts.cpp
@@ -189,7 +189,7 @@ void Scripts::printString(const Common::String &msg) {
 	_vm->_fonts._printStart = Common::Point(20, 42);
 	_vm->_timers[PRINT_TIMER]._timer = 50;
 	_vm->_timers[PRINT_TIMER]._initTm = 50;
-	_vm->_timers[PRINT_TIMER]._flag = true;
+	++_vm->_timers[PRINT_TIMER]._flag;
 
 	// Display the text in a bubble, and wait for a keypress or mouse click
 	_vm->_bubbleBox->placeBubble(msg);


Commit: c7d4958984f199e4f3a6677056c9904d7f235fbe
    https://github.com/scummvm/scummvm/commit/c7d4958984f199e4f3a6677056c9904d7f235fbe
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-08-21T00:32:11+02:00

Commit Message:
ACCESS: Implement partially doEstablish

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



diff --git a/engines/access/access.cpp b/engines/access/access.cpp
index 6fcd64e..32835a0 100644
--- a/engines/access/access.cpp
+++ b/engines/access/access.cpp
@@ -217,18 +217,23 @@ void AccessEngine::freeInactiveData() {
 	_inactive = nullptr;
 }
 
-void AccessEngine::establish(int v1, int v2) {
+void AccessEngine::establish(int v1, int sub) {
 	_establishMode = 0;
 	_establishGroup = 0;
-	doEstablish(v1, v2);
+	doEstablish(v1, sub);
 }
 
-void AccessEngine::establishCenter(int v1, int v2) {
+void AccessEngine::establishCenter(int v1, int sub) {
 	_establishMode = 1;
-	doEstablish(v1, v2);
+	doEstablish(v1, sub);
 }
 
-void AccessEngine::doEstablish(int v1, int v2) {
+byte *AccessEngine::loadEstablish(int sub) {
+	warning("TODO: loadEstablish");
+	return nullptr;
+}
+
+void AccessEngine::doEstablish(int v1, int sub) {
 	_screen->forceFadeOut();
 	_screen->clearScreen();
 	_screen->setPanel(3);
@@ -241,7 +246,29 @@ void AccessEngine::doEstablish(int v1, int v2) {
 	_room->setIconPalette();
 	_screen->forceFadeIn();
 
-	warning("TODO: doEstablish");
+	_fonts._charSet._lo = 1;
+	_fonts._charSet._hi = 10;
+	_fonts._charFor._lo = 29;
+	_fonts._charFor._hi = 32;
+
+	_bubbleBox->_maxChars = 37;
+	_fonts._printOrg = _fonts._printStart = Common::Point(48, 35);
+	_eseg = loadEstablish(sub);
+	_et = sub;
+	warning("CHECKME: Use of di");
+	_printEnd = 155;
+	if (_txtPages == 0)
+		warning("TODO: printText();");
+	else
+		warning("TODO: speakText();");
+
+	_screen->forceFadeOut();
+	_screen->clearScreen();
+
+	free(_eseg);
+	if (_establishMode == 0) {
+		warning("TODO: init4Quads();");
+	}
 }
 
 void AccessEngine::plotList() {
diff --git a/engines/access/access.h b/engines/access/access.h
index 8cb1e72..5423354 100644
--- a/engines/access/access.h
+++ b/engines/access/access.h
@@ -87,7 +87,7 @@ private:
 
 	void dummyLoop();
 
-	void doEstablish(int v1, int v2);
+	void doEstablish(int v1, int sub);
 protected:
 	const AccessGameDescription *_gameDescription;
 	Common::RandomSource _randomSource;
@@ -156,6 +156,11 @@ public:
 	int _scaleI;
 	bool _scaleFlag;
 
+	byte *_eseg;
+	int _et;
+	int _printEnd;
+	int _txtPages;
+
 	// Fields that are included in savegames
 	int _conversation;
 	int _currentMan;
@@ -211,9 +216,11 @@ public:
 	 */
 	void freeInactiveData();
 
-	void establish(int v1, int v2);
+	byte *AccessEngine::loadEstablish(int sub);
+
+	void establish(int v1, int sub);
 
-	void establishCenter(int v1, int v2);
+	void establishCenter(int v1, int sub);
 
 	void plotList();
 	void plotList1();


Commit: 5870b18e175b8beee29654978d711d94ad92ddf5
    https://github.com/scummvm/scummvm/commit/5870b18e175b8beee29654978d711d94ad92ddf5
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-20T20:02:17-04:00

Commit Message:
ACCESS: Fix for collision detection

Changed paths:
    engines/access/player.cpp
    engines/access/room.cpp



diff --git a/engines/access/player.cpp b/engines/access/player.cpp
index 420404b..063aa76 100644
--- a/engines/access/player.cpp
+++ b/engines/access/player.cpp
@@ -624,7 +624,7 @@ void Player::checkMove() {
 				}
 			}
 		} else if (_xFlag == 1) {
-			int xd = _rawPlayer.x - _moveTo.x;
+			int xd = (_playerOffset.x / 2) + _rawPlayer.x - _moveTo.x;
 			if ((xd >= 0 && xd <= -_leftDelta) || (xd < 0 && -xd <= -_leftDelta)) {
 				++_xFlag;
 
diff --git a/engines/access/room.cpp b/engines/access/room.cpp
index e40c6b7..e7008c5 100644
--- a/engines/access/room.cpp
+++ b/engines/access/room.cpp
@@ -593,7 +593,7 @@ int Room::calcLR(int yp) {
 
 	int rem = (yv % yd) << 1;
 	yv /= yd;
-	if (rem >= yd)
+	if (rem >= yd || rem < 0)
 		++yv;
 
 	return yv + screen._orgX1;
@@ -607,7 +607,7 @@ int Room::calcUD(int xp) {
 
 	int rem = (xv % xd) << 1;
 	xv /= xd;
-	if (rem >= xd)
+	if (rem >= xd || rem < 0)
 		++xv;
 
 	return xv + screen._orgY1;
@@ -638,7 +638,8 @@ bool Room::codeWalls() {
 			if ((player._rawYTemp >= screen._orgY1) &&
 					(player._rawYTemp <= screen._orgY2)) {
 				jf._wallCode |= (calcLR(player._rawYTemp) - player._rawXTemp) < 0 ? 2 : 1;
-				jf._wallCode1 |= (calcLR(player._rawYTemp) - player._playerOffset.x) < 0 ? 2 : 1;
+				jf._wallCode1 |= (calcLR(player._rawYTemp) - 
+					(player._rawXTemp + player._playerOffset.x)) < 0 ? 2 : 1;
 			}
 		}
 


Commit: 4e5eb04e47c96f98cdc6519ae79b908efc9888e7
    https://github.com/scummvm/scummvm/commit/4e5eb04e47c96f98cdc6519ae79b908efc9888e7
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-20T20:22:35-04:00

Commit Message:
ACCESS: Fix freeing player sprites when the scene changes

Changed paths:
    engines/access/animation.cpp
    engines/access/player.cpp
    engines/access/room.cpp
    engines/access/room.h
    engines/access/scripts.cpp



diff --git a/engines/access/animation.cpp b/engines/access/animation.cpp
index d9a24e7..b286237 100644
--- a/engines/access/animation.cpp
+++ b/engines/access/animation.cpp
@@ -293,9 +293,6 @@ void AnimationManager::freeAnimationData() {
 }
 
 void AnimationManager::clearTimers() {
-	for (uint i = 0; i < _animationTimers.size(); ++i)
-		delete _animationTimers[i];
-
 	_animationTimers.clear();
 }
 
diff --git a/engines/access/player.cpp b/engines/access/player.cpp
index 063aa76..e85b68a 100644
--- a/engines/access/player.cpp
+++ b/engines/access/player.cpp
@@ -155,8 +155,7 @@ void Player::load() {
 }
 
 void Player::loadSprites(const Common::String &name) {
-	delete _playerSprites1;
-	_playerSprites = nullptr;
+	freeSprites();
 
 	const byte *data = _vm->_files->loadFile(name);
 	_playerSprites1 = new SpriteResource(_vm, data, _vm->_files->_filesize,
@@ -164,7 +163,8 @@ void Player::loadSprites(const Common::String &name) {
 }
 
 void Player::freeSprites() {
-	delete _playerSprites;
+	delete _playerSprites1;
+	_playerSprites1 = nullptr;
 	_playerSprites = nullptr;
 }
 
diff --git a/engines/access/room.cpp b/engines/access/room.cpp
index e7008c5..f45ffe7 100644
--- a/engines/access/room.cpp
+++ b/engines/access/room.cpp
@@ -88,17 +88,17 @@ void Room::doRoom() {
 			doCommands();
 
 			// DOROOMFLASHBACK jump point
-			if (_function == 1) {
+			if (_function == FN_CLEAR1) {
 				clearRoom();
 				break;
-			} else if (_function == 2) {
+			} else if (_function == FN_CLEAR2) {
 				clearRoom();
 				return;
-			} else if (_function == 3) {
+			} else if (_function == FN_RELOAD) {
 				reloadRoom1();
 				reloadFlag = true;
 				break;
-			} else if (_function == 4) {
+			} else if (_function == FN_BREAK) {
 				break;
 			}
 
@@ -108,7 +108,7 @@ void Room::doRoom() {
 				_function = 0;
 				roomLoop();
 
-				if (_function == 1) {
+				if (_function == FN_CLEAR1) {
 					clearRoom();
 					break;
 				} else {
@@ -122,7 +122,7 @@ void Room::doRoom() {
 				_function = 0;
 				roomLoop();
 
-				if (_function == 1) {
+				if (_function == FN_CLEAR1) {
 					clearRoom();
 					break;
 				} else {
diff --git a/engines/access/room.h b/engines/access/room.h
index c76bd70..9b3f922 100644
--- a/engines/access/room.h
+++ b/engines/access/room.h
@@ -58,6 +58,8 @@ public:
 	}
 };
 
+enum Function { FN_NONE = 0, FN_CLEAR1 = 1, FN_CLEAR2 = 2, FN_RELOAD = 3, FN_BREAK = 4 };
+
 class Room: public Manager {
 private:
 	void roomLoop();
diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp
index 70a8d6a..f687958 100644
--- a/engines/access/scripts.cpp
+++ b/engines/access/scripts.cpp
@@ -303,7 +303,7 @@ void Scripts::cmdNewRoom() {
 	if (roomNumber != CURRENT_ROOM)
 		_vm->_player->_roomNumber = roomNumber;
 
-	_vm->_room->_function = 1;
+	_vm->_room->_function = FN_CLEAR1;
 	_vm->freeChar();
 	_vm->_converseMode = 0;
 	cmdRetPos();


Commit: a8dd2defaa3a6680102e230d091d705d54f87d7e
    https://github.com/scummvm/scummvm/commit/a8dd2defaa3a6680102e230d091d705d54f87d7e
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-20T20:27:52-04:00

Commit Message:
ACCESS: Added scene debugger command

Changed paths:
    engines/access/debugger.cpp
    engines/access/debugger.h



diff --git a/engines/access/debugger.cpp b/engines/access/debugger.cpp
index e92e340..d20b5d3 100644
--- a/engines/access/debugger.cpp
+++ b/engines/access/debugger.cpp
@@ -28,6 +28,42 @@ namespace Access {
 
 Debugger::Debugger(AccessEngine *vm) : GUI::Debugger(), _vm(vm) {
 	registerCmd("continue",		WRAP_METHOD(Debugger, cmdExit));
+	registerCmd("scene", WRAP_METHOD(Debugger, Cmd_LoadScene));
+}
+
+static int strToInt(const char *s) {
+	if (!*s)
+		// No string at all
+		return 0;
+	else if (toupper(s[strlen(s) - 1]) != 'H')
+		// Standard decimal string
+		return atoi(s);
+
+	// Hexadecimal string
+	uint tmp = 0;
+	int read = sscanf(s, "%xh", &tmp);
+	if (read < 1)
+		error("strToInt failed on string \"%s\"", s);
+	return (int)tmp;
+}
+
+bool Debugger::Cmd_LoadScene(int argc, const char **argv) {
+	if (argc != 2) {
+		debugPrintf("Current scene is: %d\n", _vm->_player->_roomNumber);
+		debugPrintf("Usage: %s <scene number>\n", argv[0]);
+		return true;
+	}
+	else {
+		_vm->_player->_roomNumber = strToInt(argv[1]);
+
+		_vm->_room->_function = FN_CLEAR1;
+		_vm->freeChar();
+		_vm->_converseMode = 0;
+		_vm->_scripts->_endFlag = true;
+		_vm->_scripts->_returnCode = 0;
+
+		return false;
+	}
 }
 
 } // End of namespace Access
diff --git a/engines/access/debugger.h b/engines/access/debugger.h
index dcf49c4..6c8424d 100644
--- a/engines/access/debugger.h
+++ b/engines/access/debugger.h
@@ -34,6 +34,7 @@ class Debugger : public GUI::Debugger {
 private:
 	AccessEngine *_vm;
 protected:
+	bool Cmd_LoadScene(int argc, const char **argv);
 public:
 public:
 	Debugger(AccessEngine *vm);


Commit: afc41c7eecc5c8d6b410534b5c66aa02807d11cb
    https://github.com/scummvm/scummvm/commit/afc41c7eecc5c8d6b410534b5c66aa02807d11cb
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-20T23:36:57-04:00

Commit Message:
ACCESS: Added initial resources and detection entry for Martian Memorandum

Changed paths:
  A engines/access/martian/martian_game.cpp
  A engines/access/martian/martian_game.h
  A engines/access/martian/martian_resources.cpp
  A engines/access/martian/martian_resources.h
  A engines/access/martian/martian_room.cpp
  A engines/access/martian/martian_room.h
  A engines/access/martian/martian_scripts.cpp
  A engines/access/martian/martian_scripts.h
    engines/access/access.h
    engines/access/amazon/amazon_game.cpp
    engines/access/data.h
    engines/access/detection.cpp
    engines/access/detection_tables.h
    engines/access/files.cpp
    engines/access/inventory.cpp
    engines/access/module.mk



diff --git a/engines/access/access.h b/engines/access/access.h
index 5423354..2185916 100644
--- a/engines/access/access.h
+++ b/engines/access/access.h
@@ -59,7 +59,7 @@ namespace Access {
 
 enum {
 	GType_Amazon = 1,
-	GType_MeanStreets = 2,
+	GType_MartianMemorandum = 2,
 	GType_Noctropolis = 3
 };
 
diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp
index c7fa6a7..286a7126 100644
--- a/engines/access/amazon/amazon_game.cpp
+++ b/engines/access/amazon/amazon_game.cpp
@@ -175,8 +175,8 @@ void AmazonEngine::setupGame() {
 	}
 
 	// Miscellaneous
+	_fonts._font1.load(FONT6x6_INDEX, FONT6x6_DATA);
 	_fonts._font2.load(FONT2_INDEX, FONT2_DATA);
-	_fonts._font6x6.load(FONT6x6_INDEX, FONT6x6_DATA);
 
 	// Set player room and position
 	_player->_roomNumber = 4;
diff --git a/engines/access/data.h b/engines/access/data.h
index e7a6d13..1601c68 100644
--- a/engines/access/data.h
+++ b/engines/access/data.h
@@ -145,7 +145,7 @@ public:
 	Common::Point _printOrg;
 	Common::Point _printStart;
 	int _printMaxX;
-	Font _font6x6;
+	Font _font1;
 	Font _font2;
 public:
 	FontManager();
diff --git a/engines/access/detection.cpp b/engines/access/detection.cpp
index 47f7af6..dd75b28 100644
--- a/engines/access/detection.cpp
+++ b/engines/access/detection.cpp
@@ -23,6 +23,7 @@
 
 #include "access/access.h"
 #include "access/amazon/amazon_game.h"
+#include "access/martian/martian_game.h"
 
 #include "base/plugins.h"
 #include "common/savefile.h"
@@ -73,6 +74,7 @@ Common::Platform AccessEngine::getPlatform() const {
 static const PlainGameDescriptor AccessGames[] = {
 	{"Access", "Access"},
 	{"amazon", "Amazon: Guardians of Eden"},
+	{ "martian", "Martian Memorandum"},
 	{0, 0}
 };
 
@@ -123,6 +125,9 @@ bool AccessMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGa
 		case Access::GType_Amazon:
 			*engine = new Access::Amazon::AmazonEngine(syst, gd);
 			break;
+		case Access::GType_MartianMemorandum:
+			*engine = new Access::Martian::MartianEngine(syst, gd);
+			break;
 		default:
 			error("Unknown game");
 		}
diff --git a/engines/access/detection_tables.h b/engines/access/detection_tables.h
index ad962f4..6a281a7 100644
--- a/engines/access/detection_tables.h
+++ b/engines/access/detection_tables.h
@@ -59,6 +59,24 @@ static const AccessGameDescription gameDescriptions[] = {
 		0
 	},
 
+	{
+		// Martian Memorandum
+		{
+			"martian",
+			nullptr,
+			{
+				{ "r00.ap", 0, "af98db5ee7f9ef86c6b1f43187a3691b", 31 },
+				AD_LISTEND
+			},
+			Common::EN_ANY,
+			Common::kPlatformDOS,
+			ADGF_NO_FLAGS,
+			GUIO1(GUIO_NONE)
+		},
+		GType_MartianMemorandum,
+		0
+	},
+
 	{ AD_TABLE_END_MARKER, 0, 0 }
 };
 
diff --git a/engines/access/files.cpp b/engines/access/files.cpp
index 1ebc2fa..970b0b9 100644
--- a/engines/access/files.cpp
+++ b/engines/access/files.cpp
@@ -22,6 +22,7 @@
 
 #include "access/files.h"
 #include "access/amazon/amazon_resources.h"
+#include "access/martian/martian_resources.h"
 #include "access/access.h"
 
 namespace Access {
@@ -31,6 +32,9 @@ FileManager::FileManager(AccessEngine *vm): _vm(vm) {
 	case GType_Amazon:
 		_filenames = &Amazon::FILENAMES[0];
 		break;
+	case GType_MartianMemorandum:
+		_filenames = &Martian::FILENAMES[0];
+		break;
 	default:
 		error("Unknown game");
 	}
diff --git a/engines/access/inventory.cpp b/engines/access/inventory.cpp
index 15668b0..e90ad62 100644
--- a/engines/access/inventory.cpp
+++ b/engines/access/inventory.cpp
@@ -23,6 +23,7 @@
 #include "access/inventory.h"
 #include "access/access.h"
 #include "access/amazon/amazon_resources.h"
+#include "access/martian/martian_resources.h"
 
 namespace Access {
 
@@ -35,11 +36,16 @@ InventoryManager::InventoryManager(AccessEngine *vm) : Manager(vm) {
 	_startAboutItem = 0;
 	_startTravelItem = 0;
 
-	const char *const *names = Amazon::INVENTORY_NAMES;
+	const char *const *names;
 	switch (vm->getGameID()) {
 	case GType_Amazon:
+		names = Amazon::INVENTORY_NAMES;
 		_inv.resize(85);
 		break;
+	case GType_MartianMemorandum:
+		names = Martian::INVENTORY_NAMES;
+		_inv.resize(54);
+		break;
 	default:
 		error("Unknown game");
 	}
diff --git a/engines/access/martian/martian_game.cpp b/engines/access/martian/martian_game.cpp
new file mode 100644
index 0000000..f087b56
--- /dev/null
+++ b/engines/access/martian/martian_game.cpp
@@ -0,0 +1,172 @@
+/* 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 "access/resources.h"
+#include "access/martian/martian_game.h"
+#include "access/martian/martian_resources.h"
+#include "access/martian/martian_room.h"
+#include "access/martian/martian_scripts.h"
+#include "access/amazon/amazon_resources.h"
+
+namespace Access {
+
+namespace Martian {
+
+MartianEngine::MartianEngine(OSystem *syst, const AccessGameDescription *gameDesc) :
+		AccessEngine(syst, gameDesc) {
+}
+
+MartianEngine::~MartianEngine() {
+}
+
+void MartianEngine::playGame() {
+	// Do introduction
+	doIntroduction();
+	if (shouldQuit())
+		return;
+
+	// Setup the game
+	setupGame();
+
+	_screen->clearScreen();
+	_screen->setPanel(0);
+	_screen->forceFadeOut();
+
+	_events->showCursor();
+
+	// Setup and execute the room
+	_room = new MartianRoom(this);
+	_scripts = new MartianScripts(this);
+	_room->doRoom();
+}
+
+void MartianEngine::doIntroduction() {
+	_screen->setInitialPalettte();
+	_events->setCursor(CURSOR_ARROW);
+	_events->showCursor();
+	_screen->setPanel(0);
+
+	// TODO: Worry about implementing full intro sequence later
+	return;
+
+	doTitle();
+	if (shouldQuit())
+		return;
+
+	if (!_skipStart) {
+		_screen->setPanel(3);
+		doOpening();
+		if (shouldQuit())
+			return;
+
+		if (!_skipStart) {
+			doTent();
+			if (shouldQuit())
+				return;
+		}
+	}
+
+	doTitle();
+}
+
+void MartianEngine::doTitle() {
+	_screen->setDisplayScan();
+	_destIn = &_buffer2;
+
+	_screen->forceFadeOut();
+	_events->hideCursor();
+
+	_sound->queueSound(0, 98, 30);
+	_sound->_soundPriority[0] = 1;
+
+	_screen->_loadPalFlag = false;
+	_files->loadScreen(0, 3);
+	
+	_buffer2.copyFrom(*_screen);
+	_buffer1.copyFrom(*_screen);
+	_screen->forceFadeIn();
+	_sound->playSound(1);
+
+	byte *spriteData = _files->loadFile(0, 2);
+	_objectsTable[0] = new SpriteResource(this, spriteData, _files->_filesize,
+		DisposeAfterUse::YES);
+
+	_sound->playSound(1);
+
+	_screen->_loadPalFlag = false;
+	_files->loadScreen(0, 4);
+	_sound->playSound(1);
+
+	_buffer2.copyFrom(*_screen);
+	_buffer1.copyFrom(*_screen);
+	_sound->playSound(1);
+
+	const int COUNTDOWN[6] = { 2, 0x80, 1, 0x7d, 0, 0x87 };
+	for (_pCount = 0; _pCount < 3; ++_pCount) {
+		_buffer2.copyFrom(_buffer1);
+		int id = READ_LE_UINT16(COUNTDOWN + _pCount * 4);
+		int xp = READ_LE_UINT16(COUNTDOWN + _pCount * 4 + 2);
+		_screen->plotImage(_objectsTable[0], id, Common::Point(xp, 71));
+	}
+	// TODO: More to do
+
+	delete _objectsTable[0];
+}
+
+void MartianEngine::doOpening() {
+	warning("TODO doOpening");
+}
+
+void MartianEngine::doTent() {
+	warning("TODO doTent");
+}
+
+void MartianEngine::setupGame() {
+
+	// Setup timers
+	const int TIMER_DEFAULTS[] = { 4, 10, 8, 1, 1, 1, 1, 2 };
+	for (int i = 0; i < 32; ++i) {
+		TimerEntry te;
+		te._initTm = te._timer = (i < 8) ? TIMER_DEFAULTS[i] : 1;
+		te._flag = 1;
+
+		_timers.push_back(te);
+	}
+
+	// Miscellaneous
+	// TODO: Replace with Martian fonts when located
+	_fonts._font1.load(Amazon::FONT6x6_INDEX, Amazon::FONT6x6_DATA);
+	_fonts._font2.load(Amazon::FONT2_INDEX, Amazon::FONT2_DATA);
+
+	// Set player room and position
+	_player->_roomNumber = 7;
+	_player->_playerX = _player->_rawPlayer.x = TRAVEL_POS[_player->_roomNumber][0];
+	_player->_playerY = _player->_rawPlayer.y = TRAVEL_POS[_player->_roomNumber][1];
+}
+
+void MartianEngine::drawHelp() {
+	error("TODO: drawHelp");
+}
+
+} // End of namespace Martian
+
+} // End of namespace Access
diff --git a/engines/access/martian/martian_game.h b/engines/access/martian/martian_game.h
new file mode 100644
index 0000000..29fdd1b
--- /dev/null
+++ b/engines/access/martian/martian_game.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.
+ *
+ */
+
+#ifndef ACCESS_MARTIAN_GAME_H
+#define ACCESS_MARTIAN_GAME_H
+
+#include "access/access.h"
+
+namespace Access {
+
+namespace Martian {
+
+class MartianEngine : public AccessEngine {
+private:
+	bool _skipStart;
+
+	/**
+	 * Do the game introduction
+	 */
+	void doIntroduction();
+
+	/**
+	 * Do title sequence
+	 */
+	void doTitle();
+
+	/**
+	 * Do opening sequence
+	 */
+	void doOpening();
+
+	/**
+	 * Do tent scene of introduction
+	 */
+	void doTent();
+
+	/**
+	 * Setup variables for the game
+	 */
+	void setupGame();
+
+protected:
+	/**
+	 * Play the game
+	 */
+	virtual void playGame();
+public:
+public:
+	MartianEngine(OSystem *syst, const AccessGameDescription *gameDesc);
+
+	virtual ~MartianEngine();
+
+	void drawHelp();
+};
+
+} // End of namespace Martian
+
+} // End of namespace Access
+
+#endif /* ACCESS_MARTIAN_GAME_H */
diff --git a/engines/access/martian/martian_resources.cpp b/engines/access/martian/martian_resources.cpp
new file mode 100644
index 0000000..6e881f3
--- /dev/null
+++ b/engines/access/martian/martian_resources.cpp
@@ -0,0 +1,649 @@
+/* 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 "access/martian/martian_resources.h"
+#include "access/access.h"
+
+namespace Access {
+
+namespace Martian {
+
+const char *const FILENAMES[] = {
+	"R00.AP", "R01.AP", "R02.AP", "R03.AP", "R04.AP", "R05.AP", "R06.AP", "R07.AP",
+	"R08.AP", "R09.AP", "R10.AP", "R11.AP", "R12.AP", "R13.AP", "R14.AP", "R15.AP",
+	"R16.AP", "R17.AP", "R18.AP", "R19.AP", "R20.AP", "R21.AP", "R22.AP", "R23.AP",
+	"R24.AP", "R25.AP", "R26.AP", "R27.AP", "R28.AP", "R29.AP", "R30.AP", "R31.AP",
+	"R32.AP", "R34.AP", "R35.AP", "R36.AP", "R37.AP", "R38.AP", "R39.AP", "R40.AP",
+	"TITLE.AP","R42.AP","S01.AP", "R45.AP","SOUND.AP","MUSIC.AP","DEAD.AP","EST.AP",
+	"W02.AP", "C02.AP", "C05.AP", "C04.AP", "C10.AP", "C03.AP", "C07.AP", "LOVE.AP",
+	"CAFE.AP","C08.AP", "C18.AP", "C19.AP", "C21.AP", "C23.AP", "C12.AP", "C16.AP",
+	"CAFE1.AP","C05A.AP","C06.AP","C11.AP", "C13.AP", "C20.AP", "C16A.AP","C09.AP",
+	"R45.AP", "R46.AP", "R47.AP", "R48.AP", "R49.AP"
+};
+
+const byte MOUSE0[] = {
+	0, 0, 0, 0, 0, 2, 0xF7, 5, 0, 3, 0xF7, 0xF7, 5, 0, 3,
+	0xF7, 0xF7, 5, 0, 4, 0xF7, 0xF7, 0xF7, 5, 0, 4, 0xF7,
+	0xF7, 0xF7, 5, 0, 5, 0xF7, 0xF7, 0xF7, 0xF7, 5, 0, 5,
+	0xF7, 0xF7, 0xF7, 0xF7, 5, 0, 6, 0xF7, 0xF7, 0xF7, 0xF7,
+	0xF7, 5, 0, 6, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 5, 0, 7,
+	0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 5, 0, 6, 0xF7, 0xF7,
+	0xF7, 0xF7, 0xF7, 5, 0, 5, 0xF7, 0xF7, 0xF7, 0xF7, 5,
+	2, 3, 0xF7, 0xF7, 5, 3, 3, 0xF7, 0xF7, 5, 3, 3, 0xF7,
+	0xF7, 5, 4, 2, 0xF7, 5
+};
+const byte MOUSE1[] = {
+	7, 0, 7, 0, 6, 1, 0xF7, 4, 5, 0xFF, 0xFF, 0, 0xFF, 0xFF,
+	3, 7, 0xFF, 0, 0, 0, 0, 0, 0xFF, 2, 9, 0xFF, 0, 0, 0,
+	0xF7, 0, 0, 0, 0xFF, 1, 11, 0xFF, 0, 0, 0, 0, 0, 0,
+	0, 0, 0, 0xFF, 1, 11, 0xFF, 0, 0, 0, 0, 0xF7, 0, 0,
+	0, 0, 0xFF, 0, 13, 0xF7, 0, 0, 0xF7, 0, 0xF7, 0, 0xF7,
+	0, 0xF7, 0, 0, 0xF7, 1, 11, 0xFF, 0, 0, 0, 0, 0xF7,
+	0, 0, 0, 0, 0xFF, 1, 11, 0xFF, 0, 0, 0, 0, 0, 0, 0,
+	0, 0, 0xFF, 2, 9, 0xFF, 0, 0, 0, 0xF7, 0, 0, 0, 0xFF,
+	3, 7, 0xFF, 0, 0, 0, 0, 0, 0xFF, 4, 5, 0xFF, 0xFF, 0,
+	0xFF, 0xFF, 6, 1, 0xF7, 0, 0, 0, 0, 0, 0
+};
+const byte MOUSE2[] = {
+	8, 0, 8, 0, 0, 0, 0, 0, 7, 2, 4, 5, 7, 2, 4, 5, 7, 2,
+	4, 5, 7, 2, 4, 5, 7, 2, 4, 5, 2, 12, 4, 4, 4, 4, 4,
+	0, 4, 4, 4, 4, 4, 5, 7, 2, 4, 5, 7, 2, 4, 5, 7, 2, 4,
+	5, 7, 2, 4, 5, 7, 2, 4, 5, 0, 0, 0, 0, 0, 0
+};
+const byte MOUSE3[] = {
+	0, 0, 0, 0, 0, 11, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
+	0, 12, 6, 7, 7, 7, 7, 7, 7, 7, 7, 6, 6, 5, 0, 12,
+	6, 7, 7, 7, 7, 7, 7, 7, 7, 6, 5, 5, 0, 12, 6, 6, 6,
+	6, 6, 6, 6, 6, 6, 6, 6, 5, 0, 12, 6, 6, 6, 6, 6, 5,
+	6, 6, 6, 6, 6, 5, 0, 12, 6, 6, 6, 6, 5, 0, 0, 6, 6,
+	6, 6, 5, 0, 12, 6, 6, 6, 6, 6, 0, 6, 6, 6, 6, 6, 5,
+	0, 12, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 0, 12,
+	6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 0, 12, 6, 6, 6,
+	6, 6, 5, 6, 6, 6, 6, 6, 5, 0, 12, 6, 6, 6, 6, 6, 5,
+	6, 6, 6, 6, 6, 5, 0, 12, 6, 6, 6, 6, 6, 6, 6, 6, 6,
+	6, 6, 5, 1, 11, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 0,
+	0, 0, 0, 0, 0
+};
+const byte *CURSORS[4] = { MOUSE0, MOUSE1, MOUSE2, MOUSE3 };
+
+const int TRAVEL_POS[][2] = {
+	{ -1, 0 },
+	{ 228, 117 },
+	{ 28, 98 },
+	{ 161, 140 },
+	{ 160, 116 },
+	{ 34, 119 },
+	{ 166, 105 },
+	{ 260, 126 },
+	{ 37, 107 },
+	{ 78, 139 },
+	{ 0, 0 },
+	{ 13, 112 },
+	{ 0, 0 },
+	{ 16, 122 },
+	{ 33, 126 },
+	{ 10, 160 },
+	{ 150, 102 },
+	{ 134, 160 },
+	{ 160, 76 },
+	{ 0, 0 },
+	{ 0, 0 },
+	{ 36, 116 },
+	{ 214, 113 },
+	{ 30, 127 },
+	{ 143, 131 },
+	{ 163, 103 },
+	{ 254, 106 },
+	{ 28, 161 },
+	{ 11, 164 },
+	{ 276, 134 },
+	{ 93, 118 },
+	{ 22, 150 },
+	{ 282, 156 },
+	{ 149, 92 },
+	{ 0, 0 },
+	{ 43, 410 },
+	{ 0, 0 },
+	{ 10, 136 },
+	{ 41, 100 },
+	{ 157, 97 },
+	{ -1, 5 },
+	{ -1, 4 },
+	{ -1, 10 },
+	{ -1, 7 },
+	{ -1, 3 },
+	{ -1, 8 },
+	{ -1, 6 },
+	{ -1, 20 },
+	{ -1, 18 },
+	{ -1, 19 },
+	{ -1, 21 }
+};
+
+const char *const INVENTORY_NAMES[] = {
+	"CAMERA", "LENS", "PHOTOS", "MAIL", "GUN", "CASH", "COMLINK", "AMMO",
+	"LOCKPICK KIT", "EARRING", "RECIEPTS", "PAPER", "LADDER", "BOOTS",
+	"DOCUMENTS", "KNIFE", "DAGGER", "KEYS", "ROCK", "LOG", "SHOVEL",
+	"STONE", "REMOTE CONTROL", "FOOD AND WATER", "DOOR CARD KEY",
+	"FLASHLIGHT", "INTERLOCK KEY", "TOOLS", "REBREATHER", "JET PACK",
+	"ROD", "HCL2", "SAFE CARD KEY", "TUNING FORK", "STONE", "ROSE",
+	"KEY", "NOTE", "ALLEN WRENCH", "HOVER BOARD", "BLUE PRINTS",
+	"LETTER", "MEMORANDUM", "MARKERS", "FILM", "ANDRETTI FILM",
+	"GLASSES", "AMULET", "FACIAL KIT", "CAT FOOD", "MONKEY WRENCH",
+	"BIG DICK CARD", "BRA", "BOLT"
+};
+
+const byte ROOM_TABLE1[] = {
+	0x00, 0x2f, 0x00, 0x0d, 0x00, 0x30, 0x22, 0x30, 0x01, 0x00,
+	0x00, 0x00, 0x01, 0x01, 0x00, 0x03, 0x00, 0xff, 0x01, 0x00,
+	0x02, 0x00, 0x01, 0x00, 0x01, 0x00, 0xc0, 0x00, 0xff, 0xff,
+	0xff, 0xff, 0xff, 0xff, 0x2e, 0x00, 0x00, 0x00, 0x01, 0x00,
+	0x2e, 0x00, 0x05, 0x00, 0x01, 0x00, 0xff, 0xff,
+};
+const byte ROOM_TABLE2[] = {
+	0x00, 0x2f, 0x00, 0x0d, 0x00, 0x32, 0x28, 0x25, 0x02, 0x00,
+	0x00, 0x00, 0x02, 0x02, 0x00, 0x03, 0x00, 0xff, 0x02, 0x00,
+	0x02, 0x00, 0x02, 0x00, 0x01, 0x00, 0xc8, 0x00, 0xff, 0xff,
+	0xff, 0xff, 0xff, 0xff, 0x2e, 0x00, 0x00, 0x00, 0x01, 0x00,
+	0x2e, 0x00, 0x06, 0x00, 0x01, 0x00, 0xff, 0xff,
+};
+const byte ROOM_TABLE3[] = {
+	0x00, 0x2f, 0x00, 0x0f, 0x00, 0x1e, 0x19, 0x24, 0x03, 0x00,
+	0x00, 0x00, 0x03, 0x03, 0x00, 0x03, 0x00, 0xff, 0x03, 0x00,
+	0x02, 0x00, 0x03, 0x00, 0x01, 0x00, 0x78, 0x00, 0xff, 0xff,
+	0xff, 0xff, 0xff, 0xff, 0x2e, 0x00, 0x00, 0x00, 0x02, 0x00,
+	0x03, 0x00, 0x04, 0x00, 0x01, 0x00, 0x03, 0x00, 0x05, 0x00,
+	0x01, 0x00, 0x03, 0x00, 0x06, 0x00, 0x01, 0x00, 0x2e, 0x00,
+	0x01, 0x00, 0x01, 0x00, 0xff, 0xff,
+};
+const byte ROOM_TABLE4[] = {
+	0x00, 0x2f, 0x00, 0x06, 0x00, 0x36, 0x27, 0x32, 0x04, 0x00,
+	0x00, 0x00, 0x04, 0x04, 0x00, 0x03, 0x00, 0xff, 0x04, 0x00,
+	0x02, 0x00, 0x04, 0x00, 0x01, 0x00, 0xc8, 0x00, 0xff, 0xff,
+	0xff, 0xff, 0xff, 0xff, 0x2e, 0x00, 0x00, 0x00, 0x01, 0x00,
+	0x2e, 0x00, 0x07, 0x00, 0x01, 0x00, 0x2e, 0x00, 0x05, 0x00,
+	0x01, 0x00, 0xff, 0xff,
+};
+const byte ROOM_TABLE5[] = {
+	0x00, 0x2f, 0x00, 0x00, 0x00, 0x28, 0x19, 0x36, 0x05, 0x00,
+	0x00, 0x00, 0x05, 0x05, 0x00, 0x03, 0x00, 0xff, 0x05, 0x00,
+	0x02, 0x00, 0x05, 0x00, 0x01, 0x00, 0xa0, 0x20, 0xff, 0xff,
+	0xff, 0xff, 0xff, 0xff, 0x2e, 0x00, 0x00, 0x00, 0x01, 0x00,
+	0x2e, 0x00, 0x02, 0x00, 0x01, 0x00, 0x2e, 0x00, 0x03, 0x00,
+	0x01, 0x00, 0xff, 0xff,
+};
+const byte ROOM_TABLE6[] = {
+	0x00, 0x2f, 0x00, 0x07, 0x00, 0x40, 0x36, 0x36, 0x06, 0x00,
+	0x00, 0x00, 0x06, 0x06, 0x00, 0x03, 0x00, 0xff, 0x06, 0x00,
+	0x02, 0x00, 0x06, 0x00, 0x01, 0x00, 0xfe, 0x00, 0xff, 0xff,
+	0xff, 0xff, 0xff, 0xff, 0x2e, 0x00, 0x00, 0x00, 0x01, 0x00,
+	0x2e, 0x00, 0x13, 0x00, 0x01, 0x00, 0x2e, 0x00, 0x08, 0x00,
+	0x01, 0x00, 0x2e, 0x00, 0x14, 0x00, 0x01, 0x00, 0x2e, 0x00,
+	0x07, 0x00, 0x01, 0x00, 0xff, 0xff,
+};
+const byte ROOM_TABLE7[] = {
+	0x00, 0x2f, 0x00, 0x0e, 0x00, 0x40, 0x32, 0x3b, 0x07, 0x00,
+	0x00, 0x00, 0x07, 0x07, 0x00, 0x03, 0x00, 0xff, 0x07, 0x00,
+	0x02, 0x00, 0x07, 0x00, 0x01, 0x00, 0xfe, 0x00, 0xff, 0xff,
+	0xff, 0xff, 0xff, 0xff, 0x2e, 0x00, 0x00, 0x00, 0x01, 0x00,
+	0x2e, 0x00, 0x14, 0x00, 0x01, 0x00, 0x2e, 0x00, 0x07, 0x00,
+	0x01, 0x00, 0xff, 0xff,
+};
+const byte ROOM_TABLE8[] = {
+	0x00, 0x2f, 0x00, 0x0a, 0x00, 0x30, 0x22, 0x46, 0x08, 0x00,
+	0x00, 0x00, 0x08, 0x08, 0x00, 0x03, 0x00, 0xff, 0x08, 0x00,
+	0x02, 0x00, 0x08, 0x00, 0x01, 0x00, 0xc0, 0x00, 0xff, 0xff,
+	0xff, 0xff, 0xff, 0xff, 0x2e, 0x00, 0x00, 0x00, 0x01, 0x00,
+	0xff, 0xff,
+};
+const byte ROOM_TABLE9[] = {
+	0x00, 0x2f, 0x00, 0x07, 0x00, 0x32, 0x0c, 0x29, 0x09, 0x00,
+	0x00, 0x00, 0x09, 0x09, 0x00, 0x03, 0x00, 0xff, 0x09, 0x00,
+	0x02, 0x00, 0x09, 0x00, 0x01, 0x00, 0xc8, 0x00, 0xff, 0xff,
+	0xff, 0xff, 0xff, 0xff, 0x2e, 0x00, 0x00, 0x00, 0x01, 0x00,
+	0xff, 0xff,
+};
+const byte ROOM_TABLE11[] = {
+	0x00, 0x2f, 0x00, 0x00, 0x00, 0x40, 0x3a, 0x22, 0x0b, 0x00,
+	0x00, 0x00, 0x0b, 0x0b, 0x00, 0x03, 0x00, 0xff, 0x0b, 0x00,
+	0x02, 0x00, 0x0b, 0x00, 0x01, 0x00, 0xfe, 0x00, 0xff, 0xff,
+	0xff, 0xff, 0xff, 0xff, 0x2e, 0x00, 0x00, 0x00, 0x01, 0x00,
+	0xff, 0xff,
+};
+const byte ROOM_TABLE13[] = {
+	0x00, 0x2f, 0x00, 0x0c, 0x00, 0x40, 0x36, 0x2c, 0x0d, 0x00,
+	0x00, 0x00, 0x0d, 0x0d, 0x00, 0x03, 0x00, 0xff, 0x0d, 0x00,
+	0x02, 0x00, 0x0d, 0x00, 0x01, 0x00, 0xe6, 0x40, 0xff, 0xff,
+	0xff, 0xff, 0xff, 0xff, 0x2e, 0x00, 0x00, 0x00, 0x01, 0x00,
+	0x2e, 0x00, 0x0a, 0x00, 0x01, 0x00, 0x2e, 0x00, 0x07, 0x00,
+	0x01, 0x00, 0x2e, 0x00, 0x0b, 0x00, 0x01, 0x00, 0x2e, 0x00,
+	0x15, 0x00, 0x01, 0x00, 0xff, 0xff,
+};
+const byte ROOM_TABLE14[] = {
+	0x00, 0x2f, 0x00, 0x05, 0x00, 0x40, 0x3e, 0x33, 0x0e, 0x00,
+	0x00, 0x00, 0x0e, 0x0e, 0x00, 0x03, 0x00, 0xff, 0x0e, 0x00,
+	0x02, 0x00, 0x0e, 0x00, 0x01, 0x00, 0xfe, 0x40, 0xff, 0xff,
+	0xff, 0xff, 0xff, 0xff, 0x2e, 0x00, 0x00, 0x00, 0x01, 0x00,
+	0x2e, 0x00, 0x09, 0x00, 0x01, 0x00, 0x2e, 0x00, 0x07, 0x00,
+	0x01, 0x00, 0x2e, 0x00, 0x13, 0x00, 0x01, 0x00, 0x2e, 0x00,
+	0x0a, 0x00, 0x01, 0x00, 0xff, 0xff,
+};
+const byte ROOM_TABLE15[] = {
+	0x00, 0x2f, 0x00, 0x0c, 0x00, 0x28, 0x0c, 0x5e, 0x0f, 0x00,
+	0x00, 0x00, 0x0f, 0x0f, 0x00, 0x03, 0x00, 0xff, 0x0f, 0x00,
+	0x02, 0x00, 0x0f, 0x00, 0x01, 0x00, 0xb4, 0x00, 0xff, 0xff,
+	0xff, 0xff, 0xff, 0xff, 0x2e, 0x00, 0x00, 0x00, 0x01, 0x00,
+	0x2e, 0x00, 0x11, 0x00, 0x01, 0x00, 0xff, 0xff,
+};
+const byte ROOM_TABLE16[] = {
+	0x00, 0x2f, 0x00, 0x05, 0x00, 0x28, 0x1e, 0x24, 0x10, 0x00,
+	0x00, 0x00, 0x10, 0x10, 0x00, 0x03, 0x00, 0xff, 0x10, 0x00,
+	0x02, 0x00, 0x10, 0x00, 0x01, 0x00, 0xa0, 0x00, 0xff, 0xff,
+	0xff, 0xff, 0xff, 0xff, 0x2e, 0x00, 0x00, 0x00, 0x01, 0x00,
+	0x2e, 0x00, 0x07, 0x00, 0x01, 0x00, 0xff, 0xff,
+};
+const byte ROOM_TABLE17[] = {
+	0x00, 0x2f, 0x00, 0x06, 0x00, 0x28, 0x19, 0x2b, 0x11, 0x00,
+	0x00, 0x00, 0x11, 0x11, 0x00, 0x03, 0x00, 0xff, 0x11, 0x00,
+	0x02, 0x00, 0x11, 0x00, 0x01, 0x00, 0xa0, 0x00, 0xff, 0xff,
+	0xff, 0xff, 0xff, 0xff, 0x2e, 0x00, 0x00, 0x00, 0x01, 0x00,
+	0x2e, 0x00, 0x05, 0x00, 0x01, 0x00, 0xff, 0xff,
+};
+const byte ROOM_TABLE18[] = {
+	0x00, 0x2f, 0x00, 0x00, 0x00, 0x2d, 0x14, 0x3c, 0x12, 0x00,
+	0x00, 0x00, 0x12, 0x12, 0x00, 0x03, 0x00, 0xff, 0x12, 0x00,
+	0x02, 0x00, 0x12, 0x00, 0x01, 0x00, 0xb1, 0x40, 0xff, 0xff,
+	0xff, 0xff, 0xff, 0xff, 0x2e, 0x00, 0x00, 0x00, 0x01, 0x00,
+	0x2e, 0x00, 0x05, 0x00, 0x01, 0x00, 0xff, 0xff,
+};
+const byte ROOM_TABLE21[] = {
+	0x00, 0x2f, 0x00, 0x07, 0x00, 0x3c, 0x2a, 0x29, 0x15, 0x00,
+	0x00, 0x00, 0x15, 0x15, 0x00, 0x03, 0x00, 0xff, 0x15, 0x00,
+	0x02, 0x00, 0x15, 0x00, 0x01, 0x00, 0xf0, 0x00, 0xff, 0xff,
+	0xff, 0xff, 0xff, 0xff, 0x2e, 0x00, 0x00, 0x00, 0x01, 0x00,
+	0x2e, 0x00, 0x12, 0x00, 0x01, 0x00, 0x2e, 0x00, 0x07, 0x00,
+	0x01, 0x00, 0xff, 0xff,
+};
+const byte ROOM_TABLE22[] = {
+	0x00, 0x2f, 0x00, 0x0a, 0x00, 0x40, 0x2d, 0x27, 0x16, 0x00,
+	0x00, 0x00, 0x16, 0x16, 0x00, 0x03, 0x00, 0xff, 0x16, 0x00,
+	0x02, 0x00, 0x16, 0x00, 0x01, 0x00, 0xfe, 0x00, 0xff, 0xff,
+	0xff, 0xff, 0xff, 0xff, 0x2e, 0x00, 0x00, 0x00, 0x01, 0x00,
+	0x2e, 0x00, 0x16, 0x00, 0x01, 0x00, 0x2e, 0x00, 0x07, 0x00,
+	0x01, 0x00, 0xff, 0xff,
+};
+const byte ROOM_TABLE23[] = {
+	0x00, 0x2f, 0x00, 0x0a, 0x00, 0x40, 0x38, 0x24, 0x17, 0x00,
+	0x00, 0x00, 0x17, 0x17, 0x00, 0x03, 0x00, 0xff, 0x17, 0x00,
+	0x02, 0x00, 0x17, 0x00, 0x01, 0x00, 0xfe, 0x40, 0xff, 0xff,
+	0xff, 0xff, 0xff, 0xff, 0x2e, 0x00, 0x00, 0x00, 0x01, 0x00,
+	0x2e, 0x00, 0x0f, 0x00, 0x01, 0x00, 0x2e, 0x00, 0x17, 0x00,
+	0x01, 0x00, 0xff, 0xff,
+};
+const byte ROOM_TABLE24[] = {
+	0x00, 0x2f, 0x00, 0x06, 0x00, 0x3e, 0x10, 0x62, 0x18, 0x00,
+	0x00, 0x00, 0x18, 0x18, 0x00, 0x03, 0x00, 0xff, 0x18, 0x00,
+	0x02, 0x00, 0x18, 0x00, 0x01, 0x00, 0xf8, 0x00, 0xff, 0xff,
+	0xff, 0xff, 0xff, 0xff, 0x2e, 0x00, 0x00, 0x00, 0x01, 0x00,
+	0x2e, 0x00, 0x16, 0x00, 0x01, 0x00, 0xff, 0xff,
+};
+const byte ROOM_TABLE25[] = {
+	0x00, 0x2f, 0x00, 0x0e, 0x00, 0x3e, 0x37, 0x19, 0x19, 0x00,
+	0x00, 0x00, 0x19, 0x19, 0x00, 0x03, 0x00, 0xff, 0x19, 0x00,
+	0x02, 0x00, 0x19, 0x00, 0x01, 0x00, 0xf8, 0x00, 0xff, 0xff,
+	0xff, 0xff, 0xff, 0xff, 0x2e, 0x00, 0x00, 0x00, 0x01, 0x00,
+	0x2e, 0x00, 0x10, 0x00, 0x01, 0x00, 0x2e, 0x00, 0x07, 0x00,
+	0x01, 0x00, 0xff, 0xff,
+};
+const byte ROOM_TABLE26[] = {
+	0x00, 0x2f, 0x00, 0x06, 0x00, 0x34, 0x28, 0x28, 0x1a, 0x00,
+	0x00, 0x00, 0x1a, 0x1a, 0x00, 0x03, 0x00, 0xff, 0x1a, 0x00,
+	0x02, 0x00, 0x1a, 0x00, 0x01, 0x00, 0xd0, 0x00, 0xff, 0xff,
+	0xff, 0xff, 0xff, 0xff, 0x2e, 0x00, 0x00, 0x00, 0x01, 0x00,
+	0x2e, 0x00, 0x07, 0x00, 0x01, 0x00, 0xff, 0xff,
+};
+const byte ROOM_TABLE27[] = {
+	0x00, 0x2f, 0x00, 0x0f, 0x00, 0x1b, 0x16, 0x18, 0x1b, 0x00,
+	0x00, 0x00, 0x1b, 0x1b, 0x00, 0x03, 0x00, 0xff, 0x1b, 0x00,
+	0x02, 0x00, 0x1b, 0x00, 0x01, 0x00, 0x70, 0x00, 0xff, 0xff,
+	0xff, 0xff, 0xff, 0xff, 0x2e, 0x00, 0x00, 0x00, 0x01, 0x00,
+	0x2e, 0x00, 0x0d, 0x00, 0x01, 0x00, 0x2e, 0x00, 0x07, 0x00,
+	0x01, 0x00, 0xff, 0xff,
+};
+const byte ROOM_TABLE28[] = {
+	0x00, 0x2f, 0x00, 0x09, 0x00, 0x25, 0x10, 0x43, 0x1c, 0x00,
+	0x00, 0x00, 0x1c, 0x1c, 0x00, 0x03, 0x00, 0xff, 0x1c, 0x00,
+	0x02, 0x00, 0x1c, 0x00, 0x01, 0x00, 0x94, 0x00, 0xff, 0xff,
+	0xff, 0xff, 0xff, 0xff, 0x2e, 0x00, 0x00, 0x00, 0x01, 0x00,
+	0xff, 0xff,
+};
+const byte ROOM_TABLE29[] = {
+	0x00, 0x2f, 0x00, 0x0a, 0x00, 0x20, 0x18, 0x56, 0x1d, 0x00,
+	0x00, 0x00, 0x1d, 0x1d, 0x00, 0x03, 0x00, 0xff, 0x1d, 0x00,
+	0x02, 0x00, 0x1d, 0x00, 0x01, 0x00, 0x80, 0x00, 0xff, 0xff,
+	0xff, 0xff, 0xff, 0xff, 0x2e, 0x00, 0x00, 0x00, 0x01, 0x00,
+	0x2e, 0x00, 0x17, 0x00, 0x01, 0x00, 0x2e, 0x00, 0x10, 0x00,
+	0x02, 0x00, 0xff, 0xff,
+};
+const byte ROOM_TABLE30[] = {
+	0x00, 0x2f, 0x00, 0x07, 0x00, 0x3f, 0x1c, 0x27, 0x1e, 0x00,
+	0x00, 0x00, 0x1e, 0x1e, 0x00, 0x03, 0x00, 0xff, 0x1e, 0x00,
+	0x02, 0x00, 0x1e, 0x00, 0x01, 0x00, 0xfe, 0x00, 0xff, 0xff,
+	0xff, 0xff, 0x1e, 0x00, 0x04, 0x00, 0xff, 0xff, 0x2e, 0x00,
+	0x00, 0x00, 0x01, 0x00, 0x2e, 0x00, 0x07, 0x00, 0x01, 0x00,
+	0x2e, 0x00, 0x15, 0x00, 0x01, 0x00, 0xff, 0xff,
+};
+const byte ROOM_TABLE31[] = {
+	0x00, 0x2f, 0x00, 0x0d, 0x00, 0x32, 0x2e, 0x69, 0x1f, 0x00,
+	0x00, 0x00, 0x1f, 0x1f, 0x00, 0x03, 0x00, 0xff, 0x1f, 0x00,
+	0x02, 0x00, 0x1f, 0x00, 0x01, 0x00, 0xc8, 0x00, 0xff, 0xff,
+	0xff, 0xff, 0xff, 0xff, 0x2e, 0x00, 0x00, 0x00, 0x01, 0x00,
+	0xff, 0xff,
+};
+const byte ROOM_TABLE32[] = {
+	0x00, 0x2f, 0x00, 0x07, 0x00, 0x40, 0x3b, 0x4b, 0x20, 0x00,
+	0x00, 0x00, 0x20, 0x20, 0x00, 0x03, 0x00, 0xff, 0x20, 0x00,
+	0x02, 0x00, 0x20, 0x00, 0x01, 0x00, 0xfe, 0x00, 0xff, 0xff,
+	0xff, 0xff, 0xff, 0xff, 0x2e, 0x00, 0x00, 0x00, 0x01, 0x00,
+	0x2e, 0x00, 0x05, 0x00, 0x01, 0x00, 0xff, 0xff,
+};
+const byte ROOM_TABLE33[] = {
+	0x00, 0x2f, 0x00, 0x0b, 0x00, 0x30, 0x10, 0x51, 0x21, 0x00,
+	0x00, 0x00, 0x21, 0x21, 0x00, 0x03, 0x00, 0xff, 0x21, 0x00,
+	0x02, 0x00, 0x21, 0x00, 0x01, 0x00, 0xc0, 0x40, 0xff, 0xff,
+	0xff, 0xff, 0xff, 0xff, 0x2e, 0x00, 0x00, 0x00, 0x01, 0x00,
+	0xff, 0xff,
+};
+const byte ROOM_TABLE35[] = {
+	0x00, 0x2f, 0x00, 0x0f, 0x00, 0x1e, 0x18, 0x25, 0x23, 0x00,
+	0x00, 0x00, 0x23, 0x23, 0x00, 0x03, 0x00, 0xff, 0x23, 0x00,
+	0x02, 0x00, 0x23, 0x00, 0x01, 0x00, 0x78, 0x18, 0xff, 0xff,
+	0xff, 0xff, 0xff, 0xff, 0x2e, 0x00, 0x00, 0x00, 0x01, 0x00,
+	0x2e, 0x00, 0x0e, 0x00, 0x01, 0x00, 0x2e, 0x00, 0x07, 0x00,
+	0x01, 0x00, 0x2e, 0x00, 0x16, 0x00, 0x01, 0x00, 0x2e, 0x00,
+	0x0c, 0x00, 0x01, 0x00, 0xff, 0xff,
+};
+const byte ROOM_TABLE37[] = {
+	0x00, 0x2f, 0x00, 0x0f, 0x00, 0x3f, 0x3a, 0x1a, 0x25, 0x00,
+	0x00, 0x00, 0x25, 0x25, 0x00, 0x03, 0x00, 0xff, 0x25, 0x00,
+	0x02, 0x00, 0x25, 0x00, 0x01, 0x00, 0xfe, 0x40, 0xff, 0xff,
+	0xff, 0xff, 0xff, 0xff, 0x2e, 0x00, 0x00, 0x00, 0x01, 0x00,
+	0x2e, 0x00, 0x0d, 0x00, 0x01, 0x00, 0xff, 0xff,
+};
+const byte ROOM_TABLE38[] = {
+	0x00, 0x2f, 0x00, 0x0d, 0x00, 0x40, 0x32, 0x32, 0x26, 0x00,
+	0x00, 0x00, 0x26, 0x26, 0x00, 0x03, 0x00, 0xff, 0x26, 0x00,
+	0x02, 0x00, 0x26, 0x00, 0x01, 0x00, 0xf0, 0x00, 0xff, 0xff,
+	0xff, 0xff, 0xff, 0xff, 0x2e, 0x00, 0x00, 0x00, 0x01, 0x00,
+	0x2e, 0x00, 0x0b, 0x00, 0x01, 0x00, 0xff, 0xff,
+};
+const byte ROOM_TABLE39[] = {
+	0x00, 0x2f, 0x00, 0x0a, 0x00, 0x3c, 0x10, 0x4c, 0x27, 0x00,
+	0x00, 0x00, 0x27, 0x27, 0x00, 0x03, 0x00, 0xff, 0x27, 0x00,
+	0x02, 0x00, 0x27, 0x00, 0x01, 0x00, 0xf0, 0x00, 0xff, 0xff,
+	0xff, 0xff, 0xff, 0xff, 0x2e, 0x00, 0x00, 0x00, 0x01, 0x00,
+	0x2e, 0x00, 0x11, 0x00, 0x01, 0x00, 0x2e, 0x00, 0x0f, 0x00,
+	0x01, 0x00, 0xff, 0xff,
+};
+const byte ROOM_TABLE47[] = {
+	0x00, 0x2f, 0x00, 0x06, 0x00, 0x28, 0x1e, 0x32, 0x2b, 0x00,
+	0x00, 0x00, 0x46, 0x2b, 0x00, 0x03, 0x00, 0xff, 0x2b, 0x00,
+	0x02, 0x00, 0x2b, 0x00, 0x01, 0x00, 0xf0, 0x00, 0xff, 0xff,
+	0xff, 0xff, 0x2b, 0x00, 0x04, 0x00, 0xff, 0xff, 0x2e, 0x00,
+	0x04, 0x00, 0x01, 0x00, 0xff, 0xff, 0x00,
+};
+const byte *ROOM_TABLE[] = {
+	nullptr, ROOM_TABLE1, ROOM_TABLE2, ROOM_TABLE3, ROOM_TABLE4, ROOM_TABLE5, ROOM_TABLE6,
+	ROOM_TABLE7, ROOM_TABLE8, ROOM_TABLE9, nullptr, ROOM_TABLE11, nullptr, ROOM_TABLE13,
+	ROOM_TABLE14, ROOM_TABLE15, ROOM_TABLE16, ROOM_TABLE17, ROOM_TABLE18, nullptr, nullptr,
+	ROOM_TABLE21, ROOM_TABLE22, ROOM_TABLE23, ROOM_TABLE24, ROOM_TABLE25, ROOM_TABLE26, ROOM_TABLE27,
+	ROOM_TABLE28, ROOM_TABLE29, ROOM_TABLE30, ROOM_TABLE31, ROOM_TABLE32, ROOM_TABLE33, nullptr,
+	ROOM_TABLE35, nullptr, ROOM_TABLE37, ROOM_TABLE38, ROOM_TABLE39, nullptr, nullptr,
+	nullptr, nullptr, nullptr, nullptr, nullptr, ROOM_TABLE47
+};
+
+const byte CHAR_TABLE0[] = {
+	0x02, 0x31, 0x00, 0x08, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff,
+	0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff,
+	0x00, 0x00, 0x00, 0x00, 0xff, 0xff,
+};
+const byte CHAR_TABLE2[] = {
+	0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+	0xff, 0x00, 0x00, 0x00, 0x00, 0x32, 0x33, 0x00, 0x01, 0x00,
+	0xff, 0xff, 0xff, 0xff, 0xff, 0x33, 0x00, 0x00, 0x00, 0x33,
+	0x00, 0x02, 0x00, 0x33, 0x00, 0x0b, 0x00, 0x33, 0x00, 0x03,
+	0x00, 0x33, 0x00, 0x0c, 0x00, 0x33, 0x00, 0x04, 0x00, 0x33,
+	0x00, 0x0d, 0x00, 0x33, 0x00, 0x05, 0x00, 0x33, 0x00, 0x0e,
+	0x00, 0x33, 0x00, 0x06, 0x00, 0x33, 0x00, 0x0f, 0x00, 0x33,
+	0x00, 0x07, 0x00, 0x33, 0x00, 0x10, 0x00, 0x33, 0x00, 0x08,
+	0x00, 0x33, 0x00, 0x11, 0x00, 0x33, 0x00, 0x09, 0x00, 0x33,
+	0x00, 0x12, 0x00, 0x33, 0x00, 0x0a, 0x00, 0x33, 0x00, 0x13,
+	0x00, 0xff, 0xff,
+};
+const byte CHAR_TABLE3[] = {
+	0x02, 0x31, 0x00, 0x03, 0x00, 0x35, 0x00, 0x37, 0x00, 0x02,
+	0x00, 0x80, 0x00, 0xf7, 0x00, 0x4b, 0x37, 0x00, 0x01, 0x00,
+	0xff, 0x37, 0x00, 0x03, 0x00, 0x37, 0x00, 0x00, 0x00, 0xff,
+	0xff,
+};
+const byte CHAR_TABLE4[] = {
+	0x01, 0x31, 0x00, 0x0a, 0x00, 0x36, 0x00, 0x35, 0x00, 0x02,
+	0x00, 0x80, 0x00, 0xf7, 0x00, 0x49, 0x35, 0x00, 0x01, 0x00,
+	0xff, 0xff, 0xff, 0xff, 0xff, 0x35, 0x00, 0x00, 0x00, 0x35,
+	0x00, 0x03, 0x00, 0x35, 0x00, 0x0c, 0x00, 0x35, 0x00, 0x04,
+	0x00, 0x35, 0x00, 0x0d, 0x00, 0x35, 0x00, 0x05, 0x00, 0x35,
+	0x00, 0x0e, 0x00, 0x35, 0x00, 0x06, 0x00, 0x35, 0x00, 0x0f,
+	0x00, 0x35, 0x00, 0x07, 0x00, 0x35, 0x00, 0x10, 0x00, 0x35,
+	0x00, 0x08, 0x00, 0x35, 0x00, 0x11, 0x00, 0x35, 0x00, 0x09,
+	0x00, 0x35, 0x00, 0x12, 0x00, 0x35, 0x00, 0x0a, 0x00, 0x35,
+	0x00, 0x13, 0x00, 0x35, 0x00, 0x0b, 0x00, 0x35, 0x00, 0x14,
+	0x00, 0xff, 0xff,
+};
+const byte CHAR_TABLE5[] = {
+	0x01, 0x31, 0x00, 0x08, 0x00, 0x37, 0x00, 0x34, 0x00, 0x02,
+	0x00, 0x80, 0x00, 0xf7, 0x00, 0x48, 0x34, 0x00, 0x01, 0x00,
+	0xff, 0xff, 0xff, 0xff, 0xff, 0x34, 0x00, 0x00, 0x00, 0x43,
+	0x00, 0x00, 0x00, 0x34, 0x00, 0x03, 0x00, 0x43, 0x00, 0x01,
+	0x00, 0x34, 0x00, 0x04, 0x00, 0x43, 0x00, 0x02, 0x00, 0x34,
+	0x00, 0x05, 0x00, 0x43, 0x00, 0x03, 0x00, 0x34, 0x00, 0x06,
+	0x00, 0x43, 0x00, 0x04, 0x00, 0x34, 0x00, 0x07, 0x00, 0x43,
+	0x00, 0x05, 0x00, 0x34, 0x00, 0x08, 0x00, 0x43, 0x00, 0x06,
+	0x00, 0x34, 0x00, 0x09, 0x00, 0x43, 0x00, 0x07, 0x00, 0x34,
+	0x00, 0x0a, 0x00, 0x43, 0x00, 0x08, 0x00, 0x34, 0x00, 0x0b,
+	0x00, 0x43, 0x00, 0x09, 0x00, 0x34, 0x00, 0x0c, 0x00, 0x43,
+	0x00, 0x0a, 0x00, 0x34, 0x00, 0x0d, 0x00, 0x43, 0x00, 0x0b,
+	0x00, 0x34, 0x00, 0x0e, 0x00, 0x43, 0x00, 0x0c, 0x00, 0x34,
+	0x00, 0x0f, 0x00, 0x43, 0x00, 0x0d, 0x00, 0x34, 0x00, 0x10,
+	0x00, 0xff, 0xff,
+};
+const byte CHAR_TABLE6[] = {
+	0x02, 0x31, 0x00, 0x03, 0x00, 0x38, 0x00, 0x44, 0x00, 0x03,
+	0x00, 0x80, 0x00, 0xf7, 0x00, 0x4e, 0x44, 0x00, 0x01, 0x00,
+	0xff, 0x44, 0x00, 0x02, 0x00, 0x44, 0x00, 0x00, 0x00, 0xff,
+	0xff,
+};
+const byte CHAR_TABLE7[] = {
+	0x02, 0x31, 0x00, 0x01, 0x00, 0x39, 0x00, 0x38, 0x00, 0x02,
+	0x00, 0x80, 0x00, 0xf7, 0x00, 0x4c, 0x38, 0x00, 0x01, 0x00,
+	0xff, 0x38, 0x00, 0x03, 0x00, 0x38, 0x00, 0x00, 0x00, 0xff,
+	0xff,
+};
+const byte CHAR_TABLE8[] = {
+	0x03, 0xff, 0xff, 0xff, 0xff, 0x3a, 0x00, 0xff, 0xff, 0xff,
+	0xff, 0x00, 0x00, 0x00, 0x00, 0x4d, 0x3b, 0x00, 0x01, 0x00,
+	0xff, 0x3b, 0x00, 0x02, 0x00, 0x3b, 0x00, 0x00, 0x00, 0xff,
+	0xff,
+};
+const byte CHAR_TABLE9[] = {
+	0x03, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+	0xff, 0x00, 0x00, 0x00, 0x00, 0x59, 0x4a, 0x00, 0x01, 0x00,
+	0xff, 0x4a, 0x00, 0x02, 0x00, 0x4a, 0x00, 0x00, 0x00, 0xff,
+	0xff,
+};
+const byte CHAR_TABLE10[] = {
+	0x01, 0x31, 0x00, 0x0a, 0x00, 0x3c, 0x00, 0x36, 0x00, 0x02,
+	0x00, 0x80, 0x00, 0xf7, 0x00, 0x4a, 0x36, 0x00, 0x01, 0x00,
+	0xff, 0xff, 0xff, 0xff, 0xff, 0x36, 0x00, 0x00, 0x00, 0x36,
+	0x00, 0x03, 0x00, 0x36, 0x00, 0x13, 0x00, 0x36, 0x00, 0x04,
+	0x00, 0x36, 0x00, 0x14, 0x00, 0x36, 0x00, 0x05, 0x00, 0x36,
+	0x00, 0x15, 0x00, 0x36, 0x00, 0x06, 0x00, 0x36, 0x00, 0x16,
+	0x00, 0x36, 0x00, 0x07, 0x00, 0x36, 0x00, 0x17, 0x00, 0x36,
+	0x00, 0x08, 0x00, 0x36, 0x00, 0x18, 0x00, 0x36, 0x00, 0x09,
+	0x00, 0x36, 0x00, 0x19, 0x00, 0x36, 0x00, 0x0a, 0x00, 0x36,
+	0x00, 0x1a, 0x00, 0x36, 0x00, 0x0b, 0x00, 0x36, 0x00, 0x1b,
+	0x00, 0x36, 0x00, 0x0c, 0x00, 0x36, 0x00, 0x1c, 0x00, 0x36,
+	0x00, 0x0d, 0x00, 0x36, 0x00, 0x1d, 0x00, 0x36, 0x00, 0x0e,
+	0x00, 0x36, 0x00, 0x1e, 0x00, 0x36, 0x00, 0x0f, 0x00, 0x36,
+	0x00, 0x1f, 0x00, 0x36, 0x00, 0x10, 0x00, 0x36, 0x00, 0x20,
+	0x00, 0x36, 0x00, 0x11, 0x00, 0x36, 0x00, 0x21, 0x00, 0x36,
+	0x00, 0x12, 0x00, 0x36, 0x00, 0x22, 0x00, 0xff, 0xff,
+};
+const byte CHAR_TABLE11[] = {
+	0x03, 0xff, 0xff, 0xff, 0xff, 0x3d, 0x00, 0xff, 0xff, 0xff,
+	0xff, 0x00, 0x00, 0x00, 0x00, 0x55, 0x45, 0x00, 0x01, 0x00,
+	0xff, 0x45, 0x00, 0x02, 0x00, 0x45, 0x00, 0x00, 0x00, 0xff,
+	0xff,
+};
+const byte CHAR_TABLE12[] = {
+	0x03, 0xff, 0xff, 0xff, 0xff, 0x3e, 0x00, 0xff, 0xff, 0xff,
+	0xff, 0x00, 0x00, 0x00, 0x00, 0x4f, 0x40, 0x00, 0x01, 0x00,
+	0xff, 0x40, 0x00, 0x02, 0x00, 0x40, 0x00, 0x00, 0x00, 0xff,
+	0xff,
+};
+const byte CHAR_TABLE13[] = {
+	0x00, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x46, 0x00, 0x02,
+	0x00, 0x80, 0x00, 0xf7, 0x00, 0x56, 0x46, 0x00, 0x01, 0x00,
+	0xff, 0x46, 0x00, 0x03, 0x00, 0x46, 0x00, 0x00, 0x00, 0x46,
+	0x00, 0x04, 0x00, 0x46, 0x00, 0x0d, 0x00, 0x46, 0x00, 0x05,
+	0x00, 0x46, 0x00, 0x0e, 0x00, 0x46, 0x00, 0x06, 0x00, 0x46,
+	0x00, 0x0f, 0x00, 0x46, 0x00, 0x07, 0x00, 0x46, 0x00, 0x10,
+	0x00, 0x46, 0x00, 0x08, 0x00, 0x46, 0x00, 0x11, 0x00, 0x46,
+	0x00, 0x09, 0x00, 0x46, 0x00, 0x12, 0x00, 0x46, 0x00, 0x0a,
+	0x00, 0x46, 0x00, 0x13, 0x00, 0x46, 0x00, 0x0b, 0x00, 0x46,
+	0x00, 0x14, 0x00, 0x46, 0x00, 0x0c, 0x00, 0x46, 0x00, 0x15,
+	0x00, 0xff, 0xff,
+};
+const byte CHAR_TABLE15[] = {
+	0x00, 0xff, 0xff, 0xff, 0xff, 0x41, 0x00, 0xff, 0xff, 0xff,
+	0xff, 0x00, 0x00, 0x00, 0x00, 0x57, 0x47, 0x00, 0x01, 0x00,
+	0xff, 0xff, 0xff, 0xff, 0xff, 0x47, 0x00, 0x00, 0x00, 0x47,
+	0x00, 0x02, 0x00, 0x47, 0x00, 0x05, 0x00, 0x47, 0x00, 0x03,
+	0x00, 0x47, 0x00, 0x06, 0x00, 0x47, 0x00, 0x04, 0x00, 0x47,
+	0x00, 0x07, 0x00, 0xff, 0xff,
+};
+const byte CHAR_TABLE16[] = {
+	0x03, 0xff, 0xff, 0xff, 0xff, 0x42, 0x00, 0xff, 0xff, 0xff,
+	0xff, 0x00, 0x00, 0x00, 0x00, 0x54, 0x41, 0x00, 0x01, 0x00,
+	0xff, 0x41, 0x00, 0x02, 0x00, 0x41, 0x00, 0x00, 0x00, 0xff,
+	0xff,
+};
+const byte CHAR_TABLE18[] = {
+	0x02, 0x31, 0x00, 0x07, 0x00, 0x44, 0x00, 0x3c, 0x00, 0x03,
+	0x00, 0x80, 0x00, 0xf7, 0x00, 0x50, 0x3c, 0x00, 0x01, 0x00,
+	0xff, 0x3c, 0x00, 0x02, 0x00, 0x3c, 0x00, 0x00, 0x00, 0xff,
+	0xff,
+};
+const byte CHAR_TABLE19[] = {
+	0x02, 0x31, 0x00, 0x07, 0x00, 0x45, 0x00, 0x3d, 0x00, 0x03,
+	0x00, 0x80, 0x00, 0xf7, 0x00, 0x51, 0x3d, 0x00, 0x01, 0x00,
+	0xff, 0x3d, 0x00, 0x02, 0x00, 0x3d, 0x00, 0x00, 0x00, 0xff,
+	0xff,
+};
+const byte CHAR_TABLE20[] = {
+	0x02, 0x31, 0x00, 0x02, 0x00, 0x46, 0x00, 0x48, 0x00, 0x02,
+	0x00, 0x80, 0x00, 0xf7, 0x00, 0x58, 0x48, 0x00, 0x01, 0x00,
+	0xff, 0x48, 0x00, 0x03, 0x00, 0x48, 0x00, 0x00, 0x00, 0xff,
+	0xff,
+};
+const byte CHAR_TABLE21[] = {
+	0x02, 0x31, 0x00, 0x07, 0x00, 0x47, 0x00, 0x3e, 0x00, 0x03,
+	0x00, 0x80, 0x00, 0xf7, 0x00, 0x52, 0x3e, 0x00, 0x01, 0x00,
+	0xff, 0x3e, 0x00, 0x02, 0x00, 0x3e, 0x00, 0x00, 0x00, 0xff,
+	0xff,
+};
+const byte CHAR_TABLE23[] = {
+	0x02, 0x31, 0x00, 0x08, 0x00, 0x49, 0x00, 0x3f, 0x00, 0x03,
+	0x00, 0x80, 0x00, 0xf7, 0x00, 0x53, 0x3f, 0x00, 0x01, 0x00,
+	0xff, 0x3f, 0x00, 0x02, 0x00, 0x3f, 0x00, 0x00, 0x00, 0xff,
+	0xff,
+};
+const byte CHAR_TABLE24[] = {
+	0x02, 0x32, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff,
+	0xff, 0x00, 0x00, 0x00, 0x00, 0x47, 0x32, 0x00, 0x02, 0x00,
+	0xff, 0xff, 0xff, 0xff, 0xff, 0x32, 0x00, 0x01, 0x00, 0x32,
+	0x00, 0x03, 0x00, 0x32, 0x00, 0x0a, 0x00, 0x32, 0x00, 0x04,
+	0x00, 0x32, 0x00, 0x0b, 0x00, 0x32, 0x00, 0x05, 0x00, 0x32,
+	0x00, 0x0c, 0x00, 0x32, 0x00, 0x06, 0x00, 0x32, 0x00, 0x0d,
+	0x00, 0x32, 0x00, 0x07, 0x00, 0x32, 0x00, 0x0e, 0x00, 0x32,
+	0x00, 0x08, 0x00, 0x32, 0x00, 0x0f, 0x00, 0x32, 0x00, 0x09,
+	0x00, 0x32, 0x00, 0x10, 0x00, 0xff, 0xff
+};
+const byte CHAR_TABLE25[] = {
+	0x02, 0x39, 0x00, 0x01, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
+	0xFF, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
+	0x39, 0x00, 0x00, 0x00, 0x39, 0x00, 0x02, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0xFF, 0xFF
+};
+const byte CHAR_TABLE26[] = {
+	0x01, 0x3a, 0x00, 0x01, 0x00, 0x0a, 0x00, 0xff, 0xff, 0xff,
+	0xff, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x3a, 0x00, 0x02, 0x00,
+	0xff, 0x3a, 0x00, 0x03, 0x00, 0x3a, 0x00, 0x00, 0x00, 0x42,
+	0x00, 0x00, 0x00, 0x3a, 0x00, 0x04, 0x00, 0x42, 0x00, 0x01,
+	0x00, 0x3a, 0x00, 0x05, 0x00, 0x42, 0x00, 0x02, 0x00, 0x3a,
+	0x00, 0x06, 0x00, 0x42, 0x00, 0x03, 0x00, 0x3a, 0x00, 0x07,
+	0x00, 0x42, 0x00, 0x04, 0x00, 0x3a, 0x00, 0x08, 0x00, 0x42,
+	0x00, 0x05, 0x00, 0x3a, 0x00, 0x09, 0x00, 0x42, 0x00, 0x06,
+	0x00, 0x3a, 0x00, 0x0a, 0x00, 0x42, 0x00, 0x07, 0x00, 0x3a,
+	0x00, 0x0b, 0x00, 0x42, 0x00, 0x08, 0x00, 0x3a, 0x00, 0x0c,
+	0x00, 0x42, 0x00, 0x09, 0x00, 0x3a, 0x00, 0x0d, 0x00, 0x42,
+	0x00, 0x0a, 0x00, 0x3a, 0x00, 0x0e, 0x00, 0x42, 0x00, 0x0b,
+	0x00, 0x3a, 0x00, 0x0f, 0x00, 0x42, 0x00, 0x0c, 0x00, 0x3a,
+	0x00, 0x10, 0x00, 0x42, 0x00, 0x0d, 0x00, 0x3a, 0x00, 0x11,
+	0x00, 0x42, 0x00, 0x0e, 0x00, 0x3a, 0x00, 0x12, 0x00, 0x42,
+	0x00, 0x0f, 0x00, 0x3a, 0x00, 0x13, 0x00, 0x42, 0x00, 0x10,
+	0x00, 0x3a, 0x00, 0x14, 0x00, 0x42, 0x00, 0x11, 0x00, 0x3a,
+	0x00, 0x15, 0x00, 0xff, 0xff
+};
+const byte CHAR_TABLE27[] = {
+	0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+	0xff, 0x00, 0x00, 0x00, 0x00, 0x58, 0x49, 0x00, 0x01, 0x00,
+	0xff, 0xff, 0xff, 0xff, 0xff, 0x49, 0x00, 0x00, 0x00, 0x49,
+	0x00, 0x02, 0x00, 0x49, 0x00, 0x0a, 0x00, 0x49, 0x00, 0x03,
+	0x00, 0x49, 0x00, 0x0b, 0x00, 0x49, 0x00, 0x04, 0x00, 0x49,
+	0x00, 0x0c, 0x00, 0x49, 0x00, 0x05, 0x00, 0x49, 0x00, 0x0d,
+	0x00, 0x49, 0x00, 0x06, 0x00, 0x49, 0x00, 0x0e, 0x00, 0x49,
+	0x00, 0x07, 0x00, 0x49, 0x00, 0x0f, 0x00, 0x49, 0x00, 0x08,
+	0x00, 0x49, 0x00, 0x10, 0x00, 0x49, 0x00, 0x09, 0x00, 0x49,
+	0x00, 0x11, 0x00, 0xff, 0xff,
+};
+const byte *CHAR_TABLE[] = {
+	CHAR_TABLE0, nullptr, CHAR_TABLE2, CHAR_TABLE3, CHAR_TABLE4, CHAR_TABLE5,
+	CHAR_TABLE6, CHAR_TABLE7, CHAR_TABLE8, CHAR_TABLE9, CHAR_TABLE10,
+	CHAR_TABLE11, CHAR_TABLE12, CHAR_TABLE13, nullptr, CHAR_TABLE15, 
+	CHAR_TABLE16, nullptr, CHAR_TABLE18, CHAR_TABLE19, CHAR_TABLE20, 
+	CHAR_TABLE21, nullptr, CHAR_TABLE23, CHAR_TABLE24, CHAR_TABLE25, 
+	CHAR_TABLE26, CHAR_TABLE27
+};
+
+} // End of namespace Martian
+
+} // End of namespace Access
diff --git a/engines/access/martian/martian_resources.h b/engines/access/martian/martian_resources.h
new file mode 100644
index 0000000..a6ababe
--- /dev/null
+++ b/engines/access/martian/martian_resources.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.
+ *
+ */
+
+#ifndef ACCESS_MARTIAN_RESOURCES_H
+#define ACCESS_MARTIAN_RESOURCES_H
+
+#include "common/scummsys.h"
+
+namespace Access {
+
+namespace Martian {
+
+extern const char *const FILENAMES[];
+
+extern const byte *CURSORS[4];
+
+extern const int TRAVEL_POS[][2];
+
+extern const char *const INVENTORY_NAMES[];
+
+extern const byte *ROOM_TABLE[];
+
+extern const byte *CHAR_TABLE[];
+
+} // End of namespace Martian
+
+} // End of namespace Access
+
+#endif /* ACCESS_MARTIAN_RESOURCES_H */
diff --git a/engines/access/martian/martian_room.cpp b/engines/access/martian/martian_room.cpp
new file mode 100644
index 0000000..80eaf59
--- /dev/null
+++ b/engines/access/martian/martian_room.cpp
@@ -0,0 +1,139 @@
+/* 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 "common/scummsys.h"
+#include "access/access.h"
+#include "access/resources.h"
+#include "access/martian/martian_game.h"
+#include "access/martian/martian_resources.h"
+#include "access/martian/martian_room.h"
+
+namespace Access {
+
+namespace Martian {
+
+MartianRoom::MartianRoom(AccessEngine *vm): Room(vm) {
+	_game = (MartianEngine *)vm;
+}
+
+MartianRoom::~MartianRoom() {
+}
+
+void MartianRoom::loadRoom(int roomNumber) {
+	loadRoomData(ROOM_TABLE[roomNumber]);
+}
+
+void MartianRoom::reloadRoom() {
+	loadRoom(_vm->_player->_roomNumber);
+
+	if (_roomFlag != 1) {
+		_vm->_currentMan = _roomFlag;
+		_vm->_currentManOld = _roomFlag;
+		_vm->_manScaleOff = 0;
+		
+		switch (_vm->_currentMan) {
+		case 0:
+			_vm->_player->loadSprites("MAN.LZ");
+			break;
+
+		case 2:
+			_vm->_player->loadSprites("JMAN.LZ");
+			break;
+
+		case 3:
+			_vm->_player->loadSprites("OVERHEAD.LZ");
+			_vm->_manScaleOff = 1;
+			break;
+
+		default:
+			break;
+		}
+	}
+
+	reloadRoom1();
+}
+
+void MartianRoom::reloadRoom1() {
+	if (_vm->_player->_roomNumber == 29 || _vm->_player->_roomNumber == 31 
+			|| _vm->_player->_roomNumber == 42 || _vm->_player->_roomNumber == 44) {
+		_vm->_inactive = _vm->_files->loadFile("MAYA.LZ");
+		_vm->_currentCharFlag = false;
+	}
+
+	_selectCommand = -1;
+	_vm->_normalMouse = 1;
+	_vm->_mouseMode = 0;
+	_vm->_boxSelect = true;
+	_vm->_player->_playerOff = false;
+
+	_vm->_screen->fadeOut();
+	_vm->_screen->clearScreen();
+	roomSet();
+
+	// TODO: Refactor
+
+	_vm->_screen->setBufferScan();
+	setupRoom();
+	setWallCodes();
+	buildScreen();
+
+	if (!_vm->_screen->_vesaMode) {
+		_vm->copyBF2Vid();
+	} else if (_vm->_player->_roomNumber != 20 && _vm->_player->_roomNumber != 24
+			&& _vm->_player->_roomNumber != 33) {
+		_vm->_screen->setPalette();
+		_vm->copyBF2Vid();
+	}
+
+	_vm->_player->_frame = 0;
+	_vm->_oldRects.clear();
+	_vm->_newRects.clear();
+}
+
+void MartianRoom::roomSet() {
+	_vm->_numAnimTimers = 0;
+	_vm->_scripts->_sequence = 1000;
+	_vm->_scripts->searchForSequence();
+	_vm->_scripts->executeScript();
+}
+
+void MartianRoom::roomMenu() {
+	byte *iconData = _vm->_files->loadFile("ICONS.LZ");
+	SpriteResource *spr = new SpriteResource(_vm, iconData, _vm->_files->_filesize);
+	delete[] iconData;
+
+	_vm->_screen->saveScreen();
+	_vm->_screen->setDisplayScan();
+	_vm->_destIn = _vm->_screen;	// TODO: Redundant
+	_vm->_screen->plotImage(spr, 0, Common::Point(0, 177));
+	_vm->_screen->plotImage(spr, 1, Common::Point(143, 177));
+
+	_vm->_screen->restoreScreen();
+	delete spr;
+}
+
+void MartianRoom::mainAreaClick() {
+}
+
+} // End of namespace Martian
+
+} // End of namespace Access
diff --git a/engines/access/martian/martian_room.h b/engines/access/martian/martian_room.h
new file mode 100644
index 0000000..526de56
--- /dev/null
+++ b/engines/access/martian/martian_room.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.
+ *
+ */
+
+#ifndef ACCESS_MARTIAN_ROOM_H
+#define ACCESS_MARTIAN_ROOM_H
+
+#include "common/scummsys.h"
+#include "access/room.h"
+
+namespace Access {
+
+class AccessEngine;
+
+namespace Martian {
+
+class MartianEngine;
+
+class MartianRoom : public Room {
+private:
+	MartianEngine *_game;
+
+	void roomSet();
+protected:
+	virtual void loadRoom(int roomNumber);
+
+	virtual void reloadRoom();
+
+	virtual void reloadRoom1();
+
+	virtual void roomMenu();
+
+	virtual void mainAreaClick();
+public:
+	MartianRoom(AccessEngine *vm);
+
+	virtual ~MartianRoom();
+};
+
+} // End of namespace Martian
+
+} // End of namespace Access
+
+#endif /* ACCESS_AMAZON_ROOM_H */
diff --git a/engines/access/martian/martian_scripts.cpp b/engines/access/martian/martian_scripts.cpp
new file mode 100644
index 0000000..0578872
--- /dev/null
+++ b/engines/access/martian/martian_scripts.cpp
@@ -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.
+ *
+ */
+
+#include "common/scummsys.h"
+#include "access/access.h"
+#include "access/martian/martian_game.h"
+#include "access/martian/martian_resources.h"
+#include "access/martian/martian_scripts.h"
+
+namespace Access {
+
+namespace Martian {
+
+MartianScripts::MartianScripts(AccessEngine *vm) : Scripts(vm) {
+	_game = (MartianEngine *)_vm;
+}
+
+void MartianScripts::executeSpecial(int commandIndex, int param1, int param2) {
+}
+
+typedef void(MartianScripts::*MartianScriptMethodPtr)();
+
+void MartianScripts::executeCommand(int commandIndex) {
+	Scripts::executeCommand(commandIndex);
+}
+
+} // End of namespace Martian
+
+} // End of namespace Access
diff --git a/engines/access/martian/martian_scripts.h b/engines/access/martian/martian_scripts.h
new file mode 100644
index 0000000..9f90643
--- /dev/null
+++ b/engines/access/martian/martian_scripts.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.
+ *
+ */
+
+#ifndef ACCESS_MARTIAN_SCRIPTS_H
+#define ACCESS_MARTIAN_SCRIPTS_H
+
+#include "common/scummsys.h"
+#include "access/scripts.h"
+
+namespace Access {
+
+namespace Martian {
+
+class MartianEngine;
+
+class MartianScripts: public Scripts {
+private:
+	MartianEngine *_game;
+protected:
+	virtual void executeSpecial(int commandIndex, int param1, int param2);
+	virtual void executeCommand(int commandIndex);
+public:
+	MartianScripts(AccessEngine *vm);
+};
+
+} // End of namespace Martian
+
+} // End of namespace Access
+
+#endif /* ACCESS_MARTIAN_SCRIPTS_H */
diff --git a/engines/access/module.mk b/engines/access/module.mk
index d74892c..46f9669 100644
--- a/engines/access/module.mk
+++ b/engines/access/module.mk
@@ -21,7 +21,11 @@ MODULE_OBJS := \
 	amazon/amazon_game.o \
 	amazon/amazon_resources.o \
 	amazon/amazon_room.o \
-	amazon/amazon_scripts.o
+	amazon/amazon_scripts.o \
+	martian/martian_game.o \
+	martian/martian_resources.o \
+	martian/martian_room.o \
+	martian/martian_scripts.o
 
 # This module can be built as a plugin
 ifeq ($(ENABLE_ACCESS), DYNAMIC_PLUGIN)


Commit: 966515a7d0f0e9bccc8ad2a761020372d4bae19f
    https://github.com/scummvm/scummvm/commit/966515a7d0f0e9bccc8ad2a761020372d4bae19f
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-21T07:44:41-04:00

Commit Message:
ACCESS: Fix room data loading for MM

Changed paths:
    engines/access/martian/martian_resources.cpp
    engines/access/room.cpp
    engines/access/room.h



diff --git a/engines/access/martian/martian_resources.cpp b/engines/access/martian/martian_resources.cpp
index 6e881f3..b596797 100644
--- a/engines/access/martian/martian_resources.cpp
+++ b/engines/access/martian/martian_resources.cpp
@@ -32,12 +32,12 @@ const char *const FILENAMES[] = {
 	"R08.AP", "R09.AP", "R10.AP", "R11.AP", "R12.AP", "R13.AP", "R14.AP", "R15.AP",
 	"R16.AP", "R17.AP", "R18.AP", "R19.AP", "R20.AP", "R21.AP", "R22.AP", "R23.AP",
 	"R24.AP", "R25.AP", "R26.AP", "R27.AP", "R28.AP", "R29.AP", "R30.AP", "R31.AP",
-	"R32.AP", "R34.AP", "R35.AP", "R36.AP", "R37.AP", "R38.AP", "R39.AP", "R40.AP",
-	"TITLE.AP","R42.AP","S01.AP", "R45.AP","SOUND.AP","MUSIC.AP","DEAD.AP","EST.AP",
-	"W02.AP", "C02.AP", "C05.AP", "C04.AP", "C10.AP", "C03.AP", "C07.AP", "LOVE.AP",
-	"CAFE.AP","C08.AP", "C18.AP", "C19.AP", "C21.AP", "C23.AP", "C12.AP", "C16.AP",
-	"CAFE1.AP","C05A.AP","C06.AP","C11.AP", "C13.AP", "C20.AP", "C16A.AP","C09.AP",
-	"R45.AP", "R46.AP", "R47.AP", "R48.AP", "R49.AP"
+	"R32.AP", "R33.AP", "R34.AP", "R35.AP", "R36.AP", "R37.AP", "R38.AP", "R39.AP", 
+	"R40.AP","TITLE.AP","R42.AP","S01.AP",  "R44.AP", "R45.AP","SOUND.AP","MUSIC.AP",
+	"DEAD.AP","EST.AP", "W02.AP", "C02.AP", "C05.AP", "C04.AP", "C10.AP", "C03.AP",
+	"C07.AP", "LOVE.AP","CAFE.AP","C08.AP", "C18.AP", "C19.AP", "C21.AP", "C23.AP", 
+	"C12.AP", "C16.AP","CAFE1.AP","C05A.AP","C06.AP","C11.AP", "C13.AP", "C20.AP", 
+	"C16A.AP","C09.AP", "R45.AP", "R46.AP", "R47.AP", "R48.AP", "R49.AP"
 };
 
 const byte MOUSE0[] = {
diff --git a/engines/access/room.cpp b/engines/access/room.cpp
index f45ffe7..0e6cba0 100644
--- a/engines/access/room.cpp
+++ b/engines/access/room.cpp
@@ -159,7 +159,7 @@ void Room::clearRoom() {
 }
 
 void Room::loadRoomData(const byte *roomData) {
-	RoomInfo roomInfo(roomData);
+	RoomInfo roomInfo(roomData, _vm->getGameID());
 
 	_roomFlag = roomInfo._roomFlag;
 
@@ -716,11 +716,16 @@ bool Room::checkCode(int v1, int v2) {
 
 /*------------------------------------------------------------------------*/
 
-RoomInfo::RoomInfo(const byte *data) {
+RoomInfo::RoomInfo(const byte *data, int gameType) {
 	Common::MemoryReadStream stream(data, 999);
 
 	_roomFlag = stream.readByte();
-	_estIndex = (int16)stream.readUint16LE();
+
+	if (gameType != GType_MartianMemorandum)
+		_estIndex = (int16)stream.readUint16LE();
+	else
+		_estIndex = -1;
+
 	_musicFile._fileNum = (int16)stream.readUint16LE();
 	_musicFile._subfile = stream.readUint16LE();
 	_scaleH1 = stream.readByte();
@@ -748,8 +753,7 @@ RoomInfo::RoomInfo(const byte *data) {
 	_paletteFile._subfile = stream.readUint16LE();
 	if (_paletteFile._fileNum == -1) {
 		_startColor = _numColors = 0;
-	}
-	else {
+	} else {
 		_startColor = stream.readUint16LE();
 		_numColors = stream.readUint16LE();
 	}
diff --git a/engines/access/room.h b/engines/access/room.h
index 9b3f922..e1a26a4 100644
--- a/engines/access/room.h
+++ b/engines/access/room.h
@@ -187,7 +187,7 @@ public:
 	Common::Array<uint32> _vidTable;
 	Common::Array<SoundIdent> _sounds;
 public:
-	RoomInfo(const byte *data);
+	RoomInfo(const byte *data, int gameType);
 };
 
 } // End of namespace Access


Commit: 8d1d1f6739b3b9f456d618a8740d754ddac2eb41
    https://github.com/scummvm/scummvm/commit/8d1d1f6739b3b9f456d618a8740d754ddac2eb41
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-21T21:03:44-04:00

Commit Message:
ACCESS: Fix displaying background in scrolling rooms

Changed paths:
    engines/access/room.cpp



diff --git a/engines/access/room.cpp b/engines/access/room.cpp
index 0e6cba0..83fcce1 100644
--- a/engines/access/room.cpp
+++ b/engines/access/room.cpp
@@ -256,15 +256,13 @@ void Room::setupRoom() {
 		_vm->_screen->_scrollX = 0;
 		_vm->_screen->_scrollCol = 0;
 	} else {
-		_vm->_screen->_scrollX = _vm->_player->_rawPlayer.x -
-			(_vm->_player->_rawPlayer.x >> 4);
-		int xp = MAX((_vm->_player->_rawPlayer.x >> 4) -
-			(_vm->_screen->_vWindowWidth / 2), 0);
-		_vm->_screen->_scrollCol = xp;
-
-		xp = xp + _vm->_screen->_vWindowWidth - _playFieldWidth;
-		if (xp >= 0) {
-			_vm->_screen->_scrollCol = xp + 1;
+		int xv = _vm->_player->_rawPlayer.x / TILE_WIDTH;
+		_vm->_screen->_scrollX = _vm->_player->_rawPlayer.x % TILE_WIDTH;
+		_vm->_screen->_scrollCol = MAX(xv - (_vm->_screen->_vWindowWidth / 2), 0);
+
+		int sx = _vm->_screen->_scrollCol + _vm->_screen->_vWindowWidth - _playFieldWidth;
+		if (sx >= 0) {
+			_vm->_screen->_scrollCol -= sx + 1;
 		}
 	}
 	


Commit: 41df7734db18cf1cb7a2fe4004e3adef98a8cb41
    https://github.com/scummvm/scummvm/commit/41df7734db18cf1cb7a2fe4004e3adef98a8cb41
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-21T22:15:00-04:00

Commit Message:
ACCESS: Standardise plotting methods and added comments

Changed paths:
    engines/access/access.cpp
    engines/access/asurface.cpp
    engines/access/asurface.h



diff --git a/engines/access/access.cpp b/engines/access/access.cpp
index 32835a0..ae03dfc 100644
--- a/engines/access/access.cpp
+++ b/engines/access/access.cpp
@@ -318,7 +318,7 @@ void AccessEngine::plotList1() {
 				if (ie._flags & 2) {
 					_buffer2.plotB(frame, Common::Point(bounds.left, bounds.top));
 				} else {
-					_buffer2.plotFrame(frame, Common::Point(bounds.left, bounds.top));
+					_buffer2.plotF(frame, Common::Point(bounds.left, bounds.top));
 				}
 			}
 		}
diff --git a/engines/access/asurface.cpp b/engines/access/asurface.cpp
index 44686ab..d3503ef 100644
--- a/engines/access/asurface.cpp
+++ b/engines/access/asurface.cpp
@@ -203,50 +203,10 @@ void ASurface::plotImage(SpriteResource *sprite, int frameNum, const Common::Poi
 		_lastBoundsW = r.width();
 		_lastBoundsH = r.height();
 
-		plotFrame(frame, pt);
+		plotF(frame, pt);
 	}
 }
 
-void ASurface::plotFrame(SpriteFrame *frame, const Common::Point &pt) {
-	frame->copyTo(this, pt);
-//	g_system->copyRectToScreen((byte *)getPixels(), 320, 0, 0, 320, 200);
-//	g_system->updateScreen();
-
-
-/*
-	byte *destP = (byte *)getBasePtr(pt.x, _scrollY + pt.y);
-	byte *srcP = frame->_data;
-	
-	int8 leftVal1 = 18;
-	int8 leftVal2 = -8;
-	if (_leftSkip) {
-		++leftVal2;
-		leftVal1 = -12;
-	}
-	int8 rightVal = (_rightSkip) ? -7 : -8;
-
-	// Skip over any lines of the frame
-	for (int yp = 0; yp < _topSkip; ++yp) {
-		srcP += *(srcP + 1) + 2;
-	}
-	
-	byte *srcLineP = srcP;
-	byte *destLineP = destP;
-	for (int yp = 0; yp < frame->h; ++yp, srcP = srcLineP, destP = destLineP) {
-		// Get length of line
-		int v = *srcP++;
-		int len = *srcP++;
-		srcLineP = srcP + len;
-		destLineP = destP + this->pitch;
-
-		// Draw the line of the frame
-		if (v != 0 || len != 0) {
-			warning("TODO: Line draw");
-		}
-	}
-	*/
-}
-
 void ASurface::copyTo(ASurface *dest, const Common::Point &destPos) {
 	for (int yp = 0; yp < h; ++yp) {
 		byte *srcP = (byte *)getBasePtr(0, yp);
@@ -305,22 +265,33 @@ void ASurface::copyTo(ASurface *dest, const Common::Rect &bounds) {
 	}
 }
 
-void ASurface::sPlotB(SpriteFrame *frame, const Common::Rect &bounds) {
+
+void ASurface::plotF(SpriteFrame *frame, const Common::Point &pt) {
+	frame->copyTo(this, pt);
+}
+
+void ASurface::plotB(SpriteFrame *frame, const Common::Point &pt) {
 	ASurface flippedFrame;
 	frame->flipHorizontal(flippedFrame);
-	flippedFrame.copyTo(this, bounds);
+	flippedFrame.copyTo(this, pt);
 }
 
 void ASurface::sPlotF(SpriteFrame *frame, const Common::Rect &bounds) {
 	frame->copyTo(this, bounds);
 }
 
-void ASurface::plotB(SpriteFrame *frame, const Common::Point &pt) {
-	frame->copyTo(this, pt);
+void ASurface::sPlotB(SpriteFrame *frame, const Common::Rect &bounds) {
+	ASurface flippedFrame;
+	frame->flipHorizontal(flippedFrame);
+	flippedFrame.copyTo(this, bounds);
 }
 
 void ASurface::copyBlock(ASurface *src, const Common::Rect &bounds) {
-	copyRectToSurface(*src, bounds.left, bounds.top, bounds);
+	Common::Rect r = bounds;
+	r.clip(Common::Rect(0, 0, this->w, this->h));
+
+	if (r.isValidRect())
+		copyRectToSurface(*src, r.left, r.top, r);
 }
 
 void ASurface::saveBlock(const Common::Rect &bounds) {
diff --git a/engines/access/asurface.h b/engines/access/asurface.h
index 88e1561..be3597d 100644
--- a/engines/access/asurface.h
+++ b/engines/access/asurface.h
@@ -54,8 +54,6 @@ public:
 
 	static void init();
 public:
-	virtual void plotFrame(SpriteFrame *frame, const Common::Point &pt);
-public:
 	virtual ~ASurface();
 
 	void create(uint16 width, uint16 height);
@@ -69,15 +67,23 @@ public:
 	void plotImage(SpriteResource *sprite, int frameNum, const Common::Point &pt);
 
 	/**
-	 * Scaled draw frame
+	 * Scaled draw frame in forward orientation
 	 */
 	void sPlotF(SpriteFrame *frame, const Common::Rect &bounds);
 
 	/**
-	 * Scaled flipped horizontal draw frame
+	 * Scaled draw frame in backwards orientation
 	 */
 	void sPlotB(SpriteFrame *frame, const Common::Rect &bounds);
 
+	/**
+	 * Draw an image full-size in forward orientation
+	 */
+	void plotF(SpriteFrame *frame, const Common::Point &pt);
+
+	/**
+	 * Draw an image full-size in backwards orientation
+	 */
 	void plotB(SpriteFrame *frame, const Common::Point &pt);
 
 	void copyBlock(ASurface *src, const Common::Rect &bounds);


Commit: e5130bcc6c2c813fa2ab9238fce277f51a999990
    https://github.com/scummvm/scummvm/commit/e5130bcc6c2c813fa2ab9238fce277f51a999990
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-22T22:15:53-04:00

Commit Message:
ACCESS: Remapping of plotting methods

Changed paths:
    engines/access/asurface.cpp



diff --git a/engines/access/asurface.cpp b/engines/access/asurface.cpp
index d3503ef..f023f93 100644
--- a/engines/access/asurface.cpp
+++ b/engines/access/asurface.cpp
@@ -267,13 +267,11 @@ void ASurface::copyTo(ASurface *dest, const Common::Rect &bounds) {
 
 
 void ASurface::plotF(SpriteFrame *frame, const Common::Point &pt) {
-	frame->copyTo(this, pt);
+	sPlotF(frame, Common::Rect(pt.x, pt.y, pt.x + frame->w, pt.y + frame->h));
 }
 
 void ASurface::plotB(SpriteFrame *frame, const Common::Point &pt) {
-	ASurface flippedFrame;
-	frame->flipHorizontal(flippedFrame);
-	flippedFrame.copyTo(this, pt);
+	sPlotB(frame, Common::Rect(pt.x, pt.y, pt.x + frame->w, pt.y + frame->h));
 }
 
 void ASurface::sPlotF(SpriteFrame *frame, const Common::Rect &bounds) {
@@ -287,11 +285,10 @@ void ASurface::sPlotB(SpriteFrame *frame, const Common::Rect &bounds) {
 }
 
 void ASurface::copyBlock(ASurface *src, const Common::Rect &bounds) {
-	Common::Rect r = bounds;
-	r.clip(Common::Rect(0, 0, this->w, this->h));
+	Common::Rect destBounds = bounds;
+	//destBounds.translate(src->_scrollX, src->_scrollY);
 
-	if (r.isValidRect())
-		copyRectToSurface(*src, r.left, r.top, r);
+	copyRectToSurface(*src, destBounds.left, destBounds.top, bounds);
 }
 
 void ASurface::saveBlock(const Common::Rect &bounds) {


Commit: b4d2484633e80ac2a1caccfedb51980cd7926c11
    https://github.com/scummvm/scummvm/commit/b4d2484633e80ac2a1caccfedb51980cd7926c11
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-22T22:55:17-04:00

Commit Message:
ACCESS: Fixes for drawing scrolling scenes

Changed paths:
    engines/access/asurface.cpp
    engines/access/asurface.h
    engines/access/room.cpp
    engines/access/screen.cpp
    engines/access/screen.h



diff --git a/engines/access/asurface.cpp b/engines/access/asurface.cpp
index f023f93..e88bd27 100644
--- a/engines/access/asurface.cpp
+++ b/engines/access/asurface.cpp
@@ -152,7 +152,7 @@ bool ASurface::clip(Common::Rect &r) {
 	_leftSkip = _rightSkip = 0;
 	_topSkip = _bottomSkip = 0;
 
-	if (r.left > _clipWidth) {
+	if (r.left > _clipWidth || r.left < 0) {
 		if (r.left >= 0)
 			return true;
 
@@ -171,7 +171,7 @@ bool ASurface::clip(Common::Rect &r) {
 		_rightSkip = skip;
 	}
 
-	if (r.top > _clipHeight) {
+	if (r.top > _clipHeight || r.top < 0) {
 		if (r.top >= 0)
 			return true;
 
@@ -285,10 +285,7 @@ void ASurface::sPlotB(SpriteFrame *frame, const Common::Rect &bounds) {
 }
 
 void ASurface::copyBlock(ASurface *src, const Common::Rect &bounds) {
-	Common::Rect destBounds = bounds;
-	//destBounds.translate(src->_scrollX, src->_scrollY);
-
-	copyRectToSurface(*src, destBounds.left, destBounds.top, bounds);
+	copyRectToSurface(*src, bounds.left, bounds.top, bounds);
 }
 
 void ASurface::saveBlock(const Common::Rect &bounds) {
diff --git a/engines/access/asurface.h b/engines/access/asurface.h
index be3597d..84fe90d 100644
--- a/engines/access/asurface.h
+++ b/engines/access/asurface.h
@@ -86,7 +86,7 @@ public:
 	 */
 	void plotB(SpriteFrame *frame, const Common::Point &pt);
 
-	void copyBlock(ASurface *src, const Common::Rect &bounds);
+	virtual void copyBlock(ASurface *src, const Common::Rect &bounds);
 
 	void copyTo(ASurface *dest, const Common::Point &destPos);
 
diff --git a/engines/access/room.cpp b/engines/access/room.cpp
index 83fcce1..225cd80 100644
--- a/engines/access/room.cpp
+++ b/engines/access/room.cpp
@@ -296,6 +296,10 @@ void Room::buildScreen() {
 	int cnt = _vm->_screen->_vWindowWidth + 1;
 	int offset = 0;
 
+	// Clear current background buffer
+	_vm->_buffer1.clearBuffer();
+
+	// Loop through drawing each column of tiles forming the background
 	for (int idx = 0; idx < cnt; offset += TILE_WIDTH, ++idx) {
 		buildColumn(_vm->_screen->_scrollCol, offset);
 		++_vm->_screen->_scrollCol;
diff --git a/engines/access/screen.cpp b/engines/access/screen.cpp
index 3092d7e..af97e2e 100644
--- a/engines/access/screen.cpp
+++ b/engines/access/screen.cpp
@@ -236,4 +236,11 @@ void Screen::moveBufferUp() {
 	error("TODO: UP");
 }
 
+void Screen::copyBlock(ASurface *src, const Common::Rect &bounds) {
+	Common::Rect destBounds = bounds;
+	destBounds.translate(_windowXAdd, _windowYAdd + _screenYOff);
+
+	copyRectToSurface(*src, destBounds.left, destBounds.top, bounds);
+}
+
 } // End of namespace Access
diff --git a/engines/access/screen.h b/engines/access/screen.h
index 98e77b4..e66a7a3 100644
--- a/engines/access/screen.h
+++ b/engines/access/screen.h
@@ -80,6 +80,8 @@ public:
 	int _vWindowLinesTall;
 	bool _screenChangeFlag;
 public:
+	virtual void copyBlock(ASurface *src, const Common::Rect &bounds);
+public:
 	Screen(AccessEngine *vm);
 
 	virtual ~Screen() {}


Commit: 44436def8328accecf756d34103f5322d0fe0f6f
    https://github.com/scummvm/scummvm/commit/44436def8328accecf756d34103f5322d0fe0f6f
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-22T22:58:44-04:00

Commit Message:
ACCESS: Stop player moving when scene changes

Changed paths:
    engines/access/amazon/amazon_room.cpp



diff --git a/engines/access/amazon/amazon_room.cpp b/engines/access/amazon/amazon_room.cpp
index 79c70c0..bc0f605 100644
--- a/engines/access/amazon/amazon_room.cpp
+++ b/engines/access/amazon/amazon_room.cpp
@@ -114,7 +114,11 @@ void AmazonRoom::reloadRoom1() {
 		_vm->copyBF2Vid();
 	}
 
+	// Stop player moving
+	_vm->_player->_playerMove = false;
 	_vm->_player->_frame = 0;
+
+	// Clear any dirty rects from the old scene
 	_vm->_oldRects.clear();
 	_vm->_newRects.clear();
 }


Commit: 6343ff72c462219afb2f11fea69539725794efd6
    https://github.com/scummvm/scummvm/commit/6343ff72c462219afb2f11fea69539725794efd6
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-23T10:21:50-04:00

Commit Message:
ACCESS: Fix cursor positioning in scrolled screens, and background restores

Changed paths:
    engines/access/amazon/amazon_room.cpp
    engines/access/bubble_box.cpp
    engines/access/events.cpp
    engines/access/events.h
    engines/access/room.cpp



diff --git a/engines/access/amazon/amazon_room.cpp b/engines/access/amazon/amazon_room.cpp
index bc0f605..c0076fd 100644
--- a/engines/access/amazon/amazon_room.cpp
+++ b/engines/access/amazon/amazon_room.cpp
@@ -146,10 +146,13 @@ void AmazonRoom::roomMenu() {
 }
 
 void AmazonRoom::mainAreaClick() {
+	Common::Point &mousePos = _vm->_events->_mousePos;
+	Common::Point pt = _vm->_events->calcRawMouse();
+
 	if (_selectCommand == -1) {
 		if (_vm->_player->_roomNumber == 42 || _vm->_player->_roomNumber == 44 ||
 				_vm->_player->_roomNumber == 31 || _vm->_player->_roomNumber == 29) {
-			switch (checkBoxes1(_vm->_events->_mousePos)) {
+			switch (checkBoxes1(pt)) {
 			case 0:
 				_game->_jasMayaFlag = 0;
 				return;
@@ -161,13 +164,13 @@ void AmazonRoom::mainAreaClick() {
 			}
 		} 
 
-		_vm->_player->_moveTo = _vm->_events->_mousePos;
+		_vm->_player->_moveTo = pt;
 		_vm->_player->_playerMove = true;
-	} else if (_vm->_events->_mousePos.x >= _vm->_screen->_windowXAdd &&
-			_vm->_events->_mousePos.x <= _vm->_screen->_vWindowBytesWide &&
-			_vm->_events->_mousePos.y >= _vm->_screen->_windowYAdd &&
-			_vm->_events->_mousePos.y <= _vm->_screen->_vWindowLinesTall) {
-		if (checkBoxes1(_vm->_events->_mousePos) >= 0) {
+	} else if (mousePos.x >= _vm->_screen->_windowXAdd &&
+			mousePos.x <= _vm->_screen->_vWindowBytesWide &&
+			mousePos.y >= _vm->_screen->_windowYAdd &&
+			mousePos.y <= _vm->_screen->_vWindowLinesTall) {
+		if (checkBoxes1(pt) >= 0) {
 			checkBoxes3();
 		}
 	}
diff --git a/engines/access/bubble_box.cpp b/engines/access/bubble_box.cpp
index 21e1040..a709fbd 100644
--- a/engines/access/bubble_box.cpp
+++ b/engines/access/bubble_box.cpp
@@ -236,7 +236,7 @@ void BubbleBox::doBox(int item, int box) {
 	screen.plotImage(icons, (_type == TYPE_4) ? 73 : 23, Common::Point(xp, yp));
 
 	if (_type == TYPE_4) {
-		// Further stuff
+		// Further stuff for filename dialog
 		error("TODO: Box type 4");
 	}
 
@@ -264,6 +264,7 @@ void BubbleBox::doBox(int item, int box) {
 	fonts._printStart = printStart;
 	_charCol = charCol;
 	_rowOff = rowOff;
+	_vm->_screen->restoreScreen();
 	
 	// Free icons data
 	delete icons;
diff --git a/engines/access/events.cpp b/engines/access/events.cpp
index 1afc551..78bbdbf 100644
--- a/engines/access/events.cpp
+++ b/engines/access/events.cpp
@@ -217,4 +217,16 @@ void EventsManager::waitKeyMouse() {
 	debounceLeft();
 }
 
+Common::Point EventsManager::calcRawMouse() {
+	Screen &screen = *_vm->_screen;
+	Common::Point pt;
+	pt.x = _mousePos.x - screen._windowXAdd +
+		(screen._scrollCol * TILE_WIDTH) + screen._scrollX;
+	pt.y = _mousePos.y - screen._screenYOff - screen._windowYAdd +
+		(screen._scrollRow * TILE_HEIGHT) + screen._scrollY;
+
+	return pt;
+}
+
+
 } // End of namespace Access
diff --git a/engines/access/events.h b/engines/access/events.h
index f7a5e9c..2ced71f 100644
--- a/engines/access/events.h
+++ b/engines/access/events.h
@@ -105,6 +105,10 @@ public:
 	void debounceLeft();
 
 	void waitKeyMouse();
+
+	Common::Point &getMousePos() { return _mousePos; }
+
+	Common::Point calcRawMouse();
 };
 
 } // End of namespace Access
diff --git a/engines/access/room.cpp b/engines/access/room.cpp
index 225cd80..b5f8554 100644
--- a/engines/access/room.cpp
+++ b/engines/access/room.cpp
@@ -556,8 +556,10 @@ int Room::checkBoxes2(const Common::Point &pt, int start, int count) {
 }
 
 void Room::checkBoxes3() {
+	Common::Point pt = _vm->_events->calcRawMouse();
+
 	for (uint start = 0; start < _plotter._blocks.size(); ++start) {
-		if (_plotter._blocks[start].contains(_vm->_events->_mousePos)) {
+		if (_plotter._blocks[start].contains(pt)) {
 			_plotter._blockIn = start;
 			if (!(validateBox(start) & 0x80)) {
 				_vm->_events->debounceLeft();


Commit: 7aa2c7fe5cca8eaa9c68c471cef4595b99021206
    https://github.com/scummvm/scummvm/commit/7aa2c7fe5cca8eaa9c68c471cef4595b99021206
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-23T12:09:27-04:00

Commit Message:
ACCESS: Beginnings of character/converse manager

Changed paths:
  A engines/access/char.cpp
  A engines/access/char.h
    engines/access/access.cpp
    engines/access/access.h
    engines/access/data.h
    engines/access/module.mk
    engines/access/room.cpp
    engines/access/room.h
    engines/access/scripts.cpp
    engines/access/scripts.h



diff --git a/engines/access/access.cpp b/engines/access/access.cpp
index ae03dfc..c84ac8b 100644
--- a/engines/access/access.cpp
+++ b/engines/access/access.cpp
@@ -34,6 +34,7 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc)
 		_useItem(_flags[100]), _startup(_flags[170]), _manScaleOff(_flags[172]) {
 	_animation = nullptr;
 	_bubbleBox = nullptr;
+	_char = nullptr;
 	_debugger = nullptr;
 	_events = nullptr;
 	_files = nullptr;
@@ -106,6 +107,7 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc)
 AccessEngine::~AccessEngine() {
 	delete _animation;
 	delete _bubbleBox;
+	delete _char;
 	delete _debugger;
 	delete _events;
 	delete _files;
@@ -147,6 +149,7 @@ void AccessEngine::initialize() {
 	ASurface::init();
 	_animation = new AnimationManager(this);
 	_bubbleBox = new BubbleBox(this);
+	_char = new CharManager(this);
 	_debugger = new Debugger(this);
 	_events = new EventsManager(this);
 	_files = new FileManager(this);
@@ -197,7 +200,7 @@ int AccessEngine::getRandomNumber(int maxNumber) {
 	return _randomSource.getRandomNumber(maxNumber);
 }
 
-void AccessEngine::loadCells(Common::Array<RoomInfo::CellIdent> &cells) {
+void AccessEngine::loadCells(Common::Array<CellIdent> &cells) {
 	for (uint i = 0; i < cells.size(); ++i) {
 		byte *spriteData = _files->loadFile(cells[i]._fileNum, cells[i]._subfile);
 		_objectsTable[cells[i]._cell] = new SpriteResource(this, 
@@ -371,4 +374,8 @@ void AccessEngine::freeChar() {
 	_animation->freeAnimationData();
 }
 
+void AccessEngine::loadChar(int charId) {
+	
+}
+
 } // End of namespace Access
diff --git a/engines/access/access.h b/engines/access/access.h
index 2185916..9742772 100644
--- a/engines/access/access.h
+++ b/engines/access/access.h
@@ -32,6 +32,7 @@
 #include "graphics/surface.h"
 #include "access/animation.h"
 #include "access/bubble_box.h"
+#include "access/char.h"
 #include "access/data.h"
 #include "access/debugger.h"
 #include "access/events.h"
@@ -108,6 +109,7 @@ protected:
 public:
 	AnimationManager *_animation;
 	BubbleBox *_bubbleBox;
+	CharManager *_char;
 	Debugger *_debugger;
 	EventsManager *_events;
 	FileManager *_files;
@@ -122,6 +124,7 @@ public:
 	ASurface *_current;
 	ASurface _buffer1;
 	ASurface _buffer2;
+	Common::Array<CharEntry *> _charTable;
 	SpriteResource *_objectsTable[100];
 	int _establishTable[100];
 	bool _establishFlag;
@@ -204,7 +207,7 @@ public:
 
 	int getRandomNumber(int maxNumber);
 
-	void loadCells(Common::Array<RoomInfo::CellIdent> &cells);
+	void loadCells(Common::Array<CellIdent> &cells);
 
 	/**
 	* Free the sprites list
@@ -236,6 +239,8 @@ public:
 	void doLoadSave();
 
 	void freeChar();
+
+	void loadChar(int charId);
 };
 
 } // End of namespace Access
diff --git a/engines/access/char.cpp b/engines/access/char.cpp
new file mode 100644
index 0000000..a01643b
--- /dev/null
+++ b/engines/access/char.cpp
@@ -0,0 +1,89 @@
+/* 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 "common/memstream.h"
+#include "access/access.h"
+#include "access/char.h"
+#include "access/amazon/amazon_resources.h"
+
+namespace Access {
+
+CharEntry::CharEntry(const byte *data) {
+	Common::MemoryReadStream s(data, 999);
+
+	_charFlag = s.readByte();
+	_estabFlag = s.readSint16LE();
+	_screenFile._fileNum = s.readSint16LE();
+	_screenFile._subfile = s.readSint16LE();
+
+	_paletteFile._fileNum = s.readSint16LE();
+	_paletteFile._subfile = s.readUint16LE();
+	_startColor = s.readUint16LE();
+	_numColors = s.readUint16LE();
+
+	// Load cells
+	for (byte cell = s.readByte(); cell != 0xff; cell = s.readByte()) {
+		CellIdent ci;
+		ci._cell = cell;
+		ci._fileNum = s.readSint16LE();
+		ci._subfile = s.readUint16LE();
+
+		_cells.push_back(ci);
+	}
+
+	_animFile._fileNum = s.readSint16LE();
+	_animFile._subfile = s.readUint16LE();
+	_scriptFile._fileNum = s.readSint16LE();
+	_scriptFile._subfile = s.readUint16LE();
+
+	for (int16 v = s.readSint16LE(); v != -1; v = s.readSint16LE()) {
+		ExtraCell ec;
+		ec._vidTable = v;
+		ec._vidTable1 = s.readSint16LE();
+		ec._vidSTable = s.readSint16LE();
+		ec._vidSTable1 = s.readSint16LE();
+
+		_extraCells.push_back(ec);
+	}
+}
+
+CharEntry::CharEntry() {
+	_charFlag = 0;
+	_estabFlag = 0;
+	_startColor = _numColors = 0;
+}
+
+/*------------------------------------------------------------------------*/
+
+CharManager::CharManager(AccessEngine *vm) : Manager(vm) {
+	switch (vm->getGameID()) {
+	case GType_Amazon:
+		// Setup character list
+		for (int i = 0; i < 37; ++i)
+			_charTable.push_back(CharEntry(Amazon::CHARTBL[i]));
+		break;
+	default:
+		error("Unknown game");
+	}
+}
+
+} // End of namespace Access
diff --git a/engines/access/char.h b/engines/access/char.h
new file mode 100644
index 0000000..8d6c49d
--- /dev/null
+++ b/engines/access/char.h
@@ -0,0 +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.
+ *
+ */
+
+#ifndef ACCESS_CHAR_H
+#define ACCESS_CHAR_H
+
+#include "common/scummsys.h"
+#include "common/array.h"
+#include "access/data.h"
+
+namespace Access {
+
+class CharEntry {
+public:
+	int _charFlag;
+	int _estabFlag;
+	FileIdent _screenFile;
+	FileIdent _paletteFile;
+	int _startColor, _numColors;
+	Common::Array<CellIdent> _cells;
+	FileIdent _animFile;
+	FileIdent _scriptFile;
+	Common::Array<ExtraCell> _extraCells;
+public:
+	CharEntry(const byte *data);
+
+	CharEntry();
+};
+
+class CharManager: public Manager {
+public:
+	Common::Array<CharEntry> _charTable;
+public:
+	CharManager(AccessEngine *vm);
+};
+
+} // End of namespace Access
+
+#endif /* ACCESS_CHAR_H */
diff --git a/engines/access/data.h b/engines/access/data.h
index 1601c68..c10b2b7 100644
--- a/engines/access/data.h
+++ b/engines/access/data.h
@@ -40,6 +40,20 @@ public:
 	Manager(AccessEngine *vm) : _vm(vm) {}
 };
 
+struct FileIdent {
+	int _fileNum;
+	int _subfile;
+
+	FileIdent() {
+		_fileNum = -1;
+		_subfile = 0;
+	}
+};
+
+struct CellIdent : FileIdent {
+	byte _cell;
+};
+
 struct TimerEntry {
 	int _initTm;
 	int _timer;
diff --git a/engines/access/module.mk b/engines/access/module.mk
index 46f9669..31f0760 100644
--- a/engines/access/module.mk
+++ b/engines/access/module.mk
@@ -5,6 +5,7 @@ MODULE_OBJS := \
 	asurface.o \
 	access.o \
 	bubble_box.o \
+	char.o \
 	data.o \
 	debugger.o \
 	decompress.o \
diff --git a/engines/access/room.cpp b/engines/access/room.cpp
index b5f8554..d703114 100644
--- a/engines/access/room.cpp
+++ b/engines/access/room.cpp
@@ -227,13 +227,8 @@ void Room::loadRoomData(const byte *roomData) {
 
 	// Load extra cells
 	_vm->_extraCells.clear();
-	for (uint i = 0; i < roomInfo._vidTable.size(); ++i) {
-		ExtraCell ec;
-		ec._vidTable = roomInfo._vidTable[i] & 0xffff;
-		ec._vidTable1 = roomInfo._vidTable[i] >> 16;
-
-		_vm->_extraCells.push_back(ec);
-	}
+	for (uint i = 0; i < roomInfo._extraCells.size(); ++i)
+		_vm->_extraCells.push_back(roomInfo._extraCells[i]);
 
 	// Load sounds for the scene
 	_vm->_sound->loadSounds(roomInfo._sounds);
@@ -726,34 +721,34 @@ RoomInfo::RoomInfo(const byte *data, int gameType) {
 	_roomFlag = stream.readByte();
 
 	if (gameType != GType_MartianMemorandum)
-		_estIndex = (int16)stream.readUint16LE();
+		_estIndex = stream.readSint16LE();
 	else
 		_estIndex = -1;
 
-	_musicFile._fileNum = (int16)stream.readUint16LE();
+	_musicFile._fileNum = stream.readSint16LE();
 	_musicFile._subfile = stream.readUint16LE();
 	_scaleH1 = stream.readByte();
 	_scaleH2 = stream.readByte();
 	_scaleN1 = stream.readByte();
-	_playFieldFile._fileNum = (int16)stream.readUint16LE();
+	_playFieldFile._fileNum = stream.readSint16LE();
 	_playFieldFile._subfile = stream.readUint16LE();
 
 	for (byte cell = stream.readByte(); cell != 0xff; cell = stream.readByte()) {
 		CellIdent ci;
 		ci._cell = cell;
-		ci._fileNum = (int16)stream.readUint16LE();
+		ci._fileNum = stream.readSint16LE();
 		ci._subfile = stream.readUint16LE();
 
 		_cells.push_back(ci);
 	}
 
-	_scriptFile._fileNum = (int16)stream.readUint16LE();
+	_scriptFile._fileNum = stream.readSint16LE();
 	_scriptFile._subfile = stream.readUint16LE();
-	_animFile._fileNum = (int16)stream.readUint16LE();
+	_animFile._fileNum = stream.readSint16LE();
 	_animFile._subfile = stream.readUint16LE();
 	_scaleI = stream.readByte();
 	_scrollThreshold = stream.readByte();
-	_paletteFile._fileNum = (int16)stream.readUint16LE();
+	_paletteFile._fileNum = stream.readSint16LE();
 	_paletteFile._subfile = stream.readUint16LE();
 	if (_paletteFile._fileNum == -1) {
 		_startColor = _numColors = 0;
@@ -762,15 +757,18 @@ RoomInfo::RoomInfo(const byte *data, int gameType) {
 		_numColors = stream.readUint16LE();
 	}
 
-	for (int16 v = (int16)stream.readUint16LE(); v != -1;
-		v = (int16)stream.readUint16LE()) {
-		uint16 v2 = stream.readUint16LE();
+	for (int16 v = stream.readSint16LE(); v != -1; v = stream.readSint16LE()) {
+		ExtraCell ec;
+		ec._vidTable = v;
+		ec._vidTable1 = stream.readSint16LE();
+		ec._vidSTable = stream.readSint16LE();
+		ec._vidSTable1 = stream.readSint16LE();
 
-		_vidTable.push_back(v | ((uint32)v2 << 16));
+		_extraCells.push_back(ec);
 	}
 
-	for (int16 fileNum = (int16)stream.readUint16LE(); fileNum != -1;
-		fileNum = (int16)stream.readUint16LE()) {
+	for (int16 fileNum = stream.readSint16LE(); fileNum != -1;
+		fileNum = stream.readSint16LE()) {
 		SoundIdent fi;
 		fi._fileNum = fileNum;
 		fi._subfile = stream.readUint16LE();
diff --git a/engines/access/room.h b/engines/access/room.h
index e1a26a4..4029095 100644
--- a/engines/access/room.h
+++ b/engines/access/room.h
@@ -156,15 +156,6 @@ public:
 
 class RoomInfo {
 public:
-	struct FileIdent {
-		int _fileNum;
-		int _subfile;
-	};
-
-	struct CellIdent : FileIdent {
-		byte _cell;
-	};
-	
 	struct SoundIdent : FileIdent {
 		int _priority;
 	};
@@ -184,7 +175,7 @@ public:
 	FileIdent _paletteFile;
 	int _startColor;
 	int _numColors;
-	Common::Array<uint32> _vidTable;
+	Common::Array<ExtraCell> _extraCells;
 	Common::Array<SoundIdent> _sounds;
 public:
 	RoomInfo(const byte *data, int gameType);
diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp
index f687958..f4934d4 100644
--- a/engines/access/scripts.cpp
+++ b/engines/access/scripts.cpp
@@ -99,7 +99,7 @@ void Scripts::executeCommand(int commandIndex) {
 		&Scripts::cmdPrint, &Scripts::cmdRetPos, &Scripts::cmdAnim,
 		&Scripts::cmdSetFlag, &Scripts::cmdCheckFlag, &Scripts::cmdGoto, 
 		&Scripts::cmdSetInventory, &Scripts::cmdSetInventory, &Scripts::cmdCheckInventory, 
-		&Scripts::cmdSetTex, &Scripts::cmdNewRoom, &Scripts::CMDCONVERSE, 
+		&Scripts::cmdSetTex, &Scripts::cmdNewRoom, &Scripts::cmdConverse, 
 		&Scripts::cmdCheckFrame, &Scripts::cmdCheckAnim, &Scripts::cmdSnd, 
 		&Scripts::cmdRetNeg, &Scripts::cmdRetPos, &Scripts::cmdCheckLoc, 
 		&Scripts::cmdSetAnim, &Scripts::cmdDispInv, &Scripts::cmdSetTimer, 
@@ -309,7 +309,22 @@ void Scripts::cmdNewRoom() {
 	cmdRetPos();
 }
 
-void Scripts::CMDCONVERSE() { error("TODO CMDCONVERSE"); }
+void Scripts::cmdConverse() { 
+	_vm->_conversation = _data->readUint16LE();
+	_vm->_room->clearRoom();
+	_vm->freeChar();
+	_vm->loadChar(_vm->_conversation);
+	_vm->_events->setCursor(CURSOR_ARROW);
+
+	_vm->_images.clear();
+	_vm->_oldRects.clear();
+	_sequence = 0;
+	searchForSequence();
+
+	if (_vm->_screen->_vesaMode) {
+		_vm->_converseMode = 1;
+	}
+}
 
 void Scripts::cmdCheckFrame() {
 	int id = _data->readUint16LE();
diff --git a/engines/access/scripts.h b/engines/access/scripts.h
index 4b224c3..ae4c755 100644
--- a/engines/access/scripts.h
+++ b/engines/access/scripts.h
@@ -79,7 +79,7 @@ protected:
 	void cmdCheckInventory();
 	void cmdSetTex();
 	void cmdNewRoom();
-	void CMDCONVERSE();
+	void cmdConverse();
 	void cmdCheckFrame();
 	void cmdCheckAnim();
 	void cmdSnd();


Commit: 31c8a524a35c19291bbd7bed3d117791a90c7401
    https://github.com/scummvm/scummvm/commit/31c8a524a35c19291bbd7bed3d117791a90c7401
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-23T13:13:56-04:00

Commit Message:
ACCESS: More implementation of CharManager

Changed paths:
    engines/access/access.cpp
    engines/access/access.h
    engines/access/char.cpp
    engines/access/char.h
    engines/access/room.cpp
    engines/access/room.h
    engines/access/screen.h
    engines/access/scripts.cpp



diff --git a/engines/access/access.cpp b/engines/access/access.cpp
index c84ac8b..0718fd6 100644
--- a/engines/access/access.cpp
+++ b/engines/access/access.cpp
@@ -62,7 +62,6 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc)
 	_startup = 0;
 	_currentCharFlag = false;
 	_boxSelect = false;
-	_charFlag = 0;
 	_scale = 0;
 	_scaleH1 = _scaleH2 = 0;
 	_scaleN1 = 0;
@@ -78,7 +77,7 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc)
 	_intTim[3] = 0;
 	_timer[3] = 0;
 	Common::fill(&_objectsTable[0], &_objectsTable[100], (SpriteResource *)nullptr);
-	Common::fill(&_establishTable[0], &_establishTable[100], 0);
+	Common::fill(&_establishTable[0], &_establishTable[100], false);
 	Common::fill(&_flags[0], &_flags[256], 0);
 	_establishFlag = false;
 	_establishMode = 0;
@@ -220,15 +219,15 @@ void AccessEngine::freeInactiveData() {
 	_inactive = nullptr;
 }
 
-void AccessEngine::establish(int v1, int sub) {
+void AccessEngine::establish(int esatabIndex, int sub) {
 	_establishMode = 0;
 	_establishGroup = 0;
-	doEstablish(v1, sub);
+	doEstablish(esatabIndex, sub);
 }
 
-void AccessEngine::establishCenter(int v1, int sub) {
+void AccessEngine::establishCenter(int esatabIndex, int sub) {
 	_establishMode = 1;
-	doEstablish(v1, sub);
+	doEstablish(esatabIndex, sub);
 }
 
 byte *AccessEngine::loadEstablish(int sub) {
@@ -236,17 +235,19 @@ byte *AccessEngine::loadEstablish(int sub) {
 	return nullptr;
 }
 
-void AccessEngine::doEstablish(int v1, int sub) {
+void AccessEngine::doEstablish(int esatabIndex, int sub) {
+	_establishMode = 1;
+
 	_screen->forceFadeOut();
 	_screen->clearScreen();
 	_screen->setPanel(3);
 
-	if (v1 != -1) {
-		_files->loadScreen(95, v1);
+	if (esatabIndex != -1) {
+		_files->loadScreen(95, esatabIndex);
 		_buffer2.copyBuffer(_screen);
 	}
 
-	_room->setIconPalette();
+	_screen->setIconPalette();
 	_screen->forceFadeIn();
 
 	_fonts._charSet._lo = 1;
@@ -374,8 +375,4 @@ void AccessEngine::freeChar() {
 	_animation->freeAnimationData();
 }
 
-void AccessEngine::loadChar(int charId) {
-	
-}
-
 } // End of namespace Access
diff --git a/engines/access/access.h b/engines/access/access.h
index 9742772..2e2358f 100644
--- a/engines/access/access.h
+++ b/engines/access/access.h
@@ -88,7 +88,7 @@ private:
 
 	void dummyLoop();
 
-	void doEstablish(int v1, int sub);
+	void doEstablish(int esatabIndex, int sub);
 protected:
 	const AccessGameDescription *_gameDescription;
 	Common::RandomSource _randomSource;
@@ -126,7 +126,7 @@ public:
 	ASurface _buffer2;
 	Common::Array<CharEntry *> _charTable;
 	SpriteResource *_objectsTable[100];
-	int _establishTable[100];
+	bool _establishTable[100];
 	bool _establishFlag;
 	int _establishMode;
 	int _establishGroup;
@@ -150,7 +150,6 @@ public:
 	int _startTravelBox;
 	bool _currentCharFlag;
 	bool _boxSelect;
-	int _charFlag;
 	int _scale;
 	int _scaleH1, _scaleH2;
 	int _scaleN1;
@@ -221,9 +220,9 @@ public:
 
 	byte *AccessEngine::loadEstablish(int sub);
 
-	void establish(int v1, int sub);
+	void establish(int esatabIndex, int sub);
 
-	void establishCenter(int v1, int sub);
+	void establishCenter(int esatabIndex, int sub);
 
 	void plotList();
 	void plotList1();
@@ -239,8 +238,6 @@ public:
 	void doLoadSave();
 
 	void freeChar();
-
-	void loadChar(int charId);
 };
 
 } // End of namespace Access
diff --git a/engines/access/char.cpp b/engines/access/char.cpp
index a01643b..40f3bf3 100644
--- a/engines/access/char.cpp
+++ b/engines/access/char.cpp
@@ -31,7 +31,7 @@ CharEntry::CharEntry(const byte *data) {
 	Common::MemoryReadStream s(data, 999);
 
 	_charFlag = s.readByte();
-	_estabFlag = s.readSint16LE();
+	_estabIndex = s.readSint16LE();
 	_screenFile._fileNum = s.readSint16LE();
 	_screenFile._subfile = s.readSint16LE();
 
@@ -68,7 +68,7 @@ CharEntry::CharEntry(const byte *data) {
 
 CharEntry::CharEntry() {
 	_charFlag = 0;
-	_estabFlag = 0;
+	_estabIndex = 0;
 	_startColor = _numColors = 0;
 }
 
@@ -84,6 +84,69 @@ CharManager::CharManager(AccessEngine *vm) : Manager(vm) {
 	default:
 		error("Unknown game");
 	}
+
+	_charFlag = 0;
+}
+
+void CharManager::loadChar(int charId) {
+	CharEntry &ce = _charTable[charId];
+	_charFlag = ce._charFlag;
+
+	_vm->_establishFlag = false;
+	if (ce._estabIndex != -1) {
+		_vm->_establishFlag = true;
+		if (!_vm->_establishTable[ce._estabIndex]) {
+			_vm->_establishTable[ce._estabIndex] = true;
+			_vm->establish(ce._estabIndex, 0);
+		}
+	}
+
+	if (_charFlag != 0 && _charFlag != 3) {
+		if (!_vm->_establishFlag)
+			_vm->_screen->fadeOut();
+
+		_vm->_files->loadScreen(ce._screenFile._fileNum, ce._screenFile._subfile);
+		_vm->_screen->setIconPalette();
+		_vm->_screen->fadeIn();
+	}
+
+	_vm->_buffer1.copyFrom(*_vm->_screen);
+	_vm->_screen->copyFrom(_vm->_buffer2);
+	_vm->_screen->setDisplayScan();
+
+	if (_charFlag != 2 && _charFlag != 3) {
+		charMenu();
+	}
+
+	_vm->_screen->_startColor = ce._startColor;
+	_vm->_screen->_numColors = ce._numColors;
+	if (ce._paletteFile._fileNum != -1) {
+		_vm->_screen->loadPalette(ce._paletteFile._fileNum, ce._paletteFile._subfile);
+	}
+	_vm->_screen->setIconPalette();
+	_vm->_screen->setPalette();
+
+	_vm->loadCells(ce._cells);
+	if (ce._animFile._fileNum != -1) {
+		byte *data = _vm->_files->loadFile(ce._animFile._fileNum, ce._animFile._subfile);
+		_vm->_animation->loadAnimations(data, _vm->_files->_filesize);
+	}
+
+	// Load script data
+	_vm->_scripts->freeScriptData();
+	if (ce._scriptFile._fileNum != -1) {
+		const byte *data = _vm->_files->loadFile(ce._scriptFile._fileNum, ce._scriptFile._subfile);
+		_vm->_scripts->setScript(data, _vm->_files->_filesize);
+	}
+
+	// Load extra cells
+	_vm->_extraCells.clear();
+	for (uint i = 0; i < ce._extraCells.size(); ++i)
+		_vm->_extraCells.push_back(ce._extraCells[i]);
+}
+
+void CharManager::charMenu() {
+	error("TODO: charMenu");
 }
 
 } // End of namespace Access
diff --git a/engines/access/char.h b/engines/access/char.h
index 8d6c49d..4bd38d7 100644
--- a/engines/access/char.h
+++ b/engines/access/char.h
@@ -32,7 +32,7 @@ namespace Access {
 class CharEntry {
 public:
 	int _charFlag;
-	int _estabFlag;
+	int _estabIndex;
 	FileIdent _screenFile;
 	FileIdent _paletteFile;
 	int _startColor, _numColors;
@@ -47,10 +47,19 @@ public:
 };
 
 class CharManager: public Manager {
+private:
+	void charMenu();
 public:
 	Common::Array<CharEntry> _charTable;
+	int _converseMode;
+	int _charFlag;
+
+	// Fields that are included in savegames
+	int _conversation;
 public:
 	CharManager(AccessEngine *vm);
+
+	void loadChar(int charId);
 };
 
 } // End of namespace Access
diff --git a/engines/access/room.cpp b/engines/access/room.cpp
index d703114..3ff4d66 100644
--- a/engines/access/room.cpp
+++ b/engines/access/room.cpp
@@ -241,39 +241,40 @@ void Room::roomLoop() {
 }
 
 void Room::setupRoom() {
-	_vm->_screen->setScaleTable(_vm->_scale);
-	_vm->_screen->setBufferScan();
+	Screen &screen = *_vm->_screen;
+	screen.setScaleTable(_vm->_scale);
+	screen.setBufferScan();
 
 	if (_roomFlag != 2)
-		setIconPalette();
+		screen.setIconPalette();
 
-	if (_vm->_screen->_vWindowWidth == _playFieldWidth) {
-		_vm->_screen->_scrollX = 0;
-		_vm->_screen->_scrollCol = 0;
+	if (screen._vWindowWidth == _playFieldWidth) {
+		screen._scrollX = 0;
+		screen._scrollCol = 0;
 	} else {
 		int xv = _vm->_player->_rawPlayer.x / TILE_WIDTH;
-		_vm->_screen->_scrollX = _vm->_player->_rawPlayer.x % TILE_WIDTH;
-		_vm->_screen->_scrollCol = MAX(xv - (_vm->_screen->_vWindowWidth / 2), 0);
+		screen._scrollX = _vm->_player->_rawPlayer.x % TILE_WIDTH;
+		screen._scrollCol = MAX(xv - (screen._vWindowWidth / 2), 0);
 
-		int sx = _vm->_screen->_scrollCol + _vm->_screen->_vWindowWidth - _playFieldWidth;
+		int sx = screen._scrollCol + screen._vWindowWidth - _playFieldWidth;
 		if (sx >= 0) {
-			_vm->_screen->_scrollCol -= sx + 1;
+			screen._scrollCol -= sx + 1;
 		}
 	}
 	
-	if (_vm->_screen->_vWindowHeight == _playFieldHeight) {
-		_vm->_screen->_scrollY = 0;
-		_vm->_screen->_scrollRow = 0;
+	if (screen._vWindowHeight == _playFieldHeight) {
+		screen._scrollY = 0;
+		screen._scrollRow = 0;
 	} else {
-		_vm->_screen->_scrollY = _vm->_player->_rawPlayer.y -
+		screen._scrollY = _vm->_player->_rawPlayer.y -
 			(_vm->_player->_rawPlayer.y >> 4);
 		int yp = MAX((_vm->_player->_rawPlayer.y >> 4) -
-			(_vm->_screen->_vWindowHeight / 2), 0);
-		_vm->_screen->_scrollRow = yp;
+			(screen._vWindowHeight / 2), 0);
+		screen._scrollRow = yp;
 
-		yp = yp + _vm->_screen->_vWindowHeight - _playFieldHeight;
+		yp = yp + screen._vWindowHeight - _playFieldHeight;
 		if (yp >= 0) {
-			_vm->_screen->_scrollRow = yp + 1;
+			screen._scrollRow = yp + 1;
 		}
 	}
 }
diff --git a/engines/access/room.h b/engines/access/room.h
index 4029095..d876a30 100644
--- a/engines/access/room.h
+++ b/engines/access/room.h
@@ -117,8 +117,6 @@ protected:
 
 	virtual void mainAreaClick() = 0;
 public:
-	virtual void setIconPalette() {}
-public:
 	Plotter _plotter;
 	Common::Array<JetFrame> _jetFrame;
 	int _function;
diff --git a/engines/access/screen.h b/engines/access/screen.h
index e66a7a3..5ffba5a 100644
--- a/engines/access/screen.h
+++ b/engines/access/screen.h
@@ -114,6 +114,11 @@ public:
 	 */
 	void setInitialPalettte();
 
+	/**
+	 * Set icon palette
+	 */
+	void setIconPalette() {}
+
 	void loadPalette(Common::SeekableReadStream *stream);
 
 	void loadPalette(int fileNum, int subfile);
diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp
index f4934d4..985f5cb 100644
--- a/engines/access/scripts.cpp
+++ b/engines/access/scripts.cpp
@@ -313,7 +313,7 @@ void Scripts::cmdConverse() {
 	_vm->_conversation = _data->readUint16LE();
 	_vm->_room->clearRoom();
 	_vm->freeChar();
-	_vm->loadChar(_vm->_conversation);
+	_vm->_char->loadChar(_vm->_conversation);
 	_vm->_events->setCursor(CURSOR_ARROW);
 
 	_vm->_images.clear();


Commit: 1e2d79eb598a0ed73a59cc540cddbaddf0bc90dd
    https://github.com/scummvm/scummvm/commit/1e2d79eb598a0ed73a59cc540cddbaddf0bc90dd
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-23T14:13:26-04:00

Commit Message:
ACCESS: Implement more opcodes, stubbed beginning of video player

Changed paths:
  A engines/access/video.cpp
  A engines/access/video.h
    engines/access/access.cpp
    engines/access/access.h
    engines/access/char.cpp
    engines/access/data.cpp
    engines/access/data.h
    engines/access/files.cpp
    engines/access/files.h
    engines/access/module.mk
    engines/access/room.cpp
    engines/access/scripts.cpp
    engines/access/scripts.h
    engines/access/sound.cpp
    engines/access/sound.h



diff --git a/engines/access/access.cpp b/engines/access/access.cpp
index 0718fd6..4035870 100644
--- a/engines/access/access.cpp
+++ b/engines/access/access.cpp
@@ -44,6 +44,7 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc)
 	_screen = nullptr;
 	_scripts = nullptr;
 	_sound = nullptr;
+	_video = nullptr;
 
 	_destIn = nullptr;
 	_current = nullptr;
@@ -116,6 +117,7 @@ AccessEngine::~AccessEngine() {
 	delete _screen;
 	delete _scripts;
 	delete _sound;
+	delete _video;
 
 	freeCells();
 	delete[] _inactive;
@@ -156,6 +158,7 @@ void AccessEngine::initialize() {
 	_player = new Player(this);
 	_screen = new Screen(this);
 	_sound = new SoundManager(this, _mixer);
+	_video = new VideoPlayer(this);
 
 	_buffer1.create(g_system->getWidth() + TILE_WIDTH, g_system->getHeight());
 	_buffer2.create(g_system->getWidth(), g_system->getHeight());
@@ -201,7 +204,7 @@ int AccessEngine::getRandomNumber(int maxNumber) {
 
 void AccessEngine::loadCells(Common::Array<CellIdent> &cells) {
 	for (uint i = 0; i < cells.size(); ++i) {
-		byte *spriteData = _files->loadFile(cells[i]._fileNum, cells[i]._subfile);
+		byte *spriteData = _files->loadFile(cells[i]);
 		_objectsTable[cells[i]._cell] = new SpriteResource(this, 
 			spriteData, _files->_filesize, DisposeAfterUse::YES);
 	}
diff --git a/engines/access/access.h b/engines/access/access.h
index 2e2358f..0d4ad19 100644
--- a/engines/access/access.h
+++ b/engines/access/access.h
@@ -43,6 +43,7 @@
 #include "access/screen.h"
 #include "access/scripts.h"
 #include "access/sound.h"
+#include "access/video.h"
 
 /**
  * This is the namespace of the Access engine.
@@ -119,6 +120,7 @@ public:
 	Screen *_screen;
 	Scripts *_scripts;
 	SoundManager *_sound;
+	VideoPlayer *_video;
 
 	ASurface *_destIn;
 	ASurface *_current;
diff --git a/engines/access/char.cpp b/engines/access/char.cpp
index 40f3bf3..09335fc 100644
--- a/engines/access/char.cpp
+++ b/engines/access/char.cpp
@@ -32,11 +32,8 @@ CharEntry::CharEntry(const byte *data) {
 
 	_charFlag = s.readByte();
 	_estabIndex = s.readSint16LE();
-	_screenFile._fileNum = s.readSint16LE();
-	_screenFile._subfile = s.readSint16LE();
-
-	_paletteFile._fileNum = s.readSint16LE();
-	_paletteFile._subfile = s.readUint16LE();
+	_screenFile.load(s);
+	_paletteFile.load(s);
 	_startColor = s.readUint16LE();
 	_numColors = s.readUint16LE();
 
@@ -44,23 +41,19 @@ CharEntry::CharEntry(const byte *data) {
 	for (byte cell = s.readByte(); cell != 0xff; cell = s.readByte()) {
 		CellIdent ci;
 		ci._cell = cell;
-		ci._fileNum = s.readSint16LE();
-		ci._subfile = s.readUint16LE();
+		ci.load(s);
 
 		_cells.push_back(ci);
 	}
 
-	_animFile._fileNum = s.readSint16LE();
-	_animFile._subfile = s.readUint16LE();
-	_scriptFile._fileNum = s.readSint16LE();
-	_scriptFile._subfile = s.readUint16LE();
+	_animFile.load(s);
+	_scriptFile.load(s);
 
 	for (int16 v = s.readSint16LE(); v != -1; v = s.readSint16LE()) {
 		ExtraCell ec;
-		ec._vidTable = v;
-		ec._vidTable1 = s.readSint16LE();
-		ec._vidSTable = s.readSint16LE();
-		ec._vidSTable1 = s.readSint16LE();
+		ec._vid._fileNum = v;
+		ec._vid._subfile = s.readSint16LE();
+		ec._vidSound.load(s);
 
 		_extraCells.push_back(ec);
 	}
@@ -128,14 +121,14 @@ void CharManager::loadChar(int charId) {
 
 	_vm->loadCells(ce._cells);
 	if (ce._animFile._fileNum != -1) {
-		byte *data = _vm->_files->loadFile(ce._animFile._fileNum, ce._animFile._subfile);
+		byte *data = _vm->_files->loadFile(ce._animFile);
 		_vm->_animation->loadAnimations(data, _vm->_files->_filesize);
 	}
 
 	// Load script data
 	_vm->_scripts->freeScriptData();
 	if (ce._scriptFile._fileNum != -1) {
-		const byte *data = _vm->_files->loadFile(ce._scriptFile._fileNum, ce._scriptFile._subfile);
+		const byte *data = _vm->_files->loadFile(ce._scriptFile);
 		_vm->_scripts->setScript(data, _vm->_files->_filesize);
 	}
 
@@ -146,7 +139,19 @@ void CharManager::loadChar(int charId) {
 }
 
 void CharManager::charMenu() {
-	error("TODO: charMenu");
+	byte *iconData = _vm->_files->loadFile("ICONS.LZ");
+	SpriteResource *spr = new SpriteResource(_vm, iconData, _vm->_files->_filesize);
+	delete[] iconData;
+
+	Screen &screen = *_vm->_screen;
+	screen.saveScreen();
+	screen.setDisplayScan();
+
+	screen.plotImage(spr, 17, Common::Point(0, 176));
+	screen.plotImage(spr, 18, Common::Point(155, 176));
+
+	screen.restoreScreen();
+	delete spr;
 }
 
 } // End of namespace Access
diff --git a/engines/access/data.cpp b/engines/access/data.cpp
index 094272b..a13c6d9 100644
--- a/engines/access/data.cpp
+++ b/engines/access/data.cpp
@@ -21,9 +21,10 @@
  */
 
 #include "common/algorithm.h"
-#include "access/data.h"
-#include "graphics/palette.h"
+#include "common/stream.h"
 #include "common/system.h"
+#include "graphics/palette.h"
+#include "access/data.h"
 
 namespace Access {
 
diff --git a/engines/access/data.h b/engines/access/data.h
index c10b2b7..3238daf 100644
--- a/engines/access/data.h
+++ b/engines/access/data.h
@@ -28,6 +28,7 @@
 #include "common/rect.h"
 #include "common/types.h"
 #include "graphics/surface.h"
+#include "access/files.h"
 
 namespace Access {
 
@@ -40,20 +41,6 @@ public:
 	Manager(AccessEngine *vm) : _vm(vm) {}
 };
 
-struct FileIdent {
-	int _fileNum;
-	int _subfile;
-
-	FileIdent() {
-		_fileNum = -1;
-		_subfile = 0;
-	}
-};
-
-struct CellIdent : FileIdent {
-	byte _cell;
-};
-
 struct TimerEntry {
 	int _initTm;
 	int _timer;
@@ -91,10 +78,8 @@ public:
 
 class ExtraCell {
 public:
-	int _vidTable;
-	int _vidTable1;
-	int _vidSTable;
-	int _vidSTable1;
+	FileIdent _vid;
+	FileIdent _vidSound;
 };
 
 struct FontVal {
diff --git a/engines/access/files.cpp b/engines/access/files.cpp
index 970b0b9..c805121 100644
--- a/engines/access/files.cpp
+++ b/engines/access/files.cpp
@@ -27,6 +27,18 @@
 
 namespace Access {
 
+FileIdent::FileIdent() {
+	_fileNum = -1;
+	_subfile = 0;
+}
+
+void FileIdent::load(Common::SeekableReadStream &s) {
+	_fileNum = s.readSint16LE();
+	_subfile = s.readUint16LE();
+}
+
+/*------------------------------------------------------------------------*/
+
 FileManager::FileManager(AccessEngine *vm): _vm(vm) {
 	switch (vm->getGameID()) {
 	case GType_Amazon:
@@ -55,6 +67,10 @@ byte *FileManager::loadFile(int fileNum, int subfile) {
 	return handleFile();
 }
 
+byte *FileManager::loadFile(FileIdent &fileIdent) {
+	return loadFile(fileIdent._fileNum, fileIdent._subfile);
+}
+
 byte *FileManager::loadFile(const Common::String &filename) {
 	// Open the file
 	openFile(filename);
diff --git a/engines/access/files.h b/engines/access/files.h
index 848ee0d..38d9179 100644
--- a/engines/access/files.h
+++ b/engines/access/files.h
@@ -32,6 +32,19 @@ namespace Access {
 
 class AccessEngine;
 
+struct FileIdent {
+	int _fileNum;
+	int _subfile;
+
+	FileIdent();
+
+	void load(Common::SeekableReadStream &s);
+};
+
+struct CellIdent : FileIdent {
+	byte _cell;
+};
+
 class FileManager {
 private:
 	AccessEngine *_vm;
@@ -56,6 +69,11 @@ public:
 	byte *loadFile(int fileNum, int subfile);
 
 	/**
+	 * Loads a resource specified by a file identifier
+	 */
+	byte *loadFile(FileIdent &fileIdent);
+
+	/**
 	 * Load a given file by name
 	 */
 	byte *loadFile(const Common::String &filename);
diff --git a/engines/access/module.mk b/engines/access/module.mk
index 31f0760..e92c2cc 100644
--- a/engines/access/module.mk
+++ b/engines/access/module.mk
@@ -19,6 +19,7 @@ MODULE_OBJS := \
 	screen.o \
 	scripts.o \
 	sound.o \
+	video.o \
 	amazon/amazon_game.o \
 	amazon/amazon_resources.o \
 	amazon/amazon_room.o \
diff --git a/engines/access/room.cpp b/engines/access/room.cpp
index 3ff4d66..90ef347 100644
--- a/engines/access/room.cpp
+++ b/engines/access/room.cpp
@@ -174,8 +174,7 @@ void Room::loadRoomData(const byte *roomData) {
 
 	_vm->_sound->freeMusic();
 	if (roomInfo._musicFile._fileNum != -1) {
-		_vm->_sound->_music = _vm->_files->loadFile(roomInfo._musicFile._fileNum,
-			roomInfo._musicFile._subfile);
+		_vm->_sound->_music = _vm->_files->loadFile(roomInfo._musicFile);
 		_vm->_sound->_midiSize = _vm->_files->_filesize;
 		_vm->_sound->midiPlay();
 		_vm->_sound->_musicRepeat = true;
@@ -200,16 +199,14 @@ void Room::loadRoomData(const byte *roomData) {
 	// Load script data
 	_vm->_scripts->freeScriptData();
 	if (roomInfo._scriptFile._fileNum != -1) {
-		const byte *data = _vm->_files->loadFile(roomInfo._scriptFile._fileNum,
-			roomInfo._scriptFile._subfile);
+		const byte *data = _vm->_files->loadFile(roomInfo._scriptFile);
 		_vm->_scripts->setScript(data, _vm->_files->_filesize);
 	}
 
 	// Load animation data
 	_vm->_animation->freeAnimationData();
 	if (roomInfo._animFile._fileNum != -1) {
-		byte *data = _vm->_files->loadFile(roomInfo._animFile._fileNum,
-			roomInfo._animFile._subfile);
+		byte *data = _vm->_files->loadFile(roomInfo._animFile);
 		_vm->_animation->loadAnimations(data, _vm->_files->_filesize);
 	}
 
@@ -726,31 +723,25 @@ RoomInfo::RoomInfo(const byte *data, int gameType) {
 	else
 		_estIndex = -1;
 
-	_musicFile._fileNum = stream.readSint16LE();
-	_musicFile._subfile = stream.readUint16LE();
+	_musicFile.load(stream);
 	_scaleH1 = stream.readByte();
 	_scaleH2 = stream.readByte();
 	_scaleN1 = stream.readByte();
-	_playFieldFile._fileNum = stream.readSint16LE();
-	_playFieldFile._subfile = stream.readUint16LE();
+	_playFieldFile.load(stream);
 
 	for (byte cell = stream.readByte(); cell != 0xff; cell = stream.readByte()) {
 		CellIdent ci;
 		ci._cell = cell;
-		ci._fileNum = stream.readSint16LE();
-		ci._subfile = stream.readUint16LE();
+		ci.load(stream);
 
 		_cells.push_back(ci);
 	}
 
-	_scriptFile._fileNum = stream.readSint16LE();
-	_scriptFile._subfile = stream.readUint16LE();
-	_animFile._fileNum = stream.readSint16LE();
-	_animFile._subfile = stream.readUint16LE();
+	_scriptFile.load(stream);
+	_animFile.load(stream);
 	_scaleI = stream.readByte();
 	_scrollThreshold = stream.readByte();
-	_paletteFile._fileNum = stream.readSint16LE();
-	_paletteFile._subfile = stream.readUint16LE();
+	_paletteFile.load(stream);
 	if (_paletteFile._fileNum == -1) {
 		_startColor = _numColors = 0;
 	} else {
@@ -760,10 +751,9 @@ RoomInfo::RoomInfo(const byte *data, int gameType) {
 
 	for (int16 v = stream.readSint16LE(); v != -1; v = stream.readSint16LE()) {
 		ExtraCell ec;
-		ec._vidTable = v;
-		ec._vidTable1 = stream.readSint16LE();
-		ec._vidSTable = stream.readSint16LE();
-		ec._vidSTable1 = stream.readSint16LE();
+		ec._vid._fileNum = v;
+		ec._vid._subfile = stream.readSint16LE();
+		ec._vidSound.load(stream);
 
 		_extraCells.push_back(ec);
 	}
diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp
index 985f5cb..2a834f8 100644
--- a/engines/access/scripts.cpp
+++ b/engines/access/scripts.cpp
@@ -104,7 +104,7 @@ void Scripts::executeCommand(int commandIndex) {
 		&Scripts::cmdRetNeg, &Scripts::cmdRetPos, &Scripts::cmdCheckLoc, 
 		&Scripts::cmdSetAnim, &Scripts::cmdDispInv, &Scripts::cmdSetTimer, 
 		&Scripts::cmdSetTimer, &Scripts::cmdCheckTimer, &Scripts::cmdSetTravel,
-		&Scripts::cmdSetTravel, &Scripts::CMDSETVID, &Scripts::CMDPLAYVID, 
+		&Scripts::cmdSetTravel, &Scripts::cmdSetVideo, &Scripts::CMDPLAYVID, 
 		&Scripts::cmdPlotImage, &Scripts::cmdSetDisplay, &Scripts::cmdSetBuffer, 
 		&Scripts::cmdSetScroll, &Scripts::CMDSAVERECT, &Scripts::CMDSAVERECT, 
 		&Scripts::CMDSETBUFVID, &Scripts::CMDPLAYBUFVID, &Scripts::cmdRemoveLast, 
@@ -113,7 +113,7 @@ void Scripts::executeCommand(int commandIndex) {
 		&Scripts::cmdTexSpeak, &Scripts::cmdTexChoice, &Scripts::CMDWAIT, 
 		&Scripts::cmdSetConPos, &Scripts::CMDCHECKVFRAME, &Scripts::cmdJumpChoice, 
 		&Scripts::cmdReturnChoice, &Scripts::cmdClearBlock, &Scripts::cmdLoadSound, 
-		&Scripts::CMDFREESOUND, &Scripts::CMDSETVIDSND, &Scripts::CMDPLAYVIDSND,
+		&Scripts::CMDFREESOUND, &Scripts::cmdSetVideoSound, &Scripts::CMDPLAYVIDSND,
 		&Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, 
 		&Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, &Scripts::cmdPlayerOff, 
 		&Scripts::cmdPlayerOn, &Scripts::CMDDEAD, &Scripts::cmdFadeOut,
@@ -417,7 +417,16 @@ void Scripts::cmdSetTravel() {
 		_data->skip(2);
 }
 
-void Scripts::CMDSETVID() { error("TODO CMDSETVID"); }
+void Scripts::cmdSetVideo() { 
+	FileIdent fi;
+	fi._fileNum = _data->readSint16LE();
+	fi._subfile = _data->readUint16LE();
+	int cellIndex = _data->readUint16LE();
+	int rate = _data->readUint16LE();
+
+	_vm->_video->setVideo(_vm->_extraCells[cellIndex]._vid, fi, rate);
+}
+
 void Scripts::CMDPLAYVID() { error("TODO CMDPLAYVID"); }
 
 void Scripts::cmdPlotImage() {
@@ -645,12 +654,22 @@ void Scripts::cmdClearBlock() {
 
 void Scripts::cmdLoadSound() {
 	int idx = _data->readSint16LE();
-	_vm->_sound->_soundTable[0]._data = _vm->_files->loadFile(_vm->_extraCells[idx]._vidSTable, _vm->_extraCells[idx]._vidSTable1);
+	_vm->_sound->_soundTable[0]._data = _vm->_files->loadFile(_vm->_extraCells[idx]._vidSound);
 	_vm->_sound->_soundPriority[0] = 1;
 }
 
 void Scripts::CMDFREESOUND() { error("TODO CMDFREESOUND"); }
-void Scripts::CMDSETVIDSND() { error("TODO CMDSETVIDSND"); }
+
+void Scripts::cmdSetVideoSound() { 
+	_data->skip(4);
+	cmdLoadSound();
+	_data->skip(-6);
+	cmdSetVideo();
+
+	_vm->_sound->_soundFrame = _data->readUint16LE();
+	_vm->_sound->_soundFlag = false;
+}
+
 void Scripts::CMDPLAYVIDSND() { error("TODO CMDPLAYVIDSND"); }
 void Scripts::CMDPUSHLOCATION() { error("TODO CMDPUSHLOCATION"); }
 
diff --git a/engines/access/scripts.h b/engines/access/scripts.h
index ae4c755..93cd495 100644
--- a/engines/access/scripts.h
+++ b/engines/access/scripts.h
@@ -90,7 +90,7 @@ protected:
 	void cmdSetTimer();
 	void cmdCheckTimer();
 	void cmdSetTravel();
-	void CMDSETVID();
+	void cmdSetVideo();
 	void CMDPLAYVID();
 	void cmdPlotImage();
 	void cmdSetDisplay();
@@ -114,7 +114,7 @@ protected:
 	void cmdClearBlock();
 	void cmdLoadSound();
 	void CMDFREESOUND();
-	void CMDSETVIDSND();
+	void cmdSetVideoSound();
 	void CMDPLAYVIDSND();
 	void CMDPUSHLOCATION();
 	void cmdPlayerOff();
diff --git a/engines/access/sound.cpp b/engines/access/sound.cpp
index c689728..aebd76f 100644
--- a/engines/access/sound.cpp
+++ b/engines/access/sound.cpp
@@ -36,6 +36,8 @@ SoundManager::SoundManager(AccessEngine *vm, Audio::Mixer *mixer) :
 	_music = nullptr;
 	_midiSize = 0;
 	_musicRepeat = false;
+	_soundFrame = 0;
+	_soundFlag = false;
 }
 
 SoundManager::~SoundManager() {
diff --git a/engines/access/sound.h b/engines/access/sound.h
index dd94396..cb73bae 100644
--- a/engines/access/sound.h
+++ b/engines/access/sound.h
@@ -51,7 +51,8 @@ public:
 	byte *_music;
 	int _midiSize;
 	bool _musicRepeat;
-
+	int _soundFrame;
+	bool _soundFlag;
 public:
 	SoundManager(AccessEngine *vm, Audio::Mixer *mixer);
 	~SoundManager();
diff --git a/engines/access/video.cpp b/engines/access/video.cpp
new file mode 100644
index 0000000..a025d31
--- /dev/null
+++ b/engines/access/video.cpp
@@ -0,0 +1,35 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "access/video.h"
+
+namespace Access {
+
+VideoPlayer::VideoPlayer(AccessEngine *vm) : Manager(vm) {
+
+}
+
+void VideoPlayer::setVideo(FileIdent &fi1, FileIdent &fi2, int rate) {
+	error("TODO: setVideo");
+}
+
+} // End of namespace Access
diff --git a/engines/access/video.h b/engines/access/video.h
new file mode 100644
index 0000000..b21f006
--- /dev/null
+++ b/engines/access/video.h
@@ -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.
+ *
+ */
+
+#ifndef ACCESS_VIDEO_H
+#define ACCESS_VIDEO_H
+
+#include "common/scummsys.h"
+#include "access/data.h"
+#include "access/files.h"
+
+namespace Access {
+
+class VideoPlayer: public Manager {
+public:
+	VideoPlayer(AccessEngine *vm);
+
+	void setVideo(FileIdent &fi1, FileIdent &fi2, int rate);
+};
+
+} // End of namespace Access
+
+#endif /* ACCESS_VIDEO_H */


Commit: 148eb972abad3d1ac8b8685a25b88f74fb5dae5e
    https://github.com/scummvm/scummvm/commit/148eb972abad3d1ac8b8685a25b88f74fb5dae5e
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-23T14:28:07-04:00

Commit Message:
ACCESS: Fix fade outs

Changed paths:
    engines/access/screen.cpp



diff --git a/engines/access/screen.cpp b/engines/access/screen.cpp
index af97e2e..f62c2f5 100644
--- a/engines/access/screen.cpp
+++ b/engines/access/screen.cpp
@@ -139,7 +139,7 @@ void Screen::forceFadeOut() {
 
 	do {
 		repeatFlag = false;
-		for (srcP = &_tempPalette[0], count = 0; count < PALETTE_COUNT; ++count, ++srcP) {
+		for (srcP = &_tempPalette[0], count = 0; count < PALETTE_SIZE; ++count, ++srcP) {
 			int v = *srcP;
 			if (v) {
 				repeatFlag = true;
@@ -149,7 +149,7 @@ void Screen::forceFadeOut() {
 
 		updatePalette();
 		g_system->delayMillis(10);
-	} while (repeatFlag);
+	} while (repeatFlag && !_vm->shouldQuit());
 }
 
 void Screen::forceFadeIn() {


Commit: ec70f3feaf3f2e81376d0bbb0ab6c11554ef1fbc
    https://github.com/scummvm/scummvm/commit/ec70f3feaf3f2e81376d0bbb0ab6c11554ef1fbc
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-23T14:47:06-04:00

Commit Message:
ACCESS: Fix graphic glitch when scrolling up

Changed paths:
    engines/access/player.cpp



diff --git a/engines/access/player.cpp b/engines/access/player.cpp
index e85b68a..4be24f4 100644
--- a/engines/access/player.cpp
+++ b/engines/access/player.cpp
@@ -719,7 +719,7 @@ scrollUp:
 			// Scroll up
 			if (scrollUp()) {
 				_scrollEnd = 4;
-				_vm->_screen->_scrollY = TILE_HEIGHT;
+				_vm->_screen->_scrollY &= TILE_HEIGHT;
 				_scrollFlag = true;
 			}
 		}


Commit: f98d4668d718b04713ebe9ed2abc41f8bcaed609
    https://github.com/scummvm/scummvm/commit/f98d4668d718b04713ebe9ed2abc41f8bcaed609
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-23T17:19:54-04:00

Commit Message:
ACCESS: Improvements for horizontal scrolling

Changed paths:
    engines/access/asurface.cpp
    engines/access/asurface.h
    engines/access/player.cpp
    engines/access/screen.cpp
    engines/access/screen.h



diff --git a/engines/access/asurface.cpp b/engines/access/asurface.cpp
index e88bd27..138978f 100644
--- a/engines/access/asurface.cpp
+++ b/engines/access/asurface.cpp
@@ -324,4 +324,24 @@ void ASurface::flipHorizontal(ASurface &dest) {
 }
 
 
+void ASurface::moveBufferLeft() {
+	byte *p = (byte *)getPixels();
+	Common::copy(p + TILE_WIDTH, p + (w * h), p);
+}
+
+void ASurface::moveBufferRight() {
+	byte *p = (byte *)getPixels();
+	Common::copy_backward(p, p + (w * h) - TILE_WIDTH, p + (w * h));
+}
+
+void ASurface::moveBufferUp() {
+	byte *p = (byte *)getPixels();
+	Common::copy(p + w, p + (w * h), p);
+}
+
+void ASurface::moveBufferDown() {
+	byte *p = (byte *)getPixels();
+	Common::copy_backward(p, p + (w * (h - 1)), p + (w * h));
+}
+
 } // End of namespace Access
diff --git a/engines/access/asurface.h b/engines/access/asurface.h
index 84fe90d..62e2923 100644
--- a/engines/access/asurface.h
+++ b/engines/access/asurface.h
@@ -97,6 +97,14 @@ public:
 	void restoreBlock();
 
 	void drawRect();
+
+	void moveBufferLeft();
+
+	void moveBufferRight();
+
+	void moveBufferUp();
+
+	void moveBufferDown();
 };
 
 class SpriteFrame : public ASurface {
diff --git a/engines/access/player.cpp b/engines/access/player.cpp
index 4be24f4..7df277c 100644
--- a/engines/access/player.cpp
+++ b/engines/access/player.cpp
@@ -738,7 +738,7 @@ bool Player::scrollUp() {
 	while (_vm->_screen->_scrollY >= TILE_HEIGHT && !_vm->shouldQuit()) {
 			_vm->_screen->_scrollY -= TILE_HEIGHT;
 		++_vm->_screen->_scrollRow;
-		_vm->_screen->moveBufferUp();
+		_vm->_buffer1.moveBufferUp();
 
 		_vm->_room->buildRow(_vm->_screen->_scrollRow + _vm->_screen->_vWindowHeight,
 			_vm->_screen->_vWindowLinesTall * _vm->_screen->_bufferBytesWide);
@@ -766,7 +766,7 @@ bool Player::scrollDown() {
 		if (--_vm->_screen->_scrollRow < 0)
 			break;
 
-		_vm->_screen->moveBufferDown();
+		_vm->_buffer1.moveBufferDown();
 		_vm->_room->buildRow(_vm->_screen->_scrollRow, 0);
 
 		if (_vm->_screen->_scrollY >= 0)
@@ -780,28 +780,29 @@ bool Player::scrollDown() {
 }
 
 bool Player::scrollLeft() {
-	_scrollAmount = -(_vm->_screen->_clipWidth - _playerX - _scrollThreshold);
-	if ((_vm->_rScrollCol + _vm->_screen->_vWindowWidth) == _vm->_room->_playFieldWidth) {
+	Screen &screen = *_vm->_screen;
+	_scrollAmount = -(screen._clipWidth - _playerX - _scrollThreshold);
+	if ((_vm->_rScrollCol + screen._vWindowWidth) == _vm->_room->_playFieldWidth) {
 		_scrollEnd = 2;
-		_vm->_screen->_scrollX = 0;
+		screen._scrollX = 0;
 		_scrollFlag = true;
 		return true;
 	} else {
 		_scrollFlag = true;
-		_vm->_screen->_scrollX = _vm->_screen->_scrollX + _scrollAmount;
+		screen._scrollX = screen._scrollX + _scrollAmount;
 
-		while (_vm->_screen->_scrollX >= TILE_WIDTH && !_vm->shouldQuit()) {
-			_vm->_screen->_scrollX -= TILE_WIDTH;
-			++_vm->_screen->_scrollCol;
-			_vm->_screen->moveBufferLeft();
-			_vm->_room->buildColumn(_vm->_screen->_scrollCol +
-				_vm->_screen->_vWindowWidth, _vm->_screen->_vWindowBytesWide);
+		do {
+			if (screen._scrollX < TILE_WIDTH)
+				return true;
 
-			if (_vm->_screen->_scrollX < TILE_WIDTH)
-				return _playerDirection == UPRIGHT;
-		}
+			screen._scrollX -= TILE_WIDTH;
+			++screen._scrollCol;
+			_vm->_buffer1.moveBufferLeft();
+			_vm->_room->buildColumn(screen._scrollCol + screen._vWindowWidth,
+				screen._vWindowBytesWide);
+		} while (!_vm->shouldQuit() && (screen._scrollX >= TILE_WIDTH));
 
-		return true;
+		return (_playerDirection == UPRIGHT);
 	}
 }
 
@@ -811,18 +812,16 @@ bool Player::scrollRight() {
 	_vm->_screen->_scrollX -= _scrollAmount;
 
 	if (_vm->_screen->_scrollX < 0) {
-		_scrollFlag = true;
-		_vm->_screen->_scrollX += _scrollAmount;
+		do {
+			_vm->_screen->_scrollX += TILE_WIDTH;
+			if (--_vm->_screen->_scrollCol < 0)
+				return true;
 
-		while (_vm->_screen->_scrollX >= TILE_WIDTH && !_vm->shouldQuit()) {
-			_vm->_screen->_scrollX -= TILE_WIDTH;
-			_vm->_screen->moveBufferLeft();
-			_vm->_room->buildColumn(_vm->_screen->_scrollCol -
-				_vm->_screen->_vWindowWidth, _vm->_screen->_vWindowBytesWide);
+			_vm->_buffer1.moveBufferRight();
+			_vm->_room->buildColumn(_vm->_screen->_scrollCol, 0);
+		} while (!_vm->shouldQuit() && (_vm->_screen->_scrollX >= 0));
 
-			if (_vm->_screen->_scrollX < TILE_WIDTH)
-				return _playerDirection == UPLEFT;
-		}
+		return false;
 	}
 
 	return true;
diff --git a/engines/access/screen.cpp b/engines/access/screen.cpp
index f62c2f5..57002c0 100644
--- a/engines/access/screen.cpp
+++ b/engines/access/screen.cpp
@@ -224,18 +224,6 @@ void Screen::restoreScreen() {
 	_screenYOff = _screenSave._screenYOff;
 }
 
-void Screen::moveBufferLeft() {
-	error("TODO: LEFT");
-}
-
-void Screen::moveBufferDown() {
-	error("TODO: DOWN");
-}
-
-void Screen::moveBufferUp() {
-	error("TODO: UP");
-}
-
 void Screen::copyBlock(ASurface *src, const Common::Rect &bounds) {
 	Common::Rect destBounds = bounds;
 	destBounds.translate(_windowXAdd, _windowYAdd + _screenYOff);
diff --git a/engines/access/screen.h b/engines/access/screen.h
index 5ffba5a..3935f2c 100644
--- a/engines/access/screen.h
+++ b/engines/access/screen.h
@@ -149,12 +149,6 @@ public:
 	 * Restores previously saved screen display state variables
 	 */
 	void restoreScreen();
-
-	void moveBufferLeft();
-
-	void moveBufferDown();
-
-	void moveBufferUp();
 };
 
 } // End of namespace Access


Commit: 955df7a94ce21d311d6e34d263d96070548d855e
    https://github.com/scummvm/scummvm/commit/955df7a94ce21d311d6e34d263d96070548d855e
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-08-23T23:49:08+02:00

Commit Message:
ACCESS: Start implementing loadEstablish

Changed paths:
    engines/access/access.cpp
    engines/access/access.h
    engines/access/files.cpp
    engines/access/files.h



diff --git a/engines/access/access.cpp b/engines/access/access.cpp
index 4035870..e90e5ba 100644
--- a/engines/access/access.cpp
+++ b/engines/access/access.cpp
@@ -83,6 +83,7 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc)
 	_establishFlag = false;
 	_establishMode = 0;
 	_establishGroup = 0;
+	_establishCtrlTblOfs = 0;
 	Common::fill(&_help1[0], &_help1[366], 0);
 	Common::fill(&_help2[0], &_help2[366], 0);
 	Common::fill(&_help1[0], &_help3[366], 0);
@@ -102,6 +103,9 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc)
 	_screenVirtX = 0;
 	_lastTime = g_system->getMillis();
 	_curTime = 0;
+	_narateFile = 0;
+	_txtPages = 0;
+	_sndSubFile = 0;
 }
 
 AccessEngine::~AccessEngine() {
@@ -233,9 +237,31 @@ void AccessEngine::establishCenter(int esatabIndex, int sub) {
 	doEstablish(esatabIndex, sub);
 }
 
-byte *AccessEngine::loadEstablish(int sub) {
-	warning("TODO: loadEstablish");
-	return nullptr;
+const char *const _estTable[] = { "ETEXT0.DAT", "ETEXT1.DAT", "ETEXT2.DAT", "ETEXT3.DAT" };
+
+void AccessEngine::loadEstablish(int sub) {
+	if (!_files->existFile("ETEXT.DAT")) {
+		int oldGroup = _establishGroup;
+		_establishGroup = 0;
+		
+		_eseg = _files->loadFile(_estTable[oldGroup]);
+	} else {
+		_eseg = _files->loadFile("ETEXT.DAT");
+	}
+
+	_establishCtrlTblOfs = READ_LE_UINT16(_eseg);
+
+	int ofs = _establishCtrlTblOfs + (sub * 2);
+	int idx = READ_LE_UINT16(_eseg + ofs);
+	_narateFile = READ_LE_UINT16(_eseg + idx);
+	_txtPages = READ_LE_UINT16(_eseg + idx + 2);
+
+	if (!_txtPages)
+		return;
+
+	_sndSubFile = READ_LE_UINT16(_eseg + idx + 4);
+	for (int i = 0; i < _txtPages; ++i)
+		_countTbl[i] = READ_LE_UINT16(_eseg + idx + 6 + (2 * i));
 }
 
 void AccessEngine::doEstablish(int esatabIndex, int sub) {
@@ -260,7 +286,7 @@ void AccessEngine::doEstablish(int esatabIndex, int sub) {
 
 	_bubbleBox->_maxChars = 37;
 	_fonts._printOrg = _fonts._printStart = Common::Point(48, 35);
-	_eseg = loadEstablish(sub);
+	loadEstablish(sub);
 	_et = sub;
 	warning("CHECKME: Use of di");
 	_printEnd = 155;
diff --git a/engines/access/access.h b/engines/access/access.h
index 0d4ad19..db96935 100644
--- a/engines/access/access.h
+++ b/engines/access/access.h
@@ -73,6 +73,8 @@ enum AccessDebugChannels {
 
 struct AccessGameDescription;
 
+extern const char *const _estTable[];
+
 class AccessEngine : public Engine {
 private:
 	uint32 _lastTime, _curTime;
@@ -132,6 +134,7 @@ public:
 	bool _establishFlag;
 	int _establishMode;
 	int _establishGroup;
+	int _establishCtrlTblOfs;
 	int _numAnimTimers;
 	TimerList _timers;
 	FontManager _fonts;
@@ -164,6 +167,9 @@ public:
 	int _et;
 	int _printEnd;
 	int _txtPages;
+	int _narateFile;
+	int _sndSubFile;
+	int _countTbl[6];
 
 	// Fields that are included in savegames
 	int _conversation;
@@ -220,7 +226,7 @@ public:
 	 */
 	void freeInactiveData();
 
-	byte *AccessEngine::loadEstablish(int sub);
+	void AccessEngine::loadEstablish(int sub);
 
 	void establish(int esatabIndex, int sub);
 
diff --git a/engines/access/files.cpp b/engines/access/files.cpp
index c805121..da38424 100644
--- a/engines/access/files.cpp
+++ b/engines/access/files.cpp
@@ -82,6 +82,10 @@ byte *FileManager::loadFile(const Common::String &filename) {
 	return handleFile();
 }
 
+bool FileManager::existFile(const Common::String &filename) {
+	return _file.exists(filename);
+}
+
 void FileManager::openFile(const Common::String &filename) {
 	// Open up the file
 	_fileNumber = -1;
diff --git a/engines/access/files.h b/engines/access/files.h
index 38d9179..b91da7d 100644
--- a/engines/access/files.h
+++ b/engines/access/files.h
@@ -64,6 +64,11 @@ public:
 	~FileManager();
 
 	/**
+	 * Check the existence of a given file
+	 */
+	bool FileManager::existFile(const Common::String &filename);
+
+	/**
 	 * Load a given subfile from a container file
 	 */
 	byte *loadFile(int fileNum, int subfile);


Commit: ee62d6c1cfce009331050fb9bf8bfecbb8f51472
    https://github.com/scummvm/scummvm/commit/ee62d6c1cfce009331050fb9bf8bfecbb8f51472
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-23T23:21:17-04:00

Commit Message:
ACCESS: In progress inventory display screen

Changed paths:
    engines/access/asurface.cpp
    engines/access/asurface.h
    engines/access/events.cpp
    engines/access/events.h
    engines/access/files.cpp
    engines/access/files.h
    engines/access/inventory.cpp
    engines/access/inventory.h
    engines/access/resources.cpp
    engines/access/resources.h
    engines/access/room.cpp
    engines/access/room.h



diff --git a/engines/access/asurface.cpp b/engines/access/asurface.cpp
index 138978f..ce977f6 100644
--- a/engines/access/asurface.cpp
+++ b/engines/access/asurface.cpp
@@ -265,6 +265,9 @@ void ASurface::copyTo(ASurface *dest, const Common::Rect &bounds) {
 	}
 }
 
+void ASurface::copyTo(ASurface *dest) {
+	copyTo(dest, Common::Point());
+}
 
 void ASurface::plotF(SpriteFrame *frame, const Common::Point &pt) {
 	sPlotF(frame, Common::Rect(pt.x, pt.y, pt.x + frame->w, pt.y + frame->h));
diff --git a/engines/access/asurface.h b/engines/access/asurface.h
index 62e2923..f5e5f48 100644
--- a/engines/access/asurface.h
+++ b/engines/access/asurface.h
@@ -92,6 +92,8 @@ public:
 
 	void copyTo(ASurface *dest, const Common::Rect &bounds);
 
+	void copyTo(ASurface *dest);
+
 	void saveBlock(const Common::Rect &bounds);
 
 	void restoreBlock();
diff --git a/engines/access/events.cpp b/engines/access/events.cpp
index 78bbdbf..15c8f8c 100644
--- a/engines/access/events.cpp
+++ b/engines/access/events.cpp
@@ -41,11 +41,11 @@ EventsManager::EventsManager(AccessEngine *vm): _vm(vm) {
 	_priorFrameTime = 0;
 	_leftButton = _rightButton = false;
 	_mouseCol = _mouseRow = 0;
-	_mouseMode = 0;
 	_cursorExitFlag = false;
 }
 
 EventsManager::~EventsManager() {
+	_invCursor.free();
 }
 
 void EventsManager::setCursor(CursorType cursorId) {
@@ -53,50 +53,56 @@ void EventsManager::setCursor(CursorType cursorId) {
 		return;	
 	_cursorId = cursorId;
 	
-	if (_mouseMode == 1 && cursorId == CURSOR_ARROW)
-		_mouseMode = 2;
-	else if (_mouseMode == 2 && cursorId != CURSOR_ARROW)
-		_mouseMode = 1;
-
-	// Get a pointer to the mouse data to use, and get the cursor hotspot
-	const byte *srcP = Amazon::CURSORS[cursorId];
-	int hotspotX = (int16)READ_LE_UINT16(srcP);
-	int hotspotY = (int16)READ_LE_UINT16(srcP + 2);
-	srcP += 4;
-
-	// Create a surface to build up the cursor on
-	Graphics::Surface cursorSurface;
-	cursorSurface.create(16, 16, Graphics::PixelFormat::createFormatCLUT8());
-	byte *destP = (byte *)cursorSurface.getPixels();
-	Common::fill(destP, destP + CURSOR_WIDTH * CURSOR_HEIGHT, 0);
-
-	// Loop to build up the cursor
-	for (int y = 0; y < CURSOR_HEIGHT; ++y) {
-		destP = (byte *)cursorSurface.getBasePtr(0, y);
-		int width = CURSOR_WIDTH;
-		int skip = *srcP++;
-		int plot = *srcP++;
-		if (skip >= width)
-			break;
+	if (cursorId == CURSOR_INVENTORY) {
+		// Set the cursor
+		CursorMan.replaceCursor(_invCursor.getPixels(), _invCursor.w, _invCursor.h,
+			0, 0, 0);
+	} else {
+		// Get a pointer to the mouse data to use, and get the cursor hotspot
+		const byte *srcP = Amazon::CURSORS[cursorId];
+		int hotspotX = (int16)READ_LE_UINT16(srcP);
+		int hotspotY = (int16)READ_LE_UINT16(srcP + 2);
+		srcP += 4;
+
+		// Create a surface to build up the cursor on
+		Graphics::Surface cursorSurface;
+		cursorSurface.create(16, 16, Graphics::PixelFormat::createFormatCLUT8());
+		byte *destP = (byte *)cursorSurface.getPixels();
+		Common::fill(destP, destP + CURSOR_WIDTH * CURSOR_HEIGHT, 0);
+
+		// Loop to build up the cursor
+		for (int y = 0; y < CURSOR_HEIGHT; ++y) {
+			destP = (byte *)cursorSurface.getBasePtr(0, y);
+			int width = CURSOR_WIDTH;
+			int skip = *srcP++;
+			int plot = *srcP++;
+			if (skip >= width)
+				break;
+
+			// Skip over pixels
+			destP += skip;
+			width -= skip;
+
+			// Write out the pixels to plot
+			while (plot > 0 && width > 0) {
+				*destP++ = *srcP++;
+				--plot;
+				--width;
+			}
+		}
 
-		// Skip over pixels
-		destP += skip;
-		width -= skip;
+		// Set the cursor
+		CursorMan.replaceCursor(cursorSurface.getPixels(), CURSOR_WIDTH, CURSOR_HEIGHT,
+			hotspotX, hotspotY, 0);
 
-		// Write out the pixels to plot
-		while (plot > 0 && width > 0) {
-			*destP++ = *srcP++;
-			--plot;
-			--width;
-		}
+		// Free the cursor surface
+		cursorSurface.free();
 	}
+}
 
-	// Set the cursor
-	CursorMan.replaceCursor(cursorSurface.getPixels(), CURSOR_WIDTH, CURSOR_HEIGHT,
-		hotspotX, hotspotY, 0);
-
-	// Free the cursor surface
-	cursorSurface.free();
+void EventsManager::setCursorData(Graphics::Surface *src, const Common::Rect &r) {
+	_invCursor.create(r.width(), r.height(), Graphics::PixelFormat::createFormatCLUT8());
+	_invCursor.copyRectToSurface(*src, 0, 0, r);
 }
 
 void EventsManager::showCursor() {
diff --git a/engines/access/events.h b/engines/access/events.h
index 2ced71f..fdfb0a5 100644
--- a/engines/access/events.h
+++ b/engines/access/events.h
@@ -32,7 +32,8 @@ namespace Access {
 enum CursorType { 
 	CURSOR_NONE = -1,
 	CURSOR_ARROW = 0, CURSOR_CROSSHAIRS, CURSOR_2, CURSOR_3, CURSOR_LOOK, 
-	CURSOR_USE, CURSOR_TAKE, CURSOR_CLIMB, CURSOR_TALK, CURSOR_HELP
+	CURSOR_USE, CURSOR_TAKE, CURSOR_CLIMB, CURSOR_TALK, CURSOR_HELP,
+	CURSOR_INVENTORY = 99
 };
 
 #define GAME_FRAME_RATE 100
@@ -45,6 +46,7 @@ private:
 	AccessEngine *_vm;
 	uint32 _frameCounter;
 	uint32 _priorFrameTime;
+	Graphics::Surface _invCursor;
 
 	bool checkForNextFrameCounter();
 
@@ -55,7 +57,6 @@ public:
 	bool _leftButton, _rightButton;
 	Common::Point _mousePos;
 	int _mouseCol, _mouseRow;
-	int _mouseMode;
 	bool _cursorExitFlag;
 	Common::FixedStack<Common::KeyState> _keypresses;
 public:
@@ -75,6 +76,11 @@ public:
 	void setCursor(CursorType cursorId);
 
 	/**
+	 * Set the image for the inventory cursor
+	 */
+	void setCursorData(Graphics::Surface *src, const Common::Rect &r);
+
+	/**
 	 * Return the current cursor Id
 	 */
 	CursorType getCursor() const { return _cursorId; }
diff --git a/engines/access/files.cpp b/engines/access/files.cpp
index da38424..230d2a8 100644
--- a/engines/access/files.cpp
+++ b/engines/access/files.cpp
@@ -39,6 +39,14 @@ void FileIdent::load(Common::SeekableReadStream &s) {
 
 /*------------------------------------------------------------------------*/
 
+CellIdent::CellIdent(int cell, int fileNum, int subfile) {
+	_cell = cell;
+	_fileNum = fileNum;
+	_subfile = subfile;
+}
+
+/*------------------------------------------------------------------------*/
+
 FileManager::FileManager(AccessEngine *vm): _vm(vm) {
 	switch (vm->getGameID()) {
 	case GType_Amazon:
diff --git a/engines/access/files.h b/engines/access/files.h
index b91da7d..d1a4d5a 100644
--- a/engines/access/files.h
+++ b/engines/access/files.h
@@ -43,6 +43,9 @@ struct FileIdent {
 
 struct CellIdent : FileIdent {
 	byte _cell;
+
+	CellIdent() {}
+	CellIdent(int cell, int fileNum, int subfile);
 };
 
 class FileManager {
diff --git a/engines/access/inventory.cpp b/engines/access/inventory.cpp
index e90ad62..6c56f6b 100644
--- a/engines/access/inventory.cpp
+++ b/engines/access/inventory.cpp
@@ -22,6 +22,7 @@
 
 #include "access/inventory.h"
 #include "access/access.h"
+#include "access/resources.h"
 #include "access/amazon/amazon_resources.h"
 #include "access/martian/martian_resources.h"
 
@@ -35,6 +36,7 @@ InventoryManager::InventoryManager(AccessEngine *vm) : Manager(vm) {
 	_invModeFlag = false;
 	_startAboutItem = 0;
 	_startTravelItem = 0;
+	_iconDisplayFlag = false;
 
 	const char *const *names;
 	switch (vm->getGameID()) {
@@ -74,9 +76,205 @@ void InventoryManager::refreshInventory() {
 }
 
 int InventoryManager::newDisplayInv() {
-	warning("TODO: newDisplayInv");
-	return 0;
+	Screen &screen = *_vm->_screen;
+	EventsManager &events = *_vm->_events;
+	Room &room = *_vm->_room;
+	FileManager &files = *_vm->_files;
+
+	_invModeFlag = true;
+	_vm->_timers.saveTimers();
+	
+	if (room._tile && !_invRefreshFlag) {
+		_vm->_buffer1.copyTo(&_savedBuffer1);
+		screen.copyTo(&_savedScreen);
+	}
+
+	savedFields();
+	screen.setPanel(1);
+	events._cursorExitFlag = false;
+	getList();
+	initFields();
+
+	files.loadScreen(99, 0);
+	_vm->_buffer1.copyTo(&_vm->_buffer2);
+	_vm->copyBF2Vid();
+
+	// Set cells
+	Common::Array<CellIdent> cells;
+	cells.push_back(CellIdent(99, 99, 1));
+	_vm->loadCells(cells);
+
+	showAllItems();
+
+	if (!_invRefreshFlag) {
+		chooseItem();
+		if (_vm->_useItem != -1) {
+			int savedScale = _vm->_scale;
+			_vm->_scale = 153;
+			_vm->_screen->setScaleTable(_vm->_scale);
+			_vm->_buffer1.clearBuffer();
+
+			SpriteResource *spr = _vm->_objectsTable[99];
+			SpriteFrame *frame = spr->getFrame(_vm->_useItem);
+
+			int w = screen._scaleTable1[46];
+			int h = screen._scaleTable1[35];
+			_vm->_buffer1.sPlotF(frame, Common::Rect(0, 0, w, h));
+			events.setCursorData(&_vm->_buffer1, Common::Rect(0, 0, w, h));
+
+			_vm->_scale = savedScale;
+			screen.setScaleTable(_vm->_scale);
+		}
+	}
+
+	freeInvCells();
+	screen.setPanel(0);
+	events.debounceLeft();
+
+	restoreFields();
+	screen.restorePalette();
+	if (!screen._vesaMode && !_invRefreshFlag) {
+		screen.clearBuffer();
+		screen.setPalette();
+	}
+
+	if (!room._tile && !_invRefreshFlag) {
+		_savedBuffer1.copyTo(&_vm->_buffer1);
+		_savedScreen.copyTo(_vm->_screen);
+	} else {
+		screen.setBufferScan();
+		room.buildScreen();
+
+		if (!screen._vesaMode) {
+			screen.fadeOut();
+			_vm->copyBF2Vid();
+		}
+	}
+
+	events._cursorExitFlag = false;
+	screen._screenChangeFlag = false;
+	_invModeFlag = false;
+	events.debounceLeft();
+	_vm->_timers.restoreTimers();
+	_vm->_startup = 1;
+
+	int result = 0;
+	if (!_invRefreshFlag) {
+		if (_vm->_useItem == -1) {
+			result = 2;
+		}
+	}
+
+	_invRefreshFlag = false;
+	_invChangeFlag = false;
+	return result;
+}
+
+void InventoryManager::savedFields() {
+	Screen &screen = *_vm->_screen;
+	Room &room = *_vm->_room;
+
+	_fields._vWindowHeight = screen._vWindowHeight;
+	_fields._vWindowLinesTall = screen._vWindowLinesTall;
+	_fields._vWindowWidth = screen._vWindowWidth;
+	_fields._vWindowBytesWide = screen._vWindowBytesWide;
+	_fields._playFieldHeight = room._playFieldHeight;
+	_fields._playFieldWidth = room._playFieldWidth;
+	_fields._windowXAdd = screen._windowXAdd;
+	_fields._windowYAdd = screen._windowYAdd;
+	_fields._screenYOff = screen._screenYOff;
+	_fields._scrollX = screen._scrollX;
+	_fields._scrollY = screen._scrollY;
+	_fields._clipWidth = screen._clipWidth;
+	_fields._clipHeight = screen._clipHeight;
+	_fields._bufferStart = screen._bufferStart;
+	_fields._scrollCol = screen._scrollCol;
+	_fields._scrollRow = screen._scrollRow;
+}
+
+void InventoryManager::restoreFields() {
+	Screen &screen = *_vm->_screen;
+	Room &room = *_vm->_room;
+
+	screen._vWindowHeight = _fields._vWindowHeight;
+	screen._vWindowLinesTall = _fields._vWindowLinesTall;
+	screen._vWindowWidth = _fields._vWindowWidth;
+	screen._vWindowBytesWide = _fields._vWindowBytesWide;
+	room._playFieldHeight = _fields._playFieldHeight;
+	room._playFieldWidth = _fields._playFieldWidth;
+	screen._windowXAdd = _fields._windowXAdd;
+	screen._windowYAdd = _fields._windowYAdd;
+	screen._screenYOff = _fields._screenYOff;
+	screen._scrollX = _fields._scrollX;
+	screen._scrollY = _fields._scrollY;
+	screen._clipWidth = _fields._clipWidth;
+	screen._clipHeight = _fields._clipHeight;
+	screen._bufferStart = _fields._bufferStart;
+	screen._scrollCol = _fields._scrollCol;
+	screen._scrollRow = _fields._scrollRow;
+}
+
+void InventoryManager::initFields() {
+	Screen &screen = *_vm->_screen;
+	Room &room = *_vm->_room;
+
+	screen._vWindowHeight = screen.h;
+	room._playFieldHeight = screen.h;
+	screen._vWindowLinesTall = screen.h;
+	screen._clipHeight = screen.h;
+	room._playFieldWidth = screen.w;
+	screen._vWindowWidth = screen.w;
+	screen._vWindowBytesWide = screen.w;
+	screen._clipWidth = screen.w;
+
+	screen._windowXAdd = 0;
+	screen._windowYAdd = 0;
+	screen._screenYOff = 0;
+	screen._scrollX = screen._scrollY = 0;
+	screen._bufferStart.x = 0;
+	screen._bufferStart.y = 0;
+
+	_vm->_buffer1.clearBuffer();
+	_vm->_buffer2.clearBuffer();
+	if (!_invRefreshFlag && !screen._vesaMode)
+		screen.clearBuffer();
+
+	screen.savePalette();
+}
+
+void InventoryManager::getList() {
+	_items.clear();
+	for (uint i = 0; i < _inv.size(); ++i) {
+		if (_inv[i])
+			_items.push_back(i);
+	}
+}
+
+void InventoryManager::showAllItems() {
+	for (uint i = 0; i < _items.size(); ++i)
+		putInvIcon(i, _items[i]);
+}
+
+void InventoryManager::putInvIcon(int itemIndex, int itemId) {
+	SpriteResource *spr = _vm->_objectsTable[99];
+	assert(spr);
+	Common::Point pt((itemIndex % 6) * 46 + 23, (itemIndex / 6) * 35 + 15);
+	_vm->_buffer2.plotImage(spr, itemId, pt);
+
+	if (_iconDisplayFlag) {
+		_vm->_buffer1.copyBlock(&_vm->_buffer2, Common::Rect(pt.x, pt.y, pt.x + 46, pt.y + 35));
+	}
+}
+
+void InventoryManager::chooseItem() {
+	_vm->_useItem = -1;
+
+	error("TODO: chooseItem");
 }
 
+void InventoryManager::freeInvCells() {
+	delete _vm->_objectsTable[99];
+	_vm->_objectsTable[99] = nullptr;
+}
 
 } // End of namespace Access
diff --git a/engines/access/inventory.h b/engines/access/inventory.h
index dddfe2e..019d7f4 100644
--- a/engines/access/inventory.h
+++ b/engines/access/inventory.h
@@ -28,10 +28,51 @@
 #include "common/rect.h"
 #include "common/str-array.h"
 #include "access/data.h"
+#include "access/asurface.h"
 
 namespace Access {
 
 class InventoryManager : public Manager {
+	struct SavedFields {
+		int _vWindowHeight;
+		int _vWindowLinesTall;
+		int _vWindowWidth;
+		int _vWindowBytesWide;
+		int _playFieldHeight;
+		int _playFieldWidth;
+		int _windowXAdd;
+		int _windowYAdd;
+		int _screenYOff;
+		int _scrollX;
+		int _scrollY;
+		int _clipWidth;
+		int _clipHeight;
+		Common::Point _bufferStart;
+		int _scrollCol;
+		int _scrollRow;
+	};
+private:
+	Common::Array<int> _items;
+	ASurface _savedBuffer1;
+	ASurface _savedScreen;
+	SavedFields _fields;
+	bool _iconDisplayFlag;
+
+	void savedFields();
+
+	void restoreFields();
+
+	void initFields();
+
+	void getList();
+
+	void showAllItems();
+
+	void putInvIcon(int itemIndex, int itemId);
+
+	void chooseItem();
+
+	void freeInvCells();
 public:
 	Common::Array<int> _inv;
 	Common::StringArray _names;
diff --git a/engines/access/resources.cpp b/engines/access/resources.cpp
index f0d74cc..e5a27a8 100644
--- a/engines/access/resources.cpp
+++ b/engines/access/resources.cpp
@@ -89,4 +89,33 @@ const char *const GENERAL_MESSAGES[] = {
 	GO_MESSAGE, TALK_MESSAGE, HELP_MESSAGE, HELP_MESSAGE, USE_MESSAGE
 };
 
+const int INVCOORDS[][4] = {
+	{ 23, 68, 15, 49 },
+	{ 69, 114, 15, 49 },
+	{ 115, 160, 15, 49 },
+	{ 161, 206, 15, 49 },
+	{ 207, 252, 15, 49 },
+	{ 253, 298, 15, 49 },
+	{ 23, 68, 50, 84 },
+	{ 69, 114, 50, 84 },
+	{ 115, 160, 50, 84 },
+	{ 161, 206, 50, 84 },
+	{ 207, 252, 50, 84 },
+	{ 253, 298, 50, 84 },
+	{ 23, 68, 85, 119 },
+	{ 69, 114, 85, 119 },
+	{ 115, 160, 85, 119 },
+	{ 161, 206, 85, 119 },
+	{ 207, 252, 85, 119 },
+	{ 253, 298, 85, 119 },
+	{ 23, 68, 120, 154 },
+	{ 69, 114, 120, 154 },
+	{ 115, 160, 120, 154 },
+	{ 161, 206, 120, 154 },
+	{ 207, 252, 120, 154 },
+	{ 253, 298, 120, 154 },
+	{ 237, 298, 177, 193 },
+	{ 25, 85, 177, 193 }
+};
+
 } // End of namespace Access
diff --git a/engines/access/resources.h b/engines/access/resources.h
index 241ed3a..6fb781e 100644
--- a/engines/access/resources.h
+++ b/engines/access/resources.h
@@ -58,6 +58,8 @@ extern const int RMOUSE[10][2];
 
 extern const char *const GENERAL_MESSAGES[];
 
+extern const int INVCOORDS[][4];
+
 } // End of namespace Access
 
 #endif /* ACCESS_RESOURCES_H */
diff --git a/engines/access/room.cpp b/engines/access/room.cpp
index 90ef347..a4be02d 100644
--- a/engines/access/room.cpp
+++ b/engines/access/room.cpp
@@ -451,34 +451,28 @@ void Room::executeCommand(int commandId) {
 
 	switch (commandId) {
 	case 0:
-		_vm->_events->_normalMouse = CURSOR_LOOK;
-		_vm->_events->_mouseMode = 0;
+		_vm->_events->setCursor(CURSOR_LOOK);
 		break;
 	case 2:
-		_vm->_events->_normalMouse = CURSOR_USE;
-		_vm->_events->_mouseMode = 0;
+		_vm->_events->setCursor(CURSOR_USE);
 		break;
 	case 3:
-		_vm->_events->_normalMouse = CURSOR_TAKE;
-		_vm->_events->_mouseMode = 0;
+		_vm->_events->setCursor(CURSOR_TAKE);
 		break;
 	case 4:
-		_vm->_events->_normalMouse = CURSOR_CROSSHAIRS;
 		_vm->_events->setCursor(CURSOR_ARROW);
 		if (_vm->_inventory->newDisplayInv() == 2) {
 			commandOff();
 			return;
 		} else {
-			warning("TODO: al = _useItem");
+			// TODO: al = _useItem?
 		}
 		break;
 	case 5:
-		_vm->_events->_normalMouse = CURSOR_CLIMB;
-		_vm->_events->_mouseMode = 0;
+		_vm->_events->setCursor(CURSOR_CLIMB);
 		break;
 	case 6:
-		_vm->_events->_normalMouse = CURSOR_TALK;
-		_vm->_events->_mouseMode = 0;
+		_vm->_events->setCursor(CURSOR_TALK);
 		break;
 	case 7:
 		_vm->_events->_normalMouse = CURSOR_CROSSHAIRS;
@@ -486,8 +480,7 @@ void Room::executeCommand(int commandId) {
 		_vm->_scripts->searchForSequence();
 		roomMenu();
 		_selectCommand = -1;
-		_vm->_events->_normalMouse = CURSOR_CROSSHAIRS;
-		_vm->_events->_mouseMode = 0;
+		_vm->_events->setCursor(CURSOR_CROSSHAIRS);
 
 		_conFlag = true;
 		while (_conFlag && !_vm->shouldQuit()) {
@@ -497,8 +490,7 @@ void Room::executeCommand(int commandId) {
 		_vm->_boxSelect = true;
 		break;
 	case 8:
-		_vm->_events->_normalMouse = CURSOR_HELP;
-		_vm->_events->_mouseMode = 0;
+		_vm->_events->setCursor(CURSOR_HELP);
 		break;
 	default:
 		break;
@@ -524,8 +516,7 @@ void Room::executeCommand(int commandId) {
 
 void Room::commandOff() {
 	_selectCommand = -1;
-	_vm->_events->_normalMouse = CURSOR_CROSSHAIRS;
-	_vm->_events->_mouseMode = 4;
+	_vm->_events->setCursor(CURSOR_CROSSHAIRS);
 	roomMenu();
 }
 
diff --git a/engines/access/room.h b/engines/access/room.h
index d876a30..6cd3b8c 100644
--- a/engines/access/room.h
+++ b/engines/access/room.h
@@ -76,7 +76,6 @@ private:
 protected:
 	void loadRoomData(const byte *roomData);
 	void setupRoom();
-	void buildScreen();
 
 	/**
 	* Free the playfield data
@@ -141,8 +140,19 @@ public:
 	 */
 	void clearRoom();
 
+	/**
+	 * Builds up a game screen
+	 */
+	void buildScreen();
+
+	/**
+	 * Draw a column of a game scene
+	 */
 	void buildColumn(int playX, int screenX);
 
+	/**
+	 * Draw a row of a game scene
+	 */
 	void buildRow(int playY, int screenY);
 
 	void init4Quads();


Commit: 7b1d0064fe3718142af2d764699d705cd2258669
    https://github.com/scummvm/scummvm/commit/7b1d0064fe3718142af2d764699d705cd2258669
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-08-24T11:02:14+02:00

Commit Message:
ACCESS: Fix the loading of text in doEstablish

Changed paths:
    engines/access/access.cpp



diff --git a/engines/access/access.cpp b/engines/access/access.cpp
index e90e5ba..0db3376 100644
--- a/engines/access/access.cpp
+++ b/engines/access/access.cpp
@@ -289,11 +289,16 @@ void AccessEngine::doEstablish(int esatabIndex, int sub) {
 	loadEstablish(sub);
 	_et = sub;
 	warning("CHECKME: Use of di");
+	Common::String msg;
+	int idx = READ_LE_UINT16(_eseg + (sub * 2) + 2);
+	for (int i = idx; _eseg[i] != 0; ++i)
+		msg += _eseg[i];
+
 	_printEnd = 155;
 	if (_txtPages == 0)
-		warning("TODO: printText();");
+		warning("TODO: printText(%s)", msg.c_str());
 	else
-		warning("TODO: speakText();");
+		warning("TODO: speakText(%s)", msg.c_str());
 
 	_screen->forceFadeOut();
 	_screen->clearScreen();


Commit: 1073646c8e20940ec606edac06ffd3e2eb015f49
    https://github.com/scummvm/scummvm/commit/1073646c8e20940ec606edac06ffd3e2eb015f49
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-24T12:18:41-04:00

Commit Message:
ACCESS: Fix negative seek in cmdSetVideoSound

Changed paths:
    engines/access/scripts.cpp



diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp
index 2a834f8..37d1d50 100644
--- a/engines/access/scripts.cpp
+++ b/engines/access/scripts.cpp
@@ -660,12 +660,14 @@ void Scripts::cmdLoadSound() {
 
 void Scripts::CMDFREESOUND() { error("TODO CMDFREESOUND"); }
 
-void Scripts::cmdSetVideoSound() { 
+void Scripts::cmdSetVideoSound() {
+	uint32 startPos = _data->pos();
 	_data->skip(4);
 	cmdLoadSound();
-	_data->skip(-6);
+	_data->seek(startPos);
 	cmdSetVideo();
 
+	_data->skip(2);
 	_vm->_sound->_soundFrame = _data->readUint16LE();
 	_vm->_sound->_soundFlag = false;
 }


Commit: 89a3c43da1318644b14531b69ed1b38708a6413a
    https://github.com/scummvm/scummvm/commit/89a3c43da1318644b14531b69ed1b38708a6413a
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-24T12:32:11-04:00

Commit Message:
ACCESS: More work on inventory screen setup

Changed paths:
    engines/access/asurface.cpp
    engines/access/files.cpp
    engines/access/files.h
    engines/access/inventory.cpp
    engines/access/inventory.h



diff --git a/engines/access/asurface.cpp b/engines/access/asurface.cpp
index ce977f6..0db44c4 100644
--- a/engines/access/asurface.cpp
+++ b/engines/access/asurface.cpp
@@ -208,6 +208,9 @@ void ASurface::plotImage(SpriteResource *sprite, int frameNum, const Common::Poi
 }
 
 void ASurface::copyTo(ASurface *dest, const Common::Point &destPos) {
+	if (dest->getPixels() == nullptr)
+		dest->create(w, h);
+
 	for (int yp = 0; yp < h; ++yp) {
 		byte *srcP = (byte *)getBasePtr(0, yp);
 		byte *destP = (byte *)dest->getBasePtr(destPos.x, destPos.y + yp);
diff --git a/engines/access/files.cpp b/engines/access/files.cpp
index 230d2a8..5cf4670 100644
--- a/engines/access/files.cpp
+++ b/engines/access/files.cpp
@@ -104,17 +104,21 @@ void FileManager::openFile(const Common::String &filename) {
 	_filesize = _file.size();
 }
 
-void FileManager::loadScreen(int fileNum, int subfile) {
+void FileManager::loadScreen(Graphics::Surface *dest, int fileNum, int subfile) {
 	setAppended(fileNum);
 	gotoAppended(subfile);
 	_vm->_screen->loadPalette(_stream);
 
 	// Get the data for the screen, and copy it over
 	byte *pSrc = handleFile();
-	Common::copy(pSrc, pSrc + _filesize, (byte *)_vm->_screen->getPixels());
+	Common::copy(pSrc, pSrc + _filesize, (byte *)dest->getPixels());
 	delete[] pSrc;
 }
 
+void FileManager::loadScreen(int fileNum, int subfile) {
+	loadScreen(_vm->_screen, fileNum, subfile);
+}
+
 void FileManager::loadScreen(const Common::String &filename) {
 	// Open the file
 	openFile(filename);
diff --git a/engines/access/files.h b/engines/access/files.h
index d1a4d5a..b13a796 100644
--- a/engines/access/files.h
+++ b/engines/access/files.h
@@ -26,6 +26,7 @@
 #include "common/scummsys.h"
 #include "common/array.h"
 #include "common/file.h"
+#include "graphics/surface.h"
 #include "access/decompress.h"
 
 namespace Access {
@@ -97,6 +98,11 @@ public:
 	void loadScreen(const Common::String &filename);
 
 	/**
+	 * Load a screen resource onto a designated surface
+	 */
+	void loadScreen(Graphics::Surface *dest, int fileNum, int subfile);
+
+	/**
 	 * Open up a sub-file container file
 	 */
 	void setAppended(int fileNum);
diff --git a/engines/access/inventory.cpp b/engines/access/inventory.cpp
index 6c56f6b..80336e4 100644
--- a/engines/access/inventory.cpp
+++ b/engines/access/inventory.cpp
@@ -54,6 +54,11 @@ InventoryManager::InventoryManager(AccessEngine *vm) : Manager(vm) {
 
 	for (uint i = 0; i < _inv.size(); ++i)
 		_names.push_back(names[i]);
+
+	for (uint i = 0; i < 26; ++i) {
+		const int *r = INVCOORDS[i];
+		_invCoords.push_back(Common::Rect(r[0], r[1], r[0] + r[2], r[1] + r[3]));
+	}
 }
 
 int &InventoryManager::operator[](int idx) {
@@ -95,7 +100,7 @@ int InventoryManager::newDisplayInv() {
 	getList();
 	initFields();
 
-	files.loadScreen(99, 0);
+	_vm->_files->loadScreen(&_vm->_buffer1, 99, 0);
 	_vm->_buffer1.copyTo(&_vm->_buffer2);
 	_vm->copyBF2Vid();
 
@@ -267,9 +272,26 @@ void InventoryManager::putInvIcon(int itemIndex, int itemId) {
 }
 
 void InventoryManager::chooseItem() {
+	EventsManager &events = *_vm->_events;
 	_vm->_useItem = -1;
-
-	error("TODO: chooseItem");
+	int selIndex;
+
+	while (!_vm->shouldQuit()) {
+		g_system->delayMillis(10);
+
+		// Poll events and wait for a click on a known area
+		events.pollEvents();
+		if (!events._leftButton || ((selIndex = coordIndexOf()) == -1))
+			continue;
+
+		if (selIndex > 23) {
+			if (selIndex == 25)
+				_vm->_useItem = -1;
+			break;
+		} else if (selIndex < (int)_items.size()) {
+			warning("TODO: Combine items");
+		}
+	}
 }
 
 void InventoryManager::freeInvCells() {
@@ -277,4 +299,16 @@ void InventoryManager::freeInvCells() {
 	_vm->_objectsTable[99] = nullptr;
 }
 
+int InventoryManager::coordIndexOf() {
+	const Common::Point pt = _vm->_events->_mousePos;
+
+	for (int i = 0; i < (int)_invCoords.size(); ++i) {
+		if (_invCoords[i].contains(pt))
+			return i;
+	}
+
+	return -1;
+}
+
+
 } // End of namespace Access
diff --git a/engines/access/inventory.h b/engines/access/inventory.h
index 019d7f4..cf8167d 100644
--- a/engines/access/inventory.h
+++ b/engines/access/inventory.h
@@ -53,6 +53,7 @@ class InventoryManager : public Manager {
 	};
 private:
 	Common::Array<int> _items;
+	Common::Array<Common::Rect> _invCoords;
 	ASurface _savedBuffer1;
 	ASurface _savedScreen;
 	SavedFields _fields;
@@ -73,6 +74,8 @@ private:
 	void chooseItem();
 
 	void freeInvCells();
+
+	int coordIndexOf();
 public:
 	Common::Array<int> _inv;
 	Common::StringArray _names;


Commit: 6774dd42467265e4083fd7f97447d7ce2f437529
    https://github.com/scummvm/scummvm/commit/6774dd42467265e4083fd7f97447d7ce2f437529
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-08-24T18:49:34+02:00

Commit Message:
ACCESS: Implement speakText()

Changed paths:
    engines/access/access.cpp
    engines/access/access.h
    engines/access/scripts.cpp
    engines/access/scripts.h
    engines/access/sound.h



diff --git a/engines/access/access.cpp b/engines/access/access.cpp
index 0db3376..9cddd1b 100644
--- a/engines/access/access.cpp
+++ b/engines/access/access.cpp
@@ -264,6 +264,90 @@ void AccessEngine::loadEstablish(int sub) {
 		_countTbl[i] = READ_LE_UINT16(_eseg + idx + 6 + (2 * i));
 }
 
+void AccessEngine::speakText(int idx) {
+	int curPage = 0;
+	int soundsLeft = 0;
+
+	Common::String msg;
+	for (int i = idx; _eseg[i] != 0; ++i)
+		msg += _eseg[i];
+
+	while(true) {
+		soundsLeft = _countTbl[curPage];
+		_events->zeroKeys();
+
+		Common::String line;
+		int width = 0;
+		bool lastLine = _fonts._font2.getLine(msg, _bubbleBox->_maxChars * 6, line, width);
+		// Set font colors
+		_fonts._font2._fontColors[0] = 0;
+		_fonts._font2._fontColors[1] = 28;
+		_fonts._font2._fontColors[2] = 29;
+		_fonts._font2._fontColors[3] = 30;
+
+		_fonts._font2.drawString(_screen, line, _fonts._printOrg);
+		_fonts._printOrg = Common::Point(_fonts._printStart.x, _fonts._printOrg.y + 9);
+
+		if ((_fonts._printOrg.y > _printEnd) && (!lastLine)) {
+			while (true) {
+				_sound->_soundTable[0]._data = _sound->loadSound(_narateFile + 99, _sndSubFile);
+				_sound->_soundPriority[0] = 1;
+				_sound->playSound(1);
+				_scripts->CMDFREESOUND();
+
+				_events->pollEvents();
+
+				if (_events->_leftButton) {
+					_events->debounceLeft();
+					_sndSubFile += soundsLeft;
+					break;
+				} else if (_events->_keypresses.size() != 0) {
+					_sndSubFile += soundsLeft;
+					break;
+				} else {
+					++_sndSubFile;
+					--soundsLeft;
+					if (soundsLeft == 0)
+						break;
+				}
+			}
+			_buffer2.copyBuffer(_screen);
+			_fonts._printOrg.y = _fonts._printStart.y;
+			++curPage;
+			soundsLeft = _countTbl[curPage];
+		}
+
+		if (lastLine)
+			break;
+	}
+
+	if (soundsLeft == 0)
+		return;
+
+	while(true) {
+		_sound->_soundTable[0]._data = _sound->loadSound(_narateFile + 99, _sndSubFile);
+		_sound->_soundPriority[0] = 1;
+		_sound->playSound(1);
+		_scripts->CMDFREESOUND();
+
+		_events->pollEvents();
+
+		if (_events->_leftButton) {
+			_events->debounceLeft();
+			_sndSubFile += soundsLeft;
+			break;
+		} else if (_events->_keypresses.size() != 0) {
+			_sndSubFile += soundsLeft;
+			break;
+		} else {
+			++_sndSubFile;
+			--soundsLeft;
+			if (soundsLeft == 0)
+				break;
+		}
+	}
+}
+
 void AccessEngine::doEstablish(int esatabIndex, int sub) {
 	_establishMode = 1;
 
@@ -289,16 +373,13 @@ void AccessEngine::doEstablish(int esatabIndex, int sub) {
 	loadEstablish(sub);
 	_et = sub;
 	warning("CHECKME: Use of di");
-	Common::String msg;
 	int idx = READ_LE_UINT16(_eseg + (sub * 2) + 2);
-	for (int i = idx; _eseg[i] != 0; ++i)
-		msg += _eseg[i];
 
 	_printEnd = 155;
 	if (_txtPages == 0)
-		warning("TODO: printText(%s)", msg.c_str());
+		warning("TODO: printText()");
 	else
-		warning("TODO: speakText(%s)", msg.c_str());
+		speakText(idx);
 
 	_screen->forceFadeOut();
 	_screen->clearScreen();
diff --git a/engines/access/access.h b/engines/access/access.h
index db96935..bd1269f 100644
--- a/engines/access/access.h
+++ b/engines/access/access.h
@@ -91,6 +91,8 @@ private:
 
 	void dummyLoop();
 
+	void speakText(int idx);
+
 	void doEstablish(int esatabIndex, int sub);
 protected:
 	const AccessGameDescription *_gameDescription;
diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp
index 37d1d50..6ee8eb0 100644
--- a/engines/access/scripts.cpp
+++ b/engines/access/scripts.cpp
@@ -658,7 +658,7 @@ void Scripts::cmdLoadSound() {
 	_vm->_sound->_soundPriority[0] = 1;
 }
 
-void Scripts::CMDFREESOUND() { error("TODO CMDFREESOUND"); }
+void Scripts::CMDFREESOUND() { warning("TODO CMDFREESOUND"); }
 
 void Scripts::cmdSetVideoSound() {
 	uint32 startPos = _data->pos();
diff --git a/engines/access/scripts.h b/engines/access/scripts.h
index 93cd495..aa5c406 100644
--- a/engines/access/scripts.h
+++ b/engines/access/scripts.h
@@ -113,7 +113,6 @@ protected:
 	void cmdReturnChoice();
 	void cmdClearBlock();
 	void cmdLoadSound();
-	void CMDFREESOUND();
 	void cmdSetVideoSound();
 	void CMDPLAYVIDSND();
 	void CMDPUSHLOCATION();
@@ -144,6 +143,8 @@ public:
 	int executeScript();
 
 	void findNull();
+
+	void CMDFREESOUND();
 };
 
 } // End of namespace Access
diff --git a/engines/access/sound.h b/engines/access/sound.h
index cb73bae..e0992db 100644
--- a/engines/access/sound.h
+++ b/engines/access/sound.h
@@ -42,8 +42,6 @@ private:
 	Audio::Mixer *_mixer;
 	Audio::SoundHandle _soundHandle;
 
-	byte *loadSound(int fileNum, int subfile);
-
 	void playSound(byte *data, uint32 size);
 public:
 	SoundEntry _soundTable[MAX_SOUNDS];
@@ -61,6 +59,7 @@ public:
 
 	void playSound(int soundIndex);
 
+	byte *loadSound(int fileNum, int subfile);
 	void loadSounds(Common::Array<RoomInfo::SoundIdent> &sounds);
 
 	void midiPlay();


Commit: e53417f91a1305cfb69ef57dd97a5f8fe5311eee
    https://github.com/scummvm/scummvm/commit/e53417f91a1305cfb69ef57dd97a5f8fe5311eee
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-24T14:42:26-04:00

Commit Message:
ACCESS: Fix loading of inventory screen background

Changed paths:
    engines/access/files.cpp
    engines/access/inventory.cpp
    engines/access/inventory.h



diff --git a/engines/access/files.cpp b/engines/access/files.cpp
index 5cf4670..b1d6140 100644
--- a/engines/access/files.cpp
+++ b/engines/access/files.cpp
@@ -111,7 +111,19 @@ void FileManager::loadScreen(Graphics::Surface *dest, int fileNum, int subfile)
 
 	// Get the data for the screen, and copy it over
 	byte *pSrc = handleFile();
-	Common::copy(pSrc, pSrc + _filesize, (byte *)dest->getPixels());
+
+	if (dest != _vm->_screen)
+		dest->w = _vm->_screen->w;
+
+	if (dest->w == dest->pitch) {
+		Common::copy(pSrc, pSrc + _filesize, (byte *)dest->getPixels());
+	} else {
+		byte *pCurr = pSrc;
+		for (int y = 0; y < dest->h; ++y, pCurr += dest->w) {
+			byte *pDest = (byte *)dest->getBasePtr(0, y);
+			Common::copy(pCurr, pCurr + dest->w, pDest);
+		}
+	}
 	delete[] pSrc;
 }
 
diff --git a/engines/access/inventory.cpp b/engines/access/inventory.cpp
index 80336e4..1bafdf5 100644
--- a/engines/access/inventory.cpp
+++ b/engines/access/inventory.cpp
@@ -90,8 +90,7 @@ int InventoryManager::newDisplayInv() {
 	_vm->_timers.saveTimers();
 	
 	if (room._tile && !_invRefreshFlag) {
-		_vm->_buffer1.copyTo(&_savedBuffer1);
-		screen.copyTo(&_savedScreen);
+		saveScreens();
 	}
 
 	savedFields();
@@ -144,8 +143,7 @@ int InventoryManager::newDisplayInv() {
 	}
 
 	if (!room._tile && !_invRefreshFlag) {
-		_savedBuffer1.copyTo(&_vm->_buffer1);
-		_savedScreen.copyTo(_vm->_screen);
+		restoreScreens();
 	} else {
 		screen.setBufferScan();
 		room.buildScreen();
@@ -310,5 +308,15 @@ int InventoryManager::coordIndexOf() {
 	return -1;
 }
 
+void InventoryManager::saveScreens() {
+	_vm->_buffer1.copyTo(&_savedBuffer1);
+	_vm->_screen->copyTo(&_savedScreen);
+}
+
+void InventoryManager::restoreScreens() {
+	_vm->_buffer1.w = _vm->_buffer1.pitch;
+	_savedBuffer1.copyTo(&_vm->_buffer1);
+	_savedScreen.copyTo(_vm->_screen);
+}
 
 } // End of namespace Access
diff --git a/engines/access/inventory.h b/engines/access/inventory.h
index cf8167d..255b6dc 100644
--- a/engines/access/inventory.h
+++ b/engines/access/inventory.h
@@ -76,6 +76,10 @@ private:
 	void freeInvCells();
 
 	int coordIndexOf();
+
+	void saveScreens();
+
+	void restoreScreens();
 public:
 	Common::Array<int> _inv;
 	Common::StringArray _names;


Commit: ce97ba5587daecd262f44cd240efb23f6bd24e8b
    https://github.com/scummvm/scummvm/commit/ce97ba5587daecd262f44cd240efb23f6bd24e8b
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-24T16:49:57-04:00

Commit Message:
ACCeSS: Fix display of items in inventory screen

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



diff --git a/engines/access/inventory.cpp b/engines/access/inventory.cpp
index 1bafdf5..f4236cc 100644
--- a/engines/access/inventory.cpp
+++ b/engines/access/inventory.cpp
@@ -36,7 +36,7 @@ InventoryManager::InventoryManager(AccessEngine *vm) : Manager(vm) {
 	_invModeFlag = false;
 	_startAboutItem = 0;
 	_startTravelItem = 0;
-	_iconDisplayFlag = false;
+	_iconDisplayFlag = true;
 
 	const char *const *names;
 	switch (vm->getGameID()) {
@@ -57,7 +57,7 @@ InventoryManager::InventoryManager(AccessEngine *vm) : Manager(vm) {
 
 	for (uint i = 0; i < 26; ++i) {
 		const int *r = INVCOORDS[i];
-		_invCoords.push_back(Common::Rect(r[0], r[1], r[0] + r[2], r[1] + r[3]));
+		_invCoords.push_back(Common::Rect(r[0], r[2], r[1], r[3]));
 	}
 }
 
@@ -99,7 +99,7 @@ int InventoryManager::newDisplayInv() {
 	getList();
 	initFields();
 
-	_vm->_files->loadScreen(&_vm->_buffer1, 99, 0);
+	files.loadScreen(&_vm->_buffer1, 99, 0);
 	_vm->_buffer1.copyTo(&_vm->_buffer2);
 	_vm->copyBF2Vid();
 
@@ -247,9 +247,13 @@ void InventoryManager::initFields() {
 
 void InventoryManager::getList() {
 	_items.clear();
+	_tempLOff.clear();
+
 	for (uint i = 0; i < _inv.size(); ++i) {
-		if (_inv[i])
+		if (_inv[i]) {
 			_items.push_back(i);
+			_tempLOff.push_back(_names[i]);
+		}
 	}
 }
 
@@ -265,7 +269,7 @@ void InventoryManager::putInvIcon(int itemIndex, int itemId) {
 	_vm->_buffer2.plotImage(spr, itemId, pt);
 
 	if (_iconDisplayFlag) {
-		_vm->_buffer1.copyBlock(&_vm->_buffer2, Common::Rect(pt.x, pt.y, pt.x + 46, pt.y + 35));
+		_vm->_screen->copyBlock(&_vm->_buffer2, Common::Rect(pt.x, pt.y, pt.x + 46, pt.y + 35));
 	}
 }
 
@@ -287,7 +291,12 @@ void InventoryManager::chooseItem() {
 				_vm->_useItem = -1;
 			break;
 		} else if (selIndex < (int)_items.size()) {
-			warning("TODO: Combine items");
+			_boxNum = selIndex;
+			_vm->copyBF2Vid();
+			combineItems();
+			_vm->copyBF2Vid();
+			outlineIcon(_boxNum);
+			_vm->_useItem = _items[_boxNum];
 		}
 	}
 }
@@ -311,6 +320,8 @@ int InventoryManager::coordIndexOf() {
 void InventoryManager::saveScreens() {
 	_vm->_buffer1.copyTo(&_savedBuffer1);
 	_vm->_screen->copyTo(&_savedScreen);
+	_vm->_newRects.push_back(Common::Rect(0, 0, _savedScreen.w, _savedScreen.h));
+	
 }
 
 void InventoryManager::restoreScreens() {
@@ -319,4 +330,24 @@ void InventoryManager::restoreScreens() {
 	_savedScreen.copyTo(_vm->_screen);
 }
 
+void InventoryManager::outlineIcon(int itemIndex) {
+	Screen &screen = *_vm->_screen;
+	screen.frameRect(_invCoords[itemIndex], 7);
+
+	Common::String s = _tempLOff[itemIndex];
+	Font &font = _vm->_fonts._font2;
+	int strWidth = font.stringWidth(s);
+
+	font._fontColors[0] = 0;
+	font._fontColors[1] = 10;
+	font._fontColors[2] = 11;
+	font._fontColors[3] = 12;
+	font.drawString(&screen, s, Common::Point((screen.w - strWidth) / 2, 184));
+}
+
+void InventoryManager::combineItems() {
+	warning("TODO: combineItems");
+}
+
+
 } // End of namespace Access
diff --git a/engines/access/inventory.h b/engines/access/inventory.h
index 255b6dc..a95581c 100644
--- a/engines/access/inventory.h
+++ b/engines/access/inventory.h
@@ -58,6 +58,10 @@ private:
 	ASurface _savedScreen;
 	SavedFields _fields;
 	bool _iconDisplayFlag;
+	Common::StringArray _names;
+	Common::Array<int> _tempLPtr;
+	Common::StringArray _tempLOff;
+	int _boxNum;
 
 	void savedFields();
 
@@ -80,9 +84,12 @@ private:
 	void saveScreens();
 
 	void restoreScreens();
+
+	void outlineIcon(int itemIndex);
+
+	void combineItems();
 public:
 	Common::Array<int> _inv;
-	Common::StringArray _names;
 	int _startInvItem;
 	int _startInvBox;
 	bool _invChangeFlag;


Commit: 3e14e7b9663130d1a730aaf6821c766b505ebdba
    https://github.com/scummvm/scummvm/commit/3e14e7b9663130d1a730aaf6821c766b505ebdba
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-24T17:31:41-04:00

Commit Message:
ACCESS: Fix selection of inventory items

Changed paths:
    engines/access/inventory.cpp
    engines/access/room.cpp



diff --git a/engines/access/inventory.cpp b/engines/access/inventory.cpp
index f4236cc..dbc3cba 100644
--- a/engines/access/inventory.cpp
+++ b/engines/access/inventory.cpp
@@ -165,6 +165,11 @@ int InventoryManager::newDisplayInv() {
 	if (!_invRefreshFlag) {
 		if (_vm->_useItem == -1) {
 			result = 2;
+			events._normalMouse = CURSOR_CROSSHAIRS;
+			events.setCursor(CURSOR_CROSSHAIRS);
+		} else {
+			events.setCursor(CURSOR_INVENTORY);
+			events._normalMouse = CURSOR_INVENTORY;
 		}
 	}
 
diff --git a/engines/access/room.cpp b/engines/access/room.cpp
index a4be02d..b00b1cf 100644
--- a/engines/access/room.cpp
+++ b/engines/access/room.cpp
@@ -447,20 +447,24 @@ void Room::handleCommand(int commandId) {
 }
 
 void Room::executeCommand(int commandId) {
+	EventsManager &events = *_vm->_events;
 	_selectCommand = commandId;
 
 	switch (commandId) {
 	case 0:
-		_vm->_events->setCursor(CURSOR_LOOK);
+		events._normalMouse = CURSOR_LOOK;
+		events.setCursor(CURSOR_LOOK);
 		break;
 	case 2:
-		_vm->_events->setCursor(CURSOR_USE);
+		events._normalMouse = CURSOR_USE;
+		events.setCursor(CURSOR_USE);
 		break;
 	case 3:
-		_vm->_events->setCursor(CURSOR_TAKE);
+		events._normalMouse = CURSOR_TAKE;
+		events.setCursor(CURSOR_TAKE);
 		break;
 	case 4:
-		_vm->_events->setCursor(CURSOR_ARROW);
+		events.setCursor(CURSOR_ARROW);
 		if (_vm->_inventory->newDisplayInv() == 2) {
 			commandOff();
 			return;
@@ -469,18 +473,20 @@ void Room::executeCommand(int commandId) {
 		}
 		break;
 	case 5:
-		_vm->_events->setCursor(CURSOR_CLIMB);
+		events._normalMouse = CURSOR_CLIMB;
+		events.setCursor(CURSOR_CLIMB);
 		break;
 	case 6:
-		_vm->_events->setCursor(CURSOR_TALK);
+		events._normalMouse = CURSOR_TALK;
+		events.setCursor(CURSOR_TALK);
 		break;
 	case 7:
-		_vm->_events->_normalMouse = CURSOR_CROSSHAIRS;
+		events._normalMouse = CURSOR_CROSSHAIRS;
+		events.setCursor(CURSOR_CROSSHAIRS);
 		_vm->_scripts->_sequence = 5000;
 		_vm->_scripts->searchForSequence();
 		roomMenu();
 		_selectCommand = -1;
-		_vm->_events->setCursor(CURSOR_CROSSHAIRS);
 
 		_conFlag = true;
 		while (_conFlag && !_vm->shouldQuit()) {
@@ -490,7 +496,7 @@ void Room::executeCommand(int commandId) {
 		_vm->_boxSelect = true;
 		break;
 	case 8:
-		_vm->_events->setCursor(CURSOR_HELP);
+		events.setCursor(CURSOR_HELP);
 		break;
 	default:
 		break;


Commit: d97cc677e106c39af278e6175d139d8a8ab0cc3e
    https://github.com/scummvm/scummvm/commit/d97cc677e106c39af278e6175d139d8a8ab0cc3e
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-24T21:05:35-04:00

Commit Message:
ACCESS: Fix mapping of _useItem onto flags array

Changed paths:
    engines/access/access.cpp



diff --git a/engines/access/access.cpp b/engines/access/access.cpp
index 9cddd1b..cea5a73 100644
--- a/engines/access/access.cpp
+++ b/engines/access/access.cpp
@@ -31,7 +31,7 @@ namespace Access {
 
 AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc) :
 		_gameDescription(gameDesc), Engine(syst), _randomSource("Access"),
-		_useItem(_flags[100]), _startup(_flags[170]), _manScaleOff(_flags[172]) {
+		_useItem(_flags[99]), _startup(_flags[170]), _manScaleOff(_flags[172]) {
 	_animation = nullptr;
 	_bubbleBox = nullptr;
 	_char = nullptr;


Commit: b7ea1133b43f3640f44dc3e5f3a3136f72729770
    https://github.com/scummvm/scummvm/commit/b7ea1133b43f3640f44dc3e5f3a3136f72729770
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-24T21:42:02-04:00

Commit Message:
ACCESS: Set hotspot for inventory item cursors to be their center

Changed paths:
    engines/access/events.cpp



diff --git a/engines/access/events.cpp b/engines/access/events.cpp
index 15c8f8c..7366905 100644
--- a/engines/access/events.cpp
+++ b/engines/access/events.cpp
@@ -56,7 +56,7 @@ void EventsManager::setCursor(CursorType cursorId) {
 	if (cursorId == CURSOR_INVENTORY) {
 		// Set the cursor
 		CursorMan.replaceCursor(_invCursor.getPixels(), _invCursor.w, _invCursor.h,
-			0, 0, 0);
+			_invCursor.w / 2, _invCursor.h / 2, 0);
 	} else {
 		// Get a pointer to the mouse data to use, and get the cursor hotspot
 		const byte *srcP = Amazon::CURSORS[cursorId];


Commit: f993c8dd46c240daa7022f359542e743d9c7a888
    https://github.com/scummvm/scummvm/commit/f993c8dd46c240daa7022f359542e743d9c7a888
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-24T22:42:24-04:00

Commit Message:
ACCESS: Improved right scrolling

Changed paths:
    engines/access/player.cpp
    engines/access/room.cpp



diff --git a/engines/access/player.cpp b/engines/access/player.cpp
index 7df277c..336be0d 100644
--- a/engines/access/player.cpp
+++ b/engines/access/player.cpp
@@ -819,7 +819,7 @@ bool Player::scrollRight() {
 
 			_vm->_buffer1.moveBufferRight();
 			_vm->_room->buildColumn(_vm->_screen->_scrollCol, 0);
-		} while (!_vm->shouldQuit() && (_vm->_screen->_scrollX >= 0));
+		} while (!_vm->shouldQuit() && (_vm->_screen->_scrollX < 0));
 
 		return false;
 	}
diff --git a/engines/access/room.cpp b/engines/access/room.cpp
index b00b1cf..29d9eef 100644
--- a/engines/access/room.cpp
+++ b/engines/access/room.cpp
@@ -468,8 +468,6 @@ void Room::executeCommand(int commandId) {
 		if (_vm->_inventory->newDisplayInv() == 2) {
 			commandOff();
 			return;
-		} else {
-			// TODO: al = _useItem?
 		}
 		break;
 	case 5:


Commit: 89993e128fe15efd16fdf89696682f0e24cb8593
    https://github.com/scummvm/scummvm/commit/89993e128fe15efd16fdf89696682f0e24cb8593
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-24T23:59:37-04:00

Commit Message:
ACCESS: Split font code into a separate file

Changed paths:
  A engines/access/font.cpp
  A engines/access/font.h
    engines/access/access.h
    engines/access/data.cpp
    engines/access/data.h
    engines/access/module.mk



diff --git a/engines/access/access.h b/engines/access/access.h
index bd1269f..2aa4130 100644
--- a/engines/access/access.h
+++ b/engines/access/access.h
@@ -37,6 +37,7 @@
 #include "access/debugger.h"
 #include "access/events.h"
 #include "access/files.h"
+#include "access/font.h"
 #include "access/inventory.h"
 #include "access/player.h"
 #include "access/room.h"
diff --git a/engines/access/data.cpp b/engines/access/data.cpp
index a13c6d9..0279cd5 100644
--- a/engines/access/data.cpp
+++ b/engines/access/data.cpp
@@ -59,148 +59,4 @@ void TimerList::updateTimers() {
 	}
 }
 
-/*------------------------------------------------------------------------*/
-
-byte Font::_fontColors[4];
-
-Font::Font() {
-}
-
-Font::~Font() {
-	for (uint i = 0; i < _chars.size(); ++i)
-		_chars[i].free();
-}
-
-void Font::load(const int *fontIndex, const byte *fontData) {
-	assert(_chars.size() == 0);
-	int count = fontIndex[0];
-	_bitWidth = fontIndex[1];
-	_height = fontIndex[2];
-
-	_chars.resize(count);
-
-	for (int i = 0; i < count; ++i) {
-		const byte *pData = fontData + fontIndex[i + 3];
-		_chars[i].create(*pData++, _height, Graphics::PixelFormat::createFormatCLUT8());
-
-		for (int y = 0; y < _height; ++y) {
-			int bitsLeft = 0;
-			byte srcByte = 0;
-			byte pixel;
-			
-			byte *pDest = (byte *)_chars[i].getBasePtr(0, y);
-			for (int x = 0; x < _chars[i].w; ++x, ++pDest) {
-				// Get the pixel
-				pixel = 0;
-				for (int pixelCtr = 0; pixelCtr < _bitWidth; ++pixelCtr, --bitsLeft) {
-					// No bits in current byte left, so get next byte
-					if (bitsLeft == 0) {
-						bitsLeft = 8;
-						srcByte = *pData++;
-					}
-
-					pixel = (pixel << 1) | (srcByte >> 7);
-					srcByte <<= 1;
-				}
-
-				// Write out the pixel
-				*pDest = pixel;
-			}
-		}
-	}
-}
-
-int Font::charWidth(char c) {
-	return _chars[c - ' '].w;
-}
-
-int Font::stringWidth(const Common::String &msg) {
-	int total = 0;
-
-	for (const char *c = msg.c_str(); *c != '\0'; ++c)
-		total += charWidth(*c);
-
-	return total;
-}
-
-bool Font::getLine(Common::String &s, int maxWidth, Common::String &line, int &width) {
-	assert(maxWidth > 0);
-	width = 0;
-	const char *src = s.c_str();
-	char c;
-
-	while ((c = *src) != '\0') {
-		if (c == '\r') {
-			// End of line, so return calculated line
-			line = Common::String(s.c_str(), src - 1);
-			s = Common::String(src + 1);
-			return false;
-		}
-
-		++src;
-		width += charWidth(c);
-		if (width < maxWidth)
-			continue;
-
-		// Reached maximum allowed size
-		// If this was the last character of the string, let it go
-		if (*src == '\0')
-			break;
-		
-		// Work backwards to find space at the start of the current word 
-		// as a point to split the line on
-		while (src >= s.c_str() && *src != ' ') {
-			width -= charWidth(*src);
-			--src;
-		}
-		if (src < s.c_str())
-			error("Could not fit line");
-
-		// Split the line around the space
-		line = Common::String(s.c_str(), src);
-		s = Common::String(src + 1);
-		return false;
-	}
-
-	// Return entire string
-	line = s;
-	s = Common::String();
-	return true;
-}
-
-void Font::drawString(Graphics::Surface *s, const Common::String &msg, const Common::Point &pt) {
-	Common::Point currPt = pt;
-	const char *msgP = msg.c_str();
-
-	while (*msgP) {
-		currPt.x += drawChar(s, *msgP, currPt);
-		++msgP;
-	}
-}
-
-int Font::drawChar(Graphics::Surface *s, char c, Common::Point &pt) {
-	Graphics::Surface &ch = _chars[c - ' '];
-
-	// Loop through the lines of the character
-	for (int y = 0; y < ch.h; ++y) {
-		byte *pSrc = (byte *)ch.getBasePtr(0, y);
-		byte *pDest = (byte *)s->getBasePtr(pt.x, pt.y + y);
-
-		// Loop through the horizontal pixels of the line
-		for (int x = 0; x < ch.w; ++x, ++pSrc, ++pDest) {
-			if (*pSrc != 0)
-				*pDest = _fontColors[*pSrc];
-		}
-	}
-
-	return ch.w;
-}
-
-/*------------------------------------------------------------------------*/
-
-FontManager::FontManager() {
-	_printMaxX = 0;
-	Common::fill(&Font::_fontColors[0], &Font::_fontColors[4], 0);
-}
-
 } // End of namespace Access
diff --git a/engines/access/data.h b/engines/access/data.h
index 3238daf..1d64a6f 100644
--- a/engines/access/data.h
+++ b/engines/access/data.h
@@ -82,74 +82,6 @@ public:
 	FileIdent _vidSound;
 };
 
-struct FontVal {
-public:
-	int _lo, _hi;
-
-	FontVal() { _lo = _hi = 0; }
-};
-
-class Font {
-private:
-	int _bitWidth;
-	int _height;
-	Common::Array<Graphics::Surface> _chars;
-public:
-	static byte _fontColors[4];
-public:
-	Font();
-
-	~Font();
-
-	/**
-	 * Load the given font data
-	 */
-	void load(const int *fontIndex, const byte *fontData);
-
-	/**
-	 * Get the width of a given character
-	 */
-	int charWidth(char c);
-
-	/**
-	 * Get the width of a given string
-	 */
-	int stringWidth(const Common::String &msg);
-
-	/**
-	 * Get a partial string that will fit in a given width
-	 * @param s			Source string. Modified to remove line
-	 * @param maxWidth	Maximum width allowed
-	 * @param line		Output line
-	 * @param width		Calculated width of returned line
-	 * @returns			True if last line
-	 */
-	bool getLine(Common::String &s, int maxWidth, Common::String &line, int &width);
-
-	/**
-	 * Draw a string on a given surface
-	 */
-	void drawString(Graphics::Surface *s, const Common::String &msg, const Common::Point &pt);
-
-	/**
-	 * Draw a character on a given surface
-	 */
-	int drawChar(Graphics::Surface *s, char c, Common::Point &pt);
-};
-
-class FontManager {
-public:
-	FontVal _charSet;
-	FontVal _charFor;
-	Common::Point _printOrg;
-	Common::Point _printStart;
-	int _printMaxX;
-	Font _font1;
-	Font _font2;
-public:
-	FontManager();
-};
-
 } // End of namespace Access
 
 #endif /* ACCESS_DATA_H */
diff --git a/engines/access/font.cpp b/engines/access/font.cpp
new file mode 100644
index 0000000..d5ad3b3d
--- /dev/null
+++ b/engines/access/font.cpp
@@ -0,0 +1,169 @@
+/* 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 "access/font.h"
+
+namespace Access {
+
+byte Font::_fontColors[4];
+
+Font::Font() {
+}
+
+Font::~Font() {
+	for (uint i = 0; i < _chars.size(); ++i)
+		_chars[i].free();
+}
+
+void Font::load(const int *fontIndex, const byte *fontData) {
+	assert(_chars.size() == 0);
+	int count = fontIndex[0];
+	_bitWidth = fontIndex[1];
+	_height = fontIndex[2];
+
+	_chars.resize(count);
+
+	for (int i = 0; i < count; ++i) {
+		const byte *pData = fontData + fontIndex[i + 3];
+		_chars[i].create(*pData++, _height, Graphics::PixelFormat::createFormatCLUT8());
+
+		for (int y = 0; y < _height; ++y) {
+			int bitsLeft = 0;
+			byte srcByte = 0;
+			byte pixel;
+			
+			byte *pDest = (byte *)_chars[i].getBasePtr(0, y);
+			for (int x = 0; x < _chars[i].w; ++x, ++pDest) {
+				// Get the pixel
+				pixel = 0;
+				for (int pixelCtr = 0; pixelCtr < _bitWidth; ++pixelCtr, --bitsLeft) {
+					// No bits in current byte left, so get next byte
+					if (bitsLeft == 0) {
+						bitsLeft = 8;
+						srcByte = *pData++;
+					}
+
+					pixel = (pixel << 1) | (srcByte >> 7);
+					srcByte <<= 1;
+				}
+
+				// Write out the pixel
+				*pDest = pixel;
+			}
+		}
+	}
+}
+
+int Font::charWidth(char c) {
+	return _chars[c - ' '].w;
+}
+
+int Font::stringWidth(const Common::String &msg) {
+	int total = 0;
+
+	for (const char *c = msg.c_str(); *c != '\0'; ++c)
+		total += charWidth(*c);
+
+	return total;
+}
+
+bool Font::getLine(Common::String &s, int maxWidth, Common::String &line, int &width) {
+	assert(maxWidth > 0);
+	width = 0;
+	const char *src = s.c_str();
+	char c;
+
+	while ((c = *src) != '\0') {
+		if (c == '\r') {
+			// End of line, so return calculated line
+			line = Common::String(s.c_str(), src - 1);
+			s = Common::String(src + 1);
+			return false;
+		}
+
+		++src;
+		width += charWidth(c);
+		if (width < maxWidth)
+			continue;
+
+		// Reached maximum allowed size
+		// If this was the last character of the string, let it go
+		if (*src == '\0')
+			break;
+		
+		// Work backwards to find space at the start of the current word 
+		// as a point to split the line on
+		while (src >= s.c_str() && *src != ' ') {
+			width -= charWidth(*src);
+			--src;
+		}
+		if (src < s.c_str())
+			error("Could not fit line");
+
+		// Split the line around the space
+		line = Common::String(s.c_str(), src);
+		s = Common::String(src + 1);
+		return false;
+	}
+
+	// Return entire string
+	line = s;
+	s = Common::String();
+	return true;
+}
+
+void Font::drawString(Graphics::Surface *s, const Common::String &msg, const Common::Point &pt) {
+	Common::Point currPt = pt;
+	const char *msgP = msg.c_str();
+
+	while (*msgP) {
+		currPt.x += drawChar(s, *msgP, currPt);
+		++msgP;
+	}
+}
+
+int Font::drawChar(Graphics::Surface *s, char c, Common::Point &pt) {
+	Graphics::Surface &ch = _chars[c - ' '];
+
+	// Loop through the lines of the character
+	for (int y = 0; y < ch.h; ++y) {
+		byte *pSrc = (byte *)ch.getBasePtr(0, y);
+		byte *pDest = (byte *)s->getBasePtr(pt.x, pt.y + y);
+
+		// Loop through the horizontal pixels of the line
+		for (int x = 0; x < ch.w; ++x, ++pSrc, ++pDest) {
+			if (*pSrc != 0)
+				*pDest = _fontColors[*pSrc];
+		}
+	}
+
+	return ch.w;
+}
+
+/*------------------------------------------------------------------------*/
+
+FontManager::FontManager() {
+	_printMaxX = 0;
+	Common::fill(&Font::_fontColors[0], &Font::_fontColors[4], 0);
+}
+
+} // End of namespace Access
diff --git a/engines/access/font.h b/engines/access/font.h
new file mode 100644
index 0000000..2c9ffd0
--- /dev/null
+++ b/engines/access/font.h
@@ -0,0 +1,104 @@
+/* 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 ACCESS_FONT_H
+#define ACCESS_FONT_H
+
+#include "common/scummsys.h"
+#include "common/array.h"
+#include "common/rect.h"
+#include "access/asurface.h"
+#include "access/data.h"
+
+namespace Access {
+
+struct FontVal {
+public:
+	int _lo, _hi;
+
+	FontVal() { _lo = _hi = 0; }
+};
+
+class Font {
+private:
+	int _bitWidth;
+	int _height;
+	Common::Array<Graphics::Surface> _chars;
+public:
+	static byte _fontColors[4];
+public:
+	Font();
+
+	~Font();
+
+	/**
+	 * Load the given font data
+	 */
+	void load(const int *fontIndex, const byte *fontData);
+
+	/**
+	 * Get the width of a given character
+	 */
+	int charWidth(char c);
+
+	/**
+	 * Get the width of a given string
+	 */
+	int stringWidth(const Common::String &msg);
+
+	/**
+	 * Get a partial string that will fit in a given width
+	 * @param s			Source string. Modified to remove line
+	 * @param maxWidth	Maximum width allowed
+	 * @param line		Output line
+	 * @param width		Calculated width of returned line
+	 * @returns			True if last line
+	 */
+	bool getLine(Common::String &s, int maxWidth, Common::String &line, int &width);
+
+	/**
+	 * Draw a string on a given surface
+	 */
+	void drawString(Graphics::Surface *s, const Common::String &msg, const Common::Point &pt);
+
+	/**
+	 * Draw a character on a given surface
+	 */
+	int drawChar(Graphics::Surface *s, char c, Common::Point &pt);
+};
+
+class FontManager {
+public:
+	FontVal _charSet;
+	FontVal _charFor;
+	Common::Point _printOrg;
+	Common::Point _printStart;
+	int _printMaxX;
+	Font _font1;
+	Font _font2;
+public:
+	FontManager();
+};
+
+} // End of namespace Access
+
+#endif /* ACCESS_FONT_H */
diff --git a/engines/access/module.mk b/engines/access/module.mk
index e92c2cc..b6e73b6 100644
--- a/engines/access/module.mk
+++ b/engines/access/module.mk
@@ -12,6 +12,7 @@ MODULE_OBJS := \
 	detection.o \
 	events.o \
 	files.o \
+	font.o \
 	inventory.o \
 	player.o \
 	resources.o \


Commit: 707a01cb38eb671f2fad29016f11268f8fab9084
    https://github.com/scummvm/scummvm/commit/707a01cb38eb671f2fad29016f11268f8fab9084
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-25T00:01:18-04:00

Commit Message:
ACCESS: Change font method parameter types

Changed paths:
    engines/access/font.cpp
    engines/access/font.h



diff --git a/engines/access/font.cpp b/engines/access/font.cpp
index d5ad3b3d..75add41 100644
--- a/engines/access/font.cpp
+++ b/engines/access/font.cpp
@@ -131,7 +131,7 @@ bool Font::getLine(Common::String &s, int maxWidth, Common::String &line, int &w
 	return true;
 }
 
-void Font::drawString(Graphics::Surface *s, const Common::String &msg, const Common::Point &pt) {
+void Font::drawString(ASurface *s, const Common::String &msg, const Common::Point &pt) {
 	Common::Point currPt = pt;
 	const char *msgP = msg.c_str();
 
@@ -141,7 +141,7 @@ void Font::drawString(Graphics::Surface *s, const Common::String &msg, const Com
 	}
 }
 
-int Font::drawChar(Graphics::Surface *s, char c, Common::Point &pt) {
+int Font::drawChar(ASurface *s, char c, Common::Point &pt) {
 	Graphics::Surface &ch = _chars[c - ' '];
 
 	// Loop through the lines of the character
diff --git a/engines/access/font.h b/engines/access/font.h
index 2c9ffd0..a32dd6b 100644
--- a/engines/access/font.h
+++ b/engines/access/font.h
@@ -78,12 +78,12 @@ public:
 	/**
 	 * Draw a string on a given surface
 	 */
-	void drawString(Graphics::Surface *s, const Common::String &msg, const Common::Point &pt);
+	void drawString(ASurface *s, const Common::String &msg, const Common::Point &pt);
 
 	/**
 	 * Draw a character on a given surface
 	 */
-	int drawChar(Graphics::Surface *s, char c, Common::Point &pt);
+	int drawChar(ASurface *s, char c, Common::Point &pt);
 };
 
 class FontManager {


Commit: 33cdeb7a4005408b92366ae34a29589e3b0fa0cb
    https://github.com/scummvm/scummvm/commit/33cdeb7a4005408b92366ae34a29589e3b0fa0cb
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-25T00:18:32-04:00

Commit Message:
ACCESS: Stub for printText method

Changed paths:
    engines/access/access.cpp
    engines/access/asurface.h
    engines/access/bubble_box.cpp
    engines/access/font.cpp
    engines/access/font.h
    engines/access/scripts.cpp



diff --git a/engines/access/access.cpp b/engines/access/access.cpp
index cea5a73..32a4e6c 100644
--- a/engines/access/access.cpp
+++ b/engines/access/access.cpp
@@ -285,10 +285,10 @@ void AccessEngine::speakText(int idx) {
 		_fonts._font2._fontColors[2] = 29;
 		_fonts._font2._fontColors[3] = 30;
 
-		_fonts._font2.drawString(_screen, line, _fonts._printOrg);
-		_fonts._printOrg = Common::Point(_fonts._printStart.x, _fonts._printOrg.y + 9);
+		_fonts._font2.drawString(_screen, line, _screen->_printOrg);
+		_screen->_printOrg = Common::Point(_screen->_printStart.x, _screen->_printOrg.y + 9);
 
-		if ((_fonts._printOrg.y > _printEnd) && (!lastLine)) {
+		if ((_screen->_printOrg.y > _printEnd) && (!lastLine)) {
 			while (true) {
 				_sound->_soundTable[0]._data = _sound->loadSound(_narateFile + 99, _sndSubFile);
 				_sound->_soundPriority[0] = 1;
@@ -312,7 +312,7 @@ void AccessEngine::speakText(int idx) {
 				}
 			}
 			_buffer2.copyBuffer(_screen);
-			_fonts._printOrg.y = _fonts._printStart.y;
+			_screen->_printOrg.y = _screen->_printStart.y;
 			++curPage;
 			soundsLeft = _countTbl[curPage];
 		}
@@ -369,17 +369,19 @@ void AccessEngine::doEstablish(int esatabIndex, int sub) {
 	_fonts._charFor._hi = 32;
 
 	_bubbleBox->_maxChars = 37;
-	_fonts._printOrg = _fonts._printStart = Common::Point(48, 35);
+	_screen->_printOrg = _screen->_printStart = Common::Point(48, 35);
 	loadEstablish(sub);
 	_et = sub;
 	warning("CHECKME: Use of di");
-	int idx = READ_LE_UINT16(_eseg + (sub * 2) + 2);
+	uint16 msgOffset = READ_LE_UINT16(_eseg + (sub * 2) + 2);
+	Common::String msg((const char *)_eseg + msgOffset);
 
 	_printEnd = 155;
-	if (_txtPages == 0)
-		warning("TODO: printText()");
-	else
-		speakText(idx);
+	if (_txtPages == 0) {
+		_fonts._font2.printText(_screen, msg);
+	} else {
+//		speakText(msg);
+	}
 
 	_screen->forceFadeOut();
 	_screen->clearScreen();
diff --git a/engines/access/asurface.h b/engines/access/asurface.h
index f5e5f48..262d414 100644
--- a/engines/access/asurface.h
+++ b/engines/access/asurface.h
@@ -52,6 +52,9 @@ public:
 	static int _orgX2, _orgY2;
 	static int _lColor;
 
+	Common::Point _printOrg;
+	Common::Point _printStart;
+
 	static void init();
 public:
 	virtual ~ASurface();
diff --git a/engines/access/bubble_box.cpp b/engines/access/bubble_box.cpp
index a709fbd..56d7157 100644
--- a/engines/access/bubble_box.cpp
+++ b/engines/access/bubble_box.cpp
@@ -74,8 +74,8 @@ void BubbleBox::placeBubble1(const Common::String &msg) {
 
 void BubbleBox::calcBubble(const Common::String &msg) {
 	// Save points
-	Common::Point printOrg = _vm->_fonts._printOrg;
-	Common::Point printStart = _vm->_fonts._printStart;
+	Common::Point printOrg = _vm->_screen->_printOrg;
+	Common::Point printStart = _vm->_screen->_printStart;
 
 	// Figure out maximum width allowed
 	if (_type == TYPE_4) {
@@ -96,12 +96,12 @@ void BubbleBox::calcBubble(const Common::String &msg) {
 		lastLine = _vm->_fonts._font2.getLine(s, _maxChars * 6, line, width);
 		_vm->_fonts._printMaxX = MAX(width, _vm->_fonts._printMaxX);
 
-		_vm->_fonts._printOrg.y += 6;
-		_vm->_fonts._printOrg.x = _vm->_fonts._printStart.x;
+		_vm->_screen->_printOrg.y += 6;
+		_vm->_screen->_printOrg.x = _vm->_screen->_printStart.x;
 	} while (!lastLine);
 
 	if (_type == TYPE_4)
-		++_vm->_fonts._printOrg.y += 6;
+		++_vm->_screen->_printOrg.y += 6;
 
 	// Determine the width for the area
 	width = (((_vm->_fonts._printMaxX >> 4) + 1) << 4) + 5;
@@ -110,7 +110,7 @@ void BubbleBox::calcBubble(const Common::String &msg) {
 	bounds.setWidth(width);
 
 	// Determine the height for area
-	int y = _vm->_fonts._printOrg.y + 6;
+	int y = _vm->_screen->_printOrg.y + 6;
 	if (_type == TYPE_4)
 		y += 6;
 	int height = y - bounds.top;
@@ -124,8 +124,8 @@ void BubbleBox::calcBubble(const Common::String &msg) {
 	_bubbles.push_back(bounds);
 
 	// Restore points
-	_vm->_fonts._printOrg = printOrg;
-	_vm->_fonts._printStart = printStart;
+	_vm->_screen->_printOrg = printOrg;
+	_vm->_screen->_printStart = printStart;
 }
 
 void BubbleBox::printBubble(const Common::String &msg) {
@@ -147,16 +147,16 @@ void BubbleBox::printBubble(const Common::String &msg) {
 		font2._fontColors[2] = 28;
 		font2._fontColors[3] = 29;
 
-		int xp = _vm->_fonts._printOrg.x;
+		int xp = _vm->_screen->_printOrg.x;
 		if (_type == TYPE_4)
 			xp = (_bounds.width() - width) / 2 + _bounds.left - 4;
 		
 		// Draw the text
-		font2.drawString(_vm->_screen, line, Common::Point(xp, _vm->_fonts._printOrg.y));
+		font2.drawString(_vm->_screen, line, Common::Point(xp, _vm->_screen->_printOrg.y));
 		
 		// Move print position
-		_vm->_fonts._printOrg.y += 6;
-		_vm->_fonts._printOrg.x = _vm->_fonts._printStart.x;
+		_vm->_screen->_printOrg.y += 6;
+		_vm->_screen->_printOrg.x = _vm->_screen->_printStart.x;
 	} while (!lastLine);
 }
 
@@ -175,8 +175,8 @@ void BubbleBox::doBox(int item, int box) {
 	// Save state information
 	FontVal charSet = fonts._charSet;
 	FontVal charFor = fonts._charFor;
-	Common::Point printOrg = fonts._printOrg;
-	Common::Point printStart = fonts._printStart;
+	Common::Point printOrg = screen._printOrg;
+	Common::Point printStart = screen._printStart;
 	int charCol = _charCol;
 	int rowOff = _rowOff;
 
@@ -260,8 +260,8 @@ void BubbleBox::doBox(int item, int box) {
 	// Restore positional state
 	fonts._charSet = charSet;
 	fonts._charFor = charFor;
-	fonts._printOrg = printOrg;
-	fonts._printStart = printStart;
+	screen._printOrg = printOrg;
+	screen._printStart = printStart;
 	_charCol = charCol;
 	_rowOff = rowOff;
 	_vm->_screen->restoreScreen();
diff --git a/engines/access/font.cpp b/engines/access/font.cpp
index 75add41..ba17f19 100644
--- a/engines/access/font.cpp
+++ b/engines/access/font.cpp
@@ -159,6 +159,10 @@ int Font::drawChar(ASurface *s, char c, Common::Point &pt) {
 	return ch.w;
 }
 
+void Font::printText(ASurface *s, const Common::String &msg) {
+	error("TODO: printText");
+}
+
 /*------------------------------------------------------------------------*/
 
 FontManager::FontManager() {
diff --git a/engines/access/font.h b/engines/access/font.h
index a32dd6b..9285d32 100644
--- a/engines/access/font.h
+++ b/engines/access/font.h
@@ -84,14 +84,17 @@ public:
 	 * Draw a character on a given surface
 	 */
 	int drawChar(ASurface *s, char c, Common::Point &pt);
+
+	/**
+	 * Draw a string on a given surface and update text positioning
+	 */
+	void printText(ASurface *s, const Common::String &msg);
 };
 
 class FontManager {
 public:
 	FontVal _charSet;
 	FontVal _charFor;
-	Common::Point _printOrg;
-	Common::Point _printStart;
 	int _printMaxX;
 	Font _font1;
 	Font _font2;
diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp
index 6ee8eb0..d6f65a6 100644
--- a/engines/access/scripts.cpp
+++ b/engines/access/scripts.cpp
@@ -185,8 +185,8 @@ void Scripts::cmdPrint() {
 }
 
 void Scripts::printString(const Common::String &msg) {
-	_vm->_fonts._printOrg = Common::Point(20, 42);
-	_vm->_fonts._printStart = Common::Point(20, 42);
+	_vm->_screen->_printOrg = Common::Point(20, 42);
+	_vm->_screen->_printStart = Common::Point(20, 42);
 	_vm->_timers[PRINT_TIMER]._timer = 50;
 	_vm->_timers[PRINT_TIMER]._initTm = 50;
 	++_vm->_timers[PRINT_TIMER]._flag;
@@ -488,8 +488,8 @@ void Scripts::CMDSETCYCLE() { error("TODO CMDSETCYCLE"); }
 void Scripts::CMDCYCLE() { error("TODO CMDCYCLE"); }
 
 void Scripts::cmdCharSpeak() {
-	_vm->_fonts._printOrg = _charsOrg;
-	_vm->_fonts._printStart = _charsOrg;
+	_vm->_screen->_printOrg = _charsOrg;
+	_vm->_screen->_printStart = _charsOrg;
 
 	byte v;
 	Common::String tmpStr = "";
@@ -501,8 +501,8 @@ void Scripts::cmdCharSpeak() {
 }
 
 void Scripts::cmdTexSpeak() {
-	_vm->_fonts._printOrg = _texsOrg;
-	_vm->_fonts._printStart = _texsOrg;
+	_vm->_screen->_printOrg = _texsOrg;
+	_vm->_screen->_printStart = _texsOrg;
 	_vm->_bubbleBox->_maxChars = 20;
 
 	byte v;
@@ -542,8 +542,8 @@ void Scripts::cmdTexChoice() {
 	_vm->_fonts._charFor._hi = 255;
 	_vm->_bubbleBox->_maxChars = 20;
 
-	_vm->_fonts._printOrg = _texsOrg;
-	_vm->_fonts._printStart = _texsOrg;
+	_vm->_screen->_printOrg = _texsOrg;
+	_vm->_screen->_printStart = _texsOrg;
 
 	_vm->_bubbleBox->clearBubbles();
 	_vm->_bubbleBox->_bubblePtr = Common::String("RESPONSE 1").c_str();
@@ -559,7 +559,7 @@ void Scripts::cmdTexChoice() {
 	Common::Rect responseCoords[2];
 	responseCoords[0] = _vm->_bubbleBox->_bounds;
 	responseCoords[1] = Common::Rect(0, 0, 0, 0);
-	_vm->_fonts._printOrg.y = _vm->_bubbleBox->_bounds.bottom + 11;
+	_vm->_screen->_printOrg.y = _vm->_bubbleBox->_bounds.bottom + 11;
 
 	findNull();
 
@@ -575,7 +575,7 @@ void Scripts::cmdTexChoice() {
 		_vm->_bubbleBox->calcBubble(tmpStr);
 		_vm->_bubbleBox->printBubble(tmpStr);
 		responseCoords[1] = _vm->_bubbleBox->_bounds;
-		_vm->_fonts._printOrg.y = _vm->_bubbleBox->_bounds.bottom + 11;
+		_vm->_screen->_printOrg.y = _vm->_bubbleBox->_bounds.bottom + 11;
 	}
 
 	findNull();
@@ -590,7 +590,7 @@ void Scripts::cmdTexChoice() {
 		_vm->_bubbleBox->calcBubble(tmpStr);
 		_vm->_bubbleBox->printBubble(tmpStr);
 		termResponse2 = _vm->_bubbleBox->_bounds;
-		_vm->_fonts._printOrg.y = _vm->_bubbleBox->_bounds.bottom + 11;
+		_vm->_screen->_printOrg.y = _vm->_bubbleBox->_bounds.bottom + 11;
 	}
 
 	findNull();


Commit: 8c059add8b25cbabd499fe9ef6e69da563a3b913
    https://github.com/scummvm/scummvm/commit/8c059add8b25cbabd499fe9ef6e69da563a3b913
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-08-25T22:46:56+02:00

Commit Message:
ACCESS: Modify speakText so it takes a string array as parameter

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



diff --git a/engines/access/access.cpp b/engines/access/access.cpp
index 32a4e6c..97ffc13 100644
--- a/engines/access/access.cpp
+++ b/engines/access/access.cpp
@@ -199,7 +199,6 @@ void AccessEngine::dummyLoop() {
 			_events->setCursor((cursorId == CURSOR_HELP) ? CURSOR_ARROW : (CursorType)(cursorId + 1));
 		}
 	}
-
 }
 
 int AccessEngine::getRandomNumber(int maxNumber) {
@@ -264,21 +263,17 @@ void AccessEngine::loadEstablish(int sub) {
 		_countTbl[i] = READ_LE_UINT16(_eseg + idx + 6 + (2 * i));
 }
 
-void AccessEngine::speakText(int idx) {
+void AccessEngine::speakText(Common::Array<Common::String> msgArr) {
 	int curPage = 0;
 	int soundsLeft = 0;
 
-	Common::String msg;
-	for (int i = idx; _eseg[i] != 0; ++i)
-		msg += _eseg[i];
-
 	while(true) {
 		soundsLeft = _countTbl[curPage];
 		_events->zeroKeys();
 
 		Common::String line;
 		int width = 0;
-		bool lastLine = _fonts._font2.getLine(msg, _bubbleBox->_maxChars * 6, line, width);
+		bool lastLine = _fonts._font2.getLine(msgArr[curPage], _bubbleBox->_maxChars * 6, line, width);
 		// Set font colors
 		_fonts._font2._fontColors[0] = 0;
 		_fonts._font2._fontColors[1] = 28;
@@ -372,15 +367,20 @@ void AccessEngine::doEstablish(int esatabIndex, int sub) {
 	_screen->_printOrg = _screen->_printStart = Common::Point(48, 35);
 	loadEstablish(sub);
 	_et = sub;
-	warning("CHECKME: Use of di");
 	uint16 msgOffset = READ_LE_UINT16(_eseg + (sub * 2) + 2);
-	Common::String msg((const char *)_eseg + msgOffset);
 
 	_printEnd = 155;
 	if (_txtPages == 0) {
+		Common::String msg((const char *)_eseg + msgOffset);
 		_fonts._font2.printText(_screen, msg);
 	} else {
-//		speakText(msg);
+		Common::Array<Common::String> msgArr;
+		for (int i = 0; i < _txtPages; ++i) {
+			Common::String msg((const char *)_eseg + msgOffset);
+			msgOffset += msg.size() + 1;
+			msgArr.push_back(msg);
+		}
+		speakText(msgArr);
 	}
 
 	_screen->forceFadeOut();
diff --git a/engines/access/access.h b/engines/access/access.h
index 2aa4130..70195d1 100644
--- a/engines/access/access.h
+++ b/engines/access/access.h
@@ -92,7 +92,7 @@ private:
 
 	void dummyLoop();
 
-	void speakText(int idx);
+	void speakText(Common::Array<Common::String>msgArr);
 
 	void doEstablish(int esatabIndex, int sub);
 protected:


Commit: 7d0392aa83a44b075cedd8d669a61f26dcb82c3b
    https://github.com/scummvm/scummvm/commit/7d0392aa83a44b075cedd8d669a61f26dcb82c3b
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-08-25T23:34:40+02:00

Commit Message:
ACCESS: Move _maxChars to asurface

Changed paths:
    engines/access/access.cpp
    engines/access/asurface.h
    engines/access/bubble_box.cpp
    engines/access/bubble_box.h
    engines/access/scripts.cpp



diff --git a/engines/access/access.cpp b/engines/access/access.cpp
index 97ffc13..47d77e7 100644
--- a/engines/access/access.cpp
+++ b/engines/access/access.cpp
@@ -273,7 +273,7 @@ void AccessEngine::speakText(Common::Array<Common::String> msgArr) {
 
 		Common::String line;
 		int width = 0;
-		bool lastLine = _fonts._font2.getLine(msgArr[curPage], _bubbleBox->_maxChars * 6, line, width);
+		bool lastLine = _fonts._font2.getLine(msgArr[curPage], _screen->_maxChars * 6, line, width);
 		// Set font colors
 		_fonts._font2._fontColors[0] = 0;
 		_fonts._font2._fontColors[1] = 28;
@@ -363,7 +363,7 @@ void AccessEngine::doEstablish(int esatabIndex, int sub) {
 	_fonts._charFor._lo = 29;
 	_fonts._charFor._hi = 32;
 
-	_bubbleBox->_maxChars = 37;
+	_screen->_maxChars = 37;
 	_screen->_printOrg = _screen->_printStart = Common::Point(48, 35);
 	loadEstablish(sub);
 	_et = sub;
diff --git a/engines/access/asurface.h b/engines/access/asurface.h
index 262d414..5d1f6fd 100644
--- a/engines/access/asurface.h
+++ b/engines/access/asurface.h
@@ -54,6 +54,7 @@ public:
 
 	Common::Point _printOrg;
 	Common::Point _printStart;
+	int _maxChars;
 
 	static void init();
 public:
diff --git a/engines/access/bubble_box.cpp b/engines/access/bubble_box.cpp
index 56d7157..d3782a3 100644
--- a/engines/access/bubble_box.cpp
+++ b/engines/access/bubble_box.cpp
@@ -34,8 +34,6 @@ BubbleBox::BubbleBox(AccessEngine *vm) : Manager(vm) {
 	_fieldE = 0;
 	_fieldF = 0;
 	_field10 = 0;
-
-	_maxChars = 0;
 }
 
 void BubbleBox::load(Common::SeekableReadStream *stream) {
@@ -53,7 +51,7 @@ void BubbleBox::clearBubbles() {
 }
 
 void BubbleBox::placeBubble(const Common::String &msg) {
-	BubbleBox::_maxChars = 27;
+	_vm->_screen->_maxChars = 27;
 	placeBubble1(msg);
 }
 
@@ -93,7 +91,7 @@ void BubbleBox::calcBubble(const Common::String &msg) {
 	int width = 0;
 	bool lastLine;
 	do {
-		lastLine = _vm->_fonts._font2.getLine(s, _maxChars * 6, line, width);
+		lastLine = _vm->_fonts._font2.getLine(s, _vm->_screen->_maxChars * 6, line, width);
 		_vm->_fonts._printMaxX = MAX(width, _vm->_fonts._printMaxX);
 
 		_vm->_screen->_printOrg.y += 6;
@@ -139,7 +137,7 @@ void BubbleBox::printBubble(const Common::String &msg) {
 	do {
 		// Get next line
 		Font &font2 = _vm->_fonts._font2;
-		lastLine = font2.getLine(s, _maxChars * 6, line, width);
+		lastLine = font2.getLine(s, _vm->_screen->_maxChars * 6, line, width);
 
 		// Set font colors
 		font2._fontColors[0] = 0;
diff --git a/engines/access/bubble_box.h b/engines/access/bubble_box.h
index 3ddb2f7..7b25a58 100644
--- a/engines/access/bubble_box.h
+++ b/engines/access/bubble_box.h
@@ -54,7 +54,6 @@ public:
 	int _fieldF;
 	int _field10;
 
-	int _maxChars;
 	Common::Array<Common::Rect> _bubbles;
 public:
 	BubbleBox(AccessEngine *vm);
diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp
index d6f65a6..833aff3 100644
--- a/engines/access/scripts.cpp
+++ b/engines/access/scripts.cpp
@@ -503,7 +503,7 @@ void Scripts::cmdCharSpeak() {
 void Scripts::cmdTexSpeak() {
 	_vm->_screen->_printOrg = _texsOrg;
 	_vm->_screen->_printStart = _texsOrg;
-	_vm->_bubbleBox->_maxChars = 20;
+	_vm->_screen->_maxChars = 20;
 
 	byte v;
 	Common::String tmpStr = "";
@@ -540,8 +540,8 @@ void Scripts::cmdTexChoice() {
 	_vm->_fonts._charSet._hi = 8;
 	_vm->_fonts._charFor._lo = 55;
 	_vm->_fonts._charFor._hi = 255;
-	_vm->_bubbleBox->_maxChars = 20;
 
+	_vm->_screen->_maxChars = 20;
 	_vm->_screen->_printOrg = _texsOrg;
 	_vm->_screen->_printStart = _texsOrg;
 


Commit: a47b10c1c01d6ff332a11dfb61bef3e0bb8e2672
    https://github.com/scummvm/scummvm/commit/a47b10c1c01d6ff332a11dfb61bef3e0bb8e2672
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-08-25T23:44:55+02:00

Commit Message:
ACCESS: Add destination surface in speakText parameters

Changed paths:
    engines/access/access.cpp
    engines/access/access.h
    engines/access/asurface.cpp



diff --git a/engines/access/access.cpp b/engines/access/access.cpp
index 47d77e7..361b8b3 100644
--- a/engines/access/access.cpp
+++ b/engines/access/access.cpp
@@ -263,7 +263,7 @@ void AccessEngine::loadEstablish(int sub) {
 		_countTbl[i] = READ_LE_UINT16(_eseg + idx + 6 + (2 * i));
 }
 
-void AccessEngine::speakText(Common::Array<Common::String> msgArr) {
+void AccessEngine::speakText(ASurface *s, Common::Array<Common::String> msgArr) {
 	int curPage = 0;
 	int soundsLeft = 0;
 
@@ -273,17 +273,17 @@ void AccessEngine::speakText(Common::Array<Common::String> msgArr) {
 
 		Common::String line;
 		int width = 0;
-		bool lastLine = _fonts._font2.getLine(msgArr[curPage], _screen->_maxChars * 6, line, width);
+		bool lastLine = _fonts._font2.getLine(msgArr[curPage], s->_maxChars * 6, line, width);
 		// Set font colors
 		_fonts._font2._fontColors[0] = 0;
 		_fonts._font2._fontColors[1] = 28;
 		_fonts._font2._fontColors[2] = 29;
 		_fonts._font2._fontColors[3] = 30;
 
-		_fonts._font2.drawString(_screen, line, _screen->_printOrg);
-		_screen->_printOrg = Common::Point(_screen->_printStart.x, _screen->_printOrg.y + 9);
+		_fonts._font2.drawString(s, line, s->_printOrg);
+		s->_printOrg = Common::Point(s->_printStart.x, s->_printOrg.y + 9);
 
-		if ((_screen->_printOrg.y > _printEnd) && (!lastLine)) {
+		if ((s->_printOrg.y > _printEnd) && (!lastLine)) {
 			while (true) {
 				_sound->_soundTable[0]._data = _sound->loadSound(_narateFile + 99, _sndSubFile);
 				_sound->_soundPriority[0] = 1;
@@ -306,8 +306,8 @@ void AccessEngine::speakText(Common::Array<Common::String> msgArr) {
 						break;
 				}
 			}
-			_buffer2.copyBuffer(_screen);
-			_screen->_printOrg.y = _screen->_printStart.y;
+			_buffer2.copyBuffer(s);
+			s->_printOrg.y = s->_printStart.y;
 			++curPage;
 			soundsLeft = _countTbl[curPage];
 		}
@@ -380,7 +380,7 @@ void AccessEngine::doEstablish(int esatabIndex, int sub) {
 			msgOffset += msg.size() + 1;
 			msgArr.push_back(msg);
 		}
-		speakText(msgArr);
+		speakText(_screen, msgArr);
 	}
 
 	_screen->forceFadeOut();
diff --git a/engines/access/access.h b/engines/access/access.h
index 70195d1..fb73b1f 100644
--- a/engines/access/access.h
+++ b/engines/access/access.h
@@ -81,7 +81,7 @@ private:
 	uint32 _lastTime, _curTime;
 
 	/**
-	 * Handles basic initialisation
+	 * Handles basic initialization
 	 */
 	void initialize();
 
@@ -92,7 +92,7 @@ private:
 
 	void dummyLoop();
 
-	void speakText(Common::Array<Common::String>msgArr);
+	void speakText(ASurface *s, Common::Array<Common::String>msgArr);
 
 	void doEstablish(int esatabIndex, int sub);
 protected:
diff --git a/engines/access/asurface.cpp b/engines/access/asurface.cpp
index 0db44c4..cdf8b3d 100644
--- a/engines/access/asurface.cpp
+++ b/engines/access/asurface.cpp
@@ -329,7 +329,6 @@ void ASurface::flipHorizontal(ASurface &dest) {
 	}
 }
 
-
 void ASurface::moveBufferLeft() {
 	byte *p = (byte *)getPixels();
 	Common::copy(p + TILE_WIDTH, p + (w * h), p);


Commit: 1568b4a433f8efc0b4e670d8e9714885aa8831c0
    https://github.com/scummvm/scummvm/commit/1568b4a433f8efc0b4e670d8e9714885aa8831c0
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-08-26T23:55:17+02:00

Commit Message:
ACCESS: Move Establish functions to Amazon engine, start implementing init4Quads

Changed paths:
    engines/access/access.cpp
    engines/access/access.h
    engines/access/amazon/amazon_game.cpp
    engines/access/amazon/amazon_game.h
    engines/access/amazon/amazon_room.cpp
    engines/access/amazon/amazon_room.h
    engines/access/martian/martian_game.h
    engines/access/martian/martian_room.h
    engines/access/room.cpp
    engines/access/room.h
    engines/access/screen.cpp
    engines/access/screen.h



diff --git a/engines/access/access.cpp b/engines/access/access.cpp
index 361b8b3..c19a37c 100644
--- a/engines/access/access.cpp
+++ b/engines/access/access.cpp
@@ -225,44 +225,6 @@ void AccessEngine::freeInactiveData() {
 	_inactive = nullptr;
 }
 
-void AccessEngine::establish(int esatabIndex, int sub) {
-	_establishMode = 0;
-	_establishGroup = 0;
-	doEstablish(esatabIndex, sub);
-}
-
-void AccessEngine::establishCenter(int esatabIndex, int sub) {
-	_establishMode = 1;
-	doEstablish(esatabIndex, sub);
-}
-
-const char *const _estTable[] = { "ETEXT0.DAT", "ETEXT1.DAT", "ETEXT2.DAT", "ETEXT3.DAT" };
-
-void AccessEngine::loadEstablish(int sub) {
-	if (!_files->existFile("ETEXT.DAT")) {
-		int oldGroup = _establishGroup;
-		_establishGroup = 0;
-		
-		_eseg = _files->loadFile(_estTable[oldGroup]);
-	} else {
-		_eseg = _files->loadFile("ETEXT.DAT");
-	}
-
-	_establishCtrlTblOfs = READ_LE_UINT16(_eseg);
-
-	int ofs = _establishCtrlTblOfs + (sub * 2);
-	int idx = READ_LE_UINT16(_eseg + ofs);
-	_narateFile = READ_LE_UINT16(_eseg + idx);
-	_txtPages = READ_LE_UINT16(_eseg + idx + 2);
-
-	if (!_txtPages)
-		return;
-
-	_sndSubFile = READ_LE_UINT16(_eseg + idx + 4);
-	for (int i = 0; i < _txtPages; ++i)
-		_countTbl[i] = READ_LE_UINT16(_eseg + idx + 6 + (2 * i));
-}
-
 void AccessEngine::speakText(ASurface *s, Common::Array<Common::String> msgArr) {
 	int curPage = 0;
 	int soundsLeft = 0;
@@ -343,55 +305,6 @@ void AccessEngine::speakText(ASurface *s, Common::Array<Common::String> msgArr)
 	}
 }
 
-void AccessEngine::doEstablish(int esatabIndex, int sub) {
-	_establishMode = 1;
-
-	_screen->forceFadeOut();
-	_screen->clearScreen();
-	_screen->setPanel(3);
-
-	if (esatabIndex != -1) {
-		_files->loadScreen(95, esatabIndex);
-		_buffer2.copyBuffer(_screen);
-	}
-
-	_screen->setIconPalette();
-	_screen->forceFadeIn();
-
-	_fonts._charSet._lo = 1;
-	_fonts._charSet._hi = 10;
-	_fonts._charFor._lo = 29;
-	_fonts._charFor._hi = 32;
-
-	_screen->_maxChars = 37;
-	_screen->_printOrg = _screen->_printStart = Common::Point(48, 35);
-	loadEstablish(sub);
-	_et = sub;
-	uint16 msgOffset = READ_LE_UINT16(_eseg + (sub * 2) + 2);
-
-	_printEnd = 155;
-	if (_txtPages == 0) {
-		Common::String msg((const char *)_eseg + msgOffset);
-		_fonts._font2.printText(_screen, msg);
-	} else {
-		Common::Array<Common::String> msgArr;
-		for (int i = 0; i < _txtPages; ++i) {
-			Common::String msg((const char *)_eseg + msgOffset);
-			msgOffset += msg.size() + 1;
-			msgArr.push_back(msg);
-		}
-		speakText(_screen, msgArr);
-	}
-
-	_screen->forceFadeOut();
-	_screen->clearScreen();
-
-	free(_eseg);
-	if (_establishMode == 0) {
-		warning("TODO: init4Quads();");
-	}
-}
-
 void AccessEngine::plotList() {
 	_player->calcPlayer();
 	plotList1();
diff --git a/engines/access/access.h b/engines/access/access.h
index fb73b1f..f25effe 100644
--- a/engines/access/access.h
+++ b/engines/access/access.h
@@ -91,10 +91,6 @@ private:
 	void setVGA();
 
 	void dummyLoop();
-
-	void speakText(ASurface *s, Common::Array<Common::String>msgArr);
-
-	void doEstablish(int esatabIndex, int sub);
 protected:
 	const AccessGameDescription *_gameDescription;
 	Common::RandomSource _randomSource;
@@ -104,6 +100,8 @@ protected:
 	 */
 	void doRoom();
 
+	void speakText(ASurface *s, Common::Array<Common::String>msgArr);
+
 	// Engine APIs
 	virtual Common::Error run();
 	virtual bool hasFeature(EngineFeature f) const;
@@ -198,6 +196,8 @@ public:
 	int _mapOffset;
 	int _screenVirtX;
 
+	bool _clearSummaryFlag;
+
 	// Fields mapped into the flags array
 	int &_useItem;
 	int &_startup;
@@ -229,11 +229,7 @@ public:
 	 */
 	void freeInactiveData();
 
-	void AccessEngine::loadEstablish(int sub);
-
-	void establish(int esatabIndex, int sub);
-
-	void establishCenter(int esatabIndex, int sub);
+	virtual void establish(int esatabIndex, int sub) = 0;
 
 	void plotList();
 	void plotList1();
diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp
index 286a7126..f7ed414 100644
--- a/engines/access/amazon/amazon_game.cpp
+++ b/engines/access/amazon/amazon_game.cpp
@@ -184,6 +184,92 @@ void AmazonEngine::setupGame() {
 	_player->_playerY = _player->_rawPlayer.y = TRAVEL_POS[_player->_roomNumber][1];
 }
 
+void AmazonEngine::establish(int esatabIndex, int sub) {
+	_establishMode = 0;
+	_establishGroup = 0;
+	doEstablish(esatabIndex, sub);
+}
+
+void AmazonEngine::establishCenter(int esatabIndex, int sub) {
+	_establishMode = 1;
+	doEstablish(esatabIndex, sub);
+}
+
+const char *const _estTable[] = { "ETEXT0.DAT", "ETEXT1.DAT", "ETEXT2.DAT", "ETEXT3.DAT" };
+
+void AmazonEngine::loadEstablish(int sub) {
+	if (!_files->existFile("ETEXT.DAT")) {
+		int oldGroup = _establishGroup;
+		_establishGroup = 0;
+
+		_eseg = _files->loadFile(_estTable[oldGroup]);
+	} else {
+		_eseg = _files->loadFile("ETEXT.DAT");
+	}
+
+	_establishCtrlTblOfs = READ_LE_UINT16(_eseg);
+
+	int ofs = _establishCtrlTblOfs + (sub * 2);
+	int idx = READ_LE_UINT16(_eseg + ofs);
+	_narateFile = READ_LE_UINT16(_eseg + idx);
+	_txtPages = READ_LE_UINT16(_eseg + idx + 2);
+
+	if (!_txtPages)
+		return;
+
+	_sndSubFile = READ_LE_UINT16(_eseg + idx + 4);
+	for (int i = 0; i < _txtPages; ++i)
+		_countTbl[i] = READ_LE_UINT16(_eseg + idx + 6 + (2 * i));
+}
+
+void AmazonEngine::doEstablish(int esatabIndex, int sub) {
+	_establishMode = 1;
+
+	_screen->forceFadeOut();
+	_screen->clearScreen();
+	_screen->setPanel(3);
+
+	if (esatabIndex != -1) {
+		_files->loadScreen(95, esatabIndex);
+		_buffer2.copyBuffer(_screen);
+	}
+
+	_screen->setIconPalette();
+	_screen->forceFadeIn();
+
+	_fonts._charSet._lo = 1;
+	_fonts._charSet._hi = 10;
+	_fonts._charFor._lo = 29;
+	_fonts._charFor._hi = 32;
+
+	_screen->_maxChars = 37;
+	_screen->_printOrg = _screen->_printStart = Common::Point(48, 35);
+	loadEstablish(sub);
+	_et = sub;
+	uint16 msgOffset = READ_LE_UINT16(_eseg + (sub * 2) + 2);
+
+	_printEnd = 155;
+	if (_txtPages == 0) {
+		Common::String msg((const char *)_eseg + msgOffset);
+		_fonts._font2.printText(_screen, msg);
+	} else {
+		Common::Array<Common::String> msgArr;
+		for (int i = 0; i < _txtPages; ++i) {
+			Common::String msg((const char *)_eseg + msgOffset);
+			msgOffset += msg.size() + 1;
+			msgArr.push_back(msg);
+		}
+		speakText(_screen, msgArr);
+	}
+
+	_screen->forceFadeOut();
+	_screen->clearScreen();
+
+	free(_eseg);
+	if (_establishMode == 0)
+		_room->init4Quads();
+}
+
 void AmazonEngine::drawHelp() {
 	error("TODO: drawHelp");
 }
diff --git a/engines/access/amazon/amazon_game.h b/engines/access/amazon/amazon_game.h
index c331830..5c4c472 100644
--- a/engines/access/amazon/amazon_game.h
+++ b/engines/access/amazon/amazon_game.h
@@ -73,6 +73,10 @@ private:
 	 */
 	void setupGame();
 
+	void loadEstablish(int sub);
+	void doEstablish(int esatabIndex, int sub);
+	void establishCenter(int esatabIndex, int sub);
+
 protected:
 	/**
 	 * Play the game
@@ -102,6 +106,8 @@ public:
 	virtual ~AmazonEngine();
 
 	void drawHelp();
+
+	virtual void establish(int esatabIndex, int sub);
 };
 
 } // End of namespace Amazon
diff --git a/engines/access/amazon/amazon_room.cpp b/engines/access/amazon/amazon_room.cpp
index c0076fd..3666de5 100644
--- a/engines/access/amazon/amazon_room.cpp
+++ b/engines/access/amazon/amazon_room.cpp
@@ -176,6 +176,18 @@ void AmazonRoom::mainAreaClick() {
 	}
 }
 
+void AmazonRoom::init4Quads() {
+	if (!_vm->_screen->_vesaMode)
+		return;
+
+	warning("TILESCREEN(TILE.BLK);");
+	_vm->_inventory->refreshInventory();
+	warning("TODO: UPDATESUMMARY(chapter)");
+
+	_vm->_screen->setPanel(0);
+	_vm->_screen->clearScreen();
+}
+
 } // End of namespace Amazon
 
 } // End of namespace Access
diff --git a/engines/access/amazon/amazon_room.h b/engines/access/amazon/amazon_room.h
index c7d8e0c..122eed9 100644
--- a/engines/access/amazon/amazon_room.h
+++ b/engines/access/amazon/amazon_room.h
@@ -51,10 +51,13 @@ protected:
 	virtual void roomMenu();
 
 	virtual void mainAreaClick();
+
 public:
 	AmazonRoom(AccessEngine *vm);
 
 	virtual ~AmazonRoom();
+
+	virtual void init4Quads();
 };
 
 } // End of namespace Amazon
diff --git a/engines/access/martian/martian_game.h b/engines/access/martian/martian_game.h
index 29fdd1b..a99ece6 100644
--- a/engines/access/martian/martian_game.h
+++ b/engines/access/martian/martian_game.h
@@ -64,12 +64,12 @@ protected:
 	 */
 	virtual void playGame();
 public:
-public:
 	MartianEngine(OSystem *syst, const AccessGameDescription *gameDesc);
 
 	virtual ~MartianEngine();
 
 	void drawHelp();
+	virtual void establish(int esatabIndex, int sub) {};
 };
 
 } // End of namespace Martian
diff --git a/engines/access/martian/martian_room.h b/engines/access/martian/martian_room.h
index 526de56..14744f5 100644
--- a/engines/access/martian/martian_room.h
+++ b/engines/access/martian/martian_room.h
@@ -53,6 +53,11 @@ public:
 	MartianRoom(AccessEngine *vm);
 
 	virtual ~MartianRoom();
+
+	virtual void loadRoomData(const byte *roomData) { warning("TODO - loadRoomData"); }
+
+	virtual void init4Quads() { }
+
 };
 
 } // End of namespace Martian
diff --git a/engines/access/room.cpp b/engines/access/room.cpp
index 29d9eef..10146ff 100644
--- a/engines/access/room.cpp
+++ b/engines/access/room.cpp
@@ -324,10 +324,6 @@ void Room::buildRow(int playY, int screenY) {
 	error("TODO: buildRow");
 }
 
-void Room::init4Quads() {
-	error("TODO: init4Quads");
-}
-
 void Room::loadPlayField(int fileNum, int subfile) {
 	byte *playData = _vm->_files->loadFile(fileNum, subfile);
 	Common::MemoryReadStream stream(playData + 0x10, _vm->_files->_filesize - 0x10);
diff --git a/engines/access/room.h b/engines/access/room.h
index 6cd3b8c..1d54084 100644
--- a/engines/access/room.h
+++ b/engines/access/room.h
@@ -155,7 +155,7 @@ public:
 	 */
 	void buildRow(int playY, int screenY);
 
-	void init4Quads();
+	virtual void init4Quads() = 0;
 
 	void setWallCodes();
 
diff --git a/engines/access/screen.cpp b/engines/access/screen.cpp
index 57002c0..0251724 100644
--- a/engines/access/screen.cpp
+++ b/engines/access/screen.cpp
@@ -58,6 +58,12 @@ Screen::Screen(AccessEngine *vm) : _vm(vm) {
 	_clipHeight = _vWindowLinesTall - 1;
 }
 
+void Screen::clearScreen() {
+	clearBuffer();
+	if (_vesaMode)
+		_vm->_clearSummaryFlag = true;
+}
+
 void Screen::setDisplayScan() {
 	_clipWidth = this->w - 1;
 	_clipHeight = this->h - 1;
diff --git a/engines/access/screen.h b/engines/access/screen.h
index 3935f2c..a166fde 100644
--- a/engines/access/screen.h
+++ b/engines/access/screen.h
@@ -107,7 +107,7 @@ public:
 
 	void fadeOut() { forceFadeOut(); }
 	void fadeIn() { forceFadeIn(); }
-	void clearScreen() { clearBuffer(); }
+	void clearScreen();
 
 	/**
 	 * Set the initial palette


Commit: 610644c4a1fd386d6fde2c4c52b5aa9c1bdacc48
    https://github.com/scummvm/scummvm/commit/610644c4a1fd386d6fde2c4c52b5aa9c1bdacc48
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-08-27T01:25:18+02:00

Commit Message:
ACCESS: Implement tileScreen

Changed paths:
    engines/access/amazon/amazon_game.cpp
    engines/access/amazon/amazon_game.h
    engines/access/amazon/amazon_room.cpp



diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp
index f7ed414..608db5d 100644
--- a/engines/access/amazon/amazon_game.cpp
+++ b/engines/access/amazon/amazon_game.cpp
@@ -44,15 +44,18 @@ AmazonEngine::AmazonEngine(OSystem *syst, const AccessGameDescription *gameDesc)
 	_hitCount = 0;
 	_saveRiver = 0;
 	_hitSafe = 0;
-	_chapter = 0;
+	_oldTitleChap = _chapter = 0;
 	_topList = 0;
 	_botList = 0;
 	_riverIndex = 0;
 	_rawInactiveX = 0;
 	_rawInactiveY = 0;
 	_inactiveYOff = 0;
+	_tilePos = Common::Point(0, 0);
 
 	Common::fill(&_esTabTable[0], &_esTabTable[100], 0);
+	memset(_tileData, 0, sizeof(_tileData));
+
 	_hintLevel = 0;
 }
 
@@ -270,6 +273,41 @@ void AmazonEngine::doEstablish(int esatabIndex, int sub) {
 		_room->init4Quads();
 }
 
+const char *const _tileFiles[] = {
+	"GRAY.BLK", "RED.BLK", "LTBROWN.BLK", "DKBROWN.BLK", "VIOLET.BLK", "LITEBLUE.BLK",
+	"DARKBLUE.BLK", "CYAN.BLK", "GREEN.BLK", "OLIVE.BLK", "GRAY.BLK", "RED.BLK",
+	"LTBROWN.BLK", "DKBROWN.BLK", "VIOLET.BLK", "OLIVE.BLK"
+};
+
+void AmazonEngine::tileScreen(Common::String filename) {
+	if (!_screen->_vesaMode)
+		return;
+
+	if (!_clearSummaryFlag && (_oldTitleChap == _chapter))
+		return;
+
+	_oldTitleChap = _chapter;
+	int idx = _chapter - 1;
+
+	if (!_files->existFile(_tileFiles[idx]))
+		return;
+
+	byte *data = _files->loadFile(_tileFiles[idx]);
+	int x = READ_LE_UINT16(data);
+	int y = READ_LE_UINT16(data + 2);
+	int size = ((x + 2) * y) + 10;
+	
+	for (int i = 0; i < size; ++i)
+		_tileData[i] = data[i + 4];
+
+	// CHECKME: Depending on the Vesa mode during initialization, 400 or 480
+	for (_tilePos.y = 0; _tilePos.y < 480; _tilePos.y += y) {
+		for (_tilePos.x = 0; _tilePos.x < 640; _tilePos.x += x)
+			warning("TODO: DRAWOBJECT");
+	}
+
+}
+
 void AmazonEngine::drawHelp() {
 	error("TODO: drawHelp");
 }
diff --git a/engines/access/amazon/amazon_game.h b/engines/access/amazon/amazon_game.h
index 5c4c472..5192e20 100644
--- a/engines/access/amazon/amazon_game.h
+++ b/engines/access/amazon/amazon_game.h
@@ -39,6 +39,7 @@ private:
 	int _hitCount;
 	int _saveRiver;
 	int _hitSafe;
+	int _oldTitleChap;
 	int _chapter;
 	int _topList;
 	int _botList;
@@ -47,6 +48,8 @@ private:
 	int _rawInactiveY;
 	int _inactiveYOff;
 	int _esTabTable[100];
+	Common::Point _tilePos;
+	byte _tileData[1455];
 
 	/**
 	 * Do the game introduction
@@ -108,6 +111,8 @@ public:
 	void drawHelp();
 
 	virtual void establish(int esatabIndex, int sub);
+
+	void tileScreen(Common::String filename);
 };
 
 } // End of namespace Amazon
diff --git a/engines/access/amazon/amazon_room.cpp b/engines/access/amazon/amazon_room.cpp
index 3666de5..f8c8bc4 100644
--- a/engines/access/amazon/amazon_room.cpp
+++ b/engines/access/amazon/amazon_room.cpp
@@ -180,7 +180,7 @@ void AmazonRoom::init4Quads() {
 	if (!_vm->_screen->_vesaMode)
 		return;
 
-	warning("TILESCREEN(TILE.BLK);");
+	_game->tileScreen(Common::String("TILE.BLK"));
 	_vm->_inventory->refreshInventory();
 	warning("TODO: UPDATESUMMARY(chapter)");
 


Commit: ff05b42e021ba12ce9ca86d118868cfa32d911eb
    https://github.com/scummvm/scummvm/commit/ff05b42e021ba12ce9ca86d118868cfa32d911eb
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-08-27T08:13:54+02:00

Commit Message:
ACCESS: Implement updateSummary

Changed paths:
    engines/access/amazon/amazon_game.cpp
    engines/access/amazon/amazon_game.h
    engines/access/amazon/amazon_room.cpp



diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp
index 608db5d..f7f3611 100644
--- a/engines/access/amazon/amazon_game.cpp
+++ b/engines/access/amazon/amazon_game.cpp
@@ -45,6 +45,7 @@ AmazonEngine::AmazonEngine(OSystem *syst, const AccessGameDescription *gameDesc)
 	_saveRiver = 0;
 	_hitSafe = 0;
 	_oldTitleChap = _chapter = 0;
+	_updateChapter = -1;
 	_topList = 0;
 	_botList = 0;
 	_riverIndex = 0;
@@ -279,7 +280,7 @@ const char *const _tileFiles[] = {
 	"LTBROWN.BLK", "DKBROWN.BLK", "VIOLET.BLK", "OLIVE.BLK"
 };
 
-void AmazonEngine::tileScreen(Common::String filename) {
+void AmazonEngine::tileScreen() {
 	if (!_screen->_vesaMode)
 		return;
 
@@ -308,6 +309,46 @@ void AmazonEngine::tileScreen(Common::String filename) {
 
 }
 
+void AmazonEngine::updateSummary(int chap) {
+	if (!_screen->_vesaMode)
+		return;
+
+	int chapter = chap;
+	if (chapter > 16)
+		chapter = 16;
+
+	if (!_clearSummaryFlag && (chapter == _updateChapter))
+		return;
+
+	_clearSummaryFlag = false;
+	int celSubFile = 0;
+	_updateChapter = chapter;
+	Common::Array<CellIdent> summaryCells;
+	loadCells(summaryCells);
+	
+	for (int i = celSubFile; i < 16; ++i) {
+		if (i > 7)
+			warning("TODO: DRAWOBJECT");
+		else
+			warning("TODO: DRAWOBJECT");
+	}
+
+	delete _objectsTable[93];
+	_objectsTable[93] = nullptr;
+
+	for (int i = 1; i <= _updateChapter; ++i) {
+		celSubFile = i;
+		loadCells(summaryCells);
+		if (i > 8)
+			warning("TODO: DRAWOBJECT");
+		else
+			warning("TODO: DRAWOBJECT");
+
+		delete _objectsTable[93];
+		_objectsTable[93] = nullptr;
+	}
+}
+
 void AmazonEngine::drawHelp() {
 	error("TODO: drawHelp");
 }
diff --git a/engines/access/amazon/amazon_game.h b/engines/access/amazon/amazon_game.h
index 5192e20..59511c4 100644
--- a/engines/access/amazon/amazon_game.h
+++ b/engines/access/amazon/amazon_game.h
@@ -40,7 +40,6 @@ private:
 	int _saveRiver;
 	int _hitSafe;
 	int _oldTitleChap;
-	int _chapter;
 	int _topList;
 	int _botList;
 	int _riverIndex;
@@ -103,6 +102,9 @@ public:
 
 	// Other game specific fields
 	int _hintLevel;
+
+	int _chapter;
+	int _updateChapter;
 public:
 	AmazonEngine(OSystem *syst, const AccessGameDescription *gameDesc);
 
@@ -112,7 +114,8 @@ public:
 
 	virtual void establish(int esatabIndex, int sub);
 
-	void tileScreen(Common::String filename);
+	void tileScreen();
+	void updateSummary(int chap);
 };
 
 } // End of namespace Amazon
diff --git a/engines/access/amazon/amazon_room.cpp b/engines/access/amazon/amazon_room.cpp
index f8c8bc4..f64264f 100644
--- a/engines/access/amazon/amazon_room.cpp
+++ b/engines/access/amazon/amazon_room.cpp
@@ -180,9 +180,10 @@ void AmazonRoom::init4Quads() {
 	if (!_vm->_screen->_vesaMode)
 		return;
 
-	_game->tileScreen(Common::String("TILE.BLK"));
+	// CHECKME: in the original, this call of tileScreen uses an useless parameter, "TILES.BLK"
+	_game->tileScreen();
 	_vm->_inventory->refreshInventory();
-	warning("TODO: UPDATESUMMARY(chapter)");
+	_game->updateSummary(_game->_chapter);
 
 	_vm->_screen->setPanel(0);
 	_vm->_screen->clearScreen();


Commit: 1590f29d149df976e27df4a49c21ae4d23ab8663
    https://github.com/scummvm/scummvm/commit/1590f29d149df976e27df4a49c21ae4d23ab8663
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-08-28T01:59:53+02:00

Commit Message:
ACCESS: Use the hires version in Amazon CD

Changed paths:
    engines/access/access.cpp



diff --git a/engines/access/access.cpp b/engines/access/access.cpp
index c19a37c..6058800 100644
--- a/engines/access/access.cpp
+++ b/engines/access/access.cpp
@@ -141,7 +141,11 @@ void AccessEngine::initialize() {
 
 	if (isCD()) {
 		const Common::FSNode gameDataDir(ConfMan.get("path"));
-		const Common::FSNode cdromDir = gameDataDir.getChild("cdrom");
+		// The CD version contains two versions of the game.
+		// - The MCGA version, in the CDROM folder
+		// - The VESA version, in the TDROM folder
+		// We use the hires version.
+		const Common::FSNode cdromDir = gameDataDir.getChild("tdrom");
 
 		for (int idx = 0; idx < 15; ++idx) {
 			Common::String folder = (idx == 0) ? "game" :


Commit: 941b443195006a787f25143559bf793e863b9446
    https://github.com/scummvm/scummvm/commit/941b443195006a787f25143559bf793e863b9446
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-08-28T02:01:05+02:00

Commit Message:
ACCESS: Fix a crash in the intro

Changed paths:
    engines/access/amazon/amazon_game.cpp



diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp
index f7f3611..15869a4 100644
--- a/engines/access/amazon/amazon_game.cpp
+++ b/engines/access/amazon/amazon_game.cpp
@@ -90,7 +90,7 @@ void AmazonEngine::doIntroduction() {
 	_events->showCursor();
 	_screen->setPanel(0);
 
-	// TODO: Worry about implementing full intro sequence later
+	//TODO: Implement the rest of the intro
 	return;
 
 	doTitle();
@@ -123,6 +123,9 @@ void AmazonEngine::doTitle() {
 	_sound->queueSound(0, 98, 30);
 	_sound->_soundPriority[0] = 1;
 
+	_sound->queueSound(1, 98, 8);
+	_sound->_soundPriority[1] = 1;
+
 	_screen->_loadPalFlag = false;
 	_files->loadScreen(0, 3);
 	
@@ -146,14 +149,18 @@ void AmazonEngine::doTitle() {
 	_sound->playSound(1);
 
 	const int COUNTDOWN[6] = { 2, 0x80, 1, 0x7d, 0, 0x87 };
-	for (_pCount = 0; _pCount < 3; ++_pCount) {
-		_buffer2.copyFrom(_buffer1);
-		int id = READ_LE_UINT16(COUNTDOWN + _pCount * 4);
-		int xp = READ_LE_UINT16(COUNTDOWN + _pCount * 4 + 2);
-		_screen->plotImage(_objectsTable[0], id, Common::Point(xp, 71));
+	for (_pCount = 0; _pCount <= 3; ++_pCount) {
+		if (_pCount != 3) {
+			_buffer2.copyFrom(_buffer1);
+			int id = READ_LE_UINT16(COUNTDOWN + _pCount * 2);
+			int xp = READ_LE_UINT16(COUNTDOWN + _pCount * 2 + 1);
+			_screen->plotImage(_objectsTable[0], id, Common::Point(xp, 71));
+			//TODO : more intro
+		} else {
+			//TODO : more intro
+		}
 	}
-	// TODO: More to do
-
+	//TODO : more intro
 	delete _objectsTable[0];
 }
 


Commit: a0e54db08155f8cf8d56f66743ffa694c188e33b
    https://github.com/scummvm/scummvm/commit/a0e54db08155f8cf8d56f66743ffa694c188e33b
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-08-28T02:01:33+02:00

Commit Message:
ACCESS: Set Vesa mode when using the CD

Changed paths:
    engines/access/screen.cpp



diff --git a/engines/access/screen.cpp b/engines/access/screen.cpp
index 0251724..4f2ee3e 100644
--- a/engines/access/screen.cpp
+++ b/engines/access/screen.cpp
@@ -41,7 +41,11 @@ Screen::Screen(AccessEngine *vm) : _vm(vm) {
 	Common::fill(&_scaleTable1[0], &_scaleTable1[256], 0);
 	Common::fill(&_scaleTable2[0], &_scaleTable2[256], 0);
 	_savedPaletteCount = 0;
-	_vesaMode = 0;
+	if (_vm->isCD())
+		_vesaMode = 0;
+	else
+		_vesaMode = 1;
+
 	_vesaCurrentWin = 0;
 	_currentPanel = 0;
 	_hideFlag = true;


Commit: 455011c37e20fb2d859e1c3f04650e369844c921
    https://github.com/scummvm/scummvm/commit/455011c37e20fb2d859e1c3f04650e369844c921
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-08-28T02:02:03+02:00

Commit Message:
ACCESS: Fix typo in detection comment

Changed paths:
    engines/access/detection_tables.h



diff --git a/engines/access/detection_tables.h b/engines/access/detection_tables.h
index 6a281a7..95ac8fa 100644
--- a/engines/access/detection_tables.h
+++ b/engines/access/detection_tables.h
@@ -42,7 +42,7 @@ static const AccessGameDescription gameDescriptions[] = {
 	},
 
 	{
-		// Amazon Guadians of Eden - CD English
+		// Amazon: Guardians of Eden - CD English
 		{
 			"amazon",
 			"CD",


Commit: c0a7852662be724077921bcf9b9bb0bf2da2dfff
    https://github.com/scummvm/scummvm/commit/c0a7852662be724077921bcf9b9bb0bf2da2dfff
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-27T22:13:43-04:00

Commit Message:
ACCESS: Refactor the file manager to return resource structures

Changed paths:
    engines/access/access.cpp
    engines/access/access.h
    engines/access/amazon/amazon_game.cpp
    engines/access/amazon/amazon_room.cpp
    engines/access/animation.cpp
    engines/access/animation.h
    engines/access/asurface.cpp
    engines/access/asurface.h
    engines/access/bubble_box.cpp
    engines/access/char.cpp
    engines/access/files.cpp
    engines/access/files.h
    engines/access/martian/martian_game.cpp
    engines/access/martian/martian_room.cpp
    engines/access/player.cpp
    engines/access/room.cpp
    engines/access/screen.cpp
    engines/access/scripts.cpp
    engines/access/scripts.h
    engines/access/sound.cpp
    engines/access/sound.h
    engines/access/video.cpp
    engines/access/video.h



diff --git a/engines/access/access.cpp b/engines/access/access.cpp
index 6058800..080cd36 100644
--- a/engines/access/access.cpp
+++ b/engines/access/access.cpp
@@ -70,6 +70,7 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc)
 	_scaleMaxY = 0;
 	_scaleI = 0;
 	_scaleFlag = false;
+	_eseg = nullptr;
 
 	_conversation = 0;
 	_currentMan = 0;
@@ -124,9 +125,9 @@ AccessEngine::~AccessEngine() {
 	delete _video;
 
 	freeCells();
-	delete[] _inactive;
-	delete[] _music;
-	delete[] _title;
+	delete _inactive;
+	delete _music;
+	delete _title;
 }
 
 void AccessEngine::setVGA() {
@@ -211,9 +212,9 @@ int AccessEngine::getRandomNumber(int maxNumber) {
 
 void AccessEngine::loadCells(Common::Array<CellIdent> &cells) {
 	for (uint i = 0; i < cells.size(); ++i) {
-		byte *spriteData = _files->loadFile(cells[i]);
-		_objectsTable[cells[i]._cell] = new SpriteResource(this, 
-			spriteData, _files->_filesize, DisposeAfterUse::YES);
+		Resource *spriteData = _files->loadFile(cells[i]);
+		_objectsTable[cells[i]._cell] = new SpriteResource(this, spriteData);
+		delete spriteData;
 	}
 }
 
@@ -251,7 +252,7 @@ void AccessEngine::speakText(ASurface *s, Common::Array<Common::String> msgArr)
 
 		if ((s->_printOrg.y > _printEnd) && (!lastLine)) {
 			while (true) {
-				_sound->_soundTable[0]._data = _sound->loadSound(_narateFile + 99, _sndSubFile);
+				_sound->_soundTable[0] = _sound->loadSound(_narateFile + 99, _sndSubFile);
 				_sound->_soundPriority[0] = 1;
 				_sound->playSound(1);
 				_scripts->CMDFREESOUND();
@@ -286,7 +287,7 @@ void AccessEngine::speakText(ASurface *s, Common::Array<Common::String> msgArr)
 		return;
 
 	while(true) {
-		_sound->_soundTable[0]._data = _sound->loadSound(_narateFile + 99, _sndSubFile);
+		_sound->_soundTable[0] = _sound->loadSound(_narateFile + 99, _sndSubFile);
 		_sound->_soundPriority[0] = 1;
 		_sound->playSound(1);
 		_scripts->CMDFREESOUND();
diff --git a/engines/access/access.h b/engines/access/access.h
index f25effe..55810e8 100644
--- a/engines/access/access.h
+++ b/engines/access/access.h
@@ -148,9 +148,9 @@ public:
 	int _mouseMode;
 
 	int _currentManOld;
-	byte *_inactive;
-	byte *_music;
-	byte *_title;
+	Resource *_inactive;
+	Resource *_music;
+	Resource *_title;
 	int _converseMode;
 	int _startAboutBox;
 	int _startTravelBox;
@@ -164,7 +164,7 @@ public:
 	int _scaleI;
 	bool _scaleFlag;
 
-	byte *_eseg;
+	Resource *_eseg;
 	int _et;
 	int _printEnd;
 	int _txtPages;
diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp
index 15869a4..cf383ce 100644
--- a/engines/access/amazon/amazon_game.cpp
+++ b/engines/access/amazon/amazon_game.cpp
@@ -134,9 +134,9 @@ void AmazonEngine::doTitle() {
 	_screen->forceFadeIn();
 	_sound->playSound(1);
 
-	byte *spriteData = _files->loadFile(0, 2);
-	_objectsTable[0] = new SpriteResource(this, spriteData, _files->_filesize,
-		DisposeAfterUse::YES);
+	Resource *spriteData = _files->loadFile(0, 2);
+	_objectsTable[0] = new SpriteResource(this, spriteData);
+	delete spriteData;
 
 	_sound->playSound(1);
 
@@ -300,13 +300,13 @@ void AmazonEngine::tileScreen() {
 	if (!_files->existFile(_tileFiles[idx]))
 		return;
 
-	byte *data = _files->loadFile(_tileFiles[idx]);
-	int x = READ_LE_UINT16(data);
-	int y = READ_LE_UINT16(data + 2);
+	Resource *res = _files->loadFile(_tileFiles[idx]);
+	int x = res->_stream->readSint16LE();
+	int y = res->_stream->readSint16LE();
 	int size = ((x + 2) * y) + 10;
 	
 	for (int i = 0; i < size; ++i)
-		_tileData[i] = data[i + 4];
+		_tileData[i] = res->_stream->readByte();
 
 	// CHECKME: Depending on the Vesa mode during initialization, 400 or 480
 	for (_tilePos.y = 0; _tilePos.y < 480; _tilePos.y += y) {
@@ -314,6 +314,7 @@ void AmazonEngine::tileScreen() {
 			warning("TODO: DRAWOBJECT");
 	}
 
+	delete res;
 }
 
 void AmazonEngine::updateSummary(int chap) {
diff --git a/engines/access/amazon/amazon_room.cpp b/engines/access/amazon/amazon_room.cpp
index f64264f..227fc47 100644
--- a/engines/access/amazon/amazon_room.cpp
+++ b/engines/access/amazon/amazon_room.cpp
@@ -131,9 +131,9 @@ void AmazonRoom::roomSet() {
 }
 
 void AmazonRoom::roomMenu() {
-	byte *iconData = _vm->_files->loadFile("ICONS.LZ");
-	SpriteResource *spr = new SpriteResource(_vm, iconData, _vm->_files->_filesize);
-	delete[] iconData;
+	Resource *iconData = _vm->_files->loadFile("ICONS.LZ");
+	SpriteResource *spr = new SpriteResource(_vm, iconData);
+	delete iconData;
 
 	_vm->_screen->saveScreen();
 	_vm->_screen->setDisplayScan();
diff --git a/engines/access/animation.cpp b/engines/access/animation.cpp
index b286237..03f349e 100644
--- a/engines/access/animation.cpp
+++ b/engines/access/animation.cpp
@@ -27,18 +27,17 @@
 
 namespace Access {
 
-AnimationResource::AnimationResource(AccessEngine *vm, const byte *data, int size) {
-	Common::MemoryReadStream stream(data, size);
-	int count = stream.readUint16LE();
+AnimationResource::AnimationResource(AccessEngine *vm, Resource *res) {
+	int count = res->_stream->readUint16LE();
 
 	Common::Array<int> offsets;
 	for (int i = 0; i < count; ++i)
-		offsets.push_back(stream.readUint32LE());
+		offsets.push_back(res->_stream->readUint32LE());
 
 	_animations.reserve(count);
 	for (int i = 0; i < count; ++i) {
-		stream.seek(offsets[i]);
-		Animation *anim = new Animation(vm, stream);
+		res->_stream->seek(offsets[i]);
+		Animation *anim = new Animation(vm, res->_stream);
 		_animations.push_back(anim);
 	}
 }
@@ -50,29 +49,29 @@ AnimationResource::~AnimationResource() {
 
 /*------------------------------------------------------------------------*/
 
-Animation::Animation(AccessEngine *vm, Common::MemoryReadStream &stream):
+Animation::Animation(AccessEngine *vm, Common::SeekableReadStream *stream) :
 		Manager(vm) {
-	uint32 startOfs = stream.pos();
-
-	_type = stream.readByte();
-	_scaling = stream.readSByte();
-	stream.readByte(); // unk
-	_frameNumber = stream.readByte();
-	_initialTicks = stream.readUint16LE();
-	stream.readUint16LE(); // unk
-	stream.readUint16LE(); // unk
-	_loopCount = stream.readSint16LE();
-	_countdownTicks = stream.readUint16LE();
-	_currentLoopCount = stream.readSint16LE();
-	stream.readUint16LE(); // unk
+	uint32 startOfs = stream->pos();
+
+	_type = stream->readByte();
+	_scaling = stream->readSByte();
+	stream->readByte(); // unk
+	_frameNumber = stream->readByte();
+	_initialTicks = stream->readUint16LE();
+	stream->readUint16LE(); // unk
+	stream->readUint16LE(); // unk
+	_loopCount = stream->readSint16LE();
+	_countdownTicks = stream->readUint16LE();
+	_currentLoopCount = stream->readSint16LE();
+	stream->readUint16LE(); // unk
 
 	Common::Array<uint16> frameOffsets;
 	uint16 ofs;
-	while ((ofs = stream.readUint16LE()) != 0)
+	while ((ofs = stream->readUint16LE()) != 0)
 		frameOffsets.push_back(ofs);
 
 	for (int i = 0; i < (int)frameOffsets.size(); i++) {
-		stream.seek(startOfs + frameOffsets[i]);
+		stream->seek(startOfs + frameOffsets[i]);
 
 		AnimationFrame *frame = new AnimationFrame(stream, startOfs);
 		_frames.push_back(frame);
@@ -239,22 +238,22 @@ void Animation::setFrame1(AnimationFrame *frame) {
 
 /*------------------------------------------------------------------------*/
 
-AnimationFrame::AnimationFrame(Common::MemoryReadStream &stream, int startOffset) {
+AnimationFrame::AnimationFrame(Common::SeekableReadStream *stream, int startOffset) {
 	uint16 nextOffset;
 
-	stream.readByte(); // unk
-	_baseX = stream.readUint16LE();
-	_baseY = stream.readUint16LE();
-	_frameDelay = stream.readUint16LE();
-	nextOffset = stream.readUint16LE();
+	stream->readByte(); // unk
+	_baseX = stream->readUint16LE();
+	_baseY = stream->readUint16LE();
+	_frameDelay = stream->readUint16LE();
+	nextOffset = stream->readUint16LE();
 
 	while (nextOffset != 0) {
-		stream.seek(startOffset + nextOffset);
+		stream->seek(startOffset + nextOffset);
 
 		AnimationFramePart *framePart = new AnimationFramePart(stream);
 		_parts.push_back(framePart);
 
-		nextOffset = stream.readUint16LE();
+		nextOffset = stream->readUint16LE();
 	}
 }
 
@@ -265,13 +264,13 @@ AnimationFrame::~AnimationFrame() {
 
 /*------------------------------------------------------------------------*/
 
-AnimationFramePart::AnimationFramePart(Common::MemoryReadStream &stream) {
-	_flags = stream.readByte();
-	_spritesIndex = stream.readByte();
-	_frameIndex = stream.readByte();
-	_position.x = stream.readUint16LE();
-	_position.y = stream.readUint16LE();
-	_offsetY = stream.readUint16LE();
+AnimationFramePart::AnimationFramePart(Common::SeekableReadStream *stream) {
+	_flags = stream->readByte();
+	_spritesIndex = stream->readByte();
+	_frameIndex = stream->readByte();
+	_position.x = stream->readUint16LE();
+	_position.y = stream->readUint16LE();
+	_offsetY = stream->readUint16LE();
 }
 
 /*------------------------------------------------------------------------*/
@@ -296,10 +295,10 @@ void AnimationManager::clearTimers() {
 	_animationTimers.clear();
 }
 
-void AnimationManager::loadAnimations(const byte *data, int size) {
+void AnimationManager::loadAnimations(Resource *res) {
 	_animationTimers.clear();
 	delete _animation;
-	_animation = new AnimationResource(_vm, data,  size);
+	_animation = new AnimationResource(_vm, res);
 }
 
 
diff --git a/engines/access/animation.h b/engines/access/animation.h
index 7e94f58..8a39333 100644
--- a/engines/access/animation.h
+++ b/engines/access/animation.h
@@ -27,6 +27,7 @@
 #include "common/array.h"
 #include "common/memstream.h"
 #include "access/data.h"
+#include "access/files.h"
 
 namespace Access {
 
@@ -47,7 +48,7 @@ public:
 	AnimationManager(AccessEngine *vm);
 	~AnimationManager();
 	void freeAnimationData();
-	void loadAnimations(const byte *data, int size);
+	void loadAnimations(Resource *res);
 	
 	Animation *findAnimation(int animId);
 	Animation *setAnimation(int animId);
@@ -74,7 +75,7 @@ class AnimationResource {
 private:
 	Common::Array<Animation *> _animations;
 public:
-	AnimationResource(AccessEngine *vm, const byte *data, int size);
+	AnimationResource(AccessEngine *vm, Resource *res);
 	~AnimationResource();
 
 	int getCount() { return _animations.size(); }
@@ -107,7 +108,7 @@ public:
 	int _currentLoopCount;
 	int _field10;
 public:
-	Animation(AccessEngine *vm, Common::MemoryReadStream &stream);
+	Animation(AccessEngine *vm, Common::SeekableReadStream *stream);
 	~Animation();
 
 	void animate();
@@ -119,7 +120,7 @@ public:
 	int _frameDelay;
 	Common::Array<AnimationFramePart *> _parts;
 public:
-	AnimationFrame(Common::MemoryReadStream &stream, int startOffset);
+	AnimationFrame(Common::SeekableReadStream *stream, int startOffset);
 	~AnimationFrame();
 };
 
@@ -131,7 +132,7 @@ public:
 	Common::Point _position;
 	int _offsetY;
 public:
-	AnimationFramePart(Common::MemoryReadStream &stream);
+	AnimationFramePart(Common::SeekableReadStream *stream);
 };
 
 } // End of namespace Access
diff --git a/engines/access/asurface.cpp b/engines/access/asurface.cpp
index cdf8b3d..cf8bf07 100644
--- a/engines/access/asurface.cpp
+++ b/engines/access/asurface.cpp
@@ -28,27 +28,22 @@
 
 namespace Access {
 
-SpriteResource::SpriteResource(AccessEngine *vm, const byte *data, uint32 size,
-		DisposeAfterUse::Flag disposeMemory) {
-	Common::MemoryReadStream stream(data, size);
+SpriteResource::SpriteResource(AccessEngine *vm, Resource *res) {
 	Common::Array<uint32> offsets;
-	int count = stream.readUint16LE();
+	int count = res->_stream->readUint16LE();
 
 	for (int i = 0; i < count; i++)
-		offsets.push_back(stream.readUint32LE());
-	offsets.push_back(size);	// For easier calculations of Noctropolis sizes
+		offsets.push_back(res->_stream->readUint32LE());
+	offsets.push_back(res->_size);	// For easier calculations of Noctropolis sizes
 
 	// Build up the frames
 	for (int i = 0; i < count; ++i) {
-		stream.seek(offsets[i]);
+		res->_stream->seek(offsets[i]);
 		int frameSize = offsets[i + 1] - offsets[i];
 
-		SpriteFrame *frame = new SpriteFrame(vm, stream, frameSize);
+		SpriteFrame *frame = new SpriteFrame(vm, res->_stream, frameSize);
 		_frames.push_back(frame);
 	}
-
-	if (disposeMemory == DisposeAfterUse::YES)
-		delete[] data;
 }
 
 SpriteResource::~SpriteResource() {
@@ -56,9 +51,9 @@ SpriteResource::~SpriteResource() {
 		delete _frames[i];
 }
 
-SpriteFrame::SpriteFrame(AccessEngine *vm, Common::MemoryReadStream &stream, int frameSize) {
-	int xSize = stream.readUint16LE();
-	int ySize = stream.readUint16LE();
+SpriteFrame::SpriteFrame(AccessEngine *vm, Common::SeekableReadStream *stream, int frameSize) {
+	int xSize = stream->readUint16LE();
+	int ySize = stream->readUint16LE();
 	create(xSize, ySize);
 	
 	// Empty surface
@@ -67,12 +62,12 @@ SpriteFrame::SpriteFrame(AccessEngine *vm, Common::MemoryReadStream &stream, int
 	
 	// Decode the data
 	for (int y = 0; y < h; ++y) {
-		int offset = stream.readByte();
-		int len = stream.readByte();
+		int offset = stream->readByte();
+		int len = stream->readByte();
 		assert((offset + len) <= w);
 
 		byte *destP = (byte *)getBasePtr(offset, y);
-		stream.read(destP, len);
+		stream->read(destP, len);
 	}
 }
 
diff --git a/engines/access/asurface.h b/engines/access/asurface.h
index 5d1f6fd..5c164f0 100644
--- a/engines/access/asurface.h
+++ b/engines/access/asurface.h
@@ -115,7 +115,7 @@ public:
 
 class SpriteFrame : public ASurface {
 public:
-	SpriteFrame(AccessEngine *vm, Common::MemoryReadStream &stream, int frameSize);
+	SpriteFrame(AccessEngine *vm, Common::SeekableReadStream *stream, int frameSize);
 	~SpriteFrame();
 };
 
@@ -123,8 +123,7 @@ class SpriteResource {
 public:
 	Common::Array<SpriteFrame *> _frames;
 public:
-	SpriteResource(AccessEngine *vm, const byte *data, uint32 size,
-		DisposeAfterUse::Flag disposeMemory = DisposeAfterUse::NO);
+	SpriteResource(AccessEngine *vm, Resource *res);
 	~SpriteResource();
 
 	int getCount() { return _frames.size(); }
diff --git a/engines/access/bubble_box.cpp b/engines/access/bubble_box.cpp
index d3782a3..c4272b6 100644
--- a/engines/access/bubble_box.cpp
+++ b/engines/access/bubble_box.cpp
@@ -191,9 +191,9 @@ void BubbleBox::doBox(int item, int box) {
 	}
 
 	// Get icons data
-	byte *iconData = _vm->_files->loadFile("ICONS.LZ");
-	SpriteResource *icons = new SpriteResource(_vm, iconData, _vm->_files->_filesize);
-	delete[] iconData;
+	Resource *iconData = _vm->_files->loadFile("ICONS.LZ");
+	SpriteResource *icons = new SpriteResource(_vm, iconData);
+	delete iconData;
 
 	// Set the up boundaries and color to use for the box background
 	_vm->_screen->_orgX1 = _bounds.left - 2;
diff --git a/engines/access/char.cpp b/engines/access/char.cpp
index 09335fc..767512f 100644
--- a/engines/access/char.cpp
+++ b/engines/access/char.cpp
@@ -121,15 +121,15 @@ void CharManager::loadChar(int charId) {
 
 	_vm->loadCells(ce._cells);
 	if (ce._animFile._fileNum != -1) {
-		byte *data = _vm->_files->loadFile(ce._animFile);
-		_vm->_animation->loadAnimations(data, _vm->_files->_filesize);
+		Resource *data = _vm->_files->loadFile(ce._animFile);
+		_vm->_animation->loadAnimations(data);
 	}
 
 	// Load script data
 	_vm->_scripts->freeScriptData();
 	if (ce._scriptFile._fileNum != -1) {
-		const byte *data = _vm->_files->loadFile(ce._scriptFile);
-		_vm->_scripts->setScript(data, _vm->_files->_filesize);
+		Resource *data = _vm->_files->loadFile(ce._scriptFile);
+		_vm->_scripts->setScript(data);
 	}
 
 	// Load extra cells
@@ -139,9 +139,9 @@ void CharManager::loadChar(int charId) {
 }
 
 void CharManager::charMenu() {
-	byte *iconData = _vm->_files->loadFile("ICONS.LZ");
-	SpriteResource *spr = new SpriteResource(_vm, iconData, _vm->_files->_filesize);
-	delete[] iconData;
+	Resource *iconData = _vm->_files->loadFile("ICONS.LZ");
+	SpriteResource *spr = new SpriteResource(_vm, iconData);
+	delete iconData;
 
 	Screen &screen = *_vm->_screen;
 	screen.saveScreen();
diff --git a/engines/access/files.cpp b/engines/access/files.cpp
index b1d6140..78cb3ef 100644
--- a/engines/access/files.cpp
+++ b/engines/access/files.cpp
@@ -20,6 +20,7 @@
  *
  */
 
+#include "common/substream.h"
 #include "access/files.h"
 #include "access/amazon/amazon_resources.h"
 #include "access/martian/martian_resources.h"
@@ -47,6 +48,27 @@ CellIdent::CellIdent(int cell, int fileNum, int subfile) {
 
 /*------------------------------------------------------------------------*/
 
+Resource::Resource() {
+	_stream = nullptr;
+	_size = 0;
+}
+
+Resource::~Resource() {
+	delete _stream;
+}
+
+byte *Resource::data() {
+	if (_data == nullptr) {
+		_data = new byte[_size];
+		_stream->seek(0);
+		_stream->read(_data, _size);
+	}
+
+	return _data;
+}
+
+/*------------------------------------------------------------------------*/
+
 FileManager::FileManager(AccessEngine *vm): _vm(vm) {
 	switch (vm->getGameID()) {
 	case GType_Amazon:
@@ -60,71 +82,70 @@ FileManager::FileManager(AccessEngine *vm): _vm(vm) {
 	}
 
 	_fileNumber = -1;
-	_stream = nullptr;
 }
 
 FileManager::~FileManager() {
-	delete _stream;
-	_file.close();
 }
 
-byte *FileManager::loadFile(int fileNum, int subfile) {
-	setAppended(fileNum);
-	gotoAppended(subfile);
+Resource *FileManager::loadFile(int fileNum, int subfile) {
+	Resource *res = new Resource();
+	setAppended(res, fileNum);
+	gotoAppended(res, subfile);
 
-	return handleFile();
+	handleFile(res);
+	return res;
 }
 
-byte *FileManager::loadFile(FileIdent &fileIdent) {
+Resource *FileManager::loadFile(FileIdent &fileIdent) {
 	return loadFile(fileIdent._fileNum, fileIdent._subfile);
 }
 
-byte *FileManager::loadFile(const Common::String &filename) {
+Resource *FileManager::loadFile(const Common::String &filename) {
+	Resource *res = new Resource();
+
 	// Open the file
-	openFile(filename);
+	openFile(res, filename);
 
-	// Get a stream for the entire file
-	delete _stream;
-	_stream = _file.readStream(_file.size());
+	// Set up stream for the entire file
+	res->_size = res->_file.size();
+	res->_stream = res->_file.readStream(res->_size);
 
-	return handleFile();
+	handleFile(res);
+	return res;
 }
 
 bool FileManager::existFile(const Common::String &filename) {
-	return _file.exists(filename);
+	Common::File f;
+	return f.exists(filename);
 }
 
-void FileManager::openFile(const Common::String &filename) {
+void FileManager::openFile(Resource *res, const Common::String &filename) {
 	// Open up the file
 	_fileNumber = -1;
-	_file.close();
-	if (!_file.open(filename))
+	if (!res->_file.open(filename))
 		error("Could not open file - %s", filename.c_str());
-
-	_filesize = _file.size();
 }
 
 void FileManager::loadScreen(Graphics::Surface *dest, int fileNum, int subfile) {
-	setAppended(fileNum);
-	gotoAppended(subfile);
-	_vm->_screen->loadPalette(_stream);
+	Resource *res = loadFile(fileNum, subfile);
+	handleScreen(dest, res);
+	delete res;
+}
 
-	// Get the data for the screen, and copy it over
-	byte *pSrc = handleFile();
+void FileManager::handleScreen(Graphics::Surface *dest, Resource *res) {
+	_vm->_screen->loadPalette(res->_stream);
 
 	if (dest != _vm->_screen)
 		dest->w = _vm->_screen->w;
 
 	if (dest->w == dest->pitch) {
-		Common::copy(pSrc, pSrc + _filesize, (byte *)dest->getPixels());
+		res->_stream->read((byte *)dest->getPixels(), dest->w * dest->h);
 	} else {
-		byte *pCurr = pSrc;
-		for (int y = 0; y < dest->h; ++y, pCurr += dest->w) {
+		for (int y = 0; y < dest->h; ++y) {
 			byte *pDest = (byte *)dest->getBasePtr(0, y);
-			Common::copy(pCurr, pCurr + dest->w, pDest);
+			res->_stream->read(pDest, dest->w);
 		}
 	}
-	delete[] pSrc;
 }
 
 void FileManager::loadScreen(int fileNum, int subfile) {
@@ -132,69 +153,62 @@ void FileManager::loadScreen(int fileNum, int subfile) {
 }
 
 void FileManager::loadScreen(const Common::String &filename) {
-	// Open the file
-	openFile(filename);
-
-	// Get the palette
-	_vm->_screen->loadPalette(&_file);
-
-	// Get a stream for the remainder of the file
-	delete _stream;
-	_stream = _file.readStream(_file.size() - _file.pos());
-
-	// Get the data for the screen, and copy it over
-	byte *pSrc = handleFile();
-	Common::copy(pSrc, pSrc + _filesize, (byte *)_vm->_screen->getPixels());
-	delete[] pSrc;
+	Resource *res = loadFile(filename);
+	handleScreen(_vm->_screen, res);
+	delete res;
 }
 
-byte *FileManager::handleFile() {
+void FileManager::handleFile(Resource *res) {
 	char header[3];
-	_stream->read(&header[0], 3);
-	_stream->seek(-3, SEEK_CUR);
+	res->_stream->read(&header[0], 3);
+	res->_stream->seek(-3, SEEK_CUR);
 
 	bool isCompressed = !strncmp(header, "DBE", 3);
 
-	// Get the data from the file or resource
-	_filesize = _stream->size() - _stream->pos();
-	byte *data = new byte[_filesize];
-	_stream->read(data, _filesize);
-
-	// If the data is compressed, uncompress it
+	// If the data is compressed, uncompress it and replace the stream 
+	// in the resource with the decompressed one
 	if (isCompressed) {
-		byte *src = data;
-		_filesize = decompressDBE(src, &data);
+		// Read in the entire compressed data
+		byte *src = new byte[res->_size];
+		res->_stream->read(src, res->_size);
+
+		// Decompress the data
+		res->_size = decompressDBE(src, &res->_data);
+
+		// Replace the default resource stream with a stream for the decompressed data
+		delete res->_stream;
+		res->_file.close();
+		res->_stream = new Common::MemoryReadStream(res->_data, res->_size);
+
 		delete[] src;
 	}
-
-	return data;
 }
 
-void FileManager::setAppended(int fileNum) {
+void FileManager::setAppended(Resource *res, int fileNum) {
+	// Open the file for access
+	if (!res->_file.open(_filenames[fileNum]))
+		error("Could not open file %s", _filenames[fileNum]);
+
+	// If a different file has been opened then previously, load it's index
 	if (_fileNumber != fileNum) {
 		_fileNumber = fileNum;
-
-		_file.close();
-		if (!_file.open(_filenames[fileNum]))
-			error("Could not open file %s", _filenames[fileNum]);
-
+			
 		// Read in the file index
-		int count = _file.readUint16LE();
+		int count = res->_file.readUint16LE();
 		assert(count <= 100);
 		_fileIndex.resize(count);
 		for (int i = 0; i < count; ++i)
-			_fileIndex[i] = _file.readUint32LE();
+			_fileIndex[i] = res->_file.readUint32LE();
 	}
 }
 
-void FileManager::gotoAppended(int subfile) {
+void FileManager::gotoAppended(Resource *res, int subfile) {
 	uint32 offset = _fileIndex[subfile];
-	uint32 size = (subfile == (int)_fileIndex.size() - 1) ? _file.size() - offset :
+	uint32 size = (subfile == (int)_fileIndex.size() - 1) ? res->_file.size() - offset :
 		_fileIndex[subfile + 1] - offset;
 
-	_file.seek(offset);
-	delete _stream;
-	_stream = _file.readStream(size);
+	res->_size = size;
+	res->_stream = new Common::SeekableSubReadStream(&res->_file, offset, offset + size);
 }
 
 } // End of namespace Access
diff --git a/engines/access/files.h b/engines/access/files.h
index b13a796..457cb81 100644
--- a/engines/access/files.h
+++ b/engines/access/files.h
@@ -49,20 +49,51 @@ struct CellIdent : FileIdent {
 	CellIdent(int cell, int fileNum, int subfile);
 };
 
+class FileManager;
+
+class Resource {
+	friend class FileManager;
+private:
+	Common::File _file;
+	byte *_data;
+public:
+	Common::SeekableReadStream *_stream;
+	int _size;
+
+	Resource();
+	~Resource();
+	byte *data();
+};
+
 class FileManager {
 private:
 	AccessEngine *_vm;
 	const char * const *_filenames;
 
-	void openFile(const Common::String &filename);
+	void openFile(Resource *res, const Common::String &filename);
+
+	/**
+	 * Handles setting up the resource with a stream for the located resource
+	 */
+	void handleFile(Resource *res);
+	
+	/**
+	 * Handles loading a screen surface and palette with decoded resource
+	 */
+	void handleScreen(Graphics::Surface *dest, Resource *res);
+
+	/**
+	* Open up a sub-file container file
+	*/
+	void setAppended(Resource *file, int fileNum);
 
-	byte *handleFile();
+	/**
+	* Open up a sub-file resource within an alrady opened container file.
+	*/
+	void gotoAppended(Resource *file, int subfile);
 public:
 	int _fileNumber;
-	Common::File _file;
-	Common::SeekableReadStream *_stream;
 	Common::Array<uint32> _fileIndex;
-	uint32 _filesize;
 public:
 	FileManager(AccessEngine *vm);
 	~FileManager();
@@ -75,17 +106,17 @@ public:
 	/**
 	 * Load a given subfile from a container file
 	 */
-	byte *loadFile(int fileNum, int subfile);
+	Resource *loadFile(int fileNum, int subfile);
 
 	/**
 	 * Loads a resource specified by a file identifier
 	 */
-	byte *loadFile(FileIdent &fileIdent);
+	Resource *loadFile(FileIdent &fileIdent);
 
 	/**
 	 * Load a given file by name
 	 */
-	byte *loadFile(const Common::String &filename);
+	Resource *loadFile(const Common::String &filename);
 
 	/**
 	 * Load a given scren from a container file
@@ -101,16 +132,6 @@ public:
 	 * Load a screen resource onto a designated surface
 	 */
 	void loadScreen(Graphics::Surface *dest, int fileNum, int subfile);
-
-	/**
-	 * Open up a sub-file container file
-	 */
-	void setAppended(int fileNum);
-
-	/**
-	 * Open up a sub-file resource within an alrady opened container file.
-	 */
-	void gotoAppended(int subfile);
 };
 
 } // End of namespace Access
diff --git a/engines/access/martian/martian_game.cpp b/engines/access/martian/martian_game.cpp
index f087b56..969267f 100644
--- a/engines/access/martian/martian_game.cpp
+++ b/engines/access/martian/martian_game.cpp
@@ -106,9 +106,9 @@ void MartianEngine::doTitle() {
 	_screen->forceFadeIn();
 	_sound->playSound(1);
 
-	byte *spriteData = _files->loadFile(0, 2);
-	_objectsTable[0] = new SpriteResource(this, spriteData, _files->_filesize,
-		DisposeAfterUse::YES);
+	Resource *spriteData = _files->loadFile(0, 2);
+	_objectsTable[0] = new SpriteResource(this, spriteData);
+	delete spriteData;
 
 	_sound->playSound(1);
 
diff --git a/engines/access/martian/martian_room.cpp b/engines/access/martian/martian_room.cpp
index 80eaf59..52eead7 100644
--- a/engines/access/martian/martian_room.cpp
+++ b/engines/access/martian/martian_room.cpp
@@ -117,9 +117,9 @@ void MartianRoom::roomSet() {
 }
 
 void MartianRoom::roomMenu() {
-	byte *iconData = _vm->_files->loadFile("ICONS.LZ");
-	SpriteResource *spr = new SpriteResource(_vm, iconData, _vm->_files->_filesize);
-	delete[] iconData;
+	Resource *iconData = _vm->_files->loadFile("ICONS.LZ");
+	SpriteResource *spr = new SpriteResource(_vm, iconData);
+	delete iconData;
 
 	_vm->_screen->saveScreen();
 	_vm->_screen->setDisplayScan();
diff --git a/engines/access/player.cpp b/engines/access/player.cpp
index 336be0d..df2ad67 100644
--- a/engines/access/player.cpp
+++ b/engines/access/player.cpp
@@ -157,9 +157,9 @@ void Player::load() {
 void Player::loadSprites(const Common::String &name) {
 	freeSprites();
 
-	const byte *data = _vm->_files->loadFile(name);
-	_playerSprites1 = new SpriteResource(_vm, data, _vm->_files->_filesize,
-		DisposeAfterUse::YES);
+	Resource *data = _vm->_files->loadFile(name);
+	_playerSprites1 = new SpriteResource(_vm, data);
+	delete data;
 }
 
 void Player::freeSprites() {
diff --git a/engines/access/room.cpp b/engines/access/room.cpp
index 10146ff..0c60f7b 100644
--- a/engines/access/room.cpp
+++ b/engines/access/room.cpp
@@ -175,7 +175,6 @@ void Room::loadRoomData(const byte *roomData) {
 	_vm->_sound->freeMusic();
 	if (roomInfo._musicFile._fileNum != -1) {
 		_vm->_sound->_music = _vm->_files->loadFile(roomInfo._musicFile);
-		_vm->_sound->_midiSize = _vm->_files->_filesize;
 		_vm->_sound->midiPlay();
 		_vm->_sound->_musicRepeat = true;
 	}
@@ -199,15 +198,15 @@ void Room::loadRoomData(const byte *roomData) {
 	// Load script data
 	_vm->_scripts->freeScriptData();
 	if (roomInfo._scriptFile._fileNum != -1) {
-		const byte *data = _vm->_files->loadFile(roomInfo._scriptFile);
-		_vm->_scripts->setScript(data, _vm->_files->_filesize);
+		Resource *newScript = _vm->_files->loadFile(roomInfo._scriptFile);
+		_vm->_scripts->setScript(newScript);
 	}
 
 	// Load animation data
 	_vm->_animation->freeAnimationData();
 	if (roomInfo._animFile._fileNum != -1) {
-		byte *data = _vm->_files->loadFile(roomInfo._animFile);
-		_vm->_animation->loadAnimations(data, _vm->_files->_filesize);
+		Resource *anim = _vm->_files->loadFile(roomInfo._animFile);
+		_vm->_animation->loadAnimations(anim);
 	}
 
 	_vm->_scale = _vm->_scaleI = roomInfo._scaleI;
@@ -325,38 +324,39 @@ void Room::buildRow(int playY, int screenY) {
 }
 
 void Room::loadPlayField(int fileNum, int subfile) {
-	byte *playData = _vm->_files->loadFile(fileNum, subfile);
-	Common::MemoryReadStream stream(playData + 0x10, _vm->_files->_filesize - 0x10);
+	Resource *playData = _vm->_files->loadFile(fileNum, subfile);
+	byte header[16];
+	playData->_stream->read(&header[0], 16);
 	Screen &screen = *_vm->_screen;
 
 	// Copy the new palette
-	screen.loadRawPalette(&stream);
+	screen.loadRawPalette(playData->_stream);
 
 	// Copy off the tile data
-	_tileSize = playData[2] << 8;
+	_tileSize = (int)header[2] << 8;
 	_tile = new byte[_tileSize];
-	stream.read(_tile, _tileSize);
+	playData->_stream->read(_tile, _tileSize);
 
 	// Copy off the playfield data
-	_matrixSize = playData[0] * playData[1];
+	_matrixSize = header[0] * header[1];
 	_playField = new byte[_matrixSize];
-	stream.read(_playField, _matrixSize);
+	playData->_stream->read(_playField, _matrixSize);
 
 	// Load the plotter data
 	int numWalls = READ_LE_UINT16(playData + 6);
-	int numBlocks = playData[8];
-	_plotter.load(&stream, numWalls, numBlocks);
+	int numBlocks = header[8];
+	_plotter.load(playData->_stream, numWalls, numBlocks);
 
-	_playFieldWidth = playData[0];
-	_playFieldHeight = playData[1];
-	screen._vWindowWidth = playData[3];
+	_playFieldWidth = header[0];
+	_playFieldHeight = header[1];
+	screen._vWindowWidth = header[3];
 	screen._vWindowBytesWide = screen._vWindowWidth << 4;
 	screen._bufferBytesWide = screen._vWindowBytesWide + 16;
-	screen._vWindowHeight = playData[4];
+	screen._vWindowHeight = header[4];
 	screen._vWindowLinesTall = screen._vWindowHeight << 4;
 
 	_vm->_screen->setBufferScan();
-	delete[] playData;
+	delete playData;
 }
 
 /*------------------------------------------------------------------------*/
@@ -502,9 +502,9 @@ void Room::executeCommand(int commandId) {
 	_vm->_screen->setDisplayScan();
 
 	// Get the toolbar icons resource
-	byte *iconData = _vm->_files->loadFile("ICONS.LZ");
-	SpriteResource *spr = new SpriteResource(_vm, iconData, _vm->_files->_filesize);
-	delete[] iconData;
+	Resource *iconData = _vm->_files->loadFile("ICONS.LZ");
+	SpriteResource *spr = new SpriteResource(_vm, iconData);
+	delete iconData;
 
 	// Draw the button as selected
 	_vm->_screen->plotImage(spr, _selectCommand + 2, 
diff --git a/engines/access/screen.cpp b/engines/access/screen.cpp
index 4f2ee3e..4b1c6d8 100644
--- a/engines/access/screen.cpp
+++ b/engines/access/screen.cpp
@@ -104,9 +104,10 @@ void Screen::loadPalette(Common::SeekableReadStream *stream) {
 }
 
 void Screen::loadPalette(int fileNum, int subfile) {
-	byte *palette = _vm->_files->loadFile(fileNum, subfile);
+	Resource *res = _vm->_files->loadFile(fileNum, subfile);
+	byte *palette = res->data();
 	Common::copy(palette, palette + (_numColors * 3), &_rawPalette[_startColor * 3]);
-	delete[] palette;
+	delete res;
 }
 
 void Screen::setPalette() {
diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp
index 833aff3..5e0986e 100644
--- a/engines/access/scripts.cpp
+++ b/engines/access/scripts.cpp
@@ -30,7 +30,7 @@
 namespace Access {
 
 Scripts::Scripts(AccessEngine *vm) : Manager(vm) {
-	_rawData = nullptr;
+	_resource = nullptr;
 	_data = nullptr;
 	_sequence = 0;
 	_endFlag = false;
@@ -45,16 +45,15 @@ Scripts::~Scripts() {
 	freeScriptData();
 }
 
-void Scripts::setScript(const byte *data, int size) {
-	_rawData = data;
-	_data = new Common::MemoryReadStream(data, size, DisposeAfterUse::NO);
+void Scripts::setScript(Resource *res) {
+	_resource = res;
+	_data = res->_stream;
 }
 
 void Scripts::freeScriptData() {
-	delete[] _rawData;
-	delete _data;
+	delete _resource;
+	_resource = nullptr;
 	_data = nullptr;
-	_rawData = nullptr;
 }
 
 void Scripts::searchForSequence() {
@@ -418,13 +417,13 @@ void Scripts::cmdSetTravel() {
 }
 
 void Scripts::cmdSetVideo() { 
-	FileIdent fi;
-	fi._fileNum = _data->readSint16LE();
-	fi._subfile = _data->readUint16LE();
+	Common::Point pt;
+	pt.x = _data->readSint16LE();
+	pt.y = _data->readSint16LE();
 	int cellIndex = _data->readUint16LE();
 	int rate = _data->readUint16LE();
 
-	_vm->_video->setVideo(_vm->_extraCells[cellIndex]._vid, fi, rate);
+	_vm->_video->setVideo(_vm->_screen, pt, _vm->_extraCells[cellIndex]._vid, rate);
 }
 
 void Scripts::CMDPLAYVID() { error("TODO CMDPLAYVID"); }
@@ -654,7 +653,7 @@ void Scripts::cmdClearBlock() {
 
 void Scripts::cmdLoadSound() {
 	int idx = _data->readSint16LE();
-	_vm->_sound->_soundTable[0]._data = _vm->_files->loadFile(_vm->_extraCells[idx]._vidSound);
+	_vm->_sound->_soundTable[0] = _vm->_files->loadFile(_vm->_extraCells[idx]._vidSound);
 	_vm->_sound->_soundPriority[0] = 1;
 }
 
diff --git a/engines/access/scripts.h b/engines/access/scripts.h
index aa5c406..ec386cf 100644
--- a/engines/access/scripts.h
+++ b/engines/access/scripts.h
@@ -34,11 +34,11 @@ class Scripts;
 
 class Scripts: public Manager {
 private:
-	const byte *_rawData;
+	Resource *_resource;
 	int _specialFunction;
 
 protected:
-	Common::MemoryReadStream *_data;
+	Common::SeekableReadStream *_data;
 
 	virtual void executeSpecial(int commandIndex, int param1, int param2) = 0;
 	virtual void executeCommand(int commandIndex);
@@ -134,7 +134,7 @@ public:
 
 	virtual ~Scripts();
 
-	void setScript(const byte *data, int size);
+	void setScript(Resource *data);
 
 	void freeScriptData();
 
diff --git a/engines/access/sound.cpp b/engines/access/sound.cpp
index aebd76f..c032f6c 100644
--- a/engines/access/sound.cpp
+++ b/engines/access/sound.cpp
@@ -31,10 +31,9 @@ SoundManager::SoundManager(AccessEngine *vm, Audio::Mixer *mixer) :
 		_vm(vm), _mixer(mixer) {
 	Common::fill(&_soundPriority[0], &_soundPriority[MAX_SOUNDS], 0);
 	for (int i = 0; i < MAX_SOUNDS; ++i)
-		_soundTable[i]._data = nullptr;
+		_soundTable[i] = nullptr;
 
 	_music = nullptr;
-	_midiSize = 0;
 	_musicRepeat = false;
 	_soundFrame = 0;
 	_soundFlag = false;
@@ -42,7 +41,7 @@ SoundManager::SoundManager(AccessEngine *vm, Audio::Mixer *mixer) :
 
 SoundManager::~SoundManager() {
 	for (int i = 0; i < MAX_SOUNDS; ++i)
-		delete _soundTable[i]._data;
+		delete _soundTable[i];
 }
 
 void SoundManager::queueSound(int idx, int fileNum, int subfile) {
@@ -52,13 +51,13 @@ void SoundManager::queueSound(int idx, int fileNum, int subfile) {
 	*/
 }
 
-byte *SoundManager::loadSound(int fileNum, int subfile) {
+Resource *SoundManager::loadSound(int fileNum, int subfile) {
 	return _vm->_files->loadFile(fileNum, subfile);
 }
 
 void SoundManager::playSound(int soundIndex) {
 	int idx = _soundPriority[soundIndex - 1] - 1;
-	playSound(_soundTable[idx]._data, _soundTable[idx]._size);
+	playSound(_soundTable[idx]->data(), _soundTable[idx]->_size);
 }
 
 void SoundManager::playSound(byte *data, uint32 size) {
diff --git a/engines/access/sound.h b/engines/access/sound.h
index e0992db..284fa84 100644
--- a/engines/access/sound.h
+++ b/engines/access/sound.h
@@ -25,6 +25,7 @@
 
 #include "common/scummsys.h"
 #include "audio/mixer.h"
+#include "access/files.h"
 
 #define MAX_SOUNDS 20
 
@@ -33,10 +34,6 @@ namespace Access {
 class AccessEngine;
 
 class SoundManager {
-	struct SoundEntry {
-		byte *_data;
-		uint32 _size;
-	};
 private:
 	AccessEngine *_vm;
 	Audio::Mixer *_mixer;
@@ -44,10 +41,9 @@ private:
 
 	void playSound(byte *data, uint32 size);
 public:
-	SoundEntry _soundTable[MAX_SOUNDS];
+	Resource *_soundTable[MAX_SOUNDS];
 	int _soundPriority[MAX_SOUNDS];
-	byte *_music;
-	int _midiSize;
+	Resource *_music;
 	bool _musicRepeat;
 	int _soundFrame;
 	bool _soundFlag;
@@ -59,7 +55,7 @@ public:
 
 	void playSound(int soundIndex);
 
-	byte *loadSound(int fileNum, int subfile);
+	Resource *loadSound(int fileNum, int subfile);
 	void loadSounds(Common::Array<RoomInfo::SoundIdent> &sounds);
 
 	void midiPlay();
diff --git a/engines/access/video.cpp b/engines/access/video.cpp
index a025d31..4774703 100644
--- a/engines/access/video.cpp
+++ b/engines/access/video.cpp
@@ -21,15 +21,37 @@
  */
 
 #include "access/video.h"
+#include "access/access.h"
 
 namespace Access {
 
 VideoPlayer::VideoPlayer(AccessEngine *vm) : Manager(vm) {
+	_vidSurface = nullptr;
+}
 
+VideoPlayer::~VideoPlayer() {
+	freeVideo();
 }
 
-void VideoPlayer::setVideo(FileIdent &fi1, FileIdent &fi2, int rate) {
-	error("TODO: setVideo");
+
+void VideoPlayer::setVideo(ASurface *vidSurface, const Common::Point &pt, FileIdent &videoFile, int rate) {
+	_vidSurface = vidSurface;
+	vidSurface->_orgX1 = pt.x;
+	vidSurface->_orgY1 = pt.y;
+	_vm->_timers[31]._timer = rate;
+	_vm->_timers[31]._initTm = rate;
+
+	// Open up video stream
+	_videoData = _vm->_files->loadFile(videoFile);
+
+	// Load in header
+	
 }
 
+void VideoPlayer::freeVideo() {
+	delete _videoData;
+	_videoData = nullptr;
+}
+
+
 } // End of namespace Access
diff --git a/engines/access/video.h b/engines/access/video.h
index b21f006..a87c90c 100644
--- a/engines/access/video.h
+++ b/engines/access/video.h
@@ -24,16 +24,27 @@
 #define ACCESS_VIDEO_H
 
 #include "common/scummsys.h"
+#include "common/memstream.h"
 #include "access/data.h"
+#include "access/asurface.h"
 #include "access/files.h"
 
 namespace Access {
 
 class VideoPlayer: public Manager {
+private:
+	ASurface *_vidSurface;
+	Resource *_videoData;
+	int _frameCount;
+	int _width, _height;
+	int _flags;
 public:
 	VideoPlayer(AccessEngine *vm);
+	~VideoPlayer();
 
-	void setVideo(FileIdent &fi1, FileIdent &fi2, int rate);
+	void setVideo(ASurface *vidSurface, const Common::Point &pt, FileIdent &videoFile, int rate);
+
+	void freeVideo();
 };
 
 } // End of namespace Access


Commit: 35923890ccb26d958d33c6c472a1b16659718392
    https://github.com/scummvm/scummvm/commit/35923890ccb26d958d33c6c472a1b16659718392
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-27T22:22:33-04:00

Commit Message:
ACCESS: Fix incorrect use of delete[] on Resources

Changed paths:
    engines/access/access.cpp
    engines/access/room.cpp
    engines/access/sound.cpp



diff --git a/engines/access/access.cpp b/engines/access/access.cpp
index 080cd36..7189ebb 100644
--- a/engines/access/access.cpp
+++ b/engines/access/access.cpp
@@ -226,7 +226,7 @@ void AccessEngine::freeCells() {
 }
 
 void AccessEngine::freeInactiveData() {
-	delete[] _inactive;
+	delete _inactive;
 	_inactive = nullptr;
 }
 
diff --git a/engines/access/room.cpp b/engines/access/room.cpp
index 0c60f7b..0de6497 100644
--- a/engines/access/room.cpp
+++ b/engines/access/room.cpp
@@ -143,7 +143,7 @@ void Room::doRoom() {
 void Room::clearRoom() {
 	if (_vm->_sound->_music) {
 		_vm->_sound->stopSong();
-		delete[] _vm->_sound->_music;
+		delete _vm->_sound->_music;
 		_vm->_sound->_music = nullptr;
 	}
 
diff --git a/engines/access/sound.cpp b/engines/access/sound.cpp
index c032f6c..bdf8c22 100644
--- a/engines/access/sound.cpp
+++ b/engines/access/sound.cpp
@@ -90,7 +90,7 @@ void SoundManager::freeSounds() {
 }
 
 void SoundManager::freeMusic() {
-	delete[] _music;
+	delete _music;
 	_music = nullptr;
 }
 


Commit: 3bbec487a53243464030fe1946f833971d6e14c0
    https://github.com/scummvm/scummvm/commit/3bbec487a53243464030fe1946f833971d6e14c0
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-27T22:34:50-04:00

Commit Message:
ACCESS: Fixes for memory leaks

Changed paths:
    engines/access/files.cpp
    engines/access/files.h
    engines/access/room.cpp



diff --git a/engines/access/files.cpp b/engines/access/files.cpp
index 78cb3ef..233d040 100644
--- a/engines/access/files.cpp
+++ b/engines/access/files.cpp
@@ -51,9 +51,11 @@ CellIdent::CellIdent(int cell, int fileNum, int subfile) {
 Resource::Resource() {
 	_stream = nullptr;
 	_size = 0;
+	_data = nullptr;
 }
 
 Resource::~Resource() {
+	delete _data;
 	delete _stream;
 }
 
diff --git a/engines/access/files.h b/engines/access/files.h
index 457cb81..0a934de 100644
--- a/engines/access/files.h
+++ b/engines/access/files.h
@@ -101,7 +101,7 @@ public:
 	/**
 	 * Check the existence of a given file
 	 */
-	bool FileManager::existFile(const Common::String &filename);
+	bool existFile(const Common::String &filename);
 
 	/**
 	 * Load a given subfile from a container file
diff --git a/engines/access/room.cpp b/engines/access/room.cpp
index 0de6497..a33bc76 100644
--- a/engines/access/room.cpp
+++ b/engines/access/room.cpp
@@ -207,6 +207,7 @@ void Room::loadRoomData(const byte *roomData) {
 	if (roomInfo._animFile._fileNum != -1) {
 		Resource *anim = _vm->_files->loadFile(roomInfo._animFile);
 		_vm->_animation->loadAnimations(anim);
+		delete anim;
 	}
 
 	_vm->_scale = _vm->_scaleI = roomInfo._scaleI;


Commit: 5abe5b89932adfcc705beb7529d323aa15a85bbd
    https://github.com/scummvm/scummvm/commit/5abe5b89932adfcc705beb7529d323aa15a85bbd
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-27T22:39:37-04:00

Commit Message:
ACCESS: Fix loading of room playfield data

Changed paths:
    engines/access/room.cpp



diff --git a/engines/access/room.cpp b/engines/access/room.cpp
index a33bc76..b9a07ea 100644
--- a/engines/access/room.cpp
+++ b/engines/access/room.cpp
@@ -344,7 +344,7 @@ void Room::loadPlayField(int fileNum, int subfile) {
 	playData->_stream->read(_playField, _matrixSize);
 
 	// Load the plotter data
-	int numWalls = READ_LE_UINT16(playData + 6);
+	int numWalls = READ_LE_UINT16(&header[6]);
 	int numBlocks = header[8];
 	_plotter.load(playData->_stream, numWalls, numBlocks);
 


Commit: 819cad3a179260d0b0a973342765a0caff4b13b4
    https://github.com/scummvm/scummvm/commit/819cad3a179260d0b0a973342765a0caff4b13b4
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-28T07:36:11-04:00

Commit Message:
ACCESS: Implemented setVideo

Changed paths:
    engines/access/access.cpp
    engines/access/access.h
    engines/access/video.cpp
    engines/access/video.h



diff --git a/engines/access/access.cpp b/engines/access/access.cpp
index 7189ebb..92ded4f 100644
--- a/engines/access/access.cpp
+++ b/engines/access/access.cpp
@@ -71,6 +71,7 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc)
 	_scaleI = 0;
 	_scaleFlag = false;
 	_eseg = nullptr;
+	_plotBuffer = nullptr;
 
 	_conversation = 0;
 	_currentMan = 0;
@@ -128,6 +129,8 @@ AccessEngine::~AccessEngine() {
 	delete _inactive;
 	delete _music;
 	delete _title;
+	delete _eseg;
+	delete _plotBuffer;
 }
 
 void AccessEngine::setVGA() {
diff --git a/engines/access/access.h b/engines/access/access.h
index 55810e8..8e05da7 100644
--- a/engines/access/access.h
+++ b/engines/access/access.h
@@ -129,6 +129,7 @@ public:
 	ASurface *_current;
 	ASurface _buffer1;
 	ASurface _buffer2;
+	byte *_plotBuffer;
 	Common::Array<CharEntry *> _charTable;
 	SpriteResource *_objectsTable[100];
 	bool _establishTable[100];
diff --git a/engines/access/video.cpp b/engines/access/video.cpp
index 4774703..da397a4 100644
--- a/engines/access/video.cpp
+++ b/engines/access/video.cpp
@@ -45,7 +45,37 @@ void VideoPlayer::setVideo(ASurface *vidSurface, const Common::Point &pt, FileId
 	_videoData = _vm->_files->loadFile(videoFile);
 
 	// Load in header
+	_frameCount = _videoData->_stream->readUint16LE();
+	_header._width = _videoData->_stream->readUint16LE();
+	_header._height = _videoData->_stream->readUint16LE();
+	_videoData->_stream->skip(1);
+	_header._flags = (VideoFlags)_videoData->_stream->readByte();
 	
+	_startCoord = (byte *)vidSurface->getBasePtr(pt.x, pt.y);
+	_frameCount = _header._frameCount - 2;
+	_xCount = _header._width;
+	_scanCount = _header._height;
+	_vidFrame = 0;
+
+	getFrame();
+
+	if (_header._flags == VIDEOFLAG_BG) {
+		// Draw the background
+		const byte *pSrc = _vm->_plotBuffer;
+		for (int y = 0; y < _scanCount; ++y) {
+			byte *pDest = (byte *)vidSurface->getBasePtr(pt.x, pt.y + y);
+			Common::copy(pSrc, pSrc + _xCount, pDest);
+			pSrc += _xCount;
+		}
+
+		if (vidSurface == _vm->_screen)
+			_vm->_newRects.push_back(Common::Rect(pt.x, pt.y, pt.x + _xCount, pt.y + _scanCount));
+	
+	
+		getFrame();
+	}
+
+	_videoEnd = false;
 }
 
 void VideoPlayer::freeVideo() {
@@ -53,5 +83,18 @@ void VideoPlayer::freeVideo() {
 	_videoData = nullptr;
 }
 
+void VideoPlayer::getFrame() {
+	_frameSize = _videoData->_stream->readUint16LE();
+	_videoData->_stream->read(_vm->_plotBuffer, _frameSize);
+}
+
+void VideoPlayer::playVideo() {
+	if (_vm->_timers[31]._flag)
+		return;
+	++_vm->_timers[31]._flag;
+
+
+}
+
 
 } // End of namespace Access
diff --git a/engines/access/video.h b/engines/access/video.h
index a87c90c..7fa1ad2 100644
--- a/engines/access/video.h
+++ b/engines/access/video.h
@@ -31,13 +31,29 @@
 
 namespace Access {
 
+enum VideoFlags { VIDEOFLAG_NONE = 0, VIDEOFLAG_BG = 1 };
+
 class VideoPlayer: public Manager {
+	struct VideoHeader {
+		int _frameCount;
+		int _width, _height;
+		VideoFlags _flags;
+	};
 private:
 	ASurface *_vidSurface;
 	Resource *_videoData;
+	VideoHeader _header;
+	byte *_startCoord;
 	int _frameCount;
-	int _width, _height;
-	int _flags;
+	int _xCount;
+	int _scanCount;
+	int _vidFrame;
+	int _frameSize;
+	bool _videoEnd;
+
+	void getFrame();
+
+	void playVideo();
 public:
 	VideoPlayer(AccessEngine *vm);
 	~VideoPlayer();


Commit: e57d7e8782e1be66a23166b04d6bec658ed2be80
    https://github.com/scummvm/scummvm/commit/e57d7e8782e1be66a23166b04d6bec658ed2be80
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-28T20:02:35-04:00

Commit Message:
ACCESS: Implemented playVideo

Changed paths:
    engines/access/access.cpp
    engines/access/access.h
    engines/access/scripts.cpp
    engines/access/scripts.h
    engines/access/sound.cpp
    engines/access/sound.h
    engines/access/video.cpp
    engines/access/video.h



diff --git a/engines/access/access.cpp b/engines/access/access.cpp
index 92ded4f..e02b0c0 100644
--- a/engines/access/access.cpp
+++ b/engines/access/access.cpp
@@ -71,7 +71,6 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc)
 	_scaleI = 0;
 	_scaleFlag = false;
 	_eseg = nullptr;
-	_plotBuffer = nullptr;
 
 	_conversation = 0;
 	_currentMan = 0;
@@ -130,7 +129,6 @@ AccessEngine::~AccessEngine() {
 	delete _music;
 	delete _title;
 	delete _eseg;
-	delete _plotBuffer;
 }
 
 void AccessEngine::setVGA() {
diff --git a/engines/access/access.h b/engines/access/access.h
index 8e05da7..55810e8 100644
--- a/engines/access/access.h
+++ b/engines/access/access.h
@@ -129,7 +129,6 @@ public:
 	ASurface *_current;
 	ASurface _buffer1;
 	ASurface _buffer2;
-	byte *_plotBuffer;
 	Common::Array<CharEntry *> _charTable;
 	SpriteResource *_objectsTable[100];
 	bool _establishTable[100];
diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp
index 5e0986e..2d6fc50 100644
--- a/engines/access/scripts.cpp
+++ b/engines/access/scripts.cpp
@@ -103,7 +103,7 @@ void Scripts::executeCommand(int commandIndex) {
 		&Scripts::cmdRetNeg, &Scripts::cmdRetPos, &Scripts::cmdCheckLoc, 
 		&Scripts::cmdSetAnim, &Scripts::cmdDispInv, &Scripts::cmdSetTimer, 
 		&Scripts::cmdSetTimer, &Scripts::cmdCheckTimer, &Scripts::cmdSetTravel,
-		&Scripts::cmdSetTravel, &Scripts::cmdSetVideo, &Scripts::CMDPLAYVID, 
+		&Scripts::cmdSetTravel, &Scripts::cmdSetVideo, &Scripts::cmdPlayVideo, 
 		&Scripts::cmdPlotImage, &Scripts::cmdSetDisplay, &Scripts::cmdSetBuffer, 
 		&Scripts::cmdSetScroll, &Scripts::CMDSAVERECT, &Scripts::CMDSAVERECT, 
 		&Scripts::CMDSETBUFVID, &Scripts::CMDPLAYBUFVID, &Scripts::cmdRemoveLast, 
@@ -112,7 +112,7 @@ void Scripts::executeCommand(int commandIndex) {
 		&Scripts::cmdTexSpeak, &Scripts::cmdTexChoice, &Scripts::CMDWAIT, 
 		&Scripts::cmdSetConPos, &Scripts::CMDCHECKVFRAME, &Scripts::cmdJumpChoice, 
 		&Scripts::cmdReturnChoice, &Scripts::cmdClearBlock, &Scripts::cmdLoadSound, 
-		&Scripts::CMDFREESOUND, &Scripts::cmdSetVideoSound, &Scripts::CMDPLAYVIDSND,
+		&Scripts::CMDFREESOUND, &Scripts::cmdSetVideoSound, &Scripts::cmdPlayVideoSound,
 		&Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, 
 		&Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, &Scripts::cmdPlayerOff, 
 		&Scripts::cmdPlayerOn, &Scripts::CMDDEAD, &Scripts::cmdFadeOut,
@@ -426,7 +426,9 @@ void Scripts::cmdSetVideo() {
 	_vm->_video->setVideo(_vm->_screen, pt, _vm->_extraCells[cellIndex]._vid, rate);
 }
 
-void Scripts::CMDPLAYVID() { error("TODO CMDPLAYVID"); }
+void Scripts::cmdPlayVideo() { 
+	_vm->_video->playVideo();
+}
 
 void Scripts::cmdPlotImage() {
 	_vm->_destIn = _vm->_current;
@@ -667,11 +669,19 @@ void Scripts::cmdSetVideoSound() {
 	cmdSetVideo();
 
 	_data->skip(2);
-	_vm->_sound->_soundFrame = _data->readUint16LE();
-	_vm->_sound->_soundFlag = false;
+	_vm->_video->_soundFrame = _data->readUint16LE();
+	_vm->_video->_soundFlag = false;
+}
+
+void Scripts::cmdPlayVideoSound() { 
+	_vm->_video->playVideo();
+	if (_vm->_video->_soundFrame == _vm->_video->_videoFrame &&
+			!_vm->_video->_soundFlag) {
+		_vm->_sound->playSound(0);
+		_vm->_video->_soundFlag = true;
+	}
 }
 
-void Scripts::CMDPLAYVIDSND() { error("TODO CMDPLAYVIDSND"); }
 void Scripts::CMDPUSHLOCATION() { error("TODO CMDPUSHLOCATION"); }
 
 void Scripts::cmdPlayerOff() {
diff --git a/engines/access/scripts.h b/engines/access/scripts.h
index ec386cf..414ba46 100644
--- a/engines/access/scripts.h
+++ b/engines/access/scripts.h
@@ -91,7 +91,7 @@ protected:
 	void cmdCheckTimer();
 	void cmdSetTravel();
 	void cmdSetVideo();
-	void CMDPLAYVID();
+	void cmdPlayVideo();
 	void cmdPlotImage();
 	void cmdSetDisplay();
 	void cmdSetBuffer();
@@ -114,7 +114,7 @@ protected:
 	void cmdClearBlock();
 	void cmdLoadSound();
 	void cmdSetVideoSound();
-	void CMDPLAYVIDSND();
+	void cmdPlayVideoSound();
 	void CMDPUSHLOCATION();
 	void cmdPlayerOff();
 	void cmdPlayerOn();
diff --git a/engines/access/sound.cpp b/engines/access/sound.cpp
index bdf8c22..2b8e6a7 100644
--- a/engines/access/sound.cpp
+++ b/engines/access/sound.cpp
@@ -35,8 +35,6 @@ SoundManager::SoundManager(AccessEngine *vm, Audio::Mixer *mixer) :
 
 	_music = nullptr;
 	_musicRepeat = false;
-	_soundFrame = 0;
-	_soundFlag = false;
 }
 
 SoundManager::~SoundManager() {
diff --git a/engines/access/sound.h b/engines/access/sound.h
index 284fa84..a534eac 100644
--- a/engines/access/sound.h
+++ b/engines/access/sound.h
@@ -45,8 +45,6 @@ public:
 	int _soundPriority[MAX_SOUNDS];
 	Resource *_music;
 	bool _musicRepeat;
-	int _soundFrame;
-	bool _soundFlag;
 public:
 	SoundManager(AccessEngine *vm, Audio::Mixer *mixer);
 	~SoundManager();
diff --git a/engines/access/video.cpp b/engines/access/video.cpp
index da397a4..4c380ff 100644
--- a/engines/access/video.cpp
+++ b/engines/access/video.cpp
@@ -27,10 +27,13 @@ namespace Access {
 
 VideoPlayer::VideoPlayer(AccessEngine *vm) : Manager(vm) {
 	_vidSurface = nullptr;
+	_videoFrame = 0;
+	_soundFlag = false;
+	_soundFrame = 0;
 }
 
 VideoPlayer::~VideoPlayer() {
-	freeVideo();
+	closeVideo();
 }
 
 
@@ -55,37 +58,33 @@ void VideoPlayer::setVideo(ASurface *vidSurface, const Common::Point &pt, FileId
 	_frameCount = _header._frameCount - 2;
 	_xCount = _header._width;
 	_scanCount = _header._height;
-	_vidFrame = 0;
+	_videoFrame = 0;
 
 	getFrame();
 
 	if (_header._flags == VIDEOFLAG_BG) {
 		// Draw the background
-		const byte *pSrc = _vm->_plotBuffer;
 		for (int y = 0; y < _scanCount; ++y) {
 			byte *pDest = (byte *)vidSurface->getBasePtr(pt.x, pt.y + y);
-			Common::copy(pSrc, pSrc + _xCount, pDest);
-			pSrc += _xCount;
+			_videoData->_stream->read(pDest, _xCount);
 		}
 
 		if (vidSurface == _vm->_screen)
 			_vm->_newRects.push_back(Common::Rect(pt.x, pt.y, pt.x + _xCount, pt.y + _scanCount));
-	
-	
+		
 		getFrame();
 	}
 
 	_videoEnd = false;
 }
 
-void VideoPlayer::freeVideo() {
+void VideoPlayer::closeVideo() {
 	delete _videoData;
 	_videoData = nullptr;
 }
 
 void VideoPlayer::getFrame() {
 	_frameSize = _videoData->_stream->readUint16LE();
-	_videoData->_stream->read(_vm->_plotBuffer, _frameSize);
 }
 
 void VideoPlayer::playVideo() {
@@ -93,7 +92,39 @@ void VideoPlayer::playVideo() {
 		return;
 	++_vm->_timers[31]._flag;
 
+	byte *pDest = _startCoord;
+	byte *pLine = _startCoord;
+	uint32 frameEnd = _videoData->_stream->pos() + _frameSize;
+
+	while ((uint32)_videoData->_stream->pos() < frameEnd) {
+		int count = _videoData->_stream->readByte();
+
+		if (count & 0x80) {
+			count &= 0x7f;
+
+			// Skip count number of pixels
+			// Loop across lines if necessary
+			while ((pDest - pLine + count) >= _xCount) {
+				pLine += _vidSurface->pitch;
+				pDest = pLine;
+				count -= _xCount;
+			}
+
+			// Skip any remaining pixels in the new line
+			pDest += count;
+		} else {
+			// Readcount number of pixels
+			assert(count <= (pDest - pLine));
+			_videoData->_stream->read(pDest, count);
+			pDest += count;
+		}
+	}
 
+	getFrame();
+	if (++_videoFrame == _frameCount) {
+		closeVideo();
+		_videoEnd = true;
+	}
 }
 
 
diff --git a/engines/access/video.h b/engines/access/video.h
index 7fa1ad2..20e5cfc 100644
--- a/engines/access/video.h
+++ b/engines/access/video.h
@@ -47,20 +47,32 @@ private:
 	int _frameCount;
 	int _xCount;
 	int _scanCount;
-	int _vidFrame;
 	int _frameSize;
 	bool _videoEnd;
 
 	void getFrame();
-
-	void playVideo();
+public:
+	int _videoFrame;
+	bool _soundFlag;
+	int _soundFrame;
 public:
 	VideoPlayer(AccessEngine *vm);
 	~VideoPlayer();
 
+	/**
+	 * Start up a video
+	 */
 	void setVideo(ASurface *vidSurface, const Common::Point &pt, FileIdent &videoFile, int rate);
 
-	void freeVideo();
+	/**
+	 * Decodes a frame of the video
+	 */
+	void playVideo();
+
+	/**
+	 * Frees the data for a previously loaded video
+	 */
+	void closeVideo();
 };
 
 } // End of namespace Access


Commit: 1d8f23985aa8eaf718388ba3d6ccae5824a530aa
    https://github.com/scummvm/scummvm/commit/1d8f23985aa8eaf718388ba3d6ccae5824a530aa
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-28T20:24:25-04:00

Commit Message:
ACCESS: Implement loadSounds

Changed paths:
    engines/access/sound.cpp
    engines/access/sound.h
    engines/access/video.cpp



diff --git a/engines/access/sound.cpp b/engines/access/sound.cpp
index 2b8e6a7..d932cc6 100644
--- a/engines/access/sound.cpp
+++ b/engines/access/sound.cpp
@@ -29,24 +29,24 @@ namespace Access {
 
 SoundManager::SoundManager(AccessEngine *vm, Audio::Mixer *mixer) : 
 		_vm(vm), _mixer(mixer) {
-	Common::fill(&_soundPriority[0], &_soundPriority[MAX_SOUNDS], 0);
-	for (int i = 0; i < MAX_SOUNDS; ++i)
-		_soundTable[i] = nullptr;
-
 	_music = nullptr;
 	_musicRepeat = false;
 }
 
 SoundManager::~SoundManager() {
-	for (int i = 0; i < MAX_SOUNDS; ++i)
+	clearSounds();
+}
+
+void SoundManager::clearSounds() {
+	for (int i = 0; i < _soundTable.size(); ++i)
 		delete _soundTable[i];
+	_soundTable.clear();
+	_soundPriority.clear();
 }
 
 void SoundManager::queueSound(int idx, int fileNum, int subfile) {
-	/*
-	_soundTable[idx]._data = _vm->_files->loadFile(fileNum, subfile);
-	_soundTable[idx]._size = _vm->_files->_filesize;
-	*/
+	delete _soundTable[idx];
+	_soundTable[idx] = _vm->_files->loadFile(fileNum, subfile);
 }
 
 Resource *SoundManager::loadSound(int fileNum, int subfile) {
@@ -54,11 +54,11 @@ Resource *SoundManager::loadSound(int fileNum, int subfile) {
 }
 
 void SoundManager::playSound(int soundIndex) {
-	int idx = _soundPriority[soundIndex - 1] - 1;
-	playSound(_soundTable[idx]->data(), _soundTable[idx]->_size);
+	int idx = _soundPriority[soundIndex];
+	playSound(_soundTable[idx]);
 }
 
-void SoundManager::playSound(byte *data, uint32 size) {
+void SoundManager::playSound(Resource *res) {
 	/*
 	Audio::QueuingAudioStream *audioStream = Audio::makeQueuingAudioStream(22050, false);
 	audioStream->queueBuffer(data, size, DisposeAfterUse::YES, 0);
@@ -68,7 +68,12 @@ void SoundManager::playSound(byte *data, uint32 size) {
 }
 
 void SoundManager::loadSounds(Common::Array<RoomInfo::SoundIdent> &sounds) {
-	// TODO
+	clearSounds();
+
+	for (uint i = 0; i < sounds.size(); ++i) {
+		_soundTable.push_back(loadSound(sounds[i]._fileNum, sounds[i]._subfile));
+		_soundPriority.push_back(sounds[i]._priority);
+	}
 }
 
 void SoundManager::midiPlay() {
diff --git a/engines/access/sound.h b/engines/access/sound.h
index a534eac..8fef9e3 100644
--- a/engines/access/sound.h
+++ b/engines/access/sound.h
@@ -39,10 +39,12 @@ private:
 	Audio::Mixer *_mixer;
 	Audio::SoundHandle _soundHandle;
 
-	void playSound(byte *data, uint32 size);
+	void clearSounds();
+
+	void playSound(Resource *res);
 public:
-	Resource *_soundTable[MAX_SOUNDS];
-	int _soundPriority[MAX_SOUNDS];
+	Common::Array<Resource *> _soundTable;
+	Common::Array<int> _soundPriority;
 	Resource *_music;
 	bool _musicRepeat;
 public:
diff --git a/engines/access/video.cpp b/engines/access/video.cpp
index 4c380ff..8197b91 100644
--- a/engines/access/video.cpp
+++ b/engines/access/video.cpp
@@ -30,6 +30,7 @@ VideoPlayer::VideoPlayer(AccessEngine *vm) : Manager(vm) {
 	_videoFrame = 0;
 	_soundFlag = false;
 	_soundFrame = 0;
+	_videoData = nullptr;
 }
 
 VideoPlayer::~VideoPlayer() {


Commit: 729f03f42c88f2caaa6616e530cf4543a6cca536
    https://github.com/scummvm/scummvm/commit/729f03f42c88f2caaa6616e530cf4543a6cca536
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-28T21:36:48-04:00

Commit Message:
ACCESS: Fixes for playVideo

Changed paths:
    engines/access/scripts.cpp
    engines/access/video.cpp



diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp
index 2d6fc50..f92a6d7 100644
--- a/engines/access/scripts.cpp
+++ b/engines/access/scripts.cpp
@@ -668,7 +668,6 @@ void Scripts::cmdSetVideoSound() {
 	_data->seek(startPos);
 	cmdSetVideo();
 
-	_data->skip(2);
 	_vm->_video->_soundFrame = _data->readUint16LE();
 	_vm->_video->_soundFlag = false;
 }
diff --git a/engines/access/video.cpp b/engines/access/video.cpp
index 8197b91..4b9a875 100644
--- a/engines/access/video.cpp
+++ b/engines/access/video.cpp
@@ -49,7 +49,7 @@ void VideoPlayer::setVideo(ASurface *vidSurface, const Common::Point &pt, FileId
 	_videoData = _vm->_files->loadFile(videoFile);
 
 	// Load in header
-	_frameCount = _videoData->_stream->readUint16LE();
+	_header._frameCount = _videoData->_stream->readUint16LE();
 	_header._width = _videoData->_stream->readUint16LE();
 	_header._height = _videoData->_stream->readUint16LE();
 	_videoData->_stream->skip(1);
@@ -105,19 +105,31 @@ void VideoPlayer::playVideo() {
 
 			// Skip count number of pixels
 			// Loop across lines if necessary
-			while ((pDest - pLine + count) >= _xCount) {
+			while (count >= (pLine + _xCount - pDest)) {
+				count -= (pLine + _xCount - pDest);
 				pLine += _vidSurface->pitch;
 				pDest = pLine;
-				count -= _xCount;
 			}
 
 			// Skip any remaining pixels in the new line
 			pDest += count;
 		} else {
-			// Readcount number of pixels
-			assert(count <= (pDest - pLine));
-			_videoData->_stream->read(pDest, count);
-			pDest += count;
+			// Read count number of pixels
+			
+			// Load across lines if necessary
+			while (count >= (pLine + _xCount - pDest)) {
+				int lineCount = (pLine + _xCount - pDest);
+				_videoData->_stream->read(pDest, lineCount);
+				count -= lineCount;
+				pLine += _vidSurface->pitch;
+				pDest = pLine;
+			}
+
+			// Load remainder of pixels on line
+			if (count > 0) {
+				_videoData->_stream->read(pDest, count);
+				pDest += count;
+			}
 		}
 	}
 


Commit: 661a5694b4bf91e61d62fbabf0294c5815cf85f6
    https://github.com/scummvm/scummvm/commit/661a5694b4bf91e61d62fbabf0294c5815cf85f6
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-28T21:40:59-04:00

Commit Message:
ACCESS: Implemented cmdVideoEnded

Changed paths:
    engines/access/scripts.cpp
    engines/access/scripts.h
    engines/access/video.h



diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp
index f92a6d7..ad806de 100644
--- a/engines/access/scripts.cpp
+++ b/engines/access/scripts.cpp
@@ -105,7 +105,7 @@ void Scripts::executeCommand(int commandIndex) {
 		&Scripts::cmdSetTimer, &Scripts::cmdCheckTimer, &Scripts::cmdSetTravel,
 		&Scripts::cmdSetTravel, &Scripts::cmdSetVideo, &Scripts::cmdPlayVideo, 
 		&Scripts::cmdPlotImage, &Scripts::cmdSetDisplay, &Scripts::cmdSetBuffer, 
-		&Scripts::cmdSetScroll, &Scripts::CMDSAVERECT, &Scripts::CMDSAVERECT, 
+		&Scripts::cmdSetScroll, &Scripts::cmdVideoEnded, &Scripts::cmdVideoEnded, 
 		&Scripts::CMDSETBUFVID, &Scripts::CMDPLAYBUFVID, &Scripts::cmdRemoveLast, 
 		&Scripts::cmdSpecial, &Scripts::cmdSpecial, &Scripts::cmdSpecial,
 		&Scripts::CMDSETCYCLE, &Scripts::CMDCYCLE, &Scripts::cmdCharSpeak, 
@@ -457,7 +457,13 @@ void Scripts::cmdSetScroll() {
 	_vm->_screen->_scrollY = 0;
 }
 
-void Scripts::CMDSAVERECT() { error("TODO CMDSAVERECT"); }
+void Scripts::cmdVideoEnded() { 
+	if (_vm->_video->_videoEnd)
+		cmdGoto();
+	else
+		_data->skip(2);
+}
+
 void Scripts::CMDSETBUFVID() { error("TODO CMDSETBUFVID"); }
 void Scripts::CMDPLAYBUFVID() { error("TODO CMDPLAYBUFVID"); }
 
diff --git a/engines/access/scripts.h b/engines/access/scripts.h
index 414ba46..7568e03 100644
--- a/engines/access/scripts.h
+++ b/engines/access/scripts.h
@@ -96,7 +96,7 @@ protected:
 	void cmdSetDisplay();
 	void cmdSetBuffer();
 	void cmdSetScroll();
-	void CMDSAVERECT();
+	void cmdVideoEnded();
 	void CMDSETBUFVID();
 	void CMDPLAYBUFVID();
 	void cmdRemoveLast();
diff --git a/engines/access/video.h b/engines/access/video.h
index 20e5cfc..bb9656b 100644
--- a/engines/access/video.h
+++ b/engines/access/video.h
@@ -48,13 +48,13 @@ private:
 	int _xCount;
 	int _scanCount;
 	int _frameSize;
-	bool _videoEnd;
 
 	void getFrame();
 public:
 	int _videoFrame;
 	bool _soundFlag;
 	int _soundFrame;
+	bool _videoEnd;
 public:
 	VideoPlayer(AccessEngine *vm);
 	~VideoPlayer();


Commit: a47457084f10faf49f002a0350bc9a832309e11d
    https://github.com/scummvm/scummvm/commit/a47457084f10faf49f002a0350bc9a832309e11d
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-28T21:55:09-04:00

Commit Message:
ACCESS: Add event polling to cmdVideoEnded to make videos play correctly

Changed paths:
    engines/access/scripts.cpp



diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp
index ad806de..c5b7d95 100644
--- a/engines/access/scripts.cpp
+++ b/engines/access/scripts.cpp
@@ -458,10 +458,14 @@ void Scripts::cmdSetScroll() {
 }
 
 void Scripts::cmdVideoEnded() { 
-	if (_vm->_video->_videoEnd)
+	_vm->_events->pollEvents();
+
+	if (_vm->_video->_videoEnd) {
 		cmdGoto();
-	else
+	} else {
+		g_system->delayMillis(10);
 		_data->skip(2);
+	}
 }
 
 void Scripts::CMDSETBUFVID() { error("TODO CMDSETBUFVID"); }


Commit: d31a0f152ff0a80f382d0e868562867fcf7fe305
    https://github.com/scummvm/scummvm/commit/d31a0f152ff0a80f382d0e868562867fcf7fe305
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-28T22:01:38-04:00

Commit Message:
ACCESS: Fix background display during character conversations

Changed paths:
    engines/access/char.cpp



diff --git a/engines/access/char.cpp b/engines/access/char.cpp
index 767512f..aebf63a 100644
--- a/engines/access/char.cpp
+++ b/engines/access/char.cpp
@@ -104,7 +104,7 @@ void CharManager::loadChar(int charId) {
 	}
 
 	_vm->_buffer1.copyFrom(*_vm->_screen);
-	_vm->_screen->copyFrom(_vm->_buffer2);
+	_vm->_buffer2.copyFrom(*_vm->_screen);
 	_vm->_screen->setDisplayScan();
 
 	if (_charFlag != 2 && _charFlag != 3) {


Commit: d2cb9d4c4318e9c1895e492539c755fb6e3cf052
    https://github.com/scummvm/scummvm/commit/d2cb9d4c4318e9c1895e492539c755fb6e3cf052
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-28T22:15:39-04:00

Commit Message:
ACCESS: Implemented cmdFreeSound

Changed paths:
    engines/access/access.cpp
    engines/access/scripts.cpp
    engines/access/scripts.h
    engines/access/sound.cpp
    engines/access/sound.h



diff --git a/engines/access/access.cpp b/engines/access/access.cpp
index e02b0c0..3e8eff3 100644
--- a/engines/access/access.cpp
+++ b/engines/access/access.cpp
@@ -256,7 +256,7 @@ void AccessEngine::speakText(ASurface *s, Common::Array<Common::String> msgArr)
 				_sound->_soundTable[0] = _sound->loadSound(_narateFile + 99, _sndSubFile);
 				_sound->_soundPriority[0] = 1;
 				_sound->playSound(1);
-				_scripts->CMDFREESOUND();
+				_scripts->cmdFreeSound();
 
 				_events->pollEvents();
 
@@ -291,7 +291,7 @@ void AccessEngine::speakText(ASurface *s, Common::Array<Common::String> msgArr)
 		_sound->_soundTable[0] = _sound->loadSound(_narateFile + 99, _sndSubFile);
 		_sound->_soundPriority[0] = 1;
 		_sound->playSound(1);
-		_scripts->CMDFREESOUND();
+		_scripts->cmdFreeSound();
 
 		_events->pollEvents();
 
diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp
index c5b7d95..a1ede67 100644
--- a/engines/access/scripts.cpp
+++ b/engines/access/scripts.cpp
@@ -67,6 +67,24 @@ void Scripts::searchForSequence() {
 	} while (sequenceId != _sequence);
 }
 
+void Scripts::charLoop() {
+	bool endFlag = _endFlag;
+	int pos = _data->pos();
+
+	_sequence = 2000;
+	searchForSequence();
+	_vm->_images.clear();
+	_vm->_buffer2.copyFrom(_vm->_buffer1);
+	_vm->_newRects.clear();
+
+	executeScript();
+	_vm->plotList1();
+	_vm->copyBlocks();
+
+	_data->seek(pos);
+	_endFlag = endFlag;
+}
+
 void Scripts::findNull() {
 	// No implementation required in ScummVM, the strings in the script files are already skipped by the use of readByte()
 }
@@ -112,7 +130,7 @@ void Scripts::executeCommand(int commandIndex) {
 		&Scripts::cmdTexSpeak, &Scripts::cmdTexChoice, &Scripts::CMDWAIT, 
 		&Scripts::cmdSetConPos, &Scripts::CMDCHECKVFRAME, &Scripts::cmdJumpChoice, 
 		&Scripts::cmdReturnChoice, &Scripts::cmdClearBlock, &Scripts::cmdLoadSound, 
-		&Scripts::CMDFREESOUND, &Scripts::cmdSetVideoSound, &Scripts::cmdPlayVideoSound,
+		&Scripts::cmdFreeSound, &Scripts::cmdSetVideoSound, &Scripts::cmdPlayVideoSound,
 		&Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, 
 		&Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, &Scripts::cmdPlayerOff, 
 		&Scripts::cmdPlayerOn, &Scripts::CMDDEAD, &Scripts::cmdFadeOut,
@@ -608,7 +626,7 @@ void Scripts::cmdTexChoice() {
 
 	int choice = -1;
 	do {
-		warning("TODO CHARLOOP");
+		charLoop();
 		_vm->_bubbleBox->_bubblePtr = _vm->_bubbleBox->_bubbleTitle.c_str();
 		if (_vm->_events->_leftButton) {
 			if (_vm->_events->_mouseRow >= 22) {
@@ -669,7 +687,23 @@ void Scripts::cmdLoadSound() {
 	_vm->_sound->_soundPriority[0] = 1;
 }
 
-void Scripts::CMDFREESOUND() { warning("TODO CMDFREESOUND"); }
+void Scripts::cmdFreeSound() { 
+	SoundManager &sound = *_vm->_sound;
+
+	if (sound._soundTable.size() > 0 && sound._soundTable[0]) {
+		// Keep doing char display loop if playing sound for it
+		do {
+			if (_vm->_flags[236] == 1)
+				charLoop();
+
+			_vm->_events->pollEvents();
+		} while (!_vm->shouldQuit() && sound._playingSound);
+
+		// Free the sound
+		delete sound._soundTable[0];
+		sound._soundTable[0] = nullptr;
+	}
+}
 
 void Scripts::cmdSetVideoSound() {
 	uint32 startPos = _data->pos();
diff --git a/engines/access/scripts.h b/engines/access/scripts.h
index 7568e03..733c7f9 100644
--- a/engines/access/scripts.h
+++ b/engines/access/scripts.h
@@ -37,6 +37,7 @@ private:
 	Resource *_resource;
 	int _specialFunction;
 
+	void charLoop();
 protected:
 	Common::SeekableReadStream *_data;
 
@@ -144,7 +145,7 @@ public:
 
 	void findNull();
 
-	void CMDFREESOUND();
+	void cmdFreeSound();
 };
 
 } // End of namespace Access
diff --git a/engines/access/sound.cpp b/engines/access/sound.cpp
index d932cc6..52d9d00 100644
--- a/engines/access/sound.cpp
+++ b/engines/access/sound.cpp
@@ -31,6 +31,7 @@ SoundManager::SoundManager(AccessEngine *vm, Audio::Mixer *mixer) :
 		_vm(vm), _mixer(mixer) {
 	_music = nullptr;
 	_musicRepeat = false;
+	_playingSound = false;
 }
 
 SoundManager::~SoundManager() {
diff --git a/engines/access/sound.h b/engines/access/sound.h
index 8fef9e3..1a94c46 100644
--- a/engines/access/sound.h
+++ b/engines/access/sound.h
@@ -47,6 +47,7 @@ public:
 	Common::Array<int> _soundPriority;
 	Resource *_music;
 	bool _musicRepeat;
+	bool _playingSound;
 public:
 	SoundManager(AccessEngine *vm, Audio::Mixer *mixer);
 	~SoundManager();


Commit: bbe7616a198b0220a038028337127fecfea842ca
    https://github.com/scummvm/scummvm/commit/bbe7616a198b0220a038028337127fecfea842ca
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-29T07:21:44-04:00

Commit Message:
ACCESS: Add event polling to cmdTexChoice so conversations work

Changed paths:
    engines/access/scripts.cpp



diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp
index a1ede67..3b03a7a 100644
--- a/engines/access/scripts.cpp
+++ b/engines/access/scripts.cpp
@@ -626,7 +626,12 @@ void Scripts::cmdTexChoice() {
 
 	int choice = -1;
 	do {
+		_vm->_events->pollEvents();
+		if (_vm->shouldQuit())
+			return;
+
 		charLoop();
+
 		_vm->_bubbleBox->_bubblePtr = _vm->_bubbleBox->_bubbleTitle.c_str();
 		if (_vm->_events->_leftButton) {
 			if (_vm->_events->_mouseRow >= 22) {


Commit: 0ef365ab025cb77ab40e95e5e9139a5f86168fa6
    https://github.com/scummvm/scummvm/commit/0ef365ab025cb77ab40e95e5e9139a5f86168fa6
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-29T07:31:23-04:00

Commit Message:
ACCESS: Fix errors in loadScreen since resource refactoring

Changed paths:
    engines/access/files.cpp



diff --git a/engines/access/files.cpp b/engines/access/files.cpp
index 233d040..4ab98a2 100644
--- a/engines/access/files.cpp
+++ b/engines/access/files.cpp
@@ -137,6 +137,11 @@ void FileManager::loadScreen(Graphics::Surface *dest, int fileNum, int subfile)
 void FileManager::handleScreen(Graphics::Surface *dest, Resource *res) {
 	_vm->_screen->loadPalette(res->_stream);
 
+	// The remainder of the file after the palette may be separately compressed,
+	// so call handleFile to handle it if it is
+	res->_size -= res->_stream->pos();
+	handleFile(res);
+
 	if (dest != _vm->_screen)
 		dest->w = _vm->_screen->w;
 


Commit: 8b9faf7de563b5c3a00cc9935eccb5e60b816632
    https://github.com/scummvm/scummvm/commit/8b9faf7de563b5c3a00cc9935eccb5e60b816632
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-29T21:03:11-04:00

Commit Message:
ACCESS: Add synchronize method for savegames

Changed paths:
    engines/access/access.cpp
    engines/access/access.h
    engines/access/amazon/amazon_game.cpp
    engines/access/amazon/amazon_game.h
    engines/access/data.cpp
    engines/access/data.h
    engines/access/inventory.cpp
    engines/access/inventory.h
    engines/access/player.cpp
    engines/access/player.h
    engines/access/sound.cpp



diff --git a/engines/access/access.cpp b/engines/access/access.cpp
index 3e8eff3..9525608 100644
--- a/engines/access/access.cpp
+++ b/engines/access/access.cpp
@@ -76,8 +76,6 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc)
 	_currentMan = 0;
 	_newTime = 0;
 	_newDate = 0;
-	_intTim[3] = 0;
-	_timer[3] = 0;
 	Common::fill(&_objectsTable[0], &_objectsTable[100], (SpriteResource *)nullptr);
 	Common::fill(&_establishTable[0], &_establishTable[100], false);
 	Common::fill(&_flags[0], &_flags[256], 0);
@@ -180,33 +178,9 @@ Common::Error AccessEngine::run() {
 
 	playGame();
 
-	dummyLoop();
 	return Common::kNoError;
 }
 
-void AccessEngine::dummyLoop() {
-	// Dummy game loop
-	while (!shouldQuit()) {
-		_events->pollEvents();
-
-		_curTime = g_system->getMillis();
-		// Process machine once every tick
-		while (_curTime - _lastTime < 20) {
-			g_system->delayMillis(5);
-			_curTime = g_system->getMillis();
-		}
-
-		_lastTime = _curTime;
-
-		g_system->updateScreen();
-
-		if (_events->_leftButton) {
-			CursorType cursorId = _events->getCursor();
-			_events->setCursor((cursorId == CURSOR_HELP) ? CURSOR_ARROW : (CursorType)(cursorId + 1));
-		}
-	}
-}
-
 int AccessEngine::getRandomNumber(int maxNumber) {
 	return _randomSource.getRandomNumber(maxNumber);
 }
@@ -411,4 +385,36 @@ void AccessEngine::freeChar() {
 	_animation->freeAnimationData();
 }
 
+void AccessEngine::synchronize(Common::Serializer &s) {
+	s.syncAsUint16LE(_conversation);
+	s.syncAsUint16LE(_currentMan);
+	s.syncAsUint32LE(_newTime);
+	s.syncAsUint32LE(_newDate);
+
+	for (int i = 0; i < 256; ++i)
+		s.syncAsUint16LE(_flags[i]);
+	for (int i = 0; i < 366; ++i) {
+		s.syncAsByte(_help1[i]);
+		s.syncAsByte(_help2[i]);
+		s.syncAsByte(_help3[i]);
+	}
+
+	s.syncAsUint16LE(_travel);
+	s.syncAsUint16LE(_ask);
+	s.syncAsUint16LE(_rScrollRow);
+	s.syncAsUint16LE(_rScrollCol);
+	s.syncAsSint16LE(_rScrollX);
+	s.syncAsSint16LE(_rScrollY);
+	s.syncAsUint16LE(_rOldRectCount);
+	s.syncAsUint16LE(_rNewRectCount);
+	s.syncAsUint16LE(_rKeyFlag);
+	s.syncAsUint16LE(_mapOffset);
+	s.syncAsUint16LE(_screenVirtX);
+
+	// Synchronize sub-objects
+	_timers.synchronize(s);
+	_inventory->synchronize(s);
+	_player->synchronize(s);
+}
+
 } // End of namespace Access
diff --git a/engines/access/access.h b/engines/access/access.h
index 55810e8..7d76be9 100644
--- a/engines/access/access.h
+++ b/engines/access/access.h
@@ -27,6 +27,7 @@
 #include "common/system.h"
 #include "common/error.h"
 #include "common/random.h"
+#include "common/serializer.h"
 #include "common/util.h"
 #include "engines/engine.h"
 #include "graphics/surface.h"
@@ -90,7 +91,6 @@ private:
 	 */
 	void setVGA();
 
-	void dummyLoop();
 protected:
 	const AccessGameDescription *_gameDescription;
 	Common::RandomSource _randomSource;
@@ -110,6 +110,11 @@ protected:
 	 * Play the game
 	 */
 	virtual void playGame() = 0;
+
+	/**
+	* Synchronize savegame data
+	*/
+	virtual void synchronize(Common::Serializer &s);
 public:
 	AnimationManager *_animation;
 	BubbleBox *_bubbleBox;
@@ -177,8 +182,6 @@ public:
 	int _currentMan;
 	uint32 _newTime;
 	uint32 _newDate;
-	int _intTim[3];
-	int _timer[3];
 	int _flags[256];
 	byte _help1[366];
 	byte _help2[366];
diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp
index cf383ce..0ccaae8 100644
--- a/engines/access/amazon/amazon_game.cpp
+++ b/engines/access/amazon/amazon_game.cpp
@@ -44,7 +44,7 @@ AmazonEngine::AmazonEngine(OSystem *syst, const AccessGameDescription *gameDesc)
 	_hitCount = 0;
 	_saveRiver = 0;
 	_hitSafe = 0;
-	_oldTitleChap = _chapter = 0;
+	_oldTitleChapter = _chapter = 0;
 	_updateChapter = -1;
 	_topList = 0;
 	_botList = 0;
@@ -291,10 +291,10 @@ void AmazonEngine::tileScreen() {
 	if (!_screen->_vesaMode)
 		return;
 
-	if (!_clearSummaryFlag && (_oldTitleChap == _chapter))
+	if (!_clearSummaryFlag && (_oldTitleChapter == _chapter))
 		return;
 
-	_oldTitleChap = _chapter;
+	_oldTitleChapter = _chapter;
 	int idx = _chapter - 1;
 
 	if (!_files->existFile(_tileFiles[idx]))
@@ -361,6 +361,40 @@ void AmazonEngine::drawHelp() {
 	error("TODO: drawHelp");
 }
 
+void AmazonEngine::synchronize(Common::Serializer &s) {
+	AccessEngine::synchronize(s);
+
+	s.syncAsSint16LE(_canoeLane);
+	s.syncAsSint16LE(_canoeYPos);
+	s.syncAsSint16LE(_hitCount);
+	s.syncAsSint16LE(_saveRiver);
+	s.syncAsSint16LE(_hitSafe);
+	s.syncAsSint16LE(_chapter);
+	s.syncAsSint16LE(_topList);
+	s.syncAsSint16LE(_botList);
+	s.syncAsSint16LE(_riverIndex);
+	s.syncAsSint16LE(_rawInactiveX);
+	s.syncAsSint16LE(_rawInactiveY);
+	s.syncAsSint16LE(_inactiveYOff);
+	for (int i = 0; i < 100; ++i)
+		s.syncAsSint16LE(_esTabTable[i]);
+}
+
+/*------------------------------------------------------------------------*/
+
+Guard::Guard() {
+	_guardCel = 0;
+	_gCode1 = _gCode2 = 0;
+	_xMid = _yMid = 0;
+}
+
+Plane::Plane() {
+	_pCount = 0;
+	_planeCount = 0;
+	_propCount = 0;
+	_xCount = 0;
+}
+
 } // End of namespace Amazon
 
 } // End of namespace Access
diff --git a/engines/access/amazon/amazon_game.h b/engines/access/amazon/amazon_game.h
index 59511c4..6511b37 100644
--- a/engines/access/amazon/amazon_game.h
+++ b/engines/access/amazon/amazon_game.h
@@ -29,6 +29,29 @@ namespace Access {
 
 namespace Amazon {
 
+class Plane {
+public:
+	int _pCount;
+	Common::Point _position;
+	int _planeCount;
+	int _propCount;
+	int _xCount;
+public:
+	Plane();
+};
+
+class Guard {
+public:
+	int _guardCel;
+	Common::Point _position;
+	int _gCode1;
+	int _gCode2;
+	Common::Rect _bounds;
+	int _xMid, _yMid;
+public:
+	Guard();
+};
+
 class AmazonEngine : public AccessEngine {
 private:
 	bool _skipStart;
@@ -39,7 +62,6 @@ private:
 	int _hitCount;
 	int _saveRiver;
 	int _hitSafe;
-	int _oldTitleChap;
 	int _topList;
 	int _botList;
 	int _riverIndex;
@@ -47,6 +69,8 @@ private:
 	int _rawInactiveY;
 	int _inactiveYOff;
 	int _esTabTable[100];
+
+	// Other fields
 	Common::Point _tilePos;
 	byte _tileData[1455];
 
@@ -84,6 +108,11 @@ protected:
 	 * Play the game
 	 */
 	virtual void playGame();
+
+	/**
+	* Synchronize savegame data
+	*/
+	virtual void synchronize(Common::Serializer &s);
 public:
 	// Fields that are mapped to flags
 	int &_guardLocation;
@@ -100,11 +129,24 @@ public:
 	int &_allenFlag;
 	int &_noSound;
 
+	// Saved fields
+	int _chapter;
+
 	// Other game specific fields
+	Guard _guard;
+	Plane _plane;
 	int _hintLevel;
-
-	int _chapter;
 	int _updateChapter;
+	int _oldTitleChapter;
+	int _maxHits;
+	int _oldScrollCol;
+	bool _deathFlag;
+	int _deathCount;
+	int _deathType;
+	int _mapPtr;
+	int _canoeVXPos;
+	int _canoeMoveCount;
+	int _canoeFrame;
 public:
 	AmazonEngine(OSystem *syst, const AccessGameDescription *gameDesc);
 
diff --git a/engines/access/data.cpp b/engines/access/data.cpp
index 0279cd5..cbc52c0 100644
--- a/engines/access/data.cpp
+++ b/engines/access/data.cpp
@@ -59,4 +59,18 @@ void TimerList::updateTimers() {
 	}
 }
 
+void TimerList::synchronize(Common::Serializer &s) {
+	int count = size();
+	s.syncAsUint16LE(count);
+
+	if (!s.isSaving())
+		resize(count);
+
+	for (int i = 0; i < count; ++i) {
+		s.syncAsUint32LE((*this)[i]._initTm);
+		s.syncAsUint32LE((*this)[i]._timer);
+		s.syncAsByte((*this)[i]._flag);
+	}
+}
+
 } // End of namespace Access
diff --git a/engines/access/data.h b/engines/access/data.h
index 1d64a6f..3b3485e 100644
--- a/engines/access/data.h
+++ b/engines/access/data.h
@@ -26,6 +26,7 @@
 #include "common/scummsys.h"
 #include "common/array.h"
 #include "common/rect.h"
+#include "common/serializer.h"
 #include "common/types.h"
 #include "graphics/surface.h"
 #include "access/files.h"
@@ -74,6 +75,11 @@ public:
 	 * Update the timer list
 	 */
 	void updateTimers();
+
+	/**
+	 * Synchronize savegame data 
+	 */
+	void synchronize(Common::Serializer &s);
 };
 
 class ExtraCell {
diff --git a/engines/access/inventory.cpp b/engines/access/inventory.cpp
index dbc3cba..25c9060 100644
--- a/engines/access/inventory.cpp
+++ b/engines/access/inventory.cpp
@@ -354,5 +354,15 @@ void InventoryManager::combineItems() {
 	warning("TODO: combineItems");
 }
 
+void InventoryManager::synchronize(Common::Serializer &s) {
+	int count = _inv.size();
+	s.syncAsUint16LE(count);
+
+	if (!s.isSaving())
+		_inv.resize(count);
+
+	for (int i = 0; i < count; ++i)
+		s.syncAsUint16LE((*this)[i]);
+}
 
 } // End of namespace Access
diff --git a/engines/access/inventory.h b/engines/access/inventory.h
index a95581c..0ff9020 100644
--- a/engines/access/inventory.h
+++ b/engines/access/inventory.h
@@ -108,6 +108,11 @@ public:
 	void refreshInventory();
 
 	int newDisplayInv();
+
+	/**
+	* Synchronize savegame data
+	*/
+	void synchronize(Common::Serializer &s);
 };
 
 } // End of namespace Access
diff --git a/engines/access/player.cpp b/engines/access/player.cpp
index df2ad67..b8eb08a 100644
--- a/engines/access/player.cpp
+++ b/engines/access/player.cpp
@@ -827,4 +827,12 @@ bool Player::scrollRight() {
 	return true;
 }
 
+void Player::synchronize(Common::Serializer &s) {
+	s.syncAsUint16LE(_roomNumber);
+	s.syncAsSint16LE(_rawPlayerLow.x);
+	s.syncAsSint16LE(_rawPlayer.x);
+	s.syncAsSint16LE(_rawPlayerLow.y);
+	s.syncAsSint16LE(_rawPlayer.y);
+}
+
 } // End of namespace Access
diff --git a/engines/access/player.h b/engines/access/player.h
index 7ba0c05..c5c9afa 100644
--- a/engines/access/player.h
+++ b/engines/access/player.h
@@ -25,6 +25,7 @@
 
 #include "common/scummsys.h"
 #include "common/rect.h"
+#include "common/serializer.h"
 #include "access/asurface.h"
 #include "access/data.h"
 
@@ -127,6 +128,11 @@ public:
 	void calcPlayer();
 
 	void checkScroll();
+
+	/**
+	* Synchronize savegame data
+	*/
+	void synchronize(Common::Serializer &s);
 };
 
 } // End of namespace Access
diff --git a/engines/access/sound.cpp b/engines/access/sound.cpp
index 52d9d00..91910f2 100644
--- a/engines/access/sound.cpp
+++ b/engines/access/sound.cpp
@@ -39,7 +39,7 @@ SoundManager::~SoundManager() {
 }
 
 void SoundManager::clearSounds() {
-	for (int i = 0; i < _soundTable.size(); ++i)
+	for (uint i = 0; i < _soundTable.size(); ++i)
 		delete _soundTable[i];
 	_soundTable.clear();
 	_soundPriority.clear();


Commit: 83528083228ea45ec3105b7dbcb720a1ac0dba55
    https://github.com/scummvm/scummvm/commit/83528083228ea45ec3105b7dbcb720a1ac0dba55
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-30T08:45:42-04:00

Commit Message:
ACCESS: Added code for reading/writing savegame headers and list saves

Changed paths:
    engines/access/access.cpp
    engines/access/access.h
    engines/access/detection.cpp
    engines/access/events.h
    engines/access/room.cpp
    engines/access/screen.cpp
    engines/access/screen.h



diff --git a/engines/access/access.cpp b/engines/access/access.cpp
index 9525608..f638226 100644
--- a/engines/access/access.cpp
+++ b/engines/access/access.cpp
@@ -25,6 +25,8 @@
 #include "common/debug-channels.h"
 #include "common/events.h"
 #include "engines/util.h"
+#include "graphics/scaler.h"
+#include "graphics/thumbnail.h"
 #include "access/access.h"
 
 namespace Access {
@@ -417,4 +419,71 @@ void AccessEngine::synchronize(Common::Serializer &s) {
 	_player->synchronize(s);
 }
 
+const char *const SAVEGAME_STR = "ACCESS";
+#define SAVEGAME_STR_SIZE 6
+
+bool AccessEngine::readSavegameHeader(Common::InSaveFile *in, AccessSavegameHeader &header) {
+	char saveIdentBuffer[SAVEGAME_STR_SIZE + 1];
+	header._thumbnail = nullptr;
+
+	// Validate the header Id
+	in->read(saveIdentBuffer, SAVEGAME_STR_SIZE + 1);
+	if (strncmp(saveIdentBuffer, SAVEGAME_STR, SAVEGAME_STR_SIZE))
+		return false;
+
+	header._version = in->readByte();
+	if (header._version > ACCESS_SAVEGAME_VERSION)
+		return false;
+
+	// Read in the string
+	header._saveName.clear();
+	char ch;
+	while ((ch = (char)in->readByte()) != '\0') header._saveName += ch;
+
+	// Get the thumbnail
+	header._thumbnail = Graphics::loadThumbnail(*in);
+	if (!header._thumbnail)
+		return false;
+
+	// Read in save date/time
+	header._year = in->readSint16LE();
+	header._month = in->readSint16LE();
+	header._day = in->readSint16LE();
+	header._hour = in->readSint16LE();
+	header._minute = in->readSint16LE();
+	header._totalFrames = in->readUint32LE();
+
+	return true;
+}
+
+void AccessEngine::writeSavegameHeader(Common::OutSaveFile *out, AccessSavegameHeader &header) {
+	// Write out a savegame header
+	out->write(SAVEGAME_STR, SAVEGAME_STR_SIZE + 1);
+
+	out->writeByte(ACCESS_SAVEGAME_VERSION);
+
+	// Write savegame name
+	out->write(header._saveName.c_str(), header._saveName.size());
+	out->writeByte('\0');
+
+	// Write a thumbnail of the screen
+	uint8 thumbPalette[PALETTE_SIZE];
+	_screen->getPalette(thumbPalette);
+	Graphics::Surface saveThumb;
+	::createThumbnail(&saveThumb, (const byte *)_screen->getPixels(),
+		_screen->w, _screen->h, thumbPalette);
+	Graphics::saveThumbnail(*out, saveThumb);
+	saveThumb.free();
+
+	// Write out the save date/time
+	TimeDate td;
+	g_system->getTimeAndDate(td);
+	out->writeSint16LE(td.tm_year + 1900);
+	out->writeSint16LE(td.tm_mon + 1);
+	out->writeSint16LE(td.tm_mday);
+	out->writeSint16LE(td.tm_hour);
+	out->writeSint16LE(td.tm_min);
+	out->writeUint32LE(_events->getFrameCounter());
+}
+
 } // End of namespace Access
diff --git a/engines/access/access.h b/engines/access/access.h
index 7d76be9..a192da3 100644
--- a/engines/access/access.h
+++ b/engines/access/access.h
@@ -27,6 +27,7 @@
 #include "common/system.h"
 #include "common/error.h"
 #include "common/random.h"
+#include "common/savefile.h"
 #include "common/serializer.h"
 #include "common/util.h"
 #include "engines/engine.h"
@@ -77,6 +78,17 @@ struct AccessGameDescription;
 
 extern const char *const _estTable[];
 
+#define ACCESS_SAVEGAME_VERSION 1
+
+struct AccessSavegameHeader {
+	uint8 _version;
+	Common::String _saveName;
+	Graphics::Surface *_thumbnail;
+	int _year, _month, _day;
+	int _hour, _minute;
+	int _totalFrames;
+};
+
 class AccessEngine : public Engine {
 private:
 	uint32 _lastTime, _curTime;
@@ -248,6 +260,10 @@ public:
 	void doLoadSave();
 
 	void freeChar();
+
+	static bool readSavegameHeader(Common::InSaveFile *in, AccessSavegameHeader &header);
+
+	void writeSavegameHeader(Common::OutSaveFile *out, AccessSavegameHeader &header);
 };
 
 } // End of namespace Access
diff --git a/engines/access/detection.cpp b/engines/access/detection.cpp
index dd75b28..293cd3d 100644
--- a/engines/access/detection.cpp
+++ b/engines/access/detection.cpp
@@ -136,7 +136,33 @@ bool AccessMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGa
 }
 
 SaveStateList AccessMetaEngine::listSaves(const char *target) const {
+	Common::SaveFileManager *saveFileMan = g_system->getSavefileManager();
+	Common::StringArray filenames;
+	Common::String saveDesc;
+	Common::String pattern = Common::String::format("%s.0??", target);
+	Access::AccessSavegameHeader header;
+
+	filenames = saveFileMan->listSavefiles(pattern);
+	sort(filenames.begin(), filenames.end());   // Sort to get the files in numerical order
+
 	SaveStateList saveList;
+	for (Common::StringArray::const_iterator file = filenames.begin(); file != filenames.end(); ++file) {
+		const char *ext = strrchr(file->c_str(), '.');
+		int slot = ext ? atoi(ext + 1) : -1;
+
+		if (slot >= 0 && slot < MAX_SAVES) {
+			Common::InSaveFile *in = g_system->getSavefileManager()->openForLoading(*file);
+
+			if (in) {
+				Access::AccessEngine::readSavegameHeader(in, header);
+				saveList.push_back(SaveStateDescriptor(slot, header._saveName));
+
+				header._thumbnail->free();
+				delete header._thumbnail;
+				delete in;
+			}
+		}
+	}
 
 	return saveList;
 }
diff --git a/engines/access/events.h b/engines/access/events.h
index fdfb0a5..014ff23 100644
--- a/engines/access/events.h
+++ b/engines/access/events.h
@@ -71,6 +71,11 @@ public:
 	~EventsManager();
 
 	/**
+	 * Return frame counter
+	 */
+	uint32 getFrameCounter() { return _frameCounter; }
+
+	/**
 	 * Sets the cursor
 	 */
 	void setCursor(CursorType cursorId);
diff --git a/engines/access/room.cpp b/engines/access/room.cpp
index b9a07ea..c9e150f 100644
--- a/engines/access/room.cpp
+++ b/engines/access/room.cpp
@@ -433,7 +433,7 @@ void Room::handleCommand(int commandId) {
 		--commandId;
 
 	if (commandId == 9)
-		_vm->doLoadSave();
+		_vm->openMainMenuDialog();
 	else if (commandId == _selectCommand) {
 		_vm->_events->debounceLeft();
 		commandOff();
diff --git a/engines/access/screen.cpp b/engines/access/screen.cpp
index 4b1c6d8..26dd2e9 100644
--- a/engines/access/screen.cpp
+++ b/engines/access/screen.cpp
@@ -141,6 +141,9 @@ void Screen::restorePalette() {
 		&_savedPalettes[_savedPaletteCount][PALETTE_SIZE], &_rawPalette[0]);
 }
 
+void Screen::getPalette(byte *pal) {
+	g_system->getPaletteManager()->grabPalette(pal, 0, 256);
+}
 
 void Screen::forceFadeOut() {
 	const int FADE_AMOUNT = 2;
diff --git a/engines/access/screen.h b/engines/access/screen.h
index a166fde..47e03de 100644
--- a/engines/access/screen.h
+++ b/engines/access/screen.h
@@ -131,6 +131,8 @@ public:
 
 	void restorePalette();
 
+	void getPalette(byte *pal);
+
 	/**
 	 * Copy a buffer to the screen
 	 */


Commit: f12fa2de07694d93a7035875f56f36ed4849275d
    https://github.com/scummvm/scummvm/commit/f12fa2de07694d93a7035875f56f36ed4849275d
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-30T09:57:51-04:00

Commit Message:
ACCESS: Implement saving and loading savegames

Changed paths:
    engines/access/access.cpp
    engines/access/access.h
    engines/access/detection.cpp
    engines/access/room.cpp



diff --git a/engines/access/access.cpp b/engines/access/access.cpp
index f638226..a039139 100644
--- a/engines/access/access.cpp
+++ b/engines/access/access.cpp
@@ -72,6 +72,7 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc)
 	_scaleMaxY = 0;
 	_scaleI = 0;
 	_scaleFlag = false;
+	_canSaveLoad = false;
 	_eseg = nullptr;
 
 	_conversation = 0;
@@ -387,6 +388,66 @@ void AccessEngine::freeChar() {
 	_animation->freeAnimationData();
 }
 
+Common::Error AccessEngine::saveGameState(int slot, const Common::String &desc) {
+	Common::OutSaveFile *out = g_system->getSavefileManager()->openForSaving(
+		generateSaveName(slot));
+	if (!out)
+		return Common::kCreatingFileFailed;
+
+	AccessSavegameHeader header;
+	header._saveName = desc;
+	writeSavegameHeader(out, header);
+
+	Common::Serializer s(nullptr, out);
+	synchronize(s);
+
+	out->finalize();
+	delete out;
+
+	return Common::kNoError;
+}
+
+Common::Error AccessEngine::loadGameState(int slot) {
+	Common::InSaveFile *saveFile = g_system->getSavefileManager()->openForLoading(
+		generateSaveName(slot));
+	if (!saveFile)
+		return Common::kReadingFailed;
+
+	Common::Serializer s(saveFile, nullptr);
+
+	// Load the savaegame header
+	AccessSavegameHeader header;
+	if (!readSavegameHeader(saveFile, header))
+		error("Invalid savegame");
+
+	if (header._thumbnail) {
+		header._thumbnail->free();
+		delete header._thumbnail;
+	}
+
+	// Load most of the savegame data
+	synchronize(s);
+	delete saveFile;
+
+	// Set extra post-load state
+	_room->_function = 1;
+	_timers._timersSavedFlag = false;
+
+	return Common::kNoError;
+}
+
+Common::String AccessEngine::generateSaveName(int slot) {
+	return Common::String::format("%s.%03d", _targetName.c_str(), slot);
+}
+
+bool AccessEngine::canLoadGameStateCurrently() {
+	return _canSaveLoad;
+}
+
+bool AccessEngine::canSaveGameStateCurrently() {
+	return _canSaveLoad;
+}
+
 void AccessEngine::synchronize(Common::Serializer &s) {
 	s.syncAsUint16LE(_conversation);
 	s.syncAsUint16LE(_currentMan);
diff --git a/engines/access/access.h b/engines/access/access.h
index a192da3..8e7c42f 100644
--- a/engines/access/access.h
+++ b/engines/access/access.h
@@ -114,6 +114,12 @@ protected:
 
 	void speakText(ASurface *s, Common::Array<Common::String>msgArr);
 
+	/**
+	* Support method that generates a savegame name
+	* @param slot		Slot number
+	*/
+	Common::String AccessEngine::generateSaveName(int slot);
+
 	// Engine APIs
 	virtual Common::Error run();
 	virtual bool hasFeature(EngineFeature f) const;
@@ -180,6 +186,7 @@ public:
 	int _scaleMaxY;
 	int _scaleI;
 	bool _scaleFlag;
+	bool _canSaveLoad;
 
 	Resource *_eseg;
 	int _et;
@@ -261,8 +268,34 @@ public:
 
 	void freeChar();
 
+	/**
+	 * Load a savegame
+	 */
+	virtual Common::Error loadGameState(int slot);
+
+	/**
+	 * Save the game
+	 */
+	virtual Common::Error saveGameState(int slot, const Common::String &desc);
+
+	/**
+	 * Returns true if a savegame can currently be loaded
+	 */
+	bool canLoadGameStateCurrently();
+
+	/**
+	* Returns true if the game can currently be saved
+	*/
+	bool canSaveGameStateCurrently();
+
+	/**
+	 * Read in a savegame header
+	 */
 	static bool readSavegameHeader(Common::InSaveFile *in, AccessSavegameHeader &header);
 
+	/**
+	 * Write out a savegame header
+	 */
 	void writeSavegameHeader(Common::OutSaveFile *out, AccessSavegameHeader &header);
 };
 
diff --git a/engines/access/detection.cpp b/engines/access/detection.cpp
index 293cd3d..59c4bc4 100644
--- a/engines/access/detection.cpp
+++ b/engines/access/detection.cpp
@@ -177,6 +177,24 @@ void AccessMetaEngine::removeSaveState(const char *target, int slot) const {
 }
 
 SaveStateDescriptor AccessMetaEngine::querySaveMetaInfos(const char *target, int slot) const {
+	Common::String filename = Common::String::format("%s.%03d", target, slot);
+	Common::InSaveFile *f = g_system->getSavefileManager()->openForLoading(filename);
+
+	if (f) {
+		Access::AccessSavegameHeader header;
+		Access::AccessEngine::readSavegameHeader(f, header);
+		delete f;
+
+		// Create the return descriptor
+		SaveStateDescriptor desc(slot, header._saveName);
+		desc.setThumbnail(header._thumbnail);
+		desc.setSaveDate(header._year, header._month, header._day);
+		desc.setSaveTime(header._hour, header._minute);
+		desc.setPlayTime(header._totalFrames * GAME_FRAME_TIME);
+
+		return desc;
+	}
+
 	return SaveStateDescriptor();
 }
 
diff --git a/engines/access/room.cpp b/engines/access/room.cpp
index c9e150f..d4e8886 100644
--- a/engines/access/room.cpp
+++ b/engines/access/room.cpp
@@ -80,7 +80,10 @@ void Room::doRoom() {
 			}
 
 			// Handle any events
+			_vm->_canSaveLoad = true;
 			_vm->_events->pollEvents();
+			_vm->_canSaveLoad = false;
+			g_system->delayMillis(5);
 
 			_vm->_player->walk();
 			_vm->_sound->midiRepeat();
@@ -432,9 +435,11 @@ void Room::handleCommand(int commandId) {
 	if (commandId == 1)
 		--commandId;
 
-	if (commandId == 9)
+	if (commandId == 9) {
+		_vm->_canSaveLoad = true;
 		_vm->openMainMenuDialog();
-	else if (commandId == _selectCommand) {
+		_vm->_canSaveLoad = false;
+	}  else if (commandId == _selectCommand) {
 		_vm->_events->debounceLeft();
 		commandOff();
 	} else {


Commit: 949033ea9242f8ce0ae7c6906c8c5d6831929056
    https://github.com/scummvm/scummvm/commit/949033ea9242f8ce0ae7c6906c8c5d6831929056
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-30T10:57:45-04:00

Commit Message:
ACCESS: Implement loading savegames from launcher

Changed paths:
    engines/access/access.cpp
    engines/access/access.h
    engines/access/amazon/amazon_game.cpp



diff --git a/engines/access/access.cpp b/engines/access/access.cpp
index a039139..01bb3e3 100644
--- a/engines/access/access.cpp
+++ b/engines/access/access.cpp
@@ -108,6 +108,7 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc)
 	_narateFile = 0;
 	_txtPages = 0;
 	_sndSubFile = 0;
+	_loadSaveSlot = -1;
 }
 
 AccessEngine::~AccessEngine() {
@@ -173,6 +174,13 @@ void AccessEngine::initialize() {
 
 	_buffer1.create(g_system->getWidth() + TILE_WIDTH, g_system->getHeight());
 	_buffer2.create(g_system->getWidth(), g_system->getHeight());
+
+	// If requested, load a savegame instead of showing the intro
+	if (ConfMan.hasKey("save_slot")) {
+		int saveSlot = ConfMan.getInt("save_slot");
+		if (saveSlot >= 0 && saveSlot <= 999)
+			_loadSaveSlot = saveSlot;
+	}
 }
 
 Common::Error AccessEngine::run() {
diff --git a/engines/access/access.h b/engines/access/access.h
index 8e7c42f..2f557df 100644
--- a/engines/access/access.h
+++ b/engines/access/access.h
@@ -106,6 +106,7 @@ private:
 protected:
 	const AccessGameDescription *_gameDescription;
 	Common::RandomSource _randomSource;
+	int _loadSaveSlot;
 
 	/**
 	 * Main handler for showing game rooms
diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp
index 0ccaae8..ecd9922 100644
--- a/engines/access/amazon/amazon_game.cpp
+++ b/engines/access/amazon/amazon_game.cpp
@@ -64,10 +64,16 @@ AmazonEngine::~AmazonEngine() {
 }
 
 void AmazonEngine::playGame() {
-	// Do introduction
-	doIntroduction();
-	if (shouldQuit())
-		return;
+	// Initialise Amazon game-specific objects
+	_room = new AmazonRoom(this);
+	_scripts = new AmazonScripts(this);
+
+	if (_loadSaveSlot != -1) {
+		// Do introduction
+		doIntroduction();
+		if (shouldQuit())
+			return;
+	}
 
 	// Setup the game
 	setupGame();
@@ -75,12 +81,13 @@ void AmazonEngine::playGame() {
 	_screen->clearScreen();
 	_screen->setPanel(0);
 	_screen->forceFadeOut();
-
 	_events->showCursor();
 
-	// Setup and execute the room
-	_room = new AmazonRoom(this);
-	_scripts = new AmazonScripts(this);
+	// If there's a pending savegame to load, load it
+	if (_loadSaveSlot != -1)
+		loadGameState(_loadSaveSlot);
+
+	// Execute the room
 	_room->doRoom();
 }
 


Commit: 2cca520465dd8005aa3ee21b25961afbde227afd
    https://github.com/scummvm/scummvm/commit/2cca520465dd8005aa3ee21b25961afbde227afd
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-30T11:52:48-04:00

Commit Message:
ACCESS: Add new support for mouse wheel for cycling through cursors

Changed paths:
    engines/access/events.cpp
    engines/access/events.h
    engines/access/room.cpp
    engines/access/room.h



diff --git a/engines/access/events.cpp b/engines/access/events.cpp
index 7366905..0a75430 100644
--- a/engines/access/events.cpp
+++ b/engines/access/events.cpp
@@ -40,6 +40,8 @@ EventsManager::EventsManager(AccessEngine *vm): _vm(vm) {
 	_frameCounter = 10;
 	_priorFrameTime = 0;
 	_leftButton = _rightButton = false;
+	_middleButton = false;
+	_wheelUp = _wheelDown = false;
 	_mouseCol = _mouseRow = 0;
 	_cursorExitFlag = false;
 }
@@ -122,6 +124,8 @@ void EventsManager::pollEvents() {
 		nextFrame();
 	}
 
+	_wheelUp = _wheelDown = false;
+
 	Common::Event event;
 	while (g_system->getEventManager()->pollEvent(event)) {
 		switch (event.type) {
@@ -158,6 +162,18 @@ void EventsManager::pollEvents() {
 		case Common::EVENT_RBUTTONUP:
 			_rightButton = false;
 			return;
+		case Common::EVENT_MBUTTONDOWN:
+			_middleButton = true;
+			return;
+		case Common::EVENT_MBUTTONUP:
+			_middleButton = false;
+			return;
+		case Common::EVENT_WHEELUP:
+			_wheelUp = true;
+			return;
+		case Common::EVENT_WHEELDOWN:
+			_wheelDown = true;
+			return;
 		default:
  			break;
 		}
diff --git a/engines/access/events.h b/engines/access/events.h
index 014ff23..6b46086 100644
--- a/engines/access/events.h
+++ b/engines/access/events.h
@@ -55,6 +55,8 @@ public:
 	CursorType _cursorId;
 	CursorType _normalMouse;
 	bool _leftButton, _rightButton;
+	bool _middleButton;
+	bool _wheelUp, _wheelDown;
 	Common::Point _mousePos;
 	int _mouseCol, _mouseRow;
 	bool _cursorExitFlag;
diff --git a/engines/access/room.cpp b/engines/access/room.cpp
index d4e8886..a7b619c 100644
--- a/engines/access/room.cpp
+++ b/engines/access/room.cpp
@@ -79,7 +79,7 @@ void Room::doRoom() {
 				_vm->_screen->fadeIn();
 			}
 
-			// Handle any events
+			// Poll for events
 			_vm->_canSaveLoad = true;
 			_vm->_events->pollEvents();
 			_vm->_canSaveLoad = false;
@@ -408,7 +408,16 @@ void Room::doCommands() {
 	if (_vm->_screen->_screenChangeFlag) {
 		_vm->_screen->_screenChangeFlag = false;
 		_vm->_events->_cursorExitFlag = true;
-		executeCommand(4);
+		executeCommand(7);
+	}
+	else if (_vm->_events->_wheelUp || _vm->_events->_wheelDown) {
+		// Handle scrolling mouse wheel
+		cycleCommand(_vm->_events->_wheelUp ? 1 : -1);
+
+	} else if (_vm->_events->_middleButton) {
+		// Switch back to walking
+		handleCommand(7);
+
 	} else if (_vm->_events->_leftButton) {
 		if (_vm->_events->_mouseRow >= 22) {
 			// Mouse in user interface area
@@ -431,6 +440,20 @@ void Room::doCommands() {
 	}
 }
 
+void Room::cycleCommand(int incr) {	
+	int command = _selectCommand + incr;
+	if (command < -1)
+		command = 6;
+	else if (command == -1)
+		command = 7;
+	else  if (command == 1)
+		command = (incr == 1) ? 2 : 0;
+	else if (command == 4)
+		command = (incr == 1) ? 5 : 3;
+
+	handleCommand(command);
+}
+
 void Room::handleCommand(int commandId) {
 	if (commandId == 1)
 		--commandId;
@@ -494,7 +517,7 @@ void Room::executeCommand(int commandId) {
 			_vm->_scripts->executeScript();
 		}
 		_vm->_boxSelect = true;
-		break;
+		return;
 	case 8:
 		events.setCursor(CURSOR_HELP);
 		break;
diff --git a/engines/access/room.h b/engines/access/room.h
index 1d54084..321ace4 100644
--- a/engines/access/room.h
+++ b/engines/access/room.h
@@ -72,6 +72,11 @@ private:
 	int calcLR(int yp);
 	int calcUD(int xp);
 
+	/**
+	 * Cycles forwards or backwards through the list of commands
+	 */
+	void cycleCommand(int incr);
+
 	bool checkCode(int v1, int v2);
 protected:
 	void loadRoomData(const byte *roomData);


Commit: d38839d64209248e07b5464be8d44fa19ae93b92
    https://github.com/scummvm/scummvm/commit/d38839d64209248e07b5464be8d44fa19ae93b92
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-30T11:55:02-04:00

Commit Message:
ACCESS: Fix selecting the help cursor

Changed paths:
    engines/access/room.cpp



diff --git a/engines/access/room.cpp b/engines/access/room.cpp
index a7b619c..c26a811 100644
--- a/engines/access/room.cpp
+++ b/engines/access/room.cpp
@@ -519,6 +519,7 @@ void Room::executeCommand(int commandId) {
 		_vm->_boxSelect = true;
 		return;
 	case 8:
+		events._normalMouse = CURSOR_HELP;
 		events.setCursor(CURSOR_HELP);
 		break;
 	default:


Commit: 67e52da359e41c350f8d79cfae3453ca70b8e6d3
    https://github.com/scummvm/scummvm/commit/67e52da359e41c350f8d79cfae3453ca70b8e6d3
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-30T14:19:49-04:00

Commit Message:
ACCESS: Fix non-scaled sprites appearing on-screen in scrolling scenes

Changed paths:
    engines/access/access.cpp



diff --git a/engines/access/access.cpp b/engines/access/access.cpp
index 01bb3e3..a0de5c8 100644
--- a/engines/access/access.cpp
+++ b/engines/access/access.cpp
@@ -341,9 +341,9 @@ void AccessEngine::plotList1() {
 				}
 			} else {
 				if (ie._flags & 2) {
-					_buffer2.plotB(frame, Common::Point(bounds.left, bounds.top));
+					_buffer2.plotB(frame, Common::Point(destBounds.left, destBounds.top));
 				} else {
-					_buffer2.plotF(frame, Common::Point(bounds.left, bounds.top));
+					_buffer2.plotF(frame, Common::Point(destBounds.left, destBounds.top));
 				}
 			}
 		}


Commit: be8d719a1a882792d3a28a2eb0f98f9ce442bbfd
    https://github.com/scummvm/scummvm/commit/be8d719a1a882792d3a28a2eb0f98f9ce442bbfd
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-30T14:25:07-04:00

Commit Message:
ACCESS: Fix ending game when a conversation is active

Changed paths:
    engines/access/scripts.cpp



diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp
index 3b03a7a..e74b185 100644
--- a/engines/access/scripts.cpp
+++ b/engines/access/scripts.cpp
@@ -101,7 +101,7 @@ int Scripts::executeScript() {
 
 		assert(_scriptCommand >= 0x80);
 		executeCommand(_scriptCommand - 0x80);
-	} while (!_endFlag);
+	} while (!_endFlag && !_vm->shouldQuit());
 
 	return _returnCode;
 }


Commit: f869019d30bbef118abb140d73bbd6ebc3a5be56
    https://github.com/scummvm/scummvm/commit/f869019d30bbef118abb140d73bbd6ebc3a5be56
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-30T17:17:19-04:00

Commit Message:
ACCESS: Implemented cmdDead

Changed paths:
    engines/access/access.h
    engines/access/amazon/amazon_game.cpp
    engines/access/amazon/amazon_resources.cpp
    engines/access/amazon/amazon_resources.h
    engines/access/data.h
    engines/access/files.cpp
    engines/access/files.h
    engines/access/martian/martian_game.cpp
    engines/access/screen.cpp
    engines/access/screen.h
    engines/access/scripts.cpp
    engines/access/scripts.h
    engines/access/sound.cpp
    engines/access/sound.h



diff --git a/engines/access/access.h b/engines/access/access.h
index 2f557df..725e1fc 100644
--- a/engines/access/access.h
+++ b/engines/access/access.h
@@ -162,6 +162,7 @@ public:
 	int _establishCtrlTblOfs;
 	int _numAnimTimers;
 	TimerList _timers;
+	DeathList _deaths;
 	FontManager _fonts;
 	Common::Array<Common::Rect> _newRects;
 	Common::Array<Common::Rect> _oldRects;
diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp
index ecd9922..712a252 100644
--- a/engines/access/amazon/amazon_game.cpp
+++ b/engines/access/amazon/amazon_game.cpp
@@ -133,7 +133,7 @@ void AmazonEngine::doTitle() {
 	_sound->queueSound(1, 98, 8);
 	_sound->_soundPriority[1] = 1;
 
-	_screen->_loadPalFlag = false;
+	_files->_loadPalFlag = false;
 	_files->loadScreen(0, 3);
 	
 	_buffer2.copyFrom(*_screen);
@@ -147,7 +147,7 @@ void AmazonEngine::doTitle() {
 
 	_sound->playSound(1);
 
-	_screen->_loadPalFlag = false;
+	_files->_loadPalFlag = false;
 	_files->loadScreen(0, 4);
 	_sound->playSound(1);
 
@@ -192,6 +192,16 @@ void AmazonEngine::setupGame() {
 		_timers.push_back(te);
 	}
 
+	// Load death list
+	_deaths.resize(58);
+	for (int i = 0; i < 58; ++i) {
+		_deaths[i]._screenId = DEATH_SCREENS[i];
+		_deaths[i]._msg = DEATH_TEXT[i];
+	}
+	_deaths._cells.resize(12);
+	for (int i = 0; i < 12; ++i)
+		_deaths._cells[i] = CellIdent(DEATH_CELLS[i][0], DEATH_CELLS[i][1], DEATH_CELLS[i][2]);
+
 	// Miscellaneous
 	_fonts._font1.load(FONT6x6_INDEX, FONT6x6_DATA);
 	_fonts._font2.load(FONT2_INDEX, FONT2_DATA);
diff --git a/engines/access/amazon/amazon_resources.cpp b/engines/access/amazon/amazon_resources.cpp
index 1f666e1..a514575 100644
--- a/engines/access/amazon/amazon_resources.cpp
+++ b/engines/access/amazon/amazon_resources.cpp
@@ -1194,6 +1194,126 @@ YOU CAN UNDERSTAND.";
 const char *const NO_HINTS_MESSAGE =
 	"THE HELP SYSTEM HAS BEEN TURNED OFF FOR THIS GAME.";
 
+
+const byte DEATH_SCREENS[58] = {
+	0,  1,  0,  0,  0,  0,  0,  0,  2,  0,
+	0,  2,  4,  2,  1,  0,  0,  0,  0,  0,
+	0,  2,  7,  7,  4,  6,  7, 10,  4,  2,
+	0,  0,  0,  0,  5,  5,  3,  3,  3,  5,
+	8,  8, 11,  9,  8, 12,  0,  1,  9,  8,
+	8,  0,  5,  8,  0, 12, 12,  11
+};
+
+const char *const DEATH_TEXT[58] = {
+	"SAM SALVADOR SPOTS YOU AND LETS YOU HAVE IT.",
+	"WHILE TAKING A MOONLIGHT SWIM YOU DISCOVER THAT PIRANHA REALLY CAN STRIP FLESH TO THE BONE.",
+	"THE GUARD FILLS YOU FULL OF HOLES BEFORE TOSSING YOU TO THE PIRANHA.",
+	"YOU'RE ONLY ABLE TO SWIM HALFWAY ACROSS THE RIVER BEFORE RUNNING OUT OF AIR.  "
+		"YOU MAKE SO MUCH NOISE GASPING FOR BREATH THAT SAM EASILY FINDS YOU AND LEAVES "
+		"YOU IN THE RIVER PERMANENTLY.",
+	"SAM SALVADOR NOTICES SOMEONE HAS BEEN PLAYING WITH THE CARGO.  "
+		"HE TRACKS YOU DOWN AND LETS YOU HAVE IT.",
+	"THE GUARD COMES AROUND THE CORNER.  HE DECIDES THAT THREE LEAD SLUGS WILL "
+		"TEACH YOU TO BE MORE POLITE.",
+	"THE CAPTAIN IS WAITING OUTSIDE THE DOOR.",
+	"THE CAPTAIN'S RANDOM SHOOTING FINALLY FINDS ITS TARGET.",
+	"THE CRATE OUTSIDE THE WINDOW EXPLODES, DESTROYING THE SHIP.  "
+		"UNFORTUNATELY, YOU'RE STILL ABOARD.",
+	"THE DOOR WAS NOT BARRED AND THE CAPTAIN WALKS RIGHT IN AND PARTS YOUR HAIR.",
+
+	"",
+	"YOU RUN OUT ON DECK, THEN REALIZE THAT MAYA IS STILL TIED UP.  "
+		"AS YOU TURN TO GO BACK THE BOAT BLOWS UP.",
+	"AFTER YOU FAIL TO PROVE YOUR DIVINITY THE NATIVES EAT YOU FOR LUNCH.",
+	"THIS IS THE GENERIC DEATH SCENE",
+	"YOU ONLY MAKE IT HALFWAY ACROSS THE RIVER BEFORE THE PIRANHA STRIKE.",
+	"WITH NOTHING TO PROTECT HIM FROM THE HAIL OF BULLETS ALLEN IS QUICKLY GUNNED DOWN.  "
+		"JASON AND MAYA SOON FOLLOW...",
+	"THE COMBINATION OF THE WIND AND GUNFIRE KNOCK THE CORRUGATED IRON OVER, "
+		"LEAVING YOU WITHOUT PROTECTION.",
+	"WITHOUT SUFFICIENT AMMUNITION, ALLEN IS UNABLE TO HOLD OFF THE ATTACKERS FOR LONG.  "
+		"THIS RESULTS IN A SERIOUS CASE OF LEAD POISONING.  ADDITIONAL AMMUNITION SHOULD "
+		"HAVE BEEN PURCHASED AT THE RIO BLANCO TRADING POST (CHAPTER 6).",
+	"ALLEN IS A MARVELOUS SHOT, BUT HIS AMMUNITION IS NOT UNLIMITED.  "
+		"SOON IT IS ALL OVER.",
+	"THE PILOT FEELS YOU ARE TOO CLOSE AND PULLS THE TRIGGER.",
+
+	"THE PILOT SHOOTS YOU IN THE HEART, THEN TOSSES YOUR LIFELESS BODY OUT THE DOOR.",
+	"THE PLANE CRASHES INTO THE JUNGLE CANOPY AT 200 MPH.",
+	"THE CANOE HITS THE ROCKS AND CAPSIZES, AND THE PIRANHA MAKE YOU THEIR LUNCH GUESTS.",
+	"YOU TAKE THE WRONG BRANCH AND ACCIDENTALLY DISCOVER THE FOURTH TALLEST WATERFALL "
+		"IN SOUTH AMERICA.",
+	"YOU TAKE THE WRONG BRANCH AND DISCOVER A VERY HUNGRY TRIBE OF CANNIBALS.",
+	"YOU TAKE THE WRONG BRANCH AND BECOME LOST IN THE WINDING WATERWAYS.  "
+		"YOU WANDER UNTIL YOU STARVE TO DEATH.",
+	"YOU TAKE THE WRONG BRANCH AND BECOME TRAPPED IN THE RAPIDS.  "
+		"EVENTUALLY YOU AND MAYA ARE CRUSHED BETWEEN THE ROCKS.",
+	"YOU WAIT AROUND FOR SOME TIME, BUT HANS STROHEIM NEVER SPEAKS TO YOU AGAIN.  "
+		"FINALLY YOU RETURN HOME KNOWING YOU HAVE FAILED.",
+	"DECIDING THAT YOU THREATEN HIM AND HIS WORK, HANS STROHEIM HAS THE NATIVES "
+		"IN THE VILLAGE KILL YOU.",
+	"YOU DO NOT GET FAR ENOUGH AWAY BEFORE THE DYNAMITE EXPLODES AND YOU ARE BLOWN "
+		"INTO A THOUSAND PIECES.",
+
+	"YOU ARE STANDING SO CLOSE TO THE ENTRANCE WHEN SANCEZ AND HIS MEN BREAK THROUGH "
+		"THE WALL THAT YOU ARE QUICKLY SPOTTED AND SHOT",
+	"THE AMAZON SENTINELS SPOT YOU AND FILL YOU FULL OF ARROWS.",
+	"SAM MAY BE UGLY, BUT HE'S NOT DEAF.  HE HEARS ALL THE NOISE YOU ARE MAKING AND "
+		"CANCELS YOUR BOARDING PASS.",
+	"WITH THE BAR OFF THE DOOR THE CAPTAIN WALTZES IN AND BLOWS YOU AWAY",
+	"THE BEAR WANDERS OFF INTO THE WOODS AND DISTURBS THE TWO LOVEBIRDS.  "
+		"WHEN THEY COME OUT THEY FIND YOU AND PUT YOU IN THE BIG HOUSE FOR TWENTY YEARS.",
+	"WHEN YOU DO NOT LEAVE THE SECURITY AREA QUICKLY ENOUGH YOU ARE ARRESTED AND CONVICTED "
+		"AS A COMMIE SPY.  YOU EMBARK ON A NEW CAREER STAMPING OUT LICENSE PLATES.",
+	"THE HUNGRY BEAR SPOTS YOU AND DECIDES YOU WILL MAKE A NICE APPETIZER.",
+	"YOU DISTURB THE BEAR'S LUNCH AND HE EATS YOU FOR DESSERT.",
+	"AFTER FAILING TO FIND ANY LUNCH AT THE GARBAGE CAN THE BEAR EATS YOU INSTEAD.",
+	"THE SUSPICIOUS LIBRARIAN CALLS SECURITY AND YOU ARE SENT TO JAIL.",
+
+	"YOU PLUMMET 10,000 FEET TO YOUR DEATH.",
+	"EL LOCO FLIES INTO AN INSANE RAGE AND BEATS YOU TO A BLOODY PULP.",
+	"THE WOMAN WALKS OUT THE DOOR AND NEVER RETURNS.  YOU SPEND THE REST OF YOUR LIFE "
+		"IN A FUTILE ATTEMPT TO LOCATE ALLEN.",
+	"YOU SLIP OFF THE PLATFORM AND FALL TO YOUR DEATH.",
+	"YOU SLIP OFF THE PLATFORM AND FALL TO YOUR DEATH.",
+	"YOU COME TOO CLOSE TO THE POWERFUL JAWS OF THE ANT AND HE SNIPS YOU IN TWO BEFORE "
+		"DEVOURING YOU.",
+	"B.O.B. HAS A FLAW IN HIS PROGRAMMING THAT DIRECTS HIM TO SHOOT FIRST AND ASK QUESTIONS LATER.",
+	"THE PLANE SINKS AND THE PIRHANA ATTACK BEFORE YOU EVEN GET OUT THE DOOR.",
+	"MAYA FALLS OFF THE END OF THE BROKEN BRIDGE.",
+	"YOUR WEIGHT IS JUST ENOUGH TO CAUSE THE REMAINING SUPPORT CABLE TO SNAP AND YOU "
+		"FALL TO THE BOTTOM OF THE GORGE.",
+	
+	"EVEN WITH REPAIRS THE BRIDGE IS NOT STRONG ENOUGH TO HOLD TWO PEOPLE.",
+	"SANCHEZ AND HIS MEN FIND YOU AND HOLD FIRING SQUAD PRACTICE.",
+	"THE TWO GUARDS ARE DISTURBED IN THEIR LOVE NEST AND COME LOOKING FOR ANYONE ACTING SUSPICIOUS.  "
+		"THEY FIND YOU AND SEND YOU UP THE RIVER.",
+	"THE PARACHUTE IS NOT LARGE ENOUGH TO SUPPORT YOU, AND YOU HIT THE TREES AT 140 M.P.H.",
+	"SANCHEZ AND HIS MEN FOLLOW YOU ACROSS THE BRIDGE AND CUT YOU DOWN IN A HAIL OF GUNFIRE",
+	"YOU TRIED TO STAB THE ANT BUT HIS SHELL IS TOO DIFFICULT TO PENETRATE.  "
+		"YOU NOTICE A SLIGHT CUT IN THE SHELL UNDERNEATH BUT YOU CAN'T GET TO IT "
+		"AND HE SNIPS YOU INTO DELICIOUS MEATY CHUNKS.",
+	"AFTER THE ANT FINISHES SUCKING ALL OF THE SAP OUT OF THE VINE HE TURNS HIS ATTENTION BACK TO YOU "
+		"AND BITES YOUR HEAD OFF.",
+	"THE CANTINA OWNER NOTICES YOU ARE TRYING TO STEAL OBJECTS FROM THE TABLES.  "
+		"TWENTY YEARS LATER YOU ARE RELEASED FROM A SOUTH AMERICAN PRISON."
+};
+
+const int DEATH_CELLS[12][3] = {
+	{ 0, 94, 3 },
+	{ 0, 94, 4 },
+	{ 0, 94, 5 },
+	{ 0, 94, 6 },
+	{ 0, 94, 7 },
+	{ 0, 94, 8 },
+	{ 0, 94, 9 },
+	{ 0, 94, 10 },
+	{ 0, 94, 11 },
+	{ 0, 94, 12 },
+	{ 0, 94, 13 },
+	{ 0, 94, 14 }
+};
+
 } // End of namespace Amazon
 
 } // End of namespace Access
diff --git a/engines/access/amazon/amazon_resources.h b/engines/access/amazon/amazon_resources.h
index d618ca5..17cca2a 100644
--- a/engines/access/amazon/amazon_resources.h
+++ b/engines/access/amazon/amazon_resources.h
@@ -52,6 +52,12 @@ extern const byte FONT6x6_DATA[];
 extern const char *const NO_HELP_MESSAGE;
 extern const char *const NO_HINTS_MESSAGE;
 
+extern const byte DEATH_SCREENS[58];
+
+extern const char *const DEATH_TEXT[58];
+
+extern const int DEATH_CELLS[12][3];
+
 } // End of namespace Amazon
 
 } // End of namespace Access
diff --git a/engines/access/data.h b/engines/access/data.h
index 3b3485e..08fbb40 100644
--- a/engines/access/data.h
+++ b/engines/access/data.h
@@ -88,6 +88,16 @@ public:
 	FileIdent _vidSound;
 };
 
+struct DeathEntry {
+	int _screenId;
+	Common::String _msg;
+};
+
+class DeathList : public Common::Array<DeathEntry> {
+public:
+	Common::Array<CellIdent> _cells;
+};
+
 } // End of namespace Access
 
 #endif /* ACCESS_DATA_H */
diff --git a/engines/access/files.cpp b/engines/access/files.cpp
index 4ab98a2..c449d90 100644
--- a/engines/access/files.cpp
+++ b/engines/access/files.cpp
@@ -84,6 +84,7 @@ FileManager::FileManager(AccessEngine *vm): _vm(vm) {
 	}
 
 	_fileNumber = -1;
+	_loadPalFlag = true;
 }
 
 FileManager::~FileManager() {
@@ -135,7 +136,11 @@ void FileManager::loadScreen(Graphics::Surface *dest, int fileNum, int subfile)
 }
 
 void FileManager::handleScreen(Graphics::Surface *dest, Resource *res) {
-	_vm->_screen->loadPalette(res->_stream);
+	if (_loadPalFlag) {
+		_vm->_screen->loadPalette(res->_stream);
+	} else {
+		res->_stream->skip(PALETTE_SIZE);
+	}
 
 	// The remainder of the file after the palette may be separately compressed,
 	// so call handleFile to handle it if it is
diff --git a/engines/access/files.h b/engines/access/files.h
index 0a934de..a32ebbf 100644
--- a/engines/access/files.h
+++ b/engines/access/files.h
@@ -94,6 +94,7 @@ private:
 public:
 	int _fileNumber;
 	Common::Array<uint32> _fileIndex;
+	bool _loadPalFlag;
 public:
 	FileManager(AccessEngine *vm);
 	~FileManager();
diff --git a/engines/access/martian/martian_game.cpp b/engines/access/martian/martian_game.cpp
index 969267f..2f11d8b 100644
--- a/engines/access/martian/martian_game.cpp
+++ b/engines/access/martian/martian_game.cpp
@@ -98,7 +98,7 @@ void MartianEngine::doTitle() {
 	_sound->queueSound(0, 98, 30);
 	_sound->_soundPriority[0] = 1;
 
-	_screen->_loadPalFlag = false;
+	_files->_loadPalFlag = false;
 	_files->loadScreen(0, 3);
 	
 	_buffer2.copyFrom(*_screen);
@@ -112,7 +112,7 @@ void MartianEngine::doTitle() {
 
 	_sound->playSound(1);
 
-	_screen->_loadPalFlag = false;
+	_files->_loadPalFlag = false;
 	_files->loadScreen(0, 4);
 	_sound->playSound(1);
 
diff --git a/engines/access/screen.cpp b/engines/access/screen.cpp
index 26dd2e9..227d9d7 100644
--- a/engines/access/screen.cpp
+++ b/engines/access/screen.cpp
@@ -49,7 +49,6 @@ Screen::Screen(AccessEngine *vm) : _vm(vm) {
 	_vesaCurrentWin = 0;
 	_currentPanel = 0;
 	_hideFlag = true;
-	_loadPalFlag = false;
 	_startColor = _numColors = 0;
 	_scrollCol = _scrollRow = 0;
 	_windowXAdd = _windowYAdd = 0;
@@ -100,7 +99,7 @@ void Screen::setInitialPalettte() {
 void Screen::loadPalette(Common::SeekableReadStream *stream) {
 	loadRawPalette(stream);
 	setPalette();
-	_loadPalFlag = true;
+	_vm->_files->_loadPalFlag = true;
 }
 
 void Screen::loadPalette(int fileNum, int subfile) {
diff --git a/engines/access/screen.h b/engines/access/screen.h
index 47e03de..b278062 100644
--- a/engines/access/screen.h
+++ b/engines/access/screen.h
@@ -64,7 +64,6 @@ private:
 	void updatePalette();
 public:
 	int _vesaMode;
-	bool _loadPalFlag;
 	int _startColor, _numColors;
 	Common::Point _bufferStart;
 	int _scrollCol, _scrollRow;
diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp
index e74b185..8ac0de7 100644
--- a/engines/access/scripts.cpp
+++ b/engines/access/scripts.cpp
@@ -133,7 +133,7 @@ void Scripts::executeCommand(int commandIndex) {
 		&Scripts::cmdFreeSound, &Scripts::cmdSetVideoSound, &Scripts::cmdPlayVideoSound,
 		&Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, 
 		&Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, &Scripts::cmdPlayerOff, 
-		&Scripts::cmdPlayerOn, &Scripts::CMDDEAD, &Scripts::cmdFadeOut,
+		&Scripts::cmdPlayerOn, &Scripts::cmdDead, &Scripts::cmdFadeOut,
 		&Scripts::CMDENDVID
 	};
 
@@ -740,7 +740,73 @@ void Scripts::cmdPlayerOn() {
 	_vm->_player->_playerOff = false;
 }
 
-void Scripts::CMDDEAD() { error("TODO CMDDEAD"); }
+void Scripts::cmdDead() { 
+	int deathId = _data->readByte();
+	_vm->_events->hideCursor();
+	_vm->_screen->forceFadeOut();
+	cmdFreeSound();
+
+	_vm->_sound->_soundTable[0] = _vm->_files->loadFile(98, 44);
+	_vm->_sound->_soundPriority[1] = 1;
+	
+	_vm->_screen->clearScreen();
+	_vm->_screen->setPanel(3);
+
+	if (deathId != 10) {
+		_vm->_sound->newMusic(62, 0);
+		_vm->_files->_loadPalFlag = false;
+		_vm->_files->loadScreen(94, 0);
+		_vm->_files->_loadPalFlag = true;
+		_vm->_buffer2.copyFrom(*_vm->_screen);
+
+		for (int i = 0; i < 3; ++i) {
+			_vm->_sound->playSound(0);
+			_vm->_screen->forceFadeIn();
+			_vm->_sound->playSound(0);
+			_vm->_screen->forceFadeOut();
+		}
+		_vm->freeCells();
+
+		// Load the cell list for the death screen
+		DeathEntry &de = _vm->_deaths[deathId];
+		Common::Array<CellIdent> cells;
+		cells.push_back(_vm->_deaths._cells[de._screenId]);
+		_vm->loadCells(cells);
+
+		_vm->_screen->setDisplayScan();
+		_vm->_files->_loadPalFlag = false;
+		_vm->_files->loadScreen(&_vm->_buffer2, 94, 1);
+		_vm->_screen->setIconPalette();
+
+		_vm->_buffer2.plotImage(_vm->_objectsTable[0], 0, Common::Point(105, 25));
+		_vm->_buffer2.copyTo(_vm->_screen);
+		_vm->_screen->forceFadeIn();
+
+		_vm->_fonts._charSet._hi = 10;
+		_vm->_fonts._charSet._lo = 1;
+		_vm->_fonts._charFor._lo = 55;
+		_vm->_fonts._charFor._hi = 255;
+		_vm->_screen->_maxChars = 46;
+		_vm->_screen->_printOrg = Common::Point(20, 155);
+		_vm->_screen->_printStart = Common::Point(20, 155);
+
+		Common::String &msg = de._msg;
+		_vm->_printEnd = 180;
+		_vm->_fonts._font2.printText(_vm->_screen, msg);
+		_vm->_screen->forceFadeOut();
+
+		_vm->_sound->newMusic(0, 1);
+		_vm->_events->showCursor();
+		_vm->_room->clearRoom();
+		_vm->freeChar();
+
+		warning("TODO: restart game");
+		_vm->quitGame();
+	}
+	else {
+		_vm->quitGame();
+	}
+}
 
 void Scripts::cmdFadeOut() {
 	_vm->_screen->forceFadeOut();
diff --git a/engines/access/scripts.h b/engines/access/scripts.h
index 733c7f9..003f441 100644
--- a/engines/access/scripts.h
+++ b/engines/access/scripts.h
@@ -119,7 +119,7 @@ protected:
 	void CMDPUSHLOCATION();
 	void cmdPlayerOff();
 	void cmdPlayerOn();
-	void CMDDEAD();
+	void cmdDead();
 	void cmdFadeOut();
 	void CMDENDVID();
 public:
diff --git a/engines/access/sound.cpp b/engines/access/sound.cpp
index 91910f2..0cdb380 100644
--- a/engines/access/sound.cpp
+++ b/engines/access/sound.cpp
@@ -93,6 +93,10 @@ void SoundManager::freeSounds() {
 	// TODO
 }
 
+void SoundManager::newMusic(int musicId, int mode) {
+	warning("TODO: newMusic");
+}
+
 void SoundManager::freeMusic() {
 	delete _music;
 	_music = nullptr;
diff --git a/engines/access/sound.h b/engines/access/sound.h
index 1a94c46..ad1688a 100644
--- a/engines/access/sound.h
+++ b/engines/access/sound.h
@@ -67,6 +67,8 @@ public:
 
 	void freeSounds();
 
+	void newMusic(int musicId, int mode);
+
 	void freeMusic();
 };
 


Commit: adddb1377d927403abc406c09f1d76ac5700188a
    https://github.com/scummvm/scummvm/commit/adddb1377d927403abc406c09f1d76ac5700188a
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-30T17:44:40-04:00

Commit Message:
ACCESS: Fix loading sound in cmdLoadSound

Changed paths:
    engines/access/scripts.cpp



diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp
index 8ac0de7..2fdb91e 100644
--- a/engines/access/scripts.cpp
+++ b/engines/access/scripts.cpp
@@ -688,8 +688,11 @@ void Scripts::cmdClearBlock() {
 
 void Scripts::cmdLoadSound() {
 	int idx = _data->readSint16LE();
-	_vm->_sound->_soundTable[0] = _vm->_files->loadFile(_vm->_extraCells[idx]._vidSound);
-	_vm->_sound->_soundPriority[0] = 1;
+
+	_vm->_sound->_soundTable.clear();
+	_vm->_sound->_soundPriority.clear();
+	_vm->_sound->_soundTable.push_back(_vm->_files->loadFile(_vm->_extraCells[idx]._vidSound));
+	_vm->_sound->_soundPriority.push_back(1);
 }
 
 void Scripts::cmdFreeSound() { 


Commit: aa755b9f3ff93e1e0918abe77b2a49b2e203e2a5
    https://github.com/scummvm/scummvm/commit/aa755b9f3ff93e1e0918abe77b2a49b2e203e2a5
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-08-31T01:06:50+02:00

Commit Message:
ACCESS: Fix loadEstablish for the CD version

Changed paths:
    engines/access/amazon/amazon_game.cpp



diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp
index 712a252..8fbc4cf 100644
--- a/engines/access/amazon/amazon_game.cpp
+++ b/engines/access/amazon/amazon_game.cpp
@@ -235,19 +235,19 @@ void AmazonEngine::loadEstablish(int sub) {
 		_eseg = _files->loadFile("ETEXT.DAT");
 	}
 
-	_establishCtrlTblOfs = READ_LE_UINT16(_eseg);
+	_establishCtrlTblOfs = READ_LE_UINT16(_eseg->data());
 
 	int ofs = _establishCtrlTblOfs + (sub * 2);
-	int idx = READ_LE_UINT16(_eseg + ofs);
-	_narateFile = READ_LE_UINT16(_eseg + idx);
-	_txtPages = READ_LE_UINT16(_eseg + idx + 2);
+	int idx = READ_LE_UINT16(_eseg->data() + ofs);
+	_narateFile = READ_LE_UINT16(_eseg->data() + idx);
+	_txtPages = READ_LE_UINT16(_eseg->data() + idx + 2);
 
 	if (!_txtPages)
 		return;
 
-	_sndSubFile = READ_LE_UINT16(_eseg + idx + 4);
+	_sndSubFile = READ_LE_UINT16(_eseg->data() + idx + 4);
 	for (int i = 0; i < _txtPages; ++i)
-		_countTbl[i] = READ_LE_UINT16(_eseg + idx + 6 + (2 * i));
+		_countTbl[i] = READ_LE_UINT16(_eseg->data() + idx + 6 + (2 * i));
 }
 
 void AmazonEngine::doEstablish(int esatabIndex, int sub) {
@@ -278,12 +278,12 @@ void AmazonEngine::doEstablish(int esatabIndex, int sub) {
 
 	_printEnd = 155;
 	if (_txtPages == 0) {
-		Common::String msg((const char *)_eseg + msgOffset);
+		Common::String msg((const char *)_eseg->data() + msgOffset);
 		_fonts._font2.printText(_screen, msg);
 	} else {
 		Common::Array<Common::String> msgArr;
 		for (int i = 0; i < _txtPages; ++i) {
-			Common::String msg((const char *)_eseg + msgOffset);
+			Common::String msg((const char *)_eseg->data() + msgOffset);
 			msgOffset += msg.size() + 1;
 			msgArr.push_back(msg);
 		}
@@ -293,7 +293,7 @@ void AmazonEngine::doEstablish(int esatabIndex, int sub) {
 	_screen->forceFadeOut();
 	_screen->clearScreen();
 
-	free(_eseg);
+	delete _eseg;
 	if (_establishMode == 0)
 		_room->init4Quads();
 }


Commit: 2cc6d9299ae6a7037704dd72eeebc44ab2c3c1b4
    https://github.com/scummvm/scummvm/commit/2cc6d9299ae6a7037704dd72eeebc44ab2c3c1b4
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-08-31T01:09:29+02:00

Commit Message:
ACCESS: Add a check to work around a difference in hardcoded data between the CD and the floppy version

Changed paths:
    engines/access/room.cpp
    engines/access/room.h



diff --git a/engines/access/room.cpp b/engines/access/room.cpp
index c26a811..3696a4c 100644
--- a/engines/access/room.cpp
+++ b/engines/access/room.cpp
@@ -162,7 +162,7 @@ void Room::clearRoom() {
 }
 
 void Room::loadRoomData(const byte *roomData) {
-	RoomInfo roomInfo(roomData, _vm->getGameID());
+	RoomInfo roomInfo(roomData, _vm->getGameID(), _vm->isCD());
 
 	_roomFlag = roomInfo._roomFlag;
 
@@ -734,14 +734,19 @@ bool Room::checkCode(int v1, int v2) {
 
 /*------------------------------------------------------------------------*/
 
-RoomInfo::RoomInfo(const byte *data, int gameType) {
+RoomInfo::RoomInfo(const byte *data, int gameType, bool isCD) {
 	Common::MemoryReadStream stream(data, 999);
 
 	_roomFlag = stream.readByte();
 
-	if (gameType != GType_MartianMemorandum)
-		_estIndex = stream.readSint16LE();
-	else
+	if (gameType == GType_Amazon) {
+		if (isCD)
+			_estIndex = stream.readSint16LE();
+		else {
+			_estIndex = -1;
+			stream.readSint16LE();
+		}
+	} else
 		_estIndex = -1;
 
 	_musicFile.load(stream);
@@ -779,8 +784,7 @@ RoomInfo::RoomInfo(const byte *data, int gameType) {
 		_extraCells.push_back(ec);
 	}
 
-	for (int16 fileNum = stream.readSint16LE(); fileNum != -1;
-		fileNum = stream.readSint16LE()) {
+	for (int16 fileNum = stream.readSint16LE(); fileNum != -1; fileNum = stream.readSint16LE()) {
 		SoundIdent fi;
 		fi._fileNum = fileNum;
 		fi._subfile = stream.readUint16LE();
diff --git a/engines/access/room.h b/engines/access/room.h
index 321ace4..fdeccc8 100644
--- a/engines/access/room.h
+++ b/engines/access/room.h
@@ -191,7 +191,7 @@ public:
 	Common::Array<ExtraCell> _extraCells;
 	Common::Array<SoundIdent> _sounds;
 public:
-	RoomInfo(const byte *data, int gameType);
+	RoomInfo(const byte *data, int gameType, bool isCD);
 };
 
 } // End of namespace Access


Commit: 469e3273608d71964da8b1f492e9c66ba9194752
    https://github.com/scummvm/scummvm/commit/469e3273608d71964da8b1f492e9c66ba9194752
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-08-31T01:11:44+02:00

Commit Message:
ACCESS: Add a safeguard to avoid a potential issue when alternating stream and raw data use

Changed paths:
    engines/access/files.cpp



diff --git a/engines/access/files.cpp b/engines/access/files.cpp
index c449d90..d8823c0 100644
--- a/engines/access/files.cpp
+++ b/engines/access/files.cpp
@@ -62,8 +62,10 @@ Resource::~Resource() {
 byte *Resource::data() {
 	if (_data == nullptr) {
 		_data = new byte[_size];
+		int pos = _stream->pos();
 		_stream->seek(0);
 		_stream->read(_data, _size);
+		_stream->seek(pos);
 	}
 
 	return _data;


Commit: 36b87d39cad736f55de62e7c0f6186e234c357e5
    https://github.com/scummvm/scummvm/commit/36b87d39cad736f55de62e7c0f6186e234c357e5
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-30T19:15:34-04:00

Commit Message:
ACCESS: Add a missing ->data() on _eseg

Changed paths:
    engines/access/amazon/amazon_game.cpp



diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp
index 8fbc4cf..ab6fb3f 100644
--- a/engines/access/amazon/amazon_game.cpp
+++ b/engines/access/amazon/amazon_game.cpp
@@ -274,7 +274,7 @@ void AmazonEngine::doEstablish(int esatabIndex, int sub) {
 	_screen->_printOrg = _screen->_printStart = Common::Point(48, 35);
 	loadEstablish(sub);
 	_et = sub;
-	uint16 msgOffset = READ_LE_UINT16(_eseg + (sub * 2) + 2);
+	uint16 msgOffset = READ_LE_UINT16(_eseg->data() + (sub * 2) + 2);
 
 	_printEnd = 155;
 	if (_txtPages == 0) {


Commit: b39d7df7cb754b975bcbfdb523f451f021847e72
    https://github.com/scummvm/scummvm/commit/b39d7df7cb754b975bcbfdb523f451f021847e72
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-30T20:12:12-04:00

Commit Message:
ACCESS: Fix background loading in doEstablish

Changed paths:
    engines/access/amazon/amazon_game.cpp



diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp
index ab6fb3f..d18729a 100644
--- a/engines/access/amazon/amazon_game.cpp
+++ b/engines/access/amazon/amazon_game.cpp
@@ -257,8 +257,8 @@ void AmazonEngine::doEstablish(int esatabIndex, int sub) {
 	_screen->clearScreen();
 	_screen->setPanel(3);
 
-	if (esatabIndex != -1) {
-		_files->loadScreen(95, esatabIndex);
+	if (sub != -1) {
+		_files->loadScreen(95, sub);
 		_buffer2.copyBuffer(_screen);
 	}
 


Commit: 9d3460e9f707b1d53534e45c19e15bbb247eba70
    https://github.com/scummvm/scummvm/commit/9d3460e9f707b1d53534e45c19e15bbb247eba70
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-08-31T02:19:05+02:00

Commit Message:
ACCESS: Implement printText()

Changed paths:
    engines/access/access.cpp
    engines/access/access.h
    engines/access/amazon/amazon_game.cpp
    engines/access/font.cpp
    engines/access/font.h
    engines/access/scripts.cpp



diff --git a/engines/access/access.cpp b/engines/access/access.cpp
index a0de5c8..360d434 100644
--- a/engines/access/access.cpp
+++ b/engines/access/access.cpp
@@ -296,6 +296,35 @@ void AccessEngine::speakText(ASurface *s, Common::Array<Common::String> msgArr)
 	}
 }
 
+void AccessEngine::printText(ASurface *s, Common::String &msg) {
+	Common::String line;
+	int width = 0;
+	while (true) {
+		bool lastLine = _fonts._font2.getLine(msg, s->_maxChars * 6, line, width);
+
+		// Set font colors
+		_fonts._font2._fontColors[0] = 0;
+		_fonts._font2._fontColors[1] = 28;
+		_fonts._font2._fontColors[2] = 29;
+		_fonts._font2._fontColors[3] = 30;
+
+		_fonts._font2.drawString(s, line, s->_printOrg);
+		s->_printOrg = Common::Point(s->_printStart.x, s->_printOrg.y + 9);
+
+		if (lastLine)
+			break;
+
+		_events->waitKeyMouse();
+		_buffer2.copyBuffer(s);
+		s->_printOrg.y = s->_printStart.y;
+
+		if (lastLine)
+			break;
+	}
+	_events->waitKeyMouse();
+}
+
+
 void AccessEngine::plotList() {
 	_player->calcPlayer();
 	plotList1();
diff --git a/engines/access/access.h b/engines/access/access.h
index 725e1fc..42ba49f 100644
--- a/engines/access/access.h
+++ b/engines/access/access.h
@@ -113,8 +113,6 @@ protected:
 	 */
 	void doRoom();
 
-	void speakText(ASurface *s, Common::Array<Common::String>msgArr);
-
 	/**
 	* Support method that generates a savegame name
 	* @param slot		Slot number
@@ -271,6 +269,12 @@ public:
 	void freeChar();
 
 	/**
+	 * Draw a string on a given surface and update text positioning
+	 */
+	void printText(ASurface *s, Common::String &msg);
+	void speakText(ASurface *s, Common::Array<Common::String>msgArr);
+
+	/**
 	 * Load a savegame
 	 */
 	virtual Common::Error loadGameState(int slot);
diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp
index d18729a..f633cd8 100644
--- a/engines/access/amazon/amazon_game.cpp
+++ b/engines/access/amazon/amazon_game.cpp
@@ -231,23 +231,26 @@ void AmazonEngine::loadEstablish(int sub) {
 		_establishGroup = 0;
 
 		_eseg = _files->loadFile(_estTable[oldGroup]);
-	} else {
-		_eseg = _files->loadFile("ETEXT.DAT");
-	}
+		_establishCtrlTblOfs = READ_LE_UINT16(_eseg->data());
 
-	_establishCtrlTblOfs = READ_LE_UINT16(_eseg->data());
+		int ofs = _establishCtrlTblOfs + (sub * 2);
+		int idx = READ_LE_UINT16(_eseg->data() + ofs);
+		_narateFile = READ_LE_UINT16(_eseg->data() + idx);
+		_txtPages = READ_LE_UINT16(_eseg->data() + idx + 2);
 
-	int ofs = _establishCtrlTblOfs + (sub * 2);
-	int idx = READ_LE_UINT16(_eseg->data() + ofs);
-	_narateFile = READ_LE_UINT16(_eseg->data() + idx);
-	_txtPages = READ_LE_UINT16(_eseg->data() + idx + 2);
-
-	if (!_txtPages)
-		return;
+		if (!_txtPages)
+			return;
 
-	_sndSubFile = READ_LE_UINT16(_eseg->data() + idx + 4);
-	for (int i = 0; i < _txtPages; ++i)
-		_countTbl[i] = READ_LE_UINT16(_eseg->data() + idx + 6 + (2 * i));
+		_sndSubFile = READ_LE_UINT16(_eseg->data() + idx + 4);
+		for (int i = 0; i < _txtPages; ++i)
+			_countTbl[i] = READ_LE_UINT16(_eseg->data() + idx + 6 + (2 * i));
+	} else {
+		_establishGroup = 0;
+		_narateFile = 0;
+		_txtPages = 0;
+		_sndSubFile = 0;
+		_eseg = _files->loadFile("ETEXT.DAT");
+	}
 }
 
 void AmazonEngine::doEstablish(int esatabIndex, int sub) {
@@ -279,7 +282,7 @@ void AmazonEngine::doEstablish(int esatabIndex, int sub) {
 	_printEnd = 155;
 	if (_txtPages == 0) {
 		Common::String msg((const char *)_eseg->data() + msgOffset);
-		_fonts._font2.printText(_screen, msg);
+		printText(_screen, msg);
 	} else {
 		Common::Array<Common::String> msgArr;
 		for (int i = 0; i < _txtPages; ++i) {
diff --git a/engines/access/font.cpp b/engines/access/font.cpp
index ba17f19..75add41 100644
--- a/engines/access/font.cpp
+++ b/engines/access/font.cpp
@@ -159,10 +159,6 @@ int Font::drawChar(ASurface *s, char c, Common::Point &pt) {
 	return ch.w;
 }
 
-void Font::printText(ASurface *s, const Common::String &msg) {
-	error("TODO: printText");
-}
-
 /*------------------------------------------------------------------------*/
 
 FontManager::FontManager() {
diff --git a/engines/access/font.h b/engines/access/font.h
index 9285d32..d8517e3 100644
--- a/engines/access/font.h
+++ b/engines/access/font.h
@@ -85,10 +85,6 @@ public:
 	 */
 	int drawChar(ASurface *s, char c, Common::Point &pt);
 
-	/**
-	 * Draw a string on a given surface and update text positioning
-	 */
-	void printText(ASurface *s, const Common::String &msg);
 };
 
 class FontManager {
diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp
index 2fdb91e..0b2150a 100644
--- a/engines/access/scripts.cpp
+++ b/engines/access/scripts.cpp
@@ -795,7 +795,7 @@ void Scripts::cmdDead() {
 
 		Common::String &msg = de._msg;
 		_vm->_printEnd = 180;
-		_vm->_fonts._font2.printText(_vm->_screen, msg);
+		_vm->printText(_vm->_screen, msg);
 		_vm->_screen->forceFadeOut();
 
 		_vm->_sound->newMusic(0, 1);


Commit: c092e0665271541719d34b40da5d856142c42a8e
    https://github.com/scummvm/scummvm/commit/c092e0665271541719d34b40da5d856142c42a8e
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-30T20:31:48-04:00

Commit Message:
ACCESS: Fix parameter usage in doEstablish

Changed paths:
    engines/access/amazon/amazon_game.cpp
    engines/access/amazon/amazon_game.h
    engines/access/room.cpp



diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp
index f633cd8..14ee9bc 100644
--- a/engines/access/amazon/amazon_game.cpp
+++ b/engines/access/amazon/amazon_game.cpp
@@ -253,7 +253,7 @@ void AmazonEngine::loadEstablish(int sub) {
 	}
 }
 
-void AmazonEngine::doEstablish(int esatabIndex, int sub) {
+void AmazonEngine::doEstablish(int estabIndex, int sub) {
 	_establishMode = 1;
 
 	_screen->forceFadeOut();
@@ -275,9 +275,9 @@ void AmazonEngine::doEstablish(int esatabIndex, int sub) {
 
 	_screen->_maxChars = 37;
 	_screen->_printOrg = _screen->_printStart = Common::Point(48, 35);
-	loadEstablish(sub);
-	_et = sub;
-	uint16 msgOffset = READ_LE_UINT16(_eseg->data() + (sub * 2) + 2);
+	loadEstablish(estabIndex);
+	_et = estabIndex;
+	uint16 msgOffset = READ_LE_UINT16(_eseg->data() + (estabIndex * 2) + 2);
 
 	_printEnd = 155;
 	if (_txtPages == 0) {
diff --git a/engines/access/amazon/amazon_game.h b/engines/access/amazon/amazon_game.h
index 6511b37..575b3d1 100644
--- a/engines/access/amazon/amazon_game.h
+++ b/engines/access/amazon/amazon_game.h
@@ -100,7 +100,7 @@ private:
 	void setupGame();
 
 	void loadEstablish(int sub);
-	void doEstablish(int esatabIndex, int sub);
+	void doEstablish(int estabIndex, int sub);
 	void establishCenter(int esatabIndex, int sub);
 
 protected:
diff --git a/engines/access/room.cpp b/engines/access/room.cpp
index 3696a4c..7df7ca9 100644
--- a/engines/access/room.cpp
+++ b/engines/access/room.cpp
@@ -171,7 +171,7 @@ void Room::loadRoomData(const byte *roomData) {
 		_vm->_establishFlag = true;
 		if (_vm->_establishTable[roomInfo._estIndex] != 1) {
 			_vm->_establishTable[roomInfo._estIndex] = 1;
-			_vm->establish(0, roomInfo._estIndex);
+			_vm->establish(roomInfo._estIndex, 0);
 		}
 	}
 


Commit: 78bf011a8b5f9eb25c2b231752c30a3ca239cbc7
    https://github.com/scummvm/scummvm/commit/78bf011a8b5f9eb25c2b231752c30a3ca239cbc7
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-30T20:50:25-04:00

Commit Message:
ACCESS: Fix playSound stub

Changed paths:
    engines/access/sound.cpp
    engines/access/sound.h



diff --git a/engines/access/sound.cpp b/engines/access/sound.cpp
index 0cdb380..001d2f3 100644
--- a/engines/access/sound.cpp
+++ b/engines/access/sound.cpp
@@ -55,11 +55,11 @@ Resource *SoundManager::loadSound(int fileNum, int subfile) {
 }
 
 void SoundManager::playSound(int soundIndex) {
-	int idx = _soundPriority[soundIndex];
-	playSound(_soundTable[idx]);
+	int priority = _soundPriority[soundIndex];
+	playSound(_soundTable[soundIndex], priority);
 }
 
-void SoundManager::playSound(Resource *res) {
+void SoundManager::playSound(Resource *res, int priority) {
 	/*
 	Audio::QueuingAudioStream *audioStream = Audio::makeQueuingAudioStream(22050, false);
 	audioStream->queueBuffer(data, size, DisposeAfterUse::YES, 0);
diff --git a/engines/access/sound.h b/engines/access/sound.h
index ad1688a..3d967c6 100644
--- a/engines/access/sound.h
+++ b/engines/access/sound.h
@@ -41,7 +41,7 @@ private:
 
 	void clearSounds();
 
-	void playSound(Resource *res);
+	void playSound(Resource *res, int priority);
 public:
 	Common::Array<Resource *> _soundTable;
 	Common::Array<int> _soundPriority;


Commit: 2f5fb206d30a77b94aa81feb6b7292c0d3e5e481
    https://github.com/scummvm/scummvm/commit/2f5fb206d30a77b94aa81feb6b7292c0d3e5e481
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-30T21:02:22-04:00

Commit Message:
ACCESS: Further cleanup of doEstablish parameters

Changed paths:
    engines/access/access.cpp
    engines/access/amazon/amazon_game.cpp
    engines/access/amazon/amazon_game.h
    engines/access/char.cpp
    engines/access/room.cpp



diff --git a/engines/access/access.cpp b/engines/access/access.cpp
index 360d434..29b7fd6 100644
--- a/engines/access/access.cpp
+++ b/engines/access/access.cpp
@@ -240,7 +240,7 @@ void AccessEngine::speakText(ASurface *s, Common::Array<Common::String> msgArr)
 			while (true) {
 				_sound->_soundTable[0] = _sound->loadSound(_narateFile + 99, _sndSubFile);
 				_sound->_soundPriority[0] = 1;
-				_sound->playSound(1);
+				_sound->playSound(0);
 				_scripts->cmdFreeSound();
 
 				_events->pollEvents();
diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp
index 14ee9bc..d15587f 100644
--- a/engines/access/amazon/amazon_game.cpp
+++ b/engines/access/amazon/amazon_game.cpp
@@ -212,20 +212,20 @@ void AmazonEngine::setupGame() {
 	_player->_playerY = _player->_rawPlayer.y = TRAVEL_POS[_player->_roomNumber][1];
 }
 
-void AmazonEngine::establish(int esatabIndex, int sub) {
+void AmazonEngine::establish(int screenId, int esatabIndex) {
 	_establishMode = 0;
 	_establishGroup = 0;
-	doEstablish(esatabIndex, sub);
+	doEstablish(screenId, esatabIndex);
 }
 
-void AmazonEngine::establishCenter(int esatabIndex, int sub) {
+void AmazonEngine::establishCenter(int screenId, int esatabIndex) {
 	_establishMode = 1;
-	doEstablish(esatabIndex, sub);
+	doEstablish(screenId, esatabIndex);
 }
 
 const char *const _estTable[] = { "ETEXT0.DAT", "ETEXT1.DAT", "ETEXT2.DAT", "ETEXT3.DAT" };
 
-void AmazonEngine::loadEstablish(int sub) {
+void AmazonEngine::loadEstablish(int estabIndex) {
 	if (!_files->existFile("ETEXT.DAT")) {
 		int oldGroup = _establishGroup;
 		_establishGroup = 0;
@@ -233,7 +233,7 @@ void AmazonEngine::loadEstablish(int sub) {
 		_eseg = _files->loadFile(_estTable[oldGroup]);
 		_establishCtrlTblOfs = READ_LE_UINT16(_eseg->data());
 
-		int ofs = _establishCtrlTblOfs + (sub * 2);
+		int ofs = _establishCtrlTblOfs + (estabIndex * 2);
 		int idx = READ_LE_UINT16(_eseg->data() + ofs);
 		_narateFile = READ_LE_UINT16(_eseg->data() + idx);
 		_txtPages = READ_LE_UINT16(_eseg->data() + idx + 2);
@@ -253,15 +253,15 @@ void AmazonEngine::loadEstablish(int sub) {
 	}
 }
 
-void AmazonEngine::doEstablish(int estabIndex, int sub) {
+void AmazonEngine::doEstablish(int screenId, int estabIndex) {
 	_establishMode = 1;
 
 	_screen->forceFadeOut();
 	_screen->clearScreen();
 	_screen->setPanel(3);
 
-	if (sub != -1) {
-		_files->loadScreen(95, sub);
+	if (screenId != -1) {
+		_files->loadScreen(95, screenId);
 		_buffer2.copyBuffer(_screen);
 	}
 
diff --git a/engines/access/amazon/amazon_game.h b/engines/access/amazon/amazon_game.h
index 575b3d1..3929eb1 100644
--- a/engines/access/amazon/amazon_game.h
+++ b/engines/access/amazon/amazon_game.h
@@ -99,9 +99,9 @@ private:
 	 */
 	void setupGame();
 
-	void loadEstablish(int sub);
-	void doEstablish(int estabIndex, int sub);
-	void establishCenter(int esatabIndex, int sub);
+	void loadEstablish(int estabIndex);
+	void doEstablish(int screenId, int estabIndex);
+	void establishCenter(int screenId, int esatabIndex);
 
 protected:
 	/**
diff --git a/engines/access/char.cpp b/engines/access/char.cpp
index aebf63a..8ce43a5 100644
--- a/engines/access/char.cpp
+++ b/engines/access/char.cpp
@@ -90,7 +90,7 @@ void CharManager::loadChar(int charId) {
 		_vm->_establishFlag = true;
 		if (!_vm->_establishTable[ce._estabIndex]) {
 			_vm->_establishTable[ce._estabIndex] = true;
-			_vm->establish(ce._estabIndex, 0);
+			_vm->establish(0, ce._estabIndex);
 		}
 	}
 
diff --git a/engines/access/room.cpp b/engines/access/room.cpp
index 7df7ca9..3696a4c 100644
--- a/engines/access/room.cpp
+++ b/engines/access/room.cpp
@@ -171,7 +171,7 @@ void Room::loadRoomData(const byte *roomData) {
 		_vm->_establishFlag = true;
 		if (_vm->_establishTable[roomInfo._estIndex] != 1) {
 			_vm->_establishTable[roomInfo._estIndex] = 1;
-			_vm->establish(roomInfo._estIndex, 0);
+			_vm->establish(0, roomInfo._estIndex);
 		}
 	}
 


Commit: b5b298a5d5a6cf461d14c6f48bdd301df803da62
    https://github.com/scummvm/scummvm/commit/b5b298a5d5a6cf461d14c6f48bdd301df803da62
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-30T21:22:11-04:00

Commit Message:
ACCESS: Fix playSound call

Changed paths:
    engines/access/access.cpp



diff --git a/engines/access/access.cpp b/engines/access/access.cpp
index 29b7fd6..55af992 100644
--- a/engines/access/access.cpp
+++ b/engines/access/access.cpp
@@ -275,7 +275,7 @@ void AccessEngine::speakText(ASurface *s, Common::Array<Common::String> msgArr)
 	while(true) {
 		_sound->_soundTable[0] = _sound->loadSound(_narateFile + 99, _sndSubFile);
 		_sound->_soundPriority[0] = 1;
-		_sound->playSound(1);
+		_sound->playSound(0);
 		_scripts->cmdFreeSound();
 
 		_events->pollEvents();


Commit: f8778a5e04b5cc46a898d9d6c570f506e7d3b58c
    https://github.com/scummvm/scummvm/commit/f8778a5e04b5cc46a898d9d6c570f506e7d3b58c
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-30T21:43:24-04:00

Commit Message:
ACCESS: Fix getLine when \r occurs just after maximum line width reached

Changed paths:
    engines/access/font.cpp



diff --git a/engines/access/font.cpp b/engines/access/font.cpp
index 75add41..ffc1715 100644
--- a/engines/access/font.cpp
+++ b/engines/access/font.cpp
@@ -74,6 +74,9 @@ void Font::load(const int *fontIndex, const byte *fontData) {
 }
 
 int Font::charWidth(char c) {
+	if (c < ' ')
+		return 0;
+
 	return _chars[c - ' '].w;
 }
 
@@ -95,7 +98,7 @@ bool Font::getLine(Common::String &s, int maxWidth, Common::String &line, int &w
 	while ((c = *src) != '\0') {
 		if (c == '\r') {
 			// End of line, so return calculated line
-			line = Common::String(s.c_str(), src - 1);
+			line = Common::String(s.c_str(), src);
 			s = Common::String(src + 1);
 			return false;
 		}


Commit: e854ec1bc98efcddc006fbf0078d15f51ffcb264
    https://github.com/scummvm/scummvm/commit/e854ec1bc98efcddc006fbf0078d15f51ffcb264
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-08-30T21:44:28-04:00

Commit Message:
ACCESS: Fix freeing _eseg correctly

Changed paths:
    engines/access/amazon/amazon_game.cpp



diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp
index d15587f..0725863 100644
--- a/engines/access/amazon/amazon_game.cpp
+++ b/engines/access/amazon/amazon_game.cpp
@@ -297,6 +297,8 @@ void AmazonEngine::doEstablish(int screenId, int estabIndex) {
 	_screen->clearScreen();
 
 	delete _eseg;
+	_eseg = nullptr;
+
 	if (_establishMode == 0)
 		_room->init4Quads();
 }


Commit: 984858b6382de2e2788fca1469fb380b036989ba
    https://github.com/scummvm/scummvm/commit/984858b6382de2e2788fca1469fb380b036989ba
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-09-09T23:54:31+02:00

Commit Message:
ACCESS: Fix an issue in checkCode

Changed paths:
    engines/access/room.cpp



diff --git a/engines/access/room.cpp b/engines/access/room.cpp
index 3696a4c..2c59760 100644
--- a/engines/access/room.cpp
+++ b/engines/access/room.cpp
@@ -705,9 +705,10 @@ bool Room::codeWalls() {
 bool Room::checkCode(int v1, int v2) {
 	Player &p = *_vm->_player;
 
-	if (!v1) {
-	} if (!v2 || (v1 == v2)) {
-	} else if (v1 & 1) {
+	if (!v1 || !v2 || (v1 == v2))
+		return false;
+
+	if (v1 & 1) {
 		if (v2 & 2) {
 			p._collideFlag = true;
 			return true;


Commit: 6f03127512a31db27a43e6ca899a909b618fff7f
    https://github.com/scummvm/scummvm/commit/6f03127512a31db27a43e6ca899a909b618fff7f
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-09-11T23:59:17+02:00

Commit Message:
ACCESS: Implement setInactive and mWhile

Changed paths:
    engines/access/amazon/amazon_game.cpp
    engines/access/amazon/amazon_game.h
    engines/access/amazon/amazon_scripts.cpp
    engines/access/amazon/amazon_scripts.h



diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp
index 0725863..66b77d6 100644
--- a/engines/access/amazon/amazon_game.cpp
+++ b/engines/access/amazon/amazon_game.cpp
@@ -37,7 +37,9 @@ AmazonEngine::AmazonEngine(OSystem *syst, const AccessGameDescription *gameDesc)
 		_riverFlag(_flags[185]), _aniOutFlag(_flags[195]), _badEnd(_flags[218]), 
 		_noHints(_flags[219]), _aniFlag(_flags[229]), _allenFlag(_flags[237]), 
 		_noSound(_flags[239]) {
+
 	_skipStart = false;
+	_charSegSwitch = false;
 
 	_canoeLane = 0;
 	_canoeYPos = 0;
diff --git a/engines/access/amazon/amazon_game.h b/engines/access/amazon/amazon_game.h
index 3929eb1..d0f1b2d 100644
--- a/engines/access/amazon/amazon_game.h
+++ b/engines/access/amazon/amazon_game.h
@@ -65,8 +65,6 @@ private:
 	int _topList;
 	int _botList;
 	int _riverIndex;
-	int _rawInactiveX;
-	int _rawInactiveY;
 	int _inactiveYOff;
 	int _esTabTable[100];
 
@@ -114,6 +112,11 @@ protected:
 	*/
 	virtual void synchronize(Common::Serializer &s);
 public:
+	bool _charSegSwitch;
+
+	int _rawInactiveX;
+	int _rawInactiveY;
+
 	// Fields that are mapped to flags
 	int &_guardLocation;
 	int &_guardFind;
diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp
index 104473a..24cd8b9 100644
--- a/engines/access/amazon/amazon_scripts.cpp
+++ b/engines/access/amazon/amazon_scripts.cpp
@@ -34,6 +34,45 @@ AmazonScripts::AmazonScripts(AccessEngine *vm) : Scripts(vm) {
 	_game = (AmazonEngine *)_vm;
 }
 
+void AmazonScripts::mWhile(int param1) {
+	switch(param1) {
+	case 1:
+		warning("TODO MWHILE1");
+		break;
+	case 2:
+		warning("TODO FLY");
+		break;
+	case 3:
+		warning("TODO FALL");
+		break;
+	case 4:
+		warning("TODO JWALK");
+		break;
+	case 5:
+		warning("TODO DOOPEN");
+		break;
+	case 6:
+		warning("TODO DOWNRIVER");
+		break;
+	case 7:
+		warning("MWHILE2");
+		break;
+	case 8:
+		warning("JWALK2");
+		break;
+	default:
+		break;
+	}
+}
+
+void AmazonScripts::setInactive() {
+	_game->_rawInactiveX = _vm->_player->_rawPlayer.x;
+	_game->_rawInactiveY = _vm->_player->_rawPlayer.y;
+	_game->_charSegSwitch = false;
+
+	mWhile(_game->_rawInactiveY);
+}
+
 void AmazonScripts::executeSpecial(int commandIndex, int param1, int param2) {
 	switch (commandIndex) {
 	case 1:
@@ -46,10 +85,10 @@ void AmazonScripts::executeSpecial(int commandIndex, int param1, int param2) {
 		warning("TODO DOCAST");
 		break;
 	case 4:
-		warning("TODO SETINACTIVE");
+		setInactive();
 		break;
 	case 6:
-		warning("TODO MWHILE");
+		mWhile(param1);
 		break;
 	case 9:
 		warning("TODO GUARD");
diff --git a/engines/access/amazon/amazon_scripts.h b/engines/access/amazon/amazon_scripts.h
index 978ef01..45caa5f 100644
--- a/engines/access/amazon/amazon_scripts.h
+++ b/engines/access/amazon/amazon_scripts.h
@@ -39,6 +39,9 @@ protected:
 	virtual void executeSpecial(int commandIndex, int param1, int param2);
 	virtual void executeCommand(int commandIndex);
 
+	void mWhile(int param1);
+	void setInactive();
+
 	void cmdHelp();
 	void CMDCYCLEBACK();
 	void CMDCHAPTER();


Commit: 5016b2e768688d449b3fd9c42e243da61b12b1f4
    https://github.com/scummvm/scummvm/commit/5016b2e768688d449b3fd9c42e243da61b12b1f4
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-09-12T19:23:06+02:00

Commit Message:
ACCESS: Implement a coupld of special commands

Changed paths:
    engines/access/amazon/amazon_scripts.cpp
    engines/access/amazon/amazon_scripts.h



diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp
index 24cd8b9..c5b49ab 100644
--- a/engines/access/amazon/amazon_scripts.cpp
+++ b/engines/access/amazon/amazon_scripts.cpp
@@ -65,6 +65,17 @@ void AmazonScripts::mWhile(int param1) {
 	}
 }
 
+void AmazonScripts::loadBackground(int param1, int param2) {
+	_vm->_files->_loadPalFlag = false;
+	_vm->_files->loadScreen(param1, param2);
+
+	_vm->_buffer2.copyFrom(*_vm->_screen);
+	_vm->_buffer1.copyFrom(*_vm->_screen);
+
+	_vm->_screen->forceFadeOut();
+	
+}
+
 void AmazonScripts::setInactive() {
 	_game->_rawInactiveX = _vm->_player->_rawPlayer.x;
 	_game->_rawInactiveY = _vm->_player->_rawPlayer.y;
@@ -73,13 +84,22 @@ void AmazonScripts::setInactive() {
 	mWhile(_game->_rawInactiveY);
 }
 
+void AmazonScripts::boatWalls(int param1, int param2) {
+	if (param1 == 1)
+		_vm->_room->_plotter._walls[42] = Common::Rect(96, 27, 87, 42);
+	else {
+		_vm->_room->_plotter._walls[39].bottom = _vm->_room->_plotter._walls[41].bottom = 106;
+		_vm->_room->_plotter._walls[40].left = 94;
+	}
+}
+
 void AmazonScripts::executeSpecial(int commandIndex, int param1, int param2) {
 	switch (commandIndex) {
 	case 1:
 		_vm->establish(param1, param2);
 		break;
 	case 2:
-		warning("TODO LOADBACKGROUND");
+		loadBackground(param1, param2);
 		break;
 	case 3:
 		warning("TODO DOCAST");
diff --git a/engines/access/amazon/amazon_scripts.h b/engines/access/amazon/amazon_scripts.h
index 45caa5f..4845863 100644
--- a/engines/access/amazon/amazon_scripts.h
+++ b/engines/access/amazon/amazon_scripts.h
@@ -40,7 +40,9 @@ protected:
 	virtual void executeCommand(int commandIndex);
 
 	void mWhile(int param1);
+	void loadBackground(int param1, int param2);
 	void setInactive();
+	void boatWalls(int param1, int param2);
 
 	void cmdHelp();
 	void CMDCYCLEBACK();


Commit: 7a1650b3d35e767a254e2ffb0d3bb84d358c37f1
    https://github.com/scummvm/scummvm/commit/7a1650b3d35e767a254e2ffb0d3bb84d358c37f1
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-09-12T19:24:42+02:00

Commit Message:
ACCESS: Add missing call to boatWalls

Changed paths:
    engines/access/amazon/amazon_scripts.cpp



diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp
index c5b49ab..7ab4a80 100644
--- a/engines/access/amazon/amazon_scripts.cpp
+++ b/engines/access/amazon/amazon_scripts.cpp
@@ -126,7 +126,7 @@ void AmazonScripts::executeSpecial(int commandIndex, int param1, int param2) {
 		warning("TODO ANT");
 		break;
 	case 15:
-		warning("TODO BOATWALLS");
+		boatWalls(param1, param2);
 		break;
 	default:
 		warning("Unexpected Special code %d - Skipped", commandIndex);


Commit: d37534fa9b5024cf8cb31b7009b1ac75bb660497
    https://github.com/scummvm/scummvm/commit/d37534fa9b5024cf8cb31b7009b1ac75bb660497
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-09-12T23:28:36+02:00

Commit Message:
ACCESS: Implement mWhile1

Changed paths:
    engines/access/amazon/amazon_scripts.cpp
    engines/access/amazon/amazon_scripts.h



diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp
index 7ab4a80..4439a28 100644
--- a/engines/access/amazon/amazon_scripts.cpp
+++ b/engines/access/amazon/amazon_scripts.cpp
@@ -34,6 +34,125 @@ AmazonScripts::AmazonScripts(AccessEngine *vm) : Scripts(vm) {
 	_game = (AmazonEngine *)_vm;
 }
 
+void AmazonScripts::cLoop() {
+	searchForSequence();
+	_vm->_images.clear();
+	_vm->_buffer2.copyFrom(_vm->_buffer1);
+	_vm->_oldRects.clear();
+	_vm->_scripts->executeScript();
+	_vm->plotList1();
+	_vm->copyBlocks();
+}
+
+void AmazonScripts::mWhile1() {
+	_vm->_screen->setDisplayScan();
+	_vm->_screen->fadeOut();
+	_vm->_events->hideCursor();
+
+	_vm->_files->loadScreen(14, 0);
+	_vm->_buffer2.copyFrom(*_vm->_screen);
+	_vm->_buffer1.copyFrom(*_vm->_screen);
+	_vm->_events->showCursor();
+
+	_vm->_screen->setIconPalette();
+	_vm->_screen->forceFadeIn();
+	
+	Resource *spriteData = _vm->_files->loadFile(14, 6);
+	_vm->_objectsTable[0] = new SpriteResource(_vm, spriteData);
+	delete spriteData;
+
+	_vm->_images.clear();
+	_vm->_oldRects.clear();
+	_sequence = 2100;
+
+	do {
+		cLoop();
+		_sequence = 2100;
+	} while (_vm->_flags[52] == 1);
+
+	_vm->_screen->copyFrom(_vm->_buffer1);
+	_vm->_buffer1.copyFrom(_vm->_buffer2);
+
+	_game->establish(-1, 14);
+
+	spriteData = _vm->_files->loadFile(14, 7);
+	_vm->_objectsTable[1] = new SpriteResource(_vm, spriteData);
+	delete spriteData;
+
+	_vm->_sound->playSound(0);
+	_vm->_screen->setDisplayScan();
+	_vm->_events->hideCursor();
+
+	_vm->_files->loadScreen(14, 1);
+	_vm->_screen->setPalette();
+	_vm->_buffer2.copyFrom(*_vm->_screen);
+	_vm->_buffer1.copyFrom(*_vm->_screen);
+	_vm->_events->showCursor();
+
+	_vm->_screen->setIconPalette();
+	_vm->_images.clear();
+	_vm->_oldRects.clear();
+	_sequence = 2200;
+
+	_vm->_sound->queueSound(0, 14, 15);
+	_vm->_sound->_soundPriority[0] = 1;
+
+	do {
+		cLoop();
+		_sequence = 2200;
+	} while (_vm->_flags[52] == 2);
+
+	_vm->_screen->setDisplayScan();
+	_vm->_events->hideCursor();
+
+	_vm->_files->loadScreen(14, 2);
+	_vm->_screen->setPalette();
+	_vm->_buffer2.copyFrom(*_vm->_screen);
+	_vm->_buffer1.copyFrom(*_vm->_screen);
+	_vm->_events->showCursor();
+
+	_vm->_screen->setIconPalette();
+	_vm->freeCells();
+
+	spriteData = _vm->_files->loadFile(14, 8);
+	_vm->_objectsTable[2] = new SpriteResource(_vm, spriteData);
+	delete spriteData;
+
+	_vm->_images.clear();
+	_vm->_oldRects.clear();
+	_sequence = 2300;
+	_vm->_sound->playSound(0);
+
+	do {
+		cLoop();
+		_sequence = 2300;
+	} while (_vm->_flags[52] == 3);
+
+	_vm->freeCells();
+	spriteData = _vm->_files->loadFile(14, 9);
+	_vm->_objectsTable[3] = new SpriteResource(_vm, spriteData);
+	delete spriteData;
+
+	_vm->_screen->setDisplayScan();
+	_vm->_events->hideCursor();
+
+	_vm->_files->loadScreen(14, 3);
+	_vm->_screen->setPalette();
+	_vm->_buffer2.copyFrom(*_vm->_screen);
+	_vm->_buffer1.copyFrom(*_vm->_screen);
+	_vm->_events->showCursor();
+
+	_vm->_screen->setIconPalette();
+	_vm->_images.clear();
+	_vm->_oldRects.clear();
+	_sequence = 2400;
+
+	do {
+		cLoop();
+		_sequence = 2400;
+	} while (_vm->_flags[52] == 4);
+}
+
 void AmazonScripts::mWhile(int param1) {
 	switch(param1) {
 	case 1:
@@ -55,10 +174,10 @@ void AmazonScripts::mWhile(int param1) {
 		warning("TODO DOWNRIVER");
 		break;
 	case 7:
-		warning("MWHILE2");
+		warning("TODO MWHILE2");
 		break;
 	case 8:
-		warning("JWALK2");
+		warning("TODO JWALK2");
 		break;
 	default:
 		break;
diff --git a/engines/access/amazon/amazon_scripts.h b/engines/access/amazon/amazon_scripts.h
index 4845863..735606f 100644
--- a/engines/access/amazon/amazon_scripts.h
+++ b/engines/access/amazon/amazon_scripts.h
@@ -39,6 +39,8 @@ protected:
 	virtual void executeSpecial(int commandIndex, int param1, int param2);
 	virtual void executeCommand(int commandIndex);
 
+	void cLoop();
+	void mWhile1();
 	void mWhile(int param1);
 	void loadBackground(int param1, int param2);
 	void setInactive();


Commit: 9accfdab6f48daa9dbe47de84f0bda84d4103546
    https://github.com/scummvm/scummvm/commit/9accfdab6f48daa9dbe47de84f0bda84d4103546
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-09-16T22:04:10+02:00

Commit Message:
ACCESS: Implement mWhile2 and plotInactive, change _inactive from Resource* to ImageEntry

Changed paths:
    engines/access/access.cpp
    engines/access/access.h
    engines/access/amazon/amazon_game.h
    engines/access/amazon/amazon_room.cpp
    engines/access/amazon/amazon_scripts.cpp
    engines/access/amazon/amazon_scripts.h
    engines/access/martian/martian_room.cpp



diff --git a/engines/access/access.cpp b/engines/access/access.cpp
index 55af992..5636654 100644
--- a/engines/access/access.cpp
+++ b/engines/access/access.cpp
@@ -55,7 +55,9 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc)
 	_mouseMode = 0;
 	_currentMan = 0;
 	_currentManOld = -1;
-	_inactive = nullptr;
+	_inactive._spritesPtr = nullptr;
+	_inactive._flags = _inactive._frameNumber = _inactive._offsetY = 0;
+	_inactive._position = Common::Point(0, 0);
 	_music = nullptr;
 	_title = nullptr;
 	_converseMode = 0;
@@ -127,7 +129,7 @@ AccessEngine::~AccessEngine() {
 	delete _video;
 
 	freeCells();
-	delete _inactive;
+	delete _inactive._spritesPtr;
 	delete _music;
 	delete _title;
 	delete _eseg;
@@ -212,8 +214,8 @@ void AccessEngine::freeCells() {
 }
 
 void AccessEngine::freeInactiveData() {
-	delete _inactive;
-	_inactive = nullptr;
+	delete _inactive._spritesPtr;
+	_inactive._spritesPtr = nullptr;
 }
 
 void AccessEngine::speakText(ASurface *s, Common::Array<Common::String> msgArr) {
diff --git a/engines/access/access.h b/engines/access/access.h
index 42ba49f..157a33c 100644
--- a/engines/access/access.h
+++ b/engines/access/access.h
@@ -171,7 +171,7 @@ public:
 	int _mouseMode;
 
 	int _currentManOld;
-	Resource *_inactive;
+	ImageEntry _inactive;
 	Resource *_music;
 	Resource *_title;
 	int _converseMode;
diff --git a/engines/access/amazon/amazon_game.h b/engines/access/amazon/amazon_game.h
index d0f1b2d..0275cee 100644
--- a/engines/access/amazon/amazon_game.h
+++ b/engines/access/amazon/amazon_game.h
@@ -65,7 +65,6 @@ private:
 	int _topList;
 	int _botList;
 	int _riverIndex;
-	int _inactiveYOff;
 	int _esTabTable[100];
 
 	// Other fields
@@ -116,6 +115,7 @@ public:
 
 	int _rawInactiveX;
 	int _rawInactiveY;
+	int _inactiveYOff;
 
 	// Fields that are mapped to flags
 	int &_guardLocation;
diff --git a/engines/access/amazon/amazon_room.cpp b/engines/access/amazon/amazon_room.cpp
index 227fc47..39cea9a 100644
--- a/engines/access/amazon/amazon_room.cpp
+++ b/engines/access/amazon/amazon_room.cpp
@@ -77,7 +77,9 @@ void AmazonRoom::reloadRoom() {
 void AmazonRoom::reloadRoom1() {
 	if (_vm->_player->_roomNumber == 29 || _vm->_player->_roomNumber == 31 
 			|| _vm->_player->_roomNumber == 42 || _vm->_player->_roomNumber == 44) {
-		_vm->_inactive = _vm->_files->loadFile("MAYA.LZ");
+		Resource *spriteData = _vm->_files->loadFile("MAYA.LZ");
+		_vm->_inactive._spritesPtr = new SpriteResource(_vm, spriteData);
+		delete spriteData;
 		_vm->_currentCharFlag = false;
 	}
 
diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp
index 4439a28..8c17233 100644
--- a/engines/access/amazon/amazon_scripts.cpp
+++ b/engines/access/amazon/amazon_scripts.cpp
@@ -153,10 +153,62 @@ void AmazonScripts::mWhile1() {
 	} while (_vm->_flags[52] == 4);
 }
 
+void AmazonScripts::mWhile2() {
+	_vm->_screen->setDisplayScan();
+	_vm->_screen->fadeOut();
+	_vm->_events->hideCursor();
+
+	_vm->_files->loadScreen(14, 0);
+	_vm->_buffer2.copyFrom(*_vm->_screen);
+	_vm->_buffer1.copyFrom(*_vm->_screen);
+	_vm->_events->showCursor();
+
+	_vm->_screen->setIconPalette();
+	_vm->_screen->forceFadeIn();
+
+	Resource *spriteData = _vm->_files->loadFile(14, 6);
+	_vm->_objectsTable[0] = new SpriteResource(_vm, spriteData);
+	delete spriteData;
+
+	_vm->_images.clear();
+	_vm->_oldRects.clear();
+	_sequence = 2100;
+
+	do {
+		cLoop();
+		_sequence = 2100;
+	} while (_vm->_flags[52] == 1);
+
+	_vm->_screen->fadeOut();
+	_vm->freeCells();
+	spriteData = _vm->_files->loadFile(14, 9);
+	_vm->_objectsTable[3] = new SpriteResource(_vm, spriteData);
+	delete spriteData;
+
+	_vm->_screen->setDisplayScan();
+	_vm->_events->hideCursor();
+
+	_vm->_files->loadScreen(14, 3);
+	_vm->_screen->setPalette();
+	_vm->_buffer2.copyFrom(*_vm->_screen);
+	_vm->_buffer1.copyFrom(*_vm->_screen);
+	_vm->_events->showCursor();
+
+	_vm->_screen->setIconPalette();
+	_vm->_images.clear();
+	_vm->_oldRects.clear();
+	_sequence = 2400;
+
+	do {
+		cLoop();
+		_sequence = 2400;
+	} while (_vm->_flags[52] == 4);
+}
+
 void AmazonScripts::mWhile(int param1) {
 	switch(param1) {
 	case 1:
-		warning("TODO MWHILE1");
+		mWhile1();
 		break;
 	case 2:
 		warning("TODO FLY");
@@ -174,7 +226,7 @@ void AmazonScripts::mWhile(int param1) {
 		warning("TODO DOWNRIVER");
 		break;
 	case 7:
-		warning("TODO MWHILE2");
+		mWhile2();
 		break;
 	case 8:
 		warning("TODO JWALK2");
@@ -212,6 +264,44 @@ void AmazonScripts::boatWalls(int param1, int param2) {
 	}
 }
 
+void AmazonScripts::plotInactive() {
+	if (_game->_charSegSwitch) {
+		_game->_currentCharFlag = true;
+		SpriteResource *tmp = _vm->_inactive._spritesPtr;
+		_vm->_inactive._spritesPtr = _vm->_player->_playerSprites;
+		_vm->_player->_playerSprites = tmp;
+		_game->_charSegSwitch = false;
+	} else if (_game->_jasMayaFlag != _game->_currentCharFlag) {
+		if (_vm->_player->_playerOff) {
+			_game->_jasMayaFlag = _game->_currentCharFlag;
+		} else {
+			_game->_currentCharFlag = _game->_jasMayaFlag;
+			int tmpX = _game->_rawInactiveX;
+			int tmpY = _game->_rawInactiveY;
+			_game->_rawInactiveX = _vm->_player->_rawPlayer.x;
+			_game->_rawInactiveY = _vm->_player->_rawPlayer.y;
+			_vm->_player->_rawPlayer.x = tmpX;
+			_vm->_player->_rawPlayer.y = tmpY;
+			_game->_inactiveYOff = _vm->_player->_playerOffset.y;
+			_vm->_player->calcManScale();
+		}
+	}
+
+	if (_vm->_player->_roomNumber == 44) {
+		warning("CHECKME: Only sets useless(?) flags 155 and 160");
+	}
+
+	_vm->_inactive._flags &= 0xFD;
+	_vm->_inactive._flags &= 0xF7;
+	_vm->_inactive._position.x = _game->_rawInactiveX;
+	_vm->_inactive._position.y = _game->_rawInactiveY - _game->_inactiveYOff;
+	_vm->_inactive._offsetY = _game->_inactiveYOff;
+	_vm->_inactive._frameNumber = 0;
+
+	_vm->_images.addToList(&_vm->_inactive);
+
+}
+
 void AmazonScripts::executeSpecial(int commandIndex, int param1, int param2) {
 	switch (commandIndex) {
 	case 1:
@@ -236,7 +326,7 @@ void AmazonScripts::executeSpecial(int commandIndex, int param1, int param2) {
 		warning("TODO NEWMUSIC");
 		break;
 	case 11:
-		warning("TODO PLOTINACTIVE");
+		plotInactive();
 		break;
 	case 13:
 		warning("TODO RIVER");
diff --git a/engines/access/amazon/amazon_scripts.h b/engines/access/amazon/amazon_scripts.h
index 735606f..7afa0ea 100644
--- a/engines/access/amazon/amazon_scripts.h
+++ b/engines/access/amazon/amazon_scripts.h
@@ -41,8 +41,10 @@ protected:
 
 	void cLoop();
 	void mWhile1();
+	void mWhile2();
 	void mWhile(int param1);
 	void loadBackground(int param1, int param2);
+	void plotInactive();
 	void setInactive();
 	void boatWalls(int param1, int param2);
 
diff --git a/engines/access/martian/martian_room.cpp b/engines/access/martian/martian_room.cpp
index 52eead7..e624b0a 100644
--- a/engines/access/martian/martian_room.cpp
+++ b/engines/access/martian/martian_room.cpp
@@ -75,7 +75,9 @@ void MartianRoom::reloadRoom() {
 void MartianRoom::reloadRoom1() {
 	if (_vm->_player->_roomNumber == 29 || _vm->_player->_roomNumber == 31 
 			|| _vm->_player->_roomNumber == 42 || _vm->_player->_roomNumber == 44) {
-		_vm->_inactive = _vm->_files->loadFile("MAYA.LZ");
+		Resource *spriteData = _vm->_files->loadFile("MAYA.LZ");
+		_vm->_inactive._spritesPtr = new SpriteResource(_vm, spriteData);
+		delete spriteData;
 		_vm->_currentCharFlag = false;
 	}
 


Commit: 2afca5a06eafff24b2892c7270ab994b04ffb8d4
    https://github.com/scummvm/scummvm/commit/2afca5a06eafff24b2892c7270ab994b04ffb8d4
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-09-16T22:12:24+02:00

Commit Message:
ACCESS: Fix bool/int comparisons and assignments

Changed paths:
    engines/access/amazon/amazon_scripts.cpp



diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp
index 8c17233..8d63da2 100644
--- a/engines/access/amazon/amazon_scripts.cpp
+++ b/engines/access/amazon/amazon_scripts.cpp
@@ -271,11 +271,11 @@ void AmazonScripts::plotInactive() {
 		_vm->_inactive._spritesPtr = _vm->_player->_playerSprites;
 		_vm->_player->_playerSprites = tmp;
 		_game->_charSegSwitch = false;
-	} else if (_game->_jasMayaFlag != _game->_currentCharFlag) {
+	} else if (_game->_jasMayaFlag != (_game->_currentCharFlag ? 1 : 0)) {
 		if (_vm->_player->_playerOff) {
-			_game->_jasMayaFlag = _game->_currentCharFlag;
+			_game->_jasMayaFlag = (_game->_currentCharFlag ? 1 : 0);
 		} else {
-			_game->_currentCharFlag = _game->_jasMayaFlag;
+			_game->_currentCharFlag = (_game->_jasMayaFlag == 1);
 			int tmpX = _game->_rawInactiveX;
 			int tmpY = _game->_rawInactiveY;
 			_game->_rawInactiveX = _vm->_player->_rawPlayer.x;


Commit: a597838490981e89ddefcc79fb21127044802b25
    https://github.com/scummvm/scummvm/commit/a597838490981e89ddefcc79fb21127044802b25
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-09-18T08:34:47+02:00

Commit Message:
ACCESS: Implement guard()

Changed paths:
    engines/access/amazon/amazon_scripts.cpp
    engines/access/amazon/amazon_scripts.h



diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp
index 8d63da2..a932dad 100644
--- a/engines/access/amazon/amazon_scripts.cpp
+++ b/engines/access/amazon/amazon_scripts.cpp
@@ -236,6 +236,73 @@ void AmazonScripts::mWhile(int param1) {
 	}
 }
 
+void AmazonScripts::guardSee() {
+	warning("TODO: guardSee()");
+}
+
+void AmazonScripts::setGuardFrame() {
+	warning("TODO: setGuardFrame()");
+}
+
+void AmazonScripts::guard() {
+	if (_vm->_timers[8]._flag != 0)
+		return;
+
+	++_vm->_timers[8]._flag;
+	++_game->_guard._guardCel;
+	int curCel = _game->_guard._guardCel;
+
+	switch (_game->_guardLocation) {
+	case 1:
+		if (curCel <= 8 || curCel > 13)
+			_game->_guard._guardCel = curCel = 8;
+
+		_game->_guard._position.y = _vm->_player->_walkOffDown[curCel - 8];
+		guardSee();
+		if (_game->_guard._position.y >= 272) {
+			_game->_guard._position.y = 272;
+			_game->_guardLocation = 2;
+		}
+		break;
+	case 2:
+		if (curCel <= 43 || curCel > 48)
+			_game->_guard._guardCel = curCel = 43;
+
+		_game->_guard._position.x = _vm->_player->_walkOffLeft[curCel - 43];
+		guardSee();
+		if (_game->_guard._position.x <= 56) {
+			_game->_guard._position.x = 56;
+			_game->_guardLocation = 3;
+		}
+		break;
+	case 3:
+		if (curCel <= 0 || curCel > 5)
+			_game->_guard._guardCel = curCel = 0;
+
+		_game->_guard._position.y = _vm->_player->_walkOffUp[curCel];
+		guardSee();
+		if (_game->_guard._position.y <= 89) {
+			_game->_guard._position.y = 89;
+			_game->_guardLocation = 4;
+			warning("CHECME: unused flag121");
+		}
+		break;
+	default:
+		if (curCel <= 43 || curCel > 48)
+			_game->_guard._guardCel = curCel = 43;
+
+		_game->_guard._position.x = _vm->_player->_walkOffRight[curCel - 43];
+		guardSee();
+		if (_game->_guard._position.x >= 127) {
+			_game->_guard._position.x = 127;
+			_game->_guardLocation = 1;
+		}
+		break;
+	}
+
+	setGuardFrame();
+}
+
 void AmazonScripts::loadBackground(int param1, int param2) {
 	_vm->_files->_loadPalFlag = false;
 	_vm->_files->loadScreen(param1, param2);
@@ -320,7 +387,7 @@ void AmazonScripts::executeSpecial(int commandIndex, int param1, int param2) {
 		mWhile(param1);
 		break;
 	case 9:
-		warning("TODO GUARD");
+		guard();
 		break;
 	case 10:
 		warning("TODO NEWMUSIC");
diff --git a/engines/access/amazon/amazon_scripts.h b/engines/access/amazon/amazon_scripts.h
index 7afa0ea..50bd2ac 100644
--- a/engines/access/amazon/amazon_scripts.h
+++ b/engines/access/amazon/amazon_scripts.h
@@ -43,6 +43,9 @@ protected:
 	void mWhile1();
 	void mWhile2();
 	void mWhile(int param1);
+	void guardSee();
+	void setGuardFrame();
+	void guard();
 	void loadBackground(int param1, int param2);
 	void plotInactive();
 	void setInactive();


Commit: 5a6a44f1c6cc59192ec702ee31a1a0feb881c2e7
    https://github.com/scummvm/scummvm/commit/5a6a44f1c6cc59192ec702ee31a1a0feb881c2e7
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-10-19T14:49:20-04:00

Commit Message:
ACCESS: Wait for keypress in speakText if voice is turned off

Changed paths:
    engines/access/access.cpp
    engines/access/sound.cpp
    engines/access/sound.h



diff --git a/engines/access/access.cpp b/engines/access/access.cpp
index 5636654..2884737 100644
--- a/engines/access/access.cpp
+++ b/engines/access/access.cpp
@@ -274,7 +274,12 @@ void AccessEngine::speakText(ASurface *s, Common::Array<Common::String> msgArr)
 	if (soundsLeft == 0)
 		return;
 
-	while(true) {
+	if (!_sound->_isVoice) {
+		_events->waitKeyMouse();
+		return;
+	}
+
+	for (;;) {
 		_sound->_soundTable[0] = _sound->loadSound(_narateFile + 99, _sndSubFile);
 		_sound->_soundPriority[0] = 1;
 		_sound->playSound(0);
diff --git a/engines/access/sound.cpp b/engines/access/sound.cpp
index 001d2f3..90818ed 100644
--- a/engines/access/sound.cpp
+++ b/engines/access/sound.cpp
@@ -32,6 +32,7 @@ SoundManager::SoundManager(AccessEngine *vm, Audio::Mixer *mixer) :
 	_music = nullptr;
 	_musicRepeat = false;
 	_playingSound = false;
+	_isVoice = false;
 }
 
 SoundManager::~SoundManager() {
diff --git a/engines/access/sound.h b/engines/access/sound.h
index 3d967c6..cc02229 100644
--- a/engines/access/sound.h
+++ b/engines/access/sound.h
@@ -48,6 +48,7 @@ public:
 	Resource *_music;
 	bool _musicRepeat;
 	bool _playingSound;
+	bool _isVoice;
 public:
 	SoundManager(AccessEngine *vm, Audio::Mixer *mixer);
 	~SoundManager();


Commit: 374669d7c3d8b9d3b7207925c90417a4e82f7ed2
    https://github.com/scummvm/scummvm/commit/374669d7c3d8b9d3b7207925c90417a4e82f7ed2
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-12T22:17:45-05:00

Commit Message:
ACCESS: Fix scene establishment paging when there are multiple pages

Changed paths:
    engines/access/access.cpp



diff --git a/engines/access/access.cpp b/engines/access/access.cpp
index 2884737..a97bd6d 100644
--- a/engines/access/access.cpp
+++ b/engines/access/access.cpp
@@ -239,29 +239,34 @@ void AccessEngine::speakText(ASurface *s, Common::Array<Common::String> msgArr)
 		s->_printOrg = Common::Point(s->_printStart.x, s->_printOrg.y + 9);
 
 		if ((s->_printOrg.y > _printEnd) && (!lastLine)) {
-			while (true) {
-				_sound->_soundTable[0] = _sound->loadSound(_narateFile + 99, _sndSubFile);
-				_sound->_soundPriority[0] = 1;
-				_sound->playSound(0);
-				_scripts->cmdFreeSound();
-
-				_events->pollEvents();
-
-				if (_events->_leftButton) {
-					_events->debounceLeft();
-					_sndSubFile += soundsLeft;
-					break;
-				} else if (_events->_keypresses.size() != 0) {
-					_sndSubFile += soundsLeft;
-					break;
-				} else {
-					++_sndSubFile;
-					--soundsLeft;
-					if (soundsLeft == 0)
+			if (!_sound->_isVoice) {
+				_events->waitKeyMouse();
+			} else {
+				for (;;) {
+					_sound->_soundTable[0] = _sound->loadSound(_narateFile + 99, _sndSubFile);
+					_sound->_soundPriority[0] = 1;
+					_sound->playSound(0);
+					_scripts->cmdFreeSound();
+
+					_events->pollEvents();
+
+					if (_events->_leftButton) {
+						_events->debounceLeft();
+						_sndSubFile += soundsLeft;
+						break;
+					} else if (_events->_keypresses.size() != 0) {
+						_sndSubFile += soundsLeft;
 						break;
+					} else {
+						++_sndSubFile;
+						--soundsLeft;
+						if (soundsLeft == 0)
+							break;
+					}
 				}
 			}
-			_buffer2.copyBuffer(s);
+
+			s->copyBuffer(&_buffer2);
 			s->_printOrg.y = s->_printStart.y;
 			++curPage;
 			soundsLeft = _countTbl[curPage];


Commit: e9c003f30648936e58253dca2e72173757d2ff80
    https://github.com/scummvm/scummvm/commit/e9c003f30648936e58253dca2e72173757d2ff80
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-12T22:18:21-05:00

Commit Message:
ACCESS: Fix display of paged text in doEstablish calls

Changed paths:
    engines/access/access.cpp
    engines/access/access.h
    engines/access/amazon/amazon_game.cpp



diff --git a/engines/access/access.cpp b/engines/access/access.cpp
index a97bd6d..051884c 100644
--- a/engines/access/access.cpp
+++ b/engines/access/access.cpp
@@ -218,17 +218,20 @@ void AccessEngine::freeInactiveData() {
 	_inactive._spritesPtr = nullptr;
 }
 
-void AccessEngine::speakText(ASurface *s, Common::Array<Common::String> msgArr) {
+void AccessEngine::speakText(ASurface *s, const Common::String &msg) {
+	Common::String lines = msg;
+	Common::String line;
 	int curPage = 0;
 	int soundsLeft = 0;
 
-	while(true) {
+	for (;;) {
 		soundsLeft = _countTbl[curPage];
 		_events->zeroKeys();
 
 		Common::String line;
 		int width = 0;
-		bool lastLine = _fonts._font2.getLine(msgArr[curPage], s->_maxChars * 6, line, width);
+		bool lastLine = _fonts._font2.getLine(lines, s->_maxChars * 6, line, width);
+
 		// Set font colors
 		_fonts._font2._fontColors[0] = 0;
 		_fonts._font2._fontColors[1] = 28;
@@ -308,11 +311,13 @@ void AccessEngine::speakText(ASurface *s, Common::Array<Common::String> msgArr)
 	}
 }
 
-void AccessEngine::printText(ASurface *s, Common::String &msg) {
+void AccessEngine::printText(ASurface *s, const Common::String &msg) {
+	Common::String lines = msg;
 	Common::String line;
 	int width = 0;
-	while (true) {
-		bool lastLine = _fonts._font2.getLine(msg, s->_maxChars * 6, line, width);
+
+	for (;;) {
+		bool lastLine = _fonts._font2.getLine(lines, s->_maxChars * 6, line, width);
 
 		// Set font colors
 		_fonts._font2._fontColors[0] = 0;
diff --git a/engines/access/access.h b/engines/access/access.h
index 157a33c..bec1dac 100644
--- a/engines/access/access.h
+++ b/engines/access/access.h
@@ -271,8 +271,8 @@ public:
 	/**
 	 * Draw a string on a given surface and update text positioning
 	 */
-	void printText(ASurface *s, Common::String &msg);
-	void speakText(ASurface *s, Common::Array<Common::String>msgArr);
+	void printText(ASurface *s, const Common::String &msg);
+	void speakText(ASurface *s, const Common::String &msg);
 
 	/**
 	 * Load a savegame
diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp
index 66b77d6..187b38c 100644
--- a/engines/access/amazon/amazon_game.cpp
+++ b/engines/access/amazon/amazon_game.cpp
@@ -282,17 +282,12 @@ void AmazonEngine::doEstablish(int screenId, int estabIndex) {
 	uint16 msgOffset = READ_LE_UINT16(_eseg->data() + (estabIndex * 2) + 2);
 
 	_printEnd = 155;
+	Common::String msg((const char *)_eseg->data() + msgOffset);
+
 	if (_txtPages == 0) {
-		Common::String msg((const char *)_eseg->data() + msgOffset);
 		printText(_screen, msg);
 	} else {
-		Common::Array<Common::String> msgArr;
-		for (int i = 0; i < _txtPages; ++i) {
-			Common::String msg((const char *)_eseg->data() + msgOffset);
-			msgOffset += msg.size() + 1;
-			msgArr.push_back(msg);
-		}
-		speakText(_screen, msgArr);
+		speakText(_screen, msg);
 	}
 
 	_screen->forceFadeOut();


Commit: 59c4c93c005896389915c1022634e5dd041e268a
    https://github.com/scummvm/scummvm/commit/59c4c93c005896389915c1022634e5dd041e268a
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-12T22:18:29-05:00

Commit Message:
ACCESS: Add needed event polling to cmdCheckTimer

Changed paths:
    engines/access/scripts.cpp



diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp
index 0b2150a..85c714f 100644
--- a/engines/access/scripts.cpp
+++ b/engines/access/scripts.cpp
@@ -414,6 +414,7 @@ void Scripts::cmdSetTimer() {
 void Scripts::cmdCheckTimer() {
 	int idx = _data->readUint16LE();
 
+	_vm->_events->pollEvents();
 	if ((idx == 9) && (_vm->_events->_keypresses.size() > 0)) {
 		_vm->_events->zeroKeys();
 		_vm->_timers[9]._timer = 0;


Commit: 3627ff51aaad803f611b2e5f3072914d0170ed9c
    https://github.com/scummvm/scummvm/commit/3627ff51aaad803f611b2e5f3072914d0170ed9c
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-12T22:18:37-05:00

Commit Message:
ACCESS: Implemented code for cmdChapter

Changed paths:
    engines/access/access.cpp
    engines/access/access.h
    engines/access/amazon/amazon_game.cpp
    engines/access/amazon/amazon_game.h
    engines/access/amazon/amazon_resources.cpp
    engines/access/amazon/amazon_resources.h
    engines/access/amazon/amazon_scripts.cpp
    engines/access/amazon/amazon_scripts.h
    engines/access/files.cpp
    engines/access/files.h
    engines/access/scripts.h
    engines/access/video.cpp
    engines/access/video.h



diff --git a/engines/access/access.cpp b/engines/access/access.cpp
index 051884c..1e3e3a7 100644
--- a/engines/access/access.cpp
+++ b/engines/access/access.cpp
@@ -432,6 +432,17 @@ void AccessEngine::copyBF2Vid() {
 	}
 }
 
+void AccessEngine::playVideo(int fileNum, const Common::Point &pt) {
+	_video->setVideo(_screen, pt, FileIdent(fileNum, 96), 10);
+
+	while (!shouldQuit() && !_video->_videoEnd) {
+		_video->playVideo();
+
+		g_system->delayMillis(10);
+		_events->pollEvents();
+	}
+}
+
 void AccessEngine::doLoadSave() {
 	error("TODO: doLoadSave");
 }
diff --git a/engines/access/access.h b/engines/access/access.h
index bec1dac..a12a632 100644
--- a/engines/access/access.h
+++ b/engines/access/access.h
@@ -119,6 +119,11 @@ protected:
 	*/
 	Common::String AccessEngine::generateSaveName(int slot);
 
+	/**
+	 * Play back an entire video
+	 */
+	void playVideo(int fileNum, const Common::Point &pt);
+
 	// Engine APIs
 	virtual Common::Error run();
 	virtual bool hasFeature(EngineFeature f) const;
diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp
index 187b38c..3af07ed 100644
--- a/engines/access/amazon/amazon_game.cpp
+++ b/engines/access/amazon/amazon_game.cpp
@@ -55,11 +55,13 @@ AmazonEngine::AmazonEngine(OSystem *syst, const AccessGameDescription *gameDesc)
 	_rawInactiveY = 0;
 	_inactiveYOff = 0;
 	_tilePos = Common::Point(0, 0);
+	_hintLevel = 0;
 
 	Common::fill(&_esTabTable[0], &_esTabTable[100], 0);
 	memset(_tileData, 0, sizeof(_tileData));
+	
+	_chapterCells.push_back(CellIdent(0, 96, 17));
 
-	_hintLevel = 0;
 }
 
 AmazonEngine::~AmazonEngine() {
@@ -380,6 +382,160 @@ void AmazonEngine::drawHelp() {
 	error("TODO: drawHelp");
 }
 
+void AmazonEngine::startChapter(int chapter) {
+	_chapter = chapter;
+	assert(_chapter <= 14);
+
+	if (chapter != 1) {
+		_room->clearRoom();
+		freeChar();
+		
+		_sound->newMusic(32, 0);
+		playVideo(0, Common::Point());
+		if (shouldQuit())
+			return;
+
+		_events->debounceLeft();
+		_events->zeroKeys();
+		playVideo(_chapter, Common::Point(4, 113));
+		if (shouldQuit())
+			return;
+
+		_timers[20]._timer = 500;
+		_timers[20]._initTm = 500;
+		_timers[20]._flag++;
+
+		_sound->_soundTable[0] = _sound->loadSound(115, 0);
+		_sound->_soundPriority[0] = 1;
+		_sound->playSound(0);
+		_sound->freeSounds();
+
+		_sound->_soundTable[0] = _sound->loadSound(115, 1);
+		_sound->_soundPriority[0] = 1;
+		_sound->playSound(0);
+		_sound->freeSounds();
+
+		// Wait loop
+		while (!shouldQuit() && !_events->_leftButton && !_events->_rightButton
+				&& _events->_keypresses.size() == 0 && _timers[20]._flag) {
+			_events->pollEvents();
+			g_system->delayMillis(10);
+		}
+	}
+
+	_screen->forceFadeOut();
+	_events->debounceLeft();
+	_events->zeroKeys();
+	_screen->clearScreen();
+
+	_screen->setPanel(3);
+	
+	// Set up cells for the chapter display
+	Common::Array<CellIdent> chapterCells;
+	chapterCells.push_back(CellIdent(0, 96, 17));
+	const int *chapCell = &CHAPTER_CELLS[_chapter - 1][0];
+	chapterCells.push_back(CellIdent(chapCell[0], chapCell[1], chapCell[2]));
+	loadCells(chapterCells);
+
+	// Show chapter screen
+	_files->loadScreen(96, 15);
+	_buffer2.copyFrom(*_screen);
+
+	const int *chapImg = &CHAPTER_TABLE[_chapter - 1][0];
+	_screen->plotImage(_objectsTable[0], _chapter - 1, 
+		Common::Point(chapImg[1], chapImg[2]));
+	_screen->plotImage(_objectsTable[_chapter - 1], 0,
+		Common::Point(chapImg[3], chapImg[4]));
+	if (chapter == 14)
+		_screen->plotImage(_objectsTable[_chapter - 1], 1, Common::Point(169, 76));
+
+	_sound->newMusic(chapImg[4], 1);
+	_sound->newMusic(33, 0);
+	_screen->forceFadeIn();
+
+	_timers[20]._timer = 950;
+	_timers[20]._initTm = 950;
+	_timers[20]._flag++;
+
+	// Wait loop
+	while (!shouldQuit() && !_events->_leftButton && !_events->_rightButton
+		&& _events->_keypresses.size() == 0 && _timers[20]._flag) {
+		_events->pollEvents();
+		g_system->delayMillis(10);
+	}
+	if (shouldQuit())
+		return;
+
+	_screen->forceFadeOut();
+	_events->debounceLeft();
+	_events->zeroKeys();
+	
+	_screen->clearBuffer();
+	_files->loadScreen(96, 16);
+	_buffer2.copyFrom(*_screen);
+	_screen->plotImage(_objectsTable[0], chapImg[0], Common::Point(90, 7));
+
+	_sound->newMusic(7, 1);
+	_sound->newMusic(34, 0);
+
+	_screen->forceFadeIn();
+	_buffer2.copyFrom(*_screen);
+
+	_fonts._charSet._lo = 1;
+	_fonts._charSet._hi = 10;
+	_fonts._charFor._lo = 55;
+	_fonts._charFor._hi = 0xFF;
+	_screen->_printOrg = Common::Point(31, 77);
+	_screen->_printStart = Common::Point(31, 77);
+
+	_establishGroup = 1;
+	loadEstablish(0x40 + _chapter);
+	uint16 msgOffset = READ_LE_UINT16(_eseg->data() + (_chapter * 2) + 2);
+	_printEnd = 170;
+
+	_printEnd = 155;
+	Common::String msg((const char *)_eseg->data() + msgOffset);
+
+	if (_txtPages == 0) {
+		printText(_screen, msg);
+	} else {
+		speakText(_screen, msg);
+	}
+	if (shouldQuit())
+		return;
+
+	_screen->forceFadeOut();
+	_screen->clearBuffer();
+	freeCells();
+	
+	_sound->newMusic(_chapter * 2, 1);
+
+	if (chapter != 1 && chapter != 14) {
+		_room->init4Quads();
+	}
+
+	if (chapter == 14) {
+		_conversation = 31;
+		_char->loadChar(_conversation);
+		_events->setCursor(CURSOR_ARROW);
+
+		_images.clear();
+		_oldRects.clear();
+		_scripts->_sequence = 0;
+		_scripts->searchForSequence();
+
+		if (_screen->_vesaMode) {
+			_converseMode = 1;
+		}
+	} else if (chapter != 1) {
+		_player->_roomNumber = CHAPTER_JUMP[_chapter - 1];
+		_room->_function = 1;
+		_converseMode = 0;
+
+		_scripts->cmdRetPos();
+	}
+}
+
 void AmazonEngine::synchronize(Common::Serializer &s) {
 	AccessEngine::synchronize(s);
 
diff --git a/engines/access/amazon/amazon_game.h b/engines/access/amazon/amazon_game.h
index 0275cee..2dc0c05 100644
--- a/engines/access/amazon/amazon_game.h
+++ b/engines/access/amazon/amazon_game.h
@@ -70,6 +70,7 @@ private:
 	// Other fields
 	Common::Point _tilePos;
 	byte _tileData[1455];
+	Common::Array<CellIdent> _chapterCells;
 
 	/**
 	 * Do the game introduction
@@ -161,6 +162,11 @@ public:
 
 	void tileScreen();
 	void updateSummary(int chap);
+
+	/**
+	 * Show the start of a chapter
+	 */
+	void startChapter(int chapter);
 };
 
 } // End of namespace Amazon
diff --git a/engines/access/amazon/amazon_resources.cpp b/engines/access/amazon/amazon_resources.cpp
index a514575..05af0c1 100644
--- a/engines/access/amazon/amazon_resources.cpp
+++ b/engines/access/amazon/amazon_resources.cpp
@@ -1314,6 +1314,44 @@ const int DEATH_CELLS[12][3] = {
 	{ 0, 94, 14 }
 };
 
+const int CHAPTER_CELLS[17][3] = {
+	{ 1, 96, 18 },
+	{ 2, 96, 19 },
+	{ 3, 96, 20 },
+	{ 4, 96, 21 },
+	{ 5, 96, 22 },
+	{ 6, 96, 23 },
+	{ 7, 96, 24 },
+	{ 8, 96, 25 },
+	{ 9, 96, 26 },
+	{ 10, 96, 27 },
+	{ 11, 96, 28 },
+	{ 12, 96, 29 },
+	{ 13, 96, 30 },
+	{ 14, 96, 31 }
+};
+
+const int CHAPTER_TABLE[14][5] = {
+	{ 18, 136, 27, 76, 49 },
+	{ 16, 134, 27, 53, 74 },
+	{ 16, 136, 27, 52, 56 },
+	{ 16, 135, 26, 46, 75 },
+	{ 16, 135, 27, 54, 66 },
+	{ 16, 137, 27, 67, 79 },
+	{ 14, 136, 27, 82, 52 },
+	{ 15, 136, 26, 65, 73 },
+	{ 15, 137, 26, 48, 75 },
+	{ 17, 135, 27, 52, 66 },
+	{ 15, 135, 27, 62, 65 },
+	{ 16, 135, 28, 45, 66 },
+	{ 16, 135, 28, 36, 67 },
+	{ 15, 135, 27, 34, 63 }
+};
+
+const int CHAPTER_JUMP[14] = {
+	0, 12, 10, 15, 19, 25, 31, 36, 45, 46, 29, 55, 61, 0
+};
+
 } // End of namespace Amazon
 
 } // End of namespace Access
diff --git a/engines/access/amazon/amazon_resources.h b/engines/access/amazon/amazon_resources.h
index 17cca2a..d8d37b5 100644
--- a/engines/access/amazon/amazon_resources.h
+++ b/engines/access/amazon/amazon_resources.h
@@ -58,6 +58,12 @@ extern const char *const DEATH_TEXT[58];
 
 extern const int DEATH_CELLS[12][3];
 
+extern const int CHAPTER_CELLS[17][3];
+
+extern const int CHAPTER_TABLE[14][5];
+
+extern const int CHAPTER_JUMP[14];
+
 } // End of namespace Amazon
 
 } // End of namespace Access
diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp
index a932dad..7ad68bd 100644
--- a/engines/access/amazon/amazon_scripts.cpp
+++ b/engines/access/amazon/amazon_scripts.cpp
@@ -414,7 +414,7 @@ typedef void(AmazonScripts::*AmazonScriptMethodPtr)();
 void AmazonScripts::executeCommand(int commandIndex) {
 	static const AmazonScriptMethodPtr COMMAND_LIST[] = {
 		&AmazonScripts::cmdHelp, &AmazonScripts::CMDCYCLEBACK,
-		&AmazonScripts::CMDCHAPTER, &AmazonScripts::cmdSetHelp,
+		&AmazonScripts::cmdChapter, &AmazonScripts::cmdSetHelp,
 		&AmazonScripts::cmdCenterPanel, &AmazonScripts::cmdMainPanel,
 		&AmazonScripts::CMDRETFLASH
 	};
@@ -452,8 +452,9 @@ void AmazonScripts::cmdHelp() {
 void AmazonScripts::CMDCYCLEBACK() { 
 	error("TODO CMDCYCLEBACK"); 
 }
-void AmazonScripts::CMDCHAPTER() { 
-	error("TODO CMDCHAPTER"); 
+void AmazonScripts::cmdChapter() {
+	int chapter = _data->readByte();
+	_game->startChapter(chapter);
 }
 
 void AmazonScripts::cmdSetHelp() {
diff --git a/engines/access/amazon/amazon_scripts.h b/engines/access/amazon/amazon_scripts.h
index 50bd2ac..edb8843 100644
--- a/engines/access/amazon/amazon_scripts.h
+++ b/engines/access/amazon/amazon_scripts.h
@@ -53,7 +53,7 @@ protected:
 
 	void cmdHelp();
 	void CMDCYCLEBACK();
-	void CMDCHAPTER();
+	void cmdChapter();
 	void cmdSetHelp();
 	void cmdCenterPanel();
 	void cmdMainPanel();
diff --git a/engines/access/files.cpp b/engines/access/files.cpp
index d8823c0..a4ec16a 100644
--- a/engines/access/files.cpp
+++ b/engines/access/files.cpp
@@ -101,7 +101,7 @@ Resource *FileManager::loadFile(int fileNum, int subfile) {
 	return res;
 }
 
-Resource *FileManager::loadFile(FileIdent &fileIdent) {
+Resource *FileManager::loadFile(const FileIdent &fileIdent) {
 	return loadFile(fileIdent._fileNum, fileIdent._subfile);
 }
 
diff --git a/engines/access/files.h b/engines/access/files.h
index a32ebbf..720d4fb 100644
--- a/engines/access/files.h
+++ b/engines/access/files.h
@@ -38,6 +38,7 @@ struct FileIdent {
 	int _subfile;
 
 	FileIdent();
+	FileIdent(int fileNum, int subfile) { _fileNum = fileNum; _subfile = subfile; }
 
 	void load(Common::SeekableReadStream &s);
 };
@@ -112,7 +113,7 @@ public:
 	/**
 	 * Loads a resource specified by a file identifier
 	 */
-	Resource *loadFile(FileIdent &fileIdent);
+	Resource *loadFile(const FileIdent &fileIdent);
 
 	/**
 	 * Load a given file by name
diff --git a/engines/access/scripts.h b/engines/access/scripts.h
index 003f441..e6faa46 100644
--- a/engines/access/scripts.h
+++ b/engines/access/scripts.h
@@ -66,7 +66,6 @@ protected:
 	void cmdJumpTalk();
 	void cmdNull();
 	void cmdPrint();
-	void cmdRetPos();
 	void cmdAnim();
 	void cmdSetFlag();
 	void cmdCheckFlag();
@@ -145,7 +144,9 @@ public:
 
 	void findNull();
 
+	// Script commands that need to be public
 	void cmdFreeSound();
+	void cmdRetPos();
 };
 
 } // End of namespace Access
diff --git a/engines/access/video.cpp b/engines/access/video.cpp
index 4b9a875..b46bdf2 100644
--- a/engines/access/video.cpp
+++ b/engines/access/video.cpp
@@ -38,7 +38,7 @@ VideoPlayer::~VideoPlayer() {
 }
 
 
-void VideoPlayer::setVideo(ASurface *vidSurface, const Common::Point &pt, FileIdent &videoFile, int rate) {
+void VideoPlayer::setVideo(ASurface *vidSurface, const Common::Point &pt, const FileIdent &videoFile, int rate) {
 	_vidSurface = vidSurface;
 	vidSurface->_orgX1 = pt.x;
 	vidSurface->_orgY1 = pt.y;
diff --git a/engines/access/video.h b/engines/access/video.h
index bb9656b..b49c876 100644
--- a/engines/access/video.h
+++ b/engines/access/video.h
@@ -62,7 +62,7 @@ public:
 	/**
 	 * Start up a video
 	 */
-	void setVideo(ASurface *vidSurface, const Common::Point &pt, FileIdent &videoFile, int rate);
+	void setVideo(ASurface *vidSurface, const Common::Point &pt, const FileIdent &videoFile, int rate);
 
 	/**
 	 * Decodes a frame of the video


Commit: fb6d9230dc24d68b888ed4cefbf99bbf2fb60e3d
    https://github.com/scummvm/scummvm/commit/fb6d9230dc24d68b888ed4cefbf99bbf2fb60e3d
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-12T22:18:45-05:00

Commit Message:
ACCESS: Add missing table to savegames

Changed paths:
    engines/access/access.cpp



diff --git a/engines/access/access.cpp b/engines/access/access.cpp
index 1e3e3a7..9b49b9f 100644
--- a/engines/access/access.cpp
+++ b/engines/access/access.cpp
@@ -539,6 +539,9 @@ void AccessEngine::synchronize(Common::Serializer &s) {
 	s.syncAsUint16LE(_mapOffset);
 	s.syncAsUint16LE(_screenVirtX);
 
+	for (int i = 0; i < 100; ++i)
+		s.syncAsByte(_establishTable[i]);
+
 	// Synchronize sub-objects
 	_timers.synchronize(s);
 	_inventory->synchronize(s);


Commit: 386aae3ffa60c9ef44181cb730ab947544b2e761
    https://github.com/scummvm/scummvm/commit/386aae3ffa60c9ef44181cb730ab947544b2e761
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-12T22:18:58-05:00

Commit Message:
ACCESS: Workaround for background column rendering bug in original

Changed paths:
    engines/access/room.cpp



diff --git a/engines/access/room.cpp b/engines/access/room.cpp
index 2c59760..181dcd6 100644
--- a/engines/access/room.cpp
+++ b/engines/access/room.cpp
@@ -309,7 +309,10 @@ void Room::buildColumn(int playX, int screenX) {
 	const byte *pSrc = _playField + _vm->_screen->_scrollRow * 
 		_playFieldWidth + playX;
 
-	for (int y = 0; y <= _vm->_screen->_vWindowHeight; ++y) {
+	// WORKAROUND: Original's use of '+ 1' would frequently cause memory overruns
+	int h = MIN(_vm->_screen->_vWindowHeight + 1, _playFieldHeight);
+
+	for (int y = 0; y < h; ++y) {
 		byte *pTile = _tile + (*pSrc << 8);
 		byte *pDest = (byte *)_vm->_buffer1.getBasePtr(screenX, y * TILE_HEIGHT);
 


Commit: 21c1d0f920a530b310a68376e9aa8836ed43471b
    https://github.com/scummvm/scummvm/commit/21c1d0f920a530b310a68376e9aa8836ed43471b
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-12T22:19:13-05:00

Commit Message:
ACCESS: Workaround for background rendering bug in original

Changed paths:
    engines/access/room.cpp



diff --git a/engines/access/room.cpp b/engines/access/room.cpp
index 181dcd6..9b83077 100644
--- a/engines/access/room.cpp
+++ b/engines/access/room.cpp
@@ -289,14 +289,16 @@ void Room::setWallCodes() {
 
 void Room::buildScreen() {
 	int scrollCol = _vm->_screen->_scrollCol;
-	int cnt = _vm->_screen->_vWindowWidth + 1;
 	int offset = 0;
 
 	// Clear current background buffer
 	_vm->_buffer1.clearBuffer();
 
+	// WORKAROUND: Original's use of '+ 1' would frequently cause memory overruns
+	int w = MIN(_vm->_screen->_vWindowWidth + 1, _playFieldWidth);
+
 	// Loop through drawing each column of tiles forming the background
-	for (int idx = 0; idx < cnt; offset += TILE_WIDTH, ++idx) {
+	for (int idx = 0; idx < w; offset += TILE_WIDTH, ++idx) {
 		buildColumn(_vm->_screen->_scrollCol, offset);
 		++_vm->_screen->_scrollCol;
 	}


Commit: ae24bf54b43ab682f4e057c117810c1506b58d4d
    https://github.com/scummvm/scummvm/commit/ae24bf54b43ab682f4e057c117810c1506b58d4d
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-12T22:19:25-05:00

Commit Message:
ACCESS: Fixes for startChapter

Changed paths:
    engines/access/access.cpp
    engines/access/access.h
    engines/access/amazon/amazon_game.cpp
    engines/access/amazon/amazon_resources.cpp



diff --git a/engines/access/access.cpp b/engines/access/access.cpp
index 9b49b9f..fab66c3 100644
--- a/engines/access/access.cpp
+++ b/engines/access/access.cpp
@@ -432,8 +432,8 @@ void AccessEngine::copyBF2Vid() {
 	}
 }
 
-void AccessEngine::playVideo(int fileNum, const Common::Point &pt) {
-	_video->setVideo(_screen, pt, FileIdent(fileNum, 96), 10);
+void AccessEngine::playVideo(int videoNum, const Common::Point &pt) {
+	_video->setVideo(_screen, pt, FileIdent(96, videoNum), 10);
 
 	while (!shouldQuit() && !_video->_videoEnd) {
 		_video->playVideo();
diff --git a/engines/access/access.h b/engines/access/access.h
index a12a632..fcac69d 100644
--- a/engines/access/access.h
+++ b/engines/access/access.h
@@ -122,7 +122,7 @@ protected:
 	/**
 	 * Play back an entire video
 	 */
-	void playVideo(int fileNum, const Common::Point &pt);
+	void playVideo(int videoNum, const Common::Point &pt);
 
 	// Engine APIs
 	virtual Common::Error run();
diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp
index 3af07ed..8270eae 100644
--- a/engines/access/amazon/amazon_game.cpp
+++ b/engines/access/amazon/amazon_game.cpp
@@ -444,10 +444,10 @@ void AmazonEngine::startChapter(int chapter) {
 	const int *chapImg = &CHAPTER_TABLE[_chapter - 1][0];
 	_screen->plotImage(_objectsTable[0], _chapter - 1, 
 		Common::Point(chapImg[1], chapImg[2]));
-	_screen->plotImage(_objectsTable[_chapter - 1], 0,
+	_screen->plotImage(_objectsTable[_chapter], 0,
 		Common::Point(chapImg[3], chapImg[4]));
 	if (chapter == 14)
-		_screen->plotImage(_objectsTable[_chapter - 1], 1, Common::Point(169, 76));
+		_screen->plotImage(_objectsTable[_chapter], 1, Common::Point(169, 76));
 
 	_sound->newMusic(chapImg[4], 1);
 	_sound->newMusic(33, 0);
@@ -485,12 +485,13 @@ void AmazonEngine::startChapter(int chapter) {
 	_fonts._charSet._hi = 10;
 	_fonts._charFor._lo = 55;
 	_fonts._charFor._hi = 0xFF;
+	_screen->_maxChars = 43;
 	_screen->_printOrg = Common::Point(31, 77);
 	_screen->_printStart = Common::Point(31, 77);
 
 	_establishGroup = 1;
 	loadEstablish(0x40 + _chapter);
-	uint16 msgOffset = READ_LE_UINT16(_eseg->data() + (_chapter * 2) + 2);
+	uint16 msgOffset = READ_LE_UINT16(_eseg->data() + ((0x40 + _chapter) * 2) + 2);
 	_printEnd = 170;
 
 	_printEnd = 155;
diff --git a/engines/access/amazon/amazon_resources.cpp b/engines/access/amazon/amazon_resources.cpp
index 05af0c1..0807a97 100644
--- a/engines/access/amazon/amazon_resources.cpp
+++ b/engines/access/amazon/amazon_resources.cpp
@@ -48,7 +48,7 @@ const char *const FILENAMES[] = {
 	"NARATE01.AP", "NARATE02.AP", "NARATE03.AP", "NARATE04.AP",
 	"NARATE05.AP", "NARATE06.AP", "NARATE07.AP", "NARATE08.AP",
 	"NARATE09.AP", "NARATE10.AP", "NARATE11.AP", "NARATE12.AP",
-	"NARATE13.AP", "NARATE14.AP"
+	"NARATE13.AP", "NARATE14.AP", "S00.AP", "TAG.AP"
 };
 
 const byte MOUSE0[] = {


Commit: 48edbf1e34993ee8eda7902197e1e6cdb33dce7b
    https://github.com/scummvm/scummvm/commit/48edbf1e34993ee8eda7902197e1e6cdb33dce7b
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-12T22:19:35-05:00

Commit Message:
ACCESS: Fixed clearing talk bubbles during conversations

Changed paths:
    engines/access/bubble_box.cpp



diff --git a/engines/access/bubble_box.cpp b/engines/access/bubble_box.cpp
index c4272b6..d865d5c 100644
--- a/engines/access/bubble_box.cpp
+++ b/engines/access/bubble_box.cpp
@@ -47,6 +47,15 @@ void BubbleBox::load(Common::SeekableReadStream *stream) {
 }
 
 void BubbleBox::clearBubbles() {
+	// Loop through the bubble list to restore the screen areas
+	for (uint i = 0; i < _bubbles.size(); ++i) {
+		_vm->_screen->_screenYOff = 0;
+		Common::Rect r = _bubbles[i];
+		r.left -= 2;
+		_vm->_screen->copyBlock(&_vm->_buffer2, r);
+	}
+
+	// Clear the list
 	_bubbles.clear();
 }
 
@@ -56,7 +65,7 @@ void BubbleBox::placeBubble(const Common::String &msg) {
 }
 
 void BubbleBox::placeBubble1(const Common::String &msg) {
-	BubbleBox::clearBubbles();
+	clearBubbles();
 	_vm->_fonts._charSet._lo = 1;
 	_vm->_fonts._charSet._hi = 8;
 	_vm->_fonts._charFor._lo = 29;


Commit: 7e4d76b1fb41662cd48e21d775322d2a0ad3325e
    https://github.com/scummvm/scummvm/commit/7e4d76b1fb41662cd48e21d775322d2a0ad3325e
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-12T22:19:44-05:00

Commit Message:
ACCESS: Implemented cmdWait

Changed paths:
    engines/access/scripts.cpp
    engines/access/scripts.h



diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp
index 85c714f..bed1a77 100644
--- a/engines/access/scripts.cpp
+++ b/engines/access/scripts.cpp
@@ -127,7 +127,7 @@ void Scripts::executeCommand(int commandIndex) {
 		&Scripts::CMDSETBUFVID, &Scripts::CMDPLAYBUFVID, &Scripts::cmdRemoveLast, 
 		&Scripts::cmdSpecial, &Scripts::cmdSpecial, &Scripts::cmdSpecial,
 		&Scripts::CMDSETCYCLE, &Scripts::CMDCYCLE, &Scripts::cmdCharSpeak, 
-		&Scripts::cmdTexSpeak, &Scripts::cmdTexChoice, &Scripts::CMDWAIT, 
+		&Scripts::cmdTexSpeak, &Scripts::cmdTexChoice, &Scripts::cmdWait, 
 		&Scripts::cmdSetConPos, &Scripts::CMDCHECKVFRAME, &Scripts::cmdJumpChoice, 
 		&Scripts::cmdReturnChoice, &Scripts::cmdClearBlock, &Scripts::cmdLoadSound, 
 		&Scripts::cmdFreeSound, &Scripts::cmdSetVideoSound, &Scripts::cmdPlayVideoSound,
@@ -655,7 +655,26 @@ void Scripts::cmdTexChoice() {
 	_vm->_bubbleBox->clearBubbles();
 }
 
-void Scripts::CMDWAIT() { error("TODO CMDWAIT"); }
+void Scripts::cmdWait() { 
+	int time = _data->readSint16LE();
+	_vm->_timers[3]._timer = time;
+	_vm->_timers[3]._initTm = time;
+	_vm->_timers[3]._flag++;
+	_vm->_events->_keypresses.clear();
+
+	while (!_vm->shouldQuit() && _vm->_events->_keypresses.empty() &&
+			!_vm->_events->_leftButton && !_vm->_events->_rightButton &&
+			_vm->_timers[3]._flag) {
+		_vm->_sound->midiRepeat();
+		charLoop();
+
+		_vm->_events->pollEvents();
+		g_system->delayMillis(10);
+	}
+
+	_vm->_events->debounceLeft();
+	_vm->_events->zeroKeys();
+}
 
 void Scripts::cmdSetConPos() {
 	int x = _data->readSint16LE();
diff --git a/engines/access/scripts.h b/engines/access/scripts.h
index e6faa46..49c3b56 100644
--- a/engines/access/scripts.h
+++ b/engines/access/scripts.h
@@ -106,7 +106,7 @@ protected:
 	void cmdCharSpeak();
 	void cmdTexSpeak();
 	void cmdTexChoice();
-	void CMDWAIT();
+	void cmdWait();
 	void cmdSetConPos();
 	void CMDCHECKVFRAME();
 	void cmdJumpChoice();


Commit: f3063a13f08a2b085d92d0a79231e568671501b3
    https://github.com/scummvm/scummvm/commit/f3063a13f08a2b085d92d0a79231e568671501b3
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-12T22:19:55-05:00

Commit Message:
ACCESS: Implement palette cycling script commands

Changed paths:
    engines/access/amazon/amazon_scripts.cpp
    engines/access/amazon/amazon_scripts.h
    engines/access/screen.cpp
    engines/access/screen.h
    engines/access/scripts.cpp
    engines/access/scripts.h



diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp
index 7ad68bd..0ea9ee5 100644
--- a/engines/access/amazon/amazon_scripts.cpp
+++ b/engines/access/amazon/amazon_scripts.cpp
@@ -413,7 +413,7 @@ typedef void(AmazonScripts::*AmazonScriptMethodPtr)();
 
 void AmazonScripts::executeCommand(int commandIndex) {
 	static const AmazonScriptMethodPtr COMMAND_LIST[] = {
-		&AmazonScripts::cmdHelp, &AmazonScripts::CMDCYCLEBACK,
+		&AmazonScripts::cmdHelp, &AmazonScripts::cmdCycleBack,
 		&AmazonScripts::cmdChapter, &AmazonScripts::cmdSetHelp,
 		&AmazonScripts::cmdCenterPanel, &AmazonScripts::cmdMainPanel,
 		&AmazonScripts::CMDRETFLASH
@@ -449,8 +449,8 @@ void AmazonScripts::cmdHelp() {
 	error("TODO: more cmdHelp");
 }
 
-void AmazonScripts::CMDCYCLEBACK() { 
-	error("TODO CMDCYCLEBACK"); 
+void AmazonScripts::cmdCycleBack() { 
+	_vm->_screen->cyclePaletteBackwards();
 }
 void AmazonScripts::cmdChapter() {
 	int chapter = _data->readByte();
diff --git a/engines/access/amazon/amazon_scripts.h b/engines/access/amazon/amazon_scripts.h
index edb8843..694260d 100644
--- a/engines/access/amazon/amazon_scripts.h
+++ b/engines/access/amazon/amazon_scripts.h
@@ -52,7 +52,7 @@ protected:
 	void boatWalls(int param1, int param2);
 
 	void cmdHelp();
-	void CMDCYCLEBACK();
+	void cmdCycleBack();
 	void cmdChapter();
 	void cmdSetHelp();
 	void cmdCenterPanel();
diff --git a/engines/access/screen.cpp b/engines/access/screen.cpp
index 227d9d7..17f36fc 100644
--- a/engines/access/screen.cpp
+++ b/engines/access/screen.cpp
@@ -59,6 +59,9 @@ Screen::Screen(AccessEngine *vm) : _vm(vm) {
 	_vWindowLinesTall = this->h;
 	_clipWidth = _vWindowBytesWide - 1;
 	_clipHeight = _vWindowLinesTall - 1;
+	_startCycle = 0;
+	_cycleStart = 0;
+	_endCycle = 0;
 }
 
 void Screen::clearScreen() {
@@ -244,4 +247,39 @@ void Screen::copyBlock(ASurface *src, const Common::Rect &bounds) {
 	copyRectToSurface(*src, destBounds.left, destBounds.top, bounds);
 }
 
+void Screen::setPaletteCycle(int startCycle, int endCycle, int timer) {
+	_startCycle = _cycleStart = startCycle;
+	_endCycle = endCycle;
+
+	TimerEntry &te = _vm->_timers[6];
+	te._timer = te._initTm = timer;
+	te._flag++;
+}
+
+void Screen::cyclePaletteForward() {
+	cyclePaletteBackwards();
+}
+
+void Screen::cyclePaletteBackwards() {
+	if (!_vm->_timers[6]._flag) {
+		_vm->_timers[6]._flag++;
+		byte *pStart = &_rawPalette[_cycleStart * 3];
+		byte *pEnd = &_rawPalette[_endCycle * 3];
+		
+		for (int idx = _startCycle; idx < _endCycle; ++idx) {
+			g_system->getPaletteManager()->setPalette(pStart, idx, 1);
+			
+			pStart += 3;
+			if (pStart == pEnd)
+				pStart = &_rawPalette[_cycleStart * 3];
+		}
+
+		if (--_cycleStart <= _startCycle)
+			_cycleStart = _endCycle - 1;
+
+		g_system->updateScreen();
+		g_system->delayMillis(10);
+	}
+}
+
 } // End of namespace Access
diff --git a/engines/access/screen.h b/engines/access/screen.h
index b278062..2db05a5 100644
--- a/engines/access/screen.h
+++ b/engines/access/screen.h
@@ -60,6 +60,9 @@ private:
 	Common::Point _virtualOffsetsTable[4];
 	bool _hideFlag;
 	ScreenSave _screenSave;
+	int _startCycle;
+	int _cycleStart;
+	int _endCycle;
 
 	void updatePalette();
 public:
@@ -150,6 +153,12 @@ public:
 	 * Restores previously saved screen display state variables
 	 */
 	void restoreScreen();
+
+	void setPaletteCycle(int startCycle, int endCycle, int timer);
+
+	void cyclePaletteForward();
+
+	void cyclePaletteBackwards();
 };
 
 } // End of namespace Access
diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp
index bed1a77..2aa10b6 100644
--- a/engines/access/scripts.cpp
+++ b/engines/access/scripts.cpp
@@ -126,7 +126,7 @@ void Scripts::executeCommand(int commandIndex) {
 		&Scripts::cmdSetScroll, &Scripts::cmdVideoEnded, &Scripts::cmdVideoEnded, 
 		&Scripts::CMDSETBUFVID, &Scripts::CMDPLAYBUFVID, &Scripts::cmdRemoveLast, 
 		&Scripts::cmdSpecial, &Scripts::cmdSpecial, &Scripts::cmdSpecial,
-		&Scripts::CMDSETCYCLE, &Scripts::CMDCYCLE, &Scripts::cmdCharSpeak, 
+		&Scripts::cmdSetCycle, &Scripts::cmdCycle, &Scripts::cmdCharSpeak, 
 		&Scripts::cmdTexSpeak, &Scripts::cmdTexChoice, &Scripts::cmdWait, 
 		&Scripts::cmdSetConPos, &Scripts::CMDCHECKVFRAME, &Scripts::cmdJumpChoice, 
 		&Scripts::cmdReturnChoice, &Scripts::cmdClearBlock, &Scripts::cmdLoadSound, 
@@ -514,8 +514,16 @@ void Scripts::cmdSpecial() {
 	}
 }
 
-void Scripts::CMDSETCYCLE() { error("TODO CMDSETCYCLE"); }
-void Scripts::CMDCYCLE() { error("TODO CMDCYCLE"); }
+void Scripts::cmdSetCycle() { 
+	int startCycle = _data->readUint16LE();
+	int endCycle = _data->readUint16LE();
+	int timer = _data->readUint16LE();
+	_vm->_screen->setPaletteCycle(startCycle, endCycle, timer);
+}
+
+void Scripts::cmdCycle() {
+	_vm->_screen->cyclePaletteForward();
+}
 
 void Scripts::cmdCharSpeak() {
 	_vm->_screen->_printOrg = _charsOrg;
diff --git a/engines/access/scripts.h b/engines/access/scripts.h
index 49c3b56..f4128f4 100644
--- a/engines/access/scripts.h
+++ b/engines/access/scripts.h
@@ -101,8 +101,8 @@ protected:
 	void CMDPLAYBUFVID();
 	void cmdRemoveLast();
 	void cmdSpecial();
-	void CMDSETCYCLE();
-	void CMDCYCLE();
+	void cmdSetCycle();
+	void cmdCycle();
 	void cmdCharSpeak();
 	void cmdTexSpeak();
 	void cmdTexChoice();


Commit: c03845258843a7b0d1db792ea42a986bf79c917a
    https://github.com/scummvm/scummvm/commit/c03845258843a7b0d1db792ea42a986bf79c917a
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-12T22:20:05-05:00

Commit Message:
ACCESS: Add missing _startup checks to palette cycling opcodes

Changed paths:
    engines/access/amazon/amazon_scripts.cpp
    engines/access/scripts.cpp



diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp
index 0ea9ee5..3e7fd4e 100644
--- a/engines/access/amazon/amazon_scripts.cpp
+++ b/engines/access/amazon/amazon_scripts.cpp
@@ -449,8 +449,9 @@ void AmazonScripts::cmdHelp() {
 	error("TODO: more cmdHelp");
 }
 
-void AmazonScripts::cmdCycleBack() { 
-	_vm->_screen->cyclePaletteBackwards();
+void AmazonScripts::cmdCycleBack() {
+	if (_vm->_startup == -1)
+		_vm->_screen->cyclePaletteBackwards();
 }
 void AmazonScripts::cmdChapter() {
 	int chapter = _data->readByte();
diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp
index 2aa10b6..c46d7b9 100644
--- a/engines/access/scripts.cpp
+++ b/engines/access/scripts.cpp
@@ -522,7 +522,8 @@ void Scripts::cmdSetCycle() {
 }
 
 void Scripts::cmdCycle() {
-	_vm->_screen->cyclePaletteForward();
+	if (_vm->_startup == -1)
+		_vm->_screen->cyclePaletteForward();
 }
 
 void Scripts::cmdCharSpeak() {


Commit: 335acfac892ab071d791db46161d5ca4c8868109
    https://github.com/scummvm/scummvm/commit/335acfac892ab071d791db46161d5ca4c8868109
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-12T22:20:16-05:00

Commit Message:
ACCESS: Implement newMusic()

Changed paths:
    engines/access/sound.cpp
    engines/access/sound.h



diff --git a/engines/access/sound.cpp b/engines/access/sound.cpp
index 90818ed..072261d 100644
--- a/engines/access/sound.cpp
+++ b/engines/access/sound.cpp
@@ -30,6 +30,7 @@ namespace Access {
 SoundManager::SoundManager(AccessEngine *vm, Audio::Mixer *mixer) : 
 		_vm(vm), _mixer(mixer) {
 	_music = nullptr;
+	_tempMusic = nullptr;
 	_musicRepeat = false;
 	_playingSound = false;
 	_isVoice = false;
@@ -37,6 +38,8 @@ SoundManager::SoundManager(AccessEngine *vm, Audio::Mixer *mixer) :
 
 SoundManager::~SoundManager() {
 	clearSounds();
+	delete _music;
+	delete _tempMusic;
 }
 
 void SoundManager::clearSounds() {
@@ -95,7 +98,20 @@ void SoundManager::freeSounds() {
 }
 
 void SoundManager::newMusic(int musicId, int mode) {
-	warning("TODO: newMusic");
+	if (mode == 1) {
+		stopSong();
+		freeMusic();
+		_music = _tempMusic;
+		_tempMusic = nullptr;
+		_musicRepeat = true;
+		if (_music)
+			midiPlay();
+	} else {
+		_musicRepeat = (mode == 2);
+		_tempMusic = _music;
+		stopSong();
+		_music = loadSound(97, musicId);
+	}
 }
 
 void SoundManager::freeMusic() {
diff --git a/engines/access/sound.h b/engines/access/sound.h
index cc02229..5c13066 100644
--- a/engines/access/sound.h
+++ b/engines/access/sound.h
@@ -46,6 +46,7 @@ public:
 	Common::Array<Resource *> _soundTable;
 	Common::Array<int> _soundPriority;
 	Resource *_music;
+	Resource *_tempMusic;
 	bool _musicRepeat;
 	bool _playingSound;
 	bool _isVoice;


Commit: 2805dcaa7bcb315e124e0f2bab7218d834a05d99
    https://github.com/scummvm/scummvm/commit/2805dcaa7bcb315e124e0f2bab7218d834a05d99
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-12T22:20:32-05:00

Commit Message:
ACCESS: Implement freeSounds

Changed paths:
    engines/access/sound.cpp
    engines/access/sound.h



diff --git a/engines/access/sound.cpp b/engines/access/sound.cpp
index 072261d..dd8cf16 100644
--- a/engines/access/sound.cpp
+++ b/engines/access/sound.cpp
@@ -93,8 +93,13 @@ void SoundManager::stopSong() {
 	// TODO
 }
 
+void SoundManager::stopSound() {
+	// TODO: REALSTOPSND or BLASTSTOPSND or STOP_SOUNDG
+}
+
 void SoundManager::freeSounds() {
-	// TODO
+	stopSound();
+	clearSounds();
 }
 
 void SoundManager::newMusic(int musicId, int mode) {
diff --git a/engines/access/sound.h b/engines/access/sound.h
index 5c13066..c1b3981 100644
--- a/engines/access/sound.h
+++ b/engines/access/sound.h
@@ -42,6 +42,8 @@ private:
 	void clearSounds();
 
 	void playSound(Resource *res, int priority);
+	void stopSound();
+
 public:
 	Common::Array<Resource *> _soundTable;
 	Common::Array<int> _soundPriority;


Commit: 7a178098a7139ee593872d551057a9892158158c
    https://github.com/scummvm/scummvm/commit/7a178098a7139ee593872d551057a9892158158c
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-12T22:20:46-05:00

Commit Message:
ACCESS: Remove a useless check, comment out some code related to original debugging

Changed paths:
    engines/access/player.cpp



diff --git a/engines/access/player.cpp b/engines/access/player.cpp
index b8eb08a..869467a 100644
--- a/engines/access/player.cpp
+++ b/engines/access/player.cpp
@@ -259,9 +259,10 @@ void Player::walkUp() {
 		_rawPlayerLow.y = _rawYTempL;
 		
 		calcManScale();
-		if (_vm->_currentMan != 3 && (_frame == 17 || _frame == 21)) {
-			warning("TODO: walkUp - si = 0?");
-		}
+
+		// This code looks totally useless as 'si' is unconditionally set in plotCom
+		//if (_vm->_currentMan != 3 && (_frame == 17 || _frame == 21))
+		//	warning("TODO: walkUp - si = 0?");
 
 		if (++_frame > _upWalkMax)
 			_frame = _upWalkMin;
@@ -288,9 +289,10 @@ void Player::walkDown() {
 		_rawPlayerLow.y = _rawYTempL;
 
 		calcManScale();
-		if (_vm->_currentMan != 3 && (_frame == 10 || _frame == 14)) {
-			warning("TODO: walkDown - si = 0?");
-		}
+
+		// This code looks totally useless as 'si' is unconditionally set in plotCom
+		//if (_vm->_currentMan != 3 && (_frame == 10 || _frame == 14))
+		//	warning("TODO: walkDown - si = 0?");
 
 		if (++_frame > _downWalkMax)
 			_frame = _downWalkMin;
@@ -329,9 +331,9 @@ void Player::walkLeft() {
 		_rawPlayerLow.x = _rawTempL;
 		++_frame;
 
-		if (_vm->_currentMan != 3 && (_frame == 1 || _frame == 5)) {
-			warning("TODO: walkLeft - si = 0?");
-		}
+		// This code looks totally useless as 'si' is unconditionally set in plotCom1
+		//if (_vm->_currentMan != 3 && (_frame == 1 || _frame == 5))
+		//	warning("TODO: walkLeft - si = 0?");
 
 		if (_frame > _sideWalkMax)
 			_frame = _sideWalkMin;
@@ -370,10 +372,7 @@ void Player::walkRight() {
 		_rawPlayerLow.x = _rawTempL;
 		++_frame;
 
-		if (_vm->_currentMan != 3 && (_frame == 1 || _frame == 5)) {
-			warning("TODO: walkRight - si = 0?");
-		}
-
+		// Useless check removed
 		if (_frame > _sideWalkMax)
 			_frame = _sideWalkMin;
 
@@ -421,9 +420,9 @@ void Player::walkUpLeft() {
 		++_frame;
 		calcManScale();
 
-		if (_vm->_currentMan != 3 && (_frame == 1 || _frame == 5)) {
-			warning("TODO: walkUpLeft - si = 0?");
-		}
+		// This code looks totally useless as 'si' is unconditionally set in plotCom1
+		//if (_vm->_currentMan != 3 && (_frame == 1 || _frame == 5))
+		//	warning("TODO: walkUpLeft - si = 0?");
 
 		if (_frame > _diagUpWalkMax)
 			_frame = _diagUpWalkMin;
@@ -472,9 +471,9 @@ void Player::walkDownLeft() {
 		++_frame;
 		calcManScale();
 		
-		if (_vm->_currentMan != 3 && (_frame == 1 || _frame == 5)) {
-			warning("TODO: walkDownLeft - si = 0?");
-		}
+		// This code looks totally useless as 'si' is unconditionally set in plotCom1
+		//if (_vm->_currentMan != 3 && (_frame == 1 || _frame == 5))
+		//	warning("TODO: walkDownLeft - si = 0?");
 
 		if (_frame > _diagDownWalkMax)
 			_frame = _diagDownWalkMin;
@@ -523,9 +522,9 @@ void Player::walkUpRight() {
 		++_frame;
 		calcManScale();
 
-		if (_vm->_currentMan != 3 && (_frame == 1 || _frame == 5)) {
-			warning("TODO: walkUpRight - si = 0?");
-		}
+		// This code looks totally useless as 'si' is unconditionally set in plotCom
+		//if (_vm->_currentMan != 3 && (_frame == 1 || _frame == 5))
+		//	warning("TODO: walkUpRight - si = 0?");
 
 		if (_frame > _diagUpWalkMax)
 			_frame = _diagUpWalkMin;
@@ -575,9 +574,9 @@ void Player::walkDownRight() {
 		++_frame;
 		calcManScale();
 
-		if (_vm->_currentMan != 3 && (_frame == 1 || _frame == 5)) {
-			warning("TODO: walkDownRight - si = 0?");
-		}
+		// This code looks totally useless as 'si' is unconditionally set in plotCom1
+		//if (_vm->_currentMan != 3 && (_frame == 1 || _frame == 5))
+		//	warning("TODO: walkDownRight - si = 0?");
 
 		if (_frame > _diagDownWalkMax)
 			_frame = _diagDownWalkMin;


Commit: 32bbfe3f606b1d02ec9283c92ceb8c74264c3008
    https://github.com/scummvm/scummvm/commit/32bbfe3f606b1d02ec9283c92ceb8c74264c3008
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-12T22:20:59-05:00

Commit Message:
ACCESS: Fix a little bug in walkUpRight()

Changed paths:
    engines/access/player.cpp



diff --git a/engines/access/player.cpp b/engines/access/player.cpp
index 869467a..ba5ba89 100644
--- a/engines/access/player.cpp
+++ b/engines/access/player.cpp
@@ -486,7 +486,7 @@ void Player::walkUpRight() {
 	if (_frame > _diagUpWalkMax || _frame < _diagUpWalkMin)
 		_frame = _diagUpWalkMin;
 
-	_playerDirection = UPLEFT;
+	_playerDirection = UPRIGHT;
 
 	int walkOffset, tempL;
 	bool flag = _scrollEnd == 1;


Commit: 958dd0b77bb7becc489d717806bbb96734901217
    https://github.com/scummvm/scummvm/commit/958dd0b77bb7becc489d717806bbb96734901217
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-12T22:21:18-05:00

Commit Message:
ACCESS: Hood newMusic in cmdSpecial

Changed paths:
    engines/access/amazon/amazon_scripts.cpp



diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp
index 3e7fd4e..9ecaadd 100644
--- a/engines/access/amazon/amazon_scripts.cpp
+++ b/engines/access/amazon/amazon_scripts.cpp
@@ -390,7 +390,7 @@ void AmazonScripts::executeSpecial(int commandIndex, int param1, int param2) {
 		guard();
 		break;
 	case 10:
-		warning("TODO NEWMUSIC");
+		_vm->_sound->newMusic(param1, param2);
 		break;
 	case 11:
 		plotInactive();


Commit: e46c0ac66a1fc94439264e4a07bbc92b09c03c07
    https://github.com/scummvm/scummvm/commit/e46c0ac66a1fc94439264e4a07bbc92b09c03c07
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-12T22:21:35-05:00

Commit Message:
ACCESS: Fix resetting cursor after conversations

Changed paths:
    engines/access/access.cpp
    engines/access/access.h
    engines/access/amazon/amazon_room.cpp
    engines/access/martian/martian_room.cpp



diff --git a/engines/access/access.cpp b/engines/access/access.cpp
index fab66c3..a3cadc1 100644
--- a/engines/access/access.cpp
+++ b/engines/access/access.cpp
@@ -51,7 +51,6 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc)
 	_destIn = nullptr;
 	_current = nullptr;
 	_pCount = 0;
-	_normalMouse = true;
 	_mouseMode = 0;
 	_currentMan = 0;
 	_currentManOld = -1;
diff --git a/engines/access/access.h b/engines/access/access.h
index fcac69d..36951c7 100644
--- a/engines/access/access.h
+++ b/engines/access/access.h
@@ -172,7 +172,6 @@ public:
 	Common::Array<ExtraCell> _extraCells;
 	ImageEntryList _images;
 	int _pCount;
-	bool _normalMouse;
 	int _mouseMode;
 
 	int _currentManOld;
diff --git a/engines/access/amazon/amazon_room.cpp b/engines/access/amazon/amazon_room.cpp
index 39cea9a..098220e 100644
--- a/engines/access/amazon/amazon_room.cpp
+++ b/engines/access/amazon/amazon_room.cpp
@@ -84,7 +84,7 @@ void AmazonRoom::reloadRoom1() {
 	}
 
 	_selectCommand = -1;
-	_vm->_normalMouse = 1;
+	_vm->_events->_normalMouse = CURSOR_CROSSHAIRS;
 	_vm->_mouseMode = 0;
 	_vm->_boxSelect = true;
 	_vm->_player->_playerOff = false;
diff --git a/engines/access/martian/martian_room.cpp b/engines/access/martian/martian_room.cpp
index e624b0a..6d4d62f 100644
--- a/engines/access/martian/martian_room.cpp
+++ b/engines/access/martian/martian_room.cpp
@@ -82,7 +82,7 @@ void MartianRoom::reloadRoom1() {
 	}
 
 	_selectCommand = -1;
-	_vm->_normalMouse = 1;
+	_vm->_events->_normalMouse = CURSOR_CROSSHAIRS;
 	_vm->_mouseMode = 0;
 	_vm->_boxSelect = true;
 	_vm->_player->_playerOff = false;


Commit: 38f010f96f3ba2ff1ff217912d196873ecc29877
    https://github.com/scummvm/scummvm/commit/38f010f96f3ba2ff1ff217912d196873ecc29877
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-12T22:21:47-05:00

Commit Message:
ACCESS: Implement mWhileFly

Changed paths:
    engines/access/amazon/amazon_scripts.cpp
    engines/access/amazon/amazon_scripts.h
    engines/access/events.h



diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp
index 9ecaadd..a39b8ae 100644
--- a/engines/access/amazon/amazon_scripts.cpp
+++ b/engines/access/amazon/amazon_scripts.cpp
@@ -205,13 +205,98 @@ void AmazonScripts::mWhile2() {
 	} while (_vm->_flags[52] == 4);
 }
 
+void AmazonScripts::doFlyCell() {
+	_game->_destIn = &_game->_buffer2;
+	if (_game->_plane._pCount <= 40) {
+		_vm->_screen->plotImage(_vm->_objectsTable[15], 3, Common::Point(70, 74));
+	} else if (_game->_plane._pCount <= 80) {
+		_vm->_screen->plotImage(_vm->_objectsTable[15], 6, Common::Point(70, 74));
+	} else if (_game->_plane._pCount <= 120) {
+		_vm->_screen->plotImage(_vm->_objectsTable[15], 2, Common::Point(50, 76));
+	} else if (_game->_plane._pCount <= 160) {
+		_vm->_screen->plotImage(_vm->_objectsTable[15], 14, Common::Point(63, 78));
+	} else if (_game->_plane._pCount <= 200) {
+		_vm->_screen->plotImage(_vm->_objectsTable[15], 5, Common::Point(86, 74));
+	} else if (_game->_plane._pCount <= 240) {
+		_vm->_screen->plotImage(_vm->_objectsTable[15], 0, Common::Point(103, 76));
+	} else if (_game->_plane._pCount <= 280) {
+		_vm->_screen->plotImage(_vm->_objectsTable[15], 4, Common::Point(119, 77));
+	} else {
+		_vm->_screen->plotImage(_vm->_objectsTable[15], 1, Common::Point(111, 77));
+	}
+}
+
+void AmazonScripts::scrollFly() {
+	_vm->copyBF1BF2();
+	_vm->_newRects.clear();
+	doFlyCell();
+	_vm->copyRects();
+	_vm->copyBF2Vid();
+}
+
+void AmazonScripts::mWhileFly() {
+	_vm->_events->hideCursor();
+	_vm->_screen->clearScreen();
+	_vm->_screen->setBufferScan();
+	_vm->_screen->fadeOut();
+	_vm->_screen->_scrollX = 0;
+
+	_vm->_room->buildScreen();
+	_vm->copyBF2Vid();
+	_vm->_screen->fadeIn();
+	_vm->_oldRects.clear();
+	_vm->_newRects.clear();
+
+	// KEYFLG = 0;
+
+	_vm->_screen->_scrollRow = _vm->_screen->_scrollCol = 0;
+	_vm->_screen->_scrollX = _vm->_screen->_scrollY = 0;
+	_vm->_player->_rawPlayer = Common::Point(0, 0);
+	_vm->_player->_scrollAmount = 1;
+
+	_game->_plane._pCount = 0;
+	_game->_plane._planeCount = 0;
+	_game->_plane._propCount = 0;
+	_game->_plane._xCount = 0;
+	_game->_plane._position = Common::Point(20, 29);
+
+	warning("FIXME: _vbCount should be handled in NEWTIMER");
+	while (true) {
+		int _vbCount = 4;
+		if (_vm->_screen->_scrollCol + _vm->_screen->_vWindowWidth == _vm->_room->_playFieldWidth) {
+			_vm->_events->showCursor();
+			return;
+		}
+
+		_vm->_screen->_scrollX += _vm->_player->_scrollAmount;
+		while (_vm->_screen->_scrollX > TILE_WIDTH) {
+			_vm->_screen->_scrollX -= TILE_WIDTH;
+			++_vm->_screen->_scrollCol;
+
+			_vm->_buffer1.moveBufferLeft();
+			_vm->_room->buildColumn(_vm->_screen->_scrollCol + _vm->_screen->_vWindowWidth, _vm->_screen->_vWindowBytesWide);
+		}
+
+		scrollFly();
+		++_game->_plane._pCount;
+		g_system->delayMillis(10);
+
+		while(_vbCount > 0) {
+			// To be rewritten when NEWTIMER is done
+			_vm->_events->checkForNextFrameCounter();
+			_vbCount--;
+			_vm->_sound->playSound(0);
+		}
+	}
+}
+
 void AmazonScripts::mWhile(int param1) {
 	switch(param1) {
 	case 1:
 		mWhile1();
 		break;
 	case 2:
-		warning("TODO FLY");
+		mWhileFly();
 		break;
 	case 3:
 		warning("TODO FALL");
diff --git a/engines/access/amazon/amazon_scripts.h b/engines/access/amazon/amazon_scripts.h
index 694260d..fb2c66f 100644
--- a/engines/access/amazon/amazon_scripts.h
+++ b/engines/access/amazon/amazon_scripts.h
@@ -39,9 +39,12 @@ protected:
 	virtual void executeSpecial(int commandIndex, int param1, int param2);
 	virtual void executeCommand(int commandIndex);
 
+	void doFlyCell();
+	void scrollFly();
 	void cLoop();
 	void mWhile1();
 	void mWhile2();
+	void mWhileFly();
 	void mWhile(int param1);
 	void guardSee();
 	void setGuardFrame();
diff --git a/engines/access/events.h b/engines/access/events.h
index 6b46086..313a039 100644
--- a/engines/access/events.h
+++ b/engines/access/events.h
@@ -47,9 +47,6 @@ private:
 	uint32 _frameCounter;
 	uint32 _priorFrameTime;
 	Graphics::Surface _invCursor;
-
-	bool checkForNextFrameCounter();
-
 	void nextFrame();
 public:
 	CursorType _cursorId;
@@ -119,6 +116,8 @@ public:
 
 	void waitKeyMouse();
 
+	bool checkForNextFrameCounter();
+
 	Common::Point &getMousePos() { return _mousePos; }
 
 	Common::Point calcRawMouse();


Commit: 43e8e905906ad77f1a98efd255ee7589edff7518
    https://github.com/scummvm/scummvm/commit/43e8e905906ad77f1a98efd255ee7589edff7518
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-12T22:22:01-05:00

Commit Message:
ACCESS: Don't show inventory items that have been used

Changed paths:
    engines/access/inventory.cpp



diff --git a/engines/access/inventory.cpp b/engines/access/inventory.cpp
index 25c9060..bb735d4 100644
--- a/engines/access/inventory.cpp
+++ b/engines/access/inventory.cpp
@@ -255,7 +255,7 @@ void InventoryManager::getList() {
 	_tempLOff.clear();
 
 	for (uint i = 0; i < _inv.size(); ++i) {
-		if (_inv[i]) {
+		if (_inv[i] == 1) {
 			_items.push_back(i);
 			_tempLOff.push_back(_names[i]);
 		}


Commit: d5ddd2268106d57c8f5cb84d1afd67f26a7a3ccc
    https://github.com/scummvm/scummvm/commit/d5ddd2268106d57c8f5cb84d1afd67f26a7a3ccc
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-12T22:22:10-05:00

Commit Message:
ACCESS: Implement mWhileFall

Changed paths:
    engines/access/amazon/amazon_scripts.cpp
    engines/access/amazon/amazon_scripts.h



diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp
index a39b8ae..af619cb 100644
--- a/engines/access/amazon/amazon_scripts.cpp
+++ b/engines/access/amazon/amazon_scripts.cpp
@@ -226,6 +226,27 @@ void AmazonScripts::doFlyCell() {
 	}
 }
 
+void AmazonScripts::doFallCell() {
+	if (_vm->_scaleI <= 0)
+		return;
+
+	_game->_destIn = &_game->_buffer2;
+
+	// 115, 11, i
+	_vm->_screen->plotImage(_vm->_objectsTable[20], _game->_plane._planeCount / 6, Common::Point(115, 11));
+	_vm->_scaleI -= 3;
+	_vm->_scale = _vm->_scaleI;
+	_vm->_screen->setScaleTable(_vm->_scale);
+	++_game->_plane._xCount;
+	if (_game->_plane._xCount == 5)
+		return;
+	_game->_plane._xCount = 0;
+	if (_game->_plane._planeCount == 18)
+		_game->_plane._planeCount = 0;
+	else
+		_game->_plane._planeCount += 6;
+}
+
 void AmazonScripts::scrollFly() {
 	_vm->copyBF1BF2();
 	_vm->_newRects.clear();
@@ -234,6 +255,14 @@ void AmazonScripts::scrollFly() {
 	_vm->copyBF2Vid();
 }
 
+void AmazonScripts::scrollFall() {
+	_vm->copyBF1BF2();
+	_vm->_newRects.clear();
+	doFallCell();
+	_vm->copyRects();
+	_vm->copyBF2Vid();
+}
+
 void AmazonScripts::mWhileFly() {
 	_vm->_events->hideCursor();
 	_vm->_screen->clearScreen();
@@ -290,6 +319,56 @@ void AmazonScripts::mWhileFly() {
 	}
 }
 
+void AmazonScripts::mWhileFall() {
+	_vm->_events->hideCursor();
+	_vm->_screen->clearScreen();
+	_vm->_screen->setBufferScan();
+	_vm->_screen->fadeOut();
+	_vm->_screen->_scrollX = 0;
+
+	_vm->_room->buildScreen();
+	_vm->copyBF2Vid();
+	_vm->_screen->fadeIn();
+	_vm->_oldRects.clear();
+	_vm->_newRects.clear();
+
+	// KEYFLG = 0;
+
+	_vm->_screen->_scrollRow = _vm->_screen->_scrollCol = 0;
+	_vm->_screen->_scrollX = _vm->_screen->_scrollY = 0;
+	_vm->_player->_scrollAmount = 3;
+	_vm->_scaleI = 255;
+
+	_game->_plane._xCount = 0;
+	_game->_plane._planeCount = 0;
+
+	while (true) {
+		int _vbCount = 4;
+		if (_vm->_screen->_scrollCol + _vm->_screen->_vWindowWidth == _vm->_room->_playFieldWidth) {
+			_vm->_events->showCursor();
+			return;
+		}
+
+		_vm->_screen->_scrollX += _vm->_player->_scrollAmount;
+		while (_vm->_screen->_scrollX >= TILE_WIDTH) {
+			_vm->_screen->_scrollX -= TILE_WIDTH;
+			++_vm->_screen->_scrollCol;
+
+			_vm->_buffer1.moveBufferLeft();
+			_vm->_room->buildColumn(_vm->_screen->_scrollCol + _vm->_screen->_vWindowWidth, _vm->_screen->_vWindowBytesWide);
+		}
+
+		scrollFall();
+		g_system->delayMillis(10);
+
+		while(_vbCount > 0) {
+			// To be rewritten when NEWTIMER is done
+			_vm->_events->checkForNextFrameCounter();
+			_vbCount--;
+		}
+	}
+}
+
 void AmazonScripts::mWhile(int param1) {
 	switch(param1) {
 	case 1:
@@ -299,7 +378,7 @@ void AmazonScripts::mWhile(int param1) {
 		mWhileFly();
 		break;
 	case 3:
-		warning("TODO FALL");
+		mWhileFall();
 		break;
 	case 4:
 		warning("TODO JWALK");
diff --git a/engines/access/amazon/amazon_scripts.h b/engines/access/amazon/amazon_scripts.h
index fb2c66f..ca96de6 100644
--- a/engines/access/amazon/amazon_scripts.h
+++ b/engines/access/amazon/amazon_scripts.h
@@ -40,11 +40,14 @@ protected:
 	virtual void executeCommand(int commandIndex);
 
 	void doFlyCell();
+	void doFallCell();
 	void scrollFly();
+	void scrollFall();
 	void cLoop();
 	void mWhile1();
 	void mWhile2();
 	void mWhileFly();
+	void mWhileFall();
 	void mWhile(int param1);
 	void guardSee();
 	void setGuardFrame();


Commit: a7d88af24d0a2c1e37b91f716ad85c8e7eb000c6
    https://github.com/scummvm/scummvm/commit/a7d88af24d0a2c1e37b91f716ad85c8e7eb000c6
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-12T22:22:21-05:00

Commit Message:
ACCESS: Fix tiny bug in mWhileFly

Changed paths:
    engines/access/amazon/amazon_scripts.cpp



diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp
index af619cb..688dbe0 100644
--- a/engines/access/amazon/amazon_scripts.cpp
+++ b/engines/access/amazon/amazon_scripts.cpp
@@ -298,7 +298,7 @@ void AmazonScripts::mWhileFly() {
 		}
 
 		_vm->_screen->_scrollX += _vm->_player->_scrollAmount;
-		while (_vm->_screen->_scrollX > TILE_WIDTH) {
+		while (_vm->_screen->_scrollX >= TILE_WIDTH) {
 			_vm->_screen->_scrollX -= TILE_WIDTH;
 			++_vm->_screen->_scrollCol;
 


Commit: fb686191a813c633d215f06ca2aadbf3ad9c64ac
    https://github.com/scummvm/scummvm/commit/fb686191a813c633d215f06ca2aadbf3ad9c64ac
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-12T22:22:30-05:00

Commit Message:
ACCESS: Fix initialisation of Y positioning in rooms with vertical scrolling

Changed paths:
    engines/access/room.cpp



diff --git a/engines/access/room.cpp b/engines/access/room.cpp
index 9b83077..76ad29e 100644
--- a/engines/access/room.cpp
+++ b/engines/access/room.cpp
@@ -267,14 +267,15 @@ void Room::setupRoom() {
 		screen._scrollRow = 0;
 	} else {
 		screen._scrollY = _vm->_player->_rawPlayer.y -
-			(_vm->_player->_rawPlayer.y >> 4);
-		int yp = MAX((_vm->_player->_rawPlayer.y >> 4) -
+			(_vm->_player->_rawPlayer.y / 16) * 16;
+		int yc = MAX((_vm->_player->_rawPlayer.y >> 4) -
 			(screen._vWindowHeight / 2), 0);
-		screen._scrollRow = yp;
+		screen._scrollRow = yc;
 
-		yp = yp + screen._vWindowHeight - _playFieldHeight;
-		if (yp >= 0) {
-			screen._scrollRow = yp + 1;
+		yc = yc + screen._vWindowHeight - _playFieldHeight;
+		if (yc >= 0) {
+			screen._scrollRow = _playFieldHeight - screen._vWindowHeight;
+			screen._scrollY = 0;
 		}
 	}
 }


Commit: 2c700cc6cd633b2a07ae5b10c803fb7b7321413c
    https://github.com/scummvm/scummvm/commit/2c700cc6cd633b2a07ae5b10c803fb7b7321413c
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-12T22:22:41-05:00

Commit Message:
ACCESS: Start implementing mWhileJWalk()

Changed paths:
    engines/access/amazon/amazon_scripts.cpp
    engines/access/amazon/amazon_scripts.h
    engines/access/player.h



diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp
index 688dbe0..d2370a2 100644
--- a/engines/access/amazon/amazon_scripts.cpp
+++ b/engines/access/amazon/amazon_scripts.cpp
@@ -32,6 +32,27 @@ namespace Amazon {
 
 AmazonScripts::AmazonScripts(AccessEngine *vm) : Scripts(vm) {
 	_game = (AmazonEngine *)_vm;
+
+	_xTrack = 0;
+	_yTrack = 0;
+	_zTrack = 0;
+	_xCam = 0;
+	_yCam = 0;
+	_zCam = 0;
+
+	_pNumObj = 0;
+	for (int i = 0; i < 32; i++) {
+		_pImgNum[i] = 0;
+		_pObject[i] = nullptr;
+		_pObjX[i] = 0;
+		_pObjY[i] = 0;
+		_pObjZ[i] = 0;
+	}
+
+	for (int i = 0; i < 16; i++) {
+		_pObjXl[i] = 0;
+		_pObjYl[i] = 0;
+	}
 }
 
 void AmazonScripts::cLoop() {
@@ -247,6 +268,10 @@ void AmazonScripts::doFallCell() {
 		_game->_plane._planeCount += 6;
 }
 
+void AmazonScripts::PAN() {
+	warning("TODO: PAN");
+}
+
 void AmazonScripts::scrollFly() {
 	_vm->copyBF1BF2();
 	_vm->_newRects.clear();
@@ -263,6 +288,14 @@ void AmazonScripts::scrollFall() {
 	_vm->copyBF2Vid();
 }
 
+void AmazonScripts::scrollJWalk() {
+	_vm->copyBF1BF2();
+	_vm->_newRects.clear();
+	_game->plotList();
+	_vm->copyRects();
+	_vm->copyBF2Vid();
+}
+
 void AmazonScripts::mWhileFly() {
 	_vm->_events->hideCursor();
 	_vm->_screen->clearScreen();
@@ -369,6 +402,83 @@ void AmazonScripts::mWhileFall() {
 	}
 }
 
+void AmazonScripts::mWhileJWalk() {
+	const int jungleObj[7][4] = {
+		{2, 77, 0, 40},
+		{0, 290, 0, 50},
+		{1, 210, 0, 70},
+		{0, 50, 0, 30},
+		{1, 70, 0, 20},
+		{0, -280, 0, 60},
+		{1, -150, 0, 30},
+	};
+
+	_vm->_screen->fadeOut();
+	_vm->_events->hideCursor();
+	_vm->_screen->clearScreen();
+	_vm->_buffer2.clearBuffer();
+	_vm->_screen->setBufferScan();
+	_vm->_screen->_scrollX = 0;
+
+	_vm->_room->buildScreen();
+	_vm->copyBF2Vid();
+	_vm->_screen->fadeIn();
+
+	// KEYFLG = 0;
+	_vm->_player->_xFlag = 1;
+	_vm->_player->_yFlag = 0;
+	_vm->_player->_moveTo.x = 160;
+	_vm->_player->_move = UP;
+
+	_game->_plane._xCount = 2;
+	_xTrack = 10;
+	_yTrack = _zTrack = 0;
+	_xCam = 480;
+	_yCam = 0;
+	_zCam = 80;
+
+	TimerEntry *te = &_vm->_timers[24];
+	te->_initTm = te->_timer = 1;
+	te->_flag++;
+	
+	_pNumObj = 7;
+	for (int i = 0; i < _pNumObj; i++) {
+		_pObject[i] = _vm->_objectsTable[24];
+		_pImgNum[i] = jungleObj[i][0];
+		_pObjX[i] = jungleObj[i][1];
+		_pObjY[i] = jungleObj[i][2];
+		_pObjZ[i] = jungleObj[i][3];
+		_pObjXl[i] = _pObjYl[i] = 0;
+	}
+	
+	while (true) {
+		_vm->_images.clear();
+		int _vbCount = 6;
+		if (_vm->_player->_xFlag == 2) {
+			_vm->_events->showCursor();
+			return;
+		}
+		
+		_pImgNum[0] = _game->_plane._xCount;
+		if (_game->_plane._xCount == 2)
+			++_game->_plane._xCount;
+		else
+			--_game->_plane._xCount;
+
+		_vm->_player->checkMove();
+		_vm->_player->checkScroll();
+		PAN();
+		scrollJWalk();
+
+		g_system->delayMillis(10);
+		while(_vbCount > 0) {
+			// To be rewritten when NEWTIMER is done
+			_vm->_events->checkForNextFrameCounter();
+			_vbCount--;
+		}
+	}
+}
+
 void AmazonScripts::mWhile(int param1) {
 	switch(param1) {
 	case 1:
@@ -381,7 +491,7 @@ void AmazonScripts::mWhile(int param1) {
 		mWhileFall();
 		break;
 	case 4:
-		warning("TODO JWALK");
+		mWhileJWalk();
 		break;
 	case 5:
 		warning("TODO DOOPEN");
diff --git a/engines/access/amazon/amazon_scripts.h b/engines/access/amazon/amazon_scripts.h
index ca96de6..50fab5c 100644
--- a/engines/access/amazon/amazon_scripts.h
+++ b/engines/access/amazon/amazon_scripts.h
@@ -35,6 +35,26 @@ class AmazonEngine;
 class AmazonScripts: public Scripts {
 private:
 	AmazonEngine *_game;
+
+	int _xTrack;
+	int _yTrack;
+	int _zTrack;
+	int _xCam;
+	int _yCam;
+	int _zCam;
+
+	int _pNumObj;
+	int _pImgNum[32];
+	SpriteResource *_pObject[32];
+
+	int _pObjX[32];
+	int _pObjY[32];
+	int _pObjZ[32];
+	int _pObjXl[16];
+	int _pObjYl[16];
+
+	void PAN();
+
 protected:
 	virtual void executeSpecial(int commandIndex, int param1, int param2);
 	virtual void executeCommand(int commandIndex);
@@ -43,11 +63,13 @@ protected:
 	void doFallCell();
 	void scrollFly();
 	void scrollFall();
+	void scrollJWalk();
 	void cLoop();
 	void mWhile1();
 	void mWhile2();
 	void mWhileFly();
 	void mWhileFall();
+	void mWhileJWalk();
 	void mWhile(int param1);
 	void guardSee();
 	void setGuardFrame();
diff --git a/engines/access/player.h b/engines/access/player.h
index c5c9afa..ed48af0 100644
--- a/engines/access/player.h
+++ b/engines/access/player.h
@@ -49,14 +49,11 @@ private:
 	int _diagUpWalkMin, _diagUpWalkMax;
 	int _diagDownWalkMin, _diagDownWalkMax;
 	Common::Point _guard;
-	Direction _move;
-	int _xFlag, _yFlag;
 	SpriteResource *_playerSprites1;
 	byte *_manPal1;
 	int _scrollEnd;
 	int _inactiveYOff;
 
-	void checkMove();
 	void plotCom(int v1);
 	void plotCom1();
 	void plotCom2();
@@ -97,6 +94,8 @@ public:
 	int _playerYLow;
 	int _playerY;
 	int _frame;
+	int _xFlag, _yFlag;
+	Direction _move;
 
 	// Additional public globals we've added to new Player class
 	bool _playerOff;
@@ -129,6 +128,8 @@ public:
 
 	void checkScroll();
 
+	void checkMove();
+
 	/**
 	* Synchronize savegame data
 	*/


Commit: b8c95e653dab6a82926effe772b03eb6770e6083
    https://github.com/scummvm/scummvm/commit/b8c95e653dab6a82926effe772b03eb6770e6083
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-12T22:22:54-05:00

Commit Message:
ACCESS: Implement pan()

Changed paths:
    engines/access/amazon/amazon_scripts.cpp
    engines/access/amazon/amazon_scripts.h



diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp
index d2370a2..2b489d6 100644
--- a/engines/access/amazon/amazon_scripts.cpp
+++ b/engines/access/amazon/amazon_scripts.cpp
@@ -268,8 +268,32 @@ void AmazonScripts::doFallCell() {
 		_game->_plane._planeCount += 6;
 }
 
-void AmazonScripts::PAN() {
-	warning("TODO: PAN");
+void AmazonScripts::pan() {
+	_zCam += _zTrack;
+	_xCam += _xTrack;
+	int tx = (_xCam << 8) / _zCam;
+	_yCam += _yTrack;
+	int ty = (_yCam << 8) / _zCam;
+
+	if (_vm->_timers[24]._flag != 1) {
+		++_vm->_timers[24]._flag;
+		for (int i = 0; i < _pNumObj; i++) {
+			_pObjZ[i] = _zTrack;
+			_pObjXl[i] += tx * _zTrack;
+			_pObjX[i] += _pObjXl[i];
+			_pObjYl[i] += ty * _zTrack;
+			_pObjY[i] += _pObjYl[i];
+		}
+	}
+
+	for (int i = 0; i < _pNumObj; i++) {
+		ImageEntry ie;
+		ie._flags= 8;
+		ie._position = Common::Point(_pObjX[i], _pObjY[i]);
+		ie._offsetY = 0xFF;
+		ie._spritesPtr = _pObject[i];
+		ie._frameNumber = _pImgNum[i];
+	}
 }
 
 void AmazonScripts::scrollFly() {
@@ -467,7 +491,7 @@ void AmazonScripts::mWhileJWalk() {
 
 		_vm->_player->checkMove();
 		_vm->_player->checkScroll();
-		PAN();
+		pan();
 		scrollJWalk();
 
 		g_system->delayMillis(10);
diff --git a/engines/access/amazon/amazon_scripts.h b/engines/access/amazon/amazon_scripts.h
index 50fab5c..1ee8b98 100644
--- a/engines/access/amazon/amazon_scripts.h
+++ b/engines/access/amazon/amazon_scripts.h
@@ -53,7 +53,7 @@ private:
 	int _pObjXl[16];
 	int _pObjYl[16];
 
-	void PAN();
+	void pan();
 
 protected:
 	virtual void executeSpecial(int commandIndex, int param1, int param2);


Commit: 6ceda069c7042bc081845d3a52f99e21a58c43d8
    https://github.com/scummvm/scummvm/commit/6ceda069c7042bc081845d3a52f99e21a58c43d8
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-12T22:23:04-05:00

Commit Message:
ACCESS: Beginnings of inventory dragging for combining items

Changed paths:
    engines/access/amazon/amazon_resources.cpp
    engines/access/amazon/amazon_resources.h
    engines/access/events.cpp
    engines/access/events.h
    engines/access/inventory.cpp
    engines/access/inventory.h
    engines/access/scripts.cpp
    engines/access/scripts.h



diff --git a/engines/access/amazon/amazon_resources.cpp b/engines/access/amazon/amazon_resources.cpp
index 0807a97..c2eab7b 100644
--- a/engines/access/amazon/amazon_resources.cpp
+++ b/engines/access/amazon/amazon_resources.cpp
@@ -1352,6 +1352,94 @@ const int CHAPTER_JUMP[14] = {
 	0, 12, 10, 15, 19, 25, 31, 36, 45, 46, 29, 55, 61, 0
 };
 
+const int COMBO_TABLE[85][4] = {
+	{ -1, -1, -1, -1 },
+	{ 12, 3, -1, -1 },
+	{ -1, -1, -1, -1 },
+	{ -1, -1, -1, -1 },
+	{ -1, -1, -1, -1 },
+	{ -1, -1, -1, -1 },
+	{ -1, -1, -1, -1 },
+	{ 24, 25, -1, -1 },
+	{ 10, 24, -1, -1 },
+	{ -1, -1, -1, -1 },
+	{ 8, 24, -1, -1 },
+	{ -1, -1, -1, -1 },
+	{ 1, 3, -1, -1 },
+	{ -1, -1, -1, -1 },
+	{ -1, -1, -1, -1 },
+	{ -1, -1, -1, -1 },
+	{ -1, -1, -1, -1 },
+	{ -1, -1, -1, -1 },
+	{ -1, -1, -1, -1 },
+	{ -1, -1, -1, -1 },
+	{ -1, -1, -1, -1 },
+	{ -1, -1, -1, -1 },
+	{ -1, -1, -1, -1 },
+	{ -1, -1, -1, -1 },
+	{ 7, 25, -1, -1 },
+	{ -1, -1, -1, -1 },
+	{ -1, -1, -1, -1 },
+	{ -1, -1, -1, -1 },
+	{ -1, -1, -1, -1 },
+	{ 80, 81, -1, -1 },
+	{ -1, -1, -1, -1 },
+	{ -1, -1, -1, -1 },
+	{ 41, 42, -1, -1 },
+	{ -1, -1, -1, -1 },
+	{ -1, -1, -1, -1 },
+	{ -1, -1, -1, -1 },
+	{ -1, -1, -1, -1 },
+	{ -1, -1, -1, -1 },
+	{ 39, 40, -1, -1 },
+	{ 38, 40, -1, -1 },
+	{ -1, -1, -1, -1 },
+	{ 32, 42, 77, 78 },
+	{ -1, -1, -1, -1 },
+	{ 60, 61, -1, -1 },
+	{ -1, -1, -1, -1 },
+	{ -1, -1, -1, -1 },
+	{ -1, -1, -1, -1 },
+	{ -1, -1, -1, -1 },
+	{ -1, -1, -1, -1 },
+	{ -1, -1, -1, -1 },
+	{ 73, 72, -1, -1 },
+	{ -1, -1, -1, -1 },
+	{ -1, -1, -1, -1 },
+	{ -1, -1, -1, -1 },
+	{ -1, -1, -1, -1 },
+	{ -1, -1, -1, -1 },
+	{ 64, 67, -1, -1 },
+	{ -1, -1, -1, -1 },
+	{ 59, 60, -1, -1 },
+	{ 58, 60, -1, -1 },
+	{ 43, 61, -1, -1 },
+	{ -1, -1, -1, -1 },
+	{ -1, -1, -1, -1 },
+	{ -1, -1, -1, -1 },
+	{ 56, 67, -1, -1 },
+	{ -1, -1, -1, -1 },
+	{ -1, -1, -1, -1 },
+	{ -1, -1, -1, -1 },
+	{ -1, -1, -1, -1 },
+	{ -1, -1, -1, -1 },
+	{ -1, -1, -1, -1 },
+	{ -1, -1, -1, -1 },
+	{ -1, -1, -1, -1 },
+	{ 50, 72, -1, -1 },
+	{ 75, 77, -1, -1 },
+	{ 74, 77, -1, -1 },
+	{ -1, -1, -1, -1 },
+	{ 41, 78, -1, -1 },
+	{ -1, -1, -1, -1 },
+	{ -1, -1, -1, -1 },
+	{ 29, 81, -1, -1 },
+	{ -1, -1, -1, -1 },
+	{ -1, -1, -1, -1 },
+	{ -1, -1, -1, -1 },
+	{ -1, -1, -1, -1 }
+};
+
 } // End of namespace Amazon
 
 } // End of namespace Access
diff --git a/engines/access/amazon/amazon_resources.h b/engines/access/amazon/amazon_resources.h
index d8d37b5..2be9b4d 100644
--- a/engines/access/amazon/amazon_resources.h
+++ b/engines/access/amazon/amazon_resources.h
@@ -64,6 +64,8 @@ extern const int CHAPTER_TABLE[14][5];
 
 extern const int CHAPTER_JUMP[14];
 
+extern const int COMBO_TABLE[85][4];
+
 } // End of namespace Amazon
 
 } // End of namespace Access
diff --git a/engines/access/events.cpp b/engines/access/events.cpp
index 0a75430..0b7a348 100644
--- a/engines/access/events.cpp
+++ b/engines/access/events.cpp
@@ -250,5 +250,18 @@ Common::Point EventsManager::calcRawMouse() {
 	return pt;
 }
 
+int EventsManager::checkMouseBox1(Common::Array<Common::Rect> &rects) {
+	int i = 0;
+	for (i = 0;; i++) {
+		if (rects[i].left == -1)
+			return -1;
+
+		if ((_mousePos.x > rects[i].left) && (_mousePos.x < rects[i].right)
+			&& (_mousePos.y > rects[i].top) && (_mousePos.y < rects[i].bottom))
+			return i;
+	}
+}
+
+
 
 } // End of namespace Access
diff --git a/engines/access/events.h b/engines/access/events.h
index 313a039..b29b541 100644
--- a/engines/access/events.h
+++ b/engines/access/events.h
@@ -121,6 +121,8 @@ public:
 	Common::Point &getMousePos() { return _mousePos; }
 
 	Common::Point calcRawMouse();
+
+	int checkMouseBox1(Common::Array<Common::Rect> &rects);
 };
 
 } // End of namespace Access
diff --git a/engines/access/inventory.cpp b/engines/access/inventory.cpp
index bb735d4..f31379a 100644
--- a/engines/access/inventory.cpp
+++ b/engines/access/inventory.cpp
@@ -28,6 +28,26 @@
 
 namespace Access {
 
+void InventoryEntry::load(const Common::String &name, const int *data) {
+	_value = 0;
+	_name = name;
+	_otherItem1 = *data++;
+	_newItem1 = *data++;
+	_otherItem2 = *data++;
+	_newItem2 = *data;
+}
+
+int InventoryEntry::checkItem(int itemId) {
+	if (_otherItem1 == itemId)
+		return _newItem1;
+	else if (_otherItem2 == itemId)
+		return _newItem2;
+	else
+		return -1;
+}
+
+/*------------------------------------------------------------------------*/
+
 InventoryManager::InventoryManager(AccessEngine *vm) : Manager(vm) {
 	_startInvItem = 0;
 	_startInvBox = 0;
@@ -39,9 +59,12 @@ InventoryManager::InventoryManager(AccessEngine *vm) : Manager(vm) {
 	_iconDisplayFlag = true;
 
 	const char *const *names;
+	const int *combineP;
+
 	switch (vm->getGameID()) {
 	case GType_Amazon:
 		names = Amazon::INVENTORY_NAMES;
+		combineP = &Amazon::COMBO_TABLE[0][0];
 		_inv.resize(85);
 		break;
 	case GType_MartianMemorandum:
@@ -52,8 +75,9 @@ InventoryManager::InventoryManager(AccessEngine *vm) : Manager(vm) {
 		error("Unknown game");
 	}
 
-	for (uint i = 0; i < _inv.size(); ++i)
-		_names.push_back(names[i]);
+	for (uint i = 0; i < _inv.size(); ++i, combineP += 4) {
+		_inv[i].load(names[i], combineP);
+	}
 
 	for (uint i = 0; i < 26; ++i) {
 		const int *r = INVCOORDS[i];
@@ -62,7 +86,7 @@ InventoryManager::InventoryManager(AccessEngine *vm) : Manager(vm) {
 }
 
 int &InventoryManager::operator[](int idx) {
-	return _inv[idx];
+	return _inv[idx]._value;
 }
 
 int InventoryManager::useItem() { 
@@ -255,9 +279,9 @@ void InventoryManager::getList() {
 	_tempLOff.clear();
 
 	for (uint i = 0; i < _inv.size(); ++i) {
-		if (_inv[i] == 1) {
+		if (_inv[i]._value == 1) {
 			_items.push_back(i);
-			_tempLOff.push_back(_names[i]);
+			_tempLOff.push_back(_inv[i]._name);
 		}
 	}
 }
@@ -351,7 +375,69 @@ void InventoryManager::outlineIcon(int itemIndex) {
 }
 
 void InventoryManager::combineItems() {
-	warning("TODO: combineItems");
+	Screen &screen = *_vm->_screen;
+	EventsManager &events = *_vm->_events;
+	screen._leftSkip = screen._rightSkip = 0;
+	screen._topSkip = screen._bottomSkip = 0;
+	screen._screenYOff = 0;
+
+	Common::Point tempMouse = events._mousePos;
+	Common::Point lastMouse = events._mousePos;
+
+	Common::Rect &inv = _invCoords[_boxNum];
+	Common::Rect r(inv.left, inv.top, inv.left + 46, inv.top + 35);
+	Common::Point tempBox(inv.left, inv.top);
+	Common::Point lastBox(inv.left, inv.top);
+
+	_vm->_buffer2.copyBlock(&_vm->_buffer1, r);
+	SpriteResource *sprites = _vm->_objectsTable[99];
+	int invItem = _items[_boxNum];
+	events.pollEvents();
+
+	// Item drag handling loop
+	while (!_vm->shouldQuit() && events._leftButton) {
+		// Poll for events
+		events.pollEvents();
+		g_system->delayMillis(10);
+
+		// Check positioning
+		if (lastMouse == events._mousePos)
+			continue;
+
+		lastMouse = events._mousePos;
+		Common::Rect lastRect(lastBox.x, lastBox.y, lastBox.x + 46, lastBox.y + 35);
+		screen.copyBlock(&_vm->_buffer2, lastRect);
+
+		int xp = MAX(events._mousePos.x - tempMouse.x + tempBox.x, 0);
+		int yp = MAX(events._mousePos.y - tempMouse.y + tempBox.y, 0);
+		screen.plotImage(sprites, invItem, Common::Point(xp, yp));
+	}
+
+	int destBox = events.checkMouseBox1(_invCoords);
+	if (destBox >= 0 && destBox != _boxNum && destBox < _items.size()
+			&& _items[destBox] != -1) {
+		int itemA = invItem;
+		int itemB = _items[destBox];
+		
+		// Check whether the items can be combined
+		int combinedItem = _inv[itemA].checkItem(itemB);
+		if (combinedItem != -1) {
+			_inv[combinedItem]._value = 1;
+			_inv[itemA]._value = 2;
+			_inv[itemB]._value = 2;
+			_items[_boxNum] = -1;
+			_items[destBox] = combinedItem;
+			_tempLOff[destBox] = _inv[combinedItem]._name;
+
+			// TODO: zoomIcon calls?
+
+			_boxNum = destBox;
+			return;
+		}
+	}
+
+	_iconDisplayFlag = true;
+	putInvIcon(_boxNum, invItem);
 }
 
 void InventoryManager::synchronize(Common::Serializer &s) {
@@ -362,7 +448,7 @@ void InventoryManager::synchronize(Common::Serializer &s) {
 		_inv.resize(count);
 
 	for (int i = 0; i < count; ++i)
-		s.syncAsUint16LE((*this)[i]);
+		s.syncAsUint16LE(_inv[i]._value);
 }
 
 } // End of namespace Access
diff --git a/engines/access/inventory.h b/engines/access/inventory.h
index 0ff9020..eff142c 100644
--- a/engines/access/inventory.h
+++ b/engines/access/inventory.h
@@ -32,6 +32,21 @@
 
 namespace Access {
 
+class InventoryEntry {
+public:
+	Common::String _name;
+	int _value;
+
+	int _otherItem1;
+	int _newItem1;
+	int _otherItem2;
+	int _newItem2;
+
+	void load(const Common::String &name, const int *data);
+
+	int checkItem(int itemId);
+};
+
 class InventoryManager : public Manager {
 	struct SavedFields {
 		int _vWindowHeight;
@@ -58,7 +73,6 @@ private:
 	ASurface _savedScreen;
 	SavedFields _fields;
 	bool _iconDisplayFlag;
-	Common::StringArray _names;
 	Common::Array<int> _tempLPtr;
 	Common::StringArray _tempLOff;
 	int _boxNum;
@@ -89,7 +103,7 @@ private:
 
 	void combineItems();
 public:
-	Common::Array<int> _inv;
+	Common::Array<InventoryEntry> _inv;
 	int _startInvItem;
 	int _startInvBox;
 	bool _invChangeFlag;
diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp
index c46d7b9..6c4c374 100644
--- a/engines/access/scripts.cpp
+++ b/engines/access/scripts.cpp
@@ -554,18 +554,6 @@ void Scripts::cmdTexSpeak() {
 	findNull();
 }
 
-int Scripts::checkMouseBox1(Common::Rect *rectArr) {
-	int i = 0;
-	for (i = 0; ; i++){
-		if (rectArr[i].left == -1)
-			return -1;
-
-		if ((_vm->_events->_mousePos.x > rectArr[i].left) && (_vm->_events->_mousePos.x < rectArr[i].right) 
-			&& (_vm->_events->_mousePos.y > rectArr[i].top) && (_vm->_events->_mousePos.y < rectArr[i].bottom))
-			return i;
-	}
-}
-
 void Scripts::cmdTexChoice() {
 	static Common::Point cMouse[7] = {
 		Common::Point(0, 76), Common::Point(77, 154), Common::Point(155, 232),
@@ -595,9 +583,9 @@ void Scripts::cmdTexChoice() {
 	_vm->_bubbleBox->calcBubble(tmpStr);
 	_vm->_bubbleBox->printBubble(tmpStr);
 
-	Common::Rect responseCoords[2];
-	responseCoords[0] = _vm->_bubbleBox->_bounds;
-	responseCoords[1] = Common::Rect(0, 0, 0, 0);
+	Common::Array<Common::Rect> responseCoords;
+	responseCoords.push_back(_vm->_bubbleBox->_bounds);
+	responseCoords.push_back(Common::Rect(0, 0, 0, 0));
 	_vm->_screen->_printOrg.y = _vm->_bubbleBox->_bounds.bottom + 11;
 
 	findNull();
@@ -655,7 +643,7 @@ void Scripts::cmdTexChoice() {
 				}
 			} else {
 				_vm->_events->debounceLeft();
-				choice = checkMouseBox1(responseCoords);
+				choice = _vm->_events->checkMouseBox1(responseCoords);
 			}
 		}
 	} while ((choice == -1) || ((choice == 2) && choice3Fl));
diff --git a/engines/access/scripts.h b/engines/access/scripts.h
index f4128f4..ab80c1c 100644
--- a/engines/access/scripts.h
+++ b/engines/access/scripts.h
@@ -44,8 +44,6 @@ protected:
 	virtual void executeSpecial(int commandIndex, int param1, int param2) = 0;
 	virtual void executeCommand(int commandIndex);
 
-	int checkMouseBox1(Common::Rect *rectArr);
-
 	/**
 	 * Print a given message to the screen in a bubble box
 	 */


Commit: b0653e1c924650c86edd220a37786c82faaeb11e
    https://github.com/scummvm/scummvm/commit/b0653e1c924650c86edd220a37786c82faaeb11e
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-12T22:23:19-05:00

Commit Message:
ACCESS: Fix redrawing during inventory item dragging

Changed paths:
    engines/access/inventory.cpp



diff --git a/engines/access/inventory.cpp b/engines/access/inventory.cpp
index f31379a..86e73c1 100644
--- a/engines/access/inventory.cpp
+++ b/engines/access/inventory.cpp
@@ -394,7 +394,7 @@ void InventoryManager::combineItems() {
 	int invItem = _items[_boxNum];
 	events.pollEvents();
 
-	// Item drag handling loop
+	// Item drag handling loop if left button is held down
 	while (!_vm->shouldQuit() && events._leftButton) {
 		// Poll for events
 		events.pollEvents();
@@ -408,9 +408,12 @@ void InventoryManager::combineItems() {
 		Common::Rect lastRect(lastBox.x, lastBox.y, lastBox.x + 46, lastBox.y + 35);
 		screen.copyBlock(&_vm->_buffer2, lastRect);
 
-		int xp = MAX(events._mousePos.x - tempMouse.x + tempBox.x, 0);
-		int yp = MAX(events._mousePos.y - tempMouse.y + tempBox.y, 0);
-		screen.plotImage(sprites, invItem, Common::Point(xp, yp));
+		Common::Point newPt;
+		newPt.x = MAX(events._mousePos.x - tempMouse.x + tempBox.x, 0);
+		newPt.y = MAX(events._mousePos.y - tempMouse.y + tempBox.y, 0);
+		
+		screen.plotImage(sprites, invItem, newPt);
+		lastBox = newPt;
 	}
 
 	int destBox = events.checkMouseBox1(_invCoords);


Commit: b5ad2b9db52e4184829c02830a9d2b22b6f85dde
    https://github.com/scummvm/scummvm/commit/b5ad2b9db52e4184829c02830a9d2b22b6f85dde
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-12T22:23:31-05:00

Commit Message:
ACCESS: Inventory item merge zoom partially working

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



diff --git a/engines/access/inventory.cpp b/engines/access/inventory.cpp
index 86e73c1..2dc73a2 100644
--- a/engines/access/inventory.cpp
+++ b/engines/access/inventory.cpp
@@ -308,10 +308,11 @@ void InventoryManager::chooseItem() {
 	int selIndex;
 
 	while (!_vm->shouldQuit()) {
+		// Check for events
+		events.pollEvents();
 		g_system->delayMillis(10);
 
 		// Poll events and wait for a click on a known area
-		events.pollEvents();
 		if (!events._leftButton || ((selIndex = coordIndexOf()) == -1))
 			continue;
 
@@ -319,7 +320,7 @@ void InventoryManager::chooseItem() {
 			if (selIndex == 25)
 				_vm->_useItem = -1;
 			break;
-		} else if (selIndex < (int)_items.size()) {
+		} else if (selIndex < (int)_items.size() && _items[selIndex] != -1) {
 			_boxNum = selIndex;
 			_vm->copyBF2Vid();
 			combineItems();
@@ -417,7 +418,7 @@ void InventoryManager::combineItems() {
 	}
 
 	int destBox = events.checkMouseBox1(_invCoords);
-	if (destBox >= 0 && destBox != _boxNum && destBox < _items.size()
+	if (destBox >= 0 && destBox != _boxNum && destBox < (int)_items.size()
 			&& _items[destBox] != -1) {
 		int itemA = invItem;
 		int itemB = _items[destBox];
@@ -432,9 +433,19 @@ void InventoryManager::combineItems() {
 			_items[destBox] = combinedItem;
 			_tempLOff[destBox] = _inv[combinedItem]._name;
 
-			// TODO: zoomIcon calls?
+			// Zoom out the old two items and zoom in the new combined item
+			events.hideCursor();
+			zoomIcon(itemA, itemB, destBox, true);
+			Common::Rect destRect(_invCoords[destBox].left, _invCoords[destBox].top,
+				_invCoords[destBox].left + 46, _invCoords[destBox].top + 35);
+			_vm->_buffer2.copyBlock(&_vm->_buffer1, destRect);
+			screen._screenYOff = 0;
+			
+			zoomIcon(itemB, -1, destBox, true);
+			zoomIcon(combinedItem, -1, destBox, false);
 
 			_boxNum = destBox;
+			events.showCursor();
 			return;
 		}
 	}
@@ -443,6 +454,48 @@ void InventoryManager::combineItems() {
 	putInvIcon(_boxNum, invItem);
 }
 
+void InventoryManager::zoomIcon(int zoomItem, int backItem, int zoomBox, bool shrink) {
+	Screen &screen = *_vm->_screen;
+	screen._screenYOff = 0;
+	SpriteResource *sprites = _vm->_objectsTable[99];
+
+	int8 zoomScale = shrink ? -1 : 1;
+	int8 zoomInc = shrink ? -1 : 1;
+	Common::Rect boxRect(_invCoords[zoomBox].left, _invCoords[zoomBox].top,
+		_invCoords[zoomBox].left + 46, _invCoords[zoomBox].top + 35);
+
+	while (!_vm->shouldQuit() && zoomScale != 0) {
+		_vm->_events->pollEvents();
+		g_system->delayMillis(5);
+
+		_vm->_buffer2.copyBlock(&_vm->_buffer1, boxRect);
+		if (backItem != -1) {
+			_iconDisplayFlag = false;
+			putInvIcon(zoomBox, backItem);
+		}
+
+		_vm->_scale = zoomScale;
+		screen.setScaleTable(zoomScale);
+
+		int xv = screen._scaleTable1[boxRect.width() + 1];
+		if (xv) {
+			int yv = screen._scaleTable1[boxRect.height() + 1];
+			if (yv) {
+				// The zoomed size is positive in both directions, so show zoomed item
+				Common::Rect scaledBox(xv, yv);
+				scaledBox.moveTo(boxRect.left + (boxRect.width() - xv + 1) / 2,
+					boxRect.top + (boxRect.height() - yv + 1) / 2);
+
+				_vm->_buffer2.sPlotF(sprites->getFrame(zoomItem), scaledBox);
+			}
+		}
+
+		screen.copyBlock(&_vm->_buffer2, boxRect);
+
+		zoomScale += zoomInc;
+	}
+}
+
 void InventoryManager::synchronize(Common::Serializer &s) {
 	int count = _inv.size();
 	s.syncAsUint16LE(count);
diff --git a/engines/access/inventory.h b/engines/access/inventory.h
index eff142c..f2b1f5e 100644
--- a/engines/access/inventory.h
+++ b/engines/access/inventory.h
@@ -102,6 +102,8 @@ private:
 	void outlineIcon(int itemIndex);
 
 	void combineItems();
+
+	void zoomIcon(int zoomItem, int backItem, int zoomBox, bool shrink);
 public:
 	Common::Array<InventoryEntry> _inv;
 	int _startInvItem;


Commit: 0a8b8d9e94bea66834c102edeeb8b6c5374423ed
    https://github.com/scummvm/scummvm/commit/0a8b8d9e94bea66834c102edeeb8b6c5374423ed
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-12T22:23:40-05:00

Commit Message:
ACCESS: Fix inventory item combining zoom logic

Changed paths:
    engines/access/inventory.cpp



diff --git a/engines/access/inventory.cpp b/engines/access/inventory.cpp
index 2dc73a2..1b81b6b 100644
--- a/engines/access/inventory.cpp
+++ b/engines/access/inventory.cpp
@@ -432,16 +432,19 @@ void InventoryManager::combineItems() {
 			_items[_boxNum] = -1;
 			_items[destBox] = combinedItem;
 			_tempLOff[destBox] = _inv[combinedItem]._name;
-
-			// Zoom out the old two items and zoom in the new combined item
 			events.hideCursor();
+
+			// Shrink down the first item on top of the second item
 			zoomIcon(itemA, itemB, destBox, true);
+
+			// Shrink down the second item
 			Common::Rect destRect(_invCoords[destBox].left, _invCoords[destBox].top,
 				_invCoords[destBox].left + 46, _invCoords[destBox].top + 35);
 			_vm->_buffer2.copyBlock(&_vm->_buffer1, destRect);
-			screen._screenYOff = 0;
-			
+			screen._screenYOff = 0;			
 			zoomIcon(itemB, -1, destBox, true);
+
+			// Exand up the new combined item from nothing to full size
 			zoomIcon(combinedItem, -1, destBox, false);
 
 			_boxNum = destBox;
@@ -459,12 +462,13 @@ void InventoryManager::zoomIcon(int zoomItem, int backItem, int zoomBox, bool sh
 	screen._screenYOff = 0;
 	SpriteResource *sprites = _vm->_objectsTable[99];
 
-	int8 zoomScale = shrink ? -1 : 1;
-	int8 zoomInc = shrink ? -1 : 1;
+	int oldScale = _vm->_scale;
+	int zoomScale = shrink ? 255 : 1;
+	int zoomInc = shrink ? -1 : 1;
 	Common::Rect boxRect(_invCoords[zoomBox].left, _invCoords[zoomBox].top,
 		_invCoords[zoomBox].left + 46, _invCoords[zoomBox].top + 35);
 
-	while (!_vm->shouldQuit() && zoomScale != 0) {
+	while (!_vm->shouldQuit() && zoomScale != 0 && zoomScale != 256) {
 		_vm->_events->pollEvents();
 		g_system->delayMillis(5);
 
@@ -494,6 +498,17 @@ void InventoryManager::zoomIcon(int zoomItem, int backItem, int zoomBox, bool sh
 
 		zoomScale += zoomInc;
 	}
+
+	if (!shrink) {
+		// Handle the final full-size version
+		_vm->_buffer2.copyBlock(&_vm->_buffer1, boxRect);
+		_vm->_buffer2.plotImage(sprites, zoomItem,
+			Common::Point(boxRect.left, boxRect.top));
+		screen.copyBlock(&_vm->_buffer2, boxRect);
+	}
+
+	_vm->_scale = oldScale;
+	screen.setScaleTable(oldScale);
 }
 
 void InventoryManager::synchronize(Common::Serializer &s) {


Commit: 8a31fca61efa4a97097a499e1f42e57f631fe678
    https://github.com/scummvm/scummvm/commit/8a31fca61efa4a97097a499e1f42e57f631fe678
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-12T22:23:50-05:00

Commit Message:
ACCESS: Implement mWhileDoOpen

Changed paths:
    engines/access/amazon/amazon_game.h
    engines/access/amazon/amazon_scripts.cpp
    engines/access/amazon/amazon_scripts.h



diff --git a/engines/access/amazon/amazon_game.h b/engines/access/amazon/amazon_game.h
index 2dc0c05..653deef 100644
--- a/engines/access/amazon/amazon_game.h
+++ b/engines/access/amazon/amazon_game.h
@@ -54,8 +54,6 @@ public:
 
 class AmazonEngine : public AccessEngine {
 private:
-	bool _skipStart;
-
 	// Fields that are included in savegames
 	int _canoeLane;
 	int _canoeYPos;
@@ -99,7 +97,6 @@ private:
 
 	void loadEstablish(int estabIndex);
 	void doEstablish(int screenId, int estabIndex);
-	void establishCenter(int screenId, int esatabIndex);
 
 protected:
 	/**
@@ -113,6 +110,7 @@ protected:
 	virtual void synchronize(Common::Serializer &s);
 public:
 	bool _charSegSwitch;
+	bool _skipStart;
 
 	int _rawInactiveX;
 	int _rawInactiveY;
@@ -162,6 +160,7 @@ public:
 
 	void tileScreen();
 	void updateSummary(int chap);
+	void establishCenter(int screenId, int esatabIndex);
 
 	/**
 	 * Show the start of a chapter
diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp
index 2b489d6..5d9f2d9 100644
--- a/engines/access/amazon/amazon_scripts.cpp
+++ b/engines/access/amazon/amazon_scripts.cpp
@@ -503,6 +503,119 @@ void AmazonScripts::mWhileJWalk() {
 	}
 }
 
+void AmazonScripts::mWhileDoOpen() {
+	const int openObj[10][4] = {
+		{8, -80, 120, 30},
+		{13, 229, 0, 50},
+		{12, 78, 0, 50},
+		{11, 10, 0, 50},
+		{10, 178, 97, 50},
+		{9, 92, 192, 50},
+		{14, 38, 0, 100},
+		{15, 132, 76, 100},
+		{16, 142, 0, 100},
+		{4, -280, 40, 120},
+	};
+
+	_vm->_screen->setBufferScan();
+	_vm->_events->hideCursor();
+	_vm->_screen->forceFadeOut();
+	_game->_skipStart = false;
+	if (_vm->_conversation != 2) {
+		_vm->_screen->setPanel(3);
+		_game->startChapter(1);
+		_game->establishCenter(0, 1);
+	}
+
+	Resource *data = _vm->_files->loadFile(0, 1);
+	SpriteResource *spr = new SpriteResource(_vm, data);
+	delete data;
+
+	_vm->_objectsTable[1] = spr;
+	_vm->_files->_loadPalFlag = false;
+	_vm->_files->loadScreen(1, 2);
+	_vm->_buffer2.copyFrom(*_vm->_screen);
+	_vm->_buffer1.copyFrom(*_vm->_screen);
+
+	warning("TODO _roomInfo = _vm->_files->loadFile(1, 1);");
+
+	_xTrack = 8;
+	_yTrack = -3;
+	_zTrack = 0;
+	_xCam = _yCam = 0;
+	_zCam = 270;
+	_vm->_timers[24]._timer = _vm->_timers[24]._initTm = 1;
+	++_vm->_timers[24]._flag;
+	_pNumObj = 10;
+
+	for (int i = 0; i < _pNumObj; i++) {
+		_pObject[i] = _vm->_objectsTable[1];
+		_pImgNum[i] = openObj[i][0];
+		_pObjX[i] = openObj[i][1];
+		_pObjY[i] = openObj[i][2];
+		_pObjZ[i] = openObj[i][3];
+		_pObjXl[i] = _pObjYl[i] = 0;
+	}
+
+	_vm->_oldRects.clear();
+	_vm->_newRects.clear();
+	Animation *anim = _vm->_animation->setAnimation(0);
+	_vm->_animation->setAnimTimer(anim);
+	anim = _vm->_animation->setAnimation(1);
+	_vm->_animation->setAnimTimer(anim);
+	_vm->_sound->newMusic(10, 0);
+	
+	bool startFl = false;
+	while (true) {
+		_vm->_images.clear();
+		_vm->_animation->animate(0);
+		_vm->_animation->animate(1);
+		pan();
+		_vm->_buffer2.copyFrom(_vm->_buffer1);
+		_vm->_newRects.clear();
+		_game->plotList();
+		_vm->copyBlocks();
+		if (!startFl) {
+			startFl = true;
+			_vm->_screen->forceFadeIn();
+		}
+		_vm->_events->pollEvents();
+		warning("TODO: check on KEYBUFCNT");
+		if (_vm->_events->_leftButton || _vm->_events->_rightButton) {
+			_game->_skipStart = true;
+			_vm->_sound->newMusic(10, 1);
+			break;
+		}
+
+		if (_xCam > 680) {
+			warning("FIXME: _vbCount should be handled in NEWTIMER");
+			int _vbCount = 125;
+			while(_vbCount > 0) {
+				// To be rewritten when NEWTIMER is done
+				_vm->_events->checkForNextFrameCounter();
+				_vbCount--;
+			}
+			break;
+		}
+	}
+	
+	_vm->_events->showCursor();
+	_vm->_buffer2.copyFrom(*_vm->_screen);
+	_vm->_buffer1.copyFrom(*_vm->_screen);
+	warning("TODO: delete _roomInfo;");
+	_vm->freeCells();
+	_vm->_oldRects.clear();
+	_vm->_newRects.clear();
+	_vm->_numAnimTimers = 0;
+	_vm->_images.clear();
+	if (_vm->_conversation == 2) {
+		Resource *spriteData = _vm->_files->loadFile(28, 37);
+		_vm->_objectsTable[28] = new SpriteResource(_vm, spriteData);
+		delete spriteData;
+		warning("TODO: _roomInfo = _vm->_files->loadFile(28, 38);");
+	}
+}
+
 void AmazonScripts::mWhile(int param1) {
 	switch(param1) {
 	case 1:
@@ -518,7 +631,7 @@ void AmazonScripts::mWhile(int param1) {
 		mWhileJWalk();
 		break;
 	case 5:
-		warning("TODO DOOPEN");
+		mWhileDoOpen();
 		break;
 	case 6:
 		warning("TODO DOWNRIVER");
diff --git a/engines/access/amazon/amazon_scripts.h b/engines/access/amazon/amazon_scripts.h
index 1ee8b98..06ed6e5 100644
--- a/engines/access/amazon/amazon_scripts.h
+++ b/engines/access/amazon/amazon_scripts.h
@@ -70,6 +70,7 @@ protected:
 	void mWhileFly();
 	void mWhileFall();
 	void mWhileJWalk();
+	void mWhileDoOpen();
 	void mWhile(int param1);
 	void guardSee();
 	void setGuardFrame();


Commit: 47304849c7c24fd9809f6e854f18354f95773980
    https://github.com/scummvm/scummvm/commit/47304849c7c24fd9809f6e854f18354f95773980
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-12T22:24:03-05:00

Commit Message:
ACCESS: Fix malformed inventory item description

Changed paths:
    engines/access/amazon/amazon_resources.cpp



diff --git a/engines/access/amazon/amazon_resources.cpp b/engines/access/amazon/amazon_resources.cpp
index c2eab7b..e60da5b 100644
--- a/engines/access/amazon/amazon_resources.cpp
+++ b/engines/access/amazon/amazon_resources.cpp
@@ -990,7 +990,7 @@ const char *const INVENTORY_NAMES[] = {
 	"RAT", "ALCOHOL", "SAFE COMBINATION", "BEAKER", "MICROFILM",
 	"VAULT KEY", "BOLT CUTTERS", "BLOWGUN", "LOVE POTION", "MONEY",
 	"DARTS", "TAPE", "JUNGLE POTION", "MOVIE", "CABINET KEY",
-	"DISPLAY CASE KEY", "FLITCH', 27h, 'S CAR KEYS", "COAT HANGER",
+	"DISPLAY CASE KEY", "FLITCH'S CAR KEYS", "COAT HANGER",
 	"CROWBAR", "COMPASS", "MAP", "LETTER OPENER", "LETTER",
 	"DECODER", "DIPPED DART", "LOADED BLOWGUN", "CARD", "JERRYCAN",
 	"CIGARETTES", "BIKE PUMP", "PARACHUTE", "PESO", "PEPPERS",


Commit: 712261f02a84700ed014b2e2e16a0f13e2c6f93c
    https://github.com/scummvm/scummvm/commit/712261f02a84700ed014b2e2e16a0f13e2c6f93c
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-12T22:24:12-05:00

Commit Message:
ACCESS: Fix entire inventory disappearing after combining items

Changed paths:
    engines/access/inventory.cpp



diff --git a/engines/access/inventory.cpp b/engines/access/inventory.cpp
index 1b81b6b..f465432 100644
--- a/engines/access/inventory.cpp
+++ b/engines/access/inventory.cpp
@@ -287,6 +287,8 @@ void InventoryManager::getList() {
 }
 
 void InventoryManager::showAllItems() {
+	_iconDisplayFlag = true;
+
 	for (uint i = 0; i < _items.size(); ++i)
 		putInvIcon(i, _items[i]);
 }


Commit: 63bacba2d906f650e702ba544c5a49528452b5b2
    https://github.com/scummvm/scummvm/commit/63bacba2d906f650e702ba544c5a49528452b5b2
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-12T22:24:21-05:00

Commit Message:
ACCESS: Add enum for inventory item states

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



diff --git a/engines/access/inventory.cpp b/engines/access/inventory.cpp
index f465432..4573846 100644
--- a/engines/access/inventory.cpp
+++ b/engines/access/inventory.cpp
@@ -29,7 +29,7 @@
 namespace Access {
 
 void InventoryEntry::load(const Common::String &name, const int *data) {
-	_value = 0;
+	_value = ITEM_NOT_FOUND;
 	_name = name;
 	_otherItem1 = *data++;
 	_newItem1 = *data++;
@@ -279,7 +279,7 @@ void InventoryManager::getList() {
 	_tempLOff.clear();
 
 	for (uint i = 0; i < _inv.size(); ++i) {
-		if (_inv[i]._value == 1) {
+		if (_inv[i]._value == ITEM_IN_INVENTORY) {
 			_items.push_back(i);
 			_tempLOff.push_back(_inv[i]._name);
 		}
diff --git a/engines/access/inventory.h b/engines/access/inventory.h
index f2b1f5e..820b15b 100644
--- a/engines/access/inventory.h
+++ b/engines/access/inventory.h
@@ -32,6 +32,10 @@
 
 namespace Access {
 
+enum ItemState {
+	ITEM_NOT_FOUND = 0, ITEM_IN_INVENTORY = 1, ITEM_USED = 2
+};
+
 class InventoryEntry {
 public:
 	Common::String _name;


Commit: dc218d53ef9d9b6de11e26e1b793204d416fc9db
    https://github.com/scummvm/scummvm/commit/dc218d53ef9d9b6de11e26e1b793204d416fc9db
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-12T22:24:34-05:00

Commit Message:
ACCESS: Merge the sound resource and priority lists

Changed paths:
    engines/access/access.cpp
    engines/access/amazon/amazon_game.cpp
    engines/access/amazon/amazon_scripts.cpp
    engines/access/martian/martian_game.cpp
    engines/access/scripts.cpp
    engines/access/sound.cpp
    engines/access/sound.h



diff --git a/engines/access/access.cpp b/engines/access/access.cpp
index a3cadc1..f04a5de 100644
--- a/engines/access/access.cpp
+++ b/engines/access/access.cpp
@@ -245,8 +245,9 @@ void AccessEngine::speakText(ASurface *s, const Common::String &msg) {
 				_events->waitKeyMouse();
 			} else {
 				for (;;) {
-					_sound->_soundTable[0] = _sound->loadSound(_narateFile + 99, _sndSubFile);
-					_sound->_soundPriority[0] = 1;
+					_sound->freeSounds();
+					Resource *sound = _sound->loadSound(_narateFile + 99, _sndSubFile);
+					_sound->_soundTable.push_back(SoundEntry(sound, 1));
 					_sound->playSound(0);
 					_scripts->cmdFreeSound();
 
@@ -287,8 +288,9 @@ void AccessEngine::speakText(ASurface *s, const Common::String &msg) {
 	}
 
 	for (;;) {
-		_sound->_soundTable[0] = _sound->loadSound(_narateFile + 99, _sndSubFile);
-		_sound->_soundPriority[0] = 1;
+		_sound->freeSounds();
+		Resource *res = _sound->loadSound(_narateFile + 99, _sndSubFile);
+		_sound->_soundTable.push_back(SoundEntry(res, 1));
 		_sound->playSound(0);
 		_scripts->cmdFreeSound();
 
diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp
index 8270eae..9801df7 100644
--- a/engines/access/amazon/amazon_game.cpp
+++ b/engines/access/amazon/amazon_game.cpp
@@ -132,10 +132,7 @@ void AmazonEngine::doTitle() {
 	_events->hideCursor();
 
 	_sound->queueSound(0, 98, 30);
-	_sound->_soundPriority[0] = 1;
-
 	_sound->queueSound(1, 98, 8);
-	_sound->_soundPriority[1] = 1;
 
 	_files->_loadPalFlag = false;
 	_files->loadScreen(0, 3);
@@ -404,14 +401,13 @@ void AmazonEngine::startChapter(int chapter) {
 		_timers[20]._timer = 500;
 		_timers[20]._initTm = 500;
 		_timers[20]._flag++;
+		_sound->freeSounds();
 
-		_sound->_soundTable[0] = _sound->loadSound(115, 0);
-		_sound->_soundPriority[0] = 1;
+		_sound->_soundTable.push_back(SoundEntry(_sound->loadSound(115, 0), 1));
 		_sound->playSound(0);
 		_sound->freeSounds();
 
-		_sound->_soundTable[0] = _sound->loadSound(115, 1);
-		_sound->_soundPriority[0] = 1;
+		_sound->_soundTable.push_back(SoundEntry(_sound->loadSound(115, 1), 1));
 		_sound->playSound(0);
 		_sound->freeSounds();
 
diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp
index 5d9f2d9..1290208 100644
--- a/engines/access/amazon/amazon_scripts.cpp
+++ b/engines/access/amazon/amazon_scripts.cpp
@@ -116,7 +116,6 @@ void AmazonScripts::mWhile1() {
 	_sequence = 2200;
 
 	_vm->_sound->queueSound(0, 14, 15);
-	_vm->_sound->_soundPriority[0] = 1;
 
 	do {
 		cLoop();
diff --git a/engines/access/martian/martian_game.cpp b/engines/access/martian/martian_game.cpp
index 2f11d8b..1c13593 100644
--- a/engines/access/martian/martian_game.cpp
+++ b/engines/access/martian/martian_game.cpp
@@ -96,7 +96,6 @@ void MartianEngine::doTitle() {
 	_events->hideCursor();
 
 	_sound->queueSound(0, 98, 30);
-	_sound->_soundPriority[0] = 1;
 
 	_files->_loadPalFlag = false;
 	_files->loadScreen(0, 3);
diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp
index 6c4c374..bf58a20 100644
--- a/engines/access/scripts.cpp
+++ b/engines/access/scripts.cpp
@@ -707,15 +707,14 @@ void Scripts::cmdLoadSound() {
 	int idx = _data->readSint16LE();
 
 	_vm->_sound->_soundTable.clear();
-	_vm->_sound->_soundPriority.clear();
-	_vm->_sound->_soundTable.push_back(_vm->_files->loadFile(_vm->_extraCells[idx]._vidSound));
-	_vm->_sound->_soundPriority.push_back(1);
+	Resource *sound = _vm->_files->loadFile(_vm->_extraCells[idx]._vidSound);
+	_vm->_sound->_soundTable.push_back(SoundEntry(sound, 1));
 }
 
 void Scripts::cmdFreeSound() { 
 	SoundManager &sound = *_vm->_sound;
 
-	if (sound._soundTable.size() > 0 && sound._soundTable[0]) {
+	if (sound._soundTable.size() > 0 && sound._soundTable[0]._res) {
 		// Keep doing char display loop if playing sound for it
 		do {
 			if (_vm->_flags[236] == 1)
@@ -725,8 +724,8 @@ void Scripts::cmdFreeSound() {
 		} while (!_vm->shouldQuit() && sound._playingSound);
 
 		// Free the sound
-		delete sound._soundTable[0];
-		sound._soundTable[0] = nullptr;
+		delete sound._soundTable[0]._res;
+		sound._soundTable.remove_at(0);
 	}
 }
 
@@ -766,8 +765,7 @@ void Scripts::cmdDead() {
 	_vm->_screen->forceFadeOut();
 	cmdFreeSound();
 
-	_vm->_sound->_soundTable[0] = _vm->_files->loadFile(98, 44);
-	_vm->_sound->_soundPriority[1] = 1;
+	_vm->_sound->_soundTable.push_back(SoundEntry(_vm->_files->loadFile(98, 44), 1));
 	
 	_vm->_screen->clearScreen();
 	_vm->_screen->setPanel(3);
diff --git a/engines/access/sound.cpp b/engines/access/sound.cpp
index dd8cf16..075bfc0 100644
--- a/engines/access/sound.cpp
+++ b/engines/access/sound.cpp
@@ -44,14 +44,17 @@ SoundManager::~SoundManager() {
 
 void SoundManager::clearSounds() {
 	for (uint i = 0; i < _soundTable.size(); ++i)
-		delete _soundTable[i];
+		delete _soundTable[i]._res;
 	_soundTable.clear();
-	_soundPriority.clear();
 }
 
 void SoundManager::queueSound(int idx, int fileNum, int subfile) {
-	delete _soundTable[idx];
-	_soundTable[idx] = _vm->_files->loadFile(fileNum, subfile);
+	if (idx >= (int)_soundTable.size())
+		_soundTable.resize(idx + 1);
+
+	delete _soundTable[idx]._res;
+	_soundTable[idx]._res = _vm->_files->loadFile(fileNum, subfile);
+	_soundTable[idx]._priority = 1;
 }
 
 Resource *SoundManager::loadSound(int fileNum, int subfile) {
@@ -59,8 +62,8 @@ Resource *SoundManager::loadSound(int fileNum, int subfile) {
 }
 
 void SoundManager::playSound(int soundIndex) {
-	int priority = _soundPriority[soundIndex];
-	playSound(_soundTable[soundIndex], priority);
+	int priority = _soundTable[soundIndex]._priority;
+	playSound(_soundTable[soundIndex]._res, priority);
 }
 
 void SoundManager::playSound(Resource *res, int priority) {
@@ -76,8 +79,8 @@ void SoundManager::loadSounds(Common::Array<RoomInfo::SoundIdent> &sounds) {
 	clearSounds();
 
 	for (uint i = 0; i < sounds.size(); ++i) {
-		_soundTable.push_back(loadSound(sounds[i]._fileNum, sounds[i]._subfile));
-		_soundPriority.push_back(sounds[i]._priority);
+		Resource *sound = loadSound(sounds[i]._fileNum, sounds[i]._subfile);
+		_soundTable.push_back(SoundEntry(sound, sounds[i]._priority));
 	}
 }
 
diff --git a/engines/access/sound.h b/engines/access/sound.h
index c1b3981..2456ba7 100644
--- a/engines/access/sound.h
+++ b/engines/access/sound.h
@@ -33,6 +33,14 @@ namespace Access {
 
 class AccessEngine;
 
+struct SoundEntry {
+	Resource *_res;
+	int _priority;
+
+	SoundEntry() { _res = nullptr; _priority = 0; }
+	SoundEntry(Resource *res, int priority) { _res = res; _priority = priority; }
+};
+
 class SoundManager {
 private:
 	AccessEngine *_vm;
@@ -45,8 +53,7 @@ private:
 	void stopSound();
 
 public:
-	Common::Array<Resource *> _soundTable;
-	Common::Array<int> _soundPriority;
+	Common::Array<SoundEntry> _soundTable;
 	Resource *_music;
 	Resource *_tempMusic;
 	bool _musicRepeat;


Commit: 6434ace3b695cc88593547f8079f6abd309b7f72
    https://github.com/scummvm/scummvm/commit/6434ace3b695cc88593547f8079f6abd309b7f72
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-12T22:24:47-05:00

Commit Message:
ACCESS: Fix not being able to save in room 9

Changed paths:
    engines/access/scripts.cpp



diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp
index bf58a20..e99af4b 100644
--- a/engines/access/scripts.cpp
+++ b/engines/access/scripts.cpp
@@ -414,7 +414,10 @@ void Scripts::cmdSetTimer() {
 void Scripts::cmdCheckTimer() {
 	int idx = _data->readUint16LE();
 
+	_vm->_canSaveLoad = true;
 	_vm->_events->pollEvents();
+	_vm->_canSaveLoad = false;
+
 	if ((idx == 9) && (_vm->_events->_keypresses.size() > 0)) {
 		_vm->_events->zeroKeys();
 		_vm->_timers[9]._timer = 0;


Commit: fddff687da7b7f9eb2156a84407794c44978caa8
    https://github.com/scummvm/scummvm/commit/fddff687da7b7f9eb2156a84407794c44978caa8
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-12T22:25:01-05:00

Commit Message:
ACCESS: Workaround for original game vertical room scrolling

Changed paths:
    engines/access/amazon/amazon_room.cpp
    engines/access/amazon/amazon_room.h
    engines/access/room.h



diff --git a/engines/access/amazon/amazon_room.cpp b/engines/access/amazon/amazon_room.cpp
index 098220e..96d34e7 100644
--- a/engines/access/amazon/amazon_room.cpp
+++ b/engines/access/amazon/amazon_room.cpp
@@ -125,6 +125,17 @@ void AmazonRoom::reloadRoom1() {
 	_vm->_newRects.clear();
 }
 
+void AmazonRoom::setupRoom() {
+	Room::setupRoom();
+
+	// WORKAROUND: The original engine doesn't handle vertical scrolling rooms
+	Screen &screen = *_vm->_screen;
+	if (screen._vWindowHeight == (_playFieldHeight - 1)) {
+		screen._scrollRow = 1;
+		screen._scrollY = 0;
+	}
+}
+
 void AmazonRoom::roomSet() {
 	_vm->_numAnimTimers = 0;
 	_vm->_scripts->_sequence = 1000;
diff --git a/engines/access/amazon/amazon_room.h b/engines/access/amazon/amazon_room.h
index 122eed9..ccace1e 100644
--- a/engines/access/amazon/amazon_room.h
+++ b/engines/access/amazon/amazon_room.h
@@ -48,6 +48,8 @@ protected:
 
 	virtual void reloadRoom1();
 
+	virtual void setupRoom();
+
 	virtual void roomMenu();
 
 	virtual void mainAreaClick();
diff --git a/engines/access/room.h b/engines/access/room.h
index fdeccc8..810082e 100644
--- a/engines/access/room.h
+++ b/engines/access/room.h
@@ -80,7 +80,6 @@ private:
 	bool checkCode(int v1, int v2);
 protected:
 	void loadRoomData(const byte *roomData);
-	void setupRoom();
 
 	/**
 	* Free the playfield data
@@ -115,6 +114,8 @@ protected:
 
 	virtual void reloadRoom1() = 0;
 
+	virtual void setupRoom();
+
 	virtual void doCommands();
 
 	virtual void roomMenu() = 0;


Commit: e7818639afd72d861c3ed985bb8aeb4f685e5042
    https://github.com/scummvm/scummvm/commit/e7818639afd72d861c3ed985bb8aeb4f685e5042
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-12T22:25:14-05:00

Commit Message:
ACCESS: Workaround not being able to leave scene 9 in Amazon to the south

Changed paths:
    engines/access/amazon/amazon_room.cpp



diff --git a/engines/access/amazon/amazon_room.cpp b/engines/access/amazon/amazon_room.cpp
index 96d34e7..ec90fc6 100644
--- a/engines/access/amazon/amazon_room.cpp
+++ b/engines/access/amazon/amazon_room.cpp
@@ -177,6 +177,11 @@ void AmazonRoom::mainAreaClick() {
 			}
 		} 
 
+		// WORKAROUND: In Amazon room 9, you can't leave the screen to the south due
+		// to not being able to click a Y position that's high enough
+		if (pt.y > 178)
+			pt.y = 200;
+
 		_vm->_player->_moveTo = pt;
 		_vm->_player->_playerMove = true;
 	} else if (mousePos.x >= _vm->_screen->_windowXAdd &&


Commit: aea906f7d3c8959337c24ee4507bb245d9f5f744
    https://github.com/scummvm/scummvm/commit/aea906f7d3c8959337c24ee4507bb245d9f5f744
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-12T22:25:25-05:00

Commit Message:
ACCESS: Implemented chapter debug command

Changed paths:
    engines/access/access.cpp
    engines/access/debugger.cpp
    engines/access/debugger.h
    engines/access/files.cpp
    engines/access/files.h
    engines/access/room.cpp
    engines/access/scripts.cpp
    engines/access/scripts.h



diff --git a/engines/access/access.cpp b/engines/access/access.cpp
index f04a5de..a1f6430 100644
--- a/engines/access/access.cpp
+++ b/engines/access/access.cpp
@@ -164,7 +164,7 @@ void AccessEngine::initialize() {
 	_animation = new AnimationManager(this);
 	_bubbleBox = new BubbleBox(this);
 	_char = new CharManager(this);
-	_debugger = new Debugger(this);
+	_debugger = Debugger::init(this);
 	_events = new EventsManager(this);
 	_files = new FileManager(this);
 	_inventory = new InventoryManager(this);
diff --git a/engines/access/debugger.cpp b/engines/access/debugger.cpp
index d20b5d3..d8f7cfe 100644
--- a/engines/access/debugger.cpp
+++ b/engines/access/debugger.cpp
@@ -23,14 +23,10 @@
 #include "common/file.h"
 #include "access/access.h"
 #include "access/debugger.h"
+#include "access/amazon/amazon_game.h"
 
 namespace Access {
 
-Debugger::Debugger(AccessEngine *vm) : GUI::Debugger(), _vm(vm) {
-	registerCmd("continue",		WRAP_METHOD(Debugger, cmdExit));
-	registerCmd("scene", WRAP_METHOD(Debugger, Cmd_LoadScene));
-}
-
 static int strToInt(const char *s) {
 	if (!*s)
 		// No string at all
@@ -47,6 +43,22 @@ static int strToInt(const char *s) {
 	return (int)tmp;
 }
 
+Debugger *Debugger::init(AccessEngine *vm) {
+	switch (vm->getGameID()) {
+	case GType_Amazon:
+		return new Amazon::AmazonDebugger(vm);
+	default:
+		return new Debugger(vm);
+	}
+}
+
+/*------------------------------------------------------------------------*/
+
+Debugger::Debugger(AccessEngine *vm) : GUI::Debugger(), _vm(vm) {
+	registerCmd("continue", WRAP_METHOD(Debugger, cmdExit));
+	registerCmd("scene", WRAP_METHOD(Debugger, Cmd_LoadScene));
+}
+
 bool Debugger::Cmd_LoadScene(int argc, const char **argv) {
 	if (argc != 2) {
 		debugPrintf("Current scene is: %d\n", _vm->_player->_roomNumber);
@@ -66,4 +78,32 @@ bool Debugger::Cmd_LoadScene(int argc, const char **argv) {
 	}
 }
 
+/*------------------------------------------------------------------------*/
+
+namespace Amazon {
+
+AmazonDebugger::AmazonDebugger(AccessEngine *vm): Debugger(vm) {
+	registerCmd("chapter", WRAP_METHOD(AmazonDebugger, Cmd_StartChapter));
+}
+
+bool AmazonDebugger::Cmd_StartChapter(int argc, const char **argv) {
+	if (argc != 2) {
+		debugPrintf("Usage: %s <chapter number>\n", argv[0]);
+		return true;
+	}
+
+	// Build up a simple one line script to start the given chapter
+	byte *chapterScript = (byte *)malloc(5);
+	chapterScript[0] = SCRIPT_START_BYTE;
+	chapterScript[1] = ROOM_SCRIPT % 256;
+	chapterScript[2] = ROOM_SCRIPT / 256;
+	chapterScript[3] = 0x80 + 75;			// cmdChapter
+	chapterScript[4] = strToInt(argv[1]);	// chapter number
+	_vm->_scripts->setScript(new Resource(chapterScript, 5));
+
+	return false;
+}
+
+} // End of namespace Amazon
+
 } // End of namespace Access
diff --git a/engines/access/debugger.h b/engines/access/debugger.h
index 6c8424d..6742543 100644
--- a/engines/access/debugger.h
+++ b/engines/access/debugger.h
@@ -31,16 +31,29 @@ namespace Access {
 class AccessEngine;
 
 class Debugger : public GUI::Debugger {
-private:
-	AccessEngine *_vm;
 protected:
+	AccessEngine *_vm;
+
 	bool Cmd_LoadScene(int argc, const char **argv);
 public:
+	static Debugger *init(AccessEngine *vm);
 public:
 	Debugger(AccessEngine *vm);
 	virtual ~Debugger() {}
 };
 
+namespace Amazon {
+
+class AmazonDebugger : public Debugger {
+protected:
+	bool Cmd_StartChapter(int argc, const char **argv);
+public:
+	AmazonDebugger(AccessEngine *vm);
+	virtual ~AmazonDebugger() {}
+};
+
+} // End of namespace Amazon
+
 } // End of namespace Access
 
 #endif	/* ACCESS_DEBUGGER_H */
diff --git a/engines/access/files.cpp b/engines/access/files.cpp
index a4ec16a..bb8dc57 100644
--- a/engines/access/files.cpp
+++ b/engines/access/files.cpp
@@ -59,6 +59,12 @@ Resource::~Resource() {
 	delete _stream;
 }
 
+Resource::Resource(byte *data, int size) {
+	_data = data;
+	_size = size;
+	_stream = new Common::MemoryReadStream(data, size);
+}
+
 byte *Resource::data() {
 	if (_data == nullptr) {
 		_data = new byte[_size];
diff --git a/engines/access/files.h b/engines/access/files.h
index 720d4fb..24e2d88 100644
--- a/engines/access/files.h
+++ b/engines/access/files.h
@@ -62,6 +62,7 @@ public:
 	int _size;
 
 	Resource();
+	Resource::Resource(byte *data, int size);
 	~Resource();
 	byte *data();
 };
diff --git a/engines/access/room.cpp b/engines/access/room.cpp
index 76ad29e..c9f4a88 100644
--- a/engines/access/room.cpp
+++ b/engines/access/room.cpp
@@ -235,7 +235,7 @@ void Room::loadRoomData(const byte *roomData) {
 }
 
 void Room::roomLoop() {
-	_vm->_scripts->_sequence = 2000;
+	_vm->_scripts->_sequence = ROOM_SCRIPT;
 	_vm->_scripts->searchForSequence();
 	_vm->_scripts->executeScript();
 }
diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp
index e99af4b..72fc35d 100644
--- a/engines/access/scripts.cpp
+++ b/engines/access/scripts.cpp
@@ -25,8 +25,6 @@
 #include "access/resources.h"
 #include "access/scripts.h"
 
-#define SCRIPT_START_BYTE 0xE0
-
 namespace Access {
 
 Scripts::Scripts(AccessEngine *vm) : Manager(vm) {
diff --git a/engines/access/scripts.h b/engines/access/scripts.h
index ab80c1c..9860c7c 100644
--- a/engines/access/scripts.h
+++ b/engines/access/scripts.h
@@ -32,6 +32,9 @@ namespace Access {
 class AccessEngine;
 class Scripts;
 
+#define SCRIPT_START_BYTE 0xE0
+#define ROOM_SCRIPT 2000
+
 class Scripts: public Manager {
 private:
 	Resource *_resource;


Commit: d23d95b9129c0f0b90718630d9d136042821d026
    https://github.com/scummvm/scummvm/commit/d23d95b9129c0f0b90718630d9d136042821d026
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-12T22:25:34-05:00

Commit Message:
ACCESS: Fix display of cutscene at the end of chapter 3

Changed paths:
    engines/access/amazon/amazon_game.cpp
    engines/access/amazon/amazon_scripts.cpp
    engines/access/files.cpp
    engines/access/files.h
    engines/access/martian/martian_game.cpp
    engines/access/screen.cpp
    engines/access/scripts.cpp



diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp
index 9801df7..87aa935 100644
--- a/engines/access/amazon/amazon_game.cpp
+++ b/engines/access/amazon/amazon_game.cpp
@@ -134,7 +134,7 @@ void AmazonEngine::doTitle() {
 	_sound->queueSound(0, 98, 30);
 	_sound->queueSound(1, 98, 8);
 
-	_files->_loadPalFlag = false;
+	_files->_setPaletteFlag = false;
 	_files->loadScreen(0, 3);
 	
 	_buffer2.copyFrom(*_screen);
@@ -148,7 +148,7 @@ void AmazonEngine::doTitle() {
 
 	_sound->playSound(1);
 
-	_files->_loadPalFlag = false;
+	_files->_setPaletteFlag = false;
 	_files->loadScreen(0, 4);
 	_sound->playSound(1);
 
diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp
index 1290208..bb17f86 100644
--- a/engines/access/amazon/amazon_scripts.cpp
+++ b/engines/access/amazon/amazon_scripts.cpp
@@ -531,7 +531,7 @@ void AmazonScripts::mWhileDoOpen() {
 	delete data;
 
 	_vm->_objectsTable[1] = spr;
-	_vm->_files->_loadPalFlag = false;
+	_vm->_files->_setPaletteFlag = false;
 	_vm->_files->loadScreen(1, 2);
 	_vm->_buffer2.copyFrom(*_vm->_screen);
 	_vm->_buffer1.copyFrom(*_vm->_screen);
@@ -714,14 +714,13 @@ void AmazonScripts::guard() {
 }
 
 void AmazonScripts::loadBackground(int param1, int param2) {
-	_vm->_files->_loadPalFlag = false;
+	_vm->_files->_setPaletteFlag = false;
 	_vm->_files->loadScreen(param1, param2);
 
 	_vm->_buffer2.copyFrom(*_vm->_screen);
 	_vm->_buffer1.copyFrom(*_vm->_screen);
 
-	_vm->_screen->forceFadeOut();
-	
+	_vm->_screen->forceFadeIn();
 }
 
 void AmazonScripts::setInactive() {
diff --git a/engines/access/files.cpp b/engines/access/files.cpp
index bb8dc57..0705b5d 100644
--- a/engines/access/files.cpp
+++ b/engines/access/files.cpp
@@ -92,7 +92,7 @@ FileManager::FileManager(AccessEngine *vm): _vm(vm) {
 	}
 
 	_fileNumber = -1;
-	_loadPalFlag = true;
+	_setPaletteFlag = true;
 }
 
 FileManager::~FileManager() {
@@ -144,11 +144,7 @@ void FileManager::loadScreen(Graphics::Surface *dest, int fileNum, int subfile)
 }
 
 void FileManager::handleScreen(Graphics::Surface *dest, Resource *res) {
-	if (_loadPalFlag) {
-		_vm->_screen->loadPalette(res->_stream);
-	} else {
-		res->_stream->skip(PALETTE_SIZE);
-	}
+	_vm->_screen->loadPalette(res->_stream);
 
 	// The remainder of the file after the palette may be separately compressed,
 	// so call handleFile to handle it if it is
diff --git a/engines/access/files.h b/engines/access/files.h
index 24e2d88..f65f2ba 100644
--- a/engines/access/files.h
+++ b/engines/access/files.h
@@ -96,7 +96,7 @@ private:
 public:
 	int _fileNumber;
 	Common::Array<uint32> _fileIndex;
-	bool _loadPalFlag;
+	bool _setPaletteFlag;
 public:
 	FileManager(AccessEngine *vm);
 	~FileManager();
diff --git a/engines/access/martian/martian_game.cpp b/engines/access/martian/martian_game.cpp
index 1c13593..81a8ffd 100644
--- a/engines/access/martian/martian_game.cpp
+++ b/engines/access/martian/martian_game.cpp
@@ -97,7 +97,7 @@ void MartianEngine::doTitle() {
 
 	_sound->queueSound(0, 98, 30);
 
-	_files->_loadPalFlag = false;
+	_files->_setPaletteFlag = false;
 	_files->loadScreen(0, 3);
 	
 	_buffer2.copyFrom(*_screen);
@@ -111,7 +111,7 @@ void MartianEngine::doTitle() {
 
 	_sound->playSound(1);
 
-	_files->_loadPalFlag = false;
+	_files->_setPaletteFlag = false;
 	_files->loadScreen(0, 4);
 	_sound->playSound(1);
 
diff --git a/engines/access/screen.cpp b/engines/access/screen.cpp
index 17f36fc..3e0863c 100644
--- a/engines/access/screen.cpp
+++ b/engines/access/screen.cpp
@@ -101,8 +101,9 @@ void Screen::setInitialPalettte() {
 
 void Screen::loadPalette(Common::SeekableReadStream *stream) {
 	loadRawPalette(stream);
-	setPalette();
-	_vm->_files->_loadPalFlag = true;
+	if (_vm->_files->_setPaletteFlag)
+		setPalette();
+	_vm->_files->_setPaletteFlag = true;
 }
 
 void Screen::loadPalette(int fileNum, int subfile) {
diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp
index 72fc35d..081fc65 100644
--- a/engines/access/scripts.cpp
+++ b/engines/access/scripts.cpp
@@ -748,6 +748,9 @@ void Scripts::cmdPlayVideoSound() {
 		_vm->_sound->playSound(0);
 		_vm->_video->_soundFlag = true;
 	}
+
+	_vm->_events->pollEvents();
+	g_system->delayMillis(10);
 }
 
 void Scripts::CMDPUSHLOCATION() { error("TODO CMDPUSHLOCATION"); }
@@ -773,9 +776,9 @@ void Scripts::cmdDead() {
 
 	if (deathId != 10) {
 		_vm->_sound->newMusic(62, 0);
-		_vm->_files->_loadPalFlag = false;
+		_vm->_files->_setPaletteFlag = false;
 		_vm->_files->loadScreen(94, 0);
-		_vm->_files->_loadPalFlag = true;
+		_vm->_files->_setPaletteFlag = true;
 		_vm->_buffer2.copyFrom(*_vm->_screen);
 
 		for (int i = 0; i < 3; ++i) {
@@ -793,7 +796,7 @@ void Scripts::cmdDead() {
 		_vm->loadCells(cells);
 
 		_vm->_screen->setDisplayScan();
-		_vm->_files->_loadPalFlag = false;
+		_vm->_files->_setPaletteFlag = false;
 		_vm->_files->loadScreen(&_vm->_buffer2, 94, 1);
 		_vm->_screen->setIconPalette();
 


Commit: d6963d8d09b9bd5f1fd5cd4c58e90bb4332a5cfe
    https://github.com/scummvm/scummvm/commit/d6963d8d09b9bd5f1fd5cd4c58e90bb4332a5cfe
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-12T22:25:45-05:00

Commit Message:
ACCESS: Simplification of logic for selectively applying loaded palettes

Changed paths:
    engines/access/files.cpp
    engines/access/screen.cpp
    engines/access/screen.h



diff --git a/engines/access/files.cpp b/engines/access/files.cpp
index 0705b5d..dacceb7 100644
--- a/engines/access/files.cpp
+++ b/engines/access/files.cpp
@@ -144,7 +144,10 @@ void FileManager::loadScreen(Graphics::Surface *dest, int fileNum, int subfile)
 }
 
 void FileManager::handleScreen(Graphics::Surface *dest, Resource *res) {
-	_vm->_screen->loadPalette(res->_stream);
+	_vm->_screen->loadRawPalette(res->_stream);
+	if (_setPaletteFlag)
+		_vm->_screen->setPalette();
+	_setPaletteFlag = true;
 
 	// The remainder of the file after the palette may be separately compressed,
 	// so call handleFile to handle it if it is
diff --git a/engines/access/screen.cpp b/engines/access/screen.cpp
index 3e0863c..f985524 100644
--- a/engines/access/screen.cpp
+++ b/engines/access/screen.cpp
@@ -99,13 +99,6 @@ void Screen::setInitialPalettte() {
 	g_system->getPaletteManager()->setPalette(INITIAL_PALETTE, 0, 18);
 }
 
-void Screen::loadPalette(Common::SeekableReadStream *stream) {
-	loadRawPalette(stream);
-	if (_vm->_files->_setPaletteFlag)
-		setPalette();
-	_vm->_files->_setPaletteFlag = true;
-}
-
 void Screen::loadPalette(int fileNum, int subfile) {
 	Resource *res = _vm->_files->loadFile(fileNum, subfile);
 	byte *palette = res->data();
diff --git a/engines/access/screen.h b/engines/access/screen.h
index 2db05a5..8875ce1 100644
--- a/engines/access/screen.h
+++ b/engines/access/screen.h
@@ -121,8 +121,6 @@ public:
 	 */
 	void setIconPalette() {}
 
-	void loadPalette(Common::SeekableReadStream *stream);
-
 	void loadPalette(int fileNum, int subfile);
 
 	void setPalette();


Commit: 876ce794a1545f04aafc1752d2e25d4379fc72ea
    https://github.com/scummvm/scummvm/commit/876ce794a1545f04aafc1752d2e25d4379fc72ea
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-12T22:25:56-05:00

Commit Message:
ACCESS: Fix crash when exiting game in the middle of a chapter start

Changed paths:
    engines/access/room.cpp



diff --git a/engines/access/room.cpp b/engines/access/room.cpp
index c9f4a88..02bb3b5 100644
--- a/engines/access/room.cpp
+++ b/engines/access/room.cpp
@@ -88,7 +88,10 @@ void Room::doRoom() {
 			_vm->_player->walk();
 			_vm->_sound->midiRepeat();
 			_vm->_player->checkScroll();
+
 			doCommands();
+			if (_vm->shouldQuit())
+				return;
 
 			// DOROOMFLASHBACK jump point
 			if (_function == FN_CLEAR1) {


Commit: 6f39c07324521becc4d12354a27e213b4bc73272
    https://github.com/scummvm/scummvm/commit/6f39c07324521becc4d12354a27e213b4bc73272
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-12T22:26:05-05:00

Commit Message:
ACCESS: Fix crash when starting scene 16

Changed paths:
    engines/access/amazon/amazon_room.cpp



diff --git a/engines/access/amazon/amazon_room.cpp b/engines/access/amazon/amazon_room.cpp
index ec90fc6..fb849d2 100644
--- a/engines/access/amazon/amazon_room.cpp
+++ b/engines/access/amazon/amazon_room.cpp
@@ -93,7 +93,7 @@ void AmazonRoom::reloadRoom1() {
 	_vm->_screen->clearScreen();
 	roomSet();
 
-	if (!_roomFlag && (_vm->_player->_roomNumber != 61 || !_antOutFlag)) {
+	if (_roomFlag != 1 && (_vm->_player->_roomNumber != 61 || !_antOutFlag)) {
 		_vm->_player->load();
 		_vm->_player->calcManScale();
 	}


Commit: 8ef3d551511f2b22c36e2cdbcb50f104eb64871a
    https://github.com/scummvm/scummvm/commit/8ef3d551511f2b22c36e2cdbcb50f104eb64871a
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-12T22:26:16-05:00

Commit Message:
ACCESS: Fix scene fade ins

Changed paths:
    engines/access/room.cpp



diff --git a/engines/access/room.cpp b/engines/access/room.cpp
index 02bb3b5..e3ac84c 100644
--- a/engines/access/room.cpp
+++ b/engines/access/room.cpp
@@ -69,12 +69,12 @@ void Room::doRoom() {
 		}
 
 		reloadFlag = false;
-		_vm->_startup = 0;
+		_vm->_startup = 8;
 		_function = 0;
 
 		while (!_vm->shouldQuit()) {
 			_vm->_images.clear();
-			if (_vm->_startup != -1 && --_vm->_startup != 0) {
+			if (_vm->_startup != -1 && --_vm->_startup == 0) {
 				_vm->_events->showCursor();
 				_vm->_screen->fadeIn();
 			}


Commit: 985ad555591ebb48ebe3f2bfd711d245bab40f71
    https://github.com/scummvm/scummvm/commit/985ad555591ebb48ebe3f2bfd711d245bab40f71
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-12T22:26:25-05:00

Commit Message:
ACCESS: Airplane flight cutscene is now partially working

Changed paths:
    engines/access/amazon/amazon_scripts.cpp
    engines/access/events.cpp
    engines/access/events.h



diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp
index bb17f86..857e444 100644
--- a/engines/access/amazon/amazon_scripts.cpp
+++ b/engines/access/amazon/amazon_scripts.cpp
@@ -226,24 +226,48 @@ void AmazonScripts::mWhile2() {
 }
 
 void AmazonScripts::doFlyCell() {
-	_game->_destIn = &_game->_buffer2;
-	if (_game->_plane._pCount <= 40) {
-		_vm->_screen->plotImage(_vm->_objectsTable[15], 3, Common::Point(70, 74));
-	} else if (_game->_plane._pCount <= 80) {
-		_vm->_screen->plotImage(_vm->_objectsTable[15], 6, Common::Point(70, 74));
-	} else if (_game->_plane._pCount <= 120) {
-		_vm->_screen->plotImage(_vm->_objectsTable[15], 2, Common::Point(50, 76));
-	} else if (_game->_plane._pCount <= 160) {
-		_vm->_screen->plotImage(_vm->_objectsTable[15], 14, Common::Point(63, 78));
-	} else if (_game->_plane._pCount <= 200) {
-		_vm->_screen->plotImage(_vm->_objectsTable[15], 5, Common::Point(86, 74));
-	} else if (_game->_plane._pCount <= 240) {
-		_vm->_screen->plotImage(_vm->_objectsTable[15], 0, Common::Point(103, 76));
-	} else if (_game->_plane._pCount <= 280) {
-		_vm->_screen->plotImage(_vm->_objectsTable[15], 4, Common::Point(119, 77));
+	Plane &plane = _game->_plane;
+	SpriteResource *sprites = _vm->_objectsTable[15];
+
+	if (plane._pCount <= 40) {
+		_vm->_buffer2.plotImage(sprites, 3, Common::Point(70, 74));
+	} else if (plane._pCount <= 80) {
+		_vm->_buffer2.plotImage(sprites, 6, Common::Point(70, 74));
+	} else if (plane._pCount <= 120) {
+		_vm->_buffer2.plotImage(sprites, 2, Common::Point(50, 76));
+	} else if (plane._pCount <= 160) {
+		_vm->_buffer2.plotImage(sprites, 14, Common::Point(63, 78));
+	} else if (plane._pCount <= 200) {
+		_vm->_buffer2.plotImage(sprites, 5, Common::Point(86, 74));
+	} else if (plane._pCount <= 240) {
+		_vm->_buffer2.plotImage(sprites, 0, Common::Point(103, 76));
+	} else if (plane._pCount <= 280) {
+		_vm->_buffer2.plotImage(sprites, 4, Common::Point(119, 77));
 	} else {
-		_vm->_screen->plotImage(_vm->_objectsTable[15], 1, Common::Point(111, 77));
+		_vm->_buffer2.plotImage(sprites, 1, Common::Point(111, 77));
 	}
+
+	if (plane._pCount == 11 || plane._pCount == 12)
+		++plane._position.y;
+	else if (plane._pCount >= 28)
+		--plane._position.y;
+
+	_vm->_buffer2.plotImage(sprites, 7, plane._position);
+	_vm->_buffer2.plotImage(sprites, plane._propCount, Common::Point(
+		plane._position.x + 99, plane._position.y + 10));
+	_vm->_buffer2.plotImage(sprites, plane._propCount, Common::Point(
+		plane._position.x + 104, plane._position.y + 18));
+
+	if (++plane._planeCount >= 30)
+		plane._planeCount = 0;
+	if (++plane._propCount >= 3)
+		plane._propCount = 0;
+
+	++plane._xCount;
+	if (plane._xCount == 1)
+		++plane._position.x;
+	else
+		plane._xCount = 0;
 }
 
 void AmazonScripts::doFallCell() {
@@ -320,59 +344,63 @@ void AmazonScripts::scrollJWalk() {
 }
 
 void AmazonScripts::mWhileFly() {
-	_vm->_events->hideCursor();
-	_vm->_screen->clearScreen();
-	_vm->_screen->setBufferScan();
-	_vm->_screen->fadeOut();
-	_vm->_screen->_scrollX = 0;
+	Screen &screen = *_vm->_screen;
+	Player &player = *_vm->_player;
+	EventsManager &events = *_vm->_events;
+	Plane &plane = _game->_plane;
+
+	events.hideCursor();
+	screen.clearScreen();
+	screen.setBufferScan();
+	screen.fadeOut();
+	screen._scrollX = 0;
 
 	_vm->_room->buildScreen();
 	_vm->copyBF2Vid();
-	_vm->_screen->fadeIn();
+	screen.fadeIn();
 	_vm->_oldRects.clear();
 	_vm->_newRects.clear();
 
 	// KEYFLG = 0;
 
-	_vm->_screen->_scrollRow = _vm->_screen->_scrollCol = 0;
-	_vm->_screen->_scrollX = _vm->_screen->_scrollY = 0;
-	_vm->_player->_rawPlayer = Common::Point(0, 0);
-	_vm->_player->_scrollAmount = 1;
+	screen._scrollRow = screen._scrollCol = 0;
+	screen._scrollX = screen._scrollY = 0;
+	player._rawPlayer = Common::Point(0, 0);
+	player._scrollAmount = 1;
 
-	_game->_plane._pCount = 0;
-	_game->_plane._planeCount = 0;
-	_game->_plane._propCount = 0;
-	_game->_plane._xCount = 0;
-	_game->_plane._position = Common::Point(20, 29);
+	plane._pCount = 0;
+	plane._planeCount = 0;
+	plane._propCount = 0;
+	plane._xCount = 0;
+	plane._position = Common::Point(20, 29);
 
-	warning("FIXME: _vbCount should be handled in NEWTIMER");
-	while (true) {
-		int _vbCount = 4;
-		if (_vm->_screen->_scrollCol + _vm->_screen->_vWindowWidth == _vm->_room->_playFieldWidth) {
-			_vm->_events->showCursor();
-			return;
-		}
+	while (!_vm->shouldQuit() && ((screen._scrollCol + screen._vWindowWidth) 
+			!= _vm->_room->_playFieldWidth)) {
+		events._vbCount = 4;
+		screen._scrollX += player._scrollAmount;
 
-		_vm->_screen->_scrollX += _vm->_player->_scrollAmount;
-		while (_vm->_screen->_scrollX >= TILE_WIDTH) {
-			_vm->_screen->_scrollX -= TILE_WIDTH;
-			++_vm->_screen->_scrollCol;
+		while (screen._scrollX >= TILE_WIDTH) {
+			screen._scrollX -= TILE_WIDTH;
+			++screen._scrollCol;
 
 			_vm->_buffer1.moveBufferLeft();
-			_vm->_room->buildColumn(_vm->_screen->_scrollCol + _vm->_screen->_vWindowWidth, _vm->_screen->_vWindowBytesWide);
+			_vm->_room->buildColumn(screen._scrollCol + screen._vWindowWidth, screen._vWindowBytesWide);
 		}
 
 		scrollFly();
-		++_game->_plane._pCount;
-		g_system->delayMillis(10);
+		++plane._pCount;
 
-		while(_vbCount > 0) {
+		while (!_vm->shouldQuit() && events._vbCount > 0) {
 			// To be rewritten when NEWTIMER is done
-			_vm->_events->checkForNextFrameCounter();
-			_vbCount--;
+			events.checkForNextFrameCounter();
 			_vm->_sound->playSound(0);
+
+			g_system->delayMillis(10);
+			events.pollEvents();
 		}
 	}
+
+	events.showCursor();
 }
 
 void AmazonScripts::mWhileFall() {
diff --git a/engines/access/events.cpp b/engines/access/events.cpp
index 0b7a348..7741a87 100644
--- a/engines/access/events.cpp
+++ b/engines/access/events.cpp
@@ -44,6 +44,7 @@ EventsManager::EventsManager(AccessEngine *vm): _vm(vm) {
 	_wheelUp = _wheelDown = false;
 	_mouseCol = _mouseRow = 0;
 	_cursorExitFlag = false;
+	_vbCount = 0;
 }
 
 EventsManager::~EventsManager() {
@@ -184,6 +185,7 @@ bool EventsManager::checkForNextFrameCounter() {
 	// Check for next game frame
 	uint32 milli = g_system->getMillis();
 	if ((milli - _priorFrameTime) >= GAME_FRAME_TIME) {
+		--_vbCount;
 		++_frameCounter;
 		_priorFrameTime = milli;
 
diff --git a/engines/access/events.h b/engines/access/events.h
index b29b541..def04ef 100644
--- a/engines/access/events.h
+++ b/engines/access/events.h
@@ -57,6 +57,7 @@ public:
 	Common::Point _mousePos;
 	int _mouseCol, _mouseRow;
 	bool _cursorExitFlag;
+	int _vbCount;
 	Common::FixedStack<Common::KeyState> _keypresses;
 public:
 	/**


Commit: bbaea32386927c856d22b97c877ddbba41fb142f
    https://github.com/scummvm/scummvm/commit/bbaea32386927c856d22b97c877ddbba41fb142f
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-12T22:26:35-05:00

Commit Message:
ACCESS: Fixes for flying plane cutscene

Changed paths:
    engines/access/amazon/amazon_scripts.cpp
    engines/access/events.cpp
    engines/access/events.h
    engines/access/room.cpp



diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp
index 857e444..b79b1c5 100644
--- a/engines/access/amazon/amazon_scripts.cpp
+++ b/engines/access/amazon/amazon_scripts.cpp
@@ -247,15 +247,15 @@ void AmazonScripts::doFlyCell() {
 		_vm->_buffer2.plotImage(sprites, 1, Common::Point(111, 77));
 	}
 
-	if (plane._pCount == 11 || plane._pCount == 12)
+	if (plane._planeCount == 11 || plane._planeCount == 12)
 		++plane._position.y;
-	else if (plane._pCount >= 28)
+	else if (plane._planeCount >= 28)
 		--plane._position.y;
 
 	_vm->_buffer2.plotImage(sprites, 7, plane._position);
-	_vm->_buffer2.plotImage(sprites, plane._propCount, Common::Point(
+	_vm->_buffer2.plotImage(sprites, 8 + plane._propCount, Common::Point(
 		plane._position.x + 99, plane._position.y + 10));
-	_vm->_buffer2.plotImage(sprites, plane._propCount, Common::Point(
+	_vm->_buffer2.plotImage(sprites, 11 + plane._propCount, Common::Point(
 		plane._position.x + 104, plane._position.y + 18));
 
 	if (++plane._planeCount >= 30)
@@ -374,8 +374,8 @@ void AmazonScripts::mWhileFly() {
 	plane._xCount = 0;
 	plane._position = Common::Point(20, 29);
 
-	while (!_vm->shouldQuit() && ((screen._scrollCol + screen._vWindowWidth) 
-			!= _vm->_room->_playFieldWidth)) {
+	while (!_vm->shouldQuit() && !events.isKeyMousePressed() &&
+			((screen._scrollCol + screen._vWindowWidth) != _vm->_room->_playFieldWidth)) {
 		events._vbCount = 4;
 		screen._scrollX += player._scrollAmount;
 
diff --git a/engines/access/events.cpp b/engines/access/events.cpp
index 7741a87..0287e8c 100644
--- a/engines/access/events.cpp
+++ b/engines/access/events.cpp
@@ -264,6 +264,13 @@ int EventsManager::checkMouseBox1(Common::Array<Common::Rect> &rects) {
 	}
 }
 
+bool EventsManager::isKeyMousePressed() {
+	bool result = _leftButton || _rightButton || _keypresses.size() > 0;
+	debounceLeft();
+	zeroKeys();
+
+	return result;
+}
 
 
 } // End of namespace Access
diff --git a/engines/access/events.h b/engines/access/events.h
index def04ef..4888a27 100644
--- a/engines/access/events.h
+++ b/engines/access/events.h
@@ -124,6 +124,8 @@ public:
 	Common::Point calcRawMouse();
 
 	int checkMouseBox1(Common::Array<Common::Rect> &rects);
+
+	bool isKeyMousePressed();
 };
 
 } // End of namespace Access
diff --git a/engines/access/room.cpp b/engines/access/room.cpp
index e3ac84c..f1e499d 100644
--- a/engines/access/room.cpp
+++ b/engines/access/room.cpp
@@ -126,7 +126,10 @@ void Room::doRoom() {
 				_vm->copyBF1BF2();
 				_vm->_newRects.clear();
 				_function = 0;
+
 				roomLoop();
+				if (_vm->shouldQuit())
+					return;
 
 				if (_function == FN_CLEAR1) {
 					clearRoom();


Commit: d7cf5701324eb0e9b69017e596f8577bf9fe14a1
    https://github.com/scummvm/scummvm/commit/d7cf5701324eb0e9b69017e596f8577bf9fe14a1
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-12T22:26:49-05:00

Commit Message:
ACCESS: Fix restoring talk bubbles where right edge is a bit over screen edge

Changed paths:
    engines/access/bubble_box.cpp



diff --git a/engines/access/bubble_box.cpp b/engines/access/bubble_box.cpp
index d865d5c..37b757f 100644
--- a/engines/access/bubble_box.cpp
+++ b/engines/access/bubble_box.cpp
@@ -52,6 +52,8 @@ void BubbleBox::clearBubbles() {
 		_vm->_screen->_screenYOff = 0;
 		Common::Rect r = _bubbles[i];
 		r.left -= 2;
+		r.right = MIN(r.right, (int16)_vm->_screen->w);
+
 		_vm->_screen->copyBlock(&_vm->_buffer2, r);
 	}
 


Commit: 4448929812a5b8ca21eebb594e587a582392c9a3
    https://github.com/scummvm/scummvm/commit/4448929812a5b8ca21eebb594e587a582392c9a3
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-12T22:26:58-05:00

Commit Message:
ACCESS: Fixes for selecting bottom buttons in conversation screen

Changed paths:
    engines/access/scripts.cpp



diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp
index 081fc65..2971180 100644
--- a/engines/access/scripts.cpp
+++ b/engines/access/scripts.cpp
@@ -555,11 +555,11 @@ void Scripts::cmdTexSpeak() {
 	findNull();
 }
 
+#define BTN_COUNT 6
 void Scripts::cmdTexChoice() {
-	static Common::Point cMouse[7] = {
-		Common::Point(0, 76), Common::Point(77, 154), Common::Point(155, 232),
-		Common::Point(233, 276), Common::Point(0, 0), Common::Point(277, 319),
-		Common::Point(297, 319)
+	static const int BTN_RANGES[BTN_COUNT][2] = {
+		{ 0, 76 }, { 77, 154 }, { 155, 232 }, { 233, 276 }, { 0, 0 }, 
+		{ 277, 319 }
 	};
 
 	_vm->_oldRects.clear();
@@ -636,8 +636,8 @@ void Scripts::cmdTexChoice() {
 			if (_vm->_events->_mouseRow >= 22) {
 				_vm->_events->debounceLeft();
 				int x = _vm->_events->_mousePos.x;
-				for (int i = 0; i < 7; i++) {
-					if ((x >= cMouse->x) && (x < cMouse->y)) {
+				for (int i = 0; i < BTN_COUNT; i++) {
+					if ((x >= BTN_RANGES[i][0]) && (x < BTN_RANGES[i][1])) {
 						choice = i;
 						break;
 					}
@@ -687,7 +687,7 @@ void Scripts::cmdSetConPos() {
 void Scripts::CMDCHECKVFRAME() { error("TODO CMDCHECKVFRAME"); }
 
 void Scripts::cmdJumpChoice() {
-	int val = (_data->readUint16LE() && 0xFF);
+	int val = (_data->readUint16LE() & 0xFF);
 	
 	if (val == _choice) {
 		_sequence = _data->readUint16LE();


Commit: 4ce87a51a061c31b0f2db605712ce7e0cab5b5d7
    https://github.com/scummvm/scummvm/commit/4ce87a51a061c31b0f2db605712ce7e0cab5b5d7
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-12T22:27:07-05:00

Commit Message:
ACCESS: Fix restoring screen after offering a character an inventory item

Changed paths:
    engines/access/inventory.cpp
    engines/access/room.cpp



diff --git a/engines/access/inventory.cpp b/engines/access/inventory.cpp
index 4573846..f2c87b2 100644
--- a/engines/access/inventory.cpp
+++ b/engines/access/inventory.cpp
@@ -113,7 +113,7 @@ int InventoryManager::newDisplayInv() {
 	_invModeFlag = true;
 	_vm->_timers.saveTimers();
 	
-	if (room._tile && !_invRefreshFlag) {
+	if (!room._tile && !_invRefreshFlag) {
 		saveScreens();
 	}
 
@@ -360,6 +360,9 @@ void InventoryManager::restoreScreens() {
 	_vm->_buffer1.w = _vm->_buffer1.pitch;
 	_savedBuffer1.copyTo(&_vm->_buffer1);
 	_savedScreen.copyTo(_vm->_screen);
+
+	_savedBuffer1.free();
+	_savedScreen.free();
 }
 
 void InventoryManager::outlineIcon(int itemIndex) {
diff --git a/engines/access/room.cpp b/engines/access/room.cpp
index f1e499d..e3a4615 100644
--- a/engines/access/room.cpp
+++ b/engines/access/room.cpp
@@ -163,6 +163,7 @@ void Room::clearRoom() {
 	_vm->_scripts->freeScriptData();
 	_vm->freeCells();
 	freePlayField();
+	freeTileData();
 	_vm->freeInactiveData();
 	_vm->_player->freeSprites();
 }


Commit: 6390f54d4b6e191d5b1f85d0a3f86e94bb110228
    https://github.com/scummvm/scummvm/commit/6390f54d4b6e191d5b1f85d0a3f86e94bb110228
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-12T22:27:18-05:00

Commit Message:
ACCESS: Fix crash at end of cmdDead

Changed paths:
    engines/access/scripts.cpp



diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp
index 2971180..9f32194 100644
--- a/engines/access/scripts.cpp
+++ b/engines/access/scripts.cpp
@@ -824,9 +824,10 @@ void Scripts::cmdDead() {
 
 		warning("TODO: restart game");
 		_vm->quitGame();
-	}
-	else {
+		_vm->_events->pollEvents();
+	} else {
 		_vm->quitGame();
+		_vm->_events->pollEvents();
 	}
 }
 


Commit: 304db8ee6f963a4f647488623fd30ccb70472962
    https://github.com/scummvm/scummvm/commit/304db8ee6f963a4f647488623fd30ccb70472962
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-12T22:27:28-05:00

Commit Message:
ACCESS: Add some code to display scene number & description

Changed paths:
    engines/access/amazon/amazon_resources.cpp
    engines/access/amazon/amazon_resources.h
    engines/access/debugger.cpp
    engines/access/debugger.h
    engines/access/martian/martian_resources.cpp
    engines/access/martian/martian_resources.h



diff --git a/engines/access/amazon/amazon_resources.cpp b/engines/access/amazon/amazon_resources.cpp
index e60da5b..42dc35a 100644
--- a/engines/access/amazon/amazon_resources.cpp
+++ b/engines/access/amazon/amazon_resources.cpp
@@ -574,6 +574,24 @@ const byte *ROOM_TABLE[] = {
 	CAVE, nullptr, nullptr, nullptr, PIT, nullptr, nullptr
 };
 
+const char *ROOM_DESCR[] = {
+	"TBD CREDITS", nullptr, nullptr, nullptr, "TBD ALLISTER",
+	"TBD HALL", "TBD JASONLAB", nullptr, "TBD ALLENLAB", "TBD OUTVAULT",
+	"TBD VAULT", "TBD LIBRARY", "TBD JASAPT", "TBD RANSACKED", "TBD MEAN1",
+	"TBD FLYSOUTH", "TBD CUZCO", "TBD INAIR", "TBD GREENMONKEY", "TBD INPLANE",
+	"TBD PILFALL", "TBD COCKPIT", "TBD CRASH", "TBD SINKING", "TBD JNGLWLK",
+	"TBD TOWN", "TBD HOTEL", "TBD CANTINA", nullptr, "TBD MASSACRE",
+	"TBD TRADE", "TBD BRIDGE", "TBD DOCK", "TBD DRIVER", nullptr,
+	nullptr, "TBD SHORE", "TBD BOAT", "TBD CABIN", "TBD CAPTIVE",
+	nullptr, nullptr, "TBD VILLAGE", nullptr, "TBD TREE",
+	"TBD CANOE", "TBD INTREE", "TBD FALLS", nullptr, nullptr,
+	nullptr, nullptr, nullptr, nullptr, "TBD WATERFALL",
+	"TBD INWATER", nullptr, "TBD CAVE", nullptr, nullptr,
+	nullptr, "TBD PIT", nullptr, nullptr
+};
+
+const int ROOM_NUMB = 63;
+
 const byte ELAINE[] = {
 	0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
 	0xFF, 0x0, 0x0, 0x0, 0x0, 0x41, 0x41, 0x0, 0x1, 0x0, 0xFF, 0x41, 0x0, 0x2,
diff --git a/engines/access/amazon/amazon_resources.h b/engines/access/amazon/amazon_resources.h
index 2be9b4d..7aee900 100644
--- a/engines/access/amazon/amazon_resources.h
+++ b/engines/access/amazon/amazon_resources.h
@@ -36,6 +36,8 @@ extern const byte *CURSORS[10];
 extern const int TRAVEL_POS[][2];
 
 extern const byte *ROOM_TABLE[];
+extern const char *ROOM_DESCR[];
+extern const int ROOM_NUMB;
 
 extern const byte *CHARTBL[];
 
diff --git a/engines/access/debugger.cpp b/engines/access/debugger.cpp
index d8f7cfe..17ab6e1 100644
--- a/engines/access/debugger.cpp
+++ b/engines/access/debugger.cpp
@@ -57,15 +57,38 @@ Debugger *Debugger::init(AccessEngine *vm) {
 Debugger::Debugger(AccessEngine *vm) : GUI::Debugger(), _vm(vm) {
 	registerCmd("continue", WRAP_METHOD(Debugger, cmdExit));
 	registerCmd("scene", WRAP_METHOD(Debugger, Cmd_LoadScene));
+
+	switch (vm->getGameID()) {
+	case GType_Amazon:
+		_sceneNumb = Amazon::ROOM_NUMB;
+		_sceneDescr = new Common::String[_sceneNumb];
+		for (int i = 0; i < _sceneNumb; i++)
+			_sceneDescr[i] = Common::String(Amazon::ROOM_DESCR[i]);
+		break;
+	case GType_MartianMemorandum:
+		_sceneNumb = Martian::ROOM_NUMB;
+		_sceneDescr = new Common::String[_sceneNumb];
+		for (int i = 0; i < _sceneNumb; i++)
+			_sceneDescr[i] = Common::String(Martian::ROOM_DESCR[i]);
+		break;
+	default:
+		_sceneDescr = nullptr;
+		_sceneNumb = 0;
+		break;
+	}
 }
 
 bool Debugger::Cmd_LoadScene(int argc, const char **argv) {
-	if (argc != 2) {
-		debugPrintf("Current scene is: %d\n", _vm->_player->_roomNumber);
-		debugPrintf("Usage: %s <scene number>\n", argv[0]);
+	switch (argc) {
+	case 1:
+		debugPrintf("Current scene is: %d\n\n", _vm->_player->_roomNumber);
+
+		for (int i = 0; i < _sceneNumb; i++)
+			if (_sceneDescr[i].size())
+				debugPrintf("%d - %s\n", i, _sceneDescr[i].c_str());
 		return true;
-	}
-	else {
+
+	case 2:
 		_vm->_player->_roomNumber = strToInt(argv[1]);
 
 		_vm->_room->_function = FN_CLEAR1;
@@ -75,6 +98,11 @@ bool Debugger::Cmd_LoadScene(int argc, const char **argv) {
 		_vm->_scripts->_returnCode = 0;
 
 		return false;
+
+	default:
+		debugPrintf("Current scene is: %d\n", _vm->_player->_roomNumber);
+		debugPrintf("Usage: %s <scene number>\n", argv[0]);
+		return true;
 	}
 }
 
diff --git a/engines/access/debugger.h b/engines/access/debugger.h
index 6742543..60bd223 100644
--- a/engines/access/debugger.h
+++ b/engines/access/debugger.h
@@ -25,6 +25,8 @@
 
 #include "common/scummsys.h"
 #include "gui/debugger.h"
+#include "access/amazon/amazon_resources.h"
+#include "access/martian/martian_resources.h"
 
 namespace Access {
 
@@ -35,6 +37,8 @@ protected:
 	AccessEngine *_vm;
 
 	bool Cmd_LoadScene(int argc, const char **argv);
+	Common::String *_sceneDescr;
+	int _sceneNumb;
 public:
 	static Debugger *init(AccessEngine *vm);
 public:
diff --git a/engines/access/martian/martian_resources.cpp b/engines/access/martian/martian_resources.cpp
index b596797..5dfb766 100644
--- a/engines/access/martian/martian_resources.cpp
+++ b/engines/access/martian/martian_resources.cpp
@@ -421,6 +421,21 @@ const byte *ROOM_TABLE[] = {
 	nullptr, nullptr, nullptr, nullptr, nullptr, ROOM_TABLE47
 };
 
+const char *ROOM_DESCR[] = {
+	nullptr, "TBD ROOM_TABLE1", "TBD ROOM_TABLE2", "TBD ROOM_TABLE3", "TBD ROOM_TABLE4",
+	"TBD ROOM_TABLE5", "TBD ROOM_TABLE6", "TBD ROOM_TABLE7", "TBD ROOM_TABLE8", "TBD ROOM_TABLE9",
+	nullptr, "TBD ROOM_TABLE11", nullptr, "TBD ROOM_TABLE13", "TBD ROOM_TABLE14",
+	"TBD ROOM_TABLE15", "TBD ROOM_TABLE16", "TBD ROOM_TABLE17", "TBD ROOM_TABLE18", nullptr,
+	nullptr, "TBD ROOM_TABLE21", "TBD ROOM_TABLE22", "TBD ROOM_TABLE23", "TBD ROOM_TABLE24",
+	"TBD ROOM_TABLE25", "TBD ROOM_TABLE26", "TBD ROOM_TABLE27", "TBD ROOM_TABLE28", "TBD ROOM_TABLE29",
+	"TBD ROOM_TABLE30", "TBD ROOM_TABLE31", "TBD ROOM_TABLE32", "TBD ROOM_TABLE33", nullptr,
+	"TBD ROOM_TABLE35", nullptr, "TBD ROOM_TABLE37", "TBD ROOM_TABLE38", "TBD ROOM_TABLE39",
+	nullptr, nullptr, nullptr, nullptr, nullptr,
+	nullptr, nullptr, "TBD ROOM_TABLE47"
+};
+
+const int ROOM_NUMB = 48;
+
 const byte CHAR_TABLE0[] = {
 	0x02, 0x31, 0x00, 0x08, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff,
 	0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff,
diff --git a/engines/access/martian/martian_resources.h b/engines/access/martian/martian_resources.h
index a6ababe..ab8dfb4 100644
--- a/engines/access/martian/martian_resources.h
+++ b/engines/access/martian/martian_resources.h
@@ -38,6 +38,8 @@ extern const int TRAVEL_POS[][2];
 extern const char *const INVENTORY_NAMES[];
 
 extern const byte *ROOM_TABLE[];
+extern const char *ROOM_DESCR[];
+extern const int ROOM_NUMB;
 
 extern const byte *CHAR_TABLE[];
 


Commit: dd2bfdd47fb111259f94fbd985513d56c263305d
    https://github.com/scummvm/scummvm/commit/dd2bfdd47fb111259f94fbd985513d56c263305d
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-12T22:27:40-05:00

Commit Message:
ACCESS: Fix compilation warning by adding a dummy inventory combo array for Martian

Changed paths:
    engines/access/inventory.cpp
    engines/access/martian/martian_resources.cpp
    engines/access/martian/martian_resources.h



diff --git a/engines/access/inventory.cpp b/engines/access/inventory.cpp
index f2c87b2..34470ac 100644
--- a/engines/access/inventory.cpp
+++ b/engines/access/inventory.cpp
@@ -69,6 +69,7 @@ InventoryManager::InventoryManager(AccessEngine *vm) : Manager(vm) {
 		break;
 	case GType_MartianMemorandum:
 		names = Martian::INVENTORY_NAMES;
+		combineP = &Martian::COMBO_TABLE[0][0];
 		_inv.resize(54);
 		break;
 	default:
diff --git a/engines/access/martian/martian_resources.cpp b/engines/access/martian/martian_resources.cpp
index 5dfb766..ae63f66 100644
--- a/engines/access/martian/martian_resources.cpp
+++ b/engines/access/martian/martian_resources.cpp
@@ -659,6 +659,64 @@ const byte *CHAR_TABLE[] = {
 	CHAR_TABLE26, CHAR_TABLE27
 };
 
+// TODO: Fix that array
+const int COMBO_TABLE[54][4] = {
+	{ -1, -1, -1, -1 },
+	{ -1, -1, -1, -1 },
+	{ -1, -1, -1, -1 },
+	{ -1, -1, -1, -1 },
+	{ -1, -1, -1, -1 },
+	{ -1, -1, -1, -1 },
+	{ -1, -1, -1, -1 },
+	{ -1, -1, -1, -1 },
+	{ -1, -1, -1, -1 },
+	{ -1, -1, -1, -1 },
+	{ -1, -1, -1, -1 },
+	{ -1, -1, -1, -1 },
+	{ -1, -1, -1, -1 },
+	{ -1, -1, -1, -1 },
+	{ -1, -1, -1, -1 },
+	{ -1, -1, -1, -1 },
+	{ -1, -1, -1, -1 },
+	{ -1, -1, -1, -1 },
+	{ -1, -1, -1, -1 },
+	{ -1, -1, -1, -1 },
+	{ -1, -1, -1, -1 },
+	{ -1, -1, -1, -1 },
+	{ -1, -1, -1, -1 },
+	{ -1, -1, -1, -1 },
+	{ -1, -1, -1, -1 },
+	{ -1, -1, -1, -1 },
+	{ -1, -1, -1, -1 },
+	{ -1, -1, -1, -1 },
+	{ -1, -1, -1, -1 },
+	{ -1, -1, -1, -1 },
+	{ -1, -1, -1, -1 },
+	{ -1, -1, -1, -1 },
+	{ -1, -1, -1, -1 },
+	{ -1, -1, -1, -1 },
+	{ -1, -1, -1, -1 },
+	{ -1, -1, -1, -1 },
+	{ -1, -1, -1, -1 },
+	{ -1, -1, -1, -1 },
+	{ -1, -1, -1, -1 },
+	{ -1, -1, -1, -1 },
+	{ -1, -1, -1, -1 },
+	{ -1, -1, -1, -1 },
+	{ -1, -1, -1, -1 },
+	{ -1, -1, -1, -1 },
+	{ -1, -1, -1, -1 },
+	{ -1, -1, -1, -1 },
+	{ -1, -1, -1, -1 },
+	{ -1, -1, -1, -1 },
+	{ -1, -1, -1, -1 },
+	{ -1, -1, -1, -1 },
+	{ -1, -1, -1, -1 },
+	{ -1, -1, -1, -1 },
+	{ -1, -1, -1, -1 },
+	{ -1, -1, -1, -1 }
+};
+
 } // End of namespace Martian
 
 } // End of namespace Access
diff --git a/engines/access/martian/martian_resources.h b/engines/access/martian/martian_resources.h
index ab8dfb4..b9584ba 100644
--- a/engines/access/martian/martian_resources.h
+++ b/engines/access/martian/martian_resources.h
@@ -43,6 +43,8 @@ extern const int ROOM_NUMB;
 
 extern const byte *CHAR_TABLE[];
 
+extern const int COMBO_TABLE[54][4];
+
 } // End of namespace Martian
 
 } // End of namespace Access


Commit: 0df4c903c77b3614723bfc183102c89aa071a65f
    https://github.com/scummvm/scummvm/commit/0df4c903c77b3614723bfc183102c89aa071a65f
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-12T22:27:52-05:00

Commit Message:
ACCESS: Add some safeguards in LoadScene debugger command

Changed paths:
    engines/access/amazon/amazon_resources.cpp
    engines/access/debugger.cpp



diff --git a/engines/access/amazon/amazon_resources.cpp b/engines/access/amazon/amazon_resources.cpp
index 42dc35a..a1db01d 100644
--- a/engines/access/amazon/amazon_resources.cpp
+++ b/engines/access/amazon/amazon_resources.cpp
@@ -575,19 +575,19 @@ const byte *ROOM_TABLE[] = {
 };
 
 const char *ROOM_DESCR[] = {
-	"TBD CREDITS", nullptr, nullptr, nullptr, "TBD ALLISTER",
-	"TBD HALL", "TBD JASONLAB", nullptr, "TBD ALLENLAB", "TBD OUTVAULT",
-	"TBD VAULT", "TBD LIBRARY", "TBD JASAPT", "TBD RANSACKED", "TBD MEAN1",
-	"TBD FLYSOUTH", "TBD CUZCO", "TBD INAIR", "TBD GREENMONKEY", "TBD INPLANE",
-	"TBD PILFALL", "TBD COCKPIT", "TBD CRASH", "TBD SINKING", "TBD JNGLWLK",
+	"Credits", nullptr, nullptr, nullptr, "Outside of Allister Center",
+	"Hall", "Jason's Lab", nullptr, "Allen's Lab", "Outside of the Vault",
+	"Inside the Vault", "Reader", "Jason's Apartment", "Jason's ransacked apartment", "Cutscene 1",
+	"TBD FLYSOUTH", "Cuzco Airport", "TBD INAIR", "Green Monkey Club", "In Plane",
+	"TBD PILFALL", "TBD COCKPIT", "TBD CRASH", "TBD SINKING", "Cutscene Jungle Walk",
 	"TBD TOWN", "TBD HOTEL", "TBD CANTINA", nullptr, "TBD MASSACRE",
 	"TBD TRADE", "TBD BRIDGE", "TBD DOCK", "TBD DRIVER", nullptr,
 	nullptr, "TBD SHORE", "TBD BOAT", "TBD CABIN", "TBD CAPTIVE",
 	nullptr, nullptr, "TBD VILLAGE", nullptr, "TBD TREE",
 	"TBD CANOE", "TBD INTREE", "TBD FALLS", nullptr, nullptr,
 	nullptr, nullptr, nullptr, nullptr, "TBD WATERFALL",
-	"TBD INWATER", nullptr, "TBD CAVE", nullptr, nullptr,
-	nullptr, "TBD PIT", nullptr, nullptr
+	"TBD INWATER", nullptr, "Cave Bridge", nullptr, nullptr,
+	nullptr, "Pit with Ants", nullptr, nullptr
 };
 
 const int ROOM_NUMB = 63;
diff --git a/engines/access/debugger.cpp b/engines/access/debugger.cpp
index 17ab6e1..9a82168 100644
--- a/engines/access/debugger.cpp
+++ b/engines/access/debugger.cpp
@@ -88,8 +88,18 @@ bool Debugger::Cmd_LoadScene(int argc, const char **argv) {
 				debugPrintf("%d - %s\n", i, _sceneDescr[i].c_str());
 		return true;
 
-	case 2:
-		_vm->_player->_roomNumber = strToInt(argv[1]);
+	case 2: {
+		int newRoom = strToInt(argv[1]);
+		if (newRoom < 0 || newRoom >= _sceneNumb) {
+			debugPrintf("Invalid Room Number");
+			return true;
+		}
+		if (!_sceneDescr[newRoom].size()) {
+			debugPrintf("Unused Room Number");
+			return true;
+		}
+			
+		_vm->_player->_roomNumber = newRoom;
 
 		_vm->_room->_function = FN_CLEAR1;
 		_vm->freeChar();
@@ -98,7 +108,7 @@ bool Debugger::Cmd_LoadScene(int argc, const char **argv) {
 		_vm->_scripts->_returnCode = 0;
 
 		return false;
-
+		}
 	default:
 		debugPrintf("Current scene is: %d\n", _vm->_player->_roomNumber);
 		debugPrintf("Usage: %s <scene number>\n", argv[0]);


Commit: ea206330813aff730c7af5f1aec931f8720105d9
    https://github.com/scummvm/scummvm/commit/ea206330813aff730c7af5f1aec931f8720105d9
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-12T22:28:02-05:00

Commit Message:
ACCESS: Fix cutscene of pilot falling out of plane

Changed paths:
    engines/access/amazon/amazon_scripts.cpp
    engines/access/room.cpp



diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp
index b79b1c5..8e33ae6 100644
--- a/engines/access/amazon/amazon_scripts.cpp
+++ b/engines/access/amazon/amazon_scripts.cpp
@@ -271,13 +271,14 @@ void AmazonScripts::doFlyCell() {
 }
 
 void AmazonScripts::doFallCell() {
-	if (_vm->_scaleI <= 0)
+	if (_vm->_scaleI <= 20)
 		return;
 
-	_game->_destIn = &_game->_buffer2;
+	SpriteFrame *frame = _vm->_objectsTable[20]->getFrame(_game->_plane._planeCount / 6);
+	Common::Rect r(115, 11, 115 + _vm->_screen->_scaleTable1[frame->w], 
+		11 + _vm->_screen->_scaleTable1[frame->h]);
+	_vm->_buffer2.sPlotF(frame, r);
 
-	// 115, 11, i
-	_vm->_screen->plotImage(_vm->_objectsTable[20], _game->_plane._planeCount / 6, Common::Point(115, 11));
 	_vm->_scaleI -= 3;
 	_vm->_scale = _vm->_scaleI;
 	_vm->_screen->setScaleTable(_vm->_scale);
@@ -404,53 +405,53 @@ void AmazonScripts::mWhileFly() {
 }
 
 void AmazonScripts::mWhileFall() {
-	_vm->_events->hideCursor();
-	_vm->_screen->clearScreen();
-	_vm->_screen->setBufferScan();
-	_vm->_screen->fadeOut();
-	_vm->_screen->_scrollX = 0;
+	Screen &screen = *_vm->_screen;
+	EventsManager &events = *_vm->_events;
+
+	events.hideCursor();
+	screen.clearScreen();
+	screen.setBufferScan();
+	screen.fadeOut();
+	screen._scrollX = 0;
 
 	_vm->_room->buildScreen();
 	_vm->copyBF2Vid();
-	_vm->_screen->fadeIn();
+	screen.fadeIn();
 	_vm->_oldRects.clear();
 	_vm->_newRects.clear();
 
 	// KEYFLG = 0;
 
-	_vm->_screen->_scrollRow = _vm->_screen->_scrollCol = 0;
-	_vm->_screen->_scrollX = _vm->_screen->_scrollY = 0;
+	screen._scrollRow = screen._scrollCol = 0;
+	screen._scrollX = screen._scrollY = 0;
 	_vm->_player->_scrollAmount = 3;
 	_vm->_scaleI = 255;
 
 	_game->_plane._xCount = 0;
 	_game->_plane._planeCount = 0;
 
-	while (true) {
-		int _vbCount = 4;
-		if (_vm->_screen->_scrollCol + _vm->_screen->_vWindowWidth == _vm->_room->_playFieldWidth) {
-			_vm->_events->showCursor();
-			return;
-		}
+	while (!_vm->shouldQuit() && !events.isKeyMousePressed() &&
+			(screen._scrollCol + screen._vWindowWidth != _vm->_room->_playFieldWidth)) {
+		events._vbCount = 4;
+		screen._scrollX += _vm->_player->_scrollAmount;
 
-		_vm->_screen->_scrollX += _vm->_player->_scrollAmount;
-		while (_vm->_screen->_scrollX >= TILE_WIDTH) {
-			_vm->_screen->_scrollX -= TILE_WIDTH;
-			++_vm->_screen->_scrollCol;
+		while (screen._scrollX >= TILE_WIDTH) {
+			screen._scrollX -= TILE_WIDTH;
+			++screen._scrollCol;
 
 			_vm->_buffer1.moveBufferLeft();
-			_vm->_room->buildColumn(_vm->_screen->_scrollCol + _vm->_screen->_vWindowWidth, _vm->_screen->_vWindowBytesWide);
+			_vm->_room->buildColumn(screen._scrollCol + screen._vWindowWidth, screen._vWindowBytesWide);
 		}
 
 		scrollFall();
-		g_system->delayMillis(10);
 
-		while(_vbCount > 0) {
-			// To be rewritten when NEWTIMER is done
-			_vm->_events->checkForNextFrameCounter();
-			_vbCount--;
+		while (!_vm->shouldQuit() && events._vbCount > 0) {
+			events.pollEvents();
+			g_system->delayMillis(10);
 		}
 	}
+
+	events.showCursor();
 }
 
 void AmazonScripts::mWhileJWalk() {
diff --git a/engines/access/room.cpp b/engines/access/room.cpp
index e3a4615..513c159 100644
--- a/engines/access/room.cpp
+++ b/engines/access/room.cpp
@@ -316,6 +316,9 @@ void Room::buildScreen() {
 }
 
 void Room::buildColumn(int playX, int screenX) {
+	if (playX < 0 || playX >= _playFieldWidth)
+		return;
+
 	const byte *pSrc = _playField + _vm->_screen->_scrollRow * 
 		_playFieldWidth + playX;
 


Commit: 7ce1da3ba47bcc7092aa7ff12b9fe1102b707e06
    https://github.com/scummvm/scummvm/commit/7ce1da3ba47bcc7092aa7ff12b9fe1102b707e06
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-12T22:28:15-05:00

Commit Message:
ACCESS: Some cleanup of remaining game cutscenes code

Changed paths:
    engines/access/amazon/amazon_scripts.cpp



diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp
index 8e33ae6..53ac4be 100644
--- a/engines/access/amazon/amazon_scripts.cpp
+++ b/engines/access/amazon/amazon_scripts.cpp
@@ -455,6 +455,10 @@ void AmazonScripts::mWhileFall() {
 }
 
 void AmazonScripts::mWhileJWalk() {
+	Screen &screen = *_vm->_screen;
+	EventsManager &events = *_vm->_events;
+	Player &player = *_vm->_player;
+
 	const int jungleObj[7][4] = {
 		{2, 77, 0, 40},
 		{0, 290, 0, 50},
@@ -465,22 +469,22 @@ void AmazonScripts::mWhileJWalk() {
 		{1, -150, 0, 30},
 	};
 
-	_vm->_screen->fadeOut();
-	_vm->_events->hideCursor();
-	_vm->_screen->clearScreen();
+	screen.fadeOut();
+	events.hideCursor();
+	screen.clearScreen();
 	_vm->_buffer2.clearBuffer();
-	_vm->_screen->setBufferScan();
-	_vm->_screen->_scrollX = 0;
+	screen.setBufferScan();
+	screen._scrollX = 0;
 
 	_vm->_room->buildScreen();
 	_vm->copyBF2Vid();
-	_vm->_screen->fadeIn();
+	screen.fadeIn();
 
 	// KEYFLG = 0;
-	_vm->_player->_xFlag = 1;
-	_vm->_player->_yFlag = 0;
-	_vm->_player->_moveTo.x = 160;
-	_vm->_player->_move = UP;
+	player._xFlag = 1;
+	player._yFlag = 0;
+	player._moveTo.x = 160;
+	player._move = UP;
 
 	_game->_plane._xCount = 2;
 	_xTrack = 10;
@@ -503,35 +507,36 @@ void AmazonScripts::mWhileJWalk() {
 		_pObjXl[i] = _pObjYl[i] = 0;
 	}
 	
-	while (true) {
+	while (!_vm->shouldQuit() && !events.isKeyMousePressed() && (player._xFlag != 2)) {
 		_vm->_images.clear();
-		int _vbCount = 6;
-		if (_vm->_player->_xFlag == 2) {
-			_vm->_events->showCursor();
-			return;
-		}
-		
+		events._vbCount = 6;
+
 		_pImgNum[0] = _game->_plane._xCount;
 		if (_game->_plane._xCount == 2)
 			++_game->_plane._xCount;
 		else
 			--_game->_plane._xCount;
 
-		_vm->_player->checkMove();
-		_vm->_player->checkScroll();
+		player.checkMove();
+		player.checkScroll();
 		pan();
 		scrollJWalk();
 
 		g_system->delayMillis(10);
-		while(_vbCount > 0) {
-			// To be rewritten when NEWTIMER is done
-			_vm->_events->checkForNextFrameCounter();
-			_vbCount--;
+		while (!_vm->shouldQuit() && events._vbCount > 0) {
+			events.pollEvents();
+			g_system->delayMillis(10);
 		}
 	}
+
+	_vm->_images.clear();
+	events.showCursor();
 }
 
 void AmazonScripts::mWhileDoOpen() {
+	Screen &screen = *_vm->_screen;
+	EventsManager &events = *_vm->_events;
+
 	const int openObj[10][4] = {
 		{8, -80, 120, 30},
 		{13, 229, 0, 50},
@@ -545,12 +550,12 @@ void AmazonScripts::mWhileDoOpen() {
 		{4, -280, 40, 120},
 	};
 
-	_vm->_screen->setBufferScan();
-	_vm->_events->hideCursor();
-	_vm->_screen->forceFadeOut();
+	screen.setBufferScan();
+	events.hideCursor();
+	screen.forceFadeOut();
 	_game->_skipStart = false;
 	if (_vm->_conversation != 2) {
-		_vm->_screen->setPanel(3);
+		screen.setPanel(3);
 		_game->startChapter(1);
 		_game->establishCenter(0, 1);
 	}
@@ -594,7 +599,7 @@ void AmazonScripts::mWhileDoOpen() {
 	_vm->_sound->newMusic(10, 0);
 	
 	bool startFl = false;
-	while (true) {
+	while (!_vm->shouldQuit()) {
 		_vm->_images.clear();
 		_vm->_animation->animate(0);
 		_vm->_animation->animate(1);
@@ -605,29 +610,28 @@ void AmazonScripts::mWhileDoOpen() {
 		_vm->copyBlocks();
 		if (!startFl) {
 			startFl = true;
-			_vm->_screen->forceFadeIn();
+			screen.forceFadeIn();
 		}
-		_vm->_events->pollEvents();
+		events.pollEvents();
 		warning("TODO: check on KEYBUFCNT");
-		if (_vm->_events->_leftButton || _vm->_events->_rightButton) {
+		if (events._leftButton || events._rightButton) {
 			_game->_skipStart = true;
 			_vm->_sound->newMusic(10, 1);
 			break;
 		}
 
 		if (_xCam > 680) {
-			warning("FIXME: _vbCount should be handled in NEWTIMER");
-			int _vbCount = 125;
-			while(_vbCount > 0) {
-				// To be rewritten when NEWTIMER is done
-				_vm->_events->checkForNextFrameCounter();
-				_vbCount--;
+			events._vbCount = 125;
+			
+			while(!_vm->shouldQuit() && !events.isKeyMousePressed() && events._vbCount > 0) {
+				events.pollEvents();
+				g_system->delayMillis(10);
 			}
 			break;
 		}
 	}
 	
-	_vm->_events->showCursor();
+	events.showCursor();
 	_vm->_buffer2.copyFrom(*_vm->_screen);
 	_vm->_buffer1.copyFrom(*_vm->_screen);
 	warning("TODO: delete _roomInfo;");
@@ -636,6 +640,7 @@ void AmazonScripts::mWhileDoOpen() {
 	_vm->_newRects.clear();
 	_vm->_numAnimTimers = 0;
 	_vm->_images.clear();
+
 	if (_vm->_conversation == 2) {
 		Resource *spriteData = _vm->_files->loadFile(28, 37);
 		_vm->_objectsTable[28] = new SpriteResource(_vm, spriteData);


Commit: 0ed120b9ff380bc59a96214c0e3ea2b60bb71c8f
    https://github.com/scummvm/scummvm/commit/0ed120b9ff380bc59a96214c0e3ea2b60bb71c8f
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-12T22:28:36-05:00

Commit Message:
ACCESS: Fix buffer source when clearing speech bubbles

Changed paths:
    engines/access/bubble_box.cpp



diff --git a/engines/access/bubble_box.cpp b/engines/access/bubble_box.cpp
index 37b757f..9f47c90 100644
--- a/engines/access/bubble_box.cpp
+++ b/engines/access/bubble_box.cpp
@@ -54,7 +54,7 @@ void BubbleBox::clearBubbles() {
 		r.left -= 2;
 		r.right = MIN(r.right, (int16)_vm->_screen->w);
 
-		_vm->_screen->copyBlock(&_vm->_buffer2, r);
+		_vm->_screen->copyBlock(&_vm->_buffer1, r);
 	}
 
 	// Clear the list


Commit: 38edbfb4bcbdfe819a133ede25bd85b19d12df60
    https://github.com/scummvm/scummvm/commit/38edbfb4bcbdfe819a133ede25bd85b19d12df60
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-12T22:28:48-05:00

Commit Message:
ACCESS: Little cleanup in roomMenu

Changed paths:
    engines/access/amazon/amazon_room.cpp



diff --git a/engines/access/amazon/amazon_room.cpp b/engines/access/amazon/amazon_room.cpp
index fb849d2..db46b48 100644
--- a/engines/access/amazon/amazon_room.cpp
+++ b/engines/access/amazon/amazon_room.cpp
@@ -148,13 +148,14 @@ void AmazonRoom::roomMenu() {
 	SpriteResource *spr = new SpriteResource(_vm, iconData);
 	delete iconData;
 
-	_vm->_screen->saveScreen();
-	_vm->_screen->setDisplayScan();
-	_vm->_destIn = _vm->_screen;	// TODO: Redundant
-	_vm->_screen->plotImage(spr, 0, Common::Point(0, 177));
-	_vm->_screen->plotImage(spr, 1, Common::Point(143, 177));
+	Screen &screen = *_vm->_screen;
+	screen.saveScreen();
+	screen.setDisplayScan();
+	_vm->_destIn = &screen;	// TODO: Redundant
+	screen.plotImage(spr, 0, Common::Point(0, 177));
+	screen.plotImage(spr, 1, Common::Point(143, 177));
 
-	_vm->_screen->restoreScreen();
+	screen.restoreScreen();
 	delete spr;
 }
 


Commit: 26b632a9eb36f8e5e8874b50666b3d739dd1416f
    https://github.com/scummvm/scummvm/commit/26b632a9eb36f8e5e8874b50666b3d739dd1416f
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-12T22:29:02-05:00

Commit Message:
ACCESS: Fix display in cmdDeath()

Changed paths:
    engines/access/access.cpp
    engines/access/font.cpp



diff --git a/engines/access/access.cpp b/engines/access/access.cpp
index a1f6430..b309e92 100644
--- a/engines/access/access.cpp
+++ b/engines/access/access.cpp
@@ -325,16 +325,15 @@ void AccessEngine::printText(ASurface *s, const Common::String &msg) {
 		_fonts._font2._fontColors[1] = 28;
 		_fonts._font2._fontColors[2] = 29;
 		_fonts._font2._fontColors[3] = 30;
-
 		_fonts._font2.drawString(s, line, s->_printOrg);
-		s->_printOrg = Common::Point(s->_printStart.x, s->_printOrg.y + 9);
 
-		if (lastLine)
-			break;
+		s->_printOrg = Common::Point(s->_printStart.x, s->_printOrg.y + 9);
 
-		_events->waitKeyMouse();
-		_buffer2.copyBuffer(s);
-		s->_printOrg.y = s->_printStart.y;
+		if (s->_printOrg.y >_printEnd && !lastLine) {
+			_events->waitKeyMouse();
+			s->copyBuffer(&_buffer2);
+			s->_printOrg.y = s->_printStart.y;
+		}
 
 		if (lastLine)
 			break;
diff --git a/engines/access/font.cpp b/engines/access/font.cpp
index ffc1715..5eaf0b0 100644
--- a/engines/access/font.cpp
+++ b/engines/access/font.cpp
@@ -111,7 +111,7 @@ bool Font::getLine(Common::String &s, int maxWidth, Common::String &line, int &w
 		// Reached maximum allowed size
 		// If this was the last character of the string, let it go
 		if (*src == '\0')
-			break;
+			return true;
 		
 		// Work backwards to find space at the start of the current word 
 		// as a point to split the line on


Commit: 0e01c3623a499fd69acef789bb4c2a6c39091b99
    https://github.com/scummvm/scummvm/commit/0e01c3623a499fd69acef789bb4c2a6c39091b99
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-12T22:29:16-05:00

Commit Message:
ACCESS: Fixes to pan method

Changed paths:
    engines/access/amazon/amazon_scripts.cpp



diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp
index 53ac4be..189f634 100644
--- a/engines/access/amazon/amazon_scripts.cpp
+++ b/engines/access/amazon/amazon_scripts.cpp
@@ -295,18 +295,18 @@ void AmazonScripts::doFallCell() {
 void AmazonScripts::pan() {
 	_zCam += _zTrack;
 	_xCam += _xTrack;
-	int tx = (_xCam << 8) / _zCam;
+	int tx = (_xTrack << 8) / _zCam;
 	_yCam += _yTrack;
-	int ty = (_yCam << 8) / _zCam;
+	int ty = (_yTrack << 8) / _zCam;
 
 	if (_vm->_timers[24]._flag != 1) {
 		++_vm->_timers[24]._flag;
 		for (int i = 0; i < _pNumObj; i++) {
-			_pObjZ[i] = _zTrack;
-			_pObjXl[i] += tx * _zTrack;
-			_pObjX[i] += _pObjXl[i];
-			_pObjYl[i] += ty * _zTrack;
-			_pObjY[i] += _pObjYl[i];
+			_pObjZ[i] += _zTrack;
+			_pObjXl[i] += (_pObjZ[i] * tx) & 0xff;
+			_pObjX[i] += (_pObjZ[i] * tx) >> 8;
+			_pObjYl[i] += (_pObjZ[i] * ty) & 0xff;
+			_pObjY[i] += (_pObjZ[i] * ty) >> 8;
 		}
 	}
 
@@ -317,6 +317,8 @@ void AmazonScripts::pan() {
 		ie._offsetY = 0xFF;
 		ie._spritesPtr = _pObject[i];
 		ie._frameNumber = _pImgNum[i];
+
+		_vm->_images.addToList(&ie);
 	}
 }
 


Commit: 878038fe07ed750a4616d4a86dfb2a9f9873d245
    https://github.com/scummvm/scummvm/commit/878038fe07ed750a4616d4a86dfb2a9f9873d245
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-12T22:29:27-05:00

Commit Message:
ACCESS: Fix redundant pointer references in adding items to _images list

Changed paths:
    engines/access/amazon/amazon_scripts.cpp
    engines/access/animation.cpp
    engines/access/asurface.cpp
    engines/access/asurface.h
    engines/access/player.cpp



diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp
index 189f634..3ccca2b 100644
--- a/engines/access/amazon/amazon_scripts.cpp
+++ b/engines/access/amazon/amazon_scripts.cpp
@@ -318,7 +318,7 @@ void AmazonScripts::pan() {
 		ie._spritesPtr = _pObject[i];
 		ie._frameNumber = _pImgNum[i];
 
-		_vm->_images.addToList(&ie);
+		_vm->_images.addToList(ie);
 	}
 }
 
@@ -810,7 +810,7 @@ void AmazonScripts::plotInactive() {
 	_vm->_inactive._offsetY = _game->_inactiveYOff;
 	_vm->_inactive._frameNumber = 0;
 
-	_vm->_images.addToList(&_vm->_inactive);
+	_vm->_images.addToList(_vm->_inactive);
 
 }
 
diff --git a/engines/access/animation.cpp b/engines/access/animation.cpp
index 03f349e..de44740 100644
--- a/engines/access/animation.cpp
+++ b/engines/access/animation.cpp
@@ -232,7 +232,7 @@ void Animation::setFrame1(AnimationFrame *frame) {
 		ie._position = part->_position + _vm->_animation->_base;
 		ie._offsetY = part->_offsetY - ie._position.y;
 
-		_vm->_images.addToList(&ie);
+		_vm->_images.addToList(ie);
 	}
 }
 
diff --git a/engines/access/asurface.cpp b/engines/access/asurface.cpp
index cf8bf07..d36f6e4 100644
--- a/engines/access/asurface.cpp
+++ b/engines/access/asurface.cpp
@@ -90,9 +90,9 @@ static bool sortImagesY(const ImageEntry &ie1, const ImageEntry &ie2) {
 	return (ie1._position.y + ie1._offsetY) < (ie2._position.y + ie2._offsetY);
 }
 
-void ImageEntryList::addToList(ImageEntry *ie) {
+void ImageEntryList::addToList(ImageEntry &ie) {
 	assert(size() < 35);
-	push_back(*ie);
+	push_back(ie);
 	Common::sort(begin(), end(), sortImagesY);
 }
 
diff --git a/engines/access/asurface.h b/engines/access/asurface.h
index 5c164f0..d066589 100644
--- a/engines/access/asurface.h
+++ b/engines/access/asurface.h
@@ -144,7 +144,7 @@ public:
 
 class ImageEntryList : public Common::Array<ImageEntry> {
 public:
-	void addToList(ImageEntry *ie);
+	void addToList(ImageEntry &ie);
 };
 
 } // End of namespace Access
diff --git a/engines/access/player.cpp b/engines/access/player.cpp
index ba5ba89..2abe9ad 100644
--- a/engines/access/player.cpp
+++ b/engines/access/player.cpp
@@ -667,7 +667,7 @@ void Player::plotCom1() {
 
 void Player::plotCom2() {
 	if (!_playerOff)
-		_vm->_images.addToList(this);
+		_vm->_images.addToList(*this);
 }
 
 void Player::plotCom3() {


Commit: 340a3fa91bc6168f5e073a33afd48a083fb14d10
    https://github.com/scummvm/scummvm/commit/340a3fa91bc6168f5e073a33afd48a083fb14d10
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-12T22:29:44-05:00

Commit Message:
ACCESS: Fix player walking in jungle cutscene

Changed paths:
    engines/access/amazon/amazon_scripts.cpp



diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp
index 3ccca2b..a22f04b 100644
--- a/engines/access/amazon/amazon_scripts.cpp
+++ b/engines/access/amazon/amazon_scripts.cpp
@@ -461,7 +461,7 @@ void AmazonScripts::mWhileJWalk() {
 	EventsManager &events = *_vm->_events;
 	Player &player = *_vm->_player;
 
-	const int jungleObj[7][4] = {
+	static const int JUNGLE_OBJ[7][4] = {
 		{2, 77, 0, 40},
 		{0, 290, 0, 50},
 		{1, 210, 0, 70},
@@ -478,15 +478,16 @@ void AmazonScripts::mWhileJWalk() {
 	screen.setBufferScan();
 	screen._scrollX = 0;
 
+	// Build the initial jungle scene and fade it in
 	_vm->_room->buildScreen();
 	_vm->copyBF2Vid();
 	screen.fadeIn();
 
-	// KEYFLG = 0;
+	// Set up the player to walk horizontally
 	player._xFlag = 1;
 	player._yFlag = 0;
 	player._moveTo.x = 160;
-	player._move = UP;
+	player._playerMove = true;
 
 	_game->_plane._xCount = 2;
 	_xTrack = 10;
@@ -502,10 +503,10 @@ void AmazonScripts::mWhileJWalk() {
 	_pNumObj = 7;
 	for (int i = 0; i < _pNumObj; i++) {
 		_pObject[i] = _vm->_objectsTable[24];
-		_pImgNum[i] = jungleObj[i][0];
-		_pObjX[i] = jungleObj[i][1];
-		_pObjY[i] = jungleObj[i][2];
-		_pObjZ[i] = jungleObj[i][3];
+		_pImgNum[i] = JUNGLE_OBJ[i][0];
+		_pObjX[i] = JUNGLE_OBJ[i][1];
+		_pObjY[i] = JUNGLE_OBJ[i][2];
+		_pObjZ[i] = JUNGLE_OBJ[i][3];
 		_pObjXl[i] = _pObjYl[i] = 0;
 	}
 	


Commit: 4d82191f34c2c08f250914f52b183914e26e4df9
    https://github.com/scummvm/scummvm/commit/4d82191f34c2c08f250914f52b183914e26e4df9
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-12T22:29:58-05:00

Commit Message:
ACCESS: Fix crashes for scene debugger command when launched from cmdCheckTimer

Changed paths:
    engines/access/scripts.cpp



diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp
index 9f32194..34d5372 100644
--- a/engines/access/scripts.cpp
+++ b/engines/access/scripts.cpp
@@ -46,6 +46,7 @@ Scripts::~Scripts() {
 void Scripts::setScript(Resource *res) {
 	_resource = res;
 	_data = res->_stream;
+	_endFlag = true;
 }
 
 void Scripts::freeScriptData() {
@@ -416,6 +417,12 @@ void Scripts::cmdCheckTimer() {
 	_vm->_events->pollEvents();
 	_vm->_canSaveLoad = false;
 
+	// Since the ScummVM debugger can be launched from the above point, we need
+	// to check whether the script needs to be ended here, since some commands,
+	// like the scene command, can change the current script
+	if (_endFlag)
+		return;
+
 	if ((idx == 9) && (_vm->_events->_keypresses.size() > 0)) {
 		_vm->_events->zeroKeys();
 		_vm->_timers[9]._timer = 0;


Commit: a97bbb86c4c40a10e67b358372743c919a5ee59d
    https://github.com/scummvm/scummvm/commit/a97bbb86c4c40a10e67b358372743c919a5ee59d
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-12T22:30:08-05:00

Commit Message:
ACCESS: Fix incorrect screen draw during setup of bubble boxes

Changed paths:
    engines/access/bubble_box.cpp



diff --git a/engines/access/bubble_box.cpp b/engines/access/bubble_box.cpp
index 9f47c90..ff6c4de 100644
--- a/engines/access/bubble_box.cpp
+++ b/engines/access/bubble_box.cpp
@@ -67,7 +67,7 @@ void BubbleBox::placeBubble(const Common::String &msg) {
 }
 
 void BubbleBox::placeBubble1(const Common::String &msg) {
-	clearBubbles();
+	_bubbles.clear();
 	_vm->_fonts._charSet._lo = 1;
 	_vm->_fonts._charSet._hi = 8;
 	_vm->_fonts._charFor._lo = 29;


Commit: fa46257a77c462c92c6c6c5f7af2ef55dbb0d802
    https://github.com/scummvm/scummvm/commit/fa46257a77c462c92c6c6c5f7af2ef55dbb0d802
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-12T22:30:23-05:00

Commit Message:
ACCESS: Fix item Z ordering issue causing flickering in airplane rear scene

Changed paths:
    engines/access/asurface.cpp



diff --git a/engines/access/asurface.cpp b/engines/access/asurface.cpp
index d36f6e4..dbbf119 100644
--- a/engines/access/asurface.cpp
+++ b/engines/access/asurface.cpp
@@ -87,7 +87,8 @@ ImageEntry::ImageEntry() {
 /*------------------------------------------------------------------------*/
 
 static bool sortImagesY(const ImageEntry &ie1, const ImageEntry &ie2) {
-	return (ie1._position.y + ie1._offsetY) < (ie2._position.y + ie2._offsetY);
+	int v = (ie1._position.y + ie1._offsetY) - (ie2._position.y + ie2._offsetY);
+	return (v < 0) || (v == 0 && ie1._position.y <= ie2._position.y);
 }
 
 void ImageEntryList::addToList(ImageEntry &ie) {


Commit: 2fe5957393d37cbae864327ddefe262cbb789211
    https://github.com/scummvm/scummvm/commit/2fe5957393d37cbae864327ddefe262cbb789211
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-12T22:30:44-05:00

Commit Message:
ACCESS: Start working on ANT()

Changed paths:
    engines/access/amazon/amazon_game.cpp
    engines/access/amazon/amazon_game.h
    engines/access/amazon/amazon_resources.cpp
    engines/access/amazon/amazon_resources.h
    engines/access/amazon/amazon_scripts.cpp
    engines/access/amazon/amazon_scripts.h



diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp
index 87aa935..b1a8bbe 100644
--- a/engines/access/amazon/amazon_game.cpp
+++ b/engines/access/amazon/amazon_game.cpp
@@ -57,6 +57,17 @@ AmazonEngine::AmazonEngine(OSystem *syst, const AccessGameDescription *gameDesc)
 	_tilePos = Common::Point(0, 0);
 	_hintLevel = 0;
 
+	_antDirection = NONE;
+	_pitDirection = NONE;
+	_antCel = 0;
+	_torchCel = 0;
+	_pitCel = 0;
+	_stabCel = 0;
+	_antPos = Common::Point(0, 0);
+	_antDieFl = _antEatFl = false;
+	_stabFl = false;
+	_pitPos = Common::Point(0, 0);
+
 	Common::fill(&_esTabTable[0], &_esTabTable[100], 0);
 	memset(_tileData, 0, sizeof(_tileData));
 	
diff --git a/engines/access/amazon/amazon_game.h b/engines/access/amazon/amazon_game.h
index 653deef..0c6fb1c 100644
--- a/engines/access/amazon/amazon_game.h
+++ b/engines/access/amazon/amazon_game.h
@@ -149,6 +149,18 @@ public:
 	int _canoeVXPos;
 	int _canoeMoveCount;
 	int _canoeFrame;
+
+	Direction _antDirection;
+	Direction _pitDirection;
+	int _antCel;
+	int _torchCel;
+	int _pitCel;
+	int _stabCel;
+	Common::Point _antPos;
+	bool _antDieFl;
+	bool _antEatFl;
+	bool _stabFl;
+	Common::Point _pitPos;
 public:
 	AmazonEngine(OSystem *syst, const AccessGameDescription *gameDesc);
 
diff --git a/engines/access/amazon/amazon_resources.cpp b/engines/access/amazon/amazon_resources.cpp
index a1db01d..5768be3 100644
--- a/engines/access/amazon/amazon_resources.cpp
+++ b/engines/access/amazon/amazon_resources.cpp
@@ -1458,6 +1458,71 @@ const int COMBO_TABLE[85][4] = {
 	{ -1, -1, -1, -1 }
 };
 
-} // End of namespace Amazon
+const int ANTWALK[24] = {
+	 0,  3,  0,
+	 1,  5,  0,
+	 2,  4,  0,
+	 3,  2,  0,
+	 4,  4,  0,
+	 5,  3,  0,
+	 6,  4,  0,
+	-1, -1, -1
+};
+
+const int ANTEAT[33] = {
+	 7,  0,  -1,
+	 8,  0,  -5,
+	 9,  0, -11,
+	10,  0,   7,
+	11,  0,  -3,
+	12,  0,   3,
+	13,  0,  -1,
+	 9,  0,  -6,
+	 8,  0,  11,
+	 7,  0,   6,
+	-1, -1,  -1 
+};
+
+const int ANTDIE[21] = {
+	14,  4,  8,
+	15,  7,  6,
+	16,  6,  7,
+	17,  8,  2,
+	18,  0,  0,
+	19,  0,  0,
+	-1, -1, -1
+};
+
+const int PITWALK[27] = {
+	18,  0, -1,
+	19, -2,  1,
+	20, -2,  1,
+	21, -2,  1,
+	22, -2,  0,
+	23, -3,  0,
+	24, -3, -1,
+	25, -2, -1,
+	-1, -1, -1
+};
+
+const int PITSTAB[21] = {
+	14, -2,   0,
+	15, -4,   0,
+	16,  3, -13,
+	16,  0,   0,
+	15, -3,  13,
+	14,  4,   0,
+	-1, -1,  -1
+};
+
+const int TORCH[12] = {
+	26, -11, -7,
+	27, -12, -2,
+	28, -15, -4,
+	-1,  -1, -1
+};
+
+const int SPEAR[3] = {30, -13, 1};
 
+} // End of namespace Amazon
 } // End of namespace Access
diff --git a/engines/access/amazon/amazon_resources.h b/engines/access/amazon/amazon_resources.h
index 7aee900..0d65a56 100644
--- a/engines/access/amazon/amazon_resources.h
+++ b/engines/access/amazon/amazon_resources.h
@@ -68,6 +68,19 @@ extern const int CHAPTER_JUMP[14];
 
 extern const int COMBO_TABLE[85][4];
 
+extern const int ANTWALK[24];
+
+extern const int ANTEAT[33];
+
+extern const int ANTDIE[21];
+
+extern const int PITWALK[27];
+
+extern const int PITSTAB[21];
+
+extern const int TORCH[12];
+
+extern const int SPEAR[3];
 } // End of namespace Amazon
 
 } // End of namespace Access
diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp
index a22f04b..0074a5d 100644
--- a/engines/access/amazon/amazon_scripts.cpp
+++ b/engines/access/amazon/amazon_scripts.cpp
@@ -768,6 +768,257 @@ void AmazonScripts::setInactive() {
 	mWhile(_game->_rawInactiveY);
 }
 
+void AmazonScripts::PLOTPIT() {
+	warning("TODO: PLOTPIT");
+}
+
+void AmazonScripts::ANT() {
+	_game->_antDirection = NONE;
+	if (_game->_aniFlag != 1) {
+		_game->_aniFlag = 1;
+		_game->_antCel = 0;
+		_game->_torchCel = 0;
+		_game->_pitCel = 0;
+
+		_game->_timers[15]._timer = 16;
+		_game->_timers[15]._initTm = 16;
+		_game->_timers[15]._flag = 1;
+
+		_game->_timers[13]._timer = 5;
+		_game->_timers[13]._initTm = 5;
+		_game->_timers[13]._flag = 1;
+
+		_game->_timers[14]._timer = 10;
+		_game->_timers[14]._initTm = 10;
+		_game->_timers[14]._flag = 1;
+
+		_game->_antPos = Common::Point(-40, 123);
+		_game->_antDieFl = _game->_antEatFl = false;
+		_game->_stabFl = false;
+		_game->_pitPos = Common::Point(_vm->_player->_rawPlayer.x, 127);
+	}
+
+	const int *buf = nullptr;
+	if (_game->_antDieFl) {
+		buf = Amazon::ANTDIE;
+	} else if (_game->_antEatFl) {
+		buf = Amazon::ANTEAT;
+	} else if (_game->_antPos.x > 120 && _vm->_flags[198] == 1) {
+		_game->_antEatFl = true;
+		_vm->_flags[235] = 1;
+		_game->_antCel = 0;
+		buf = Amazon::ANTEAT;
+	} else {
+		buf = Amazon::ANTWALK;
+		if (_vm->_inventory->_inv[76]._value == 1)
+			_game->_antDirection = UP;
+	}
+
+	int idx = _game->_antCel;
+	if (_game->_timers[15]._flag == 0) {
+		_game->_timers[15]._flag = 1;
+		if (_game->_antDirection == UP) {
+			if (_game->_antPos.x > 10) {
+				if (idx == 0)
+					idx = 36;
+				else
+					idx -= 6;
+
+				_game->_antPos = Common::Point(buf[(idx / 2) + 1], buf[(idx / 2) + 2]);
+				_game->_antCel = idx;
+			}
+		} else {
+			idx += 6;
+			if (buf[(idx / 2)] != -1) {
+				_game->_antPos = Common::Point(buf[(idx / 2) + 1], buf[(idx / 2) + 2]);
+				_game->_antCel = idx;
+			} else if (!_game->_antDieFl) {
+				idx = 0;
+				_game->_antPos = Common::Point(buf[(idx / 2) + 1], buf[(idx / 2) + 2]);
+				_game->_antCel = idx;
+			} else {
+				idx -= 6;
+				if (_game->_flags[200] == 0)
+					_game->_flags[200] = 1;
+			}
+		}
+	}
+
+	ImageEntry ie;
+	ie._flags = 8;
+	ie._spritesPtr = _pObject[61];
+	ie._frameNumber = buf[(idx / 2)];
+	ie._position = Common::Point(_game->_antPos.x, _game->_antPos.y);
+	ie._offsetY = _game->_antPos.y - 70;
+	_vm->_images.addToList(ie);
+	_game->_antCel = idx;
+
+	if (_game->_flags[196] != 1) {
+		idx = _game->_pitCel;
+		if (_game->_stabFl == 1) {
+			if (_vm->_inventory->_inv[78]._value == 1) {
+				PLOTPIT();
+			} else {
+				buf = Amazon::PITSTAB;
+				idx = _game->_stabCel;
+				if (_game->_timers[13]._flag == 0) {
+					PLOTPIT();
+				} else {
+					_game->_timers[13]._flag = 1;
+					idx += 6;
+					if (Amazon::PITSTAB[idx] == -1) {
+						_game->_stabFl = false;
+						_game->_pitCel = 0;
+						_game->_pitPos.y = 127;
+						idx = 0;
+						buf = Amazon::PITWALK;
+						PLOTPIT();
+					} else {
+						_game->_pitPos.x += buf[(idx / 2) + 1];
+						_game->_pitPos.y += buf[(idx / 2) + 2];
+						_game->_pitCel = idx;
+						PLOTPIT();
+					}
+				}
+			}
+		} else {
+			buf = Amazon::PITWALK;
+			if (_game->_timers[13]._flag != 0) {
+				PLOTPIT();
+			} else {
+				_game->_timers[13]._flag = 1;
+				_vm->_events->pollEvents();
+				if (_vm->_events->_leftButton) {
+					Common::Point pt = _vm->_events->calcRawMouse();
+					if (pt.x < _game->_pitPos.x) {
+						if (_game->_pitDirection == UP) {
+							_game->_pitDirection = NONE;
+							_game->_pitPos.y = 127;
+						}
+						idx = _game->_pitCel;
+						buf = Amazon::PITWALK;
+						idx += 6;
+						if (buf[idx / 2] == -1) {
+							idx = 0;
+							_game->_pitPos.y = 127;
+						}
+						_game->_pitPos.x += buf[(idx / 2) + 1];
+						_game->_pitPos.y += buf[(idx / 2) + 2];
+						_game->_pitCel = idx;
+						PLOTPIT();
+					} else if (pt.x > _game->_pitPos.x) {
+						if (_game->_pitDirection == NONE) {
+							_game->_pitDirection = UP;
+							_game->_pitPos.y = 127;
+							idx = _game->_pitCel;
+							buf = Amazon::PITWALK;
+							if (_game->_pitPos.x >= 230)
+								PLOTPIT();
+							else {
+								if (idx == 0) {
+									idx = 48;
+									_game->_pitPos.y = 127;
+								}
+								idx -= 6;
+								_game->_pitPos.x -= buf[(idx / 2) + 1];
+								_game->_pitPos.y -= buf[(idx / 2) + 2];
+								_game->_pitCel = idx;
+								PLOTPIT();
+							}
+						}
+					} else {
+						PLOTPIT();
+					}
+				} else {
+					buf = Amazon::PITWALK;
+					if (_vm->_player->_playerDirection == UP) {
+						if (_vm->_inventory->_inv[78]._value == 1) {
+							PLOTPIT();
+						} else {
+							if (_game->_stabFl) {
+								buf = Amazon::PITSTAB;
+								idx = _game->_stabCel;
+								if (_game->_timers[13]._flag == 0) {
+									PLOTPIT();
+								} else {
+									_game->_timers[13]._flag = 1;
+									idx += 6;
+									if (Amazon::PITSTAB[idx] == -1) {
+										_game->_stabFl = false;
+										_game->_pitCel = 0;
+										_game->_pitPos.y = 127;
+										idx = 0;
+										buf = Amazon::PITWALK;
+										PLOTPIT();
+									} else {
+										_game->_pitPos.x += buf[(idx / 2) + 1];
+										_game->_pitPos.y += buf[(idx / 2) + 2];
+										_game->_pitCel = idx;
+										PLOTPIT();
+									}
+								}
+							} else {
+								_game->_stabFl = true;
+								_game->_pitCel = 0;
+								idx = 0;
+								_game->_stabCel = 0;
+								int dist = _game->_pitPos.x - _game->_antPos.x;
+								if (!_game->_antEatFl || _game->_antDieFl || (dist > 80))
+									PLOTPIT();
+								else {
+									_game->_antDieFl = true;
+									_game->_antCel = 0;
+									_game->_antPos.y = 123;
+									_vm->_sound->playSound(1);
+									PLOTPIT();
+								}
+							}
+						}
+					} else if (_vm->_player->_playerDirection == LEFT) {
+						if (_game->_pitDirection == UP) {
+							_game->_pitDirection = NONE;
+							_game->_pitPos.y = 127;
+						}
+						idx = _game->_pitCel;
+						buf = Amazon::PITWALK;
+						idx += 6;
+						if (buf[idx / 2] == -1) {
+							idx = 0;
+							_game->_pitPos.y = 127;
+						}
+						_game->_pitPos.x += buf[(idx / 2) + 1];
+						_game->_pitPos.y += buf[(idx / 2) + 2];
+						_game->_pitCel = idx;
+						PLOTPIT();
+					} else if (_vm->_player->_playerDirection == RIGHT) {
+						if (_game->_pitDirection == NONE) {
+							_game->_pitDirection = UP;
+							_game->_pitPos.y = 127;
+							idx = _game->_pitCel;
+							buf = Amazon::PITWALK;
+							if (_game->_pitPos.x >= 230)
+								PLOTPIT();
+							else {
+								if (idx == 0) {
+									idx = 48;
+									_game->_pitPos.y = 127;
+								}
+								idx -= 6;
+								_game->_pitPos.x -= buf[(idx / 2) + 1];
+								_game->_pitPos.y -= buf[(idx / 2) + 2];
+								_game->_pitCel = idx;
+								PLOTPIT();
+							}
+						}
+					} else {
+						PLOTPIT();
+					}
+				}
+			}
+		}
+	}
+}
+
 void AmazonScripts::boatWalls(int param1, int param2) {
 	if (param1 == 1)
 		_vm->_room->_plotter._walls[42] = Common::Rect(96, 27, 87, 42);
@@ -845,7 +1096,7 @@ void AmazonScripts::executeSpecial(int commandIndex, int param1, int param2) {
 		warning("TODO RIVER");
 		break;
 	case 14:
-		warning("TODO ANT");
+		ANT();
 		break;
 	case 15:
 		boatWalls(param1, param2);
diff --git a/engines/access/amazon/amazon_scripts.h b/engines/access/amazon/amazon_scripts.h
index 06ed6e5..9733c1c 100644
--- a/engines/access/amazon/amazon_scripts.h
+++ b/engines/access/amazon/amazon_scripts.h
@@ -75,6 +75,8 @@ protected:
 	void guardSee();
 	void setGuardFrame();
 	void guard();
+	void PLOTPIT();
+	void ANT();
 	void loadBackground(int param1, int param2);
 	void plotInactive();
 	void setInactive();


Commit: b874ddd31573ee491fd0780e81810913c7a9ff2c
    https://github.com/scummvm/scummvm/commit/b874ddd31573ee491fd0780e81810913c7a9ff2c
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-12T22:30:59-05:00

Commit Message:
ACCESS: Refactor ANT

Changed paths:
    engines/access/amazon/amazon_scripts.cpp
    engines/access/amazon/amazon_scripts.h



diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp
index 0074a5d..8553bab 100644
--- a/engines/access/amazon/amazon_scripts.cpp
+++ b/engines/access/amazon/amazon_scripts.cpp
@@ -768,10 +768,89 @@ void AmazonScripts::setInactive() {
 	mWhile(_game->_rawInactiveY);
 }
 
-void AmazonScripts::PLOTPIT() {
+void AmazonScripts::PLOTPIT(int idx, const int *buf) {
 	warning("TODO: PLOTPIT");
 }
 
+int AmazonScripts::antHandleRight(int indx, const int *buf) {
+	int retval = indx;
+	if (_game->_pitDirection == NONE) {
+		_game->_pitDirection = UP;
+		_game->_pitPos.y = 127;
+	}
+	retval = _game->_pitCel;
+	buf = Amazon::PITWALK;
+	if (_game->_pitPos.x < 230) {
+		if (retval == 0) {
+			retval = 48;
+			_game->_pitPos.y = 127;
+		}
+		retval -= 6;
+		_game->_pitPos.x -= buf[(retval / 2) + 1];
+		_game->_pitPos.y -= buf[(retval / 2) + 2];
+		_game->_pitCel = retval;
+	}
+	return retval;
+}
+
+int AmazonScripts::antHandleLeft(int indx, const int *buf) {
+	int retval = indx;
+	if (_game->_pitDirection == UP) {
+		_game->_pitDirection = NONE;
+		_game->_pitPos.y = 127;
+	}
+	retval = _game->_pitCel;
+	buf = Amazon::PITWALK;
+	retval += 6;
+	if (buf[retval / 2] == -1) {
+		retval = 0;
+		_game->_pitPos.y = 127;
+	}
+	_game->_pitPos.x += buf[(retval / 2) + 1];
+	_game->_pitPos.y += buf[(retval / 2) + 2];
+	_game->_pitCel = retval;
+
+	return retval;
+}
+
+int AmazonScripts::antHandleStab(int indx, const int *buf) {
+	int retval = indx;
+	if (_vm->_inventory->_inv[78]._value != 1) {
+		if (_game->_stabFl) {
+			buf = Amazon::PITSTAB;
+			retval = _game->_stabCel;
+			if (_game->_timers[13]._flag == 0) {
+				_game->_timers[13]._flag = 1;
+				retval += 6;
+				if (Amazon::PITSTAB[retval] == -1) {
+					_game->_stabFl = false;
+					_game->_pitCel = 0;
+					_game->_pitPos.y = 127;
+					retval = 0;
+					buf = Amazon::PITWALK;
+				} else {
+					_game->_pitPos.x += buf[(retval / 2) + 1];
+					_game->_pitPos.y += buf[(retval / 2) + 2];
+					_game->_pitCel = retval;
+				}
+			}
+		} else {
+			_game->_stabFl = true;
+			_game->_pitCel = 0;
+			retval = 0;
+			_game->_stabCel = 0;
+			int dist = _game->_pitPos.x - _game->_antPos.x;
+			if (_game->_antEatFl && !_game->_antDieFl && (dist <= 80)) {
+				_game->_antDieFl = true;
+				_game->_antCel = 0;
+				_game->_antPos.y = 123;
+				_vm->_sound->playSound(1);
+			}
+		}
+	}
+	return retval;
+}
+
 void AmazonScripts::ANT() {
 	_game->_antDirection = NONE;
 	if (_game->_aniFlag != 1) {
@@ -856,166 +935,38 @@ void AmazonScripts::ANT() {
 	if (_game->_flags[196] != 1) {
 		idx = _game->_pitCel;
 		if (_game->_stabFl == 1) {
-			if (_vm->_inventory->_inv[78]._value == 1) {
-				PLOTPIT();
-			} else {
-				buf = Amazon::PITSTAB;
-				idx = _game->_stabCel;
-				if (_game->_timers[13]._flag == 0) {
-					PLOTPIT();
-				} else {
-					_game->_timers[13]._flag = 1;
-					idx += 6;
-					if (Amazon::PITSTAB[idx] == -1) {
-						_game->_stabFl = false;
-						_game->_pitCel = 0;
-						_game->_pitPos.y = 127;
-						idx = 0;
-						buf = Amazon::PITWALK;
-						PLOTPIT();
-					} else {
-						_game->_pitPos.x += buf[(idx / 2) + 1];
-						_game->_pitPos.y += buf[(idx / 2) + 2];
-						_game->_pitCel = idx;
-						PLOTPIT();
-					}
-				}
-			}
+			idx = antHandleStab(idx, buf);
 		} else {
 			buf = Amazon::PITWALK;
-			if (_game->_timers[13]._flag != 0) {
-				PLOTPIT();
-			} else {
+			if (_game->_timers[13]._flag == 0) {
 				_game->_timers[13]._flag = 1;
 				_vm->_events->pollEvents();
 				if (_vm->_events->_leftButton) {
 					Common::Point pt = _vm->_events->calcRawMouse();
-					if (pt.x < _game->_pitPos.x) {
-						if (_game->_pitDirection == UP) {
-							_game->_pitDirection = NONE;
-							_game->_pitPos.y = 127;
-						}
-						idx = _game->_pitCel;
-						buf = Amazon::PITWALK;
-						idx += 6;
-						if (buf[idx / 2] == -1) {
-							idx = 0;
-							_game->_pitPos.y = 127;
-						}
-						_game->_pitPos.x += buf[(idx / 2) + 1];
-						_game->_pitPos.y += buf[(idx / 2) + 2];
-						_game->_pitCel = idx;
-						PLOTPIT();
-					} else if (pt.x > _game->_pitPos.x) {
-						if (_game->_pitDirection == NONE) {
-							_game->_pitDirection = UP;
-							_game->_pitPos.y = 127;
-							idx = _game->_pitCel;
-							buf = Amazon::PITWALK;
-							if (_game->_pitPos.x >= 230)
-								PLOTPIT();
-							else {
-								if (idx == 0) {
-									idx = 48;
-									_game->_pitPos.y = 127;
-								}
-								idx -= 6;
-								_game->_pitPos.x -= buf[(idx / 2) + 1];
-								_game->_pitPos.y -= buf[(idx / 2) + 2];
-								_game->_pitCel = idx;
-								PLOTPIT();
-							}
-						}
-					} else {
-						PLOTPIT();
-					}
+					if (pt.x < _game->_pitPos.x)
+						idx = antHandleLeft(idx, buf);
+					else if (pt.x > _game->_pitPos.x)
+						idx = antHandleRight(idx, buf);
 				} else {
 					buf = Amazon::PITWALK;
-					if (_vm->_player->_playerDirection == UP) {
-						if (_vm->_inventory->_inv[78]._value == 1) {
-							PLOTPIT();
-						} else {
-							if (_game->_stabFl) {
-								buf = Amazon::PITSTAB;
-								idx = _game->_stabCel;
-								if (_game->_timers[13]._flag == 0) {
-									PLOTPIT();
-								} else {
-									_game->_timers[13]._flag = 1;
-									idx += 6;
-									if (Amazon::PITSTAB[idx] == -1) {
-										_game->_stabFl = false;
-										_game->_pitCel = 0;
-										_game->_pitPos.y = 127;
-										idx = 0;
-										buf = Amazon::PITWALK;
-										PLOTPIT();
-									} else {
-										_game->_pitPos.x += buf[(idx / 2) + 1];
-										_game->_pitPos.y += buf[(idx / 2) + 2];
-										_game->_pitCel = idx;
-										PLOTPIT();
-									}
-								}
-							} else {
-								_game->_stabFl = true;
-								_game->_pitCel = 0;
-								idx = 0;
-								_game->_stabCel = 0;
-								int dist = _game->_pitPos.x - _game->_antPos.x;
-								if (!_game->_antEatFl || _game->_antDieFl || (dist > 80))
-									PLOTPIT();
-								else {
-									_game->_antDieFl = true;
-									_game->_antCel = 0;
-									_game->_antPos.y = 123;
-									_vm->_sound->playSound(1);
-									PLOTPIT();
-								}
-							}
-						}
-					} else if (_vm->_player->_playerDirection == LEFT) {
-						if (_game->_pitDirection == UP) {
-							_game->_pitDirection = NONE;
-							_game->_pitPos.y = 127;
-						}
-						idx = _game->_pitCel;
-						buf = Amazon::PITWALK;
-						idx += 6;
-						if (buf[idx / 2] == -1) {
-							idx = 0;
-							_game->_pitPos.y = 127;
-						}
-						_game->_pitPos.x += buf[(idx / 2) + 1];
-						_game->_pitPos.y += buf[(idx / 2) + 2];
-						_game->_pitCel = idx;
-						PLOTPIT();
-					} else if (_vm->_player->_playerDirection == RIGHT) {
-						if (_game->_pitDirection == NONE) {
-							_game->_pitDirection = UP;
-							_game->_pitPos.y = 127;
-							idx = _game->_pitCel;
-							buf = Amazon::PITWALK;
-							if (_game->_pitPos.x >= 230)
-								PLOTPIT();
-							else {
-								if (idx == 0) {
-									idx = 48;
-									_game->_pitPos.y = 127;
-								}
-								idx -= 6;
-								_game->_pitPos.x -= buf[(idx / 2) + 1];
-								_game->_pitPos.y -= buf[(idx / 2) + 2];
-								_game->_pitCel = idx;
-								PLOTPIT();
-							}
-						}
-					} else {
-						PLOTPIT();
-					}
+					if (_vm->_player->_playerDirection == UP)
+						idx = antHandleStab(idx, buf);
+					else if (_vm->_player->_playerDirection == LEFT)
+						idx = antHandleLeft(idx, buf);
+					else if (_vm->_player->_playerDirection == RIGHT)
+						idx = antHandleRight(idx, buf);
 				}
 			}
 		}
+		PLOTPIT(idx, buf);
+	}
+
+	if (!_game->_antDieFl) {
+		int dist = _game->_pitPos.x - _game->_antPos.x;
+		if ((_game->_antEatFl && (dist <= 45)) || (!_game->_antEatFl && (dist <= 80))) {
+			_game->_flags[199] = 1;
+			_game->_aniFlag = 0;
+		}
 	}
 }
 
diff --git a/engines/access/amazon/amazon_scripts.h b/engines/access/amazon/amazon_scripts.h
index 9733c1c..fc6fb0a 100644
--- a/engines/access/amazon/amazon_scripts.h
+++ b/engines/access/amazon/amazon_scripts.h
@@ -75,7 +75,10 @@ protected:
 	void guardSee();
 	void setGuardFrame();
 	void guard();
-	void PLOTPIT();
+	void PLOTPIT(int idx, const int *buf);
+	int antHandleRight(int indx, const int *buf);
+	int antHandleLeft(int indx, const int *buf);
+	int antHandleStab(int indx, const int *buf);
 	void ANT();
 	void loadBackground(int param1, int param2);
 	void plotInactive();


Commit: c3660acf63e684bdb90efd4cb7fb1fedd3ed1ea0
    https://github.com/scummvm/scummvm/commit/c3660acf63e684bdb90efd4cb7fb1fedd3ed1ea0
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-12T22:31:19-05:00

Commit Message:
ACCESS: Implement plotPit()

Changed paths:
    engines/access/amazon/amazon_scripts.cpp
    engines/access/amazon/amazon_scripts.h



diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp
index 8553bab..d0b4d7a 100644
--- a/engines/access/amazon/amazon_scripts.cpp
+++ b/engines/access/amazon/amazon_scripts.cpp
@@ -768,8 +768,43 @@ void AmazonScripts::setInactive() {
 	mWhile(_game->_rawInactiveY);
 }
 
-void AmazonScripts::PLOTPIT(int idx, const int *buf) {
-	warning("TODO: PLOTPIT");
+void AmazonScripts::plotTorchSpear(int indx, const int *buf) {
+	int idx = indx;
+
+	ImageEntry ie;
+	ie._flags = 8;
+	ie._spritesPtr = _pObject[62];
+	ie._frameNumber = buf[(idx / 2)];
+	ie._position = Common::Point(_game->_pitPos.x + buf[(idx / 2) + 1], _game->_pitPos.y + buf[(idx / 2) + 2]);
+	ie._offsetY = 255;
+	_vm->_images.addToList(ie);
+}
+
+void AmazonScripts::plotPit(int indx, const int *buf) {
+	int idx = indx;
+	ImageEntry ie;
+	ie._flags = 8;
+	ie._spritesPtr = _pObject[62];
+	ie._frameNumber = buf[(idx / 2)];
+	ie._position = Common::Point(_game->_pitPos.x, _game->_pitPos.y);
+	ie._offsetY = _game->_pitPos.y;
+	_vm->_images.addToList(ie);
+
+	_vm->_player->_rawPlayer = _game->_pitPos;
+	if (_vm->_inventory->_inv[76]._value == 1) {
+		idx = _game->_torchCel;
+		buf = Amazon::TORCH;
+		_vm->_timers[14]._flag = 1;
+		idx += 6;
+		if (buf[idx / 2] == -1)
+			idx = 0;
+		_game->_torchCel = idx;
+		plotTorchSpear(idx, buf);
+	} else if (!_game->_stabFl && (_vm->_inventory->_inv[78]._value == 1)) {
+		idx = 0;
+		buf = Amazon::SPEAR;
+		plotTorchSpear(idx, buf);
+	}
 }
 
 int AmazonScripts::antHandleRight(int indx, const int *buf) {
@@ -958,7 +993,7 @@ void AmazonScripts::ANT() {
 				}
 			}
 		}
-		PLOTPIT(idx, buf);
+		plotPit(idx, buf);
 	}
 
 	if (!_game->_antDieFl) {
diff --git a/engines/access/amazon/amazon_scripts.h b/engines/access/amazon/amazon_scripts.h
index fc6fb0a..7e42c0c 100644
--- a/engines/access/amazon/amazon_scripts.h
+++ b/engines/access/amazon/amazon_scripts.h
@@ -75,7 +75,8 @@ protected:
 	void guardSee();
 	void setGuardFrame();
 	void guard();
-	void PLOTPIT(int idx, const int *buf);
+	void plotTorchSpear(int indx, const int *buf);
+	void plotPit(int indx, const int *buf);
 	int antHandleRight(int indx, const int *buf);
 	int antHandleLeft(int indx, const int *buf);
 	int antHandleStab(int indx, const int *buf);


Commit: 15da1cc639faf09984b1a228a25ad829b98cd331
    https://github.com/scummvm/scummvm/commit/15da1cc639faf09984b1a228a25ad829b98cd331
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-12T22:31:30-05:00

Commit Message:
ACCESS: Fix some parameters in ANT

Changed paths:
    engines/access/amazon/amazon_scripts.cpp
    engines/access/amazon/amazon_scripts.h



diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp
index d0b4d7a..0642119 100644
--- a/engines/access/amazon/amazon_scripts.cpp
+++ b/engines/access/amazon/amazon_scripts.cpp
@@ -768,7 +768,7 @@ void AmazonScripts::setInactive() {
 	mWhile(_game->_rawInactiveY);
 }
 
-void AmazonScripts::plotTorchSpear(int indx, const int *buf) {
+void AmazonScripts::plotTorchSpear(int indx, const int *&buf) {
 	int idx = indx;
 
 	ImageEntry ie;
@@ -780,7 +780,7 @@ void AmazonScripts::plotTorchSpear(int indx, const int *buf) {
 	_vm->_images.addToList(ie);
 }
 
-void AmazonScripts::plotPit(int indx, const int *buf) {
+void AmazonScripts::plotPit(int indx, const int *&buf) {
 	int idx = indx;
 	ImageEntry ie;
 	ie._flags = 8;
@@ -807,7 +807,7 @@ void AmazonScripts::plotPit(int indx, const int *buf) {
 	}
 }
 
-int AmazonScripts::antHandleRight(int indx, const int *buf) {
+int AmazonScripts::antHandleRight(int indx, const int *&buf) {
 	int retval = indx;
 	if (_game->_pitDirection == NONE) {
 		_game->_pitDirection = UP;
@@ -828,7 +828,7 @@ int AmazonScripts::antHandleRight(int indx, const int *buf) {
 	return retval;
 }
 
-int AmazonScripts::antHandleLeft(int indx, const int *buf) {
+int AmazonScripts::antHandleLeft(int indx, const int *&buf) {
 	int retval = indx;
 	if (_game->_pitDirection == UP) {
 		_game->_pitDirection = NONE;
@@ -848,7 +848,7 @@ int AmazonScripts::antHandleLeft(int indx, const int *buf) {
 	return retval;
 }
 
-int AmazonScripts::antHandleStab(int indx, const int *buf) {
+int AmazonScripts::antHandleStab(int indx, const int *&buf) {
 	int retval = indx;
 	if (_vm->_inventory->_inv[78]._value != 1) {
 		if (_game->_stabFl) {
diff --git a/engines/access/amazon/amazon_scripts.h b/engines/access/amazon/amazon_scripts.h
index 7e42c0c..9d74115 100644
--- a/engines/access/amazon/amazon_scripts.h
+++ b/engines/access/amazon/amazon_scripts.h
@@ -75,11 +75,11 @@ protected:
 	void guardSee();
 	void setGuardFrame();
 	void guard();
-	void plotTorchSpear(int indx, const int *buf);
-	void plotPit(int indx, const int *buf);
-	int antHandleRight(int indx, const int *buf);
-	int antHandleLeft(int indx, const int *buf);
-	int antHandleStab(int indx, const int *buf);
+	void plotTorchSpear(int indx, const int *&buf);
+	void plotPit(int indx, const int *&buf);
+	int antHandleRight(int indx, const int *&buf);
+	int antHandleLeft(int indx, const int *&buf);
+	int antHandleStab(int indx, const int *&buf);
 	void ANT();
 	void loadBackground(int param1, int param2);
 	void plotInactive();


Commit: ba8f4941b5ed387999ec1f30c90e237b048e9d76
    https://github.com/scummvm/scummvm/commit/ba8f4941b5ed387999ec1f30c90e237b048e9d76
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-12T22:31:41-05:00

Commit Message:
ACCESS: Add missing code in guard()

Changed paths:
    engines/access/amazon/amazon_scripts.cpp



diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp
index 0642119..e2fea04 100644
--- a/engines/access/amazon/amazon_scripts.cpp
+++ b/engines/access/amazon/amazon_scripts.cpp
@@ -731,7 +731,8 @@ void AmazonScripts::guard() {
 		if (_game->_guard._position.y <= 89) {
 			_game->_guard._position.y = 89;
 			_game->_guardLocation = 4;
-			warning("CHECME: unused flag121");
+			if (_game->_flags[121] == 1)
+				_game->_guardLocation = 5;
 		}
 		break;
 	default:


Commit: 37431dcedfddbac02b450affa9346d6c2581e673
    https://github.com/scummvm/scummvm/commit/37431dcedfddbac02b450affa9346d6c2581e673
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-12T22:31:52-05:00

Commit Message:
ACCESS: Implement guardSee and setGuardFrame

Changed paths:
    engines/access/amazon/amazon_scripts.cpp
    engines/access/amazon/amazon_scripts.h



diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp
index e2fea04..faf2ede 100644
--- a/engines/access/amazon/amazon_scripts.cpp
+++ b/engines/access/amazon/amazon_scripts.cpp
@@ -683,12 +683,56 @@ void AmazonScripts::mWhile(int param1) {
 	}
 }
 
+void AmazonScripts::CHKVLINE() {
+	warning("TODO: CHKVLINE()");
+}
+
+void AmazonScripts::CHKHLINE() {
+	warning("TODO: CHKHLINE()");
+}
+
 void AmazonScripts::guardSee() {
-	warning("TODO: guardSee()");
+	int tmpY = (_vm->_screen->_scrollRow << 4) + _vm->_screen->_scrollY;
+	_game->_flags[140] = 0;
+	if (tmpY > _game->_guard._position.y)
+		return;
+
+	tmpY += _vm->_screen->_vWindowLinesTall;
+	tmpY -= 11;
+
+	if (tmpY < _game->_guard._position.y)
+		return;
+
+	_game->_guardFind = 1;
+	_game->_flags[140] = 1;
+
+	for (uint16 idx = 0; idx < _vm->_room->_plotter._walls.size(); idx++) {
+		_vm->_screen->_orgX1 = _vm->_room->_plotter._walls[idx].left;
+		_vm->_screen->_orgY1 = _vm->_room->_plotter._walls[idx].top;
+		_vm->_screen->_orgX2 = _vm->_room->_plotter._walls[idx].right;
+		_vm->_screen->_orgY2 = _vm->_room->_plotter._walls[idx].bottom;
+		if (_vm->_screen->_orgX1 == _vm->_screen->_orgX2) {
+			CHKVLINE();
+			if (_game->_guardFind == 0)
+				return;
+		} else if (_vm->_screen->_orgY1 == _vm->_screen->_orgY2) {
+			CHKHLINE();
+			if (_game->_guardFind == 0)
+				return;
+		}
+	}
 }
 
 void AmazonScripts::setGuardFrame() {
-	warning("TODO: setGuardFrame()");
+	ImageEntry ie;
+	ie._flags = 8;
+	if (_game->_guardLocation == 4)
+		ie._flags |= 2;
+	ie._spritesPtr = _vm->_objectsTable[37];
+	ie._frameNumber = _game->_guard._guardCel;
+	ie._position = _game->_guard._position;
+	ie._offsetY = 10;
+	_vm->_images.addToList(ie);
 }
 
 void AmazonScripts::guard() {
diff --git a/engines/access/amazon/amazon_scripts.h b/engines/access/amazon/amazon_scripts.h
index 9d74115..9d5e4d8 100644
--- a/engines/access/amazon/amazon_scripts.h
+++ b/engines/access/amazon/amazon_scripts.h
@@ -72,6 +72,8 @@ protected:
 	void mWhileJWalk();
 	void mWhileDoOpen();
 	void mWhile(int param1);
+	void CHKVLINE();
+	void CHKHLINE();
 	void guardSee();
 	void setGuardFrame();
 	void guard();


Commit: c74821161b05f27fa4f37afd1f549260fc4d6c90
    https://github.com/scummvm/scummvm/commit/c74821161b05f27fa4f37afd1f549260fc4d6c90
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-12T22:32:02-05:00

Commit Message:
ACCESS: Fix some issues in plotTorchSpear(), in plotPit() and in ANT()

Changed paths:
    engines/access/amazon/amazon_scripts.cpp



diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp
index faf2ede..f75d12f 100644
--- a/engines/access/amazon/amazon_scripts.cpp
+++ b/engines/access/amazon/amazon_scripts.cpp
@@ -818,7 +818,7 @@ void AmazonScripts::plotTorchSpear(int indx, const int *&buf) {
 
 	ImageEntry ie;
 	ie._flags = 8;
-	ie._spritesPtr = _pObject[62];
+	ie._spritesPtr = _vm->_objectsTable[62];
 	ie._frameNumber = buf[(idx / 2)];
 	ie._position = Common::Point(_game->_pitPos.x + buf[(idx / 2) + 1], _game->_pitPos.y + buf[(idx / 2) + 2]);
 	ie._offsetY = 255;
@@ -829,7 +829,7 @@ void AmazonScripts::plotPit(int indx, const int *&buf) {
 	int idx = indx;
 	ImageEntry ie;
 	ie._flags = 8;
-	ie._spritesPtr = _pObject[62];
+	ie._spritesPtr = _vm->_objectsTable[62];
 	ie._frameNumber = buf[(idx / 2)];
 	ie._position = Common::Point(_game->_pitPos.x, _game->_pitPos.y);
 	ie._offsetY = _game->_pitPos.y;
@@ -1005,7 +1005,7 @@ void AmazonScripts::ANT() {
 
 	ImageEntry ie;
 	ie._flags = 8;
-	ie._spritesPtr = _pObject[61];
+	ie._spritesPtr = _vm->_objectsTable[61];
 	ie._frameNumber = buf[(idx / 2)];
 	ie._position = Common::Point(_game->_antPos.x, _game->_antPos.y);
 	ie._offsetY = _game->_antPos.y - 70;


Commit: 4ca5cc5ab4409601ed7458d08bf08c79c96dc8f7
    https://github.com/scummvm/scummvm/commit/4ca5cc5ab4409601ed7458d08bf08c79c96dc8f7
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-12T22:32:14-05:00

Commit Message:
ACCESS: Implement chkVLine and chkHLine

Changed paths:
    engines/access/amazon/amazon_scripts.cpp
    engines/access/amazon/amazon_scripts.h



diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp
index f75d12f..4d08047 100644
--- a/engines/access/amazon/amazon_scripts.cpp
+++ b/engines/access/amazon/amazon_scripts.cpp
@@ -683,12 +683,94 @@ void AmazonScripts::mWhile(int param1) {
 	}
 }
 
-void AmazonScripts::CHKVLINE() {
-	warning("TODO: CHKVLINE()");
+void AmazonScripts::VCODE(Common::Rect bounds) {
+	warning("TODO: VCODE()");
 }
 
-void AmazonScripts::CHKHLINE() {
-	warning("TODO: CHKHLINE()");
+void AmazonScripts::HCODE(Common::Rect bounds) {
+	warning("TODO: HCODE()");
+}
+
+void AmazonScripts::chkVLine() {
+	if (_game->_guard._position.x > _vm->_player->_rawPlayer.x)
+		_game->_guard._bounds = Common::Rect(_vm->_player->_rawPlayer.x, _vm->_player->_rawPlayer.y, _game->_guard._position.x, _game->_guard._position.y);
+	else
+		_game->_guard._bounds = Common::Rect(_game->_guard._position.x, _game->_guard._position.y, _vm->_player->_rawPlayer.x, _vm->_player->_rawPlayer.y);
+
+	if (_vm->_screen->_orgY1 > _vm->_screen->_orgY2)
+		SWAP(_vm->_screen->_orgY1, _vm->_screen->_orgY2);
+
+	while (true) {
+		VCODE(_game->_guard._bounds);
+		int code = _game->_guard._gCode1 | _game->_guard._gCode2;
+		if (code == 10) {
+			_game->_guardFind = 0;
+			return;
+		}
+
+		int code2 = _game->_guard._gCode1 & _game->_guard._gCode2;
+		code2 &= 5;
+		if (((code & 10) == 8) || ((code & 10) == 2) || (code2 != 0))
+			return;
+
+		int midX = (_game->_guard._bounds.left + _game->_guard._bounds.right) / 2;
+		int midY = (_game->_guard._bounds.top + _game->_guard._bounds.bottom) / 2;
+
+		if (midX < _vm->_screen->_orgX1) {
+			if ((midX == _game->_guard._bounds.left) && (midY == _game->_guard._bounds.top))
+				return;
+
+			_game->_guard._bounds.left = midX;
+			_game->_guard._bounds.top = midY;
+		} else {
+			if ((midX == _game->_guard._bounds.right) && (midY == _game->_guard._bounds.bottom))
+				return;
+
+			_game->_guard._bounds.right = midX;
+			_game->_guard._bounds.bottom = midY;
+		}
+	}
+}
+
+void AmazonScripts::chkHLine() {
+	if (_game->_guard._position.y > _vm->_player->_rawPlayer.y)
+		_game->_guard._bounds = Common::Rect(_vm->_player->_rawPlayer.x, _vm->_player->_rawPlayer.y, _game->_guard._position.x, _game->_guard._position.y);
+	else
+		_game->_guard._bounds = Common::Rect(_game->_guard._position.x, _game->_guard._position.y, _vm->_player->_rawPlayer.x, _vm->_player->_rawPlayer.y);
+
+	if (_vm->_screen->_orgX1 > _vm->_screen->_orgX2)
+		SWAP(_vm->_screen->_orgX1, _vm->_screen->_orgX2);
+
+	while (true) {
+		HCODE(_game->_guard._bounds);
+		int code = _game->_guard._gCode1 | _game->_guard._gCode2;
+		if (code == 5) {
+			_game->_guardFind = 0;
+			return;
+		}
+
+		int code2 = _game->_guard._gCode1 & _game->_guard._gCode2;
+		code2 &= 10;
+		if (((code & 5) == 4) || ((code & 5) == 1) || (code2 != 0))
+			return;
+
+		int midX = (_game->_guard._bounds.left + _game->_guard._bounds.right) / 2;
+		int midY = (_game->_guard._bounds.top + _game->_guard._bounds.bottom) / 2;
+
+		if (midY < _vm->_screen->_orgY1) {
+			if ((midX == _game->_guard._bounds.left) && (midY == _game->_guard._bounds.top))
+				return;
+
+			_game->_guard._bounds.left = midX;
+			_game->_guard._bounds.top = midY;
+		} else {
+			if ((midX == _game->_guard._bounds.right) && (midY == _game->_guard._bounds.bottom))
+				return;
+
+			_game->_guard._bounds.right = midX;
+			_game->_guard._bounds.bottom = midY;
+		}
+	}
 }
 
 void AmazonScripts::guardSee() {
@@ -712,11 +794,11 @@ void AmazonScripts::guardSee() {
 		_vm->_screen->_orgX2 = _vm->_room->_plotter._walls[idx].right;
 		_vm->_screen->_orgY2 = _vm->_room->_plotter._walls[idx].bottom;
 		if (_vm->_screen->_orgX1 == _vm->_screen->_orgX2) {
-			CHKVLINE();
+			chkVLine();
 			if (_game->_guardFind == 0)
 				return;
 		} else if (_vm->_screen->_orgY1 == _vm->_screen->_orgY2) {
-			CHKHLINE();
+			chkHLine();
 			if (_game->_guardFind == 0)
 				return;
 		}
diff --git a/engines/access/amazon/amazon_scripts.h b/engines/access/amazon/amazon_scripts.h
index 9d5e4d8..c4e4869 100644
--- a/engines/access/amazon/amazon_scripts.h
+++ b/engines/access/amazon/amazon_scripts.h
@@ -72,8 +72,10 @@ protected:
 	void mWhileJWalk();
 	void mWhileDoOpen();
 	void mWhile(int param1);
-	void CHKVLINE();
-	void CHKHLINE();
+	void VCODE(Common::Rect bounds);
+	void HCODE(Common::Rect bounds);
+	void chkVLine();
+	void chkHLine();
 	void guardSee();
 	void setGuardFrame();
 	void guard();


Commit: c4a5c36290e59d47272cb47244f294696cc6c5c1
    https://github.com/scummvm/scummvm/commit/c4a5c36290e59d47272cb47244f294696cc6c5c1
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-12T22:32:24-05:00

Commit Message:
ACCESS: Fix crash when talking to pilot on the plane

Changed paths:
    engines/access/debugger.cpp
    engines/access/scripts.cpp
    engines/access/scripts.h



diff --git a/engines/access/debugger.cpp b/engines/access/debugger.cpp
index 9a82168..359b2e7 100644
--- a/engines/access/debugger.cpp
+++ b/engines/access/debugger.cpp
@@ -137,7 +137,7 @@ bool AmazonDebugger::Cmd_StartChapter(int argc, const char **argv) {
 	chapterScript[2] = ROOM_SCRIPT / 256;
 	chapterScript[3] = 0x80 + 75;			// cmdChapter
 	chapterScript[4] = strToInt(argv[1]);	// chapter number
-	_vm->_scripts->setScript(new Resource(chapterScript, 5));
+	_vm->_scripts->setScript(new Resource(chapterScript, 5), true);
 
 	return false;
 }
diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp
index 34d5372..9f91948 100644
--- a/engines/access/scripts.cpp
+++ b/engines/access/scripts.cpp
@@ -43,10 +43,10 @@ Scripts::~Scripts() {
 	freeScriptData();
 }
 
-void Scripts::setScript(Resource *res) {
+void Scripts::setScript(Resource *res, bool restartFlag) {
 	_resource = res;
 	_data = res->_stream;
-	_endFlag = true;
+	_endFlag = restartFlag;
 }
 
 void Scripts::freeScriptData() {
diff --git a/engines/access/scripts.h b/engines/access/scripts.h
index 9860c7c..eaac996 100644
--- a/engines/access/scripts.h
+++ b/engines/access/scripts.h
@@ -135,7 +135,7 @@ public:
 
 	virtual ~Scripts();
 
-	void setScript(Resource *data);
+	void setScript(Resource *data, bool restartFlag = false);
 
 	void freeScriptData();
 


Commit: 2daa96e2840fd608f8968226ae44715ccf26c977
    https://github.com/scummvm/scummvm/commit/2daa96e2840fd608f8968226ae44715ccf26c977
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-12T22:32:36-05:00

Commit Message:
ACCESS: Fix crash in conversation screen when clicking outside response boxes

Changed paths:
    engines/access/events.cpp



diff --git a/engines/access/events.cpp b/engines/access/events.cpp
index 0287e8c..b05aea3 100644
--- a/engines/access/events.cpp
+++ b/engines/access/events.cpp
@@ -254,7 +254,7 @@ Common::Point EventsManager::calcRawMouse() {
 
 int EventsManager::checkMouseBox1(Common::Array<Common::Rect> &rects) {
 	int i = 0;
-	for (i = 0;; i++) {
+	for (i = 0; i < rects.size(); ++i) {
 		if (rects[i].left == -1)
 			return -1;
 
@@ -262,6 +262,8 @@ int EventsManager::checkMouseBox1(Common::Array<Common::Rect> &rects) {
 			&& (_mousePos.y > rects[i].top) && (_mousePos.y < rects[i].bottom))
 			return i;
 	}
+
+	return -1;
 }
 
 bool EventsManager::isKeyMousePressed() {


Commit: 96cc1e3ac9270ca2ce60aedcbae3cca8c7410c1a
    https://github.com/scummvm/scummvm/commit/96cc1e3ac9270ca2ce60aedcbae3cca8c7410c1a
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-12T22:32:46-05:00

Commit Message:
ACCESS: Implement setVerticalCode and setHorizontalCode used by the guard scene

Changed paths:
    engines/access/amazon/amazon_scripts.cpp
    engines/access/amazon/amazon_scripts.h



diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp
index 4d08047..ae7e047 100644
--- a/engines/access/amazon/amazon_scripts.cpp
+++ b/engines/access/amazon/amazon_scripts.cpp
@@ -683,12 +683,65 @@ void AmazonScripts::mWhile(int param1) {
 	}
 }
 
-void AmazonScripts::VCODE(Common::Rect bounds) {
-	warning("TODO: VCODE()");
+void AmazonScripts::setVerticalCode(Common::Rect bounds) {
+	_game->_guard._gCode1 = 0;
+	_game->_guard._gCode2 = 0;
+	if (bounds.left < _vm->_screen->_orgX1)
+		_game->_guard._gCode1 |= 8;
+	else if (bounds.left == _vm->_screen->_orgX1) {
+		_game->_guard._gCode1 |= 8;
+		_game->_guard._gCode1 |= 2;
+	} else
+		_game->_guard._gCode1 |= 2;
+
+	if (bounds.right < _vm->_screen->_orgX1)
+		_game->_guard._gCode2 |= 8;
+	else if (bounds.right == _vm->_screen->_orgX1) {
+		_game->_guard._gCode2 |= 8;
+		_game->_guard._gCode2 |= 2;
+	} else
+		_game->_guard._gCode2 |= 2;
+
+	if (bounds.top < _vm->_screen->_orgY1)
+		_game->_guard._gCode1 |= 4;
+	else if (bounds.top > _vm->_screen->_orgY2)
+		_game->_guard._gCode1 |= 1;
+
+	if (bounds.bottom < _vm->_screen->_orgY1)
+		_game->_guard._gCode2 |= 4;
+	else if (bounds.bottom > _vm->_screen->_orgY2)
+		_game->_guard._gCode2 |= 1;
 }
 
-void AmazonScripts::HCODE(Common::Rect bounds) {
-	warning("TODO: HCODE()");
+void AmazonScripts::setHorizontalCode(Common::Rect bounds) {
+	_game->_guard._gCode1 = 0;
+	_game->_guard._gCode2 = 0;
+
+	if (bounds.top < _vm->_screen->_orgY1)
+		_game->_guard._gCode1 |= 4;
+	else if (bounds.left == _vm->_screen->_orgX1) {
+		_game->_guard._gCode1 |= 4;
+		_game->_guard._gCode1 |= 1;
+	} else
+		_game->_guard._gCode1 |= 1;
+
+	if (bounds.bottom < _vm->_screen->_orgY1)
+		_game->_guard._gCode2 |= 4;
+	else if (bounds.right == _vm->_screen->_orgX1) {
+		_game->_guard._gCode2 |= 4;
+		_game->_guard._gCode2 |= 1;
+	} else
+		_game->_guard._gCode2 |= 1;
+
+	if (bounds.left < _vm->_screen->_orgX1)
+		_game->_guard._gCode1 |= 8;
+	else if (bounds.left > _vm->_screen->_orgX2)
+		_game->_guard._gCode1 |= 2;
+
+	if (bounds.right < _vm->_screen->_orgX1)
+		_game->_guard._gCode2 |= 8;
+	else if (bounds.bottom > _vm->_screen->_orgX2)
+		_game->_guard._gCode2 |= 2;
 }
 
 void AmazonScripts::chkVLine() {
@@ -701,7 +754,7 @@ void AmazonScripts::chkVLine() {
 		SWAP(_vm->_screen->_orgY1, _vm->_screen->_orgY2);
 
 	while (true) {
-		VCODE(_game->_guard._bounds);
+		setVerticalCode(_game->_guard._bounds);
 		int code = _game->_guard._gCode1 | _game->_guard._gCode2;
 		if (code == 10) {
 			_game->_guardFind = 0;
@@ -742,7 +795,7 @@ void AmazonScripts::chkHLine() {
 		SWAP(_vm->_screen->_orgX1, _vm->_screen->_orgX2);
 
 	while (true) {
-		HCODE(_game->_guard._bounds);
+		setHorizontalCode(_game->_guard._bounds);
 		int code = _game->_guard._gCode1 | _game->_guard._gCode2;
 		if (code == 5) {
 			_game->_guardFind = 0;
diff --git a/engines/access/amazon/amazon_scripts.h b/engines/access/amazon/amazon_scripts.h
index c4e4869..c7b72a6 100644
--- a/engines/access/amazon/amazon_scripts.h
+++ b/engines/access/amazon/amazon_scripts.h
@@ -72,8 +72,8 @@ protected:
 	void mWhileJWalk();
 	void mWhileDoOpen();
 	void mWhile(int param1);
-	void VCODE(Common::Rect bounds);
-	void HCODE(Common::Rect bounds);
+	void setVerticalCode(Common::Rect bounds);
+	void setHorizontalCode(Common::Rect bounds);
 	void chkVLine();
 	void chkHLine();
 	void guardSee();


Commit: bacb9badf859ebb4fa6c5b15f1cb46460f57ab5b
    https://github.com/scummvm/scummvm/commit/bacb9badf859ebb4fa6c5b15f1cb46460f57ab5b
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-12T22:32:56-05:00

Commit Message:
ACCESS: Fix compilation warning

Changed paths:
    engines/access/events.cpp



diff --git a/engines/access/events.cpp b/engines/access/events.cpp
index b05aea3..ac07a75 100644
--- a/engines/access/events.cpp
+++ b/engines/access/events.cpp
@@ -253,8 +253,7 @@ Common::Point EventsManager::calcRawMouse() {
 }
 
 int EventsManager::checkMouseBox1(Common::Array<Common::Rect> &rects) {
-	int i = 0;
-	for (i = 0; i < rects.size(); ++i) {
+	for (uint16 i = 0; i < rects.size(); ++i) {
 		if (rects[i].left == -1)
 			return -1;
 


Commit: 339847872b3d35cf6bec5b4d0360a2e0e815dbbd
    https://github.com/scummvm/scummvm/commit/339847872b3d35cf6bec5b4d0360a2e0e815dbbd
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-12T22:33:11-05:00

Commit Message:
ACCESS: Fix the call of doIntroduction

Changed paths:
    engines/access/amazon/amazon_game.cpp



diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp
index b1a8bbe..fc5a44f 100644
--- a/engines/access/amazon/amazon_game.cpp
+++ b/engines/access/amazon/amazon_game.cpp
@@ -79,11 +79,11 @@ AmazonEngine::~AmazonEngine() {
 }
 
 void AmazonEngine::playGame() {
-	// Initialise Amazon game-specific objects
+	// Initialize Amazon game-specific objects
 	_room = new AmazonRoom(this);
 	_scripts = new AmazonScripts(this);
 
-	if (_loadSaveSlot != -1) {
+	if (_loadSaveSlot == -1) {
 		// Do introduction
 		doIntroduction();
 		if (shouldQuit())
@@ -111,10 +111,11 @@ void AmazonEngine::doIntroduction() {
 	_events->setCursor(CURSOR_ARROW);
 	_events->showCursor();
 	_screen->setPanel(0);
+	_screen->setPalette();
 
-	//TODO: Implement the rest of the intro
-	return;
-
+	_events->setCursor(CURSOR_ARROW);
+	_events->showCursor();
+	_screen->setPanel(3);
 	doTitle();
 	if (shouldQuit())
 		return;
@@ -132,6 +133,7 @@ void AmazonEngine::doIntroduction() {
 		}
 	}
 
+	warning("TODO - More introduction code");
 	doTitle();
 }
 


Commit: 4e1394c8e34fd1163f2ef54b5cb66e6945110d96
    https://github.com/scummvm/scummvm/commit/4e1394c8e34fd1163f2ef54b5cb66e6945110d96
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-12T22:33:28-05:00

Commit Message:
ACCESS: Fix intro countdown, add splashscreen and loading of scene 0

Changed paths:
    engines/access/amazon/amazon_game.cpp
    engines/access/room.h



diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp
index fc5a44f..4c2662e 100644
--- a/engines/access/amazon/amazon_game.cpp
+++ b/engines/access/amazon/amazon_game.cpp
@@ -132,9 +132,6 @@ void AmazonEngine::doIntroduction() {
 				return;
 		}
 	}
-
-	warning("TODO - More introduction code");
-	doTitle();
 }
 
 void AmazonEngine::doTitle() {
@@ -170,19 +167,70 @@ void AmazonEngine::doTitle() {
 	_sound->playSound(1);
 
 	const int COUNTDOWN[6] = { 2, 0x80, 1, 0x7d, 0, 0x87 };
-	for (_pCount = 0; _pCount <= 3; ++_pCount) {
-		if (_pCount != 3) {
-			_buffer2.copyFrom(_buffer1);
-			int id = READ_LE_UINT16(COUNTDOWN + _pCount * 2);
-			int xp = READ_LE_UINT16(COUNTDOWN + _pCount * 2 + 1);
-			_screen->plotImage(_objectsTable[0], id, Common::Point(xp, 71));
-			//TODO : more intro
-		} else {
-			//TODO : more intro
+	for (_pCount = 0; _pCount < 3; ++_pCount) {
+		_buffer2.copyFrom(_buffer1);
+		int id = COUNTDOWN[_pCount * 2];
+		int xp = COUNTDOWN[_pCount * 2 + 1];
+		_buffer2.plotImage(_objectsTable[0], id, Common::Point(xp, 71));
+		_screen->copyFrom(_buffer2);
+
+		_events->_vbCount = 70;
+		while (!shouldQuit() && _events->_vbCount > 0) {
+			_events->pollEvents();
+			g_system->delayMillis(10);
 		}
 	}
-	//TODO : more intro
+
+	_sound->playSound(0);
+	_screen->forceFadeOut();
+	_events->_vbCount = 100;
+	while (!shouldQuit() && _events->_vbCount > 0) {
+		_events->pollEvents();
+		g_system->delayMillis(10);
+	}
+
+	_sound->freeSounds();
 	delete _objectsTable[0];
+	_objectsTable[0] = nullptr;
+
+	_files->_setPaletteFlag = false;
+	_files->loadScreen(0, 5);
+	_buffer2.copyFrom(*_screen);
+	_buffer1.copyFrom(*_screen);
+	_screen->forceFadeIn();
+	_sound->newMusic(1, 0);
+	_events->_vbCount = 700;
+	warning("TODO: check on KEYBUFCNT");
+	while (!shouldQuit() && (_events->_vbCount > 0) && (!_events->_leftButton) && (!_events->_rightButton)) {
+		_events->pollEvents();
+		g_system->delayMillis(10);
+	}
+	if (_events->_rightButton) {
+		_skipStart = true;
+		_room->clearRoom();
+		_events->showCursor();
+		return;
+	}
+
+	_sound->newMusic(1, 1);
+	_sound->_musicRepeat = false;
+	_events->zeroKeys();
+	_room->loadRoom(0);
+	_screen->clearScreen();
+	_screen->setBufferScan();
+	_screen->_scrollRow = _screen->_scrollCol = 0;
+	_screen->_scrollX = _screen->_scrollY = 0;
+	_player->_rawPlayer = Common::Point(0, 0);
+	_screen->forceFadeOut();
+	_screen->_scrollX = 0;
+	_room->buildScreen();
+	copyBF2Vid();
+	_screen->forceFadeIn();
+	_oldRects.clear();
+	_newRects.clear();
+	// KEYFLG = 0;
+	_player->_scrollAmount = 1;
+	_pCount = 1;
 }
 
 void AmazonEngine::doOpening() {
diff --git a/engines/access/room.h b/engines/access/room.h
index 810082e..6c8b040 100644
--- a/engines/access/room.h
+++ b/engines/access/room.h
@@ -108,8 +108,6 @@ protected:
 	 */
 	void executeCommand(int commandId);
 
-	virtual void loadRoom(int roomNumber) = 0;
-
 	virtual void reloadRoom() = 0;
 
 	virtual void reloadRoom1() = 0;
@@ -141,6 +139,8 @@ public:
 
 	void doRoom();
 
+	virtual void loadRoom(int roomNumber) = 0;
+
 	/**
 	 * Clear all the data used by the room
 	 */


Commit: 731d7d20394d6cb8852fcc32e9beadc46d724cc7
    https://github.com/scummvm/scummvm/commit/731d7d20394d6cb8852fcc32e9beadc46d724cc7
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-12T22:33:42-05:00

Commit Message:
ACCESS: Add more intro code, including credit scrolling

Changed paths:
    engines/access/amazon/amazon_game.cpp
    engines/access/amazon/amazon_game.h



diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp
index 4c2662e..f10c933 100644
--- a/engines/access/amazon/amazon_game.cpp
+++ b/engines/access/amazon/amazon_game.cpp
@@ -134,6 +134,42 @@ void AmazonEngine::doIntroduction() {
 	}
 }
 
+void AmazonEngine::doCredit() {
+	if (_pCount < 15)
+		return;
+
+	if (_pCount <= 75)
+		_buffer2.plotImage(_objectsTable[0], 0, Common::Point(90, 35));
+	else if (_pCount <= 210)
+		_buffer2.plotImage(_objectsTable[0], 1, Common::Point(65, 35));
+	else if (_pCount <= 272)
+		_buffer2.plotImage(_objectsTable[0], 2, Common::Point(96, 45));
+	else if (_pCount <= 334)
+		_buffer2.plotImage(_objectsTable[0], 3, Common::Point(68, 54));
+	else if (_pCount <= 396)
+		_buffer2.plotImage(_objectsTable[0], 4, Common::Point(103, 54));
+	else if (_pCount <= 458) {
+		_buffer2.plotImage(_objectsTable[0], 5, Common::Point(8, 5));
+		_buffer2.plotImage(_objectsTable[0], 12, Common::Point(88, 55));
+		_buffer2.plotImage(_objectsTable[0], 6, Common::Point(194, 98));
+	} else if (_pCount <= 520) {
+		_buffer2.plotImage(_objectsTable[0], 7, Common::Point(90, 35));
+		_buffer2.plotImage(_objectsTable[0], 8, Common::Point(90, 35));
+	} else if (_pCount <= 580) {
+		_buffer2.plotImage(_objectsTable[0], 9, Common::Point(18, 15));
+		_buffer2.plotImage(_objectsTable[0], 10, Common::Point(164, 81));
+	} else
+		_buffer2.plotImage(_objectsTable[0], 11, Common::Point(106, 55));
+}
+
+void AmazonEngine::scrollTitle() {
+	copyBF1BF2();
+	_newRects.clear();
+	doCredit();
+	copyRects();
+	copyBF2Vid();
+}
+
 void AmazonEngine::doTitle() {
 	_screen->setDisplayScan();
 	_destIn = &_buffer2;
@@ -230,7 +266,83 @@ void AmazonEngine::doTitle() {
 	_newRects.clear();
 	// KEYFLG = 0;
 	_player->_scrollAmount = 1;
-	_pCount = 1;
+	_pCount = 0;
+
+	while(true) {
+		_events->pollEvents();
+		if (_events->_rightButton) {
+			_skipStart = true;
+			_room->clearRoom();
+			_events->showCursor();
+			return;
+		}
+
+		warning("TODO: check on KEYBUFCNT");
+		if (_events->_leftButton) {
+			_room->clearRoom();
+			_events->showCursor();
+			return;
+		}
+
+		_events->_vbCount = 4;
+		if (_screen->_scrollCol + _screen->_vWindowWidth != _room->_playFieldWidth) {
+			_screen->_scrollX += _player->_scrollAmount;
+
+			while (_screen->_scrollX >= TILE_WIDTH && !shouldQuit()) {
+				_screen->_scrollX -= TILE_WIDTH;
+				++_screen->_scrollCol;
+
+				_buffer1.moveBufferLeft();
+				_room->buildColumn(_screen->_scrollCol + _screen->_vWindowWidth, _screen->_vWindowBytesWide);
+			}
+			scrollTitle();
+			++_pCount;
+
+			while (!shouldQuit() && (_events->_vbCount > 0)) {
+				_events->pollEvents();
+				g_system->delayMillis(10);
+			}
+			continue;
+		}
+
+		_events->_vbCount = 120;
+		while (!shouldQuit() && (_events->_vbCount > 0)) {
+			_events->pollEvents();
+			g_system->delayMillis(10);
+		}
+
+		while(true) {
+			_pCount = 0;
+			_events->_vbCount = 3;
+			if (_screen->_scrollRow + _screen->_vWindowHeight >= _room->_playFieldHeight) {
+				_room->clearRoom();
+				_events->showCursor();
+				return;
+			}
+
+			_screen->_scrollY = _screen->_scrollY + _player->_scrollAmount;
+
+			while (_screen->_scrollY >= TILE_HEIGHT && !shouldQuit()) {
+				_screen->_scrollY -= TILE_HEIGHT;
+				++_screen->_scrollRow;
+				_buffer1.moveBufferUp();
+
+				_room->buildRow(_screen->_scrollRow + _screen->_vWindowHeight, _screen->_vWindowLinesTall * _screen->_bufferBytesWide);
+
+				if (_screen->_scrollRow + _screen->_vWindowHeight >= _room->_playFieldHeight) {
+					_room->clearRoom();
+					_events->showCursor();
+					return;
+				}
+				
+				scrollTitle();
+				while (!shouldQuit() && (_events->_vbCount > 0)) {
+					_events->pollEvents();
+					g_system->delayMillis(10);
+				}
+			}
+		}
+	}
 }
 
 void AmazonEngine::doOpening() {
diff --git a/engines/access/amazon/amazon_game.h b/engines/access/amazon/amazon_game.h
index 0c6fb1c..34a1eef 100644
--- a/engines/access/amazon/amazon_game.h
+++ b/engines/access/amazon/amazon_game.h
@@ -95,6 +95,8 @@ private:
 	 */
 	void setupGame();
 
+	void doCredit();
+	void scrollTitle();
 	void loadEstablish(int estabIndex);
 	void doEstablish(int screenId, int estabIndex);
 


Commit: 1ad11d091f03aeb437413c328c36bed1c08b73d8
    https://github.com/scummvm/scummvm/commit/1ad11d091f03aeb437413c328c36bed1c08b73d8
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-12T22:33:52-05:00

Commit Message:
ACCESS: Simplify doIntroduction()

Changed paths:
    engines/access/amazon/amazon_game.cpp



diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp
index f10c933..d110a6c 100644
--- a/engines/access/amazon/amazon_game.cpp
+++ b/engines/access/amazon/amazon_game.cpp
@@ -117,21 +117,17 @@ void AmazonEngine::doIntroduction() {
 	_events->showCursor();
 	_screen->setPanel(3);
 	doTitle();
-	if (shouldQuit())
+
+	if (shouldQuit() || _skipStart)
 		return;
 
-	if (!_skipStart) {
-		_screen->setPanel(3);
-		doOpening();
-		if (shouldQuit())
-			return;
+	_screen->setPanel(3);
+	doOpening();
 
-		if (!_skipStart) {
-			doTent();
-			if (shouldQuit())
-				return;
-		}
-	}
+	if (shouldQuit() || _skipStart)
+		return;
+
+	doTent();
 }
 
 void AmazonEngine::doCredit() {


Commit: f70012a115dc963f21ac531d57e593af0e5a1ccf
    https://github.com/scummvm/scummvm/commit/f70012a115dc963f21ac531d57e593af0e5a1ccf
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-12T22:34:03-05:00

Commit Message:
ACCESS: Replace doOpening by mWhileDoOpen, move openObj to Amazon Resources

Changed paths:
    engines/access/amazon/amazon_game.cpp
    engines/access/amazon/amazon_game.h
    engines/access/amazon/amazon_resources.cpp
    engines/access/amazon/amazon_resources.h
    engines/access/amazon/amazon_scripts.cpp
    engines/access/amazon/amazon_scripts.h



diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp
index d110a6c..e9c42d0 100644
--- a/engines/access/amazon/amazon_game.cpp
+++ b/engines/access/amazon/amazon_game.cpp
@@ -122,7 +122,7 @@ void AmazonEngine::doIntroduction() {
 		return;
 
 	_screen->setPanel(3);
-	doOpening();
+	((AmazonScripts *)_scripts)->mWhileDoOpen();
 
 	if (shouldQuit() || _skipStart)
 		return;
@@ -341,10 +341,6 @@ void AmazonEngine::doTitle() {
 	}
 }
 
-void AmazonEngine::doOpening() {
-	warning("TODO doOpening");
-}
-
 void AmazonEngine::doTent() {
 	warning("TODO doTent");
 }
diff --git a/engines/access/amazon/amazon_game.h b/engines/access/amazon/amazon_game.h
index 34a1eef..ba81a77 100644
--- a/engines/access/amazon/amazon_game.h
+++ b/engines/access/amazon/amazon_game.h
@@ -81,11 +81,6 @@ private:
 	void doTitle();
 
 	/**
-	 * Do opening sequence
-	 */
-	void doOpening();
-
-	/**
 	 * Do tent scene of introduction
 	 */
 	void doTent();
diff --git a/engines/access/amazon/amazon_resources.cpp b/engines/access/amazon/amazon_resources.cpp
index 5768be3..925ea19 100644
--- a/engines/access/amazon/amazon_resources.cpp
+++ b/engines/access/amazon/amazon_resources.cpp
@@ -1524,5 +1524,18 @@ const int TORCH[12] = {
 
 const int SPEAR[3] = {30, -13, 1};
 
+const int openObj[10][4] = {
+	{8, -80, 120, 30},
+	{13, 229, 0, 50},
+	{12, 78, 0, 50},
+	{11, 10, 0, 50},
+	{10, 178, 97, 50},
+	{9, 92, 192, 50},
+	{14, 38, 0, 100},
+	{15, 132, 76, 100},
+	{16, 142, 0, 100},
+	{4, -280, 40, 120},
+};
+
 } // End of namespace Amazon
 } // End of namespace Access
diff --git a/engines/access/amazon/amazon_resources.h b/engines/access/amazon/amazon_resources.h
index 0d65a56..434a0f3 100644
--- a/engines/access/amazon/amazon_resources.h
+++ b/engines/access/amazon/amazon_resources.h
@@ -81,6 +81,8 @@ extern const int PITSTAB[21];
 extern const int TORCH[12];
 
 extern const int SPEAR[3];
+
+extern const int openObj[10][4];
 } // End of namespace Amazon
 
 } // End of namespace Access
diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp
index ae7e047..f97d789 100644
--- a/engines/access/amazon/amazon_scripts.cpp
+++ b/engines/access/amazon/amazon_scripts.cpp
@@ -540,19 +540,6 @@ void AmazonScripts::mWhileDoOpen() {
 	Screen &screen = *_vm->_screen;
 	EventsManager &events = *_vm->_events;
 
-	const int openObj[10][4] = {
-		{8, -80, 120, 30},
-		{13, 229, 0, 50},
-		{12, 78, 0, 50},
-		{11, 10, 0, 50},
-		{10, 178, 97, 50},
-		{9, 92, 192, 50},
-		{14, 38, 0, 100},
-		{15, 132, 76, 100},
-		{16, 142, 0, 100},
-		{4, -280, 40, 120},
-	};
-
 	screen.setBufferScan();
 	events.hideCursor();
 	screen.forceFadeOut();
diff --git a/engines/access/amazon/amazon_scripts.h b/engines/access/amazon/amazon_scripts.h
index c7b72a6..67e7e77 100644
--- a/engines/access/amazon/amazon_scripts.h
+++ b/engines/access/amazon/amazon_scripts.h
@@ -35,16 +35,16 @@ class AmazonEngine;
 class AmazonScripts: public Scripts {
 private:
 	AmazonEngine *_game;
-
 	int _xTrack;
 	int _yTrack;
 	int _zTrack;
 	int _xCam;
 	int _yCam;
 	int _zCam;
-
 	int _pNumObj;
+
 	int _pImgNum[32];
+
 	SpriteResource *_pObject[32];
 
 	int _pObjX[32];
@@ -70,7 +70,6 @@ protected:
 	void mWhileFly();
 	void mWhileFall();
 	void mWhileJWalk();
-	void mWhileDoOpen();
 	void mWhile(int param1);
 	void setVerticalCode(Common::Rect bounds);
 	void setHorizontalCode(Common::Rect bounds);
@@ -99,6 +98,8 @@ protected:
 	void CMDRETFLASH();
 public:
 	AmazonScripts(AccessEngine *vm);
+
+	void mWhileDoOpen();
 };
 
 } // End of namespace Amazon


Commit: a0294b633896dda85d3dee610c4ba2f938f3d731
    https://github.com/scummvm/scummvm/commit/a0294b633896dda85d3dee610c4ba2f938f3d731
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-12T22:34:13-05:00

Commit Message:
ACCESS: Move setupGame before doIntroduction to fix a crash

Changed paths:
    engines/access/amazon/amazon_game.cpp



diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp
index e9c42d0..4407175 100644
--- a/engines/access/amazon/amazon_game.cpp
+++ b/engines/access/amazon/amazon_game.cpp
@@ -83,6 +83,9 @@ void AmazonEngine::playGame() {
 	_room = new AmazonRoom(this);
 	_scripts = new AmazonScripts(this);
 
+	// Setup the game
+	setupGame();
+
 	if (_loadSaveSlot == -1) {
 		// Do introduction
 		doIntroduction();
@@ -90,9 +93,6 @@ void AmazonEngine::playGame() {
 			return;
 	}
 
-	// Setup the game
-	setupGame();
-
 	_screen->clearScreen();
 	_screen->setPanel(0);
 	_screen->forceFadeOut();


Commit: 44e7051b955b7ccf12da6a8bfdbca2155f296a98
    https://github.com/scummvm/scummvm/commit/44e7051b955b7ccf12da6a8bfdbca2155f296a98
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-12T22:34:23-05:00

Commit Message:
ACCESS: Fix display height of text in chapter introduction

Changed paths:
    engines/access/amazon/amazon_game.cpp



diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp
index 4407175..bc26ee3 100644
--- a/engines/access/amazon/amazon_game.cpp
+++ b/engines/access/amazon/amazon_game.cpp
@@ -655,7 +655,6 @@ void AmazonEngine::startChapter(int chapter) {
 	uint16 msgOffset = READ_LE_UINT16(_eseg->data() + ((0x40 + _chapter) * 2) + 2);
 	_printEnd = 170;
 
-	_printEnd = 155;
 	Common::String msg((const char *)_eseg->data() + msgOffset);
 
 	if (_txtPages == 0) {


Commit: 8e483e037f1851fb96fd2125bf526828cdfa6e98
    https://github.com/scummvm/scummvm/commit/8e483e037f1851fb96fd2125bf526828cdfa6e98
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-12T22:34:33-05:00

Commit Message:
ACCESS: Fix the handling of the very last line of a text in getLine

Changed paths:
    engines/access/font.cpp



diff --git a/engines/access/font.cpp b/engines/access/font.cpp
index 5eaf0b0..5686cdf 100644
--- a/engines/access/font.cpp
+++ b/engines/access/font.cpp
@@ -110,8 +110,11 @@ bool Font::getLine(Common::String &s, int maxWidth, Common::String &line, int &w
 
 		// Reached maximum allowed size
 		// If this was the last character of the string, let it go
-		if (*src == '\0')
+		if (*src == '\0') {
+			line = Common::String(s.c_str(), src);
+			s = "";
 			return true;
+		}
 		
 		// Work backwards to find space at the start of the current word 
 		// as a point to split the line on


Commit: 31fc8fdaa1520d57b02c9aeb83fb4a57b4fef16e
    https://github.com/scummvm/scummvm/commit/31fc8fdaa1520d57b02c9aeb83fb4a57b4fef16e
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-12T22:34:43-05:00

Commit Message:
ACCESS: Add a hack in order to make the first screen visible

Changed paths:
    engines/access/amazon/amazon_game.cpp



diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp
index bc26ee3..d7ad12e 100644
--- a/engines/access/amazon/amazon_game.cpp
+++ b/engines/access/amazon/amazon_game.cpp
@@ -184,6 +184,15 @@ void AmazonEngine::doTitle() {
 	_screen->forceFadeIn();
 	_sound->playSound(1);
 
+	// HACK: This delay has been added so that the very first screen is visible.
+	// The original was using disk loading time to display it, and it's too fast
+	// nowadays to be visible.
+	_events->_vbCount = 70;
+	while (!shouldQuit() && _events->_vbCount > 0) {
+		_events->pollEvents();
+		g_system->delayMillis(10);
+	}
+
 	Resource *spriteData = _files->loadFile(0, 2);
 	_objectsTable[0] = new SpriteResource(this, spriteData);
 	delete spriteData;


Commit: 8939d657f701d3e40112b5b19fe49022eca8f18a
    https://github.com/scummvm/scummvm/commit/8939d657f701d3e40112b5b19fe49022eca8f18a
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-12T22:34:52-05:00

Commit Message:
ACCESS: Fix loading animation data in mWhileDoOpen

Changed paths:
    engines/access/amazon/amazon_scripts.cpp



diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp
index f97d789..9bb910c 100644
--- a/engines/access/amazon/amazon_scripts.cpp
+++ b/engines/access/amazon/amazon_scripts.cpp
@@ -560,7 +560,11 @@ void AmazonScripts::mWhileDoOpen() {
 	_vm->_buffer2.copyFrom(*_vm->_screen);
 	_vm->_buffer1.copyFrom(*_vm->_screen);
 
-	warning("TODO _roomInfo = _vm->_files->loadFile(1, 1);");
+	// Load animation data
+	_vm->_animation->freeAnimationData();
+	Resource *animResource = _vm->_files->loadFile(1, 1);
+	_vm->_animation->loadAnimations(animResource);
+	delete animResource;
 
 	_xTrack = 8;
 	_yTrack = -3;


Commit: a01ddaeb1b20d4e512d8418fa2ae9b72dcaca308
    https://github.com/scummvm/scummvm/commit/a01ddaeb1b20d4e512d8418fa2ae9b72dcaca308
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-12T22:35:01-05:00

Commit Message:
ACCESS: Fix loading correct sprite resource in mWhileDoOpen

Changed paths:
    engines/access/amazon/amazon_scripts.cpp



diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp
index 9bb910c..b4a1568 100644
--- a/engines/access/amazon/amazon_scripts.cpp
+++ b/engines/access/amazon/amazon_scripts.cpp
@@ -550,7 +550,7 @@ void AmazonScripts::mWhileDoOpen() {
 		_game->establishCenter(0, 1);
 	}
 
-	Resource *data = _vm->_files->loadFile(0, 1);
+	Resource *data = _vm->_files->loadFile(1, 0);
 	SpriteResource *spr = new SpriteResource(_vm, data);
 	delete data;
 


Commit: b2e67a69c6dd53f2ffa720eced127dff97eb856c
    https://github.com/scummvm/scummvm/commit/b2e67a69c6dd53f2ffa720eced127dff97eb856c
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-12T22:35:10-05:00

Commit Message:
ACCESS: Fix incorrect loading of exra cells during room load

Changed paths:
    engines/access/room.cpp



diff --git a/engines/access/room.cpp b/engines/access/room.cpp
index 513c159..31d1583 100644
--- a/engines/access/room.cpp
+++ b/engines/access/room.cpp
@@ -796,7 +796,6 @@ RoomInfo::RoomInfo(const byte *data, int gameType, bool isCD) {
 		ExtraCell ec;
 		ec._vid._fileNum = v;
 		ec._vid._subfile = stream.readSint16LE();
-		ec._vidSound.load(stream);
 
 		_extraCells.push_back(ec);
 	}


Commit: 8e45582492cab277c5b53884f7ec9c0a22a6e4ca
    https://github.com/scummvm/scummvm/commit/8e45582492cab277c5b53884f7ec9c0a22a6e4ca
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-12T22:35:19-05:00

Commit Message:
ACCESS: Add extra shouldQuit checks during title sequence

Changed paths:
    engines/access/amazon/amazon_game.cpp



diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp
index d7ad12e..dba1b6f 100644
--- a/engines/access/amazon/amazon_game.cpp
+++ b/engines/access/amazon/amazon_game.cpp
@@ -273,8 +273,7 @@ void AmazonEngine::doTitle() {
 	_player->_scrollAmount = 1;
 	_pCount = 0;
 
-	while(true) {
-		_events->pollEvents();
+	while (!shouldQuit()) {
 		if (_events->_rightButton) {
 			_skipStart = true;
 			_room->clearRoom();
@@ -293,7 +292,7 @@ void AmazonEngine::doTitle() {
 		if (_screen->_scrollCol + _screen->_vWindowWidth != _room->_playFieldWidth) {
 			_screen->_scrollX += _player->_scrollAmount;
 
-			while (_screen->_scrollX >= TILE_WIDTH && !shouldQuit()) {
+			while (_screen->_scrollX >= TILE_WIDTH) {
 				_screen->_scrollX -= TILE_WIDTH;
 				++_screen->_scrollCol;
 
@@ -316,7 +315,7 @@ void AmazonEngine::doTitle() {
 			g_system->delayMillis(10);
 		}
 
-		while(true) {
+		while (!shouldQuit()) {
 			_pCount = 0;
 			_events->_vbCount = 3;
 			if (_screen->_scrollRow + _screen->_vWindowHeight >= _room->_playFieldHeight) {


Commit: e9e19446d833c784430e2947098df251583f24ce
    https://github.com/scummvm/scummvm/commit/e9e19446d833c784430e2947098df251583f24ce
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-12T22:35:28-05:00

Commit Message:
ACCESS: Implement doTent

Changed paths:
    engines/access/amazon/amazon_game.cpp



diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp
index dba1b6f..f663f03 100644
--- a/engines/access/amazon/amazon_game.cpp
+++ b/engines/access/amazon/amazon_game.cpp
@@ -350,7 +350,74 @@ void AmazonEngine::doTitle() {
 }
 
 void AmazonEngine::doTent() {
-	warning("TODO doTent");
+	int step = 0;
+	_screen->setDisplayScan();
+	_screen->forceFadeOut();
+	_events->hideCursor();
+	_sound->_soundTable.push_back(SoundEntry(_sound->loadSound(98, 39), 1));
+	_sound->_soundTable.push_back(SoundEntry(_sound->loadSound(98, 14), 1));
+	_sound->_soundTable.push_back(SoundEntry(_sound->loadSound(98, 15), 1));
+	_sound->_soundTable.push_back(SoundEntry(_sound->loadSound(98, 16), 1));
+	_sound->_soundTable.push_back(SoundEntry(_sound->loadSound(98, 31), 2));
+	_sound->_soundTable.push_back(SoundEntry(_sound->loadSound(98, 52), 2));
+	_sound->playSound(0);
+
+	_files->_setPaletteFlag = false;
+	_files->loadScreen(2, 0);
+	_buffer2.copyFrom(*_screen);
+	_buffer1.copyFrom(*_screen);
+	_screen->forceFadeIn();
+
+	_video->setVideo(_screen, Common::Point(126, 73), FileIdent(2, 1), 10);
+	while (!shouldQuit() && !_video->_videoEnd) {
+		_video->playVideo();
+		if ((_video->_videoFrame == 32) || (_video->_videoFrame == 34))
+			_sound->playSound(4);
+		else if (_video->_videoFrame == 36) {
+			if (step != 2) {
+				_sound->playSound(2);
+				step = 2;
+			}
+		} else if (_video->_videoFrame == 18) {
+			if (step != 1) {
+				_sound->newMusic(73, 1);
+				_sound->newMusic(11, 0);
+				step = 1;
+				_sound->playSound(1);
+			}
+		}
+
+		g_system->delayMillis(10);
+		_events->pollEvents();
+	}	
+
+	_sound->playSound(5);
+	_video->setVideo(_screen, Common::Point(43, 11), FileIdent(2, 2), 10);
+	while (!shouldQuit() && !_video->_videoEnd) {
+		_video->playVideo();
+		if (_video->_videoFrame == 26) {
+			_sound->playSound(5);
+		} else if (_video->_videoFrame == 15) {
+			if (step !=3) {
+				_sound->playSound(3);
+				step = 3;
+			}
+		}
+
+		g_system->delayMillis(10);
+		_events->pollEvents();
+	}
+
+	_events->_vbCount = 200;
+	while (!shouldQuit() && _events->_vbCount > 0) {
+		_events->pollEvents();
+		g_system->delayMillis(10);
+	}
+	_events->showCursor();
+	_sound->newMusic(11, 1);
+	_sound->_soundTable.clear();
+
+	establishCenter(0, 4);
 }
 
 void AmazonEngine::setupGame() {


Commit: bc050a549ca43b8571270782bc3b12cc0b31c634
    https://github.com/scummvm/scummvm/commit/bc050a549ca43b8571270782bc3b12cc0b31c634
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-12T22:35:39-05:00

Commit Message:
ACCESS: Implemented cmdCheckVFrame opcode

Changed paths:
    engines/access/scripts.cpp
    engines/access/scripts.h



diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp
index 9f91948..89c8a4d 100644
--- a/engines/access/scripts.cpp
+++ b/engines/access/scripts.cpp
@@ -127,7 +127,7 @@ void Scripts::executeCommand(int commandIndex) {
 		&Scripts::cmdSpecial, &Scripts::cmdSpecial, &Scripts::cmdSpecial,
 		&Scripts::cmdSetCycle, &Scripts::cmdCycle, &Scripts::cmdCharSpeak, 
 		&Scripts::cmdTexSpeak, &Scripts::cmdTexChoice, &Scripts::cmdWait, 
-		&Scripts::cmdSetConPos, &Scripts::CMDCHECKVFRAME, &Scripts::cmdJumpChoice, 
+		&Scripts::cmdSetConPos, &Scripts::cmdCheckVFrame, &Scripts::cmdJumpChoice, 
 		&Scripts::cmdReturnChoice, &Scripts::cmdClearBlock, &Scripts::cmdLoadSound, 
 		&Scripts::cmdFreeSound, &Scripts::cmdSetVideoSound, &Scripts::cmdPlayVideoSound,
 		&Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, 
@@ -691,7 +691,12 @@ void Scripts::cmdSetConPos() {
 	_texsOrg = Common::Point(x, y);
 }
 
-void Scripts::CMDCHECKVFRAME() { error("TODO CMDCHECKVFRAME"); }
+void Scripts::cmdCheckVFrame() { 
+	if (_vm->_video->_videoFrame == _data->readSint16LE())
+		cmdGoto();
+	else
+		_data->skip(2);
+}
 
 void Scripts::cmdJumpChoice() {
 	int val = (_data->readUint16LE() & 0xFF);
diff --git a/engines/access/scripts.h b/engines/access/scripts.h
index eaac996..2b527a8 100644
--- a/engines/access/scripts.h
+++ b/engines/access/scripts.h
@@ -109,7 +109,7 @@ protected:
 	void cmdTexChoice();
 	void cmdWait();
 	void cmdSetConPos();
-	void CMDCHECKVFRAME();
+	void cmdCheckVFrame();
 	void cmdJumpChoice();
 	void cmdReturnChoice();
 	void cmdClearBlock();


Commit: 43f7fe9182a151f070c93dae4550dc022aeb12be
    https://github.com/scummvm/scummvm/commit/43f7fe9182a151f070c93dae4550dc022aeb12be
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-12T22:35:51-05:00

Commit Message:
ACCESS: Implement doCast

Changed paths:
    engines/access/amazon/amazon_scripts.cpp
    engines/access/amazon/amazon_scripts.h
    engines/access/sound.cpp
    engines/access/sound.h



diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp
index b4a1568..451c689 100644
--- a/engines/access/amazon/amazon_scripts.cpp
+++ b/engines/access/amazon/amazon_scripts.cpp
@@ -931,6 +931,143 @@ void AmazonScripts::loadBackground(int param1, int param2) {
 	_vm->_screen->forceFadeIn();
 }
 
+void AmazonScripts::doCast(int param1) {
+	static const int END_OBJ[26][4] = {
+		{ 0, 118, 210, 10},
+		{ 1,  38, 250, 10},
+		{ 2,  38, 280, 10},
+		{ 3,  38, 310, 10},
+		{ 4,  38, 340, 10},
+		{ 5,  38, 370, 10},
+		{ 6,  38, 400, 10},
+		{ 7,  38, 430, 10},
+		{ 8,  38, 460, 10},
+		{ 9,  38, 490, 10},
+		{10,  38, 520, 10},
+		{11,  38, 550, 10},
+		{12,  38, 580, 10},
+		{13,  38, 610, 10},
+		{14,  38, 640, 10},
+		{15,  38, 670, 10},
+		{16,  38, 700, 10},
+		{17,  38, 730, 10},
+		{18,  38, 760, 10},
+		{19,  38, 790, 10},
+		{20,  95, 820, 10},
+		{21,  94, 850, 10},
+		{22,  96, 880, 10},
+		{23, 114, 910, 10},
+		{24, 114, 940, 10},
+		{25, 110, 970, 10}
+	};
+
+	static const int END_OBJ1[4][4] = {
+		{0,  40, 1100, 10},
+		{2,  11, 1180, 10},
+		{1, 154, 1180, 10},
+		{3, 103, 1300, 10}
+	};
+
+	_vm->_screen->setDisplayScan();
+	_vm->_events->hideCursor();
+	_vm->_screen->forceFadeOut();
+	_vm->_screen->_clipHeight = 173;
+	_vm->_screen->clearScreen();
+	_game->_chapter = 16;
+	_game->tileScreen();
+	_game->updateSummary(param1);
+	_vm->_screen->setPanel(3);
+	_game->_chapter = 14;
+
+	Resource *spriteData = _vm->_files->loadFile(91, 0);
+	_vm->_objectsTable[0] = new SpriteResource(_vm, spriteData);
+	delete spriteData;
+	spriteData = _vm->_files->loadFile(91, 1);
+	_vm->_objectsTable[1] = new SpriteResource(_vm, spriteData);
+	delete spriteData;
+
+	_vm->_files->_setPaletteFlag = false;
+	_vm->_files->loadScreen(58, 1);
+	_vm->_buffer2.copyFrom(*_vm->_screen);
+	_vm->_buffer1.copyFrom(*_vm->_screen);
+
+	_xTrack = 0;
+	_yTrack = -6;
+	_zTrack = 0;
+	_xCam = _yCam = 0;
+	_zCam = 60;
+
+	_game->_timers[24]._timer = 1;
+	_game->_timers[24]._initTm = 1;
+	++_game->_timers[24]._flag;
+
+	_pNumObj = 26;
+	for (int i = 0; i < _pNumObj; i++) {
+		_pObject[i] = _vm->_objectsTable[0];
+		_pImgNum[i] = END_OBJ[i][0];
+		_pObjX[i] = END_OBJ[i][1];
+		_pObjY[i] = END_OBJ[i][2];
+		_pObjZ[i] = END_OBJ[i][3];
+		_pObjXl[i] = _pObjYl[i] = 0;
+	}
+
+	_pNumObj = 4;
+	for (int i = 0; i < _pNumObj; i++) {
+		_pObject[26 + i] = _vm->_objectsTable[1];
+		_pImgNum[26 + i] = END_OBJ1[i][0];
+		_pObjX[26 + i] = END_OBJ1[i][1];
+		_pObjY[26 + i] = END_OBJ1[i][2];
+		_pObjZ[26 + i] = END_OBJ1[i][3];
+		_pObjXl[26 + i] = _pObjYl[26 + i] = 0;
+	}
+
+	_vm->_oldRects.clear();
+	_vm->_newRects.clear();
+	_vm->_numAnimTimers = 0;
+
+	_vm->_sound->newMusic(58, 0);
+	_vm->_screen->forceFadeIn();
+
+	while (!_vm->shouldQuit()) {
+		_vm->_images.clear();
+		pan();
+		_vm->_buffer2.copyFrom(_vm->_buffer1);
+		_vm->_newRects.clear();
+		_game->plotList();
+		_vm->copyBlocks();
+
+		_vm->_events->pollEvents();
+		warning("TODO: check on KEYBUFCNT");
+
+		if (_yCam < -7550) {
+			_vm->_events->_vbCount = 50;
+
+			while(!_vm->shouldQuit() && !_vm->_events->isKeyMousePressed() && _vm->_events->_vbCount > 0) {
+				_vm->_events->pollEvents();
+				g_system->delayMillis(10);
+			}
+
+			while (!_vm->shouldQuit() && !_vm->_sound->checkMidiDone())
+				_vm->_events->pollEvents();
+
+			break;
+		}
+	}
+
+	_vm->_sound->newMusic(58, 1);
+	_vm->_events->showCursor();
+	warning("TODO: delete _roomInfo;");
+	_vm->freeCells();
+	_vm->_oldRects.clear();
+	_vm->_newRects.clear();
+	_vm->_numAnimTimers = 0;
+	_vm->_images.clear();
+	_vm->_screen->forceFadeOut();
+
+	warning("TODO: EXIT");
+
+}
+
 void AmazonScripts::setInactive() {
 	_game->_rawInactiveX = _vm->_player->_rawPlayer.x;
 	_game->_rawInactiveY = _vm->_player->_rawPlayer.y;
@@ -1232,7 +1369,7 @@ void AmazonScripts::executeSpecial(int commandIndex, int param1, int param2) {
 		loadBackground(param1, param2);
 		break;
 	case 3:
-		warning("TODO DOCAST");
+		doCast(param1);
 		break;
 	case 4:
 		setInactive();
diff --git a/engines/access/amazon/amazon_scripts.h b/engines/access/amazon/amazon_scripts.h
index 67e7e77..ccf19fa 100644
--- a/engines/access/amazon/amazon_scripts.h
+++ b/engines/access/amazon/amazon_scripts.h
@@ -84,6 +84,7 @@ protected:
 	int antHandleLeft(int indx, const int *&buf);
 	int antHandleStab(int indx, const int *&buf);
 	void ANT();
+	void doCast(int param1);
 	void loadBackground(int param1, int param2);
 	void plotInactive();
 	void setInactive();
diff --git a/engines/access/sound.cpp b/engines/access/sound.cpp
index 075bfc0..6d42cd5 100644
--- a/engines/access/sound.cpp
+++ b/engines/access/sound.cpp
@@ -88,6 +88,11 @@ void SoundManager::midiPlay() {
 	// TODO
 }
 
+bool SoundManager::checkMidiDone() {
+	// TODO
+	return true;
+}
+
 void SoundManager::midiRepeat() {
 	// TODO
 }
diff --git a/engines/access/sound.h b/engines/access/sound.h
index 2456ba7..46e3b23 100644
--- a/engines/access/sound.h
+++ b/engines/access/sound.h
@@ -72,6 +72,8 @@ public:
 
 	void midiPlay();
 
+	bool checkMidiDone();
+
 	void midiRepeat();
 
 	void stopSong();


Commit: 690bea4c8831895ec74c022aeda599a9a7d119f6
    https://github.com/scummvm/scummvm/commit/690bea4c8831895ec74c022aeda599a9a7d119f6
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-12T22:36:11-05:00

Commit Message:
ACCESS: Trigger quit game at the end of doCast

Changed paths:
    engines/access/amazon/amazon_scripts.cpp



diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp
index 451c689..4c4f2f3 100644
--- a/engines/access/amazon/amazon_scripts.cpp
+++ b/engines/access/amazon/amazon_scripts.cpp
@@ -1064,8 +1064,8 @@ void AmazonScripts::doCast(int param1) {
 	_vm->_images.clear();
 	_vm->_screen->forceFadeOut();
 
-	warning("TODO: EXIT");
-
+	_vm->quitGame();
+	_vm->_events->pollEvents();
 }
 
 void AmazonScripts::setInactive() {


Commit: 7427f29e85dc5988126349b2579d37a0cf3997f1
    https://github.com/scummvm/scummvm/commit/7427f29e85dc5988126349b2579d37a0cf3997f1
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-12T22:36:22-05:00

Commit Message:
ACCESS: Implement mWhileJWalk2 (WIP)

Changed paths:
    engines/access/amazon/amazon_scripts.cpp
    engines/access/amazon/amazon_scripts.h



diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp
index 4c4f2f3..f7d1df5 100644
--- a/engines/access/amazon/amazon_scripts.cpp
+++ b/engines/access/amazon/amazon_scripts.cpp
@@ -225,6 +225,100 @@ void AmazonScripts::mWhile2() {
 	} while (_vm->_flags[52] == 4);
 }
 
+void AmazonScripts::initJWalk2() {
+	const int JUNGLE1OBJ[7][4] = {
+		{2, 470, 0, 20},
+		{0, 290, 0, 50},
+		{1, 210, 0, 40},
+		{0, 500, 0, 30},
+		{1, 550, 0, 20},
+		{0, 580, 0, 60},
+		{1, 650, 0, 30}
+	};
+	_vm->_screen->fadeOut();
+	_vm->_events->hideCursor();
+	_vm->_screen->clearScreen();
+	_vm->_buffer2.clearBuffer();
+	_vm->_screen->setBufferScan();
+
+	_vm->_screen->_scrollX = _vm->_screen->_scrollY;
+	_vm->_screen->_scrollCol = _vm->_screen->_scrollRow;
+	_vm->_room->buildScreen();
+	_vm->copyBF2Vid();
+	_vm->_screen->fadeIn();
+	// KEYFL = 0;
+
+	_game->_plane._xCount = 2;
+	_vm->_player->_scrollAmount = 5;
+	_xTrack = -10;
+	_yTrack = _zTrack = 0;
+	_xCam = 480;
+	_yCam = 0;
+	_zCam = 80;
+
+	_game->_timers[24]._timer = 1;
+	_game->_timers[24]._initTm = 1;
+	++_game->_timers[24]._flag;
+
+	_pNumObj = 7;
+	for (int i = 0; i < _pNumObj; i++) {
+		_pObject[i] = _vm->_objectsTable[24];
+		_pImgNum[i] = JUNGLE1OBJ[i][0];
+		_pObjX[i] = JUNGLE1OBJ[i][1];
+		_pObjY[i] = JUNGLE1OBJ[i][2];
+		_pObjZ[i] = JUNGLE1OBJ[i][3];
+		_pObjXl[i] = _pObjYl[i] = 0;
+	}
+
+	_jCnt[0] = 0;
+	_jCnt[1] = 3;
+	_jCnt[2] = 5;
+
+	_jungleX[0] = 50;
+	_jungleX[1] = 16;
+	_jungleX[2] = 93;
+}
+
+void AmazonScripts::jungleMove() {
+	warning("TODO jungleMove");
+}
+
+void AmazonScripts::mWhileJWalk2() {
+	Screen &screen = *_vm->_screen;
+
+	initJWalk2();
+
+	while(true) {
+		_vm->_images.clear();
+		_vm->_events->_vbCount = 6;
+		_pImgNum[0] = _game->_plane._xCount;
+		while ((screen._scrollCol + screen._vWindowWidth) != _vm->_room->_playFieldWidth) {
+			int scrollX = screen._scrollCol + screen._vWindowWidth;
+			jungleMove();
+			while (scrollX >= TILE_WIDTH) {
+				screen._scrollX -= TILE_WIDTH;
+				++screen._scrollCol;
+				_vm->_buffer1.moveBufferLeft();
+				_vm->_room->buildColumn(screen._scrollCol + screen._vWindowWidth, screen._vWindowBytesWide);
+			}
+			if (_game->_plane._xCount == 2)
+				++_game->_plane._xCount;
+			else
+				--_game->_plane._xCount;
+
+			pan();
+			scrollJWalk();
+
+			g_system->delayMillis(10);
+			while (!_vm->shouldQuit() && _vm->_events->_vbCount > 0) {
+				_vm->_events->pollEvents();
+				g_system->delayMillis(10);
+			}
+		}
+	}
+	_vm->_events->showCursor();
+}
+
 void AmazonScripts::doFlyCell() {
 	Plane &plane = _game->_plane;
 	SpriteResource *sprites = _vm->_objectsTable[15];
@@ -667,7 +761,7 @@ void AmazonScripts::mWhile(int param1) {
 		mWhile2();
 		break;
 	case 8:
-		warning("TODO JWALK2");
+		mWhileJWalk2();
 		break;
 	default:
 		break;
diff --git a/engines/access/amazon/amazon_scripts.h b/engines/access/amazon/amazon_scripts.h
index ccf19fa..d07445b 100644
--- a/engines/access/amazon/amazon_scripts.h
+++ b/engines/access/amazon/amazon_scripts.h
@@ -53,6 +53,9 @@ private:
 	int _pObjXl[16];
 	int _pObjYl[16];
 
+	int _jCnt[3];
+	int _jungleX[3];
+
 	void pan();
 
 protected:
@@ -70,6 +73,9 @@ protected:
 	void mWhileFly();
 	void mWhileFall();
 	void mWhileJWalk();
+	void initJWalk2();
+	void jungleMove();
+	void mWhileJWalk2();
 	void mWhile(int param1);
 	void setVerticalCode(Common::Rect bounds);
 	void setHorizontalCode(Common::Rect bounds);


Commit: 60ee5456c9b7436e0830ba30a30acb53051d2820
    https://github.com/scummvm/scummvm/commit/60ee5456c9b7436e0830ba30a30acb53051d2820
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-12T22:36:36-05:00

Commit Message:
ACCESS: Implement jungleMove

Changed paths:
    engines/access/amazon/amazon_scripts.cpp



diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp
index f7d1df5..7272564 100644
--- a/engines/access/amazon/amazon_scripts.cpp
+++ b/engines/access/amazon/amazon_scripts.cpp
@@ -280,7 +280,35 @@ void AmazonScripts::initJWalk2() {
 }
 
 void AmazonScripts::jungleMove() {
-	warning("TODO jungleMove");
+	const static int jungleY[3] = {27, 30, 29};
+	int cx = 1;
+	int dx = 0;
+	if (_vm->_timers[0]._flag == 0) {
+		_vm->_timers[0]._flag = 1;
+		_vm->_screen->_scrollX += _vm->_player->_scrollAmount;
+		for (int i = 0; i <= 3; i++) {
+			int newJCnt = (_jCnt[i] + 1) % 8;
+			_jCnt[i] = newJCnt;
+			_jungleX[i] += 5;
+		}
+		dx = 4;
+		if (_game->_allenFlag != 1)
+			cx = 2;
+		else
+			cx = 3;
+	}
+
+	for (int i = 0; i <= cx; i++) {
+		ImageEntry ie;
+		ie._flags = 8;
+		ie._spritesPtr = _vm->_objectsTable[24];
+		ie._frameNumber = _jCnt[i] + dx;
+		ie._position = Common::Point(_jungleX[i], jungleY[i]);
+		ie._offsetY = jungleY[i];
+
+		_vm->_images.addToList(ie);
+		dx += 8;
+	}
 }
 
 void AmazonScripts::mWhileJWalk2() {
@@ -293,9 +321,8 @@ void AmazonScripts::mWhileJWalk2() {
 		_vm->_events->_vbCount = 6;
 		_pImgNum[0] = _game->_plane._xCount;
 		while ((screen._scrollCol + screen._vWindowWidth) != _vm->_room->_playFieldWidth) {
-			int scrollX = screen._scrollCol + screen._vWindowWidth;
 			jungleMove();
-			while (scrollX >= TILE_WIDTH) {
+			while (screen._scrollX >= TILE_WIDTH) {
 				screen._scrollX -= TILE_WIDTH;
 				++screen._scrollCol;
 				_vm->_buffer1.moveBufferLeft();


Commit: 968bfec0677c75943fde080c63ab2e265aefa2b2
    https://github.com/scummvm/scummvm/commit/968bfec0677c75943fde080c63ab2e265aefa2b2
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-12T22:36:46-05:00

Commit Message:
ACCESS: Workaround for original setting animations when none is loaded

Changed paths:
    engines/access/animation.cpp
    engines/access/scripts.cpp



diff --git a/engines/access/animation.cpp b/engines/access/animation.cpp
index de44740..184b015 100644
--- a/engines/access/animation.cpp
+++ b/engines/access/animation.cpp
@@ -304,6 +304,8 @@ void AnimationManager::loadAnimations(Resource *res) {
 
 Animation *AnimationManager::setAnimation(int animId) {
 	Animation *anim = findAnimation(animId);
+	if (!anim)
+		return nullptr;
 
 	anim->_countdownTicks = anim->_initialTicks;
 	anim->_frameNumber = 0;
@@ -320,7 +322,7 @@ void AnimationManager::setAnimTimer(Animation *anim) {
 }
 
 Animation *AnimationManager::findAnimation(int animId) {
-	_animStart = _animation->getAnimation(animId);
+	_animStart = (_animation == nullptr) ? nullptr : _animation->getAnimation(animId);
 	return _animStart;
 }
 
diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp
index 89c8a4d..b7ee4d2 100644
--- a/engines/access/scripts.cpp
+++ b/engines/access/scripts.cpp
@@ -391,7 +391,9 @@ void Scripts::cmdCheckLoc() {
 void Scripts::cmdSetAnim() { 
 	int animId = _data->readByte();
 	Animation *anim = _vm->_animation->setAnimation(animId);
-	_vm->_animation->setAnimTimer(anim);
+
+	if (anim)
+		_vm->_animation->setAnimTimer(anim);
 }
 
 void Scripts::cmdDispInv() {


Commit: 5de214dfc446a7905d48900f49e1da37871f209c
    https://github.com/scummvm/scummvm/commit/5de214dfc446a7905d48900f49e1da37871f209c
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-12T22:37:07-05:00

Commit Message:
ACCESS: Implement mWhileDownRiver

Changed paths:
    engines/access/amazon/amazon_scripts.cpp
    engines/access/amazon/amazon_scripts.h



diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp
index 7272564..df6b24b 100644
--- a/engines/access/amazon/amazon_scripts.cpp
+++ b/engines/access/amazon/amazon_scripts.cpp
@@ -764,6 +764,110 @@ void AmazonScripts::mWhileDoOpen() {
 	}
 }
 
+void AmazonScripts::scrollRiver() {
+	_vm->copyBF1BF2();
+	_vm->_newRects.clear();
+	_vm->_buffer2.plotImage(_vm->_objectsTable[33], 0, Common::Point(66, 30));
+	_vm->plotList();
+	_vm->copyRects();
+	_vm->copyBF2Vid();
+}
+
+void AmazonScripts::mWhileDownRiver() {
+	static const int RIVEROBJ[14][4] = {
+		{3,  77, 0, 40},
+		{2,  30, 0, 30},
+		{2, 290, 0, 50},
+		{1, 210, 0, 70},
+		{2, 350, 0, 30},
+		{1, 370, 0, 20},
+		{2, 480, 0, 60},
+		{3, 395, 0, 10},
+		{1, 550, 0, 30},
+		{2, 620, 0, 50},
+		{1, 690, 0, 10},
+		{2, 715, 0, 40},
+		{1, 770, 0, 30},
+		{3, 700, 0, 20}
+	};
+
+	_vm->_events->hideCursor();
+	_vm->_screen->setDisplayScan();
+	_vm->_screen->clearScreen();
+	_vm->_screen->savePalette();
+
+	_vm->_files->loadScreen(95, 4);
+	_vm->_buffer2.copyFrom(*_vm->_screen);
+	_vm->_screen->restorePalette();
+	_vm->_screen->setPalette();
+	_vm->_screen->setBufferScan();
+	_vm->_screen->_scrollX = 0;
+	_vm->_room->buildScreen();
+	_vm->copyBF2Vid();
+
+	// KEYFLG = 0;
+
+	_vm->_player->_scrollAmount = 2;
+	_vm->_destIn = &_vm->_buffer2;
+	_xTrack = -7;
+	_yTrack = _zTrack = 0;
+	_xCam = _yCam = 0;
+	_zCam = 80;
+
+	_game->_timers[24]._timer = 1;
+	_game->_timers[24]._initTm = 1;
+	++_game->_timers[24]._flag;
+	
+	_pNumObj = 14;
+	for (int i = 0; i <_pNumObj; i++) {
+		_pObject[i] = _vm->_objectsTable[33];
+		_pImgNum[i] = RIVEROBJ[i][0];
+		_pObjX[i] = RIVEROBJ[i][1];
+		_pObjY[i] = RIVEROBJ[i][2];
+		_pObjZ[i] = RIVEROBJ[i][3];
+		_pObjXl[i] = _pObjYl[i] = 0;
+	}
+
+	_game->_timers[3]._timer = 200;
+	_game->_timers[3]._initTm = 200;
+	++_game->_timers[3]._flag;
+	_game->_timers[4]._timer = 350;
+	_game->_timers[4]._initTm = 350;
+	++_game->_timers[4]._flag;
+
+	while(true) {
+		_vm->_images.clear();
+		_vm->_events->_vbCount = 6;
+		while ((_vm->_screen->_scrollCol + _vm->_screen->_vWindowWidth != _vm->_room->_playFieldWidth) && _vm->_events->_vbCount) {
+			jungleMove();
+			while (_vm->_screen->_scrollX >= TILE_WIDTH) {
+				_vm->_screen->_scrollX -= TILE_WIDTH;
+				++_vm->_screen->_scrollCol;
+				_vm->_buffer1.moveBufferLeft();
+				_vm->_room->buildColumn(_vm->_screen->_scrollCol + _vm->_screen->_vWindowWidth, _vm->_screen->_vWindowBytesWide);
+			}
+
+			pan();
+			scrollRiver();
+
+			if (_game->_timers[3]._flag == 0) {
+				_game->_timers[3]._flag = 1;
+				_vm->_sound->playSound(1);
+			} else if (_game->_timers[4]._flag == 0) {
+				_game->_timers[4]._flag = 1;
+				_vm->_sound->playSound(0);
+			}
+
+			g_system->delayMillis(10);
+			while (!_vm->shouldQuit() && _vm->_events->_vbCount > 0) {
+				_vm->_events->pollEvents();
+				g_system->delayMillis(10);
+			}
+		}
+	}
+	_vm->_events->showCursor();
+}
+
 void AmazonScripts::mWhile(int param1) {
 	switch(param1) {
 	case 1:
@@ -782,7 +886,7 @@ void AmazonScripts::mWhile(int param1) {
 		mWhileDoOpen();
 		break;
 	case 6:
-		warning("TODO DOWNRIVER");
+		mWhileDownRiver();
 		break;
 	case 7:
 		mWhile2();
diff --git a/engines/access/amazon/amazon_scripts.h b/engines/access/amazon/amazon_scripts.h
index d07445b..06fe56a 100644
--- a/engines/access/amazon/amazon_scripts.h
+++ b/engines/access/amazon/amazon_scripts.h
@@ -76,6 +76,8 @@ protected:
 	void initJWalk2();
 	void jungleMove();
 	void mWhileJWalk2();
+	void scrollRiver();
+	void mWhileDownRiver();
 	void mWhile(int param1);
 	void setVerticalCode(Common::Rect bounds);
 	void setHorizontalCode(Common::Rect bounds);


Commit: e1e97ec9ff30435bee991133d8adc009d74979e5
    https://github.com/scummvm/scummvm/commit/e1e97ec9ff30435bee991133d8adc009d74979e5
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-12T22:37:18-05:00

Commit Message:
ACCESS: Start the implementation of RIVER (WIP)

Changed paths:
    engines/access/amazon/amazon_game.h
    engines/access/amazon/amazon_scripts.cpp
    engines/access/amazon/amazon_scripts.h



diff --git a/engines/access/amazon/amazon_game.h b/engines/access/amazon/amazon_game.h
index ba81a77..f062a28 100644
--- a/engines/access/amazon/amazon_game.h
+++ b/engines/access/amazon/amazon_game.h
@@ -59,7 +59,6 @@ private:
 	int _canoeYPos;
 	int _hitCount;
 	int _saveRiver;
-	int _hitSafe;
 	int _topList;
 	int _botList;
 	int _riverIndex;
@@ -109,6 +108,7 @@ public:
 	bool _charSegSwitch;
 	bool _skipStart;
 
+	int _hitSafe;
 	int _rawInactiveX;
 	int _rawInactiveY;
 	int _inactiveYOff;
diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp
index df6b24b..a45e6f7 100644
--- a/engines/access/amazon/amazon_scripts.cpp
+++ b/engines/access/amazon/amazon_scripts.cpp
@@ -1585,6 +1585,107 @@ void AmazonScripts::plotInactive() {
 
 }
 
+void AmazonScripts::initRiver() {
+	warning("TODO: initRiver()");
+}
+
+bool AmazonScripts::JUMPTEST() {
+	warning("TODO: JUMPTEST();");
+	return true;
+}
+
+void AmazonScripts::RIVERSOUND() {
+	warning("TODO: RIVERSOUND();");
+}
+
+void AmazonScripts::MOVECANOE() {
+	warning("TODO: MOVECANOE();");
+}
+
+void AmazonScripts::UPDATEOBSTACLES() {
+	warning("TODO: UPDATEOBSTACLES()");
+}
+
+void AmazonScripts::SETPHYSX() {
+	warning("TODO: SETPHYSX()");
+}
+
+void AmazonScripts::RIVERCOLLIDE() {
+	warning("TODO: RIVERCOLLIDE()");
+}
+
+void AmazonScripts::SCROLLRIVER1() {
+	warning("TODO: SCROLLRIVER1()");
+}
+
+void AmazonScripts::RIVER() {
+	static const int RIVERDEATH[5] = {22, 23, 24, 25, 26};
+
+	initRiver();
+	while (true) {
+		_vm->_events->_vbCount = 4;
+
+		int bx = _vm->_player->_scrollAmount - _screenVertX;
+		if (_vm->_screen->_scrollX == 0) {
+			_vm->_sound->midiRepeat();
+			if (JUMPTEST()) {
+				CHICKENOUTFLG = false;
+				return;
+			}
+		} else {
+			_vm->_screen->_scrollX -= _vm->_player->_scrollAmount;
+		}
+
+		if (CHICKENOUTFLG) {
+			CHICKENOUTFLG = false;
+			return;
+		}
+
+		_vm->_images.clear();
+		_vm->_animation->animate(0);
+
+		RIVERSOUND();
+		pan();
+		MOVECANOE();
+
+		if (_vm->_room->_function == 1) {
+			CHICKENOUTFLG = false;
+			return;
+		}
+		
+		UPDATEOBSTACLES();
+		SETPHYSX();
+		RIVERCOLLIDE();
+		if (_game->_hitSafe != 0)
+			_game->_hitSafe -= 2;
+
+		if (_game->_hitSafe < 0) {
+			warning("TODO: cmdDead(RIVERDEATH[0]);");
+			return;
+		}
+
+		if (_game->_deathFlag) {
+			_game->_deathCount--;
+			if (_game->_deathCount == 0) {
+				warning("TODO: cmdDead(RIVERDEATH[_game->_deathType]);");
+				return;
+			}
+		}
+		
+		if (_vm->_events->_mousePos.y >= 24 && _vm->_events->_mousePos.y <= 136) {
+			_vm->_events->hideCursor();
+			SCROLLRIVER1();
+			_vm->_events->pollEvents();
+		} else
+			SCROLLRIVER1();
+
+		while (!_vm->shouldQuit() && _vm->_events->_vbCount > 0) {
+			_vm->_events->pollEvents();
+			g_system->delayMillis(10);
+		}
+	}
+}
+
 void AmazonScripts::executeSpecial(int commandIndex, int param1, int param2) {
 	switch (commandIndex) {
 	case 1:
@@ -1612,7 +1713,7 @@ void AmazonScripts::executeSpecial(int commandIndex, int param1, int param2) {
 		plotInactive();
 		break;
 	case 13:
-		warning("TODO RIVER");
+		RIVER();
 		break;
 	case 14:
 		ANT();
diff --git a/engines/access/amazon/amazon_scripts.h b/engines/access/amazon/amazon_scripts.h
index 06fe56a..5c3fc0f 100644
--- a/engines/access/amazon/amazon_scripts.h
+++ b/engines/access/amazon/amazon_scripts.h
@@ -42,7 +42,8 @@ private:
 	int _yCam;
 	int _zCam;
 	int _pNumObj;
-
+	int _screenVertX;
+	bool CHICKENOUTFLG;
 	int _pImgNum[32];
 
 	SpriteResource *_pObject[32];
@@ -94,6 +95,15 @@ protected:
 	void ANT();
 	void doCast(int param1);
 	void loadBackground(int param1, int param2);
+	void initRiver();
+	bool JUMPTEST();
+	void RIVERSOUND();
+	void MOVECANOE();
+	void UPDATEOBSTACLES();
+	void SETPHYSX();
+	void RIVERCOLLIDE();
+	void SCROLLRIVER1();
+	void RIVER();
 	void plotInactive();
 	void setInactive();
 	void boatWalls(int param1, int param2);


Commit: 5cfdc983c38c6b470701be46209dacba06e537a0
    https://github.com/scummvm/scummvm/commit/5cfdc983c38c6b470701be46209dacba06e537a0
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-12T22:37:29-05:00

Commit Message:
ACCESS: Fix loading of animation at end of mWhileDoOpen

Changed paths:
    engines/access/amazon/amazon_scripts.cpp
    engines/access/scripts.cpp



diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp
index a45e6f7..bb8f8a9 100644
--- a/engines/access/amazon/amazon_scripts.cpp
+++ b/engines/access/amazon/amazon_scripts.cpp
@@ -749,7 +749,7 @@ void AmazonScripts::mWhileDoOpen() {
 	events.showCursor();
 	_vm->_buffer2.copyFrom(*_vm->_screen);
 	_vm->_buffer1.copyFrom(*_vm->_screen);
-	warning("TODO: delete _roomInfo;");
+	
 	_vm->freeCells();
 	_vm->_oldRects.clear();
 	_vm->_newRects.clear();
@@ -757,10 +757,15 @@ void AmazonScripts::mWhileDoOpen() {
 	_vm->_images.clear();
 
 	if (_vm->_conversation == 2) {
+		// Cutscene at end of Chapter 6
 		Resource *spriteData = _vm->_files->loadFile(28, 37);
 		_vm->_objectsTable[28] = new SpriteResource(_vm, spriteData);
 		delete spriteData;
-		warning("TODO: _roomInfo = _vm->_files->loadFile(28, 38);");
+		
+		_vm->_animation->freeAnimationData();
+		animResource = _vm->_files->loadFile(28, 38);
+		_vm->_animation->loadAnimations(animResource);
+		delete animResource;
 	}
 }
 
diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp
index b7ee4d2..9268b82 100644
--- a/engines/access/scripts.cpp
+++ b/engines/access/scripts.cpp
@@ -595,7 +595,6 @@ void Scripts::cmdTexChoice() {
 
 	Common::Array<Common::Rect> responseCoords;
 	responseCoords.push_back(_vm->_bubbleBox->_bounds);
-	responseCoords.push_back(Common::Rect(0, 0, 0, 0));
 	_vm->_screen->_printOrg.y = _vm->_bubbleBox->_bounds.bottom + 11;
 
 	findNull();
@@ -605,13 +604,12 @@ void Scripts::cmdTexChoice() {
 	while ((v = _data->readByte()) != 0)
 		tmpStr += (char)v;
 
-	Common::Rect termResponse2 = Common::Rect(-1, 0, 0, 0);
 	if (tmpStr.size() != 0) {
 		choice2Fl = true;
 		_vm->_bubbleBox->_bubblePtr = Common::String("RESPONSE 2").c_str();
 		_vm->_bubbleBox->calcBubble(tmpStr);
 		_vm->_bubbleBox->printBubble(tmpStr);
-		responseCoords[1] = _vm->_bubbleBox->_bounds;
+		responseCoords.push_back(_vm->_bubbleBox->_bounds);
 		_vm->_screen->_printOrg.y = _vm->_bubbleBox->_bounds.bottom + 11;
 	}
 
@@ -626,7 +624,7 @@ void Scripts::cmdTexChoice() {
 		_vm->_bubbleBox->_bubblePtr = Common::String("RESPONSE 3").c_str();
 		_vm->_bubbleBox->calcBubble(tmpStr);
 		_vm->_bubbleBox->printBubble(tmpStr);
-		termResponse2 = _vm->_bubbleBox->_bounds;
+		responseCoords.push_back(_vm->_bubbleBox->_bounds);
 		_vm->_screen->_printOrg.y = _vm->_bubbleBox->_bounds.bottom + 11;
 	}
 


Commit: 237404fa70e0aa75c0a9803830915d01bb763d43
    https://github.com/scummvm/scummvm/commit/237404fa70e0aa75c0a9803830915d01bb763d43
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-12T22:37:57-05:00

Commit Message:
ACCESS: Some more work on RIVER (still WIP)

Changed paths:
    engines/access/amazon/amazon_game.cpp
    engines/access/amazon/amazon_game.h
    engines/access/amazon/amazon_resources.cpp
    engines/access/amazon/amazon_resources.h
    engines/access/amazon/amazon_room.h
    engines/access/amazon/amazon_scripts.cpp
    engines/access/amazon/amazon_scripts.h
    engines/access/events.cpp
    engines/access/events.h
    engines/access/martian/martian_room.h
    engines/access/room.h



diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp
index f663f03..396ba42 100644
--- a/engines/access/amazon/amazon_game.cpp
+++ b/engines/access/amazon/amazon_game.cpp
@@ -775,13 +775,15 @@ void AmazonEngine::startChapter(int chapter) {
 void AmazonEngine::synchronize(Common::Serializer &s) {
 	AccessEngine::synchronize(s);
 
+	int dummy = 0;
+
 	s.syncAsSint16LE(_canoeLane);
 	s.syncAsSint16LE(_canoeYPos);
 	s.syncAsSint16LE(_hitCount);
 	s.syncAsSint16LE(_saveRiver);
 	s.syncAsSint16LE(_hitSafe);
 	s.syncAsSint16LE(_chapter);
-	s.syncAsSint16LE(_topList);
+	s.syncAsSint16LE(dummy);
 	s.syncAsSint16LE(_botList);
 	s.syncAsSint16LE(_riverIndex);
 	s.syncAsSint16LE(_rawInactiveX);
@@ -789,6 +791,8 @@ void AmazonEngine::synchronize(Common::Serializer &s) {
 	s.syncAsSint16LE(_inactiveYOff);
 	for (int i = 0; i < 100; ++i)
 		s.syncAsSint16LE(_esTabTable[i]);
+
+	warning("TODO: 	s.syncAsSint16LE(_topList);");
 }
 
 /*------------------------------------------------------------------------*/
diff --git a/engines/access/amazon/amazon_game.h b/engines/access/amazon/amazon_game.h
index f062a28..911ec55 100644
--- a/engines/access/amazon/amazon_game.h
+++ b/engines/access/amazon/amazon_game.h
@@ -55,13 +55,7 @@ public:
 class AmazonEngine : public AccessEngine {
 private:
 	// Fields that are included in savegames
-	int _canoeLane;
-	int _canoeYPos;
-	int _hitCount;
-	int _saveRiver;
-	int _topList;
 	int _botList;
-	int _riverIndex;
 	int _esTabTable[100];
 
 	// Other fields
@@ -108,6 +102,13 @@ public:
 	bool _charSegSwitch;
 	bool _skipStart;
 
+	int _canoeLane;
+	int _canoeYPos;
+	int _hitCount;
+	const byte *_topList;
+	int _riverIndex;
+	int _saveRiver;
+	int _canoeDir;
 	int _hitSafe;
 	int _rawInactiveX;
 	int _rawInactiveY;
@@ -142,7 +143,7 @@ public:
 	bool _deathFlag;
 	int _deathCount;
 	int _deathType;
-	int _mapPtr;
+	byte *_mapPtr;
 	int _canoeVXPos;
 	int _canoeMoveCount;
 	int _canoeFrame;
diff --git a/engines/access/amazon/amazon_resources.cpp b/engines/access/amazon/amazon_resources.cpp
index 925ea19..4df2c0c 100644
--- a/engines/access/amazon/amazon_resources.cpp
+++ b/engines/access/amazon/amazon_resources.cpp
@@ -1537,5 +1537,213 @@ const int openObj[10][4] = {
 	{4, -280, 40, 120},
 };
 
+const byte MAP0[26] = {
+	0, 0, 0, 1, 1, 1, 0, 0, 1, 0, 4, 0,
+	0, 0, 1, 0, 2, 0, 0, 1, 1, 3, 0, 0,
+	0, 0xFF
+};
+
+const byte MAP1[27] = {
+	0, 0, 1, 0, 3, 0, 0, 1, 1, 2, 0, 0,
+	0, 0, 1, 1, 1, 0, 0, 0, 1, 0, 4, 0,
+	0, 0, 0xFF
+};
+
+const byte MAP2[32] = {
+	0, 0, 0, 1, 0, 2, 0, 0, 0, 0, 1, 0,
+	3, 0, 0, 1, 0, 4, 0, 0, 1, 1, 2, 0,
+	0, 1, 0, 1, 0, 0, 0, 0xFF
+};
+
+const byte *MAPTBL[3] = {MAP0, MAP1, MAP2};
+
+const byte RIVER0OBJECTS[450] = {
+	16, 31, 0, 0, 25, 0, 0, 4, 12,
+	0, 16, 31, 0, 56, 24, 0, 0, 2,
+	12, 0, 17, 30, 0, 212, 23, 0, 0,
+	3, 15, 0, 16, 31, 0, 82, 23, 0,
+	0, 7, 12, 0, 17, 30, 0, 22, 23,
+	0, 0, 5, 15, 0, 17, 30, 0, 98,
+	22, 0, 0, 3, 15, 0, 16, 31, 0,
+	68, 22, 0, 0, 7, 12, 0, 255, 58,
+	1, 16, 21, 0, 0, 4, 0, 0, 17,
+	30, 0, 35, 20, 0, 0, 1, 15, 0,
+	16, 31, 0, 30, 20, 0, 0, 5, 12,
+	0, 16, 31, 0, 192, 19, 0, 0, 7,
+	12, 0, 17, 30, 0, 36, 19, 0, 0,
+	2, 15, 0, 17, 30, 0, 177, 18, 0,
+	0, 7, 15, 0, 16, 31, 0, 82, 18,
+	0, 0, 4, 12, 0, 16, 31, 0, 52,
+	18, 0, 0, 1, 12, 0, 17, 30, 0,
+	208, 17, 0, 0, 5, 15, 0, 16, 31,
+	0, 113, 17, 0, 0, 2, 12, 0, 255,
+	58, 1, 16, 16, 0, 0, 4, 0, 0,
+	17, 30, 0, 165, 15, 0, 0, 3, 15,
+	0, 16, 31, 0, 25, 15, 0, 0, 6,
+	12, 0, 17, 30, 0, 21, 14, 0, 0,
+	4, 15, 0, 16, 31, 0, 32, 13, 0,
+	0, 1, 12, 0, 17, 30, 0, 33, 12,
+	0, 0, 0, 15, 0, 16, 31, 0, 8,
+	12, 0, 0, 7, 12, 0, 17, 30, 0,
+	198, 11, 0, 0, 4, 15, 0, 16, 31,
+	0, 176, 11, 0, 0, 3, 12, 0, 16,
+	31, 0, 160, 11, 0, 0, 2, 12, 0,
+	17, 30, 0, 64, 11, 0, 0, 7, 15,
+	0, 17, 30, 0, 44, 11, 0, 0, 0,
+	15, 0, 255, 58, 1, 208, 9, 0, 0,
+	4, 0, 0, 17, 30, 0, 222, 8, 0,
+	0, 4, 15, 0, 16, 31, 0, 147, 8,
+	0, 0, 6, 12, 0, 17, 30, 0, 32,
+	7, 0, 0, 1, 15, 0, 16, 31, 0,
+	240, 6, 0, 0, 4, 12, 0, 17, 30,
+	0, 114, 6, 0, 0, 3, 15, 0, 16,
+	31, 0, 80, 6, 0, 0, 7, 12, 0,
+	17, 30, 0, 49, 6, 0, 0, 2, 15,
+	0, 255, 58, 1, 208, 4, 0, 0, 4,
+	0, 0, 17, 30, 0, 166, 4, 0, 0,
+	2, 15, 0, 16, 31, 0, 96, 4, 0,
+	0, 4, 12, 0, 17, 30, 0, 202, 3,
+	0, 0, 7, 15, 0, 16, 31, 0, 142,
+	3, 0, 0, 5, 12, 0, 17, 30, 0,
+	193, 2, 0, 0, 0, 15, 0, 16, 31,
+	0, 38, 2, 0, 0, 4, 12, 0, 17,
+	30, 0, 49, 1, 0, 0, 2, 15, 0
+};
+
+const byte ENDRIVER0[10] = {16, 31, 0, 4, 1, 0, 0, 7, 12, 0};
+
+const byte RIVER1OBJECTS[490] = {
+	16, 31, 0, 8, 27, 0, 0, 1, 12,
+	0, 16, 31, 0, 84, 26, 0, 0, 4,
+	12, 0, 17, 30, 0, 43, 26, 0, 0,
+	1, 15, 0, 16, 31, 0, 210, 25, 0,
+	0, 2, 12, 0, 17, 30, 0, 95, 25,
+	0, 0, 6, 15, 0, 17, 30, 0, 241,
+	24, 0, 0, 4, 15, 0, 16, 31, 0,
+	206, 24, 0, 0, 1, 12, 0, 17, 30,
+	0, 36, 24, 0, 0, 0, 15, 0, 255,
+	58, 1, 144, 23, 0, 0, 4, 0, 0,
+	16, 31, 0, 168, 22, 0, 0, 3, 12,
+	0, 17, 30, 0, 158, 22, 0, 0, 6,
+	15, 0, 16, 31, 0, 154, 21, 0, 0,
+	4, 12, 0, 16, 31, 0, 124, 21, 0,
+	0, 7, 12, 0, 17, 30, 0, 119, 21,
+	0, 0, 1, 15, 0, 17, 30, 0, 0,
+	21, 0, 0, 0, 15, 0, 16, 31, 0,
+	208, 20, 0, 0, 7, 12, 0, 17, 30,
+	0, 128, 20, 0, 0, 2, 15, 0, 16,
+	31, 0, 128, 20, 0, 0, 6, 12, 0,
+	255, 58, 1, 144, 18, 0, 0, 4, 0,
+	0, 17, 30, 0, 80, 17, 0, 0, 2,
+	15, 0, 16, 31, 0, 80, 17, 0, 0,
+	7, 12, 0, 16, 31, 0, 32, 17, 0,
+	0, 2, 12, 0, 17, 30, 0, 16, 17,
+	0, 0, 5, 15, 0, 16, 31, 0, 240,
+	16, 0, 0, 4, 12, 0, 17, 30, 0,
+	89, 16, 0, 0, 1, 15, 0, 16, 31,
+	0, 29, 16, 0, 0, 3, 12, 0, 17,
+	30, 0, 233, 14, 0, 0, 7, 15, 0,
+	16, 31, 0, 28, 14, 0, 0, 4, 12,
+	0, 16, 31, 0, 32, 13, 0, 0, 5,
+	12, 0, 16, 31, 0, 193, 12, 0, 0,
+	7, 12, 0, 17, 30, 0, 128, 12, 0,
+	0, 1, 15, 0, 17, 30, 0, 240, 11,
+	0, 0, 6, 15, 0, 255, 58, 1, 16,
+	11, 0, 0, 4, 0, 0, 16, 31, 0,
+	180, 10, 0, 0, 3, 12, 0, 17, 30,
+	0, 134, 10, 0, 0, 6, 15, 0, 16,
+	31, 0, 151, 9, 0, 0, 0, 12, 0,
+	17, 30, 0, 237, 8, 0, 0, 5, 15,
+	0, 16, 31, 0, 212, 8, 0, 0, 2,
+	12, 0, 16, 31, 0, 112, 7, 0, 0,
+	5, 12, 0, 17, 30, 0, 16, 7, 0,
+	0, 1, 15, 0, 16, 31, 0, 208, 6,
+	0, 0, 7, 12, 0, 17, 30, 0, 160,
+	6, 0, 0, 4, 15, 0, 16, 31, 0,
+	32, 6, 0, 0, 2, 12, 0, 255, 58,
+	1, 208, 4, 0, 0, 4, 0, 0, 17,
+	30, 0, 202, 3, 0, 0, 4, 15, 0,
+	16, 31, 0, 142, 3, 0, 0, 7, 12,
+	0, 17, 30, 0, 193, 2, 0, 0, 0,
+	15, 0, 16, 31, 0, 38, 2, 0, 0,
+	6, 12, 0, 17, 30, 0, 49, 1, 0,
+	0, 3, 15, 0
+};
+
+const byte ENDRIVER1[10] = {
+	16, 31, 0, 4, 1, 0, 0, 1, 12, 0
+};
+
+const byte RIVER2OBJECTS[530] = {
+	16, 31, 0, 38, 32, 0, 0, 6, 12,
+	0, 16, 31, 0, 179, 31, 0, 0, 7,
+	12, 0, 17, 30, 0, 19, 31, 0, 0,
+	4, 15, 0, 16, 31, 0, 210, 30, 0,
+	0, 0, 12, 0, 16, 31, 0, 192, 29,
+	0, 0, 2, 12, 0, 17, 30, 0, 48,
+	29, 0, 0, 5, 15, 0, 16, 31, 0,
+	1, 29, 0, 0, 4, 12, 0, 17, 30,
+	0, 192, 28, 0, 0, 1, 15, 0, 16,
+	31, 0, 160, 28, 0, 0, 6, 12, 0,
+	255, 58, 1, 80, 27, 0, 0, 4, 0,
+	0, 16, 31, 0, 64, 26, 0, 0, 3,
+	12, 0, 17, 30, 0, 44, 26, 0, 0,
+	6, 15, 0, 16, 31, 0, 118, 25, 0,
+	0, 2, 12, 0, 17, 30, 0, 81, 24,
+	0, 0, 5, 15, 0, 16, 31, 0, 56,
+	24, 0, 0, 2, 12, 0, 17, 30, 0,
+	102, 23, 0, 0, 1, 15, 0, 16, 31,
+	0, 72, 23, 0, 0, 7, 12, 0, 16,
+	31, 0, 68, 22, 0, 0, 2, 12, 0,
+	17, 30, 0, 18, 22, 0, 0, 4, 15,
+	0, 16, 31, 0, 192, 21, 0, 0, 5,
+	12, 0, 17, 30, 0, 112, 21, 0, 0,
+	6, 15, 0, 255, 58, 1, 208, 19, 0,
+	0, 4, 0, 0, 17, 30, 0, 217, 18,
+	0, 0, 4, 15, 0, 16, 31, 0, 174,
+	18, 0, 0, 2, 12, 0, 17, 30, 0,
+	52, 18, 0, 0, 5, 15, 0, 16, 31,
+	0, 158, 17, 0, 0, 7, 12, 0, 16,
+	31, 0, 143, 17, 0, 0, 1, 12, 0,
+	17, 30, 0, 154, 16, 0, 0, 2, 15,
+	0, 16, 31, 0, 99, 16, 0, 0, 4,
+	12, 0, 255, 58, 1, 208, 14, 0, 0,
+	4, 0, 0, 17, 30, 0, 16, 14, 0,
+	0, 3, 15, 0, 16, 31, 0, 142, 13,
+	0, 0, 5, 12, 0, 16, 31, 0, 94,
+	13, 0, 0, 2, 12, 0, 17, 30, 0,
+	98, 12, 0, 0, 6, 15, 0, 16, 31,
+	0, 144, 11, 0, 0, 4, 12, 0, 17,
+	30, 0, 139, 11, 0, 0, 7, 15, 0,
+	255, 58, 1, 208, 9, 0, 0, 4, 0,
+	0, 17, 30, 0, 111, 9, 0, 0, 1,
+	15, 0, 16, 31, 0, 14, 9, 0, 0,
+	0, 12, 0, 17, 30, 0, 227, 8, 0,
+	0, 2, 15, 0, 16, 31, 0, 222, 8,
+	0, 0, 6, 12, 0, 17, 30, 0, 234,
+	7, 0, 0, 3, 15, 0, 16, 31, 0,
+	208, 7, 0, 0, 0, 12, 0, 16, 31,
+	0, 48, 7, 0, 0, 3, 12, 0, 17,
+	30, 0, 3, 7, 0, 0, 7, 15, 0,
+	16, 31, 0, 98, 6, 0, 0, 5, 12,
+	0, 17, 30, 0, 94, 6, 0, 0, 1,
+	15, 0, 255, 58, 1, 208, 4, 0, 0,
+	4, 0, 0, 17, 30, 0, 202, 3, 0,
+	0, 2, 15, 0, 16, 31, 0, 142, 3,
+	0, 0, 5, 12, 0, 17, 30, 0, 193,
+	2, 0, 0, 0, 15, 0, 16, 31, 0,
+	38, 2, 0, 0, 4, 12, 0, 17, 30,
+	0, 49, 1, 0, 0, 3, 15, 0
+};
+
+const byte ENDRIVER2[10] = {
+	16, 31, 0, 4, 1, 0, 0, 6, 12, 0
+};
+
+const byte *RIVEROBJECTTBL[6] = {
+	RIVER0OBJECTS, ENDRIVER0, RIVER1OBJECTS, 
+	ENDRIVER1, RIVER2OBJECTS, ENDRIVER2
+};
+
 } // End of namespace Amazon
 } // End of namespace Access
diff --git a/engines/access/amazon/amazon_resources.h b/engines/access/amazon/amazon_resources.h
index 434a0f3..f7e1b03 100644
--- a/engines/access/amazon/amazon_resources.h
+++ b/engines/access/amazon/amazon_resources.h
@@ -83,6 +83,21 @@ extern const int TORCH[12];
 extern const int SPEAR[3];
 
 extern const int openObj[10][4];
+
+extern const byte MAP0[26];
+extern const byte MAP1[27];
+extern const byte MAP2[32];
+
+extern const byte *MAPTBL[3];
+
+extern const byte RIVER0OBJECTS[450];
+extern const byte ENDRIVER0[10];
+extern const byte RIVER1OBJECTS[490];
+extern const byte ENDRIVER1[10];
+extern const byte RIVER2OBJECTS[530];
+extern const byte ENDRIVER2[10];
+
+extern const byte *RIVEROBJECTTBL[6];
 } // End of namespace Amazon
 
 } // End of namespace Access
diff --git a/engines/access/amazon/amazon_room.h b/engines/access/amazon/amazon_room.h
index ccace1e..6b89a8f 100644
--- a/engines/access/amazon/amazon_room.h
+++ b/engines/access/amazon/amazon_room.h
@@ -50,8 +50,6 @@ protected:
 
 	virtual void setupRoom();
 
-	virtual void roomMenu();
-
 	virtual void mainAreaClick();
 
 public:
@@ -60,6 +58,8 @@ public:
 	virtual ~AmazonRoom();
 
 	virtual void init4Quads();
+	
+	virtual void roomMenu();
 };
 
 } // End of namespace Amazon
diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp
index bb8f8a9..2d46261 100644
--- a/engines/access/amazon/amazon_scripts.cpp
+++ b/engines/access/amazon/amazon_scripts.cpp
@@ -1590,8 +1590,92 @@ void AmazonScripts::plotInactive() {
 
 }
 
+void AmazonScripts::SETRIVERPAN() {
+	warning("TODO: SETRIVERPAN");
+}
+
 void AmazonScripts::initRiver() {
 	warning("TODO: initRiver()");
+
+	static const int RIVERVXTBL[3] = {6719, 7039, 8319};
+
+	_vm->_events->centerMousePos();
+	_vm->_events->restrictMouse();
+	_vm->_screen->setDisplayScan();
+	_vm->_screen->clearScreen();
+	_vm->_screen->savePalette();
+	_vm->_screen->forceFadeOut();
+
+	_vm->_files->_setPaletteFlag = false;
+	_vm->_files->loadScreen(95, 4);
+	_vm->_buffer2.copyFrom(*_vm->_screen);
+
+	_vm->_screen->restorePalette();
+	_vm->_screen->setBufferScan();
+	_vm->_destIn = &_vm->_buffer2;
+	_vm->_room->roomMenu();
+
+	if (_game->_saveRiver == 1) {
+		_vm->_screen->_scrollRow = _vm->_rScrollRow;
+		_vm->_screen->_scrollCol = _vm->_rScrollCol;
+		_vm->_screen->_scrollX = _vm->_rScrollX;
+		_vm->_screen->_scrollY = _vm->_rScrollY;
+	} else {
+		_vm->_screen->_scrollRow = 0;
+		_vm->_screen->_scrollCol = 140;
+		_vm->_screen->_scrollX = 0;
+		_vm->_screen->_scrollY = 0;
+	}
+
+	_vm->_room->buildScreen();
+	_vm->copyBF2Vid();
+	_vm->_screen->forceFadeIn();
+	if (_game->_saveRiver == 1) {
+		_vm->_oldRects.resize(_vm->_rOldRectCount);
+		_vm->_newRects.resize(_vm->_rNewRectCount);
+		// KEYFLG = _vm->_rKeyFlag
+	} else {
+		_vm->_oldRects.clear();
+		_vm->_newRects.clear();
+		// KEYFLG = 0
+	}
+
+	_vm->_player->_scrollAmount = 2;
+	SETRIVERPAN();
+	_game->_timers[3]._timer = 1;
+	_game->_timers[3]._initTm = 1;
+	++_game->_timers[3]._flag;
+
+	_game->_canoeFrame = 0;
+	_game->_mapPtr = (byte *)MAPTBL[_game->_riverFlag] + 1;
+	if (_game->_saveRiver == 1) {
+		_game->_mapPtr--;
+		_game->_mapPtr += _game->_mapOffset;
+	} else {
+		_screenVertX = RIVERVXTBL[_game->_riverFlag] - 320;
+		_game->_canoeLane = 3;
+		_game->_hitCount = 0;
+		_game->_hitSafe = 0;
+		_game->_canoeYPos = 71;
+	}
+
+	_game->_riverIndex = _game->_riverFlag;
+	_game->_topList = RIVEROBJECTTBL[_game->_riverIndex];
+	UPDATEOBSTACLES();
+	SETPHYSX();
+	_game->_canoeDir = 0;
+	_game->_deathFlag = 0;
+	_game->_deathCount = 0;
+
+	_game->_timers[11]._timer = 1200;
+	_game->_timers[11]._initTm = 1200;
+	++_game->_timers[11]._flag;
+	_game->_timers[12]._timer = 1500;
+	_game->_timers[12]._initTm = 1500;
+	++_game->_timers[12]._flag;
+	
+	_game->_maxHits = 2 - _game->_riverFlag;
+	_game->_saveRiver = 0;
 }
 
 bool AmazonScripts::JUMPTEST() {
diff --git a/engines/access/amazon/amazon_scripts.h b/engines/access/amazon/amazon_scripts.h
index 5c3fc0f..703e0b8 100644
--- a/engines/access/amazon/amazon_scripts.h
+++ b/engines/access/amazon/amazon_scripts.h
@@ -103,6 +103,7 @@ protected:
 	void SETPHYSX();
 	void RIVERCOLLIDE();
 	void SCROLLRIVER1();
+	void SETRIVERPAN();
 	void RIVER();
 	void plotInactive();
 	void setInactive();
diff --git a/engines/access/events.cpp b/engines/access/events.cpp
index ac07a75..fd43257 100644
--- a/engines/access/events.cpp
+++ b/engines/access/events.cpp
@@ -273,5 +273,12 @@ bool EventsManager::isKeyMousePressed() {
 	return result;
 }
 
+void EventsManager::centerMousePos() {
+	_mousePos = Common::Point(160, 100);
+}
+
+void EventsManager::restrictMouse() {
+	warning("TODO: restrictMouse");
+}
 
 } // End of namespace Access
diff --git a/engines/access/events.h b/engines/access/events.h
index 4888a27..d73f76a 100644
--- a/engines/access/events.h
+++ b/engines/access/events.h
@@ -126,6 +126,9 @@ public:
 	int checkMouseBox1(Common::Array<Common::Rect> &rects);
 
 	bool isKeyMousePressed();
+
+	void centerMousePos();
+	void restrictMouse();
 };
 
 } // End of namespace Access
diff --git a/engines/access/martian/martian_room.h b/engines/access/martian/martian_room.h
index 14744f5..85529ce 100644
--- a/engines/access/martian/martian_room.h
+++ b/engines/access/martian/martian_room.h
@@ -46,8 +46,6 @@ protected:
 
 	virtual void reloadRoom1();
 
-	virtual void roomMenu();
-
 	virtual void mainAreaClick();
 public:
 	MartianRoom(AccessEngine *vm);
@@ -58,6 +56,7 @@ public:
 
 	virtual void init4Quads() { }
 
+	virtual void roomMenu();
 };
 
 } // End of namespace Martian
diff --git a/engines/access/room.h b/engines/access/room.h
index 6c8b040..9b31366 100644
--- a/engines/access/room.h
+++ b/engines/access/room.h
@@ -116,8 +116,6 @@ protected:
 
 	virtual void doCommands();
 
-	virtual void roomMenu() = 0;
-
 	virtual void mainAreaClick() = 0;
 public:
 	Plotter _plotter;
@@ -141,6 +139,8 @@ public:
 
 	virtual void loadRoom(int roomNumber) = 0;
 
+	virtual void roomMenu() = 0;
+
 	/**
 	 * Clear all the data used by the room
 	 */


Commit: 1d70d61d2b9935c3d64711757e9da67091ba0bc2
    https://github.com/scummvm/scummvm/commit/1d70d61d2b9935c3d64711757e9da67091ba0bc2
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-12T22:38:12-05:00

Commit Message:
ACCESS: Implement setRiverPan

Changed paths:
    engines/access/amazon/amazon_scripts.cpp
    engines/access/amazon/amazon_scripts.h



diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp
index 2d46261..d3377f9 100644
--- a/engines/access/amazon/amazon_scripts.cpp
+++ b/engines/access/amazon/amazon_scripts.cpp
@@ -1590,13 +1590,57 @@ void AmazonScripts::plotInactive() {
 
 }
 
-void AmazonScripts::SETRIVERPAN() {
-	warning("TODO: SETRIVERPAN");
+void AmazonScripts::setRiverPan() {
+	static const int RIVER1OBJ[23][4] = {
+		{18,   -77,  0, 30},
+		{18,  -325,  0, 20},
+		{18,  -450,  0, 15},
+		{18, -1250,  0, 25},
+		{19,  -130,  0, 20},
+		{19,  -410,  0, 15},
+		{19,  -710,  0, 25},
+		{19, -1510,  0, 20},
+		{20,  -350,  0, 30},
+		{20,  -695,  0, 25},
+		{20,  -990,  0, 20},
+		{20, -1300,  0, 25},
+		{20, -1600,  0, 30},
+		{21,  -370,  0, 20},
+		{21,  -650,  0, 30},
+		{21, -1215,  0, 40},
+		{21, -1815,  0, 35},
+		{22,  -380,  0, 25},
+		{22,  -720,  0, 35},
+		{22, -1020,  0, 30},
+		{22, -1170,  0, 25},
+		{22, -1770,  0, 35},
+		{23,  -500, 63, 20}
+	};
+
+	int delta = (_vm->_screen->_scrollCol * 16) + _vm->_screen->_scrollX;
+
+	_xTrack = 9;
+	_yTrack = _zTrack = 0;
+	_xCam = 160;
+	_yCam = 0;
+	_zCam = 80;
+
+	_game->_timers[24]._timer = 1;
+	_game->_timers[24]._initTm = 1;
+	++_game->_timers[24]._flag;
+
+	_pNumObj = 23;
+	for (int i = 0; i < _pNumObj; i++) {
+		_pObject[i] = _vm->_objectsTable[45];
+		_pImgNum[i] = RIVER1OBJ[i][0];
+		_pObjX[i] = RIVER1OBJ[i][1] + delta;
+		_pObjY[i] = RIVER1OBJ[i][2];
+		_pObjZ[i] = RIVER1OBJ[i][3];
+		_pObjXl[i] = _pObjYl[i] = 0;
+	}
 }
 
 void AmazonScripts::initRiver() {
-	warning("TODO: initRiver()");
-
 	static const int RIVERVXTBL[3] = {6719, 7039, 8319};
 
 	_vm->_events->centerMousePos();
@@ -1641,7 +1685,7 @@ void AmazonScripts::initRiver() {
 	}
 
 	_vm->_player->_scrollAmount = 2;
-	SETRIVERPAN();
+	setRiverPan();
 	_game->_timers[3]._timer = 1;
 	_game->_timers[3]._initTm = 1;
 	++_game->_timers[3]._flag;
diff --git a/engines/access/amazon/amazon_scripts.h b/engines/access/amazon/amazon_scripts.h
index 703e0b8..08ad23d 100644
--- a/engines/access/amazon/amazon_scripts.h
+++ b/engines/access/amazon/amazon_scripts.h
@@ -103,7 +103,7 @@ protected:
 	void SETPHYSX();
 	void RIVERCOLLIDE();
 	void SCROLLRIVER1();
-	void SETRIVERPAN();
+	void setRiverPan();
 	void RIVER();
 	void plotInactive();
 	void setInactive();


Commit: 1d60368724198d9c5fd201ab628ef46d285bb73b
    https://github.com/scummvm/scummvm/commit/1d60368724198d9c5fd201ab628ef46d285bb73b
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-12T22:38:22-05:00

Commit Message:
ACCESS: Tweaks to mWhileDoOpen and fixes to pan method

Changed paths:
    engines/access/amazon/amazon_resources.cpp
    engines/access/amazon/amazon_resources.h
    engines/access/amazon/amazon_scripts.cpp



diff --git a/engines/access/amazon/amazon_resources.cpp b/engines/access/amazon/amazon_resources.cpp
index 4df2c0c..ead6410 100644
--- a/engines/access/amazon/amazon_resources.cpp
+++ b/engines/access/amazon/amazon_resources.cpp
@@ -1524,7 +1524,7 @@ const int TORCH[12] = {
 
 const int SPEAR[3] = {30, -13, 1};
 
-const int openObj[10][4] = {
+const int OPENING_OBJS[10][4] = {
 	{8, -80, 120, 30},
 	{13, 229, 0, 50},
 	{12, 78, 0, 50},
@@ -1746,4 +1746,5 @@ const byte *RIVEROBJECTTBL[6] = {
 };
 
 } // End of namespace Amazon
+
 } // End of namespace Access
diff --git a/engines/access/amazon/amazon_resources.h b/engines/access/amazon/amazon_resources.h
index f7e1b03..b29bdab 100644
--- a/engines/access/amazon/amazon_resources.h
+++ b/engines/access/amazon/amazon_resources.h
@@ -82,7 +82,7 @@ extern const int TORCH[12];
 
 extern const int SPEAR[3];
 
-extern const int openObj[10][4];
+extern const int OPENING_OBJS[10][4];
 
 extern const byte MAP0[26];
 extern const byte MAP1[27];
@@ -98,6 +98,7 @@ extern const byte RIVER2OBJECTS[530];
 extern const byte ENDRIVER2[10];
 
 extern const byte *RIVEROBJECTTBL[6];
+
 } // End of namespace Amazon
 
 } // End of namespace Access
diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp
index d3377f9..d4018c2 100644
--- a/engines/access/amazon/amazon_scripts.cpp
+++ b/engines/access/amazon/amazon_scripts.cpp
@@ -425,9 +425,12 @@ void AmazonScripts::pan() {
 		for (int i = 0; i < _pNumObj; i++) {
 			_pObjZ[i] += _zTrack;
 			_pObjXl[i] += (_pObjZ[i] * tx) & 0xff;
-			_pObjX[i] += (_pObjZ[i] * tx) >> 8;
+			_pObjX[i] += (_pObjZ[i] * tx) >> 8 + (_pObjXl[i] >> 8);
+			_pObjXl[i] &= 0xff;
+
 			_pObjYl[i] += (_pObjZ[i] * ty) & 0xff;
-			_pObjY[i] += (_pObjZ[i] * ty) >> 8;
+			_pObjY[i] += (_pObjZ[i] * ty) >> 8 + (_pObjYl[i] >> 8);
+			_pObjYl[i] &= 0xff;
 		}
 	}
 
@@ -435,7 +438,7 @@ void AmazonScripts::pan() {
 		ImageEntry ie;
 		ie._flags= 8;
 		ie._position = Common::Point(_pObjX[i], _pObjY[i]);
-		ie._offsetY = 0xFF;
+		ie._offsetY = 255;
 		ie._spritesPtr = _pObject[i];
 		ie._frameNumber = _pImgNum[i];
 
@@ -666,16 +669,16 @@ void AmazonScripts::mWhileDoOpen() {
 	screen.forceFadeOut();
 	_game->_skipStart = false;
 	if (_vm->_conversation != 2) {
+		// Cutscene at start of chapter 1
 		screen.setPanel(3);
 		_game->startChapter(1);
 		_game->establishCenter(0, 1);
 	}
 
 	Resource *data = _vm->_files->loadFile(1, 0);
-	SpriteResource *spr = new SpriteResource(_vm, data);
+	_vm->_objectsTable[1] = new SpriteResource(_vm, data);
 	delete data;
 
-	_vm->_objectsTable[1] = spr;
 	_vm->_files->_setPaletteFlag = false;
 	_vm->_files->loadScreen(1, 2);
 	_vm->_buffer2.copyFrom(*_vm->_screen);
@@ -698,10 +701,10 @@ void AmazonScripts::mWhileDoOpen() {
 
 	for (int i = 0; i < _pNumObj; i++) {
 		_pObject[i] = _vm->_objectsTable[1];
-		_pImgNum[i] = openObj[i][0];
-		_pObjX[i] = openObj[i][1];
-		_pObjY[i] = openObj[i][2];
-		_pObjZ[i] = openObj[i][3];
+		_pImgNum[i] = OPENING_OBJS[i][0];
+		_pObjX[i] = OPENING_OBJS[i][1];
+		_pObjY[i] = OPENING_OBJS[i][2];
+		_pObjZ[i] = OPENING_OBJS[i][3];
 		_pObjXl[i] = _pObjYl[i] = 0;
 	}
 
@@ -727,11 +730,14 @@ void AmazonScripts::mWhileDoOpen() {
 			startFl = true;
 			screen.forceFadeIn();
 		}
-		events.pollEvents();
-		warning("TODO: check on KEYBUFCNT");
-		if (events._leftButton || events._rightButton) {
+
+		events.pollEvents();		
+		if (events._leftButton || events._rightButton || events._keypresses.size() > 0) {
 			_game->_skipStart = true;
 			_vm->_sound->newMusic(10, 1);
+
+			events.debounceLeft();
+			events.zeroKeys();
 			break;
 		}
 


Commit: 30f602b6cb265000d4ac95e645598d324e3d5d49
    https://github.com/scummvm/scummvm/commit/30f602b6cb265000d4ac95e645598d324e3d5d49
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-12T22:38:31-05:00

Commit Message:
ACCESS: Further fixes for panning

Changed paths:
    engines/access/access.cpp
    engines/access/access.h
    engines/access/amazon/amazon_scripts.cpp
    engines/access/asurface.h



diff --git a/engines/access/access.cpp b/engines/access/access.cpp
index b309e92..e87b647 100644
--- a/engines/access/access.cpp
+++ b/engines/access/access.cpp
@@ -72,7 +72,7 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc)
 	_scaleT1 = 0;
 	_scaleMaxY = 0;
 	_scaleI = 0;
-	_scaleFlag = false;
+	_imgUnscaled = false;
 	_canSaveLoad = false;
 	_eseg = nullptr;
 
@@ -351,13 +351,13 @@ void AccessEngine::plotList1() {
 	for (uint idx = 0; idx < _images.size(); ++idx) {
 		ImageEntry &ie = _images[idx];
 
-		_scaleFlag = (ie._flags & 8) != 0;
+		_imgUnscaled = (ie._flags & IMGFLAG_UNSCALED) != 0;
 		Common::Point pt = ie._position - _screen->_bufferStart;
 		SpriteResource *sprites = ie._spritesPtr;
 		SpriteFrame *frame = sprites->getFrame(ie._frameNumber);
 
 		Common::Rect bounds(pt.x, pt.y, pt.x + frame->w, pt.y + frame->h);
-		if (!_scaleFlag) {
+		if (!_imgUnscaled) {
 			bounds.setWidth(_screen->_scaleTable1[frame->w]);
 			bounds.setHeight(_screen->_scaleTable1[frame->h]);
 		}
@@ -376,7 +376,7 @@ void AccessEngine::plotList1() {
 
 			_newRects.push_back(bounds);
 
-			if (!_scaleFlag) {
+			if (!_imgUnscaled) {
 				_buffer2._rightSkip /= _scale;
 				bounds.setWidth(bounds.width() / _scale);
 
@@ -386,7 +386,7 @@ void AccessEngine::plotList1() {
 					_buffer2.sPlotF(frame, destBounds);
 				}
 			} else {
-				if (ie._flags & 2) {
+				if (ie._flags & IMGFLAG_BACKWARDS) {
 					_buffer2.plotB(frame, Common::Point(destBounds.left, destBounds.top));
 				} else {
 					_buffer2.plotF(frame, Common::Point(destBounds.left, destBounds.top));
diff --git a/engines/access/access.h b/engines/access/access.h
index 36951c7..805abcc 100644
--- a/engines/access/access.h
+++ b/engines/access/access.h
@@ -189,7 +189,7 @@ public:
 	int _scaleT1;
 	int _scaleMaxY;
 	int _scaleI;
-	bool _scaleFlag;
+	bool _imgUnscaled;
 	bool _canSaveLoad;
 
 	Resource *_eseg;
diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp
index d4018c2..4d35401 100644
--- a/engines/access/amazon/amazon_scripts.cpp
+++ b/engines/access/amazon/amazon_scripts.cpp
@@ -425,11 +425,11 @@ void AmazonScripts::pan() {
 		for (int i = 0; i < _pNumObj; i++) {
 			_pObjZ[i] += _zTrack;
 			_pObjXl[i] += (_pObjZ[i] * tx) & 0xff;
-			_pObjX[i] += (_pObjZ[i] * tx) >> 8 + (_pObjXl[i] >> 8);
+			_pObjX[i] += ((_pObjZ[i] * tx) >> 8) + (_pObjXl[i] >> 8);
 			_pObjXl[i] &= 0xff;
 
 			_pObjYl[i] += (_pObjZ[i] * ty) & 0xff;
-			_pObjY[i] += (_pObjZ[i] * ty) >> 8 + (_pObjYl[i] >> 8);
+			_pObjY[i] += ((_pObjZ[i] * ty) >> 8) + (_pObjYl[i] >> 8);
 			_pObjYl[i] &= 0xff;
 		}
 	}
@@ -697,8 +697,9 @@ void AmazonScripts::mWhileDoOpen() {
 	_zCam = 270;
 	_vm->_timers[24]._timer = _vm->_timers[24]._initTm = 1;
 	++_vm->_timers[24]._flag;
-	_pNumObj = 10;
+	_vm->_timers.updateTimers();
 
+	_pNumObj = 10;
 	for (int i = 0; i < _pNumObj; i++) {
 		_pObject[i] = _vm->_objectsTable[1];
 		_pImgNum[i] = OPENING_OBJS[i][0];
@@ -731,7 +732,9 @@ void AmazonScripts::mWhileDoOpen() {
 			screen.forceFadeIn();
 		}
 
-		events.pollEvents();		
+		events.pollEvents();
+		g_system->delayMillis(10);
+
 		if (events._leftButton || events._rightButton || events._keypresses.size() > 0) {
 			_game->_skipStart = true;
 			_vm->_sound->newMusic(10, 1);
diff --git a/engines/access/asurface.h b/engines/access/asurface.h
index d066589..1c30db8 100644
--- a/engines/access/asurface.h
+++ b/engines/access/asurface.h
@@ -131,6 +131,8 @@ public:
 	SpriteFrame *getFrame(int idx) { return _frames[idx]; }
 };
 
+enum ImageFlag { IMGFLAG_BACKWARDS = 2, IMGFLAG_UNSCALED = 8 };
+
 class ImageEntry {
 public:
 	int _frameNumber;


Commit: c1b3db90c49de5c2925cf65dfa49889dd2941164
    https://github.com/scummvm/scummvm/commit/c1b3db90c49de5c2925cf65dfa49889dd2941164
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-12T22:38:39-05:00

Commit Message:
ACCESS: Implement riverSound

Changed paths:
    engines/access/amazon/amazon_scripts.cpp
    engines/access/amazon/amazon_scripts.h



diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp
index 4d35401..6138768 100644
--- a/engines/access/amazon/amazon_scripts.cpp
+++ b/engines/access/amazon/amazon_scripts.cpp
@@ -1733,11 +1733,23 @@ void AmazonScripts::initRiver() {
 
 bool AmazonScripts::JUMPTEST() {
 	warning("TODO: JUMPTEST();");
+
 	return true;
 }
 
-void AmazonScripts::RIVERSOUND() {
-	warning("TODO: RIVERSOUND();");
+void AmazonScripts::riverSound() {
+	if (_game->_timers[11]._flag == 0) {
+		++_game->_timers[11]._flag;
+		_vm->_sound->playSound(2);
+	}
+
+	if (_game->_timers[12]._flag == 0) {
+		++_game->_timers[12]._flag;
+		_vm->_sound->playSound(3);
+	}
+
+	if ((_xCam >= 1300) && (_xCam <= 1320))
+		_vm->_sound->playSound(1);
 }
 
 void AmazonScripts::MOVECANOE() {
@@ -1786,7 +1798,7 @@ void AmazonScripts::RIVER() {
 		_vm->_images.clear();
 		_vm->_animation->animate(0);
 
-		RIVERSOUND();
+		riverSound();
 		pan();
 		MOVECANOE();
 
diff --git a/engines/access/amazon/amazon_scripts.h b/engines/access/amazon/amazon_scripts.h
index 08ad23d..7162bab 100644
--- a/engines/access/amazon/amazon_scripts.h
+++ b/engines/access/amazon/amazon_scripts.h
@@ -97,7 +97,7 @@ protected:
 	void loadBackground(int param1, int param2);
 	void initRiver();
 	bool JUMPTEST();
-	void RIVERSOUND();
+	void riverSound();
 	void MOVECANOE();
 	void UPDATEOBSTACLES();
 	void SETPHYSX();


Commit: 7fbd145f5db82c002a213f57de8839c4decdc427
    https://github.com/scummvm/scummvm/commit/7fbd145f5db82c002a213f57de8839c4decdc427
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-12T22:38:49-05:00

Commit Message:
ACCESS: Use a new structure instead of a byte array for River Objects

Changed paths:
    engines/access/amazon/amazon_game.cpp
    engines/access/amazon/amazon_game.h
    engines/access/amazon/amazon_resources.cpp
    engines/access/amazon/amazon_resources.h



diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp
index 396ba42..def64f2 100644
--- a/engines/access/amazon/amazon_game.cpp
+++ b/engines/access/amazon/amazon_game.cpp
@@ -48,8 +48,8 @@ AmazonEngine::AmazonEngine(OSystem *syst, const AccessGameDescription *gameDesc)
 	_hitSafe = 0;
 	_oldTitleChapter = _chapter = 0;
 	_updateChapter = -1;
-	_topList = 0;
-	_botList = 0;
+	_topList = nullptr;
+	_botList = nullptr;
 	_riverIndex = 0;
 	_rawInactiveX = 0;
 	_rawInactiveY = 0;
@@ -784,7 +784,7 @@ void AmazonEngine::synchronize(Common::Serializer &s) {
 	s.syncAsSint16LE(_hitSafe);
 	s.syncAsSint16LE(_chapter);
 	s.syncAsSint16LE(dummy);
-	s.syncAsSint16LE(_botList);
+	s.syncAsSint16LE(dummy);
 	s.syncAsSint16LE(_riverIndex);
 	s.syncAsSint16LE(_rawInactiveX);
 	s.syncAsSint16LE(_rawInactiveY);
@@ -793,6 +793,7 @@ void AmazonEngine::synchronize(Common::Serializer &s) {
 		s.syncAsSint16LE(_esTabTable[i]);
 
 	warning("TODO: 	s.syncAsSint16LE(_topList);");
+	warning("TODO: 	s.syncAsSint16LE(_botList);");
 }
 
 /*------------------------------------------------------------------------*/
diff --git a/engines/access/amazon/amazon_game.h b/engines/access/amazon/amazon_game.h
index 911ec55..3b8b981 100644
--- a/engines/access/amazon/amazon_game.h
+++ b/engines/access/amazon/amazon_game.h
@@ -55,7 +55,6 @@ public:
 class AmazonEngine : public AccessEngine {
 private:
 	// Fields that are included in savegames
-	int _botList;
 	int _esTabTable[100];
 
 	// Other fields
@@ -105,7 +104,8 @@ public:
 	int _canoeLane;
 	int _canoeYPos;
 	int _hitCount;
-	const byte *_topList;
+	const RiverStruct *_topList;
+	const RiverStruct *_botList;
 	int _riverIndex;
 	int _saveRiver;
 	int _canoeDir;
diff --git a/engines/access/amazon/amazon_resources.cpp b/engines/access/amazon/amazon_resources.cpp
index ead6410..192af2c 100644
--- a/engines/access/amazon/amazon_resources.cpp
+++ b/engines/access/amazon/amazon_resources.cpp
@@ -1557,190 +1557,169 @@ const byte MAP2[32] = {
 
 const byte *MAPTBL[3] = {MAP0, MAP1, MAP2};
 
-const byte RIVER0OBJECTS[450] = {
-	16, 31, 0, 0, 25, 0, 0, 4, 12,
-	0, 16, 31, 0, 56, 24, 0, 0, 2,
-	12, 0, 17, 30, 0, 212, 23, 0, 0,
-	3, 15, 0, 16, 31, 0, 82, 23, 0,
-	0, 7, 12, 0, 17, 30, 0, 22, 23,
-	0, 0, 5, 15, 0, 17, 30, 0, 98,
-	22, 0, 0, 3, 15, 0, 16, 31, 0,
-	68, 22, 0, 0, 7, 12, 0, 255, 58,
-	1, 16, 21, 0, 0, 4, 0, 0, 17,
-	30, 0, 35, 20, 0, 0, 1, 15, 0,
-	16, 31, 0, 30, 20, 0, 0, 5, 12,
-	0, 16, 31, 0, 192, 19, 0, 0, 7,
-	12, 0, 17, 30, 0, 36, 19, 0, 0,
-	2, 15, 0, 17, 30, 0, 177, 18, 0,
-	0, 7, 15, 0, 16, 31, 0, 82, 18,
-	0, 0, 4, 12, 0, 16, 31, 0, 52,
-	18, 0, 0, 1, 12, 0, 17, 30, 0,
-	208, 17, 0, 0, 5, 15, 0, 16, 31,
-	0, 113, 17, 0, 0, 2, 12, 0, 255,
-	58, 1, 16, 16, 0, 0, 4, 0, 0,
-	17, 30, 0, 165, 15, 0, 0, 3, 15,
-	0, 16, 31, 0, 25, 15, 0, 0, 6,
-	12, 0, 17, 30, 0, 21, 14, 0, 0,
-	4, 15, 0, 16, 31, 0, 32, 13, 0,
-	0, 1, 12, 0, 17, 30, 0, 33, 12,
-	0, 0, 0, 15, 0, 16, 31, 0, 8,
-	12, 0, 0, 7, 12, 0, 17, 30, 0,
-	198, 11, 0, 0, 4, 15, 0, 16, 31,
-	0, 176, 11, 0, 0, 3, 12, 0, 16,
-	31, 0, 160, 11, 0, 0, 2, 12, 0,
-	17, 30, 0, 64, 11, 0, 0, 7, 15,
-	0, 17, 30, 0, 44, 11, 0, 0, 0,
-	15, 0, 255, 58, 1, 208, 9, 0, 0,
-	4, 0, 0, 17, 30, 0, 222, 8, 0,
-	0, 4, 15, 0, 16, 31, 0, 147, 8,
-	0, 0, 6, 12, 0, 17, 30, 0, 32,
-	7, 0, 0, 1, 15, 0, 16, 31, 0,
-	240, 6, 0, 0, 4, 12, 0, 17, 30,
-	0, 114, 6, 0, 0, 3, 15, 0, 16,
-	31, 0, 80, 6, 0, 0, 7, 12, 0,
-	17, 30, 0, 49, 6, 0, 0, 2, 15,
-	0, 255, 58, 1, 208, 4, 0, 0, 4,
-	0, 0, 17, 30, 0, 166, 4, 0, 0,
-	2, 15, 0, 16, 31, 0, 96, 4, 0,
-	0, 4, 12, 0, 17, 30, 0, 202, 3,
-	0, 0, 7, 15, 0, 16, 31, 0, 142,
-	3, 0, 0, 5, 12, 0, 17, 30, 0,
-	193, 2, 0, 0, 0, 15, 0, 16, 31,
-	0, 38, 2, 0, 0, 4, 12, 0, 17,
-	30, 0, 49, 1, 0, 0, 2, 15, 0
-};
-
-const byte ENDRIVER0[10] = {16, 31, 0, 4, 1, 0, 0, 7, 12, 0};
-
-const byte RIVER1OBJECTS[490] = {
-	16, 31, 0, 8, 27, 0, 0, 1, 12,
-	0, 16, 31, 0, 84, 26, 0, 0, 4,
-	12, 0, 17, 30, 0, 43, 26, 0, 0,
-	1, 15, 0, 16, 31, 0, 210, 25, 0,
-	0, 2, 12, 0, 17, 30, 0, 95, 25,
-	0, 0, 6, 15, 0, 17, 30, 0, 241,
-	24, 0, 0, 4, 15, 0, 16, 31, 0,
-	206, 24, 0, 0, 1, 12, 0, 17, 30,
-	0, 36, 24, 0, 0, 0, 15, 0, 255,
-	58, 1, 144, 23, 0, 0, 4, 0, 0,
-	16, 31, 0, 168, 22, 0, 0, 3, 12,
-	0, 17, 30, 0, 158, 22, 0, 0, 6,
-	15, 0, 16, 31, 0, 154, 21, 0, 0,
-	4, 12, 0, 16, 31, 0, 124, 21, 0,
-	0, 7, 12, 0, 17, 30, 0, 119, 21,
-	0, 0, 1, 15, 0, 17, 30, 0, 0,
-	21, 0, 0, 0, 15, 0, 16, 31, 0,
-	208, 20, 0, 0, 7, 12, 0, 17, 30,
-	0, 128, 20, 0, 0, 2, 15, 0, 16,
-	31, 0, 128, 20, 0, 0, 6, 12, 0,
-	255, 58, 1, 144, 18, 0, 0, 4, 0,
-	0, 17, 30, 0, 80, 17, 0, 0, 2,
-	15, 0, 16, 31, 0, 80, 17, 0, 0,
-	7, 12, 0, 16, 31, 0, 32, 17, 0,
-	0, 2, 12, 0, 17, 30, 0, 16, 17,
-	0, 0, 5, 15, 0, 16, 31, 0, 240,
-	16, 0, 0, 4, 12, 0, 17, 30, 0,
-	89, 16, 0, 0, 1, 15, 0, 16, 31,
-	0, 29, 16, 0, 0, 3, 12, 0, 17,
-	30, 0, 233, 14, 0, 0, 7, 15, 0,
-	16, 31, 0, 28, 14, 0, 0, 4, 12,
-	0, 16, 31, 0, 32, 13, 0, 0, 5,
-	12, 0, 16, 31, 0, 193, 12, 0, 0,
-	7, 12, 0, 17, 30, 0, 128, 12, 0,
-	0, 1, 15, 0, 17, 30, 0, 240, 11,
-	0, 0, 6, 15, 0, 255, 58, 1, 16,
-	11, 0, 0, 4, 0, 0, 16, 31, 0,
-	180, 10, 0, 0, 3, 12, 0, 17, 30,
-	0, 134, 10, 0, 0, 6, 15, 0, 16,
-	31, 0, 151, 9, 0, 0, 0, 12, 0,
-	17, 30, 0, 237, 8, 0, 0, 5, 15,
-	0, 16, 31, 0, 212, 8, 0, 0, 2,
-	12, 0, 16, 31, 0, 112, 7, 0, 0,
-	5, 12, 0, 17, 30, 0, 16, 7, 0,
-	0, 1, 15, 0, 16, 31, 0, 208, 6,
-	0, 0, 7, 12, 0, 17, 30, 0, 160,
-	6, 0, 0, 4, 15, 0, 16, 31, 0,
-	32, 6, 0, 0, 2, 12, 0, 255, 58,
-	1, 208, 4, 0, 0, 4, 0, 0, 17,
-	30, 0, 202, 3, 0, 0, 4, 15, 0,
-	16, 31, 0, 142, 3, 0, 0, 7, 12,
-	0, 17, 30, 0, 193, 2, 0, 0, 0,
-	15, 0, 16, 31, 0, 38, 2, 0, 0,
-	6, 12, 0, 17, 30, 0, 49, 1, 0,
-	0, 3, 15, 0
-};
-
-const byte ENDRIVER1[10] = {
-	16, 31, 0, 4, 1, 0, 0, 1, 12, 0
-};
-
-const byte RIVER2OBJECTS[530] = {
-	16, 31, 0, 38, 32, 0, 0, 6, 12,
-	0, 16, 31, 0, 179, 31, 0, 0, 7,
-	12, 0, 17, 30, 0, 19, 31, 0, 0,
-	4, 15, 0, 16, 31, 0, 210, 30, 0,
-	0, 0, 12, 0, 16, 31, 0, 192, 29,
-	0, 0, 2, 12, 0, 17, 30, 0, 48,
-	29, 0, 0, 5, 15, 0, 16, 31, 0,
-	1, 29, 0, 0, 4, 12, 0, 17, 30,
-	0, 192, 28, 0, 0, 1, 15, 0, 16,
-	31, 0, 160, 28, 0, 0, 6, 12, 0,
-	255, 58, 1, 80, 27, 0, 0, 4, 0,
-	0, 16, 31, 0, 64, 26, 0, 0, 3,
-	12, 0, 17, 30, 0, 44, 26, 0, 0,
-	6, 15, 0, 16, 31, 0, 118, 25, 0,
-	0, 2, 12, 0, 17, 30, 0, 81, 24,
-	0, 0, 5, 15, 0, 16, 31, 0, 56,
-	24, 0, 0, 2, 12, 0, 17, 30, 0,
-	102, 23, 0, 0, 1, 15, 0, 16, 31,
-	0, 72, 23, 0, 0, 7, 12, 0, 16,
-	31, 0, 68, 22, 0, 0, 2, 12, 0,
-	17, 30, 0, 18, 22, 0, 0, 4, 15,
-	0, 16, 31, 0, 192, 21, 0, 0, 5,
-	12, 0, 17, 30, 0, 112, 21, 0, 0,
-	6, 15, 0, 255, 58, 1, 208, 19, 0,
-	0, 4, 0, 0, 17, 30, 0, 217, 18,
-	0, 0, 4, 15, 0, 16, 31, 0, 174,
-	18, 0, 0, 2, 12, 0, 17, 30, 0,
-	52, 18, 0, 0, 5, 15, 0, 16, 31,
-	0, 158, 17, 0, 0, 7, 12, 0, 16,
-	31, 0, 143, 17, 0, 0, 1, 12, 0,
-	17, 30, 0, 154, 16, 0, 0, 2, 15,
-	0, 16, 31, 0, 99, 16, 0, 0, 4,
-	12, 0, 255, 58, 1, 208, 14, 0, 0,
-	4, 0, 0, 17, 30, 0, 16, 14, 0,
-	0, 3, 15, 0, 16, 31, 0, 142, 13,
-	0, 0, 5, 12, 0, 16, 31, 0, 94,
-	13, 0, 0, 2, 12, 0, 17, 30, 0,
-	98, 12, 0, 0, 6, 15, 0, 16, 31,
-	0, 144, 11, 0, 0, 4, 12, 0, 17,
-	30, 0, 139, 11, 0, 0, 7, 15, 0,
-	255, 58, 1, 208, 9, 0, 0, 4, 0,
-	0, 17, 30, 0, 111, 9, 0, 0, 1,
-	15, 0, 16, 31, 0, 14, 9, 0, 0,
-	0, 12, 0, 17, 30, 0, 227, 8, 0,
-	0, 2, 15, 0, 16, 31, 0, 222, 8,
-	0, 0, 6, 12, 0, 17, 30, 0, 234,
-	7, 0, 0, 3, 15, 0, 16, 31, 0,
-	208, 7, 0, 0, 0, 12, 0, 16, 31,
-	0, 48, 7, 0, 0, 3, 12, 0, 17,
-	30, 0, 3, 7, 0, 0, 7, 15, 0,
-	16, 31, 0, 98, 6, 0, 0, 5, 12,
-	0, 17, 30, 0, 94, 6, 0, 0, 1,
-	15, 0, 255, 58, 1, 208, 4, 0, 0,
-	4, 0, 0, 17, 30, 0, 202, 3, 0,
-	0, 2, 15, 0, 16, 31, 0, 142, 3,
-	0, 0, 5, 12, 0, 17, 30, 0, 193,
-	2, 0, 0, 0, 15, 0, 16, 31, 0,
-	38, 2, 0, 0, 4, 12, 0, 17, 30,
-	0, 49, 1, 0, 0, 3, 15, 0
-};
-
-const byte ENDRIVER2[10] = {
-	16, 31, 0, 4, 1, 0, 0, 6, 12, 0
-};
-
-const byte *RIVEROBJECTTBL[6] = {
+const RiverStruct RIVER0OBJECTS[45] = {
+	{16,  31, 6400, 0, 4, 12},
+	{16,  31, 6200, 0, 2, 12},
+	{17,  30, 6100, 0, 3, 15},
+	{16,  31, 5970, 0, 7, 12},
+	{17,  30, 5910, 0, 5, 15},
+	{17,  30, 5730, 0, 3, 15},
+	{16,  31, 5700, 0, 7, 12},
+	{-1, 314, 5392, 0, 4,  0},
+	{17,  30, 5155, 0, 1, 15},
+	{16,  31, 5150, 0, 5, 12},
+	{16,  31, 5056, 0, 7, 12},
+	{17,  30, 4900, 0, 2, 15},
+	{17,  30, 4785, 0, 7, 15},
+	{16,  31, 4690, 0, 4, 12},
+	{16,  31, 4660, 0, 1, 12},
+	{17,  30, 4560, 0, 5, 15},
+	{16,  31, 4465, 0, 2, 12},
+	{-1, 314, 4112, 0, 4,  0},
+	{17,  30, 4005, 0, 3, 15},
+	{16,  31, 3865, 0, 6, 12},
+	{17,  30, 3605, 0, 4, 15},
+	{16,  31, 3360, 0, 1, 12},
+	{17,  30, 3105, 0, 0, 15},
+	{16,  31, 3080, 0, 7, 12},
+	{17,  30, 3014, 0, 4, 15},
+	{16,  31, 2992, 0, 3, 12},
+	{16,  31, 2976, 0, 2, 12},
+	{17,  30, 2880, 0, 7, 15},
+	{17,  30, 2860, 0, 0, 15},
+	{-1, 314, 2512, 0, 4,  0},
+	{17,  30, 2270, 0, 4, 15},
+	{16,  31, 2195, 0, 6, 12},
+	{17,  30, 1824, 0, 1, 15},
+	{16,  31, 1776, 0, 4, 12},
+	{17,  30, 1650, 0, 3, 15},
+	{16,  31, 1616, 0, 7, 12},
+	{17,  30, 1585, 0, 2, 15},
+	{-1, 314, 1232, 0, 4,  0},
+	{17,  30, 1190, 0, 2, 15},
+	{16,  31, 1120, 0, 4, 12},
+	{17,  30,  970, 0, 7, 15},
+	{16,  31,  910, 0, 5, 12},
+	{17,  30,  705, 0, 0, 15},
+	{16,  31,  550, 0, 4, 12},
+	{17,  30,  305, 0, 2, 15}
+};
+
+const RiverStruct ENDRIVER0[1] = {16, 31, 260, 0, 7, 12};
+
+const RiverStruct RIVER1OBJECTS[49] = {
+	{16,  31, 6920, 0, 1, 12},
+	{16,  31, 6740, 0, 4, 12},
+	{17,  30, 6699, 0, 1, 15},
+	{16,  31, 6610, 0, 2, 12},
+	{17,  30, 6495, 0, 6, 15},
+	{17,  30, 6385, 0, 4, 15},
+	{16,  31, 6350, 0, 1, 12},
+	{17,  30, 6180, 0, 0, 15},
+	{-1, 314, 6032, 0, 4,  0},
+	{16,  31, 5800, 0, 3, 12},
+	{17,  30, 5790, 0, 6, 15},
+	{16,  31, 5530, 0, 4, 12},
+	{16,  31, 5500, 0, 7, 12},
+	{17,  30, 5495, 0, 1, 15},
+	{17,  30, 5376, 0, 0, 15},
+	{16,  31, 5328, 0, 7, 12},
+	{17,  30, 5248, 0, 2, 15},
+	{16,  31, 5248, 0, 6, 12},
+	{-1, 314, 4752, 0, 4,  0},
+	{17,  30, 4432, 0, 2, 15},
+	{16,  31, 4432, 0, 7, 12},
+	{16,  31, 4384, 0, 2, 12},
+	{17,  30, 4368, 0, 5, 15},
+	{16,  31, 4336, 0, 4, 12},
+	{17,  30, 4185, 0, 1, 15},
+	{16,  31, 4125, 0, 3, 12},
+	{17,  30, 3817, 0, 7, 15},
+	{16,  31, 3612, 0, 4, 12},
+	{16,  31, 3360, 0, 5, 12},
+	{16,  31, 3265, 0, 7, 12},
+	{17,  30, 3200, 0, 1, 15},
+	{17,  30, 3056, 0, 6, 15},
+	{-1, 314, 2832, 0, 4,  0},
+	{16,  31, 2740, 0, 3, 12},
+	{17,  30, 2694, 0, 6, 15},
+	{16,  31, 2455, 0, 0, 12},
+	{17,  30, 2285, 0, 5, 15},
+	{16,  31, 2260, 0, 2, 12},
+	{16,  31, 1904, 0, 5, 12},
+	{17,  30, 1808, 0, 1, 15},
+	{16,  31, 1744, 0, 7, 12},
+	{17,  30, 1696, 0, 4, 15},
+	{16,  31, 1568, 0, 2, 12},
+	{-1, 314, 1232, 0, 4,  0},
+	{17,  30,  970, 0, 4, 15},
+	{16,  31,  910, 0, 7, 12},
+	{17,  30,  705, 0, 0, 15},
+	{16,  31,  550, 0, 6, 12},
+	{17,  30,  305, 0, 3, 15}
+};
+
+const RiverStruct ENDRIVER1[1] = {16, 31, 260, 0, 1, 12};
+
+const RiverStruct RIVER2OBJECTS[53] = {
+	{16,  31, 8230, 0, 6, 12},
+	{16,  31, 8115, 0, 7, 12},
+	{17,  30, 7955, 0, 4, 15},
+	{16,  31, 7890, 0, 0, 12},
+	{16,  31, 7616, 0, 2, 12},
+	{17,  30, 7472, 0, 5, 15},
+	{16,  31, 7425, 0, 4, 12},
+	{17,  30, 7360, 0, 1, 15},
+	{16,  31, 7328, 0, 6, 12},
+	{-1, 314, 6992, 0, 4,  0},
+	{16,  31, 6720, 0, 3, 12},
+	{17,  30, 6700, 0, 6, 15},
+	{16,  31, 6518, 0, 2, 12},
+	{17,  30, 6225, 0, 5, 15},
+	{16,  31, 6200, 0, 2, 12},
+	{17,  30, 5990, 0, 1, 15},
+	{16,  31, 5960, 0, 7, 12},
+	{16,  31, 5700, 0, 2, 12},
+	{17,  30, 5650, 0, 4, 15},
+	{16,  31, 5568, 0, 5, 12},
+	{17,  30, 5488, 0, 6, 15},
+	{-1, 314, 5072, 0, 4,  0},
+	{17,  30, 4825, 0, 4, 15},
+	{16,  31, 4782, 0, 2, 12},
+	{17,  30, 4660, 0, 5, 15},
+	{16,  31, 4510, 0, 7, 12},
+	{16,  31, 4495, 0, 1, 12},
+	{17,  30, 4250, 0, 2, 15},
+	{16,  31, 4195, 0, 4, 12},
+	{-1, 314, 3792, 0, 4,  0},
+	{17,  30, 3600, 0, 3, 15},
+	{16,  31, 3470, 0, 5, 12},
+	{16,  31, 3422, 0, 2, 12},
+	{17,  30, 3170, 0, 6, 15},
+	{16,  31, 2960, 0, 4, 12},
+	{17,  30, 2955, 0, 7, 15},
+	{-1, 314, 2512, 0, 4,  0},
+	{17,  30, 2415, 0, 1, 15},
+	{16,  31, 2318, 0, 0, 12},
+	{17,  30, 2275, 0, 2, 15},
+	{16,  31, 2270, 0, 6, 12},
+	{17,  30, 2026, 0, 3, 15},
+	{16,  31, 2000, 0, 0, 12},
+	{16,  31, 1840, 0, 3, 12},
+	{17,  30, 1795, 0, 7, 15},
+	{16,  31, 1634, 0, 5, 12},
+	{17,  30, 1630, 0, 1, 15},
+	{-1, 314, 1232, 0, 4,  0},
+	{17,  30,  970, 0, 2, 15},
+	{16,  31,  910, 0, 5, 12},
+	{17,  30,  705, 0, 0, 15},
+	{16,  31,  550, 0, 4, 12},
+	{17,  30,  305, 0, 3, 15}
+};
+
+const RiverStruct ENDRIVER2[1] = {16, 31, 260, 0, 6, 12};
+
+const RiverStruct *RIVEROBJECTTBL[6] = {
 	RIVER0OBJECTS, ENDRIVER0, RIVER1OBJECTS, 
 	ENDRIVER1, RIVER2OBJECTS, ENDRIVER2
 };
diff --git a/engines/access/amazon/amazon_resources.h b/engines/access/amazon/amazon_resources.h
index b29bdab..ec41276 100644
--- a/engines/access/amazon/amazon_resources.h
+++ b/engines/access/amazon/amazon_resources.h
@@ -29,6 +29,15 @@ namespace Access {
 
 namespace Amazon {
 
+struct RiverStruct {
+	int _id;
+	int _field1;
+	int _field3;
+	int _field5;
+	int _lane;
+	int _field8;
+};
+
 extern const char *const FILENAMES[];
 
 extern const byte *CURSORS[10];
@@ -90,14 +99,14 @@ extern const byte MAP2[32];
 
 extern const byte *MAPTBL[3];
 
-extern const byte RIVER0OBJECTS[450];
-extern const byte ENDRIVER0[10];
-extern const byte RIVER1OBJECTS[490];
-extern const byte ENDRIVER1[10];
-extern const byte RIVER2OBJECTS[530];
-extern const byte ENDRIVER2[10];
+extern const RiverStruct RIVER0OBJECTS[45];
+extern const RiverStruct ENDRIVER0[1];
+extern const RiverStruct RIVER1OBJECTS[49];
+extern const RiverStruct ENDRIVER1[1];
+extern const RiverStruct RIVER2OBJECTS[53];
+extern const RiverStruct ENDRIVER2[1];
 
-extern const byte *RIVEROBJECTTBL[6];
+extern const RiverStruct *RIVEROBJECTTBL[6];
 
 } // End of namespace Amazon
 


Commit: ff003f3b657a7651cc1f49be84d5190299ec17d5
    https://github.com/scummvm/scummvm/commit/ff003f3b657a7651cc1f49be84d5190299ec17d5
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-12T22:38:58-05:00

Commit Message:
ACCESS: Fix the jungle walk 2 cutscene

Changed paths:
    engines/access/amazon/amazon_scripts.cpp
    engines/access/events.cpp
    engines/access/events.h



diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp
index 6138768..d0b13d9 100644
--- a/engines/access/amazon/amazon_scripts.cpp
+++ b/engines/access/amazon/amazon_scripts.cpp
@@ -281,33 +281,33 @@ void AmazonScripts::initJWalk2() {
 
 void AmazonScripts::jungleMove() {
 	const static int jungleY[3] = {27, 30, 29};
-	int cx = 1;
-	int dx = 0;
-	if (_vm->_timers[0]._flag == 0) {
-		_vm->_timers[0]._flag = 1;
+	int count = 1;
+	int frameOffset = 0;
+
+	if (!_vm->_timers[0]._flag) {
+		++_vm->_timers[0]._flag;
 		_vm->_screen->_scrollX += _vm->_player->_scrollAmount;
-		for (int i = 0; i <= 3; i++) {
+
+		for (int i = 0; i < 3; ++i) {
 			int newJCnt = (_jCnt[i] + 1) % 8;
 			_jCnt[i] = newJCnt;
 			_jungleX[i] += 5;
 		}
-		dx = 4;
-		if (_game->_allenFlag != 1)
-			cx = 2;
-		else
-			cx = 3;
+
+		frameOffset = 4;
+		count = (_game->_allenFlag != 1) ? 2 : 3;
 	}
 
-	for (int i = 0; i <= cx; i++) {
+	for (int i = 0; i < count; ++i) {
 		ImageEntry ie;
 		ie._flags = 8;
 		ie._spritesPtr = _vm->_objectsTable[24];
-		ie._frameNumber = _jCnt[i] + dx;
+		ie._frameNumber = _jCnt[i] + frameOffset;
 		ie._position = Common::Point(_jungleX[i], jungleY[i]);
 		ie._offsetY = jungleY[i];
 
 		_vm->_images.addToList(ie);
-		dx += 8;
+		frameOffset += 8;
 	}
 }
 
@@ -316,33 +316,33 @@ void AmazonScripts::mWhileJWalk2() {
 
 	initJWalk2();
 
-	while(true) {
+	while (!_vm->shouldQuit() && !_vm->_events->isKeyMousePressed() &&
+			(screen._scrollCol + screen._vWindowWidth) != _vm->_room->_playFieldWidth) {
 		_vm->_images.clear();
 		_vm->_events->_vbCount = 6;
 		_pImgNum[0] = _game->_plane._xCount;
-		while ((screen._scrollCol + screen._vWindowWidth) != _vm->_room->_playFieldWidth) {
-			jungleMove();
-			while (screen._scrollX >= TILE_WIDTH) {
-				screen._scrollX -= TILE_WIDTH;
-				++screen._scrollCol;
-				_vm->_buffer1.moveBufferLeft();
-				_vm->_room->buildColumn(screen._scrollCol + screen._vWindowWidth, screen._vWindowBytesWide);
-			}
-			if (_game->_plane._xCount == 2)
-				++_game->_plane._xCount;
-			else
-				--_game->_plane._xCount;
 
-			pan();
-			scrollJWalk();
+		jungleMove();
+		while (screen._scrollX >= TILE_WIDTH) {
+			screen._scrollX -= TILE_WIDTH;
+			++screen._scrollCol;
+			_vm->_buffer1.moveBufferLeft();
+			_vm->_room->buildColumn(screen._scrollCol + screen._vWindowWidth, screen._vWindowBytesWide);
+		}
 
-			g_system->delayMillis(10);
-			while (!_vm->shouldQuit() && _vm->_events->_vbCount > 0) {
-				_vm->_events->pollEvents();
-				g_system->delayMillis(10);
-			}
+		if (_game->_plane._xCount == 2)
+			++_game->_plane._xCount;
+		else
+			--_game->_plane._xCount;
+
+		pan();
+		scrollJWalk();
+
+		while (!_vm->shouldQuit() && _vm->_events->_vbCount > 0) {
+			_vm->_events->pollEventsAndWait();
 		}
 	}
+
 	_vm->_events->showCursor();
 }
 
@@ -522,8 +522,7 @@ void AmazonScripts::mWhileFly() {
 			events.checkForNextFrameCounter();
 			_vm->_sound->playSound(0);
 
-			g_system->delayMillis(10);
-			events.pollEvents();
+			events.pollEventsAndWait();
 		}
 	}
 
@@ -572,8 +571,7 @@ void AmazonScripts::mWhileFall() {
 		scrollFall();
 
 		while (!_vm->shouldQuit() && events._vbCount > 0) {
-			events.pollEvents();
-			g_system->delayMillis(10);
+			events.pollEventsAndWait();
 		}
 	}
 
@@ -649,10 +647,8 @@ void AmazonScripts::mWhileJWalk() {
 		pan();
 		scrollJWalk();
 
-		g_system->delayMillis(10);
 		while (!_vm->shouldQuit() && events._vbCount > 0) {
-			events.pollEvents();
-			g_system->delayMillis(10);
+			events.pollEventsAndWait();
 		}
 	}
 
@@ -732,8 +728,7 @@ void AmazonScripts::mWhileDoOpen() {
 			screen.forceFadeIn();
 		}
 
-		events.pollEvents();
-		g_system->delayMillis(10);
+		events.pollEventsAndWait();
 
 		if (events._leftButton || events._rightButton || events._keypresses.size() > 0) {
 			_game->_skipStart = true;
@@ -748,8 +743,7 @@ void AmazonScripts::mWhileDoOpen() {
 			events._vbCount = 125;
 			
 			while(!_vm->shouldQuit() && !events.isKeyMousePressed() && events._vbCount > 0) {
-				events.pollEvents();
-				g_system->delayMillis(10);
+				events.pollEventsAndWait();
 			}
 			break;
 		}
@@ -872,10 +866,8 @@ void AmazonScripts::mWhileDownRiver() {
 				_vm->_sound->playSound(0);
 			}
 
-			g_system->delayMillis(10);
 			while (!_vm->shouldQuit() && _vm->_events->_vbCount > 0) {
-				_vm->_events->pollEvents();
-				g_system->delayMillis(10);
+				_vm->_events->pollEventsAndWait();
 			}
 		}
 	}
@@ -1282,12 +1274,11 @@ void AmazonScripts::doCast(int param1) {
 			_vm->_events->_vbCount = 50;
 
 			while(!_vm->shouldQuit() && !_vm->_events->isKeyMousePressed() && _vm->_events->_vbCount > 0) {
-				_vm->_events->pollEvents();
-				g_system->delayMillis(10);
+				_vm->_events->pollEventsAndWait();
 			}
 
 			while (!_vm->shouldQuit() && !_vm->_sound->checkMidiDone())
-				_vm->_events->pollEvents();
+				_vm->_events->pollEventsAndWait();
 
 			break;
 		}
@@ -1295,7 +1286,7 @@ void AmazonScripts::doCast(int param1) {
 
 	_vm->_sound->newMusic(58, 1);
 	_vm->_events->showCursor();
-	warning("TODO: delete _roomInfo;");
+
 	_vm->freeCells();
 	_vm->_oldRects.clear();
 	_vm->_newRects.clear();
@@ -1834,8 +1825,7 @@ void AmazonScripts::RIVER() {
 			SCROLLRIVER1();
 
 		while (!_vm->shouldQuit() && _vm->_events->_vbCount > 0) {
-			_vm->_events->pollEvents();
-			g_system->delayMillis(10);
+			_vm->_events->pollEventsAndWait();
 		}
 	}
 }
diff --git a/engines/access/events.cpp b/engines/access/events.cpp
index fd43257..d911e66 100644
--- a/engines/access/events.cpp
+++ b/engines/access/events.cpp
@@ -181,6 +181,11 @@ void EventsManager::pollEvents() {
 	}
 }
 
+void EventsManager::pollEventsAndWait() {
+	pollEvents();
+	g_system->delayMillis(10);
+}
+
 bool EventsManager::checkForNextFrameCounter() {
 	// Check for next game frame
 	uint32 milli = g_system->getMillis();
diff --git a/engines/access/events.h b/engines/access/events.h
index d73f76a..0a2a541 100644
--- a/engines/access/events.h
+++ b/engines/access/events.h
@@ -107,6 +107,8 @@ public:
 
 	void pollEvents();
 
+	void pollEventsAndWait();
+
 	void zeroKeys();
 
 	bool getKey(Common::KeyState &key);


Commit: ada5ca20f97a4d0b3b21ed18feac7c8d814d8959
    https://github.com/scummvm/scummvm/commit/ada5ca20f97a4d0b3b21ed18feac7c8d814d8959
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-12T22:39:11-05:00

Commit Message:
ACCESS: Reorganise Amazon game-specific variables that are saved

Changed paths:
    engines/access/amazon/amazon_game.h



diff --git a/engines/access/amazon/amazon_game.h b/engines/access/amazon/amazon_game.h
index 3b8b981..26a9454 100644
--- a/engines/access/amazon/amazon_game.h
+++ b/engines/access/amazon/amazon_game.h
@@ -54,10 +54,6 @@ public:
 
 class AmazonEngine : public AccessEngine {
 private:
-	// Fields that are included in savegames
-	int _esTabTable[100];
-
-	// Other fields
 	Common::Point _tilePos;
 	byte _tileData[1455];
 	Common::Array<CellIdent> _chapterCells;
@@ -101,18 +97,9 @@ public:
 	bool _charSegSwitch;
 	bool _skipStart;
 
-	int _canoeLane;
-	int _canoeYPos;
-	int _hitCount;
 	const RiverStruct *_topList;
 	const RiverStruct *_botList;
-	int _riverIndex;
-	int _saveRiver;
 	int _canoeDir;
-	int _hitSafe;
-	int _rawInactiveX;
-	int _rawInactiveY;
-	int _inactiveYOff;
 
 	// Fields that are mapped to flags
 	int &_guardLocation;
@@ -130,7 +117,17 @@ public:
 	int &_noSound;
 
 	// Saved fields
+	int _canoeLane;
+	int _canoeYPos;
+	int _hitCount;
+	int _saveRiver;
+	int _hitSafe;
 	int _chapter;
+	int _riverIndex;
+	int _rawInactiveX;
+	int _rawInactiveY;
+	int _inactiveYOff;
+	int _esTabTable[100];
 
 	// Other game specific fields
 	Guard _guard;


Commit: 1cbaab55cd6870c9f75162f1ddb90f0c25959db3
    https://github.com/scummvm/scummvm/commit/1cbaab55cd6870c9f75162f1ddb90f0c25959db3
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-12T22:39:28-05:00

Commit Message:
ACCESS: Split cmdDead in order to use it in RIVER

Changed paths:
    engines/access/amazon/amazon_scripts.cpp
    engines/access/scripts.cpp
    engines/access/scripts.h



diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp
index d0b13d9..75fbd05 100644
--- a/engines/access/amazon/amazon_scripts.cpp
+++ b/engines/access/amazon/amazon_scripts.cpp
@@ -1805,14 +1805,14 @@ void AmazonScripts::RIVER() {
 			_game->_hitSafe -= 2;
 
 		if (_game->_hitSafe < 0) {
-			warning("TODO: cmdDead(RIVERDEATH[0]);");
+			cmdDead(RIVERDEATH[0]);
 			return;
 		}
 
 		if (_game->_deathFlag) {
 			_game->_deathCount--;
 			if (_game->_deathCount == 0) {
-				warning("TODO: cmdDead(RIVERDEATH[_game->_deathType]);");
+				cmdDead(RIVERDEATH[_game->_deathType]);
 				return;
 			}
 		}
diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp
index 9268b82..3f94ea2 100644
--- a/engines/access/scripts.cpp
+++ b/engines/access/scripts.cpp
@@ -775,14 +775,13 @@ void Scripts::cmdPlayerOn() {
 	_vm->_player->_playerOff = false;
 }
 
-void Scripts::cmdDead() { 
-	int deathId = _data->readByte();
+void Scripts::cmdDead(int deathId) {
 	_vm->_events->hideCursor();
 	_vm->_screen->forceFadeOut();
 	cmdFreeSound();
 
 	_vm->_sound->_soundTable.push_back(SoundEntry(_vm->_files->loadFile(98, 44), 1));
-	
+
 	_vm->_screen->clearScreen();
 	_vm->_screen->setPanel(3);
 
@@ -843,6 +842,11 @@ void Scripts::cmdDead() {
 	}
 }
 
+void Scripts::cmdDead() { 
+	int deathId = _data->readByte();
+	cmdDead(deathId);
+}
+
 void Scripts::cmdFadeOut() {
 	_vm->_screen->forceFadeOut();
 }
diff --git a/engines/access/scripts.h b/engines/access/scripts.h
index 2b527a8..de27ae7 100644
--- a/engines/access/scripts.h
+++ b/engines/access/scripts.h
@@ -120,6 +120,7 @@ protected:
 	void cmdPlayerOff();
 	void cmdPlayerOn();
 	void cmdDead();
+	void cmdDead(int deathId);
 	void cmdFadeOut();
 	void CMDENDVID();
 public:


Commit: a0beb08984b989d6dcb1c9dcbc8bb083e2534891
    https://github.com/scummvm/scummvm/commit/a0beb08984b989d6dcb1c9dcbc8bb083e2534891
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-12T22:39:42-05:00

Commit Message:
ACCESS: Refactor _inactive from AccessEngine to AmazonEngine

Changed paths:
    engines/access/access.cpp
    engines/access/access.h
    engines/access/amazon/amazon_game.cpp
    engines/access/amazon/amazon_game.h
    engines/access/amazon/amazon_room.cpp
    engines/access/amazon/amazon_room.h
    engines/access/amazon/amazon_scripts.cpp
    engines/access/martian/martian_room.cpp
    engines/access/room.cpp
    engines/access/room.h



diff --git a/engines/access/access.cpp b/engines/access/access.cpp
index e87b647..cb47598 100644
--- a/engines/access/access.cpp
+++ b/engines/access/access.cpp
@@ -54,9 +54,6 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc)
 	_mouseMode = 0;
 	_currentMan = 0;
 	_currentManOld = -1;
-	_inactive._spritesPtr = nullptr;
-	_inactive._flags = _inactive._frameNumber = _inactive._offsetY = 0;
-	_inactive._position = Common::Point(0, 0);
 	_music = nullptr;
 	_title = nullptr;
 	_converseMode = 0;
@@ -128,7 +125,6 @@ AccessEngine::~AccessEngine() {
 	delete _video;
 
 	freeCells();
-	delete _inactive._spritesPtr;
 	delete _music;
 	delete _title;
 	delete _eseg;
@@ -212,11 +208,6 @@ void AccessEngine::freeCells() {
 	}
 }
 
-void AccessEngine::freeInactiveData() {
-	delete _inactive._spritesPtr;
-	_inactive._spritesPtr = nullptr;
-}
-
 void AccessEngine::speakText(ASurface *s, const Common::String &msg) {
 	Common::String lines = msg;
 	Common::String line;
diff --git a/engines/access/access.h b/engines/access/access.h
index 805abcc..12e0e1b 100644
--- a/engines/access/access.h
+++ b/engines/access/access.h
@@ -175,7 +175,6 @@ public:
 	int _mouseMode;
 
 	int _currentManOld;
-	ImageEntry _inactive;
 	Resource *_music;
 	Resource *_title;
 	int _converseMode;
@@ -250,11 +249,6 @@ public:
 	*/
 	void freeCells();
 
-	/**
-	 * Free the inactive data
-	 */
-	void freeInactiveData();
-
 	virtual void establish(int esatabIndex, int sub) = 0;
 
 	void plotList();
diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp
index def64f2..5c7a3ed 100644
--- a/engines/access/amazon/amazon_game.cpp
+++ b/engines/access/amazon/amazon_game.cpp
@@ -72,10 +72,19 @@ AmazonEngine::AmazonEngine(OSystem *syst, const AccessGameDescription *gameDesc)
 	memset(_tileData, 0, sizeof(_tileData));
 	
 	_chapterCells.push_back(CellIdent(0, 96, 17));
-
+	_inactive._spritesPtr = nullptr;
+	_inactive._altSpritesPtr = nullptr;
+	_inactive._flags = _inactive._frameNumber = _inactive._offsetY = 0;
+	_inactive._position = Common::Point(0, 0);
 }
 
 AmazonEngine::~AmazonEngine() {
+	delete _inactive._spritesPtr;
+}
+
+void AmazonEngine::freeInactivePlayer() {
+	delete _inactive._spritesPtr;
+	_inactive._spritesPtr = nullptr;
 }
 
 void AmazonEngine::playGame() {
diff --git a/engines/access/amazon/amazon_game.h b/engines/access/amazon/amazon_game.h
index 26a9454..05caa21 100644
--- a/engines/access/amazon/amazon_game.h
+++ b/engines/access/amazon/amazon_game.h
@@ -52,6 +52,11 @@ public:
 	Guard();
 };
 
+class InactivePlayer : public ImageEntry {
+public:
+	SpriteResource *_altSpritesPtr;
+};
+
 class AmazonEngine : public AccessEngine {
 private:
 	Common::Point _tilePos;
@@ -94,6 +99,7 @@ protected:
 	*/
 	virtual void synchronize(Common::Serializer &s);
 public:
+	InactivePlayer _inactive;
 	bool _charSegSwitch;
 	bool _skipStart;
 
@@ -161,6 +167,11 @@ public:
 
 	virtual ~AmazonEngine();
 
+	/**
+	* Free the inactive player data
+	*/
+	void freeInactivePlayer();
+
 	void drawHelp();
 
 	virtual void establish(int esatabIndex, int sub);
diff --git a/engines/access/amazon/amazon_room.cpp b/engines/access/amazon/amazon_room.cpp
index db46b48..262a6ca 100644
--- a/engines/access/amazon/amazon_room.cpp
+++ b/engines/access/amazon/amazon_room.cpp
@@ -78,7 +78,7 @@ void AmazonRoom::reloadRoom1() {
 	if (_vm->_player->_roomNumber == 29 || _vm->_player->_roomNumber == 31 
 			|| _vm->_player->_roomNumber == 42 || _vm->_player->_roomNumber == 44) {
 		Resource *spriteData = _vm->_files->loadFile("MAYA.LZ");
-		_vm->_inactive._spritesPtr = new SpriteResource(_vm, spriteData);
+		_game->_inactive._spritesPtr = new SpriteResource(_vm, spriteData);
 		delete spriteData;
 		_vm->_currentCharFlag = false;
 	}
@@ -168,9 +168,11 @@ void AmazonRoom::mainAreaClick() {
 				_vm->_player->_roomNumber == 31 || _vm->_player->_roomNumber == 29) {
 			switch (checkBoxes1(pt)) {
 			case 0:
+				// Make Jason the active player
 				_game->_jasMayaFlag = 0;
 				return;
 			case 1:
+				// Make Maya the active player
 				_game->_jasMayaFlag = 1;
 				return;
 			default:
@@ -208,6 +210,11 @@ void AmazonRoom::init4Quads() {
 	_vm->_screen->clearScreen();
 }
 
+void AmazonRoom::clearRoom() {
+	Room::clearRoom();
+	_game->freeInactivePlayer();
+}
+
 } // End of namespace Amazon
 
 } // End of namespace Access
diff --git a/engines/access/amazon/amazon_room.h b/engines/access/amazon/amazon_room.h
index 6b89a8f..bcb0d84 100644
--- a/engines/access/amazon/amazon_room.h
+++ b/engines/access/amazon/amazon_room.h
@@ -52,6 +52,7 @@ protected:
 
 	virtual void mainAreaClick();
 
+	virtual void clearRoom();
 public:
 	AmazonRoom(AccessEngine *vm);
 
diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp
index 75fbd05..8a92dd6 100644
--- a/engines/access/amazon/amazon_scripts.cpp
+++ b/engines/access/amazon/amazon_scripts.cpp
@@ -1553,41 +1553,51 @@ void AmazonScripts::boatWalls(int param1, int param2) {
 }
 
 void AmazonScripts::plotInactive() {
+	Player &player = *_vm->_player;
+	InactivePlayer &inactive = _game->_inactive;
+
 	if (_game->_charSegSwitch) {
 		_game->_currentCharFlag = true;
-		SpriteResource *tmp = _vm->_inactive._spritesPtr;
-		_vm->_inactive._spritesPtr = _vm->_player->_playerSprites;
-		_vm->_player->_playerSprites = tmp;
+		SpriteResource *tmp = inactive._spritesPtr;
+		inactive._spritesPtr = player._playerSprites;
+		player._playerSprites = tmp;
 		_game->_charSegSwitch = false;
 	} else if (_game->_jasMayaFlag != (_game->_currentCharFlag ? 1 : 0)) {
-		if (_vm->_player->_playerOff) {
+		if (player._playerOff) {
 			_game->_jasMayaFlag = (_game->_currentCharFlag ? 1 : 0);
 		} else {
 			_game->_currentCharFlag = (_game->_jasMayaFlag == 1);
 			int tmpX = _game->_rawInactiveX;
 			int tmpY = _game->_rawInactiveY;
-			_game->_rawInactiveX = _vm->_player->_rawPlayer.x;
-			_game->_rawInactiveY = _vm->_player->_rawPlayer.y;
-			_vm->_player->_rawPlayer.x = tmpX;
-			_vm->_player->_rawPlayer.y = tmpY;
-			_game->_inactiveYOff = _vm->_player->_playerOffset.y;
-			_vm->_player->calcManScale();
+			_game->_rawInactiveX = player._rawPlayer.x;
+			_game->_rawInactiveY = player._rawPlayer.y;
+			player._rawPlayer.x = tmpX;
+			player._rawPlayer.y = tmpY;
+			_game->_inactiveYOff = player._playerOffset.y;
+			player.calcManScale();
 		}
 	}
 
-	if (_vm->_player->_roomNumber == 44) {
-		warning("CHECKME: Only sets useless(?) flags 155 and 160");
+	_game->_flags[155] = 0;
+	if (_game->_rawInactiveX >= 152 && _game->_rawInactiveX <= 167 &&
+			_game->_rawInactiveY >= 158 && _game->_rawInactiveY <= 173) {
+		_game->_flags[155] = 1;
+	} else {
+		_game->_flags[160] = 1;
+		if (!_game->_jasMayaFlag && _game->_rawInactiveX <= 266 && _game->_rawInactiveX < 290
+			&& _game->_rawInactiveY >= 70 && _game->_rawInactiveY <= 87) {
+			_game->_flags[160] = 1;
+		}
 	}
 
-	_vm->_inactive._flags &= 0xFD;
-	_vm->_inactive._flags &= 0xF7;
-	_vm->_inactive._position.x = _game->_rawInactiveX;
-	_vm->_inactive._position.y = _game->_rawInactiveY - _game->_inactiveYOff;
-	_vm->_inactive._offsetY = _game->_inactiveYOff;
-	_vm->_inactive._frameNumber = 0;
-
-	_vm->_images.addToList(_vm->_inactive);
+	inactive._flags &= ~IMGFLAG_UNSCALED;
+	inactive._flags &= ~IMGFLAG_BACKWARDS;
+	inactive._position.x = _game->_rawInactiveX;
+	inactive._position.y = _game->_rawInactiveY - _game->_inactiveYOff;
+	inactive._offsetY = _game->_inactiveYOff;
+	inactive._frameNumber = 0;
 
+	_vm->_images.addToList(_game->_inactive);
 }
 
 void AmazonScripts::setRiverPan() {
diff --git a/engines/access/martian/martian_room.cpp b/engines/access/martian/martian_room.cpp
index 6d4d62f..62c44bc 100644
--- a/engines/access/martian/martian_room.cpp
+++ b/engines/access/martian/martian_room.cpp
@@ -75,9 +75,9 @@ void MartianRoom::reloadRoom() {
 void MartianRoom::reloadRoom1() {
 	if (_vm->_player->_roomNumber == 29 || _vm->_player->_roomNumber == 31 
 			|| _vm->_player->_roomNumber == 42 || _vm->_player->_roomNumber == 44) {
-		Resource *spriteData = _vm->_files->loadFile("MAYA.LZ");
-		_vm->_inactive._spritesPtr = new SpriteResource(_vm, spriteData);
-		delete spriteData;
+		//Resource *spriteData = _vm->_files->loadFile("MAYA.LZ");
+		//_vm->_inactive._spritesPtr = new SpriteResource(_vm, spriteData);
+		//delete spriteData;
 		_vm->_currentCharFlag = false;
 	}
 
diff --git a/engines/access/room.cpp b/engines/access/room.cpp
index 31d1583..37746d1 100644
--- a/engines/access/room.cpp
+++ b/engines/access/room.cpp
@@ -164,7 +164,6 @@ void Room::clearRoom() {
 	_vm->freeCells();
 	freePlayField();
 	freeTileData();
-	_vm->freeInactiveData();
 	_vm->_player->freeSprites();
 }
 
diff --git a/engines/access/room.h b/engines/access/room.h
index 9b31366..a26f2ed 100644
--- a/engines/access/room.h
+++ b/engines/access/room.h
@@ -144,7 +144,7 @@ public:
 	/**
 	 * Clear all the data used by the room
 	 */
-	void clearRoom();
+	virtual void clearRoom();
 
 	/**
 	 * Builds up a game screen


Commit: 9e84be664cab90788aa67049732bc6be1e5b6209
    https://github.com/scummvm/scummvm/commit/9e84be664cab90788aa67049732bc6be1e5b6209
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-12T22:39:56-05:00

Commit Message:
ACCESS: Implement a couple of script functions

Changed paths:
    engines/access/access.cpp
    engines/access/access.h
    engines/access/scripts.cpp
    engines/access/scripts.h
    engines/access/video.cpp
    engines/access/video.h



diff --git a/engines/access/access.cpp b/engines/access/access.cpp
index cb47598..cdabb32 100644
--- a/engines/access/access.cpp
+++ b/engines/access/access.cpp
@@ -107,6 +107,7 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc)
 	_txtPages = 0;
 	_sndSubFile = 0;
 	_loadSaveSlot = -1;
+	_vidX = _vidY = 0;
 }
 
 AccessEngine::~AccessEngine() {
@@ -171,6 +172,7 @@ void AccessEngine::initialize() {
 
 	_buffer1.create(g_system->getWidth() + TILE_WIDTH, g_system->getHeight());
 	_buffer2.create(g_system->getWidth(), g_system->getHeight());
+	_vidBuf.create(160, 101);
 
 	// If requested, load a savegame instead of showing the intro
 	if (ConfMan.hasKey("save_slot")) {
diff --git a/engines/access/access.h b/engines/access/access.h
index 12e0e1b..2cd35fb 100644
--- a/engines/access/access.h
+++ b/engines/access/access.h
@@ -156,6 +156,8 @@ public:
 	ASurface *_current;
 	ASurface _buffer1;
 	ASurface _buffer2;
+	ASurface _vidBuf;
+	int _vidX, _vidY;
 	Common::Array<CharEntry *> _charTable;
 	SpriteResource *_objectsTable[100];
 	bool _establishTable[100];
diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp
index 3f94ea2..442d91d 100644
--- a/engines/access/scripts.cpp
+++ b/engines/access/scripts.cpp
@@ -123,7 +123,7 @@ void Scripts::executeCommand(int commandIndex) {
 		&Scripts::cmdSetTravel, &Scripts::cmdSetVideo, &Scripts::cmdPlayVideo, 
 		&Scripts::cmdPlotImage, &Scripts::cmdSetDisplay, &Scripts::cmdSetBuffer, 
 		&Scripts::cmdSetScroll, &Scripts::cmdVideoEnded, &Scripts::cmdVideoEnded, 
-		&Scripts::CMDSETBUFVID, &Scripts::CMDPLAYBUFVID, &Scripts::cmdRemoveLast, 
+		&Scripts::cmdSetBufVid, &Scripts::CMDPLAYBUFVID, &Scripts::cmdRemoveLast, 
 		&Scripts::cmdSpecial, &Scripts::cmdSpecial, &Scripts::cmdSpecial,
 		&Scripts::cmdSetCycle, &Scripts::cmdCycle, &Scripts::cmdCharSpeak, 
 		&Scripts::cmdTexSpeak, &Scripts::cmdTexChoice, &Scripts::cmdWait, 
@@ -497,8 +497,19 @@ void Scripts::cmdVideoEnded() {
 	}
 }
 
-void Scripts::CMDSETBUFVID() { error("TODO CMDSETBUFVID"); }
-void Scripts::CMDPLAYBUFVID() { error("TODO CMDPLAYBUFVID"); }
+void Scripts::cmdSetBufVid() {
+	_vm->_vidX = _data->readUint16LE();
+	_vm->_vidY = _data->readUint16LE();
+	int idx = _data->readUint16LE();
+	int rate = _data->readUint16LE();
+
+	_vm->_video->setVideo(&_vm->_vidBuf, Common::Point(0, 0), FileIdent(_vm->_extraCells[idx]._vid._fileNum, _vm->_extraCells[idx]._vid._subfile), rate);
+}
+
+void Scripts::CMDPLAYBUFVID() {
+	_vm->_video->playVideo();
+	_vm->_video->copyVideo();
+}
 
 void Scripts::cmdRemoveLast() {
 	--_vm->_numAnimTimers;
diff --git a/engines/access/scripts.h b/engines/access/scripts.h
index de27ae7..aa9b266 100644
--- a/engines/access/scripts.h
+++ b/engines/access/scripts.h
@@ -98,7 +98,7 @@ protected:
 	void cmdSetBuffer();
 	void cmdSetScroll();
 	void cmdVideoEnded();
-	void CMDSETBUFVID();
+	void cmdSetBufVid();
 	void CMDPLAYBUFVID();
 	void cmdRemoveLast();
 	void cmdSpecial();
diff --git a/engines/access/video.cpp b/engines/access/video.cpp
index b46bdf2..539ad34 100644
--- a/engines/access/video.cpp
+++ b/engines/access/video.cpp
@@ -140,5 +140,7 @@ void VideoPlayer::playVideo() {
 	}
 }
 
-
+void VideoPlayer::copyVideo() {
+	warning("TODO: copyVideo");
+}
 } // End of namespace Access
diff --git a/engines/access/video.h b/engines/access/video.h
index b49c876..f4be76d 100644
--- a/engines/access/video.h
+++ b/engines/access/video.h
@@ -69,6 +69,7 @@ public:
 	 */
 	void playVideo();
 
+	void copyVideo();
 	/**
 	 * Frees the data for a previously loaded video
 	 */


Commit: 80ec09d0aee51a5430887cc94c70928375d55640
    https://github.com/scummvm/scummvm/commit/80ec09d0aee51a5430887cc94c70928375d55640
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-12T22:40:07-05:00

Commit Message:
ACCESS: Rename a function

Changed paths:
    engines/access/scripts.cpp
    engines/access/scripts.h



diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp
index 442d91d..2336e78 100644
--- a/engines/access/scripts.cpp
+++ b/engines/access/scripts.cpp
@@ -123,7 +123,7 @@ void Scripts::executeCommand(int commandIndex) {
 		&Scripts::cmdSetTravel, &Scripts::cmdSetVideo, &Scripts::cmdPlayVideo, 
 		&Scripts::cmdPlotImage, &Scripts::cmdSetDisplay, &Scripts::cmdSetBuffer, 
 		&Scripts::cmdSetScroll, &Scripts::cmdVideoEnded, &Scripts::cmdVideoEnded, 
-		&Scripts::cmdSetBufVid, &Scripts::CMDPLAYBUFVID, &Scripts::cmdRemoveLast, 
+		&Scripts::cmdSetBufVid, &Scripts::cmdPlayBufVid, &Scripts::cmdRemoveLast, 
 		&Scripts::cmdSpecial, &Scripts::cmdSpecial, &Scripts::cmdSpecial,
 		&Scripts::cmdSetCycle, &Scripts::cmdCycle, &Scripts::cmdCharSpeak, 
 		&Scripts::cmdTexSpeak, &Scripts::cmdTexChoice, &Scripts::cmdWait, 
@@ -506,7 +506,7 @@ void Scripts::cmdSetBufVid() {
 	_vm->_video->setVideo(&_vm->_vidBuf, Common::Point(0, 0), FileIdent(_vm->_extraCells[idx]._vid._fileNum, _vm->_extraCells[idx]._vid._subfile), rate);
 }
 
-void Scripts::CMDPLAYBUFVID() {
+void Scripts::cmdPlayBufVid() {
 	_vm->_video->playVideo();
 	_vm->_video->copyVideo();
 }
diff --git a/engines/access/scripts.h b/engines/access/scripts.h
index aa9b266..ebee79d 100644
--- a/engines/access/scripts.h
+++ b/engines/access/scripts.h
@@ -99,7 +99,7 @@ protected:
 	void cmdSetScroll();
 	void cmdVideoEnded();
 	void cmdSetBufVid();
-	void CMDPLAYBUFVID();
+	void cmdPlayBufVid();
 	void cmdRemoveLast();
 	void cmdSpecial();
 	void cmdSetCycle();


Commit: 74a61d1118df5c54b2ad75f6068328d8a6d54bec
    https://github.com/scummvm/scummvm/commit/74a61d1118df5c54b2ad75f6068328d8a6d54bec
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-12T22:40:17-05:00

Commit Message:
ACCESS: Fix the ability to switch between players

Changed paths:
    engines/access/amazon/amazon_game.cpp
    engines/access/amazon/amazon_room.cpp
    engines/access/amazon/amazon_scripts.cpp



diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp
index 5c7a3ed..657458f 100644
--- a/engines/access/amazon/amazon_game.cpp
+++ b/engines/access/amazon/amazon_game.cpp
@@ -79,12 +79,12 @@ AmazonEngine::AmazonEngine(OSystem *syst, const AccessGameDescription *gameDesc)
 }
 
 AmazonEngine::~AmazonEngine() {
-	delete _inactive._spritesPtr;
+	delete _inactive._altSpritesPtr;
 }
 
 void AmazonEngine::freeInactivePlayer() {
-	delete _inactive._spritesPtr;
-	_inactive._spritesPtr = nullptr;
+	delete _inactive._altSpritesPtr;
+	_inactive._altSpritesPtr = nullptr;
 }
 
 void AmazonEngine::playGame() {
diff --git a/engines/access/amazon/amazon_room.cpp b/engines/access/amazon/amazon_room.cpp
index 262a6ca..3381688 100644
--- a/engines/access/amazon/amazon_room.cpp
+++ b/engines/access/amazon/amazon_room.cpp
@@ -78,7 +78,7 @@ void AmazonRoom::reloadRoom1() {
 	if (_vm->_player->_roomNumber == 29 || _vm->_player->_roomNumber == 31 
 			|| _vm->_player->_roomNumber == 42 || _vm->_player->_roomNumber == 44) {
 		Resource *spriteData = _vm->_files->loadFile("MAYA.LZ");
-		_game->_inactive._spritesPtr = new SpriteResource(_vm, spriteData);
+		_game->_inactive._altSpritesPtr = new SpriteResource(_vm, spriteData);
 		delete spriteData;
 		_vm->_currentCharFlag = false;
 	}
diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp
index 8a92dd6..e4c58c9 100644
--- a/engines/access/amazon/amazon_scripts.cpp
+++ b/engines/access/amazon/amazon_scripts.cpp
@@ -1558,9 +1558,7 @@ void AmazonScripts::plotInactive() {
 
 	if (_game->_charSegSwitch) {
 		_game->_currentCharFlag = true;
-		SpriteResource *tmp = inactive._spritesPtr;
-		inactive._spritesPtr = player._playerSprites;
-		player._playerSprites = tmp;
+		SWAP(inactive._altSpritesPtr, player._playerSprites);
 		_game->_charSegSwitch = false;
 	} else if (_game->_jasMayaFlag != (_game->_currentCharFlag ? 1 : 0)) {
 		if (player._playerOff) {
@@ -1575,6 +1573,9 @@ void AmazonScripts::plotInactive() {
 			player._rawPlayer.y = tmpY;
 			_game->_inactiveYOff = player._playerOffset.y;
 			player.calcManScale();
+
+			SWAP(inactive._altSpritesPtr, player._playerSprites);
+			_vm->_room->setWallCodes();
 		}
 	}
 
@@ -1595,7 +1596,7 @@ void AmazonScripts::plotInactive() {
 	inactive._position.x = _game->_rawInactiveX;
 	inactive._position.y = _game->_rawInactiveY - _game->_inactiveYOff;
 	inactive._offsetY = _game->_inactiveYOff;
-	inactive._frameNumber = 0;
+	inactive._spritesPtr = inactive._altSpritesPtr;
 
 	_vm->_images.addToList(_game->_inactive);
 }


Commit: ddfe7395546e9b932280d7aae9e6455dbb4d9989
    https://github.com/scummvm/scummvm/commit/ddfe7395546e9b932280d7aae9e6455dbb4d9989
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-12T22:40:26-05:00

Commit Message:
ACCESS: Implement copyVideo

Changed paths:
    engines/access/video.cpp



diff --git a/engines/access/video.cpp b/engines/access/video.cpp
index 539ad34..776c58a 100644
--- a/engines/access/video.cpp
+++ b/engines/access/video.cpp
@@ -141,6 +141,28 @@ void VideoPlayer::playVideo() {
 }
 
 void VideoPlayer::copyVideo() {
-	warning("TODO: copyVideo");
+	_vm->_player->calcPlayer();
+	Common::Rect r = Common::Rect(_vm->_vidX - _vm->_screen->_bufferStart.x,
+		_vm->_vidY - _vm->_screen->_bufferStart.y, 
+		_vm->_vidX - _vm->_screen->_bufferStart.x + _header._width,
+		_vm->_vidY - _vm->_screen->_bufferStart.y + _header._height);
+	if (!_vm->_screen->clip(r))
+		return;
+	
+	_vm->_newRects.push_back(r);
+	int vh = _header._height;
+	int vw = _header._width;
+	int destIdx = _vm->_vidX - _vm->_screen->_bufferStart.x;
+	int srcIdx = _vm->_screen->_leftSkip;
+	for (int i = 0; i < _vm->_screen->_topSkip; i++)
+		destIdx += 160;
+
+	const byte *srcP = (const byte *)_vm->_vidBuf.getPixels() + srcIdx;
+	byte *destP = (byte *)_vm->_buffer2.getPixels() + destIdx;
+	for (int i = 0; i < vh; i++) {
+		Common::copy(srcP, srcP + vw, destP);
+		srcP += _vm->_vidBuf.pitch;
+		destP += _vm->_buffer2.pitch;
+	}
 }
 } // End of namespace Access


Commit: 08c65399002ffa7c1d5f055c242996ff0f416fad
    https://github.com/scummvm/scummvm/commit/08c65399002ffa7c1d5f055c242996ff0f416fad
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-12T22:40:35-05:00

Commit Message:
ACCESS: Implement cmdEndVideo

Changed paths:
    engines/access/scripts.cpp
    engines/access/scripts.h



diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp
index 2336e78..d4bd5ad 100644
--- a/engines/access/scripts.cpp
+++ b/engines/access/scripts.cpp
@@ -133,7 +133,7 @@ void Scripts::executeCommand(int commandIndex) {
 		&Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, 
 		&Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, &Scripts::cmdPlayerOff, 
 		&Scripts::cmdPlayerOn, &Scripts::cmdDead, &Scripts::cmdFadeOut,
-		&Scripts::CMDENDVID
+		&Scripts::cmdEndVideo
 	};
 
 	(this->*COMMAND_LIST[commandIndex])();
@@ -862,6 +862,9 @@ void Scripts::cmdFadeOut() {
 	_vm->_screen->forceFadeOut();
 }
 
-void Scripts::CMDENDVID() { error("TODO CMDENDVID"); }
+void Scripts::cmdEndVideo() {
+	_vm->_video->closeVideo();
+	_vm->_video->_videoEnd = true;
+}
 
 } // End of namespace Access
diff --git a/engines/access/scripts.h b/engines/access/scripts.h
index ebee79d..b6a3dc4 100644
--- a/engines/access/scripts.h
+++ b/engines/access/scripts.h
@@ -122,7 +122,7 @@ protected:
 	void cmdDead();
 	void cmdDead(int deathId);
 	void cmdFadeOut();
-	void CMDENDVID();
+	void cmdEndVideo();
 public:
 	int _sequence;
 	bool _endFlag;


Commit: d2d75dd4a7b3b7d2a90186adf82d45c1c18e3c2a
    https://github.com/scummvm/scummvm/commit/d2d75dd4a7b3b7d2a90186adf82d45c1c18e3c2a
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-12T22:40:44-05:00

Commit Message:
ACCESS: Workaround for original game bug doing inventory check

In scene 31, moving the corrugated metal does a check on an invalid item
index

Changed paths:
    engines/access/inventory.cpp



diff --git a/engines/access/inventory.cpp b/engines/access/inventory.cpp
index 34470ac..11baa8f 100644
--- a/engines/access/inventory.cpp
+++ b/engines/access/inventory.cpp
@@ -87,7 +87,10 @@ InventoryManager::InventoryManager(AccessEngine *vm) : Manager(vm) {
 }
 
 int &InventoryManager::operator[](int idx) {
-	return _inv[idx]._value;
+	// WORKAROUND: At least in Amazon, some game scripts accidentally do reads
+	// beyond the length of the inventory array
+	static int invalid = 0;
+	return (idx >= _inv.size()) ? invalid : _inv[idx]._value;
 }
 
 int InventoryManager::useItem() { 


Commit: a9131a93c377311addf8f74d0b71fe6c8fac3aa7
    https://github.com/scummvm/scummvm/commit/a9131a93c377311addf8f74d0b71fe6c8fac3aa7
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-12T22:40:58-05:00

Commit Message:
ACCESS: Fix freeing alternate player sprites resource

Changed paths:
    engines/access/amazon/amazon_room.cpp



diff --git a/engines/access/amazon/amazon_room.cpp b/engines/access/amazon/amazon_room.cpp
index 3381688..762daf0 100644
--- a/engines/access/amazon/amazon_room.cpp
+++ b/engines/access/amazon/amazon_room.cpp
@@ -211,8 +211,8 @@ void AmazonRoom::init4Quads() {
 }
 
 void AmazonRoom::clearRoom() {
-	Room::clearRoom();
 	_game->freeInactivePlayer();
+	Room::clearRoom();
 }
 
 } // End of namespace Amazon


Commit: cdb2159ba282bd8218db86651199ee8072603525
    https://github.com/scummvm/scummvm/commit/cdb2159ba282bd8218db86651199ee8072603525
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-12T22:41:18-05:00

Commit Message:
ACCESS: Workaround for original Amazon bug trying to draw player in
cutscene

In scene 33, the game briefly adds the player to the _images list, even
though no player sprites have been loaded, since it's a cutscene scene

Changed paths:
    engines/access/player.cpp



diff --git a/engines/access/player.cpp b/engines/access/player.cpp
index 2abe9ad..7adfc5e 100644
--- a/engines/access/player.cpp
+++ b/engines/access/player.cpp
@@ -666,7 +666,8 @@ void Player::plotCom1() {
 }
 
 void Player::plotCom2() {
-	if (!_playerOff)
+	// WORKAROUND: Amazon has at least one cutscene with the player not properly turned off
+	if (!_playerOff && _spritesPtr != nullptr)
 		_vm->_images.addToList(*this);
 }
 


Commit: 36a3c5d2341204cbbba8bd067f90e65820edb72b
    https://github.com/scummvm/scummvm/commit/36a3c5d2341204cbbba8bd067f90e65820edb72b
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-12T22:41:33-05:00

Commit Message:
ACCESS: Implement riverJumpTest

Changed paths:
    engines/access/amazon/amazon_scripts.cpp
    engines/access/amazon/amazon_scripts.h



diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp
index e4c58c9..c61229b 100644
--- a/engines/access/amazon/amazon_scripts.cpp
+++ b/engines/access/amazon/amazon_scripts.cpp
@@ -1733,10 +1733,60 @@ void AmazonScripts::initRiver() {
 	_game->_saveRiver = 0;
 }
 
-bool AmazonScripts::JUMPTEST() {
-	warning("TODO: JUMPTEST();");
+void AmazonScripts::RESETPOSITIONS() {
+	warning("TODO: RESETPOSITIONS");
+}
+
+void AmazonScripts::CHECKRIVERPAN() {
+	warning("TODO: CHECKRIVERPAN");
+}
+
+bool AmazonScripts::riverJumpTest() {
+	if (_vm->_screen->_scrollCol == 120 || _vm->_screen->_scrollCol == 60 || _vm->_screen->_scrollCol == 0) {
+		int val = _game->_mapPtr[0];
+		++_game->_mapPtr;
+		if (val == 0xFF)
+			return true;
+		_game->_oldScrollCol = _vm->_screen->_scrollCol;
+
+		if (val == 0) {
+			_vm->_screen->_scrollCol = 139;
+			_vm->_screen->_scrollX = 14;
+			_vm->_room->buildScreen();
+			RESETPOSITIONS();
+			return false;
+		}
+	} else if (_vm->_screen->_scrollCol == 105) {
+		int val1 = _game->_mapPtr[1];
+		int val2 = _game->_mapPtr[2];
+		_game->_mapPtr += 3;
+		if (_game->_canoeLane < 3) {
+			if (val1 != 0) {
+				_game->_deathFlag = true;
+				_game->_deathCount = 300;
+				_game->_deathType = val2;
+			}
+		} else {
+			if (val1 != 1) {
+				_game->_deathFlag = true;
+				_game->_deathCount = 300;
+				_game->_deathType = val2;
+			}
+			_game->_oldScrollCol = _vm->_screen->_scrollCol;
+			_vm->_screen->_scrollCol = 44;
+			_vm->_screen->_scrollX = 14;
+			_vm->_room->buildScreen();
+			RESETPOSITIONS();
+			return false;
+		}
+	}
 
-	return true;
+	_vm->_screen->_scrollX = 14;
+	--_vm->_screen->_scrollCol;
+	_vm->_buffer1.moveBufferRight();
+	_vm->_room->buildColumn(_vm->_screen->_scrollCol, 0);
+	CHECKRIVERPAN();
+	return false;
 }
 
 void AmazonScripts::riverSound() {
@@ -1784,7 +1834,7 @@ void AmazonScripts::RIVER() {
 		int bx = _vm->_player->_scrollAmount - _screenVertX;
 		if (_vm->_screen->_scrollX == 0) {
 			_vm->_sound->midiRepeat();
-			if (JUMPTEST()) {
+			if (riverJumpTest()) {
 				CHICKENOUTFLG = false;
 				return;
 			}
diff --git a/engines/access/amazon/amazon_scripts.h b/engines/access/amazon/amazon_scripts.h
index 7162bab..155afb8 100644
--- a/engines/access/amazon/amazon_scripts.h
+++ b/engines/access/amazon/amazon_scripts.h
@@ -96,7 +96,9 @@ protected:
 	void doCast(int param1);
 	void loadBackground(int param1, int param2);
 	void initRiver();
-	bool JUMPTEST();
+	void RESETPOSITIONS();
+	void CHECKRIVERPAN();
+	bool riverJumpTest();
 	void riverSound();
 	void MOVECANOE();
 	void UPDATEOBSTACLES();


Commit: 74a15d659989f90140b8ff30ad4af4783802b758
    https://github.com/scummvm/scummvm/commit/74a15d659989f90140b8ff30ad4af4783802b758
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-12T22:41:45-05:00

Commit Message:
ACCESS: Fix the mWhileDownRiver cutscene

Changed paths:
    engines/access/amazon/amazon_resources.cpp
    engines/access/amazon/amazon_resources.h
    engines/access/amazon/amazon_scripts.cpp



diff --git a/engines/access/amazon/amazon_resources.cpp b/engines/access/amazon/amazon_resources.cpp
index 192af2c..af631ea 100644
--- a/engines/access/amazon/amazon_resources.cpp
+++ b/engines/access/amazon/amazon_resources.cpp
@@ -1557,6 +1557,23 @@ const byte MAP2[32] = {
 
 const byte *MAPTBL[3] = {MAP0, MAP1, MAP2};
 
+const int DOWNRIVEROBJ[14][4] = {
+	{ 3, 77, 0, 40 },
+	{ 2, 30, 0, 30 },
+	{ 2, 290, 0, 50 },
+	{ 1, 210, 0, 70 },
+	{ 2, 350, 0, 30 },
+	{ 1, 370, 0, 20 },
+	{ 2, 480, 0, 60 },
+	{ 3, 395, 0, 10 },
+	{ 1, 550, 0, 30 },
+	{ 2, 620, 0, 50 },
+	{ 1, 690, 0, 10 },
+	{ 2, 715, 0, 40 },
+	{ 1, 770, 0, 30 },
+	{ 3, 700, 0, 20 }
+};
+
 const RiverStruct RIVER0OBJECTS[45] = {
 	{16,  31, 6400, 0, 4, 12},
 	{16,  31, 6200, 0, 2, 12},
diff --git a/engines/access/amazon/amazon_resources.h b/engines/access/amazon/amazon_resources.h
index ec41276..02560cc 100644
--- a/engines/access/amazon/amazon_resources.h
+++ b/engines/access/amazon/amazon_resources.h
@@ -99,6 +99,8 @@ extern const byte MAP2[32];
 
 extern const byte *MAPTBL[3];
 
+extern const int DOWNRIVEROBJ[14][4];
+
 extern const RiverStruct RIVER0OBJECTS[45];
 extern const RiverStruct ENDRIVER0[1];
 extern const RiverStruct RIVER1OBJECTS[49];
diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp
index c61229b..4fc0a4b 100644
--- a/engines/access/amazon/amazon_scripts.cpp
+++ b/engines/access/amazon/amazon_scripts.cpp
@@ -782,23 +782,6 @@ void AmazonScripts::scrollRiver() {
 }
 
 void AmazonScripts::mWhileDownRiver() {
-	static const int RIVEROBJ[14][4] = {
-		{3,  77, 0, 40},
-		{2,  30, 0, 30},
-		{2, 290, 0, 50},
-		{1, 210, 0, 70},
-		{2, 350, 0, 30},
-		{1, 370, 0, 20},
-		{2, 480, 0, 60},
-		{3, 395, 0, 10},
-		{1, 550, 0, 30},
-		{2, 620, 0, 50},
-		{1, 690, 0, 10},
-		{2, 715, 0, 40},
-		{1, 770, 0, 30},
-		{3, 700, 0, 20}
-	};
-
 	_vm->_events->hideCursor();
 	_vm->_screen->setDisplayScan();
 	_vm->_screen->clearScreen();
@@ -813,8 +796,6 @@ void AmazonScripts::mWhileDownRiver() {
 	_vm->_room->buildScreen();
 	_vm->copyBF2Vid();
 
-	// KEYFLG = 0;
-
 	_vm->_player->_scrollAmount = 2;
 	_vm->_destIn = &_vm->_buffer2;
 	_xTrack = -7;
@@ -829,10 +810,10 @@ void AmazonScripts::mWhileDownRiver() {
 	_pNumObj = 14;
 	for (int i = 0; i <_pNumObj; i++) {
 		_pObject[i] = _vm->_objectsTable[33];
-		_pImgNum[i] = RIVEROBJ[i][0];
-		_pObjX[i] = RIVEROBJ[i][1];
-		_pObjY[i] = RIVEROBJ[i][2];
-		_pObjZ[i] = RIVEROBJ[i][3];
+		_pImgNum[i] = DOWNRIVEROBJ[i][0];
+		_pObjX[i] = DOWNRIVEROBJ[i][1];
+		_pObjY[i] = DOWNRIVEROBJ[i][2];
+		_pObjZ[i] = DOWNRIVEROBJ[i][3];
 		_pObjXl[i] = _pObjYl[i] = 0;
 	}
 
@@ -843,34 +824,35 @@ void AmazonScripts::mWhileDownRiver() {
 	_game->_timers[4]._initTm = 350;
 	++_game->_timers[4]._flag;
 
-	while(true) {
+	while (!_vm->shouldQuit() && !_vm->_events->isKeyMousePressed() &&
+			(_vm->_screen->_scrollCol + _vm->_screen->_vWindowWidth != _vm->_room->_playFieldWidth)) {
 		_vm->_images.clear();
 		_vm->_events->_vbCount = 6;
-		while ((_vm->_screen->_scrollCol + _vm->_screen->_vWindowWidth != _vm->_room->_playFieldWidth) && _vm->_events->_vbCount) {
-			jungleMove();
-			while (_vm->_screen->_scrollX >= TILE_WIDTH) {
-				_vm->_screen->_scrollX -= TILE_WIDTH;
-				++_vm->_screen->_scrollCol;
-				_vm->_buffer1.moveBufferLeft();
-				_vm->_room->buildColumn(_vm->_screen->_scrollCol + _vm->_screen->_vWindowWidth, _vm->_screen->_vWindowBytesWide);
-			}
 
-			pan();
-			scrollRiver();
+		_vm->_screen->_scrollX += _vm->_player->_scrollAmount;
+		while (_vm->_screen->_scrollX >= TILE_WIDTH) {
+			_vm->_screen->_scrollX -= TILE_WIDTH;
+			++_vm->_screen->_scrollCol;
+			_vm->_buffer1.moveBufferLeft();
+			_vm->_room->buildColumn(_vm->_screen->_scrollCol + _vm->_screen->_vWindowWidth, _vm->_screen->_vWindowBytesWide);
+		}
 
-			if (_game->_timers[3]._flag == 0) {
-				_game->_timers[3]._flag = 1;
-				_vm->_sound->playSound(1);
-			} else if (_game->_timers[4]._flag == 0) {
-				_game->_timers[4]._flag = 1;
-				_vm->_sound->playSound(0);
-			}
+		pan();
+		scrollRiver();
 
-			while (!_vm->shouldQuit() && _vm->_events->_vbCount > 0) {
-				_vm->_events->pollEventsAndWait();
-			}
+		if (!_game->_timers[3]._flag) {
+			++_game->_timers[3]._flag;
+			_vm->_sound->playSound(1);
+		} else if (!_game->_timers[4]._flag) {
+			++_game->_timers[4]._flag;
+			_vm->_sound->playSound(0);
+		}
+
+		while (!_vm->shouldQuit() && _vm->_events->_vbCount > 0) {
+			_vm->_events->pollEventsAndWait();
 		}
 	}
+
 	_vm->_events->showCursor();
 }
 


Commit: cc07c2e5a229381a5efe5d2aa092270b6dd0b75a
    https://github.com/scummvm/scummvm/commit/cc07c2e5a229381a5efe5d2aa092270b6dd0b75a
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-12T22:42:10-05:00

Commit Message:
ACCESS: Implement two more RIVER related functions

Changed paths:
    engines/access/amazon/amazon_game.h
    engines/access/amazon/amazon_resources.cpp
    engines/access/amazon/amazon_resources.h
    engines/access/amazon/amazon_scripts.cpp
    engines/access/amazon/amazon_scripts.h



diff --git a/engines/access/amazon/amazon_game.h b/engines/access/amazon/amazon_game.h
index 05caa21..c646f51 100644
--- a/engines/access/amazon/amazon_game.h
+++ b/engines/access/amazon/amazon_game.h
@@ -103,8 +103,8 @@ public:
 	bool _charSegSwitch;
 	bool _skipStart;
 
-	const RiverStruct *_topList;
-	const RiverStruct *_botList;
+	RiverStruct *_topList;
+	RiverStruct *_botList;
 	int _canoeDir;
 
 	// Fields that are mapped to flags
diff --git a/engines/access/amazon/amazon_resources.cpp b/engines/access/amazon/amazon_resources.cpp
index af631ea..23929ef 100644
--- a/engines/access/amazon/amazon_resources.cpp
+++ b/engines/access/amazon/amazon_resources.cpp
@@ -1574,7 +1574,7 @@ const int DOWNRIVEROBJ[14][4] = {
 	{ 3, 700, 0, 20 }
 };
 
-const RiverStruct RIVER0OBJECTS[45] = {
+RiverStruct RIVER0OBJECTS[45] = {
 	{16,  31, 6400, 0, 4, 12},
 	{16,  31, 6200, 0, 2, 12},
 	{17,  30, 6100, 0, 3, 15},
@@ -1622,9 +1622,9 @@ const RiverStruct RIVER0OBJECTS[45] = {
 	{17,  30,  305, 0, 2, 15}
 };
 
-const RiverStruct ENDRIVER0[1] = {16, 31, 260, 0, 7, 12};
+RiverStruct ENDRIVER0[1] = {16, 31, 260, 0, 7, 12};
 
-const RiverStruct RIVER1OBJECTS[49] = {
+RiverStruct RIVER1OBJECTS[49] = {
 	{16,  31, 6920, 0, 1, 12},
 	{16,  31, 6740, 0, 4, 12},
 	{17,  30, 6699, 0, 1, 15},
@@ -1676,9 +1676,9 @@ const RiverStruct RIVER1OBJECTS[49] = {
 	{17,  30,  305, 0, 3, 15}
 };
 
-const RiverStruct ENDRIVER1[1] = {16, 31, 260, 0, 1, 12};
+RiverStruct ENDRIVER1[1] = {16, 31, 260, 0, 1, 12};
 
-const RiverStruct RIVER2OBJECTS[53] = {
+RiverStruct RIVER2OBJECTS[53] = {
 	{16,  31, 8230, 0, 6, 12},
 	{16,  31, 8115, 0, 7, 12},
 	{17,  30, 7955, 0, 4, 15},
@@ -1734,9 +1734,9 @@ const RiverStruct RIVER2OBJECTS[53] = {
 	{17,  30,  305, 0, 3, 15}
 };
 
-const RiverStruct ENDRIVER2[1] = {16, 31, 260, 0, 6, 12};
+RiverStruct ENDRIVER2[1] = {16, 31, 260, 0, 6, 12};
 
-const RiverStruct *RIVEROBJECTTBL[6] = {
+RiverStruct *RIVEROBJECTTBL[6] = {
 	RIVER0OBJECTS, ENDRIVER0, RIVER1OBJECTS, 
 	ENDRIVER1, RIVER2OBJECTS, ENDRIVER2
 };
diff --git a/engines/access/amazon/amazon_resources.h b/engines/access/amazon/amazon_resources.h
index 02560cc..99ce40e 100644
--- a/engines/access/amazon/amazon_resources.h
+++ b/engines/access/amazon/amazon_resources.h
@@ -101,14 +101,14 @@ extern const byte *MAPTBL[3];
 
 extern const int DOWNRIVEROBJ[14][4];
 
-extern const RiverStruct RIVER0OBJECTS[45];
-extern const RiverStruct ENDRIVER0[1];
-extern const RiverStruct RIVER1OBJECTS[49];
-extern const RiverStruct ENDRIVER1[1];
-extern const RiverStruct RIVER2OBJECTS[53];
-extern const RiverStruct ENDRIVER2[1];
-
-extern const RiverStruct *RIVEROBJECTTBL[6];
+extern RiverStruct RIVER0OBJECTS[45];
+extern RiverStruct ENDRIVER0[1];
+extern RiverStruct RIVER1OBJECTS[49];
+extern RiverStruct ENDRIVER1[1];
+extern RiverStruct RIVER2OBJECTS[53];
+extern RiverStruct ENDRIVER2[1];
+
+extern RiverStruct *RIVEROBJECTTBL[6];
 
 } // End of namespace Amazon
 
diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp
index 4fc0a4b..3bd1148 100644
--- a/engines/access/amazon/amazon_scripts.cpp
+++ b/engines/access/amazon/amazon_scripts.cpp
@@ -1699,7 +1699,7 @@ void AmazonScripts::initRiver() {
 	_game->_riverIndex = _game->_riverFlag;
 	_game->_topList = RIVEROBJECTTBL[_game->_riverIndex];
 	UPDATEOBSTACLES();
-	SETPHYSX();
+	riverSetPhysX();
 	_game->_canoeDir = 0;
 	_game->_deathFlag = 0;
 	_game->_deathCount = 0;
@@ -1715,8 +1715,16 @@ void AmazonScripts::initRiver() {
 	_game->_saveRiver = 0;
 }
 
-void AmazonScripts::RESETPOSITIONS() {
-	warning("TODO: RESETPOSITIONS");
+void AmazonScripts::resetPositions() {
+	riverSetPhysX();
+	int val = (_vm->_screen->_scrollCol + 1 - _game->_oldScrollCol) * 16;
+	if (val > 256) {
+		val &= 0x7F;
+		val |= 0x80;
+	}
+
+	for (int i = 0; i < _pNumObj; i++)
+		_pObjX[i] += val;
 }
 
 void AmazonScripts::CHECKRIVERPAN() {
@@ -1735,7 +1743,7 @@ bool AmazonScripts::riverJumpTest() {
 			_vm->_screen->_scrollCol = 139;
 			_vm->_screen->_scrollX = 14;
 			_vm->_room->buildScreen();
-			RESETPOSITIONS();
+			resetPositions();
 			return false;
 		}
 	} else if (_vm->_screen->_scrollCol == 105) {
@@ -1758,7 +1766,7 @@ bool AmazonScripts::riverJumpTest() {
 			_vm->_screen->_scrollCol = 44;
 			_vm->_screen->_scrollX = 14;
 			_vm->_room->buildScreen();
-			RESETPOSITIONS();
+			resetPositions();
 			return false;
 		}
 	}
@@ -1794,8 +1802,14 @@ void AmazonScripts::UPDATEOBSTACLES() {
 	warning("TODO: UPDATEOBSTACLES()");
 }
 
-void AmazonScripts::SETPHYSX() {
-	warning("TODO: SETPHYSX()");
+void AmazonScripts::riverSetPhysX() {
+	int val = (_vm->_screen->_scrollCol * 16) + _vm->_screen->_scrollX;
+	RiverStruct *si = _game->_topList;
+	RiverStruct *di = _game->_botList;
+	while (si <= di) {
+		si[0]._field5 = val - (_screenVertX - si[0]._field3);
+		si = &si[1];
+	}
 }
 
 void AmazonScripts::RIVERCOLLIDE() {
@@ -1842,7 +1856,7 @@ void AmazonScripts::RIVER() {
 		}
 		
 		UPDATEOBSTACLES();
-		SETPHYSX();
+		riverSetPhysX();
 		RIVERCOLLIDE();
 		if (_game->_hitSafe != 0)
 			_game->_hitSafe -= 2;
diff --git a/engines/access/amazon/amazon_scripts.h b/engines/access/amazon/amazon_scripts.h
index 155afb8..2b634ca 100644
--- a/engines/access/amazon/amazon_scripts.h
+++ b/engines/access/amazon/amazon_scripts.h
@@ -96,13 +96,13 @@ protected:
 	void doCast(int param1);
 	void loadBackground(int param1, int param2);
 	void initRiver();
-	void RESETPOSITIONS();
+	void resetPositions();
 	void CHECKRIVERPAN();
 	bool riverJumpTest();
 	void riverSound();
 	void MOVECANOE();
 	void UPDATEOBSTACLES();
-	void SETPHYSX();
+	void riverSetPhysX();
 	void RIVERCOLLIDE();
 	void SCROLLRIVER1();
 	void setRiverPan();


Commit: 68dc425cd4ba6907be6b1fa46c2251e5715b8803
    https://github.com/scummvm/scummvm/commit/68dc425cd4ba6907be6b1fa46c2251e5715b8803
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-12T22:42:36-05:00

Commit Message:
ACCESS: Implemented buildRow for vertical screen scrolling

Changed paths:
    engines/access/asurface.cpp
    engines/access/room.cpp



diff --git a/engines/access/asurface.cpp b/engines/access/asurface.cpp
index dbbf119..96cb199 100644
--- a/engines/access/asurface.cpp
+++ b/engines/access/asurface.cpp
@@ -337,12 +337,12 @@ void ASurface::moveBufferRight() {
 
 void ASurface::moveBufferUp() {
 	byte *p = (byte *)getPixels();
-	Common::copy(p + w, p + (w * h), p);
+	Common::copy(p + (w * TILE_HEIGHT), p + (w * h), p);
 }
 
 void ASurface::moveBufferDown() {
 	byte *p = (byte *)getPixels();
-	Common::copy_backward(p, p + (w * (h - 1)), p + (w * h));
+	Common::copy_backward(p, p + (w * (h - TILE_HEIGHT)), p + (w * h));
 }
 
 } // End of namespace Access
diff --git a/engines/access/room.cpp b/engines/access/room.cpp
index 37746d1..f32bc95 100644
--- a/engines/access/room.cpp
+++ b/engines/access/room.cpp
@@ -339,7 +339,27 @@ void Room::buildColumn(int playX, int screenX) {
 }
 
 void Room::buildRow(int playY, int screenY) {
-	error("TODO: buildRow");
+	if (playY < 0 || playY >= _playFieldHeight)
+		return;
+	assert(screenY <= (_vm->_screen->h - TILE_HEIGHT));
+
+	const byte *pSrc = _playField + screenY *_playFieldWidth + _vm->_screen->_scrollCol;
+
+	// WORKAROUND: Original's use of '+ 1' would frequently cause memory overruns
+	int w = MIN(_vm->_screen->_vWindowWidth + 1, _playFieldWidth);
+
+	for (int x = 0; x < w; ++x) {
+		byte *pTile = _tile + (*pSrc << 8);
+		byte *pDest = (byte *)_vm->_buffer1.getBasePtr(w * TILE_WIDTH, screenY);
+
+		for (int tileY = 0; tileY < TILE_HEIGHT; ++tileY) {
+			Common::copy(pTile, pTile + TILE_WIDTH, pDest);
+			pTile += TILE_WIDTH;
+			pDest += _vm->_buffer1.pitch;
+		}
+
+		++pSrc;
+	}
 }
 
 void Room::loadPlayField(int fileNum, int subfile) {


Commit: 0c4fdc6a4896a4690af45aa0aabe77d90fffcaaf
    https://github.com/scummvm/scummvm/commit/0c4fdc6a4896a4690af45aa0aabe77d90fffcaaf
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-12T22:42:50-05:00

Commit Message:
ACCESS: Implement some more RIVER functions

Changed paths:
    engines/access/amazon/amazon_scripts.cpp
    engines/access/amazon/amazon_scripts.h



diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp
index 3bd1148..3f0e53e 100644
--- a/engines/access/amazon/amazon_scripts.cpp
+++ b/engines/access/amazon/amazon_scripts.cpp
@@ -1727,8 +1727,15 @@ void AmazonScripts::resetPositions() {
 		_pObjX[i] += val;
 }
 
-void AmazonScripts::CHECKRIVERPAN() {
-	warning("TODO: CHECKRIVERPAN");
+void AmazonScripts::checkRiverPan() {
+	int val = (_vm->_screen->_scrollCol + 20) * 16;
+
+	for (int i = 0; i < _pNumObj; i++) {
+		if (_pObjX[i] < val)
+			return;
+	}
+
+	setRiverPan();
 }
 
 bool AmazonScripts::riverJumpTest() {
@@ -1775,7 +1782,7 @@ bool AmazonScripts::riverJumpTest() {
 	--_vm->_screen->_scrollCol;
 	_vm->_buffer1.moveBufferRight();
 	_vm->_room->buildColumn(_vm->_screen->_scrollCol, 0);
-	CHECKRIVERPAN();
+	checkRiverPan();
 	return false;
 }
 
@@ -1816,8 +1823,17 @@ void AmazonScripts::RIVERCOLLIDE() {
 	warning("TODO: RIVERCOLLIDE()");
 }
 
-void AmazonScripts::SCROLLRIVER1() {
-	warning("TODO: SCROLLRIVER1()");
+void AmazonScripts::PLOTRIVER() {
+	warning("TODO: PLOTRIVER");
+}
+
+void AmazonScripts::scrollRiver1() {
+	_vm->copyBF1BF2();
+	_vm->_newRects.clear();
+	PLOTRIVER();
+	_vm->plotList();
+	_vm->copyRects();
+	_vm->copyBF2Vid();
 }
 
 void AmazonScripts::RIVER() {
@@ -1876,10 +1892,10 @@ void AmazonScripts::RIVER() {
 		
 		if (_vm->_events->_mousePos.y >= 24 && _vm->_events->_mousePos.y <= 136) {
 			_vm->_events->hideCursor();
-			SCROLLRIVER1();
+			scrollRiver1();
 			_vm->_events->pollEvents();
 		} else
-			SCROLLRIVER1();
+			scrollRiver1();
 
 		while (!_vm->shouldQuit() && _vm->_events->_vbCount > 0) {
 			_vm->_events->pollEventsAndWait();
diff --git a/engines/access/amazon/amazon_scripts.h b/engines/access/amazon/amazon_scripts.h
index 2b634ca..1e3290e 100644
--- a/engines/access/amazon/amazon_scripts.h
+++ b/engines/access/amazon/amazon_scripts.h
@@ -97,14 +97,15 @@ protected:
 	void loadBackground(int param1, int param2);
 	void initRiver();
 	void resetPositions();
-	void CHECKRIVERPAN();
+	void checkRiverPan();
 	bool riverJumpTest();
 	void riverSound();
 	void MOVECANOE();
 	void UPDATEOBSTACLES();
 	void riverSetPhysX();
 	void RIVERCOLLIDE();
-	void SCROLLRIVER1();
+	void PLOTRIVER();
+	void scrollRiver1();
 	void setRiverPan();
 	void RIVER();
 	void plotInactive();


Commit: 51ccd0c1fbbb2065441e6c7fbbe7f6ec6c3c3e3e
    https://github.com/scummvm/scummvm/commit/51ccd0c1fbbb2065441e6c7fbbe7f6ec6c3c3e3e
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-12T22:43:03-05:00

Commit Message:
ACCESS: Implement moveCanoe

Changed paths:
    engines/access/amazon/amazon_resources.cpp
    engines/access/amazon/amazon_resources.h
    engines/access/amazon/amazon_scripts.cpp
    engines/access/amazon/amazon_scripts.h



diff --git a/engines/access/amazon/amazon_resources.cpp b/engines/access/amazon/amazon_resources.cpp
index 23929ef..08b5795 100644
--- a/engines/access/amazon/amazon_resources.cpp
+++ b/engines/access/amazon/amazon_resources.cpp
@@ -1209,9 +1209,10 @@ const char *const NO_HELP_MESSAGE =
 	"WE ARE UNABLE TO PROVIDE YOU WITH ANY MORE HINTS.  YOUR IQ \
 HAS DECREASED SO FAR THAT WE CAN NO LONGER PUT THE HINTS IN TERMS \
 YOU CAN UNDERSTAND.";
-const char *const NO_HINTS_MESSAGE =
-	"THE HELP SYSTEM HAS BEEN TURNED OFF FOR THIS GAME.";
-
+const char *const NO_HINTS_MESSAGE = "THE HELP SYSTEM HAS BEEN TURNED OFF FOR THIS GAME.";
+const char *const HIT1 = "YOU HIT THE ROCKS AND THE CANOE BEGINS TO LEAK.";
+const char *const HIT2 = "YOU HIT THE ROCKS AND THE CANOE DEVELOPS SERIOUS LEAKS.";
+const char *const BAR_MESSAGE = "YOU ARE TOO BUSY TRYING TO KEEP FROM SINKING TO DO THAT";
 
 const byte DEATH_SCREENS[58] = {
 	0,  1,  0,  0,  0,  0,  0,  0,  2,  0,
diff --git a/engines/access/amazon/amazon_resources.h b/engines/access/amazon/amazon_resources.h
index 99ce40e..65a38dc 100644
--- a/engines/access/amazon/amazon_resources.h
+++ b/engines/access/amazon/amazon_resources.h
@@ -62,6 +62,9 @@ extern const byte FONT6x6_DATA[];
 
 extern const char *const NO_HELP_MESSAGE;
 extern const char *const NO_HINTS_MESSAGE;
+extern const char *const HIT1;
+extern const char *const HIT2;
+extern const char *const BAR_MESSAGE;
 
 extern const byte DEATH_SCREENS[58];
 
diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp
index 3f0e53e..5e53e0b 100644
--- a/engines/access/amazon/amazon_scripts.cpp
+++ b/engines/access/amazon/amazon_scripts.cpp
@@ -22,6 +22,7 @@
 
 #include "common/scummsys.h"
 #include "access/access.h"
+#include "access/resources.h"
 #include "access/amazon/amazon_game.h"
 #include "access/amazon/amazon_resources.h"
 #include "access/amazon/amazon_scripts.h"
@@ -1801,8 +1802,99 @@ void AmazonScripts::riverSound() {
 		_vm->_sound->playSound(1);
 }
 
-void AmazonScripts::MOVECANOE() {
-	warning("TODO: MOVECANOE();");
+void AmazonScripts::moveCanoe() {
+	if (_game->_canoeDir != 0) {
+		_game->_canoeYPos += _game->_canoeDir;
+		++_game->_canoeMoveCount;
+		if (_game->_canoeMoveCount == 5) {
+			_game->_canoeLane += _game->_canoeDir;
+			_game->_canoeDir = 0;
+		}
+		return;
+	}
+
+	_vm->_events->pollEvents();
+	if (_vm->_events->_leftButton) {
+		Common::Point pt = _vm->_events->calcRawMouse();
+		if (pt.y < 180) {
+			if (_vm->_events->_mousePos.x < RMOUSE[8][0]) {
+				printString(BAR_MESSAGE);
+				return;
+			}
+			_game->_saveRiver = 1;
+			_vm->_rScrollRow = _vm->_screen->_scrollRow;
+			_vm->_rScrollCol = _vm->_screen->_scrollCol;
+			_vm->_rScrollX = _vm->_screen->_scrollX;
+			_vm->_rScrollY = _vm->_screen->_scrollY;
+			_vm->_rOldRectCount = _vm->_oldRects.size();
+			_vm->_rNewRectCount = _vm->_newRects.size();
+			// _vm->_rKeyFlag = KEYFLG;
+			_vm->_mapOffset = _game->_mapPtr - MAPTBL[_game->_riverFlag];
+			_vm->doLoadSave();
+			if (_vm->_room->_function == 1) {
+				_endFlag = true;
+				_returnCode = 0;
+			} else {
+				_game->_saveRiver = 0;
+				_vm->_room->buildScreen();
+				_vm->copyBF2Vid();
+			}
+			return;
+		} 
+		
+		if (pt.y <= _game->_canoeYPos) {
+			if (_game->_canoeLane == 0)
+				return;
+
+			_game->_canoeDir = -1;
+			_game->_canoeMoveCount = 0;
+			_game->_canoeYPos += _game->_canoeDir;
+			++_game->_canoeMoveCount;
+			if (_game->_canoeMoveCount == 5) {
+				_game->_canoeLane += _game->_canoeDir;
+				_game->_canoeDir = 0;
+			}
+		} else {
+			if (_game->_canoeLane == 7)
+				return;
+
+			_game->_canoeDir = 1;
+			_game->_canoeMoveCount = 0;
+			_game->_canoeYPos += _game->_canoeDir;
+			++_game->_canoeMoveCount;
+			if (_game->_canoeMoveCount == 5) {
+				_game->_canoeLane += _game->_canoeDir;
+				_game->_canoeDir = 0;
+			}
+		}
+		return;
+	}	
+
+	if (_vm->_player->_move == UP) {
+		if (_game->_canoeLane == 0)
+			return;
+
+		_game->_canoeDir = -1;
+		_game->_canoeMoveCount = 0;
+		_game->_canoeYPos += _game->_canoeDir;
+		++_game->_canoeMoveCount;
+		if (_game->_canoeMoveCount == 5) {
+			_game->_canoeLane += _game->_canoeDir;
+			_game->_canoeDir = 0;
+		}
+	} else if (_vm->_player->_move == DOWN) {
+		if (_game->_canoeLane == 7)
+			return;
+
+		_game->_canoeDir = 1;
+		_game->_canoeMoveCount = 0;
+		_game->_canoeYPos += _game->_canoeDir;
+		++_game->_canoeMoveCount;
+		if (_game->_canoeMoveCount == 5) {
+			_game->_canoeLane += _game->_canoeDir;
+			_game->_canoeDir = 0;
+		}
+	}
 }
 
 void AmazonScripts::UPDATEOBSTACLES() {
@@ -1864,7 +1956,7 @@ void AmazonScripts::RIVER() {
 
 		riverSound();
 		pan();
-		MOVECANOE();
+		moveCanoe();
 
 		if (_vm->_room->_function == 1) {
 			CHICKENOUTFLG = false;
diff --git a/engines/access/amazon/amazon_scripts.h b/engines/access/amazon/amazon_scripts.h
index 1e3290e..20fca8e 100644
--- a/engines/access/amazon/amazon_scripts.h
+++ b/engines/access/amazon/amazon_scripts.h
@@ -100,7 +100,7 @@ protected:
 	void checkRiverPan();
 	bool riverJumpTest();
 	void riverSound();
-	void MOVECANOE();
+	void moveCanoe();
 	void UPDATEOBSTACLES();
 	void riverSetPhysX();
 	void RIVERCOLLIDE();


Commit: f1b99b0ede325c1f447ce79e2c00159871ee1462
    https://github.com/scummvm/scummvm/commit/f1b99b0ede325c1f447ce79e2c00159871ee1462
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-12T22:43:14-05:00

Commit Message:
ACCESS: Implement plotRiver

Changed paths:
    engines/access/amazon/amazon_scripts.cpp
    engines/access/amazon/amazon_scripts.h



diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp
index 5e53e0b..2c16938 100644
--- a/engines/access/amazon/amazon_scripts.cpp
+++ b/engines/access/amazon/amazon_scripts.cpp
@@ -1903,11 +1903,10 @@ void AmazonScripts::UPDATEOBSTACLES() {
 
 void AmazonScripts::riverSetPhysX() {
 	int val = (_vm->_screen->_scrollCol * 16) + _vm->_screen->_scrollX;
-	RiverStruct *si = _game->_topList;
-	RiverStruct *di = _game->_botList;
-	while (si <= di) {
-		si[0]._field5 = val - (_screenVertX - si[0]._field3);
-		si = &si[1];
+	RiverStruct *cur = _game->_topList;
+	while (cur <= _game->_botList) {
+		cur[0]._field5 = val - (_screenVertX - cur[0]._field3);
+		++cur;
 	}
 }
 
@@ -1915,14 +1914,44 @@ void AmazonScripts::RIVERCOLLIDE() {
 	warning("TODO: RIVERCOLLIDE()");
 }
 
-void AmazonScripts::PLOTRIVER() {
-	warning("TODO: PLOTRIVER");
+void AmazonScripts::plotRiver() {
+	if (_vm->_timers[3]._flag == 0) {
+		++_vm->_timers[3]._flag;
+		if (_game->_canoeFrame == 12)
+			_game->_canoeFrame = 0;
+		else
+			++_game->_canoeFrame;
+	}
+
+	ImageEntry ie;
+	ie._flags = 8;
+	ie._spritesPtr = _vm->_objectsTable[45];
+	ie._frameNumber = _game->_canoeFrame;
+	ie._position.x = (_vm->_screen->_scrollCol * 16) + _vm->_screen->_scrollX + 160;
+	ie._position.y = _game->_canoeYPos - 41;
+	ie._offsetY = 41;
+	_vm->_images.addToList(ie);
+
+	RiverStruct *cur = _game->_topList;
+	while (cur <= _game->_botList) {
+		if (cur[0]._id != -1) {
+			ie._flags = 8;
+			ie._spritesPtr = _vm->_objectsTable[45];
+			ie._frameNumber = 0;
+			ie._position.x = cur[0]._field5;
+			int val = (cur[0]._lane * 5) + 56;
+			ie._position.y = val - cur[0]._field8;
+			ie._offsetY = cur[0]._field8;
+			_vm->_images.addToList(ie);
+		}
+		++cur;
+	}
 }
 
 void AmazonScripts::scrollRiver1() {
 	_vm->copyBF1BF2();
 	_vm->_newRects.clear();
-	PLOTRIVER();
+	plotRiver();
 	_vm->plotList();
 	_vm->copyRects();
 	_vm->copyBF2Vid();
diff --git a/engines/access/amazon/amazon_scripts.h b/engines/access/amazon/amazon_scripts.h
index 20fca8e..ef7ead6 100644
--- a/engines/access/amazon/amazon_scripts.h
+++ b/engines/access/amazon/amazon_scripts.h
@@ -104,7 +104,7 @@ protected:
 	void UPDATEOBSTACLES();
 	void riverSetPhysX();
 	void RIVERCOLLIDE();
-	void PLOTRIVER();
+	void plotRiver();
 	void scrollRiver1();
 	void setRiverPan();
 	void RIVER();


Commit: 8eeb5bd8e6a4f1e3ca7ff8f10c7487ebc75b6426
    https://github.com/scummvm/scummvm/commit/8eeb5bd8e6a4f1e3ca7ff8f10c7487ebc75b6426
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-12T22:43:24-05:00

Commit Message:
ACCESS: Refine scene 9 workaround to stop movement problems on ship

Changed paths:
    engines/access/amazon/amazon_room.cpp



diff --git a/engines/access/amazon/amazon_room.cpp b/engines/access/amazon/amazon_room.cpp
index 762daf0..a942ed3 100644
--- a/engines/access/amazon/amazon_room.cpp
+++ b/engines/access/amazon/amazon_room.cpp
@@ -182,7 +182,7 @@ void AmazonRoom::mainAreaClick() {
 
 		// WORKAROUND: In Amazon room 9, you can't leave the screen to the south due
 		// to not being able to click a Y position that's high enough
-		if (pt.y > 178)
+		if (_vm->_screen->_scrollRow == 0 && pt.y > 178)
 			pt.y = 200;
 
 		_vm->_player->_moveTo = pt;


Commit: b01f5d61d7ad648c5d41a86682ce28bb8f9ddc88
    https://github.com/scummvm/scummvm/commit/b01f5d61d7ad648c5d41a86682ce28bb8f9ddc88
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-12T22:43:33-05:00

Commit Message:
ACCESS: Fix vertically scrolling up the screen

Changed paths:
    engines/access/player.cpp



diff --git a/engines/access/player.cpp b/engines/access/player.cpp
index 7adfc5e..2492345 100644
--- a/engines/access/player.cpp
+++ b/engines/access/player.cpp
@@ -741,7 +741,7 @@ bool Player::scrollUp() {
 		_vm->_buffer1.moveBufferUp();
 
 		_vm->_room->buildRow(_vm->_screen->_scrollRow + _vm->_screen->_vWindowHeight,
-			_vm->_screen->_vWindowLinesTall * _vm->_screen->_bufferBytesWide);
+			_vm->_screen->_vWindowLinesTall);
 
 		if ((_vm->_screen->_scrollRow + _vm->_screen->_vWindowHeight) >=
 			_vm->_room->_playFieldHeight)


Commit: 9fa0fc845e2cc20f400790be57b607b4e656078e
    https://github.com/scummvm/scummvm/commit/9fa0fc845e2cc20f400790be57b607b4e656078e
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-12T22:43:42-05:00

Commit Message:
ACCESS: Fix 'bounce' when reaching left end of a horizontal scrolling scene

Changed paths:
    engines/access/player.cpp



diff --git a/engines/access/player.cpp b/engines/access/player.cpp
index 2492345..70f6881 100644
--- a/engines/access/player.cpp
+++ b/engines/access/player.cpp
@@ -814,8 +814,12 @@ bool Player::scrollRight() {
 	if (_vm->_screen->_scrollX < 0) {
 		do {
 			_vm->_screen->_scrollX += TILE_WIDTH;
-			if (--_vm->_screen->_scrollCol < 0)
+			if (--_vm->_screen->_scrollCol < 0) {
+				_scrollEnd = true;
+				_vm->_screen->_scrollX = 0;
+				_vm->_screen->_scrollCol = 0;
 				return true;
+			}
 
 			_vm->_buffer1.moveBufferRight();
 			_vm->_room->buildColumn(_vm->_screen->_scrollCol, 0);


Commit: 5674bed27bb43f0313e4d0a67ad94d4e41e8719c
    https://github.com/scummvm/scummvm/commit/5674bed27bb43f0313e4d0a67ad94d4e41e8719c
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-12T22:43:51-05:00

Commit Message:
ACCESS: Implement updateObstacles

Changed paths:
    engines/access/amazon/amazon_scripts.cpp
    engines/access/amazon/amazon_scripts.h



diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp
index 2c16938..b6d4987 100644
--- a/engines/access/amazon/amazon_scripts.cpp
+++ b/engines/access/amazon/amazon_scripts.cpp
@@ -1699,7 +1699,7 @@ void AmazonScripts::initRiver() {
 
 	_game->_riverIndex = _game->_riverFlag;
 	_game->_topList = RIVEROBJECTTBL[_game->_riverIndex];
-	UPDATEOBSTACLES();
+	updateObstacles();
 	riverSetPhysX();
 	_game->_canoeDir = 0;
 	_game->_deathFlag = 0;
@@ -1897,8 +1897,43 @@ void AmazonScripts::moveCanoe() {
 	}
 }
 
-void AmazonScripts::UPDATEOBSTACLES() {
-	warning("TODO: UPDATEOBSTACLES()");
+void AmazonScripts::updateObstacles() {
+	RiverStruct *cur = _game->_topList;
+	while (true) {
+		int val = cur[0]._field1 + cur[0]._field3 - 1;
+		if (val < _screenVertX) {
+			cur = _game->_topList;
+			cur--;
+			_game->_botList = cur;
+			return;
+		}
+
+		if (cur[0]._field3 < _screenVertX + 319) {
+			_game->_topList = _game->_botList = cur;
+			break;
+		}
+
+		if (cur > RIVEROBJECTTBL[_game->_riverIndex + 1]) {
+			cur = _game->_topList;
+			cur--;
+			_game->_botList = cur;
+			return;
+		}
+	}
+
+	while (true) {
+		if (cur > RIVEROBJECTTBL[_game->_riverIndex + 1])
+			return;
+		++cur;
+		int val = cur[0]._field1 + cur[0]._field3 - 1;
+		if (val < _screenVertX)
+			return;
+
+		if (cur[0]._field3 >= _screenVertX + 319)
+			return;
+
+		_game->_botList = cur;
+	}
 }
 
 void AmazonScripts::riverSetPhysX() {
@@ -1992,7 +2027,7 @@ void AmazonScripts::RIVER() {
 			return;
 		}
 		
-		UPDATEOBSTACLES();
+		updateObstacles();
 		riverSetPhysX();
 		RIVERCOLLIDE();
 		if (_game->_hitSafe != 0)
diff --git a/engines/access/amazon/amazon_scripts.h b/engines/access/amazon/amazon_scripts.h
index ef7ead6..0f71e89 100644
--- a/engines/access/amazon/amazon_scripts.h
+++ b/engines/access/amazon/amazon_scripts.h
@@ -101,7 +101,7 @@ protected:
 	bool riverJumpTest();
 	void riverSound();
 	void moveCanoe();
-	void UPDATEOBSTACLES();
+	void updateObstacles();
 	void riverSetPhysX();
 	void RIVERCOLLIDE();
 	void plotRiver();


Commit: 6e2d63e4cd8240cc1b0dae2096cbef7bde993afe
    https://github.com/scummvm/scummvm/commit/6e2d63e4cd8240cc1b0dae2096cbef7bde993afe
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-12T22:44:04-05:00

Commit Message:
ACCESS: Implement checkRiverCollide()

Changed paths:
    engines/access/amazon/amazon_scripts.cpp
    engines/access/amazon/amazon_scripts.h



diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp
index b6d4987..e83bc9f 100644
--- a/engines/access/amazon/amazon_scripts.cpp
+++ b/engines/access/amazon/amazon_scripts.cpp
@@ -1945,8 +1945,26 @@ void AmazonScripts::riverSetPhysX() {
 	}
 }
 
-void AmazonScripts::RIVERCOLLIDE() {
-	warning("TODO: RIVERCOLLIDE()");
+bool AmazonScripts::checkRiverCollide() {
+	if (_game->_hitSafe)
+		return false;
+
+	_game->_canoeVXPos = _screenVertX + 170;
+
+	for (RiverStruct *si = _game->_topList; si <= _game->_botList; ++si) {
+		if (si[0]._lane < _game->_canoeLane)
+			continue;
+
+		if ((si[0]._lane == _game->_canoeLane) || (si[0]._lane == _game->_canoeLane + 1)) {
+			if (si[0]._field1 + si[0]._field3 - 1 >= _game->_canoeVXPos) {
+				if (_game->_canoeVXPos + 124 >= si[0]._field3) {
+					_vm->_sound->playSound(4);
+					return true;
+				}
+			}
+		}
+	}
+	return false;
 }
 
 void AmazonScripts::plotRiver() {
@@ -2029,11 +2047,11 @@ void AmazonScripts::RIVER() {
 		
 		updateObstacles();
 		riverSetPhysX();
-		RIVERCOLLIDE();
+		bool checkCollide = checkRiverCollide();
 		if (_game->_hitSafe != 0)
 			_game->_hitSafe -= 2;
 
-		if (_game->_hitSafe < 0) {
+		if (checkCollide) {
 			cmdDead(RIVERDEATH[0]);
 			return;
 		}
diff --git a/engines/access/amazon/amazon_scripts.h b/engines/access/amazon/amazon_scripts.h
index 0f71e89..1da10d8 100644
--- a/engines/access/amazon/amazon_scripts.h
+++ b/engines/access/amazon/amazon_scripts.h
@@ -103,7 +103,7 @@ protected:
 	void moveCanoe();
 	void updateObstacles();
 	void riverSetPhysX();
-	void RIVERCOLLIDE();
+	bool checkRiverCollide();
 	void plotRiver();
 	void scrollRiver1();
 	void setRiverPan();


Commit: a8c99d1986a902aaf65c760b365c49cce2174e30
    https://github.com/scummvm/scummvm/commit/a8c99d1986a902aaf65c760b365c49cce2174e30
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-12T22:44:16-05:00

Commit Message:
ACCESS: Some work on drawHelp (WIP)

Changed paths:
    engines/access/amazon/amazon_game.cpp
    engines/access/amazon/amazon_game.h



diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp
index 657458f..e864a92 100644
--- a/engines/access/amazon/amazon_game.cpp
+++ b/engines/access/amazon/amazon_game.cpp
@@ -624,8 +624,70 @@ void AmazonEngine::updateSummary(int chap) {
 	}
 }
 
+void AmazonEngine::HELPTITLE() {
+	warning("TODO: HELPTITLE");
+}
+
+void AmazonEngine::drawHelpText(const Common::String &msg) {
+	_screen->_maxChars = 39;
+	_screen->_printOrg = Common::Point(26, 58);
+	_screen->_printStart = Common::Point(26, 58);
+
+	Common::String lines = msg;
+	Common::String line;
+	int width = 0;
+	bool lastLine = false;
+	do {
+		lastLine = _fonts._font2.getLine(lines, _screen->_maxChars * 6, line, width);
+
+		// Set font colors
+		_fonts._font2._fontColors[0] = 0;
+		_fonts._font2._fontColors[1] = 27;
+		_fonts._font2._fontColors[2] = 28;
+		_fonts._font2._fontColors[3] = 29;
+
+		_fonts._font2.drawString(_screen, line, _screen->_printOrg);
+		_screen->_printOrg = Common::Point(_screen->_printStart.x, _screen->_printOrg.y + 8);
+	} while (!lastLine);
+
+	_events->showCursor();
+}
+
 void AmazonEngine::drawHelp() {
-	error("TODO: drawHelp");
+	_events->hideCursor();
+	if (_useItem == 0) {
+		_buffer2.copyBuffer(_screen);
+		if (_screen->_vesaMode) {
+			_screen->setPanel(2);
+			_screen->saveScreen();
+		}
+		_screen->setPalette();
+		_screen->fadeOut();
+		_screen->clearBuffer();
+		if (_moreHelp == 1) {
+			// Set cells
+			Common::Array<CellIdent> cells;
+			cells.push_back(CellIdent(95, 95, 3));
+			loadCells(cells);
+		}
+	}
+
+	_files->loadScreen(95, 2);
+	if (_moreHelp == 1) {
+		ASurface *oldDest = _destIn;
+		_destIn = _screen;
+		int oldClip = _screen->_clipHeight;
+		_screen->_clipHeight = 200;
+		_screen->plotImage(_objectsTable[95], 0, Common::Point(76, 168));
+		_destIn = oldDest;
+		_screen->_clipHeight = oldClip;		
+	}
+
+	if ((_useItem == 0) && (_screen->_vesaMode == 0))
+		_screen->fadeIn();
+
+	HELPTITLE();
+	drawHelpText("TODO: WHICH BUFFER?");
 }
 
 void AmazonEngine::startChapter(int chapter) {
diff --git a/engines/access/amazon/amazon_game.h b/engines/access/amazon/amazon_game.h
index c646f51..0aea435 100644
--- a/engines/access/amazon/amazon_game.h
+++ b/engines/access/amazon/amazon_game.h
@@ -83,6 +83,8 @@ private:
 	 */
 	void setupGame();
 
+	void HELPTITLE();
+	void drawHelpText(const Common::String &msg);
 	void doCredit();
 	void scrollTitle();
 	void loadEstablish(int estabIndex);


Commit: cc8a8bfdddaf66f6c3b8a7ac049a05b6877eb973
    https://github.com/scummvm/scummvm/commit/cc8a8bfdddaf66f6c3b8a7ac049a05b6877eb973
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-12T22:44:43-05:00

Commit Message:
ACCESS: Refactored Amazon specific player loading into new AmazonPlayer class

Changed paths:
  A engines/access/amazon/amazon_player.cpp
  A engines/access/amazon/amazon_player.h
    engines/access/access.cpp
    engines/access/amazon/amazon_resources.cpp
    engines/access/amazon/amazon_resources.h
    engines/access/animation.cpp
    engines/access/module.mk
    engines/access/player.cpp
    engines/access/player.h
    engines/access/resources.cpp
    engines/access/resources.h



diff --git a/engines/access/access.cpp b/engines/access/access.cpp
index cdabb32..88c62a7 100644
--- a/engines/access/access.cpp
+++ b/engines/access/access.cpp
@@ -165,7 +165,7 @@ void AccessEngine::initialize() {
 	_events = new EventsManager(this);
 	_files = new FileManager(this);
 	_inventory = new InventoryManager(this);
-	_player = new Player(this);
+	_player = Player::init(this);
 	_screen = new Screen(this);
 	_sound = new SoundManager(this, _mixer);
 	_video = new VideoPlayer(this);
diff --git a/engines/access/amazon/amazon_player.cpp b/engines/access/amazon/amazon_player.cpp
new file mode 100644
index 0000000..ede7ab5
--- /dev/null
+++ b/engines/access/amazon/amazon_player.cpp
@@ -0,0 +1,86 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be 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 "common/scummsys.h"
+#include "access/access.h"
+#include "access/room.h"
+#include "access/amazon/amazon_game.h"
+#include "access/amazon/amazon_player.h"
+#include "access/amazon/amazon_resources.h"
+
+namespace Access {
+
+namespace Amazon {
+
+AmazonPlayer::AmazonPlayer(AccessEngine *vm) : Player(vm) {
+	_game = (AmazonEngine *)vm;
+}
+
+void AmazonPlayer::load() {
+	Player::load();
+
+	// Special scene setup for the top-down view when on the Slaver ship
+	if (_vm->_room->_roomFlag == 3) {
+		_playerOffset.x = _vm->_screen->_scaleTable1[8];
+		_playerOffset.y = _vm->_screen->_scaleTable1[11];
+		_leftDelta = 0;
+		_rightDelta = 8;
+		_upDelta = 2;
+		_downDelta = -2;
+		_scrollConst = 2;
+
+		for (int i = 0; i < PLAYER_DATA_COUNT; ++i) {
+			_walkOffRight[i] = OVEROFFR[i];
+			_walkOffLeft[i] = OVEROFFL[i];
+			_walkOffUp[i] = OVEROFFU[i];
+			_walkOffDown[i] = OVEROFFD[i];
+			_walkOffUR[i].x = OVEROFFURX[i];
+			_walkOffUR[i].y = OVEROFFURY[i];
+			_walkOffDR[i].x = OVEROFFDRX[i];
+			_walkOffDR[i].y = OVEROFFDRY[i];
+			_walkOffUL[i].x = OVEROFFULX[i];
+			_walkOffUL[i].y = OVEROFFULY[i];
+			_walkOffDL[i].x = OVEROFFDLX[i];
+			_walkOffDL[i].y = OVEROFFDLY[i];
+		}
+
+		_vm->_timers[8]._initTm = 7;
+		_vm->_timers[8]._timer = 7;
+		++_vm->_timers[8]._flag;
+
+		_sideWalkMin = 0;
+		_sideWalkMax = 5;
+		_upWalkMin = 12;
+		_upWalkMax = 17;
+		_downWalkMin = 6;
+		_downWalkMax = 11;
+		_diagUpWalkMin = 0;
+		_diagUpWalkMax = 5;
+		_diagDownWalkMin = 0;
+		_diagDownWalkMax = 5;
+		_game->_guard._position = Common::Point(56, 190);
+	}
+}
+
+} // End of namespace Amazon
+
+} // End of namespace Access
diff --git a/engines/access/amazon/amazon_player.h b/engines/access/amazon/amazon_player.h
new file mode 100644
index 0000000..200b530
--- /dev/null
+++ b/engines/access/amazon/amazon_player.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.
+ *
+ */
+
+#ifndef ACCESS_AMAZON_PLAYER_H
+#define ACCESS_AMAZON_PLAYER_H
+
+#include "common/scummsys.h"
+#include "access/player.h"
+
+namespace Access {
+
+namespace Amazon {
+
+class AmazonEngine;
+
+class AmazonPlayer: public Player {
+private:
+	AmazonEngine *_game;
+public:
+	AmazonPlayer(AccessEngine *vm);
+
+	virtual void load();
+};
+
+} // End of namespace Amazon
+
+} // End of namespace Access
+
+#endif /* ACCESS_AMAZON_PLAYER_H */
diff --git a/engines/access/amazon/amazon_resources.cpp b/engines/access/amazon/amazon_resources.cpp
index 08b5795..e03750f 100644
--- a/engines/access/amazon/amazon_resources.cpp
+++ b/engines/access/amazon/amazon_resources.cpp
@@ -245,6 +245,19 @@ const int TRAVEL_POS[][2] = {
 	{ 0, 0 }
 };
 
+const int OVEROFFR[] = { 2, 2, 1, 2, 2, 1, 0, 0, 0 };
+const int OVEROFFL[] = { 2, 2, 1, 2, 2, 1, 0, 0, 0 };
+const int OVEROFFU[] = { 1, 1, 1, 1, 1, 1, 0, 0, 0 };
+const int OVEROFFD[] = { 1, 1, 1, 1, 1, 1, 0, 0, 0 };
+const int OVEROFFURX[] = { 3, 1, 1, 2, 2, 1, 0, 0, 0 };
+const int OVEROFFURY[] = { 1, 0, 0, 1, 1, 0, 0, 0, 0 };
+const int OVEROFFDRX[] = { 1, 2, 1, 1, 2, 1, 0, 0, 0 };
+const int OVEROFFDRY[] = { 0, 1, 0, 0, 1, 1, 0, 0, 0 };
+const int OVEROFFULX[] = { 2, 1, 1, 1, 2, 1, 0, 0, 0 };
+const int OVEROFFULY[] = { 1, 0, 0, 2, 1, 0, 0, 0, 0 };
+const int OVEROFFDLX[] = { 1, 2, 1, 1, 2, 1, 0, 0, 0 };
+const int OVEROFFDLY[] = { 0, 1, 0, 0, 1, 1, 0, 0, 0 };
+
 const byte CREDITS[] = {
 	0x2, 0xFF, 0xFF, 0x61, 0x0, 0x3, 0x0, 0x30, 0x22, 0x30, 0x0, 0x0, 0x0,
 	0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0xFF, 0xFF, 0xFF, 0x0, 0x0, 0xFF, 0xFF,
diff --git a/engines/access/amazon/amazon_resources.h b/engines/access/amazon/amazon_resources.h
index 65a38dc..4229522 100644
--- a/engines/access/amazon/amazon_resources.h
+++ b/engines/access/amazon/amazon_resources.h
@@ -44,6 +44,19 @@ extern const byte *CURSORS[10];
 
 extern const int TRAVEL_POS[][2];
 
+extern const int OVEROFFR[];
+extern const int OVEROFFL[];
+extern const int OVEROFFU[];
+extern const int OVEROFFD[];
+extern const int OVEROFFURX[];
+extern const int OVEROFFURY[];
+extern const int OVEROFFDRX[];
+extern const int OVEROFFDRY[];
+extern const int OVEROFFULX[];
+extern const int OVEROFFULY[];
+extern const int OVEROFFDLX[];
+extern const int OVEROFFDLY[];
+
 extern const byte *ROOM_TABLE[];
 extern const char *ROOM_DESCR[];
 extern const int ROOM_NUMB;
diff --git a/engines/access/animation.cpp b/engines/access/animation.cpp
index 184b015..e59874f 100644
--- a/engines/access/animation.cpp
+++ b/engines/access/animation.cpp
@@ -222,9 +222,9 @@ void Animation::setFrame1(AnimationFrame *frame) {
 		ImageEntry ie;
 
 		// Set the flags
-		ie._flags = part->_flags & 0xF7;
+		ie._flags = part->_flags & ~IMGFLAG_UNSCALED;
 		if (_vm->_animation->_frameScale == -1)
-			ie._flags |= 8;
+			ie._flags |= IMGFLAG_UNSCALED;
 
 		// Set the other fields
 		ie._spritesPtr = _vm->_objectsTable[part->_spritesIndex];
diff --git a/engines/access/module.mk b/engines/access/module.mk
index b6e73b6..9846401 100644
--- a/engines/access/module.mk
+++ b/engines/access/module.mk
@@ -22,6 +22,7 @@ MODULE_OBJS := \
 	sound.o \
 	video.o \
 	amazon/amazon_game.o \
+	amazon/amazon_player.o \
 	amazon/amazon_resources.o \
 	amazon/amazon_room.o \
 	amazon/amazon_scripts.o \
diff --git a/engines/access/player.cpp b/engines/access/player.cpp
index 70f6881..b504663 100644
--- a/engines/access/player.cpp
+++ b/engines/access/player.cpp
@@ -25,9 +25,19 @@
 #include "access/player.h"
 #include "access/access.h"
 #include "access/resources.h"
+#include "access/amazon/amazon_player.h"
 
 namespace Access {
 
+Player *Player::init(AccessEngine *vm) {
+	switch (vm->getGameID()) {
+	case GType_Amazon:
+		return new Amazon::AmazonPlayer(vm);
+	default:
+		return new Player(vm);
+	}
+}
+
 Player::Player(AccessEngine *vm): Manager(vm), ImageEntry() {
 	Common::fill(&_walkOffRight[0], &_walkOffRight[PLAYER_DATA_COUNT], 0);
 	Common::fill(&_walkOffLeft[0], &_walkOffLeft[PLAYER_DATA_COUNT], 0);
@@ -71,81 +81,40 @@ Player::~Player() {
 }
 
 void Player::load() {
-	if (_vm->_room->_roomFlag == 3) {
-		_playerOffset.x = _vm->_screen->_scaleTable1[8];
-		_playerOffset.y = _vm->_screen->_scaleTable1[11];
-		_leftDelta = 0;
-		_rightDelta = 8;
-		_upDelta = 2;
-		_downDelta = -2;
-		_scrollConst = 2;
-
-		for (int i = 0; i < PLAYER_DATA_COUNT; ++i) {
-			_walkOffRight[i] = OVEROFFR[i];
-			_walkOffLeft[i] = OVEROFFL[i];
-			_walkOffUp[i] = OVEROFFU[i];
-			_walkOffDown[i] = OVEROFFD[i];
-			_walkOffUR[i].x = OVEROFFURX[i];
-			_walkOffUR[i].y = OVEROFFURY[i];
-			_walkOffDR[i].x = OVEROFFDRX[i];
-			_walkOffDR[i].y = OVEROFFDRY[i];
-			_walkOffUL[i].x = OVEROFFULX[i];
-			_walkOffUL[i].y = OVEROFFULY[i];
-			_walkOffDL[i].x = OVEROFFDLX[i];
-			_walkOffDL[i].y = OVEROFFDLY[i];
-		}
-
-		_vm->_timers[8]._initTm = 7;
-		_vm->_timers[8]._timer = 7;
-		++_vm->_timers[8]._flag;
-
-		_sideWalkMin = 0;
-		_sideWalkMax = 5;
-		_upWalkMin = 12;
-		_upWalkMax = 17;
-		_downWalkMin = 6;
-		_downWalkMax = 11;
-		_diagUpWalkMin = 0;
-		_diagUpWalkMax = 5;
-		_diagDownWalkMin = 0;
-		_diagDownWalkMax = 5;
-		_guard = Common::Point(56, 190);
-	} else {
-		_playerOffset.x = _vm->_screen->_scaleTable1[25];
-		_playerOffset.y = _vm->_screen->_scaleTable1[67];
-		_leftDelta = -3;
-		_rightDelta = 33;
-		_upDelta = 5;
-		_downDelta = -10;
-		_scrollConst = 5;
-
-		for (int i = 0; i < PLAYER_DATA_COUNT; ++i) {
-			_walkOffRight[i] = SIDEOFFR[i];
-			_walkOffLeft[i] = SIDEOFFL[i];
-			_walkOffUp[i] = SIDEOFFU[i];
-			_walkOffDown[i] = SIDEOFFD[i];
-			_walkOffUR[i].x = DIAGOFFURX[i];
-			_walkOffUR[i].y = DIAGOFFURY[i];
-			_walkOffDR[i].x = DIAGOFFDRX[i];
-			_walkOffDR[i].y = DIAGOFFDRY[i];
-			_walkOffUL[i].x = DIAGOFFULX[i];
-			_walkOffUL[i].y = DIAGOFFULY[i];
-			_walkOffDL[i].x = DIAGOFFDLX[i];
-			_walkOffDL[i].y = DIAGOFFDLY[i];
-		}
-
-		_sideWalkMin = 0;
-		_sideWalkMax = 7;
-		_upWalkMin = 16;
-		_upWalkMax = 23;
-		_downWalkMin = 8;
-		_downWalkMax = 15;
-		_diagUpWalkMin = 0;
-		_diagUpWalkMax = 7;
-		_diagDownWalkMin = 0;
-		_diagDownWalkMax = 7;
+	_playerOffset.x = _vm->_screen->_scaleTable1[25];
+	_playerOffset.y = _vm->_screen->_scaleTable1[67];
+	_leftDelta = -3;
+	_rightDelta = 33;
+	_upDelta = 5;
+	_downDelta = -10;
+	_scrollConst = 5;
+
+	for (int i = 0; i < PLAYER_DATA_COUNT; ++i) {
+		_walkOffRight[i] = SIDEOFFR[i];
+		_walkOffLeft[i] = SIDEOFFL[i];
+		_walkOffUp[i] = SIDEOFFU[i];
+		_walkOffDown[i] = SIDEOFFD[i];
+		_walkOffUR[i].x = DIAGOFFURX[i];
+		_walkOffUR[i].y = DIAGOFFURY[i];
+		_walkOffDR[i].x = DIAGOFFDRX[i];
+		_walkOffDR[i].y = DIAGOFFDRY[i];
+		_walkOffUL[i].x = DIAGOFFULX[i];
+		_walkOffUL[i].y = DIAGOFFULY[i];
+		_walkOffDL[i].x = DIAGOFFDLX[i];
+		_walkOffDL[i].y = DIAGOFFDLY[i];
 	}
 
+	_sideWalkMin = 0;
+	_sideWalkMax = 7;
+	_upWalkMin = 16;
+	_upWalkMax = 23;
+	_downWalkMin = 8;
+	_downWalkMax = 15;
+	_diagUpWalkMin = 0;
+	_diagUpWalkMax = 7;
+	_diagDownWalkMin = 0;
+	_diagDownWalkMax = 7;
+
 	_playerSprites = _playerSprites1;
 	if (_manPal1) {
 		Common::copy(_manPal1 + 0x270, _manPal1 + 0x270 + 0x60, _vm->_screen->_manPal);
diff --git a/engines/access/player.h b/engines/access/player.h
index ed48af0..400770c 100644
--- a/engines/access/player.h
+++ b/engines/access/player.h
@@ -38,8 +38,8 @@ enum Direction { NONE = 0, UP = 1, DOWN = 2, LEFT = 3, RIGHT = 4,
 
 class AccessEngine;
 
-class Player: public ImageEntry, Manager {
-private:
+class Player: public ImageEntry, public Manager {
+protected:
 	int _leftDelta, _rightDelta;
 	int _upDelta, _downDelta;
 	int _scrollConst;
@@ -48,7 +48,6 @@ private:
 	int _downWalkMin, _downWalkMax;
 	int _diagUpWalkMin, _diagUpWalkMax;
 	int _diagDownWalkMin, _diagDownWalkMax;
-	Common::Point _guard;
 	SpriteResource *_playerSprites1;
 	byte *_manPal1;
 	int _scrollEnd;
@@ -113,8 +112,9 @@ public:
 public:
 	Player(AccessEngine *vm);
 	~Player();
+	static Player *init(AccessEngine *vm);
 
-	void load();
+	virtual void load();
 
 	void loadSprites(const Common::String &name);
 
diff --git a/engines/access/resources.cpp b/engines/access/resources.cpp
index e5a27a8..9bef5cf 100644
--- a/engines/access/resources.cpp
+++ b/engines/access/resources.cpp
@@ -58,18 +58,6 @@ const int DIAGOFFULX[] = { 4, 5, 4, 3, 3, 2, 2, 2, 0 };
 const int DIAGOFFULY[] = { 3, 3, 1, 2, 2, 1, 1, 1, 0 };
 const int DIAGOFFDLX[] = { 4, 5, 3, 3, 5, 4, 6, 1, 0 };
 const int DIAGOFFDLY[] = { 2, 2, 1, 2, 3, 1, 2, 1, 0 };
-const int OVEROFFR[] = { 2, 2, 1, 2, 2, 1, 0, 0, 0 };
-const int OVEROFFL[] = { 2, 2, 1, 2, 2, 1, 0, 0, 0 };
-const int OVEROFFU[] = { 1, 1, 1, 1, 1, 1, 0, 0, 0 };
-const int OVEROFFD[] = { 1, 1, 1, 1, 1, 1, 0, 0, 0 };
-const int OVEROFFURX[] = { 3, 1, 1, 2, 2, 1, 0, 0, 0 };
-const int OVEROFFURY[] = { 1, 0, 0, 1, 1, 0, 0, 0, 0 };
-const int OVEROFFDRX[] = { 1, 2, 1, 1, 2, 1, 0, 0, 0 };
-const int OVEROFFDRY[] = { 0, 1, 0, 0, 1, 1, 0, 0, 0 };
-const int OVEROFFULX[] = { 2, 1, 1, 1, 2, 1, 0, 0, 0 };
-const int OVEROFFULY[] = { 1, 0, 0, 2, 1, 0, 0, 0, 0 };
-const int OVEROFFDLX[] = { 1, 2, 1, 1, 2, 1, 0, 0, 0 };
-const int OVEROFFDLY[] = { 0, 1, 0, 0, 1, 1, 0, 0, 0 };
 
 const int RMOUSE[10][2] = {
 	{ 0, 35 }, { 0, 0 }, { 36, 70 }, { 71, 106 }, { 107, 141 },
diff --git a/engines/access/resources.h b/engines/access/resources.h
index 6fb781e..10f2adb 100644
--- a/engines/access/resources.h
+++ b/engines/access/resources.h
@@ -41,18 +41,6 @@ extern const int DIAGOFFULX[];
 extern const int DIAGOFFULY[];
 extern const int DIAGOFFDLX[];
 extern const int DIAGOFFDLY[];
-extern const int OVEROFFR[];
-extern const int OVEROFFL[];
-extern const int OVEROFFU[];
-extern const int OVEROFFD[];
-extern const int OVEROFFURX[];
-extern const int OVEROFFURY[];
-extern const int OVEROFFDRX[];
-extern const int OVEROFFDRY[];
-extern const int OVEROFFULX[];
-extern const int OVEROFFULY[];
-extern const int OVEROFFDLX[];
-extern const int OVEROFFDLY[];
 
 extern const int RMOUSE[10][2];
 


Commit: 7a691f38cf866c43222ce7d555f6bc953de49017
    https://github.com/scummvm/scummvm/commit/7a691f38cf866c43222ce7d555f6bc953de49017
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-12T22:44:58-05:00

Commit Message:
ACCESS: Fix guard movement logic on slaver boat

Changed paths:
    engines/access/amazon/amazon_scripts.cpp



diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp
index e83bc9f..df6bb8f 100644
--- a/engines/access/amazon/amazon_scripts.cpp
+++ b/engines/access/amazon/amazon_scripts.cpp
@@ -1085,10 +1085,11 @@ void AmazonScripts::guard() {
 
 	switch (_game->_guardLocation) {
 	case 1:
+		// Guard walking down
 		if (curCel <= 8 || curCel > 13)
 			_game->_guard._guardCel = curCel = 8;
 
-		_game->_guard._position.y = _vm->_player->_walkOffDown[curCel - 8];
+		_game->_guard._position.y += _vm->_player->_walkOffDown[curCel - 8];
 		guardSee();
 		if (_game->_guard._position.y >= 272) {
 			_game->_guard._position.y = 272;
@@ -1096,10 +1097,11 @@ void AmazonScripts::guard() {
 		}
 		break;
 	case 2:
+		// Guard walking left
 		if (curCel <= 43 || curCel > 48)
 			_game->_guard._guardCel = curCel = 43;
 
-		_game->_guard._position.x = _vm->_player->_walkOffLeft[curCel - 43];
+		_game->_guard._position.x -= _vm->_player->_walkOffLeft[curCel - 43];
 		guardSee();
 		if (_game->_guard._position.x <= 56) {
 			_game->_guard._position.x = 56;
@@ -1107,10 +1109,11 @@ void AmazonScripts::guard() {
 		}
 		break;
 	case 3:
+		// Guard walking up
 		if (curCel <= 0 || curCel > 5)
 			_game->_guard._guardCel = curCel = 0;
 
-		_game->_guard._position.y = _vm->_player->_walkOffUp[curCel];
+		_game->_guard._position.y -= _vm->_player->_walkOffUp[curCel];
 		guardSee();
 		if (_game->_guard._position.y <= 89) {
 			_game->_guard._position.y = 89;
@@ -1120,10 +1123,11 @@ void AmazonScripts::guard() {
 		}
 		break;
 	default:
+		// Guard walking right
 		if (curCel <= 43 || curCel > 48)
 			_game->_guard._guardCel = curCel = 43;
 
-		_game->_guard._position.x = _vm->_player->_walkOffRight[curCel - 43];
+		_game->_guard._position.x += _vm->_player->_walkOffRight[curCel - 43];
 		guardSee();
 		if (_game->_guard._position.x >= 127) {
 			_game->_guard._position.x = 127;


Commit: 2ea4601589196ba91d2e87582cb5f9325e0b1f95
    https://github.com/scummvm/scummvm/commit/2ea4601589196ba91d2e87582cb5f9325e0b1f95
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-12T22:45:17-05:00

Commit Message:
ACCESS: Implement helpTitle

Changed paths:
    engines/access/amazon/amazon_game.cpp
    engines/access/amazon/amazon_game.h
    engines/access/amazon/amazon_resources.cpp
    engines/access/amazon/amazon_resources.h



diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp
index e864a92..c12af5e 100644
--- a/engines/access/amazon/amazon_game.cpp
+++ b/engines/access/amazon/amazon_game.cpp
@@ -624,8 +624,50 @@ void AmazonEngine::updateSummary(int chap) {
 	}
 }
 
-void AmazonEngine::HELPTITLE() {
-	warning("TODO: HELPTITLE");
+void AmazonEngine::CALCIQ() {
+	warning("TODO: CALCIQ");
+}
+
+void AmazonEngine::helpTitle() {
+	int width = _fonts._font2.stringWidth(_bubbleBox->_bubbleTitle);
+	int posX = 160 - (width / 2);
+	_fonts._font2._fontColors[0] = 0;
+	_fonts._font2._fontColors[1] = 33;
+	_fonts._font2._fontColors[2] = 34;
+	_fonts._font2._fontColors[3] = 35;
+	_fonts._font2.drawString(_screen, _bubbleBox->_bubbleTitle, Common::Point(posX, 24));
+
+	width = _fonts._font2.stringWidth(HELPLVLTXT[_helpLevel]);
+	posX = 160 - (width / 2);
+	_fonts._font2._fontColors[0] = 0;
+	_fonts._font2._fontColors[1] = 10;
+	_fonts._font2._fontColors[2] = 11;
+	_fonts._font2._fontColors[3] = 12;
+	_fonts._font2.drawString(_screen, HELPLVLTXT[_helpLevel], Common::Point(posX, 36));
+
+	Common::String iqText = "IQ: ";
+	CALCIQ();
+	Common::String IQSCORE = Common::String::format("d", _iqValue);
+	while (IQSCORE.size() != 4)
+		IQSCORE = " " + IQSCORE;
+
+	iqText += IQSCORE;
+	int index = _iqValue;
+	if (index == 170)
+		index = 169;
+
+	index /= 20;
+	
+	iqText += " ";
+	iqText += IQLABELS[index];
+
+	width = _fonts._font2.stringWidth(iqText);
+	posX = 160 - (width / 2);
+	_fonts._font2._fontColors[0] = 0;
+	_fonts._font2._fontColors[1] = 10;
+	_fonts._font2._fontColors[2] = 11;
+	_fonts._font2._fontColors[3] = 12;
+	_fonts._font2.drawString(_screen, iqText, Common::Point(posX, 44));
 }
 
 void AmazonEngine::drawHelpText(const Common::String &msg) {
@@ -686,7 +728,7 @@ void AmazonEngine::drawHelp() {
 	if ((_useItem == 0) && (_screen->_vesaMode == 0))
 		_screen->fadeIn();
 
-	HELPTITLE();
+	helpTitle();
 	drawHelpText("TODO: WHICH BUFFER?");
 }
 
diff --git a/engines/access/amazon/amazon_game.h b/engines/access/amazon/amazon_game.h
index 0aea435..89d15d3 100644
--- a/engines/access/amazon/amazon_game.h
+++ b/engines/access/amazon/amazon_game.h
@@ -83,7 +83,8 @@ private:
 	 */
 	void setupGame();
 
-	void HELPTITLE();
+	void CALCIQ();
+	void helpTitle();
 	void drawHelpText(const Common::String &msg);
 	void doCredit();
 	void scrollTitle();
@@ -164,6 +165,7 @@ public:
 	bool _antEatFl;
 	bool _stabFl;
 	Common::Point _pitPos;
+	int _iqValue;
 public:
 	AmazonEngine(OSystem *syst, const AccessGameDescription *gameDesc);
 
diff --git a/engines/access/amazon/amazon_resources.cpp b/engines/access/amazon/amazon_resources.cpp
index e03750f..08ecfff 100644
--- a/engines/access/amazon/amazon_resources.cpp
+++ b/engines/access/amazon/amazon_resources.cpp
@@ -1226,6 +1226,23 @@ const char *const NO_HINTS_MESSAGE = "THE HELP SYSTEM HAS BEEN TURNED OFF FOR TH
 const char *const HIT1 = "YOU HIT THE ROCKS AND THE CANOE BEGINS TO LEAK.";
 const char *const HIT2 = "YOU HIT THE ROCKS AND THE CANOE DEVELOPS SERIOUS LEAKS.";
 const char *const BAR_MESSAGE = "YOU ARE TOO BUSY TRYING TO KEEP FROM SINKING TO DO THAT";
+const char *const HELPLVLTXT[3] = {
+	" LEVEL 1 ",
+	" LEVEL 2 ",
+	" LEVEL 3 "
+};
+
+const char *const IQLABELS[9] = {
+	"VEGETABLE",
+	"NEANDERTHAL",
+	"LOBOTOMIZED",
+	"DENSE",
+	"AVERAGE",
+	"INTELLIGENT",
+	"MURPHYITE",
+	"BRILLIANT",
+	"GENIUS"
+};
 
 const byte DEATH_SCREENS[58] = {
 	0,  1,  0,  0,  0,  0,  0,  0,  2,  0,
diff --git a/engines/access/amazon/amazon_resources.h b/engines/access/amazon/amazon_resources.h
index 4229522..37b12d2 100644
--- a/engines/access/amazon/amazon_resources.h
+++ b/engines/access/amazon/amazon_resources.h
@@ -78,7 +78,8 @@ extern const char *const NO_HINTS_MESSAGE;
 extern const char *const HIT1;
 extern const char *const HIT2;
 extern const char *const BAR_MESSAGE;
-
+extern const char *const HELPLVLTXT[3];
+extern const char *const IQLABELS[9];
 extern const byte DEATH_SCREENS[58];
 
 extern const char *const DEATH_TEXT[58];


Commit: 79fa346ca04a6a2a0ac7cb725d21ba496944feb1
    https://github.com/scummvm/scummvm/commit/79fa346ca04a6a2a0ac7cb725d21ba496944feb1
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-12T22:45:29-05:00

Commit Message:
ACCESS: Implement calcIQ

Changed paths:
    engines/access/amazon/amazon_game.cpp
    engines/access/amazon/amazon_game.h



diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp
index c12af5e..33e5888 100644
--- a/engines/access/amazon/amazon_game.cpp
+++ b/engines/access/amazon/amazon_game.cpp
@@ -624,8 +624,33 @@ void AmazonEngine::updateSummary(int chap) {
 	}
 }
 
-void AmazonEngine::CALCIQ() {
-	warning("TODO: CALCIQ");
+void AmazonEngine::calcIQ() {
+	int tmpIQ = 170;
+	for (int i = 0; i < 256; i++) {
+		if (_help1[i] == 1)
+			tmpIQ -= 3;
+	}
+
+	for (int i = 0; i < 256; i++) {
+		if (_help2[i] == 1)
+			tmpIQ -= 5;
+	}
+
+	for (int i = 0; i < 256; i++) {
+		if (_help3[i] == 1)
+			tmpIQ -= 10;
+	}
+
+	if (tmpIQ < 0)
+		tmpIQ = 0;
+
+	_iqValue = tmpIQ;
+
+	if (_iqValue <= 100)
+		_badEnd = 1;
+
+	if (_iqValue <= 0)
+		_noHints = 1;
 }
 
 void AmazonEngine::helpTitle() {
@@ -646,7 +671,7 @@ void AmazonEngine::helpTitle() {
 	_fonts._font2.drawString(_screen, HELPLVLTXT[_helpLevel], Common::Point(posX, 36));
 
 	Common::String iqText = "IQ: ";
-	CALCIQ();
+	calcIQ();
 	Common::String IQSCORE = Common::String::format("d", _iqValue);
 	while (IQSCORE.size() != 4)
 		IQSCORE = " " + IQSCORE;
diff --git a/engines/access/amazon/amazon_game.h b/engines/access/amazon/amazon_game.h
index 89d15d3..6208796 100644
--- a/engines/access/amazon/amazon_game.h
+++ b/engines/access/amazon/amazon_game.h
@@ -83,7 +83,7 @@ private:
 	 */
 	void setupGame();
 
-	void CALCIQ();
+	void calcIQ();
 	void helpTitle();
 	void drawHelpText(const Common::String &msg);
 	void doCredit();


Commit: 451a29ada517fad99a5de823efca8758416ccd46
    https://github.com/scummvm/scummvm/commit/451a29ada517fad99a5de823efca8758416ccd46
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-12T22:45:42-05:00

Commit Message:
ACCESS: Fix character in first screen when the intro is played

Changed paths:
    engines/access/amazon/amazon_game.cpp
    engines/access/amazon/amazon_game.h



diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp
index 33e5888..6288ddb 100644
--- a/engines/access/amazon/amazon_game.cpp
+++ b/engines/access/amazon/amazon_game.cpp
@@ -107,6 +107,8 @@ void AmazonEngine::playGame() {
 	_screen->forceFadeOut();
 	_events->showCursor();
 
+	initVariables();
+
 	// If there's a pending savegame to load, load it
 	if (_loadSaveSlot != -1)
 		loadGameState(_loadSaveSlot);
@@ -430,8 +432,6 @@ void AmazonEngine::doTent() {
 }
 
 void AmazonEngine::setupGame() {
-	_chapter = 1;
-
 	// Setup timers
 	const int TIMER_DEFAULTS[] = { 3, 10, 8, 1, 1, 1, 1, 2 };
 	for (int i = 0; i < 32; ++i) {
@@ -456,6 +456,11 @@ void AmazonEngine::setupGame() {
 	_fonts._font1.load(FONT6x6_INDEX, FONT6x6_DATA);
 	_fonts._font2.load(FONT2_INDEX, FONT2_DATA);
 
+	initVariables();
+}
+
+void AmazonEngine::initVariables() {
+	_chapter = 1;
 	// Set player room and position
 	_player->_roomNumber = 4;
 	_player->_playerX = _player->_rawPlayer.x = TRAVEL_POS[_player->_roomNumber][0];
diff --git a/engines/access/amazon/amazon_game.h b/engines/access/amazon/amazon_game.h
index 6208796..e6c817d 100644
--- a/engines/access/amazon/amazon_game.h
+++ b/engines/access/amazon/amazon_game.h
@@ -83,6 +83,7 @@ private:
 	 */
 	void setupGame();
 
+	void initVariables();
 	void calcIQ();
 	void helpTitle();
 	void drawHelpText(const Common::String &msg);


Commit: 0a28a77e1a6339c292826b264047bd439290fe16
    https://github.com/scummvm/scummvm/commit/0a28a77e1a6339c292826b264047bd439290fe16
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-12T22:46:01-05:00

Commit Message:
ACCESS: Silent warning

Changed paths:
    engines/access/inventory.cpp



diff --git a/engines/access/inventory.cpp b/engines/access/inventory.cpp
index 11baa8f..629b89f 100644
--- a/engines/access/inventory.cpp
+++ b/engines/access/inventory.cpp
@@ -90,7 +90,7 @@ int &InventoryManager::operator[](int idx) {
 	// WORKAROUND: At least in Amazon, some game scripts accidentally do reads
 	// beyond the length of the inventory array
 	static int invalid = 0;
-	return (idx >= _inv.size()) ? invalid : _inv[idx]._value;
+	return (idx >= (int)_inv.size()) ? invalid : _inv[idx]._value;
 }
 
 int InventoryManager::useItem() { 


Commit: 486b7d7e04f3832bfd2a6ed63ba92295cd509965
    https://github.com/scummvm/scummvm/commit/486b7d7e04f3832bfd2a6ed63ba92295cd509965
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-12T22:46:20-05:00

Commit Message:
ACCESS: Add detection for Amazon English Demo

Changed paths:
    engines/access/detection_tables.h



diff --git a/engines/access/detection_tables.h b/engines/access/detection_tables.h
index 95ac8fa..ec15076 100644
--- a/engines/access/detection_tables.h
+++ b/engines/access/detection_tables.h
@@ -41,6 +41,24 @@ static const AccessGameDescription gameDescriptions[] = {
 		0
 	},
 
+	// Amazon Guardians of Eden - Demo English
+	{
+		{
+		"amazon",
+		"Demo",
+			{
+				{ "c25.ap", 0, "5baba0c052d22157499bfa05cb1ed5b7", 65458 },
+				AD_LISTEND
+			},
+			Common::EN_ANY,
+			Common::kPlatformDOS,
+			ADGF_DEMO,
+			GUIO1(GUIO_NONE)
+		},
+		GType_Amazon,
+		0
+	},
+
 	{
 		// Amazon: Guardians of Eden - CD English
 		{


Commit: 9cd2bbf6bd9c7b053aa5748872087a0fafe0fb3d
    https://github.com/scummvm/scummvm/commit/9cd2bbf6bd9c7b053aa5748872087a0fafe0fb3d
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-12T22:46:36-05:00

Commit Message:
ACCESS: Move slaver guard functions into the Guard class

Changed paths:
    engines/access/amazon/amazon_game.cpp
    engines/access/amazon/amazon_game.h
    engines/access/amazon/amazon_scripts.cpp
    engines/access/amazon/amazon_scripts.h



diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp
index 6288ddb..550d8b2 100644
--- a/engines/access/amazon/amazon_game.cpp
+++ b/engines/access/amazon/amazon_game.cpp
@@ -31,7 +31,7 @@ namespace Access {
 namespace Amazon {
 
 AmazonEngine::AmazonEngine(OSystem *syst, const AccessGameDescription *gameDesc) :
-		AccessEngine(syst, gameDesc),
+AccessEngine(syst, gameDesc),
 		_guardLocation(_flags[122]), _guardFind(_flags[128]), _helpLevel(_flags[167]), 
 		_jasMayaFlag(_flags[168]), _moreHelp(_flags[169]), _flashbackFlag(_flags[171]),
 		_riverFlag(_flags[185]), _aniOutFlag(_flags[195]), _badEnd(_flags[218]), 
@@ -91,6 +91,7 @@ void AmazonEngine::playGame() {
 	// Initialize Amazon game-specific objects
 	_room = new AmazonRoom(this);
 	_scripts = new AmazonScripts(this);
+	_guard.setVm(this);
 
 	// Setup the game
 	setupGame();
@@ -941,17 +942,283 @@ void AmazonEngine::synchronize(Common::Serializer &s) {
 
 /*------------------------------------------------------------------------*/
 
+Plane::Plane() {
+	_pCount = 0;
+	_planeCount = 0;
+	_propCount = 0;
+	_xCount = 0;
+}
+
+/*------------------------------------------------------------------------*/
+
 Guard::Guard() {
+	_vm = nullptr;
 	_guardCel = 0;
 	_gCode1 = _gCode2 = 0;
 	_xMid = _yMid = 0;
 }
 
-Plane::Plane() {
-	_pCount = 0;
-	_planeCount = 0;
-	_propCount = 0;
-	_xCount = 0;
+void Guard::setVerticalCode() {
+	_gCode1 = 0;
+	_gCode2 = 0;
+	if (_topLeft.x < _vm->_screen->_orgX1)
+		_gCode1 |= 8;
+	else if (_topLeft.x == _vm->_screen->_orgX1) {
+		_gCode1 |= 8;
+		_gCode1 |= 2;
+	}
+	else
+		_gCode1 |= 2;
+
+	if (_bottomRight.x < _vm->_screen->_orgX1)
+		_gCode2 |= 8;
+	else if (_bottomRight.x == _vm->_screen->_orgX1) {
+		_gCode2 |= 8;
+		_gCode2 |= 2;
+	}
+	else
+		_gCode2 |= 2;
+
+	if (_topLeft.y < _vm->_screen->_orgY1)
+		_gCode1 |= 4;
+	else if (_topLeft.y > _vm->_screen->_orgY2)
+		_gCode1 |= 1;
+
+	if (_bottomRight.y < _vm->_screen->_orgY1)
+		_gCode2 |= 4;
+	else if (_bottomRight.y > _vm->_screen->_orgY2)
+		_gCode2 |= 1;
+}
+
+void Guard::setHorizontalCode() {
+	_gCode1 = 0;
+	_gCode2 = 0;
+
+	if (_topLeft.y < _vm->_screen->_orgY1)
+		_gCode1 |= 4;
+	else if (_topLeft.x == _vm->_screen->_orgX1) {
+		_gCode1 |= 4;
+		_gCode1 |= 1;
+	}
+	else
+		_gCode1 |= 1;
+
+	if (_bottomRight.y < _vm->_screen->_orgY1)
+		_gCode2 |= 4;
+	else if (_bottomRight.x == _vm->_screen->_orgX1) {
+		_gCode2 |= 4;
+		_gCode2 |= 1;
+	}
+	else
+		_gCode2 |= 1;
+
+	if (_topLeft.x < _vm->_screen->_orgX1)
+		_gCode1 |= 8;
+	else if (_topLeft.x > _vm->_screen->_orgX2)
+		_gCode1 |= 2;
+
+	if (_bottomRight.x < _vm->_screen->_orgX1)
+		_gCode2 |= 8;
+	else if (_bottomRight.y > _vm->_screen->_orgX2)
+		_gCode2 |= 2;
+}
+
+void Guard::chkVLine() {
+	if (_position.x > _vm->_player->_rawPlayer.x) {
+		_topLeft = _vm->_player->_rawPlayer;
+		_bottomRight = _position;
+	} else {
+		_topLeft = _position;
+		_bottomRight = _vm->_player->_rawPlayer;
+	}
+
+	if (_vm->_screen->_orgY1 > _vm->_screen->_orgY2)
+		SWAP(_vm->_screen->_orgY1, _vm->_screen->_orgY2);
+
+	for (;;) {
+		setVerticalCode();
+		int code = _gCode1 | _gCode2;
+		if (code == 10) {
+			_vm->_guardFind = 0;
+			return;
+		}
+
+		int code2 = _gCode1 & _gCode2;
+		code2 &= 5;
+		if (((code & 10) == 8) || ((code & 10) == 2) || (code2 != 0))
+			return;
+
+		int midX = (_topLeft.x + _bottomRight.x) / 2;
+		int midY = (_topLeft.y + _bottomRight.y) / 2;
+
+		if (midX < _vm->_screen->_orgX1) {
+			if ((midX == _topLeft.x) && (midY == _topLeft.y))
+				return;
+
+			_topLeft.x = midX;
+			_topLeft.y = midY;
+		} else {
+			if ((midX == _bottomRight.x) && (midY == _bottomRight.y))
+				return;
+
+			_bottomRight.x = midX;
+			_bottomRight.y = midY;
+		}
+	}
+}
+
+void Guard::chkHLine() {
+	if (_position.y > _vm->_player->_rawPlayer.y) {
+		_topLeft = _vm->_player->_rawPlayer;
+		_bottomRight = _position;
+	} else {
+		_topLeft = _position;
+		_bottomRight = _vm->_player->_rawPlayer;
+	}
+
+	if (_vm->_screen->_orgX1 > _vm->_screen->_orgX2)
+		SWAP(_vm->_screen->_orgX1, _vm->_screen->_orgX2);
+
+	while (true) {
+		setHorizontalCode();
+		int code = _gCode1 | _gCode2;
+		if (code == 5) {
+			_vm->_guardFind = 0;
+			return;
+		}
+
+		int code2 = _gCode1 & _gCode2;
+		code2 &= 10;
+		if (((code & 5) == 4) || ((code & 5) == 1) || (code2 != 0))
+			return;
+
+		int midX = (_topLeft.x + _bottomRight.x) / 2;
+		int midY = (_topLeft.y + _bottomRight.y) / 2;
+
+		if (midY < _vm->_screen->_orgY1) {
+			if ((midX == _topLeft.x) && (midY == _topLeft.y))
+				return;
+
+			_topLeft.x = midX;
+			_topLeft.y = midY;
+		} else {
+			if ((midX == _bottomRight.x) && (midY == _bottomRight.y))
+				return;
+
+			_bottomRight.x = midX;
+			_bottomRight.y = midY;
+		}
+	}
+}
+
+void Guard::guardSee() {
+	int tmpY = (_vm->_screen->_scrollRow << 4) + _vm->_screen->_scrollY;
+	_vm->_flags[140] = 0;
+	if (tmpY > _position.y)
+		return;
+
+	tmpY += _vm->_screen->_vWindowLinesTall;
+	tmpY -= 11;
+
+	if (tmpY < _position.y)
+		return;
+
+	_vm->_guardFind = 1;
+	_vm->_flags[140] = 1;
+
+	for (uint16 idx = 0; idx < _vm->_room->_plotter._walls.size(); idx++) {
+		_vm->_screen->_orgX1 = _vm->_room->_plotter._walls[idx].left;
+		_vm->_screen->_orgY1 = _vm->_room->_plotter._walls[idx].top;
+		_vm->_screen->_orgX2 = _vm->_room->_plotter._walls[idx].right;
+		_vm->_screen->_orgY2 = _vm->_room->_plotter._walls[idx].bottom;
+		if (_vm->_screen->_orgX1 == _vm->_screen->_orgX2) {
+			chkVLine();
+			if (_vm->_guardFind == 0)
+				return;
+		}
+		else if (_vm->_screen->_orgY1 == _vm->_screen->_orgY2) {
+			chkHLine();
+			if (_vm->_guardFind == 0)
+				return;
+		}
+	}
+}
+
+void Guard::setGuardFrame() {
+	ImageEntry ie;
+	ie._flags = 8;
+
+	if (_vm->_guardLocation == 4)
+		ie._flags |= 2;
+	ie._spritesPtr = _vm->_objectsTable[37];
+	ie._frameNumber = _guardCel;
+	ie._position = _position;
+	ie._offsetY = 10;
+	_vm->_images.addToList(ie);
+}
+
+void Guard::guard() {
+	if (_vm->_timers[8]._flag != 0)
+		return;
+
+	++_vm->_timers[8]._flag;
+	++_guardCel;
+	int curCel = _guardCel;
+
+	switch (_vm->_guardLocation) {
+	case 1:
+		// Guard walking down
+		if (curCel <= 8 || curCel > 13)
+			_guardCel = curCel = 8;
+
+		_position.y += _vm->_player->_walkOffDown[curCel - 8];
+		guardSee();
+		if (_position.y >= 272) {
+			_position.y = 272;
+			_vm->_guardLocation = 2;
+		}
+		break;
+	case 2:
+		// Guard walking left
+		if (curCel <= 43 || curCel > 48)
+			_guardCel = curCel = 43;
+
+		_position.x -= _vm->_player->_walkOffLeft[curCel - 43];
+		guardSee();
+		if (_position.x <= 56) {
+			_position.x = 56;
+			_vm->_guardLocation = 3;
+		}
+		break;
+	case 3:
+		// Guard walking up
+		if (curCel <= 0 || curCel > 5)
+			_guardCel = curCel = 0;
+
+		_position.y -= _vm->_player->_walkOffUp[curCel];
+		guardSee();
+		if (_position.y <= 89) {
+			_position.y = 89;
+			_vm->_guardLocation = 4;
+			if (_vm->_flags[121] == 1)
+				_vm->_guardLocation = 5;
+		}
+		break;
+	default:
+		// Guard walking right
+		if (curCel <= 43 || curCel > 48)
+			_guardCel = curCel = 43;
+
+		_position.x += _vm->_player->_walkOffRight[curCel - 43];
+		guardSee();
+		if (_position.x >= 127) {
+			_position.x = 127;
+			_vm->_guardLocation = 1;
+		}
+		break;
+	}
+
+	setGuardFrame();
 }
 
 } // End of namespace Amazon
diff --git a/engines/access/amazon/amazon_game.h b/engines/access/amazon/amazon_game.h
index e6c817d..7917586 100644
--- a/engines/access/amazon/amazon_game.h
+++ b/engines/access/amazon/amazon_game.h
@@ -29,6 +29,8 @@ namespace Access {
 
 namespace Amazon {
 
+	class AmazonEngine;
+
 class Plane {
 public:
 	int _pCount;
@@ -41,15 +43,28 @@ public:
 };
 
 class Guard {
+private:
+	AmazonEngine *_vm;
+
+	void chkVLine();
+	void chkHLine();
+	void setVerticalCode();
+	void setHorizontalCode();
+	void guardSee();
+	void setGuardFrame();
 public:
 	int _guardCel;
 	Common::Point _position;
 	int _gCode1;
 	int _gCode2;
-	Common::Rect _bounds;
+	Common::Point _topLeft;
+	Common::Point _bottomRight;
 	int _xMid, _yMid;
 public:
 	Guard();
+	void setVm(AmazonEngine *vm) { _vm = vm; }
+
+	void guard();
 };
 
 class InactivePlayer : public ImageEntry {
diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp
index df6bb8f..f3f120b 100644
--- a/engines/access/amazon/amazon_scripts.cpp
+++ b/engines/access/amazon/amazon_scripts.cpp
@@ -888,257 +888,6 @@ void AmazonScripts::mWhile(int param1) {
 	}
 }
 
-void AmazonScripts::setVerticalCode(Common::Rect bounds) {
-	_game->_guard._gCode1 = 0;
-	_game->_guard._gCode2 = 0;
-	if (bounds.left < _vm->_screen->_orgX1)
-		_game->_guard._gCode1 |= 8;
-	else if (bounds.left == _vm->_screen->_orgX1) {
-		_game->_guard._gCode1 |= 8;
-		_game->_guard._gCode1 |= 2;
-	} else
-		_game->_guard._gCode1 |= 2;
-
-	if (bounds.right < _vm->_screen->_orgX1)
-		_game->_guard._gCode2 |= 8;
-	else if (bounds.right == _vm->_screen->_orgX1) {
-		_game->_guard._gCode2 |= 8;
-		_game->_guard._gCode2 |= 2;
-	} else
-		_game->_guard._gCode2 |= 2;
-
-	if (bounds.top < _vm->_screen->_orgY1)
-		_game->_guard._gCode1 |= 4;
-	else if (bounds.top > _vm->_screen->_orgY2)
-		_game->_guard._gCode1 |= 1;
-
-	if (bounds.bottom < _vm->_screen->_orgY1)
-		_game->_guard._gCode2 |= 4;
-	else if (bounds.bottom > _vm->_screen->_orgY2)
-		_game->_guard._gCode2 |= 1;
-}
-
-void AmazonScripts::setHorizontalCode(Common::Rect bounds) {
-	_game->_guard._gCode1 = 0;
-	_game->_guard._gCode2 = 0;
-
-	if (bounds.top < _vm->_screen->_orgY1)
-		_game->_guard._gCode1 |= 4;
-	else if (bounds.left == _vm->_screen->_orgX1) {
-		_game->_guard._gCode1 |= 4;
-		_game->_guard._gCode1 |= 1;
-	} else
-		_game->_guard._gCode1 |= 1;
-
-	if (bounds.bottom < _vm->_screen->_orgY1)
-		_game->_guard._gCode2 |= 4;
-	else if (bounds.right == _vm->_screen->_orgX1) {
-		_game->_guard._gCode2 |= 4;
-		_game->_guard._gCode2 |= 1;
-	} else
-		_game->_guard._gCode2 |= 1;
-
-	if (bounds.left < _vm->_screen->_orgX1)
-		_game->_guard._gCode1 |= 8;
-	else if (bounds.left > _vm->_screen->_orgX2)
-		_game->_guard._gCode1 |= 2;
-
-	if (bounds.right < _vm->_screen->_orgX1)
-		_game->_guard._gCode2 |= 8;
-	else if (bounds.bottom > _vm->_screen->_orgX2)
-		_game->_guard._gCode2 |= 2;
-}
-
-void AmazonScripts::chkVLine() {
-	if (_game->_guard._position.x > _vm->_player->_rawPlayer.x)
-		_game->_guard._bounds = Common::Rect(_vm->_player->_rawPlayer.x, _vm->_player->_rawPlayer.y, _game->_guard._position.x, _game->_guard._position.y);
-	else
-		_game->_guard._bounds = Common::Rect(_game->_guard._position.x, _game->_guard._position.y, _vm->_player->_rawPlayer.x, _vm->_player->_rawPlayer.y);
-
-	if (_vm->_screen->_orgY1 > _vm->_screen->_orgY2)
-		SWAP(_vm->_screen->_orgY1, _vm->_screen->_orgY2);
-
-	while (true) {
-		setVerticalCode(_game->_guard._bounds);
-		int code = _game->_guard._gCode1 | _game->_guard._gCode2;
-		if (code == 10) {
-			_game->_guardFind = 0;
-			return;
-		}
-
-		int code2 = _game->_guard._gCode1 & _game->_guard._gCode2;
-		code2 &= 5;
-		if (((code & 10) == 8) || ((code & 10) == 2) || (code2 != 0))
-			return;
-
-		int midX = (_game->_guard._bounds.left + _game->_guard._bounds.right) / 2;
-		int midY = (_game->_guard._bounds.top + _game->_guard._bounds.bottom) / 2;
-
-		if (midX < _vm->_screen->_orgX1) {
-			if ((midX == _game->_guard._bounds.left) && (midY == _game->_guard._bounds.top))
-				return;
-
-			_game->_guard._bounds.left = midX;
-			_game->_guard._bounds.top = midY;
-		} else {
-			if ((midX == _game->_guard._bounds.right) && (midY == _game->_guard._bounds.bottom))
-				return;
-
-			_game->_guard._bounds.right = midX;
-			_game->_guard._bounds.bottom = midY;
-		}
-	}
-}
-
-void AmazonScripts::chkHLine() {
-	if (_game->_guard._position.y > _vm->_player->_rawPlayer.y)
-		_game->_guard._bounds = Common::Rect(_vm->_player->_rawPlayer.x, _vm->_player->_rawPlayer.y, _game->_guard._position.x, _game->_guard._position.y);
-	else
-		_game->_guard._bounds = Common::Rect(_game->_guard._position.x, _game->_guard._position.y, _vm->_player->_rawPlayer.x, _vm->_player->_rawPlayer.y);
-
-	if (_vm->_screen->_orgX1 > _vm->_screen->_orgX2)
-		SWAP(_vm->_screen->_orgX1, _vm->_screen->_orgX2);
-
-	while (true) {
-		setHorizontalCode(_game->_guard._bounds);
-		int code = _game->_guard._gCode1 | _game->_guard._gCode2;
-		if (code == 5) {
-			_game->_guardFind = 0;
-			return;
-		}
-
-		int code2 = _game->_guard._gCode1 & _game->_guard._gCode2;
-		code2 &= 10;
-		if (((code & 5) == 4) || ((code & 5) == 1) || (code2 != 0))
-			return;
-
-		int midX = (_game->_guard._bounds.left + _game->_guard._bounds.right) / 2;
-		int midY = (_game->_guard._bounds.top + _game->_guard._bounds.bottom) / 2;
-
-		if (midY < _vm->_screen->_orgY1) {
-			if ((midX == _game->_guard._bounds.left) && (midY == _game->_guard._bounds.top))
-				return;
-
-			_game->_guard._bounds.left = midX;
-			_game->_guard._bounds.top = midY;
-		} else {
-			if ((midX == _game->_guard._bounds.right) && (midY == _game->_guard._bounds.bottom))
-				return;
-
-			_game->_guard._bounds.right = midX;
-			_game->_guard._bounds.bottom = midY;
-		}
-	}
-}
-
-void AmazonScripts::guardSee() {
-	int tmpY = (_vm->_screen->_scrollRow << 4) + _vm->_screen->_scrollY;
-	_game->_flags[140] = 0;
-	if (tmpY > _game->_guard._position.y)
-		return;
-
-	tmpY += _vm->_screen->_vWindowLinesTall;
-	tmpY -= 11;
-
-	if (tmpY < _game->_guard._position.y)
-		return;
-
-	_game->_guardFind = 1;
-	_game->_flags[140] = 1;
-
-	for (uint16 idx = 0; idx < _vm->_room->_plotter._walls.size(); idx++) {
-		_vm->_screen->_orgX1 = _vm->_room->_plotter._walls[idx].left;
-		_vm->_screen->_orgY1 = _vm->_room->_plotter._walls[idx].top;
-		_vm->_screen->_orgX2 = _vm->_room->_plotter._walls[idx].right;
-		_vm->_screen->_orgY2 = _vm->_room->_plotter._walls[idx].bottom;
-		if (_vm->_screen->_orgX1 == _vm->_screen->_orgX2) {
-			chkVLine();
-			if (_game->_guardFind == 0)
-				return;
-		} else if (_vm->_screen->_orgY1 == _vm->_screen->_orgY2) {
-			chkHLine();
-			if (_game->_guardFind == 0)
-				return;
-		}
-	}
-}
-
-void AmazonScripts::setGuardFrame() {
-	ImageEntry ie;
-	ie._flags = 8;
-	if (_game->_guardLocation == 4)
-		ie._flags |= 2;
-	ie._spritesPtr = _vm->_objectsTable[37];
-	ie._frameNumber = _game->_guard._guardCel;
-	ie._position = _game->_guard._position;
-	ie._offsetY = 10;
-	_vm->_images.addToList(ie);
-}
-
-void AmazonScripts::guard() {
-	if (_vm->_timers[8]._flag != 0)
-		return;
-
-	++_vm->_timers[8]._flag;
-	++_game->_guard._guardCel;
-	int curCel = _game->_guard._guardCel;
-
-	switch (_game->_guardLocation) {
-	case 1:
-		// Guard walking down
-		if (curCel <= 8 || curCel > 13)
-			_game->_guard._guardCel = curCel = 8;
-
-		_game->_guard._position.y += _vm->_player->_walkOffDown[curCel - 8];
-		guardSee();
-		if (_game->_guard._position.y >= 272) {
-			_game->_guard._position.y = 272;
-			_game->_guardLocation = 2;
-		}
-		break;
-	case 2:
-		// Guard walking left
-		if (curCel <= 43 || curCel > 48)
-			_game->_guard._guardCel = curCel = 43;
-
-		_game->_guard._position.x -= _vm->_player->_walkOffLeft[curCel - 43];
-		guardSee();
-		if (_game->_guard._position.x <= 56) {
-			_game->_guard._position.x = 56;
-			_game->_guardLocation = 3;
-		}
-		break;
-	case 3:
-		// Guard walking up
-		if (curCel <= 0 || curCel > 5)
-			_game->_guard._guardCel = curCel = 0;
-
-		_game->_guard._position.y -= _vm->_player->_walkOffUp[curCel];
-		guardSee();
-		if (_game->_guard._position.y <= 89) {
-			_game->_guard._position.y = 89;
-			_game->_guardLocation = 4;
-			if (_game->_flags[121] == 1)
-				_game->_guardLocation = 5;
-		}
-		break;
-	default:
-		// Guard walking right
-		if (curCel <= 43 || curCel > 48)
-			_game->_guard._guardCel = curCel = 43;
-
-		_game->_guard._position.x += _vm->_player->_walkOffRight[curCel - 43];
-		guardSee();
-		if (_game->_guard._position.x >= 127) {
-			_game->_guard._position.x = 127;
-			_game->_guardLocation = 1;
-		}
-		break;
-	}
-
-	setGuardFrame();
-}
-
 void AmazonScripts::loadBackground(int param1, int param2) {
 	_vm->_files->_setPaletteFlag = false;
 	_vm->_files->loadScreen(param1, param2);
@@ -2099,7 +1848,7 @@ void AmazonScripts::executeSpecial(int commandIndex, int param1, int param2) {
 		mWhile(param1);
 		break;
 	case 9:
-		guard();
+		_game->_guard.guard();
 		break;
 	case 10:
 		_vm->_sound->newMusic(param1, param2);
diff --git a/engines/access/amazon/amazon_scripts.h b/engines/access/amazon/amazon_scripts.h
index 1da10d8..20dfb63 100644
--- a/engines/access/amazon/amazon_scripts.h
+++ b/engines/access/amazon/amazon_scripts.h
@@ -80,13 +80,6 @@ protected:
 	void scrollRiver();
 	void mWhileDownRiver();
 	void mWhile(int param1);
-	void setVerticalCode(Common::Rect bounds);
-	void setHorizontalCode(Common::Rect bounds);
-	void chkVLine();
-	void chkHLine();
-	void guardSee();
-	void setGuardFrame();
-	void guard();
 	void plotTorchSpear(int indx, const int *&buf);
 	void plotPit(int indx, const int *&buf);
 	int antHandleRight(int indx, const int *&buf);


Commit: 84d500a35a2fc674adbbbc59311702f195cb4984
    https://github.com/scummvm/scummvm/commit/84d500a35a2fc674adbbbc59311702f195cb4984
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-12T22:46:49-05:00

Commit Message:
ACCESS: Fix flickering slaver guard

Changed paths:
    engines/access/amazon/amazon_game.cpp



diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp
index 550d8b2..1a89ddb 100644
--- a/engines/access/amazon/amazon_game.cpp
+++ b/engines/access/amazon/amazon_game.cpp
@@ -1158,8 +1158,10 @@ void Guard::setGuardFrame() {
 }
 
 void Guard::guard() {
-	if (_vm->_timers[8]._flag != 0)
+	if (_vm->_timers[8]._flag) {
+		setGuardFrame();
 		return;
+	}
 
 	++_vm->_timers[8]._flag;
 	++_guardCel;


Commit: 0cafe2719d56e1acd1b3972737a9f8e031d51136
    https://github.com/scummvm/scummvm/commit/0cafe2719d56e1acd1b3972737a9f8e031d51136
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-12T22:47:00-05:00

Commit Message:
ACCESS: Fix for proper vertical scrolling on the ship

Changed paths:
    engines/access/room.cpp



diff --git a/engines/access/room.cpp b/engines/access/room.cpp
index f32bc95..57a5c4a 100644
--- a/engines/access/room.cpp
+++ b/engines/access/room.cpp
@@ -343,14 +343,14 @@ void Room::buildRow(int playY, int screenY) {
 		return;
 	assert(screenY <= (_vm->_screen->h - TILE_HEIGHT));
 
-	const byte *pSrc = _playField + screenY *_playFieldWidth + _vm->_screen->_scrollCol;
+	const byte *pSrc = _playField + playY *_playFieldWidth + _vm->_screen->_scrollCol;
 
 	// WORKAROUND: Original's use of '+ 1' would frequently cause memory overruns
 	int w = MIN(_vm->_screen->_vWindowWidth + 1, _playFieldWidth);
 
 	for (int x = 0; x < w; ++x) {
 		byte *pTile = _tile + (*pSrc << 8);
-		byte *pDest = (byte *)_vm->_buffer1.getBasePtr(w * TILE_WIDTH, screenY);
+		byte *pDest = (byte *)_vm->_buffer1.getBasePtr(x * TILE_WIDTH, screenY);
 
 		for (int tileY = 0; tileY < TILE_HEIGHT; ++tileY) {
 			Common::copy(pTile, pTile + TILE_WIDTH, pDest);


Commit: 953321cc26f431f82314866b15fe312094e32ecb
    https://github.com/scummvm/scummvm/commit/953321cc26f431f82314866b15fe312094e32ecb
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-12T22:47:11-05:00

Commit Message:
ACCESS: Fix a glitch in the intro, add a workaround for a crash, fix a logic flaw

Changed paths:
    engines/access/amazon/amazon_game.cpp



diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp
index 1a89ddb..05ac80e 100644
--- a/engines/access/amazon/amazon_game.cpp
+++ b/engines/access/amazon/amazon_game.cpp
@@ -161,8 +161,8 @@ void AmazonEngine::doCredit() {
 		_buffer2.plotImage(_objectsTable[0], 12, Common::Point(88, 55));
 		_buffer2.plotImage(_objectsTable[0], 6, Common::Point(194, 98));
 	} else if (_pCount <= 520) {
-		_buffer2.plotImage(_objectsTable[0], 7, Common::Point(90, 35));
-		_buffer2.plotImage(_objectsTable[0], 8, Common::Point(90, 35));
+		_buffer2.plotImage(_objectsTable[0], 7, Common::Point(32, 13));
+		_buffer2.plotImage(_objectsTable[0], 8, Common::Point(162, 80));
 	} else if (_pCount <= 580) {
 		_buffer2.plotImage(_objectsTable[0], 9, Common::Point(18, 15));
 		_buffer2.plotImage(_objectsTable[0], 10, Common::Point(164, 81));
@@ -258,6 +258,7 @@ void AmazonEngine::doTitle() {
 		_events->pollEvents();
 		g_system->delayMillis(10);
 	}
+
 	if (_events->_rightButton) {
 		_skipStart = true;
 		_room->clearRoom();
@@ -343,19 +344,19 @@ void AmazonEngine::doTitle() {
 				++_screen->_scrollRow;
 				_buffer1.moveBufferUp();
 
-				_room->buildRow(_screen->_scrollRow + _screen->_vWindowHeight, _screen->_vWindowLinesTall * _screen->_bufferBytesWide);
+				// WORKAROUND: the original was using _screen->_vWindowBytesWide * _screen->_vWindowLinesTall
+				_room->buildRow(_screen->_scrollRow + _screen->_vWindowHeight, _screen->_vWindowLinesTall);
 
 				if (_screen->_scrollRow + _screen->_vWindowHeight >= _room->_playFieldHeight) {
 					_room->clearRoom();
 					_events->showCursor();
 					return;
 				}
-				
-				scrollTitle();
-				while (!shouldQuit() && (_events->_vbCount > 0)) {
-					_events->pollEvents();
-					g_system->delayMillis(10);
-				}
+			}
+			scrollTitle();
+			while (!shouldQuit() && (_events->_vbCount > 0)) {
+				_events->pollEvents();
+				g_system->delayMillis(10);
 			}
 		}
 	}


Commit: fde1ea9d0e5edc6b3761b893891c5c7431488a91
    https://github.com/scummvm/scummvm/commit/fde1ea9d0e5edc6b3761b893891c5c7431488a91
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-12T22:47:22-05:00

Commit Message:
ACCESS: Improve usage of ImageEntry _flags IMGFLAG enum

Changed paths:
    engines/access/access.cpp
    engines/access/amazon/amazon_game.cpp
    engines/access/amazon/amazon_scripts.cpp
    engines/access/asurface.h



diff --git a/engines/access/access.cpp b/engines/access/access.cpp
index 88c62a7..2c97316 100644
--- a/engines/access/access.cpp
+++ b/engines/access/access.cpp
@@ -360,12 +360,12 @@ void AccessEngine::plotList1() {
 		Common::Rect destBounds = bounds;
 
 		if (_buffer2.clip(bounds)) {
-			ie._flags |= 1;
+			ie._flags |= IMGFLAG_CROPPED;
 		} else {
-			ie._flags &= ~1;
+			ie._flags &= ~IMGFLAG_CROPPED;
 			if (_buffer2._leftSkip != 0 ||  _buffer2._rightSkip != 0
 				|| _buffer2._topSkip != 0 || _buffer2._bottomSkip != 0)
-				ie._flags |= 1;
+				ie._flags |= IMGFLAG_CROPPED;
 
 			_newRects.push_back(bounds);
 
@@ -373,7 +373,7 @@ void AccessEngine::plotList1() {
 				_buffer2._rightSkip /= _scale;
 				bounds.setWidth(bounds.width() / _scale);
 
-				if (ie._flags & 2) {
+				if (ie._flags & IMGFLAG_BACKWARDS) {
 					_buffer2.sPlotB(frame, destBounds);
 				} else {
 					_buffer2.sPlotF(frame, destBounds);
@@ -386,6 +386,8 @@ void AccessEngine::plotList1() {
 				}
 			}
 		}
+
+		ie._flags |= IMGFLAG_DRAWN;
 	}
 }
 
diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp
index 05ac80e..c575d84 100644
--- a/engines/access/amazon/amazon_game.cpp
+++ b/engines/access/amazon/amazon_game.cpp
@@ -1147,10 +1147,10 @@ void Guard::guardSee() {
 
 void Guard::setGuardFrame() {
 	ImageEntry ie;
-	ie._flags = 8;
+	ie._flags = IMGFLAG_UNSCALED;
 
 	if (_vm->_guardLocation == 4)
-		ie._flags |= 2;
+		ie._flags |= IMGFLAG_BACKWARDS;
 	ie._spritesPtr = _vm->_objectsTable[37];
 	ie._frameNumber = _guardCel;
 	ie._position = _position;
diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp
index f3f120b..7ec0f95 100644
--- a/engines/access/amazon/amazon_scripts.cpp
+++ b/engines/access/amazon/amazon_scripts.cpp
@@ -301,7 +301,7 @@ void AmazonScripts::jungleMove() {
 
 	for (int i = 0; i < count; ++i) {
 		ImageEntry ie;
-		ie._flags = 8;
+		ie._flags = IMGFLAG_UNSCALED;
 		ie._spritesPtr = _vm->_objectsTable[24];
 		ie._frameNumber = _jCnt[i] + frameOffset;
 		ie._position = Common::Point(_jungleX[i], jungleY[i]);
@@ -437,7 +437,7 @@ void AmazonScripts::pan() {
 
 	for (int i = 0; i < _pNumObj; i++) {
 		ImageEntry ie;
-		ie._flags= 8;
+		ie._flags = IMGFLAG_UNSCALED;
 		ie._position = Common::Point(_pObjX[i], _pObjY[i]);
 		ie._offsetY = 255;
 		ie._spritesPtr = _pObject[i];
@@ -1046,7 +1046,7 @@ void AmazonScripts::plotTorchSpear(int indx, const int *&buf) {
 	int idx = indx;
 
 	ImageEntry ie;
-	ie._flags = 8;
+	ie._flags = IMGFLAG_UNSCALED;
 	ie._spritesPtr = _vm->_objectsTable[62];
 	ie._frameNumber = buf[(idx / 2)];
 	ie._position = Common::Point(_game->_pitPos.x + buf[(idx / 2) + 1], _game->_pitPos.y + buf[(idx / 2) + 2]);
@@ -1057,7 +1057,7 @@ void AmazonScripts::plotTorchSpear(int indx, const int *&buf) {
 void AmazonScripts::plotPit(int indx, const int *&buf) {
 	int idx = indx;
 	ImageEntry ie;
-	ie._flags = 8;
+	ie._flags = IMGFLAG_UNSCALED;
 	ie._spritesPtr = _vm->_objectsTable[62];
 	ie._frameNumber = buf[(idx / 2)];
 	ie._position = Common::Point(_game->_pitPos.x, _game->_pitPos.y);
@@ -1233,7 +1233,7 @@ void AmazonScripts::ANT() {
 	}
 
 	ImageEntry ie;
-	ie._flags = 8;
+	ie._flags = IMGFLAG_UNSCALED;
 	ie._spritesPtr = _vm->_objectsTable[61];
 	ie._frameNumber = buf[(idx / 2)];
 	ie._position = Common::Point(_game->_antPos.x, _game->_antPos.y);
@@ -1730,7 +1730,7 @@ void AmazonScripts::plotRiver() {
 	}
 
 	ImageEntry ie;
-	ie._flags = 8;
+	ie._flags = IMGFLAG_UNSCALED;
 	ie._spritesPtr = _vm->_objectsTable[45];
 	ie._frameNumber = _game->_canoeFrame;
 	ie._position.x = (_vm->_screen->_scrollCol * 16) + _vm->_screen->_scrollX + 160;
@@ -1741,7 +1741,7 @@ void AmazonScripts::plotRiver() {
 	RiverStruct *cur = _game->_topList;
 	while (cur <= _game->_botList) {
 		if (cur[0]._id != -1) {
-			ie._flags = 8;
+			ie._flags = IMGFLAG_UNSCALED;
 			ie._spritesPtr = _vm->_objectsTable[45];
 			ie._frameNumber = 0;
 			ie._position.x = cur[0]._field5;
diff --git a/engines/access/asurface.h b/engines/access/asurface.h
index 1c30db8..273578c 100644
--- a/engines/access/asurface.h
+++ b/engines/access/asurface.h
@@ -131,7 +131,8 @@ public:
 	SpriteFrame *getFrame(int idx) { return _frames[idx]; }
 };
 
-enum ImageFlag { IMGFLAG_BACKWARDS = 2, IMGFLAG_UNSCALED = 8 };
+enum ImageFlag { IMGFLAG_CROPPED = 1, IMGFLAG_BACKWARDS = 2, IMGFLAG_DRAWN = 4,
+	IMGFLAG_UNSCALED = 8 };
 
 class ImageEntry {
 public:


Commit: d8c97d259bc19f22ecf8b1cc9da03c374a3adbec
    https://github.com/scummvm/scummvm/commit/d8c97d259bc19f22ecf8b1cc9da03c374a3adbec
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-12T22:47:33-05:00

Commit Message:
ACCESS: add code to replace the checks on KEYBUFCNT

Changed paths:
    engines/access/amazon/amazon_game.cpp
    engines/access/amazon/amazon_scripts.cpp



diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp
index c575d84..6da895a 100644
--- a/engines/access/amazon/amazon_game.cpp
+++ b/engines/access/amazon/amazon_game.cpp
@@ -253,8 +253,7 @@ void AmazonEngine::doTitle() {
 	_screen->forceFadeIn();
 	_sound->newMusic(1, 0);
 	_events->_vbCount = 700;
-	warning("TODO: check on KEYBUFCNT");
-	while (!shouldQuit() && (_events->_vbCount > 0) && (!_events->_leftButton) && (!_events->_rightButton)) {
+	while (!shouldQuit() && (_events->_vbCount > 0) && !_events->isKeyMousePressed()) {
 		_events->pollEvents();
 		g_system->delayMillis(10);
 	}
@@ -287,15 +286,9 @@ void AmazonEngine::doTitle() {
 	_pCount = 0;
 
 	while (!shouldQuit()) {
-		if (_events->_rightButton) {
-			_skipStart = true;
-			_room->clearRoom();
-			_events->showCursor();
-			return;
-		}
-
-		warning("TODO: check on KEYBUFCNT");
-		if (_events->_leftButton) {
+		if (!_events->isKeyMousePressed()) {
+			if (_events->_rightButton)
+				_skipStart = true;
 			_room->clearRoom();
 			_events->showCursor();
 			return;
diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp
index 7ec0f95..30cd6c8 100644
--- a/engines/access/amazon/amazon_scripts.cpp
+++ b/engines/access/amazon/amazon_scripts.cpp
@@ -1004,7 +1004,8 @@ void AmazonScripts::doCast(int param1) {
 		_vm->copyBlocks();
 
 		_vm->_events->pollEvents();
-		warning("TODO: check on KEYBUFCNT");
+		if (_vm->_events->isKeyMousePressed())
+			break;
 
 		if (_yCam < -7550) {
 			_vm->_events->_vbCount = 50;


Commit: 89b20c618f16f1d3ad8e33819dd9202d234aa258
    https://github.com/scummvm/scummvm/commit/89b20c618f16f1d3ad8e33819dd9202d234aa258
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-12T22:47:44-05:00

Commit Message:
ACCESS: Fix to correctly draw partly off-screen sprites

Changed paths:
    engines/access/asurface.cpp



diff --git a/engines/access/asurface.cpp b/engines/access/asurface.cpp
index 96cb199..e954e9e 100644
--- a/engines/access/asurface.cpp
+++ b/engines/access/asurface.cpp
@@ -224,7 +224,7 @@ void ASurface::copyTo(ASurface *dest, const Common::Rect &bounds) {
 	int scaleY = SCALE_LIMIT * bounds.height() / this->h;
 	int scaleXCtr = 0, scaleYCtr = 0;
 
-	for (int yCtr = 0, y = bounds.top; yCtr < this->h; ++yCtr) {
+	for (int yCtr = 0, destY = bounds.top; yCtr < this->h; ++yCtr, ++destY) {
 		// Handle skipping lines if Y scaling 
 		scaleYCtr += scaleY;
 		if (scaleYCtr < SCALE_LIMIT)
@@ -232,14 +232,14 @@ void ASurface::copyTo(ASurface *dest, const Common::Rect &bounds) {
 		scaleYCtr -= SCALE_LIMIT;
 
 		// Handle off-screen lines
-		if (y < 0)
+		if (destY < 0)
 			continue;
-		else if (y >= dest->h)
+		else if (destY >= dest->h)
 			break;
 
 		// Handle drawing the line
 		byte *pSrc = (byte *)getBasePtr(0, yCtr);
-		byte *pDest = (byte *)dest->getBasePtr(bounds.left, y);
+		byte *pDest = (byte *)dest->getBasePtr(bounds.left, destY);
 		scaleXCtr = 0;
 		int x = bounds.left;
 
@@ -259,8 +259,6 @@ void ASurface::copyTo(ASurface *dest, const Common::Rect &bounds) {
 			++pDest;
 			++x;
 		}
-
-		++y;
 	}
 }
 


Commit: 7434c764c6899e114d07e756356a55595adb8694
    https://github.com/scummvm/scummvm/commit/7434c764c6899e114d07e756356a55595adb8694
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-12T22:47:55-05:00

Commit Message:
ACCESS: gcc compilation fixes

Changed paths:
    engines/access/access.cpp
    engines/access/access.h
    engines/access/amazon/amazon_game.cpp
    engines/access/amazon/amazon_game.h
    engines/access/amazon/amazon_resources.cpp
    engines/access/amazon/amazon_scripts.cpp
    engines/access/files.cpp
    engines/access/files.h
    engines/access/player.h
    engines/access/scripts.cpp



diff --git a/engines/access/access.cpp b/engines/access/access.cpp
index 2c97316..4d326ac 100644
--- a/engines/access/access.cpp
+++ b/engines/access/access.cpp
@@ -220,7 +220,6 @@ void AccessEngine::speakText(ASurface *s, const Common::String &msg) {
 		soundsLeft = _countTbl[curPage];
 		_events->zeroKeys();
 
-		Common::String line;
 		int width = 0;
 		bool lastLine = _fonts._font2.getLine(lines, s->_maxChars * 6, line, width);
 
diff --git a/engines/access/access.h b/engines/access/access.h
index 2cd35fb..c0bc467 100644
--- a/engines/access/access.h
+++ b/engines/access/access.h
@@ -117,7 +117,7 @@ protected:
 	* Support method that generates a savegame name
 	* @param slot		Slot number
 	*/
-	Common::String AccessEngine::generateSaveName(int slot);
+	Common::String generateSaveName(int slot);
 
 	/**
 	 * Play back an entire video
diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp
index 6da895a..9b9df8b 100644
--- a/engines/access/amazon/amazon_game.cpp
+++ b/engines/access/amazon/amazon_game.cpp
@@ -672,7 +672,7 @@ void AmazonEngine::helpTitle() {
 
 	Common::String iqText = "IQ: ";
 	calcIQ();
-	Common::String IQSCORE = Common::String::format("d", _iqValue);
+	Common::String IQSCORE = Common::String::format("%d", _iqValue);
 	while (IQSCORE.size() != 4)
 		IQSCORE = " " + IQSCORE;
 
diff --git a/engines/access/amazon/amazon_game.h b/engines/access/amazon/amazon_game.h
index 7917586..2d371ca 100644
--- a/engines/access/amazon/amazon_game.h
+++ b/engines/access/amazon/amazon_game.h
@@ -165,7 +165,7 @@ public:
 	bool _deathFlag;
 	int _deathCount;
 	int _deathType;
-	byte *_mapPtr;
+	const byte *_mapPtr;
 	int _canoeVXPos;
 	int _canoeMoveCount;
 	int _canoeFrame;
diff --git a/engines/access/amazon/amazon_resources.cpp b/engines/access/amazon/amazon_resources.cpp
index 08ecfff..68e078e 100644
--- a/engines/access/amazon/amazon_resources.cpp
+++ b/engines/access/amazon/amazon_resources.cpp
@@ -1653,7 +1653,7 @@ RiverStruct RIVER0OBJECTS[45] = {
 	{17,  30,  305, 0, 2, 15}
 };
 
-RiverStruct ENDRIVER0[1] = {16, 31, 260, 0, 7, 12};
+RiverStruct ENDRIVER0[1] = { { 16, 31, 260, 0, 7, 12 } };
 
 RiverStruct RIVER1OBJECTS[49] = {
 	{16,  31, 6920, 0, 1, 12},
@@ -1707,7 +1707,7 @@ RiverStruct RIVER1OBJECTS[49] = {
 	{17,  30,  305, 0, 3, 15}
 };
 
-RiverStruct ENDRIVER1[1] = {16, 31, 260, 0, 1, 12};
+RiverStruct ENDRIVER1[1] = { { 16, 31, 260, 0, 1, 12 } };
 
 RiverStruct RIVER2OBJECTS[53] = {
 	{16,  31, 8230, 0, 6, 12},
@@ -1765,7 +1765,7 @@ RiverStruct RIVER2OBJECTS[53] = {
 	{17,  30,  305, 0, 3, 15}
 };
 
-RiverStruct ENDRIVER2[1] = {16, 31, 260, 0, 6, 12};
+RiverStruct ENDRIVER2[1] = { { 16, 31, 260, 0, 6, 12 } };
 
 RiverStruct *RIVEROBJECTTBL[6] = {
 	RIVER0OBJECTS, ENDRIVER0, RIVER1OBJECTS, 
diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp
index 30cd6c8..7b4729b 100644
--- a/engines/access/amazon/amazon_scripts.cpp
+++ b/engines/access/amazon/amazon_scripts.cpp
@@ -1282,7 +1282,7 @@ void AmazonScripts::ANT() {
 
 void AmazonScripts::boatWalls(int param1, int param2) {
 	if (param1 == 1)
-		_vm->_room->_plotter._walls[42] = Common::Rect(96, 27, 87, 42);
+		_vm->_room->_plotter._walls[42] = Common::Rect(96, 27, 96 + 87, 27 + 42);
 	else {
 		_vm->_room->_plotter._walls[39].bottom = _vm->_room->_plotter._walls[41].bottom = 106;
 		_vm->_room->_plotter._walls[40].left = 94;
@@ -1439,7 +1439,7 @@ void AmazonScripts::initRiver() {
 	++_game->_timers[3]._flag;
 
 	_game->_canoeFrame = 0;
-	_game->_mapPtr = (byte *)MAPTBL[_game->_riverFlag] + 1;
+	_game->_mapPtr = (const byte *)MAPTBL[_game->_riverFlag] + 1;
 	if (_game->_saveRiver == 1) {
 		_game->_mapPtr--;
 		_game->_mapPtr += _game->_mapOffset;
@@ -1771,7 +1771,7 @@ void AmazonScripts::RIVER() {
 	while (true) {
 		_vm->_events->_vbCount = 4;
 
-		int bx = _vm->_player->_scrollAmount - _screenVertX;
+//		int bx = _vm->_player->_scrollAmount - _screenVertX;
 		if (_vm->_screen->_scrollX == 0) {
 			_vm->_sound->midiRepeat();
 			if (riverJumpTest()) {
diff --git a/engines/access/files.cpp b/engines/access/files.cpp
index dacceb7..df11422 100644
--- a/engines/access/files.cpp
+++ b/engines/access/files.cpp
@@ -59,10 +59,10 @@ Resource::~Resource() {
 	delete _stream;
 }
 
-Resource::Resource(byte *data, int size) {
-	_data = data;
+Resource::Resource(byte *p, int size) {
+	_data = p;
 	_size = size;
-	_stream = new Common::MemoryReadStream(data, size);
+	_stream = new Common::MemoryReadStream(p, size);
 }
 
 byte *Resource::data() {
diff --git a/engines/access/files.h b/engines/access/files.h
index f65f2ba..f90071d 100644
--- a/engines/access/files.h
+++ b/engines/access/files.h
@@ -62,7 +62,7 @@ public:
 	int _size;
 
 	Resource();
-	Resource::Resource(byte *data, int size);
+	Resource(byte *data, int size);
 	~Resource();
 	byte *data();
 };
diff --git a/engines/access/player.h b/engines/access/player.h
index 400770c..67908a3 100644
--- a/engines/access/player.h
+++ b/engines/access/player.h
@@ -111,7 +111,7 @@ public:
 	Common::Point _rawPlayer;
 public:
 	Player(AccessEngine *vm);
-	~Player();
+	virtual ~Player();
 	static Player *init(AccessEngine *vm);
 
 	virtual void load();
diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp
index d4bd5ad..9aba05a 100644
--- a/engines/access/scripts.cpp
+++ b/engines/access/scripts.cpp
@@ -610,13 +610,11 @@ void Scripts::cmdTexChoice() {
 
 	findNull();
 
-	bool choice2Fl = false;
 	tmpStr = "";
 	while ((v = _data->readByte()) != 0)
 		tmpStr += (char)v;
 
 	if (tmpStr.size() != 0) {
-		choice2Fl = true;
 		_vm->_bubbleBox->_bubblePtr = Common::String("RESPONSE 2").c_str();
 		_vm->_bubbleBox->calcBubble(tmpStr);
 		_vm->_bubbleBox->printBubble(tmpStr);


Commit: f75fa68c057dc5e626428415b38f7159d2d23c06
    https://github.com/scummvm/scummvm/commit/f75fa68c057dc5e626428415b38f7159d2d23c06
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-12T22:48:06-05:00

Commit Message:
ACCESS: Add a replacement of configSelect, currently just initializing _hintLevel

Changed paths:
    engines/access/amazon/amazon_game.cpp
    engines/access/amazon/amazon_game.h



diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp
index 9b9df8b..912c4dd 100644
--- a/engines/access/amazon/amazon_game.cpp
+++ b/engines/access/amazon/amazon_game.cpp
@@ -87,6 +87,11 @@ void AmazonEngine::freeInactivePlayer() {
 	_inactive._altSpritesPtr = nullptr;
 }
 
+void AmazonEngine::configSelect() {
+	// Initialize fields contained in the config file.
+	_hintLevel = 3;
+}
+
 void AmazonEngine::playGame() {
 	// Initialize Amazon game-specific objects
 	_room = new AmazonRoom(this);
@@ -95,6 +100,7 @@ void AmazonEngine::playGame() {
 
 	// Setup the game
 	setupGame();
+	configSelect();
 
 	if (_loadSaveSlot == -1) {
 		// Do introduction
diff --git a/engines/access/amazon/amazon_game.h b/engines/access/amazon/amazon_game.h
index 2d371ca..d67f0c2 100644
--- a/engines/access/amazon/amazon_game.h
+++ b/engines/access/amazon/amazon_game.h
@@ -98,6 +98,11 @@ private:
 	 */
 	void setupGame();
 
+	/**
+	 * Initialize variables found in the config file
+	 */
+	void configSelect();
+
 	void initVariables();
 	void calcIQ();
 	void helpTitle();


Commit: 4c71b12e021d69550a7574579327002afda9d0e7
    https://github.com/scummvm/scummvm/commit/4c71b12e021d69550a7574579327002afda9d0e7
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-12T22:48:16-05:00

Commit Message:
ACCESS: Fix memory leaks

Changed paths:
    engines/access/debugger.cpp
    engines/access/debugger.h
    engines/access/files.cpp



diff --git a/engines/access/debugger.cpp b/engines/access/debugger.cpp
index 359b2e7..6b49fb0 100644
--- a/engines/access/debugger.cpp
+++ b/engines/access/debugger.cpp
@@ -78,6 +78,10 @@ Debugger::Debugger(AccessEngine *vm) : GUI::Debugger(), _vm(vm) {
 	}
 }
 
+Debugger::~Debugger() {
+	delete[] _sceneDescr;
+}
+
 bool Debugger::Cmd_LoadScene(int argc, const char **argv) {
 	switch (argc) {
 	case 1:
diff --git a/engines/access/debugger.h b/engines/access/debugger.h
index 60bd223..839d131 100644
--- a/engines/access/debugger.h
+++ b/engines/access/debugger.h
@@ -43,7 +43,7 @@ public:
 	static Debugger *init(AccessEngine *vm);
 public:
 	Debugger(AccessEngine *vm);
-	virtual ~Debugger() {}
+	virtual ~Debugger();
 };
 
 namespace Amazon {
diff --git a/engines/access/files.cpp b/engines/access/files.cpp
index df11422..cbcfa3f 100644
--- a/engines/access/files.cpp
+++ b/engines/access/files.cpp
@@ -55,7 +55,7 @@ Resource::Resource() {
 }
 
 Resource::~Resource() {
-	delete _data;
+	delete[] _data;
 	delete _stream;
 }
 


Commit: abb4b9d1e6cd1373a3d71c2fe97f3ca4d6df2454
    https://github.com/scummvm/scummvm/commit/abb4b9d1e6cd1373a3d71c2fe97f3ca4d6df2454
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-12T22:48:33-05:00

Commit Message:
ACCESS: Fix regression in bd004bd6f3b960e36756248d8e44bfdf955fdb52

Changed paths:
    engines/access/asurface.cpp



diff --git a/engines/access/asurface.cpp b/engines/access/asurface.cpp
index e954e9e..c9c335e 100644
--- a/engines/access/asurface.cpp
+++ b/engines/access/asurface.cpp
@@ -224,7 +224,7 @@ void ASurface::copyTo(ASurface *dest, const Common::Rect &bounds) {
 	int scaleY = SCALE_LIMIT * bounds.height() / this->h;
 	int scaleXCtr = 0, scaleYCtr = 0;
 
-	for (int yCtr = 0, destY = bounds.top; yCtr < this->h; ++yCtr, ++destY) {
+	for (int yCtr = 0, destY = bounds.top; yCtr < this->h; ++yCtr) {
 		// Handle skipping lines if Y scaling 
 		scaleYCtr += scaleY;
 		if (scaleYCtr < SCALE_LIMIT)
@@ -250,7 +250,7 @@ void ASurface::copyTo(ASurface *dest, const Common::Rect &bounds) {
 				continue;
 			scaleXCtr -= SCALE_LIMIT;
 
-			// Only handle on-scren pixels
+			// Only handle on-screen pixels
 			if (x >= dest->w)
 				break;	
 			if (x >= 0 && *pSrc != 0)
@@ -259,6 +259,7 @@ void ASurface::copyTo(ASurface *dest, const Common::Rect &bounds) {
 			++pDest;
 			++x;
 		}
+		++destY;
 	}
 }
 


Commit: f0f19dbea07be8593cdc50bcef671bf69a8bd731
    https://github.com/scummvm/scummvm/commit/f0f19dbea07be8593cdc50bcef671bf69a8bd731
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-12T22:48:47-05:00

Commit Message:
ACCESS: Fix for vertical scrolling after using inventory screen

Changed paths:
    engines/access/asurface.cpp



diff --git a/engines/access/asurface.cpp b/engines/access/asurface.cpp
index c9c335e..6247219 100644
--- a/engines/access/asurface.cpp
+++ b/engines/access/asurface.cpp
@@ -331,17 +331,17 @@ void ASurface::moveBufferLeft() {
 
 void ASurface::moveBufferRight() {
 	byte *p = (byte *)getPixels();
-	Common::copy_backward(p, p + (w * h) - TILE_WIDTH, p + (w * h));
+	Common::copy_backward(p, p + (pitch * h) - TILE_WIDTH, p + (pitch * h));
 }
 
 void ASurface::moveBufferUp() {
 	byte *p = (byte *)getPixels();
-	Common::copy(p + (w * TILE_HEIGHT), p + (w * h), p);
+	Common::copy(p + (pitch * TILE_HEIGHT), p + (pitch * h), p);
 }
 
 void ASurface::moveBufferDown() {
 	byte *p = (byte *)getPixels();
-	Common::copy_backward(p, p + (w * (h - TILE_HEIGHT)), p + (w * h));
+	Common::copy_backward(p, p + (pitch * (h - TILE_HEIGHT)), p + (pitch * h));
 }
 
 } // End of namespace Access


Commit: bb93268ee21a216162ef077c64462e0ac360df0a
    https://github.com/scummvm/scummvm/commit/bb93268ee21a216162ef077c64462e0ac360df0a
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-12T22:48:53-05:00

Commit Message:
ACCESS: Fix left button flag beig stuck after saving & loading games

Changed paths:
    engines/access/access.cpp
    engines/access/events.cpp
    engines/access/events.h
    engines/access/room.cpp



diff --git a/engines/access/access.cpp b/engines/access/access.cpp
index 4d326ac..82c405c 100644
--- a/engines/access/access.cpp
+++ b/engines/access/access.cpp
@@ -491,6 +491,7 @@ Common::Error AccessEngine::loadGameState(int slot) {
 	// Set extra post-load state
 	_room->_function = 1;
 	_timers._timersSavedFlag = false;
+	_events->clearEvents();
 
 	return Common::kNoError;
 }
diff --git a/engines/access/events.cpp b/engines/access/events.cpp
index d911e66..327fb06 100644
--- a/engines/access/events.cpp
+++ b/engines/access/events.cpp
@@ -236,6 +236,11 @@ void EventsManager::debounceLeft() {
 	}
 }
 
+void EventsManager::clearEvents() {
+	_leftButton = _rightButton = false;
+	_keypresses.clear();
+}
+
 void EventsManager::waitKeyMouse() {
 	while (!_vm->shouldQuit() && !_leftButton && _keypresses.size() == 0) {
 		pollEvents();
diff --git a/engines/access/events.h b/engines/access/events.h
index 0a2a541..c72f245 100644
--- a/engines/access/events.h
+++ b/engines/access/events.h
@@ -117,6 +117,8 @@ public:
 
 	void debounceLeft();
 
+	void clearEvents();
+
 	void waitKeyMouse();
 
 	bool checkForNextFrameCounter();
diff --git a/engines/access/room.cpp b/engines/access/room.cpp
index 57a5c4a..9251db4 100644
--- a/engines/access/room.cpp
+++ b/engines/access/room.cpp
@@ -494,6 +494,7 @@ void Room::handleCommand(int commandId) {
 		--commandId;
 
 	if (commandId == 9) {
+		_vm->_events->debounceLeft();
 		_vm->_canSaveLoad = true;
 		_vm->openMainMenuDialog();
 		_vm->_canSaveLoad = false;


Commit: f6a1faa5e4ea7b35b3dd9d1bd942858dd31cdbde
    https://github.com/scummvm/scummvm/commit/f6a1faa5e4ea7b35b3dd9d1bd942858dd31cdbde
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-12T22:49:00-05:00

Commit Message:
ACCESS: Fix check for scene area that can be clicked in

Changed paths:
    engines/access/amazon/amazon_room.cpp



diff --git a/engines/access/amazon/amazon_room.cpp b/engines/access/amazon/amazon_room.cpp
index a942ed3..4df1131 100644
--- a/engines/access/amazon/amazon_room.cpp
+++ b/engines/access/amazon/amazon_room.cpp
@@ -162,10 +162,12 @@ void AmazonRoom::roomMenu() {
 void AmazonRoom::mainAreaClick() {
 	Common::Point &mousePos = _vm->_events->_mousePos;
 	Common::Point pt = _vm->_events->calcRawMouse();
+	Screen &screen = *_vm->_screen;
+	Player &player = *_vm->_player;
 
 	if (_selectCommand == -1) {
-		if (_vm->_player->_roomNumber == 42 || _vm->_player->_roomNumber == 44 ||
-				_vm->_player->_roomNumber == 31 || _vm->_player->_roomNumber == 29) {
+		if (player._roomNumber == 42 || player._roomNumber == 44 ||
+				player._roomNumber == 31 || player._roomNumber == 29) {
 			switch (checkBoxes1(pt)) {
 			case 0:
 				// Make Jason the active player
@@ -182,15 +184,15 @@ void AmazonRoom::mainAreaClick() {
 
 		// WORKAROUND: In Amazon room 9, you can't leave the screen to the south due
 		// to not being able to click a Y position that's high enough
-		if (_vm->_screen->_scrollRow == 0 && pt.y > 178)
+		if (screen._scrollRow == 0 && pt.y > 178)
 			pt.y = 200;
 
-		_vm->_player->_moveTo = pt;
-		_vm->_player->_playerMove = true;
-	} else if (mousePos.x >= _vm->_screen->_windowXAdd &&
-			mousePos.x <= _vm->_screen->_vWindowBytesWide &&
-			mousePos.y >= _vm->_screen->_windowYAdd &&
-			mousePos.y <= _vm->_screen->_vWindowLinesTall) {
+		player._moveTo = pt;
+		player._playerMove = true;
+	} else if (mousePos.x >= screen._windowXAdd &&
+			mousePos.x <= (screen._windowXAdd + screen._vWindowBytesWide) &&
+			mousePos.y >= screen._windowYAdd &&
+			mousePos.y <= (screen._windowYAdd + screen._vWindowLinesTall)) {
 		if (checkBoxes1(pt) >= 0) {
 			checkBoxes3();
 		}


Commit: 64b45e68aa10954edafe34139386b4cd7042ad74
    https://github.com/scummvm/scummvm/commit/64b45e68aa10954edafe34139386b4cd7042ad74
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-12T22:49:06-05:00

Commit Message:
ACCESS: Fix loading or exiting game when Maya is active player

Changed paths:
    engines/access/player.cpp



diff --git a/engines/access/player.cpp b/engines/access/player.cpp
index b504663..b945b76 100644
--- a/engines/access/player.cpp
+++ b/engines/access/player.cpp
@@ -76,7 +76,7 @@ Player::Player(AccessEngine *vm): Manager(vm), ImageEntry() {
 }
 
 Player::~Player() {
-	delete _playerSprites1;
+	delete _playerSprites;
 	delete[] _manPal1;
 }
 
@@ -132,7 +132,7 @@ void Player::loadSprites(const Common::String &name) {
 }
 
 void Player::freeSprites() {
-	delete _playerSprites1;
+	delete _playerSprites;
 	_playerSprites1 = nullptr;
 	_playerSprites = nullptr;
 }


Commit: 3be3cb1ac21dcaf8f79907e9ce463c4828cba65c
    https://github.com/scummvm/scummvm/commit/3be3cb1ac21dcaf8f79907e9ce463c4828cba65c
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-12T22:49:16-05:00

Commit Message:
ACCESS: Cleanup of room _function and river canoe movement

Changed paths:
    engines/access/access.cpp
    engines/access/amazon/amazon_game.cpp
    engines/access/amazon/amazon_resources.cpp
    engines/access/amazon/amazon_resources.h
    engines/access/amazon/amazon_scripts.cpp
    engines/access/amazon/amazon_scripts.h
    engines/access/room.cpp
    engines/access/room.h
    engines/access/scripts.cpp



diff --git a/engines/access/access.cpp b/engines/access/access.cpp
index 82c405c..885b2f9 100644
--- a/engines/access/access.cpp
+++ b/engines/access/access.cpp
@@ -489,7 +489,7 @@ Common::Error AccessEngine::loadGameState(int slot) {
 	delete saveFile;
 
 	// Set extra post-load state
-	_room->_function = 1;
+	_room->_function = FN_CLEAR1;
 	_timers._timersSavedFlag = false;
 	_events->clearEvents();
 
diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp
index 912c4dd..cdc7727 100644
--- a/engines/access/amazon/amazon_game.cpp
+++ b/engines/access/amazon/amazon_game.cpp
@@ -909,7 +909,7 @@ void AmazonEngine::startChapter(int chapter) {
 		}
 	} else if (chapter != 1) {
 		_player->_roomNumber = CHAPTER_JUMP[_chapter - 1];
-		_room->_function = 1;
+		_room->_function = FN_CLEAR1;
 		_converseMode = 0;
 
 		_scripts->cmdRetPos();
@@ -936,8 +936,12 @@ void AmazonEngine::synchronize(Common::Serializer &s) {
 	for (int i = 0; i < 100; ++i)
 		s.syncAsSint16LE(_esTabTable[i]);
 
-	warning("TODO: 	s.syncAsSint16LE(_topList);");
-	warning("TODO: 	s.syncAsSint16LE(_botList);");
+	if (_player->_roomNumber == 45) {
+
+
+		warning("TODO: 	s.syncAsSint16LE(_topList);");
+		warning("TODO: 	s.syncAsSint16LE(_botList);");
+	}
 }
 
 /*------------------------------------------------------------------------*/
diff --git a/engines/access/amazon/amazon_resources.cpp b/engines/access/amazon/amazon_resources.cpp
index 68e078e..6148eeb 100644
--- a/engines/access/amazon/amazon_resources.cpp
+++ b/engines/access/amazon/amazon_resources.cpp
@@ -1223,8 +1223,8 @@ const char *const NO_HELP_MESSAGE =
 HAS DECREASED SO FAR THAT WE CAN NO LONGER PUT THE HINTS IN TERMS \
 YOU CAN UNDERSTAND.";
 const char *const NO_HINTS_MESSAGE = "THE HELP SYSTEM HAS BEEN TURNED OFF FOR THIS GAME.";
-const char *const HIT1 = "YOU HIT THE ROCKS AND THE CANOE BEGINS TO LEAK.";
-const char *const HIT2 = "YOU HIT THE ROCKS AND THE CANOE DEVELOPS SERIOUS LEAKS.";
+const char *const RIVER_HIT1 = "YOU HIT THE ROCKS AND THE CANOE BEGINS TO LEAK.";
+const char *const RIVER_HIT2 = "YOU HIT THE ROCKS AND THE CANOE DEVELOPS SERIOUS LEAKS.";
 const char *const BAR_MESSAGE = "YOU ARE TOO BUSY TRYING TO KEEP FROM SINKING TO DO THAT";
 const char *const HELPLVLTXT[3] = {
 	" LEVEL 1 ",
diff --git a/engines/access/amazon/amazon_resources.h b/engines/access/amazon/amazon_resources.h
index 37b12d2..cd1fc95 100644
--- a/engines/access/amazon/amazon_resources.h
+++ b/engines/access/amazon/amazon_resources.h
@@ -75,8 +75,8 @@ extern const byte FONT6x6_DATA[];
 
 extern const char *const NO_HELP_MESSAGE;
 extern const char *const NO_HINTS_MESSAGE;
-extern const char *const HIT1;
-extern const char *const HIT2;
+extern const char *const RIVER_HIT1;
+extern const char *const RIVER_HIT2;
 extern const char *const BAR_MESSAGE;
 extern const char *const HELPLVLTXT[3];
 extern const char *const IQLABELS[9];
diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp
index 7b4729b..537dd30 100644
--- a/engines/access/amazon/amazon_scripts.cpp
+++ b/engines/access/amazon/amazon_scripts.cpp
@@ -40,6 +40,7 @@ AmazonScripts::AmazonScripts(AccessEngine *vm) : Scripts(vm) {
 	_xCam = 0;
 	_yCam = 0;
 	_zCam = 0;
+	_CHICKENOUTFLG = false;
 
 	_pNumObj = 0;
 	for (int i = 0; i < 32; i++) {
@@ -1557,97 +1558,66 @@ void AmazonScripts::riverSound() {
 }
 
 void AmazonScripts::moveCanoe() {
-	if (_game->_canoeDir != 0) {
-		_game->_canoeYPos += _game->_canoeDir;
-		++_game->_canoeMoveCount;
-		if (_game->_canoeMoveCount == 5) {
-			_game->_canoeLane += _game->_canoeDir;
-			_game->_canoeDir = 0;
-		}
-		return;
-	}
+	Screen &screen = *_vm->_screen;
+	EventsManager &events = *_vm->_events;
+	Common::Point pt = events.calcRawMouse();
 
 	_vm->_events->pollEvents();
-	if (_vm->_events->_leftButton) {
-		Common::Point pt = _vm->_events->calcRawMouse();
-		if (pt.y < 180) {
-			if (_vm->_events->_mousePos.x < RMOUSE[8][0]) {
+
+	if (_game->_canoeDir) {
+		// Canoe movement in progress
+		moveCanoe2();
+	} else {
+		if (events._leftButton && pt.y < 180) {
+			if (RMOUSE[8][0] < pt.x) {
 				printString(BAR_MESSAGE);
-				return;
-			}
-			_game->_saveRiver = 1;
-			_vm->_rScrollRow = _vm->_screen->_scrollRow;
-			_vm->_rScrollCol = _vm->_screen->_scrollCol;
-			_vm->_rScrollX = _vm->_screen->_scrollX;
-			_vm->_rScrollY = _vm->_screen->_scrollY;
-			_vm->_rOldRectCount = _vm->_oldRects.size();
-			_vm->_rNewRectCount = _vm->_newRects.size();
-			// _vm->_rKeyFlag = KEYFLG;
-			_vm->_mapOffset = _game->_mapPtr - MAPTBL[_game->_riverFlag];
-			_vm->doLoadSave();
-			if (_vm->_room->_function == 1) {
-				_endFlag = true;
-				_returnCode = 0;
 			} else {
-				_game->_saveRiver = 0;
-				_vm->_room->buildScreen();
-				_vm->copyBF2Vid();
+				_game->_saveRiver = 1;
+				_game->_rScrollRow = screen._scrollRow;
+				_game->_rScrollCol = screen._scrollCol;
+				_game->_rScrollX = screen._scrollX;
+				_game->_rScrollY = screen._scrollY;
+				_game->_mapOffset = _game->_mapPtr - MAPTBL[_game->_riverFlag];
+
+				// Show the ScummVM menu
+				_vm->_room->handleCommand(9);
+
+				if (_vm->_room->_function == FN_CLEAR1) {
+					_endFlag = true;
+					_returnCode = 0;
+				} else {
+					_game->_saveRiver = 0;
+					_vm->_room->buildScreen();
+					_vm->copyBF2Vid();
+				}
 			}
-			return;
-		} 
-		
-		if (pt.y <= _game->_canoeYPos) {
-			if (_game->_canoeLane == 0)
-				return;
-
-			_game->_canoeDir = -1;
-			_game->_canoeMoveCount = 0;
-			_game->_canoeYPos += _game->_canoeDir;
-			++_game->_canoeMoveCount;
-			if (_game->_canoeMoveCount == 5) {
-				_game->_canoeLane += _game->_canoeDir;
-				_game->_canoeDir = 0;
+		} else if ((events._leftButton && pt.y <= _game->_canoeYPos) ||
+			(!events._leftButton && _vm->_player->_move == UP)) {
+			// Move canoe up
+			if (_game->_canoeLane > 0) {
+				_game->_canoeDir = -1;
+				_game->_canoeMoveCount = 0;
+
+				moveCanoe2();
 			}
-		} else {
-			if (_game->_canoeLane == 7)
-				return;
+		} else if (events._leftButton || _vm->_player->_move == DOWN) {
+			// Move canoe down
+			if (_game->_canoeLane < 7) {
+				_game->_canoeDir = 1;
+				_game->_canoeMoveCount = 0;
 
-			_game->_canoeDir = 1;
-			_game->_canoeMoveCount = 0;
-			_game->_canoeYPos += _game->_canoeDir;
-			++_game->_canoeMoveCount;
-			if (_game->_canoeMoveCount == 5) {
-				_game->_canoeLane += _game->_canoeDir;
-				_game->_canoeDir = 0;
+				moveCanoe2();
 			}
 		}
-		return;
-	}	
-
-	if (_vm->_player->_move == UP) {
-		if (_game->_canoeLane == 0)
-			return;
+	}
+}
 
-		_game->_canoeDir = -1;
-		_game->_canoeMoveCount = 0;
-		_game->_canoeYPos += _game->_canoeDir;
-		++_game->_canoeMoveCount;
-		if (_game->_canoeMoveCount == 5) {
-			_game->_canoeLane += _game->_canoeDir;
-			_game->_canoeDir = 0;
-		}
-	} else if (_vm->_player->_move == DOWN) {
-		if (_game->_canoeLane == 7)
-			return;
+void AmazonScripts::moveCanoe2() {
+	_game->_canoeYPos += _game->_canoeDir;
 
-		_game->_canoeDir = 1;
-		_game->_canoeMoveCount = 0;
+	if (++_game->_canoeMoveCount == 5) {
 		_game->_canoeYPos += _game->_canoeDir;
-		++_game->_canoeMoveCount;
-		if (_game->_canoeMoveCount == 5) {
-			_game->_canoeLane += _game->_canoeDir;
-			_game->_canoeDir = 0;
-		}
+		_game->_canoeDir = 0;
 	}
 }
 
@@ -1768,22 +1738,22 @@ void AmazonScripts::RIVER() {
 	static const int RIVERDEATH[5] = {22, 23, 24, 25, 26};
 
 	initRiver();
-	while (true) {
+	while (!_vm->shouldQuit()) {
 		_vm->_events->_vbCount = 4;
 
 //		int bx = _vm->_player->_scrollAmount - _screenVertX;
 		if (_vm->_screen->_scrollX == 0) {
 			_vm->_sound->midiRepeat();
 			if (riverJumpTest()) {
-				CHICKENOUTFLG = false;
+				_CHICKENOUTFLG = false;
 				return;
 			}
 		} else {
 			_vm->_screen->_scrollX -= _vm->_player->_scrollAmount;
 		}
 
-		if (CHICKENOUTFLG) {
-			CHICKENOUTFLG = false;
+		if (_CHICKENOUTFLG) {
+			_CHICKENOUTFLG = false;
 			return;
 		}
 
@@ -1794,8 +1764,8 @@ void AmazonScripts::RIVER() {
 		pan();
 		moveCanoe();
 
-		if (_vm->_room->_function == 1) {
-			CHICKENOUTFLG = false;
+		if (_vm->_room->_function == FN_CLEAR1) {
+			_CHICKENOUTFLG = false;
 			return;
 		}
 		
diff --git a/engines/access/amazon/amazon_scripts.h b/engines/access/amazon/amazon_scripts.h
index 20dfb63..5fd1bb8 100644
--- a/engines/access/amazon/amazon_scripts.h
+++ b/engines/access/amazon/amazon_scripts.h
@@ -43,7 +43,7 @@ private:
 	int _zCam;
 	int _pNumObj;
 	int _screenVertX;
-	bool CHICKENOUTFLG;
+	bool _CHICKENOUTFLG;
 	int _pImgNum[32];
 
 	SpriteResource *_pObject[32];
@@ -94,6 +94,7 @@ protected:
 	bool riverJumpTest();
 	void riverSound();
 	void moveCanoe();
+	void moveCanoe2();
 	void updateObstacles();
 	void riverSetPhysX();
 	bool checkRiverCollide();
diff --git a/engines/access/room.cpp b/engines/access/room.cpp
index 9251db4..bc76d48 100644
--- a/engines/access/room.cpp
+++ b/engines/access/room.cpp
@@ -29,7 +29,7 @@
 namespace Access {
 
 Room::Room(AccessEngine *vm) : Manager(vm) {
-	_function = 0;
+	_function = FN_NONE;
 	_roomFlag = 0;
 	_playField = nullptr;
 	_playFieldWidth = _playFieldHeight = 0;
@@ -70,7 +70,7 @@ void Room::doRoom() {
 
 		reloadFlag = false;
 		_vm->_startup = 8;
-		_function = 0;
+		_function = FN_NONE;
 
 		while (!_vm->shouldQuit()) {
 			_vm->_images.clear();
@@ -111,7 +111,7 @@ void Room::doRoom() {
 			if (_vm->_player->_scrollFlag) {
 				_vm->copyBF1BF2();
 				_vm->_newRects.clear();
-				_function = 0;
+				_function = FN_NONE;
 				roomLoop();
 
 				if (_function == FN_CLEAR1) {
@@ -125,7 +125,7 @@ void Room::doRoom() {
 			} else {
 				_vm->copyBF1BF2();
 				_vm->_newRects.clear();
-				_function = 0;
+				_function = FN_NONE;
 
 				roomLoop();
 				if (_vm->shouldQuit())
diff --git a/engines/access/room.h b/engines/access/room.h
index a26f2ed..a3ee019 100644
--- a/engines/access/room.h
+++ b/engines/access/room.h
@@ -91,11 +91,6 @@ protected:
 	*/
 	void freeTileData();
 
-	/**
-	* Switch to a given command mode
-	*/
-	void handleCommand(int commandId);
-
 	int checkBoxes();
 	int checkBoxes1(const Common::Point &pt);
 	int checkBoxes2(const Common::Point &pt, int start, int count);
@@ -120,7 +115,7 @@ protected:
 public:
 	Plotter _plotter;
 	Common::Array<JetFrame> _jetFrame;
-	int _function;
+	Function _function;
 	int _roomFlag;
 	byte *_playField;
 	int _matrixSize;
@@ -166,6 +161,11 @@ public:
 	void setWallCodes();
 
 	bool codeWalls();
+
+	/**
+	* Switch to a given command mode
+	*/
+	void handleCommand(int commandId);
 };
 
 class RoomInfo {
diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp
index 9aba05a..72650f4 100644
--- a/engines/access/scripts.cpp
+++ b/engines/access/scripts.cpp
@@ -531,7 +531,7 @@ void Scripts::cmdSpecial() {
 
 	if (_specialFunction == 1) {
 		_vm->_screen->restorePalette();
-		_vm->_room->_function = 3;
+		_vm->_room->_function = FN_RELOAD;
 	}
 }
 


Commit: c6042e2e2593f92ff0dc936fe34e6b933c284589
    https://github.com/scummvm/scummvm/commit/c6042e2e2593f92ff0dc936fe34e6b933c284589
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-12T22:49:26-05:00

Commit Message:
ACCESS: Minor cleanups of canoe code

Changed paths:
    engines/access/amazon/amazon_scripts.cpp



diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp
index 537dd30..aa90471 100644
--- a/engines/access/amazon/amazon_scripts.cpp
+++ b/engines/access/amazon/amazon_scripts.cpp
@@ -1562,16 +1562,18 @@ void AmazonScripts::moveCanoe() {
 	EventsManager &events = *_vm->_events;
 	Common::Point pt = events.calcRawMouse();
 
-	_vm->_events->pollEvents();
+	events.pollEvents();
 
 	if (_game->_canoeDir) {
 		// Canoe movement in progress
 		moveCanoe2();
 	} else {
-		if (events._leftButton && pt.y < 180) {
-			if (RMOUSE[8][0] < pt.x) {
+		if (events._leftButton && pt.y >= 140) {
+			if (pt.x < RMOUSE[8][0]) {
+				// Disk icon wasn't clicked
 				printString(BAR_MESSAGE);
 			} else {
+				// Clicked on the Disc icon
 				_game->_saveRiver = 1;
 				_game->_rScrollRow = screen._scrollRow;
 				_game->_rScrollCol = screen._scrollCol;
@@ -1738,6 +1740,8 @@ void AmazonScripts::RIVER() {
 	static const int RIVERDEATH[5] = {22, 23, 24, 25, 26};
 
 	initRiver();
+	_vm->_events->showCursor();
+
 	while (!_vm->shouldQuit()) {
 		_vm->_events->_vbCount = 4;
 
@@ -1787,14 +1791,11 @@ void AmazonScripts::RIVER() {
 				return;
 			}
 		}
-		
-		if (_vm->_events->_mousePos.y >= 24 && _vm->_events->_mousePos.y <= 136) {
-			_vm->_events->hideCursor();
-			scrollRiver1();
-			_vm->_events->pollEvents();
-		} else
-			scrollRiver1();
 
+		// Scroll the river
+		scrollRiver1();
+
+		// Allow time for new scrolled river position to be shown
 		while (!_vm->shouldQuit() && _vm->_events->_vbCount > 0) {
 			_vm->_events->pollEventsAndWait();
 		}


Commit: b1ea7879f3f6726e4b63aac5f985876fcd1ea9b2
    https://github.com/scummvm/scummvm/commit/b1ea7879f3f6726e4b63aac5f985876fcd1ea9b2
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-12T22:49:35-05:00

Commit Message:
ACCESS: Fix saving/loading using ScummVM GMM in the river scene

Changed paths:
    engines/access/amazon/amazon_scripts.cpp



diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp
index aa90471..ea7df7b 100644
--- a/engines/access/amazon/amazon_scripts.cpp
+++ b/engines/access/amazon/amazon_scripts.cpp
@@ -1562,7 +1562,12 @@ void AmazonScripts::moveCanoe() {
 	EventsManager &events = *_vm->_events;
 	Common::Point pt = events.calcRawMouse();
 
+	// Do an event polling
+	_vm->_canSaveLoad = true;
 	events.pollEvents();
+	_vm->_canSaveLoad = false;
+	if (_vm->_room->_function == FN_CLEAR1)
+		return;
 
 	if (_game->_canoeDir) {
 		// Canoe movement in progress
@@ -1584,10 +1589,7 @@ void AmazonScripts::moveCanoe() {
 				// Show the ScummVM menu
 				_vm->_room->handleCommand(9);
 
-				if (_vm->_room->_function == FN_CLEAR1) {
-					_endFlag = true;
-					_returnCode = 0;
-				} else {
+				if (_vm->_room->_function != FN_CLEAR1) {
 					_game->_saveRiver = 0;
 					_vm->_room->buildScreen();
 					_vm->copyBF2Vid();
@@ -1768,36 +1770,43 @@ void AmazonScripts::RIVER() {
 		pan();
 		moveCanoe();
 
-		if (_vm->_room->_function == FN_CLEAR1) {
-			_CHICKENOUTFLG = false;
-			return;
-		}
-		
-		updateObstacles();
-		riverSetPhysX();
-		bool checkCollide = checkRiverCollide();
-		if (_game->_hitSafe != 0)
-			_game->_hitSafe -= 2;
-
-		if (checkCollide) {
-			cmdDead(RIVERDEATH[0]);
-			return;
-		}
+		if (_vm->_room->_function != FN_CLEAR1) {
+			updateObstacles();
+			riverSetPhysX();
+			bool checkCollide = checkRiverCollide();
+			if (_game->_hitSafe != 0)
+				_game->_hitSafe -= 2;
 
-		if (_game->_deathFlag) {
-			_game->_deathCount--;
-			if (_game->_deathCount == 0) {
-				cmdDead(RIVERDEATH[_game->_deathType]);
+			if (checkCollide) {
+				cmdDead(RIVERDEATH[0]);
 				return;
 			}
-		}
 
-		// Scroll the river
-		scrollRiver1();
+			if (_game->_deathFlag) {
+				_game->_deathCount--;
+				if (_game->_deathCount == 0) {
+					cmdDead(RIVERDEATH[_game->_deathType]);
+					return;
+				}
+			}
+
+			// Scroll the river
+			scrollRiver1();
 
-		// Allow time for new scrolled river position to be shown
-		while (!_vm->shouldQuit() && _vm->_events->_vbCount > 0) {
-			_vm->_events->pollEventsAndWait();
+			// Allow time for new scrolled river position to be shown
+			_vm->_canSaveLoad = true;
+			while (!_vm->shouldQuit() && _vm->_room->_function == FN_NONE &&
+					_vm->_events->_vbCount > 0) {
+				_vm->_events->pollEventsAndWait();
+			}
+			_vm->_canSaveLoad = false;
+		}
+
+		if (_vm->_room->_function == FN_CLEAR1) {
+			_endFlag = true;
+			_returnCode = 0;
+			_CHICKENOUTFLG = false;
+			break;
 		}
 	}
 }


Commit: 3f445384415d18bc4e437c33df67be88dfdb4a0a
    https://github.com/scummvm/scummvm/commit/3f445384415d18bc4e437c33df67be88dfdb4a0a
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-12T22:49:43-05:00

Commit Message:
ACCESS: Fix array sizes for panning objects fields

Changed paths:
    engines/access/amazon/amazon_scripts.h



diff --git a/engines/access/amazon/amazon_scripts.h b/engines/access/amazon/amazon_scripts.h
index 5fd1bb8..bd47e9c 100644
--- a/engines/access/amazon/amazon_scripts.h
+++ b/engines/access/amazon/amazon_scripts.h
@@ -44,15 +44,14 @@ private:
 	int _pNumObj;
 	int _screenVertX;
 	bool _CHICKENOUTFLG;
-	int _pImgNum[32];
 
 	SpriteResource *_pObject[32];
-
+	int _pImgNum[32];
 	int _pObjX[32];
 	int _pObjY[32];
 	int _pObjZ[32];
-	int _pObjXl[16];
-	int _pObjYl[16];
+	int _pObjXl[32];
+	int _pObjYl[32];
 
 	int _jCnt[3];
 	int _jungleX[3];


Commit: 27351011799b4c85e0fc7f80acbbbf10dbb78aa9
    https://github.com/scummvm/scummvm/commit/27351011799b4c85e0fc7f80acbbbf10dbb78aa9
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-12T22:49:53-05:00

Commit Message:
ACCESS: Finish the implementation of cmdHelp (still a redraw issue)

Changed paths:
    engines/access/amazon/amazon_game.cpp
    engines/access/amazon/amazon_game.h
    engines/access/amazon/amazon_resources.cpp
    engines/access/amazon/amazon_resources.h
    engines/access/amazon/amazon_scripts.cpp



diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp
index cdc7727..f4cf83e 100644
--- a/engines/access/amazon/amazon_game.cpp
+++ b/engines/access/amazon/amazon_game.cpp
@@ -726,7 +726,7 @@ void AmazonEngine::drawHelpText(const Common::String &msg) {
 	_events->showCursor();
 }
 
-void AmazonEngine::drawHelp() {
+void AmazonEngine::drawHelp(const Common::String str) {
 	_events->hideCursor();
 	if (_useItem == 0) {
 		_buffer2.copyBuffer(_screen);
@@ -760,7 +760,7 @@ void AmazonEngine::drawHelp() {
 		_screen->fadeIn();
 
 	helpTitle();
-	drawHelpText("TODO: WHICH BUFFER?");
+	drawHelpText(str);
 }
 
 void AmazonEngine::startChapter(int chapter) {
diff --git a/engines/access/amazon/amazon_game.h b/engines/access/amazon/amazon_game.h
index d67f0c2..435e172 100644
--- a/engines/access/amazon/amazon_game.h
+++ b/engines/access/amazon/amazon_game.h
@@ -197,7 +197,7 @@ public:
 	*/
 	void freeInactivePlayer();
 
-	void drawHelp();
+	void drawHelp(const Common::String str);
 
 	virtual void establish(int esatabIndex, int sub);
 
diff --git a/engines/access/amazon/amazon_resources.cpp b/engines/access/amazon/amazon_resources.cpp
index 6148eeb..05e234a 100644
--- a/engines/access/amazon/amazon_resources.cpp
+++ b/engines/access/amazon/amazon_resources.cpp
@@ -1772,6 +1772,10 @@ RiverStruct *RIVEROBJECTTBL[6] = {
 	ENDRIVER1, RIVER2OBJECTS, ENDRIVER2
 };
 
+const int HELP1COORDS[2][4] = {
+	{  76, 129, 168, 183 }, { 187, 240, 168, 183 }
+};
+
 } // End of namespace Amazon
 
 } // End of namespace Access
diff --git a/engines/access/amazon/amazon_resources.h b/engines/access/amazon/amazon_resources.h
index cd1fc95..6d94e6a 100644
--- a/engines/access/amazon/amazon_resources.h
+++ b/engines/access/amazon/amazon_resources.h
@@ -126,6 +126,7 @@ extern RiverStruct RIVER2OBJECTS[53];
 extern RiverStruct ENDRIVER2[1];
 
 extern RiverStruct *RIVEROBJECTTBL[6];
+extern const int HELP1COORDS[2][4];
 
 } // End of namespace Amazon
 
diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp
index ea7df7b..cde1ff8 100644
--- a/engines/access/amazon/amazon_scripts.cpp
+++ b/engines/access/amazon/amazon_scripts.cpp
@@ -1887,8 +1887,51 @@ void AmazonScripts::cmdHelp() {
 	if (level < _game->_helpLevel)
 		_game->_moreHelp = 0;
 
-	_game->drawHelp();
-	error("TODO: more cmdHelp");
+	_game->drawHelp(helpMessage);
+
+	while(true) {
+		while(!_vm->shouldQuit() && !_vm->_events->_leftButton)
+			_vm->_events->pollEventsAndWait();
+
+		_vm->_events->debounceLeft();
+
+		static const Common::Rect butn1 = Common::Rect(HELP1COORDS[0][0], HELP1COORDS[0][2], HELP1COORDS[0][1], HELP1COORDS[0][3]);
+		static const Common::Rect butn2 = Common::Rect(HELP1COORDS[1][0], HELP1COORDS[1][2], HELP1COORDS[1][1], HELP1COORDS[1][3]);
+		const Common::Point pt = _vm->_events->_mousePos;
+
+		int choice = -1;
+		if (butn1.contains(pt))
+			choice = 0;
+		else if (butn2.contains(pt))
+			choice = 1;
+
+		if (choice < 0)
+			continue;
+
+		if (choice == 1) {
+			_game->_helpLevel = 0;
+			_game->_moreHelp = 1;
+			_game->_useItem = 0;
+			_vm->_events->hideCursor();
+			_vm->_screen->restoreScreen();
+			_vm->_screen->setPanel(0);
+			_vm->_buffer2.copyFrom(*_vm->_screen);
+			_vm->_screen->restorePalette();
+			_vm->_screen->setPalette();
+			_vm->_events->showCursor();
+			free(_vm->_objectsTable[45]);
+			_vm->_objectsTable[45] = nullptr;
+			_vm->_timers.restoreTimers();
+			break;
+		} else {
+			if ((_game->_moreHelp == 0) || (choice != 0))
+				continue;
+			++_game->_helpLevel;
+			_game->_useItem = 1;
+			break;
+		}
+	}
+	findNull();
 }
 
 void AmazonScripts::cmdCycleBack() {


Commit: 62a7619017c676c229ba72b295a4ceae19d3f0c7
    https://github.com/scummvm/scummvm/commit/62a7619017c676c229ba72b295a4ceae19d3f0c7
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-12T22:50:03-05:00

Commit Message:
ACCESS: Better fix for drawing partially off-screen sprites

Changed paths:
    engines/access/asurface.cpp



diff --git a/engines/access/asurface.cpp b/engines/access/asurface.cpp
index 6247219..4202ed0 100644
--- a/engines/access/asurface.cpp
+++ b/engines/access/asurface.cpp
@@ -232,33 +232,34 @@ void ASurface::copyTo(ASurface *dest, const Common::Rect &bounds) {
 		scaleYCtr -= SCALE_LIMIT;
 
 		// Handle off-screen lines
-		if (destY < 0)
-			continue;
-		else if (destY >= dest->h)
+		if (destY >= dest->h)
 			break;
 
-		// Handle drawing the line
-		byte *pSrc = (byte *)getBasePtr(0, yCtr);
-		byte *pDest = (byte *)dest->getBasePtr(bounds.left, destY);
-		scaleXCtr = 0;
-		int x = bounds.left;
-
-		for (int xCtr = 0; xCtr < this->w; ++xCtr, ++pSrc) {
-			// Handle horizontal scaling
-			scaleXCtr += scaleX;
-			if (scaleXCtr < SCALE_LIMIT)
-				continue;
-			scaleXCtr -= SCALE_LIMIT;
-
-			// Only handle on-screen pixels
-			if (x >= dest->w)
-				break;	
-			if (x >= 0 && *pSrc != 0)
-				*pDest = *pSrc;
-			
-			++pDest;
-			++x;
+		if (destY >= 0) {
+			// Handle drawing the line
+			byte *pSrc = (byte *)getBasePtr(0, yCtr);
+			byte *pDest = (byte *)dest->getBasePtr(bounds.left, destY);
+			scaleXCtr = 0;
+			int x = bounds.left;
+
+			for (int xCtr = 0; xCtr < this->w; ++xCtr, ++pSrc) {
+				// Handle horizontal scaling
+				scaleXCtr += scaleX;
+				if (scaleXCtr < SCALE_LIMIT)
+					continue;
+				scaleXCtr -= SCALE_LIMIT;
+
+				// Only handle on-screen pixels
+				if (x >= dest->w)
+					break;
+				if (x >= 0 && *pSrc != 0)
+					*pDest = *pSrc;
+
+				++pDest;
+				++x;
+			}
 		}
+
 		++destY;
 	}
 }


Commit: bfbce8c6a6ac00423b47f3c3ce0f3b9a32e497ae
    https://github.com/scummvm/scummvm/commit/bfbce8c6a6ac00423b47f3c3ce0f3b9a32e497ae
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-12T22:50:15-05:00

Commit Message:
ACCESS: Cleanup of updateObstacles

Changed paths:
    engines/access/amazon/amazon_game.cpp
    engines/access/amazon/amazon_game.h
    engines/access/amazon/amazon_scripts.cpp
    engines/access/events.cpp



diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp
index f4cf83e..4237982 100644
--- a/engines/access/amazon/amazon_game.cpp
+++ b/engines/access/amazon/amazon_game.cpp
@@ -44,7 +44,7 @@ AccessEngine(syst, gameDesc),
 	_canoeLane = 0;
 	_canoeYPos = 0;
 	_hitCount = 0;
-	_saveRiver = 0;
+	_saveRiver = false;
 	_hitSafe = 0;
 	_oldTitleChapter = _chapter = 0;
 	_updateChapter = -1;
diff --git a/engines/access/amazon/amazon_game.h b/engines/access/amazon/amazon_game.h
index 435e172..4c4b304 100644
--- a/engines/access/amazon/amazon_game.h
+++ b/engines/access/amazon/amazon_game.h
@@ -150,7 +150,7 @@ public:
 	int _canoeLane;
 	int _canoeYPos;
 	int _hitCount;
-	int _saveRiver;
+	bool _saveRiver;
 	int _hitSafe;
 	int _chapter;
 	int _riverIndex;
diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp
index cde1ff8..7cae5fd 100644
--- a/engines/access/amazon/amazon_scripts.cpp
+++ b/engines/access/amazon/amazon_scripts.cpp
@@ -1408,12 +1408,14 @@ void AmazonScripts::initRiver() {
 	_vm->_destIn = &_vm->_buffer2;
 	_vm->_room->roomMenu();
 
-	if (_game->_saveRiver == 1) {
+	if (_game->_saveRiver) {
+		// Restoring a savegame, so set properties from saved fields
 		_vm->_screen->_scrollRow = _vm->_rScrollRow;
 		_vm->_screen->_scrollCol = _vm->_rScrollCol;
 		_vm->_screen->_scrollX = _vm->_rScrollX;
 		_vm->_screen->_scrollY = _vm->_rScrollY;
 	} else {
+		// Set initial scene state
 		_vm->_screen->_scrollRow = 0;
 		_vm->_screen->_scrollCol = 140;
 		_vm->_screen->_scrollX = 0;
@@ -1423,11 +1425,14 @@ void AmazonScripts::initRiver() {
 	_vm->_room->buildScreen();
 	_vm->copyBF2Vid();
 	_vm->_screen->forceFadeIn();
-	if (_game->_saveRiver == 1) {
+
+	if (_game->_saveRiver) {
+		// Restore draw rects from savegame
 		_vm->_oldRects.resize(_vm->_rOldRectCount);
 		_vm->_newRects.resize(_vm->_rNewRectCount);
 		// KEYFLG = _vm->_rKeyFlag
 	} else {
+		// Reset draw rects
 		_vm->_oldRects.clear();
 		_vm->_newRects.clear();
 		// KEYFLG = 0
@@ -1441,7 +1446,7 @@ void AmazonScripts::initRiver() {
 
 	_game->_canoeFrame = 0;
 	_game->_mapPtr = (const byte *)MAPTBL[_game->_riverFlag] + 1;
-	if (_game->_saveRiver == 1) {
+	if (_game->_saveRiver) {
 		_game->_mapPtr--;
 		_game->_mapPtr += _game->_mapOffset;
 	} else {
@@ -1468,7 +1473,7 @@ void AmazonScripts::initRiver() {
 	++_game->_timers[12]._flag;
 	
 	_game->_maxHits = 2 - _game->_riverFlag;
-	_game->_saveRiver = 0;
+	_game->_saveRiver = false;
 }
 
 void AmazonScripts::resetPositions() {
@@ -1579,7 +1584,7 @@ void AmazonScripts::moveCanoe() {
 				printString(BAR_MESSAGE);
 			} else {
 				// Clicked on the Disc icon
-				_game->_saveRiver = 1;
+				_game->_saveRiver = true;
 				_game->_rScrollRow = screen._scrollRow;
 				_game->_rScrollCol = screen._scrollCol;
 				_game->_rScrollX = screen._scrollX;
@@ -1590,7 +1595,7 @@ void AmazonScripts::moveCanoe() {
 				_vm->_room->handleCommand(9);
 
 				if (_vm->_room->_function != FN_CLEAR1) {
-					_game->_saveRiver = 0;
+					_game->_saveRiver = false;
 					_vm->_room->buildScreen();
 					_vm->copyBF2Vid();
 				}
@@ -1626,42 +1631,32 @@ void AmazonScripts::moveCanoe2() {
 }
 
 void AmazonScripts::updateObstacles() {
-	RiverStruct *cur = _game->_topList;
-	while (true) {
-		int val = cur[0]._field1 + cur[0]._field3 - 1;
-		if (val < _screenVertX) {
-			cur = _game->_topList;
-			cur--;
-			_game->_botList = cur;
-			return;
-		}
-
-		if (cur[0]._field3 < _screenVertX + 319) {
-			_game->_topList = _game->_botList = cur;
+	RiverStruct *cur;
+	for (cur = _game->_topList; cur < RIVEROBJECTTBL[_game->_riverIndex + 1]; ++cur) {
+		int val = cur->_field1 + cur->_field3 - 1;
+		if (val < _screenVertX)
 			break;
-		}
 
-		if (cur > RIVEROBJECTTBL[_game->_riverIndex + 1]) {
-			cur = _game->_topList;
-			cur--;
+		if (cur->_field3 < (_game->_screenVirtX + 319)) {
+			_game->_topList = cur;
 			_game->_botList = cur;
-			return;
-		}
-	}
 
-	while (true) {
-		if (cur > RIVEROBJECTTBL[_game->_riverIndex + 1])
-			return;
-		++cur;
-		int val = cur[0]._field1 + cur[0]._field3 - 1;
-		if (val < _screenVertX)
-			return;
+			while (cur < RIVEROBJECTTBL[_game->_riverIndex + 1]) {
+				++cur;
+				val = cur->_field1 + cur->_field3 - 1;
+				if (val < _screenVertX || (cur->_field3 >= (_game->_screenVirtX + 319)))
+					break;
 
-		if (cur[0]._field3 >= _screenVertX + 319)
-			return;
+				_game->_botList = cur;
+			}
 
-		_game->_botList = cur;
+			return;
+		}
 	}
+
+	cur = _game->_topList;
+	cur--;
+	_game->_botList = cur;
 }
 
 void AmazonScripts::riverSetPhysX() {
diff --git a/engines/access/events.cpp b/engines/access/events.cpp
index 327fb06..06552b7 100644
--- a/engines/access/events.cpp
+++ b/engines/access/events.cpp
@@ -288,7 +288,7 @@ void EventsManager::centerMousePos() {
 }
 
 void EventsManager::restrictMouse() {
-	warning("TODO: restrictMouse");
+	// No implementation in ScummVM
 }
 
 } // End of namespace Access


Commit: abecac94d4b944f1c594f6963cb308614086360a
    https://github.com/scummvm/scummvm/commit/abecac94d4b944f1c594f6963cb308614086360a
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-12T22:50:24-05:00

Commit Message:
ACCESS: Fix to restrict river canoe to 7 allowable 'lanes'

Changed paths:
    engines/access/amazon/amazon_scripts.cpp



diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp
index 7cae5fd..5849125 100644
--- a/engines/access/amazon/amazon_scripts.cpp
+++ b/engines/access/amazon/amazon_scripts.cpp
@@ -1625,7 +1625,7 @@ void AmazonScripts::moveCanoe2() {
 	_game->_canoeYPos += _game->_canoeDir;
 
 	if (++_game->_canoeMoveCount == 5) {
-		_game->_canoeYPos += _game->_canoeDir;
+		_game->_canoeLane += _game->_canoeDir;
 		_game->_canoeDir = 0;
 	}
 }


Commit: eeb9d63a19ba3a712a8f02ecede554dc992246fe
    https://github.com/scummvm/scummvm/commit/eeb9d63a19ba3a712a8f02ecede554dc992246fe
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-12T22:50:36-05:00

Commit Message:
ACCESS: Don't decrease timers whilst text dialogs are showing

Changed paths:
    engines/access/events.cpp
    engines/access/events.h
    engines/access/scripts.cpp



diff --git a/engines/access/events.cpp b/engines/access/events.cpp
index 06552b7..8b109ea 100644
--- a/engines/access/events.cpp
+++ b/engines/access/events.cpp
@@ -120,9 +120,9 @@ bool EventsManager::isCursorVisible() {
 	return CursorMan.isVisible();
 }
 
-void EventsManager::pollEvents() {
+void EventsManager::pollEvents(bool skipTimers) {
 	if (checkForNextFrameCounter()) {
-		nextFrame();
+		nextFrame(skipTimers);
 	}
 
 	_wheelUp = _wheelDown = false;
@@ -200,10 +200,12 @@ bool EventsManager::checkForNextFrameCounter() {
 	return false;
 }
 
-void EventsManager::nextFrame() {
-	// Update timers
-	_vm->_animation->updateTimers();
-	_vm->_timers.updateTimers();
+void EventsManager::nextFrame(bool skipTimers) {
+	if (skipTimers) {
+		// Update timers
+		_vm->_animation->updateTimers();
+		_vm->_timers.updateTimers();
+	}
 
 	// Give time to the debugger
 	_vm->_debugger->onFrame();
@@ -243,7 +245,7 @@ void EventsManager::clearEvents() {
 
 void EventsManager::waitKeyMouse() {
 	while (!_vm->shouldQuit() && !_leftButton && _keypresses.size() == 0) {
-		pollEvents();
+		pollEvents(true);
 		g_system->delayMillis(10);
 	}
 
diff --git a/engines/access/events.h b/engines/access/events.h
index c72f245..95ba926 100644
--- a/engines/access/events.h
+++ b/engines/access/events.h
@@ -47,7 +47,7 @@ private:
 	uint32 _frameCounter;
 	uint32 _priorFrameTime;
 	Graphics::Surface _invCursor;
-	void nextFrame();
+	void nextFrame(bool skipTimers);
 public:
 	CursorType _cursorId;
 	CursorType _normalMouse;
@@ -105,7 +105,7 @@ public:
 	 */
 	bool isCursorVisible();
 
-	void pollEvents();
+	void pollEvents(bool skipTimers = false);
 
 	void pollEventsAndWait();
 
diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp
index 72650f4..d611b6f 100644
--- a/engines/access/scripts.cpp
+++ b/engines/access/scripts.cpp
@@ -213,7 +213,7 @@ void Scripts::printString(const Common::String &msg) {
 
 	// Wait until the bubble display is expired
 	while (!_vm->shouldQuit() && _vm->_timers[PRINT_TIMER]._flag) {
-		_vm->_events->pollEvents();
+		_vm->_events->pollEvents(true);
 	}
 
 	// Restore the original screen over the text bubble


Commit: 740df9b42aac87472353512d2eda796bdd6d3aa3
    https://github.com/scummvm/scummvm/commit/740df9b42aac87472353512d2eda796bdd6d3aa3
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-12T22:50:45-05:00

Commit Message:
ACCESS: Further tweaks to timer skipping

Changed paths:
    engines/access/events.cpp
    engines/access/scripts.cpp



diff --git a/engines/access/events.cpp b/engines/access/events.cpp
index 8b109ea..87e5d10 100644
--- a/engines/access/events.cpp
+++ b/engines/access/events.cpp
@@ -201,7 +201,7 @@ bool EventsManager::checkForNextFrameCounter() {
 }
 
 void EventsManager::nextFrame(bool skipTimers) {
-	if (skipTimers) {
+	if (!skipTimers) {
 		// Update timers
 		_vm->_animation->updateTimers();
 		_vm->_timers.updateTimers();
diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp
index d611b6f..72650f4 100644
--- a/engines/access/scripts.cpp
+++ b/engines/access/scripts.cpp
@@ -213,7 +213,7 @@ void Scripts::printString(const Common::String &msg) {
 
 	// Wait until the bubble display is expired
 	while (!_vm->shouldQuit() && _vm->_timers[PRINT_TIMER]._flag) {
-		_vm->_events->pollEvents(true);
+		_vm->_events->pollEvents();
 	}
 
 	// Restore the original screen over the text bubble


Commit: e3322185686f268c0375bcaef93c5ef35209ebdc
    https://github.com/scummvm/scummvm/commit/e3322185686f268c0375bcaef93c5ef35209ebdc
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-12T22:50:54-05:00

Commit Message:
ACCESS: Workaround for Exit/walk icon in massacre site scene

Changed paths:
    engines/access/amazon/amazon_room.cpp
    engines/access/amazon/amazon_room.h
    engines/access/room.cpp
    engines/access/room.h



diff --git a/engines/access/amazon/amazon_room.cpp b/engines/access/amazon/amazon_room.cpp
index 4df1131..ca0d7bf 100644
--- a/engines/access/amazon/amazon_room.cpp
+++ b/engines/access/amazon/amazon_room.cpp
@@ -199,6 +199,22 @@ void AmazonRoom::mainAreaClick() {
 	}
 }
 
+void AmazonRoom::walkCursor() {
+	// WORKAROUND: For scene 29, which is a normal walkable scene, but yet can be
+	// 'exitted'. This workaround ensures the scene will only be left if you click
+	// the Exit icon wgeb the cursor is already a walk cursor
+	EventsManager &events = *_vm->_events;
+
+	if (_vm->_player->_roomNumber == 29 && events._normalMouse != CURSOR_CROSSHAIRS) {
+		events._normalMouse = CURSOR_CROSSHAIRS;
+		events.setCursor(CURSOR_CROSSHAIRS);
+		_selectCommand = -1;
+		_vm->_boxSelect = true;
+	} else {
+		Room::walkCursor();
+	}
+}
+
 void AmazonRoom::init4Quads() {
 	if (!_vm->_screen->_vesaMode)
 		return;
diff --git a/engines/access/amazon/amazon_room.h b/engines/access/amazon/amazon_room.h
index bcb0d84..ab92127 100644
--- a/engines/access/amazon/amazon_room.h
+++ b/engines/access/amazon/amazon_room.h
@@ -53,6 +53,8 @@ protected:
 	virtual void mainAreaClick();
 
 	virtual void clearRoom();
+
+	virtual void walkCursor();
 public:
 	AmazonRoom(AccessEngine *vm);
 
diff --git a/engines/access/room.cpp b/engines/access/room.cpp
index bc76d48..b9ce069 100644
--- a/engines/access/room.cpp
+++ b/engines/access/room.cpp
@@ -540,19 +540,7 @@ void Room::executeCommand(int commandId) {
 		events.setCursor(CURSOR_TALK);
 		break;
 	case 7:
-		events._normalMouse = CURSOR_CROSSHAIRS;
-		events.setCursor(CURSOR_CROSSHAIRS);
-		_vm->_scripts->_sequence = 5000;
-		_vm->_scripts->searchForSequence();
-		roomMenu();
-		_selectCommand = -1;
-
-		_conFlag = true;
-		while (_conFlag && !_vm->shouldQuit()) {
-			_conFlag = false;
-			_vm->_scripts->executeScript();
-		}
-		_vm->_boxSelect = true;
+		walkCursor();
 		return;
 	case 8:
 		events._normalMouse = CURSOR_HELP;
@@ -580,6 +568,25 @@ void Room::executeCommand(int commandId) {
 	_vm->_boxSelect = true;
 }
 
+void Room::walkCursor() {
+	EventsManager &events = *_vm->_events;
+	
+	events._normalMouse = CURSOR_CROSSHAIRS;
+	events.setCursor(CURSOR_CROSSHAIRS);
+	_vm->_scripts->_sequence = 5000;
+	_vm->_scripts->searchForSequence();
+	roomMenu();
+	_selectCommand = -1;
+
+	_conFlag = true;
+	while (_conFlag && !_vm->shouldQuit()) {
+		_conFlag = false;
+		_vm->_scripts->executeScript();
+	}
+
+	_vm->_boxSelect = true;
+}
+
 void Room::commandOff() {
 	_selectCommand = -1;
 	_vm->_events->setCursor(CURSOR_CROSSHAIRS);
diff --git a/engines/access/room.h b/engines/access/room.h
index a3ee019..4ec80d1 100644
--- a/engines/access/room.h
+++ b/engines/access/room.h
@@ -112,6 +112,8 @@ protected:
 	virtual void doCommands();
 
 	virtual void mainAreaClick() = 0;
+
+	virtual void walkCursor();
 public:
 	Plotter _plotter;
 	Common::Array<JetFrame> _jetFrame;


Commit: 1716cd9b30e9fdf97fcbcc854c30c0818ae90011
    https://github.com/scummvm/scummvm/commit/1716cd9b30e9fdf97fcbcc854c30c0818ae90011
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-12T22:51:04-05:00

Commit Message:
ACCESS: Major refactoring of Amazon logic into their own classes

Changed paths:
  A engines/access/amazon/amazon_logic.cpp
  A engines/access/amazon/amazon_logic.h
    engines/access/access.cpp
    engines/access/access.h
    engines/access/amazon/amazon_game.cpp
    engines/access/amazon/amazon_game.h
    engines/access/amazon/amazon_player.cpp
    engines/access/amazon/amazon_resources.cpp
    engines/access/amazon/amazon_resources.h
    engines/access/amazon/amazon_room.cpp
    engines/access/amazon/amazon_scripts.cpp
    engines/access/amazon/amazon_scripts.h
    engines/access/martian/martian_game.h
    engines/access/module.mk
    engines/access/player.cpp
    engines/access/scripts.cpp
    engines/access/scripts.h



diff --git a/engines/access/access.cpp b/engines/access/access.cpp
index 885b2f9..1ab40a2 100644
--- a/engines/access/access.cpp
+++ b/engines/access/access.cpp
@@ -92,15 +92,6 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc)
 	_helpTbl[2] = _help3;
 	_travel = 0;
 	_ask = 0;
-	_rScrollRow = 0;
-	_rScrollCol = 0;
-	_rScrollX = 0;
-	_rScrollY = 0;
-	_rOldRectCount = 0;
-	_rNewRectCount = 0;
-	_rKeyFlag = 0;
-	_mapOffset = 0;
-	_screenVirtX = 0;
 	_lastTime = g_system->getMillis();
 	_curTime = 0;
 	_narateFile = 0;
@@ -524,15 +515,6 @@ void AccessEngine::synchronize(Common::Serializer &s) {
 
 	s.syncAsUint16LE(_travel);
 	s.syncAsUint16LE(_ask);
-	s.syncAsUint16LE(_rScrollRow);
-	s.syncAsUint16LE(_rScrollCol);
-	s.syncAsSint16LE(_rScrollX);
-	s.syncAsSint16LE(_rScrollY);
-	s.syncAsUint16LE(_rOldRectCount);
-	s.syncAsUint16LE(_rNewRectCount);
-	s.syncAsUint16LE(_rKeyFlag);
-	s.syncAsUint16LE(_mapOffset);
-	s.syncAsUint16LE(_screenVirtX);
 
 	for (int i = 0; i < 100; ++i)
 		s.syncAsByte(_establishTable[i]);
diff --git a/engines/access/access.h b/engines/access/access.h
index c0bc467..0942c9e 100644
--- a/engines/access/access.h
+++ b/engines/access/access.h
@@ -213,15 +213,6 @@ public:
 	byte *_helpTbl[3];
 	int _travel;
 	int _ask;
-	int _rScrollRow;
-	int _rScrollCol;
-	int _rScrollX;
-	int _rScrollY;
-	int _rOldRectCount;
-	int _rNewRectCount;
-	int _rKeyFlag;
-	int _mapOffset;
-	int _screenVirtX;
 
 	bool _clearSummaryFlag;
 
@@ -234,6 +225,8 @@ public:
 	AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc);
 	virtual ~AccessEngine();
 
+	virtual void dead(int deathId) = 0;
+
 	uint32 getFeatures() const;
 	bool isCD() const;
 	Common::Language getLanguage() const;
diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp
index 4237982..55876b5 100644
--- a/engines/access/amazon/amazon_game.cpp
+++ b/engines/access/amazon/amazon_game.cpp
@@ -36,38 +36,22 @@ AccessEngine(syst, gameDesc),
 		_jasMayaFlag(_flags[168]), _moreHelp(_flags[169]), _flashbackFlag(_flags[171]),
 		_riverFlag(_flags[185]), _aniOutFlag(_flags[195]), _badEnd(_flags[218]), 
 		_noHints(_flags[219]), _aniFlag(_flags[229]), _allenFlag(_flags[237]), 
-		_noSound(_flags[239]) {
+		_noSound(_flags[239]),
+		_ant(this), _cast(this), _guard(this), _jungle(this), _opening(this), 
+		_plane(this), _river(this) {
 
 	_skipStart = false;
 	_charSegSwitch = false;
 
-	_canoeLane = 0;
-	_canoeYPos = 0;
-	_hitCount = 0;
 	_saveRiver = false;
-	_hitSafe = 0;
 	_oldTitleChapter = _chapter = 0;
 	_updateChapter = -1;
-	_topList = nullptr;
-	_botList = nullptr;
-	_riverIndex = 0;
 	_rawInactiveX = 0;
 	_rawInactiveY = 0;
 	_inactiveYOff = 0;
 	_tilePos = Common::Point(0, 0);
 	_hintLevel = 0;
 
-	_antDirection = NONE;
-	_pitDirection = NONE;
-	_antCel = 0;
-	_torchCel = 0;
-	_pitCel = 0;
-	_stabCel = 0;
-	_antPos = Common::Point(0, 0);
-	_antDieFl = _antEatFl = false;
-	_stabFl = false;
-	_pitPos = Common::Point(0, 0);
-
 	Common::fill(&_esTabTable[0], &_esTabTable[100], 0);
 	memset(_tileData, 0, sizeof(_tileData));
 	
@@ -96,7 +80,6 @@ void AmazonEngine::playGame() {
 	// Initialize Amazon game-specific objects
 	_room = new AmazonRoom(this);
 	_scripts = new AmazonScripts(this);
-	_guard.setVm(this);
 
 	// Setup the game
 	setupGame();
@@ -140,7 +123,7 @@ void AmazonEngine::doIntroduction() {
 		return;
 
 	_screen->setPanel(3);
-	((AmazonScripts *)_scripts)->mWhileDoOpen();
+	_opening.mWhileDoOpen();
 
 	if (shouldQuit() || _skipStart)
 		return;
@@ -916,315 +899,89 @@ void AmazonEngine::startChapter(int chapter) {
 	}
 }
 
-void AmazonEngine::synchronize(Common::Serializer &s) {
-	AccessEngine::synchronize(s);
-
-	int dummy = 0;
-
-	s.syncAsSint16LE(_canoeLane);
-	s.syncAsSint16LE(_canoeYPos);
-	s.syncAsSint16LE(_hitCount);
-	s.syncAsSint16LE(_saveRiver);
-	s.syncAsSint16LE(_hitSafe);
-	s.syncAsSint16LE(_chapter);
-	s.syncAsSint16LE(dummy);
-	s.syncAsSint16LE(dummy);
-	s.syncAsSint16LE(_riverIndex);
-	s.syncAsSint16LE(_rawInactiveX);
-	s.syncAsSint16LE(_rawInactiveY);
-	s.syncAsSint16LE(_inactiveYOff);
-	for (int i = 0; i < 100; ++i)
-		s.syncAsSint16LE(_esTabTable[i]);
-
-	if (_player->_roomNumber == 45) {
-
-
-		warning("TODO: 	s.syncAsSint16LE(_topList);");
-		warning("TODO: 	s.syncAsSint16LE(_botList);");
-	}
-}
-
-/*------------------------------------------------------------------------*/
-
-Plane::Plane() {
-	_pCount = 0;
-	_planeCount = 0;
-	_propCount = 0;
-	_xCount = 0;
-}
-
-/*------------------------------------------------------------------------*/
-
-Guard::Guard() {
-	_vm = nullptr;
-	_guardCel = 0;
-	_gCode1 = _gCode2 = 0;
-	_xMid = _yMid = 0;
-}
 
-void Guard::setVerticalCode() {
-	_gCode1 = 0;
-	_gCode2 = 0;
-	if (_topLeft.x < _vm->_screen->_orgX1)
-		_gCode1 |= 8;
-	else if (_topLeft.x == _vm->_screen->_orgX1) {
-		_gCode1 |= 8;
-		_gCode1 |= 2;
-	}
-	else
-		_gCode1 |= 2;
-
-	if (_bottomRight.x < _vm->_screen->_orgX1)
-		_gCode2 |= 8;
-	else if (_bottomRight.x == _vm->_screen->_orgX1) {
-		_gCode2 |= 8;
-		_gCode2 |= 2;
-	}
-	else
-		_gCode2 |= 2;
-
-	if (_topLeft.y < _vm->_screen->_orgY1)
-		_gCode1 |= 4;
-	else if (_topLeft.y > _vm->_screen->_orgY2)
-		_gCode1 |= 1;
-
-	if (_bottomRight.y < _vm->_screen->_orgY1)
-		_gCode2 |= 4;
-	else if (_bottomRight.y > _vm->_screen->_orgY2)
-		_gCode2 |= 1;
-}
-
-void Guard::setHorizontalCode() {
-	_gCode1 = 0;
-	_gCode2 = 0;
-
-	if (_topLeft.y < _vm->_screen->_orgY1)
-		_gCode1 |= 4;
-	else if (_topLeft.x == _vm->_screen->_orgX1) {
-		_gCode1 |= 4;
-		_gCode1 |= 1;
-	}
-	else
-		_gCode1 |= 1;
-
-	if (_bottomRight.y < _vm->_screen->_orgY1)
-		_gCode2 |= 4;
-	else if (_bottomRight.x == _vm->_screen->_orgX1) {
-		_gCode2 |= 4;
-		_gCode2 |= 1;
-	}
-	else
-		_gCode2 |= 1;
-
-	if (_topLeft.x < _vm->_screen->_orgX1)
-		_gCode1 |= 8;
-	else if (_topLeft.x > _vm->_screen->_orgX2)
-		_gCode1 |= 2;
-
-	if (_bottomRight.x < _vm->_screen->_orgX1)
-		_gCode2 |= 8;
-	else if (_bottomRight.y > _vm->_screen->_orgX2)
-		_gCode2 |= 2;
-}
+void AmazonEngine::dead(int deathId) {
+	_events->hideCursor();
+	_screen->forceFadeOut();
+	_scripts->cmdFreeSound();
 
-void Guard::chkVLine() {
-	if (_position.x > _vm->_player->_rawPlayer.x) {
-		_topLeft = _vm->_player->_rawPlayer;
-		_bottomRight = _position;
-	} else {
-		_topLeft = _position;
-		_bottomRight = _vm->_player->_rawPlayer;
-	}
+	_sound->_soundTable.push_back(SoundEntry(_files->loadFile(98, 44), 1));
 
-	if (_vm->_screen->_orgY1 > _vm->_screen->_orgY2)
-		SWAP(_vm->_screen->_orgY1, _vm->_screen->_orgY2);
+	_screen->clearScreen();
+	_screen->setPanel(3);
 
-	for (;;) {
-		setVerticalCode();
-		int code = _gCode1 | _gCode2;
-		if (code == 10) {
-			_vm->_guardFind = 0;
-			return;
+	if (deathId != 10) {
+		_sound->newMusic(62, 0);
+		_files->_setPaletteFlag = false;
+		_files->loadScreen(94, 0);
+		_files->_setPaletteFlag = true;
+		_buffer2.copyFrom(*_screen);
+
+		for (int i = 0; i < 3; ++i) {
+			_sound->playSound(0);
+			_screen->forceFadeIn();
+			_sound->playSound(0);
+			_screen->forceFadeOut();
 		}
+		freeCells();
+
+		// Load the cell list for the death screen
+		DeathEntry &de = _deaths[deathId];
+		Common::Array<CellIdent> cells;
+		cells.push_back(_deaths._cells[de._screenId]);
+		loadCells(cells);
+
+		_screen->setDisplayScan();
+		_files->_setPaletteFlag = false;
+		_files->loadScreen(&_buffer2, 94, 1);
+		_screen->setIconPalette();
+
+		_buffer2.plotImage(_objectsTable[0], 0, Common::Point(105, 25));
+		_buffer2.copyTo(_screen);
+		_screen->forceFadeIn();
+
+		_fonts._charSet._hi = 10;
+		_fonts._charSet._lo = 1;
+		_fonts._charFor._lo = 55;
+		_fonts._charFor._hi = 255;
+		_screen->_maxChars = 46;
+		_screen->_printOrg = Common::Point(20, 155);
+		_screen->_printStart = Common::Point(20, 155);
+
+		Common::String &msg = de._msg;
+		_printEnd = 180;
+		printText(_screen, msg);
+		_screen->forceFadeOut();
 
-		int code2 = _gCode1 & _gCode2;
-		code2 &= 5;
-		if (((code & 10) == 8) || ((code & 10) == 2) || (code2 != 0))
-			return;
-
-		int midX = (_topLeft.x + _bottomRight.x) / 2;
-		int midY = (_topLeft.y + _bottomRight.y) / 2;
-
-		if (midX < _vm->_screen->_orgX1) {
-			if ((midX == _topLeft.x) && (midY == _topLeft.y))
-				return;
-
-			_topLeft.x = midX;
-			_topLeft.y = midY;
-		} else {
-			if ((midX == _bottomRight.x) && (midY == _bottomRight.y))
-				return;
-
-			_bottomRight.x = midX;
-			_bottomRight.y = midY;
-		}
-	}
-}
+		_sound->newMusic(0, 1);
+		_events->showCursor();
+		_room->clearRoom();
+		freeChar();
 
-void Guard::chkHLine() {
-	if (_position.y > _vm->_player->_rawPlayer.y) {
-		_topLeft = _vm->_player->_rawPlayer;
-		_bottomRight = _position;
+		warning("TODO: restart game");
+		quitGame();
+		_events->pollEvents();
 	} else {
-		_topLeft = _position;
-		_bottomRight = _vm->_player->_rawPlayer;
-	}
-
-	if (_vm->_screen->_orgX1 > _vm->_screen->_orgX2)
-		SWAP(_vm->_screen->_orgX1, _vm->_screen->_orgX2);
-
-	while (true) {
-		setHorizontalCode();
-		int code = _gCode1 | _gCode2;
-		if (code == 5) {
-			_vm->_guardFind = 0;
-			return;
-		}
-
-		int code2 = _gCode1 & _gCode2;
-		code2 &= 10;
-		if (((code & 5) == 4) || ((code & 5) == 1) || (code2 != 0))
-			return;
-
-		int midX = (_topLeft.x + _bottomRight.x) / 2;
-		int midY = (_topLeft.y + _bottomRight.y) / 2;
-
-		if (midY < _vm->_screen->_orgY1) {
-			if ((midX == _topLeft.x) && (midY == _topLeft.y))
-				return;
-
-			_topLeft.x = midX;
-			_topLeft.y = midY;
-		} else {
-			if ((midX == _bottomRight.x) && (midY == _bottomRight.y))
-				return;
-
-			_bottomRight.x = midX;
-			_bottomRight.y = midY;
-		}
-	}
-}
-
-void Guard::guardSee() {
-	int tmpY = (_vm->_screen->_scrollRow << 4) + _vm->_screen->_scrollY;
-	_vm->_flags[140] = 0;
-	if (tmpY > _position.y)
-		return;
-
-	tmpY += _vm->_screen->_vWindowLinesTall;
-	tmpY -= 11;
-
-	if (tmpY < _position.y)
-		return;
-
-	_vm->_guardFind = 1;
-	_vm->_flags[140] = 1;
-
-	for (uint16 idx = 0; idx < _vm->_room->_plotter._walls.size(); idx++) {
-		_vm->_screen->_orgX1 = _vm->_room->_plotter._walls[idx].left;
-		_vm->_screen->_orgY1 = _vm->_room->_plotter._walls[idx].top;
-		_vm->_screen->_orgX2 = _vm->_room->_plotter._walls[idx].right;
-		_vm->_screen->_orgY2 = _vm->_room->_plotter._walls[idx].bottom;
-		if (_vm->_screen->_orgX1 == _vm->_screen->_orgX2) {
-			chkVLine();
-			if (_vm->_guardFind == 0)
-				return;
-		}
-		else if (_vm->_screen->_orgY1 == _vm->_screen->_orgY2) {
-			chkHLine();
-			if (_vm->_guardFind == 0)
-				return;
-		}
+		quitGame();
+		_events->pollEvents();
 	}
 }
 
-void Guard::setGuardFrame() {
-	ImageEntry ie;
-	ie._flags = IMGFLAG_UNSCALED;
-
-	if (_vm->_guardLocation == 4)
-		ie._flags |= IMGFLAG_BACKWARDS;
-	ie._spritesPtr = _vm->_objectsTable[37];
-	ie._frameNumber = _guardCel;
-	ie._position = _position;
-	ie._offsetY = 10;
-	_vm->_images.addToList(ie);
-}
+void AmazonEngine::synchronize(Common::Serializer &s) {
+	AccessEngine::synchronize(s);
 
-void Guard::guard() {
-	if (_vm->_timers[8]._flag) {
-		setGuardFrame();
-		return;
-	}
+	int dummy = 0;
 
-	++_vm->_timers[8]._flag;
-	++_guardCel;
-	int curCel = _guardCel;
-
-	switch (_vm->_guardLocation) {
-	case 1:
-		// Guard walking down
-		if (curCel <= 8 || curCel > 13)
-			_guardCel = curCel = 8;
-
-		_position.y += _vm->_player->_walkOffDown[curCel - 8];
-		guardSee();
-		if (_position.y >= 272) {
-			_position.y = 272;
-			_vm->_guardLocation = 2;
-		}
-		break;
-	case 2:
-		// Guard walking left
-		if (curCel <= 43 || curCel > 48)
-			_guardCel = curCel = 43;
-
-		_position.x -= _vm->_player->_walkOffLeft[curCel - 43];
-		guardSee();
-		if (_position.x <= 56) {
-			_position.x = 56;
-			_vm->_guardLocation = 3;
-		}
-		break;
-	case 3:
-		// Guard walking up
-		if (curCel <= 0 || curCel > 5)
-			_guardCel = curCel = 0;
-
-		_position.y -= _vm->_player->_walkOffUp[curCel];
-		guardSee();
-		if (_position.y <= 89) {
-			_position.y = 89;
-			_vm->_guardLocation = 4;
-			if (_vm->_flags[121] == 1)
-				_vm->_guardLocation = 5;
-		}
-		break;
-	default:
-		// Guard walking right
-		if (curCel <= 43 || curCel > 48)
-			_guardCel = curCel = 43;
-
-		_position.x += _vm->_player->_walkOffRight[curCel - 43];
-		guardSee();
-		if (_position.x >= 127) {
-			_position.x = 127;
-			_vm->_guardLocation = 1;
-		}
-		break;
-	}
+	s.syncAsSint16LE(_chapter);
+	s.syncAsSint16LE(dummy);
+	s.syncAsSint16LE(dummy);
+	s.syncAsSint16LE(_rawInactiveX);
+	s.syncAsSint16LE(_rawInactiveY);
+	s.syncAsSint16LE(_inactiveYOff);
+	for (int i = 0; i < 100; ++i)
+		s.syncAsSint16LE(_esTabTable[i]);
 
-	setGuardFrame();
+	_river.synchronize(s);
 }
 
 } // End of namespace Amazon
diff --git a/engines/access/amazon/amazon_game.h b/engines/access/amazon/amazon_game.h
index 4c4b304..b09c96d 100644
--- a/engines/access/amazon/amazon_game.h
+++ b/engines/access/amazon/amazon_game.h
@@ -24,53 +24,13 @@
 #define ACCESS_AMAZON_GAME_H
 
 #include "access/access.h"
+#include "access/amazon/amazon_logic.h"
 
 namespace Access {
 
 namespace Amazon {
 
-	class AmazonEngine;
-
-class Plane {
-public:
-	int _pCount;
-	Common::Point _position;
-	int _planeCount;
-	int _propCount;
-	int _xCount;
-public:
-	Plane();
-};
-
-class Guard {
-private:
-	AmazonEngine *_vm;
-
-	void chkVLine();
-	void chkHLine();
-	void setVerticalCode();
-	void setHorizontalCode();
-	void guardSee();
-	void setGuardFrame();
-public:
-	int _guardCel;
-	Common::Point _position;
-	int _gCode1;
-	int _gCode2;
-	Common::Point _topLeft;
-	Common::Point _bottomRight;
-	int _xMid, _yMid;
-public:
-	Guard();
-	void setVm(AmazonEngine *vm) { _vm = vm; }
-
-	void guard();
-};
-
-class InactivePlayer : public ImageEntry {
-public:
-	SpriteResource *_altSpritesPtr;
-};
+class AmazonEngine;
 
 class AmazonEngine : public AccessEngine {
 private:
@@ -126,10 +86,7 @@ public:
 	InactivePlayer _inactive;
 	bool _charSegSwitch;
 	bool _skipStart;
-
-	RiverStruct *_topList;
-	RiverStruct *_botList;
-	int _canoeDir;
+	bool _saveRiver;
 
 	// Fields that are mapped to flags
 	int &_guardLocation;
@@ -147,21 +104,20 @@ public:
 	int &_noSound;
 
 	// Saved fields
-	int _canoeLane;
-	int _canoeYPos;
-	int _hitCount;
-	bool _saveRiver;
-	int _hitSafe;
 	int _chapter;
-	int _riverIndex;
 	int _rawInactiveX;
 	int _rawInactiveY;
 	int _inactiveYOff;
 	int _esTabTable[100];
 
 	// Other game specific fields
+	Ant _ant;
+	Cast _cast;
 	Guard _guard;
+	Jungle _jungle;
+	Opening _opening;
 	Plane _plane;
+	River _river;
 	int _hintLevel;
 	int _updateChapter;
 	int _oldTitleChapter;
@@ -170,28 +126,14 @@ public:
 	bool _deathFlag;
 	int _deathCount;
 	int _deathType;
-	const byte *_mapPtr;
-	int _canoeVXPos;
-	int _canoeMoveCount;
-	int _canoeFrame;
-
-	Direction _antDirection;
-	Direction _pitDirection;
-	int _antCel;
-	int _torchCel;
-	int _pitCel;
-	int _stabCel;
-	Common::Point _antPos;
-	bool _antDieFl;
-	bool _antEatFl;
-	bool _stabFl;
-	Common::Point _pitPos;
 	int _iqValue;
 public:
 	AmazonEngine(OSystem *syst, const AccessGameDescription *gameDesc);
 
 	virtual ~AmazonEngine();
 
+	virtual void dead(int deathId);
+
 	/**
 	* Free the inactive player data
 	*/
diff --git a/engines/access/amazon/amazon_logic.cpp b/engines/access/amazon/amazon_logic.cpp
new file mode 100644
index 0000000..cae3373
--- /dev/null
+++ b/engines/access/amazon/amazon_logic.cpp
@@ -0,0 +1,1832 @@
+/* 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 "common/scummsys.h"
+#include "access/access.h"
+#include "access/resources.h"
+#include "access/screen.h"
+#include "access/amazon/amazon_game.h"
+#include "access/amazon/amazon_logic.h"
+
+namespace Access {
+
+namespace Amazon {
+
+PannedScene::PannedScene(AmazonEngine *vm): AmazonManager(vm) {
+	for (int i = 0; i < PAN_SIZE; ++i) {
+		_pan[i]._pObject = nullptr;
+		_pan[i]._pImgNum = 0;
+		_pan[i]._pObjX = _pan[i]._pObjY = _pan[i]._pObjZ = 0;
+		_pan[i]._pObjXl = _pan[i]._pObjYl = 0;
+	}
+
+	_xCount = 0;
+	_xTrack = _yTrack = _zTrack = 0;
+	_xCam = _yCam = _zCam = 0;
+	_pNumObj = 0;
+	_screenVertX = 0;
+}
+
+void PannedScene::pan() {
+	_zCam += _zTrack;
+	_xCam += _xTrack;
+	int tx = (_xTrack << 8) / _zCam;
+	_yCam += _yTrack;
+	int ty = (_yTrack << 8) / _zCam;
+
+	if (_vm->_timers[24]._flag != 1) {
+		++_vm->_timers[24]._flag;
+		for (int i = 0; i < _pNumObj; i++) {
+			_pan[i]._pObjZ += _zTrack;
+			_pan[i]._pObjXl += (_pan[i]._pObjZ * tx) & 0xff;
+			_pan[i]._pObjX += ((_pan[i]._pObjZ * tx) >> 8) + (_pan[i]._pObjXl >> 8);
+			_pan[i]._pObjXl &= 0xff;
+
+			_pan[i]._pObjYl += (_pan[i]._pObjZ * ty) & 0xff;
+			_pan[i]._pObjY += ((_pan[i]._pObjZ * ty) >> 8) + (_pan[i]._pObjYl >> 8);
+			_pan[i]._pObjYl &= 0xff;
+		}
+	}
+
+	for (int i = 0; i < _pNumObj; i++) {
+		ImageEntry ie;
+		ie._flags = IMGFLAG_UNSCALED;
+		ie._position = Common::Point(_pan[i]._pObjX, _pan[i]._pObjY);
+		ie._offsetY = 255;
+		ie._spritesPtr = _pan[i]._pObject;
+		ie._frameNumber = _pan[i]._pImgNum;
+
+		_vm->_images.addToList(ie);
+	}
+}
+
+/*------------------------------------------------------------------------*/
+
+Opening::Opening(AmazonEngine *vm) : PannedScene(vm) {
+}
+
+void Opening::mWhileDoOpen() {
+	Screen &screen = *_vm->_screen;
+	EventsManager &events = *_vm->_events;
+
+	screen.setBufferScan();
+	events.hideCursor();
+	screen.forceFadeOut();
+	_vm->_skipStart = false;
+	if (_vm->_conversation != 2) {
+		// Cutscene at start of chapter 1
+		screen.setPanel(3);
+		_vm->startChapter(1);
+		_vm->establishCenter(0, 1);
+	}
+
+	Resource *data = _vm->_files->loadFile(1, 0);
+	_vm->_objectsTable[1] = new SpriteResource(_vm, data);
+	delete data;
+
+	_vm->_files->_setPaletteFlag = false;
+	_vm->_files->loadScreen(1, 2);
+	_vm->_buffer2.copyFrom(*_vm->_screen);
+	_vm->_buffer1.copyFrom(*_vm->_screen);
+
+	// Load animation data
+	_vm->_animation->freeAnimationData();
+	Resource *animResource = _vm->_files->loadFile(1, 1);
+	_vm->_animation->loadAnimations(animResource);
+	delete animResource;
+
+	_xTrack = 8;
+	_yTrack = -3;
+	_zTrack = 0;
+	_xCam = _yCam = 0;
+	_zCam = 270;
+	_vm->_timers[24]._timer = _vm->_timers[24]._initTm = 1;
+	++_vm->_timers[24]._flag;
+	_vm->_timers.updateTimers();
+
+	_pNumObj = 10;
+	for (int i = 0; i < _pNumObj; i++) {
+		_pan[i]._pObject = _vm->_objectsTable[1];
+		_pan[i]._pImgNum = OPENING_OBJS[i][0];
+		_pan[i]._pObjX = OPENING_OBJS[i][1];
+		_pan[i]._pObjY = OPENING_OBJS[i][2];
+		_pan[i]._pObjZ = OPENING_OBJS[i][3];
+		_pan[i]._pObjXl = _pan[i]._pObjYl = 0;
+	}
+
+	_vm->_oldRects.clear();
+	_vm->_newRects.clear();
+	Animation *anim = _vm->_animation->setAnimation(0);
+	_vm->_animation->setAnimTimer(anim);
+	anim = _vm->_animation->setAnimation(1);
+	_vm->_animation->setAnimTimer(anim);
+	_vm->_sound->newMusic(10, 0);
+
+	bool startFl = false;
+	while (!_vm->shouldQuit()) {
+		_vm->_images.clear();
+		_vm->_animation->animate(0);
+		_vm->_animation->animate(1);
+		pan();
+		_vm->_buffer2.copyFrom(_vm->_buffer1);
+		_vm->_newRects.clear();
+		_vm->plotList();
+		_vm->copyBlocks();
+		if (!startFl) {
+			startFl = true;
+			screen.forceFadeIn();
+		}
+
+		events.pollEventsAndWait();
+
+		if (events._leftButton || events._rightButton || events._keypresses.size() > 0) {
+			_vm->_skipStart = true;
+			_vm->_sound->newMusic(10, 1);
+
+			events.debounceLeft();
+			events.zeroKeys();
+			break;
+		}
+
+		if (_xCam > 680) {
+			events._vbCount = 125;
+
+			while (!_vm->shouldQuit() && !events.isKeyMousePressed() && events._vbCount > 0) {
+				events.pollEventsAndWait();
+			}
+			break;
+		}
+	}
+
+	events.showCursor();
+	_vm->_buffer2.copyFrom(*_vm->_screen);
+	_vm->_buffer1.copyFrom(*_vm->_screen);
+
+	_vm->freeCells();
+	_vm->_oldRects.clear();
+	_vm->_newRects.clear();
+	_vm->_numAnimTimers = 0;
+	_vm->_images.clear();
+
+	if (_vm->_conversation == 2) {
+		// Cutscene at end of Chapter 6
+		Resource *spriteData = _vm->_files->loadFile(28, 37);
+		_vm->_objectsTable[28] = new SpriteResource(_vm, spriteData);
+		delete spriteData;
+
+		_vm->_animation->freeAnimationData();
+		animResource = _vm->_files->loadFile(28, 38);
+		_vm->_animation->loadAnimations(animResource);
+		delete animResource;
+	}
+}
+
+/*------------------------------------------------------------------------*/
+
+Plane::Plane(AmazonEngine *vm): PannedScene(vm) {
+	_pCount = 0;
+	_planeCount = 0;
+	_propCount = 0;
+}
+
+
+void Plane::doFlyCell() {
+	SpriteResource *sprites = _vm->_objectsTable[15];
+
+	if (_pCount <= 40) {
+		_vm->_buffer2.plotImage(sprites, 3, Common::Point(70, 74));
+	} else if (_pCount <= 80) {
+		_vm->_buffer2.plotImage(sprites, 6, Common::Point(70, 74));
+	} else if (_pCount <= 120) {
+		_vm->_buffer2.plotImage(sprites, 2, Common::Point(50, 76));
+	} else if (_pCount <= 160) {
+		_vm->_buffer2.plotImage(sprites, 14, Common::Point(63, 78));
+	} else if (_pCount <= 200) {
+		_vm->_buffer2.plotImage(sprites, 5, Common::Point(86, 74));
+	} else if (_pCount <= 240) {
+		_vm->_buffer2.plotImage(sprites, 0, Common::Point(103, 76));
+	} else if (_pCount <= 280) {
+		_vm->_buffer2.plotImage(sprites, 4, Common::Point(119, 77));
+	} else {
+		_vm->_buffer2.plotImage(sprites, 1, Common::Point(111, 77));
+	}
+
+	if (_planeCount == 11 || _planeCount == 12)
+		++_position.y;
+	else if (_planeCount >= 28)
+		--_position.y;
+
+	_vm->_buffer2.plotImage(sprites, 7, _position);
+	_vm->_buffer2.plotImage(sprites, 8 + _propCount, Common::Point(
+		_position.x + 99, _position.y + 10));
+	_vm->_buffer2.plotImage(sprites, 11 + _propCount, Common::Point(
+		_position.x + 104, _position.y + 18));
+
+	if (++_planeCount >= 30)
+		_planeCount = 0;
+	if (++_propCount >= 3)
+		_propCount = 0;
+
+	++_xCount;
+	if (_xCount == 1)
+		++_position.x;
+	else
+		_xCount = 0;
+}
+
+void Plane::doFallCell() {
+	if (_vm->_scaleI <= 20)
+		return;
+
+	SpriteFrame *frame = _vm->_objectsTable[20]->getFrame(_planeCount / 6);
+	Common::Rect r(115, 11, 115 + _vm->_screen->_scaleTable1[frame->w],
+		11 + _vm->_screen->_scaleTable1[frame->h]);
+	_vm->_buffer2.sPlotF(frame, r);
+
+	_vm->_scaleI -= 3;
+	_vm->_scale = _vm->_scaleI;
+	_vm->_screen->setScaleTable(_vm->_scale);
+	++_xCount;
+	if (_xCount == 5)
+		return;
+	_xCount = 0;
+	if (_planeCount == 18)
+		_planeCount = 0;
+	else
+		_planeCount += 6;
+}
+
+void Plane::scrollFly() {
+	_vm->copyBF1BF2();
+	_vm->_newRects.clear();
+	doFlyCell();
+	_vm->copyRects();
+	_vm->copyBF2Vid();
+}
+
+void Plane::scrollFall() {
+	_vm->copyBF1BF2();
+	_vm->_newRects.clear();
+	doFallCell();
+	_vm->copyRects();
+	_vm->copyBF2Vid();
+}
+
+void Plane::mWhileFly() {
+	Screen &screen = *_vm->_screen;
+	Player &player = *_vm->_player;
+	EventsManager &events = *_vm->_events;
+
+	events.hideCursor();
+	screen.clearScreen();
+	screen.setBufferScan();
+	screen.fadeOut();
+	screen._scrollX = 0;
+
+	_vm->_room->buildScreen();
+	_vm->copyBF2Vid();
+	screen.fadeIn();
+	_vm->_oldRects.clear();
+	_vm->_newRects.clear();
+
+	// KEYFLG = 0;
+
+	screen._scrollRow = screen._scrollCol = 0;
+	screen._scrollX = screen._scrollY = 0;
+	player._rawPlayer = Common::Point(0, 0);
+	player._scrollAmount = 1;
+
+	_pCount = 0;
+	_planeCount = 0;
+	_propCount = 0;
+	_xCount = 0;
+	_position = Common::Point(20, 29);
+
+	while (!_vm->shouldQuit() && !events.isKeyMousePressed() &&
+		((screen._scrollCol + screen._vWindowWidth) != _vm->_room->_playFieldWidth)) {
+		events._vbCount = 4;
+		screen._scrollX += player._scrollAmount;
+
+		while (screen._scrollX >= TILE_WIDTH) {
+			screen._scrollX -= TILE_WIDTH;
+			++screen._scrollCol;
+
+			_vm->_buffer1.moveBufferLeft();
+			_vm->_room->buildColumn(screen._scrollCol + screen._vWindowWidth, screen._vWindowBytesWide);
+		}
+
+		scrollFly();
+		++_pCount;
+
+		while (!_vm->shouldQuit() && events._vbCount > 0) {
+			// To be rewritten when NEWTIMER is done
+			events.checkForNextFrameCounter();
+			_vm->_sound->playSound(0);
+
+			events.pollEventsAndWait();
+		}
+	}
+
+	events.showCursor();
+}
+
+void Plane::mWhileFall() {
+	Screen &screen = *_vm->_screen;
+	EventsManager &events = *_vm->_events;
+
+	events.hideCursor();
+	screen.clearScreen();
+	screen.setBufferScan();
+	screen.fadeOut();
+	screen._scrollX = 0;
+
+	_vm->_room->buildScreen();
+	_vm->copyBF2Vid();
+	screen.fadeIn();
+	_vm->_oldRects.clear();
+	_vm->_newRects.clear();
+
+	// KEYFLG = 0;
+
+	screen._scrollRow = screen._scrollCol = 0;
+	screen._scrollX = screen._scrollY = 0;
+	_vm->_player->_scrollAmount = 3;
+	_vm->_scaleI = 255;
+
+	_xCount = 0;
+	_planeCount = 0;
+
+	while (!_vm->shouldQuit() && !events.isKeyMousePressed() &&
+		(screen._scrollCol + screen._vWindowWidth != _vm->_room->_playFieldWidth)) {
+		events._vbCount = 4;
+		screen._scrollX += _vm->_player->_scrollAmount;
+
+		while (screen._scrollX >= TILE_WIDTH) {
+			screen._scrollX -= TILE_WIDTH;
+			++screen._scrollCol;
+
+			_vm->_buffer1.moveBufferLeft();
+			_vm->_room->buildColumn(screen._scrollCol + screen._vWindowWidth, screen._vWindowBytesWide);
+		}
+
+		scrollFall();
+
+		while (!_vm->shouldQuit() && events._vbCount > 0) {
+			events.pollEventsAndWait();
+		}
+	}
+
+	events.showCursor();
+}
+
+/*------------------------------------------------------------------------*/
+
+Jungle::Jungle(AmazonEngine *vm) : PannedScene(vm) {
+	for (int i = 0; i < JUNGLE_SIZE; ++i) {
+		_jCnt[i] = _jungleX[i] = -1;
+	}
+}
+
+void Jungle::jungleMove() {
+	const static int jungleY[3] = { 27, 30, 29 };
+	int count = 1;
+	int frameOffset = 0;
+
+	if (!_vm->_timers[0]._flag) {
+		++_vm->_timers[0]._flag;
+		_vm->_screen->_scrollX += _vm->_player->_scrollAmount;
+
+		for (int i = 0; i < 3; ++i) {
+			int newJCnt = (_jCnt[i] + 1) % 8;
+			_jCnt[i] = newJCnt;
+			_jungleX[i] += 5;
+		}
+
+		frameOffset = 4;
+		count = (_vm->_allenFlag != 1) ? 2 : 3;
+	}
+
+	for (int i = 0; i < count; ++i) {
+		ImageEntry ie;
+		ie._flags = IMGFLAG_UNSCALED;
+		ie._spritesPtr = _vm->_objectsTable[24];
+		ie._frameNumber = _jCnt[i] + frameOffset;
+		ie._position = Common::Point(_jungleX[i], jungleY[i]);
+		ie._offsetY = jungleY[i];
+
+		_vm->_images.addToList(ie);
+		frameOffset += 8;
+	}
+}
+
+void Jungle::initJWalk2() {
+	const int JUNGLE1OBJ[7][4] = {
+		{ 2, 470, 0, 20 },
+		{ 0, 290, 0, 50 },
+		{ 1, 210, 0, 40 },
+		{ 0, 500, 0, 30 },
+		{ 1, 550, 0, 20 },
+		{ 0, 580, 0, 60 },
+		{ 1, 650, 0, 30 }
+	};
+	_vm->_screen->fadeOut();
+	_vm->_events->hideCursor();
+	_vm->_screen->clearScreen();
+	_vm->_buffer2.clearBuffer();
+	_vm->_screen->setBufferScan();
+
+	_vm->_screen->_scrollX = _vm->_screen->_scrollY;
+	_vm->_screen->_scrollCol = _vm->_screen->_scrollRow;
+	_vm->_room->buildScreen();
+	_vm->copyBF2Vid();
+	_vm->_screen->fadeIn();
+	// KEYFL = 0;
+
+	_xCount = 2;
+	_vm->_player->_scrollAmount = 5;
+	_xTrack = -10;
+	_yTrack = _zTrack = 0;
+	_xCam = 480;
+	_yCam = 0;
+	_zCam = 80;
+
+	_vm->_timers[24]._timer = 1;
+	_vm->_timers[24]._initTm = 1;
+	++_vm->_timers[24]._flag;
+
+	_pNumObj = 7;
+	for (int i = 0; i < _pNumObj; i++) {
+		_pan[i]._pObject = _vm->_objectsTable[24];
+		_pan[i]._pImgNum = JUNGLE1OBJ[i][0];
+		_pan[i]._pObjX = JUNGLE1OBJ[i][1];
+		_pan[i]._pObjY = JUNGLE1OBJ[i][2];
+		_pan[i]._pObjZ = JUNGLE1OBJ[i][3];
+		_pan[i]._pObjXl = _pan[i]._pObjYl = 0;
+	}
+
+	_jCnt[0] = 0;
+	_jCnt[1] = 3;
+	_jCnt[2] = 5;
+
+	_jungleX[0] = 50;
+	_jungleX[1] = 16;
+	_jungleX[2] = 93;
+}
+
+void Jungle::mWhileJWalk() {
+	Screen &screen = *_vm->_screen;
+	EventsManager &events = *_vm->_events;
+	Player &player = *_vm->_player;
+
+	static const int JUNGLE_OBJ[7][4] = {
+		{ 2, 77, 0, 40 },
+		{ 0, 290, 0, 50 },
+		{ 1, 210, 0, 70 },
+		{ 0, 50, 0, 30 },
+		{ 1, 70, 0, 20 },
+		{ 0, -280, 0, 60 },
+		{ 1, -150, 0, 30 },
+	};
+
+	screen.fadeOut();
+	events.hideCursor();
+	screen.clearScreen();
+	_vm->_buffer2.clearBuffer();
+	screen.setBufferScan();
+	screen._scrollX = 0;
+
+	// Build the initial jungle scene and fade it in
+	_vm->_room->buildScreen();
+	_vm->copyBF2Vid();
+	screen.fadeIn();
+
+	// Set up the player to walk horizontally
+	player._xFlag = 1;
+	player._yFlag = 0;
+	player._moveTo.x = 160;
+	player._playerMove = true;
+
+	_xCount = 2;
+	_xTrack = 10;
+	_yTrack = _zTrack = 0;
+	_xCam = 480;
+	_yCam = 0;
+	_zCam = 80;
+
+	TimerEntry *te = &_vm->_timers[24];
+	te->_initTm = te->_timer = 1;
+	te->_flag++;
+
+	_pNumObj = 7;
+	for (int i = 0; i < _pNumObj; i++) {
+		_pan[i]._pObject = _vm->_objectsTable[24];
+		_pan[i]._pImgNum = JUNGLE_OBJ[i][0];
+		_pan[i]._pObjX = JUNGLE_OBJ[i][1];
+		_pan[i]._pObjY = JUNGLE_OBJ[i][2];
+		_pan[i]._pObjZ = JUNGLE_OBJ[i][3];
+		_pan[i]._pObjXl = _pan[i]._pObjYl = 0;
+	}
+
+	while (!_vm->shouldQuit() && !events.isKeyMousePressed() && (player._xFlag != 2)) {
+		_vm->_images.clear();
+		events._vbCount = 6;
+
+		_pan[0]._pImgNum = _xCount;
+		if (_xCount == 2)
+			++_xCount;
+		else
+			--_xCount;
+
+		player.checkMove();
+		player.checkScroll();
+		pan();
+		scrollJWalk();
+
+		while (!_vm->shouldQuit() && events._vbCount > 0) {
+			events.pollEventsAndWait();
+		}
+	}
+
+	_vm->_images.clear();
+	events.showCursor();
+}
+
+void Jungle::mWhileJWalk2() {
+	Screen &screen = *_vm->_screen;
+
+	initJWalk2();
+
+	while (!_vm->shouldQuit() && !_vm->_events->isKeyMousePressed() &&
+		(screen._scrollCol + screen._vWindowWidth) != _vm->_room->_playFieldWidth) {
+		_vm->_images.clear();
+		_vm->_events->_vbCount = 6;
+		_pan[0]._pImgNum = _xCount;
+
+		jungleMove();
+		while (screen._scrollX >= TILE_WIDTH) {
+			screen._scrollX -= TILE_WIDTH;
+			++screen._scrollCol;
+			_vm->_buffer1.moveBufferLeft();
+			_vm->_room->buildColumn(screen._scrollCol + screen._vWindowWidth, screen._vWindowBytesWide);
+		}
+
+		if (_xCount == 2)
+			++_xCount;
+		else
+			--_xCount;
+
+		pan();
+		scrollJWalk();
+
+		while (!_vm->shouldQuit() && _vm->_events->_vbCount > 0) {
+			_vm->_events->pollEventsAndWait();
+		}
+	}
+
+	_vm->_events->showCursor();
+}
+
+void Jungle::scrollJWalk() {
+	_vm->copyBF1BF2();
+	_vm->_newRects.clear();
+	_vm->plotList();
+	_vm->copyRects();
+	_vm->copyBF2Vid();
+}
+
+/*------------------------------------------------------------------------*/
+
+Guard::Guard(AmazonEngine *vm): PannedScene(vm) {
+	_vm = nullptr;
+	_guardCel = 0;
+	_gCode1 = _gCode2 = 0;
+	_xMid = _yMid = 0;
+}
+
+void Guard::setVerticalCode() {
+	_gCode1 = 0;
+	_gCode2 = 0;
+	if (_topLeft.x < _vm->_screen->_orgX1)
+		_gCode1 |= 8;
+	else if (_topLeft.x == _vm->_screen->_orgX1) {
+		_gCode1 |= 8;
+		_gCode1 |= 2;
+	}
+	else
+		_gCode1 |= 2;
+
+	if (_bottomRight.x < _vm->_screen->_orgX1)
+		_gCode2 |= 8;
+	else if (_bottomRight.x == _vm->_screen->_orgX1) {
+		_gCode2 |= 8;
+		_gCode2 |= 2;
+	}
+	else
+		_gCode2 |= 2;
+
+	if (_topLeft.y < _vm->_screen->_orgY1)
+		_gCode1 |= 4;
+	else if (_topLeft.y > _vm->_screen->_orgY2)
+		_gCode1 |= 1;
+
+	if (_bottomRight.y < _vm->_screen->_orgY1)
+		_gCode2 |= 4;
+	else if (_bottomRight.y > _vm->_screen->_orgY2)
+		_gCode2 |= 1;
+}
+
+void Guard::setHorizontalCode() {
+	_gCode1 = 0;
+	_gCode2 = 0;
+
+	if (_topLeft.y < _vm->_screen->_orgY1)
+		_gCode1 |= 4;
+	else if (_topLeft.x == _vm->_screen->_orgX1) {
+		_gCode1 |= 4;
+		_gCode1 |= 1;
+	}
+	else
+		_gCode1 |= 1;
+
+	if (_bottomRight.y < _vm->_screen->_orgY1)
+		_gCode2 |= 4;
+	else if (_bottomRight.x == _vm->_screen->_orgX1) {
+		_gCode2 |= 4;
+		_gCode2 |= 1;
+	}
+	else
+		_gCode2 |= 1;
+
+	if (_topLeft.x < _vm->_screen->_orgX1)
+		_gCode1 |= 8;
+	else if (_topLeft.x > _vm->_screen->_orgX2)
+		_gCode1 |= 2;
+
+	if (_bottomRight.x < _vm->_screen->_orgX1)
+		_gCode2 |= 8;
+	else if (_bottomRight.y > _vm->_screen->_orgX2)
+		_gCode2 |= 2;
+}
+
+void Guard::chkVLine() {
+	if (_position.x > _vm->_player->_rawPlayer.x) {
+		_topLeft = _vm->_player->_rawPlayer;
+		_bottomRight = _position;
+	}
+	else {
+		_topLeft = _position;
+		_bottomRight = _vm->_player->_rawPlayer;
+	}
+
+	if (_vm->_screen->_orgY1 > _vm->_screen->_orgY2)
+		SWAP(_vm->_screen->_orgY1, _vm->_screen->_orgY2);
+
+	for (;;) {
+		setVerticalCode();
+		int code = _gCode1 | _gCode2;
+		if (code == 10) {
+			_vm->_guardFind = 0;
+			return;
+		}
+
+		int code2 = _gCode1 & _gCode2;
+		code2 &= 5;
+		if (((code & 10) == 8) || ((code & 10) == 2) || (code2 != 0))
+			return;
+
+		int midX = (_topLeft.x + _bottomRight.x) / 2;
+		int midY = (_topLeft.y + _bottomRight.y) / 2;
+
+		if (midX < _vm->_screen->_orgX1) {
+			if ((midX == _topLeft.x) && (midY == _topLeft.y))
+				return;
+
+			_topLeft.x = midX;
+			_topLeft.y = midY;
+		}
+		else {
+			if ((midX == _bottomRight.x) && (midY == _bottomRight.y))
+				return;
+
+			_bottomRight.x = midX;
+			_bottomRight.y = midY;
+		}
+	}
+}
+
+void Guard::chkHLine() {
+	if (_position.y > _vm->_player->_rawPlayer.y) {
+		_topLeft = _vm->_player->_rawPlayer;
+		_bottomRight = _position;
+	}
+	else {
+		_topLeft = _position;
+		_bottomRight = _vm->_player->_rawPlayer;
+	}
+
+	if (_vm->_screen->_orgX1 > _vm->_screen->_orgX2)
+		SWAP(_vm->_screen->_orgX1, _vm->_screen->_orgX2);
+
+	while (true) {
+		setHorizontalCode();
+		int code = _gCode1 | _gCode2;
+		if (code == 5) {
+			_vm->_guardFind = 0;
+			return;
+		}
+
+		int code2 = _gCode1 & _gCode2;
+		code2 &= 10;
+		if (((code & 5) == 4) || ((code & 5) == 1) || (code2 != 0))
+			return;
+
+		int midX = (_topLeft.x + _bottomRight.x) / 2;
+		int midY = (_topLeft.y + _bottomRight.y) / 2;
+
+		if (midY < _vm->_screen->_orgY1) {
+			if ((midX == _topLeft.x) && (midY == _topLeft.y))
+				return;
+
+			_topLeft.x = midX;
+			_topLeft.y = midY;
+		}
+		else {
+			if ((midX == _bottomRight.x) && (midY == _bottomRight.y))
+				return;
+
+			_bottomRight.x = midX;
+			_bottomRight.y = midY;
+		}
+	}
+}
+
+void Guard::guardSee() {
+	int tmpY = (_vm->_screen->_scrollRow << 4) + _vm->_screen->_scrollY;
+	_vm->_flags[140] = 0;
+	if (tmpY > _position.y)
+		return;
+
+	tmpY += _vm->_screen->_vWindowLinesTall;
+	tmpY -= 11;
+
+	if (tmpY < _position.y)
+		return;
+
+	_vm->_guardFind = 1;
+	_vm->_flags[140] = 1;
+
+	for (uint16 idx = 0; idx < _vm->_room->_plotter._walls.size(); idx++) {
+		_vm->_screen->_orgX1 = _vm->_room->_plotter._walls[idx].left;
+		_vm->_screen->_orgY1 = _vm->_room->_plotter._walls[idx].top;
+		_vm->_screen->_orgX2 = _vm->_room->_plotter._walls[idx].right;
+		_vm->_screen->_orgY2 = _vm->_room->_plotter._walls[idx].bottom;
+		if (_vm->_screen->_orgX1 == _vm->_screen->_orgX2) {
+			chkVLine();
+			if (_vm->_guardFind == 0)
+				return;
+		}
+		else if (_vm->_screen->_orgY1 == _vm->_screen->_orgY2) {
+			chkHLine();
+			if (_vm->_guardFind == 0)
+				return;
+		}
+	}
+}
+
+void Guard::setGuardFrame() {
+	ImageEntry ie;
+	ie._flags = IMGFLAG_UNSCALED;
+
+	if (_vm->_guardLocation == 4)
+		ie._flags |= IMGFLAG_BACKWARDS;
+	ie._spritesPtr = _vm->_objectsTable[37];
+	ie._frameNumber = _guardCel;
+	ie._position = _position;
+	ie._offsetY = 10;
+	_vm->_images.addToList(ie);
+}
+
+void Guard::doGuard() {
+	if (_vm->_timers[8]._flag) {
+		setGuardFrame();
+		return;
+	}
+
+	++_vm->_timers[8]._flag;
+	++_guardCel;
+	int curCel = _guardCel;
+
+	switch (_vm->_guardLocation) {
+	case 1:
+		// Guard walking down
+		if (curCel <= 8 || curCel > 13)
+			_guardCel = curCel = 8;
+
+		_position.y += _vm->_player->_walkOffDown[curCel - 8];
+		guardSee();
+		if (_position.y >= 272) {
+			_position.y = 272;
+			_vm->_guardLocation = 2;
+		}
+		break;
+	case 2:
+		// Guard walking left
+		if (curCel <= 43 || curCel > 48)
+			_guardCel = curCel = 43;
+
+		_position.x -= _vm->_player->_walkOffLeft[curCel - 43];
+		guardSee();
+		if (_position.x <= 56) {
+			_position.x = 56;
+			_vm->_guardLocation = 3;
+		}
+		break;
+	case 3:
+		// Guard walking up
+		if (curCel <= 0 || curCel > 5)
+			_guardCel = curCel = 0;
+
+		_position.y -= _vm->_player->_walkOffUp[curCel];
+		guardSee();
+		if (_position.y <= 89) {
+			_position.y = 89;
+			_vm->_guardLocation = 4;
+			if (_vm->_flags[121] == 1)
+				_vm->_guardLocation = 5;
+		}
+		break;
+	default:
+		// Guard walking right
+		if (curCel <= 43 || curCel > 48)
+			_guardCel = curCel = 43;
+
+		_position.x += _vm->_player->_walkOffRight[curCel - 43];
+		guardSee();
+		if (_position.x >= 127) {
+			_position.x = 127;
+			_vm->_guardLocation = 1;
+		}
+		break;
+	}
+
+	setGuardFrame();
+}
+
+void Guard::setPosition(const Common::Point &pt) {
+	_position = pt;
+}
+
+/*------------------------------------------------------------------------*/
+
+Cast::Cast(AmazonEngine *vm) : PannedScene(vm) {
+}
+
+void Cast::doCast(int param1) {
+	_vm->_screen->setDisplayScan();
+	_vm->_events->hideCursor();
+	_vm->_screen->forceFadeOut();
+	_vm->_screen->_clipHeight = 173;
+	_vm->_screen->clearScreen();
+	_vm->_chapter = 16;
+	_vm->tileScreen();
+	_vm->updateSummary(param1);
+	_vm->_screen->setPanel(3);
+	_vm->_chapter = 14;
+
+	Resource *spriteData = _vm->_files->loadFile(91, 0);
+	_vm->_objectsTable[0] = new SpriteResource(_vm, spriteData);
+	delete spriteData;
+	spriteData = _vm->_files->loadFile(91, 1);
+	_vm->_objectsTable[1] = new SpriteResource(_vm, spriteData);
+	delete spriteData;
+
+	_vm->_files->_setPaletteFlag = false;
+	_vm->_files->loadScreen(58, 1);
+	_vm->_buffer2.copyFrom(*_vm->_screen);
+	_vm->_buffer1.copyFrom(*_vm->_screen);
+
+	_xTrack = 0;
+	_yTrack = -6;
+	_zTrack = 0;
+	_xCam = _yCam = 0;
+	_zCam = 60;
+
+	_vm->_timers[24]._timer = 1;
+	_vm->_timers[24]._initTm = 1;
+	++_vm->_timers[24]._flag;
+
+	_pNumObj = 26;
+	for (int i = 0; i < _pNumObj; i++) {
+		_pan[i]._pObject = _vm->_objectsTable[0];
+		_pan[i]._pImgNum = CAST_END_OBJ[i][0];
+		_pan[i]._pObjX = CAST_END_OBJ[i][1];
+		_pan[i]._pObjY = CAST_END_OBJ[i][2];
+		_pan[i]._pObjZ = CAST_END_OBJ[i][3];
+		_pan[i]._pObjXl = _pan[i]._pObjYl = 0;
+	}
+
+	_pNumObj = 4;
+	for (int i = 0; i < _pNumObj; i++) {
+		_pan[26 + i]._pObject = _vm->_objectsTable[1];
+		_pan[26 + i]._pImgNum = CAST_END_OBJ1[i][0];
+		_pan[26 + i]._pObjX = CAST_END_OBJ1[i][1];
+		_pan[26 + i]._pObjY = CAST_END_OBJ1[i][2];
+		_pan[26 + i]._pObjZ = CAST_END_OBJ1[i][3];
+		_pan[26 + i]._pObjXl = _pan[26 + i]._pObjYl = 0;
+	}
+
+	_vm->_oldRects.clear();
+	_vm->_newRects.clear();
+	_vm->_numAnimTimers = 0;
+
+	_vm->_sound->newMusic(58, 0);
+	_vm->_screen->forceFadeIn();
+
+	while (!_vm->shouldQuit()) {
+		_vm->_images.clear();
+		pan();
+		_vm->_buffer2.copyFrom(_vm->_buffer1);
+		_vm->_newRects.clear();
+		_vm->plotList();
+		_vm->copyBlocks();
+
+		_vm->_events->pollEvents();
+		if (_vm->_events->isKeyMousePressed())
+			break;
+
+		if (_yCam < -7550) {
+			_vm->_events->_vbCount = 50;
+
+			while (!_vm->shouldQuit() && !_vm->_events->isKeyMousePressed() && _vm->_events->_vbCount > 0) {
+				_vm->_events->pollEventsAndWait();
+			}
+
+			while (!_vm->shouldQuit() && !_vm->_sound->checkMidiDone())
+				_vm->_events->pollEventsAndWait();
+
+			break;
+		}
+	}
+
+	_vm->_sound->newMusic(58, 1);
+	_vm->_events->showCursor();
+
+	_vm->freeCells();
+	_vm->_oldRects.clear();
+	_vm->_newRects.clear();
+	_vm->_numAnimTimers = 0;
+	_vm->_images.clear();
+	_vm->_screen->forceFadeOut();
+
+	_vm->quitGame();
+	_vm->_events->pollEvents();
+}
+
+/*------------------------------------------------------------------------*/
+
+River::River(AmazonEngine *vm): PannedScene(vm) {
+	_vm = nullptr;
+	_CHICKENOUTFLG = false;
+	_rScrollRow = 0;
+	_rScrollCol = 0;
+	_rScrollX = 0;
+	_rScrollY = 0;
+	_rOldRectCount = 0;
+	_rNewRectCount = 0;
+	_rKeyFlag = 0;
+	_mapOffset = 0;
+	_screenVirtX = 0;
+}
+
+void River::setRiverPan() {
+	int delta = (_vm->_screen->_scrollCol * 16) + _vm->_screen->_scrollX;
+
+	_xTrack = 9;
+	_yTrack = _zTrack = 0;
+	_xCam = 160;
+	_yCam = 0;
+	_zCam = 80;
+
+	_vm->_timers[24]._timer = 1;
+	_vm->_timers[24]._initTm = 1;
+	++_vm->_timers[24]._flag;
+
+	_pNumObj = 23;
+	for (int i = 0; i < _pNumObj; i++) {
+		_pan[i]._pObject = _vm->_objectsTable[45];
+		_pan[i]._pImgNum = RIVER1OBJ[i][0];
+		_pan[i]._pObjX = RIVER1OBJ[i][1] + delta;
+		_pan[i]._pObjY = RIVER1OBJ[i][2];
+		_pan[i]._pObjZ = RIVER1OBJ[i][3];
+		_pan[i]._pObjXl = _pan[i]._pObjYl = 0;
+	}
+}
+
+void River::initRiver() {
+	static const int RIVERVXTBL[3] = { 6719, 7039, 8319 };
+
+	_vm->_events->centerMousePos();
+	_vm->_events->restrictMouse();
+	_vm->_screen->setDisplayScan();
+	_vm->_screen->clearScreen();
+	_vm->_screen->savePalette();
+	_vm->_screen->forceFadeOut();
+
+	_vm->_files->_setPaletteFlag = false;
+	_vm->_files->loadScreen(95, 4);
+	_vm->_buffer2.copyFrom(*_vm->_screen);
+
+	_vm->_screen->restorePalette();
+	_vm->_screen->setBufferScan();
+	_vm->_destIn = &_vm->_buffer2;
+	_vm->_room->roomMenu();
+
+	if (_vm->_saveRiver) {
+		// Restoring a savegame, so set properties from saved fields
+		_vm->_screen->_scrollRow = _rScrollRow;
+		_vm->_screen->_scrollCol = _rScrollCol;
+		_vm->_screen->_scrollX = _rScrollX;
+		_vm->_screen->_scrollY = _rScrollY;
+	} else {
+		// Set initial scene state
+		_vm->_screen->_scrollRow = 0;
+		_vm->_screen->_scrollCol = 140;
+		_vm->_screen->_scrollX = 0;
+		_vm->_screen->_scrollY = 0;
+	}
+
+	_vm->_room->buildScreen();
+	_vm->copyBF2Vid();
+	_vm->_screen->forceFadeIn();
+
+	if (_vm->_saveRiver) {
+		// Restore draw rects from savegame
+		_vm->_oldRects.resize(_rOldRectCount);
+		_vm->_newRects.resize(_rNewRectCount);
+		// KEYFLG = _vm->_rKeyFlag
+	} else {
+		// Reset draw rects
+		_vm->_oldRects.clear();
+		_vm->_newRects.clear();
+		// KEYFLG = 0
+	}
+
+	_vm->_player->_scrollAmount = 2;
+	setRiverPan();
+	_vm->_timers[3]._timer = 1;
+	_vm->_timers[3]._initTm = 1;
+	++_vm->_timers[3]._flag;
+
+	_canoeFrame = 0;
+	_mapPtr = (const byte *)MAPTBL[_vm->_riverFlag] + 1;
+	if (_vm->_saveRiver) {
+		_mapPtr--;
+		_mapPtr += _mapOffset;
+	} else {
+		_screenVertX = RIVERVXTBL[_vm->_riverFlag] - 320;
+		_canoeLane = 3;
+		_hitCount = 0;
+		_hitSafe = 0;
+		_canoeYPos = 71;
+	}
+
+	_riverIndex = _vm->_riverFlag;
+	_topList = RIVEROBJECTTBL[_riverIndex];
+	updateObstacles();
+	riverSetPhysX();
+	_canoeDir = 0;
+	_vm->_deathFlag = 0;
+	_vm->_deathCount = 0;
+
+	_vm->_timers[11]._timer = 1200;
+	_vm->_timers[11]._initTm = 1200;
+	++_vm->_timers[11]._flag;
+	_vm->_timers[12]._timer = 1500;
+	_vm->_timers[12]._initTm = 1500;
+	++_vm->_timers[12]._flag;
+
+	_vm->_maxHits = 2 - _vm->_riverFlag;
+	_vm->_saveRiver = false;
+}
+
+void River::resetPositions() {
+	riverSetPhysX();
+	int val = (_vm->_screen->_scrollCol + 1 - _vm->_oldScrollCol) * 16;
+	if (val > 256) {
+		val &= 0x7F;
+		val |= 0x80;
+	}
+
+	for (int i = 0; i < _pNumObj; i++)
+		_pan[i]._pObjX += val;
+}
+
+void River::checkRiverPan() {
+	int val = (_vm->_screen->_scrollCol + 20) * 16;
+
+	for (int i = 0; i < _pNumObj; i++) {
+		if (_pan[i]._pObjX < val)
+			return;
+	}
+
+	setRiverPan();
+}
+
+bool River::riverJumpTest() {
+	if (_vm->_screen->_scrollCol == 120 || _vm->_screen->_scrollCol == 60 || _vm->_screen->_scrollCol == 0) {
+		int val = _mapPtr[0];
+		++_mapPtr;
+		if (val == 0xFF)
+			return true;
+		_vm->_oldScrollCol = _vm->_screen->_scrollCol;
+
+		if (val == 0) {
+			_vm->_screen->_scrollCol = 139;
+			_vm->_screen->_scrollX = 14;
+			_vm->_room->buildScreen();
+			resetPositions();
+			return false;
+		}
+	} else if (_vm->_screen->_scrollCol == 105) {
+		int val1 = _mapPtr[1];
+		int val2 = _mapPtr[2];
+		_mapPtr += 3;
+		if (_canoeLane < 3) {
+			if (val1 != 0) {
+				_vm->_deathFlag = true;
+				_vm->_deathCount = 300;
+				_vm->_deathType = val2;
+			}
+		} else {
+			if (val1 != 1) {
+				_vm->_deathFlag = true;
+				_vm->_deathCount = 300;
+				_vm->_deathType = val2;
+			}
+			_vm->_oldScrollCol = _vm->_screen->_scrollCol;
+			_vm->_screen->_scrollCol = 44;
+			_vm->_screen->_scrollX = 14;
+			_vm->_room->buildScreen();
+			resetPositions();
+			return false;
+		}
+	}
+
+	_vm->_screen->_scrollX = 14;
+	--_vm->_screen->_scrollCol;
+	_vm->_buffer1.moveBufferRight();
+	_vm->_room->buildColumn(_vm->_screen->_scrollCol, 0);
+	checkRiverPan();
+	return false;
+}
+
+void River::riverSound() {
+	if (_vm->_timers[11]._flag == 0) {
+		++_vm->_timers[11]._flag;
+		_vm->_sound->playSound(2);
+	}
+
+	if (_vm->_timers[12]._flag == 0) {
+		++_vm->_timers[12]._flag;
+		_vm->_sound->playSound(3);
+	}
+
+	if ((_xCam >= 1300) && (_xCam <= 1320))
+		_vm->_sound->playSound(1);
+}
+
+void River::moveCanoe() {
+	Screen &screen = *_vm->_screen;
+	EventsManager &events = *_vm->_events;
+	Common::Point pt = events.calcRawMouse();
+
+	// Do an event polling
+	_vm->_canSaveLoad = true;
+	events.pollEvents();
+	_vm->_canSaveLoad = false;
+	if (_vm->_room->_function == FN_CLEAR1)
+		return;
+
+	if (_canoeDir) {
+		// Canoe movement in progress
+		moveCanoe2();
+	} else {
+		if (events._leftButton && pt.y >= 140) {
+			if (pt.x < RMOUSE[8][0]) {
+				// Disk icon wasn't clicked
+				_vm->_scripts->printString(BAR_MESSAGE);
+			} else {
+				// Clicked on the Disc icon
+				_vm->_saveRiver = true;
+				_rScrollRow = screen._scrollRow;
+				_rScrollCol = screen._scrollCol;
+				_rScrollX = screen._scrollX;
+				_rScrollY = screen._scrollY;
+				_mapOffset = _mapPtr - MAPTBL[_vm->_riverFlag];
+
+				// Show the ScummVM menu
+				_vm->_room->handleCommand(9);
+
+				if (_vm->_room->_function != FN_CLEAR1) {
+					_vm->_saveRiver = false;
+					_vm->_room->buildScreen();
+					_vm->copyBF2Vid();
+				}
+			}
+		}
+		else if ((events._leftButton && pt.y <= _canoeYPos) ||
+			(!events._leftButton && _vm->_player->_move == UP)) {
+			// Move canoe up
+			if (_canoeLane > 0) {
+				_canoeDir = -1;
+				_canoeMoveCount = 0;
+
+				moveCanoe2();
+			}
+		}
+		else if (events._leftButton || _vm->_player->_move == DOWN) {
+			// Move canoe down
+			if (_canoeLane < 7) {
+				_canoeDir = 1;
+				_canoeMoveCount = 0;
+
+				moveCanoe2();
+			}
+		}
+	}
+}
+
+void River::moveCanoe2() {
+	_canoeYPos += _canoeDir;
+
+	if (++_canoeMoveCount == 5) {
+		_canoeLane += _canoeDir;
+		_canoeDir = 0;
+	}
+}
+
+void River::updateObstacles() {
+	RiverStruct *cur;
+	for (cur = _topList; cur < RIVEROBJECTTBL[_riverIndex + 1]; ++cur) {
+		int val = cur->_field1 + cur->_field3 - 1;
+		if (val < _screenVertX)
+			break;
+
+		if (cur->_field3 < (_screenVirtX + 319)) {
+			_topList = cur;
+			_botList = cur;
+
+			while (cur < RIVEROBJECTTBL[_riverIndex + 1]) {
+				++cur;
+				val = cur->_field1 + cur->_field3 - 1;
+				if (val < _screenVertX || (cur->_field3 >= (_screenVirtX + 319)))
+					break;
+
+				_botList = cur;
+			}
+
+			return;
+		}
+	}
+
+	cur = _topList;
+	cur--;
+	_botList = cur;
+}
+
+void River::riverSetPhysX() {
+	int val = (_vm->_screen->_scrollCol * 16) + _vm->_screen->_scrollX;
+	RiverStruct *cur = _topList;
+	while (cur <= _botList) {
+		cur[0]._field5 = val - (_screenVertX - cur[0]._field3);
+		++cur;
+	}
+}
+
+bool River::checkRiverCollide() {
+	if (_hitSafe)
+		return false;
+
+	_canoeVXPos = _screenVertX + 170;
+
+	for (RiverStruct *si = _topList; si <= _botList; ++si) {
+		if (si[0]._lane < _canoeLane)
+			continue;
+
+		if ((si[0]._lane == _canoeLane) || (si[0]._lane == _canoeLane + 1)) {
+			if (si[0]._field1 + si[0]._field3 - 1 >= _canoeVXPos) {
+				if (_canoeVXPos + 124 >= si[0]._field3) {
+					_vm->_sound->playSound(4);
+					return true;
+				}
+			}
+		}
+	}
+	return false;
+}
+
+void River::plotRiver() {
+	if (_vm->_timers[3]._flag == 0) {
+		++_vm->_timers[3]._flag;
+		if (_canoeFrame == 12)
+			_canoeFrame = 0;
+		else
+			++_canoeFrame;
+	}
+
+	ImageEntry ie;
+	ie._flags = IMGFLAG_UNSCALED;
+	ie._spritesPtr = _vm->_objectsTable[45];
+	ie._frameNumber = _canoeFrame;
+	ie._position.x = (_vm->_screen->_scrollCol * 16) + _vm->_screen->_scrollX + 160;
+	ie._position.y = _canoeYPos - 41;
+	ie._offsetY = 41;
+	_vm->_images.addToList(ie);
+
+	RiverStruct *cur = _topList;
+	while (cur <= _botList) {
+		if (cur[0]._id != -1) {
+			ie._flags = IMGFLAG_UNSCALED;
+			ie._spritesPtr = _vm->_objectsTable[45];
+			ie._frameNumber = 0;
+			ie._position.x = cur[0]._field5;
+			int val = (cur[0]._lane * 5) + 56;
+			ie._position.y = val - cur[0]._field8;
+			ie._offsetY = cur[0]._field8;
+			_vm->_images.addToList(ie);
+		}
+		++cur;
+	}
+}
+
+void River::mWhileDownRiver() {
+	_vm->_events->hideCursor();
+	_vm->_screen->setDisplayScan();
+	_vm->_screen->clearScreen();
+	_vm->_screen->savePalette();
+
+	_vm->_files->loadScreen(95, 4);
+	_vm->_buffer2.copyFrom(*_vm->_screen);
+	_vm->_screen->restorePalette();
+	_vm->_screen->setPalette();
+	_vm->_screen->setBufferScan();
+	_vm->_screen->_scrollX = 0;
+	_vm->_room->buildScreen();
+	_vm->copyBF2Vid();
+
+	_vm->_player->_scrollAmount = 2;
+	_vm->_destIn = &_vm->_buffer2;
+	_xTrack = -7;
+	_yTrack = _zTrack = 0;
+	_xCam = _yCam = 0;
+	_zCam = 80;
+
+	_vm->_timers[24]._timer = 1;
+	_vm->_timers[24]._initTm = 1;
+	++_vm->_timers[24]._flag;
+
+	_pNumObj = 14;
+	for (int i = 0; i <_pNumObj; i++) {
+		_pan[i]._pObject = _vm->_objectsTable[33];
+		_pan[i]._pImgNum = DOWNRIVEROBJ[i][0];
+		_pan[i]._pObjX = DOWNRIVEROBJ[i][1];
+		_pan[i]._pObjY = DOWNRIVEROBJ[i][2];
+		_pan[i]._pObjZ = DOWNRIVEROBJ[i][3];
+		_pan[i]._pObjXl = _pan[i]._pObjYl = 0;
+	}
+
+	_vm->_timers[3]._timer = 200;
+	_vm->_timers[3]._initTm = 200;
+	++_vm->_timers[3]._flag;
+	_vm->_timers[4]._timer = 350;
+	_vm->_timers[4]._initTm = 350;
+	++_vm->_timers[4]._flag;
+
+	while (!_vm->shouldQuit() && !_vm->_events->isKeyMousePressed() &&
+		(_vm->_screen->_scrollCol + _vm->_screen->_vWindowWidth != _vm->_room->_playFieldWidth)) {
+		_vm->_images.clear();
+		_vm->_events->_vbCount = 6;
+
+		_vm->_screen->_scrollX += _vm->_player->_scrollAmount;
+		while (_vm->_screen->_scrollX >= TILE_WIDTH) {
+			_vm->_screen->_scrollX -= TILE_WIDTH;
+			++_vm->_screen->_scrollCol;
+			_vm->_buffer1.moveBufferLeft();
+			_vm->_room->buildColumn(_vm->_screen->_scrollCol + _vm->_screen->_vWindowWidth, _vm->_screen->_vWindowBytesWide);
+		}
+
+		pan();
+		scrollRiver();
+
+		if (!_vm->_timers[3]._flag) {
+			++_vm->_timers[3]._flag;
+			_vm->_sound->playSound(1);
+		}
+		else if (!_vm->_timers[4]._flag) {
+			++_vm->_timers[4]._flag;
+			_vm->_sound->playSound(0);
+		}
+
+		while (!_vm->shouldQuit() && _vm->_events->_vbCount > 0) {
+			_vm->_events->pollEventsAndWait();
+		}
+	}
+
+	_vm->_events->showCursor();
+}
+
+void River::scrollRiver() {
+	_vm->copyBF1BF2();
+	_vm->_newRects.clear();
+	_vm->_buffer2.plotImage(_vm->_objectsTable[33], 0, Common::Point(66, 30));
+	_vm->plotList();
+	_vm->copyRects();
+	_vm->copyBF2Vid();
+}
+
+void River::scrollRiver1() {
+	_vm->copyBF1BF2();
+	_vm->_newRects.clear();
+	plotRiver();
+	_vm->plotList();
+	_vm->copyRects();
+	_vm->copyBF2Vid();
+}
+
+void River::river() {
+	static const int RIVERDEATH[5] = { 22, 23, 24, 25, 26 };
+
+	initRiver();
+	_vm->_events->showCursor();
+
+	while (!_vm->shouldQuit()) {
+		_vm->_events->_vbCount = 4;
+
+		//		int bx = _vm->_player->_scrollAmount - _screenVertX;
+		if (_vm->_screen->_scrollX == 0) {
+			_vm->_sound->midiRepeat();
+			if (riverJumpTest()) {
+				_CHICKENOUTFLG = false;
+				return;
+			}
+		}
+		else {
+			_vm->_screen->_scrollX -= _vm->_player->_scrollAmount;
+		}
+
+		if (_CHICKENOUTFLG) {
+			_CHICKENOUTFLG = false;
+			return;
+		}
+
+		_vm->_images.clear();
+		_vm->_animation->animate(0);
+
+		riverSound();
+		pan();
+		moveCanoe();
+
+		if (_vm->_room->_function != FN_CLEAR1) {
+			updateObstacles();
+			riverSetPhysX();
+			bool checkCollide = checkRiverCollide();
+			if (_hitSafe != 0)
+				_hitSafe -= 2;
+
+			if (checkCollide) {
+				_vm->dead(RIVERDEATH[0]);
+				return;
+			}
+
+			if (_vm->_deathFlag) {
+				_vm->_deathCount--;
+				if (_vm->_deathCount == 0) {
+					_vm->dead(RIVERDEATH[_vm->_deathType]);
+					return;
+				}
+			}
+
+			// Scroll the river
+			scrollRiver1();
+
+			// Allow time for new scrolled river position to be shown
+			_vm->_canSaveLoad = true;
+			while (!_vm->shouldQuit() && _vm->_room->_function == FN_NONE &&
+				_vm->_events->_vbCount > 0) {
+				_vm->_events->pollEventsAndWait();
+			}
+			_vm->_canSaveLoad = false;
+		}
+
+		if (_vm->_room->_function == FN_CLEAR1) {
+			_vm->_scripts->_endFlag = true;
+			_vm->_scripts->_returnCode = 0;
+			_CHICKENOUTFLG = false;
+			break;
+		}
+	}
+}
+void River::synchronize(Common::Serializer &s) {
+	s.syncAsSint16LE(_canoeLane);
+	s.syncAsSint16LE(_canoeYPos);
+	s.syncAsSint16LE(_hitCount);
+	s.syncAsSint16LE(_riverIndex);
+	s.syncAsSint16LE(_hitSafe);
+	s.syncAsUint16LE(_rScrollRow);
+	s.syncAsUint16LE(_rScrollCol);
+	s.syncAsSint16LE(_rScrollX);
+	s.syncAsSint16LE(_rScrollY);
+	s.syncAsUint16LE(_rOldRectCount);
+	s.syncAsUint16LE(_rNewRectCount);
+	s.syncAsUint16LE(_rKeyFlag);
+	s.syncAsUint16LE(_mapOffset);
+	s.syncAsUint16LE(_screenVirtX);
+	warning("TODO: 	s.syncAsSint16LE(_topList);");
+	warning("TODO: 	s.syncAsSint16LE(_botList);");
+}
+
+/*------------------------------------------------------------------------*/
+
+Ant::Ant(AmazonEngine *vm) : AmazonManager(vm) {
+	_antDirection = NONE;
+	_pitDirection = NONE;
+	_antCel = 0;
+	_torchCel = 0;
+	_pitCel = 0;
+	_stabCel = 0;
+	_antPos = Common::Point(0, 0);
+	_antDieFl = _antEatFl = false;
+	_stabFl = false;
+	_pitPos = Common::Point(0, 0);
+}
+
+void Ant::plotTorchSpear(int indx, const int *&buf) {
+	int idx = indx;
+
+	ImageEntry ie;
+	ie._flags = IMGFLAG_UNSCALED;
+	ie._spritesPtr = _vm->_objectsTable[62];
+	ie._frameNumber = buf[(idx / 2)];
+	ie._position = Common::Point(_pitPos.x + buf[(idx / 2) + 1], _pitPos.y + buf[(idx / 2) + 2]);
+	ie._offsetY = 255;
+	_vm->_images.addToList(ie);
+}
+
+void Ant::plotPit(int indx, const int *&buf) {
+	int idx = indx;
+	ImageEntry ie;
+	ie._flags = IMGFLAG_UNSCALED;
+	ie._spritesPtr = _vm->_objectsTable[62];
+	ie._frameNumber = buf[(idx / 2)];
+	ie._position = Common::Point(_pitPos.x, _pitPos.y);
+	ie._offsetY = _pitPos.y;
+	_vm->_images.addToList(ie);
+
+	_vm->_player->_rawPlayer = _pitPos;
+	if (_vm->_inventory->_inv[76]._value == 1) {
+		idx = _torchCel;
+		buf = Amazon::TORCH;
+		_vm->_timers[14]._flag = 1;
+		idx += 6;
+		if (buf[idx / 2] == -1)
+			idx = 0;
+		_torchCel = idx;
+		plotTorchSpear(idx, buf);
+	}
+	else if (!_stabFl && (_vm->_inventory->_inv[78]._value == 1)) {
+		idx = 0;
+		buf = Amazon::SPEAR;
+		plotTorchSpear(idx, buf);
+	}
+}
+
+int Ant::antHandleRight(int indx, const int *&buf) {
+	int retval = indx;
+	if (_pitDirection == NONE) {
+		_pitDirection = UP;
+		_pitPos.y = 127;
+	}
+	retval = _pitCel;
+	buf = Amazon::PITWALK;
+	if (_pitPos.x < 230) {
+		if (retval == 0) {
+			retval = 48;
+			_pitPos.y = 127;
+		}
+		retval -= 6;
+		_pitPos.x -= buf[(retval / 2) + 1];
+		_pitPos.y -= buf[(retval / 2) + 2];
+		_pitCel = retval;
+	}
+	return retval;
+}
+
+int Ant::antHandleLeft(int indx, const int *&buf) {
+	int retval = indx;
+	if (_pitDirection == UP) {
+		_pitDirection = NONE;
+		_pitPos.y = 127;
+	}
+	retval = _pitCel;
+	buf = Amazon::PITWALK;
+	retval += 6;
+	if (buf[retval / 2] == -1) {
+		retval = 0;
+		_pitPos.y = 127;
+	}
+	_pitPos.x += buf[(retval / 2) + 1];
+	_pitPos.y += buf[(retval / 2) + 2];
+	_pitCel = retval;
+
+	return retval;
+}
+
+int Ant::antHandleStab(int indx, const int *&buf) {
+	int retval = indx;
+	if (_vm->_inventory->_inv[78]._value != 1) {
+		if (_stabFl) {
+			buf = Amazon::PITSTAB;
+			retval = _stabCel;
+			if (_vm->_timers[13]._flag == 0) {
+				_vm->_timers[13]._flag = 1;
+				retval += 6;
+				if (Amazon::PITSTAB[retval] == -1) {
+					_stabFl = false;
+					_pitCel = 0;
+					_pitPos.y = 127;
+					retval = 0;
+					buf = Amazon::PITWALK;
+				}
+				else {
+					_pitPos.x += buf[(retval / 2) + 1];
+					_pitPos.y += buf[(retval / 2) + 2];
+					_pitCel = retval;
+				}
+			}
+		}
+		else {
+			_stabFl = true;
+			_pitCel = 0;
+			retval = 0;
+			_stabCel = 0;
+			int dist = _pitPos.x - _antPos.x;
+			if (_antEatFl && !_antDieFl && (dist <= 80)) {
+				_antDieFl = true;
+				_antCel = 0;
+				_antPos.y = 123;
+				_vm->_sound->playSound(1);
+			}
+		}
+	}
+	return retval;
+}
+
+void Ant::doAnt() {
+	_antDirection = NONE;
+	if (_vm->_aniFlag != 1) {
+		_vm->_aniFlag = 1;
+		_antCel = 0;
+		_torchCel = 0;
+		_pitCel = 0;
+
+		_vm->_timers[15]._timer = 16;
+		_vm->_timers[15]._initTm = 16;
+		_vm->_timers[15]._flag = 1;
+
+		_vm->_timers[13]._timer = 5;
+		_vm->_timers[13]._initTm = 5;
+		_vm->_timers[13]._flag = 1;
+
+		_vm->_timers[14]._timer = 10;
+		_vm->_timers[14]._initTm = 10;
+		_vm->_timers[14]._flag = 1;
+
+		_antPos = Common::Point(-40, 123);
+		_antDieFl = _antEatFl = false;
+		_stabFl = false;
+		_pitPos = Common::Point(_vm->_player->_rawPlayer.x, 127);
+	}
+
+	const int *buf = nullptr;
+	if (_antDieFl) {
+		buf = Amazon::ANTDIE;
+	}
+	else if (_antEatFl) {
+		buf = Amazon::ANTEAT;
+	}
+	else if (_antPos.x > 120 && _vm->_flags[198] == 1) {
+		_antEatFl = true;
+		_vm->_flags[235] = 1;
+		_antCel = 0;
+		buf = Amazon::ANTEAT;
+	}
+	else {
+		buf = Amazon::ANTWALK;
+		if (_vm->_inventory->_inv[76]._value == 1)
+			_antDirection = UP;
+	}
+
+	int idx = _antCel;
+	if (_vm->_timers[15]._flag == 0) {
+		_vm->_timers[15]._flag = 1;
+		if (_antDirection == UP) {
+			if (_antPos.x > 10) {
+				if (idx == 0)
+					idx = 36;
+				else
+					idx -= 6;
+
+				_antPos = Common::Point(buf[(idx / 2) + 1], buf[(idx / 2) + 2]);
+				_antCel = idx;
+			}
+		}
+		else {
+			idx += 6;
+			if (buf[(idx / 2)] != -1) {
+				_antPos = Common::Point(buf[(idx / 2) + 1], buf[(idx / 2) + 2]);
+				_antCel = idx;
+			}
+			else if (!_antDieFl) {
+				idx = 0;
+				_antPos = Common::Point(buf[(idx / 2) + 1], buf[(idx / 2) + 2]);
+				_antCel = idx;
+			}
+			else {
+				idx -= 6;
+				if (_vm->_flags[200] == 0)
+					_vm->_flags[200] = 1;
+			}
+		}
+	}
+
+	ImageEntry ie;
+	ie._flags = IMGFLAG_UNSCALED;
+	ie._spritesPtr = _vm->_objectsTable[61];
+	ie._frameNumber = buf[(idx / 2)];
+	ie._position = Common::Point(_antPos.x, _antPos.y);
+	ie._offsetY = _antPos.y - 70;
+	_vm->_images.addToList(ie);
+	_antCel = idx;
+
+	if (_vm->_flags[196] != 1) {
+		idx = _pitCel;
+		if (_stabFl == 1) {
+			idx = antHandleStab(idx, buf);
+		}
+		else {
+			buf = Amazon::PITWALK;
+			if (_vm->_timers[13]._flag == 0) {
+				_vm->_timers[13]._flag = 1;
+				_vm->_events->pollEvents();
+				if (_vm->_events->_leftButton) {
+					Common::Point pt = _vm->_events->calcRawMouse();
+					if (pt.x < _pitPos.x)
+						idx = antHandleLeft(idx, buf);
+					else if (pt.x > _pitPos.x)
+						idx = antHandleRight(idx, buf);
+				}
+				else {
+					buf = Amazon::PITWALK;
+					if (_vm->_player->_playerDirection == UP)
+						idx = antHandleStab(idx, buf);
+					else if (_vm->_player->_playerDirection == LEFT)
+						idx = antHandleLeft(idx, buf);
+					else if (_vm->_player->_playerDirection == RIGHT)
+						idx = antHandleRight(idx, buf);
+				}
+			}
+		}
+		plotPit(idx, buf);
+	}
+
+	if (!_antDieFl) {
+		int dist = _pitPos.x - _antPos.x;
+		if ((_antEatFl && (dist <= 45)) || (!_antEatFl && (dist <= 80))) {
+			_vm->_flags[199] = 1;
+			_vm->_aniFlag = 0;
+		}
+	}
+}
+
+} // End of namespace Amazon
+
+} // End of namespace Access
diff --git a/engines/access/amazon/amazon_logic.h b/engines/access/amazon/amazon_logic.h
new file mode 100644
index 0000000..4d5e274
--- /dev/null
+++ b/engines/access/amazon/amazon_logic.h
@@ -0,0 +1,228 @@
+/* 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 ACCESS_AMAZON_LOGIC_H
+#define ACCESS_AMAZON_LOGIC_H
+
+#include "common/scummsys.h"
+#include "access/scripts.h"
+#include "access/asurface.h"
+
+namespace Access {
+
+namespace Amazon {
+
+class AmazonEngine;
+
+#define PAN_SIZE 32
+
+class AmazonManager {
+protected:
+	AmazonEngine *_vm;
+public:
+	AmazonManager(AmazonEngine *vm) : _vm(vm) {}
+};
+
+class PannedScene: public AmazonManager {
+	struct PanEntry {
+		SpriteResource *_pObject;
+		int _pImgNum;
+		int _pObjX;
+		int _pObjY;
+		int _pObjZ;
+		int _pObjXl;
+		int _pObjYl;
+	};
+protected:
+	int _xCount;
+	int _xTrack;
+	int _yTrack;
+	int _zTrack;
+	int _xCam;
+	int _yCam;
+	int _zCam;
+	int _pNumObj;
+	int _screenVertX;
+
+	PanEntry _pan[PAN_SIZE];
+public:
+	PannedScene(AmazonEngine *vm);
+
+	void pan();
+};
+
+class Opening: public PannedScene {
+public:
+	Opening(AmazonEngine *vm);
+
+	void mWhileDoOpen();
+};
+
+class Plane: public PannedScene {
+public:
+	int _pCount;
+	Common::Point _position;
+	int _planeCount;
+	int _propCount;
+
+	void doFlyCell();
+	void doFallCell();
+	void scrollFly();
+	void scrollFall();
+	void mWhileFly();
+	void mWhileFall();
+public:
+	Plane(AmazonEngine *vm);
+};
+
+#define JUNGLE_SIZE 3
+class Jungle: public PannedScene {
+private:
+	void initJWalk2();
+	void jungleMove();
+	void scrollJWalk();
+
+	int _jCnt[JUNGLE_SIZE];
+	int _jungleX[JUNGLE_SIZE];
+public:
+	Jungle(AmazonEngine *vm);
+
+	void mWhileJWalk();
+	void mWhileJWalk2();
+};
+
+class Guard : public PannedScene {
+private:
+	int _guardCel;
+	Common::Point _position;
+	int _gCode1;
+	int _gCode2;
+	Common::Point _topLeft;
+	Common::Point _bottomRight;
+	int _xMid, _yMid;
+
+	void chkVLine();
+	void chkHLine();
+	void setVerticalCode();
+	void setHorizontalCode();
+	void guardSee();
+	void setGuardFrame();
+public:
+	Guard(AmazonEngine *vm);
+
+	void doGuard();
+
+	void setPosition(const Common::Point &pt);
+};
+
+class Cast : public PannedScene {
+public:
+	Cast(AmazonEngine *vm);
+
+	void doCast(int param1);
+};
+
+class River: public PannedScene {
+private:
+	bool _CHICKENOUTFLG;
+	const byte *_mapPtr;
+	int _canoeVXPos;
+	int _canoeMoveCount;
+	int _canoeFrame;
+	RiverStruct *_topList;
+	RiverStruct *_botList;
+	int _canoeDir;
+
+	// Saved fields
+	int _canoeLane;
+	int _canoeYPos;
+	int _hitCount;
+	int _riverIndex;
+	int _hitSafe;
+	int _rScrollRow;
+	int _rScrollCol;
+	int _rScrollX;
+	int _rScrollY;
+	int _rOldRectCount;
+	int _rNewRectCount;
+	int _rKeyFlag;
+	int _mapOffset;
+	int _screenVirtX;
+
+	void initRiver();
+	void resetPositions();
+	void checkRiverPan();
+	bool riverJumpTest();
+	void riverSound();
+	void moveCanoe();
+	void moveCanoe2();
+	void updateObstacles();
+	void riverSetPhysX();
+	bool checkRiverCollide();
+	void plotRiver();
+	void scrollRiver();
+	void scrollRiver1();
+	void setRiverPan();
+public:
+	River(AmazonEngine *vm);
+
+	void river();
+	void mWhileDownRiver();
+
+	void synchronize(Common::Serializer &s);
+};
+
+class Ant: public AmazonManager {
+private:
+	Direction _antDirection;
+	Direction _pitDirection;
+	int _antCel;
+	int _torchCel;
+	int _pitCel;
+	int _stabCel;
+	Common::Point _antPos;
+	bool _antDieFl;
+	bool _antEatFl;
+	bool _stabFl;
+	Common::Point _pitPos;
+
+	void plotTorchSpear(int indx, const int *&buf);
+	void plotPit(int indx, const int *&buf);
+	int antHandleRight(int indx, const int *&buf);
+	int antHandleLeft(int indx, const int *&buf);
+	int antHandleStab(int indx, const int *&buf);
+public:
+	Ant(AmazonEngine *vm);
+
+	void doAnt();
+};
+
+class InactivePlayer : public ImageEntry {
+public:
+	SpriteResource *_altSpritesPtr;
+};
+
+} // End of namespace Amazon
+
+} // End of namespace Access
+
+#endif /* ACCESS_AMAZON_LOGIC_H */
diff --git a/engines/access/amazon/amazon_player.cpp b/engines/access/amazon/amazon_player.cpp
index ede7ab5..c9b63a9 100644
--- a/engines/access/amazon/amazon_player.cpp
+++ b/engines/access/amazon/amazon_player.cpp
@@ -77,7 +77,7 @@ void AmazonPlayer::load() {
 		_diagUpWalkMax = 5;
 		_diagDownWalkMin = 0;
 		_diagDownWalkMax = 5;
-		_game->_guard._position = Common::Point(56, 190);
+		_game->_guard.setPosition(Common::Point(56, 190));
 	}
 }
 
diff --git a/engines/access/amazon/amazon_resources.cpp b/engines/access/amazon/amazon_resources.cpp
index 05e234a..0ae7ef0 100644
--- a/engines/access/amazon/amazon_resources.cpp
+++ b/engines/access/amazon/amazon_resources.cpp
@@ -1776,6 +1776,68 @@ const int HELP1COORDS[2][4] = {
 	{  76, 129, 168, 183 }, { 187, 240, 168, 183 }
 };
 
+const int RIVER1OBJ[23][4] = {
+	{ 18, -77, 0, 30 },
+	{ 18, -325, 0, 20 },
+	{ 18, -450, 0, 15 },
+	{ 18, -1250, 0, 25 },
+	{ 19, -130, 0, 20 },
+	{ 19, -410, 0, 15 },
+	{ 19, -710, 0, 25 },
+	{ 19, -1510, 0, 20 },
+	{ 20, -350, 0, 30 },
+	{ 20, -695, 0, 25 },
+	{ 20, -990, 0, 20 },
+	{ 20, -1300, 0, 25 },
+	{ 20, -1600, 0, 30 },
+	{ 21, -370, 0, 20 },
+	{ 21, -650, 0, 30 },
+	{ 21, -1215, 0, 40 },
+	{ 21, -1815, 0, 35 },
+	{ 22, -380, 0, 25 },
+	{ 22, -720, 0, 35 },
+	{ 22, -1020, 0, 30 },
+	{ 22, -1170, 0, 25 },
+	{ 22, -1770, 0, 35 },
+	{ 23, -500, 63, 20 }
+};
+
+const int CAST_END_OBJ[26][4] = {
+	{ 0, 118, 210, 10 },
+	{ 1, 38, 250, 10 },
+	{ 2, 38, 280, 10 },
+	{ 3, 38, 310, 10 },
+	{ 4, 38, 340, 10 },
+	{ 5, 38, 370, 10 },
+	{ 6, 38, 400, 10 },
+	{ 7, 38, 430, 10 },
+	{ 8, 38, 460, 10 },
+	{ 9, 38, 490, 10 },
+	{ 10, 38, 520, 10 },
+	{ 11, 38, 550, 10 },
+	{ 12, 38, 580, 10 },
+	{ 13, 38, 610, 10 },
+	{ 14, 38, 640, 10 },
+	{ 15, 38, 670, 10 },
+	{ 16, 38, 700, 10 },
+	{ 17, 38, 730, 10 },
+	{ 18, 38, 760, 10 },
+	{ 19, 38, 790, 10 },
+	{ 20, 95, 820, 10 },
+	{ 21, 94, 850, 10 },
+	{ 22, 96, 880, 10 },
+	{ 23, 114, 910, 10 },
+	{ 24, 114, 940, 10 },
+	{ 25, 110, 970, 10 }
+};
+
+const int CAST_END_OBJ1[4][4] = {
+	{ 0, 40, 1100, 10 },
+	{ 2, 11, 1180, 10 },
+	{ 1, 154, 1180, 10 },
+	{ 3, 103, 1300, 10 }
+};
+
 } // End of namespace Amazon
 
 } // End of namespace Access
diff --git a/engines/access/amazon/amazon_resources.h b/engines/access/amazon/amazon_resources.h
index 6d94e6a..61659d3 100644
--- a/engines/access/amazon/amazon_resources.h
+++ b/engines/access/amazon/amazon_resources.h
@@ -128,6 +128,12 @@ extern RiverStruct ENDRIVER2[1];
 extern RiverStruct *RIVEROBJECTTBL[6];
 extern const int HELP1COORDS[2][4];
 
+extern const int RIVER1OBJ[23][4];
+
+extern const int CAST_END_OBJ[26][4];
+
+extern const int CAST_END_OBJ1[4][4];
+
 } // End of namespace Amazon
 
 } // End of namespace Access
diff --git a/engines/access/amazon/amazon_room.cpp b/engines/access/amazon/amazon_room.cpp
index ca0d7bf..14514c2 100644
--- a/engines/access/amazon/amazon_room.cpp
+++ b/engines/access/amazon/amazon_room.cpp
@@ -205,7 +205,8 @@ void AmazonRoom::walkCursor() {
 	// the Exit icon wgeb the cursor is already a walk cursor
 	EventsManager &events = *_vm->_events;
 
-	if (_vm->_player->_roomNumber == 29 && events._normalMouse != CURSOR_CROSSHAIRS) {
+	if (_vm->_events->_middleButton || (_vm->_player->_roomNumber == 29 && 
+			events._normalMouse != CURSOR_CROSSHAIRS)) {
 		events._normalMouse = CURSOR_CROSSHAIRS;
 		events.setCursor(CURSOR_CROSSHAIRS);
 		_selectCommand = -1;
diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp
index 5849125..d6a57d7 100644
--- a/engines/access/amazon/amazon_scripts.cpp
+++ b/engines/access/amazon/amazon_scripts.cpp
@@ -33,28 +33,6 @@ namespace Amazon {
 
 AmazonScripts::AmazonScripts(AccessEngine *vm) : Scripts(vm) {
 	_game = (AmazonEngine *)_vm;
-
-	_xTrack = 0;
-	_yTrack = 0;
-	_zTrack = 0;
-	_xCam = 0;
-	_yCam = 0;
-	_zCam = 0;
-	_CHICKENOUTFLG = false;
-
-	_pNumObj = 0;
-	for (int i = 0; i < 32; i++) {
-		_pImgNum[i] = 0;
-		_pObject[i] = nullptr;
-		_pObjX[i] = 0;
-		_pObjY[i] = 0;
-		_pObjZ[i] = 0;
-	}
-
-	for (int i = 0; i < 16; i++) {
-		_pObjXl[i] = 0;
-		_pObjYl[i] = 0;
-	}
 }
 
 void AmazonScripts::cLoop() {
@@ -227,662 +205,31 @@ void AmazonScripts::mWhile2() {
 	} while (_vm->_flags[52] == 4);
 }
 
-void AmazonScripts::initJWalk2() {
-	const int JUNGLE1OBJ[7][4] = {
-		{2, 470, 0, 20},
-		{0, 290, 0, 50},
-		{1, 210, 0, 40},
-		{0, 500, 0, 30},
-		{1, 550, 0, 20},
-		{0, 580, 0, 60},
-		{1, 650, 0, 30}
-	};
-	_vm->_screen->fadeOut();
-	_vm->_events->hideCursor();
-	_vm->_screen->clearScreen();
-	_vm->_buffer2.clearBuffer();
-	_vm->_screen->setBufferScan();
-
-	_vm->_screen->_scrollX = _vm->_screen->_scrollY;
-	_vm->_screen->_scrollCol = _vm->_screen->_scrollRow;
-	_vm->_room->buildScreen();
-	_vm->copyBF2Vid();
-	_vm->_screen->fadeIn();
-	// KEYFL = 0;
-
-	_game->_plane._xCount = 2;
-	_vm->_player->_scrollAmount = 5;
-	_xTrack = -10;
-	_yTrack = _zTrack = 0;
-	_xCam = 480;
-	_yCam = 0;
-	_zCam = 80;
-
-	_game->_timers[24]._timer = 1;
-	_game->_timers[24]._initTm = 1;
-	++_game->_timers[24]._flag;
-
-	_pNumObj = 7;
-	for (int i = 0; i < _pNumObj; i++) {
-		_pObject[i] = _vm->_objectsTable[24];
-		_pImgNum[i] = JUNGLE1OBJ[i][0];
-		_pObjX[i] = JUNGLE1OBJ[i][1];
-		_pObjY[i] = JUNGLE1OBJ[i][2];
-		_pObjZ[i] = JUNGLE1OBJ[i][3];
-		_pObjXl[i] = _pObjYl[i] = 0;
-	}
-
-	_jCnt[0] = 0;
-	_jCnt[1] = 3;
-	_jCnt[2] = 5;
-
-	_jungleX[0] = 50;
-	_jungleX[1] = 16;
-	_jungleX[2] = 93;
-}
-
-void AmazonScripts::jungleMove() {
-	const static int jungleY[3] = {27, 30, 29};
-	int count = 1;
-	int frameOffset = 0;
-
-	if (!_vm->_timers[0]._flag) {
-		++_vm->_timers[0]._flag;
-		_vm->_screen->_scrollX += _vm->_player->_scrollAmount;
-
-		for (int i = 0; i < 3; ++i) {
-			int newJCnt = (_jCnt[i] + 1) % 8;
-			_jCnt[i] = newJCnt;
-			_jungleX[i] += 5;
-		}
-
-		frameOffset = 4;
-		count = (_game->_allenFlag != 1) ? 2 : 3;
-	}
-
-	for (int i = 0; i < count; ++i) {
-		ImageEntry ie;
-		ie._flags = IMGFLAG_UNSCALED;
-		ie._spritesPtr = _vm->_objectsTable[24];
-		ie._frameNumber = _jCnt[i] + frameOffset;
-		ie._position = Common::Point(_jungleX[i], jungleY[i]);
-		ie._offsetY = jungleY[i];
-
-		_vm->_images.addToList(ie);
-		frameOffset += 8;
-	}
-}
-
-void AmazonScripts::mWhileJWalk2() {
-	Screen &screen = *_vm->_screen;
-
-	initJWalk2();
-
-	while (!_vm->shouldQuit() && !_vm->_events->isKeyMousePressed() &&
-			(screen._scrollCol + screen._vWindowWidth) != _vm->_room->_playFieldWidth) {
-		_vm->_images.clear();
-		_vm->_events->_vbCount = 6;
-		_pImgNum[0] = _game->_plane._xCount;
-
-		jungleMove();
-		while (screen._scrollX >= TILE_WIDTH) {
-			screen._scrollX -= TILE_WIDTH;
-			++screen._scrollCol;
-			_vm->_buffer1.moveBufferLeft();
-			_vm->_room->buildColumn(screen._scrollCol + screen._vWindowWidth, screen._vWindowBytesWide);
-		}
-
-		if (_game->_plane._xCount == 2)
-			++_game->_plane._xCount;
-		else
-			--_game->_plane._xCount;
-
-		pan();
-		scrollJWalk();
-
-		while (!_vm->shouldQuit() && _vm->_events->_vbCount > 0) {
-			_vm->_events->pollEventsAndWait();
-		}
-	}
-
-	_vm->_events->showCursor();
-}
-
-void AmazonScripts::doFlyCell() {
-	Plane &plane = _game->_plane;
-	SpriteResource *sprites = _vm->_objectsTable[15];
-
-	if (plane._pCount <= 40) {
-		_vm->_buffer2.plotImage(sprites, 3, Common::Point(70, 74));
-	} else if (plane._pCount <= 80) {
-		_vm->_buffer2.plotImage(sprites, 6, Common::Point(70, 74));
-	} else if (plane._pCount <= 120) {
-		_vm->_buffer2.plotImage(sprites, 2, Common::Point(50, 76));
-	} else if (plane._pCount <= 160) {
-		_vm->_buffer2.plotImage(sprites, 14, Common::Point(63, 78));
-	} else if (plane._pCount <= 200) {
-		_vm->_buffer2.plotImage(sprites, 5, Common::Point(86, 74));
-	} else if (plane._pCount <= 240) {
-		_vm->_buffer2.plotImage(sprites, 0, Common::Point(103, 76));
-	} else if (plane._pCount <= 280) {
-		_vm->_buffer2.plotImage(sprites, 4, Common::Point(119, 77));
-	} else {
-		_vm->_buffer2.plotImage(sprites, 1, Common::Point(111, 77));
-	}
-
-	if (plane._planeCount == 11 || plane._planeCount == 12)
-		++plane._position.y;
-	else if (plane._planeCount >= 28)
-		--plane._position.y;
-
-	_vm->_buffer2.plotImage(sprites, 7, plane._position);
-	_vm->_buffer2.plotImage(sprites, 8 + plane._propCount, Common::Point(
-		plane._position.x + 99, plane._position.y + 10));
-	_vm->_buffer2.plotImage(sprites, 11 + plane._propCount, Common::Point(
-		plane._position.x + 104, plane._position.y + 18));
-
-	if (++plane._planeCount >= 30)
-		plane._planeCount = 0;
-	if (++plane._propCount >= 3)
-		plane._propCount = 0;
-
-	++plane._xCount;
-	if (plane._xCount == 1)
-		++plane._position.x;
-	else
-		plane._xCount = 0;
-}
-
-void AmazonScripts::doFallCell() {
-	if (_vm->_scaleI <= 20)
-		return;
-
-	SpriteFrame *frame = _vm->_objectsTable[20]->getFrame(_game->_plane._planeCount / 6);
-	Common::Rect r(115, 11, 115 + _vm->_screen->_scaleTable1[frame->w], 
-		11 + _vm->_screen->_scaleTable1[frame->h]);
-	_vm->_buffer2.sPlotF(frame, r);
-
-	_vm->_scaleI -= 3;
-	_vm->_scale = _vm->_scaleI;
-	_vm->_screen->setScaleTable(_vm->_scale);
-	++_game->_plane._xCount;
-	if (_game->_plane._xCount == 5)
-		return;
-	_game->_plane._xCount = 0;
-	if (_game->_plane._planeCount == 18)
-		_game->_plane._planeCount = 0;
-	else
-		_game->_plane._planeCount += 6;
-}
-
-void AmazonScripts::pan() {
-	_zCam += _zTrack;
-	_xCam += _xTrack;
-	int tx = (_xTrack << 8) / _zCam;
-	_yCam += _yTrack;
-	int ty = (_yTrack << 8) / _zCam;
-
-	if (_vm->_timers[24]._flag != 1) {
-		++_vm->_timers[24]._flag;
-		for (int i = 0; i < _pNumObj; i++) {
-			_pObjZ[i] += _zTrack;
-			_pObjXl[i] += (_pObjZ[i] * tx) & 0xff;
-			_pObjX[i] += ((_pObjZ[i] * tx) >> 8) + (_pObjXl[i] >> 8);
-			_pObjXl[i] &= 0xff;
-
-			_pObjYl[i] += (_pObjZ[i] * ty) & 0xff;
-			_pObjY[i] += ((_pObjZ[i] * ty) >> 8) + (_pObjYl[i] >> 8);
-			_pObjYl[i] &= 0xff;
-		}
-	}
-
-	for (int i = 0; i < _pNumObj; i++) {
-		ImageEntry ie;
-		ie._flags = IMGFLAG_UNSCALED;
-		ie._position = Common::Point(_pObjX[i], _pObjY[i]);
-		ie._offsetY = 255;
-		ie._spritesPtr = _pObject[i];
-		ie._frameNumber = _pImgNum[i];
-
-		_vm->_images.addToList(ie);
-	}
-}
-
-void AmazonScripts::scrollFly() {
-	_vm->copyBF1BF2();
-	_vm->_newRects.clear();
-	doFlyCell();
-	_vm->copyRects();
-	_vm->copyBF2Vid();
-}
-
-void AmazonScripts::scrollFall() {
-	_vm->copyBF1BF2();
-	_vm->_newRects.clear();
-	doFallCell();
-	_vm->copyRects();
-	_vm->copyBF2Vid();
-}
-
-void AmazonScripts::scrollJWalk() {
-	_vm->copyBF1BF2();
-	_vm->_newRects.clear();
-	_game->plotList();
-	_vm->copyRects();
-	_vm->copyBF2Vid();
-}
-
-void AmazonScripts::mWhileFly() {
-	Screen &screen = *_vm->_screen;
-	Player &player = *_vm->_player;
-	EventsManager &events = *_vm->_events;
-	Plane &plane = _game->_plane;
-
-	events.hideCursor();
-	screen.clearScreen();
-	screen.setBufferScan();
-	screen.fadeOut();
-	screen._scrollX = 0;
-
-	_vm->_room->buildScreen();
-	_vm->copyBF2Vid();
-	screen.fadeIn();
-	_vm->_oldRects.clear();
-	_vm->_newRects.clear();
-
-	// KEYFLG = 0;
-
-	screen._scrollRow = screen._scrollCol = 0;
-	screen._scrollX = screen._scrollY = 0;
-	player._rawPlayer = Common::Point(0, 0);
-	player._scrollAmount = 1;
-
-	plane._pCount = 0;
-	plane._planeCount = 0;
-	plane._propCount = 0;
-	plane._xCount = 0;
-	plane._position = Common::Point(20, 29);
-
-	while (!_vm->shouldQuit() && !events.isKeyMousePressed() &&
-			((screen._scrollCol + screen._vWindowWidth) != _vm->_room->_playFieldWidth)) {
-		events._vbCount = 4;
-		screen._scrollX += player._scrollAmount;
-
-		while (screen._scrollX >= TILE_WIDTH) {
-			screen._scrollX -= TILE_WIDTH;
-			++screen._scrollCol;
-
-			_vm->_buffer1.moveBufferLeft();
-			_vm->_room->buildColumn(screen._scrollCol + screen._vWindowWidth, screen._vWindowBytesWide);
-		}
-
-		scrollFly();
-		++plane._pCount;
-
-		while (!_vm->shouldQuit() && events._vbCount > 0) {
-			// To be rewritten when NEWTIMER is done
-			events.checkForNextFrameCounter();
-			_vm->_sound->playSound(0);
-
-			events.pollEventsAndWait();
-		}
-	}
-
-	events.showCursor();
-}
-
-void AmazonScripts::mWhileFall() {
-	Screen &screen = *_vm->_screen;
-	EventsManager &events = *_vm->_events;
-
-	events.hideCursor();
-	screen.clearScreen();
-	screen.setBufferScan();
-	screen.fadeOut();
-	screen._scrollX = 0;
-
-	_vm->_room->buildScreen();
-	_vm->copyBF2Vid();
-	screen.fadeIn();
-	_vm->_oldRects.clear();
-	_vm->_newRects.clear();
-
-	// KEYFLG = 0;
-
-	screen._scrollRow = screen._scrollCol = 0;
-	screen._scrollX = screen._scrollY = 0;
-	_vm->_player->_scrollAmount = 3;
-	_vm->_scaleI = 255;
-
-	_game->_plane._xCount = 0;
-	_game->_plane._planeCount = 0;
-
-	while (!_vm->shouldQuit() && !events.isKeyMousePressed() &&
-			(screen._scrollCol + screen._vWindowWidth != _vm->_room->_playFieldWidth)) {
-		events._vbCount = 4;
-		screen._scrollX += _vm->_player->_scrollAmount;
-
-		while (screen._scrollX >= TILE_WIDTH) {
-			screen._scrollX -= TILE_WIDTH;
-			++screen._scrollCol;
-
-			_vm->_buffer1.moveBufferLeft();
-			_vm->_room->buildColumn(screen._scrollCol + screen._vWindowWidth, screen._vWindowBytesWide);
-		}
-
-		scrollFall();
-
-		while (!_vm->shouldQuit() && events._vbCount > 0) {
-			events.pollEventsAndWait();
-		}
-	}
-
-	events.showCursor();
-}
-
-void AmazonScripts::mWhileJWalk() {
-	Screen &screen = *_vm->_screen;
-	EventsManager &events = *_vm->_events;
-	Player &player = *_vm->_player;
-
-	static const int JUNGLE_OBJ[7][4] = {
-		{2, 77, 0, 40},
-		{0, 290, 0, 50},
-		{1, 210, 0, 70},
-		{0, 50, 0, 30},
-		{1, 70, 0, 20},
-		{0, -280, 0, 60},
-		{1, -150, 0, 30},
-	};
-
-	screen.fadeOut();
-	events.hideCursor();
-	screen.clearScreen();
-	_vm->_buffer2.clearBuffer();
-	screen.setBufferScan();
-	screen._scrollX = 0;
-
-	// Build the initial jungle scene and fade it in
-	_vm->_room->buildScreen();
-	_vm->copyBF2Vid();
-	screen.fadeIn();
-
-	// Set up the player to walk horizontally
-	player._xFlag = 1;
-	player._yFlag = 0;
-	player._moveTo.x = 160;
-	player._playerMove = true;
-
-	_game->_plane._xCount = 2;
-	_xTrack = 10;
-	_yTrack = _zTrack = 0;
-	_xCam = 480;
-	_yCam = 0;
-	_zCam = 80;
-
-	TimerEntry *te = &_vm->_timers[24];
-	te->_initTm = te->_timer = 1;
-	te->_flag++;
-	
-	_pNumObj = 7;
-	for (int i = 0; i < _pNumObj; i++) {
-		_pObject[i] = _vm->_objectsTable[24];
-		_pImgNum[i] = JUNGLE_OBJ[i][0];
-		_pObjX[i] = JUNGLE_OBJ[i][1];
-		_pObjY[i] = JUNGLE_OBJ[i][2];
-		_pObjZ[i] = JUNGLE_OBJ[i][3];
-		_pObjXl[i] = _pObjYl[i] = 0;
-	}
-	
-	while (!_vm->shouldQuit() && !events.isKeyMousePressed() && (player._xFlag != 2)) {
-		_vm->_images.clear();
-		events._vbCount = 6;
-
-		_pImgNum[0] = _game->_plane._xCount;
-		if (_game->_plane._xCount == 2)
-			++_game->_plane._xCount;
-		else
-			--_game->_plane._xCount;
-
-		player.checkMove();
-		player.checkScroll();
-		pan();
-		scrollJWalk();
-
-		while (!_vm->shouldQuit() && events._vbCount > 0) {
-			events.pollEventsAndWait();
-		}
-	}
-
-	_vm->_images.clear();
-	events.showCursor();
-}
-
-void AmazonScripts::mWhileDoOpen() {
-	Screen &screen = *_vm->_screen;
-	EventsManager &events = *_vm->_events;
-
-	screen.setBufferScan();
-	events.hideCursor();
-	screen.forceFadeOut();
-	_game->_skipStart = false;
-	if (_vm->_conversation != 2) {
-		// Cutscene at start of chapter 1
-		screen.setPanel(3);
-		_game->startChapter(1);
-		_game->establishCenter(0, 1);
-	}
-
-	Resource *data = _vm->_files->loadFile(1, 0);
-	_vm->_objectsTable[1] = new SpriteResource(_vm, data);
-	delete data;
-
-	_vm->_files->_setPaletteFlag = false;
-	_vm->_files->loadScreen(1, 2);
-	_vm->_buffer2.copyFrom(*_vm->_screen);
-	_vm->_buffer1.copyFrom(*_vm->_screen);
-
-	// Load animation data
-	_vm->_animation->freeAnimationData();
-	Resource *animResource = _vm->_files->loadFile(1, 1);
-	_vm->_animation->loadAnimations(animResource);
-	delete animResource;
-
-	_xTrack = 8;
-	_yTrack = -3;
-	_zTrack = 0;
-	_xCam = _yCam = 0;
-	_zCam = 270;
-	_vm->_timers[24]._timer = _vm->_timers[24]._initTm = 1;
-	++_vm->_timers[24]._flag;
-	_vm->_timers.updateTimers();
-
-	_pNumObj = 10;
-	for (int i = 0; i < _pNumObj; i++) {
-		_pObject[i] = _vm->_objectsTable[1];
-		_pImgNum[i] = OPENING_OBJS[i][0];
-		_pObjX[i] = OPENING_OBJS[i][1];
-		_pObjY[i] = OPENING_OBJS[i][2];
-		_pObjZ[i] = OPENING_OBJS[i][3];
-		_pObjXl[i] = _pObjYl[i] = 0;
-	}
-
-	_vm->_oldRects.clear();
-	_vm->_newRects.clear();
-	Animation *anim = _vm->_animation->setAnimation(0);
-	_vm->_animation->setAnimTimer(anim);
-	anim = _vm->_animation->setAnimation(1);
-	_vm->_animation->setAnimTimer(anim);
-	_vm->_sound->newMusic(10, 0);
-	
-	bool startFl = false;
-	while (!_vm->shouldQuit()) {
-		_vm->_images.clear();
-		_vm->_animation->animate(0);
-		_vm->_animation->animate(1);
-		pan();
-		_vm->_buffer2.copyFrom(_vm->_buffer1);
-		_vm->_newRects.clear();
-		_game->plotList();
-		_vm->copyBlocks();
-		if (!startFl) {
-			startFl = true;
-			screen.forceFadeIn();
-		}
-
-		events.pollEventsAndWait();
-
-		if (events._leftButton || events._rightButton || events._keypresses.size() > 0) {
-			_game->_skipStart = true;
-			_vm->_sound->newMusic(10, 1);
-
-			events.debounceLeft();
-			events.zeroKeys();
-			break;
-		}
-
-		if (_xCam > 680) {
-			events._vbCount = 125;
-			
-			while(!_vm->shouldQuit() && !events.isKeyMousePressed() && events._vbCount > 0) {
-				events.pollEventsAndWait();
-			}
-			break;
-		}
-	}
-	
-	events.showCursor();
-	_vm->_buffer2.copyFrom(*_vm->_screen);
-	_vm->_buffer1.copyFrom(*_vm->_screen);
-	
-	_vm->freeCells();
-	_vm->_oldRects.clear();
-	_vm->_newRects.clear();
-	_vm->_numAnimTimers = 0;
-	_vm->_images.clear();
-
-	if (_vm->_conversation == 2) {
-		// Cutscene at end of Chapter 6
-		Resource *spriteData = _vm->_files->loadFile(28, 37);
-		_vm->_objectsTable[28] = new SpriteResource(_vm, spriteData);
-		delete spriteData;
-		
-		_vm->_animation->freeAnimationData();
-		animResource = _vm->_files->loadFile(28, 38);
-		_vm->_animation->loadAnimations(animResource);
-		delete animResource;
-	}
-}
-
-void AmazonScripts::scrollRiver() {
-	_vm->copyBF1BF2();
-	_vm->_newRects.clear();
-	_vm->_buffer2.plotImage(_vm->_objectsTable[33], 0, Common::Point(66, 30));
-	_vm->plotList();
-	_vm->copyRects();
-	_vm->copyBF2Vid();
-}
-
-void AmazonScripts::mWhileDownRiver() {
-	_vm->_events->hideCursor();
-	_vm->_screen->setDisplayScan();
-	_vm->_screen->clearScreen();
-	_vm->_screen->savePalette();
-
-	_vm->_files->loadScreen(95, 4);
-	_vm->_buffer2.copyFrom(*_vm->_screen);
-	_vm->_screen->restorePalette();
-	_vm->_screen->setPalette();
-	_vm->_screen->setBufferScan();
-	_vm->_screen->_scrollX = 0;
-	_vm->_room->buildScreen();
-	_vm->copyBF2Vid();
-
-	_vm->_player->_scrollAmount = 2;
-	_vm->_destIn = &_vm->_buffer2;
-	_xTrack = -7;
-	_yTrack = _zTrack = 0;
-	_xCam = _yCam = 0;
-	_zCam = 80;
-
-	_game->_timers[24]._timer = 1;
-	_game->_timers[24]._initTm = 1;
-	++_game->_timers[24]._flag;
-	
-	_pNumObj = 14;
-	for (int i = 0; i <_pNumObj; i++) {
-		_pObject[i] = _vm->_objectsTable[33];
-		_pImgNum[i] = DOWNRIVEROBJ[i][0];
-		_pObjX[i] = DOWNRIVEROBJ[i][1];
-		_pObjY[i] = DOWNRIVEROBJ[i][2];
-		_pObjZ[i] = DOWNRIVEROBJ[i][3];
-		_pObjXl[i] = _pObjYl[i] = 0;
-	}
-
-	_game->_timers[3]._timer = 200;
-	_game->_timers[3]._initTm = 200;
-	++_game->_timers[3]._flag;
-	_game->_timers[4]._timer = 350;
-	_game->_timers[4]._initTm = 350;
-	++_game->_timers[4]._flag;
-
-	while (!_vm->shouldQuit() && !_vm->_events->isKeyMousePressed() &&
-			(_vm->_screen->_scrollCol + _vm->_screen->_vWindowWidth != _vm->_room->_playFieldWidth)) {
-		_vm->_images.clear();
-		_vm->_events->_vbCount = 6;
-
-		_vm->_screen->_scrollX += _vm->_player->_scrollAmount;
-		while (_vm->_screen->_scrollX >= TILE_WIDTH) {
-			_vm->_screen->_scrollX -= TILE_WIDTH;
-			++_vm->_screen->_scrollCol;
-			_vm->_buffer1.moveBufferLeft();
-			_vm->_room->buildColumn(_vm->_screen->_scrollCol + _vm->_screen->_vWindowWidth, _vm->_screen->_vWindowBytesWide);
-		}
-
-		pan();
-		scrollRiver();
-
-		if (!_game->_timers[3]._flag) {
-			++_game->_timers[3]._flag;
-			_vm->_sound->playSound(1);
-		} else if (!_game->_timers[4]._flag) {
-			++_game->_timers[4]._flag;
-			_vm->_sound->playSound(0);
-		}
-
-		while (!_vm->shouldQuit() && _vm->_events->_vbCount > 0) {
-			_vm->_events->pollEventsAndWait();
-		}
-	}
-
-	_vm->_events->showCursor();
-}
-
 void AmazonScripts::mWhile(int param1) {
 	switch(param1) {
 	case 1:
 		mWhile1();
 		break;
 	case 2:
-		mWhileFly();
+		_game->_plane.mWhileFly();
 		break;
 	case 3:
-		mWhileFall();
+		_game->_plane.mWhileFall();
 		break;
 	case 4:
-		mWhileJWalk();
+		_game->_jungle.mWhileJWalk();
 		break;
 	case 5:
-		mWhileDoOpen();
+		_game->_opening.mWhileDoOpen();
 		break;
 	case 6:
-		mWhileDownRiver();
+		_game->_river.mWhileDownRiver();
 		break;
 	case 7:
 		mWhile2();
 		break;
 	case 8:
-		mWhileJWalk2();
+		_game->_jungle.mWhileJWalk2();
 		break;
 	default:
 		break;
@@ -899,143 +246,6 @@ void AmazonScripts::loadBackground(int param1, int param2) {
 	_vm->_screen->forceFadeIn();
 }
 
-void AmazonScripts::doCast(int param1) {
-	static const int END_OBJ[26][4] = {
-		{ 0, 118, 210, 10},
-		{ 1,  38, 250, 10},
-		{ 2,  38, 280, 10},
-		{ 3,  38, 310, 10},
-		{ 4,  38, 340, 10},
-		{ 5,  38, 370, 10},
-		{ 6,  38, 400, 10},
-		{ 7,  38, 430, 10},
-		{ 8,  38, 460, 10},
-		{ 9,  38, 490, 10},
-		{10,  38, 520, 10},
-		{11,  38, 550, 10},
-		{12,  38, 580, 10},
-		{13,  38, 610, 10},
-		{14,  38, 640, 10},
-		{15,  38, 670, 10},
-		{16,  38, 700, 10},
-		{17,  38, 730, 10},
-		{18,  38, 760, 10},
-		{19,  38, 790, 10},
-		{20,  95, 820, 10},
-		{21,  94, 850, 10},
-		{22,  96, 880, 10},
-		{23, 114, 910, 10},
-		{24, 114, 940, 10},
-		{25, 110, 970, 10}
-	};
-
-	static const int END_OBJ1[4][4] = {
-		{0,  40, 1100, 10},
-		{2,  11, 1180, 10},
-		{1, 154, 1180, 10},
-		{3, 103, 1300, 10}
-	};
-
-	_vm->_screen->setDisplayScan();
-	_vm->_events->hideCursor();
-	_vm->_screen->forceFadeOut();
-	_vm->_screen->_clipHeight = 173;
-	_vm->_screen->clearScreen();
-	_game->_chapter = 16;
-	_game->tileScreen();
-	_game->updateSummary(param1);
-	_vm->_screen->setPanel(3);
-	_game->_chapter = 14;
-
-	Resource *spriteData = _vm->_files->loadFile(91, 0);
-	_vm->_objectsTable[0] = new SpriteResource(_vm, spriteData);
-	delete spriteData;
-	spriteData = _vm->_files->loadFile(91, 1);
-	_vm->_objectsTable[1] = new SpriteResource(_vm, spriteData);
-	delete spriteData;
-
-	_vm->_files->_setPaletteFlag = false;
-	_vm->_files->loadScreen(58, 1);
-	_vm->_buffer2.copyFrom(*_vm->_screen);
-	_vm->_buffer1.copyFrom(*_vm->_screen);
-
-	_xTrack = 0;
-	_yTrack = -6;
-	_zTrack = 0;
-	_xCam = _yCam = 0;
-	_zCam = 60;
-
-	_game->_timers[24]._timer = 1;
-	_game->_timers[24]._initTm = 1;
-	++_game->_timers[24]._flag;
-
-	_pNumObj = 26;
-	for (int i = 0; i < _pNumObj; i++) {
-		_pObject[i] = _vm->_objectsTable[0];
-		_pImgNum[i] = END_OBJ[i][0];
-		_pObjX[i] = END_OBJ[i][1];
-		_pObjY[i] = END_OBJ[i][2];
-		_pObjZ[i] = END_OBJ[i][3];
-		_pObjXl[i] = _pObjYl[i] = 0;
-	}
-
-	_pNumObj = 4;
-	for (int i = 0; i < _pNumObj; i++) {
-		_pObject[26 + i] = _vm->_objectsTable[1];
-		_pImgNum[26 + i] = END_OBJ1[i][0];
-		_pObjX[26 + i] = END_OBJ1[i][1];
-		_pObjY[26 + i] = END_OBJ1[i][2];
-		_pObjZ[26 + i] = END_OBJ1[i][3];
-		_pObjXl[26 + i] = _pObjYl[26 + i] = 0;
-	}
-
-	_vm->_oldRects.clear();
-	_vm->_newRects.clear();
-	_vm->_numAnimTimers = 0;
-
-	_vm->_sound->newMusic(58, 0);
-	_vm->_screen->forceFadeIn();
-
-	while (!_vm->shouldQuit()) {
-		_vm->_images.clear();
-		pan();
-		_vm->_buffer2.copyFrom(_vm->_buffer1);
-		_vm->_newRects.clear();
-		_game->plotList();
-		_vm->copyBlocks();
-
-		_vm->_events->pollEvents();
-		if (_vm->_events->isKeyMousePressed())
-			break;
-
-		if (_yCam < -7550) {
-			_vm->_events->_vbCount = 50;
-
-			while(!_vm->shouldQuit() && !_vm->_events->isKeyMousePressed() && _vm->_events->_vbCount > 0) {
-				_vm->_events->pollEventsAndWait();
-			}
-
-			while (!_vm->shouldQuit() && !_vm->_sound->checkMidiDone())
-				_vm->_events->pollEventsAndWait();
-
-			break;
-		}
-	}
-
-	_vm->_sound->newMusic(58, 1);
-	_vm->_events->showCursor();
-
-	_vm->freeCells();
-	_vm->_oldRects.clear();
-	_vm->_newRects.clear();
-	_vm->_numAnimTimers = 0;
-	_vm->_images.clear();
-	_vm->_screen->forceFadeOut();
-
-	_vm->quitGame();
-	_vm->_events->pollEvents();
-}
-
 void AmazonScripts::setInactive() {
 	_game->_rawInactiveX = _vm->_player->_rawPlayer.x;
 	_game->_rawInactiveY = _vm->_player->_rawPlayer.y;
@@ -1044,243 +254,6 @@ void AmazonScripts::setInactive() {
 	mWhile(_game->_rawInactiveY);
 }
 
-void AmazonScripts::plotTorchSpear(int indx, const int *&buf) {
-	int idx = indx;
-
-	ImageEntry ie;
-	ie._flags = IMGFLAG_UNSCALED;
-	ie._spritesPtr = _vm->_objectsTable[62];
-	ie._frameNumber = buf[(idx / 2)];
-	ie._position = Common::Point(_game->_pitPos.x + buf[(idx / 2) + 1], _game->_pitPos.y + buf[(idx / 2) + 2]);
-	ie._offsetY = 255;
-	_vm->_images.addToList(ie);
-}
-
-void AmazonScripts::plotPit(int indx, const int *&buf) {
-	int idx = indx;
-	ImageEntry ie;
-	ie._flags = IMGFLAG_UNSCALED;
-	ie._spritesPtr = _vm->_objectsTable[62];
-	ie._frameNumber = buf[(idx / 2)];
-	ie._position = Common::Point(_game->_pitPos.x, _game->_pitPos.y);
-	ie._offsetY = _game->_pitPos.y;
-	_vm->_images.addToList(ie);
-
-	_vm->_player->_rawPlayer = _game->_pitPos;
-	if (_vm->_inventory->_inv[76]._value == 1) {
-		idx = _game->_torchCel;
-		buf = Amazon::TORCH;
-		_vm->_timers[14]._flag = 1;
-		idx += 6;
-		if (buf[idx / 2] == -1)
-			idx = 0;
-		_game->_torchCel = idx;
-		plotTorchSpear(idx, buf);
-	} else if (!_game->_stabFl && (_vm->_inventory->_inv[78]._value == 1)) {
-		idx = 0;
-		buf = Amazon::SPEAR;
-		plotTorchSpear(idx, buf);
-	}
-}
-
-int AmazonScripts::antHandleRight(int indx, const int *&buf) {
-	int retval = indx;
-	if (_game->_pitDirection == NONE) {
-		_game->_pitDirection = UP;
-		_game->_pitPos.y = 127;
-	}
-	retval = _game->_pitCel;
-	buf = Amazon::PITWALK;
-	if (_game->_pitPos.x < 230) {
-		if (retval == 0) {
-			retval = 48;
-			_game->_pitPos.y = 127;
-		}
-		retval -= 6;
-		_game->_pitPos.x -= buf[(retval / 2) + 1];
-		_game->_pitPos.y -= buf[(retval / 2) + 2];
-		_game->_pitCel = retval;
-	}
-	return retval;
-}
-
-int AmazonScripts::antHandleLeft(int indx, const int *&buf) {
-	int retval = indx;
-	if (_game->_pitDirection == UP) {
-		_game->_pitDirection = NONE;
-		_game->_pitPos.y = 127;
-	}
-	retval = _game->_pitCel;
-	buf = Amazon::PITWALK;
-	retval += 6;
-	if (buf[retval / 2] == -1) {
-		retval = 0;
-		_game->_pitPos.y = 127;
-	}
-	_game->_pitPos.x += buf[(retval / 2) + 1];
-	_game->_pitPos.y += buf[(retval / 2) + 2];
-	_game->_pitCel = retval;
-
-	return retval;
-}
-
-int AmazonScripts::antHandleStab(int indx, const int *&buf) {
-	int retval = indx;
-	if (_vm->_inventory->_inv[78]._value != 1) {
-		if (_game->_stabFl) {
-			buf = Amazon::PITSTAB;
-			retval = _game->_stabCel;
-			if (_game->_timers[13]._flag == 0) {
-				_game->_timers[13]._flag = 1;
-				retval += 6;
-				if (Amazon::PITSTAB[retval] == -1) {
-					_game->_stabFl = false;
-					_game->_pitCel = 0;
-					_game->_pitPos.y = 127;
-					retval = 0;
-					buf = Amazon::PITWALK;
-				} else {
-					_game->_pitPos.x += buf[(retval / 2) + 1];
-					_game->_pitPos.y += buf[(retval / 2) + 2];
-					_game->_pitCel = retval;
-				}
-			}
-		} else {
-			_game->_stabFl = true;
-			_game->_pitCel = 0;
-			retval = 0;
-			_game->_stabCel = 0;
-			int dist = _game->_pitPos.x - _game->_antPos.x;
-			if (_game->_antEatFl && !_game->_antDieFl && (dist <= 80)) {
-				_game->_antDieFl = true;
-				_game->_antCel = 0;
-				_game->_antPos.y = 123;
-				_vm->_sound->playSound(1);
-			}
-		}
-	}
-	return retval;
-}
-
-void AmazonScripts::ANT() {
-	_game->_antDirection = NONE;
-	if (_game->_aniFlag != 1) {
-		_game->_aniFlag = 1;
-		_game->_antCel = 0;
-		_game->_torchCel = 0;
-		_game->_pitCel = 0;
-
-		_game->_timers[15]._timer = 16;
-		_game->_timers[15]._initTm = 16;
-		_game->_timers[15]._flag = 1;
-
-		_game->_timers[13]._timer = 5;
-		_game->_timers[13]._initTm = 5;
-		_game->_timers[13]._flag = 1;
-
-		_game->_timers[14]._timer = 10;
-		_game->_timers[14]._initTm = 10;
-		_game->_timers[14]._flag = 1;
-
-		_game->_antPos = Common::Point(-40, 123);
-		_game->_antDieFl = _game->_antEatFl = false;
-		_game->_stabFl = false;
-		_game->_pitPos = Common::Point(_vm->_player->_rawPlayer.x, 127);
-	}
-
-	const int *buf = nullptr;
-	if (_game->_antDieFl) {
-		buf = Amazon::ANTDIE;
-	} else if (_game->_antEatFl) {
-		buf = Amazon::ANTEAT;
-	} else if (_game->_antPos.x > 120 && _vm->_flags[198] == 1) {
-		_game->_antEatFl = true;
-		_vm->_flags[235] = 1;
-		_game->_antCel = 0;
-		buf = Amazon::ANTEAT;
-	} else {
-		buf = Amazon::ANTWALK;
-		if (_vm->_inventory->_inv[76]._value == 1)
-			_game->_antDirection = UP;
-	}
-
-	int idx = _game->_antCel;
-	if (_game->_timers[15]._flag == 0) {
-		_game->_timers[15]._flag = 1;
-		if (_game->_antDirection == UP) {
-			if (_game->_antPos.x > 10) {
-				if (idx == 0)
-					idx = 36;
-				else
-					idx -= 6;
-
-				_game->_antPos = Common::Point(buf[(idx / 2) + 1], buf[(idx / 2) + 2]);
-				_game->_antCel = idx;
-			}
-		} else {
-			idx += 6;
-			if (buf[(idx / 2)] != -1) {
-				_game->_antPos = Common::Point(buf[(idx / 2) + 1], buf[(idx / 2) + 2]);
-				_game->_antCel = idx;
-			} else if (!_game->_antDieFl) {
-				idx = 0;
-				_game->_antPos = Common::Point(buf[(idx / 2) + 1], buf[(idx / 2) + 2]);
-				_game->_antCel = idx;
-			} else {
-				idx -= 6;
-				if (_game->_flags[200] == 0)
-					_game->_flags[200] = 1;
-			}
-		}
-	}
-
-	ImageEntry ie;
-	ie._flags = IMGFLAG_UNSCALED;
-	ie._spritesPtr = _vm->_objectsTable[61];
-	ie._frameNumber = buf[(idx / 2)];
-	ie._position = Common::Point(_game->_antPos.x, _game->_antPos.y);
-	ie._offsetY = _game->_antPos.y - 70;
-	_vm->_images.addToList(ie);
-	_game->_antCel = idx;
-
-	if (_game->_flags[196] != 1) {
-		idx = _game->_pitCel;
-		if (_game->_stabFl == 1) {
-			idx = antHandleStab(idx, buf);
-		} else {
-			buf = Amazon::PITWALK;
-			if (_game->_timers[13]._flag == 0) {
-				_game->_timers[13]._flag = 1;
-				_vm->_events->pollEvents();
-				if (_vm->_events->_leftButton) {
-					Common::Point pt = _vm->_events->calcRawMouse();
-					if (pt.x < _game->_pitPos.x)
-						idx = antHandleLeft(idx, buf);
-					else if (pt.x > _game->_pitPos.x)
-						idx = antHandleRight(idx, buf);
-				} else {
-					buf = Amazon::PITWALK;
-					if (_vm->_player->_playerDirection == UP)
-						idx = antHandleStab(idx, buf);
-					else if (_vm->_player->_playerDirection == LEFT)
-						idx = antHandleLeft(idx, buf);
-					else if (_vm->_player->_playerDirection == RIGHT)
-						idx = antHandleRight(idx, buf);
-				}
-			}
-		}
-		plotPit(idx, buf);
-	}
-
-	if (!_game->_antDieFl) {
-		int dist = _game->_pitPos.x - _game->_antPos.x;
-		if ((_game->_antEatFl && (dist <= 45)) || (!_game->_antEatFl && (dist <= 80))) {
-			_game->_flags[199] = 1;
-			_game->_aniFlag = 0;
-		}
-	}
-}
-
 void AmazonScripts::boatWalls(int param1, int param2) {
 	if (param1 == 1)
 		_vm->_room->_plotter._walls[42] = Common::Rect(96, 27, 96 + 87, 27 + 42);
@@ -1339,473 +312,6 @@ void AmazonScripts::plotInactive() {
 	_vm->_images.addToList(_game->_inactive);
 }
 
-void AmazonScripts::setRiverPan() {
-	static const int RIVER1OBJ[23][4] = {
-		{18,   -77,  0, 30},
-		{18,  -325,  0, 20},
-		{18,  -450,  0, 15},
-		{18, -1250,  0, 25},
-		{19,  -130,  0, 20},
-		{19,  -410,  0, 15},
-		{19,  -710,  0, 25},
-		{19, -1510,  0, 20},
-		{20,  -350,  0, 30},
-		{20,  -695,  0, 25},
-		{20,  -990,  0, 20},
-		{20, -1300,  0, 25},
-		{20, -1600,  0, 30},
-		{21,  -370,  0, 20},
-		{21,  -650,  0, 30},
-		{21, -1215,  0, 40},
-		{21, -1815,  0, 35},
-		{22,  -380,  0, 25},
-		{22,  -720,  0, 35},
-		{22, -1020,  0, 30},
-		{22, -1170,  0, 25},
-		{22, -1770,  0, 35},
-		{23,  -500, 63, 20}
-	};
-
-	int delta = (_vm->_screen->_scrollCol * 16) + _vm->_screen->_scrollX;
-
-	_xTrack = 9;
-	_yTrack = _zTrack = 0;
-	_xCam = 160;
-	_yCam = 0;
-	_zCam = 80;
-
-	_game->_timers[24]._timer = 1;
-	_game->_timers[24]._initTm = 1;
-	++_game->_timers[24]._flag;
-
-	_pNumObj = 23;
-	for (int i = 0; i < _pNumObj; i++) {
-		_pObject[i] = _vm->_objectsTable[45];
-		_pImgNum[i] = RIVER1OBJ[i][0];
-		_pObjX[i] = RIVER1OBJ[i][1] + delta;
-		_pObjY[i] = RIVER1OBJ[i][2];
-		_pObjZ[i] = RIVER1OBJ[i][3];
-		_pObjXl[i] = _pObjYl[i] = 0;
-	}
-}
-
-void AmazonScripts::initRiver() {
-	static const int RIVERVXTBL[3] = {6719, 7039, 8319};
-
-	_vm->_events->centerMousePos();
-	_vm->_events->restrictMouse();
-	_vm->_screen->setDisplayScan();
-	_vm->_screen->clearScreen();
-	_vm->_screen->savePalette();
-	_vm->_screen->forceFadeOut();
-
-	_vm->_files->_setPaletteFlag = false;
-	_vm->_files->loadScreen(95, 4);
-	_vm->_buffer2.copyFrom(*_vm->_screen);
-
-	_vm->_screen->restorePalette();
-	_vm->_screen->setBufferScan();
-	_vm->_destIn = &_vm->_buffer2;
-	_vm->_room->roomMenu();
-
-	if (_game->_saveRiver) {
-		// Restoring a savegame, so set properties from saved fields
-		_vm->_screen->_scrollRow = _vm->_rScrollRow;
-		_vm->_screen->_scrollCol = _vm->_rScrollCol;
-		_vm->_screen->_scrollX = _vm->_rScrollX;
-		_vm->_screen->_scrollY = _vm->_rScrollY;
-	} else {
-		// Set initial scene state
-		_vm->_screen->_scrollRow = 0;
-		_vm->_screen->_scrollCol = 140;
-		_vm->_screen->_scrollX = 0;
-		_vm->_screen->_scrollY = 0;
-	}
-
-	_vm->_room->buildScreen();
-	_vm->copyBF2Vid();
-	_vm->_screen->forceFadeIn();
-
-	if (_game->_saveRiver) {
-		// Restore draw rects from savegame
-		_vm->_oldRects.resize(_vm->_rOldRectCount);
-		_vm->_newRects.resize(_vm->_rNewRectCount);
-		// KEYFLG = _vm->_rKeyFlag
-	} else {
-		// Reset draw rects
-		_vm->_oldRects.clear();
-		_vm->_newRects.clear();
-		// KEYFLG = 0
-	}
-
-	_vm->_player->_scrollAmount = 2;
-	setRiverPan();
-	_game->_timers[3]._timer = 1;
-	_game->_timers[3]._initTm = 1;
-	++_game->_timers[3]._flag;
-
-	_game->_canoeFrame = 0;
-	_game->_mapPtr = (const byte *)MAPTBL[_game->_riverFlag] + 1;
-	if (_game->_saveRiver) {
-		_game->_mapPtr--;
-		_game->_mapPtr += _game->_mapOffset;
-	} else {
-		_screenVertX = RIVERVXTBL[_game->_riverFlag] - 320;
-		_game->_canoeLane = 3;
-		_game->_hitCount = 0;
-		_game->_hitSafe = 0;
-		_game->_canoeYPos = 71;
-	}
-
-	_game->_riverIndex = _game->_riverFlag;
-	_game->_topList = RIVEROBJECTTBL[_game->_riverIndex];
-	updateObstacles();
-	riverSetPhysX();
-	_game->_canoeDir = 0;
-	_game->_deathFlag = 0;
-	_game->_deathCount = 0;
-
-	_game->_timers[11]._timer = 1200;
-	_game->_timers[11]._initTm = 1200;
-	++_game->_timers[11]._flag;
-	_game->_timers[12]._timer = 1500;
-	_game->_timers[12]._initTm = 1500;
-	++_game->_timers[12]._flag;
-	
-	_game->_maxHits = 2 - _game->_riverFlag;
-	_game->_saveRiver = false;
-}
-
-void AmazonScripts::resetPositions() {
-	riverSetPhysX();
-	int val = (_vm->_screen->_scrollCol + 1 - _game->_oldScrollCol) * 16;
-	if (val > 256) {
-		val &= 0x7F;
-		val |= 0x80;
-	}
-
-	for (int i = 0; i < _pNumObj; i++)
-		_pObjX[i] += val;
-}
-
-void AmazonScripts::checkRiverPan() {
-	int val = (_vm->_screen->_scrollCol + 20) * 16;
-
-	for (int i = 0; i < _pNumObj; i++) {
-		if (_pObjX[i] < val)
-			return;
-	}
-
-	setRiverPan();
-}
-
-bool AmazonScripts::riverJumpTest() {
-	if (_vm->_screen->_scrollCol == 120 || _vm->_screen->_scrollCol == 60 || _vm->_screen->_scrollCol == 0) {
-		int val = _game->_mapPtr[0];
-		++_game->_mapPtr;
-		if (val == 0xFF)
-			return true;
-		_game->_oldScrollCol = _vm->_screen->_scrollCol;
-
-		if (val == 0) {
-			_vm->_screen->_scrollCol = 139;
-			_vm->_screen->_scrollX = 14;
-			_vm->_room->buildScreen();
-			resetPositions();
-			return false;
-		}
-	} else if (_vm->_screen->_scrollCol == 105) {
-		int val1 = _game->_mapPtr[1];
-		int val2 = _game->_mapPtr[2];
-		_game->_mapPtr += 3;
-		if (_game->_canoeLane < 3) {
-			if (val1 != 0) {
-				_game->_deathFlag = true;
-				_game->_deathCount = 300;
-				_game->_deathType = val2;
-			}
-		} else {
-			if (val1 != 1) {
-				_game->_deathFlag = true;
-				_game->_deathCount = 300;
-				_game->_deathType = val2;
-			}
-			_game->_oldScrollCol = _vm->_screen->_scrollCol;
-			_vm->_screen->_scrollCol = 44;
-			_vm->_screen->_scrollX = 14;
-			_vm->_room->buildScreen();
-			resetPositions();
-			return false;
-		}
-	}
-
-	_vm->_screen->_scrollX = 14;
-	--_vm->_screen->_scrollCol;
-	_vm->_buffer1.moveBufferRight();
-	_vm->_room->buildColumn(_vm->_screen->_scrollCol, 0);
-	checkRiverPan();
-	return false;
-}
-
-void AmazonScripts::riverSound() {
-	if (_game->_timers[11]._flag == 0) {
-		++_game->_timers[11]._flag;
-		_vm->_sound->playSound(2);
-	}
-
-	if (_game->_timers[12]._flag == 0) {
-		++_game->_timers[12]._flag;
-		_vm->_sound->playSound(3);
-	}
-
-	if ((_xCam >= 1300) && (_xCam <= 1320))
-		_vm->_sound->playSound(1);
-}
-
-void AmazonScripts::moveCanoe() {
-	Screen &screen = *_vm->_screen;
-	EventsManager &events = *_vm->_events;
-	Common::Point pt = events.calcRawMouse();
-
-	// Do an event polling
-	_vm->_canSaveLoad = true;
-	events.pollEvents();
-	_vm->_canSaveLoad = false;
-	if (_vm->_room->_function == FN_CLEAR1)
-		return;
-
-	if (_game->_canoeDir) {
-		// Canoe movement in progress
-		moveCanoe2();
-	} else {
-		if (events._leftButton && pt.y >= 140) {
-			if (pt.x < RMOUSE[8][0]) {
-				// Disk icon wasn't clicked
-				printString(BAR_MESSAGE);
-			} else {
-				// Clicked on the Disc icon
-				_game->_saveRiver = true;
-				_game->_rScrollRow = screen._scrollRow;
-				_game->_rScrollCol = screen._scrollCol;
-				_game->_rScrollX = screen._scrollX;
-				_game->_rScrollY = screen._scrollY;
-				_game->_mapOffset = _game->_mapPtr - MAPTBL[_game->_riverFlag];
-
-				// Show the ScummVM menu
-				_vm->_room->handleCommand(9);
-
-				if (_vm->_room->_function != FN_CLEAR1) {
-					_game->_saveRiver = false;
-					_vm->_room->buildScreen();
-					_vm->copyBF2Vid();
-				}
-			}
-		} else if ((events._leftButton && pt.y <= _game->_canoeYPos) ||
-			(!events._leftButton && _vm->_player->_move == UP)) {
-			// Move canoe up
-			if (_game->_canoeLane > 0) {
-				_game->_canoeDir = -1;
-				_game->_canoeMoveCount = 0;
-
-				moveCanoe2();
-			}
-		} else if (events._leftButton || _vm->_player->_move == DOWN) {
-			// Move canoe down
-			if (_game->_canoeLane < 7) {
-				_game->_canoeDir = 1;
-				_game->_canoeMoveCount = 0;
-
-				moveCanoe2();
-			}
-		}
-	}
-}
-
-void AmazonScripts::moveCanoe2() {
-	_game->_canoeYPos += _game->_canoeDir;
-
-	if (++_game->_canoeMoveCount == 5) {
-		_game->_canoeLane += _game->_canoeDir;
-		_game->_canoeDir = 0;
-	}
-}
-
-void AmazonScripts::updateObstacles() {
-	RiverStruct *cur;
-	for (cur = _game->_topList; cur < RIVEROBJECTTBL[_game->_riverIndex + 1]; ++cur) {
-		int val = cur->_field1 + cur->_field3 - 1;
-		if (val < _screenVertX)
-			break;
-
-		if (cur->_field3 < (_game->_screenVirtX + 319)) {
-			_game->_topList = cur;
-			_game->_botList = cur;
-
-			while (cur < RIVEROBJECTTBL[_game->_riverIndex + 1]) {
-				++cur;
-				val = cur->_field1 + cur->_field3 - 1;
-				if (val < _screenVertX || (cur->_field3 >= (_game->_screenVirtX + 319)))
-					break;
-
-				_game->_botList = cur;
-			}
-
-			return;
-		}
-	}
-
-	cur = _game->_topList;
-	cur--;
-	_game->_botList = cur;
-}
-
-void AmazonScripts::riverSetPhysX() {
-	int val = (_vm->_screen->_scrollCol * 16) + _vm->_screen->_scrollX;
-	RiverStruct *cur = _game->_topList;
-	while (cur <= _game->_botList) {
-		cur[0]._field5 = val - (_screenVertX - cur[0]._field3);
-		++cur;
-	}
-}
-
-bool AmazonScripts::checkRiverCollide() {
-	if (_game->_hitSafe)
-		return false;
-
-	_game->_canoeVXPos = _screenVertX + 170;
-
-	for (RiverStruct *si = _game->_topList; si <= _game->_botList; ++si) {
-		if (si[0]._lane < _game->_canoeLane)
-			continue;
-
-		if ((si[0]._lane == _game->_canoeLane) || (si[0]._lane == _game->_canoeLane + 1)) {
-			if (si[0]._field1 + si[0]._field3 - 1 >= _game->_canoeVXPos) {
-				if (_game->_canoeVXPos + 124 >= si[0]._field3) {
-					_vm->_sound->playSound(4);
-					return true;
-				}
-			}
-		}
-	}
-	return false;
-}
-
-void AmazonScripts::plotRiver() {
-	if (_vm->_timers[3]._flag == 0) {
-		++_vm->_timers[3]._flag;
-		if (_game->_canoeFrame == 12)
-			_game->_canoeFrame = 0;
-		else
-			++_game->_canoeFrame;
-	}
-
-	ImageEntry ie;
-	ie._flags = IMGFLAG_UNSCALED;
-	ie._spritesPtr = _vm->_objectsTable[45];
-	ie._frameNumber = _game->_canoeFrame;
-	ie._position.x = (_vm->_screen->_scrollCol * 16) + _vm->_screen->_scrollX + 160;
-	ie._position.y = _game->_canoeYPos - 41;
-	ie._offsetY = 41;
-	_vm->_images.addToList(ie);
-
-	RiverStruct *cur = _game->_topList;
-	while (cur <= _game->_botList) {
-		if (cur[0]._id != -1) {
-			ie._flags = IMGFLAG_UNSCALED;
-			ie._spritesPtr = _vm->_objectsTable[45];
-			ie._frameNumber = 0;
-			ie._position.x = cur[0]._field5;
-			int val = (cur[0]._lane * 5) + 56;
-			ie._position.y = val - cur[0]._field8;
-			ie._offsetY = cur[0]._field8;
-			_vm->_images.addToList(ie);
-		}
-		++cur;
-	}
-}
-
-void AmazonScripts::scrollRiver1() {
-	_vm->copyBF1BF2();
-	_vm->_newRects.clear();
-	plotRiver();
-	_vm->plotList();
-	_vm->copyRects();
-	_vm->copyBF2Vid();
-}
-
-void AmazonScripts::RIVER() {
-	static const int RIVERDEATH[5] = {22, 23, 24, 25, 26};
-
-	initRiver();
-	_vm->_events->showCursor();
-
-	while (!_vm->shouldQuit()) {
-		_vm->_events->_vbCount = 4;
-
-//		int bx = _vm->_player->_scrollAmount - _screenVertX;
-		if (_vm->_screen->_scrollX == 0) {
-			_vm->_sound->midiRepeat();
-			if (riverJumpTest()) {
-				_CHICKENOUTFLG = false;
-				return;
-			}
-		} else {
-			_vm->_screen->_scrollX -= _vm->_player->_scrollAmount;
-		}
-
-		if (_CHICKENOUTFLG) {
-			_CHICKENOUTFLG = false;
-			return;
-		}
-
-		_vm->_images.clear();
-		_vm->_animation->animate(0);
-
-		riverSound();
-		pan();
-		moveCanoe();
-
-		if (_vm->_room->_function != FN_CLEAR1) {
-			updateObstacles();
-			riverSetPhysX();
-			bool checkCollide = checkRiverCollide();
-			if (_game->_hitSafe != 0)
-				_game->_hitSafe -= 2;
-
-			if (checkCollide) {
-				cmdDead(RIVERDEATH[0]);
-				return;
-			}
-
-			if (_game->_deathFlag) {
-				_game->_deathCount--;
-				if (_game->_deathCount == 0) {
-					cmdDead(RIVERDEATH[_game->_deathType]);
-					return;
-				}
-			}
-
-			// Scroll the river
-			scrollRiver1();
-
-			// Allow time for new scrolled river position to be shown
-			_vm->_canSaveLoad = true;
-			while (!_vm->shouldQuit() && _vm->_room->_function == FN_NONE &&
-					_vm->_events->_vbCount > 0) {
-				_vm->_events->pollEventsAndWait();
-			}
-			_vm->_canSaveLoad = false;
-		}
-
-		if (_vm->_room->_function == FN_CLEAR1) {
-			_endFlag = true;
-			_returnCode = 0;
-			_CHICKENOUTFLG = false;
-			break;
-		}
-	}
-}
-
 void AmazonScripts::executeSpecial(int commandIndex, int param1, int param2) {
 	switch (commandIndex) {
 	case 1:
@@ -1815,7 +321,7 @@ void AmazonScripts::executeSpecial(int commandIndex, int param1, int param2) {
 		loadBackground(param1, param2);
 		break;
 	case 3:
-		doCast(param1);
+		_game->_cast.doCast(param1);
 		break;
 	case 4:
 		setInactive();
@@ -1824,7 +330,7 @@ void AmazonScripts::executeSpecial(int commandIndex, int param1, int param2) {
 		mWhile(param1);
 		break;
 	case 9:
-		_game->_guard.guard();
+		_game->_guard.doGuard();
 		break;
 	case 10:
 		_vm->_sound->newMusic(param1, param2);
@@ -1833,10 +339,10 @@ void AmazonScripts::executeSpecial(int commandIndex, int param1, int param2) {
 		plotInactive();
 		break;
 	case 13:
-		RIVER();
+		_game->_river.river();
 		break;
 	case 14:
-		ANT();
+		_game->_ant.doAnt();
 		break;
 	case 15:
 		boatWalls(param1, param2);
diff --git a/engines/access/amazon/amazon_scripts.h b/engines/access/amazon/amazon_scripts.h
index bd47e9c..968d51e 100644
--- a/engines/access/amazon/amazon_scripts.h
+++ b/engines/access/amazon/amazon_scripts.h
@@ -35,72 +35,15 @@ class AmazonEngine;
 class AmazonScripts: public Scripts {
 private:
 	AmazonEngine *_game;
-	int _xTrack;
-	int _yTrack;
-	int _zTrack;
-	int _xCam;
-	int _yCam;
-	int _zCam;
-	int _pNumObj;
-	int _screenVertX;
-	bool _CHICKENOUTFLG;
-
-	SpriteResource *_pObject[32];
-	int _pImgNum[32];
-	int _pObjX[32];
-	int _pObjY[32];
-	int _pObjZ[32];
-	int _pObjXl[32];
-	int _pObjYl[32];
-
-	int _jCnt[3];
-	int _jungleX[3];
-
-	void pan();
-
 protected:
 	virtual void executeSpecial(int commandIndex, int param1, int param2);
 	virtual void executeCommand(int commandIndex);
 
-	void doFlyCell();
-	void doFallCell();
-	void scrollFly();
-	void scrollFall();
-	void scrollJWalk();
 	void cLoop();
 	void mWhile1();
 	void mWhile2();
-	void mWhileFly();
-	void mWhileFall();
-	void mWhileJWalk();
-	void initJWalk2();
-	void jungleMove();
-	void mWhileJWalk2();
-	void scrollRiver();
-	void mWhileDownRiver();
 	void mWhile(int param1);
-	void plotTorchSpear(int indx, const int *&buf);
-	void plotPit(int indx, const int *&buf);
-	int antHandleRight(int indx, const int *&buf);
-	int antHandleLeft(int indx, const int *&buf);
-	int antHandleStab(int indx, const int *&buf);
-	void ANT();
-	void doCast(int param1);
 	void loadBackground(int param1, int param2);
-	void initRiver();
-	void resetPositions();
-	void checkRiverPan();
-	bool riverJumpTest();
-	void riverSound();
-	void moveCanoe();
-	void moveCanoe2();
-	void updateObstacles();
-	void riverSetPhysX();
-	bool checkRiverCollide();
-	void plotRiver();
-	void scrollRiver1();
-	void setRiverPan();
-	void RIVER();
 	void plotInactive();
 	void setInactive();
 	void boatWalls(int param1, int param2);
@@ -114,8 +57,6 @@ protected:
 	void CMDRETFLASH();
 public:
 	AmazonScripts(AccessEngine *vm);
-
-	void mWhileDoOpen();
 };
 
 } // End of namespace Amazon
diff --git a/engines/access/martian/martian_game.h b/engines/access/martian/martian_game.h
index a99ece6..e46b2bb 100644
--- a/engines/access/martian/martian_game.h
+++ b/engines/access/martian/martian_game.h
@@ -63,6 +63,8 @@ protected:
 	 * Play the game
 	 */
 	virtual void playGame();
+
+	virtual void dead(int deathId) {}
 public:
 	MartianEngine(OSystem *syst, const AccessGameDescription *gameDesc);
 
diff --git a/engines/access/module.mk b/engines/access/module.mk
index 9846401..b6961ae 100644
--- a/engines/access/module.mk
+++ b/engines/access/module.mk
@@ -22,6 +22,7 @@ MODULE_OBJS := \
 	sound.o \
 	video.o \
 	amazon/amazon_game.o \
+	amazon/amazon_logic.o \
 	amazon/amazon_player.o \
 	amazon/amazon_resources.o \
 	amazon/amazon_room.o \
diff --git a/engines/access/player.cpp b/engines/access/player.cpp
index b945b76..2313ed2 100644
--- a/engines/access/player.cpp
+++ b/engines/access/player.cpp
@@ -751,7 +751,7 @@ bool Player::scrollDown() {
 bool Player::scrollLeft() {
 	Screen &screen = *_vm->_screen;
 	_scrollAmount = -(screen._clipWidth - _playerX - _scrollThreshold);
-	if ((_vm->_rScrollCol + screen._vWindowWidth) == _vm->_room->_playFieldWidth) {
+	if ((screen._scrollCol + screen._vWindowWidth) == _vm->_room->_playFieldWidth) {
 		_scrollEnd = 2;
 		screen._scrollX = 0;
 		_scrollFlag = true;
diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp
index 72650f4..add461e 100644
--- a/engines/access/scripts.cpp
+++ b/engines/access/scripts.cpp
@@ -784,76 +784,9 @@ void Scripts::cmdPlayerOn() {
 	_vm->_player->_playerOff = false;
 }
 
-void Scripts::cmdDead(int deathId) {
-	_vm->_events->hideCursor();
-	_vm->_screen->forceFadeOut();
-	cmdFreeSound();
-
-	_vm->_sound->_soundTable.push_back(SoundEntry(_vm->_files->loadFile(98, 44), 1));
-
-	_vm->_screen->clearScreen();
-	_vm->_screen->setPanel(3);
-
-	if (deathId != 10) {
-		_vm->_sound->newMusic(62, 0);
-		_vm->_files->_setPaletteFlag = false;
-		_vm->_files->loadScreen(94, 0);
-		_vm->_files->_setPaletteFlag = true;
-		_vm->_buffer2.copyFrom(*_vm->_screen);
-
-		for (int i = 0; i < 3; ++i) {
-			_vm->_sound->playSound(0);
-			_vm->_screen->forceFadeIn();
-			_vm->_sound->playSound(0);
-			_vm->_screen->forceFadeOut();
-		}
-		_vm->freeCells();
-
-		// Load the cell list for the death screen
-		DeathEntry &de = _vm->_deaths[deathId];
-		Common::Array<CellIdent> cells;
-		cells.push_back(_vm->_deaths._cells[de._screenId]);
-		_vm->loadCells(cells);
-
-		_vm->_screen->setDisplayScan();
-		_vm->_files->_setPaletteFlag = false;
-		_vm->_files->loadScreen(&_vm->_buffer2, 94, 1);
-		_vm->_screen->setIconPalette();
-
-		_vm->_buffer2.plotImage(_vm->_objectsTable[0], 0, Common::Point(105, 25));
-		_vm->_buffer2.copyTo(_vm->_screen);
-		_vm->_screen->forceFadeIn();
-
-		_vm->_fonts._charSet._hi = 10;
-		_vm->_fonts._charSet._lo = 1;
-		_vm->_fonts._charFor._lo = 55;
-		_vm->_fonts._charFor._hi = 255;
-		_vm->_screen->_maxChars = 46;
-		_vm->_screen->_printOrg = Common::Point(20, 155);
-		_vm->_screen->_printStart = Common::Point(20, 155);
-
-		Common::String &msg = de._msg;
-		_vm->_printEnd = 180;
-		_vm->printText(_vm->_screen, msg);
-		_vm->_screen->forceFadeOut();
-
-		_vm->_sound->newMusic(0, 1);
-		_vm->_events->showCursor();
-		_vm->_room->clearRoom();
-		_vm->freeChar();
-
-		warning("TODO: restart game");
-		_vm->quitGame();
-		_vm->_events->pollEvents();
-	} else {
-		_vm->quitGame();
-		_vm->_events->pollEvents();
-	}
-}
-
 void Scripts::cmdDead() { 
 	int deathId = _data->readByte();
-	cmdDead(deathId);
+	_vm->dead(deathId);
 }
 
 void Scripts::cmdFadeOut() {
diff --git a/engines/access/scripts.h b/engines/access/scripts.h
index b6a3dc4..098fd4f 100644
--- a/engines/access/scripts.h
+++ b/engines/access/scripts.h
@@ -48,11 +48,6 @@ protected:
 	virtual void executeCommand(int commandIndex);
 
 	/**
-	 * Print a given message to the screen in a bubble box
-	 */
-	void printString(const Common::String &msg);
-
-	/**
 	 * Read a null terminated string from the script
 	 */
 	Common::String readString();
@@ -120,7 +115,6 @@ protected:
 	void cmdPlayerOff();
 	void cmdPlayerOn();
 	void cmdDead();
-	void cmdDead(int deathId);
 	void cmdFadeOut();
 	void cmdEndVideo();
 public:
@@ -146,6 +140,11 @@ public:
 
 	void findNull();
 
+	/**
+	 * Print a given message to the screen in a bubble box
+	 */
+	void printString(const Common::String &msg);
+
 	// Script commands that need to be public
 	void cmdFreeSound();
 	void cmdRetPos();


Commit: 01e9214c7d98f1b64597d943b35ac8efb3069c47
    https://github.com/scummvm/scummvm/commit/01e9214c7d98f1b64597d943b35ac8efb3069c47
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-12T22:51:15-05:00

Commit Message:
ACCESS: Only save river scene fields when actually in the river scene

I'm still not happy everything needed is being synchronised, so this
way we can work on it further without upsetting other Amazon saves

Changed paths:
    engines/access/amazon/amazon_logic.cpp



diff --git a/engines/access/amazon/amazon_logic.cpp b/engines/access/amazon/amazon_logic.cpp
index cae3373..5470265 100644
--- a/engines/access/amazon/amazon_logic.cpp
+++ b/engines/access/amazon/amazon_logic.cpp
@@ -1546,22 +1546,24 @@ void River::river() {
 	}
 }
 void River::synchronize(Common::Serializer &s) {
-	s.syncAsSint16LE(_canoeLane);
-	s.syncAsSint16LE(_canoeYPos);
-	s.syncAsSint16LE(_hitCount);
-	s.syncAsSint16LE(_riverIndex);
-	s.syncAsSint16LE(_hitSafe);
-	s.syncAsUint16LE(_rScrollRow);
-	s.syncAsUint16LE(_rScrollCol);
-	s.syncAsSint16LE(_rScrollX);
-	s.syncAsSint16LE(_rScrollY);
-	s.syncAsUint16LE(_rOldRectCount);
-	s.syncAsUint16LE(_rNewRectCount);
-	s.syncAsUint16LE(_rKeyFlag);
-	s.syncAsUint16LE(_mapOffset);
-	s.syncAsUint16LE(_screenVirtX);
-	warning("TODO: 	s.syncAsSint16LE(_topList);");
-	warning("TODO: 	s.syncAsSint16LE(_botList);");
+	if (_vm->_player->_roomNumber == 45) {
+		s.syncAsSint16LE(_canoeLane);
+		s.syncAsSint16LE(_canoeYPos);
+		s.syncAsSint16LE(_hitCount);
+		s.syncAsSint16LE(_riverIndex);
+		s.syncAsSint16LE(_hitSafe);
+		s.syncAsUint16LE(_rScrollRow);
+		s.syncAsUint16LE(_rScrollCol);
+		s.syncAsSint16LE(_rScrollX);
+		s.syncAsSint16LE(_rScrollY);
+		s.syncAsUint16LE(_rOldRectCount);
+		s.syncAsUint16LE(_rNewRectCount);
+		s.syncAsUint16LE(_rKeyFlag);
+		s.syncAsUint16LE(_mapOffset);
+		s.syncAsUint16LE(_screenVirtX);
+		warning("TODO: 	s.syncAsSint16LE(_topList);");
+		warning("TODO: 	s.syncAsSint16LE(_botList);");
+	}
 }
 
 /*------------------------------------------------------------------------*/


Commit: 21519194348425f988f9a78c3748bc596bb1ac61
    https://github.com/scummvm/scummvm/commit/21519194348425f988f9a78c3748bc596bb1ac61
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-12T22:51:34-05:00

Commit Message:
ACCESS: Remove accidental resetting of _vm pointers

Changed paths:
    engines/access/amazon/amazon_logic.cpp



diff --git a/engines/access/amazon/amazon_logic.cpp b/engines/access/amazon/amazon_logic.cpp
index 5470265..8df28ae 100644
--- a/engines/access/amazon/amazon_logic.cpp
+++ b/engines/access/amazon/amazon_logic.cpp
@@ -616,7 +616,6 @@ void Jungle::scrollJWalk() {
 /*------------------------------------------------------------------------*/
 
 Guard::Guard(AmazonEngine *vm): PannedScene(vm) {
-	_vm = nullptr;
 	_guardCel = 0;
 	_gCode1 = _gCode2 = 0;
 	_xMid = _yMid = 0;
@@ -1004,7 +1003,6 @@ void Cast::doCast(int param1) {
 /*------------------------------------------------------------------------*/
 
 River::River(AmazonEngine *vm): PannedScene(vm) {
-	_vm = nullptr;
 	_CHICKENOUTFLG = false;
 	_rScrollRow = 0;
 	_rScrollCol = 0;


Commit: b478b05df2ac62425fc01ea7ad13899c50404166
    https://github.com/scummvm/scummvm/commit/b478b05df2ac62425fc01ea7ad13899c50404166
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-12T22:51:43-05:00

Commit Message:
ACCESS: Move _saveRiver from engine to River class

Changed paths:
    engines/access/amazon/amazon_game.cpp
    engines/access/amazon/amazon_game.h
    engines/access/amazon/amazon_logic.cpp
    engines/access/amazon/amazon_logic.h



diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp
index 55876b5..b6c5385 100644
--- a/engines/access/amazon/amazon_game.cpp
+++ b/engines/access/amazon/amazon_game.cpp
@@ -43,7 +43,6 @@ AccessEngine(syst, gameDesc),
 	_skipStart = false;
 	_charSegSwitch = false;
 
-	_saveRiver = false;
 	_oldTitleChapter = _chapter = 0;
 	_updateChapter = -1;
 	_rawInactiveX = 0;
diff --git a/engines/access/amazon/amazon_game.h b/engines/access/amazon/amazon_game.h
index b09c96d..d697b16 100644
--- a/engines/access/amazon/amazon_game.h
+++ b/engines/access/amazon/amazon_game.h
@@ -86,7 +86,6 @@ public:
 	InactivePlayer _inactive;
 	bool _charSegSwitch;
 	bool _skipStart;
-	bool _saveRiver;
 
 	// Fields that are mapped to flags
 	int &_guardLocation;
diff --git a/engines/access/amazon/amazon_logic.cpp b/engines/access/amazon/amazon_logic.cpp
index 8df28ae..3ecb20d 100644
--- a/engines/access/amazon/amazon_logic.cpp
+++ b/engines/access/amazon/amazon_logic.cpp
@@ -1013,6 +1013,7 @@ River::River(AmazonEngine *vm): PannedScene(vm) {
 	_rKeyFlag = 0;
 	_mapOffset = 0;
 	_screenVirtX = 0;
+	_saveRiver = false;
 }
 
 void River::setRiverPan() {
@@ -1058,7 +1059,7 @@ void River::initRiver() {
 	_vm->_destIn = &_vm->_buffer2;
 	_vm->_room->roomMenu();
 
-	if (_vm->_saveRiver) {
+	if (_saveRiver) {
 		// Restoring a savegame, so set properties from saved fields
 		_vm->_screen->_scrollRow = _rScrollRow;
 		_vm->_screen->_scrollCol = _rScrollCol;
@@ -1076,7 +1077,7 @@ void River::initRiver() {
 	_vm->copyBF2Vid();
 	_vm->_screen->forceFadeIn();
 
-	if (_vm->_saveRiver) {
+	if (_saveRiver) {
 		// Restore draw rects from savegame
 		_vm->_oldRects.resize(_rOldRectCount);
 		_vm->_newRects.resize(_rNewRectCount);
@@ -1096,7 +1097,7 @@ void River::initRiver() {
 
 	_canoeFrame = 0;
 	_mapPtr = (const byte *)MAPTBL[_vm->_riverFlag] + 1;
-	if (_vm->_saveRiver) {
+	if (_saveRiver) {
 		_mapPtr--;
 		_mapPtr += _mapOffset;
 	} else {
@@ -1123,7 +1124,7 @@ void River::initRiver() {
 	++_vm->_timers[12]._flag;
 
 	_vm->_maxHits = 2 - _vm->_riverFlag;
-	_vm->_saveRiver = false;
+	_saveRiver = false;
 }
 
 void River::resetPositions() {
@@ -1234,7 +1235,7 @@ void River::moveCanoe() {
 				_vm->_scripts->printString(BAR_MESSAGE);
 			} else {
 				// Clicked on the Disc icon
-				_vm->_saveRiver = true;
+				_saveRiver = true;
 				_rScrollRow = screen._scrollRow;
 				_rScrollCol = screen._scrollCol;
 				_rScrollX = screen._scrollX;
@@ -1245,7 +1246,7 @@ void River::moveCanoe() {
 				_vm->_room->handleCommand(9);
 
 				if (_vm->_room->_function != FN_CLEAR1) {
-					_vm->_saveRiver = false;
+					_saveRiver = false;
 					_vm->_room->buildScreen();
 					_vm->copyBF2Vid();
 				}
@@ -1561,6 +1562,8 @@ void River::synchronize(Common::Serializer &s) {
 		s.syncAsUint16LE(_screenVirtX);
 		warning("TODO: 	s.syncAsSint16LE(_topList);");
 		warning("TODO: 	s.syncAsSint16LE(_botList);");
+
+		_saveRiver = s.isLoading();
 	}
 }
 
diff --git a/engines/access/amazon/amazon_logic.h b/engines/access/amazon/amazon_logic.h
index 4d5e274..46b3c70 100644
--- a/engines/access/amazon/amazon_logic.h
+++ b/engines/access/amazon/amazon_logic.h
@@ -151,6 +151,7 @@ private:
 	RiverStruct *_topList;
 	RiverStruct *_botList;
 	int _canoeDir;
+	bool _saveRiver;
 
 	// Saved fields
 	int _canoeLane;


Commit: ec44c0504f7dc37f7d38894b5a7f764aa17721cc
    https://github.com/scummvm/scummvm/commit/ec44c0504f7dc37f7d38894b5a7f764aa17721cc
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-12T22:51:52-05:00

Commit Message:
ACCESS: Remove unneeded dummy field syncs from serializer

Changed paths:
    engines/access/amazon/amazon_game.cpp



diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp
index b6c5385..fb88489 100644
--- a/engines/access/amazon/amazon_game.cpp
+++ b/engines/access/amazon/amazon_game.cpp
@@ -969,11 +969,7 @@ void AmazonEngine::dead(int deathId) {
 void AmazonEngine::synchronize(Common::Serializer &s) {
 	AccessEngine::synchronize(s);
 
-	int dummy = 0;
-
 	s.syncAsSint16LE(_chapter);
-	s.syncAsSint16LE(dummy);
-	s.syncAsSint16LE(dummy);
 	s.syncAsSint16LE(_rawInactiveX);
 	s.syncAsSint16LE(_rawInactiveY);
 	s.syncAsSint16LE(_inactiveYOff);


Commit: 01124c3378f03f9fa0c7c7618879caff5926f735
    https://github.com/scummvm/scummvm/commit/01124c3378f03f9fa0c7c7618879caff5926f735
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-12T22:52:01-05:00

Commit Message:
ACCESS: Moved help table data from AccessEngine to AmazonEngine

Changed paths:
    engines/access/access.cpp
    engines/access/access.h
    engines/access/amazon/amazon_game.cpp
    engines/access/amazon/amazon_game.h
    engines/access/amazon/amazon_scripts.cpp



diff --git a/engines/access/access.cpp b/engines/access/access.cpp
index 1ab40a2..2d25ae9 100644
--- a/engines/access/access.cpp
+++ b/engines/access/access.cpp
@@ -84,12 +84,6 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc)
 	_establishMode = 0;
 	_establishGroup = 0;
 	_establishCtrlTblOfs = 0;
-	Common::fill(&_help1[0], &_help1[366], 0);
-	Common::fill(&_help2[0], &_help2[366], 0);
-	Common::fill(&_help1[0], &_help3[366], 0);
-	_helpTbl[0] = _help1;
-	_helpTbl[1] = _help2;
-	_helpTbl[2] = _help3;
 	_travel = 0;
 	_ask = 0;
 	_lastTime = g_system->getMillis();
@@ -507,11 +501,6 @@ void AccessEngine::synchronize(Common::Serializer &s) {
 
 	for (int i = 0; i < 256; ++i)
 		s.syncAsUint16LE(_flags[i]);
-	for (int i = 0; i < 366; ++i) {
-		s.syncAsByte(_help1[i]);
-		s.syncAsByte(_help2[i]);
-		s.syncAsByte(_help3[i]);
-	}
 
 	s.syncAsUint16LE(_travel);
 	s.syncAsUint16LE(_ask);
diff --git a/engines/access/access.h b/engines/access/access.h
index 0942c9e..165ae83 100644
--- a/engines/access/access.h
+++ b/engines/access/access.h
@@ -207,10 +207,6 @@ public:
 	uint32 _newTime;
 	uint32 _newDate;
 	int _flags[256];
-	byte _help1[366];
-	byte _help2[366];
-	byte _help3[366];
-	byte *_helpTbl[3];
 	int _travel;
 	int _ask;
 
diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp
index fb88489..8958239 100644
--- a/engines/access/amazon/amazon_game.cpp
+++ b/engines/access/amazon/amazon_game.cpp
@@ -53,7 +53,13 @@ AccessEngine(syst, gameDesc),
 
 	Common::fill(&_esTabTable[0], &_esTabTable[100], 0);
 	memset(_tileData, 0, sizeof(_tileData));
-	
+	Common::fill(&_help1[0], &_help1[366], 0);
+	Common::fill(&_help2[0], &_help2[366], 0);
+	Common::fill(&_help1[0], &_help3[366], 0);
+	_helpTbl[0] = _help1;
+	_helpTbl[1] = _help2;
+	_helpTbl[2] = _help3;
+
 	_chapterCells.push_back(CellIdent(0, 96, 17));
 	_inactive._spritesPtr = nullptr;
 	_inactive._altSpritesPtr = nullptr;
@@ -973,8 +979,14 @@ void AmazonEngine::synchronize(Common::Serializer &s) {
 	s.syncAsSint16LE(_rawInactiveX);
 	s.syncAsSint16LE(_rawInactiveY);
 	s.syncAsSint16LE(_inactiveYOff);
+
 	for (int i = 0; i < 100; ++i)
 		s.syncAsSint16LE(_esTabTable[i]);
+	for (int i = 0; i < 366; ++i) {
+		s.syncAsByte(_help1[i]);
+		s.syncAsByte(_help2[i]);
+		s.syncAsByte(_help3[i]);
+	}
 
 	_river.synchronize(s);
 }
diff --git a/engines/access/amazon/amazon_game.h b/engines/access/amazon/amazon_game.h
index d697b16..016ddf4 100644
--- a/engines/access/amazon/amazon_game.h
+++ b/engines/access/amazon/amazon_game.h
@@ -86,6 +86,10 @@ public:
 	InactivePlayer _inactive;
 	bool _charSegSwitch;
 	bool _skipStart;
+	byte _help1[366];
+	byte _help2[366];
+	byte _help3[366];
+	byte *_helpTbl[3];
 
 	// Fields that are mapped to flags
 	int &_guardLocation;
diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp
index d6a57d7..4c3b838 100644
--- a/engines/access/amazon/amazon_scripts.cpp
+++ b/engines/access/amazon/amazon_scripts.cpp
@@ -448,7 +448,7 @@ void AmazonScripts::cmdSetHelp() {
 	int arrayId = (_data->readUint16LE() && 0xFF) - 1;
 	int helpId = _data->readUint16LE() && 0xFF;
 
-	byte *help = _vm->_helpTbl[arrayId];
+	byte *help = _game->_helpTbl[arrayId];
 	help[helpId] = 1;
 
 	if (_vm->_useItem == 0) {


Commit: eadaf534865c674bbe11588818539c34da278e0e
    https://github.com/scummvm/scummvm/commit/eadaf534865c674bbe11588818539c34da278e0e
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-12T22:52:13-05:00

Commit Message:
ACCESS: Remove unused _travel and _ask fields

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



diff --git a/engines/access/access.cpp b/engines/access/access.cpp
index 2d25ae9..6161336 100644
--- a/engines/access/access.cpp
+++ b/engines/access/access.cpp
@@ -84,8 +84,6 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc)
 	_establishMode = 0;
 	_establishGroup = 0;
 	_establishCtrlTblOfs = 0;
-	_travel = 0;
-	_ask = 0;
 	_lastTime = g_system->getMillis();
 	_curTime = 0;
 	_narateFile = 0;
@@ -501,10 +499,6 @@ void AccessEngine::synchronize(Common::Serializer &s) {
 
 	for (int i = 0; i < 256; ++i)
 		s.syncAsUint16LE(_flags[i]);
-
-	s.syncAsUint16LE(_travel);
-	s.syncAsUint16LE(_ask);
-
 	for (int i = 0; i < 100; ++i)
 		s.syncAsByte(_establishTable[i]);
 
diff --git a/engines/access/access.h b/engines/access/access.h
index 165ae83..47f5b5e 100644
--- a/engines/access/access.h
+++ b/engines/access/access.h
@@ -207,8 +207,6 @@ public:
 	uint32 _newTime;
 	uint32 _newDate;
 	int _flags[256];
-	int _travel;
-	int _ask;
 
 	bool _clearSummaryFlag;
 


Commit: 16a8d705baab154498cf33905655c4ed4b93b545
    https://github.com/scummvm/scummvm/commit/16a8d705baab154498cf33905655c4ed4b93b545
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-12T22:52:26-05:00

Commit Message:
ACCESS: Fix restoring game scene after using help

Changed paths:
    engines/access/amazon/amazon_game.cpp
    engines/access/amazon/amazon_scripts.cpp



diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp
index 8958239..b05bb7b 100644
--- a/engines/access/amazon/amazon_game.cpp
+++ b/engines/access/amazon/amazon_game.cpp
@@ -722,7 +722,7 @@ void AmazonEngine::drawHelp(const Common::String str) {
 			_screen->setPanel(2);
 			_screen->saveScreen();
 		}
-		_screen->setPalette();
+		_screen->savePalette();
 		_screen->fadeOut();
 		_screen->clearBuffer();
 		if (_moreHelp == 1) {
diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp
index 4c3b838..e2d1814 100644
--- a/engines/access/amazon/amazon_scripts.cpp
+++ b/engines/access/amazon/amazon_scripts.cpp
@@ -390,8 +390,8 @@ void AmazonScripts::cmdHelp() {
 
 	_game->drawHelp(helpMessage);
 
-	while(true) {
-		while(!_vm->shouldQuit() && !_vm->_events->_leftButton)
+	while (!_vm->shouldQuit()) {
+		while (!_vm->shouldQuit() && !_vm->_events->_leftButton)
 			_vm->_events->pollEventsAndWait();
 
 		_vm->_events->debounceLeft();
@@ -410,21 +410,24 @@ void AmazonScripts::cmdHelp() {
 			continue;
 
 		if (choice == 1) {
+			// Done button selected
 			_game->_helpLevel = 0;
 			_game->_moreHelp = 1;
 			_game->_useItem = 0;
 			_vm->_events->hideCursor();
 			_vm->_screen->restoreScreen();
 			_vm->_screen->setPanel(0);
-			_vm->_buffer2.copyFrom(*_vm->_screen);
+			_vm->_screen->copyFrom(_vm->_buffer2);
 			_vm->_screen->restorePalette();
 			_vm->_screen->setPalette();
 			_vm->_events->showCursor();
-			free(_vm->_objectsTable[45]);
+			
+			delete _vm->_objectsTable[45];
 			_vm->_objectsTable[45] = nullptr;
 			_vm->_timers.restoreTimers();
 			break;
 		} else {
+			// More button selected
 			if ((_game->_moreHelp == 0) || (choice != 0))
 				continue;
 			++_game->_helpLevel;


Commit: c42666f3d28519c52ac30695e175b8abb42436c7
    https://github.com/scummvm/scummvm/commit/c42666f3d28519c52ac30695e175b8abb42436c7
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-12T22:52:39-05:00

Commit Message:
ACCESS: Add some code for VGA mode in cmdHelp

Changed paths:
    engines/access/amazon/amazon_scripts.cpp



diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp
index e2d1814..eadcbdd 100644
--- a/engines/access/amazon/amazon_scripts.cpp
+++ b/engines/access/amazon/amazon_scripts.cpp
@@ -415,8 +415,14 @@ void AmazonScripts::cmdHelp() {
 			_game->_moreHelp = 1;
 			_game->_useItem = 0;
 			_vm->_events->hideCursor();
-			_vm->_screen->restoreScreen();
-			_vm->_screen->setPanel(0);
+			if (_vm->_screen->_vesaMode) {
+				_vm->_screen->restoreScreen();
+				_vm->_screen->setPanel(0);
+			} else {
+				_vm->_screen->fadeOut();
+				_vm->_screen->clearBuffer();
+			}
+
 			_vm->_screen->copyFrom(_vm->_buffer2);
 			_vm->_screen->restorePalette();
 			_vm->_screen->setPalette();


Commit: a8e111fae4b492c8478dd4eab239a7fa622b8833
    https://github.com/scummvm/scummvm/commit/a8e111fae4b492c8478dd4eab239a7fa622b8833
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-12T22:52:51-05:00

Commit Message:
ACCESS: Refactor opening scenes logic into Opening class

Changed paths:
    engines/access/access.cpp
    engines/access/access.h
    engines/access/amazon/amazon_game.cpp
    engines/access/amazon/amazon_game.h
    engines/access/amazon/amazon_logic.cpp
    engines/access/amazon/amazon_logic.h
    engines/access/amazon/amazon_scripts.cpp
    engines/access/martian/martian_game.cpp
    engines/access/martian/martian_game.h



diff --git a/engines/access/access.cpp b/engines/access/access.cpp
index 6161336..bac1308 100644
--- a/engines/access/access.cpp
+++ b/engines/access/access.cpp
@@ -50,7 +50,6 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc)
 
 	_destIn = nullptr;
 	_current = nullptr;
-	_pCount = 0;
 	_mouseMode = 0;
 	_currentMan = 0;
 	_currentManOld = -1;
diff --git a/engines/access/access.h b/engines/access/access.h
index 47f5b5e..af0d423 100644
--- a/engines/access/access.h
+++ b/engines/access/access.h
@@ -173,7 +173,6 @@ public:
 	Common::Array<Common::Rect> _oldRects;
 	Common::Array<ExtraCell> _extraCells;
 	ImageEntryList _images;
-	int _pCount;
 	int _mouseMode;
 
 	int _currentManOld;
diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp
index b05bb7b..dfaba97 100644
--- a/engines/access/amazon/amazon_game.cpp
+++ b/engines/access/amazon/amazon_game.cpp
@@ -40,7 +40,6 @@ AccessEngine(syst, gameDesc),
 		_ant(this), _cast(this), _guard(this), _jungle(this), _opening(this), 
 		_plane(this), _river(this) {
 
-	_skipStart = false;
 	_charSegSwitch = false;
 
 	_oldTitleChapter = _chapter = 0;
@@ -92,7 +91,7 @@ void AmazonEngine::playGame() {
 
 	if (_loadSaveSlot == -1) {
 		// Do introduction
-		doIntroduction();
+		_opening.doIntroduction();
 		if (shouldQuit())
 			return;
 	}
@@ -112,314 +111,6 @@ void AmazonEngine::playGame() {
 	_room->doRoom();
 }
 
-void AmazonEngine::doIntroduction() {
-	_screen->setInitialPalettte();
-	_events->setCursor(CURSOR_ARROW);
-	_events->showCursor();
-	_screen->setPanel(0);
-	_screen->setPalette();
-
-	_events->setCursor(CURSOR_ARROW);
-	_events->showCursor();
-	_screen->setPanel(3);
-	doTitle();
-
-	if (shouldQuit() || _skipStart)
-		return;
-
-	_screen->setPanel(3);
-	_opening.mWhileDoOpen();
-
-	if (shouldQuit() || _skipStart)
-		return;
-
-	doTent();
-}
-
-void AmazonEngine::doCredit() {
-	if (_pCount < 15)
-		return;
-
-	if (_pCount <= 75)
-		_buffer2.plotImage(_objectsTable[0], 0, Common::Point(90, 35));
-	else if (_pCount <= 210)
-		_buffer2.plotImage(_objectsTable[0], 1, Common::Point(65, 35));
-	else if (_pCount <= 272)
-		_buffer2.plotImage(_objectsTable[0], 2, Common::Point(96, 45));
-	else if (_pCount <= 334)
-		_buffer2.plotImage(_objectsTable[0], 3, Common::Point(68, 54));
-	else if (_pCount <= 396)
-		_buffer2.plotImage(_objectsTable[0], 4, Common::Point(103, 54));
-	else if (_pCount <= 458) {
-		_buffer2.plotImage(_objectsTable[0], 5, Common::Point(8, 5));
-		_buffer2.plotImage(_objectsTable[0], 12, Common::Point(88, 55));
-		_buffer2.plotImage(_objectsTable[0], 6, Common::Point(194, 98));
-	} else if (_pCount <= 520) {
-		_buffer2.plotImage(_objectsTable[0], 7, Common::Point(32, 13));
-		_buffer2.plotImage(_objectsTable[0], 8, Common::Point(162, 80));
-	} else if (_pCount <= 580) {
-		_buffer2.plotImage(_objectsTable[0], 9, Common::Point(18, 15));
-		_buffer2.plotImage(_objectsTable[0], 10, Common::Point(164, 81));
-	} else
-		_buffer2.plotImage(_objectsTable[0], 11, Common::Point(106, 55));
-}
-
-void AmazonEngine::scrollTitle() {
-	copyBF1BF2();
-	_newRects.clear();
-	doCredit();
-	copyRects();
-	copyBF2Vid();
-}
-
-void AmazonEngine::doTitle() {
-	_screen->setDisplayScan();
-	_destIn = &_buffer2;
-
-	_screen->forceFadeOut();
-	_events->hideCursor();
-
-	_sound->queueSound(0, 98, 30);
-	_sound->queueSound(1, 98, 8);
-
-	_files->_setPaletteFlag = false;
-	_files->loadScreen(0, 3);
-	
-	_buffer2.copyFrom(*_screen);
-	_buffer1.copyFrom(*_screen);
-	_screen->forceFadeIn();
-	_sound->playSound(1);
-
-	// HACK: This delay has been added so that the very first screen is visible.
-	// The original was using disk loading time to display it, and it's too fast
-	// nowadays to be visible.
-	_events->_vbCount = 70;
-	while (!shouldQuit() && _events->_vbCount > 0) {
-		_events->pollEvents();
-		g_system->delayMillis(10);
-	}
-
-	Resource *spriteData = _files->loadFile(0, 2);
-	_objectsTable[0] = new SpriteResource(this, spriteData);
-	delete spriteData;
-
-	_sound->playSound(1);
-
-	_files->_setPaletteFlag = false;
-	_files->loadScreen(0, 4);
-	_sound->playSound(1);
-
-	_buffer2.copyFrom(*_screen);
-	_buffer1.copyFrom(*_screen);
-	_sound->playSound(1);
-
-	const int COUNTDOWN[6] = { 2, 0x80, 1, 0x7d, 0, 0x87 };
-	for (_pCount = 0; _pCount < 3; ++_pCount) {
-		_buffer2.copyFrom(_buffer1);
-		int id = COUNTDOWN[_pCount * 2];
-		int xp = COUNTDOWN[_pCount * 2 + 1];
-		_buffer2.plotImage(_objectsTable[0], id, Common::Point(xp, 71));
-		_screen->copyFrom(_buffer2);
-
-		_events->_vbCount = 70;
-		while (!shouldQuit() && _events->_vbCount > 0) {
-			_events->pollEvents();
-			g_system->delayMillis(10);
-		}
-	}
-
-	_sound->playSound(0);
-	_screen->forceFadeOut();
-	_events->_vbCount = 100;
-	while (!shouldQuit() && _events->_vbCount > 0) {
-		_events->pollEvents();
-		g_system->delayMillis(10);
-	}
-
-	_sound->freeSounds();
-	delete _objectsTable[0];
-	_objectsTable[0] = nullptr;
-
-	_files->_setPaletteFlag = false;
-	_files->loadScreen(0, 5);
-	_buffer2.copyFrom(*_screen);
-	_buffer1.copyFrom(*_screen);
-	_screen->forceFadeIn();
-	_sound->newMusic(1, 0);
-	_events->_vbCount = 700;
-	while (!shouldQuit() && (_events->_vbCount > 0) && !_events->isKeyMousePressed()) {
-		_events->pollEvents();
-		g_system->delayMillis(10);
-	}
-
-	if (_events->_rightButton) {
-		_skipStart = true;
-		_room->clearRoom();
-		_events->showCursor();
-		return;
-	}
-
-	_sound->newMusic(1, 1);
-	_sound->_musicRepeat = false;
-	_events->zeroKeys();
-	_room->loadRoom(0);
-	_screen->clearScreen();
-	_screen->setBufferScan();
-	_screen->_scrollRow = _screen->_scrollCol = 0;
-	_screen->_scrollX = _screen->_scrollY = 0;
-	_player->_rawPlayer = Common::Point(0, 0);
-	_screen->forceFadeOut();
-	_screen->_scrollX = 0;
-	_room->buildScreen();
-	copyBF2Vid();
-	_screen->forceFadeIn();
-	_oldRects.clear();
-	_newRects.clear();
-	// KEYFLG = 0;
-	_player->_scrollAmount = 1;
-	_pCount = 0;
-
-	while (!shouldQuit()) {
-		if (!_events->isKeyMousePressed()) {
-			if (_events->_rightButton)
-				_skipStart = true;
-			_room->clearRoom();
-			_events->showCursor();
-			return;
-		}
-
-		_events->_vbCount = 4;
-		if (_screen->_scrollCol + _screen->_vWindowWidth != _room->_playFieldWidth) {
-			_screen->_scrollX += _player->_scrollAmount;
-
-			while (_screen->_scrollX >= TILE_WIDTH) {
-				_screen->_scrollX -= TILE_WIDTH;
-				++_screen->_scrollCol;
-
-				_buffer1.moveBufferLeft();
-				_room->buildColumn(_screen->_scrollCol + _screen->_vWindowWidth, _screen->_vWindowBytesWide);
-			}
-			scrollTitle();
-			++_pCount;
-
-			while (!shouldQuit() && (_events->_vbCount > 0)) {
-				_events->pollEvents();
-				g_system->delayMillis(10);
-			}
-			continue;
-		}
-
-		_events->_vbCount = 120;
-		while (!shouldQuit() && (_events->_vbCount > 0)) {
-			_events->pollEvents();
-			g_system->delayMillis(10);
-		}
-
-		while (!shouldQuit()) {
-			_pCount = 0;
-			_events->_vbCount = 3;
-			if (_screen->_scrollRow + _screen->_vWindowHeight >= _room->_playFieldHeight) {
-				_room->clearRoom();
-				_events->showCursor();
-				return;
-			}
-
-			_screen->_scrollY = _screen->_scrollY + _player->_scrollAmount;
-
-			while (_screen->_scrollY >= TILE_HEIGHT && !shouldQuit()) {
-				_screen->_scrollY -= TILE_HEIGHT;
-				++_screen->_scrollRow;
-				_buffer1.moveBufferUp();
-
-				// WORKAROUND: the original was using _screen->_vWindowBytesWide * _screen->_vWindowLinesTall
-				_room->buildRow(_screen->_scrollRow + _screen->_vWindowHeight, _screen->_vWindowLinesTall);
-
-				if (_screen->_scrollRow + _screen->_vWindowHeight >= _room->_playFieldHeight) {
-					_room->clearRoom();
-					_events->showCursor();
-					return;
-				}
-			}
-			scrollTitle();
-			while (!shouldQuit() && (_events->_vbCount > 0)) {
-				_events->pollEvents();
-				g_system->delayMillis(10);
-			}
-		}
-	}
-}
-
-void AmazonEngine::doTent() {
-	int step = 0;
-	_screen->setDisplayScan();
-	_screen->forceFadeOut();
-	_events->hideCursor();
-	_sound->_soundTable.push_back(SoundEntry(_sound->loadSound(98, 39), 1));
-	_sound->_soundTable.push_back(SoundEntry(_sound->loadSound(98, 14), 1));
-	_sound->_soundTable.push_back(SoundEntry(_sound->loadSound(98, 15), 1));
-	_sound->_soundTable.push_back(SoundEntry(_sound->loadSound(98, 16), 1));
-	_sound->_soundTable.push_back(SoundEntry(_sound->loadSound(98, 31), 2));
-	_sound->_soundTable.push_back(SoundEntry(_sound->loadSound(98, 52), 2));
-	_sound->playSound(0);
-
-	_files->_setPaletteFlag = false;
-	_files->loadScreen(2, 0);
-	_buffer2.copyFrom(*_screen);
-	_buffer1.copyFrom(*_screen);
-	_screen->forceFadeIn();
-
-	_video->setVideo(_screen, Common::Point(126, 73), FileIdent(2, 1), 10);
-	while (!shouldQuit() && !_video->_videoEnd) {
-		_video->playVideo();
-		if ((_video->_videoFrame == 32) || (_video->_videoFrame == 34))
-			_sound->playSound(4);
-		else if (_video->_videoFrame == 36) {
-			if (step != 2) {
-				_sound->playSound(2);
-				step = 2;
-			}
-		} else if (_video->_videoFrame == 18) {
-			if (step != 1) {
-				_sound->newMusic(73, 1);
-				_sound->newMusic(11, 0);
-				step = 1;
-				_sound->playSound(1);
-			}
-		}
-
-		g_system->delayMillis(10);
-		_events->pollEvents();
-	}	
-
-	_sound->playSound(5);
-	_video->setVideo(_screen, Common::Point(43, 11), FileIdent(2, 2), 10);
-	while (!shouldQuit() && !_video->_videoEnd) {
-		_video->playVideo();
-		if (_video->_videoFrame == 26) {
-			_sound->playSound(5);
-		} else if (_video->_videoFrame == 15) {
-			if (step !=3) {
-				_sound->playSound(3);
-				step = 3;
-			}
-		}
-
-		g_system->delayMillis(10);
-		_events->pollEvents();
-	}
-
-	_events->_vbCount = 200;
-	while (!shouldQuit() && _events->_vbCount > 0) {
-		_events->pollEvents();
-		g_system->delayMillis(10);
-	}
-	_events->showCursor();
-	_sound->newMusic(11, 1);
-	_sound->_soundTable.clear();
-
-	establishCenter(0, 4);
-}
-
 void AmazonEngine::setupGame() {
 	// Setup timers
 	const int TIMER_DEFAULTS[] = { 3, 10, 8, 1, 1, 1, 1, 2 };
diff --git a/engines/access/amazon/amazon_game.h b/engines/access/amazon/amazon_game.h
index 016ddf4..ca8287b 100644
--- a/engines/access/amazon/amazon_game.h
+++ b/engines/access/amazon/amazon_game.h
@@ -39,21 +39,6 @@ private:
 	Common::Array<CellIdent> _chapterCells;
 
 	/**
-	 * Do the game introduction
-	 */
-	void doIntroduction();
-
-	/**
-	 * Do title sequence
-	 */
-	void doTitle();
-
-	/**
-	 * Do tent scene of introduction
-	 */
-	void doTent();
-
-	/**
 	 * Setup variables for the game
 	 */
 	void setupGame();
@@ -67,8 +52,6 @@ private:
 	void calcIQ();
 	void helpTitle();
 	void drawHelpText(const Common::String &msg);
-	void doCredit();
-	void scrollTitle();
 	void loadEstablish(int estabIndex);
 	void doEstablish(int screenId, int estabIndex);
 
@@ -85,7 +68,6 @@ protected:
 public:
 	InactivePlayer _inactive;
 	bool _charSegSwitch;
-	bool _skipStart;
 	byte _help1[366];
 	byte _help2[366];
 	byte _help3[366];
diff --git a/engines/access/amazon/amazon_logic.cpp b/engines/access/amazon/amazon_logic.cpp
index 3ecb20d..8db7e9f 100644
--- a/engines/access/amazon/amazon_logic.cpp
+++ b/engines/access/amazon/amazon_logic.cpp
@@ -81,17 +81,18 @@ void PannedScene::pan() {
 
 /*------------------------------------------------------------------------*/
 
-Opening::Opening(AmazonEngine *vm) : PannedScene(vm) {
+CampScene::CampScene(AmazonEngine *vm) : PannedScene(vm) {
+	_skipStart = false;
 }
 
-void Opening::mWhileDoOpen() {
+void CampScene::mWhileDoOpen() {
 	Screen &screen = *_vm->_screen;
 	EventsManager &events = *_vm->_events;
 
 	screen.setBufferScan();
 	events.hideCursor();
 	screen.forceFadeOut();
-	_vm->_skipStart = false;
+	_skipStart = false;
 	if (_vm->_conversation != 2) {
 		// Cutscene at start of chapter 1
 		screen.setPanel(3);
@@ -159,7 +160,7 @@ void Opening::mWhileDoOpen() {
 		events.pollEventsAndWait();
 
 		if (events._leftButton || events._rightButton || events._keypresses.size() > 0) {
-			_vm->_skipStart = true;
+			_skipStart = true;
 			_vm->_sound->newMusic(10, 1);
 
 			events.debounceLeft();
@@ -202,6 +203,319 @@ void Opening::mWhileDoOpen() {
 
 /*------------------------------------------------------------------------*/
 
+Opening::Opening(AmazonEngine *vm) : CampScene(vm) {
+	_pCount = 0;
+}
+
+void Opening::doIntroduction() {
+	_vm->_screen->setInitialPalettte();
+	_vm->_events->setCursor(CURSOR_ARROW);
+	_vm->_events->showCursor();
+	_vm->_screen->setPanel(0);
+	_vm->_screen->setPalette();
+
+	_vm->_events->setCursor(CURSOR_ARROW);
+	_vm->_events->showCursor();
+	_vm->_screen->setPanel(3);
+	doTitle();
+
+	if (_vm->shouldQuit() || _skipStart)
+		return;
+
+	_vm->_screen->setPanel(3);
+	mWhileDoOpen();
+
+	if (_vm->shouldQuit() || _skipStart)
+		return;
+
+	doTent();
+}
+
+void Opening::doCredit() {
+	if (_pCount < 15)
+		return;
+
+	if (_pCount <= 75)
+		_vm->_buffer2.plotImage(_vm->_objectsTable[0], 0, Common::Point(90, 35));
+	else if (_pCount <= 210)
+		_vm->_buffer2.plotImage(_vm->_objectsTable[0], 1, Common::Point(65, 35));
+	else if (_pCount <= 272)
+		_vm->_buffer2.plotImage(_vm->_objectsTable[0], 2, Common::Point(96, 45));
+	else if (_pCount <= 334)
+		_vm->_buffer2.plotImage(_vm->_objectsTable[0], 3, Common::Point(68, 54));
+	else if (_pCount <= 396)
+		_vm->_buffer2.plotImage(_vm->_objectsTable[0], 4, Common::Point(103, 54));
+	else if (_pCount <= 458) {
+		_vm->_buffer2.plotImage(_vm->_objectsTable[0], 5, Common::Point(8, 5));
+		_vm->_buffer2.plotImage(_vm->_objectsTable[0], 12, Common::Point(88, 55));
+		_vm->_buffer2.plotImage(_vm->_objectsTable[0], 6, Common::Point(194, 98));
+	} else if (_pCount <= 520) {
+		_vm->_buffer2.plotImage(_vm->_objectsTable[0], 7, Common::Point(32, 13));
+		_vm->_buffer2.plotImage(_vm->_objectsTable[0], 8, Common::Point(162, 80));
+	} else if (_pCount <= 580) {
+		_vm->_buffer2.plotImage(_vm->_objectsTable[0], 9, Common::Point(18, 15));
+		_vm->_buffer2.plotImage(_vm->_objectsTable[0], 10, Common::Point(164, 81));
+	} else
+		_vm->_buffer2.plotImage(_vm->_objectsTable[0], 11, Common::Point(106, 55));
+}
+
+void Opening::scrollTitle() {
+	_vm->copyBF1BF2();
+	_vm->_newRects.clear();
+	doCredit();
+	_vm->copyRects();
+	_vm->copyBF2Vid();
+}
+
+void Opening::doTitle() {
+	_vm->_screen->setDisplayScan();
+
+	_vm->_screen->forceFadeOut();
+	_vm->_events->hideCursor();
+
+	_vm->_sound->queueSound(0, 98, 30);
+	_vm->_sound->queueSound(1, 98, 8);
+
+	_vm->_files->_setPaletteFlag = false;
+	_vm->_files->loadScreen(0, 3);
+	
+	_vm->_buffer2.copyFrom(*_vm->_screen);
+	_vm->_buffer1.copyFrom(*_vm->_screen);
+	_vm->_screen->forceFadeIn();
+	_vm->_sound->playSound(1);
+
+	// HACK: This delay has been added so that the very first screen is visible.
+	// The original was using disk loading time to display it, and it's too fast
+	// nowadays to be visible.
+	_vm->_events->_vbCount = 70;
+	while (!_vm->shouldQuit() && _vm->_events->_vbCount > 0) {
+		_vm->_events->pollEvents();
+		g_system->delayMillis(10);
+	}
+
+	Resource *spriteData = _vm->_files->loadFile(0, 2);
+	_vm->_objectsTable[0] = new SpriteResource(_vm, spriteData);
+	delete spriteData;
+
+	_vm->_sound->playSound(1);
+
+	_vm->_files->_setPaletteFlag = false;
+	_vm->_files->loadScreen(0, 4);
+	_vm->_sound->playSound(1);
+
+	_vm->_buffer2.copyFrom(*_vm->_screen);
+	_vm->_buffer1.copyFrom(*_vm->_screen);
+	_vm->_sound->playSound(1);
+
+	const int COUNTDOWN[6] = { 2, 0x80, 1, 0x7d, 0, 0x87 };
+	for (_pCount = 0; _pCount < 3; ++_pCount) {
+		_vm->_buffer2.copyFrom(_vm->_buffer1);
+		int id = COUNTDOWN[_pCount * 2];
+		int xp = COUNTDOWN[_pCount * 2 + 1];
+		_vm->_buffer2.plotImage(_vm->_objectsTable[0], id, Common::Point(xp, 71));
+		_vm->_screen->copyFrom(_vm->_buffer2);
+
+		_vm->_events->_vbCount = 70;
+		while (!_vm->shouldQuit() && _vm->_events->_vbCount > 0) {
+			_vm->_events->pollEvents();
+			g_system->delayMillis(10);
+		}
+	}
+
+	_vm->_sound->playSound(0);
+	_vm->_screen->forceFadeOut();
+	_vm->_events->_vbCount = 100;
+	while (!_vm->shouldQuit() && _vm->_events->_vbCount > 0) {
+		_vm->_events->pollEvents();
+		g_system->delayMillis(10);
+	}
+
+	_vm->_sound->freeSounds();
+	delete _vm->_objectsTable[0];
+	_vm->_objectsTable[0] = nullptr;
+
+	_vm->_files->_setPaletteFlag = false;
+	_vm->_files->loadScreen(0, 5);
+	_vm->_buffer2.copyFrom(*_vm->_screen);
+	_vm->_buffer1.copyFrom(*_vm->_screen);
+	_vm->_screen->forceFadeIn();
+	_vm->_sound->newMusic(1, 0);
+	_vm->_events->_vbCount = 700;
+	while (!_vm->shouldQuit() && (_vm->_events->_vbCount > 0) && !_vm->_events->isKeyMousePressed()) {
+		_vm->_events->pollEvents();
+		g_system->delayMillis(10);
+	}
+
+	if (_vm->_events->_rightButton) {
+		_skipStart = true;
+		_vm->_room->clearRoom();
+		_vm->_events->showCursor();
+		return;
+	}
+
+	_vm->_sound->newMusic(1, 1);
+	_vm->_sound->_musicRepeat = false;
+	_vm->_events->zeroKeys();
+	_vm->_room->loadRoom(0);
+	_vm->_screen->clearScreen();
+	_vm->_screen->setBufferScan();
+	_vm->_screen->_scrollRow = _vm->_screen->_scrollCol = 0;
+	_vm->_screen->_scrollX = _vm->_screen->_scrollY = 0;
+	_vm->_player->_rawPlayer = Common::Point(0, 0);
+	_vm->_screen->forceFadeOut();
+	_vm->_screen->_scrollX = 0;
+	_vm->_room->buildScreen();
+	_vm->copyBF2Vid();
+	_vm->_screen->forceFadeIn();
+	_vm->_oldRects.clear();
+	_vm->_newRects.clear();
+	// KEYFLG = 0;
+	_vm->_player->_scrollAmount = 1;
+	_pCount = 0;
+
+	while (!_vm->shouldQuit()) {
+		if (!_vm->_events->isKeyMousePressed()) {
+			if (_vm->_events->_rightButton)
+				_skipStart = true;
+			_vm->_room->clearRoom();
+			_vm->_events->showCursor();
+			return;
+		}
+
+		_vm->_events->_vbCount = 4;
+		if (_vm->_screen->_scrollCol + _vm->_screen->_vWindowWidth != _vm->_room->_playFieldWidth) {
+			_vm->_screen->_scrollX += _vm->_player->_scrollAmount;
+
+			while (_vm->_screen->_scrollX >= TILE_WIDTH) {
+				_vm->_screen->_scrollX -= TILE_WIDTH;
+				++_vm->_screen->_scrollCol;
+
+				_vm->_buffer1.moveBufferLeft();
+				_vm->_room->buildColumn(_vm->_screen->_scrollCol + _vm->_screen->_vWindowWidth, _vm->_screen->_vWindowBytesWide);
+			}
+			scrollTitle();
+			++_pCount;
+
+			while (!_vm->shouldQuit() && (_vm->_events->_vbCount > 0)) {
+				_vm->_events->pollEvents();
+				g_system->delayMillis(10);
+			}
+			continue;
+		}
+
+		_vm->_events->_vbCount = 120;
+		while (!_vm->shouldQuit() && (_vm->_events->_vbCount > 0)) {
+			_vm->_events->pollEvents();
+			g_system->delayMillis(10);
+		}
+
+		while (!_vm->shouldQuit()) {
+			_pCount = 0;
+			_vm->_events->_vbCount = 3;
+			if (_vm->_screen->_scrollRow + _vm->_screen->_vWindowHeight >= _vm->_room->_playFieldHeight) {
+				_vm->_room->clearRoom();
+				_vm->_events->showCursor();
+				return;
+			}
+
+			_vm->_screen->_scrollY = _vm->_screen->_scrollY + _vm->_player->_scrollAmount;
+
+			while (_vm->_screen->_scrollY >= TILE_HEIGHT && !_vm->shouldQuit()) {
+				_vm->_screen->_scrollY -= TILE_HEIGHT;
+				++_vm->_screen->_scrollRow;
+				_vm->_buffer1.moveBufferUp();
+
+				// WORKAROUND: the original was using _vm->_screen->_vWindowBytesWide * _vm->_screen->_vWindowLinesTall
+				_vm->_room->buildRow(_vm->_screen->_scrollRow + _vm->_screen->_vWindowHeight, _vm->_screen->_vWindowLinesTall);
+
+				if (_vm->_screen->_scrollRow + _vm->_screen->_vWindowHeight >= _vm->_room->_playFieldHeight) {
+					_vm->_room->clearRoom();
+					_vm->_events->showCursor();
+					return;
+				}
+			}
+			scrollTitle();
+			while (!_vm->shouldQuit() && (_vm->_events->_vbCount > 0)) {
+				_vm->_events->pollEvents();
+				g_system->delayMillis(10);
+			}
+		}
+	}
+}
+
+void Opening::doTent() {
+	int step = 0;
+	_vm->_screen->setDisplayScan();
+	_vm->_screen->forceFadeOut();
+	_vm->_events->hideCursor();
+	_vm->_sound->_soundTable.push_back(SoundEntry(_vm->_sound->loadSound(98, 39), 1));
+	_vm->_sound->_soundTable.push_back(SoundEntry(_vm->_sound->loadSound(98, 14), 1));
+	_vm->_sound->_soundTable.push_back(SoundEntry(_vm->_sound->loadSound(98, 15), 1));
+	_vm->_sound->_soundTable.push_back(SoundEntry(_vm->_sound->loadSound(98, 16), 1));
+	_vm->_sound->_soundTable.push_back(SoundEntry(_vm->_sound->loadSound(98, 31), 2));
+	_vm->_sound->_soundTable.push_back(SoundEntry(_vm->_sound->loadSound(98, 52), 2));
+	_vm->_sound->playSound(0);
+
+	_vm->_files->_setPaletteFlag = false;
+	_vm->_files->loadScreen(2, 0);
+	_vm->_buffer2.copyFrom(*_vm->_screen);
+	_vm->_buffer1.copyFrom(*_vm->_screen);
+	_vm->_screen->forceFadeIn();
+
+	_vm->_video->setVideo(_vm->_screen, Common::Point(126, 73), FileIdent(2, 1), 10);
+	while (!_vm->shouldQuit() && !_vm->_video->_videoEnd) {
+		_vm->_video->playVideo();
+		if ((_vm->_video->_videoFrame == 32) || (_vm->_video->_videoFrame == 34))
+			_vm->_sound->playSound(4);
+		else if (_vm->_video->_videoFrame == 36) {
+			if (step != 2) {
+				_vm->_sound->playSound(2);
+				step = 2;
+			}
+		} else if (_vm->_video->_videoFrame == 18) {
+			if (step != 1) {
+				_vm->_sound->newMusic(73, 1);
+				_vm->_sound->newMusic(11, 0);
+				step = 1;
+				_vm->_sound->playSound(1);
+			}
+		}
+
+		g_system->delayMillis(10);
+		_vm->_events->pollEvents();
+	}	
+
+	_vm->_sound->playSound(5);
+	_vm->_video->setVideo(_vm->_screen, Common::Point(43, 11), FileIdent(2, 2), 10);
+	while (!_vm->shouldQuit() && !_vm->_video->_videoEnd) {
+		_vm->_video->playVideo();
+		if (_vm->_video->_videoFrame == 26) {
+			_vm->_sound->playSound(5);
+		} else if (_vm->_video->_videoFrame == 15) {
+			if (step !=3) {
+				_vm->_sound->playSound(3);
+				step = 3;
+			}
+		}
+
+		g_system->delayMillis(10);
+		_vm->_events->pollEvents();
+	}
+
+	_vm->_events->_vbCount = 200;
+	while (!_vm->shouldQuit() && _vm->_events->_vbCount > 0) {
+		_vm->_events->pollEvents();
+		g_system->delayMillis(10);
+	}
+	_vm->_events->showCursor();
+	_vm->_sound->newMusic(11, 1);
+	_vm->_sound->_soundTable.clear();
+
+	_vm->establishCenter(0, 4);
+}
+
+/*------------------------------------------------------------------------*/
+
 Plane::Plane(AmazonEngine *vm): PannedScene(vm) {
 	_pCount = 0;
 	_planeCount = 0;
@@ -400,7 +714,7 @@ void Plane::mWhileFall() {
 
 /*------------------------------------------------------------------------*/
 
-Jungle::Jungle(AmazonEngine *vm) : PannedScene(vm) {
+Jungle::Jungle(AmazonEngine *vm) : CampScene(vm) {
 	for (int i = 0; i < JUNGLE_SIZE; ++i) {
 		_jCnt[i] = _jungleX[i] = -1;
 	}
diff --git a/engines/access/amazon/amazon_logic.h b/engines/access/amazon/amazon_logic.h
index 46b3c70..c2752af 100644
--- a/engines/access/amazon/amazon_logic.h
+++ b/engines/access/amazon/amazon_logic.h
@@ -70,13 +70,29 @@ public:
 	void pan();
 };
 
-class Opening: public PannedScene {
+class CampScene : public PannedScene {
+protected:
+	bool _skipStart;
 public:
-	Opening(AmazonEngine *vm);
+	CampScene(AmazonEngine *vm);
 
 	void mWhileDoOpen();
 };
 
+class Opening: public CampScene {
+private:
+	int _pCount;
+
+	void doTitle();
+	void doCredit();
+	void scrollTitle();
+	void doTent();
+public:
+	Opening(AmazonEngine *vm);
+
+	void doIntroduction();
+};
+
 class Plane: public PannedScene {
 public:
 	int _pCount;
@@ -95,7 +111,7 @@ public:
 };
 
 #define JUNGLE_SIZE 3
-class Jungle: public PannedScene {
+class Jungle: public CampScene {
 private:
 	void initJWalk2();
 	void jungleMove();
diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp
index eadcbdd..f38c80c 100644
--- a/engines/access/amazon/amazon_scripts.cpp
+++ b/engines/access/amazon/amazon_scripts.cpp
@@ -220,7 +220,7 @@ void AmazonScripts::mWhile(int param1) {
 		_game->_jungle.mWhileJWalk();
 		break;
 	case 5:
-		_game->_opening.mWhileDoOpen();
+		_game->_jungle.mWhileDoOpen();
 		break;
 	case 6:
 		_game->_river.mWhileDownRiver();
diff --git a/engines/access/martian/martian_game.cpp b/engines/access/martian/martian_game.cpp
index 81a8ffd..e534b6c 100644
--- a/engines/access/martian/martian_game.cpp
+++ b/engines/access/martian/martian_game.cpp
@@ -79,7 +79,7 @@ void MartianEngine::doIntroduction() {
 			return;
 
 		if (!_skipStart) {
-			doTent();
+			//doTent();
 			if (shouldQuit())
 				return;
 		}
@@ -89,6 +89,7 @@ void MartianEngine::doIntroduction() {
 }
 
 void MartianEngine::doTitle() {
+	/*
 	_screen->setDisplayScan();
 	_destIn = &_buffer2;
 
@@ -129,16 +130,13 @@ void MartianEngine::doTitle() {
 	// TODO: More to do
 
 	delete _objectsTable[0];
+	*/
 }
 
 void MartianEngine::doOpening() {
 	warning("TODO doOpening");
 }
 
-void MartianEngine::doTent() {
-	warning("TODO doTent");
-}
-
 void MartianEngine::setupGame() {
 
 	// Setup timers
diff --git a/engines/access/martian/martian_game.h b/engines/access/martian/martian_game.h
index e46b2bb..a83b67a 100644
--- a/engines/access/martian/martian_game.h
+++ b/engines/access/martian/martian_game.h
@@ -49,11 +49,6 @@ private:
 	void doOpening();
 
 	/**
-	 * Do tent scene of introduction
-	 */
-	void doTent();
-
-	/**
 	 * Setup variables for the game
 	 */
 	void setupGame();


Commit: d37593d5c1008995b292a62f473a2a8dfa322cc1
    https://github.com/scummvm/scummvm/commit/d37593d5c1008995b292a62f473a2a8dfa322cc1
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-12T22:53:09-05:00

Commit Message:
ACCESS: Replaced delayMilli calls to use pollEventsAndWait

Changed paths:
    engines/access/amazon/amazon_logic.cpp



diff --git a/engines/access/amazon/amazon_logic.cpp b/engines/access/amazon/amazon_logic.cpp
index 8db7e9f..c62ca57 100644
--- a/engines/access/amazon/amazon_logic.cpp
+++ b/engines/access/amazon/amazon_logic.cpp
@@ -284,14 +284,14 @@ void Opening::doTitle() {
 	_vm->_screen->forceFadeIn();
 	_vm->_sound->playSound(1);
 
-	// HACK: This delay has been added so that the very first screen is visible.
-	// The original was using disk loading time to display it, and it's too fast
+	// WORKAROUND: This delay has been added to replace original game delay that
+	// came from loading resources, since nowadays it would be too fast to be visible
 	// nowadays to be visible.
 	_vm->_events->_vbCount = 70;
-	while (!_vm->shouldQuit() && _vm->_events->_vbCount > 0) {
-		_vm->_events->pollEvents();
-		g_system->delayMillis(10);
-	}
+	while (!_vm->shouldQuit() && _vm->_events->_vbCount > 0)
+		_vm->_events->pollEventsAndWait();
+	if (_vm->shouldQuit())
+		return;
 
 	Resource *spriteData = _vm->_files->loadFile(0, 2);
 	_vm->_objectsTable[0] = new SpriteResource(_vm, spriteData);
@@ -308,7 +308,7 @@ void Opening::doTitle() {
 	_vm->_sound->playSound(1);
 
 	const int COUNTDOWN[6] = { 2, 0x80, 1, 0x7d, 0, 0x87 };
-	for (_pCount = 0; _pCount < 3; ++_pCount) {
+	for (_pCount = 0; _pCount < 3 && !_vm->shouldQuit(); ++_pCount) {
 		_vm->_buffer2.copyFrom(_vm->_buffer1);
 		int id = COUNTDOWN[_pCount * 2];
 		int xp = COUNTDOWN[_pCount * 2 + 1];
@@ -316,19 +316,19 @@ void Opening::doTitle() {
 		_vm->_screen->copyFrom(_vm->_buffer2);
 
 		_vm->_events->_vbCount = 70;
-		while (!_vm->shouldQuit() && _vm->_events->_vbCount > 0) {
-			_vm->_events->pollEvents();
-			g_system->delayMillis(10);
-		}
+		while (!_vm->shouldQuit() && _vm->_events->_vbCount > 0)
+			_vm->_events->pollEventsAndWait();
 	}
+	if (_vm->shouldQuit())
+		return;
 
 	_vm->_sound->playSound(0);
 	_vm->_screen->forceFadeOut();
 	_vm->_events->_vbCount = 100;
-	while (!_vm->shouldQuit() && _vm->_events->_vbCount > 0) {
-		_vm->_events->pollEvents();
-		g_system->delayMillis(10);
-	}
+	while (!_vm->shouldQuit() && _vm->_events->_vbCount > 0)
+		_vm->_events->pollEventsAndWait();
+	if (_vm->shouldQuit())
+		return;
 
 	_vm->_sound->freeSounds();
 	delete _vm->_objectsTable[0];
@@ -342,8 +342,7 @@ void Opening::doTitle() {
 	_vm->_sound->newMusic(1, 0);
 	_vm->_events->_vbCount = 700;
 	while (!_vm->shouldQuit() && (_vm->_events->_vbCount > 0) && !_vm->_events->isKeyMousePressed()) {
-		_vm->_events->pollEvents();
-		g_system->delayMillis(10);
+		_vm->_events->pollEventsAndWait();
 	}
 
 	if (_vm->_events->_rightButton) {
@@ -397,17 +396,14 @@ void Opening::doTitle() {
 			++_pCount;
 
 			while (!_vm->shouldQuit() && (_vm->_events->_vbCount > 0)) {
-				_vm->_events->pollEvents();
-				g_system->delayMillis(10);
+				_vm->_events->pollEventsAndWait();
 			}
 			continue;
 		}
 
 		_vm->_events->_vbCount = 120;
-		while (!_vm->shouldQuit() && (_vm->_events->_vbCount > 0)) {
-			_vm->_events->pollEvents();
-			g_system->delayMillis(10);
-		}
+		while (!_vm->shouldQuit() && (_vm->_events->_vbCount > 0))
+			_vm->_events->pollEventsAndWait();
 
 		while (!_vm->shouldQuit()) {
 			_pCount = 0;
@@ -435,10 +431,8 @@ void Opening::doTitle() {
 				}
 			}
 			scrollTitle();
-			while (!_vm->shouldQuit() && (_vm->_events->_vbCount > 0)) {
-				_vm->_events->pollEvents();
-				g_system->delayMillis(10);
-			}
+			while (!_vm->shouldQuit() && (_vm->_events->_vbCount > 0))
+				_vm->_events->pollEventsAndWait();
 		}
 	}
 }
@@ -481,8 +475,7 @@ void Opening::doTent() {
 			}
 		}
 
-		g_system->delayMillis(10);
-		_vm->_events->pollEvents();
+		_vm->_events->pollEventsAndWait();
 	}	
 
 	_vm->_sound->playSound(5);
@@ -498,15 +491,13 @@ void Opening::doTent() {
 			}
 		}
 
-		g_system->delayMillis(10);
-		_vm->_events->pollEvents();
+		_vm->_events->pollEventsAndWait();
 	}
 
 	_vm->_events->_vbCount = 200;
-	while (!_vm->shouldQuit() && _vm->_events->_vbCount > 0) {
-		_vm->_events->pollEvents();
-		g_system->delayMillis(10);
-	}
+	while (!_vm->shouldQuit() && _vm->_events->_vbCount > 0)
+		_vm->_events->pollEventsAndWait();
+
 	_vm->_events->showCursor();
 	_vm->_sound->newMusic(11, 1);
 	_vm->_sound->_soundTable.clear();


Commit: 63bcd2ebcbe8063e5009fb27ed2d1aaa08bf28a1
    https://github.com/scummvm/scummvm/commit/63bcd2ebcbe8063e5009fb27ed2d1aaa08bf28a1
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-12T22:53:22-05:00

Commit Message:
ACCESS: Remove second character sprite in Dead command

Changed paths:
    engines/access/amazon/amazon_game.cpp
    engines/access/player.cpp
    engines/access/player.h



diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp
index dfaba97..b665c49 100644
--- a/engines/access/amazon/amazon_game.cpp
+++ b/engines/access/amazon/amazon_game.cpp
@@ -654,6 +654,9 @@ void AmazonEngine::dead(int deathId) {
 		_room->clearRoom();
 		freeChar();
 
+		_currentManOld = 1;
+		_player->removeSprite1();
+
 		warning("TODO: restart game");
 		quitGame();
 		_events->pollEvents();
diff --git a/engines/access/player.cpp b/engines/access/player.cpp
index 2313ed2..cb7459e 100644
--- a/engines/access/player.cpp
+++ b/engines/access/player.cpp
@@ -137,6 +137,13 @@ void Player::freeSprites() {
 	_playerSprites = nullptr;
 }
 
+void Player::removeSprite1() {
+	if (_playerSprites1) {
+		delete _playerSprites1;
+		_playerSprites1 = nullptr;
+	}
+}
+
 void Player::calcManScale() {
 	if (!_vm->_manScaleOff) {
 		_vm->_scale = ((((_rawPlayer.y - _vm->_scaleMaxY + _vm->_scaleN1) * 
diff --git a/engines/access/player.h b/engines/access/player.h
index 67908a3..631452f 100644
--- a/engines/access/player.h
+++ b/engines/access/player.h
@@ -120,6 +120,8 @@ public:
 
 	void freeSprites();
 
+	void removeSprite1();
+
 	void calcManScale();
 
 	void walk();


Commit: a3801df5187cb2500e72b74d37c6bccdbff1f8c5
    https://github.com/scummvm/scummvm/commit/a3801df5187cb2500e72b74d37c6bccdbff1f8c5
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-12T22:53:31-05:00

Commit Message:
ACCESS: First implementation of Sound playback for both CD and Floppy version. Courtesy of m_kiewitz

Changed paths:
    engines/access/sound.cpp



diff --git a/engines/access/sound.cpp b/engines/access/sound.cpp
index 6d42cd5..fdc606b 100644
--- a/engines/access/sound.cpp
+++ b/engines/access/sound.cpp
@@ -21,7 +21,10 @@
  */
 
 #include "common/algorithm.h"
+#include "audio/mixer.h"
 #include "audio/audiostream.h"
+#include "audio/decoders/raw.h"
+#include "audio/decoders/wave.h"
 #include "access/access.h"
 #include "access/sound.h"
 
@@ -49,11 +52,14 @@ void SoundManager::clearSounds() {
 }
 
 void SoundManager::queueSound(int idx, int fileNum, int subfile) {
+	Resource *soundResource;
+
 	if (idx >= (int)_soundTable.size())
 		_soundTable.resize(idx + 1);
 
 	delete _soundTable[idx]._res;
-	_soundTable[idx]._res = _vm->_files->loadFile(fileNum, subfile);
+	soundResource = _vm->_files->loadFile(fileNum, subfile);
+	_soundTable[idx]._res = soundResource;
 	_soundTable[idx]._priority = 1;
 }
 
@@ -67,6 +73,54 @@ void SoundManager::playSound(int soundIndex) {
 }
 
 void SoundManager::playSound(Resource *res, int priority) {
+	byte *resourceData = res->data();
+	Audio::SoundHandle audioHandle;
+	Audio::RewindableAudioStream *audioStream = 0;
+	
+	assert(res->_size >= 32);
+
+	if (READ_BE_UINT32(resourceData) == MKTAG('R','I','F','F')) {
+		// CD version uses WAVE-files
+		Common::SeekableReadStream *waveStream = new Common::MemoryReadStream(resourceData, res->_size, DisposeAfterUse::NO);
+		audioStream = Audio::makeWAVStream(waveStream, DisposeAfterUse::YES);
+
+	} else if (READ_BE_UINT32(resourceData) == MKTAG('S', 'T', 'E', 'V')) {
+		// sound files have a fixed header of 32 bytes in total
+		//  header content:
+		//   "STEVE" - fixed header
+		//   byte    - sample rate
+		//              01h mapped internally to 3Ch ??
+		//              02h mapped internally to 78h seems to be 11025Hz
+		//              03h mapped internally to B5h
+		//              04h mapped internally to F1h
+		//   byte    - unknown
+		//   word    - actual sample size (should be resource-size - 32)
+		byte internalSampleRate = resourceData[5];
+		int sampleSize = READ_LE_UINT16(resourceData + 7);
+	
+		assert( (sampleSize + 32) == res->_size);
+
+		int sampleRate = 0;
+		switch (internalSampleRate) {
+		case 1: sampleRate = 16666; break; // 3Ch -> C4h time constant
+		case 2: sampleRate = 8334; break;  // 78h -> 88h time constant
+		case 3: sampleRate = 5525; break;  // B5h -> 4Bh time constant
+		case 4: sampleRate = 4150; break;  // F1h -> 0Fh time constant
+		default:
+			error("Unexpected internal Sample Rate %d", internalSampleRate);
+			return;
+		}
+	
+		audioStream = Audio::makeRawStream(resourceData + 32, sampleSize, sampleRate, 0);
+
+	} else
+		error("Unknown format");
+	
+	audioHandle = Audio::SoundHandle();
+	_mixer->playStream(Audio::Mixer::kSFXSoundType, &audioHandle,
+						audioStream, -1, _mixer->kMaxChannelVolume, 0,
+						DisposeAfterUse::NO);
+
 	/*
 	Audio::QueuingAudioStream *audioStream = Audio::makeQueuingAudioStream(22050, false);
 	audioStream->queueBuffer(data, size, DisposeAfterUse::YES, 0);


Commit: 11e920f427312c496b080c280dca7a9eb8b75676
    https://github.com/scummvm/scummvm/commit/11e920f427312c496b080c280dca7a9eb8b75676
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-12T22:53:43-05:00

Commit Message:
ACCESS: Split SoundManager and MusicManager

Changed paths:
    engines/access/access.cpp
    engines/access/access.h
    engines/access/amazon/amazon_game.cpp
    engines/access/amazon/amazon_logic.cpp
    engines/access/amazon/amazon_scripts.cpp
    engines/access/room.cpp
    engines/access/scripts.cpp
    engines/access/sound.cpp
    engines/access/sound.h



diff --git a/engines/access/access.cpp b/engines/access/access.cpp
index bac1308..b0b28f6 100644
--- a/engines/access/access.cpp
+++ b/engines/access/access.cpp
@@ -100,6 +100,7 @@ AccessEngine::~AccessEngine() {
 	delete _events;
 	delete _files;
 	delete _inventory;
+	delete _midi;
 	delete _player;
 	delete _room;
 	delete _screen;
@@ -150,6 +151,7 @@ void AccessEngine::initialize() {
 	_player = Player::init(this);
 	_screen = new Screen(this);
 	_sound = new SoundManager(this, _mixer);
+	_midi = new MusicManager(this, _mixer);
 	_video = new VideoPlayer(this);
 
 	_buffer1.create(g_system->getWidth() + TILE_WIDTH, g_system->getHeight());
diff --git a/engines/access/access.h b/engines/access/access.h
index af0d423..da10d63 100644
--- a/engines/access/access.h
+++ b/engines/access/access.h
@@ -150,6 +150,7 @@ public:
 	Screen *_screen;
 	Scripts *_scripts;
 	SoundManager *_sound;
+	MusicManager *_midi;
 	VideoPlayer *_video;
 
 	ASurface *_destIn;
diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp
index b665c49..ba8b156 100644
--- a/engines/access/amazon/amazon_game.cpp
+++ b/engines/access/amazon/amazon_game.cpp
@@ -450,7 +450,7 @@ void AmazonEngine::startChapter(int chapter) {
 		_room->clearRoom();
 		freeChar();
 		
-		_sound->newMusic(32, 0);
+		_midi->newMusic(32, 0);
 		playVideo(0, Common::Point());
 		if (shouldQuit())
 			return;
@@ -508,8 +508,8 @@ void AmazonEngine::startChapter(int chapter) {
 	if (chapter == 14)
 		_screen->plotImage(_objectsTable[_chapter], 1, Common::Point(169, 76));
 
-	_sound->newMusic(chapImg[4], 1);
-	_sound->newMusic(33, 0);
+	_midi->newMusic(chapImg[4], 1);
+	_midi->newMusic(33, 0);
 	_screen->forceFadeIn();
 
 	_timers[20]._timer = 950;
@@ -534,8 +534,8 @@ void AmazonEngine::startChapter(int chapter) {
 	_buffer2.copyFrom(*_screen);
 	_screen->plotImage(_objectsTable[0], chapImg[0], Common::Point(90, 7));
 
-	_sound->newMusic(7, 1);
-	_sound->newMusic(34, 0);
+	_midi->newMusic(7, 1);
+	_midi->newMusic(34, 0);
 
 	_screen->forceFadeIn();
 	_buffer2.copyFrom(*_screen);
@@ -567,7 +567,7 @@ void AmazonEngine::startChapter(int chapter) {
 	_screen->clearBuffer();
 	freeCells();
 	
-	_sound->newMusic(_chapter * 2, 1);
+	_midi->newMusic(_chapter * 2, 1);
 
 	if (chapter != 1 && chapter != 14) {
 		_room->init4Quads();
@@ -607,7 +607,7 @@ void AmazonEngine::dead(int deathId) {
 	_screen->setPanel(3);
 
 	if (deathId != 10) {
-		_sound->newMusic(62, 0);
+		_midi->newMusic(62, 0);
 		_files->_setPaletteFlag = false;
 		_files->loadScreen(94, 0);
 		_files->_setPaletteFlag = true;
@@ -649,7 +649,7 @@ void AmazonEngine::dead(int deathId) {
 		printText(_screen, msg);
 		_screen->forceFadeOut();
 
-		_sound->newMusic(0, 1);
+		_midi->newMusic(0, 1);
 		_events->showCursor();
 		_room->clearRoom();
 		freeChar();
diff --git a/engines/access/amazon/amazon_logic.cpp b/engines/access/amazon/amazon_logic.cpp
index c62ca57..c330429 100644
--- a/engines/access/amazon/amazon_logic.cpp
+++ b/engines/access/amazon/amazon_logic.cpp
@@ -140,7 +140,7 @@ void CampScene::mWhileDoOpen() {
 	_vm->_animation->setAnimTimer(anim);
 	anim = _vm->_animation->setAnimation(1);
 	_vm->_animation->setAnimTimer(anim);
-	_vm->_sound->newMusic(10, 0);
+	_vm->_midi->newMusic(10, 0);
 
 	bool startFl = false;
 	while (!_vm->shouldQuit()) {
@@ -161,7 +161,7 @@ void CampScene::mWhileDoOpen() {
 
 		if (events._leftButton || events._rightButton || events._keypresses.size() > 0) {
 			_skipStart = true;
-			_vm->_sound->newMusic(10, 1);
+			_vm->_midi->newMusic(10, 1);
 
 			events.debounceLeft();
 			events.zeroKeys();
@@ -339,7 +339,7 @@ void Opening::doTitle() {
 	_vm->_buffer2.copyFrom(*_vm->_screen);
 	_vm->_buffer1.copyFrom(*_vm->_screen);
 	_vm->_screen->forceFadeIn();
-	_vm->_sound->newMusic(1, 0);
+	_vm->_midi->newMusic(1, 0);
 	_vm->_events->_vbCount = 700;
 	while (!_vm->shouldQuit() && (_vm->_events->_vbCount > 0) && !_vm->_events->isKeyMousePressed()) {
 		_vm->_events->pollEventsAndWait();
@@ -352,8 +352,8 @@ void Opening::doTitle() {
 		return;
 	}
 
-	_vm->_sound->newMusic(1, 1);
-	_vm->_sound->_musicRepeat = false;
+	_vm->_midi->newMusic(1, 1);
+	_vm->_midi->_musicRepeat = false;
 	_vm->_events->zeroKeys();
 	_vm->_room->loadRoom(0);
 	_vm->_screen->clearScreen();
@@ -468,8 +468,8 @@ void Opening::doTent() {
 			}
 		} else if (_vm->_video->_videoFrame == 18) {
 			if (step != 1) {
-				_vm->_sound->newMusic(73, 1);
-				_vm->_sound->newMusic(11, 0);
+				_vm->_midi->newMusic(73, 1);
+				_vm->_midi->newMusic(11, 0);
 				step = 1;
 				_vm->_sound->playSound(1);
 			}
@@ -499,7 +499,7 @@ void Opening::doTent() {
 		_vm->_events->pollEventsAndWait();
 
 	_vm->_events->showCursor();
-	_vm->_sound->newMusic(11, 1);
+	_vm->_midi->newMusic(11, 1);
 	_vm->_sound->_soundTable.clear();
 
 	_vm->establishCenter(0, 4);
@@ -1262,7 +1262,7 @@ void Cast::doCast(int param1) {
 	_vm->_newRects.clear();
 	_vm->_numAnimTimers = 0;
 
-	_vm->_sound->newMusic(58, 0);
+	_vm->_midi->newMusic(58, 0);
 	_vm->_screen->forceFadeIn();
 
 	while (!_vm->shouldQuit()) {
@@ -1284,14 +1284,14 @@ void Cast::doCast(int param1) {
 				_vm->_events->pollEventsAndWait();
 			}
 
-			while (!_vm->shouldQuit() && !_vm->_sound->checkMidiDone())
+			while (!_vm->shouldQuit() && !_vm->_midi->checkMidiDone())
 				_vm->_events->pollEventsAndWait();
 
 			break;
 		}
 	}
 
-	_vm->_sound->newMusic(58, 1);
+	_vm->_midi->newMusic(58, 1);
 	_vm->_events->showCursor();
 
 	_vm->freeCells();
@@ -1787,7 +1787,7 @@ void River::river() {
 
 		//		int bx = _vm->_player->_scrollAmount - _screenVertX;
 		if (_vm->_screen->_scrollX == 0) {
-			_vm->_sound->midiRepeat();
+			_vm->_midi->midiRepeat();
 			if (riverJumpTest()) {
 				_CHICKENOUTFLG = false;
 				return;
diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp
index f38c80c..da43f1b 100644
--- a/engines/access/amazon/amazon_scripts.cpp
+++ b/engines/access/amazon/amazon_scripts.cpp
@@ -333,7 +333,7 @@ void AmazonScripts::executeSpecial(int commandIndex, int param1, int param2) {
 		_game->_guard.doGuard();
 		break;
 	case 10:
-		_vm->_sound->newMusic(param1, param2);
+		_vm->_midi->newMusic(param1, param2);
 		break;
 	case 11:
 		plotInactive();
diff --git a/engines/access/room.cpp b/engines/access/room.cpp
index b9ce069..7ef3d69 100644
--- a/engines/access/room.cpp
+++ b/engines/access/room.cpp
@@ -86,7 +86,7 @@ void Room::doRoom() {
 			g_system->delayMillis(5);
 
 			_vm->_player->walk();
-			_vm->_sound->midiRepeat();
+			_vm->_midi->midiRepeat();
 			_vm->_player->checkScroll();
 
 			doCommands();
@@ -150,10 +150,10 @@ void Room::doRoom() {
 }
 
 void Room::clearRoom() {
-	if (_vm->_sound->_music) {
-		_vm->_sound->stopSong();
-		delete _vm->_sound->_music;
-		_vm->_sound->_music = nullptr;
+	if (_vm->_midi->_music) {
+		_vm->_midi->stopSong();
+		delete _vm->_midi->_music;
+		_vm->_midi->_music = nullptr;
 	}
 
 	_vm->_sound->freeSounds();
@@ -181,11 +181,11 @@ void Room::loadRoomData(const byte *roomData) {
 		}
 	}
 
-	_vm->_sound->freeMusic();
+	_vm->_midi->freeMusic();
 	if (roomInfo._musicFile._fileNum != -1) {
-		_vm->_sound->_music = _vm->_files->loadFile(roomInfo._musicFile);
-		_vm->_sound->midiPlay();
-		_vm->_sound->_musicRepeat = true;
+		_vm->_midi->_music = _vm->_files->loadFile(roomInfo._musicFile);
+		_vm->_midi->midiPlay();
+		_vm->_midi->_musicRepeat = true;
 	}
 
 	_vm->_scaleH1 = roomInfo._scaleH1;
diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp
index add461e..2c32f59 100644
--- a/engines/access/scripts.cpp
+++ b/engines/access/scripts.cpp
@@ -679,7 +679,7 @@ void Scripts::cmdWait() {
 	while (!_vm->shouldQuit() && _vm->_events->_keypresses.empty() &&
 			!_vm->_events->_leftButton && !_vm->_events->_rightButton &&
 			_vm->_timers[3]._flag) {
-		_vm->_sound->midiRepeat();
+		_vm->_midi->midiRepeat();
 		charLoop();
 
 		_vm->_events->pollEvents();
diff --git a/engines/access/sound.cpp b/engines/access/sound.cpp
index fdc606b..7d18859 100644
--- a/engines/access/sound.cpp
+++ b/engines/access/sound.cpp
@@ -32,17 +32,12 @@ namespace Access {
 
 SoundManager::SoundManager(AccessEngine *vm, Audio::Mixer *mixer) : 
 		_vm(vm), _mixer(mixer) {
-	_music = nullptr;
-	_tempMusic = nullptr;
-	_musicRepeat = false;
 	_playingSound = false;
 	_isVoice = false;
 }
 
 SoundManager::~SoundManager() {
 	clearSounds();
-	delete _music;
-	delete _tempMusic;
 }
 
 void SoundManager::clearSounds() {
@@ -138,33 +133,51 @@ void SoundManager::loadSounds(Common::Array<RoomInfo::SoundIdent> &sounds) {
 	}
 }
 
-void SoundManager::midiPlay() {
-	// TODO
+void SoundManager::stopSound() {
+	// TODO: REALSTOPSND or BLASTSTOPSND or STOP_SOUNDG
+	warning("TODO: stopSound");
+}
+
+void SoundManager::freeSounds() {
+	stopSound();
+	clearSounds();
+}
+
+/******************************************************************************************/
+
+MusicManager::MusicManager(AccessEngine *vm, Audio::Mixer *mixer) : _vm(vm), _mixer(mixer) {
+	_music = nullptr;
+	_tempMusic = nullptr;
+	_musicRepeat = false;
+}
+
+MusicManager::~MusicManager() {
+	delete _music;
+	delete _tempMusic;
 }
 
-bool SoundManager::checkMidiDone() {
+void MusicManager::midiPlay() {
 	// TODO
-	return true;
 }
 
-void SoundManager::midiRepeat() {
+bool MusicManager::checkMidiDone() {
 	// TODO
+	return true;
 }
 
-void SoundManager::stopSong() {
+void MusicManager::midiRepeat() {
 	// TODO
 }
 
-void SoundManager::stopSound() {
-	// TODO: REALSTOPSND or BLASTSTOPSND or STOP_SOUNDG
+void MusicManager::stopSong() {
+	// TODO
 }
 
-void SoundManager::freeSounds() {
-	stopSound();
-	clearSounds();
+Resource *MusicManager::loadMusic(int fileNum, int subfile) {
+	return _vm->_files->loadFile(fileNum, subfile);
 }
 
-void SoundManager::newMusic(int musicId, int mode) {
+void MusicManager::newMusic(int musicId, int mode) {
 	if (mode == 1) {
 		stopSong();
 		freeMusic();
@@ -177,11 +190,11 @@ void SoundManager::newMusic(int musicId, int mode) {
 		_musicRepeat = (mode == 2);
 		_tempMusic = _music;
 		stopSong();
-		_music = loadSound(97, musicId);
+		_music = loadMusic(97, musicId);
 	}
 }
 
-void SoundManager::freeMusic() {
+void MusicManager::freeMusic() {
 	delete _music;
 	_music = nullptr;
 }
diff --git a/engines/access/sound.h b/engines/access/sound.h
index 46e3b23..b14ce7c 100644
--- a/engines/access/sound.h
+++ b/engines/access/sound.h
@@ -54,9 +54,6 @@ private:
 
 public:
 	Common::Array<SoundEntry> _soundTable;
-	Resource *_music;
-	Resource *_tempMusic;
-	bool _musicRepeat;
 	bool _playingSound;
 	bool _isVoice;
 public:
@@ -70,6 +67,25 @@ public:
 	Resource *loadSound(int fileNum, int subfile);
 	void loadSounds(Common::Array<RoomInfo::SoundIdent> &sounds);
 
+	void freeSounds();
+};
+
+class MusicManager {
+private:
+	AccessEngine *_vm;
+	Audio::Mixer *_mixer;
+
+	Resource *loadMusic(int fileNum, int subfile);
+
+public:
+	Resource *_music;
+	Resource *_tempMusic;
+	bool _musicRepeat;
+	bool _playingSound;
+public:
+	MusicManager(AccessEngine *vm, Audio::Mixer *mixer);
+	~MusicManager();
+
 	void midiPlay();
 
 	bool checkMidiDone();
@@ -78,13 +94,10 @@ public:
 
 	void stopSong();
 
-	void freeSounds();
-
 	void newMusic(int musicId, int mode);
 
 	void freeMusic();
 };
-
 } // End of namespace Access
 
 #endif /* ACCESS_SOUND_H*/


Commit: 0277d1654d23fa92d09bfb6486d0b7a9514e6403
    https://github.com/scummvm/scummvm/commit/0277d1654d23fa92d09bfb6486d0b7a9514e6403
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-12T22:53:55-05:00

Commit Message:
ACCESS: Remove two unused variables

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



diff --git a/engines/access/access.cpp b/engines/access/access.cpp
index b0b28f6..6111ec7 100644
--- a/engines/access/access.cpp
+++ b/engines/access/access.cpp
@@ -53,8 +53,6 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc)
 	_mouseMode = 0;
 	_currentMan = 0;
 	_currentManOld = -1;
-	_music = nullptr;
-	_title = nullptr;
 	_converseMode = 0;
 	_startAboutBox = 0;
 	_startTravelBox = 0;
@@ -109,8 +107,6 @@ AccessEngine::~AccessEngine() {
 	delete _video;
 
 	freeCells();
-	delete _music;
-	delete _title;
 	delete _eseg;
 }
 
diff --git a/engines/access/access.h b/engines/access/access.h
index da10d63..2fdf619 100644
--- a/engines/access/access.h
+++ b/engines/access/access.h
@@ -177,8 +177,6 @@ public:
 	int _mouseMode;
 
 	int _currentManOld;
-	Resource *_music;
-	Resource *_title;
 	int _converseMode;
 	int _startAboutBox;
 	int _startTravelBox;


Commit: 9604da9da3fad69daca3604de618f5c91c293850
    https://github.com/scummvm/scummvm/commit/9604da9da3fad69daca3604de618f5c91c293850
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-12T22:54:08-05:00

Commit Message:
ACCESS: Rename _Eseg

Changed paths:
    engines/access/access.cpp
    engines/access/access.h
    engines/access/amazon/amazon_game.cpp



diff --git a/engines/access/access.cpp b/engines/access/access.cpp
index 6111ec7..41706fc 100644
--- a/engines/access/access.cpp
+++ b/engines/access/access.cpp
@@ -68,7 +68,7 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc)
 	_scaleI = 0;
 	_imgUnscaled = false;
 	_canSaveLoad = false;
-	_eseg = nullptr;
+	_establish = nullptr;
 
 	_conversation = 0;
 	_currentMan = 0;
@@ -107,7 +107,7 @@ AccessEngine::~AccessEngine() {
 	delete _video;
 
 	freeCells();
-	delete _eseg;
+	delete _establish;
 }
 
 void AccessEngine::setVGA() {
diff --git a/engines/access/access.h b/engines/access/access.h
index 2fdf619..eacdae9 100644
--- a/engines/access/access.h
+++ b/engines/access/access.h
@@ -191,7 +191,7 @@ public:
 	bool _imgUnscaled;
 	bool _canSaveLoad;
 
-	Resource *_eseg;
+	Resource *_establish;
 	int _et;
 	int _printEnd;
 	int _txtPages;
diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp
index ba8b156..5b27eb2 100644
--- a/engines/access/amazon/amazon_game.cpp
+++ b/engines/access/amazon/amazon_game.cpp
@@ -165,26 +165,26 @@ void AmazonEngine::loadEstablish(int estabIndex) {
 		int oldGroup = _establishGroup;
 		_establishGroup = 0;
 
-		_eseg = _files->loadFile(_estTable[oldGroup]);
-		_establishCtrlTblOfs = READ_LE_UINT16(_eseg->data());
+		_establish = _files->loadFile(_estTable[oldGroup]);
+		_establishCtrlTblOfs = READ_LE_UINT16(_establish->data());
 
 		int ofs = _establishCtrlTblOfs + (estabIndex * 2);
-		int idx = READ_LE_UINT16(_eseg->data() + ofs);
-		_narateFile = READ_LE_UINT16(_eseg->data() + idx);
-		_txtPages = READ_LE_UINT16(_eseg->data() + idx + 2);
+		int idx = READ_LE_UINT16(_establish->data() + ofs);
+		_narateFile = READ_LE_UINT16(_establish->data() + idx);
+		_txtPages = READ_LE_UINT16(_establish->data() + idx + 2);
 
 		if (!_txtPages)
 			return;
 
-		_sndSubFile = READ_LE_UINT16(_eseg->data() + idx + 4);
+		_sndSubFile = READ_LE_UINT16(_establish->data() + idx + 4);
 		for (int i = 0; i < _txtPages; ++i)
-			_countTbl[i] = READ_LE_UINT16(_eseg->data() + idx + 6 + (2 * i));
+			_countTbl[i] = READ_LE_UINT16(_establish->data() + idx + 6 + (2 * i));
 	} else {
 		_establishGroup = 0;
 		_narateFile = 0;
 		_txtPages = 0;
 		_sndSubFile = 0;
-		_eseg = _files->loadFile("ETEXT.DAT");
+		_establish = _files->loadFile("ETEXT.DAT");
 	}
 }
 
@@ -212,10 +212,10 @@ void AmazonEngine::doEstablish(int screenId, int estabIndex) {
 	_screen->_printOrg = _screen->_printStart = Common::Point(48, 35);
 	loadEstablish(estabIndex);
 	_et = estabIndex;
-	uint16 msgOffset = READ_LE_UINT16(_eseg->data() + (estabIndex * 2) + 2);
+	uint16 msgOffset = READ_LE_UINT16(_establish->data() + (estabIndex * 2) + 2);
 
 	_printEnd = 155;
-	Common::String msg((const char *)_eseg->data() + msgOffset);
+	Common::String msg((const char *)_establish->data() + msgOffset);
 
 	if (_txtPages == 0) {
 		printText(_screen, msg);
@@ -226,8 +226,8 @@ void AmazonEngine::doEstablish(int screenId, int estabIndex) {
 	_screen->forceFadeOut();
 	_screen->clearScreen();
 
-	delete _eseg;
-	_eseg = nullptr;
+	delete _establish;
+	_establish = nullptr;
 
 	if (_establishMode == 0)
 		_room->init4Quads();
@@ -550,10 +550,10 @@ void AmazonEngine::startChapter(int chapter) {
 
 	_establishGroup = 1;
 	loadEstablish(0x40 + _chapter);
-	uint16 msgOffset = READ_LE_UINT16(_eseg->data() + ((0x40 + _chapter) * 2) + 2);
+	uint16 msgOffset = READ_LE_UINT16(_establish->data() + ((0x40 + _chapter) * 2) + 2);
 	_printEnd = 170;
 
-	Common::String msg((const char *)_eseg->data() + msgOffset);
+	Common::String msg((const char *)_establish->data() + msgOffset);
 
 	if (_txtPages == 0) {
 		printText(_screen, msg);


Commit: 6e8f29c15b433e517b06c17fc63d082e7c5069d9
    https://github.com/scummvm/scummvm/commit/6e8f29c15b433e517b06c17fc63d082e7c5069d9
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-12T22:54:20-05:00

Commit Message:
ACCESS: Implement stopSound

Changed paths:
    engines/access/sound.cpp



diff --git a/engines/access/sound.cpp b/engines/access/sound.cpp
index 7d18859..a24dd1a 100644
--- a/engines/access/sound.cpp
+++ b/engines/access/sound.cpp
@@ -134,8 +134,7 @@ void SoundManager::loadSounds(Common::Array<RoomInfo::SoundIdent> &sounds) {
 }
 
 void SoundManager::stopSound() {
-	// TODO: REALSTOPSND or BLASTSTOPSND or STOP_SOUNDG
-	warning("TODO: stopSound");
+	_mixer->stopHandle(Audio::SoundHandle());
 }
 
 void SoundManager::freeSounds() {


Commit: f364782d05cf0772bf2eaa71ea418650e0d9bf27
    https://github.com/scummvm/scummvm/commit/f364782d05cf0772bf2eaa71ea418650e0d9bf27
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-12T22:54:42-05:00

Commit Message:
ACCESS: Some rework in MusicManager

Changed paths:
    engines/access/room.cpp
    engines/access/sound.cpp
    engines/access/sound.h



diff --git a/engines/access/room.cpp b/engines/access/room.cpp
index 7ef3d69..8ef61a9 100644
--- a/engines/access/room.cpp
+++ b/engines/access/room.cpp
@@ -152,8 +152,7 @@ void Room::doRoom() {
 void Room::clearRoom() {
 	if (_vm->_midi->_music) {
 		_vm->_midi->stopSong();
-		delete _vm->_midi->_music;
-		_vm->_midi->_music = nullptr;
+		_vm->_midi->freeMusic();
 	}
 
 	_vm->_sound->freeSounds();
@@ -183,7 +182,7 @@ void Room::loadRoomData(const byte *roomData) {
 
 	_vm->_midi->freeMusic();
 	if (roomInfo._musicFile._fileNum != -1) {
-		_vm->_midi->_music = _vm->_files->loadFile(roomInfo._musicFile);
+		_vm->_midi->loadMusic(roomInfo._musicFile);
 		_vm->_midi->midiPlay();
 		_vm->_midi->_musicRepeat = true;
 	}
diff --git a/engines/access/sound.cpp b/engines/access/sound.cpp
index a24dd1a..316ac54 100644
--- a/engines/access/sound.cpp
+++ b/engines/access/sound.cpp
@@ -172,8 +172,12 @@ void MusicManager::stopSong() {
 	// TODO
 }
 
-Resource *MusicManager::loadMusic(int fileNum, int subfile) {
-	return _vm->_files->loadFile(fileNum, subfile);
+void MusicManager::loadMusic(int fileNum, int subfile) {
+	_music = _vm->_files->loadFile(fileNum, subfile);
+}
+
+void MusicManager::loadMusic(FileIdent file) {
+	_music = _vm->_files->loadFile(file);
 }
 
 void MusicManager::newMusic(int musicId, int mode) {
@@ -189,7 +193,7 @@ void MusicManager::newMusic(int musicId, int mode) {
 		_musicRepeat = (mode == 2);
 		_tempMusic = _music;
 		stopSong();
-		_music = loadMusic(97, musicId);
+		loadMusic(97, musicId);
 	}
 }
 
diff --git a/engines/access/sound.h b/engines/access/sound.h
index b14ce7c..827a00f 100644
--- a/engines/access/sound.h
+++ b/engines/access/sound.h
@@ -75,13 +75,14 @@ private:
 	AccessEngine *_vm;
 	Audio::Mixer *_mixer;
 
-	Resource *loadMusic(int fileNum, int subfile);
+	Resource *_tempMusic;
 
 public:
-	Resource *_music;
-	Resource *_tempMusic;
 	bool _musicRepeat;
 	bool _playingSound;
+
+	Resource *_music;
+
 public:
 	MusicManager(AccessEngine *vm, Audio::Mixer *mixer);
 	~MusicManager();
@@ -97,6 +98,9 @@ public:
 	void newMusic(int musicId, int mode);
 
 	void freeMusic();
+
+	void loadMusic(int fileNum, int subfile);
+	void loadMusic(FileIdent file);
 };
 } // End of namespace Access
 


Commit: 11870c414460d8c9ea70651a979b1842e58569e5
    https://github.com/scummvm/scummvm/commit/11870c414460d8c9ea70651a979b1842e58569e5
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-12T22:54:52-05:00

Commit Message:
ACCESS: Implement music player (WIP)

Changed paths:
    engines/access/amazon/amazon_logic.cpp
    engines/access/room.cpp
    engines/access/sound.cpp
    engines/access/sound.h



diff --git a/engines/access/amazon/amazon_logic.cpp b/engines/access/amazon/amazon_logic.cpp
index c330429..de497c2 100644
--- a/engines/access/amazon/amazon_logic.cpp
+++ b/engines/access/amazon/amazon_logic.cpp
@@ -353,7 +353,7 @@ void Opening::doTitle() {
 	}
 
 	_vm->_midi->newMusic(1, 1);
-	_vm->_midi->_musicRepeat = false;
+	_vm->_midi->setLoop(false);
 	_vm->_events->zeroKeys();
 	_vm->_room->loadRoom(0);
 	_vm->_screen->clearScreen();
diff --git a/engines/access/room.cpp b/engines/access/room.cpp
index 8ef61a9..a5873b2 100644
--- a/engines/access/room.cpp
+++ b/engines/access/room.cpp
@@ -184,7 +184,7 @@ void Room::loadRoomData(const byte *roomData) {
 	if (roomInfo._musicFile._fileNum != -1) {
 		_vm->_midi->loadMusic(roomInfo._musicFile);
 		_vm->_midi->midiPlay();
-		_vm->_midi->_musicRepeat = true;
+		_vm->_midi->setLoop(true);
 	}
 
 	_vm->_scaleH1 = roomInfo._scaleH1;
diff --git a/engines/access/sound.cpp b/engines/access/sound.cpp
index 316ac54..2d38a2c 100644
--- a/engines/access/sound.cpp
+++ b/engines/access/sound.cpp
@@ -147,7 +147,20 @@ void SoundManager::freeSounds() {
 MusicManager::MusicManager(AccessEngine *vm, Audio::Mixer *mixer) : _vm(vm), _mixer(mixer) {
 	_music = nullptr;
 	_tempMusic = nullptr;
-	_musicRepeat = false;
+	_isLooping = false;
+
+	MidiPlayer::createDriver();
+	MidiDriver::detectDevice(MDT_MIDI | MDT_ADLIB | MDT_PREFER_GM);
+
+	int retValue = _driver->open();
+	if (retValue == 0) {
+		if (_nativeMT32)
+			_driver->sendMT32Reset();
+		else
+			_driver->sendGMReset();
+
+		_driver->setTimerCallback(this, &timerCallback);
+	}
 }
 
 MusicManager::~MusicManager() {
@@ -155,46 +168,92 @@ MusicManager::~MusicManager() {
 	delete _tempMusic;
 }
 
+void MusicManager::send(uint32 b) {
+	if ((b & 0xF0) == 0xC0 && !_nativeMT32) {
+		b = (b & 0xFFFF00FF) | MidiDriver::_mt32ToGm[(b >> 8) & 0xFF] << 8;
+	}
+
+	Audio::MidiPlayer::send(b);
+}
+
 void MusicManager::midiPlay() {
-	// TODO
+	warning("MusicManager::midiPlay");
+	if (_music->_size < 4) {
+		error("midiPlay() wrong music resource size");
+	}
+
+	if (READ_BE_UINT32(_music->data()) != MKTAG('F', 'O', 'R', 'M'))
+		error("midiPlay() Unexpected signature");
+
+	stop();
+
+	_parser = MidiParser::createParser_XMIDI();
+
+	if (!_parser->loadMusic(_music->data(), _music->_size))
+		error("midiPlay() wrong music resource");
+
+	_parser->setTrack(0);
+	_parser->setMidiDriver(this);
+	_parser->setTimerRate(_driver->getBaseTempo());
+	_parser->property(MidiParser::mpCenterPitchWheelOnUnload, 1);
+	_parser->property(MidiParser::mpSendSustainOffOnNotesOff, 1);
+
+	// Handle music looping
+	_parser->property(MidiParser::mpAutoLoop, _isLooping);
+	//	_isLooping = loop;
+
+	setVolume(127);
+	_isPlaying = true;
 }
 
 bool MusicManager::checkMidiDone() {
-	// TODO
-	return true;
+	warning("MusicManager::checkMidiDone");
+	return (!_isPlaying);
 }
 
 void MusicManager::midiRepeat() {
-	// TODO
+	warning("MusicManager::midiRepeat");
+	if (!_parser)
+		return;
+
+	_isLooping = true;
+	_parser->property(MidiParser::mpAutoLoop, _isLooping);
+	if (!_isPlaying)
+		_parser->setTrack(0);
 }
 
 void MusicManager::stopSong() {
-	// TODO
+	warning("MusicManager::stopSong");
+	stop();
 }
 
 void MusicManager::loadMusic(int fileNum, int subfile) {
+	warning("MusicManager::loadMusic %d %d", fileNum, subfile);
 	_music = _vm->_files->loadFile(fileNum, subfile);
 }
 
 void MusicManager::loadMusic(FileIdent file) {
+	warning("MusicManager::loadMusic %d %d", file._fileNum, file._subfile);
 	_music = _vm->_files->loadFile(file);
 }
 
 void MusicManager::newMusic(int musicId, int mode) {
+	warning("MusicManager::newMusic %d %d", musicId, mode);
 	if (mode == 1) {
 		stopSong();
 		freeMusic();
 		_music = _tempMusic;
 		_tempMusic = nullptr;
-		_musicRepeat = true;
-		if (_music)
-			midiPlay();
+		_isLooping = true;
 	} else {
-		_musicRepeat = (mode == 2);
+		_isLooping = (mode == 2);
 		_tempMusic = _music;
 		stopSong();
 		loadMusic(97, musicId);
 	}
+
+	if (_music)
+		midiPlay();
 }
 
 void MusicManager::freeMusic() {
@@ -202,4 +261,9 @@ void MusicManager::freeMusic() {
 	_music = nullptr;
 }
 
+void MusicManager::setLoop(bool loop) {
+	_isLooping = loop;
+	if (_parser)
+		_parser->property(MidiParser::mpAutoLoop, _isLooping);
+}
 } // End of namespace Access
diff --git a/engines/access/sound.h b/engines/access/sound.h
index 827a00f..5089bd0 100644
--- a/engines/access/sound.h
+++ b/engines/access/sound.h
@@ -26,6 +26,8 @@
 #include "common/scummsys.h"
 #include "audio/mixer.h"
 #include "access/files.h"
+#include "audio/midiplayer.h"
+#include "audio/midiparser.h"
 
 #define MAX_SOUNDS 20
 
@@ -70,17 +72,17 @@ public:
 	void freeSounds();
 };
 
-class MusicManager {
+class MusicManager : public Audio::MidiPlayer {
 private:
 	AccessEngine *_vm;
 	Audio::Mixer *_mixer;
 
 	Resource *_tempMusic;
 
-public:
-	bool _musicRepeat;
-	bool _playingSound;
+	// MidiDriver_BASE interface implementation
+	virtual void send(uint32 b);
 
+public:
 	Resource *_music;
 
 public:
@@ -101,6 +103,8 @@ public:
 
 	void loadMusic(int fileNum, int subfile);
 	void loadMusic(FileIdent file);
+
+	void setLoop(bool loop);
 };
 } // End of namespace Access
 


Commit: 0028556d6c1706f647f0df3fddd04adb87bd6630
    https://github.com/scummvm/scummvm/commit/0028556d6c1706f647f0df3fddd04adb87bd6630
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-12T22:55:08-05:00

Commit Message:
ACCESS: improve the sound during the title countdown

Changed paths:
    engines/access/amazon/amazon_logic.cpp



diff --git a/engines/access/amazon/amazon_logic.cpp b/engines/access/amazon/amazon_logic.cpp
index de497c2..5db3efb 100644
--- a/engines/access/amazon/amazon_logic.cpp
+++ b/engines/access/amazon/amazon_logic.cpp
@@ -316,8 +316,12 @@ void Opening::doTitle() {
 		_vm->_screen->copyFrom(_vm->_buffer2);
 
 		_vm->_events->_vbCount = 70;
-		while (!_vm->shouldQuit() && _vm->_events->_vbCount > 0)
+		while (!_vm->shouldQuit() && _vm->_events->_vbCount > 0 && !_skipStart) {
+			_vm->_sound->playSound(1);
 			_vm->_events->pollEventsAndWait();
+			if (_vm->_events->_rightButton)
+				_skipStart = true;
+		}
 	}
 	if (_vm->shouldQuit())
 		return;


Commit: 0eeb5b5bf3e6dfe5537647068f697eedda87c468
    https://github.com/scummvm/scummvm/commit/0eeb5b5bf3e6dfe5537647068f697eedda87c468
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-12T22:55:30-05:00

Commit Message:
ACCESS: Fix the horizontal scrolling in intro, add some calls to clearEvents

Changed paths:
    engines/access/amazon/amazon_logic.cpp



diff --git a/engines/access/amazon/amazon_logic.cpp b/engines/access/amazon/amazon_logic.cpp
index 5db3efb..1649cdd 100644
--- a/engines/access/amazon/amazon_logic.cpp
+++ b/engines/access/amazon/amazon_logic.cpp
@@ -372,12 +372,12 @@ void Opening::doTitle() {
 	_vm->_screen->forceFadeIn();
 	_vm->_oldRects.clear();
 	_vm->_newRects.clear();
-	// KEYFLG = 0;
+	_vm->_events->clearEvents();
 	_vm->_player->_scrollAmount = 1;
 	_pCount = 0;
 
 	while (!_vm->shouldQuit()) {
-		if (!_vm->_events->isKeyMousePressed()) {
+		if (_vm->_events->isKeyMousePressed()) {
 			if (_vm->_events->_rightButton)
 				_skipStart = true;
 			_vm->_room->clearRoom();
@@ -616,8 +616,7 @@ void Plane::mWhileFly() {
 	screen.fadeIn();
 	_vm->_oldRects.clear();
 	_vm->_newRects.clear();
-
-	// KEYFLG = 0;
+	_vm->_events->clearEvents();
 
 	screen._scrollRow = screen._scrollCol = 0;
 	screen._scrollX = screen._scrollY = 0;
@@ -673,8 +672,7 @@ void Plane::mWhileFall() {
 	screen.fadeIn();
 	_vm->_oldRects.clear();
 	_vm->_newRects.clear();
-
-	// KEYFLG = 0;
+	_vm->_events->clearEvents();
 
 	screen._scrollRow = screen._scrollCol = 0;
 	screen._scrollX = screen._scrollY = 0;
@@ -768,7 +766,7 @@ void Jungle::initJWalk2() {
 	_vm->_room->buildScreen();
 	_vm->copyBF2Vid();
 	_vm->_screen->fadeIn();
-	// KEYFL = 0;
+	_vm->_events->clearEvents();
 
 	_xCount = 2;
 	_vm->_player->_scrollAmount = 5;
@@ -1395,7 +1393,8 @@ void River::initRiver() {
 		// Reset draw rects
 		_vm->_oldRects.clear();
 		_vm->_newRects.clear();
-		// KEYFLG = 0
+		_vm->_events->clearEvents();
+
 	}
 
 	_vm->_player->_scrollAmount = 2;


Commit: 954a0d0f9f8ebf3fc49df583d9eda59de8f62ed8
    https://github.com/scummvm/scummvm/commit/954a0d0f9f8ebf3fc49df583d9eda59de8f62ed8
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-12T22:55:42-05:00

Commit Message:
ACCESS: Remove useless (and commented) code

Changed paths:
    engines/access/sound.cpp



diff --git a/engines/access/sound.cpp b/engines/access/sound.cpp
index 2d38a2c..bf11d6a 100644
--- a/engines/access/sound.cpp
+++ b/engines/access/sound.cpp
@@ -200,7 +200,6 @@ void MusicManager::midiPlay() {
 
 	// Handle music looping
 	_parser->property(MidiParser::mpAutoLoop, _isLooping);
-	//	_isLooping = loop;
 
 	setVolume(127);
 	_isPlaying = true;


Commit: 66f9d71f1dc27ab0e4d3499703e39ebf35e87a27
    https://github.com/scummvm/scummvm/commit/66f9d71f1dc27ab0e4d3499703e39ebf35e87a27
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-12T22:55:56-05:00

Commit Message:
ACCESS: Add some code for the intro (WIP)

Changed paths:
    engines/access/access.h
    engines/access/amazon/amazon_logic.cpp
    engines/access/amazon/amazon_resources.cpp
    engines/access/amazon/amazon_resources.h
    engines/access/amazon/amazon_room.cpp
    engines/access/detection.cpp
    engines/access/files.cpp



diff --git a/engines/access/access.h b/engines/access/access.h
index eacdae9..2fe4b72 100644
--- a/engines/access/access.h
+++ b/engines/access/access.h
@@ -221,6 +221,7 @@ public:
 
 	uint32 getFeatures() const;
 	bool isCD() const;
+	bool isDemo() const;
 	Common::Language getLanguage() const;
 	Common::Platform getPlatform() const;
 	uint16 getVersion() const;
diff --git a/engines/access/amazon/amazon_logic.cpp b/engines/access/amazon/amazon_logic.cpp
index 1649cdd..68a52e7 100644
--- a/engines/access/amazon/amazon_logic.cpp
+++ b/engines/access/amazon/amazon_logic.cpp
@@ -273,92 +273,94 @@ void Opening::doTitle() {
 	_vm->_screen->forceFadeOut();
 	_vm->_events->hideCursor();
 
-	_vm->_sound->queueSound(0, 98, 30);
-	_vm->_sound->queueSound(1, 98, 8);
-
-	_vm->_files->_setPaletteFlag = false;
-	_vm->_files->loadScreen(0, 3);
-	
-	_vm->_buffer2.copyFrom(*_vm->_screen);
-	_vm->_buffer1.copyFrom(*_vm->_screen);
-	_vm->_screen->forceFadeIn();
-	_vm->_sound->playSound(1);
+	if (!_vm->isDemo()) {
+		_vm->_sound->queueSound(0, 98, 30);
+		_vm->_sound->queueSound(1, 98, 8);
+
+		_vm->_files->_setPaletteFlag = false;
+		_vm->_files->loadScreen(0, 3);
+		
+		_vm->_buffer2.copyFrom(*_vm->_screen);
+		_vm->_buffer1.copyFrom(*_vm->_screen);
+		_vm->_screen->forceFadeIn();
+		_vm->_sound->playSound(1);
 
-	// WORKAROUND: This delay has been added to replace original game delay that
-	// came from loading resources, since nowadays it would be too fast to be visible
-	// nowadays to be visible.
-	_vm->_events->_vbCount = 70;
-	while (!_vm->shouldQuit() && _vm->_events->_vbCount > 0)
-		_vm->_events->pollEventsAndWait();
-	if (_vm->shouldQuit())
-		return;
+		// WORKAROUND: This delay has been added to replace original game delay that
+		// came from loading resources, since nowadays it would be too fast to be visible
+		// nowadays to be visible.
+		_vm->_events->_vbCount = 70;
+		while (!_vm->shouldQuit() && _vm->_events->_vbCount > 0)
+			_vm->_events->pollEventsAndWait();
+		if (_vm->shouldQuit())
+			return;
 
-	Resource *spriteData = _vm->_files->loadFile(0, 2);
-	_vm->_objectsTable[0] = new SpriteResource(_vm, spriteData);
-	delete spriteData;
+		Resource *spriteData = _vm->_files->loadFile(0, 2);
+		_vm->_objectsTable[0] = new SpriteResource(_vm, spriteData);
+		delete spriteData;
 
-	_vm->_sound->playSound(1);
+		_vm->_sound->playSound(1);
 
-	_vm->_files->_setPaletteFlag = false;
-	_vm->_files->loadScreen(0, 4);
-	_vm->_sound->playSound(1);
+		_vm->_files->_setPaletteFlag = false;
+		_vm->_files->loadScreen(0, 4);
+		_vm->_sound->playSound(1);
 
-	_vm->_buffer2.copyFrom(*_vm->_screen);
-	_vm->_buffer1.copyFrom(*_vm->_screen);
-	_vm->_sound->playSound(1);
+		_vm->_buffer2.copyFrom(*_vm->_screen);
+		_vm->_buffer1.copyFrom(*_vm->_screen);
+		_vm->_sound->playSound(1);
 
-	const int COUNTDOWN[6] = { 2, 0x80, 1, 0x7d, 0, 0x87 };
-	for (_pCount = 0; _pCount < 3 && !_vm->shouldQuit(); ++_pCount) {
-		_vm->_buffer2.copyFrom(_vm->_buffer1);
-		int id = COUNTDOWN[_pCount * 2];
-		int xp = COUNTDOWN[_pCount * 2 + 1];
-		_vm->_buffer2.plotImage(_vm->_objectsTable[0], id, Common::Point(xp, 71));
-		_vm->_screen->copyFrom(_vm->_buffer2);
+		const int COUNTDOWN[6] = { 2, 0x80, 1, 0x7d, 0, 0x87 };
+		for (_pCount = 0; _pCount < 3 && !_vm->shouldQuit(); ++_pCount) {
+			_vm->_buffer2.copyFrom(_vm->_buffer1);
+			int id = COUNTDOWN[_pCount * 2];
+			int xp = COUNTDOWN[_pCount * 2 + 1];
+			_vm->_buffer2.plotImage(_vm->_objectsTable[0], id, Common::Point(xp, 71));
+			_vm->_screen->copyFrom(_vm->_buffer2);
 
-		_vm->_events->_vbCount = 70;
-		while (!_vm->shouldQuit() && _vm->_events->_vbCount > 0 && !_skipStart) {
-			_vm->_sound->playSound(1);
-			_vm->_events->pollEventsAndWait();
-			if (_vm->_events->_rightButton)
-				_skipStart = true;
+			_vm->_events->_vbCount = 70;
+			while (!_vm->shouldQuit() && _vm->_events->_vbCount > 0 && !_skipStart) {
+				_vm->_sound->playSound(1);
+				_vm->_events->pollEventsAndWait();
+				if (_vm->_events->_rightButton)
+					_skipStart = true;
+			}
 		}
-	}
-	if (_vm->shouldQuit())
-		return;
+		if (_vm->shouldQuit())
+			return;
 
-	_vm->_sound->playSound(0);
-	_vm->_screen->forceFadeOut();
-	_vm->_events->_vbCount = 100;
-	while (!_vm->shouldQuit() && _vm->_events->_vbCount > 0)
-		_vm->_events->pollEventsAndWait();
-	if (_vm->shouldQuit())
-		return;
+		_vm->_sound->playSound(0);
+		_vm->_screen->forceFadeOut();
+		_vm->_events->_vbCount = 100;
+		while (!_vm->shouldQuit() && _vm->_events->_vbCount > 0)
+			_vm->_events->pollEventsAndWait();
+		if (_vm->shouldQuit())
+			return;
 
-	_vm->_sound->freeSounds();
-	delete _vm->_objectsTable[0];
-	_vm->_objectsTable[0] = nullptr;
+		_vm->_sound->freeSounds();
+		delete _vm->_objectsTable[0];
+		_vm->_objectsTable[0] = nullptr;
+
+		_vm->_files->_setPaletteFlag = false;
+		_vm->_files->loadScreen(0, 5);
+		_vm->_buffer2.copyFrom(*_vm->_screen);
+		_vm->_buffer1.copyFrom(*_vm->_screen);
+		_vm->_screen->forceFadeIn();
+		_vm->_midi->newMusic(1, 0);
+		_vm->_events->_vbCount = 700;
+		while (!_vm->shouldQuit() && (_vm->_events->_vbCount > 0) && !_vm->_events->isKeyMousePressed()) {
+			_vm->_events->pollEventsAndWait();
+		}
 
-	_vm->_files->_setPaletteFlag = false;
-	_vm->_files->loadScreen(0, 5);
-	_vm->_buffer2.copyFrom(*_vm->_screen);
-	_vm->_buffer1.copyFrom(*_vm->_screen);
-	_vm->_screen->forceFadeIn();
-	_vm->_midi->newMusic(1, 0);
-	_vm->_events->_vbCount = 700;
-	while (!_vm->shouldQuit() && (_vm->_events->_vbCount > 0) && !_vm->_events->isKeyMousePressed()) {
-		_vm->_events->pollEventsAndWait();
-	}
+		if (_vm->_events->_rightButton) {
+			_skipStart = true;
+			_vm->_room->clearRoom();
+			_vm->_events->showCursor();
+			return;
+		}
 
-	if (_vm->_events->_rightButton) {
-		_skipStart = true;
-		_vm->_room->clearRoom();
-		_vm->_events->showCursor();
-		return;
+		_vm->_midi->newMusic(1, 1);
+		_vm->_midi->setLoop(false);
+		_vm->_events->zeroKeys();
 	}
-
-	_vm->_midi->newMusic(1, 1);
-	_vm->_midi->setLoop(false);
-	_vm->_events->zeroKeys();
 	_vm->_room->loadRoom(0);
 	_vm->_screen->clearScreen();
 	_vm->_screen->setBufferScan();
diff --git a/engines/access/amazon/amazon_resources.cpp b/engines/access/amazon/amazon_resources.cpp
index 0ae7ef0..8e5fccb 100644
--- a/engines/access/amazon/amazon_resources.cpp
+++ b/engines/access/amazon/amazon_resources.cpp
@@ -51,6 +51,25 @@ const char *const FILENAMES[] = {
 	"NARATE13.AP", "NARATE14.AP", "S00.AP", "TAG.AP"
 };
 
+const char *const FILENAMES_DEMO[] = {
+	"S00.AP", "S01.AP", "S02.AP", "R03.AP", "S04.AP", "S05.AP",
+	"S06.AP", "S07.AP", "S08.AP", "S09.AP", "S10.AP", "S11.AP",
+	"S12.AP", "S13.AP", "S14.AP", "S15.AP", "S16.AP", "S17.AP",
+	"S18.AP", "S19.AP", "S20.AP", "S21.AP", "S22.AP", "S23.AP",
+	"S24.AP", "S25.AP", "S26.AP", "S27.AP", "S28.AP", "S29.AP",
+	"S30.AP", "S31.AP", "S32.AP", "S33.AP", "S34.AP", "R35.AP",
+	"S36.AP", "S37.AP", "S38.AP", "S39.AP", "S40.AP", "TITLE.AP",
+	"S42.AP", "S01.AP", "S44.AP", "S45.AP", "S46.AP", "S47.AP",
+	nullptr, nullptr, "S50.AP", nullptr, nullptr, "S53.AP",
+	"S54.AP", nullptr, nullptr, "S57.AP", nullptr, nullptr,
+	nullptr, "S61.AP", nullptr, "C23.AP", "C12.AP", "C00.AP",
+	"C01.AP", "C06.AP", "C07.AP", "C08.AP", "C05.AP", "C09.AP",
+	"C12.AP", "C03.AP", "C13.AP", "C15.AP", "C14.AP", "C16.AP",
+	"C17.AP", "C19.AP", "C20.AP", "C21.AP", "C22.AP", "C23.AP",
+	"C24.AP", "C25.AP", "R49.AP", "R49.AP", "R49.AP", "R49.AP",
+	"R49.AP", "R49.AP", "R49.AP", "R49.AP", "DEAD.AP", "EST.AP",
+	"CHAPTER.AP", "MUSIC.AP", "SOUND.AP", "INV.AP" 
+};
 const byte MOUSE0[] = {
 	0, 0, 0, 0, 
 	0, 2, 6, 1, 0, 3, 6, 6, 1, 0, 3, 6, 6, 1,
@@ -603,6 +622,362 @@ const char *ROOM_DESCR[] = {
 	nullptr, "Pit with Ants", nullptr, nullptr
 };
 
+const byte ROOM_TABLE1_DEMO[] = {
+	0x02, 0x61, 0x00, 0x03, 0x00, 0x30, 0x22, 0x30, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0xFF, 0xFF, 0xFF,
+	0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0xFF, 0xFF,
+	0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF
+};
+
+const byte ROOM_TABLE5_DEMO[] = {
+	0x00, 0x61, 0x00, 0x0E, 0x00, 0x36, 0x0F, 0x5E, 0x04, 0x00,
+	0x00, 0x00, 0x04, 0x04, 0x00, 0x03, 0x00, 0xFF, 0x04, 0x00,
+	0x02, 0x00, 0x04, 0x00, 0x01, 0x00, 0x8C, 0x00, 0xFF, 0xFF,
+	0xFF, 0xFF, 0xFF, 0xFF, 0x62, 0x00, 0x00, 0x00, 0x01, 0x00,
+	0x62, 0x00, 0x0B, 0x00, 0x01, 0x00, 0x62, 0x00, 0x0C, 0x00,
+	0x01, 0x00, 0x62, 0x00, 0x0D, 0x00, 0x01, 0x00, 0xFF, 0xFF
+};
+
+const byte ROOM_TABLE6_DEMO[] = {
+	0x00, 0x61, 0x00, 0x0E, 0x00, 0x40, 0x3E, 0x1A, 0x05, 0x00,
+	0x00, 0x00, 0x05, 0x05, 0x00, 0x03, 0x00, 0xFF, 0x05, 0x00,
+	0x02, 0x00, 0x05, 0x00, 0x01, 0x00, 0xFF, 0x30, 0xFF, 0xFF,
+	0xFF, 0xFF, 0xFF, 0xFF, 0x62, 0x00, 0x00, 0x00, 0x02, 0x00,
+	0x62, 0x00, 0x12, 0x00, 0x03, 0x00, 0x62, 0x00, 0x13, 0x00,
+	0x01, 0x00, 0x62, 0x00, 0x14, 0x00, 0x02, 0x00, 0x62, 0x00,
+	0x04, 0x00, 0x01, 0x00, 0xFF, 0xFF
+};
+
+const byte ROOM_TABLE7_DEMO[] = {
+	0x01, 0x61, 0x00, 0x0D, 0x00, 0x40, 0x20, 0xC4, 0x06, 0x00,
+	0x00, 0x00, 0x06, 0x06, 0x00, 0x03, 0x00, 0xFF, 0x06, 0x00,
+	0x02, 0x00, 0x06, 0x00, 0x01, 0x00, 0xFF, 0x00, 0xFF, 0xFF,
+	0xFF, 0xFF, 0xFF, 0xFF, 0x62, 0x00, 0x00, 0x00, 0x01, 0x00,
+	0x62, 0x00, 0x01, 0x00, 0x01, 0x00, 0x62, 0x00, 0x02, 0x00,
+	0x01, 0x00, 0x62, 0x00, 0x03, 0x00, 0x02, 0x00, 0x62, 0x00,
+	0x26, 0x00, 0x01, 0x00, 0xFF, 0xFF
+};
+
+const byte ROOM_TABLE9_DEMO[] = {
+	0x01, 0x61, 0x00, 0x0D, 0x00, 0x40, 0x20, 0xC4, 0x08, 0x00,
+	0x00, 0x00, 0x08, 0x08, 0x00, 0x03, 0x00, 0xFF, 0x08, 0x00,
+	0x02, 0x00, 0x08, 0x00, 0x01, 0x00, 0xFF, 0x00, 0xFF, 0xFF,
+	0xFF, 0xFF, 0xFF, 0xFF, 0x62, 0x00, 0x00, 0x00, 0x01, 0x00,
+	0x62, 0x00, 0x07, 0x00, 0x01, 0x00, 0x62, 0x00, 0x08, 0x00,
+	0x02, 0x00, 0x62, 0x00, 0x09, 0x00, 0x01, 0x00, 0x62, 0x00,
+	0x0A, 0x00, 0x01, 0x00, 0xFF, 0xFF
+};
+
+const byte ROOM_TABLE10_DEMO[] = {
+	0x00, 0x61, 0x00, 0x0E, 0x00, 0x30, 0x18, 0x9B, 0x09, 0x00,
+	0x00, 0x00, 0x09, 0x09, 0x00, 0x03, 0x00, 0xFF, 0x09, 0x00,
+	0x02, 0x00, 0x09, 0x00, 0x01, 0x00, 0xB4, 0x10, 0xFF, 0xFF,
+	0xFF, 0xFF, 0xFF, 0xFF, 0x62, 0x00, 0x00, 0x00, 0x03, 0x00,
+	0x62, 0x00, 0x04, 0x00, 0x01, 0x00, 0x62, 0x00, 0x05, 0x00,
+	0x02, 0x00, 0x62, 0x00, 0x06, 0x00, 0x02, 0x00, 0xFF, 0xFF
+};
+
+const byte ROOM_TABLE11_DEMO[] = {
+	0x01, 0x61, 0x00, 0x0E, 0x00, 0x40, 0x30, 0x14, 0x0A, 0x00,
+	0x00, 0x00, 0x0A, 0x0A, 0x00, 0x03, 0x00, 0xFF, 0x0A, 0x00,
+	0x02, 0x00, 0x0A, 0x00, 0x01, 0x00, 0xFF, 0x00, 0xFF, 0xFF,
+	0xFF, 0xFF, 0xFF, 0xFF, 0x62, 0x00, 0x00, 0x00, 0x01, 0x00,
+	0x62, 0x00, 0x15, 0x00, 0x01, 0x00, 0x62, 0x00, 0x16, 0x00,
+	0x01, 0x00, 0xFF, 0xFF
+};
+
+const byte ROOM_TABLE12_DEMO[] = {
+	0x01, 0x61, 0x00, 0x0E, 0x00, 0x40, 0x3A, 0x22, 0x0B, 0x00,
+	0x00, 0x00, 0x0B, 0x0B, 0x00, 0x03, 0x00, 0xFF, 0x0B, 0x00,
+	0x02, 0x00, 0x0B, 0x00, 0x01, 0x00, 0xFF, 0x00, 0xFF, 0xFF,
+	0xFF, 0xFF, 0xFF, 0xFF, 0x62, 0x00, 0x00, 0x00, 0x01, 0x00,
+	0x62, 0x00, 0x01, 0x00, 0x01, 0x00, 0xFF, 0xFF
+};
+
+const byte ROOM_TABLE13_DEMO[] = {
+	0x01, 0x61, 0x00, 0x08, 0x00, 0x40, 0x30, 0x14, 0x0C, 0x00,
+	0x00, 0x00, 0x0C, 0x0C, 0x00, 0x03, 0x00, 0xFF, 0x0C, 0x00,
+	0x02, 0x00, 0x0C, 0x00, 0x01, 0x00, 0xFF, 0x00, 0xFF, 0xFF,
+	0xFF, 0xFF, 0xFF, 0xFF, 0x62, 0x00, 0x18, 0x00, 0x02, 0x00,
+	0x62, 0x00, 0x17, 0x00, 0x01, 0x00, 0x62, 0x00, 0x11, 0x00,
+	0x01, 0x00, 0xFF, 0xFF
+};
+
+const byte ROOM_TABLE14_DEMO[] = {
+	0x01, 0x61, 0x00, 0x0D, 0x00, 0x40, 0x36, 0x2C, 0x0D, 0x00,
+	0x00, 0x00, 0x0D, 0x0D, 0x00, 0x03, 0x00, 0xFF, 0x0D, 0x00,
+	0x02, 0x00, 0x0D, 0x00, 0x01, 0x00, 0xFF, 0x00, 0xFF, 0xFF,
+	0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF
+};
+
+const byte ROOM_TABLE15_DEMO[] = {
+	0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0x40, 0x3E, 0x33, 0xFF, 0xFF,
+	0x00, 0x00, 0xFF, 0x0E, 0x00, 0x05, 0x00, 0x0E, 0x00, 0x04,
+	0x00, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
+	0xFF
+};
+
+const byte ROOM_TABLE16_DEMO[] = {
+	0x01, 0x61, 0x00, 0x10, 0x00, 0x28, 0x0C, 0x5E, 0x0F, 0x00,
+	0x00, 0x00, 0x0F, 0x0F, 0x00, 0x02, 0x00, 0xFF, 0x0F, 0x00,
+	0x01, 0x00, 0xFF, 0xFF, 0x01, 0x00, 0xFF, 0x00, 0xFF, 0xFF,
+	0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF
+};
+
+const byte ROOM_TABLE17_DEMO[] = {
+	0x02, 0x61, 0x00, 0x10, 0x00, 0x40, 0x20, 0x30, 0x10, 0x00,
+	0x00, 0x00, 0x10, 0x10, 0x00, 0x03, 0x00, 0xFF, 0x10, 0x00,
+	0x02, 0x00, 0x10, 0x00, 0x01, 0x00, 0x6E, 0x00, 0xFF, 0xFF,
+	0xFF, 0xFF, 0xFF, 0xFF, 0x62, 0x00, 0x00, 0x00, 0x01, 0x00,
+	0xFF, 0xFF
+};
+
+const byte ROOM_TABLE18_DEMO[] = {
+	0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0x28, 0x19, 0x2B, 0x11, 0x00,
+	0x00, 0x00, 0x11, 0x11, 0x00, 0x03, 0x00, 0xFF, 0x11, 0x00,
+	0x02, 0x00, 0x11, 0x00, 0x01, 0x00, 0xFF, 0x00, 0xFF, 0xFF,
+	0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF
+};
+
+const byte ROOM_TABLE19_DEMO[] = {
+	0x01, 0x61, 0x00, 0x11, 0x00, 0x2D, 0x14, 0x3C, 0x12, 0x00,
+	0x00, 0x00, 0x12, 0x12, 0x00, 0x03, 0x00, 0xFF, 0x12, 0x00,
+	0x02, 0x00, 0x12, 0x00, 0x01, 0x00, 0xFF, 0x00, 0xFF, 0xFF,
+	0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF
+};
+
+const byte ROOM_TABLE20_DEMO[] = {
+	0x02, 0x61, 0x00, 0x12, 0x00, 0x2D, 0x28, 0x28, 0x13, 0x00,
+	0x00, 0x00, 0x13, 0x13, 0x00, 0x03, 0x00, 0xFF, 0x13, 0x00,
+	0x02, 0x00, 0x13, 0x00, 0x01, 0x00, 0xFF, 0x00, 0xFF, 0xFF,
+	0xFF, 0xFF, 0xFF, 0xFF, 0x62, 0x00, 0x00, 0x00, 0x02, 0x00,
+	0x62, 0x00, 0x29, 0x00, 0x01, 0x00, 0x62, 0x00, 0x24, 0x00,
+	0x01, 0x00, 0xFF, 0xFF
+};
+
+const byte ROOM_TABLE21_DEMO[] = {
+	0x01, 0x61, 0x00, 0x16, 0x00, 0x28, 0x0C, 0x5E, 0x14, 0x00,
+	0x00, 0x00, 0x14, 0x14, 0x00, 0x02, 0x00, 0xFF, 0x14, 0x00,
+	0x01, 0x00, 0xFF, 0xFF, 0x01, 0x00, 0xFF, 0x00, 0xFF, 0xFF,
+	0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF
+};
+
+const byte ROOM_TABLE22_DEMO[] = {
+	0x01, 0x61, 0x00, 0x12, 0x00, 0x3C, 0x2A, 0x29, 0x15, 0x00,
+	0x00, 0x00, 0x15, 0x15, 0x00, 0x03, 0x00, 0xFF, 0x15, 0x00,
+	0x02, 0x00, 0x15, 0x00, 0x01, 0x00, 0xFF, 0x00, 0xFF, 0xFF,
+	0xFF, 0xFF, 0xFF, 0xFF, 0x62, 0x00, 0x23, 0x00, 0x01, 0x00,
+	0xFF, 0xFF
+};
+
+const byte ROOM_TABLE23_DEMO[] = {
+	0x01, 0x61, 0x00, 0x13, 0x00, 0x40, 0x2D, 0x64, 0x16, 0x00,
+	0x00, 0x00, 0xFF, 0x16, 0x00, 0x01, 0x00, 0xFF, 0xFF, 0x00,
+	0x00, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x16, 0x00, 0x02,
+	0x00, 0xFF, 0xFF, 0x62, 0x00, 0x2A, 0x00, 0x01, 0x00, 0xFF,
+	0xFF
+};
+
+const byte ROOM_TABLE24_DEMO[] = {
+	0x02, 0x61, 0x00, 0x14, 0x00, 0x40, 0x3C, 0x19, 0x17, 0x00,
+	0x00, 0x00, 0x17, 0x17, 0x00, 0x03, 0x00, 0xFF, 0x17, 0x00,
+	0x02, 0x00, 0x17, 0x00, 0x01, 0x00, 0xFF, 0x00, 0xFF, 0xFF,
+	0xFF, 0xFF, 0xFF, 0xFF, 0x62, 0x00, 0x00, 0x00, 0x01, 0x00,
+	0xFF, 0xFF
+};
+
+const byte ROOM_TABLE25_DEMO[] = {
+	0x02, 0xFF, 0xFF, 0xFF, 0xFF, 0x40, 0x3F, 0x5A, 0x18, 0x00,
+	0x00, 0x00, 0x18, 0x18, 0x00, 0x02, 0x00, 0xFF, 0x18, 0x00,
+	0x01, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xDC, 0xA0, 0xFF, 0xFF,
+	0xFF, 0xFF, 0xFF, 0xFF, 0x62, 0x00, 0x00, 0x00, 0x01, 0x00,
+	0xFF, 0xFF
+};
+
+const byte ROOM_TABLE26_DEMO[] = {
+	0x02, 0x61, 0x00, 0x17, 0x00, 0x3E, 0x32, 0x80, 0x19, 0x00,
+	0x00, 0x00, 0x19, 0x19, 0x00, 0x03, 0x00, 0xFF, 0x19, 0x00,
+	0x02, 0x00, 0x19, 0x00, 0x01, 0x00, 0x64, 0x00, 0xFF, 0xFF,
+	0xFF, 0xFF, 0xFF, 0xFF, 0x62, 0x00, 0x00, 0x00, 0x01, 0x00,
+	0xFF, 0xFF
+};
+
+const byte ROOM_TABLE27_DEMO[] = {
+	0x01, 0x61, 0x00, 0x19, 0x00, 0x34, 0x28, 0x28, 0x1A, 0x00,
+	0x00, 0x00, 0x1A, 0x1A, 0x00, 0x03, 0x00, 0xFF, 0x1A, 0x00,
+	0x02, 0x00, 0x1A, 0x00, 0x01, 0x00, 0xFF, 0x00, 0xFF, 0xFF,
+	0xFF, 0xFF, 0xFF, 0xFF, 0x62, 0x00, 0x28, 0x00, 0x01, 0x00,
+	0x62, 0x00, 0x2B, 0x00, 0x01, 0x00, 0xFF, 0xFF
+};
+
+const byte ROOM_TABLE28_DEMO[] = {
+	0x02, 0x61, 0x00, 0x18, 0x00, 0x40, 0x3A, 0x6C, 0x1B, 0x00,
+	0x00, 0x00, 0x1B, 0x1B, 0x00, 0x03, 0x00, 0xFF, 0x1B, 0x00,
+	0x02, 0x00, 0x1B, 0x00, 0x01, 0x00, 0xC8, 0x00, 0xFF, 0xFF,
+	0xFF, 0xFF, 0xFF, 0xFF, 0x62, 0x00, 0x00, 0x00, 0x01, 0x00,
+	0xFF, 0xFF
+};
+
+const byte ROOM_TABLE30_DEMO[] = {
+	0x02, 0xFF, 0xFF, 0xFF, 0xFF, 0x20, 0x18, 0x73, 0x1D, 0x00,
+	0x00, 0x00, 0x1D, 0x1D, 0x00, 0x03, 0x00, 0xFF, 0x1D, 0x00,
+	0x02, 0x00, 0x1D, 0x00, 0x01, 0x00, 0x80, 0x00, 0xFF, 0xFF,
+	0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF
+};
+
+const byte ROOM_TABLE31_DEMO[] = {
+	0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0x3F, 0x1C, 0x27, 0x1E, 0x00,
+	0x00, 0x00, 0x1E, 0x1E, 0x00, 0x03, 0x00, 0xFF, 0x1E, 0x00,
+	0x02, 0x00, 0x1E, 0x00, 0x01, 0x00, 0xFF, 0x00, 0xFF, 0xFF,
+	0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF
+};
+
+const byte ROOM_TABLE32_DEMO[] = {
+	0x02, 0x61, 0x00, 0x1B, 0x00, 0x40, 0x10, 0x78, 0x1F, 0x00,
+	0x00, 0x00, 0x1F, 0x1F, 0x00, 0x03, 0x00, 0xFF, 0x1F, 0x00,
+	0x02, 0x00, 0x1F, 0x00, 0x01, 0x00, 0xFE, 0x00, 0xFF, 0xFF,
+	0xFF, 0xFF, 0xFF, 0xFF, 0x62, 0x00, 0x00, 0x00, 0x02, 0x00,
+	0x62, 0x00, 0x1F, 0x00, 0x01, 0x00, 0xFF, 0xFF
+};
+
+const byte ROOM_TABLE33_DEMO[] = {
+	0x01, 0x61, 0x00, 0x1E, 0x00, 0x40, 0x3B, 0x4B, 0x20, 0x00,
+	0x00, 0x00, 0x20, 0x20, 0x00, 0x03, 0x00, 0xFF, 0x20, 0x00,
+	0x02, 0x00, 0x20, 0x00, 0x01, 0x00, 0xFF, 0x00, 0xFF, 0xFF,
+	0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF
+};
+
+const byte ROOM_TABLE34_DEMO[] = {
+	0x01, 0x61, 0x00, 0x04, 0x00, 0x30, 0x10, 0x51, 0x21, 0x00,
+	0x00, 0x00, 0x21, 0x21, 0x00, 0x02, 0x00, 0xFF, 0x21, 0x00,
+	0x01, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0xFF, 0xFF,
+	0xFF, 0xFF, 0xFF, 0xFF, 0x62, 0x00, 0x2E, 0x00, 0x01, 0x00,
+	0x62, 0x00, 0x2F, 0x00, 0x01, 0x00, 0xFF, 0xFF
+};
+
+const byte ROOM_TABLE37_DEMO[] = {
+	0x02, 0x61, 0x00, 0x04, 0x00, 0x3E, 0x3A, 0x32, 0x24, 0x00,
+	0x00, 0x00, 0x24, 0x24, 0x00, 0x03, 0x00, 0xFF, 0x24, 0x00,
+	0x02, 0x00, 0x24, 0x00, 0x01, 0x00, 0xB4, 0x00, 0xFF, 0xFF,
+	0xFF, 0xFF, 0xFF, 0xFF, 0x62, 0x00, 0x2D, 0x00, 0x02, 0x00,
+	0x62, 0x00, 0x1F, 0x00, 0x01, 0x00, 0x62, 0x00, 0x2E, 0x00,
+	0x01, 0x00, 0x62, 0x00, 0x2F, 0x00, 0x01, 0x00, 0xFF, 0xFF
+};
+
+const byte ROOM_TABLE38_DEMO[] = {
+	0x03, 0x61, 0x00, 0x08, 0x00, 0x3F, 0x3F, 0xFF, 0x25, 0x00,
+	0x00, 0x00, 0x25, 0x25, 0x00, 0x03, 0x00, 0xFF, 0x25, 0x00,
+	0x02, 0x00, 0x25, 0x00, 0x01, 0x00, 0xFF, 0x40, 0xFF, 0xFF,
+	0xFF, 0xFF, 0xFF, 0xFF, 0x62, 0x00, 0x00, 0x00, 0x02, 0x00,
+	0x62, 0x00, 0x21, 0x00, 0x01, 0x00, 0x62, 0x00, 0x25, 0x00,
+	0x01, 0x00, 0x62, 0x00, 0x1F, 0x00, 0x01, 0x00, 0x62, 0x00,
+	0x30, 0x00, 0x01, 0x00, 0x62, 0x00, 0x32, 0x00, 0x01, 0x00,
+	0xFF, 0xFF
+};
+
+const byte ROOM_TABLE39_DEMO[] = {
+	0x01, 0x61, 0x00, 0x08, 0x00, 0x40, 0x32, 0x50, 0x26, 0x00,
+	0x00, 0x00, 0x26, 0x26, 0x00, 0x03, 0x00, 0xFF, 0x26, 0x00,
+	0x02, 0x00, 0x26, 0x00, 0x01, 0x00, 0xFF, 0x00, 0xFF, 0xFF,
+	0xFF, 0xFF, 0xFF, 0xFF, 0x62, 0x00, 0x00, 0x00, 0x01, 0x00,
+	0x62, 0x00, 0x22, 0x00, 0x02, 0x00, 0x62, 0x00, 0x31, 0x00,
+	0x01, 0x00, 0xFF, 0xFF
+};
+
+const byte ROOM_TABLE40_DEMO[] = {
+	0x02, 0x61, 0x00, 0x09, 0x00, 0x40, 0x3F, 0x37, 0x27, 0x00,
+	0x00, 0x00, 0x27, 0x27, 0x00, 0x03, 0x00, 0xFF, 0x27, 0x00,
+	0x02, 0x00, 0x27, 0x00, 0x01, 0x00, 0xFF, 0x00, 0xFF, 0xFF,
+	0xFF, 0xFF, 0xFF, 0xFF, 0x62, 0x00, 0x00, 0x00, 0x04, 0x00,
+	0x62, 0x00, 0x1B, 0x00, 0x03, 0x00, 0x62, 0x00, 0x1C, 0x00,
+	0x01, 0x00, 0x62, 0x00, 0x1F, 0x00, 0x02, 0x00, 0x62, 0x00,
+	0x23, 0x00, 0x01, 0x00, 0x62, 0x00, 0x32, 0x00, 0x01, 0x00,
+	0xFF, 0xFF
+};
+
+const byte ROOM_TABLE43_DEMO[] = {
+	0x02, 0xFF, 0xFF, 0xFF, 0xFF, 0x1E, 0x1B, 0x6E, 0x2A, 0x00,
+	0x00, 0x00, 0x2A, 0x2A, 0x00, 0x03, 0x00, 0xFF, 0x2A, 0x00,
+	0x02, 0x00, 0x2A, 0x00, 0x01, 0x00, 0xA5, 0x00, 0xFF, 0xFF,
+	0xFF, 0xFF, 0xFF, 0xFF, 0x62, 0x00, 0x00, 0x00, 0x01, 0x00,
+	0xFF, 0xFF
+};
+
+const byte ROOM_TABLE45_DEMO[] = {
+	0x02, 0xFF, 0xFF, 0xFF, 0xFF, 0x1E, 0x1D, 0xBE, 0x2C, 0x00,
+	0x00, 0x00, 0x2C, 0x2C, 0x00, 0x03, 0x00, 0xFF, 0x2C, 0x00,
+	0x02, 0x00, 0x2C, 0x00, 0x01, 0x00, 0x50, 0x00, 0xFF, 0xFF,
+	0xFF, 0xFF, 0xFF, 0xFF, 0x62, 0x00, 0x00, 0x00, 0x01, 0x00,
+	0xFF, 0xFF
+};
+
+const byte ROOM_TABLE46_DEMO[] = {
+	0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0x1E, 0x1D, 0x78, 0x2D, 0x00,
+	0x00, 0x00, 0x2D, 0x2D, 0x00, 0x03, 0x00, 0xFF, 0x2D, 0x00,
+	0x02, 0x00, 0x2D, 0x00, 0x01, 0x00, 0xFF, 0x00, 0xFF, 0xFF,
+	0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF
+};
+
+const byte ROOM_TABLE47_DEMO[] = {
+	0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0x28, 0x1E, 0x32, 0x2E, 0x00,
+	0x00, 0x00, 0x2E, 0x2E, 0x00, 0x03, 0x00, 0xFF, 0x2E, 0x00,
+	0x02, 0x00, 0x2E, 0x00, 0x01, 0x00, 0xF0, 0x00, 0xFF, 0xFF,
+	0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF
+};
+
+const byte ROOM_TABLE48_DEMO[] = {
+	0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0x28, 0x1E, 0x32, 0x2F, 0x00,
+	0x00, 0x00, 0x2F, 0x2F, 0x00, 0x03, 0x00, 0xFF, 0x2F, 0x00,
+	0x02, 0x00, 0x2F, 0x00, 0x01, 0x00, 0xFF, 0x00, 0xFF, 0xFF,
+	0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF
+};
+
+const byte ROOM_TABLE51_DEMO[] = {
+	0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0x28, 0x1E, 0x32, 0xFF, 0xFF,
+	0x00, 0x00, 0xFF, 0x32, 0x00, 0x00, 0x00, 0x0E, 0x00, 0x04,
+	0x00, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x32,
+	0x00, 0x01, 0x00, 0x01, 0x00, 0xFF, 0xFF
+};
+
+const byte ROOM_TABLE55_DEMO[] = {
+	0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0x28, 0x1E, 0x6E, 0x36, 0x00,
+	0x00, 0x00, 0x36, 0x36, 0x00, 0x03, 0x00, 0xFF, 0x36, 0x00,
+	0x02, 0x00, 0x36, 0x00, 0x01, 0x00, 0xFF, 0x00, 0xFF, 0xFF,
+	0xFF, 0xFF, 0x36, 0x00, 0x04, 0x00, 0xFF, 0xFF, 0xFF, 0xFF
+};
+
+const byte ROOM_TABLE58_DEMO[] = {
+	0x02, 0xFF, 0xFF, 0xFF, 0xFF, 0x32, 0x14, 0x73, 0x39, 0x00,
+	0x00, 0x00, 0x39, 0x39, 0x00, 0x03, 0x00, 0xFF, 0x39, 0x00,
+	0x02, 0x00, 0x39, 0x00, 0x01, 0x00, 0xB4, 0x00, 0xFF, 0xFF,
+	0xFF, 0xFF, 0xFF, 0xFF, 0x62, 0x00, 0x00, 0x00, 0x01, 0x00,
+	0xFF, 0xFF
+};
+
+const byte ROOM_TABLE62_DEMO[] = {
+	0x02, 0xFF, 0xFF, 0xFF, 0xFF, 0x41, 0x3F, 0x19, 0x3D, 0x00,
+	0x00, 0x00, 0x3D, 0x3D, 0x00, 0x03, 0x00, 0x3E, 0x3D, 0x00,
+	0x04, 0x00, 0xFF, 0x3D, 0x00, 0x02, 0x00, 0x3D, 0x00, 0x01,
+	0x00, 0xBE, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x62,
+	0x00, 0x00, 0x00, 0x01, 0x00, 0xFF, 0xFF, 0x00
+};
+
+const byte *ROOM_TABLE_DEMO[] = {
+	ROOM_TABLE1_DEMO, nullptr, nullptr, nullptr, ROOM_TABLE5_DEMO,
+	ROOM_TABLE6_DEMO, ROOM_TABLE7_DEMO, nullptr, ROOM_TABLE9_DEMO, ROOM_TABLE10_DEMO,
+	ROOM_TABLE11_DEMO, ROOM_TABLE12_DEMO, ROOM_TABLE13_DEMO, ROOM_TABLE14_DEMO, ROOM_TABLE15_DEMO,
+	ROOM_TABLE16_DEMO, ROOM_TABLE17_DEMO, ROOM_TABLE18_DEMO, ROOM_TABLE19_DEMO, ROOM_TABLE20_DEMO,
+	ROOM_TABLE21_DEMO, ROOM_TABLE22_DEMO, ROOM_TABLE23_DEMO, ROOM_TABLE24_DEMO, ROOM_TABLE25_DEMO,
+	ROOM_TABLE26_DEMO, ROOM_TABLE27_DEMO, ROOM_TABLE28_DEMO, nullptr, ROOM_TABLE30_DEMO,
+	ROOM_TABLE31_DEMO, ROOM_TABLE32_DEMO, ROOM_TABLE33_DEMO, ROOM_TABLE34_DEMO, nullptr,
+	nullptr, ROOM_TABLE37_DEMO, ROOM_TABLE38_DEMO, ROOM_TABLE39_DEMO, ROOM_TABLE40_DEMO,
+	nullptr, nullptr, ROOM_TABLE43_DEMO, nullptr, ROOM_TABLE45_DEMO, 
+	ROOM_TABLE46_DEMO, ROOM_TABLE47_DEMO, ROOM_TABLE48_DEMO, nullptr, nullptr,
+	ROOM_TABLE51_DEMO, nullptr, nullptr, nullptr, ROOM_TABLE55_DEMO,
+	nullptr, nullptr, ROOM_TABLE58_DEMO, nullptr, nullptr,
+	nullptr, ROOM_TABLE62_DEMO, nullptr, nullptr
+};
+
 const int ROOM_NUMB = 63;
 
 const byte ELAINE[] = {
diff --git a/engines/access/amazon/amazon_resources.h b/engines/access/amazon/amazon_resources.h
index 61659d3..e75b78a 100644
--- a/engines/access/amazon/amazon_resources.h
+++ b/engines/access/amazon/amazon_resources.h
@@ -39,6 +39,7 @@ struct RiverStruct {
 };
 
 extern const char *const FILENAMES[];
+extern const char *const FILENAMES_DEMO[];
 
 extern const byte *CURSORS[10];
 
@@ -59,6 +60,7 @@ extern const int OVEROFFDLY[];
 
 extern const byte *ROOM_TABLE[];
 extern const char *ROOM_DESCR[];
+extern const byte *ROOM_TABLE_DEMO[];
 extern const int ROOM_NUMB;
 
 extern const byte *CHARTBL[];
diff --git a/engines/access/amazon/amazon_room.cpp b/engines/access/amazon/amazon_room.cpp
index 14514c2..24aedf5 100644
--- a/engines/access/amazon/amazon_room.cpp
+++ b/engines/access/amazon/amazon_room.cpp
@@ -41,7 +41,10 @@ AmazonRoom::~AmazonRoom() {
 }
 
 void AmazonRoom::loadRoom(int roomNumber) {
-	loadRoomData(ROOM_TABLE[roomNumber]);
+	if (_vm->isDemo())
+		loadRoomData(ROOM_TABLE_DEMO[roomNumber]);
+	else
+		loadRoomData(ROOM_TABLE[roomNumber]);
 }
 
 void AmazonRoom::reloadRoom() {
diff --git a/engines/access/detection.cpp b/engines/access/detection.cpp
index 59c4bc4..914f98e 100644
--- a/engines/access/detection.cpp
+++ b/engines/access/detection.cpp
@@ -61,6 +61,10 @@ bool AccessEngine::isCD() const {
 	return (bool)(_gameDescription->desc.flags & ADGF_CD);
 }
 
+bool AccessEngine::isDemo() const {
+	return (bool)(_gameDescription->desc.flags & ADGF_DEMO);
+}
+
 Common::Language AccessEngine::getLanguage() const {
 	return _gameDescription->desc.language;
 }
diff --git a/engines/access/files.cpp b/engines/access/files.cpp
index cbcfa3f..6671a48 100644
--- a/engines/access/files.cpp
+++ b/engines/access/files.cpp
@@ -82,7 +82,10 @@ byte *Resource::data() {
 FileManager::FileManager(AccessEngine *vm): _vm(vm) {
 	switch (vm->getGameID()) {
 	case GType_Amazon:
-		_filenames = &Amazon::FILENAMES[0];
+		if (_vm->isDemo())
+			_filenames = &Amazon::FILENAMES_DEMO[0];
+		else
+			_filenames = &Amazon::FILENAMES[0];
 		break;
 	case GType_MartianMemorandum:
 		_filenames = &Martian::FILENAMES[0];


Commit: f9685533292b0301ed9770439e55f39fbc934a7f
    https://github.com/scummvm/scummvm/commit/f9685533292b0301ed9770439e55f39fbc934a7f
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-12T22:56:11-05:00

Commit Message:
ACCESS: Fix RoomInfo for the demo version, fix a typo in a comment

Changed paths:
    engines/access/files.cpp
    engines/access/room.cpp
    engines/access/room.h



diff --git a/engines/access/files.cpp b/engines/access/files.cpp
index 6671a48..9fff6c4 100644
--- a/engines/access/files.cpp
+++ b/engines/access/files.cpp
@@ -211,7 +211,7 @@ void FileManager::setAppended(Resource *res, int fileNum) {
 	if (!res->_file.open(_filenames[fileNum]))
 		error("Could not open file %s", _filenames[fileNum]);
 
-	// If a different file has been opened then previously, load it's index
+	// If a different file has been opened then previously, load its index
 	if (_fileNumber != fileNum) {
 		_fileNumber = fileNum;
 			
diff --git a/engines/access/room.cpp b/engines/access/room.cpp
index a5873b2..97341b0 100644
--- a/engines/access/room.cpp
+++ b/engines/access/room.cpp
@@ -167,7 +167,7 @@ void Room::clearRoom() {
 }
 
 void Room::loadRoomData(const byte *roomData) {
-	RoomInfo roomInfo(roomData, _vm->getGameID(), _vm->isCD());
+	RoomInfo roomInfo(roomData, _vm->getGameID(), _vm->isCD(), _vm->isDemo());
 
 	_roomFlag = roomInfo._roomFlag;
 
@@ -777,7 +777,7 @@ bool Room::checkCode(int v1, int v2) {
 
 /*------------------------------------------------------------------------*/
 
-RoomInfo::RoomInfo(const byte *data, int gameType, bool isCD) {
+RoomInfo::RoomInfo(const byte *data, int gameType, bool isCD, bool isDemo) {
 	Common::MemoryReadStream stream(data, 999);
 
 	_roomFlag = stream.readByte();
@@ -787,7 +787,8 @@ RoomInfo::RoomInfo(const byte *data, int gameType, bool isCD) {
 			_estIndex = stream.readSint16LE();
 		else {
 			_estIndex = -1;
-			stream.readSint16LE();
+			if (!isDemo)
+				stream.readSint16LE();
 		}
 	} else
 		_estIndex = -1;
diff --git a/engines/access/room.h b/engines/access/room.h
index 4ec80d1..db794db 100644
--- a/engines/access/room.h
+++ b/engines/access/room.h
@@ -194,7 +194,7 @@ public:
 	Common::Array<ExtraCell> _extraCells;
 	Common::Array<SoundIdent> _sounds;
 public:
-	RoomInfo(const byte *data, int gameType, bool isCD);
+	RoomInfo(const byte *data, int gameType, bool isCD, bool isDemo);
 };
 
 } // End of namespace Access


Commit: 8267b5d2abe9bd5f620502bd436acb74453daa06
    https://github.com/scummvm/scummvm/commit/8267b5d2abe9bd5f620502bd436acb74453daa06
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-12T22:57:35-05:00

Commit Message:
ACCESS: Skip the unknown midi file format used by the demo

Changed paths:
    engines/access/sound.cpp



diff --git a/engines/access/sound.cpp b/engines/access/sound.cpp
index bf11d6a..7dab0a7 100644
--- a/engines/access/sound.cpp
+++ b/engines/access/sound.cpp
@@ -182,27 +182,29 @@ void MusicManager::midiPlay() {
 		error("midiPlay() wrong music resource size");
 	}
 
-	if (READ_BE_UINT32(_music->data()) != MKTAG('F', 'O', 'R', 'M'))
-		error("midiPlay() Unexpected signature");
-
 	stop();
 
-	_parser = MidiParser::createParser_XMIDI();
+	if (READ_BE_UINT32(_music->data()) != MKTAG('F', 'O', 'R', 'M')) {
+		warning("midiPlay() Unexpected signature");
+		_isPlaying = false;
+	} else {
+		_parser = MidiParser::createParser_XMIDI();
 
-	if (!_parser->loadMusic(_music->data(), _music->_size))
-		error("midiPlay() wrong music resource");
+		if (!_parser->loadMusic(_music->data(), _music->_size))
+			error("midiPlay() wrong music resource");
 
-	_parser->setTrack(0);
-	_parser->setMidiDriver(this);
-	_parser->setTimerRate(_driver->getBaseTempo());
-	_parser->property(MidiParser::mpCenterPitchWheelOnUnload, 1);
-	_parser->property(MidiParser::mpSendSustainOffOnNotesOff, 1);
+		_parser->setTrack(0);
+		_parser->setMidiDriver(this);
+		_parser->setTimerRate(_driver->getBaseTempo());
+		_parser->property(MidiParser::mpCenterPitchWheelOnUnload, 1);
+		_parser->property(MidiParser::mpSendSustainOffOnNotesOff, 1);
 
-	// Handle music looping
-	_parser->property(MidiParser::mpAutoLoop, _isLooping);
+		// Handle music looping
+		_parser->property(MidiParser::mpAutoLoop, _isLooping);
 
-	setVolume(127);
-	_isPlaying = true;
+		setVolume(127);
+		_isPlaying = true;
+	}
 }
 
 bool MusicManager::checkMidiDone() {


Commit: 860f7c717cc9ed2f89b87bd75783f3d74c19c572
    https://github.com/scummvm/scummvm/commit/860f7c717cc9ed2f89b87bd75783f3d74c19c572
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-12T22:57:50-05:00

Commit Message:
ACCESS: Implement the demo logic in doTitle

Changed paths:
    engines/access/amazon/amazon_logic.cpp



diff --git a/engines/access/amazon/amazon_logic.cpp b/engines/access/amazon/amazon_logic.cpp
index 68a52e7..b921971 100644
--- a/engines/access/amazon/amazon_logic.cpp
+++ b/engines/access/amazon/amazon_logic.cpp
@@ -236,27 +236,69 @@ void Opening::doCredit() {
 		return;
 
 	if (_pCount <= 75)
-		_vm->_buffer2.plotImage(_vm->_objectsTable[0], 0, Common::Point(90, 35));
-	else if (_pCount <= 210)
-		_vm->_buffer2.plotImage(_vm->_objectsTable[0], 1, Common::Point(65, 35));
-	else if (_pCount <= 272)
-		_vm->_buffer2.plotImage(_vm->_objectsTable[0], 2, Common::Point(96, 45));
-	else if (_pCount <= 334)
-		_vm->_buffer2.plotImage(_vm->_objectsTable[0], 3, Common::Point(68, 54));
-	else if (_pCount <= 396)
-		_vm->_buffer2.plotImage(_vm->_objectsTable[0], 4, Common::Point(103, 54));
-	else if (_pCount <= 458) {
-		_vm->_buffer2.plotImage(_vm->_objectsTable[0], 5, Common::Point(8, 5));
-		_vm->_buffer2.plotImage(_vm->_objectsTable[0], 12, Common::Point(88, 55));
-		_vm->_buffer2.plotImage(_vm->_objectsTable[0], 6, Common::Point(194, 98));
+		_vm->_buffer2.plotImage(_vm->_objectsTable[0], _vm->isDemo()? 24 : 0, Common::Point(90, 35));
+	else if (_pCount <= 210) {
+		if (_vm->isDemo())
+			_vm->_buffer2.plotImage(_vm->_objectsTable[0], 25, Common::Point(82, 35));
+		else
+			_vm->_buffer2.plotImage(_vm->_objectsTable[0], 1, Common::Point(65, 35));
+	} else if (_pCount <= 272) {
+		if (_vm->isDemo()) {
+			_vm->_buffer2.plotImage(_vm->_objectsTable[0], 23, Common::Point(77, 20));
+			_vm->_buffer2.plotImage(_vm->_objectsTable[0], 4, Common::Point(50, 35));
+		} else 
+			_vm->_buffer2.plotImage(_vm->_objectsTable[0], 2, Common::Point(96, 45));
+	} else if (_pCount <= 334) {
+		if (_vm->isDemo()) {
+			_vm->_buffer2.plotImage(_vm->_objectsTable[0], 16, Common::Point(200, 70));
+			_vm->_buffer2.plotImage(_vm->_objectsTable[0], 4, Common::Point(170, 85));
+		} else 
+			_vm->_buffer2.plotImage(_vm->_objectsTable[0], 3, Common::Point(68, 54));
+	} else if (_pCount <= 396) {
+		if (_vm->isDemo()) {
+			_vm->_buffer2.plotImage(_vm->_objectsTable[0], 15, Common::Point(65, 15));
+			_vm->_buffer2.plotImage(_vm->_objectsTable[0], 2, Common::Point(30, 30));
+		} else 
+			_vm->_buffer2.plotImage(_vm->_objectsTable[0], 4, Common::Point(103, 54));
+	} else if (_pCount <= 458) {
+		if (_vm->isDemo()) {
+			_vm->_buffer2.plotImage(_vm->_objectsTable[0], 19, Common::Point(123, 40));
+			_vm->_buffer2.plotImage(_vm->_objectsTable[0], 10, Common::Point(115, 55));
+		} else {
+			_vm->_buffer2.plotImage(_vm->_objectsTable[0], 5, Common::Point(8, 5));
+			_vm->_buffer2.plotImage(_vm->_objectsTable[0], 12, Common::Point(88, 55));
+			_vm->_buffer2.plotImage(_vm->_objectsTable[0], 6, Common::Point(194, 98));
+		}
 	} else if (_pCount <= 520) {
-		_vm->_buffer2.plotImage(_vm->_objectsTable[0], 7, Common::Point(32, 13));
-		_vm->_buffer2.plotImage(_vm->_objectsTable[0], 8, Common::Point(162, 80));
+		if (_vm->isDemo()) {
+			_vm->_buffer2.plotImage(_vm->_objectsTable[0], 18, Common::Point(50, 15));
+			_vm->_buffer2.plotImage(_vm->_objectsTable[0], 9, Common::Point(40, 30));
+			_vm->_buffer2.plotImage(_vm->_objectsTable[0], 0, Common::Point(40, 55));
+			_vm->_buffer2.plotImage(_vm->_objectsTable[0], 20, Common::Point(198, 95));
+			_vm->_buffer2.plotImage(_vm->_objectsTable[0], 3, Common::Point(160, 110));
+		} else {
+			_vm->_buffer2.plotImage(_vm->_objectsTable[0], 7, Common::Point(32, 13));
+			_vm->_buffer2.plotImage(_vm->_objectsTable[0], 8, Common::Point(162, 80));
+		}
 	} else if (_pCount <= 580) {
-		_vm->_buffer2.plotImage(_vm->_objectsTable[0], 9, Common::Point(18, 15));
-		_vm->_buffer2.plotImage(_vm->_objectsTable[0], 10, Common::Point(164, 81));
-	} else
-		_vm->_buffer2.plotImage(_vm->_objectsTable[0], 11, Common::Point(106, 55));
+		if (_vm->isDemo()) {
+			_vm->_buffer2.plotImage(_vm->_objectsTable[0], 21, Common::Point(40, 10));
+			_vm->_buffer2.plotImage(_vm->_objectsTable[0], 6, Common::Point(20, 25));
+			_vm->_buffer2.plotImage(_vm->_objectsTable[0], 22, Common::Point(145, 50));
+			_vm->_buffer2.plotImage(_vm->_objectsTable[0], 7, Common::Point(125, 65));
+			_vm->_buffer2.plotImage(_vm->_objectsTable[0], 12, Common::Point(207, 90));
+			_vm->_buffer2.plotImage(_vm->_objectsTable[0], 5, Common::Point(200, 105));
+		} else {
+			_vm->_buffer2.plotImage(_vm->_objectsTable[0], 9, Common::Point(18, 15));
+			_vm->_buffer2.plotImage(_vm->_objectsTable[0], 10, Common::Point(164, 81));
+		}
+	} else {
+		if (_vm->isDemo()) {
+			_vm->_buffer2.plotImage(_vm->_objectsTable[0], 11, Common::Point(125, 30));
+			_vm->_buffer2.plotImage(_vm->_objectsTable[0], 4, Common::Point(115, 45));
+		} else
+			_vm->_buffer2.plotImage(_vm->_objectsTable[0], 11, Common::Point(106, 55));
+	}
 }
 
 void Opening::scrollTitle() {


Commit: 2413fd0798b3eb0bd89b51a03dea432b40311bfd
    https://github.com/scummvm/scummvm/commit/2413fd0798b3eb0bd89b51a03dea432b40311bfd
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-12T22:58:01-05:00

Commit Message:
ACCESS: Skip the end of the full intro in the demo

Changed paths:
    engines/access/amazon/amazon_logic.cpp



diff --git a/engines/access/amazon/amazon_logic.cpp b/engines/access/amazon/amazon_logic.cpp
index b921971..4fcca20 100644
--- a/engines/access/amazon/amazon_logic.cpp
+++ b/engines/access/amazon/amazon_logic.cpp
@@ -219,7 +219,7 @@ void Opening::doIntroduction() {
 	_vm->_screen->setPanel(3);
 	doTitle();
 
-	if (_vm->shouldQuit() || _skipStart)
+	if (_vm->shouldQuit() || _skipStart || _vm->isDemo())
 		return;
 
 	_vm->_screen->setPanel(3);


Commit: c6322702e692948933056b889820c84b8af842c5
    https://github.com/scummvm/scummvm/commit/c6322702e692948933056b889820c84b8af842c5
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-12T22:58:12-05:00

Commit Message:
ACCESS: Fix doEstablish for the floppy and for the demo versions

Changed paths:
    engines/access/amazon/amazon_game.cpp



diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp
index 5b27eb2..29197fe 100644
--- a/engines/access/amazon/amazon_game.cpp
+++ b/engines/access/amazon/amazon_game.cpp
@@ -142,7 +142,10 @@ void AmazonEngine::setupGame() {
 void AmazonEngine::initVariables() {
 	_chapter = 1;
 	// Set player room and position
-	_player->_roomNumber = 4;
+	if (isDemo())
+		_player->_roomNumber = 33;
+	else
+		_player->_roomNumber = 4;
 	_player->_playerX = _player->_rawPlayer.x = TRAVEL_POS[_player->_roomNumber][0];
 	_player->_playerY = _player->_rawPlayer.y = TRAVEL_POS[_player->_roomNumber][1];
 }
@@ -212,7 +215,11 @@ void AmazonEngine::doEstablish(int screenId, int estabIndex) {
 	_screen->_printOrg = _screen->_printStart = Common::Point(48, 35);
 	loadEstablish(estabIndex);
 	_et = estabIndex;
-	uint16 msgOffset = READ_LE_UINT16(_establish->data() + (estabIndex * 2) + 2);
+	uint16 msgOffset;
+	if (!isCD())
+		msgOffset = READ_LE_UINT16(_establish->data() + (estabIndex * 2));
+	else
+		msgOffset = READ_LE_UINT16(_establish->data() + (estabIndex * 2) + 2);
 
 	_printEnd = 155;
 	Common::String msg((const char *)_establish->data() + msgOffset);


Commit: cbd772ea5fa0c6911ba56d3aad78c078f1d9a2ac
    https://github.com/scummvm/scummvm/commit/cbd772ea5fa0c6911ba56d3aad78c078f1d9a2ac
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-12T22:58:21-05:00

Commit Message:
ACCESS: Avoid the call to loadScreen in mWhileDownRiver

Changed paths:
    engines/access/amazon/amazon_logic.cpp



diff --git a/engines/access/amazon/amazon_logic.cpp b/engines/access/amazon/amazon_logic.cpp
index 4fcca20..65519f3 100644
--- a/engines/access/amazon/amazon_logic.cpp
+++ b/engines/access/amazon/amazon_logic.cpp
@@ -1731,15 +1731,17 @@ void River::plotRiver() {
 
 void River::mWhileDownRiver() {
 	_vm->_events->hideCursor();
+
 	_vm->_screen->setDisplayScan();
 	_vm->_screen->clearScreen();
 	_vm->_screen->savePalette();
-
-	_vm->_files->loadScreen(95, 4);
+	if (!_vm->isDemo())
+		_vm->_files->loadScreen(95, 4);
 	_vm->_buffer2.copyFrom(*_vm->_screen);
 	_vm->_screen->restorePalette();
 	_vm->_screen->setPalette();
 	_vm->_screen->setBufferScan();
+
 	_vm->_screen->_scrollX = 0;
 	_vm->_room->buildScreen();
 	_vm->copyBF2Vid();


Commit: 771bcc8efd12d40c9ad13c270fe93567e093f329
    https://github.com/scummvm/scummvm/commit/771bcc8efd12d40c9ad13c270fe93567e093f329
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-12T22:58:31-05:00

Commit Message:
ACCESS: Add warnings about opcodes changed in the demo version

Changed paths:
    engines/access/amazon/amazon_scripts.cpp



diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp
index da43f1b..80aded7 100644
--- a/engines/access/amazon/amazon_scripts.cpp
+++ b/engines/access/amazon/amazon_scripts.cpp
@@ -321,14 +321,29 @@ void AmazonScripts::executeSpecial(int commandIndex, int param1, int param2) {
 		loadBackground(param1, param2);
 		break;
 	case 3:
-		_game->_cast.doCast(param1);
+		if (_vm->isDemo())
+			warning("TODO: DEMO - LOADCELLSET");
+		else
+			_game->_cast.doCast(param1);
 		break;
 	case 4:
-		setInactive();
+		if (_vm->isDemo())
+			warning("TODO: DEMO - LOADNSOUND");
+		else
+			setInactive();
+		break;
+	case 5: 
+		warning("TODO: DEMO - UNLOADCELLSET");
 		break;
 	case 6:
 		mWhile(param1);
 		break;
+	case 7:
+		warning("TODO: DEMO - ADDMONEY");
+		break;
+	case 8:
+		warning("TODO: DEMO - CHKMONEY");
+		break;
 	case 9:
 		_game->_guard.doGuard();
 		break;


Commit: 580fec468f61d8883ad0a78b27cc6555532b5803
    https://github.com/scummvm/scummvm/commit/580fec468f61d8883ad0a78b27cc6555532b5803
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-12T22:58:40-05:00

Commit Message:
ACCESS: Implement loadNSound, add a warning about another special opcode used by the demo

Changed paths:
    engines/access/amazon/amazon_scripts.cpp
    engines/access/amazon/amazon_scripts.h



diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp
index 80aded7..43532aa 100644
--- a/engines/access/amazon/amazon_scripts.cpp
+++ b/engines/access/amazon/amazon_scripts.cpp
@@ -246,6 +246,11 @@ void AmazonScripts::loadBackground(int param1, int param2) {
 	_vm->_screen->forceFadeIn();
 }
 
+void AmazonScripts::loadNSound(int param1, int param2) {
+	Resource *sound = _vm->_files->loadFile(param1, param2);
+	_vm->_sound->_soundTable.push_back(SoundEntry(sound, 1));
+}
+
 void AmazonScripts::setInactive() {
 	_game->_rawInactiveX = _vm->_player->_rawPlayer.x;
 	_game->_rawInactiveY = _vm->_player->_rawPlayer.y;
@@ -314,6 +319,9 @@ void AmazonScripts::plotInactive() {
 
 void AmazonScripts::executeSpecial(int commandIndex, int param1, int param2) {
 	switch (commandIndex) {
+	case 0:
+		warning("TODO: DEMO - RESETAN");
+		break;
 	case 1:
 		_vm->establish(param1, param2);
 		break;
@@ -328,7 +336,7 @@ void AmazonScripts::executeSpecial(int commandIndex, int param1, int param2) {
 		break;
 	case 4:
 		if (_vm->isDemo())
-			warning("TODO: DEMO - LOADNSOUND");
+			loadNSound(param1, param2);
 		else
 			setInactive();
 		break;
diff --git a/engines/access/amazon/amazon_scripts.h b/engines/access/amazon/amazon_scripts.h
index 968d51e..573ffb8 100644
--- a/engines/access/amazon/amazon_scripts.h
+++ b/engines/access/amazon/amazon_scripts.h
@@ -45,6 +45,7 @@ protected:
 	void mWhile(int param1);
 	void loadBackground(int param1, int param2);
 	void plotInactive();
+	void loadNSound(int param1, int param2);
 	void setInactive();
 	void boatWalls(int param1, int param2);
 


Commit: e35e6df93a72f1a29b731281bef123d675bcfd01
    https://github.com/scummvm/scummvm/commit/e35e6df93a72f1a29b731281bef123d675bcfd01
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-12T22:58:50-05:00

Commit Message:
ACCESS: Rename cmdObject

Changed paths:
    engines/access/scripts.cpp
    engines/access/scripts.h



diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp
index 2c32f59..57af1a8 100644
--- a/engines/access/scripts.cpp
+++ b/engines/access/scripts.cpp
@@ -109,7 +109,7 @@ typedef void(Scripts::*ScriptMethodPtr)();
 
 void Scripts::executeCommand(int commandIndex) {
 	static const ScriptMethodPtr COMMAND_LIST[] = {
-		&Scripts::CMDOBJECT, &Scripts::cmdEndObject, &Scripts::cmdJumpLook, 
+		&Scripts::cmdObject, &Scripts::cmdEndObject, &Scripts::cmdJumpLook, 
 		&Scripts::cmdJumpHelp, &Scripts::cmdJumpGet, &Scripts::cmdJumpMove,
 		&Scripts::cmdJumpUse, &Scripts::cmdJumpTalk, &Scripts::cmdNull, 
 		&Scripts::cmdPrint, &Scripts::cmdRetPos, &Scripts::cmdAnim,
@@ -139,7 +139,7 @@ void Scripts::executeCommand(int commandIndex) {
 	(this->*COMMAND_LIST[commandIndex])();
 }
 
-void Scripts::CMDOBJECT() { 
+void Scripts::cmdObject() { 
 	_vm->_bubbleBox->load(_data);
 }
 
diff --git a/engines/access/scripts.h b/engines/access/scripts.h
index 098fd4f..cc9eca3 100644
--- a/engines/access/scripts.h
+++ b/engines/access/scripts.h
@@ -52,7 +52,7 @@ protected:
 	 */
 	Common::String readString();
 
-	void CMDOBJECT();
+	void cmdObject();
 	void cmdEndObject();
 	void cmdJumpLook();
 	void cmdJumpHelp();


Commit: 7571fdd4b19f5f1bf3008d764c85c254ed86f635
    https://github.com/scummvm/scummvm/commit/7571fdd4b19f5f1bf3008d764c85c254ed86f635
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-12T22:59:03-05:00

Commit Message:
ACCESS: Add some more Demo opcodes

Changed paths:
    engines/access/amazon/amazon_scripts.cpp
    engines/access/scripts.cpp
    engines/access/scripts.h



diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp
index 43532aa..5cf2210 100644
--- a/engines/access/amazon/amazon_scripts.cpp
+++ b/engines/access/amazon/amazon_scripts.cpp
@@ -472,8 +472,12 @@ void AmazonScripts::cmdCycleBack() {
 		_vm->_screen->cyclePaletteBackwards();
 }
 void AmazonScripts::cmdChapter() {
-	int chapter = _data->readByte();
-	_game->startChapter(chapter);
+	if (_vm->isDemo()) {
+		cmdSetHelp();
+	} else {
+		int chapter = _data->readByte();
+		_game->startChapter(chapter);
+	}
 }
 
 void AmazonScripts::cmdSetHelp() {
diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp
index 57af1a8..053e824 100644
--- a/engines/access/scripts.cpp
+++ b/engines/access/scripts.cpp
@@ -114,24 +114,24 @@ void Scripts::executeCommand(int commandIndex) {
 		&Scripts::cmdJumpUse, &Scripts::cmdJumpTalk, &Scripts::cmdNull, 
 		&Scripts::cmdPrint, &Scripts::cmdRetPos, &Scripts::cmdAnim,
 		&Scripts::cmdSetFlag, &Scripts::cmdCheckFlag, &Scripts::cmdGoto, 
-		&Scripts::cmdSetInventory, &Scripts::cmdSetInventory, &Scripts::cmdCheckInventory, 
+		&Scripts::cmdAddScore, &Scripts::cmdSetInventory, &Scripts::cmdCheckInventory, 
 		&Scripts::cmdSetTex, &Scripts::cmdNewRoom, &Scripts::cmdConverse, 
 		&Scripts::cmdCheckFrame, &Scripts::cmdCheckAnim, &Scripts::cmdSnd, 
 		&Scripts::cmdRetNeg, &Scripts::cmdRetPos, &Scripts::cmdCheckLoc, 
-		&Scripts::cmdSetAnim, &Scripts::cmdDispInv, &Scripts::cmdSetTimer, 
+		&Scripts::cmdSetAnim, &Scripts::cmdDispInv, &Scripts::cmdSetAbout, 
 		&Scripts::cmdSetTimer, &Scripts::cmdCheckTimer, &Scripts::cmdSetTravel,
-		&Scripts::cmdSetTravel, &Scripts::cmdSetVideo, &Scripts::cmdPlayVideo, 
+		&Scripts::cmdJumpGoto, &Scripts::cmdSetVideo, &Scripts::cmdPlayVideo, 
 		&Scripts::cmdPlotImage, &Scripts::cmdSetDisplay, &Scripts::cmdSetBuffer, 
-		&Scripts::cmdSetScroll, &Scripts::cmdVideoEnded, &Scripts::cmdVideoEnded, 
+		&Scripts::cmdSetScroll, &Scripts::cmdSaveRect, &Scripts::cmdVideoEnded, 
 		&Scripts::cmdSetBufVid, &Scripts::cmdPlayBufVid, &Scripts::cmdRemoveLast, 
-		&Scripts::cmdSpecial, &Scripts::cmdSpecial, &Scripts::cmdSpecial,
+		&Scripts::cmdDoTravel, &Scripts::cmdCheckAbout, &Scripts::cmdSpecial,
 		&Scripts::cmdSetCycle, &Scripts::cmdCycle, &Scripts::cmdCharSpeak, 
 		&Scripts::cmdTexSpeak, &Scripts::cmdTexChoice, &Scripts::cmdWait, 
 		&Scripts::cmdSetConPos, &Scripts::cmdCheckVFrame, &Scripts::cmdJumpChoice, 
 		&Scripts::cmdReturnChoice, &Scripts::cmdClearBlock, &Scripts::cmdLoadSound, 
 		&Scripts::cmdFreeSound, &Scripts::cmdSetVideoSound, &Scripts::cmdPlayVideoSound,
-		&Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, 
-		&Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, &Scripts::cmdPlayerOff, 
+		&Scripts::cmdPrintWatch, &Scripts::cmdDispAbout, &Scripts::CMDPUSHLOCATION, 
+		&Scripts::cmdCheckTravel, &Scripts::cmdBlock, &Scripts::cmdPlayerOff, 
 		&Scripts::cmdPlayerOn, &Scripts::cmdDead, &Scripts::cmdFadeOut,
 		&Scripts::cmdEndVideo
 	};
@@ -263,6 +263,15 @@ void Scripts::cmdGoto() {
 	searchForSequence();
 }
 
+void Scripts::cmdAddScore() {
+	if (_vm->isCD()) {
+		cmdSetInventory();
+		return;
+	}
+
+	_data->skip(1);
+}
+
 void Scripts::cmdSetInventory() { 
 	int itemId = _data->readByte();
 	int itemVal = _data->readByte();
@@ -400,6 +409,15 @@ void Scripts::cmdDispInv() {
 	_vm->_inventory->newDisplayInv();
 }
 
+void Scripts::cmdSetAbout() {
+	if (_vm->isCD()) {
+		cmdSetTimer();
+		return;
+	}
+
+	error("TODO: DEMO - cmdSetAbout");
+}
+
 void Scripts::cmdSetTimer() {
 	int idx = _data->readUint16LE();
 	int val = _data->readUint16LE();
@@ -439,6 +457,14 @@ void Scripts::cmdCheckTimer() {
 }
 
 void Scripts::cmdSetTravel() {
+	if (_vm->isCD()) {
+		cmdJumpGoto();
+		return;
+	}
+	error("TODO: DEMO - cmdSetTravel");
+}
+
+void Scripts::cmdJumpGoto() {
 	if (_vm->_room->_selectCommand == 5)
 		cmdGoto();
 	else
@@ -486,6 +512,14 @@ void Scripts::cmdSetScroll() {
 	_vm->_screen->_scrollY = 0;
 }
 
+void Scripts::cmdSaveRect() {
+	if (_vm->isCD()) {
+		cmdVideoEnded();
+		return;
+	}
+	error("TODO: DEMO - cmdSaveRect");
+}
+
 void Scripts::cmdVideoEnded() { 
 	_vm->_events->pollEvents();
 
@@ -515,6 +549,22 @@ void Scripts::cmdRemoveLast() {
 	--_vm->_numAnimTimers;
 }
 
+void Scripts::cmdDoTravel() {
+	if (_vm->isCD()) {
+		cmdSpecial();
+		return;
+	}
+	error("TODO: DEMO - cmdDoTravel");
+}
+
+void Scripts::cmdCheckAbout() {
+	if (_vm->isCD()) {
+		cmdSpecial();
+		return;
+	}
+	error("TODO: DEMO - cmdCheckAbout");
+}
+
 void Scripts::cmdSpecial() { 
 	_specialFunction = _data->readUint16LE();
 	int p1 = _data->readUint16LE();
@@ -774,7 +824,41 @@ void Scripts::cmdPlayVideoSound() {
 	g_system->delayMillis(10);
 }
 
-void Scripts::CMDPUSHLOCATION() { error("TODO CMDPUSHLOCATION"); }
+void Scripts::cmdPrintWatch() {
+	if (_vm->isCD()) {
+		CMDPUSHLOCATION();
+		return;
+	}
+	error("TODO: DEMO - cmdPrintWatch"); 
+}
+
+void Scripts::cmdDispAbout() {
+	if (_vm->isCD()) {
+		CMDPUSHLOCATION();
+		return;
+	}
+	error("TODO: DEMO - cmdDispAbout"); 
+}
+
+void Scripts::CMDPUSHLOCATION() {
+	error("TODO CMDPUSHLOCATION"); 
+}
+
+void Scripts::cmdCheckTravel() {
+	if (_vm->isCD()) {
+		CMDPUSHLOCATION();
+		return;
+	}
+	error("TODO: DEMO - cmdCheckTravel"); 
+}
+
+void Scripts::cmdBlock() {
+	if (_vm->isCD()) {
+		CMDPUSHLOCATION();
+		return;
+	}
+	error("TODO: DEMO - cmdBlock"); 
+}
 
 void Scripts::cmdPlayerOff() {
 	_vm->_player->_playerOff = true;
diff --git a/engines/access/scripts.h b/engines/access/scripts.h
index cc9eca3..320da73 100644
--- a/engines/access/scripts.h
+++ b/engines/access/scripts.h
@@ -71,6 +71,7 @@ protected:
 	 */
 	void cmdGoto();
 	
+	void cmdAddScore();
 	void cmdSetInventory();
 	void cmdCheckInventory();
 	void cmdSetTex();
@@ -83,8 +84,10 @@ protected:
 	void cmdCheckLoc();
 	void cmdSetAnim();
 	void cmdDispInv();
+	void cmdSetAbout();
 	void cmdSetTimer();
 	void cmdCheckTimer();
+	void cmdJumpGoto();
 	void cmdSetTravel();
 	void cmdSetVideo();
 	void cmdPlayVideo();
@@ -92,10 +95,13 @@ protected:
 	void cmdSetDisplay();
 	void cmdSetBuffer();
 	void cmdSetScroll();
+	void cmdSaveRect();
 	void cmdVideoEnded();
 	void cmdSetBufVid();
 	void cmdPlayBufVid();
 	void cmdRemoveLast();
+	void cmdDoTravel();
+	void cmdCheckAbout();
 	void cmdSpecial();
 	void cmdSetCycle();
 	void cmdCycle();
@@ -111,12 +117,19 @@ protected:
 	void cmdLoadSound();
 	void cmdSetVideoSound();
 	void cmdPlayVideoSound();
+	void cmdPrintWatch();
+	void cmdDispAbout();
 	void CMDPUSHLOCATION();
+	void cmdCheckTravel();
+	void cmdBlock();
 	void cmdPlayerOff();
 	void cmdPlayerOn();
 	void cmdDead();
 	void cmdFadeOut();
 	void cmdEndVideo();
+	void cmdHelp();
+	void cmdCycleBack();
+	void cmdSetHelp();
 public:
 	int _sequence;
 	bool _endFlag;


Commit: 889a564e73e824f736706345c19497007a321df7
    https://github.com/scummvm/scummvm/commit/889a564e73e824f736706345c19497007a321df7
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-12T22:59:14-05:00

Commit Message:
ACCESS: Fix definition of river data structures

Changed paths:
    engines/access/amazon/amazon_logic.cpp
    engines/access/amazon/amazon_resources.cpp
    engines/access/amazon/amazon_resources.h



diff --git a/engines/access/amazon/amazon_logic.cpp b/engines/access/amazon/amazon_logic.cpp
index 65519f3..039cc01 100644
--- a/engines/access/amazon/amazon_logic.cpp
+++ b/engines/access/amazon/amazon_logic.cpp
@@ -1461,7 +1461,7 @@ void River::initRiver() {
 	}
 
 	_riverIndex = _vm->_riverFlag;
-	_topList = RIVEROBJECTTBL[_riverIndex];
+	_topList = RIVER_OBJECTS[_riverIndex][RIVER_START];
 	updateObstacles();
 	riverSetPhysX();
 	_canoeDir = 0;
@@ -1637,7 +1637,7 @@ void River::moveCanoe2() {
 
 void River::updateObstacles() {
 	RiverStruct *cur;
-	for (cur = _topList; cur < RIVEROBJECTTBL[_riverIndex + 1]; ++cur) {
+	for (cur = _topList; cur < RIVER_OBJECTS[_riverIndex][RIVER_END]; ++cur) {
 		int val = cur->_field1 + cur->_field3 - 1;
 		if (val < _screenVertX)
 			break;
@@ -1646,7 +1646,7 @@ void River::updateObstacles() {
 			_topList = cur;
 			_botList = cur;
 
-			while (cur < RIVEROBJECTTBL[_riverIndex + 1]) {
+			while (cur < RIVER_OBJECTS[_riverIndex][RIVER_END]) {
 				++cur;
 				val = cur->_field1 + cur->_field3 - 1;
 				if (val < _screenVertX || (cur->_field3 >= (_screenVirtX + 319)))
diff --git a/engines/access/amazon/amazon_resources.cpp b/engines/access/amazon/amazon_resources.cpp
index 8e5fccb..1b83e6b 100644
--- a/engines/access/amazon/amazon_resources.cpp
+++ b/engines/access/amazon/amazon_resources.cpp
@@ -1980,7 +1980,7 @@ const int DOWNRIVEROBJ[14][4] = {
 	{ 3, 700, 0, 20 }
 };
 
-RiverStruct RIVER0OBJECTS[45] = {
+RiverStruct RIVER0OBJECTS[46] = {
 	{16,  31, 6400, 0, 4, 12},
 	{16,  31, 6200, 0, 2, 12},
 	{17,  30, 6100, 0, 3, 15},
@@ -2025,12 +2025,11 @@ RiverStruct RIVER0OBJECTS[45] = {
 	{16,  31,  910, 0, 5, 12},
 	{17,  30,  705, 0, 0, 15},
 	{16,  31,  550, 0, 4, 12},
-	{17,  30,  305, 0, 2, 15}
+	{17,  30,  305, 0, 2, 15},
+	{16,  31,  260, 0, 7, 12}
 };
 
-RiverStruct ENDRIVER0[1] = { { 16, 31, 260, 0, 7, 12 } };
-
-RiverStruct RIVER1OBJECTS[49] = {
+RiverStruct RIVER1OBJECTS[50] = {
 	{16,  31, 6920, 0, 1, 12},
 	{16,  31, 6740, 0, 4, 12},
 	{17,  30, 6699, 0, 1, 15},
@@ -2079,12 +2078,11 @@ RiverStruct RIVER1OBJECTS[49] = {
 	{16,  31,  910, 0, 7, 12},
 	{17,  30,  705, 0, 0, 15},
 	{16,  31,  550, 0, 6, 12},
-	{17,  30,  305, 0, 3, 15}
+	{17,  30,  305, 0, 3, 15},
+	{ 16, 31, 260, 0, 1, 12 }
 };
 
-RiverStruct ENDRIVER1[1] = { { 16, 31, 260, 0, 1, 12 } };
-
-RiverStruct RIVER2OBJECTS[53] = {
+RiverStruct RIVER2OBJECTS[54] = {
 	{16,  31, 8230, 0, 6, 12},
 	{16,  31, 8115, 0, 7, 12},
 	{17,  30, 7955, 0, 4, 15},
@@ -2137,14 +2135,14 @@ RiverStruct RIVER2OBJECTS[53] = {
 	{16,  31,  910, 0, 5, 12},
 	{17,  30,  705, 0, 0, 15},
 	{16,  31,  550, 0, 4, 12},
-	{17,  30,  305, 0, 3, 15}
+	{17,  30,  305, 0, 3, 15},
+	{16,  31,  260, 0, 6, 12}
 };
 
-RiverStruct ENDRIVER2[1] = { { 16, 31, 260, 0, 6, 12 } };
-
-RiverStruct *RIVEROBJECTTBL[6] = {
-	RIVER0OBJECTS, ENDRIVER0, RIVER1OBJECTS, 
-	ENDRIVER1, RIVER2OBJECTS, ENDRIVER2
+RiverStruct *RIVER_OBJECTS[3][2] = {
+	{ RIVER0OBJECTS, RIVER0OBJECTS + 46 - 1},
+	{ RIVER1OBJECTS, RIVER0OBJECTS + 50 - 1 },
+	{ RIVER2OBJECTS, RIVER0OBJECTS + 54 - 1 }
 };
 
 const int HELP1COORDS[2][4] = {
diff --git a/engines/access/amazon/amazon_resources.h b/engines/access/amazon/amazon_resources.h
index e75b78a..be1dc7d 100644
--- a/engines/access/amazon/amazon_resources.h
+++ b/engines/access/amazon/amazon_resources.h
@@ -120,14 +120,12 @@ extern const byte *MAPTBL[3];
 
 extern const int DOWNRIVEROBJ[14][4];
 
-extern RiverStruct RIVER0OBJECTS[45];
-extern RiverStruct ENDRIVER0[1];
-extern RiverStruct RIVER1OBJECTS[49];
-extern RiverStruct ENDRIVER1[1];
-extern RiverStruct RIVER2OBJECTS[53];
-extern RiverStruct ENDRIVER2[1];
-
-extern RiverStruct *RIVEROBJECTTBL[6];
+extern RiverStruct RIVER0OBJECTS[46];
+extern RiverStruct RIVER1OBJECTS[50];
+extern RiverStruct RIVER2OBJECTS[54];
+extern RiverStruct *RIVER_OBJECTS[3][2];
+enum { RIVER_START = 0, RIVER_END = 1 };
+
 extern const int HELP1COORDS[2][4];
 
 extern const int RIVER1OBJ[23][4];


Commit: 4c2ab8b2979dcbc7ccaee4d42e79aed554d1eb46
    https://github.com/scummvm/scummvm/commit/4c2ab8b2979dcbc7ccaee4d42e79aed554d1eb46
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-12T22:59:25-05:00

Commit Message:
ACCESS: Remove misnamed duplicate _screenVirtX field

Changed paths:
    engines/access/amazon/amazon_logic.cpp
    engines/access/amazon/amazon_logic.h



diff --git a/engines/access/amazon/amazon_logic.cpp b/engines/access/amazon/amazon_logic.cpp
index 039cc01..1a9765e 100644
--- a/engines/access/amazon/amazon_logic.cpp
+++ b/engines/access/amazon/amazon_logic.cpp
@@ -43,7 +43,6 @@ PannedScene::PannedScene(AmazonEngine *vm): AmazonManager(vm) {
 	_xTrack = _yTrack = _zTrack = 0;
 	_xCam = _yCam = _zCam = 0;
 	_pNumObj = 0;
-	_screenVertX = 0;
 }
 
 void PannedScene::pan() {
@@ -1363,7 +1362,7 @@ River::River(AmazonEngine *vm): PannedScene(vm) {
 	_rNewRectCount = 0;
 	_rKeyFlag = 0;
 	_mapOffset = 0;
-	_screenVirtX = 0;
+	_screenVertX = 0;
 	_saveRiver = false;
 }
 
@@ -1642,14 +1641,14 @@ void River::updateObstacles() {
 		if (val < _screenVertX)
 			break;
 
-		if (cur->_field3 < (_screenVirtX + 319)) {
+		if (cur->_field3 < (_screenVertX + 319)) {
 			_topList = cur;
 			_botList = cur;
 
 			while (cur < RIVER_OBJECTS[_riverIndex][RIVER_END]) {
 				++cur;
 				val = cur->_field1 + cur->_field3 - 1;
-				if (val < _screenVertX || (cur->_field3 >= (_screenVirtX + 319)))
+				if (val < _screenVertX || (cur->_field3 >= (_screenVertX + 319)))
 					break;
 
 				_botList = cur;
@@ -1834,15 +1833,16 @@ void River::river() {
 	while (!_vm->shouldQuit()) {
 		_vm->_events->_vbCount = 4;
 
-		//		int bx = _vm->_player->_scrollAmount - _screenVertX;
+		// Move the river position
+		_screenVertX -= _vm->_player->_scrollAmount;
+
 		if (_vm->_screen->_scrollX == 0) {
 			_vm->_midi->midiRepeat();
 			if (riverJumpTest()) {
 				_CHICKENOUTFLG = false;
 				return;
 			}
-		}
-		else {
+		} else {
 			_vm->_screen->_scrollX -= _vm->_player->_scrollAmount;
 		}
 
@@ -1913,7 +1913,7 @@ void River::synchronize(Common::Serializer &s) {
 		s.syncAsUint16LE(_rNewRectCount);
 		s.syncAsUint16LE(_rKeyFlag);
 		s.syncAsUint16LE(_mapOffset);
-		s.syncAsUint16LE(_screenVirtX);
+		s.syncAsUint16LE(_screenVertX);
 		warning("TODO: 	s.syncAsSint16LE(_topList);");
 		warning("TODO: 	s.syncAsSint16LE(_botList);");
 
diff --git a/engines/access/amazon/amazon_logic.h b/engines/access/amazon/amazon_logic.h
index c2752af..f6f07b4 100644
--- a/engines/access/amazon/amazon_logic.h
+++ b/engines/access/amazon/amazon_logic.h
@@ -61,7 +61,6 @@ protected:
 	int _yCam;
 	int _zCam;
 	int _pNumObj;
-	int _screenVertX;
 
 	PanEntry _pan[PAN_SIZE];
 public:
@@ -183,7 +182,7 @@ private:
 	int _rNewRectCount;
 	int _rKeyFlag;
 	int _mapOffset;
-	int _screenVirtX;
+	int _screenVertX;
 
 	void initRiver();
 	void resetPositions();


Commit: c1e80440b5969e025109301fad9fa8426558108a
    https://github.com/scummvm/scummvm/commit/c1e80440b5969e025109301fad9fa8426558108a
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-12T22:59:45-05:00

Commit Message:
ACCESS: Fix the formatting of a bunch of else statements

Changed paths:
    engines/access/amazon/amazon_logic.cpp
    engines/access/player.cpp



diff --git a/engines/access/amazon/amazon_logic.cpp b/engines/access/amazon/amazon_logic.cpp
index 1a9765e..94a61ad 100644
--- a/engines/access/amazon/amazon_logic.cpp
+++ b/engines/access/amazon/amazon_logic.cpp
@@ -1040,8 +1040,7 @@ void Guard::chkVLine() {
 	if (_position.x > _vm->_player->_rawPlayer.x) {
 		_topLeft = _vm->_player->_rawPlayer;
 		_bottomRight = _position;
-	}
-	else {
+	} else {
 		_topLeft = _position;
 		_bottomRight = _vm->_player->_rawPlayer;
 	}
@@ -1071,8 +1070,7 @@ void Guard::chkVLine() {
 
 			_topLeft.x = midX;
 			_topLeft.y = midY;
-		}
-		else {
+		} else {
 			if ((midX == _bottomRight.x) && (midY == _bottomRight.y))
 				return;
 
@@ -1086,8 +1084,7 @@ void Guard::chkHLine() {
 	if (_position.y > _vm->_player->_rawPlayer.y) {
 		_topLeft = _vm->_player->_rawPlayer;
 		_bottomRight = _position;
-	}
-	else {
+	} else {
 		_topLeft = _position;
 		_bottomRight = _vm->_player->_rawPlayer;
 	}
@@ -1117,8 +1114,7 @@ void Guard::chkHLine() {
 
 			_topLeft.x = midX;
 			_topLeft.y = midY;
-		}
-		else {
+		} else {
 			if ((midX == _bottomRight.x) && (midY == _bottomRight.y))
 				return;
 
@@ -2032,15 +2028,13 @@ int Ant::antHandleStab(int indx, const int *&buf) {
 					_pitPos.y = 127;
 					retval = 0;
 					buf = Amazon::PITWALK;
-				}
-				else {
+				} else {
 					_pitPos.x += buf[(retval / 2) + 1];
 					_pitPos.y += buf[(retval / 2) + 2];
 					_pitCel = retval;
 				}
 			}
-		}
-		else {
+		} else {
 			_stabFl = true;
 			_pitCel = 0;
 			retval = 0;
@@ -2095,8 +2089,7 @@ void Ant::doAnt() {
 		_vm->_flags[235] = 1;
 		_antCel = 0;
 		buf = Amazon::ANTEAT;
-	}
-	else {
+	} else {
 		buf = Amazon::ANTWALK;
 		if (_vm->_inventory->_inv[76]._value == 1)
 			_antDirection = UP;
@@ -2115,19 +2108,16 @@ void Ant::doAnt() {
 				_antPos = Common::Point(buf[(idx / 2) + 1], buf[(idx / 2) + 2]);
 				_antCel = idx;
 			}
-		}
-		else {
+		} else {
 			idx += 6;
 			if (buf[(idx / 2)] != -1) {
 				_antPos = Common::Point(buf[(idx / 2) + 1], buf[(idx / 2) + 2]);
 				_antCel = idx;
-			}
-			else if (!_antDieFl) {
+			} else if (!_antDieFl) {
 				idx = 0;
 				_antPos = Common::Point(buf[(idx / 2) + 1], buf[(idx / 2) + 2]);
 				_antCel = idx;
-			}
-			else {
+			} else {
 				idx -= 6;
 				if (_vm->_flags[200] == 0)
 					_vm->_flags[200] = 1;
@@ -2148,8 +2138,7 @@ void Ant::doAnt() {
 		idx = _pitCel;
 		if (_stabFl == 1) {
 			idx = antHandleStab(idx, buf);
-		}
-		else {
+		} else {
 			buf = Amazon::PITWALK;
 			if (_vm->_timers[13]._flag == 0) {
 				_vm->_timers[13]._flag = 1;
@@ -2160,8 +2149,7 @@ void Ant::doAnt() {
 						idx = antHandleLeft(idx, buf);
 					else if (pt.x > _pitPos.x)
 						idx = antHandleRight(idx, buf);
-				}
-				else {
+				} else {
 					buf = Amazon::PITWALK;
 					if (_vm->_player->_playerDirection == UP)
 						idx = antHandleStab(idx, buf);
diff --git a/engines/access/player.cpp b/engines/access/player.cpp
index cb7459e..97d7d48 100644
--- a/engines/access/player.cpp
+++ b/engines/access/player.cpp
@@ -528,8 +528,7 @@ void Player::walkDownRight() {
 		_rawTempL = (byte)tempL;
 		_rawXTemp = _rawPlayer.x + _vm->_screen->_scaleTable1[walkOffset] +
 			(tempL >= 0x100 ? 1 : 0);
-	}
-	else {
+	} else {
 		_rawXTemp = _rawPlayer.x + _vm->_screen->_scaleTable1[_scrollConst];
 	}
 


Commit: 93b1516f9f7398de188808884f2696751056237a
    https://github.com/scummvm/scummvm/commit/93b1516f9f7398de188808884f2696751056237a
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-12T22:59:59-05:00

Commit Message:
ACCESS: Fix display of rocks in the river arcade scene

Changed paths:
    engines/access/amazon/amazon_logic.cpp
    engines/access/amazon/amazon_resources.h



diff --git a/engines/access/amazon/amazon_logic.cpp b/engines/access/amazon/amazon_logic.cpp
index 94a61ad..7029a7c 100644
--- a/engines/access/amazon/amazon_logic.cpp
+++ b/engines/access/amazon/amazon_logic.cpp
@@ -1633,18 +1633,18 @@ void River::moveCanoe2() {
 void River::updateObstacles() {
 	RiverStruct *cur;
 	for (cur = _topList; cur < RIVER_OBJECTS[_riverIndex][RIVER_END]; ++cur) {
-		int val = cur->_field1 + cur->_field3 - 1;
+		int val = cur->_field1 + cur->_riverX - 1;
 		if (val < _screenVertX)
 			break;
 
-		if (cur->_field3 < (_screenVertX + 319)) {
+		if (cur->_riverX < (_screenVertX + 319)) {
 			_topList = cur;
 			_botList = cur;
 
 			while (cur < RIVER_OBJECTS[_riverIndex][RIVER_END]) {
 				++cur;
-				val = cur->_field1 + cur->_field3 - 1;
-				if (val < _screenVertX || (cur->_field3 >= (_screenVertX + 319)))
+				val = cur->_field1 + cur->_riverX - 1;
+				if (val < _screenVertX || (cur->_riverX >= (_screenVertX + 319)))
 					break;
 
 				_botList = cur;
@@ -1663,7 +1663,7 @@ void River::riverSetPhysX() {
 	int val = (_vm->_screen->_scrollCol * 16) + _vm->_screen->_scrollX;
 	RiverStruct *cur = _topList;
 	while (cur <= _botList) {
-		cur[0]._field5 = val - (_screenVertX - cur[0]._field3);
+		cur[0]._xp = val - (_screenVertX - cur[0]._riverX);
 		++cur;
 	}
 }
@@ -1675,12 +1675,12 @@ bool River::checkRiverCollide() {
 	_canoeVXPos = _screenVertX + 170;
 
 	for (RiverStruct *si = _topList; si <= _botList; ++si) {
-		if (si[0]._lane < _canoeLane)
+		if (si->_lane < _canoeLane)
 			continue;
 
-		if ((si[0]._lane == _canoeLane) || (si[0]._lane == _canoeLane + 1)) {
-			if (si[0]._field1 + si[0]._field3 - 1 >= _canoeVXPos) {
-				if (_canoeVXPos + 124 >= si[0]._field3) {
+		if ((si->_lane == _canoeLane) || (si->_lane == _canoeLane + 1)) {
+			if (si->_field1 + si->_riverX - 1 >= _canoeVXPos) {
+				if (_canoeVXPos + 124 >= si->_riverX) {
 					_vm->_sound->playSound(4);
 					return true;
 				}
@@ -1710,14 +1710,14 @@ void River::plotRiver() {
 
 	RiverStruct *cur = _topList;
 	while (cur <= _botList) {
-		if (cur[0]._id != -1) {
+		if (cur->_id != -1) {
 			ie._flags = IMGFLAG_UNSCALED;
 			ie._spritesPtr = _vm->_objectsTable[45];
-			ie._frameNumber = 0;
-			ie._position.x = cur[0]._field5;
+			ie._frameNumber = cur->_id;
+			ie._position.x = cur->_xp;
 			int val = (cur[0]._lane * 5) + 56;
-			ie._position.y = val - cur[0]._field8;
-			ie._offsetY = cur[0]._field8;
+			ie._position.y = val - cur->_offsetY;
+			ie._offsetY = cur->_offsetY;
 			_vm->_images.addToList(ie);
 		}
 		++cur;
diff --git a/engines/access/amazon/amazon_resources.h b/engines/access/amazon/amazon_resources.h
index be1dc7d..b6b0dbb 100644
--- a/engines/access/amazon/amazon_resources.h
+++ b/engines/access/amazon/amazon_resources.h
@@ -32,10 +32,10 @@ namespace Amazon {
 struct RiverStruct {
 	int _id;
 	int _field1;
-	int _field3;
-	int _field5;
+	int _riverX;
+	int _xp;
 	int _lane;
-	int _field8;
+	int _offsetY;
 };
 
 extern const char *const FILENAMES[];


Commit: f2cd2ee5b3b9cef53441375cb35bd2fd67a80f48
    https://github.com/scummvm/scummvm/commit/f2cd2ee5b3b9cef53441375cb35bd2fd67a80f48
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-12T23:00:16-05:00

Commit Message:
ACCESS: Move river death flags from engine to River class

Changed paths:
    engines/access/amazon/amazon_game.h
    engines/access/amazon/amazon_logic.cpp
    engines/access/amazon/amazon_logic.h



diff --git a/engines/access/amazon/amazon_game.h b/engines/access/amazon/amazon_game.h
index ca8287b..43fce80 100644
--- a/engines/access/amazon/amazon_game.h
+++ b/engines/access/amazon/amazon_game.h
@@ -108,9 +108,6 @@ public:
 	int _oldTitleChapter;
 	int _maxHits;
 	int _oldScrollCol;
-	bool _deathFlag;
-	int _deathCount;
-	int _deathType;
 	int _iqValue;
 public:
 	AmazonEngine(OSystem *syst, const AccessGameDescription *gameDesc);
diff --git a/engines/access/amazon/amazon_logic.cpp b/engines/access/amazon/amazon_logic.cpp
index 7029a7c..9ccf5eb 100644
--- a/engines/access/amazon/amazon_logic.cpp
+++ b/engines/access/amazon/amazon_logic.cpp
@@ -1360,6 +1360,8 @@ River::River(AmazonEngine *vm): PannedScene(vm) {
 	_mapOffset = 0;
 	_screenVertX = 0;
 	_saveRiver = false;
+	_deathFlag = false;
+	_deathCount = 0;
 }
 
 void River::setRiverPan() {
@@ -1460,8 +1462,8 @@ void River::initRiver() {
 	updateObstacles();
 	riverSetPhysX();
 	_canoeDir = 0;
-	_vm->_deathFlag = 0;
-	_vm->_deathCount = 0;
+	_deathFlag = false;
+	_deathCount = 0;
 
 	_vm->_timers[11]._timer = 1200;
 	_vm->_timers[11]._initTm = 1200;
@@ -1518,15 +1520,15 @@ bool River::riverJumpTest() {
 		_mapPtr += 3;
 		if (_canoeLane < 3) {
 			if (val1 != 0) {
-				_vm->_deathFlag = true;
-				_vm->_deathCount = 300;
-				_vm->_deathType = val2;
+				_deathFlag = true;
+				_deathCount = 300;
+				_deathType = val2;
 			}
 		} else {
 			if (val1 != 1) {
-				_vm->_deathFlag = true;
-				_vm->_deathCount = 300;
-				_vm->_deathType = val2;
+				_deathFlag = true;
+				_deathCount = 300;
+				_deathType = val2;
 			}
 			_vm->_oldScrollCol = _vm->_screen->_scrollCol;
 			_vm->_screen->_scrollCol = 44;
@@ -1866,10 +1868,9 @@ void River::river() {
 				return;
 			}
 
-			if (_vm->_deathFlag) {
-				_vm->_deathCount--;
-				if (_vm->_deathCount == 0) {
-					_vm->dead(RIVERDEATH[_vm->_deathType]);
+			if (_deathFlag) {
+				if (--_deathCount == 0) {
+					_vm->dead(RIVERDEATH[_deathType]);
 					return;
 				}
 			}
diff --git a/engines/access/amazon/amazon_logic.h b/engines/access/amazon/amazon_logic.h
index f6f07b4..14f5199 100644
--- a/engines/access/amazon/amazon_logic.h
+++ b/engines/access/amazon/amazon_logic.h
@@ -167,6 +167,9 @@ private:
 	RiverStruct *_botList;
 	int _canoeDir;
 	bool _saveRiver;
+	bool _deathFlag;
+	int _deathCount;
+	int _deathType;
 
 	// Saved fields
 	int _canoeLane;


Commit: 06f99158f063e72a492a661fc94529ec3b0d242a
    https://github.com/scummvm/scummvm/commit/06f99158f063e72a492a661fc94529ec3b0d242a
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-12T23:00:25-05:00

Commit Message:
ACCESS: Debounce any mouse press when showing death screen

Changed paths:
    engines/access/amazon/amazon_game.cpp



diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp
index 29197fe..248f5e2 100644
--- a/engines/access/amazon/amazon_game.cpp
+++ b/engines/access/amazon/amazon_game.cpp
@@ -607,6 +607,8 @@ void AmazonEngine::dead(int deathId) {
 	_events->hideCursor();
 	_screen->forceFadeOut();
 	_scripts->cmdFreeSound();
+	_events->debounceLeft();
+	_events->zeroKeys();
 
 	_sound->_soundTable.push_back(SoundEntry(_files->loadFile(98, 44), 1));
 


Commit: 3c97961fd2c300a4b4541517a4884498f5d52366
    https://github.com/scummvm/scummvm/commit/3c97961fd2c300a4b4541517a4884498f5d52366
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-12T23:00:35-05:00

Commit Message:
ACCESS: Fix the display in the floppy and demo version by removing the inventory pre-rendering

Changed paths:
    engines/access/inventory.cpp



diff --git a/engines/access/inventory.cpp b/engines/access/inventory.cpp
index 629b89f..1bf3bdc 100644
--- a/engines/access/inventory.cpp
+++ b/engines/access/inventory.cpp
@@ -102,10 +102,14 @@ void InventoryManager::setUseItem(int itemId) {
 }
 
 void InventoryManager::refreshInventory() {
-	if (_vm->_screen->_vesaMode) {
-		_invRefreshFlag = true;
-		newDisplayInv();
-	}
+	
+	// The original version was using pre-rendering for the inventory to spare some time.
+	// This is not needed on modern hardware, and it breaks a couple of things.
+	// Therefore it was removed in order to keep the same logic than for the CD version
+	// if (_vm->_screen->_vesaMode) {
+	//		_invRefreshFlag = true;
+	//		newDisplayInv();
+	// }
 }
 
 int InventoryManager::newDisplayInv() {


Commit: 84ba0df9b2ce15d6c1d32a6c61794a1accb3fc99
    https://github.com/scummvm/scummvm/commit/84ba0df9b2ce15d6c1d32a6c61794a1accb3fc99
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-12T23:00:46-05:00

Commit Message:
ACCESS: Janitorial

Changed paths:
    engines/access/access.cpp
    engines/access/amazon/amazon_game.cpp
    engines/access/amazon/amazon_logic.cpp
    engines/access/amazon/amazon_resources.cpp
    engines/access/amazon/amazon_room.cpp
    engines/access/amazon/amazon_scripts.cpp
    engines/access/animation.cpp
    engines/access/asurface.cpp
    engines/access/bubble_box.cpp
    engines/access/bubble_box.h
    engines/access/data.h
    engines/access/events.h
    engines/access/files.cpp
    engines/access/font.cpp
    engines/access/inventory.cpp
    engines/access/martian/martian_resources.cpp
    engines/access/martian/martian_room.cpp
    engines/access/player.cpp
    engines/access/resources.cpp
    engines/access/room.cpp
    engines/access/scripts.cpp
    engines/access/sound.cpp
    engines/access/video.cpp



diff --git a/engines/access/access.cpp b/engines/access/access.cpp
index 41706fc..2153f59 100644
--- a/engines/access/access.cpp
+++ b/engines/access/access.cpp
@@ -396,7 +396,7 @@ void AccessEngine::copyBF1BF2() {
 
 void AccessEngine::copyBF2Vid() {
 	const byte *srcP = (const byte *)_buffer2.getPixels();
-	byte *destP = (byte *)_screen->getBasePtr(_screen->_windowXAdd, 
+	byte *destP = (byte *)_screen->getBasePtr(_screen->_windowXAdd,
 		_screen->_windowYAdd + _screen->_screenYOff);
 
 	for (int yp = 0; yp < _screen->_vWindowLinesTall; ++yp) {
diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp
index 248f5e2..deb45ff 100644
--- a/engines/access/amazon/amazon_game.cpp
+++ b/engines/access/amazon/amazon_game.cpp
@@ -32,12 +32,12 @@ namespace Amazon {
 
 AmazonEngine::AmazonEngine(OSystem *syst, const AccessGameDescription *gameDesc) :
 AccessEngine(syst, gameDesc),
-		_guardLocation(_flags[122]), _guardFind(_flags[128]), _helpLevel(_flags[167]), 
+		_guardLocation(_flags[122]), _guardFind(_flags[128]), _helpLevel(_flags[167]),
 		_jasMayaFlag(_flags[168]), _moreHelp(_flags[169]), _flashbackFlag(_flags[171]),
-		_riverFlag(_flags[185]), _aniOutFlag(_flags[195]), _badEnd(_flags[218]), 
-		_noHints(_flags[219]), _aniFlag(_flags[229]), _allenFlag(_flags[237]), 
+		_riverFlag(_flags[185]), _aniOutFlag(_flags[195]), _badEnd(_flags[218]),
+		_noHints(_flags[219]), _aniFlag(_flags[229]), _allenFlag(_flags[237]),
 		_noSound(_flags[239]),
-		_ant(this), _cast(this), _guard(this), _jungle(this), _opening(this), 
+		_ant(this), _cast(this), _guard(this), _jungle(this), _opening(this),
 		_plane(this), _river(this) {
 
 	_charSegSwitch = false;
@@ -263,7 +263,7 @@ void AmazonEngine::tileScreen() {
 	int x = res->_stream->readSint16LE();
 	int y = res->_stream->readSint16LE();
 	int size = ((x + 2) * y) + 10;
-	
+
 	for (int i = 0; i < size; ++i)
 		_tileData[i] = res->_stream->readByte();
 
@@ -292,7 +292,7 @@ void AmazonEngine::updateSummary(int chap) {
 	_updateChapter = chapter;
 	Common::Array<CellIdent> summaryCells;
 	loadCells(summaryCells);
-	
+
 	for (int i = celSubFile; i < 16; ++i) {
 		if (i > 7)
 			warning("TODO: DRAWOBJECT");
@@ -374,7 +374,7 @@ void AmazonEngine::helpTitle() {
 		index = 169;
 
 	index /= 20;
-	
+
 	iqText += " ";
 	iqText += IQLABELS[index];
 
@@ -439,7 +439,7 @@ void AmazonEngine::drawHelp(const Common::String str) {
 		_screen->_clipHeight = 200;
 		_screen->plotImage(_objectsTable[95], 0, Common::Point(76, 168));
 		_destIn = oldDest;
-		_screen->_clipHeight = oldClip;		
+		_screen->_clipHeight = oldClip;
 	}
 
 	if ((_useItem == 0) && (_screen->_vesaMode == 0))
@@ -456,7 +456,7 @@ void AmazonEngine::startChapter(int chapter) {
 	if (chapter != 1) {
 		_room->clearRoom();
 		freeChar();
-		
+
 		_midi->newMusic(32, 0);
 		playVideo(0, Common::Point());
 		if (shouldQuit())
@@ -495,7 +495,7 @@ void AmazonEngine::startChapter(int chapter) {
 	_screen->clearScreen();
 
 	_screen->setPanel(3);
-	
+
 	// Set up cells for the chapter display
 	Common::Array<CellIdent> chapterCells;
 	chapterCells.push_back(CellIdent(0, 96, 17));
@@ -508,7 +508,7 @@ void AmazonEngine::startChapter(int chapter) {
 	_buffer2.copyFrom(*_screen);
 
 	const int *chapImg = &CHAPTER_TABLE[_chapter - 1][0];
-	_screen->plotImage(_objectsTable[0], _chapter - 1, 
+	_screen->plotImage(_objectsTable[0], _chapter - 1,
 		Common::Point(chapImg[1], chapImg[2]));
 	_screen->plotImage(_objectsTable[_chapter], 0,
 		Common::Point(chapImg[3], chapImg[4]));
@@ -535,7 +535,7 @@ void AmazonEngine::startChapter(int chapter) {
 	_screen->forceFadeOut();
 	_events->debounceLeft();
 	_events->zeroKeys();
-	
+
 	_screen->clearBuffer();
 	_files->loadScreen(96, 16);
 	_buffer2.copyFrom(*_screen);
@@ -573,7 +573,7 @@ void AmazonEngine::startChapter(int chapter) {
 	_screen->forceFadeOut();
 	_screen->clearBuffer();
 	freeCells();
-	
+
 	_midi->newMusic(_chapter * 2, 1);
 
 	if (chapter != 1 && chapter != 14) {
diff --git a/engines/access/amazon/amazon_logic.cpp b/engines/access/amazon/amazon_logic.cpp
index 9ccf5eb..428b85f 100644
--- a/engines/access/amazon/amazon_logic.cpp
+++ b/engines/access/amazon/amazon_logic.cpp
@@ -245,19 +245,19 @@ void Opening::doCredit() {
 		if (_vm->isDemo()) {
 			_vm->_buffer2.plotImage(_vm->_objectsTable[0], 23, Common::Point(77, 20));
 			_vm->_buffer2.plotImage(_vm->_objectsTable[0], 4, Common::Point(50, 35));
-		} else 
+		} else
 			_vm->_buffer2.plotImage(_vm->_objectsTable[0], 2, Common::Point(96, 45));
 	} else if (_pCount <= 334) {
 		if (_vm->isDemo()) {
 			_vm->_buffer2.plotImage(_vm->_objectsTable[0], 16, Common::Point(200, 70));
 			_vm->_buffer2.plotImage(_vm->_objectsTable[0], 4, Common::Point(170, 85));
-		} else 
+		} else
 			_vm->_buffer2.plotImage(_vm->_objectsTable[0], 3, Common::Point(68, 54));
 	} else if (_pCount <= 396) {
 		if (_vm->isDemo()) {
 			_vm->_buffer2.plotImage(_vm->_objectsTable[0], 15, Common::Point(65, 15));
 			_vm->_buffer2.plotImage(_vm->_objectsTable[0], 2, Common::Point(30, 30));
-		} else 
+		} else
 			_vm->_buffer2.plotImage(_vm->_objectsTable[0], 4, Common::Point(103, 54));
 	} else if (_pCount <= 458) {
 		if (_vm->isDemo()) {
@@ -320,7 +320,7 @@ void Opening::doTitle() {
 
 		_vm->_files->_setPaletteFlag = false;
 		_vm->_files->loadScreen(0, 3);
-		
+
 		_vm->_buffer2.copyFrom(*_vm->_screen);
 		_vm->_buffer1.copyFrom(*_vm->_screen);
 		_vm->_screen->forceFadeIn();
@@ -523,7 +523,7 @@ void Opening::doTent() {
 		}
 
 		_vm->_events->pollEventsAndWait();
-	}	
+	}
 
 	_vm->_sound->playSound(5);
 	_vm->_video->setVideo(_vm->_screen, Common::Point(43, 11), FileIdent(2, 2), 10);
diff --git a/engines/access/amazon/amazon_resources.cpp b/engines/access/amazon/amazon_resources.cpp
index 1b83e6b..bd4e4f8 100644
--- a/engines/access/amazon/amazon_resources.cpp
+++ b/engines/access/amazon/amazon_resources.cpp
@@ -68,10 +68,10 @@ const char *const FILENAMES_DEMO[] = {
 	"C17.AP", "C19.AP", "C20.AP", "C21.AP", "C22.AP", "C23.AP",
 	"C24.AP", "C25.AP", "R49.AP", "R49.AP", "R49.AP", "R49.AP",
 	"R49.AP", "R49.AP", "R49.AP", "R49.AP", "DEAD.AP", "EST.AP",
-	"CHAPTER.AP", "MUSIC.AP", "SOUND.AP", "INV.AP" 
+	"CHAPTER.AP", "MUSIC.AP", "SOUND.AP", "INV.AP"
 };
 const byte MOUSE0[] = {
-	0, 0, 0, 0, 
+	0, 0, 0, 0,
 	0, 2, 6, 1, 0, 3, 6, 6, 1, 0, 3, 6, 6, 1,
 	0, 4, 6, 6, 6, 1, 0, 4, 6, 6, 6, 1, 0, 5, 6, 6, 6, 6,
 	1, 0, 5, 6, 6, 6, 6, 1, 0, 6, 6, 6, 6, 6, 6, 1, 0, 6,
@@ -971,7 +971,7 @@ const byte *ROOM_TABLE_DEMO[] = {
 	ROOM_TABLE26_DEMO, ROOM_TABLE27_DEMO, ROOM_TABLE28_DEMO, nullptr, ROOM_TABLE30_DEMO,
 	ROOM_TABLE31_DEMO, ROOM_TABLE32_DEMO, ROOM_TABLE33_DEMO, ROOM_TABLE34_DEMO, nullptr,
 	nullptr, ROOM_TABLE37_DEMO, ROOM_TABLE38_DEMO, ROOM_TABLE39_DEMO, ROOM_TABLE40_DEMO,
-	nullptr, nullptr, ROOM_TABLE43_DEMO, nullptr, ROOM_TABLE45_DEMO, 
+	nullptr, nullptr, ROOM_TABLE43_DEMO, nullptr, ROOM_TABLE45_DEMO,
 	ROOM_TABLE46_DEMO, ROOM_TABLE47_DEMO, ROOM_TABLE48_DEMO, nullptr, nullptr,
 	ROOM_TABLE51_DEMO, nullptr, nullptr, nullptr, ROOM_TABLE55_DEMO,
 	nullptr, nullptr, ROOM_TABLE58_DEMO, nullptr, nullptr,
@@ -1124,14 +1124,14 @@ const byte BEXPLODE[] = {
 
 const byte THORNICK[] = {
 	0x2, 0x7, 0x0, 0x7, 0x0, 0x1, 0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0x0, 0x0, 0x0,
-	0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7, 0x0, 0x0, 0x0, 0x7, 0x0, 0x2, 0x0, 
-	0x7, 0x0, 0x5, 0x0, 0x7, 0x0, 0x3, 0x0, 0x7, 0x0, 0x6, 0x0, 0x7, 0x0, 0x3, 
+	0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7, 0x0, 0x0, 0x0, 0x7, 0x0, 0x2, 0x0,
+	0x7, 0x0, 0x5, 0x0, 0x7, 0x0, 0x3, 0x0, 0x7, 0x0, 0x6, 0x0, 0x7, 0x0, 0x3,
 	0x0, 0x7, 0x0, 0x7, 0x0, 0x7, 0x0, 0x4, 0x0, 0x7, 0x0, 0x8, 0x0, 0xFF, 0xFF
 };
 
 const byte MAYA[] = {
-	0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x0, 
-	0x0, 0x0, 0x0, 0x48, 0x48, 0x0, 0x1, 0x0, 0xFF, 0xFF, 0xFF, 0x2, 0x0, 
+	0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x0,
+	0x0, 0x0, 0x0, 0x48, 0x48, 0x0, 0x1, 0x0, 0xFF, 0xFF, 0xFF, 0x2, 0x0,
 	0x48, 0x0, 0x0, 0x0, 0x48, 0x0, 0x2, 0x0, 0x48, 0x0, 0x13, 0x0, 0x48,
 	0x0, 0x3, 0x0, 0x48, 0x0, 0x14, 0x0, 0x48, 0x0, 0x4, 0x0, 0x48, 0x0, 0x15,
 	0x0, 0x48, 0x0, 0x5, 0x0, 0x48, 0x0, 0x16, 0x0, 0x48, 0x0, 0x6, 0x0, 0x48,
@@ -1258,14 +1258,14 @@ const byte JWATER[] = {
 const byte SHOOT[] = {
 	0x2, 0xFF, 0xFF, 0x52, 0x0, 0x2, 0x0, 0xFF, 0xFF, 0xFF, 0xFF,
 	0x0, 0x0, 0x0, 0x0, 0x38, 0x52, 0x0, 0x1, 0x0, 0xFF, 0xFF, 0xFF, 0x0,
-	0x0, 0x52, 0x0, 0x0, 0x0, 0x52, 0x0, 0x3, 0x0, 0x52, 0x0, 0x5, 0x0, 0x52, 
+	0x0, 0x52, 0x0, 0x0, 0x0, 0x52, 0x0, 0x3, 0x0, 0x52, 0x0, 0x5, 0x0, 0x52,
 	0x0, 0x4, 0x0, 0x62, 0x0, 0x1F, 0x0, 0xFF, 0xFF
 };
 
 const byte ADIE[] = {
 	0x2, 0xFF, 0xFF, 0x53, 0x0, 0x1, 0x0, 0xFF, 0xFF, 0xFF, 0xFF,
 	0x0, 0x0, 0x0, 0x0, 0xFF, 0xFF, 0xFF, 0x2, 0x0, 0x53, 0x0, 0x0, 0x0, 0x53,
-	0x0, 0x2, 0x0, 0x62, 0x0, 0x4, 0x0, 0x53, 0x0, 0x3, 0x0, 0x62, 0x0, 0x4, 
+	0x0, 0x2, 0x0, 0x62, 0x0, 0x4, 0x0, 0x53, 0x0, 0x3, 0x0, 0x62, 0x0, 0x4,
 	0x0, 0x53, 0x0, 0x4, 0x0, 0x62, 0x0, 0x4, 0x0, 0xFF, 0xFF
 };
 
@@ -1278,20 +1278,20 @@ const byte DYNAMITE[] = {
 const byte MAYASHOT[] = {
 	0x3, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
 	0xFF, 0x0, 0x0, 0x0, 0x0, 0x36, 0x55, 0x0, 0x1, 0x0, 0xFF, 0xFF, 0xFF,
-	0x3, 0x0, 0x55, 0x0, 0x0, 0x0, 0x55, 0x0, 0x2, 0x0, 0x62, 0x0, 0x1F, 
+	0x3, 0x0, 0x55, 0x0, 0x0, 0x0, 0x55, 0x0, 0x2, 0x0, 0x62, 0x0, 0x1F,
 	0x0, 0xFF, 0xFF
 };
 
 const byte OFFKEV[] = {
-	0x3, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x0, 
-	0x0, 0x0, 0x0, 0x4D, 0x29, 0x0, 0x1, 0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 
+	0x3, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x0,
+	0x0, 0x0, 0x0, 0x4D, 0x29, 0x0, 0x1, 0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
 	0x29, 0x0, 0x0, 0x0, 0x29, 0x0, 0x2, 0x0, 0x29, 0x0, 0x3, 0x0, 0xFF, 0xFF
 };
 
 const byte VALLEY[] = {
 	0x2, 0x3A, 0x0, 0x3A, 0x0, 0x1, 0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0x0,
 	0x0, 0x0, 0x0, 0x3A, 0x3A, 0x0, 0x2, 0x0, 0xFF, 0xFF, 0xFF, 0x3, 0x0,
-	0x3A, 0x0, 0x0, 0x0, 0x3A, 0x0, 0x3, 0x0, 0x3A, 0x0, 0x5, 0x0, 0x3A, 0x0, 
+	0x3A, 0x0, 0x0, 0x0, 0x3A, 0x0, 0x3, 0x0, 0x3A, 0x0, 0x5, 0x0, 0x3A, 0x0,
 	0x4, 0x0, 0x62, 0x0, 0x27, 0x0, 0xFF, 0xFF
 };
 
@@ -1352,14 +1352,14 @@ const byte ROBOT[] = {
 };
 
 const byte ANTKILL[] = {
-	0x3, 0xFF, 0xFF, 0xFF, 0xFF, 0x1, 0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0x0, 0x0, 
-	0x0, 0x0, 0x3C, 0x59, 0x0, 0x1, 0x0, 0xFF, 0xFF, 0xFF, 0x0, 0x0, 0x59, 
+	0x3, 0xFF, 0xFF, 0xFF, 0xFF, 0x1, 0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0x0, 0x0,
+	0x0, 0x0, 0x3C, 0x59, 0x0, 0x1, 0x0, 0xFF, 0xFF, 0xFF, 0x0, 0x0, 0x59,
 	0x0, 0x0, 0x0, 0x59, 0x0, 0x2, 0x0, 0x62, 0x0, 0x0E, 0x0, 0xFF, 0xFF
 };
 
 const byte LOCOHOT[] = {
-	0x3, 0xFF, 0xFF, 0xFF, 0xFF, 0x1, 0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0x0, 0x0, 
-	0x0, 0x0, 0x19, 0x5A, 0x0, 0x1, 0x0, 0xFF, 0xFF, 0xFF, 0x0, 0x0, 0x5A, 
+	0x3, 0xFF, 0xFF, 0xFF, 0xFF, 0x1, 0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0x0, 0x0,
+	0x0, 0x0, 0x19, 0x5A, 0x0, 0x1, 0x0, 0xFF, 0xFF, 0xFF, 0x0, 0x0, 0x5A,
 	0x0, 0x0, 0x0, 0x5A, 0x0, 0x2, 0x0, 0x62, 0x0, 0x3C, 0x0, 0xFF, 0xFF
 };
 
@@ -1593,7 +1593,7 @@ const byte FONT6x6_DATA[] = {
 	0x54, 0x49, 0x4f, 0x4e, 0x00, 0x4d, 0x4f, 0x56, 0x49,
 };
 
-const char *const NO_HELP_MESSAGE = 
+const char *const NO_HELP_MESSAGE =
 	"WE ARE UNABLE TO PROVIDE YOU WITH ANY MORE HINTS.  YOUR IQ \
 HAS DECREASED SO FAR THAT WE CAN NO LONGER PUT THE HINTS IN TERMS \
 YOU CAN UNDERSTAND.";
@@ -1707,7 +1707,7 @@ const char *const DEATH_TEXT[58] = {
 	"MAYA FALLS OFF THE END OF THE BROKEN BRIDGE.",
 	"YOUR WEIGHT IS JUST ENOUGH TO CAUSE THE REMAINING SUPPORT CABLE TO SNAP AND YOU "
 		"FALL TO THE BOTTOM OF THE GORGE.",
-	
+
 	"EVEN WITH REPAIRS THE BRIDGE IS NOT STRONG ENOUGH TO HOLD TWO PEOPLE.",
 	"SANCHEZ AND HIS MEN FIND YOU AND HOLD FIRING SQUAD PRACTICE.",
 	"THE TWO GUARDS ARE DISTURBED IN THEIR LOVE NEST AND COME LOOKING FOR ANYONE ACTING SUSPICIOUS.  "
@@ -1886,7 +1886,7 @@ const int ANTEAT[33] = {
 	 9,  0,  -6,
 	 8,  0,  11,
 	 7,  0,   6,
-	-1, -1,  -1 
+	-1, -1,  -1
 };
 
 const int ANTDIE[21] = {
diff --git a/engines/access/amazon/amazon_room.cpp b/engines/access/amazon/amazon_room.cpp
index 24aedf5..d6ab2bd 100644
--- a/engines/access/amazon/amazon_room.cpp
+++ b/engines/access/amazon/amazon_room.cpp
@@ -54,7 +54,7 @@ void AmazonRoom::reloadRoom() {
 		_vm->_currentMan = _roomFlag;
 		_vm->_currentManOld = _roomFlag;
 		_vm->_manScaleOff = 0;
-		
+
 		switch (_vm->_currentMan) {
 		case 0:
 			_vm->_player->loadSprites("MAN.LZ");
@@ -78,7 +78,7 @@ void AmazonRoom::reloadRoom() {
 }
 
 void AmazonRoom::reloadRoom1() {
-	if (_vm->_player->_roomNumber == 29 || _vm->_player->_roomNumber == 31 
+	if (_vm->_player->_roomNumber == 29 || _vm->_player->_roomNumber == 31
 			|| _vm->_player->_roomNumber == 42 || _vm->_player->_roomNumber == 44) {
 		Resource *spriteData = _vm->_files->loadFile("MAYA.LZ");
 		_game->_inactive._altSpritesPtr = new SpriteResource(_vm, spriteData);
@@ -183,7 +183,7 @@ void AmazonRoom::mainAreaClick() {
 			default:
 				break;
 			}
-		} 
+		}
 
 		// WORKAROUND: In Amazon room 9, you can't leave the screen to the south due
 		// to not being able to click a Y position that's high enough
@@ -208,7 +208,7 @@ void AmazonRoom::walkCursor() {
 	// the Exit icon wgeb the cursor is already a walk cursor
 	EventsManager &events = *_vm->_events;
 
-	if (_vm->_events->_middleButton || (_vm->_player->_roomNumber == 29 && 
+	if (_vm->_events->_middleButton || (_vm->_player->_roomNumber == 29 &&
 			events._normalMouse != CURSOR_CROSSHAIRS)) {
 		events._normalMouse = CURSOR_CROSSHAIRS;
 		events.setCursor(CURSOR_CROSSHAIRS);
diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp
index 5cf2210..fb1ccbe 100644
--- a/engines/access/amazon/amazon_scripts.cpp
+++ b/engines/access/amazon/amazon_scripts.cpp
@@ -57,7 +57,7 @@ void AmazonScripts::mWhile1() {
 
 	_vm->_screen->setIconPalette();
 	_vm->_screen->forceFadeIn();
-	
+
 	Resource *spriteData = _vm->_files->loadFile(14, 6);
 	_vm->_objectsTable[0] = new SpriteResource(_vm, spriteData);
 	delete spriteData;
@@ -340,7 +340,7 @@ void AmazonScripts::executeSpecial(int commandIndex, int param1, int param2) {
 		else
 			setInactive();
 		break;
-	case 5: 
+	case 5:
 		warning("TODO: DEMO - UNLOADCELLSET");
 		break;
 	case 6:
@@ -450,7 +450,7 @@ void AmazonScripts::cmdHelp() {
 			_vm->_screen->restorePalette();
 			_vm->_screen->setPalette();
 			_vm->_events->showCursor();
-			
+
 			delete _vm->_objectsTable[45];
 			_vm->_objectsTable[45] = nullptr;
 			_vm->_timers.restoreTimers();
@@ -507,8 +507,8 @@ void AmazonScripts::cmdMainPanel() {
 	}
 }
 
-void AmazonScripts::CMDRETFLASH() { 
-	error("TODO CMDRETFLASH"); 
+void AmazonScripts::CMDRETFLASH() {
+	error("TODO CMDRETFLASH");
 }
 
 } // End of namespace Amazon
diff --git a/engines/access/animation.cpp b/engines/access/animation.cpp
index e59874f..b13fcfd 100644
--- a/engines/access/animation.cpp
+++ b/engines/access/animation.cpp
@@ -87,7 +87,7 @@ typedef void(Animation::*AnimationMethodPtr)();
 
 void Animation::animate() {
 	static const AnimationMethodPtr METHODS[8] =
-	{ &Animation::anim0, &Animation::anim1, &Animation::anim2, &Animation::anim3, 
+	{ &Animation::anim0, &Animation::anim1, &Animation::anim2, &Animation::anim3,
 	&Animation::anim4, &Animation::animNone, &Animation::animNone, &Animation::anim7 };
 
 	(this->*METHODS[_type])();
@@ -310,10 +310,10 @@ Animation *AnimationManager::setAnimation(int animId) {
 	anim->_countdownTicks = anim->_initialTicks;
 	anim->_frameNumber = 0;
 
-	anim->_currentLoopCount = (anim->_type != 3 && anim->_type != 4) ? 0 : 
+	anim->_currentLoopCount = (anim->_type != 3 && anim->_type != 4) ? 0 :
 		anim->_loopCount;
 	anim->_field10 = 0;
-		
+
 	return anim;
 }
 
diff --git a/engines/access/asurface.cpp b/engines/access/asurface.cpp
index 4202ed0..cd872e0 100644
--- a/engines/access/asurface.cpp
+++ b/engines/access/asurface.cpp
@@ -55,11 +55,11 @@ SpriteFrame::SpriteFrame(AccessEngine *vm, Common::SeekableReadStream *stream, i
 	int xSize = stream->readUint16LE();
 	int ySize = stream->readUint16LE();
 	create(xSize, ySize);
-	
+
 	// Empty surface
 	byte *data = (byte *)getPixels();
 	Common::fill(data, data + w * h, 0);
-	
+
 	// Decode the data
 	for (int y = 0; y < h; ++y) {
 		int offset = stream->readByte();
@@ -225,7 +225,7 @@ void ASurface::copyTo(ASurface *dest, const Common::Rect &bounds) {
 	int scaleXCtr = 0, scaleYCtr = 0;
 
 	for (int yCtr = 0, destY = bounds.top; yCtr < this->h; ++yCtr) {
-		// Handle skipping lines if Y scaling 
+		// Handle skipping lines if Y scaling
 		scaleYCtr += scaleY;
 		if (scaleYCtr < SCALE_LIMIT)
 			continue;
diff --git a/engines/access/bubble_box.cpp b/engines/access/bubble_box.cpp
index ff6c4de..e9e2a18 100644
--- a/engines/access/bubble_box.cpp
+++ b/engines/access/bubble_box.cpp
@@ -159,10 +159,10 @@ void BubbleBox::printBubble(const Common::String &msg) {
 		int xp = _vm->_screen->_printOrg.x;
 		if (_type == TYPE_4)
 			xp = (_bounds.width() - width) / 2 + _bounds.left - 4;
-		
+
 		// Draw the text
 		font2.drawString(_vm->_screen, line, Common::Point(xp, _vm->_screen->_printOrg.y));
-		
+
 		// Move print position
 		_vm->_screen->_printOrg.y += 6;
 		_vm->_screen->_printOrg.x = _vm->_screen->_printStart.x;
@@ -237,10 +237,10 @@ void BubbleBox::doBox(int item, int box) {
 	yp += (_type == TYPE_4) ? 4 : 8;
 
 	for (int x = 0; x < xSize; ++x, xp += 20) {
-		screen.plotImage(icons, (_type == TYPE_4 ? 62 : 34) + x, 
+		screen.plotImage(icons, (_type == TYPE_4 ? 62 : 34) + x,
 			Common::Point(xp, yp));
 	}
-	
+
 	yp = screen._orgY2 - (_type == TYPE_4 ? 18 : 12);
 	screen.plotImage(icons, (_type == TYPE_4) ? 73 : 23, Common::Point(xp, yp));
 
@@ -274,7 +274,7 @@ void BubbleBox::doBox(int item, int box) {
 	_charCol = charCol;
 	_rowOff = rowOff;
 	_vm->_screen->restoreScreen();
-	
+
 	// Free icons data
 	delete icons;
 }
diff --git a/engines/access/bubble_box.h b/engines/access/bubble_box.h
index 7b25a58..128bd61 100644
--- a/engines/access/bubble_box.h
+++ b/engines/access/bubble_box.h
@@ -71,7 +71,7 @@ public:
 	void calcBubble(const Common::String &msg);
 
 	/**
-	 * Prints a text bubble and it's contents 
+	 * Prints a text bubble and it's contents
 	 */
 	void printBubble(const Common::String &msg);
 
diff --git a/engines/access/data.h b/engines/access/data.h
index 08fbb40..6b44edd 100644
--- a/engines/access/data.h
+++ b/engines/access/data.h
@@ -77,7 +77,7 @@ public:
 	void updateTimers();
 
 	/**
-	 * Synchronize savegame data 
+	 * Synchronize savegame data
 	 */
 	void synchronize(Common::Serializer &s);
 };
diff --git a/engines/access/events.h b/engines/access/events.h
index 95ba926..965e8e7 100644
--- a/engines/access/events.h
+++ b/engines/access/events.h
@@ -29,9 +29,9 @@
 
 namespace Access {
 
-enum CursorType { 
+enum CursorType {
 	CURSOR_NONE = -1,
-	CURSOR_ARROW = 0, CURSOR_CROSSHAIRS, CURSOR_2, CURSOR_3, CURSOR_LOOK, 
+	CURSOR_ARROW = 0, CURSOR_CROSSHAIRS, CURSOR_2, CURSOR_3, CURSOR_LOOK,
 	CURSOR_USE, CURSOR_TAKE, CURSOR_CLIMB, CURSOR_TALK, CURSOR_HELP,
 	CURSOR_INVENTORY = 99
 };
diff --git a/engines/access/files.cpp b/engines/access/files.cpp
index 9fff6c4..b846cbd 100644
--- a/engines/access/files.cpp
+++ b/engines/access/files.cpp
@@ -187,7 +187,7 @@ void FileManager::handleFile(Resource *res) {
 
 	bool isCompressed = !strncmp(header, "DBE", 3);
 
-	// If the data is compressed, uncompress it and replace the stream 
+	// If the data is compressed, uncompress it and replace the stream
 	// in the resource with the decompressed one
 	if (isCompressed) {
 		// Read in the entire compressed data
@@ -214,7 +214,7 @@ void FileManager::setAppended(Resource *res, int fileNum) {
 	// If a different file has been opened then previously, load its index
 	if (_fileNumber != fileNum) {
 		_fileNumber = fileNum;
-			
+
 		// Read in the file index
 		int count = res->_file.readUint16LE();
 		assert(count <= 100);
diff --git a/engines/access/font.cpp b/engines/access/font.cpp
index 5686cdf..51fb9dc 100644
--- a/engines/access/font.cpp
+++ b/engines/access/font.cpp
@@ -50,7 +50,7 @@ void Font::load(const int *fontIndex, const byte *fontData) {
 			int bitsLeft = 0;
 			byte srcByte = 0;
 			byte pixel;
-			
+
 			byte *pDest = (byte *)_chars[i].getBasePtr(0, y);
 			for (int x = 0; x < _chars[i].w; ++x, ++pDest) {
 				// Get the pixel
@@ -115,8 +115,8 @@ bool Font::getLine(Common::String &s, int maxWidth, Common::String &line, int &w
 			s = "";
 			return true;
 		}
-		
-		// Work backwards to find space at the start of the current word 
+
+		// Work backwards to find space at the start of the current word
 		// as a point to split the line on
 		while (src >= s.c_str() && *src != ' ') {
 			width -= charWidth(*src);
diff --git a/engines/access/inventory.cpp b/engines/access/inventory.cpp
index 1bf3bdc..d9e1b49 100644
--- a/engines/access/inventory.cpp
+++ b/engines/access/inventory.cpp
@@ -93,16 +93,15 @@ int &InventoryManager::operator[](int idx) {
 	return (idx >= (int)_inv.size()) ? invalid : _inv[idx]._value;
 }
 
-int InventoryManager::useItem() { 
+int InventoryManager::useItem() {
 	return _vm->_useItem;
 }
 
-void InventoryManager::setUseItem(int itemId) { 
-	_vm->_useItem = itemId; 
+void InventoryManager::setUseItem(int itemId) {
+	_vm->_useItem = itemId;
 }
 
 void InventoryManager::refreshInventory() {
-	
 	// The original version was using pre-rendering for the inventory to spare some time.
 	// This is not needed on modern hardware, and it breaks a couple of things.
 	// Therefore it was removed in order to keep the same logic than for the CD version
@@ -120,7 +119,7 @@ int InventoryManager::newDisplayInv() {
 
 	_invModeFlag = true;
 	_vm->_timers.saveTimers();
-	
+
 	if (!room._tile && !_invRefreshFlag) {
 		saveScreens();
 	}
@@ -361,7 +360,7 @@ void InventoryManager::saveScreens() {
 	_vm->_buffer1.copyTo(&_savedBuffer1);
 	_vm->_screen->copyTo(&_savedScreen);
 	_vm->_newRects.push_back(Common::Rect(0, 0, _savedScreen.w, _savedScreen.h));
-	
+
 }
 
 void InventoryManager::restoreScreens() {
@@ -425,7 +424,7 @@ void InventoryManager::combineItems() {
 		Common::Point newPt;
 		newPt.x = MAX(events._mousePos.x - tempMouse.x + tempBox.x, 0);
 		newPt.y = MAX(events._mousePos.y - tempMouse.y + tempBox.y, 0);
-		
+
 		screen.plotImage(sprites, invItem, newPt);
 		lastBox = newPt;
 	}
@@ -435,7 +434,7 @@ void InventoryManager::combineItems() {
 			&& _items[destBox] != -1) {
 		int itemA = invItem;
 		int itemB = _items[destBox];
-		
+
 		// Check whether the items can be combined
 		int combinedItem = _inv[itemA].checkItem(itemB);
 		if (combinedItem != -1) {
@@ -454,7 +453,7 @@ void InventoryManager::combineItems() {
 			Common::Rect destRect(_invCoords[destBox].left, _invCoords[destBox].top,
 				_invCoords[destBox].left + 46, _invCoords[destBox].top + 35);
 			_vm->_buffer2.copyBlock(&_vm->_buffer1, destRect);
-			screen._screenYOff = 0;			
+			screen._screenYOff = 0;
 			zoomIcon(itemB, -1, destBox, true);
 
 			// Exand up the new combined item from nothing to full size
diff --git a/engines/access/martian/martian_resources.cpp b/engines/access/martian/martian_resources.cpp
index ae63f66..046e06c 100644
--- a/engines/access/martian/martian_resources.cpp
+++ b/engines/access/martian/martian_resources.cpp
@@ -32,11 +32,11 @@ const char *const FILENAMES[] = {
 	"R08.AP", "R09.AP", "R10.AP", "R11.AP", "R12.AP", "R13.AP", "R14.AP", "R15.AP",
 	"R16.AP", "R17.AP", "R18.AP", "R19.AP", "R20.AP", "R21.AP", "R22.AP", "R23.AP",
 	"R24.AP", "R25.AP", "R26.AP", "R27.AP", "R28.AP", "R29.AP", "R30.AP", "R31.AP",
-	"R32.AP", "R33.AP", "R34.AP", "R35.AP", "R36.AP", "R37.AP", "R38.AP", "R39.AP", 
+	"R32.AP", "R33.AP", "R34.AP", "R35.AP", "R36.AP", "R37.AP", "R38.AP", "R39.AP",
 	"R40.AP","TITLE.AP","R42.AP","S01.AP",  "R44.AP", "R45.AP","SOUND.AP","MUSIC.AP",
 	"DEAD.AP","EST.AP", "W02.AP", "C02.AP", "C05.AP", "C04.AP", "C10.AP", "C03.AP",
-	"C07.AP", "LOVE.AP","CAFE.AP","C08.AP", "C18.AP", "C19.AP", "C21.AP", "C23.AP", 
-	"C12.AP", "C16.AP","CAFE1.AP","C05A.AP","C06.AP","C11.AP", "C13.AP", "C20.AP", 
+	"C07.AP", "LOVE.AP","CAFE.AP","C08.AP", "C18.AP", "C19.AP", "C21.AP", "C23.AP",
+	"C12.AP", "C16.AP","CAFE1.AP","C05A.AP","C06.AP","C11.AP", "C13.AP", "C20.AP",
 	"C16A.AP","C09.AP", "R45.AP", "R46.AP", "R47.AP", "R48.AP", "R49.AP"
 };
 
@@ -653,9 +653,9 @@ const byte CHAR_TABLE27[] = {
 const byte *CHAR_TABLE[] = {
 	CHAR_TABLE0, nullptr, CHAR_TABLE2, CHAR_TABLE3, CHAR_TABLE4, CHAR_TABLE5,
 	CHAR_TABLE6, CHAR_TABLE7, CHAR_TABLE8, CHAR_TABLE9, CHAR_TABLE10,
-	CHAR_TABLE11, CHAR_TABLE12, CHAR_TABLE13, nullptr, CHAR_TABLE15, 
-	CHAR_TABLE16, nullptr, CHAR_TABLE18, CHAR_TABLE19, CHAR_TABLE20, 
-	CHAR_TABLE21, nullptr, CHAR_TABLE23, CHAR_TABLE24, CHAR_TABLE25, 
+	CHAR_TABLE11, CHAR_TABLE12, CHAR_TABLE13, nullptr, CHAR_TABLE15,
+	CHAR_TABLE16, nullptr, CHAR_TABLE18, CHAR_TABLE19, CHAR_TABLE20,
+	CHAR_TABLE21, nullptr, CHAR_TABLE23, CHAR_TABLE24, CHAR_TABLE25,
 	CHAR_TABLE26, CHAR_TABLE27
 };
 
diff --git a/engines/access/martian/martian_room.cpp b/engines/access/martian/martian_room.cpp
index 62c44bc..2bd9818 100644
--- a/engines/access/martian/martian_room.cpp
+++ b/engines/access/martian/martian_room.cpp
@@ -49,7 +49,7 @@ void MartianRoom::reloadRoom() {
 		_vm->_currentMan = _roomFlag;
 		_vm->_currentManOld = _roomFlag;
 		_vm->_manScaleOff = 0;
-		
+
 		switch (_vm->_currentMan) {
 		case 0:
 			_vm->_player->loadSprites("MAN.LZ");
@@ -73,7 +73,7 @@ void MartianRoom::reloadRoom() {
 }
 
 void MartianRoom::reloadRoom1() {
-	if (_vm->_player->_roomNumber == 29 || _vm->_player->_roomNumber == 31 
+	if (_vm->_player->_roomNumber == 29 || _vm->_player->_roomNumber == 31
 			|| _vm->_player->_roomNumber == 42 || _vm->_player->_roomNumber == 44) {
 		//Resource *spriteData = _vm->_files->loadFile("MAYA.LZ");
 		//_vm->_inactive._spritesPtr = new SpriteResource(_vm, spriteData);
diff --git a/engines/access/player.cpp b/engines/access/player.cpp
index 97d7d48..5668e9c 100644
--- a/engines/access/player.cpp
+++ b/engines/access/player.cpp
@@ -146,7 +146,7 @@ void Player::removeSprite1() {
 
 void Player::calcManScale() {
 	if (!_vm->_manScaleOff) {
-		_vm->_scale = ((((_rawPlayer.y - _vm->_scaleMaxY + _vm->_scaleN1) * 
+		_vm->_scale = ((((_rawPlayer.y - _vm->_scaleMaxY + _vm->_scaleN1) *
 			_vm->_scaleT1 + (_vm->_scaleH2 << 8)) & 0xff00) / _vm->_scaleH1 * _vm->_scaleI) >> 8;
 		_vm->_screen->setScaleTable(_vm->_scale);
 
@@ -159,7 +159,7 @@ void Player::calcManScale() {
 void Player::walk() {
 	_collideFlag = false;
 	_playerDirection = NONE;
-	
+
 	if (_playerOff)
 		return;
 	else if (_vm->_timers[0]._flag) {
@@ -223,7 +223,7 @@ void Player::walkUp() {
 	int walkOff = _walkOffUp[_frame - _upWalkMin];
 	int tempL = _rawPlayerLow.y - _vm->_screen->_scaleTable2[walkOff];
 	_rawYTempL = (byte)tempL;
-	int yTemp = _rawPlayer.y - _vm->_screen->_scaleTable1[walkOff] - 
+	int yTemp = _rawPlayer.y - _vm->_screen->_scaleTable1[walkOff] -
 		(tempL < 0 ? 1 : 0);
 	_rawYTemp = yTemp;
 	_rawXTemp = _rawPlayer.x;
@@ -233,7 +233,7 @@ void Player::walkUp() {
 	} else {
 		_rawPlayer.y = _rawYTemp;
 		_rawPlayerLow.y = _rawYTempL;
-		
+
 		calcManScale();
 
 		// This code looks totally useless as 'si' is unconditionally set in plotCom
@@ -297,7 +297,7 @@ void Player::walkLeft() {
 			(tempL < 0 ? 1 : 0);
 	} else {
 		_rawXTemp = _rawPlayer.x - _vm->_screen->_scaleTable1[_scrollConst];
-	}	
+	}
 	_rawYTemp = _rawPlayer.y;
 
 	if (_vm->_room->codeWalls()) {
@@ -378,7 +378,7 @@ void Player::walkUpLeft() {
 	} else {
 		_rawXTemp = _rawPlayer.x - _vm->_screen->_scaleTable1[_scrollConst];
 	}
-	
+
 	walkOffset = _walkOffUL[_frame - _diagUpWalkMin].y;
 	tempL = _rawPlayerLow.y - _vm->_screen->_scaleTable2[walkOffset];
 	_rawYTempL = (byte)tempL;
@@ -446,7 +446,7 @@ void Player::walkDownLeft() {
 
 		++_frame;
 		calcManScale();
-		
+
 		// This code looks totally useless as 'si' is unconditionally set in plotCom1
 		//if (_vm->_currentMan != 3 && (_frame == 1 || _frame == 5))
 		//	warning("TODO: walkDownLeft - si = 0?");
@@ -668,7 +668,7 @@ void Player::checkScroll() {
 		if (!scrollRight()) {
 			if (_playerDirection == DOWNLEFT)
 				goto scrollUp;
-			
+
 			return;
 		}
 	} else if ((_playerDirection == UPRIGHT || _playerDirection == DOWNRIGHT ||
@@ -678,7 +678,7 @@ void Player::checkScroll() {
 		if (!scrollLeft()) {
 			if (_playerDirection == DOWNRIGHT)
 				goto scrollUp;
-	
+
 			return;
 		}
 	}
diff --git a/engines/access/resources.cpp b/engines/access/resources.cpp
index 9bef5cf..41f611d 100644
--- a/engines/access/resources.cpp
+++ b/engines/access/resources.cpp
@@ -26,7 +26,7 @@
 namespace Access {
 
 const byte INITIAL_PALETTE[18 * 3] = {
-	0x00, 0x00, 0x00, 
+	0x00, 0x00, 0x00,
 	0xff, 0xff, 0xff,
 	0xf0, 0xf0, 0xf0,
 	0xe0, 0xe0, 0xe0,
@@ -73,7 +73,7 @@ const char *GO_MESSAGE = "YOU CAN'T CLIMB THAT.";
 const char *HELP_MESSAGE = "THIS OBJECT REQUIRES NO HINTS";
 const char *TALK_MESSAGE      = "THERE SEEMS TO BE NO RESPONSE.";
 const char *const GENERAL_MESSAGES[] = {
-	LOOK_MESSAGE, OPEN_MESSAGE, MOVE_MESSAGE, GET_MESSAGE, USE_MESSAGE, 
+	LOOK_MESSAGE, OPEN_MESSAGE, MOVE_MESSAGE, GET_MESSAGE, USE_MESSAGE,
 	GO_MESSAGE, TALK_MESSAGE, HELP_MESSAGE, HELP_MESSAGE, USE_MESSAGE
 };
 
diff --git a/engines/access/room.cpp b/engines/access/room.cpp
index 97341b0..b3c3317 100644
--- a/engines/access/room.cpp
+++ b/engines/access/room.cpp
@@ -266,7 +266,7 @@ void Room::setupRoom() {
 			screen._scrollCol -= sx + 1;
 		}
 	}
-	
+
 	if (screen._vWindowHeight == _playFieldHeight) {
 		screen._scrollY = 0;
 		screen._scrollRow = 0;
@@ -317,7 +317,7 @@ void Room::buildColumn(int playX, int screenX) {
 	if (playX < 0 || playX >= _playFieldWidth)
 		return;
 
-	const byte *pSrc = _playField + _vm->_screen->_scrollRow * 
+	const byte *pSrc = _playField + _vm->_screen->_scrollRow *
 		_playFieldWidth + playX;
 
 	// WORKAROUND: Original's use of '+ 1' would frequently cause memory overruns
@@ -406,7 +406,7 @@ Plotter::Plotter() {
 void Plotter::load(Common::SeekableReadStream *stream, int wallCount, int blockCount) {
 	// Load the wall count
 	_walls.resize(wallCount);
-	
+
 	for (int i = 0; i < wallCount; ++i)
 		_walls[i].left = stream->readSint16LE();
 	for (int i = 0; i < wallCount; ++i)
@@ -474,7 +474,7 @@ void Room::doCommands() {
 	}
 }
 
-void Room::cycleCommand(int incr) {	
+void Room::cycleCommand(int incr) {
 	int command = _selectCommand + incr;
 	if (command < -1)
 		command = 6;
@@ -560,7 +560,7 @@ void Room::executeCommand(int commandId) {
 	delete iconData;
 
 	// Draw the button as selected
-	_vm->_screen->plotImage(spr, _selectCommand + 2, 
+	_vm->_screen->plotImage(spr, _selectCommand + 2,
 		Common::Point(RMOUSE[_selectCommand][0], 176));
 
 	_vm->_screen->restoreScreen();
@@ -569,7 +569,7 @@ void Room::executeCommand(int commandId) {
 
 void Room::walkCursor() {
 	EventsManager &events = *_vm->_events;
-	
+
 	events._normalMouse = CURSOR_CROSSHAIRS;
 	events.setCursor(CURSOR_CROSSHAIRS);
 	_vm->_scripts->_sequence = 5000;
@@ -698,7 +698,7 @@ bool Room::codeWalls() {
 			if ((player._rawYTemp >= screen._orgY1) &&
 					(player._rawYTemp <= screen._orgY2)) {
 				jf._wallCode |= (calcLR(player._rawYTemp) - player._rawXTemp) < 0 ? 2 : 1;
-				jf._wallCode1 |= (calcLR(player._rawYTemp) - 
+				jf._wallCode1 |= (calcLR(player._rawYTemp) -
 					(player._rawXTemp + player._playerOffset.x)) < 0 ? 2 : 1;
 			}
 		}
diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp
index 053e824..ec41f37 100644
--- a/engines/access/scripts.cpp
+++ b/engines/access/scripts.cpp
@@ -109,29 +109,29 @@ typedef void(Scripts::*ScriptMethodPtr)();
 
 void Scripts::executeCommand(int commandIndex) {
 	static const ScriptMethodPtr COMMAND_LIST[] = {
-		&Scripts::cmdObject, &Scripts::cmdEndObject, &Scripts::cmdJumpLook, 
+		&Scripts::cmdObject, &Scripts::cmdEndObject, &Scripts::cmdJumpLook,
 		&Scripts::cmdJumpHelp, &Scripts::cmdJumpGet, &Scripts::cmdJumpMove,
-		&Scripts::cmdJumpUse, &Scripts::cmdJumpTalk, &Scripts::cmdNull, 
+		&Scripts::cmdJumpUse, &Scripts::cmdJumpTalk, &Scripts::cmdNull,
 		&Scripts::cmdPrint, &Scripts::cmdRetPos, &Scripts::cmdAnim,
-		&Scripts::cmdSetFlag, &Scripts::cmdCheckFlag, &Scripts::cmdGoto, 
-		&Scripts::cmdAddScore, &Scripts::cmdSetInventory, &Scripts::cmdCheckInventory, 
-		&Scripts::cmdSetTex, &Scripts::cmdNewRoom, &Scripts::cmdConverse, 
-		&Scripts::cmdCheckFrame, &Scripts::cmdCheckAnim, &Scripts::cmdSnd, 
-		&Scripts::cmdRetNeg, &Scripts::cmdRetPos, &Scripts::cmdCheckLoc, 
-		&Scripts::cmdSetAnim, &Scripts::cmdDispInv, &Scripts::cmdSetAbout, 
+		&Scripts::cmdSetFlag, &Scripts::cmdCheckFlag, &Scripts::cmdGoto,
+		&Scripts::cmdAddScore, &Scripts::cmdSetInventory, &Scripts::cmdCheckInventory,
+		&Scripts::cmdSetTex, &Scripts::cmdNewRoom, &Scripts::cmdConverse,
+		&Scripts::cmdCheckFrame, &Scripts::cmdCheckAnim, &Scripts::cmdSnd,
+		&Scripts::cmdRetNeg, &Scripts::cmdRetPos, &Scripts::cmdCheckLoc,
+		&Scripts::cmdSetAnim, &Scripts::cmdDispInv, &Scripts::cmdSetAbout,
 		&Scripts::cmdSetTimer, &Scripts::cmdCheckTimer, &Scripts::cmdSetTravel,
-		&Scripts::cmdJumpGoto, &Scripts::cmdSetVideo, &Scripts::cmdPlayVideo, 
-		&Scripts::cmdPlotImage, &Scripts::cmdSetDisplay, &Scripts::cmdSetBuffer, 
-		&Scripts::cmdSetScroll, &Scripts::cmdSaveRect, &Scripts::cmdVideoEnded, 
-		&Scripts::cmdSetBufVid, &Scripts::cmdPlayBufVid, &Scripts::cmdRemoveLast, 
+		&Scripts::cmdJumpGoto, &Scripts::cmdSetVideo, &Scripts::cmdPlayVideo,
+		&Scripts::cmdPlotImage, &Scripts::cmdSetDisplay, &Scripts::cmdSetBuffer,
+		&Scripts::cmdSetScroll, &Scripts::cmdSaveRect, &Scripts::cmdVideoEnded,
+		&Scripts::cmdSetBufVid, &Scripts::cmdPlayBufVid, &Scripts::cmdRemoveLast,
 		&Scripts::cmdDoTravel, &Scripts::cmdCheckAbout, &Scripts::cmdSpecial,
-		&Scripts::cmdSetCycle, &Scripts::cmdCycle, &Scripts::cmdCharSpeak, 
-		&Scripts::cmdTexSpeak, &Scripts::cmdTexChoice, &Scripts::cmdWait, 
-		&Scripts::cmdSetConPos, &Scripts::cmdCheckVFrame, &Scripts::cmdJumpChoice, 
-		&Scripts::cmdReturnChoice, &Scripts::cmdClearBlock, &Scripts::cmdLoadSound, 
+		&Scripts::cmdSetCycle, &Scripts::cmdCycle, &Scripts::cmdCharSpeak,
+		&Scripts::cmdTexSpeak, &Scripts::cmdTexChoice, &Scripts::cmdWait,
+		&Scripts::cmdSetConPos, &Scripts::cmdCheckVFrame, &Scripts::cmdJumpChoice,
+		&Scripts::cmdReturnChoice, &Scripts::cmdClearBlock, &Scripts::cmdLoadSound,
 		&Scripts::cmdFreeSound, &Scripts::cmdSetVideoSound, &Scripts::cmdPlayVideoSound,
-		&Scripts::cmdPrintWatch, &Scripts::cmdDispAbout, &Scripts::CMDPUSHLOCATION, 
-		&Scripts::cmdCheckTravel, &Scripts::cmdBlock, &Scripts::cmdPlayerOff, 
+		&Scripts::cmdPrintWatch, &Scripts::cmdDispAbout, &Scripts::CMDPUSHLOCATION,
+		&Scripts::cmdCheckTravel, &Scripts::cmdBlock, &Scripts::cmdPlayerOff,
 		&Scripts::cmdPlayerOn, &Scripts::cmdDead, &Scripts::cmdFadeOut,
 		&Scripts::cmdEndVideo
 	};
@@ -139,11 +139,11 @@ void Scripts::executeCommand(int commandIndex) {
 	(this->*COMMAND_LIST[commandIndex])();
 }
 
-void Scripts::cmdObject() { 
+void Scripts::cmdObject() {
 	_vm->_bubbleBox->load(_data);
 }
 
-void Scripts::cmdEndObject() { 
+void Scripts::cmdEndObject() {
 	printString(GENERAL_MESSAGES[_vm->_room->_selectCommand]);
 }
 
@@ -154,35 +154,35 @@ void Scripts::cmdJumpLook() {
 		_data->skip(2);
 }
 
-void Scripts::cmdJumpHelp() { 
+void Scripts::cmdJumpHelp() {
 	if (_vm->_room->_selectCommand == 8)
 		cmdGoto();
 	else
 		_data->skip(2);
 }
 
-void Scripts::cmdJumpGet() { 
+void Scripts::cmdJumpGet() {
 	if (_vm->_room->_selectCommand == 3)
 		cmdGoto();
 	else
 		_data->skip(2);
 }
 
-void Scripts::cmdJumpMove() { 
+void Scripts::cmdJumpMove() {
 	if (_vm->_room->_selectCommand == 2)
 		cmdGoto();
 	else
 		_data->skip(2);
 }
 
-void Scripts::cmdJumpUse() { 
+void Scripts::cmdJumpUse() {
 	if (_vm->_room->_selectCommand == 4)
 		cmdGoto();
 	else
 		_data->skip(2);
 }
 
-void Scripts::cmdJumpTalk() { 
+void Scripts::cmdJumpTalk() {
 	if (_vm->_room->_selectCommand == 6)
 		cmdGoto();
 	else
@@ -234,12 +234,12 @@ void Scripts::cmdRetPos() {
 	_returnCode = 0;
 }
 
-void Scripts::cmdAnim() { 
+void Scripts::cmdAnim() {
 	int animId = _data->readByte();
 	_vm->_animation->animate(animId);
 }
 
-void Scripts::cmdSetFlag() { 
+void Scripts::cmdSetFlag() {
 	int flagNum = _data->readByte();
 	byte flagVal = _data->readByte();
 	assert(flagNum < 256);
@@ -247,7 +247,7 @@ void Scripts::cmdSetFlag() {
 	_vm->_flags[flagNum] = flagVal;
 }
 
-void Scripts::cmdCheckFlag() { 
+void Scripts::cmdCheckFlag() {
 	int flagNum = _data->readUint16LE();
 	int flagVal = _data->readUint16LE();
 	assert(flagNum < 256);
@@ -258,7 +258,7 @@ void Scripts::cmdCheckFlag() {
 		_data->skip(2);
 }
 
-void Scripts::cmdGoto() { 
+void Scripts::cmdGoto() {
 	_sequence = _data->readUint16LE();
 	searchForSequence();
 }
@@ -272,7 +272,7 @@ void Scripts::cmdAddScore() {
 	_data->skip(1);
 }
 
-void Scripts::cmdSetInventory() { 
+void Scripts::cmdSetInventory() {
 	int itemId = _data->readByte();
 	int itemVal = _data->readByte();
 
@@ -282,7 +282,7 @@ void Scripts::cmdSetInventory() {
 	_vm->_inventory->_invChangeFlag = true;
 }
 
-void Scripts::cmdCheckInventory() { 
+void Scripts::cmdCheckInventory() {
 	int itemId = _data->readUint16LE();
 	int itemVal = _data->readUint16LE();
 
@@ -323,7 +323,7 @@ void Scripts::cmdSetTex() {
 
 #define CURRENT_ROOM 0xFF
 
-void Scripts::cmdNewRoom() { 
+void Scripts::cmdNewRoom() {
 	int roomNumber = _data->readByte();
 	if (roomNumber != CURRENT_ROOM)
 		_vm->_player->_roomNumber = roomNumber;
@@ -334,7 +334,7 @@ void Scripts::cmdNewRoom() {
 	cmdRetPos();
 }
 
-void Scripts::cmdConverse() { 
+void Scripts::cmdConverse() {
 	_vm->_conversation = _data->readUint16LE();
 	_vm->_room->clearRoom();
 	_vm->freeChar();
@@ -397,7 +397,7 @@ void Scripts::cmdCheckLoc() {
 		_data->skip(2);
 }
 
-void Scripts::cmdSetAnim() { 
+void Scripts::cmdSetAnim() {
 	int animId = _data->readByte();
 	Animation *anim = _vm->_animation->setAnimation(animId);
 
@@ -471,7 +471,7 @@ void Scripts::cmdJumpGoto() {
 		_data->skip(2);
 }
 
-void Scripts::cmdSetVideo() { 
+void Scripts::cmdSetVideo() {
 	Common::Point pt;
 	pt.x = _data->readSint16LE();
 	pt.y = _data->readSint16LE();
@@ -481,7 +481,7 @@ void Scripts::cmdSetVideo() {
 	_vm->_video->setVideo(_vm->_screen, pt, _vm->_extraCells[cellIndex]._vid, rate);
 }
 
-void Scripts::cmdPlayVideo() { 
+void Scripts::cmdPlayVideo() {
 	_vm->_video->playVideo();
 }
 
@@ -520,7 +520,7 @@ void Scripts::cmdSaveRect() {
 	error("TODO: DEMO - cmdSaveRect");
 }
 
-void Scripts::cmdVideoEnded() { 
+void Scripts::cmdVideoEnded() {
 	_vm->_events->pollEvents();
 
 	if (_vm->_video->_videoEnd) {
@@ -565,7 +565,7 @@ void Scripts::cmdCheckAbout() {
 	error("TODO: DEMO - cmdCheckAbout");
 }
 
-void Scripts::cmdSpecial() { 
+void Scripts::cmdSpecial() {
 	_specialFunction = _data->readUint16LE();
 	int p1 = _data->readUint16LE();
 	int p2 = _data->readUint16LE();
@@ -585,7 +585,7 @@ void Scripts::cmdSpecial() {
 	}
 }
 
-void Scripts::cmdSetCycle() { 
+void Scripts::cmdSetCycle() {
 	int startCycle = _data->readUint16LE();
 	int endCycle = _data->readUint16LE();
 	int timer = _data->readUint16LE();
@@ -628,7 +628,7 @@ void Scripts::cmdTexSpeak() {
 #define BTN_COUNT 6
 void Scripts::cmdTexChoice() {
 	static const int BTN_RANGES[BTN_COUNT][2] = {
-		{ 0, 76 }, { 77, 154 }, { 155, 232 }, { 233, 276 }, { 0, 0 }, 
+		{ 0, 76 }, { 77, 154 }, { 155, 232 }, { 233, 276 }, { 0, 0 },
 		{ 277, 319 }
 	};
 
@@ -714,12 +714,12 @@ void Scripts::cmdTexChoice() {
 			}
 		}
 	} while ((choice == -1) || ((choice == 2) && choice3Fl));
-	
+
 	_choice = choice + 1;
 	_vm->_bubbleBox->clearBubbles();
 }
 
-void Scripts::cmdWait() { 
+void Scripts::cmdWait() {
 	int time = _data->readSint16LE();
 	_vm->_timers[3]._timer = time;
 	_vm->_timers[3]._initTm = time;
@@ -750,7 +750,7 @@ void Scripts::cmdSetConPos() {
 	_texsOrg = Common::Point(x, y);
 }
 
-void Scripts::cmdCheckVFrame() { 
+void Scripts::cmdCheckVFrame() {
 	if (_vm->_video->_videoFrame == _data->readSint16LE())
 		cmdGoto();
 	else
@@ -759,7 +759,7 @@ void Scripts::cmdCheckVFrame() {
 
 void Scripts::cmdJumpChoice() {
 	int val = (_data->readUint16LE() & 0xFF);
-	
+
 	if (val == _choice) {
 		_sequence = _data->readUint16LE();
 		searchForSequence();
@@ -783,7 +783,7 @@ void Scripts::cmdLoadSound() {
 	_vm->_sound->_soundTable.push_back(SoundEntry(sound, 1));
 }
 
-void Scripts::cmdFreeSound() { 
+void Scripts::cmdFreeSound() {
 	SoundManager &sound = *_vm->_sound;
 
 	if (sound._soundTable.size() > 0 && sound._soundTable[0]._res) {
@@ -812,7 +812,7 @@ void Scripts::cmdSetVideoSound() {
 	_vm->_video->_soundFlag = false;
 }
 
-void Scripts::cmdPlayVideoSound() { 
+void Scripts::cmdPlayVideoSound() {
 	_vm->_video->playVideo();
 	if (_vm->_video->_soundFrame == _vm->_video->_videoFrame &&
 			!_vm->_video->_soundFlag) {
@@ -829,7 +829,7 @@ void Scripts::cmdPrintWatch() {
 		CMDPUSHLOCATION();
 		return;
 	}
-	error("TODO: DEMO - cmdPrintWatch"); 
+	error("TODO: DEMO - cmdPrintWatch");
 }
 
 void Scripts::cmdDispAbout() {
@@ -837,11 +837,11 @@ void Scripts::cmdDispAbout() {
 		CMDPUSHLOCATION();
 		return;
 	}
-	error("TODO: DEMO - cmdDispAbout"); 
+	error("TODO: DEMO - cmdDispAbout");
 }
 
 void Scripts::CMDPUSHLOCATION() {
-	error("TODO CMDPUSHLOCATION"); 
+	error("TODO CMDPUSHLOCATION");
 }
 
 void Scripts::cmdCheckTravel() {
@@ -849,7 +849,7 @@ void Scripts::cmdCheckTravel() {
 		CMDPUSHLOCATION();
 		return;
 	}
-	error("TODO: DEMO - cmdCheckTravel"); 
+	error("TODO: DEMO - cmdCheckTravel");
 }
 
 void Scripts::cmdBlock() {
@@ -857,7 +857,7 @@ void Scripts::cmdBlock() {
 		CMDPUSHLOCATION();
 		return;
 	}
-	error("TODO: DEMO - cmdBlock"); 
+	error("TODO: DEMO - cmdBlock");
 }
 
 void Scripts::cmdPlayerOff() {
@@ -868,7 +868,7 @@ void Scripts::cmdPlayerOn() {
 	_vm->_player->_playerOff = false;
 }
 
-void Scripts::cmdDead() { 
+void Scripts::cmdDead() {
 	int deathId = _data->readByte();
 	_vm->dead(deathId);
 }
diff --git a/engines/access/sound.cpp b/engines/access/sound.cpp
index 7dab0a7..95576d2 100644
--- a/engines/access/sound.cpp
+++ b/engines/access/sound.cpp
@@ -30,7 +30,7 @@
 
 namespace Access {
 
-SoundManager::SoundManager(AccessEngine *vm, Audio::Mixer *mixer) : 
+SoundManager::SoundManager(AccessEngine *vm, Audio::Mixer *mixer) :
 		_vm(vm), _mixer(mixer) {
 	_playingSound = false;
 	_isVoice = false;
@@ -71,7 +71,7 @@ void SoundManager::playSound(Resource *res, int priority) {
 	byte *resourceData = res->data();
 	Audio::SoundHandle audioHandle;
 	Audio::RewindableAudioStream *audioStream = 0;
-	
+
 	assert(res->_size >= 32);
 
 	if (READ_BE_UINT32(resourceData) == MKTAG('R','I','F','F')) {
@@ -92,7 +92,7 @@ void SoundManager::playSound(Resource *res, int priority) {
 		//   word    - actual sample size (should be resource-size - 32)
 		byte internalSampleRate = resourceData[5];
 		int sampleSize = READ_LE_UINT16(resourceData + 7);
-	
+
 		assert( (sampleSize + 32) == res->_size);
 
 		int sampleRate = 0;
@@ -105,12 +105,12 @@ void SoundManager::playSound(Resource *res, int priority) {
 			error("Unexpected internal Sample Rate %d", internalSampleRate);
 			return;
 		}
-	
+
 		audioStream = Audio::makeRawStream(resourceData + 32, sampleSize, sampleRate, 0);
 
 	} else
 		error("Unknown format");
-	
+
 	audioHandle = Audio::SoundHandle();
 	_mixer->playStream(Audio::Mixer::kSFXSoundType, &audioHandle,
 						audioStream, -1, _mixer->kMaxChannelVolume, 0,
@@ -119,7 +119,7 @@ void SoundManager::playSound(Resource *res, int priority) {
 	/*
 	Audio::QueuingAudioStream *audioStream = Audio::makeQueuingAudioStream(22050, false);
 	audioStream->queueBuffer(data, size, DisposeAfterUse::YES, 0);
-	_mixer->playStream(Audio::Mixer::kPlainSoundType, &_soundHandle, audioStream, -1, 
+	_mixer->playStream(Audio::Mixer::kPlainSoundType, &_soundHandle, audioStream, -1,
 		Audio::Mixer::kMaxChannelVolume, 0, DisposeAfterUse::YES, false);
 		*/
 }
diff --git a/engines/access/video.cpp b/engines/access/video.cpp
index 776c58a..abe833c 100644
--- a/engines/access/video.cpp
+++ b/engines/access/video.cpp
@@ -54,7 +54,7 @@ void VideoPlayer::setVideo(ASurface *vidSurface, const Common::Point &pt, const
 	_header._height = _videoData->_stream->readUint16LE();
 	_videoData->_stream->skip(1);
 	_header._flags = (VideoFlags)_videoData->_stream->readByte();
-	
+
 	_startCoord = (byte *)vidSurface->getBasePtr(pt.x, pt.y);
 	_frameCount = _header._frameCount - 2;
 	_xCount = _header._width;
@@ -72,7 +72,7 @@ void VideoPlayer::setVideo(ASurface *vidSurface, const Common::Point &pt, const
 
 		if (vidSurface == _vm->_screen)
 			_vm->_newRects.push_back(Common::Rect(pt.x, pt.y, pt.x + _xCount, pt.y + _scanCount));
-		
+
 		getFrame();
 	}
 
@@ -115,7 +115,7 @@ void VideoPlayer::playVideo() {
 			pDest += count;
 		} else {
 			// Read count number of pixels
-			
+
 			// Load across lines if necessary
 			while (count >= (pLine + _xCount - pDest)) {
 				int lineCount = (pLine + _xCount - pDest);
@@ -143,12 +143,12 @@ void VideoPlayer::playVideo() {
 void VideoPlayer::copyVideo() {
 	_vm->_player->calcPlayer();
 	Common::Rect r = Common::Rect(_vm->_vidX - _vm->_screen->_bufferStart.x,
-		_vm->_vidY - _vm->_screen->_bufferStart.y, 
+		_vm->_vidY - _vm->_screen->_bufferStart.y,
 		_vm->_vidX - _vm->_screen->_bufferStart.x + _header._width,
 		_vm->_vidY - _vm->_screen->_bufferStart.y + _header._height);
 	if (!_vm->_screen->clip(r))
 		return;
-	
+
 	_vm->_newRects.push_back(r);
 	int vh = _header._height;
 	int vw = _header._width;


Commit: 1f42800e0cd2b4ab08bba78edbe69f657dc89367
    https://github.com/scummvm/scummvm/commit/1f42800e0cd2b4ab08bba78edbe69f657dc89367
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-12T23:00:57-05:00

Commit Message:
ACCESS: Further cleanup of river obstacles checks

Changed paths:
    engines/access/amazon/amazon_game.cpp
    engines/access/amazon/amazon_logic.cpp
    engines/access/amazon/amazon_resources.h



diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp
index deb45ff..79fca87 100644
--- a/engines/access/amazon/amazon_game.cpp
+++ b/engines/access/amazon/amazon_game.cpp
@@ -627,6 +627,9 @@ void AmazonEngine::dead(int deathId) {
 			_screen->forceFadeIn();
 			_sound->playSound(0);
 			_screen->forceFadeOut();
+
+			if (shouldQuit())
+				return;
 		}
 		freeCells();
 
diff --git a/engines/access/amazon/amazon_logic.cpp b/engines/access/amazon/amazon_logic.cpp
index 428b85f..a7ee432 100644
--- a/engines/access/amazon/amazon_logic.cpp
+++ b/engines/access/amazon/amazon_logic.cpp
@@ -1635,8 +1635,9 @@ void River::moveCanoe2() {
 void River::updateObstacles() {
 	RiverStruct *cur;
 	for (cur = _topList; cur < RIVER_OBJECTS[_riverIndex][RIVER_END]; ++cur) {
-		int val = cur->_field1 + cur->_riverX - 1;
+		int val = cur->_riverX + cur->_width - 1;
 		if (val < _screenVertX)
+			// Obstacle is not yet on-scren
 			break;
 
 		if (cur->_riverX < (_screenVertX + 319)) {
@@ -1645,7 +1646,7 @@ void River::updateObstacles() {
 
 			while (cur < RIVER_OBJECTS[_riverIndex][RIVER_END]) {
 				++cur;
-				val = cur->_field1 + cur->_riverX - 1;
+				val = cur->_riverX + cur->_width - 1;
 				if (val < _screenVertX || (cur->_riverX >= (_screenVertX + 319)))
 					break;
 
@@ -1676,19 +1677,19 @@ bool River::checkRiverCollide() {
 
 	_canoeVXPos = _screenVertX + 170;
 
-	for (RiverStruct *si = _topList; si <= _botList; ++si) {
-		if (si->_lane < _canoeLane)
+	for (RiverStruct *cur = _topList; cur <= _botList; ++cur) {
+		if (cur->_lane < _canoeLane)
 			continue;
 
-		if ((si->_lane == _canoeLane) || (si->_lane == _canoeLane + 1)) {
-			if (si->_field1 + si->_riverX - 1 >= _canoeVXPos) {
-				if (_canoeVXPos + 124 >= si->_riverX) {
-					_vm->_sound->playSound(4);
-					return true;
-				}
+		if ((cur->_lane == _canoeLane) || (cur->_lane == _canoeLane + 1)) {
+			if ((cur->_riverX + cur->_width - 1) >= _canoeVXPos &&
+					cur->_riverX < (_canoeVXPos + 124)) {
+				_vm->_sound->playSound(4);
+				return true;
 			}
 		}
 	}
+
 	return false;
 }
 
diff --git a/engines/access/amazon/amazon_resources.h b/engines/access/amazon/amazon_resources.h
index b6b0dbb..777c579 100644
--- a/engines/access/amazon/amazon_resources.h
+++ b/engines/access/amazon/amazon_resources.h
@@ -31,7 +31,7 @@ namespace Amazon {
 
 struct RiverStruct {
 	int _id;
-	int _field1;
+	int _width;
 	int _riverX;
 	int _xp;
 	int _lane;


Commit: c41d7bab2b3bdfd04a1872d2261866660c8b0bf3
    https://github.com/scummvm/scummvm/commit/c41d7bab2b3bdfd04a1872d2261866660c8b0bf3
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-12T23:01:06-05:00

Commit Message:
ACCESS: Add some data for the character info used by the demo

Changed paths:
    engines/access/amazon/amazon_resources.cpp
    engines/access/amazon/amazon_resources.h
    engines/access/char.cpp



diff --git a/engines/access/amazon/amazon_resources.cpp b/engines/access/amazon/amazon_resources.cpp
index bd4e4f8..509c8bc 100644
--- a/engines/access/amazon/amazon_resources.cpp
+++ b/engines/access/amazon/amazon_resources.cpp
@@ -1383,6 +1383,31 @@ const byte LETTER[] = {
 	0x0, 0x0, 0x0, 0x30, 0x0, 0x5, 0x0, 0xFF, 0xFF
 };
 
+const byte OVERBOARD_DEMO[] = {
+	0x02, 0xFF, 0xFF, 0x22, 0x00, 0x01, 0x00, 0xFF, 0xFF, 0xFF,
+	0xFF, 0x00, 0x00, 0x00, 0x00, 0x22, 0x22, 0x00, 0x02, 0x00,
+	0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x22, 0x00, 0x00, 0x00, 0x22,
+	0x00, 0x03, 0x00, 0x22, 0x00, 0x06, 0x00, 0x22, 0x00, 0x04,
+	0x00, 0x22, 0x00, 0x07, 0x00, 0x22, 0x00, 0x05, 0x00, 0x62,
+	0x00, 0x1D, 0x00, 0x60, 0x00, 0x00, 0x00, 0x22, 0x00, 0x06,
+	0x00, 0x60, 0x00, 0x01, 0x00, 0x22, 0x00, 0x07, 0x00, 0xFF,
+	0xFF
+};
+
+const byte SHORE1[] = {
+	0x02, 0xFF, 0xFF, 0x55, 0x00, 0x01, 0x00, 0xFF, 0xFF, 0xFF,
+	0xFF, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x03, 0x00,
+	0x55, 0x00, 0x00, 0x00, 0x55, 0x00, 0x02, 0x00, 0x62, 0x00,
+	0x2E, 0x00, 0x55, 0x00, 0x02, 0x00, 0x62, 0x00, 0x2F, 0x00,
+	0xFF, 0xFF
+};
+
+const byte CHAP8[] = {
+	0x02, 0xFF, 0xFF, 0x60, 0x00, 0x03, 0x00, 0xFF, 0xFF, 0xFF,
+	0xFF, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
+	0x60, 0x00, 0x02, 0x00, 0xFF, 0xFF 
+};
+
 const byte *CHARTBL[] = {
 	ELAINE, LIB, FLASHBACK, ALLENDIE, OVERBOARD, PILOT2, TIKAGENT,
 	BARTENDER, PILOT1, COOK, BEXPLODE, THORNICK, MAYA, CAPTAIN,
@@ -1392,6 +1417,13 @@ const byte *CHARTBL[] = {
 	CRACK, LETTER
 };
 
+const byte *CHARTBL_DEMO[] = {
+	ELAINE, LIB, FLASHBACK, ALLENDIE, OVERBOARD_DEMO, PILOT2, TIKAGENT,
+	BARTENDER, PILOT1, COOK, BEXPLODE, THORNICK, MAYA, CAPTAIN,
+	ALLEN, ARCH, GUARD1, MCANOE, CAMPFIRE, COLONEL, SOLDIERS,
+	JWATER, SHOOT, ADIE, DYNAMITE, SHORE1, CHAP8
+};
+
 const char *const INVENTORY_NAMES[] = {
 	"RAT", "ALCOHOL", "SAFE COMBINATION", "BEAKER", "MICROFILM",
 	"VAULT KEY", "BOLT CUTTERS", "BLOWGUN", "LOVE POTION", "MONEY",
diff --git a/engines/access/amazon/amazon_resources.h b/engines/access/amazon/amazon_resources.h
index 777c579..6e35ca0 100644
--- a/engines/access/amazon/amazon_resources.h
+++ b/engines/access/amazon/amazon_resources.h
@@ -64,6 +64,7 @@ extern const byte *ROOM_TABLE_DEMO[];
 extern const int ROOM_NUMB;
 
 extern const byte *CHARTBL[];
+extern const byte *CHARTBL_DEMO[];
 
 extern const char *const INVENTORY_NAMES[];
 
diff --git a/engines/access/char.cpp b/engines/access/char.cpp
index 8ce43a5..d5eec3e 100644
--- a/engines/access/char.cpp
+++ b/engines/access/char.cpp
@@ -71,8 +71,13 @@ CharManager::CharManager(AccessEngine *vm) : Manager(vm) {
 	switch (vm->getGameID()) {
 	case GType_Amazon:
 		// Setup character list
-		for (int i = 0; i < 37; ++i)
-			_charTable.push_back(CharEntry(Amazon::CHARTBL[i]));
+		if (_vm->isDemo()) {
+			for (int i = 0; i < 27; ++i)
+				_charTable.push_back(CharEntry(Amazon::CHARTBL_DEMO[i]));
+		} else {
+			for (int i = 0; i < 37; ++i)
+				_charTable.push_back(CharEntry(Amazon::CHARTBL[i]));
+		}
 		break;
 	default:
 		error("Unknown game");


Commit: 59099a72057ff2e242679955a80e29d425219c8a
    https://github.com/scummvm/scummvm/commit/59099a72057ff2e242679955a80e29d425219c8a
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-12T23:01:16-05:00

Commit Message:
ACCESS: Fix cmdDead for the demo

Changed paths:
    engines/access/amazon/amazon_game.cpp
    engines/access/amazon/amazon_resources.cpp
    engines/access/amazon/amazon_resources.h



diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp
index 79fca87..3252754 100644
--- a/engines/access/amazon/amazon_game.cpp
+++ b/engines/access/amazon/amazon_game.cpp
@@ -124,9 +124,16 @@ void AmazonEngine::setupGame() {
 
 	// Load death list
 	_deaths.resize(58);
-	for (int i = 0; i < 58; ++i) {
-		_deaths[i]._screenId = DEATH_SCREENS[i];
-		_deaths[i]._msg = DEATH_TEXT[i];
+	if (isDemo()) {
+		for (int i = 0; i < 34; ++i) {
+			_deaths[i]._screenId = DEATH_SCREENS_DEMO[i];
+			_deaths[i]._msg = DEATH_TEXT_DEMO[i];
+		}
+	} else {
+		for (int i = 0; i < 58; ++i) {
+			_deaths[i]._screenId = DEATH_SCREENS[i];
+			_deaths[i]._msg = DEATH_TEXT[i];
+		}
 	}
 	_deaths._cells.resize(12);
 	for (int i = 0; i < 12; ++i)
@@ -616,7 +623,8 @@ void AmazonEngine::dead(int deathId) {
 	_screen->setPanel(3);
 
 	if (deathId != 10) {
-		_midi->newMusic(62, 0);
+		if (!isDemo())
+			_midi->newMusic(62, 0);
 		_files->_setPaletteFlag = false;
 		_files->loadScreen(94, 0);
 		_files->_setPaletteFlag = true;
@@ -631,43 +639,72 @@ void AmazonEngine::dead(int deathId) {
 			if (shouldQuit())
 				return;
 		}
-		freeCells();
 
-		// Load the cell list for the death screen
-		DeathEntry &de = _deaths[deathId];
-		Common::Array<CellIdent> cells;
-		cells.push_back(_deaths._cells[de._screenId]);
-		loadCells(cells);
+		if (!isDemo()) {
+			freeCells();
 
-		_screen->setDisplayScan();
-		_files->_setPaletteFlag = false;
-		_files->loadScreen(&_buffer2, 94, 1);
-		_screen->setIconPalette();
-
-		_buffer2.plotImage(_objectsTable[0], 0, Common::Point(105, 25));
-		_buffer2.copyTo(_screen);
-		_screen->forceFadeIn();
-
-		_fonts._charSet._hi = 10;
-		_fonts._charSet._lo = 1;
-		_fonts._charFor._lo = 55;
-		_fonts._charFor._hi = 255;
-		_screen->_maxChars = 46;
-		_screen->_printOrg = Common::Point(20, 155);
-		_screen->_printStart = Common::Point(20, 155);
-
-		Common::String &msg = de._msg;
-		_printEnd = 180;
-		printText(_screen, msg);
-		_screen->forceFadeOut();
+			// Load the cell list for the death screen
+			DeathEntry &de = _deaths[deathId];
+			Common::Array<CellIdent> cells;
+			cells.push_back(_deaths._cells[de._screenId]);
+			loadCells(cells);
 
-		_midi->newMusic(0, 1);
-		_events->showCursor();
-		_room->clearRoom();
-		freeChar();
+			_screen->setDisplayScan();
+			_files->_setPaletteFlag = false;
+			_files->loadScreen(&_buffer2, 94, 1);
+			_screen->setIconPalette();
+
+			_buffer2.plotImage(_objectsTable[0], 0, Common::Point(105, 25));
+			_buffer2.copyTo(_screen);
+			_screen->forceFadeIn();
+
+			_fonts._charSet._hi = 10;
+			_fonts._charSet._lo = 1;
+			_fonts._charFor._lo = 55;
+			_fonts._charFor._hi = 255;
+			_screen->_maxChars = 46;
+			_screen->_printOrg = Common::Point(20, 155);
+			_screen->_printStart = Common::Point(20, 155);
 
-		_currentManOld = 1;
-		_player->removeSprite1();
+			Common::String &msg = de._msg;
+			_printEnd = 180;
+
+			printText(_screen, msg);
+			_screen->forceFadeOut();
+
+			_midi->newMusic(0, 1);
+			_events->showCursor();
+			_room->clearRoom();
+			freeChar();
+
+			_currentManOld = 1;
+			_player->removeSprite1();
+
+		} else {
+			_files->loadScreen(_screen, 94, _deaths[deathId]._screenId);
+			_screen->forceFadeIn();
+
+			_fonts._charSet._hi = 10;
+			_fonts._charSet._lo = 1;
+			_fonts._charFor._lo = 55;
+			_fonts._charFor._hi = 255;
+			_screen->_maxChars = 49;
+			_screen->_printOrg = Common::Point(15, 165);
+			_screen->_printStart = Common::Point(15, 165);
+
+			Common::String msg = Common::String(_deaths[deathId]._msg);
+			_printEnd = 200;
+
+			printText(_screen, msg);
+			_screen->fadeOut();
+
+			_events->showCursor();
+			_room->clearRoom();
+			freeChar();
+
+			_currentManOld = 1;
+			_player->removeSprite1();
+		}
 
 		warning("TODO: restart game");
 		quitGame();
diff --git a/engines/access/amazon/amazon_resources.cpp b/engines/access/amazon/amazon_resources.cpp
index 509c8bc..ed4a012 100644
--- a/engines/access/amazon/amazon_resources.cpp
+++ b/engines/access/amazon/amazon_resources.cpp
@@ -1660,6 +1660,13 @@ const byte DEATH_SCREENS[58] = {
 	8,  0,  5,  8,  0, 12, 12,  11
 };
 
+const byte DEATH_SCREENS_DEMO[34] = {
+	1, 2, 1, 1, 1, 1, 1, 1, 4, 1,
+	3, 4, 2, 4, 2, 1, 1, 1, 1, 1,
+	1, 4, 2, 4, 2, 4, 2, 4, 4, 4,
+	1, 1, 1, 1
+};
+
 const char *const DEATH_TEXT[58] = {
 	"SAM SALVADOR SPOTS YOU AND LETS YOU HAVE IT.",
 	"WHILE TAKING A MOONLIGHT SWIM YOU DISCOVER THAT PIRANHA REALLY CAN STRIP FLESH TO THE BONE.",
@@ -1755,6 +1762,43 @@ const char *const DEATH_TEXT[58] = {
 		"TWENTY YEARS LATER YOU ARE RELEASED FROM A SOUTH AMERICAN PRISON."
 };
 
+const char *const DEATH_TEXT_DEMO[34] = {
+	"SAM SALVADOR SPOTS YOU AND LETS YOU HAVE IT.",
+	"WHILE TAKING A MOONLIGHT SWIM YOU DISCOVER THAT PIRANHA REALLY CAN STRIP FLESH TO THE BONE.",
+	"THE GUARD FILLS YOU FULL OF HOLES BEFORE TOSSING YOU TO THE PIRANHA.",
+	"YOU'RE ONLY ABLE TO SWIM HALFWAY ACROSS THE RIVER BEFORE RUNNING OUT OF AIR.  YOU MAKE SO MUCH NOISE GASPING FOR BREATH THAT SAM EASILY FINDS YOU AND LEAVES YOU IN THE RIVER PERMANENTLY.",
+	"SAM SALVADOR NOTICES SOMEONE HAS BEEN PLAYING WITH THE CARGO. HE TRACKS YOU DOWN AND LETS YOU HAVE IT.",
+	"THE GUARD COMES AROUND THE CORNER.  HE DECIDES THAT THREE LEAD SLUGS WILL TEACH YOU TO BE MORE POLITE.",
+	"THE CAPTAIN IS WAITING OUTSIDE THE DOOR.",
+	"THE CAPTAIN',27h,'S RANDOM SHOOTING FINALLY FINDS ITS TARGET.",
+	"THE CRATE OUTSIDE THE WINDOW EXPLODES, DESTROYING THE SHIP.  UNFORTUNATELY, YOU'RE STILL ABOARD.",
+	"THE DOOR WAS NOT BARRED AND THE CAPTAIN WALKS RIGHT IN AND PARTS YOUR HAIR.",
+	"",
+	"YOU RUN OUT ON DECK, THEN REALIZE THAT MAYA IS STILL TIED UP.  AS YOU TURN TO GO BACK THE BOAT BLOWS UP.",
+	"AFTER YOU FAIL TO PROVE YOUR DIVINITY THE NATIVES EAT YOU FOR LUNCH.",
+	"THIS IS THE GENERIC DEATH SCENE",
+	"YOU ONLY MAKE IT HALFWAY ACROSS THE RIVER BEFORE THE PIRANHA STRIKE.",
+	"WITH NOTHING TO PROTECT HIM FROM THE HAIL OF BULLETS ALLEN IS QUICKLY GUNNED DOWN.  JASON AND MAYA SOON FOLLOW...",
+	"THE COMBINATION OF THE WIND AND GUNFIRE KNOCK THE CORRUGATED IRON OVER, LEAVING YOU WITHOUT PROTECTION.",
+	"WITHOUT SUFFICIENT AMMUNITION, ALLEN IS UNABLE TO HOLD OFF THE ATTACKERS FOR LONG.  THIS RESULTS IN A SERIOUS CASE OF LEAD POISONING.",
+	"ALLEN IS A MARVELOUS SHOT, BUT HIS AMMUNITION IS NOT UNLIMITED.  SOON IT IS ALL OVER.",
+	"THE PILOT FEELS YOU ARE TOO CLOSE AND PULLS THE TRIGGER.",
+	"THE PILOT SHOOTS YOU IN THE HEAD, THEN TOSSES YOUR LIFELESS",
+	"THE PLANE CRASHES INTO THE JUNGLE CANOPY AT 200 MPH.",
+	"THE CANOE HITS THE ROCKS AND CAPSIZES, AND THE PIRANHA MAKE YOU THEIR LUNCH GUESTS.",
+	"YOU ACCIDENTALLY DISCOVER THE FOURTH TALLEST WATERFALL IN SOUTH AMERICA.",
+	"YOU DISCOVER A VERY HUNGRY TRIBE OF CANNIBALS.",
+	"YOU BECOME LOST IN THE WINDING WATERWAYS AND WANDER UNTIL YOU STARVE TO DEATH.",
+	"YOU BECOME TRAPPED IN THE RAPIDS AND ARE CRUSHED BETWEEN THE ROCKS.",
+	"YOU WAIT AROUND FOR SOME TIME, BUT HANS STROHEIM NEVER SPEAKS TO YOU AGAIN.  FINALLY YOU RETURN HOME KNOWING YOU HAVE FAILED.",
+	"DECIDING THAT YOU THREATEN HIM AND HIS WORK, HANS STROHEIM HAS THE NATIVES IN THE VILLAGE KILL YOU.",
+	"YOU DO NOT GET FAR ENOUGH AWAY BEFORE THE DYNAMITE EXPLODES AND YOU ARE BLOWN INTO A THOUSAND PIECES.",
+	"STANDING OUT IN THE OPEN YOU ARE EXPOSED TO THE HAIL OF BULLETS FROM SANCHEZ' MEN.",
+	"THE AMAZON SENTINELS SPOT YOU AND FILL YOU FULL OF ARROWS.",
+	"SAM MAY BE UGLY, BUT HE',27h,'S NOT DEAF.  HE HEARS ALL THE NOISE YOU ARE MAKING AND CANCELS YOUR BOARDING PASS.",
+	"WITH THE BAR OFF THE DOOR THE CAPTAIN WALTZES IN AND BLOWS YOU AWAY"
+};
+
 const int DEATH_CELLS[12][3] = {
 	{ 0, 94, 3 },
 	{ 0, 94, 4 },
diff --git a/engines/access/amazon/amazon_resources.h b/engines/access/amazon/amazon_resources.h
index 6e35ca0..92e0cec 100644
--- a/engines/access/amazon/amazon_resources.h
+++ b/engines/access/amazon/amazon_resources.h
@@ -84,8 +84,10 @@ extern const char *const BAR_MESSAGE;
 extern const char *const HELPLVLTXT[3];
 extern const char *const IQLABELS[9];
 extern const byte DEATH_SCREENS[58];
+extern const byte DEATH_SCREENS_DEMO[34];
 
 extern const char *const DEATH_TEXT[58];
+extern const char *const DEATH_TEXT_DEMO[34];
 
 extern const int DEATH_CELLS[12][3];
 


Commit: 84d77b7daf8473cd25196ae9445015ed3656797a
    https://github.com/scummvm/scummvm/commit/84d77b7daf8473cd25196ae9445015ed3656797a
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-12T23:01:27-05:00

Commit Message:
ACCESS: Fix the inventory behavior in the floppy and demo version

Changed paths:
    engines/access/inventory.cpp



diff --git a/engines/access/inventory.cpp b/engines/access/inventory.cpp
index d9e1b49..78a85c3 100644
--- a/engines/access/inventory.cpp
+++ b/engines/access/inventory.cpp
@@ -168,7 +168,9 @@ int InventoryManager::newDisplayInv() {
 
 	restoreFields();
 	screen.restorePalette();
-	if (!screen._vesaMode && !_invRefreshFlag) {
+	// The original was testing the vesa mode too.
+	// We removed this check as we don't use pre-rendering
+	if (!_invRefreshFlag) {
 		screen.clearBuffer();
 		screen.setPalette();
 	}
@@ -179,10 +181,10 @@ int InventoryManager::newDisplayInv() {
 		screen.setBufferScan();
 		room.buildScreen();
 
-		if (!screen._vesaMode) {
-			screen.fadeOut();
-			_vm->copyBF2Vid();
-		}
+		// The original was doing a check on the vesa mode at this point.
+		// We don't need it as we don't do inventory pre-rendering
+		screen.fadeOut();
+		_vm->copyBF2Vid();
 	}
 
 	events._cursorExitFlag = false;
@@ -275,7 +277,9 @@ void InventoryManager::initFields() {
 
 	_vm->_buffer1.clearBuffer();
 	_vm->_buffer2.clearBuffer();
-	if (!_invRefreshFlag && !screen._vesaMode)
+	// The original was doing at this point a check on vesa mode
+	// We don't need it as we don't do inventory pre-rendering
+	if (!_invRefreshFlag)
 		screen.clearBuffer();
 
 	screen.savePalette();


Commit: 67b3304f710a6888943e8b029237b246377d4026
    https://github.com/scummvm/scummvm/commit/67b3304f710a6888943e8b029237b246377d4026
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-12T23:01:37-05:00

Commit Message:
ACCESS: Clean up keyboard control

Changed paths:
    engines/access/access.cpp
    engines/access/amazon/amazon_game.cpp
    engines/access/amazon/amazon_logic.cpp
    engines/access/events.cpp
    engines/access/events.h
    engines/access/scripts.cpp



diff --git a/engines/access/access.cpp b/engines/access/access.cpp
index 2153f59..55fe251 100644
--- a/engines/access/access.cpp
+++ b/engines/access/access.cpp
@@ -229,7 +229,7 @@ void AccessEngine::speakText(ASurface *s, const Common::String &msg) {
 						_events->debounceLeft();
 						_sndSubFile += soundsLeft;
 						break;
-					} else if (_events->_keypresses.size() != 0) {
+					} else if (_events->isKeyPending()) {
 						_sndSubFile += soundsLeft;
 						break;
 					} else {
@@ -272,7 +272,7 @@ void AccessEngine::speakText(ASurface *s, const Common::String &msg) {
 			_events->debounceLeft();
 			_sndSubFile += soundsLeft;
 			break;
-		} else if (_events->_keypresses.size() != 0) {
+		} else if (_events->isKeyPending()) {
 			_sndSubFile += soundsLeft;
 			break;
 		} else {
diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp
index 3252754..902cfcd 100644
--- a/engines/access/amazon/amazon_game.cpp
+++ b/engines/access/amazon/amazon_game.cpp
@@ -489,8 +489,7 @@ void AmazonEngine::startChapter(int chapter) {
 		_sound->freeSounds();
 
 		// Wait loop
-		while (!shouldQuit() && !_events->_leftButton && !_events->_rightButton
-				&& _events->_keypresses.size() == 0 && _timers[20]._flag) {
+		while (!shouldQuit() && !_events->isKeyMousePressed() && _timers[20]._flag) {
 			_events->pollEvents();
 			g_system->delayMillis(10);
 		}
@@ -531,8 +530,7 @@ void AmazonEngine::startChapter(int chapter) {
 	_timers[20]._flag++;
 
 	// Wait loop
-	while (!shouldQuit() && !_events->_leftButton && !_events->_rightButton
-		&& _events->_keypresses.size() == 0 && _timers[20]._flag) {
+	while (!shouldQuit() && !_events->isKeyMousePressed() && _timers[20]._flag) {
 		_events->pollEvents();
 		g_system->delayMillis(10);
 	}
diff --git a/engines/access/amazon/amazon_logic.cpp b/engines/access/amazon/amazon_logic.cpp
index a7ee432..5def481 100644
--- a/engines/access/amazon/amazon_logic.cpp
+++ b/engines/access/amazon/amazon_logic.cpp
@@ -158,12 +158,9 @@ void CampScene::mWhileDoOpen() {
 
 		events.pollEventsAndWait();
 
-		if (events._leftButton || events._rightButton || events._keypresses.size() > 0) {
+		if (_vm->_events->isKeyMousePressed()) {
 			_skipStart = true;
 			_vm->_midi->newMusic(10, 1);
-
-			events.debounceLeft();
-			events.zeroKeys();
 			break;
 		}
 
diff --git a/engines/access/events.cpp b/engines/access/events.cpp
index 87e5d10..60073e6 100644
--- a/engines/access/events.cpp
+++ b/engines/access/events.cpp
@@ -45,6 +45,7 @@ EventsManager::EventsManager(AccessEngine *vm): _vm(vm) {
 	_mouseCol = _mouseRow = 0;
 	_cursorExitFlag = false;
 	_vbCount = 0;
+	_keyCode = Common::KEYCODE_INVALID;
 }
 
 EventsManager::~EventsManager() {
@@ -141,7 +142,7 @@ void EventsManager::pollEvents(bool skipTimers) {
 				_vm->_debugger->attach();
 				_vm->_debugger->onFrame();
 			} else {
-				_keypresses.push(event.kbd);
+				keyControl(event.kbd.keycode);
 			}
 			return;
 		case Common::EVENT_KEYUP:
@@ -181,6 +182,11 @@ void EventsManager::pollEvents(bool skipTimers) {
 	}
 }
 
+void EventsManager::keyControl(Common::KeyCode keycode) {
+	_keyCode = keycode;
+	// TODO: Keypress handling
+}
+
 void EventsManager::pollEventsAndWait() {
 	pollEvents();
 	g_system->delayMillis(10);
@@ -219,18 +225,23 @@ void EventsManager::delay(int time) {
 }
 
 void EventsManager::zeroKeys() {
-	_keypresses.clear();
+	_keyCode = Common::KEYCODE_INVALID;
 }
 
 bool EventsManager::getKey(Common::KeyState &key) {
-	if (_keypresses.empty()) {
+	if (_keyCode == Common::KEYCODE_INVALID) {
 		return false;
 	} else {
-		key = _keypresses.pop();
+		key = _keyCode;
+		_keyCode = Common::KEYCODE_INVALID;
 		return true;
 	}
 }
 
+bool EventsManager::isKeyPending() const {
+	return _keyCode != Common::KEYCODE_INVALID;
+}
+
 void EventsManager::debounceLeft() {
 	while (_leftButton && !_vm->shouldQuit()) {
 		pollEvents();
@@ -240,17 +251,14 @@ void EventsManager::debounceLeft() {
 
 void EventsManager::clearEvents() {
 	_leftButton = _rightButton = false;
-	_keypresses.clear();
+	zeroKeys();
 }
 
 void EventsManager::waitKeyMouse() {
-	while (!_vm->shouldQuit() && !_leftButton && _keypresses.size() == 0) {
+	while (!_vm->shouldQuit() && isKeyMousePressed()) {
 		pollEvents(true);
 		g_system->delayMillis(10);
 	}
-
-	zeroKeys();
-	debounceLeft();
 }
 
 Common::Point EventsManager::calcRawMouse() {
@@ -278,7 +286,7 @@ int EventsManager::checkMouseBox1(Common::Array<Common::Rect> &rects) {
 }
 
 bool EventsManager::isKeyMousePressed() {
-	bool result = _leftButton || _rightButton || _keypresses.size() > 0;
+	bool result = _leftButton || _rightButton || isKeyPending();
 	debounceLeft();
 	zeroKeys();
 
diff --git a/engines/access/events.h b/engines/access/events.h
index 965e8e7..ffb0dba 100644
--- a/engines/access/events.h
+++ b/engines/access/events.h
@@ -46,8 +46,11 @@ private:
 	AccessEngine *_vm;
 	uint32 _frameCounter;
 	uint32 _priorFrameTime;
+	Common::KeyCode _keyCode;
+
 	Graphics::Surface _invCursor;
 	void nextFrame(bool skipTimers);
+	void keyControl(Common::KeyCode keycode);
 public:
 	CursorType _cursorId;
 	CursorType _normalMouse;
@@ -58,7 +61,6 @@ public:
 	int _mouseCol, _mouseRow;
 	bool _cursorExitFlag;
 	int _vbCount;
-	Common::FixedStack<Common::KeyState> _keypresses;
 public:
 	/**
 	 * Constructor
@@ -113,6 +115,8 @@ public:
 
 	bool getKey(Common::KeyState &key);
 
+	bool isKeyPending() const;
+
 	void delay(int time);
 
 	void debounceLeft();
diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp
index ec41f37..728421c 100644
--- a/engines/access/scripts.cpp
+++ b/engines/access/scripts.cpp
@@ -443,7 +443,7 @@ void Scripts::cmdCheckTimer() {
 	if (_endFlag)
 		return;
 
-	if ((idx == 9) && (_vm->_events->_keypresses.size() > 0)) {
+	if ((idx == 9) && _vm->_events->isKeyPending()) {
 		_vm->_events->zeroKeys();
 		_vm->_timers[9]._timer = 0;
 		_vm->_timers[9]._flag = 0;
@@ -724,10 +724,9 @@ void Scripts::cmdWait() {
 	_vm->_timers[3]._timer = time;
 	_vm->_timers[3]._initTm = time;
 	_vm->_timers[3]._flag++;
-	_vm->_events->_keypresses.clear();
+	_vm->_events->zeroKeys();
 
-	while (!_vm->shouldQuit() && _vm->_events->_keypresses.empty() &&
-			!_vm->_events->_leftButton && !_vm->_events->_rightButton &&
+	while (!_vm->shouldQuit() && !_vm->_events->isKeyMousePressed() &&
 			_vm->_timers[3]._flag) {
 		_vm->_midi->midiRepeat();
 		charLoop();


Commit: 7cd7bb9b54266f952c4049875532e587b0278415
    https://github.com/scummvm/scummvm/commit/7cd7bb9b54266f952c4049875532e587b0278415
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-12T23:01:46-05:00

Commit Message:
ACCESS: Implement player keyboard movement

Changed paths:
    engines/access/events.cpp
    engines/access/events.h



diff --git a/engines/access/events.cpp b/engines/access/events.cpp
index 60073e6..a1be7ff 100644
--- a/engines/access/events.cpp
+++ b/engines/access/events.cpp
@@ -27,6 +27,7 @@
 #include "engines/util.h"
 #include "access/access.h"
 #include "access/events.h"
+#include "access/player.h"
 #include "access/amazon/amazon_resources.h"
 
 #define CURSOR_WIDTH 16
@@ -142,10 +143,11 @@ void EventsManager::pollEvents(bool skipTimers) {
 				_vm->_debugger->attach();
 				_vm->_debugger->onFrame();
 			} else {
-				keyControl(event.kbd.keycode);
+				keyControl(event.kbd.keycode, true);
 			}
 			return;
 		case Common::EVENT_KEYUP:
+			keyControl(event.kbd.keycode, false);
 			return;
 		case Common::EVENT_MOUSEMOVE:
 			_mousePos = event.mouse;
@@ -182,9 +184,51 @@ void EventsManager::pollEvents(bool skipTimers) {
 	}
 }
 
-void EventsManager::keyControl(Common::KeyCode keycode) {
+void EventsManager::keyControl(Common::KeyCode keycode, bool isKeyDown) {
+	Player &player = *_vm->_player;
+
+	if (!isKeyDown) {
+		if (player._move != NONE) {
+			_keyCode = Common::KEYCODE_INVALID;
+			player._move = NONE;
+		}
+		return;
+	}
+	
 	_keyCode = keycode;
-	// TODO: Keypress handling
+	
+	switch (keycode) {
+	case Common::KEYCODE_UP:
+	case Common::KEYCODE_KP8:
+		player._move = UP;
+		break;
+	case Common::KEYCODE_DOWN:
+	case Common::KEYCODE_KP2:
+		player._move = DOWN;
+		break;
+	case Common::KEYCODE_LEFT:
+	case Common::KEYCODE_KP4:
+		player._move = LEFT;
+		break;
+	case Common::KEYCODE_RIGHT:
+	case Common::KEYCODE_KP6:
+		player._move = RIGHT;
+		break;
+	case Common::KEYCODE_KP7:
+		player._move = UPLEFT;
+		break;
+	case Common::KEYCODE_KP9:
+		player._move = UPRIGHT;
+		break;
+	case Common::KEYCODE_KP1:
+		player._move = DOWNLEFT;
+		break;
+	case Common::KEYCODE_KP3:
+		player._move = DOWNRIGHT;
+		break;
+	default:
+		break;
+	}
 }
 
 void EventsManager::pollEventsAndWait() {
diff --git a/engines/access/events.h b/engines/access/events.h
index ffb0dba..04edd2b 100644
--- a/engines/access/events.h
+++ b/engines/access/events.h
@@ -50,7 +50,7 @@ private:
 
 	Graphics::Surface _invCursor;
 	void nextFrame(bool skipTimers);
-	void keyControl(Common::KeyCode keycode);
+	void keyControl(Common::KeyCode keycode, bool isKeyDown);
 public:
 	CursorType _cursorId;
 	CursorType _normalMouse;


Commit: 40b84172969781899347aff208f87da9d243d0ba
    https://github.com/scummvm/scummvm/commit/40b84172969781899347aff208f87da9d243d0ba
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-12T23:01:54-05:00

Commit Message:
ACCESS: Correct down-right player movement

Changed paths:
    engines/access/player.cpp



diff --git a/engines/access/player.cpp b/engines/access/player.cpp
index 5668e9c..35c5dad 100644
--- a/engines/access/player.cpp
+++ b/engines/access/player.cpp
@@ -516,14 +516,14 @@ void Player::walkDownRight() {
 	_playerDirection = DOWNRIGHT;
 
 	int walkOffset, tempL;
-	bool flag = _scrollEnd == 1;
+	bool flag = _scrollEnd == 2;
 	if (!flag) {
 		calcPlayer();
-		flag = (_playerX - _vm->_screen->_scaleTable1[_scrollConst] -
+		flag = (_vm->_screen->_clipWidth -  _playerX - _vm->_screen->_scaleTable1[_scrollConst] -
 			_vm->_player->_scrollThreshold) > 0;
 	}
 	if (flag) {
-		walkOffset = _walkOffUR[_frame - _sideWalkMin].x;
+		walkOffset = _walkOffUR[_frame - _diagDownWalkMin].x;
 		tempL = _rawPlayerLow.x + _vm->_screen->_scaleTable2[walkOffset];
 		_rawTempL = (byte)tempL;
 		_rawXTemp = _rawPlayer.x + _vm->_screen->_scaleTable1[walkOffset] +
@@ -533,7 +533,7 @@ void Player::walkDownRight() {
 	}
 
 	walkOffset = _walkOffDR[_frame - _diagDownWalkMin].y;
-	tempL = _rawPlayerLow.y - _vm->_screen->_scaleTable2[walkOffset];
+	tempL = _rawPlayerLow.y + _vm->_screen->_scaleTable2[walkOffset];
 	_rawYTempL = (byte)tempL;
 	_rawYTemp = _rawPlayer.y + _vm->_screen->_scaleTable1[walkOffset] +
 		(tempL >= 0x100 ? 1 : 0);
@@ -546,17 +546,17 @@ void Player::walkDownRight() {
 		_rawPlayerLow.x = _rawTempL;
 		_rawPlayerLow.y = _rawYTempL;
 
-		++_frame;
 		calcManScale();
 
 		// This code looks totally useless as 'si' is unconditionally set in plotCom1
 		//if (_vm->_currentMan != 3 && (_frame == 1 || _frame == 5))
 		//	warning("TODO: walkDownRight - si = 0?");
 
+		++_frame;
 		if (_frame > _diagDownWalkMax)
 			_frame = _diagDownWalkMin;
 
-		plotCom1();
+		plotCom(0);
 	}
 }
 


Commit: a1e5e8be9481add1402ea337039b755937ef6441
    https://github.com/scummvm/scummvm/commit/a1e5e8be9481add1402ea337039b755937ef6441
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-12T23:02:06-05:00

Commit Message:
ACCESS: Cleaned up event handling for scene establish text display

Changed paths:
    engines/access/access.cpp
    engines/access/amazon/amazon_game.cpp
    engines/access/events.cpp



diff --git a/engines/access/access.cpp b/engines/access/access.cpp
index 55fe251..a09e47c 100644
--- a/engines/access/access.cpp
+++ b/engines/access/access.cpp
@@ -196,7 +196,7 @@ void AccessEngine::speakText(ASurface *s, const Common::String &msg) {
 	int curPage = 0;
 	int soundsLeft = 0;
 
-	for (;;) {
+	while (!shouldQuit()) {
 		soundsLeft = _countTbl[curPage];
 		_events->zeroKeys();
 
@@ -216,7 +216,7 @@ void AccessEngine::speakText(ASurface *s, const Common::String &msg) {
 			if (!_sound->_isVoice) {
 				_events->waitKeyMouse();
 			} else {
-				for (;;) {
+				while (!shouldQuit()) {
 					_sound->freeSounds();
 					Resource *sound = _sound->loadSound(_narateFile + 99, _sndSubFile);
 					_sound->_soundTable.push_back(SoundEntry(sound, 1));
@@ -225,11 +225,7 @@ void AccessEngine::speakText(ASurface *s, const Common::String &msg) {
 
 					_events->pollEvents();
 
-					if (_events->_leftButton) {
-						_events->debounceLeft();
-						_sndSubFile += soundsLeft;
-						break;
-					} else if (_events->isKeyPending()) {
+					if (_events->isKeyMousePressed()) {
 						_sndSubFile += soundsLeft;
 						break;
 					} else {
diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp
index 902cfcd..979fffe 100644
--- a/engines/access/amazon/amazon_game.cpp
+++ b/engines/access/amazon/amazon_game.cpp
@@ -201,6 +201,7 @@ void AmazonEngine::loadEstablish(int estabIndex) {
 void AmazonEngine::doEstablish(int screenId, int estabIndex) {
 	_establishMode = 1;
 
+	_events->clearEvents();
 	_screen->forceFadeOut();
 	_screen->clearScreen();
 	_screen->setPanel(3);
diff --git a/engines/access/events.cpp b/engines/access/events.cpp
index a1be7ff..5ed5ee2 100644
--- a/engines/access/events.cpp
+++ b/engines/access/events.cpp
@@ -299,7 +299,7 @@ void EventsManager::clearEvents() {
 }
 
 void EventsManager::waitKeyMouse() {
-	while (!_vm->shouldQuit() && isKeyMousePressed()) {
+	while (!_vm->shouldQuit() && !isKeyMousePressed()) {
 		pollEvents(true);
 		g_system->delayMillis(10);
 	}


Commit: bf361715e0c83ebb18914e8769a867a2c5c370c2
    https://github.com/scummvm/scummvm/commit/bf361715e0c83ebb18914e8769a867a2c5c370c2
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-12T23:02:16-05:00

Commit Message:
ACCESS: Simply river savegame fields

Changed paths:
    engines/access/amazon/amazon_logic.cpp
    engines/access/amazon/amazon_logic.h



diff --git a/engines/access/amazon/amazon_logic.cpp b/engines/access/amazon/amazon_logic.cpp
index 5def481..c9e8886 100644
--- a/engines/access/amazon/amazon_logic.cpp
+++ b/engines/access/amazon/amazon_logic.cpp
@@ -1351,9 +1351,6 @@ River::River(AmazonEngine *vm): PannedScene(vm) {
 	_rScrollCol = 0;
 	_rScrollX = 0;
 	_rScrollY = 0;
-	_rOldRectCount = 0;
-	_rNewRectCount = 0;
-	_rKeyFlag = 0;
 	_mapOffset = 0;
 	_screenVertX = 0;
 	_saveRiver = false;
@@ -1422,12 +1419,7 @@ void River::initRiver() {
 	_vm->copyBF2Vid();
 	_vm->_screen->forceFadeIn();
 
-	if (_saveRiver) {
-		// Restore draw rects from savegame
-		_vm->_oldRects.resize(_rOldRectCount);
-		_vm->_newRects.resize(_rNewRectCount);
-		// KEYFLG = _vm->_rKeyFlag
-	} else {
+	if (!_saveRiver) {
 		// Reset draw rects
 		_vm->_oldRects.clear();
 		_vm->_newRects.clear();
@@ -1904,13 +1896,8 @@ void River::synchronize(Common::Serializer &s) {
 		s.syncAsUint16LE(_rScrollCol);
 		s.syncAsSint16LE(_rScrollX);
 		s.syncAsSint16LE(_rScrollY);
-		s.syncAsUint16LE(_rOldRectCount);
-		s.syncAsUint16LE(_rNewRectCount);
-		s.syncAsUint16LE(_rKeyFlag);
 		s.syncAsUint16LE(_mapOffset);
 		s.syncAsUint16LE(_screenVertX);
-		warning("TODO: 	s.syncAsSint16LE(_topList);");
-		warning("TODO: 	s.syncAsSint16LE(_botList);");
 
 		_saveRiver = s.isLoading();
 	}
diff --git a/engines/access/amazon/amazon_logic.h b/engines/access/amazon/amazon_logic.h
index 14f5199..1cc65cb 100644
--- a/engines/access/amazon/amazon_logic.h
+++ b/engines/access/amazon/amazon_logic.h
@@ -181,9 +181,6 @@ private:
 	int _rScrollCol;
 	int _rScrollX;
 	int _rScrollY;
-	int _rOldRectCount;
-	int _rNewRectCount;
-	int _rKeyFlag;
 	int _mapOffset;
 	int _screenVertX;
 


Commit: b864b846356b6b20d6e6def414456b5d44fe88c7
    https://github.com/scummvm/scummvm/commit/b864b846356b6b20d6e6def414456b5d44fe88c7
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-12T23:02:30-05:00

Commit Message:
ACCESS: Fix the end of the demo

Changed paths:
    engines/access/amazon/amazon_game.cpp



diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp
index 979fffe..b425fe9 100644
--- a/engines/access/amazon/amazon_game.cpp
+++ b/engines/access/amazon/amazon_game.cpp
@@ -621,7 +621,11 @@ void AmazonEngine::dead(int deathId) {
 	_screen->clearScreen();
 	_screen->setPanel(3);
 
-	if (deathId != 10) {
+	if ((deathId == 10) && !isDemo()) {
+		quitGame();
+		_events->pollEvents();
+		return;
+	} else {
 		if (!isDemo())
 			_midi->newMusic(62, 0);
 		_files->_setPaletteFlag = false;
@@ -629,14 +633,16 @@ void AmazonEngine::dead(int deathId) {
 		_files->_setPaletteFlag = true;
 		_buffer2.copyFrom(*_screen);
 
-		for (int i = 0; i < 3; ++i) {
-			_sound->playSound(0);
-			_screen->forceFadeIn();
-			_sound->playSound(0);
-			_screen->forceFadeOut();
+		if (!isDemo() || deathId != 10) {
+			for (int i = 0; i < 3; ++i) {
+				_sound->playSound(0);
+				_screen->forceFadeIn();
+				_sound->playSound(0);
+				_screen->forceFadeOut();
 
-			if (shouldQuit())
-				return;
+				if (shouldQuit())
+					return;
+			}
 		}
 
 		if (!isDemo()) {
@@ -708,9 +714,6 @@ void AmazonEngine::dead(int deathId) {
 		warning("TODO: restart game");
 		quitGame();
 		_events->pollEvents();
-	} else {
-		quitGame();
-		_events->pollEvents();
 	}
 }
 


Commit: 3cf08939797c1963264cf1ef49ed227fba3daf00
    https://github.com/scummvm/scummvm/commit/3cf08939797c1963264cf1ef49ed227fba3daf00
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-12T23:02:41-05:00

Commit Message:
ACCESS: Add a cheat mode which currently skips the guard in chapter 8

Changed paths:
    engines/access/access.cpp
    engines/access/access.h
    engines/access/amazon/amazon_logic.cpp
    engines/access/debugger.cpp
    engines/access/debugger.h



diff --git a/engines/access/access.cpp b/engines/access/access.cpp
index a09e47c..428c4c6 100644
--- a/engines/access/access.cpp
+++ b/engines/access/access.cpp
@@ -88,6 +88,7 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc)
 	_sndSubFile = 0;
 	_loadSaveSlot = -1;
 	_vidX = _vidY = 0;
+	_cheatFl = false;
 }
 
 AccessEngine::~AccessEngine() {
diff --git a/engines/access/access.h b/engines/access/access.h
index 2fe4b72..2fdf263 100644
--- a/engines/access/access.h
+++ b/engines/access/access.h
@@ -207,7 +207,7 @@ public:
 	int _flags[256];
 
 	bool _clearSummaryFlag;
-
+	bool _cheatFl;
 	// Fields mapped into the flags array
 	int &_useItem;
 	int &_startup;
diff --git a/engines/access/amazon/amazon_logic.cpp b/engines/access/amazon/amazon_logic.cpp
index c9e8886..c1df535 100644
--- a/engines/access/amazon/amazon_logic.cpp
+++ b/engines/access/amazon/amazon_logic.cpp
@@ -1168,6 +1168,11 @@ void Guard::setGuardFrame() {
 }
 
 void Guard::doGuard() {
+	// Skip the code dealing with the guard on the boat (chapter 8)
+	// if the cheat mode is activated
+	if (_vm->_cheatFl)
+		return;
+
 	if (_vm->_timers[8]._flag) {
 		setGuardFrame();
 		return;
diff --git a/engines/access/debugger.cpp b/engines/access/debugger.cpp
index 6b49fb0..1f81004 100644
--- a/engines/access/debugger.cpp
+++ b/engines/access/debugger.cpp
@@ -57,6 +57,7 @@ Debugger *Debugger::init(AccessEngine *vm) {
 Debugger::Debugger(AccessEngine *vm) : GUI::Debugger(), _vm(vm) {
 	registerCmd("continue", WRAP_METHOD(Debugger, cmdExit));
 	registerCmd("scene", WRAP_METHOD(Debugger, Cmd_LoadScene));
+	registerCmd("cheat", WRAP_METHOD(Debugger, Cmd_Cheat));
 
 	switch (vm->getGameID()) {
 	case GType_Amazon:
@@ -120,6 +121,18 @@ bool Debugger::Cmd_LoadScene(int argc, const char **argv) {
 	}
 }
 
+bool Debugger::Cmd_Cheat(int argc, const char **argv) {
+	if (argc != 1) {
+		debugPrintf("Usage: %s\n", argv[0]);
+		debugPrintf("Switches on/off the cheat mode\n");
+		return true;
+	}
+
+	_vm->_cheatFl = !_vm->_cheatFl;
+	debugPrintf("Cheat is now %s\n", _vm->_cheatFl ? "ON" : "OFF");
+	return true;
+}
+
 /*------------------------------------------------------------------------*/
 
 namespace Amazon {
diff --git a/engines/access/debugger.h b/engines/access/debugger.h
index 839d131..6bd2374 100644
--- a/engines/access/debugger.h
+++ b/engines/access/debugger.h
@@ -37,6 +37,7 @@ protected:
 	AccessEngine *_vm;
 
 	bool Cmd_LoadScene(int argc, const char **argv);
+	bool Cmd_Cheat(int argc, const char **argv);
 	Common::String *_sceneDescr;
 	int _sceneNumb;
 public:


Commit: 07456932d4be48fcf27a991d9d764a111abc5524
    https://github.com/scummvm/scummvm/commit/07456932d4be48fcf27a991d9d764a111abc5524
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-12T23:02:56-05:00

Commit Message:
ACCESS: Add a debug channel for the sound & music handling

Changed paths:
    engines/access/access.cpp
    engines/access/access.h
    engines/access/sound.cpp



diff --git a/engines/access/access.cpp b/engines/access/access.cpp
index 428c4c6..b63bb29 100644
--- a/engines/access/access.cpp
+++ b/engines/access/access.cpp
@@ -120,6 +120,7 @@ void AccessEngine::initialize() {
 	DebugMan.addDebugChannel(kDebugPath, "Path", "Pathfinding debug level");
 	DebugMan.addDebugChannel(kDebugScripts, "scripts", "Game scripts");
 	DebugMan.addDebugChannel(kDebugGraphics, "graphics", "Graphics handling");
+	DebugMan.addDebugChannel(kDebugSound, "sound", "Sound and Music handling");
 
 	if (isCD()) {
 		const Common::FSNode gameDataDir(ConfMan.get("path"));
diff --git a/engines/access/access.h b/engines/access/access.h
index 2fdf263..284ac26 100644
--- a/engines/access/access.h
+++ b/engines/access/access.h
@@ -71,7 +71,8 @@ enum {
 enum AccessDebugChannels {
 	kDebugPath      = 1 << 0,
 	kDebugScripts	= 1 << 1,
-	kDebugGraphics	= 1 << 2
+	kDebugGraphics	= 1 << 2,
+	kDebugSound     = 1 << 3
 };
 
 struct AccessGameDescription;
diff --git a/engines/access/sound.cpp b/engines/access/sound.cpp
index 95576d2..b5800ba 100644
--- a/engines/access/sound.cpp
+++ b/engines/access/sound.cpp
@@ -30,8 +30,7 @@
 
 namespace Access {
 
-SoundManager::SoundManager(AccessEngine *vm, Audio::Mixer *mixer) :
-		_vm(vm), _mixer(mixer) {
+SoundManager::SoundManager(AccessEngine *vm, Audio::Mixer *mixer) : _vm(vm), _mixer(mixer) {
 	_playingSound = false;
 	_isVoice = false;
 }
@@ -41,12 +40,16 @@ SoundManager::~SoundManager() {
 }
 
 void SoundManager::clearSounds() {
+	debugC(1, kDebugSound, "clearSounds()");
+
 	for (uint i = 0; i < _soundTable.size(); ++i)
 		delete _soundTable[i]._res;
 	_soundTable.clear();
 }
 
 void SoundManager::queueSound(int idx, int fileNum, int subfile) {
+	debugC(1, kDebugSound, "queueSound(%d, %d, %d)", idx, fileNum, subfile);
+
 	Resource *soundResource;
 
 	if (idx >= (int)_soundTable.size())
@@ -59,15 +62,20 @@ void SoundManager::queueSound(int idx, int fileNum, int subfile) {
 }
 
 Resource *SoundManager::loadSound(int fileNum, int subfile) {
+	debugC(1, kDebugSound, "loadSound(%d, %d)", fileNum, subfile);
 	return _vm->_files->loadFile(fileNum, subfile);
 }
 
 void SoundManager::playSound(int soundIndex) {
+	debugC(1, kDebugSound, "playSound(%d)", soundIndex);
+
 	int priority = _soundTable[soundIndex]._priority;
 	playSound(_soundTable[soundIndex]._res, priority);
 }
 
 void SoundManager::playSound(Resource *res, int priority) {
+	debugC(1, kDebugSound, "playSound");
+
 	byte *resourceData = res->data();
 	Audio::SoundHandle audioHandle;
 	Audio::RewindableAudioStream *audioStream = 0;
@@ -125,6 +133,8 @@ void SoundManager::playSound(Resource *res, int priority) {
 }
 
 void SoundManager::loadSounds(Common::Array<RoomInfo::SoundIdent> &sounds) {
+	debugC(1, kDebugSound, "loadSounds");
+
 	clearSounds();
 
 	for (uint i = 0; i < sounds.size(); ++i) {
@@ -134,10 +144,14 @@ void SoundManager::loadSounds(Common::Array<RoomInfo::SoundIdent> &sounds) {
 }
 
 void SoundManager::stopSound() {
+	debugC(3, kDebugSound, "stopSound");
+
 	_mixer->stopHandle(Audio::SoundHandle());
 }
 
 void SoundManager::freeSounds() {
+	debugC(3, kDebugSound, "freeSounds");
+
 	stopSound();
 	clearSounds();
 }
@@ -177,7 +191,8 @@ void MusicManager::send(uint32 b) {
 }
 
 void MusicManager::midiPlay() {
-	warning("MusicManager::midiPlay");
+	debugC(1, kDebugSound, "midiPlay");
+
 	if (_music->_size < 4) {
 		error("midiPlay() wrong music resource size");
 	}
@@ -208,12 +223,13 @@ void MusicManager::midiPlay() {
 }
 
 bool MusicManager::checkMidiDone() {
-	warning("MusicManager::checkMidiDone");
+	debugC(1, kDebugSound, "checkMidiDone");
 	return (!_isPlaying);
 }
 
 void MusicManager::midiRepeat() {
-	warning("MusicManager::midiRepeat");
+	debugC(1, kDebugSound, "midiRepeat");
+
 	if (!_parser)
 		return;
 
@@ -224,22 +240,26 @@ void MusicManager::midiRepeat() {
 }
 
 void MusicManager::stopSong() {
-	warning("MusicManager::stopSong");
+	debugC(1, kDebugSound, "stopSong");
+
 	stop();
 }
 
 void MusicManager::loadMusic(int fileNum, int subfile) {
-	warning("MusicManager::loadMusic %d %d", fileNum, subfile);
+	debugC(1, kDebugSound, "loadMusic(%d, %d)", fileNum, subfile);
+
 	_music = _vm->_files->loadFile(fileNum, subfile);
 }
 
 void MusicManager::loadMusic(FileIdent file) {
-	warning("MusicManager::loadMusic %d %d", file._fileNum, file._subfile);
+	debugC(1, kDebugSound, "loadMusic(%d, %d)", file._fileNum, file._subfile);
+
 	_music = _vm->_files->loadFile(file);
 }
 
 void MusicManager::newMusic(int musicId, int mode) {
-	warning("MusicManager::newMusic %d %d", musicId, mode);
+	debugC(1, kDebugSound, "newMusic(%d, %d)", musicId, mode);
+
 	if (mode == 1) {
 		stopSong();
 		freeMusic();
@@ -258,11 +278,15 @@ void MusicManager::newMusic(int musicId, int mode) {
 }
 
 void MusicManager::freeMusic() {
+	debugC(3, kDebugSound, "freeMusic");
+
 	delete _music;
 	_music = nullptr;
 }
 
 void MusicManager::setLoop(bool loop) {
+	debugC(3, kDebugSound, "setLoop");
+
 	_isLooping = loop;
 	if (_parser)
 		_parser->property(MidiParser::mpAutoLoop, _isLooping);


Commit: 8e90ef2ec7fd1b3bf7d020988fff1629605b0481
    https://github.com/scummvm/scummvm/commit/8e90ef2ec7fd1b3bf7d020988fff1629605b0481
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-12T23:03:06-05:00

Commit Message:
ACCESS: Minor river code clean up and saving fix

Changed paths:
    engines/access/amazon/amazon_game.h
    engines/access/amazon/amazon_logic.cpp
    engines/access/amazon/amazon_logic.h



diff --git a/engines/access/amazon/amazon_game.h b/engines/access/amazon/amazon_game.h
index 43fce80..63ee978 100644
--- a/engines/access/amazon/amazon_game.h
+++ b/engines/access/amazon/amazon_game.h
@@ -107,7 +107,6 @@ public:
 	int _updateChapter;
 	int _oldTitleChapter;
 	int _maxHits;
-	int _oldScrollCol;
 	int _iqValue;
 public:
 	AmazonEngine(OSystem *syst, const AccessGameDescription *gameDesc);
diff --git a/engines/access/amazon/amazon_logic.cpp b/engines/access/amazon/amazon_logic.cpp
index c1df535..cb655bb 100644
--- a/engines/access/amazon/amazon_logic.cpp
+++ b/engines/access/amazon/amazon_logic.cpp
@@ -1361,6 +1361,7 @@ River::River(AmazonEngine *vm): PannedScene(vm) {
 	_saveRiver = false;
 	_deathFlag = false;
 	_deathCount = 0;
+	_oldScrollCol = 0;
 }
 
 void River::setRiverPan() {
@@ -1472,7 +1473,7 @@ void River::initRiver() {
 
 void River::resetPositions() {
 	riverSetPhysX();
-	int val = (_vm->_screen->_scrollCol + 1 - _vm->_oldScrollCol) * 16;
+	int val = (_vm->_screen->_scrollCol + 1 - _oldScrollCol) * 16;
 	if (val > 256) {
 		val &= 0x7F;
 		val |= 0x80;
@@ -1483,7 +1484,7 @@ void River::resetPositions() {
 }
 
 void River::checkRiverPan() {
-	int val = (_vm->_screen->_scrollCol + 20) * 16;
+	int val = _vm->_screen->_scrollCol * 16 + 320;
 
 	for (int i = 0; i < _pNumObj; i++) {
 		if (_pan[i]._pObjX < val)
@@ -1499,7 +1500,7 @@ bool River::riverJumpTest() {
 		++_mapPtr;
 		if (val == 0xFF)
 			return true;
-		_vm->_oldScrollCol = _vm->_screen->_scrollCol;
+		_oldScrollCol = _vm->_screen->_scrollCol;
 
 		if (val == 0) {
 			_vm->_screen->_scrollCol = 139;
@@ -1524,7 +1525,7 @@ bool River::riverJumpTest() {
 				_deathCount = 300;
 				_deathType = val2;
 			}
-			_vm->_oldScrollCol = _vm->_screen->_scrollCol;
+			_oldScrollCol = _vm->_screen->_scrollCol;
 			_vm->_screen->_scrollCol = 44;
 			_vm->_screen->_scrollX = 14;
 			_vm->_room->buildScreen();
@@ -1579,11 +1580,6 @@ void River::moveCanoe() {
 			} else {
 				// Clicked on the Disc icon
 				_saveRiver = true;
-				_rScrollRow = screen._scrollRow;
-				_rScrollCol = screen._scrollCol;
-				_rScrollX = screen._scrollX;
-				_rScrollY = screen._scrollY;
-				_mapOffset = _mapPtr - MAPTBL[_vm->_riverFlag];
 
 				// Show the ScummVM menu
 				_vm->_room->handleCommand(9);
@@ -1635,6 +1631,8 @@ void River::updateObstacles() {
 			break;
 
 		if (cur->_riverX < (_screenVertX + 319)) {
+			// Object is now on-screen. So set _topList/_botList to the range
+			// of river obstacles that are currently visible
 			_topList = cur;
 			_botList = cur;
 
@@ -1657,11 +1655,10 @@ void River::updateObstacles() {
 }
 
 void River::riverSetPhysX() {
-	int val = (_vm->_screen->_scrollCol * 16) + _vm->_screen->_scrollX;
-	RiverStruct *cur = _topList;
-	while (cur <= _botList) {
-		cur[0]._xp = val - (_screenVertX - cur[0]._riverX);
-		++cur;
+	int xAmt = (_vm->_screen->_scrollCol * 16) + _vm->_screen->_scrollX;
+	
+	for (RiverStruct *cur = _topList; cur <= _botList; ++cur) {
+		cur->_xp = xAmt - (_screenVertX - cur->_riverX);
 	}
 }
 
@@ -1688,14 +1685,15 @@ bool River::checkRiverCollide() {
 }
 
 void River::plotRiver() {
+	// Handle cycling through the canoe rowing frames
 	if (_vm->_timers[3]._flag == 0) {
 		++_vm->_timers[3]._flag;
-		if (_canoeFrame == 12)
+
+		if (_canoeFrame++ == 12)
 			_canoeFrame = 0;
-		else
-			++_canoeFrame;
 	}
 
+	// Draw the canoe
 	ImageEntry ie;
 	ie._flags = IMGFLAG_UNSCALED;
 	ie._spritesPtr = _vm->_objectsTable[45];
@@ -1705,19 +1703,17 @@ void River::plotRiver() {
 	ie._offsetY = 41;
 	_vm->_images.addToList(ie);
 
-	RiverStruct *cur = _topList;
-	while (cur <= _botList) {
+	// Draw any on-screen obstacles
+	for (RiverStruct *cur = _topList; cur <= _botList; ++cur) {
 		if (cur->_id != -1) {
 			ie._flags = IMGFLAG_UNSCALED;
 			ie._spritesPtr = _vm->_objectsTable[45];
 			ie._frameNumber = cur->_id;
 			ie._position.x = cur->_xp;
-			int val = (cur[0]._lane * 5) + 56;
-			ie._position.y = val - cur->_offsetY;
+			ie._position.y = (cur->_lane * 5) + 56 - cur->_offsetY;
 			ie._offsetY = cur->_offsetY;
 			_vm->_images.addToList(ie);
 		}
-		++cur;
 	}
 }
 
@@ -1890,8 +1886,19 @@ void River::river() {
 		}
 	}
 }
+
 void River::synchronize(Common::Serializer &s) {
 	if (_vm->_player->_roomNumber == 45) {
+		if (s.isSaving()) {
+			// Set river properties to be saved out
+			Screen &screen = *_vm->_screen;
+			_rScrollRow = screen._scrollRow;
+			_rScrollCol = screen._scrollCol;
+			_rScrollX = screen._scrollX;
+			_rScrollY = screen._scrollY;
+			_mapOffset = _mapPtr - MAPTBL[_vm->_riverFlag];
+		}
+
 		s.syncAsSint16LE(_canoeLane);
 		s.syncAsSint16LE(_canoeYPos);
 		s.syncAsSint16LE(_hitCount);
diff --git a/engines/access/amazon/amazon_logic.h b/engines/access/amazon/amazon_logic.h
index 1cc65cb..d2fb333 100644
--- a/engines/access/amazon/amazon_logic.h
+++ b/engines/access/amazon/amazon_logic.h
@@ -183,6 +183,7 @@ private:
 	int _rScrollY;
 	int _mapOffset;
 	int _screenVertX;
+	int _oldScrollCol;
 
 	void initRiver();
 	void resetPositions();


Commit: 86bee5b48ecbadf9c8f1b4ae2f48c8bcbdf3fce9
    https://github.com/scummvm/scummvm/commit/86bee5b48ecbadf9c8f1b4ae2f48c8bcbdf3fce9
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-12T23:03:16-05:00

Commit Message:
ACCESS: Fix function key mapping for game icons

Changed paths:
    engines/access/room.cpp



diff --git a/engines/access/room.cpp b/engines/access/room.cpp
index b3c3317..a781dab 100644
--- a/engines/access/room.cpp
+++ b/engines/access/room.cpp
@@ -468,8 +468,8 @@ void Room::doCommands() {
 			mainAreaClick();
 		}
 	} else if (_vm->_events->getKey(keyState)) {
-		if (keyState.ascii >= ';' && keyState.ascii <= 'D') {
-			handleCommand((int)keyState.ascii - ';');
+		if (keyState.keycode >= Common::KEYCODE_F1 && keyState.keycode <= Common::KEYCODE_F9) {
+			handleCommand(keyState.keycode - Common::KEYCODE_F1 + 1);
 		}
 	}
 }


Commit: 7508e7b5f8c491556b65ff48d54f289cec9532b1
    https://github.com/scummvm/scummvm/commit/7508e7b5f8c491556b65ff48d54f289cec9532b1
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-12T23:03:27-05:00

Commit Message:
ACCESS: Minor River cleanup

Changed paths:
    engines/access/amazon/amazon_game.h
    engines/access/amazon/amazon_logic.cpp
    engines/access/amazon/amazon_logic.h



diff --git a/engines/access/amazon/amazon_game.h b/engines/access/amazon/amazon_game.h
index 63ee978..30b9b80 100644
--- a/engines/access/amazon/amazon_game.h
+++ b/engines/access/amazon/amazon_game.h
@@ -106,7 +106,6 @@ public:
 	int _hintLevel;
 	int _updateChapter;
 	int _oldTitleChapter;
-	int _maxHits;
 	int _iqValue;
 public:
 	AmazonEngine(OSystem *syst, const AccessGameDescription *gameDesc);
diff --git a/engines/access/amazon/amazon_logic.cpp b/engines/access/amazon/amazon_logic.cpp
index cb655bb..89ea815 100644
--- a/engines/access/amazon/amazon_logic.cpp
+++ b/engines/access/amazon/amazon_logic.cpp
@@ -1362,6 +1362,7 @@ River::River(AmazonEngine *vm): PannedScene(vm) {
 	_deathFlag = false;
 	_deathCount = 0;
 	_oldScrollCol = 0;
+	_maxHits = 0;
 }
 
 void River::setRiverPan() {
@@ -1467,7 +1468,7 @@ void River::initRiver() {
 	_vm->_timers[12]._initTm = 1500;
 	++_vm->_timers[12]._flag;
 
-	_vm->_maxHits = 2 - _vm->_riverFlag;
+	_maxHits = 2 - _vm->_riverFlag;
 	_saveRiver = false;
 }
 
@@ -1558,7 +1559,6 @@ void River::riverSound() {
 }
 
 void River::moveCanoe() {
-	Screen &screen = *_vm->_screen;
 	EventsManager &events = *_vm->_events;
 	Common::Point pt = events.calcRawMouse();
 
diff --git a/engines/access/amazon/amazon_logic.h b/engines/access/amazon/amazon_logic.h
index d2fb333..2799e4f 100644
--- a/engines/access/amazon/amazon_logic.h
+++ b/engines/access/amazon/amazon_logic.h
@@ -170,6 +170,7 @@ private:
 	bool _deathFlag;
 	int _deathCount;
 	int _deathType;
+	int _maxHits;
 
 	// Saved fields
 	int _canoeLane;


Commit: 960a787c033fa7a90d347b9d37c4c0e890444ce2
    https://github.com/scummvm/scummvm/commit/960a787c033fa7a90d347b9d37c4c0e890444ce2
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-12T23:03:38-05:00

Commit Message:
ACCESS: Reduce the scope of a variable in Inventory

Changed paths:
    engines/access/inventory.cpp



diff --git a/engines/access/inventory.cpp b/engines/access/inventory.cpp
index 78a85c3..4038929 100644
--- a/engines/access/inventory.cpp
+++ b/engines/access/inventory.cpp
@@ -318,13 +318,13 @@ void InventoryManager::putInvIcon(int itemIndex, int itemId) {
 void InventoryManager::chooseItem() {
 	EventsManager &events = *_vm->_events;
 	_vm->_useItem = -1;
-	int selIndex;
 
 	while (!_vm->shouldQuit()) {
 		// Check for events
 		events.pollEvents();
 		g_system->delayMillis(10);
 
+		int selIndex;
 		// Poll events and wait for a click on a known area
 		if (!events._leftButton || ((selIndex = coordIndexOf()) == -1))
 			continue;


Commit: 9ef60f3f3357491e39dfe3c16470fa3711e8a211
    https://github.com/scummvm/scummvm/commit/9ef60f3f3357491e39dfe3c16470fa3711e8a211
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-12T23:03:48-05:00

Commit Message:
ACCESS: Fix a bug in plotInactive

Changed paths:
    engines/access/amazon/amazon_scripts.cpp



diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp
index fb1ccbe..c5b7795 100644
--- a/engines/access/amazon/amazon_scripts.cpp
+++ b/engines/access/amazon/amazon_scripts.cpp
@@ -300,8 +300,8 @@ void AmazonScripts::plotInactive() {
 			_game->_rawInactiveY >= 158 && _game->_rawInactiveY <= 173) {
 		_game->_flags[155] = 1;
 	} else {
-		_game->_flags[160] = 1;
-		if (!_game->_jasMayaFlag && _game->_rawInactiveX <= 266 && _game->_rawInactiveX < 290
+		_game->_flags[160] = 0;
+		if (!_game->_jasMayaFlag && _game->_rawInactiveX >= 266 && _game->_rawInactiveX <= 290
 			&& _game->_rawInactiveY >= 70 && _game->_rawInactiveY <= 87) {
 			_game->_flags[160] = 1;
 		}


Commit: 35922c28c8579c9f2fe476a351da74a92b7660d5
    https://github.com/scummvm/scummvm/commit/35922c28c8579c9f2fe476a351da74a92b7660d5
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-12T23:03:59-05:00

Commit Message:
ACCESS: Add a hack to fake queueing

Changed paths:
    engines/access/amazon/amazon_logic.cpp
    engines/access/sound.cpp



diff --git a/engines/access/amazon/amazon_logic.cpp b/engines/access/amazon/amazon_logic.cpp
index 89ea815..f1bf7dc 100644
--- a/engines/access/amazon/amazon_logic.cpp
+++ b/engines/access/amazon/amazon_logic.cpp
@@ -354,9 +354,9 @@ void Opening::doTitle() {
 			_vm->_buffer2.plotImage(_vm->_objectsTable[0], id, Common::Point(xp, 71));
 			_vm->_screen->copyFrom(_vm->_buffer2);
 
+			_vm->_sound->playSound(1);
 			_vm->_events->_vbCount = 70;
 			while (!_vm->shouldQuit() && _vm->_events->_vbCount > 0 && !_skipStart) {
-				_vm->_sound->playSound(1);
 				_vm->_events->pollEventsAndWait();
 				if (_vm->_events->_rightButton)
 					_skipStart = true;
diff --git a/engines/access/sound.cpp b/engines/access/sound.cpp
index b5800ba..4e70161 100644
--- a/engines/access/sound.cpp
+++ b/engines/access/sound.cpp
@@ -82,6 +82,10 @@ void SoundManager::playSound(Resource *res, int priority) {
 
 	assert(res->_size >= 32);
 
+	// HACK: Simulates queueing for the rare sounds played one after the other
+	while (_mixer->hasActiveChannelOfType(Audio::Mixer::kSFXSoundType))
+		;
+
 	if (READ_BE_UINT32(resourceData) == MKTAG('R','I','F','F')) {
 		// CD version uses WAVE-files
 		Common::SeekableReadStream *waveStream = new Common::MemoryReadStream(resourceData, res->_size, DisposeAfterUse::NO);


Commit: b20c755f46b34906305c773d1e4e320d0d8affbe
    https://github.com/scummvm/scummvm/commit/b20c755f46b34906305c773d1e4e320d0d8affbe
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-12T23:04:09-05:00

Commit Message:
ACCESS: Fix progressing within the river

Changed paths:
    engines/access/amazon/amazon_logic.cpp



diff --git a/engines/access/amazon/amazon_logic.cpp b/engines/access/amazon/amazon_logic.cpp
index f1bf7dc..952809f 100644
--- a/engines/access/amazon/amazon_logic.cpp
+++ b/engines/access/amazon/amazon_logic.cpp
@@ -1497,10 +1497,10 @@ void River::checkRiverPan() {
 
 bool River::riverJumpTest() {
 	if (_vm->_screen->_scrollCol == 120 || _vm->_screen->_scrollCol == 60 || _vm->_screen->_scrollCol == 0) {
-		int val = _mapPtr[0];
-		++_mapPtr;
+		int val = *++_mapPtr;
 		if (val == 0xFF)
 			return true;
+
 		_oldScrollCol = _vm->_screen->_scrollCol;
 
 		if (val == 0) {


Commit: c69480f6bf6f7afd6f0cffb0a6a76e22ad8e08cf
    https://github.com/scummvm/scummvm/commit/c69480f6bf6f7afd6f0cffb0a6a76e22ad8e08cf
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-12T23:04:24-05:00

Commit Message:
ACCESS: Fix event pollig in death flashing loop

Changed paths:
    engines/access/amazon/amazon_game.cpp
    engines/access/amazon/amazon_logic.cpp



diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp
index b425fe9..9880b65 100644
--- a/engines/access/amazon/amazon_game.cpp
+++ b/engines/access/amazon/amazon_game.cpp
@@ -640,6 +640,7 @@ void AmazonEngine::dead(int deathId) {
 				_sound->playSound(0);
 				_screen->forceFadeOut();
 
+				_events->pollEvents();
 				if (shouldQuit())
 					return;
 			}
diff --git a/engines/access/amazon/amazon_logic.cpp b/engines/access/amazon/amazon_logic.cpp
index 952809f..0145007 100644
--- a/engines/access/amazon/amazon_logic.cpp
+++ b/engines/access/amazon/amazon_logic.cpp
@@ -1475,8 +1475,7 @@ void River::initRiver() {
 void River::resetPositions() {
 	riverSetPhysX();
 	int val = (_vm->_screen->_scrollCol + 1 - _oldScrollCol) * 16;
-	if (val > 256) {
-		val &= 0x7F;
+	if (val < 0) {
 		val |= 0x80;
 	}
 


Commit: 8ee8444779b11528391fb969f186fd8a74f437a6
    https://github.com/scummvm/scummvm/commit/8ee8444779b11528391fb969f186fd8a74f437a6
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-12T23:04:34-05:00

Commit Message:
ACCESS: Skip chapter speech for the non-CD versions

Changed paths:
    engines/access/amazon/amazon_game.cpp



diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp
index 9880b65..98eba1f 100644
--- a/engines/access/amazon/amazon_game.cpp
+++ b/engines/access/amazon/amazon_game.cpp
@@ -481,13 +481,14 @@ void AmazonEngine::startChapter(int chapter) {
 		_timers[20]._flag++;
 		_sound->freeSounds();
 
-		_sound->_soundTable.push_back(SoundEntry(_sound->loadSound(115, 0), 1));
-		_sound->playSound(0);
-		_sound->freeSounds();
+		if (isCD()) {
+			_sound->_soundTable.push_back(SoundEntry(_sound->loadSound(115, 0), 1));
+			_sound->_soundTable.push_back(SoundEntry(_sound->loadSound(115, 1), 1));
+			_sound->playSound(0);
+			_sound->playSound(1);
 
-		_sound->_soundTable.push_back(SoundEntry(_sound->loadSound(115, 1), 1));
-		_sound->playSound(0);
-		_sound->freeSounds();
+			_sound->freeSounds();
+		}
 
 		// Wait loop
 		while (!shouldQuit() && !_events->isKeyMousePressed() && _timers[20]._flag) {


Commit: 8d97dc9891a3a4a217c72915b8a319f66f84d250
    https://github.com/scummvm/scummvm/commit/8d97dc9891a3a4a217c72915b8a319f66f84d250
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-12T23:04:44-05:00

Commit Message:
ACCESS: stops the SFX sounds in the intro at the end of the countdown

Changed paths:
    engines/access/amazon/amazon_logic.cpp
    engines/access/sound.h



diff --git a/engines/access/amazon/amazon_logic.cpp b/engines/access/amazon/amazon_logic.cpp
index 0145007..80c98a8 100644
--- a/engines/access/amazon/amazon_logic.cpp
+++ b/engines/access/amazon/amazon_logic.cpp
@@ -365,6 +365,7 @@ void Opening::doTitle() {
 		if (_vm->shouldQuit())
 			return;
 
+		_vm->_sound->stopSound();
 		_vm->_sound->playSound(0);
 		_vm->_screen->forceFadeOut();
 		_vm->_events->_vbCount = 100;
diff --git a/engines/access/sound.h b/engines/access/sound.h
index 5089bd0..dc8bd90 100644
--- a/engines/access/sound.h
+++ b/engines/access/sound.h
@@ -52,8 +52,6 @@ private:
 	void clearSounds();
 
 	void playSound(Resource *res, int priority);
-	void stopSound();
-
 public:
 	Common::Array<SoundEntry> _soundTable;
 	bool _playingSound;
@@ -69,6 +67,7 @@ public:
 	Resource *loadSound(int fileNum, int subfile);
 	void loadSounds(Common::Array<RoomInfo::SoundIdent> &sounds);
 
+	void stopSound();
 	void freeSounds();
 };
 


Commit: 98685b935822f3f934d3b69aa079e3e70b71f2e2
    https://github.com/scummvm/scummvm/commit/98685b935822f3f934d3b69aa079e3e70b71f2e2
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-12T23:04:54-05:00

Commit Message:
ACCESS: Add some more checks for the floppy version

Changed paths:
    engines/access/amazon/amazon_game.cpp



diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp
index 98eba1f..77ee8fe 100644
--- a/engines/access/amazon/amazon_game.cpp
+++ b/engines/access/amazon/amazon_game.cpp
@@ -232,7 +232,7 @@ void AmazonEngine::doEstablish(int screenId, int estabIndex) {
 	_printEnd = 155;
 	Common::String msg((const char *)_establish->data() + msgOffset);
 
-	if (_txtPages == 0) {
+	if ((_txtPages == 0) || !isCD()) {
 		printText(_screen, msg);
 	} else {
 		speakText(_screen, msg);
@@ -569,7 +569,7 @@ void AmazonEngine::startChapter(int chapter) {
 
 	Common::String msg((const char *)_establish->data() + msgOffset);
 
-	if (_txtPages == 0) {
+	if ((_txtPages == 0) || !isCD()) {
 		printText(_screen, msg);
 	} else {
 		speakText(_screen, msg);


Commit: 1870e31e25bd2b502fca538fd6c84e97c839b5a5
    https://github.com/scummvm/scummvm/commit/1870e31e25bd2b502fca538fd6c84e97c839b5a5
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-12T23:05:05-05:00

Commit Message:
ACCESS: Add a comment related to the CD specific files

Changed paths:
    engines/access/amazon/amazon_resources.cpp



diff --git a/engines/access/amazon/amazon_resources.cpp b/engines/access/amazon/amazon_resources.cpp
index ed4a012..cb84841 100644
--- a/engines/access/amazon/amazon_resources.cpp
+++ b/engines/access/amazon/amazon_resources.cpp
@@ -45,6 +45,7 @@ const char *const FILENAMES[] = {
 	"C24.AP", "C25.AP", "C29.AP", "C30.AP", "C32.AP", "C33.AP",
 	"C34.AP", "CREDITS.AP", "MIDIDRV.AP", "SUMMARY.AP", "DEAD.AP",
 	"EST.AP", "CHAPTER.AP", "MIDI.AP", "SOUND.AP", "INV.AP",
+	// The following files are only present in the CD version
 	"NARATE01.AP", "NARATE02.AP", "NARATE03.AP", "NARATE04.AP",
 	"NARATE05.AP", "NARATE06.AP", "NARATE07.AP", "NARATE08.AP",
 	"NARATE09.AP", "NARATE10.AP", "NARATE11.AP", "NARATE12.AP",


Commit: beba0b40d5730844d6c8ffc813f19cf5d743f2af
    https://github.com/scummvm/scummvm/commit/beba0b40d5730844d6c8ffc813f19cf5d743f2af
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-12T23:05:25-05:00

Commit Message:
ACCESS: Minor cleanup of _saveRiver flag

Changed paths:
    engines/access/amazon/amazon_logic.cpp



diff --git a/engines/access/amazon/amazon_logic.cpp b/engines/access/amazon/amazon_logic.cpp
index 80c98a8..23a8a43 100644
--- a/engines/access/amazon/amazon_logic.cpp
+++ b/engines/access/amazon/amazon_logic.cpp
@@ -1578,14 +1578,10 @@ void River::moveCanoe() {
 				// Disk icon wasn't clicked
 				_vm->_scripts->printString(BAR_MESSAGE);
 			} else {
-				// Clicked on the Disc icon
-				_saveRiver = true;
-
-				// Show the ScummVM menu
+				// Clicked on the Disc icon. Show the ScummVM menu
 				_vm->_room->handleCommand(9);
 
 				if (_vm->_room->_function != FN_CLEAR1) {
-					_saveRiver = false;
 					_vm->_room->buildScreen();
 					_vm->copyBF2Vid();
 				}


Commit: cdc27778c0c07d728876ebe169d658dda666ef1f
    https://github.com/scummvm/scummvm/commit/cdc27778c0c07d728876ebe169d658dda666ef1f
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-12T23:05:36-05:00

Commit Message:
ACCESS: Add a button to allow skipping the river scene

Changed paths:
    engines/access/amazon/amazon_logic.cpp
    engines/access/amazon/amazon_logic.h
    engines/access/amazon/amazon_scripts.cpp



diff --git a/engines/access/amazon/amazon_logic.cpp b/engines/access/amazon/amazon_logic.cpp
index 23a8a43..eb889d2 100644
--- a/engines/access/amazon/amazon_logic.cpp
+++ b/engines/access/amazon/amazon_logic.cpp
@@ -1471,6 +1471,12 @@ void River::initRiver() {
 
 	_maxHits = 2 - _vm->_riverFlag;
 	_saveRiver = false;
+
+	Font &font2 = _vm->_fonts._font2;
+	font2._fontColors[0] = 0;
+	font2._fontColors[1] = 33;
+	font2._fontColors[2] = 34;
+	font2._fontColors[3] = 35;
 }
 
 void River::resetPositions() {
@@ -1561,6 +1567,7 @@ void River::riverSound() {
 void River::moveCanoe() {
 	EventsManager &events = *_vm->_events;
 	Common::Point pt = events.calcRawMouse();
+	Common::Point mousePos = events.getMousePos();
 
 	// Do an event polling
 	_vm->_canSaveLoad = true;
@@ -1586,8 +1593,10 @@ void River::moveCanoe() {
 					_vm->copyBF2Vid();
 				}
 			}
-		}
-		else if ((events._leftButton && pt.y <= _canoeYPos) ||
+		} else if (events._leftButton && mousePos.x < 35 && mousePos.y < 12) {
+			// Clicked on the Skip button. So chicken out
+			_CHICKENOUTFLG = true;
+		}  else if ((events._leftButton && pt.y <= _canoeYPos) ||
 			(!events._leftButton && _vm->_player->_move == UP)) {
 			// Move canoe up
 			if (_canoeLane > 0) {
@@ -1596,8 +1605,7 @@ void River::moveCanoe() {
 
 				moveCanoe2();
 			}
-		}
-		else if (events._leftButton || _vm->_player->_move == DOWN) {
+		} else if (events._leftButton || _vm->_player->_move == DOWN) {
 			// Move canoe down
 			if (_canoeLane < 7) {
 				_canoeDir = 1;
@@ -1711,6 +1719,10 @@ void River::plotRiver() {
 			_vm->_images.addToList(ie);
 		}
 	}
+
+	// Draw the text for skipping the river
+	Font &font2 = _vm->_fonts._font2;
+	font2.drawString(_vm->_screen, "SKIP", Common::Point(5, 5));
 }
 
 void River::mWhileDownRiver() {
@@ -1809,7 +1821,7 @@ void River::scrollRiver1() {
 	_vm->copyBF2Vid();
 }
 
-void River::river() {
+void River::doRiver() {
 	static const int RIVERDEATH[5] = { 22, 23, 24, 25, 26 };
 
 	initRiver();
diff --git a/engines/access/amazon/amazon_logic.h b/engines/access/amazon/amazon_logic.h
index 2799e4f..2962d77 100644
--- a/engines/access/amazon/amazon_logic.h
+++ b/engines/access/amazon/amazon_logic.h
@@ -203,7 +203,7 @@ private:
 public:
 	River(AmazonEngine *vm);
 
-	void river();
+	void doRiver();
 	void mWhileDownRiver();
 
 	void synchronize(Common::Serializer &s);
diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp
index c5b7795..76513db 100644
--- a/engines/access/amazon/amazon_scripts.cpp
+++ b/engines/access/amazon/amazon_scripts.cpp
@@ -362,7 +362,7 @@ void AmazonScripts::executeSpecial(int commandIndex, int param1, int param2) {
 		plotInactive();
 		break;
 	case 13:
-		_game->_river.river();
+		_game->_river.doRiver();
 		break;
 	case 14:
 		_game->_ant.doAnt();


Commit: 80dfc3537d8495bb1f096c1bd21ab4052ac0cb40
    https://github.com/scummvm/scummvm/commit/80dfc3537d8495bb1f096c1bd21ab4052ac0cb40
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-12T23:05:46-05:00

Commit Message:
ACCESS: Fix _help3 initialization

Changed paths:
    engines/access/amazon/amazon_game.cpp
    engines/access/amazon/amazon_game.h



diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp
index 77ee8fe..20d7102 100644
--- a/engines/access/amazon/amazon_game.cpp
+++ b/engines/access/amazon/amazon_game.cpp
@@ -47,14 +47,13 @@ AccessEngine(syst, gameDesc),
 	_rawInactiveX = 0;
 	_rawInactiveY = 0;
 	_inactiveYOff = 0;
-	_tilePos = Common::Point(0, 0);
 	_hintLevel = 0;
 
 	Common::fill(&_esTabTable[0], &_esTabTable[100], 0);
 	memset(_tileData, 0, sizeof(_tileData));
 	Common::fill(&_help1[0], &_help1[366], 0);
 	Common::fill(&_help2[0], &_help2[366], 0);
-	Common::fill(&_help1[0], &_help3[366], 0);
+	Common::fill(&_help3[0], &_help3[366], 0);
 	_helpTbl[0] = _help1;
 	_helpTbl[1] = _help2;
 	_helpTbl[2] = _help3;
@@ -276,8 +275,9 @@ void AmazonEngine::tileScreen() {
 		_tileData[i] = res->_stream->readByte();
 
 	// CHECKME: Depending on the Vesa mode during initialization, 400 or 480
-	for (_tilePos.y = 0; _tilePos.y < 480; _tilePos.y += y) {
-		for (_tilePos.x = 0; _tilePos.x < 640; _tilePos.x += x)
+	Common::Point tilePos;
+	for (tilePos.y = 0; tilePos.y < 480; tilePos.y += y) {
+		for (tilePos.x = 0; tilePos.x < 640; tilePos.x += x)
 			warning("TODO: DRAWOBJECT");
 	}
 
diff --git a/engines/access/amazon/amazon_game.h b/engines/access/amazon/amazon_game.h
index 30b9b80..e475542 100644
--- a/engines/access/amazon/amazon_game.h
+++ b/engines/access/amazon/amazon_game.h
@@ -34,7 +34,6 @@ class AmazonEngine;
 
 class AmazonEngine : public AccessEngine {
 private:
-	Common::Point _tilePos;
 	byte _tileData[1455];
 	Common::Array<CellIdent> _chapterCells;
 


Commit: 538782e14e085fa4cc8e435439f0432b3b1f0b21
    https://github.com/scummvm/scummvm/commit/538782e14e085fa4cc8e435439f0432b3b1f0b21
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-12T23:05:57-05:00

Commit Message:
ACCESS: Get rid of the use of 'this' in constructor

Changed paths:
    engines/access/amazon/amazon_game.cpp
    engines/access/amazon/amazon_game.h
    engines/access/amazon/amazon_player.cpp
    engines/access/amazon/amazon_scripts.cpp



diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp
index 20d7102..cfcafbb 100644
--- a/engines/access/amazon/amazon_game.cpp
+++ b/engines/access/amazon/amazon_game.cpp
@@ -36,9 +36,15 @@ AccessEngine(syst, gameDesc),
 		_jasMayaFlag(_flags[168]), _moreHelp(_flags[169]), _flashbackFlag(_flags[171]),
 		_riverFlag(_flags[185]), _aniOutFlag(_flags[195]), _badEnd(_flags[218]),
 		_noHints(_flags[219]), _aniFlag(_flags[229]), _allenFlag(_flags[237]),
-		_noSound(_flags[239]),
-		_ant(this), _cast(this), _guard(this), _jungle(this), _opening(this),
-		_plane(this), _river(this) {
+		_noSound(_flags[239]) {
+
+	_ant = nullptr;
+	_cast = nullptr;
+	_guard = nullptr;
+	_jungle = nullptr;
+	_opening = nullptr;
+	_plane = nullptr;
+	_river = nullptr;
 
 	_charSegSwitch = false;
 
@@ -67,6 +73,14 @@ AccessEngine(syst, gameDesc),
 
 AmazonEngine::~AmazonEngine() {
 	delete _inactive._altSpritesPtr;
+
+	delete _ant;
+	delete _cast;
+	delete _guard;
+	delete _jungle;
+	delete _opening;
+	delete _plane;
+	delete _river;
 }
 
 void AmazonEngine::freeInactivePlayer() {
@@ -79,18 +93,30 @@ void AmazonEngine::configSelect() {
 	_hintLevel = 3;
 }
 
-void AmazonEngine::playGame() {
-	// Initialize Amazon game-specific objects
+void AmazonEngine::initObjects() {
 	_room = new AmazonRoom(this);
 	_scripts = new AmazonScripts(this);
 
+	_ant = new Ant(this);
+	_cast = new Cast(this);
+	_guard = new Guard(this);
+	_jungle = new Jungle(this);
+	_opening = new Opening(this);
+	_plane = new Plane(this);
+	_river = new River(this);
+}
+
+void AmazonEngine::playGame() {
+	// Initialize Amazon game-specific objects
+	initObjects();
+
 	// Setup the game
 	setupGame();
 	configSelect();
 
 	if (_loadSaveSlot == -1) {
 		// Do introduction
-		_opening.doIntroduction();
+		_opening->doIntroduction();
 		if (shouldQuit())
 			return;
 	}
@@ -735,7 +761,7 @@ void AmazonEngine::synchronize(Common::Serializer &s) {
 		s.syncAsByte(_help3[i]);
 	}
 
-	_river.synchronize(s);
+	_river->synchronize(s);
 }
 
 } // End of namespace Amazon
diff --git a/engines/access/amazon/amazon_game.h b/engines/access/amazon/amazon_game.h
index e475542..4ebea0f 100644
--- a/engines/access/amazon/amazon_game.h
+++ b/engines/access/amazon/amazon_game.h
@@ -48,6 +48,7 @@ private:
 	void configSelect();
 
 	void initVariables();
+	void initObjects();
 	void calcIQ();
 	void helpTitle();
 	void drawHelpText(const Common::String &msg);
@@ -95,13 +96,13 @@ public:
 	int _esTabTable[100];
 
 	// Other game specific fields
-	Ant _ant;
-	Cast _cast;
-	Guard _guard;
-	Jungle _jungle;
-	Opening _opening;
-	Plane _plane;
-	River _river;
+	Ant *_ant;
+	Cast *_cast;
+	Guard *_guard;
+	Jungle *_jungle;
+	Opening *_opening;
+	Plane *_plane;
+	River *_river;
 	int _hintLevel;
 	int _updateChapter;
 	int _oldTitleChapter;
diff --git a/engines/access/amazon/amazon_player.cpp b/engines/access/amazon/amazon_player.cpp
index c9b63a9..2780922 100644
--- a/engines/access/amazon/amazon_player.cpp
+++ b/engines/access/amazon/amazon_player.cpp
@@ -77,7 +77,7 @@ void AmazonPlayer::load() {
 		_diagUpWalkMax = 5;
 		_diagDownWalkMin = 0;
 		_diagDownWalkMax = 5;
-		_game->_guard.setPosition(Common::Point(56, 190));
+		_game->_guard->setPosition(Common::Point(56, 190));
 	}
 }
 
diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp
index 76513db..52c142a 100644
--- a/engines/access/amazon/amazon_scripts.cpp
+++ b/engines/access/amazon/amazon_scripts.cpp
@@ -211,25 +211,25 @@ void AmazonScripts::mWhile(int param1) {
 		mWhile1();
 		break;
 	case 2:
-		_game->_plane.mWhileFly();
+		_game->_plane->mWhileFly();
 		break;
 	case 3:
-		_game->_plane.mWhileFall();
+		_game->_plane->mWhileFall();
 		break;
 	case 4:
-		_game->_jungle.mWhileJWalk();
+		_game->_jungle->mWhileJWalk();
 		break;
 	case 5:
-		_game->_jungle.mWhileDoOpen();
+		_game->_jungle->mWhileDoOpen();
 		break;
 	case 6:
-		_game->_river.mWhileDownRiver();
+		_game->_river->mWhileDownRiver();
 		break;
 	case 7:
 		mWhile2();
 		break;
 	case 8:
-		_game->_jungle.mWhileJWalk2();
+		_game->_jungle->mWhileJWalk2();
 		break;
 	default:
 		break;
@@ -332,7 +332,7 @@ void AmazonScripts::executeSpecial(int commandIndex, int param1, int param2) {
 		if (_vm->isDemo())
 			warning("TODO: DEMO - LOADCELLSET");
 		else
-			_game->_cast.doCast(param1);
+			_game->_cast->doCast(param1);
 		break;
 	case 4:
 		if (_vm->isDemo())
@@ -353,7 +353,7 @@ void AmazonScripts::executeSpecial(int commandIndex, int param1, int param2) {
 		warning("TODO: DEMO - CHKMONEY");
 		break;
 	case 9:
-		_game->_guard.doGuard();
+		_game->_guard->doGuard();
 		break;
 	case 10:
 		_vm->_midi->newMusic(param1, param2);
@@ -362,10 +362,10 @@ void AmazonScripts::executeSpecial(int commandIndex, int param1, int param2) {
 		plotInactive();
 		break;
 	case 13:
-		_game->_river.doRiver();
+		_game->_river->doRiver();
 		break;
 	case 14:
-		_game->_ant.doAnt();
+		_game->_ant->doAnt();
 		break;
 	case 15:
 		boatWalls(param1, param2);


Commit: 8517209bcbef56a1fa68a6e17b04d56c13fa77b2
    https://github.com/scummvm/scummvm/commit/8517209bcbef56a1fa68a6e17b04d56c13fa77b2
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-12T23:06:08-05:00

Commit Message:
ACCESS: Implement restart after death

Changed paths:
    engines/access/access.cpp
    engines/access/access.h
    engines/access/amazon/amazon_game.cpp
    engines/access/room.cpp
    engines/access/scripts.cpp



diff --git a/engines/access/access.cpp b/engines/access/access.cpp
index b63bb29..4201564 100644
--- a/engines/access/access.cpp
+++ b/engines/access/access.cpp
@@ -89,6 +89,7 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc)
 	_loadSaveSlot = -1;
 	_vidX = _vidY = 0;
 	_cheatFl = false;
+	_restartFl = false;
 }
 
 AccessEngine::~AccessEngine() {
@@ -570,4 +571,7 @@ void AccessEngine::writeSavegameHeader(Common::OutSaveFile *out, AccessSavegameH
 	out->writeUint32LE(_events->getFrameCounter());
 }
 
+bool AccessEngine::shouldQuitOrRestart() {
+	return shouldQuit() || _restartFl;
+}
 } // End of namespace Access
diff --git a/engines/access/access.h b/engines/access/access.h
index 284ac26..5470d2a 100644
--- a/engines/access/access.h
+++ b/engines/access/access.h
@@ -209,6 +209,7 @@ public:
 
 	bool _clearSummaryFlag;
 	bool _cheatFl;
+	bool _restartFl;
 	// Fields mapped into the flags array
 	int &_useItem;
 	int &_startup;
@@ -228,6 +229,7 @@ public:
 	uint16 getVersion() const;
 	uint32 getGameID() const;
 	uint32 getGameFeatures() const;
+	bool shouldQuitOrRestart();
 
 	int getRandomNumber(int maxNumber);
 
diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp
index cfcafbb..29466f1 100644
--- a/engines/access/amazon/amazon_game.cpp
+++ b/engines/access/amazon/amazon_game.cpp
@@ -121,40 +121,36 @@ void AmazonEngine::playGame() {
 			return;
 	}
 
-	_screen->clearScreen();
-	_screen->setPanel(0);
-	_screen->forceFadeOut();
-	_events->showCursor();
-
-	initVariables();
-
-	// If there's a pending savegame to load, load it
-	if (_loadSaveSlot != -1)
-		loadGameState(_loadSaveSlot);
+	do {
+		_restartFl = false;
+		_screen->clearScreen();
+		_screen->setPanel(0);
+		_screen->forceFadeOut();
+		_events->showCursor();
+
+		initVariables();
+
+		// If there's a pending savegame to load, load it
+		if (_loadSaveSlot != -1) {
+			loadGameState(_loadSaveSlot);
+			_loadSaveSlot = -1;
+		}
 
-	// Execute the room
-	_room->doRoom();
+		// Execute the room
+		_room->doRoom();
+	} while (_restartFl);
 }
 
 void AmazonEngine::setupGame() {
-	// Setup timers
-	const int TIMER_DEFAULTS[] = { 3, 10, 8, 1, 1, 1, 1, 2 };
-	for (int i = 0; i < 32; ++i) {
-		TimerEntry te;
-		te._initTm = te._timer = (i < 8) ? TIMER_DEFAULTS[i] : 1;
-		te._flag = 1;
-
-		_timers.push_back(te);
-	}
-
 	// Load death list
-	_deaths.resize(58);
 	if (isDemo()) {
+		_deaths.resize(34);
 		for (int i = 0; i < 34; ++i) {
 			_deaths[i]._screenId = DEATH_SCREENS_DEMO[i];
 			_deaths[i]._msg = DEATH_TEXT_DEMO[i];
 		}
 	} else {
+		_deaths.resize(58);
 		for (int i = 0; i < 58; ++i) {
 			_deaths[i]._screenId = DEATH_SCREENS[i];
 			_deaths[i]._msg = DEATH_TEXT[i];
@@ -178,8 +174,29 @@ void AmazonEngine::initVariables() {
 		_player->_roomNumber = 33;
 	else
 		_player->_roomNumber = 4;
+
+	_converseMode = 0;
+	_inventory->_startInvItem = 0;
+	_inventory->_startInvBox = 0;
+	Common::fill(&_objectsTable[0], &_objectsTable[100], (SpriteResource *)nullptr);
+	_player->_playerOff = false;
+
+	// Setup timers
+	const int TIMER_DEFAULTS[] = { 3, 10, 8, 1, 1, 1, 1, 2 };
+	for (int i = 0; i < 32; ++i) {
+		TimerEntry te;
+		te._initTm = te._timer = (i < 8) ? TIMER_DEFAULTS[i] : 1;
+		te._flag = 1;
+
+		_timers.push_back(te);
+	}
+
 	_player->_playerX = _player->_rawPlayer.x = TRAVEL_POS[_player->_roomNumber][0];
 	_player->_playerY = _player->_rawPlayer.y = TRAVEL_POS[_player->_roomNumber][1];
+	_room->_selectCommand = -1;
+	_events->_normalMouse = CURSOR_CROSSHAIRS;
+	_mouseMode = 0;
+	_numAnimTimers = 0;
 }
 
 void AmazonEngine::establish(int screenId, int esatabIndex) {
@@ -739,8 +756,8 @@ void AmazonEngine::dead(int deathId) {
 			_player->removeSprite1();
 		}
 
-		warning("TODO: restart game");
-		quitGame();
+		// The original was jumping to the restart label in main
+		_restartFl = true;
 		_events->pollEvents();
 	}
 }
diff --git a/engines/access/room.cpp b/engines/access/room.cpp
index a781dab..57332f7 100644
--- a/engines/access/room.cpp
+++ b/engines/access/room.cpp
@@ -90,7 +90,7 @@ void Room::doRoom() {
 			_vm->_player->checkScroll();
 
 			doCommands();
-			if (_vm->shouldQuit())
+			if (_vm->shouldQuitOrRestart())
 				return;
 
 			// DOROOMFLASHBACK jump point
@@ -128,7 +128,7 @@ void Room::doRoom() {
 				_function = FN_NONE;
 
 				roomLoop();
-				if (_vm->shouldQuit())
+				if (_vm->shouldQuitOrRestart())
 					return;
 
 				if (_function == FN_CLEAR1) {
@@ -578,7 +578,7 @@ void Room::walkCursor() {
 	_selectCommand = -1;
 
 	_conFlag = true;
-	while (_conFlag && !_vm->shouldQuit()) {
+	while (_conFlag && !_vm->shouldQuitOrRestart()) {
 		_conFlag = false;
 		_vm->_scripts->executeScript();
 	}
@@ -622,7 +622,7 @@ void Room::checkBoxes3() {
 				_vm->_boxSelect = start;
 
 				_conFlag = true;
-				while (_conFlag && !_vm->shouldQuit()) {
+				while (_conFlag && !_vm->shouldQuitOrRestart()) {
 					_conFlag = false;
 					_vm->_scripts->executeScript();
 				}
diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp
index 728421c..6c9f278 100644
--- a/engines/access/scripts.cpp
+++ b/engines/access/scripts.cpp
@@ -100,7 +100,7 @@ int Scripts::executeScript() {
 
 		assert(_scriptCommand >= 0x80);
 		executeCommand(_scriptCommand - 0x80);
-	} while (!_endFlag && !_vm->shouldQuit());
+	} while (!_endFlag && !_vm->shouldQuitOrRestart());
 
 	return _returnCode;
 }


Commit: b1d5359fc6033c25c3360d30de0fe98ce4fce29e
    https://github.com/scummvm/scummvm/commit/b1d5359fc6033c25c3360d30de0fe98ce4fce29e
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-12T23:06:23-05:00

Commit Message:
ACCESS: Minor formatting for debugger error messages

Changed paths:
    engines/access/debugger.cpp



diff --git a/engines/access/debugger.cpp b/engines/access/debugger.cpp
index 1f81004..5eb615f 100644
--- a/engines/access/debugger.cpp
+++ b/engines/access/debugger.cpp
@@ -96,11 +96,11 @@ bool Debugger::Cmd_LoadScene(int argc, const char **argv) {
 	case 2: {
 		int newRoom = strToInt(argv[1]);
 		if (newRoom < 0 || newRoom >= _sceneNumb) {
-			debugPrintf("Invalid Room Number");
+			debugPrintf("Invalid Room Number\n");
 			return true;
 		}
 		if (!_sceneDescr[newRoom].size()) {
-			debugPrintf("Unused Room Number");
+			debugPrintf("Unused Room Number\n");
 			return true;
 		}
 			


Commit: 781c6ff8c44efd4e9411114d2628d547fab8ce33
    https://github.com/scummvm/scummvm/commit/781c6ff8c44efd4e9411114d2628d547fab8ce33
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-12T23:06:46-05:00

Commit Message:
ACCESS: Initial enum cleanup for Ant fields

Changed paths:
    engines/access/amazon/amazon_logic.cpp
    engines/access/amazon/amazon_logic.h



diff --git a/engines/access/amazon/amazon_logic.cpp b/engines/access/amazon/amazon_logic.cpp
index eb889d2..49bc47f 100644
--- a/engines/access/amazon/amazon_logic.cpp
+++ b/engines/access/amazon/amazon_logic.cpp
@@ -1926,8 +1926,8 @@ void River::synchronize(Common::Serializer &s) {
 /*------------------------------------------------------------------------*/
 
 Ant::Ant(AmazonEngine *vm) : AmazonManager(vm) {
-	_antDirection = NONE;
-	_pitDirection = NONE;
+	_antDirection = RIGHT;
+	_pitDirection = RIGHT;
 	_antCel = 0;
 	_torchCel = 0;
 	_pitCel = 0;
@@ -1962,6 +1962,7 @@ void Ant::plotPit(int indx, const int *&buf) {
 
 	_vm->_player->_rawPlayer = _pitPos;
 	if (_vm->_inventory->_inv[76]._value == 1) {
+		// Player has torch
 		idx = _torchCel;
 		buf = Amazon::TORCH;
 		_vm->_timers[14]._flag = 1;
@@ -1970,8 +1971,8 @@ void Ant::plotPit(int indx, const int *&buf) {
 			idx = 0;
 		_torchCel = idx;
 		plotTorchSpear(idx, buf);
-	}
-	else if (!_stabFl && (_vm->_inventory->_inv[78]._value == 1)) {
+	} else if (!_stabFl && (_vm->_inventory->_inv[78]._value == 1)) {
+		// Player has spear
 		idx = 0;
 		buf = Amazon::SPEAR;
 		plotTorchSpear(idx, buf);
@@ -1980,8 +1981,8 @@ void Ant::plotPit(int indx, const int *&buf) {
 
 int Ant::antHandleRight(int indx, const int *&buf) {
 	int retval = indx;
-	if (_pitDirection == NONE) {
-		_pitDirection = UP;
+	if (_pitDirection == RIGHT) {
+		_pitDirection = LEFT;
 		_pitPos.y = 127;
 	}
 	retval = _pitCel;
@@ -2001,8 +2002,8 @@ int Ant::antHandleRight(int indx, const int *&buf) {
 
 int Ant::antHandleLeft(int indx, const int *&buf) {
 	int retval = indx;
-	if (_pitDirection == UP) {
-		_pitDirection = NONE;
+	if (_pitDirection == LEFT) {
+		_pitDirection = RIGHT;
 		_pitPos.y = 127;
 	}
 	retval = _pitCel;
@@ -2058,7 +2059,7 @@ int Ant::antHandleStab(int indx, const int *&buf) {
 }
 
 void Ant::doAnt() {
-	_antDirection = NONE;
+	_antDirection = RIGHT;
 	if (_vm->_aniFlag != 1) {
 		_vm->_aniFlag = 1;
 		_antCel = 0;
@@ -2086,11 +2087,9 @@ void Ant::doAnt() {
 	const int *buf = nullptr;
 	if (_antDieFl) {
 		buf = Amazon::ANTDIE;
-	}
-	else if (_antEatFl) {
+	} else if (_antEatFl) {
 		buf = Amazon::ANTEAT;
-	}
-	else if (_antPos.x > 120 && _vm->_flags[198] == 1) {
+	} else if (_antPos.x > 120 && _vm->_flags[198] == 1) {
 		_antEatFl = true;
 		_vm->_flags[235] = 1;
 		_antCel = 0;
@@ -2098,13 +2097,14 @@ void Ant::doAnt() {
 	} else {
 		buf = Amazon::ANTWALK;
 		if (_vm->_inventory->_inv[76]._value == 1)
-			_antDirection = UP;
+			// Player has burning torch, which scares the Ant
+			_antDirection = LEFT;
 	}
 
 	int idx = _antCel;
 	if (_vm->_timers[15]._flag == 0) {
 		_vm->_timers[15]._flag = 1;
-		if (_antDirection == UP) {
+		if (_antDirection == LEFT) {
 			if (_antPos.x > 10) {
 				if (idx == 0)
 					idx = 36;
diff --git a/engines/access/amazon/amazon_logic.h b/engines/access/amazon/amazon_logic.h
index 2962d77..d66a8d8 100644
--- a/engines/access/amazon/amazon_logic.h
+++ b/engines/access/amazon/amazon_logic.h
@@ -209,10 +209,12 @@ public:
 	void synchronize(Common::Serializer &s);
 };
 
+enum AntDirection { RIGHT = 0, LEFT = 1 };
+
 class Ant: public AmazonManager {
 private:
-	Direction _antDirection;
-	Direction _pitDirection;
+	AntDirection _antDirection;
+	AntDirection _pitDirection;
 	int _antCel;
 	int _torchCel;
 	int _pitCel;


Commit: 547f3debb2b44dfb8fb3d659ac09f3bd24a017c4
    https://github.com/scummvm/scummvm/commit/547f3debb2b44dfb8fb3d659ac09f3bd24a017c4
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-12T23:07:00-05:00

Commit Message:
ACCESS: Separate timer updates from frame updates, and overall delay cleanup

Changed paths:
    engines/access/access.cpp
    engines/access/amazon/amazon_game.cpp
    engines/access/amazon/amazon_logic.cpp
    engines/access/events.cpp
    engines/access/events.h
    engines/access/inventory.cpp
    engines/access/room.cpp
    engines/access/screen.cpp
    engines/access/scripts.cpp



diff --git a/engines/access/access.cpp b/engines/access/access.cpp
index 4201564..bb5414d 100644
--- a/engines/access/access.cpp
+++ b/engines/access/access.cpp
@@ -410,9 +410,7 @@ void AccessEngine::playVideo(int videoNum, const Common::Point &pt) {
 
 	while (!shouldQuit() && !_video->_videoEnd) {
 		_video->playVideo();
-
-		g_system->delayMillis(10);
-		_events->pollEvents();
+		_events->pollEventsAndWait();
 	}
 }
 
diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp
index 29466f1..63291bd 100644
--- a/engines/access/amazon/amazon_game.cpp
+++ b/engines/access/amazon/amazon_game.cpp
@@ -535,8 +535,7 @@ void AmazonEngine::startChapter(int chapter) {
 
 		// Wait loop
 		while (!shouldQuit() && !_events->isKeyMousePressed() && _timers[20]._flag) {
-			_events->pollEvents();
-			g_system->delayMillis(10);
+			_events->pollEventsAndWait();
 		}
 	}
 
@@ -576,8 +575,7 @@ void AmazonEngine::startChapter(int chapter) {
 
 	// Wait loop
 	while (!shouldQuit() && !_events->isKeyMousePressed() && _timers[20]._flag) {
-		_events->pollEvents();
-		g_system->delayMillis(10);
+		_events->pollEventsAndWait();
 	}
 	if (shouldQuit())
 		return;
diff --git a/engines/access/amazon/amazon_logic.cpp b/engines/access/amazon/amazon_logic.cpp
index 49bc47f..320d874 100644
--- a/engines/access/amazon/amazon_logic.cpp
+++ b/engines/access/amazon/amazon_logic.cpp
@@ -687,10 +687,7 @@ void Plane::mWhileFly() {
 		++_pCount;
 
 		while (!_vm->shouldQuit() && events._vbCount > 0) {
-			// To be rewritten when NEWTIMER is done
-			events.checkForNextFrameCounter();
 			_vm->_sound->playSound(0);
-
 			events.pollEventsAndWait();
 		}
 	}
diff --git a/engines/access/events.cpp b/engines/access/events.cpp
index 5ed5ee2..249ba15 100644
--- a/engines/access/events.cpp
+++ b/engines/access/events.cpp
@@ -47,6 +47,7 @@ EventsManager::EventsManager(AccessEngine *vm): _vm(vm) {
 	_cursorExitFlag = false;
 	_vbCount = 0;
 	_keyCode = Common::KEYCODE_INVALID;
+	_priorTimerTime = 0;
 }
 
 EventsManager::~EventsManager() {
@@ -124,9 +125,12 @@ bool EventsManager::isCursorVisible() {
 
 void EventsManager::pollEvents(bool skipTimers) {
 	if (checkForNextFrameCounter()) {
-		nextFrame(skipTimers);
+		nextFrame();
 	}
 
+	if (checkForNextTimerUpdate() && !skipTimers)
+		nextTimer();
+
 	_wheelUp = _wheelDown = false;
 
 	Common::Event event;
@@ -233,7 +237,7 @@ void EventsManager::keyControl(Common::KeyCode keycode, bool isKeyDown) {
 
 void EventsManager::pollEventsAndWait() {
 	pollEvents();
-	g_system->delayMillis(10);
+	delay();
 }
 
 bool EventsManager::checkForNextFrameCounter() {
@@ -250,13 +254,19 @@ bool EventsManager::checkForNextFrameCounter() {
 	return false;
 }
 
-void EventsManager::nextFrame(bool skipTimers) {
-	if (!skipTimers) {
-		// Update timers
-		_vm->_animation->updateTimers();
-		_vm->_timers.updateTimers();
+bool EventsManager::checkForNextTimerUpdate() {
+	// Check for next timer update
+	uint32 milli = g_system->getMillis();
+	if ((milli - _priorTimerTime) >= GAME_TIMER_TIME) {
+		_priorTimerTime = milli;
+
+		return true;
 	}
 
+	return false;
+}
+
+void EventsManager::nextFrame() {
 	// Give time to the debugger
 	_vm->_debugger->onFrame();
 
@@ -264,6 +274,11 @@ void EventsManager::nextFrame(bool skipTimers) {
 	_vm->_screen->updateScreen();
 }
 
+void EventsManager::nextTimer() {
+	_vm->_animation->updateTimers();
+	_vm->_timers.updateTimers();
+}
+
 void EventsManager::delay(int time) {
 	g_system->delayMillis(time);
 }
@@ -288,8 +303,7 @@ bool EventsManager::isKeyPending() const {
 
 void EventsManager::debounceLeft() {
 	while (_leftButton && !_vm->shouldQuit()) {
-		pollEvents();
-		g_system->delayMillis(10);
+		pollEventsAndWait();
 	}
 }
 
@@ -301,7 +315,7 @@ void EventsManager::clearEvents() {
 void EventsManager::waitKeyMouse() {
 	while (!_vm->shouldQuit() && !isKeyMousePressed()) {
 		pollEvents(true);
-		g_system->delayMillis(10);
+		delay();
 	}
 }
 
diff --git a/engines/access/events.h b/engines/access/events.h
index 04edd2b..c43bf47 100644
--- a/engines/access/events.h
+++ b/engines/access/events.h
@@ -38,6 +38,7 @@ enum CursorType {
 
 #define GAME_FRAME_RATE 100
 #define GAME_FRAME_TIME (1000 / GAME_FRAME_RATE)
+#define GAME_TIMER_TIME 15
 
 class AccessEngine;
 
@@ -46,10 +47,14 @@ private:
 	AccessEngine *_vm;
 	uint32 _frameCounter;
 	uint32 _priorFrameTime;
+	uint32 _priorTimerTime;
 	Common::KeyCode _keyCode;
 
 	Graphics::Surface _invCursor;
-	void nextFrame(bool skipTimers);
+	bool checkForNextFrameCounter();
+	bool checkForNextTimerUpdate();
+	void nextFrame();
+	void nextTimer();
 	void keyControl(Common::KeyCode keycode, bool isKeyDown);
 public:
 	CursorType _cursorId;
@@ -117,7 +122,7 @@ public:
 
 	bool isKeyPending() const;
 
-	void delay(int time);
+	void delay(int time = 5);
 
 	void debounceLeft();
 
@@ -125,8 +130,6 @@ public:
 
 	void waitKeyMouse();
 
-	bool checkForNextFrameCounter();
-
 	Common::Point &getMousePos() { return _mousePos; }
 
 	Common::Point calcRawMouse();
diff --git a/engines/access/inventory.cpp b/engines/access/inventory.cpp
index 4038929..acba604 100644
--- a/engines/access/inventory.cpp
+++ b/engines/access/inventory.cpp
@@ -321,8 +321,7 @@ void InventoryManager::chooseItem() {
 
 	while (!_vm->shouldQuit()) {
 		// Check for events
-		events.pollEvents();
-		g_system->delayMillis(10);
+		events.pollEventsAndWait();
 
 		int selIndex;
 		// Poll events and wait for a click on a known area
@@ -414,8 +413,7 @@ void InventoryManager::combineItems() {
 	// Item drag handling loop if left button is held down
 	while (!_vm->shouldQuit() && events._leftButton) {
 		// Poll for events
-		events.pollEvents();
-		g_system->delayMillis(10);
+		events.pollEventsAndWait();
 
 		// Check positioning
 		if (lastMouse == events._mousePos)
@@ -485,8 +483,7 @@ void InventoryManager::zoomIcon(int zoomItem, int backItem, int zoomBox, bool sh
 		_invCoords[zoomBox].left + 46, _invCoords[zoomBox].top + 35);
 
 	while (!_vm->shouldQuit() && zoomScale != 0 && zoomScale != 256) {
-		_vm->_events->pollEvents();
-		g_system->delayMillis(5);
+		_vm->_events->pollEventsAndWait();
 
 		_vm->_buffer2.copyBlock(&_vm->_buffer1, boxRect);
 		if (backItem != -1) {
diff --git a/engines/access/room.cpp b/engines/access/room.cpp
index 57332f7..e18bd4a 100644
--- a/engines/access/room.cpp
+++ b/engines/access/room.cpp
@@ -81,9 +81,8 @@ void Room::doRoom() {
 
 			// Poll for events
 			_vm->_canSaveLoad = true;
-			_vm->_events->pollEvents();
+			_vm->_events->pollEventsAndWait();
 			_vm->_canSaveLoad = false;
-			g_system->delayMillis(5);
 
 			_vm->_player->walk();
 			_vm->_midi->midiRepeat();
diff --git a/engines/access/screen.cpp b/engines/access/screen.cpp
index f985524..318eb66 100644
--- a/engines/access/screen.cpp
+++ b/engines/access/screen.cpp
@@ -158,7 +158,7 @@ void Screen::forceFadeOut() {
 		}
 
 		updatePalette();
-		g_system->delayMillis(10);
+		_vm->_events->pollEventsAndWait();
 	} while (repeatFlag && !_vm->shouldQuit());
 }
 
@@ -180,7 +180,7 @@ void Screen::forceFadeIn() {
 		}
 
 		updatePalette();
-		g_system->delayMillis(10);
+		_vm->_events->pollEventsAndWait();
 	} while (repeatFlag);
 }
 
diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp
index 6c9f278..d8f9a51 100644
--- a/engines/access/scripts.cpp
+++ b/engines/access/scripts.cpp
@@ -521,12 +521,11 @@ void Scripts::cmdSaveRect() {
 }
 
 void Scripts::cmdVideoEnded() {
-	_vm->_events->pollEvents();
+	_vm->_events->pollEventsAndWait();
 
 	if (_vm->_video->_videoEnd) {
 		cmdGoto();
 	} else {
-		g_system->delayMillis(10);
 		_data->skip(2);
 	}
 }
@@ -731,8 +730,7 @@ void Scripts::cmdWait() {
 		_vm->_midi->midiRepeat();
 		charLoop();
 
-		_vm->_events->pollEvents();
-		g_system->delayMillis(10);
+		_vm->_events->pollEventsAndWait();
 	}
 
 	_vm->_events->debounceLeft();
@@ -819,8 +817,7 @@ void Scripts::cmdPlayVideoSound() {
 		_vm->_video->_soundFlag = true;
 	}
 
-	_vm->_events->pollEvents();
-	g_system->delayMillis(10);
+	_vm->_events->pollEventsAndWait();
 }
 
 void Scripts::cmdPrintWatch() {


Commit: c2e5dd8487834b875333652d6b482bd61a50354d
    https://github.com/scummvm/scummvm/commit/c2e5dd8487834b875333652d6b482bd61a50354d
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-12T23:07:12-05:00

Commit Message:
ACCESS: Fix positioning of Ant in pit scene

Changed paths:
    engines/access/amazon/amazon_logic.cpp



diff --git a/engines/access/amazon/amazon_logic.cpp b/engines/access/amazon/amazon_logic.cpp
index 320d874..517351f 100644
--- a/engines/access/amazon/amazon_logic.cpp
+++ b/engines/access/amazon/amazon_logic.cpp
@@ -2108,17 +2108,17 @@ void Ant::doAnt() {
 				else
 					idx -= 6;
 
-				_antPos = Common::Point(buf[(idx / 2) + 1], buf[(idx / 2) + 2]);
+				_antPos -= Common::Point(buf[(idx / 2) + 1], buf[(idx / 2) + 2]);
 				_antCel = idx;
 			}
 		} else {
 			idx += 6;
 			if (buf[(idx / 2)] != -1) {
-				_antPos = Common::Point(buf[(idx / 2) + 1], buf[(idx / 2) + 2]);
+				_antPos += Common::Point(buf[(idx / 2) + 1], buf[(idx / 2) + 2]);
 				_antCel = idx;
 			} else if (!_antDieFl) {
 				idx = 0;
-				_antPos = Common::Point(buf[(idx / 2) + 1], buf[(idx / 2) + 2]);
+				_antPos += Common::Point(buf[(idx / 2) + 1], buf[(idx / 2) + 2]);
 				_antCel = idx;
 			} else {
 				idx -= 6;


Commit: 41d0908606469ebbac5d8b3a6442e70a5e778b7f
    https://github.com/scummvm/scummvm/commit/41d0908606469ebbac5d8b3a6442e70a5e778b7f
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-12T23:07:24-05:00

Commit Message:
ACCESS: Fix death cell list data

Changed paths:
    engines/access/amazon/amazon_game.cpp
    engines/access/amazon/amazon_resources.cpp
    engines/access/amazon/amazon_resources.h



diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp
index 63291bd..802cb38 100644
--- a/engines/access/amazon/amazon_game.cpp
+++ b/engines/access/amazon/amazon_game.cpp
@@ -156,8 +156,8 @@ void AmazonEngine::setupGame() {
 			_deaths[i]._msg = DEATH_TEXT[i];
 		}
 	}
-	_deaths._cells.resize(12);
-	for (int i = 0; i < 12; ++i)
+	_deaths._cells.resize(13);
+	for (int i = 0; i < 13; ++i)
 		_deaths._cells[i] = CellIdent(DEATH_CELLS[i][0], DEATH_CELLS[i][1], DEATH_CELLS[i][2]);
 
 	// Miscellaneous
diff --git a/engines/access/amazon/amazon_resources.cpp b/engines/access/amazon/amazon_resources.cpp
index cb84841..694454c 100644
--- a/engines/access/amazon/amazon_resources.cpp
+++ b/engines/access/amazon/amazon_resources.cpp
@@ -1800,7 +1800,8 @@ const char *const DEATH_TEXT_DEMO[34] = {
 	"WITH THE BAR OFF THE DOOR THE CAPTAIN WALTZES IN AND BLOWS YOU AWAY"
 };
 
-const int DEATH_CELLS[12][3] = {
+const int DEATH_CELLS[13][3] = {
+	{ 0, 94, 2 },
 	{ 0, 94, 3 },
 	{ 0, 94, 4 },
 	{ 0, 94, 5 },
diff --git a/engines/access/amazon/amazon_resources.h b/engines/access/amazon/amazon_resources.h
index 92e0cec..36ae2af 100644
--- a/engines/access/amazon/amazon_resources.h
+++ b/engines/access/amazon/amazon_resources.h
@@ -89,7 +89,7 @@ extern const byte DEATH_SCREENS_DEMO[34];
 extern const char *const DEATH_TEXT[58];
 extern const char *const DEATH_TEXT_DEMO[34];
 
-extern const int DEATH_CELLS[12][3];
+extern const int DEATH_CELLS[13][3];
 
 extern const int CHAPTER_CELLS[17][3];
 


Commit: a6cc9250d329ab0d56c49dd24018ac1c84a723dc
    https://github.com/scummvm/scummvm/commit/a6cc9250d329ab0d56c49dd24018ac1c84a723dc
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-12T23:07:35-05:00

Commit Message:
ACCESS: Remove a useless variable, some renaming

Changed paths:
    engines/access/amazon/amazon_game.cpp
    engines/access/amazon/amazon_game.h
    engines/access/amazon/amazon_logic.cpp
    engines/access/amazon/amazon_logic.h



diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp
index 802cb38..ff16bbf 100644
--- a/engines/access/amazon/amazon_game.cpp
+++ b/engines/access/amazon/amazon_game.cpp
@@ -55,7 +55,6 @@ AccessEngine(syst, gameDesc),
 	_inactiveYOff = 0;
 	_hintLevel = 0;
 
-	Common::fill(&_esTabTable[0], &_esTabTable[100], 0);
 	memset(_tileData, 0, sizeof(_tileData));
 	Common::fill(&_help1[0], &_help1[366], 0);
 	Common::fill(&_help2[0], &_help2[366], 0);
@@ -415,11 +414,11 @@ void AmazonEngine::helpTitle() {
 
 	Common::String iqText = "IQ: ";
 	calcIQ();
-	Common::String IQSCORE = Common::String::format("%d", _iqValue);
-	while (IQSCORE.size() != 4)
-		IQSCORE = " " + IQSCORE;
+	Common::String scoreIQ = Common::String::format("%d", _iqValue);
+	while (scoreIQ.size() < 4)
+		scoreIQ = " " + scoreIQ;
 
-	iqText += IQSCORE;
+	iqText += scoreIQ;
 	int index = _iqValue;
 	if (index == 170)
 		index = 169;
@@ -768,8 +767,10 @@ void AmazonEngine::synchronize(Common::Serializer &s) {
 	s.syncAsSint16LE(_rawInactiveY);
 	s.syncAsSint16LE(_inactiveYOff);
 
+	int dummy = 0;
 	for (int i = 0; i < 100; ++i)
-		s.syncAsSint16LE(_esTabTable[i]);
+		s.syncAsSint16LE(dummy);
+
 	for (int i = 0; i < 366; ++i) {
 		s.syncAsByte(_help1[i]);
 		s.syncAsByte(_help2[i]);
diff --git a/engines/access/amazon/amazon_game.h b/engines/access/amazon/amazon_game.h
index 4ebea0f..5d87cc4 100644
--- a/engines/access/amazon/amazon_game.h
+++ b/engines/access/amazon/amazon_game.h
@@ -93,7 +93,6 @@ public:
 	int _rawInactiveX;
 	int _rawInactiveY;
 	int _inactiveYOff;
-	int _esTabTable[100];
 
 	// Other game specific fields
 	Ant *_ant;
diff --git a/engines/access/amazon/amazon_logic.cpp b/engines/access/amazon/amazon_logic.cpp
index 517351f..2aed0bc 100644
--- a/engines/access/amazon/amazon_logic.cpp
+++ b/engines/access/amazon/amazon_logic.cpp
@@ -1349,7 +1349,7 @@ void Cast::doCast(int param1) {
 /*------------------------------------------------------------------------*/
 
 River::River(AmazonEngine *vm): PannedScene(vm) {
-	_CHICKENOUTFLG = false;
+	_chickenOutFl = false;
 	_rScrollRow = 0;
 	_rScrollCol = 0;
 	_rScrollX = 0;
@@ -1592,7 +1592,7 @@ void River::moveCanoe() {
 			}
 		} else if (events._leftButton && mousePos.x < 35 && mousePos.y < 12) {
 			// Clicked on the Skip button. So chicken out
-			_CHICKENOUTFLG = true;
+			_chickenOutFl = true;
 		}  else if ((events._leftButton && pt.y <= _canoeYPos) ||
 			(!events._leftButton && _vm->_player->_move == UP)) {
 			// Move canoe up
@@ -1833,15 +1833,15 @@ void River::doRiver() {
 		if (_vm->_screen->_scrollX == 0) {
 			_vm->_midi->midiRepeat();
 			if (riverJumpTest()) {
-				_CHICKENOUTFLG = false;
+				_chickenOutFl = false;
 				return;
 			}
 		} else {
 			_vm->_screen->_scrollX -= _vm->_player->_scrollAmount;
 		}
 
-		if (_CHICKENOUTFLG) {
-			_CHICKENOUTFLG = false;
+		if (_chickenOutFl) {
+			_chickenOutFl = false;
 			return;
 		}
 
@@ -1886,7 +1886,7 @@ void River::doRiver() {
 		if (_vm->_room->_function == FN_CLEAR1) {
 			_vm->_scripts->_endFlag = true;
 			_vm->_scripts->_returnCode = 0;
-			_CHICKENOUTFLG = false;
+			_chickenOutFl = false;
 			break;
 		}
 	}
diff --git a/engines/access/amazon/amazon_logic.h b/engines/access/amazon/amazon_logic.h
index d66a8d8..8fb6df9 100644
--- a/engines/access/amazon/amazon_logic.h
+++ b/engines/access/amazon/amazon_logic.h
@@ -158,7 +158,7 @@ public:
 
 class River: public PannedScene {
 private:
-	bool _CHICKENOUTFLG;
+	bool _chickenOutFl;
 	const byte *_mapPtr;
 	int _canoeVXPos;
 	int _canoeMoveCount;


Commit: c82fb8c9571073b95da0f45a6b8beb3000fbfbc0
    https://github.com/scummvm/scummvm/commit/c82fb8c9571073b95da0f45a6b8beb3000fbfbc0
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-12T23:07:46-05:00

Commit Message:
ACCESS: Reduce screen pointer usage in amazon logic

Changed paths:
    engines/access/amazon/amazon_logic.cpp



diff --git a/engines/access/amazon/amazon_logic.cpp b/engines/access/amazon/amazon_logic.cpp
index 2aed0bc..c8bf054 100644
--- a/engines/access/amazon/amazon_logic.cpp
+++ b/engines/access/amazon/amazon_logic.cpp
@@ -204,21 +204,23 @@ Opening::Opening(AmazonEngine *vm) : CampScene(vm) {
 }
 
 void Opening::doIntroduction() {
-	_vm->_screen->setInitialPalettte();
+	Screen &screen = *_vm->_screen;
+
+	screen.setInitialPalettte();
 	_vm->_events->setCursor(CURSOR_ARROW);
 	_vm->_events->showCursor();
-	_vm->_screen->setPanel(0);
-	_vm->_screen->setPalette();
+	screen.setPanel(0);
+	screen.setPalette();
 
 	_vm->_events->setCursor(CURSOR_ARROW);
 	_vm->_events->showCursor();
-	_vm->_screen->setPanel(3);
+	screen.setPanel(3);
 	doTitle();
 
 	if (_vm->shouldQuit() || _skipStart || _vm->isDemo())
 		return;
 
-	_vm->_screen->setPanel(3);
+	screen.setPanel(3);
 	mWhileDoOpen();
 
 	if (_vm->shouldQuit() || _skipStart)
@@ -306,9 +308,11 @@ void Opening::scrollTitle() {
 }
 
 void Opening::doTitle() {
-	_vm->_screen->setDisplayScan();
+	Screen &screen = *_vm->_screen;
 
-	_vm->_screen->forceFadeOut();
+	screen.setDisplayScan();
+
+	screen.forceFadeOut();
 	_vm->_events->hideCursor();
 
 	if (!_vm->isDemo()) {
@@ -320,7 +324,7 @@ void Opening::doTitle() {
 
 		_vm->_buffer2.copyFrom(*_vm->_screen);
 		_vm->_buffer1.copyFrom(*_vm->_screen);
-		_vm->_screen->forceFadeIn();
+		screen.forceFadeIn();
 		_vm->_sound->playSound(1);
 
 		// WORKAROUND: This delay has been added to replace original game delay that
@@ -352,7 +356,7 @@ void Opening::doTitle() {
 			int id = COUNTDOWN[_pCount * 2];
 			int xp = COUNTDOWN[_pCount * 2 + 1];
 			_vm->_buffer2.plotImage(_vm->_objectsTable[0], id, Common::Point(xp, 71));
-			_vm->_screen->copyFrom(_vm->_buffer2);
+			screen.copyFrom(_vm->_buffer2);
 
 			_vm->_sound->playSound(1);
 			_vm->_events->_vbCount = 70;
@@ -367,7 +371,7 @@ void Opening::doTitle() {
 
 		_vm->_sound->stopSound();
 		_vm->_sound->playSound(0);
-		_vm->_screen->forceFadeOut();
+		screen.forceFadeOut();
 		_vm->_events->_vbCount = 100;
 		while (!_vm->shouldQuit() && _vm->_events->_vbCount > 0)
 			_vm->_events->pollEventsAndWait();
@@ -382,7 +386,7 @@ void Opening::doTitle() {
 		_vm->_files->loadScreen(0, 5);
 		_vm->_buffer2.copyFrom(*_vm->_screen);
 		_vm->_buffer1.copyFrom(*_vm->_screen);
-		_vm->_screen->forceFadeIn();
+		screen.forceFadeIn();
 		_vm->_midi->newMusic(1, 0);
 		_vm->_events->_vbCount = 700;
 		while (!_vm->shouldQuit() && (_vm->_events->_vbCount > 0) && !_vm->_events->isKeyMousePressed()) {
@@ -401,16 +405,16 @@ void Opening::doTitle() {
 		_vm->_events->zeroKeys();
 	}
 	_vm->_room->loadRoom(0);
-	_vm->_screen->clearScreen();
-	_vm->_screen->setBufferScan();
-	_vm->_screen->_scrollRow = _vm->_screen->_scrollCol = 0;
-	_vm->_screen->_scrollX = _vm->_screen->_scrollY = 0;
+	screen.clearScreen();
+	screen.setBufferScan();
+	screen._scrollRow = screen._scrollCol = 0;
+	screen._scrollX = screen._scrollY = 0;
 	_vm->_player->_rawPlayer = Common::Point(0, 0);
-	_vm->_screen->forceFadeOut();
-	_vm->_screen->_scrollX = 0;
+	screen.forceFadeOut();
+	screen._scrollX = 0;
 	_vm->_room->buildScreen();
 	_vm->copyBF2Vid();
-	_vm->_screen->forceFadeIn();
+	screen.forceFadeIn();
 	_vm->_oldRects.clear();
 	_vm->_newRects.clear();
 	_vm->_events->clearEvents();
@@ -427,15 +431,15 @@ void Opening::doTitle() {
 		}
 
 		_vm->_events->_vbCount = 4;
-		if (_vm->_screen->_scrollCol + _vm->_screen->_vWindowWidth != _vm->_room->_playFieldWidth) {
-			_vm->_screen->_scrollX += _vm->_player->_scrollAmount;
+		if (screen._scrollCol + screen._vWindowWidth != _vm->_room->_playFieldWidth) {
+			screen._scrollX += _vm->_player->_scrollAmount;
 
-			while (_vm->_screen->_scrollX >= TILE_WIDTH) {
-				_vm->_screen->_scrollX -= TILE_WIDTH;
-				++_vm->_screen->_scrollCol;
+			while (screen._scrollX >= TILE_WIDTH) {
+				screen._scrollX -= TILE_WIDTH;
+				++screen._scrollCol;
 
 				_vm->_buffer1.moveBufferLeft();
-				_vm->_room->buildColumn(_vm->_screen->_scrollCol + _vm->_screen->_vWindowWidth, _vm->_screen->_vWindowBytesWide);
+				_vm->_room->buildColumn(screen._scrollCol + screen._vWindowWidth, screen._vWindowBytesWide);
 			}
 			scrollTitle();
 			++_pCount;
@@ -453,23 +457,23 @@ void Opening::doTitle() {
 		while (!_vm->shouldQuit()) {
 			_pCount = 0;
 			_vm->_events->_vbCount = 3;
-			if (_vm->_screen->_scrollRow + _vm->_screen->_vWindowHeight >= _vm->_room->_playFieldHeight) {
+			if (screen._scrollRow + screen._vWindowHeight >= _vm->_room->_playFieldHeight) {
 				_vm->_room->clearRoom();
 				_vm->_events->showCursor();
 				return;
 			}
 
-			_vm->_screen->_scrollY = _vm->_screen->_scrollY + _vm->_player->_scrollAmount;
+			screen._scrollY = screen._scrollY + _vm->_player->_scrollAmount;
 
-			while (_vm->_screen->_scrollY >= TILE_HEIGHT && !_vm->shouldQuit()) {
-				_vm->_screen->_scrollY -= TILE_HEIGHT;
-				++_vm->_screen->_scrollRow;
+			while (screen._scrollY >= TILE_HEIGHT && !_vm->shouldQuit()) {
+				screen._scrollY -= TILE_HEIGHT;
+				++screen._scrollRow;
 				_vm->_buffer1.moveBufferUp();
 
-				// WORKAROUND: the original was using _vm->_screen->_vWindowBytesWide * _vm->_screen->_vWindowLinesTall
-				_vm->_room->buildRow(_vm->_screen->_scrollRow + _vm->_screen->_vWindowHeight, _vm->_screen->_vWindowLinesTall);
+				// WORKAROUND: the original was using screen._vWindowBytesWide * screen._vWindowLinesTall
+				_vm->_room->buildRow(screen._scrollRow + screen._vWindowHeight, screen._vWindowLinesTall);
 
-				if (_vm->_screen->_scrollRow + _vm->_screen->_vWindowHeight >= _vm->_room->_playFieldHeight) {
+				if (screen._scrollRow + screen._vWindowHeight >= _vm->_room->_playFieldHeight) {
 					_vm->_room->clearRoom();
 					_vm->_events->showCursor();
 					return;
@@ -793,17 +797,19 @@ void Jungle::initJWalk2() {
 		{ 0, 580, 0, 60 },
 		{ 1, 650, 0, 30 }
 	};
-	_vm->_screen->fadeOut();
+
+	Screen &screen = *_vm->_screen;
+	screen.fadeOut();
 	_vm->_events->hideCursor();
-	_vm->_screen->clearScreen();
+	screen.clearScreen();
 	_vm->_buffer2.clearBuffer();
-	_vm->_screen->setBufferScan();
+	screen.setBufferScan();
 
-	_vm->_screen->_scrollX = _vm->_screen->_scrollY;
-	_vm->_screen->_scrollCol = _vm->_screen->_scrollRow;
+	screen._scrollX = screen._scrollY;
+	screen._scrollCol = screen._scrollRow;
 	_vm->_room->buildScreen();
 	_vm->copyBF2Vid();
-	_vm->_screen->fadeIn();
+	screen.fadeIn();
 	_vm->_events->clearEvents();
 
 	_xCount = 2;
@@ -967,67 +973,71 @@ Guard::Guard(AmazonEngine *vm): PannedScene(vm) {
 }
 
 void Guard::setVerticalCode() {
+	Screen &screen = *_vm->_screen;
+
 	_gCode1 = 0;
 	_gCode2 = 0;
-	if (_topLeft.x < _vm->_screen->_orgX1)
+	if (_topLeft.x < screen._orgX1)
 		_gCode1 |= 8;
-	else if (_topLeft.x == _vm->_screen->_orgX1) {
+	else if (_topLeft.x == screen._orgX1) {
 		_gCode1 |= 8;
 		_gCode1 |= 2;
 	}
 	else
 		_gCode1 |= 2;
 
-	if (_bottomRight.x < _vm->_screen->_orgX1)
+	if (_bottomRight.x < screen._orgX1)
 		_gCode2 |= 8;
-	else if (_bottomRight.x == _vm->_screen->_orgX1) {
+	else if (_bottomRight.x == screen._orgX1) {
 		_gCode2 |= 8;
 		_gCode2 |= 2;
 	}
 	else
 		_gCode2 |= 2;
 
-	if (_topLeft.y < _vm->_screen->_orgY1)
+	if (_topLeft.y < screen._orgY1)
 		_gCode1 |= 4;
-	else if (_topLeft.y > _vm->_screen->_orgY2)
+	else if (_topLeft.y > screen._orgY2)
 		_gCode1 |= 1;
 
-	if (_bottomRight.y < _vm->_screen->_orgY1)
+	if (_bottomRight.y < screen._orgY1)
 		_gCode2 |= 4;
-	else if (_bottomRight.y > _vm->_screen->_orgY2)
+	else if (_bottomRight.y > screen._orgY2)
 		_gCode2 |= 1;
 }
 
 void Guard::setHorizontalCode() {
+	Screen &screen = *_vm->_screen;
+
 	_gCode1 = 0;
 	_gCode2 = 0;
 
-	if (_topLeft.y < _vm->_screen->_orgY1)
+	if (_topLeft.y < screen._orgY1)
 		_gCode1 |= 4;
-	else if (_topLeft.x == _vm->_screen->_orgX1) {
+	else if (_topLeft.x == screen._orgX1) {
 		_gCode1 |= 4;
 		_gCode1 |= 1;
 	}
 	else
 		_gCode1 |= 1;
 
-	if (_bottomRight.y < _vm->_screen->_orgY1)
+	if (_bottomRight.y < screen._orgY1)
 		_gCode2 |= 4;
-	else if (_bottomRight.x == _vm->_screen->_orgX1) {
+	else if (_bottomRight.x == screen._orgX1) {
 		_gCode2 |= 4;
 		_gCode2 |= 1;
 	}
 	else
 		_gCode2 |= 1;
 
-	if (_topLeft.x < _vm->_screen->_orgX1)
+	if (_topLeft.x < screen._orgX1)
 		_gCode1 |= 8;
-	else if (_topLeft.x > _vm->_screen->_orgX2)
+	else if (_topLeft.x > screen._orgX2)
 		_gCode1 |= 2;
 
-	if (_bottomRight.x < _vm->_screen->_orgX1)
+	if (_bottomRight.x < screen._orgX1)
 		_gCode2 |= 8;
-	else if (_bottomRight.y > _vm->_screen->_orgX2)
+	else if (_bottomRight.y > screen._orgX2)
 		_gCode2 |= 2;
 }
 
@@ -1120,12 +1130,13 @@ void Guard::chkHLine() {
 }
 
 void Guard::guardSee() {
-	int tmpY = (_vm->_screen->_scrollRow << 4) + _vm->_screen->_scrollY;
+	Screen &screen = *_vm->_screen;
+	int tmpY = (screen._scrollRow << 4) + screen._scrollY;
 	_vm->_flags[140] = 0;
 	if (tmpY > _position.y)
 		return;
 
-	tmpY += _vm->_screen->_vWindowLinesTall;
+	tmpY += screen._vWindowLinesTall;
 	tmpY -= 11;
 
 	if (tmpY < _position.y)
@@ -1135,16 +1146,16 @@ void Guard::guardSee() {
 	_vm->_flags[140] = 1;
 
 	for (uint16 idx = 0; idx < _vm->_room->_plotter._walls.size(); idx++) {
-		_vm->_screen->_orgX1 = _vm->_room->_plotter._walls[idx].left;
-		_vm->_screen->_orgY1 = _vm->_room->_plotter._walls[idx].top;
-		_vm->_screen->_orgX2 = _vm->_room->_plotter._walls[idx].right;
-		_vm->_screen->_orgY2 = _vm->_room->_plotter._walls[idx].bottom;
-		if (_vm->_screen->_orgX1 == _vm->_screen->_orgX2) {
+		screen._orgX1 = _vm->_room->_plotter._walls[idx].left;
+		screen._orgY1 = _vm->_room->_plotter._walls[idx].top;
+		screen._orgX2 = _vm->_room->_plotter._walls[idx].right;
+		screen._orgY2 = _vm->_room->_plotter._walls[idx].bottom;
+		if (screen._orgX1 == screen._orgX2) {
 			chkVLine();
 			if (_vm->_guardFind == 0)
 				return;
 		}
-		else if (_vm->_screen->_orgY1 == _vm->_screen->_orgY2) {
+		else if (screen._orgY1 == screen._orgY2) {
 			chkHLine();
 			if (_vm->_guardFind == 0)
 				return;
@@ -1246,15 +1257,17 @@ Cast::Cast(AmazonEngine *vm) : PannedScene(vm) {
 }
 
 void Cast::doCast(int param1) {
-	_vm->_screen->setDisplayScan();
+	Screen &screen = *_vm->_screen;
+
+	screen.setDisplayScan();
 	_vm->_events->hideCursor();
-	_vm->_screen->forceFadeOut();
-	_vm->_screen->_clipHeight = 173;
-	_vm->_screen->clearScreen();
+	screen.forceFadeOut();
+	screen._clipHeight = 173;
+	screen.clearScreen();
 	_vm->_chapter = 16;
 	_vm->tileScreen();
 	_vm->updateSummary(param1);
-	_vm->_screen->setPanel(3);
+	screen.setPanel(3);
 	_vm->_chapter = 14;
 
 	Resource *spriteData = _vm->_files->loadFile(91, 0);
@@ -1304,7 +1317,7 @@ void Cast::doCast(int param1) {
 	_vm->_numAnimTimers = 0;
 
 	_vm->_midi->newMusic(58, 0);
-	_vm->_screen->forceFadeIn();
+	screen.forceFadeIn();
 
 	while (!_vm->shouldQuit()) {
 		_vm->_images.clear();
@@ -1340,7 +1353,7 @@ void Cast::doCast(int param1) {
 	_vm->_newRects.clear();
 	_vm->_numAnimTimers = 0;
 	_vm->_images.clear();
-	_vm->_screen->forceFadeOut();
+	screen.forceFadeOut();
 
 	_vm->quitGame();
 	_vm->_events->pollEvents();
@@ -1389,40 +1402,41 @@ void River::setRiverPan() {
 
 void River::initRiver() {
 	static const int RIVERVXTBL[3] = { 6719, 7039, 8319 };
+	Screen &screen = *_vm->_screen;
 
 	_vm->_events->centerMousePos();
 	_vm->_events->restrictMouse();
-	_vm->_screen->setDisplayScan();
-	_vm->_screen->clearScreen();
-	_vm->_screen->savePalette();
-	_vm->_screen->forceFadeOut();
+	screen.setDisplayScan();
+	screen.clearScreen();
+	screen.savePalette();
+	screen.forceFadeOut();
 
 	_vm->_files->_setPaletteFlag = false;
 	_vm->_files->loadScreen(95, 4);
 	_vm->_buffer2.copyFrom(*_vm->_screen);
 
-	_vm->_screen->restorePalette();
-	_vm->_screen->setBufferScan();
+	screen.restorePalette();
+	screen.setBufferScan();
 	_vm->_destIn = &_vm->_buffer2;
 	_vm->_room->roomMenu();
 
 	if (_saveRiver) {
 		// Restoring a savegame, so set properties from saved fields
-		_vm->_screen->_scrollRow = _rScrollRow;
-		_vm->_screen->_scrollCol = _rScrollCol;
-		_vm->_screen->_scrollX = _rScrollX;
-		_vm->_screen->_scrollY = _rScrollY;
+		screen._scrollRow = _rScrollRow;
+		screen._scrollCol = _rScrollCol;
+		screen._scrollX = _rScrollX;
+		screen._scrollY = _rScrollY;
 	} else {
 		// Set initial scene state
-		_vm->_screen->_scrollRow = 0;
-		_vm->_screen->_scrollCol = 140;
-		_vm->_screen->_scrollX = 0;
-		_vm->_screen->_scrollY = 0;
+		screen._scrollRow = 0;
+		screen._scrollCol = 140;
+		screen._scrollX = 0;
+		screen._scrollY = 0;
 	}
 
 	_vm->_room->buildScreen();
 	_vm->copyBF2Vid();
-	_vm->_screen->forceFadeIn();
+	screen.forceFadeIn();
 
 	if (!_saveRiver) {
 		// Reset draw rects
@@ -1499,21 +1513,23 @@ void River::checkRiverPan() {
 }
 
 bool River::riverJumpTest() {
-	if (_vm->_screen->_scrollCol == 120 || _vm->_screen->_scrollCol == 60 || _vm->_screen->_scrollCol == 0) {
+	Screen &screen = *_vm->_screen;
+
+	if (screen._scrollCol == 120 || screen._scrollCol == 60 || screen._scrollCol == 0) {
 		int val = *++_mapPtr;
 		if (val == 0xFF)
 			return true;
 
-		_oldScrollCol = _vm->_screen->_scrollCol;
+		_oldScrollCol = screen._scrollCol;
 
 		if (val == 0) {
-			_vm->_screen->_scrollCol = 139;
-			_vm->_screen->_scrollX = 14;
+			screen._scrollCol = 139;
+			screen._scrollX = 14;
 			_vm->_room->buildScreen();
 			resetPositions();
 			return false;
 		}
-	} else if (_vm->_screen->_scrollCol == 105) {
+	} else if (screen._scrollCol == 105) {
 		int val1 = _mapPtr[1];
 		int val2 = _mapPtr[2];
 		_mapPtr += 3;
@@ -1529,19 +1545,19 @@ bool River::riverJumpTest() {
 				_deathCount = 300;
 				_deathType = val2;
 			}
-			_oldScrollCol = _vm->_screen->_scrollCol;
-			_vm->_screen->_scrollCol = 44;
-			_vm->_screen->_scrollX = 14;
+			_oldScrollCol = screen._scrollCol;
+			screen._scrollCol = 44;
+			screen._scrollX = 14;
 			_vm->_room->buildScreen();
 			resetPositions();
 			return false;
 		}
 	}
 
-	_vm->_screen->_scrollX = 14;
-	--_vm->_screen->_scrollCol;
+	screen._scrollX = 14;
+	--screen._scrollCol;
 	_vm->_buffer1.moveBufferRight();
-	_vm->_room->buildColumn(_vm->_screen->_scrollCol, 0);
+	_vm->_room->buildColumn(screen._scrollCol, 0);
 	checkRiverPan();
 	return false;
 }
@@ -1628,7 +1644,7 @@ void River::updateObstacles() {
 	for (cur = _topList; cur < RIVER_OBJECTS[_riverIndex][RIVER_END]; ++cur) {
 		int val = cur->_riverX + cur->_width - 1;
 		if (val < _screenVertX)
-			// Obstacle is not yet on-scren
+			// Obstacle is not yet on-screen
 			break;
 
 		if (cur->_riverX < (_screenVertX + 319)) {
@@ -1723,19 +1739,20 @@ void River::plotRiver() {
 }
 
 void River::mWhileDownRiver() {
+	Screen &screen = *_vm->_screen;
 	_vm->_events->hideCursor();
 
-	_vm->_screen->setDisplayScan();
-	_vm->_screen->clearScreen();
-	_vm->_screen->savePalette();
+	screen.setDisplayScan();
+	screen.clearScreen();
+	screen.savePalette();
 	if (!_vm->isDemo())
 		_vm->_files->loadScreen(95, 4);
 	_vm->_buffer2.copyFrom(*_vm->_screen);
-	_vm->_screen->restorePalette();
-	_vm->_screen->setPalette();
-	_vm->_screen->setBufferScan();
+	screen.restorePalette();
+	screen.setPalette();
+	screen.setBufferScan();
 
-	_vm->_screen->_scrollX = 0;
+	screen._scrollX = 0;
 	_vm->_room->buildScreen();
 	_vm->copyBF2Vid();
 
@@ -1768,16 +1785,16 @@ void River::mWhileDownRiver() {
 	++_vm->_timers[4]._flag;
 
 	while (!_vm->shouldQuit() && !_vm->_events->isKeyMousePressed() &&
-		(_vm->_screen->_scrollCol + _vm->_screen->_vWindowWidth != _vm->_room->_playFieldWidth)) {
+		(screen._scrollCol + screen._vWindowWidth != _vm->_room->_playFieldWidth)) {
 		_vm->_images.clear();
 		_vm->_events->_vbCount = 6;
 
-		_vm->_screen->_scrollX += _vm->_player->_scrollAmount;
-		while (_vm->_screen->_scrollX >= TILE_WIDTH) {
-			_vm->_screen->_scrollX -= TILE_WIDTH;
-			++_vm->_screen->_scrollCol;
+		screen._scrollX += _vm->_player->_scrollAmount;
+		while (screen._scrollX >= TILE_WIDTH) {
+			screen._scrollX -= TILE_WIDTH;
+			++screen._scrollCol;
 			_vm->_buffer1.moveBufferLeft();
-			_vm->_room->buildColumn(_vm->_screen->_scrollCol + _vm->_screen->_vWindowWidth, _vm->_screen->_vWindowBytesWide);
+			_vm->_room->buildColumn(screen._scrollCol + screen._vWindowWidth, screen._vWindowBytesWide);
 		}
 
 		pan();


Commit: 5520a763849a4dd7df6cd2eb727ac89294b5790f
    https://github.com/scummvm/scummvm/commit/5520a763849a4dd7df6cd2eb727ac89294b5790f
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-12T23:07:57-05:00

Commit Message:
ACCESS: Fix speakText behavior

Changed paths:
    engines/access/access.cpp



diff --git a/engines/access/access.cpp b/engines/access/access.cpp
index bb5414d..97b08d7 100644
--- a/engines/access/access.cpp
+++ b/engines/access/access.cpp
@@ -216,27 +216,25 @@ void AccessEngine::speakText(ASurface *s, const Common::String &msg) {
 		s->_printOrg = Common::Point(s->_printStart.x, s->_printOrg.y + 9);
 
 		if ((s->_printOrg.y > _printEnd) && (!lastLine)) {
-			if (!_sound->_isVoice) {
-				_events->waitKeyMouse();
-			} else {
-				while (!shouldQuit()) {
-					_sound->freeSounds();
-					Resource *sound = _sound->loadSound(_narateFile + 99, _sndSubFile);
-					_sound->_soundTable.push_back(SoundEntry(sound, 1));
-					_sound->playSound(0);
-					_scripts->cmdFreeSound();
-
-					_events->pollEvents();
-
-					if (_events->isKeyMousePressed()) {
-						_sndSubFile += soundsLeft;
+			_events->clearEvents();
+			while (!shouldQuit()) {
+				_sound->freeSounds();
+				Resource *sound = _sound->loadSound(_narateFile + 99, _sndSubFile);
+				_sound->_soundTable.push_back(SoundEntry(sound, 1));
+				_sound->playSound(0);
+				_scripts->cmdFreeSound();
+
+				_events->pollEvents();
+
+				if (_events->isKeyMousePressed()) {
+					_sndSubFile += soundsLeft;
+					break;
+				} else {
+					++_sndSubFile;
+					--soundsLeft;
+					if (soundsLeft == 0)
 						break;
-					} else {
-						++_sndSubFile;
-						--soundsLeft;
-						if (soundsLeft == 0)
-							break;
-					}
+					_events->clearEvents();
 				}
 			}
 
@@ -253,11 +251,6 @@ void AccessEngine::speakText(ASurface *s, const Common::String &msg) {
 	if (soundsLeft == 0)
 		return;
 
-	if (!_sound->_isVoice) {
-		_events->waitKeyMouse();
-		return;
-	}
-
 	for (;;) {
 		_sound->freeSounds();
 		Resource *res = _sound->loadSound(_narateFile + 99, _sndSubFile);


Commit: b1f63a9985055a7a71ebfdfb14bfe1d59502ad16
    https://github.com/scummvm/scummvm/commit/b1f63a9985055a7a71ebfdfb14bfe1d59502ad16
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-12T23:08:08-05:00

Commit Message:
ACCESS: Fix for player movement and stab action in pit scene

Changed paths:
    engines/access/amazon/amazon_game.cpp
    engines/access/amazon/amazon_logic.cpp
    engines/access/amazon/amazon_logic.h



diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp
index ff16bbf..af9de52 100644
--- a/engines/access/amazon/amazon_game.cpp
+++ b/engines/access/amazon/amazon_game.cpp
@@ -778,6 +778,7 @@ void AmazonEngine::synchronize(Common::Serializer &s) {
 	}
 
 	_river->synchronize(s);
+	_ant->synchronize(s);
 }
 
 } // End of namespace Amazon
diff --git a/engines/access/amazon/amazon_logic.cpp b/engines/access/amazon/amazon_logic.cpp
index c8bf054..e8e27fc 100644
--- a/engines/access/amazon/amazon_logic.cpp
+++ b/engines/access/amazon/amazon_logic.cpp
@@ -1940,8 +1940,8 @@ void River::synchronize(Common::Serializer &s) {
 /*------------------------------------------------------------------------*/
 
 Ant::Ant(AmazonEngine *vm) : AmazonManager(vm) {
-	_antDirection = RIGHT;
-	_pitDirection = RIGHT;
+	_antDirection = ANT_RIGHT;
+	_pitDirection = ANT_RIGHT;
 	_antCel = 0;
 	_torchCel = 0;
 	_pitCel = 0;
@@ -1975,7 +1975,7 @@ void Ant::plotPit(int indx, const int *&buf) {
 	_vm->_images.addToList(ie);
 
 	_vm->_player->_rawPlayer = _pitPos;
-	if (_vm->_inventory->_inv[76]._value == 1) {
+	if (_vm->_inventory->_inv[76]._value == ITEM_IN_INVENTORY) {
 		// Player has torch
 		idx = _torchCel;
 		buf = Amazon::TORCH;
@@ -1985,7 +1985,8 @@ void Ant::plotPit(int indx, const int *&buf) {
 			idx = 0;
 		_torchCel = idx;
 		plotTorchSpear(idx, buf);
-	} else if (!_stabFl && (_vm->_inventory->_inv[78]._value == 1)) {
+	}
+	else if (!_stabFl && (_vm->_inventory->_inv[78]._value == ITEM_IN_INVENTORY)) {
 		// Player has spear
 		idx = 0;
 		buf = Amazon::SPEAR;
@@ -1995,8 +1996,8 @@ void Ant::plotPit(int indx, const int *&buf) {
 
 int Ant::antHandleRight(int indx, const int *&buf) {
 	int retval = indx;
-	if (_pitDirection == RIGHT) {
-		_pitDirection = LEFT;
+	if (_pitDirection == ANT_RIGHT) {
+		_pitDirection = ANT_LEFT;
 		_pitPos.y = 127;
 	}
 	retval = _pitCel;
@@ -2016,8 +2017,8 @@ int Ant::antHandleRight(int indx, const int *&buf) {
 
 int Ant::antHandleLeft(int indx, const int *&buf) {
 	int retval = indx;
-	if (_pitDirection == LEFT) {
-		_pitDirection = RIGHT;
+	if (_pitDirection == ANT_LEFT) {
+		_pitDirection = ANT_RIGHT;
 		_pitPos.y = 127;
 	}
 	retval = _pitCel;
@@ -2036,14 +2037,16 @@ int Ant::antHandleLeft(int indx, const int *&buf) {
 
 int Ant::antHandleStab(int indx, const int *&buf) {
 	int retval = indx;
-	if (_vm->_inventory->_inv[78]._value != 1) {
+	if (_vm->_inventory->_inv[78]._value == ITEM_IN_INVENTORY) {
 		if (_stabFl) {
 			buf = Amazon::PITSTAB;
 			retval = _stabCel;
 			if (_vm->_timers[13]._flag == 0) {
 				_vm->_timers[13]._flag = 1;
 				retval += 6;
-				if (Amazon::PITSTAB[retval] == -1) {
+				_stabCel = retval;
+
+				if (buf[retval] == -1) {
 					_stabFl = false;
 					_pitCel = 0;
 					_pitPos.y = 127;
@@ -2069,11 +2072,12 @@ int Ant::antHandleStab(int indx, const int *&buf) {
 			}
 		}
 	}
+
 	return retval;
 }
 
 void Ant::doAnt() {
-	_antDirection = RIGHT;
+	_antDirection = ANT_RIGHT;
 	if (_vm->_aniFlag != 1) {
 		_vm->_aniFlag = 1;
 		_antCel = 0;
@@ -2110,15 +2114,15 @@ void Ant::doAnt() {
 		buf = Amazon::ANTEAT;
 	} else {
 		buf = Amazon::ANTWALK;
-		if (_vm->_inventory->_inv[76]._value == 1)
+		if (_vm->_inventory->_inv[76]._value == ITEM_IN_INVENTORY)
 			// Player has burning torch, which scares the Ant
-			_antDirection = LEFT;
+			_antDirection = ANT_LEFT;
 	}
 
 	int idx = _antCel;
 	if (_vm->_timers[15]._flag == 0) {
 		_vm->_timers[15]._flag = 1;
-		if (_antDirection == LEFT) {
+		if (_antDirection == ANT_LEFT) {
 			if (_antPos.x > 10) {
 				if (idx == 0)
 					idx = 36;
@@ -2156,7 +2160,7 @@ void Ant::doAnt() {
 
 	if (_vm->_flags[196] != 1) {
 		idx = _pitCel;
-		if (_stabFl == 1) {
+		if (_stabFl) {
 			idx = antHandleStab(idx, buf);
 		} else {
 			buf = Amazon::PITWALK;
@@ -2164,18 +2168,20 @@ void Ant::doAnt() {
 				_vm->_timers[13]._flag = 1;
 				_vm->_events->pollEvents();
 				if (_vm->_events->_leftButton) {
+					// Handle moving the player whilst the mouse button is held down
 					Common::Point pt = _vm->_events->calcRawMouse();
 					if (pt.x < _pitPos.x)
 						idx = antHandleLeft(idx, buf);
 					else if (pt.x > _pitPos.x)
 						idx = antHandleRight(idx, buf);
 				} else {
+					// Handle movement based on keyboard keys
 					buf = Amazon::PITWALK;
-					if (_vm->_player->_playerDirection == UP)
+					if (_vm->_player->_move == UP)
 						idx = antHandleStab(idx, buf);
-					else if (_vm->_player->_playerDirection == LEFT)
+					else if (_vm->_player->_move == LEFT)
 						idx = antHandleLeft(idx, buf);
-					else if (_vm->_player->_playerDirection == RIGHT)
+					else if (_vm->_player->_move == RIGHT)
 						idx = antHandleRight(idx, buf);
 				}
 			}
@@ -2192,6 +2198,25 @@ void Ant::doAnt() {
 	}
 }
 
+void Ant::synchronize(Common::Serializer &s) {
+	if (_vm->_player->_roomNumber == 61) {
+		s.syncAsByte(_antDirection);
+		s.syncAsByte(_pitDirection);
+		s.syncAsSint16LE(_antCel);
+		s.syncAsSint16LE(_torchCel);
+		s.syncAsSint16LE(_pitCel);
+		s.syncAsSint16LE(_stabCel);
+		s.syncAsSint16LE(_antPos.x);
+		s.syncAsSint16LE(_antPos.y);
+		s.syncAsSint16LE(_pitPos.x);
+		s.syncAsSint16LE(_pitPos.y);
+		s.syncAsByte(_antDieFl);
+		s.syncAsByte(_antEatFl);
+		s.syncAsByte(_stabFl);
+	}
+}
+
+
 } // End of namespace Amazon
 
 } // End of namespace Access
diff --git a/engines/access/amazon/amazon_logic.h b/engines/access/amazon/amazon_logic.h
index 8fb6df9..9b429d8 100644
--- a/engines/access/amazon/amazon_logic.h
+++ b/engines/access/amazon/amazon_logic.h
@@ -209,7 +209,7 @@ public:
 	void synchronize(Common::Serializer &s);
 };
 
-enum AntDirection { RIGHT = 0, LEFT = 1 };
+enum AntDirection { ANT_RIGHT = 0, ANT_LEFT = 1 };
 
 class Ant: public AmazonManager {
 private:
@@ -234,6 +234,8 @@ public:
 	Ant(AmazonEngine *vm);
 
 	void doAnt();
+
+	void synchronize(Common::Serializer &s);
 };
 
 class InactivePlayer : public ImageEntry {


Commit: 712a18d0500dd51dc113ebaf5ac420ceaa8e456c
    https://github.com/scummvm/scummvm/commit/712a18d0500dd51dc113ebaf5ac420ceaa8e456c
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-12T23:08:18-05:00

Commit Message:
ACCESS: Fix compilation errors reported by Criezy

Changed paths:
    engines/access/access.cpp
    engines/access/amazon/amazon_scripts.cpp
    engines/access/sound.cpp
    engines/access/sound.h



diff --git a/engines/access/access.cpp b/engines/access/access.cpp
index 97b08d7..d0bd3e6 100644
--- a/engines/access/access.cpp
+++ b/engines/access/access.cpp
@@ -150,7 +150,7 @@ void AccessEngine::initialize() {
 	_player = Player::init(this);
 	_screen = new Screen(this);
 	_sound = new SoundManager(this, _mixer);
-	_midi = new MusicManager(this, _mixer);
+	_midi = new MusicManager(this);
 	_video = new VideoPlayer(this);
 
 	_buffer1.create(g_system->getWidth() + TILE_WIDTH, g_system->getHeight());
diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp
index 52c142a..ce9a3d5 100644
--- a/engines/access/amazon/amazon_scripts.cpp
+++ b/engines/access/amazon/amazon_scripts.cpp
@@ -481,8 +481,8 @@ void AmazonScripts::cmdChapter() {
 }
 
 void AmazonScripts::cmdSetHelp() {
-	int arrayId = (_data->readUint16LE() && 0xFF) - 1;
-	int helpId = _data->readUint16LE() && 0xFF;
+	int arrayId = (_data->readUint16LE() & 0xFF) - 1;
+	int helpId = _data->readUint16LE() & 0xFF;
 
 	byte *help = _game->_helpTbl[arrayId];
 	help[helpId] = 1;
diff --git a/engines/access/sound.cpp b/engines/access/sound.cpp
index 4e70161..e151458 100644
--- a/engines/access/sound.cpp
+++ b/engines/access/sound.cpp
@@ -162,7 +162,7 @@ void SoundManager::freeSounds() {
 
 /******************************************************************************************/
 
-MusicManager::MusicManager(AccessEngine *vm, Audio::Mixer *mixer) : _vm(vm), _mixer(mixer) {
+MusicManager::MusicManager(AccessEngine *vm) : _vm(vm) {
 	_music = nullptr;
 	_tempMusic = nullptr;
 	_isLooping = false;
diff --git a/engines/access/sound.h b/engines/access/sound.h
index dc8bd90..ed8fe0b 100644
--- a/engines/access/sound.h
+++ b/engines/access/sound.h
@@ -74,7 +74,6 @@ public:
 class MusicManager : public Audio::MidiPlayer {
 private:
 	AccessEngine *_vm;
-	Audio::Mixer *_mixer;
 
 	Resource *_tempMusic;
 
@@ -85,7 +84,7 @@ public:
 	Resource *_music;
 
 public:
-	MusicManager(AccessEngine *vm, Audio::Mixer *mixer);
+	MusicManager(AccessEngine *vm);
 	~MusicManager();
 
 	void midiPlay();


Commit: de63e2afbc967016e5cdd1d5aff126a1fca7d4ed
    https://github.com/scummvm/scummvm/commit/de63e2afbc967016e5cdd1d5aff126a1fca7d4ed
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-12T23:08:29-05:00

Commit Message:
ACCESS: Properly indent some code in playSound

Changed paths:
    engines/access/sound.cpp



diff --git a/engines/access/sound.cpp b/engines/access/sound.cpp
index e151458..57f95c9 100644
--- a/engines/access/sound.cpp
+++ b/engines/access/sound.cpp
@@ -96,8 +96,8 @@ void SoundManager::playSound(Resource *res, int priority) {
 		//  header content:
 		//   "STEVE" - fixed header
 		//   byte    - sample rate
-		//              01h mapped internally to 3Ch ??
-		//              02h mapped internally to 78h seems to be 11025Hz
+		//              01h mapped internally to 3Ch
+		//              02h mapped internally to 78h
 		//              03h mapped internally to B5h
 		//              04h mapped internally to F1h
 		//   byte    - unknown
@@ -109,10 +109,22 @@ void SoundManager::playSound(Resource *res, int priority) {
 
 		int sampleRate = 0;
 		switch (internalSampleRate) {
-		case 1: sampleRate = 16666; break; // 3Ch -> C4h time constant
-		case 2: sampleRate = 8334; break;  // 78h -> 88h time constant
-		case 3: sampleRate = 5525; break;  // B5h -> 4Bh time constant
-		case 4: sampleRate = 4150; break;  // F1h -> 0Fh time constant
+		case 1: // NEG(3Ch) -> C4h time constant
+			sampleRate = 16666;
+			break;
+
+		case 2: // NEG(78h) -> 88h time constant
+			sampleRate = 8334;
+			break;
+
+		case 3: // NEG(B5h) -> 4Bh time constant
+			sampleRate = 5525;
+			break;
+
+		case 4: // NEG(F1h) -> 0Fh time constant
+			sampleRate = 4150;
+			break;
+
 		default:
 			error("Unexpected internal Sample Rate %d", internalSampleRate);
 			return;


Commit: 330cb5fb07c18ecd61e1cac20ce3e030dfe5687b
    https://github.com/scummvm/scummvm/commit/330cb5fb07c18ecd61e1cac20ce3e030dfe5687b
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-12T23:24:49-05:00

Commit Message:
ACCESS: Remove old dummy unused fields from savegame

Changed paths:
    engines/access/amazon/amazon_game.cpp



diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp
index af9de52..793a601 100644
--- a/engines/access/amazon/amazon_game.cpp
+++ b/engines/access/amazon/amazon_game.cpp
@@ -767,10 +767,6 @@ void AmazonEngine::synchronize(Common::Serializer &s) {
 	s.syncAsSint16LE(_rawInactiveY);
 	s.syncAsSint16LE(_inactiveYOff);
 
-	int dummy = 0;
-	for (int i = 0; i < 100; ++i)
-		s.syncAsSint16LE(dummy);
-
 	for (int i = 0; i < 366; ++i) {
 		s.syncAsByte(_help1[i]);
 		s.syncAsByte(_help2[i]);


Commit: 98889efae52bba628c83f0d9109962e65c6f5c0a
    https://github.com/scummvm/scummvm/commit/98889efae52bba628c83f0d9109962e65c6f5c0a
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-13T21:25:46-05:00

Commit Message:
ACCESS: Beginnings of dirty rect handling for screen

Changed paths:
    engines/access/access.cpp
    engines/access/asurface.h
    engines/access/screen.cpp
    engines/access/screen.h



diff --git a/engines/access/access.cpp b/engines/access/access.cpp
index d0bd3e6..b67aebf 100644
--- a/engines/access/access.cpp
+++ b/engines/access/access.cpp
@@ -396,6 +396,11 @@ void AccessEngine::copyBF2Vid() {
 		srcP += _buffer2.pitch;
 		destP += _screen->pitch;
 	}
+
+	// Add dirty rect for affected area
+	Common::Rect r(_screen->_vWindowBytesWide, _screen->_vWindowLinesTall);
+	r.moveTo(_screen->_windowXAdd, _screen->_windowYAdd + _screen->_screenYOff);
+	_screen->addDirtyRect(r);
 }
 
 void AccessEngine::playVideo(int videoNum, const Common::Point &pt) {
diff --git a/engines/access/asurface.h b/engines/access/asurface.h
index 273578c..0ce08bb 100644
--- a/engines/access/asurface.h
+++ b/engines/access/asurface.h
@@ -38,9 +38,10 @@ class SpriteFrame;
 class ASurface : public Graphics::Surface {
 private:
 	Graphics::Surface _savedBlock;
-	Common::Rect _savedBounds;
 
 	void flipHorizontal(ASurface &dest);
+protected:
+	Common::Rect _savedBounds;
 public:
 	static int _leftSkip, _rightSkip;
 	static int _topSkip, _bottomSkip;
@@ -92,6 +93,8 @@ public:
 
 	virtual void copyBlock(ASurface *src, const Common::Rect &bounds);
 
+	virtual void restoreBlock();
+
 	void copyTo(ASurface *dest, const Common::Point &destPos);
 
 	void copyTo(ASurface *dest, const Common::Rect &bounds);
@@ -100,8 +103,6 @@ public:
 
 	void saveBlock(const Common::Rect &bounds);
 
-	void restoreBlock();
-
 	void drawRect();
 
 	void moveBufferLeft();
diff --git a/engines/access/screen.cpp b/engines/access/screen.cpp
index 318eb66..9ccad28 100644
--- a/engines/access/screen.cpp
+++ b/engines/access/screen.cpp
@@ -68,6 +68,8 @@ void Screen::clearScreen() {
 	clearBuffer();
 	if (_vesaMode)
 		_vm->_clearSummaryFlag = true;
+
+	addDirtyRect(Common::Rect(0, 0, this->w, this->h));
 }
 
 void Screen::setDisplayScan() {
@@ -87,9 +89,15 @@ void Screen::setPanel(int num) {
 }
 
 void Screen::updateScreen() {
-	g_system->copyRectToScreen((byte *)getPixels(), this->pitch, 0, 0,
-		this->w, this->h);
+	for (uint i = 0; i < _dirtyRects.size(); ++i) {
+		const Common::Rect &r = _dirtyRects[i];
+		const byte *srcP = (const byte *)getBasePtr(r.left, r.top);
+		g_system->copyRectToScreen(srcP, this->pitch, r.left, r.top,
+			r.width(), r.height());
+	}
+
 	g_system->updateScreen();
+	_dirtyRects.clear();
 }
 
 void Screen::setInitialPalettte() {
@@ -239,6 +247,12 @@ void Screen::copyBlock(ASurface *src, const Common::Rect &bounds) {
 	destBounds.translate(_windowXAdd, _windowYAdd + _screenYOff);
 
 	copyRectToSurface(*src, destBounds.left, destBounds.top, bounds);
+	addDirtyRect(destBounds);
+}
+
+void Screen::restoreBlock() {
+	ASurface::restoreBlock();
+	addDirtyRect(_savedBounds);
 }
 
 void Screen::setPaletteCycle(int startCycle, int endCycle, int timer) {
@@ -276,4 +290,8 @@ void Screen::cyclePaletteBackwards() {
 	}
 }
 
+void Screen::addDirtyRect(const Common::Rect &r) {
+	_dirtyRects.push_back(r);
+}
+
 } // End of namespace Access
diff --git a/engines/access/screen.h b/engines/access/screen.h
index 8875ce1..93da5aa 100644
--- a/engines/access/screen.h
+++ b/engines/access/screen.h
@@ -63,6 +63,7 @@ private:
 	int _startCycle;
 	int _cycleStart;
 	int _endCycle;
+	Common::Array<Common::Rect> _dirtyRects;
 
 	void updatePalette();
 public:
@@ -83,6 +84,8 @@ public:
 	bool _screenChangeFlag;
 public:
 	virtual void copyBlock(ASurface *src, const Common::Rect &bounds);
+
+	virtual void restoreBlock();
 public:
 	Screen(AccessEngine *vm);
 
@@ -157,6 +160,8 @@ public:
 	void cyclePaletteForward();
 
 	void cyclePaletteBackwards();
+
+	void addDirtyRect(const Common::Rect &r);
 };
 
 } // End of namespace Access


Commit: 9314daa11cb2eb8d4c4ecbe1c00fc044ba271f3d
    https://github.com/scummvm/scummvm/commit/9314daa11cb2eb8d4c4ecbe1c00fc044ba271f3d
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-13T22:06:58-05:00

Commit Message:
ACCESS: Dirty rect handling for bubble boxes

Changed paths:
    engines/access/asurface.h
    engines/access/inventory.cpp
    engines/access/screen.cpp
    engines/access/screen.h



diff --git a/engines/access/asurface.h b/engines/access/asurface.h
index 0ce08bb..ffa22d5 100644
--- a/engines/access/asurface.h
+++ b/engines/access/asurface.h
@@ -95,6 +95,8 @@ public:
 
 	virtual void restoreBlock();
 
+	virtual void drawRect();
+
 	void copyTo(ASurface *dest, const Common::Point &destPos);
 
 	void copyTo(ASurface *dest, const Common::Rect &bounds);
@@ -103,8 +105,6 @@ public:
 
 	void saveBlock(const Common::Rect &bounds);
 
-	void drawRect();
-
 	void moveBufferLeft();
 
 	void moveBufferRight();
diff --git a/engines/access/inventory.cpp b/engines/access/inventory.cpp
index acba604..20c9976 100644
--- a/engines/access/inventory.cpp
+++ b/engines/access/inventory.cpp
@@ -171,7 +171,7 @@ int InventoryManager::newDisplayInv() {
 	// The original was testing the vesa mode too.
 	// We removed this check as we don't use pre-rendering
 	if (!_invRefreshFlag) {
-		screen.clearBuffer();
+		screen.clearScreen();
 		screen.setPalette();
 	}
 
diff --git a/engines/access/screen.cpp b/engines/access/screen.cpp
index 9ccad28..98dbdb4 100644
--- a/engines/access/screen.cpp
+++ b/engines/access/screen.cpp
@@ -251,8 +251,13 @@ void Screen::copyBlock(ASurface *src, const Common::Rect &bounds) {
 }
 
 void Screen::restoreBlock() {
-	ASurface::restoreBlock();
 	addDirtyRect(_savedBounds);
+	ASurface::restoreBlock();
+}
+
+void Screen::drawRect() {
+	addDirtyRect(Common::Rect(_orgX1, _orgY1, _orgX2, _orgY2));
+	ASurface::drawRect();
 }
 
 void Screen::setPaletteCycle(int startCycle, int endCycle, int timer) {
@@ -292,6 +297,7 @@ void Screen::cyclePaletteBackwards() {
 
 void Screen::addDirtyRect(const Common::Rect &r) {
 	_dirtyRects.push_back(r);
+	assert(r.isValidRect() && r.width() > 0 && r.height() > 0);
 }
 
 } // End of namespace Access
diff --git a/engines/access/screen.h b/engines/access/screen.h
index 93da5aa..c43a03c 100644
--- a/engines/access/screen.h
+++ b/engines/access/screen.h
@@ -86,6 +86,8 @@ public:
 	virtual void copyBlock(ASurface *src, const Common::Rect &bounds);
 
 	virtual void restoreBlock();
+
+	virtual void drawRect();
 public:
 	Screen(AccessEngine *vm);
 


Commit: 310853a285d5d648f1695cc3a40a165223b2928a
    https://github.com/scummvm/scummvm/commit/310853a285d5d648f1695cc3a40a165223b2928a
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-13T22:33:23-05:00

Commit Message:
ACCESS: Add dirty rects when plotting images to the screen

Changed paths:
    engines/access/amazon/amazon_logic.cpp
    engines/access/amazon/amazon_scripts.cpp
    engines/access/asurface.cpp
    engines/access/asurface.h
    engines/access/screen.cpp
    engines/access/screen.h



diff --git a/engines/access/amazon/amazon_logic.cpp b/engines/access/amazon/amazon_logic.cpp
index e8e27fc..42f9a24 100644
--- a/engines/access/amazon/amazon_logic.cpp
+++ b/engines/access/amazon/amazon_logic.cpp
@@ -356,7 +356,7 @@ void Opening::doTitle() {
 			int id = COUNTDOWN[_pCount * 2];
 			int xp = COUNTDOWN[_pCount * 2 + 1];
 			_vm->_buffer2.plotImage(_vm->_objectsTable[0], id, Common::Point(xp, 71));
-			screen.copyFrom(_vm->_buffer2);
+			_vm->_buffer2.copyTo(_vm->_screen);
 
 			_vm->_sound->playSound(1);
 			_vm->_events->_vbCount = 70;
diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp
index ce9a3d5..6f9d9c9 100644
--- a/engines/access/amazon/amazon_scripts.cpp
+++ b/engines/access/amazon/amazon_scripts.cpp
@@ -71,8 +71,8 @@ void AmazonScripts::mWhile1() {
 		_sequence = 2100;
 	} while (_vm->_flags[52] == 1);
 
-	_vm->_screen->copyFrom(_vm->_buffer1);
-	_vm->_buffer1.copyFrom(_vm->_buffer2);
+	_vm->_buffer1.copyTo(_vm->_screen);
+	_vm->_buffer2.copyTo(&_vm->_buffer1);
 
 	_game->establish(-1, 14);
 
@@ -446,7 +446,7 @@ void AmazonScripts::cmdHelp() {
 				_vm->_screen->clearBuffer();
 			}
 
-			_vm->_screen->copyFrom(_vm->_buffer2);
+			_vm->_buffer2.copyTo(_vm->_screen);
 			_vm->_screen->restorePalette();
 			_vm->_screen->setPalette();
 			_vm->_events->showCursor();
diff --git a/engines/access/asurface.cpp b/engines/access/asurface.cpp
index cd872e0..9725a5f 100644
--- a/engines/access/asurface.cpp
+++ b/engines/access/asurface.cpp
@@ -203,13 +203,13 @@ void ASurface::plotImage(SpriteResource *sprite, int frameNum, const Common::Poi
 	}
 }
 
-void ASurface::copyTo(ASurface *dest, const Common::Point &destPos) {
-	if (dest->getPixels() == nullptr)
-		dest->create(w, h);
+void ASurface::copyFrom(ASurface *src, const Common::Point &destPos) {
+	if (getPixels() == nullptr)
+		create(w, h);
 
-	for (int yp = 0; yp < h; ++yp) {
-		byte *srcP = (byte *)getBasePtr(0, yp);
-		byte *destP = (byte *)dest->getBasePtr(destPos.x, destPos.y + yp);
+	for (int yp = 0; yp < src->h; ++yp) {
+		const byte *srcP = (const byte *)src->getBasePtr(0, yp);
+		byte *destP = (byte *)getBasePtr(destPos.x, destPos.y + yp);
 
 		for (int xp = 0; xp < this->w; ++xp, ++srcP, ++destP) {
 			if (*srcP != 0)
@@ -218,13 +218,13 @@ void ASurface::copyTo(ASurface *dest, const Common::Point &destPos) {
 	}
 }
 
-void ASurface::copyTo(ASurface *dest, const Common::Rect &bounds) {
+void ASurface::copyFrom(ASurface *src, const Common::Rect &bounds) {
 	const int SCALE_LIMIT = 0x100;
-	int scaleX = SCALE_LIMIT * bounds.width() / this->w;
-	int scaleY = SCALE_LIMIT * bounds.height() / this->h;
+	int scaleX = SCALE_LIMIT * bounds.width() / src->w;
+	int scaleY = SCALE_LIMIT * bounds.height() / src->h;
 	int scaleXCtr = 0, scaleYCtr = 0;
 
-	for (int yCtr = 0, destY = bounds.top; yCtr < this->h; ++yCtr) {
+	for (int yCtr = 0, destY = bounds.top; yCtr < src->h; ++yCtr) {
 		// Handle skipping lines if Y scaling
 		scaleYCtr += scaleY;
 		if (scaleYCtr < SCALE_LIMIT)
@@ -232,17 +232,17 @@ void ASurface::copyTo(ASurface *dest, const Common::Rect &bounds) {
 		scaleYCtr -= SCALE_LIMIT;
 
 		// Handle off-screen lines
-		if (destY >= dest->h)
+		if (destY >= this->h)
 			break;
 
 		if (destY >= 0) {
 			// Handle drawing the line
-			byte *pSrc = (byte *)getBasePtr(0, yCtr);
-			byte *pDest = (byte *)dest->getBasePtr(bounds.left, destY);
+			const byte *pSrc = (const byte *)src->getBasePtr(0, yCtr);
+			byte *pDest = (byte *)getBasePtr(bounds.left, destY);
 			scaleXCtr = 0;
 			int x = bounds.left;
 
-			for (int xCtr = 0; xCtr < this->w; ++xCtr, ++pSrc) {
+			for (int xCtr = 0; xCtr < src->w; ++xCtr, ++pSrc) {
 				// Handle horizontal scaling
 				scaleXCtr += scaleX;
 				if (scaleXCtr < SCALE_LIMIT)
@@ -250,7 +250,7 @@ void ASurface::copyTo(ASurface *dest, const Common::Rect &bounds) {
 				scaleXCtr -= SCALE_LIMIT;
 
 				// Only handle on-screen pixels
-				if (x >= dest->w)
+				if (x >= this->w)
 					break;
 				if (x >= 0 && *pSrc != 0)
 					*pDest = *pSrc;
@@ -264,8 +264,12 @@ void ASurface::copyTo(ASurface *dest, const Common::Rect &bounds) {
 	}
 }
 
-void ASurface::copyTo(ASurface *dest) {
-	copyTo(dest, Common::Point());
+void ASurface::copyFrom(ASurface &src) {
+	copyFrom(&src, Common::Point());
+}
+
+void ASurface::copyBuffer(Graphics::Surface *src) {
+	Graphics::Surface::copyFrom(*src);
 }
 
 void ASurface::plotF(SpriteFrame *frame, const Common::Point &pt) {
@@ -277,13 +281,14 @@ void ASurface::plotB(SpriteFrame *frame, const Common::Point &pt) {
 }
 
 void ASurface::sPlotF(SpriteFrame *frame, const Common::Rect &bounds) {
-	frame->copyTo(this, bounds);
+	copyFrom(frame, bounds);
 }
 
 void ASurface::sPlotB(SpriteFrame *frame, const Common::Rect &bounds) {
 	ASurface flippedFrame;
 	frame->flipHorizontal(flippedFrame);
-	flippedFrame.copyTo(this, bounds);
+
+	copyFrom(&flippedFrame, bounds);
 }
 
 void ASurface::copyBlock(ASurface *src, const Common::Rect &bounds) {
diff --git a/engines/access/asurface.h b/engines/access/asurface.h
index ffa22d5..36fd251 100644
--- a/engines/access/asurface.h
+++ b/engines/access/asurface.h
@@ -65,8 +65,6 @@ public:
 
 	void clearBuffer();
 
-	void copyBuffer(Graphics::Surface *src) { copyFrom(*src); }
-
 	bool clip(Common::Rect &r);
 
 	void plotImage(SpriteResource *sprite, int frameNum, const Common::Point &pt);
@@ -97,11 +95,15 @@ public:
 
 	virtual void drawRect();
 
-	void copyTo(ASurface *dest, const Common::Point &destPos);
+	virtual void copyFrom(ASurface *src, const Common::Point &destPos);
+
+	virtual void copyFrom(ASurface *src, const Common::Rect &bounds);
+
+	virtual void copyFrom(ASurface &src);
 
-	void copyTo(ASurface *dest, const Common::Rect &bounds);
+	void copyTo(ASurface *dest) { dest->copyFrom(*this); }
 
-	void copyTo(ASurface *dest);
+	virtual void copyBuffer(Graphics::Surface *src);
 
 	void saveBlock(const Common::Rect &bounds);
 
diff --git a/engines/access/screen.cpp b/engines/access/screen.cpp
index 98dbdb4..14ead2e 100644
--- a/engines/access/screen.cpp
+++ b/engines/access/screen.cpp
@@ -260,6 +260,21 @@ void Screen::drawRect() {
 	ASurface::drawRect();
 }
 
+void Screen::copyFrom(ASurface *src, const Common::Point &destPos) {
+	addDirtyRect(Common::Rect(destPos.x, destPos.y, destPos.x + src->w, destPos.y + src->h));
+	ASurface::copyFrom(src, destPos);
+}
+
+void Screen::copyFrom(ASurface *src, const Common::Rect &bounds) {
+	addDirtyRect(bounds);
+	ASurface::copyFrom(src, bounds);
+}
+
+void Screen::copyBuffer(Graphics::Surface *src) {
+	addDirtyRect(Common::Rect(0, 0, src->w, src->h));
+	ASurface::copyBuffer(src);
+}
+
 void Screen::setPaletteCycle(int startCycle, int endCycle, int timer) {
 	_startCycle = _cycleStart = startCycle;
 	_endCycle = endCycle;
diff --git a/engines/access/screen.h b/engines/access/screen.h
index c43a03c..1d93efb 100644
--- a/engines/access/screen.h
+++ b/engines/access/screen.h
@@ -88,6 +88,12 @@ public:
 	virtual void restoreBlock();
 
 	virtual void drawRect();
+
+	virtual void copyFrom(ASurface *src, const Common::Point &destPos);
+
+	virtual void copyFrom(ASurface *src, const Common::Rect &bounds);
+
+	virtual void copyBuffer(Graphics::Surface *src);
 public:
 	Screen(AccessEngine *vm);
 


Commit: 2cdd05306c4c4c405a7405f1d0e5d491ec886c1d
    https://github.com/scummvm/scummvm/commit/2cdd05306c4c4c405a7405f1d0e5d491ec886c1d
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-14T10:17:47-05:00

Commit Message:
ACCESS: Dirty rect handling for conversation videos

Changed paths:
    engines/access/screen.cpp
    engines/access/video.cpp
    engines/access/video.h



diff --git a/engines/access/screen.cpp b/engines/access/screen.cpp
index 14ead2e..2276fcc 100644
--- a/engines/access/screen.cpp
+++ b/engines/access/screen.cpp
@@ -251,7 +251,8 @@ void Screen::copyBlock(ASurface *src, const Common::Rect &bounds) {
 }
 
 void Screen::restoreBlock() {
-	addDirtyRect(_savedBounds);
+	if (!_savedBounds.isEmpty())
+		addDirtyRect(_savedBounds);
 	ASurface::restoreBlock();
 }
 
diff --git a/engines/access/video.cpp b/engines/access/video.cpp
index abe833c..eb50083 100644
--- a/engines/access/video.cpp
+++ b/engines/access/video.cpp
@@ -60,6 +60,7 @@ void VideoPlayer::setVideo(ASurface *vidSurface, const Common::Point &pt, const
 	_xCount = _header._width;
 	_scanCount = _header._height;
 	_videoFrame = 0;
+	_videoBounds = Common::Rect(pt.x, pt.y, pt.x + _header._width, pt.y + _header._height);
 
 	getFrame();
 
@@ -133,6 +134,10 @@ void VideoPlayer::playVideo() {
 		}
 	}
 
+	// If the video is playing on the screen surface, add a dirty rect
+	if (_vidSurface == _vm->_screen)
+		_vm->_screen->addDirtyRect(_videoBounds);
+
 	getFrame();
 	if (++_videoFrame == _frameCount) {
 		closeVideo();
@@ -142,14 +147,16 @@ void VideoPlayer::playVideo() {
 
 void VideoPlayer::copyVideo() {
 	_vm->_player->calcPlayer();
+
+	// Figure out the dirty rect area for the video frame
 	Common::Rect r = Common::Rect(_vm->_vidX - _vm->_screen->_bufferStart.x,
 		_vm->_vidY - _vm->_screen->_bufferStart.y,
 		_vm->_vidX - _vm->_screen->_bufferStart.x + _header._width,
 		_vm->_vidY - _vm->_screen->_bufferStart.y + _header._height);
 	if (!_vm->_screen->clip(r))
 		return;
-
 	_vm->_newRects.push_back(r);
+
 	int vh = _header._height;
 	int vw = _header._width;
 	int destIdx = _vm->_vidX - _vm->_screen->_bufferStart.x;
@@ -165,4 +172,5 @@ void VideoPlayer::copyVideo() {
 		destP += _vm->_buffer2.pitch;
 	}
 }
+
 } // End of namespace Access
diff --git a/engines/access/video.h b/engines/access/video.h
index f4be76d..65d6ad6 100644
--- a/engines/access/video.h
+++ b/engines/access/video.h
@@ -48,6 +48,7 @@ private:
 	int _xCount;
 	int _scanCount;
 	int _frameSize;
+	Common::Rect _videoBounds;
 
 	void getFrame();
 public:


Commit: 93979484f6932759ea5075d68ac75fa479848080
    https://github.com/scummvm/scummvm/commit/93979484f6932759ea5075d68ac75fa479848080
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-14T11:56:42-05:00

Commit Message:
ACCESS: Fix for background redraws during conversations

Changed paths:
    engines/access/asurface.cpp
    engines/access/asurface.h
    engines/access/screen.cpp
    engines/access/screen.h



diff --git a/engines/access/asurface.cpp b/engines/access/asurface.cpp
index 9725a5f..ef8e079 100644
--- a/engines/access/asurface.cpp
+++ b/engines/access/asurface.cpp
@@ -203,7 +203,7 @@ void ASurface::plotImage(SpriteResource *sprite, int frameNum, const Common::Poi
 	}
 }
 
-void ASurface::copyFrom(ASurface *src, const Common::Point &destPos) {
+void ASurface::transCopyFrom(ASurface *src, const Common::Point &destPos) {
 	if (getPixels() == nullptr)
 		create(w, h);
 
@@ -218,7 +218,7 @@ void ASurface::copyFrom(ASurface *src, const Common::Point &destPos) {
 	}
 }
 
-void ASurface::copyFrom(ASurface *src, const Common::Rect &bounds) {
+void ASurface::transCopyFrom(ASurface *src, const Common::Rect &bounds) {
 	const int SCALE_LIMIT = 0x100;
 	int scaleX = SCALE_LIMIT * bounds.width() / src->w;
 	int scaleY = SCALE_LIMIT * bounds.height() / src->h;
@@ -264,12 +264,12 @@ void ASurface::copyFrom(ASurface *src, const Common::Rect &bounds) {
 	}
 }
 
-void ASurface::copyFrom(ASurface &src) {
-	copyFrom(&src, Common::Point());
+void ASurface::transCopyFrom(ASurface &src) {
+	copyFrom(src);
 }
 
 void ASurface::copyBuffer(Graphics::Surface *src) {
-	Graphics::Surface::copyFrom(*src);
+	copyFrom(*src);
 }
 
 void ASurface::plotF(SpriteFrame *frame, const Common::Point &pt) {
@@ -281,14 +281,14 @@ void ASurface::plotB(SpriteFrame *frame, const Common::Point &pt) {
 }
 
 void ASurface::sPlotF(SpriteFrame *frame, const Common::Rect &bounds) {
-	copyFrom(frame, bounds);
+	transCopyFrom(frame, bounds);
 }
 
 void ASurface::sPlotB(SpriteFrame *frame, const Common::Rect &bounds) {
 	ASurface flippedFrame;
 	frame->flipHorizontal(flippedFrame);
 
-	copyFrom(&flippedFrame, bounds);
+	transCopyFrom(&flippedFrame, bounds);
 }
 
 void ASurface::copyBlock(ASurface *src, const Common::Rect &bounds) {
diff --git a/engines/access/asurface.h b/engines/access/asurface.h
index 36fd251..c04b33c 100644
--- a/engines/access/asurface.h
+++ b/engines/access/asurface.h
@@ -95,16 +95,16 @@ public:
 
 	virtual void drawRect();
 
-	virtual void copyFrom(ASurface *src, const Common::Point &destPos);
+	virtual void transCopyFrom(ASurface *src, const Common::Point &destPos);
 
-	virtual void copyFrom(ASurface *src, const Common::Rect &bounds);
+	virtual void transCopyFrom(ASurface *src, const Common::Rect &bounds);
 
-	virtual void copyFrom(ASurface &src);
-
-	void copyTo(ASurface *dest) { dest->copyFrom(*this); }
+	virtual void transCopyFrom(ASurface &src);
 
 	virtual void copyBuffer(Graphics::Surface *src);
 
+	void copyTo(ASurface *dest) { dest->copyFrom(*this); }
+
 	void saveBlock(const Common::Rect &bounds);
 
 	void moveBufferLeft();
diff --git a/engines/access/screen.cpp b/engines/access/screen.cpp
index 2276fcc..5897fbe 100644
--- a/engines/access/screen.cpp
+++ b/engines/access/screen.cpp
@@ -261,14 +261,14 @@ void Screen::drawRect() {
 	ASurface::drawRect();
 }
 
-void Screen::copyFrom(ASurface *src, const Common::Point &destPos) {
+void Screen::transCopyFrom(ASurface *src, const Common::Point &destPos) {
 	addDirtyRect(Common::Rect(destPos.x, destPos.y, destPos.x + src->w, destPos.y + src->h));
-	ASurface::copyFrom(src, destPos);
+	ASurface::transCopyFrom(src, destPos);
 }
 
-void Screen::copyFrom(ASurface *src, const Common::Rect &bounds) {
+void Screen::transCopyFrom(ASurface *src, const Common::Rect &bounds) {
 	addDirtyRect(bounds);
-	ASurface::copyFrom(src, bounds);
+	ASurface::transCopyFrom(src, bounds);
 }
 
 void Screen::copyBuffer(Graphics::Surface *src) {
diff --git a/engines/access/screen.h b/engines/access/screen.h
index 1d93efb..f790dd7 100644
--- a/engines/access/screen.h
+++ b/engines/access/screen.h
@@ -89,9 +89,9 @@ public:
 
 	virtual void drawRect();
 
-	virtual void copyFrom(ASurface *src, const Common::Point &destPos);
+	virtual void transCopyFrom(ASurface *src, const Common::Point &destPos);
 
-	virtual void copyFrom(ASurface *src, const Common::Rect &bounds);
+	virtual void transCopyFrom(ASurface *src, const Common::Rect &bounds);
 
 	virtual void copyBuffer(Graphics::Surface *src);
 public:


Commit: 924f2abdf40a97966fff991d7cb0db842212a567
    https://github.com/scummvm/scummvm/commit/924f2abdf40a97966fff991d7cb0db842212a567
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-14T14:45:06-05:00

Commit Message:
ACCESS: Dirty rect handling for intro screens

Changed paths:
    engines/access/asurface.cpp
    engines/access/asurface.h
    engines/access/files.cpp
    engines/access/screen.cpp
    engines/access/screen.h



diff --git a/engines/access/asurface.cpp b/engines/access/asurface.cpp
index ef8e079..e135ae7 100644
--- a/engines/access/asurface.cpp
+++ b/engines/access/asurface.cpp
@@ -268,6 +268,10 @@ void ASurface::transCopyFrom(ASurface &src) {
 	copyFrom(src);
 }
 
+void ASurface::copyFrom(Graphics::Surface &src) {
+	Graphics::Surface::copyFrom(src);
+}
+
 void ASurface::copyBuffer(Graphics::Surface *src) {
 	copyFrom(*src);
 }
diff --git a/engines/access/asurface.h b/engines/access/asurface.h
index c04b33c..db17eb2 100644
--- a/engines/access/asurface.h
+++ b/engines/access/asurface.h
@@ -101,6 +101,8 @@ public:
 
 	virtual void transCopyFrom(ASurface &src);
 
+	virtual void copyFrom(Graphics::Surface &src);
+
 	virtual void copyBuffer(Graphics::Surface *src);
 
 	void copyTo(ASurface *dest) { dest->copyFrom(*this); }
diff --git a/engines/access/files.cpp b/engines/access/files.cpp
index b846cbd..004886a 100644
--- a/engines/access/files.cpp
+++ b/engines/access/files.cpp
@@ -168,6 +168,9 @@ void FileManager::handleScreen(Graphics::Surface *dest, Resource *res) {
 			res->_stream->read(pDest, dest->w);
 		}
 	}
+
+	if (dest == _vm->_screen)
+		_vm->_screen->addDirtyRect(Common::Rect(0, 0, dest->w, dest->h));
 }
 
 void FileManager::loadScreen(int fileNum, int subfile) {
diff --git a/engines/access/screen.cpp b/engines/access/screen.cpp
index 5897fbe..34755ad 100644
--- a/engines/access/screen.cpp
+++ b/engines/access/screen.cpp
@@ -271,6 +271,11 @@ void Screen::transCopyFrom(ASurface *src, const Common::Rect &bounds) {
 	ASurface::transCopyFrom(src, bounds);
 }
 
+void Screen::copyFrom(Graphics::Surface &src) {
+	addDirtyRect(Common::Rect(0, 0, src.w, src.h));
+	ASurface::copyFrom(src);
+}
+
 void Screen::copyBuffer(Graphics::Surface *src) {
 	addDirtyRect(Common::Rect(0, 0, src->w, src->h));
 	ASurface::copyBuffer(src);
diff --git a/engines/access/screen.h b/engines/access/screen.h
index f790dd7..56ee9be 100644
--- a/engines/access/screen.h
+++ b/engines/access/screen.h
@@ -93,6 +93,8 @@ public:
 
 	virtual void transCopyFrom(ASurface *src, const Common::Rect &bounds);
 
+	virtual void copyFrom(Graphics::Surface &src);
+
 	virtual void copyBuffer(Graphics::Surface *src);
 public:
 	Screen(AccessEngine *vm);


Commit: fda4ef620f3eefc76d7362945d514e6c46187073
    https://github.com/scummvm/scummvm/commit/fda4ef620f3eefc76d7362945d514e6c46187073
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-14T15:22:09-05:00

Commit Message:
ACCESS: Add dirty rect handling for font display

Changed paths:
    engines/access/asurface.h
    engines/access/font.cpp
    engines/access/screen.h



diff --git a/engines/access/asurface.h b/engines/access/asurface.h
index db17eb2..1395651 100644
--- a/engines/access/asurface.h
+++ b/engines/access/asurface.h
@@ -105,6 +105,8 @@ public:
 
 	virtual void copyBuffer(Graphics::Surface *src);
 
+	virtual void addDirtyRect(const Common::Rect &r) {}
+
 	void copyTo(ASurface *dest) { dest->copyFrom(*this); }
 
 	void saveBlock(const Common::Rect &bounds);
diff --git a/engines/access/font.cpp b/engines/access/font.cpp
index 51fb9dc..1aadfb6 100644
--- a/engines/access/font.cpp
+++ b/engines/access/font.cpp
@@ -150,6 +150,8 @@ void Font::drawString(ASurface *s, const Common::String &msg, const Common::Poin
 int Font::drawChar(ASurface *s, char c, Common::Point &pt) {
 	Graphics::Surface &ch = _chars[c - ' '];
 
+	s->addDirtyRect(Common::Rect(pt.x, pt.y, pt.x + ch.w, pt.y + ch.h));
+
 	// Loop through the lines of the character
 	for (int y = 0; y < ch.h; ++y) {
 		byte *pSrc = (byte *)ch.getBasePtr(0, y);
diff --git a/engines/access/screen.h b/engines/access/screen.h
index 56ee9be..7134aff 100644
--- a/engines/access/screen.h
+++ b/engines/access/screen.h
@@ -96,6 +96,8 @@ public:
 	virtual void copyFrom(Graphics::Surface &src);
 
 	virtual void copyBuffer(Graphics::Surface *src);
+
+	virtual void addDirtyRect(const Common::Rect &r);
 public:
 	Screen(AccessEngine *vm);
 
@@ -170,8 +172,6 @@ public:
 	void cyclePaletteForward();
 
 	void cyclePaletteBackwards();
-
-	void addDirtyRect(const Common::Rect &r);
 };
 
 } // End of namespace Access


Commit: 831a3f7f3591182ab0e7b8812e98c12282923909
    https://github.com/scummvm/scummvm/commit/831a3f7f3591182ab0e7b8812e98c12282923909
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-14T15:39:37-05:00

Commit Message:
ACCESS: Implement dirty rect merging

Changed paths:
    engines/access/screen.cpp
    engines/access/screen.h



diff --git a/engines/access/screen.cpp b/engines/access/screen.cpp
index 34755ad..3e6bd7e 100644
--- a/engines/access/screen.cpp
+++ b/engines/access/screen.cpp
@@ -89,13 +89,19 @@ void Screen::setPanel(int num) {
 }
 
 void Screen::updateScreen() {
-	for (uint i = 0; i < _dirtyRects.size(); ++i) {
-		const Common::Rect &r = _dirtyRects[i];
+	// Merge the dirty rects
+	mergeDirtyRects();
+
+	// Loop through copying dirty areas to the physical screen
+	Common::List<Common::Rect>::iterator i;
+	for (i = _dirtyRects.begin(); i != _dirtyRects.end(); ++i) {
+		const Common::Rect &r = *i;
 		const byte *srcP = (const byte *)getBasePtr(r.left, r.top);
 		g_system->copyRectToScreen(srcP, this->pitch, r.left, r.top,
 			r.width(), r.height());
 	}
 
+	// Signal the physical screen to update
 	g_system->updateScreen();
 	_dirtyRects.clear();
 }
@@ -321,4 +327,43 @@ void Screen::addDirtyRect(const Common::Rect &r) {
 	assert(r.isValidRect() && r.width() > 0 && r.height() > 0);
 }
 
+void Screen::mergeDirtyRects() {
+	Common::List<Common::Rect>::iterator rOuter, rInner;
+
+	// Ensure dirty rect list has at least two entries
+	rOuter = _dirtyRects.begin();
+	for (int i = 0; i < 2; ++i, ++rOuter) {
+		if (rOuter == _dirtyRects.end())
+			return;
+	}
+	
+	// Process the dirty rect list to find any rects to merge
+	for (rOuter = _dirtyRects.begin(); rOuter != _dirtyRects.end(); ++rOuter) {
+		rInner = rOuter;
+		while (++rInner != _dirtyRects.end()) {
+
+			if ((*rOuter).intersects(*rInner)) {
+				// these two rectangles overlap or
+				// are next to each other - merge them
+
+				unionRectangle(*rOuter, *rOuter, *rInner);
+
+				// remove the inner rect from the list
+				_dirtyRects.erase(rInner);
+
+				// move back to beginning of list
+				rInner = rOuter;
+			}
+		}
+	}
+}
+
+bool Screen::unionRectangle(Common::Rect &destRect, const Common::Rect &src1, const Common::Rect &src2) {
+	destRect = src1;
+	destRect.extend(src2);
+
+	return !destRect.isEmpty();
+}
+
+
 } // End of namespace Access
diff --git a/engines/access/screen.h b/engines/access/screen.h
index 7134aff..775cb6b 100644
--- a/engines/access/screen.h
+++ b/engines/access/screen.h
@@ -63,9 +63,13 @@ private:
 	int _startCycle;
 	int _cycleStart;
 	int _endCycle;
-	Common::Array<Common::Rect> _dirtyRects;
+	Common::List<Common::Rect> _dirtyRects;
 
 	void updatePalette();
+
+	void mergeDirtyRects();
+
+	bool unionRectangle(Common::Rect &destRect, const Common::Rect &src1, const Common::Rect &src2);
 public:
 	int _vesaMode;
 	int _startColor, _numColors;


Commit: 27ed5246b8780dc74235478058177abcc1d8e84d
    https://github.com/scummvm/scummvm/commit/27ed5246b8780dc74235478058177abcc1d8e84d
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-14T22:43:01+01:00

Commit Message:
ACCESS: Use the same (weird) key mapping than in the original game

Changed paths:
    engines/access/room.cpp



diff --git a/engines/access/room.cpp b/engines/access/room.cpp
index e18bd4a..b9d13c9 100644
--- a/engines/access/room.cpp
+++ b/engines/access/room.cpp
@@ -467,9 +467,10 @@ void Room::doCommands() {
 			mainAreaClick();
 		}
 	} else if (_vm->_events->getKey(keyState)) {
-		if (keyState.keycode >= Common::KEYCODE_F1 && keyState.keycode <= Common::KEYCODE_F9) {
+		if (keyState.keycode == Common::KEYCODE_F1)
 			handleCommand(keyState.keycode - Common::KEYCODE_F1 + 1);
-		}
+		else if (keyState.keycode >= Common::KEYCODE_F2 && keyState.keycode <= Common::KEYCODE_F10)
+			handleCommand(keyState.keycode - Common::KEYCODE_F1);
 	}
 }
 


Commit: dcc6ceb117549a68a275b5740edea5e5e02030bd
    https://github.com/scummvm/scummvm/commit/dcc6ceb117549a68a275b5740edea5e5e02030bd
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-14T23:22:54+01:00

Commit Message:
ACCESS: Fix icon when unselecting a menu button

Changed paths:
    engines/access/room.cpp



diff --git a/engines/access/room.cpp b/engines/access/room.cpp
index b9d13c9..a33f773 100644
--- a/engines/access/room.cpp
+++ b/engines/access/room.cpp
@@ -588,6 +588,7 @@ void Room::walkCursor() {
 
 void Room::commandOff() {
 	_selectCommand = -1;
+	_vm->_events->_normalMouse = CURSOR_CROSSHAIRS;
 	_vm->_events->setCursor(CURSOR_CROSSHAIRS);
 	roomMenu();
 }


Commit: 66bf0ec7412949eee758c138be1f81571b1fc56d
    https://github.com/scummvm/scummvm/commit/66bf0ec7412949eee758c138be1f81571b1fc56d
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-14T23:51:01+01:00

Commit Message:
ACCESS: Some refactoring concerning the mouse cursor

Changed paths:
    engines/access/amazon/amazon_game.cpp
    engines/access/amazon/amazon_room.cpp
    engines/access/events.cpp
    engines/access/events.h
    engines/access/inventory.cpp
    engines/access/martian/martian_room.cpp
    engines/access/room.cpp



diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp
index 793a601..9a86642 100644
--- a/engines/access/amazon/amazon_game.cpp
+++ b/engines/access/amazon/amazon_game.cpp
@@ -193,7 +193,7 @@ void AmazonEngine::initVariables() {
 	_player->_playerX = _player->_rawPlayer.x = TRAVEL_POS[_player->_roomNumber][0];
 	_player->_playerY = _player->_rawPlayer.y = TRAVEL_POS[_player->_roomNumber][1];
 	_room->_selectCommand = -1;
-	_events->_normalMouse = CURSOR_CROSSHAIRS;
+	_events->setNormalCursor(CURSOR_CROSSHAIRS);
 	_mouseMode = 0;
 	_numAnimTimers = 0;
 }
diff --git a/engines/access/amazon/amazon_room.cpp b/engines/access/amazon/amazon_room.cpp
index d6ab2bd..10b622c 100644
--- a/engines/access/amazon/amazon_room.cpp
+++ b/engines/access/amazon/amazon_room.cpp
@@ -87,7 +87,7 @@ void AmazonRoom::reloadRoom1() {
 	}
 
 	_selectCommand = -1;
-	_vm->_events->_normalMouse = CURSOR_CROSSHAIRS;
+	_vm->_events->setNormalCursor(CURSOR_CROSSHAIRS);
 	_vm->_mouseMode = 0;
 	_vm->_boxSelect = true;
 	_vm->_player->_playerOff = false;
@@ -210,8 +210,7 @@ void AmazonRoom::walkCursor() {
 
 	if (_vm->_events->_middleButton || (_vm->_player->_roomNumber == 29 &&
 			events._normalMouse != CURSOR_CROSSHAIRS)) {
-		events._normalMouse = CURSOR_CROSSHAIRS;
-		events.setCursor(CURSOR_CROSSHAIRS);
+		events.forceSetCursor(CURSOR_CROSSHAIRS);
 		_selectCommand = -1;
 		_vm->_boxSelect = true;
 	} else {
diff --git a/engines/access/events.cpp b/engines/access/events.cpp
index 249ba15..cd1880b 100644
--- a/engines/access/events.cpp
+++ b/engines/access/events.cpp
@@ -54,6 +54,15 @@ EventsManager::~EventsManager() {
 	_invCursor.free();
 }
 
+void EventsManager::forceSetCursor(CursorType cursorId) {
+	setNormalCursor(cursorId);
+	setCursor(cursorId);
+}
+
+void EventsManager::setNormalCursor(CursorType cursorId) {
+	_normalMouse = cursorId;
+}
+
 void EventsManager::setCursor(CursorType cursorId) {
 	if (cursorId == _cursorId)
 		return;	
diff --git a/engines/access/events.h b/engines/access/events.h
index c43bf47..fd3adf8 100644
--- a/engines/access/events.h
+++ b/engines/access/events.h
@@ -83,6 +83,16 @@ public:
 	uint32 getFrameCounter() { return _frameCounter; }
 
 	/**
+	 * Sets the cursor and reset the normal cursor
+	 */
+	void EventsManager::forceSetCursor(CursorType cursorId);
+
+	/**
+	 * Sets the normal cursor
+	 */
+	void EventsManager::setNormalCursor(CursorType cursorId);
+
+	/**
 	 * Sets the cursor
 	 */
 	void setCursor(CursorType cursorId);
diff --git a/engines/access/inventory.cpp b/engines/access/inventory.cpp
index 20c9976..49fa6e7 100644
--- a/engines/access/inventory.cpp
+++ b/engines/access/inventory.cpp
@@ -198,12 +198,9 @@ int InventoryManager::newDisplayInv() {
 	if (!_invRefreshFlag) {
 		if (_vm->_useItem == -1) {
 			result = 2;
-			events._normalMouse = CURSOR_CROSSHAIRS;
-			events.setCursor(CURSOR_CROSSHAIRS);
-		} else {
-			events.setCursor(CURSOR_INVENTORY);
-			events._normalMouse = CURSOR_INVENTORY;
-		}
+			events.forceSetCursor(CURSOR_CROSSHAIRS);
+		} else
+			events.forceSetCursor(CURSOR_INVENTORY);
 	}
 
 	_invRefreshFlag = false;
diff --git a/engines/access/martian/martian_room.cpp b/engines/access/martian/martian_room.cpp
index 2bd9818..22f456f 100644
--- a/engines/access/martian/martian_room.cpp
+++ b/engines/access/martian/martian_room.cpp
@@ -82,7 +82,7 @@ void MartianRoom::reloadRoom1() {
 	}
 
 	_selectCommand = -1;
-	_vm->_events->_normalMouse = CURSOR_CROSSHAIRS;
+	_vm->_events->setNormalCursor(CURSOR_CROSSHAIRS);
 	_vm->_mouseMode = 0;
 	_vm->_boxSelect = true;
 	_vm->_player->_playerOff = false;
diff --git a/engines/access/room.cpp b/engines/access/room.cpp
index a33f773..f482609 100644
--- a/engines/access/room.cpp
+++ b/engines/access/room.cpp
@@ -136,11 +136,11 @@ void Room::doRoom() {
 				} else {
 					_vm->plotList();
 
-					if (_vm->_events->_mousePos.y < 177) {
+					if (_vm->_events->_mousePos.y < 177)
 						_vm->_events->setCursor(_vm->_events->_normalMouse);
-					} else {
+					else
 						_vm->_events->setCursor(CURSOR_ARROW);
-					}
+
 					_vm->copyBlocks();
 				}
 			}
@@ -512,16 +512,13 @@ void Room::executeCommand(int commandId) {
 
 	switch (commandId) {
 	case 0:
-		events._normalMouse = CURSOR_LOOK;
-		events.setCursor(CURSOR_LOOK);
+		events.forceSetCursor(CURSOR_LOOK);
 		break;
 	case 2:
-		events._normalMouse = CURSOR_USE;
-		events.setCursor(CURSOR_USE);
+		events.forceSetCursor(CURSOR_USE);
 		break;
 	case 3:
-		events._normalMouse = CURSOR_TAKE;
-		events.setCursor(CURSOR_TAKE);
+		events.forceSetCursor(CURSOR_TAKE);
 		break;
 	case 4:
 		events.setCursor(CURSOR_ARROW);
@@ -531,19 +528,16 @@ void Room::executeCommand(int commandId) {
 		}
 		break;
 	case 5:
-		events._normalMouse = CURSOR_CLIMB;
-		events.setCursor(CURSOR_CLIMB);
+		events.forceSetCursor(CURSOR_CLIMB);
 		break;
 	case 6:
-		events._normalMouse = CURSOR_TALK;
-		events.setCursor(CURSOR_TALK);
+		events.forceSetCursor(CURSOR_TALK);
 		break;
 	case 7:
 		walkCursor();
 		return;
 	case 8:
-		events._normalMouse = CURSOR_HELP;
-		events.setCursor(CURSOR_HELP);
+		events.forceSetCursor(CURSOR_HELP);
 		break;
 	default:
 		break;
@@ -570,8 +564,7 @@ void Room::executeCommand(int commandId) {
 void Room::walkCursor() {
 	EventsManager &events = *_vm->_events;
 
-	events._normalMouse = CURSOR_CROSSHAIRS;
-	events.setCursor(CURSOR_CROSSHAIRS);
+	events.forceSetCursor(CURSOR_CROSSHAIRS);
 	_vm->_scripts->_sequence = 5000;
 	_vm->_scripts->searchForSequence();
 	roomMenu();
@@ -588,8 +581,7 @@ void Room::walkCursor() {
 
 void Room::commandOff() {
 	_selectCommand = -1;
-	_vm->_events->_normalMouse = CURSOR_CROSSHAIRS;
-	_vm->_events->setCursor(CURSOR_CROSSHAIRS);
+	_vm->_events->forceSetCursor(CURSOR_CROSSHAIRS);
 	roomMenu();
 }
 


Commit: 450deabd4536eb71671286e52e4b01a03a4e581a
    https://github.com/scummvm/scummvm/commit/450deabd4536eb71671286e52e4b01a03a4e581a
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-14T23:55:22+01:00

Commit Message:
ACCESS: Fix a couple of typos in comments

Changed paths:
    engines/access/amazon/amazon_room.cpp



diff --git a/engines/access/amazon/amazon_room.cpp b/engines/access/amazon/amazon_room.cpp
index 10b622c..d026f7b 100644
--- a/engines/access/amazon/amazon_room.cpp
+++ b/engines/access/amazon/amazon_room.cpp
@@ -204,8 +204,8 @@ void AmazonRoom::mainAreaClick() {
 
 void AmazonRoom::walkCursor() {
 	// WORKAROUND: For scene 29, which is a normal walkable scene, but yet can be
-	// 'exitted'. This workaround ensures the scene will only be left if you click
-	// the Exit icon wgeb the cursor is already a walk cursor
+	// 'exited'. This workaround ensures the scene will only be left if you click
+	// the Exit icon when the cursor is already a walk cursor
 	EventsManager &events = *_vm->_events;
 
 	if (_vm->_events->_middleButton || (_vm->_player->_roomNumber == 29 &&


Commit: 37aefd08f245c0a5de0c11929e06705271952f65
    https://github.com/scummvm/scummvm/commit/37aefd08f245c0a5de0c11929e06705271952f65
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-14T18:27:29-05:00

Commit Message:
ACCESS: Add enum for inventory items referred in hardcoded logic

Changed paths:
    engines/access/amazon/amazon_logic.cpp
    engines/access/amazon/amazon_resources.h



diff --git a/engines/access/amazon/amazon_logic.cpp b/engines/access/amazon/amazon_logic.cpp
index 42f9a24..ecc43f5 100644
--- a/engines/access/amazon/amazon_logic.cpp
+++ b/engines/access/amazon/amazon_logic.cpp
@@ -26,6 +26,7 @@
 #include "access/screen.h"
 #include "access/amazon/amazon_game.h"
 #include "access/amazon/amazon_logic.h"
+#include "access/amazon/amazon_resources.h"
 
 namespace Access {
 
@@ -1975,7 +1976,7 @@ void Ant::plotPit(int indx, const int *&buf) {
 	_vm->_images.addToList(ie);
 
 	_vm->_player->_rawPlayer = _pitPos;
-	if (_vm->_inventory->_inv[76]._value == ITEM_IN_INVENTORY) {
+	if (_vm->_inventory->_inv[INV_TORCH]._value == ITEM_IN_INVENTORY) {
 		// Player has torch
 		idx = _torchCel;
 		buf = Amazon::TORCH;
@@ -1986,7 +1987,7 @@ void Ant::plotPit(int indx, const int *&buf) {
 		_torchCel = idx;
 		plotTorchSpear(idx, buf);
 	}
-	else if (!_stabFl && (_vm->_inventory->_inv[78]._value == ITEM_IN_INVENTORY)) {
+	else if (!_stabFl && (_vm->_inventory->_inv[INV_KNIFE_SPEAR]._value == ITEM_IN_INVENTORY)) {
 		// Player has spear
 		idx = 0;
 		buf = Amazon::SPEAR;
@@ -2037,7 +2038,7 @@ int Ant::antHandleLeft(int indx, const int *&buf) {
 
 int Ant::antHandleStab(int indx, const int *&buf) {
 	int retval = indx;
-	if (_vm->_inventory->_inv[78]._value == ITEM_IN_INVENTORY) {
+	if (_vm->_inventory->_inv[INV_KNIFE_SPEAR]._value == ITEM_IN_INVENTORY) {
 		if (_stabFl) {
 			buf = Amazon::PITSTAB;
 			retval = _stabCel;
@@ -2114,7 +2115,7 @@ void Ant::doAnt() {
 		buf = Amazon::ANTEAT;
 	} else {
 		buf = Amazon::ANTWALK;
-		if (_vm->_inventory->_inv[76]._value == ITEM_IN_INVENTORY)
+		if (_vm->_inventory->_inv[INV_TORCH]._value == ITEM_IN_INVENTORY)
 			// Player has burning torch, which scares the Ant
 			_antDirection = ANT_LEFT;
 	}
diff --git a/engines/access/amazon/amazon_resources.h b/engines/access/amazon/amazon_resources.h
index 36ae2af..c4d2cc9 100644
--- a/engines/access/amazon/amazon_resources.h
+++ b/engines/access/amazon/amazon_resources.h
@@ -29,6 +29,10 @@ namespace Access {
 
 namespace Amazon {
 
+enum InventoryEnum {
+	INV_BAITED_POLE = 67, INV_TORCH = 76, INV_KNIFE_SPEAR = 78
+};
+
 struct RiverStruct {
 	int _id;
 	int _width;


Commit: e806c6333283ca33a52a2c3ed0f36779c7bc48d6
    https://github.com/scummvm/scummvm/commit/e806c6333283ca33a52a2c3ed0f36779c7bc48d6
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-14T18:37:31-05:00

Commit Message:
ACCESS: Formatting fixes

Changed paths:
    engines/access/amazon/amazon_logic.cpp



diff --git a/engines/access/amazon/amazon_logic.cpp b/engines/access/amazon/amazon_logic.cpp
index ecc43f5..98ab57b 100644
--- a/engines/access/amazon/amazon_logic.cpp
+++ b/engines/access/amazon/amazon_logic.cpp
@@ -983,8 +983,7 @@ void Guard::setVerticalCode() {
 	else if (_topLeft.x == screen._orgX1) {
 		_gCode1 |= 8;
 		_gCode1 |= 2;
-	}
-	else
+	} else
 		_gCode1 |= 2;
 
 	if (_bottomRight.x < screen._orgX1)
@@ -992,8 +991,7 @@ void Guard::setVerticalCode() {
 	else if (_bottomRight.x == screen._orgX1) {
 		_gCode2 |= 8;
 		_gCode2 |= 2;
-	}
-	else
+	} else
 		_gCode2 |= 2;
 
 	if (_topLeft.y < screen._orgY1)
@@ -1018,8 +1016,7 @@ void Guard::setHorizontalCode() {
 	else if (_topLeft.x == screen._orgX1) {
 		_gCode1 |= 4;
 		_gCode1 |= 1;
-	}
-	else
+	} else
 		_gCode1 |= 1;
 
 	if (_bottomRight.y < screen._orgY1)
@@ -1027,8 +1024,7 @@ void Guard::setHorizontalCode() {
 	else if (_bottomRight.x == screen._orgX1) {
 		_gCode2 |= 4;
 		_gCode2 |= 1;
-	}
-	else
+	} else
 		_gCode2 |= 1;
 
 	if (_topLeft.x < screen._orgX1)
@@ -1155,8 +1151,7 @@ void Guard::guardSee() {
 			chkVLine();
 			if (_vm->_guardFind == 0)
 				return;
-		}
-		else if (screen._orgY1 == screen._orgY2) {
+		} else if (screen._orgY1 == screen._orgY2) {
 			chkHLine();
 			if (_vm->_guardFind == 0)
 				return;
@@ -1804,8 +1799,7 @@ void River::mWhileDownRiver() {
 		if (!_vm->_timers[3]._flag) {
 			++_vm->_timers[3]._flag;
 			_vm->_sound->playSound(1);
-		}
-		else if (!_vm->_timers[4]._flag) {
+		} else if (!_vm->_timers[4]._flag) {
 			++_vm->_timers[4]._flag;
 			_vm->_sound->playSound(0);
 		}
@@ -1986,8 +1980,7 @@ void Ant::plotPit(int indx, const int *&buf) {
 			idx = 0;
 		_torchCel = idx;
 		plotTorchSpear(idx, buf);
-	}
-	else if (!_stabFl && (_vm->_inventory->_inv[INV_KNIFE_SPEAR]._value == ITEM_IN_INVENTORY)) {
+	} else if (!_stabFl && (_vm->_inventory->_inv[INV_KNIFE_SPEAR]._value == ITEM_IN_INVENTORY)) {
 		// Player has spear
 		idx = 0;
 		buf = Amazon::SPEAR;


Commit: 0e4a4a28ad57e7b9698baff4b42b398d345e8a24
    https://github.com/scummvm/scummvm/commit/0e4a4a28ad57e7b9698baff4b42b398d345e8a24
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-14T21:33:14-05:00

Commit Message:
ACCESS: Fix distortion occurring at left edge of jungle scrolling in introduction

Changed paths:
    engines/access/amazon/amazon_logic.cpp



diff --git a/engines/access/amazon/amazon_logic.cpp b/engines/access/amazon/amazon_logic.cpp
index 98ab57b..eb7d8b5 100644
--- a/engines/access/amazon/amazon_logic.cpp
+++ b/engines/access/amazon/amazon_logic.cpp
@@ -405,6 +405,8 @@ void Opening::doTitle() {
 		_vm->_midi->setLoop(false);
 		_vm->_events->zeroKeys();
 	}
+
+	_vm->_buffer1.create(_vm->_screen->w + TILE_WIDTH, _vm->_screen->h);
 	_vm->_room->loadRoom(0);
 	screen.clearScreen();
 	screen.setBufferScan();


Commit: 8120cbfde316ce344d11bcdfac18222414965d8a
    https://github.com/scummvm/scummvm/commit/8120cbfde316ce344d11bcdfac18222414965d8a
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-15T19:48:02+01:00

Commit Message:
ACCESS: Remove extra qualification stupidly accepted by MSVC

Changed paths:
    engines/access/events.h



diff --git a/engines/access/events.h b/engines/access/events.h
index fd3adf8..3fdcf12 100644
--- a/engines/access/events.h
+++ b/engines/access/events.h
@@ -85,12 +85,12 @@ public:
 	/**
 	 * Sets the cursor and reset the normal cursor
 	 */
-	void EventsManager::forceSetCursor(CursorType cursorId);
+	void forceSetCursor(CursorType cursorId);
 
 	/**
 	 * Sets the normal cursor
 	 */
-	void EventsManager::setNormalCursor(CursorType cursorId);
+	void setNormalCursor(CursorType cursorId);
 
 	/**
 	 * Sets the cursor


Commit: 64435ef25fb52a9113b6c73619c80bc072372950
    https://github.com/scummvm/scummvm/commit/64435ef25fb52a9113b6c73619c80bc072372950
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-16T19:40:27+01:00

Commit Message:
ACCESS: Fix cmdFreeSound, which fixes the sound played during the death animation

Changed paths:
    engines/access/scripts.cpp



diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp
index d8f9a51..b1cc289 100644
--- a/engines/access/scripts.cpp
+++ b/engines/access/scripts.cpp
@@ -792,9 +792,11 @@ void Scripts::cmdFreeSound() {
 			_vm->_events->pollEvents();
 		} while (!_vm->shouldQuit() && sound._playingSound);
 
-		// Free the sound
-		delete sound._soundTable[0]._res;
-		sound._soundTable.remove_at(0);
+		// Free the sounds
+		while (sound._soundTable.size() > 0) {
+			delete sound._soundTable[0]._res;
+			sound._soundTable.remove_at(0);
+		}
 	}
 }
 


Commit: c3312749ff20c76a527edcc0a30291cf6033c694
    https://github.com/scummvm/scummvm/commit/c3312749ff20c76a527edcc0a30291cf6033c694
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-16T22:41:27+01:00

Commit Message:
ACCESS: Fix crash when getting randomly shot in the cabin

Changed paths:
    engines/access/amazon/amazon_resources.cpp



diff --git a/engines/access/amazon/amazon_resources.cpp b/engines/access/amazon/amazon_resources.cpp
index 694454c..989dcf1 100644
--- a/engines/access/amazon/amazon_resources.cpp
+++ b/engines/access/amazon/amazon_resources.cpp
@@ -1771,7 +1771,7 @@ const char *const DEATH_TEXT_DEMO[34] = {
 	"SAM SALVADOR NOTICES SOMEONE HAS BEEN PLAYING WITH THE CARGO. HE TRACKS YOU DOWN AND LETS YOU HAVE IT.",
 	"THE GUARD COMES AROUND THE CORNER.  HE DECIDES THAT THREE LEAD SLUGS WILL TEACH YOU TO BE MORE POLITE.",
 	"THE CAPTAIN IS WAITING OUTSIDE THE DOOR.",
-	"THE CAPTAIN',27h,'S RANDOM SHOOTING FINALLY FINDS ITS TARGET.",
+	"THE CAPTAIN'S RANDOM SHOOTING FINALLY FINDS ITS TARGET.",
 	"THE CRATE OUTSIDE THE WINDOW EXPLODES, DESTROYING THE SHIP.  UNFORTUNATELY, YOU'RE STILL ABOARD.",
 	"THE DOOR WAS NOT BARRED AND THE CAPTAIN WALKS RIGHT IN AND PARTS YOUR HAIR.",
 	"",
@@ -1796,7 +1796,7 @@ const char *const DEATH_TEXT_DEMO[34] = {
 	"YOU DO NOT GET FAR ENOUGH AWAY BEFORE THE DYNAMITE EXPLODES AND YOU ARE BLOWN INTO A THOUSAND PIECES.",
 	"STANDING OUT IN THE OPEN YOU ARE EXPOSED TO THE HAIL OF BULLETS FROM SANCHEZ' MEN.",
 	"THE AMAZON SENTINELS SPOT YOU AND FILL YOU FULL OF ARROWS.",
-	"SAM MAY BE UGLY, BUT HE',27h,'S NOT DEAF.  HE HEARS ALL THE NOISE YOU ARE MAKING AND CANCELS YOUR BOARDING PASS.",
+	"SAM MAY BE UGLY, BUT HE'S NOT DEAF.  HE HEARS ALL THE NOISE YOU ARE MAKING AND CANCELS YOUR BOARDING PASS.",
 	"WITH THE BAR OFF THE DOOR THE CAPTAIN WALTZES IN AND BLOWS YOU AWAY"
 };
 


Commit: 7ae4fca38e792e8d27664d58562eafe6bd049a4d
    https://github.com/scummvm/scummvm/commit/7ae4fca38e792e8d27664d58562eafe6bd049a4d
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-16T22:21:49-05:00

Commit Message:
ACCESS: Fix foreground parallex in opening scene

Changed paths:
    engines/access/amazon/amazon_logic.cpp



diff --git a/engines/access/amazon/amazon_logic.cpp b/engines/access/amazon/amazon_logic.cpp
index eb7d8b5..5ac7341 100644
--- a/engines/access/amazon/amazon_logic.cpp
+++ b/engines/access/amazon/amazon_logic.cpp
@@ -89,7 +89,7 @@ void CampScene::mWhileDoOpen() {
 	Screen &screen = *_vm->_screen;
 	EventsManager &events = *_vm->_events;
 
-	screen.setBufferScan();
+	screen.setDisplayScan();
 	events.hideCursor();
 	screen.forceFadeOut();
 	_skipStart = false;


Commit: 3a1203ff734f7923042ed0b5ab96a460e72369ec
    https://github.com/scummvm/scummvm/commit/3a1203ff734f7923042ed0b5ab96a460e72369ec
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-17T07:47:55+01:00

Commit Message:
ACCESS: Use a while statement as suggested by _sev in the merge request

Also fix a formatting issue pointed out by _sev

Changed paths:
    engines/access/access.cpp



diff --git a/engines/access/access.cpp b/engines/access/access.cpp
index b67aebf..c0f8905 100644
--- a/engines/access/access.cpp
+++ b/engines/access/access.cpp
@@ -248,10 +248,7 @@ void AccessEngine::speakText(ASurface *s, const Common::String &msg) {
 			break;
 	}
 
-	if (soundsLeft == 0)
-		return;
-
-	for (;;) {
+	while (soundsLeft) {
 		_sound->freeSounds();
 		Resource *res = _sound->loadSound(_narateFile + 99, _sndSubFile);
 		_sound->_soundTable.push_back(SoundEntry(res, 1));
@@ -270,8 +267,6 @@ void AccessEngine::speakText(ASurface *s, const Common::String &msg) {
 		} else {
 			++_sndSubFile;
 			--soundsLeft;
-			if (soundsLeft == 0)
-				break;
 		}
 	}
 }
@@ -519,7 +514,8 @@ bool AccessEngine::readSavegameHeader(Common::InSaveFile *in, AccessSavegameHead
 	// Read in the string
 	header._saveName.clear();
 	char ch;
-	while ((ch = (char)in->readByte()) != '\0') header._saveName += ch;
+	while ((ch = (char)in->readByte()) != '\0')
+		header._saveName += ch;
 
 	// Get the thumbnail
 	header._thumbnail = Graphics::loadThumbnail(*in);


Commit: 56d28bc4c8bececc6bba2788e727718c5741d0ec
    https://github.com/scummvm/scummvm/commit/56d28bc4c8bececc6bba2788e727718c5741d0ec
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-17T07:58:24+01:00

Commit Message:
ACCESS: Split doCredit in two, putting demo code in a separate function

Changed paths:
    engines/access/amazon/amazon_logic.cpp
    engines/access/amazon/amazon_logic.h



diff --git a/engines/access/amazon/amazon_logic.cpp b/engines/access/amazon/amazon_logic.cpp
index 5ac7341..0200f7a 100644
--- a/engines/access/amazon/amazon_logic.cpp
+++ b/engines/access/amazon/amazon_logic.cpp
@@ -236,74 +236,74 @@ void Opening::doCredit() {
 
 	if (_pCount <= 75)
 		_vm->_buffer2.plotImage(_vm->_objectsTable[0], _vm->isDemo()? 24 : 0, Common::Point(90, 35));
-	else if (_pCount <= 210) {
-		if (_vm->isDemo())
-			_vm->_buffer2.plotImage(_vm->_objectsTable[0], 25, Common::Point(82, 35));
-		else
-			_vm->_buffer2.plotImage(_vm->_objectsTable[0], 1, Common::Point(65, 35));
-	} else if (_pCount <= 272) {
-		if (_vm->isDemo()) {
-			_vm->_buffer2.plotImage(_vm->_objectsTable[0], 23, Common::Point(77, 20));
-			_vm->_buffer2.plotImage(_vm->_objectsTable[0], 4, Common::Point(50, 35));
-		} else
-			_vm->_buffer2.plotImage(_vm->_objectsTable[0], 2, Common::Point(96, 45));
+	else if (_pCount <= 210)
+		_vm->_buffer2.plotImage(_vm->_objectsTable[0], 1, Common::Point(65, 35));
+	else if (_pCount <= 272)
+		_vm->_buffer2.plotImage(_vm->_objectsTable[0], 2, Common::Point(96, 45));
+	else if (_pCount <= 334)
+		_vm->_buffer2.plotImage(_vm->_objectsTable[0], 3, Common::Point(68, 54));
+	else if (_pCount <= 396)
+		_vm->_buffer2.plotImage(_vm->_objectsTable[0], 4, Common::Point(103, 54));
+	else if (_pCount <= 458) {
+		_vm->_buffer2.plotImage(_vm->_objectsTable[0], 5, Common::Point(8, 5));
+		_vm->_buffer2.plotImage(_vm->_objectsTable[0], 12, Common::Point(88, 55));
+		_vm->_buffer2.plotImage(_vm->_objectsTable[0], 6, Common::Point(194, 98));
+	} else if (_pCount <= 520) {
+		_vm->_buffer2.plotImage(_vm->_objectsTable[0], 7, Common::Point(32, 13));
+		_vm->_buffer2.plotImage(_vm->_objectsTable[0], 8, Common::Point(162, 80));
+	} else if (_pCount <= 580) {
+		_vm->_buffer2.plotImage(_vm->_objectsTable[0], 9, Common::Point(18, 15));
+		_vm->_buffer2.plotImage(_vm->_objectsTable[0], 10, Common::Point(164, 81));
+	} else
+		_vm->_buffer2.plotImage(_vm->_objectsTable[0], 11, Common::Point(106, 55));
+}
+
+void Opening::doCreditDemo() {
+	if (_pCount < 15)
+		return;
+
+	if (_pCount <= 75)
+		_vm->_buffer2.plotImage(_vm->_objectsTable[0], _vm->isDemo()? 24 : 0, Common::Point(90, 35));
+	else if (_pCount <= 210)
+		_vm->_buffer2.plotImage(_vm->_objectsTable[0], 25, Common::Point(82, 35));
+	else if (_pCount <= 272) {
+		_vm->_buffer2.plotImage(_vm->_objectsTable[0], 23, Common::Point(77, 20));
+		_vm->_buffer2.plotImage(_vm->_objectsTable[0], 4, Common::Point(50, 35));
 	} else if (_pCount <= 334) {
-		if (_vm->isDemo()) {
-			_vm->_buffer2.plotImage(_vm->_objectsTable[0], 16, Common::Point(200, 70));
-			_vm->_buffer2.plotImage(_vm->_objectsTable[0], 4, Common::Point(170, 85));
-		} else
-			_vm->_buffer2.plotImage(_vm->_objectsTable[0], 3, Common::Point(68, 54));
+		_vm->_buffer2.plotImage(_vm->_objectsTable[0], 16, Common::Point(200, 70));
+		_vm->_buffer2.plotImage(_vm->_objectsTable[0], 4, Common::Point(170, 85));
 	} else if (_pCount <= 396) {
-		if (_vm->isDemo()) {
-			_vm->_buffer2.plotImage(_vm->_objectsTable[0], 15, Common::Point(65, 15));
-			_vm->_buffer2.plotImage(_vm->_objectsTable[0], 2, Common::Point(30, 30));
-		} else
-			_vm->_buffer2.plotImage(_vm->_objectsTable[0], 4, Common::Point(103, 54));
+		_vm->_buffer2.plotImage(_vm->_objectsTable[0], 15, Common::Point(65, 15));
+		_vm->_buffer2.plotImage(_vm->_objectsTable[0], 2, Common::Point(30, 30));
 	} else if (_pCount <= 458) {
-		if (_vm->isDemo()) {
-			_vm->_buffer2.plotImage(_vm->_objectsTable[0], 19, Common::Point(123, 40));
-			_vm->_buffer2.plotImage(_vm->_objectsTable[0], 10, Common::Point(115, 55));
-		} else {
-			_vm->_buffer2.plotImage(_vm->_objectsTable[0], 5, Common::Point(8, 5));
-			_vm->_buffer2.plotImage(_vm->_objectsTable[0], 12, Common::Point(88, 55));
-			_vm->_buffer2.plotImage(_vm->_objectsTable[0], 6, Common::Point(194, 98));
-		}
+		_vm->_buffer2.plotImage(_vm->_objectsTable[0], 19, Common::Point(123, 40));
+		_vm->_buffer2.plotImage(_vm->_objectsTable[0], 10, Common::Point(115, 55));
 	} else if (_pCount <= 520) {
-		if (_vm->isDemo()) {
-			_vm->_buffer2.plotImage(_vm->_objectsTable[0], 18, Common::Point(50, 15));
-			_vm->_buffer2.plotImage(_vm->_objectsTable[0], 9, Common::Point(40, 30));
-			_vm->_buffer2.plotImage(_vm->_objectsTable[0], 0, Common::Point(40, 55));
-			_vm->_buffer2.plotImage(_vm->_objectsTable[0], 20, Common::Point(198, 95));
-			_vm->_buffer2.plotImage(_vm->_objectsTable[0], 3, Common::Point(160, 110));
-		} else {
-			_vm->_buffer2.plotImage(_vm->_objectsTable[0], 7, Common::Point(32, 13));
-			_vm->_buffer2.plotImage(_vm->_objectsTable[0], 8, Common::Point(162, 80));
-		}
+		_vm->_buffer2.plotImage(_vm->_objectsTable[0], 18, Common::Point(50, 15));
+		_vm->_buffer2.plotImage(_vm->_objectsTable[0], 9, Common::Point(40, 30));
+		_vm->_buffer2.plotImage(_vm->_objectsTable[0], 0, Common::Point(40, 55));
+		_vm->_buffer2.plotImage(_vm->_objectsTable[0], 20, Common::Point(198, 95));
+		_vm->_buffer2.plotImage(_vm->_objectsTable[0], 3, Common::Point(160, 110));
 	} else if (_pCount <= 580) {
-		if (_vm->isDemo()) {
-			_vm->_buffer2.plotImage(_vm->_objectsTable[0], 21, Common::Point(40, 10));
-			_vm->_buffer2.plotImage(_vm->_objectsTable[0], 6, Common::Point(20, 25));
-			_vm->_buffer2.plotImage(_vm->_objectsTable[0], 22, Common::Point(145, 50));
-			_vm->_buffer2.plotImage(_vm->_objectsTable[0], 7, Common::Point(125, 65));
-			_vm->_buffer2.plotImage(_vm->_objectsTable[0], 12, Common::Point(207, 90));
-			_vm->_buffer2.plotImage(_vm->_objectsTable[0], 5, Common::Point(200, 105));
-		} else {
-			_vm->_buffer2.plotImage(_vm->_objectsTable[0], 9, Common::Point(18, 15));
-			_vm->_buffer2.plotImage(_vm->_objectsTable[0], 10, Common::Point(164, 81));
-		}
+		_vm->_buffer2.plotImage(_vm->_objectsTable[0], 21, Common::Point(40, 10));
+		_vm->_buffer2.plotImage(_vm->_objectsTable[0], 6, Common::Point(20, 25));
+		_vm->_buffer2.plotImage(_vm->_objectsTable[0], 22, Common::Point(145, 50));
+		_vm->_buffer2.plotImage(_vm->_objectsTable[0], 7, Common::Point(125, 65));
+		_vm->_buffer2.plotImage(_vm->_objectsTable[0], 12, Common::Point(207, 90));
+		_vm->_buffer2.plotImage(_vm->_objectsTable[0], 5, Common::Point(200, 105));
 	} else {
-		if (_vm->isDemo()) {
-			_vm->_buffer2.plotImage(_vm->_objectsTable[0], 11, Common::Point(125, 30));
-			_vm->_buffer2.plotImage(_vm->_objectsTable[0], 4, Common::Point(115, 45));
-		} else
-			_vm->_buffer2.plotImage(_vm->_objectsTable[0], 11, Common::Point(106, 55));
+		_vm->_buffer2.plotImage(_vm->_objectsTable[0], 11, Common::Point(125, 30));
+		_vm->_buffer2.plotImage(_vm->_objectsTable[0], 4, Common::Point(115, 45));
 	}
 }
 
 void Opening::scrollTitle() {
 	_vm->copyBF1BF2();
 	_vm->_newRects.clear();
-	doCredit();
+	if (_vm->isDemo())
+		doCreditDemo();
+	else
+		doCredit();
 	_vm->copyRects();
 	_vm->copyBF2Vid();
 }
diff --git a/engines/access/amazon/amazon_logic.h b/engines/access/amazon/amazon_logic.h
index 9b429d8..c8e7745 100644
--- a/engines/access/amazon/amazon_logic.h
+++ b/engines/access/amazon/amazon_logic.h
@@ -84,6 +84,7 @@ private:
 
 	void doTitle();
 	void doCredit();
+	void doCreditDemo();
 	void scrollTitle();
 	void doTent();
 public:


Commit: 1496ad9717f499a73ce96cf318c6bf8070f02915
    https://github.com/scummvm/scummvm/commit/1496ad9717f499a73ce96cf318c6bf8070f02915
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-17T08:29:24+01:00

Commit Message:
ACCESS: Split mouse data per line

Changed paths:
    engines/access/amazon/amazon_resources.cpp



diff --git a/engines/access/amazon/amazon_resources.cpp b/engines/access/amazon/amazon_resources.cpp
index 989dcf1..55302c0 100644
--- a/engines/access/amazon/amazon_resources.cpp
+++ b/engines/access/amazon/amazon_resources.cpp
@@ -71,126 +71,243 @@ const char *const FILENAMES_DEMO[] = {
 	"R49.AP", "R49.AP", "R49.AP", "R49.AP", "DEAD.AP", "EST.AP",
 	"CHAPTER.AP", "MUSIC.AP", "SOUND.AP", "INV.AP"
 };
+
 const byte MOUSE0[] = {
+	// hotspot x and y, uint16 LE
 	0, 0, 0, 0,
-	0, 2, 6, 1, 0, 3, 6, 6, 1, 0, 3, 6, 6, 1,
-	0, 4, 6, 6, 6, 1, 0, 4, 6, 6, 6, 1, 0, 5, 6, 6, 6, 6,
-	1, 0, 5, 6, 6, 6, 6, 1, 0, 6, 6, 6, 6, 6, 6, 1, 0, 6,
-	6, 6, 6, 6, 6, 1, 0, 7, 6, 6, 6, 6, 6, 6, 1, 0, 6, 6,
-	6, 6, 6, 6, 1, 0, 5, 6, 6, 6, 6, 1, 2, 3, 6, 6, 1, 3,
-	3, 6, 6, 1, 3, 3, 6, 6, 1, 4, 2, 6, 1
+	// byte 1: number of skipped pixels
+	// byte 2: number of plotted pixels
+	// then, pixels
+	0, 2, 6, 1,
+	0, 3, 6, 6, 1, 
+	0, 3, 6, 6, 1, 
+	0, 4, 6, 6, 6, 1, 
+	0, 4, 6, 6, 6, 1, 
+	0, 5, 6, 6, 6, 6, 1, 
+	0, 5, 6, 6, 6, 6, 1, 
+	0, 6, 6, 6, 6, 6, 6, 1,
+	0, 6, 6, 6, 6, 6, 6, 1,
+	0, 7, 6, 6, 6, 6, 6, 6, 1,
+	0, 6, 6, 6, 6, 6, 6, 1,
+	0, 5, 6, 6, 6, 6, 1,
+	2, 3, 6, 6, 1,
+	3, 3, 6, 6, 1,
+	3, 3, 6, 6, 1,
+	4, 2, 6, 1
 };
+
 const byte MOUSE1[] = {
-	0x07, 0x00, 0x07, 0x00, 0x06, 0x01, 0x05, 0x04, 0x05, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x03, 0x07,
-	0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x02, 0x09, 0xFF, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00,
-	0x00, 0xFF, 0x01, 0x0B, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x01,
-	0x0B, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x0D, 0x05, 0x00,
-	0x00, 0x05, 0x00, 0x05, 0x00, 0x05, 0x00, 0x05, 0x00, 0x00, 0x05, 0x01, 0x0B, 0xFF, 0x00, 0x00,
-	0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x01, 0x0B, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0xFF, 0x02, 0x09, 0xFF, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0xFF,
-	0x03, 0x07, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x04, 0x05, 0xFF, 0xFF, 0x00, 0xFF, 0xFF,
-	0x06, 0x01, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+	// hotspot x and y, uint16 LE
+	0x07, 0x00, 0x07, 0x00,
+	// byte 1: number of skipped pixels
+	// byte 2: number of plotted pixels
+	// then, pixels
+	0x06, 0x01, 0x05,
+	0x04, 0x05, 0xFF, 0xFF, 0x00, 0xFF, 0xFF,
+	0x03, 0x07, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF,
+	0x02, 0x09, 0xFF, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0xFF,
+	0x01, 0x0B, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF,
+	0x01, 0x0B, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0xFF,
+	0x00, 0x0D, 0x05, 0x00, 0x00, 0x05, 0x00, 0x05, 0x00, 0x05, 0x00, 0x05, 0x00, 0x00, 0x05,
+	0x01, 0x0B, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0xFF,
+	0x01, 0x0B, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF,
+	0x02, 0x09, 0xFF, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0xFF,
+	0x03, 0x07, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF,
+	0x04, 0x05, 0xFF, 0xFF, 0x00, 0xFF, 0xFF,
+	0x06, 0x01, 0x05,
+	0x00, 0x00,
+	0x00, 0x00,
+	0x00, 0x00
 };
+
 const byte MOUSE2[] = {
-	0x08, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x02, 0x04, 0x05, 0x07, 0x02, 0x04, 0x05,
-	0x07, 0x02, 0x04, 0x05, 0x07, 0x02, 0x04, 0x05, 0x07, 0x02, 0x04, 0x05, 0x02, 0x0C, 0x04, 0x04,
-	0x04, 0x04, 0x04, 0x00, 0x04, 0x04, 0x04, 0x04, 0x04, 0x05, 0x07, 0x02, 0x04, 0x05, 0x07, 0x02,
-	0x04, 0x05, 0x07, 0x02, 0x04, 0x05, 0x07, 0x02, 0x04, 0x05, 0x07, 0x02, 0x04, 0x05, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00
+	// hotspot x and y, uint16 LE
+	0x08, 0x00, 0x08, 0x00,
+	// byte 1: number of skipped pixels
+	// byte 2: number of plotted pixels
+	// then, pixels
+	0x00, 0x00,
+	0x00, 0x00,
+	0x07, 0x02, 0x04, 0x05,
+	0x07, 0x02, 0x04, 0x05,
+	0x07, 0x02, 0x04, 0x05,
+	0x07, 0x02, 0x04, 0x05,
+	0x07, 0x02, 0x04, 0x05,
+	0x02, 0x0C, 0x04, 0x04, 0x04, 0x04, 0x04, 0x00, 0x04, 0x04, 0x04, 0x04, 0x04, 0x05,
+	0x07, 0x02, 0x04, 0x05,
+	0x07, 0x02, 0x04, 0x05,
+	0x07, 0x02, 0x04, 0x05,
+	0x07, 0x02, 0x04, 0x05,
+	0x07, 0x02, 0x04, 0x05,
+	0x00, 0x00,
+	0x00, 0x00,
+	0x00, 0x00
 };
+
 const byte MOUSE3[] = {
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x0B, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06,
-	0x06, 0x00, 0x0C, 0x06, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x06, 0x06, 0x05, 0x00,
-	0x0C, 0x06, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x06, 0x05, 0x05, 0x00, 0x0C, 0x06,
-	0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x05, 0x00, 0x0C, 0x06, 0x06, 0x06,
-	0x06, 0x06, 0x05, 0x06, 0x06, 0x06, 0x06, 0x06, 0x05, 0x00, 0x0C, 0x06, 0x06, 0x06, 0x06, 0x05,
-	0x00, 0x00, 0x06, 0x06, 0x06, 0x06, 0x05, 0x00, 0x0C, 0x06, 0x06, 0x06, 0x06, 0x06, 0x00, 0x06,
-	0x06, 0x06, 0x06, 0x06, 0x05, 0x00, 0x0C, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06,
-	0x06, 0x06, 0x05, 0x00, 0x0C, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06,
-	0x05, 0x00, 0x0C, 0x06, 0x06, 0x06, 0x06, 0x06, 0x05, 0x06, 0x06, 0x06, 0x06, 0x06, 0x05, 0x00,
-	0x0C, 0x06, 0x06, 0x06, 0x06, 0x06, 0x05, 0x06, 0x06, 0x06, 0x06, 0x06, 0x05, 0x00, 0x0C, 0x06,
-	0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x05, 0x01, 0x0B, 0x05, 0x05, 0x05,
-	0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+	// hotspot x and y, uint16 LE
+	0x00, 0x00, 0x00, 0x00,
+	// byte 1: number of skipped pixels
+	// byte 2: number of plotted pixels
+	// then, pixels
+	0x00, 0x0B, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06,
+	0x00, 0x0C, 0x06, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x06, 0x06, 0x05,
+	0x00, 0x0C, 0x06, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x06, 0x05, 0x05,
+	0x00, 0x0C, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x05,
+	0x00, 0x0C, 0x06, 0x06, 0x06, 0x06, 0x06, 0x05, 0x06, 0x06, 0x06, 0x06, 0x06, 0x05,
+	0x00, 0x0C, 0x06, 0x06, 0x06, 0x06, 0x05, 0x00, 0x00, 0x06, 0x06, 0x06, 0x06, 0x05,
+	0x00, 0x0C, 0x06, 0x06, 0x06, 0x06, 0x06, 0x00, 0x06, 0x06, 0x06, 0x06, 0x06, 0x05,
+	0x00, 0x0C, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x05,
+	0x00, 0x0C, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x05,
+	0x00, 0x0C, 0x06, 0x06, 0x06, 0x06, 0x06, 0x05, 0x06, 0x06, 0x06, 0x06, 0x06, 0x05,
+	0x00, 0x0C, 0x06, 0x06, 0x06, 0x06, 0x06, 0x05, 0x06, 0x06, 0x06, 0x06, 0x06, 0x05,
+	0x00, 0x0C, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x05,
+	0x01, 0x0B, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05,
+	0x00, 0x00,
+	0x00, 0x00,
+	0x00, 0x00
 };
 const byte CURSEYE[] = {
-	0x01, 0x00, 0x08, 0x00, 0x04, 0x06, 0x0E, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x03, 0x09, 0x0E, 0x01,
-	0x01, 0x01, 0x01, 0x01, 0x01, 0x0D, 0x0D, 0x02, 0x0B, 0x0E, 0x01, 0x33, 0x33, 0x01, 0x01, 0x33,
-	0x34, 0x01, 0x01, 0x0D, 0x01, 0x0D, 0x0E, 0x01, 0x04, 0x34, 0x01, 0x01, 0x01, 0x07, 0x33, 0x04,
-	0x04, 0x01, 0x0D, 0x00, 0x0F, 0x0E, 0x0E, 0x01, 0x07, 0x33, 0x33, 0x01, 0x01, 0x33, 0x34, 0x07,
-	0x07, 0x06, 0x01, 0x0E, 0x01, 0x0D, 0x0F, 0x0F, 0x06, 0x07, 0x34, 0x33, 0x33, 0x34, 0x07, 0x07,
-	0x06, 0x0F, 0x0E, 0x03, 0x09, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0E, 0x01, 0x01,
-	0x07, 0x00, 0x03, 0x07, 0x01, 0x07, 0x01, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00
+	// hotspot x and y, uint16 LE
+	0x01, 0x00, 0x08, 0x00,
+	// byte 1: number of skipped pixels
+	// byte 2: number of plotted pixels
+	// then, pixels
+	0x04, 0x06, 0x0E, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D,
+	0x03, 0x09, 0x0E, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x0D, 0x0D,
+	0x02, 0x0B, 0x0E, 0x01, 0x33, 0x33, 0x01, 0x01, 0x33, 0x34, 0x01, 0x01, 0x0D,
+	0x01, 0x0D, 0x0E, 0x01, 0x04, 0x34, 0x01, 0x01, 0x01, 0x07, 0x33, 0x04, 0x04, 0x01, 0x0D,
+	0x00, 0x0F, 0x0E, 0x0E, 0x01, 0x07, 0x33, 0x33, 0x01, 0x01, 0x33, 0x34, 0x07, 0x07, 0x06, 0x01, 0x0E,
+	0x01, 0x0D, 0x0F, 0x0F, 0x06, 0x07, 0x34, 0x33, 0x33, 0x34, 0x07, 0x07, 0x06, 0x0F, 0x0E,
+	0x03, 0x09, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0E,
+	0x01, 0x01, 0x07,
+	0x00, 0x03, 0x07, 0x01, 0x07,
+	0x01, 0x01, 0x07,
+	0x00, 0x00,
+	0x00, 0x00,
+	0x00, 0x00,
+	0x00, 0x00,
+	0x00, 0x00,
+	0x00, 0x00
 };
+
 const byte CURSHAND[] = {
-	0x02, 0x00, 0x03, 0x00, 0x07, 0x02, 0x17, 0x0E, 0x05, 0x07, 0x0E, 0x12, 0x17, 0x0E, 0x13, 0x17,
-	0x0E, 0x02, 0x0C, 0x07, 0x00, 0x17, 0x0E, 0x11, 0x0F, 0x0E, 0x11, 0x17, 0x0E, 0x00, 0x17, 0x01,
-	0x0E, 0x07, 0x01, 0x07, 0x0F, 0x0E, 0x11, 0x17, 0x0E, 0x11, 0x0F, 0x0E, 0x12, 0x17, 0x0E, 0x02,
-	0x0D, 0x07, 0x00, 0x17, 0x0F, 0x12, 0x0F, 0x0F, 0x11, 0x17, 0x0E, 0x12, 0x0F, 0x0E, 0x04, 0x0B,
-	0x0F, 0x0E, 0x11, 0x17, 0x0E, 0x12, 0x0F, 0x0F, 0x11, 0x17, 0x0E, 0x04, 0x0B, 0x17, 0x0E, 0x12,
-	0x17, 0x0E, 0x12, 0x17, 0x0E, 0x11, 0x0F, 0x0E, 0x00, 0x0F, 0x0E, 0x0D, 0x12, 0x00, 0x17, 0x0F,
-	0x0F, 0x0F, 0x0F, 0x12, 0x0F, 0x0E, 0x12, 0x17, 0x0F, 0x00, 0x0F, 0x0F, 0x17, 0x0D, 0x11, 0x0F,
-	0x0E, 0x0D, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0E, 0x0D, 0x01, 0x0E, 0x0F, 0x17, 0x0F, 0x0E,
-	0x0F, 0x0D, 0x0D, 0x0D, 0x0D, 0x0E, 0x0F, 0x0F, 0x0E, 0x0D, 0x02, 0x0D, 0x0F, 0x17, 0x0F, 0x0E,
-	0x0D, 0x0D, 0x0F, 0x0F, 0x0E, 0x0F, 0x0E, 0x0E, 0x12, 0x03, 0x0C, 0x0F, 0x17, 0x0F, 0x0F, 0x0F,
-	0x0E, 0x0F, 0x0F, 0x0F, 0x0E, 0x0D, 0x12, 0x04, 0x0A, 0x0F, 0x17, 0x0F, 0x0F, 0x0F, 0x0E, 0x0F,
-	0x0F, 0x0E, 0x0D, 0x05, 0x09, 0x0F, 0x17, 0x0F, 0x0F, 0x0F, 0x0F, 0x0E, 0x0D, 0x12, 0x06, 0x08,
-	0x17, 0x0F, 0x0F, 0x0F, 0x0F, 0x0E, 0x0D, 0x12, 0x06, 0x07, 0x17, 0x0F, 0x0F, 0x0F, 0x3D, 0x0E,
-	0x0D
+	// hotspot x and y, uint16 LE
+	0x02, 0x00, 0x03, 0x00,
+	// byte 1: number of skipped pixels
+	// byte 2: number of plotted pixels
+	// then, pixels
+	0x07, 0x02, 0x17, 0x0E,
+	0x05, 0x07, 0x0E, 0x12, 0x17, 0x0E, 0x13, 0x17, 0x0E,
+	0x02, 0x0C, 0x07, 0x00, 0x17, 0x0E, 0x11, 0x0F, 0x0E, 0x11, 0x17, 0x0E, 0x00, 0x17,
+	0x01, 0x0E, 0x07, 0x01, 0x07, 0x0F, 0x0E, 0x11, 0x17, 0x0E, 0x11, 0x0F, 0x0E, 0x12, 0x17, 0x0E,
+	0x02, 0x0D, 0x07, 0x00, 0x17, 0x0F, 0x12, 0x0F, 0x0F, 0x11, 0x17, 0x0E, 0x12, 0x0F, 0x0E,
+	0x04, 0x0B, 0x0F, 0x0E, 0x11, 0x17, 0x0E, 0x12, 0x0F, 0x0F, 0x11, 0x17, 0x0E,
+	0x04, 0x0B, 0x17, 0x0E, 0x12, 0x17, 0x0E, 0x12, 0x17, 0x0E, 0x11, 0x0F, 0x0E,
+	0x00, 0x0F, 0x0E, 0x0D, 0x12, 0x00, 0x17, 0x0F, 0x0F, 0x0F, 0x0F, 0x12, 0x0F, 0x0E, 0x12, 0x17, 0x0F,
+	0x00, 0x0F, 0x0F, 0x17, 0x0D, 0x11, 0x0F, 0x0E, 0x0D, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0E, 0x0D,
+	0x01, 0x0E, 0x0F, 0x17, 0x0F, 0x0E, 0x0F, 0x0D, 0x0D, 0x0D, 0x0D, 0x0E, 0x0F, 0x0F, 0x0E, 0x0D,
+	0x02, 0x0D, 0x0F, 0x17, 0x0F, 0x0E, 0x0D, 0x0D, 0x0F, 0x0F, 0x0E, 0x0F, 0x0E, 0x0E, 0x12,
+	0x03, 0x0C, 0x0F, 0x17, 0x0F, 0x0F, 0x0F, 0x0E, 0x0F, 0x0F, 0x0F, 0x0E, 0x0D, 0x12,
+	0x04, 0x0A, 0x0F, 0x17, 0x0F, 0x0F, 0x0F, 0x0E, 0x0F, 0x0F, 0x0E, 0x0D,
+	0x05, 0x09, 0x0F, 0x17, 0x0F, 0x0F, 0x0F, 0x0F, 0x0E, 0x0D, 0x12,
+	0x06, 0x08, 0x17, 0x0F, 0x0F, 0x0F, 0x0F, 0x0E, 0x0D, 0x12,
+	0x06, 0x07, 0x17, 0x0F, 0x0F, 0x0F, 0x3D, 0x0E, 0x0D
 };
+
 const byte CURSGET[] = {
-	0x07, 0x00, 0x0E, 0x00, 0x0A, 0x05, 0x1C, 0x07, 0x0F, 0x0F, 0x0F, 0x08, 0x08, 0x1C, 0x07, 0x0F,
-	0x0F, 0x0F, 0x0F, 0x0F, 0x0C, 0x06, 0x0A, 0x1C, 0x07, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F,
-	0x0C, 0x05, 0x0A, 0x07, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0C, 0x03, 0x0C, 0x07,
-	0x1C, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0C, 0x02, 0x0D, 0x1C, 0x0F, 0x0E,
-	0x0E, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0C, 0x01, 0x0E, 0x07, 0x0F, 0x0E, 0x0D,
-	0x0F, 0x0E, 0x0D, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0C, 0x00, 0x0F, 0x1C, 0x0F, 0x0E, 0x0D,
-	0x0F, 0x0E, 0x0D, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0C, 0x00, 0x0F, 0x1C, 0x0E, 0x0D,
-	0x0F, 0x0E, 0x0D, 0x0F, 0x0F, 0x0C, 0x0C, 0x0E, 0x0F, 0x0F, 0x0F, 0x0C, 0x00, 0x0E, 0x1C, 0x0D,
-	0x0F, 0x0E, 0x0D, 0x0F, 0x0F, 0x0C, 0x00, 0x00, 0x0E, 0x0F, 0x0F, 0x0C, 0x00, 0x0E, 0x1C, 0x0E,
-	0x0F, 0x0D, 0x0F, 0x0F, 0x0C, 0x00, 0x00, 0x0E, 0x1C, 0x0F, 0x0F, 0x0C, 0x00, 0x0D, 0x1C, 0x0D,
-	0x0F, 0x0D, 0x0F, 0x0C, 0x00, 0x00, 0x00, 0x0E, 0x1C, 0x0F, 0x0C, 0x01, 0x0B, 0x0E, 0x0F, 0x0E,
-	0x0F, 0x0C, 0x00, 0x00, 0x0E, 0x07, 0x0F, 0x0C, 0x02, 0x09, 0x0E, 0x0D, 0x0F, 0x0C, 0x00, 0x07,
-	0x0E, 0x0F, 0x0C, 0x03, 0x06, 0x0E, 0x0F, 0x0E, 0x07, 0x01, 0x07, 0x07, 0x01, 0x07
+	// hotspot x and y, uint16 LE
+	0x07, 0x00, 0x0E, 0x00,
+	// byte 1: number of skipped pixels
+	// byte 2: number of plotted pixels
+	// then, pixels
+	0x0A, 0x05, 0x1C, 0x07, 0x0F, 0x0F, 0x0F,
+	0x08, 0x08, 0x1C, 0x07, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0C,
+	0x06, 0x0A, 0x1C, 0x07, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0C,
+	0x05, 0x0A, 0x07, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0C,
+	0x03, 0x0C, 0x07, 0x1C, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0C,
+	0x02, 0x0D, 0x1C, 0x0F, 0x0E, 0x0E, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0C,
+	0x01, 0x0E, 0x07, 0x0F, 0x0E, 0x0D, 0x0F, 0x0E, 0x0D, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0C,
+	0x00, 0x0F, 0x1C, 0x0F, 0x0E, 0x0D, 0x0F, 0x0E, 0x0D, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0C,
+	0x00, 0x0F, 0x1C, 0x0E, 0x0D, 0x0F, 0x0E, 0x0D, 0x0F, 0x0F, 0x0C, 0x0C, 0x0E, 0x0F, 0x0F, 0x0F, 0x0C,
+	0x00, 0x0E, 0x1C, 0x0D, 0x0F, 0x0E, 0x0D, 0x0F, 0x0F, 0x0C, 0x00, 0x00, 0x0E, 0x0F, 0x0F, 0x0C,
+	0x00, 0x0E, 0x1C, 0x0E, 0x0F, 0x0D, 0x0F, 0x0F, 0x0C, 0x00, 0x00, 0x0E, 0x1C, 0x0F, 0x0F, 0x0C,
+	0x00, 0x0D, 0x1C, 0x0D, 0x0F, 0x0D, 0x0F, 0x0C, 0x00, 0x00, 0x00, 0x0E, 0x1C, 0x0F, 0x0C,
+	0x01, 0x0B, 0x0E, 0x0F, 0x0E, 0x0F, 0x0C, 0x00, 0x00, 0x0E, 0x07, 0x0F, 0x0C,
+	0x02, 0x09, 0x0E, 0x0D, 0x0F, 0x0C, 0x00, 0x07, 0x0E, 0x0F, 0x0C,
+	0x03, 0x06, 0x0E, 0x0F, 0x0E, 0x07, 0x01, 0x07,
+	0x07, 0x01, 0x07
 };
+
 const byte CURSCLIMB[] = {
-	0x03, 0x00, 0x0E, 0x00, 0x06, 0x04, 0x01, 0x01, 0x01, 0x01, 0x06, 0x04, 0x0F, 0x0E, 0x01, 0x01,
-	0x06, 0x04, 0x0F, 0x0E, 0x0D, 0x01, 0x07, 0x02, 0x0F, 0x0D, 0x00, 0x0C, 0x0F, 0x00, 0x00, 0x00,
-	0x00, 0x13, 0x12, 0x12, 0x12, 0x12, 0x11, 0x11, 0x00, 0x0D, 0x0D, 0x0E, 0x00, 0x00, 0x13, 0x14,
-	0x13, 0x12, 0x12, 0x12, 0x11, 0x11, 0x0E, 0x01, 0x0C, 0x0D, 0x0D, 0x0D, 0x0E, 0x11, 0x13, 0x13,
-	0x12, 0x11, 0x11, 0x0E, 0x0D, 0x02, 0x0C, 0x0E, 0x0E, 0x00, 0x00, 0x00, 0x13, 0x12, 0x11, 0x00,
-	0x00, 0x0E, 0x0D, 0x03, 0x0B, 0x04, 0x04, 0x04, 0x22, 0x21, 0x21, 0x20, 0x00, 0x00, 0x00, 0x0D,
-	0x02, 0x0D, 0x22, 0x04, 0x20, 0x22, 0x04, 0x21, 0x04, 0x20, 0x00, 0x00, 0x00, 0x0E, 0x0E, 0x03,
-	0x07, 0x22, 0x21, 0x20, 0x20, 0x22, 0x04, 0x20, 0x04, 0x06, 0x01, 0x01, 0x00, 0x04, 0x22, 0x20,
-	0x02, 0x09, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x04, 0x20, 0x03, 0x09, 0x07, 0x01, 0x01,
-	0x00, 0x00, 0x00, 0x22, 0x04, 0x20, 0x02, 0x0B, 0x07, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x01, 0x01, 0x20, 0x03, 0x0A, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01
+	// hotspot x and y, uint16 LE
+	0x03, 0x00, 0x0E, 0x00,
+	// byte 1: number of skipped pixels
+	// byte 2: number of plotted pixels
+	// then, pixels
+	0x06, 0x04, 0x01, 0x01, 0x01, 0x01,
+	0x06, 0x04, 0x0F, 0x0E, 0x01, 0x01,
+	0x06, 0x04, 0x0F, 0x0E, 0x0D, 0x01,
+	0x07, 0x02, 0x0F, 0x0D,
+	0x00, 0x0C, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x13, 0x12, 0x12, 0x12, 0x12, 0x11, 0x11,
+	0x00, 0x0D, 0x0D, 0x0E, 0x00, 0x00, 0x13, 0x14, 0x13, 0x12, 0x12, 0x12, 0x11, 0x11, 0x0E,
+	0x01, 0x0C, 0x0D, 0x0D, 0x0D, 0x0E, 0x11, 0x13, 0x13, 0x12, 0x11, 0x11, 0x0E, 0x0D,
+	0x02, 0x0C, 0x0E, 0x0E, 0x00, 0x00, 0x00, 0x13, 0x12, 0x11, 0x00, 0x00, 0x0E, 0x0D,
+	0x03, 0x0B, 0x04, 0x04, 0x04, 0x22, 0x21, 0x21, 0x20, 0x00, 0x00, 0x00, 0x0D,
+	0x02, 0x0D, 0x22, 0x04, 0x20, 0x22, 0x04, 0x21, 0x04, 0x20, 0x00, 0x00, 0x00, 0x0E, 0x0E,
+	0x03, 0x07, 0x22, 0x21, 0x20, 0x20, 0x22, 0x04, 0x20,
+	0x04, 0x06, 0x01, 0x01, 0x00, 0x04, 0x22, 0x20,
+	0x02, 0x09, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x04, 0x20,
+	0x03, 0x09, 0x07, 0x01, 0x01, 0x00, 0x00, 0x00, 0x22, 0x04, 0x20,
+	0x02, 0x0B, 0x07, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x20,
+	0x03, 0x0A, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01
 };
+
 const byte CURSTALK[] = {
-	0x02, 0x00, 0x0B, 0x00, 0x03, 0x08, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x01, 0x0C,
-	0x06, 0x06, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x06, 0x06, 0x00, 0x0E, 0x06, 0x06,
-	0x06, 0x06, 0x07, 0x06, 0x07, 0x07, 0x06, 0x07, 0x07, 0x06, 0x07, 0x06, 0x00, 0x0F, 0x06, 0x08,
-	0x08, 0x08, 0x06, 0x08, 0x06, 0x06, 0x08, 0x06, 0x06, 0x08, 0x06, 0x08, 0x06, 0x00, 0x0F, 0x06,
-	0x06, 0x08, 0x06, 0x08, 0x06, 0x08, 0x06, 0x08, 0x06, 0x06, 0x08, 0x08, 0x06, 0x06, 0x00, 0x0F,
-	0x06, 0x06, 0x08, 0x06, 0x08, 0x08, 0x08, 0x06, 0x08, 0x06, 0x06, 0x08, 0x06, 0x08, 0x06, 0x01,
-	0x0E, 0x06, 0x08, 0x06, 0x08, 0x06, 0x08, 0x06, 0x08, 0x08, 0x06, 0x08, 0x06, 0x08, 0x06, 0x02,
-	0x0C, 0x06, 0x06, 0x06, 0x07, 0x06, 0x07, 0x06, 0x06, 0x07, 0x06, 0x07, 0x06, 0x04, 0x09, 0x06,
-	0x06, 0x06, 0x07, 0x07, 0x07, 0x07, 0x06, 0x06, 0x07, 0x04, 0x06, 0x07, 0x07, 0x06, 0x02, 0x08,
-	0x07, 0x00, 0x00, 0x06, 0x06, 0x06, 0x06, 0x06, 0x01, 0x06, 0x07, 0x01, 0x07, 0x06, 0x06, 0x06,
-	0x02, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+	// hotspot x and y, uint16 LE
+	0x02, 0x00, 0x0B, 0x00,
+	// byte 1: number of skipped pixels
+	// byte 2: number of plotted pixels
+	// then, pixels
+	0x03, 0x08, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06,
+	0x01, 0x0C, 0x06, 0x06, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x06, 0x06,
+	0x00, 0x0E, 0x06, 0x06, 0x06, 0x06, 0x07, 0x06, 0x07, 0x07, 0x06, 0x07, 0x07, 0x06, 0x07, 0x06,
+	0x00, 0x0F, 0x06, 0x08, 0x08, 0x08, 0x06, 0x08, 0x06, 0x06, 0x08, 0x06, 0x06, 0x08, 0x06, 0x08, 0x06,
+	0x00, 0x0F, 0x06, 0x06, 0x08, 0x06, 0x08, 0x06, 0x08, 0x06, 0x08, 0x06, 0x06, 0x08, 0x08, 0x06, 0x06,
+	0x00, 0x0F, 0x06, 0x06, 0x08, 0x06, 0x08, 0x08, 0x08, 0x06, 0x08, 0x06, 0x06, 0x08, 0x06, 0x08, 0x06,
+	0x01, 0x0E, 0x06, 0x08, 0x06, 0x08, 0x06, 0x08, 0x06, 0x08, 0x08, 0x06, 0x08, 0x06, 0x08, 0x06,
+	0x02, 0x0C, 0x06, 0x06, 0x06, 0x07, 0x06, 0x07, 0x06, 0x06, 0x07, 0x06, 0x07, 0x06,
+	0x04, 0x09, 0x06, 0x06, 0x06, 0x07, 0x07, 0x07, 0x07, 0x06, 0x06,
+	0x07, 0x04, 0x06, 0x07, 0x07, 0x06,
+	0x02, 0x08, 0x07, 0x00, 0x00, 0x06, 0x06, 0x06, 0x06, 0x06,
+	0x01, 0x06, 0x07, 0x01, 0x07, 0x06, 0x06, 0x06,
+	0x02, 0x01, 0x07,
+	0x00, 0x00,
+	0x00, 0x00,
+	0x00, 0x00
 };
 const byte CURSHELP[] = {
-	0x02, 0x00, 0x0B, 0x00, 0x04, 0x06, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x02, 0x0A, 0x24, 0x24,
-	0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x20, 0x20, 0x01, 0x0C, 0x24, 0x22, 0x22, 0x22, 0x20, 0x20,
-	0x20, 0x22, 0x22, 0x22, 0x22, 0x20, 0x00, 0x0E, 0x24, 0x22, 0x22, 0x22, 0x20, 0x00, 0x00, 0x00,
-	0x24, 0x22, 0x22, 0x22, 0x22, 0x20, 0x00, 0x0E, 0x24, 0x22, 0x22, 0x22, 0x22, 0x20, 0x00, 0x00,
-	0x00, 0x24, 0x22, 0x22, 0x22, 0x20, 0x00, 0x0E, 0x24, 0x22, 0x22, 0x22, 0x22, 0x20, 0x00, 0x00,
-	0x00, 0x24, 0x22, 0x22, 0x22, 0x20, 0x01, 0x0D, 0x24, 0x20, 0x20, 0x20, 0x00, 0x00, 0x00, 0x24,
-	0x22, 0x22, 0x22, 0x22, 0x20, 0x07, 0x06, 0x24, 0x22, 0x22, 0x22, 0x22, 0x20, 0x05, 0x07, 0x24,
-	0x22, 0x22, 0x22, 0x22, 0x20, 0x20, 0x04, 0x05, 0x24, 0x22, 0x22, 0x22, 0x20, 0x02, 0x07, 0x07,
-	0x00, 0x24, 0x20, 0x20, 0x20, 0x20, 0x01, 0x03, 0x07, 0x01, 0x07, 0x02, 0x07, 0x07, 0x00, 0x00,
-	0x24, 0x24, 0x24, 0x24, 0x04, 0x06, 0x24, 0x22, 0x22, 0x22, 0x22, 0x20, 0x04, 0x06, 0x24, 0x22,
-	0x22, 0x22, 0x22, 0x20, 0x05, 0x04, 0x20, 0x20, 0x20, 0x20
+	// hotspot x and y, uint16 LE
+	0x02, 0x00, 0x0B, 0x00,
+	// byte 1: number of skipped pixels
+	// byte 2: number of plotted pixels
+	// then, pixels
+	0x04, 0x06, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24,
+	0x02, 0x0A, 0x24, 0x24, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x20, 0x20,
+	0x01, 0x0C, 0x24, 0x22, 0x22, 0x22, 0x20, 0x20, 0x20, 0x22, 0x22, 0x22, 0x22, 0x20,
+	0x00, 0x0E, 0x24, 0x22, 0x22, 0x22, 0x20, 0x00, 0x00, 0x00, 0x24, 0x22, 0x22, 0x22, 0x22, 0x20,
+	0x00, 0x0E, 0x24, 0x22, 0x22, 0x22, 0x22, 0x20, 0x00, 0x00, 0x00, 0x24, 0x22, 0x22, 0x22, 0x20,
+	0x00, 0x0E, 0x24, 0x22, 0x22, 0x22, 0x22, 0x20, 0x00, 0x00, 0x00, 0x24, 0x22, 0x22, 0x22, 0x20,
+	0x01, 0x0D, 0x24, 0x20, 0x20, 0x20, 0x00, 0x00, 0x00, 0x24, 0x22, 0x22, 0x22, 0x22, 0x20,
+	0x07, 0x06, 0x24, 0x22, 0x22, 0x22, 0x22, 0x20,
+	0x05, 0x07, 0x24, 0x22, 0x22, 0x22, 0x22, 0x20, 0x20,
+	0x04, 0x05, 0x24, 0x22, 0x22, 0x22, 0x20,
+	0x02, 0x07, 0x07, 0x00, 0x24, 0x20, 0x20, 0x20, 0x20,
+	0x01, 0x03, 0x07, 0x01, 0x07,
+	0x02, 0x07, 0x07, 0x00, 0x00, 0x24, 0x24, 0x24, 0x24,
+	0x04, 0x06, 0x24, 0x22, 0x22, 0x22, 0x22, 0x20,
+	0x04, 0x06, 0x24, 0x22, 0x22, 0x22, 0x22, 0x20,
+	0x05, 0x04, 0x20, 0x20, 0x20, 0x20
 };
 const byte *CURSORS[10] = {
 	MOUSE0, MOUSE1, MOUSE2, MOUSE3, CURSEYE, CURSHAND, CURSGET, CURSCLIMB, CURSTALK, CURSHELP


Commit: 82dfe2a5bcac49e2abbec98f09693810839e422e
    https://github.com/scummvm/scummvm/commit/82dfe2a5bcac49e2abbec98f09693810839e422e
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-17T18:25:24+01:00

Commit Message:
ACCESS: Use writeString in writeSavegameHeader

Changed paths:
    engines/access/access.cpp



diff --git a/engines/access/access.cpp b/engines/access/access.cpp
index c0f8905..cc44313 100644
--- a/engines/access/access.cpp
+++ b/engines/access/access.cpp
@@ -8,12 +8,12 @@
  * 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.
@@ -540,7 +540,7 @@ void AccessEngine::writeSavegameHeader(Common::OutSaveFile *out, AccessSavegameH
 	out->writeByte(ACCESS_SAVEGAME_VERSION);
 
 	// Write savegame name
-	out->write(header._saveName.c_str(), header._saveName.size());
+	out->writeString(header._saveName);
 	out->writeByte('\0');
 
 	// Write a thumbnail of the screen


Commit: c8d6370edfef51fc0b5d3382cb5141613046d400
    https://github.com/scummvm/scummvm/commit/c8d6370edfef51fc0b5d3382cb5141613046d400
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-17T18:27:01+01:00

Commit Message:
ACCESS: Fix broken file header

Changed paths:
    engines/access/amazon/amazon_resources.cpp
    engines/access/files.cpp
    engines/access/resources.cpp



diff --git a/engines/access/amazon/amazon_resources.cpp b/engines/access/amazon/amazon_resources.cpp
index 55302c0..e61c704 100644
--- a/engines/access/amazon/amazon_resources.cpp
+++ b/engines/access/amazon/amazon_resources.cpp
@@ -1,22 +1,22 @@
 /* ScummVM - Graphic Adventure Engine
  *
- * ScummVM is the legal property of its developers, 0xwhose names
+ * 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, 0xor (at your option) any later version.
-
+ * 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, 0xwrite to the Free Software
- * Foundation, 0xInc., 0x51 Franklin Street, 0xFifth Floor, 0xBoston, 0xMA 02110-1301, 0xUSA.
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  *
  */
 
diff --git a/engines/access/files.cpp b/engines/access/files.cpp
index 004886a..1e81b7c 100644
--- a/engines/access/files.cpp
+++ b/engines/access/files.cpp
@@ -1,22 +1,22 @@
 /* ScummVM - Graphic Adventure Engine
  *
- * ScummVM is the legal property of its developers, 0xwhose names
+ * 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, 0xor (at your option) any later version.
-
+ * 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, 0xwrite to the Free Software
- * Foundation, 0xInc., 0x51 Franklin Street, 0xFifth Floor, 0xBoston, 0xMA 02110-1301, 0xUSA.
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  *
  */
 
diff --git a/engines/access/resources.cpp b/engines/access/resources.cpp
index 41f611d..6282d93 100644
--- a/engines/access/resources.cpp
+++ b/engines/access/resources.cpp
@@ -1,22 +1,22 @@
 /* ScummVM - Graphic Adventure Engine
  *
- * ScummVM is the legal property of its developers, 0xwhose names
+ * 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, 0xor (at your option) any later version.
-
+ * 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, 0xwrite to the Free Software
- * Foundation, 0xInc., 0x51 Franklin Street, 0xFifth Floor, 0xBoston, 0xMA 02110-1301, 0xUSA.
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  *
  */
 


Commit: 492d974550924522774181cbcfa559c4b7e7b3a1
    https://github.com/scummvm/scummvm/commit/492d974550924522774181cbcfa559c4b7e7b3a1
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-17T18:27:47+01:00

Commit Message:
ACCESS: Some more polishing in the file headers

Changed paths:
    engines/access/access.h
    engines/access/amazon/amazon_game.cpp
    engines/access/amazon/amazon_game.h
    engines/access/amazon/amazon_logic.cpp
    engines/access/amazon/amazon_logic.h
    engines/access/amazon/amazon_player.cpp
    engines/access/amazon/amazon_player.h
    engines/access/amazon/amazon_resources.h
    engines/access/amazon/amazon_room.cpp
    engines/access/amazon/amazon_room.h
    engines/access/amazon/amazon_scripts.cpp
    engines/access/amazon/amazon_scripts.h
    engines/access/animation.cpp
    engines/access/animation.h
    engines/access/asurface.cpp
    engines/access/asurface.h
    engines/access/bubble_box.cpp
    engines/access/bubble_box.h
    engines/access/char.cpp
    engines/access/char.h
    engines/access/data.cpp
    engines/access/data.h
    engines/access/debugger.cpp
    engines/access/debugger.h
    engines/access/decompress.cpp
    engines/access/decompress.h
    engines/access/detection.cpp
    engines/access/detection_tables.h
    engines/access/events.cpp
    engines/access/events.h
    engines/access/files.h
    engines/access/font.cpp
    engines/access/font.h
    engines/access/inventory.cpp
    engines/access/inventory.h
    engines/access/player.cpp
    engines/access/player.h
    engines/access/resources.h
    engines/access/room.cpp
    engines/access/room.h
    engines/access/screen.cpp
    engines/access/screen.h
    engines/access/scripts.cpp
    engines/access/scripts.h
    engines/access/sound.cpp
    engines/access/sound.h
    engines/access/video.cpp
    engines/access/video.h



diff --git a/engines/access/access.h b/engines/access/access.h
index 5470d2a..2672f3b 100644
--- a/engines/access/access.h
+++ b/engines/access/access.h
@@ -8,12 +8,12 @@
  * 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.
diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp
index 9a86642..6ee4242 100644
--- a/engines/access/amazon/amazon_game.cpp
+++ b/engines/access/amazon/amazon_game.cpp
@@ -8,12 +8,12 @@
  * 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.
diff --git a/engines/access/amazon/amazon_game.h b/engines/access/amazon/amazon_game.h
index 5d87cc4..8f6dffe 100644
--- a/engines/access/amazon/amazon_game.h
+++ b/engines/access/amazon/amazon_game.h
@@ -8,12 +8,12 @@
  * 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.
diff --git a/engines/access/amazon/amazon_logic.cpp b/engines/access/amazon/amazon_logic.cpp
index 0200f7a..2e93617 100644
--- a/engines/access/amazon/amazon_logic.cpp
+++ b/engines/access/amazon/amazon_logic.cpp
@@ -8,12 +8,12 @@
  * 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.
diff --git a/engines/access/amazon/amazon_logic.h b/engines/access/amazon/amazon_logic.h
index c8e7745..5c78172 100644
--- a/engines/access/amazon/amazon_logic.h
+++ b/engines/access/amazon/amazon_logic.h
@@ -8,12 +8,12 @@
  * 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.
diff --git a/engines/access/amazon/amazon_player.cpp b/engines/access/amazon/amazon_player.cpp
index 2780922..b1ed501 100644
--- a/engines/access/amazon/amazon_player.cpp
+++ b/engines/access/amazon/amazon_player.cpp
@@ -8,12 +8,12 @@
  * 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.
diff --git a/engines/access/amazon/amazon_player.h b/engines/access/amazon/amazon_player.h
index 200b530..2d37972 100644
--- a/engines/access/amazon/amazon_player.h
+++ b/engines/access/amazon/amazon_player.h
@@ -8,12 +8,12 @@
  * 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.
diff --git a/engines/access/amazon/amazon_resources.h b/engines/access/amazon/amazon_resources.h
index c4d2cc9..e7afa2a 100644
--- a/engines/access/amazon/amazon_resources.h
+++ b/engines/access/amazon/amazon_resources.h
@@ -8,12 +8,12 @@
  * 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.
diff --git a/engines/access/amazon/amazon_room.cpp b/engines/access/amazon/amazon_room.cpp
index d026f7b..82e6db6 100644
--- a/engines/access/amazon/amazon_room.cpp
+++ b/engines/access/amazon/amazon_room.cpp
@@ -8,12 +8,12 @@
  * 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.
diff --git a/engines/access/amazon/amazon_room.h b/engines/access/amazon/amazon_room.h
index ab92127..6396f80 100644
--- a/engines/access/amazon/amazon_room.h
+++ b/engines/access/amazon/amazon_room.h
@@ -8,12 +8,12 @@
  * 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.
diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp
index 6f9d9c9..633188e 100644
--- a/engines/access/amazon/amazon_scripts.cpp
+++ b/engines/access/amazon/amazon_scripts.cpp
@@ -8,12 +8,12 @@
  * 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.
diff --git a/engines/access/amazon/amazon_scripts.h b/engines/access/amazon/amazon_scripts.h
index 573ffb8..bdbabfc 100644
--- a/engines/access/amazon/amazon_scripts.h
+++ b/engines/access/amazon/amazon_scripts.h
@@ -8,12 +8,12 @@
  * 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.
diff --git a/engines/access/animation.cpp b/engines/access/animation.cpp
index b13fcfd..f030e32 100644
--- a/engines/access/animation.cpp
+++ b/engines/access/animation.cpp
@@ -8,12 +8,12 @@
  * 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.
diff --git a/engines/access/animation.h b/engines/access/animation.h
index 8a39333..97d45c7 100644
--- a/engines/access/animation.h
+++ b/engines/access/animation.h
@@ -8,12 +8,12 @@
  * 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.
diff --git a/engines/access/asurface.cpp b/engines/access/asurface.cpp
index e135ae7..45ce44d 100644
--- a/engines/access/asurface.cpp
+++ b/engines/access/asurface.cpp
@@ -8,12 +8,12 @@
  * 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.
diff --git a/engines/access/asurface.h b/engines/access/asurface.h
index 1395651..833927e 100644
--- a/engines/access/asurface.h
+++ b/engines/access/asurface.h
@@ -8,12 +8,12 @@
  * 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.
diff --git a/engines/access/bubble_box.cpp b/engines/access/bubble_box.cpp
index e9e2a18..572567c 100644
--- a/engines/access/bubble_box.cpp
+++ b/engines/access/bubble_box.cpp
@@ -8,12 +8,12 @@
  * 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.
diff --git a/engines/access/bubble_box.h b/engines/access/bubble_box.h
index 128bd61..8a4d67e 100644
--- a/engines/access/bubble_box.h
+++ b/engines/access/bubble_box.h
@@ -8,12 +8,12 @@
  * 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.
diff --git a/engines/access/char.cpp b/engines/access/char.cpp
index d5eec3e..5bc6707 100644
--- a/engines/access/char.cpp
+++ b/engines/access/char.cpp
@@ -8,12 +8,12 @@
  * 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.
diff --git a/engines/access/char.h b/engines/access/char.h
index 4bd38d7..882e707 100644
--- a/engines/access/char.h
+++ b/engines/access/char.h
@@ -8,12 +8,12 @@
  * 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.
diff --git a/engines/access/data.cpp b/engines/access/data.cpp
index cbc52c0..cf40e81 100644
--- a/engines/access/data.cpp
+++ b/engines/access/data.cpp
@@ -8,12 +8,12 @@
  * 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.
diff --git a/engines/access/data.h b/engines/access/data.h
index 6b44edd..19413ec 100644
--- a/engines/access/data.h
+++ b/engines/access/data.h
@@ -8,12 +8,12 @@
  * 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.
diff --git a/engines/access/debugger.cpp b/engines/access/debugger.cpp
index 5eb615f..fb5c4d5 100644
--- a/engines/access/debugger.cpp
+++ b/engines/access/debugger.cpp
@@ -8,12 +8,12 @@
  * 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.
diff --git a/engines/access/debugger.h b/engines/access/debugger.h
index 6bd2374..f4d8df7 100644
--- a/engines/access/debugger.h
+++ b/engines/access/debugger.h
@@ -8,12 +8,12 @@
  * 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.
diff --git a/engines/access/decompress.cpp b/engines/access/decompress.cpp
index 45ae07d..62bff87 100644
--- a/engines/access/decompress.cpp
+++ b/engines/access/decompress.cpp
@@ -8,12 +8,12 @@
  * 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.
diff --git a/engines/access/decompress.h b/engines/access/decompress.h
index 400aee4..eea4500 100644
--- a/engines/access/decompress.h
+++ b/engines/access/decompress.h
@@ -8,12 +8,12 @@
  * 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.
diff --git a/engines/access/detection.cpp b/engines/access/detection.cpp
index 914f98e..abd5604 100644
--- a/engines/access/detection.cpp
+++ b/engines/access/detection.cpp
@@ -8,17 +8,16 @@
  * 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 "access/access.h"
diff --git a/engines/access/detection_tables.h b/engines/access/detection_tables.h
index ec15076..ed3989a 100644
--- a/engines/access/detection_tables.h
+++ b/engines/access/detection_tables.h
@@ -8,12 +8,12 @@
  * 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.
diff --git a/engines/access/events.cpp b/engines/access/events.cpp
index cd1880b..f504c86 100644
--- a/engines/access/events.cpp
+++ b/engines/access/events.cpp
@@ -8,12 +8,12 @@
  * 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.
diff --git a/engines/access/events.h b/engines/access/events.h
index 3fdcf12..b8c5f0e 100644
--- a/engines/access/events.h
+++ b/engines/access/events.h
@@ -8,12 +8,12 @@
  * 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.
diff --git a/engines/access/files.h b/engines/access/files.h
index f90071d..8b1aef0 100644
--- a/engines/access/files.h
+++ b/engines/access/files.h
@@ -8,12 +8,12 @@
  * 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.
diff --git a/engines/access/font.cpp b/engines/access/font.cpp
index 1aadfb6..3ff1b7e 100644
--- a/engines/access/font.cpp
+++ b/engines/access/font.cpp
@@ -8,12 +8,12 @@
  * 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.
diff --git a/engines/access/font.h b/engines/access/font.h
index d8517e3..6a81205 100644
--- a/engines/access/font.h
+++ b/engines/access/font.h
@@ -8,12 +8,12 @@
  * 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.
diff --git a/engines/access/inventory.cpp b/engines/access/inventory.cpp
index 49fa6e7..d09b784 100644
--- a/engines/access/inventory.cpp
+++ b/engines/access/inventory.cpp
@@ -8,12 +8,12 @@
  * 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.
diff --git a/engines/access/inventory.h b/engines/access/inventory.h
index 820b15b..6a9390e 100644
--- a/engines/access/inventory.h
+++ b/engines/access/inventory.h
@@ -8,12 +8,12 @@
  * 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.
diff --git a/engines/access/player.cpp b/engines/access/player.cpp
index 35c5dad..f56bd69 100644
--- a/engines/access/player.cpp
+++ b/engines/access/player.cpp
@@ -8,12 +8,12 @@
  * 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.
diff --git a/engines/access/player.h b/engines/access/player.h
index 631452f..ab4222e 100644
--- a/engines/access/player.h
+++ b/engines/access/player.h
@@ -8,12 +8,12 @@
  * 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.
diff --git a/engines/access/resources.h b/engines/access/resources.h
index 10f2adb..8d59b1b 100644
--- a/engines/access/resources.h
+++ b/engines/access/resources.h
@@ -8,12 +8,12 @@
  * 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.
diff --git a/engines/access/room.cpp b/engines/access/room.cpp
index f482609..fc9cb6a 100644
--- a/engines/access/room.cpp
+++ b/engines/access/room.cpp
@@ -8,12 +8,12 @@
  * 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.
diff --git a/engines/access/room.h b/engines/access/room.h
index db794db..1ba4af1 100644
--- a/engines/access/room.h
+++ b/engines/access/room.h
@@ -8,12 +8,12 @@
  * 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.
diff --git a/engines/access/screen.cpp b/engines/access/screen.cpp
index 3e6bd7e..d0974bd 100644
--- a/engines/access/screen.cpp
+++ b/engines/access/screen.cpp
@@ -8,12 +8,12 @@
  * 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.
diff --git a/engines/access/screen.h b/engines/access/screen.h
index 775cb6b..1cec75d 100644
--- a/engines/access/screen.h
+++ b/engines/access/screen.h
@@ -8,12 +8,12 @@
  * 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.
diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp
index b1cc289..8b66452 100644
--- a/engines/access/scripts.cpp
+++ b/engines/access/scripts.cpp
@@ -8,12 +8,12 @@
  * 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.
diff --git a/engines/access/scripts.h b/engines/access/scripts.h
index 320da73..fbc3e74 100644
--- a/engines/access/scripts.h
+++ b/engines/access/scripts.h
@@ -8,12 +8,12 @@
  * 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.
diff --git a/engines/access/sound.cpp b/engines/access/sound.cpp
index 57f95c9..a7d96da 100644
--- a/engines/access/sound.cpp
+++ b/engines/access/sound.cpp
@@ -8,12 +8,12 @@
  * 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.
diff --git a/engines/access/sound.h b/engines/access/sound.h
index ed8fe0b..d0f4584 100644
--- a/engines/access/sound.h
+++ b/engines/access/sound.h
@@ -8,12 +8,12 @@
  * 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.
diff --git a/engines/access/video.cpp b/engines/access/video.cpp
index eb50083..b7d5652 100644
--- a/engines/access/video.cpp
+++ b/engines/access/video.cpp
@@ -8,12 +8,12 @@
  * 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.
diff --git a/engines/access/video.h b/engines/access/video.h
index 65d6ad6..6331ea4 100644
--- a/engines/access/video.h
+++ b/engines/access/video.h
@@ -8,12 +8,12 @@
  * 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.


Commit: 7d73acbccc9fd2178c711c973b62e216ffdcfd4b
    https://github.com/scummvm/scummvm/commit/7d73acbccc9fd2178c711c973b62e216ffdcfd4b
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-17T18:36:49+01:00

Commit Message:
ACCESS: Remove useless defines

Changed paths:
    engines/access/access.h



diff --git a/engines/access/access.h b/engines/access/access.h
index 2672f3b..c984620 100644
--- a/engines/access/access.h
+++ b/engines/access/access.h
@@ -58,10 +58,6 @@
  */
 namespace Access {
 
-#define DEBUG_BASIC 1
-#define DEBUG_INTERMEDIATE 2
-#define DEBUG_DETAILED 3
-
 enum {
 	GType_Amazon = 1,
 	GType_MartianMemorandum = 2,


Commit: 9daf9a30c07ede6d5c931af06976d6582fa38ba1
    https://github.com/scummvm/scummvm/commit/9daf9a30c07ede6d5c931af06976d6582fa38ba1
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-17T19:13:23+01:00

Commit Message:
ACCESS: Modify the indentation of constructor when it's multiline

Changed paths:
    engines/access/access.cpp
    engines/access/amazon/amazon_game.cpp



diff --git a/engines/access/access.cpp b/engines/access/access.cpp
index cc44313..dd6d0ea 100644
--- a/engines/access/access.cpp
+++ b/engines/access/access.cpp
@@ -31,9 +31,9 @@
 
 namespace Access {
 
-AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc) :
-		_gameDescription(gameDesc), Engine(syst), _randomSource("Access"),
-		_useItem(_flags[99]), _startup(_flags[170]), _manScaleOff(_flags[172]) {
+AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc)
+	: _gameDescription(gameDesc), Engine(syst), _randomSource("Access"),
+	  _useItem(_flags[99]), _startup(_flags[170]), _manScaleOff(_flags[172]) {
 	_animation = nullptr;
 	_bubbleBox = nullptr;
 	_char = nullptr;
diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp
index 6ee4242..4c57b58 100644
--- a/engines/access/amazon/amazon_game.cpp
+++ b/engines/access/amazon/amazon_game.cpp
@@ -30,14 +30,12 @@ namespace Access {
 
 namespace Amazon {
 
-AmazonEngine::AmazonEngine(OSystem *syst, const AccessGameDescription *gameDesc) :
-AccessEngine(syst, gameDesc),
-		_guardLocation(_flags[122]), _guardFind(_flags[128]), _helpLevel(_flags[167]),
-		_jasMayaFlag(_flags[168]), _moreHelp(_flags[169]), _flashbackFlag(_flags[171]),
-		_riverFlag(_flags[185]), _aniOutFlag(_flags[195]), _badEnd(_flags[218]),
-		_noHints(_flags[219]), _aniFlag(_flags[229]), _allenFlag(_flags[237]),
-		_noSound(_flags[239]) {
-
+AmazonEngine::AmazonEngine(OSystem *syst, const AccessGameDescription *gameDesc)
+	: AccessEngine(syst, gameDesc), _guardLocation(_flags[122]), _guardFind(_flags[128]),
+	  _helpLevel(_flags[167]), _jasMayaFlag(_flags[168]), _moreHelp(_flags[169]),
+	  _flashbackFlag(_flags[171]), _riverFlag(_flags[185]), _aniOutFlag(_flags[195]),
+	  _badEnd(_flags[218]), _noHints(_flags[219]), _aniFlag(_flags[229]),
+	  _allenFlag(_flags[237]), _noSound(_flags[239]) {
 	_ant = nullptr;
 	_cast = nullptr;
 	_guard = nullptr;


Commit: 67a40fd9b0be371fcc80f01d5cda73e7272027d0
    https://github.com/scummvm/scummvm/commit/67a40fd9b0be371fcc80f01d5cda73e7272027d0
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-17T19:14:14+01:00

Commit Message:
ACCESS: Add missing space before semicolumn in constructors

Changed paths:
    engines/access/amazon/amazon_logic.cpp
    engines/access/amazon/amazon_room.cpp
    engines/access/animation.cpp
    engines/access/debugger.cpp
    engines/access/events.cpp
    engines/access/files.cpp
    engines/access/martian/martian_game.cpp
    engines/access/martian/martian_room.cpp
    engines/access/player.cpp



diff --git a/engines/access/amazon/amazon_logic.cpp b/engines/access/amazon/amazon_logic.cpp
index 2e93617..90bc29c 100644
--- a/engines/access/amazon/amazon_logic.cpp
+++ b/engines/access/amazon/amazon_logic.cpp
@@ -32,7 +32,7 @@ namespace Access {
 
 namespace Amazon {
 
-PannedScene::PannedScene(AmazonEngine *vm): AmazonManager(vm) {
+PannedScene::PannedScene(AmazonEngine *vm) : AmazonManager(vm) {
 	for (int i = 0; i < PAN_SIZE; ++i) {
 		_pan[i]._pObject = nullptr;
 		_pan[i]._pImgNum = 0;
@@ -559,7 +559,7 @@ void Opening::doTent() {
 
 /*------------------------------------------------------------------------*/
 
-Plane::Plane(AmazonEngine *vm): PannedScene(vm) {
+Plane::Plane(AmazonEngine *vm) : PannedScene(vm) {
 	_pCount = 0;
 	_planeCount = 0;
 	_propCount = 0;
@@ -969,7 +969,7 @@ void Jungle::scrollJWalk() {
 
 /*------------------------------------------------------------------------*/
 
-Guard::Guard(AmazonEngine *vm): PannedScene(vm) {
+Guard::Guard(AmazonEngine *vm) : PannedScene(vm) {
 	_guardCel = 0;
 	_gCode1 = _gCode2 = 0;
 	_xMid = _yMid = 0;
@@ -1359,7 +1359,7 @@ void Cast::doCast(int param1) {
 
 /*------------------------------------------------------------------------*/
 
-River::River(AmazonEngine *vm): PannedScene(vm) {
+River::River(AmazonEngine *vm) : PannedScene(vm) {
 	_chickenOutFl = false;
 	_rScrollRow = 0;
 	_rScrollCol = 0;
diff --git a/engines/access/amazon/amazon_room.cpp b/engines/access/amazon/amazon_room.cpp
index 82e6db6..8174969 100644
--- a/engines/access/amazon/amazon_room.cpp
+++ b/engines/access/amazon/amazon_room.cpp
@@ -31,7 +31,7 @@ namespace Access {
 
 namespace Amazon {
 
-AmazonRoom::AmazonRoom(AccessEngine *vm): Room(vm) {
+AmazonRoom::AmazonRoom(AccessEngine *vm) : Room(vm) {
 	_game = (AmazonEngine *)vm;
 	_antOutFlag = false;
 	_icon = nullptr;
diff --git a/engines/access/animation.cpp b/engines/access/animation.cpp
index f030e32..126f904 100644
--- a/engines/access/animation.cpp
+++ b/engines/access/animation.cpp
@@ -49,8 +49,7 @@ AnimationResource::~AnimationResource() {
 
 /*------------------------------------------------------------------------*/
 
-Animation::Animation(AccessEngine *vm, Common::SeekableReadStream *stream) :
-		Manager(vm) {
+Animation::Animation(AccessEngine *vm, Common::SeekableReadStream *stream) : Manager(vm) {
 	uint32 startOfs = stream->pos();
 
 	_type = stream->readByte();
diff --git a/engines/access/debugger.cpp b/engines/access/debugger.cpp
index fb5c4d5..6cb2bb6 100644
--- a/engines/access/debugger.cpp
+++ b/engines/access/debugger.cpp
@@ -137,7 +137,7 @@ bool Debugger::Cmd_Cheat(int argc, const char **argv) {
 
 namespace Amazon {
 
-AmazonDebugger::AmazonDebugger(AccessEngine *vm): Debugger(vm) {
+AmazonDebugger::AmazonDebugger(AccessEngine *vm) : Debugger(vm) {
 	registerCmd("chapter", WRAP_METHOD(AmazonDebugger, Cmd_StartChapter));
 }
 
diff --git a/engines/access/events.cpp b/engines/access/events.cpp
index f504c86..c314fe9 100644
--- a/engines/access/events.cpp
+++ b/engines/access/events.cpp
@@ -35,7 +35,7 @@
 
 namespace Access {
 
-EventsManager::EventsManager(AccessEngine *vm): _vm(vm) {
+EventsManager::EventsManager(AccessEngine *vm) : _vm(vm) {
 	_cursorId = CURSOR_NONE;
 	_normalMouse = CURSOR_CROSSHAIRS;
 	_frameCounter = 10;
diff --git a/engines/access/files.cpp b/engines/access/files.cpp
index 1e81b7c..42a7914 100644
--- a/engines/access/files.cpp
+++ b/engines/access/files.cpp
@@ -79,7 +79,7 @@ byte *Resource::data() {
 
 /*------------------------------------------------------------------------*/
 
-FileManager::FileManager(AccessEngine *vm): _vm(vm) {
+FileManager::FileManager(AccessEngine *vm) : _vm(vm) {
 	switch (vm->getGameID()) {
 	case GType_Amazon:
 		if (_vm->isDemo())
diff --git a/engines/access/martian/martian_game.cpp b/engines/access/martian/martian_game.cpp
index e534b6c..6392206 100644
--- a/engines/access/martian/martian_game.cpp
+++ b/engines/access/martian/martian_game.cpp
@@ -31,8 +31,7 @@ namespace Access {
 
 namespace Martian {
 
-MartianEngine::MartianEngine(OSystem *syst, const AccessGameDescription *gameDesc) :
-		AccessEngine(syst, gameDesc) {
+MartianEngine::MartianEngine(OSystem *syst, const AccessGameDescription *gameDesc) : AccessEngine(syst, gameDesc) {
 }
 
 MartianEngine::~MartianEngine() {
diff --git a/engines/access/martian/martian_room.cpp b/engines/access/martian/martian_room.cpp
index 22f456f..e9d1b9d 100644
--- a/engines/access/martian/martian_room.cpp
+++ b/engines/access/martian/martian_room.cpp
@@ -31,7 +31,7 @@ namespace Access {
 
 namespace Martian {
 
-MartianRoom::MartianRoom(AccessEngine *vm): Room(vm) {
+MartianRoom::MartianRoom(AccessEngine *vm) : Room(vm) {
 	_game = (MartianEngine *)vm;
 }
 
diff --git a/engines/access/player.cpp b/engines/access/player.cpp
index f56bd69..828be01 100644
--- a/engines/access/player.cpp
+++ b/engines/access/player.cpp
@@ -38,7 +38,7 @@ Player *Player::init(AccessEngine *vm) {
 	}
 }
 
-Player::Player(AccessEngine *vm): Manager(vm), ImageEntry() {
+Player::Player(AccessEngine *vm) : Manager(vm), ImageEntry() {
 	Common::fill(&_walkOffRight[0], &_walkOffRight[PLAYER_DATA_COUNT], 0);
 	Common::fill(&_walkOffLeft[0], &_walkOffLeft[PLAYER_DATA_COUNT], 0);
 	Common::fill(&_walkOffUp[0], &_walkOffUp[PLAYER_DATA_COUNT], 0);


Commit: df7fa78a860a06d110bad38e559e85257a08c87e
    https://github.com/scummvm/scummvm/commit/df7fa78a860a06d110bad38e559e85257a08c87e
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-17T21:10:50+01:00

Commit Message:
ACCESS: Fix three out of bounds

Changed paths:
    engines/access/amazon/amazon_game.cpp



diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp
index 4c57b58..66ccf3d 100644
--- a/engines/access/amazon/amazon_game.cpp
+++ b/engines/access/amazon/amazon_game.cpp
@@ -54,9 +54,9 @@ AmazonEngine::AmazonEngine(OSystem *syst, const AccessGameDescription *gameDesc)
 	_hintLevel = 0;
 
 	memset(_tileData, 0, sizeof(_tileData));
-	Common::fill(&_help1[0], &_help1[366], 0);
-	Common::fill(&_help2[0], &_help2[366], 0);
-	Common::fill(&_help3[0], &_help3[366], 0);
+	Common::fill(&_help1[0], &_help1[365], 0);
+	Common::fill(&_help2[0], &_help2[365], 0);
+	Common::fill(&_help3[0], &_help3[365], 0);
 	_helpTbl[0] = _help1;
 	_helpTbl[1] = _help2;
 	_helpTbl[2] = _help3;


Commit: ce1f04b1d5c27ca63c1e01b67ae5bfbe5faa0ee9
    https://github.com/scummvm/scummvm/commit/ce1f04b1d5c27ca63c1e01b67ae5bfbe5faa0ee9
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-17T21:19:33+01:00

Commit Message:
ACCESS: Get rid of hardcoded size when using Common::Fill

Changed paths:
    engines/access/amazon/amazon_game.cpp



diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp
index 66ccf3d..933a98a 100644
--- a/engines/access/amazon/amazon_game.cpp
+++ b/engines/access/amazon/amazon_game.cpp
@@ -53,10 +53,10 @@ AmazonEngine::AmazonEngine(OSystem *syst, const AccessGameDescription *gameDesc)
 	_inactiveYOff = 0;
 	_hintLevel = 0;
 
-	memset(_tileData, 0, sizeof(_tileData));
-	Common::fill(&_help1[0], &_help1[365], 0);
-	Common::fill(&_help2[0], &_help2[365], 0);
-	Common::fill(&_help3[0], &_help3[365], 0);
+	Common::fill(&_tileData[0], &_tileData[0] + sizeof(_tileData), 0);
+	Common::fill(&_help1[0], &_help1[0] + sizeof(_help1), 0);
+	Common::fill(&_help2[0], &_help2[0] + sizeof(_help2), 0);
+	Common::fill(&_help3[0], &_help3[0] + sizeof(_help3), 0);
 	_helpTbl[0] = _help1;
 	_helpTbl[1] = _help2;
 	_helpTbl[2] = _help3;


Commit: fe627c5ce19482bdb111df7d5018dfcc94030115
    https://github.com/scummvm/scummvm/commit/fe627c5ce19482bdb111df7d5018dfcc94030115
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-17T21:31:26+01:00

Commit Message:
ACCESS: Fix spacing around semicolumn in class definitions

Changed paths:
    engines/access/amazon/amazon_logic.h
    engines/access/amazon/amazon_player.h
    engines/access/amazon/amazon_scripts.h
    engines/access/animation.h
    engines/access/bubble_box.h
    engines/access/char.h
    engines/access/martian/martian_scripts.h
    engines/access/player.h
    engines/access/room.h
    engines/access/screen.h
    engines/access/scripts.h
    engines/access/video.h



diff --git a/engines/access/amazon/amazon_logic.h b/engines/access/amazon/amazon_logic.h
index 5c78172..a1fb4ee 100644
--- a/engines/access/amazon/amazon_logic.h
+++ b/engines/access/amazon/amazon_logic.h
@@ -42,7 +42,7 @@ public:
 	AmazonManager(AmazonEngine *vm) : _vm(vm) {}
 };
 
-class PannedScene: public AmazonManager {
+class PannedScene : public AmazonManager {
 	struct PanEntry {
 		SpriteResource *_pObject;
 		int _pImgNum;
@@ -78,7 +78,7 @@ public:
 	void mWhileDoOpen();
 };
 
-class Opening: public CampScene {
+class Opening : public CampScene {
 private:
 	int _pCount;
 
@@ -93,7 +93,7 @@ public:
 	void doIntroduction();
 };
 
-class Plane: public PannedScene {
+class Plane : public PannedScene {
 public:
 	int _pCount;
 	Common::Point _position;
@@ -111,7 +111,7 @@ public:
 };
 
 #define JUNGLE_SIZE 3
-class Jungle: public CampScene {
+class Jungle : public CampScene {
 private:
 	void initJWalk2();
 	void jungleMove();
@@ -157,7 +157,7 @@ public:
 	void doCast(int param1);
 };
 
-class River: public PannedScene {
+class River : public PannedScene {
 private:
 	bool _chickenOutFl;
 	const byte *_mapPtr;
@@ -212,7 +212,7 @@ public:
 
 enum AntDirection { ANT_RIGHT = 0, ANT_LEFT = 1 };
 
-class Ant: public AmazonManager {
+class Ant : public AmazonManager {
 private:
 	AntDirection _antDirection;
 	AntDirection _pitDirection;
diff --git a/engines/access/amazon/amazon_player.h b/engines/access/amazon/amazon_player.h
index 2d37972..236b8bd 100644
--- a/engines/access/amazon/amazon_player.h
+++ b/engines/access/amazon/amazon_player.h
@@ -32,7 +32,7 @@ namespace Amazon {
 
 class AmazonEngine;
 
-class AmazonPlayer: public Player {
+class AmazonPlayer : public Player {
 private:
 	AmazonEngine *_game;
 public:
diff --git a/engines/access/amazon/amazon_scripts.h b/engines/access/amazon/amazon_scripts.h
index bdbabfc..e10eefb 100644
--- a/engines/access/amazon/amazon_scripts.h
+++ b/engines/access/amazon/amazon_scripts.h
@@ -32,7 +32,7 @@ namespace Amazon {
 
 class AmazonEngine;
 
-class AmazonScripts: public Scripts {
+class AmazonScripts : public Scripts {
 private:
 	AmazonEngine *_game;
 protected:
diff --git a/engines/access/animation.h b/engines/access/animation.h
index 97d45c7..722f543 100644
--- a/engines/access/animation.h
+++ b/engines/access/animation.h
@@ -82,7 +82,7 @@ public:
 	Animation *getAnimation(int idx) { return _animations[idx]; }
 };
 
-class Animation: public Manager {
+class Animation : public Manager {
 private:
 	Common::Array<AnimationFrame *> _frames;
 
diff --git a/engines/access/bubble_box.h b/engines/access/bubble_box.h
index 8a4d67e..2c05d09 100644
--- a/engines/access/bubble_box.h
+++ b/engines/access/bubble_box.h
@@ -38,7 +38,7 @@ class AccessEngine;
 
 enum BoxType { TYPE_2 = 2, TYPE_4 = 4 };
 
-class BubbleBox: public Manager {
+class BubbleBox : public Manager {
 private:
 	int _startItem, _startBox;
 	int _charCol, _rowOff;
diff --git a/engines/access/char.h b/engines/access/char.h
index 882e707..e89cdae 100644
--- a/engines/access/char.h
+++ b/engines/access/char.h
@@ -46,7 +46,7 @@ public:
 	CharEntry();
 };
 
-class CharManager: public Manager {
+class CharManager : public Manager {
 private:
 	void charMenu();
 public:
diff --git a/engines/access/martian/martian_scripts.h b/engines/access/martian/martian_scripts.h
index 9f90643..fc7495f 100644
--- a/engines/access/martian/martian_scripts.h
+++ b/engines/access/martian/martian_scripts.h
@@ -32,7 +32,7 @@ namespace Martian {
 
 class MartianEngine;
 
-class MartianScripts: public Scripts {
+class MartianScripts : public Scripts {
 private:
 	MartianEngine *_game;
 protected:
diff --git a/engines/access/player.h b/engines/access/player.h
index ab4222e..7c8e9a2 100644
--- a/engines/access/player.h
+++ b/engines/access/player.h
@@ -38,7 +38,7 @@ enum Direction { NONE = 0, UP = 1, DOWN = 2, LEFT = 3, RIGHT = 4,
 
 class AccessEngine;
 
-class Player: public ImageEntry, public Manager {
+class Player : public ImageEntry, public Manager {
 protected:
 	int _leftDelta, _rightDelta;
 	int _upDelta, _downDelta;
diff --git a/engines/access/room.h b/engines/access/room.h
index 1ba4af1..44279fa 100644
--- a/engines/access/room.h
+++ b/engines/access/room.h
@@ -60,7 +60,7 @@ public:
 
 enum Function { FN_NONE = 0, FN_CLEAR1 = 1, FN_CLEAR2 = 2, FN_RELOAD = 3, FN_BREAK = 4 };
 
-class Room: public Manager {
+class Room : public Manager {
 private:
 	void roomLoop();
 
diff --git a/engines/access/screen.h b/engines/access/screen.h
index 1cec75d..bf4ccea 100644
--- a/engines/access/screen.h
+++ b/engines/access/screen.h
@@ -47,7 +47,7 @@ struct ScreenSave {
 	int _screenYOff;
 };
 
-class Screen: public ASurface {
+class Screen : public ASurface {
 private:
 	AccessEngine *_vm;
 	byte _tempPalette[PALETTE_SIZE];
diff --git a/engines/access/scripts.h b/engines/access/scripts.h
index fbc3e74..e12f282 100644
--- a/engines/access/scripts.h
+++ b/engines/access/scripts.h
@@ -35,7 +35,7 @@ class Scripts;
 #define SCRIPT_START_BYTE 0xE0
 #define ROOM_SCRIPT 2000
 
-class Scripts: public Manager {
+class Scripts : public Manager {
 private:
 	Resource *_resource;
 	int _specialFunction;
diff --git a/engines/access/video.h b/engines/access/video.h
index 6331ea4..17825db 100644
--- a/engines/access/video.h
+++ b/engines/access/video.h
@@ -33,7 +33,7 @@ namespace Access {
 
 enum VideoFlags { VIDEOFLAG_NONE = 0, VIDEOFLAG_BG = 1 };
 
-class VideoPlayer: public Manager {
+class VideoPlayer : public Manager {
 	struct VideoHeader {
 		int _frameCount;
 		int _width, _height;


Commit: e141da25e80fcf9c124661883a1818e13168bd93
    https://github.com/scummvm/scummvm/commit/e141da25e80fcf9c124661883a1818e13168bd93
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-17T21:39:26+01:00

Commit Message:
ACCESS: Use a uint instead of a int in a loop based on size()

Changed paths:
    engines/access/animation.cpp



diff --git a/engines/access/animation.cpp b/engines/access/animation.cpp
index 126f904..a1b7952 100644
--- a/engines/access/animation.cpp
+++ b/engines/access/animation.cpp
@@ -78,7 +78,7 @@ Animation::Animation(AccessEngine *vm, Common::SeekableReadStream *stream) : Man
 }
 
 Animation::~Animation() {
-	for (int i = 0; i < (int)_frames.size(); ++i)
+	for (uint i = 0; i < _frames.size(); ++i)
 		delete _frames[i];
 }
 


Commit: bb01fa31f80e45f0537b3ea02083eed113c41f9c
    https://github.com/scummvm/scummvm/commit/bb01fa31f80e45f0537b3ea02083eed113c41f9c
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-17T22:31:29+01:00

Commit Message:
ACCESS: Constify some resources

Changed paths:
    engines/access/amazon/amazon_resources.cpp
    engines/access/amazon/amazon_resources.h



diff --git a/engines/access/amazon/amazon_resources.cpp b/engines/access/amazon/amazon_resources.cpp
index e61c704..2010c7d 100644
--- a/engines/access/amazon/amazon_resources.cpp
+++ b/engines/access/amazon/amazon_resources.cpp
@@ -309,7 +309,7 @@ const byte CURSHELP[] = {
 	0x04, 0x06, 0x24, 0x22, 0x22, 0x22, 0x22, 0x20,
 	0x05, 0x04, 0x20, 0x20, 0x20, 0x20
 };
-const byte *CURSORS[10] = {
+const byte *const CURSORS[10] = {
 	MOUSE0, MOUSE1, MOUSE2, MOUSE3, CURSEYE, CURSHAND, CURSGET, CURSCLIMB, CURSTALK, CURSHELP
 };
 
@@ -713,7 +713,7 @@ const byte PIT[] = {
 	0x62, 0x0, 0x4D, 0x0, 0x2, 0x0, 0xFF, 0xFF, 0x0
 };
 
-const byte *ROOM_TABLE[] = {
+const byte *const ROOM_TABLE[] = {
 	CREDITS, nullptr, nullptr, nullptr, ALLISTER, HALL, JASONLAB, nullptr,
 	ALLENLAB, OUTVAULT, VAULT, LIBRARY, JASAPT, RANSACKED, MEAN1, FLYSOUTH,
 	CUZCO, INAIR, GREENMONKEY, INPLANE, PILFALL, COCKPIT, CRASH, SINKING,
@@ -724,7 +724,7 @@ const byte *ROOM_TABLE[] = {
 	CAVE, nullptr, nullptr, nullptr, PIT, nullptr, nullptr
 };
 
-const char *ROOM_DESCR[] = {
+const char *const ROOM_DESCR[] = {
 	"Credits", nullptr, nullptr, nullptr, "Outside of Allister Center",
 	"Hall", "Jason's Lab", nullptr, "Allen's Lab", "Outside of the Vault",
 	"Inside the Vault", "Reader", "Jason's Apartment", "Jason's ransacked apartment", "Cutscene 1",
@@ -1080,7 +1080,7 @@ const byte ROOM_TABLE62_DEMO[] = {
 	0x00, 0x00, 0x00, 0x01, 0x00, 0xFF, 0xFF, 0x00
 };
 
-const byte *ROOM_TABLE_DEMO[] = {
+const byte *const ROOM_TABLE_DEMO[] = {
 	ROOM_TABLE1_DEMO, nullptr, nullptr, nullptr, ROOM_TABLE5_DEMO,
 	ROOM_TABLE6_DEMO, ROOM_TABLE7_DEMO, nullptr, ROOM_TABLE9_DEMO, ROOM_TABLE10_DEMO,
 	ROOM_TABLE11_DEMO, ROOM_TABLE12_DEMO, ROOM_TABLE13_DEMO, ROOM_TABLE14_DEMO, ROOM_TABLE15_DEMO,
@@ -1526,7 +1526,7 @@ const byte CHAP8[] = {
 	0x60, 0x00, 0x02, 0x00, 0xFF, 0xFF 
 };
 
-const byte *CHARTBL[] = {
+const byte *const CHARTBL[] = {
 	ELAINE, LIB, FLASHBACK, ALLENDIE, OVERBOARD, PILOT2, TIKAGENT,
 	BARTENDER, PILOT1, COOK, BEXPLODE, THORNICK, MAYA, CAPTAIN,
 	ALLEN, ARCH, GUARD1, MCANOE, CAMPFIRE, COLONEL, SOLDIERS,
@@ -1535,7 +1535,7 @@ const byte *CHARTBL[] = {
 	CRACK, LETTER
 };
 
-const byte *CHARTBL_DEMO[] = {
+const byte *const CHARTBL_DEMO[] = {
 	ELAINE, LIB, FLASHBACK, ALLENDIE, OVERBOARD_DEMO, PILOT2, TIKAGENT,
 	BARTENDER, PILOT1, COOK, BEXPLODE, THORNICK, MAYA, CAPTAIN,
 	ALLEN, ARCH, GUARD1, MCANOE, CAMPFIRE, COLONEL, SOLDIERS,
@@ -2156,7 +2156,7 @@ const byte MAP2[32] = {
 	0, 1, 0, 1, 0, 0, 0, 0xFF
 };
 
-const byte *MAPTBL[3] = {MAP0, MAP1, MAP2};
+const byte *const MAPTBL[3] = {MAP0, MAP1, MAP2};
 
 const int DOWNRIVEROBJ[14][4] = {
 	{ 3, 77, 0, 40 },
diff --git a/engines/access/amazon/amazon_resources.h b/engines/access/amazon/amazon_resources.h
index e7afa2a..a952860 100644
--- a/engines/access/amazon/amazon_resources.h
+++ b/engines/access/amazon/amazon_resources.h
@@ -45,7 +45,7 @@ struct RiverStruct {
 extern const char *const FILENAMES[];
 extern const char *const FILENAMES_DEMO[];
 
-extern const byte *CURSORS[10];
+extern const byte *const CURSORS[10];
 
 extern const int TRAVEL_POS[][2];
 
@@ -62,13 +62,13 @@ extern const int OVEROFFULY[];
 extern const int OVEROFFDLX[];
 extern const int OVEROFFDLY[];
 
-extern const byte *ROOM_TABLE[];
-extern const char *ROOM_DESCR[];
-extern const byte *ROOM_TABLE_DEMO[];
+extern const byte *const ROOM_TABLE[];
+extern const char *const ROOM_DESCR[];
+extern const byte *const ROOM_TABLE_DEMO[];
 extern const int ROOM_NUMB;
 
-extern const byte *CHARTBL[];
-extern const byte *CHARTBL_DEMO[];
+extern const byte *const CHARTBL[];
+extern const byte *const CHARTBL_DEMO[];
 
 extern const char *const INVENTORY_NAMES[];
 
@@ -123,7 +123,7 @@ extern const byte MAP0[26];
 extern const byte MAP1[27];
 extern const byte MAP2[32];
 
-extern const byte *MAPTBL[3];
+extern const byte *const MAPTBL[3];
 
 extern const int DOWNRIVEROBJ[14][4];
 


Commit: c57f1919603c6a7223cb02c637f3682dfb96975f
    https://github.com/scummvm/scummvm/commit/c57f1919603c6a7223cb02c637f3682dfb96975f
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-17T22:38:01+01:00

Commit Message:
ACCESS: Constify some resources in MM too

Changed paths:
    engines/access/martian/martian_resources.cpp
    engines/access/martian/martian_resources.h



diff --git a/engines/access/martian/martian_resources.cpp b/engines/access/martian/martian_resources.cpp
index 046e06c..d2b5dfd 100644
--- a/engines/access/martian/martian_resources.cpp
+++ b/engines/access/martian/martian_resources.cpp
@@ -83,7 +83,7 @@ const byte MOUSE3[] = {
 	6, 6, 5, 1, 11, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 0,
 	0, 0, 0, 0, 0
 };
-const byte *CURSORS[4] = { MOUSE0, MOUSE1, MOUSE2, MOUSE3 };
+const byte *const CURSORS[4] = { MOUSE0, MOUSE1, MOUSE2, MOUSE3 };
 
 const int TRAVEL_POS[][2] = {
 	{ -1, 0 },
@@ -411,7 +411,7 @@ const byte ROOM_TABLE47[] = {
 	0xff, 0xff, 0x2b, 0x00, 0x04, 0x00, 0xff, 0xff, 0x2e, 0x00,
 	0x04, 0x00, 0x01, 0x00, 0xff, 0xff, 0x00,
 };
-const byte *ROOM_TABLE[] = {
+const byte *const ROOM_TABLE[] = {
 	nullptr, ROOM_TABLE1, ROOM_TABLE2, ROOM_TABLE3, ROOM_TABLE4, ROOM_TABLE5, ROOM_TABLE6,
 	ROOM_TABLE7, ROOM_TABLE8, ROOM_TABLE9, nullptr, ROOM_TABLE11, nullptr, ROOM_TABLE13,
 	ROOM_TABLE14, ROOM_TABLE15, ROOM_TABLE16, ROOM_TABLE17, ROOM_TABLE18, nullptr, nullptr,
@@ -421,7 +421,7 @@ const byte *ROOM_TABLE[] = {
 	nullptr, nullptr, nullptr, nullptr, nullptr, ROOM_TABLE47
 };
 
-const char *ROOM_DESCR[] = {
+const char *const ROOM_DESCR[] = {
 	nullptr, "TBD ROOM_TABLE1", "TBD ROOM_TABLE2", "TBD ROOM_TABLE3", "TBD ROOM_TABLE4",
 	"TBD ROOM_TABLE5", "TBD ROOM_TABLE6", "TBD ROOM_TABLE7", "TBD ROOM_TABLE8", "TBD ROOM_TABLE9",
 	nullptr, "TBD ROOM_TABLE11", nullptr, "TBD ROOM_TABLE13", "TBD ROOM_TABLE14",
@@ -650,7 +650,7 @@ const byte CHAR_TABLE27[] = {
 	0x00, 0x49, 0x00, 0x10, 0x00, 0x49, 0x00, 0x09, 0x00, 0x49,
 	0x00, 0x11, 0x00, 0xff, 0xff,
 };
-const byte *CHAR_TABLE[] = {
+const byte *const CHAR_TABLE[] = {
 	CHAR_TABLE0, nullptr, CHAR_TABLE2, CHAR_TABLE3, CHAR_TABLE4, CHAR_TABLE5,
 	CHAR_TABLE6, CHAR_TABLE7, CHAR_TABLE8, CHAR_TABLE9, CHAR_TABLE10,
 	CHAR_TABLE11, CHAR_TABLE12, CHAR_TABLE13, nullptr, CHAR_TABLE15,
diff --git a/engines/access/martian/martian_resources.h b/engines/access/martian/martian_resources.h
index b9584ba..a52967d 100644
--- a/engines/access/martian/martian_resources.h
+++ b/engines/access/martian/martian_resources.h
@@ -31,17 +31,17 @@ namespace Martian {
 
 extern const char *const FILENAMES[];
 
-extern const byte *CURSORS[4];
+extern const byte *const CURSORS[4];
 
 extern const int TRAVEL_POS[][2];
 
 extern const char *const INVENTORY_NAMES[];
 
-extern const byte *ROOM_TABLE[];
-extern const char *ROOM_DESCR[];
+extern const byte *const ROOM_TABLE[];
+extern const char *const ROOM_DESCR[];
 extern const int ROOM_NUMB;
 
-extern const byte *CHAR_TABLE[];
+extern const byte *const CHAR_TABLE[];
 
 extern const int COMBO_TABLE[54][4];
 


Commit: 223038924b226b67e93081a5b1c7ed18310c9834
    https://github.com/scummvm/scummvm/commit/223038924b226b67e93081a5b1c7ed18310c9834
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-17T22:49:01+01:00

Commit Message:
ACCESS: Get rid of a goto

Changed paths:
    engines/access/player.cpp
    engines/access/player.h



diff --git a/engines/access/player.cpp b/engines/access/player.cpp
index 828be01..83f075e 100644
--- a/engines/access/player.cpp
+++ b/engines/access/player.cpp
@@ -657,6 +657,19 @@ void Player::plotCom3() {
 	plotCom2();
 }
 
+void Player::checkScrollUp() {
+	if ((_playerDirection == DOWNRIGHT || _playerDirection == DOWNLEFT ||
+		_playerDirection == DOWN) && (_vm->_screen->_clipHeight -
+		_playerY - _scrollThreshold) <= 0) {
+			// Scroll up
+			if (scrollUp()) {
+				_scrollEnd = 4;
+				_vm->_screen->_scrollY &= TILE_HEIGHT;
+				_scrollFlag = true;
+			}
+	}
+}
+
 void Player::checkScroll() {
 	_scrollFlag = false;
 	if (_playerDirection == NONE)
@@ -667,7 +680,7 @@ void Player::checkScroll() {
 		// Scroll right
 		if (!scrollRight()) {
 			if (_playerDirection == DOWNLEFT)
-				goto scrollUp;
+				checkScrollUp();
 
 			return;
 		}
@@ -677,7 +690,7 @@ void Player::checkScroll() {
 		// Scroll left
 		if (!scrollLeft()) {
 			if (_playerDirection == DOWNRIGHT)
-				goto scrollUp;
+				checkScrollUp();
 
 			return;
 		}
@@ -687,17 +700,7 @@ void Player::checkScroll() {
 			_playerDirection == UP) && _playerY <= _scrollThreshold) {
 		scrollDown();
 	} else {
-scrollUp:
-		if ((_playerDirection == DOWNRIGHT || _playerDirection == DOWNLEFT ||
-			_playerDirection == DOWN) && (_vm->_screen->_clipHeight -
-			_playerY - _scrollThreshold) <= 0) {
-			// Scroll up
-			if (scrollUp()) {
-				_scrollEnd = 4;
-				_vm->_screen->_scrollY &= TILE_HEIGHT;
-				_scrollFlag = true;
-			}
-		}
+		checkScrollUp();
 	}
 }
 
diff --git a/engines/access/player.h b/engines/access/player.h
index 7c8e9a2..e3cf5c5 100644
--- a/engines/access/player.h
+++ b/engines/access/player.h
@@ -66,6 +66,7 @@ protected:
 	void walkDownLeft();
 	void walkUpRight();
 	void walkDownRight();
+	void checkScrollUp();
 	bool scrollUp();
 	bool scrollDown();
 	bool scrollLeft();


Commit: 240b9dcaeba7f28800df1cd6929ceed4bb3cff33
    https://github.com/scummvm/scummvm/commit/240b9dcaeba7f28800df1cd6929ceed4bb3cff33
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-17T22:54:29+01:00

Commit Message:
ACCESS: Format Direction enum as suggested by LordHoto

Changed paths:
    engines/access/player.h



diff --git a/engines/access/player.h b/engines/access/player.h
index e3cf5c5..26caec6 100644
--- a/engines/access/player.h
+++ b/engines/access/player.h
@@ -33,8 +33,17 @@ namespace Access {
 
 #define PLAYER_DATA_COUNT 8
 
-enum Direction { NONE = 0, UP = 1, DOWN = 2, LEFT = 3, RIGHT = 4,
-	UPRIGHT = 5, DOWNRIGHT = 6, UPLEFT = 7, DOWNLEFT = 8 };
+enum Direction {
+	NONE = 0,
+	UP = 1,
+	DOWN = 2,
+	LEFT = 3,
+	RIGHT = 4,
+	UPRIGHT = 5,
+	DOWNRIGHT = 6,
+	UPLEFT = 7,
+	DOWNLEFT = 8
+};
 
 class AccessEngine;
 


Commit: 207c4012ad33f7f11b5375c1478ed2f5e13679b9
    https://github.com/scummvm/scummvm/commit/207c4012ad33f7f11b5375c1478ed2f5e13679b9
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-17T23:05:22+01:00

Commit Message:
ACCESS: replace an assert by an error as suggested by LordHoto

Changed paths:
    engines/access/scripts.cpp



diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp
index 8b66452..79d7469 100644
--- a/engines/access/scripts.cpp
+++ b/engines/access/scripts.cpp
@@ -98,7 +98,9 @@ int Scripts::executeScript() {
 		while ((_scriptCommand = _data->readByte()) == SCRIPT_START_BYTE)
 			_data->skip(2);
 
-		assert(_scriptCommand >= 0x80);
+		if (_scriptCommand < 0x80)
+			error("Unexpected opcode value %d", _scriptCommand);
+
 		executeCommand(_scriptCommand - 0x80);
 	} while (!_endFlag && !_vm->shouldQuitOrRestart());
 


Commit: 79b51f20e48f9f93a519f548ba42afdcb8a03899
    https://github.com/scummvm/scummvm/commit/79b51f20e48f9f93a519f548ba42afdcb8a03899
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-17T23:08:54+01:00

Commit Message:
ACCESS: Use clear to empty Common::String variables

Changed paths:
    engines/access/font.cpp
    engines/access/scripts.cpp



diff --git a/engines/access/font.cpp b/engines/access/font.cpp
index 3ff1b7e..da8f0b6 100644
--- a/engines/access/font.cpp
+++ b/engines/access/font.cpp
@@ -112,7 +112,7 @@ bool Font::getLine(Common::String &s, int maxWidth, Common::String &line, int &w
 		// If this was the last character of the string, let it go
 		if (*src == '\0') {
 			line = Common::String(s.c_str(), src);
-			s = "";
+			s.clear();
 			return true;
 		}
 
diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp
index 79d7469..59d89af 100644
--- a/engines/access/scripts.cpp
+++ b/engines/access/scripts.cpp
@@ -661,7 +661,7 @@ void Scripts::cmdTexChoice() {
 
 	findNull();
 
-	tmpStr = "";
+	tmpStr.clear();
 	while ((v = _data->readByte()) != 0)
 		tmpStr += (char)v;
 
@@ -676,7 +676,7 @@ void Scripts::cmdTexChoice() {
 	findNull();
 
 	bool choice3Fl = false;
-	tmpStr = "";
+	tmpStr.clear();
 	while ((v = _data->readByte()) != 0)
 		tmpStr += (char)v;
 


Commit: cd4183a4638e964cc7b4c6b5c7e31c1bec9ffb99
    https://github.com/scummvm/scummvm/commit/cd4183a4638e964cc7b4c6b5c7e31c1bec9ffb99
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-17T23:15:13+01:00

Commit Message:
ACCESS: Fix indentation of METHODS in animate()

Changed paths:
    engines/access/animation.cpp



diff --git a/engines/access/animation.cpp b/engines/access/animation.cpp
index a1b7952..045382a 100644
--- a/engines/access/animation.cpp
+++ b/engines/access/animation.cpp
@@ -85,9 +85,10 @@ Animation::~Animation() {
 typedef void(Animation::*AnimationMethodPtr)();
 
 void Animation::animate() {
-	static const AnimationMethodPtr METHODS[8] =
-	{ &Animation::anim0, &Animation::anim1, &Animation::anim2, &Animation::anim3,
-	&Animation::anim4, &Animation::animNone, &Animation::animNone, &Animation::anim7 };
+	static const AnimationMethodPtr METHODS[8] = {
+	   &Animation::anim0, &Animation::anim1, &Animation::anim2, &Animation::anim3,
+	   &Animation::anim4, &Animation::animNone, &Animation::animNone, &Animation::anim7
+	};
 
 	(this->*METHODS[_type])();
 }


Commit: a9903237034859883618de2b86a08fe5ec572881
    https://github.com/scummvm/scummvm/commit/a9903237034859883618de2b86a08fe5ec572881
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-17T23:21:13+01:00

Commit Message:
ACCESS: Format the definition of ImagerFlag

and fix a comment

Changed paths:
    engines/access/animation.cpp
    engines/access/asurface.h



diff --git a/engines/access/animation.cpp b/engines/access/animation.cpp
index 045382a..548e7db 100644
--- a/engines/access/animation.cpp
+++ b/engines/access/animation.cpp
@@ -191,7 +191,7 @@ void Animation::anim4() {
 }
 
 void Animation::animNone() {
-	// No implementation
+	// Empty implementation
 }
 
 void Animation::anim7() {
diff --git a/engines/access/asurface.h b/engines/access/asurface.h
index 833927e..6ffbf0e 100644
--- a/engines/access/asurface.h
+++ b/engines/access/asurface.h
@@ -138,8 +138,12 @@ public:
 	SpriteFrame *getFrame(int idx) { return _frames[idx]; }
 };
 
-enum ImageFlag { IMGFLAG_CROPPED = 1, IMGFLAG_BACKWARDS = 2, IMGFLAG_DRAWN = 4,
-	IMGFLAG_UNSCALED = 8 };
+enum ImageFlag {
+	IMGFLAG_CROPPED = 1,
+	IMGFLAG_BACKWARDS = 2,
+	IMGFLAG_DRAWN = 4,
+	IMGFLAG_UNSCALED = 8
+};
 
 class ImageEntry {
 public:


Commit: beba3cd3f21f60ba560a7af3485389c0f3dcc065
    https://github.com/scummvm/scummvm/commit/beba3cd3f21f60ba560a7af3485389c0f3dcc065
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-17T23:22:50+01:00

Commit Message:
ACCESS: Fix indentation issue pointed out by _sev

Changed paths:
    engines/access/detection.cpp



diff --git a/engines/access/detection.cpp b/engines/access/detection.cpp
index abd5604..1903bf2 100644
--- a/engines/access/detection.cpp
+++ b/engines/access/detection.cpp
@@ -77,7 +77,7 @@ Common::Platform AccessEngine::getPlatform() const {
 static const PlainGameDescriptor AccessGames[] = {
 	{"Access", "Access"},
 	{"amazon", "Amazon: Guardians of Eden"},
-	{ "martian", "Martian Memorandum"},
+	{"martian", "Martian Memorandum"},
 	{0, 0}
 };
 


Commit: c11b6e3eb36f736de2a726fabfbfe7ee21466d34
    https://github.com/scummvm/scummvm/commit/c11b6e3eb36f736de2a726fabfbfe7ee21466d34
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-17T23:27:55+01:00

Commit Message:
ACCESS: Add original engine dates

Changed paths:
    engines/access/detection.cpp



diff --git a/engines/access/detection.cpp b/engines/access/detection.cpp
index 1903bf2..441740c 100644
--- a/engines/access/detection.cpp
+++ b/engines/access/detection.cpp
@@ -94,7 +94,7 @@ public:
 	}
 
 	virtual const char *getOriginalCopyright() const {
-		return "Access (c)";
+		return "Access Engine (c) 1989-1994 Access Software";
 	}
 
 	virtual bool hasFeature(MetaEngineFeature f) const;


Commit: 8fe8cf8e437df59874b0337946708cff6bb56c6d
    https://github.com/scummvm/scummvm/commit/8fe8cf8e437df59874b0337946708cff6bb56c6d
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-17T23:35:12+01:00

Commit Message:
ACCESS: Use AD_ENTRY1s in detection tables

Changed paths:
    engines/access/detection_tables.h



diff --git a/engines/access/detection_tables.h b/engines/access/detection_tables.h
index ed3989a..88a6447 100644
--- a/engines/access/detection_tables.h
+++ b/engines/access/detection_tables.h
@@ -24,14 +24,13 @@ namespace Access {
 
 static const AccessGameDescription gameDescriptions[] = {
 	{
-		// Amazon Guadians of Eden - Floppy English
+		// Amazon Guardians of Eden - Floppy English
+		// 3.5" and 5.25" floppies provided by Strangerke had the same md5
+		// Except the sound file. The executable is also identical
 		{
 			"amazon",
 			0,
-			{
-				{ "c00.ap", 0, "dcabf69d5a0d911168cb73511ebaead0", 331481 },
-				AD_LISTEND
-			},
+			AD_ENTRY1s("c00.ap", "dcabf69d5a0d911168cb73511ebaead0", 331481),
 			Common::EN_ANY,
 			Common::kPlatformDOS,
 			ADGF_NO_FLAGS,
@@ -44,12 +43,9 @@ static const AccessGameDescription gameDescriptions[] = {
 	// Amazon Guardians of Eden - Demo English
 	{
 		{
-		"amazon",
-		"Demo",
-			{
-				{ "c25.ap", 0, "5baba0c052d22157499bfa05cb1ed5b7", 65458 },
-				AD_LISTEND
-			},
+			"amazon",
+			"Demo",
+			AD_ENTRY1s("c25.ap", "5baba0c052d22157499bfa05cb1ed5b7", 65458),
 			Common::EN_ANY,
 			Common::kPlatformDOS,
 			ADGF_DEMO,
@@ -64,10 +60,7 @@ static const AccessGameDescription gameDescriptions[] = {
 		{
 			"amazon",
 			"CD",
-			{
-				{ "checksum.crc", 0, "bef85478132fec74cb5d9067f3a37d24", 8 },
-				AD_LISTEND
-			},
+			AD_ENTRY1s("checksum.crc", "bef85478132fec74cb5d9067f3a37d24", 8),
 			Common::EN_ANY,
 			Common::kPlatformDOS,
 			ADGF_CD,
@@ -82,10 +75,7 @@ static const AccessGameDescription gameDescriptions[] = {
 		{
 			"martian",
 			nullptr,
-			{
-				{ "r00.ap", 0, "af98db5ee7f9ef86c6b1f43187a3691b", 31 },
-				AD_LISTEND
-			},
+			AD_ENTRY1s("r00.ap", "af98db5ee7f9ef86c6b1f43187a3691b", 31),
 			Common::EN_ANY,
 			Common::kPlatformDOS,
 			ADGF_NO_FLAGS,


Commit: 20bcc7f7aac3f19e002f25dec14e4def7b9c1ca5
    https://github.com/scummvm/scummvm/commit/20bcc7f7aac3f19e002f25dec14e4def7b9c1ca5
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-17T23:45:41+01:00

Commit Message:
ACCESS: Rename CMDPUSHLOCATION

Changed paths:
    engines/access/scripts.cpp
    engines/access/scripts.h



diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp
index 59d89af..ac10fe3 100644
--- a/engines/access/scripts.cpp
+++ b/engines/access/scripts.cpp
@@ -132,7 +132,7 @@ void Scripts::executeCommand(int commandIndex) {
 		&Scripts::cmdSetConPos, &Scripts::cmdCheckVFrame, &Scripts::cmdJumpChoice,
 		&Scripts::cmdReturnChoice, &Scripts::cmdClearBlock, &Scripts::cmdLoadSound,
 		&Scripts::cmdFreeSound, &Scripts::cmdSetVideoSound, &Scripts::cmdPlayVideoSound,
-		&Scripts::cmdPrintWatch, &Scripts::cmdDispAbout, &Scripts::CMDPUSHLOCATION,
+		&Scripts::cmdPrintWatch, &Scripts::cmdDispAbout, &Scripts::cmdPushLocation,
 		&Scripts::cmdCheckTravel, &Scripts::cmdBlock, &Scripts::cmdPlayerOff,
 		&Scripts::cmdPlayerOn, &Scripts::cmdDead, &Scripts::cmdFadeOut,
 		&Scripts::cmdEndVideo
@@ -826,7 +826,7 @@ void Scripts::cmdPlayVideoSound() {
 
 void Scripts::cmdPrintWatch() {
 	if (_vm->isCD()) {
-		CMDPUSHLOCATION();
+		cmdPushLocation();
 		return;
 	}
 	error("TODO: DEMO - cmdPrintWatch");
@@ -834,19 +834,19 @@ void Scripts::cmdPrintWatch() {
 
 void Scripts::cmdDispAbout() {
 	if (_vm->isCD()) {
-		CMDPUSHLOCATION();
+		cmdPushLocation();
 		return;
 	}
 	error("TODO: DEMO - cmdDispAbout");
 }
 
-void Scripts::CMDPUSHLOCATION() {
-	error("TODO CMDPUSHLOCATION");
+void Scripts::cmdPushLocation() {
+	error("TODO cmdPushLocation");
 }
 
 void Scripts::cmdCheckTravel() {
 	if (_vm->isCD()) {
-		CMDPUSHLOCATION();
+		cmdPushLocation();
 		return;
 	}
 	error("TODO: DEMO - cmdCheckTravel");
@@ -854,7 +854,7 @@ void Scripts::cmdCheckTravel() {
 
 void Scripts::cmdBlock() {
 	if (_vm->isCD()) {
-		CMDPUSHLOCATION();
+		cmdPushLocation();
 		return;
 	}
 	error("TODO: DEMO - cmdBlock");
diff --git a/engines/access/scripts.h b/engines/access/scripts.h
index e12f282..cfadf6d 100644
--- a/engines/access/scripts.h
+++ b/engines/access/scripts.h
@@ -119,7 +119,7 @@ protected:
 	void cmdPlayVideoSound();
 	void cmdPrintWatch();
 	void cmdDispAbout();
-	void CMDPUSHLOCATION();
+	void cmdPushLocation();
 	void cmdCheckTravel();
 	void cmdBlock();
 	void cmdPlayerOff();


Commit: 7895c5408c37c54dcb5c30ddf7ae09f91052d768
    https://github.com/scummvm/scummvm/commit/7895c5408c37c54dcb5c30ddf7ae09f91052d768
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-18T07:14:21+01:00

Commit Message:
ACCESS: Constify general messages

Changed paths:
    engines/access/resources.cpp



diff --git a/engines/access/resources.cpp b/engines/access/resources.cpp
index 6282d93..4157cdf 100644
--- a/engines/access/resources.cpp
+++ b/engines/access/resources.cpp
@@ -64,14 +64,14 @@ const int RMOUSE[10][2] = {
 	{ 142, 177 }, { 178, 212 }, { 213, 248 }, { 249, 283 }, { 284, 318 }
 };
 
-const char *LOOK_MESSAGE = "LOOKING THERE REVEALS NOTHING OF INTEREST.";
-const char *GET_MESSAGE = "YOU CAN'T TAKE THAT.";
-const char *OPEN_MESSAGE = "THAT DOESN'T OPEN.";
-const char *MOVE_MESSAGE = "THAT WON'T MOVE.";
-const char *USE_MESSAGE = "THAT DOESN'T SEEM TO WORK.";
-const char *GO_MESSAGE = "YOU CAN'T CLIMB THAT.";
-const char *HELP_MESSAGE = "THIS OBJECT REQUIRES NO HINTS";
-const char *TALK_MESSAGE      = "THERE SEEMS TO BE NO RESPONSE.";
+const char *const LOOK_MESSAGE = "LOOKING THERE REVEALS NOTHING OF INTEREST.";
+const char *const GET_MESSAGE  = "YOU CAN'T TAKE THAT.";
+const char *const OPEN_MESSAGE = "THAT DOESN'T OPEN.";
+const char *const MOVE_MESSAGE = "THAT WON'T MOVE.";
+const char *const USE_MESSAGE  = "THAT DOESN'T SEEM TO WORK.";
+const char *const GO_MESSAGE   = "YOU CAN'T CLIMB THAT.";
+const char *const HELP_MESSAGE = "THIS OBJECT REQUIRES NO HINTS";
+const char *const TALK_MESSAGE = "THERE SEEMS TO BE NO RESPONSE.";
 const char *const GENERAL_MESSAGES[] = {
 	LOOK_MESSAGE, OPEN_MESSAGE, MOVE_MESSAGE, GET_MESSAGE, USE_MESSAGE,
 	GO_MESSAGE, TALK_MESSAGE, HELP_MESSAGE, HELP_MESSAGE, USE_MESSAGE


Commit: 3fca9d42f3ff6d19eba40d09754cc794f8e17585
    https://github.com/scummvm/scummvm/commit/3fca9d42f3ff6d19eba40d09754cc794f8e17585
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-18T07:23:18+01:00

Commit Message:
ACCESS: Use  Common::String to display bubble box text

Changed paths:
    engines/access/bubble_box.cpp
    engines/access/bubble_box.h
    engines/access/scripts.cpp



diff --git a/engines/access/bubble_box.cpp b/engines/access/bubble_box.cpp
index 572567c..e37a814 100644
--- a/engines/access/bubble_box.cpp
+++ b/engines/access/bubble_box.cpp
@@ -29,7 +29,7 @@ namespace Access {
 BubbleBox::BubbleBox(AccessEngine *vm) : Manager(vm) {
 	_type = TYPE_2;
 	_bounds = Common::Rect(64, 32, 64 + 130, 32 + 122);
-	_bubblePtr = nullptr;
+	_bubbleDisplStr = "";
 	_fieldD = 0;
 	_fieldE = 0;
 	_fieldF = 0;
@@ -43,7 +43,7 @@ void BubbleBox::load(Common::SeekableReadStream *stream) {
 	while ((v = stream->readByte()) != 0)
 		_bubbleTitle += (char)v;
 
-	_bubblePtr = _bubbleTitle.c_str();
+	_bubbleDisplStr = _bubbleTitle;
 }
 
 void BubbleBox::clearBubbles() {
@@ -90,7 +90,7 @@ void BubbleBox::calcBubble(const Common::String &msg) {
 	if (_type == TYPE_4) {
 		_vm->_fonts._printMaxX = 110;
 	} else {
-		_vm->_fonts._printMaxX = _vm->_fonts._font2.stringWidth(_bubblePtr);
+		_vm->_fonts._printMaxX = _vm->_fonts._font2.stringWidth(_bubbleDisplStr);
 	}
 
 	// Start of with a rect with the given starting x and y
@@ -257,13 +257,13 @@ void BubbleBox::doBox(int item, int box) {
 	}
 
 	// Handle drawing title
-	int titleWidth = _vm->_fonts._font2.stringWidth(_bubblePtr);
+	int titleWidth = _vm->_fonts._font2.stringWidth(_bubbleDisplStr);
 	Font &font2 = _vm->_fonts._font2;
 	font2._fontColors[0] = 0;
 	font2._fontColors[1] = 3;
 	font2._fontColors[2] = 2;
 	font2._fontColors[3] = 1;
-	font2.drawString(_vm->_screen, _bubblePtr, Common::Point(
+	font2.drawString(_vm->_screen, _bubbleDisplStr, Common::Point(
 		_bounds.left + (_bounds.width() / 2) - (titleWidth / 2), _bounds.top + 1));
 
 	// Restore positional state
diff --git a/engines/access/bubble_box.h b/engines/access/bubble_box.h
index 2c05d09..0130344 100644
--- a/engines/access/bubble_box.h
+++ b/engines/access/bubble_box.h
@@ -48,7 +48,7 @@ public:
 	Common::Rect _bounds;
 	Common::StringArray _nameIndex;
 	Common::String _bubbleTitle;
-	const char *_bubblePtr;
+	Common::String _bubbleDisplStr;
 	int _fieldD;
 	int _fieldE;
 	int _fieldF;
diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp
index ac10fe3..99f52c0 100644
--- a/engines/access/scripts.cpp
+++ b/engines/access/scripts.cpp
@@ -621,7 +621,7 @@ void Scripts::cmdTexSpeak() {
 	while ((v = _data->readByte()) != 0)
 		tmpStr += (char)v;
 
-	_vm->_bubbleBox->_bubblePtr = Common::String("JASON").c_str();
+	_vm->_bubbleBox->_bubbleDisplStr = Common::String("JASON");
 	_vm->_bubbleBox->placeBubble1(tmpStr);
 	findNull();
 }
@@ -645,7 +645,7 @@ void Scripts::cmdTexChoice() {
 	_vm->_screen->_printStart = _texsOrg;
 
 	_vm->_bubbleBox->clearBubbles();
-	_vm->_bubbleBox->_bubblePtr = Common::String("RESPONSE 1").c_str();
+	_vm->_bubbleBox->_bubbleDisplStr = Common::String("RESPONSE 1");
 
 	byte v;
 	Common::String tmpStr = "";
@@ -666,7 +666,7 @@ void Scripts::cmdTexChoice() {
 		tmpStr += (char)v;
 
 	if (tmpStr.size() != 0) {
-		_vm->_bubbleBox->_bubblePtr = Common::String("RESPONSE 2").c_str();
+		_vm->_bubbleBox->_bubbleDisplStr = Common::String("RESPONSE 2");
 		_vm->_bubbleBox->calcBubble(tmpStr);
 		_vm->_bubbleBox->printBubble(tmpStr);
 		responseCoords.push_back(_vm->_bubbleBox->_bounds);
@@ -681,7 +681,7 @@ void Scripts::cmdTexChoice() {
 		tmpStr += (char)v;
 
 	if (tmpStr.size() != 0) {
-		_vm->_bubbleBox->_bubblePtr = Common::String("RESPONSE 3").c_str();
+		_vm->_bubbleBox->_bubbleDisplStr = Common::String("RESPONSE 3");
 		_vm->_bubbleBox->calcBubble(tmpStr);
 		_vm->_bubbleBox->printBubble(tmpStr);
 		responseCoords.push_back(_vm->_bubbleBox->_bounds);
@@ -698,7 +698,7 @@ void Scripts::cmdTexChoice() {
 
 		charLoop();
 
-		_vm->_bubbleBox->_bubblePtr = _vm->_bubbleBox->_bubbleTitle.c_str();
+		_vm->_bubbleBox->_bubbleDisplStr = _vm->_bubbleBox->_bubbleTitle;
 		if (_vm->_events->_leftButton) {
 			if (_vm->_events->_mouseRow >= 22) {
 				_vm->_events->debounceLeft();


Commit: 864cab5e477dc5792339e05c1687b78b92318d89
    https://github.com/scummvm/scummvm/commit/864cab5e477dc5792339e05c1687b78b92318d89
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-12-19T01:35:33+01:00

Commit Message:
ACCESS: Fix issue related to demo-only (and unused afawk) opcodes

Changed paths:
    engines/access/scripts.cpp



diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp
index 99f52c0..d1dd5e7 100644
--- a/engines/access/scripts.cpp
+++ b/engines/access/scripts.cpp
@@ -266,7 +266,7 @@ void Scripts::cmdGoto() {
 }
 
 void Scripts::cmdAddScore() {
-	if (_vm->isCD()) {
+	if (!_vm->isDemo()) {
 		cmdSetInventory();
 		return;
 	}
@@ -412,7 +412,7 @@ void Scripts::cmdDispInv() {
 }
 
 void Scripts::cmdSetAbout() {
-	if (_vm->isCD()) {
+	if (!_vm->isDemo()) {
 		cmdSetTimer();
 		return;
 	}
@@ -459,7 +459,7 @@ void Scripts::cmdCheckTimer() {
 }
 
 void Scripts::cmdSetTravel() {
-	if (_vm->isCD()) {
+	if (!_vm->isDemo()) {
 		cmdJumpGoto();
 		return;
 	}
@@ -515,7 +515,7 @@ void Scripts::cmdSetScroll() {
 }
 
 void Scripts::cmdSaveRect() {
-	if (_vm->isCD()) {
+	if (!_vm->isDemo()) {
 		cmdVideoEnded();
 		return;
 	}
@@ -551,7 +551,7 @@ void Scripts::cmdRemoveLast() {
 }
 
 void Scripts::cmdDoTravel() {
-	if (_vm->isCD()) {
+	if (!_vm->isDemo()) {
 		cmdSpecial();
 		return;
 	}
@@ -559,7 +559,7 @@ void Scripts::cmdDoTravel() {
 }
 
 void Scripts::cmdCheckAbout() {
-	if (_vm->isCD()) {
+	if (!_vm->isDemo()) {
 		cmdSpecial();
 		return;
 	}
@@ -825,7 +825,7 @@ void Scripts::cmdPlayVideoSound() {
 }
 
 void Scripts::cmdPrintWatch() {
-	if (_vm->isCD()) {
+	if (!_vm->isDemo()) {
 		cmdPushLocation();
 		return;
 	}
@@ -833,7 +833,7 @@ void Scripts::cmdPrintWatch() {
 }
 
 void Scripts::cmdDispAbout() {
-	if (_vm->isCD()) {
+	if (!_vm->isDemo()) {
 		cmdPushLocation();
 		return;
 	}
@@ -845,7 +845,7 @@ void Scripts::cmdPushLocation() {
 }
 
 void Scripts::cmdCheckTravel() {
-	if (_vm->isCD()) {
+	if (!_vm->isDemo()) {
 		cmdPushLocation();
 		return;
 	}
@@ -853,7 +853,7 @@ void Scripts::cmdCheckTravel() {
 }
 
 void Scripts::cmdBlock() {
-	if (_vm->isCD()) {
+	if (!_vm->isDemo()) {
 		cmdPushLocation();
 		return;
 	}


Commit: 95aa9a13a6ca634af664a3ac4753faf8b8271fd9
    https://github.com/scummvm/scummvm/commit/95aa9a13a6ca634af664a3ac4753faf8b8271fd9
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-18T21:45:55-05:00

Commit Message:
ACCESS: Refactor most of ASurface statics to instance variables

Changed paths:
    engines/access/access.cpp
    engines/access/access.h
    engines/access/amazon/amazon_logic.cpp
    engines/access/amazon/amazon_room.cpp
    engines/access/asurface.cpp
    engines/access/asurface.h
    engines/access/events.cpp
    engines/access/inventory.cpp
    engines/access/player.cpp
    engines/access/room.cpp
    engines/access/screen.cpp
    engines/access/screen.h
    engines/access/scripts.cpp



diff --git a/engines/access/access.cpp b/engines/access/access.cpp
index dd6d0ea..6ad1b22 100644
--- a/engines/access/access.cpp
+++ b/engines/access/access.cpp
@@ -66,6 +66,8 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc)
 	_scaleT1 = 0;
 	_scaleMaxY = 0;
 	_scaleI = 0;
+	_scrollCol = _scrollRow = 0;
+	_scrollX = _scrollY = 0;
 	_imgUnscaled = false;
 	_canSaveLoad = false;
 	_establish = nullptr;
@@ -139,7 +141,6 @@ void AccessEngine::initialize() {
 	}
 
 	// Create sub-objects of the engine
-	ASurface::init();
 	_animation = new AnimationManager(this);
 	_bubbleBox = new BubbleBox(this);
 	_char = new CharManager(this);
@@ -376,9 +377,9 @@ void AccessEngine::copyRects() {
 
 void AccessEngine::copyBF1BF2() {
 	_buffer2.copyRectToSurface(_buffer1, 0, 0,
-		Common::Rect(_buffer1._scrollX, _buffer1._scrollY,
-		_buffer1._scrollX + _screen->_vWindowBytesWide,
-		_buffer1._scrollY + _screen->_vWindowLinesTall));
+		Common::Rect(_scrollX, _scrollY,
+		_scrollX + _screen->_vWindowBytesWide,
+		_scrollY + _screen->_vWindowLinesTall));
 }
 
 void AccessEngine::copyBF2Vid() {
diff --git a/engines/access/access.h b/engines/access/access.h
index c984620..a082b96 100644
--- a/engines/access/access.h
+++ b/engines/access/access.h
@@ -185,6 +185,8 @@ public:
 	int _scaleT1;
 	int _scaleMaxY;
 	int _scaleI;
+	int _scrollX, _scrollY;
+	int _scrollCol, _scrollRow;
 	bool _imgUnscaled;
 	bool _canSaveLoad;
 
diff --git a/engines/access/amazon/amazon_logic.cpp b/engines/access/amazon/amazon_logic.cpp
index 90bc29c..436a875 100644
--- a/engines/access/amazon/amazon_logic.cpp
+++ b/engines/access/amazon/amazon_logic.cpp
@@ -410,11 +410,10 @@ void Opening::doTitle() {
 	_vm->_room->loadRoom(0);
 	screen.clearScreen();
 	screen.setBufferScan();
-	screen._scrollRow = screen._scrollCol = 0;
-	screen._scrollX = screen._scrollY = 0;
+	_vm->_scrollRow = _vm->_scrollCol = 0;
+	_vm->_scrollX = _vm->_scrollY = 0;
 	_vm->_player->_rawPlayer = Common::Point(0, 0);
 	screen.forceFadeOut();
-	screen._scrollX = 0;
 	_vm->_room->buildScreen();
 	_vm->copyBF2Vid();
 	screen.forceFadeIn();
@@ -434,15 +433,15 @@ void Opening::doTitle() {
 		}
 
 		_vm->_events->_vbCount = 4;
-		if (screen._scrollCol + screen._vWindowWidth != _vm->_room->_playFieldWidth) {
-			screen._scrollX += _vm->_player->_scrollAmount;
+		if (_vm->_scrollCol + screen._vWindowWidth != _vm->_room->_playFieldWidth) {
+			_vm->_scrollX += _vm->_player->_scrollAmount;
 
-			while (screen._scrollX >= TILE_WIDTH) {
-				screen._scrollX -= TILE_WIDTH;
-				++screen._scrollCol;
+			while (_vm->_scrollX >= TILE_WIDTH) {
+				_vm->_scrollX -= TILE_WIDTH;
+				++_vm->_scrollCol;
 
 				_vm->_buffer1.moveBufferLeft();
-				_vm->_room->buildColumn(screen._scrollCol + screen._vWindowWidth, screen._vWindowBytesWide);
+				_vm->_room->buildColumn(_vm->_scrollCol + screen._vWindowWidth, screen._vWindowBytesWide);
 			}
 			scrollTitle();
 			++_pCount;
@@ -460,23 +459,23 @@ void Opening::doTitle() {
 		while (!_vm->shouldQuit()) {
 			_pCount = 0;
 			_vm->_events->_vbCount = 3;
-			if (screen._scrollRow + screen._vWindowHeight >= _vm->_room->_playFieldHeight) {
+			if (_vm->_scrollRow + screen._vWindowHeight >= _vm->_room->_playFieldHeight) {
 				_vm->_room->clearRoom();
 				_vm->_events->showCursor();
 				return;
 			}
 
-			screen._scrollY = screen._scrollY + _vm->_player->_scrollAmount;
+			_vm->_scrollY = _vm->_scrollY + _vm->_player->_scrollAmount;
 
-			while (screen._scrollY >= TILE_HEIGHT && !_vm->shouldQuit()) {
-				screen._scrollY -= TILE_HEIGHT;
-				++screen._scrollRow;
+			while (_vm->_scrollY >= TILE_HEIGHT && !_vm->shouldQuit()) {
+				_vm->_scrollY -= TILE_HEIGHT;
+				++_vm->_scrollRow;
 				_vm->_buffer1.moveBufferUp();
 
 				// WORKAROUND: the original was using screen._vWindowBytesWide * screen._vWindowLinesTall
-				_vm->_room->buildRow(screen._scrollRow + screen._vWindowHeight, screen._vWindowLinesTall);
+				_vm->_room->buildRow(_vm->_scrollRow + screen._vWindowHeight, screen._vWindowLinesTall);
 
-				if (screen._scrollRow + screen._vWindowHeight >= _vm->_room->_playFieldHeight) {
+				if (_vm->_scrollRow + screen._vWindowHeight >= _vm->_room->_playFieldHeight) {
 					_vm->_room->clearRoom();
 					_vm->_events->showCursor();
 					return;
@@ -657,7 +656,7 @@ void Plane::mWhileFly() {
 	screen.clearScreen();
 	screen.setBufferScan();
 	screen.fadeOut();
-	screen._scrollX = 0;
+	_vm->_scrollX = 0;
 
 	_vm->_room->buildScreen();
 	_vm->copyBF2Vid();
@@ -666,8 +665,8 @@ void Plane::mWhileFly() {
 	_vm->_newRects.clear();
 	_vm->_events->clearEvents();
 
-	screen._scrollRow = screen._scrollCol = 0;
-	screen._scrollX = screen._scrollY = 0;
+	_vm->_scrollRow = _vm->_scrollCol = 0;
+	_vm->_scrollX = _vm->_scrollY = 0;
 	player._rawPlayer = Common::Point(0, 0);
 	player._scrollAmount = 1;
 
@@ -678,16 +677,16 @@ void Plane::mWhileFly() {
 	_position = Common::Point(20, 29);
 
 	while (!_vm->shouldQuit() && !events.isKeyMousePressed() &&
-		((screen._scrollCol + screen._vWindowWidth) != _vm->_room->_playFieldWidth)) {
+		((_vm->_scrollCol + screen._vWindowWidth) != _vm->_room->_playFieldWidth)) {
 		events._vbCount = 4;
-		screen._scrollX += player._scrollAmount;
+		_vm->_scrollX += player._scrollAmount;
 
-		while (screen._scrollX >= TILE_WIDTH) {
-			screen._scrollX -= TILE_WIDTH;
-			++screen._scrollCol;
+		while (_vm->_scrollX >= TILE_WIDTH) {
+			_vm->_scrollX -= TILE_WIDTH;
+			++_vm->_scrollCol;
 
 			_vm->_buffer1.moveBufferLeft();
-			_vm->_room->buildColumn(screen._scrollCol + screen._vWindowWidth, screen._vWindowBytesWide);
+			_vm->_room->buildColumn(_vm->_scrollCol + screen._vWindowWidth, screen._vWindowBytesWide);
 		}
 
 		scrollFly();
@@ -710,7 +709,7 @@ void Plane::mWhileFall() {
 	screen.clearScreen();
 	screen.setBufferScan();
 	screen.fadeOut();
-	screen._scrollX = 0;
+	_vm->_scrollX = 0;
 
 	_vm->_room->buildScreen();
 	_vm->copyBF2Vid();
@@ -719,8 +718,8 @@ void Plane::mWhileFall() {
 	_vm->_newRects.clear();
 	_vm->_events->clearEvents();
 
-	screen._scrollRow = screen._scrollCol = 0;
-	screen._scrollX = screen._scrollY = 0;
+	_vm->_scrollRow = _vm->_scrollCol = 0;
+	_vm->_scrollX = _vm->_scrollY = 0;
 	_vm->_player->_scrollAmount = 3;
 	_vm->_scaleI = 255;
 
@@ -728,16 +727,16 @@ void Plane::mWhileFall() {
 	_planeCount = 0;
 
 	while (!_vm->shouldQuit() && !events.isKeyMousePressed() &&
-		(screen._scrollCol + screen._vWindowWidth != _vm->_room->_playFieldWidth)) {
+		(_vm->_scrollCol + screen._vWindowWidth != _vm->_room->_playFieldWidth)) {
 		events._vbCount = 4;
-		screen._scrollX += _vm->_player->_scrollAmount;
+		_vm->_scrollX += _vm->_player->_scrollAmount;
 
-		while (screen._scrollX >= TILE_WIDTH) {
-			screen._scrollX -= TILE_WIDTH;
-			++screen._scrollCol;
+		while (_vm->_scrollX >= TILE_WIDTH) {
+			_vm->_scrollX -= TILE_WIDTH;
+			++_vm->_scrollCol;
 
 			_vm->_buffer1.moveBufferLeft();
-			_vm->_room->buildColumn(screen._scrollCol + screen._vWindowWidth, screen._vWindowBytesWide);
+			_vm->_room->buildColumn(_vm->_scrollCol + screen._vWindowWidth, screen._vWindowBytesWide);
 		}
 
 		scrollFall();
@@ -765,7 +764,7 @@ void Jungle::jungleMove() {
 
 	if (!_vm->_timers[0]._flag) {
 		++_vm->_timers[0]._flag;
-		_vm->_screen->_scrollX += _vm->_player->_scrollAmount;
+		_vm->_scrollX += _vm->_player->_scrollAmount;
 
 		for (int i = 0; i < 3; ++i) {
 			int newJCnt = (_jCnt[i] + 1) % 8;
@@ -808,8 +807,8 @@ void Jungle::initJWalk2() {
 	_vm->_buffer2.clearBuffer();
 	screen.setBufferScan();
 
-	screen._scrollX = screen._scrollY;
-	screen._scrollCol = screen._scrollRow;
+	_vm->_scrollX = _vm->_scrollY;
+	_vm->_scrollCol = _vm->_scrollRow;
 	_vm->_room->buildScreen();
 	_vm->copyBF2Vid();
 	screen.fadeIn();
@@ -866,7 +865,7 @@ void Jungle::mWhileJWalk() {
 	screen.clearScreen();
 	_vm->_buffer2.clearBuffer();
 	screen.setBufferScan();
-	screen._scrollX = 0;
+	_vm->_scrollX = 0;
 
 	// Build the initial jungle scene and fade it in
 	_vm->_room->buildScreen();
@@ -930,17 +929,17 @@ void Jungle::mWhileJWalk2() {
 	initJWalk2();
 
 	while (!_vm->shouldQuit() && !_vm->_events->isKeyMousePressed() &&
-		(screen._scrollCol + screen._vWindowWidth) != _vm->_room->_playFieldWidth) {
+		(_vm->_scrollCol + screen._vWindowWidth) != _vm->_room->_playFieldWidth) {
 		_vm->_images.clear();
 		_vm->_events->_vbCount = 6;
 		_pan[0]._pImgNum = _xCount;
 
 		jungleMove();
-		while (screen._scrollX >= TILE_WIDTH) {
-			screen._scrollX -= TILE_WIDTH;
-			++screen._scrollCol;
+		while (_vm->_scrollX >= TILE_WIDTH) {
+			_vm->_scrollX -= TILE_WIDTH;
+			++_vm->_scrollCol;
 			_vm->_buffer1.moveBufferLeft();
-			_vm->_room->buildColumn(screen._scrollCol + screen._vWindowWidth, screen._vWindowBytesWide);
+			_vm->_room->buildColumn(_vm->_scrollCol + screen._vWindowWidth, screen._vWindowBytesWide);
 		}
 
 		if (_xCount == 2)
@@ -1130,7 +1129,7 @@ void Guard::chkHLine() {
 
 void Guard::guardSee() {
 	Screen &screen = *_vm->_screen;
-	int tmpY = (screen._scrollRow << 4) + screen._scrollY;
+	int tmpY = (_vm->_scrollRow << 4) + _vm->_scrollY;
 	_vm->_flags[140] = 0;
 	if (tmpY > _position.y)
 		return;
@@ -1375,7 +1374,7 @@ River::River(AmazonEngine *vm) : PannedScene(vm) {
 }
 
 void River::setRiverPan() {
-	int delta = (_vm->_screen->_scrollCol * 16) + _vm->_screen->_scrollX;
+	int delta = (_vm->_scrollCol * 16) + _vm->_scrollX;
 
 	_xTrack = 9;
 	_yTrack = _zTrack = 0;
@@ -1420,16 +1419,16 @@ void River::initRiver() {
 
 	if (_saveRiver) {
 		// Restoring a savegame, so set properties from saved fields
-		screen._scrollRow = _rScrollRow;
-		screen._scrollCol = _rScrollCol;
-		screen._scrollX = _rScrollX;
-		screen._scrollY = _rScrollY;
+		_vm->_scrollRow = _rScrollRow;
+		_vm->_scrollCol = _rScrollCol;
+		_vm->_scrollX = _rScrollX;
+		_vm->_scrollY = _rScrollY;
 	} else {
 		// Set initial scene state
-		screen._scrollRow = 0;
-		screen._scrollCol = 140;
-		screen._scrollX = 0;
-		screen._scrollY = 0;
+		_vm->_scrollRow = 0;
+		_vm->_scrollCol = 140;
+		_vm->_scrollX = 0;
+		_vm->_scrollY = 0;
 	}
 
 	_vm->_room->buildScreen();
@@ -1490,7 +1489,7 @@ void River::initRiver() {
 
 void River::resetPositions() {
 	riverSetPhysX();
-	int val = (_vm->_screen->_scrollCol + 1 - _oldScrollCol) * 16;
+	int val = (_vm->_scrollCol + 1 - _oldScrollCol) * 16;
 	if (val < 0) {
 		val |= 0x80;
 	}
@@ -1500,7 +1499,7 @@ void River::resetPositions() {
 }
 
 void River::checkRiverPan() {
-	int val = _vm->_screen->_scrollCol * 16 + 320;
+	int val = _vm->_scrollCol * 16 + 320;
 
 	for (int i = 0; i < _pNumObj; i++) {
 		if (_pan[i]._pObjX < val)
@@ -1513,21 +1512,21 @@ void River::checkRiverPan() {
 bool River::riverJumpTest() {
 	Screen &screen = *_vm->_screen;
 
-	if (screen._scrollCol == 120 || screen._scrollCol == 60 || screen._scrollCol == 0) {
+	if (_vm->_scrollCol == 120 || _vm->_scrollCol == 60 || _vm->_scrollCol == 0) {
 		int val = *++_mapPtr;
 		if (val == 0xFF)
 			return true;
 
-		_oldScrollCol = screen._scrollCol;
+		_oldScrollCol = _vm->_scrollCol;
 
 		if (val == 0) {
-			screen._scrollCol = 139;
-			screen._scrollX = 14;
+			_vm->_scrollCol = 139;
+			_vm->_scrollX = 14;
 			_vm->_room->buildScreen();
 			resetPositions();
 			return false;
 		}
-	} else if (screen._scrollCol == 105) {
+	} else if (_vm->_scrollCol == 105) {
 		int val1 = _mapPtr[1];
 		int val2 = _mapPtr[2];
 		_mapPtr += 3;
@@ -1543,19 +1542,19 @@ bool River::riverJumpTest() {
 				_deathCount = 300;
 				_deathType = val2;
 			}
-			_oldScrollCol = screen._scrollCol;
-			screen._scrollCol = 44;
-			screen._scrollX = 14;
+			_oldScrollCol = _vm->_scrollCol;
+			_vm->_scrollCol = 44;
+			_vm->_scrollX = 14;
 			_vm->_room->buildScreen();
 			resetPositions();
 			return false;
 		}
 	}
 
-	screen._scrollX = 14;
-	--screen._scrollCol;
+	_vm->_scrollX = 14;
+	--_vm->_scrollCol;
 	_vm->_buffer1.moveBufferRight();
-	_vm->_room->buildColumn(screen._scrollCol, 0);
+	_vm->_room->buildColumn(_vm->_scrollCol, 0);
 	checkRiverPan();
 	return false;
 }
@@ -1670,7 +1669,7 @@ void River::updateObstacles() {
 }
 
 void River::riverSetPhysX() {
-	int xAmt = (_vm->_screen->_scrollCol * 16) + _vm->_screen->_scrollX;
+	int xAmt = (_vm->_scrollCol * 16) + _vm->_scrollX;
 	
 	for (RiverStruct *cur = _topList; cur <= _botList; ++cur) {
 		cur->_xp = xAmt - (_screenVertX - cur->_riverX);
@@ -1713,7 +1712,7 @@ void River::plotRiver() {
 	ie._flags = IMGFLAG_UNSCALED;
 	ie._spritesPtr = _vm->_objectsTable[45];
 	ie._frameNumber = _canoeFrame;
-	ie._position.x = (_vm->_screen->_scrollCol * 16) + _vm->_screen->_scrollX + 160;
+	ie._position.x = (_vm->_scrollCol * 16) + _vm->_scrollX + 160;
 	ie._position.y = _canoeYPos - 41;
 	ie._offsetY = 41;
 	_vm->_images.addToList(ie);
@@ -1750,7 +1749,7 @@ void River::mWhileDownRiver() {
 	screen.setPalette();
 	screen.setBufferScan();
 
-	screen._scrollX = 0;
+	_vm->_scrollX = 0;
 	_vm->_room->buildScreen();
 	_vm->copyBF2Vid();
 
@@ -1783,16 +1782,16 @@ void River::mWhileDownRiver() {
 	++_vm->_timers[4]._flag;
 
 	while (!_vm->shouldQuit() && !_vm->_events->isKeyMousePressed() &&
-		(screen._scrollCol + screen._vWindowWidth != _vm->_room->_playFieldWidth)) {
+		(_vm->_scrollCol + screen._vWindowWidth != _vm->_room->_playFieldWidth)) {
 		_vm->_images.clear();
 		_vm->_events->_vbCount = 6;
 
-		screen._scrollX += _vm->_player->_scrollAmount;
-		while (screen._scrollX >= TILE_WIDTH) {
-			screen._scrollX -= TILE_WIDTH;
-			++screen._scrollCol;
+		_vm->_scrollX += _vm->_player->_scrollAmount;
+		while (_vm->_scrollX >= TILE_WIDTH) {
+			_vm->_scrollX -= TILE_WIDTH;
+			++_vm->_scrollCol;
 			_vm->_buffer1.moveBufferLeft();
-			_vm->_room->buildColumn(screen._scrollCol + screen._vWindowWidth, screen._vWindowBytesWide);
+			_vm->_room->buildColumn(_vm->_scrollCol + screen._vWindowWidth, screen._vWindowBytesWide);
 		}
 
 		pan();
@@ -1844,14 +1843,14 @@ void River::doRiver() {
 		// Move the river position
 		_screenVertX -= _vm->_player->_scrollAmount;
 
-		if (_vm->_screen->_scrollX == 0) {
+		if (_vm->_scrollX == 0) {
 			_vm->_midi->midiRepeat();
 			if (riverJumpTest()) {
 				_chickenOutFl = false;
 				return;
 			}
 		} else {
-			_vm->_screen->_scrollX -= _vm->_player->_scrollAmount;
+			_vm->_scrollX -= _vm->_player->_scrollAmount;
 		}
 
 		if (_chickenOutFl) {
@@ -1911,10 +1910,10 @@ void River::synchronize(Common::Serializer &s) {
 		if (s.isSaving()) {
 			// Set river properties to be saved out
 			Screen &screen = *_vm->_screen;
-			_rScrollRow = screen._scrollRow;
-			_rScrollCol = screen._scrollCol;
-			_rScrollX = screen._scrollX;
-			_rScrollY = screen._scrollY;
+			_rScrollRow = _vm->_scrollRow;
+			_rScrollCol = _vm->_scrollCol;
+			_rScrollX = _vm->_scrollX;
+			_rScrollY = _vm->_scrollY;
 			_mapOffset = _mapPtr - MAPTBL[_vm->_riverFlag];
 		}
 
diff --git a/engines/access/amazon/amazon_room.cpp b/engines/access/amazon/amazon_room.cpp
index 8174969..29742f6 100644
--- a/engines/access/amazon/amazon_room.cpp
+++ b/engines/access/amazon/amazon_room.cpp
@@ -134,8 +134,8 @@ void AmazonRoom::setupRoom() {
 	// WORKAROUND: The original engine doesn't handle vertical scrolling rooms
 	Screen &screen = *_vm->_screen;
 	if (screen._vWindowHeight == (_playFieldHeight - 1)) {
-		screen._scrollRow = 1;
-		screen._scrollY = 0;
+		_vm->_scrollRow = 1;
+		_vm->_scrollY = 0;
 	}
 }
 
@@ -187,7 +187,7 @@ void AmazonRoom::mainAreaClick() {
 
 		// WORKAROUND: In Amazon room 9, you can't leave the screen to the south due
 		// to not being able to click a Y position that's high enough
-		if (screen._scrollRow == 0 && pt.y > 178)
+		if (_vm->_scrollRow == 0 && pt.y > 178)
 			pt.y = 200;
 
 		player._moveTo = pt;
diff --git a/engines/access/asurface.cpp b/engines/access/asurface.cpp
index 45ce44d..27e73a0 100644
--- a/engines/access/asurface.cpp
+++ b/engines/access/asurface.cpp
@@ -99,31 +99,14 @@ void ImageEntryList::addToList(ImageEntry &ie) {
 
 /*------------------------------------------------------------------------*/
 
-int ASurface::_leftSkip;
-int ASurface::_rightSkip;
-int ASurface::_topSkip;
-int ASurface::_bottomSkip;
 int ASurface::_clipWidth;
 int ASurface::_clipHeight;
-int ASurface::_lastBoundsX;
-int ASurface::_lastBoundsY;
-int ASurface::_lastBoundsW;
-int ASurface::_lastBoundsH;
-int ASurface::_scrollX;
-int ASurface::_scrollY;
-int ASurface::_orgX1;
-int ASurface::_orgY1;
-int ASurface::_orgX2;
-int ASurface::_orgY2;
-int ASurface::_lColor;
-
-void ASurface::init() {
+
+ASurface::ASurface() {
 	_leftSkip = _rightSkip = 0;
 	_topSkip = _bottomSkip = 0;
-	_clipWidth = _clipHeight = 0;
 	_lastBoundsX = _lastBoundsY = 0;
 	_lastBoundsW = _lastBoundsH = 0;
-	_scrollX = _scrollY = 0;
 	_orgX1 = _orgY1 = 0;
 	_orgX2 = _orgY2 = 0;
 	_lColor = 0;
diff --git a/engines/access/asurface.h b/engines/access/asurface.h
index 6ffbf0e..763e3e6 100644
--- a/engines/access/asurface.h
+++ b/engines/access/asurface.h
@@ -43,22 +43,22 @@ private:
 protected:
 	Common::Rect _savedBounds;
 public:
-	static int _leftSkip, _rightSkip;
-	static int _topSkip, _bottomSkip;
-	static int _clipWidth, _clipHeight;
-	static int _lastBoundsX, _lastBoundsY;
-	static int _lastBoundsW, _lastBoundsH;
-	static int _scrollX, _scrollY;
-	static int _orgX1, _orgY1;
-	static int _orgX2, _orgY2;
-	static int _lColor;
+	int _leftSkip, _rightSkip;
+	int _topSkip, _bottomSkip;
+	int _lastBoundsX, _lastBoundsY;
+	int _lastBoundsW, _lastBoundsH;
+	int _orgX1, _orgY1;
+	int _orgX2, _orgY2;
+	int _lColor;
 
 	Common::Point _printOrg;
 	Common::Point _printStart;
 	int _maxChars;
-
-	static void init();
 public:
+	static int _clipWidth, _clipHeight;
+public:
+	ASurface();
+
 	virtual ~ASurface();
 
 	void create(uint16 width, uint16 height);
diff --git a/engines/access/events.cpp b/engines/access/events.cpp
index c314fe9..0867b09 100644
--- a/engines/access/events.cpp
+++ b/engines/access/events.cpp
@@ -329,12 +329,12 @@ void EventsManager::waitKeyMouse() {
 }
 
 Common::Point EventsManager::calcRawMouse() {
-	Screen &screen = *_vm->_screen;
 	Common::Point pt;
+	Screen &screen = *_vm->_screen;
 	pt.x = _mousePos.x - screen._windowXAdd +
-		(screen._scrollCol * TILE_WIDTH) + screen._scrollX;
+		(_vm->_scrollCol * TILE_WIDTH) + _vm->_scrollX;
 	pt.y = _mousePos.y - screen._screenYOff - screen._windowYAdd +
-		(screen._scrollRow * TILE_HEIGHT) + screen._scrollY;
+		(_vm->_scrollRow * TILE_HEIGHT) + _vm->_scrollY;
 
 	return pt;
 }
diff --git a/engines/access/inventory.cpp b/engines/access/inventory.cpp
index d09b784..8db62a4 100644
--- a/engines/access/inventory.cpp
+++ b/engines/access/inventory.cpp
@@ -221,13 +221,13 @@ void InventoryManager::savedFields() {
 	_fields._windowXAdd = screen._windowXAdd;
 	_fields._windowYAdd = screen._windowYAdd;
 	_fields._screenYOff = screen._screenYOff;
-	_fields._scrollX = screen._scrollX;
-	_fields._scrollY = screen._scrollY;
+	_fields._scrollX = _vm->_scrollX;
+	_fields._scrollY = _vm->_scrollY;
 	_fields._clipWidth = screen._clipWidth;
 	_fields._clipHeight = screen._clipHeight;
 	_fields._bufferStart = screen._bufferStart;
-	_fields._scrollCol = screen._scrollCol;
-	_fields._scrollRow = screen._scrollRow;
+	_fields._scrollCol = _vm->_scrollCol;
+	_fields._scrollRow = _vm->_scrollRow;
 }
 
 void InventoryManager::restoreFields() {
@@ -243,13 +243,13 @@ void InventoryManager::restoreFields() {
 	screen._windowXAdd = _fields._windowXAdd;
 	screen._windowYAdd = _fields._windowYAdd;
 	screen._screenYOff = _fields._screenYOff;
-	screen._scrollX = _fields._scrollX;
-	screen._scrollY = _fields._scrollY;
+	_vm->_scrollX = _fields._scrollX;
+	_vm->_scrollY = _fields._scrollY;
 	screen._clipWidth = _fields._clipWidth;
 	screen._clipHeight = _fields._clipHeight;
 	screen._bufferStart = _fields._bufferStart;
-	screen._scrollCol = _fields._scrollCol;
-	screen._scrollRow = _fields._scrollRow;
+	_vm->_scrollCol = _fields._scrollCol;
+	_vm->_scrollRow = _fields._scrollRow;
 }
 
 void InventoryManager::initFields() {
@@ -268,9 +268,9 @@ void InventoryManager::initFields() {
 	screen._windowXAdd = 0;
 	screen._windowYAdd = 0;
 	screen._screenYOff = 0;
-	screen._scrollX = screen._scrollY = 0;
 	screen._bufferStart.x = 0;
 	screen._bufferStart.y = 0;
+	_vm->_scrollX = _vm->_scrollY = 0;
 
 	_vm->_buffer1.clearBuffer();
 	_vm->_buffer2.clearBuffer();
diff --git a/engines/access/player.cpp b/engines/access/player.cpp
index 83f075e..d547aed 100644
--- a/engines/access/player.cpp
+++ b/engines/access/player.cpp
@@ -209,8 +209,8 @@ void Player::walk() {
 
 void Player::calcPlayer() {
 	Screen &scr = *_vm->_screen;
-	scr._bufferStart.x = (scr._scrollCol << 4) + scr._scrollX;
-	scr._bufferStart.y = (scr._scrollRow << 4) + scr._scrollY;
+	scr._bufferStart.x = (_vm->_scrollCol << 4) + _vm->_scrollX;
+	scr._bufferStart.y = (_vm->_scrollRow << 4) + _vm->_scrollY;
 	_playerX = _rawPlayer.x - scr._bufferStart.x;
 	_playerY = _rawPlayer.y - scr._bufferStart.y;
 }
@@ -519,7 +519,7 @@ void Player::walkDownRight() {
 	bool flag = _scrollEnd == 2;
 	if (!flag) {
 		calcPlayer();
-		flag = (_vm->_screen->_clipWidth -  _playerX - _vm->_screen->_scaleTable1[_scrollConst] -
+		flag = (_vm->_screen->_clipWidth - _playerX - _vm->_screen->_scaleTable1[_scrollConst] -
 			_vm->_player->_scrollThreshold) > 0;
 	}
 	if (flag) {
@@ -664,7 +664,7 @@ void Player::checkScrollUp() {
 			// Scroll up
 			if (scrollUp()) {
 				_scrollEnd = 4;
-				_vm->_screen->_scrollY &= TILE_HEIGHT;
+				_vm->_scrollY &= TILE_HEIGHT;
 				_scrollFlag = true;
 			}
 	}
@@ -706,26 +706,26 @@ void Player::checkScroll() {
 
 bool Player::scrollUp() {
 	_scrollAmount = -(_vm->_screen->_clipHeight - _playerY - _scrollThreshold);
-	if ((_vm->_screen->_scrollRow + _vm->_screen->_vWindowHeight) >=
+	if ((_vm->_scrollRow + _vm->_screen->_vWindowHeight) >=
 			_vm->_room->_playFieldHeight)
 		return true;
 
 	_scrollFlag = true;
-	_vm->_screen->_scrollY = _vm->_screen->_scrollY + _scrollAmount;
+	_vm->_scrollY = _vm->_scrollY + _scrollAmount;
 
-	while (_vm->_screen->_scrollY >= TILE_HEIGHT && !_vm->shouldQuit()) {
-			_vm->_screen->_scrollY -= TILE_HEIGHT;
-		++_vm->_screen->_scrollRow;
+	while (_vm->_scrollY >= TILE_HEIGHT && !_vm->shouldQuit()) {
+			_vm->_scrollY -= TILE_HEIGHT;
+		++_vm->_scrollRow;
 		_vm->_buffer1.moveBufferUp();
 
-		_vm->_room->buildRow(_vm->_screen->_scrollRow + _vm->_screen->_vWindowHeight,
+		_vm->_room->buildRow(_vm->_scrollRow + _vm->_screen->_vWindowHeight,
 			_vm->_screen->_vWindowLinesTall);
 
-		if ((_vm->_screen->_scrollRow + _vm->_screen->_vWindowHeight) >=
+		if ((_vm->_scrollRow + _vm->_screen->_vWindowHeight) >=
 			_vm->_room->_playFieldHeight)
 			return true;
 
-		if (_vm->_screen->_scrollY <= TILE_HEIGHT)
+		if (_vm->_scrollY <= TILE_HEIGHT)
 			return false;
 	}
 
@@ -735,50 +735,50 @@ bool Player::scrollUp() {
 bool Player::scrollDown() {
 	_scrollAmount = -(_playerY - _scrollThreshold);
 	_scrollFlag = true;
-	_vm->_screen->_scrollY -= _scrollAmount;
-	if (_vm->_screen->_scrollY >= 0)
+	_vm->_scrollY -= _scrollAmount;
+	if (_vm->_scrollY >= 0)
 		return true;
 
 	do {
-		_vm->_screen->_scrollY += TILE_HEIGHT;
-		if (--_vm->_screen->_scrollRow < 0)
+		_vm->_scrollY += TILE_HEIGHT;
+		if (--_vm->_scrollRow < 0)
 			break;
 
 		_vm->_buffer1.moveBufferDown();
-		_vm->_room->buildRow(_vm->_screen->_scrollRow, 0);
+		_vm->_room->buildRow(_vm->_scrollRow, 0);
 
-		if (_vm->_screen->_scrollY >= 0)
+		if (_vm->_scrollY >= 0)
 			return false;
 	} while (!_vm->shouldQuit());
 
 	_scrollEnd = 3;
-	_vm->_screen->_scrollY = 0;
-	_vm->_screen->_scrollRow = 0;
+	_vm->_scrollY = 0;
+	_vm->_scrollRow = 0;
 	return true;
 }
 
 bool Player::scrollLeft() {
 	Screen &screen = *_vm->_screen;
-	_scrollAmount = -(screen._clipWidth - _playerX - _scrollThreshold);
-	if ((screen._scrollCol + screen._vWindowWidth) == _vm->_room->_playFieldWidth) {
+	_scrollAmount = -(_vm->_screen->_clipWidth - _playerX - _scrollThreshold);
+	if ((_vm->_scrollCol + screen._vWindowWidth) == _vm->_room->_playFieldWidth) {
 		_scrollEnd = 2;
-		screen._scrollX = 0;
+		_vm->_scrollX = 0;
 		_scrollFlag = true;
 		return true;
 	} else {
 		_scrollFlag = true;
-		screen._scrollX = screen._scrollX + _scrollAmount;
+		_vm->_scrollX = _vm->_scrollX + _scrollAmount;
 
 		do {
-			if (screen._scrollX < TILE_WIDTH)
+			if (_vm->_scrollX < TILE_WIDTH)
 				return true;
 
-			screen._scrollX -= TILE_WIDTH;
-			++screen._scrollCol;
+			_vm->_scrollX -= TILE_WIDTH;
+			++_vm->_scrollCol;
 			_vm->_buffer1.moveBufferLeft();
-			_vm->_room->buildColumn(screen._scrollCol + screen._vWindowWidth,
+			_vm->_room->buildColumn(_vm->_scrollCol + screen._vWindowWidth,
 				screen._vWindowBytesWide);
-		} while (!_vm->shouldQuit() && (screen._scrollX >= TILE_WIDTH));
+		} while (!_vm->shouldQuit() && (_vm->_scrollX >= TILE_WIDTH));
 
 		return (_playerDirection == UPRIGHT);
 	}
@@ -787,21 +787,21 @@ bool Player::scrollLeft() {
 bool Player::scrollRight() {
 	_scrollAmount = -(_playerX - _scrollThreshold);
 	_scrollFlag = true;
-	_vm->_screen->_scrollX -= _scrollAmount;
+	_vm->_scrollX -= _scrollAmount;
 
-	if (_vm->_screen->_scrollX < 0) {
+	if (_vm->_scrollX < 0) {
 		do {
-			_vm->_screen->_scrollX += TILE_WIDTH;
-			if (--_vm->_screen->_scrollCol < 0) {
+			_vm->_scrollX += TILE_WIDTH;
+			if (--_vm->_scrollCol < 0) {
 				_scrollEnd = true;
-				_vm->_screen->_scrollX = 0;
-				_vm->_screen->_scrollCol = 0;
+				_vm->_scrollX = 0;
+				_vm->_scrollCol = 0;
 				return true;
 			}
 
 			_vm->_buffer1.moveBufferRight();
-			_vm->_room->buildColumn(_vm->_screen->_scrollCol, 0);
-		} while (!_vm->shouldQuit() && (_vm->_screen->_scrollX < 0));
+			_vm->_room->buildColumn(_vm->_scrollCol, 0);
+		} while (!_vm->shouldQuit() && (_vm->_scrollX < 0));
 
 		return false;
 	}
diff --git a/engines/access/room.cpp b/engines/access/room.cpp
index fc9cb6a..f7c2eab 100644
--- a/engines/access/room.cpp
+++ b/engines/access/room.cpp
@@ -253,33 +253,33 @@ void Room::setupRoom() {
 		screen.setIconPalette();
 
 	if (screen._vWindowWidth == _playFieldWidth) {
-		screen._scrollX = 0;
-		screen._scrollCol = 0;
+		_vm->_scrollX = 0;
+		_vm->_scrollCol = 0;
 	} else {
 		int xv = _vm->_player->_rawPlayer.x / TILE_WIDTH;
-		screen._scrollX = _vm->_player->_rawPlayer.x % TILE_WIDTH;
-		screen._scrollCol = MAX(xv - (screen._vWindowWidth / 2), 0);
+		_vm->_scrollX = _vm->_player->_rawPlayer.x % TILE_WIDTH;
+		_vm->_scrollCol = MAX(xv - (screen._vWindowWidth / 2), 0);
 
-		int sx = screen._scrollCol + screen._vWindowWidth - _playFieldWidth;
+		int sx = _vm->_scrollCol + screen._vWindowWidth - _playFieldWidth;
 		if (sx >= 0) {
-			screen._scrollCol -= sx + 1;
+			_vm->_scrollCol -= sx + 1;
 		}
 	}
 
 	if (screen._vWindowHeight == _playFieldHeight) {
-		screen._scrollY = 0;
-		screen._scrollRow = 0;
+		_vm->_scrollY = 0;
+		_vm->_scrollRow = 0;
 	} else {
-		screen._scrollY = _vm->_player->_rawPlayer.y -
+		_vm->_scrollY = _vm->_player->_rawPlayer.y -
 			(_vm->_player->_rawPlayer.y / 16) * 16;
 		int yc = MAX((_vm->_player->_rawPlayer.y >> 4) -
 			(screen._vWindowHeight / 2), 0);
-		screen._scrollRow = yc;
+		_vm->_scrollRow = yc;
 
 		yc = yc + screen._vWindowHeight - _playFieldHeight;
 		if (yc >= 0) {
-			screen._scrollRow = _playFieldHeight - screen._vWindowHeight;
-			screen._scrollY = 0;
+			_vm->_scrollRow = _playFieldHeight - screen._vWindowHeight;
+			_vm->_scrollY = 0;
 		}
 	}
 }
@@ -293,7 +293,7 @@ void Room::setWallCodes() {
 }
 
 void Room::buildScreen() {
-	int scrollCol = _vm->_screen->_scrollCol;
+	int scrollCol = _vm->_scrollCol;
 	int offset = 0;
 
 	// Clear current background buffer
@@ -304,11 +304,11 @@ void Room::buildScreen() {
 
 	// Loop through drawing each column of tiles forming the background
 	for (int idx = 0; idx < w; offset += TILE_WIDTH, ++idx) {
-		buildColumn(_vm->_screen->_scrollCol, offset);
-		++_vm->_screen->_scrollCol;
+		buildColumn(_vm->_scrollCol, offset);
+		++_vm->_scrollCol;
 	}
 
-	_vm->_screen->_scrollCol = scrollCol;
+	_vm->_scrollCol = scrollCol;
 	_vm->copyBF1BF2();
 }
 
@@ -316,7 +316,7 @@ void Room::buildColumn(int playX, int screenX) {
 	if (playX < 0 || playX >= _playFieldWidth)
 		return;
 
-	const byte *pSrc = _playField + _vm->_screen->_scrollRow *
+	const byte *pSrc = _playField + _vm->_scrollRow *
 		_playFieldWidth + playX;
 
 	// WORKAROUND: Original's use of '+ 1' would frequently cause memory overruns
@@ -341,7 +341,7 @@ void Room::buildRow(int playY, int screenY) {
 		return;
 	assert(screenY <= (_vm->_screen->h - TILE_HEIGHT));
 
-	const byte *pSrc = _playField + playY *_playFieldWidth + _vm->_screen->_scrollCol;
+	const byte *pSrc = _playField + playY *_playFieldWidth + _vm->_scrollCol;
 
 	// WORKAROUND: Original's use of '+ 1' would frequently cause memory overruns
 	int w = MIN(_vm->_screen->_vWindowWidth + 1, _playFieldWidth);
diff --git a/engines/access/screen.cpp b/engines/access/screen.cpp
index d0974bd..35069ba 100644
--- a/engines/access/screen.cpp
+++ b/engines/access/screen.cpp
@@ -50,7 +50,6 @@ Screen::Screen(AccessEngine *vm) : _vm(vm) {
 	_currentPanel = 0;
 	_hideFlag = true;
 	_startColor = _numColors = 0;
-	_scrollCol = _scrollRow = 0;
 	_windowXAdd = _windowYAdd = 0;
 	_screenYOff = 0;
 	_screenChangeFlag = false;
@@ -76,8 +75,8 @@ void Screen::setDisplayScan() {
 	_clipWidth = this->w - 1;
 	_clipHeight = this->h - 1;
 	_windowXAdd = _windowYAdd = 0;
-	_scrollX = _scrollY = 0;
-	_scrollCol = _scrollRow = 0;
+	_vm->_scrollX = _vm->_scrollY = 0;
+	_vm->_scrollCol = _vm->_scrollRow = 0;
 	_bufferStart.x = _bufferStart.y = 0;
 	_screenYOff = 0;
 }
@@ -225,10 +224,10 @@ void Screen::saveScreen() {
 	_screenSave._clipHeight = _clipHeight;
 	_screenSave._windowXAdd = _windowXAdd;
 	_screenSave._windowYAdd = _windowYAdd;
-	_screenSave._scroll.x = _scrollX;
-	_screenSave._scroll.y = _scrollY;
-	_screenSave._scrollCol = _scrollCol;
-	_screenSave._scrollRow = _scrollRow;
+	_screenSave._scroll.x = _vm->_scrollX;
+	_screenSave._scroll.y = _vm->_scrollY;
+	_screenSave._scrollCol = _vm->_scrollCol;
+	_screenSave._scrollRow = _vm->_scrollRow;
 	_screenSave._bufferStart.x = _bufferStart.x;
 	_screenSave._bufferStart.y = _bufferStart.y;
 	_screenSave._screenYOff = _screenYOff;
@@ -239,10 +238,10 @@ void Screen::restoreScreen() {
 	_clipHeight = _screenSave._clipHeight;
 	_windowXAdd = _screenSave._windowXAdd;
 	_windowYAdd = _screenSave._windowYAdd;
-	_scrollX = _screenSave._scroll.x;
-	_scrollY = _screenSave._scroll.y;
-	_scrollCol = _screenSave._scrollCol;
-	_scrollRow = _screenSave._scrollRow;
+	_vm->_scrollX = _screenSave._scroll.x;
+	_vm->_scrollY = _screenSave._scroll.y;
+	_vm->_scrollCol = _screenSave._scrollCol;
+	_vm->_scrollRow = _screenSave._scrollRow;
 	_bufferStart.x = _screenSave._bufferStart.x;
 	_bufferStart.y = _screenSave._bufferStart.y;
 	_screenYOff = _screenSave._screenYOff;
diff --git a/engines/access/screen.h b/engines/access/screen.h
index bf4ccea..0fa111c 100644
--- a/engines/access/screen.h
+++ b/engines/access/screen.h
@@ -74,7 +74,6 @@ public:
 	int _vesaMode;
 	int _startColor, _numColors;
 	Common::Point _bufferStart;
-	int _scrollCol, _scrollRow;
 	int _windowXAdd, _windowYAdd;
 	int _screenYOff;
 	byte _manPal[0x60];
diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp
index d1dd5e7..2e22d9a 100644
--- a/engines/access/scripts.cpp
+++ b/engines/access/scripts.cpp
@@ -508,10 +508,10 @@ void Scripts::cmdSetBuffer() {
 }
 
 void Scripts::cmdSetScroll() {
-	_vm->_screen->_scrollCol = _data->readUint16LE();
-	_vm->_screen->_scrollRow = _data->readUint16LE();
-	_vm->_screen->_scrollX = 0;
-	_vm->_screen->_scrollY = 0;
+	_vm->_scrollCol = _data->readUint16LE();
+	_vm->_scrollRow = _data->readUint16LE();
+	_vm->_scrollX = 0;
+	_vm->_scrollY = 0;
 }
 
 void Scripts::cmdSaveRect() {


Commit: 93bbe3a45e4d9a6542b93ec9747bc0c6031054ae
    https://github.com/scummvm/scummvm/commit/93bbe3a45e4d9a6542b93ec9747bc0c6031054ae
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-18T21:52:59-05:00

Commit Message:
ACCESS: Manually implement ASurface::copyFrom for performance

The original called Surface::copyFrom, which keeps recreating the
dest surface with each copy. This version simply copies the image

Changed paths:
    engines/access/asurface.cpp



diff --git a/engines/access/asurface.cpp b/engines/access/asurface.cpp
index 27e73a0..38af7ad 100644
--- a/engines/access/asurface.cpp
+++ b/engines/access/asurface.cpp
@@ -252,7 +252,11 @@ void ASurface::transCopyFrom(ASurface &src) {
 }
 
 void ASurface::copyFrom(Graphics::Surface &src) {
-	Graphics::Surface::copyFrom(src);
+	for (int y = 0; y < src.h; ++y) {
+		const byte *srcP = (const byte *)src.getBasePtr(0, y);
+		byte *destP = (byte *)getBasePtr(0, y);
+		Common::copy(srcP, srcP + src.w, destP);
+	}
 }
 
 void ASurface::copyBuffer(Graphics::Surface *src) {


Commit: 3c2ac653b2ee2c7f2efd2684516a13eb47cbf102
    https://github.com/scummvm/scummvm/commit/3c2ac653b2ee2c7f2efd2684516a13eb47cbf102
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-12-19T07:20:40-05:00

Commit Message:
Merge pull request #548 from dreammaster/access

ACCESS: Support for Amazon - Guardians of Eden

Changed paths:
  A engines/access/access.cpp
  A engines/access/access.h
  A engines/access/amazon/amazon_game.cpp
  A engines/access/amazon/amazon_game.h
  A engines/access/amazon/amazon_logic.cpp
  A engines/access/amazon/amazon_logic.h
  A engines/access/amazon/amazon_player.cpp
  A engines/access/amazon/amazon_player.h
  A engines/access/amazon/amazon_resources.cpp
  A engines/access/amazon/amazon_resources.h
  A engines/access/amazon/amazon_room.cpp
  A engines/access/amazon/amazon_room.h
  A engines/access/amazon/amazon_scripts.cpp
  A engines/access/amazon/amazon_scripts.h
  A engines/access/animation.cpp
  A engines/access/animation.h
  A engines/access/asurface.cpp
  A engines/access/asurface.h
  A engines/access/bubble_box.cpp
  A engines/access/bubble_box.h
  A engines/access/char.cpp
  A engines/access/char.h
  A engines/access/configure.engine
  A engines/access/data.cpp
  A engines/access/data.h
  A engines/access/debugger.cpp
  A engines/access/debugger.h
  A engines/access/decompress.cpp
  A engines/access/decompress.h
  A engines/access/detection.cpp
  A engines/access/detection_tables.h
  A engines/access/events.cpp
  A engines/access/events.h
  A engines/access/files.cpp
  A engines/access/files.h
  A engines/access/font.cpp
  A engines/access/font.h
  A engines/access/inventory.cpp
  A engines/access/inventory.h
  A engines/access/martian/martian_game.cpp
  A engines/access/martian/martian_game.h
  A engines/access/martian/martian_resources.cpp
  A engines/access/martian/martian_resources.h
  A engines/access/martian/martian_room.cpp
  A engines/access/martian/martian_room.h
  A engines/access/martian/martian_scripts.cpp
  A engines/access/martian/martian_scripts.h
  A engines/access/module.mk
  A engines/access/player.cpp
  A engines/access/player.h
  A engines/access/resources.cpp
  A engines/access/resources.h
  A engines/access/room.cpp
  A engines/access/room.h
  A engines/access/screen.cpp
  A engines/access/screen.h
  A engines/access/scripts.cpp
  A engines/access/scripts.h
  A engines/access/sound.cpp
  A engines/access/sound.h
  A engines/access/video.cpp
  A engines/access/video.h









More information about the Scummvm-git-logs mailing list