aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--AUTHORS15
-rw-r--r--CONTRIBUTING.md12
-rw-r--r--NEWS7
-rw-r--r--README4
-rw-r--r--audio/softsynth/mt32/Analog.cpp348
-rw-r--r--audio/softsynth/mt32/Analog.h57
-rw-r--r--audio/softsynth/mt32/BReverbModel.cpp10
-rw-r--r--audio/softsynth/mt32/BReverbModel.h2
-rw-r--r--audio/softsynth/mt32/LA32FloatWaveGenerator.cpp2
-rw-r--r--audio/softsynth/mt32/LA32Ramp.cpp2
-rw-r--r--audio/softsynth/mt32/LA32WaveGenerator.cpp10
-rw-r--r--audio/softsynth/mt32/MemoryRegion.h124
-rw-r--r--audio/softsynth/mt32/MidiEventQueue.h67
-rw-r--r--audio/softsynth/mt32/Part.cpp1
-rw-r--r--audio/softsynth/mt32/Partial.cpp5
-rw-r--r--audio/softsynth/mt32/PartialManager.cpp1
-rw-r--r--audio/softsynth/mt32/Poly.cpp1
-rw-r--r--audio/softsynth/mt32/Poly.h1
-rw-r--r--audio/softsynth/mt32/ROMInfo.cpp15
-rw-r--r--audio/softsynth/mt32/ROMInfo.h4
-rw-r--r--audio/softsynth/mt32/Structures.h47
-rw-r--r--audio/softsynth/mt32/Synth.cpp248
-rw-r--r--audio/softsynth/mt32/Synth.h347
-rw-r--r--audio/softsynth/mt32/TVA.cpp1
-rw-r--r--audio/softsynth/mt32/TVF.cpp1
-rw-r--r--audio/softsynth/mt32/TVP.cpp1
-rw-r--r--audio/softsynth/mt32/Tables.cpp5
-rw-r--r--audio/softsynth/mt32/Tables.h15
-rw-r--r--audio/softsynth/mt32/Types.h40
-rw-r--r--audio/softsynth/mt32/internals.h83
-rw-r--r--audio/softsynth/mt32/module.mk1
-rw-r--r--audio/softsynth/mt32/mt32emu.h67
-rw-r--r--audio/timestamp.cpp6
-rw-r--r--backends/events/dinguxsdl/dinguxsdl-events.cpp34
-rw-r--r--backends/fs/amigaos4/amigaos4-fs.cpp59
-rw-r--r--backends/fs/amigaos4/amigaos4-fs.h11
-rw-r--r--backends/graphics/opengl/opengl-graphics.cpp6
-rw-r--r--backends/graphics/openglsdl/openglsdl-graphics.cpp2
-rw-r--r--backends/keymapper/action.h2
-rw-r--r--backends/platform/android/asset-archive.cpp3
-rw-r--r--backends/platform/dingux/dingux.mk35
-rw-r--r--backends/platform/sdl/sdl.cpp2
-rw-r--r--backends/platform/wii/osystem_events.cpp136
-rw-r--r--backends/taskbar/unity/unity-taskbar.cpp9
-rw-r--r--base/main.cpp28
-rw-r--r--base/version.cpp8
-rw-r--r--common/EventMapper.cpp6
-rw-r--r--common/c++11-compat.h6
-rw-r--r--common/scummsys.h2
-rw-r--r--common/unzip.cpp2
-rw-r--r--common/xmlparser.cpp2
-rwxr-xr-xconfig.guess364
-rwxr-xr-xconfig.sub158
-rwxr-xr-xconfigure39
-rw-r--r--devtools/create_kyradat/create_kyradat.cpp2
-rw-r--r--devtools/create_kyradat/games.cpp1
-rw-r--r--devtools/create_kyradat/resources.cpp89
-rw-r--r--devtools/create_kyradat/resources/eob1_dos_italian.h891
-rw-r--r--devtools/create_translations/po_parser.cpp7
-rwxr-xr-xdevtools/credits.pl13
-rw-r--r--devtools/scumm-md5.txt43
-rw-r--r--dists/engine-data/kyra.datbin485978 -> 496648 bytes
-rw-r--r--dists/gcw0/default.gcw0.desktop16
-rwxr-xr-xdists/gcw0/opk_make.sh111
-rw-r--r--dists/gcw0/scummvm.pngbin0 -> 2656 bytes
-rwxr-xr-xdists/gcw0/scummvm.sh9
-rw-r--r--dists/gcw0/scummvmrc9
-rw-r--r--engines/access/access.cpp575
-rw-r--r--engines/access/access.h296
-rw-r--r--engines/access/amazon/amazon_game.cpp786
-rw-r--r--engines/access/amazon/amazon_game.h139
-rw-r--r--engines/access/amazon/amazon_logic.cpp2230
-rw-r--r--engines/access/amazon/amazon_logic.h253
-rw-r--r--engines/access/amazon/amazon_player.cpp86
-rw-r--r--engines/access/amazon/amazon_player.h48
-rw-r--r--engines/access/amazon/amazon_resources.cpp2411
-rw-r--r--engines/access/amazon/amazon_resources.h148
-rw-r--r--engines/access/amazon/amazon_room.cpp241
-rw-r--r--engines/access/amazon/amazon_room.h72
-rw-r--r--engines/access/amazon/amazon_scripts.cpp516
-rw-r--r--engines/access/amazon/amazon_scripts.h67
-rw-r--r--engines/access/animation.cpp340
-rw-r--r--engines/access/animation.h139
-rw-r--r--engines/access/asurface.cpp346
-rw-r--r--engines/access/asurface.h166
-rw-r--r--engines/access/bubble_box.cpp281
-rw-r--r--engines/access/bubble_box.h85
-rw-r--r--engines/access/char.cpp162
-rw-r--r--engines/access/char.h64
-rw-r--r--engines/access/configure.engine3
-rw-r--r--engines/access/data.cpp76
-rw-r--r--engines/access/data.h103
-rw-r--r--engines/access/debugger.cpp164
-rw-r--r--engines/access/debugger.h64
-rw-r--r--engines/access/decompress.cpp128
-rw-r--r--engines/access/decompress.h43
-rw-r--r--engines/access/detection.cpp209
-rw-r--r--engines/access/detection_tables.h91
-rw-r--r--engines/access/events.cpp373
-rw-r--r--engines/access/events.h157
-rw-r--r--engines/access/files.cpp239
-rw-r--r--engines/access/files.h142
-rw-r--r--engines/access/font.cpp179
-rw-r--r--engines/access/font.h103
-rw-r--r--engines/access/inventory.cpp536
-rw-r--r--engines/access/inventory.h140
-rw-r--r--engines/access/martian/martian_game.cpp168
-rw-r--r--engines/access/martian/martian_game.h76
-rw-r--r--engines/access/martian/martian_resources.cpp722
-rw-r--r--engines/access/martian/martian_resources.h52
-rw-r--r--engines/access/martian/martian_room.cpp141
-rw-r--r--engines/access/martian/martian_room.h66
-rw-r--r--engines/access/martian/martian_scripts.cpp48
-rw-r--r--engines/access/martian/martian_scripts.h49
-rw-r--r--engines/access/module.mk41
-rw-r--r--engines/access/player.cpp825
-rw-r--r--engines/access/player.h152
-rw-r--r--engines/access/resources.cpp109
-rw-r--r--engines/access/resources.h53
-rw-r--r--engines/access/room.cpp833
-rw-r--r--engines/access/room.h201
-rw-r--r--engines/access/screen.cpp369
-rw-r--r--engines/access/screen.h182
-rw-r--r--engines/access/scripts.cpp887
-rw-r--r--engines/access/scripts.h168
-rw-r--r--engines/access/sound.cpp326
-rw-r--r--engines/access/sound.h111
-rw-r--r--engines/access/video.cpp187
-rw-r--r--engines/access/video.h82
-rw-r--r--engines/agi/agi.cpp6
-rw-r--r--engines/agi/detection.cpp15
-rw-r--r--engines/agi/graphics.cpp23
-rw-r--r--engines/agi/loader_v2.cpp8
-rw-r--r--engines/agi/loader_v3.cpp5
-rw-r--r--engines/agi/preagi_mickey.cpp2
-rw-r--r--engines/agos/detection_tables.h26
-rw-r--r--engines/agos/gfx.cpp2
-rw-r--r--engines/agos/input.cpp10
-rw-r--r--engines/agos/midi.cpp22
-rw-r--r--engines/agos/midi.h4
-rw-r--r--engines/bbvs/bbvs.cpp98
-rw-r--r--engines/bbvs/bbvs.h78
-rw-r--r--engines/bbvs/detection.cpp2
-rw-r--r--engines/bbvs/dialogs.cpp8
-rw-r--r--engines/bbvs/dialogs.h6
-rw-r--r--engines/bbvs/gamemodule.cpp40
-rw-r--r--engines/bbvs/gamemodule.h50
-rw-r--r--engines/bbvs/graphics.cpp4
-rw-r--r--engines/bbvs/minigames/bbairguitar.cpp62
-rw-r--r--engines/bbvs/minigames/bbairguitar.h34
-rw-r--r--engines/bbvs/minigames/bbant.cpp64
-rw-r--r--engines/bbvs/minigames/bbant.h26
-rw-r--r--engines/bbvs/minigames/bbloogie.cpp68
-rw-r--r--engines/bbvs/minigames/bbloogie.h36
-rw-r--r--engines/bbvs/minigames/bbtennis.cpp44
-rw-r--r--engines/bbvs/minigames/bbtennis.h22
-rw-r--r--engines/bbvs/minigames/minigame.cpp6
-rw-r--r--engines/bbvs/minigames/minigame.h14
-rw-r--r--engines/bbvs/saveload.cpp26
-rw-r--r--engines/bbvs/scene.cpp20
-rw-r--r--engines/bbvs/spritemodule.cpp12
-rw-r--r--engines/bbvs/videoplayer.cpp4
-rw-r--r--engines/bbvs/walk.cpp24
-rw-r--r--engines/cge/POTFILES2
-rw-r--r--engines/cge/detection.cpp56
-rw-r--r--engines/cge/fileio.cpp22
-rw-r--r--engines/cge/vga13h.cpp2
-rw-r--r--engines/cge2/POTFILES1
-rw-r--r--engines/cge2/cge2.cpp3
-rw-r--r--engines/cge2/cge2.h5
-rw-r--r--engines/cge2/cge2_main.cpp27
-rw-r--r--engines/cge2/cge2_main.h2
-rw-r--r--engines/cge2/configure.engine2
-rw-r--r--engines/cge2/detection.cpp62
-rw-r--r--engines/cge2/events.cpp4
-rw-r--r--engines/cge2/fileio.cpp14
-rw-r--r--engines/cge2/hero.cpp28
-rw-r--r--engines/cge2/map.cpp4
-rw-r--r--engines/cge2/saveload.cpp4
-rw-r--r--engines/cge2/snail.cpp12
-rw-r--r--engines/cge2/sound.cpp6
-rw-r--r--engines/cge2/spare.h2
-rw-r--r--engines/cge2/talk.cpp2
-rw-r--r--engines/cge2/toolbar.cpp15
-rw-r--r--engines/cge2/vga13h.cpp11
-rw-r--r--engines/drascula/detection.cpp3
-rw-r--r--engines/drascula/drascula.cpp14
-rw-r--r--engines/dreamweb/POTFILES2
-rw-r--r--engines/engine.cpp31
-rw-r--r--engines/engine.h28
-rw-r--r--engines/fullpipe/fullpipe.cpp4
-rw-r--r--engines/fullpipe/gfx.cpp8
-rw-r--r--engines/fullpipe/input.cpp2
-rw-r--r--engines/fullpipe/inventory.cpp2
-rw-r--r--engines/fullpipe/mgm.cpp7
-rw-r--r--engines/fullpipe/motion.cpp14
-rw-r--r--engines/fullpipe/scene.cpp2
-rw-r--r--engines/fullpipe/scenes/scene02.cpp2
-rw-r--r--engines/fullpipe/scenes/scene04.cpp9
-rw-r--r--engines/fullpipe/scenes/scene14.cpp2
-rw-r--r--engines/fullpipe/scenes/scene15.cpp2
-rw-r--r--engines/fullpipe/scenes/scene16.cpp10
-rw-r--r--engines/fullpipe/scenes/scene23.cpp2
-rw-r--r--engines/fullpipe/scenes/scene27.cpp2
-rw-r--r--engines/fullpipe/scenes/scene28.cpp2
-rw-r--r--engines/fullpipe/scenes/scene29.cpp2
-rw-r--r--engines/fullpipe/scenes/scene37.cpp2
-rw-r--r--engines/fullpipe/sound.cpp2
-rw-r--r--engines/fullpipe/statics.cpp19
-rw-r--r--engines/gob/POTFILES2
-rw-r--r--engines/gob/inter_v1.cpp2
-rw-r--r--engines/groovie/graphics.cpp25
-rw-r--r--engines/groovie/graphics.h2
-rw-r--r--engines/groovie/roq.cpp76
-rw-r--r--engines/groovie/roq.h6
-rw-r--r--engines/groovie/script.cpp69
-rw-r--r--engines/groovie/script.h1
-rw-r--r--engines/hopkins/POTFILES2
-rw-r--r--engines/hopkins/computer.cpp2
-rw-r--r--engines/hopkins/files.cpp2
-rw-r--r--engines/hopkins/sound.cpp53
-rw-r--r--engines/hopkins/sound.h2
-rw-r--r--engines/hopkins/talk.cpp2
-rw-r--r--engines/kyra/POTFILES1
-rw-r--r--engines/kyra/detection_tables.h16
-rw-r--r--engines/kyra/staticres.cpp2
-rw-r--r--engines/kyra/staticres_eob.cpp28
-rw-r--r--engines/kyra/text_rpg.cpp4
-rw-r--r--engines/kyra/vqa.cpp2
-rw-r--r--engines/mads/animation.cpp84
-rw-r--r--engines/mads/animation.h25
-rw-r--r--engines/mads/audio.cpp43
-rw-r--r--engines/mads/audio.h1
-rw-r--r--engines/mads/debugger.cpp43
-rw-r--r--engines/mads/debugger.h2
-rw-r--r--engines/mads/dialogs.cpp74
-rw-r--r--engines/mads/dialogs.h32
-rw-r--r--engines/mads/game.cpp4
-rw-r--r--engines/mads/mads.cpp7
-rw-r--r--engines/mads/mads.h1
-rw-r--r--engines/mads/menu_views.cpp768
-rw-r--r--engines/mads/menu_views.h225
-rw-r--r--engines/mads/module.mk1
-rw-r--r--engines/mads/msurface.cpp9
-rw-r--r--engines/mads/msurface.h9
-rw-r--r--engines/mads/nebular/dialogs_nebular.cpp87
-rw-r--r--engines/mads/nebular/dialogs_nebular.h36
-rw-r--r--engines/mads/nebular/game_nebular.cpp28
-rw-r--r--engines/mads/nebular/game_nebular.h4
-rw-r--r--engines/mads/nebular/menu_nebular.cpp638
-rw-r--r--engines/mads/nebular/menu_nebular.h154
-rw-r--r--engines/mads/nebular/nebular_scenes5.cpp2
-rw-r--r--engines/mads/nebular/nebular_scenes6.cpp7
-rw-r--r--engines/mads/nebular/nebular_scenes7.cpp2
-rw-r--r--engines/mads/nebular/nebular_scenes8.cpp2
-rw-r--r--engines/mads/nebular/sound_nebular.cpp29
-rw-r--r--engines/mads/nebular/sound_nebular.h5
-rw-r--r--engines/mads/palette.cpp65
-rw-r--r--engines/mads/palette.h2
-rw-r--r--engines/mads/phantom/game_phantom.cpp15
-rw-r--r--engines/mads/scene.cpp9
-rw-r--r--engines/mads/scene.h10
-rw-r--r--engines/mads/scene_data.cpp15
-rw-r--r--engines/mads/screen.cpp2
-rw-r--r--engines/mads/sequence.cpp2
-rw-r--r--engines/mads/sound.cpp22
-rw-r--r--engines/mads/sound.h2
-rw-r--r--engines/mads/sprites.cpp6
-rw-r--r--engines/mads/user_interface.h2
-rw-r--r--engines/mohawk/riven_external.cpp2
-rw-r--r--engines/mortevielle/detection_tables.h2
-rw-r--r--engines/mortevielle/mortevielle.h2
-rw-r--r--engines/mortevielle/utils.cpp2
-rw-r--r--engines/neverhood/console.cpp2
-rw-r--r--engines/neverhood/modules/module2400.cpp9
-rw-r--r--engines/neverhood/modules/module2700_sprites.cpp56
-rw-r--r--engines/neverhood/modules/module2800.cpp15
-rw-r--r--engines/neverhood/modules/module2800_sprites.cpp10
-rw-r--r--engines/neverhood/modules/module3000.cpp12
-rw-r--r--engines/neverhood/modules/module3000_sprites.cpp36
-rw-r--r--engines/neverhood/sound.cpp2
-rw-r--r--engines/pegasus/input.cpp2
-rw-r--r--engines/pegasus/pegasus.cpp2
-rw-r--r--engines/prince/animation.cpp178
-rw-r--r--engines/prince/animation.h73
-rw-r--r--engines/prince/archive.cpp166
-rw-r--r--engines/prince/archive.h62
-rw-r--r--engines/prince/common.h (renamed from engines/zvision/core/menu.h)27
-rw-r--r--engines/prince/configure.engine3
-rw-r--r--engines/prince/cursor.cpp54
-rw-r--r--engines/prince/cursor.h46
-rw-r--r--engines/prince/curve_values.h45
-rw-r--r--engines/prince/debugger.cpp174
-rw-r--r--engines/prince/debugger.h58
-rw-r--r--engines/prince/decompress.cpp171
-rw-r--r--engines/prince/decompress.h44
-rw-r--r--engines/prince/detection.cpp75
-rw-r--r--engines/prince/detection.h130
-rw-r--r--engines/prince/flags.cpp420
-rw-r--r--engines/prince/flags.h421
-rw-r--r--engines/prince/font.cpp94
-rw-r--r--engines/prince/font.h64
-rw-r--r--engines/prince/graphics.cpp474
-rw-r--r--engines/prince/graphics.h76
-rw-r--r--engines/prince/hero.cpp1002
-rw-r--r--engines/prince/hero.h184
-rw-r--r--engines/prince/hero_set.h244
-rw-r--r--engines/prince/mhwanh.cpp71
-rw-r--r--engines/prince/mhwanh.h55
-rw-r--r--engines/prince/mob.cpp108
-rw-r--r--engines/prince/mob.h70
-rw-r--r--engines/prince/module.mk30
-rw-r--r--engines/prince/musNum.h87
-rw-r--r--engines/prince/object.cpp113
-rw-r--r--engines/prince/object.h70
-rw-r--r--engines/prince/option_text.h85
-rw-r--r--engines/prince/prince.cpp4846
-rw-r--r--engines/prince/prince.h674
-rw-r--r--engines/prince/pscr.cpp75
-rw-r--r--engines/prince/pscr.h48
-rw-r--r--engines/prince/resource.h100
-rw-r--r--engines/prince/saveload.cpp531
-rw-r--r--engines/prince/script.cpp2082
-rw-r--r--engines/prince/script.h398
-rw-r--r--engines/prince/sound.cpp211
-rw-r--r--engines/prince/sound.h67
-rw-r--r--engines/prince/variatxt.cpp55
-rw-r--r--engines/prince/variatxt.h (renamed from engines/zvision/inventory/inventory_manager.h)24
-rw-r--r--engines/queen/POTFILES2
-rw-r--r--engines/queen/logic.cpp6
-rw-r--r--engines/queen/talk.cpp12
-rw-r--r--engines/saga/actor.h1
-rw-r--r--engines/saga/introproc_ite.cpp2
-rw-r--r--engines/saga/saveload.cpp29
-rw-r--r--engines/saga/scene.h3
-rw-r--r--engines/saga/sfuncs.cpp4
-rw-r--r--engines/saga/shorten.cpp2
-rw-r--r--engines/sci/console.cpp5
-rw-r--r--engines/sci/detection.cpp22
-rw-r--r--engines/sci/detection_tables.h69
-rw-r--r--engines/sci/engine/kernel.h4
-rw-r--r--engines/sci/engine/kfile.cpp20
-rw-r--r--engines/sci/engine/kgraphics.cpp33
-rw-r--r--engines/sci/engine/kstring.cpp10
-rw-r--r--engines/sci/engine/savegame.cpp10
-rw-r--r--engines/sci/engine/script_patches.cpp61
-rw-r--r--engines/sci/engine/script_patches.h2
-rw-r--r--engines/sci/engine/state.cpp115
-rw-r--r--engines/sci/engine/workarounds.cpp3
-rw-r--r--engines/sci/event.cpp2
-rw-r--r--engines/sci/graphics/controls16.cpp12
-rw-r--r--engines/sci/graphics/controls16.h6
-rw-r--r--engines/sci/graphics/cursor.cpp8
-rw-r--r--engines/sci/graphics/font.cpp8
-rw-r--r--engines/sci/graphics/font.h4
-rw-r--r--engines/sci/graphics/frameout.cpp19
-rw-r--r--engines/sci/graphics/paint16.cpp6
-rw-r--r--engines/sci/graphics/paint16.h2
-rw-r--r--engines/sci/graphics/paint32.cpp2
-rw-r--r--engines/sci/graphics/palette.cpp87
-rw-r--r--engines/sci/graphics/palette.h6
-rw-r--r--engines/sci/graphics/picture.cpp88
-rw-r--r--engines/sci/graphics/portrait.cpp102
-rw-r--r--engines/sci/graphics/portrait.h2
-rw-r--r--engines/sci/graphics/ports.cpp16
-rw-r--r--engines/sci/graphics/screen.cpp386
-rw-r--r--engines/sci/graphics/screen.h94
-rw-r--r--engines/sci/graphics/text16.cpp225
-rw-r--r--engines/sci/graphics/text16.h15
-rw-r--r--engines/sci/graphics/transitions.cpp6
-rw-r--r--engines/sci/graphics/view.cpp3
-rw-r--r--engines/sci/module.mk4
-rw-r--r--engines/sci/parser/vocabulary.cpp5
-rw-r--r--engines/sci/resource.cpp55
-rw-r--r--engines/sci/resource.h16
-rw-r--r--engines/sci/resource_audio.cpp3
-rw-r--r--engines/sci/sci.cpp6
-rw-r--r--engines/sci/sci.h13
-rw-r--r--engines/sci/sound/drivers/midi.cpp74
-rw-r--r--engines/sci/sound/music.cpp2
-rw-r--r--engines/sci/sound/music.h2
-rw-r--r--engines/scumm/POTFILES3
-rw-r--r--engines/scumm/actor.cpp725
-rw-r--r--engines/scumm/actor.h49
-rw-r--r--engines/scumm/boxes.cpp24
-rw-r--r--engines/scumm/cdda.cpp2
-rw-r--r--engines/scumm/detection.cpp11
-rw-r--r--engines/scumm/detection_tables.h27
-rw-r--r--engines/scumm/dialogs.cpp6
-rw-r--r--engines/scumm/file.cpp26
-rw-r--r--engines/scumm/input.cpp12
-rw-r--r--engines/scumm/players/player_mac.cpp1
-rw-r--r--engines/scumm/resource_v2.cpp10
-rw-r--r--engines/scumm/room.cpp9
-rw-r--r--engines/scumm/saveload.cpp9
-rw-r--r--engines/scumm/saveload.h2
-rw-r--r--engines/scumm/script.cpp6
-rw-r--r--engines/scumm/script_v0.cpp34
-rw-r--r--engines/scumm/script_v2.cpp9
-rw-r--r--engines/scumm/script_v5.cpp4
-rw-r--r--engines/scumm/script_v6.cpp6
-rw-r--r--engines/scumm/scumm-md5.h42
-rw-r--r--engines/scumm/scumm.cpp65
-rw-r--r--engines/scumm/scumm.h6
-rw-r--r--engines/scumm/scumm_v0.h8
-rw-r--r--engines/scumm/sound.cpp4
-rw-r--r--engines/scumm/vars.cpp2
-rw-r--r--engines/scumm/verbs.cpp57
-rw-r--r--engines/sword1/POTFILES2
-rw-r--r--engines/sword1/console.cpp2
-rw-r--r--engines/sword1/sound.cpp2
-rw-r--r--engines/sword25/gfx/renderobjectmanager.cpp2
-rw-r--r--engines/sword25/kernel/outputpersistenceblock.cpp7
-rw-r--r--engines/sword25/kernel/outputpersistenceblock.h1
-rw-r--r--engines/sword25/module.mk7
-rw-r--r--engines/sword25/script/luascript.cpp61
-rw-r--r--engines/sword25/sword25.cpp1
-rw-r--r--engines/sword25/util/double_serialization.cpp138
-rw-r--r--engines/sword25/util/double_serialization.h95
-rw-r--r--engines/sword25/util/lua/lapi.cpp3
-rw-r--r--engines/sword25/util/lua/liolib.cpp2
-rw-r--r--engines/sword25/util/lua_persist.cpp804
-rw-r--r--engines/sword25/util/lua_persistence.h67
-rw-r--r--engines/sword25/util/lua_persistence_util.cpp393
-rw-r--r--engines/sword25/util/lua_persistence_util.h122
-rw-r--r--engines/sword25/util/lua_unpersist.cpp722
-rw-r--r--engines/sword25/util/pluto/CHANGELOG37
-rw-r--r--engines/sword25/util/pluto/FILEFORMAT168
-rw-r--r--engines/sword25/util/pluto/README133
-rw-r--r--engines/sword25/util/pluto/THANKS9
-rw-r--r--engines/sword25/util/pluto/pdep.cpp112
-rw-r--r--engines/sword25/util/pluto/pdep/README5
-rw-r--r--engines/sword25/util/pluto/pdep/lzio.h65
-rw-r--r--engines/sword25/util/pluto/pdep/pdep.h42
-rw-r--r--engines/sword25/util/pluto/pluto.cpp2083
-rw-r--r--engines/sword25/util/pluto/pluto.h25
-rw-r--r--engines/sword25/util/pluto/plzio.cpp74
-rw-r--r--engines/tinsel/tinsel.cpp15
-rw-r--r--engines/tony/game.cpp4
-rw-r--r--engines/tony/gfxcore.cpp119
-rw-r--r--engines/tony/mpal/lzo.cpp2
-rw-r--r--engines/tony/window.cpp14
-rw-r--r--engines/toon/character.cpp2
-rw-r--r--engines/toon/state.cpp2
-rw-r--r--engines/touche/detection.cpp1
-rw-r--r--engines/tsage/POTFILES3
-rw-r--r--engines/tsage/blue_force/blueforce_dialogs.cpp2
-rw-r--r--engines/tsage/debugger.cpp6
-rw-r--r--engines/tsage/debugger.h4
-rw-r--r--engines/tsage/module.mk3
-rw-r--r--engines/tsage/ringworld/ringworld_dialogs.cpp2
-rw-r--r--engines/tsage/ringworld2/ringworld2_airduct.cpp909
-rw-r--r--engines/tsage/ringworld2/ringworld2_airduct.h89
-rw-r--r--engines/tsage/ringworld2/ringworld2_logic.cpp8
-rw-r--r--engines/tsage/ringworld2/ringworld2_outpost.cpp4700
-rw-r--r--engines/tsage/ringworld2/ringworld2_outpost.h259
-rw-r--r--engines/tsage/ringworld2/ringworld2_scenes0.cpp2
-rw-r--r--engines/tsage/ringworld2/ringworld2_scenes1.cpp7254
-rw-r--r--engines/tsage/ringworld2/ringworld2_scenes1.h401
-rw-r--r--engines/tsage/ringworld2/ringworld2_scenes3.cpp2
-rw-r--r--engines/tsage/ringworld2/ringworld2_vampire.cpp1821
-rw-r--r--engines/tsage/ringworld2/ringworld2_vampire.h179
-rw-r--r--engines/wintermute/POTFILES1
-rw-r--r--engines/wintermute/base/base_engine.cpp3
-rw-r--r--engines/wintermute/base/base_engine.h9
-rw-r--r--engines/wintermute/base/base_game.cpp5
-rw-r--r--engines/wintermute/base/base_game.h2
-rw-r--r--engines/wintermute/base/base_game_settings.cpp5
-rw-r--r--engines/wintermute/base/base_game_settings.h1
-rw-r--r--engines/wintermute/base/base_keyboard_state.cpp48
-rw-r--r--engines/wintermute/base/base_sprite.cpp15
-rw-r--r--engines/wintermute/base/base_string_table.cpp9
-rw-r--r--engines/wintermute/base/base_string_table.h1
-rw-r--r--engines/wintermute/base/sound/base_sound.cpp18
-rw-r--r--engines/wintermute/base/sound/base_sound_buffer.cpp29
-rw-r--r--engines/wintermute/base/sound/base_sound_buffer.h15
-rw-r--r--engines/wintermute/base/sound/base_sound_manager.cpp8
-rw-r--r--engines/wintermute/detection.cpp6
-rw-r--r--engines/wintermute/detection_tables.h1552
-rw-r--r--engines/wintermute/game_description.h53
-rw-r--r--engines/wintermute/math/rect32.h2
-rw-r--r--engines/wintermute/module.mk2
-rw-r--r--engines/wintermute/video/subtitle_card.cpp56
-rw-r--r--engines/wintermute/video/subtitle_card.h53
-rw-r--r--engines/wintermute/video/video_subtitler.cpp266
-rw-r--r--engines/wintermute/video/video_subtitler.h53
-rw-r--r--engines/wintermute/video/video_theora_player.cpp27
-rw-r--r--engines/wintermute/video/video_theora_player.h6
-rw-r--r--engines/wintermute/wintermute.cpp4
-rw-r--r--engines/wintermute/wintermute.h5
-rw-r--r--engines/zvision/POTFILES1
-rw-r--r--engines/zvision/animation/rlf_animation.cpp331
-rw-r--r--engines/zvision/animation/rlf_animation.h163
-rw-r--r--engines/zvision/core/clock.cpp (renamed from engines/zvision/utility/clock.cpp)3
-rw-r--r--engines/zvision/core/clock.h (renamed from engines/zvision/utility/clock.h)11
-rw-r--r--engines/zvision/core/console.cpp188
-rw-r--r--engines/zvision/core/console.h6
-rw-r--r--engines/zvision/core/events.cpp434
-rw-r--r--engines/zvision/core/save_manager.cpp206
-rw-r--r--engines/zvision/cursors/cursor.cpp94
-rw-r--r--engines/zvision/cursors/cursor_manager.cpp152
-rw-r--r--engines/zvision/detection.cpp278
-rw-r--r--engines/zvision/detection.h1
-rw-r--r--engines/zvision/file/lzss_read_stream.cpp (renamed from engines/zvision/utility/lzss_read_stream.cpp)15
-rw-r--r--engines/zvision/file/lzss_read_stream.h (renamed from engines/zvision/utility/lzss_read_stream.h)3
-rw-r--r--engines/zvision/file/save_manager.cpp290
-rw-r--r--engines/zvision/file/save_manager.h (renamed from engines/zvision/core/save_manager.h)29
-rw-r--r--engines/zvision/file/search_manager.cpp290
-rw-r--r--engines/zvision/file/search_manager.h71
-rw-r--r--engines/zvision/file/zfs_archive.cpp (renamed from engines/zvision/archives/zfs_archive.cpp)16
-rw-r--r--engines/zvision/file/zfs_archive.h (renamed from engines/zvision/archives/zfs_archive.h)5
-rw-r--r--engines/zvision/fonts/truetype_font.cpp113
-rw-r--r--engines/zvision/graphics/cursors/cursor.cpp96
-rw-r--r--engines/zvision/graphics/cursors/cursor.h (renamed from engines/zvision/cursors/cursor.h)28
-rw-r--r--engines/zvision/graphics/cursors/cursor_manager.cpp154
-rw-r--r--engines/zvision/graphics/cursors/cursor_manager.h (renamed from engines/zvision/cursors/cursor_manager.h)84
-rw-r--r--engines/zvision/graphics/effects/fog.cpp173
-rw-r--r--engines/zvision/graphics/effects/fog.h53
-rw-r--r--engines/zvision/graphics/effects/light.cpp109
-rw-r--r--engines/zvision/graphics/effects/light.h53
-rw-r--r--engines/zvision/graphics/effects/wave.cpp145
-rw-r--r--engines/zvision/graphics/effects/wave.h51
-rw-r--r--engines/zvision/graphics/graphics_effect.h83
-rw-r--r--engines/zvision/graphics/render_manager.cpp1291
-rw-r--r--engines/zvision/graphics/render_manager.h372
-rw-r--r--engines/zvision/graphics/render_table.cpp96
-rw-r--r--engines/zvision/graphics/render_table.h18
-rw-r--r--engines/zvision/module.mk45
-rw-r--r--engines/zvision/scripting/actions.cpp952
-rw-r--r--engines/zvision/scripting/actions.h331
-rw-r--r--engines/zvision/scripting/control.cpp64
-rw-r--r--engines/zvision/scripting/control.h111
-rw-r--r--engines/zvision/scripting/controls/animation_control.cpp263
-rw-r--r--engines/zvision/scripting/controls/fist_control.cpp299
-rw-r--r--engines/zvision/scripting/controls/fist_control.h84
-rw-r--r--engines/zvision/scripting/controls/hotmov_control.cpp188
-rw-r--r--engines/zvision/scripting/controls/hotmov_control.h61
-rw-r--r--engines/zvision/scripting/controls/input_control.cpp201
-rw-r--r--engines/zvision/scripting/controls/input_control.h36
-rw-r--r--engines/zvision/scripting/controls/lever_control.cpp224
-rw-r--r--engines/zvision/scripting/controls/lever_control.h24
-rw-r--r--engines/zvision/scripting/controls/paint_control.cpp219
-rw-r--r--engines/zvision/scripting/controls/paint_control.h92
-rw-r--r--engines/zvision/scripting/controls/push_toggle_control.cpp111
-rw-r--r--engines/zvision/scripting/controls/push_toggle_control.h22
-rw-r--r--engines/zvision/scripting/controls/safe_control.cpp180
-rw-r--r--engines/zvision/scripting/controls/safe_control.h65
-rw-r--r--engines/zvision/scripting/controls/save_control.cpp125
-rw-r--r--engines/zvision/scripting/controls/save_control.h55
-rw-r--r--engines/zvision/scripting/controls/slot_control.cpp219
-rw-r--r--engines/zvision/scripting/controls/slot_control.h84
-rw-r--r--engines/zvision/scripting/controls/titler_control.cpp108
-rw-r--r--engines/zvision/scripting/controls/titler_control.h55
-rw-r--r--engines/zvision/scripting/effects/animation_effect.cpp217
-rw-r--r--engines/zvision/scripting/effects/animation_effect.h (renamed from engines/zvision/scripting/controls/animation_control.h)72
-rw-r--r--engines/zvision/scripting/effects/distort_effect.cpp104
-rw-r--r--engines/zvision/scripting/effects/distort_effect.h63
-rw-r--r--engines/zvision/scripting/effects/music_effect.cpp248
-rw-r--r--engines/zvision/scripting/effects/music_effect.h135
-rw-r--r--engines/zvision/scripting/effects/region_effect.cpp56
-rw-r--r--engines/zvision/scripting/effects/region_effect.h57
-rw-r--r--engines/zvision/scripting/effects/syncsound_effect.cpp85
-rw-r--r--engines/zvision/scripting/effects/syncsound_effect.h56
-rw-r--r--engines/zvision/scripting/effects/timer_effect.cpp (renamed from engines/zvision/scripting/controls/timer_node.cpp)42
-rw-r--r--engines/zvision/scripting/effects/timer_effect.h (renamed from engines/zvision/scripting/controls/timer_node.h)14
-rw-r--r--engines/zvision/scripting/effects/ttytext_effect.cpp174
-rw-r--r--engines/zvision/scripting/effects/ttytext_effect.h73
-rw-r--r--engines/zvision/scripting/inventory.cpp122
-rw-r--r--engines/zvision/scripting/menu.cpp761
-rw-r--r--engines/zvision/scripting/menu.h119
-rw-r--r--engines/zvision/scripting/puzzle.h14
-rw-r--r--engines/zvision/scripting/scr_file_handling.cpp303
-rw-r--r--engines/zvision/scripting/script_manager.cpp928
-rw-r--r--engines/zvision/scripting/script_manager.h212
-rw-r--r--engines/zvision/scripting/scripting_effect.h124
-rw-r--r--engines/zvision/sound/midi.cpp91
-rw-r--r--engines/zvision/sound/midi.h59
-rw-r--r--engines/zvision/sound/zork_raw.cpp248
-rw-r--r--engines/zvision/sound/zork_raw.h96
-rw-r--r--engines/zvision/strings/string_manager.cpp255
-rw-r--r--engines/zvision/text/string_manager.cpp71
-rw-r--r--engines/zvision/text/string_manager.h (renamed from engines/zvision/strings/string_manager.h)33
-rw-r--r--engines/zvision/text/subtitles.cpp108
-rw-r--r--engines/zvision/text/subtitles.h (renamed from engines/zvision/subtitles/subtitles.h)28
-rw-r--r--engines/zvision/text/text.cpp557
-rw-r--r--engines/zvision/text/text.h99
-rw-r--r--engines/zvision/text/truetype_font.cpp228
-rw-r--r--engines/zvision/text/truetype_font.h (renamed from engines/zvision/fonts/truetype_font.h)63
-rw-r--r--engines/zvision/utility/single_value_container.cpp348
-rw-r--r--engines/zvision/utility/single_value_container.h183
-rw-r--r--engines/zvision/utility/utility.cpp237
-rw-r--r--engines/zvision/utility/utility.h114
-rw-r--r--engines/zvision/video/rlf_decoder.cpp313
-rw-r--r--engines/zvision/video/rlf_decoder.h134
-rw-r--r--engines/zvision/video/video.cpp157
-rw-r--r--engines/zvision/video/zork_avi_decoder.cpp22
-rw-r--r--engines/zvision/video/zork_avi_decoder.h28
-rw-r--r--engines/zvision/zvision.cpp295
-rw-r--r--engines/zvision/zvision.h156
-rw-r--r--graphics/VectorRenderer.h2
-rw-r--r--graphics/VectorRendererSpec.cpp52
-rw-r--r--graphics/VectorRendererSpec.h2
-rw-r--r--graphics/surface.h2
-rw-r--r--graphics/transform_struct.h2
-rw-r--r--graphics/transform_tools.h2
-rw-r--r--gui/EventRecorder.cpp1
-rw-r--r--gui/about.cpp2
-rw-r--r--gui/browser_osx.mm4
-rw-r--r--gui/credits.h19
-rw-r--r--gui/debugger.cpp109
-rw-r--r--gui/debugger.h4
-rw-r--r--gui/saveload-dialog.cpp17
-rw-r--r--gui/themes/scummmodern.zipbin1489429 -> 1485886 bytes
-rw-r--r--gui/themes/scummmodern/scummmodern_layout.stx4
-rw-r--r--gui/themes/translations.datbin464738 -> 470115 bytes
-rw-r--r--gui/widgets/edittext.cpp2
-rw-r--r--gui/widgets/tab.h2
-rw-r--r--image/codecs/mjpeg.cpp2
-rw-r--r--image/codecs/mpeg.h2
-rw-r--r--image/iff.cpp2
-rw-r--r--image/image_decoder.h2
-rw-r--r--po/be_BY.po133
-rw-r--r--po/ca_ES.po134
-rw-r--r--po/cs_CZ.po133
-rw-r--r--po/da_DA.po133
-rw-r--r--po/de_DE.po133
-rw-r--r--po/es_ES.po135
-rw-r--r--po/eu.po127
-rw-r--r--po/fi_FI.po133
-rw-r--r--po/fr_FR.po133
-rw-r--r--po/gl_ES.po134
-rw-r--r--po/hu_HU.po133
-rw-r--r--po/it_IT.po133
-rw-r--r--po/nb_NO.po133
-rw-r--r--po/nl_NL.po194
-rw-r--r--po/nn_NO.po128
-rw-r--r--po/pl_PL.po133
-rw-r--r--po/pt_BR.po126
-rw-r--r--po/ru_RU.po133
-rw-r--r--po/scummvm.pot127
-rw-r--r--po/se_SE.po133
-rw-r--r--po/uk_UA.po133
-rw-r--r--ports.mk5
-rw-r--r--test/audio/timestamp.h13
-rw-r--r--video/avi_decoder.cpp372
-rw-r--r--video/avi_decoder.h18
-rw-r--r--video/theora_decoder.h1
-rw-r--r--video/video_decoder.cpp4
648 files changed, 66512 insertions, 20735 deletions
diff --git a/AUTHORS b/AUTHORS
index 37067e5e04..3e8c65e5e2 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -257,9 +257,12 @@ ScummVM Team
Wintermute:
Einar Johan T. Somaaen
+ Tobia Tesan
ZVision:
Adrian Astley
+ Filippos Karapetis
+ Anton Yarcev
Backend Teams
-------------
@@ -523,6 +526,12 @@ Other contributions
Victor Gonzalez - Soltys Spanish translation
Alejandro Gomez de la Munoza - Soltys Spanish translation
+ CGE2:
+ Arnaud Boutonne - Sfinx English translation
+ Thierry Crozat - Sfinx English translation
+ Peter Bozso - Sfinx English translation editor
+ Ryan Clark - Sfinx English translation editor
+
Drascula:
Thierry Crozat - Improve French translation
@@ -651,7 +660,7 @@ Special thanks to
repository, planet and doxygen sites as well as tons
of HD space
DOSBox Team - For their awesome OPL2 and OPL3 emulator
- Yusuke Kamiyamane - For contributing some GUI icons
+ Yusuke Kamiyamane - For contributing some GUI icons
Till Kresslein - For design of modern ScummVM GUI
Jezar - For his freeverb filter implementation
Jim Leiterman - Various info on his FM-TOWNS/Marty SCUMM ports
@@ -700,8 +709,8 @@ Special thanks to
of Dreamweb and for their tremendous support.
Janusz Wisniewski and Miroslaw Liminowicz from Laboratorium Komputerowe
- Avalon for providing full source code for Soltys and letting us
- redistribute the game.
+ Avalon for providing full source code for Soltys and Sfinx and letting us
+ redistribute the games.
Jan Nedoma for providing the sources to the Wintermute-engine, and for his
support while porting the engine to ScummVM.
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
new file mode 100644
index 0000000000..3a6672b0cb
--- /dev/null
+++ b/CONTRIBUTING.md
@@ -0,0 +1,12 @@
+Thank you for considering contributing to ScummVM.
+
+Please make sure to read our guidelines for contributions on our
+[wiki](http://wiki.scummvm.org/index.php/Developer_Central). In particular:
+
+* [Coding style](http://wiki.scummvm.org/index.php/Code_Formatting_Conventions)
+* [Portability](http://wiki.scummvm.org/index.php/Coding_Conventions)
+* [Commit message style](http://wiki.scummvm.org/index.php/Commit_Guidelines)
+* License: GPLv2+
+
+If you have any questions about code, style, procedure, or anything else, feel
+free to contact us on our mailing list at scummvm-devel@lists.sourceforge.net.
diff --git a/NEWS b/NEWS
index bb23bb37ff..470ddc01bd 100644
--- a/NEWS
+++ b/NEWS
@@ -2,8 +2,13 @@ For a more comprehensive changelog of the latest experimental code, see:
https://github.com/scummvm/scummvm/commits/
1.8.0 (????-??-??)
+ New Games:
+ - Added support for Sfinx.
+
+ General:
+ - Updated Munt MT-32 emulation code to version 1.5.0.
-Broken Sword 1:
+ Broken Sword 1:
- Fix speech endianness detection on big endian systems for the mac
version (bug #6720).
- Fix crash when reloading a game from the Main Menu while in the bull's
diff --git a/README b/README
index 0a256b39f3..5b0569089c 100644
--- a/README
+++ b/README
@@ -427,7 +427,7 @@ in the previous paragraph.
3.3) Maniac Mansion NES notes:
---- -------------------------
Supported versions are English GB (E), French (F), German (G), Italian (I),
-Swedish (SW) and English US (U). ScummVM requires just the PRG section
+Swedish (SW) and English US (U). ScummVM requires just the PRG section
to run and not the whole ROM.
In order to get the game working, you will have to strip out the first
@@ -1441,7 +1441,7 @@ The platforms that currently have a different default directory are:
<windir>\Profiles\username\Application Data\ScummVM\Saved games\
Saved games are stored under a hidden area in Windows NT4/2000/XP/Vista/7,
-which can be accessed by running "%APPDATA%\ScummVM\Saved Games\" or by
+which can be accessed by running "%APPDATA%\ScummVM\Saved Games\" or by
enabling hidden files in Windows Explorer.
Note for Windows NT4/2000/XP/Vista/7 users: The default saved games location
diff --git a/audio/softsynth/mt32/Analog.cpp b/audio/softsynth/mt32/Analog.cpp
new file mode 100644
index 0000000000..8ac28e401a
--- /dev/null
+++ b/audio/softsynth/mt32/Analog.cpp
@@ -0,0 +1,348 @@
+/* Copyright (C) 2003, 2004, 2005, 2006, 2008, 2009 Dean Beeler, Jerome Fisher
+ * Copyright (C) 2011, 2012, 2013, 2014 Dean Beeler, Jerome Fisher, Sergey V. Mikayev
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 2.1 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+//#include <cstring>
+#include "Analog.h"
+
+namespace MT32Emu {
+
+#if MT32EMU_USE_FLOAT_SAMPLES
+
+/* FIR approximation of the overall impulse response of the cascade composed of the sample & hold circuit and the low pass filter
+ * of the MT-32 first generation.
+ * The coefficients below are found by windowing the inverse DFT of the 1024 pin frequency response converted to the minimum phase.
+ * The frequency response of the LPF is computed directly, the effect of the S&H is approximated by multiplying the LPF frequency
+ * response by the corresponding sinc. Although, the LPF has DC gain of 3.2, we ignore this in the emulation and use normalised model.
+ * The peak gain of the normalised cascade appears about 1.7 near 11.8 kHz. Relative error doesn't exceed 1% for the frequencies
+ * below 12.5 kHz. In the higher frequency range, the relative error is below 8%. Peak error value is at 16 kHz.
+ */
+static const float COARSE_LPF_TAPS_MT32[] = {
+ 1.272473681f, -0.220267785f, -0.158039905f, 0.179603785f, -0.111484097f, 0.054137498f, -0.023518029f, 0.010997169f, -0.006935698f
+};
+
+// Similar approximation for new MT-32 and CM-32L/LAPC-I LPF. As the voltage controlled amplifier was introduced, LPF has unity DC gain.
+// The peak gain value shifted towards higher frequencies and a bit higher about 1.83 near 13 kHz.
+static const float COARSE_LPF_TAPS_CM32L[] = {
+ 1.340615635f, -0.403331694f, 0.036005517f, 0.066156844f, -0.069672532f, 0.049563806f, -0.031113416f, 0.019169774f, -0.012421368f
+};
+
+#else
+
+static const unsigned int COARSE_LPF_FRACTION_BITS = 14;
+
+// Integer versions of the FIRs above multiplied by (1 << 14) and rounded.
+static const SampleEx COARSE_LPF_TAPS_MT32[] = {
+ 20848, -3609, -2589, 2943, -1827, 887, -385, 180, -114
+};
+
+static const SampleEx COARSE_LPF_TAPS_CM32L[] = {
+ 21965, -6608, 590, 1084, -1142, 812, -510, 314, -204
+};
+
+#endif
+
+/* Combined FIR that both approximates the impulse response of the analogue circuits of sample & hold and the low pass filter
+ * in the audible frequency range (below 20 kHz) and attenuates unwanted mirror spectra above 28 kHz as well. It is a polyphase
+ * filter intended for resampling the signal to 48 kHz yet for applying high frequency boost.
+ * As with the filter above, the analogue LPF frequency response is obtained for 1536 pin grid for range up to 96 kHz and multiplied
+ * by the corresponding sinc. The result is further squared, windowed and passed to generalised Parks-McClellan routine as a desired response.
+ * Finally, the minimum phase factor is found that's essentially the coefficients below.
+ * Relative error in the audible frequency range doesn't exceed 0.0006%, attenuation in the stopband is better than 100 dB.
+ * This level of performance makes it nearly bit-accurate for standard 16-bit sample resolution.
+ */
+
+// FIR version for MT-32 first generation.
+static const float ACCURATE_LPF_TAPS_MT32[] = {
+ 0.003429281f, 0.025929869f, 0.096587777f, 0.228884848f, 0.372413431f, 0.412386503f, 0.263980018f,
+ -0.014504962f, -0.237394528f, -0.257043496f, -0.103436603f, 0.063996095f, 0.124562333f, 0.083703206f,
+ 0.013921662f, -0.033475018f, -0.046239712f, -0.029310921f, 0.00126585f, 0.021060961f, 0.017925605f,
+ 0.003559874f, -0.005105248f, -0.005647917f, -0.004157918f, -0.002065664f, 0.00158747f, 0.003762585f,
+ 0.001867137f, -0.001090028f, -0.001433979f, -0.00022367f, 4.34308E-05f, -0.000247827f, 0.000157087f,
+ 0.000605823f, 0.000197317f, -0.000370511f, -0.000261202f, 9.96069E-05f, 9.85073E-05f, -5.28754E-05f,
+ -1.00912E-05f, 7.69943E-05f, 2.03162E-05f, -5.67967E-05f, -3.30637E-05f, 1.61958E-05f, 1.73041E-05f
+};
+
+// FIR version for new MT-32 and CM-32L/LAPC-I.
+static const float ACCURATE_LPF_TAPS_CM32L[] = {
+ 0.003917452f, 0.030693861f, 0.116424199f, 0.275101674f, 0.43217361f, 0.431247894f, 0.183255659f,
+ -0.174955671f, -0.354240244f, -0.212401714f, 0.072259178f, 0.204655344f, 0.108336211f, -0.039099027f,
+ -0.075138174f, -0.026261906f, 0.00582663f, 0.003052193f, 0.00613657f, 0.017017951f, 0.008732535f,
+ -0.011027427f, -0.012933664f, 0.001158097f, 0.006765958f, 0.00046778f, -0.002191106f, 0.001561017f,
+ 0.001842871f, -0.001996876f, -0.002315836f, 0.000980965f, 0.001817454f, -0.000243272f, -0.000972848f,
+ 0.000149941f, 0.000498886f, -0.000204436f, -0.000347415f, 0.000142386f, 0.000249137f, -4.32946E-05f,
+ -0.000131231f, 3.88575E-07f, 4.48813E-05f, -1.31906E-06f, -1.03499E-05f, 7.71971E-06f, 2.86721E-06f
+};
+
+// According to the CM-64 PCB schematic, there is a difference in the values of the LPF entrance resistors for the reverb and non-reverb channels.
+// This effectively results in non-unity LPF DC gain for the reverb channel of 0.68 while the LPF has unity DC gain for the LA32 output channels.
+// In emulation, the reverb output gain is multiplied by this factor to compensate for the LPF gain difference.
+static const float CM32L_REVERB_TO_LA32_ANALOG_OUTPUT_GAIN_FACTOR = 0.68f;
+
+static const unsigned int OUTPUT_GAIN_FRACTION_BITS = 8;
+static const float OUTPUT_GAIN_MULTIPLIER = float(1 << OUTPUT_GAIN_FRACTION_BITS);
+
+static const unsigned int COARSE_LPF_DELAY_LINE_LENGTH = 8; // Must be a power of 2
+static const unsigned int ACCURATE_LPF_DELAY_LINE_LENGTH = 16; // Must be a power of 2
+static const unsigned int ACCURATE_LPF_NUMBER_OF_PHASES = 3; // Upsampling factor
+static const unsigned int ACCURATE_LPF_PHASE_INCREMENT_REGULAR = 2; // Downsampling factor
+static const unsigned int ACCURATE_LPF_PHASE_INCREMENT_OVERSAMPLED = 1; // No downsampling
+static const Bit32u ACCURATE_LPF_DELTAS_REGULAR[][ACCURATE_LPF_NUMBER_OF_PHASES] = { { 0, 0, 0 }, { 1, 1, 0 }, { 1, 2, 1 } };
+static const Bit32u ACCURATE_LPF_DELTAS_OVERSAMPLED[][ACCURATE_LPF_NUMBER_OF_PHASES] = { { 0, 0, 0 }, { 1, 0, 0 }, { 1, 0, 1 } };
+
+class AbstractLowPassFilter {
+public:
+ static AbstractLowPassFilter &createLowPassFilter(AnalogOutputMode mode, bool oldMT32AnalogLPF);
+ static void muteRingBuffer(SampleEx *ringBuffer, unsigned int length);
+
+ virtual ~AbstractLowPassFilter() {}
+ virtual SampleEx process(SampleEx sample) = 0;
+ virtual bool hasNextSample() const;
+ virtual unsigned int getOutputSampleRate() const;
+ virtual unsigned int estimateInSampleCount(unsigned int outSamples) const;
+ virtual void addPositionIncrement(unsigned int) {}
+};
+
+class NullLowPassFilter : public AbstractLowPassFilter {
+public:
+ SampleEx process(SampleEx sample);
+};
+
+class CoarseLowPassFilter : public AbstractLowPassFilter {
+private:
+ const SampleEx * const LPF_TAPS;
+ SampleEx ringBuffer[COARSE_LPF_DELAY_LINE_LENGTH];
+ unsigned int ringBufferPosition;
+
+public:
+ CoarseLowPassFilter(bool oldMT32AnalogLPF);
+ SampleEx process(SampleEx sample);
+};
+
+class AccurateLowPassFilter : public AbstractLowPassFilter {
+private:
+ const float * const LPF_TAPS;
+ const Bit32u (* const deltas)[ACCURATE_LPF_NUMBER_OF_PHASES];
+ const unsigned int phaseIncrement;
+ const unsigned int outputSampleRate;
+
+ SampleEx ringBuffer[ACCURATE_LPF_DELAY_LINE_LENGTH];
+ unsigned int ringBufferPosition;
+ unsigned int phase;
+
+public:
+ AccurateLowPassFilter(bool oldMT32AnalogLPF, bool oversample);
+ SampleEx process(SampleEx sample);
+ bool hasNextSample() const;
+ unsigned int getOutputSampleRate() const;
+ unsigned int estimateInSampleCount(unsigned int outSamples) const;
+ void addPositionIncrement(unsigned int positionIncrement);
+};
+
+Analog::Analog(const AnalogOutputMode mode, const ControlROMFeatureSet *controlROMFeatures) :
+ leftChannelLPF(AbstractLowPassFilter::createLowPassFilter(mode, controlROMFeatures->isOldMT32AnalogLPF())),
+ rightChannelLPF(AbstractLowPassFilter::createLowPassFilter(mode, controlROMFeatures->isOldMT32AnalogLPF())),
+ synthGain(0),
+ reverbGain(0)
+{}
+
+Analog::~Analog() {
+ delete &leftChannelLPF;
+ delete &rightChannelLPF;
+}
+
+void Analog::process(Sample **outStream, const Sample *nonReverbLeft, const Sample *nonReverbRight, const Sample *reverbDryLeft, const Sample *reverbDryRight, const Sample *reverbWetLeft, const Sample *reverbWetRight, Bit32u outLength) {
+ if (outStream == NULL) {
+ leftChannelLPF.addPositionIncrement(outLength);
+ rightChannelLPF.addPositionIncrement(outLength);
+ return;
+ }
+
+ while (0 < (outLength--)) {
+ SampleEx outSampleL;
+ SampleEx outSampleR;
+
+ if (leftChannelLPF.hasNextSample()) {
+ outSampleL = leftChannelLPF.process(0);
+ outSampleR = rightChannelLPF.process(0);
+ } else {
+ SampleEx inSampleL = ((SampleEx)*(nonReverbLeft++) + (SampleEx)*(reverbDryLeft++)) * synthGain + (SampleEx)*(reverbWetLeft++) * reverbGain;
+ SampleEx inSampleR = ((SampleEx)*(nonReverbRight++) + (SampleEx)*(reverbDryRight++)) * synthGain + (SampleEx)*(reverbWetRight++) * reverbGain;
+
+#if !MT32EMU_USE_FLOAT_SAMPLES
+ inSampleL >>= OUTPUT_GAIN_FRACTION_BITS;
+ inSampleR >>= OUTPUT_GAIN_FRACTION_BITS;
+#endif
+
+ outSampleL = leftChannelLPF.process(inSampleL);
+ outSampleR = rightChannelLPF.process(inSampleR);
+ }
+
+ *((*outStream)++) = Synth::clipSampleEx(outSampleL);
+ *((*outStream)++) = Synth::clipSampleEx(outSampleR);
+ }
+}
+
+unsigned int Analog::getOutputSampleRate() const {
+ return leftChannelLPF.getOutputSampleRate();
+}
+
+Bit32u Analog::getDACStreamsLength(Bit32u outputLength) const {
+ return leftChannelLPF.estimateInSampleCount(outputLength);
+}
+
+void Analog::setSynthOutputGain(float useSynthGain) {
+#if MT32EMU_USE_FLOAT_SAMPLES
+ synthGain = useSynthGain;
+#else
+ if (OUTPUT_GAIN_MULTIPLIER < useSynthGain) useSynthGain = OUTPUT_GAIN_MULTIPLIER;
+ synthGain = SampleEx(useSynthGain * OUTPUT_GAIN_MULTIPLIER);
+#endif
+}
+
+void Analog::setReverbOutputGain(float useReverbGain, bool mt32ReverbCompatibilityMode) {
+ if (!mt32ReverbCompatibilityMode) useReverbGain *= CM32L_REVERB_TO_LA32_ANALOG_OUTPUT_GAIN_FACTOR;
+#if MT32EMU_USE_FLOAT_SAMPLES
+ reverbGain = useReverbGain;
+#else
+ if (OUTPUT_GAIN_MULTIPLIER < useReverbGain) useReverbGain = OUTPUT_GAIN_MULTIPLIER;
+ reverbGain = SampleEx(useReverbGain * OUTPUT_GAIN_MULTIPLIER);
+#endif
+}
+
+AbstractLowPassFilter &AbstractLowPassFilter::createLowPassFilter(AnalogOutputMode mode, bool oldMT32AnalogLPF) {
+ switch (mode) {
+ case AnalogOutputMode_COARSE:
+ return *new CoarseLowPassFilter(oldMT32AnalogLPF);
+ case AnalogOutputMode_ACCURATE:
+ return *new AccurateLowPassFilter(oldMT32AnalogLPF, false);
+ case AnalogOutputMode_OVERSAMPLED:
+ return *new AccurateLowPassFilter(oldMT32AnalogLPF, true);
+ default:
+ return *new NullLowPassFilter;
+ }
+}
+
+void AbstractLowPassFilter::muteRingBuffer(SampleEx *ringBuffer, unsigned int length) {
+
+#if MT32EMU_USE_FLOAT_SAMPLES
+
+ SampleEx *p = ringBuffer;
+ while (length--) {
+ *(p++) = 0.0f;
+ }
+
+#else
+
+ memset(ringBuffer, 0, length * sizeof(SampleEx));
+
+#endif
+
+}
+
+bool AbstractLowPassFilter::hasNextSample() const {
+ return false;
+}
+
+unsigned int AbstractLowPassFilter::getOutputSampleRate() const {
+ return SAMPLE_RATE;
+}
+
+unsigned int AbstractLowPassFilter::estimateInSampleCount(unsigned int outSamples) const {
+ return outSamples;
+}
+
+SampleEx NullLowPassFilter::process(const SampleEx inSample) {
+ return inSample;
+}
+
+CoarseLowPassFilter::CoarseLowPassFilter(bool oldMT32AnalogLPF) :
+ LPF_TAPS(oldMT32AnalogLPF ? COARSE_LPF_TAPS_MT32 : COARSE_LPF_TAPS_CM32L),
+ ringBufferPosition(0)
+{
+ muteRingBuffer(ringBuffer, COARSE_LPF_DELAY_LINE_LENGTH);
+}
+
+SampleEx CoarseLowPassFilter::process(const SampleEx inSample) {
+ static const unsigned int DELAY_LINE_MASK = COARSE_LPF_DELAY_LINE_LENGTH - 1;
+
+ SampleEx sample = LPF_TAPS[COARSE_LPF_DELAY_LINE_LENGTH] * ringBuffer[ringBufferPosition];
+ ringBuffer[ringBufferPosition] = Synth::clipSampleEx(inSample);
+
+ for (unsigned int i = 0; i < COARSE_LPF_DELAY_LINE_LENGTH; i++) {
+ sample += LPF_TAPS[i] * ringBuffer[(i + ringBufferPosition) & DELAY_LINE_MASK];
+ }
+
+ ringBufferPosition = (ringBufferPosition - 1) & DELAY_LINE_MASK;
+
+#if !MT32EMU_USE_FLOAT_SAMPLES
+ sample >>= COARSE_LPF_FRACTION_BITS;
+#endif
+
+ return sample;
+}
+
+AccurateLowPassFilter::AccurateLowPassFilter(const bool oldMT32AnalogLPF, const bool oversample) :
+ LPF_TAPS(oldMT32AnalogLPF ? ACCURATE_LPF_TAPS_MT32 : ACCURATE_LPF_TAPS_CM32L),
+ deltas(oversample ? ACCURATE_LPF_DELTAS_OVERSAMPLED : ACCURATE_LPF_DELTAS_REGULAR),
+ phaseIncrement(oversample ? ACCURATE_LPF_PHASE_INCREMENT_OVERSAMPLED : ACCURATE_LPF_PHASE_INCREMENT_REGULAR),
+ outputSampleRate(SAMPLE_RATE * ACCURATE_LPF_NUMBER_OF_PHASES / phaseIncrement),
+ ringBufferPosition(0),
+ phase(0)
+{
+ muteRingBuffer(ringBuffer, ACCURATE_LPF_DELAY_LINE_LENGTH);
+}
+
+SampleEx AccurateLowPassFilter::process(const SampleEx inSample) {
+ static const unsigned int DELAY_LINE_MASK = ACCURATE_LPF_DELAY_LINE_LENGTH - 1;
+
+ float sample = (phase == 0) ? LPF_TAPS[ACCURATE_LPF_DELAY_LINE_LENGTH * ACCURATE_LPF_NUMBER_OF_PHASES] * ringBuffer[ringBufferPosition] : 0.0f;
+ if (!hasNextSample()) {
+ ringBuffer[ringBufferPosition] = inSample;
+ }
+
+ for (unsigned int tapIx = phase, delaySampleIx = 0; delaySampleIx < ACCURATE_LPF_DELAY_LINE_LENGTH; delaySampleIx++, tapIx += ACCURATE_LPF_NUMBER_OF_PHASES) {
+ sample += LPF_TAPS[tapIx] * ringBuffer[(delaySampleIx + ringBufferPosition) & DELAY_LINE_MASK];
+ }
+
+ phase += phaseIncrement;
+ if (ACCURATE_LPF_NUMBER_OF_PHASES <= phase) {
+ phase -= ACCURATE_LPF_NUMBER_OF_PHASES;
+ ringBufferPosition = (ringBufferPosition - 1) & DELAY_LINE_MASK;
+ }
+
+ return SampleEx(ACCURATE_LPF_NUMBER_OF_PHASES * sample);
+}
+
+bool AccurateLowPassFilter::hasNextSample() const {
+ return phaseIncrement <= phase;
+}
+
+unsigned int AccurateLowPassFilter::getOutputSampleRate() const {
+ return outputSampleRate;
+}
+
+unsigned int AccurateLowPassFilter::estimateInSampleCount(unsigned int outSamples) const {
+ Bit32u cycleCount = outSamples / ACCURATE_LPF_NUMBER_OF_PHASES;
+ Bit32u remainder = outSamples - cycleCount * ACCURATE_LPF_NUMBER_OF_PHASES;
+ return cycleCount * phaseIncrement + deltas[remainder][phase];
+}
+
+void AccurateLowPassFilter::addPositionIncrement(const unsigned int positionIncrement) {
+ phase = (phase + positionIncrement * phaseIncrement) % ACCURATE_LPF_NUMBER_OF_PHASES;
+}
+
+}
diff --git a/audio/softsynth/mt32/Analog.h b/audio/softsynth/mt32/Analog.h
new file mode 100644
index 0000000000..a48db72485
--- /dev/null
+++ b/audio/softsynth/mt32/Analog.h
@@ -0,0 +1,57 @@
+/* Copyright (C) 2003, 2004, 2005, 2006, 2008, 2009 Dean Beeler, Jerome Fisher
+ * Copyright (C) 2011, 2012, 2013, 2014 Dean Beeler, Jerome Fisher, Sergey V. Mikayev
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 2.1 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef MT32EMU_ANALOG_H
+#define MT32EMU_ANALOG_H
+
+#include "mt32emu.h"
+
+namespace MT32Emu {
+
+class AbstractLowPassFilter;
+
+/* Analog class is dedicated to perform fair emulation of analogue circuitry of hardware units that is responsible
+ * for processing output signal after the DAC. It appears that the analogue circuit labeled "LPF" on the schematic
+ * also applies audible changes to the signal spectra. There is a significant boost of higher frequencies observed
+ * aside from quite poor attenuation of the mirror spectra above 16 kHz which is due to a relatively low filter order.
+ *
+ * As the final mixing of multiplexed output signal is performed after the DAC, this function is migrated here from Synth.
+ * Saying precisely, mixing is performed within the LPF as the entrance resistors are actually components of a LPF
+ * designed using the multiple feedback topology. Nevertheless, the schematic separates them.
+ */
+class Analog {
+public:
+ Analog(AnalogOutputMode mode, const ControlROMFeatureSet *controlROMFeatures);
+ ~Analog();
+ void process(Sample **outStream, const Sample *nonReverbLeft, const Sample *nonReverbRight, const Sample *reverbDryLeft, const Sample *reverbDryRight, const Sample *reverbWetLeft, const Sample *reverbWetRight, const Bit32u outLength);
+ unsigned int getOutputSampleRate() const;
+ Bit32u getDACStreamsLength(Bit32u outputLength) const;
+ void setSynthOutputGain(float synthGain);
+ void setReverbOutputGain(float reverbGain, bool mt32ReverbCompatibilityMode);
+
+private:
+ AbstractLowPassFilter &leftChannelLPF;
+ AbstractLowPassFilter &rightChannelLPF;
+ SampleEx synthGain;
+ SampleEx reverbGain;
+
+ Analog(Analog &);
+};
+
+}
+
+#endif
diff --git a/audio/softsynth/mt32/BReverbModel.cpp b/audio/softsynth/mt32/BReverbModel.cpp
index 37b3e9670d..5e02db8f99 100644
--- a/audio/softsynth/mt32/BReverbModel.cpp
+++ b/audio/softsynth/mt32/BReverbModel.cpp
@@ -15,7 +15,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-//#include <memory.h>
+//#include <cstring>
#include "mt32emu.h"
#include "BReverbModel.h"
@@ -501,9 +501,9 @@ void BReverbModel::process(const Sample *inLeft, const Sample *inRight, Sample *
* Analysing of the algorithm suggests that the overflow is most probable when the combs output is added below.
* So, despite this isn't actually accurate, we only add the check here for performance reasons.
*/
- Sample outSample = Synth::clipBit16s(Synth::clipBit16s(Synth::clipBit16s(Synth::clipBit16s((Bit32s)outL1 + Bit32s(outL1 >> 1)) + (Bit32s)outL2) + Bit32s(outL2 >> 1)) + (Bit32s)outL3);
+ Sample outSample = Synth::clipSampleEx(Synth::clipSampleEx(Synth::clipSampleEx(Synth::clipSampleEx((SampleEx)outL1 + SampleEx(outL1 >> 1)) + (SampleEx)outL2) + SampleEx(outL2 >> 1)) + (SampleEx)outL3);
#else
- Sample outSample = Synth::clipBit16s((Bit32s)outL1 + Bit32s(outL1 >> 1) + (Bit32s)outL2 + Bit32s(outL2 >> 1) + (Bit32s)outL3);
+ Sample outSample = Synth::clipSampleEx((SampleEx)outL1 + SampleEx(outL1 >> 1) + (SampleEx)outL2 + SampleEx(outL2 >> 1) + (SampleEx)outL3);
#endif
*(outLeft++) = weirdMul(outSample, wetLevel, 0xFF);
}
@@ -515,9 +515,9 @@ void BReverbModel::process(const Sample *inLeft, const Sample *inRight, Sample *
Sample outSample = 1.5f * (outR1 + outR2) + outR3;
#elif MT32EMU_BOSS_REVERB_PRECISE_MODE
// See the note above for the left channel output.
- Sample outSample = Synth::clipBit16s(Synth::clipBit16s(Synth::clipBit16s(Synth::clipBit16s((Bit32s)outR1 + Bit32s(outR1 >> 1)) + (Bit32s)outR2) + Bit32s(outR2 >> 1)) + (Bit32s)outR3);
+ Sample outSample = Synth::clipSampleEx(Synth::clipSampleEx(Synth::clipSampleEx(Synth::clipSampleEx((SampleEx)outR1 + SampleEx(outR1 >> 1)) + (SampleEx)outR2) + SampleEx(outR2 >> 1)) + (SampleEx)outR3);
#else
- Sample outSample = Synth::clipBit16s((Bit32s)outR1 + Bit32s(outR1 >> 1) + (Bit32s)outR2 + Bit32s(outR2 >> 1) + (Bit32s)outR3);
+ Sample outSample = Synth::clipSampleEx((SampleEx)outR1 + SampleEx(outR1 >> 1) + (SampleEx)outR2 + SampleEx(outR2 >> 1) + (SampleEx)outR3);
#endif
*(outRight++) = weirdMul(outSample, wetLevel, 0xFF);
}
diff --git a/audio/softsynth/mt32/BReverbModel.h b/audio/softsynth/mt32/BReverbModel.h
index 9b840900c3..764daf1a9e 100644
--- a/audio/softsynth/mt32/BReverbModel.h
+++ b/audio/softsynth/mt32/BReverbModel.h
@@ -95,7 +95,6 @@ class BReverbModel {
const bool tapDelayMode;
Bit32u dryAmp;
Bit32u wetLevel;
- void mute();
static const BReverbSettings &getCM32L_LAPCSettings(const ReverbMode mode);
static const BReverbSettings &getMT32Settings(const ReverbMode mode);
@@ -107,6 +106,7 @@ public:
void open();
// May be called multiple times without an open() in between.
void close();
+ void mute();
void setParameters(Bit8u time, Bit8u level);
void process(const Sample *inLeft, const Sample *inRight, Sample *outLeft, Sample *outRight, unsigned long numSamples);
bool isActive() const;
diff --git a/audio/softsynth/mt32/LA32FloatWaveGenerator.cpp b/audio/softsynth/mt32/LA32FloatWaveGenerator.cpp
index 9265d80c88..42d820ebad 100644
--- a/audio/softsynth/mt32/LA32FloatWaveGenerator.cpp
+++ b/audio/softsynth/mt32/LA32FloatWaveGenerator.cpp
@@ -18,7 +18,7 @@
//#include <cmath>
#include "mt32emu.h"
#include "mmath.h"
-#include "LA32FloatWaveGenerator.h"
+#include "internals.h"
namespace MT32Emu {
diff --git a/audio/softsynth/mt32/LA32Ramp.cpp b/audio/softsynth/mt32/LA32Ramp.cpp
index 454612c842..2b31a330d2 100644
--- a/audio/softsynth/mt32/LA32Ramp.cpp
+++ b/audio/softsynth/mt32/LA32Ramp.cpp
@@ -50,8 +50,8 @@ We haven't fully explored:
//#include <cmath>
#include "mt32emu.h"
-#include "LA32Ramp.h"
#include "mmath.h"
+#include "internals.h"
namespace MT32Emu {
diff --git a/audio/softsynth/mt32/LA32WaveGenerator.cpp b/audio/softsynth/mt32/LA32WaveGenerator.cpp
index 7ac7cc6aaa..765f75fa61 100644
--- a/audio/softsynth/mt32/LA32WaveGenerator.cpp
+++ b/audio/softsynth/mt32/LA32WaveGenerator.cpp
@@ -15,15 +15,15 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-//#include <cmath>
-#include "mt32emu.h"
-#include "mmath.h"
-#include "LA32WaveGenerator.h"
-
#if MT32EMU_USE_FLOAT_SAMPLES
#include "LA32FloatWaveGenerator.cpp"
#else
+//#include <cmath>
+#include "mt32emu.h"
+#include "mmath.h"
+#include "internals.h"
+
namespace MT32Emu {
static const Bit32u SINE_SEGMENT_RELATIVE_LENGTH = 1 << 18;
diff --git a/audio/softsynth/mt32/MemoryRegion.h b/audio/softsynth/mt32/MemoryRegion.h
new file mode 100644
index 0000000000..c0cb041e11
--- /dev/null
+++ b/audio/softsynth/mt32/MemoryRegion.h
@@ -0,0 +1,124 @@
+/* Copyright (C) 2003, 2004, 2005, 2006, 2008, 2009 Dean Beeler, Jerome Fisher
+ * Copyright (C) 2011, 2012, 2013, 2014 Dean Beeler, Jerome Fisher, Sergey V. Mikayev
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 2.1 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef MT32EMU_MEMORY_REGION_H
+#define MT32EMU_MEMORY_REGION_H
+
+namespace MT32Emu {
+
+enum MemoryRegionType {
+ MR_PatchTemp, MR_RhythmTemp, MR_TimbreTemp, MR_Patches, MR_Timbres, MR_System, MR_Display, MR_Reset
+};
+
+class MemoryRegion {
+private:
+ Synth *synth;
+ Bit8u *realMemory;
+ Bit8u *maxTable;
+public:
+ MemoryRegionType type;
+ Bit32u startAddr, entrySize, entries;
+
+ MemoryRegion(Synth *useSynth, Bit8u *useRealMemory, Bit8u *useMaxTable, MemoryRegionType useType, Bit32u useStartAddr, Bit32u useEntrySize, Bit32u useEntries) {
+ synth = useSynth;
+ realMemory = useRealMemory;
+ maxTable = useMaxTable;
+ type = useType;
+ startAddr = useStartAddr;
+ entrySize = useEntrySize;
+ entries = useEntries;
+ }
+ int lastTouched(Bit32u addr, Bit32u len) const {
+ return (offset(addr) + len - 1) / entrySize;
+ }
+ int firstTouchedOffset(Bit32u addr) const {
+ return offset(addr) % entrySize;
+ }
+ int firstTouched(Bit32u addr) const {
+ return offset(addr) / entrySize;
+ }
+ Bit32u regionEnd() const {
+ return startAddr + entrySize * entries;
+ }
+ bool contains(Bit32u addr) const {
+ return addr >= startAddr && addr < regionEnd();
+ }
+ int offset(Bit32u addr) const {
+ return addr - startAddr;
+ }
+ Bit32u getClampedLen(Bit32u addr, Bit32u len) const {
+ if (addr + len > regionEnd())
+ return regionEnd() - addr;
+ return len;
+ }
+ Bit32u next(Bit32u addr, Bit32u len) const {
+ if (addr + len > regionEnd()) {
+ return regionEnd() - addr;
+ }
+ return 0;
+ }
+ Bit8u getMaxValue(int off) const {
+ if (maxTable == NULL)
+ return 0xFF;
+ return maxTable[off % entrySize];
+ }
+ Bit8u *getRealMemory() const {
+ return realMemory;
+ }
+ bool isReadable() const {
+ return getRealMemory() != NULL;
+ }
+ void read(unsigned int entry, unsigned int off, Bit8u *dst, unsigned int len) const;
+ void write(unsigned int entry, unsigned int off, const Bit8u *src, unsigned int len, bool init = false) const;
+};
+
+class PatchTempMemoryRegion : public MemoryRegion {
+public:
+ PatchTempMemoryRegion(Synth *useSynth, Bit8u *useRealMemory, Bit8u *useMaxTable) : MemoryRegion(useSynth, useRealMemory, useMaxTable, MR_PatchTemp, MT32EMU_MEMADDR(0x030000), sizeof(MemParams::PatchTemp), 9) {}
+};
+class RhythmTempMemoryRegion : public MemoryRegion {
+public:
+ RhythmTempMemoryRegion(Synth *useSynth, Bit8u *useRealMemory, Bit8u *useMaxTable) : MemoryRegion(useSynth, useRealMemory, useMaxTable, MR_RhythmTemp, MT32EMU_MEMADDR(0x030110), sizeof(MemParams::RhythmTemp), 85) {}
+};
+class TimbreTempMemoryRegion : public MemoryRegion {
+public:
+ TimbreTempMemoryRegion(Synth *useSynth, Bit8u *useRealMemory, Bit8u *useMaxTable) : MemoryRegion(useSynth, useRealMemory, useMaxTable, MR_TimbreTemp, MT32EMU_MEMADDR(0x040000), sizeof(TimbreParam), 8) {}
+};
+class PatchesMemoryRegion : public MemoryRegion {
+public:
+ PatchesMemoryRegion(Synth *useSynth, Bit8u *useRealMemory, Bit8u *useMaxTable) : MemoryRegion(useSynth, useRealMemory, useMaxTable, MR_Patches, MT32EMU_MEMADDR(0x050000), sizeof(PatchParam), 128) {}
+};
+class TimbresMemoryRegion : public MemoryRegion {
+public:
+ TimbresMemoryRegion(Synth *useSynth, Bit8u *useRealMemory, Bit8u *useMaxTable) : MemoryRegion(useSynth, useRealMemory, useMaxTable, MR_Timbres, MT32EMU_MEMADDR(0x080000), sizeof(MemParams::PaddedTimbre), 64 + 64 + 64 + 64) {}
+};
+class SystemMemoryRegion : public MemoryRegion {
+public:
+ SystemMemoryRegion(Synth *useSynth, Bit8u *useRealMemory, Bit8u *useMaxTable) : MemoryRegion(useSynth, useRealMemory, useMaxTable, MR_System, MT32EMU_MEMADDR(0x100000), sizeof(MemParams::System), 1) {}
+};
+class DisplayMemoryRegion : public MemoryRegion {
+public:
+ DisplayMemoryRegion(Synth *useSynth) : MemoryRegion(useSynth, NULL, NULL, MR_Display, MT32EMU_MEMADDR(0x200000), MAX_SYSEX_SIZE - 1, 1) {}
+};
+class ResetMemoryRegion : public MemoryRegion {
+public:
+ ResetMemoryRegion(Synth *useSynth) : MemoryRegion(useSynth, NULL, NULL, MR_Reset, MT32EMU_MEMADDR(0x7F0000), 0x3FFF, 1) {}
+};
+
+}
+
+#endif
diff --git a/audio/softsynth/mt32/MidiEventQueue.h b/audio/softsynth/mt32/MidiEventQueue.h
new file mode 100644
index 0000000000..b1948c5f8e
--- /dev/null
+++ b/audio/softsynth/mt32/MidiEventQueue.h
@@ -0,0 +1,67 @@
+/* Copyright (C) 2003, 2004, 2005, 2006, 2008, 2009 Dean Beeler, Jerome Fisher
+ * Copyright (C) 2011, 2012, 2013, 2014 Dean Beeler, Jerome Fisher, Sergey V. Mikayev
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 2.1 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef MT32EMU_MIDI_EVENT_QUEUE_H
+#define MT32EMU_MIDI_EVENT_QUEUE_H
+
+namespace MT32Emu {
+
+/**
+ * Used to safely store timestamped MIDI events in a local queue.
+ */
+struct MidiEvent {
+ Bit32u shortMessageData;
+ const Bit8u *sysexData;
+ Bit32u sysexLength;
+ Bit32u timestamp;
+
+ ~MidiEvent();
+ void setShortMessage(Bit32u shortMessageData, Bit32u timestamp);
+ void setSysex(const Bit8u *sysexData, Bit32u sysexLength, Bit32u timestamp);
+};
+
+/**
+ * Simple queue implementation using a ring buffer to store incoming MIDI event before the synth actually processes it.
+ * It is intended to:
+ * - get rid of prerenderer while retaining graceful partial abortion
+ * - add fair emulation of the MIDI interface delays
+ * - extend the synth interface with the default implementation of a typical rendering loop.
+ * THREAD SAFETY:
+ * It is safe to use either in a single thread environment or when there are only two threads - one performs only reading
+ * and one performs only writing. More complicated usage requires external synchronisation.
+ */
+class MidiEventQueue {
+private:
+ MidiEvent * const ringBuffer;
+ const Bit32u ringBufferMask;
+ volatile Bit32u startPosition;
+ volatile Bit32u endPosition;
+
+public:
+ MidiEventQueue(Bit32u ringBufferSize = DEFAULT_MIDI_EVENT_QUEUE_SIZE); // Must be a power of 2
+ ~MidiEventQueue();
+ void reset();
+ bool pushShortMessage(Bit32u shortMessageData, Bit32u timestamp);
+ bool pushSysex(const Bit8u *sysexData, Bit32u sysexLength, Bit32u timestamp);
+ const MidiEvent *peekMidiEvent();
+ void dropMidiEvent();
+ bool isFull() const;
+};
+
+}
+
+#endif
diff --git a/audio/softsynth/mt32/Part.cpp b/audio/softsynth/mt32/Part.cpp
index d92473b5db..cffc3ed744 100644
--- a/audio/softsynth/mt32/Part.cpp
+++ b/audio/softsynth/mt32/Part.cpp
@@ -19,6 +19,7 @@
//#include <cstring>
#include "mt32emu.h"
+#include "internals.h"
#include "PartialManager.h"
namespace MT32Emu {
diff --git a/audio/softsynth/mt32/Partial.cpp b/audio/softsynth/mt32/Partial.cpp
index 7dcc6e945a..7348087509 100644
--- a/audio/softsynth/mt32/Partial.cpp
+++ b/audio/softsynth/mt32/Partial.cpp
@@ -21,6 +21,7 @@
#include "mt32emu.h"
#include "mmath.h"
+#include "internals.h"
namespace MT32Emu {
@@ -312,8 +313,8 @@ bool Partial::produceOutput(Sample *leftBuf, Sample *rightBuf, unsigned long len
// Though, it is unknown whether this overflow is exploited somewhere.
Sample leftOut = Sample((sample * leftPanValue) >> 8);
Sample rightOut = Sample((sample * rightPanValue) >> 8);
- *leftBuf = Synth::clipBit16s((Bit32s)*leftBuf + (Bit32s)leftOut);
- *rightBuf = Synth::clipBit16s((Bit32s)*rightBuf + (Bit32s)rightOut);
+ *leftBuf = Synth::clipSampleEx((SampleEx)*leftBuf + (SampleEx)leftOut);
+ *rightBuf = Synth::clipSampleEx((SampleEx)*rightBuf + (SampleEx)rightOut);
leftBuf++;
rightBuf++;
#endif
diff --git a/audio/softsynth/mt32/PartialManager.cpp b/audio/softsynth/mt32/PartialManager.cpp
index fe73087581..8ca6e4e3d7 100644
--- a/audio/softsynth/mt32/PartialManager.cpp
+++ b/audio/softsynth/mt32/PartialManager.cpp
@@ -18,6 +18,7 @@
//#include <cstring>
#include "mt32emu.h"
+#include "internals.h"
#include "PartialManager.h"
namespace MT32Emu {
diff --git a/audio/softsynth/mt32/Poly.cpp b/audio/softsynth/mt32/Poly.cpp
index e07ceb4231..badcd8fb96 100644
--- a/audio/softsynth/mt32/Poly.cpp
+++ b/audio/softsynth/mt32/Poly.cpp
@@ -16,6 +16,7 @@
*/
#include "mt32emu.h"
+#include "internals.h"
namespace MT32Emu {
diff --git a/audio/softsynth/mt32/Poly.h b/audio/softsynth/mt32/Poly.h
index 9c6431ce36..e2614369bb 100644
--- a/audio/softsynth/mt32/Poly.h
+++ b/audio/softsynth/mt32/Poly.h
@@ -21,6 +21,7 @@
namespace MT32Emu {
class Part;
+class Partial;
enum PolyState {
POLY_Playing,
diff --git a/audio/softsynth/mt32/ROMInfo.cpp b/audio/softsynth/mt32/ROMInfo.cpp
index eb9622620f..7c0127078b 100644
--- a/audio/softsynth/mt32/ROMInfo.cpp
+++ b/audio/softsynth/mt32/ROMInfo.cpp
@@ -21,8 +21,8 @@
namespace MT32Emu {
static const ROMInfo *getKnownROMInfoFromList(unsigned int index) {
- static const ControlROMFeatureSet MT32_COMPATIBLE(true);
- static const ControlROMFeatureSet CM32L_COMPATIBLE(false);
+ static const ControlROMFeatureSet MT32_COMPATIBLE(true, true);
+ static const ControlROMFeatureSet CM32L_COMPATIBLE(false, false);
// Known ROMs
static const ROMInfo CTRL_MT32_V1_04 = {65536, "5a5cb5a77d7d55ee69657c2f870416daed52dea7", ROMInfo::Control, "ctrl_mt32_1_04", "MT-32 Control v1.04", ROMInfo::Full, NULL, &MT32_COMPATIBLE};
@@ -106,7 +106,6 @@ void ROMImage::freeROMImage(const ROMImage *romImage) {
delete romImage;
}
-
Common::File* ROMImage::getFile() const {
return file;
}
@@ -115,11 +114,17 @@ const ROMInfo* ROMImage::getROMInfo() const {
return romInfo;
}
-ControlROMFeatureSet::ControlROMFeatureSet(bool useDefaultReverbMT32Compatible) : defaultReverbMT32Compatible(useDefaultReverbMT32Compatible) {
-}
+ControlROMFeatureSet::ControlROMFeatureSet(bool useDefaultReverbMT32Compatible, bool useOldMT32AnalogLPF) :
+ defaultReverbMT32Compatible(useDefaultReverbMT32Compatible),
+ oldMT32AnalogLPF(useOldMT32AnalogLPF)
+{}
bool ControlROMFeatureSet::isDefaultReverbMT32Compatible() const {
return defaultReverbMT32Compatible;
}
+bool ControlROMFeatureSet::isOldMT32AnalogLPF() const {
+ return oldMT32AnalogLPF;
+}
+
}
diff --git a/audio/softsynth/mt32/ROMInfo.h b/audio/softsynth/mt32/ROMInfo.h
index cecbb6054f..4682620a15 100644
--- a/audio/softsynth/mt32/ROMInfo.h
+++ b/audio/softsynth/mt32/ROMInfo.h
@@ -77,10 +77,12 @@ public:
struct ControlROMFeatureSet {
private:
unsigned int defaultReverbMT32Compatible : 1;
+ unsigned int oldMT32AnalogLPF : 1;
public:
- ControlROMFeatureSet(bool defaultReverbMT32Compatible);
+ ControlROMFeatureSet(bool defaultReverbMT32Compatible, bool oldMT32AnalogLPF);
bool isDefaultReverbMT32Compatible() const;
+ bool isOldMT32AnalogLPF() const;
};
}
diff --git a/audio/softsynth/mt32/Structures.h b/audio/softsynth/mt32/Structures.h
index 35dcee90d6..4dada3a847 100644
--- a/audio/softsynth/mt32/Structures.h
+++ b/audio/softsynth/mt32/Structures.h
@@ -31,19 +31,6 @@ namespace MT32Emu {
#define MT32EMU_ALIGN_PACKED __attribute__((packed))
#endif
-typedef unsigned int Bit32u;
-typedef signed int Bit32s;
-typedef unsigned short int Bit16u;
-typedef signed short int Bit16s;
-typedef unsigned char Bit8u;
-typedef signed char Bit8s;
-
-#if MT32EMU_USE_FLOAT_SAMPLES
-typedef float Sample;
-#else
-typedef Bit16s Sample;
-#endif
-
// The following structures represent the MT-32's memory
// Since sysex allows this memory to be written to in blocks of bytes,
// we keep this packed so that we can copy data into the various
@@ -184,7 +171,37 @@ struct MemParams {
#pragma pack()
#endif
-struct ControlROMPCMStruct;
+struct ControlROMMap {
+ Bit16u idPos;
+ Bit16u idLen;
+ const char *idBytes;
+ Bit16u pcmTable; // 4 * pcmCount bytes
+ Bit16u pcmCount;
+ Bit16u timbreAMap; // 128 bytes
+ Bit16u timbreAOffset;
+ bool timbreACompressed;
+ Bit16u timbreBMap; // 128 bytes
+ Bit16u timbreBOffset;
+ bool timbreBCompressed;
+ Bit16u timbreRMap; // 2 * timbreRCount bytes
+ Bit16u timbreRCount;
+ Bit16u rhythmSettings; // 4 * rhythmSettingsCount bytes
+ Bit16u rhythmSettingsCount;
+ Bit16u reserveSettings; // 9 bytes
+ Bit16u panSettings; // 8 bytes
+ Bit16u programSettings; // 8 bytes
+ Bit16u rhythmMaxTable; // 4 bytes
+ Bit16u patchMaxTable; // 16 bytes
+ Bit16u systemMaxTable; // 23 bytes
+ Bit16u timbreMaxTable; // 72 bytes
+};
+
+struct ControlROMPCMStruct {
+ Bit8u pos;
+ Bit8u len;
+ Bit8u pitchLSB;
+ Bit8u pitchMSB;
+};
struct PCMWaveEntry {
Bit32u addr;
@@ -216,8 +233,6 @@ struct PatchCache {
const TimbreParam::PartialParam *partialParam;
};
-class Partial; // Forward reference for class defined in partial.h
-
}
#endif
diff --git a/audio/softsynth/mt32/Synth.cpp b/audio/softsynth/mt32/Synth.cpp
index 3bff429875..6df7eb9e31 100644
--- a/audio/softsynth/mt32/Synth.cpp
+++ b/audio/softsynth/mt32/Synth.cpp
@@ -22,12 +22,19 @@
#include "mt32emu.h"
#include "mmath.h"
-#include "PartialManager.h"
+#include "internals.h"
+
+#include "Analog.h"
#include "BReverbModel.h"
-#include "common/debug.h"
+#include "MemoryRegion.h"
+#include "MidiEventQueue.h"
+#include "PartialManager.h"
namespace MT32Emu {
+// MIDI interface data transfer rate in samples. Used to simulate the transfer delay.
+static const double MIDI_DATA_TRANSFER_RATE = (double)SAMPLE_RATE / 31250.0 * 8.0;
+
static const ControlROMMap ControlROMMaps[7] = {
// ID IDc IDbytes PCMmap PCMc tmbrA tmbrAO, tmbrAC tmbrB tmbrBO, tmbrBC tmbrR trC rhythm rhyC rsrv panpot prog rhyMax patMax sysMax timMax
{0x4014, 22, "\000 ver1.04 14 July 87 ", 0x3000, 128, 0x8000, 0x0000, false, 0xC000, 0x4000, false, 0x3200, 30, 0x73A6, 85, 0x57C7, 0x57E2, 0x57D0, 0x5252, 0x525E, 0x526E, 0x520A},
@@ -46,18 +53,15 @@ static inline void advanceStreamPosition(Sample *&stream, Bit32u posDelta) {
}
}
-Bit8u Synth::calcSysexChecksum(const Bit8u *data, Bit32u len, Bit8u checksum) {
+Bit8u Synth::calcSysexChecksum(const Bit8u *data, const Bit32u len, const Bit8u initChecksum) {
+ unsigned int checksum = -initChecksum;
for (unsigned int i = 0; i < len; i++) {
- checksum = checksum + data[i];
+ checksum -= data[i];
}
- checksum = checksum & 0x7f;
- if (checksum) {
- checksum = 0x80 - checksum;
- }
- return checksum;
+ return Bit8u(checksum & 0x7f);
}
-Synth::Synth(ReportHandler *useReportHandler) {
+Synth::Synth(ReportHandler *useReportHandler) : mt32ram(*new MemParams()), mt32default(*new MemParams()) {
isOpen = false;
reverbOverridden = false;
partialCount = DEFAULT_MAX_PARTIALS;
@@ -75,6 +79,7 @@ Synth::Synth(ReportHandler *useReportHandler) {
reverbModels[i] = NULL;
}
reverbModel = NULL;
+ analog = NULL;
setDACInputMode(DACInputMode_NICE);
setMIDIDelayMode(MIDIDelayMode_DELAY_SHORT_MESSAGES_ONLY);
setOutputGain(1.0f);
@@ -92,6 +97,8 @@ Synth::~Synth() {
if (isDefaultReportHandler) {
delete reportHandler;
}
+ delete &mt32ram;
+ delete &mt32default;
}
void ReportHandler::showLCDMessage(const char *data) {
@@ -126,7 +133,7 @@ void Synth::printDebug(const char *fmt, ...) {
va_list ap;
va_start(ap, fmt);
#if MT32EMU_DEBUG_SAMPLESTAMPS > 0
- reportHandler->printDebug("[%u] ", renderedSampleCount);
+ reportHandler->printDebug("[%u] ", (char *)&renderedSampleCount);
#endif
reportHandler->printDebug(fmt, ap);
va_end(ap);
@@ -211,10 +218,7 @@ MIDIDelayMode Synth::getMIDIDelayMode() const {
void Synth::setOutputGain(float newOutputGain) {
if (newOutputGain < 0.0f) newOutputGain = -newOutputGain;
outputGain = newOutputGain;
-#if !MT32EMU_USE_FLOAT_SAMPLES
- if (256.0f < newOutputGain) newOutputGain = 256.0f;
- effectiveOutputGain = int(newOutputGain * 256.0f);
-#endif
+ if (analog != NULL) analog->setSynthOutputGain(newOutputGain);
}
float Synth::getOutputGain() const {
@@ -224,13 +228,7 @@ float Synth::getOutputGain() const {
void Synth::setReverbOutputGain(float newReverbOutputGain) {
if (newReverbOutputGain < 0.0f) newReverbOutputGain = -newReverbOutputGain;
reverbOutputGain = newReverbOutputGain;
- if (!isMT32ReverbCompatibilityMode()) newReverbOutputGain *= CM32L_REVERB_TO_LA32_ANALOG_OUTPUT_GAIN_FACTOR;
-#if MT32EMU_USE_FLOAT_SAMPLES
- effectiveReverbOutputGain = newReverbOutputGain;
-#else
- if (256.0f < newReverbOutputGain) newReverbOutputGain = 256.0f;
- effectiveReverbOutputGain = int(newReverbOutputGain * 256.0f);
-#endif
+ if (analog != NULL) analog->setReverbOutputGain(newReverbOutputGain, isMT32ReverbCompatibilityMode());
}
float Synth::getReverbOutputGain() const {
@@ -393,7 +391,11 @@ bool Synth::initTimbres(Bit16u mapAddress, Bit16u offset, int count, int startTi
return true;
}
-bool Synth::open(const ROMImage &controlROMImage, const ROMImage &pcmROMImage, unsigned int usePartialCount) {
+bool Synth::open(const ROMImage &controlROMImage, const ROMImage &pcmROMImage, AnalogOutputMode analogOutputMode) {
+ return open(controlROMImage, pcmROMImage, DEFAULT_MAX_PARTIALS, analogOutputMode);
+}
+
+bool Synth::open(const ROMImage &controlROMImage, const ROMImage &pcmROMImage, unsigned int usePartialCount, AnalogOutputMode analogOutputMode) {
if (isOpen) {
return false;
}
@@ -548,6 +550,10 @@ bool Synth::open(const ROMImage &controlROMImage, const ROMImage &pcmROMImage, u
midiQueue = new MidiEventQueue();
+ analog = new Analog(analogOutputMode, controlROMFeatures);
+ setOutputGain(outputGain);
+ setReverbOutputGain(reverbOutputGain);
+
isOpen = true;
isEnabled = false;
@@ -565,6 +571,9 @@ void Synth::close(bool forced) {
delete midiQueue;
midiQueue = NULL;
+ delete analog;
+ analog = NULL;
+
delete partialManager;
partialManager = NULL;
@@ -603,16 +612,37 @@ void Synth::flushMIDIQueue() {
}
}
-void Synth::setMIDIEventQueueSize(Bit32u useSize) {
- if (midiQueue != NULL) {
- flushMIDIQueue();
- delete midiQueue;
- midiQueue = new MidiEventQueue(useSize);
+Bit32u Synth::setMIDIEventQueueSize(Bit32u useSize) {
+ static const Bit32u MAX_QUEUE_SIZE = (1 << 24); // This results in about 256 Mb - much greater than any reasonable value
+
+ if (midiQueue == NULL) return 0;
+ flushMIDIQueue();
+
+ // Find a power of 2 that is >= useSize
+ Bit32u binarySize = 1;
+ if (useSize < MAX_QUEUE_SIZE) {
+ // Using simple linear search as this isn't time critical
+ while (binarySize < useSize) binarySize <<= 1;
+ } else {
+ binarySize = MAX_QUEUE_SIZE;
}
+ delete midiQueue;
+ midiQueue = new MidiEventQueue(binarySize);
+ return binarySize;
}
Bit32u Synth::getShortMessageLength(Bit32u msg) {
- if ((msg & 0xF0) == 0xF0) return 1;
+ if ((msg & 0xF0) == 0xF0) {
+ switch (msg & 0xFF) {
+ case 0xF1:
+ case 0xF3:
+ return 2;
+ case 0xF2:
+ return 3;
+ default:
+ return 1;
+ }
+ }
// NOTE: This calculation isn't quite correct
// as it doesn't consider the running status byte
return ((msg & 0xE0) == 0xC0) ? 2 : 3;
@@ -638,6 +668,7 @@ bool Synth::playMsg(Bit32u msg, Bit32u timestamp) {
if (midiDelayMode != MIDIDelayMode_IMMEDIATE) {
timestamp = addMIDIInterfaceDelay(getShortMessageLength(msg), timestamp);
}
+ if (!isEnabled) isEnabled = true;
return midiQueue->pushShortMessage(msg, timestamp);
}
@@ -650,16 +681,19 @@ bool Synth::playSysex(const Bit8u *sysex, Bit32u len, Bit32u timestamp) {
if (midiDelayMode == MIDIDelayMode_DELAY_ALL) {
timestamp = addMIDIInterfaceDelay(len, timestamp);
}
+ if (!isEnabled) isEnabled = true;
return midiQueue->pushSysex(sysex, len, timestamp);
}
void Synth::playMsgNow(Bit32u msg) {
- // FIXME: Implement active sensing
+ // NOTE: Active sense IS implemented in real hardware. However, realtime processing is clearly out of the library scope.
+ // It is assumed that realtime consumers of the library respond to these MIDI events as appropriate.
+
unsigned char code = (unsigned char)((msg & 0x0000F0) >> 4);
unsigned char chan = (unsigned char)(msg & 0x00000F);
unsigned char note = (unsigned char)((msg & 0x007F00) >> 8);
unsigned char velocity = (unsigned char)((msg & 0x7F0000) >> 16);
- isEnabled = true;
+ if (!isEnabled) isEnabled = true;
//printDebug("Playing chan %d, code 0x%01x note: 0x%02x", chan, code, note);
@@ -831,7 +865,7 @@ void Synth::playSysexWithoutHeader(unsigned char device, unsigned char command,
printDebug("playSysexWithoutHeader: Message is too short (%d bytes)!", len);
return;
}
- unsigned char checksum = calcSysexChecksum(sysex, len - 1, 0);
+ Bit8u checksum = calcSysexChecksum(sysex, len - 1);
if (checksum != sysex[len - 1]) {
printDebug("playSysexWithoutHeader: Message checksum is incorrect (provided: %02x, expected: %02x)!", sysex[len - 1], checksum);
return;
@@ -1410,9 +1444,8 @@ void MidiEvent::setSysex(const Bit8u *useSysexData, Bit32u useSysexLength, Bit32
memcpy(dstSysexData, useSysexData, sysexLength);
}
-MidiEventQueue::MidiEventQueue(Bit32u useRingBufferSize) : ringBufferSize(useRingBufferSize) {
- ringBuffer = new MidiEvent[ringBufferSize];
- memset(ringBuffer, 0, ringBufferSize * sizeof(MidiEvent));
+MidiEventQueue::MidiEventQueue(Bit32u useRingBufferSize) : ringBuffer(new MidiEvent[useRingBufferSize]), ringBufferMask(useRingBufferSize - 1) {
+ memset(ringBuffer, 0, useRingBufferSize * sizeof(MidiEvent));
reset();
}
@@ -1426,7 +1459,7 @@ void MidiEventQueue::reset() {
}
bool MidiEventQueue::pushShortMessage(Bit32u shortMessageData, Bit32u timestamp) {
- unsigned int newEndPosition = (endPosition + 1) % ringBufferSize;
+ Bit32u newEndPosition = (endPosition + 1) & ringBufferMask;
// Is ring buffer full?
if (startPosition == newEndPosition) return false;
ringBuffer[endPosition].setShortMessage(shortMessageData, timestamp);
@@ -1435,7 +1468,7 @@ bool MidiEventQueue::pushShortMessage(Bit32u shortMessageData, Bit32u timestamp)
}
bool MidiEventQueue::pushSysex(const Bit8u *sysexData, Bit32u sysexLength, Bit32u timestamp) {
- unsigned int newEndPosition = (endPosition + 1) % ringBufferSize;
+ Bit32u newEndPosition = (endPosition + 1) & ringBufferMask;
// Is ring buffer full?
if (startPosition == newEndPosition) return false;
ringBuffer[endPosition].setSysex(sysexData, sysexLength, timestamp);
@@ -1450,31 +1483,36 @@ const MidiEvent *MidiEventQueue::peekMidiEvent() {
void MidiEventQueue::dropMidiEvent() {
// Is ring buffer empty?
if (startPosition != endPosition) {
- startPosition = (startPosition + 1) % ringBufferSize;
+ startPosition = (startPosition + 1) & ringBufferMask;
}
}
+bool MidiEventQueue::isFull() const {
+ return startPosition == ((endPosition + 1) & ringBufferMask);
+}
+
+unsigned int Synth::getStereoOutputSampleRate() const {
+ return (analog == NULL) ? SAMPLE_RATE : analog->getOutputSampleRate();
+}
+
void Synth::render(Sample *stream, Bit32u len) {
- Sample tmpNonReverbLeft[MAX_SAMPLES_PER_RUN];
- Sample tmpNonReverbRight[MAX_SAMPLES_PER_RUN];
- Sample tmpReverbDryLeft[MAX_SAMPLES_PER_RUN];
- Sample tmpReverbDryRight[MAX_SAMPLES_PER_RUN];
- Sample tmpReverbWetLeft[MAX_SAMPLES_PER_RUN];
- Sample tmpReverbWetRight[MAX_SAMPLES_PER_RUN];
+ if (!isEnabled) {
+ renderedSampleCount += analog->getDACStreamsLength(len);
+ analog->process(NULL, NULL, NULL, NULL, NULL, NULL, NULL, len);
+ muteSampleBuffer(stream, len << 1);
+ return;
+ }
+
+ // As in AnalogOutputMode_ACCURATE mode output is upsampled, buffer size MAX_SAMPLES_PER_RUN is more than enough.
+ Sample tmpNonReverbLeft[MAX_SAMPLES_PER_RUN], tmpNonReverbRight[MAX_SAMPLES_PER_RUN];
+ Sample tmpReverbDryLeft[MAX_SAMPLES_PER_RUN], tmpReverbDryRight[MAX_SAMPLES_PER_RUN];
+ Sample tmpReverbWetLeft[MAX_SAMPLES_PER_RUN], tmpReverbWetRight[MAX_SAMPLES_PER_RUN];
while (len > 0) {
- Bit32u thisLen = len > MAX_SAMPLES_PER_RUN ? MAX_SAMPLES_PER_RUN : len;
- renderStreams(tmpNonReverbLeft, tmpNonReverbRight, tmpReverbDryLeft, tmpReverbDryRight, tmpReverbWetLeft, tmpReverbWetRight, thisLen);
- for (Bit32u i = 0; i < thisLen; i++) {
-#if MT32EMU_USE_FLOAT_SAMPLES
- *(stream++) = tmpNonReverbLeft[i] + tmpReverbDryLeft[i] + tmpReverbWetLeft[i];
- *(stream++) = tmpNonReverbRight[i] + tmpReverbDryRight[i] + tmpReverbWetRight[i];
-#else
- *(stream++) = clipBit16s((Bit32s)tmpNonReverbLeft[i] + (Bit32s)tmpReverbDryLeft[i] + (Bit32s)tmpReverbWetLeft[i]);
- *(stream++) = clipBit16s((Bit32s)tmpNonReverbRight[i] + (Bit32s)tmpReverbDryRight[i] + (Bit32s)tmpReverbWetRight[i]);
-#endif
- }
- len -= thisLen;
+ Bit32u thisPassLen = len > MAX_SAMPLES_PER_RUN ? MAX_SAMPLES_PER_RUN : len;
+ renderStreams(tmpNonReverbLeft, tmpNonReverbRight, tmpReverbDryLeft, tmpReverbDryRight, tmpReverbWetLeft, tmpReverbWetRight, analog->getDACStreamsLength(thisPassLen));
+ analog->process(&stream, tmpNonReverbLeft, tmpNonReverbRight, tmpReverbDryLeft, tmpReverbDryRight, tmpReverbWetLeft, tmpReverbWetRight, thisPassLen);
+ len -= thisPassLen;
}
}
@@ -1518,7 +1556,10 @@ void Synth::renderStreams(Sample *nonReverbLeft, Sample *nonReverbRight, Sample
// In GENERATION2 units, the output from LA32 goes to the Boss chip already bit-shifted.
// In NICE mode, it's also better to increase volume before the reverb processing to preserve accuracy.
void Synth::produceLA32Output(Sample *buffer, Bit32u len) {
-#if !MT32EMU_USE_FLOAT_SAMPLES
+#if MT32EMU_USE_FLOAT_SAMPLES
+ (void)buffer;
+ (void)len;
+#else
switch (dacInputMode) {
case DACInputMode_GENERATION2:
while (len--) {
@@ -1528,7 +1569,7 @@ void Synth::produceLA32Output(Sample *buffer, Bit32u len) {
break;
case DACInputMode_NICE:
while (len--) {
- *buffer = clipBit16s(Bit32s(*buffer) << 1);
+ *buffer = clipSampleEx(SampleEx(*buffer) << 1);
++buffer;
}
break;
@@ -1538,26 +1579,16 @@ void Synth::produceLA32Output(Sample *buffer, Bit32u len) {
#endif
}
-void Synth::convertSamplesToOutput(Sample *buffer, Bit32u len, bool reverb) {
- if (dacInputMode == DACInputMode_PURE) return;
-
+void Synth::convertSamplesToOutput(Sample *buffer, Bit32u len) {
#if MT32EMU_USE_FLOAT_SAMPLES
- float gain = reverb ? effectiveReverbOutputGain : outputGain;
- while (len--) {
- *(buffer++) *= gain;
- }
+ (void)buffer;
+ (void)len;
#else
- int gain = reverb ? effectiveReverbOutputGain : effectiveOutputGain;
if (dacInputMode == DACInputMode_GENERATION1) {
while (len--) {
- Bit32s target = Bit16s((*buffer & 0x8000) | ((*buffer << 1) & 0x7FFE));
- *(buffer++) = clipBit16s((target * gain) >> 8);
+ *buffer = Sample((*buffer & 0x8000) | ((*buffer << 1) & 0x7FFE));
+ ++buffer;
}
- return;
- }
- while (len--) {
- *buffer = clipBit16s((Bit32s(*buffer) * gain) >> 8);
- ++buffer;
}
#endif
}
@@ -1566,18 +1597,18 @@ void Synth::doRenderStreams(Sample *nonReverbLeft, Sample *nonReverbRight, Sampl
// Even if LA32 output isn't desired, we proceed anyway with temp buffers
Sample tmpBufNonReverbLeft[MAX_SAMPLES_PER_RUN], tmpBufNonReverbRight[MAX_SAMPLES_PER_RUN];
if (nonReverbLeft == NULL) nonReverbLeft = tmpBufNonReverbLeft;
- if (nonReverbLeft == NULL) nonReverbRight = tmpBufNonReverbRight;
+ if (nonReverbRight == NULL) nonReverbRight = tmpBufNonReverbRight;
Sample tmpBufReverbDryLeft[MAX_SAMPLES_PER_RUN], tmpBufReverbDryRight[MAX_SAMPLES_PER_RUN];
if (reverbDryLeft == NULL) reverbDryLeft = tmpBufReverbDryLeft;
if (reverbDryRight == NULL) reverbDryRight = tmpBufReverbDryRight;
- muteSampleBuffer(nonReverbLeft, len);
- muteSampleBuffer(nonReverbRight, len);
- muteSampleBuffer(reverbDryLeft, len);
- muteSampleBuffer(reverbDryRight, len);
-
if (isEnabled) {
+ muteSampleBuffer(nonReverbLeft, len);
+ muteSampleBuffer(nonReverbRight, len);
+ muteSampleBuffer(reverbDryLeft, len);
+ muteSampleBuffer(reverbDryRight, len);
+
for (unsigned int i = 0; i < getPartialCount(); i++) {
if (partialManager->shouldReverb(i)) {
partialManager->produceOutput(i, reverbDryLeft, reverbDryRight, len);
@@ -1591,8 +1622,8 @@ void Synth::doRenderStreams(Sample *nonReverbLeft, Sample *nonReverbRight, Sampl
if (isReverbEnabled()) {
reverbModel->process(reverbDryLeft, reverbDryRight, reverbWetLeft, reverbWetRight, len);
- if (reverbWetLeft != NULL) convertSamplesToOutput(reverbWetLeft, len, true);
- if (reverbWetRight != NULL) convertSamplesToOutput(reverbWetRight, len, true);
+ if (reverbWetLeft != NULL) convertSamplesToOutput(reverbWetLeft, len);
+ if (reverbWetRight != NULL) convertSamplesToOutput(reverbWetRight, len);
} else {
muteSampleBuffer(reverbWetLeft, len);
muteSampleBuffer(reverbWetRight, len);
@@ -1601,15 +1632,20 @@ void Synth::doRenderStreams(Sample *nonReverbLeft, Sample *nonReverbRight, Sampl
// Don't bother with conversion if the output is going to be unused
if (nonReverbLeft != tmpBufNonReverbLeft) {
produceLA32Output(nonReverbLeft, len);
- convertSamplesToOutput(nonReverbLeft, len, false);
+ convertSamplesToOutput(nonReverbLeft, len);
}
if (nonReverbRight != tmpBufNonReverbRight) {
produceLA32Output(nonReverbRight, len);
- convertSamplesToOutput(nonReverbRight, len, false);
+ convertSamplesToOutput(nonReverbRight, len);
}
- if (reverbDryLeft != tmpBufReverbDryLeft) convertSamplesToOutput(reverbDryLeft, len, false);
- if (reverbDryRight != tmpBufReverbDryRight) convertSamplesToOutput(reverbDryRight, len, false);
+ if (reverbDryLeft != tmpBufReverbDryLeft) convertSamplesToOutput(reverbDryLeft, len);
+ if (reverbDryRight != tmpBufReverbDryRight) convertSamplesToOutput(reverbDryRight, len);
} else {
+ // Avoid muting buffers that wasn't requested
+ if (nonReverbLeft != tmpBufNonReverbLeft) muteSampleBuffer(nonReverbLeft, len);
+ if (nonReverbRight != tmpBufNonReverbRight) muteSampleBuffer(nonReverbRight, len);
+ if (reverbDryLeft != tmpBufReverbDryLeft) muteSampleBuffer(reverbDryLeft, len);
+ if (reverbDryRight != tmpBufReverbDryRight) muteSampleBuffer(reverbDryRight, len);
muteSampleBuffer(reverbWetLeft, len);
muteSampleBuffer(reverbWetRight, len);
}
@@ -1651,14 +1687,48 @@ bool Synth::isActive() const {
return false;
}
-const Partial *Synth::getPartial(unsigned int partialNum) const {
- return partialManager->getPartial(partialNum);
-}
-
unsigned int Synth::getPartialCount() const {
return partialCount;
}
+void Synth::getPartStates(bool *partStates) const {
+ for (int partNumber = 0; partNumber < 9; partNumber++) {
+ const Part *part = parts[partNumber];
+ partStates[partNumber] = part->getActiveNonReleasingPartialCount() > 0;
+ }
+}
+
+void Synth::getPartialStates(PartialState *partialStates) const {
+ static const PartialState partialPhaseToState[8] = {
+ PartialState_ATTACK, PartialState_ATTACK, PartialState_ATTACK, PartialState_ATTACK,
+ PartialState_SUSTAIN, PartialState_SUSTAIN, PartialState_RELEASE, PartialState_INACTIVE
+ };
+
+ for (unsigned int partialNum = 0; partialNum < getPartialCount(); partialNum++) {
+ const Partial *partial = partialManager->getPartial(partialNum);
+ partialStates[partialNum] = partial->isActive() ? partialPhaseToState[partial->getTVA()->getPhase()] : PartialState_INACTIVE;
+ }
+}
+
+unsigned int Synth::getPlayingNotes(unsigned int partNumber, Bit8u *keys, Bit8u *velocities) const {
+ unsigned int playingNotes = 0;
+ if (isOpen && (partNumber < 9)) {
+ const Part *part = parts[partNumber];
+ const Poly *poly = part->getFirstActivePoly();
+ while (poly != NULL) {
+ keys[playingNotes] = (Bit8u)poly->getKey();
+ velocities[playingNotes] = (Bit8u)poly->getVelocity();
+ playingNotes++;
+ poly = poly->getNext();
+ }
+ }
+ return playingNotes;
+}
+
+const char *Synth::getPatchName(unsigned int partNumber) const {
+ return (!isOpen || partNumber > 8) ? NULL : parts[partNumber]->getCurrentInstr();
+}
+
const Part *Synth::getPart(unsigned int partNum) const {
if (partNum > 8) {
return NULL;
diff --git a/audio/softsynth/mt32/Synth.h b/audio/softsynth/mt32/Synth.h
index 37fb7b280a..97d4644ee2 100644
--- a/audio/softsynth/mt32/Synth.h
+++ b/audio/softsynth/mt32/Synth.h
@@ -19,15 +19,31 @@
#define MT32EMU_SYNTH_H
//#include <cstdarg>
+//#include <cstring>
namespace MT32Emu {
-class TableInitialiser;
+class Analog;
+class BReverbModel;
+class MemoryRegion;
+class MidiEventQueue;
+class Part;
+class Poly;
class Partial;
class PartialManager;
-class Part;
-class ROMImage;
-class BReverbModel;
+
+class PatchTempMemoryRegion;
+class RhythmTempMemoryRegion;
+class TimbreTempMemoryRegion;
+class PatchesMemoryRegion;
+class TimbresMemoryRegion;
+class SystemMemoryRegion;
+class DisplayMemoryRegion;
+class ResetMemoryRegion;
+
+struct ControlROMMap;
+struct PCMWaveEntry;
+struct MemParams;
/**
* Methods for emulating the connection between the LA32 and the DAC, which involves
@@ -43,8 +59,7 @@ enum DACInputMode {
// Produces samples that exactly match the bits output from the emulated LA32.
// * Nicer overdrive characteristics than the DAC hacks (it simply clips samples within range)
// * Much less likely to overdrive than any other mode.
- // * Half the volume of any of the other modes, meaning its volume relative to the reverb
- // output when mixed together directly will sound wrong.
+ // * Half the volume of any of the other modes.
// * Output gain is ignored for both LA32 and reverb output.
// * Perfect for developers while debugging :)
DACInputMode_PURE,
@@ -60,6 +75,7 @@ enum DACInputMode {
DACInputMode_GENERATION2
};
+// Methods for emulating the effective delay of incoming MIDI messages introduced by a MIDI interface.
enum MIDIDelayMode {
// Process incoming MIDI events immediately.
MIDIDelayMode_IMMEDIATE,
@@ -72,6 +88,35 @@ enum MIDIDelayMode {
MIDIDelayMode_DELAY_ALL
};
+// Methods for emulating the effects of analogue circuits of real hardware units on the output signal.
+enum AnalogOutputMode {
+ // Only digital path is emulated. The output samples correspond to the digital signal at the DAC entrance.
+ AnalogOutputMode_DIGITAL_ONLY,
+ // Coarse emulation of LPF circuit. High frequencies are boosted, sample rate remains unchanged.
+ AnalogOutputMode_COARSE,
+ // Finer emulation of LPF circuit. Output signal is upsampled to 48 kHz to allow emulation of audible mirror spectra above 16 kHz,
+ // which is passed through the LPF circuit without significant attenuation.
+ AnalogOutputMode_ACCURATE,
+ // Same as AnalogOutputMode_ACCURATE mode but the output signal is 2x oversampled, i.e. the output sample rate is 96 kHz.
+ // This makes subsequent resampling easier. Besides, due to nonlinear passband of the LPF emulated, it takes fewer number of MACs
+ // compared to a regular LPF FIR implementations.
+ AnalogOutputMode_OVERSAMPLED
+};
+
+enum ReverbMode {
+ REVERB_MODE_ROOM,
+ REVERB_MODE_HALL,
+ REVERB_MODE_PLATE,
+ REVERB_MODE_TAP_DELAY
+};
+
+enum PartialState {
+ PartialState_INACTIVE,
+ PartialState_ATTACK,
+ PartialState_SUSTAIN,
+ PartialState_RELEASE
+};
+
const Bit8u SYSEX_MANUFACTURER_ROLAND = 0x41;
const Bit8u SYSEX_MDL_MT32 = 0x16;
@@ -87,148 +132,10 @@ const Bit8u SYSEX_CMD_EOD = 0x45; // End of data
const Bit8u SYSEX_CMD_ERR = 0x4E; // Communications error
const Bit8u SYSEX_CMD_RJC = 0x4F; // Rejection
-const int MAX_SYSEX_SIZE = 512;
+const int MAX_SYSEX_SIZE = 512; // FIXME: Does this correspond to a real MIDI buffer used in h/w devices?
const unsigned int CONTROL_ROM_SIZE = 64 * 1024;
-struct ControlROMPCMStruct {
- Bit8u pos;
- Bit8u len;
- Bit8u pitchLSB;
- Bit8u pitchMSB;
-};
-
-struct ControlROMMap {
- Bit16u idPos;
- Bit16u idLen;
- const char *idBytes;
- Bit16u pcmTable; // 4 * pcmCount bytes
- Bit16u pcmCount;
- Bit16u timbreAMap; // 128 bytes
- Bit16u timbreAOffset;
- bool timbreACompressed;
- Bit16u timbreBMap; // 128 bytes
- Bit16u timbreBOffset;
- bool timbreBCompressed;
- Bit16u timbreRMap; // 2 * timbreRCount bytes
- Bit16u timbreRCount;
- Bit16u rhythmSettings; // 4 * rhythmSettingsCount bytes
- Bit16u rhythmSettingsCount;
- Bit16u reserveSettings; // 9 bytes
- Bit16u panSettings; // 8 bytes
- Bit16u programSettings; // 8 bytes
- Bit16u rhythmMaxTable; // 4 bytes
- Bit16u patchMaxTable; // 16 bytes
- Bit16u systemMaxTable; // 23 bytes
- Bit16u timbreMaxTable; // 72 bytes
-};
-
-enum MemoryRegionType {
- MR_PatchTemp, MR_RhythmTemp, MR_TimbreTemp, MR_Patches, MR_Timbres, MR_System, MR_Display, MR_Reset
-};
-
-enum ReverbMode {
- REVERB_MODE_ROOM,
- REVERB_MODE_HALL,
- REVERB_MODE_PLATE,
- REVERB_MODE_TAP_DELAY
-};
-
-class MemoryRegion {
-private:
- Synth *synth;
- Bit8u *realMemory;
- Bit8u *maxTable;
-public:
- MemoryRegionType type;
- Bit32u startAddr, entrySize, entries;
-
- MemoryRegion(Synth *useSynth, Bit8u *useRealMemory, Bit8u *useMaxTable, MemoryRegionType useType, Bit32u useStartAddr, Bit32u useEntrySize, Bit32u useEntries) {
- synth = useSynth;
- realMemory = useRealMemory;
- maxTable = useMaxTable;
- type = useType;
- startAddr = useStartAddr;
- entrySize = useEntrySize;
- entries = useEntries;
- }
- int lastTouched(Bit32u addr, Bit32u len) const {
- return (offset(addr) + len - 1) / entrySize;
- }
- int firstTouchedOffset(Bit32u addr) const {
- return offset(addr) % entrySize;
- }
- int firstTouched(Bit32u addr) const {
- return offset(addr) / entrySize;
- }
- Bit32u regionEnd() const {
- return startAddr + entrySize * entries;
- }
- bool contains(Bit32u addr) const {
- return addr >= startAddr && addr < regionEnd();
- }
- int offset(Bit32u addr) const {
- return addr - startAddr;
- }
- Bit32u getClampedLen(Bit32u addr, Bit32u len) const {
- if (addr + len > regionEnd())
- return regionEnd() - addr;
- return len;
- }
- Bit32u next(Bit32u addr, Bit32u len) const {
- if (addr + len > regionEnd()) {
- return regionEnd() - addr;
- }
- return 0;
- }
- Bit8u getMaxValue(int off) const {
- if (maxTable == NULL)
- return 0xFF;
- return maxTable[off % entrySize];
- }
- Bit8u *getRealMemory() const {
- return realMemory;
- }
- bool isReadable() const {
- return getRealMemory() != NULL;
- }
- void read(unsigned int entry, unsigned int off, Bit8u *dst, unsigned int len) const;
- void write(unsigned int entry, unsigned int off, const Bit8u *src, unsigned int len, bool init = false) const;
-};
-
-class PatchTempMemoryRegion : public MemoryRegion {
-public:
- PatchTempMemoryRegion(Synth *useSynth, Bit8u *useRealMemory, Bit8u *useMaxTable) : MemoryRegion(useSynth, useRealMemory, useMaxTable, MR_PatchTemp, MT32EMU_MEMADDR(0x030000), sizeof(MemParams::PatchTemp), 9) {}
-};
-class RhythmTempMemoryRegion : public MemoryRegion {
-public:
- RhythmTempMemoryRegion(Synth *useSynth, Bit8u *useRealMemory, Bit8u *useMaxTable) : MemoryRegion(useSynth, useRealMemory, useMaxTable, MR_RhythmTemp, MT32EMU_MEMADDR(0x030110), sizeof(MemParams::RhythmTemp), 85) {}
-};
-class TimbreTempMemoryRegion : public MemoryRegion {
-public:
- TimbreTempMemoryRegion(Synth *useSynth, Bit8u *useRealMemory, Bit8u *useMaxTable) : MemoryRegion(useSynth, useRealMemory, useMaxTable, MR_TimbreTemp, MT32EMU_MEMADDR(0x040000), sizeof(TimbreParam), 8) {}
-};
-class PatchesMemoryRegion : public MemoryRegion {
-public:
- PatchesMemoryRegion(Synth *useSynth, Bit8u *useRealMemory, Bit8u *useMaxTable) : MemoryRegion(useSynth, useRealMemory, useMaxTable, MR_Patches, MT32EMU_MEMADDR(0x050000), sizeof(PatchParam), 128) {}
-};
-class TimbresMemoryRegion : public MemoryRegion {
-public:
- TimbresMemoryRegion(Synth *useSynth, Bit8u *useRealMemory, Bit8u *useMaxTable) : MemoryRegion(useSynth, useRealMemory, useMaxTable, MR_Timbres, MT32EMU_MEMADDR(0x080000), sizeof(MemParams::PaddedTimbre), 64 + 64 + 64 + 64) {}
-};
-class SystemMemoryRegion : public MemoryRegion {
-public:
- SystemMemoryRegion(Synth *useSynth, Bit8u *useRealMemory, Bit8u *useMaxTable) : MemoryRegion(useSynth, useRealMemory, useMaxTable, MR_System, MT32EMU_MEMADDR(0x100000), sizeof(MemParams::System), 1) {}
-};
-class DisplayMemoryRegion : public MemoryRegion {
-public:
- DisplayMemoryRegion(Synth *useSynth) : MemoryRegion(useSynth, NULL, NULL, MR_Display, MT32EMU_MEMADDR(0x200000), MAX_SYSEX_SIZE - 1, 1) {}
-};
-class ResetMemoryRegion : public MemoryRegion {
-public:
- ResetMemoryRegion(Synth *useSynth) : MemoryRegion(useSynth, NULL, NULL, MR_Reset, MT32EMU_MEMADDR(0x7F0000), 0x3FFF, 1) {}
-};
-
class ReportHandler {
friend class Synth;
@@ -254,47 +161,6 @@ protected:
virtual void onProgramChanged(int /* partNum */, int /* bankNum */, const char * /* patchName */) {}
};
-/**
- * Used to safely store timestamped MIDI events in a local queue.
- */
-struct MidiEvent {
- Bit32u shortMessageData;
- const Bit8u *sysexData;
- Bit32u sysexLength;
- Bit32u timestamp;
-
- ~MidiEvent();
- void setShortMessage(Bit32u shortMessageData, Bit32u timestamp);
- void setSysex(const Bit8u *sysexData, Bit32u sysexLength, Bit32u timestamp);
-};
-
-/**
- * Simple queue implementation using a ring buffer to store incoming MIDI event before the synth actually processes it.
- * It is intended to:
- * - get rid of prerenderer while retaining graceful partial abortion
- * - add fair emulation of the MIDI interface delays
- * - extend the synth interface with the default implementation of a typical rendering loop.
- * THREAD SAFETY:
- * It is safe to use either in a single thread environment or when there are only two threads - one performs only reading
- * and one performs only writing. More complicated usage requires external synchronisation.
- */
-class MidiEventQueue {
-private:
- MidiEvent *ringBuffer;
- Bit32u ringBufferSize;
- volatile Bit32u startPosition;
- volatile Bit32u endPosition;
-
-public:
- MidiEventQueue(Bit32u ringBufferSize = DEFAULT_MIDI_EVENT_QUEUE_SIZE);
- ~MidiEventQueue();
- void reset();
- bool pushShortMessage(Bit32u shortMessageData, Bit32u timestamp);
- bool pushSysex(const Bit8u *sysexData, Bit32u sysexLength, Bit32u timestamp);
- const MidiEvent *peekMidiEvent();
- void dropMidiEvent();
-};
-
class Synth {
friend class Part;
friend class RhythmPart;
@@ -335,7 +201,7 @@ private:
volatile Bit32u lastReceivedMIDIEventTimestamp;
volatile Bit32u renderedSampleCount;
- MemParams mt32ram, mt32default;
+ MemParams &mt32ram, &mt32default;
BReverbModel *reverbModels[4];
BReverbModel *reverbModel;
@@ -346,12 +212,6 @@ private:
float outputGain;
float reverbOutputGain;
-#if MT32EMU_USE_FLOAT_SAMPLES
- float effectiveReverbOutputGain;
-#else
- int effectiveOutputGain;
- int effectiveReverbOutputGain;
-#endif
bool reversedStereoEnabled;
@@ -368,11 +228,12 @@ private:
// We emulate this by delaying new MIDI events processing until abortion finishes.
Poly *abortingPoly;
- Bit32u getShortMessageLength(Bit32u msg);
+ Analog *analog;
+
Bit32u addMIDIInterfaceDelay(Bit32u len, Bit32u timestamp);
void produceLA32Output(Sample *buffer, Bit32u len);
- void convertSamplesToOutput(Sample *buffer, Bit32u len, bool reverb);
+ void convertSamplesToOutput(Sample *buffer, Bit32u len);
bool isAbortingPoly() const;
void doRenderStreams(Sample *nonReverbLeft, Sample *nonReverbRight, Sample *reverbDryLeft, Sample *reverbDryRight, Sample *reverbWetLeft, Sample *reverbWetRight, Bit32u len);
@@ -404,13 +265,20 @@ private:
void newTimbreSet(int partNum, Bit8u timbreGroup, const char patchName[]);
void printDebug(const char *fmt, ...);
+ // partNum should be 0..7 for Part 1..8, or 8 for Rhythm
+ const Part *getPart(unsigned int partNum) const;
+
public:
- static inline Bit16s clipBit16s(Bit32s sample) {
+ static inline Sample clipSampleEx(SampleEx sampleEx) {
+#if MT32EMU_USE_FLOAT_SAMPLES
+ return sampleEx;
+#else
// Clamp values above 32767 to 32767, and values below -32768 to -32768
// FIXME: Do we really need this stuff? I think these branches are very well predicted. Instead, this introduces a chain.
// The version below is actually a bit faster on my system...
- //return ((sample + 0x8000) & ~0xFFFF) ? (sample >> 31) ^ 0x7FFF : (Bit16s)sample;
- return ((-0x8000 <= sample) && (sample <= 0x7FFF)) ? (Bit16s)sample : (sample >> 31) ^ 0x7FFF;
+ //return ((sampleEx + 0x8000) & ~0xFFFF) ? (sampleEx >> 31) ^ 0x7FFF : (Sample)sampleEx;
+ return ((-0x8000 <= sampleEx) && (sampleEx <= 0x7FFF)) ? (Sample)sampleEx : (sampleEx >> 31) ^ 0x7FFF;
+#endif
}
static inline void muteSampleBuffer(Sample *buffer, Bit32u len) {
@@ -426,7 +294,8 @@ public:
#endif
}
- static Bit8u calcSysexChecksum(const Bit8u *data, Bit32u len, Bit8u checksum);
+ static Bit32u getShortMessageLength(Bit32u msg);
+ static Bit8u calcSysexChecksum(const Bit8u *data, const Bit32u len, const Bit8u initChecksum = 0);
// Optionally sets callbacks for reporting various errors, information and debug messages
Synth(ReportHandler *useReportHandler = NULL);
@@ -435,8 +304,12 @@ public:
// Used to initialise the MT-32. Must be called before any other function.
// Returns true if initialization was sucessful, otherwise returns false.
// controlROMImage and pcmROMImage represent Control and PCM ROM images for use by synth.
- // usePartialCount sets the maximum number of partials playing simultaneously for this session.
- bool open(const ROMImage &controlROMImage, const ROMImage &pcmROMImage, unsigned int usePartialCount = DEFAULT_MAX_PARTIALS);
+ // usePartialCount sets the maximum number of partials playing simultaneously for this session (optional).
+ // analogOutputMode sets the mode for emulation of analogue circuitry of the hardware units (optional).
+ bool open(const ROMImage &controlROMImage, const ROMImage &pcmROMImage, unsigned int usePartialCount = DEFAULT_MAX_PARTIALS, AnalogOutputMode analogOutputMode = AnalogOutputMode_COARSE);
+
+ // Overloaded method which opens the synth with default partial count.
+ bool open(const ROMImage &controlROMImage, const ROMImage &pcmROMImage, AnalogOutputMode analogOutputMode);
// Closes the MT-32 and deallocates any memory used by the synthesizer
void close(bool forced = false);
@@ -444,29 +317,34 @@ public:
// All the enqueued events are processed by the synth immediately.
void flushMIDIQueue();
- // Sets size of the internal MIDI event queue.
+ // Sets size of the internal MIDI event queue. The queue size is set to the minimum power of 2 that is greater or equal to the size specified.
// The queue is flushed before reallocation.
- void setMIDIEventQueueSize(Bit32u);
+ // Returns the actual queue size being used.
+ Bit32u setMIDIEventQueueSize(Bit32u);
// Enqueues a MIDI event for subsequent playback.
- // The minimum delay involves the delay introduced while the event is transferred via MIDI interface
+ // The MIDI event will be processed not before the specified timestamp.
+ // The timestamp is measured as the global rendered sample count since the synth was created (at the native sample rate 32000 Hz).
+ // The minimum delay involves emulation of the delay introduced while the event is transferred via MIDI interface
// and emulation of the MCU busy-loop while it frees partials for use by a new Poly.
- // Calls from multiple threads must be synchronised, although,
- // no synchronisation is required with the rendering thread.
+ // Calls from multiple threads must be synchronised, although, no synchronisation is required with the rendering thread.
+ // The methods return false if the MIDI event queue is full and the message cannot be enqueued.
- // The MIDI event will be processed not before the specified timestamp.
- // The timestamp is measured as the global rendered sample count since the synth was created.
+ // Enqueues a single short MIDI message. The message must contain a status byte.
bool playMsg(Bit32u msg, Bit32u timestamp);
+ // Enqueues a single well formed System Exclusive MIDI message.
bool playSysex(const Bit8u *sysex, Bit32u len, Bit32u timestamp);
- // The MIDI event will be processed ASAP.
+
+ // Overloaded methods for the MIDI events to be processed ASAP.
bool playMsg(Bit32u msg);
bool playSysex(const Bit8u *sysex, Bit32u len);
// WARNING:
// The methods below don't ensure minimum 1-sample delay between sequential MIDI events,
// and a sequence of NoteOn and immediately succeeding NoteOff messages is always silent.
+ // A thread that invokes these methods must be explicitly synchronised with the thread performing sample rendering.
- // Sends a 4-byte MIDI message to the MT-32 for immediate playback.
+ // Sends a short MIDI message to the synth for immediate playback. The message must contain a status byte.
void playMsgNow(Bit32u msg);
void playMsgOnPart(unsigned char part, unsigned char code, unsigned char note, unsigned char velocity);
@@ -495,12 +373,17 @@ public:
void setMIDIDelayMode(MIDIDelayMode mode);
MIDIDelayMode getMIDIDelayMode() const;
- // Sets output gain factor. Applied to all output samples and unrelated with the synth's Master volume.
+ // Sets output gain factor for synth output channels. Applied to all output samples and unrelated with the synth's Master volume,
+ // it rather corresponds to the gain of the output analog circuitry of the hardware units. However, together with setReverbOutputGain()
+ // it offers to the user a capability to control the gain of reverb and non-reverb output channels independently.
// Ignored in DACInputMode_PURE
void setOutputGain(float);
float getOutputGain() const;
- // Sets output gain factor for the reverb wet output. setOutputGain() doesn't change reverb output gain.
+ // Sets output gain factor for the reverb wet output channels. It rather corresponds to the gain of the output
+ // analog circuitry of the hardware units. However, together with setOutputGain() it offers to the user a capability
+ // to control the gain of reverb and non-reverb output channels independently.
+ //
// Note: We're currently emulate CM-32L/CM-64 reverb quite accurately and the reverb output level closely
// corresponds to the level of digital capture. Although, according to the CM-64 PCB schematic,
// there is a difference in the reverb analogue circuit, and the resulting output gain is 0.68
@@ -512,12 +395,21 @@ public:
void setReversedStereoEnabled(bool enabled);
bool isReversedStereoEnabled();
- // Renders samples to the specified output stream.
- // The length is in frames, not bytes (in 16-bit stereo,
- // one frame is 4 bytes).
+ // Returns actual sample rate used in emulation of stereo analog circuitry of hardware units.
+ // See comment for render() below.
+ unsigned int getStereoOutputSampleRate() const;
+
+ // Renders samples to the specified output stream as if they were sampled at the analog stereo output.
+ // When AnalogOutputMode is set to ACCURATE, the output signal is upsampled to 48 kHz in order
+ // to retain emulation accuracy in whole audible frequency spectra. Otherwise, native digital signal sample rate is retained.
+ // getStereoOutputSampleRate() can be used to query actual sample rate of the output signal.
+ // The length is in frames, not bytes (in 16-bit stereo, one frame is 4 bytes).
void render(Sample *stream, Bit32u len);
- // Renders samples to the specified output streams (any or all of which may be NULL).
+ // Renders samples to the specified output streams as if they appeared at the DAC entrance.
+ // No further processing performed in analog circuitry emulation is applied to the signal.
+ // NULL may be specified in place of any or all of the stream buffers.
+ // The length is in samples, not bytes.
void renderStreams(Sample *nonReverbLeft, Sample *nonReverbRight, Sample *reverbDryLeft, Sample *reverbDryRight, Sample *reverbWetLeft, Sample *reverbWetRight, Bit32u len);
// Returns true when there is at least one active partial, otherwise false.
@@ -526,15 +418,28 @@ public:
// Returns true if hasActivePartials() returns true, or reverb is (somewhat unreliably) detected as being active.
bool isActive() const;
- const Partial *getPartial(unsigned int partialNum) const;
-
// Returns the maximum number of partials playing simultaneously.
unsigned int getPartialCount() const;
- void readMemory(Bit32u addr, Bit32u len, Bit8u *data);
+ // Fills in current states of all the parts into the array provided. The array must have at least 9 entries to fit values for all the parts.
+ // If the value returned for a part is true, there is at least one active non-releasing partial playing on this part.
+ // This info is useful in emulating behaviour of LCD display of the hardware units.
+ void getPartStates(bool *partStates) const;
- // partNum should be 0..7 for Part 1..8, or 8 for Rhythm
- const Part *getPart(unsigned int partNum) const;
+ // Fills in current states of all the partials into the array provided. The array must be large enough to accommodate states of all the partials.
+ void getPartialStates(PartialState *partialStates) const;
+
+ // Fills in information about currently playing notes on the specified part into the arrays provided. The arrays must be large enough
+ // to accommodate data for all the playing notes. The maximum number of simultaneously playing notes cannot exceed the number of partials.
+ // Argument partNumber should be 0..7 for Part 1..8, or 8 for Rhythm.
+ // Returns the number of currently playing notes on the specified part.
+ unsigned int getPlayingNotes(unsigned int partNumber, Bit8u *keys, Bit8u *velocities) const;
+
+ // Returns name of the patch set on the specified part.
+ // Argument partNumber should be 0..7 for Part 1..8, or 8 for Rhythm.
+ const char *getPatchName(unsigned int partNumber) const;
+
+ void readMemory(Bit32u addr, Bit32u len, Bit8u *data);
};
}
diff --git a/audio/softsynth/mt32/TVA.cpp b/audio/softsynth/mt32/TVA.cpp
index 3fefb791f2..894e53f14a 100644
--- a/audio/softsynth/mt32/TVA.cpp
+++ b/audio/softsynth/mt32/TVA.cpp
@@ -23,6 +23,7 @@
#include "mt32emu.h"
#include "mmath.h"
+#include "internals.h"
namespace MT32Emu {
diff --git a/audio/softsynth/mt32/TVF.cpp b/audio/softsynth/mt32/TVF.cpp
index bf8d50a7c9..164cf2b4cb 100644
--- a/audio/softsynth/mt32/TVF.cpp
+++ b/audio/softsynth/mt32/TVF.cpp
@@ -19,6 +19,7 @@
#include "mt32emu.h"
#include "mmath.h"
+#include "internals.h"
namespace MT32Emu {
diff --git a/audio/softsynth/mt32/TVP.cpp b/audio/softsynth/mt32/TVP.cpp
index 374646e5f1..a8003d96dc 100644
--- a/audio/softsynth/mt32/TVP.cpp
+++ b/audio/softsynth/mt32/TVP.cpp
@@ -19,6 +19,7 @@
//#include <cstdlib>
#include "mt32emu.h"
+#include "internals.h"
namespace MT32Emu {
diff --git a/audio/softsynth/mt32/Tables.cpp b/audio/softsynth/mt32/Tables.cpp
index ae9f11fff0..7e165b5a7a 100644
--- a/audio/softsynth/mt32/Tables.cpp
+++ b/audio/softsynth/mt32/Tables.cpp
@@ -16,14 +16,15 @@
*/
//#include <cmath>
-//#include <cstdlib>
-//#include <cstring>
#include "mt32emu.h"
#include "mmath.h"
+#include "Tables.h"
namespace MT32Emu {
+// UNUSED: const int MIDDLEC = 60;
+
const Tables &Tables::getInstance() {
static const Tables instance;
return instance;
diff --git a/audio/softsynth/mt32/Tables.h b/audio/softsynth/mt32/Tables.h
index e7b97af515..8865c7fac8 100644
--- a/audio/softsynth/mt32/Tables.h
+++ b/audio/softsynth/mt32/Tables.h
@@ -20,24 +20,11 @@
namespace MT32Emu {
-// Sample rate to use in mixing. With the progress of development, we've found way too many thing dependent.
-// In order to achieve further advance in emulation accuracy, sample rate made fixed throughout the emulator.
-// The output from the synth is supposed to be resampled to convert the sample rate.
-const unsigned int SAMPLE_RATE = 32000;
-
-// MIDI interface data transfer rate in samples. Used to simulate the transfer delay.
-const double MIDI_DATA_TRANSFER_RATE = (double)SAMPLE_RATE / 31250.0 * 8.0;
-
-const float CM32L_REVERB_TO_LA32_ANALOG_OUTPUT_GAIN_FACTOR = 0.68f;
-
-const int MIDDLEC = 60;
-
-class Synth;
-
class Tables {
private:
Tables();
Tables(Tables &);
+ ~Tables() {}
public:
static const Tables &getInstance();
diff --git a/audio/softsynth/mt32/Types.h b/audio/softsynth/mt32/Types.h
new file mode 100644
index 0000000000..934b1a1173
--- /dev/null
+++ b/audio/softsynth/mt32/Types.h
@@ -0,0 +1,40 @@
+/* Copyright (C) 2003, 2004, 2005, 2006, 2008, 2009 Dean Beeler, Jerome Fisher
+ * Copyright (C) 2011, 2012, 2013, 2014 Dean Beeler, Jerome Fisher, Sergey V. Mikayev
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 2.1 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef MT32EMU_TYPES_H
+#define MT32EMU_TYPES_H
+
+namespace MT32Emu {
+
+typedef unsigned int Bit32u;
+typedef signed int Bit32s;
+typedef unsigned short int Bit16u;
+typedef signed short int Bit16s;
+typedef unsigned char Bit8u;
+typedef signed char Bit8s;
+
+#if MT32EMU_USE_FLOAT_SAMPLES
+typedef float Sample;
+typedef float SampleEx;
+#else
+typedef Bit16s Sample;
+typedef Bit32s SampleEx;
+#endif
+
+}
+
+#endif
diff --git a/audio/softsynth/mt32/internals.h b/audio/softsynth/mt32/internals.h
new file mode 100644
index 0000000000..ef56819a42
--- /dev/null
+++ b/audio/softsynth/mt32/internals.h
@@ -0,0 +1,83 @@
+/* Copyright (C) 2003, 2004, 2005, 2006, 2008, 2009 Dean Beeler, Jerome Fisher
+ * Copyright (C) 2011, 2012, 2013, 2014 Dean Beeler, Jerome Fisher, Sergey V. Mikayev
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 2.1 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef MT32EMU_INTERNALS_H
+#define MT32EMU_INTERNALS_H
+
+// Debugging
+
+// 0: Standard debug output is not stamped with the rendered sample count
+// 1: Standard debug output is stamped with the rendered sample count
+// NOTE: The "samplestamp" corresponds to the end of the last completed rendering run.
+// This is important to bear in mind for debug output that occurs during a run.
+#define MT32EMU_DEBUG_SAMPLESTAMPS 0
+
+// 0: No debug output for initialisation progress
+// 1: Debug output for initialisation progress
+#define MT32EMU_MONITOR_INIT 0
+
+// 0: No debug output for MIDI events
+// 1: Debug output for weird MIDI events
+#define MT32EMU_MONITOR_MIDI 0
+
+// 0: No debug output for note on/off
+// 1: Basic debug output for note on/off
+// 2: Comprehensive debug output for note on/off
+#define MT32EMU_MONITOR_INSTRUMENTS 0
+
+// 0: No debug output for partial allocations
+// 1: Show partial stats when an allocation fails
+// 2: Show partial stats with every new poly
+// 3: Show individual partial allocations/deactivations
+#define MT32EMU_MONITOR_PARTIALS 0
+
+// 0: No debug output for sysex
+// 1: Basic debug output for sysex
+#define MT32EMU_MONITOR_SYSEX 0
+
+// 0: No debug output for sysex writes to the timbre areas
+// 1: Debug output with the name and location of newly-written timbres
+// 2: Complete dump of timbre parameters for newly-written timbres
+#define MT32EMU_MONITOR_TIMBRES 0
+
+// 0: No TVA/TVF-related debug output.
+// 1: Shows changes to TVA/TVF target, increment and phase.
+#define MT32EMU_MONITOR_TVA 0
+#define MT32EMU_MONITOR_TVF 0
+
+// Configuration
+
+// If non-zero, deletes reverb buffers that are not in use to save memory.
+// If zero, keeps reverb buffers for all modes around all the time to avoid allocating/freeing in the critical path.
+#define MT32EMU_REDUCE_REVERB_MEMORY 1
+
+// 0: Maximum speed at the cost of a bit lower emulation accuracy.
+// 1: Maximum achievable emulation accuracy.
+#define MT32EMU_BOSS_REVERB_PRECISE_MODE 0
+
+#include "Structures.h"
+#include "Tables.h"
+#include "Poly.h"
+#include "LA32Ramp.h"
+#include "LA32WaveGenerator.h"
+#include "TVA.h"
+#include "TVP.h"
+#include "TVF.h"
+#include "Partial.h"
+#include "Part.h"
+
+#endif
diff --git a/audio/softsynth/mt32/module.mk b/audio/softsynth/mt32/module.mk
index 1c8aa125ab..f966da8d08 100644
--- a/audio/softsynth/mt32/module.mk
+++ b/audio/softsynth/mt32/module.mk
@@ -1,6 +1,7 @@
MODULE := audio/softsynth/mt32
MODULE_OBJS := \
+ Analog.o \
BReverbModel.o \
LA32Ramp.o \
LA32WaveGenerator.o \
diff --git a/audio/softsynth/mt32/mt32emu.h b/audio/softsynth/mt32/mt32emu.h
index d738a5de35..1574c08f0d 100644
--- a/audio/softsynth/mt32/mt32emu.h
+++ b/audio/softsynth/mt32/mt32emu.h
@@ -18,63 +18,20 @@
#ifndef MT32EMU_MT32EMU_H
#define MT32EMU_MT32EMU_H
-// Debugging
-
-// 0: Standard debug output is not stamped with the rendered sample count
-// 1: Standard debug output is stamped with the rendered sample count
-// NOTE: The "samplestamp" corresponds to the end of the last completed rendering run.
-// This is important to bear in mind for debug output that occurs during a run.
-#define MT32EMU_DEBUG_SAMPLESTAMPS 0
-
-// 0: No debug output for initialisation progress
-// 1: Debug output for initialisation progress
-#define MT32EMU_MONITOR_INIT 0
-
-// 0: No debug output for MIDI events
-// 1: Debug output for weird MIDI events
-#define MT32EMU_MONITOR_MIDI 0
-
-// 0: No debug output for note on/off
-// 1: Basic debug output for note on/off
-// 2: Comprehensive debug output for note on/off
-#define MT32EMU_MONITOR_INSTRUMENTS 0
-
-// 0: No debug output for partial allocations
-// 1: Show partial stats when an allocation fails
-// 2: Show partial stats with every new poly
-// 3: Show individual partial allocations/deactivations
-#define MT32EMU_MONITOR_PARTIALS 0
-
-// 0: No debug output for sysex
-// 1: Basic debug output for sysex
-#define MT32EMU_MONITOR_SYSEX 0
-
-// 0: No debug output for sysex writes to the timbre areas
-// 1: Debug output with the name and location of newly-written timbres
-// 2: Complete dump of timbre parameters for newly-written timbres
-#define MT32EMU_MONITOR_TIMBRES 0
-
-// 0: No TVA/TVF-related debug output.
-// 1: Shows changes to TVA/TVF target, increment and phase.
-#define MT32EMU_MONITOR_TVA 0
-#define MT32EMU_MONITOR_TVF 0
-
// Configuration
-// If non-zero, deletes reverb buffers that are not in use to save memory.
-// If zero, keeps reverb buffers for all modes around all the time to avoid allocating/freeing in the critical path.
-#define MT32EMU_REDUCE_REVERB_MEMORY 1
-
-// 0: Maximum speed at the cost of a bit lower emulation accuracy.
-// 1: Maximum achievable emulation accuracy.
-#define MT32EMU_BOSS_REVERB_PRECISE_MODE 0
-
// 0: Use 16-bit signed samples and refined wave generator based on logarithmic fixed-point computations and LUTs. Maximum emulation accuracy and speed.
// 1: Use float samples in the wave generator and renderer. Maximum output quality and minimum noise.
#define MT32EMU_USE_FLOAT_SAMPLES 0
namespace MT32Emu
{
+// Sample rate to use in mixing. With the progress of development, we've found way too many thing dependent.
+// In order to achieve further advance in emulation accuracy, sample rate made fixed throughout the emulator,
+// except the emulation of analogue path.
+// The output from the synth is supposed to be resampled externally in order to convert to the desired sample rate.
+const unsigned int SAMPLE_RATE = 32000;
+
// The default value for the maximum number of partials playing simultaneously.
const unsigned int DEFAULT_MAX_PARTIALS = 32;
@@ -97,17 +54,7 @@ const unsigned int MAX_SAMPLES_PER_RUN = 4096;
const unsigned int DEFAULT_MIDI_EVENT_QUEUE_SIZE = 1024;
}
-#include "Structures.h"
-#include "common/file.h"
-#include "Tables.h"
-#include "Poly.h"
-#include "LA32Ramp.h"
-#include "LA32WaveGenerator.h"
-#include "TVA.h"
-#include "TVP.h"
-#include "TVF.h"
-#include "Partial.h"
-#include "Part.h"
+#include "Types.h"
#include "ROMInfo.h"
#include "Synth.h"
diff --git a/audio/timestamp.cpp b/audio/timestamp.cpp
index 1ce971631c..63752812e1 100644
--- a/audio/timestamp.cpp
+++ b/audio/timestamp.cpp
@@ -39,12 +39,10 @@ Timestamp::Timestamp(uint ms, uint fr) {
Timestamp::Timestamp(uint s, uint frames, uint fr) {
assert(fr > 0);
- _secs = s;
+ _secs = s + (frames / fr);
_framerateFactor = 1000 / Common::gcd<uint>(1000, fr);
_framerate = fr * _framerateFactor;
- _numFrames = frames * _framerateFactor;
-
- normalize();
+ _numFrames = (frames % fr) * _framerateFactor;
}
Timestamp Timestamp::convertToFramerate(uint newFramerate) const {
diff --git a/backends/events/dinguxsdl/dinguxsdl-events.cpp b/backends/events/dinguxsdl/dinguxsdl-events.cpp
index 6f9f2a7748..cc15f2666c 100644
--- a/backends/events/dinguxsdl/dinguxsdl-events.cpp
+++ b/backends/events/dinguxsdl/dinguxsdl-events.cpp
@@ -26,18 +26,48 @@
#include "backends/events/dinguxsdl/dinguxsdl-events.h"
+#ifndef GCW0
#define PAD_UP SDLK_UP
#define PAD_DOWN SDLK_DOWN
#define PAD_LEFT SDLK_LEFT
#define PAD_RIGHT SDLK_RIGHT
#define BUT_A SDLK_LCTRL
#define BUT_B SDLK_LALT
-#define BUT_X SDLK_SPACE
-#define BUT_Y SDLK_LSHIFT
+#define BUT_X SDLK_SPACE // BUT_Y in GCW0
+#define BUT_Y SDLK_LSHIFT // BUT_X in GCW0
#define BUT_SELECT SDLK_ESCAPE
#define BUT_START SDLK_RETURN
#define TRIG_L SDLK_TAB
#define TRIG_R SDLK_BACKSPACE
+#else // GCW0
+
+/******
+ * GCW0 keymap
+ * Dingoo button
+ * A -> Left Button BUT_Y
+ * B -> right button BUT_B
+ * X -> ' ' BUT_A '0'
+ * Y -> '.' BUT_X
+ * Select -> ESC TRIG_R
+ * Start -> F5 TRIG_L
+ * L -> Shift BUT_START
+ * R -> VK BUT_SELECT
+ */
+
+#define PAD_UP SDLK_UP
+#define PAD_DOWN SDLK_DOWN
+#define PAD_LEFT SDLK_LEFT
+#define PAD_RIGHT SDLK_RIGHT
+#define BUT_A SDLK_LSHIFT
+#define BUT_B SDLK_LALT
+#define BUT_X SDLK_SPACE
+#define BUT_Y SDLK_LCTRL
+#define BUT_SELECT SDLK_BACKSPACE
+#define BUT_START SDLK_TAB
+#define TRIG_L SDLK_RETURN
+#define TRIG_R SDLK_ESCAPE
+
+#endif
bool DINGUXSdlEventSource::remapKey(SDL_Event &ev, Common::Event &event) {
if (ev.key.keysym.sym == PAD_UP) {
diff --git a/backends/fs/amigaos4/amigaos4-fs.cpp b/backends/fs/amigaos4/amigaos4-fs.cpp
index 5a66cdaa2f..7bebdf8ce6 100644
--- a/backends/fs/amigaos4/amigaos4-fs.cpp
+++ b/backends/fs/amigaos4/amigaos4-fs.cpp
@@ -62,7 +62,7 @@ AmigaOSFilesystemNode::AmigaOSFilesystemNode() {
_bIsDirectory = true;
_sPath = "";
_pFileLock = 0;
- _nProt = 0; // protection is ignored for the root volume
+ _nProt = 0; // Protection is ignored for the root volume
LEAVE();
}
@@ -84,7 +84,7 @@ AmigaOSFilesystemNode::AmigaOSFilesystemNode(const Common::String &p) {
_bIsDirectory = false;
_bIsValid = false;
- // Check whether the node exists and if it is a directory
+ // Check whether the node exists and if it's a directory
struct ExamineData * pExd = IDOS->ExamineObjectTags(EX_StringNameInput,_sPath.c_str(),TAG_END);
if (pExd) {
_nProt = pExd->Protection;
@@ -93,7 +93,7 @@ AmigaOSFilesystemNode::AmigaOSFilesystemNode(const Common::String &p) {
_pFileLock = IDOS->Lock((CONST_STRPTR)_sPath.c_str(), SHARED_LOCK);
_bIsValid = (_pFileLock != 0);
- // Add a trailing slash if it is needed
+ // Add a trailing slash if needed
const char c = _sPath.lastChar();
if (c != '/' && c != ':')
_sPath += '/';
@@ -134,7 +134,7 @@ AmigaOSFilesystemNode::AmigaOSFilesystemNode(BPTR pLock, const char *pDisplayNam
delete[] n;
}
- _bIsValid = false;
+ _bIsValid = false;
_bIsDirectory = false;
struct ExamineData * pExd = IDOS->ExamineObjectTags(EX_FileLockInput,pLock,TAG_END);
@@ -188,10 +188,10 @@ bool AmigaOSFilesystemNode::exists() const {
bool nodeExists = false;
- // previously we were trying to examine the node in order
+ // Previously we were trying to examine the node in order
// to determine if the node exists or not.
// I don't see the point : once you have been granted a
- // lock on it then it means it exists...
+ // lock on it, it means it exists...
//
// ============================= Old code
// BPTR pLock = IDOS->Lock((STRPTR)_sPath.c_str(), SHARED_LOCK);
@@ -237,8 +237,8 @@ bool AmigaOSFilesystemNode::getChildren(AbstractFSList &myList, ListMode mode, b
ENTER();
bool ret = false;
- //TODO: honor the hidden flag
- // There is nothing like a hidden flag under AmigaOS...
+ // TODO: Honor the hidden flag
+ // There is no such thing as a hidden flag in AmigaOS...
if (!_bIsValid) {
debug(6, "Invalid node");
@@ -252,7 +252,7 @@ bool AmigaOSFilesystemNode::getChildren(AbstractFSList &myList, ListMode mode, b
return false; // Empty list
}
- if (_pFileLock == 0) {
+ if (isRootNode()) {
debug(6, "Root node");
LEAVE();
myList = listVolumes();
@@ -264,7 +264,7 @@ bool AmigaOSFilesystemNode::getChildren(AbstractFSList &myList, ListMode mode, b
EX_DataFields, (EXF_NAME|EXF_LINK|EXF_TYPE),
TAG_END);
if (context) {
- struct ExamineData * pExd = NULL; // NB: no need to free value after usage, all is dealt by the DirContext release
+ struct ExamineData * pExd = NULL; // NB: No need to free the value after usage, everything will be dealt with by the DirContext release
AmigaOSFilesystemNode *entry ;
while ( (pExd = IDOS->ExamineDir(context)) ) {
@@ -307,21 +307,33 @@ bool AmigaOSFilesystemNode::getChildren(AbstractFSList &myList, ListMode mode, b
AbstractFSNode *AmigaOSFilesystemNode::getParent() const {
ENTER();
- if (_pFileLock == 0) {
+ if (isRootNode()) {
debug(6, "Root node");
LEAVE();
return new AmigaOSFilesystemNode(*this);
}
+ BPTR pLock = _pFileLock;
+
+ if (!_bIsDirectory) {
+ assert(!pLock);
+ pLock = IDOS->Lock((CONST_STRPTR)_sPath.c_str(), SHARED_LOCK);
+ assert(pLock);
+ }
+
AmigaOSFilesystemNode *node;
- BPTR parentDir = IDOS->ParentDir( _pFileLock );
+ BPTR parentDir = IDOS->ParentDir( pLock );
if (parentDir) {
node = new AmigaOSFilesystemNode(parentDir);
IDOS->UnLock(parentDir);
} else
node = new AmigaOSFilesystemNode();
+ if (!_bIsDirectory) {
+ IDOS->UnLock(pLock);
+ }
+
LEAVE();
return node;
@@ -332,9 +344,9 @@ bool AmigaOSFilesystemNode::isReadable() const {
return false;
// Regular RWED protection flags are low-active or inverted, thus the negation.
- // moreover pseudo root filesystem (null _pFileLock) is readable whatever the
- // protection says
- bool readable = !(_nProt & EXDF_OTR_READ) || _pFileLock == 0;
+ // Moreover, a pseudo root filesystem is readable whatever the
+ // protection says.
+ bool readable = !(_nProt & EXDF_OTR_READ) || isRootNode();
return readable;
}
@@ -344,9 +356,9 @@ bool AmigaOSFilesystemNode::isWritable() const {
return false;
// Regular RWED protection flags are low-active or inverted, thus the negation.
- // moreover pseudo root filesystem (null _pFileLock) is never writable whatever
- // the protection says (because of the pseudo nature)
- bool writable = !(_nProt & EXDF_OTR_WRITE) && _pFileLock !=0;
+ // Moreover, a pseudo root filesystem is never writable whatever
+ // the protection says (Because of it's pseudo nature).
+ bool writable = !(_nProt & EXDF_OTR_WRITE) && !isRootNode();
return writable;
}
@@ -371,12 +383,13 @@ AbstractFSList AmigaOSFilesystemNode::listVolumes() const {
if (dosList->dol_Type == DLT_VOLUME &&
dosList->dol_Name) {
- // Original was
- // dosList->dol_Name &&
- // dosList->dol_Task) {
+ // The original line was
+ //if (dosList->dol_Type == DLT_VOLUME &&
+ //dosList->dol_Name &&
+ //dosList->dol_Task) {
// which errored using SDK 53.24 with a 'struct dosList' has no member called 'dol_Task'
// I removed dol_Task because it's not used anywhere else
- // and it neither brought up further errors nor crashes or regressions.
+ // and it neither brought up further errors nor crashes or regressions
// Copy name to buffer
IDOS->CopyStringBSTRToC(dosList->dol_Name, buffer, MAXPATHLEN);
@@ -410,7 +423,7 @@ AbstractFSList AmigaOSFilesystemNode::listVolumes() const {
delete[] volName;
}
- dosList = IDOS->NextDosEntry(dosList, LDF_VOLUMES);
+ dosList = IDOS->NextDosEntry(dosList, LDF_VOLUMES);
}
IDOS->UnLockDosList(kLockFlags);
diff --git a/backends/fs/amigaos4/amigaos4-fs.h b/backends/fs/amigaos4/amigaos4-fs.h
index bbe88b2716..408354888e 100644
--- a/backends/fs/amigaos4/amigaos4-fs.h
+++ b/backends/fs/amigaos4/amigaos4-fs.h
@@ -62,6 +62,11 @@ protected:
*/
virtual AbstractFSList listVolumes() const;
+ /**
+ * True if this is the pseudo root filesystem.
+ */
+ bool isRootNode() const { return _bIsValid && _bIsDirectory && _pFileLock == 0; }
+
public:
/**
* Creates an AmigaOSFilesystemNode with the root node as path.
@@ -76,19 +81,19 @@ public:
AmigaOSFilesystemNode(const Common::String &p);
/**
- * Creates an AmigaOSFilesystemNode given its lock and display name
+ * Creates an AmigaOSFilesystemNode given its lock and display name.
*
* @param pLock BPTR to the lock.
* @param pDisplayName name to be used for display, in case not supplied the FilePart() of the filename will be used.
*
- * @note This shouldn't even be public as it's only internally, at best it should have been protected if not private
+ * @note This shouldn't even be public as it's only internally, at best it should have been protected if not private.
*/
AmigaOSFilesystemNode(BPTR pLock, const char *pDisplayName = 0);
/**
* Copy constructor.
*
- * @note Needed because it duplicates the file lock
+ * @note Needed because it duplicates the file lock.
*/
AmigaOSFilesystemNode(const AmigaOSFilesystemNode &node);
diff --git a/backends/graphics/opengl/opengl-graphics.cpp b/backends/graphics/opengl/opengl-graphics.cpp
index cbd06e9161..c455c4ce2e 100644
--- a/backends/graphics/opengl/opengl-graphics.cpp
+++ b/backends/graphics/opengl/opengl-graphics.cpp
@@ -489,7 +489,7 @@ void OpenGLGraphicsManager::warpMouse(int x, int y) {
if (!_overlay) {
return;
}
-
+
// It might be confusing that we actually have to handle something
// here when the overlay is visible. This is because for very small
// resolutions we have a minimal overlay size and have to adjust
@@ -1044,8 +1044,8 @@ void OpenGLGraphicsManager::recalculateDisplayArea() {
}
// We center the screen in the middle for now.
- _displayX = (_outputScreenWidth - _displayWidth ) / 2;
- _displayY = (_outputScreenHeight - _displayHeight) / 2;
+ _displayX = (_outputScreenWidth - _displayWidth ) / 2;
+ _displayY = (_outputScreenHeight - _displayHeight) / 2;
}
void OpenGLGraphicsManager::updateCursorPalette() {
diff --git a/backends/graphics/openglsdl/openglsdl-graphics.cpp b/backends/graphics/openglsdl/openglsdl-graphics.cpp
index c998f3d1f1..b028cd5b1a 100644
--- a/backends/graphics/openglsdl/openglsdl-graphics.cpp
+++ b/backends/graphics/openglsdl/openglsdl-graphics.cpp
@@ -282,7 +282,7 @@ bool OpenGLSdlGraphicsManager::setupMode(uint width, uint height) {
if (!_fullscreenVideoModes.empty()) {
VideoModeArray::const_iterator i = _fullscreenVideoModes.end();
--i;
-
+
_desiredFullscreenWidth = i->width;
_desiredFullscreenHeight = i->height;
} else {
diff --git a/backends/keymapper/action.h b/backends/keymapper/action.h
index ed4bb86ce6..17b1153c77 100644
--- a/backends/keymapper/action.h
+++ b/backends/keymapper/action.h
@@ -37,7 +37,7 @@ namespace Common {
struct HardwareInput;
class Keymap;
-#define ACTION_ID_SIZE (4)
+#define ACTION_ID_SIZE (5)
struct KeyActionEntry {
const KeyState ks;
diff --git a/backends/platform/android/asset-archive.cpp b/backends/platform/android/asset-archive.cpp
index 52c2c084bd..6680081c16 100644
--- a/backends/platform/android/asset-archive.cpp
+++ b/backends/platform/android/asset-archive.cpp
@@ -295,7 +295,6 @@ AssetFdReadStream::AssetFdReadStream(JNIEnv *env, jobject assetfd) :
jclass cls = env->GetObjectClass(_assetfd);
MID_close = env->GetMethodID(cls, "close", "()V");
assert(MID_close);
- env->DeleteLocalRef(cls);
jmethodID MID_getStartOffset =
env->GetMethodID(cls, "getStartOffset", "()J");
@@ -321,6 +320,8 @@ AssetFdReadStream::AssetFdReadStream(JNIEnv *env, jobject assetfd) :
_fd = env->GetIntField(javafd, FID_descriptor);
env->DeleteLocalRef(javafd);
+
+ env->DeleteLocalRef(cls);
}
AssetFdReadStream::~AssetFdReadStream() {
diff --git a/backends/platform/dingux/dingux.mk b/backends/platform/dingux/dingux.mk
index 48a9347143..1333e89ff8 100644
--- a/backends/platform/dingux/dingux.mk
+++ b/backends/platform/dingux/dingux.mk
@@ -1,6 +1,7 @@
DINGUX_EXE_STRIPPED := scummvm_stripped$(EXEEXT)
bundle_name = dingux-dist/scummvm
+gcw0_bundle = gcw0-opk
all: $(DINGUX_EXE_STRIPPED)
@@ -30,3 +31,37 @@ endif
$(CP) $(srcdir)/backends/platform/dingux/scummvm.gpe $(bundle_name)/
$(CP) $(srcdir)/backends/platform/dingux/README.DINGUX $(bundle_name)/
$(CP) $(srcdir)/backends/platform/dingux/scummvm.png $(bundle_name)/
+
+# Special target for generationg GCW-Zero OPK bundle
+$(gcw0_bundle): all
+ $(MKDIR) $(gcw0_bundle)
+ $(CP) $(DIST_FILES_DOCS) $(gcw0_bundle)/
+ $(MKDIR) $(gcw0_bundle)/themes
+ $(CP) $(DIST_FILES_THEMES) $(gcw0_bundle)/themes/
+ifdef DIST_FILES_ENGINEDATA
+ $(MKDIR) $(gcw0_bundle)/engine-data
+ $(CP) $(DIST_FILES_ENGINEDATA) $(gcw0_bundle)/engine-data/
+endif
+ifdef DYNAMIC_MODULES
+ $(MKDIR) $(gcw0_bundle)/plugins
+ $(CP) $(PLUGINS) $(gcw0_bundle)/plugins/
+endif
+ $(CP) $(EXECUTABLE) $(gcw0_bundle)/scummvm
+
+ $(CP) $(srcdir)/backends/vkeybd/packs/vkeybd_default.zip $(gcw0_bundle)/
+ $(CP) $(srcdir)/backends/vkeybd/packs/vkeybd_small.zip $(gcw0_bundle)/
+
+ $(CP) $(srcdir)/dists/gcw0/scummvm.png $(gcw0_bundle)/
+ $(CP) $(srcdir)/dists/gcw0/default.gcw0.desktop $(gcw0_bundle)/
+ $(CP) $(srcdir)/dists/gcw0/scummvmrc $(gcw0_bundle)/
+ $(CP) $(srcdir)/dists/gcw0/scummvm.sh $(gcw0_bundle)/
+
+gcw0-opk-unstripped: $(gcw0_bundle)
+ $(CP) $(PLUGINS) $(gcw0_bundle)/plugins/
+ $(CP) $(EXECUTABLE) $(gcw0_bundle)/scummvm
+ ./dists/gcw0/opk_make.sh -d $(gcw0_bundle) -o scummvm
+
+gcw-opk: $(gcw0_bundle)
+ $(STRIP) $(gcw0_bundle)/plugins/*
+ $(STRIP) $(gcw0_bundle)/scummvm
+ ./dists/gcw0/opk_make.sh -d $(gcw0_bundle) -o scummvm
diff --git a/backends/platform/sdl/sdl.cpp b/backends/platform/sdl/sdl.cpp
index 41610dc0c7..4dc5929dab 100644
--- a/backends/platform/sdl/sdl.cpp
+++ b/backends/platform/sdl/sdl.cpp
@@ -390,7 +390,7 @@ Common::String OSystem_SDL::getSystemLanguage() const {
#else // WIN32
// Activating current locale settings
const Common::String locale = setlocale(LC_ALL, "");
-
+
// Restore default C locale to prevent issues with
// portability of sscanf(), atof(), etc.
// See bug #3615148
diff --git a/backends/platform/wii/osystem_events.cpp b/backends/platform/wii/osystem_events.cpp
index 0563639de3..13f5d1fbe0 100644
--- a/backends/platform/wii/osystem_events.cpp
+++ b/backends/platform/wii/osystem_events.cpp
@@ -70,73 +70,73 @@
#endif
#ifdef USE_WII_KBD
-static int keymap[][2] = {
- { KS_Return, Common::KEYCODE_RETURN },
- { KS_Up, Common::KEYCODE_UP },
- { KS_Down, Common::KEYCODE_DOWN },
- { KS_Left, Common::KEYCODE_LEFT },
- { KS_Right, Common::KEYCODE_RIGHT },
- { KS_Shift_L, Common::KEYCODE_LSHIFT },
- { KS_Shift_R, Common::KEYCODE_RSHIFT },
- { KS_Control_L, Common::KEYCODE_LCTRL },
- { KS_Control_R, Common::KEYCODE_RCTRL },
- { KS_Alt_L, Common::KEYCODE_LALT },
- { KS_Alt_R, Common::KEYCODE_RALT },
- { KS_Meta_L, Common::KEYCODE_LMETA },
- { KS_Meta_R, Common::KEYCODE_RMETA },
- { KS_KP_0, Common::KEYCODE_KP0 },
- { KS_KP_1, Common::KEYCODE_KP1 },
- { KS_KP_2, Common::KEYCODE_KP2 },
- { KS_KP_3, Common::KEYCODE_KP3 },
- { KS_KP_4, Common::KEYCODE_KP4 },
- { KS_KP_5, Common::KEYCODE_KP5 },
- { KS_KP_6, Common::KEYCODE_KP6 },
- { KS_KP_7, Common::KEYCODE_KP7 },
- { KS_KP_8, Common::KEYCODE_KP8 },
- { KS_KP_9, Common::KEYCODE_KP9 },
- { KS_Home, Common::KEYCODE_HOME },
- { KS_Insert, Common::KEYCODE_INSERT },
- { KS_End, Common::KEYCODE_END },
- { KS_Prior, Common::KEYCODE_PAGEUP },
- { KS_Next, Common::KEYCODE_PAGEDOWN },
- { KS_f1, Common::KEYCODE_F1 },
- { KS_f2, Common::KEYCODE_F2 },
- { KS_f3, Common::KEYCODE_F3 },
- { KS_f4, Common::KEYCODE_F4 },
- { KS_f5, Common::KEYCODE_F5 },
- { KS_f6, Common::KEYCODE_F6 },
- { KS_f7, Common::KEYCODE_F7 },
- { KS_f8, Common::KEYCODE_F8 },
- { KS_f9, Common::KEYCODE_F9 },
- { KS_f10, Common::KEYCODE_F10 },
- { KS_f11, Common::KEYCODE_F11 },
- { KS_f12, Common::KEYCODE_F12 },
- { KS_f13, Common::KEYCODE_F13 },
- { KS_f14, Common::KEYCODE_F14 },
- { KS_f15, Common::KEYCODE_F15 },
- { KS_F1, Common::KEYCODE_F1 },
- { KS_F2, Common::KEYCODE_F2 },
- { KS_F3, Common::KEYCODE_F3 },
- { KS_F4, Common::KEYCODE_F4 },
- { KS_F5, Common::KEYCODE_F5 },
- { KS_F6, Common::KEYCODE_F6 },
- { KS_F7, Common::KEYCODE_F7 },
- { KS_F8, Common::KEYCODE_F8 },
- { KS_F9, Common::KEYCODE_F9 },
- { KS_F10, Common::KEYCODE_F10 },
- { KS_F11, Common::KEYCODE_F11 },
- { KS_F12, Common::KEYCODE_F12 },
- { KS_F13, Common::KEYCODE_F13 },
- { KS_F14, Common::KEYCODE_F14 },
- { KS_F15, Common::KEYCODE_F15 },
- { KS_KP_Separator, Common::KEYCODE_KP_PERIOD },
- { KS_KP_Subtract, Common::KEYCODE_KP_DIVIDE },
- { KS_KP_Multiply, Common::KEYCODE_KP_MULTIPLY },
- { KS_KP_Add, Common::KEYCODE_KP_PLUS },
- { KS_KP_Subtract, Common::KEYCODE_KP_MINUS },
- { KS_KP_Equal, Common::KEYCODE_KP_EQUALS },
- { KS_KP_Enter, Common::KEYCODE_KP_ENTER },
- { 0, 0 }
+static int keymap[][3] = {
+ { KS_Return, Common::KEYCODE_RETURN, Common::ASCII_RETURN },
+ { KS_Up, Common::KEYCODE_UP, 0 },
+ { KS_Down, Common::KEYCODE_DOWN, 0 },
+ { KS_Left, Common::KEYCODE_LEFT, 0 },
+ { KS_Right, Common::KEYCODE_RIGHT, 0 },
+ { KS_Shift_L, Common::KEYCODE_LSHIFT, 0 },
+ { KS_Shift_R, Common::KEYCODE_RSHIFT, 0 },
+ { KS_Control_L, Common::KEYCODE_LCTRL, 0 },
+ { KS_Control_R, Common::KEYCODE_RCTRL, 0 },
+ { KS_Alt_L, Common::KEYCODE_LALT, 0 },
+ { KS_Alt_R, Common::KEYCODE_RALT, 0 },
+ { KS_Meta_L, Common::KEYCODE_LMETA, 0 },
+ { KS_Meta_R, Common::KEYCODE_RMETA, 0 },
+ { KS_KP_0, Common::KEYCODE_KP0, '0' },
+ { KS_KP_1, Common::KEYCODE_KP1, '1' },
+ { KS_KP_2, Common::KEYCODE_KP2, '2' },
+ { KS_KP_3, Common::KEYCODE_KP3, '3' },
+ { KS_KP_4, Common::KEYCODE_KP4, '4' },
+ { KS_KP_5, Common::KEYCODE_KP5, '5' },
+ { KS_KP_6, Common::KEYCODE_KP6, '6' },
+ { KS_KP_7, Common::KEYCODE_KP7, '7' },
+ { KS_KP_8, Common::KEYCODE_KP8, '8' },
+ { KS_KP_9, Common::KEYCODE_KP9, '9' },
+ { KS_Home, Common::KEYCODE_HOME, 0 },
+ { KS_Insert, Common::KEYCODE_INSERT, 0 },
+ { KS_End, Common::KEYCODE_END, 0 },
+ { KS_Prior, Common::KEYCODE_PAGEUP, 0 },
+ { KS_Next, Common::KEYCODE_PAGEDOWN, 0 },
+ { KS_f1, Common::KEYCODE_F1, Common::ASCII_F1 },
+ { KS_f2, Common::KEYCODE_F2, Common::ASCII_F2 },
+ { KS_f3, Common::KEYCODE_F3, Common::ASCII_F3 },
+ { KS_f4, Common::KEYCODE_F4, Common::ASCII_F4 },
+ { KS_f5, Common::KEYCODE_F5, Common::ASCII_F5 },
+ { KS_f6, Common::KEYCODE_F6, Common::ASCII_F6 },
+ { KS_f7, Common::KEYCODE_F7, Common::ASCII_F7 },
+ { KS_f8, Common::KEYCODE_F8, Common::ASCII_F8 },
+ { KS_f9, Common::KEYCODE_F9, Common::ASCII_F9 },
+ { KS_f10, Common::KEYCODE_F10, Common::ASCII_F10 },
+ { KS_f11, Common::KEYCODE_F11, Common::ASCII_F11 },
+ { KS_f12, Common::KEYCODE_F12, Common::ASCII_F12 },
+ { KS_f13, Common::KEYCODE_F13, 0 },
+ { KS_f14, Common::KEYCODE_F14, 0 },
+ { KS_f15, Common::KEYCODE_F15, 0 },
+ { KS_F1, Common::KEYCODE_F1, Common::ASCII_F1 },
+ { KS_F2, Common::KEYCODE_F2, Common::ASCII_F2 },
+ { KS_F3, Common::KEYCODE_F3, Common::ASCII_F3 },
+ { KS_F4, Common::KEYCODE_F4, Common::ASCII_F4 },
+ { KS_F5, Common::KEYCODE_F5, Common::ASCII_F5 },
+ { KS_F6, Common::KEYCODE_F6, Common::ASCII_F6 },
+ { KS_F7, Common::KEYCODE_F7, Common::ASCII_F7 },
+ { KS_F8, Common::KEYCODE_F8, Common::ASCII_F8 },
+ { KS_F9, Common::KEYCODE_F9, Common::ASCII_F9 },
+ { KS_F10, Common::KEYCODE_F10, Common::ASCII_F10 },
+ { KS_F11, Common::KEYCODE_F11, Common::ASCII_F11 },
+ { KS_F12, Common::KEYCODE_F12, Common::ASCII_F12 },
+ { KS_F13, Common::KEYCODE_F13, 0 },
+ { KS_F14, Common::KEYCODE_F14, 0 },
+ { KS_F15, Common::KEYCODE_F15, 0 },
+ { KS_KP_Separator, Common::KEYCODE_KP_PERIOD, '.' },
+ { KS_KP_Divide, Common::KEYCODE_KP_DIVIDE, '/' },
+ { KS_KP_Multiply, Common::KEYCODE_KP_MULTIPLY, '*' },
+ { KS_KP_Add, Common::KEYCODE_KP_PLUS, '+' },
+ { KS_KP_Subtract, Common::KEYCODE_KP_MINUS, '-' },
+ { KS_KP_Equal, Common::KEYCODE_KP_EQUALS, '=' },
+ { KS_KP_Enter, Common::KEYCODE_KP_ENTER, Common::ASCII_RETURN },
+ { 0, 0, 0 }
};
#endif
@@ -262,7 +262,7 @@ bool OSystem_Wii::pollKeyboard(Common::Event &event) {
while (keymap[i][0] != 0) {
if (keymap[i][0] == kbdEvent.symbol) {
event.kbd.keycode = static_cast<Common::KeyCode>(keymap[i][1]);
- event.kbd.ascii = 0;
+ event.kbd.ascii = keymap[i][2];
return true;
}
diff --git a/backends/taskbar/unity/unity-taskbar.cpp b/backends/taskbar/unity/unity-taskbar.cpp
index 1b82e58c8a..532d9656c3 100644
--- a/backends/taskbar/unity/unity-taskbar.cpp
+++ b/backends/taskbar/unity/unity-taskbar.cpp
@@ -26,6 +26,8 @@
#if defined(POSIX) && defined(USE_TASKBAR) && defined(USE_UNITY)
+#define GLIB_DISABLE_DEPRECATION_WARNINGS
+
#include "backends/taskbar/unity/unity-taskbar.h"
#include "common/textconsole.h"
@@ -33,7 +35,12 @@
#include <unity.h>
UnityTaskbarManager::UnityTaskbarManager() {
- g_type_init();
+ /*
+ * Deprecated in Glib >= 2.36.0
+ */
+ if (!glib_check_version(2, 36, 0)) {
+ g_type_init();
+ }
_loop = g_main_loop_new(NULL, FALSE);
diff --git a/base/main.cpp b/base/main.cpp
index b5de7d94d2..0f5ebc7845 100644
--- a/base/main.cpp
+++ b/base/main.cpp
@@ -523,22 +523,42 @@ extern "C" int scummvm_main(int argc, const char * const argv[]) {
}
#endif
+ // At this point, we usually return to the launcher. However, the
+ // game may have requested that one or more other games be "chained"
+ // to the current one, with optional save slots to start the games
+ // at. At the time of writing, this is used for the Maniac Mansion
+ // easter egg in Day of the Tentacle.
+
+ Common::String chainedGame;
+ int saveSlot = -1;
+
+ ChainedGamesMan.pop(chainedGame, saveSlot);
+
// Discard any command line options. It's unlikely that the user
// wanted to apply them to *all* games ever launched.
ConfMan.getDomain(Common::ConfigManager::kTransientDomain)->clear();
- // Clear the active config domain
- ConfMan.setActiveDomain("");
+ if (!chainedGame.empty()) {
+ if (saveSlot != -1) {
+ ConfMan.setInt("save_slot", saveSlot, Common::ConfigManager::kTransientDomain);
+ }
+ // Start the chained game
+ ConfMan.setActiveDomain(chainedGame);
+ } else {
+ // Clear the active config domain
+ ConfMan.setActiveDomain("");
+ }
PluginManager::instance().loadAllPlugins(); // only for cached manager
-
} else {
GUI::displayErrorDialog(_("Could not find any engine capable of running the selected game"));
}
// reset the graphics to default
setupGraphics(system);
- launcherDialog();
+ if (0 == ConfMan.getActiveDomain()) {
+ launcherDialog();
+ }
}
PluginManager::instance().unloadAllPlugins();
PluginManager::destroy();
diff --git a/base/version.cpp b/base/version.cpp
index ef02ff9d21..fcb2740de9 100644
--- a/base/version.cpp
+++ b/base/version.cpp
@@ -146,4 +146,12 @@ const char *gScummVMFeatures = ""
#ifdef USE_PNG
"PNG "
#endif
+
+#ifdef ENABLE_KEYMAPPER
+ "keymapper "
+#endif
+
+#ifdef ENABLE_VKEYBD
+ "virtual keyboard "
+#endif
;
diff --git a/common/EventMapper.cpp b/common/EventMapper.cpp
index b92116cbe7..cf65946d50 100644
--- a/common/EventMapper.cpp
+++ b/common/EventMapper.cpp
@@ -45,7 +45,7 @@ List<Event> DefaultEventMapper::mapEvent(const Event &ev, EventSource *source) {
if (ev.type == EVENT_MBUTTONUP) {
if ((g_system->getMillis() - vkeybdThen) >= vkeybdTime) {
mappedEvent.type = EVENT_VIRTUAL_KEYBOARD;
-
+
// Avoid blocking event from engine.
addDelayedEvent(100, ev);
}
@@ -59,7 +59,7 @@ List<Event> DefaultEventMapper::mapEvent(const Event &ev, EventSource *source) {
#ifdef ENABLE_VKEYBD
else if (ev.kbd.hasFlags(KBD_CTRL) && ev.kbd.keycode == KEYCODE_F7) {
mappedEvent.type = EVENT_VIRTUAL_KEYBOARD;
-
+
// Avoid blocking CTRL-F7 events from engine.
addDelayedEvent(100, ev);
}
@@ -67,7 +67,7 @@ List<Event> DefaultEventMapper::mapEvent(const Event &ev, EventSource *source) {
#ifdef ENABLE_KEYMAPPER
else if (ev.kbd.hasFlags(KBD_CTRL) && ev.kbd.keycode == KEYCODE_F8) {
mappedEvent.type = EVENT_KEYMAPPER_REMAP;
-
+
// Avoid blocking CTRL-F8 events from engine.
addDelayedEvent(100, ev);
}
diff --git a/common/c++11-compat.h b/common/c++11-compat.h
index 14e0642821..a56b79514c 100644
--- a/common/c++11-compat.h
+++ b/common/c++11-compat.h
@@ -32,13 +32,19 @@
// though.
//
#if !defined(nullptr) // XCode 5.0.1 has __cplusplus=199711 but defines this
+// MSVC 2010 and newer fully support nullptr: http://msdn.microsoft.com/en-us/library/hh567368.aspx
+#if !defined(_MSC_VER) || _MSC_VER < 1600
#define nullptr 0
#endif
+#endif
//
// Replacement for the override keyword. This allows compilation of code
// which uses it, but does not feature any semantic.
//
+// MSVC 2012 and newer fully support override: http://msdn.microsoft.com/en-us/library/hh567368.aspx
+#if !defined(_MSC_VER) || _MSC_VER < 1700
#define override
+#endif
#endif
diff --git a/common/scummsys.h b/common/scummsys.h
index c30bc4a52a..0c4687e03e 100644
--- a/common/scummsys.h
+++ b/common/scummsys.h
@@ -148,7 +148,7 @@
#endif
#endif
-// The following math constants are usually defined by the system math.h header, but
+// The following math constants are usually defined by the system math.h header, but
// they are not part of the ANSI C++ standards and so can NOT be relied upon to be
// present i.e. when -std=c++11 is passed to GCC, enabling strict ANSI compliance.
// As we rely on these being present, we define them if they are not set.
diff --git a/common/unzip.cpp b/common/unzip.cpp
index 716c8c2d5e..1f4e601989 100644
--- a/common/unzip.cpp
+++ b/common/unzip.cpp
@@ -334,8 +334,10 @@ int unzGetLocalExtrafield(unzFile file, voidp buf, unsigned len);
#define SIZEZIPLOCALHEADER (0x1e)
+#if 0
const char unz_copyright[] =
" unzip 0.15 Copyright 1998 Gilles Vollant ";
+#endif
/* unz_file_info_interntal contain internal info about a file in zipfile*/
typedef struct {
diff --git a/common/xmlparser.cpp b/common/xmlparser.cpp
index c80d5e15be..67a3d36cec 100644
--- a/common/xmlparser.cpp
+++ b/common/xmlparser.cpp
@@ -69,7 +69,7 @@ bool XMLParser::loadBuffer(const byte *buffer, uint32 size, DisposeAfterUse::Fla
bool XMLParser::loadStream(SeekableReadStream *stream) {
_stream = stream;
_fileName = "File Stream";
- return true;
+ return _stream != nullptr;
}
void XMLParser::close() {
diff --git a/config.guess b/config.guess
index 43f0cdbcfd..6c32c8645c 100755
--- a/config.guess
+++ b/config.guess
@@ -1,14 +1,12 @@
#! /bin/sh
# Attempt to guess a canonical system name.
-# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
-# 2011 Free Software Foundation, Inc.
+# Copyright 1992-2014 Free Software Foundation, Inc.
-timestamp='2011-10-01'
+timestamp='2014-11-04'
# This file is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
+# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
@@ -17,26 +15,22 @@ timestamp='2011-10-01'
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
-# 02110-1301, USA.
+# along with this program; if not, see <http://www.gnu.org/licenses/>.
#
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
-# the same distribution terms that you use for the rest of that program.
-
-
-# Originally written by Per Bothner. Please send patches (context
-# diff format) to <config-patches@gnu.org> and include a ChangeLog
-# entry.
+# the same distribution terms that you use for the rest of that
+# program. This Exception is an additional permission under section 7
+# of the GNU General Public License, version 3 ("GPLv3").
#
-# This script attempts to guess a canonical system name similar to
-# config.sub. If it succeeds, it prints the system name on stdout, and
-# exits with 0. Otherwise, it exits with 1.
+# Originally written by Per Bothner; maintained since 2000 by Ben Elliston.
#
# You can get the latest version of this script from:
# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD
+#
+# Please send patches to <config-patches@gnu.org>.
+
me=`echo "$0" | sed -e 's,.*/,,'`
@@ -56,9 +50,7 @@ version="\
GNU config.guess ($timestamp)
Originally written by Per Bothner.
-Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free
-Software Foundation, Inc.
+Copyright 1992-2014 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
@@ -140,12 +132,33 @@ UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown
UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
+case "${UNAME_SYSTEM}" in
+Linux|GNU|GNU/*)
+ # If the system lacks a compiler, then just pick glibc.
+ # We could probably try harder.
+ LIBC=gnu
+
+ eval $set_cc_for_build
+ cat <<-EOF > $dummy.c
+ #include <features.h>
+ #if defined(__UCLIBC__)
+ LIBC=uclibc
+ #elif defined(__dietlibc__)
+ LIBC=dietlibc
+ #else
+ LIBC=gnu
+ #endif
+ EOF
+ eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC' | sed 's, ,,g'`
+ ;;
+esac
+
# Note: order is significant - the case branches are not exclusive.
case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
*:NetBSD:*:*)
# NetBSD (nbsd) targets should (where applicable) match one or
- # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*,
+ # more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*,
# *-*-netbsdecoff* and *-*-netbsd*. For targets that recently
# switched to ELF, *-*-netbsd* would select the old
# object file format. This provides both forward
@@ -202,6 +215,10 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used.
echo "${machine}-${os}${release}"
exit ;;
+ *:Bitrig:*:*)
+ UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'`
+ echo ${UNAME_MACHINE_ARCH}-unknown-bitrig${UNAME_RELEASE}
+ exit ;;
*:OpenBSD:*:*)
UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'`
echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE}
@@ -304,7 +321,7 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
echo arm-acorn-riscix${UNAME_RELEASE}
exit ;;
- arm:riscos:*:*|arm:RISCOS:*:*)
+ arm*:riscos:*:*|arm*:RISCOS:*:*)
echo arm-unknown-riscos
exit ;;
SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*)
@@ -562,8 +579,9 @@ EOF
else
IBM_ARCH=powerpc
fi
- if [ -x /usr/bin/oslevel ] ; then
- IBM_REV=`/usr/bin/oslevel`
+ if [ -x /usr/bin/lslpp ] ; then
+ IBM_REV=`/usr/bin/lslpp -Lqc bos.rte.libc |
+ awk -F: '{ print $3 }' | sed s/[0-9]*$/0/`
else
IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
fi
@@ -803,9 +821,15 @@ EOF
i*:CYGWIN*:*)
echo ${UNAME_MACHINE}-pc-cygwin
exit ;;
+ *:MINGW64*:*)
+ echo ${UNAME_MACHINE}-pc-mingw64
+ exit ;;
*:MINGW*:*)
echo ${UNAME_MACHINE}-pc-mingw32
exit ;;
+ *:MSYS*:*)
+ echo ${UNAME_MACHINE}-pc-msys
+ exit ;;
i*:windows32*:*)
# uname -m includes "-pc" on this system.
echo ${UNAME_MACHINE}-mingw32
@@ -851,15 +875,22 @@ EOF
exit ;;
*:GNU:*:*)
# the GNU system
- echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`
+ echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-${LIBC}`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`
exit ;;
*:GNU/*:*:*)
# other systems with GNU libc and userland
- echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu
+ echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-${LIBC}
exit ;;
i*86:Minix:*:*)
echo ${UNAME_MACHINE}-pc-minix
exit ;;
+ aarch64:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+ exit ;;
+ aarch64_be:Linux:*:*)
+ UNAME_MACHINE=aarch64_be
+ echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+ exit ;;
alpha:Linux:*:*)
case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in
EV5) UNAME_MACHINE=alphaev5 ;;
@@ -871,59 +902,54 @@ EOF
EV68*) UNAME_MACHINE=alphaev68 ;;
esac
objdump --private-headers /bin/sh | grep -q ld.so.1
- if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi
- echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC}
+ if test "$?" = 0 ; then LIBC="gnulibc1" ; fi
+ echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+ exit ;;
+ arc:Linux:*:* | arceb:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
exit ;;
arm*:Linux:*:*)
eval $set_cc_for_build
if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \
| grep -q __ARM_EABI__
then
- echo ${UNAME_MACHINE}-unknown-linux-gnu
+ echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
else
if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \
| grep -q __ARM_PCS_VFP
then
- echo ${UNAME_MACHINE}-unknown-linux-gnueabi
+ echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabi
else
- echo ${UNAME_MACHINE}-unknown-linux-gnueabihf
+ echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabihf
fi
fi
exit ;;
avr32*:Linux:*:*)
- echo ${UNAME_MACHINE}-unknown-linux-gnu
+ echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
exit ;;
cris:Linux:*:*)
- echo cris-axis-linux-gnu
+ echo ${UNAME_MACHINE}-axis-linux-${LIBC}
exit ;;
crisv32:Linux:*:*)
- echo crisv32-axis-linux-gnu
+ echo ${UNAME_MACHINE}-axis-linux-${LIBC}
exit ;;
frv:Linux:*:*)
- echo frv-unknown-linux-gnu
+ echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
exit ;;
hexagon:Linux:*:*)
- echo hexagon-unknown-linux-gnu
+ echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
exit ;;
i*86:Linux:*:*)
- LIBC=gnu
- eval $set_cc_for_build
- sed 's/^ //' << EOF >$dummy.c
- #ifdef __dietlibc__
- LIBC=dietlibc
- #endif
-EOF
- eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC'`
- echo "${UNAME_MACHINE}-pc-linux-${LIBC}"
+ echo ${UNAME_MACHINE}-pc-linux-${LIBC}
exit ;;
ia64:Linux:*:*)
- echo ${UNAME_MACHINE}-unknown-linux-gnu
+ echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
exit ;;
m32r*:Linux:*:*)
- echo ${UNAME_MACHINE}-unknown-linux-gnu
+ echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
exit ;;
m68*:Linux:*:*)
- echo ${UNAME_MACHINE}-unknown-linux-gnu
+ echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
exit ;;
mips:Linux:*:* | mips64:Linux:*:*)
eval $set_cc_for_build
@@ -942,54 +968,63 @@ EOF
#endif
EOF
eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'`
- test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; }
+ test x"${CPU}" != x && { echo "${CPU}-unknown-linux-${LIBC}"; exit; }
;;
- or32:Linux:*:*)
- echo or32-unknown-linux-gnu
+ openrisc*:Linux:*:*)
+ echo or1k-unknown-linux-${LIBC}
+ exit ;;
+ or32:Linux:*:* | or1k*:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
exit ;;
padre:Linux:*:*)
- echo sparc-unknown-linux-gnu
+ echo sparc-unknown-linux-${LIBC}
exit ;;
parisc64:Linux:*:* | hppa64:Linux:*:*)
- echo hppa64-unknown-linux-gnu
+ echo hppa64-unknown-linux-${LIBC}
exit ;;
parisc:Linux:*:* | hppa:Linux:*:*)
# Look for CPU level
case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in
- PA7*) echo hppa1.1-unknown-linux-gnu ;;
- PA8*) echo hppa2.0-unknown-linux-gnu ;;
- *) echo hppa-unknown-linux-gnu ;;
+ PA7*) echo hppa1.1-unknown-linux-${LIBC} ;;
+ PA8*) echo hppa2.0-unknown-linux-${LIBC} ;;
+ *) echo hppa-unknown-linux-${LIBC} ;;
esac
exit ;;
ppc64:Linux:*:*)
- echo powerpc64-unknown-linux-gnu
+ echo powerpc64-unknown-linux-${LIBC}
exit ;;
ppc:Linux:*:*)
- echo powerpc-unknown-linux-gnu
+ echo powerpc-unknown-linux-${LIBC}
+ exit ;;
+ ppc64le:Linux:*:*)
+ echo powerpc64le-unknown-linux-${LIBC}
+ exit ;;
+ ppcle:Linux:*:*)
+ echo powerpcle-unknown-linux-${LIBC}
exit ;;
s390:Linux:*:* | s390x:Linux:*:*)
- echo ${UNAME_MACHINE}-ibm-linux
+ echo ${UNAME_MACHINE}-ibm-linux-${LIBC}
exit ;;
sh64*:Linux:*:*)
- echo ${UNAME_MACHINE}-unknown-linux-gnu
+ echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
exit ;;
sh*:Linux:*:*)
- echo ${UNAME_MACHINE}-unknown-linux-gnu
+ echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
exit ;;
sparc:Linux:*:* | sparc64:Linux:*:*)
- echo ${UNAME_MACHINE}-unknown-linux-gnu
+ echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
exit ;;
tile*:Linux:*:*)
- echo ${UNAME_MACHINE}-unknown-linux-gnu
+ echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
exit ;;
vax:Linux:*:*)
- echo ${UNAME_MACHINE}-dec-linux-gnu
+ echo ${UNAME_MACHINE}-dec-linux-${LIBC}
exit ;;
x86_64:Linux:*:*)
- echo x86_64-unknown-linux-gnu
+ echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
exit ;;
xtensa*:Linux:*:*)
- echo ${UNAME_MACHINE}-unknown-linux-gnu
+ echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
exit ;;
i*86:DYNIX/ptx:4*:*)
# ptx 4.0 does uname -s correctly, with DYNIX/ptx in there.
@@ -1193,6 +1228,9 @@ EOF
BePC:Haiku:*:*) # Haiku running on Intel PC compatible.
echo i586-pc-haiku
exit ;;
+ x86_64:Haiku:*:*)
+ echo x86_64-unknown-haiku
+ exit ;;
SX-4:SUPER-UX:*:*)
echo sx4-nec-superux${UNAME_RELEASE}
exit ;;
@@ -1219,19 +1257,31 @@ EOF
exit ;;
*:Darwin:*:*)
UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown
- case $UNAME_PROCESSOR in
- i386)
- eval $set_cc_for_build
- if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then
- if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \
- (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \
- grep IS_64BIT_ARCH >/dev/null
- then
- UNAME_PROCESSOR="x86_64"
- fi
- fi ;;
- unknown) UNAME_PROCESSOR=powerpc ;;
- esac
+ eval $set_cc_for_build
+ if test "$UNAME_PROCESSOR" = unknown ; then
+ UNAME_PROCESSOR=powerpc
+ fi
+ if test `echo "$UNAME_RELEASE" | sed -e 's/\..*//'` -le 10 ; then
+ if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then
+ if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \
+ (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \
+ grep IS_64BIT_ARCH >/dev/null
+ then
+ case $UNAME_PROCESSOR in
+ i386) UNAME_PROCESSOR=x86_64 ;;
+ powerpc) UNAME_PROCESSOR=powerpc64 ;;
+ esac
+ fi
+ fi
+ elif test "$UNAME_PROCESSOR" = i386 ; then
+ # Avoid executing cc on OS X 10.9, as it ships with a stub
+ # that puts up a graphical alert prompting to install
+ # developer tools. Any system running Mac OS X 10.7 or
+ # later (Darwin 11 and later) is required to have a 64-bit
+ # processor. This is not true of the ARM version of Darwin
+ # that Apple uses in portable devices.
+ UNAME_PROCESSOR=x86_64
+ fi
echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE}
exit ;;
*:procnto*:*:* | *:QNX:[0123456789]*:*)
@@ -1248,7 +1298,7 @@ EOF
NEO-?:NONSTOP_KERNEL:*:*)
echo neo-tandem-nsk${UNAME_RELEASE}
exit ;;
- NSE-?:NONSTOP_KERNEL:*:*)
+ NSE-*:NONSTOP_KERNEL:*:*)
echo nse-tandem-nsk${UNAME_RELEASE}
exit ;;
NSR-?:NONSTOP_KERNEL:*:*)
@@ -1317,158 +1367,10 @@ EOF
i*86:AROS:*:*)
echo ${UNAME_MACHINE}-pc-aros
exit ;;
-esac
-
-#echo '(No uname command or uname output not recognized.)' 1>&2
-#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2
-
-eval $set_cc_for_build
-cat >$dummy.c <<EOF
-#ifdef _SEQUENT_
-# include <sys/types.h>
-# include <sys/utsname.h>
-#endif
-main ()
-{
-#if defined (sony)
-#if defined (MIPSEB)
- /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed,
- I don't know.... */
- printf ("mips-sony-bsd\n"); exit (0);
-#else
-#include <sys/param.h>
- printf ("m68k-sony-newsos%s\n",
-#ifdef NEWSOS4
- "4"
-#else
- ""
-#endif
- ); exit (0);
-#endif
-#endif
-
-#if defined (__arm) && defined (__acorn) && defined (__unix)
- printf ("arm-acorn-riscix\n"); exit (0);
-#endif
-
-#if defined (hp300) && !defined (hpux)
- printf ("m68k-hp-bsd\n"); exit (0);
-#endif
-
-#if defined (NeXT)
-#if !defined (__ARCHITECTURE__)
-#define __ARCHITECTURE__ "m68k"
-#endif
- int version;
- version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`;
- if (version < 4)
- printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version);
- else
- printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version);
- exit (0);
-#endif
-
-#if defined (MULTIMAX) || defined (n16)
-#if defined (UMAXV)
- printf ("ns32k-encore-sysv\n"); exit (0);
-#else
-#if defined (CMU)
- printf ("ns32k-encore-mach\n"); exit (0);
-#else
- printf ("ns32k-encore-bsd\n"); exit (0);
-#endif
-#endif
-#endif
-
-#if defined (__386BSD__)
- printf ("i386-pc-bsd\n"); exit (0);
-#endif
-
-#if defined (sequent)
-#if defined (i386)
- printf ("i386-sequent-dynix\n"); exit (0);
-#endif
-#if defined (ns32000)
- printf ("ns32k-sequent-dynix\n"); exit (0);
-#endif
-#endif
-
-#if defined (_SEQUENT_)
- struct utsname un;
-
- uname(&un);
-
- if (strncmp(un.version, "V2", 2) == 0) {
- printf ("i386-sequent-ptx2\n"); exit (0);
- }
- if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */
- printf ("i386-sequent-ptx1\n"); exit (0);
- }
- printf ("i386-sequent-ptx\n"); exit (0);
-
-#endif
-
-#if defined (vax)
-# if !defined (ultrix)
-# include <sys/param.h>
-# if defined (BSD)
-# if BSD == 43
- printf ("vax-dec-bsd4.3\n"); exit (0);
-# else
-# if BSD == 199006
- printf ("vax-dec-bsd4.3reno\n"); exit (0);
-# else
- printf ("vax-dec-bsd\n"); exit (0);
-# endif
-# endif
-# else
- printf ("vax-dec-bsd\n"); exit (0);
-# endif
-# else
- printf ("vax-dec-ultrix\n"); exit (0);
-# endif
-#endif
-
-#if defined (alliant) && defined (i860)
- printf ("i860-alliant-bsd\n"); exit (0);
-#endif
-
- exit (1);
-}
-EOF
-
-$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && SYSTEM_NAME=`$dummy` &&
- { echo "$SYSTEM_NAME"; exit; }
-
-# Apollos put the system type in the environment.
-
-test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; }
-
-# Convex versions that predate uname can use getsysinfo(1)
-
-if [ -x /usr/convex/getsysinfo ]
-then
- case `getsysinfo -f cpu_type` in
- c1*)
- echo c1-convex-bsd
- exit ;;
- c2*)
- if getsysinfo -f scalar_acc
- then echo c32-convex-bsd
- else echo c2-convex-bsd
- fi
- exit ;;
- c34*)
- echo c34-convex-bsd
+ x86_64:VMkernel:*:*)
+ echo ${UNAME_MACHINE}-unknown-esx
exit ;;
- c38*)
- echo c38-convex-bsd
- exit ;;
- c4*)
- echo c4-convex-bsd
- exit ;;
- esac
-fi
+esac
cat >&2 <<EOF
$0: unable to guess system type
diff --git a/config.sub b/config.sub
index 5b8736823d..7ffe373784 100755
--- a/config.sub
+++ b/config.sub
@@ -1,38 +1,31 @@
#! /bin/sh
# Configuration validation subroutine script.
-# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
-# 2011 Free Software Foundation, Inc.
+# Copyright 1992-2014 Free Software Foundation, Inc.
-timestamp='2011-10-08'
+timestamp='2014-12-03'
-# This file is (in principle) common to ALL GNU software.
-# The presence of a machine in this file suggests that SOME GNU software
-# can handle that machine. It does not imply ALL GNU software can.
-#
-# This file is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
+# This file is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
-# 02110-1301, USA.
+# along with this program; if not, see <http://www.gnu.org/licenses/>.
#
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
-# the same distribution terms that you use for the rest of that program.
+# the same distribution terms that you use for the rest of that
+# program. This Exception is an additional permission under section 7
+# of the GNU General Public License, version 3 ("GPLv3").
-# Please send patches to <config-patches@gnu.org>. Submit a context
-# diff and a properly formatted GNU ChangeLog entry.
+# Please send patches to <config-patches@gnu.org>.
#
# Configuration subroutine to validate and canonicalize a configuration type.
# Supply the specified configuration type as an argument.
@@ -75,9 +68,7 @@ Report bugs and patches to <config-patches@gnu.org>."
version="\
GNU config.sub ($timestamp)
-Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free
-Software Foundation, Inc.
+Copyright 1992-2014 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
@@ -125,13 +116,17 @@ esac
maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
case $maybe_os in
nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \
- linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \
+ linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \
knetbsd*-gnu* | netbsd*-gnu* | \
kopensolaris*-gnu* | \
storm-chaos* | os2-emx* | rtmk-nova*)
os=-$maybe_os
basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
;;
+ android-linux)
+ os=-linux-android
+ basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`-unknown
+ ;;
*)
basic_machine=`echo $1 | sed 's/-[^-]*$//'`
if [ $basic_machine != $1 ]
@@ -154,7 +149,7 @@ case $os in
-convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\
-c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \
-harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \
- -apple | -axis | -knuth | -cray | -microblaze)
+ -apple | -axis | -knuth | -cray | -microblaze*)
os=
basic_machine=$1
;;
@@ -223,6 +218,12 @@ case $os in
-isc*)
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
;;
+ -lynx*178)
+ os=-lynxos178
+ ;;
+ -lynx*5)
+ os=-lynxos5
+ ;;
-lynx*)
os=-lynxos
;;
@@ -247,13 +248,16 @@ case $basic_machine in
# Some are omitted here because they have special meanings below.
1750a | 580 \
| a29k \
+ | aarch64 | aarch64_be \
| alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \
| alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \
| am33_2.0 \
- | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr | avr32 \
- | be32 | be64 \
+ | arc | arceb \
+ | arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv7[arm] \
+ | avr | avr32 \
+ | be32 | be64 \
| bfin \
- | c4x | clipper \
+ | c4x | c8051 | clipper \
| d10v | d30v | dlx | dsp16xx \
| epiphany \
| fido | fr30 | frv \
@@ -261,10 +265,11 @@ case $basic_machine in
| hexagon \
| i370 | i860 | i960 | ia64 \
| ip2k | iq2000 \
+ | k1om \
| le32 | le64 \
| lm32 \
| m32c | m32r | m32rle | m68000 | m68k | m88k \
- | maxq | mb | microblaze | mcore | mep | metag \
+ | maxq | mb | microblaze | microblazeel | mcore | mep | metag \
| mips | mipsbe | mipseb | mipsel | mipsle \
| mips16 \
| mips64 | mips64el \
@@ -278,24 +283,27 @@ case $basic_machine in
| mips64vr5900 | mips64vr5900el \
| mipsisa32 | mipsisa32el \
| mipsisa32r2 | mipsisa32r2el \
+ | mipsisa32r6 | mipsisa32r6el \
| mipsisa64 | mipsisa64el \
| mipsisa64r2 | mipsisa64r2el \
+ | mipsisa64r6 | mipsisa64r6el \
| mipsisa64sb1 | mipsisa64sb1el \
| mipsisa64sr71k | mipsisa64sr71kel \
+ | mipsr5900 | mipsr5900el \
| mipstx39 | mipstx39el \
| mn10200 | mn10300 \
| moxie \
| mt \
| msp430 \
| nds32 | nds32le | nds32be \
- | nios | nios2 \
+ | nios | nios2 | nios2eb | nios2el \
| ns16k | ns32k \
- | open8 \
- | or32 \
+ | open8 | or1k | or1knd | or32 \
| pdp10 | pdp11 | pj | pjl \
| powerpc | powerpc64 | powerpc64le | powerpcle \
| pyramid \
- | rx \
+ | riscv32 | riscv64 \
+ | rl78 | rx \
| score \
| sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \
| sh64 | sh64le \
@@ -305,6 +313,7 @@ case $basic_machine in
| tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \
| ubicom32 \
| v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \
+ | visium \
| we32k \
| x86 | xc16x | xstormy16 | xtensa \
| z8k | z80)
@@ -319,8 +328,10 @@ case $basic_machine in
c6x)
basic_machine=tic6x-unknown
;;
- m6811 | m68hc11 | m6812 | m68hc12 | picochip)
- # Motorola 68HC11/12.
+ leon|leon[3-9])
+ basic_machine=sparc-$basic_machine
+ ;;
+ m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | nvptx | picochip)
basic_machine=$basic_machine-unknown
os=-none
;;
@@ -333,7 +344,10 @@ case $basic_machine in
strongarm | thumb | xscale)
basic_machine=arm-unknown
;;
-
+ xgate)
+ basic_machine=$basic_machine-unknown
+ os=-none
+ ;;
xscaleeb)
basic_machine=armeb-unknown
;;
@@ -356,15 +370,16 @@ case $basic_machine in
# Recognize the basic CPU types with company name.
580-* \
| a29k-* \
+ | aarch64-* | aarch64_be-* \
| alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \
| alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \
- | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \
+ | alphapca5[67]-* | alpha64pca5[67]-* | arc-* | arceb-* \
| arm-* | armbe-* | armle-* | armeb-* | armv*-* \
| avr-* | avr32-* \
| be32-* | be64-* \
| bfin-* | bs2000-* \
| c[123]* | c30-* | [cjt]90-* | c4x-* \
- | clipper-* | craynv-* | cydra-* \
+ | c8051-* | clipper-* | craynv-* | cydra-* \
| d10v-* | d30v-* | dlx-* \
| elxsi-* \
| f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \
@@ -373,11 +388,13 @@ case $basic_machine in
| hexagon-* \
| i*86-* | i860-* | i960-* | ia64-* \
| ip2k-* | iq2000-* \
+ | k1om-* \
| le32-* | le64-* \
| lm32-* \
| m32c-* | m32r-* | m32rle-* \
| m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \
- | m88110-* | m88k-* | maxq-* | mcore-* | metag-* | microblaze-* \
+ | m88110-* | m88k-* | maxq-* | mcore-* | metag-* \
+ | microblaze-* | microblazeel-* \
| mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \
| mips16-* \
| mips64-* | mips64el-* \
@@ -391,23 +408,27 @@ case $basic_machine in
| mips64vr5900-* | mips64vr5900el-* \
| mipsisa32-* | mipsisa32el-* \
| mipsisa32r2-* | mipsisa32r2el-* \
+ | mipsisa32r6-* | mipsisa32r6el-* \
| mipsisa64-* | mipsisa64el-* \
| mipsisa64r2-* | mipsisa64r2el-* \
+ | mipsisa64r6-* | mipsisa64r6el-* \
| mipsisa64sb1-* | mipsisa64sb1el-* \
| mipsisa64sr71k-* | mipsisa64sr71kel-* \
+ | mipsr5900-* | mipsr5900el-* \
| mipstx39-* | mipstx39el-* \
| mmix-* \
| mt-* \
| msp430-* \
| nds32-* | nds32le-* | nds32be-* \
- | nios-* | nios2-* \
+ | nios-* | nios2-* | nios2eb-* | nios2el-* \
| none-* | np1-* | ns16k-* | ns32k-* \
| open8-* \
+ | or1k*-* \
| orion-* \
| pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \
| powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \
| pyramid-* \
- | romp-* | rs6000-* | rx-* \
+ | rl78-* | romp-* | rs6000-* | rx-* \
| sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \
| shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \
| sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \
@@ -420,6 +441,7 @@ case $basic_machine in
| ubicom32-* \
| v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \
| vax-* \
+ | visium-* \
| we32k-* \
| x86-* | x86_64-* | xc16x-* | xps100-* \
| xstormy16-* | xtensa*-* \
@@ -719,7 +741,6 @@ case $basic_machine in
i370-ibm* | ibm*)
basic_machine=i370-ibm
;;
-# I'm not sure what "Sysv32" means. Should this be sysv3.2?
i*86v32)
basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
os=-sysv32
@@ -758,6 +779,9 @@ case $basic_machine in
basic_machine=m68k-isi
os=-sysv
;;
+ leon-*|leon[3-9]-*)
+ basic_machine=sparc-`echo $basic_machine | sed 's/-.*//'`
+ ;;
m68knommu)
basic_machine=m68k-unknown
os=-linux
@@ -777,11 +801,15 @@ case $basic_machine in
basic_machine=ns32k-utek
os=-sysv
;;
- microblaze)
+ microblaze*)
basic_machine=microblaze-xilinx
;;
+ mingw64)
+ basic_machine=x86_64-pc
+ os=-mingw64
+ ;;
mingw32)
- basic_machine=i386-pc
+ basic_machine=i686-pc
os=-mingw32
;;
mingw32ce)
@@ -809,6 +837,10 @@ case $basic_machine in
basic_machine=powerpc-unknown
os=-morphos
;;
+ moxiebox)
+ basic_machine=moxie-unknown
+ os=-moxiebox
+ ;;
msdos)
basic_machine=i386-pc
os=-msdos
@@ -816,6 +848,10 @@ case $basic_machine in
ms1-*)
basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'`
;;
+ msys)
+ basic_machine=i686-pc
+ os=-msys
+ ;;
mvs)
basic_machine=i370-ibm
os=-mvs
@@ -1004,7 +1040,11 @@ case $basic_machine in
basic_machine=i586-unknown
os=-pw32
;;
- rdos)
+ rdos | rdos64)
+ basic_machine=x86_64-pc
+ os=-rdos
+ ;;
+ rdos32)
basic_machine=i386-pc
os=-rdos
;;
@@ -1331,29 +1371,29 @@ case $os in
-gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \
| -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\
| -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \
- | -sym* | -kopensolaris* \
+ | -sym* | -kopensolaris* | -plan9* \
| -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \
| -aos* | -aros* \
| -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
| -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
| -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \
- | -openbsd* | -solidbsd* \
+ | -bitrig* | -openbsd* | -solidbsd* \
| -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \
| -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \
| -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
| -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
| -chorusos* | -chorusrdb* | -cegcc* \
- | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
- | -mingw32* | -linux-gnu* | -linux-android* \
- | -linux-newlib* | -linux-uclibc* \
- | -uxpv* | -beos* | -mpeix* | -udk* \
+ | -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
+ | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \
+ | -linux-newlib* | -linux-musl* | -linux-uclibc* \
+ | -uxpv* | -beos* | -mpeix* | -udk* | -moxiebox* \
| -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
| -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
| -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \
| -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \
| -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \
| -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \
- | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es*)
+ | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es* | -tirtos*)
# Remember, each alternative MUST END IN *, to match a version number.
;;
-qnx*)
@@ -1477,9 +1517,6 @@ case $os in
-aros*)
os=-aros
;;
- -kaos*)
- os=-kaos
- ;;
-zvmoe)
os=-zvmoe
;;
@@ -1528,6 +1565,12 @@ case $basic_machine in
c4x-* | tic4x-*)
os=-coff
;;
+ c8051-*)
+ os=-elf
+ ;;
+ hexagon-*)
+ os=-elf
+ ;;
tic54x-*)
os=-coff
;;
@@ -1555,9 +1598,6 @@ case $basic_machine in
;;
m68000-sun)
os=-sunos3
- # This also exists in the configure program, but was not the
- # default.
- # os=-sunos4
;;
m68*-cisco)
os=-aout
diff --git a/configure b/configure
index 541d1c2198..eba1ebcb32 100755
--- a/configure
+++ b/configure
@@ -822,9 +822,9 @@ Usage: $0 [OPTIONS]...
Configuration:
-h, --help display this help and exit
- --backend=BACKEND backend to build (android, tizen, dc, dingux, ds, gph,
- iphone, linuxmoto, maemo, n64, null, openpandora, ps2,
- psp, samsungtv, sdl, webos, wii, wince) [sdl]
+ --backend=BACKEND backend to build (android, tizen, dc, dingux, ds, gcw0,
+ gph, iphone, linuxmoto, maemo, n64, null, openpandora,
+ ps2, psp, samsungtv, sdl, webos, wii, wince) [sdl]
Installation directories:
--prefix=PREFIX install architecture-independent files in PREFIX
@@ -859,6 +859,7 @@ Special configuration feature:
dreamcast for Sega Dreamcast
ds for Nintendo DS
gamecube for Nintendo GameCube
+ gcw0 for GCW Zero
gp2x for GP2X
gp2xwiz for GP2X Wiz
iphone for Apple iPhone
@@ -1298,7 +1299,7 @@ caanoo)
_host_cpu=arm
_host_alias=arm-none-linux-gnueabi
;;
-dingux)
+dingux | gcw0)
_host_os=linux
_host_cpu=mipsel
_host_alias=mipsel-linux
@@ -2588,6 +2589,25 @@ if test -n "$_host"; then
add_line_to_config_h "/* #define DEBUG_WII_GDB */"
add_line_to_config_h "#define USE_WII_DI"
;;
+ gcw0)
+ DEFINES="$DEFINES -DDINGUX -DGCW0"
+ DEFINES="$DEFINES -DREDUCE_MEMORY_USAGE"
+ ASFLAGS="$ASFLAGS"
+ CXXFLAGS="$CXXFLAGS -mips32"
+ _backend="dingux"
+ _mt32emu=no
+ _optimization_level=-O3
+ # Disable alsa midi to get the port build on OpenDingux toolchain
+ _alsa=no
+ _vkeybd=yes
+ _build_hq_scalers=no
+ _keymapper=yes
+ # Force disable vorbis on dingux, it has terrible performance compared to tremor
+ _vorbis=no
+ # Force disable seq on dingux, no way to use it and it would get enabled by default with configure
+ _seq_midi=no
+ _port_mk="backends/platform/dingux/dingux.mk"
+ ;;
gp2x)
DEFINES="$DEFINES -DGP2X"
CXXFLAGS="$CXXFLAGS -march=armv4t"
@@ -2743,6 +2763,9 @@ if test -n "$_host"; then
_port_mk="backends/platform/openpandora/op-bundle.mk"
;;
ppc-amigaos)
+ # PPC Linker requires this to fix relocation errors
+ CXXFLAGS="$CXXFLAGS -mlongcall"
+
# Only static builds link successfully on buildbot
LDFLAGS=`echo $LDFLAGS | sed 's/-use-dynld//'`
LDFLAGS="$LDFLAGS -static"
@@ -3848,8 +3871,8 @@ if test "$_libunity" = auto ; then
;;
*)
# Unity has a lots of dependencies, update the libs and cflags var with them
- LIBUNITY_LIBS="$LIBUNITY_LIBS `pkg-config --libs unity = 3.8.4 2>> "$TMPLOG"`"
- LIBUNITY_CFLAGS="$LIBUNITY_CFLAGS `pkg-config --cflags unity = 3.8.4 2>> "$TMPLOG"`"
+ LIBUNITY_LIBS="$LIBUNITY_LIBS `pkg-config --libs 'unity > 3.8.1' 2>> "$TMPLOG"`"
+ LIBUNITY_CFLAGS="$LIBUNITY_CFLAGS `pkg-config --cflags 'unity > 3.8.1' 2>> "$TMPLOG"`"
_libunity=no
cat > $TMPC << EOF
#include <unity.h>
@@ -3863,6 +3886,10 @@ EOF
esac
fi
if test "$_libunity" = yes ; then
+ if test "$LIBUNITY_CFLAGS" = "" || test "$LIBUNITY_LIBS" = ""; then
+ LIBUNITY_LIBS="$LIBUNITY_LIBS `pkg-config --libs 'unity > 3.8.1' 2>> "$TMPLOG"`"
+ LIBUNITY_CFLAGS="$LIBUNITY_CFLAGS `pkg-config --cflags 'unity > 3.8.1' 2>> "$TMPLOG"`"
+ fi
LIBS="$LIBS $LIBUNITY_LIBS"
INCLUDES="$INCLUDES $LIBUNITY_CFLAGS"
fi
diff --git a/devtools/create_kyradat/create_kyradat.cpp b/devtools/create_kyradat/create_kyradat.cpp
index 7da7bd4ef0..441f315c8d 100644
--- a/devtools/create_kyradat/create_kyradat.cpp
+++ b/devtools/create_kyradat/create_kyradat.cpp
@@ -45,7 +45,7 @@
enum {
- kKyraDatVersion = 85
+ kKyraDatVersion = 86
};
const ExtractFilename extractFilenames[] = {
diff --git a/devtools/create_kyradat/games.cpp b/devtools/create_kyradat/games.cpp
index 0162bda8ad..afe0c67dbf 100644
--- a/devtools/create_kyradat/games.cpp
+++ b/devtools/create_kyradat/games.cpp
@@ -99,6 +99,7 @@ const Game kyra3Games[] = {
const Game eob1Games[] = {
{ kEoB1, kPlatformDOS, kNoSpecial, EN_ANY },
{ kEoB1, kPlatformDOS, kNoSpecial, DE_DEU },
+ { kEoB1, kPlatformDOS, kNoSpecial, IT_ITA },
GAME_DUMMY_ENTRY
};
diff --git a/devtools/create_kyradat/resources.cpp b/devtools/create_kyradat/resources.cpp
index 66db495caf..4df6bb8fb8 100644
--- a/devtools/create_kyradat/resources.cpp
+++ b/devtools/create_kyradat/resources.cpp
@@ -93,6 +93,7 @@
#include "resources/eob1_dos.h"
#include "resources/eob1_dos_english.h"
#include "resources/eob1_dos_german.h"
+#include "resources/eob1_dos_italian.h"
// Eye of the Beholder: The Legend of Darkmoon
#include "resources/eob2_dos.h"
@@ -1249,6 +1250,94 @@ static const ResourceProvider resourceProviders[] = {
{ kEoBBaseManWord, kEoB1, kPlatformDOS, kNoSpecial, DE_DEU, &kEoB1ManWordDOSGermanProvider },
{ kEoBBaseManPrompt, kEoB1, kPlatformDOS, kNoSpecial, DE_DEU, &kEoB1ManPromptDOSGermanProvider },
{ kEoBBaseMonsterDistAttStrings, kEoB1, kPlatformDOS, kNoSpecial, DE_DEU, &kEoB1MonsterDistAttStringsDOSGermanProvider },
+ { kEoBBaseChargenStrings1, kEoB1, kPlatformDOS, kNoSpecial, IT_ITA, &kEoB1ChargenStrings1DOSItalianProvider },
+ { kEoBBaseChargenStrings2, kEoB1, kPlatformDOS, kNoSpecial, IT_ITA, &kEoB1ChargenStrings2DOSItalianProvider },
+ { kEoBBaseChargenStatStrings, kEoB1, kPlatformDOS, kNoSpecial, IT_ITA, &kEoB1ChargenStatStringsDOSItalianProvider },
+ { kEoBBaseChargenRaceSexStrings, kEoB1, kPlatformDOS, kNoSpecial, IT_ITA, &kEoB1ChargenRaceSexStringsDOSItalianProvider },
+ { kEoBBaseChargenClassStrings, kEoB1, kPlatformDOS, kNoSpecial, IT_ITA, &kEoB1ChargenClassStringsDOSItalianProvider },
+ { kEoBBaseChargenAlignmentStrings, kEoB1, kPlatformDOS, kNoSpecial, IT_ITA, &kEoB1ChargenAlignmentStringsDOSItalianProvider },
+ { kEoBBaseChargenEnterGameStrings, kEoB1, kPlatformDOS, kNoSpecial, IT_ITA, &kEoB1ChargenEnterGameStringsDOSItalianProvider },
+ { kEoB1MainMenuStrings, kEoB1, kPlatformDOS, kNoSpecial, IT_ITA, &kEoB1MainMenuStringsDOSItalianProvider },
+ { kEoB1BonusStrings, kEoB1, kPlatformDOS, kNoSpecial, IT_ITA, &kEoB1BonusStringsDOSItalianProvider },
+ { kEoB1TurnUndeadString, kEoB1, kPlatformDOS, kNoSpecial, IT_ITA, &kEoB1TurnUndeadStringDOSItalianProvider },
+ { kEoB1Npc0Strings, kEoB1, kPlatformDOS, kNoSpecial, IT_ITA, &kEoB1Npc0StringsDOSItalianProvider },
+ { kEoB1Npc11Strings, kEoB1, kPlatformDOS, kNoSpecial, IT_ITA, &kEoB1Npc11StringsDOSItalianProvider },
+ { kEoB1Npc12Strings, kEoB1, kPlatformDOS, kNoSpecial, IT_ITA, &kEoB1Npc12StringsDOSItalianProvider },
+ { kEoB1Npc21Strings, kEoB1, kPlatformDOS, kNoSpecial, IT_ITA, &kEoB1Npc21StringsDOSItalianProvider },
+ { kEoB1Npc22Strings, kEoB1, kPlatformDOS, kNoSpecial, IT_ITA, &kEoB1Npc22StringsDOSItalianProvider },
+ { kEoB1Npc31Strings, kEoB1, kPlatformDOS, kNoSpecial, IT_ITA, &kEoB1Npc31StringsDOSItalianProvider },
+ { kEoB1Npc32Strings, kEoB1, kPlatformDOS, kNoSpecial, IT_ITA, &kEoB1Npc32StringsDOSItalianProvider },
+ { kEoB1Npc4Strings, kEoB1, kPlatformDOS, kNoSpecial, IT_ITA, &kEoB1Npc4StringsDOSItalianProvider },
+ { kEoB1Npc5Strings, kEoB1, kPlatformDOS, kNoSpecial, IT_ITA, &kEoB1Npc5StringsDOSItalianProvider },
+ { kEoB1Npc6Strings, kEoB1, kPlatformDOS, kNoSpecial, IT_ITA, &kEoB1Npc6StringsDOSItalianProvider },
+ { kEoB1Npc7Strings, kEoB1, kPlatformDOS, kNoSpecial, IT_ITA, &kEoB1Npc7StringsDOSItalianProvider },
+ { kEoBBasePryDoorStrings, kEoB1, kPlatformDOS, kNoSpecial, IT_ITA, &kEoB1PryDoorStringsDOSItalianProvider },
+ { kEoBBaseWarningStrings, kEoB1, kPlatformDOS, kNoSpecial, IT_ITA, &kEoB1WarningStringsDOSItalianProvider },
+ { kEoBBaseItemSuffixStringsRings, kEoB1, kPlatformDOS, kNoSpecial, IT_ITA, &kEoB1ItemSuffixStringsRingsDOSItalianProvider },
+ { kEoBBaseItemSuffixStringsPotions, kEoB1, kPlatformDOS, kNoSpecial, IT_ITA, &kEoB1ItemSuffixStringsPotionsDOSItalianProvider },
+ { kEoBBaseItemSuffixStringsWands, kEoB1, kPlatformDOS, kNoSpecial, IT_ITA, &kEoB1ItemSuffixStringsWandsDOSItalianProvider },
+ { kEoBBaseRipItemStrings, kEoB1, kPlatformDOS, kNoSpecial, IT_ITA, &kEoB1RipItemStringsDOSItalianProvider },
+ { kEoBBaseCursedString, kEoB1, kPlatformDOS, kNoSpecial, IT_ITA, &kEoB1CursedStringDOSItalianProvider },
+ { kEoBBaseMagicObjectStrings, kEoB1, kPlatformDOS, kNoSpecial, IT_ITA, &kEoB1MagicObjectStringsDOSItalianProvider },
+ { kEoBBaseMagicObjectString5, kEoB1, kPlatformDOS, kNoSpecial, IT_ITA, &kEoB1MagicObjectString5DOSItalianProvider },
+ { kEoBBasePatternSuffix, kEoB1, kPlatformDOS, kNoSpecial, IT_ITA, &kEoB1PatternSuffixDOSItalianProvider },
+ { kEoBBasePatternGrFix1, kEoB1, kPlatformDOS, kNoSpecial, IT_ITA, &kEoB1PatternGrFix1DOSItalianProvider },
+ { kEoBBasePatternGrFix2, kEoB1, kPlatformDOS, kNoSpecial, IT_ITA, &kEoB1PatternGrFix2DOSItalianProvider },
+ { kEoBBaseValidateArmorString, kEoB1, kPlatformDOS, kNoSpecial, IT_ITA, &kEoB1ValidateArmorStringDOSItalianProvider },
+ { kEoBBaseValidateNoDropString, kEoB1, kPlatformDOS, kNoSpecial, IT_ITA, &kEoB1ValidateNoDropStringDOSItalianProvider },
+ { kEoBBasePotionStrings, kEoB1, kPlatformDOS, kNoSpecial, IT_ITA, &kEoB1PotionStringsDOSItalianProvider },
+ { kEoBBaseWandStrings, kEoB1, kPlatformDOS, kNoSpecial, IT_ITA, &kEoB1WandStringsDOSItalianProvider },
+ { kEoBBaseItemMisuseStrings, kEoB1, kPlatformDOS, kNoSpecial, IT_ITA, &kEoB1ItemMisuseStringsDOSItalianProvider },
+ { kEoBBaseTakenStrings, kEoB1, kPlatformDOS, kNoSpecial, IT_ITA, &kEoB1TakenStringsDOSItalianProvider },
+ { kEoBBasePotionEffectStrings, kEoB1, kPlatformDOS, kNoSpecial, IT_ITA, &kEoB1PotionEffectStringsDOSItalianProvider },
+ { kEoBBaseYesNoStrings, kEoB1, kPlatformDOS, kNoSpecial, IT_ITA, &kEoB1YesNoStringsDOSItalianProvider },
+ { kRpgCommonMoreStrings, kEoB1, kPlatformDOS, kNoSpecial, IT_ITA, &kEoB1MoreStringsDOSItalianProvider },
+ { kEoBBaseNpcMaxStrings, kEoB1, kPlatformDOS, kNoSpecial, IT_ITA, &kEoB1NpcMaxStringsDOSItalianProvider },
+ { kEoBBaseNpcJoinStrings, kEoB1, kPlatformDOS, kNoSpecial, IT_ITA, &kEoB1NpcJoinStringsDOSItalianProvider },
+ { kEoBBaseCancelStrings, kEoB1, kPlatformDOS, kNoSpecial, IT_ITA, &kEoB1CancelStringsDOSItalianProvider },
+ { kEoBBaseMenuStringsMain, kEoB1, kPlatformDOS, kNoSpecial, IT_ITA, &kEoB1MenuStringsMainDOSItalianProvider },
+ { kEoBBaseMenuStringsSaveLoad, kEoB1, kPlatformDOS, kNoSpecial, IT_ITA, &kEoB1MenuStringsSaveLoadDOSItalianProvider },
+ { kEoBBaseMenuStringsOnOff, kEoB1, kPlatformDOS, kNoSpecial, IT_ITA, &kEoB1MenuStringsOnOffDOSItalianProvider },
+ { kEoBBaseMenuStringsSpells, kEoB1, kPlatformDOS, kNoSpecial, IT_ITA, &kEoB1MenuStringsSpellsDOSItalianProvider },
+ { kEoBBaseMenuStringsRest, kEoB1, kPlatformDOS, kNoSpecial, IT_ITA, &kEoB1MenuStringsRestDOSItalianProvider },
+ { kEoBBaseMenuStringsDrop, kEoB1, kPlatformDOS, kNoSpecial, IT_ITA, &kEoB1MenuStringsDropDOSItalianProvider },
+ { kEoBBaseMenuStringsExit, kEoB1, kPlatformDOS, kNoSpecial, IT_ITA, &kEoB1MenuStringsExitDOSItalianProvider },
+ { kEoBBaseMenuStringsStarve, kEoB1, kPlatformDOS, kNoSpecial, IT_ITA, &kEoB1MenuStringsStarveDOSItalianProvider },
+ { kEoBBaseMenuStringsScribe, kEoB1, kPlatformDOS, kNoSpecial, IT_ITA, &kEoB1MenuStringsScribeDOSItalianProvider },
+ { kEoBBaseMenuStringsDrop2, kEoB1, kPlatformDOS, kNoSpecial, IT_ITA, &kEoB1MenuStringsDrop2DOSItalianProvider },
+ { kEoBBaseMenuStringsHead, kEoB1, kPlatformDOS, kNoSpecial, IT_ITA, &kEoB1MenuStringsHeadDOSItalianProvider },
+ { kEoBBaseMenuStringsPoison, kEoB1, kPlatformDOS, kNoSpecial, IT_ITA, &kEoB1MenuStringsPoisonDOSItalianProvider },
+ { kEoBBaseMenuStringsMgc, kEoB1, kPlatformDOS, kNoSpecial, IT_ITA, &kEoB1MenuStringsMgcDOSItalianProvider },
+ { kEoBBaseMenuStringsPrefs, kEoB1, kPlatformDOS, kNoSpecial, IT_ITA, &kEoB1MenuStringsPrefsDOSItalianProvider },
+ { kEoBBaseMenuStringsRest2, kEoB1, kPlatformDOS, kNoSpecial, IT_ITA, &kEoB1MenuStringsRest2DOSItalianProvider },
+ { kEoBBaseMenuStringsRest4, kEoB1, kPlatformDOS, kNoSpecial, IT_ITA, &kEoB1MenuStringsRest4DOSItalianProvider },
+ { kEoBBaseMenuStringsDefeat, kEoB1, kPlatformDOS, kNoSpecial, IT_ITA, &kEoB1MenuStringsDefeatDOSItalianProvider },
+ { kEoBBaseMenuYesNoStrings, kEoB1, kPlatformDOS, kNoSpecial, IT_ITA, &kEoB1MenuYesNoStringsDOSItalianProvider },
+ { kEoBBaseCharGuiStringsHp, kEoB1, kPlatformDOS, kNoSpecial, IT_ITA, &kEoB1CharGuiStringsHpDOSItalianProvider },
+ { kEoBBaseCharGuiStringsWp1, kEoB1, kPlatformDOS, kNoSpecial, IT_ITA, &kEoB1CharGuiStringsWp1DOSItalianProvider },
+ { kEoBBaseCharGuiStringsWr, kEoB1, kPlatformDOS, kNoSpecial, IT_ITA, &kEoB1CharGuiStringsWrDOSItalianProvider },
+ { kEoBBaseCharGuiStringsSt1, kEoB1, kPlatformDOS, kNoSpecial, IT_ITA, &kEoB1CharGuiStringsSt1DOSItalianProvider },
+ { kEoBBaseCharGuiStringsIn, kEoB1, kPlatformDOS, kNoSpecial, IT_ITA, &kEoB1CharGuiStringsInDOSItalianProvider },
+ { kEoBBaseCharStatusStrings7, kEoB1, kPlatformDOS, kNoSpecial, IT_ITA, &kEoB1CharStatusStrings7DOSItalianProvider },
+ { kEoBBaseCharStatusStrings81, kEoB1, kPlatformDOS, kNoSpecial, IT_ITA, &kEoB1CharStatusStrings81DOSItalianProvider },
+ { kEoBBaseCharStatusStrings9, kEoB1, kPlatformDOS, kNoSpecial, IT_ITA, &kEoB1CharStatusStrings9DOSItalianProvider },
+ { kEoBBaseCharStatusStrings131, kEoB1, kPlatformDOS, kNoSpecial, IT_ITA, &kEoB1CharStatusStrings131DOSItalianProvider },
+ { kEoBBaseLevelGainStrings, kEoB1, kPlatformDOS, kNoSpecial, IT_ITA, &kEoB1LevelGainStringsDOSItalianProvider },
+ { kEoBBaseBookNumbers, kEoB1, kPlatformDOS, kNoSpecial, IT_ITA, &kEoB1BookNumbersDOSItalianProvider },
+ { kEoBBaseMageSpellsList, kEoB1, kPlatformDOS, kNoSpecial, IT_ITA, &kEoB1MageSpellsListDOSItalianProvider },
+ { kEoBBaseClericSpellsList, kEoB1, kPlatformDOS, kNoSpecial, IT_ITA, &kEoB1ClericSpellsListDOSItalianProvider },
+ { kEoBBaseSpellNames, kEoB1, kPlatformDOS, kNoSpecial, IT_ITA, &kEoB1SpellNamesDOSItalianProvider },
+ { kEoBBaseMagicStrings1, kEoB1, kPlatformDOS, kNoSpecial, IT_ITA, &kEoB1MagicStrings1DOSItalianProvider },
+ { kEoBBaseMagicStrings2, kEoB1, kPlatformDOS, kNoSpecial, IT_ITA, &kEoB1MagicStrings2DOSItalianProvider },
+ { kEoBBaseMagicStrings3, kEoB1, kPlatformDOS, kNoSpecial, IT_ITA, &kEoB1MagicStrings3DOSItalianProvider },
+ { kEoBBaseMagicStrings4, kEoB1, kPlatformDOS, kNoSpecial, IT_ITA, &kEoB1MagicStrings4DOSItalianProvider },
+ { kEoBBaseMagicStrings6, kEoB1, kPlatformDOS, kNoSpecial, IT_ITA, &kEoB1MagicStrings6DOSItalianProvider },
+ { kEoBBaseMagicStrings7, kEoB1, kPlatformDOS, kNoSpecial, IT_ITA, &kEoB1MagicStrings7DOSItalianProvider },
+ { kEoBBaseMagicStrings8, kEoB1, kPlatformDOS, kNoSpecial, IT_ITA, &kEoB1MagicStrings8DOSItalianProvider },
+ { kEoBBaseManDef, kEoB1, kPlatformDOS, kNoSpecial, IT_ITA, &kEoB1ManDefDOSItalianProvider },
+ { kEoBBaseManWord, kEoB1, kPlatformDOS, kNoSpecial, IT_ITA, &kEoB1ManWordDOSItalianProvider },
+ { kEoBBaseManPrompt, kEoB1, kPlatformDOS, kNoSpecial, IT_ITA, &kEoB1ManPromptDOSItalianProvider },
+ { kEoBBaseMonsterDistAttStrings, kEoB1, kPlatformDOS, kNoSpecial, IT_ITA, &kEoB1MonsterDistAttStringsDOSItalianProvider },
{ kEoBBaseChargenStrings1, kEoB2, kPlatformDOS, kNoSpecial, EN_ANY, &kEoB2ChargenStrings1DOSEnglishProvider },
{ kEoBBaseChargenStrings2, kEoB2, kPlatformDOS, kNoSpecial, EN_ANY, &kEoB2ChargenStrings2DOSEnglishProvider },
{ kEoBBaseChargenStartLevels, kEoB2, kPlatformDOS, kNoSpecial, UNK_LANG, &kEoB2ChargenStartLevelsDOSProvider },
diff --git a/devtools/create_kyradat/resources/eob1_dos_italian.h b/devtools/create_kyradat/resources/eob1_dos_italian.h
new file mode 100644
index 0000000000..680e197b57
--- /dev/null
+++ b/devtools/create_kyradat/resources/eob1_dos_italian.h
@@ -0,0 +1,891 @@
+static const char *const kEoB1ChargenStrings1DOSItalian[9] = {
+ "Il tuo gruppo ""\x0E""\rcompleto.Premi il\rbottone GIOCA per\riniziare la nuova\rpartita.",
+ " ",
+ "CA\rPF\rLIV",
+ "%s\r%d\r%d\r%d\r%d\r%d",
+ "%d\r%d",
+ "%d",
+ "%d/%d",
+ "%d/%d/%d",
+ "Scegli il riquadro\rdel personaggio\rche vuoi creare o\rvedere."
+};
+
+static const StringListProvider kEoB1ChargenStrings1DOSItalianProvider = { ARRAYSIZE(kEoB1ChargenStrings1DOSItalian), kEoB1ChargenStrings1DOSItalian };
+
+static const char *const kEoB1ChargenStrings2DOSItalian[12] = {
+ "%s",
+ "%d",
+ "%s",
+ "%d",
+ "%d",
+ "%d",
+ "%s",
+ "%d",
+ "SCEGLI RAZZA:",
+ "SCEGLI CLASSE:",
+ "SCEGLI ALLINEAMENTO:",
+ "NOME:"
+};
+
+static const StringListProvider kEoB1ChargenStrings2DOSItalianProvider = { ARRAYSIZE(kEoB1ChargenStrings2DOSItalian), kEoB1ChargenStrings2DOSItalian };
+
+static const char *const kEoB1ChargenStatStringsDOSItalian[12] = {
+ "FOR",
+ "INT",
+ "SAG",
+ "DES",
+ "COS",
+ "CAR",
+ "FORZA",
+ "INTELLIGENZA",
+ "SAGGEZZA",
+ "DESTREZZA",
+ "COSTITUZIONE",
+ "CARISMA"
+};
+
+static const StringListProvider kEoB1ChargenStatStringsDOSItalianProvider = { ARRAYSIZE(kEoB1ChargenStatStringsDOSItalian), kEoB1ChargenStatStringsDOSItalian };
+
+static const char *const kEoB1ChargenRaceSexStringsDOSItalian[12] = {
+ "UMANO MASCHIO",
+ "UMANO FEMMINA",
+ "ELFO MASCHIO",
+ "ELFO FEMMINA",
+ "MEZZUOMO MASCHIO",
+ "MEZZUOMO FEMMINA",
+ "NANO MASCHIO",
+ "NANO FEMMINA",
+ "GNOMO MASCHIO",
+ "GNOMO FEMMINA",
+ "MEZZUOMO MASCHIO",
+ "MEZZUOMO FEMMINA"
+};
+
+static const StringListProvider kEoB1ChargenRaceSexStringsDOSItalianProvider = { ARRAYSIZE(kEoB1ChargenRaceSexStringsDOSItalian), kEoB1ChargenRaceSexStringsDOSItalian };
+
+static const char *const kEoB1ChargenClassStringsDOSItalian[21] = {
+ "GUERRIERO",
+ "RANGER",
+ "PALADINO",
+ "MAGO",
+ "CHIERICO",
+ "LADRO",
+ "GUERRIERO/CHIERICO",
+ "GUERRIERO/LADRO",
+ "GUERRIERO/MAGO",
+ "GUER./MAGO/LADRO",
+ "LADRO/MAGO",
+ "CHIERICO/LADRO",
+ "GUER./CHIERICO/MAGO",
+ "RANGER/CHIERICO",
+ "CHIERICO/MAGO",
+ "GUERRIERO",
+ "MAGO",
+ "CHIERICO",
+ "LADRO",
+ "PALADINO",
+ "RANGER"
+};
+
+static const StringListProvider kEoB1ChargenClassStringsDOSItalianProvider = { ARRAYSIZE(kEoB1ChargenClassStringsDOSItalian), kEoB1ChargenClassStringsDOSItalian };
+
+static const char *const kEoB1ChargenAlignmentStringsDOSItalian[9] = {
+ "LEGALE BUONO",
+ "NEUTRALE BUONO",
+ "CAOTICO BUONO",
+ "LEGALE NEUTRALE",
+ "NEUTRALE PURO",
+ "CAOTICO NEUT.",
+ "LEGALE MALVAGIO",
+ "NEUTRALE MALV.",
+ "CAOTICO MALV."
+};
+
+static const StringListProvider kEoB1ChargenAlignmentStringsDOSItalianProvider = { ARRAYSIZE(kEoB1ChargenAlignmentStringsDOSItalian), kEoB1ChargenAlignmentStringsDOSItalian };
+
+static const char *const kEoB1ChargenEnterGameStringsDOSItalian[1] = {
+ " Avvio partita.\r in corso..."
+};
+
+static const StringListProvider kEoB1ChargenEnterGameStringsDOSItalianProvider = { ARRAYSIZE(kEoB1ChargenEnterGameStringsDOSItalian), kEoB1ChargenEnterGameStringsDOSItalian };
+
+static const char *const kEoB1MainMenuStringsDOSItalian[3] = {
+ "CARICA UNA PARTITA\r",
+ "CREA UN NUOVO GRUPPO\r",
+ "ESCI\r"
+};
+
+static const StringListProvider kEoB1MainMenuStringsDOSItalianProvider = { ARRAYSIZE(kEoB1MainMenuStringsDOSItalian), kEoB1MainMenuStringsDOSItalian };
+
+static const char *const kEoB1BonusStringsDOSItalian[3] = {
+ "Congratulazioni per aver scoperto tutte le 12 quest bonus di Beholder.\r\rI nomi dei personaggi del tuo gruppo vincente sono:\r\r",
+ "\r",
+ "\r\rPassword: %04x\r"
+};
+
+static const StringListProvider kEoB1BonusStringsDOSItalianProvider = { ARRAYSIZE(kEoB1BonusStringsDOSItalian), kEoB1BonusStringsDOSItalian };
+
+static const char *const kEoB1TurnUndeadStringDOSItalian[1] = {
+ "\x06\x06""%s usa scacciare non-morti!""\x06\x0F""\r"
+};
+
+static const StringListProvider kEoB1TurnUndeadStringDOSItalianProvider = { ARRAYSIZE(kEoB1TurnUndeadStringDOSItalian), kEoB1TurnUndeadStringDOSItalian };
+
+static const char *const kEoB1Npc0StringsDOSItalian[2] = {
+ "\rVi auguro fortuna nel vostro viaggio.",
+ "Chi dovrei resuscitare?"
+};
+
+static const StringListProvider kEoB1Npc0StringsDOSItalianProvider = { ARRAYSIZE(kEoB1Npc0StringsDOSItalian), kEoB1Npc0StringsDOSItalian };
+
+static const char *const kEoB1Npc11StringsDOSItalian[3] = {
+ "Curalo",
+ "Parla",
+ "Riparti"
+};
+
+static const StringListProvider kEoB1Npc11StringsDOSItalianProvider = { ARRAYSIZE(kEoB1Npc11StringsDOSItalian), kEoB1Npc11StringsDOSItalian };
+
+static const char *const kEoB1Npc12StringsDOSItalian[2] = {
+ "Curalo",
+ "Riparti"
+};
+
+static const StringListProvider kEoB1Npc12StringsDOSItalianProvider = { ARRAYSIZE(kEoB1Npc12StringsDOSItalian), kEoB1Npc12StringsDOSItalian };
+
+static const char *const kEoB1Npc21StringsDOSItalian[2] = {
+ "Ascolta Proposta",
+ "Riparti"
+};
+
+static const StringListProvider kEoB1Npc21StringsDOSItalianProvider = { ARRAYSIZE(kEoB1Npc21StringsDOSItalian), kEoB1Npc21StringsDOSItalian };
+
+static const char *const kEoB1Npc22StringsDOSItalian[2] = {
+ "Aiutalo",
+ "Riparti"
+};
+
+static const StringListProvider kEoB1Npc22StringsDOSItalianProvider = { ARRAYSIZE(kEoB1Npc22StringsDOSItalian), kEoB1Npc22StringsDOSItalian };
+
+static const char *const kEoB1Npc31StringsDOSItalian[2] = {
+ "Cura Gruppo",
+ "Riparti"
+};
+
+static const StringListProvider kEoB1Npc31StringsDOSItalianProvider = { ARRAYSIZE(kEoB1Npc31StringsDOSItalian), kEoB1Npc31StringsDOSItalian };
+
+static const char *const kEoB1Npc32StringsDOSItalian[3] = {
+ "Cura Gruppo",
+ "Resuscita morti",
+ "Riparti"
+};
+
+static const StringListProvider kEoB1Npc32StringsDOSItalianProvider = { ARRAYSIZE(kEoB1Npc32StringsDOSItalian), kEoB1Npc32StringsDOSItalian };
+
+static const char *const kEoB1Npc4StringsDOSItalian[2] = {
+ "Attacca",
+ "Corrompi"
+};
+
+static const StringListProvider kEoB1Npc4StringsDOSItalianProvider = { ARRAYSIZE(kEoB1Npc4StringsDOSItalian), kEoB1Npc4StringsDOSItalian };
+
+static const char *const kEoB1Npc5StringsDOSItalian[3] = {
+ "Uccidila",
+ "Ascoltala",
+ "Falla scappare"
+};
+
+static const StringListProvider kEoB1Npc5StringsDOSItalianProvider = { ARRAYSIZE(kEoB1Npc5StringsDOSItalian), kEoB1Npc5StringsDOSItalian };
+
+static const char *const kEoB1Npc6StringsDOSItalian[2] = {
+ "Arrenditi",
+ "Attacca"
+};
+
+static const StringListProvider kEoB1Npc6StringsDOSItalianProvider = { ARRAYSIZE(kEoB1Npc6StringsDOSItalian), kEoB1Npc6StringsDOSItalian };
+
+static const char *const kEoB1Npc7StringsDOSItalian[3] = {
+ "Liberalo",
+ "Uccidilo",
+ "Riparti"
+};
+
+static const StringListProvider kEoB1Npc7StringsDOSItalianProvider = { ARRAYSIZE(kEoB1Npc7StringsDOSItalian), kEoB1Npc7StringsDOSItalian };
+
+static const char *const kEoB1PryDoorStringsDOSItalian[7] = {
+ "Nessuno pu""\x11"" forzare la porta\r",
+ "Il gruppo forza la porta!\r",
+ "%s forza la porta!\r",
+ "Il gruppo prova a forzare la porta, ma fallisce.\r",
+ "Non puoi metterci quest'oggetto.\r",
+ "L'oggetto ""\x0E"" troppo grande.\r",
+ "Nessuno pu""\x11"" forzare questa porta.\r"
+};
+
+static const StringListProvider kEoB1PryDoorStringsDOSItalianProvider = { ARRAYSIZE(kEoB1PryDoorStringsDOSItalian), kEoB1PryDoorStringsDOSItalian };
+
+static const char *const kEoB1WarningStringsDOSItalian[3] = {
+ "Non potete proseguire da questa parte.\r",
+ "%s non pu""\x11"" consumare cibo!\r",
+ "Non ""\x0E"" commestibile!\r"
+};
+
+static const StringListProvider kEoB1WarningStringsDOSItalianProvider = { ARRAYSIZE(kEoB1WarningStringsDOSItalian), kEoB1WarningStringsDOSItalian };
+
+static const char *const kEoB1ItemSuffixStringsRingsDOSItalian[4] = {
+ "Ornamento",
+ "Stregoneria",
+ "Sostentamento",
+ "Caduta Morbida"
+};
+
+static const StringListProvider kEoB1ItemSuffixStringsRingsDOSItalianProvider = { ARRAYSIZE(kEoB1ItemSuffixStringsRingsDOSItalian), kEoB1ItemSuffixStringsRingsDOSItalian };
+
+static const char *const kEoB1ItemSuffixStringsPotionsDOSItalian[8] = {
+ "Forza dei Giganti",
+ "Guarigione",
+ "Super-Guarigione",
+ "Veleno",
+ "Vitalit""\x0C""",
+ "Velocit""\x0C""",
+ "Invisibilit""\x0C""",
+ "Antidoti"
+};
+
+static const StringListProvider kEoB1ItemSuffixStringsPotionsDOSItalianProvider = { ARRAYSIZE(kEoB1ItemSuffixStringsPotionsDOSItalian), kEoB1ItemSuffixStringsPotionsDOSItalian };
+
+static const char *const kEoB1ItemSuffixStringsWandsDOSItalian[7] = {
+ "Legno",
+ "Fulmini",
+ "Gelo",
+ "Cure",
+ "Palla di Fuoco",
+ "Silvias",
+ "Dardo Incantato",
+};
+
+static const StringListProvider kEoB1ItemSuffixStringsWandsDOSItalianProvider = { ARRAYSIZE(kEoB1ItemSuffixStringsWandsDOSItalian), kEoB1ItemSuffixStringsWandsDOSItalian };
+
+static const char *const kEoB1RipItemStringsDOSItalian[3] = {
+ "%s ha perso la sua ",
+ "%s ha perso il suo ",
+ ".\r"
+};
+
+static const StringListProvider kEoB1RipItemStringsDOSItalianProvider = { ARRAYSIZE(kEoB1RipItemStringsDOSItalian), kEoB1RipItemStringsDOSItalian };
+
+static const char *const kEoB1CursedStringDOSItalian[1] = {
+ "Maledetta %s %d"
+};
+
+static const StringListProvider kEoB1CursedStringDOSItalianProvider = { ARRAYSIZE(kEoB1CursedStringDOSItalian), kEoB1CursedStringDOSItalian };
+
+static const char *const kEoB1MagicObjectStringsDOSItalian[5] = {
+ "Pergamena del mago",
+ "Pergamena del Chierico",
+ "Anello",
+ "Pozione",
+ "bacchetta"
+};
+
+static const StringListProvider kEoB1MagicObjectStringsDOSItalianProvider = { ARRAYSIZE(kEoB1MagicObjectStringsDOSItalian), kEoB1MagicObjectStringsDOSItalian };
+
+static const char *const kEoB1MagicObjectString5DOSItalian[1] = {
+ "Legno"
+};
+
+static const StringListProvider kEoB1MagicObjectString5DOSItalianProvider = { ARRAYSIZE(kEoB1MagicObjectString5DOSItalian), kEoB1MagicObjectString5DOSItalian };
+
+static const char *const kEoB1PatternSuffixDOSItalian[1] = {
+ "%s di %s"
+};
+
+static const StringListProvider kEoB1PatternSuffixDOSItalianProvider = { ARRAYSIZE(kEoB1PatternSuffixDOSItalian), kEoB1PatternSuffixDOSItalian };
+
+static const char *const kEoB1PatternGrFix1DOSItalian[1] = {
+ "%s di %s"
+};
+
+static const StringListProvider kEoB1PatternGrFix1DOSItalianProvider = { ARRAYSIZE(kEoB1PatternGrFix1DOSItalian), kEoB1PatternGrFix1DOSItalian };
+
+static const char *const kEoB1PatternGrFix2DOSItalian[1] = {
+ "%s di %s"
+};
+
+static const StringListProvider kEoB1PatternGrFix2DOSItalianProvider = { ARRAYSIZE(kEoB1PatternGrFix2DOSItalian), kEoB1PatternGrFix2DOSItalian };
+
+static const char *const kEoB1ValidateArmorStringDOSItalian[1] = {
+ "%s non pu""\x11"" indossare quest'armatura.\r"
+};
+
+static const StringListProvider kEoB1ValidateArmorStringDOSItalianProvider = { ARRAYSIZE(kEoB1ValidateArmorStringDOSItalian), kEoB1ValidateArmorStringDOSItalian };
+
+static const char *const kEoB1ValidateNoDropStringDOSItalian[1] = {
+ "Non puoi metterci quest'oggetto.\r"
+};
+
+static const StringListProvider kEoB1ValidateNoDropStringDOSItalianProvider = { ARRAYSIZE(kEoB1ValidateNoDropStringDOSItalian), kEoB1ValidateNoDropStringDOSItalian };
+
+static const char *const kEoB1PotionStringsDOSItalian[2] = {
+ "avvelenato",
+ "%s si sente %s!\r"
+};
+
+static const StringListProvider kEoB1PotionStringsDOSItalianProvider = { ARRAYSIZE(kEoB1PotionStringsDOSItalian), kEoB1PotionStringsDOSItalian };
+
+static const char *const kEoB1WandStringsDOSItalian[2] = {
+ "La bacchetta pare priva di magia\r",
+ "Nessun effetto.\r"
+};
+
+static const StringListProvider kEoB1WandStringsDOSItalianProvider = { ARRAYSIZE(kEoB1WandStringsDOSItalian), kEoB1WandStringsDOSItalian };
+
+static const char *const kEoB1ItemMisuseStringsDOSItalian[3] = {
+ " non pu""\x11"" usare quest'oggetto.\r",
+ "Se indossato quest'oggetto funziona in automatico.\r",
+ "Questo oggetto non si usa cos""\x10"".\r"
+};
+
+static const StringListProvider kEoB1ItemMisuseStringsDOSItalianProvider = { ARRAYSIZE(kEoB1ItemMisuseStringsDOSItalian), kEoB1ItemMisuseStringsDOSItalian };
+
+static const char *const kEoB1TakenStringsDOSItalian[1] = {
+ " preso.\r"
+};
+
+static const StringListProvider kEoB1TakenStringsDOSItalianProvider = { ARRAYSIZE(kEoB1TakenStringsDOSItalian), kEoB1TakenStringsDOSItalian };
+
+static const char *const kEoB1PotionEffectStringsDOSItalian[8] = {
+ "molto pi""\x12"" forte",
+ "meglio",
+ "molto meglio",
+ "ammalato",
+ "sazio",
+ "agile e veloce",
+ "trasparente",
+ "meglio"
+};
+
+static const StringListProvider kEoB1PotionEffectStringsDOSItalianProvider = { ARRAYSIZE(kEoB1PotionEffectStringsDOSItalian), kEoB1PotionEffectStringsDOSItalian };
+
+static const char *const kEoB1YesNoStringsDOSItalian[2] = {
+ "s""\x10""",
+ "no"
+};
+
+static const StringListProvider kEoB1YesNoStringsDOSItalianProvider = { ARRAYSIZE(kEoB1YesNoStringsDOSItalian), kEoB1YesNoStringsDOSItalian };
+
+static const char *const kEoB1MoreStringsDOSItalian[1] = {
+ " >> "
+};
+
+static const StringListProvider kEoB1MoreStringsDOSItalianProvider = { ARRAYSIZE(kEoB1MoreStringsDOSItalian), kEoB1MoreStringsDOSItalian };
+
+static const char *const kEoB1NpcMaxStringsDOSItalian[1] = {
+ "Puoi avere solo sei personaggi nel tuo gruppo. Scegli chi congedare."
+};
+
+static const StringListProvider kEoB1NpcMaxStringsDOSItalianProvider = { ARRAYSIZE(kEoB1NpcMaxStringsDOSItalian), kEoB1NpcMaxStringsDOSItalian };
+
+static const char *const kEoB1NpcJoinStringsDOSItalian[1] = {
+ "%s si unisce al gruppo.\r"
+};
+
+static const StringListProvider kEoB1NpcJoinStringsDOSItalianProvider = { ARRAYSIZE(kEoB1NpcJoinStringsDOSItalian), kEoB1NpcJoinStringsDOSItalian };
+
+static const char *const kEoB1CancelStringsDOSItalian[1] = {
+ "ANNULLA"
+};
+
+static const StringListProvider kEoB1CancelStringsDOSItalianProvider = { ARRAYSIZE(kEoB1CancelStringsDOSItalian), kEoB1CancelStringsDOSItalian };
+
+static const char *const kEoB1MenuStringsMainDOSItalian[8] = {
+ "Opzioni:",
+ "Riposa",
+ "Studia Incantesimi",
+ "Prega Incantesimi",
+ "Trascrivi Pergamene",
+ "Impostazioni",
+ "Opzioni",
+ " << "
+};
+
+static const StringListProvider kEoB1MenuStringsMainDOSItalianProvider = { ARRAYSIZE(kEoB1MenuStringsMainDOSItalian), kEoB1MenuStringsMainDOSItalian };
+
+static const char *const kEoB1MenuStringsSaveLoadDOSItalian[8] = {
+ "Carica Partita",
+ "Salva Partita",
+ "Congeda Personaggio",
+ "Esci dal gioco",
+ "Opzioni:",
+ "\r Salvato!",
+ "\r Salvataggio\r fallito!",
+ "\r Caricamento\r fallito!"
+};
+
+static const StringListProvider kEoB1MenuStringsSaveLoadDOSItalianProvider = { ARRAYSIZE(kEoB1MenuStringsSaveLoadDOSItalian), kEoB1MenuStringsSaveLoadDOSItalian };
+
+static const char *const kEoB1MenuStringsOnOffDOSItalian[2] = {
+ "ON",
+ "OFF"
+};
+
+static const StringListProvider kEoB1MenuStringsOnOffDOSItalianProvider = { ARRAYSIZE(kEoB1MenuStringsOnOffDOSItalian), kEoB1MenuStringsOnOffDOSItalian };
+
+static const char *const kEoB1MenuStringsSpellsDOSItalian[17] = {
+ "\r\r Scegli il\r personaggio del\r gruppo a cui\r far studiare gli\r incantesimi.",
+ "\r Il tuo Paladino ""\x0E""\r di livello troppo\r basso.",
+ "\r\r Il Mago non ha\r il Libro degli\r Incantesimi!",
+ "\r\r\r Scegli il\r personaggio del\r gruppo a cui far\r pregare per gli\r incantesimi.",
+ "\r Non hai nessun\r Chierico che\r possa pregare.",
+ "\r Non hai nessun\r Mago che possa\r studiare gli\r incantesimi.",
+ " Un Mago morto o\r svenuto non pu""\x11""\r memorizzare\r incantesimi.",
+ " Un Chierico morto o\r svenuto non pu""\x11""\r memorizzare\r incantesimi.",
+ "1",
+ "2",
+ "3",
+ "4",
+ "5",
+ "Canc.",
+ "Incantesimi:",
+ "S""\x10""",
+ "No"
+};
+
+static const StringListProvider kEoB1MenuStringsSpellsDOSItalianProvider = { ARRAYSIZE(kEoB1MenuStringsSpellsDOSItalian), kEoB1MenuStringsSpellsDOSItalian };
+
+static const char *const kEoB1MenuStringsRestDOSItalian[5] = {
+ "\rMetti i tuoi \rguaritori a curare\ril gruppo?",
+ " Qualcuno ""\x0E"" ancora\rferito. Riposa\rfino alla\rguarigione?",
+ "Riposando.",
+ "\r Tutti i\r personaggi sono\r riposati.",
+ " Il tuo gruppo ha\rbisogno di riposare\rper ottenere gli\rincantesimi."
+};
+
+static const StringListProvider kEoB1MenuStringsRestDOSItalianProvider = { ARRAYSIZE(kEoB1MenuStringsRestDOSItalian), kEoB1MenuStringsRestDOSItalian };
+
+static const char *const kEoB1MenuStringsDropDOSItalian[1] = {
+ " Non puoi avere\r meno di quattro\r personaggi."
+};
+
+static const StringListProvider kEoB1MenuStringsDropDOSItalianProvider = { ARRAYSIZE(kEoB1MenuStringsDropDOSItalian), kEoB1MenuStringsDropDOSItalian };
+
+static const char *const kEoB1MenuStringsExitDOSItalian[1] = {
+ " Sei sicuro di\rvoler uscire dal\rgioco?"
+};
+
+static const StringListProvider kEoB1MenuStringsExitDOSItalianProvider = { ARRAYSIZE(kEoB1MenuStringsExitDOSItalian), kEoB1MenuStringsExitDOSItalian };
+
+static const char *const kEoB1MenuStringsStarveDOSItalian[1] = {
+ " Il tuo gruppo sta\rpatendo la fame.\rContinua a riposare?"
+};
+
+static const StringListProvider kEoB1MenuStringsStarveDOSItalianProvider = { ARRAYSIZE(kEoB1MenuStringsStarveDOSItalian), kEoB1MenuStringsStarveDOSItalian };
+
+static const char *const kEoB1MenuStringsScribeDOSItalian[5] = {
+ "Scegli la pergamena\rda trascrivere.",
+ "\r\r\r Scegli un Mago che\r vorrebbe trascrivere\r gli incantesimi.",
+ " Non hai nessuna\r pergamena da\r trascrivere.",
+ " Non hai nessuna\r pergamena utile\r a questo Mago.",
+ "\r Non hai nessun\r Mago che possa\r trascrivere\r pergamene."
+};
+
+static const StringListProvider kEoB1MenuStringsScribeDOSItalianProvider = { ARRAYSIZE(kEoB1MenuStringsScribeDOSItalian), kEoB1MenuStringsScribeDOSItalian };
+
+static const char *const kEoB1MenuStringsDrop2DOSItalian[3] = {
+ " Scegli il\r personaggio da\r congedare.",
+ " Sei sicuro di\rvoler salvare la\rpartita?",
+ " Sei sicuro di\rvoler caricare una\rpartita?"
+};
+
+static const StringListProvider kEoB1MenuStringsDrop2DOSItalianProvider = { ARRAYSIZE(kEoB1MenuStringsDrop2DOSItalian), kEoB1MenuStringsDrop2DOSItalian };
+
+static const char *const kEoB1MenuStringsHeadDOSItalian[3] = {
+ "Al Campo:",
+ "Impostazioni:",
+ "Opzioni:"
+};
+
+static const StringListProvider kEoB1MenuStringsHeadDOSItalianProvider = { ARRAYSIZE(kEoB1MenuStringsHeadDOSItalian), kEoB1MenuStringsHeadDOSItalian };
+
+static const char *const kEoB1MenuStringsPoisonDOSItalian[1] = {
+ "I membri avvelenati\rmoriranno! Riposa\rcomunque?"
+};
+
+static const StringListProvider kEoB1MenuStringsPoisonDOSItalianProvider = { ARRAYSIZE(kEoB1MenuStringsPoisonDOSItalian), kEoB1MenuStringsPoisonDOSItalian };
+
+static const char *const kEoB1MenuStringsMgcDOSItalian[2] = {
+ "%-18s %1d",
+ "%d di %d rimanenti. "
+};
+
+static const StringListProvider kEoB1MenuStringsMgcDOSItalianProvider = { ARRAYSIZE(kEoB1MenuStringsMgcDOSItalian), kEoB1MenuStringsMgcDOSItalian };
+
+static const char *const kEoB1MenuStringsPrefsDOSItalian[4] = {
+ "Musiche %-3s",
+ "Effetti sonori %-3s",
+ "Barre grafiche %-3s",
+ "Mouse %-3s"
+};
+
+static const StringListProvider kEoB1MenuStringsPrefsDOSItalianProvider = { ARRAYSIZE(kEoB1MenuStringsPrefsDOSItalian), kEoB1MenuStringsPrefsDOSItalian };
+
+static const char *const kEoB1MenuStringsRest2DOSItalian[4] = {
+ "%s ha ottenuto %s.\r",
+ "%s ha memorizzato %s.\r",
+ "%s Cura %s.\r",
+ "Ore di riposo: %-4d"
+};
+
+static const StringListProvider kEoB1MenuStringsRest2DOSItalianProvider = { ARRAYSIZE(kEoB1MenuStringsRest2DOSItalian), kEoB1MenuStringsRest2DOSItalian };
+
+static const char *const kEoB1MenuStringsRest4DOSItalian[1] = {
+ "\rNon potete riposare vicino a dei mostri."
+};
+
+static const StringListProvider kEoB1MenuStringsRest4DOSItalianProvider = { ARRAYSIZE(kEoB1MenuStringsRest4DOSItalian), kEoB1MenuStringsRest4DOSItalian };
+
+static const char *const kEoB1MenuStringsDefeatDOSItalian[1] = {
+ "L'intero gruppo ""\x0E"" stato sconfitto. I servitori del male potranno portare avanti i loro piani indisturbati!\r"
+};
+
+static const StringListProvider kEoB1MenuStringsDefeatDOSItalianProvider = { ARRAYSIZE(kEoB1MenuStringsDefeatDOSItalian), kEoB1MenuStringsDefeatDOSItalian };
+
+static const char *const kEoB1MenuYesNoStringsDOSItalian[2] = {
+ "S""\x10""",
+ "No"
+};
+
+static const StringListProvider kEoB1MenuYesNoStringsDOSItalianProvider = { ARRAYSIZE(kEoB1MenuYesNoStringsDOSItalian), kEoB1MenuYesNoStringsDOSItalian };
+
+static const char *const kEoB1CharGuiStringsHpDOSItalian[2] = {
+ "PF",
+ "%3d di %-3d"
+};
+
+static const StringListProvider kEoB1CharGuiStringsHpDOSItalianProvider = { ARRAYSIZE(kEoB1CharGuiStringsHpDOSItalian), kEoB1CharGuiStringsHpDOSItalian };
+
+static const char *const kEoB1CharGuiStringsWp1DOSItalian[2] = {
+ "FFSSS",
+ "ZAC"
+};
+
+static const StringListProvider kEoB1CharGuiStringsWp1DOSItalianProvider = { ARRAYSIZE(kEoB1CharGuiStringsWp1DOSItalian), kEoB1CharGuiStringsWp1DOSItalian };
+
+static const char *const kEoB1CharGuiStringsWrDOSItalian[4] = {
+ "FUORI",
+ "PORTATA",
+ "NESSUNA",
+ "MUNIZIONE"
+};
+
+static const StringListProvider kEoB1CharGuiStringsWrDOSItalianProvider = { ARRAYSIZE(kEoB1CharGuiStringsWrDOSItalian), kEoB1CharGuiStringsWrDOSItalian };
+
+static const char *const kEoB1CharGuiStringsSt1DOSItalian[6] = {
+ "Scambiando",
+ "MORTO",
+ "SVENUTO",
+ "(LENTEZZA)",
+ "AVVELENATO",
+ "PARALIZZATO"
+};
+
+static const StringListProvider kEoB1CharGuiStringsSt1DOSItalianProvider = { ARRAYSIZE(kEoB1CharGuiStringsSt1DOSItalian), kEoB1CharGuiStringsSt1DOSItalian };
+
+static const char *const kEoB1CharGuiStringsInDOSItalian[4] = {
+ "INFO PERSONAGGIO",
+ "CLASSE ARMATURA",
+ "ESP",
+ "LIV"
+};
+
+static const StringListProvider kEoB1CharGuiStringsInDOSItalianProvider = { ARRAYSIZE(kEoB1CharGuiStringsInDOSItalian), kEoB1CharGuiStringsInDOSItalian };
+
+static const char *const kEoB1CharStatusStrings7DOSItalian[1] = {
+ "%s ha perso la forza dei giganti.\r"
+};
+
+static const StringListProvider kEoB1CharStatusStrings7DOSItalianProvider = { ARRAYSIZE(kEoB1CharStatusStrings7DOSItalian), kEoB1CharStatusStrings7DOSItalian };
+
+static const char *const kEoB1CharStatusStrings81DOSItalian[1] = {
+ "%s risente degli effetti del veleno!\r"
+};
+
+static const StringListProvider kEoB1CharStatusStrings81DOSItalianProvider = { ARRAYSIZE(kEoB1CharStatusStrings81DOSItalian), kEoB1CharStatusStrings81DOSItalian };
+
+static const char *const kEoB1CharStatusStrings9DOSItalian[1] = {
+ "%s non ""\x0E"" pi""\x12"" paralizzato!\r"
+};
+
+static const StringListProvider kEoB1CharStatusStrings9DOSItalianProvider = { ARRAYSIZE(kEoB1CharStatusStrings9DOSItalian), kEoB1CharStatusStrings9DOSItalian };
+
+static const char *const kEoB1CharStatusStrings131DOSItalian[1] = {
+ "%s ""\x0E"" %s!\r"
+};
+
+static const StringListProvider kEoB1CharStatusStrings131DOSItalianProvider = { ARRAYSIZE(kEoB1CharStatusStrings131DOSItalian), kEoB1CharStatusStrings131DOSItalian };
+
+static const char *const kEoB1LevelGainStringsDOSItalian[1] = {
+ "\x06\x01""%s ha guadagnato un livello di esperienza.""\x06\x0F""\r"
+};
+
+static const StringListProvider kEoB1LevelGainStringsDOSItalianProvider = { ARRAYSIZE(kEoB1LevelGainStringsDOSItalian), kEoB1LevelGainStringsDOSItalian };
+
+static const char *const kEoB1BookNumbersDOSItalian[5] = {
+ "Primo",
+ "Secondo",
+ "Terzo",
+ "Quarto",
+ "Quinto"
+};
+
+static const StringListProvider kEoB1BookNumbersDOSItalianProvider = { ARRAYSIZE(kEoB1BookNumbersDOSItalian), kEoB1BookNumbersDOSItalian };
+
+static const char *const kEoB1MageSpellsListDOSItalian[26] = {
+ "",
+ "Armatura",
+ "Mani Brucianti",
+ "Individua Magico",
+ "Dardo Incantato",
+ "Lettura Magico",
+ "Scudo",
+ "Scarica Elettrica",
+ "Invisibilit""\x0C",
+ "Chiavistello",
+ "Freccia Acida M.",
+ "Nube Maleodorante",
+ "Dissolvi Magie",
+ "Palla di Fuoco",
+ "Freccia Infuocata",
+ "Velocit""\x0C",
+ "Blocca Persone",
+ "Invisibilit""\x0C"" 3m",
+ "Fulmine",
+ "Tocco del Vampiro",
+ "Paura",
+ "Tempesta Ghiaccio",
+ "Pelle di Pietra",
+ "Nube Assassina",
+ "Cono di Freddo",
+ "Blocca Mostri"
+};
+
+static const StringListProvider kEoB1MageSpellsListDOSItalianProvider = { ARRAYSIZE(kEoB1MageSpellsListDOSItalian), kEoB1MageSpellsListDOSItalian };
+
+static const char *const kEoB1ClericSpellsListDOSItalian[25] = {
+ "",
+ "Benedizione",
+ "Cura Fer.L.",
+ "Causa Fer.L.",
+ "Individua Magico",
+ "Protez.Male",
+ "Aiuto",
+ "Lama Fiammegg.",
+ "Blocca Persone",
+ "Rallenta Veleno",
+ "Creare Cibo",
+ "Dissolvi Magie",
+ "Paramenti Magici",
+ "Preghiera",
+ "Rimuovi Paralisi",
+ "Cura Fer.G.",
+ "Causa Fer.G.",
+ "Neutral.Veleni",
+ "Protez.Male 3m",
+ "Protez.Fulmine",
+ "Cura Fer.C.",
+ "Causa Fer.C.",
+ "Colonna di Fuoco",
+ "Rianimare Morti",
+ "Imposizione Mani"
+};
+
+static const StringListProvider kEoB1ClericSpellsListDOSItalianProvider = { ARRAYSIZE(kEoB1ClericSpellsListDOSItalian), kEoB1ClericSpellsListDOSItalian };
+
+static const char *const kEoB1SpellNamesDOSItalian[51] = {
+ "",
+ "armatura",
+ "mani brucianti",
+ "individuazione del magico",
+ "dardo incantato",
+ "scudo",
+ "scarica elettrica",
+ "invisibilit""\x0C",
+ "freccia acida di melf",
+ "nube maleodorante",
+ "dissolvi magie",
+ "palla di fuoco",
+ "freccia infuocata",
+ "velocit""\x0C",
+ "blocca persone",
+ "invisibilit""\x0C"",raggio 3m",
+ "fulmine",
+ "tocco del vampiro",
+ "paura",
+ "tempesta di ghiaccio",
+ "pelle di pietra",
+ "nube assassina",
+ "cono di freddo",
+ "blocca mostri",
+ "benedizione",
+ "cura ferite leggere",
+ "causa ferita leggere",
+ "individuazione del magico",
+ "protezione dal male",
+ "aiuto",
+ "lama fiammeggiante",
+ "blocca persone",
+ "rallenta veleno",
+ "creare cibo e acqua",
+ "dissolvi magie",
+ "paramenti magici",
+ "preghiera",
+ "rimuovi paralisi",
+ "cura ferite gravi",
+ "causa ferite gravi",
+ "neutralizzare veleni",
+ "protezione dal male,raggio 3m",
+ "protezione dal fulmine",
+ "cura ferite critiche",
+ "causa ferite critiche",
+ "colonna di fuoco",
+ "rianimare morti",
+ "imposizione delle mani",
+ "",
+ "",
+ ""
+};
+
+static const StringListProvider kEoB1SpellNamesDOSItalianProvider = { ARRAYSIZE(kEoB1SpellNamesDOSItalian), kEoB1SpellNamesDOSItalian };
+
+static const char *const kEoB1MagicStrings1DOSItalian[6] = {
+ "ANNULLA",
+ "ANNULLA",
+ "Questo incantesimo richiede una mano libera.\r",
+ "Non puoi avere due di questi incantesimi attivi.\r",
+ "%s lancia %s.\r",
+ "ok\r"
+};
+
+static const StringListProvider kEoB1MagicStrings1DOSItalianProvider = { ARRAYSIZE(kEoB1MagicStrings1DOSItalian), kEoB1MagicStrings1DOSItalian };
+
+static const char *const kEoB1MagicStrings2DOSItalian[3] = {
+ "nessun effetto\r",
+ "%s ""\x0E"" stato disintegrato!!\r",
+ "Il gruppo ""\x0E"" stato colpito da 'Morte'!\r"
+};
+
+static const StringListProvider kEoB1MagicStrings2DOSItalianProvider = { ARRAYSIZE(kEoB1MagicStrings2DOSItalian), kEoB1MagicStrings2DOSItalian };
+
+static const char *const kEoB1MagicStrings3DOSItalian[6] = {
+ "Su chi lanci l'incantesimo? ",
+ "\rok\r",
+ "\rAnnullato.\r",
+ "L'incantesimo di %s, %s svanisce.\r",
+ "%s ha mancato il mostro.\r",
+ "%s deve stare in prima linea per colpire!\r"
+};
+
+static const StringListProvider kEoB1MagicStrings3DOSItalianProvider = { ARRAYSIZE(kEoB1MagicStrings3DOSItalian), kEoB1MagicStrings3DOSItalian };
+
+static const char *const kEoB1MagicStrings4DOSItalian[1] = {
+ "nessun effetto.\r"
+};
+
+static const StringListProvider kEoB1MagicStrings4DOSItalianProvider = { ARRAYSIZE(kEoB1MagicStrings4DOSItalian), kEoB1MagicStrings4DOSItalian };
+
+static const char *const kEoB1MagicStrings6DOSItalian[1] = {
+ "%s ha gi""\x0C"" classe armatura base alta.\r"
+};
+
+static const StringListProvider kEoB1MagicStrings6DOSItalianProvider = { ARRAYSIZE(kEoB1MagicStrings6DOSItalian), kEoB1MagicStrings6DOSItalian };
+
+static const char *const kEoB1MagicStrings7DOSItalian[5] = {
+ "I",
+ "II",
+ "III",
+ "IV",
+ "V"
+};
+
+static const StringListProvider kEoB1MagicStrings7DOSItalianProvider = { ARRAYSIZE(kEoB1MagicStrings7DOSItalian), kEoB1MagicStrings7DOSItalian };
+
+static const char *const kEoB1MagicStrings8DOSItalian[3] = {
+ "Tutti gli incantesimi su %s si sono dissolti.\r",
+ "'Benedizione' ""\x0E"" gi""\x0C"" attiva sul gruppo.\r",
+ "'Aiuto' fallisce!\r"
+};
+
+static const StringListProvider kEoB1MagicStrings8DOSItalianProvider = { ARRAYSIZE(kEoB1MagicStrings8DOSItalian), kEoB1MagicStrings8DOSItalian };
+
+static const byte kEoB1ManDefDOSItalian[120] = {
+ 0x09, 0x0A, 0x02, 0x00, 0x09, 0x04, 0x03, 0x00,
+ 0x09, 0x06, 0x06, 0x00, 0x09, 0x03, 0x03, 0x00,
+ 0x09, 0x04, 0x02, 0x00, 0x09, 0x01, 0x02, 0x00,
+ 0x09, 0x05, 0x01, 0x00, 0x09, 0x09, 0x02, 0x00,
+ 0x09, 0x06, 0x02, 0x00, 0x23, 0x01, 0x05, 0x00,
+ 0x23, 0x02, 0x02, 0x00, 0x23, 0x03, 0x06, 0x00,
+ 0x23, 0x05, 0x01, 0x00, 0x23, 0x06, 0x03, 0x00,
+ 0x23, 0x07, 0x01, 0x00, 0x1A, 0x01, 0x01, 0x00,
+ 0x1A, 0x03, 0x02, 0x00, 0x1A, 0x06, 0x01, 0x00,
+ 0x24, 0x01, 0x03, 0x00, 0x24, 0x03, 0x04, 0x00,
+ 0x24, 0x03, 0x01, 0x00, 0x02, 0x04, 0x03, 0x00,
+ 0x02, 0x03, 0x03, 0x00, 0x02, 0x05, 0x03, 0x00,
+ 0x01, 0x01, 0x01, 0x00, 0x01, 0x05, 0x03, 0x00,
+ 0x01, 0x04, 0x03, 0x00, 0x0C, 0x02, 0x01, 0x00,
+ 0x0C, 0x03, 0x03, 0x00, 0x0C, 0x04, 0x02, 0x00
+};
+
+static const ByteProvider kEoB1ManDefDOSItalianProvider = { ARRAYSIZE(kEoB1ManDefDOSItalian), kEoB1ManDefDOSItalian };
+
+static const char *const kEoB1ManWordDOSItalian[31] = {
+ "attacks",
+ "short",
+ "line",
+ "weapons",
+ "certain",
+ "rank",
+ "rear",
+ "can",
+ "away",
+ "dungeon",
+ "cursor",
+ "feature",
+ "information",
+ "displayed",
+ "below",
+ "around",
+ "carefree",
+ "gnomes",
+ "clerics",
+ "mystic",
+ "pummel",
+ "fitness",
+ "using",
+ "toughness",
+ "wealth",
+ "wizard",
+ "officials",
+ "hound",
+ "disturbing",
+ "flaming",
+ ""
+};
+
+static const StringListProvider kEoB1ManWordDOSItalianProvider = { ARRAYSIZE(kEoB1ManWordDOSItalian), kEoB1ManWordDOSItalian };
+
+static const char *const kEoB1ManPromptDOSItalian[1] = {
+ "\r\r\r\rOn the page with this symbol...\r\rFind line %d\rEnter word %d\r"
+};
+
+static const StringListProvider kEoB1ManPromptDOSItalianProvider = { ARRAYSIZE(kEoB1ManPromptDOSItalian), kEoB1ManPromptDOSItalian };
+
+static const char *const kEoB1MonsterDistAttStringsDOSItalian[5] = {
+ "%s ""\x0E"" stato colpito da 'Causa Ferite Gravi'\r",
+ "Il gruppo ""\x0E"" stato colpito da 'Flagello Mentale'!\r",
+ "paralizzato",
+ "avvelenato",
+ "paralizzato"
+};
+
+static const StringListProvider kEoB1MonsterDistAttStringsDOSItalianProvider = { ARRAYSIZE(kEoB1MonsterDistAttStringsDOSItalian), kEoB1MonsterDistAttStringsDOSItalian };
+
diff --git a/devtools/create_translations/po_parser.cpp b/devtools/create_translations/po_parser.cpp
index 7882502ca4..ecc3ba540c 100644
--- a/devtools/create_translations/po_parser.cpp
+++ b/devtools/create_translations/po_parser.cpp
@@ -332,6 +332,13 @@ PoMessageEntryList *parsePoFile(const char *file, PoMessageList& messages) {
strcat(currentBuf, stripLine(line));
}
}
+ if (currentBuf == msgstrBuf) {
+ // add last entry
+ if (*msgstrBuf != '\0' && !fuzzy) {
+ messages.insert(msgidBuf);
+ list->addMessageEntry(msgstrBuf, msgidBuf, msgctxtBuf);
+ }
+ }
fclose(inFile);
return list;
diff --git a/devtools/credits.pl b/devtools/credits.pl
index 0960011802..7dc954a6a7 100755
--- a/devtools/credits.pl
+++ b/devtools/credits.pl
@@ -786,10 +786,13 @@ begin_credits("Credits");
begin_section("Wintermute");
add_person("Einar Johan T. S&oslash;m&aring;en", "somaen", "");
+ add_person("Tobia Tesan", "t0by", "");
end_section();
begin_section("ZVision");
add_person("Adrian Astley", "RichieSams", "");
+ add_person("Filippos Karapetis", "[md5]", "");
+ add_person("Anton Yarcev", "Zidane", "");
end_section();
end_section();
@@ -1091,6 +1094,12 @@ begin_credits("Credits");
add_person("V&iacute;ctor Gonz&aacute;lez", "IlDucci", "Soltys Spanish translation");
add_person("Alejandro G&oacute;mez de la Mu&ntilde;oza", "TheFireRed", "Soltys Spanish translation");
end_section();
+ begin_section("CGE2");
+ add_person("Arnaud Boutonn&eacute;", "Strangerke", "Sfinx English translation");
+ add_person("Thierry Crozat", "criezy", "Sfinx English translation");
+ add_person("Peter Bozs&oacute;", "uruk", "Sfinx English translation editor");
+ add_person("Ryan Clark", "", "Sfinx English translation editor");
+ end_section();
begin_section("Drascula");
add_person("Thierry Crozat", "criezy", "Improve French translation");
end_section();
@@ -1205,7 +1214,7 @@ begin_credits("Credits");
add_person("Ivan Dubrov", "", "For contributing the initial version of the Gobliiins engine");
add_person("Henrik Engqvist", "qvist", "For generously providing hosting for our buildbot, SVN repository, planet and doxygen sites as well as tons of HD space");
add_person("DOSBox Team", "", "For their awesome OPL2 and OPL3 emulator");
- add_person("Yusuke Kamiyamane", "", "For contributing some GUI icons ");
+ add_person("Yusuke Kamiyamane", "", "For contributing some GUI icons");
add_person("Till Kresslein", "Krest", "For design of modern ScummVM GUI");
add_person("", "Jezar", "For his freeverb filter implementation");
add_person("Jim Leiterman", "", "Various info on his FM-TOWNS/Marty SCUMM ports");
@@ -1266,7 +1275,7 @@ begin_credits("Credits");
add_paragraph(
"Janusz Wi&#347;niewski and Miroslaw Liminowicz from Laboratorium Komputerowe Avalon ".
- "for providing full source code for So&#322;tys and letting us redistribute the game.");
+ "for providing full source code for So&#322;tys and Sfinx and letting us redistribute the games.");
add_paragraph(
"Jan Nedoma for providing the sources to the Wintermute-engine, and for his ".
diff --git a/devtools/scumm-md5.txt b/devtools/scumm-md5.txt
index f0cb577237..62925e98fa 100644
--- a/devtools/scumm-md5.txt
+++ b/devtools/scumm-md5.txt
@@ -21,9 +21,6 @@
# - Source
# -> The source of the information, useful in case it has to be verified
#
-# TODO: We really should have a separate target for "Misc FM-TOWNS demos", so
-# that their description in the launcher doesn't start with "Zak McKracken"
-#
#
# Table of email addresse of contributors: Sometimes we need to add new
# information to this table, or need to verify the correctness of an
@@ -55,6 +52,7 @@
maniac Maniac Mansion
2d624d1b214f7faf0094daea65c6d1a6 -1 en 2gs Apple II - -
+ 2cb46375dd5cdfd023e2f07e0a21b530 -1 en C64 C64 Demo - Robert Crossfield
eea4d9ac2fb6f145945a308e8866915b -1 en C64 C64 - -
439a7f4adf510489981ac52308e7d7a2 -1 de C64 C64 - -
@@ -483,9 +481,9 @@ fbpack Fatty Bear's Fun Pack
freddi Freddi Fish 1: The Case of the Missing Kelp Seeds
d4cccb5af88f3e77f370896e9ba8c5f9 -1 All Windows HE 71 - - sev
- c0039ad982999c92d0de81910d640fa0 -1 nl Windows HE 71 - - adutchguy
+ c0039ad982999c92d0de81910d640fa0 26159 nl Windows HE 71 - - adutchguy
68530d2e15f339fbbf3150b78b4d2ffb -1 en Mac HE 73 - - satz
- 6d1baa1065ac5f7b210be8ebe4235e49 -1 nl Mac HE 73 - - daniel9
+ 6d1baa1065ac5f7b210be8ebe4235e49 26384 nl Mac HE 73 - - daniel9
c782fbbe74a987c3df8ac73cd3e289ed -1 se Mac HE 73 - - Torbjіrn Andersson
5ebb57234b2fe5c5dff641e00184ad81 -1 fr Windows HE 73 - - gist974
cf8ef3a1fb483c5c4b1c584d1167b2c4 -1 de Windows HE 73 - - Oncer
@@ -516,7 +514,7 @@ freddi Freddi Fish 1: The Case of the Missing Kelp Seeds
freddi2 Freddi Fish 2: The Case of the Haunted Schoolhouse
0a295b80f9a9edf818e8e161a0e83830 -1 fr All HE 80 - - gist974, ThierryFR
fce4b8010704b103acfeea9413788f32 -1 de All HE 80 - - Joachim Eberhard
- 8e9830a6f2702be5b22c8fa0a6aaf977 -1 nl Mac HE 80 - - daniel9
+ 8e9830a6f2702be5b22c8fa0a6aaf977 65305 nl All HE 80 - - daniel9
5057fb0e99e5aa29df1836329232f101 -1 All Windows HE 80 - - sev
ac62d50e39492ee3738b4e83a5ac780f -1 nl Windows HE 80 - - joostp
151071053a1d0021198216713939521d -1 en Windows HE 80 - - vampir_raziel
@@ -564,7 +562,11 @@ freddi4 Freddi Fish 4: The Case of the Hogfish Rustlers of Briny Gulch
fa84cb1018103a4ee4e5fa8041c1d0d1 13609 de Windows - Demo - George Kormendi
ebd324dcf06a4c49e1ba5c231eee1060 -1 us All HE 99 Demo - sev
688328c5bdc4c8ec4145688dfa077bf2 -1 de All HE 99 Demo - Joachim Eberhard
- 03d3b18ee3fd68114e2a687c871e38d5 -1 us Windows HE 99 Mini Game - eriktorbjorn
+ 03d3b18ee3fd68114e2a687c871e38d5 13609 us Windows HE 99 Mini Game - eriktorbjorn
+ 9340b552b0f2dffe6d4f3d13ebebe832 13609 nl Windows HE 99 Mini Game - Ben Castricum
+ c486e4cfa7bd6f8efcd0740f96f7dde3 13609 fr Windows HE 99 Mini Game - Ben Castricum
+ 7a2b6d8e8a645c9d534c8c4edc38a9c9 13609 it Windows HE 99 Mini Game - Ben Castricum
+ 09b0be55c16cd9e88b5080bf89ff281d 13609 de Windows HE 99 Mini Game - Ben Castricum
16effd200aa6b8abe9c569c3e578814d -1 nl All HE 99 Demo - joostp
499c958affc394f2a3868f1eb568c3ee -1 nl All HE 99 Demo - adutchguy
5fdb2ac2483908b065c6e77988338a54 -1 nl Windows HE 99 Demo - Ben
@@ -577,6 +579,7 @@ freddicove Freddi Fish 5: The Case of the Creature of Coral Cove
590e6546aacd0d374b7f3a4f53013ab1 -1 All All - - - cyx
21abe302e1b1e2b66d6f5c12e241ebfd -1 ru Windows unenc Unencrypted - sev
b8955d7d23b4972229060d1592489fef -1 nl All HE 100 - - adutchguy, daniel9
+ 8f345db2f3f5a25ed6305001957e6f72 41182 nl All HE 100 - - Ben Castricum
b100abf7ff83146df50db78dbd5e9cfa -1 fr All HE 100 - - alamaz, gist974
4ce2d5b355964bbcb5e5ce73236ef868 -1 ru Windows HE 100 - - sev
@@ -624,9 +627,11 @@ farm Let's Explore the Farm with Buzzy
a5c5388da9bf0e6662fdca8813a79d13 86962 en Windows - - - George Kormendi
a85856675429fe88051744f755b72f93 -1 en Windows - - - Kirben
a2386da005672cbd5136f4f27a626c5f 87061 nl Windows - - - George Kormendi
+ eeb606c2d2ec877a712a9f20c10bcdda 87034 nl Mac - - - Ben Castricum
5dda73606533d66a4c3f4f9ea6e842af 87061 ru Windows - - - sev
39fd6db10d0222d817025c4d3346e3b4 -1 en Mac - Demo - Joachim Eberhard
+ 6c375c2236d99f56e6c2cf540e74e474 34333 nl Windows - Demo - Kirben
bf8b52fdd9a69c67f34e8e9fec72661c -1 en Windows HE 71 Demo - khalek, sev
0557df19f046a84c2fdc63507c6616cb -1 nl Windows HE 72 Demo - adutchguy
8d479e36f35e80257dfc102cf4b8a912 34333 en Windows HE 72 Demo - khalek, sev
@@ -678,7 +683,7 @@ pajama3 Pajama Sam 3: You Are What You Eat From Your Head to Your Feet
f7711f9264d4d43c2a1518ec7c10a607 79382 us All - - - Kirben
2e8a1f76ea33bc5e04347646feee173d -1 de All - - - Joachim Eberhard
aefa244ea034b7cd2041f0a44be7d9ba -1 en Mac - - - pix_climber
- 06c3cf4f31daad8b1cd93153491db9e6 -1 nl Mac - - - daniel9
+ 06c3cf4f31daad8b1cd93153491db9e6 79382 nl All - - - daniel9
7410a8ba9795020cd42f171c4320659e -1 fr Windows - - - gist974
20176076d708bf14407bcc9bdcd7a418 -1 ru Windows - - - sev
@@ -686,7 +691,11 @@ pajama3 Pajama Sam 3: You Are What You Eat From Your Head to Your Feet
a654fb60c3b67d6317a7894ffd9f25c5 -1 us All - Demo - sev
a9f2f04b1ecaab9495b59befffe9bf88 -1 us All - Demo - sev
0c45eb4baff0c12c3d9dfa889c8070ab 13884 de All - Demo - Joachim Eberhard
- 4fe6a2e8df3c4536b278fdd2fbcb181e -1 en Windows - Mini Game - Trekky
+ 4fe6a2e8df3c4536b278fdd2fbcb181e 13911 en Windows - Mini Game - Trekky
+ 24942a4200d99bdb4bdb78f9c7e07027 13911 nl Windows - Mini Game - Ben Castricum
+ faa89ab5e67ba4eebb4399f584f7490c 13911 fr Windows - Mini Game - Ben Castricum
+ d1a73e87564477c7c2dcc2b8f616ad0b 13911 it Windows - Mini Game - Ben Castricum
+ a8fcc3084ad5e3e569722755f205b1ef 13911 de Windows - Mini Game - Ben Castricum
679855cf61932f9bf995c8f3677380ed -1 fr Windows - Demo - Mevi
c8c5baadcbfc8d0372ed4335abace8a7 -1 fr Windows - Demo - Mevi
784b499c98d07260a30952685758636b 13911 de Windows - Demo - George Kormendi
@@ -723,6 +732,7 @@ puttrace Putt-Putt Enters the Race
62050da376483d8edcbd98cd26b6cb57 -1 ru Windows HE 99 - - sev
0ac41e2e3d2174e5a042a6b565328dba 13110 us All HE 98 Demo - sev
+ ee8cfeb76e55d43a01c25e0865a9db76 13135 nl Mac HE 98 Demo - Ben Castricum
6af2419fe3db5c2fdb091ae4e5833770 -1 nl All HE 98.5 Demo - Kirben
663743c03ae0c007f3d665cf631c0e6b 13135 de All HE 99 Demo - Joachim Eberhard
aaa587701cde7e74692c68c1024b85eb -1 nl All HE 99 Demo - joostp
@@ -812,7 +822,10 @@ PuttTime Putt-Putt Travels Through Time
59d5cfcc5e672a6e07baae01328b918b -1 fr All HE 90 Demo - Kirben
fbb697d89d2beca87360a145f467bdae -1 de All HE 90 Demo - Joachim Eberhard
6b19d0e25cbf720d05822379b8b90ed9 -1 nl All HE 90 Demo - adutchguy
- 0a6d7b81b850ed4a77811c60c9b5c555 -1 us Windows HE 99 Mini Game - eriktorbjorn
+ 0a6d7b81b850ed4a77811c60c9b5c555 18458 us Windows HE 99 Mini Game - eriktorbjorn
+ a71014c53a6d18c66ef2ea0ee42328e9 18458 nl Windows HE 99 Mini Game - Ben Castricum
+ 8dd4d590685c19bf651b5016e749ead2 18458 fr Windows HE 99 Mini Game - Ben Castricum
+ aef415cc5dc063e3668359c2657169f3 18458 de Windows HE 99 Mini Game - Ben Castricum
0ab19be9e2a3f6938226638b2a3744fe -1 us All HE 100 Demo - khalek
balloon Putt-Putt and Pep's Balloon-O-Rama
@@ -820,7 +833,7 @@ balloon Putt-Putt and Pep's Balloon-O-Rama
bab0fb81dcb12b8930c5d850b8f2a7de 12800 de Windows HE 80 - - George Kormendi
145bd3373574feb668cc2eea2ec6cf86 -1 ru Windows HE 80 - - sev
27b2ef1653089fe5b897d9cc89ce784f -1 ru Windows HE 80 - - George Kormendi
- 2232b0b9411575b1f9961713ebc9de61 -1 All Windows HE 80 - ES and NL exiltd (ES), Ben Castricum (NL)
+ 2232b0b9411575b1f9961713ebc9de61 -1 nl Windows HE 80 - - Ben Castricum
a22af0ad0e3126d19d22707b0267a37d -1 nl Windows HE 80 - - Ben Castricum
a56a05c6b865b9956639f8c51269e5ab -1 nl Mac HE 80 - - Ben Castricum
d7b247c26bf1f01f8f7daf142be84de3 -1 en Windows HE 99 Updated - iziku
@@ -876,12 +889,16 @@ spyfox2 SPY Fox 2: Some Assembly Required
bc4700bc0e12879f6d25d14d6be6cfdd -1 de All - - - Joachim Eberhard
cea91e3dd47f2518ea418e41611aa77f -1 ru All - - - sev
9fd66fb3b04703bd50da4356e4202558 51295 en Mac - - - pix_climber
- 71fe97c3108678cf604f14abe342341b -1 nl Windows - - - adutchguy
+ 71fe97c3108678cf604f14abe342341b 51286 nl All - - - adutchguy
1c792d28376d45e145cb916bca0400a2 -1 nl All - Demo - joostp
7222f260253f325c21fcfa68b5bfab67 -1 us All - Demo - Kirben
732845548b1d6c2da572cb6a1bf81b07 -1 de All - Demo - Joachim Eberhard
- e62056ba675ad65d8854ab3c5ad4b3c0 -1 en Windows - Mini Game - Trekky
+ e62056ba675ad65d8854ab3c5ad4b3c0 14689 en Windows - Mini Game - Trekky
+ 22c7432dc97a821fcfccd480e93e3911 14689 nl Windows - Mini Game - Ben Castricum
+ 6b10c9977cad9de503642059359792b1 14689 fr Windows - Mini Game - Ben Castricum
+ 9684c161258d68e0d464d6cab7024b9c 14689 it Windows - Mini Game - Ben Castricum
+ 7f2578d8d33a9ff525488a2d9ba617e4 14689 de Windows - Mini Game - Ben Castricum
22de86b2f7ec6e5db745ed1123310b44 15832 fr Windows - Demo - George Kormendi
204453e33456c4faa26e276229fe5b76 14689 de Windows - Demo - George Kormendi
19bf6938a94698296bcb0c99c31c91a7 -1 gb Windows - Demo - eriktorbjorn
diff --git a/dists/engine-data/kyra.dat b/dists/engine-data/kyra.dat
index 37b3b0ef0b..3ad01b868f 100644
--- a/dists/engine-data/kyra.dat
+++ b/dists/engine-data/kyra.dat
Binary files differ
diff --git a/dists/gcw0/default.gcw0.desktop b/dists/gcw0/default.gcw0.desktop
new file mode 100644
index 0000000000..46bd2be092
--- /dev/null
+++ b/dists/gcw0/default.gcw0.desktop
@@ -0,0 +1,16 @@
+[Desktop Entry]
+Name=ScummVM
+Comment=Interpreter for several adventure games
+Comment[pl]=Interpreter graficznych gier przygodowych
+Comment[sv]=Tolk fУЖr flera УЄventyrsspel
+Comment[he]=зЄзЈзЉзŸ зœзžзЁзЄзЈ зžзЉз—зЇз™ з”зЈзЄзЊзЇзз•зЊ
+Comment[de]=Interpreter fУМr diverse Abenteuerspiele
+Comment[es]=IntУЉrprete para varias aventuras grУЁficas
+Comment[ca]=IntУЈrpret per diverses aventures grУ fiques
+Exec=scummvm.sh
+Icon=scummvm
+Terminal=false
+Type=Application
+Categories=games
+StartupNotify=false
+X-OD-Manual=README
diff --git a/dists/gcw0/opk_make.sh b/dists/gcw0/opk_make.sh
new file mode 100755
index 0000000000..b1bfd03efb
--- /dev/null
+++ b/dists/gcw0/opk_make.sh
@@ -0,0 +1,111 @@
+#!/bin/bash
+#
+# opk_make.sh
+#
+# This script is meant to ease generation of a opk file. Please consult the output
+# when running --help for a list of available parameters and an explaination of
+# those.
+#
+# Required tools when running the script:
+# bash
+# echo, cat, mv, rm, mksquashfs
+
+check_for_tool()
+{
+ which $1 &> /dev/null
+ if [ "$?" -ne "0" ];
+ then
+ cecho "ERROR: Could not find the program '$1'. Please make sure
+that it is available in your PATH since it is required to complete your request." $red
+ exit 1
+ fi
+}
+
+print_help()
+{
+ cat << EOSTREAM
+opk_make.sh - A script to package "something" into a OPK.
+
+Usage:
+ $(basename ${0}) {--directory|-d} <folder> {--opk|-o} <file> [{--help|-h}]
+
+
+Switches:
+ --directory / -d Sets the folder that is to be used for the resulting opk
+ to <folder>. This option is mandatory for the script to
+ function correctly.
+
+ --help / -h Displays this help text.
+
+ --opkname / -o Sets the output filename of the resulting opk to <file>.
+ This option is mandatory for the script to function
+ correctly.
+
+A version >=4.0 of squashfs is required to be available in your PATH.
+EOSTREAM
+}
+
+
+# Parse command line parameters
+while [ "${1}" != "" ]; do
+ if [ "${1}" = "--directory" ] || [ "${1}" = "-d" ];
+ then
+ FOLDER=$2
+ shift 2
+ elif [ "${1}" = "--help" ] || [ "${1}" = "-h" ];
+ then
+ print_help
+ exit 0
+ elif [ "${1}" = "--opkname" ] || [ "${1}" = "-o" ];
+ then
+ OPKNAME=$2
+ shift 2
+ else
+ echo "ERROR: '$1' is not a known argument. Printing --help and aborting."
+ print_help
+ exit 1
+ fi
+done
+
+
+# Probe if required variables were set
+echo "Checking if all required variables were set."
+if [ ! $OPKNAME ] || [ ! $FOLDER ];
+then
+ echo "ERROR: Not all required options were set! Please see the --help information below."
+ print_help
+ exit 1
+else
+ echo "OPKNAME set to '$OPKNAME'."
+fi
+# Check if the selected folder actually exists
+if [ ! -d $FOLDER ];
+then
+ echo "ERROR: '$FOLDER' doesn't exist or is not a folder."
+ exit 1
+else
+ echo "FOLDER set to '$FOLDER'."
+fi
+
+# Make iso from folder
+echo "Creating an iso file based on '$FOLDER'."
+
+check_for_tool mksquashfs
+if [ $(mksquashfs -version | awk 'BEGIN{r=0} $3>=4{r=1} END{print r}') -eq 0 ];
+then
+ echo "ERROR: Your squashfs version is older then version 4, please upgrade to 4.0 or later"
+ exit 1
+fi
+mksquashfs $FOLDER $OPKNAME.opk -noappend -no-exports -no-xattrs
+
+# Final message
+if [ -f $OPKNAME ];
+then
+ echo "Successfully finished creating the opk '$OPKNAME'."
+else
+ echo "There seems to have been a problem and '$OPKNAME' was not created. Please check
+the output above for any error messages. A possible cause for this is that there was
+not enough space available."
+ exit 1
+fi
+
diff --git a/dists/gcw0/scummvm.png b/dists/gcw0/scummvm.png
new file mode 100644
index 0000000000..128e59efc4
--- /dev/null
+++ b/dists/gcw0/scummvm.png
Binary files differ
diff --git a/dists/gcw0/scummvm.sh b/dists/gcw0/scummvm.sh
new file mode 100755
index 0000000000..c12a3030cc
--- /dev/null
+++ b/dists/gcw0/scummvm.sh
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+cd `dirname $0`
+
+if [ ! -f $HOME/.scummvmrc ] ; then
+ cp ./scummvmrc $HOME/.scummvmrc
+fi
+
+exec ./scummvm
diff --git a/dists/gcw0/scummvmrc b/dists/gcw0/scummvmrc
new file mode 100644
index 0000000000..c2087c222a
--- /dev/null
+++ b/dists/gcw0/scummvmrc
@@ -0,0 +1,9 @@
+[scummvm]
+fullscreen=true
+gfx_mode=1x
+aspect_ratio=true
+themepath=./themes
+browser_lastpath=/media
+extrapath=./engine-data
+pluginspath=./plugins
+joystick_num=0
diff --git a/engines/access/access.cpp b/engines/access/access.cpp
new file mode 100644
index 0000000000..7f59ae7ad6
--- /dev/null
+++ b/engines/access/access.cpp
@@ -0,0 +1,575 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public 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 "graphics/scaler.h"
+#include "graphics/thumbnail.h"
+#include "access/access.h"
+
+namespace Access {
+
+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;
+ _debugger = nullptr;
+ _events = nullptr;
+ _files = nullptr;
+ _inventory = nullptr;
+ _midi = nullptr;
+ _player = nullptr;
+ _room = nullptr;
+ _screen = nullptr;
+ _scripts = nullptr;
+ _sound = nullptr;
+ _video = nullptr;
+
+ _destIn = nullptr;
+ _current = nullptr;
+ _mouseMode = 0;
+ _currentMan = 0;
+ _currentManOld = -1;
+ _converseMode = 0;
+ _startAboutBox = 0;
+ _startTravelBox = 0;
+ _numAnimTimers = 0;
+ _startup = 0;
+ _currentCharFlag = false;
+ _boxSelect = false;
+ _scale = 0;
+ _scaleH1 = _scaleH2 = 0;
+ _scaleN1 = 0;
+ _scaleT1 = 0;
+ _scaleMaxY = 0;
+ _scaleI = 0;
+ _scrollCol = _scrollRow = 0;
+ _scrollX = _scrollY = 0;
+ _imgUnscaled = false;
+ _canSaveLoad = false;
+ _establish = nullptr;
+
+ _conversation = 0;
+ _currentMan = 0;
+ _newTime = 0;
+ _newDate = 0;
+ Common::fill(&_objectsTable[0], &_objectsTable[100], (SpriteResource *)nullptr);
+ Common::fill(&_establishTable[0], &_establishTable[100], false);
+ Common::fill(&_flags[0], &_flags[256], 0);
+ _establishFlag = false;
+ _establishMode = 0;
+ _establishGroup = 0;
+ _establishCtrlTblOfs = 0;
+ _lastTime = g_system->getMillis();
+ _curTime = 0;
+ _narateFile = 0;
+ _txtPages = 0;
+ _sndSubFile = 0;
+ _loadSaveSlot = -1;
+ _vidX = _vidY = 0;
+ _cheatFl = false;
+ _restartFl = false;
+ _printEnd = 0;
+}
+
+AccessEngine::~AccessEngine() {
+ delete _animation;
+ delete _bubbleBox;
+ delete _char;
+ delete _debugger;
+ delete _events;
+ delete _files;
+ delete _inventory;
+ delete _midi;
+ delete _player;
+ delete _room;
+ delete _screen;
+ delete _scripts;
+ delete _sound;
+ delete _video;
+
+ freeCells();
+ delete _establish;
+}
+
+void AccessEngine::setVGA() {
+ initGraphics(320, 200, false);
+}
+
+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");
+ DebugMan.addDebugChannel(kDebugSound, "sound", "Sound and Music handling");
+
+ if (isCD()) {
+ const Common::FSNode gameDataDir(ConfMan.get("path"));
+ // 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" :
+ Common::String::format("chap%.2d", idx);
+ SearchMan.addSubDirectoryMatching(cdromDir, folder);
+ }
+ }
+
+ // Create sub-objects of the engine
+ _animation = new AnimationManager(this);
+ _bubbleBox = new BubbleBox(this);
+ _char = new CharManager(this);
+ _debugger = Debugger::init(this);
+ _events = new EventsManager(this);
+ _files = new FileManager(this);
+ _inventory = new InventoryManager(this);
+ _player = Player::init(this);
+ _screen = new Screen(this);
+ _sound = new SoundManager(this, _mixer);
+ _midi = new MusicManager(this);
+ _video = new VideoPlayer(this);
+
+ _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")) {
+ int saveSlot = ConfMan.getInt("save_slot");
+ if (saveSlot >= 0 && saveSlot <= 999)
+ _loadSaveSlot = saveSlot;
+ }
+}
+
+Common::Error AccessEngine::run() {
+ setVGA();
+ initialize();
+
+ playGame();
+
+ return Common::kNoError;
+}
+
+int AccessEngine::getRandomNumber(int maxNumber) {
+ return _randomSource.getRandomNumber(maxNumber);
+}
+
+void AccessEngine::loadCells(Common::Array<CellIdent> &cells) {
+ for (uint i = 0; i < cells.size(); ++i) {
+ Resource *spriteData = _files->loadFile(cells[i]);
+ _objectsTable[cells[i]._cell] = new SpriteResource(this, spriteData);
+ delete spriteData;
+ }
+}
+
+void AccessEngine::freeCells() {
+ for (int i = 0; i < 100; ++i) {
+ delete _objectsTable[i];
+ _objectsTable[i] = nullptr;
+ }
+}
+
+void AccessEngine::speakText(ASurface *s, const Common::String &msg) {
+ Common::String lines = msg;
+ Common::String line;
+ int curPage = 0;
+ int soundsLeft = 0;
+
+ while (!shouldQuit()) {
+ soundsLeft = _countTbl[curPage];
+ _events->zeroKeys();
+
+ int width = 0;
+ bool lastLine = _fonts._font2.getLine(lines, 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 ((s->_printOrg.y > _printEnd) && (!lastLine)) {
+ _events->clearEvents();
+ while (!shouldQuit()) {
+ _sound->freeSounds();
+ _sound->loadSoundTable(0, _narateFile + 99, _sndSubFile);
+ _sound->playSound(0);
+
+ while(_sound->isSFXPlaying() && !shouldQuit())
+ _events->pollEvents();
+
+ _scripts->cmdFreeSound();
+
+ if (_events->isKeyMousePressed()) {
+ _sndSubFile += soundsLeft;
+ break;
+ } else {
+ ++_sndSubFile;
+ --soundsLeft;
+ if (soundsLeft == 0)
+ break;
+ _events->clearEvents();
+ }
+ }
+
+ s->copyBuffer(&_buffer2);
+ s->_printOrg.y = s->_printStart.y;
+ ++curPage;
+ soundsLeft = _countTbl[curPage];
+ }
+
+ if (lastLine)
+ break;
+ }
+
+ while (soundsLeft) {
+ _sound->freeSounds();
+ Resource *res = _sound->loadSound(_narateFile + 99, _sndSubFile);
+ _sound->_soundTable.push_back(SoundEntry(res, 1));
+ _sound->playSound(0);
+
+ while(_sound->isSFXPlaying() && !shouldQuit())
+ _events->pollEvents();
+
+ _scripts->cmdFreeSound();
+
+ if (_events->_leftButton) {
+ _events->debounceLeft();
+ _sndSubFile += soundsLeft;
+ break;
+ } else if (_events->isKeyPending()) {
+ _sndSubFile += soundsLeft;
+ break;
+ } else {
+ ++_sndSubFile;
+ --soundsLeft;
+ }
+ }
+}
+
+void AccessEngine::printText(ASurface *s, const Common::String &msg) {
+ Common::String lines = msg;
+ Common::String line;
+ int width = 0;
+
+ for (;;) {
+ bool lastLine = _fonts._font2.getLine(lines, 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 (s->_printOrg.y >_printEnd && !lastLine) {
+ _events->waitKeyMouse();
+ s->copyBuffer(&_buffer2);
+ s->_printOrg.y = s->_printStart.y;
+ }
+
+ if (lastLine)
+ break;
+ }
+ _events->waitKeyMouse();
+}
+
+
+void AccessEngine::plotList() {
+ _player->calcPlayer();
+ plotList1();
+}
+
+void AccessEngine::plotList1() {
+ for (uint idx = 0; idx < _images.size(); ++idx) {
+ ImageEntry &ie = _images[idx];
+
+ _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 (!_imgUnscaled) {
+ bounds.setWidth(_screen->_scaleTable1[frame->w]);
+ 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 |= IMGFLAG_CROPPED;
+ } else {
+ ie._flags &= ~IMGFLAG_CROPPED;
+ if (_buffer2._leftSkip != 0 || _buffer2._rightSkip != 0
+ || _buffer2._topSkip != 0 || _buffer2._bottomSkip != 0)
+ ie._flags |= IMGFLAG_CROPPED;
+
+ _newRects.push_back(bounds);
+
+ if (!_imgUnscaled) {
+ _buffer2._rightSkip /= _scale;
+ bounds.setWidth(bounds.width() / _scale);
+
+ if (ie._flags & IMGFLAG_BACKWARDS) {
+ _buffer2.sPlotB(frame, destBounds);
+ } else {
+ _buffer2.sPlotF(frame, destBounds);
+ }
+ } else {
+ if (ie._flags & IMGFLAG_BACKWARDS) {
+ _buffer2.plotB(frame, Common::Point(destBounds.left, destBounds.top));
+ } else {
+ _buffer2.plotF(frame, Common::Point(destBounds.left, destBounds.top));
+ }
+ }
+ }
+
+ ie._flags |= IMGFLAG_DRAWN;
+ }
+}
+
+void AccessEngine::copyBlocks() {
+ // Copy the block list from the previous frame
+ for (uint i = 0; i < _oldRects.size(); ++i) {
+ _screen->copyBlock(&_buffer2, _oldRects[i]);
+ }
+
+ copyRects();
+}
+
+void AccessEngine::copyRects() {
+ _oldRects.clear();
+ for (uint i = 0; i < _newRects.size(); ++i) {
+ _screen->copyBlock(&_buffer2, _newRects[i]);
+ _oldRects.push_back(_newRects[i]);
+ }
+}
+
+void AccessEngine::copyBF1BF2() {
+ _buffer2.copyRectToSurface(_buffer1, 0, 0,
+ Common::Rect(_scrollX, _scrollY,
+ _scrollX + _screen->_vWindowBytesWide,
+ _scrollY + _screen->_vWindowLinesTall));
+}
+
+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;
+ }
+
+ // 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) {
+ _video->setVideo(_screen, pt, FileIdent(96, videoNum), 10);
+
+ while (!shouldQuit() && !_video->_videoEnd) {
+ _video->playVideo();
+ _events->pollEventsAndWait();
+ }
+}
+
+void AccessEngine::doLoadSave() {
+ error("TODO: doLoadSave");
+}
+
+void AccessEngine::freeChar() {
+ _scripts->freeScriptData();
+ _animation->clearTimers();
+ _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 = FN_CLEAR1;
+ _timers._timersSavedFlag = false;
+ _events->clearEvents();
+
+ 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);
+ s.syncAsUint32LE(_newTime);
+ s.syncAsUint32LE(_newDate);
+
+ for (int i = 0; i < 256; ++i)
+ s.syncAsUint16LE(_flags[i]);
+ for (int i = 0; i < 100; ++i)
+ s.syncAsByte(_establishTable[i]);
+
+ // Synchronize sub-objects
+ _timers.synchronize(s);
+ _inventory->synchronize(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->writeString(header._saveName);
+ 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());
+}
+
+bool AccessEngine::shouldQuitOrRestart() {
+ return shouldQuit() || _restartFl;
+}
+} // End of namespace Access
diff --git a/engines/access/access.h b/engines/access/access.h
new file mode 100644
index 0000000000..be007e0cb8
--- /dev/null
+++ b/engines/access/access.h
@@ -0,0 +1,296 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public 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/savefile.h"
+#include "common/serializer.h"
+#include "common/util.h"
+#include "engines/engine.h"
+#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"
+#include "access/files.h"
+#include "access/font.h"
+#include "access/inventory.h"
+#include "access/player.h"
+#include "access/room.h"
+#include "access/screen.h"
+#include "access/scripts.h"
+#include "access/sound.h"
+#include "access/video.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 {
+
+enum {
+ GType_Amazon = 1,
+ GType_MartianMemorandum = 2,
+ GType_Noctropolis = 3
+};
+
+enum AccessDebugChannels {
+ kDebugPath = 1 << 0,
+ kDebugScripts = 1 << 1,
+ kDebugGraphics = 1 << 2,
+ kDebugSound = 1 << 3
+};
+
+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;
+
+ /**
+ * Handles basic initialization
+ */
+ void initialize();
+
+ /**
+ * Set VGA mode
+ */
+ void setVGA();
+
+protected:
+ const AccessGameDescription *_gameDescription;
+ Common::RandomSource _randomSource;
+ int _loadSaveSlot;
+
+ /**
+ * Main handler for showing game rooms
+ */
+ void doRoom();
+
+ /**
+ * Support method that generates a savegame name
+ * @param slot Slot number
+ */
+ Common::String generateSaveName(int slot);
+
+ /**
+ * Play back an entire video
+ */
+ void playVideo(int videoNum, const Common::Point &pt);
+
+ // Engine APIs
+ virtual Common::Error run();
+ virtual bool hasFeature(EngineFeature f) const;
+protected:
+ /**
+ * Play the game
+ */
+ virtual void playGame() = 0;
+
+ /**
+ * Synchronize savegame data
+ */
+ virtual void synchronize(Common::Serializer &s);
+public:
+ AnimationManager *_animation;
+ BubbleBox *_bubbleBox;
+ CharManager *_char;
+ Debugger *_debugger;
+ EventsManager *_events;
+ FileManager *_files;
+ InventoryManager *_inventory;
+ Player *_player;
+ Room *_room;
+ Screen *_screen;
+ Scripts *_scripts;
+ SoundManager *_sound;
+ MusicManager *_midi;
+ VideoPlayer *_video;
+
+ ASurface *_destIn;
+ ASurface *_current;
+ ASurface _buffer1;
+ ASurface _buffer2;
+ ASurface _vidBuf;
+ int _vidX, _vidY;
+ Common::Array<CharEntry *> _charTable;
+ SpriteResource *_objectsTable[100];
+ bool _establishTable[100];
+ bool _establishFlag;
+ int _establishMode;
+ int _establishGroup;
+ int _establishCtrlTblOfs;
+ int _numAnimTimers;
+ TimerList _timers;
+ DeathList _deaths;
+ FontManager _fonts;
+ Common::Array<Common::Rect> _newRects;
+ Common::Array<Common::Rect> _oldRects;
+ Common::Array<ExtraCell> _extraCells;
+ ImageEntryList _images;
+ int _mouseMode;
+
+ int _currentManOld;
+ int _converseMode;
+ int _startAboutBox;
+ int _startTravelBox;
+ bool _currentCharFlag;
+ bool _boxSelect;
+ int _scale;
+ int _scaleH1, _scaleH2;
+ int _scaleN1;
+ int _scaleT1;
+ int _scaleMaxY;
+ int _scaleI;
+ int _scrollX, _scrollY;
+ int _scrollCol, _scrollRow;
+ bool _imgUnscaled;
+ bool _canSaveLoad;
+
+ Resource *_establish;
+ int _printEnd;
+ int _txtPages;
+ int _narateFile;
+ int _sndSubFile;
+ int _countTbl[6];
+
+ // Fields that are included in savegames
+ int _conversation;
+ int _currentMan;
+ uint32 _newTime;
+ uint32 _newDate;
+ int _flags[256];
+
+ bool _clearSummaryFlag;
+ bool _cheatFl;
+ bool _restartFl;
+ // Fields mapped into the flags array
+ int &_useItem;
+ int &_startup;
+ int &_manScaleOff;
+
+public:
+ AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc);
+ virtual ~AccessEngine();
+
+ virtual void dead(int deathId) = 0;
+
+ uint32 getFeatures() const;
+ bool isCD() const;
+ bool isDemo() const;
+ Common::Language getLanguage() const;
+ Common::Platform getPlatform() const;
+ uint16 getVersion() const;
+ uint32 getGameID() const;
+ uint32 getGameFeatures() const;
+ bool shouldQuitOrRestart();
+
+ int getRandomNumber(int maxNumber);
+
+ void loadCells(Common::Array<CellIdent> &cells);
+
+ /**
+ * Free the sprites list
+ */
+ void freeCells();
+
+ virtual void establish(int esatabIndex, int sub) = 0;
+
+ void plotList();
+ void plotList1();
+
+ void copyBlocks();
+
+ void copyRects();
+
+ void copyBF1BF2();
+
+ void copyBF2Vid();
+
+ void doLoadSave();
+
+ void freeChar();
+
+ /**
+ * Draw a string on a given surface and update text positioning
+ */
+ void printText(ASurface *s, const Common::String &msg);
+ void speakText(ASurface *s, const Common::String &msg);
+
+ /**
+ * 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);
+};
+
+} // End of namespace Access
+
+#endif /* ACCESS_ACCESS_H */
diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp
new file mode 100644
index 0000000000..4c9df7b8ff
--- /dev/null
+++ b/engines/access/amazon/amazon_game.cpp
@@ -0,0 +1,786 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public 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/amazon/amazon_game.h"
+#include "access/amazon/amazon_resources.h"
+#include "access/amazon/amazon_room.h"
+#include "access/amazon/amazon_scripts.h"
+
+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]) {
+ _ant = nullptr;
+ _cast = nullptr;
+ _guard = nullptr;
+ _jungle = nullptr;
+ _opening = nullptr;
+ _plane = nullptr;
+ _river = nullptr;
+
+ _charSegSwitch = false;
+
+ _oldTitleChapter = _chapter = 0;
+ _updateChapter = -1;
+ _rawInactiveX = 0;
+ _rawInactiveY = 0;
+ _inactiveYOff = 0;
+ _hintLevel = 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;
+
+ _chapter = 0;
+ _rawInactiveX = _rawInactiveY = 0;
+ _inactiveYOff = 0;
+ _hintLevel = 0;
+ _updateChapter = 0;
+ _oldTitleChapter = 0;
+ _iqValue = 0;
+
+ _chapterCells.push_back(CellIdent(0, 96, 17));
+ _inactive._spritesPtr = nullptr;
+ _inactive._flags = _inactive._frameNumber = _inactive._offsetY = 0;
+ _inactive._position = Common::Point(0, 0);
+}
+
+AmazonEngine::~AmazonEngine() {
+ delete _inactive._altSpritesPtr;
+
+ delete _ant;
+ delete _cast;
+ delete _guard;
+ delete _jungle;
+ delete _opening;
+ delete _plane;
+ delete _river;
+}
+
+void AmazonEngine::freeInactivePlayer() {
+ delete _inactive._altSpritesPtr;
+ _inactive._altSpritesPtr = nullptr;
+}
+
+void AmazonEngine::configSelect() {
+ // Initialize fields contained in the config file.
+ _hintLevel = 3;
+}
+
+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();
+ if (shouldQuit())
+ return;
+ }
+
+ 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();
+ } while (_restartFl);
+}
+
+void AmazonEngine::setupGame() {
+ // Load death list
+ 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];
+ }
+ }
+ _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
+ _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
+ if (isDemo())
+ _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->setNormalCursor(CURSOR_CROSSHAIRS);
+ _mouseMode = 0;
+ _numAnimTimers = 0;
+}
+
+void AmazonEngine::establish(int screenId, int esatabIndex) {
+ _establishMode = 0;
+ _establishGroup = 0;
+ doEstablish(screenId, esatabIndex);
+}
+
+void AmazonEngine::establishCenter(int screenId, int esatabIndex) {
+ _establishMode = 1;
+ doEstablish(screenId, esatabIndex);
+}
+
+const char *const _estTable[] = { "ETEXT0.DAT", "ETEXT1.DAT", "ETEXT2.DAT", "ETEXT3.DAT" };
+
+void AmazonEngine::loadEstablish(int estabIndex) {
+ if (!_files->existFile("ETEXT.DAT")) {
+ int oldGroup = _establishGroup;
+ _establishGroup = 0;
+
+ _establish = _files->loadFile(_estTable[oldGroup]);
+ _establishCtrlTblOfs = READ_LE_UINT16(_establish->data());
+
+ int ofs = _establishCtrlTblOfs + (estabIndex * 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(_establish->data() + idx + 4);
+ for (int i = 0; i < _txtPages; ++i)
+ _countTbl[i] = READ_LE_UINT16(_establish->data() + idx + 6 + (2 * i));
+ } else {
+ _establishGroup = 0;
+ _narateFile = 0;
+ _txtPages = 0;
+ _sndSubFile = 0;
+ _establish = _files->loadFile("ETEXT.DAT");
+ }
+}
+
+void AmazonEngine::doEstablish(int screenId, int estabIndex) {
+ _establishMode = 1;
+
+ _events->clearEvents();
+ _screen->forceFadeOut();
+ _screen->clearScreen();
+ _screen->setPanel(3);
+
+ if (screenId != -1) {
+ _files->loadScreen(95, screenId);
+ _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(estabIndex);
+ 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);
+
+ if ((_txtPages == 0) || !isCD()) {
+ printText(_screen, msg);
+ } else {
+ speakText(_screen, msg);
+ }
+
+ _screen->forceFadeOut();
+ _screen->clearScreen();
+
+ delete _establish;
+ _establish = nullptr;
+
+ if (_establishMode == 0)
+ _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() {
+ if (!_screen->_vesaMode)
+ return;
+
+ if (!_clearSummaryFlag && (_oldTitleChapter == _chapter))
+ return;
+
+ _oldTitleChapter = _chapter;
+ int idx = _chapter - 1;
+
+ if (!_files->existFile(_tileFiles[idx]))
+ return;
+
+ 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] = res->_stream->readByte();
+
+ // CHECKME: Depending on the Vesa mode during initialization, 400 or 480
+ 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");
+ }
+
+ delete res;
+}
+
+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::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() {
+ 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 scoreIQ = Common::String::format("%d", _iqValue);
+ while (scoreIQ.size() < 4)
+ scoreIQ = " " + scoreIQ;
+
+ iqText += scoreIQ;
+ 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) {
+ _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(const Common::String str) {
+ _events->hideCursor();
+ if (_useItem == 0) {
+ _buffer2.copyBuffer(_screen);
+ if (_screen->_vesaMode) {
+ _screen->setPanel(2);
+ _screen->saveScreen();
+ }
+ _screen->savePalette();
+ _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(str);
+}
+
+void AmazonEngine::startChapter(int chapter) {
+ _chapter = chapter;
+ assert(_chapter <= 14);
+
+ if (chapter != 1) {
+ _room->clearRoom();
+ freeChar();
+
+ _midi->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->freeSounds();
+
+ if (isCD()) {
+ _sound->loadSoundTable(0, 115, 0);
+ _sound->loadSoundTable(1, 115, 1);
+ _sound->playSound(0);
+ _sound->playSound(1);
+
+ _sound->freeSounds();
+ }
+
+ // Wait loop
+ while (!shouldQuit() && !_events->isKeyMousePressed() && _timers[20]._flag) {
+ _events->pollEventsAndWait();
+ }
+ }
+
+ _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.blitFrom(*_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], 0,
+ Common::Point(chapImg[3], chapImg[4]));
+ if (chapter == 14)
+ _screen->plotImage(_objectsTable[_chapter], 1, Common::Point(169, 76));
+
+ _midi->newMusic(chapImg[4], 1);
+ _midi->newMusic(33, 0);
+ _screen->forceFadeIn();
+
+ _timers[20]._timer = 950;
+ _timers[20]._initTm = 950;
+ _timers[20]._flag++;
+
+ // Wait loop
+ while (!shouldQuit() && !_events->isKeyMousePressed() && _timers[20]._flag) {
+ _events->pollEventsAndWait();
+ }
+ if (shouldQuit())
+ return;
+
+ _screen->forceFadeOut();
+ _events->debounceLeft();
+ _events->zeroKeys();
+
+ _screen->clearBuffer();
+ _files->loadScreen(96, 16);
+ _buffer2.blitFrom(*_screen);
+ _screen->plotImage(_objectsTable[0], chapImg[0], Common::Point(90, 7));
+
+ _midi->newMusic(7, 1);
+ _midi->newMusic(34, 0);
+
+ _screen->forceFadeIn();
+ _buffer2.blitFrom(*_screen);
+
+ _fonts._charSet._lo = 1;
+ _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(_establish->data() + ((0x40 + _chapter) * 2) + 2);
+ _printEnd = 170;
+
+ Common::String msg((const char *)_establish->data() + msgOffset);
+
+ if ((_txtPages == 0) || !isCD()) {
+ printText(_screen, msg);
+ } else {
+ speakText(_screen, msg);
+ }
+ if (shouldQuit())
+ return;
+
+ _screen->forceFadeOut();
+ _screen->clearBuffer();
+ freeCells();
+
+ _midi->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 = FN_CLEAR1;
+ _converseMode = 0;
+
+ _scripts->cmdRetPos();
+ }
+}
+
+
+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));
+
+ _screen->clearScreen();
+ _screen->setPanel(3);
+
+ if ((deathId == 10) && !isDemo()) {
+ quitGame();
+ _events->pollEvents();
+ return;
+ } else {
+ if (!isDemo())
+ _midi->newMusic(62, 0);
+ _files->_setPaletteFlag = false;
+ _files->loadScreen(94, 0);
+ _files->_setPaletteFlag = true;
+ _buffer2.blitFrom(*_screen);
+
+ if (!isDemo() || deathId != 10) {
+ for (int i = 0; i < 3; ++i) {
+ _sound->playSound(0);
+ _screen->forceFadeIn();
+ _sound->playSound(0);
+ _screen->forceFadeOut();
+
+ _events->pollEvents();
+ if (shouldQuit())
+ return;
+ }
+ }
+
+ if (!isDemo()) {
+ 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();
+
+ _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();
+ }
+
+ // The original was jumping to the restart label in main
+ _restartFl = true;
+ _events->pollEvents();
+ }
+}
+
+void AmazonEngine::synchronize(Common::Serializer &s) {
+ AccessEngine::synchronize(s);
+
+ s.syncAsSint16LE(_chapter);
+ s.syncAsSint16LE(_rawInactiveX);
+ s.syncAsSint16LE(_rawInactiveY);
+ s.syncAsSint16LE(_inactiveYOff);
+
+ for (int i = 0; i < 366; ++i) {
+ s.syncAsByte(_help1[i]);
+ s.syncAsByte(_help2[i]);
+ s.syncAsByte(_help3[i]);
+ }
+
+ _river->synchronize(s);
+ _ant->synchronize(s);
+}
+
+} // 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 0000000000..8f6dffe28c
--- /dev/null
+++ b/engines/access/amazon/amazon_game.h
@@ -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.
+ *
+ */
+
+#ifndef ACCESS_AMAZON_GAME_H
+#define ACCESS_AMAZON_GAME_H
+
+#include "access/access.h"
+#include "access/amazon/amazon_logic.h"
+
+namespace Access {
+
+namespace Amazon {
+
+class AmazonEngine;
+
+class AmazonEngine : public AccessEngine {
+private:
+ byte _tileData[1455];
+ Common::Array<CellIdent> _chapterCells;
+
+ /**
+ * Setup variables for the game
+ */
+ void setupGame();
+
+ /**
+ * Initialize variables found in the config file
+ */
+ void configSelect();
+
+ void initVariables();
+ void initObjects();
+ void calcIQ();
+ void helpTitle();
+ void drawHelpText(const Common::String &msg);
+ void loadEstablish(int estabIndex);
+ void doEstablish(int screenId, int estabIndex);
+
+protected:
+ /**
+ * Play the game
+ */
+ virtual void playGame();
+
+ /**
+ * Synchronize savegame data
+ */
+ virtual void synchronize(Common::Serializer &s);
+public:
+ InactivePlayer _inactive;
+ bool _charSegSwitch;
+ byte _help1[366];
+ byte _help2[366];
+ byte _help3[366];
+ byte *_helpTbl[3];
+
+ // 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;
+
+ // Saved fields
+ int _chapter;
+ int _rawInactiveX;
+ int _rawInactiveY;
+ int _inactiveYOff;
+
+ // Other game specific fields
+ Ant *_ant;
+ Cast *_cast;
+ Guard *_guard;
+ Jungle *_jungle;
+ Opening *_opening;
+ Plane *_plane;
+ River *_river;
+ int _hintLevel;
+ int _updateChapter;
+ int _oldTitleChapter;
+ int _iqValue;
+public:
+ AmazonEngine(OSystem *syst, const AccessGameDescription *gameDesc);
+
+ virtual ~AmazonEngine();
+
+ virtual void dead(int deathId);
+
+ /**
+ * Free the inactive player data
+ */
+ void freeInactivePlayer();
+
+ void drawHelp(const Common::String str);
+
+ virtual void establish(int esatabIndex, int sub);
+
+ void tileScreen();
+ void updateSummary(int chap);
+ void establishCenter(int screenId, int esatabIndex);
+
+ /**
+ * Show the start of a chapter
+ */
+ void startChapter(int chapter);
+};
+
+} // End of namespace Amazon
+
+} // End of namespace Access
+
+#endif /* ACCESS_ACCESS_H */
diff --git a/engines/access/amazon/amazon_logic.cpp b/engines/access/amazon/amazon_logic.cpp
new file mode 100644
index 0000000000..6dffb85e5e
--- /dev/null
+++ b/engines/access/amazon/amazon_logic.cpp
@@ -0,0 +1,2230 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public 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"
+#include "access/amazon/amazon_resources.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;
+}
+
+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);
+ }
+}
+
+/*------------------------------------------------------------------------*/
+
+CampScene::CampScene(AmazonEngine *vm) : PannedScene(vm) {
+ _skipStart = false;
+}
+
+void CampScene::mWhileDoOpen() {
+ Screen &screen = *_vm->_screen;
+ EventsManager &events = *_vm->_events;
+
+ screen.setDisplayScan();
+ events.hideCursor();
+ screen.forceFadeOut();
+ _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.blitFrom(*_vm->_screen);
+ _vm->_buffer1.blitFrom(*_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->_midi->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 (_vm->_events->isKeyMousePressed()) {
+ _skipStart = true;
+ _vm->_midi->newMusic(10, 1);
+ 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;
+ }
+}
+
+/*------------------------------------------------------------------------*/
+
+Opening::Opening(AmazonEngine *vm) : CampScene(vm) {
+ _pCount = 0;
+}
+
+void Opening::doIntroduction() {
+ Screen &screen = *_vm->_screen;
+
+ screen.setInitialPalettte();
+ _vm->_events->setCursor(CURSOR_ARROW);
+ _vm->_events->showCursor();
+ screen.setPanel(0);
+ screen.setPalette();
+
+ _vm->_events->setCursor(CURSOR_ARROW);
+ _vm->_events->showCursor();
+ screen.setPanel(3);
+ doTitle();
+
+ if (_vm->shouldQuit() || _skipStart || _vm->isDemo())
+ return;
+
+ 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], _vm->isDemo()? 24 : 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::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) {
+ _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) {
+ _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) {
+ _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) {
+ _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) {
+ _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], 11, Common::Point(125, 30));
+ _vm->_buffer2.plotImage(_vm->_objectsTable[0], 4, Common::Point(115, 45));
+ }
+}
+
+void Opening::scrollTitle() {
+ _vm->copyBF1BF2();
+ _vm->_newRects.clear();
+ if (_vm->isDemo())
+ doCreditDemo();
+ else
+ doCredit();
+ _vm->copyRects();
+ _vm->copyBF2Vid();
+}
+
+void Opening::doTitle() {
+ Screen &screen = *_vm->_screen;
+
+ screen.setDisplayScan();
+
+ screen.forceFadeOut();
+ _vm->_events->hideCursor();
+
+ if (!_vm->isDemo()) {
+ _vm->_sound->loadSoundTable(0, 98, 30);
+ _vm->_sound->loadSoundTable(1, 98, 8);
+
+ _vm->_files->_setPaletteFlag = false;
+ _vm->_files->loadScreen(0, 3);
+
+ _vm->_buffer2.copyFrom(*_vm->_screen);
+ _vm->_buffer1.copyFrom(*_vm->_screen);
+ 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;
+
+ Resource *spriteData = _vm->_files->loadFile(0, 2);
+ _vm->_objectsTable[0] = new SpriteResource(_vm, spriteData);
+ delete spriteData;
+
+ _vm->_files->_setPaletteFlag = false;
+ _vm->_files->loadScreen(0, 4);
+ _vm->_sound->playSound(1);
+
+ _vm->_buffer2.copyFrom(*_vm->_screen);
+ _vm->_buffer1.copyFrom(*_vm->_screen);
+
+ const int COUNTDOWN[6] = { 2, 0x80, 1, 0x7d, 0, 0x87 };
+ for (_pCount = 0; _pCount < 3 && !_vm->shouldQuit(); ++_pCount) {
+ _vm->_buffer2.blitFrom(_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->_buffer2.copyTo(_vm->_screen);
+
+ _vm->_sound->playSound(1);
+ _vm->_events->_vbCount = 70;
+ while (!_vm->shouldQuit() && _vm->_events->_vbCount > 0 && !_skipStart) {
+ _vm->_events->pollEventsAndWait();
+ if (_vm->_events->_rightButton)
+ _skipStart = true;
+ }
+ }
+ if (_vm->shouldQuit())
+ return;
+
+ _vm->_sound->stopSound();
+ _vm->_sound->playSound(0);
+ 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->_files->_setPaletteFlag = false;
+ _vm->_files->loadScreen(0, 5);
+ _vm->_buffer2.blitFrom(*_vm->_screen);
+ _vm->_buffer1.blitFrom(*_vm->_screen);
+ 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;
+ }
+
+ _vm->_midi->newMusic(1, 1);
+ _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();
+ _vm->_scrollRow = _vm->_scrollCol = 0;
+ _vm->_scrollX = _vm->_scrollY = 0;
+ _vm->_player->_rawPlayer = Common::Point(0, 0);
+ screen.forceFadeOut();
+ _vm->_room->buildScreen();
+ _vm->copyBF2Vid();
+ screen.forceFadeIn();
+ _vm->_oldRects.clear();
+ _vm->_newRects.clear();
+ _vm->_events->clearEvents();
+ _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->_scrollCol + screen._vWindowWidth != _vm->_room->_playFieldWidth) {
+ _vm->_scrollX += _vm->_player->_scrollAmount;
+
+ while (_vm->_scrollX >= TILE_WIDTH) {
+ _vm->_scrollX -= TILE_WIDTH;
+ ++_vm->_scrollCol;
+
+ _vm->_buffer1.moveBufferLeft();
+ _vm->_room->buildColumn(_vm->_scrollCol + screen._vWindowWidth, screen._vWindowBytesWide);
+ }
+ scrollTitle();
+ ++_pCount;
+
+ while (!_vm->shouldQuit() && (_vm->_events->_vbCount > 0)) {
+ _vm->_events->pollEventsAndWait();
+ }
+ continue;
+ }
+
+ _vm->_events->_vbCount = 120;
+ while (!_vm->shouldQuit() && (_vm->_events->_vbCount > 0))
+ _vm->_events->pollEventsAndWait();
+
+ while (!_vm->shouldQuit()) {
+ _pCount = 0;
+ _vm->_events->_vbCount = 3;
+ if (_vm->_scrollRow + screen._vWindowHeight >= _vm->_room->_playFieldHeight) {
+ _vm->_room->clearRoom();
+ _vm->_events->showCursor();
+ return;
+ }
+
+ _vm->_scrollY = _vm->_scrollY + _vm->_player->_scrollAmount;
+
+ 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(_vm->_scrollRow + screen._vWindowHeight, screen._vWindowLinesTall);
+
+ if (_vm->_scrollRow + screen._vWindowHeight >= _vm->_room->_playFieldHeight) {
+ _vm->_room->clearRoom();
+ _vm->_events->showCursor();
+ return;
+ }
+ }
+ scrollTitle();
+ while (!_vm->shouldQuit() && (_vm->_events->_vbCount > 0))
+ _vm->_events->pollEventsAndWait();
+ }
+ }
+}
+
+void Opening::doTent() {
+ int step = 0;
+ _vm->_screen->setDisplayScan();
+ _vm->_screen->forceFadeOut();
+ _vm->_events->hideCursor();
+ _vm->_sound->loadSoundTable(0, 98, 39);
+ _vm->_sound->loadSoundTable(1, 98, 14);
+ _vm->_sound->loadSoundTable(2, 98, 15);
+ _vm->_sound->loadSoundTable(3, 98, 16);
+ _vm->_sound->loadSoundTable(4, 98, 31, 2);
+ _vm->_sound->loadSoundTable(5, 98, 52, 2);
+ _vm->_sound->playSound(0);
+
+ _vm->_files->_setPaletteFlag = false;
+ _vm->_files->loadScreen(2, 0);
+ _vm->_buffer2.blitFrom(*_vm->_screen);
+ _vm->_buffer1.blitFrom(*_vm->_screen);
+ _vm->_screen->forceFadeIn();
+
+ _vm->_video->setVideo(_vm->_screen, Common::Point(126, 73), FileIdent(2, 1), 10);
+ int previousFrame = -1;
+ while (!_vm->shouldQuit() && !_vm->_video->_videoEnd) {
+ _vm->_video->playVideo();
+ if (previousFrame != _vm->_video->_videoFrame) {
+ previousFrame = _vm->_video->_videoFrame;
+
+ 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->_midi->newMusic(73, 1);
+ _vm->_midi->newMusic(11, 0);
+ step = 1;
+ _vm->_sound->playSound(1);
+ }
+ }
+ }
+ _vm->_events->pollEventsAndWait();
+ }
+
+ _vm->_sound->playSound(5);
+ _vm->_video->setVideo(_vm->_screen, Common::Point(43, 11), FileIdent(2, 2), 10);
+ previousFrame = -1;
+ while (!_vm->shouldQuit() && !_vm->_video->_videoEnd) {
+ _vm->_video->playVideo();
+ if (previousFrame != _vm->_video->_videoFrame) {
+ previousFrame = _vm->_video->_videoFrame;
+ if (_vm->_video->_videoFrame == 26) {
+ _vm->_sound->playSound(5);
+ } else if (_vm->_video->_videoFrame == 15) {
+ if (step !=3) {
+ _vm->_sound->playSound(3);
+ step = 3;
+ }
+ }
+ }
+ _vm->_events->pollEventsAndWait();
+ }
+
+ _vm->_events->_vbCount = 200;
+ while (!_vm->shouldQuit() && _vm->_events->_vbCount > 0)
+ _vm->_events->pollEventsAndWait();
+
+ _vm->_events->showCursor();
+ _vm->_midi->newMusic(11, 1);
+ _vm->_sound->_soundTable.clear();
+
+ _vm->establishCenter(0, 4);
+}
+
+/*------------------------------------------------------------------------*/
+
+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();
+ _vm->_scrollX = 0;
+
+ _vm->_room->buildScreen();
+ _vm->copyBF2Vid();
+ screen.fadeIn();
+ _vm->_oldRects.clear();
+ _vm->_newRects.clear();
+ _vm->_events->clearEvents();
+
+ _vm->_scrollRow = _vm->_scrollCol = 0;
+ _vm->_scrollX = _vm->_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() &&
+ ((_vm->_scrollCol + screen._vWindowWidth) != _vm->_room->_playFieldWidth)) {
+ events._vbCount = 4;
+ _vm->_scrollX += player._scrollAmount;
+
+ while (_vm->_scrollX >= TILE_WIDTH) {
+ _vm->_scrollX -= TILE_WIDTH;
+ ++_vm->_scrollCol;
+
+ _vm->_buffer1.moveBufferLeft();
+ _vm->_room->buildColumn(_vm->_scrollCol + screen._vWindowWidth, screen._vWindowBytesWide);
+ }
+
+ scrollFly();
+ ++_pCount;
+
+ while (!_vm->shouldQuit() && events._vbCount > 0) {
+ _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();
+ _vm->_scrollX = 0;
+
+ _vm->_room->buildScreen();
+ _vm->copyBF2Vid();
+ screen.fadeIn();
+ _vm->_oldRects.clear();
+ _vm->_newRects.clear();
+ _vm->_events->clearEvents();
+
+ _vm->_scrollRow = _vm->_scrollCol = 0;
+ _vm->_scrollX = _vm->_scrollY = 0;
+ _vm->_player->_scrollAmount = 3;
+ _vm->_scaleI = 255;
+
+ _xCount = 0;
+ _planeCount = 0;
+
+ while (!_vm->shouldQuit() && !events.isKeyMousePressed() &&
+ (_vm->_scrollCol + screen._vWindowWidth != _vm->_room->_playFieldWidth)) {
+ events._vbCount = 4;
+ _vm->_scrollX += _vm->_player->_scrollAmount;
+
+ while (_vm->_scrollX >= TILE_WIDTH) {
+ _vm->_scrollX -= TILE_WIDTH;
+ ++_vm->_scrollCol;
+
+ _vm->_buffer1.moveBufferLeft();
+ _vm->_room->buildColumn(_vm->_scrollCol + screen._vWindowWidth, screen._vWindowBytesWide);
+ }
+
+ scrollFall();
+
+ while (!_vm->shouldQuit() && events._vbCount > 0) {
+ events.pollEventsAndWait();
+ }
+ }
+
+ events.showCursor();
+}
+
+/*------------------------------------------------------------------------*/
+
+Jungle::Jungle(AmazonEngine *vm) : CampScene(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->_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 }
+ };
+
+ Screen &screen = *_vm->_screen;
+ screen.fadeOut();
+ _vm->_events->hideCursor();
+ screen.clearScreen();
+ _vm->_buffer2.clearBuffer();
+ screen.setBufferScan();
+
+ _vm->_scrollX = _vm->_scrollY;
+ _vm->_scrollCol = _vm->_scrollRow;
+ _vm->_room->buildScreen();
+ _vm->copyBF2Vid();
+ screen.fadeIn();
+ _vm->_events->clearEvents();
+
+ _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();
+ _vm->_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() &&
+ (_vm->_scrollCol + screen._vWindowWidth) != _vm->_room->_playFieldWidth) {
+ _vm->_images.clear();
+ _vm->_events->_vbCount = 6;
+ _pan[0]._pImgNum = _xCount;
+
+ jungleMove();
+ while (_vm->_scrollX >= TILE_WIDTH) {
+ _vm->_scrollX -= TILE_WIDTH;
+ ++_vm->_scrollCol;
+ _vm->_buffer1.moveBufferLeft();
+ _vm->_room->buildColumn(_vm->_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) {
+ _guardCel = 0;
+ _gCode1 = _gCode2 = 0;
+ _xMid = _yMid = 0;
+}
+
+void Guard::setVerticalCode() {
+ Screen &screen = *_vm->_screen;
+
+ _gCode1 = 0;
+ _gCode2 = 0;
+ if (_topLeft.x < screen._orgX1)
+ _gCode1 |= 8;
+ else if (_topLeft.x == screen._orgX1) {
+ _gCode1 |= 8;
+ _gCode1 |= 2;
+ } else
+ _gCode1 |= 2;
+
+ if (_bottomRight.x < screen._orgX1)
+ _gCode2 |= 8;
+ else if (_bottomRight.x == screen._orgX1) {
+ _gCode2 |= 8;
+ _gCode2 |= 2;
+ } else
+ _gCode2 |= 2;
+
+ if (_topLeft.y < screen._orgY1)
+ _gCode1 |= 4;
+ else if (_topLeft.y > screen._orgY2)
+ _gCode1 |= 1;
+
+ if (_bottomRight.y < screen._orgY1)
+ _gCode2 |= 4;
+ else if (_bottomRight.y > screen._orgY2)
+ _gCode2 |= 1;
+}
+
+void Guard::setHorizontalCode() {
+ Screen &screen = *_vm->_screen;
+
+ _gCode1 = 0;
+ _gCode2 = 0;
+
+ if (_topLeft.y < screen._orgY1)
+ _gCode1 |= 4;
+ else if (_topLeft.x == screen._orgX1) {
+ _gCode1 |= 4;
+ _gCode1 |= 1;
+ } else
+ _gCode1 |= 1;
+
+ if (_bottomRight.y < screen._orgY1)
+ _gCode2 |= 4;
+ else if (_bottomRight.x == screen._orgX1) {
+ _gCode2 |= 4;
+ _gCode2 |= 1;
+ } else
+ _gCode2 |= 1;
+
+ if (_topLeft.x < screen._orgX1)
+ _gCode1 |= 8;
+ else if (_topLeft.x > screen._orgX2)
+ _gCode1 |= 2;
+
+ if (_bottomRight.x < screen._orgX1)
+ _gCode2 |= 8;
+ else if (_bottomRight.x > 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() {
+ Screen &screen = *_vm->_screen;
+ int tmpY = (_vm->_scrollRow << 4) + _vm->_scrollY;
+ _vm->_flags[140] = 0;
+ if (tmpY > _position.y)
+ return;
+
+ tmpY += 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++) {
+ 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 (screen._orgY1 == 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() {
+ // 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;
+ }
+
+ ++_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) {
+ Screen &screen = *_vm->_screen;
+
+ screen.setDisplayScan();
+ _vm->_events->hideCursor();
+ screen.forceFadeOut();
+ screen._clipHeight = 173;
+ screen.clearScreen();
+ _vm->_chapter = 16;
+ _vm->tileScreen();
+ _vm->updateSummary(param1);
+ 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.blitFrom(*_vm->_screen);
+ _vm->_buffer1.blitFrom(*_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->_midi->newMusic(58, 0);
+ screen.forceFadeIn();
+
+ while (!_vm->shouldQuit()) {
+ _vm->_images.clear();
+ pan();
+ _vm->_buffer2.blitFrom(_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->_midi->checkMidiDone())
+ _vm->_events->pollEventsAndWait();
+
+ break;
+ }
+ }
+
+ _vm->_midi->newMusic(58, 1);
+ _vm->_events->showCursor();
+
+ _vm->freeCells();
+ _vm->_oldRects.clear();
+ _vm->_newRects.clear();
+ _vm->_numAnimTimers = 0;
+ _vm->_images.clear();
+ screen.forceFadeOut();
+
+ _vm->quitGame();
+ _vm->_events->pollEvents();
+}
+
+/*------------------------------------------------------------------------*/
+
+River::River(AmazonEngine *vm) : PannedScene(vm) {
+ _chickenOutFl = false;
+ _rScrollRow = 0;
+ _rScrollCol = 0;
+ _rScrollX = 0;
+ _rScrollY = 0;
+ _mapOffset = 0;
+ _screenVertX = 0;
+ _saveRiver = false;
+ _deathFlag = false;
+ _deathCount = 0;
+ _oldScrollCol = 0;
+ _maxHits = 0;
+ _mapPtr = nullptr;
+ _canoeMoveCount = 0;
+ _canoeVXPos = 0;
+ _canoeFrame = 0;
+ _canoeDir = 0;
+ _canoeLane = 0;
+ _canoeYPos = 0;
+ _hitCount = 0;
+ _riverIndex = 0;
+ _topList = _botList = nullptr;
+ _deathType = 0;
+ _hitSafe = 0;
+}
+
+void River::setRiverPan() {
+ int delta = (_vm->_scrollCol * 16) + _vm->_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 };
+ Screen &screen = *_vm->_screen;
+
+ _vm->_events->centerMousePos();
+ _vm->_events->restrictMouse();
+ screen.setDisplayScan();
+ screen.clearScreen();
+ screen.savePalette();
+ screen.forceFadeOut();
+
+ _vm->_files->_setPaletteFlag = false;
+ _vm->_files->loadScreen(95, 4);
+ _vm->_buffer2.blitFrom(*_vm->_screen);
+
+ screen.restorePalette();
+ screen.setBufferScan();
+ _vm->_destIn = &_vm->_buffer2;
+ _vm->_room->roomMenu();
+
+ if (_saveRiver) {
+ // Restoring a savegame, so set properties from saved fields
+ _vm->_scrollRow = _rScrollRow;
+ _vm->_scrollCol = _rScrollCol;
+ _vm->_scrollX = _rScrollX;
+ _vm->_scrollY = _rScrollY;
+ } else {
+ // Set initial scene state
+ _vm->_scrollRow = 0;
+ _vm->_scrollCol = 140;
+ _vm->_scrollX = 0;
+ _vm->_scrollY = 0;
+ }
+
+ _vm->_room->buildScreen();
+ _vm->copyBF2Vid();
+ screen.forceFadeIn();
+
+ if (!_saveRiver) {
+ // Reset draw rects
+ _vm->_oldRects.clear();
+ _vm->_newRects.clear();
+ _vm->_events->clearEvents();
+
+ }
+
+ _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 (_saveRiver) {
+ _mapPtr--;
+ _mapPtr += _mapOffset;
+ } else {
+ _screenVertX = RIVERVXTBL[_vm->_riverFlag] - 320;
+ _canoeLane = 3;
+ _hitCount = 0;
+ _hitSafe = 0;
+ _canoeYPos = 71;
+ }
+
+ _riverIndex = _vm->_riverFlag;
+ _topList = RIVER_OBJECTS[_riverIndex][RIVER_START];
+ updateObstacles();
+ riverSetPhysX();
+ _canoeDir = 0;
+ _deathFlag = false;
+ _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;
+
+ _maxHits = 2 - _vm->_riverFlag;
+ _saveRiver = false;
+
+ // Set font colors for drawing using font2
+ Font::_fontColors[0] = 0;
+ Font::_fontColors[1] = 33;
+ Font::_fontColors[2] = 34;
+ Font::_fontColors[3] = 35;
+}
+
+void River::resetPositions() {
+ riverSetPhysX();
+ int val = (_vm->_scrollCol + 1 - _oldScrollCol) * 16;
+ if (val < 0) {
+ val |= 0x80;
+ }
+
+ for (int i = 0; i < _pNumObj; i++)
+ _pan[i]._pObjX += val;
+}
+
+void River::checkRiverPan() {
+ int val = _vm->_scrollCol * 16 + 320;
+
+ for (int i = 0; i < _pNumObj; i++) {
+ if (_pan[i]._pObjX < val)
+ return;
+ }
+
+ setRiverPan();
+}
+
+bool River::riverJumpTest() {
+ if (_vm->_scrollCol == 120 || _vm->_scrollCol == 60 || _vm->_scrollCol == 0) {
+ int val = *++_mapPtr;
+ if (val == 0xFF)
+ return true;
+
+ _oldScrollCol = _vm->_scrollCol;
+
+ if (val == 0) {
+ _vm->_scrollCol = 139;
+ _vm->_scrollX = 14;
+ _vm->_room->buildScreen();
+ resetPositions();
+ return false;
+ }
+ } else if (_vm->_scrollCol == 105) {
+ int val1 = _mapPtr[1];
+ int val2 = _mapPtr[2];
+ _mapPtr += 3;
+ if (_canoeLane < 3) {
+ if (val1 != 0) {
+ _deathFlag = true;
+ _deathCount = 300;
+ _deathType = val2;
+ }
+ } else {
+ if (val1 != 1) {
+ _deathFlag = true;
+ _deathCount = 300;
+ _deathType = val2;
+ }
+ _oldScrollCol = _vm->_scrollCol;
+ _vm->_scrollCol = 44;
+ _vm->_scrollX = 14;
+ _vm->_room->buildScreen();
+ resetPositions();
+ return false;
+ }
+ }
+
+ _vm->_scrollX = 14;
+ --_vm->_scrollCol;
+ _vm->_buffer1.moveBufferRight();
+ _vm->_room->buildColumn(_vm->_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() {
+ EventsManager &events = *_vm->_events;
+ Common::Point pt = events.calcRawMouse();
+ Common::Point mousePos = events.getMousePos();
+
+ // 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. Show the ScummVM menu
+ _vm->_room->handleCommand(9);
+
+ if (_vm->_room->_function != FN_CLEAR1) {
+ _vm->_room->buildScreen();
+ _vm->copyBF2Vid();
+ }
+ }
+ } else if (events._leftButton && mousePos.x < 35 && mousePos.y < 12) {
+ // Clicked on the Skip button. So chicken out
+ _chickenOutFl = true;
+ } 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 < RIVER_OBJECTS[_riverIndex][RIVER_END]; ++cur) {
+ int val = cur->_riverX + cur->_width - 1;
+ if (val < _screenVertX)
+ // Obstacle is not yet on-screen
+ 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;
+
+ while (cur < RIVER_OBJECTS[_riverIndex][RIVER_END]) {
+ ++cur;
+ val = cur->_riverX + cur->_width - 1;
+ if (val < _screenVertX || (cur->_riverX >= (_screenVertX + 319)))
+ break;
+
+ _botList = cur;
+ }
+
+ return;
+ }
+ }
+
+ cur = _topList;
+ cur--;
+ _botList = cur;
+}
+
+void River::riverSetPhysX() {
+ int xAmt = (_vm->_scrollCol * 16) + _vm->_scrollX;
+
+ for (RiverStruct *cur = _topList; cur <= _botList; ++cur) {
+ cur->_xp = xAmt - (_screenVertX - cur->_riverX);
+ }
+}
+
+bool River::checkRiverCollide() {
+ if (_hitSafe)
+ return false;
+
+ _canoeVXPos = _screenVertX + 170;
+
+ for (RiverStruct *cur = _topList; cur <= _botList; ++cur) {
+ if (cur->_lane < _canoeLane)
+ continue;
+
+ 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;
+}
+
+void River::plotRiver() {
+ // Handle cycling through the canoe rowing frames
+ if (_vm->_timers[3]._flag == 0) {
+ ++_vm->_timers[3]._flag;
+
+ if (_canoeFrame++ == 12)
+ _canoeFrame = 0;
+ }
+
+ // Draw the canoe
+ ImageEntry ie;
+ ie._flags = IMGFLAG_UNSCALED;
+ ie._spritesPtr = _vm->_objectsTable[45];
+ ie._frameNumber = _canoeFrame;
+ ie._position.x = (_vm->_scrollCol * 16) + _vm->_scrollX + 160;
+ ie._position.y = _canoeYPos - 41;
+ ie._offsetY = 41;
+ _vm->_images.addToList(ie);
+
+ // 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;
+ ie._position.y = (cur->_lane * 5) + 56 - cur->_offsetY;
+ ie._offsetY = cur->_offsetY;
+ _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() {
+ Screen &screen = *_vm->_screen;
+ _vm->_events->hideCursor();
+
+ screen.setDisplayScan();
+ screen.clearScreen();
+ screen.savePalette();
+ if (!_vm->isDemo())
+ _vm->_files->loadScreen(95, 4);
+ _vm->_buffer2.blitFrom(*_vm->_screen);
+ screen.restorePalette();
+ screen.setPalette();
+ screen.setBufferScan();
+
+ _vm->_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->_scrollCol + screen._vWindowWidth != _vm->_room->_playFieldWidth)) {
+ _vm->_images.clear();
+ _vm->_events->_vbCount = 6;
+
+ _vm->_scrollX += _vm->_player->_scrollAmount;
+ while (_vm->_scrollX >= TILE_WIDTH) {
+ _vm->_scrollX -= TILE_WIDTH;
+ ++_vm->_scrollCol;
+ _vm->_buffer1.moveBufferLeft();
+ _vm->_room->buildColumn(_vm->_scrollCol + screen._vWindowWidth, 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::doRiver() {
+ static const int RIVERDEATH[5] = { 22, 23, 24, 25, 26 };
+
+ initRiver();
+ _vm->_events->showCursor();
+
+ while (!_vm->shouldQuit()) {
+ _vm->_events->_vbCount = 4;
+
+ // Move the river position
+ _screenVertX -= _vm->_player->_scrollAmount;
+
+ if (_vm->_scrollX == 0) {
+ _vm->_midi->midiRepeat();
+ if (riverJumpTest()) {
+ _chickenOutFl = false;
+ return;
+ }
+ } else {
+ _vm->_scrollX -= _vm->_player->_scrollAmount;
+ }
+
+ if (_chickenOutFl) {
+ _chickenOutFl = 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 (_deathFlag) {
+ if (--_deathCount == 0) {
+ _vm->dead(RIVERDEATH[_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;
+ _chickenOutFl = false;
+ break;
+ }
+ }
+}
+
+void River::synchronize(Common::Serializer &s) {
+ if (_vm->_player->_roomNumber == 45) {
+ if (s.isSaving()) {
+ // Set river properties to be saved out
+ _rScrollRow = _vm->_scrollRow;
+ _rScrollCol = _vm->_scrollCol;
+ _rScrollX = _vm->_scrollX;
+ _rScrollY = _vm->_scrollY;
+ _mapOffset = _mapPtr - MAPTBL[_vm->_riverFlag];
+ }
+
+ 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(_mapOffset);
+ s.syncAsUint16LE(_screenVertX);
+
+ _saveRiver = s.isLoading();
+ }
+}
+
+/*------------------------------------------------------------------------*/
+
+Ant::Ant(AmazonEngine *vm) : AmazonManager(vm) {
+ _antDirection = ANT_RIGHT;
+ _pitDirection = ANT_RIGHT;
+ _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[INV_TORCH]._value == ITEM_IN_INVENTORY) {
+ // Player has torch
+ 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[INV_KNIFE_SPEAR]._value == ITEM_IN_INVENTORY)) {
+ // Player has spear
+ idx = 0;
+ buf = Amazon::SPEAR;
+ plotTorchSpear(idx, buf);
+ }
+}
+
+int Ant::antHandleRight(int indx, const int *&buf) {
+ int retval = indx;
+ if (_pitDirection == ANT_RIGHT) {
+ _pitDirection = ANT_LEFT;
+ _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 == ANT_LEFT) {
+ _pitDirection = ANT_RIGHT;
+ _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[INV_KNIFE_SPEAR]._value == ITEM_IN_INVENTORY) {
+ if (_stabFl) {
+ buf = Amazon::PITSTAB;
+ retval = _stabCel;
+ if (_vm->_timers[13]._flag == 0) {
+ _vm->_timers[13]._flag = 1;
+ retval += 6;
+ _stabCel = retval;
+
+ if (buf[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 = ANT_RIGHT;
+ 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[INV_TORCH]._value == ITEM_IN_INVENTORY)
+ // Player has burning torch, which scares the Ant
+ _antDirection = ANT_LEFT;
+ }
+
+ int idx = _antCel;
+ if (_vm->_timers[15]._flag == 0) {
+ _vm->_timers[15]._flag = 1;
+ if (_antDirection == ANT_LEFT) {
+ 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) {
+ 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) {
+ // 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->_move == UP)
+ idx = antHandleStab(idx, buf);
+ else if (_vm->_player->_move == LEFT)
+ idx = antHandleLeft(idx, buf);
+ else if (_vm->_player->_move == 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;
+ }
+ }
+}
+
+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
new file mode 100644
index 0000000000..0d962483e6
--- /dev/null
+++ b/engines/access/amazon/amazon_logic.h
@@ -0,0 +1,253 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public 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;
+
+ PanEntry _pan[PAN_SIZE];
+public:
+ PannedScene(AmazonEngine *vm);
+
+ void pan();
+};
+
+class CampScene : public PannedScene {
+protected:
+ bool _skipStart;
+public:
+ CampScene(AmazonEngine *vm);
+
+ void mWhileDoOpen();
+};
+
+class Opening : public CampScene {
+private:
+ int _pCount;
+
+ void doTitle();
+ void doCredit();
+ void doCreditDemo();
+ void scrollTitle();
+ void doTent();
+public:
+ Opening(AmazonEngine *vm);
+
+ void doIntroduction();
+};
+
+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 CampScene {
+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 _chickenOutFl;
+ const byte *_mapPtr;
+ int _canoeVXPos;
+ int _canoeMoveCount;
+ int _canoeFrame;
+ RiverStruct *_topList;
+ RiverStruct *_botList;
+ int _canoeDir;
+ bool _saveRiver;
+ bool _deathFlag;
+ int _deathCount;
+ int _deathType;
+ int _maxHits;
+
+ // Saved fields
+ int _canoeLane;
+ int _canoeYPos;
+ int _hitCount;
+ int _riverIndex;
+ int _hitSafe;
+ int _rScrollRow;
+ int _rScrollCol;
+ int _rScrollX;
+ int _rScrollY;
+ int _mapOffset;
+ int _screenVertX;
+ int _oldScrollCol;
+
+ 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 doRiver();
+ void mWhileDownRiver();
+
+ void synchronize(Common::Serializer &s);
+};
+
+enum AntDirection { ANT_RIGHT = 0, ANT_LEFT = 1 };
+
+class Ant : public AmazonManager {
+private:
+ AntDirection _antDirection;
+ AntDirection _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();
+
+ void synchronize(Common::Serializer &s);
+};
+
+class InactivePlayer : public ImageEntry {
+public:
+ SpriteResource *_altSpritesPtr;
+
+ InactivePlayer() { _altSpritesPtr = nullptr; }
+};
+
+} // 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
new file mode 100644
index 0000000000..b1ed501fce
--- /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->setPosition(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 0000000000..236b8bd1bd
--- /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
new file mode 100644
index 0000000000..2010c7d842
--- /dev/null
+++ b/engines/access/amazon/amazon_resources.cpp
@@ -0,0 +1,2411 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public 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_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",
+ // 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",
+ "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[] = {
+ // hotspot x and y, uint16 LE
+ 0, 0, 0, 0,
+ // 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[] = {
+ // 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[] = {
+ // 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[] = {
+ // 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[] = {
+ // 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[] = {
+ // 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[] = {
+ // 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[] = {
+ // 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[] = {
+ // 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[] = {
+ // 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 *const 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 }
+};
+
+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,
+ 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 *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,
+ 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 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",
+ "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, "Cave Bridge", nullptr, nullptr,
+ 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 *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,
+ 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[] = {
+ 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
+};
+
+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 *const 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
+};
+
+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,
+ 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",
+ "DARTS", "TAPE", "JUNGLE POTION", "MOVIE", "CABINET KEY",
+ "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",
+ "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"
+};
+
+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,
+};
+
+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 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 ",
+ " 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,
+ 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 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.",
+ "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 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'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'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[13][3] = {
+ { 0, 94, 2 },
+ { 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 }
+};
+
+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
+};
+
+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 }
+};
+
+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};
+
+const int OPENING_OBJS[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},
+};
+
+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 *const 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 }
+};
+
+RiverStruct RIVER0OBJECTS[46] = {
+ {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},
+ {16, 31, 260, 0, 7, 12}
+};
+
+RiverStruct RIVER1OBJECTS[50] = {
+ {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},
+ { 16, 31, 260, 0, 1, 12 }
+};
+
+RiverStruct RIVER2OBJECTS[54] = {
+ {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},
+ {16, 31, 260, 0, 6, 12}
+};
+
+RiverStruct *RIVER_OBJECTS[3][2] = {
+ { RIVER0OBJECTS, RIVER0OBJECTS + 46 - 1},
+ { RIVER1OBJECTS, RIVER0OBJECTS + 50 - 1 },
+ { RIVER2OBJECTS, RIVER0OBJECTS + 54 - 1 }
+};
+
+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
new file mode 100644
index 0000000000..a952860bc2
--- /dev/null
+++ b/engines/access/amazon/amazon_resources.h
@@ -0,0 +1,148 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public 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 {
+
+enum InventoryEnum {
+ INV_BAITED_POLE = 67, INV_TORCH = 76, INV_KNIFE_SPEAR = 78
+};
+
+struct RiverStruct {
+ int _id;
+ int _width;
+ int _riverX;
+ int _xp;
+ int _lane;
+ int _offsetY;
+};
+
+extern const char *const FILENAMES[];
+extern const char *const FILENAMES_DEMO[];
+
+extern const byte *const 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 *const ROOM_TABLE[];
+extern const char *const ROOM_DESCR[];
+extern const byte *const ROOM_TABLE_DEMO[];
+extern const int ROOM_NUMB;
+
+extern const byte *const CHARTBL[];
+extern const byte *const CHARTBL_DEMO[];
+
+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[];
+
+extern const char *const NO_HELP_MESSAGE;
+extern const char *const NO_HINTS_MESSAGE;
+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];
+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[13][3];
+
+extern const int CHAPTER_CELLS[17][3];
+
+extern const int CHAPTER_TABLE[14][5];
+
+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];
+
+extern const int OPENING_OBJS[10][4];
+
+extern const byte MAP0[26];
+extern const byte MAP1[27];
+extern const byte MAP2[32];
+
+extern const byte *const MAPTBL[3];
+
+extern const int DOWNRIVEROBJ[14][4];
+
+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];
+
+extern const int CAST_END_OBJ[26][4];
+
+extern const int CAST_END_OBJ1[4][4];
+
+} // End of namespace Amazon
+
+} // End of namespace Access
+
+#endif /* ACCESS_AMAZON_RESOURCES_H */
diff --git a/engines/access/amazon/amazon_room.cpp b/engines/access/amazon/amazon_room.cpp
new file mode 100644
index 0000000000..29742f66bd
--- /dev/null
+++ b/engines/access/amazon/amazon_room.cpp
@@ -0,0 +1,241 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public 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/amazon/amazon_game.h"
+#include "access/amazon/amazon_resources.h"
+#include "access/amazon/amazon_room.h"
+
+namespace Access {
+
+namespace Amazon {
+
+AmazonRoom::AmazonRoom(AccessEngine *vm) : Room(vm) {
+ _game = (AmazonEngine *)vm;
+ _antOutFlag = false;
+ _icon = nullptr;
+}
+
+AmazonRoom::~AmazonRoom() {
+}
+
+void AmazonRoom::loadRoom(int roomNumber) {
+ if (_vm->isDemo())
+ loadRoomData(ROOM_TABLE_DEMO[roomNumber]);
+ else
+ loadRoomData(ROOM_TABLE[roomNumber]);
+}
+
+void AmazonRoom::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 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._altSpritesPtr = new SpriteResource(_vm, spriteData);
+ delete spriteData;
+ _vm->_currentCharFlag = false;
+ }
+
+ _selectCommand = -1;
+ _vm->_events->setNormalCursor(CURSOR_CROSSHAIRS);
+ _vm->_mouseMode = 0;
+ _vm->_boxSelect = true;
+ _vm->_player->_playerOff = false;
+
+ _vm->_screen->fadeOut();
+ _vm->_screen->clearScreen();
+ roomSet();
+
+ if (_roomFlag != 1 && (_vm->_player->_roomNumber != 61 || !_antOutFlag)) {
+ _vm->_player->load();
+ _vm->_player->calcManScale();
+ }
+
+ if (_vm->_player->_roomNumber != 20 && _vm->_player->_roomNumber != 24
+ && _vm->_player->_roomNumber != 33 && _vm->_player->_roomNumber != 45) {
+ roomMenu();
+ }
+
+ _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();
+ }
+
+ // 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();
+}
+
+void AmazonRoom::setupRoom() {
+ Room::setupRoom();
+
+ // WORKAROUND: The original engine doesn't handle vertical scrolling rooms
+ Screen &screen = *_vm->_screen;
+ if (screen._vWindowHeight == (_playFieldHeight - 1)) {
+ _vm->_scrollRow = 1;
+ _vm->_scrollY = 0;
+ }
+}
+
+void AmazonRoom::roomSet() {
+ _vm->_numAnimTimers = 0;
+ _vm->_scripts->_sequence = 1000;
+ _vm->_scripts->searchForSequence();
+ _vm->_scripts->executeScript();
+}
+
+void AmazonRoom::roomMenu() {
+ Resource *iconData = _vm->_files->loadFile("ICONS.LZ");
+ SpriteResource *spr = new SpriteResource(_vm, iconData);
+ delete iconData;
+
+ 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));
+
+ screen.restoreScreen();
+ delete spr;
+}
+
+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 (player._roomNumber == 42 || player._roomNumber == 44 ||
+ player._roomNumber == 31 || 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:
+ 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
+ if (_vm->_scrollRow == 0 && pt.y > 178)
+ pt.y = 200;
+
+ 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();
+ }
+ }
+}
+
+void AmazonRoom::walkCursor() {
+ // WORKAROUND: For scene 29, which is a normal walkable scene, but yet can be
+ // '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 &&
+ events._normalMouse != CURSOR_CROSSHAIRS)) {
+ events.forceSetCursor(CURSOR_CROSSHAIRS);
+ _selectCommand = -1;
+ _vm->_boxSelect = true;
+ } else {
+ Room::walkCursor();
+ }
+}
+
+void AmazonRoom::init4Quads() {
+ if (!_vm->_screen->_vesaMode)
+ return;
+
+ // CHECKME: in the original, this call of tileScreen uses an useless parameter, "TILES.BLK"
+ _game->tileScreen();
+ _vm->_inventory->refreshInventory();
+ _game->updateSummary(_game->_chapter);
+
+ _vm->_screen->setPanel(0);
+ _vm->_screen->clearScreen();
+}
+
+void AmazonRoom::clearRoom() {
+ _game->freeInactivePlayer();
+ Room::clearRoom();
+}
+
+} // 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 0000000000..6396f80199
--- /dev/null
+++ b/engines/access/amazon/amazon_room.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_AMAZON_ROOM_H
+#define ACCESS_AMAZON_ROOM_H
+
+#include "common/scummsys.h"
+#include "access/room.h"
+
+namespace Access {
+
+class AccessEngine;
+
+namespace Amazon {
+
+class AmazonEngine;
+
+class AmazonRoom : public Room {
+private:
+ AmazonEngine *_game;
+ bool _antOutFlag;
+ const byte *_icon;
+
+ void roomSet();
+protected:
+ virtual void loadRoom(int roomNumber);
+
+ virtual void reloadRoom();
+
+ virtual void reloadRoom1();
+
+ virtual void setupRoom();
+
+ virtual void mainAreaClick();
+
+ virtual void clearRoom();
+
+ virtual void walkCursor();
+public:
+ AmazonRoom(AccessEngine *vm);
+
+ virtual ~AmazonRoom();
+
+ virtual void init4Quads();
+
+ virtual void roomMenu();
+};
+
+} // 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 0000000000..92acb3686d
--- /dev/null
+++ b/engines/access/amazon/amazon_scripts.cpp
@@ -0,0 +1,516 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public 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/amazon/amazon_game.h"
+#include "access/amazon/amazon_resources.h"
+#include "access/amazon/amazon_scripts.h"
+
+namespace Access {
+
+namespace Amazon {
+
+AmazonScripts::AmazonScripts(AccessEngine *vm) : Scripts(vm) {
+ _game = (AmazonEngine *)_vm;
+}
+
+void AmazonScripts::cLoop() {
+ searchForSequence();
+ _vm->_images.clear();
+ _vm->_buffer2.blitFrom(_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.blitFrom(*_vm->_screen);
+ _vm->_buffer1.blitFrom(*_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->_buffer1.copyTo(_vm->_screen);
+ _vm->_buffer2.copyTo(&_vm->_buffer1);
+
+ _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.blitFrom(*_vm->_screen);
+ _vm->_buffer1.blitFrom(*_vm->_screen);
+ _vm->_events->showCursor();
+
+ _vm->_screen->setIconPalette();
+ _vm->_images.clear();
+ _vm->_oldRects.clear();
+ _sequence = 2200;
+
+ _vm->_sound->loadSoundTable(0, 14, 15);
+
+ 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.blitFrom(*_vm->_screen);
+ _vm->_buffer1.blitFrom(*_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.blitFrom(*_vm->_screen);
+ _vm->_buffer1.blitFrom(*_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::mWhile2() {
+ _vm->_screen->setDisplayScan();
+ _vm->_screen->fadeOut();
+ _vm->_events->hideCursor();
+
+ _vm->_files->loadScreen(14, 0);
+ _vm->_buffer2.blitFrom(*_vm->_screen);
+ _vm->_buffer1.blitFrom(*_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.blitFrom(*_vm->_screen);
+ _vm->_buffer1.blitFrom(*_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:
+ mWhile1();
+ break;
+ case 2:
+ _game->_plane->mWhileFly();
+ break;
+ case 3:
+ _game->_plane->mWhileFall();
+ break;
+ case 4:
+ _game->_jungle->mWhileJWalk();
+ break;
+ case 5:
+ _game->_jungle->mWhileDoOpen();
+ break;
+ case 6:
+ _game->_river->mWhileDownRiver();
+ break;
+ case 7:
+ mWhile2();
+ break;
+ case 8:
+ _game->_jungle->mWhileJWalk2();
+ break;
+ default:
+ break;
+ }
+}
+
+void AmazonScripts::loadBackground(int param1, int param2) {
+ _vm->_files->_setPaletteFlag = false;
+ _vm->_files->loadScreen(param1, param2);
+
+ _vm->_buffer2.blitFrom(*_vm->_screen);
+ _vm->_buffer1.blitFrom(*_vm->_screen);
+
+ _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;
+ _game->_charSegSwitch = false;
+
+ mWhile(_game->_rawInactiveY);
+}
+
+void AmazonScripts::boatWalls(int param1, int param2) {
+ if (param1 == 1)
+ _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;
+ }
+}
+
+void AmazonScripts::plotInactive() {
+ Player &player = *_vm->_player;
+ InactivePlayer &inactive = _game->_inactive;
+
+ if (_game->_charSegSwitch) {
+ _game->_currentCharFlag = true;
+ SWAP(inactive._altSpritesPtr, player._playerSprites);
+ _game->_charSegSwitch = false;
+ } else if (_game->_jasMayaFlag != (_game->_currentCharFlag ? 1 : 0)) {
+ 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 = player._rawPlayer.x;
+ _game->_rawInactiveY = player._rawPlayer.y;
+ player._rawPlayer.x = tmpX;
+ player._rawPlayer.y = tmpY;
+ _game->_inactiveYOff = player._playerOffset.y;
+ player.calcManScale();
+
+ SWAP(inactive._altSpritesPtr, player._playerSprites);
+ _vm->_room->setWallCodes();
+ }
+ }
+
+ _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] = 0;
+ if (!_game->_jasMayaFlag && _game->_rawInactiveX >= 266 && _game->_rawInactiveX <= 290
+ && _game->_rawInactiveY >= 70 && _game->_rawInactiveY <= 87) {
+ _game->_flags[160] = 1;
+ }
+ }
+
+ 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._spritesPtr = inactive._altSpritesPtr;
+
+ _vm->_images.addToList(_game->_inactive);
+}
+
+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;
+ case 2:
+ loadBackground(param1, param2);
+ break;
+ case 3:
+ if (_vm->isDemo())
+ warning("TODO: DEMO - LOADCELLSET");
+ else
+ _game->_cast->doCast(param1);
+ break;
+ case 4:
+ if (_vm->isDemo())
+ loadNSound(param1, param2);
+ 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;
+ case 10:
+ _vm->_midi->newMusic(param1, param2);
+ break;
+ case 11:
+ plotInactive();
+ break;
+ case 13:
+ _game->_river->doRiver();
+ break;
+ case 14:
+ _game->_ant->doAnt();
+ break;
+ case 15:
+ boatWalls(param1, param2);
+ break;
+ default:
+ warning("Unexpected Special code %d - Skipped", commandIndex);
+ }
+}
+
+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() {
+ 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(helpMessage);
+
+ while (!_vm->shouldQuit()) {
+ 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) {
+ // Done button selected
+ _game->_helpLevel = 0;
+ _game->_moreHelp = 1;
+ _game->_useItem = 0;
+ _vm->_events->hideCursor();
+ if (_vm->_screen->_vesaMode) {
+ _vm->_screen->restoreScreen();
+ _vm->_screen->setPanel(0);
+ } else {
+ _vm->_screen->fadeOut();
+ _vm->_screen->clearBuffer();
+ }
+
+ _vm->_buffer2.copyTo(_vm->_screen);
+ _vm->_screen->restorePalette();
+ _vm->_screen->setPalette();
+ _vm->_events->showCursor();
+
+ 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;
+ _game->_useItem = 1;
+ break;
+ }
+ }
+ findNull();
+}
+
+void AmazonScripts::cmdCycleBack() {
+ if (_vm->_startup == -1)
+ _vm->_screen->cyclePaletteBackwards();
+}
+void AmazonScripts::cmdChapter() {
+ if (_vm->isDemo()) {
+ cmdSetHelp();
+ } else {
+ int chapter = _data->readByte();
+ _game->startChapter(chapter);
+ }
+}
+
+void AmazonScripts::cmdSetHelp() {
+ int arrayId = (_data->readUint16LE() & 0xFF) - 1;
+ int helpId = _data->readUint16LE() & 0xFF;
+
+ byte *help = _game->_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
+
+} // 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 0000000000..e10eefb4f5
--- /dev/null
+++ b/engines/access/amazon/amazon_scripts.h
@@ -0,0 +1,67 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef ACCESS_AMAZON_SCRIPTS_H
+#define ACCESS_AMAZON_SCRIPTS_H
+
+#include "common/scummsys.h"
+#include "access/scripts.h"
+
+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 cLoop();
+ void mWhile1();
+ void mWhile2();
+ 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);
+
+ void cmdHelp();
+ void cmdCycleBack();
+ void cmdChapter();
+ void cmdSetHelp();
+ void cmdCenterPanel();
+ void cmdMainPanel();
+ void CMDRETFLASH();
+public:
+ AmazonScripts(AccessEngine *vm);
+};
+
+} // End of namespace Amazon
+
+} // End of namespace Access
+
+#endif /* ACCESS_AMAZON_SCRIPTS_H */
diff --git a/engines/access/animation.cpp b/engines/access/animation.cpp
new file mode 100644
index 0000000000..14d7c0d4cc
--- /dev/null
+++ b/engines/access/animation.cpp
@@ -0,0 +1,340 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public 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 "common/memstream.h"
+#include "access/access.h"
+#include "access/animation.h"
+
+namespace Access {
+
+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(res->_stream->readUint32LE());
+
+ _animations.reserve(count);
+ for (int i = 0; i < count; ++i) {
+ res->_stream->seek(offsets[i]);
+ Animation *anim = new Animation(vm, res->_stream);
+ _animations.push_back(anim);
+ }
+}
+
+AnimationResource::~AnimationResource() {
+ for (int i = 0; i < (int)_animations.size(); ++i)
+ delete _animations[i];
+}
+
+/*------------------------------------------------------------------------*/
+
+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
+
+ 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 (uint i = 0; i < _frames.size(); ++i)
+ 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) {
+ setFrame1(calcFrame());
+ } else {
+ _countdownTicks = _initialTicks;
+ ++_frameNumber;
+ AnimationFrame *frame = calcFrame();
+
+ if (frame == nullptr) {
+ _frameNumber = 0;
+ _currentLoopCount = -1;
+ frame = calcFrame();
+ }
+
+ setFrame(frame);
+ }
+ }
+}
+
+void Animation::anim1() {
+ if (_currentLoopCount == -1 || _countdownTicks != 0) {
+ setFrame1(calcFrame());
+ } else {
+ _countdownTicks = _initialTicks;
+ ++_frameNumber;
+ AnimationFrame *frame = calcFrame();
+
+ if (frame == nullptr) {
+ --_frameNumber;
+ _currentLoopCount = -1;
+ frame = calcFrame();
+ }
+
+ setFrame(frame);
+ }
+}
+
+void Animation::anim2() {
+ if (_countdownTicks != 0) {
+ setFrame1(calcFrame());
+ } else {
+ _countdownTicks = _initialTicks;
+ ++_frameNumber;
+ AnimationFrame *frame = calcFrame();
+
+ if (frame == nullptr) {
+ _frameNumber = 0;
+ frame = calcFrame();
+ }
+
+ setFrame(frame);
+ }
+}
+
+void Animation::anim3() {
+ if (_currentLoopCount != -1) {
+ if (_countdownTicks != 0) {
+ setFrame1(calcFrame());
+ } else {
+ _countdownTicks = _initialTicks;
+ ++_frameNumber;
+ AnimationFrame *frame = calcFrame();
+
+ if (frame == nullptr) {
+ --_currentLoopCount;
+ _frameNumber = 0;
+ frame = calcFrame();
+ }
+
+ setFrame(frame);
+ }
+ }
+}
+
+void Animation::anim4() {
+ if (_currentLoopCount == -1 || _countdownTicks != 0) {
+ setFrame1(calcFrame());
+ } else {
+ _countdownTicks = _initialTicks;
+ ++_frameNumber;
+ AnimationFrame *frame = calcFrame();
+
+ if (frame == nullptr) {
+ if (--_currentLoopCount == -1) {
+ setFrame1(calcFrame());
+ return;
+ } else {
+ _frameNumber = 0;
+ frame = calcFrame();
+ }
+ }
+
+ setFrame(frame);
+ }
+}
+
+void Animation::animNone() {
+ // Empty implementation
+}
+
+void Animation::anim7() {
+ setFrame(calcFrame1());
+}
+
+AnimationFrame *Animation::calcFrame() {
+ return (_frameNumber < (int)_frames.size()) ? _frames[_frameNumber] : nullptr;
+}
+
+AnimationFrame *Animation::calcFrame1() {
+ return _frames[0];
+}
+
+void Animation::setFrame(AnimationFrame *frame) {
+ assert(frame);
+ _countdownTicks += frame->_frameDelay;
+ setFrame1(frame);
+}
+
+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 & ~IMGFLAG_UNSCALED;
+ if (_vm->_animation->_frameScale == -1)
+ ie._flags |= IMGFLAG_UNSCALED;
+
+ // Set the other fields
+ ie._spritesPtr = _vm->_objectsTable[part->_spritesIndex];
+ ie._frameNumber = part->_frameIndex;
+ ie._position = part->_position + _vm->_animation->_base;
+ ie._offsetY = part->_offsetY - ie._position.y;
+
+ _vm->_images.addToList(ie);
+ }
+}
+
+/*------------------------------------------------------------------------*/
+
+AnimationFrame::AnimationFrame(Common::SeekableReadStream *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::SeekableReadStream *stream) {
+ _flags = stream->readByte();
+ _spritesIndex = stream->readByte();
+ _frameIndex = stream->readByte();
+ _position.x = stream->readUint16LE();
+ _position.y = stream->readUint16LE();
+ _offsetY = stream->readUint16LE();
+}
+
+/*------------------------------------------------------------------------*/
+
+AnimationManager::AnimationManager(AccessEngine *vm) : Manager(vm) {
+ _animation = nullptr;
+ _animStart = nullptr;
+ _frameScale = 0;
+}
+
+AnimationManager::~AnimationManager() {
+ delete _animation;
+}
+
+void AnimationManager::freeAnimationData() {
+ delete _animation;
+ _animation = nullptr;
+ _animStart = nullptr;
+}
+
+void AnimationManager::clearTimers() {
+ _animationTimers.clear();
+}
+
+void AnimationManager::loadAnimations(Resource *res) {
+ _animationTimers.clear();
+ delete _animation;
+ _animation = new AnimationResource(_vm, res);
+}
+
+
+Animation *AnimationManager::setAnimation(int animId) {
+ Animation *anim = findAnimation(animId);
+ if (!anim)
+ return nullptr;
+
+ anim->_countdownTicks = anim->_initialTicks;
+ anim->_frameNumber = 0;
+
+ anim->_currentLoopCount = (anim->_type != 3 && anim->_type != 4) ? 0 : anim->_loopCount;
+
+ return anim;
+}
+
+void AnimationManager::setAnimTimer(Animation *anim) {
+ _animationTimers.push_back(anim);
+}
+
+Animation *AnimationManager::findAnimation(int animId) {
+ _animStart = (_animation == nullptr) ? nullptr : _animation->getAnimation(animId);
+ return _animStart;
+}
+
+void AnimationManager::animate(int animId) {
+ Animation *anim = findAnimation(animId);
+ _frameScale = anim->_scaling;
+ 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
new file mode 100644
index 0000000000..72621c4d11
--- /dev/null
+++ b/engines/access/animation.h
@@ -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.
+ *
+ */
+
+#ifndef ACCESS_ANIMATION_H
+#define ACCESS_ANIMATION_H
+
+#include "common/scummsys.h"
+#include "common/array.h"
+#include "common/memstream.h"
+#include "access/data.h"
+#include "access/files.h"
+
+namespace Access {
+
+class AnimationResource;
+class Animation;
+class AnimationFrame;
+class AnimationFramePart;
+
+class AnimationManager : public Manager {
+private:
+ Common::Array<Animation *> _animationTimers;
+ AnimationResource *_animation;
+public:
+ Animation *_animStart;
+ Common::Point _base;
+ int _frameScale;
+public:
+ AnimationManager(AccessEngine *vm);
+ ~AnimationManager();
+ void freeAnimationData();
+ void loadAnimations(Resource *res);
+
+ 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);
+
+ /**
+ * Update the timing of all currently active animation
+ */
+ void updateTimers();
+};
+
+class AnimationResource {
+private:
+ Common::Array<Animation *> _animations;
+public:
+ AnimationResource(AccessEngine *vm, Resource *res);
+ ~AnimationResource();
+
+ int getCount() { return _animations.size(); }
+ Animation *getAnimation(int idx) { return _animations[idx]; }
+};
+
+class Animation : public Manager {
+private:
+ Common::Array<AnimationFrame *> _frames;
+
+ void anim0();
+ void anim1();
+ void anim2();
+ void anim3();
+ void anim4();
+ void animNone();
+ void anim7();
+
+ AnimationFrame *calcFrame();
+ AnimationFrame *calcFrame1();
+ void setFrame(AnimationFrame *frame);
+ void setFrame1(AnimationFrame *frame);
+public:
+ int _type;
+ int _scaling;
+ int _frameNumber;
+ int _initialTicks;
+ int _loopCount;
+ int _countdownTicks;
+ int _currentLoopCount;
+public:
+ Animation(AccessEngine *vm, Common::SeekableReadStream *stream);
+ ~Animation();
+
+ void animate();
+};
+
+class AnimationFrame {
+public:
+ int _baseX, _baseY;
+ int _frameDelay;
+ Common::Array<AnimationFramePart *> _parts;
+public:
+ AnimationFrame(Common::SeekableReadStream *stream, int startOffset);
+ ~AnimationFrame();
+};
+
+class AnimationFramePart {
+public:
+ byte _flags;
+ int _spritesIndex;
+ int _frameIndex;
+ Common::Point _position;
+ int _offsetY;
+public:
+ AnimationFramePart(Common::SeekableReadStream *stream);
+};
+
+} // End of namespace Access
+
+#endif /* ACCESS_ANIMATION_H */
diff --git a/engines/access/asurface.cpp b/engines/access/asurface.cpp
new file mode 100644
index 0000000000..5f4372d5af
--- /dev/null
+++ b/engines/access/asurface.cpp
@@ -0,0 +1,346 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public 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/endian.h"
+#include "common/memstream.h"
+#include "access/access.h"
+#include "access/asurface.h"
+
+namespace Access {
+
+SpriteResource::SpriteResource(AccessEngine *vm, Resource *res) {
+ Common::Array<uint32> offsets;
+ int count = res->_stream->readUint16LE();
+
+ for (int i = 0; i < count; i++)
+ 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) {
+ res->_stream->seek(offsets[i]);
+ int frameSize = offsets[i + 1] - offsets[i];
+
+ SpriteFrame *frame = new SpriteFrame(vm, res->_stream, frameSize);
+ _frames.push_back(frame);
+ }
+}
+
+SpriteResource::~SpriteResource() {
+ for (uint i = 0; i < _frames.size(); ++i)
+ delete _frames[i];
+}
+
+SpriteFrame::SpriteFrame(AccessEngine *vm, Common::SeekableReadStream *stream, int frameSize) {
+ 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();
+ int len = stream->readByte();
+ assert((offset + len) <= w);
+
+ byte *destP = (byte *)getBasePtr(offset, y);
+ stream->read(destP, len);
+ }
+}
+
+SpriteFrame::~SpriteFrame() {
+ free();
+}
+
+/*------------------------------------------------------------------------*/
+
+ImageEntry::ImageEntry() {
+ _frameNumber = 0;
+ _spritesPtr = nullptr;
+ _offsetY = 0;
+ _flags = 0;
+}
+
+/*------------------------------------------------------------------------*/
+
+static bool sortImagesY(const ImageEntry &ie1, const ImageEntry &ie2) {
+ 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) {
+ assert(size() < 35);
+ push_back(ie);
+ Common::sort(begin(), end(), sortImagesY);
+}
+
+/*------------------------------------------------------------------------*/
+
+int ASurface::_clipWidth;
+int ASurface::_clipHeight;
+
+ASurface::ASurface(): Graphics::Surface() {
+ _leftSkip = _rightSkip = 0;
+ _topSkip = _bottomSkip = 0;
+ _lastBoundsX = _lastBoundsY = 0;
+ _lastBoundsW = _lastBoundsH = 0;
+ _orgX1 = _orgY1 = 0;
+ _orgX2 = _orgY2 = 0;
+ _lColor = 0;
+ _maxChars = 0;
+}
+
+ASurface::~ASurface() {
+ free();
+ _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);
+}
+
+bool ASurface::clip(Common::Rect &r) {
+ int skip;
+ _leftSkip = _rightSkip = 0;
+ _topSkip = _bottomSkip = 0;
+
+ if (r.left > _clipWidth || r.left < 0) {
+ if (r.left >= 0)
+ return true;
+
+ skip = -r.left;
+ r.setWidth(r.width() - skip);
+ _leftSkip = skip;
+ r.moveTo(0, r.top);
+ }
+
+ 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 || r.top < 0) {
+ if (r.top >= 0)
+ return true;
+
+ skip = -r.top;
+ r.setHeight(r.height() - skip);
+ _topSkip = skip;
+ r.moveTo(r.left, 0);
+ }
+
+ 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();
+
+ plotF(frame, pt);
+ }
+}
+
+void ASurface::transBlitFrom(ASurface *src, const Common::Point &destPos) {
+ if (getPixels() == nullptr)
+ create(w, h);
+
+ 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)
+ *destP = *srcP;
+ }
+ }
+}
+
+void ASurface::transBlitFrom(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;
+ int scaleXCtr = 0, scaleYCtr = 0;
+
+ for (int yCtr = 0, destY = bounds.top; yCtr < src->h; ++yCtr) {
+ // Handle skipping lines if Y scaling
+ scaleYCtr += scaleY;
+ if (scaleYCtr < SCALE_LIMIT)
+ continue;
+ scaleYCtr -= SCALE_LIMIT;
+
+ // Handle off-screen lines
+ if (destY >= this->h)
+ break;
+
+ if (destY >= 0) {
+ // Handle drawing the line
+ 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 < src->w; ++xCtr, ++pSrc) {
+ // Handle horizontal scaling
+ scaleXCtr += scaleX;
+ if (scaleXCtr < SCALE_LIMIT)
+ continue;
+ scaleXCtr -= SCALE_LIMIT;
+
+ // Only handle on-screen pixels
+ if (x >= this->w)
+ break;
+ if (x >= 0 && *pSrc != 0)
+ *pDest = *pSrc;
+
+ ++pDest;
+ ++x;
+ }
+ }
+
+ ++destY;
+ }
+}
+
+void ASurface::transBlitFrom(ASurface &src) {
+ blitFrom(src);
+}
+
+void ASurface::blitFrom(Graphics::Surface &src) {
+ assert(w >= src.w && h >= src.h);
+ 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) {
+ blitFrom(*src);
+}
+
+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));
+}
+
+void ASurface::plotB(SpriteFrame *frame, const Common::Point &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) {
+ transBlitFrom(frame, bounds);
+}
+
+void ASurface::sPlotB(SpriteFrame *frame, const Common::Rect &bounds) {
+ ASurface flippedFrame;
+ frame->flipHorizontal(flippedFrame);
+
+ transBlitFrom(&flippedFrame, bounds);
+}
+
+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);
+ }
+}
+
+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;
+ }
+}
+
+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 + (pitch * h) - TILE_WIDTH, p + (pitch * h));
+}
+
+void ASurface::moveBufferUp() {
+ byte *p = (byte *)getPixels();
+ Common::copy(p + (pitch * TILE_HEIGHT), p + (pitch * h), p);
+}
+
+void ASurface::moveBufferDown() {
+ byte *p = (byte *)getPixels();
+ Common::copy_backward(p, p + (pitch * (h - TILE_HEIGHT)), p + (pitch * h));
+}
+
+} // End of namespace Access
diff --git a/engines/access/asurface.h b/engines/access/asurface.h
new file mode 100644
index 0000000000..4fb47b9c09
--- /dev/null
+++ b/engines/access/asurface.h
@@ -0,0 +1,166 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public 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/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 SpriteResource;
+class SpriteFrame;
+
+class ASurface : public Graphics::Surface {
+private:
+ Graphics::Surface _savedBlock;
+
+ void flipHorizontal(ASurface &dest);
+protected:
+ Common::Rect _savedBounds;
+public:
+ 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;
+public:
+ static int _clipWidth, _clipHeight;
+public:
+ ASurface();
+
+ virtual ~ASurface();
+
+ void create(uint16 width, uint16 height);
+
+ void clearBuffer();
+
+ bool clip(Common::Rect &r);
+
+ void plotImage(SpriteResource *sprite, int frameNum, const Common::Point &pt);
+
+ /**
+ * Scaled draw frame in forward orientation
+ */
+ void sPlotF(SpriteFrame *frame, const Common::Rect &bounds);
+
+ /**
+ * 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);
+
+ virtual void copyBlock(ASurface *src, const Common::Rect &bounds);
+
+ virtual void restoreBlock();
+
+ virtual void drawRect();
+
+ virtual void transBlitFrom(ASurface *src, const Common::Point &destPos);
+
+ virtual void transBlitFrom(ASurface *src, const Common::Rect &bounds);
+
+ virtual void transBlitFrom(ASurface &src);
+
+ virtual void blitFrom(Graphics::Surface &src);
+
+ virtual void copyBuffer(Graphics::Surface *src);
+
+ virtual void addDirtyRect(const Common::Rect &r) {}
+
+ void copyTo(ASurface *dest) { dest->blitFrom(*this); }
+
+ void saveBlock(const Common::Rect &bounds);
+
+ void moveBufferLeft();
+
+ void moveBufferRight();
+
+ void moveBufferUp();
+
+ void moveBufferDown();
+};
+
+class SpriteFrame : public ASurface {
+public:
+ SpriteFrame(AccessEngine *vm, Common::SeekableReadStream *stream, int frameSize);
+ ~SpriteFrame();
+};
+
+class SpriteResource {
+public:
+ Common::Array<SpriteFrame *> _frames;
+public:
+ SpriteResource(AccessEngine *vm, Resource *res);
+ ~SpriteResource();
+
+ int getCount() { return _frames.size(); }
+
+ SpriteFrame *getFrame(int idx) { return _frames[idx]; }
+};
+
+enum ImageFlag {
+ IMGFLAG_CROPPED = 1,
+ IMGFLAG_BACKWARDS = 2,
+ IMGFLAG_DRAWN = 4,
+ IMGFLAG_UNSCALED = 8
+};
+
+class ImageEntry {
+public:
+ int _frameNumber;
+ SpriteResource *_spritesPtr;
+ int _offsetY;
+ Common::Point _position;
+ int _flags;
+public:
+ ImageEntry();
+};
+
+class ImageEntryList : public Common::Array<ImageEntry> {
+public:
+ void addToList(ImageEntry &ie);
+};
+
+} // End of namespace Access
+
+#endif /* ACCESS_ASURFACE_H */
diff --git a/engines/access/bubble_box.cpp b/engines/access/bubble_box.cpp
new file mode 100644
index 0000000000..28c211991c
--- /dev/null
+++ b/engines/access/bubble_box.cpp
@@ -0,0 +1,281 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public 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 {
+
+BubbleBox::BubbleBox(AccessEngine *vm) : Manager(vm) {
+ _startItem = 0;
+ _startBox = 0;
+ _charCol = _rowOff = 0;
+ _type = TYPE_2;
+ _bounds = Common::Rect(64, 32, 64 + 130, 32 + 122);
+ _bubbleDisplStr = "";
+}
+
+void BubbleBox::load(Common::SeekableReadStream *stream) {
+ _bubbleTitle.clear();
+
+ byte v;
+ while ((v = stream->readByte()) != 0)
+ _bubbleTitle += (char)v;
+
+ _bubbleDisplStr = _bubbleTitle;
+}
+
+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;
+ r.right = MIN(r.right, (int16)_vm->_screen->w);
+
+ _vm->_screen->copyBlock(&_vm->_buffer1, r);
+ }
+
+ // Clear the list
+ _bubbles.clear();
+}
+
+void BubbleBox::placeBubble(const Common::String &msg) {
+ _vm->_screen->_maxChars = 27;
+ placeBubble1(msg);
+}
+
+void BubbleBox::placeBubble1(const Common::String &msg) {
+ _bubbles.clear();
+ _vm->_fonts._charSet._lo = 1;
+ _vm->_fonts._charSet._hi = 8;
+ _vm->_fonts._charFor._lo = 29;
+ _vm->_fonts._charFor._hi = 32;
+
+ calcBubble(msg);
+
+ Common::Rect r = _bubbles[0];
+ r.translate(-2, 0);
+ _vm->_screen->saveBlock(r);
+ printBubble(msg);
+}
+
+void BubbleBox::calcBubble(const Common::String &msg) {
+ // Save points
+ Common::Point printOrg = _vm->_screen->_printOrg;
+ Common::Point printStart = _vm->_screen->_printStart;
+
+ // Figure out maximum width allowed
+ if (_type == TYPE_4) {
+ _vm->_fonts._printMaxX = 110;
+ } else {
+ _vm->_fonts._printMaxX = _vm->_fonts._font2.stringWidth(_bubbleDisplStr);
+ }
+
+ // Start of with a rect with the given starting x and y
+ Common::Rect bounds(printOrg.x - 2, printOrg.y - 10, printOrg.x - 2, printOrg.y - 10);
+
+ // Loop through getting lines
+ Common::String s = msg;
+ Common::String line;
+ int width = 0;
+ bool lastLine;
+ do {
+ 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;
+ _vm->_screen->_printOrg.x = _vm->_screen->_printStart.x;
+ } while (!lastLine);
+
+ if (_type == TYPE_4)
+ ++_vm->_screen->_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->_screen->_printOrg.y + 6;
+ if (_type == TYPE_4)
+ y += 6;
+ int height = y - bounds.top;
+ bounds.setHeight(height);
+
+ height -= (_type == TYPE_4) ? 30 : 24;
+ if (height >= 0)
+ bounds.setHeight(bounds.height() + 13 - (height % 13));
+
+ // Add the new bounds to the bubbles list
+ _bubbles.push_back(bounds);
+
+ // Restore points
+ _vm->_screen->_printOrg = printOrg;
+ _vm->_screen->_printStart = printStart;
+}
+
+void BubbleBox::printBubble(const Common::String &msg) {
+ 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, _vm->_screen->_maxChars * 6, line, width);
+
+ // Set font colors
+ font2._fontColors[0] = 0;
+ font2._fontColors[1] = 27;
+ font2._fontColors[2] = 28;
+ font2._fontColors[3] = 29;
+
+ 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;
+ } while (!lastLine);
+}
+
+void BubbleBox::drawBubble(int 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 = screen._printOrg;
+ Common::Point printStart = screen._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
+ 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;
+ _vm->_screen->_orgY1 = _bounds.top;
+ _vm->_screen->_orgX2 = _bounds.right - 2;
+ _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 = 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 for filename dialog
+ error("TODO: Box type 4");
+ }
+
+ // Draw images to form the sides
+ yp = screen._orgY1 + 12;
+ 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));
+ }
+
+ // Handle drawing title
+ 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, _bubbleDisplStr, Common::Point(
+ _bounds.left + (_bounds.width() / 2) - (titleWidth / 2), _bounds.top + 1));
+
+ // Restore positional state
+ fonts._charSet = charSet;
+ fonts._charFor = charFor;
+ screen._printOrg = printOrg;
+ screen._printStart = printStart;
+ _charCol = charCol;
+ _rowOff = rowOff;
+ _vm->_screen->restoreScreen();
+
+ // Free icons data
+ delete icons;
+}
+
+} // End of namespace Access
diff --git a/engines/access/bubble_box.h b/engines/access/bubble_box.h
new file mode 100644
index 0000000000..0b3f139520
--- /dev/null
+++ b/engines/access/bubble_box.h
@@ -0,0 +1,85 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef ACCESS_BUBBLE_BOX_H
+#define ACCESS_BUBBLE_BOX_H
+
+#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"
+#include "access/data.h"
+
+namespace Access {
+
+class AccessEngine;
+
+enum BoxType { TYPE_2 = 2, TYPE_4 = 4 };
+
+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;
+ Common::String _bubbleDisplStr;
+
+ Common::Array<Common::Rect> _bubbles;
+public:
+ BubbleBox(AccessEngine *vm);
+
+ void load(Common::SeekableReadStream *stream);
+
+ void clearBubbles();
+
+ 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);
+
+ void doBox(int item, int box);
+};
+
+} // End of namespace Access
+
+#endif /* ACCESS_BUBBLE_BOX_H */
diff --git a/engines/access/char.cpp b/engines/access/char.cpp
new file mode 100644
index 0000000000..b359bcf13a
--- /dev/null
+++ b/engines/access/char.cpp
@@ -0,0 +1,162 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#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();
+ _estabIndex = s.readSint16LE();
+ _screenFile.load(s);
+ _paletteFile.load(s);
+ _startColor = s.readUint16LE();
+ _numColors = s.readUint16LE();
+
+ // Load cells
+ for (byte cell = s.readByte(); cell != 0xff; cell = s.readByte()) {
+ CellIdent ci;
+ ci._cell = cell;
+ ci.load(s);
+
+ _cells.push_back(ci);
+ }
+
+ _animFile.load(s);
+ _scriptFile.load(s);
+
+ for (int16 v = s.readSint16LE(); v != -1; v = s.readSint16LE()) {
+ ExtraCell ec;
+ ec._vid._fileNum = v;
+ ec._vid._subfile = s.readSint16LE();
+ ec._vidSound.load(s);
+
+ _extraCells.push_back(ec);
+ }
+}
+
+CharEntry::CharEntry() {
+ _charFlag = 0;
+ _estabIndex = 0;
+ _startColor = _numColors = 0;
+}
+
+/*------------------------------------------------------------------------*/
+
+CharManager::CharManager(AccessEngine *vm) : Manager(vm) {
+ switch (vm->getGameID()) {
+ case GType_Amazon:
+ // Setup character list
+ 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");
+ }
+
+ _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(0, ce._estabIndex);
+ }
+ }
+
+ 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.blitFrom(*_vm->_screen);
+ _vm->_buffer2.blitFrom(*_vm->_screen);
+ _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) {
+ Resource *data = _vm->_files->loadFile(ce._animFile);
+ _vm->_animation->loadAnimations(data);
+ }
+
+ // Load script data
+ _vm->_scripts->freeScriptData();
+ if (ce._scriptFile._fileNum != -1) {
+ Resource *data = _vm->_files->loadFile(ce._scriptFile);
+ _vm->_scripts->setScript(data);
+ }
+
+ // 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() {
+ Resource *iconData = _vm->_files->loadFile("ICONS.LZ");
+ SpriteResource *spr = new SpriteResource(_vm, iconData);
+ 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/char.h b/engines/access/char.h
new file mode 100644
index 0000000000..6fb4934978
--- /dev/null
+++ b/engines/access/char.h
@@ -0,0 +1,64 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#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 _estabIndex;
+ 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 {
+private:
+ void charMenu();
+public:
+ Common::Array<CharEntry> _charTable;
+ int _charFlag;
+
+public:
+ CharManager(AccessEngine *vm);
+
+ void loadChar(int charId);
+};
+
+} // End of namespace Access
+
+#endif /* ACCESS_CHAR_H */
diff --git a/engines/access/configure.engine b/engines/access/configure.engine
new file mode 100644
index 0000000000..b1defce946
--- /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/data.cpp b/engines/access/data.cpp
new file mode 100644
index 0000000000..cf40e81ccb
--- /dev/null
+++ b/engines/access/data.cpp
@@ -0,0 +1,76 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "common/algorithm.h"
+#include "common/stream.h"
+#include "common/system.h"
+#include "graphics/palette.h"
+#include "access/data.h"
+
+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;
+ }
+}
+
+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 = 0;
+ }
+ }
+ }
+}
+
+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
new file mode 100644
index 0000000000..19413ecd7e
--- /dev/null
+++ b/engines/access/data.h
@@ -0,0 +1,103 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef ACCESS_DATA_H
+#define ACCESS_DATA_H
+
+#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"
+
+namespace Access {
+
+class AccessEngine;
+
+class Manager {
+protected:
+ AccessEngine *_vm;
+public:
+ Manager(AccessEngine *vm) : _vm(vm) {}
+};
+
+struct TimerEntry {
+ int _initTm;
+ int _timer;
+ byte _flag;
+
+ TimerEntry() {
+ _initTm = _timer = 0;
+ _flag = 0;
+ }
+};
+
+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();
+
+ /**
+ * Update the timer list
+ */
+ void updateTimers();
+
+ /**
+ * Synchronize savegame data
+ */
+ void synchronize(Common::Serializer &s);
+};
+
+class ExtraCell {
+public:
+ FileIdent _vid;
+ 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/debugger.cpp b/engines/access/debugger.cpp
new file mode 100644
index 0000000000..6cb2bb606c
--- /dev/null
+++ b/engines/access/debugger.cpp
@@ -0,0 +1,164 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public 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"
+#include "access/amazon/amazon_game.h"
+
+namespace Access {
+
+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;
+}
+
+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));
+ registerCmd("cheat", WRAP_METHOD(Debugger, Cmd_Cheat));
+
+ 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;
+ }
+}
+
+Debugger::~Debugger() {
+ delete[] _sceneDescr;
+}
+
+bool Debugger::Cmd_LoadScene(int argc, const char **argv) {
+ 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;
+
+ case 2: {
+ int newRoom = strToInt(argv[1]);
+ if (newRoom < 0 || newRoom >= _sceneNumb) {
+ debugPrintf("Invalid Room Number\n");
+ return true;
+ }
+ if (!_sceneDescr[newRoom].size()) {
+ debugPrintf("Unused Room Number\n");
+ return true;
+ }
+
+ _vm->_player->_roomNumber = newRoom;
+
+ _vm->_room->_function = FN_CLEAR1;
+ _vm->freeChar();
+ _vm->_converseMode = 0;
+ _vm->_scripts->_endFlag = true;
+ _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;
+ }
+}
+
+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 {
+
+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), true);
+
+ return false;
+}
+
+} // End of namespace Amazon
+
+} // End of namespace Access
diff --git a/engines/access/debugger.h b/engines/access/debugger.h
new file mode 100644
index 0000000000..f4d8df7634
--- /dev/null
+++ b/engines/access/debugger.h
@@ -0,0 +1,64 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef ACCESS_DEBUGGER_H
+#define ACCESS_DEBUGGER_H
+
+#include "common/scummsys.h"
+#include "gui/debugger.h"
+#include "access/amazon/amazon_resources.h"
+#include "access/martian/martian_resources.h"
+
+namespace Access {
+
+class AccessEngine;
+
+class Debugger : public GUI::Debugger {
+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:
+ 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/decompress.cpp b/engines/access/decompress.cpp
new file mode 100644
index 0000000000..c5656afa51
--- /dev/null
+++ b/engines/access/decompress.cpp
@@ -0,0 +1,128 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public 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 = 0;
+ uint16 oldCode = 0;
+ uint16 copyLength, maxCodeValue, code, nextCode, lastCode;
+
+ 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 0000000000..eea450086b
--- /dev/null
+++ b/engines/access/decompress.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_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/detection.cpp b/engines/access/detection.cpp
new file mode 100644
index 0000000000..441740c1b2
--- /dev/null
+++ b/engines/access/detection.cpp
@@ -0,0 +1,209 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public 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 "access/amazon/amazon_game.h"
+#include "access/martian/martian_game.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;
+}
+
+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;
+}
+
+Common::Platform AccessEngine::getPlatform() const {
+ return _gameDescription->desc.platform;
+}
+
+} // End of namespace Access
+
+static const PlainGameDescriptor AccessGames[] = {
+ {"Access", "Access"},
+ {"amazon", "Amazon: Guardians of Eden"},
+ {"martian", "Martian Memorandum"},
+ {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 Engine (c) 1989-1994 Access Software";
+ }
+
+ 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) {
+ switch (gd->gameID) {
+ 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");
+ }
+ }
+ return gd != 0;
+}
+
+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;
+}
+
+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 {
+ 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();
+}
+
+
+#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 0000000000..88a64470c5
--- /dev/null
+++ b/engines/access/detection_tables.h
@@ -0,0 +1,91 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public 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 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,
+ AD_ENTRY1s("c00.ap", "dcabf69d5a0d911168cb73511ebaead0", 331481),
+ Common::EN_ANY,
+ Common::kPlatformDOS,
+ ADGF_NO_FLAGS,
+ GUIO1(GUIO_NONE)
+ },
+ GType_Amazon,
+ 0
+ },
+
+ // Amazon Guardians of Eden - Demo English
+ {
+ {
+ "amazon",
+ "Demo",
+ AD_ENTRY1s("c25.ap", "5baba0c052d22157499bfa05cb1ed5b7", 65458),
+ Common::EN_ANY,
+ Common::kPlatformDOS,
+ ADGF_DEMO,
+ GUIO1(GUIO_NONE)
+ },
+ GType_Amazon,
+ 0
+ },
+
+ {
+ // Amazon: Guardians of Eden - CD English
+ {
+ "amazon",
+ "CD",
+ AD_ENTRY1s("checksum.crc", "bef85478132fec74cb5d9067f3a37d24", 8),
+ Common::EN_ANY,
+ Common::kPlatformDOS,
+ ADGF_CD,
+ GUIO1(GUIO_NONE)
+ },
+ GType_Amazon,
+ 0
+ },
+
+ {
+ // Martian Memorandum
+ {
+ "martian",
+ nullptr,
+ AD_ENTRY1s("r00.ap", "af98db5ee7f9ef86c6b1f43187a3691b", 31),
+ Common::EN_ANY,
+ Common::kPlatformDOS,
+ ADGF_NO_FLAGS,
+ GUIO1(GUIO_NONE)
+ },
+ GType_MartianMemorandum,
+ 0
+ },
+
+ { AD_TABLE_END_MARKER, 0, 0 }
+};
+
+} // End of namespace Access
diff --git a/engines/access/events.cpp b/engines/access/events.cpp
new file mode 100644
index 0000000000..6ffe67acfb
--- /dev/null
+++ b/engines/access/events.cpp
@@ -0,0 +1,373 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public 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 "common/endian.h"
+#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
+#define CURSOR_HEIGHT 16
+
+namespace Access {
+
+EventsManager::EventsManager(AccessEngine *vm) : _vm(vm) {
+ _cursorId = CURSOR_NONE;
+ _normalMouse = CURSOR_CROSSHAIRS;
+ _frameCounter = 10;
+ _priorFrameTime = 0;
+ _leftButton = _rightButton = false;
+ _middleButton = false;
+ _wheelUp = _wheelDown = false;
+ _mouseCol = _mouseRow = 0;
+ _cursorExitFlag = false;
+ _vbCount = 0;
+ _keyCode = Common::KEYCODE_INVALID;
+ _priorTimerTime = 0;
+}
+
+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;
+ _cursorId = cursorId;
+
+ if (cursorId == CURSOR_INVENTORY) {
+ // Set the cursor
+ CursorMan.replaceCursor(_invCursor.getPixels(), _invCursor.w, _invCursor.h,
+ _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];
+ 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::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() {
+ CursorMan.showMouse(true);
+}
+
+void EventsManager::hideCursor() {
+ CursorMan.showMouse(false);
+}
+
+bool EventsManager::isCursorVisible() {
+ return CursorMan.isVisible();
+}
+
+void EventsManager::pollEvents(bool skipTimers) {
+ if (checkForNextFrameCounter()) {
+ nextFrame();
+ }
+
+ if (checkForNextTimerUpdate() && !skipTimers)
+ nextTimer();
+
+ _vm->_sound->checkSoundQueue();
+
+ _wheelUp = _wheelDown = false;
+
+ Common::Event event;
+ while (g_system->getEventManager()->pollEvent(event)) {
+ 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();
+ } else {
+ keyControl(event.kbd.keycode, true);
+ }
+ return;
+ case Common::EVENT_KEYUP:
+ keyControl(event.kbd.keycode, false);
+ return;
+ case Common::EVENT_MOUSEMOVE:
+ _mousePos = event.mouse;
+ _mouseCol = _mousePos.x / 8;
+ _mouseRow = _mousePos.y / 8;
+ 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;
+ 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;
+ }
+ }
+}
+
+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;
+
+ 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() {
+ pollEvents();
+ delay();
+}
+
+bool EventsManager::checkForNextFrameCounter() {
+ // Check for next game frame
+ uint32 milli = g_system->getMillis();
+ if ((milli - _priorFrameTime) >= GAME_FRAME_TIME) {
+ --_vbCount;
+ ++_frameCounter;
+ _priorFrameTime = milli;
+
+ return true;
+ }
+
+ return false;
+}
+
+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();
+
+ // TODO: Refactor for dirty rects
+ _vm->_screen->updateScreen();
+}
+
+void EventsManager::nextTimer() {
+ _vm->_animation->updateTimers();
+ _vm->_timers.updateTimers();
+}
+
+void EventsManager::delay(int time) {
+ g_system->delayMillis(time);
+}
+
+void EventsManager::zeroKeys() {
+ _keyCode = Common::KEYCODE_INVALID;
+}
+
+bool EventsManager::getKey(Common::KeyState &key) {
+ if (_keyCode == Common::KEYCODE_INVALID) {
+ return false;
+ } else {
+ key = _keyCode;
+ _keyCode = Common::KEYCODE_INVALID;
+ return true;
+ }
+}
+
+bool EventsManager::isKeyPending() const {
+ return _keyCode != Common::KEYCODE_INVALID;
+}
+
+void EventsManager::debounceLeft() {
+ while (_leftButton && !_vm->shouldQuit()) {
+ pollEventsAndWait();
+ }
+}
+
+void EventsManager::clearEvents() {
+ _leftButton = _rightButton = false;
+ zeroKeys();
+}
+
+void EventsManager::waitKeyMouse() {
+ while (!_vm->shouldQuit() && !isKeyMousePressed()) {
+ pollEvents(true);
+ delay();
+ }
+}
+
+Common::Point EventsManager::calcRawMouse() {
+ Common::Point pt;
+ Screen &screen = *_vm->_screen;
+ pt.x = _mousePos.x - screen._windowXAdd +
+ (_vm->_scrollCol * TILE_WIDTH) + _vm->_scrollX;
+ pt.y = _mousePos.y - screen._screenYOff - screen._windowYAdd +
+ (_vm->_scrollRow * TILE_HEIGHT) + _vm->_scrollY;
+
+ return pt;
+}
+
+int EventsManager::checkMouseBox1(Common::Array<Common::Rect> &rects) {
+ for (uint16 i = 0; i < rects.size(); ++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;
+ }
+
+ return -1;
+}
+
+bool EventsManager::isKeyMousePressed() {
+ bool result = _leftButton || _rightButton || isKeyPending();
+ debounceLeft();
+ zeroKeys();
+
+ return result;
+}
+
+void EventsManager::centerMousePos() {
+ _mousePos = Common::Point(160, 100);
+}
+
+void EventsManager::restrictMouse() {
+ // No implementation in ScummVM
+}
+
+} // End of namespace Access
diff --git a/engines/access/events.h b/engines/access/events.h
new file mode 100644
index 0000000000..b8c5f0ee5e
--- /dev/null
+++ b/engines/access/events.h
@@ -0,0 +1,157 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public 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 = -1,
+ CURSOR_ARROW = 0, CURSOR_CROSSHAIRS, CURSOR_2, CURSOR_3, CURSOR_LOOK,
+ CURSOR_USE, CURSOR_TAKE, CURSOR_CLIMB, CURSOR_TALK, CURSOR_HELP,
+ CURSOR_INVENTORY = 99
+};
+
+#define GAME_FRAME_RATE 100
+#define GAME_FRAME_TIME (1000 / GAME_FRAME_RATE)
+#define GAME_TIMER_TIME 15
+
+class AccessEngine;
+
+class EventsManager {
+private:
+ AccessEngine *_vm;
+ uint32 _frameCounter;
+ uint32 _priorFrameTime;
+ uint32 _priorTimerTime;
+ Common::KeyCode _keyCode;
+
+ Graphics::Surface _invCursor;
+ bool checkForNextFrameCounter();
+ bool checkForNextTimerUpdate();
+ void nextFrame();
+ void nextTimer();
+ void keyControl(Common::KeyCode keycode, bool isKeyDown);
+public:
+ CursorType _cursorId;
+ CursorType _normalMouse;
+ bool _leftButton, _rightButton;
+ bool _middleButton;
+ bool _wheelUp, _wheelDown;
+ Common::Point _mousePos;
+ int _mouseCol, _mouseRow;
+ bool _cursorExitFlag;
+ int _vbCount;
+public:
+ /**
+ * Constructor
+ */
+ EventsManager(AccessEngine *vm);
+
+ /**
+ * Destructor
+ */
+ ~EventsManager();
+
+ /**
+ * Return frame counter
+ */
+ uint32 getFrameCounter() { return _frameCounter; }
+
+ /**
+ * Sets the cursor and reset the normal cursor
+ */
+ void forceSetCursor(CursorType cursorId);
+
+ /**
+ * Sets the normal cursor
+ */
+ void setNormalCursor(CursorType cursorId);
+
+ /**
+ * Sets the cursor
+ */
+ 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; }
+
+ /**
+ * Show the mouse cursor
+ */
+ void showCursor();
+
+ /**
+ * Hide the mouse cursor
+ */
+ void hideCursor();
+
+ /**
+ * Returns if the mouse cursor is visible
+ */
+ bool isCursorVisible();
+
+ void pollEvents(bool skipTimers = false);
+
+ void pollEventsAndWait();
+
+ void zeroKeys();
+
+ bool getKey(Common::KeyState &key);
+
+ bool isKeyPending() const;
+
+ void delay(int time = 5);
+
+ void debounceLeft();
+
+ void clearEvents();
+
+ void waitKeyMouse();
+
+ Common::Point &getMousePos() { return _mousePos; }
+
+ Common::Point calcRawMouse();
+
+ int checkMouseBox1(Common::Array<Common::Rect> &rects);
+
+ bool isKeyMousePressed();
+
+ void centerMousePos();
+ void restrictMouse();
+};
+
+} // End of namespace Access
+
+#endif /* ACCESS_EVENTS_H */
diff --git a/engines/access/files.cpp b/engines/access/files.cpp
new file mode 100644
index 0000000000..42a7914638
--- /dev/null
+++ b/engines/access/files.cpp
@@ -0,0 +1,239 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public 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/substream.h"
+#include "access/files.h"
+#include "access/amazon/amazon_resources.h"
+#include "access/martian/martian_resources.h"
+#include "access/access.h"
+
+namespace Access {
+
+FileIdent::FileIdent() {
+ _fileNum = -1;
+ _subfile = 0;
+}
+
+void FileIdent::load(Common::SeekableReadStream &s) {
+ _fileNum = s.readSint16LE();
+ _subfile = s.readUint16LE();
+}
+
+/*------------------------------------------------------------------------*/
+
+CellIdent::CellIdent(int cell, int fileNum, int subfile) {
+ _cell = cell;
+ _fileNum = fileNum;
+ _subfile = subfile;
+}
+
+/*------------------------------------------------------------------------*/
+
+Resource::Resource() {
+ _stream = nullptr;
+ _size = 0;
+ _data = nullptr;
+}
+
+Resource::~Resource() {
+ delete[] _data;
+ delete _stream;
+}
+
+Resource::Resource(byte *p, int size) {
+ _data = p;
+ _size = size;
+ _stream = new Common::MemoryReadStream(p, size);
+}
+
+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;
+}
+
+/*------------------------------------------------------------------------*/
+
+FileManager::FileManager(AccessEngine *vm) : _vm(vm) {
+ switch (vm->getGameID()) {
+ case GType_Amazon:
+ if (_vm->isDemo())
+ _filenames = &Amazon::FILENAMES_DEMO[0];
+ else
+ _filenames = &Amazon::FILENAMES[0];
+ break;
+ case GType_MartianMemorandum:
+ _filenames = &Martian::FILENAMES[0];
+ break;
+ default:
+ error("Unknown game");
+ }
+
+ _fileNumber = -1;
+ _setPaletteFlag = true;
+}
+
+FileManager::~FileManager() {
+}
+
+Resource *FileManager::loadFile(int fileNum, int subfile) {
+ Resource *res = new Resource();
+ setAppended(res, fileNum);
+ gotoAppended(res, subfile);
+
+ handleFile(res);
+ return res;
+}
+
+Resource *FileManager::loadFile(const FileIdent &fileIdent) {
+ return loadFile(fileIdent._fileNum, fileIdent._subfile);
+}
+
+Resource *FileManager::loadFile(const Common::String &filename) {
+ Resource *res = new Resource();
+
+ // Open the file
+ openFile(res, filename);
+
+ // Set up stream for the entire file
+ res->_size = res->_file.size();
+ res->_stream = res->_file.readStream(res->_size);
+
+ handleFile(res);
+ return res;
+}
+
+bool FileManager::existFile(const Common::String &filename) {
+ Common::File f;
+ return f.exists(filename);
+}
+
+void FileManager::openFile(Resource *res, const Common::String &filename) {
+ // Open up the file
+ _fileNumber = -1;
+ if (!res->_file.open(filename))
+ error("Could not open file - %s", filename.c_str());
+}
+
+void FileManager::loadScreen(Graphics::Surface *dest, int fileNum, int subfile) {
+ Resource *res = loadFile(fileNum, subfile);
+ handleScreen(dest, res);
+ delete res;
+}
+
+void FileManager::handleScreen(Graphics::Surface *dest, Resource *res) {
+ _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
+ res->_size -= res->_stream->pos();
+ handleFile(res);
+
+ if (dest != _vm->_screen)
+ dest->w = _vm->_screen->w;
+
+ if (dest->w == dest->pitch) {
+ res->_stream->read((byte *)dest->getPixels(), dest->w * dest->h);
+ } else {
+ for (int y = 0; y < dest->h; ++y) {
+ byte *pDest = (byte *)dest->getBasePtr(0, y);
+ 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) {
+ loadScreen(_vm->_screen, fileNum, subfile);
+}
+
+void FileManager::loadScreen(const Common::String &filename) {
+ Resource *res = loadFile(filename);
+ handleScreen(_vm->_screen, res);
+ delete res;
+}
+
+void FileManager::handleFile(Resource *res) {
+ char header[3];
+ res->_stream->read(&header[0], 3);
+ res->_stream->seek(-3, SEEK_CUR);
+
+ bool isCompressed = !strncmp(header, "DBE", 3);
+
+ // 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
+ 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;
+ }
+}
+
+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 its index
+ if (_fileNumber != fileNum) {
+ _fileNumber = fileNum;
+
+ // Read in the file index
+ int count = res->_file.readUint16LE();
+ assert(count <= 100);
+ _fileIndex.resize(count);
+ for (int i = 0; i < count; ++i)
+ _fileIndex[i] = res->_file.readUint32LE();
+ }
+}
+
+void FileManager::gotoAppended(Resource *res, int subfile) {
+ uint32 offset = _fileIndex[subfile];
+ uint32 size = (subfile == (int)_fileIndex.size() - 1) ? res->_file.size() - offset :
+ _fileIndex[subfile + 1] - offset;
+
+ 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
new file mode 100644
index 0000000000..8b1aef0363
--- /dev/null
+++ b/engines/access/files.h
@@ -0,0 +1,142 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public 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/array.h"
+#include "common/file.h"
+#include "graphics/surface.h"
+#include "access/decompress.h"
+
+namespace Access {
+
+class AccessEngine;
+
+struct FileIdent {
+ int _fileNum;
+ int _subfile;
+
+ FileIdent();
+ FileIdent(int fileNum, int subfile) { _fileNum = fileNum; _subfile = subfile; }
+
+ void load(Common::SeekableReadStream &s);
+};
+
+struct CellIdent : FileIdent {
+ byte _cell;
+
+ CellIdent() {}
+ 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, int size);
+ ~Resource();
+ byte *data();
+};
+
+class FileManager {
+private:
+ AccessEngine *_vm;
+ const char * const *_filenames;
+
+ 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);
+
+ /**
+ * Open up a sub-file resource within an alrady opened container file.
+ */
+ void gotoAppended(Resource *file, int subfile);
+public:
+ int _fileNumber;
+ Common::Array<uint32> _fileIndex;
+ bool _setPaletteFlag;
+public:
+ FileManager(AccessEngine *vm);
+ ~FileManager();
+
+ /**
+ * Check the existence of a given file
+ */
+ bool existFile(const Common::String &filename);
+
+ /**
+ * Load a given subfile from a container file
+ */
+ Resource *loadFile(int fileNum, int subfile);
+
+ /**
+ * Loads a resource specified by a file identifier
+ */
+ Resource *loadFile(const FileIdent &fileIdent);
+
+ /**
+ * Load a given file by name
+ */
+ Resource *loadFile(const Common::String &filename);
+
+ /**
+ * Load a given scren from a container file
+ */
+ void loadScreen(int fileNum, int subfile);
+
+ /**
+ * Load a given screen by name
+ */
+ void loadScreen(const Common::String &filename);
+
+ /**
+ * Load a screen resource onto a designated surface
+ */
+ void loadScreen(Graphics::Surface *dest, int fileNum, int subfile);
+};
+
+} // End of namespace Access
+
+#endif /* ACCESS_FILES_H */
diff --git a/engines/access/font.cpp b/engines/access/font.cpp
new file mode 100644
index 0000000000..8af183f193
--- /dev/null
+++ b/engines/access/font.cpp
@@ -0,0 +1,179 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public 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() {
+ _bitWidth = 0;
+ _height = 0;
+}
+
+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) {
+ if (c < ' ')
+ return 0;
+
+ 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);
+ 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') {
+ line = Common::String(s.c_str(), src);
+ s.clear();
+ return true;
+ }
+
+ // 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(ASurface *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(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);
+ 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 0000000000..6a812051ca
--- /dev/null
+++ b/engines/access/font.h
@@ -0,0 +1,103 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#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(ASurface *s, const Common::String &msg, const Common::Point &pt);
+
+ /**
+ * Draw a character on a given surface
+ */
+ int drawChar(ASurface *s, char c, Common::Point &pt);
+
+};
+
+class FontManager {
+public:
+ FontVal _charSet;
+ FontVal _charFor;
+ int _printMaxX;
+ Font _font1;
+ Font _font2;
+public:
+ FontManager();
+};
+
+} // End of namespace Access
+
+#endif /* ACCESS_FONT_H */
diff --git a/engines/access/inventory.cpp b/engines/access/inventory.cpp
new file mode 100644
index 0000000000..df499ba705
--- /dev/null
+++ b/engines/access/inventory.cpp
@@ -0,0 +1,536 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public 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/resources.h"
+#include "access/amazon/amazon_resources.h"
+#include "access/martian/martian_resources.h"
+
+namespace Access {
+
+void InventoryEntry::load(const Common::String &name, const int *data) {
+ _value = ITEM_NOT_FOUND;
+ _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;
+ _invChangeFlag = true;
+ _invRefreshFlag = false;
+ _invModeFlag = false;
+ _startAboutItem = 0;
+ _startTravelItem = 0;
+ _iconDisplayFlag = true;
+ _boxNum = 0;
+
+ 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:
+ names = Martian::INVENTORY_NAMES;
+ combineP = &Martian::COMBO_TABLE[0][0];
+ _inv.resize(54);
+ break;
+ default:
+ error("Unknown game");
+ }
+
+ 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];
+ _invCoords.push_back(Common::Rect(r[0], r[2], r[1], r[3]));
+ }
+}
+
+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 >= (int)_inv.size()) ? invalid : _inv[idx]._value;
+}
+
+int InventoryManager::useItem() {
+ return _vm->_useItem;
+}
+
+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
+ // if (_vm->_screen->_vesaMode) {
+ // _invRefreshFlag = true;
+ // newDisplayInv();
+ // }
+}
+
+int InventoryManager::newDisplayInv() {
+ 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) {
+ saveScreens();
+ }
+
+ savedFields();
+ screen.setPanel(1);
+ events._cursorExitFlag = false;
+ getList();
+ initFields();
+
+ files.loadScreen(&_vm->_buffer1, 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();
+ // The original was testing the vesa mode too.
+ // We removed this check as we don't use pre-rendering
+ if (!_invRefreshFlag) {
+ screen.clearScreen();
+ screen.setPalette();
+ }
+
+ if (!room._tile && !_invRefreshFlag) {
+ restoreScreens();
+ } else {
+ screen.setBufferScan();
+ room.buildScreen();
+
+ // 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;
+ screen._screenChangeFlag = false;
+ _invModeFlag = false;
+ events.debounceLeft();
+ _vm->_timers.restoreTimers();
+ _vm->_startup = 1;
+
+ int result = 0;
+ if (!_invRefreshFlag) {
+ if (_vm->_useItem == -1) {
+ result = 2;
+ events.forceSetCursor(CURSOR_CROSSHAIRS);
+ } else
+ events.forceSetCursor(CURSOR_INVENTORY);
+ }
+
+ _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 = _vm->_scrollX;
+ _fields._scrollY = _vm->_scrollY;
+ _fields._clipWidth = screen._clipWidth;
+ _fields._clipHeight = screen._clipHeight;
+ _fields._bufferStart = screen._bufferStart;
+ _fields._scrollCol = _vm->_scrollCol;
+ _fields._scrollRow = _vm->_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;
+ _vm->_scrollX = _fields._scrollX;
+ _vm->_scrollY = _fields._scrollY;
+ screen._clipWidth = _fields._clipWidth;
+ screen._clipHeight = _fields._clipHeight;
+ screen._bufferStart = _fields._bufferStart;
+ _vm->_scrollCol = _fields._scrollCol;
+ _vm->_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._bufferStart.x = 0;
+ screen._bufferStart.y = 0;
+ _vm->_scrollX = _vm->_scrollY = 0;
+
+ _vm->_buffer1.clearBuffer();
+ _vm->_buffer2.clearBuffer();
+ // 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();
+}
+
+void InventoryManager::getList() {
+ _items.clear();
+ _tempLOff.clear();
+
+ for (uint i = 0; i < _inv.size(); ++i) {
+ if (_inv[i]._value == ITEM_IN_INVENTORY) {
+ _items.push_back(i);
+ _tempLOff.push_back(_inv[i]._name);
+ }
+ }
+}
+
+void InventoryManager::showAllItems() {
+ _iconDisplayFlag = true;
+
+ 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->_screen->copyBlock(&_vm->_buffer2, Common::Rect(pt.x, pt.y, pt.x + 46, pt.y + 35));
+ }
+}
+
+void InventoryManager::chooseItem() {
+ EventsManager &events = *_vm->_events;
+ _vm->_useItem = -1;
+
+ while (!_vm->shouldQuit()) {
+ // Check for events
+ events.pollEventsAndWait();
+
+ int selIndex;
+ // Poll events and wait for a click on a known area
+ if (!events._leftButton || ((selIndex = coordIndexOf()) == -1))
+ continue;
+
+ if (selIndex > 23) {
+ if (selIndex == 25)
+ _vm->_useItem = -1;
+ break;
+ } else if (selIndex < (int)_items.size() && _items[selIndex] != -1) {
+ _boxNum = selIndex;
+ _vm->copyBF2Vid();
+ combineItems();
+ _vm->copyBF2Vid();
+ outlineIcon(_boxNum);
+ _vm->_useItem = _items[_boxNum];
+ }
+ }
+}
+
+void InventoryManager::freeInvCells() {
+ delete _vm->_objectsTable[99];
+ _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;
+}
+
+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() {
+ _vm->_buffer1.w = _vm->_buffer1.pitch;
+ _savedBuffer1.copyTo(&_vm->_buffer1);
+ _savedScreen.copyTo(_vm->_screen);
+
+ _savedBuffer1.free();
+ _savedScreen.free();
+}
+
+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() {
+ 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 if left button is held down
+ while (!_vm->shouldQuit() && events._leftButton) {
+ // Poll for events
+ events.pollEventsAndWait();
+
+ // 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);
+
+ 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);
+ if (destBox >= 0 && destBox != _boxNum && destBox < (int)_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;
+ 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;
+ zoomIcon(itemB, -1, destBox, true);
+
+ // Exand up the new combined item from nothing to full size
+ zoomIcon(combinedItem, -1, destBox, false);
+
+ _boxNum = destBox;
+ events.showCursor();
+ return;
+ }
+ }
+
+ _iconDisplayFlag = true;
+ 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];
+
+ 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 && zoomScale != 256) {
+ _vm->_events->pollEventsAndWait();
+
+ _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;
+ }
+
+ 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) {
+ int count = _inv.size();
+ s.syncAsUint16LE(count);
+
+ if (!s.isSaving())
+ _inv.resize(count);
+
+ for (int i = 0; i < count; ++i)
+ s.syncAsUint16LE(_inv[i]._value);
+}
+
+} // End of namespace Access
diff --git a/engines/access/inventory.h b/engines/access/inventory.h
new file mode 100644
index 0000000000..6a9390eda9
--- /dev/null
+++ b/engines/access/inventory.h
@@ -0,0 +1,140 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public 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"
+#include "access/asurface.h"
+
+namespace Access {
+
+enum ItemState {
+ ITEM_NOT_FOUND = 0, ITEM_IN_INVENTORY = 1, ITEM_USED = 2
+};
+
+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;
+ 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;
+ Common::Array<Common::Rect> _invCoords;
+ ASurface _savedBuffer1;
+ ASurface _savedScreen;
+ SavedFields _fields;
+ bool _iconDisplayFlag;
+ Common::Array<int> _tempLPtr;
+ Common::StringArray _tempLOff;
+ int _boxNum;
+
+ void savedFields();
+
+ void restoreFields();
+
+ void initFields();
+
+ void getList();
+
+ void showAllItems();
+
+ void putInvIcon(int itemIndex, int itemId);
+
+ void chooseItem();
+
+ void freeInvCells();
+
+ int coordIndexOf();
+
+ void saveScreens();
+
+ void restoreScreens();
+
+ void outlineIcon(int itemIndex);
+
+ void combineItems();
+
+ void zoomIcon(int zoomItem, int backItem, int zoomBox, bool shrink);
+public:
+ Common::Array<InventoryEntry> _inv;
+ int _startInvItem;
+ int _startInvBox;
+ bool _invChangeFlag;
+ bool _invRefreshFlag;
+ bool _invModeFlag;
+ int _startAboutItem;
+ int _startTravelItem;
+public:
+ InventoryManager(AccessEngine *vm);
+
+ int &operator[](int idx);
+
+ int useItem();
+ void setUseItem(int itemId);
+
+ void refreshInventory();
+
+ int newDisplayInv();
+
+ /**
+ * Synchronize savegame data
+ */
+ void synchronize(Common::Serializer &s);
+};
+
+} // End of namespace Access
+
+#endif /* ACCESS_INVENTORY_H */
diff --git a/engines/access/martian/martian_game.cpp b/engines/access/martian/martian_game.cpp
new file mode 100644
index 0000000000..4e4a5135a6
--- /dev/null
+++ b/engines/access/martian/martian_game.cpp
@@ -0,0 +1,168 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public 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);
+
+ _files->_setPaletteFlag = false;
+ _files->loadScreen(0, 3);
+
+ _buffer2.blitFrom(*_screen);
+ _buffer1.blitFrom(*_screen);
+ _screen->forceFadeIn();
+ _sound->playSound(1);
+
+ 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.blitFrom(*_screen);
+ _buffer1.blitFrom(*_screen);
+ _sound->playSound(1);
+
+ const int COUNTDOWN[6] = { 2, 0x80, 1, 0x7d, 0, 0x87 };
+ for (_pCount = 0; _pCount < 3; ++_pCount) {
+ _buffer2.blitFrom(_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::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 0000000000..a83b67a288
--- /dev/null
+++ b/engines/access/martian/martian_game.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_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();
+
+ /**
+ * Setup variables for the game
+ */
+ void setupGame();
+
+protected:
+ /**
+ * Play the game
+ */
+ virtual void playGame();
+
+ virtual void dead(int deathId) {}
+public:
+ MartianEngine(OSystem *syst, const AccessGameDescription *gameDesc);
+
+ virtual ~MartianEngine();
+
+ void drawHelp();
+ virtual void establish(int esatabIndex, int sub) {};
+};
+
+} // 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 0000000000..d2b5dfd5d0
--- /dev/null
+++ b/engines/access/martian/martian_resources.cpp
@@ -0,0 +1,722 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public 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", "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[] = {
+ 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 *const 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 *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,
+ 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 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",
+ "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,
+ 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 *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,
+ CHAR_TABLE16, nullptr, CHAR_TABLE18, CHAR_TABLE19, CHAR_TABLE20,
+ CHAR_TABLE21, nullptr, CHAR_TABLE23, CHAR_TABLE24, CHAR_TABLE25,
+ 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
new file mode 100644
index 0000000000..a52967d42a
--- /dev/null
+++ b/engines/access/martian/martian_resources.h
@@ -0,0 +1,52 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public 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 *const CURSORS[4];
+
+extern const int TRAVEL_POS[][2];
+
+extern const char *const INVENTORY_NAMES[];
+
+extern const byte *const ROOM_TABLE[];
+extern const char *const ROOM_DESCR[];
+extern const int ROOM_NUMB;
+
+extern const byte *const CHAR_TABLE[];
+
+extern const int COMBO_TABLE[54][4];
+
+} // 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 0000000000..e9d1b9d8cf
--- /dev/null
+++ b/engines/access/martian/martian_room.cpp
@@ -0,0 +1,141 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public 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) {
+ //Resource *spriteData = _vm->_files->loadFile("MAYA.LZ");
+ //_vm->_inactive._spritesPtr = new SpriteResource(_vm, spriteData);
+ //delete spriteData;
+ _vm->_currentCharFlag = false;
+ }
+
+ _selectCommand = -1;
+ _vm->_events->setNormalCursor(CURSOR_CROSSHAIRS);
+ _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() {
+ Resource *iconData = _vm->_files->loadFile("ICONS.LZ");
+ 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));
+
+ _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 0000000000..85529ce8f0
--- /dev/null
+++ b/engines/access/martian/martian_room.h
@@ -0,0 +1,66 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#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 mainAreaClick();
+public:
+ MartianRoom(AccessEngine *vm);
+
+ virtual ~MartianRoom();
+
+ virtual void loadRoomData(const byte *roomData) { warning("TODO - loadRoomData"); }
+
+ virtual void init4Quads() { }
+
+ virtual void roomMenu();
+};
+
+} // 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 0000000000..0578872092
--- /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 0000000000..fc7495fc47
--- /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
new file mode 100644
index 0000000000..b6961aeca9
--- /dev/null
+++ b/engines/access/module.mk
@@ -0,0 +1,41 @@
+MODULE := engines/access
+
+MODULE_OBJS := \
+ animation.o \
+ asurface.o \
+ access.o \
+ bubble_box.o \
+ char.o \
+ data.o \
+ debugger.o \
+ decompress.o \
+ detection.o \
+ events.o \
+ files.o \
+ font.o \
+ inventory.o \
+ player.o \
+ resources.o \
+ room.o \
+ screen.o \
+ scripts.o \
+ sound.o \
+ video.o \
+ amazon/amazon_game.o \
+ amazon/amazon_logic.o \
+ amazon/amazon_player.o \
+ amazon/amazon_resources.o \
+ amazon/amazon_room.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)
+PLUGIN := 1
+endif
+
+# Include common rules
+include $(srcdir)/rules.mk
diff --git a/engines/access/player.cpp b/engines/access/player.cpp
new file mode 100644
index 0000000000..e47daf532c
--- /dev/null
+++ b/engines/access/player.cpp
@@ -0,0 +1,825 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public 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 "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);
+ Common::fill(&_walkOffUp[0], &_walkOffUp[PLAYER_DATA_COUNT], 0);
+ Common::fill(&_walkOffDown[0], &_walkOffDown[PLAYER_DATA_COUNT], 0);
+
+ _playerSprites = nullptr;
+ _playerSprites1 = nullptr;
+ _manPal1 = nullptr;
+ _frameNumber = 0;
+ _rawTempL = 0;
+ _rawXTemp = 0;
+ _rawYTempL = 0;
+ _rawYTemp = 0;
+ _playerXLow = 0;
+ _playerX = 0;
+ _playerYLow = 0;
+ _playerY = 0;
+ _frame = 0;
+ _playerOff = false;
+ _playerMove = false;
+ _leftDelta = _rightDelta = 0;
+ _upDelta = _downDelta = 0;
+ _scrollConst = 0;
+ _scrollFlag = false;
+ _scrollThreshold = 0;
+ _scrollAmount = 0;
+ _scrollEnd = 0;
+ _roomNumber = 0;
+ _collideFlag = false;
+ _move = NONE;
+ _playerDirection = NONE;
+ _xFlag = _yFlag = 0;
+ _inactiveYOff = 0;
+
+ _sideWalkMin = _sideWalkMax = 0;
+ _upWalkMin = _upWalkMax = 0;
+ _downWalkMin = _downWalkMax = 0;
+ _diagUpWalkMin = _diagUpWalkMax = 0;
+ _diagDownWalkMin = _diagDownWalkMax = 0;
+}
+
+Player::~Player() {
+ delete _playerSprites;
+ delete[] _manPal1;
+}
+
+void Player::load() {
+ _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);
+ } else {
+ Common::fill(_vm->_screen->_manPal, _vm->_screen->_manPal + 0x60, 0);
+ }
+}
+
+void Player::loadSprites(const Common::String &name) {
+ freeSprites();
+
+ Resource *data = _vm->_files->loadFile(name);
+ _playerSprites1 = new SpriteResource(_vm, data);
+ delete data;
+}
+
+void Player::freeSprites() {
+ delete _playerSprites;
+ _playerSprites1 = nullptr;
+ _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) *
+ _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;
+ }
+}
+
+void Player::walk() {
+ _collideFlag = false;
+ _playerDirection = NONE;
+
+ if (_playerOff)
+ return;
+ else if (_vm->_timers[0]._flag) {
+ plotCom3();
+ return;
+ }
+
+ ++_vm->_timers[0]._flag;
+ switch (_move) {
+ case UP:
+ _playerMove = false;
+ walkUp();
+ break;
+ case DOWN:
+ _playerMove = false;
+ walkDown();
+ break;
+ case LEFT:
+ _playerMove = false;
+ walkLeft();
+ break;
+ case RIGHT:
+ _playerMove = false;
+ walkRight();
+ break;
+ case UPLEFT:
+ _playerMove = false;
+ walkUpLeft();
+ break;
+ case DOWNLEFT:
+ _playerMove = false;
+ walkDownLeft();
+ break;
+ case UPRIGHT:
+ _playerMove = false;
+ walkUpRight();
+ break;
+ case DOWNRIGHT:
+ _playerMove = false;
+ walkDownRight();
+ break;
+ default:
+ checkMove();
+ break;
+ }
+}
+
+void Player::calcPlayer() {
+ Screen &scr = *_vm->_screen;
+ 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;
+}
+
+void Player::walkUp() {
+ if (_frame > _upWalkMax || _frame < _upWalkMin)
+ _frame = _upWalkMin;
+
+ _playerDirection = UP;
+ int walkOff = _walkOffUp[_frame - _upWalkMin];
+ 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()) {
+ plotCom2();
+ } else {
+ _rawPlayer.y = _rawYTemp;
+ _rawPlayerLow.y = _rawYTempL;
+
+ calcManScale();
+
+ // 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;
+
+ plotCom(0);
+ }
+}
+
+void Player::walkDown() {
+ if (_frame > _downWalkMax || _frame < _downWalkMin)
+ _frame = _downWalkMin;
+
+ _playerDirection = DOWN;
+ int walkOff = _walkOffDown[_frame - _downWalkMin];
+ 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()) {
+ plotCom2();
+ } else {
+ _rawPlayer.y = _rawYTemp;
+ _rawPlayerLow.y = _rawYTempL;
+
+ calcManScale();
+
+ // 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;
+
+ plotCom(0);
+ }
+}
+
+void Player::walkLeft() {
+ if (_frame > _sideWalkMax || _frame < _sideWalkMin)
+ _frame = _sideWalkMin;
+
+ _playerDirection = LEFT;
+
+ bool flag = _scrollEnd == 1;
+ if (!flag) {
+ calcPlayer();
+ flag = (_playerX - _vm->_screen->_scaleTable1[_scrollConst] -
+ _vm->_player->_scrollThreshold) > 0;
+ }
+ if (flag) {
+ int walkOffset = _walkOffLeft[_frame - _sideWalkMin];
+ 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];
+ }
+ _rawYTemp = _rawPlayer.y;
+
+ if (_vm->_room->codeWalls()) {
+ plotCom2();
+ } else {
+ _rawPlayer.x = _rawXTemp;
+ _rawPlayerLow.x = _rawTempL;
+ ++_frame;
+
+ // 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;
+
+ plotCom1();
+ }
+}
+
+void Player::walkRight() {
+ if (_frame > _sideWalkMax || _frame < _sideWalkMin)
+ _frame = _sideWalkMin;
+
+ _playerDirection = RIGHT;
+
+ bool flag = _scrollEnd == 2;
+ if (!flag) {
+ calcPlayer();
+ flag = (_vm->_screen->_clipWidth - _playerX - _vm->_screen->_scaleTable1[_scrollConst] -
+ _vm->_player->_scrollThreshold) > 0;
+ }
+ if (flag) {
+ 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];
+ }
+ _rawYTemp = _rawPlayer.y;
+
+ if (_vm->_room->codeWalls()) {
+ plotCom2();
+ } else {
+ _rawPlayer.x = _rawXTemp;
+ _rawPlayerLow.x = _rawTempL;
+ ++_frame;
+
+ // Useless check removed
+ if (_frame > _sideWalkMax)
+ _frame = _sideWalkMin;
+
+ plotCom(0);
+ }
+}
+
+void Player::walkUpLeft() {
+ if (_frame > _diagUpWalkMax || _frame < _diagUpWalkMin)
+ _frame = _diagUpWalkMin;
+
+ _playerDirection = UPLEFT;
+
+ int walkOffset, tempL;
+ bool flag = _scrollEnd == 1;
+ if (!flag) {
+ calcPlayer();
+ flag = (_playerX - _vm->_screen->_scaleTable1[_scrollConst] -
+ _vm->_player->_scrollThreshold) > 0;
+ }
+ if (flag) {
+ walkOffset = _walkOffUL[_frame - _diagUpWalkMin].x;
+ 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;
+ 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();
+ } else {
+ _rawPlayer.x = _rawXTemp;
+ _rawPlayer.y = _rawYTemp;
+ _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: walkUpLeft - si = 0?");
+
+ if (_frame > _diagUpWalkMax)
+ _frame = _diagUpWalkMin;
+
+ plotCom1();
+ }
+}
+
+void Player::walkDownLeft() {
+ if (_frame > _diagDownWalkMax || _frame < _diagDownWalkMin)
+ _frame = _diagDownWalkMin;
+
+ _playerDirection = DOWNLEFT;
+
+ int walkOffset, tempL;
+ bool flag = _scrollEnd == 1;
+ if (!flag) {
+ calcPlayer();
+ flag = (_playerX - _vm->_screen->_scaleTable1[_scrollConst] -
+ _vm->_player->_scrollThreshold) > 0;
+ }
+ if (flag) {
+ walkOffset = _walkOffDL[_frame - _sideWalkMin].x;
+ 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;
+ 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();
+ } else {
+ _rawPlayer.x = _rawXTemp;
+ _rawPlayer.y = _rawYTemp;
+ _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: walkDownLeft - si = 0?");
+
+ if (_frame > _diagDownWalkMax)
+ _frame = _diagDownWalkMin;
+
+ plotCom1();
+ }
+}
+
+void Player::walkUpRight() {
+ if (_frame > _diagUpWalkMax || _frame < _diagUpWalkMin)
+ _frame = _diagUpWalkMin;
+
+ _playerDirection = UPRIGHT;
+
+ int walkOffset, tempL;
+ bool flag = _scrollEnd == 1;
+ if (!flag) {
+ calcPlayer();
+ flag = (_vm->_screen->_clipWidth - _playerX - _vm->_screen->_scaleTable1[_scrollConst] -
+ _vm->_player->_scrollThreshold) > 0;
+ }
+ if (flag) {
+ walkOffset = _walkOffUR[_frame - _diagUpWalkMin].x;
+ 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];
+ }
+
+ walkOffset = _walkOffUL[_frame - _diagUpWalkMin].y;
+ 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();
+ } else {
+ _rawPlayer.x = _rawXTemp;
+ _rawPlayer.y = _rawYTemp;
+ _rawPlayerLow.x = _rawTempL;
+ _rawPlayerLow.y = _rawYTempL;
+
+ ++_frame;
+ calcManScale();
+
+ // 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;
+
+ plotCom(0);
+ }
+}
+
+void Player::walkDownRight() {
+ if (_frame > _diagDownWalkMax || _frame < _diagDownWalkMin)
+ _frame = _diagDownWalkMin;
+
+ _playerDirection = DOWNRIGHT;
+
+ int walkOffset, tempL;
+ bool flag = _scrollEnd == 2;
+ if (!flag) {
+ calcPlayer();
+ flag = (_vm->_screen->_clipWidth - _playerX - _vm->_screen->_scaleTable1[_scrollConst] -
+ _vm->_player->_scrollThreshold) > 0;
+ }
+ if (flag) {
+ walkOffset = _walkOffUR[_frame - _diagDownWalkMin].x;
+ 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];
+ }
+
+ walkOffset = _walkOffDR[_frame - _diagDownWalkMin].y;
+ 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();
+ } else {
+ _rawPlayer.x = _rawXTemp;
+ _rawPlayer.y = _rawYTemp;
+ _rawPlayerLow.x = _rawTempL;
+ _rawPlayerLow.y = _rawYTempL;
+
+ 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;
+
+ plotCom(0);
+ }
+}
+
+void Player::checkMove() {
+ if (_playerMove) {
+ 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) {
+ _playerMove = false;
+ _xFlag = _yFlag = 0;
+ } else {
+ ++_xFlag;
+ }
+ } else {
+ if (yd >= 0)
+ walkUp();
+ else
+ walkDown();
+
+ if (_collideFlag) {
+ _playerMove = false;
+ _xFlag = _yFlag = 0;
+ }
+ }
+ } else if (_xFlag == 1) {
+ int xd = (_playerOffset.x / 2) + _rawPlayer.x - _moveTo.x;
+ if ((xd >= 0 && xd <= -_leftDelta) || (xd < 0 && -xd <= -_leftDelta)) {
+ ++_xFlag;
+
+ if (_yFlag) {
+ _playerMove = false;
+ _xFlag = _yFlag = 0;
+ }
+ } else {
+ if (xd >= 0)
+ walkLeft();
+ else
+ walkRight();
+
+ if (_collideFlag) {
+ _playerMove = false;
+ _xFlag = _yFlag = 0;
+ }
+ }
+ } else if (!_yFlag) {
+ ++_yFlag;
+ } else {
+ _playerMove = false;
+ _xFlag = _yFlag = 0;
+ }
+ }
+
+ plotCom3();
+}
+
+void Player::plotCom(int flags) {
+ _flags &= ~2;
+ _flags &= ~8;
+ _flags |= flags;
+
+ plotCom3();
+}
+
+void Player::plotCom1() {
+ plotCom(2);
+}
+
+void Player::plotCom2() {
+ // WORKAROUND: Amazon has at least one cutscene with the player not properly turned off
+ if (!_playerOff && _spritesPtr != nullptr)
+ _vm->_images.addToList(*this);
+}
+
+void Player::plotCom3() {
+ // Update the base ImageEntry fields for the player
+ _position.x = _rawPlayer.x;
+ _position.y = _rawPlayer.y - _playerOffset.y;
+ _offsetY = _playerOffset.y;
+ _spritesPtr = _playerSprites;
+ _frameNumber = _frame;
+
+ plotCom2();
+}
+
+void Player::checkScrollUp() {
+ if ((_playerDirection == DOWNRIGHT || _playerDirection == DOWNLEFT ||
+ _playerDirection == DOWN) && (_vm->_screen->_clipHeight -
+ _playerY - _scrollThreshold) <= 0) {
+ // Scroll up
+ if (scrollUp()) {
+ _scrollEnd = 4;
+ _vm->_scrollY &= TILE_HEIGHT;
+ _scrollFlag = true;
+ }
+ }
+}
+
+void Player::checkScroll() {
+ _scrollFlag = false;
+ if (_playerDirection == NONE)
+ return;
+
+ if ((_playerDirection == UPLEFT || _playerDirection == DOWNLEFT ||
+ _playerDirection == LEFT) && _playerX <= _scrollThreshold) {
+ // Scroll right
+ if (!scrollRight()) {
+ if (_playerDirection == DOWNLEFT)
+ checkScrollUp();
+
+ return;
+ }
+ } else if ((_playerDirection == UPRIGHT || _playerDirection == DOWNRIGHT ||
+ _playerDirection == RIGHT) && (_vm->_screen->_clipWidth -
+ _playerX - _scrollThreshold) <= 0) {
+ // Scroll left
+ if (!scrollLeft()) {
+ if (_playerDirection == DOWNRIGHT)
+ checkScrollUp();
+
+ return;
+ }
+ }
+
+ if ((_playerDirection == UPRIGHT || _playerDirection == UPLEFT ||
+ _playerDirection == UP) && _playerY <= _scrollThreshold) {
+ scrollDown();
+ } else {
+ checkScrollUp();
+ }
+}
+
+bool Player::scrollUp() {
+ _scrollAmount = -(_vm->_screen->_clipHeight - _playerY - _scrollThreshold);
+ if ((_vm->_scrollRow + _vm->_screen->_vWindowHeight) >=
+ _vm->_room->_playFieldHeight)
+ return true;
+
+ _scrollFlag = true;
+ _vm->_scrollY = _vm->_scrollY + _scrollAmount;
+
+ while (_vm->_scrollY >= TILE_HEIGHT && !_vm->shouldQuit()) {
+ _vm->_scrollY -= TILE_HEIGHT;
+ ++_vm->_scrollRow;
+ _vm->_buffer1.moveBufferUp();
+
+ _vm->_room->buildRow(_vm->_scrollRow + _vm->_screen->_vWindowHeight,
+ _vm->_screen->_vWindowLinesTall);
+
+ if ((_vm->_scrollRow + _vm->_screen->_vWindowHeight) >=
+ _vm->_room->_playFieldHeight)
+ return true;
+
+ if (_vm->_scrollY <= TILE_HEIGHT)
+ return false;
+ }
+
+ return false;
+}
+
+bool Player::scrollDown() {
+ _scrollAmount = -(_playerY - _scrollThreshold);
+ _scrollFlag = true;
+ _vm->_scrollY -= _scrollAmount;
+ if (_vm->_scrollY >= 0)
+ return true;
+
+ do {
+ _vm->_scrollY += TILE_HEIGHT;
+ if (--_vm->_scrollRow < 0)
+ break;
+
+ _vm->_buffer1.moveBufferDown();
+ _vm->_room->buildRow(_vm->_scrollRow, 0);
+
+ if (_vm->_scrollY >= 0)
+ return false;
+ } while (!_vm->shouldQuit());
+
+ _scrollEnd = 3;
+ _vm->_scrollY = 0;
+ _vm->_scrollRow = 0;
+ return true;
+}
+
+bool Player::scrollLeft() {
+ Screen &screen = *_vm->_screen;
+ _scrollAmount = -(_vm->_screen->_clipWidth - _playerX - _scrollThreshold);
+ if ((_vm->_scrollCol + screen._vWindowWidth) == _vm->_room->_playFieldWidth) {
+ _scrollEnd = 2;
+ _vm->_scrollX = 0;
+ _scrollFlag = true;
+ return true;
+ } else {
+ _scrollFlag = true;
+ _vm->_scrollX = _vm->_scrollX + _scrollAmount;
+
+ do {
+ if (_vm->_scrollX < TILE_WIDTH)
+ return true;
+
+ _vm->_scrollX -= TILE_WIDTH;
+ ++_vm->_scrollCol;
+ _vm->_buffer1.moveBufferLeft();
+ _vm->_room->buildColumn(_vm->_scrollCol + screen._vWindowWidth,
+ screen._vWindowBytesWide);
+ } while (!_vm->shouldQuit() && (_vm->_scrollX >= TILE_WIDTH));
+
+ return (_playerDirection == UPRIGHT);
+ }
+}
+
+bool Player::scrollRight() {
+ _scrollAmount = -(_playerX - _scrollThreshold);
+ _scrollFlag = true;
+ _vm->_scrollX -= _scrollAmount;
+
+ if (_vm->_scrollX < 0) {
+ do {
+ _vm->_scrollX += TILE_WIDTH;
+ if (--_vm->_scrollCol < 0) {
+ _scrollEnd = true;
+ _vm->_scrollX = 0;
+ _vm->_scrollCol = 0;
+ return true;
+ }
+
+ _vm->_buffer1.moveBufferRight();
+ _vm->_room->buildColumn(_vm->_scrollCol, 0);
+ } while (!_vm->shouldQuit() && (_vm->_scrollX < 0));
+
+ return false;
+ }
+
+ 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
new file mode 100644
index 0000000000..329cc15ed2
--- /dev/null
+++ b/engines/access/player.h
@@ -0,0 +1,152 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public 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"
+#include "common/serializer.h"
+#include "access/asurface.h"
+#include "access/data.h"
+
+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 ImageEntry, public Manager {
+protected:
+ int _leftDelta, _rightDelta;
+ int _upDelta, _downDelta;
+ int _scrollConst;
+ int _sideWalkMin, _sideWalkMax;
+ int _upWalkMin, _upWalkMax;
+ int _downWalkMin, _downWalkMax;
+ int _diagUpWalkMin, _diagUpWalkMax;
+ int _diagDownWalkMin, _diagDownWalkMax;
+ SpriteResource *_playerSprites1;
+ byte *_manPal1;
+ int _scrollEnd;
+ int _inactiveYOff;
+
+ 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();
+ void checkScrollUp();
+ bool scrollUp();
+ bool scrollDown();
+ bool scrollLeft();
+ bool scrollRight();
+public:
+ Direction _playerDirection;
+ SpriteResource *_playerSprites;
+ // Fields in original Player structure
+ 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];
+ byte _rawTempL;
+ int _rawXTemp;
+ byte _rawYTempL;
+ int _rawYTemp;
+ Common::Point _playerOffset;
+ int _playerXLow;
+ int _playerX;
+ int _playerYLow;
+ int _playerY;
+ int _frame;
+ int _xFlag, _yFlag;
+ Direction _move;
+
+ // Additional public globals we've added to new Player class
+ bool _playerOff;
+ bool _playerMove;
+ Common::Point _moveTo;
+ bool _collideFlag;
+ bool _scrollFlag;
+ int _scrollThreshold;
+ int _scrollAmount;
+
+ // Additional globals that need to be saved
+ int _roomNumber;
+ Common::Point _rawPlayerLow;
+ Common::Point _rawPlayer;
+public:
+ Player(AccessEngine *vm);
+ virtual ~Player();
+ static Player *init(AccessEngine *vm);
+
+ virtual void load();
+
+ void loadSprites(const Common::String &name);
+
+ void freeSprites();
+
+ void removeSprite1();
+
+ void calcManScale();
+
+ void walk();
+
+ void calcPlayer();
+
+ void checkScroll();
+
+ void checkMove();
+
+ /**
+ * Synchronize savegame data
+ */
+ void synchronize(Common::Serializer &s);
+};
+
+} // End of namespace Access
+
+#endif /* ACCESS_PLAYER_H */
diff --git a/engines/access/resources.cpp b/engines/access/resources.cpp
new file mode 100644
index 0000000000..4157cdfc0d
--- /dev/null
+++ b/engines/access/resources.cpp
@@ -0,0 +1,109 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public 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/access.h"
+
+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
+};
+
+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 RMOUSE[10][2] = {
+ { 0, 35 }, { 0, 0 }, { 36, 70 }, { 71, 106 }, { 107, 141 },
+ { 142, 177 }, { 178, 212 }, { 213, 248 }, { 249, 283 }, { 284, 318 }
+};
+
+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
+};
+
+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
new file mode 100644
index 0000000000..8d59b1b1f1
--- /dev/null
+++ b/engines/access/resources.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_RESOURCES_H
+#define ACCESS_RESOURCES_H
+
+#include "common/scummsys.h"
+
+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 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
new file mode 100644
index 0000000000..607259ec6f
--- /dev/null
+++ b/engines/access/room.cpp
@@ -0,0 +1,833 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public 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/memstream.h"
+#include "access/access.h"
+#include "access/resources.h"
+#include "access/room.h"
+
+namespace Access {
+
+Room::Room(AccessEngine *vm) : Manager(vm) {
+ _function = FN_NONE;
+ _roomFlag = 0;
+ _playField = nullptr;
+ _playFieldWidth = _playFieldHeight = 0;
+ _matrixSize = 0;
+ _tile = nullptr;
+ _selectCommand = 0;
+ _conFlag = false;
+ _selectCommand = -1;
+}
+
+Room::~Room() {
+ delete[] _playField;
+ delete[] _tile;
+}
+
+void Room::freePlayField() {
+ delete[] _playField;
+ _playField = nullptr;
+}
+
+void Room::freeTileData() {
+ delete[] _tile;
+ _tile = nullptr;
+}
+
+void Room::doRoom() {
+ bool reloadFlag = false;
+
+ while (!_vm->shouldQuit()) {
+ if (!reloadFlag) {
+ _vm->_images.clear();
+ _vm->_newRects.clear();
+ _vm->_oldRects.clear();
+ _vm->_numAnimTimers = 0;
+
+ reloadRoom();
+ }
+
+ reloadFlag = false;
+ _vm->_startup = 8;
+ _function = FN_NONE;
+
+ while (!_vm->shouldQuit()) {
+ _vm->_images.clear();
+ if (_vm->_startup != -1 && --_vm->_startup == 0) {
+ _vm->_events->showCursor();
+ _vm->_screen->fadeIn();
+ }
+
+ // Poll for events
+ _vm->_canSaveLoad = true;
+ _vm->_events->pollEventsAndWait();
+ _vm->_canSaveLoad = false;
+
+ _vm->_player->walk();
+ _vm->_midi->midiRepeat();
+ _vm->_player->checkScroll();
+
+ doCommands();
+ if (_vm->shouldQuitOrRestart())
+ return;
+
+ // DOROOMFLASHBACK jump point
+ if (_function == FN_CLEAR1) {
+ clearRoom();
+ break;
+ } else if (_function == FN_CLEAR2) {
+ clearRoom();
+ return;
+ } else if (_function == FN_RELOAD) {
+ reloadRoom1();
+ reloadFlag = true;
+ break;
+ } else if (_function == FN_BREAK) {
+ break;
+ }
+
+ if (_vm->_player->_scrollFlag) {
+ _vm->copyBF1BF2();
+ _vm->_newRects.clear();
+ _function = FN_NONE;
+ roomLoop();
+
+ if (_function == FN_CLEAR1) {
+ clearRoom();
+ break;
+ } else {
+ _vm->plotList();
+ _vm->copyRects();
+ _vm->copyBF2Vid();
+ }
+ } else {
+ _vm->copyBF1BF2();
+ _vm->_newRects.clear();
+ _function = FN_NONE;
+
+ roomLoop();
+ if (_vm->shouldQuitOrRestart())
+ return;
+
+ if (_function == FN_CLEAR1) {
+ clearRoom();
+ break;
+ } else {
+ _vm->plotList();
+
+ if (_vm->_events->_mousePos.y < 177)
+ _vm->_events->setCursor(_vm->_events->_normalMouse);
+ else
+ _vm->_events->setCursor(CURSOR_ARROW);
+
+ _vm->copyBlocks();
+ }
+ }
+ }
+ }
+}
+
+void Room::clearRoom() {
+ if (_vm->_midi->_music) {
+ _vm->_midi->stopSong();
+ _vm->_midi->freeMusic();
+ }
+
+ _vm->_sound->freeSounds();
+ _vm->_numAnimTimers = 0;
+
+ _vm->_animation->freeAnimationData();
+ _vm->_scripts->freeScriptData();
+ _vm->freeCells();
+ freePlayField();
+ freeTileData();
+ _vm->_player->freeSprites();
+}
+
+void Room::loadRoomData(const byte *roomData) {
+ RoomInfo roomInfo(roomData, _vm->getGameID(), _vm->isCD(), _vm->isDemo());
+
+ _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, roomInfo._estIndex);
+ }
+ }
+
+ _vm->_midi->freeMusic();
+ if (roomInfo._musicFile._fileNum != -1) {
+ _vm->_midi->loadMusic(roomInfo._musicFile);
+ _vm->_midi->midiPlay();
+ _vm->_midi->setLoop(true);
+ }
+
+ _vm->_scaleH1 = roomInfo._scaleH1;
+ _vm->_scaleH2 = roomInfo._scaleH2;
+ _vm->_scaleN1 = roomInfo._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 = _playFieldHeight << 4;
+ }
+
+ // Load cells
+ _vm->loadCells(roomInfo._cells);
+
+ // Load script data
+ _vm->_scripts->freeScriptData();
+ if (roomInfo._scriptFile._fileNum != -1) {
+ Resource *newScript = _vm->_files->loadFile(roomInfo._scriptFile);
+ _vm->_scripts->setScript(newScript);
+ }
+
+ // Load animation data
+ _vm->_animation->freeAnimationData();
+ if (roomInfo._animFile._fileNum != -1) {
+ Resource *anim = _vm->_files->loadFile(roomInfo._animFile);
+ _vm->_animation->loadAnimations(anim);
+ delete anim;
+ }
+
+ _vm->_scale = _vm->_scaleI = roomInfo._scaleI;
+ _vm->_screen->setScaleTable(_vm->_scale);
+ _vm->_player->_scrollThreshold = roomInfo._scrollThreshold;
+
+ // 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();
+ 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);
+}
+
+void Room::roomLoop() {
+ _vm->_scripts->_sequence = ROOM_SCRIPT;
+ _vm->_scripts->searchForSequence();
+ _vm->_scripts->executeScript();
+}
+
+void Room::setupRoom() {
+ Screen &screen = *_vm->_screen;
+ screen.setScaleTable(_vm->_scale);
+ screen.setBufferScan();
+
+ if (_roomFlag != 2)
+ screen.setIconPalette();
+
+ if (screen._vWindowWidth == _playFieldWidth) {
+ _vm->_scrollX = 0;
+ _vm->_scrollCol = 0;
+ } else {
+ int xv = _vm->_player->_rawPlayer.x / TILE_WIDTH;
+ _vm->_scrollX = _vm->_player->_rawPlayer.x % TILE_WIDTH;
+ _vm->_scrollCol = MAX(xv - (screen._vWindowWidth / 2), 0);
+
+ int sx = _vm->_scrollCol + screen._vWindowWidth - _playFieldWidth;
+ if (sx >= 0) {
+ _vm->_scrollCol -= sx + 1;
+ }
+ }
+
+ if (screen._vWindowHeight == _playFieldHeight) {
+ _vm->_scrollY = 0;
+ _vm->_scrollRow = 0;
+ } else {
+ _vm->_scrollY = _vm->_player->_rawPlayer.y -
+ (_vm->_player->_rawPlayer.y / 16) * 16;
+ int yc = MAX((_vm->_player->_rawPlayer.y >> 4) -
+ (screen._vWindowHeight / 2), 0);
+ _vm->_scrollRow = yc;
+
+ yc = yc + screen._vWindowHeight - _playFieldHeight;
+ if (yc >= 0) {
+ _vm->_scrollRow = _playFieldHeight - screen._vWindowHeight;
+ _vm->_scrollY = 0;
+ }
+ }
+}
+
+void Room::setWallCodes() {
+ _jetFrame.clear();
+ _jetFrame.resize(_plotter._walls.size());
+
+ _vm->_player->_rawXTemp = _vm->_player->_rawPlayer.x;
+ _vm->_player->_rawYTemp = _vm->_player->_rawPlayer.y;
+}
+
+void Room::buildScreen() {
+ int scrollCol = _vm->_scrollCol;
+ 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 < w; offset += TILE_WIDTH, ++idx) {
+ buildColumn(_vm->_scrollCol, offset);
+ ++_vm->_scrollCol;
+ }
+
+ _vm->_scrollCol = scrollCol;
+ _vm->copyBF1BF2();
+}
+
+void Room::buildColumn(int playX, int screenX) {
+ if (playX < 0 || playX >= _playFieldWidth)
+ return;
+
+ const byte *pSrc = _playField + _vm->_scrollRow *
+ _playFieldWidth + playX;
+
+ // 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);
+
+ for (int tileY = 0; tileY < TILE_HEIGHT; ++tileY) {
+ Common::copy(pTile, pTile + TILE_WIDTH, pDest);
+ pTile += TILE_WIDTH;
+ pDest += _vm->_buffer1.pitch;
+ }
+
+ pSrc += _playFieldWidth;
+ }
+}
+
+void Room::buildRow(int playY, int screenY) {
+ if (playY < 0 || playY >= _playFieldHeight)
+ return;
+ assert(screenY <= (_vm->_screen->h - TILE_HEIGHT));
+
+ 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);
+
+ for (int x = 0; x < w; ++x) {
+ byte *pTile = _tile + (*pSrc << 8);
+ 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);
+ pTile += TILE_WIDTH;
+ pDest += _vm->_buffer1.pitch;
+ }
+
+ ++pSrc;
+ }
+}
+
+void Room::loadPlayField(int fileNum, int subfile) {
+ 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(playData->_stream);
+
+ // Copy off the tile data
+ int tileSize = (int)header[2] << 8;
+ _tile = new byte[tileSize];
+ playData->_stream->read(_tile, tileSize);
+
+ // Copy off the playfield data
+ _matrixSize = header[0] * header[1];
+ _playField = new byte[_matrixSize];
+ playData->_stream->read(_playField, _matrixSize);
+
+ // Load the plotter data
+ int numWalls = READ_LE_UINT16(&header[6]);
+ int numBlocks = header[8];
+ _plotter.load(playData->_stream, numWalls, numBlocks);
+
+ _playFieldWidth = header[0];
+ _playFieldHeight = header[1];
+ screen._vWindowWidth = header[3];
+ screen._vWindowBytesWide = screen._vWindowWidth << 4;
+ screen._bufferBytesWide = screen._vWindowBytesWide + 16;
+ screen._vWindowHeight = header[4];
+ screen._vWindowLinesTall = screen._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();
+}
+
+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(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
+ 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.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);
+ }
+}
+
+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;
+
+ if (commandId == 9) {
+ _vm->_events->debounceLeft();
+ _vm->_canSaveLoad = true;
+ _vm->openMainMenuDialog();
+ _vm->_canSaveLoad = false;
+ } else if (commandId == _selectCommand) {
+ _vm->_events->debounceLeft();
+ commandOff();
+ } else {
+ _vm->_events->debounceLeft();
+ executeCommand(commandId);
+ }
+}
+
+void Room::executeCommand(int commandId) {
+ EventsManager &events = *_vm->_events;
+ _selectCommand = commandId;
+
+ switch (commandId) {
+ case 0:
+ events.forceSetCursor(CURSOR_LOOK);
+ break;
+ case 2:
+ events.forceSetCursor(CURSOR_USE);
+ break;
+ case 3:
+ events.forceSetCursor(CURSOR_TAKE);
+ break;
+ case 4:
+ events.setCursor(CURSOR_ARROW);
+ if (_vm->_inventory->newDisplayInv() == 2) {
+ commandOff();
+ return;
+ }
+ break;
+ case 5:
+ events.forceSetCursor(CURSOR_CLIMB);
+ break;
+ case 6:
+ events.forceSetCursor(CURSOR_TALK);
+ break;
+ case 7:
+ walkCursor();
+ return;
+ case 8:
+ events.forceSetCursor(CURSOR_HELP);
+ break;
+ default:
+ break;
+ }
+
+ // Draw the default toolbar menu at the bottom of the screen
+ roomMenu();
+ _vm->_screen->saveScreen();
+ _vm->_screen->setDisplayScan();
+
+ // Get the toolbar icons resource
+ 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,
+ Common::Point(RMOUSE[_selectCommand][0], 176));
+
+ _vm->_screen->restoreScreen();
+ _vm->_boxSelect = true;
+}
+
+void Room::walkCursor() {
+ EventsManager &events = *_vm->_events;
+
+ events.forceSetCursor(CURSOR_CROSSHAIRS);
+ _vm->_scripts->_sequence = 5000;
+ _vm->_scripts->searchForSequence();
+ roomMenu();
+ _selectCommand = -1;
+
+ _conFlag = true;
+ while (_conFlag && !_vm->shouldQuitOrRestart()) {
+ _conFlag = false;
+ _vm->_scripts->executeScript();
+ }
+
+ _vm->_boxSelect = true;
+}
+
+void Room::commandOff() {
+ _selectCommand = -1;
+ _vm->_events->forceSetCursor(CURSOR_CROSSHAIRS);
+ 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() {
+ Common::Point pt = _vm->_events->calcRawMouse();
+
+ for (uint start = 0; start < _plotter._blocks.size(); ++start) {
+ if (_plotter._blocks[start].contains(pt)) {
+ _plotter._blockIn = start;
+ if (!(validateBox(start) & 0x80)) {
+ _vm->_events->debounceLeft();
+ _vm->_boxSelect = start;
+
+ _conFlag = true;
+ while (_conFlag && !_vm->shouldQuitOrRestart()) {
+ _conFlag = false;
+ _vm->_scripts->executeScript();
+ }
+
+ _vm->_boxSelect = true;
+ return;
+ }
+ }
+ }
+}
+
+int Room::validateBox(int boxId) {
+ _vm->_scripts->_sequence = boxId;
+ _vm->_scripts->searchForSequence();
+ 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 || rem < 0)
+ ++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 || rem < 0)
+ ++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._rawXTemp + 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 || !v2 || (v1 == v2))
+ return false;
+
+ 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, int gameType, bool isCD, bool isDemo) {
+ Common::MemoryReadStream stream(data, 999);
+
+ _roomFlag = stream.readByte();
+
+ if (gameType == GType_Amazon) {
+ if (isCD)
+ _estIndex = stream.readSint16LE();
+ else {
+ _estIndex = -1;
+ if (!isDemo)
+ stream.readSint16LE();
+ }
+ } else
+ _estIndex = -1;
+
+ _musicFile.load(stream);
+ _scaleH1 = stream.readByte();
+ _scaleH2 = stream.readByte();
+ _scaleN1 = stream.readByte();
+ _playFieldFile.load(stream);
+
+ for (byte cell = stream.readByte(); cell != 0xff; cell = stream.readByte()) {
+ CellIdent ci;
+ ci._cell = cell;
+ ci.load(stream);
+
+ _cells.push_back(ci);
+ }
+
+ _scriptFile.load(stream);
+ _animFile.load(stream);
+ _scaleI = stream.readByte();
+ _scrollThreshold = stream.readByte();
+ _paletteFile.load(stream);
+ if (_paletteFile._fileNum == -1) {
+ _startColor = _numColors = 0;
+ } else {
+ _startColor = stream.readUint16LE();
+ _numColors = stream.readUint16LE();
+ }
+
+ for (int16 v = stream.readSint16LE(); v != -1; v = stream.readSint16LE()) {
+ ExtraCell ec;
+ ec._vid._fileNum = v;
+ ec._vid._subfile = stream.readSint16LE();
+
+ _extraCells.push_back(ec);
+ }
+
+ for (int16 fileNum = stream.readSint16LE(); fileNum != -1; fileNum = stream.readSint16LE()) {
+ SoundIdent fi;
+ fi._fileNum = fileNum;
+ fi._subfile = stream.readUint16LE();
+ fi._priority = stream.readUint16LE();
+
+ _sounds.push_back(fi);
+ }
+}
+
+} // End of namespace Access
diff --git a/engines/access/room.h b/engines/access/room.h
new file mode 100644
index 0000000000..eec273e3f4
--- /dev/null
+++ b/engines/access/room.h
@@ -0,0 +1,201 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public 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"
+#include "common/array.h"
+#include "common/rect.h"
+#include "access/data.h"
+
+#define TILE_WIDTH 16
+#define TILE_HEIGHT 16
+
+namespace Access {
+
+class Plotter {
+public:
+ Common::Array<Common::Rect> _walls;
+ Common::Array<Common::Rect> _blocks;
+ int _blockIn;
+ int _delta;
+public:
+ Plotter();
+
+ void load(Common::SeekableReadStream *stream, int wallCount, int blockCount);
+};
+
+class JetFrame {
+public:
+ int _wallCode;
+ int _wallCodeOld;
+ int _wallCode1;
+ int _wallCode1Old;
+
+ JetFrame() {
+ _wallCode = _wallCodeOld = 0;
+ _wallCode1 = _wallCode1Old = 0;
+ }
+};
+
+enum Function { FN_NONE = 0, FN_CLEAR1 = 1, FN_CLEAR2 = 2, FN_RELOAD = 3, FN_BREAK = 4 };
+
+class Room : public Manager {
+private:
+ void roomLoop();
+
+ void loadPlayField(int fileNum, int subfile);
+
+ void commandOff();
+
+ void swapOrg();
+ 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);
+
+ /**
+ * Free the playfield data
+ */
+ void freePlayField();
+
+ /**
+ * Free tile data
+ */
+ void freeTileData();
+
+ 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
+ */
+ void executeCommand(int commandId);
+
+ virtual void reloadRoom() = 0;
+
+ virtual void reloadRoom1() = 0;
+
+ virtual void setupRoom();
+
+ virtual void doCommands();
+
+ virtual void mainAreaClick() = 0;
+
+ virtual void walkCursor();
+public:
+ Plotter _plotter;
+ Common::Array<JetFrame> _jetFrame;
+ Function _function;
+ int _roomFlag;
+ byte *_playField;
+ int _matrixSize;
+ int _playFieldWidth;
+ int _playFieldHeight;
+ byte *_tile;
+ int _selectCommand;
+ bool _conFlag;
+public:
+ Room(AccessEngine *vm);
+
+ virtual ~Room();
+
+ void doRoom();
+
+ virtual void loadRoom(int roomNumber) = 0;
+
+ virtual void roomMenu() = 0;
+
+ /**
+ * Clear all the data used by the room
+ */
+ virtual 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);
+
+ virtual void init4Quads() = 0;
+
+ void setWallCodes();
+
+ bool codeWalls();
+
+ /**
+ * Switch to a given command mode
+ */
+ void handleCommand(int commandId);
+};
+
+class RoomInfo {
+public:
+ struct SoundIdent : FileIdent {
+ int _priority;
+ };
+public:
+ int _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<ExtraCell> _extraCells;
+ Common::Array<SoundIdent> _sounds;
+public:
+ RoomInfo(const byte *data, int gameType, bool isCD, bool isDemo);
+};
+
+} // End of namespace Access
+
+#endif /* ACCESS_ROOM_H */
diff --git a/engines/access/screen.cpp b/engines/access/screen.cpp
new file mode 100644
index 0000000000..970a8f3079
--- /dev/null
+++ b/engines/access/screen.cpp
@@ -0,0 +1,369 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public 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/endian.h"
+#include "common/rect.h"
+#include "common/textconsole.h"
+#include "common/system.h"
+#include "graphics/palette.h"
+#include "access/access.h"
+#include "access/screen.h"
+#include "access/resources.h"
+
+namespace Access {
+
+#define VGA_COLOR_TRANS(x) ((x) * 255 / 63)
+
+Screen::Screen(AccessEngine *vm) : _vm(vm) {
+ 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);
+ Common::fill(&_scaleTable2[0], &_scaleTable2[256], 0);
+ _savedPaletteCount = 0;
+ if (_vm->isCD())
+ _vesaMode = 0;
+ else
+ _vesaMode = 1;
+
+ _vesaCurrentWin = 0;
+ _currentPanel = 0;
+ _hideFlag = true;
+ _startColor = _numColors = 0;
+ _windowXAdd = _windowYAdd = 0;
+ _screenYOff = 0;
+ _screenChangeFlag = false;
+
+ _bufferBytesWide = _vWindowBytesWide = this->w;
+ _vWindowLinesTall = this->h;
+ _vWindowWidth = _vWindowHeight = 0;
+ _clipWidth = _vWindowBytesWide - 1;
+ _clipHeight = _vWindowLinesTall - 1;
+ _startCycle = 0;
+ _cycleStart = 0;
+ _endCycle = 0;
+}
+
+void Screen::clearScreen() {
+ clearBuffer();
+ if (_vesaMode)
+ _vm->_clearSummaryFlag = true;
+
+ addDirtyRect(Common::Rect(0, 0, this->w, this->h));
+}
+
+void Screen::setDisplayScan() {
+ _clipWidth = this->w - 1;
+ _clipHeight = this->h - 1;
+ _windowXAdd = _windowYAdd = 0;
+ _vm->_scrollX = _vm->_scrollY = 0;
+ _vm->_scrollCol = _vm->_scrollRow = 0;
+ _bufferStart.x = _bufferStart.y = 0;
+ _screenYOff = 0;
+}
+
+void Screen::setPanel(int num) {
+ assert(num < 4);
+ _currentPanel = num;
+ _msVirtualOffset = _virtualOffsetsTable[num];
+}
+
+void Screen::updateScreen() {
+ // 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();
+}
+
+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::loadPalette(int fileNum, int subfile) {
+ Resource *res = _vm->_files->loadFile(fileNum, subfile);
+ byte *palette = res->data();
+ Common::copy(palette, palette + (_numColors * 3), &_rawPalette[_startColor * 3]);
+ delete res;
+}
+
+void Screen::setPalette() {
+ g_system->getPaletteManager()->setPalette(&_rawPalette[0], 0, PALETTE_COUNT);
+}
+
+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() {
+ g_system->getPaletteManager()->setPalette(&_tempPalette[0], 0, PALETTE_COUNT);
+ 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::getPalette(byte *pal) {
+ g_system->getPaletteManager()->grabPalette(pal, 0, 256);
+}
+
+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_SIZE; ++count, ++srcP) {
+ int v = *srcP;
+ if (v) {
+ repeatFlag = true;
+ *srcP = MAX(*srcP - FADE_AMOUNT, 0);
+ }
+ }
+
+ updatePalette();
+ _vm->_events->pollEventsAndWait();
+ } while (repeatFlag && !_vm->shouldQuit());
+}
+
+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();
+ _vm->_events->pollEventsAndWait();
+ } 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);
+}
+
+void Screen::setBufferScan() {
+ _clipWidth = _vWindowBytesWide - 1;
+ _windowXAdd = (320 - _clipWidth) >> 1;
+ _clipHeight = _vWindowLinesTall - 1;
+ _windowYAdd = (176 - _clipHeight) >> 1;
+}
+
+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;
+ }
+}
+
+void Screen::saveScreen() {
+ _screenSave._clipWidth = _clipWidth;
+ _screenSave._clipHeight = _clipHeight;
+ _screenSave._windowXAdd = _windowXAdd;
+ _screenSave._windowYAdd = _windowYAdd;
+ _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;
+}
+
+void Screen::restoreScreen() {
+ _clipWidth = _screenSave._clipWidth;
+ _clipHeight = _screenSave._clipHeight;
+ _windowXAdd = _screenSave._windowXAdd;
+ _windowYAdd = _screenSave._windowYAdd;
+ _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;
+}
+
+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);
+ addDirtyRect(destBounds);
+}
+
+void Screen::restoreBlock() {
+ if (!_savedBounds.isEmpty())
+ addDirtyRect(_savedBounds);
+ ASurface::restoreBlock();
+}
+
+void Screen::drawRect() {
+ addDirtyRect(Common::Rect(_orgX1, _orgY1, _orgX2, _orgY2));
+ ASurface::drawRect();
+}
+
+void Screen::transBlitFrom(ASurface *src, const Common::Point &destPos) {
+ addDirtyRect(Common::Rect(destPos.x, destPos.y, destPos.x + src->w, destPos.y + src->h));
+ ASurface::transBlitFrom(src, destPos);
+}
+
+void Screen::transBlitFrom(ASurface *src, const Common::Rect &bounds) {
+ addDirtyRect(bounds);
+ ASurface::transBlitFrom(src, bounds);
+}
+
+void Screen::blitFrom(Graphics::Surface &src) {
+ addDirtyRect(Common::Rect(0, 0, src.w, src.h));
+ ASurface::blitFrom(src);
+}
+
+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;
+
+ 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);
+ }
+}
+
+void Screen::addDirtyRect(const Common::Rect &r) {
+ _dirtyRects.push_back(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
new file mode 100644
index 0000000000..d45a533f9a
--- /dev/null
+++ b/engines/access/screen.h
@@ -0,0 +1,182 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public 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 "common/stream.h"
+#include "access/asurface.h"
+
+namespace Access {
+
+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;
+ byte _tempPalette[PALETTE_SIZE];
+ byte _rawPalette[PALETTE_SIZE];
+ byte _savedPalettes[2][PALETTE_SIZE];
+ int _savedPaletteCount;
+ int _vesaCurrentWin;
+ int _currentPanel;
+ Common::Point _msVirtualOffset;
+ Common::Point _virtualOffsetsTable[4];
+ bool _hideFlag;
+ ScreenSave _screenSave;
+ int _startCycle;
+ int _cycleStart;
+ int _endCycle;
+ 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;
+ Common::Point _bufferStart;
+ int _windowXAdd, _windowYAdd;
+ int _screenYOff;
+ byte _manPal[0x60];
+ byte _scaleTable1[256];
+ byte _scaleTable2[256];
+ int _vWindowWidth;
+ int _vWindowHeight;
+ int _vWindowBytesWide;
+ int _bufferBytesWide;
+ int _vWindowLinesTall;
+ bool _screenChangeFlag;
+public:
+ virtual void copyBlock(ASurface *src, const Common::Rect &bounds);
+
+ virtual void restoreBlock();
+
+ virtual void drawRect();
+
+ virtual void transBlitFrom(ASurface *src, const Common::Point &destPos);
+
+ virtual void transBlitFrom(ASurface *src, const Common::Rect &bounds);
+
+ virtual void blitFrom(Graphics::Surface &src);
+
+ virtual void copyBuffer(Graphics::Surface *src);
+
+ virtual void addDirtyRect(const Common::Rect &r);
+public:
+ Screen(AccessEngine *vm);
+
+ virtual ~Screen() {}
+
+ void setDisplayScan();
+
+ void setPanel(int num);
+
+ /**
+ * Update the underlying screen
+ */
+ void updateScreen();
+
+ /**
+ * Fade out screen
+ */
+ void forceFadeOut();
+
+ /**
+ * Fade in screen
+ */
+ void forceFadeIn();
+
+ void fadeOut() { forceFadeOut(); }
+ void fadeIn() { forceFadeIn(); }
+ void clearScreen();
+
+ /**
+ * Set the initial palette
+ */
+ void setInitialPalettte();
+
+ /**
+ * Set icon palette
+ */
+ void setIconPalette() {}
+
+ void loadPalette(int fileNum, int subfile);
+
+ void setPalette();
+
+ void loadRawPalette(Common::SeekableReadStream *stream);
+
+ void savePalette();
+
+ void restorePalette();
+
+ void getPalette(byte *pal);
+
+ /**
+ * Copy a buffer to the screen
+ */
+ void copyBuffer(const byte *data);
+
+ void setBufferScan();
+
+ void setScaleTable(int scale);
+
+ /**
+ * Save all the screen display state variables
+ */
+ void saveScreen();
+
+ /**
+ * 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
+
+#endif /* ACCESS_SCREEN_H */
diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp
new file mode 100644
index 0000000000..1bd24894d7
--- /dev/null
+++ b/engines/access/scripts.cpp
@@ -0,0 +1,887 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public 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/scripts.h"
+
+namespace Access {
+
+Scripts::Scripts(AccessEngine *vm) : Manager(vm) {
+ _resource = nullptr;
+ _specialFunction = -1;
+ _data = nullptr;
+ _sequence = 0;
+ _endFlag = false;
+ _returnCode = 0;
+ _scriptCommand = 0;
+ _choice = 0;
+ _choiceStart = 0;
+ _charsOrg = Common::Point(0, 0);
+ _texsOrg = Common::Point(0, 0);
+}
+
+Scripts::~Scripts() {
+ freeScriptData();
+}
+
+void Scripts::setScript(Resource *res, bool restartFlag) {
+ _resource = res;
+ _data = res->_stream;
+ _endFlag = restartFlag;
+}
+
+void Scripts::freeScriptData() {
+ delete _resource;
+ _resource = nullptr;
+ _data = nullptr;
+}
+
+void Scripts::searchForSequence() {
+ assert(_data);
+
+ _data->seek(0);
+ int sequenceId;
+ do {
+ while (_data->readByte() != SCRIPT_START_BYTE) ;
+ sequenceId = _data->readUint16LE();
+ } while (sequenceId != _sequence);
+}
+
+void Scripts::charLoop() {
+ bool endFlag = _endFlag;
+ int pos = _data->pos();
+
+ _sequence = 2000;
+ searchForSequence();
+ _vm->_images.clear();
+ _vm->_buffer2.blitFrom(_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()
+}
+
+int Scripts::executeScript() {
+ assert(_data);
+ _endFlag = false;
+ _returnCode = 0;
+
+ do {
+ // Get next command, skipping over script start start if it's being pointed to
+ while ((_scriptCommand = _data->readByte()) == SCRIPT_START_BYTE)
+ _data->skip(2);
+
+ if (_scriptCommand < 0x80)
+ error("Unexpected opcode value %d", _scriptCommand);
+
+ executeCommand(_scriptCommand - 0x80);
+ } while (!_endFlag && !_vm->shouldQuitOrRestart());
+
+ return _returnCode;
+}
+
+typedef void(Scripts::*ScriptMethodPtr)();
+
+void Scripts::executeCommand(int commandIndex) {
+ static const ScriptMethodPtr COMMAND_LIST[] = {
+ &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::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::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::cmdPrintWatch, &Scripts::cmdDispAbout, &Scripts::cmdPushLocation,
+ &Scripts::cmdCheckTravel, &Scripts::cmdBlock, &Scripts::cmdPlayerOff,
+ &Scripts::cmdPlayerOn, &Scripts::cmdDead, &Scripts::cmdFadeOut,
+ &Scripts::cmdEndVideo
+ };
+
+ (this->*COMMAND_LIST[commandIndex])();
+}
+
+void Scripts::cmdObject() {
+ _vm->_bubbleBox->load(_data);
+}
+
+void Scripts::cmdEndObject() {
+ printString(GENERAL_MESSAGES[_vm->_room->_selectCommand]);
+}
+
+void Scripts::cmdJumpLook() {
+ if (_vm->_room->_selectCommand == 0)
+ cmdGoto();
+ else
+ _data->skip(2);
+}
+
+void Scripts::cmdJumpHelp() {
+ if (_vm->_room->_selectCommand == 8)
+ cmdGoto();
+ else
+ _data->skip(2);
+}
+
+void Scripts::cmdJumpGet() {
+ if (_vm->_room->_selectCommand == 3)
+ cmdGoto();
+ else
+ _data->skip(2);
+}
+
+void Scripts::cmdJumpMove() {
+ if (_vm->_room->_selectCommand == 2)
+ cmdGoto();
+ else
+ _data->skip(2);
+}
+
+void Scripts::cmdJumpUse() {
+ if (_vm->_room->_selectCommand == 4)
+ cmdGoto();
+ else
+ _data->skip(2);
+}
+
+void Scripts::cmdJumpTalk() {
+ if (_vm->_room->_selectCommand == 6)
+ cmdGoto();
+ else
+ _data->skip(2);
+}
+
+void Scripts::cmdNull() {
+}
+
+#define PRINT_TIMER 25
+
+void Scripts::cmdPrint() {
+ // Get a text line for display
+ Common::String msg = readString();
+ printString(msg);
+}
+
+void Scripts::printString(const Common::String &msg) {
+ _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;
+
+ // 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->shouldQuit() && _vm->_timers[PRINT_TIMER]._flag) {
+ _vm->_events->pollEvents();
+ }
+
+ // Restore the original screen over the text bubble
+ _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;
+}
+
+void Scripts::cmdAnim() {
+ int animId = _data->readByte();
+ _vm->_animation->animate(animId);
+}
+
+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 < 256);
+
+ if (_vm->_flags[flagNum] == flagVal)
+ cmdGoto();
+ else
+ _data->skip(2);
+}
+
+void Scripts::cmdGoto() {
+ _sequence = _data->readUint16LE();
+ searchForSequence();
+}
+
+void Scripts::cmdAddScore() {
+ if (!_vm->isDemo()) {
+ cmdSetInventory();
+ return;
+ }
+
+ _data->skip(1);
+}
+
+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() {
+ _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->_offsetY = _vm->_player->_playerOffset.y;
+ _vm->_player->_spritesPtr = _vm->_player->_playerSprites;
+ _vm->_player->_frameNumber = _vm->_player->_frame;
+
+ _vm->_room->setWallCodes();
+}
+
+#define CURRENT_ROOM 0xFF
+
+void Scripts::cmdNewRoom() {
+ int roomNumber = _data->readByte();
+ if (roomNumber != CURRENT_ROOM)
+ _vm->_player->_roomNumber = roomNumber;
+
+ _vm->_room->_function = FN_CLEAR1;
+ _vm->freeChar();
+ _vm->_converseMode = 0;
+ cmdRetPos();
+}
+
+void Scripts::cmdConverse() {
+ _vm->_conversation = _data->readUint16LE();
+ _vm->_room->clearRoom();
+ _vm->freeChar();
+ _vm->_char->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();
+ 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();
+ Animation *anim = _vm->_animation->findAnimation(id);
+
+ if (anim->_currentLoopCount == -1)
+ cmdGoto();
+ else
+ _data->skip(2);
+}
+
+void Scripts::cmdSnd() {
+ int id = _data->readByte();
+ _vm->_sound->playSound(id);
+}
+
+void Scripts::cmdRetNeg() {
+ _endFlag = true;
+ _returnCode = -1;
+}
+
+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();
+ else
+ _data->skip(2);
+}
+
+void Scripts::cmdSetAnim() {
+ int animId = _data->readByte();
+ Animation *anim = _vm->_animation->setAnimation(animId);
+
+ if (anim)
+ _vm->_animation->setAnimTimer(anim);
+}
+
+void Scripts::cmdDispInv() {
+ _vm->_inventory->newDisplayInv();
+}
+
+void Scripts::cmdSetAbout() {
+ if (!_vm->isDemo()) {
+ cmdSetTimer();
+ return;
+ }
+
+ error("TODO: DEMO - cmdSetAbout");
+}
+
+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();
+
+ _vm->_canSaveLoad = true;
+ _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->isKeyPending()) {
+ _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->isDemo()) {
+ cmdJumpGoto();
+ return;
+ }
+ error("TODO: DEMO - cmdSetTravel");
+}
+
+void Scripts::cmdJumpGoto() {
+ if (_vm->_room->_selectCommand == 5)
+ cmdGoto();
+ else
+ _data->skip(2);
+}
+
+void Scripts::cmdSetVideo() {
+ Common::Point pt;
+ pt.x = _data->readSint16LE();
+ pt.y = _data->readSint16LE();
+ int cellIndex = _data->readUint16LE();
+ int rate = _data->readUint16LE();
+
+ _vm->_video->setVideo(_vm->_screen, pt, _vm->_extraCells[cellIndex]._vid, rate);
+}
+
+void Scripts::cmdPlayVideo() {
+ _vm->_video->playVideo();
+}
+
+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() {
+ _vm->_current = &_vm->_buffer2;
+}
+
+void Scripts::cmdSetScroll() {
+ _vm->_scrollCol = _data->readUint16LE();
+ _vm->_scrollRow = _data->readUint16LE();
+ _vm->_scrollX = 0;
+ _vm->_scrollY = 0;
+}
+
+void Scripts::cmdSaveRect() {
+ if (!_vm->isDemo()) {
+ cmdVideoEnded();
+ return;
+ }
+ error("TODO: DEMO - cmdSaveRect");
+}
+
+void Scripts::cmdVideoEnded() {
+ _vm->_events->pollEventsAndWait();
+
+ if (_vm->_video->_videoEnd) {
+ cmdGoto();
+ } else {
+ _data->skip(2);
+ }
+}
+
+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;
+}
+
+void Scripts::cmdDoTravel() {
+ if (!_vm->isDemo()) {
+ cmdSpecial();
+ return;
+ }
+ error("TODO: DEMO - cmdDoTravel");
+}
+
+void Scripts::cmdCheckAbout() {
+ if (!_vm->isDemo()) {
+ cmdSpecial();
+ return;
+ }
+ error("TODO: DEMO - cmdCheckAbout");
+}
+
+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 = FN_RELOAD;
+ }
+}
+
+void Scripts::cmdSetCycle() {
+ int startCycle = _data->readUint16LE();
+ int endCycle = _data->readUint16LE();
+ int timer = _data->readUint16LE();
+ _vm->_screen->setPaletteCycle(startCycle, endCycle, timer);
+}
+
+void Scripts::cmdCycle() {
+ if (_vm->_startup == -1)
+ _vm->_screen->cyclePaletteForward();
+}
+
+void Scripts::cmdCharSpeak() {
+ _vm->_screen->_printOrg = _charsOrg;
+ _vm->_screen->_printStart = _charsOrg;
+
+ byte v;
+ Common::String tmpStr = "";
+ while ((v = _data->readByte()) != 0)
+ tmpStr += (char)v;
+
+ _vm->_bubbleBox->placeBubble(tmpStr);
+ findNull();
+}
+
+void Scripts::cmdTexSpeak() {
+ _vm->_screen->_printOrg = _texsOrg;
+ _vm->_screen->_printStart = _texsOrg;
+ _vm->_screen->_maxChars = 20;
+
+ byte v;
+ Common::String tmpStr = "";
+ while ((v = _data->readByte()) != 0)
+ tmpStr += (char)v;
+
+ _vm->_bubbleBox->_bubbleDisplStr = Common::String("JASON");
+ _vm->_bubbleBox->placeBubble1(tmpStr);
+ findNull();
+}
+
+#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 },
+ { 277, 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->_screen->_maxChars = 20;
+ _vm->_screen->_printOrg = _texsOrg;
+ _vm->_screen->_printStart = _texsOrg;
+
+ _vm->_bubbleBox->clearBubbles();
+ _vm->_bubbleBox->_bubbleDisplStr = Common::String("RESPONSE 1");
+
+ byte v;
+ Common::String tmpStr = "";
+ while ((v = _data->readByte()) != 0)
+ tmpStr += (char)v;
+
+ _vm->_bubbleBox->calcBubble(tmpStr);
+ _vm->_bubbleBox->printBubble(tmpStr);
+
+ Common::Array<Common::Rect> responseCoords;
+ responseCoords.push_back(_vm->_bubbleBox->_bounds);
+ _vm->_screen->_printOrg.y = _vm->_bubbleBox->_bounds.bottom + 11;
+
+ findNull();
+
+ tmpStr.clear();
+ while ((v = _data->readByte()) != 0)
+ tmpStr += (char)v;
+
+ if (tmpStr.size() != 0) {
+ _vm->_bubbleBox->_bubbleDisplStr = Common::String("RESPONSE 2");
+ _vm->_bubbleBox->calcBubble(tmpStr);
+ _vm->_bubbleBox->printBubble(tmpStr);
+ responseCoords.push_back(_vm->_bubbleBox->_bounds);
+ _vm->_screen->_printOrg.y = _vm->_bubbleBox->_bounds.bottom + 11;
+ }
+
+ findNull();
+
+ bool choice3Fl = false;
+ tmpStr.clear();
+ while ((v = _data->readByte()) != 0)
+ tmpStr += (char)v;
+
+ if (tmpStr.size() != 0) {
+ _vm->_bubbleBox->_bubbleDisplStr = Common::String("RESPONSE 3");
+ _vm->_bubbleBox->calcBubble(tmpStr);
+ _vm->_bubbleBox->printBubble(tmpStr);
+ responseCoords.push_back(_vm->_bubbleBox->_bounds);
+ _vm->_screen->_printOrg.y = _vm->_bubbleBox->_bounds.bottom + 11;
+ }
+
+ findNull();
+
+ int choice = -1;
+ do {
+ _vm->_events->pollEvents();
+ if (_vm->shouldQuit())
+ return;
+
+ charLoop();
+
+ _vm->_bubbleBox->_bubbleDisplStr = _vm->_bubbleBox->_bubbleTitle;
+ if (_vm->_events->_leftButton) {
+ if (_vm->_events->_mouseRow >= 22) {
+ _vm->_events->debounceLeft();
+ int x = _vm->_events->_mousePos.x;
+ for (int i = 0; i < BTN_COUNT; i++) {
+ if ((x >= BTN_RANGES[i][0]) && (x < BTN_RANGES[i][1])) {
+ choice = i;
+ break;
+ }
+ }
+ } else {
+ _vm->_events->debounceLeft();
+ choice = _vm->_events->checkMouseBox1(responseCoords);
+ }
+ }
+ } while ((choice == -1) || ((choice == 2) && choice3Fl));
+
+ _choice = choice + 1;
+ _vm->_bubbleBox->clearBubbles();
+}
+
+void Scripts::cmdWait() {
+ int time = _data->readSint16LE();
+ _vm->_timers[3]._timer = time;
+ _vm->_timers[3]._initTm = time;
+ _vm->_timers[3]._flag++;
+ _vm->_events->zeroKeys();
+
+ while (!_vm->shouldQuit() && !_vm->_events->isKeyMousePressed() &&
+ _vm->_timers[3]._flag) {
+ _vm->_midi->midiRepeat();
+ charLoop();
+
+ _vm->_events->pollEventsAndWait();
+ }
+
+ _vm->_events->debounceLeft();
+ _vm->_events->zeroKeys();
+}
+
+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() {
+ if (_vm->_video->_videoFrame == _data->readSint16LE())
+ cmdGoto();
+ else
+ _data->skip(2);
+}
+
+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() {
+ _vm->_screen->restoreBlock();
+}
+
+void Scripts::cmdLoadSound() {
+ int idx = _data->readSint16LE();
+
+ _vm->_sound->_soundTable.clear();
+ 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]._res) {
+ // Keep doing char display loop if playing sound for it
+ do {
+ if (_vm->_flags[236] == 1)
+ charLoop();
+
+ _vm->_events->pollEvents();
+ } while (!_vm->shouldQuit() && sound.isSFXPlaying());
+
+ // Free the sounds
+ while (sound._soundTable.size() > 0) {
+ delete sound._soundTable[0]._res;
+ sound._soundTable.remove_at(0);
+ }
+ }
+}
+
+void Scripts::cmdSetVideoSound() {
+ uint32 startPos = _data->pos();
+ _data->skip(4);
+ cmdLoadSound();
+ _data->seek(startPos);
+ cmdSetVideo();
+
+ _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;
+ }
+
+ _vm->_events->pollEventsAndWait();
+}
+
+void Scripts::cmdPrintWatch() {
+ if (!_vm->isDemo()) {
+ cmdPushLocation();
+ return;
+ }
+ error("TODO: DEMO - cmdPrintWatch");
+}
+
+void Scripts::cmdDispAbout() {
+ if (!_vm->isDemo()) {
+ cmdPushLocation();
+ return;
+ }
+ error("TODO: DEMO - cmdDispAbout");
+}
+
+void Scripts::cmdPushLocation() {
+ error("TODO cmdPushLocation");
+}
+
+void Scripts::cmdCheckTravel() {
+ if (!_vm->isDemo()) {
+ cmdPushLocation();
+ return;
+ }
+ error("TODO: DEMO - cmdCheckTravel");
+}
+
+void Scripts::cmdBlock() {
+ if (!_vm->isDemo()) {
+ cmdPushLocation();
+ return;
+ }
+ error("TODO: DEMO - cmdBlock");
+}
+
+void Scripts::cmdPlayerOff() {
+ _vm->_player->_playerOff = true;
+}
+
+void Scripts::cmdPlayerOn() {
+ _vm->_player->_playerOff = false;
+}
+
+void Scripts::cmdDead() {
+ int deathId = _data->readByte();
+ _vm->dead(deathId);
+}
+
+void Scripts::cmdFadeOut() {
+ _vm->_screen->forceFadeOut();
+}
+
+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
new file mode 100644
index 0000000000..cfadf6d901
--- /dev/null
+++ b/engines/access/scripts.h
@@ -0,0 +1,168 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public 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"
+#include "common/memstream.h"
+#include "access/data.h"
+
+namespace Access {
+
+class AccessEngine;
+class Scripts;
+
+#define SCRIPT_START_BYTE 0xE0
+#define ROOM_SCRIPT 2000
+
+class Scripts : public Manager {
+private:
+ Resource *_resource;
+ int _specialFunction;
+
+ void charLoop();
+protected:
+ Common::SeekableReadStream *_data;
+
+ virtual void executeSpecial(int commandIndex, int param1, int param2) = 0;
+ virtual void executeCommand(int commandIndex);
+
+ /**
+ * Read a null terminated string from the script
+ */
+ Common::String readString();
+
+ void cmdObject();
+ void cmdEndObject();
+ void cmdJumpLook();
+ void cmdJumpHelp();
+ void cmdJumpGet();
+ void cmdJumpMove();
+ void cmdJumpUse();
+ void cmdJumpTalk();
+ void cmdNull();
+ void cmdPrint();
+ void cmdAnim();
+ void cmdSetFlag();
+ void cmdCheckFlag();
+
+ /**
+ * Jump to another script
+ */
+ void cmdGoto();
+
+ void cmdAddScore();
+ void cmdSetInventory();
+ void cmdCheckInventory();
+ void cmdSetTex();
+ void cmdNewRoom();
+ void cmdConverse();
+ void cmdCheckFrame();
+ void cmdCheckAnim();
+ void cmdSnd();
+ void cmdRetNeg();
+ void cmdCheckLoc();
+ void cmdSetAnim();
+ void cmdDispInv();
+ void cmdSetAbout();
+ void cmdSetTimer();
+ void cmdCheckTimer();
+ void cmdJumpGoto();
+ void cmdSetTravel();
+ void cmdSetVideo();
+ void cmdPlayVideo();
+ void cmdPlotImage();
+ 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();
+ void cmdCharSpeak();
+ void cmdTexSpeak();
+ void cmdTexChoice();
+ void cmdWait();
+ void cmdSetConPos();
+ void cmdCheckVFrame();
+ void cmdJumpChoice();
+ void cmdReturnChoice();
+ void cmdClearBlock();
+ 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;
+ int _returnCode;
+ int _scriptCommand;
+ int _choice;
+ int32 _choiceStart;
+ Common::Point _charsOrg, _texsOrg;
+public:
+ Scripts(AccessEngine *vm);
+
+ virtual ~Scripts();
+
+ void setScript(Resource *data, bool restartFlag = false);
+
+ void freeScriptData();
+
+ void searchForSequence();
+
+ int executeScript();
+
+ 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();
+};
+
+} // End of namespace Access
+
+#endif /* ACCESS_SCRIPTS_H */
diff --git a/engines/access/sound.cpp b/engines/access/sound.cpp
new file mode 100644
index 0000000000..da267bdc4c
--- /dev/null
+++ b/engines/access/sound.cpp
@@ -0,0 +1,326 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "common/algorithm.h"
+#include "audio/mixer.h"
+#include "audio/decoders/raw.h"
+#include "audio/decoders/wave.h"
+#include "access/access.h"
+#include "access/sound.h"
+
+namespace Access {
+
+SoundManager::SoundManager(AccessEngine *vm, Audio::Mixer *mixer) : _vm(vm), _mixer(mixer) {
+}
+
+SoundManager::~SoundManager() {
+ clearSounds();
+}
+
+void SoundManager::clearSounds() {
+ debugC(1, kDebugSound, "clearSounds()");
+
+ for (uint i = 0; i < _soundTable.size(); ++i)
+ delete _soundTable[i]._res;
+
+ _soundTable.clear();
+
+ if (_mixer->isSoundHandleActive(_effectsHandle))
+ _mixer->stopHandle(_effectsHandle);
+
+ if (_queue.size())
+ _queue.remove_at(0);
+
+ while (_queue.size()) {
+ delete _queue[0];
+ _queue.remove_at(0);
+ }
+}
+
+void SoundManager::loadSoundTable(int idx, int fileNum, int subfile, int priority) {
+ debugC(1, kDebugSound, "loadSoundTable(%d, %d, %d)", idx, fileNum, subfile);
+
+ Resource *soundResource;
+
+ if (idx >= (int)_soundTable.size())
+ _soundTable.resize(idx + 1);
+
+ delete _soundTable[idx]._res;
+ soundResource = _vm->_files->loadFile(fileNum, subfile);
+ _soundTable[idx]._res = soundResource;
+ _soundTable[idx]._priority = priority;
+}
+
+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();
+
+ 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);
+ Audio::RewindableAudioStream *audioStream = Audio::makeWAVStream(waveStream, DisposeAfterUse::YES);
+ _queue.push_back(audioStream);
+
+ } 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
+ // 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: // 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;
+ }
+
+ Audio::RewindableAudioStream *audioStream = Audio::makeRawStream(resourceData + 32, sampleSize, sampleRate, 0, DisposeAfterUse::NO);
+ _queue.push_back(audioStream);
+
+ } else
+ error("Unknown format");
+
+ if (!_mixer->isSoundHandleActive(_effectsHandle))
+ _mixer->playStream(Audio::Mixer::kSFXSoundType, &_effectsHandle,
+ _queue[0], -1, _mixer->kMaxChannelVolume, 0,
+ DisposeAfterUse::YES);
+}
+
+void SoundManager::checkSoundQueue() {
+ debugC(5, kDebugSound, "checkSoundQueue");
+
+ if (_queue.empty() || _mixer->isSoundHandleActive(_effectsHandle))
+ return;
+
+ _queue.remove_at(0);
+
+ if (_queue.size())
+ _mixer->playStream(Audio::Mixer::kSFXSoundType, &_effectsHandle,
+ _queue[0], -1, _mixer->kMaxChannelVolume, 0,
+ DisposeAfterUse::YES);
+}
+
+bool SoundManager::isSFXPlaying() {
+ return _mixer->isSoundHandleActive(_effectsHandle);
+}
+
+void SoundManager::loadSounds(Common::Array<RoomInfo::SoundIdent> &sounds) {
+ debugC(1, kDebugSound, "loadSounds");
+
+ clearSounds();
+
+ for (uint i = 0; i < sounds.size(); ++i) {
+ Resource *sound = loadSound(sounds[i]._fileNum, sounds[i]._subfile);
+ _soundTable.push_back(SoundEntry(sound, sounds[i]._priority));
+ }
+}
+
+void SoundManager::stopSound() {
+ debugC(3, kDebugSound, "stopSound");
+
+ _mixer->stopHandle(Audio::SoundHandle());
+}
+
+void SoundManager::freeSounds() {
+ debugC(3, kDebugSound, "freeSounds");
+
+ stopSound();
+ clearSounds();
+}
+
+/******************************************************************************************/
+
+MusicManager::MusicManager(AccessEngine *vm) : _vm(vm) {
+ _music = nullptr;
+ _tempMusic = nullptr;
+ _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() {
+ delete _music;
+ 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() {
+ debugC(1, kDebugSound, "midiPlay");
+
+ if (_music->_size < 4) {
+ error("midiPlay() wrong music resource size");
+ }
+
+ stop();
+
+ 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");
+
+ _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);
+
+ setVolume(127);
+ _isPlaying = true;
+ }
+}
+
+bool MusicManager::checkMidiDone() {
+ debugC(1, kDebugSound, "checkMidiDone");
+ return (!_isPlaying);
+}
+
+void MusicManager::midiRepeat() {
+ debugC(1, kDebugSound, "midiRepeat");
+
+ if (!_parser)
+ return;
+
+ _isLooping = true;
+ _parser->property(MidiParser::mpAutoLoop, _isLooping);
+ if (!_isPlaying)
+ _parser->setTrack(0);
+}
+
+void MusicManager::stopSong() {
+ debugC(1, kDebugSound, "stopSong");
+
+ stop();
+}
+
+void MusicManager::loadMusic(int fileNum, int subfile) {
+ debugC(1, kDebugSound, "loadMusic(%d, %d)", fileNum, subfile);
+
+ _music = _vm->_files->loadFile(fileNum, subfile);
+}
+
+void MusicManager::loadMusic(FileIdent file) {
+ debugC(1, kDebugSound, "loadMusic(%d, %d)", file._fileNum, file._subfile);
+
+ _music = _vm->_files->loadFile(file);
+}
+
+void MusicManager::newMusic(int musicId, int mode) {
+ debugC(1, kDebugSound, "newMusic(%d, %d)", musicId, mode);
+
+ if (mode == 1) {
+ stopSong();
+ freeMusic();
+ _music = _tempMusic;
+ _tempMusic = nullptr;
+ _isLooping = true;
+ } else {
+ _isLooping = (mode == 2);
+ _tempMusic = _music;
+ stopSong();
+ loadMusic(97, musicId);
+ }
+
+ if (_music)
+ midiPlay();
+}
+
+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);
+}
+} // End of namespace Access
diff --git a/engines/access/sound.h b/engines/access/sound.h
new file mode 100644
index 0000000000..90f6656e26
--- /dev/null
+++ b/engines/access/sound.h
@@ -0,0 +1,111 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public 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
+
+#include "common/scummsys.h"
+#include "audio/audiostream.h"
+#include "audio/mixer.h"
+#include "access/files.h"
+#include "audio/midiplayer.h"
+#include "audio/midiparser.h"
+
+#define MAX_SOUNDS 20
+
+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;
+ Audio::Mixer *_mixer;
+ Audio::SoundHandle _effectsHandle;
+ Common::Array<Audio::RewindableAudioStream *> _queue;
+
+ void clearSounds();
+
+ void playSound(Resource *res, int priority);
+public:
+ Common::Array<SoundEntry> _soundTable;
+public:
+ SoundManager(AccessEngine *vm, Audio::Mixer *mixer);
+ ~SoundManager();
+
+ void loadSoundTable(int idx, int fileNum, int subfile, int priority = 1);
+
+ void playSound(int soundIndex);
+ void checkSoundQueue();
+ bool isSFXPlaying();
+
+ Resource *loadSound(int fileNum, int subfile);
+ void loadSounds(Common::Array<RoomInfo::SoundIdent> &sounds);
+
+ void stopSound();
+ void freeSounds();
+};
+
+class MusicManager : public Audio::MidiPlayer {
+private:
+ AccessEngine *_vm;
+
+ Resource *_tempMusic;
+
+ // MidiDriver_BASE interface implementation
+ virtual void send(uint32 b);
+
+public:
+ Resource *_music;
+
+public:
+ MusicManager(AccessEngine *vm);
+ ~MusicManager();
+
+ void midiPlay();
+
+ bool checkMidiDone();
+
+ void midiRepeat();
+
+ void stopSong();
+
+ void newMusic(int musicId, int mode);
+
+ void freeMusic();
+
+ void loadMusic(int fileNum, int subfile);
+ void loadMusic(FileIdent file);
+
+ void setLoop(bool loop);
+};
+} // End of namespace Access
+
+#endif /* ACCESS_SOUND_H*/
diff --git a/engines/access/video.cpp b/engines/access/video.cpp
new file mode 100644
index 0000000000..63d0aa5c89
--- /dev/null
+++ b/engines/access/video.cpp
@@ -0,0 +1,187 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public 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"
+#include "access/access.h"
+
+namespace Access {
+
+VideoPlayer::VideoPlayer(AccessEngine *vm) : Manager(vm) {
+ _vidSurface = nullptr;
+ _videoData = nullptr;
+ _startCoord = nullptr;
+
+ _frameCount = 0;
+ _xCount = 0;
+ _scanCount = 0;
+ _frameSize = 0;
+ _videoFrame = 0;
+ _soundFlag = false;
+ _soundFrame = 0;
+ _videoEnd = false;
+
+ _header._frameCount = 0;
+ _header._width = _header._height = 0;
+ _header._flags = VIDEOFLAG_NONE;
+}
+
+VideoPlayer::~VideoPlayer() {
+ closeVideo();
+}
+
+
+void VideoPlayer::setVideo(ASurface *vidSurface, const Common::Point &pt, const 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
+ _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;
+ _videoFrame = 0;
+ _videoBounds = Common::Rect(pt.x, pt.y, pt.x + _header._width, pt.y + _header._height);
+
+ getFrame();
+
+ if (_header._flags == VIDEOFLAG_BG) {
+ // Draw the background
+ for (int y = 0; y < _scanCount; ++y) {
+ byte *pDest = (byte *)vidSurface->getBasePtr(pt.x, pt.y + y);
+ _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::closeVideo() {
+ delete _videoData;
+ _videoData = nullptr;
+}
+
+void VideoPlayer::getFrame() {
+ _frameSize = _videoData->_stream->readUint16LE();
+}
+
+void VideoPlayer::playVideo() {
+ if (_vm->_timers[31]._flag)
+ 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 (count >= (pLine + _xCount - pDest)) {
+ count -= (pLine + _xCount - pDest);
+ pLine += _vidSurface->pitch;
+ pDest = pLine;
+ }
+
+ // Skip any remaining pixels in the new line
+ pDest += count;
+ } else {
+ // 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;
+ }
+ }
+ }
+
+ // 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();
+ _videoEnd = true;
+ }
+}
+
+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;
+ 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
diff --git a/engines/access/video.h b/engines/access/video.h
new file mode 100644
index 0000000000..17825db367
--- /dev/null
+++ b/engines/access/video.h
@@ -0,0 +1,82 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public 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 "common/memstream.h"
+#include "access/data.h"
+#include "access/asurface.h"
+#include "access/files.h"
+
+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 _xCount;
+ int _scanCount;
+ int _frameSize;
+ Common::Rect _videoBounds;
+
+ void getFrame();
+public:
+ int _videoFrame;
+ bool _soundFlag;
+ int _soundFrame;
+ bool _videoEnd;
+public:
+ VideoPlayer(AccessEngine *vm);
+ ~VideoPlayer();
+
+ /**
+ * Start up a video
+ */
+ void setVideo(ASurface *vidSurface, const Common::Point &pt, const FileIdent &videoFile, int rate);
+
+ /**
+ * Decodes a frame of the video
+ */
+ void playVideo();
+
+ void copyVideo();
+ /**
+ * Frees the data for a previously loaded video
+ */
+ void closeVideo();
+};
+
+} // End of namespace Access
+
+#endif /* ACCESS_VIDEO_H */
diff --git a/engines/agi/agi.cpp b/engines/agi/agi.cpp
index 6bdbabd33e..1e663ec29a 100644
--- a/engines/agi/agi.cpp
+++ b/engines/agi/agi.cpp
@@ -492,14 +492,10 @@ struct GameSettings {
const char *detectname;
};
-static const GameSettings agiSettings[] = {
- {"agi", "AGI game", GID_AGI, MDT_ADLIB, "OBJECT"},
- {NULL, NULL, 0, 0, NULL}
-};
-
AgiBase::AgiBase(OSystem *syst, const AGIGameDescription *gameDesc) : Engine(syst), _gameDescription(gameDesc) {
// Assign default values to the config manager, in case settings are missing
ConfMan.registerDefault("originalsaveload", "false");
+ ConfMan.registerDefault("altamigapalette", "false");
_noSaveLoadAllowed = false;
diff --git a/engines/agi/detection.cpp b/engines/agi/detection.cpp
index 1d58900056..3230b4e5d3 100644
--- a/engines/agi/detection.cpp
+++ b/engines/agi/detection.cpp
@@ -145,6 +145,13 @@ static const ExtraGuiOption agiExtraGuiOption = {
false
};
+static const ExtraGuiOption agiExtraGuiOptionAmiga = {
+ _s("Use an alternative palette"),
+ _s("Use an alternative palette, common for all Amiga games. This was the old behavior"),
+ "altamigapalette",
+ false
+};
+
#include "agi/detection_tables.h"
using namespace Agi;
@@ -230,6 +237,8 @@ bool AgiMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGameD
const ExtraGuiOptions AgiMetaEngine::getExtraGuiOptions(const Common::String &target) const {
ExtraGuiOptions options;
options.push_back(agiExtraGuiOption);
+ if (target.contains("-amiga"))
+ options.push_back(agiExtraGuiOptionAmiga);
return options;
}
@@ -267,15 +276,13 @@ SaveStateList AgiMetaEngine::listSaves(const char *target) const {
int AgiMetaEngine::getMaximumSaveSlot() const { return 999; }
void AgiMetaEngine::removeSaveState(const char *target, int slot) const {
- char fileName[MAXPATHLEN];
- sprintf(fileName, "%s.%03d", target, slot);
+ Common::String fileName = Common::String::format("%s.%03d", target, slot);
g_system->getSavefileManager()->removeSavefile(fileName);
}
SaveStateDescriptor AgiMetaEngine::querySaveMetaInfos(const char *target, int slot) const {
const uint32 AGIflag = MKTAG('A','G','I',':');
- char fileName[MAXPATHLEN];
- sprintf(fileName, "%s.%03d", target, slot);
+ Common::String fileName = Common::String::format("%s.%03d", target, slot);
Common::InSaveFile *in = g_system->getSavefileManager()->openForLoading(fileName);
diff --git a/engines/agi/graphics.cpp b/engines/agi/graphics.cpp
index 34651c70b2..2b1bd8c829 100644
--- a/engines/agi/graphics.cpp
+++ b/engines/agi/graphics.cpp
@@ -20,6 +20,7 @@
*
*/
+#include "common/config-manager.h"
#include "common/file.h"
#include "common/textconsole.h"
@@ -220,7 +221,7 @@ static const uint8 amigaAgiPaletteV3[16 * 3] = {
/**
* 16 color amiga-ish palette.
*/
-static const uint8 newPalette[16 * 3] = {
+static const uint8 altAmigaPalette[16 * 3] = {
0x00, 0x00, 0x00,
0x00, 0x00, 0x3f,
0x00, 0x2A, 0x00,
@@ -904,6 +905,7 @@ static const byte sciMouseCursor[] = {
0,0,0,0,0,0,1,2,2,1,0
};
+#if 0
/**
* A black and white Apple IIGS style arrow cursor (9x11).
* 0 = Transparent.
@@ -923,6 +925,7 @@ static const byte appleIIgsMouseCursor[] = {
2,2,2,0,2,1,1,2,0,
0,0,0,0,0,2,2,2,0
};
+#endif
/**
* RGB-palette for the black and white SCI and Apple IIGS arrow cursors.
@@ -1030,8 +1033,22 @@ int GfxMgr::initVideo() {
initPalette(vgaPalette, 256, 8);
else if (_vm->_renderMode == Common::kRenderEGA)
initPalette(egaPalette);
- else
- initPalette(newPalette);
+ else if (_vm->_renderMode == Common::kRenderAmiga) {
+ if (!ConfMan.getBool("altamigapalette")) {
+ // Set the correct Amiga palette
+ if (_vm->getVersion() < 0x2936)
+ // TODO: This palette isn't used for Apple IIGS games yet, as
+ // we don't set a separate render mode for them yet
+ initPalette(amigaAgiPaletteV1, 16, 4);
+ else if (_vm->getVersion() == 0x2936)
+ initPalette(amigaAgiPaletteV2, 16, 4);
+ else if (_vm->getVersion() > 0x2936)
+ initPalette(amigaAgiPaletteV3, 16, 4);
+ } else
+ // Set the old common alternative Amiga palette
+ initPalette(altAmigaPalette);
+ } else
+ error("initVideo: Unhandled render mode");
if ((_agiScreen = (uint8 *)calloc(GFX_WIDTH, GFX_HEIGHT)) == NULL)
return errNotEnoughMemory;
diff --git a/engines/agi/loader_v2.cpp b/engines/agi/loader_v2.cpp
index 787eeaa0c7..693c53c2bf 100644
--- a/engines/agi/loader_v2.cpp
+++ b/engines/agi/loader_v2.cpp
@@ -135,13 +135,13 @@ int AgiLoader_v2::unloadResource(int t, int n) {
*/
uint8 *AgiLoader_v2::loadVolRes(struct AgiDir *agid) {
uint8 *data = NULL;
- char x[MAXPATHLEN], *path;
+ char x[6];
Common::File fp;
unsigned int sig;
+ Common::String path;
- sprintf(x, "vol.%i", agid->volume);
- path = x;
- debugC(3, kDebugLevelResources, "Vol res: path = %s", path);
+ path = Common::String::format("vol.%i", agid->volume);
+ debugC(3, kDebugLevelResources, "Vol res: path = %s", path.c_str());
if (agid->offset != _EMPTY && fp.open(path)) {
debugC(3, kDebugLevelResources, "loading resource at offset %d", agid->offset);
diff --git a/engines/agi/loader_v3.cpp b/engines/agi/loader_v3.cpp
index fa135e5476..39759b4649 100644
--- a/engines/agi/loader_v3.cpp
+++ b/engines/agi/loader_v3.cpp
@@ -198,14 +198,13 @@ int AgiLoader_v3::unloadResource(int t, int n) {
* NULL is returned if unsucsessful.
*/
uint8 *AgiLoader_v3::loadVolRes(AgiDir *agid) {
- char x[MAXPATHLEN];
+ char x[8];
uint8 *data = NULL, *compBuffer;
Common::File fp;
Common::String path;
debugC(3, kDebugLevelResources, "(%p)", (void *)agid);
- sprintf(x, "vol.%i", agid->volume);
- path = Common::String(_vm->_game.name) + x;
+ path = Common::String::format("%svol.%i", _vm->_game.name, agid->volume);
if (agid->offset != _EMPTY && fp.open(path)) {
fp.seek(agid->offset, SEEK_SET);
diff --git a/engines/agi/preagi_mickey.cpp b/engines/agi/preagi_mickey.cpp
index 4ca8d00824..a1572d7f1f 100644
--- a/engines/agi/preagi_mickey.cpp
+++ b/engines/agi/preagi_mickey.cpp
@@ -892,6 +892,7 @@ void MickeyEngine::drawRoom() {
drawRoomAnimation();
}
+#if 0
const uint8 colorBCG[16][2] = {
{ 0x00, 0x00 }, // 0 (black, black)
{ 0, 0 },
@@ -910,6 +911,7 @@ const uint8 colorBCG[16][2] = {
{ 0, 0 },
{ 0xFF, 0xFF } // F (white, white)
};
+#endif
void MickeyEngine::drawLogo() {
// TODO: clean this up and make it work properly, the logo is drawn way off to the right
diff --git a/engines/agos/detection_tables.h b/engines/agos/detection_tables.h
index 77fc88c6bb..2f4709c49e 100644
--- a/engines/agos/detection_tables.h
+++ b/engines/agos/detection_tables.h
@@ -1259,6 +1259,32 @@ static const AGOSGameDescription gameDescriptions[] = {
GF_TALKIE | GF_OLD_BUNDLE | GF_PLANAR
},
+ // Simon the Sorcerer 1 - English Amiga CD32 demo, from the cover disc of
+ // issue 5 (October 1994) of Amiga CD32 Gamer
+ {
+ {
+ "simon1",
+ "CD32 Demo",
+
+ {
+ { "gameamiga", GAME_BASEFILE, "e243f9229f9728b3476e54d2cf5f18a1", 27998},
+ { "icon.pkd", GAME_ICONFILE, "565ef7a98dcc21ef526a2bb10b6f42ed", 18979},
+ { "stripped.txt", GAME_STRFILE, "94413c71c86c32ed9baaa1c74a151cb3", 243},
+ { "tbllist", GAME_TBLFILE, "f9d5bf2ce09f82289c791c3ca26e1e4b", 696},
+ { NULL, 0, NULL, 0}
+ },
+ Common::EN_ANY,
+ Common::kPlatformAmiga,
+ ADGF_CD | ADGF_DEMO,
+ GUIO2(GUIO_NOSUBTITLES, GUIO_NOMIDI)
+ },
+
+ GType_SIMON1,
+ GID_SIMON1CD32,
+ GF_TALKIE | GF_OLD_BUNDLE | GF_PLANAR
+ },
+
+
// Simon the Sorcerer 1 - English DOS Floppy Demo
{
{
diff --git a/engines/agos/gfx.cpp b/engines/agos/gfx.cpp
index 33145b7d0d..5a1f9f1917 100644
--- a/engines/agos/gfx.cpp
+++ b/engines/agos/gfx.cpp
@@ -547,7 +547,7 @@ void AGOSEngine_Simon1::drawMaskedImage(VC10_state *state) {
if ((dst[count * 2] & 0xF0) == 0x20)
dst[count * 2] = src[count * 2];
if (mask[count + state->x_skip] & 0x0F)
- if ((dst[count * 2 + 1] & 0x0F) == 0x20)
+ if ((dst[count * 2 + 1] & 0xF0) == 0x20)
dst[count * 2 + 1] = src[count * 2 + 1];
} else {
/* no transparency */
diff --git a/engines/agos/input.cpp b/engines/agos/input.cpp
index 8a4e87017a..687a8ef1cf 100644
--- a/engines/agos/input.cpp
+++ b/engines/agos/input.cpp
@@ -460,7 +460,7 @@ void AGOSEngine_Simon1::handleMouseWheelUp() {
_saveLoadEdit = false;
listSaveGames();
}
- } else {
+ } else {
AGOSEngine::handleMouseWheelUp();
}
}
@@ -472,11 +472,11 @@ void AGOSEngine_Simon1::handleMouseWheelDown() {
_saveLoadRowCurPos += 1;
if (_saveLoadRowCurPos >= _numSaveGameRows)
_saveLoadRowCurPos = _numSaveGameRows;
-
+
_saveLoadEdit = false;
listSaveGames();
}
- } else {
+ } else {
AGOSEngine::handleMouseWheelDown();
}
}
@@ -492,7 +492,7 @@ void AGOSEngine_Elvira2::handleMouseWheelUp() {
_saveLoadRowCurPos -= 3;
listSaveGames();
- } else {
+ } else {
AGOSEngine::handleMouseWheelUp();
}
}
@@ -506,7 +506,7 @@ void AGOSEngine_Elvira2::handleMouseWheelDown() {
_saveLoadRowCurPos = 1;
listSaveGames();
- } else {
+ } else {
AGOSEngine::handleMouseWheelDown();
}
}
diff --git a/engines/agos/midi.cpp b/engines/agos/midi.cpp
index c26fbe3331..045fd9dac5 100644
--- a/engines/agos/midi.cpp
+++ b/engines/agos/midi.cpp
@@ -52,7 +52,7 @@ MidiPlayer::MidiPlayer() {
_paused = false;
_currentTrack = 255;
- _loopTrack = 0;
+ _loopTrackDefault = false;
_queuedTrack = 255;
_loopQueuedTrack = 0;
}
@@ -166,13 +166,13 @@ void MidiPlayer::metaEvent(byte type, byte *data, uint16 length) {
return;
} else if (_current == &_sfx) {
clearConstructs(_sfx);
- } else if (_loopTrack) {
+ } else if (_current->loopTrack) {
_current->parser->jumpToTick(0);
} else if (_queuedTrack != 255) {
_currentTrack = 255;
byte destination = _queuedTrack;
_queuedTrack = 255;
- _loopTrack = _loopQueuedTrack;
+ _current->loopTrack = _loopQueuedTrack;
_loopQueuedTrack = false;
// Remember, we're still inside the locked mutex.
@@ -300,7 +300,7 @@ void MidiPlayer::setVolume(int musicVol, int sfxVol) {
void MidiPlayer::setLoop(bool loop) {
Common::StackLock lock(_mutex);
- _loopTrack = loop;
+ _loopTrackDefault = loop;
}
void MidiPlayer::queueTrack(int track, bool loop) {
@@ -405,7 +405,7 @@ void MidiPlayer::loadSMF(Common::File *in, int song, bool sfx) {
uint32 timerRate = _driver->getBaseTempo();
- if (!memcmp(p->data, "GMF\x1", 4)) {
+ if (isGMF) {
// The GMF header
// 3 BYTES: 'GMF'
// 1 BYTE : Major version
@@ -426,11 +426,9 @@ void MidiPlayer::loadSMF(Common::File *in, int song, bool sfx) {
// It seems that 4 corresponds to our base tempo, so
// this should be the right way to calculate it.
timerRate = (4 * _driver->getBaseTempo()) / p->data[5];
-
- // According to bug #1004919 calling setLoop() from
- // within a lock causes a lockup, though I have no
- // idea when this actually happens.
- _loopTrack = (p->data[6] != 0);
+ p->loopTrack = (p->data[6] != 0);
+ } else {
+ p->loopTrack = _loopTrackDefault;
}
MidiParser *parser = MidiParser::createParser_SMF();
@@ -500,6 +498,8 @@ void MidiPlayer::loadMultipleSMF(Common::File *in, bool sfx) {
p->song_sizes[i] = size;
}
+ p->loopTrack = _loopTrackDefault;
+
if (!sfx) {
_currentTrack = 255;
resetVolumeTable();
@@ -531,6 +531,7 @@ void MidiPlayer::loadXMIDI(Common::File *in, bool sfx) {
in->seek(pos, 0);
p->data = (byte *)calloc(size, 1);
in->read(p->data, size);
+ p->loopTrack = _loopTrackDefault;
} else {
error("Expected 'FORM' tag but found '%c%c%c%c' instead", buf[0], buf[1], buf[2], buf[3]);
}
@@ -575,6 +576,7 @@ void MidiPlayer::loadS1D(Common::File *in, bool sfx) {
_currentTrack = 255;
resetVolumeTable();
}
+ p->loopTrack = _loopTrackDefault;
p->parser = parser; // That plugs the power cord into the wall
}
diff --git a/engines/agos/midi.h b/engines/agos/midi.h
index 3efadddc2f..398e445535 100644
--- a/engines/agos/midi.h
+++ b/engines/agos/midi.h
@@ -36,6 +36,7 @@ namespace AGOS {
struct MusicInfo {
MidiParser *parser;
byte *data;
+ bool loopTrack;
byte num_songs; // For Type 1 SMF resources
byte *songs[16]; // For Type 1 SMF resources
uint32 song_sizes[16]; // For Type 1 SMF resources
@@ -46,6 +47,7 @@ struct MusicInfo {
MusicInfo() { clear(); }
void clear() {
parser = 0; data = 0; num_songs = 0;
+ loopTrack = false;
memset(songs, 0, sizeof(songs));
memset(song_sizes, 0, sizeof(song_sizes));
memset(channel, 0, sizeof(channel));
@@ -71,7 +73,7 @@ protected:
// These are only used for music.
byte _currentTrack;
- bool _loopTrack;
+ bool _loopTrackDefault;
byte _queuedTrack;
bool _loopQueuedTrack;
diff --git a/engines/bbvs/bbvs.cpp b/engines/bbvs/bbvs.cpp
index d2e13e525c..11e4b6cea7 100644
--- a/engines/bbvs/bbvs.cpp
+++ b/engines/bbvs/bbvs.cpp
@@ -60,7 +60,7 @@ static const BBPoint kInventorySlotPositions[] = {
{135, 93}, {134, 145}, { 96, 224}, {128, 224}, {160, 224},
{192, 224}, {224, 224}, {240, 224}, {256, 224}, { 0, 0}
};
-
+
static const BBRect kVerbRects[6] = {
{-32, -2, 19, 27}, {-33, -33, 19, 27}, { 12, -2, 19, 27},
{ 13, -33, 19, 27}, {-10, 8, 19, 27}, {-11, -49, 19, 27}
@@ -77,7 +77,7 @@ bool WalkArea::contains(const Common::Point &pt) const {
BbvsEngine::BbvsEngine(OSystem *syst, const ADGameDescription *gd) :
Engine(syst), _gameDescription(gd) {
-
+
_random = new Common::RandomSource("bbvs");
_currActionCommandIndex = -1;
_buttheadObject = nullptr;
@@ -148,14 +148,14 @@ Common::Error BbvsEngine::run() {
_gameModule = new GameModule();
_spriteModule = new SpriteModule();
_sound = new SoundMan();
-
+
allocSnapshot();
memset(_easterEggInput, 0, sizeof(_easterEggInput));
-
+
_gameTicks = 0;
_playVideoNumber = 0;
_bootSaveSlot = -1;
-
+
memset(_inventoryItemStatus, 0, sizeof(_inventoryItemStatus));
memset(_gameVars, 0, sizeof(_gameVars));
memset(_sceneVisited, 0, sizeof(_sceneVisited));
@@ -189,7 +189,7 @@ Common::Error BbvsEngine::run() {
_playVideoNumber = 0;
}
}
-
+
writeContinueSavegame();
freeSnapshot();
@@ -282,20 +282,20 @@ void BbvsEngine::updateGame() {
inputTicks = 1;
_gameTicks = _system->getMillis();
}
-
+
if (inputTicks > 20) {
inputTicks = 20;
_gameTicks = _system->getMillis();
}
-
+
if (inputTicks == 0)
return;
-
+
if (_mouseX >= 320 || _mouseY >= 240) {
_mouseY = -1;
_mouseX = -1;
}
-
+
bool done;
do {
@@ -304,14 +304,14 @@ void BbvsEngine::updateGame() {
_mouseButtons &= ~kRightButtonClicked;
_keyCode = Common::KEYCODE_INVALID;
} while (--inputTicks && _playVideoNumber == 0 && _gameTicks > 0 && !done);
-
+
if (!done && _playVideoNumber == 0 && _gameTicks > 0) {
DrawList drawList;
buildDrawList(drawList);
_screen->drawDrawList(drawList, _spriteModule);
drawScreen();
}
-
+
_system->delayMillis(10);
}
@@ -329,7 +329,7 @@ void BbvsEngine::updateBackgroundSounds() {
_backgroundSoundsActive[i] = 0;
}
}
-}
+}
bool BbvsEngine::update(int mouseX, int mouseY, uint mouseButtons, Common::KeyCode keyCode) {
@@ -339,7 +339,7 @@ bool BbvsEngine::update(int mouseX, int mouseY, uint mouseButtons, Common::KeyCo
_bootSaveSlot = -1;
return false;
}
-
+
if (_newSceneNum != 0) {
_gameTicks = 0;
return changeScene();
@@ -413,7 +413,7 @@ bool BbvsEngine::update(int mouseX, int mouseY, uint mouseButtons, Common::KeyCo
}
updateInventory(mouseButtons & kLeftButtonClicked);
break;
-
+
case kGSVerbs:
_isSaveAllowed = false;
updateVerbs();
@@ -426,7 +426,7 @@ bool BbvsEngine::update(int mouseX, int mouseY, uint mouseButtons, Common::KeyCo
}
}
break;
-
+
case kGSWait:
case kGSWaitDialog:
_isSaveAllowed = false;
@@ -438,14 +438,14 @@ bool BbvsEngine::update(int mouseX, int mouseY, uint mouseButtons, Common::KeyCo
else
updateCommon();
break;
-
+
case kGSDialog:
_isSaveAllowed = true;
saveSnapshot();
updateDialog(mouseButtons & kLeftButtonClicked);
updateCommon();
break;
-
+
}
return true;
@@ -503,7 +503,7 @@ void BbvsEngine::buildDrawList(DrawList &drawList) {
// Verbs background
drawList.add(_gameModule->getGuiSpriteIndex(13), _verbPos.x - _cameraPos.x,
_verbPos.y - _cameraPos.y, 500);
- // Selected inventory item
+ // Selected inventory item
if (_currInventoryItem >= 0) {
drawList.add(_gameModule->getInventoryItemSpriteIndex(2 * _currInventoryItem), _verbPos.x - _cameraPos.x,
_verbPos.y - _cameraPos.y + 27, 500);
@@ -538,7 +538,7 @@ void BbvsEngine::updateVerbs() {
_mouseCursorSpriteIndex = 0;
return;
}
-
+
for (int i = 0; i < 6; ++i) {
const BBRect &verbRect = kVerbRects[i];
const int16 x = _verbPos.x + verbRect.x;
@@ -551,7 +551,7 @@ void BbvsEngine::updateVerbs() {
break;
}
}
-
+
switch (_currVerbNum) {
case kVerbLook:
case kVerbUse:
@@ -585,7 +585,7 @@ void BbvsEngine::updateDialog(bool clicked) {
_gameState = kGSScene;
return;
}
-
+
int slotX = (_mousePos.x - _cameraPos.x) / 32;
if (slotX >= _dialogSlotCount) {
@@ -597,7 +597,7 @@ void BbvsEngine::updateDialog(bool clicked) {
_mouseCursorSpriteIndex = _gameModule->getGuiSpriteIndex(5);
_activeItemType = kITDialog;
-
+
// Find the selected dialog item index
for (int i = 0; i < 50 && slotX >= 0; ++i) {
if (_dialogItemStatus[i]) {
@@ -605,7 +605,7 @@ void BbvsEngine::updateDialog(bool clicked) {
_activeItemIndex = i;
}
}
-
+
// Select the dialog item action if it was clicked
if (clicked) {
for (int i = 0; i < _gameModule->getActionsCount(); ++i) {
@@ -622,7 +622,7 @@ void BbvsEngine::updateDialog(bool clicked) {
}
void BbvsEngine::updateInventory(bool clicked) {
-
+
Common::Rect kInvButtonRects[3] = {
Common::Rect(97, 13, 97 + 20, 13 + 26),
Common::Rect(135, 15, 135 + 46, 15 + 25),
@@ -636,10 +636,10 @@ void BbvsEngine::updateInventory(bool clicked) {
if (_currVerbNum != kVerbLook && _currVerbNum != kVerbUse && _currVerbNum != kVerbInvItem)
_currVerbNum = kVerbUse;
-
+
const int16 mx = _mousePos.x - _cameraPos.x;
const int16 my = _mousePos.y - _cameraPos.y;
-
+
// Check inventory exit left/right edge of screen
if (mx < 40 || mx > 280) {
_mouseCursorSpriteIndex = _gameModule->getGuiSpriteIndex(10);
@@ -652,7 +652,7 @@ void BbvsEngine::updateInventory(bool clicked) {
return;
}
- // Check hovered/clicked inventory button
+ // Check hovered/clicked inventory button
_inventoryButtonIndex = -1;
if (kInvButtonRects[0].contains(mx, my)) {
_inventoryButtonIndex = 0;
@@ -677,10 +677,10 @@ void BbvsEngine::updateInventory(bool clicked) {
// Find hovered/clicked inventory item
int currItem = -1;
-
+
if (_currVerbNum == kVerbInvItem)
currItem = _currInventoryItem;
-
+
_activeItemType = kITEmpty;
for (int i = 0; i < 50; ++i) {
@@ -769,7 +769,7 @@ void BbvsEngine::updateScene(bool clicked) {
}
}
}
-
+
for (int i = 0; i < _gameModule->getBgObjectsCount(); ++i) {
BgObject *bgObject = _gameModule->getBgObject(i);
if (lastPriority <= bgObject->rect.bottom && bgObject->rect.contains(_mousePos)) {
@@ -921,7 +921,7 @@ bool BbvsEngine::performActionCommand(ActionCommand *actionCommand) {
return false;
case kActionCmdWalkObject:
- {
+ {
SceneObject *sceneObject = &_sceneObjects[actionCommand->sceneObjectIndex];
debug(5, "[%s] walks from (%d, %d) to (%d, %d)", sceneObject->sceneObjectDef->name,
sceneObject->x >> 16, sceneObject->y >> 16, actionCommand->walkDest.x, actionCommand->walkDest.y);
@@ -998,14 +998,14 @@ bool BbvsEngine::performActionCommand(ActionCommand *actionCommand) {
bool BbvsEngine::processCurrAction() {
bool actionsFinished = false;
-
+
if (_sceneObjectActions.size() == 0) {
-
+
for (uint i = 0; i < _currAction->actionCommands.size(); ++i) {
ActionCommand *actionCommand = &_currAction->actionCommands[i];
if (actionCommand->timeStamp != 0)
break;
-
+
if (actionCommand->cmd == kActionCmdMoveObject || actionCommand->cmd == kActionCmdAnimObject) {
SceneObjectAction *sceneObjectAction = 0;
// See if there's already an entry for the SceneObject
@@ -1027,14 +1027,14 @@ bool BbvsEngine::processCurrAction() {
sceneObjectAction->animationIndex = actionCommand->param;
}
}
-
+
if (actionCommand->cmd == kActionCmdSetCameraPos) {
_currCameraNum = actionCommand->param;
_newCameraPos = _gameModule->getCameraInit(actionCommand->param)->cameraPos;
}
}
-
+
// Delete entries for SceneObjects without anim
for (uint i = 0; i < _sceneObjectActions.size();) {
if (!_sceneObjects[_sceneObjectActions[i].sceneObjectIndex].anim)
@@ -1107,7 +1107,7 @@ void BbvsEngine::updateCommon() {
if (doActionCommands) {
ActionCommand *actionCommand = &_currAction->actionCommands[_currActionCommandIndex];
-
+
while (actionCommand->timeStamp == _currActionCommandTimeStamp &&
_currActionCommandIndex < (int)_currAction->actionCommands.size()) {
if (!performActionCommand(actionCommand)) {
@@ -1161,7 +1161,7 @@ void BbvsEngine::updateCommon() {
}
updateWalkObject(sceneObject);
}
-
+
if (sceneObject->walkCount > 0 && sceneObject->turnCount == 0) {
debug(5, "walk step, xIncr: %d, yIncr: %d", sceneObject->xIncr, sceneObject->yIncr);
sceneObject->x += sceneObject->xIncr;
@@ -1226,7 +1226,7 @@ void BbvsEngine::updateCommon() {
}
}
}
-
+
if (_cameraPos.x < _newCameraPos.x)
++_cameraPos.x;
if (_cameraPos.x > _newCameraPos.x)
@@ -1235,7 +1235,7 @@ void BbvsEngine::updateCommon() {
++_cameraPos.y;
if (_cameraPos.y > _newCameraPos.y)
--_cameraPos.y;
-
+
// Check if Butthead is inside a scene exit
if (_newSceneNum == 0 && !_currAction && _buttheadObject) {
int16 buttheadX = _buttheadObject->x >> 16;
@@ -1314,13 +1314,13 @@ void BbvsEngine::stopSounds() {
bool BbvsEngine::runMinigame(int minigameNum) {
debug(0, "BbvsEngine::runMinigame() minigameNum: %d", minigameNum);
-
+
bool fromMainGame = _currSceneNum != kMainMenu;
-
+
_sound->unloadSounds();
-
+
Minigame *minigame = 0;
-
+
switch (minigameNum) {
case kMinigameBbLoogie:
minigame = new MinigameBbLoogie(this);
@@ -1338,9 +1338,9 @@ bool BbvsEngine::runMinigame(int minigameNum) {
error("Incorrect minigame number %d", minigameNum);
break;
}
-
+
bool minigameResult = minigame->run(fromMainGame);
-
+
delete minigame;
// Check if the principal was hit with a megaloogie in the loogie minigame
@@ -1370,11 +1370,11 @@ void BbvsEngine::checkEasterEgg(char key) {
"SKCUS",
"NAMTAH"
};
-
+
static const int kEasterEggLengths[] = {
7, 5, 5, 6
};
-
+
if (_currSceneNum == kCredits) {
memcpy(&_easterEggInput[1], &_easterEggInput[0], 6);
_easterEggInput[0] = key;
diff --git a/engines/bbvs/bbvs.h b/engines/bbvs/bbvs.h
index 6a9a13905c..bbd8046a8b 100644
--- a/engines/bbvs/bbvs.h
+++ b/engines/bbvs/bbvs.h
@@ -149,7 +149,7 @@ struct BBPoint {
struct BBRect {
int16 x, y, width, height;
-};
+};
struct BBPolygon {
const BBPoint *points;
@@ -229,66 +229,66 @@ public:
private:
const ADGameDescription *_gameDescription;
Graphics::PixelFormat _pixelFormat;
-public:
+public:
Common::RandomSource *_random;
-
+
GameModule *_gameModule;
SpriteModule *_spriteModule;
SoundMan *_sound;
-
+
Screen *_screen;
-
+
int _bootSaveSlot;
-
+
int _mouseX, _mouseY;
uint _mouseButtons;
Common::KeyCode _keyCode;
-
+
int _mouseCursorSpriteIndex;
int _gameState;
int _gameTicks;
-
+
Common::Point _mousePos;
Common::Point _verbPos;
Common::Point _walkMousePos;
-
+
int _activeItemType;
int _activeItemIndex;
int _currTalkObjectIndex;
-
+
Common::Point _cameraPos, _newCameraPos;
-
+
int _newSceneNum, _prevSceneNum, _currSceneNum;
int _playVideoNumber;
-
+
int _dialogSlotCount;
byte _dialogItemStatus[kDialogItemStatusCount];
-
+
byte _gameVars[kGameVarsCount];
byte _sceneVisited[kSceneVisitedCount];
int _currVerbNum;
-
+
int _currInventoryItem;
byte _inventoryItemStatus[kInventoryItemStatusCount];
int _inventoryButtonIndex;
-
+
Action *_currAction;
uint32 _currActionCommandTimeStamp;
int _currActionCommandIndex;
-
+
Common::Array<Action*> _walkAreaActions;
-
+
SceneObject _sceneObjects[kSceneObjectsCount];
Common::Array<SceneObjectAction> _sceneObjectActions;
-
+
SceneObject *_buttheadObject, *_beavisObject;
int _currCameraNum;
-
+
byte _backgroundSoundsActive[kSceneSoundsCount];
Audio::SoundHandle _speechSoundHandle;
-
+
int _walkAreasCount;
WalkArea _walkAreas[80];
int _walkInfosCount;
@@ -298,40 +298,40 @@ public:
Common::Rect _tempWalkableRects1[256];
Common::Rect _tempWalkableRects2[256];
WalkInfo *_walkInfoPtrs[256];
-
+
WalkArea *_sourceWalkArea, *_destWalkArea;
Common::Point _sourceWalkAreaPt, _destWalkAreaPt, _finalWalkPt;
int _currWalkDistance;
bool _walkReachedDestArea;
-
+
bool _hasSnapshot;
byte *_snapshot;
Common::SeekableMemoryWriteStream *_snapshotStream;
-
+
char _easterEggInput[7];
-
+
void updateEvents();
int getRandom(int max);
void drawDebugInfo();
void drawScreen();
-
+
void updateGame();
bool evalCondition(Conditions &conditions);
bool evalCameraCondition(Conditions &conditions, int value);
int evalDialogCondition(Conditions &conditions);
void evalActionResults(ActionResults &results);
-
+
void updateBackgroundSounds();
void loadScene(int sceneNum);
void initScene(bool sounds);
- bool changeScene();
+ bool changeScene();
bool update(int mouseX, int mouseY, uint mouseButtons, Common::KeyCode keyCode);
-
+
void buildDrawList(DrawList &drawList);
-
+
void updateVerbs();
void updateDialog(bool clicked);
void updateInventory(bool clicked);
@@ -342,7 +342,7 @@ public:
void skipCurrAction();
void updateCommon();
-
+
void updateWalkableRects();
void startWalkObject(SceneObject *sceneObject);
void updateWalkObject(SceneObject *sceneObject);
@@ -360,20 +360,20 @@ public:
void walkFindPath(WalkArea *sourceWalkArea, int infoCount);
int calcDistance(const Common::Point &pt1, const Common::Point &pt2);
void walkFoundPath(int count);
-
+
void updateSceneObjectsTurnValue();
void updateDialogConditions();
-
- void playSpeech(int soundNum);
+
+ void playSpeech(int soundNum);
void stopSpeech();
-
+
void playSound(uint soundNum, bool loop = false);
void stopSound(uint soundNum);
void stopSounds();
-
+
bool runMinigame(int minigameNum);
void playVideo(int videoNum);
-
+
void runMainMenu();
void checkEasterEgg(char key);
@@ -409,13 +409,13 @@ public:
bool existsSavegame(int num);
static Common::String getSavegameFilename(const Common::String &target, int num);
static kReadSaveHeaderError readSaveHeader(Common::SeekableReadStream *in, bool loadThumbnail, SaveHeader &header);
-
+
void allocSnapshot();
void freeSnapshot();
void saveSnapshot();
-
+
void writeContinueSavegame();
-
+
};
} // End of namespace Bbvs
diff --git a/engines/bbvs/detection.cpp b/engines/bbvs/detection.cpp
index e7383163f5..3e247aad99 100644
--- a/engines/bbvs/detection.cpp
+++ b/engines/bbvs/detection.cpp
@@ -133,7 +133,7 @@ SaveStateDescriptor BbvsMetaEngine::querySaveMetaInfos(const char *target, int s
Bbvs::BbvsEngine::kReadSaveHeaderError error;
error = Bbvs::BbvsEngine::readSaveHeader(in, true, header);
delete in;
- if (error == Bbvs::BbvsEngine::kRSHENoError) {
+ if (error == Bbvs::BbvsEngine::kRSHENoError) {
SaveStateDescriptor desc(slot, header.description);
// Slot 0 is used for the "Continue" save
desc.setDeletableFlag(slot != 0);
diff --git a/engines/bbvs/dialogs.cpp b/engines/bbvs/dialogs.cpp
index 5247a58ec8..af95f06c1e 100644
--- a/engines/bbvs/dialogs.cpp
+++ b/engines/bbvs/dialogs.cpp
@@ -34,7 +34,7 @@ struct MenuButton {
static const MenuButton kMenuButtons[] = {
// Main menu
- {"New Game", kCmdNewGame},
+ {"New Game", kCmdNewGame},
{"Continue", kCmdContinue},
{"Options", kCmdOptions},
{"Mini Games", kCmdMiniGames},
@@ -61,7 +61,7 @@ MainMenu::~MainMenu() {
}
void MainMenu::init() {
- _buttons[0] = new GUI::ButtonWidget(this, 0, 0, 1, 1, "", 0, 0);
+ _buttons[0] = new GUI::ButtonWidget(this, 0, 0, 1, 1, "", 0, 0);
_buttons[1] = new GUI::ButtonWidget(this, 0, 0, 1, 1, "", 0, 0);
_buttons[2] = new GUI::ButtonWidget(this, 0, 0, 1, 1, "", 0, 0);
_buttons[3] = new GUI::ButtonWidget(this, 0, 0, 1, 1, "", 0, 0);
@@ -76,14 +76,14 @@ void MainMenu::reflowLayout() {
const int buttonWidth = screenW * 70 / 320;
const int buttonHeight = screenH * 14 / 240;
const int buttonPadding = screenW * 3 / 320;
-
+
_w = 2 * buttonWidth + buttonPadding;
_h = 3 * buttonHeight + 3 * buttonPadding;
_x = (screenW - _w) / 2;
_y = screenH - _h;
int x = 0, y = 0;
-
+
x = 0;
y = 0;
_buttons[0]->resize(x, y, buttonWidth, buttonHeight);
diff --git a/engines/bbvs/dialogs.h b/engines/bbvs/dialogs.h
index 2dce2a110b..7db0b182b7 100644
--- a/engines/bbvs/dialogs.h
+++ b/engines/bbvs/dialogs.h
@@ -67,13 +67,13 @@ protected:
BbvsEngine *_vm;
void init();
-
+
GUI::ButtonWidget *_buttons[5];
-
+
void gotoMenuScreen(int index);
bool canContinue();
void gotoScene(int sceneNum);
-
+
};
}
diff --git a/engines/bbvs/gamemodule.cpp b/engines/bbvs/gamemodule.cpp
index d6343084ab..80f0e81450 100644
--- a/engines/bbvs/gamemodule.cpp
+++ b/engines/bbvs/gamemodule.cpp
@@ -39,11 +39,11 @@ GameModule::~GameModule() {
void GameModule::load(const char *filename) {
debug(0, "GameModule::load()");
-
+
unload();
Common::File fd;
-
+
if (!fd.open(filename))
error("GameModule::load() Could not open %s", filename);
@@ -68,7 +68,7 @@ void GameModule::load(const char *filename) {
fd.seek(0x1A8);
_buttheadObjectIndex = fd.readUint32LE();
-
+
fd.close();
debug(0, "GameModule::load() OK");
@@ -177,7 +177,7 @@ int GameModule::getBgSpritePriority(int index) {
int GameModule::getSceneSoundsCount() {
return _sceneSoundsCount;
}
-
+
SceneSound *GameModule::getSceneSound(int index) {
assert(index < _sceneSoundsCount);
return &_sceneSounds[index];
@@ -257,7 +257,7 @@ void GameModule::unload() {
void GameModule::loadBgSprites(Common::SeekableReadStream &s) {
debug(0, "GameModule::loadBgSprites()");
-
+
s.seek(0x14);
_bgSpriteCount = s.readUint32LE();
uint32 bgSpriteIndicesOffs = s.readUint32LE();
@@ -275,7 +275,7 @@ void GameModule::loadBgSprites(Common::SeekableReadStream &s) {
void GameModule::loadCameraInits(Common::SeekableReadStream &s) {
debug(0, "GameModule::loadCameraInits()");
-
+
s.seek(0x20);
for (int i = 0; i < kCameraInitsCount; ++i) {
CameraInit &cameraInit = _cameraInits[i];
@@ -283,13 +283,13 @@ void GameModule::loadCameraInits(Common::SeekableReadStream &s) {
for (int j = 0; j < 8; ++j)
cameraInit.cameraLinks[j] = s.readByte();
for (int j = 0; j < 8; ++j)
- cameraInit.rects[j] = readRect(s);
+ cameraInit.rects[j] = readRect(s);
}
}
void GameModule::loadWalkRects(Common::SeekableReadStream &s) {
debug(0, "GameModule::loadWalkRects()");
-
+
s.seek(0x150);
_walkRectsCount = s.readUint32LE();
uint32 offs = s.readUint32LE();
@@ -301,7 +301,7 @@ void GameModule::loadWalkRects(Common::SeekableReadStream &s) {
void GameModule::loadSceneExits(Common::SeekableReadStream &s) {
debug(0, "GameModule::loadSceneExits()");
-
+
s.seek(0x158);
_sceneExitsCount = s.readUint32LE();
uint32 offs = s.readUint32LE();
@@ -329,13 +329,13 @@ void GameModule::loadBgObjects(Common::SeekableReadStream &s) {
void GameModule::loadAnimations(Common::SeekableReadStream &s) {
debug(0, "GameModule::loadAnimations()");
-
+
s.seek(0x168);
_animationsCount = s.readUint32LE();
uint32 offs = s.readUint32LE();
_animations = new Animation[_animationsCount];
for (int i = 0; i < _animationsCount; ++i) {
- Animation &anim = _animations[i];
+ Animation &anim = _animations[i];
s.seek(offs + i * 20);
anim.frameCount = s.readUint32LE();
uint32 frameSpriteIndicesOffs = s.readUint32LE();
@@ -363,7 +363,7 @@ void GameModule::loadAnimations(Common::SeekableReadStream &s) {
void GameModule::loadSceneObjectDefs(Common::SeekableReadStream &s) {
debug(0, "GameModule::loadSceneObjectDefs()");
-
+
s.seek(0x170);
_sceneObjectDefsCount = s.readUint32LE();
uint32 offs = s.readUint32LE();
@@ -379,7 +379,7 @@ void GameModule::loadSceneObjectDefs(Common::SeekableReadStream &s) {
void GameModule::loadSceneObjectInits(Common::SeekableReadStream &s) {
debug(0, "GameModule::loadSceneObjectInits()");
-
+
s.seek(0x178);
_sceneObjectInitsCount = s.readUint32LE();
uint32 offs = s.readUint32LE();
@@ -396,7 +396,7 @@ void GameModule::loadSceneObjectInits(Common::SeekableReadStream &s) {
void GameModule::loadActions(Common::SeekableReadStream &s) {
debug(0, "GameModule::loadActions()");
-
+
s.seek(0x180);
_actionsCount = s.readUint32LE();
uint32 offs = s.readUint32LE();
@@ -427,7 +427,7 @@ void GameModule::loadActions(Common::SeekableReadStream &s) {
void GameModule::loadGuiSpriteIndices(Common::SeekableReadStream &s) {
debug(0, "GameModule::loadGuiSpriteIndices()");
-
+
s.seek(0x188);
uint32 offs = s.readUint32LE();
s.seek(offs);
@@ -437,7 +437,7 @@ void GameModule::loadGuiSpriteIndices(Common::SeekableReadStream &s) {
void GameModule::loadInventoryItemSpriteIndices(Common::SeekableReadStream &s) {
debug(0, "GameModule::loadInventoryItemSpriteIndices()");
-
+
s.seek(0x18C);
uint32 offs = s.readUint32LE();
s.seek(offs);
@@ -447,7 +447,7 @@ void GameModule::loadInventoryItemSpriteIndices(Common::SeekableReadStream &s) {
void GameModule::loadInventoryItemInfos(Common::SeekableReadStream &s) {
debug(0, "GameModule::loadInventoryItemInfos()");
-
+
s.seek(0x190);
uint32 offs = s.readUint32LE();
s.seek(offs);
@@ -462,7 +462,7 @@ void GameModule::loadInventoryItemInfos(Common::SeekableReadStream &s) {
void GameModule::loadDialogItemSpriteIndices(Common::SeekableReadStream &s) {
debug(0, "GameModule::loadDialogItemSpriteIndices()");
-
+
s.seek(0x194);
uint32 offs = s.readUint32LE();
s.seek(offs);
@@ -473,7 +473,7 @@ void GameModule::loadDialogItemSpriteIndices(Common::SeekableReadStream &s) {
void GameModule::loadSceneSounds(Common::SeekableReadStream &s) {
debug(0, "GameModule::loadSceneSounds()");
-
+
s.seek(0x1A0);
_sceneSoundsCount = s.readUint32LE();
uint32 offs = s.readUint32LE();
@@ -487,7 +487,7 @@ void GameModule::loadSceneSounds(Common::SeekableReadStream &s) {
void GameModule::loadPreloadSounds(Common::SeekableReadStream &s) {
debug(0, "GameModule::loadPreloadSounds()");
-
+
s.seek(0x198);
_preloadSoundsCount = s.readUint32LE();
uint32 offs = s.readUint32LE();
diff --git a/engines/bbvs/gamemodule.h b/engines/bbvs/gamemodule.h
index 4d4f5b90a1..b31b95dcee 100644
--- a/engines/bbvs/gamemodule.h
+++ b/engines/bbvs/gamemodule.h
@@ -134,29 +134,29 @@ class GameModule {
public:
GameModule();
~GameModule();
-
+
void load(const char *filename);
-
+
int getFieldC();
int getButtheadObjectIndex();
-
+
int getGuiSpriteIndex(int index);
int getInventoryItemSpriteIndex(int index);
int getDialogItemSpriteIndex(int index);
-
+
int getActionsCount();
Action *getAction(int index);
-
+
InventoryItemInfo *getInventoryItemInfo(int index);
CameraInit *getCameraInit(int cameraNum);
-
+
int getSceneExitsCount();
SceneExit *getSceneExit(int index);
-
+
int getWalkRectsCount();
Common::Rect *getWalkRects();
-
+
int getSceneObjectDefsCount();
SceneObjectDef *getSceneObjectDef(int index);
@@ -170,44 +170,44 @@ public:
int getBgSpriteIndex(int index);
int getBgSpritePriority(int index);
- int getSceneSoundsCount();
+ int getSceneSoundsCount();
SceneSound *getSceneSound(int index);
- uint getSceneSoundIndex(uint soundNum);
-
+ uint getSceneSoundIndex(uint soundNum);
+
uint getPreloadSoundsCount();
uint getPreloadSound(uint index);
Animation *getAnimation(int index);
-
+
protected:
-
+
int _bgSpriteCount;
int *_bgSpriteIndices;
int16 *_bgSpritePriorities;
-
+
CameraInit _cameraInits[kCameraInitsCount];
-
+
int _walkRectsCount;
Common::Rect *_walkRects;
-
+
int _sceneExitsCount;
SceneExit *_sceneExits;
-
+
int _bgObjectsCount;
BgObject *_bgObjects;
-
+
int _animationsCount;
Animation *_animations;
-
+
int _sceneObjectDefsCount;
SceneObjectDef *_sceneObjectDefs;
-
+
int _sceneObjectInitsCount;
SceneObjectInit *_sceneObjectInits;
int _actionsCount;
Action *_actions;
-
+
int _sceneSoundsCount;
SceneSound *_sceneSounds;
@@ -218,16 +218,16 @@ protected:
int _inventoryItemSpriteIndices[kInventoryItemSpriteCount];
InventoryItemInfo _inventoryItemInfos[kInventoryItemCount];
int _dialogItemSpriteIndices[kDialogItemSpriteCount];
-
+
int _fieldC;
int _buttheadObjectIndex;
Common::Point readPoint(Common::SeekableReadStream &s);
Common::Rect readRect(Common::SeekableReadStream &s);
Conditions readConditions(Common::SeekableReadStream &s);
-
+
void unload();
-
+
void loadBgSprites(Common::SeekableReadStream &s);
void loadCameraInits(Common::SeekableReadStream &s);
void loadWalkRects(Common::SeekableReadStream &s);
@@ -243,7 +243,7 @@ protected:
void loadDialogItemSpriteIndices(Common::SeekableReadStream &s);
void loadSceneSounds(Common::SeekableReadStream &s);
void loadPreloadSounds(Common::SeekableReadStream &s);
-
+
};
} // End of namespace Bbvs
diff --git a/engines/bbvs/graphics.cpp b/engines/bbvs/graphics.cpp
index 810d910abf..43840607c8 100644
--- a/engines/bbvs/graphics.cpp
+++ b/engines/bbvs/graphics.cpp
@@ -104,9 +104,9 @@ void Screen::drawSprite(Sprite &sprite, int x, int y) {
}
if (destX + width >= _surface->w)
width = _surface->w - destX;
-
+
debug(0, "drawSprite() (%d, %d, %d, %d); skipX: %d; skipY: %d; %d", destX, destY, width, height, skipX, skipY, sprite.type);
-
+
if (sprite.type == 1) {
for (int yc = 0; yc < height; ++yc) {
byte *source = sprite.getRow(skipY + yc);
diff --git a/engines/bbvs/minigames/bbairguitar.cpp b/engines/bbvs/minigames/bbairguitar.cpp
index f2e42313e3..1984dbb0fd 100644
--- a/engines/bbvs/minigames/bbairguitar.cpp
+++ b/engines/bbvs/minigames/bbairguitar.cpp
@@ -198,12 +198,12 @@ void MinigameBbAirGuitar::buildDrawList1(DrawList &drawList) {
if (_trackBarX > kTrackBarMaxX)
_trackBarX = kTrackBarMaxX;
-
+
_trackBarThumbRect.top = 208;
_trackBarThumbRect.bottom = 218;
_trackBarThumbRect.left = _trackBarX;
_trackBarThumbRect.right = _trackBarX + 6;
-
+
drawList.add(_objects[5].anim->frameIndices[0], _trackBarX, 208, 100);
if (_playerMode != 0) {
@@ -228,7 +228,7 @@ void MinigameBbAirGuitar::buildDrawList1(DrawList &drawList) {
drawList.add(_objects[i].anim->frameIndices[frameIndex], kPointsTbl2[i - 47].x, kPointsTbl2[i - 47].y, 254);
}
}
-
+
if (_backgroundSpriteIndex > 0)
drawList.add(_backgroundSpriteIndex, 0, 0, 0);
@@ -394,7 +394,7 @@ void MinigameBbAirGuitar::initObjects1() {
_track[0].noteNum = -1;
stop();
changePatch(0);
-
+
}
bool MinigameBbAirGuitar::updateStatus(int mouseX, int mouseY, uint mouseButtons) {
@@ -408,7 +408,7 @@ bool MinigameBbAirGuitar::updateStatus(int mouseX, int mouseY, uint mouseButtons
}
bool MinigameBbAirGuitar::updateStatus0(int mouseX, int mouseY, uint mouseButtons) {
-
+
if (mouseButtons & kAnyButtonDown) {
stopSound(1);
_rockTunePlaying = false;
@@ -436,14 +436,14 @@ bool MinigameBbAirGuitar::updateStatus0(int mouseX, int mouseY, uint mouseButton
}
}
-
+
return true;
}
bool MinigameBbAirGuitar::updateStatus1(int mouseX, int mouseY, uint mouseButtons) {
-
+
int currTicks = _vm->_system->getMillis();
-
+
if (_playerMode == 1 && _track[_trackIndex].ticks <= currTicks - _noteStartTime) {
noteOff(_track[_trackIndex].noteNum);
if (_trackIndex < _trackCount && _track[++_trackIndex].noteNum != -1)
@@ -481,17 +481,17 @@ bool MinigameBbAirGuitar::updateStatus1(int mouseX, int mouseY, uint mouseButton
} else {
++_vuMeterRight2;
}
-
+
if (_resetAnims && _vm->_system->getMillis() - _noteStartTime >= 1000)
resetObjs();
-
+
_objects[0].x = mouseX;
_objects[0].y = mouseY;
-
+
_trackBarMouseX = CLIP(mouseX, kTrackBarMinX, kTrackBarMaxX);
-
+
bool checkClick = false;
-
+
if (mouseButtons & kAnyButtonClicked) {
checkClick = true;
} else if (!(mouseButtons & kAnyButtonDown)) {
@@ -506,14 +506,14 @@ bool MinigameBbAirGuitar::updateStatus1(int mouseX, int mouseY, uint mouseButton
}
} else if (!_movingTrackBar)
checkClick = true;
-
+
if (checkClick) {
afterButtonReleased();
_objects[0].frameIndex = 1;
-
+
if (ptInRect(&kRect2, mouseX, mouseY)) {
-
+
if (_playerMode != 1 && ptInRect(&kPianoRect, mouseX, mouseY)) {
for (int i = 0; i <= 12; ++i) {
if (ptInPoly(&kPianoKeyAreas[i], mouseX, mouseY)) {
@@ -538,7 +538,7 @@ bool MinigameBbAirGuitar::updateStatus1(int mouseX, int mouseY, uint mouseButton
break;
}
}
-
+
if (playerButtonNum >= 0) {
_currButtonNum = playerButtonNum;
_currPlayerButtonRect = &kPlayerButtonRects[playerButtonNum];
@@ -673,12 +673,12 @@ bool MinigameBbAirGuitar::updateStatus1(int mouseX, int mouseY, uint mouseButton
}
}
}
-
+
if (_buttonClickTicks + 1000 < currTicks)
_buttonClickTicks = currTicks;
-
+
int newKind = _buttonClickTicks + 500 < currTicks ? 1 : 0;
-
+
switch (_playerMode) {
case 1:
@@ -770,20 +770,20 @@ bool MinigameBbAirGuitar::run(bool fromMainGame) {
_gameResult = false;
_gameDone = false;
initObjects();
-
+
_spriteModule = new SpriteModule();
_spriteModule->load("bbairg/bbairg.000");
Palette palette = _spriteModule->getPalette();
_vm->_screen->setPalette(palette);
-
+
loadSounds();
-
+
while (!_vm->shouldQuit() &&!_gameDone) {
_vm->updateEvents();
update();
}
-
+
_vm->_sound->unloadSounds();
delete _spriteModule;
@@ -803,15 +803,15 @@ void MinigameBbAirGuitar::update() {
inputTicks = 1;
_gameTicks = _vm->_system->getMillis();
}
-
+
if (_vm->_keyCode == Common::KEYCODE_ESCAPE) {
_gameDone = true;
return;
}
-
+
if (inputTicks == 0)
return;
-
+
bool done;
do {
@@ -820,9 +820,9 @@ void MinigameBbAirGuitar::update() {
_vm->_mouseButtons &= ~kRightButtonClicked;
_vm->_keyCode = Common::KEYCODE_INVALID;
} while (--inputTicks && _gameTicks > 0 && !done);
-
+
drawSprites();
-
+
_vm->_system->delayMillis(10);
}
@@ -1001,7 +1001,7 @@ void MinigameBbAirGuitar::calcTotalTicks1() {
}
void MinigameBbAirGuitar::noteOn(int noteNum) {
-
+
if (_currNoteNum != -2) {
if (noteNum == _currNoteNum)
return;
@@ -1087,7 +1087,7 @@ void MinigameBbAirGuitar::noteOn(int noteNum) {
}
void MinigameBbAirGuitar::noteOff(int noteNum) {
-
+
if (_currNoteNum != noteNum)
return;
diff --git a/engines/bbvs/minigames/bbairguitar.h b/engines/bbvs/minigames/bbairguitar.h
index d4fd6ec30c..40b8a50a03 100644
--- a/engines/bbvs/minigames/bbairguitar.h
+++ b/engines/bbvs/minigames/bbairguitar.h
@@ -32,7 +32,7 @@ public:
MinigameBbAirGuitar(BbvsEngine *vm) : Minigame(vm) {};
bool run(bool fromMainGame);
public:
-
+
struct Obj {
int kind;
int x, y;
@@ -44,24 +44,24 @@ public:
int16 frameIndexAdd;
int16 unk2;
};
-
+
enum {
kMaxObjectsCount = 256,
kMaxTracks = 2049
};
-
+
struct PianoKeyInfo {
int x, y;
int frameIndex;
};
-
+
struct TrackEvt {
int8 noteNum;
int16 ticks;
};
-
+
Obj _objects[kMaxObjectsCount];
-
+
int _playerMode;
bool _modified;
@@ -82,24 +82,24 @@ public:
int *_currFrameIndex;
int _btn3KindToggle;
-
+
const BBPolygon *_currPianoKeyArea;
const Rect *_currPlayerButtonRect;
-
+
bool _movingTrackBar;
int _trackBarMouseX;
int _trackBarX;
Rect _trackBarThumbRect;
-
+
int _currTrackPos, _totalTrackLength;
int _ticksDelta;
-
+
int _actionStartTrackPos, _actionTrackPos;
int _actionStartTime;
int _currNoteNum;
int _currPatchNum;
-
+
const ObjAnimation *getAnimation(int animIndex);
bool ptInRect(const Rect *r, int x, int y);
bool ptInPoly(const BBPolygon *poly, int x, int y);
@@ -109,14 +109,14 @@ public:
void buildDrawList1(DrawList &drawList);
void drawSprites();
-
+
void initObjs();
Obj *getFreeObject();
-
+
void initObjects();
void initObjects0();
void initObjects1();
-
+
bool updateStatus(int mouseX, int mouseY, uint mouseButtons);
bool updateStatus0(int mouseX, int mouseY, uint mouseButtons);
bool updateStatus1(int mouseX, int mouseY, uint mouseButtons);
@@ -124,7 +124,7 @@ public:
void updateObjs();
void update();
-
+
void play();
void record();
void setPlayerMode3();
@@ -136,9 +136,9 @@ public:
void noteOn(int noteNum);
void noteOff(int noteNum);
void resetObjs();
-
+
void loadSounds();
- void playNote(int noteNum);
+ void playNote(int noteNum);
void stopNote(int noteNum);
};
diff --git a/engines/bbvs/minigames/bbant.cpp b/engines/bbvs/minigames/bbant.cpp
index 9786682ada..3678934345 100644
--- a/engines/bbvs/minigames/bbant.cpp
+++ b/engines/bbvs/minigames/bbant.cpp
@@ -94,7 +94,7 @@ void MinigameBbAnt::buildDrawList1(DrawList &drawList) {
drawNumber(drawList, _score, 68, 16);
drawList.add(getAnimation(166)->frameIndices[0], 230, 2, 2000);
drawNumber(drawList, _levelTimeLeft, 280, 16);
-
+
for (int i = 0; i < _stompCount; ++i)
drawList.add(getAnimation(130)->frameIndices[0], 20 + i * 30, 230, 2000);
@@ -116,7 +116,7 @@ void MinigameBbAnt::buildDrawList3(DrawList &drawList) {
drawNumber(drawList, _hiScore, 208, 107);
}
-void MinigameBbAnt::drawMagnifyingGlass(DrawList &drawList) {
+void MinigameBbAnt::drawMagnifyingGlass(DrawList &drawList) {
scale2x(_objects[0].x - 28, _objects[0].y - 27);
drawList.clear();
drawList.add(_objects[0].anim->frameIndices[0], _objects[0].x, _objects[0].y, _objects[0].priority);
@@ -358,7 +358,7 @@ bool MinigameBbAnt::updateStatus0(int mouseX, int mouseY, uint mouseButtons) {
_objects[0].x = 0;
if (_objects[0].y < 0)
_objects[0].y = 0;
-
+
if ((mouseButtons & kLeftButtonDown) || (mouseButtons & kRightButtonDown)) {
_gameState = 1;
initObjects();
@@ -447,7 +447,7 @@ bool MinigameBbAnt::updateStatus1(int mouseX, int mouseY, uint mouseButtons) {
int maxKindCount = 0, objKind = 0;
_stompCounter2 = _stompCounter1;
-
+
for (int i = 0; i < 4; ++i)
testTbl[i] = _vm->getRandom(_bugsChanceByKind[i] - _bugsCountByKind[i]);
@@ -471,7 +471,7 @@ bool MinigameBbAnt::updateStatus1(int mouseX, int mouseY, uint mouseButtons) {
if (_stompCounter1 > 20)
--_stompCounter1;
}
-
+
return true;
}
@@ -701,7 +701,7 @@ void MinigameBbAnt::updateBugObjAnim(int objIndex) {
void MinigameBbAnt::updateObjAnim2(int objIndex) {
Obj *obj = &_objects[objIndex];
-
+
obj->animIndexIncr += _vm->getRandom(3) - 1;
if (obj->animIndexIncr < 0)
obj->animIndexIncr = 7;
@@ -736,7 +736,7 @@ bool MinigameBbAnt::isBugOutOfScreen(int objIndex) {
void MinigameBbAnt::updateObjAnim3(int objIndex) {
Obj *obj = &_objects[objIndex];
-
+
obj->animIndexIncr += _vm->getRandom(3) - 1;
if (obj->animIndexIncr < 0)
obj->animIndexIncr = 7;
@@ -752,7 +752,7 @@ void MinigameBbAnt::updateBugObj1(int objIndex) {
Obj *obj = &_objects[objIndex];
bool flag1 = false;
bool flag2 = false;
-
+
if (--obj->ticks == 0) {
++obj->frameIndex;
if (obj->anim->frameCount == obj->frameIndex) {
@@ -911,7 +911,7 @@ void MinigameBbAnt::updateStompObj(int objIndex) {
void MinigameBbAnt::updateSmokeObj(int objIndex) {
Obj *obj = &_objects[objIndex];
-
+
obj->x += obj->xIncr;
obj->y += obj->yIncr;
@@ -1047,7 +1047,7 @@ bool MinigameBbAnt::isMagGlassAtBug(int objIndex) {
Obj *obj = &_objects[objIndex];
Obj *obj0 = &_objects[0];
bool result = false;
-
+
if (obj->kind >= 1 && obj->kind <= 5) {
const BBRect &frameRect1 = obj0->anim->frameRects[0];
const int obj1X1 = obj0->x + frameRect1.x;
@@ -1102,7 +1102,7 @@ bool MinigameBbAnt::testObj5(int objIndex) {
}
void MinigameBbAnt::updateObjs(uint mouseButtons) {
-
+
for (int i = 12; i < kMaxObjectsCount; ++i) {
Obj *obj = &_objects[i];
@@ -1162,7 +1162,7 @@ void MinigameBbAnt::updateObjs(uint mouseButtons) {
}
}
-
+
}
}
@@ -1170,9 +1170,9 @@ void MinigameBbAnt::updateObjs(uint mouseButtons) {
bool MinigameBbAnt::run(bool fromMainGame) {
memset(_objects, 0, sizeof(_objects));
-
+
_numbersAnim = getAnimation(167);
-
+
_backgroundSpriteIndex = 303;
_titleScreenSpriteIndex = 304;
@@ -1187,23 +1187,23 @@ bool MinigameBbAnt::run(bool fromMainGame) {
_gameDone = false;
initObjects();
initVars();
-
+
_spriteModule = new SpriteModule();
_spriteModule->load("bbant/bbant.000");
Palette palette = _spriteModule->getPalette();
_vm->_screen->setPalette(palette);
-
+
loadSounds();
_gameTicks = 0;
playSound(12, true);
-
+
while (!_vm->shouldQuit() &&!_gameDone) {
_vm->updateEvents();
update();
}
-
+
_vm->_sound->unloadSounds();
if (!_fromMainGame)
@@ -1243,19 +1243,19 @@ void MinigameBbAnt::update() {
_vm->_mouseButtons &= ~kRightButtonClicked;
_vm->_keyCode = Common::KEYCODE_INVALID;
} while (--inputTicks && _gameTicks > 0 && !done);
-
+
drawSprites();
-
+
_vm->_system->delayMillis(10);
}
void MinigameBbAnt::scale2x(int x, int y) {
- Graphics::Surface *surface = _vm->_screen->_surface;
-
+ Graphics::Surface *surface = _vm->_screen->_surface;
+
int srcX = x + 14, srcY = y + 14;
int srcW = kScaleDim, srcH = kScaleDim;
-
+
if (srcX < 0) {
srcW += srcX;
srcX = 0;
@@ -1265,21 +1265,21 @@ void MinigameBbAnt::scale2x(int x, int y) {
srcH += srcY;
srcY = 0;
}
-
+
if (srcX + srcW >= 320)
srcW = 320 - srcX - 1;
-
+
if (srcY + srcH >= 240)
srcH = 240 - srcY - 1;
-
+
for (int yc = 0; yc < srcH; ++yc) {
byte *src = (byte*)surface->getBasePtr(srcX, srcY + yc);
memcpy(&_scaleBuf[yc * kScaleDim], src, srcW);
}
-
+
int dstX = x, dstY = y;
int dstW = 2 * kScaleDim, dstH = 2 * kScaleDim;
-
+
if (dstX < 0) {
dstW += dstX;
dstX = 0;
@@ -1289,15 +1289,15 @@ void MinigameBbAnt::scale2x(int x, int y) {
dstH += dstY;
dstY = 0;
}
-
+
if (dstX + dstW >= 320)
dstW = 320 - dstX - 1;
-
+
if (dstY + dstH >= 240)
dstH = 240 - dstY - 1;
-
+
int w = MIN(srcW * 2, dstW), h = MIN(srcH * 2, dstH);
-
+
for (int yc = 0; yc < h; ++yc) {
byte *src = _scaleBuf + kScaleDim * (yc / 2);
byte *dst = (byte*)surface->getBasePtr(dstX, dstY + yc);
diff --git a/engines/bbvs/minigames/bbant.h b/engines/bbvs/minigames/bbant.h
index be2afe688d..88b4af9c71 100644
--- a/engines/bbvs/minigames/bbant.h
+++ b/engines/bbvs/minigames/bbant.h
@@ -32,7 +32,7 @@ public:
MinigameBbAnt(BbvsEngine *vm) : Minigame(vm) {};
bool run(bool fromMainGame);
public:
-
+
struct Obj {
int kind;
int x, y, priority;
@@ -55,21 +55,21 @@ public:
int status2;
int flag;
};
-
+
enum {
kMaxObjectsCount = 256,
kScaleDim = 28
};
-
+
struct ObjInit {
const ObjAnimation *anim1;
const ObjAnimation *anim2;
const ObjAnimation *anim3;
int x, y;
};
-
+
Obj _objects[kMaxObjectsCount];
-
+
int _score, _hiScore;
int _totalBugsCount;
@@ -96,37 +96,37 @@ public:
int _countdown6;
int _countdown5;
int _countdown7;
-
+
byte _scaleBuf[kScaleDim * kScaleDim];
const ObjAnimation *getAnimation(int animIndex);
const ObjInit *getObjInit(int index);
const ObjAnimation * const *getObjKindAnimTable(int kind);
const ObjAnimation *getObjAnim(int index);
-
+
void buildDrawList0(DrawList &drawList);
void buildDrawList1(DrawList &drawList);
void buildDrawList2(DrawList &drawList);
void buildDrawList3(DrawList &drawList);
void drawMagnifyingGlass(DrawList &drawList);
-
+
void drawSprites();
void drawSprites0();
void drawSprites1();
void drawSprites2();
void drawSprites3();
-
+
Obj *getFreeObject();
-
+
void initObjects();
void initObjects0();
void initObjects1();
-
+
void initVars();
void initVars1();
void initVars2();
void initVars3();
-
+
bool updateStatus(int mouseX, int mouseY, uint mouseButtons);
bool updateStatus0(int mouseX, int mouseY, uint mouseButtons);
bool updateStatus1(int mouseX, int mouseY, uint mouseButtons);
@@ -161,7 +161,7 @@ public:
void updateObjs(uint mouseButtons);
void update();
-
+
void scale2x(int x, int y);
void loadSounds();
diff --git a/engines/bbvs/minigames/bbloogie.cpp b/engines/bbvs/minigames/bbloogie.cpp
index 4601e9ff93..68a3147f9a 100644
--- a/engines/bbvs/minigames/bbloogie.cpp
+++ b/engines/bbvs/minigames/bbloogie.cpp
@@ -117,7 +117,7 @@ void MinigameBbLoogie::buildDrawList0(DrawList &drawList) {
}
void MinigameBbLoogie::buildDrawList1(DrawList &drawList) {
-
+
for (int i = 0; i < kMaxObjectsCount; ++i) {
Obj *obj = &_objects[i];
switch (obj->kind) {
@@ -163,7 +163,7 @@ void MinigameBbLoogie::buildDrawList1(DrawList &drawList) {
}
void MinigameBbLoogie::buildDrawList2(DrawList &drawList) {
-
+
buildDrawList1(drawList);
if (_level > 0 && (_bonusDisplayDelay1 > 0 || _bonusDisplayDelay2 > 0)) {
@@ -180,7 +180,7 @@ void MinigameBbLoogie::buildDrawList2(DrawList &drawList) {
}
void MinigameBbLoogie::buildDrawList3(DrawList &drawList) {
-
+
for (int i = 0; i < kMaxObjectsCount; ++i) {
Obj *obj = &_objects[i];
if (obj->kind == 2)
@@ -191,7 +191,7 @@ void MinigameBbLoogie::buildDrawList3(DrawList &drawList) {
if (_backgroundSpriteIndex)
drawList.add(_backgroundSpriteIndex, 0, 0, 0);
-
+
drawList.add(getAnimation(10)->frameIndices[0], 230, 2, 2000);
drawNumber(drawList, _levelTimeLeft, 280, 16);
@@ -201,7 +201,7 @@ void MinigameBbLoogie::buildDrawList3(DrawList &drawList) {
int numberX2 = drawNumber(drawList, _currScore, 68, 16);
drawList.add(getAnimation(9)->frameIndices[10], numberX2, 16, 2000);
drawNumber(drawList, _dispLevelScore, numberX2 + 10, 16);
-
+
drawList.add(getAnimation(20)->frameIndices[0], 120, 70, 2000);
drawList.add(getAnimation(13)->frameIndices[0], 95, 95, 2000);
@@ -416,7 +416,7 @@ bool MinigameBbLoogie::updateStatus(int mouseX, int mouseY, uint mouseButtons) {
}
bool MinigameBbLoogie::updateStatus0(int mouseX, int mouseY, uint mouseButtons) {
-
+
_objects[0].x = mouseX;
_objects[0].y = mouseY;
@@ -445,7 +445,7 @@ bool MinigameBbLoogie::updateStatus0(int mouseX, int mouseY, uint mouseButtons)
_objects[4].kind = 0;
_objects[2].kind = 1;
}
-
+
for (int i = 0; i < kMaxObjectsCount; ++i) {
Obj *obj = &_objects[i];
if (obj->kind == 11) {
@@ -487,12 +487,12 @@ bool MinigameBbLoogie::updateStatus0(int mouseX, int mouseY, uint mouseButtons)
initVars();
_gameTicks = 0;
}
-
+
return true;
}
bool MinigameBbLoogie::updateStatus1(int mouseX, int mouseY, uint mouseButtons) {
-
+
if (--_levelTimeDelay == 0) {
_levelTimeDelay = 58;
--_levelTimeLeft;
@@ -568,9 +568,9 @@ bool MinigameBbLoogie::updateStatus2(int mouseX, int mouseY, uint mouseButtons)
}
bool MinigameBbLoogie::updateStatus3(int mouseX, int mouseY, uint mouseButtons) {
-
+
_objects[0].x = mouseX;
-
+
for (int i = 0; i < kMaxObjectsCount; ++i) {
Obj *obj = &_objects[i];
if (obj->kind == 2) {
@@ -582,7 +582,7 @@ bool MinigameBbLoogie::updateStatus3(int mouseX, int mouseY, uint mouseButtons)
}
}
}
-
+
return true;
}
@@ -620,7 +620,7 @@ void MinigameBbLoogie::updateObjs(uint mouseButtons) {
break;
}
}
-
+
if (--_carDelay == 0) {
// Car
Obj *obj = getFreeObject();
@@ -633,7 +633,7 @@ void MinigameBbLoogie::updateObjs(uint mouseButtons) {
obj->yIncr = 0;
_carDelay = _vm->getRandom(256) + 800;
}
-
+
if (--_bikeDelay == 0) {
// Bike
Obj *obj = getFreeObject();
@@ -646,7 +646,7 @@ void MinigameBbLoogie::updateObjs(uint mouseButtons) {
obj->yIncr = 0;
_bikeDelay = _vm->getRandom(512) + 500;
}
-
+
if (--_squirrelDelay == 0) {
// Squirrel
Obj *obj = getFreeObject();
@@ -662,7 +662,7 @@ void MinigameBbLoogie::updateObjs(uint mouseButtons) {
playSound(9);
_squirrelDelay = _vm->getRandom(512) + 300;
}
-
+
if (--_paperPlaneDelay == 0) {
// Paper plane
Obj *obj = getFreeObject();
@@ -685,7 +685,7 @@ void MinigameBbLoogie::updateObjs(uint mouseButtons) {
}
_paperPlaneDelay = 400;
}
-
+
if (_principalDelay >= 0 && --_principalDelay == 0) {
// Principal
Obj *obj = getFreeObject();
@@ -703,13 +703,13 @@ void MinigameBbLoogie::updateObjs(uint mouseButtons) {
_principalFirstFrameIndex = 11;
_principalLastFrameIndex = 16;
}
-
+
}
void MinigameBbLoogie::updatePlayer(int objIndex, uint mouseButtons) {
Obj *obj = &_objects[0];
-
+
switch (obj->status) {
case 1:
@@ -817,7 +817,7 @@ void MinigameBbLoogie::updateLoogie(int objIndex) {
obj->y -= kLoogieOffY[obj->unk2 / 8];
--obj->unk2;
}
-
+
if (obj->ticks-- == 0) {
obj->ticks = getAnimation(5)->frameTicks[0];
++obj->frameIndex;
@@ -832,9 +832,9 @@ void MinigameBbLoogie::updateLoogie(int objIndex) {
void MinigameBbLoogie::updateCar(int objIndex) {
Obj *obj = &_objects[objIndex];
-
+
obj->x += obj->xIncr;
-
+
if (obj->ticks-- == 0) {
if (obj->frameIndex++ == 3 || obj->frameIndex == 6)
obj->frameIndex = 0;
@@ -867,7 +867,7 @@ void MinigameBbLoogie::updateCar(int objIndex) {
void MinigameBbLoogie::updateBike(int objIndex) {
Obj *obj = &_objects[objIndex];
-
+
obj->x += obj->xIncr;
if (obj->ticks-- == 0) {
@@ -965,7 +965,7 @@ void MinigameBbLoogie::updatePaperPlane(int objIndex) {
loogieObj = findLoogieObj(loogieObjIndex++);
}
}
-
+
}
void MinigameBbLoogie::updateIndicator(int objIndex) {
@@ -995,7 +995,7 @@ void MinigameBbLoogie::updateIndicator(int objIndex) {
obj->kind = 0;
obj->anim = getAnimation(6);
}
-
+
}
void MinigameBbLoogie::updatePrincipal(int objIndex) {
@@ -1281,22 +1281,22 @@ bool MinigameBbLoogie::run(bool fromMainGame) {
_gameDone = false;
initObjects();
initVars();
-
+
_spriteModule = new SpriteModule();
_spriteModule->load("bbloogie/bbloogie.000");
Palette palette = _spriteModule->getPalette();
_vm->_screen->setPalette(palette);
-
+
loadSounds();
playSound(32, true);
-
+
while (!_vm->shouldQuit() &&!_gameDone) {
_vm->updateEvents();
update();
}
-
+
_vm->_sound->unloadSounds();
if (!_fromMainGame)
@@ -1319,15 +1319,15 @@ void MinigameBbLoogie::update() {
inputTicks = 1;
_gameTicks = _vm->_system->getMillis();
}
-
+
if (_vm->_keyCode == Common::KEYCODE_ESCAPE) {
_gameDone = true;
return;
}
-
+
if (inputTicks == 0)
return;
-
+
bool done;
do {
@@ -1336,9 +1336,9 @@ void MinigameBbLoogie::update() {
_vm->_mouseButtons &= ~kRightButtonClicked;
_vm->_keyCode = Common::KEYCODE_INVALID;
} while (--inputTicks && _gameTicks > 0 && !done);
-
+
drawSprites();
-
+
_vm->_system->delayMillis(10);
}
diff --git a/engines/bbvs/minigames/bbloogie.h b/engines/bbvs/minigames/bbloogie.h
index 1dd4049b41..04ead51a1e 100644
--- a/engines/bbvs/minigames/bbloogie.h
+++ b/engines/bbvs/minigames/bbloogie.h
@@ -32,7 +32,7 @@ public:
MinigameBbLoogie(BbvsEngine *vm) : Minigame(vm) {};
bool run(bool fromMainGame);
public:
-
+
struct Obj {
int kind;
int x, y;
@@ -44,33 +44,33 @@ public:
int16 frameIndexAdd;
int16 unk2;
};
-
+
enum {
kMaxObjectsCount = 256
};
-
+
enum {
kGSTitleScreen = 0, // Title screen
kGSMainGame = 1, // Game when called as part of the main game
kGSStandaloneGame = 2, // Game when called as standalone game
kGSScoreCountUp = 3 // Score countup and next level text
};
-
+
Obj _objects[kMaxObjectsCount];
-
+
int _playerKind;
const ObjAnimation *_playerAnim;
const uint *_playerSounds1, *_playerSounds2;
uint _playerSounds1Count, _playerSounds2Count;
-
+
int _level, _levelTimeLeft, _levelTimeDelay;
- int _numberOfHits, _currScore, _hiScore;
+ int _numberOfHits, _currScore, _hiScore;
int _doubleScore, _megaLoogieCount;
-
+
int _dispLevelScore, _nextLevelScore;
int _timeBonusCtr, _bonusDisplayDelay1, _bonusDisplayDelay2, _bonusDisplayDelay3;
-
+
int _carDelay;
int _bikeDelay;
int _squirrelDelay;
@@ -78,37 +78,37 @@ public:
int _paperPlaneDelay;
int _principalDelay;
- int _prevPrincipalStatus;
+ int _prevPrincipalStatus;
int _principalCtr, _principalFirstFrameIndex, _principalLastFrameIndex;
bool _principalAngry;
-
+
const ObjAnimation *getAnimation(int animIndex);
-
+
void buildDrawList(DrawList &drawList);
void buildDrawList0(DrawList &drawList);
void buildDrawList1(DrawList &drawList);
void buildDrawList2(DrawList &drawList);
void buildDrawList3(DrawList &drawList);
-
+
void drawSprites();
-
+
void initObjs();
Obj *getFreeObject();
Obj *findLoogieObj(int startObjIndex);
bool isHit(Obj *obj1, Obj *obj2);
bool isCursorAtObj(int objIndex);
-
+
void initObjects();
void initObjects0();
void initObjects1();
void initObjects3();
-
+
void initVars();
void initVars0();
void initVars1();
void initVars2();
void initVars3();
-
+
bool updateStatus(int mouseX, int mouseY, uint mouseButtons);
bool updateStatus0(int mouseX, int mouseY, uint mouseButtons);
bool updateStatus1(int mouseX, int mouseY, uint mouseButtons);
@@ -129,7 +129,7 @@ public:
void incNumberOfHits();
void incScore(int incrAmount);
void playRndSound();
-
+
void update();
void loadSounds();
diff --git a/engines/bbvs/minigames/bbtennis.cpp b/engines/bbvs/minigames/bbtennis.cpp
index ddd5cfc804..7763548330 100644
--- a/engines/bbvs/minigames/bbtennis.cpp
+++ b/engines/bbvs/minigames/bbtennis.cpp
@@ -86,7 +86,7 @@ void MinigameBbTennis::buildDrawList(DrawList &drawList) {
}
void MinigameBbTennis::buildDrawList0(DrawList &drawList) {
-
+
drawList.add(_objects[0].anim->frameIndices[_objects[0].frameIndex], _objects[0].x, _objects[0].y, 2000);
for (int i = 0; i < kMaxObjectsCount; ++i) {
@@ -154,7 +154,7 @@ void MinigameBbTennis::buildDrawList1(DrawList &drawList) {
break;
}
-
+
drawList.add(index, x, y, priority);
}
@@ -174,16 +174,16 @@ void MinigameBbTennis::buildDrawList1(DrawList &drawList) {
drawList.add(getAnimation(9)->frameIndices[0], 256, 52, 500);
drawList.add(getAnimation(10)->frameIndices[0], 60, 162, 500);
drawList.add(getAnimation(21)->frameIndices[0], 36, 18, 2000);
-
+
drawNumber(drawList, _score, 70, 18);
-
+
for (int i = 0; i < _numHearts; ++i)
drawList.add(getAnimation(7)->frameIndices[0], 20 + i * 20, 236, 990);
}
void MinigameBbTennis::buildDrawList2(DrawList &drawList) {
-
+
for (int i = 0; i < kMaxObjectsCount; ++i) {
Obj *obj = &_objects[i];
if (obj->kind)
@@ -384,7 +384,7 @@ bool MinigameBbTennis::updateStatus1(int mouseX, int mouseY, uint mouseButtons)
_objects[0].x = mouseX;
_objects[0].y = mouseY;
-
+
if (_allHeartsGone) {
_gameState = 2;
initObjects();
@@ -427,13 +427,13 @@ bool MinigameBbTennis::updateStatus1(int mouseX, int mouseY, uint mouseButtons)
if (_newBallTimer > 0)
--_newBallTimer;
-
+
if (++_delayDecreaseTimer == 30) {
_delayDecreaseTimer = 0;
if (_playerDecrease < 199)
++_playerDecrease;
}
-
+
updateObjs();
if (!_playedThisIsTheCoolest && _score > 3 && _vm->getRandom(10) == 1 && !isAnySoundPlaying(kAllSounds, 11)) {
@@ -482,7 +482,7 @@ void MinigameBbTennis::updateObjs() {
break;
}
}
-
+
if (_rapidFireBallsCount == 0) {
--_squirrelDelay;
if (--_squirrelDelay == 0) {
@@ -763,7 +763,7 @@ void MinigameBbTennis::updateTennisPlayer(int objIndex) {
}
++_tennisPlayerDelay;
break;
-
+
case 2:
if (--obj->ticks == 0) {
++obj->frameIndex;
@@ -1077,7 +1077,7 @@ void MinigameBbTennis::updateNetPlayer(int objIndex) {
void MinigameBbTennis::updateEnemyTennisBall(int objIndex) {
Obj *obj = &_objects[objIndex];
-
+
if (--obj->ticks == 0) {
--obj->frameIndex;
obj->ticks = getAnimation(6)->frameTicks[obj->frameIndex];
@@ -1103,7 +1103,7 @@ void MinigameBbTennis::updateEnemyTennisBall(int objIndex) {
obj->x = (int)obj->fltX;
obj->fltY = obj->fltY - obj->fltStepY;
obj->y = (int)obj->fltY;
-
+
}
void MinigameBbTennis::makeEnemyBall(int x, int y, int frameIndex) {
@@ -1184,7 +1184,7 @@ void MinigameBbTennis::hitSomething() {
bool MinigameBbTennis::run(bool fromMainGame) {
memset(_objects, 0, sizeof(_objects));
-
+
_numbersAnim = getAnimation(20);
_backgroundSpriteIndex = 272;
@@ -1201,23 +1201,23 @@ bool MinigameBbTennis::run(bool fromMainGame) {
_gameDone = false;
initObjects();
initVars();
-
+
_spriteModule = new SpriteModule();
_spriteModule->load("bbtennis/bbtennis.000");
Palette palette = _spriteModule->getPalette();
_vm->_screen->setPalette(palette);
-
+
loadSounds();
_gameTicks = 0;
playSound(29, true);
-
+
while (!_vm->shouldQuit() &&!_gameDone) {
_vm->updateEvents();
update();
}
-
+
_vm->_sound->unloadSounds();
if (!_fromMainGame)
@@ -1240,15 +1240,15 @@ void MinigameBbTennis::update() {
inputTicks = 1;
_gameTicks = _vm->_system->getMillis();
}
-
+
if (_vm->_keyCode == Common::KEYCODE_ESCAPE) {
_gameDone = true;
return;
}
-
+
if (inputTicks == 0)
return;
-
+
bool done;
do {
@@ -1257,9 +1257,9 @@ void MinigameBbTennis::update() {
_vm->_mouseButtons &= ~kRightButtonClicked;
_vm->_keyCode = Common::KEYCODE_INVALID;
} while (--inputTicks && _gameTicks > 0 && !done);
-
+
drawSprites();
-
+
_vm->_system->delayMillis(10);
}
diff --git a/engines/bbvs/minigames/bbtennis.h b/engines/bbvs/minigames/bbtennis.h
index 690bd724a0..7eac904c4d 100644
--- a/engines/bbvs/minigames/bbtennis.h
+++ b/engines/bbvs/minigames/bbtennis.h
@@ -32,7 +32,7 @@ public:
MinigameBbTennis(BbvsEngine *vm) : Minigame(vm) {};
bool run(bool fromMainGame);
public:
-
+
struct Obj {
int kind;
int x, y;
@@ -51,20 +51,20 @@ public:
int ballStepCtr;
int netPlayDirection;
};
-
+
enum {
kMaxObjectsCount = 256
};
-
+
enum {
kGSTitleScreen = 0, // Title screen
kGSMainGame = 1, // Game when called as part of the main game
kGSStandaloneGame = 2, // Game when called as standalone game
kGSScoreCountUp = 3 // Score countup and next level text
};
-
+
Obj _objects[kMaxObjectsCount];
-
+
int _numHearts;
int _squirrelDelay;
int _tennisPlayerDelay;
@@ -85,29 +85,29 @@ public:
bool _endSoundPlaying;
const ObjAnimation *getAnimation(int animIndex);
-
+
void buildDrawList(DrawList &drawList);
void buildDrawList0(DrawList &drawList);
void buildDrawList1(DrawList &drawList);
void buildDrawList2(DrawList &drawList);
-
+
void drawSprites();
-
+
void initObjs();
Obj *getFreeObject();
Obj *findTennisBall(int startObjIndex);
bool isHit(Obj *obj1, Obj *obj2);
-
+
void initObjects();
void initObjects0();
void initObjects1();
void initObjects2();
-
+
void initVars();
void initVars0();
void initVars1();
void initVars2();
-
+
bool updateStatus(int mouseX, int mouseY, uint mouseButtons);
bool updateStatus0(int mouseX, int mouseY, uint mouseButtons);
bool updateStatus1(int mouseX, int mouseY, uint mouseButtons);
diff --git a/engines/bbvs/minigames/minigame.cpp b/engines/bbvs/minigames/minigame.cpp
index aae18072d9..58d98a9df8 100644
--- a/engines/bbvs/minigames/minigame.cpp
+++ b/engines/bbvs/minigames/minigame.cpp
@@ -44,13 +44,13 @@ Minigame::~Minigame() {
int Minigame::drawNumber(DrawList &drawList, int number, int x, int y) {
int digits = 1, rightX = x;
-
+
for (int mag = 10; number / mag != 0; mag *= 10)
++digits;
-
+
rightX = x + digits * 10;
x = rightX;
-
+
while (digits--) {
const int n = number % 10;
x -= 10;
diff --git a/engines/bbvs/minigames/minigame.h b/engines/bbvs/minigames/minigame.h
index 675dec360d..1c24110519 100644
--- a/engines/bbvs/minigames/minigame.h
+++ b/engines/bbvs/minigames/minigame.h
@@ -51,30 +51,30 @@ public:
virtual ~Minigame();
virtual bool run(bool fromMainGame) = 0;
protected:
- BbvsEngine *_vm;
+ BbvsEngine *_vm;
SpriteModule *_spriteModule;
-
+
int _gameState;
int _gameTicks;
bool _gameResult;
bool _gameDone;
bool _fromMainGame;
int _hiScoreTable[kMinigameCount];
-
+
int _backgroundSpriteIndex, _titleScreenSpriteIndex;
-
+
const ObjAnimation *_numbersAnim;
-
+
int drawNumber(DrawList &drawList, int number, int x, int y);
void playSound(uint index, bool loop = false);
void stopSound(uint index);
bool isSoundPlaying(uint index);
bool isAnySoundPlaying(const uint *indices, uint count);
-
+
void saveHiscore(int minigameNum, int score);
int loadHiscore(int minigameNum);
-
+
};
} // End of namespace Bbvs
diff --git a/engines/bbvs/saveload.cpp b/engines/bbvs/saveload.cpp
index ff53cc457b..e7725713fd 100644
--- a/engines/bbvs/saveload.cpp
+++ b/engines/bbvs/saveload.cpp
@@ -73,7 +73,7 @@ void BbvsEngine::savegame(const char *filename, const char *description) {
byte descriptionLen = strlen(description);
out->writeByte(descriptionLen);
out->write(description, descriptionLen);
-
+
Graphics::saveThumbnail(*out);
// Not used yet, reserved for future usage
@@ -86,7 +86,7 @@ void BbvsEngine::savegame(const char *filename, const char *description) {
out->writeUint32LE(saveTime);
out->writeUint32LE(playTime);
// Header end
-
+
out->write(_snapshot, _snapshotStream->pos());
out->finalize();
@@ -103,15 +103,15 @@ void BbvsEngine::loadgame(const char *filename) {
SaveHeader header;
kReadSaveHeaderError errorCode = readSaveHeader(in, false, header);
-
+
if (errorCode != kRSHENoError) {
warning("Error loading savegame '%s'", filename);
delete in;
return;
}
-
+
g_engine->setTotalPlayTime(header.playTime * 1000);
-
+
memset(_sceneObjects, 0, sizeof(_sceneObjects));
for (int i = 0; i < kSceneObjectsCount; ++i) {
_sceneObjects[i].walkDestPt.x = -1;
@@ -120,7 +120,7 @@ void BbvsEngine::loadgame(const char *filename) {
_currSceneNum = 0;
_newSceneNum = in->readUint32LE();
-
+
initScene(false);
_prevSceneNum = in->readUint32LE();
@@ -157,16 +157,16 @@ void BbvsEngine::loadgame(const char *filename) {
obj->frameIndex = in->readUint32LE();
obj->frameTicks = in->readUint32LE();
obj->walkCount = in->readUint32LE();
- obj->xIncr = in->readUint32LE();
+ obj->xIncr = in->readUint32LE();
obj->yIncr = in->readUint32LE();
- obj->turnValue = in->readUint32LE();
- obj->turnCount = in->readUint32LE();
+ obj->turnValue = in->readUint32LE();
+ obj->turnCount = in->readUint32LE();
obj->turnTicks = in->readUint32LE();
obj->walkDestPt.x = in->readUint16LE();
obj->walkDestPt.y = in->readUint16LE();
obj->anim = obj->animIndex > 0 ? _gameModule->getAnimation(obj->animIndex) : 0;
}
-
+
updateWalkableRects();
// Restart scene background sounds
@@ -259,10 +259,10 @@ void BbvsEngine::saveSnapshot() {
_snapshotStream->writeUint32LE(obj->frameIndex);
_snapshotStream->writeUint32LE(obj->frameTicks);
_snapshotStream->writeUint32LE(obj->walkCount);
- _snapshotStream->writeUint32LE(obj->xIncr);
+ _snapshotStream->writeUint32LE(obj->xIncr);
_snapshotStream->writeUint32LE(obj->yIncr);
- _snapshotStream->writeUint32LE(obj->turnValue);
- _snapshotStream->writeUint32LE(obj->turnCount);
+ _snapshotStream->writeUint32LE(obj->turnValue);
+ _snapshotStream->writeUint32LE(obj->turnCount);
_snapshotStream->writeUint32LE(obj->turnTicks);
_snapshotStream->writeUint16LE(obj->walkDestPt.x);
_snapshotStream->writeUint16LE(obj->walkDestPt.y);
diff --git a/engines/bbvs/scene.cpp b/engines/bbvs/scene.cpp
index 0d86eb4dbc..a89c88fd82 100644
--- a/engines/bbvs/scene.cpp
+++ b/engines/bbvs/scene.cpp
@@ -34,7 +34,7 @@ static const int kAfterVideoSceneNum[] = {
void BbvsEngine::loadScene(int sceneNum) {
debug(0, "BbvsEngine::loadScene() sceneNum: %d", sceneNum);
-
+
Common::String sprFilename = Common::String::format("vnm/vspr%04d.vnm", sceneNum);
Common::String gamFilename = Common::String::format("vnm/game%04d.vnm", sceneNum);
@@ -42,7 +42,7 @@ void BbvsEngine::loadScene(int sceneNum) {
_spriteModule->load(sprFilename.c_str());
_gameModule->load(gamFilename.c_str());
-
+
Palette palette = _spriteModule->getPalette();
_screen->setPalette(palette);
@@ -106,10 +106,10 @@ void BbvsEngine::initScene(bool sounds) {
loadScene(_newSceneNum);
_currSceneNum = _newSceneNum;
_newSceneNum = 0;
-
+
for (int i = 0; i < _gameModule->getSceneObjectDefsCount(); ++i)
_sceneObjects[i].sceneObjectDef = _gameModule->getSceneObjectDef(i);
-
+
for (int i = 0; i < _gameModule->getSceneObjectInitsCount(); ++i) {
SceneObjectInit *soInit = _gameModule->getSceneObjectInit(i);
if (evalCondition(soInit->conditions)) {
@@ -149,10 +149,10 @@ void BbvsEngine::initScene(bool sounds) {
}
}
}
-
+
_cameraPos = _gameModule->getCameraInit(_currCameraNum)->cameraPos;
_newCameraPos = _cameraPos;
-
+
_walkAreaActions.clear();
for (int i = 0; i < _gameModule->getActionsCount(); ++i) {
Action *action = _gameModule->getAction(i);
@@ -165,7 +165,7 @@ void BbvsEngine::initScene(bool sounds) {
_activeItemIndex = 0;
_activeItemType = kITEmpty;
-
+
for (int i = 0; i < _gameModule->getActionsCount(); ++i) {
Action *action = _gameModule->getAction(i);
if (evalCondition(action->conditions)) {
@@ -183,7 +183,7 @@ void BbvsEngine::initScene(bool sounds) {
break;
}
}
-
+
if (sounds)
updateBackgroundSounds();
@@ -192,7 +192,7 @@ void BbvsEngine::initScene(bool sounds) {
bool BbvsEngine::changeScene() {
writeContinueSavegame();
-
+
if (_newSceneNum >= 27 && _newSceneNum <= 30) {
// Run minigames
stopSpeech();
@@ -221,7 +221,7 @@ bool BbvsEngine::changeScene() {
}
return true;
-
+
}
} // End of namespace Bbvs
diff --git a/engines/bbvs/spritemodule.cpp b/engines/bbvs/spritemodule.cpp
index 8eae7f9a6a..f8b0d9afd5 100644
--- a/engines/bbvs/spritemodule.cpp
+++ b/engines/bbvs/spritemodule.cpp
@@ -41,15 +41,15 @@ SpriteModule::~SpriteModule() {
void SpriteModule::load(const char *filename) {
unload();
-
+
Common::File fd;
if (!fd.open(filename))
error("SpriteModule::load() Could not open %s", filename);
-
+
fd.readUint32LE(); // Skip magic
fd.readUint32LE(); // Skip unused
fd.readUint32LE(); // Skip filesize
-
+
_paletteOffs = fd.readUint32LE();
fd.readUint32LE(); // Skip unused flagsTbl1Ofs
fd.readUint32LE(); // Skip unused flagsTbl2Ofs
@@ -57,18 +57,18 @@ void SpriteModule::load(const char *filename) {
_paletteStart = fd.readUint32LE();
_paletteCount = fd.readUint32LE();
_spritesCount = fd.readUint32LE();
-
+
debug(0, "_paletteOffs: %08X", _paletteOffs);
debug(0, "_spriteTblOffs: %08X", _spriteTblOffs);
debug(0, "_paletteStart: %d", _paletteStart);
debug(0, "_paletteCount: %d", _paletteCount);
debug(0, "_spritesCount: %d", _spritesCount);
-
+
_spriteDataSize = fd.size();
_spriteData = new byte[_spriteDataSize];
fd.seek(0);
fd.read(_spriteData, _spriteDataSize);
-
+
// Convert palette
byte *palette = _spriteData + _paletteOffs;
for (int i = 0; i < _paletteCount; ++i) {
diff --git a/engines/bbvs/videoplayer.cpp b/engines/bbvs/videoplayer.cpp
index fda9372ade..9ea73ad10b 100644
--- a/engines/bbvs/videoplayer.cpp
+++ b/engines/bbvs/videoplayer.cpp
@@ -42,7 +42,7 @@ void BbvsEngine::playVideo(int videoNum) {
warning("Couldn't switch to a RGB color video mode to play a video.");
return;
}
-
+
Video::VideoDecoder *videoDecoder = new Video::AVIDecoder();
if (!videoDecoder->loadFile(videoFilename)) {
delete videoDecoder;
@@ -74,7 +74,7 @@ void BbvsEngine::playVideo(int videoNum) {
}
delete videoDecoder;
-
+
initGraphics(320, 240, false);
}
diff --git a/engines/bbvs/walk.cpp b/engines/bbvs/walk.cpp
index 077110b867..5ef14101a0 100644
--- a/engines/bbvs/walk.cpp
+++ b/engines/bbvs/walk.cpp
@@ -46,7 +46,7 @@ static const int8 kWalkAnimTbl[32] = {
void BbvsEngine::startWalkObject(SceneObject *sceneObject) {
if (_buttheadObject != sceneObject && _beavisObject != sceneObject)
return;
-
+
initWalkAreas(sceneObject);
_sourceWalkAreaPt.x = sceneObject->x >> 16;
_sourceWalkAreaPt.y = sceneObject->y >> 16;
@@ -60,7 +60,7 @@ void BbvsEngine::startWalkObject(SceneObject *sceneObject) {
_destWalkArea = getWalkAreaAtPos(_destWalkAreaPt);
if (!_destWalkArea)
return;
-
+
if (_sourceWalkArea != _destWalkArea) {
_currWalkDistance = kMaxDistance;
walkFindPath(_sourceWalkArea, 0);
@@ -68,12 +68,12 @@ void BbvsEngine::startWalkObject(SceneObject *sceneObject) {
}
walkObject(sceneObject, _destWalkAreaPt, sceneObject->sceneObjectDef->walkSpeed);
-
+
}
void BbvsEngine::updateWalkObject(SceneObject *sceneObject) {
int animIndex;
-
+
if (sceneObject->walkCount > 0 && (sceneObject->xIncr != 0 || sceneObject->yIncr != 0)) {
if (ABS(sceneObject->xIncr) <= ABS(sceneObject->yIncr))
sceneObject->turnValue = sceneObject->yIncr >= 0 ? 0 : 4;
@@ -89,7 +89,7 @@ void BbvsEngine::updateWalkObject(SceneObject *sceneObject) {
Animation *anim = 0;
if (animIndex > 0)
anim = _gameModule->getAnimation(animIndex);
-
+
if (sceneObject->anim != anim) {
if (anim) {
sceneObject->anim = anim;
@@ -305,12 +305,12 @@ bool BbvsEngine::canButtheadWalkToDest(const Common::Point &destPt) {
}
void BbvsEngine::canWalkToDest(WalkArea *walkArea, int infoCount) {
-
+
if (_destWalkArea == walkArea) {
_walkReachedDestArea = true;
return;
}
-
+
if (_gameModule->getFieldC() <= 320 || infoCount <= 20) {
walkArea->checked = true;
for (int linkIndex = 0; linkIndex < walkArea->linksCount; ++linkIndex) {
@@ -364,10 +364,10 @@ int BbvsEngine::calcDistance(const Common::Point &pt1, const Common::Point &pt2)
void BbvsEngine::walkFoundPath(int count) {
debug(5, "BbvsEngine::walkFoundPath(%d)", count);
-
+
Common::Point midPt = _sourceWalkAreaPt;
int totalMidPtDistance = 0;
-
+
if (count > 0) {
Common::Point lastMidPt;
int halfCount = (count + 1) >> 1;
@@ -384,13 +384,13 @@ void BbvsEngine::walkFoundPath(int count) {
if (distance >= _currWalkDistance)
return;
-
+
debug(5, "BbvsEngine::walkFoundPath() distance smaller");
_currWalkDistance = distance;
Common::Point destPt = _destWalkAreaPt, newDestPt;
-
+
while (1) {
int index = 0;
@@ -408,7 +408,7 @@ void BbvsEngine::walkFoundPath(int count) {
WalkInfo *walkInfo = _walkInfoPtrs[--count];
destPt.x = walkInfo->x;
destPt.y = walkInfo->y;
-
+
if (walkInfo->direction) {
newDestPt.x = walkInfo->x;
newDestPt.y = walkInfo->y + walkInfo->delta - 1;
diff --git a/engines/cge/POTFILES b/engines/cge/POTFILES
new file mode 100644
index 0000000000..55430683c3
--- /dev/null
+++ b/engines/cge/POTFILES
@@ -0,0 +1,2 @@
+engines/cge/detection.cpp
+
diff --git a/engines/cge/detection.cpp b/engines/cge/detection.cpp
index 45231fecf2..da5eb2b1f2 100644
--- a/engines/cge/detection.cpp
+++ b/engines/cge/detection.cpp
@@ -28,24 +28,17 @@
#include "base/plugins.h"
#include "graphics/thumbnail.h"
#include "cge/cge.h"
+#include "cge/fileio.h"
namespace CGE {
-struct CgeGameDescription {
- ADGameDescription desc;
-};
-
#define GAMEOPTION_COLOR_BLIND_DEFAULT_OFF GUIO_GAMEOPTIONS1
-} // End of namespace CGE
-
static const PlainGameDescriptor CGEGames[] = {
{ "soltys", "Soltys" },
{ 0, 0 }
};
-namespace CGE {
-
static const ADGameDescription gameDescriptions[] = {
{
"soltys", "Freeware",
@@ -104,7 +97,6 @@ static const ADGameDescription gameDescriptions[] = {
AD_TABLE_END_MARKER
};
-} // End of namespace CGE
static const ADExtraGuiOptionsMap optionsList[] = {
{
@@ -122,7 +114,7 @@ static const ADExtraGuiOptionsMap optionsList[] = {
class CGEMetaEngine : public AdvancedMetaEngine {
public:
- CGEMetaEngine() : AdvancedMetaEngine(CGE::gameDescriptions, sizeof(CGE::CgeGameDescription), CGEGames, optionsList) {
+ CGEMetaEngine() : AdvancedMetaEngine(CGE::gameDescriptions, sizeof(ADGameDescription), CGEGames, optionsList) {
_singleid = "soltys";
}
@@ -134,6 +126,7 @@ public:
return "Soltys (c) 1994-1996 L.K. Avalon";
}
+ virtual const ADGameDescription *fallbackDetect(const FileMap &allFiles, const Common::FSList &fslist) const;
virtual bool hasFeature(MetaEngineFeature f) const;
virtual bool createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const;
virtual int getMaximumSaveSlot() const;
@@ -142,6 +135,44 @@ public:
virtual void removeSaveState(const char *target, int slot) const;
};
+static const ADFileBasedFallback fileBasedFallback[] = {
+ { &gameDescriptions[0], { "vol.cat", "vol.dat", 0 } },
+ { 0, { 0 } }
+};
+
+static ADGameDescription s_fallbackDesc = {
+ "Soltys",
+ "Unknown version",
+ AD_ENTRY1(0, 0), // This should always be AD_ENTRY1(0, 0) in the fallback descriptor
+ Common::UNK_LANG,
+ Common::kPlatformDOS,
+ ADGF_NO_FLAGS,
+ GUIO1(GAMEOPTION_COLOR_BLIND_DEFAULT_OFF)
+};
+
+const ADGameDescription *CGEMetaEngine::fallbackDetect(const FileMap &allFiles, const Common::FSList &fslist) const {
+ ADFilePropertiesMap filesProps;
+
+ const ADGameDescription *game;
+ game = detectGameFilebased(allFiles, fslist, CGE::fileBasedFallback, &filesProps);
+
+ if (!game)
+ return nullptr;
+
+ SearchMan.clear();
+ SearchMan.addDirectory(fslist.begin()->getParent().getPath(), fslist.begin()->getParent());
+ ResourceManager *resman;
+ resman = new ResourceManager();
+ bool result = resman->exist("CGE.SAY");
+ delete resman;
+
+ if (!result)
+ return nullptr;
+
+ reportUnknown(fslist.begin()->getParent(), filesProps);
+ return &s_fallbackDesc;
+}
+
bool CGEMetaEngine::hasFeature(MetaEngineFeature f) const {
return
(f == kSupportsListSaves) ||
@@ -251,9 +282,10 @@ bool CGEMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGameD
}
return desc != 0;
}
+} // End of namespace CGE
#if PLUGIN_ENABLED_DYNAMIC(CGE)
- REGISTER_PLUGIN_DYNAMIC(CGE, PLUGIN_TYPE_ENGINE, CGEMetaEngine);
+REGISTER_PLUGIN_DYNAMIC(CGE, PLUGIN_TYPE_ENGINE, CGE::CGEMetaEngine);
#else
- REGISTER_PLUGIN_STATIC(CGE, PLUGIN_TYPE_ENGINE, CGEMetaEngine);
+REGISTER_PLUGIN_STATIC(CGE, PLUGIN_TYPE_ENGINE, CGE::CGEMetaEngine);
#endif
diff --git a/engines/cge/fileio.cpp b/engines/cge/fileio.cpp
index d910e275eb..df5c31d367 100644
--- a/engines/cge/fileio.cpp
+++ b/engines/cge/fileio.cpp
@@ -77,7 +77,7 @@ ResourceManager::ResourceManager() {
_buff[i]._page = new BtPage;
_buff[i]._pageNo = kBtValNone;
_buff[i]._index = -1;
- assert(_buff[i]._page != NULL);
+ assert(_buff[i]._page != nullptr);
}
}
@@ -118,10 +118,16 @@ uint16 ResourceManager::read(byte *buf, uint16 length) {
BtPage *ResourceManager::getPage(int level, uint16 pageId) {
debugC(1, kCGEDebugFile, "ResourceManager::getPage(%d, %d)", level, pageId);
+ if (level >= kBtLevel)
+ return nullptr;
+
if (_buff[level]._pageNo != pageId) {
int32 pos = pageId * kBtSize;
_buff[level]._pageNo = pageId;
- assert(_catFile->size() > pos);
+
+ if (_catFile->size() <= pos)
+ return nullptr;
+
// In the original, there was a check verifying if the
// purpose was to write a new file. This should only be
// to create a new file, thus it was removed.
@@ -146,11 +152,13 @@ BtKeypack *ResourceManager::find(const char *key) {
uint16 nxt = kBtValRoot;
while (!_catFile->eos()) {
BtPage *pg = getPage(lev, nxt);
+ if (!pg)
+ return nullptr;
+
// search
if (pg->_header._down != kBtValNone) {
int i;
for (i = 0; i < pg->_header._count; i++) {
- // Does this work, or does it have to compare the entire buffer?
if (scumm_strnicmp((const char *)key, (const char*)pg->_inner[i]._key, kBtKeySize) < 0)
break;
}
@@ -167,13 +175,17 @@ BtKeypack *ResourceManager::find(const char *key) {
return &pg->_leaf[i];
}
}
- return NULL;
+ return nullptr;
}
bool ResourceManager::exist(const char *name) {
debugC(1, kCGEDebugFile, "ResourceManager::exist(%s)", name);
- return scumm_stricmp(find(name)->_key, name) == 0;
+ BtKeypack* result = find(name);
+ if (!result)
+ return false;
+
+ return scumm_stricmp(result->_key, name) == 0;
}
uint16 ResourceManager::catRead(byte *buf, uint16 length) {
diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp
index babcb7e667..4d3a103663 100644
--- a/engines/cge/vga13h.cpp
+++ b/engines/cge/vga13h.cpp
@@ -640,7 +640,7 @@ Vga::Vga(CGEEngine *vm) : _frmCnt(0), _msg(NULL), _name(NULL), _setPal(false), _
if (ConfMan.getBool("enable_color_blind"))
_mono = 1;
-
+
_oldColors = (Dac *)malloc(sizeof(Dac) * kPalCount);
_newColors = (Dac *)malloc(sizeof(Dac) * kPalCount);
diff --git a/engines/cge2/POTFILES b/engines/cge2/POTFILES
new file mode 100644
index 0000000000..1e904763ec
--- /dev/null
+++ b/engines/cge2/POTFILES
@@ -0,0 +1 @@
+engines/cge2/detection.cpp
diff --git a/engines/cge2/cge2.cpp b/engines/cge2/cge2.cpp
index 852b7afb22..ee62e20ac6 100644
--- a/engines/cge2/cge2.cpp
+++ b/engines/cge2/cge2.cpp
@@ -76,6 +76,7 @@ CGE2Engine::CGE2Engine(OSystem *syst, const ADGameDescription *gameDescription)
_vol[i] = nullptr;
_eventManager = nullptr;
_map = nullptr;
+ _console = nullptr;
_quitFlag = false;
_bitmapPalette = nullptr;
_gamePhase = kPhaseIntro;
@@ -96,7 +97,7 @@ CGE2Engine::CGE2Engine(OSystem *syst, const ADGameDescription *gameDescription)
_midiNotify = nullptr;
_spriteNotify = nullptr;
_startGameSlot = 0;
-
+
_sayCap = ConfMan.getBool("subtitles");
_sayVox = !ConfMan.getBool("speech_mute");
_muteAll = ConfMan.getBool("mute");
diff --git a/engines/cge2/cge2.h b/engines/cge2/cge2.h
index 1f1cb17b48..fbe4cb3abc 100644
--- a/engines/cge2/cge2.h
+++ b/engines/cge2/cge2.h
@@ -93,10 +93,7 @@ struct SavegameHeader;
#define kPowerRef 123
#define kDvolRef 124
#define kMvolRef 125
-#define kRef 126
#define kBusyRef 127
-#define kCapRef 128
-#define kVoxRef 129
#define kOffUseCount 130
#define kOffUseText 131
@@ -272,7 +269,7 @@ public:
void snRoom(Sprite *spr, bool on);
void snGhost(Bitmap *bmp);
void snSay(Sprite *spr, int val);
-
+
void hide1(Sprite *spr);
Sprite *expandSprite(Sprite *spr);
void qGame();
diff --git a/engines/cge2/cge2_main.cpp b/engines/cge2/cge2_main.cpp
index 1057b00089..4e3d229618 100644
--- a/engines/cge2/cge2_main.cpp
+++ b/engines/cge2/cge2_main.cpp
@@ -58,7 +58,7 @@ void System::touch(uint16 mask, V2D pos, Common::KeyCode keyCode) {
if (_vm->_gamePhase != kPhaseInGame)
return;
_vm->_infoLine->setText(nullptr);
-
+
if (mask & kMouseLeftUp) {
if (pos.y >= 0) { // world
if (!_vm->_talk && pos.y < _vm->_mouseTop)
@@ -184,7 +184,7 @@ Sprite *CGE2Engine::loadSprite(const char *fname, int ref, int scene, V3D &pos)
if (line.empty())
continue;
Common::strlcpy(tmpStr, line.c_str(), sizeof(tmpStr));
-
+
char *p = token(tmpStr);
if (*p == '@') {
if (label != kNoByte)
@@ -327,7 +327,7 @@ void CGE2Engine::loadScript(const char *fname, bool onlyToolbar) {
lcnt++;
Common::strlcpy(tmpStr, line.c_str(), sizeof(tmpStr));
-
+
ok = false; // not OK if break
V3D P;
@@ -419,7 +419,7 @@ void CGE2Engine::sceneUp(int cav) {
_map->load(_now);
_spare->takeScene(_now);
openPocket();
-
+
for (int i = 0; i < 2; i++) {
Hero *h = _heroTab[i]->_ptr;
if (h && h->_scene == _now) {
@@ -432,7 +432,7 @@ void CGE2Engine::sceneUp(int cav) {
h->setContact();
}
}
-
+
_sound->stop();
_fx->clear();
@@ -596,7 +596,7 @@ void CGE2Engine::tick() {
for (Sprite *spr = _vga->_showQ->first(); spr; spr = spr->_next) {
if (spr->_time && (--spr->_time == 0))
spr->tick();
-
+
if (_waitRef && (_waitRef == spr->_ref) && spr->seqTest(_waitSeq))
_waitRef = 0;
}
@@ -658,10 +658,10 @@ void CGE2Engine::loadUser() {
void CGE2Engine::loadHeroes() { // Original name: loadGame()
// load sprites & pocket
-
+
Sprite *s;
Hero *h = nullptr;
-
+
// initialize Andzia/Anna
s = _spare->take(142);
if (s) {
@@ -698,7 +698,7 @@ void CGE2Engine::loadPos() {
if (_resman->exist("CGE.HXY")) {
for (int cav = 0; cav < kSceneMax; cav++)
_heroTab[1]->_posTab[cav] = new V2D(this, 180, 10);
-
+
EncryptedStream file(this, "CGE.HXY");
for (int cav = 0; cav < kSceneMax; cav++) {
@@ -722,10 +722,9 @@ void CGE2Engine::loadTab() {
if (_resman->exist(kTabName)) {
EncryptedStream f(this, kTabName);
- uint32 v;
for (int i = 0; i < kSceneMax; i++) {
- v = f.readUint32LE();
+ uint32 v = f.readUint32LE();
_eyeTab[i]->_x = FXP(v >> 8, static_cast<int>((int8)(v & 0xff)));
v = f.readUint32LE();
@@ -753,7 +752,7 @@ void CGE2Engine::cge2_main() {
runGame();
_gamePhase = kPhaseOver;
}
-
+
_vga->sunset();
} else
_vga->sunset();
@@ -768,7 +767,7 @@ char *CGE2Engine::mergeExt(char *buf, const char *name, const char *ext) {
return buf;
}
-void CGE2Engine::setEye(const V3D &e) {
+void CGE2Engine::setEye(const V3D &e) {
*_eye = e;
}
@@ -932,7 +931,7 @@ void CGE2Engine::offUse() {
// This fixes the issue of empty speech bubbles in the original.
// Now we only let this cycle pass if it randoms a valid value for getText().
int txt = 0;
- do {
+ do {
txt = kOffUseText + _sex * offUseCount + newRandom(offUseCount);
} while (_text->getText(txt) == nullptr);
diff --git a/engines/cge2/cge2_main.h b/engines/cge2/cge2_main.h
index 88cca1cc1e..4d92c33e50 100644
--- a/engines/cge2/cge2_main.h
+++ b/engines/cge2/cge2_main.h
@@ -40,7 +40,7 @@ public:
Sprite *_blinkSprite;
System(CGE2Engine *vm);
-
+
virtual void touch(uint16 mask, V2D pos, Common::KeyCode keyCode);
void tick();
private:
diff --git a/engines/cge2/configure.engine b/engines/cge2/configure.engine
index 6ccbfee088..79d091fec5 100644
--- a/engines/cge2/configure.engine
+++ b/engines/cge2/configure.engine
@@ -1,3 +1,3 @@
# This file is included from the main "configure" script
# add_engine [name] [desc] [build-by-default] [subengines] [base games] [deps]
-add_engine cge2 "CGE2" no
+add_engine cge2 "CGE2" yes
diff --git a/engines/cge2/detection.cpp b/engines/cge2/detection.cpp
index fa02d412f1..4acdea3fde 100644
--- a/engines/cge2/detection.cpp
+++ b/engines/cge2/detection.cpp
@@ -26,6 +26,7 @@
*/
#include "cge2/cge2.h"
+#include "cge2/fileio.h"
#include "engines/advancedDetector.h"
#include "common/translation.h"
#include "graphics/surface.h"
@@ -70,6 +71,26 @@ static const ADGameDescription gameDescriptions[] = {
Common::EN_ANY, Common::kPlatformDOS, ADGF_NO_FLAGS, GUIO1(GAMEOPTION_COLOR_BLIND_DEFAULT_OFF)
},
+ {
+ "sfinx", "Freeware v1.0",
+ {
+ {"vol.cat", 0, "f158e469dccbebc5a632eb848df89779", 129024},
+ {"vol.dat", 0, "d40a6b4ae173d6930be54ba56bee15d5", 34183443},
+ AD_LISTEND
+ },
+ Common::EN_ANY, Common::kPlatformDOS, ADGF_NO_FLAGS, GUIO1(GAMEOPTION_COLOR_BLIND_DEFAULT_OFF)
+ },
+
+ {
+ "sfinx", "Freeware v1.1",
+ {
+ {"vol.cat", 0, "f158e469dccbebc5a632eb848df89779", 129024},
+ {"vol.dat", 0, "d40a6b4ae173d6930be54ba56bee15d5", 34182773},
+ AD_LISTEND
+ },
+ Common::EN_ANY, Common::kPlatformDOS, ADGF_NO_FLAGS, GUIO1(GAMEOPTION_COLOR_BLIND_DEFAULT_OFF)
+ },
+
AD_TABLE_END_MARKER
};
@@ -101,6 +122,7 @@ public:
return "Sfinx (c) 1994-1997 Janus B. Wisniewski and L.K. Avalon";
}
+ virtual const ADGameDescription *fallbackDetect(const FileMap &allFiles, const Common::FSList &fslist) const;
virtual bool createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const;
virtual bool hasFeature(MetaEngineFeature f) const;
virtual int getMaximumSaveSlot() const;
@@ -109,6 +131,46 @@ public:
virtual void removeSaveState(const char *target, int slot) const;
};
+static const ADFileBasedFallback fileBasedFallback[] = {
+ { &gameDescriptions[0], { "vol.cat", "vol.dat", 0 } },
+ { 0, { 0 } }
+};
+
+static ADGameDescription s_fallbackDesc = {
+ "Sfinx",
+ "Unknown version",
+ AD_ENTRY1(0, 0), // This should always be AD_ENTRY1(0, 0) in the fallback descriptor
+ Common::UNK_LANG,
+ Common::kPlatformDOS,
+ ADGF_NO_FLAGS,
+ GUIO1(GAMEOPTION_COLOR_BLIND_DEFAULT_OFF)
+};
+
+// This fallback detection looks identical to the one used for CGE. In fact, the difference resides
+// in the ResourceManager which handles a different archive format. The rest of the detection is identical.
+const ADGameDescription *CGE2MetaEngine::fallbackDetect(const FileMap &allFiles, const Common::FSList &fslist) const {
+ ADFilePropertiesMap filesProps;
+
+ const ADGameDescription *game;
+ game = detectGameFilebased(allFiles, fslist, CGE2::fileBasedFallback, &filesProps);
+
+ if (!game)
+ return 0;
+
+ SearchMan.clear();
+ SearchMan.addDirectory(fslist.begin()->getParent().getPath(), fslist.begin()->getParent());
+ ResourceManager *resman;
+ resman = new ResourceManager();
+ bool result = resman->exist("CGE.SAY");
+ delete resman;
+
+ if (!result)
+ return 0;
+
+ reportUnknown(fslist.begin()->getParent(), filesProps);
+ return &s_fallbackDesc;
+}
+
bool CGE2MetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const {
if (desc)
*engine = new CGE2::CGE2Engine(syst, desc);
diff --git a/engines/cge2/events.cpp b/engines/cge2/events.cpp
index ed1ec66bb1..85743c8011 100644
--- a/engines/cge2/events.cpp
+++ b/engines/cge2/events.cpp
@@ -132,7 +132,7 @@ Mouse::Mouse(CGE2Engine *vm) : Sprite(vm), _busy(nullptr), _hold(nullptr), _hx(0
_busy = nullptr;
_active = false;
_flags._kill = false;
-
+
setSeq(_stdSeq8);
BitmapPtr MC = new Bitmap[2];
@@ -260,7 +260,7 @@ void EventManager::handleEvents() {
if (e._spritePtr) {
if (e._mask & kEventKeyb)
e._spritePtr->touch(e._mask, _vm->_mouse->_point, e._keyCode);
- else
+ else
e._spritePtr->touch(e._mask, _vm->_mouse->_point - e._spritePtr->_pos2D, e._keyCode);
} else if (_vm->_sys)
_vm->_sys->touch(e._mask, _vm->_mouse->_point, e._keyCode);
diff --git a/engines/cge2/fileio.cpp b/engines/cge2/fileio.cpp
index 6f8009716b..acb5bb870f 100644
--- a/engines/cge2/fileio.cpp
+++ b/engines/cge2/fileio.cpp
@@ -116,7 +116,10 @@ BtPage *ResourceManager::getPage(int level, uint16 pageId) {
if (_buff[level]._pageNo != pageId) {
int32 pos = pageId * kBtSize;
_buff[level]._pageNo = pageId;
- assert(_catFile->size() > pos);
+
+ if (_catFile->size() <= pos)
+ return nullptr;
+
// In the original, there was a check verifying if the
// purpose was to write a new file. This should only be
// to create a new file, thus it was removed.
@@ -139,6 +142,9 @@ BtKeypack *ResourceManager::find(const char *key) {
uint16 nxt = kBtValRoot;
while (!_catFile->eos()) {
BtPage *pg = getPage(lev, nxt);
+ if (!pg)
+ return nullptr;
+
// search
if (pg->_header._down != kBtValNone) {
int i;
@@ -170,7 +176,11 @@ BtKeypack *ResourceManager::find(const char *key) {
}
bool ResourceManager::exist(const char *name) {
- return scumm_stricmp(find(name)->_key, name) == 0;
+ BtKeypack *result = find(name);
+ if (!result)
+ return false;
+
+ return scumm_stricmp(result->_key, name) == 0;
}
uint16 ResourceManager::catRead(byte *buf, uint16 length) {
diff --git a/engines/cge2/hero.cpp b/engines/cge2/hero.cpp
index 86bd7ac953..42ae67cc2b 100644
--- a/engines/cge2/hero.cpp
+++ b/engines/cge2/hero.cpp
@@ -31,13 +31,14 @@
namespace CGE2 {
-Hero::Hero(CGE2Engine *vm)
- : Sprite(vm), _contact(nullptr), _dir(kNoDir),
- _curDim(0), _tracePtr(-1), _ignoreMap(false), _maxDist(0) {
+Hero::Hero(CGE2Engine *vm) : Sprite(vm), _contact(nullptr), _dir(kNoDir),
+ _curDim(0), _tracePtr(-1), _ignoreMap(false), _maxDist(0) {
- for (int i = 0; i < kDimMax; i++) {
+ for (int i = 0; i < kDimMax; i++)
_dim[i] = nullptr;
- }
+
+ _reachStart = _reachCycle = _sayStart = _funStart = 0;
+ _funDel0 = _funDel = 0;
}
Hero::~Hero() {
@@ -120,7 +121,8 @@ Sprite *Hero::expand() {
break;
case kIdName:
Common::strlcpy(tmpStr, line.c_str(), sizeof(tmpStr));
- for (p = tmpStr; *p != '='; p++); // We search for the =
+ for (p = tmpStr; *p != '='; p++) // We search for the =
+ ;
setName(_vm->tail(p));
break;
default:
@@ -201,9 +203,9 @@ Sprite *Hero::expand() {
delete[] text;
int i = stepSize() / 2;
- _maxDist = sqrt(double(i * i * 2));
+ _maxDist = (int)sqrt(double(i * i * 2));
setCurrent();
-
+
return this;
}
@@ -413,7 +415,7 @@ void Hero::fun() {
}
int Hero::len(V2D v) {
- return sqrt(double(v.x * v.x + v.y * v.y));
+ return (int)sqrt(double(v.x * v.x + v.y * v.y));
}
bool Hero::findWay(){
@@ -556,9 +558,9 @@ int CGE2Engine::mapCross(const V2D &a, const V2D &b) {
if (p) {
if (cross(a, b, *n0, *n))
++cnt;
-
+
if (*n == *p)
- p = nullptr;
+ p = nullptr;
} else {
p = n;
}
@@ -585,7 +587,7 @@ void Hero::operator--() {
bool Sprite::works(Sprite *spr) {
if (!spr || !spr->_ext)
return false;
-
+
bool ok = false;
Action a = _vm->_heroTab[_vm->_sex]->_ptr->action();
@@ -613,7 +615,7 @@ bool Sprite::works(Sprite *spr) {
}
}
}
-
+
return ok;
}
diff --git a/engines/cge2/map.cpp b/engines/cge2/map.cpp
index 1ed0ea7daf..275e15f55a 100644
--- a/engines/cge2/map.cpp
+++ b/engines/cge2/map.cpp
@@ -42,13 +42,13 @@ void Map::clear() {
void Map::load(int scene) {
clear();
- char fname[] = "%.2d.MAP\0";
+ const char *fname = "%.2d.MAP";
Common::String fileName = Common::String::format(fname, scene);
if (!_vm->_resman->exist(fileName.c_str()))
return;
EncryptedStream file(_vm, fileName.c_str());
-
+
Common::String line;
for (line = file.readLine(); !file.eos(); line = file.readLine()) {
if (line.empty())
diff --git a/engines/cge2/saveload.cpp b/engines/cge2/saveload.cpp
index fd60422dff..7735c077a6 100644
--- a/engines/cge2/saveload.cpp
+++ b/engines/cge2/saveload.cpp
@@ -104,7 +104,7 @@ bool CGE2Engine::loadGame(int slotNumber) {
saveFile->read(dataBuffer, size);
readStream = new Common::MemoryReadStream(dataBuffer, size, DisposeAfterUse::YES);
delete saveFile;
-
+
// Check to see if it's a ScummVM savegame or not
char buffer[kSavegameStrSize + 1];
readStream->read(buffer, kSavegameStrSize + 1);
@@ -132,7 +132,7 @@ bool CGE2Engine::loadGame(int slotNumber) {
delete readStream;
loadHeroes();
-
+
return true;
}
diff --git a/engines/cge2/snail.cpp b/engines/cge2/snail.cpp
index 0bf63839e9..7580ef4425 100644
--- a/engines/cge2/snail.cpp
+++ b/engines/cge2/snail.cpp
@@ -62,7 +62,7 @@ void CommandHandler::runCommand() {
if (_vm->_fx->exist(_vm->_soundStat._ref[1], _vm->_soundStat._ref[0])) {
int16 oldRepeat = _vm->_sound->getRepeat();
_vm->_sound->setRepeat(1);
- _vm->_sound->play(Audio::Mixer::kSFXSoundType, _vm->_fx->load(_vm->_soundStat._ref[1], _vm->_soundStat._ref[0]), _vm->_sound->_smpinf._span);
+ _vm->_sound->play(Audio::Mixer::kSpeechSoundType, _vm->_fx->load(_vm->_soundStat._ref[1], _vm->_soundStat._ref[0]), _vm->_sound->_smpinf._span);
_vm->_sound->setRepeat(oldRepeat);
return;
}
@@ -92,7 +92,7 @@ void CommandHandler::runCommand() {
}
_textDelay = false;
}
-
+
if (_vm->_talk && tailCmd._commandType != kCmdPause)
break;
}
@@ -332,7 +332,7 @@ void CGE2Engine::snRSeq(Sprite *spr, int val) {
void CGE2Engine::snSend(Sprite *spr, int val) {
if (!spr)
return;
-
+
// Sending", spr->_file
// from scene", spr->_scene
// to scene", val
@@ -691,7 +691,7 @@ Sprite *CGE2Engine::expandSprite(Sprite *spr) {
void CGE2Engine::qGame() {
// Write out the user's progress
saveGame(0, Common::String("Automatic Savegame"));
-
+
busy(false);
_vga->sunset();
_endGame = true;
@@ -853,13 +853,13 @@ void CGE2Engine::feedSnail(Sprite *spr, Action snq, Hero *hero) {
if (s == spr)
break;
}
-
+
_commandHandler->addCommand(c->_commandType, c->_ref, c->_val, spr);
++c;
}
}
-
+
}
} // End of namespace CGE2.
diff --git a/engines/cge2/sound.cpp b/engines/cge2/sound.cpp
index 32f94b17b9..57ec5983e8 100644
--- a/engines/cge2/sound.cpp
+++ b/engines/cge2/sound.cpp
@@ -143,9 +143,9 @@ void Fx::clear() {
}
Common::String Fx::name(int ref, int sub) {
- char fxname[] = "%.2dfx%.2d.WAV\0";
- char subName[] = "%.2dfx%.2d?.WAV\0";
- char *p = (sub) ? subName : fxname;
+ const char *fxname = "%.2dfx%.2d.WAV";
+ const char *subName = "%.2dfx%.2d?.WAV";
+ const char *p = (sub) ? subName : fxname;
Common::String filename = Common::String::format(p, ref >> 8, ref & 0xFF);
if (sub)
filename.setChar('@' + sub, 6);
diff --git a/engines/cge2/spare.h b/engines/cge2/spare.h
index 7dc6ce60f5..24a97712ff 100644
--- a/engines/cge2/spare.h
+++ b/engines/cge2/spare.h
@@ -38,7 +38,7 @@ class Spare {
public:
Spare(CGE2Engine *vm) : _vm(vm) {}
~Spare() { clear(); }
- void store(Sprite *spr);
+ void store(Sprite *spr);
Sprite *locate(int ref);
Sprite *take(int ref);
void takeScene(int cav);
diff --git a/engines/cge2/talk.cpp b/engines/cge2/talk.cpp
index 9109da90f1..8e6be6cac2 100644
--- a/engines/cge2/talk.cpp
+++ b/engines/cge2/talk.cpp
@@ -121,7 +121,7 @@ Talk::Talk(CGE2Engine *vm, const char *text, TextBoxStyle mode, ColorBank color,
Talk::Talk(CGE2Engine *vm, ColorBank color)
: Sprite(vm), _mode(kTBPure), _created(false), _wideSpace(false), _vm(vm) {
_color = _vm->_font->_colorSet[color];
-
+
if (color == kCBRel)
_vm->setAutoColors();
}
diff --git a/engines/cge2/toolbar.cpp b/engines/cge2/toolbar.cpp
index 6af64b1f5c..0cd220c984 100644
--- a/engines/cge2/toolbar.cpp
+++ b/engines/cge2/toolbar.cpp
@@ -35,11 +35,11 @@
namespace CGE2 {
-#define kSoundNumtoStateRate 25.7
+#define kSoundNumToStateRate 25.7
// == 257 / 10; where 10 equals to the volume switches' number of states [0..9]
// and ScummVM has a scale of 257 different values for setting sounds.
-#define kSoundStatetoNumRate 28.45
+#define kSoundStateToNumRate 28.45
// == 256 / 9 + 0.1; where 256 is the positive range of numbers we can set the volume to
// and the 10 states of a switch cut this range up to 9 equally big parts.
// We don't take into account 0 regarding the 256 different values (it would be the 257th),
@@ -120,7 +120,7 @@ void CGE2Engine::setVolume(int idx, int cnt) {
int p = _vol[idx]->_seqPtr + cnt;
if ((p >= 0) && (p < _vol[idx]->_seqCnt)) {
_vol[idx]->step(p);
- int newVolume = p * kSoundStatetoNumRate;
+ int newVolume = (int)(p * kSoundStateToNumRate);
switch (idx) {
case 0:
_oldSfxVolume = ConfMan.getInt("sfx_volume");
@@ -140,11 +140,11 @@ void CGE2Engine::setVolume(int idx, int cnt) {
void CGE2Engine::checkVolumeSwitches() {
int musicVolume = ConfMan.getInt("music_volume");
if (musicVolume != _oldMusicVolume)
- _vol[1]->step(musicVolume / kSoundNumtoStateRate);
+ _vol[1]->step((int)(musicVolume / kSoundNumToStateRate));
int sfxVolume = ConfMan.getInt("sfx_volume");
if (sfxVolume != _oldSfxVolume)
- _vol[0]->step(sfxVolume / kSoundNumtoStateRate);
+ _vol[0]->step((int)(sfxVolume / kSoundNumToStateRate));
}
void CGE2Engine::switchCap() {
@@ -208,14 +208,13 @@ void CGE2Engine::initToolbar() {
void CGE2Engine::initVolumeSwitch(Sprite *volSwitch, int val) {
int state = 0;
- state = val / kSoundNumtoStateRate;
+ state = (int)(val / kSoundNumToStateRate);
volSwitch->step(state);
}
void CGE2Engine::checkMute() {
bool mute = ConfMan.getBool("mute");
- bool mutedChanged = mute != _muteAll;
- if (mutedChanged) {
+ if (mute != _muteAll) {
switchMusic();
switchVox();
_muteAll = mute;
diff --git a/engines/cge2/vga13h.cpp b/engines/cge2/vga13h.cpp
index db96682237..f4064f3565 100644
--- a/engines/cge2/vga13h.cpp
+++ b/engines/cge2/vga13h.cpp
@@ -45,13 +45,13 @@ void V3D::sync(Common::Serializer &s) {
_z.sync(s);
}
-FXP FXP::operator*(const FXP& x) const {
- FXP y;
+FXP FXP::operator*(const FXP& x) const {
+ FXP y;
int32 t1 = (v >> 8) * x.v;
int32 t2 = ((v & 0xFF) * x.v) >> 8;
y.v = t1 + t2;
- return y;
+ return y;
}
FXP FXP::operator/(const FXP& x) const {
@@ -371,7 +371,8 @@ Sprite *Sprite::expand() {
break;
case kIdName:
Common::strlcpy(tmpStr, line.c_str(), sizeof(tmpStr));
- for (p = tmpStr; *p != '='; p++); // We search for the =
+ for (p = tmpStr; *p != '='; p++) // We search for the =
+ ;
setName(_vm->tail(p));
break;
default:
@@ -612,7 +613,7 @@ void Sprite::gotoxyz(V2D pos) {
++trim;
}
_pos2D.x = pos.x;
-
+
if (pos.y < -kPanHeight) {
pos.y = -kPanHeight;
++trim;
diff --git a/engines/drascula/detection.cpp b/engines/drascula/detection.cpp
index 833363669d..a84bd11cb1 100644
--- a/engines/drascula/detection.cpp
+++ b/engines/drascula/detection.cpp
@@ -382,8 +382,7 @@ SaveStateList DrasculaMetaEngine::listSaves(const char *target) const {
}
SaveStateDescriptor DrasculaMetaEngine::querySaveMetaInfos(const char *target, int slot) const {
- char fileName[MAXPATHLEN];
- sprintf(fileName, "%s.%03d", target, slot);
+ Common::String fileName = Common::String::format("%s.%03d", target, slot);
Common::InSaveFile *in = g_system->getSavefileManager()->openForLoading(fileName);
diff --git a/engines/drascula/drascula.cpp b/engines/drascula/drascula.cpp
index 797b6d94b0..c72d77c281 100644
--- a/engines/drascula/drascula.cpp
+++ b/engines/drascula/drascula.cpp
@@ -41,20 +41,6 @@
namespace Drascula {
-struct GameSettings {
- const char *gameid;
- const char *description;
- byte id;
- uint32 features;
- const char *detectname;
-};
-
-static const GameSettings drasculaSettings[] = {
- {"drascula", "Drascula game", 0, 0, 0},
-
- {NULL, NULL, 0, 0, NULL}
-};
-
DrasculaEngine::DrasculaEngine(OSystem *syst, const DrasculaGameDescription *gameDesc) : Engine(syst), _gameDescription(gameDesc) {
_charMap = 0;
_itemLocations = 0;
diff --git a/engines/dreamweb/POTFILES b/engines/dreamweb/POTFILES
index d05d239bb7..64fb20db67 100644
--- a/engines/dreamweb/POTFILES
+++ b/engines/dreamweb/POTFILES
@@ -1 +1,3 @@
engines/dreamweb/detection.cpp
+engines/dreamweb/saveload.cpp
+
diff --git a/engines/engine.cpp b/engines/engine.cpp
index c63437f800..24008dd073 100644
--- a/engines/engine.cpp
+++ b/engines/engine.cpp
@@ -45,6 +45,7 @@
#include "common/taskbar.h"
#include "common/textconsole.h"
#include "common/translation.h"
+#include "common/singleton.h"
#include "backends/keymapper/keymapper.h"
@@ -101,6 +102,36 @@ static void defaultErrorHandler(const char *msg) {
}
}
+// Chained games manager
+
+ChainedGamesManager::ChainedGamesManager() {
+ clear();
+}
+
+void ChainedGamesManager::clear() {
+ _chainedGames.clear();
+}
+
+void ChainedGamesManager::push(const Common::String target, const int slot) {
+ Game game;
+ game.target = target;
+ game.slot = slot;
+ _chainedGames.push(game);
+}
+
+bool ChainedGamesManager::pop(Common::String &target, int &slot) {
+ if (_chainedGames.empty()) {
+ return false;
+ }
+ Game game = _chainedGames.pop();
+ target = game.target;
+ slot = game.slot;
+ return true;
+}
+
+namespace Common {
+DECLARE_SINGLETON(ChainedGamesManager);
+}
Engine::Engine(OSystem *syst)
: _system(syst),
diff --git a/engines/engine.h b/engines/engine.h
index e325cc1ba2..d3415d584c 100644
--- a/engines/engine.h
+++ b/engines/engine.h
@@ -27,6 +27,8 @@
#include "common/str.h"
#include "common/language.h"
#include "common/platform.h"
+#include "common/queue.h"
+#include "common/singleton.h"
class OSystem;
@@ -334,6 +336,32 @@ protected:
};
+// Chained games
+
+/**
+ * Singleton class which manages chained games. A chained game is one that
+ * starts automatically, optionally loading a saved game, instead of returning
+ * to the launcher.
+ */
+class ChainedGamesManager : public Common::Singleton<ChainedGamesManager> {
+private:
+ struct Game {
+ Common::String target;
+ int slot;
+ };
+
+ Common::Queue<Game> _chainedGames;
+
+public:
+ ChainedGamesManager();
+ void clear();
+ void push(const Common::String target, const int slot = -1);
+ bool pop(Common::String &target, int &slot);
+};
+
+/** Convenience shortcut for accessing the chained games manager. */
+#define ChainedGamesMan ChainedGamesManager::instance()
+
// FIXME: HACK for MidiEmu & error()
extern Engine *g_engine;
diff --git a/engines/fullpipe/fullpipe.cpp b/engines/fullpipe/fullpipe.cpp
index bb0838395d..ebaff32550 100644
--- a/engines/fullpipe/fullpipe.cpp
+++ b/engines/fullpipe/fullpipe.cpp
@@ -163,7 +163,7 @@ FullpipeEngine::FullpipeEngine(OSystem *syst, const ADGameDescription *gameDesc)
for (int i = 0; i < 11; i++)
_currSoundList1[i] = 0;
-
+
for (int i = 0; i < 200; i++)
_mapTable[i] = 0;
@@ -285,7 +285,7 @@ Common::Error FullpipeEngine::run() {
freeGameLoader();
_currentScene = 0;
_updateTicks = 0;
-
+
loadGam("fullpipe.gam");
_needRestart = false;
}
diff --git a/engines/fullpipe/gfx.cpp b/engines/fullpipe/gfx.cpp
index 61fbf7192f..42846850ca 100644
--- a/engines/fullpipe/gfx.cpp
+++ b/engines/fullpipe/gfx.cpp
@@ -153,7 +153,7 @@ bool PictureObject::load(MfcArchive &file, bool bigPicture) {
if (count > 0) {
GameObject *o = new GameObject();
-
+
o->load(file);
_pictureObject2List->push_back(o);
}
@@ -286,9 +286,9 @@ bool GameObject::load(MfcArchive &file) {
_okeyCode = 0;
_flags = 0;
_field_20 = 0;
-
+
_id = file.readUint16LE();
-
+
_objectName = file.readPascalString();
_ox = file.readUint32LE();
_oy = file.readUint32LE();
@@ -498,7 +498,7 @@ bool Picture::load(MfcArchive &file) {
_x = file.readUint32LE();
_y = file.readUint32LE();
_field_44 = file.readUint16LE();
-
+
assert(g_fp->_gameProjectVersion >= 2);
_width = file.readUint32LE();
diff --git a/engines/fullpipe/input.cpp b/engines/fullpipe/input.cpp
index 7c97461a24..b681f4fbe7 100644
--- a/engines/fullpipe/input.cpp
+++ b/engines/fullpipe/input.cpp
@@ -70,7 +70,7 @@ void setInputDisabled(bool state) {
void InputController::addCursor(CursorInfo *cursor) {
CursorInfo *newc = new CursorInfo(cursor);
Common::Point p;
-
+
cursor->picture->getDimensions(&p);
newc->width = p.x;
diff --git a/engines/fullpipe/inventory.cpp b/engines/fullpipe/inventory.cpp
index e79f9c54df..f9b507c50b 100644
--- a/engines/fullpipe/inventory.cpp
+++ b/engines/fullpipe/inventory.cpp
@@ -126,7 +126,7 @@ void Inventory2::removeItem2(Scene *sceneObj, int itemId, int x, int y, int prio
int idx = getInventoryItemIndexById(itemId);
if (idx >= 0) {
- if (_inventoryItems[idx]->itemId >> 16) {
+ if (_inventoryItems[idx]->count) {
removeItem(itemId, 1);
Scene *sc = g_fp->accessScene(_sceneId);
diff --git a/engines/fullpipe/mgm.cpp b/engines/fullpipe/mgm.cpp
index aacfd5452a..1c8ca2a7b1 100644
--- a/engines/fullpipe/mgm.cpp
+++ b/engines/fullpipe/mgm.cpp
@@ -155,13 +155,14 @@ void MGM::rebuildTables(int objId) {
if (!obj)
return;
- for (uint i = 0; i < obj->_staticsList.size(); i++)
+ for (uint i = 0; i < obj->_staticsList.size(); i++) {
_items[idx]->statics.push_back((Statics *)obj->_staticsList[i]);
+ _items[idx]->subItems.push_back(new MGMSubItem);
+ }
+
for (uint i = 0; i < obj->_movements.size(); i++)
_items[idx]->movements1.push_back((Movement *)obj->_movements[i]);
-
- _items[idx]->subItems.clear();
}
int MGM::getItemIndexById(int objId) {
diff --git a/engines/fullpipe/motion.cpp b/engines/fullpipe/motion.cpp
index 49cf88434e..9573e0517b 100644
--- a/engines/fullpipe/motion.cpp
+++ b/engines/fullpipe/motion.cpp
@@ -1040,11 +1040,11 @@ MessageQueue *MovGraph::doWalkTo(StaticANIObject *subj, int xpos, int ypos, int
if (!mq || !mq->getExCommandByIndex(0))
return 0;
-
+
ExCommand *ex = mq->getExCommandByIndex(0);
- if ((ex->_messageKind != 1 && ex->_messageKind != 20) ||
- ex->_messageNum != subj->_movement->_id ||
+ if ((ex->_messageKind != 1 && ex->_messageKind != 20) ||
+ ex->_messageNum != subj->_movement->_id ||
(ex->_field_14 >= 1 && ex->_field_14 <= subj->_movement->_currDynamicPhaseIndex))
subj->playIdle();
}
@@ -1416,8 +1416,8 @@ Common::Array<MovArr *> *MovGraph::genMovArr(int x, int y, int *arrSize, int fla
movarr = new MovArr;
movarr->_link = lnk;
- movarr->_dist = ((double)(lnk->_movGraphNode1->_y - lnk->_movGraphNode2->_y) * (double)(lnk->_movGraphNode1->_y - point.y) +
- (double)(lnk->_movGraphNode2->_x - lnk->_movGraphNode1->_x) * (double)(point.x - lnk->_movGraphNode1->_x)) /
+ movarr->_dist = ((double)(lnk->_movGraphNode1->_y - lnk->_movGraphNode2->_y) * (double)(lnk->_movGraphNode1->_y - point.y) +
+ (double)(lnk->_movGraphNode2->_x - lnk->_movGraphNode1->_x) * (double)(point.x - lnk->_movGraphNode1->_x)) /
lnk->_distance / lnk->_distance;
movarr->_point = point;
@@ -1445,8 +1445,8 @@ Common::Array<MovArr *> *MovGraph::genMovArr(int x, int y, int *arrSize, int fla
} else {
movarr = new MovArr;
movarr->_link = lnk;
- movarr->_dist = ((double)(lnk->_movGraphNode1->_y - lnk->_movGraphNode2->_y) * (double)(lnk->_movGraphNode1->_y - y) +
- (double)(lnk->_movGraphNode2->_x - lnk->_movGraphNode1->_x) * (double)(x - lnk->_movGraphNode1->_x)) /
+ movarr->_dist = ((double)(lnk->_movGraphNode1->_y - lnk->_movGraphNode2->_y) * (double)(lnk->_movGraphNode1->_y - y) +
+ (double)(lnk->_movGraphNode2->_x - lnk->_movGraphNode1->_x) * (double)(x - lnk->_movGraphNode1->_x)) /
lnk->_distance / lnk->_distance;
movarr->_point.x = x;
movarr->_point.y = y;
diff --git a/engines/fullpipe/scene.cpp b/engines/fullpipe/scene.cpp
index 8463b3ab40..00dd70c1b2 100644
--- a/engines/fullpipe/scene.cpp
+++ b/engines/fullpipe/scene.cpp
@@ -162,7 +162,7 @@ bool Scene::load(MfcArchive &file) {
Background::load(file);
_sceneId = file.readUint16LE();
-
+
_sceneName = file.readPascalString();
debug(0, "scene: <%s> %d", transCyrillic((byte *)_sceneName), _sceneId);
diff --git a/engines/fullpipe/scenes/scene02.cpp b/engines/fullpipe/scenes/scene02.cpp
index 109a20a07a..fd542d580d 100644
--- a/engines/fullpipe/scenes/scene02.cpp
+++ b/engines/fullpipe/scenes/scene02.cpp
@@ -134,5 +134,5 @@ int sceneHandler02(ExCommand *ex) {
return res;
}
-
+
} // End of namespace Fullpipe
diff --git a/engines/fullpipe/scenes/scene04.cpp b/engines/fullpipe/scenes/scene04.cpp
index fd1ececdf2..4a87ae5b87 100644
--- a/engines/fullpipe/scenes/scene04.cpp
+++ b/engines/fullpipe/scenes/scene04.cpp
@@ -949,7 +949,7 @@ void sceneHandler04_springWobble() {
if (g_vars->scene04_bottleWeight < newdelta)
g_vars->scene04_springOffset--;
- if ((oldDynIndex > g_vars->scene04_bottleWeight && newdelta > g_vars->scene04_bottleWeight) || newdelta <= g_vars->scene04_bottleWeight) {
+ if ((oldDynIndex <= g_vars->scene04_bottleWeight && newdelta > g_vars->scene04_bottleWeight) || newdelta <= g_vars->scene04_bottleWeight) {
g_vars->scene04_springDelay++;
if (g_vars->scene04_springOffset && g_vars->scene04_springDelay > 1) {
@@ -960,6 +960,8 @@ void sceneHandler04_springWobble() {
Common::Point point;
+ int oldpos = g_vars->scene04_spring->getCurrDimensions(point)->y - oldDynIndex;
+
if (g_vars->scene04_dynamicPhaseIndex) {
if (!g_vars->scene04_spring->_movement)
g_vars->scene04_spring->startAnim(MV_SPR_LOWER, 0, -1);
@@ -969,8 +971,9 @@ void sceneHandler04_springWobble() {
g_vars->scene04_spring->changeStatics2(ST_SPR_UP);
}
- if (g_vars->scene04_dynamicPhaseIndex != oldDynIndex)
- sceneHandler04_bottleUpdateObjects(oldDynIndex - g_vars->scene04_dynamicPhaseIndex);
+ if (g_vars->scene04_dynamicPhaseIndex != oldDynIndex) {
+ sceneHandler04_bottleUpdateObjects(oldpos - (g_vars->scene04_spring->getCurrDimensions(point)->y - g_vars->scene04_dynamicPhaseIndex));
+ }
}
void sceneHandler04_leaveScene() {
diff --git a/engines/fullpipe/scenes/scene14.cpp b/engines/fullpipe/scenes/scene14.cpp
index 21dbe8101f..446f477133 100644
--- a/engines/fullpipe/scenes/scene14.cpp
+++ b/engines/fullpipe/scenes/scene14.cpp
@@ -57,7 +57,7 @@ void scene14_initScene(Scene *sc) {
ball->_flags &= 0xFFFB;
g_vars->scene14_balls.push_back(ball);
-
+
for (uint i = 0; i < 3; i++) {
ball = new StaticANIObject(ball); // create a copy
diff --git a/engines/fullpipe/scenes/scene15.cpp b/engines/fullpipe/scenes/scene15.cpp
index 452f2edeca..efc69a5fa6 100644
--- a/engines/fullpipe/scenes/scene15.cpp
+++ b/engines/fullpipe/scenes/scene15.cpp
@@ -71,7 +71,7 @@ void scene15_initScene(Scene *sc) {
grandma->hide();
g_fp->setObjectState(sO_LeftPipe_15, g_fp->getObjectEnumState(sO_LeftPipe_15, sO_IsOpened));
}
-
+
g_vars->scene15_plusminus = sc->getStaticANIObject1ById(ANI_PLUSMINUS, -1);
if (g_fp->getObjectState(sO_Guard_2) == g_fp->getObjectEnumState(sO_Guard_2, sO_Off))
diff --git a/engines/fullpipe/scenes/scene16.cpp b/engines/fullpipe/scenes/scene16.cpp
index ed3c51a6c2..df005950d2 100644
--- a/engines/fullpipe/scenes/scene16.cpp
+++ b/engines/fullpipe/scenes/scene16.cpp
@@ -57,9 +57,9 @@ void scene16_initScene(Scene *sc) {
boy[1] = new StaticANIObject(boy[0]);
sc->addStaticANIObject(boy[1], 1);
-
+
int idx = 0;
-
+
for (int i = 0; i < 3; i++) {
g_vars->scene16_figures.push_back(boy[idx]);
@@ -68,7 +68,7 @@ void scene16_initScene(Scene *sc) {
if (idx >= 2)
idx = 0;
}
-
+
g_vars->scene16_figures.push_back(sc->getStaticANIObject1ById(ANI_GIRL, -1));
for (int i = 0; i < 4; i++) {
@@ -182,7 +182,7 @@ void sceneHandler16_fillMug() {
mq = new MessageQueue(g_fp->_currentScene->getMessageQueueById(QU_SC16_BOYOUT), 0, 1);
mq->replaceKeyCode(-1, g_vars->scene16_walkingBoy->_okeyCode);
- if (!mq || mq->chain(g_vars->scene16_walkingBoy))
+ if (mq->chain(g_vars->scene16_walkingBoy))
return;
} else {
if (!g_vars->scene16_walkingGirl)
@@ -259,7 +259,7 @@ void sceneHandler16_drink() {
mq = new MessageQueue(g_fp->_currentScene->getMessageQueueById(QU_SC16_BOYKICK), 0, 1);
mq->replaceKeyCode(-1, g_vars->scene16_walkingBoy->_okeyCode);
-
+
ex = new ExCommand(ANI_MAN, 34, 384, 0, 0, 0, 1, 0, 0, 0);
ex->_excFlags |= 3u;
ex->_field_14 = 384;
diff --git a/engines/fullpipe/scenes/scene23.cpp b/engines/fullpipe/scenes/scene23.cpp
index ccfbac9223..f66ea12b4b 100644
--- a/engines/fullpipe/scenes/scene23.cpp
+++ b/engines/fullpipe/scenes/scene23.cpp
@@ -146,7 +146,7 @@ void scene23_initScene(Scene *sc) {
sc->getStaticANIObject1ById(ANI_INV_LEVERHANDLE, -1)->hide();
}
-
+
g_fp->_currentScene = oldsc;
}
diff --git a/engines/fullpipe/scenes/scene27.cpp b/engines/fullpipe/scenes/scene27.cpp
index 1431ceffba..8ec05caaff 100644
--- a/engines/fullpipe/scenes/scene27.cpp
+++ b/engines/fullpipe/scenes/scene27.cpp
@@ -340,7 +340,7 @@ void sceneHandler27_wipeDo() {
bool sceneHandler27_batFallLogic(uint batn) {
Bat *bat = g_vars->scene27_bats[batn];
- int y = (bat->currY - 458.0) * 0.4848484848484849 + 734.0;
+ int y = (int)((bat->currY - 458.0) * 0.4848484848484849 + 734.0);
if (y >= bat->currX)
return false;
diff --git a/engines/fullpipe/scenes/scene28.cpp b/engines/fullpipe/scenes/scene28.cpp
index c21ce05502..de5a96e70d 100644
--- a/engines/fullpipe/scenes/scene28.cpp
+++ b/engines/fullpipe/scenes/scene28.cpp
@@ -46,7 +46,7 @@ void scene28_initScene(Scene *sc) {
g_vars->scene28_lift6inside = false;
g_fp->_floaters->init(g_fp->getGameLoaderGameVar()->getSubVarByName("SC_28"));
-
+
g_fp->initArcadeKeys("SC_28");
}
diff --git a/engines/fullpipe/scenes/scene29.cpp b/engines/fullpipe/scenes/scene29.cpp
index 8f82e99ad1..222a541554 100644
--- a/engines/fullpipe/scenes/scene29.cpp
+++ b/engines/fullpipe/scenes/scene29.cpp
@@ -840,7 +840,7 @@ void sceneHandler29_shootersEscape() {
void sceneHandler29_manRideBack() {
g_vars->scene29_manX -= 2;
-
+
g_fp->_aniMan->setOXY(g_vars->scene29_manX, g_vars->scene29_manY);
}
diff --git a/engines/fullpipe/scenes/scene37.cpp b/engines/fullpipe/scenes/scene37.cpp
index 09da01f138..324d3ac92d 100644
--- a/engines/fullpipe/scenes/scene37.cpp
+++ b/engines/fullpipe/scenes/scene37.cpp
@@ -91,7 +91,7 @@ void scene37_initScene(Scene *sc) {
g_vars->scene37_rings.push_back(ring);
g_fp->setObjectState(sO_LeftPipe_37, g_fp->getObjectEnumState(sO_LeftPipe_37, sO_IsClosed));
-
+
Scene *oldsc = g_fp->_currentScene;
g_fp->_currentScene = sc;
diff --git a/engines/fullpipe/sound.cpp b/engines/fullpipe/sound.cpp
index a4ca06f489..230d6c39a9 100644
--- a/engines/fullpipe/sound.cpp
+++ b/engines/fullpipe/sound.cpp
@@ -62,7 +62,7 @@ bool SoundList::load(MfcArchive &file, char *fname) {
}
return true;
-
+
}
bool SoundList::loadFile(const char *fname, char *libname) {
diff --git a/engines/fullpipe/statics.cpp b/engines/fullpipe/statics.cpp
index 717de84925..de3e1ea728 100644
--- a/engines/fullpipe/statics.cpp
+++ b/engines/fullpipe/statics.cpp
@@ -246,7 +246,7 @@ bool StaticANIObject::load(MfcArchive &file) {
void StaticANIObject::setOXY(int x, int y) {
_ox = x;
_oy = y;
-
+
if (_movement)
_movement->setOXY(x, y);
}
@@ -713,7 +713,7 @@ void StaticANIObject::setSpeed(int speed) {
void StaticANIObject::setAlpha(int alpha) {
for (uint i = 0; i < _movements.size(); i++)
_movements[i]->setAlpha(alpha);
-
+
for (uint i = 0; i < _staticsList.size(); i++)
_staticsList[i]->setAlpha(alpha);
}
@@ -1048,8 +1048,11 @@ MessageQueue *StaticANIObject::changeStatics1(int msgNum) {
if (_flags & 1)
_messageQueueId = mq->_id;
} else {
- if (!queueMessageQueue(mq))
+ if (!queueMessageQueue(mq)) {
+ delete mq;
+
return 0;
+ }
g_fp->_globalMessageQueueList->addMessageQueue(mq);
}
@@ -1594,6 +1597,12 @@ Movement::Movement(Movement *src, int *oldIdxs, int newSize, StaticANIObject *an
newSize = src->_dynamicPhases.size();
}
+ if (!newSize) {
+ warning("Movement::Movement: newSize = 0");
+
+ return;
+ }
+
_framePosOffsets = (Common::Point **)calloc(newSize, sizeof(Common::Point *));
for (int i = 0; i < newSize; i++)
@@ -1813,7 +1822,7 @@ void Movement::initStatics(StaticANIObject *ani) {
_staticsObj2 = ani->addReverseStatics(_currMovement->_staticsObj2);
_staticsObj1 = ani->addReverseStatics(_currMovement->_staticsObj1);
-
+
_mx = _currMovement->_mx;
_my = _currMovement->_my;
@@ -2279,7 +2288,7 @@ bool StaticPhase::load(MfcArchive &file) {
_initialCountdown = file.readUint16LE();
_field_6A = file.readUint16LE();
-
+
if (g_fp->_gameProjectVersion >= 12) {
_exCommand = (ExCommand *)file.readClass();
diff --git a/engines/gob/POTFILES b/engines/gob/POTFILES
index 9a512469dd..ca7aa14177 100644
--- a/engines/gob/POTFILES
+++ b/engines/gob/POTFILES
@@ -1,3 +1,5 @@
engines/gob/inter_playtoons.cpp
engines/gob/inter_v2.cpp
engines/gob/inter_v5.cpp
+engines/gob/inter_geisha.cpp
+
diff --git a/engines/gob/inter_v1.cpp b/engines/gob/inter_v1.cpp
index 40134bbf17..676564a9fb 100644
--- a/engines/gob/inter_v1.cpp
+++ b/engines/gob/inter_v1.cpp
@@ -1124,8 +1124,6 @@ void Inter_v1::o1_palLoad(OpFuncParams &params) {
_vm->_draw->_vgaPalette[i].green = _vm->_game->_script->readByte();
_vm->_draw->_vgaPalette[i].blue = _vm->_game->_script->readByte();
}
-
- memcpy(_vm->_draw->_vgaPalette, _vm->_draw->_vgaPalette, 16 * 3);
break;
case 53:
diff --git a/engines/groovie/graphics.cpp b/engines/groovie/graphics.cpp
index b85277fac7..e0c198f377 100644
--- a/engines/groovie/graphics.cpp
+++ b/engines/groovie/graphics.cpp
@@ -63,7 +63,7 @@ void GraphicsMan::update() {
// Clear the buffer when ending the fade out
if (_fading == 2)
- _foreground.fillRect(Common::Rect(640, 320), 0);
+ _foreground.fillRect(Common::Rect(640, _foreground.h), 0);
}
}
@@ -74,6 +74,22 @@ void GraphicsMan::update() {
}
}
+void GraphicsMan::switchToFullScreen(bool fullScreen) {
+ _foreground.free();
+ _background.free();
+
+ if (fullScreen) {
+ _foreground.create(640, 480, _vm->_pixelFormat);
+ _background.create(640, 480, _vm->_pixelFormat);
+ } else {
+ _vm->_system->fillScreen(0);
+ _foreground.create(640, 320, _vm->_pixelFormat);
+ _background.create(640, 320, _vm->_pixelFormat);
+ }
+
+ _changed = true;
+}
+
void GraphicsMan::change() {
_changed = true;
}
@@ -84,7 +100,7 @@ void GraphicsMan::mergeFgAndBg() {
countf = (byte *)_foreground.getPixels();
countb = (byte *)_background.getPixels();
- for (i = 640 * 320; i; i--) {
+ for (i = 640 * _foreground.h; i; i--) {
if (255 == *(countf)) {
*(countf) = *(countb);
}
@@ -94,7 +110,10 @@ void GraphicsMan::mergeFgAndBg() {
}
void GraphicsMan::updateScreen(Graphics::Surface *source) {
- _vm->_system->copyRectToScreen(source->getPixels(), 640, 0, 80, 640, 320);
+ if (!isFullScreen())
+ _vm->_system->copyRectToScreen(source->getPixels(), source->pitch, 0, 80, 640, 320);
+ else
+ _vm->_system->copyRectToScreen(source->getPixels(), source->pitch, 0, 0, 640, 480);
change();
}
diff --git a/engines/groovie/graphics.h b/engines/groovie/graphics.h
index 72ab01deb6..69934f9d68 100644
--- a/engines/groovie/graphics.h
+++ b/engines/groovie/graphics.h
@@ -38,6 +38,8 @@ public:
void update();
void change();
void mergeFgAndBg();
+ void switchToFullScreen(bool fullScreen);
+ bool isFullScreen() { return (_foreground.h == 480); }
void updateScreen(Graphics::Surface *source);
Graphics::Surface _foreground; // The main surface that most things are drawn to
Graphics::Surface _background; // Used occasionally, mostly (only?) in puzzles
diff --git a/engines/groovie/roq.cpp b/engines/groovie/roq.cpp
index 379fcabc07..f14cacd6b8 100644
--- a/engines/groovie/roq.cpp
+++ b/engines/groovie/roq.cpp
@@ -28,6 +28,7 @@
#include "groovie/groovie.h"
#include "common/debug.h"
+#include "common/debug-channels.h"
#include "common/rect.h"
#include "common/substream.h"
#include "common/textconsole.h"
@@ -46,6 +47,7 @@ namespace Groovie {
ROQPlayer::ROQPlayer(GroovieEngine *vm) :
VideoPlayer(vm), _codingTypeCount(0),
+ _fg(&_vm->_graphicsMan->_foreground),
_bg(&_vm->_graphicsMan->_background),
_firstFrame(true) {
@@ -63,6 +65,22 @@ ROQPlayer::~ROQPlayer() {
}
uint16 ROQPlayer::loadInternal() {
+ if (DebugMan.isDebugChannelEnabled(kDebugVideo)) {
+ int8 i;
+ debugN(1, "Groovie::ROQ: New ROQ: bitflags are ");
+ for (i = 15; i >= 0; i--) {
+ debugN(1, "%d", _flags & (1 << i)? 1 : 0);
+ if (i % 4 == 0) {
+ debugN(1, " ");
+ }
+ }
+ debug(1, " <- 0 ");
+ }
+
+ // Flags:
+ // - 2 For overlay videos, show the whole video
+ _flagTwo = ((_flags & (1 << 2)) != 0);
+
// Begin reading the file
debugC(1, kDebugVideo, "Groovie::ROQ: Loading video");
@@ -106,13 +124,23 @@ uint16 ROQPlayer::loadInternal() {
}
void ROQPlayer::buildShowBuf() {
+ if (_alpha)
+ _fg->copyFrom(*_bg);
+
for (int line = 0; line < _bg->h; line++) {
- uint32 *out = (uint32 *)_bg->getBasePtr(0, line);
+ uint32 *out = _alpha ? (uint32 *)_fg->getBasePtr(0, line) : (uint32 *)_bg->getBasePtr(0, line);
uint32 *in = (uint32 *)_currBuf->getBasePtr(0, line / _scaleY);
for (int x = 0; x < _bg->w; x++) {
- // Copy a pixel
- *out++ = *in;
+ // Copy a pixel, checking the alpha channel first
+ if (_alpha && !(*in & 0xFF))
+ out++;
+ else if (_fg->h == 480 && *in == _vm->_pixelFormat.RGBToColor(255, 255, 255))
+ // Handle transparency in Gamepad videos
+ // TODO: For now, we detect these videos by checking for full screen
+ out++;
+ else
+ *out++ = *in;
// Skip to the next pixel
if (!(x % _scaleX))
@@ -145,19 +173,27 @@ bool ROQPlayer::playFrameInternal() {
}
// Wait until the current frame can be shown
- waitFrame();
+ // Don't wait if we're just showing one frame
+ if (!playFirstFrame())
+ waitFrame();
if (_dirty) {
// Update the screen
- _syst->copyRectToScreen(_bg->getPixels(), _bg->pitch, 0, (_syst->getHeight() - _bg->h) / 2, _bg->w, _bg->h);
+ void *src = (_alpha) ? _fg->getPixels() : _bg->getPixels();
+ _syst->copyRectToScreen(src, _bg->pitch, 0, (_syst->getHeight() - _bg->h) / 2, _bg->w, _bg->h);
_syst->updateScreen();
+ // For overlay videos, set the background buffer when the video ends
+ if (_alpha && (!_flagTwo || (_flagTwo && _file->eos())))
+ _bg->copyFrom(*_fg);
+
// Clear the dirty flag
_dirty = false;
}
- // Return whether the video has ended
- return _file->eos();
+ // Report the end of the video if we reached the end of the file or if we
+ // just wanted to play one frame.
+ return _file->eos() || playFirstFrame();
}
bool ROQPlayer::readBlockHeader(ROQBlockHeader &blockHeader) {
@@ -277,9 +313,17 @@ bool ROQPlayer::processBlockInfo(ROQBlockHeader &blockHeader) {
_prevBuf->create(width, height, _vm->_pixelFormat);
}
+ // Switch from/to fullscreen, if needed
+ if (_bg->h != 480 && height == 480)
+ _vm->_graphicsMan->switchToFullScreen(true);
+ else if (_bg->h == 480 && height != 480)
+ _vm->_graphicsMan->switchToFullScreen(false);
+
// Clear the buffers with black
- _currBuf->fillRect(Common::Rect(width, height), _vm->_pixelFormat.RGBToColor(0, 0, 0));
- _prevBuf->fillRect(Common::Rect(width, height), _vm->_pixelFormat.RGBToColor(0, 0, 0));
+ if (!_alpha) {
+ _currBuf->fillRect(Common::Rect(width, height), _vm->_pixelFormat.RGBToColor(0, 0, 0));
+ _prevBuf->fillRect(Common::Rect(width, height), _vm->_pixelFormat.RGBToColor(0, 0, 0));
+ }
return true;
}
@@ -448,7 +492,7 @@ bool ROQPlayer::processBlockSoundMono(ROQBlockHeader &blockHeader) {
}
// Initialize the audio stream if needed
- if (!_audioStream) {
+ if (!_audioStream && !playFirstFrame()) {
_audioStream = Audio::makeQueuingAudioStream(22050, false);
Audio::SoundHandle sound_handle;
g_system->getMixer()->playStream(Audio::Mixer::kPlainSoundType, &sound_handle, _audioStream);
@@ -477,7 +521,10 @@ bool ROQPlayer::processBlockSoundMono(ROQBlockHeader &blockHeader) {
#ifdef SCUMM_LITTLE_ENDIAN
flags |= Audio::FLAG_LITTLE_ENDIAN;
#endif
- _audioStream->queueBuffer((byte *)buffer, blockHeader.size * 2, DisposeAfterUse::YES, flags);
+ if (!playFirstFrame())
+ _audioStream->queueBuffer((byte *)buffer, blockHeader.size * 2, DisposeAfterUse::YES, flags);
+ else
+ free(buffer);
return true;
}
@@ -491,7 +538,7 @@ bool ROQPlayer::processBlockSoundStereo(ROQBlockHeader &blockHeader) {
}
// Initialize the audio stream if needed
- if (!_audioStream) {
+ if (!_audioStream && !playFirstFrame()) {
_audioStream = Audio::makeQueuingAudioStream(22050, true);
Audio::SoundHandle sound_handle;
g_system->getMixer()->playStream(Audio::Mixer::kPlainSoundType, &sound_handle, _audioStream);
@@ -533,7 +580,10 @@ bool ROQPlayer::processBlockSoundStereo(ROQBlockHeader &blockHeader) {
#ifdef SCUMM_LITTLE_ENDIAN
flags |= Audio::FLAG_LITTLE_ENDIAN;
#endif
- _audioStream->queueBuffer((byte *)buffer, blockHeader.size * 2, DisposeAfterUse::YES, flags);
+ if (!playFirstFrame())
+ _audioStream->queueBuffer((byte *)buffer, blockHeader.size * 2, DisposeAfterUse::YES, flags);
+ else
+ free(buffer);
return true;
}
diff --git a/engines/groovie/roq.h b/engines/groovie/roq.h
index 7e7d38580e..ce1a3a2d58 100644
--- a/engines/groovie/roq.h
+++ b/engines/groovie/roq.h
@@ -57,6 +57,7 @@ private:
bool processBlockSoundMono(ROQBlockHeader &blockHeader);
bool processBlockSoundStereo(ROQBlockHeader &blockHeader);
bool processBlockAudioContainer(ROQBlockHeader &blockHeader);
+ bool playFirstFrame() { return _alpha && !_flagTwo; }
void paint2(byte i, int destx, int desty);
void paint4(byte i, int destx, int desty);
@@ -74,8 +75,11 @@ private:
uint32 _codebook2[256 * 4];
byte _codebook4[256 * 4];
+ // Flags
+ bool _flagTwo;
+
// Buffers
- Graphics::Surface *_bg;
+ Graphics::Surface *_fg, *_bg;
Graphics::Surface *_currBuf, *_prevBuf;
void buildShowBuf();
byte _scaleX, _scaleY;
diff --git a/engines/groovie/script.cpp b/engines/groovie/script.cpp
index 7625151082..eef97b6ff9 100644
--- a/engines/groovie/script.cpp
+++ b/engines/groovie/script.cpp
@@ -179,12 +179,20 @@ void Script::directGameLoad(int slot) {
// TODO: Return to the main script, likely reusing most of o_returnscript()
- // HACK: We set variable 0x19 to the slot to load, and set the current
- // instruction to the one that actually loads the saved game specified
- // in that variable. This will change in other versions of the game and
- // in other games.
- setVariable(0x19, slot);
- _currentInstruction = 0x287;
+ // HACK: We set the slot to load in the appropriate variable, and set the
+ // current instruction to the one that actually loads the saved game
+ // specified in that variable. This differs depending on the game and its
+ // version.
+ if (_version == kGroovieT7G) {
+ // 7th Guest
+ setVariable(0x19, slot);
+ _currentInstruction = 0x287;
+ } else {
+ // 11th Hour
+ setVariable(0xF, slot);
+ // FIXME: This bypasses a lot of the game's initialization procedure
+ _currentInstruction = 0xE78E;
+ }
// TODO: We'll probably need to start by running the beginning of the
// script to let it do the soundcard initialization and then do the
@@ -350,9 +358,10 @@ bool Script::hotspot(Common::Rect rect, uint16 address, uint8 cursor) {
// Show hotspots when debugging
if (DebugMan.isDebugChannelEnabled(kDebugHotspots)) {
- rect.translate(0, -80);
+ if (!_vm->_graphicsMan->isFullScreen())
+ rect.translate(0, -80);
_vm->_graphicsMan->_foreground.frameRect(rect, 250);
- _vm->_system->copyRectToScreen(_vm->_graphicsMan->_foreground.getPixels(), _vm->_graphicsMan->_foreground.pitch, 0, 80, 640, 320);
+ _vm->_graphicsMan->updateScreen(&_vm->_graphicsMan->_foreground);
_vm->_system->updateScreen();
}
@@ -962,7 +971,7 @@ void Script::o_strcmpnejmp_var() { // 0x21
void Script::o_copybgtofg() { // 0x22
debugC(1, kDebugScript, "COPY_BG_TO_FG");
- memcpy(_vm->_graphicsMan->_foreground.getPixels(), _vm->_graphicsMan->_background.getPixels(), 640 * 320);
+ memcpy(_vm->_graphicsMan->_foreground.getPixels(), _vm->_graphicsMan->_background.getPixels(), 640 * _vm->_graphicsMan->_foreground.h);
}
void Script::o_strcmpeqjmp() { // 0x23
@@ -1198,6 +1207,7 @@ void Script::o_copyrecttobg() { // 0x37
uint16 top = readScript16bits();
uint16 right = readScript16bits();
uint16 bottom = readScript16bits();
+ uint16 baseTop = (!_vm->_graphicsMan->isFullScreen()) ? 80 : 0;
// Sanity checks to prevent bad pointer access crashes
if (left > right) {
@@ -1216,9 +1226,9 @@ void Script::o_copyrecttobg() { // 0x37
bottom = top;
top = j;
}
- if (top < 80) {
- warning("COPYRECT top < 80... clamping");
- top = 80;
+ if (top < baseTop) {
+ warning("COPYRECT top < baseTop... clamping");
+ top = baseTop;
}
if (top >= 480) {
warning("COPYRECT top >= 480... clamping");
@@ -1243,13 +1253,13 @@ void Script::o_copyrecttobg() { // 0x37
debugC(1, kDebugScript, "COPYRECT((%d,%d)->(%d,%d))", left, top, right, bottom);
- fg = (byte *)_vm->_graphicsMan->_foreground.getBasePtr(left, top - 80);
- bg = (byte *)_vm->_graphicsMan->_background.getBasePtr(left, top - 80);
+ fg = (byte *)_vm->_graphicsMan->_foreground.getBasePtr(left, top - baseTop);
+ bg = (byte *)_vm->_graphicsMan->_background.getBasePtr(left, top - baseTop);
for (i = 0; i < height; i++) {
memcpy(bg + offset, fg + offset, width);
offset += 640;
}
- _vm->_system->copyRectToScreen(_vm->_graphicsMan->_background.getBasePtr(left, top - 80), 640, left, top, width, height);
+ _vm->_system->copyRectToScreen(_vm->_graphicsMan->_background.getBasePtr(left, top - baseTop), 640, left, top, width, height);
_vm->_graphicsMan->change();
}
@@ -1595,8 +1605,7 @@ void Script::o_hotspot_outrect() {
bool contained = rect.contains(mousepos);
if (!contained) {
- error("hotspot-outrect unimplemented");
- // TODO: what to do with address?
+ _currentInstruction = address;
}
}
@@ -1670,15 +1679,29 @@ void Script::o2_vdxtransition() {
void Script::o2_copyscreentobg() {
uint16 val = readScript16bits();
+ // TODO: Parameter
+ if (val)
+ warning("o2_copyscreentobg: Param is %d", val);
+
+ Graphics::Surface *screen = _vm->_system->lockScreen();
+ _vm->_graphicsMan->_background.copyFrom(screen->getSubArea(Common::Rect(0, 80, 640, 320)));
+ _vm->_system->unlockScreen();
+
debugC(1, kDebugScript, "CopyScreenToBG3: 0x%04X", val);
- error("Unimplemented Opcode 0x4F");
}
void Script::o2_copybgtoscreen() {
uint16 val = readScript16bits();
+ // TODO: Parameter
+ if (val)
+ warning("o2_copybgtoscreen: Param is %d", val);
+
+ Graphics::Surface *screen = _vm->_system->lockScreen();
+ _vm->_graphicsMan->_background.copyRectToSurface(*screen, 0, 80, Common::Rect(0, 0, 640, 320 - 80));
+ _vm->_system->unlockScreen();
+
debugC(1, kDebugScript, "CopyBG3ToScreen: 0x%04X", val);
- error("Unimplemented Opcode 0x50");
}
void Script::o2_setvideoskip() {
@@ -1686,6 +1709,12 @@ void Script::o2_setvideoskip() {
debugC(1, kDebugScript, "SetVideoSkip (0x%04X)", _videoSkipAddress);
}
+void Script::o2_stub42() {
+ uint8 arg = readScript8bits();
+ // TODO: Switch with 5 cases (0 - 5). Anything above 5 is a NOP
+ debugC(1, kDebugScript, "STUB42 (0x%02X)", arg);
+}
+
void Script::o2_stub52() {
uint8 arg = readScript8bits();
debugC(1, kDebugScript, "STUB52 (0x%02X)", arg);
@@ -1859,7 +1888,7 @@ Script::OpcodeFunc Script::_opcodesV2[NUM_OPCODES] = {
&Script::o_loadscript,
&Script::o_setvideoorigin, // 0x40
&Script::o_sub,
- &Script::o_cellmove,
+ &Script::o2_stub42,
&Script::o_returnscript,
&Script::o_sethotspotright, // 0x44
&Script::o_sethotspotleft,
diff --git a/engines/groovie/script.h b/engines/groovie/script.h
index 35e52593de..a9f6143509 100644
--- a/engines/groovie/script.h
+++ b/engines/groovie/script.h
@@ -238,6 +238,7 @@ private:
void o2_setvideoskip();
void o2_copyscreentobg();
void o2_copybgtoscreen();
+ void o2_stub42();
void o2_stub52();
void o2_setscriptend();
};
diff --git a/engines/hopkins/POTFILES b/engines/hopkins/POTFILES
new file mode 100644
index 0000000000..1ea7d5111b
--- /dev/null
+++ b/engines/hopkins/POTFILES
@@ -0,0 +1,2 @@
+engines/hopkins/detection.cpp
+
diff --git a/engines/hopkins/computer.cpp b/engines/hopkins/computer.cpp
index 84d5c631c7..18b16cb4c8 100644
--- a/engines/hopkins/computer.cpp
+++ b/engines/hopkins/computer.cpp
@@ -883,7 +883,7 @@ void ComputerManager::getScoreName() {
_vm->_graphicsMan->setColorPercentage(254, 0, 0, 0);
byte *ptr = _vm->_fileIO->loadFile("ALPHA.SPR");
_vm->_graphicsMan->fadeInBreakout();
-
+
// Figure out the line to put the new high score on
int scoreLine = 0;
while (scoreLine < 5 && _breakoutScore < atol(_score[scoreLine]._score.c_str()))
diff --git a/engines/hopkins/files.cpp b/engines/hopkins/files.cpp
index 6620f2878c..3100ed6cdc 100644
--- a/engines/hopkins/files.cpp
+++ b/engines/hopkins/files.cpp
@@ -74,7 +74,7 @@ int FileManager::readStream(Common::ReadStream &stream, void *buf, size_t nbytes
* It's now using the config manager and a per-engine GUI option.
*/
void FileManager::initCensorship() {
- _vm->_globals->_censorshipFl = ConfMan.getBool("enable_gore");
+ _vm->_globals->_censorshipFl = !ConfMan.getBool("enable_gore");
}
/**
diff --git a/engines/hopkins/sound.cpp b/engines/hopkins/sound.cpp
index 773c714899..6660233740 100644
--- a/engines/hopkins/sound.cpp
+++ b/engines/hopkins/sound.cpp
@@ -261,9 +261,9 @@ void SoundManager::loadAnimSound() {
}
}
-void SoundManager::playAnimSound(int soundNumber) {
+void SoundManager::playAnimSound(int animFrame) {
if (!_vm->_globals->_censorshipFl && _specialSoundNum == 2) {
- switch (soundNumber) {
+ switch (animFrame) {
case 20:
playSample(5);
break;
@@ -273,44 +273,59 @@ void SoundManager::playAnimSound(int soundNumber) {
playSample(1);
break;
case 75:
- playSample(2);
+ // This removes the sound of the gun played while the guard is being shot, as this part of the scene has been
+ // removed in the Polish version of the game
+ if (_vm->getLanguage() != Common::PL_POL)
+ playSample(2);
+ break;
+ case 95:
+ // This fixes an original bug in the Polish version of the game, which was literally butchered for some reason
+ if (_vm->getLanguage() == Common::PL_POL)
+ playSample(3);
break;
case 109:
- playSample(3);
+ if (_vm->getLanguage() != Common::PL_POL)
+ playSample(3);
+ break;
+ case 108:
+ // This fixes an original bug in the Polish version of the game, which was literally butchered for some reason
+ if (_vm->getLanguage() == Common::PL_POL)
+ playSample(4);
break;
case 122:
- playSample(4);
+ if (_vm->getLanguage() != Common::PL_POL)
+ playSample(4);
break;
}
- } else if (_specialSoundNum == 1 && soundNumber == 17)
+ } else if (_specialSoundNum == 1 && animFrame == 17)
playSoundFile("SOUND42.WAV");
- else if (_specialSoundNum == 5 && soundNumber == 19)
+ else if (_specialSoundNum == 5 && animFrame == 19)
playWav(1);
- else if (_specialSoundNum == 14 && soundNumber == 625)
+ else if (_specialSoundNum == 14 && animFrame == 625)
playWav(1);
- else if (_specialSoundNum == 16 && soundNumber == 25)
+ else if (_specialSoundNum == 16 && animFrame == 25)
playWav(1);
else if (_specialSoundNum == 17) {
- if (soundNumber == 6)
+ if (animFrame == 6)
playSample(1);
- else if (soundNumber == 14)
+ else if (animFrame == 14)
playSample(2);
- else if (soundNumber == 67)
+ else if (animFrame == 67)
playSample(3);
- } else if (_specialSoundNum == 198 && soundNumber == 15)
+ } else if (_specialSoundNum == 198 && animFrame == 15)
playWav(1);
- else if (_specialSoundNum == 199 && soundNumber == 72)
+ else if (_specialSoundNum == 199 && animFrame == 72)
playWav(1);
- else if (_specialSoundNum == 208 && soundNumber == 40)
+ else if (_specialSoundNum == 208 && animFrame == 40)
playWav(1);
- else if (_specialSoundNum == 210 && soundNumber == 2)
+ else if (_specialSoundNum == 210 && animFrame == 2)
playWav(1);
- else if (_specialSoundNum == 211 && soundNumber == 22)
+ else if (_specialSoundNum == 211 && animFrame == 22)
playWav(1);
else if (_specialSoundNum == 229) {
- if (soundNumber == 15)
+ if (animFrame == 15)
playWav(1);
- else if (soundNumber == 91)
+ else if (animFrame == 91)
playWav(2);
}
}
diff --git a/engines/hopkins/sound.h b/engines/hopkins/sound.h
index 97cdcdc1dd..1fb4f9ae71 100644
--- a/engines/hopkins/sound.h
+++ b/engines/hopkins/sound.h
@@ -116,7 +116,7 @@ public:
~SoundManager();
void loadAnimSound();
- void playAnimSound(int soundNumber);
+ void playAnimSound(int animFrame);
void loadSample(int wavIndex, const Common::String &file);
void playSample(int wavIndex, int voiceMode = 9);
diff --git a/engines/hopkins/talk.cpp b/engines/hopkins/talk.cpp
index df7b26c82c..00c4ab0332 100644
--- a/engines/hopkins/talk.cpp
+++ b/engines/hopkins/talk.cpp
@@ -68,7 +68,7 @@ void TalkManager::startAnimatedCharacterDialogue(const Common::String &filename)
getStringFromBuffer(40, spriteFilename, (const char *)_characterBuffer);
getStringFromBuffer(0, _questionsFilename, (const char *)_characterBuffer);
getStringFromBuffer(20, _answersFilename, (const char *)_characterBuffer);
-
+
switch (_vm->_globals->_language) {
case LANG_FR:
_answersFilename = _questionsFilename = "RUE.TXT";
diff --git a/engines/kyra/POTFILES b/engines/kyra/POTFILES
index 16888e2c5a..e5b380e52e 100644
--- a/engines/kyra/POTFILES
+++ b/engines/kyra/POTFILES
@@ -1,3 +1,4 @@
engines/kyra/detection.cpp
engines/kyra/lol.cpp
engines/kyra/sound_midi.cpp
+engines/kyra/saveload_eob.cpp
diff --git a/engines/kyra/detection_tables.h b/engines/kyra/detection_tables.h
index 1ada9a87ba..2ee0262ef2 100644
--- a/engines/kyra/detection_tables.h
+++ b/engines/kyra/detection_tables.h
@@ -1568,6 +1568,22 @@ const KYRAGameDescription adGameDescs[] = {
EOB_FLAGS
},
+ { // Italian fan translation
+ {
+ "eob",
+ 0,
+ {
+ { "EOBDATA3.PAK", 0, "3ed915ab5b94d60dbfe1b55379889c51", -1 },
+ { 0, 0, 0, 0 }
+ },
+ Common::IT_ITA,
+ Common::kPlatformDOS,
+ ADGF_TESTING,
+ GUIO7(GUIO_NOSPEECH, GUIO_MIDIADLIB, GUIO_MIDIPCSPK, GUIO_RENDERVGA, GUIO_RENDEREGA, GUIO_RENDERCGA, GAMEOPTION_EOB_HPGRAPHS)
+ },
+ EOB_FLAGS
+ },
+
{
{
"eob2",
diff --git a/engines/kyra/staticres.cpp b/engines/kyra/staticres.cpp
index 9b3b92b9c7..731f2f4ce5 100644
--- a/engines/kyra/staticres.cpp
+++ b/engines/kyra/staticres.cpp
@@ -39,7 +39,7 @@
namespace Kyra {
-#define RESFILE_VERSION 85
+#define RESFILE_VERSION 86
namespace {
bool checkKyraDat(Common::SeekableReadStream *file) {
diff --git a/engines/kyra/staticres_eob.cpp b/engines/kyra/staticres_eob.cpp
index 54cc3066ec..aa7adc7461 100644
--- a/engines/kyra/staticres_eob.cpp
+++ b/engines/kyra/staticres_eob.cpp
@@ -464,20 +464,34 @@ void EoBCoreEngine::initStaticResource() {
// EOB I doesn't have load and save menus, because there is only one single
// save slot. Instead of emulating this we provide a menu similiar to EOB II.
- static const char *const saveLoadStrings[3][4] = {
- { "Cancel", "Empty Slot", "Save Game", "Load Game" },
- { "Abbr.", "Leerer Slot", "Speichern", " Laden" },
- { 0, 0, 0, 0 }
+ static const char *const saveLoadStrings[4][4] = {
+ { "Cancel", "Empty Slot", "Save Game", "Load Game" },
+ { "Abbr.", "Leerer Slot", "Speichern", " Laden" },
+ { " < < ", "Posizione Vuota", "Salva", "Carica" },
+ { 0, 0, 0, 0 }
};
- static const char *const errorSlotEmptyString[3] = {
+ static const char *const errorSlotEmptyString[4] = {
"There is no game\rsaved in that slot!",
"Hier ist noch kein\rSpiel gespeichert!",
+ "Non c'\x0E alcun gioco\rsalvato in quella\rposizione!",
0
};
- _saveLoadStrings = saveLoadStrings[(_flags.lang == Common::EN_ANY) ? 0 : ((_flags.lang == Common::DE_DEU) ? 1 : 2)];
- _errorSlotEmptyString = errorSlotEmptyString[(_flags.lang == Common::EN_ANY) ? 0 : ((_flags.lang == Common::DE_DEU) ? 1 : 2)];
+ if (_flags.lang == Common::EN_ANY) {
+ _saveLoadStrings = saveLoadStrings[0];
+ _errorSlotEmptyString = errorSlotEmptyString[0];
+ } else if (_flags.lang == Common::DE_DEU) {
+ _saveLoadStrings = saveLoadStrings[1];
+ _errorSlotEmptyString = errorSlotEmptyString[1];
+ } else if (_flags.lang == Common::IT_ITA) {
+ _saveLoadStrings = saveLoadStrings[2];
+ _errorSlotEmptyString = errorSlotEmptyString[2];
+ } else {
+ _saveLoadStrings = saveLoadStrings[3];
+ _errorSlotEmptyString = errorSlotEmptyString[3];
+ }
+
_menuOkString = "OK";
}
diff --git a/engines/kyra/text_rpg.cpp b/engines/kyra/text_rpg.cpp
index 03acde8497..5cd99738ef 100644
--- a/engines/kyra/text_rpg.cpp
+++ b/engines/kyra/text_rpg.cpp
@@ -30,7 +30,7 @@
namespace Kyra {
enum {
- kEoBTextBufferSize = 2048
+ kEoBTextBufferSize = 2560
};
TextDisplayer_rpg::TextDisplayer_rpg(KyraRpgEngine *engine, Screen *scr) : _vm(engine), _screen(scr),
@@ -216,7 +216,7 @@ void TextDisplayer_rpg::displayText(char *str, ...) {
break;
default:
- if (_vm->game() == GI_LOL || (unsigned char)c > 30) {
+ if (_vm->game() == GI_EOB1 || _vm->game() == GI_LOL || (unsigned char)c > 30) {
_lineWidth += (sjisTextMode ? 4 : (_screen->_currentFont == Screen::FID_SJIS_FNT ? 9 : _screen->getCharWidth((uint8)c)));
_currentLine[_numCharsLeft++] = c;
_currentLine[_numCharsLeft] = 0;
diff --git a/engines/kyra/vqa.cpp b/engines/kyra/vqa.cpp
index fb51c05e51..cfd5f6ffc6 100644
--- a/engines/kyra/vqa.cpp
+++ b/engines/kyra/vqa.cpp
@@ -532,7 +532,7 @@ void VQADecoder::VQAVideoTrack::handleVQFR(Common::SeekableReadStream *stream) {
uint32 tag = readTag(stream);
uint32 i;
size = stream->readUint32BE();
-
+
switch (tag) {
case MKTAG('C','B','F','0'): // Full codebook
stream->read(_codeBook, size);
diff --git a/engines/mads/animation.cpp b/engines/mads/animation.cpp
index 512a3979f9..2b999fa305 100644
--- a/engines/mads/animation.cpp
+++ b/engines/mads/animation.cpp
@@ -32,10 +32,8 @@ void AAHeader::load(Common::SeekableReadStream *f) {
_miscEntriesCount = f->readUint16LE();
_frameEntriesCount = f->readUint16LE();
_messagesCount = f->readUint16LE();
- f->skip(1);
- _flags = f->readByte();
-
- f->skip(2);
+ _loadFlags = f->readUint16LE();
+ _charSpacing = f->readSint16LE();
_bgType = (AnimBgType)f->readUint16LE();
_roomNumber = f->readUint16LE();
f->skip(2);
@@ -49,7 +47,7 @@ void AAHeader::load(Common::SeekableReadStream *f) {
char buffer[FILENAME_SIZE];
f->read(buffer, FILENAME_SIZE);
buffer[FILENAME_SIZE - 1] = '\0';
- _interfaceFile = Common::String(buffer);
+ _backgroundFile = Common::String(buffer);
for (int i = 0; i < 50; ++i) {
f->read(buffer, FILENAME_SIZE);
@@ -134,7 +132,8 @@ void AnimMiscEntry::load(Common::SeekableReadStream *f) {
_numTicks = f->readUint16LE();
_posAdjust.x = f->readSint16LE();
_posAdjust.y = f->readSint16LE();
- _field8 = f->readUint16LE();
+ _scroll.x = f->readSByte();
+ _scroll.y = f->readSByte();
}
/*------------------------------------------------------------------------*/
@@ -160,6 +159,7 @@ Animation *Animation::init(MADSEngine *vm, Scene *scene) {
}
Animation::Animation(MADSEngine *vm, Scene *scene) : _vm(vm), _scene(scene) {
+ _flags = 0;
_font = nullptr;
_resetFlag = false;
_messageCtr = 0;
@@ -175,6 +175,8 @@ Animation::Animation(MADSEngine *vm, Scene *scene) : _vm(vm), _scene(scene) {
_actionDetails._indirectObjectId = -1;
_currentFrame = 0;
_oldFrameEntry = 0;
+ _rgbResult = -1;
+ _palIndex1 = _palIndex2 = -1;
}
Animation::~Animation() {
@@ -189,7 +191,7 @@ Animation::~Animation() {
}
}
-void Animation::load(UserInterface &interfaceSurface, DepthSurface &depthSurface,
+void Animation::load(MSurface &backSurface, DepthSurface &depthSurface,
const Common::String &resName, int flags, Common::Array<PaletteCycle> *palCycles,
SceneInfo *sceneInfo) {
Common::String resourceName = resName;
@@ -205,9 +207,10 @@ void Animation::load(UserInterface &interfaceSurface, DepthSurface &depthSurface
if (_header._bgType == ANIMBG_INTERFACE)
flags |= PALFLAG_RESERVED;
+ _flags = flags;
if (flags & ANIMFLAG_LOAD_BACKGROUND) {
- loadInterface(interfaceSurface, depthSurface, _header, flags, palCycles, sceneInfo);
+ loadBackground(backSurface, depthSurface, _header, flags, palCycles, sceneInfo);
}
if (flags & ANIMFLAG_LOAD_BACKGROUND_ONLY) {
// No data
@@ -243,7 +246,7 @@ void Animation::load(UserInterface &interfaceSurface, DepthSurface &depthSurface
for (int i = 0; i < _header._frameEntriesCount; i++) {
AnimFrameEntry rec;
- rec.load(frameStream, flags & ANIMFLAG_LOAD_BACKGROUND);
+ rec.load(frameStream, _header._bgType == ANIMBG_INTERFACE);
_frameEntries.push_back(rec);
}
@@ -256,7 +259,7 @@ void Animation::load(UserInterface &interfaceSurface, DepthSurface &depthSurface
// Chunk 4: Misc Data
Common::SeekableReadStream *miscStream = madsPack.getItemStream(streamIndex++);
- if (flags & ANIMFLAG_LOAD_BACKGROUND) {
+ if (_header._bgType == ANIMBG_INTERFACE) {
for (int i = 0; i < _header._miscEntriesCount; ++i) {
AnimUIEntry rec;
rec.load(miscStream);
@@ -275,7 +278,7 @@ void Animation::load(UserInterface &interfaceSurface, DepthSurface &depthSurface
// If the animation specifies a font, then load it for access
delete _font;
- if (_header._flags & ANIMFLAG_CUSTOM_FONT) {
+ if (_header._loadFlags & ANIMFLAG_CUSTOM_FONT) {
Common::String fontName = "*" + _header._fontResource;
_font = _vm->_font->getFont(fontName.c_str());
} else {
@@ -337,9 +340,6 @@ void Animation::startAnimation(int endTrigger) {
_unkIndex = -1;
//SpriteAsset *asset = _scene->_sprites[_spriteListIndexes[_header._spritesIndex]];
- // TODO: Weird stuff with _unkList. Seems like it's treated as pointers
- // here, but in processText, it's used as POINTs?
-
loadFrame(1);
}
@@ -385,12 +385,12 @@ bool Animation::drawFrame(SpriteAsset &spriteSet, const Common::Point &pt, int f
return 0;
}
-void Animation::loadInterface(UserInterface &interfaceSurface, DepthSurface &depthSurface,
+void Animation::loadBackground(MSurface &backSurface, DepthSurface &depthSurface,
AAHeader &header, int flags, Common::Array<PaletteCycle> *palCycles, SceneInfo *sceneInfo) {
_scene->_depthStyle = 0;
if (header._bgType <= ANIMBG_FULL_SIZE) {
_vm->_palette->_paletteUsage.setEmpty();
- sceneInfo->load(header._roomNumber, flags, header._interfaceFile, 0, depthSurface, interfaceSurface);
+ sceneInfo->load(header._roomNumber, 0, header._backgroundFile, flags, depthSurface, backSurface);
_scene->_depthStyle = sceneInfo->_depthStyle == 2 ? 1 : 0;
if (palCycles) {
palCycles->clear();
@@ -399,8 +399,8 @@ void Animation::loadInterface(UserInterface &interfaceSurface, DepthSurface &dep
}
} else if (header._bgType == ANIMBG_INTERFACE) {
// Load a scene interface
- Common::String resourceName = "*" + header._interfaceFile;
- interfaceSurface.load(resourceName);
+ Common::String resourceName = "*" + header._backgroundFile;
+ backSurface.load(resourceName);
if (palCycles)
palCycles->clear();
@@ -415,6 +415,7 @@ bool Animation::hasScroll() const {
void Animation::update() {
Scene &scene = _vm->_game->_scene;
+ Palette &palette = *_vm->_palette;
if (_header._manualFlag) {
int spriteListIndex = _spriteListIndexes[_header._spritesIndex];
@@ -534,28 +535,43 @@ void Animation::update() {
// Start displaying the message
AnimMessage &me = _messages[idx];
- // The color index to use is dependant on how many messages are currently on-screen
- uint8 colIndex;
- switch (_messageCtr) {
- case 1:
- colIndex = 252;
- break;
- case 2:
- colIndex = 16;
- break;
- default:
- colIndex = 250;
- break;
- }
+ if (_flags & ANIMFLAG_ANIMVIEW) {
+ _rgbResult = palette._paletteUsage.checkRGB(me._rgb1, -1, true, &_palIndex1);
+ _rgbResult = palette._paletteUsage.checkRGB(me._rgb2, _rgbResult, true, &_palIndex2);
+
+ // Update the palette with the two needed colors
+ int palStart = MIN(_palIndex1, _palIndex2);
+ int palCount = ABS(_palIndex2 - _palIndex1) + 1;
+ palette.setPalette(&palette._mainPalette[palStart * 3], palStart, palCount);
+ } else {
+ // The color index to use is dependant on how many messages are currently on-screen
+ switch (_messageCtr) {
+ case 1:
+ _palIndex1 = 252;
+ break;
+ case 2:
+ _palIndex1 = 16;
+ break;
+ default:
+ _palIndex1 = 250;
+ break;
+ }
+ _palIndex2 = _palIndex1 + 1;
- _vm->_palette->setEntry(colIndex, me._rgb1[0], me._rgb1[1], me._rgb1[2]);
- _vm->_palette->setEntry(colIndex + 1, me._rgb2[0], me._rgb2[1], me._rgb2[2]);
+ _vm->_palette->setEntry(_palIndex1, me._rgb1[0], me._rgb1[1], me._rgb1[2]);
+ _vm->_palette->setEntry(_palIndex2, me._rgb2[0], me._rgb2[1], me._rgb2[2]);
+ }
// Add a kernel message to display the given text
- me._kernelMsgIndex = scene._kernelMessages.add(me._pos, colIndex * 0x101 + 0x100,
+ me._kernelMsgIndex = scene._kernelMessages.add(me._pos,
+ _palIndex1 | (_palIndex2 << 8),
0, 0, INDEFINITE_TIMEOUT, me._msg);
assert(me._kernelMsgIndex >= 0);
++_messageCtr;
+
+ // If there's an accompanying sound, also play it
+ if (me._soundId > 0)
+ _vm->_audio->playSound(me._soundId - 1);
}
}
diff --git a/engines/mads/animation.h b/engines/mads/animation.h
index 15086d3e41..8b85a5370d 100644
--- a/engines/mads/animation.h
+++ b/engines/mads/animation.h
@@ -34,10 +34,11 @@
namespace MADS {
enum AnimFlag {
- ANIMFLAG_DITHER = 0x0001, // Dither to 16 colors
- ANIMFLAG_CUSTOM_FONT = 0x0020, // Load ccustom font
+ ANIMFLAG_DITHER = 0x1000, // Dither to 16 colors
+ ANIMFLAG_CUSTOM_FONT = 0x2000, // Load ccustom font
ANIMFLAG_LOAD_BACKGROUND = 0x0100, // Load background
- ANIMFLAG_LOAD_BACKGROUND_ONLY = 0x0200 // Load background only
+ ANIMFLAG_LOAD_BACKGROUND_ONLY = 0x0200, // Load background only
+ ANIMFLAG_ANIMVIEW = 0x4000 // Cutscene animation
};
enum AnimBgType {
@@ -82,7 +83,7 @@ public:
int _msgIndex;
int _numTicks;
Common::Point _posAdjust;
- int _field8;
+ Common::Point _scroll;
/**
* Loads data for the record
@@ -116,14 +117,15 @@ public:
int _miscEntriesCount;
int _frameEntriesCount;
int _messagesCount;
- byte _flags;
+ int _loadFlags;
+ int _charSpacing;
AnimBgType _bgType;
int _roomNumber;
bool _manualFlag;
int _spritesIndex;
Common::Point _scrollPosition;
uint32 _scrollTicks;
- Common::String _interfaceFile;
+ Common::String _backgroundFile;
Common::StringArray _spriteSetNames;
Common::String _lbmFilename;
Common::String _spritesFilename;
@@ -154,6 +156,9 @@ private:
uint32 _nextScrollTimer;
int _messageCtr;
int _trigger;
+ int _flags;
+ int _rgbResult;
+ int _palIndex1, _palIndex2;
TriggerMode _triggerMode;
ActionDetails _actionDetails;
@@ -166,9 +171,9 @@ private:
bool drawFrame(SpriteAsset &spriteSet, const Common::Point &pt, int frameNumber);
/**
- * Load the user interface display for an animation
+ * Load the user interface display or background for an animation
*/
- void loadInterface(UserInterface &interfaceSurface, DepthSurface &depthSurface,
+ void loadBackground(MSurface &backSurface, DepthSurface &depthSurface,
AAHeader &header, int flags, Common::Array<PaletteCycle> *palCycles, SceneInfo *sceneInfo);
/**
@@ -196,7 +201,7 @@ public:
/**
* Loads animation data
*/
- void load(UserInterface &interfaceSurface, DepthSurface &depthSurface, const Common::String &resName,
+ void load(MSurface &backSurface, DepthSurface &depthSurface, const Common::String &resName,
int flags, Common::Array<PaletteCycle> *palCycles, SceneInfo *sceneInfo);
/**
@@ -223,6 +228,8 @@ public:
int roomNumber() const { return _header._roomNumber; }
void resetSpriteSetsCount() { _header._spriteSetsCount = 0; } // CHECKME: See if it doesn't leak the memory when the destructor is called
+
+ SpriteAsset *getSpriteSet(int idx) { return _spriteSets[idx]; }
};
} // End of namespace MADS
diff --git a/engines/mads/audio.cpp b/engines/mads/audio.cpp
index 1c61e13957..def2cd6c62 100644
--- a/engines/mads/audio.cpp
+++ b/engines/mads/audio.cpp
@@ -37,6 +37,7 @@ AudioPlayer::AudioPlayer(Audio::Mixer *mixer, uint32 gameID) : _mixer(mixer), _g
AudioPlayer::~AudioPlayer() {
_dsrEntries.clear();
+ _filename = "";
}
bool AudioPlayer::isPlaying() const {
@@ -65,25 +66,27 @@ void AudioPlayer::setDefaultSoundGroup() {
}
void AudioPlayer::setSoundGroup(const Common::String &filename) {
- _dsrEntries.clear();
-
- _filename = filename;
- _dsrFile.open(filename);
-
- // Read header
- uint16 entryCount = _dsrFile.readUint16LE();
-
- for (uint16 i = 0; i < entryCount; i++) {
- DSREntry newEntry;
- newEntry.frequency = _dsrFile.readUint16LE();
- newEntry.channels = _dsrFile.readUint32LE();
- newEntry.compSize = _dsrFile.readUint32LE();
- newEntry.uncompSize = _dsrFile.readUint32LE();
- newEntry.offset = _dsrFile.readUint32LE();
- _dsrEntries.push_back(newEntry);
+ if (_filename != filename) {
+ _dsrEntries.clear();
+
+ _filename = filename;
+ _dsrFile.open(filename);
+
+ // Read header
+ uint16 entryCount = _dsrFile.readUint16LE();
+
+ for (uint16 i = 0; i < entryCount; i++) {
+ DSREntry newEntry;
+ newEntry.frequency = _dsrFile.readUint16LE();
+ newEntry.channels = _dsrFile.readUint32LE();
+ newEntry.compSize = _dsrFile.readUint32LE();
+ newEntry.uncompSize = _dsrFile.readUint32LE();
+ newEntry.offset = _dsrFile.readUint32LE();
+ _dsrEntries.push_back(newEntry);
+ }
+
+ _dsrFile.close();
}
-
- _dsrFile.close();
}
void AudioPlayer::playSound(int soundIndex, bool loop) {
@@ -126,4 +129,8 @@ void AudioPlayer::playSound(int soundIndex, bool loop) {
*/
}
+void AudioPlayer::stop() {
+ _mixer->stopHandle(_handle);
+}
+
} // End of namespace M4
diff --git a/engines/mads/audio.h b/engines/mads/audio.h
index 21f4bed59a..13c540bf85 100644
--- a/engines/mads/audio.h
+++ b/engines/mads/audio.h
@@ -46,6 +46,7 @@ public:
void setSoundGroup(const Common::String &filename);
void setDefaultSoundGroup();
void playSound(int soundIndex, bool loop = false);
+ void stop();
void setVolume(int volume);
bool isPlaying() const;
diff --git a/engines/mads/debugger.cpp b/engines/mads/debugger.cpp
index 6bc6cf572d..99251f9fbb 100644
--- a/engines/mads/debugger.cpp
+++ b/engines/mads/debugger.cpp
@@ -24,6 +24,7 @@
#include "mads/compression.h"
#include "mads/mads.h"
#include "mads/debugger.h"
+#include "mads/nebular/menu_nebular.h"
namespace MADS {
@@ -46,6 +47,8 @@ Debugger::Debugger(MADSEngine *vm) : GUI::Debugger(), _vm(vm) {
registerCmd("show_item", WRAP_METHOD(Debugger, Cmd_ShowItem));
registerCmd("dump_items", WRAP_METHOD(Debugger, Cmd_DumpItems));
registerCmd("item", WRAP_METHOD(Debugger, Cmd_Item));
+ registerCmd("play_anim", WRAP_METHOD(Debugger, Cmd_PlayAnim));
+ registerCmd("play_text", WRAP_METHOD(Debugger, Cmd_PlayText));
}
static int strToInt(const char *s) {
@@ -348,4 +351,44 @@ bool Debugger::Cmd_Item(int argc, const char **argv) {
}
}
+bool Debugger::Cmd_PlayAnim(int argc, const char **argv) {
+ if (argc != 2) {
+ debugPrintf("Usage: %s <anim name>\n", argv[0]);
+ return true;
+ } else {
+ Common::String resName = argv[1];
+ if (resName.hasPrefix("@"))
+ resName.deleteChar(0);
+
+ Common::File f;
+ if (f.exists(resName) || f.exists(resName + ".res")) {
+ AnimationView::execute(_vm, resName);
+ return false;
+ } else {
+ debugPrintf("Could not find resource file\n");
+ return true;
+ }
+ }
+}
+
+bool Debugger::Cmd_PlayText(int argc, const char **argv) {
+ if (argc != 2) {
+ debugPrintf("Usage: %s <text name>\n", argv[0]);
+ return true;
+ } else {
+ Common::String resName = argv[1];
+ if (resName.hasPrefix("@"))
+ resName.deleteChar(0);
+
+ Common::File f;
+ if (f.exists(resName) || f.exists(resName + ".txr")) {
+ TextView::execute(_vm, resName);
+ return false;
+ } else {
+ debugPrintf("Could not find resource file\n");
+ return true;
+ }
+ }
+}
+
} // End of namespace MADS
diff --git a/engines/mads/debugger.h b/engines/mads/debugger.h
index 351eb13615..c8fee5f5b2 100644
--- a/engines/mads/debugger.h
+++ b/engines/mads/debugger.h
@@ -49,6 +49,8 @@ protected:
bool Cmd_ShowItem(int argc, const char **argv);
bool Cmd_DumpItems(int argc, const char **argv);
bool Cmd_Item(int argc, const char **argv);
+ bool Cmd_PlayAnim(int argc, const char **argv);
+ bool Cmd_PlayText(int argc, const char **argv);
public:
bool _showMousePos;
public:
diff --git a/engines/mads/dialogs.cpp b/engines/mads/dialogs.cpp
index 7e6909d113..5e38f34fc6 100644
--- a/engines/mads/dialogs.cpp
+++ b/engines/mads/dialogs.cpp
@@ -395,4 +395,78 @@ Dialogs::Dialogs(MADSEngine *vm)
_pendingDialog = DIALOG_NONE;
}
+/*------------------------------------------------------------------------*/
+
+FullScreenDialog::FullScreenDialog(MADSEngine *vm) : _vm(vm) {
+ switch (_vm->getGameID()) {
+ case GType_RexNebular:
+ _screenId = 990;
+ break;
+ case GType_Phantom:
+ _screenId = 920;
+ break;
+ case GType_Dragonsphere:
+ _screenId = 922;
+ break;
+ default:
+ error("FullScreenDialog:Unknown game");
+ }
+ _palFlag = true;
+}
+
+FullScreenDialog::~FullScreenDialog() {
+ _vm->_screen.resetClipBounds();
+ _vm->_game->_scene.restrictScene();
+}
+
+void FullScreenDialog::display() {
+ Game &game = *_vm->_game;
+ Scene &scene = game._scene;
+
+ int nextSceneId = scene._nextSceneId;
+ int currentSceneId = scene._currentSceneId;
+ int priorSceneId = scene._priorSceneId;
+
+ if (_screenId > 0) {
+ SceneInfo *sceneInfo = SceneInfo::init(_vm);
+ sceneInfo->load(_screenId, 0, "", 0, scene._depthSurface, scene._backgroundSurface);
+ }
+
+ scene._priorSceneId = priorSceneId;
+ scene._currentSceneId = currentSceneId;
+ scene._nextSceneId = nextSceneId;
+
+ _vm->_events->initVars();
+ game._kernelMode = KERNEL_ROOM_INIT;
+
+ byte pal[768];
+ if (_vm->_screenFade) {
+ Common::fill(&pal[0], &pal[PALETTE_SIZE], 0);
+ _vm->_palette->setFullPalette(pal);
+ } else {
+ _vm->_palette->getFullPalette(pal);
+ _vm->_palette->fadeOut(pal, nullptr, 0, PALETTE_COUNT, 0, 1, 1, 16);
+ }
+
+ // Set Fx state and palette entries
+ game._fx = _vm->_screenFade == SCREEN_FADE_SMOOTH ? kTransitionFadeIn : kCenterVertTransition;
+ game._trigger = 0;
+
+ // Clear the screen and draw the upper and lower horizontal lines
+ _vm->_screen.empty();
+ _vm->_palette->setLowRange();
+ _vm->_screen.hLine(0, 20, MADS_SCREEN_WIDTH, 2);
+ _vm->_screen.hLine(0, 179, MADS_SCREEN_WIDTH, 2);
+ _vm->_screen.resetClipBounds();
+ _vm->_screen.copyRectToScreen(Common::Rect(0, 0, MADS_SCREEN_WIDTH, MADS_SCREEN_HEIGHT));
+
+ // Restrict the screen to the area between the two lines
+ _vm->_screen.setClipBounds(Common::Rect(0, DIALOG_TOP, MADS_SCREEN_WIDTH,
+ DIALOG_TOP + MADS_SCENE_HEIGHT));
+ _vm->_game->_scene.restrictScene();
+
+ if (_screenId > 0)
+ scene._spriteSlots.fullRefresh();
+}
+
} // End of namespace MADS
diff --git a/engines/mads/dialogs.h b/engines/mads/dialogs.h
index c586a6f1fe..317c7bd792 100644
--- a/engines/mads/dialogs.h
+++ b/engines/mads/dialogs.h
@@ -30,6 +30,8 @@
namespace MADS {
+#define DIALOG_TOP 22
+
class Dialog {
private:
void setDialogPalette();
@@ -226,6 +228,36 @@ public:
virtual bool show(int messageId, int objectId = -1) = 0;
};
+class FullScreenDialog: public EventTarget {
+protected:
+ /**
+ * Engine reference
+ */
+ MADSEngine *_vm;
+
+ /**
+ * Screen/scene to show background from
+ */
+ int _screenId;
+
+ /**
+ * Flag for palette initialization
+ */
+ bool _palFlag;
+
+ /**
+ * Handles displaying the screen background and dialog
+ */
+ virtual void display();
+public:
+ /**
+ * Constructor
+ */
+ FullScreenDialog(MADSEngine *vm);
+
+ virtual ~FullScreenDialog();
+};
+
} // End of namespace MADS
#endif /* MADS_DIALOGS_H */
diff --git a/engines/mads/game.cpp b/engines/mads/game.cpp
index b544eff2db..94653f9a39 100644
--- a/engines/mads/game.cpp
+++ b/engines/mads/game.cpp
@@ -433,8 +433,6 @@ void Game::handleKeypress(const Common::Event &event) {
default:
break;
}
-
- warning("TODO: handleKeypress - %d", (int)event.kbd.keycode);
}
void Game::synchronize(Common::Serializer &s, bool phase1) {
@@ -558,7 +556,7 @@ void Game::writeSavegameHeader(Common::OutSaveFile *out, MADSSavegameHeader &hea
if (!_saveThumb)
createThumbnail();
Graphics::saveThumbnail(*out, *_saveThumb);
-
+
_saveThumb->free();
delete _saveThumb;
_saveThumb = nullptr;
diff --git a/engines/mads/mads.cpp b/engines/mads/mads.cpp
index d56994ab8e..52a0b40561 100644
--- a/engines/mads/mads.cpp
+++ b/engines/mads/mads.cpp
@@ -55,7 +55,6 @@ MADSEngine::MADSEngine(OSystem *syst, const MADSGameDescription *gameDesc) :
_resources = nullptr;
_sound = nullptr;
_audio = nullptr;
- _opl = nullptr;
}
MADSEngine::~MADSEngine() {
@@ -71,7 +70,6 @@ MADSEngine::~MADSEngine() {
delete _audio;
_mixer->stopAll();
- delete _opl;
}
void MADSEngine::initialize() {
@@ -80,9 +78,6 @@ void MADSEngine::initialize() {
DebugMan.addDebugChannel(kDebugScripts, "scripts", "Game scripts");
DebugMan.addDebugChannel(kDebugGraphics, "graphics", "Graphics handling");
- _opl = OPL::Config::create();
- _opl->init(11025);
-
// Initial sub-system engine references
MSurface::setVm(this);
MSprite::setVm(this);
@@ -96,7 +91,7 @@ void MADSEngine::initialize() {
Font::init(this);
_font = new Font();
_screen.init();
- _sound = new SoundManager(this, _mixer, _opl);
+ _sound = new SoundManager(this, _mixer);
_audio = new AudioPlayer(_mixer, getGameID());
_game = Game::init(this);
diff --git a/engines/mads/mads.h b/engines/mads/mads.h
index 8fc2788c28..9a8f2152a1 100644
--- a/engines/mads/mads.h
+++ b/engines/mads/mads.h
@@ -99,7 +99,6 @@ public:
ScreenSurface _screen;
SoundManager *_sound;
AudioPlayer *_audio;
- FM_OPL *_opl;
bool _easyMouse;
bool _invObjectsAnimated;
bool _textWindowStill;
diff --git a/engines/mads/menu_views.cpp b/engines/mads/menu_views.cpp
new file mode 100644
index 0000000000..ee4268a650
--- /dev/null
+++ b/engines/mads/menu_views.cpp
@@ -0,0 +1,768 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public 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 "mads/game.h"
+#include "mads/mads.h"
+#include "mads/menu_views.h"
+#include "mads/resources.h"
+#include "mads/scene.h"
+#include "mads/screen.h"
+
+namespace MADS {
+
+MenuView::MenuView(MADSEngine *vm) : FullScreenDialog(vm) {
+ _breakFlag = false;
+ _redrawFlag = true;
+ _palFlag = false;
+}
+
+void MenuView::show() {
+ Scene &scene = _vm->_game->_scene;
+ EventsManager &events = *_vm->_events;
+ _vm->_screenFade = SCREEN_FADE_FAST;
+
+ scene._spriteSlots.reset(true);
+ display();
+
+ events.setEventTarget(this);
+ events.hideCursor();
+
+ while (!_breakFlag && !_vm->shouldQuit()) {
+ if (_redrawFlag) {
+ scene._kernelMessages.update();
+
+ _vm->_game->_scene.drawElements(_vm->_game->_fx, _vm->_game->_fx);
+ _redrawFlag = false;
+ }
+
+ _vm->_events->waitForNextFrame();
+ _vm->_game->_fx = kTransitionNone;
+ doFrame();
+ }
+
+ events.setEventTarget(nullptr);
+ _vm->_sound->stop();
+}
+
+void MenuView::display() {
+ _vm->_palette->resetGamePalette(4, 8);
+
+ FullScreenDialog::display();
+}
+
+bool MenuView::onEvent(Common::Event &event) {
+ if (event.type == Common::EVENT_KEYDOWN || event.type == Common::EVENT_LBUTTONDOWN) {
+ _breakFlag = true;
+ _vm->_dialogs->_pendingDialog = DIALOG_MAIN_MENU;
+ return true;
+ }
+
+ return false;
+}
+
+Common::String MenuView::getResourceName() {
+ Common::String s(_filename);
+ s.toLowercase();
+ while (s.contains('.'))
+ s.deleteLastChar();
+
+ return s;
+}
+
+/*------------------------------------------------------------------------*/
+
+char TextView::_resourceName[100];
+#define TEXTVIEW_LINE_SPACING 2
+#define TEXT_ANIMATION_DELAY 100
+#define TV_NUM_FADE_STEPS 40
+#define TV_FADE_DELAY_MILLI 50
+
+void TextView::execute(MADSEngine *vm, const Common::String &resName) {
+ assert(resName.size() < 100);
+ Common::strlcpy(_resourceName, resName.c_str(), sizeof(_resourceName));
+ vm->_dialogs->_pendingDialog = DIALOG_TEXTVIEW;
+}
+
+TextView::TextView(MADSEngine *vm) : MenuView(vm) {
+ _animating = false;
+ _panSpeed = 0;
+ _spareScreen = nullptr;
+ _scrollCount = 0;
+ _lineY = -1;
+ _scrollTimeout = 0;
+ _panCountdown = 0;
+ _translationX = 0;
+ _screenId = -1;
+
+ _font = _vm->_font->getFont(FONT_CONVERSATION);
+ _vm->_palette->resetGamePalette(4, 0);
+
+ load();
+}
+
+TextView::~TextView() {
+ // Turn off palette cycling as well as any playing sound
+ Scene &scene = _vm->_game->_scene;
+ scene._cyclingActive = false;
+ _vm->_sound->stop();
+}
+
+void TextView::load() {
+ Common::String scriptName(_resourceName);
+ scriptName += ".txr";
+
+ _filename = scriptName;
+ if (!_script.open(scriptName))
+ error("Could not open resource %s", _resourceName);
+
+ processLines();
+}
+
+void TextView::processLines() {
+ if (_script.eos())
+ error("Attempted to read past end of response file");
+
+ while (!_script.eos()) {
+ // Read in the next line
+ _script.readLine(_currentLine, 79);
+ char *p = _currentLine + strlen(_currentLine) - 1;
+ if (*p == '\n')
+ *p = '\0';
+
+ // Commented out line, so go loop for another
+ if (_currentLine[0] == '#')
+ continue;
+
+ // Process the line
+ char *cStart = strchr(_currentLine, '[');
+ if (cStart) {
+ while (cStart) {
+ // Loop for possible multiple commands on one line
+ char *cEnd = strchr(_currentLine, ']');
+ if (!cEnd)
+ error("Unterminated command '%s' in response file", _currentLine);
+
+ *cEnd = '\0';
+ processCommand();
+
+ // Copy rest of line (if any) to start of buffer
+ Common::strlcpy(_currentLine, cEnd + 1, sizeof(_currentLine));
+
+ cStart = strchr(_currentLine, '[');
+ }
+
+ if (_currentLine[0]) {
+ processText();
+ break;
+ }
+
+ } else {
+ processText();
+ break;
+ }
+ }
+}
+
+void TextView::processCommand() {
+ Scene &scene = _vm->_game->_scene;
+ Common::String scriptLine(_currentLine + 1);
+ scriptLine.toUppercase();
+ const char *paramP;
+ const char *commandStr = scriptLine.c_str();
+
+ if (!strncmp(commandStr, "BACKGROUND", 10)) {
+ // Set the background
+ paramP = commandStr + 10;
+ resetPalette();
+ int screenId = getParameter(&paramP);
+
+ SceneInfo *sceneInfo = SceneInfo::init(_vm);
+ sceneInfo->load(screenId, 0, "", 0, scene._depthSurface, scene._backgroundSurface);
+ scene._spriteSlots.fullRefresh();
+ _redrawFlag = true;
+
+ } else if (!strncmp(commandStr, "GO", 2)) {
+ _animating = true;
+
+ } else if (!strncmp(commandStr, "PAN", 3)) {
+ // Set panning values
+ paramP = commandStr + 3;
+ int panX = getParameter(&paramP);
+ int panY = getParameter(&paramP);
+ int panSpeed = getParameter(&paramP);
+
+ if ((panX != 0) || (panY != 0)) {
+ _pan = Common::Point(panX, panY);
+ _panSpeed = panSpeed;
+ }
+
+ } else if (!strncmp(commandStr, "DRIVER", 6)) {
+ // Set the driver to use
+ paramP = commandStr + 7;
+
+ if (!strncmp(paramP, "#SOUND.00", 9)) {
+ int driverNum = paramP[9] - '0';
+ _vm->_sound->init(driverNum);
+ }
+ } else if (!strncmp(commandStr, "SOUND", 5)) {
+ // Set sound number
+ paramP = commandStr + 5;
+ int soundId = getParameter(&paramP);
+ _vm->_sound->command(soundId);
+
+ } else if (!strncmp(commandStr, "COLOR", 5) && ((commandStr[5] == '0') ||
+ (commandStr[5] == '1'))) {
+ // Set the text colors
+ int index = commandStr[5] - '0';
+ paramP = commandStr + 6;
+
+ byte r = getParameter(&paramP);
+ byte g = getParameter(&paramP);
+ byte b = getParameter(&paramP);
+
+ _vm->_palette->setEntry(5 + index, r, g, b);
+
+ } else if (!strncmp(commandStr, "SPARE", 5)) {
+ // Sets a secondary background number that can be later switched in with a PAGE command
+ paramP = commandStr + 6;
+ int spareIndex = commandStr[5] - '0';
+ assert(spareIndex < 4);
+ int screenId = getParameter(&paramP);
+
+ // Load the spare background
+ SceneInfo *sceneInfo = SceneInfo::init(_vm);
+ sceneInfo->_width = MADS_SCREEN_WIDTH;
+ sceneInfo->_height = MADS_SCENE_HEIGHT;
+ _spareScreens[spareIndex].setSize(MADS_SCREEN_WIDTH, MADS_SCENE_HEIGHT);
+ sceneInfo->loadMadsV1Background(screenId, "", SCENEFLAG_TRANSLATE,
+ _spareScreens[spareIndex]);
+ delete sceneInfo;
+
+ } else if (!strncmp(commandStr, "PAGE", 4)) {
+ // Signals to change to a previous specified secondary background
+ paramP = commandStr + 4;
+ int spareIndex = getParameter(&paramP);
+
+ // Only allow background switches if one isn't currently in progress
+ if (!_spareScreen && _spareScreens[spareIndex].getPixels() != nullptr) {
+ _spareScreen = &_spareScreens[spareIndex];
+ _translationX = 0;
+ }
+
+ } else {
+ error("Unknown response command: '%s'", commandStr);
+ }
+}
+
+int TextView::getParameter(const char **paramP) {
+ if ((**paramP != '=') && (**paramP != ','))
+ return 0;
+
+ int result = 0;
+ ++*paramP;
+ while ((**paramP >= '0') && (**paramP <= '9')) {
+ result = result * 10 + (**paramP - '0');
+ ++*paramP;
+ }
+
+ return result;
+}
+
+void TextView::processText() {
+ int xStart;
+
+ if (!strcmp(_currentLine, "***")) {
+ // Special signifier for end of script
+ _scrollCount = _font->getHeight() * 13;
+ _lineY = -1;
+ return;
+ }
+
+ _lineY = 0;
+
+ // Lines are always centered, except if line contains a '@', in which case the
+ // '@' marks the position that must be horizontally centered
+ char *centerP = strchr(_currentLine, '@');
+ if (centerP) {
+ *centerP = '\0';
+ xStart = (MADS_SCREEN_WIDTH / 2) - _font->getWidth(_currentLine);
+
+ // Delete the @ character and shift back the remainder of the string
+ char *p = centerP + 1;
+ if (*p == ' ') ++p;
+ strcpy(centerP, p);
+
+ } else {
+ int lineWidth = _font->getWidth(_currentLine);
+ xStart = (MADS_SCREEN_WIDTH - lineWidth) / 2;
+ }
+
+ // Add the new line to the list of pending lines
+ TextLine tl;
+ tl._pos = Common::Point(xStart, MADS_SCENE_HEIGHT);
+ tl._line = _currentLine;
+ tl._textDisplayIndex = -1;
+ _textLines.push_back(tl);
+}
+
+void TextView::display() {
+ FullScreenDialog::display();
+}
+
+void TextView::resetPalette() {
+ _vm->_palette->resetGamePalette(8, 8);
+ _vm->_palette->setEntry(5, 0, 63, 63);
+ _vm->_palette->setEntry(6, 0, 45, 45);
+}
+
+void TextView::doFrame() {
+ Scene &scene = _vm->_game->_scene;
+ if (!_animating)
+ return;
+
+ // Only update state if wait period has expired
+ uint32 currTime = g_system->getMillis();
+
+ // If a screen transition is in progress and it's time for another column, handle it
+ if (_spareScreen) {
+ byte *srcP = _spareScreen->getBasePtr(_translationX, 0);
+ byte *bgP = scene._backgroundSurface.getBasePtr(_translationX, 0);
+ byte *screenP = (byte *)_vm->_screen.getBasePtr(_translationX, 0);
+
+ for (int y = 0; y < MADS_SCENE_HEIGHT; ++y, srcP += MADS_SCREEN_WIDTH,
+ bgP += MADS_SCREEN_WIDTH, screenP += MADS_SCREEN_WIDTH) {
+ *bgP = *srcP;
+ *screenP = *srcP;
+ }
+
+ // Flag the column of the screen is modified
+ _vm->_screen.copyRectToScreen(Common::Rect(_translationX, 0,
+ _translationX + 1, MADS_SCENE_HEIGHT));
+
+ // Keep moving the column to copy to the right
+ if (++_translationX == MADS_SCREEN_WIDTH) {
+ // Surface transition is complete
+ _spareScreen = nullptr;
+ }
+ }
+
+ // Make sure it's time for an update
+ if (currTime < _scrollTimeout)
+ return;
+ _scrollTimeout = g_system->getMillis() + TEXT_ANIMATION_DELAY;
+ _redrawFlag = true;
+
+ // If any panning values are set, pan the background surface
+ if ((_pan.x != 0) || (_pan.y != 0)) {
+ if (_panCountdown > 0) {
+ --_panCountdown;
+ return;
+ }
+
+ // Handle horizontal panning
+ if (_pan.x != 0) {
+ byte *lineTemp = new byte[_pan.x];
+ for (int y = 0; y < MADS_SCENE_HEIGHT; ++y) {
+ byte *pixelsP = (byte *)scene._backgroundSurface.getBasePtr(0, y);
+
+ // Copy the first X pixels into temp buffer, move the rest of the line
+ // to the start of the line, and then move temp buffer pixels to end of line
+ Common::copy(pixelsP, pixelsP + _pan.x, lineTemp);
+ Common::copy(pixelsP + _pan.x, pixelsP + MADS_SCREEN_WIDTH, pixelsP);
+ Common::copy(lineTemp, lineTemp + _pan.x, pixelsP + MADS_SCREEN_WIDTH - _pan.x);
+ }
+
+ delete[] lineTemp;
+ }
+
+ // Handle vertical panning
+ if (_pan.y != 0) {
+ // Store the bottom Y lines into a temp buffer, move the rest of the lines down,
+ // and then copy the stored lines back to the top of the screen
+ byte *linesTemp = new byte[_pan.y * MADS_SCREEN_WIDTH];
+ byte *pixelsP = (byte *)scene._backgroundSurface.getBasePtr(0, MADS_SCENE_HEIGHT - _pan.y);
+ Common::copy(pixelsP, pixelsP + MADS_SCREEN_WIDTH * _pan.y, linesTemp);
+
+ for (int y = MADS_SCENE_HEIGHT - 1; y >= _pan.y; --y) {
+ byte *destP = (byte *)scene._backgroundSurface.getBasePtr(0, y);
+ byte *srcP = (byte *)scene._backgroundSurface.getBasePtr(0, y - _pan.y);
+ Common::copy(srcP, srcP + MADS_SCREEN_WIDTH, destP);
+ }
+
+ Common::copy(linesTemp, linesTemp + _pan.y * MADS_SCREEN_WIDTH,
+ (byte *)scene._backgroundSurface.getPixels());
+ delete[] linesTemp;
+ }
+
+ // Flag for a full screen refresh
+ scene._spriteSlots.fullRefresh();
+ }
+
+ // Scroll all active text lines up
+ for (int i = _textLines.size() - 1; i >= 0; --i) {
+ TextLine &tl = _textLines[i];
+ if (tl._textDisplayIndex != -1)
+ // Expire the text line that's already on-screen
+ scene._textDisplay.expire(tl._textDisplayIndex);
+
+ tl._pos.y--;
+ if (tl._pos.y < 0) {
+ _textLines.remove_at(i);
+ } else {
+ tl._textDisplayIndex = scene._textDisplay.add(tl._pos.x, tl._pos.y,
+ 0x605, -1, tl._line, _font);
+ }
+ }
+
+ if (_scrollCount > 0) {
+ // Handling final scrolling of text off of screen
+ if (--_scrollCount == 0) {
+ scriptDone();
+ return;
+ }
+ } else {
+ // Handling a text row
+ if (++_lineY == (_font->getHeight() + TEXTVIEW_LINE_SPACING))
+ processLines();
+ }
+}
+
+void TextView::scriptDone() {
+ _breakFlag = true;
+ _vm->_dialogs->_pendingDialog = DIALOG_MAIN_MENU;
+}
+
+/*------------------------------------------------------------------------*/
+
+char AnimationView::_resourceName[100];
+
+void AnimationView::execute(MADSEngine *vm, const Common::String &resName) {
+ assert(resName.size() < 100);
+ Common::strlcpy(_resourceName, resName.c_str(), sizeof(_resourceName));
+ vm->_dialogs->_pendingDialog = DIALOG_ANIMVIEW;
+}
+
+AnimationView::AnimationView(MADSEngine *vm) : MenuView(vm) {
+ _redrawFlag = false;
+
+ _soundDriverLoaded = false;
+ _previousUpdate = 0;
+ _screenId = -1;
+ _resetPalette = false;
+ _resyncMode = NEVER;
+ _v1 = 0;
+ _v2 = -1;
+ _resourceIndex = -1;
+ _currentAnimation = nullptr;
+ _sfx = 0;
+ _soundFlag = _bgLoadFlag = true;
+ _showWhiteBars = true;
+ _manualFrameNumber = 0;
+ _manualSpriteSet = nullptr;
+ _manualStartFrame = _manualEndFrame = 0;
+ _manualFrame2 = 0;
+ _animFrameNumber = 0;
+ _nextCyclingActive = false;
+ _sceneInfo = SceneInfo::init(_vm);
+
+ load();
+}
+
+AnimationView::~AnimationView() {
+ // Turn off palette cycling as well as any playing sound
+ Scene &scene = _vm->_game->_scene;
+ scene._cyclingActive = false;
+ _vm->_sound->stop();
+ _vm->_audio->stop();
+
+ // Delete data
+ delete _currentAnimation;
+ delete _sceneInfo;
+}
+
+void AnimationView::load() {
+ Common::String resName(_resourceName);
+ if (!resName.hasSuffix("."))
+ resName += ".res";
+
+ _filename = resName;
+ if (!_script.open(resName))
+ error("Could not open resource %s", resName.c_str());
+
+ processLines();
+}
+
+void AnimationView::display() {
+ Scene &scene = _vm->_game->_scene;
+ _vm->_palette->initPalette();
+ Common::fill(&_vm->_palette->_cyclingPalette[0], &_vm->_palette->_cyclingPalette[PALETTE_SIZE], 0);
+
+ _vm->_palette->resetGamePalette(1, 8);
+ scene._spriteSlots.reset();
+ scene._paletteCycles.clear();
+
+ MenuView::display();
+}
+
+bool AnimationView::onEvent(Common::Event &event) {
+ // Wait for the Escape key or a mouse press
+ if (((event.type == Common::EVENT_KEYDOWN) && (event.kbd.keycode == Common::KEYCODE_ESCAPE)) ||
+ (event.type == Common::EVENT_LBUTTONUP)) {
+ scriptDone();
+ return true;
+ }
+
+ return false;
+}
+
+void AnimationView::doFrame() {
+ Scene &scene = _vm->_game->_scene;
+
+ if (_resourceIndex == -1 || _currentAnimation->freeFlag()) {
+ if (++_resourceIndex == (int)_resources.size()) {
+ scriptDone();
+ } else {
+ scene._frameStartTime = 0;
+ loadNextResource();
+ }
+ } else if (_currentAnimation->getCurrentFrame() == 1) {
+ scene._cyclingActive = _nextCyclingActive;
+ }
+
+ if (_currentAnimation) {
+ ++scene._frameStartTime;
+ _currentAnimation->update();
+ _redrawFlag = true;
+ }
+}
+
+void AnimationView::loadNextResource() {
+ Scene &scene = _vm->_game->_scene;
+ Palette &palette = *_vm->_palette;
+ ResourceEntry &resEntry = _resources[_resourceIndex];
+ Common::Array<PaletteCycle> paletteCycles;
+
+ if (resEntry._bgFlag)
+ palette.resetGamePalette(1, 8);
+
+ palette._mainPalette[253 * 3] = palette._mainPalette[253 * 3 + 1]
+ = palette._mainPalette[253 * 3 + 2] = 0xb4;
+ palette.setPalette(&palette._mainPalette[253 * 3], 253, 1);
+
+ // Free any previous messages
+ scene._kernelMessages.reset();
+
+ // Handle the bars at the top/bottom
+ if (resEntry._showWhiteBars) {
+ // For animations the screen has been clipped to the middle 156 rows.
+ // So although it's slightly messy, bypass our screen class entirely,
+ // and draw the horizontal lines directly on the physiacl screen surface
+ Graphics::Surface *s = g_system->lockScreen();
+ s->hLine(0, 20, MADS_SCREEN_WIDTH, 253);
+ s->hLine(0, 179, MADS_SCREEN_WIDTH, 253);
+ g_system->unlockScreen();
+ }
+
+ // Load the new animation
+ delete _currentAnimation;
+ _currentAnimation = Animation::init(_vm, &scene);
+ int flags = ANIMFLAG_ANIMVIEW | (resEntry._bgFlag ? ANIMFLAG_LOAD_BACKGROUND : 0);
+ _currentAnimation->load(scene._backgroundSurface, scene._depthSurface,
+ resEntry._resourceName, flags, &paletteCycles, _sceneInfo);
+
+ // Signal for a screen refresh
+ scene._spriteSlots.fullRefresh();
+
+ // If a sound driver has been specified, then load the correct one
+ if (!_currentAnimation->_header._soundName.empty()) {
+ const char *chP = strchr(_currentAnimation->_header._soundName.c_str(), '.');
+ assert(chP);
+
+ // Handle both Rex naming (xxx.009) and naming in later games (e.g. xxx.ph9)
+ int driverNum = atoi(chP + 3);
+ // HACK for Dragon
+ if (_currentAnimation->_header._soundName == "#SOUND.DRG")
+ driverNum = 9;
+ _vm->_sound->init(driverNum);
+ }
+
+ // Handle any manual setup
+ if (_currentAnimation->_header._manualFlag) {
+ _manualFrameNumber = _currentAnimation->_header._spritesIndex;
+ _manualSpriteSet = _currentAnimation->getSpriteSet(_manualFrameNumber);
+ }
+
+ // Set the sound data for the animation
+ _vm->_sound->setEnabled(resEntry._soundFlag);
+
+ Common::String dsrName = _currentAnimation->_header._dsrName;
+ if (!dsrName.empty())
+ _vm->_audio->setSoundGroup(dsrName);
+
+ // Start the new animation
+ _currentAnimation->startAnimation(0);
+
+ // Handle the palette and cycling palette
+ scene._cyclingActive = false;
+ Common::copy(&palette._mainPalette[0], &palette._mainPalette[PALETTE_SIZE],
+ &palette._cyclingPalette[0]);
+
+ _vm->_game->_fx = (ScreenTransition)resEntry._fx;
+ _nextCyclingActive = paletteCycles.size() > 0;
+ if (!_vm->_game->_fx) {
+ palette.setFullPalette(palette._mainPalette);
+ }
+
+ scene.initPaletteAnimation(paletteCycles, _nextCyclingActive && !_vm->_game->_fx);
+}
+
+void AnimationView::scriptDone() {
+ _breakFlag = true;
+ _vm->_dialogs->_pendingDialog = DIALOG_MAIN_MENU;
+}
+
+void AnimationView::processLines() {
+ if (_script.eos()) {
+ // end of script, end animation
+ scriptDone();
+ return;
+ }
+
+ while (!_script.eos()) {
+ // Get in next line
+ _currentLine.clear();
+ char c;
+ while (!_script.eos() && (c = _script.readByte()) != '\n') {
+ if (c != '\r' && c != '\0')
+ _currentLine += c;
+ }
+
+ // Process the line
+ while (!_currentLine.empty()) {
+ if (_currentLine.hasPrefix("-")) {
+ _currentLine.deleteChar(0);
+
+ processCommand();
+ } else {
+ // Get resource name
+ Common::String resName;
+ while (!_currentLine.empty() && (c = _currentLine[0]) != ' ') {
+ _currentLine.deleteChar(0);
+ resName += c;
+ }
+
+ // Add resource into list along with any set state information
+ _resources.push_back(ResourceEntry(resName, _sfx, _soundFlag,
+ _bgLoadFlag, _showWhiteBars));
+
+ // Fx resets between resource entries
+ _sfx = 0;
+ }
+
+ // Skip any spaces
+ while (_currentLine.hasPrefix(" "))
+ _currentLine.deleteChar(0);
+ }
+ }
+}
+
+void AnimationView::processCommand() {
+ // Get the command character
+ char commandChar = toupper(_currentLine[0]);
+ _currentLine.deleteChar(0);
+
+ // Handle the command
+ switch (commandChar) {
+ case 'B':
+ _soundFlag = !_soundFlag;
+ break;
+ case 'H':
+ // -h[:ex] Disable EMS / XMS high memory support
+ if (_currentLine.hasPrefix(":"))
+ _currentLine.deleteChar(0);
+ while (_currentLine.hasPrefix("e") || _currentLine.hasPrefix("x"))
+ _currentLine.deleteChar(0);
+ break;
+ case 'O':
+ // -o:xxx Specify opening special effect
+ assert(_currentLine[0] == ':');
+ _currentLine.deleteChar(0);
+ _sfx = getParameter();
+ break;
+ case 'P':
+ // Switch to CONCAT mode, which is ignored anyway
+ break;
+ case 'R': {
+ // Resynch timer (always, beginning, never)
+ assert(_currentLine[0] == ':');
+ _currentLine.deleteChar(0);
+
+ char v = toupper(_currentLine[0]);
+ _currentLine.deleteChar(0);
+ if (v == 'N')
+ _resyncMode = NEVER;
+ else if (v == 'A')
+ _resyncMode = ALWAYS;
+ else if (v == 'B')
+ _resyncMode = BEGINNING;
+ else
+ error("Unknown parameter");
+ break;
+ }
+ case 'W':
+ // Switch white bars being visible
+ _showWhiteBars = !_showWhiteBars;
+ break;
+ case 'X':
+ // Exit after animation finishes. Ignore
+ break;
+ case 'D':
+ // Unimplemented and ignored in the original. Ignore as well
+ break;
+ case 'Y':
+ // Reset palette on startup
+ _resetPalette = true;
+ break;
+ default:
+ error("Unknown command char: '%c'", commandChar);
+ }
+}
+
+int AnimationView::getParameter() {
+ int result = 0;
+
+ while (!_currentLine.empty()) {
+ char c = _currentLine[0];
+
+ if (c >= '0' && c <= '9') {
+ _currentLine.deleteChar(0);
+ result = result * 10 + (c - '0');
+ } else {
+ break;
+ }
+ }
+
+ return result;
+}
+
+} // End of namespace MADS
diff --git a/engines/mads/menu_views.h b/engines/mads/menu_views.h
new file mode 100644
index 0000000000..cc5a13006f
--- /dev/null
+++ b/engines/mads/menu_views.h
@@ -0,0 +1,225 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public 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 MADS_MENU_VIEWS_H
+#define MADS_MENU_VIEWS_H
+
+#include "common/scummsys.h"
+#include "mads/dialogs.h"
+#include "mads/game.h"
+#include "mads/msurface.h"
+
+namespace MADS {
+
+class MADSEngine;
+
+class MenuView: public FullScreenDialog {
+protected:
+ bool _breakFlag;
+ bool _redrawFlag;
+ Common::String _filename;
+
+ virtual void doFrame() = 0;
+
+ virtual void display();
+
+ /**
+ * Event handler
+ */
+ virtual bool onEvent(Common::Event &event);
+public:
+ MenuView(MADSEngine *vm);
+
+ virtual ~MenuView() {}
+
+ virtual void show();
+
+ Common::String getResourceName();
+};
+
+struct TextLine {
+ Common::Point _pos;
+ Common::String _line;
+ int _textDisplayIndex;
+};
+
+/**
+ * Scrolling text view
+ */
+class TextView : public MenuView {
+private:
+ static char _resourceName[100];
+
+ bool _animating;
+ Common::Array<TextLine> _textLines;
+ Common::Point _pan;
+ int _panSpeed;
+ MSurface _spareScreens[4];
+ int _scrollCount;
+ int _lineY;
+ uint32 _scrollTimeout;
+ int _panCountdown;
+ int _translationX;
+ Common::File _script;
+ char _currentLine[80];
+ MSurface *_spareScreen;
+ Font *_font;
+private:
+ /**
+ * Load the text resource
+ */
+ void load();
+
+ /**
+ * Process the lines
+ */
+ void processLines();
+
+ /**
+ * Process a command from the script file
+ */
+ void processCommand();
+
+ /**
+ * Process text from the script file
+ */
+ void processText();
+
+ /**
+ * Get a parameter from line
+ */
+ int getParameter(const char **paramP);
+
+ /**
+ * Reset the game palette
+ */
+ void resetPalette();
+protected:
+ virtual void display();
+
+ virtual void doFrame();
+
+ /**
+ * Called when the script is finished
+ */
+ virtual void scriptDone();
+public:
+ /**
+ * Queue the given text resource for display
+ */
+ static void execute(MADSEngine *vm, const Common::String &resName);
+
+ TextView(MADSEngine *vm);
+
+ virtual ~TextView();
+};
+
+enum ResyncMode { NEVER, ALWAYS, BEGINNING };
+
+struct ResourceEntry {
+ Common::String _resourceName;
+ int _fx;
+ bool _soundFlag;
+ bool _bgFlag;
+ bool _showWhiteBars;
+
+ ResourceEntry() {}
+ ResourceEntry(const Common::String &resName, int fx, bool soundFlag,
+ bool bgFlag, bool showWhiteBars) {
+ _resourceName = resName;
+ _fx = fx;
+ _soundFlag = soundFlag;
+ _bgFlag = bgFlag;
+ _showWhiteBars = showWhiteBars;
+ }
+};
+
+struct ResIndexEntry {
+ int _id;
+ int _v;
+ Common::String _resourceName;
+
+ ResIndexEntry() {}
+};
+
+/**
+* Animation cutscene view
+*/
+class AnimationView : public MenuView {
+private:
+ static char _resourceName[100];
+
+ Common::File _script;
+ uint32 _previousUpdate;
+ Common::String _currentLine;
+ bool _soundDriverLoaded;
+ bool _resetPalette;
+ ResyncMode _resyncMode;
+ int _sfx;
+ bool _soundFlag;
+ bool _bgLoadFlag;
+ bool _showWhiteBars;
+ Common::Array<ResourceEntry> _resources;
+ Common::Array<ResIndexEntry> _resIndex;
+ int _v1;
+ int _v2;
+ int _resourceIndex;
+ SceneInfo *_sceneInfo;
+ Animation *_currentAnimation;
+ int _manualFrameNumber;
+ SpriteAsset *_manualSpriteSet;
+ int _manualStartFrame, _manualEndFrame;
+ int _manualFrame2;
+ int _animFrameNumber;
+ bool _nextCyclingActive;
+private:
+ void load();
+
+ void processLines();
+
+ void processCommand();
+
+ int getParameter();
+
+ void loadNextResource();
+protected:
+ virtual void display();
+
+ virtual void doFrame();
+
+ virtual bool onEvent(Common::Event &event);
+
+ virtual void scriptDone();
+public:
+ /**
+ * Queue the given text resource for display
+ */
+ static void execute(MADSEngine *vm, const Common::String &resName);
+
+ AnimationView(MADSEngine *vm);
+
+ virtual ~AnimationView();
+};
+
+} // End of namespace MADS
+
+#endif /* MADS_MENU_VIEWS_H */
diff --git a/engines/mads/module.mk b/engines/mads/module.mk
index 96353e9ae5..fc04a2f8ba 100644
--- a/engines/mads/module.mk
+++ b/engines/mads/module.mk
@@ -35,6 +35,7 @@ MODULE_OBJS := \
hotspots.o \
inventory.o \
mads.o \
+ menu_views.o \
messages.o \
msurface.o \
palette.o \
diff --git a/engines/mads/msurface.cpp b/engines/mads/msurface.cpp
index 349f4a5f23..39824bac4b 100644
--- a/engines/mads/msurface.cpp
+++ b/engines/mads/msurface.cpp
@@ -87,7 +87,6 @@ void MSurface::drawSprite(const Common::Point &pt, SpriteInfo &info, const Commo
// rectangle is always 0, 0
assert(clipRect.top == 0 && clipRect.left == 0);
- // TODO: Put err* and scaled* into SpriteInfo
int errX = info.hotX * info.scaleX % 100;
int errY = info.hotY * info.scaleY % 100;
int scaledWidth = scaleValue(info.width, info.scaleX, errX);
@@ -160,7 +159,6 @@ void MSurface::drawSprite(const Common::Point &pt, SpriteInfo &info, const Commo
if (status == kStatusDraw && clipY == 0) {
// Draw previously scaled line
- // TODO Implement different drawing types (depth, shadow etc.)
byte *tempDst = dst;
for (int lineX = 0; lineX < scaledWidth; lineX++) {
byte pixel = scaledLineBuf[lineX];
@@ -186,8 +184,6 @@ void MSurface::drawSprite(const Common::Point &pt, SpriteInfo &info, const Commo
}
dst += pitch;
heightAmt--;
- // TODO depth etc.
- //depthAddress += Destination -> Width;
errY += 100;
if (errY >= 0)
@@ -266,11 +262,11 @@ void MSurface::copyFrom(MSurface *src, const Common::Point &destPos, int depth,
int highestDim = MAX(frameWidth, frameHeight);
bool lineDist[MADS_SCREEN_WIDTH];
- int distIndex = 0;
int distXCount = 0, distYCount = 0;
if (scale != -1) {
int distCtr = 0;
+ int distIndex = 0;
do {
distCtr += scale;
if (distCtr < 100) {
@@ -356,9 +352,10 @@ void MSurface::copyFrom(MSurface *src, const Common::Point &destPos, int depth,
if (widthAmount > 0)
spriteWidth -= widthAmount;
- int spriteRight = spriteLeft + spriteWidth;
if (spriteWidth <= 0)
return;
+
+ int spriteRight = spriteLeft + spriteWidth;
if (flipped) {
destX += distXCount - 1;
spriteLeft = -(distXCount - spriteRight);
diff --git a/engines/mads/msurface.h b/engines/mads/msurface.h
index 3a5bf22eed..650d7fdaee 100644
--- a/engines/mads/msurface.h
+++ b/engines/mads/msurface.h
@@ -64,6 +64,11 @@ public:
* Helper method for calculating new dimensions when scaling a sprite
*/
static int scaleValue(int value, int scale, int err);
+
+ /**
+ * Base method for descendents to load their contents
+ */
+ virtual void load(const Common::String &resName) {}
public:
/**
* Basic constructor
@@ -218,8 +223,6 @@ public:
};
class DepthSurface : public MSurface {
-private:
- MADSEngine *_vm;
public:
/**
* Depth style
@@ -229,7 +232,7 @@ public:
/**
* Constructor
*/
- DepthSurface(MADSEngine *vm) : _vm(vm), _depthStyle(0) {}
+ DepthSurface() : _depthStyle(0) {}
/**
* Returns the depth at a given position
diff --git a/engines/mads/nebular/dialogs_nebular.cpp b/engines/mads/nebular/dialogs_nebular.cpp
index 35a7d3bdc6..f5355517bd 100644
--- a/engines/mads/nebular/dialogs_nebular.cpp
+++ b/engines/mads/nebular/dialogs_nebular.cpp
@@ -314,13 +314,13 @@ void DialogsNebular::showDialog() {
break;
}
case DIALOG_TEXTVIEW: {
- TextView *dlg = new TextView(_vm);
+ TextView *dlg = new RexTextView(_vm);
dlg->show();
delete dlg;
break;
}
case DIALOG_ANIMVIEW: {
- AnimationView *dlg = new AnimationView(_vm);
+ AnimationView *dlg = new RexAnimationView(_vm);
dlg->show();
delete dlg;
break;
@@ -553,67 +553,6 @@ void PictureDialog::restore() {
/*------------------------------------------------------------------------*/
-FullScreenDialog::FullScreenDialog(MADSEngine *vm) : _vm(vm) {
- _screenId = 990;
- _palFlag = true;
-}
-
-FullScreenDialog::~FullScreenDialog() {
- _vm->_screen.resetClipBounds();
- _vm->_game->_scene.restrictScene();
-}
-
-void FullScreenDialog::display() {
- Game &game = *_vm->_game;
- Scene &scene = game._scene;
-
- int nextSceneId = scene._nextSceneId;
- int currentSceneId = scene._currentSceneId;
- int priorSceneId = scene._priorSceneId;
-
- if (_screenId > 0) {
- SceneInfo *sceneInfo = SceneInfo::init(_vm);
- sceneInfo->load(_screenId, 0, "", 0, scene._depthSurface, scene._backgroundSurface);
- }
-
- scene._priorSceneId = priorSceneId;
- scene._currentSceneId = currentSceneId;
- scene._nextSceneId = nextSceneId;
-
- _vm->_events->initVars();
- game._kernelMode = KERNEL_ROOM_INIT;
-
- byte pal[768];
- if (_vm->_screenFade) {
- Common::fill(&pal[0], &pal[PALETTE_SIZE], 0);
- _vm->_palette->setFullPalette(pal);
- } else {
- _vm->_palette->getFullPalette(pal);
- _vm->_palette->fadeOut(pal, nullptr, 0, PALETTE_COUNT, 0, 1, 1, 16);
- }
-
- // Set Fx state and palette entries
- game._fx = _vm->_screenFade == SCREEN_FADE_SMOOTH ? kTransitionFadeIn : kCenterVertTransition;
- game._trigger = 0;
-
- // Clear the screen and draw the upper and lower horizontal lines
- _vm->_screen.empty();
- _vm->_palette->setLowRange();
- _vm->_screen.hLine(0, 20, MADS_SCREEN_WIDTH, 2);
- _vm->_screen.hLine(0, 179, MADS_SCREEN_WIDTH, 2);
- _vm->_screen.copyRectToScreen(Common::Rect(0, 0, MADS_SCREEN_WIDTH, MADS_SCREEN_HEIGHT));
-
- // Restrict the screen to the area between the two lines
- _vm->_screen.setClipBounds(Common::Rect(0, DIALOG_TOP, MADS_SCREEN_WIDTH,
- DIALOG_TOP + MADS_SCENE_HEIGHT));
- _vm->_game->_scene.restrictScene();
-
- if (_screenId > 0)
- scene._spriteSlots.fullRefresh();
-}
-
-/*------------------------------------------------------------------------*/
-
GameDialog::DialogLine::DialogLine() {
_active = true;
_state = DLGSTATE_UNSELECTED;
@@ -655,6 +594,9 @@ GameDialog::GameDialog(MADSEngine *vm) : FullScreenDialog(vm) {
_vm->_events->waitCursor();
scene.clearVocab();
scene._dynamicHotspots.clear();
+ // Clear scene sprites and objects
+ scene._spriteSlots.reset();
+ _vm->_game->_screenObjects.clear();
_vm->_dialogs->_defaultPosition = Common::Point(-1, -1);
_menuSpritesIndex = 0;
}
@@ -966,7 +908,7 @@ void GameDialog::refreshText() {
}
if (!skipFlag) {
- _lines[i]._textDisplayIndex = scene._textDisplay.add(_lines[i]._pos.x, _lines[i]._pos.y,
+ _lines[i]._textDisplayIndex = scene._textDisplay.add(_lines[i]._pos.x, _lines[i]._pos.y,
fontColor, _lines[i]._widthAdjust, _lines[i]._msg, _lines[i]._font);
}
}
@@ -1122,6 +1064,14 @@ void OptionsDialog::display() {
void OptionsDialog::show() {
Nebular::GameNebular &game = *(Nebular::GameNebular *)_vm->_game;
+
+ // Previous options, restored when cancel is selected
+ bool prevEasyMouse = _vm->_easyMouse;
+ bool prevInvObjectsAnimated = _vm->_invObjectsAnimated;
+ bool prevTextWindowStill = _vm->_textWindowStill;
+ ScreenFade prevScreenFade = _vm->_screenFade;
+ StoryMode prevStoryMode = game._storyMode;
+
do {
_selectedLine = 0;
GameDialog::show();
@@ -1166,10 +1116,15 @@ void OptionsDialog::show() {
switch (_selectedLine) {
case 8: // Done
- // TODO: Copy from temporary config
+ // New options will be applied
break;
case 9: // Cancel
- // TODO: Ignore all changes to temporary config
+ // Revert all options from the saved ones
+ _vm->_easyMouse = prevEasyMouse;
+ _vm->_invObjectsAnimated = prevInvObjectsAnimated;
+ _vm->_textWindowStill = prevTextWindowStill;
+ _vm->_screenFade = prevScreenFade;
+ game._storyMode = prevStoryMode;
break;
default:
break;
diff --git a/engines/mads/nebular/dialogs_nebular.h b/engines/mads/nebular/dialogs_nebular.h
index f64f992611..5dbe4da6f0 100644
--- a/engines/mads/nebular/dialogs_nebular.h
+++ b/engines/mads/nebular/dialogs_nebular.h
@@ -31,8 +31,6 @@ namespace MADS {
namespace Nebular {
-#define DIALOG_TOP 22
-
enum CapitalizationMode { kUppercase = 0, kLowercase = 1, kUpperAndLower = 2 };
class DialogsNebular : public Dialogs {
@@ -109,36 +107,6 @@ enum DialogTextAlign { ALIGN_NONE = 0, ALIGN_CENTER = -1, ALIGN_AT_CENTER = -2,
enum DialogState { DLGSTATE_UNSELECTED = 0, DLGSTATE_SELECTED = 1, DLGSTATE_FOCUSED = 2 };
-class FullScreenDialog: public EventTarget {
-protected:
- /**
- * Engine reference
- */
- MADSEngine *_vm;
-
- /**
- * Screen/scene to show background from
- */
- int _screenId;
-
- /**
- * Flag for palette initialization
- */
- bool _palFlag;
-
- /**
- * Handles displaying the screen background and dialog
- */
- virtual void display();
-public:
- /**
- * Constructor
- */
- FullScreenDialog(MADSEngine *vm);
-
- virtual ~FullScreenDialog();
-};
-
class GameDialog: public FullScreenDialog {
struct DialogLine {
bool _active;
@@ -148,7 +116,7 @@ class GameDialog: public FullScreenDialog {
Common::String _msg;
Font *_font;
int _widthAdjust;
-
+
DialogLine();
DialogLine(const Common::String &s);
};
@@ -162,7 +130,7 @@ protected:
int _menuSpritesIndex;
int _lineIndex;
int _textLineCount;
-
+
/**
* Display the dialog
*/
diff --git a/engines/mads/nebular/game_nebular.cpp b/engines/mads/nebular/game_nebular.cpp
index 902f42507a..fd669bc5cf 100644
--- a/engines/mads/nebular/game_nebular.cpp
+++ b/engines/mads/nebular/game_nebular.cpp
@@ -27,6 +27,7 @@
#include "mads/game.h"
#include "mads/screen.h"
#include "mads/msurface.h"
+#include "mads/menu_views.h"
#include "mads/nebular/game_nebular.h"
#include "mads/nebular/dialogs_nebular.h"
#include "mads/nebular/globals_nebular.h"
@@ -309,6 +310,31 @@ void GameNebular::setSectionHandler() {
}
void GameNebular::checkShowDialog() {
+ // Handling to start endgame sequences if the win/lose type has been set
+ switch (_winStatus) {
+ case 1:
+ // No shields failure ending
+ AnimationView::execute(_vm, "rexend1");
+ break;
+ case 2:
+ // Shields, but no targetting failure ending
+ AnimationView::execute(_vm, "rexend2");
+ break;
+ case 3:
+ // Completed game successfully, so activate quotes item on the main menu
+ ConfMan.setBool("ShowQuotes", true);
+ ConfMan.flushToDisk();
+
+ AnimationView::execute(_vm, "rexend3");
+ break;
+ case 4:
+ // Decompression ending
+ TextView::execute(_vm, "ending4");
+ break;
+ }
+ _winStatus = 0;
+
+ // Loop for showing dialogs, if any need to be shown
if (_vm->_dialogs->_pendingDialog && _player._stepEnabled && !_globals[kCopyProtectFailed]) {
_player.releasePlayerSprites();
@@ -599,7 +625,7 @@ void GameNebular::doObjectAction() {
_objects.addToInventory(OBJ_DURAFAIL_CELLS);
if (_difficulty == DIFFICULTY_HARD) {
dialogs.showItem(OBJ_DURAFAIL_CELLS, 416);
- }
+ }
_globals[kHandsetCellStatus] = 0;
break;
case 3:
diff --git a/engines/mads/nebular/game_nebular.h b/engines/mads/nebular/game_nebular.h
index da607d47ee..efa21a2e73 100644
--- a/engines/mads/nebular/game_nebular.h
+++ b/engines/mads/nebular/game_nebular.h
@@ -133,18 +133,16 @@ public:
virtual void synchronize(Common::Serializer &s, bool phase1);
};
-
+// Section handlers aren't needed in ScummVM implementation
class Section1Handler : public SectionHandler {
public:
Section1Handler(MADSEngine *vm) : SectionHandler(vm) {}
- // TODO: Properly implement handler methods
virtual void preLoadSection() {}
virtual void sectionPtr2() {}
virtual void postLoadSection() {}
};
-// TODO: Properly implement handler classes
typedef Section1Handler Section2Handler;
typedef Section1Handler Section3Handler;
typedef Section1Handler Section4Handler;
diff --git a/engines/mads/nebular/menu_nebular.cpp b/engines/mads/nebular/menu_nebular.cpp
index f0a0a995b0..28de4e5650 100644
--- a/engines/mads/nebular/menu_nebular.cpp
+++ b/engines/mads/nebular/menu_nebular.cpp
@@ -21,8 +21,10 @@
*/
#include "common/scummsys.h"
+#include "common/config-manager.h"
#include "mads/game.h"
#include "mads/mads.h"
+#include "mads/menu_views.h"
#include "mads/resources.h"
#include "mads/scene.h"
#include "mads/screen.h"
@@ -36,56 +38,6 @@ namespace Nebular {
#define MADS_MENU_Y ((MADS_SCREEN_HEIGHT - MADS_SCENE_HEIGHT) / 2)
#define MADS_MENU_ANIM_DELAY 70
-MenuView::MenuView(MADSEngine *vm) : FullScreenDialog(vm) {
- _breakFlag = false;
- _redrawFlag = true;
- _palFlag = false;
-}
-
-void MenuView::show() {
- Scene &scene = _vm->_game->_scene;
- EventsManager &events = *_vm->_events;
- _vm->_screenFade = SCREEN_FADE_FAST;
-
- scene._spriteSlots.reset(true);
- display();
-
- events.setEventTarget(this);
- events.hideCursor();
-
- while (!_breakFlag && !_vm->shouldQuit()) {
- if (_redrawFlag) {
- _vm->_game->_scene.drawElements(_vm->_game->_fx, _vm->_game->_fx);
- _redrawFlag = false;
- }
-
- _vm->_events->waitForNextFrame();
- _vm->_game->_fx = kTransitionNone;
- doFrame();
- }
-
- events.setEventTarget(nullptr);
- _vm->_sound->stop();
-}
-
-void MenuView::display() {
- _vm->_palette->resetGamePalette(4, 8);
-
- FullScreenDialog::display();
-}
-
-bool MenuView::onEvent(Common::Event &event) {
- if (event.type == Common::EVENT_KEYDOWN || event.type == Common::EVENT_LBUTTONDOWN) {
- _breakFlag = true;
- _vm->_dialogs->_pendingDialog = DIALOG_MAIN_MENU;
- return true;
- }
-
- return false;
-}
-
-/*------------------------------------------------------------------------*/
-
MainMenu::MainMenu(MADSEngine *vm): MenuView(vm) {
Common::fill(&_menuItems[0], &_menuItems[7], (SpriteAsset *)nullptr);
Common::fill(&_menuItemIndexes[0], &_menuItemIndexes[7], -1);
@@ -96,7 +48,7 @@ MainMenu::MainMenu(MADSEngine *vm): MenuView(vm) {
_highlightedIndex = -1;
_selectedIndex = -1;
_buttonDown = false;
-
+
for (int i = 0; i < 7; ++i)
_menuItems[i] = nullptr;
}
@@ -111,6 +63,10 @@ MainMenu::~MainMenu() {
scene._spriteSlots.reset();
}
+bool MainMenu::shouldShowQuotes() {
+ return ConfMan.hasKey("ShowQuotes") && ConfMan.getBool("ShowQuotes");
+}
+
void MainMenu::display() {
MenuView::display();
Scene &scene = _vm->_game->_scene;
@@ -129,7 +85,7 @@ void MainMenu::display() {
Common::Point pt(frame0->_offset.x - (frame0->w / 2),
frame0->_offset.y - frame0->h);
screenObjects.add(
- Common::Rect(pt.x, pt.y + DIALOG_TOP, pt.x + frame0->w,
+ Common::Rect(pt.x, pt.y + DIALOG_TOP, pt.x + frame0->w,
pt.y + frame0->h + DIALOG_TOP), LAYER_GUI, CAT_COMMAND, i);
}
@@ -150,6 +106,9 @@ void MainMenu::doFrame() {
handleAction((MADSGameAction)_selectedIndex);
} else {
for (_menuItemIndex = 0; _menuItemIndex < 6; ++_menuItemIndex) {
+ if (_menuItemIndex == 4 && !shouldShowQuotes())
+ continue;
+
if (_menuItemIndex != _selectedIndex) {
addSpriteSlot();
}
@@ -167,8 +126,11 @@ void MainMenu::doFrame() {
// If the user has chosen to skip the animation, show the full menu immediately
if (_skipFlag && _menuItemIndex >= 0) {
- // Quickly loop through all the menu items to display each's final frame
+ // Quickly loop through all the menu items to display each's final frame
for (; _menuItemIndex < 6; ++_menuItemIndex) {
+ if (_menuItemIndex == 4 && !shouldShowQuotes())
+ continue;
+
// Draw the final frame of the menuitem
_frameIndex = 0;
addSpriteSlot();
@@ -178,9 +140,12 @@ void MainMenu::doFrame() {
} else {
if ((_menuItemIndex == -1) || (_frameIndex == 0)) {
if (++_menuItemIndex == 6) {
+
// Reached end of display animation
_vm->_events->showCursor();
return;
+ } else if (_menuItemIndex == 4 && !shouldShowQuotes()) {
+ ++_menuItemIndex;
}
_frameIndex = _menuItems[_menuItemIndex]->getCount() - 1;
@@ -196,7 +161,7 @@ void MainMenu::doFrame() {
void MainMenu::addSpriteSlot() {
Scene &scene = _vm->_game->_scene;
SpriteSlots &spriteSlots = scene._spriteSlots;
-
+
int seqIndex = (_menuItemIndex < 6) ? _menuItemIndex : _frameIndex;
spriteSlots.deleteTimer(seqIndex);
@@ -290,7 +255,7 @@ bool MainMenu::onEvent(Common::Event &event) {
}
return true;
- case Common::EVENT_MOUSEMOVE:
+ case Common::EVENT_MOUSEMOVE:
if (_buttonDown) {
int menuIndex = getHighlightedItem(event.mouse);
if (menuIndex != _highlightedIndex) {
@@ -322,7 +287,7 @@ bool MainMenu::onEvent(Common::Event &event) {
default:
break;
}
-
+
return false;
}
@@ -352,7 +317,7 @@ void MainMenu::handleAction(MADSGameAction action) {
break;
case RESUME_GAME:
- // The original resumed the most recently saved game. Instead,
+ // The original resumed the most recently saved game. Instead,
// just show the load game scren
_vm->_dialogs->_pendingDialog = DIALOG_RESTORE;
return;
@@ -389,7 +354,7 @@ void AdvertView::show() {
uint32 expiryTime = g_system->getMillis() + 10 * 1000;
_vm->_palette->resetGamePalette(4, 8);
-
+
// Load the advert background onto the screen
SceneInfo *sceneInfo = SceneInfo::init(_vm);
sceneInfo->load(screenId, 0, Common::String(), 0, _vm->_game->_scene._depthSurface,
@@ -426,558 +391,19 @@ bool AdvertView::onEvent(Common::Event &event) {
/*------------------------------------------------------------------------*/
-char TextView::_resourceName[100];
-#define TEXTVIEW_LINE_SPACING 2
-#define TEXT_ANIMATION_DELAY 100
-#define TV_NUM_FADE_STEPS 40
-#define TV_FADE_DELAY_MILLI 50
-
-void TextView::execute(MADSEngine *vm, const Common::String &resName) {
- assert(resName.size() < 100);
- strncpy(_resourceName, resName.c_str(), sizeof(_resourceName));
- vm->_dialogs->_pendingDialog = DIALOG_TEXTVIEW;
-}
-
-TextView::TextView(MADSEngine *vm) : MenuView(vm) {
- _animating = false;
- _panSpeed = 0;
- _spareScreen = nullptr;
- _scrollCount = 0;
- _lineY = -1;
- _scrollTimeout = 0;
- _panCountdown = 0;
- _translationX = 0;
- _screenId = -1;
-
- _font = _vm->_font->getFont(FONT_CONVERSATION);
- _vm->_palette->resetGamePalette(4, 0);
- load();
-}
-
-TextView::~TextView() {
-}
-
-void TextView::load() {
- Common::String scriptName(_resourceName);
- scriptName += ".txr";
-
- if (!_script.open(scriptName))
- error("Could not open resource %s", _resourceName);
-
- processLines();
-}
-
-void TextView::processLines() {
- if (_script.eos())
- error("Attempted to read past end of response file");
-
- while (!_script.eos()) {
- // Read in the next line
- _script.readLine(_currentLine, 79);
- char *p = _currentLine + strlen(_currentLine) - 1;
- if (*p == '\n')
- *p = '\0';
-
- // Commented out line, so go loop for another
- if (_currentLine[0] == '#')
- continue;
-
- // Process the line
- char *cStart = strchr(_currentLine, '[');
- if (cStart) {
- while (cStart) {
- // Loop for possible multiple commands on one line
- char *cEnd = strchr(_currentLine, ']');
- if (!cEnd)
- error("Unterminated command '%s' in response file", _currentLine);
-
- *cEnd = '\0';
- processCommand();
-
- // Copy rest of line (if any) to start of buffer
- strncpy(_currentLine, cEnd + 1, sizeof(_currentLine));
-
- cStart = strchr(_currentLine, '[');
- }
-
- if (_currentLine[0]) {
- processText();
- break;
- }
-
- } else {
- processText();
- break;
- }
- }
-}
-
-void TextView::processCommand() {
- Scene &scene = _vm->_game->_scene;
- Common::String scriptLine(_currentLine + 1);
- scriptLine.toUppercase();
- const char *paramP;
- const char *commandStr = scriptLine.c_str();
-
- if (!strncmp(commandStr, "BACKGROUND", 10)) {
- // Set the background
- paramP = commandStr + 10;
- resetPalette();
- int screenId = getParameter(&paramP);
-
- SceneInfo *sceneInfo = SceneInfo::init(_vm);
- sceneInfo->load(screenId, 0, "", 0, scene._depthSurface, scene._backgroundSurface);
- scene._spriteSlots.fullRefresh();
- _redrawFlag = true;
-
- } else if (!strncmp(commandStr, "GO", 2)) {
- _animating = true;
-
- } else if (!strncmp(commandStr, "PAN", 3)) {
- // Set panning values
- paramP = commandStr + 3;
- int panX = getParameter(&paramP);
- int panY = getParameter(&paramP);
- int panSpeed = getParameter(&paramP);
-
- if ((panX != 0) || (panY != 0)) {
- _pan = Common::Point(panX, panY);
- _panSpeed = panSpeed;
- }
-
- } else if (!strncmp(commandStr, "DRIVER", 6)) {
- // Set the driver to use
- paramP = commandStr + 7;
-
- if (!strncmp(paramP, "#SOUND.00", 9)) {
- int driverNum = paramP[9] - '0';
- _vm->_sound->init(driverNum);
- }
- } else if (!strncmp(commandStr, "SOUND", 5)) {
- // Set sound number
- paramP = commandStr + 5;
- int soundId = getParameter(&paramP);
- _vm->_sound->command(soundId);
-
- } else if (!strncmp(commandStr, "COLOR", 5) && ((commandStr[5] == '0') ||
- (commandStr[5] == '1'))) {
- // Set the text colors
- int index = commandStr[5] - '0';
- paramP = commandStr + 6;
-
- byte r = getParameter(&paramP);
- byte g = getParameter(&paramP);
- byte b = getParameter(&paramP);
-
- _vm->_palette->setEntry(5 + index, r, g, b);
-
- } else if (!strncmp(commandStr, "SPARE", 5)) {
- // Sets a secondary background number that can be later switched in with a PAGE command
- paramP = commandStr + 6;
- int spareIndex = commandStr[5] - '0';
- assert(spareIndex < 4);
- int screenId = getParameter(&paramP);
-
- // Load the spare background
- SceneInfo *sceneInfo = SceneInfo::init(_vm);
- sceneInfo->_width = MADS_SCREEN_WIDTH;
- sceneInfo->_height = MADS_SCENE_HEIGHT;
- _spareScreens[spareIndex].setSize(MADS_SCREEN_WIDTH, MADS_SCENE_HEIGHT);
- sceneInfo->loadMadsV1Background(screenId, "", SCENEFLAG_TRANSLATE,
- _spareScreens[spareIndex]);
- delete sceneInfo;
-
- } else if (!strncmp(commandStr, "PAGE", 4)) {
- // Signals to change to a previous specified secondary background
- paramP = commandStr + 4;
- int spareIndex = getParameter(&paramP);
-
- // Only allow background switches if one isn't currently in progress
- if (!_spareScreen && _spareScreens[spareIndex].getPixels() != nullptr) {
- _spareScreen = &_spareScreens[spareIndex];
- _translationX = 0;
- }
-
- } else {
- error("Unknown response command: '%s'", commandStr);
- }
-}
-
-int TextView::getParameter(const char **paramP) {
- if ((**paramP != '=') && (**paramP != ','))
- return 0;
-
- int result = 0;
- ++*paramP;
- while ((**paramP >= '0') && (**paramP <= '9')) {
- result = result * 10 + (**paramP - '0');
- ++*paramP;
- }
-
- return result;
-}
-
-void TextView::processText() {
- int lineWidth, xStart;
-
- if (!strcmp(_currentLine, "***")) {
- // Special signifier for end of script
- _scrollCount = _font->getHeight() * 13;
- _lineY = -1;
- return;
- }
-
- _lineY = 0;
-
- // Lines are always centered, except if line contains a '@', in which case the
- // '@' marks the position that must be horizontally centered
- char *centerP = strchr(_currentLine, '@');
- if (centerP) {
- *centerP = '\0';
- xStart = (MADS_SCREEN_WIDTH / 2) - _font->getWidth(_currentLine);
-
- // Delete the @ character and shift back the remainder of the string
- char *p = centerP + 1;
- if (*p == ' ') ++p;
- strcpy(centerP, p);
-
- } else {
- lineWidth = _font->getWidth(_currentLine);
- xStart = (MADS_SCREEN_WIDTH - lineWidth) / 2;
- }
-
- // Add the new line to the list of pending lines
- TextLine tl;
- tl._pos = Common::Point(xStart, MADS_SCENE_HEIGHT);
- tl._line = _currentLine;
- tl._textDisplayIndex = -1;
- _textLines.push_back(tl);
-}
-
-void TextView::display() {
- FullScreenDialog::display();
- _sceneChanged = true;
-}
-
-void TextView::resetPalette() {
- _vm->_palette->resetGamePalette(8, 8);
- _vm->_palette->setEntry(5, 0, 63, 63);
- _vm->_palette->setEntry(6, 0, 45, 45);
-}
-
-void TextView::doFrame() {
- Scene &scene = _vm->_game->_scene;
- if (!_animating)
- return;
+void RexAnimationView::scriptDone() {
+ AnimationView::scriptDone();
- // Only update state if wait period has expired
- uint32 currTime = g_system->getMillis();
-
- // If a screen transition is in progress and it's time for another column, handle it
- if (_spareScreen) {
- byte *srcP = _spareScreen->getBasePtr(_translationX, 0);
- byte *bgP = scene._backgroundSurface.getBasePtr(_translationX, 0);
- byte *screenP = (byte *)_vm->_screen.getBasePtr(_translationX, 0);
-
- for (int y = 0; y < MADS_SCENE_HEIGHT; ++y, srcP += MADS_SCREEN_WIDTH,
- bgP += MADS_SCREEN_WIDTH, screenP += MADS_SCREEN_WIDTH) {
- *bgP = *srcP;
- *screenP = *srcP;
- }
-
- // Flag the column of the screen is modified
- _vm->_screen.copyRectToScreen(Common::Rect(_translationX, 0,
- _translationX + 1, MADS_SCENE_HEIGHT));
-
- // Keep moving the column to copy to the right
- if (++_translationX == MADS_SCREEN_WIDTH) {
- // Surface transition is complete
- _spareScreen = nullptr;
- }
- }
-
- // Make sure it's time for an update
- if (currTime < _scrollTimeout)
- return;
- _scrollTimeout = g_system->getMillis() + TEXT_ANIMATION_DELAY;
- _redrawFlag = true;
-
- // If any panning values are set, pan the background surface
- if ((_pan.x != 0) || (_pan.y != 0)) {
- if (_panCountdown > 0) {
- --_panCountdown;
- return;
- }
-
- // Handle horizontal panning
- if (_pan.x != 0) {
- byte *lineTemp = new byte[_pan.x];
- for (int y = 0; y < MADS_SCENE_HEIGHT; ++y) {
- byte *pixelsP = (byte *)scene._backgroundSurface.getBasePtr(0, y);
-
- // Copy the first X pixels into temp buffer, move the rest of the line
- // to the start of the line, and then move temp buffer pixels to end of line
- Common::copy(pixelsP, pixelsP + _pan.x, lineTemp);
- Common::copy(pixelsP + _pan.x, pixelsP + MADS_SCREEN_WIDTH, pixelsP);
- Common::copy(lineTemp, lineTemp + _pan.x, pixelsP + MADS_SCREEN_WIDTH - _pan.x);
- }
-
- delete[] lineTemp;
- }
-
- // Handle vertical panning
- if (_pan.y != 0) {
- // Store the bottom Y lines into a temp buffer, move the rest of the lines down,
- // and then copy the stored lines back to the top of the screen
- byte *linesTemp = new byte[_pan.y * MADS_SCREEN_WIDTH];
- byte *pixelsP = (byte *)scene._backgroundSurface.getBasePtr(0, MADS_SCENE_HEIGHT - _pan.y);
- Common::copy(pixelsP, pixelsP + MADS_SCREEN_WIDTH * _pan.y, linesTemp);
-
- for (int y = MADS_SCENE_HEIGHT - 1; y >= _pan.y; --y) {
- byte *destP = (byte *)scene._backgroundSurface.getBasePtr(0, y);
- byte *srcP = (byte *)scene._backgroundSurface.getBasePtr(0, y - _pan.y);
- Common::copy(srcP, srcP + MADS_SCREEN_WIDTH, destP);
- }
-
- Common::copy(linesTemp, linesTemp + _pan.y * MADS_SCREEN_WIDTH,
- (byte *)scene._backgroundSurface.getPixels());
- delete[] linesTemp;
- }
-
- // Flag for a full screen refresh
- scene._spriteSlots.fullRefresh();
- }
-
- // Scroll all active text lines up
- for (int i = _textLines.size() - 1; i >= 0; --i) {
- TextLine &tl = _textLines[i];
- if (tl._textDisplayIndex != -1)
- // Expire the text line that's already on-screen
- scene._textDisplay.expire(tl._textDisplayIndex);
-
- tl._pos.y--;
- if (tl._pos.y < 0) {
- _textLines.remove_at(i);
- } else {
- tl._textDisplayIndex = scene._textDisplay.add(tl._pos.x, tl._pos.y,
- 0x605, -1, tl._line, _font);
- }
- }
-
- if (_scrollCount > 0) {
- // Handling final scrolling of text off of screen
- if (--_scrollCount == 0) {
- scriptDone();
- return;
- }
- } else {
- // Handling a text row
- if (++_lineY == (_font->getHeight() + TEXTVIEW_LINE_SPACING))
- processLines();
- }
-}
-
-void TextView::scriptDone() {
- _breakFlag = true;
- _vm->_dialogs->_pendingDialog = DIALOG_MAIN_MENU;
-}
-
-/*------------------------------------------------------------------------*/
-
-char AnimationView::_resourceName[100];
-
-void AnimationView::execute(MADSEngine *vm, const Common::String &resName) {
- assert(resName.size() < 100);
- strncpy(_resourceName, resName.c_str(), sizeof(_resourceName));
- vm->_dialogs->_pendingDialog = DIALOG_ANIMVIEW;
-}
-
-AnimationView::AnimationView(MADSEngine *vm) : MenuView(vm) {
- _soundDriverLoaded = false;
- _previousUpdate = 0;
- _screenId = -1;
- _showWhiteBars = true;
- _resetPalette = false;
- _resyncMode = NEVER;
-
- load();
-}
-
-void AnimationView::load() {
- Common::String resName(_resourceName);
- if (!resName.hasSuffix("."))
- resName += ".res";
-
- if (!_script.open(resName))
- error("Could not open resource %s", resName.c_str());
-
- processLines();
-}
-
-bool AnimationView::onEvent(Common::Event &event) {
- // Wait for the Escape key or a mouse press
- if (((event.type == Common::EVENT_KEYDOWN) && (event.kbd.keycode == Common::KEYCODE_ESCAPE)) ||
- (event.type == Common::EVENT_RBUTTONUP)) {
- scriptDone();
- return true;
- }
-
- return false;
-}
-
-void AnimationView::doFrame() {
- // Only update state if wait period has expired
- if (_previousUpdate > 0) {
- if (g_system->getMillis() - _previousUpdate < 3000) {
- return;
- } else {
- // time for an update
- _previousUpdate = g_system->getMillis();
- }
- } else {
- _previousUpdate = g_system->getMillis();
- return;
- }
- /*
- char bgFile[10];
- strncpy(bgFile, _currentFile, 5);
- bgFile[0] = bgFile[2];
- bgFile[1] = bgFile[3];
- bgFile[2] = bgFile[4];
- bgFile[3] = '\0';
- bgNumber = atoi(bgFile);
- sprintf(bgFile, "rm%i.art", bgNumber);
-
- // Not all scenes have a background. If there is one, refresh it
- if (Common::File::exists(bgFile)) {
- _vm->_palette->resetGamePalette(4, 8);
- SceneInfo *sceneInfo = SceneInfo::init(_vm);
- sceneInfo->load(bgNumber, 0, Common::String(), 0, scene._depthSurface,
- scene._backgroundSurface);
- }
- */
-}
-
-void AnimationView::scriptDone() {
- _breakFlag = true;
- _vm->_dialogs->_pendingDialog = DIALOG_MAIN_MENU;
-}
-
-void AnimationView::processLines() {
- if (_script.eos()) {
- // end of script, end animation
- scriptDone();
- return;
- }
-
- char c;
- while (!_script.eos()) {
- // Get in next line
- _currentLine.empty();
- while (!_script.eos() && (c = _script.readByte()) != '\n') {
- if (c != '\r')
- _currentLine += c;
- }
-
- // Process the line
- while (!_currentLine.empty()) {
- if (_currentLine.hasPrefix("-")) {
- _currentLine.deleteChar(0);
-
- processCommand();
- } else {
- // Get resource name
- Common::String resName;
- while (!_currentLine.empty() && (c = _currentLine[0]) != ' ') {
- _currentLine.deleteChar(0);
- resName += c;
- }
-
- _resources.push_back(ResourceEntry(resName, _sfx));
- _sfx = 0;
- }
-
- // Skip any spaces
- while (_currentLine.hasPrefix(" "))
- _currentLine.deleteChar(0);
- }
- }
-}
-
-void AnimationView::processCommand() {
- // Get the command character
- char commandChar = toupper(_currentLine[0]);
- _currentLine.deleteChar(0);
-
- // Handle the command
- switch (commandChar) {
- case 'H':
- // -h[:ex] Disable EMS / XMS high memory support
- if (_currentLine.hasPrefix(":"))
- _currentLine.deleteChar(0);
- while (_currentLine.hasPrefix("e") || _currentLine.hasPrefix("x"))
- _currentLine.deleteChar(0);
- break;
- case 'O':
- // -o:xxx Specify opening special effect
- assert(_currentLine[0] == ':');
- _currentLine.deleteChar(0);
- _sfx = getParameter();
- break;
- case 'P':
- // Switch to CONCAT mode, which is ignored anyway
- break;
- case 'R': {
- // Resynch timer (always, beginning, never)
- assert(_currentLine[0] == ':');
- _currentLine.deleteChar(0);
-
- char v = toupper(_currentLine[0]);
- _currentLine.deleteChar(0);
- if (v == 'N')
- _resyncMode = NEVER;
- else if (v == 'A')
- _resyncMode = ALWAYS;
- else if (v == 'B')
- _resyncMode = BEGINNING;
- else
- error("Unknown parameter");
- break;
- }
- case 'W':
- // Switch white bars being visible
- _showWhiteBars = !_showWhiteBars;
- break;
- case 'X':
- // Exit after animation finishes. Ignore
- break;
- case 'Y':
- // Reset palette on startup
- _resetPalette = true;
- break;
- default:
- error("Unknown command char: '%c'", commandChar);
- }
-}
-
-int AnimationView::getParameter() {
- int result = 0;
-
- while (!_currentLine.empty()) {
- char c = _currentLine[0];
-
- if (c >= '0' && c <= '9') {
- _currentLine.deleteChar(0);
- result = result * 10 + (c - '0');
- } else {
- break;
- }
+ Common::String s = getResourceName();
+ if (s == "rexend1") {
+ TextView::execute(_vm, "ending1");
+ } else if (s == "rexend2") {
+ TextView::execute(_vm, "ending2");
+ } else if (s == "rexend3") {
+ TextView::execute(_vm, "credits");
}
-
- return result;
}
-
} // End of namespace Nebular
} // End of namespace MADS
diff --git a/engines/mads/nebular/menu_nebular.h b/engines/mads/nebular/menu_nebular.h
index 7abe3c8892..77b8b6fc6e 100644
--- a/engines/mads/nebular/menu_nebular.h
+++ b/engines/mads/nebular/menu_nebular.h
@@ -25,6 +25,7 @@
#include "common/scummsys.h"
#include "mads/game.h"
+#include "mads/menu_views.h"
#include "mads/msurface.h"
#include "mads/nebular/dialogs_nebular.h"
@@ -36,27 +37,6 @@ namespace Nebular {
enum MADSGameAction { START_GAME, RESUME_GAME, SHOW_INTRO, CREDITS, QUOTES, EXIT };
-class MenuView: public FullScreenDialog {
-protected:
- bool _breakFlag;
- bool _redrawFlag;
-
- virtual void doFrame() = 0;
-
- virtual void display();
-
- /**
- * Event handler
- */
- virtual bool onEvent(Common::Event &event);
-public:
- MenuView(MADSEngine *vm);
-
- virtual ~MenuView() {}
-
- virtual void show();
-};
-
class MainMenu: public MenuView {
private:
SpriteAsset *_menuItems[7];
@@ -100,6 +80,8 @@ private:
* Add a sprite slot for the current menuitem frame
*/
void addSpriteSlot();
+
+ bool shouldShowQuotes();
protected:
/**
* Display the menu
@@ -148,136 +130,16 @@ public:
void show();
};
-struct TextLine {
- Common::Point _pos;
- Common::String _line;
- int _textDisplayIndex;
-};
-
-/**
- * Scrolling text view
- */
-class TextView : public MenuView {
-private:
- static char _resourceName[100];
-
- bool _animating;
- bool _sceneChanged;
- Common::Array<TextLine> _textLines;
- Common::Point _pan;
- int _panSpeed;
- MSurface _spareScreens[4];
- int _scrollCount;
- int _lineY;
- uint32 _scrollTimeout;
- int _panCountdown;
- int _translationX;
- Common::File _script;
- char _currentLine[80];
- MSurface *_spareScreen;
- Font *_font;
-private:
- /**
- * Load the text resource
- */
- void load();
-
- /**
- * Process the lines
- */
- void processLines();
-
- /**
- * Process a command from the script file
- */
- void processCommand();
-
- /**
- * Process text from the script file
- */
- void processText();
-
- /**
- * Get a parameter from line
- */
- int getParameter(const char **paramP);
-
- /**
- * Called when the script is finished
- */
- void scriptDone();
-
- /**
- * Reset the game palette
- */
- void resetPalette();
+class RexAnimationView : public AnimationView {
protected:
- virtual void display();
-
- virtual void doFrame();
+ virtual void scriptDone();
public:
- /**
- * Queue the given text resource for display
- */
- static void execute(MADSEngine *vm, const Common::String &resName);
-
- TextView(MADSEngine *vm);
-
- virtual ~TextView();
-};
-
-enum ResyncMode { NEVER, ALWAYS, BEGINNING };
-
-struct ResourceEntry {
- Common::String _resourceName;
- int _sfx;
-
- ResourceEntry() {}
- ResourceEntry(const Common::String &resName, int sfx) {
- _resourceName = resName;
- _sfx = sfx;
- }
+ RexAnimationView(MADSEngine *vm) : AnimationView(vm) {}
};
-/**
-* Animation cutscene view
-*/
-class AnimationView : public MenuView {
-private:
- static char _resourceName[100];
-
- Common::File _script;
- uint32 _previousUpdate;
- Common::String _currentLine;
- bool _soundDriverLoaded;
- bool _showWhiteBars;
- bool _resetPalette;
- ResyncMode _resyncMode;
- int _sfx;
- Common::Array<ResourceEntry> _resources;
-private:
- void load();
-
- void processLines();
-
- void processCommand();
-
- int getParameter();
-
- void scriptDone();
-protected:
- virtual void doFrame();
-
- virtual bool onEvent(Common::Event &event);
+class RexTextView : public TextView {
public:
- /**
- * Queue the given text resource for display
- */
- static void execute(MADSEngine *vm, const Common::String &resName);
-
- AnimationView(MADSEngine *vm);
-
- virtual ~AnimationView() {}
+ RexTextView(MADSEngine *vm) : TextView(vm) {}
};
} // End of namespace Nebular
diff --git a/engines/mads/nebular/nebular_scenes5.cpp b/engines/mads/nebular/nebular_scenes5.cpp
index 5a67d1541f..66d8294fc6 100644
--- a/engines/mads/nebular/nebular_scenes5.cpp
+++ b/engines/mads/nebular/nebular_scenes5.cpp
@@ -2847,8 +2847,6 @@ void Scene551::actions() {
_vm->_dialogs->show(55113);
else if (_action.isAction(VERB_LOOK, NOUN_TELEPORTER))
_vm->_dialogs->show(55114);
- else if (_action.isAction(VERB_LOOK, NOUN_BUILDING))
- _vm->_dialogs->show(55115);
else if (_action.isAction(VERB_LOOK, NOUN_SIDEWALK_TO_WEST)) {
if (_game._visitedScenes.exists(505))
_vm->_dialogs->show(55116);
diff --git a/engines/mads/nebular/nebular_scenes6.cpp b/engines/mads/nebular/nebular_scenes6.cpp
index d33675c578..679039535f 100644
--- a/engines/mads/nebular/nebular_scenes6.cpp
+++ b/engines/mads/nebular/nebular_scenes6.cpp
@@ -643,7 +643,8 @@ void Scene603::actions() {
_game._player._visible = true;
_game._player._stepEnabled = true;
}
- }
+ } else
+ _vm->_dialogs->show(60323);
} else if (_action._lookFlag)
_vm->_dialogs->show(60310);
else if (_action.isAction(VERB_LOOK, NOUN_BED))
@@ -670,8 +671,6 @@ void Scene603::actions() {
_vm->_dialogs->show(60321);
else if (_action.isAction(VERB_TAKE, NOUN_PERFUME))
_vm->_dialogs->show(60322);
- else if (_action.isAction(VERB_TAKE, NOUN_NOTE))
- _vm->_dialogs->show(60323);
else if (_action.isAction(VERB_LOOK, NOUN_NOTE)) {
if (_game._objects[OBJ_NOTE]._roomNumber == _scene->_currentSceneId)
_vm->_dialogs->show(60324);
@@ -3156,7 +3155,7 @@ bool Scene611::check2ChargedBatteries() {
}
bool Scene611::check4ChargedBatteries() {
- if (_game._objects.isInInventory(OBJ_DURAFAIL_CELLS) && _game._objects.isInInventory(OBJ_PHONE_CELLS)
+ if (_game._objects.isInInventory(OBJ_DURAFAIL_CELLS) && _game._objects.isInInventory(OBJ_PHONE_CELLS)
&& _globals[kDurafailRecharged])
return true;
diff --git a/engines/mads/nebular/nebular_scenes7.cpp b/engines/mads/nebular/nebular_scenes7.cpp
index 930bb7c250..0f019c4b19 100644
--- a/engines/mads/nebular/nebular_scenes7.cpp
+++ b/engines/mads/nebular/nebular_scenes7.cpp
@@ -2616,7 +2616,7 @@ void Scene752::actions() {
default:
break;
}
- } else if (_action.isAction(VERB_TAKE, NOUN_BONES) && (_action._savedFields._mainObjectSource == CAT_HOTSPOT) &&
+ } else if (_action.isAction(VERB_TAKE, NOUN_BONES) && (_action._savedFields._mainObjectSource == CAT_HOTSPOT) &&
(!_game._objects.isInInventory(OBJ_BONES) || _game._trigger)) {
switch (_game._trigger) {
case 0:
diff --git a/engines/mads/nebular/nebular_scenes8.cpp b/engines/mads/nebular/nebular_scenes8.cpp
index 14f36756de..62a1a262b0 100644
--- a/engines/mads/nebular/nebular_scenes8.cpp
+++ b/engines/mads/nebular/nebular_scenes8.cpp
@@ -1098,7 +1098,7 @@ void Scene804::actions() {
_action.isAction(VERB_OPEN, NOUN_SERVICE_PANEL)) {
_scene->_nextSceneId = 805;
} else if ((_action.isAction(VERB_ACTIVATE, NOUN_REMOTE)) && _globals[kTopButtonPushed]) {
- if (!_globals[kInSpace]) {
+ if (!_globals[kInSpace]) {
// Top button pressed on panel in hanger control
if (!_globals[kBeamIsUp]) {
_globals[kFromCockpit] = true;
diff --git a/engines/mads/nebular/sound_nebular.cpp b/engines/mads/nebular/sound_nebular.cpp
index 5ce362e053..0a054440b2 100644
--- a/engines/mads/nebular/sound_nebular.cpp
+++ b/engines/mads/nebular/sound_nebular.cpp
@@ -24,6 +24,7 @@
#include "audio/decoders/raw.h"
#include "common/algorithm.h"
#include "common/debug.h"
+#include "common/md5.h"
#include "common/memstream.h"
#include "mads/sound.h"
#include "mads/nebular/sound_nebular.h"
@@ -218,6 +219,32 @@ ASound::~ASound() {
_mixer->stopHandle(_soundHandle);
}
+void ASound::validate() {
+ Common::File f;
+ static const char *const MD5[] = {
+ "205398468de2c8873b7d4d73d5be8ddc",
+ "f9b2d944a2fb782b1af5c0ad592306d3",
+ "7431f8dad77d6ddfc24e6f3c0c4ac7df",
+ "eb1f3f5a4673d3e73d8ac1818c957cf4",
+ "f936dd853073fa44f3daac512e91c476",
+ "3dc139d3e02437a6d9b732072407c366",
+ "af0edab2934947982e9a405476702e03",
+ "8cbc25570b50ba41c9b5361cad4fbedc",
+ "a31e4783e098f633cbb6689adb41dd4f"
+ };
+
+ for (int i = 1; i <= 9; ++i) {
+ Common::String filename = Common::String::format("ASOUND.00%d", i);
+ if (!f.open(filename))
+ error("Could not process - %s", filename.c_str());
+ Common::String md5str = Common::computeStreamMD5AsString(f, 8192);
+ f.close();
+
+ if (md5str != MD5[i - 1])
+ error("Invalid sound file - %s", filename.c_str());
+ }
+}
+
void ASound::adlibInit() {
write(4, 0x60);
write(4, 0x80);
@@ -3141,7 +3168,7 @@ ASound9::ASound9(Audio::Mixer *mixer, FM_OPL *opl) : ASound(mixer, opl, "asound.
}
int ASound9::command(int commandId, int param) {
- if (commandId > 60)
+ if (commandId > 51)
return 0;
_commandParam = param;
diff --git a/engines/mads/nebular/sound_nebular.h b/engines/mads/nebular/sound_nebular.h
index abb6516030..ccfd40ad52 100644
--- a/engines/mads/nebular/sound_nebular.h
+++ b/engines/mads/nebular/sound_nebular.h
@@ -318,6 +318,11 @@ public:
virtual ~ASound();
/**
+ * Validates the Adlib sound files
+ */
+ static void validate();
+
+ /**
* Execute a player command. Most commands represent sounds to play, but some
* low number commands also provide control operations.
* @param commandId Player ommand to execute.
diff --git a/engines/mads/palette.cpp b/engines/mads/palette.cpp
index eedbf36ddd..836d04f7c0 100644
--- a/engines/mads/palette.cpp
+++ b/engines/mads/palette.cpp
@@ -143,7 +143,7 @@ int PaletteUsage::process(Common::Array<RGB6> &palette, uint flags) {
for (uint palIndex = 0; palIndex < palette.size(); ++palIndex) {
bool changed = false;
- int newPalIndex = -1;
+ int newPalIndex = 0xFF;
int v1 = palRange[palIndex]._v2;
if (palette[v1]._flags & 8) {
@@ -229,8 +229,11 @@ int PaletteUsage::process(Common::Array<RGB6> &palette, uint flags) {
// In at least scene 318, when the doctor knocks you with the blackjack,
// the changed flag can be false
//assert(changed);
- assert(newPalIndex != -1);
-
+
+ // CHECKME: When pressing on F1 in the first screen, newPalIndex is set to 0xFF at this point
+ // which is a valid value for the index. Maybe a better check would be "< 256" ?
+ //assert(newPalIndex != -1);
+
int var52 = (noUsageFlag && palette[palIndex]._u2) ? 2 : 0;
_vm->_palette->_palFlags[newPalIndex] |= var52 | rgbMask;
@@ -314,6 +317,62 @@ int PaletteUsage::rgbFactor(byte *palEntry, RGB6 &pal6) {
return total;
}
+int PaletteUsage::checkRGB(const byte *rgb, int palStart, bool flag, int *palIndex) {
+ Palette &palette = *_vm->_palette;
+ bool match = false;
+ int result;
+ if (palStart >= 0) {
+ result = palStart;
+ } else {
+ result = -1;
+ for (int i = 0; i < palette._highRange; ++i) {
+ if (!palette._rgbList[i]) {
+ result = i;
+ break;
+ }
+ }
+ }
+
+ if (result >= 0) {
+ int mask = 1 << result;
+ byte *palP = &palette._mainPalette[0];
+ uint32 *flagsP = &palette._palFlags[0];
+
+ for (; flagsP < &palette._palFlags[PALETTE_COUNT]; ++flagsP, ++result) {
+ if ((!(*flagsP & 1) || flag) && !(*flagsP & 2)) {
+ if (!memcmp(palP, rgb, 3)) {
+ *flagsP |= mask;
+
+ if (palIndex)
+ *palIndex = result;
+ match = true;
+ break;
+ }
+ }
+ }
+
+ if (!match) {
+ palP = &palette._mainPalette[0];
+ flagsP = &palette._palFlags[0];
+
+ for (int i = 0; i < PALETTE_COUNT; ++i, palP += 3, ++flagsP) {
+ if (!*flagsP) {
+ Common::copy(rgb, rgb + 3, palP);
+ *flagsP |= mask;
+
+ if (palIndex)
+ *palIndex = i;
+ match = true;
+ break;
+ }
+ }
+ }
+ }
+
+ assert(match);
+ return result;
+}
+
/*------------------------------------------------------------------------*/
void RGBList::clear() {
diff --git a/engines/mads/palette.h b/engines/mads/palette.h
index 9b8b7146db..27d25f266b 100644
--- a/engines/mads/palette.h
+++ b/engines/mads/palette.h
@@ -136,6 +136,8 @@ public:
void updateUsage(Common::Array<int> &usageList, int sceneUsageIndex);
void resetPalFlags(int idx);
+
+ int checkRGB(const byte *rgb, int palStart, bool flag, int *palIndex);
};
class RGBList {
diff --git a/engines/mads/phantom/game_phantom.cpp b/engines/mads/phantom/game_phantom.cpp
index ba2179fcbf..0b2531ef65 100644
--- a/engines/mads/phantom/game_phantom.cpp
+++ b/engines/mads/phantom/game_phantom.cpp
@@ -50,11 +50,12 @@ void GamePhantom::startGame() {
}
void GamePhantom::initializeGlobals() {
- //int count, count2;
- //int bad;
-
_globals.reset();
- //_globals[kTalkInanimateCount] = 8;
+
+ warning("TODO: sub_316DA()");
+
+ _player._facing = FACING_NORTH;
+ _player._turnToFacing = FACING_NORTH;
/* Section #1 variables */
// TODO
@@ -74,11 +75,7 @@ void GamePhantom::initializeGlobals() {
/* Section #9 variables */
// TODO
- _player._facing = FACING_NORTH;
- _player._turnToFacing = FACING_NORTH;
-
- //Player::preloadSequences("RXM", 1);
- //Player::preloadSequences("ROX", 1);
+ Player::preloadSequences("RAL", 1);
}
void GamePhantom::setSectionHandler() {
diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp
index ad24dd4f60..d2b4b29622 100644
--- a/engines/mads/scene.cpp
+++ b/engines/mads/scene.cpp
@@ -31,7 +31,7 @@
namespace MADS {
Scene::Scene(MADSEngine *vm)
- : _vm(vm), _action(_vm), _depthSurface(vm),
+ : _vm(vm), _action(_vm), _depthSurface(),
_dirtyAreas(_vm), _dynamicHotspots(vm), _hotspots(vm),
_kernelMessages(vm), _sequences(vm), _sprites(vm), _spriteSlots(vm),
_textDisplay(vm), _userInterface(vm) {
@@ -182,7 +182,7 @@ void Scene::loadScene(int sceneId, const Common::String &prefix, bool palFlag) {
flags |= ANIMFLAG_LOAD_BACKGROUND_ONLY;
_animationData = Animation::init(_vm, this);
- DepthSurface depthSurface(_vm);
+ DepthSurface depthSurface;
_animationData->load(_userInterface, depthSurface, prefix, flags, nullptr, nullptr);
_vm->_palette->_paletteUsage.load(&_scenePaletteUsage);
@@ -360,6 +360,9 @@ void Scene::loop() {
if (_vm->_dialogs->_pendingDialog != DIALOG_NONE && !_vm->_game->_trigger
&& _vm->_game->_player._stepEnabled)
_reloadSceneFlag = true;
+
+ if (_vm->_game->_winStatus)
+ break;
}
}
@@ -608,7 +611,7 @@ void Scene::loadAnimation(const Common::String &resName, int trigger) {
if (_activeAnimation)
freeAnimation();
- DepthSurface depthSurface(_vm);
+ DepthSurface depthSurface;
UserInterface interfaceSurface(_vm);
_activeAnimation = Animation::init(_vm, this);
diff --git a/engines/mads/scene.h b/engines/mads/scene.h
index ee7864cfee..9fd99ad8e5 100644
--- a/engines/mads/scene.h
+++ b/engines/mads/scene.h
@@ -52,11 +52,6 @@ private:
*/
void loadVocabStrings();
- /*
- * Initializes the data for palette animation within the scene
- */
- void initPaletteAnimation(Common::Array<PaletteCycle> &palCycles, bool animFlag);
-
/**
* Handles a single frame within the game scene
*/
@@ -204,6 +199,11 @@ public:
*/
void drawElements(ScreenTransition transitionType, bool surfaceFlag);
+ /*
+ * Initializes the data for palette animation within the scene
+ */
+ void initPaletteAnimation(Common::Array<PaletteCycle> &palCycles, bool animFlag);
+
/**
* Handles cycling palette colors for the scene
*/
diff --git a/engines/mads/scene_data.cpp b/engines/mads/scene_data.cpp
index 174579a624..b5e219ed04 100644
--- a/engines/mads/scene_data.cpp
+++ b/engines/mads/scene_data.cpp
@@ -217,7 +217,7 @@ void SceneInfo::load(int sceneId, int variant, const Common::String &resName,
int width = _width;
int height = _height;
- if (!bgSurface.getPixels()) {
+ if (!bgSurface.getPixels() || (bgSurface.w != width) || (bgSurface.h != height)) {
bgSurface.setSize(width, height);
}
@@ -232,7 +232,7 @@ void SceneInfo::load(int sceneId, int variant, const Common::String &resName,
infoFile.close();
if (_vm->getGameID() == GType_RexNebular) {
- loadMadsV1Background(_sceneId, resName, flags, bgSurface);
+ loadMadsV1Background(_artFileNum, resName, flags, bgSurface);
loadPalette(_sceneId, _artFileNum, resName, flags, bgSurface);
} else {
loadMadsV2Background(_sceneId, resName, flags, bgSurface);
@@ -264,7 +264,7 @@ void SceneInfo::load(int sceneId, int variant, const Common::String &resName,
assert(asset && _depthStyle != 2);
MSprite *spr = asset->getFrame(asset->getCount() - 1);
- bgSurface.copyFrom(spr, si._position, si._depth, &depthSurface,
+ bgSurface.copyFrom(spr, si._position, si._depth, &depthSurface,
si._scale, spr->getTransparencyIndex());
}
@@ -299,6 +299,7 @@ void SceneInfo::loadPalette(int sceneId, int artFileNum, const Common::String &r
delete stream;
// Copy out the palette animation data
+ _paletteCycles.clear();
for (uint i = 0; i < artHeader._paletteCycles.size(); ++i)
_paletteCycles.push_back(artHeader._paletteCycles[i]);
@@ -342,8 +343,8 @@ void SceneInfo::loadMadsV1Background(int sceneId, const Common::String &resName,
File artFile(resourceName);
MadsPack artResource(&artFile);
- // Read in the background surface data
- assert(_width == bgSurface.w && _height == bgSurface.h);
+ // Read inhh the background surface data
+ assert(_width && _height == bgSurface.h);
stream = artResource.getItemStream(1);
stream->read(bgSurface.getPixels(), bgSurface.w * bgSurface.h);
delete stream;
@@ -353,7 +354,9 @@ void SceneInfo::loadMadsV1Background(int sceneId, const Common::String &resName,
Common::SeekableReadStream *palStream = artResource.getItemStream(0);
Common::Array<RGB6> palette;
- palStream->skip(4); // Skip width and height
+ _width = palStream->readUint16LE();
+ _height = palStream->readUint16LE();
+
int numColors = palStream->readUint16LE();
assert(numColors <= 252);
palette.resize(numColors);
diff --git a/engines/mads/screen.cpp b/engines/mads/screen.cpp
index 590e63ac9e..c9a0863d85 100644
--- a/engines/mads/screen.cpp
+++ b/engines/mads/screen.cpp
@@ -212,7 +212,7 @@ void DirtyAreas::copy(MSurface *srcSurface, MSurface *destSurface, const Common:
Common::Rect bounds(srcBounds.left + posAdjust.x, srcBounds.top + posAdjust.y,
srcBounds.right + posAdjust.x, srcBounds.bottom + posAdjust.y);
- Common::Point destPos(bounds.left, bounds.top);
+ Common::Point destPos(srcBounds.left, srcBounds.top);
if ((*this)[i]._active && bounds.isValidRect()) {
srcSurface->copyTo(destSurface, bounds, destPos);
diff --git a/engines/mads/sequence.cpp b/engines/mads/sequence.cpp
index 07b1451718..05f00afb5a 100644
--- a/engines/mads/sequence.cpp
+++ b/engines/mads/sequence.cpp
@@ -473,7 +473,7 @@ int SequenceList::startReverseCycle(int srcSpriteIndex, bool flipped, int numTic
int depth = _vm->_game->_scene._depthSurface.getDepth(Common::Point(
frame->_offset.x + frame->w / 2, frame->_offset.y + frame->h / 2));
- return add(srcSpriteIndex, flipped, sprites->getCount(), triggerCountdown, timeoutTicks,
+ return add(srcSpriteIndex, flipped, sprites->getCount(), triggerCountdown, timeoutTicks,
extraTicks, numTicks, 0, 0, true, 100, depth - 1, -1, ANIMTYPE_REVERSIBLE, 0, 0);
}
diff --git a/engines/mads/sound.cpp b/engines/mads/sound.cpp
index 12109895b5..1652550ba3 100644
--- a/engines/mads/sound.cpp
+++ b/engines/mads/sound.cpp
@@ -29,18 +29,34 @@
namespace MADS {
-SoundManager::SoundManager(MADSEngine *vm, Audio::Mixer *mixer, FM_OPL *opl) {
+SoundManager::SoundManager(MADSEngine *vm, Audio::Mixer *mixer) {
_vm = vm;
_mixer = mixer;
- _opl = opl;
_driver = nullptr;
_pollSoundEnabled = false;
_soundPollFlag = false;
_newSoundsPaused = false;
+
+ _opl = OPL::Config::create();
+ _opl->init(11025);
+
+ // Validate sound files
+ switch (_vm->getGameID()) {
+ case GType_RexNebular:
+ Nebular::ASound::validate();
+ break;
+ default:
+ break;
+ }
}
SoundManager::~SoundManager() {
- delete _driver;
+ if (_driver) {
+ _driver->stop();
+ delete _driver;
+ }
+
+ delete _opl;
}
void SoundManager::init(int sectionNumber) {
diff --git a/engines/mads/sound.h b/engines/mads/sound.h
index b2af7e2346..72bb21a812 100644
--- a/engines/mads/sound.h
+++ b/engines/mads/sound.h
@@ -44,7 +44,7 @@ private:
bool _newSoundsPaused;
Common::Queue<int> _queuedCommands;
public:
- SoundManager(MADSEngine *vm, Audio::Mixer *mixer, FM_OPL *opl);
+ SoundManager(MADSEngine *vm, Audio::Mixer *mixer);
~SoundManager();
/**
diff --git a/engines/mads/sprites.cpp b/engines/mads/sprites.cpp
index cd358077b5..fd73930475 100644
--- a/engines/mads/sprites.cpp
+++ b/engines/mads/sprites.cpp
@@ -262,7 +262,7 @@ void SpriteSlots::drawBackground() {
scene._backgroundSurface.copyFrom(frame, pt, spriteSlot._depth, &scene._depthSurface,
-1, false, frame->getTransparencyIndex());
} else {
- error("Unsupported depth style");
+ frame->copyTo(&scene._backgroundSurface, pt, frame->getTransparencyIndex());
}
}
}
@@ -404,9 +404,9 @@ void SpriteSets::remove(int idx) {
delete (*this)[idx];
(*this)[idx] = nullptr;
} else {
- while (size() > 0 && (*this)[size() - 1] == nullptr) {
+ do {
remove_at(size() - 1);
- }
+ } while (size() > 0 && (*this)[size() - 1] == nullptr);
}
if (_assetCount > 0)
diff --git a/engines/mads/user_interface.h b/engines/mads/user_interface.h
index f251441e40..89044c9bf1 100644
--- a/engines/mads/user_interface.h
+++ b/engines/mads/user_interface.h
@@ -225,7 +225,7 @@ public:
/**
* Loads an interface from a specified resource
*/
- void load(const Common::String &resName);
+ virtual void load(const Common::String &resName);
/**
* Set up the interface
diff --git a/engines/mohawk/riven_external.cpp b/engines/mohawk/riven_external.cpp
index 3d0bccc47f..cda0683028 100644
--- a/engines/mohawk/riven_external.cpp
+++ b/engines/mohawk/riven_external.cpp
@@ -2513,7 +2513,7 @@ void RivenExternal::xthideinventory(uint16 argc, uint16 *argv) {
static const uint32 kMarbleCount = 6;
static const int kSmallMarbleWidth = 4;
static const int kSmallMarbleHeight = 2;
-static const int kLargeMarbleSize = 8;
+//static const int kLargeMarbleSize = 8;
static const int kMarbleHotspotSize = 13;
static const char *s_marbleNames[] = { "tred", "torange", "tyellow", "tgreen", "tblue", "tviolet" };
diff --git a/engines/mortevielle/detection_tables.h b/engines/mortevielle/detection_tables.h
index 0aa27b89eb..d244d15365 100644
--- a/engines/mortevielle/detection_tables.h
+++ b/engines/mortevielle/detection_tables.h
@@ -75,7 +75,7 @@ static const MortevielleGameDescription MortevielleGameDescriptions[] = {
// DOS English version doesn't exist. Technically, they are French or German versions,
// using English strings stored mort.dat
-
+
// English on top of French version
{
{
diff --git a/engines/mortevielle/mortevielle.h b/engines/mortevielle/mortevielle.h
index c3d1e4ae8b..5f7f175c26 100644
--- a/engines/mortevielle/mortevielle.h
+++ b/engines/mortevielle/mortevielle.h
@@ -421,7 +421,7 @@ public:
byte *_curPict;
byte *_curAnim;
byte *_rightFramePict;
-
+
PaletteManager _paletteManager;
GfxSurface _backgroundSurface;
Common::RandomSource _randomSource;
diff --git a/engines/mortevielle/utils.cpp b/engines/mortevielle/utils.cpp
index d5dec6a286..40136ad78b 100644
--- a/engines/mortevielle/utils.cpp
+++ b/engines/mortevielle/utils.cpp
@@ -3097,7 +3097,7 @@ void MortevielleEngine::putObject() {
*/
void MortevielleEngine::addObjectToInventory(int objectId) {
int i;
-
+
for (i = 1; (i <= 5) && (_coreVar._inventory[i] != 0); i++)
;
diff --git a/engines/neverhood/console.cpp b/engines/neverhood/console.cpp
index 91ab3e767a..7ee6b30311 100644
--- a/engines/neverhood/console.cpp
+++ b/engines/neverhood/console.cpp
@@ -55,7 +55,7 @@ bool Console::Cmd_Scene(int argc, const char **argv) {
const char *sceneTypes[] = { "normal", "smacker", "navigation" };
- debugPrintf("Current module: %d, previous module: %d, scene %d (%s scene)\n", currentModule, previousModule, scenenNum, sceneTypes[sceneType]);
+ debugPrintf("Current module: %d, previous module: %d, scene %d (%s scene)\n", currentModule, previousModule, scenenNum, sceneTypes[sceneType]);
if (sceneType == kSceneTypeNormal) {
Scene *scene = (Scene *)((GameModule *)_vm->_gameModule->_childObject)->_childObject;
diff --git a/engines/neverhood/modules/module2400.cpp b/engines/neverhood/modules/module2400.cpp
index 3acb952db9..4bfc10abbf 100644
--- a/engines/neverhood/modules/module2400.cpp
+++ b/engines/neverhood/modules/module2400.cpp
@@ -168,11 +168,6 @@ static const uint32 kScene2401FileHashes2[] = {
0xD0910068, 0xD09100A8, 0
};
-static const uint32 kScene2401FileHashes3[] = {
- 0xD0910020, 0xD0910038, 0xD0910008,
- 0xD0910068, 0xD09100A8, 0
-};
-
static const NRect kScene2401Rects[] = {
{ 369, 331, 394, 389 },
{ 395, 331, 419, 389 },
@@ -264,11 +259,11 @@ void Scene2401::update() {
} else if (_pipeStatus >= 5) {
_ssWaterPipes[_pipeStatus]->setVisible(true);
_countdown1 = 8;
- playPipeSound(kScene2401FileHashes3[getSubVar(VA_CURR_WATER_PIPES_LEVEL, _pipeStatus - 5)]);
+ playPipeSound(kScene2401FileHashes2[getSubVar(VA_CURR_WATER_PIPES_LEVEL, _pipeStatus - 5)]);
} else {
_ssWaterPipes[_pipeStatus]->setVisible(true);
_countdown1 = _pipeStatus == 4 ? 16 : 8;
- playPipeSound(kScene2401FileHashes3[getSubVar(VA_GOOD_WATER_PIPES_LEVEL, _pipeStatus)]);
+ playPipeSound(kScene2401FileHashes2[getSubVar(VA_GOOD_WATER_PIPES_LEVEL, _pipeStatus)]);
}
_pipeStatus++;
}
diff --git a/engines/neverhood/modules/module2700_sprites.cpp b/engines/neverhood/modules/module2700_sprites.cpp
index e17cddc834..079e0b7afe 100644
--- a/engines/neverhood/modules/module2700_sprites.cpp
+++ b/engines/neverhood/modules/module2700_sprites.cpp
@@ -24,62 +24,6 @@
namespace Neverhood {
-static const NRect kScene2710ClipRect = { 0, 0, 626, 480 };
-
-static const uint32 kScene2710StaticSprites[] = {
- 0x0D2016C0,
- 0
-};
-
-static const NRect kScene2711ClipRect = { 0, 0, 521, 480 };
-
-static const uint32 kScene2711FileHashes1[] = {
- 0,
- 0x100801A1,
- 0x201081A0,
- 0x006800A4,
- 0x40390120,
- 0x000001B1,
- 0x001000A1,
- 0
-};
-
-static const uint32 kScene2711FileHashes2[] = {
- 0,
- 0x40403308,
- 0x71403168,
- 0x80423928,
- 0x224131A8,
- 0x50401328,
- 0x70423328,
- 0
-};
-
-static const uint32 kScene2711FileHashes3[] = {
- 0,
- 0x1088A021,
- 0x108120E5,
- 0x18A02321,
- 0x148221A9,
- 0x10082061,
- 0x188820E1,
- 0
-};
-
-static const NRect kScene2724ClipRect = { 0, 141, 640, 480 };
-
-static const uint32 kScene2724StaticSprites[] = {
- 0xC20D00A5,
- 0
-};
-
-static const NRect kScene2725ClipRect = { 0, 0, 640, 413 };
-
-static const uint32 kScene2725StaticSprites[] = {
- 0xC20E00A5,
- 0
-};
-
static const NPoint kCarShadowOffsets[] = {
{-63, 3}, {-48, 40}, {-33, 58},
{ 0, 65}, { 40, 53}, { 56, 27},
diff --git a/engines/neverhood/modules/module2800.cpp b/engines/neverhood/modules/module2800.cpp
index a59c3f8156..ab22390c7d 100644
--- a/engines/neverhood/modules/module2800.cpp
+++ b/engines/neverhood/modules/module2800.cpp
@@ -1477,21 +1477,6 @@ static const uint32 kScene2808FileHashes2[] = {
0xB0196098
};
-static const uint32 kClass428FileHashes[] = {
- 0x140022CA,
- 0x4C30A602,
- 0xB1633402,
- 0x12982135,
- 0x0540B728,
- 0x002A81E3,
- 0x08982841,
- 0x10982841,
- 0x20982841,
- 0x40982841,
- 0x80982841,
- 0x40800711
-};
-
Scene2808::Scene2808(NeverhoodEngine *vm, Module *parentModule, int which)
: Scene(vm, parentModule), _countdown(0), _testTubeSetNum(which), _leaveResult(0), _isFlowing(false) {
diff --git a/engines/neverhood/modules/module2800_sprites.cpp b/engines/neverhood/modules/module2800_sprites.cpp
index f9a58de92d..ad814d2b5b 100644
--- a/engines/neverhood/modules/module2800_sprites.cpp
+++ b/engines/neverhood/modules/module2800_sprites.cpp
@@ -574,16 +574,6 @@ uint32 AsScene2806Spew::handleMessage(int messageNum, const MessageParam &param,
return messageResult;
}
-static const uint32 kScene2808FileHashes1[] = {
- 0x90B0392,
- 0x90B0192
-};
-
-static const uint32 kScene2808FileHashes2[] = {
- 0xB0396098,
- 0xB0196098
-};
-
static const uint32 kClass428FileHashes[] = {
0x140022CA,
0x4C30A602,
diff --git a/engines/neverhood/modules/module3000.cpp b/engines/neverhood/modules/module3000.cpp
index d4809611ad..0f84dbd18d 100644
--- a/engines/neverhood/modules/module3000.cpp
+++ b/engines/neverhood/modules/module3000.cpp
@@ -666,18 +666,6 @@ static const uint32 kScene3010ButtonNameHashes[] = {
0x01180951
};
-static const uint32 kScene3010DeadBoltButtonFileHashes1[] = {
- 0x301024C2,
- 0x20280580,
- 0x30200452
-};
-
-static const uint32 kScene3010DeadBoltButtonFileHashes2[] = {
- 0x50C025A8,
- 0x1020A0A0,
- 0x5000A7E8
-};
-
Scene3010::Scene3010(NeverhoodEngine *vm, Module *parentModule, int which)
: Scene(vm, parentModule), _countdown(0), _doorUnlocked(false), _checkUnlocked(false) {
diff --git a/engines/neverhood/modules/module3000_sprites.cpp b/engines/neverhood/modules/module3000_sprites.cpp
index 3f883eaa72..23a388efe4 100644
--- a/engines/neverhood/modules/module3000_sprites.cpp
+++ b/engines/neverhood/modules/module3000_sprites.cpp
@@ -46,42 +46,6 @@ enum {
kCTSCount = 14
};
-static const uint32 kScene3009CannonScopeVideos[] = {
- 0x1010000D,
- 0x340A0049,
- 0x340A0049,
- 0x0282081D,
- 0x0082080D,
- 0x0882080D,
- 0x0882080D,
- 0x0282081D,
- 0x004B000B,
- 0x014B000B,
- 0x044B000B,
- 0x0282081D,
- 0x0282081D,
- 0x0282081D,
- 0x340A0049
-};
-
-static const uint32 kScene3009CannonActionVideos[] = {
- 0x00000000,
- 0x8004001B, // 1 Fire cannon at wall, it breaks (lowered)
- 0x0004001A, // 2 Fire cannon at wall, nothing happens (lowered)
- 0x1048404B, // 3 Fire cannon at emptyness (raised)
- 0x50200109, // 4 Fire cannon, robot missed (raised)
- 0x12032109, // 5 Fire cannon, robot hit (raised)
- 0x10201109, // 6 Fire cannon, no robot (raised)
- 0x000A2030, // 7 Raise the cannon
- 0x000A0028, // 8
- 0x000A0028, // 9
- 0x000A0028, // 10
- 0x040A1069, // 11
- 0x040A1069, // 12
- 0x040A1069, // 13
- 0x240A1101 // 14 Lower the cannon
-};
-
static const uint32 kSsScene3009SymbolEdgesFileHashes[] = {
0x618827A0,
0xB1A92322
diff --git a/engines/neverhood/sound.cpp b/engines/neverhood/sound.cpp
index d53243d4ba..b15bea4a64 100644
--- a/engines/neverhood/sound.cpp
+++ b/engines/neverhood/sound.cpp
@@ -560,7 +560,7 @@ int NeverhoodAudioStream::readBuffer(int16 *buffer, const int numSamples) {
} else {
while (samplesRead--) {
*buffer++ = READ_LE_UINT16(src);
- src += 2;
+ src += 2;
}
}
diff --git a/engines/pegasus/input.cpp b/engines/pegasus/input.cpp
index e1b7e25cd5..73c319bd8b 100644
--- a/engines/pegasus/input.cpp
+++ b/engines/pegasus/input.cpp
@@ -57,7 +57,7 @@ InputDeviceManager::InputDeviceManager() {
_keyMap[Common::KEYCODE_p] = false;
_keyMap[Common::KEYCODE_TILDE] = false;
_keyMap[Common::KEYCODE_BACKQUOTE] = false;
- _keyMap[Common::KEYCODE_KP7] = false;
+ _keyMap[Common::KEYCODE_KP7] = false;
_keyMap[Common::KEYCODE_BACKSPACE] = false;
_keyMap[Common::KEYCODE_KP_MULTIPLY] = false;
_keyMap[Common::KEYCODE_KP9] = false;
diff --git a/engines/pegasus/pegasus.cpp b/engines/pegasus/pegasus.cpp
index 0c8ea2e4ee..4262ad4c12 100644
--- a/engines/pegasus/pegasus.cpp
+++ b/engines/pegasus/pegasus.cpp
@@ -979,7 +979,7 @@ void PegasusEngine::doGameMenuCommand(const GameMenuCommand command) {
resetIntroTimer();
break;
case kMenuCmdPauseSave:
- result = showSaveDialog();
+ result = showSaveDialog();
if (result.getCode() != Common::kUserCanceled) {
if (result.getCode() != Common::kNoError)
diff --git a/engines/prince/animation.cpp b/engines/prince/animation.cpp
new file mode 100644
index 0000000000..aabdd7a623
--- /dev/null
+++ b/engines/prince/animation.cpp
@@ -0,0 +1,178 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public 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 "prince/animation.h"
+#include "prince/decompress.h"
+
+#include "common/debug.h"
+#include "common/endian.h"
+
+namespace Prince {
+
+Animation::Animation() : _loopCount(0), _phaseCount(0), _frameCount(0), _baseX(0), _baseY(0)
+{
+}
+
+Animation::~Animation() {
+ clear();
+}
+
+void Animation::clear() {
+ _phaseList.clear();
+ for (int i = 0; i < _frameCount; i++) {
+ _frameList[i]._surface->free();
+ delete _frameList[i]._surface;
+ _frameList[i]._surface = nullptr;
+ if (_frameList[i]._compressedData != nullptr) {
+ free(_frameList[i]._compressedData);
+ _frameList[i]._compressedData = nullptr;
+ }
+ }
+}
+
+bool Animation::loadStream(Common::SeekableReadStream &stream) {
+ stream.skip(2); // skip not used x and y coord diff
+ _loopCount = stream.readUint16LE();
+ _phaseCount = stream.readUint16LE();
+ stream.skip(2); // skip _frameCount here
+ _baseX = stream.readUint16LE();
+ _baseY = stream.readUint16LE();
+ uint32 phaseTableOffset = stream.readUint32LE();
+ uint32 tableOfFrameOffsets = stream.pos();
+
+ stream.seek(phaseTableOffset);
+ Phase tempPhase;
+ _frameCount = 0;
+ for (int phase = 0; phase < _phaseCount; phase++) {
+ tempPhase._phaseOffsetX = stream.readSint16LE();
+ tempPhase._phaseOffsetY = stream.readSint16LE();
+ tempPhase._phaseToFrameIndex = stream.readUint16LE();
+ if (tempPhase._phaseToFrameIndex > _frameCount) {
+ _frameCount = tempPhase._phaseToFrameIndex;
+ }
+ _phaseList.push_back(tempPhase);
+ stream.skip(2);
+ }
+ if (_phaseCount) {
+ _frameCount++;
+ }
+
+ Frame tempFrame;
+ for (int frame = 0; frame < _frameCount; frame++) {
+ stream.seek(tableOfFrameOffsets + frame * 4);
+ uint32 frameInfoOffset = stream.readUint32LE();
+ stream.seek(frameInfoOffset);
+ uint16 frameWidth = stream.readUint16LE();
+ uint16 frameHeight = stream.readUint16LE();
+ uint32 frameDataPos = stream.pos();
+ uint32 frameDataOffset = stream.readUint32BE();
+
+ tempFrame._surface = new Graphics::Surface();
+ tempFrame._surface->create(frameWidth, frameHeight, Graphics::PixelFormat::createFormatCLUT8());
+ if (frameDataOffset == MKTAG('m', 'a', 's', 'm')) {
+ tempFrame._isCompressed = true;
+ tempFrame._dataSize = stream.readUint32LE();
+ tempFrame._compressedData = (byte *)malloc(tempFrame._dataSize);
+ stream.read(tempFrame._compressedData, tempFrame._dataSize);
+ } else {
+ tempFrame._isCompressed = false;
+ tempFrame._dataSize = 0;
+ tempFrame._compressedData = nullptr;
+ stream.seek(frameDataPos);
+ for (uint16 i = 0; i < frameHeight; i++) {
+ stream.read(tempFrame._surface->getBasePtr(0, i), frameWidth);
+ }
+ }
+ _frameList.push_back(tempFrame);
+ }
+
+ return true;
+}
+
+int16 Animation::getLoopCount() const {
+ return _loopCount;
+}
+
+int32 Animation::getPhaseCount() const {
+ return _phaseCount;
+}
+
+int32 Animation::getFrameCount() const {
+ return _frameCount;
+}
+
+int16 Animation::getBaseX() const {
+ return _baseX;
+}
+
+int16 Animation::getBaseY() const {
+ return _baseY;
+}
+
+int16 Animation::getPhaseOffsetX(int phaseIndex) const {
+ if (phaseIndex < _phaseCount) {
+ return _phaseList[phaseIndex]._phaseOffsetX;
+ } else {
+ error("getPhaseOffsetX() phaseIndex: %d, phaseCount: %d", phaseIndex, _phaseCount);
+ }
+}
+
+int16 Animation::getPhaseOffsetY(int phaseIndex) const {
+ if (phaseIndex < _phaseCount) {
+ return _phaseList[phaseIndex]._phaseOffsetY;
+ } else {
+ error("getPhaseOffsetY() phaseIndex: %d, phaseCount: %d", phaseIndex, _phaseCount);
+ }
+}
+
+int16 Animation::getPhaseFrameIndex(int phaseIndex) const {
+ if (phaseIndex < _phaseCount) {
+ return _phaseList[phaseIndex]._phaseToFrameIndex;
+ } else {
+ error("getPhaseFrameIndex() phaseIndex: %d, phaseCount: %d", phaseIndex, _phaseCount);
+ }
+}
+
+Graphics::Surface *Animation::getFrame(int frameIndex) {
+ if (frameIndex < _frameCount) {
+ if (_frameList[frameIndex]._isCompressed) {
+ Decompressor dec;
+ byte *ddata = (byte *)malloc(_frameList[frameIndex]._dataSize);
+ dec.decompress(_frameList[frameIndex]._compressedData, ddata, _frameList[frameIndex]._dataSize);
+ int frameHeight = _frameList[frameIndex]._surface->h;
+ int frameWidth = _frameList[frameIndex]._surface->w;
+ for (uint16 i = 0; i < frameHeight; i++) {
+ memcpy(_frameList[frameIndex]._surface->getBasePtr(0, i), ddata + frameWidth * i, frameWidth);
+ }
+ free(ddata);
+ free(_frameList[frameIndex]._compressedData);
+ _frameList[frameIndex]._compressedData = nullptr;
+ _frameList[frameIndex]._dataSize = 0;
+ _frameList[frameIndex]._isCompressed = false;
+ }
+ return _frameList[frameIndex]._surface;
+ } else {
+ error("getFrame() frameIndex: %d, frameCount: %d", frameIndex, _frameCount);
+ }
+}
+
+} // End of namespace Prince
diff --git a/engines/prince/animation.h b/engines/prince/animation.h
new file mode 100644
index 0000000000..3471ffa158
--- /dev/null
+++ b/engines/prince/animation.h
@@ -0,0 +1,73 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef PRINCE_ANIMATION_H
+#define PRINCE_ANIMATION_H
+
+#include "common/array.h"
+#include "common/stream.h"
+
+#include "graphics/surface.h"
+
+namespace Prince {
+
+class Animation {
+public:
+ Animation();
+ ~Animation();
+ bool loadStream(Common::SeekableReadStream &stream);
+
+ int16 getLoopCount() const;
+ int32 getPhaseCount() const;
+ int32 getFrameCount() const;
+ int16 getBaseX() const;
+ int16 getBaseY() const;
+ int16 getPhaseOffsetX(int phaseIndex) const;
+ int16 getPhaseOffsetY(int phaseIndex) const;
+ int16 getPhaseFrameIndex(int phaseIndex) const;
+ Graphics::Surface *getFrame(int frameIndex);
+ void clear();
+
+private:
+ struct Phase {
+ int16 _phaseOffsetX;
+ int16 _phaseOffsetY;
+ uint16 _phaseToFrameIndex;
+ };
+ struct Frame {
+ bool _isCompressed;
+ uint32 _dataSize;
+ byte *_compressedData;
+ Graphics::Surface *_surface;
+ };
+ Common::Array<Frame> _frameList;
+ Common::Array<Phase> _phaseList;
+ int16 _loopCount;
+ int16 _phaseCount;
+ int32 _frameCount;
+ int16 _baseX;
+ int16 _baseY;
+};
+
+} // End of namespace Prince
+
+#endif
diff --git a/engines/prince/archive.cpp b/engines/prince/archive.cpp
new file mode 100644
index 0000000000..a01f824df8
--- /dev/null
+++ b/engines/prince/archive.cpp
@@ -0,0 +1,166 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public 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 "prince/archive.h"
+#include "prince/decompress.h"
+
+#include "common/stream.h"
+#include "common/debug.h"
+#include "common/memstream.h"
+
+namespace Prince {
+
+PtcArchive::PtcArchive() : _stream(nullptr) {
+}
+
+PtcArchive::~PtcArchive() {
+ close();
+}
+
+static void decrypt(byte *buffer, uint32 size) {
+ uint32 key = 0xDEADF00D;
+ while (size--) {
+ *buffer++ += key & 0xFF;
+ key ^= 0x2E84299A;
+ key += MKTAG('B', 'L', 'A', 'H');
+ key = ((key & 1) << 31) | (key >> 1);
+ }
+}
+
+bool PtcArchive::open(const Common::String &filename) {
+ _stream = SearchMan.createReadStreamForMember(filename);
+ if (!_stream)
+ return false;
+
+ _stream->readUint32LE(); // magic
+ uint32 fileTableOffset = _stream->readUint32LE() ^ 0x4D4F4B2D; // MOK-
+ uint32 fileTableSize = _stream->readUint32LE() ^ 0x534F4654; // SOFT
+
+ //debug("fileTableOffset : %08X", fileTableOffset);
+ //debug("fileTableSize: %08X", fileTableSize);
+
+ _stream->seek(fileTableOffset);
+
+ byte *fileTable = (byte *)malloc(fileTableSize);
+ byte *fileTableEnd = fileTable + fileTableSize;
+ _stream->read(fileTable, fileTableSize);
+ decrypt(fileTable, fileTableSize);
+
+ for (byte *fileItem = fileTable; fileItem < fileTableEnd; fileItem += 32) {
+ FileEntry item;
+ Common::String name = (const char*)fileItem;
+ item._offset = READ_LE_UINT32(fileItem + 24);
+ item._size = READ_LE_UINT32(fileItem + 28);
+ //debug("%12s %8X %d", name.c_str(), item._offset, item._size);
+ _items[name] = item;
+ }
+
+ free(fileTable);
+
+ return true;
+}
+
+bool PtcArchive::openTranslation(const Common::String &filename) {
+ _stream = SearchMan.createReadStreamForMember(filename);
+ if (!_stream)
+ return false;
+
+ Common::Array<Common::String> translationNames;
+ Common::String translationFileName;
+ const int kTranslationFiles = 5;
+ for (int i = 0; i < kTranslationFiles; i++) {
+ translationFileName = _stream->readLine();
+ translationNames.push_back(translationFileName);
+ }
+ FileEntry item;
+ for (int i = 0; i < kTranslationFiles; i++) {
+ item._offset = _stream->readUint32LE();
+ item._size = _stream->readUint32LE();
+ _items[translationNames[i]] = item;
+ }
+
+ return true;
+}
+
+void PtcArchive::close() {
+ delete _stream;
+ _stream = nullptr;
+ _items.clear();
+}
+
+bool PtcArchive::hasFile(const Common::String &name) const {
+ // TODO: check if path matching should be added
+ return _items.contains(name);
+}
+
+int PtcArchive::listMembers(Common::ArchiveMemberList &list) const {
+ int matches = 0;
+
+ for (FileMap::const_iterator it = _items.begin(); it != _items.end(); ++it) {
+ list.push_back(Common::ArchiveMemberList::value_type(new Common::GenericArchiveMember(it->_key, this)));
+ matches++;
+ }
+
+ return matches;
+}
+
+const Common::ArchiveMemberPtr PtcArchive::getMember(const Common::String &name) const {
+ if (!_items.contains(name)) {
+ Common::ArchiveMemberPtr();
+ }
+ return Common::ArchiveMemberList::value_type(new Common::GenericArchiveMember(name, this));
+}
+
+Common::SeekableReadStream *PtcArchive::createReadStreamForMember(const Common::String &name) const {
+ if (!_items.contains(name)) {
+ return 0;
+ }
+
+ const FileEntry &entryHeader = _items[name];
+
+ if (entryHeader._size < 4)
+ return 0;
+
+ uint32 size = entryHeader._size;
+
+ _stream->seek(entryHeader._offset);
+
+ // This *HAS* to be malloc (not new[]) because MemoryReadStream uses free() to free the memory
+ byte *buffer = (byte *)malloc(size);
+ _stream->read(buffer, size);
+
+ if (READ_BE_UINT32(buffer) == MKTAG('M', 'A', 'S', 'M')) {
+ Decompressor dec;
+ uint32 decompLen = READ_BE_UINT32(buffer + 14);
+ byte *decompData = (byte *)malloc(decompLen);
+ dec.decompress(buffer + 18, decompData, decompLen);
+ free(buffer);
+ size = decompLen;
+ buffer = decompData;
+ }
+
+ //debug("PtcArchive::createReadStreamForMember name %s", name.c_str());
+
+ return new Common::MemoryReadStream(buffer, size, DisposeAfterUse::YES);
+}
+
+} // End of namespace Prince
diff --git a/engines/prince/archive.h b/engines/prince/archive.h
new file mode 100644
index 0000000000..a640b77911
--- /dev/null
+++ b/engines/prince/archive.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 PRINCE_ARCHIVE_H
+#define PRINCE_ARCHIVE_H
+
+#include "common/archive.h"
+#include "common/hashmap.h"
+#include "common/hash-str.h"
+
+namespace Prince {
+
+class PtcArchive : public Common::Archive {
+public:
+ PtcArchive();
+ ~PtcArchive();
+
+ bool open(const Common::String &filename);
+ bool openTranslation(const Common::String &filename);
+ void close();
+ bool isOpen() const { return _stream != 0; }
+
+ // Common::Archive API implementation
+ bool hasFile(const Common::String &name) const;
+ int listMembers(Common::ArchiveMemberList &list) const;
+ const Common::ArchiveMemberPtr getMember(const Common::String &name) const;
+ Common::SeekableReadStream *createReadStreamForMember(const Common::String &name) const;
+
+private:
+ struct FileEntry {
+ uint32 _offset;
+ uint32 _size;
+ };
+
+ Common::SeekableReadStream *_stream;
+
+ typedef Common::HashMap<Common::String, FileEntry, Common::IgnoreCase_Hash, Common::IgnoreCase_EqualTo> FileMap;
+ FileMap _items;
+};
+
+} // End of namespace Prince
+
+#endif
diff --git a/engines/zvision/core/menu.h b/engines/prince/common.h
index 3ab6d4c2ec..c846f9a751 100644
--- a/engines/zvision/core/menu.h
+++ b/engines/prince/common.h
@@ -8,21 +8,38 @@
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
- *
+
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+
* You should have received a copy of the GNU General Public 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 ZVISION_MENU_H
-#define ZVISION_MENU_H
+#ifndef PRINCE_COMMON_H
+#define PRINCE_COMMON_H
+
+namespace Prince {
+
+enum Direction {
+ kDirLD,
+ kDirL,
+ kDirLU,
+ kDirRD,
+ kDirR,
+ kDirRU,
+ kDirUL,
+ kDirU,
+ kDirUR,
+ kDirDL,
+ kDirD,
+ kDirDR
+};
-// TODO: Implement MenuHandler
+} // End of namespace Prince
#endif
diff --git a/engines/prince/configure.engine b/engines/prince/configure.engine
new file mode 100644
index 0000000000..50740d9f41
--- /dev/null
+++ b/engines/prince/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 prince "The Prince and The Coward" no
diff --git a/engines/prince/cursor.cpp b/engines/prince/cursor.cpp
new file mode 100644
index 0000000000..ddcabbd28f
--- /dev/null
+++ b/engines/prince/cursor.cpp
@@ -0,0 +1,54 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "prince/cursor.h"
+
+#include "common/debug.h"
+
+namespace Prince {
+
+Cursor::Cursor() : _surface(nullptr) {
+}
+
+Cursor::~Cursor() {
+ if (_surface != nullptr) {
+ _surface->free();
+ delete _surface;
+ _surface = nullptr;
+ }
+}
+
+bool Cursor::loadStream(Common::SeekableReadStream &stream) {
+ stream.skip(4);
+ uint16 width = stream.readUint16LE();
+ uint16 height = stream.readUint16LE();
+
+ _surface = new Graphics::Surface();
+ _surface->create(width, height, Graphics::PixelFormat::createFormatCLUT8());
+
+ for (int h = 0; h < height; h++) {
+ stream.read(_surface->getBasePtr(0, h), width);
+ }
+ return true;
+}
+
+} // End of namespace Prince
diff --git a/engines/prince/cursor.h b/engines/prince/cursor.h
new file mode 100644
index 0000000000..fb07d01729
--- /dev/null
+++ b/engines/prince/cursor.h
@@ -0,0 +1,46 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef CURSOR_PRINCE_H
+#define CURSOR_PRINCE_H
+
+#include "graphics/surface.h"
+
+#include "common/stream.h"
+
+namespace Prince {
+
+class Cursor {
+public:
+ Cursor();
+ ~Cursor();
+
+ bool loadStream(Common::SeekableReadStream &stream);
+ const Graphics::Surface *getSurface() const { return _surface; }
+
+private:
+ Graphics::Surface *_surface;
+};
+
+} // End of namespace Prince
+
+#endif
diff --git a/engines/prince/curve_values.h b/engines/prince/curve_values.h
new file mode 100644
index 0000000000..d72f11fd36
--- /dev/null
+++ b/engines/prince/curve_values.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.
+ *
+ */
+
+namespace Prince {
+
+const int curveValues[17][4] = {
+ { 32768, 0, 0, 0 },
+ { 25200, 7200, 480, -112 },
+ { 18816, 12544, 1792, -384 },
+ { 13520, 16224, 3744, -720 },
+ { 9216, 18432, 6144, -1024 },
+ { 5808, 19360, 8800, -1200 },
+ { 3200, 19200, 11520, -1152 },
+ { 1296, 18144, 14112, -784 },
+ { 0, 16384, 16384, 0 },
+ { -784, 14112, 18144, 1296 },
+ { -1152, 11520, 19200, 3200 },
+ { -1200, 8800, 19360, 5808 },
+ { -1024, 6144, 18432, 9216 },
+ { -720, 3744, 16224, 13520 },
+ { -384, 1792, 12544, 18816 },
+ { -112, 480, 7200, 25200 },
+ { 0, 0, 0, 32768 }
+};
+
+} // End of namespace Prince
diff --git a/engines/prince/debugger.cpp b/engines/prince/debugger.cpp
new file mode 100644
index 0000000000..fc216e0cfb
--- /dev/null
+++ b/engines/prince/debugger.cpp
@@ -0,0 +1,174 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public 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 "prince/debugger.h"
+#include "prince/prince.h"
+#include "prince/flags.h"
+#include "prince/script.h"
+
+namespace Prince {
+
+Debugger::Debugger(PrinceEngine *vm, InterpreterFlags *flags) : GUI::Debugger(), _vm(vm), _locationNr(0), _flags(flags) {
+ registerCmd("continue", WRAP_METHOD(Debugger, cmdExit));
+ registerCmd("level", WRAP_METHOD(Debugger, Cmd_DebugLevel));
+ registerCmd("setflag", WRAP_METHOD(Debugger, Cmd_SetFlag));
+ registerCmd("getflag", WRAP_METHOD(Debugger, Cmd_GetFlag));
+ registerCmd("clearflag", WRAP_METHOD(Debugger, Cmd_ClearFlag));
+ registerCmd("viewflc", WRAP_METHOD(Debugger, Cmd_ViewFlc));
+ registerCmd("initroom", WRAP_METHOD(Debugger, Cmd_InitRoom));
+ registerCmd("changecursor", WRAP_METHOD(Debugger, Cmd_ChangeCursor));
+ registerCmd("additem", WRAP_METHOD(Debugger, Cmd_AddItem));
+}
+
+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_DebugLevel(int argc, const char **argv) {
+ if (argc == 1) {
+ debugPrintf("Debugging is currently set at level %d\n", gDebugLevel);
+ } else { // set level
+ gDebugLevel = atoi(argv[1]);
+ if (0 <= gDebugLevel && gDebugLevel < 11) {
+ debugPrintf("Debug level set to level %d\n", gDebugLevel);
+ } else if (gDebugLevel < 0) {
+ debugPrintf("Debugging is now disabled\n");
+ } else
+ debugPrintf("Not a valid debug level (0 - 10)\n");
+ }
+
+ return true;
+}
+
+/*
+ * This command sets a flag
+ */
+bool Debugger::Cmd_SetFlag(int argc, const char **argv) {
+ // Check for a flag to set
+ if (argc != 3) {
+ debugPrintf("Usage: %s <flag number> <value>\n", argv[0]);
+ return true;
+ }
+
+ int flagNum = strToInt(argv[1]);
+ uint16 value = strToInt(argv[2]);
+ _flags->setFlagValue((Flags::Id)flagNum, value);
+ return true;
+}
+
+/*
+ * This command gets the value of a flag
+ */
+bool Debugger::Cmd_GetFlag(int argc, const char **argv) {
+ // Check for an flag to display
+ if (argc != 2) {
+ debugPrintf("Usage: %s <flag number>\n", argv[0]);
+ return true;
+ }
+
+ int flagNum = strToInt(argv[1]);
+ debugPrintf("Value: %d\n", _flags->getFlagValue((Flags::Id)flagNum));
+ return true;
+}
+
+/*
+ * This command clears a flag
+ */
+bool Debugger::Cmd_ClearFlag(int argc, const char **argv) {
+ // Check for a flag to clear
+ if (argc != 2) {
+ debugPrintf("Usage: %s <flag number>\n", argv[0]);
+ return true;
+ }
+
+ int flagNum = strToInt(argv[1]);
+ _flags->setFlagValue((Flags::Id)flagNum, 0);
+ return true;
+}
+
+/*
+ * This command starts new flc anim
+ */
+bool Debugger::Cmd_ViewFlc(int argc, const char **argv) {
+ // Check for a flag to clear
+ if (argc != 2) {
+ debugPrintf("Usage: %s <anim number>\n", argv[0]);
+ return true;
+ }
+
+ int flagNum = strToInt(argv[1]);
+ _vm->loadAnim(flagNum, false);
+ return true;
+}
+
+bool Debugger::Cmd_InitRoom(int argc, const char **argv) {
+ // Check for a flag to clear
+ if (argc != 2) {
+ debugPrintf("Usage: %s <anim number>\n", argv[0]);
+ return true;
+ }
+
+ _locationNr = strToInt(argv[1]);
+ return true;
+}
+
+bool Debugger::Cmd_ChangeCursor(int argc, const char **argv) {
+ // Check for a flag to clear
+ if (argc != 2) {
+ debugPrintf("Usage: %s <curId>\n", argv[0]);
+ return true;
+ }
+
+ _cursorNr = strToInt(argv[1]);
+
+ return true;
+}
+
+bool Debugger::Cmd_AddItem(int argc, const char **argv) {
+ if (argc != 2) {
+ debugPrintf("Usage: %s <itemId>\n", argv[0]);
+ return true;
+ }
+ if (!strcmp(argv[1], "map")) {
+ _vm->addInv(0, 29, true);
+ _vm->_flags->setFlagValue(Flags::MapaUsable, 1);
+ } else {
+ int itemId = strToInt(argv[1]);
+ _vm->addInv(0, itemId, true);
+ }
+
+ return true;
+}
+
+} // End of namespace Prince
diff --git a/engines/prince/debugger.h b/engines/prince/debugger.h
new file mode 100644
index 0000000000..a4467e63d5
--- /dev/null
+++ b/engines/prince/debugger.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 PRINCE_DEBUGGER_H
+#define PRINCE_DEBUGGER_H
+
+#include "common/scummsys.h"
+#include "gui/debugger.h"
+
+namespace Prince {
+
+class PrinceEngine;
+class InterpreterFlags;
+
+class Debugger : public GUI::Debugger {
+public:
+ Debugger(PrinceEngine *vm, InterpreterFlags *flags);
+ virtual ~Debugger() {} // we need this for __SYMBIAN32__ archaic gcc/UIQ
+
+ uint8 _locationNr;
+ uint8 _cursorNr;
+
+private:
+ bool Cmd_DebugLevel(int argc, const char **argv);
+ bool Cmd_SetFlag(int argc, const char **argv);
+ bool Cmd_GetFlag(int argc, const char **argv);
+ bool Cmd_ClearFlag(int argc, const char **argv);
+ bool Cmd_ViewFlc(int argc, const char **argv);
+ bool Cmd_InitRoom(int argc, const char **argv);
+ bool Cmd_ChangeCursor(int argc, const char **argv);
+ bool Cmd_AddItem(int argc, const char **argv);
+
+ PrinceEngine *_vm;
+ InterpreterFlags *_flags;
+};
+
+} // End of namespace Prince
+
+#endif
diff --git a/engines/prince/decompress.cpp b/engines/prince/decompress.cpp
new file mode 100644
index 0000000000..7fba179541
--- /dev/null
+++ b/engines/prince/decompress.cpp
@@ -0,0 +1,171 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+// John_Doe's implementation
+
+#include "prince/decompress.h"
+
+namespace Prince {
+
+static const uint16 table1[] = {
+ 0x8000, 0x0002,
+ 0x4000, 0x0004,
+ 0x2000, 0x0008,
+ 0x1000, 0x0010,
+ 0x0800, 0x0020,
+ 0x0400, 0x0040,
+ 0x0200, 0x0080,
+ 0x0100, 0x0100,
+ 0x0080, 0x0200,
+ 0x0040, 0x0400
+};
+
+static const uint32 table2[] = {
+ 0x0000F000,
+ 0x0020FC00,
+ 0x00A0FF00,
+ 0x02A0FF80,
+ 0x06A0FFC0,
+ 0x0EA0FFE0,
+ 0x1EA0FFF0,
+ 0x3EA0FFF8
+};
+
+static const uint16 table3[] = {
+ 0x8000, 0x0000,
+ 0x4000, 0x0002,
+ 0x2000, 0x0006,
+ 0x1000, 0x000E,
+ 0x0800, 0x001E,
+ 0x0400, 0x003E,
+ 0x0200, 0x007E,
+ 0x0100, 0x00FE,
+ 0x0080, 0x01FE,
+ 0x0040, 0x03FE,
+ 0x0020, 0x07FE,
+ 0x0010, 0x0FFE,
+ 0x0008, 0x1FFE,
+ 0x0004, 0x3FFE,
+ 0x0002, 0x7FFE,
+ 0x0001, 0xFFFE
+};
+
+void Decompressor::decompress(byte *source, byte *dest, uint32 destSize) {
+ byte *destEnd = dest + destSize;
+ int more;
+ _src = source;
+ _dst = dest;
+ _bitBuffer = 0x80;
+ while (_dst < destEnd) {
+ uint32 ebp;
+ uint16 offset, length;
+ if (getBit()) {
+ if (getBit()) {
+ if (getBit()) {
+ if (getBit()) {
+ if (getBit()) {
+ if (getBit()) {
+ uint32 tableIndex = 0;
+ while (getBit())
+ tableIndex++;
+ length = table3[tableIndex * 2 + 0];
+ do {
+ more = !(length & 0x8000);
+ length = (length << 1) | getBit();
+ } while (more);
+ length += table3[tableIndex * 2 + 1];
+ length++;
+ memcpy(_dst, _src, length);
+ _src += length;
+ _dst += length;
+ }
+ *_dst++ = *_src++;
+ }
+ *_dst++ = *_src++;
+ }
+ *_dst++ = *_src++;
+ }
+ *_dst++ = *_src++;
+ }
+ *_dst++ = *_src++;
+ }
+ if (!getBit()) {
+ if (getBit()) {
+ uint32 tableIndex = getBit();
+ tableIndex = (tableIndex << 1) | getBit();
+ tableIndex = (tableIndex << 1) | getBit();
+ ebp = table2[tableIndex];
+ length = 1;
+ } else {
+ ebp = 0x0000FF00;
+ length = 0;
+ }
+ } else {
+ uint32 tableIndex = 0;
+ while (getBit())
+ tableIndex++;
+ length = table1[tableIndex * 2 + 0];
+ do {
+ more = !(length & 0x8000);
+ length = (length << 1) | getBit();
+ } while (more);
+ length += table1[tableIndex * 2 + 1];
+ tableIndex = getBit();
+ tableIndex = (tableIndex << 1) | getBit();
+ tableIndex = (tableIndex << 1) | getBit();
+ ebp = table2[tableIndex];
+ }
+ offset = ebp & 0xFFFF;
+ do {
+ if (_bitBuffer == 0x80) {
+ if (offset >= 0xFF00) {
+ offset = (offset << 8) | *_src++;
+ }
+ }
+ more = offset & 0x8000;
+ offset = (offset << 1) | getBit();
+ } while (more);
+ offset += (ebp >> 16);
+ length += 2;
+ while (length--) {
+ if (_dst >= destEnd) {
+ return;
+ }
+ *_dst = *(_dst - offset);
+ _dst++;
+ }
+ }
+}
+
+int Decompressor::getBit() {
+ int bit = (_bitBuffer & 0x80) >> 7;
+ _bitBuffer <<= 1;
+ if (_bitBuffer == 0) {
+ _bitBuffer = *_src++;
+ bit = (_bitBuffer & 0x80) >> 7;
+ _bitBuffer <<= 1;
+ _bitBuffer |= 1;
+ }
+ return bit;
+}
+
+} // End of namespace Prince
diff --git a/engines/prince/decompress.h b/engines/prince/decompress.h
new file mode 100644
index 0000000000..ef495db65e
--- /dev/null
+++ b/engines/prince/decompress.h
@@ -0,0 +1,44 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+// John_Doe's implementation
+
+#ifndef PRINCE_DECOMPRESS_H
+#define PRINCE_DECOMPRESS_H
+
+#include "engines/util.h"
+
+namespace Prince {
+
+class Decompressor {
+public:
+ void decompress(byte *source, byte *dest, uint32 destSize);
+protected:
+ byte *_src, *_dst;
+ byte _bitBuffer;
+ int _bitsLeft;
+ int getBit();
+};
+
+} // End of namespace Prince
+
+#endif
diff --git a/engines/prince/detection.cpp b/engines/prince/detection.cpp
new file mode 100644
index 0000000000..3fe7993fdb
--- /dev/null
+++ b/engines/prince/detection.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; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public 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 "prince/detection.h"
+
+namespace Prince {
+
+int PrinceEngine::getGameType() const {
+ return _gameDescription->gameType;
+}
+
+const char *PrinceEngine::getGameId() const {
+ return _gameDescription->desc.gameid;
+}
+
+uint32 PrinceEngine::getFeatures() const {
+ return _gameDescription->desc.flags;
+}
+
+Common::Language PrinceEngine::getLanguage() const {
+ return _gameDescription->desc.language;
+}
+
+bool PrinceMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const {
+ using namespace Prince;
+ const PrinceGameDescription *gd = (const PrinceGameDescription *)desc;
+ if (gd) {
+ *engine = new PrinceEngine(syst, gd);
+ }
+ return gd != 0;
+}
+
+bool PrinceMetaEngine::hasFeature(MetaEngineFeature f) const {
+ return
+ (f == kSupportsDeleteSave) ||
+ (f == kSavesSupportMetaInfo) ||
+ (f == kSavesSupportThumbnail) ||
+ (f == kSavesSupportCreationDate) ||
+ (f == kSupportsListSaves) ||
+ (f == kSupportsLoadingDuringStartup);
+}
+
+bool Prince::PrinceEngine::hasFeature(EngineFeature f) const {
+ return
+ (f == kSupportsLoadingDuringRuntime) ||
+ (f == kSupportsSavingDuringRuntime) ||
+ (f == kSupportsRTL);
+}
+
+} // End of namespace Prince
+
+#if PLUGIN_ENABLED_DYNAMIC(PRINCE)
+REGISTER_PLUGIN_DYNAMIC(PRINCE, PLUGIN_TYPE_ENGINE, Prince::PrinceMetaEngine);
+#else
+REGISTER_PLUGIN_STATIC(PRINCE, PLUGIN_TYPE_ENGINE, Prince::PrinceMetaEngine);
+#endif
diff --git a/engines/prince/detection.h b/engines/prince/detection.h
new file mode 100644
index 0000000000..7e5bdd6b7b
--- /dev/null
+++ b/engines/prince/detection.h
@@ -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.
+ *
+ */
+
+#ifndef PRINCE_DETECTION_H
+#define PRINCE_DETECTION_H
+
+#include "prince/prince.h"
+#include "engines/advancedDetector.h"
+
+namespace Prince {
+
+enum PrinceGameType {
+ kPrinceDataUNK,
+ kPrinceDataDE,
+ kPrinceDataPL
+};
+
+struct PrinceGameDescription {
+ ADGameDescription desc;
+ PrinceGameType gameType;
+};
+
+static const PlainGameDescriptor princeGames[] = {
+ {"prince", "Prince Game"},
+ {0, 0}
+};
+
+static const PrinceGameDescription gameDescriptions[] = {
+ {
+ {
+ "prince",
+ "Galador",
+ AD_ENTRY1s("databank.ptc", "5fa03833177331214ec1354761b1d2ee", 3565031),
+ Common::DE_DEU,
+ Common::kPlatformWindows,
+ ADGF_TESTING,
+ GUIO1(GUIO_NONE)
+ },
+ kPrinceDataDE
+ },
+ {
+ {
+ "prince",
+ "Ksiaze i Tchorz",
+ AD_ENTRY1s("databank.ptc", "48ec9806bda9d152acbea8ce31c93c49", 3435298),
+ Common::PL_POL,
+ Common::kPlatformWindows,
+ ADGF_TESTING,
+ GUIO1(GUIO_NONE)
+ },
+ kPrinceDataPL
+ },
+ {
+ {
+ "prince",
+ "The Prince and the Coward",
+ AD_ENTRY1s("databank.ptc", "5fa03833177331214ec1354761b1d2ee", 3565031),
+ Common::EN_ANY,
+ Common::kPlatformWindows,
+ ADGF_TESTING,
+ GUIO1(GUIO_NONE)
+ },
+ kPrinceDataDE
+ },
+ {
+ {
+ "prince",
+ "The Prince and the Coward",
+ AD_ENTRY1s("databank.ptc", "48ec9806bda9d152acbea8ce31c93c49", 3435298),
+ Common::EN_ANY,
+ Common::kPlatformWindows,
+ ADGF_TESTING,
+ GUIO1(GUIO_NONE)
+ },
+ kPrinceDataPL
+ },
+ { AD_TABLE_END_MARKER, kPrinceDataUNK }
+};
+
+const static char *directoryGlobs[] = {
+ "all",
+ 0
+};
+
+class PrinceMetaEngine : public AdvancedMetaEngine {
+public:
+ PrinceMetaEngine() : AdvancedMetaEngine(Prince::gameDescriptions, sizeof(Prince::PrinceGameDescription), princeGames) {
+ _singleid = "prince";
+ _maxScanDepth = 2;
+ _directoryGlobs = directoryGlobs;
+ }
+
+ virtual const char *getName() const {
+ return "Prince Engine";
+ }
+
+ virtual const char *getOriginalCopyright() const {
+ return "The Prince and the Coward (C) 1996-97 Metropolis";
+ }
+
+ virtual bool createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const;
+ virtual bool hasFeature(MetaEngineFeature f) const;
+ virtual int getMaximumSaveSlot() const;
+ virtual SaveStateList listSaves(const char *target) const;
+ SaveStateDescriptor querySaveMetaInfos(const char *target, int slot) const;
+ virtual void removeSaveState(const char *target, int slot) const;
+};
+
+} // End of namespace Prince
+
+#endif
diff --git a/engines/prince/flags.cpp b/engines/prince/flags.cpp
new file mode 100644
index 0000000000..f1a05bd4df
--- /dev/null
+++ b/engines/prince/flags.cpp
@@ -0,0 +1,420 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public 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 "prince/flags.h"
+#include "prince/script.h"
+
+namespace Prince {
+
+const char *Flags::getFlagName(uint16 flagId) {
+ FlagDebug *flagd = nullptr;
+ flagd = (FlagDebug *)bsearch(&flagId, _flagNames, kFlagDebugAmount, sizeof(FlagDebug), Flags::compareFlagDebug);
+ if (flagd != nullptr) {
+ return flagd->flagName;
+ } else {
+ return "unknown_flag";
+ }
+}
+
+int Flags::compareFlagDebug(const void *a, const void *b) {
+ const uint32 *flagId = (const uint32 *)a;
+ const FlagDebug *entry = (const FlagDebug *)b;
+ if (*flagId < (uint32)entry->id) {
+ return -1;
+ } else if (*flagId > (uint32)entry->id) {
+ return 1;
+ }
+ return 0;
+}
+
+const Flags::FlagDebug Flags::_flagNames[Flags::kFlagDebugAmount] = {
+ { Flags::FLAGA1, "FLAGA1" },
+ { Flags::FLAGA2, "FLAGA2" },
+ { Flags::FLAGA3, "FLAGA3" },
+ { Flags::DESTX, "DESTX" },
+ { Flags::DESTY, "DESTY" },
+ { Flags::DESTD, "DESTD" },
+ { Flags::DwarfDone, "DwarfDone" },
+ { Flags::GRABARZCOUNTER, "GRABARZCOUNTER" },
+ { Flags::KIERUNEK, "KIERUNEK" },
+ { Flags::BACKFLAG1, "BACKFLAG1" },
+ { Flags::BACKFLAG2, "BACKFLAG2" },
+ { Flags::BACKFLAG3, "BACKFLAG3" },
+ { Flags::BACKFLAG4, "BACKFLAG4" },
+ { Flags::MACROFLAG1, "MACROFLAG1" },
+ { Flags::MACROFLAG2, "MACROFLAG2" },
+ { Flags::MACROFLAG3, "MACROFLAG3" },
+ { Flags::HEROLDDONE, "HEROLDDONE" },
+ { Flags::BRIDGESET, "BRIDGESET" },
+ { Flags::U_BT_1, "U_BT_1" },
+ { Flags::U_BT_2, "U_BT_2" },
+ { Flags::U_BT_3, "U_BT_3" },
+ { Flags::U_BT_4, "U_BT_4" },
+ { Flags::U_BT_5, "U_BT_5" },
+ { Flags::U_BT_6, "U_BT_6" },
+ { Flags::U_BT_7, "U_BT_7" },
+ { Flags::U_BT_8, "U_BT_8" },
+ { Flags::U_BT_9, "U_BT_9" },
+ { Flags::U_BT_COUNTER, "U_BT_COUNTER" },
+ { Flags::ARIVALDALIVE, "ARIVALDALIVE" },
+ { Flags::TALKCHAR1, "TALKCHAR1" },
+ { Flags::TalkType1, "TalkType1" },
+ { Flags::TALKROUT1, "TALKROUT1" },
+ { Flags::TALKROUT2, "TALKROUT2" },
+ { Flags::TALKROUT3, "TALKROUT3" },
+ { Flags::TALKROUT4, "TALKROUT4" },
+ { Flags::TALKANIM1, "TALKANIM1" },
+ { Flags::TALKANIM2, "TALKANIM2" },
+ { Flags::TALKCOLOR1, "TALKCOLOR1" },
+ { Flags::TALKCOLOR2, "TALKCOLOR2" },
+ { Flags::KapciuchTaken, "KapciuchTaken" },
+ { Flags::CurrentBeggarA, "CurrentBeggarA" },
+ { Flags::TempKapc, "TempKapc" },
+ { Flags::HomTaken, "HomTaken" },
+ { Flags::WizardTalk, "WizardTalk" },
+ { Flags::SunlordTalk, "SunlordTalk" },
+ { Flags::HermitTalk, "HermitTalk" },
+ { Flags::RunyMode, "RunyMode" },
+ { Flags::FatMerchantTalk, "FatMerchantTalk" },
+ { Flags::HotDogTalk, "HotDogTalk" },
+ { Flags::ThiefTalk, "ThiefTalk" },
+ { Flags::BeggarTalk, "BeggarTalk" },
+ { Flags::MonkTalk, "MonkTalk" },
+ { Flags::BardTalk, "BardTalk" },
+ { Flags::BarmanTalk, "BarmanTalk" },
+ { Flags::LeftPlayerTalk, "LeftPlayerTalk" },
+ { Flags::OczySowy, "OczySowy" },
+ { Flags::CzachySpeed1, "CzachySpeed1" },
+ { Flags::CzachySpeed2, "CzachySpeed2" },
+ { Flags::CzachySpeed3, "CzachySpeed3" },
+ { Flags::CzachySlowDown1, "CzachySlowDown1" },
+ { Flags::CzachySlowDown2, "CzachySlowDown2" },
+ { Flags::CzachySlowDown3, "CzachySlowDown3" },
+ { Flags::FjordDane, "FjordDane" },
+ { Flags::GKopany1, "GKopany1" },
+ { Flags::GKopany2, "GKopany2" },
+ { Flags::GKopany3, "GKopany3" },
+ { Flags::GKopany4, "GKopany4" },
+ { Flags::KnowGodWord, "KnowGodWord" },
+ { Flags::TALKROUT21, "TALKROUT21" },
+ { Flags::TALKROUT22, "TALKROUT22" },
+ { Flags::TALKROUT23, "TALKROUT23" },
+ { Flags::TALKROUT24, "TALKROUT24" },
+ { Flags::TalkType2, "TalkType2" },
+ { Flags::GrabarzTalk, "GrabarzTalk" },
+ { Flags::LastTalker, "LastTalker" },
+ { Flags::MapaPustelniaEnabled, "MapaPustelniaEnabled" },
+ { Flags::MapaTempleEnabled, "MapaTempleEnabled" },
+ { Flags::MapaFjordEnabled, "MapaFjordEnabled" },
+ { Flags::MapaSilmanionaEnabled, "MapaSilmanionaEnabled" },
+ { Flags::MapaKurhanEnabled, "MapaKurhanEnabled" },
+ { Flags::MapaDragonEnabled, "MapaDragonEnabled" },
+ { Flags::MapaMillEnabled, "MapaMillEnabled" },
+ { Flags::DwarfRunning, "DwarfRunning" },
+ { Flags::DwarfTalk, "DwarfTalk" },
+ { Flags::CurseLift, "CurseLift" },
+ { Flags::KosciSwapped, "KosciSwapped" },
+ { Flags::BookStolen, "BookStolen" },
+ { Flags::MapaUsable, "MapaUsable" },
+ { Flags::FjordBoss, "FjordBoss" },
+ { Flags::FjordHotDog, "FjordHotDog" },
+ { Flags::FjordLewy, "FjordLewy" },
+ { Flags::FjordPrawy, "FjordPrawy" },
+ { Flags::TalkArivald, "TalkArivald" },
+ { Flags::ShootDone, "ShootDone" },
+ { Flags::ShootRunning, "ShootRunning" },
+ { Flags::ShootKnow, "ShootKnow" },
+ { Flags::MirrorKnow, "MirrorKnow" },
+ { Flags::Gar1stTime, "Gar1stTime" },
+ { Flags::KosciTaken, "KosciTaken" },
+ { Flags::ArivGotSpell, "ArivGotSpell" },
+ { Flags::BookGiven, "BookGiven" },
+ { Flags::Wywieszka, "Wywieszka" },
+ { Flags::TalkSheila, "TalkSheila" },
+ { Flags::TalkSheila2, "TalkSheila2" },
+ { Flags::BackHuman, "BackHuman" },
+ { Flags::SkarbiecOpen, "SkarbiecOpen" },
+ { Flags::LustroTaken, "LustroTaken" },
+ { Flags::GargoyleHom, "GargoyleHom" },
+ { Flags::GargoyleBroken, "GargoyleBroken" },
+ { Flags::FjordDzien, "FjordDzien" },
+ { Flags::GargoyleHom2, "GargoyleHom2" },
+ { Flags::RunMonstersRunning, "RunMonstersRunning" },
+ { Flags::FoundPaperInCoffin, "FoundPaperInCoffin" },
+ { Flags::KnowSunlord, "KnowSunlord" },
+ { Flags::KnowSunlordTalk, "KnowSunlordTalk" },
+ { Flags::ArivaldCzyta, "ArivaldCzyta" },
+ { Flags::TelepX, "TelepX" },
+ { Flags::TelepY, "TelepY" },
+ { Flags::TelepDir, "TelepDir" },
+ { Flags::TelepRoom, "TelepRoom" },
+ { Flags::ListStolen, "ListStolen" },
+ { Flags::WifeInDoor, "WifeInDoor" },
+ { Flags::TalkWifeFlag, "TalkWifeFlag" },
+ { Flags::LetterGiven, "LetterGiven" },
+ { Flags::LutniaTaken, "LutniaTaken" },
+ { Flags::BardHomeOpen, "BardHomeOpen" },
+ { Flags::FjordNoMonsters, "FjordNoMonsters" },
+ { Flags::ShandriaWallTalking, "ShandriaWallTalking" },
+ { Flags::ShandriaWallCounter, "ShandriaWallCounter" },
+ { Flags::ShandriaWallDone, "ShandriaWallDone" },
+ { Flags::FutureDone, "FutureDone" },
+ { Flags::TalkButch, "TalkButch" },
+ { Flags::GotSzalik, "GotSzalik" },
+ { Flags::GotCzosnek, "GotCzosnek" },
+ { Flags::BearDone, "BearDone" },
+ { Flags::NekrVisited, "NekrVisited" },
+ { Flags::SunRiddle, "SunRiddle" },
+ { Flags::PtaszekAway, "PtaszekAway" },
+ { Flags::KotGadanie, "KotGadanie" },
+ { Flags::SzlafmycaTaken, "SzlafmycaTaken" },
+ { Flags::BabkaTalk, "BabkaTalk" },
+ { Flags::SellerTalk, "SellerTalk" },
+ { Flags::CzosnekDone, "CzosnekDone" },
+ { Flags::PriestCounter, "PriestCounter" },
+ { Flags::PriestGest1, "PriestGest1" },
+ { Flags::PriestGest2, "PriestGest2" },
+ { Flags::PriestGest3, "PriestGest3" },
+ { Flags::PriestGest4, "PriestGest4" },
+ { Flags::PriestAnim, "PriestAnim" },
+ { Flags::HolyWaterTaken, "HolyWaterTaken" },
+ { Flags::AxeTaken, "AxeTaken" },
+ { Flags::BadylTaken1, "BadylTaken1" },
+ { Flags::BadylTaken2, "BadylTaken2" },
+ { Flags::BadylSharpened, "BadylSharpened" },
+ { Flags::PorwanieSmoka, "PorwanieSmoka" },
+ { Flags::ShopReOpen, "ShopReOpen" },
+ { Flags::LuskaShown, "LuskaShown" },
+ { Flags::CudKnow, "CudKnow" },
+ { Flags::VampireDead, "VampireDead" },
+ { Flags::MapaVisible1, "MapaVisible1" },
+ { Flags::MapaVisible2, "MapaVisible2" },
+ { Flags::MapaVisible3, "MapaVisible3" },
+ { Flags::MapaVisible4, "MapaVisible4" },
+ { Flags::MapaVisible5, "MapaVisible5" },
+ { Flags::MapaVisible6, "MapaVisible6" },
+ { Flags::MapaVisible7, "MapaVisible7" },
+ { Flags::MapaVisible8, "MapaVisible8" },
+ { Flags::MapaVisible9, "MapaVisible9" },
+ { Flags::MapaX, "MapaX" },
+ { Flags::MapaY, "MapaY" },
+ { Flags::MapaD, "MapaD" },
+ { Flags::OldMapaX, "OldMapaX" },
+ { Flags::OldMapaY, "OldMapaY" },
+ { Flags::OldMapaD, "OldMapaD" },
+ { Flags::MovingBack, "MovingBack" },
+ { Flags::MapaCount, "MapaCount" },
+ { Flags::Pustelnia1st, "Pustelnia1st" },
+ { Flags::CzarnePole1st, "CzarnePole1st" },
+ { Flags::TalkArivNum, "TalkArivNum" },
+ { Flags::Pfui, "Pfui" },
+ { Flags::MapaSunlordEnabled, "MapaSunlordEnabled" },
+ { Flags::WebDone, "WebDone" },
+ { Flags::DragonDone, "DragonDone" },
+ { Flags::KanPlay, "KanPlay" },
+ { Flags::OldKanPlay, "OldKanPlay" },
+ { Flags::LapkiWait, "LapkiWait" },
+ { Flags::WebNoCheck, "WebNoCheck" },
+ { Flags::Perfumeria, "Perfumeria" },
+ { Flags::SmokNoCheck, "SmokNoCheck" },
+ { Flags::IluzjaBroken, "IluzjaBroken" },
+ { Flags::IluzjaWorking, "IluzjaWorking" },
+ { Flags::IluzjaCounter, "IluzjaCounter" },
+ { Flags::KurhanOpen1, "KurhanOpen1" },
+ { Flags::KastetTaken, "KastetTaken" },
+ { Flags::KastetDown, "KastetDown" },
+ { Flags::KurhanDone, "KurhanDone" },
+ { Flags::SkelCounter, "SkelCounter" },
+ { Flags::SkelDial1, "SkelDial1" },
+ { Flags::SkelDial2, "SkelDial2" },
+ { Flags::SkelDial3, "SkelDial3" },
+ { Flags::SkelDial4, "SkelDial4" },
+ { Flags::SameTalker, "SameTalker" },
+ { Flags::RunMonstersText, "RunMonstersText" },
+ { Flags::PiwnicaChecked, "PiwnicaChecked" },
+ { Flags::DragonTalked, "DragonTalked" },
+ { Flags::ToldAboutBook, "ToldAboutBook" },
+ { Flags::SilmanionaDone, "SilmanionaDone" },
+ { Flags::ToldBookCount, "ToldBookCount" },
+ { Flags::SmrodNoCheck, "SmrodNoCheck" },
+ { Flags::RopeTaken, "RopeTaken" },
+ { Flags::RopeTime, "RopeTime" },
+ { Flags::LaskaFree, "LaskaFree" },
+ { Flags::ShanSmokTalked, "ShanSmokTalked" },
+ { Flags::SwordTaken, "SwordTaken" },
+ { Flags::Mill1st, "Mill1st" },
+ { Flags::SawRat, "SawRat" },
+ { Flags::KnowRat, "KnowRat" },
+ { Flags::DziuraTimer, "DziuraTimer" },
+ { Flags::LaskaInside, "LaskaInside" },
+ { Flags::HoleBig, "HoleBig" },
+ { Flags::EnableWiedzmin, "EnableWiedzmin" },
+ { Flags::EnableTrucizna, "EnableTrucizna" },
+ { Flags::KnowPoison, "KnowPoison" },
+ { Flags::KufelTaken, "KufelTaken" },
+ { Flags::BojkaEnabled, "BojkaEnabled" },
+ { Flags::BitwaNot1st, "BitwaNot1st" },
+ { Flags::BojkaTimer, "BojkaTimer" },
+ { Flags::BojkaGirl, "BojkaGirl" },
+ { Flags::Look1st, "Look1st" },
+ { Flags::RatTaken, "RatTaken" },
+ { Flags::LaskaTalkedGr, "LaskaTalkedGr" },
+ { Flags::RatusGivus, "RatusGivus" },
+ { Flags::MamObole, "MamObole" },
+ { Flags::Speed1st, "Speed1st" },
+ { Flags::SpeedTimer, "SpeedTimer" },
+ { Flags::ProveIt, "ProveIt" },
+ { Flags::Proven, "Proven" },
+ { Flags::ShowWoalka, "ShowWoalka" },
+ { Flags::PoisonTaken, "PoisonTaken" },
+ { Flags::HellOpened, "HellOpened" },
+ { Flags::HellNoCheck, "HellNoCheck" },
+ { Flags::TalAn1, "TalAn1" },
+ { Flags::TalAn2, "TalAn2" },
+ { Flags::TalAn3, "TalAn3" },
+ { Flags::TalkDevilGuard, "TalkDevilGuard" },
+ { Flags::Sword1st, "Sword1st" },
+ { Flags::IluzjaNoCheck, "IluzjaNoCheck" },
+ { Flags::RozdzielniaNumber, "RozdzielniaNumber" },
+ { Flags::JailChecked, "JailChecked" },
+ { Flags::JailTalked, "JailTalked" },
+ { Flags::TrickFailed, "TrickFailed" },
+ { Flags::WegielVisible, "WegielVisible" },
+ { Flags::WegielTimer1, "WegielTimer1" },
+ { Flags::RandomSample, "RandomSample" },
+ { Flags::RandomSampleTimer, "RandomSampleTimer" },
+ { Flags::SampleTimer, "SampleTimer" },
+ { Flags::ZonaSample, "ZonaSample" },
+ { Flags::HoleTryAgain, "HoleTryAgain" },
+ { Flags::TeleportTimer, "TeleportTimer" },
+ { Flags::RozLezy, "RozLezy" },
+ { Flags::UdkoTimer, "UdkoTimer" },
+ { Flags::ZaworZatkany, "ZaworZatkany" },
+ { Flags::ZaworOpened, "ZaworOpened" },
+ { Flags::DoorExploded, "DoorExploded" },
+ { Flags::SkoraTaken, "SkoraTaken" },
+ { Flags::CiezkieByl, "CiezkieByl" },
+ { Flags::MamWegiel, "MamWegiel" },
+ { Flags::SwiecaAway, "SwiecaAway" },
+ { Flags::ITSAVE, "ITSAVE" },
+ { Flags::RozpadlSie, "RozpadlSie" },
+ { Flags::WegielFullTimer, "WegielFullTimer" },
+ { Flags::WegielDown, "WegielDown" },
+ { Flags::WegielDownTimer, "WegielDownTimer" },
+ { Flags::PaliSie, "PaliSie" },
+ { Flags::DiabGuardTalked, "DiabGuardTalked" },
+ { Flags::GuardsNoCheck, "GuardsNoCheck" },
+ { Flags::TalkedPowloka, "TalkedPowloka" },
+ { Flags::JailOpen, "JailOpen" },
+ { Flags::PrzytulTimer, "PrzytulTimer" },
+ { Flags::JailDone, "JailDone" },
+ { Flags::MamMonety, "MamMonety" },
+ { Flags::LotTimer, "LotTimer" },
+ { Flags::LotObj, "LotObj" },
+ { Flags::PtakTimer, "PtakTimer" },
+ { Flags::BookTimer, "BookTimer" },
+ { Flags::BookGiba, "BookGiba" },
+ { Flags::PtakLata, "PtakLata" },
+ { Flags::Podej, "Podej" },
+ { Flags::GotHint, "GotHint" },
+ { Flags::LawaLeci, "LawaLeci" },
+ { Flags::PowerKlik, "PowerKlik" },
+ { Flags::LucekBad, "LucekBad" },
+ { Flags::LucekBad1st, "LucekBad1st" },
+ { Flags::IntroDial1, "IntroDial1" },
+ { Flags::IntroDial2, "IntroDial2" },
+ { Flags::ItsOutro, "ItsOutro" },
+ { Flags::KamienComment, "KamienComment" },
+ { Flags::KamienSkip, "KamienSkip" },
+ { Flags::TesterFlag, "TesterFlag" },
+ { Flags::RememberLine, "RememberLine" },
+ { Flags::OpisLapek, "OpisLapek" },
+ { Flags::TalWait, "TalWait" },
+ { Flags::OpisKamienia, "OpisKamienia" },
+ { Flags::JumpBox, "JumpBox" },
+ { Flags::JumpBox1, "JumpBox1" },
+ { Flags::JumpBox2, "JumpBox2" },
+ { Flags::JumpBox3, "JumpBox3" },
+ { Flags::SpecPiesek, "SpecPiesek" },
+ { Flags::SpecPiesekCount, "SpecPiesekCount" },
+ { Flags::SpecPiesekGadanie, "SpecPiesekGadanie" },
+ { Flags::ZnikaFlag, "ZnikaFlag" },
+ { Flags::ZnikaTimer, "ZnikaTimer" },
+ { Flags::SowaTimer, "SowaTimer" },
+ { Flags::MamrotanieOff, "MamrotanieOff" },
+ { Flags::CURRMOB, "CURRMOB" },
+ { Flags::KOLOR, "KOLOR" },
+ { Flags::MBFLAG, "MBFLAG" },
+ { Flags::MXFLAG, "MXFLAG" },
+ { Flags::MYFLAG, "MYFLAG" },
+ { Flags::SCROLLTYPE, "SCROLLTYPE" },
+ { Flags::SCROLLVALUE, "SCROLLVALUE" },
+ { Flags::SCROLLVALUE2, "SCROLLVALUE2" },
+ { Flags::TALKEXITCODE, "TALKEXITCODE" },
+ { Flags::SPECROUTFLAG1, "SPECROUTFLAG1" },
+ { Flags::SPECROUTFLAG2, "SPECROUTFLAG2" },
+ { Flags::SPECROUTFLAG3, "SPECROUTFLAG3" },
+ { Flags::TALKFLAGCODE, "TALKFLAGCODE" },
+ { Flags::CURRROOM, "CURRROOM" },
+ { Flags::Talker1Init, "Talker1Init" },
+ { Flags::Talker2Init, "Talker2Init" },
+ { Flags::RESTOREROOM, "RESTOREROOM" },
+ { Flags::INVALLOWED, "INVALLOWED" },
+ { Flags::BOXSEL, "BOXSEL" },
+ { Flags::CURSEBLINK, "CURSEBLINK" },
+ { Flags::EXACTMOVE, "EXACTMOVE" },
+ { Flags::MOVEDESTX, "MOVEDESTX" },
+ { Flags::MOVEDESTY, "MOVEDESTY" },
+ { Flags::NOANTIALIAS, "NOANTIALIAS" },
+ { Flags::ESCAPED, "ESCAPED" },
+ { Flags::ALLOW1OPTION, "ALLOW1OPTION" },
+ { Flags::VOICE_H_LINE, "VOICE_H_LINE" },
+ { Flags::VOICE_A_LINE, "VOICE_A_LINE" },
+ { Flags::VOICE_B_LINE, "VOICE_B_LINE" },
+ { Flags::VOICE_C_LINE, "VOICE_C_LINE" },
+ { Flags::NOHEROATALL, "NOHEROATALL" },
+ { Flags::MOUSEENABLED, "MOUSEENABLED" },
+ { Flags::DIALINES, "DIALINES" },
+ { Flags::SHANWALK, "SHANWALK" },
+ { Flags::SHANDOG, "SHANDOG" },
+ { Flags::GETACTIONBACK, "GETACTIONBACK" },
+ { Flags::GETACTIONDATA, "GETACTIONDATA" },
+ { Flags::GETACTION, "GETACTION" },
+ { Flags::HEROFAST, "HEROFAST" },
+ { Flags::SELITEM, "SELITEM" },
+ { Flags::LMOUSE, "LMOUSE" },
+ { Flags::MINMX, "MINMX" },
+ { Flags::MAXMX, "MAXMX" },
+ { Flags::MINMY, "MINMY" },
+ { Flags::MAXMY, "MAXMY" },
+ { Flags::TORX1, "TORX1" },
+ { Flags::TORY1, "TORY1" },
+ { Flags::TORX2, "TORX2" },
+ { Flags::TORY2, "TORY2" },
+ { Flags::POWER, "POWER" },
+ { Flags::POWERENABLED, "POWERENABLED" },
+ { Flags::FLCRESTORE, "FLCRESTORE" },
+ { Flags::NOCLSTEXT, "NOCLSTEXT" },
+ { Flags::ESCAPED2, "ESCAPED2" },
+};
+
+} // End of namespace Prince
diff --git a/engines/prince/flags.h b/engines/prince/flags.h
new file mode 100644
index 0000000000..8337f82a95
--- /dev/null
+++ b/engines/prince/flags.h
@@ -0,0 +1,421 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public 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 PRINCE_FLAGS_H
+#define PRINCE_FLAGS_H
+
+#include "common/scummsys.h"
+
+namespace Prince {
+
+class Flags {
+public:
+ static int compareFlagDebug(const void *a, const void *b);
+ static const char *getFlagName(uint16 flagId);
+
+ enum Id {
+ FLAGA1 = 0x8000,
+ FLAGA2 = 0x8002,
+ FLAGA3 = 0x8004,
+ DESTX = 0x8006,
+ DESTY = 0x8008,
+ DESTD = 0x800A,
+ DwarfDone = 0x800C,
+ GRABARZCOUNTER = 0x800E,
+ KIERUNEK = 0x8010,
+ BACKFLAG1 = 0x8012,
+ BACKFLAG2 = 0x8014,
+ BACKFLAG3 = 0x8016,
+ BACKFLAG4 = 0x8018,
+ MACROFLAG1 = 0x801A,
+ MACROFLAG2 = 0x801C,
+ MACROFLAG3 = 0x801E,
+ HEROLDDONE = 0x8020,
+ BRIDGESET = 0x8022,
+ U_BT_1 = 0x8024,
+ U_BT_2 = 0x8026,
+ U_BT_3 = 0x8028,
+ U_BT_4 = 0x802A,
+ U_BT_5 = 0x802C,
+ U_BT_6 = 0x802E,
+ U_BT_7 = 0x8030,
+ U_BT_8 = 0x8032,
+ U_BT_9 = 0x8034,
+ U_BT_COUNTER = 0x8036,
+ ARIVALDALIVE = 0x8038,
+ TALKCHAR1 = 0x803A,
+ TalkType1 = 0x803C,
+ TALKROUT1 = 0x803E,
+ TALKROUT2 = 0x8042,
+ TALKROUT3 = 0x8046,
+ TALKROUT4 = 0x804A,
+ TALKANIM1 = 0x804E,
+ TALKANIM2 = 0x8050,
+ TALKCOLOR1 = 0x8052,
+ TALKCOLOR2 = 0x8054,
+ KapciuchTaken = 0x8056,
+ CurrentBeggarA = 0x8058,
+ TempKapc = 0x805A,
+ HomTaken = 0x805C,
+ WizardTalk = 0x805E,
+ SunlordTalk = 0x8060,
+ HermitTalk = 0x8062,
+ RunyMode = 0x8064,
+ FatMerchantTalk = 0x8066,
+ HotDogTalk = 0x8068,
+ ThiefTalk = 0x806A,
+ BeggarTalk = 0x806C,
+ // DwarfTalk = 0x806E, // Redefinition
+ MonkTalk = 0x8070,
+ BardTalk = 0x8072,
+ BarmanTalk = 0x8074,
+ LeftPlayerTalk = 0x8076,
+ OczySowy = 0x8078,
+ CzachySpeed1 = 0x807A,
+ CzachySpeed2 = 0x807C,
+ CzachySpeed3 = 0x807E,
+ CzachySlowDown1 = 0x8080,
+ CzachySlowDown2 = 0x8082,
+ CzachySlowDown3 = 0x8084,
+ FjordDane = 0x8086,
+ GKopany1 = 0x8088,
+ GKopany2 = 0x808A,
+ GKopany3 = 0x808C,
+ GKopany4 = 0x808E,
+ KnowGodWord = 0x8090,
+ TALKROUT21 = 0x8092,
+ TALKROUT22 = 0x8096,
+ TALKROUT23 = 0x809A,
+ TALKROUT24 = 0x809E,
+ TalkType2 = 0x80A2,
+ GrabarzTalk = 0x80A4,
+ LastTalker = 0x80A6,
+ MapaPustelniaEnabled = 0x80A8,
+ MapaTempleEnabled = 0x80AA,
+ MapaFjordEnabled = 0x80AC,
+ MapaSilmanionaEnabled = 0x80AE,
+ MapaKurhanEnabled = 0x80B0,
+ MapaDragonEnabled = 0x80B2,
+ MapaMillEnabled = 0x80B4,
+ DwarfRunning = 0x80B6,
+ DwarfTalk = 0x80B8,
+ CurseLift = 0x80BA,
+ KosciSwapped = 0x80BC,
+ BookStolen = 0x80BE,
+ MapaUsable = 0x80C0,
+ FjordBoss = 0x80C2,
+ FjordHotDog = 0x80C4,
+ FjordLewy = 0x80C6,
+ FjordPrawy = 0x80C8,
+ TalkArivald = 0x80CA,
+ ShootDone = 0x80CC,
+ ShootRunning = 0x80CE,
+ ShootKnow = 0x80D0,
+ MirrorKnow = 0x80D2,
+ Gar1stTime = 0x80D4,
+ KosciTaken = 0x80D6,
+ ArivGotSpell = 0x80D8,
+ BookGiven = 0x80DA,
+ Wywieszka = 0x80DC,
+ TalkSheila = 0x80DE,
+ TalkSheila2 = 0x80E0,
+ BackHuman = 0x80E2,
+ SkarbiecOpen = 0x80E4,
+ LustroTaken = 0x80E6,
+ GargoyleHom = 0x80E8,
+ GargoyleBroken = 0x80EA,
+ FjordDzien = 0x80EC,
+ GargoyleHom2 = 0x80EE,
+ RunMonstersRunning = 0x80F0,
+ FoundPaperInCoffin = 0x80F2,
+ KnowSunlord = 0x80F4,
+ KnowSunlordTalk = 0x80F6,
+ ArivaldCzyta = 0x80F8,
+ TelepX = 0x80FA,
+ TelepY = 0x80FC,
+ TelepDir = 0x80FE,
+ TelepRoom = 0x8100,
+ ListStolen = 0x8102,
+ WifeInDoor = 0x8104,
+ TalkWifeFlag = 0x8106,
+ LetterGiven = 0x8108,
+ LutniaTaken = 0x810A,
+ BardHomeOpen = 0x810C,
+ FjordNoMonsters = 0x810E,
+ ShandriaWallTalking = 0x8110,
+ ShandriaWallCounter = 0x8112,
+ ShandriaWallDone = 0x8114,
+ FutureDone = 0x8116,
+ TalkButch = 0x8118,
+ GotSzalik = 0x811A,
+ GotCzosnek = 0x811C,
+ BearDone = 0x811E,
+ NekrVisited = 0x8120,
+ SunRiddle = 0x8122,
+ PtaszekAway = 0x8124,
+ KotGadanie = 0x8126,
+ SzlafmycaTaken = 0x8128,
+ BabkaTalk = 0x812A,
+ SellerTalk = 0x812C,
+ CzosnekDone = 0x812E,
+ PriestCounter = 0x8130,
+ PriestGest1 = 0x8132,
+ PriestGest2 = 0x8134,
+ PriestGest3 = 0x8136,
+ PriestGest4 = 0x8138,
+ PriestAnim = 0x813A,
+ HolyWaterTaken = 0x813C,
+ AxeTaken = 0x813E,
+ BadylTaken1 = 0x8140,
+ BadylTaken2 = 0x8142,
+ BadylSharpened = 0x8144,
+ PorwanieSmoka = 0x8146,
+ ShopReOpen = 0x8148,
+ LuskaShown = 0x814A,
+ CudKnow = 0x814C,
+ VampireDead = 0x814E,
+ MapaVisible1 = 0x8150,
+ MapaVisible2 = 0x8152,
+ MapaVisible3 = 0x8154,
+ MapaVisible4 = 0x8156,
+ MapaVisible5 = 0x8158,
+ MapaVisible6 = 0x815A,
+ MapaVisible7 = 0x815C,
+ MapaVisible8 = 0x815E,
+ MapaVisible9 = 0x8160,
+ MapaX = 0x8162,
+ MapaY = 0x8164,
+ MapaD = 0x8166,
+ OldMapaX = 0x8168,
+ OldMapaY = 0x816A,
+ OldMapaD = 0x816C,
+ MovingBack = 0x816E,
+ MapaCount = 0x8170,
+ Pustelnia1st = 0x8172,
+ CzarnePole1st = 0x8174,
+ TalkArivNum = 0x8176,
+ Pfui = 0x8178,
+ MapaSunlordEnabled = 0x817A,
+ WebDone = 0x817C,
+ DragonDone = 0x817E,
+ KanPlay = 0x8180,
+ OldKanPlay = 0x8182,
+ LapkiWait = 0x8184,
+ WebNoCheck = 0x8186,
+ Perfumeria = 0x8188,
+ SmokNoCheck = 0x818A,
+ IluzjaBroken = 0x818C,
+ IluzjaWorking = 0x818E,
+ IluzjaCounter = 0x8190,
+ KurhanOpen1 = 0x8192,
+ KastetTaken = 0x8194,
+ KastetDown = 0x8196,
+ KurhanDone = 0x8198,
+ SkelCounter = 0x819A,
+ SkelDial1 = 0x819C,
+ SkelDial2 = 0x819E,
+ SkelDial3 = 0x81A0,
+ SkelDial4 = 0x81A2,
+ SameTalker = 0x81A4,
+ RunMonstersText = 0x81A6,
+ PiwnicaChecked = 0x81A8,
+ DragonTalked = 0x81AA,
+ ToldAboutBook = 0x81AC,
+ SilmanionaDone = 0x81AE,
+ ToldBookCount = 0x81B0,
+ SmrodNoCheck = 0x81B2,
+ RopeTaken = 0x81B4,
+ RopeTime = 0x81B6,
+ LaskaFree = 0x81B8,
+ ShanSmokTalked = 0x81BA,
+ SwordTaken = 0x81BC,
+ Mill1st = 0x81BE,
+ SawRat = 0x81C0,
+ KnowRat = 0x81C2,
+ DziuraTimer = 0x81C4,
+ LaskaInside = 0x81C6,
+ HoleBig = 0x81C8,
+ EnableWiedzmin = 0x81CA,
+ EnableTrucizna = 0x81CC,
+ KnowPoison = 0x81CE,
+ KufelTaken = 0x81D0,
+ BojkaEnabled = 0x81D2,
+ BitwaNot1st = 0x81D4,
+ BojkaTimer = 0x81D6,
+ BojkaGirl = 0x81D8,
+ Look1st = 0x81DA,
+ RatTaken = 0x81DC,
+ LaskaTalkedGr = 0x81DE,
+ RatusGivus = 0x81E0,
+ MamObole = 0x81E2,
+ Speed1st = 0x81E4,
+ SpeedTimer = 0x81E6,
+ ProveIt = 0x81E8,
+ Proven = 0x81EA,
+ ShowWoalka = 0x81EC,
+ PoisonTaken = 0x81EE,
+ HellOpened = 0x81F0,
+ HellNoCheck = 0x81F2,
+ TalAn1 = 0x81F4,
+ TalAn2 = 0x81F6,
+ TalAn3 = 0x81F8,
+ TalkDevilGuard = 0x81fA,
+ Sword1st = 0x81FC,
+ IluzjaNoCheck = 0x81FE,
+ RozdzielniaNumber = 0x8200,
+ JailChecked = 0x8202,
+ JailTalked = 0x8204,
+ TrickFailed = 0x8206,
+ WegielVisible = 0x8208,
+ WegielTimer1 = 0x820A,
+ RandomSample = 0x820C,
+ RandomSampleTimer = 0x820E,
+ SampleTimer = 0x8210,
+ ZonaSample = 0x8212,
+ HoleTryAgain = 0x8214,
+ TeleportTimer = 0x8216,
+ RozLezy = 0x8218,
+ UdkoTimer = 0x821A,
+ ZaworZatkany = 0x821C,
+ ZaworOpened = 0x821E,
+ DoorExploded = 0x8220,
+ SkoraTaken = 0x8222,
+ CiezkieByl = 0x8224,
+ MamWegiel = 0x8226,
+ SwiecaAway = 0x8228,
+ ITSAVE = 0x822A,
+ RozpadlSie = 0x822C,
+ WegielFullTimer = 0x822E,
+ WegielDown = 0x8230,
+ WegielDownTimer = 0x8232,
+ PaliSie = 0x8234,
+ DiabGuardTalked = 0x8236,
+ GuardsNoCheck = 0x8238,
+ TalkedPowloka = 0x823A,
+ JailOpen = 0x823C,
+ PrzytulTimer = 0x823E,
+ JailDone = 0x8240,
+ MamMonety = 0x8242,
+ LotTimer = 0x8244,
+ LotObj = 0x8246,
+ PtakTimer = 0x8248,
+ BookTimer = 0x824A,
+ BookGiba = 0x824C,
+ PtakLata = 0x824E,
+ Podej = 0x8250,
+ GotHint = 0x8252,
+ LawaLeci = 0x8254,
+ PowerKlik = 0x8258,
+ LucekBad = 0x825A,
+ LucekBad1st = 0x825C,
+ IntroDial1 = 0x825E,
+ IntroDial2 = 0x8260,
+ ItsOutro = 0x8262,
+ KamienComment = 0x8264,
+ KamienSkip = 0x8266,
+ TesterFlag = 0x8268,
+ RememberLine = 0x826A,
+ OpisLapek = 0x826C,
+ //OpisKamienia = 0x826E, // Redefinition
+ TalWait = 0x8270,
+ OpisKamienia = 0x8272,
+ JumpBox = 0x8274,
+ JumpBox1 = 0x8276,
+ JumpBox2 = 0x8278,
+ JumpBox3 = 0x827A,
+ SpecPiesek = 0x827C,
+ SpecPiesekCount = 0x827E,
+ SpecPiesekGadanie = 0x8282,
+ ZnikaFlag = 0x8284,
+ ZnikaTimer = 0x8286,
+ SowaTimer = 0x8288,
+ MamrotanieOff = 0x828A,
+ // System flags controlled by script
+ CURRMOB = 0x8400,
+ KOLOR = 0x8402,
+ MBFLAG = 0x8404,
+ MXFLAG = 0x8406,
+ MYFLAG = 0x8408,
+ SCROLLTYPE = 0x840A,
+ SCROLLVALUE = 0x840C,
+ SCROLLVALUE2 = 0x840E,
+ TALKEXITCODE = 0x8410,
+ SPECROUTFLAG1 = 0x8412,
+ SPECROUTFLAG2 = 0x8414,
+ SPECROUTFLAG3 = 0x8416,
+ TALKFLAGCODE = 0x8418,
+ CURRROOM = 0x841A,
+ Talker1Init = 0x841C,
+ Talker2Init = 0x841E,
+ RESTOREROOM = 0x8420,
+ INVALLOWED = 0x8422,
+ BOXSEL = 0x8424,
+ CURSEBLINK = 0x8426,
+ EXACTMOVE = 0x8428,
+ MOVEDESTX = 0x842A,
+ MOVEDESTY = 0x842C,
+ NOANTIALIAS = 0x842E,
+ ESCAPED = 0x8430,
+ ALLOW1OPTION = 0x8432,
+ VOICE_H_LINE = 0x8434,
+ VOICE_A_LINE = 0x8436,
+ VOICE_B_LINE = 0x8438,
+ VOICE_C_LINE = 0x843A,
+ NOHEROATALL = 0x843C,
+ MOUSEENABLED = 0x843E,
+ DIALINES = 0x8440,
+ //SELITEM = 0x8442, // Redefinition
+ SHANWALK = 0x8444,
+ SHANDOG = 0x8446,
+ GETACTIONBACK = 0x8448,
+ GETACTIONDATA = 0x844C,
+ GETACTION = 0x8450,
+ HEROFAST = 0x8452,
+ SELITEM = 0x8454,
+ LMOUSE = 0x8456,
+ MINMX = 0x8458,
+ MAXMX = 0x845A,
+ MINMY = 0x845C,
+ MAXMY = 0x845E,
+ TORX1 = 0x8460,
+ TORY1 = 0x8462,
+ TORX2 = 0x8464,
+ TORY2 = 0x8466,
+ POWER = 0x8468,
+ POWERENABLED = 0x846A,
+ FLCRESTORE = 0x846C,
+ NOCLSTEXT = 0x846E,
+ ESCAPED2 = 0x8470
+ };
+
+ struct FlagDebug {
+ Id id;
+ char flagName[30];
+ };
+
+ static const int kFlagDebugAmount = 368;
+ static const FlagDebug _flagNames[kFlagDebugAmount];
+};
+
+} // End of namespace Prince
+
+#endif
diff --git a/engines/prince/font.cpp b/engines/prince/font.cpp
new file mode 100644
index 0000000000..e81a93d1a1
--- /dev/null
+++ b/engines/prince/font.cpp
@@ -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.
+ *
+ */
+
+#include "common/archive.h"
+#include "common/debug.h"
+#include "common/stream.h"
+
+#include "prince/font.h"
+#include "prince/prince.h"
+
+namespace Prince {
+
+Font::Font() : _fontData(nullptr) {
+}
+
+Font::~Font() {
+ if (_fontData != nullptr) {
+ free(_fontData);
+ _fontData = nullptr;
+ }
+}
+
+bool Font::loadStream(Common::SeekableReadStream &stream) {
+ stream.seek(0);
+ uint32 dataSize = stream.size();
+ _fontData = (byte *)malloc(dataSize);
+ stream.read(_fontData, stream.size());
+ return true;
+}
+
+int Font::getFontHeight() const {
+ return _fontData[5];
+}
+
+int Font::getMaxCharWidth() const {
+ return 0;
+}
+
+Font::ChrData Font::getChrData(byte chr) const {
+ chr -= 32;
+ uint16 chrOffset = 4 * chr + 6;
+
+ ChrData chrData;
+ chrData._width = _fontData[chrOffset + 2];
+ chrData._height = _fontData[chrOffset + 3];
+ chrData._pixels = _fontData + READ_LE_UINT16(_fontData + chrOffset);
+
+ return chrData;
+}
+
+int Font::getCharWidth(uint32 chr) const {
+ return getChrData(chr)._width;
+}
+
+void Font::drawChar(Graphics::Surface *dst, uint32 chr, int posX, int posY, uint32 color) const {
+ const ChrData chrData = getChrData(chr);
+ Common::Rect screenRect(0, 0, PrinceEngine::kNormalWidth, PrinceEngine::kNormalHeight);
+
+ for (int y = 0; y < chrData._height; y++) {
+ for (int x = 0; x < chrData._width; x++) {
+ byte d = chrData._pixels[x + (chrData._width * y)];
+ if (d == 0) d = 255;
+ else if (d == 1) d = 0;
+ else if (d == 2) d = color;
+ else if (d == 3) d = 0;
+ if (d != 255) {
+ if (screenRect.contains(posX + x, posY + y)) {
+ *(byte *)dst->getBasePtr(posX + x, posY + y) = d;
+ }
+ }
+ }
+ }
+}
+
+} // End of namespace Prince
diff --git a/engines/prince/font.h b/engines/prince/font.h
new file mode 100644
index 0000000000..b03849a4aa
--- /dev/null
+++ b/engines/prince/font.h
@@ -0,0 +1,64 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#ifndef PRINCE_FONT_H
+#define PRINCE_FONT_H
+
+#include "graphics/font.h"
+#include "graphics/surface.h"
+
+#include "common/str.h"
+#include "common/rect.h"
+
+namespace Prince {
+
+class Font : public Graphics::Font {
+public:
+ Font();
+ virtual ~Font();
+
+ bool loadStream(Common::SeekableReadStream &stream);
+
+ virtual int getFontHeight() const override;
+
+ virtual int getMaxCharWidth() const override;
+
+ virtual int getCharWidth(uint32 chr) const override;
+
+ virtual void drawChar(Graphics::Surface *dst, uint32 chr, int x, int y, uint32 color) const override;
+
+ virtual int getKerningOffset(uint32 left, uint32 right) const override { return -2; }
+
+private:
+ struct ChrData {
+ byte *_pixels;
+ byte _width;
+ byte _height;
+ };
+
+ ChrData getChrData(byte chr) const;
+
+ byte *_fontData;
+};
+
+} // End of namespace Prince
+
+#endif
diff --git a/engines/prince/graphics.cpp b/engines/prince/graphics.cpp
new file mode 100644
index 0000000000..f556d81eab
--- /dev/null
+++ b/engines/prince/graphics.cpp
@@ -0,0 +1,474 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public 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 "prince/graphics.h"
+#include "prince/prince.h"
+#include "prince/mhwanh.h"
+
+#include "graphics/palette.h"
+
+#include "common/memstream.h"
+
+namespace Prince {
+
+GraphicsMan::GraphicsMan(PrinceEngine *vm) : _vm(vm), _changed(false) {
+ initGraphics(640, 480, true);
+
+ _frontScreen = new Graphics::Surface();
+ _frontScreen->create(640, 480, Graphics::PixelFormat::createFormatCLUT8());
+
+ _screenForInventory = new Graphics::Surface();
+ _screenForInventory->create(640, 480, Graphics::PixelFormat::createFormatCLUT8());
+
+ _mapScreen = new Graphics::Surface();
+ _mapScreen->create(640, 480, Graphics::PixelFormat::createFormatCLUT8());
+
+ _shadowTable70 = (byte *)malloc(256);
+ _shadowTable50 = (byte *)malloc(256);
+}
+
+GraphicsMan::~GraphicsMan() {
+ _frontScreen->free();
+ delete _frontScreen;
+
+ _screenForInventory->free();
+ delete _screenForInventory;
+
+ _mapScreen->free();
+ delete _mapScreen;
+
+ free(_shadowTable70);
+ free(_shadowTable50);
+}
+
+void GraphicsMan::update(Graphics::Surface *screen) {
+ if (_changed) {
+ _vm->_system->copyRectToScreen((byte *)screen->getBasePtr(0, 0), 640, 0, 0, 640, 480);
+
+ _vm->_system->updateScreen();
+ _changed = false;
+ }
+}
+
+void GraphicsMan::setPalette(const byte *palette) {
+ _vm->_system->getPaletteManager()->setPalette(palette, 0, 256);
+}
+
+void GraphicsMan::change() {
+ _changed = true;
+}
+
+void GraphicsMan::draw(Graphics::Surface *screen, const Graphics::Surface *s) {
+ uint16 w = MIN(screen->w, s->w);
+ const byte *src = (const byte *)s->getBasePtr(0, 0);
+ byte *dst = (byte *)screen->getBasePtr(0, 0);
+ for (uint y = 0; y < s->h; y++) {
+ if (y < screen->h) {
+ memcpy(dst, src, w);
+ }
+ src += s->pitch;
+ dst += screen->pitch;
+ }
+ change();
+}
+
+// Black (value = 0) as a primary transparent color, fix for FLC animations
+void GraphicsMan::drawTransparentSurface(Graphics::Surface *screen, int32 posX, int32 posY, const Graphics::Surface *s, int secondTransColor) {
+ const byte *src1 = (const byte *)s->getBasePtr(0, 0);
+ byte *dst1 = (byte *)screen->getBasePtr(posX, posY);
+ for (int y = 0; y < s->h; y++) {
+ if (y + posY < screen->h && y + posY >= 0) {
+ const byte *src2 = src1;
+ byte *dst2 = dst1;
+ for (int x = 0; x < s->w; x++, src2++, dst2++) {
+ if (*src2 && *src2 != secondTransColor) {
+ if (x + posX < screen->w && x + posX >= 0) {
+ *dst2 = *src2;
+ }
+ }
+ }
+ }
+ src1 += s->pitch;
+ dst1 += screen->pitch;
+ }
+ change();
+}
+
+/**
+ * Similar to drawTransparentSurface but with use of shadowTable for color recalculation
+ * and kShadowColor (191) as a transparent color.
+ */
+void GraphicsMan::drawAsShadowSurface(Graphics::Surface *screen, int32 posX, int32 posY, const Graphics::Surface *s, byte *shadowTable) {
+ const byte *src1 = (const byte *)s->getBasePtr(0, 0);
+ byte *dst1 = (byte *)screen->getBasePtr(posX, posY);
+ for (int y = 0; y < s->h; y++) {
+ if (y + posY < screen->h && y + posY >= 0) {
+ const byte *src2 = src1;
+ byte *dst2 = dst1;
+ for (int x = 0; x < s->w; x++, src2++, dst2++) {
+ if (*src2 == kShadowColor) {
+ if (x + posX < screen->w && x + posX >= 0) {
+ *dst2 = *(shadowTable + *dst2);
+ }
+ }
+ }
+ }
+ src1 += s->pitch;
+ dst1 += screen->pitch;
+ }
+}
+
+/**
+ * Used in glowing animation for inventory items. Creates special blendTable array of colors,
+ * use black (0) as a transparent color.
+ */
+void GraphicsMan::drawTransparentWithBlendSurface(Graphics::Surface *screen, int32 posX, int32 posY, const Graphics::Surface *s) {
+ const byte *src1 = (const byte *)s->getBasePtr(0, 0);
+ byte *dst1 = (byte *)screen->getBasePtr(posX, posY);
+ byte *blendTable = (byte *)malloc(256);
+ for (int i = 0; i < 256; i++) {
+ blendTable[i] = 255;
+ }
+ for (int y = 0; y < s->h; y++) {
+ if (y + posY < screen->h && y + posY >= 0) {
+ const byte *src2 = src1;
+ byte *dst2 = dst1;
+ for (int x = 0; x < s->w; x++, src2++, dst2++) {
+ if (*src2) {
+ if (x + posX < screen->w && x + posX >= 0) {
+ *dst2 = getBlendTableColor(*src2, *dst2, blendTable);
+ }
+ }
+ }
+ }
+ src1 += s->pitch;
+ dst1 += screen->pitch;
+ }
+ free(blendTable);
+ change();
+}
+
+/**
+ * Similar to drawTransparentSurface but with with use of DrawNode as argument for Z axis sorting
+ * and white (255) as transparent color.
+ */
+void GraphicsMan::drawTransparentDrawNode(Graphics::Surface *screen, DrawNode *drawNode) {
+ byte *src1 = (byte *)drawNode->s->getBasePtr(0, 0);
+ byte *dst1 = (byte *)screen->getBasePtr(drawNode->posX, drawNode->posY);
+ for (int y = 0; y < drawNode->s->h; y++) {
+ if (y + drawNode->posY < screen->h && y + drawNode->posY >= 0) {
+ byte *src2 = src1;
+ byte *dst2 = dst1;
+ for (int x = 0; x < drawNode->s->w; x++, src2++, dst2++) {
+ if (*src2 != 255) {
+ if (x + drawNode->posX < screen->w && x + drawNode->posX >= 0) {
+ *dst2 = *src2;
+ }
+ }
+ }
+ }
+ src1 += drawNode->s->pitch;
+ dst1 += screen->pitch;
+ }
+}
+
+/**
+ * Similar to drawTransparentDrawNode but with additional anti-aliasing code for sprite drawing.
+ * Edge smoothing is based on 256 x 256 table of colors transition.
+ * Algorithm is checking if currently drawing pixel is located next to the edge of sprite and if it makes jagged line.
+ * If it does then this pixel is set with color from transition table calculated of original background pixel color
+ * and sprite's edge pixel color.
+ */
+void GraphicsMan::drawTransparentWithTransDrawNode(Graphics::Surface *screen, DrawNode *drawNode) {
+ // pos of first pixel for each row of source sprite
+ byte *src1 = (byte *)drawNode->s->getBasePtr(0, 0);
+ // pos of drawing first pixel for each row on screen surface
+ byte *dst1 = (byte *)screen->getBasePtr(drawNode->posX, drawNode->posY);
+ // trasition table for calculating new color value
+ byte *transTableData = (byte *)drawNode->data;
+ for (int y = 0; y < drawNode->s->h; y++) {
+ if (y + drawNode->posY < screen->h && y + drawNode->posY >= 0) {
+ // current pixel in row of source sprite
+ byte *src2 = src1;
+ // current pixel in row of screen surface
+ byte *dst2 = dst1;
+ for (int x = 0; x < drawNode->s->w; x++, src2++, dst2++) {
+ if (x + drawNode->posX < screen->w && x + drawNode->posX >= 0) {
+ if (*src2 != 255) {
+ // if source sprite pixel is not mask color than draw it normally
+ *dst2 = *src2;
+ } else {
+ // check for making jagged line
+ if (x) {
+ // not first pixel in row
+ if (*(src2 - 1) == 255) {
+ // if it has mask color to the left - check right
+ if (x != drawNode->s->w - 1) {
+ // not last pixel in row
+ if (*(src2 + 1) == 255) {
+ // pixel to the right with mask color - no anti-alias
+ continue;
+ }
+ // it's not mask color to the right - we continue checking
+ } else {
+ // last pixel in row, no right check - no anti-alias
+ continue;
+ }
+ }
+ // it's not mask color to the left - we continue checking
+ } else if (x != drawNode->s->w - 1) {
+ // first pixel in row but not last - just right pixel checking
+ if (*(src2 + 1) == 255) {
+ // pixel to the right with mask color - no anti-alias
+ continue;
+ }
+ // it's not mask color to the right - we continue checking
+ } else {
+ // it's first and last pixel in row at the same time (width = 1) - no anti-alias
+ continue;
+ }
+ byte value = 0;
+ if (y != drawNode->s->h - 1) {
+ // not last row
+ // check pixel below of current src2 pixel
+ value = *(src2 + drawNode->s->pitch);
+ if (value == 255) {
+ // pixel below with mask color - check above
+ if (y) {
+ // not first row
+ value = *(src2 - drawNode->s->pitch);
+ if (value == 255) {
+ // pixel above with mask color - no anti-alias
+ continue;
+ }
+ // it's not mask color above - we draw as transition color
+ } else {
+ // first row - no anti-alias
+ continue;
+ }
+ }
+ // it's not mask color below - we draw as transition color
+ } else if (y) {
+ // last row - just check above
+ value = *(src2 - drawNode->s->pitch);
+ if (value == 255) {
+ // pixel above with mask color - no anti-alias
+ continue;
+ }
+ // it's not mask color above - we draw as transition color
+ } else {
+ // first and last row at the same time (height = 1) - no anti-alias
+ continue;
+ }
+ // new color value based on orginal screen surface color and sprite's edge pixel color
+ *dst2 = transTableData[*dst2 * 256 + value];
+ }
+ }
+ }
+ }
+ // adding pitch to jump to next row of pixels
+ src1 += drawNode->s->pitch;
+ dst1 += screen->pitch;
+ }
+}
+
+void GraphicsMan::drawMaskDrawNode(Graphics::Surface *screen, DrawNode *drawNode) {
+ byte *maskData = (byte *)drawNode->data;
+ byte *src1 = (byte *)drawNode->originalRoomSurface->getBasePtr(drawNode->posX, drawNode->posY);
+ byte *dst1 = (byte *)screen->getBasePtr(drawNode->posX, drawNode->posY);
+ int maskWidth = drawNode->width >> 3;
+ int maskPostion = 0;
+ int maskCounter = 128;
+ for (int y = 0; y < drawNode->height; y++) {
+ if (y + drawNode->posY < screen->h && y + drawNode->posY >= 0) {
+ byte *src2 = src1;
+ byte *dst2 = dst1;
+ int tempMaskPostion = maskPostion;
+ for (int x = 0; x < drawNode->width; x++, src2++, dst2++) {
+ if (x + drawNode->posX < screen->w && x + drawNode->posX >= 0) {
+ if ((maskData[tempMaskPostion] & maskCounter) != 0) {
+ *dst2 = *src2;
+ }
+ }
+ maskCounter >>= 1;
+ if (maskCounter == 0) {
+ maskCounter = 128;
+ tempMaskPostion++;
+ }
+ }
+ }
+ src1 += drawNode->originalRoomSurface->pitch;
+ dst1 += screen->pitch;
+ maskPostion += maskWidth;
+ maskCounter = 128;
+ }
+}
+
+void GraphicsMan::drawAsShadowDrawNode(Graphics::Surface *screen, DrawNode *drawNode) {
+ byte *shadowData = (byte *)drawNode->data;
+ byte *src1 = (byte *)drawNode->s->getBasePtr(0, 0);
+ byte *dst1 = (byte *)screen->getBasePtr(drawNode->posX, drawNode->posY);
+ for (int y = 0; y < drawNode->s->h; y++) {
+ if (y + drawNode->posY < screen->h && y + drawNode->posY >= 0) {
+ byte *src2 = src1;
+ byte *dst2 = dst1;
+ for (int x = 0; x < drawNode->s->w; x++, src2++, dst2++) {
+ if (*src2 == kShadowColor) {
+ if (x + drawNode->posX < screen->w && x + drawNode->posX >= 0) {
+ *dst2 = *(shadowData + *dst2);
+ }
+ }
+ }
+ }
+ src1 += drawNode->s->pitch;
+ dst1 += screen->pitch;
+ }
+}
+
+void GraphicsMan::drawBackSpriteDrawNode(Graphics::Surface *screen, DrawNode *drawNode) {
+ byte *src1 = (byte *)drawNode->s->getBasePtr(0, 0);
+ byte *dst1 = (byte *)screen->getBasePtr(drawNode->posX, drawNode->posY);
+ for (int y = 0; y < drawNode->s->h; y++) {
+ if (y + drawNode->posY < screen->h && y + drawNode->posY >= 0) {
+ byte *src2 = src1;
+ byte *dst2 = dst1;
+ for (int x = 0; x < drawNode->s->w; x++, src2++, dst2++) {
+ if (*src2 != 255) {
+ if (x + drawNode->posX < screen->w && x + drawNode->posX >= 0) {
+ if (*dst2 == 255) {
+ *dst2 = *src2;
+ }
+ }
+ }
+ }
+ }
+ src1 += drawNode->s->pitch;
+ dst1 += screen->pitch;
+ }
+}
+
+byte GraphicsMan::getBlendTableColor(byte pixelColor, byte backgroundPixelColor, byte *blendTable) {
+ int currColor = 0;
+
+ if (blendTable[pixelColor] != 255) {
+ currColor = blendTable[pixelColor];
+ } else {
+ const byte *originalPalette = _vm->_roomBmp->getPalette();
+
+ int redFirstOrg = originalPalette[pixelColor * 3] * _vm->_mst_shadow / 256;
+ CLIP(redFirstOrg, 0, 255);
+ if (_vm->_mst_shadow <= 256) {
+ int redFirstBack = originalPalette[backgroundPixelColor * 3] * (256 - _vm->_mst_shadow) / 256;
+ CLIP(redFirstBack, 0, 255);
+ redFirstOrg += redFirstBack;
+ CLIP(redFirstOrg, 0, 255);
+ }
+
+ int greenFirstOrg = originalPalette[pixelColor * 3 + 1] * _vm->_mst_shadow / 256;
+ CLIP(greenFirstOrg, 0, 255);
+ if (_vm->_mst_shadow <= 256) {
+ int greenFirstBack = originalPalette[backgroundPixelColor * 3 + 1] * (256 - _vm->_mst_shadow) / 256;
+ CLIP(greenFirstBack, 0, 255);
+ greenFirstOrg += greenFirstBack;
+ CLIP(greenFirstOrg, 0, 255);
+ }
+
+ int blueFirstOrg = originalPalette[pixelColor * 3 + 2] * _vm->_mst_shadow / 256;
+ CLIP(blueFirstOrg, 0, 255);
+ if (_vm->_mst_shadow <= 256) {
+ int blueFirstBack = originalPalette[backgroundPixelColor * 3 + 2] * (256 - _vm->_mst_shadow) / 256;
+ CLIP(blueFirstBack, 0, 255);
+ blueFirstOrg += blueFirstBack;
+ CLIP(blueFirstOrg, 0, 255);
+ }
+
+ int bigValue = PrinceEngine::kIntMax; // infinity
+ for (int j = 0; j < 256; j++) {
+ int redSecondOrg = originalPalette[3 * j];
+ int redNew = redFirstOrg - redSecondOrg;
+ redNew = redNew * redNew;
+
+ int greenSecondOrg = originalPalette[3 * j + 1];
+ int greenNew = greenFirstOrg - greenSecondOrg;
+ greenNew = greenNew * greenNew;
+
+ int blueSecondOrg = originalPalette[3 * j + 2];
+ int blueNew = blueFirstOrg - blueSecondOrg;
+ blueNew = blueNew * blueNew;
+
+ int sumOfColorValues = redNew + greenNew + blueNew;
+
+ if (sumOfColorValues < bigValue) {
+ bigValue = sumOfColorValues;
+ currColor = j;
+ }
+
+ if (sumOfColorValues == 0) {
+ break;
+ }
+ }
+ blendTable[pixelColor] = currColor;
+ }
+ return currColor;
+}
+
+void GraphicsMan::makeShadowTable(int brightness, byte *shadowPalette) {
+ int shadow = brightness * 256 / 100;
+ const byte *originalPalette = _vm->_roomBmp->getPalette();
+
+ for (int i = 0; i < 256; i++) {
+ int redFirstOrg = originalPalette[3 * i] * shadow / 256;
+ int greenFirstOrg = originalPalette[3 * i + 1] * shadow / 256;
+ int blueFirstOrg = originalPalette[3 * i + 2] * shadow / 256;
+
+ int currColor = 0;
+ int bigValue = 999999999; // infinity
+
+ for (int j = 0; j < 256; j++) {
+ int redSecondOrg = originalPalette[3 * j];
+ int redNew = redFirstOrg - redSecondOrg;
+ redNew = redNew * redNew;
+
+ int greenSecondOrg = originalPalette[3 * j + 1];
+ int greenNew = greenFirstOrg - greenSecondOrg;
+ greenNew = greenNew * greenNew;
+
+ int blueSecondOrg = originalPalette[3 * j + 2];
+ int blueNew = blueFirstOrg - blueSecondOrg;
+ blueNew = blueNew * blueNew;
+
+ int sumOfColorValues = redNew + greenNew + blueNew;
+
+ if (sumOfColorValues < bigValue) {
+ bigValue = sumOfColorValues;
+ currColor = j;
+ }
+
+ if (sumOfColorValues == 0) {
+ break;
+ }
+ }
+ shadowPalette[i] = currColor;
+ }
+}
+
+} // End of namespace Prince
diff --git a/engines/prince/graphics.h b/engines/prince/graphics.h
new file mode 100644
index 0000000000..1a1737f976
--- /dev/null
+++ b/engines/prince/graphics.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 PRINCE_GRAPHICS_H
+#define PRINCE_GRAPHICS_H
+
+#include "graphics/surface.h"
+
+namespace Prince {
+
+class PrinceEngine;
+class MhwanhDecoder;
+struct DrawNode;
+
+class GraphicsMan {
+public:
+ GraphicsMan(PrinceEngine *vm);
+ ~GraphicsMan();
+
+ void update(Graphics::Surface *screen);
+
+ void change();
+
+ void setPalette(const byte *palette);
+ void makeShadowTable(int brightness, byte *shadowTable);
+
+ void draw(Graphics::Surface *screen, const Graphics::Surface *s);
+ void drawTransparentSurface(Graphics::Surface *screen, int32 posX, int32 posY, const Graphics::Surface *s, int secondTransColor = 0);
+ void drawAsShadowSurface(Graphics::Surface *screen, int32 posX, int32 posY, const Graphics::Surface *s, byte *shadowTable);
+ void drawTransparentWithBlendSurface(Graphics::Surface *screen, int32 posX, int32 posY, const Graphics::Surface *s);
+
+ static void drawTransparentDrawNode(Graphics::Surface *screen, DrawNode *drawNode);
+ static void drawTransparentWithTransDrawNode(Graphics::Surface *screen, DrawNode *drawNode);
+ static void drawAsShadowDrawNode(Graphics::Surface *screen, DrawNode *drawNode);
+ static void drawMaskDrawNode(Graphics::Surface *screen, DrawNode *drawNode);
+ static void drawBackSpriteDrawNode(Graphics::Surface *screen, DrawNode *drawNode);
+
+ byte getBlendTableColor(byte pixelColor, byte backgroundPixelColor, byte *blendTable);
+
+ Graphics::Surface *_frontScreen;
+ Graphics::Surface *_screenForInventory;
+ Graphics::Surface *_mapScreen;
+ const Graphics::Surface *_roomBackground;
+
+ byte *_shadowTable70;
+ byte *_shadowTable50;
+
+ static const byte kShadowColor = 191;
+
+private:
+ PrinceEngine *_vm;
+ bool _changed;
+};
+
+} // End of namespace Prince
+
+#endif
diff --git a/engines/prince/hero.cpp b/engines/prince/hero.cpp
new file mode 100644
index 0000000000..b873e83360
--- /dev/null
+++ b/engines/prince/hero.cpp
@@ -0,0 +1,1002 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public 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/random.h"
+
+#include "prince/hero.h"
+#include "prince/hero_set.h"
+#include "prince/animation.h"
+#include "prince/resource.h"
+#include "prince/prince.h"
+#include "prince/graphics.h"
+#include "prince/flags.h"
+#include "prince/script.h"
+
+namespace Prince {
+
+Hero::Hero(PrinceEngine *vm, GraphicsMan *graph) : _vm(vm), _graph(graph),
+ _number(0), _visible(false), _state(kHeroStateStay), _middleX(0), _middleY(0),
+ _boreNum(1), _currHeight(0), _moveDelay(0), _shadMinus(0), _moveSetType(0), _zoomedHeroSurface(nullptr),
+ _lastDirection(kHeroDirDown), _destDirection(kHeroDirDown), _talkTime(0), _boredomTime(0), _phase(0),
+ _specAnim(nullptr), _drawX(0), _drawY(0), _drawZ(0),
+ _frameXSize(0), _frameYSize(0), _scaledFrameXSize(0), _scaledFrameYSize(0), _color(0),
+ _coords(nullptr), _dirTab(nullptr), _currCoords(nullptr), _currDirTab(nullptr), _step(0),
+ _maxBoredom(200), _leftRightMainDir(0), _upDownMainDir(0), _animSetNr(0)
+{
+}
+
+Hero::~Hero() {
+ freeHeroAnim();
+ freeOldMove();
+ freeZoomedSurface();
+}
+
+bool Hero::loadAnimSet(uint32 animSetNr) {
+ _animSetNr = animSetNr;
+
+ if (animSetNr >= ARRAYSIZE(heroSetTable)) {
+ return false;
+ }
+
+ _shadMinus = heroSetBack[animSetNr];
+
+ for (uint32 i = 0; i < _moveSet.size(); i++) {
+ delete _moveSet[i];
+ }
+
+ const HeroSetAnimNames &animSet = *heroSetTable[animSetNr];
+
+ _moveSet.resize(kMoveSetSize);
+ for (uint32 i = 0; i < kMoveSetSize; i++) {
+ debug("Anim set item %d %s", i, animSet[i]);
+ Animation *anim = nullptr;
+ if (animSet[i] != nullptr) {
+ anim = new Animation();
+ Resource::loadResource(anim, animSet[i], false);
+ }
+ _moveSet[i] = anim;
+ }
+
+ return true;
+}
+
+Graphics::Surface *Hero::getSurface() {
+ Animation *heroAnim = nullptr;
+ if (_specAnim != nullptr) {
+ heroAnim = _specAnim;
+ } else {
+ heroAnim = _moveSet[_moveSetType];
+ }
+
+ if (heroAnim != nullptr) {
+ int16 phaseFrameIndex = heroAnim->getPhaseFrameIndex(_phase);
+ Graphics::Surface *heroFrame = heroAnim->getFrame(phaseFrameIndex);
+ return heroFrame;
+ }
+ return nullptr;
+}
+
+uint16 Hero::getData(AttrId dataId) {
+ switch (dataId) {
+ case kHeroLastDir:
+ return _lastDirection;
+ case kHeroAnimSet:
+ return _animSetNr;
+ default:
+ assert(false);
+ return 0;
+ }
+}
+
+int Hero::getScaledValue(int size) {
+ int16 initScaleValue = _vm->_scaleValue;
+ if (_vm->_scaleValue != 10000) {
+ int newSize = 0;
+ for (int i = 0; i < size; i++) {
+ initScaleValue -= 100;
+ if (initScaleValue >= 0) {
+ newSize++;
+ } else {
+ initScaleValue += _vm->_scaleValue;
+ }
+ }
+ return newSize;
+ } else {
+ return size;
+ }
+}
+
+Graphics::Surface *Hero::zoomSprite(Graphics::Surface *heroFrame) {
+ Graphics::Surface *zoomedFrame = new Graphics::Surface();
+ zoomedFrame->create(_scaledFrameXSize, _scaledFrameYSize, Graphics::PixelFormat::createFormatCLUT8());
+
+ int sprZoomX;
+ int sprZoomY = _vm->_scaleValue;
+ uint xSource = 0;
+ uint ySource = 0;
+ uint xDest = 0;
+ uint yDest = 0;
+
+ for (int i = 0; i < _scaledFrameYSize; i++) {
+ // linear_loop:
+ while (1) {
+ sprZoomY -= 100;
+ if (sprZoomY >= 0 || _vm->_scaleValue == 10000) {
+ // all_r_y
+ sprZoomX = _vm->_scaleValue;
+ break; // to loop_lin
+ } else {
+ sprZoomY += _vm->_scaleValue;
+ xSource = 0;
+ ySource++;
+ }
+ }
+ // loop_lin:
+ for (int j = 0; j < _scaledFrameXSize; j++) {
+ sprZoomX -= 100;
+ if (sprZoomX >= 0) {
+ // its_all_r
+ memcpy(zoomedFrame->getBasePtr(xDest, yDest), heroFrame->getBasePtr(xSource, ySource), 1);
+ xDest++;
+ } else {
+ sprZoomX += _vm->_scaleValue;
+ j--;
+ }
+ xSource++;
+ }
+ xDest = 0;
+ yDest++;
+ xSource = 0;
+ ySource++;
+ }
+ return zoomedFrame;
+}
+
+void Hero::countDrawPosition() {
+ Animation *heroAnim = nullptr;
+ if (_specAnim != nullptr) {
+ heroAnim = _specAnim;
+ } else {
+ heroAnim = _moveSet[_moveSetType];
+ }
+ if (heroAnim != nullptr) {
+ int phaseFrameIndex = heroAnim->getPhaseFrameIndex(_phase);
+ Graphics::Surface *heroSurface = heroAnim->getFrame(phaseFrameIndex);
+
+ _frameXSize = heroSurface->w;
+ _frameYSize = heroSurface->h;
+ _scaledFrameXSize = getScaledValue(_frameXSize);
+ _scaledFrameYSize = getScaledValue(_frameYSize);
+
+ if (_vm->_scaleValue != 10000) {
+ //notfullSize
+ _drawX = _middleX - _scaledFrameXSize / 2;
+ _drawY = _middleY + 1 - _scaledFrameYSize;
+ _vm->checkMasks(_drawX, _drawY - 1, _scaledFrameXSize, _scaledFrameYSize, _middleY);
+ } else {
+ //fullSize
+ _drawX = _middleX - _frameXSize / 2;
+ _drawY = _middleY + 1 - _frameYSize;
+ _vm->checkMasks(_drawX, _drawY - 1, _frameXSize, _frameYSize, _middleY);
+ }
+ _drawZ = _middleY;
+ }
+}
+
+void Hero::showHeroShadow(Graphics::Surface *screen, DrawNode *drawNode) {
+ PrinceEngine *vm = (PrinceEngine *)drawNode->data;
+ int16 heroSurfaceWidth = drawNode->s->w;
+ int16 heroSurfaceHeight = drawNode->s->h;
+
+ Graphics::Surface *makeShadow = new Graphics::Surface();
+ makeShadow->create(heroSurfaceWidth, heroSurfaceHeight, Graphics::PixelFormat::createFormatCLUT8());
+
+ for (int y = 0; y < heroSurfaceHeight; y++) {
+ byte *src = (byte *)drawNode->s->getBasePtr(0, y);
+ byte *dst = (byte *)makeShadow->getBasePtr(0, y);
+ for (int x = 0; x < heroSurfaceWidth; x++, dst++, src++) {
+ if (*src != 0xFF) {
+ *dst = GraphicsMan::kShadowColor;
+ } else {
+ *dst = *src;
+ }
+ }
+ }
+
+ if (drawNode->posY > 1 && drawNode->posY < PrinceEngine::kMaxPicHeight) {
+ int shadDirection;
+ if (vm->_lightY > drawNode->posY) {
+ shadDirection = 1;
+ } else {
+ shadDirection = 0;
+ }
+
+ vm->_shadLineLen = 0;
+ Graphics::drawLine(vm->_lightX, vm->_lightY, drawNode->posX, drawNode->posY, 0, &vm->plotShadowLinePoint, vm);
+
+ byte *sprShadow = vm->_graph->_shadowTable70;
+
+ int shadDrawX = drawNode->posX - vm->_picWindowX;
+ int shadDrawY = drawNode->posY - vm->_picWindowY;
+
+ int shadPosX = shadDrawX;
+ int shadPosY = shadDrawY;
+ int shadBitAddr = drawNode->posY * PrinceEngine::kMaxPicWidth / 8 + drawNode->posX / 8;
+ int shadBitMask = 128 >> (drawNode->posX % 8);
+
+ int shadZoomY2 = vm->_shadScaleValue;
+ int shadZoomY = drawNode->scaleValue;
+
+ int diffX = 0;
+ int diffY = 0;
+
+ int shadowHeroX = 0;
+ int shadowHeroY = heroSurfaceHeight - 1;
+
+ int shadLastY = 0;
+
+ byte *shadowHero = (byte *)makeShadow->getBasePtr(shadowHeroX, shadowHeroY); // first pixel from last row of shadow hero
+ byte *background = (byte *)screen->getBasePtr(shadDrawX, shadDrawY); // pixel of background where shadow sprite starts
+
+ // banked2
+ byte *shadowLineStart = vm->_shadowLine + 8;
+
+ int shadWallDown = 0;
+ int shadWallBitAddr = 0;
+ int shadWallBitMask = 0;
+ byte *shadWallDestAddr = 0;
+ int shadWallPosY = 0;
+ int shadWallSkipX = 0;
+ int shadWallModulo = 0;
+
+ // linear_loop
+ for (int i = 0; i < heroSurfaceHeight; i++) {
+ int j;
+ //retry_line:
+ for (j = heroSurfaceHeight - i; j > 0; j--) {
+ shadZoomY -= 100;
+ if (shadZoomY < 0 && drawNode->scaleValue != 10000) {
+ shadZoomY += drawNode->scaleValue;
+ shadowHeroY--;
+ if (shadowHeroY < 0) {
+ break;
+ }
+ } else {
+ break;
+ }
+ }
+ if (!j) {
+ break;
+ }
+ if (shadowHeroY < 0) {
+ break;
+ }
+
+ //line_y_ok
+ if (shadLastY != shadPosY && shadPosY >= 0 && shadPosY < 480 && shadPosX < 640) {
+ shadLastY = shadPosY;
+ bool skipLineFlag = false;
+ int shadSkipX = 0;
+ int ctLoop = 0;
+ int sprModulo = 0;
+
+ if (shadPosX < 0) {
+ shadSkipX = -1 * shadPosX;
+ if (heroSurfaceWidth > shadSkipX) {
+ ctLoop = heroSurfaceWidth - shadSkipX;
+ shadowHeroX = shadSkipX;
+ } else {
+ //skip_line
+ skipLineFlag = true;
+ }
+ } else {
+ //x1_ok
+ if (shadPosX + heroSurfaceWidth > 640) {
+ ctLoop = 640 - shadPosX;
+ sprModulo = shadPosX + heroSurfaceWidth - 640;
+ } else {
+ //draw_line
+ ctLoop = heroSurfaceWidth;
+ }
+ }
+
+ if (!skipLineFlag) {
+ //draw_line1
+ //retry_line2
+ int k;
+ for (k = j; k > 0; k--) {
+ shadZoomY2 -= 100;
+ if (shadZoomY2 < 0 && vm->_shadScaleValue != 10000) {
+ shadZoomY2 += vm->_shadScaleValue;
+ shadowHeroY--;
+ if (shadowHeroY < 0) {
+ break;
+ }
+ } else {
+ break;
+ }
+ }
+ if (shadowHeroY < 0) {
+ break;
+ }
+ if (!k) {
+ break;
+ }
+ //line_y_ok_2:
+ //copy_trans
+ bool shadWDFlag = false;
+ int shadZoomX = drawNode->scaleValue;
+ int backgroundDiff = shadSkipX;
+ int shadBitMaskCopyTrans = shadBitMask;
+ int shadBitAddrCopyTrans = shadBitAddr;
+ shadowHero = (byte *)makeShadow->getBasePtr(shadowHeroX, shadowHeroY);
+ background = (byte *)screen->getBasePtr(shadDrawX + diffX + backgroundDiff, shadDrawY + diffY);
+
+ if (shadPosX < 0) {
+ if (heroSurfaceWidth > shadSkipX) {
+ shadBitAddrCopyTrans += shadSkipX / 8;
+ if ((shadSkipX % 8)) {
+ //loop_rotate:
+ for (int a = 0; a < (shadSkipX % 8); a++) {
+ if (shadBitMaskCopyTrans == 1) {
+ shadBitMaskCopyTrans = 128;
+ shadBitAddrCopyTrans++;
+ } else {
+ shadBitMaskCopyTrans >>= 1;
+ }
+ }
+ }
+ }
+ }
+
+ //ct_loop:
+ for (int l = 0; l < ctLoop; l++) {
+ shadZoomX -= 100;
+ if (shadZoomX < 0 && drawNode->scaleValue != 10000) {
+ shadZoomX += drawNode->scaleValue;
+ } else {
+ if (*shadowHero == GraphicsMan::kShadowColor) {
+ if ((shadBitMaskCopyTrans & vm->_shadowBitmap[shadBitAddrCopyTrans])) {
+ if (shadWallDown == 0) {
+ if ((shadBitMaskCopyTrans & vm->_shadowBitmap[shadBitAddrCopyTrans + PrinceEngine::kShadowBitmapSize])) {
+ shadWDFlag = true;
+ //shadow
+ *background = *(sprShadow + *background);
+ }
+ }
+ } else {
+ //shadow
+ *background = *(sprShadow + *background);
+ }
+ }
+ //ct_next
+ if (shadBitMaskCopyTrans == 1) {
+ shadBitMaskCopyTrans = 128;
+ shadBitAddrCopyTrans++;
+ } else {
+ shadBitMaskCopyTrans >>= 1;
+ }
+ //okok
+ backgroundDiff++;
+ background = (byte *)screen->getBasePtr(shadDrawX + diffX + backgroundDiff, shadDrawY + diffY);
+ }
+ shadowHeroX++;
+ shadowHero = (byte *)makeShadow->getBasePtr(shadowHeroX, shadowHeroY);
+ }
+ //byebyebye
+ if (!shadWallDown && shadWDFlag) {
+ shadWallDown = shadPosX;
+ shadWallBitAddr = shadBitAddr;
+ shadWallDestAddr = (byte *)screen->getBasePtr(shadDrawX + diffX, shadDrawY + diffY);
+ shadWallBitMask = shadBitMask;
+ shadWallPosY = shadPosY;
+ shadWallSkipX = shadSkipX;
+ shadWallModulo = sprModulo;
+ }
+ //byebye
+ if (shadDirection && shadWallDown) {
+ int shadBitMaskWallCopyTrans = shadWallBitMask;
+ int shadBitAddrWallCopyTrans = shadWallBitAddr;
+ background = shadWallDestAddr;
+ shadowHero = (byte *)makeShadow->getBasePtr(shadWallSkipX, shadowHeroY);
+
+ if (ctLoop > shadWallSkipX && ctLoop - shadWallSkipX > shadWallModulo) {
+ //WALL_copy_trans
+ shadWDFlag = false;
+ int shadZoomXWall = drawNode->scaleValue;
+ int backgroundDiffWall = 0;
+ int shadowHeroXWall = 0;
+ //ct_loop:
+ for (int m = 0; m < ctLoop; m++) {
+ shadZoomXWall -= 100;
+ if (shadZoomXWall < 0 && drawNode->scaleValue != 10000) {
+ shadZoomXWall += drawNode->scaleValue;
+ } else {
+ //point_ok:
+ if (*shadowHero == GraphicsMan::kShadowColor) {
+ if ((shadBitMaskWallCopyTrans & vm->_shadowBitmap[shadBitAddrWallCopyTrans + PrinceEngine::kShadowBitmapSize])) {
+ *background = *(sprShadow + *background);
+ }
+ }
+ //ct_next
+ if (shadBitMaskWallCopyTrans == 1) {
+ shadBitMaskWallCopyTrans = 128;
+ shadBitAddrWallCopyTrans++;
+ } else {
+ shadBitMaskWallCopyTrans >>= 1;
+ }
+ //okok
+ backgroundDiffWall++;
+ background = shadWallDestAddr + backgroundDiffWall;
+ }
+ shadowHeroXWall++;
+ shadowHero = (byte *)makeShadow->getBasePtr(shadWallSkipX + shadowHeroXWall, shadowHeroY);
+ }
+ }
+ //krap2
+ shadWallDestAddr -= PrinceEngine::kNormalWidth;
+ shadWallBitAddr -= PrinceEngine::kMaxPicWidth / 8;
+ shadWallPosY--;
+ }
+ }
+ }
+ //skip_line
+ //next_line
+ if (READ_LE_UINT16(shadowLineStart + 2) < READ_LE_UINT16(shadowLineStart - 2)) {
+ //minus_y
+ shadBitAddr -= PrinceEngine::kMaxPicWidth / 8;
+ shadPosY--;
+ diffY--;
+ } else if (READ_LE_UINT16(shadowLineStart + 2) > READ_LE_UINT16(shadowLineStart - 2)) {
+ shadBitAddr += PrinceEngine::kMaxPicWidth / 8;
+ shadPosY++;
+ diffY++;
+ }
+ //no_change_y
+ if (READ_LE_UINT16(shadowLineStart) < READ_LE_UINT16(shadowLineStart - 4)) {
+ //minus_x
+ shadPosX--;
+ //rol
+ if (shadBitMask == 128) {
+ shadBitMask = 1;
+ shadBitAddr--;
+ } else {
+ shadBitMask <<= 1;
+ }
+ diffX--;
+ } else if (READ_LE_UINT16(shadowLineStart) > READ_LE_UINT16(shadowLineStart - 4)) {
+ shadPosX++;
+ //ror
+ if (shadBitMask == 1) {
+ shadBitMask = 128;
+ shadBitAddr++;
+ } else {
+ shadBitMask >>= 1;
+ }
+ diffX++;
+ }
+ //no_change_x
+ shadowLineStart += 4;
+ shadowHeroY--;
+ if (shadowHeroY < 0) {
+ break;
+ }
+ shadowHeroX = 0;
+ background = (byte *)screen->getBasePtr(shadDrawX + diffX, shadDrawY + diffY);
+ shadowHero = (byte *)makeShadow->getBasePtr(shadowHeroX, shadowHeroY);
+ }
+ //koniec_bajki - end_of_a_story
+ }
+ makeShadow->free();
+ delete makeShadow;
+}
+
+void Hero::setScale(int8 zoomBitmapValue) {
+ if (!zoomBitmapValue) {
+ _vm->_scaleValue = 10000;
+ } else {
+ _vm->_scaleValue = 10000 / zoomBitmapValue;
+ }
+}
+
+void Hero::selectZoom() {
+ int8 zoomBitmapValue = *(_vm->_zoomBitmap + _middleY / 4 * _vm->kZoomBitmapWidth + _middleX / 4);
+ setScale(zoomBitmapValue);
+}
+
+int Hero::rotateHero(int oldDirection, int newDirection) {
+ switch (oldDirection) {
+ case kHeroDirLeft:
+ switch (newDirection) {
+ case kHeroDirRight:
+ return kMove_MLR;
+ case kHeroDirUp:
+ return kMove_MLU;
+ case kHeroDirDown:
+ return kMove_MLD;
+ }
+ break;
+ case kHeroDirRight:
+ switch (newDirection) {
+ case kHeroDirLeft:
+ return kMove_MRL;
+ case kHeroDirUp:
+ return kMove_MRU;
+ case kHeroDirDown:
+ return kMove_MRD;
+ }
+ break;
+ case kHeroDirUp:
+ switch (newDirection) {
+ case kHeroDirLeft:
+ return kMove_MUL;
+ case kHeroDirRight:
+ return kMove_MUR;
+ case kHeroDirDown:
+ return kMove_MUD;
+ }
+ break;
+ case kHeroDirDown:
+ switch (newDirection) {
+ case kHeroDirLeft:
+ return kMove_MDL;
+ case kHeroDirRight:
+ return kMove_MDR;
+ case kHeroDirUp:
+ return kMove_MDU;
+ }
+ break;
+ }
+ error("rotateHero - wrong directions - old %d, new %d", oldDirection, newDirection);
+}
+
+void Hero::heroStanding() {
+ _phase = 0;
+ switch (_lastDirection) {
+ case kHeroDirLeft:
+ _moveSetType = kMove_SL;
+ break;
+ case kHeroDirRight:
+ _moveSetType = kMove_SR;
+ break;
+ case kHeroDirUp:
+ _moveSetType = kMove_SU;
+ break;
+ case kHeroDirDown:
+ _moveSetType = kMove_SD;
+ break;
+ }
+}
+
+void Hero::showHero() {
+ if (_visible && !_vm->_flags->getFlagValue(Flags::NOHEROATALL)) {
+
+ if (_talkTime != 0) {
+ _talkTime--;
+ }
+
+ // Scale of hero
+ selectZoom();
+
+ if (_state != kHeroStateStay) {
+ _boredomTime = 0;
+ }
+
+ if (_state == kHeroStateSpec) {
+ if (_specAnim != nullptr) {
+ if (_phase < _specAnim->getPhaseCount() - 1) {
+ _phase++;
+ } else {
+ if (!_talkTime) {
+ _state = kHeroStateStay;
+ } else {
+ _state = kHeroStateTalk;
+ }
+ countDrawPosition();
+ return;
+ }
+ } else {
+ _state = kHeroStateStay;
+ }
+ } else {
+ freeHeroAnim();
+ }
+
+ if (_state == kHeroStateTalk) {
+ if (_talkTime) {
+ switch (_lastDirection) {
+ case kHeroDirLeft:
+ _moveSetType = kMove_TL;
+ break;
+ case kHeroDirRight:
+ _moveSetType = kMove_TR;
+ break;
+ case kHeroDirUp:
+ _moveSetType = kMove_TU;
+ break;
+ case kHeroDirDown:
+ _moveSetType = kMove_TD;
+ break;
+ }
+ if (_phase < _moveSet[_moveSetType]->getPhaseCount() - 1) {
+ _phase++;
+ } else {
+ _phase = _moveSet[_moveSetType]->getLoopCount();
+ }
+ } else {
+ _state = kHeroStateStay;
+ }
+ }
+
+ if (_state == kHeroStateBore) {
+ switch (_boreNum) {
+ case 0:
+ _moveSetType = kMove_BORED1;
+ break;
+ case 1:
+ _moveSetType = kMove_BORED2;
+ break;
+ }
+ if (_moveSet[_moveSetType] != nullptr) {
+ if (_phase < _moveSet[_moveSetType]->getPhaseCount() - 1) {
+ _phase++;
+ } else {
+ _phase = 0;
+ _lastDirection = kHeroDirDown;
+ _state = kHeroStateStay;
+ }
+ } else {
+ _state = kHeroStateStay;
+ }
+ }
+
+ if (_state == kHeroStateStay) {
+ if (!_vm->_optionsFlag) {
+ if (!_vm->_interpreter->getLastOPCode() || !_vm->_interpreter->getFgOpcodePC()) {
+ _boredomTime++;
+ if (_boredomTime == _maxBoredom) {
+ _boreNum =_vm->_randomSource.getRandomNumber(1); // rand one of two 'bored' animation
+ _phase = 0;
+ _state = kHeroStateBore;
+ if (_lastDirection == kHeroDirUp) {
+ _lastDirection = kHeroDirLeft;
+ } else {
+ _lastDirection = kHeroDirDown;
+ }
+ }
+ } else {
+ _boredomTime = 0;
+ }
+ } else {
+ _boredomTime = 0;
+ }
+ heroStanding();
+ }
+
+ if (_state == kHeroStateTurn) {
+ if (_destDirection && (_lastDirection != _destDirection)) {
+ _phase = 0;
+ int rotateDir = rotateHero(_lastDirection, _destDirection);
+ _lastDirection = _destDirection;
+ if (rotateDir) {
+ _moveSetType = rotateDir;
+ _state = kHeroStateTran;
+ } else {
+ _state = kHeroStateStay;
+ heroStanding();
+ }
+ } else {
+ _state = kHeroStateStay;
+ heroStanding();
+ }
+ }
+
+ if (_state == kHeroStateTran) {
+ if (_moveSet[_moveSetType] != nullptr) {
+ // only in bear form
+ if (_phase < _moveSet[_moveSetType]->getPhaseCount() - 2) {
+ _phase += 2;
+ } else {
+ _state = kHeroStateStay;
+ heroStanding();
+ }
+ } else {
+ _state = kHeroStateStay;
+ heroStanding();
+ }
+ }
+
+ if (_state == kHeroStateMvan) {
+ if (_moveSet[_moveSetType] != nullptr) {
+ // only in bear form
+ if (_phase < _moveSet[_moveSetType]->getPhaseCount() - 2) {
+ _phase += 2;
+ } else {
+ _state = kHeroStateMove;
+ }
+ } else {
+ _state = kHeroStateMove;
+ }
+ }
+
+ if (_state == kHeroStateDelayMove) {
+ _moveDelay--;
+ if (!_moveDelay) {
+ _state = kHeroStateMove;
+ }
+ }
+
+ if (_state == kHeroStateMove || _state == kHeroStateRun) {
+ //go_for_it:
+ while (1) {
+ if (_currCoords != nullptr) {
+ if (READ_LE_UINT32(_currCoords) != 0xFFFFFFFF) {
+ int x = READ_LE_UINT16(_currCoords);
+ int y = READ_LE_UINT16(_currCoords + 2);
+ _currCoords += 4;
+ int dir = *_currDirTab;
+ _currDirTab++;
+ if (_lastDirection != dir) {
+ _phase = 0;
+ int rotateDir = rotateHero(_lastDirection, dir);
+ _lastDirection = dir;
+ if (_moveSet[rotateDir] != nullptr) {
+ // only in bear form
+ _state = kHeroStateMvan;
+ _moveSetType = rotateDir;
+ if (_phase < _moveSet[_moveSetType]->getPhaseCount() - 2) {
+ _phase += 2;
+ break;
+ } else {
+ _state = kHeroStateMove;
+ continue;
+ }
+ } else {
+ continue;
+ }
+ }
+ //no_need_direction_change
+ if (dir == kHeroDirLeft) {
+ if (_middleX - x >= _step) {
+ heroMoveGotIt(x, y, dir);
+ break;
+ }
+ } else if (dir == kHeroDirRight) {
+ if (x - _middleX >= _step) {
+ heroMoveGotIt(x, y, dir);
+ break;
+ }
+ } else if (dir == kHeroDirUp) {
+ if (_middleY - y >= _step) {
+ heroMoveGotIt(x, y, dir);
+ break;
+ }
+ } else if (dir == kHeroDirDown) {
+ if (y - _middleY >= _step) {
+ heroMoveGotIt(x, y, dir);
+ break;
+ }
+ }
+ } else {
+ //finito
+ _middleX = READ_LE_UINT16(_currCoords - 4);
+ _middleY = READ_LE_UINT16(_currCoords - 2);
+ selectZoom();
+
+ if (_coords != nullptr) {
+ free(_coords);
+ _coords = nullptr;
+ _currCoords = nullptr;
+ }
+
+ if (_dirTab != nullptr) {
+ free(_dirTab);
+ _dirTab = nullptr;
+ _currDirTab = nullptr;
+ }
+
+ _boredomTime = 0;
+ _phase = 0;
+ _state = kHeroStateTurn;
+
+ if (!_destDirection) {
+ _destDirection = _lastDirection;
+ }
+
+ heroStanding();
+
+ break;
+ }
+ } else {
+ heroStanding();
+ break;
+ }
+ }
+ }
+ countDrawPosition();
+ }
+}
+
+void Hero::drawHero() {
+ if (_visible && !_vm->_flags->getFlagValue(Flags::NOHEROATALL)) {
+ freeZoomedSurface();
+ Graphics::Surface *mainHeroSurface = getSurface();
+ if (mainHeroSurface) {
+ DrawNode newDrawNode;
+ newDrawNode.posX = _drawX;
+ newDrawNode.posY = _drawY;
+ newDrawNode.posZ = _drawZ;
+ newDrawNode.width = 0;
+ newDrawNode.height = 0;
+ newDrawNode.originalRoomSurface = nullptr;
+ newDrawNode.data = _vm->_transTable;
+ newDrawNode.drawFunction = &_graph->drawTransparentWithTransDrawNode;
+
+ if (_vm->_scaleValue != 10000) {
+ _zoomedHeroSurface = zoomSprite(mainHeroSurface);
+ newDrawNode.s = _zoomedHeroSurface;
+ } else {
+ newDrawNode.s = mainHeroSurface;
+ }
+ _vm->_drawNodeList.push_back(newDrawNode);
+
+ drawHeroShadow(mainHeroSurface);
+
+ }
+ }
+}
+
+void Hero::drawHeroShadow(Graphics::Surface *heroFrame) {
+ DrawNode newDrawNode;
+ newDrawNode.posX = _middleX - _scaledFrameXSize / 2;
+ newDrawNode.posY = _middleY - _shadMinus - 1;
+ newDrawNode.posZ = kHeroShadowZ;
+ newDrawNode.width = 0;
+ newDrawNode.height = 0;
+ newDrawNode.scaleValue = _vm->_scaleValue;
+ newDrawNode.originalRoomSurface = nullptr;
+ newDrawNode.data = _vm;
+ newDrawNode.drawFunction = &showHeroShadow;
+ newDrawNode.s = heroFrame;
+ _vm->_drawNodeList.push_back(newDrawNode);
+}
+
+void Hero::heroMoveGotIt(int x, int y, int dir) {
+ _middleX = x;
+ _middleY = y;
+ selectZoom();
+
+ switch (dir) {
+ case kHeroDirLeft:
+ _moveSetType = kMove_ML;
+ break;
+ case kHeroDirRight:
+ _moveSetType = kMove_MR;
+ break;
+ case kHeroDirUp:
+ _moveSetType = kMove_MU;
+ break;
+ case kHeroDirDown:
+ _moveSetType = kMove_MD;
+ break;
+ }
+
+ if (_vm->_flags->getFlagValue(Flags::HEROFAST) || _state == kHeroStateRun) {
+ if (_phase < _moveSet[_moveSetType]->getPhaseCount() - 2) {
+ _phase += 2;
+ } else {
+ _phase = 0;
+ }
+ } else {
+ if (_phase < _moveSet[_moveSetType]->getPhaseCount() - 1) {
+ _phase++;
+ } else {
+ _phase = 0;
+ }
+ }
+
+ _step = kStepLeftRight;
+ if (_moveSetType == kMove_MU || _moveSetType == kMove_MD) {
+ _step = kStepUpDown;
+ }
+ if (_vm->_flags->getFlagValue(Flags::HEROFAST)) {
+ _step *= 2.5;
+ } else if (_state == kHeroStateRun) {
+ _step *= 2;
+ }
+}
+
+void Hero::scrollHero() {
+ int scrollType = _vm->_flags->getFlagValue(Flags::SCROLLTYPE);
+ int position = _middleX;
+ int scrollValue, scrollValue2;
+
+ switch (scrollType) {
+ case 0:
+ position = _middleX;
+ break;
+ case 1:
+ scrollValue = _vm->_flags->getFlagValue(Flags::SCROLLVALUE);
+ position = _vm->_normAnimList[scrollValue]._currX + _vm->_normAnimList[scrollValue]._currW / 2;
+ break;
+ case 2:
+ scrollValue = _vm->_flags->getFlagValue(Flags::SCROLLVALUE);
+ scrollValue2 = _vm->_flags->getFlagValue(Flags::SCROLLVALUE2);
+ position = scrollValue;
+ if (scrollValue < scrollValue2) {
+ _vm->_flags->setFlagValue(Flags::SCROLLVALUE, 0);
+ } else {
+ _vm->_flags->setFlagValue(Flags::SCROLLVALUE, scrollValue - scrollValue2);
+ }
+ break;
+ }
+
+ int locationWidth = _vm->_sceneWidth;
+ int difference = locationWidth - _vm->kNormalWidth / 2;
+
+ int destValue = 0;
+ if (position > _vm->kNormalWidth / 2) {
+ destValue = difference - _vm->kNormalWidth / 2;
+ }
+ if (position < difference) {
+ destValue = position - _vm->kNormalWidth / 2;
+ }
+
+ if(destValue < 0) {
+ destValue = 0;
+ }
+ _vm->_picWindowX = destValue;
+ _drawX -= destValue;
+}
+
+void Hero::freeOldMove() {
+ if (_coords != nullptr) {
+ free(_coords);
+ _coords = nullptr;
+ }
+ if (_dirTab != nullptr) {
+ free(_dirTab);
+ _dirTab = nullptr;
+ }
+ _step = 0;
+ _phase = 0;
+ _moveDelay = 0;
+ _state = Hero::kHeroStateStay;
+}
+
+void Hero::freeHeroAnim() {
+ if (_specAnim != nullptr) {
+ delete _specAnim;
+ _specAnim = nullptr;
+ }
+}
+
+void Hero::freeZoomedSurface() {
+ if (_zoomedHeroSurface != nullptr) {
+ _zoomedHeroSurface->free();
+ delete _zoomedHeroSurface;
+ _zoomedHeroSurface = nullptr;
+ }
+}
+
+} // End of namespace Prince
diff --git a/engines/prince/hero.h b/engines/prince/hero.h
new file mode 100644
index 0000000000..703ef0650d
--- /dev/null
+++ b/engines/prince/hero.h
@@ -0,0 +1,184 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public 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 PRINCE_HERO_H
+#define PRINCE_HERO_H
+
+#include "common/scummsys.h"
+#include "common/array.h"
+#include "common/memstream.h"
+
+#include "graphics/surface.h"
+#include "graphics/primitives.h"
+
+namespace Prince {
+
+class Animation;
+class PrinceEngine;
+class GraphicsMan;
+struct InventoryItem;
+struct DrawNode;
+
+class Hero {
+public:
+ static const uint32 kMoveSetSize = 26;
+ static const int16 kStepLeftRight = 8;
+ static const int16 kStepUpDown = 4;
+ static const int16 kHeroShadowZ = 2;
+
+ enum State {
+ kHeroStateStay,
+ kHeroStateTurn,
+ kHeroStateMove,
+ kHeroStateBore,
+ kHeroStateSpec,
+ kHeroStateTalk,
+ kHeroStateMvan,
+ kHeroStateTran,
+ kHeroStateRun,
+ kHeroStateDelayMove
+ };
+
+ enum Direction {
+ kHeroDirLeft = 1,
+ kHeroDirRight = 2,
+ kHeroDirUp = 3,
+ kHeroDirDown = 4
+ };
+
+ enum MoveSet {
+ kMove_SL,
+ kMove_SR,
+ kMove_SU,
+ kMove_SD,
+ kMove_ML,
+ kMove_MR,
+ kMove_MU,
+ kMove_MD,
+ kMove_TL,
+ kMove_TR,
+ kMove_TU,
+ kMove_TD,
+ kMove_MLU,
+ kMove_MLD,
+ kMove_MLR,
+ kMove_MRU,
+ kMove_MRD,
+ kMove_MRL,
+ kMove_MUL,
+ kMove_MUR,
+ kMove_MUD,
+ kMove_MDL,
+ kMove_MDR,
+ kMove_MDU,
+ kMove_BORED1,
+ kMove_BORED2
+ };
+
+ // Used instead of offset in getData
+ enum AttrId {
+ kHeroLastDir = 26,
+ kHeroAnimSet = 120
+ };
+
+ uint16 getData(AttrId dataId);
+
+ Hero(PrinceEngine *vm, GraphicsMan *graph);
+ ~Hero();
+ bool loadAnimSet(uint32 heroAnimNumber);
+
+ Graphics::Surface *getSurface();
+
+ void setPos(int16 x, int16 y) { _middleX = x; _middleY = y; }
+ void setVisible(bool flag) { _visible = flag; }
+
+ void showHero();
+ void drawHero();
+ void freeZoomedSurface();
+ void heroStanding();
+ void heroMoveGotIt(int x, int y, int dir);
+ int rotateHero(int oldDirection, int newDirection);
+ void scrollHero();
+ void setScale(int8 zoomBitmapValue);
+ int getScaledValue(int size);
+ void selectZoom();
+ void countDrawPosition();
+ Graphics::Surface *zoomSprite(Graphics::Surface *heroFrame);
+ void line(int x1, int y1, int x2, int y2);
+ void plotPoint(int x, int y);
+ static void showHeroShadow(Graphics::Surface *screen, DrawNode *drawNode);
+ void drawHeroShadow(Graphics::Surface *heroFrame);
+ void freeOldMove();
+ void freeHeroAnim();
+
+ uint16 _number;
+ uint16 _visible;
+ int16 _state;
+ int16 _middleX; // middle of X
+ int16 _middleY; // lower part of hero
+ int16 _moveSetType;
+
+ int16 _frameXSize;
+ int16 _frameYSize;
+ int16 _scaledFrameXSize;
+ int16 _scaledFrameYSize;
+ int16 _drawX;
+ int16 _drawY;
+ int16 _drawZ;
+
+ byte *_coords; // array of coordinates
+ byte *_dirTab; // array of directions
+ byte *_currCoords; // current coordinations
+ byte *_currDirTab; // current direction
+ int16 _lastDirection; // previous move direction
+ int16 _destDirection;
+ int16 _leftRightMainDir; // left or right - dominant direction
+ int16 _upDownMainDir; // up or down - dominant direction
+ int32 _phase; // Phase animation phase
+ int16 _step; // Step x/y step size depends on direction
+ int16 _maxBoredom; // stand still timeout
+ int16 _boredomTime; // Boredom current boredom time in frames
+ uint16 _boreNum; // Bore anim frame
+ int16 _talkTime; // TalkTime time of talk anim
+ Animation *_specAnim; // additional anim
+ Graphics::Surface *_zoomedHeroSurface;
+
+ uint16 _currHeight; // height of current anim phase
+
+ Common::Array<byte> _inventory; // Inventory array of items
+ Common::Array<byte> _inventory2; // Inventory2 array of items
+ // Font subtitiles font
+ int _color; // subtitles color
+ uint32 _animSetNr; // number of animation set
+ Common::Array<Animation *> _moveSet; // MoveAnims MoveSet
+
+ uint32 _moveDelay;
+ uint32 _shadMinus;
+
+private:
+ PrinceEngine *_vm;
+ GraphicsMan *_graph;
+};
+
+} // End of namespace Prince
+
+#endif
diff --git a/engines/prince/hero_set.h b/engines/prince/hero_set.h
new file mode 100644
index 0000000000..dfe7e50268
--- /dev/null
+++ b/engines/prince/hero_set.h
@@ -0,0 +1,244 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public 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"
+
+namespace Prince {
+
+const int heroSetBack[7] = { 0, 0, 10, 0, 6, 0, 0 };
+
+typedef const char *HeroSetAnimNames[26];
+
+static HeroSetAnimNames heroSet5 = {
+ "SL_DIAB.ANI",
+ "SR_DIAB.ANI",
+ "SU_DIAB.ANI",
+ "SD_DIAB.ANI",
+ nullptr,
+ nullptr,
+ "MU_DIAB.ANI",
+ "MD_DIAB.ANI",
+ "TL_DIAB.ANI",
+ "TR_DIAB.ANI",
+ "TU_DIAB.ANI",
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr
+};
+
+static HeroSetAnimNames heroSet1 = {
+ "SL_HERO1.ANI",
+ "SR_HERO1.ANI",
+ "SU_HERO1.ANI",
+ "SD_HERO1.ANI",
+ "ML_HERO1.ANI",
+ "MR_HERO1.ANI",
+ "MU_HERO1.ANI",
+ "MD_HERO1.ANI",
+ "TL_HERO1.ANI",
+ "TR_HERO1.ANI",
+ "TU_HERO1.ANI",
+ "TD_HERO1.ANI",
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ "KSI_KURZ.ANI",
+ "KS_WLOSY.ANI"
+};
+
+static HeroSetAnimNames heroSet2 = {
+ "SL_HERO2.ANI",
+ "SR_HERO2.ANI",
+ "SU_HERO2.ANI",
+ "SD_HERO2.ANI",
+ "ML_HERO2.ANI",
+ "MR_HERO2.ANI",
+ "MU_HERO2.ANI",
+ "MD_HERO2.ANI",
+ "TL_HERO2.ANI",
+ "TR_HERO2.ANI",
+ "TU_HERO2.ANI",
+ "TD_HERO2.ANI",
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ "KSI_KU_S.ANI",
+ "KS_WLO_S.ANI"
+};
+
+static HeroSetAnimNames heroSet3 = {
+ "SL_BEAR.ANI",
+ "SR_BEAR.ANI",
+ "SU_BEAR.ANI",
+ "SD_BEAR.ANI",
+ "NIED-LEW.ANI",
+ "NIED-PRW.ANI",
+ "NIED-TYL.ANI",
+ "NIED-PRZ.ANI",
+ "SL_BEAR.ANI",
+ "SR_BEAR.ANI",
+ "SU_BEAR.ANI",
+ "SD_BEAR.ANI",
+ "N_LW-TYL.ANI",
+ "N_LW-PRZ.ANI",
+ "N_LW-PR.ANI",
+ "N_PR-TYL.ANI",
+ "N_PR-PRZ.ANI",
+ "N_PR-LW.ANI",
+ "N_TYL-LW.ANI",
+ "N_TYL-PR.ANI",
+ "N_TL-PRZ.ANI",
+ "N_PRZ-LW.ANI",
+ "N_PRZ-PR.ANI",
+ "N_PRZ-TL.ANI",
+ nullptr,
+ nullptr,
+};
+
+static HeroSetAnimNames shanSet1 = {
+ "SL_SHAN.ANI",
+ "SR_SHAN.ANI",
+ "SU_SHAN.ANI",
+ "SD_SHAN.ANI",
+ "ML_SHAN.ANI",
+ "MR_SHAN.ANI",
+ "MU_SHAN.ANI",
+ "MD_SHAN.ANI",
+ "TL_SHAN.ANI",
+ "TR_SHAN.ANI",
+ "TU_SHAN.ANI",
+ "TD_SHAN.ANI",
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ "B1_SHAN.ANI",
+ "B2_SHAN.ANI",
+};
+
+static HeroSetAnimNames shanSet2 = {
+ "SL_SHAN2.ANI",
+ "SR_SHAN2.ANI",
+ "SU_SHAN.ANI",
+ "SD_SHAN2.ANI",
+ "ML_SHAN2.ANI",
+ "MR_SHAN2.ANI",
+ "MU_SHAN.ANI",
+ "MD_SHAN2.ANI",
+ "TL_SHAN2.ANI",
+ "TR_SHAN2.ANI",
+ "TU_SHAN.ANI",
+ "TD_SHAN2.ANI",
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ "B1_SHAN2.ANI",
+ "B2_SHAN2.ANI"
+};
+
+static HeroSetAnimNames arivSet1 = {
+ "SL_ARIV.ANI",
+ "SR_ARIV.ANI",
+ "SU_ARIV.ANI",
+ "SD_ARIV.ANI",
+ "ML_ARIV.ANI",
+ "MR_ARIV.ANI",
+ "MU_ARIV.ANI",
+ "MD_ARIV.ANI",
+ "TL_ARIV.ANI",
+ "TR_ARIV.ANI",
+ "TU_ARIV.ANI",
+ "TD_ARIV.ANI",
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr
+};
+
+const HeroSetAnimNames *heroSetTable[7] = {
+ &heroSet1,
+ &heroSet2,
+ &heroSet3,
+ &shanSet1,
+ &arivSet1,
+ &heroSet5,
+ &shanSet2,
+};
+
+} // End of namespace Prince
diff --git a/engines/prince/mhwanh.cpp b/engines/prince/mhwanh.cpp
new file mode 100644
index 0000000000..608ccc23d7
--- /dev/null
+++ b/engines/prince/mhwanh.cpp
@@ -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.
+ *
+ */
+
+#include "common/stream.h"
+
+#include "graphics/surface.h"
+
+#include "prince/mhwanh.h"
+
+namespace Prince {
+
+MhwanhDecoder::MhwanhDecoder() : _surface(nullptr), _palette(nullptr) {
+}
+
+MhwanhDecoder::~MhwanhDecoder() {
+ destroy();
+}
+
+void MhwanhDecoder::destroy() {
+ if (_surface != nullptr) {
+ _surface->free();
+ delete _surface;
+ _surface = nullptr;
+ }
+ if (_palette != nullptr) {
+ free(_palette);
+ _palette = nullptr;
+ }
+}
+
+bool MhwanhDecoder::loadStream(Common::SeekableReadStream &stream) {
+ destroy();
+ stream.seek(0);
+ stream.skip(0x20);
+ // Read the palette
+ _palette = (byte *)malloc(kPaletteColorCount * 3);
+ for (uint16 i = 0; i < kPaletteColorCount; i++) {
+ _palette[i * 3] = stream.readByte();
+ _palette[i * 3 + 1] = stream.readByte();
+ _palette[i * 3 + 2] = stream.readByte();
+ }
+
+ _surface = new Graphics::Surface();
+ _surface->create(640, 480, Graphics::PixelFormat::createFormatCLUT8());
+ for (int h = 0; h < 480; h++) {
+ stream.read(_surface->getBasePtr(0, h), 640);
+ }
+
+ return true;
+}
+
+} // End of namespace Prince
diff --git a/engines/prince/mhwanh.h b/engines/prince/mhwanh.h
new file mode 100644
index 0000000000..f8165a7666
--- /dev/null
+++ b/engines/prince/mhwanh.h
@@ -0,0 +1,55 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef PRINCE_MHWANH_H
+#define PRINCE_MHWANH_H
+
+#include "image/image_decoder.h"
+#include "image/bmp.h"
+
+#include "graphics/surface.h"
+
+#include "resource.h"
+
+namespace Prince {
+
+class MhwanhDecoder : public Image::ImageDecoder {
+public:
+ MhwanhDecoder();
+ virtual ~MhwanhDecoder();
+
+ // ImageDecoder API
+ void destroy();
+ virtual bool loadStream(Common::SeekableReadStream &stream);
+ virtual Graphics::Surface *getSurface() const { return _surface; }
+ virtual const byte *getPalette() const { return _palette; }
+ uint16 getPaletteCount() const { return kPaletteColorCount; }
+ static const uint16 kPaletteColorCount = 256;
+
+private:
+ Graphics::Surface *_surface;
+ byte *_palette;
+};
+
+} // End of namespace Prince
+
+#endif
diff --git a/engines/prince/mob.cpp b/engines/prince/mob.cpp
new file mode 100644
index 0000000000..de825ef8b2
--- /dev/null
+++ b/engines/prince/mob.cpp
@@ -0,0 +1,108 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "prince/mob.h"
+
+namespace Prince {
+
+bool Mob::loadFromStream(Common::SeekableReadStream &stream) {
+ int32 pos = stream.pos();
+
+ uint16 visible = stream.readUint16LE();
+
+ if (visible == 0xFFFF)
+ return false;
+
+ _visible = visible;
+ _type = stream.readUint16LE();
+ _rect.left = stream.readUint16LE();
+ _rect.top = stream.readUint16LE();
+ _rect.right = stream.readUint16LE();
+ _rect.bottom = stream.readUint16LE();
+
+ _mask = stream.readUint16LE();
+
+ _examPosition.x = stream.readUint16LE();
+ _examPosition.y = stream.readUint16LE();
+ _examDirection = (Direction)stream.readUint16LE();
+
+ _usePosition.x = stream.readByte();
+ _usePosition.y = stream.readByte();
+ _useDirection = (Direction)stream.readUint16LE();
+
+ uint32 nameOffset = stream.readUint32LE();
+ uint32 examTextOffset = stream.readUint32LE();
+
+ byte c;
+ stream.seek(nameOffset);
+ _name.clear();
+ while ((c = stream.readByte()))
+ _name += c;
+
+ stream.seek(examTextOffset);
+ _examText.clear();
+ c = stream.readByte();
+ if (c) {
+ _examText += c;
+ do {
+ c = stream.readByte();
+ _examText += c;
+ } while (c != 255);
+ }
+ stream.seek(pos + 32);
+
+ return true;
+}
+
+void Mob::setData(AttrId dataId, uint16 value) {
+ switch (dataId) {
+ case kMobExamDir:
+ _examDirection = (Direction)value;
+ break;
+ case kMobExamX:
+ _examPosition.x = value;
+ break;
+ case kMobExamY:
+ _examPosition.y = value;
+ break;
+ default:
+ assert(false);
+ }
+}
+
+uint16 Mob::getData(AttrId dataId) {
+ switch (dataId) {
+ case kMobVisible:
+ return _visible;
+ case kMobExamDir:
+ return _examDirection;
+ case kMobExamX:
+ return _examPosition.x;
+ case kMobExamY:
+ return _examPosition.y;
+ default:
+ assert(false);
+ return 0;
+ }
+}
+
+} // End of namespace Prince
diff --git a/engines/prince/mob.h b/engines/prince/mob.h
new file mode 100644
index 0000000000..0ea610dd8f
--- /dev/null
+++ b/engines/prince/mob.h
@@ -0,0 +1,70 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public 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 PRINCE_MOB_H
+#define PRINCE_MOB_H
+
+#include "common/scummsys.h"
+#include "common/rect.h"
+#include "common/str.h"
+#include "common/stream.h"
+
+#include "prince/common.h"
+
+namespace Prince {
+
+class Mob {
+public:
+
+ Mob() : _name(""), _examText("") {}
+
+ bool loadFromStream(Common::SeekableReadStream &stream);
+
+ // Used instead of offset in setData and getData
+ enum AttrId {
+ kMobVisible = 0,
+ kMobExamX = 14,
+ kMobExamY = 16,
+ kMobExamDir = 18
+ };
+
+ void setData(AttrId dataId, uint16 value);
+ uint16 getData(AttrId dataId);
+
+ bool _visible;
+ uint16 _type;
+ uint16 _mask;
+ Common::Rect _rect;
+
+ Common::Point _examPosition;
+ Direction _examDirection;
+
+ Common::Point _usePosition;
+ Direction _useDirection;
+
+ Common::String _name;
+ Common::String _examText;
+};
+
+} // End of namespace Prince
+
+#endif
diff --git a/engines/prince/module.mk b/engines/prince/module.mk
new file mode 100644
index 0000000000..b1be123d4b
--- /dev/null
+++ b/engines/prince/module.mk
@@ -0,0 +1,30 @@
+MODULE := engines/prince
+
+MODULE_OBJS = \
+ animation.o \
+ archive.o \
+ cursor.o \
+ debugger.o \
+ decompress.o \
+ detection.o \
+ flags.o \
+ font.o \
+ graphics.o \
+ hero.o \
+ mhwanh.o \
+ mob.o \
+ object.o \
+ prince.o \
+ pscr.o \
+ saveload.o \
+ script.o \
+ sound.o \
+ variatxt.o
+
+# This module can be built as a plugin
+ifeq ($(ENABLE_PRINCE), DYNAMIC_PLUGIN)
+PLUGIN := 1
+endif
+
+# Include common rules
+include $(srcdir)/rules.mk
diff --git a/engines/prince/musNum.h b/engines/prince/musNum.h
new file mode 100644
index 0000000000..c24cba6ad7
--- /dev/null
+++ b/engines/prince/musNum.h
@@ -0,0 +1,87 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public 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 Prince {
+
+enum RoomMus {
+ ROOM01MUS = 3,
+ ROOM02MUS = 9,
+ ROOM03MUS = 9,
+ ROOM04MUS = 9,
+ ROOM05MUS = 13,
+ ROOM06MUS = 9,
+ ROOM07MUS = 9,
+ ROOM08MUS = 9,
+ ROOM09MUS = 14,
+ ROOM10MUS = 9,
+ ROOM11MUS = 9,
+ ROOM12MUS = 9,
+ ROOM13MUS = 9,
+ ROOM14MUS = 9,
+ ROOM15MUS = 5,
+ ROOM16MUS = 5,
+ ROOM17MUS = 5,
+ ROOM18MUS = 5,
+ ROOM19MUS = 5,
+ ROOM20MUS = 12,
+ ROOM21MUS = 9,
+ ROOM22MUS = 9,
+ ROOM23MUS = 1,
+ ROOM24MUS = 1,
+ ROOM25MUS = 2,
+ ROOM26MUS = 10,
+ ROOM27MUS = 7,
+ ROOM28MUS = 10,
+ ROOM29MUS = 10,
+ ROOM30MUS = 11,
+ ROOM31MUS = 14,
+ ROOM32MUS = 11,
+ ROOM33MUS = 7,
+ ROOM34MUS = 7,
+ ROOM35MUS = 7,
+ ROOM36MUS = 7,
+ ROOM37MUS = 7,
+ ROOM38MUS = 7,
+ ROOM39MUS = 7,
+ ROOM40MUS = 7,
+ ROOM41MUS = 7,
+ ROOM42MUS = 7,
+ ROOM43MUS = 15,
+ ROOM46MUS = 100,
+ ROOM47MUS = 100,
+ ROOM48MUS = 100,
+ ROOM49MUS = 100,
+ ROOM50MUS = 100,
+ ROOM51MUS = 12,
+ ROOM52MUS = 9,
+ ROOM53MUS = 5,
+ ROOM54MUS = 11,
+ ROOM55MUS = 11,
+ ROOM56MUS = 11,
+ ROOM57MUS = 7,
+ ROOM58MUS = 13,
+ ROOM59MUS = 16,
+ ROOM60MUS = 4,
+ ROOM61MUS = 0
+};
+
+} // End of namespace Prince
diff --git a/engines/prince/object.cpp b/engines/prince/object.cpp
new file mode 100644
index 0000000000..2dc5da68e7
--- /dev/null
+++ b/engines/prince/object.cpp
@@ -0,0 +1,113 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public 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/archive.h"
+#include "common/debug-channels.h"
+#include "common/debug.h"
+#include "common/stream.h"
+
+#include "graphics/surface.h"
+
+#include "prince/object.h"
+
+namespace Prince {
+
+Object::Object() : _surface(nullptr), _x(0), _y(0), _z(0), _flags(0), _width(0),
+ _height(0), _zoomTime(0), _zoomSurface(nullptr)
+{
+}
+
+Object::~Object() {
+ if (_surface != nullptr) {
+ _surface->free();
+ delete _surface;
+ _surface = nullptr;
+ }
+ if (_zoomSurface != nullptr) {
+ _zoomSurface->free();
+ delete _zoomSurface;
+ _zoomSurface = nullptr;
+ }
+}
+
+void Object::loadSurface(Common::SeekableReadStream &stream) {
+ stream.skip(4);
+ _width = stream.readUint16LE();
+ _height = stream.readUint16LE();
+ _surface = new Graphics::Surface();
+ _surface->create(_width, _height, Graphics::PixelFormat::createFormatCLUT8());
+
+ for (int h = 0; h < _surface->h; h++) {
+ stream.read(_surface->getBasePtr(0, h), _surface->w);
+ }
+}
+
+bool Object::loadFromStream(Common::SeekableReadStream &stream) {
+ int32 pos = stream.pos();
+ uint16 x = stream.readUint16LE();
+ if (x == 0xFFFF) {
+ return false;
+ }
+ _x = x;
+ _y = stream.readSint16LE(); // skull mini-game has some signed y coords
+
+ const Common::String obStreamName = Common::String::format("OB%02d", stream.readUint16LE());
+ Common::SeekableReadStream *obStream = SearchMan.createReadStreamForMember(obStreamName);
+ if (obStream) {
+ loadSurface(*obStream);
+ }
+ delete obStream;
+
+ _flags = stream.readUint16LE();
+ _z = stream.readUint16LE();
+
+ stream.seek(pos + 16);
+
+ return true;
+}
+
+void Object::setData(AttrId dataId, int32 value) {
+ switch (dataId) {
+ case kObjectX:
+ _x = value;
+ break;
+ case kObjectY:
+ _y = value;
+ break;
+ default:
+ assert(false);
+ }
+}
+
+int32 Object::getData(AttrId dataId) {
+ switch (dataId) {
+ case kObjectX:
+ return _x;
+ case kObjectY:
+ return _y;
+ default:
+ assert(false);
+ return 0;
+ }
+}
+
+} // End of namespace Prince
diff --git a/engines/prince/object.h b/engines/prince/object.h
new file mode 100644
index 0000000000..ff22a05805
--- /dev/null
+++ b/engines/prince/object.h
@@ -0,0 +1,70 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public 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 PRINCE_OBJECT_H
+#define PRINCE_OBJECT_H
+
+#include "image/image_decoder.h"
+#include "graphics/surface.h"
+
+namespace Prince {
+
+class Object {
+public:
+ Object();
+ ~Object();
+
+ int32 _x;
+ int32 _y;
+ int32 _z;
+ uint16 _width;
+ uint16 _height;
+ int32 _flags;
+ int32 _zoomTime;
+ Graphics::Surface *_zoomSurface;
+
+ // Used instead of offset in setData and getData
+ enum AttrId {
+ kObjectAddr = 0,
+ kObjectX = 4,
+ kObjectY = 6,
+ kObjectZ = 8,
+ kObjectFlags = 10,
+ kObjectZoomInSource = 12,
+ kObjectZoomInLen = 16,
+ kObjectZoomInAddr = 20,
+ kObjectZoomInTime = 24
+ };
+
+ bool loadFromStream(Common::SeekableReadStream &stream);
+ Graphics::Surface *getSurface() const { return _surface; }
+ int32 getData(AttrId dataId);
+ void setData(AttrId dataId, int32 value);
+
+private:
+ void loadSurface(Common::SeekableReadStream &stream);
+ Graphics::Surface *_surface;
+};
+
+} // End of namespace Prince
+
+#endif
diff --git a/engines/prince/option_text.h b/engines/prince/option_text.h
new file mode 100644
index 0000000000..d4d214c98c
--- /dev/null
+++ b/engines/prince/option_text.h
@@ -0,0 +1,85 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+namespace Prince {
+
+// PL - Mazovia coding
+const char invOptionsTextPL[5][18] = {
+ "Obejrzyj",
+ "U\xa7""yj",
+ "Otw\xa2""rz/Pchnij",
+ "Zamknij/Poci\x86""gnij",
+ "Daj"
+};
+
+const char optionsTextPL[7][18] = {
+ "Podejd\xa6",
+ "Obejrzyj",
+ "Zabierz",
+ "U\xa7""yj",
+ "Otw\xa2""rz/Pchnij",
+ "Zamknij/Poci\x86""gnij",
+ "Porozmawiaj"
+};
+
+// DE - Other font then for PL + ISO 8859-2 or Windows-1250
+// + special letter values changing
+// Normal value: 196, 214, 220, 223, 228, 246, 252
+// Prince change: 131, 132, 133, 127, 128, 129, 130
+char invOptionsTextDE[5][17] = {
+ "Anschauen",
+ "Benutzen",
+ "\x84""ffnen/Sto\x7f""en",
+ "Schlie\x7f""en/Ziehen",
+ "Geben"
+};
+
+const char optionsTextDE[7][17] = {
+ "Hingehen",
+ "Anschauen",
+ "Wegnehmen",
+ "Benutzen",
+ "\x84""ffnen/Sto\x7f""en",
+ "Schlie\x7f""en/Ziehen",
+ "Ansprechen"
+};
+
+// EN
+const char *invOptionsTextEN[] = {
+ "Examine",
+ "Use",
+ "Open/Push",
+ "Close/Pull",
+ "Give"
+};
+
+const char *optionsTextEN[] = {
+ "Walk to",
+ "Examine",
+ "Pick up",
+ "Use",
+ "Open/Push",
+ "Close/Pull",
+ "Talk to"
+};
+
+} // End of namespace Prince
diff --git a/engines/prince/prince.cpp b/engines/prince/prince.cpp
new file mode 100644
index 0000000000..55f12a6560
--- /dev/null
+++ b/engines/prince/prince.cpp
@@ -0,0 +1,4846 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public 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/debug.h"
+#include "common/events.h"
+#include "common/file.h"
+#include "common/random.h"
+#include "common/fs.h"
+#include "common/keyboard.h"
+#include "common/substream.h"
+#include "common/str.h"
+
+#include "graphics/cursorman.h"
+#include "graphics/surface.h"
+#include "graphics/palette.h"
+#include "graphics/pixelformat.h"
+
+#include "engines/util.h"
+#include "engines/advancedDetector.h"
+
+#include "audio/audiostream.h"
+
+#include "prince/prince.h"
+#include "prince/font.h"
+#include "prince/graphics.h"
+#include "prince/script.h"
+#include "prince/debugger.h"
+#include "prince/object.h"
+#include "prince/mob.h"
+#include "prince/sound.h"
+#include "prince/variatxt.h"
+#include "prince/flags.h"
+#include "prince/font.h"
+#include "prince/mhwanh.h"
+#include "prince/cursor.h"
+#include "prince/archive.h"
+#include "prince/hero.h"
+#include "prince/resource.h"
+#include "prince/animation.h"
+#include "prince/option_text.h"
+#include "prince/curve_values.h"
+#include "prince/detection.h"
+
+namespace Prince {
+
+void PrinceEngine::debugEngine(const char *s, ...) {
+ char buf[STRINGBUFLEN];
+ va_list va;
+
+ va_start(va, s);
+ vsnprintf(buf, STRINGBUFLEN, s, va);
+ va_end(va);
+
+ debug("Prince::Engine %s", buf);
+}
+
+PrinceEngine::PrinceEngine(OSystem *syst, const PrinceGameDescription *gameDesc) :
+ Engine(syst), _gameDescription(gameDesc), _graph(nullptr), _script(nullptr), _interpreter(nullptr), _flags(nullptr),
+ _locationNr(0), _debugger(nullptr), _midiPlayer(nullptr), _room(nullptr),
+ _cursor1(nullptr), _cursor2(nullptr), _cursor3(nullptr), _font(nullptr),
+ _suitcaseBmp(nullptr), _roomBmp(nullptr), _cursorNr(0), _picWindowX(0), _picWindowY(0), _randomSource("prince"),
+ _invLineX(134), _invLineY(176), _invLine(5), _invLines(3), _invLineW(70), _invLineH(76), _maxInvW(72), _maxInvH(76),
+ _invLineSkipX(2), _invLineSkipY(3), _showInventoryFlag(false), _inventoryBackgroundRemember(false),
+ _mst_shadow(0), _mst_shadow2(0), _candleCounter(0), _invX1(53), _invY1(18), _invWidth(536), _invHeight(438),
+ _invCurInside(false), _optionsFlag(false), _optionEnabled(0), _invExamY(120), _invMaxCount(2), _invCounter(0),
+ _optionsMob(-1), _currentPointerNumber(1), _selectedMob(-1), _selectedItem(0), _selectedMode(0),
+ _optionsWidth(210), _optionsHeight(170), _invOptionsWidth(210), _invOptionsHeight(130), _optionsStep(20),
+ _invOptionsStep(20), _optionsNumber(7), _invOptionsNumber(5), _optionsColor1(236), _optionsColor2(252),
+ _dialogWidth(600), _dialogHeight(0), _dialogLineSpace(10), _dialogColor1(220), _dialogColor2(223),
+ _dialogFlag(false), _dialogLines(0), _dialogText(nullptr), _mouseFlag(1),
+ _roomPathBitmap(nullptr), _roomPathBitmapTemp(nullptr), _coordsBufEnd(nullptr), _coordsBuf(nullptr), _coords(nullptr),
+ _traceLineLen(0), _rembBitmapTemp(nullptr), _rembBitmap(nullptr), _rembMask(0), _rembX(0), _rembY(0), _fpX(0), _fpY(0),
+ _checkBitmapTemp(nullptr), _checkBitmap(nullptr), _checkMask(0), _checkX(0), _checkY(0), _traceLineFirstPointFlag(false),
+ _tracePointFirstPointFlag(false), _coordsBuf2(nullptr), _coords2(nullptr), _coordsBuf3(nullptr), _coords3(nullptr),
+ _shanLen(0), _directionTable(nullptr), _currentMidi(0), _lightX(0), _lightY(0), _curveData(nullptr), _curvPos(0),
+ _creditsData(nullptr), _creditsDataSize(0), _currentTime(0), _zoomBitmap(nullptr), _shadowBitmap(nullptr), _transTable(nullptr),
+ _flcFrameSurface(nullptr), _shadScaleValue(0), _shadLineLen(0), _scaleValue(0), _dialogImage(nullptr), _mobTranslationData(nullptr),
+ _mobTranslationSize(0) {
+
+ // Debug/console setup
+ DebugMan.addDebugChannel(DebugChannel::kScript, "script", "Prince Script debug channel");
+ DebugMan.addDebugChannel(DebugChannel::kEngine, "engine", "Prince Engine debug channel");
+
+ DebugMan.enableDebugChannel("script");
+
+ memset(_audioStream, 0, sizeof(_audioStream));
+
+ gDebugLevel = 10;
+}
+
+PrinceEngine::~PrinceEngine() {
+ DebugMan.clearAllDebugChannels();
+
+ delete _rnd;
+ delete _debugger;
+ delete _cursor1;
+ delete _cursor3;
+ delete _midiPlayer;
+ delete _script;
+ delete _flags;
+ delete _interpreter;
+ delete _font;
+ delete _roomBmp;
+ delete _suitcaseBmp;
+ delete _variaTxt;
+ free(_talkTxt);
+ free(_invTxt);
+ free(_dialogDat);
+ delete _graph;
+ delete _room;
+
+ if (_cursor2 != nullptr) {
+ _cursor2->free();
+ delete _cursor2;
+ }
+
+ for (uint i = 0; i < _objList.size(); i++) {
+ delete _objList[i];
+ }
+ _objList.clear();
+
+ free(_objSlot);
+
+ for (uint32 i = 0; i < _pscrList.size(); i++) {
+ delete _pscrList[i];
+ }
+ _pscrList.clear();
+
+ for (uint i = 0; i < _maskList.size(); i++) {
+ free(_maskList[i]._data);
+ }
+ _maskList.clear();
+
+ _drawNodeList.clear();
+
+ clearBackAnimList();
+ _backAnimList.clear();
+
+ freeAllNormAnims();
+ _normAnimList.clear();
+
+ for (uint i = 0; i < _allInvList.size(); i++) {
+ _allInvList[i]._surface->free();
+ delete _allInvList[i]._surface;
+ }
+ _allInvList.clear();
+
+ _optionsPic->free();
+ delete _optionsPic;
+
+ _optionsPicInInventory->free();
+ delete _optionsPicInInventory;
+
+ for (uint i = 0; i < _mainHero->_moveSet.size(); i++) {
+ delete _mainHero->_moveSet[i];
+ }
+
+ for (uint i = 0; i < _secondHero->_moveSet.size(); i++) {
+ delete _secondHero->_moveSet[i];
+ }
+
+ delete _mainHero;
+ delete _secondHero;
+
+ free(_roomPathBitmap);
+ free(_roomPathBitmapTemp);
+ free(_coordsBuf);
+
+ _mobPriorityList.clear();
+
+ freeAllSamples();
+
+ free(_zoomBitmap);
+ free(_shadowBitmap);
+ free(_transTable);
+
+ free(_curveData);
+
+ free(_shadowLine);
+
+ free(_creditsData);
+
+ if (_dialogImage != nullptr) {
+ _dialogImage->free();
+ delete _dialogImage;
+ }
+
+ free(_mobTranslationData);
+}
+
+GUI::Debugger *PrinceEngine::getDebugger() {
+ return _debugger;
+}
+
+void PrinceEngine::init() {
+
+ const Common::FSNode gameDataDir(ConfMan.get("path"));
+
+ debugEngine("Adding all path: %s", gameDataDir.getPath().c_str());
+
+ PtcArchive *all = new PtcArchive();
+ if (!all->open("all/databank.ptc"))
+ error("Can't open all/databank.ptc");
+
+ PtcArchive *voices = new PtcArchive();
+ if (!voices->open("data/voices/databank.ptc"))
+ error("Can't open data/voices/databank.ptc");
+
+ PtcArchive *sound = new PtcArchive();
+ if (!sound->open("sound/databank.ptc"))
+ error("Can't open sound/databank.ptc");
+
+ PtcArchive *translation = new PtcArchive();
+ if (getLanguage() != Common::PL_POL && getLanguage() != Common::DE_DEU) {
+ if (!translation->openTranslation("all/prince_translation.dat"))
+ error("Can't open prince_translation.dat");
+ }
+
+ SearchMan.addSubDirectoryMatching(gameDataDir, "all");
+
+ SearchMan.add("all", all);
+ SearchMan.add("voices", voices);
+ SearchMan.add("sound", sound);
+ if (getLanguage() != Common::PL_POL && getLanguage() != Common::DE_DEU) {
+ SearchMan.add("translation", translation);
+ }
+
+ _graph = new GraphicsMan(this);
+
+ _rnd = new Common::RandomSource("prince");
+
+ _midiPlayer = new MusicPlayer(this);
+
+ if (getLanguage() == Common::DE_DEU) {
+ _font = new Font();
+ Resource::loadResource(_font, "font3.raw", true);
+ } else {
+ _font = new Font();
+ Resource::loadResource(_font, "font1.raw", true);
+ }
+
+ _suitcaseBmp = new MhwanhDecoder();
+ Resource::loadResource(_suitcaseBmp, "walizka", true);
+
+ _script = new Script(this);
+ Resource::loadResource(_script, "skrypt.dat", true);
+
+ _flags = new InterpreterFlags();
+ _interpreter = new Interpreter(this, _script, _flags);
+
+ _debugger = new Debugger(this, _flags);
+
+ _variaTxt = new VariaTxt();
+ if (getLanguage() == Common::PL_POL || getLanguage() == Common::DE_DEU) {
+ Resource::loadResource(_variaTxt, "variatxt.dat", true);
+ } else {
+ Resource::loadResource(_variaTxt, "variatxt_translate.dat", true);
+ }
+
+ _cursor1 = new Cursor();
+ Resource::loadResource(_cursor1, "mouse1.cur", true);
+
+ _cursor3 = new Cursor();
+ Resource::loadResource(_cursor3, "mouse2.cur", true);
+
+ Common::SeekableReadStream *talkTxtStream;
+ if (getLanguage() == Common::PL_POL || getLanguage() == Common::DE_DEU) {
+ talkTxtStream = SearchMan.createReadStreamForMember("talktxt.dat");
+ } else {
+ talkTxtStream = SearchMan.createReadStreamForMember("talktxt_translate.dat");
+ }
+ if (!talkTxtStream) {
+ error("Can't load talkTxtStream");
+ return;
+ }
+ _talkTxtSize = talkTxtStream->size();
+ _talkTxt = (byte *)malloc(_talkTxtSize);
+ talkTxtStream->read(_talkTxt, _talkTxtSize);
+
+ delete talkTxtStream;
+
+ Common::SeekableReadStream *invTxtStream;
+ if (getLanguage() == Common::PL_POL || getLanguage() == Common::DE_DEU) {
+ invTxtStream = SearchMan.createReadStreamForMember("invtxt.dat");
+ } else {
+ invTxtStream = SearchMan.createReadStreamForMember("invtxt_translate.dat");
+ }
+ if (!invTxtStream) {
+ error("Can't load invTxtStream");
+ return;
+ }
+ _invTxtSize = invTxtStream->size();
+ _invTxt = (byte *)malloc(_invTxtSize);
+ invTxtStream->read(_invTxt, _invTxtSize);
+
+ delete invTxtStream;
+
+ loadAllInv();
+
+ Common::SeekableReadStream *dialogDatStream = SearchMan.createReadStreamForMember("dialog.dat");
+ if (!dialogDatStream) {
+ error("Can't load dialogDatStream");
+ return;
+ }
+ _dialogDatSize = dialogDatStream->size();
+ _dialogDat = (byte *)malloc(_dialogDatSize);
+ dialogDatStream->read(_dialogDat, _dialogDatSize);
+
+ delete dialogDatStream;
+
+ _optionsPic = new Graphics::Surface();
+ _optionsPic->create(_optionsWidth, _optionsHeight, Graphics::PixelFormat::createFormatCLUT8());
+ Common::Rect picRect(0, 0, _optionsWidth, _optionsHeight);
+ _optionsPic->fillRect(picRect, _graph->kShadowColor);
+
+ _optionsPicInInventory = new Graphics::Surface();
+ _optionsPicInInventory->create(_invOptionsWidth, _invOptionsHeight, Graphics::PixelFormat::createFormatCLUT8());
+ Common::Rect invPicRect(0, 0, _invOptionsWidth, _invOptionsHeight);
+ _optionsPicInInventory->fillRect(invPicRect, _graph->kShadowColor);
+
+ _roomBmp = new Image::BitmapDecoder();
+
+ _room = new Room();
+
+ _mainHero = new Hero(this, _graph);
+ _secondHero = new Hero(this, _graph);
+ _secondHero->_maxBoredom = 140;
+ _secondHero->loadAnimSet(3);
+
+ _roomPathBitmap = (byte *)malloc(kPathBitmapLen);
+ _roomPathBitmapTemp = (byte *)malloc(kPathBitmapLen);
+ _coordsBuf = (byte *)malloc(kTracePts * 4);
+ _coords = _coordsBuf;
+ _coordsBufEnd = _coordsBuf + kTracePts * 4 - 4;
+
+ BackgroundAnim tempBackAnim;
+ tempBackAnim._seq._currRelative = 0;
+ for (int i = 0; i < kMaxBackAnims; i++) {
+ _backAnimList.push_back(tempBackAnim);
+ }
+
+ Anim tempAnim;
+ tempAnim._animData = nullptr;
+ tempAnim._shadowData = nullptr;
+ for (int i = 0; i < kMaxNormAnims; i++) {
+ _normAnimList.push_back(tempAnim);
+ }
+
+ _objSlot = (uint16 *)malloc(kMaxObjects * sizeof(uint16));
+ for (int i = 0; i < kMaxObjects; i++) {
+ _objSlot[i] = 0xFF;
+ }
+
+ _zoomBitmap = (byte *)malloc(kZoomBitmapLen);
+ _shadowBitmap = (byte *)malloc(2 * kShadowBitmapSize);
+ _transTable = (byte *)malloc(kTransTableSize);
+
+ _curveData = (int16 *)malloc(2 * kCurveLen * sizeof(int16));
+
+ _shadowLine = (byte *)malloc(kShadowLineArraySize);
+
+ Common::SeekableReadStream *creditsDataStream;
+ if (getLanguage() == Common::PL_POL || getLanguage() == Common::DE_DEU) {
+ creditsDataStream = SearchMan.createReadStreamForMember("credits.dat");
+ } else {
+ creditsDataStream = SearchMan.createReadStreamForMember("credits_translate.dat");
+ }
+ if (!creditsDataStream) {
+ error("Can't load creditsDataStream");
+ return;
+ }
+ _creditsDataSize = creditsDataStream->size();
+ _creditsData = (byte *)malloc(_creditsDataSize);
+ creditsDataStream->read(_creditsData, _creditsDataSize);
+ delete creditsDataStream;
+
+ if (getLanguage() != Common::PL_POL && getLanguage() != Common::DE_DEU) {
+ loadMobTranslationTexts();
+ }
+}
+
+void PrinceEngine::showLogo() {
+ MhwanhDecoder logo;
+ if (Resource::loadResource(&logo, "logo.raw", true)) {
+ loadSample(0, "LOGO.WAV");
+ playSample(0, 0);
+ _graph->draw(_graph->_frontScreen, logo.getSurface());
+ _graph->change();
+ _graph->update(_graph->_frontScreen);
+ setPalette(logo.getPalette());
+
+ uint32 logoStart = _system->getMillis();
+ while (_system->getMillis() < logoStart + 5000) {
+ Common::Event event;
+ Common::EventManager *eventMan = _system->getEventManager();
+ while (eventMan->pollEvent(event)) {
+ switch (event.type) {
+ case Common::EVENT_KEYDOWN:
+ if (event.kbd.keycode == Common::KEYCODE_ESCAPE) {
+ stopSample(0);
+ return;
+ }
+ break;
+ case Common::EVENT_LBUTTONDOWN:
+ stopSample(0);
+ return;
+ default:
+ break;
+ }
+ }
+
+ if (shouldQuit()) {
+ return;
+ }
+ }
+ }
+}
+
+Common::Error PrinceEngine::run() {
+ syncSoundSettings();
+ int startGameSlot = ConfMan.hasKey("save_slot") ? ConfMan.getInt("save_slot") : -1;
+ init();
+ if (startGameSlot == -1) {
+ showLogo();
+ } else {
+ loadLocation(59); // load intro location - easiest way to set everything up
+ loadGame(startGameSlot);
+ }
+ mainLoop();
+ return Common::kNoError;
+}
+
+void PrinceEngine::pauseEngineIntern(bool pause) {
+ Engine::pauseEngineIntern(pause);
+ if (pause) {
+ _midiPlayer->pause();
+ }
+ else {
+ _midiPlayer->resume();
+ }
+}
+
+bool AnimListItem::loadFromStream(Common::SeekableReadStream &stream) {
+ int32 pos = stream.pos();
+
+ uint16 type = stream.readUint16LE();
+ if (type == 0xFFFF) {
+ return false;
+ }
+ _type = type;
+ _fileNumber = stream.readUint16LE();
+ _startPhase = stream.readUint16LE();
+ _endPhase = stream.readUint16LE();
+ _loopPhase = stream.readUint16LE();
+ _x = stream.readSint16LE();
+ _y = stream.readSint16LE();
+ _loopType = stream.readUint16LE();
+ _nextAnim = stream.readUint16LE();
+ _flags = stream.readUint16LE();
+
+ //debug("AnimListItem type %d, fileNumber %d, x %d, y %d, flags %d", _type, _fileNumber, _x, _y, _flags);
+ //debug("startPhase %d, endPhase %d, loopPhase %d", _startPhase, _endPhase, _loopPhase);
+
+ // 32 byte aligment
+ stream.seek(pos + 32);
+
+ return true;
+}
+
+bool PrinceEngine::loadLocation(uint16 locationNr) {
+
+ blackPalette();
+
+ _flicPlayer.close();
+
+ memset(_textSlots, 0, sizeof(_textSlots));
+ freeAllSamples();
+
+ debugEngine("PrinceEngine::loadLocation %d", locationNr);
+ const Common::FSNode gameDataDir(ConfMan.get("path"));
+ SearchMan.remove(Common::String::format("%02d", _locationNr));
+
+ _locationNr = locationNr;
+ _debugger->_locationNr = locationNr;
+
+ _flags->setFlagValue(Flags::CURRROOM, _locationNr);
+ _interpreter->stopBg();
+
+ changeCursor(0);
+
+ const Common::String locationNrStr = Common::String::format("%02d", _locationNr);
+ debugEngine("loadLocation %s", locationNrStr.c_str());
+
+ PtcArchive *locationArchive = new PtcArchive();
+ if (!locationArchive->open(locationNrStr + "/databank.ptc"))
+ error("Can't open location %s", locationNrStr.c_str());
+
+ SearchMan.add(locationNrStr, locationArchive);
+
+ loadMusic(_locationNr);
+
+ // load location background, replace old one
+ Resource::loadResource(_roomBmp, "room", true);
+ if (_roomBmp->getSurface()) {
+ _sceneWidth = _roomBmp->getSurface()->w;
+ }
+
+ loadZoom(_zoomBitmap, kZoomBitmapLen, "zoom");
+ loadShadow(_shadowBitmap, kShadowBitmapSize, "shadow", "shadow2");
+ loadTrans(_transTable, "trans");
+ loadPath("path");
+
+ for (uint32 i = 0; i < _pscrList.size(); i++) {
+ delete _pscrList[i];
+ }
+ _pscrList.clear();
+ Resource::loadResource(_pscrList, "pscr.lst", false);
+
+ loadMobPriority("mobpri");
+
+ _mobList.clear();
+ if (getGameType() == kPrinceDataDE) {
+ const Common::String mobLstName = Common::String::format("mob%02d.lst", _locationNr);
+ debug("name: %s", mobLstName.c_str());
+ Resource::loadResource(_mobList, mobLstName.c_str(), false);
+ } else if (getGameType() == kPrinceDataPL) {
+ Resource::loadResource(_mobList, "mob.lst", false);
+ }
+ if (getLanguage() != Common::PL_POL && getLanguage() != Common::DE_DEU) {
+ // update Mob texts for translated version
+ setMobTranslationTexts();
+ }
+
+ _animList.clear();
+ Resource::loadResource(_animList, "anim.lst", false);
+
+ for (uint32 i = 0; i < _objList.size(); i++) {
+ delete _objList[i];
+ }
+ _objList.clear();
+ Resource::loadResource(_objList, "obj.lst", false);
+
+ _room->loadRoom(_script->getRoomOffset(_locationNr));
+
+ for (uint i = 0; i < _maskList.size(); i++) {
+ free(_maskList[i]._data);
+ }
+ _maskList.clear();
+ _script->loadAllMasks(_maskList, _room->_nak);
+
+ _picWindowX = 0;
+
+ _lightX = _script->getLightX(_locationNr);
+ _lightY = _script->getLightY(_locationNr);
+ setShadowScale(_script->getShadowScale(_locationNr));
+
+ for (uint i = 0; i < _mobList.size(); i++) {
+ _mobList[i]._visible = _script->getMobVisible(_room->_mobs, i);
+ }
+
+ _script->installObjects(_room->_obj);
+
+ freeAllNormAnims();
+
+ clearBackAnimList();
+ _script->installBackAnims(_backAnimList, _room->_backAnim);
+
+ _graph->makeShadowTable(70, _graph->_shadowTable70);
+ _graph->makeShadowTable(50, _graph->_shadowTable50);
+
+ _mainHero->freeOldMove();
+ _secondHero->freeOldMove();
+
+ _mainHero->scrollHero();
+
+ return true;
+}
+
+void PrinceEngine::setShadowScale(int32 shadowScale) {
+ shadowScale = 100 - shadowScale;
+ if (!shadowScale) {
+ _shadScaleValue = 10000;
+ } else {
+ _shadScaleValue = 10000 / shadowScale;
+ }
+}
+
+void PrinceEngine::plotShadowLinePoint(int x, int y, int color, void *data) {
+ PrinceEngine *vm = (PrinceEngine *)data;
+ WRITE_LE_UINT16(&vm->_shadowLine[vm->_shadLineLen * 4], x);
+ WRITE_LE_UINT16(&vm->_shadowLine[vm->_shadLineLen * 4 + 2], y);
+ vm->_shadLineLen++;
+}
+
+void PrinceEngine::changeCursor(uint16 curId) {
+ _debugger->_cursorNr = curId;
+ _mouseFlag = curId;
+ _flags->setFlagValue(Flags::MOUSEENABLED, curId);
+
+ const Graphics::Surface *curSurface = nullptr;
+
+ switch (curId) {
+ case 0:
+ CursorMan.showMouse(false);
+ _optionsFlag = 0;
+ _selectedMob = -1;
+ return;
+ case 1:
+ curSurface = _cursor1->getSurface();
+ break;
+ case 2:
+ curSurface = _cursor2;
+ break;
+ case 3:
+ curSurface = _cursor3->getSurface();
+ Common::Point mousePos = _system->getEventManager()->getMousePos();
+ mousePos.x = CLIP(mousePos.x, (int16) 315, (int16) 639);
+ mousePos.y = CLIP(mousePos.y, (int16) 0, (int16) 170);
+ _system->warpMouse(mousePos.x, mousePos.y);
+ break;
+ }
+
+ CursorMan.replaceCursorPalette(_roomBmp->getPalette(), 0, 255);
+ CursorMan.replaceCursor(
+ curSurface->getBasePtr(0, 0),
+ curSurface->w, curSurface->h,
+ 0, 0,
+ 255, false,
+ &curSurface->format
+ );
+ CursorMan.showMouse(true);
+}
+
+void PrinceEngine::makeInvCursor(int itemNr) {
+ const Graphics::Surface *cur1Surface = _cursor1->getSurface();
+ int cur1W = cur1Surface->w;
+ int cur1H = cur1Surface->h;
+ const Common::Rect cur1Rect(0, 0, cur1W, cur1H);
+
+ const Graphics::Surface *itemSurface = _allInvList[itemNr].getSurface();
+ int itemW = itemSurface->w;
+ int itemH = itemSurface->h;
+
+ int cur2W = cur1W + itemW / 2;
+ int cur2H = cur1H + itemH / 2;
+
+ if (_cursor2 != nullptr) {
+ _cursor2->free();
+ delete _cursor2;
+ }
+ _cursor2 = new Graphics::Surface();
+ _cursor2->create(cur2W, cur2H, Graphics::PixelFormat::createFormatCLUT8());
+ Common::Rect cur2Rect(0, 0, cur2W, cur2H);
+ _cursor2->fillRect(cur2Rect, 255);
+ _cursor2->copyRectToSurface(*cur1Surface, 0, 0, cur1Rect);
+
+ const byte *src1 = (const byte *)itemSurface->getBasePtr(0, 0);
+ byte *dst1 = (byte *)_cursor2->getBasePtr(cur1W, cur1H);
+
+ if (itemH % 2) {
+ itemH--;
+ }
+ if (itemW % 2) {
+ itemW--;
+ }
+
+ for (int y = 0; y < itemH; y++) {
+ const byte *src2 = src1;
+ byte *dst2 = dst1;
+ if (y % 2 == 0) {
+ for (int x = 0; x < itemW; x++, src2++) {
+ if (x % 2 == 0) {
+ if (*src2) {
+ *dst2 = *src2;
+ } else {
+ *dst2 = 255;
+ }
+ dst2++;
+ }
+ }
+ dst1 += _cursor2->pitch;
+ }
+ src1 += itemSurface->pitch;
+ }
+}
+
+bool PrinceEngine::loadMusic(int musNumber) {
+ uint8 midiNumber = MusicPlayer::_musRoomTable[musNumber];
+ if (midiNumber) {
+ if (midiNumber != 100) {
+ if (_currentMidi != midiNumber) {
+ _currentMidi = midiNumber;
+ const char *musName = MusicPlayer::_musTable[_currentMidi];
+ _midiPlayer->loadMidi(musName);
+ }
+ }
+ } else {
+ stopMusic();
+ }
+ return true;
+}
+
+void PrinceEngine::stopMusic() {
+ if (_midiPlayer->isPlaying()) {
+ _midiPlayer->stop();
+ }
+}
+
+bool PrinceEngine::playNextFLCFrame() {
+ if (!_flicPlayer.isVideoLoaded())
+ return false;
+
+ const Graphics::Surface *s = _flicPlayer.decodeNextFrame();
+ if (s) {
+ _graph->drawTransparentSurface(_graph->_frontScreen, 0, 0, s, 255);
+ _graph->change();
+ _flcFrameSurface = s;
+ } else if (_flicLooped) {
+ _flicPlayer.rewind();
+ playNextFLCFrame();
+ } else if (_flcFrameSurface) {
+ _graph->drawTransparentSurface(_graph->_frontScreen, 0, 0, _flcFrameSurface, 255);
+ _graph->change();
+ }
+
+ return true;
+}
+
+void PrinceEngine::playSample(uint16 sampleId, uint16 loopType) {
+ if (_audioStream[sampleId]) {
+ if (_mixer->isSoundIDActive(sampleId)) {
+ return;
+ }
+ _audioStream[sampleId]->rewind();
+ if (sampleId < 28) {
+ _mixer->playStream(Audio::Mixer::kSFXSoundType, &_soundHandle[sampleId], _audioStream[sampleId], sampleId, Audio::Mixer::kMaxChannelVolume, 0, DisposeAfterUse::NO);
+ } else {
+ _mixer->playStream(Audio::Mixer::kSpeechSoundType, &_soundHandle[sampleId], _audioStream[sampleId], sampleId, Audio::Mixer::kMaxChannelVolume, 0, DisposeAfterUse::NO);
+ }
+ }
+}
+
+void PrinceEngine::stopSample(uint16 sampleId) {
+ _mixer->stopID(sampleId);
+}
+
+void PrinceEngine::stopAllSamples() {
+ _mixer->stopAll();
+}
+
+void PrinceEngine::freeSample(uint16 sampleId) {
+ stopSample(sampleId);
+ if (_audioStream[sampleId] != nullptr) {
+ delete _audioStream[sampleId];
+ _audioStream[sampleId] = nullptr;
+ }
+}
+
+void PrinceEngine::freeAllSamples() {
+ for (int sampleId = 0; sampleId < kMaxSamples; sampleId++) {
+ freeSample(sampleId);
+ }
+}
+
+bool PrinceEngine::loadSample(uint32 sampleSlot, const Common::String &streamName) {
+ // FIXME: This is just a workaround streamName is a path
+ // SOUND\\SCIERKA1.WAV for now only last path component is used
+ Common::String normalizedPath = lastPathComponent(streamName, '\\');
+
+ // WALKAROUND: Wrong name in script, not existing sound in data files
+ if (!normalizedPath.compareTo("9997BEKA.WAV")) {
+ return 0;
+ }
+
+ debugEngine("loadSample slot %d, name %s", sampleSlot, normalizedPath.c_str());
+
+ freeSample(sampleSlot);
+ Common::SeekableReadStream *sampleStream = SearchMan.createReadStreamForMember(normalizedPath);
+ if (sampleStream == nullptr) {
+ delete sampleStream;
+ error("Can't load sample %s to slot %d", normalizedPath.c_str(), sampleSlot);
+ }
+ _audioStream[sampleSlot] = Audio::makeWAVStream(sampleStream, DisposeAfterUse::NO);
+ delete sampleStream;
+ return true;
+}
+
+bool PrinceEngine::loadVoice(uint32 slot, uint32 sampleSlot, const Common::String &streamName) {
+ debugEngine("Loading wav %s slot %d", streamName.c_str(), slot);
+
+ if (slot >= kMaxTexts) {
+ error("Text slot bigger than MAXTEXTS %d", kMaxTexts - 1);
+ return false;
+ }
+
+ freeSample(sampleSlot);
+ Common::SeekableReadStream *sampleStream = SearchMan.createReadStreamForMember(streamName);
+ if (sampleStream == nullptr) {
+ debug("Can't open %s", streamName.c_str());
+ return false;
+ }
+
+ uint32 id = sampleStream->readUint32LE();
+ if (id != MKTAG('F', 'F', 'I', 'R')) {
+ error("It's not RIFF file %s", streamName.c_str());
+ return false;
+ }
+
+ sampleStream->skip(0x20);
+ id = sampleStream->readUint32LE();
+ if (id != MKTAG('a', 't', 'a', 'd')) {
+ error("No data section in %s id %04x", streamName.c_str(), id);
+ return false;
+ }
+
+ id = sampleStream->readUint32LE();
+ debugEngine("SetVoice slot %d time %04x", slot, id);
+ id <<= 3;
+ id /= 22050;
+ id += 2;
+
+ _textSlots[slot]._time = id;
+ if (!slot) {
+ _mainHero->_talkTime = id;
+ } else if (slot == 1) {
+ _secondHero->_talkTime = id;
+ }
+
+ debugEngine("SetVoice slot %d time %04x", slot, id);
+ sampleStream->seek(SEEK_SET);
+ _audioStream[sampleSlot] = Audio::makeWAVStream(sampleStream, DisposeAfterUse::NO);
+ delete sampleStream;
+ return true;
+}
+
+void PrinceEngine::setVoice(uint16 slot, uint32 sampleSlot, uint16 flag) {
+ Common::String sampleName;
+ uint32 currentString = _interpreter->getCurrentString();
+
+ if (currentString >= 80000) {
+ uint32 nr = currentString - 80000;
+ sampleName = Common::String::format("%02d0%02d-%02d.WAV", nr / 100, nr % 100, flag);
+ } else if (currentString >= 70000) {
+ sampleName = Common::String::format("inv%02d-01.WAV", currentString - 70000);
+ } else if (currentString >= 60000) {
+ sampleName = Common::String::format("M%04d-%02d.WAV", currentString - 60000, flag);
+ } else if (currentString >= 2000) {
+ return;
+ } else if (flag >= 100) {
+ sampleName = Common::String::format("%03d-%03d.WAV", currentString, flag);
+ } else {
+ sampleName = Common::String::format("%03d-%02d.WAV", currentString, flag);
+ }
+
+ loadVoice(slot, sampleSlot, sampleName);
+}
+
+bool PrinceEngine::loadAnim(uint16 animNr, bool loop) {
+ Common::String streamName = Common::String::format("AN%02d", animNr);
+ Common::SeekableReadStream *flicStream = SearchMan.createReadStreamForMember(streamName);
+
+ if (!flicStream) {
+ error("Can't open %s", streamName.c_str());
+ return false;
+ }
+
+ if (!_flicPlayer.loadStream(flicStream)) {
+ error("Can't load flic stream %s", streamName.c_str());
+ }
+
+ debugEngine("%s loaded", streamName.c_str());
+ _flicLooped = loop;
+ _flicPlayer.start();
+ playNextFLCFrame();
+ return true;
+}
+
+bool PrinceEngine::loadZoom(byte *zoomBitmap, uint32 dataSize, const char *resourceName) {
+ Common::SeekableReadStream *stream = SearchMan.createReadStreamForMember(resourceName);
+ if (!stream) {
+ delete stream;
+ return false;
+ }
+ if (stream->read(zoomBitmap, dataSize) != dataSize) {
+ free(zoomBitmap);
+ delete stream;
+ return false;
+ }
+ delete stream;
+ return true;
+}
+
+bool PrinceEngine::loadShadow(byte *shadowBitmap, uint32 dataSize, const char *resourceName1, const char *resourceName2) {
+ Common::SeekableReadStream *stream = SearchMan.createReadStreamForMember(resourceName1);
+ if (!stream) {
+ delete stream;
+ return false;
+ }
+
+ if (stream->read(shadowBitmap, dataSize) != dataSize) {
+ free(shadowBitmap);
+ delete stream;
+ return false;
+ }
+
+ Common::SeekableReadStream *stream2 = SearchMan.createReadStreamForMember(resourceName2);
+ if (!stream2) {
+ delete stream;
+ delete stream2;
+ return false;
+ }
+
+ byte *shadowBitmap2 = shadowBitmap + dataSize;
+ if (stream2->read(shadowBitmap2, dataSize) != dataSize) {
+ free(shadowBitmap);
+ delete stream;
+ delete stream2;
+ return false;
+ }
+
+ delete stream;
+ delete stream2;
+ return true;
+}
+
+bool PrinceEngine::loadTrans(byte *transTable, const char *resourceName) {
+ Common::SeekableReadStream *stream = SearchMan.createReadStreamForMember(resourceName);
+ if (!stream) {
+ delete stream;
+ for (int i = 0; i < 256; i++) {
+ for (int j = 0; j < 256; j++) {
+ transTable[i * 256 + j] = j;
+ }
+ }
+ return true;
+ }
+ if (stream->read(transTable, kTransTableSize) != kTransTableSize) {
+ delete stream;
+ return false;
+ }
+ delete stream;
+ return true;
+}
+
+bool PrinceEngine::loadPath(const char *resourceName) {
+ Common::SeekableReadStream *stream = SearchMan.createReadStreamForMember(resourceName);
+ if (!stream) {
+ delete stream;
+ return false;
+ }
+ if (stream->read(_roomPathBitmap, kPathBitmapLen) != kPathBitmapLen) {
+ delete stream;
+ return false;
+ }
+ delete stream;
+ return true;
+}
+
+bool PrinceEngine::loadAllInv() {
+ for (int i = 0; i < kMaxInv; i++) {
+ InvItem tempInvItem;
+
+ const Common::String invStreamName = Common::String::format("INV%02d", i);
+ Common::SeekableReadStream *invStream = SearchMan.createReadStreamForMember(invStreamName);
+ if (!invStream) {
+ delete invStream;
+ return true;
+ }
+
+ tempInvItem._x = invStream->readUint16LE();
+ tempInvItem._y = invStream->readUint16LE();
+ int width = invStream->readUint16LE();
+ int height = invStream->readUint16LE();
+ tempInvItem._surface = new Graphics::Surface();
+ tempInvItem._surface->create(width, height, Graphics::PixelFormat::createFormatCLUT8());
+
+ for (int h = 0; h < tempInvItem._surface->h; h++) {
+ invStream->read(tempInvItem._surface->getBasePtr(0, h), tempInvItem._surface->w);
+ }
+
+ _allInvList.push_back(tempInvItem);
+ delete invStream;
+ }
+
+ return true;
+}
+
+bool PrinceEngine::loadMobPriority(const char *resourceName) {
+ Common::SeekableReadStream *stream = SearchMan.createReadStreamForMember(resourceName);
+ if (!stream) {
+ delete stream;
+ return false;
+ }
+
+ _mobPriorityList.clear();
+ uint mobId;
+ while (1) {
+ mobId = stream->readUint32LE();
+ if (mobId == 0xFFFFFFFF) {
+ break;
+ }
+ _mobPriorityList.push_back(mobId);
+ }
+ delete stream;
+ return true;
+}
+
+void PrinceEngine::loadMobTranslationTexts() {
+ Common::SeekableReadStream *mobTranslationStream = SearchMan.createReadStreamForMember("mob_translate.dat");
+ if (!mobTranslationStream) {
+ error("Can't load mob_translate.dat");
+ }
+ _mobTranslationSize = mobTranslationStream->size();
+ _mobTranslationData = (byte *)malloc(_mobTranslationSize);
+ mobTranslationStream->read(_mobTranslationData, _mobTranslationSize);
+ delete mobTranslationStream;
+}
+
+void PrinceEngine::setMobTranslationTexts() {
+ int locationOffset = READ_UINT16(_mobTranslationData + (_locationNr - 1) * 2);
+ if (locationOffset) {
+ byte *locationText = _mobTranslationData + locationOffset;
+ for (uint i = 0; i < _mobList.size(); i++) {
+ byte c;
+ locationText++;
+ _mobList[i]._name.clear();
+ while ((c = *locationText)) {
+ _mobList[i]._name += c;
+ locationText++;
+ }
+ locationText++;
+ _mobList[i]._examText.clear();
+ c = *locationText;
+ locationText++;
+ if (c) {
+ _mobList[i]._examText += c;
+ do {
+ c = *locationText;
+ _mobList[i]._examText += c;
+ locationText++;
+ } while (c != 255);
+ }
+ }
+ }
+}
+
+void PrinceEngine::keyHandler(Common::Event event) {
+ uint16 nChar = event.kbd.keycode;
+ switch (nChar) {
+ case Common::KEYCODE_d:
+ if (event.kbd.hasFlags(Common::KBD_CTRL)) {
+ getDebugger()->attach();
+ }
+ break;
+ case Common::KEYCODE_z:
+ if (_flags->getFlagValue(Flags::POWERENABLED)) {
+ _flags->setFlagValue(Flags::MBFLAG, 1);
+ }
+ break;
+ case Common::KEYCODE_x:
+ if (_flags->getFlagValue(Flags::POWERENABLED)) {
+ _flags->setFlagValue(Flags::MBFLAG, 2);
+ }
+ break;
+ case Common::KEYCODE_ESCAPE:
+ _flags->setFlagValue(Flags::ESCAPED2, 1);
+ break;
+ }
+}
+
+int PrinceEngine::getMob(Common::Array<Mob> &mobList, bool usePriorityList, int posX, int posY) {
+
+ Common::Point pointPos(posX, posY);
+
+ int mobListSize;
+ if (usePriorityList) {
+ mobListSize = _mobPriorityList.size();
+ } else {
+ mobListSize = mobList.size();
+ }
+
+ for (int mobNumber = 0; mobNumber < mobListSize; mobNumber++) {
+ Mob *mob = nullptr;
+ if (usePriorityList) {
+ mob = &mobList[_mobPriorityList[mobNumber]];
+ } else {
+ mob = &mobList[mobNumber];
+ }
+
+ if (mob->_visible) {
+ continue;
+ }
+
+ int type = mob->_type & 7;
+ switch (type) {
+ case 0:
+ case 1:
+ //normal_mob
+ if (!mob->_rect.contains(pointPos)) {
+ continue;
+ }
+ break;
+ case 3:
+ //mob_obj
+ if (mob->_mask < kMaxObjects) {
+ int nr = _objSlot[mob->_mask];
+ if (nr != 0xFF) {
+ Object &obj = *_objList[nr];
+ Common::Rect objectRect(obj._x, obj._y, obj._x + obj._width, obj._y + obj._height);
+ if (objectRect.contains(pointPos)) {
+ Graphics::Surface *objSurface = obj.getSurface();
+ byte *pixel = (byte *)objSurface->getBasePtr(posX - obj._x, posY - obj._y);
+ if (*pixel != 255) {
+ break;
+ }
+ }
+ }
+ }
+ continue;
+ break;
+ case 2:
+ case 5:
+ //check_ba_mob
+ if (!_backAnimList[mob->_mask].backAnims.empty()) {
+ int currentAnim = _backAnimList[mob->_mask]._seq._currRelative;
+ Anim &backAnim = _backAnimList[mob->_mask].backAnims[currentAnim];
+ if (backAnim._animData != nullptr) {
+ if (!backAnim._state) {
+ Common::Rect backAnimRect(backAnim._currX, backAnim._currY, backAnim._currX + backAnim._currW, backAnim._currY + backAnim._currH);
+ if (backAnimRect.contains(pointPos)) {
+ int phase = backAnim._showFrame;
+ int phaseFrameIndex = backAnim._animData->getPhaseFrameIndex(phase);
+ Graphics::Surface *backAnimSurface = backAnim._animData->getFrame(phaseFrameIndex);
+ byte pixel = *(byte *)backAnimSurface->getBasePtr(posX - backAnim._currX, posY - backAnim._currY);
+ if (pixel != 255) {
+ if (type == 5) {
+ if (mob->_rect.contains(pointPos)) {
+ break;
+ }
+ } else {
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+ continue;
+ break;
+ default:
+ //not_part_ba
+ continue;
+ break;
+ }
+
+ if (usePriorityList) {
+ return _mobPriorityList[mobNumber];
+ } else {
+ return mobNumber;
+ }
+ }
+ return -1;
+}
+
+int PrinceEngine::checkMob(Graphics::Surface *screen, Common::Array<Mob> &mobList, bool usePriorityList) {
+ if (_mouseFlag == 0 || _mouseFlag == 3) {
+ return -1;
+ }
+ Common::Point mousePos = _system->getEventManager()->getMousePos();
+ int mobNumber = getMob(mobList, usePriorityList, mousePos.x + _picWindowX, mousePos.y);
+
+ if (mobNumber != -1) {
+ Common::String mobName = mobList[mobNumber]._name;
+
+ if (getLanguage() == Common::DE_DEU) {
+ for (uint i = 0; i < mobName.size(); i++) {
+ switch (mobName[i]) {
+ case '\xc4':
+ mobName.setChar('\x83', i);
+ break;
+ case '\xd6':
+ mobName.setChar('\x84', i);
+ break;
+ case '\xdc':
+ mobName.setChar('\x85', i);
+ break;
+ case '\xdf':
+ mobName.setChar('\x7f', i);
+ break;
+ case '\xe4':
+ mobName.setChar('\x80', i);
+ break;
+ case '\xf6':
+ mobName.setChar('\x81', i);
+ break;
+ case '\xfc':
+ mobName.setChar('\x82', i);
+ break;
+ }
+ }
+ }
+
+ uint16 textW = getTextWidth(mobName.c_str());
+
+ uint16 x = mousePos.x - textW / 2;
+ if (x > screen->w) {
+ x = 0;
+ }
+
+ if (x + textW > screen->w) {
+ x = screen->w - textW;
+ }
+
+ uint16 y = mousePos.y - _font->getFontHeight();
+ if (y > screen->h) {
+ y = _font->getFontHeight() - 2;
+ }
+
+ _font->drawString(screen, mobName, x, y, screen->w, 216);
+ }
+
+ return mobNumber;
+}
+
+void PrinceEngine::printAt(uint32 slot, uint8 color, char *s, uint16 x, uint16 y) {
+ debugC(1, DebugChannel::kEngine, "PrinceEngine::printAt slot %d, color %d, x %02d, y %02d, str %s", slot, color, x, y, s);
+
+ if (getLanguage() == Common::DE_DEU)
+ correctStringDEU(s);
+
+ Text &text = _textSlots[slot];
+ text._str = s;
+ text._x = x;
+ text._y = y;
+ text._color = color;
+ int lines = calcTextLines(s);
+ text._time = calcTextTime(lines);
+}
+
+int PrinceEngine::calcTextLines(const char *s) {
+ int lines = 1;
+ while (*s) {
+ if (*s == '\n') {
+ lines++;
+ }
+ s++;
+ }
+ return lines;
+}
+
+int PrinceEngine::calcTextTime(int numberOfLines) {
+ return numberOfLines * 30;
+}
+
+void PrinceEngine::correctStringDEU(char *s) {
+ while (*s) {
+ switch (*s) {
+ case '\xc4':
+ *s = '\x83';
+ break;
+ case '\xd6':
+ *s = '\x84';
+ break;
+ case '\xdc':
+ *s = '\x85';
+ break;
+ case '\xdf':
+ *s = '\x7f';
+ break;
+ case '\xe4':
+ *s = '\x80';
+ break;
+ case '\xf6':
+ *s = '\x81';
+ break;
+ case '\xfc':
+ *s = '\x82';
+ break;
+ }
+ s++;
+ }
+}
+
+uint32 PrinceEngine::getTextWidth(const char *s) {
+ uint16 textW = 0;
+ while (*s) {
+ textW += _font->getCharWidth(*s) + _font->getKerningOffset(0, 0);
+ s++;
+ }
+ return textW;
+}
+
+void PrinceEngine::showTexts(Graphics::Surface *screen) {
+ for (uint32 slot = 0; slot < kMaxTexts; slot++) {
+
+ if (_showInventoryFlag && slot) {
+ // only slot 0 for inventory
+ break;
+ }
+
+ Text& text = _textSlots[slot];
+ if (!text._str && !text._time) {
+ continue;
+ }
+
+ int x = text._x;
+ int y = text._y;
+
+ if (!_showInventoryFlag) {
+ x -= _picWindowX;
+ y -= _picWindowY;
+ }
+
+ Common::Array<Common::String> lines;
+ _font->wordWrapText(text._str, _graph->_frontScreen->w, lines);
+
+ int wideLine = 0;
+ for (uint i = 0; i < lines.size(); i++) {
+ int textLen = getTextWidth(lines[i].c_str());
+ if (textLen > wideLine) {
+ wideLine = textLen;
+ }
+ }
+
+ int leftBorderText = 6;
+ if (x + wideLine / 2 > kNormalWidth - leftBorderText) {
+ x = kNormalWidth - leftBorderText - wideLine / 2;
+ }
+
+ if (x - wideLine / 2 < leftBorderText) {
+ x = leftBorderText + wideLine / 2;
+ }
+
+ int textSkip = 2;
+ for (uint i = 0; i < lines.size(); i++) {
+ int drawX = x - getTextWidth(lines[i].c_str()) / 2;
+ int drawY = y - 10 - (lines.size() - i) * (_font->getFontHeight() - textSkip);
+ if (drawX < 0) {
+ drawX = 0;
+ }
+ if (drawY < 0) {
+ drawY = 0;
+ }
+ _font->drawString(screen, lines[i], drawX, drawY, screen->w, text._color);
+ }
+
+ text._time--;
+ if (!text._time) {
+ text._str = nullptr;
+ }
+ }
+}
+
+bool PrinceEngine::spriteCheck(int sprWidth, int sprHeight, int destX, int destY) {
+ destX -= _picWindowX;
+ destY -= _picWindowY;
+
+ // if x1 is on visible part of screen
+ if (destX < 0) {
+ if (destX + sprWidth < 1) {
+ //x2 is negative - out of window
+ return false;
+ }
+ }
+ // if x1 is outside of screen on right side
+ if (destX >= kNormalWidth) {
+ return false;
+ }
+
+ if (destY < 0) {
+ if (destY + sprHeight < 1) {
+ //y2 is negative - out of window
+ return false;
+ }
+ }
+ if (destY >= kNormalHeight) {
+ return false;
+ }
+
+ return true;
+}
+
+// CheckNak
+void PrinceEngine::checkMasks(int x1, int y1, int sprWidth, int sprHeight, int z) {
+ int x2 = x1 + sprWidth - 1;
+ int y2 = y1 + sprHeight - 1;
+ if (x1 < 0) {
+ x1 = 0;
+ }
+ for (uint i = 0; i < _maskList.size(); i++) {
+ if (!_maskList[i]._state && !_maskList[i]._flags) {
+ if (_maskList[i]._z > z) {
+ if (_maskList[i]._x1 <= x2 && _maskList[i]._x2 >= x1) {
+ if (_maskList[i]._y1 <= y2 && _maskList[i]._y2 >= y1) {
+ _maskList[i]._state = 1;
+ }
+ }
+ }
+ }
+ }
+}
+
+// ClsNak
+void PrinceEngine::clsMasks() {
+ for (uint i = 0; i < _maskList.size(); i++) {
+ if (_maskList[i]._state) {
+ _maskList[i]._state = 0;
+ }
+ }
+}
+
+// InsertNakladki
+void PrinceEngine::insertMasks(Graphics::Surface *originalRoomSurface) {
+ for (uint i = 0; i < _maskList.size(); i++) {
+ if (_maskList[i]._state) {
+ if (_maskList[i]._data != nullptr) {
+ showMask(i, originalRoomSurface);
+ } else {
+ error("insertMasks() - Wrong mask data- nr %d", i);
+ }
+ }
+ }
+}
+
+// ShowNak
+void PrinceEngine::showMask(int maskNr, Graphics::Surface *originalRoomSurface) {
+ if (!_maskList[maskNr]._flags) {
+ if (spriteCheck(_maskList[maskNr]._width, _maskList[maskNr]._height, _maskList[maskNr]._x1, _maskList[maskNr]._y1)) {
+ int destX = _maskList[maskNr]._x1 - _picWindowX;
+ int destY = _maskList[maskNr]._y1 - _picWindowY;
+ DrawNode newDrawNode;
+ newDrawNode.posX = destX;
+ newDrawNode.posY = destY;
+ newDrawNode.posZ = _maskList[maskNr]._z;
+ newDrawNode.width = _maskList[maskNr]._width;
+ newDrawNode.height = _maskList[maskNr]._height;
+ newDrawNode.s = nullptr;
+ newDrawNode.originalRoomSurface = originalRoomSurface;
+ newDrawNode.data = _maskList[maskNr].getMask();
+ newDrawNode.drawFunction = &_graph->drawMaskDrawNode;
+ _drawNodeList.push_back(newDrawNode);
+ }
+ }
+}
+
+void PrinceEngine::showSprite(Graphics::Surface *spriteSurface, int destX, int destY, int destZ) {
+ if (spriteCheck(spriteSurface->w, spriteSurface->h, destX, destY)) {
+ destX -= _picWindowX;
+ destY -= _picWindowY;
+ DrawNode newDrawNode;
+ newDrawNode.posX = destX;
+ newDrawNode.posY = destY;
+ newDrawNode.posZ = destZ;
+ newDrawNode.width = 0;
+ newDrawNode.height = 0;
+ newDrawNode.s = spriteSurface;
+ newDrawNode.originalRoomSurface = nullptr;
+ newDrawNode.data = _transTable;
+ newDrawNode.drawFunction = &_graph->drawTransparentWithTransDrawNode;
+ _drawNodeList.push_back(newDrawNode);
+ }
+}
+
+void PrinceEngine::showSpriteShadow(Graphics::Surface *shadowSurface, int destX, int destY, int destZ) {
+ if (spriteCheck(shadowSurface->w, shadowSurface->h, destX, destY)) {
+ destX -= _picWindowX;
+ destY -= _picWindowY;
+ DrawNode newDrawNode;
+ newDrawNode.posX = destX;
+ newDrawNode.posY = destY;
+ newDrawNode.posZ = destZ;
+ newDrawNode.width = 0;
+ newDrawNode.height = 0;
+ newDrawNode.s = shadowSurface;
+ newDrawNode.originalRoomSurface = nullptr;
+ newDrawNode.data = _graph->_shadowTable70;
+ newDrawNode.drawFunction = &_graph->drawAsShadowDrawNode;
+ _drawNodeList.push_back(newDrawNode);
+ }
+}
+
+void PrinceEngine::showAnim(Anim &anim) {
+ //ShowFrameCode
+ //ShowAnimFrame
+ int phase = anim._showFrame;
+ int phaseFrameIndex = anim._animData->getPhaseFrameIndex(phase);
+ int x = anim._x + anim._animData->getPhaseOffsetX(phase);
+ int y = anim._y + anim._animData->getPhaseOffsetY(phase);
+ int animFlag = anim._flags;
+ int checkMaskFlag = (animFlag & 1);
+ int maxFrontFlag = (animFlag & 2);
+ int specialZFlag = anim._nextAnim;
+ int z = anim._nextAnim;
+ Graphics::Surface *animSurface = anim._animData->getFrame(phaseFrameIndex);
+ int frameWidth = animSurface->w;
+ int frameHeight = animSurface->h;
+ int shadowZ = 0;
+
+ if (checkMaskFlag) {
+ if (!anim._nextAnim) {
+ z = y + frameHeight - 1;
+ }
+ checkMasks(x, y, frameWidth, frameHeight, z);
+ }
+
+ if (specialZFlag) {
+ z = specialZFlag;
+ } else if (maxFrontFlag) {
+ z = kMaxPicHeight + 1;
+ } else {
+ z = y + frameHeight - 1;
+ }
+ shadowZ = z;
+
+ anim._currX = x;
+ anim._currY = y;
+ anim._currW = frameWidth;
+ anim._currH = frameHeight;
+ showSprite(animSurface, x, y, z);
+
+ // make_special_shadow
+ if ((anim._flags & 0x80)) {
+ if (animSurface) {
+ DrawNode newDrawNode;
+ newDrawNode.posX = x;
+ newDrawNode.posY = y + animSurface->h - anim._shadowBack;
+ newDrawNode.posZ = Hero::kHeroShadowZ;
+ newDrawNode.width = 0;
+ newDrawNode.height = 0;
+ newDrawNode.scaleValue = _scaleValue;
+ newDrawNode.originalRoomSurface = nullptr;
+ newDrawNode.data = this;
+ newDrawNode.drawFunction = &Hero::showHeroShadow;
+ newDrawNode.s = animSurface;
+ _drawNodeList.push_back(newDrawNode);
+ }
+ }
+
+ //ShowFrameCodeShadow
+ //ShowAnimFrameShadow
+ if (anim._shadowData != nullptr) {
+ int shadowPhaseFrameIndex = anim._shadowData->getPhaseFrameIndex(phase);
+ int shadowX = anim._shadowData->getBaseX() + anim._shadowData->getPhaseOffsetX(phase);
+ int shadowY = anim._shadowData->getBaseY() + anim._shadowData->getPhaseOffsetY(phase);
+ Graphics::Surface *shadowSurface = anim._shadowData->getFrame(shadowPhaseFrameIndex);
+ int shadowFrameWidth = shadowSurface->w;
+ int shadowFrameHeight = shadowSurface->h;
+
+ if (checkMaskFlag) {
+ checkMasks(shadowX, shadowY, shadowFrameWidth, shadowFrameHeight, shadowY + shadowFrameWidth - 1);
+ }
+
+ if (!shadowZ) {
+ if (maxFrontFlag) {
+ shadowZ = kMaxPicHeight + 1;
+ } else {
+ shadowZ = shadowY + shadowFrameWidth - 1;
+ }
+ }
+ showSpriteShadow(shadowSurface, shadowX, shadowY, shadowZ);
+ }
+}
+
+void PrinceEngine::showNormAnims() {
+ for (int i = 0; i < kMaxNormAnims; i++) {
+ Anim &anim = _normAnimList[i];
+ if (anim._animData != nullptr) {
+ int phaseCount = anim._animData->getPhaseCount();
+ if (!anim._state) {
+ if (anim._frame == anim._lastFrame - 1) {
+ if (anim._loopType) {
+ if (anim._loopType == 1) {
+ anim._frame = anim._loopFrame;
+ } else {
+ continue;
+ }
+ }
+ } else {
+ anim._frame++;
+ }
+ anim._showFrame = anim._frame;
+ if (anim._showFrame >= phaseCount) {
+ anim._showFrame = phaseCount - 1;
+ }
+ showAnim(anim);
+ }
+ }
+ }
+}
+
+void PrinceEngine::setBackAnim(Anim &backAnim) {
+ int start = backAnim._basaData._start;
+ if (start != -1) {
+ backAnim._frame = start;
+ backAnim._showFrame = start;
+ backAnim._loopFrame = start;
+ }
+ int end = backAnim._basaData._end;
+ if (end != -1) {
+ backAnim._lastFrame = end;
+ }
+ backAnim._state = 0;
+}
+
+void PrinceEngine::showBackAnims() {
+ for (int i = 0; i < kMaxBackAnims; i++) {
+ BAS &seq = _backAnimList[i]._seq;
+ int activeSubAnim = seq._currRelative;
+ if (!_backAnimList[i].backAnims.empty()) {
+ if (_backAnimList[i].backAnims[activeSubAnim]._animData != nullptr) {
+ if (!_backAnimList[i].backAnims[activeSubAnim]._state) {
+ seq._counter++;
+ if (seq._type == 2) {
+ if (!seq._currRelative) {
+ if (seq._counter >= seq._data) {
+ if (seq._anims > 2) {
+ seq._currRelative = _randomSource.getRandomNumber(seq._anims - 2) + 1;
+ activeSubAnim = seq._currRelative;
+ seq._current = _backAnimList[i].backAnims[activeSubAnim]._basaData._num;
+ }
+ setBackAnim(_backAnimList[i].backAnims[activeSubAnim]);
+ seq._counter = 0;
+ }
+ }
+ }
+
+ if (seq._type == 3) {
+ if (!seq._currRelative) {
+ if (seq._counter < seq._data2) {
+ continue;
+ } else {
+ setBackAnim(_backAnimList[i].backAnims[activeSubAnim]);
+ }
+ }
+ }
+
+ if (_backAnimList[i].backAnims[activeSubAnim]._frame == _backAnimList[i].backAnims[activeSubAnim]._lastFrame - 1) {
+ _backAnimList[i].backAnims[activeSubAnim]._frame = _backAnimList[i].backAnims[activeSubAnim]._loopFrame;
+ switch (seq._type) {
+ case 1:
+ if (seq._anims > 1) {
+ int rnd;
+ do {
+ rnd = _randomSource.getRandomNumber(seq._anims - 1);
+ } while (rnd == seq._currRelative);
+ seq._currRelative = rnd;
+ seq._current = _backAnimList[i].backAnims[rnd]._basaData._num;
+ activeSubAnim = rnd;
+ setBackAnim(_backAnimList[i].backAnims[activeSubAnim]);
+ seq._counter = 0;
+ }
+ break;
+ case 2:
+ if (seq._currRelative) {
+ seq._currRelative = 0;
+ seq._current = _backAnimList[i].backAnims[0]._basaData._num;
+ activeSubAnim = 0;
+ setBackAnim(_backAnimList[i].backAnims[activeSubAnim]);
+ seq._counter = 0;
+ }
+ break;
+ case 3:
+ seq._currRelative = 0;
+ seq._current = _backAnimList[i].backAnims[0]._basaData._num;
+ seq._counter = 0;
+ seq._data2 = _randomSource.getRandomNumber(seq._data - 1);
+ continue; // for bug in original game
+ break;
+ }
+ } else {
+ _backAnimList[i].backAnims[activeSubAnim]._frame++;
+ }
+ _backAnimList[i].backAnims[activeSubAnim]._showFrame = _backAnimList[i].backAnims[activeSubAnim]._frame;
+ showAnim(_backAnimList[i].backAnims[activeSubAnim]);
+ }
+ }
+ }
+ }
+}
+
+void PrinceEngine::removeSingleBackAnim(int slot) {
+ if (!_backAnimList[slot].backAnims.empty()) {
+ for (uint j = 0; j < _backAnimList[slot].backAnims.size(); j++) {
+ if (_backAnimList[slot].backAnims[j]._animData != nullptr) {
+ delete _backAnimList[slot].backAnims[j]._animData;
+ _backAnimList[slot].backAnims[j]._animData = nullptr;
+ }
+ if (_backAnimList[slot].backAnims[j]._shadowData != nullptr) {
+ delete _backAnimList[slot].backAnims[j]._shadowData;
+ _backAnimList[slot].backAnims[j]._shadowData = nullptr;
+ }
+ }
+ _backAnimList[slot].backAnims.clear();
+ _backAnimList[slot]._seq._currRelative = 0;
+ }
+}
+
+void PrinceEngine::clearBackAnimList() {
+ for (int i = 0; i < kMaxBackAnims; i++) {
+ removeSingleBackAnim(i);
+ }
+}
+
+void PrinceEngine::grabMap() {
+ _graph->_frontScreen->copyFrom(*_roomBmp->getSurface());
+ showObjects();
+ runDrawNodes();
+ _graph->_mapScreen->copyFrom(*_graph->_frontScreen);
+}
+
+void PrinceEngine::initZoomIn(int slot) {
+ freeZoomObject(slot);
+ Object *object = _objList[slot];
+ if (object != nullptr) {
+ Graphics::Surface *zoomSource = object->getSurface();
+ if (zoomSource != nullptr) {
+ object->_flags |= 0x8000;
+ object->_zoomSurface = new Graphics::Surface();
+ object->_zoomSurface->create(zoomSource->w, zoomSource->h, Graphics::PixelFormat::createFormatCLUT8());
+ object->_zoomSurface->fillRect(Common::Rect(zoomSource->w, zoomSource->h), 0xFF);
+ object->_zoomTime = 20;
+ }
+ }
+}
+
+void PrinceEngine::initZoomOut(int slot) {
+ freeZoomObject(slot);
+ Object *object = _objList[slot];
+ if (object != nullptr) {
+ Graphics::Surface *zoomSource = object->getSurface();
+ if (zoomSource != nullptr) {
+ object->_flags |= 0x4000;
+ object->_zoomSurface = new Graphics::Surface();
+ object->_zoomSurface->copyFrom(*zoomSource);
+ object->_zoomTime = 10;
+ }
+ }
+}
+
+void PrinceEngine::doZoomIn(int slot) {
+ Object *object = _objList[slot];
+ if (object != nullptr) {
+ Graphics::Surface *orgSurface = object->getSurface();
+ if (orgSurface != nullptr) {
+ byte *src1 = (byte *)orgSurface->getBasePtr(0, 0);
+ byte *dst1 = (byte *)object->_zoomSurface->getBasePtr(0, 0);
+ int x = 0;
+ int surfaceHeight = orgSurface->h;
+ for (int y = 0; y < surfaceHeight; y++) {
+ byte *src2 = src1;
+ byte *dst2 = dst1;
+ int w = orgSurface->w - x;
+ src2 += x;
+ dst2 += x;
+ while (w > 0) {
+ int randVal = _randomSource.getRandomNumber(zoomInStep - 1);
+ if (randVal < w) {
+ *(dst2 + randVal) = *(src2 + randVal);
+ src2 += zoomInStep;
+ dst2 += zoomInStep;
+ } else if (y + 1 != surfaceHeight) {
+ *(dst1 + orgSurface->pitch + randVal - w) = *(src1 + orgSurface->pitch + randVal - w);
+ }
+ w -= zoomInStep;
+ }
+ x = -1 * w;
+ src1 += orgSurface->pitch;
+ dst1 += orgSurface->pitch;
+ }
+ }
+ }
+}
+
+void PrinceEngine::doZoomOut(int slot) {
+ Object *object = _objList[slot];
+ if (object != nullptr) {
+ Graphics::Surface *orgSurface = object->getSurface();
+ if (orgSurface != nullptr) {
+ byte *dst1 = (byte *)object->_zoomSurface->getBasePtr(0, 0);
+ int x = 0;
+ int surfaceHeight = orgSurface->h;
+ for (int y = 0; y < surfaceHeight; y++) {
+ byte *dst2 = dst1;
+ int w = orgSurface->w - x;
+ dst2 += x;
+ while (w > 0) {
+ int randVal = _randomSource.getRandomNumber(zoomInStep - 1);
+ if (randVal < w) {
+ *(dst2 + randVal) = 255;
+ dst2 += zoomInStep;
+ } else if (y + 1 != surfaceHeight) {
+ *(dst1 + orgSurface->pitch + randVal - w) = 255;
+ }
+ w -= zoomInStep;
+ }
+ x = -1 * w;
+ dst1 += orgSurface->pitch;
+ }
+ }
+ }
+}
+
+void PrinceEngine::freeZoomObject(int slot) {
+ Object *object = _objList[slot];
+ if (object != nullptr) {
+ if (object->_zoomSurface != nullptr) {
+ object->_zoomSurface->free();
+ delete object->_zoomSurface;
+ object->_zoomSurface = nullptr;
+ }
+ }
+}
+
+void PrinceEngine::showObjects() {
+ for (int i = 0; i < kMaxObjects; i++) {
+ int nr = _objSlot[i];
+ if (nr != 0xFF) {
+ Graphics::Surface *objSurface = nullptr;
+ if ((_objList[nr]->_flags & 0x8000)) {
+ _objList[nr]->_zoomTime--;
+ if (!_objList[nr]->_zoomTime) {
+ freeZoomObject(nr);
+ _objList[nr]->_flags &= 0x7FFF;
+ objSurface = _objList[nr]->getSurface();
+ } else {
+ doZoomIn(nr);
+ objSurface = _objList[nr]->_zoomSurface;
+ }
+ } else if ((_objList[nr]->_flags & 0x4000)) {
+ _objList[nr]->_zoomTime--;
+ if (!_objList[nr]->_zoomTime) {
+ freeZoomObject(nr);
+ _objList[nr]->_flags &= 0xBFFF;
+ objSurface = _objList[nr]->getSurface();
+ } else {
+ doZoomOut(nr);
+ objSurface = _objList[nr]->_zoomSurface;
+ }
+ } else {
+ objSurface = _objList[nr]->getSurface();
+ }
+
+ if (objSurface != nullptr) {
+ if (spriteCheck(objSurface->w, objSurface->h, _objList[nr]->_x, _objList[nr]->_y)) {
+ int destX = _objList[nr]->_x - _picWindowX;
+ int destY = _objList[nr]->_y - _picWindowY;
+ DrawNode newDrawNode;
+ newDrawNode.posX = destX;
+ newDrawNode.posY = destY;
+ newDrawNode.posZ = _objList[nr]->_z;
+ newDrawNode.width = 0;
+ newDrawNode.height = 0;
+ newDrawNode.s = objSurface;
+ newDrawNode.originalRoomSurface = nullptr;
+ if ((_objList[nr]->_flags & 0x2000)) {
+ newDrawNode.data = nullptr;
+ newDrawNode.drawFunction = &_graph->drawBackSpriteDrawNode;
+ } else {
+ newDrawNode.data = _transTable;
+ if (_flags->getFlagValue(Flags::NOANTIALIAS)) {
+ newDrawNode.drawFunction = &_graph->drawTransparentDrawNode;
+ } else {
+ newDrawNode.drawFunction = &_graph->drawTransparentWithTransDrawNode;
+ }
+ }
+ _drawNodeList.push_back(newDrawNode);
+ }
+
+ if ((_objList[nr]->_flags & 1)) {
+ checkMasks(_objList[nr]->_x, _objList[nr]->_y, objSurface->w, objSurface->h, _objList[nr]->_z);
+ }
+ }
+ }
+ }
+}
+
+void PrinceEngine::showParallax() {
+ if (!_pscrList.empty()) {
+ for (uint i = 0; i < _pscrList.size(); i++) {
+ Graphics::Surface *pscrSurface = _pscrList[i]->getSurface();
+ if (pscrSurface != nullptr) {
+ int x = _pscrList[i]->_x - (_pscrList[i]->_step * _picWindowX / 4);
+ int y = _pscrList[i]->_y;
+ int z = PScr::kPScrZ;
+ if (spriteCheck(pscrSurface->w, pscrSurface->h, x, y)) {
+ showSprite(pscrSurface, x, y, z);
+ }
+ }
+ }
+ }
+}
+
+bool PrinceEngine::compareDrawNodes(DrawNode d1, DrawNode d2) {
+ if (d1.posZ < d2.posZ) {
+ return true;
+ }
+ return false;
+}
+
+void PrinceEngine::runDrawNodes() {
+ Common::sort(_drawNodeList.begin(), _drawNodeList.end(), compareDrawNodes);
+
+ for (uint i = 0; i < _drawNodeList.size(); i++) {
+ (*_drawNodeList[i].drawFunction)(_graph->_frontScreen, &_drawNodeList[i]);
+ }
+ _graph->change();
+}
+
+void PrinceEngine::drawScreen() {
+ if (!_showInventoryFlag || _inventoryBackgroundRemember) {
+ clsMasks();
+
+ _mainHero->showHero();
+ _mainHero->scrollHero();
+ _mainHero->drawHero();
+
+ _secondHero->showHero();
+ _secondHero->_drawX -= _picWindowX;
+ _secondHero->drawHero();
+
+ const Graphics::Surface *roomSurface;
+ if (_locationNr != 50) {
+ roomSurface = _roomBmp->getSurface();
+ } else {
+ roomSurface = _graph->_mapScreen;
+ }
+ Graphics::Surface visiblePart;
+ if (roomSurface) {
+ visiblePart = roomSurface->getSubArea(Common::Rect(_picWindowX, 0, roomSurface->w, roomSurface->h));
+ _graph->draw(_graph->_frontScreen, &visiblePart);
+ }
+
+ showBackAnims();
+
+ showNormAnims();
+
+ playNextFLCFrame();
+
+ showObjects();
+
+ if (roomSurface) {
+ insertMasks(&visiblePart);
+ }
+
+ showParallax();
+
+ runDrawNodes();
+
+ _drawNodeList.clear();
+
+ if (!_inventoryBackgroundRemember && !_dialogFlag) {
+ if (!_optionsFlag) {
+ _selectedMob = checkMob(_graph->_frontScreen, _mobList, true);
+ }
+ showTexts(_graph->_frontScreen);
+ checkOptions();
+ } else {
+ _inventoryBackgroundRemember = false;
+ }
+
+ showPower();
+
+ getDebugger()->onFrame();
+
+ } else {
+ displayInventory();
+ }
+}
+
+void PrinceEngine::blackPalette() {
+ byte *paletteBackup = (byte *)malloc(256 * 3);
+ byte *blackPalette1 = (byte *)malloc(256 * 3);
+
+ int fadeStep = kFadeStep - 1;
+ for (int i = 0; i < kFadeStep; i++) {
+ _system->getPaletteManager()->grabPalette(paletteBackup, 0, 256);
+ for (int j = 0; j < 256; j++) {
+ blackPalette1[3 * j] = paletteBackup[3 * j] * fadeStep / 4;
+ blackPalette1[3 * j + 1] = paletteBackup[3 * j + 1] * fadeStep / 4;
+ blackPalette1[3 * j + 2] = paletteBackup[3 * j + 2] * fadeStep / 4;
+ }
+ fadeStep--;
+ _graph->setPalette(blackPalette1);
+ _system->updateScreen();
+ Common::Event event;
+ Common::EventManager *eventMan = _system->getEventManager();
+ eventMan->pollEvent(event);
+ if (shouldQuit()) {
+ free(paletteBackup);
+ free(blackPalette1);
+ return;
+ }
+ pausePrinceEngine();
+ }
+ free(paletteBackup);
+ free(blackPalette1);
+}
+
+void PrinceEngine::setPalette(const byte *palette) {
+ if (palette != nullptr) {
+ byte *blackPalette_ = (byte *)malloc(256 * 3);
+ int fadeStep = 0;
+ for (int i = 0; i <= kFadeStep; i++) {
+ for (int j = 0; j < 256; j++) {
+ blackPalette_[3 * j] = palette[3 * j] * fadeStep / 4;
+ blackPalette_[3 * j + 1] = palette[3 * j + 1] * fadeStep / 4;
+ blackPalette_[3 * j + 2] = palette[3 * j + 2] * fadeStep / 4;
+ }
+ fadeStep++;
+ _graph->setPalette(blackPalette_);
+ _system->updateScreen();
+ Common::Event event;
+ Common::EventManager *eventMan = _system->getEventManager();
+ eventMan->pollEvent(event);
+ if (shouldQuit()) {
+ _graph->setPalette(palette);
+ free(blackPalette_);
+ return;
+ }
+ pausePrinceEngine();
+ }
+ _graph->setPalette(palette);
+ free(blackPalette_);
+ }
+}
+
+void PrinceEngine::pausePrinceEngine(int fps) {
+ int delay = 1000 / fps - int32(_system->getMillis() - _currentTime);
+ delay = delay < 0 ? 0 : delay;
+ _system->delayMillis(delay);
+ _currentTime = _system->getMillis();
+}
+
+void PrinceEngine::addInv(int heroId, int item, bool addItemQuiet) {
+ Hero *hero = nullptr;
+ if (!heroId) {
+ hero = _mainHero;
+ } else if (heroId == 1) {
+ hero = _secondHero;
+ }
+ if (hero != nullptr) {
+ if (hero->_inventory.size() < kMaxItems) {
+ if (item != 0x7FFF) {
+ hero->_inventory.push_back(item);
+ }
+ if (!addItemQuiet) {
+ addInvObj();
+ }
+ _interpreter->setResult(0);
+ } else {
+ _interpreter->setResult(1);
+ }
+ }
+}
+
+void PrinceEngine::remInv(int heroId, int item) {
+ Hero *hero = nullptr;
+ if (!heroId) {
+ hero = _mainHero;
+ } else if (heroId == 1) {
+ hero = _secondHero;
+ }
+ if (hero != nullptr) {
+ for (uint i = 0; i < hero->_inventory.size(); i++) {
+ if (hero->_inventory[i] == item) {
+ hero->_inventory.remove_at(i);
+ _interpreter->setResult(0);
+ return;
+ }
+ }
+ }
+ _interpreter->setResult(1);
+}
+
+void PrinceEngine::clearInv(int heroId) {
+ switch (heroId) {
+ case 0:
+ _mainHero->_inventory.clear();
+ break;
+ case 1:
+ _secondHero->_inventory.clear();
+ break;
+ default:
+ error("clearInv() - wrong hero slot");
+ break;
+ }
+}
+
+void PrinceEngine::swapInv(int heroId) {
+ Common::Array<int> tempInv;
+ Hero *hero = nullptr;
+ if (!heroId) {
+ hero = _mainHero;
+ } else if (heroId == 1) {
+ hero = _secondHero;
+ }
+ if (hero != nullptr) {
+ for (uint i = 0; i < hero->_inventory.size(); i++) {
+ tempInv.push_back(hero->_inventory[i]);
+ }
+ hero->_inventory.clear();
+ for (uint i = 0; i < hero->_inventory2.size(); i++) {
+ hero->_inventory.push_back(hero->_inventory2[i]);
+ }
+ hero->_inventory2.clear();
+ for (uint i = 0; i < tempInv.size(); i++) {
+ hero->_inventory2.push_back(tempInv[i]);
+ }
+ tempInv.clear();
+ }
+}
+
+void PrinceEngine::addInvObj() {
+ changeCursor(0);
+ prepareInventoryToView();
+
+ _inventoryBackgroundRemember = true;
+ drawScreen();
+
+ Graphics::Surface *suitcase = _suitcaseBmp->getSurface();
+
+ if (!_flags->getFlagValue(Flags::CURSEBLINK)) {
+
+ loadSample(27, "PRZEDMIO.WAV");
+ playSample(27, 0);
+
+ _mst_shadow2 = 1;
+
+ while (_mst_shadow2 < 512) {
+ rememberScreenInv();
+ _graph->drawTransparentSurface(_graph->_screenForInventory, 0, 0, suitcase);
+ drawInvItems();
+ _graph->update(_graph->_screenForInventory);
+ _mst_shadow2 += 50;
+ Common::Event event;
+ Common::EventManager *eventMan = _system->getEventManager();
+ eventMan->pollEvent(event);
+ if (shouldQuit()) {
+ return;
+ }
+ pausePrinceEngine();
+ }
+ while (_mst_shadow2 > 256) {
+ rememberScreenInv();
+ _graph->drawTransparentSurface(_graph->_screenForInventory, 0, 0, suitcase);
+ drawInvItems();
+ _graph->update(_graph->_screenForInventory);
+ _mst_shadow2 -= 42;
+ Common::Event event;
+ Common::EventManager *eventMan = _system->getEventManager();
+ eventMan->pollEvent(event);
+ if (shouldQuit()) {
+ return;
+ }
+ pausePrinceEngine();
+ }
+ } else {
+ //CURSEBLINK:
+ for (int i = 0; i < 3; i++) {
+ _mst_shadow2 = 256;
+ while (_mst_shadow2 < 512) {
+ rememberScreenInv();
+ _graph->drawTransparentSurface(_graph->_screenForInventory, 0, 0, suitcase);
+ drawInvItems();
+ _graph->update(_graph->_screenForInventory);
+ _mst_shadow2 += 50;
+ Common::Event event;
+ Common::EventManager *eventMan = _system->getEventManager();
+ eventMan->pollEvent(event);
+ if (shouldQuit()) {
+ return;
+ }
+ pausePrinceEngine();
+ }
+ while (_mst_shadow2 > 256) {
+ rememberScreenInv();
+ _graph->drawTransparentSurface(_graph->_screenForInventory, 0, 0, suitcase);
+ drawInvItems();
+ _graph->update(_graph->_screenForInventory);
+ _mst_shadow2 -= 50;
+ Common::Event event;
+ Common::EventManager *eventMan = _system->getEventManager();
+ eventMan->pollEvent(event);
+ if (shouldQuit()) {
+ return;
+ }
+ pausePrinceEngine();
+ }
+ }
+ }
+ _mst_shadow2 = 0;
+ for (int i = 0; i < 20; i++) {
+ rememberScreenInv();
+ _graph->drawTransparentSurface(_graph->_screenForInventory, 0, 0, suitcase);
+ drawInvItems();
+ _graph->update(_graph->_screenForInventory);
+ Common::Event event;
+ Common::EventManager *eventMan = _system->getEventManager();
+ eventMan->pollEvent(event);
+ if (shouldQuit()) {
+ return;
+ }
+ pausePrinceEngine();
+ }
+}
+
+void PrinceEngine::rememberScreenInv() {
+ _graph->_screenForInventory->copyFrom(*_graph->_frontScreen);
+}
+
+void PrinceEngine::inventoryFlagChange(bool inventoryState) {
+ if (inventoryState) {
+ _showInventoryFlag = true;
+ _inventoryBackgroundRemember = true;
+ } else {
+ _showInventoryFlag = false;
+ }
+}
+
+void PrinceEngine::prepareInventoryToView() {
+ _invMobList.clear();
+ int invItem = _mainHero->_inventory.size();
+ _invLine = invItem / 3;
+ if (invItem % 3) {
+ _invLine++;
+ }
+ if (_invLine < 4) {
+ _invLine = 4;
+ }
+ _maxInvW = (374 - 2 * _invLine) / _invLine;
+ _invLineW = _maxInvW - 2;
+
+ int currInvX = _invLineX;
+ int currInvY = _invLineY;
+
+ Common::MemoryReadStream stream(_invTxt, _invTxtSize);
+ byte c;
+
+ uint item = 0;
+ for (int i = 0; i < _invLines; i++) {
+ for (int j = 0; j < _invLine; j++) {
+ Mob tempMobItem;
+ if (item < _mainHero->_inventory.size()) {
+ int itemNr = _mainHero->_inventory[item];
+ tempMobItem._visible = 0;
+ tempMobItem._mask = itemNr;
+ tempMobItem._rect = Common::Rect(currInvX + _picWindowX, currInvY, currInvX + _picWindowX + _invLineW - 1, currInvY + _invLineH - 1);
+ tempMobItem._type = 0; // to work with checkMob()
+
+ tempMobItem._name = "";
+ tempMobItem._examText = "";
+ int txtOffset = READ_LE_UINT32(&_invTxt[itemNr * 8]);
+ int examTxtOffset = READ_LE_UINT32(&_invTxt[itemNr * 8 + 4]);
+
+ stream.seek(txtOffset);
+ while ((c = stream.readByte())) {
+ tempMobItem._name += c;
+ }
+
+ stream.seek(examTxtOffset);
+ while ((c = stream.readByte())) {
+ tempMobItem._examText += c;
+ }
+ _invMobList.push_back(tempMobItem);
+ }
+ currInvX += _invLineW + _invLineSkipX;
+ item++;
+ }
+ currInvX = _invLineX;
+ currInvY += _invLineSkipY + _invLineH;
+ }
+}
+
+void PrinceEngine::drawInvItems() {
+ int currInvX = _invLineX;
+ int currInvY = _invLineY;
+ uint item = 0;
+ for (int i = 0; i < _invLines; i++) {
+ for (int j = 0; j < _invLine; j++) {
+ if (item < _mainHero->_inventory.size()) {
+ int itemNr = _mainHero->_inventory[item];
+ _mst_shadow = 0;
+ if (_mst_shadow2) {
+ if (!_flags->getFlagValue(Flags::CURSEBLINK)) {
+ if (item + 1 == _mainHero->_inventory.size()) { // last item in inventory
+ _mst_shadow = 1;
+ }
+ } else if (itemNr == 1 || itemNr == 3 || itemNr == 4 || itemNr == 7) {
+ _mst_shadow = 1;
+ }
+ }
+
+ int drawX = currInvX;
+ int drawY = currInvY;
+ Graphics::Surface *itemSurface = nullptr;
+ if (itemNr != 68) {
+ itemSurface = _allInvList[itemNr].getSurface();
+ if (itemSurface->h < _maxInvH) {
+ drawY += (_maxInvH - itemSurface->h) / 2;
+ }
+ } else {
+ // candle item:
+ if (_candleCounter == 8) {
+ _candleCounter = 0;
+ }
+ itemNr = _candleCounter;
+ _candleCounter++;
+ itemNr &= 7;
+ itemNr += 71;
+ itemSurface = _allInvList[itemNr].getSurface();
+ drawY += _allInvList[itemNr]._y + (_maxInvH - 76) / 2 - 200;
+ }
+ if (itemSurface->w < _maxInvW) {
+ drawX += (_maxInvW - itemSurface->w) / 2;
+ }
+ if (!_mst_shadow) {
+ _graph->drawTransparentSurface(_graph->_screenForInventory, drawX, drawY, itemSurface);
+ } else {
+ _mst_shadow = _mst_shadow2;
+ _graph->drawTransparentWithBlendSurface(_graph->_screenForInventory, drawX, drawY, itemSurface);
+ }
+ }
+ currInvX += _invLineW + _invLineSkipX;
+ item++;
+ }
+ currInvX = _invLineX;
+ currInvY += _invLineSkipY + _invLineH;
+ }
+}
+
+void PrinceEngine::walkTo() {
+ if (_mainHero->_visible) {
+ _mainHero->freeHeroAnim();
+ _mainHero->freeOldMove();
+ _interpreter->storeNewPC(_script->_scriptInfo.usdCode);
+ int destX, destY;
+ if (_optionsMob != -1) {
+ destX = _mobList[_optionsMob]._examPosition.x;
+ destY = _mobList[_optionsMob]._examPosition.y;
+ _mainHero->_destDirection = _mobList[_optionsMob]._examDirection;
+ } else {
+ Common::Point mousePos = _system->getEventManager()->getMousePos();
+ destX = mousePos.x + _picWindowX;
+ destY = mousePos.y + _picWindowY;
+ _mainHero->_destDirection = 0;
+ }
+ _mainHero->_coords = makePath(kMainHero, _mainHero->_middleX, _mainHero->_middleY, destX, destY);
+ if (_mainHero->_coords != nullptr) {
+ _mainHero->_currCoords = _mainHero->_coords;
+ _mainHero->_dirTab = _directionTable;
+ _mainHero->_currDirTab = _directionTable;
+ _directionTable = nullptr;
+ _mainHero->_state = Hero::kHeroStateMove;
+ moveShandria();
+ }
+ }
+}
+
+void PrinceEngine::moveRunHero(int heroId, int x, int y, int dir, bool runHeroFlag) {
+ Hero *hero = nullptr;
+ if (!heroId) {
+ hero = _mainHero;
+ } else if (heroId == 1) {
+ hero = _secondHero;
+ }
+
+ if (hero != nullptr) {
+ if (dir) {
+ hero->_destDirection = dir;
+ }
+ if (x || y) {
+ hero->freeOldMove();
+ hero->_coords = makePath(heroId, hero->_middleX, hero->_middleY, x, y);
+ if (hero->_coords != nullptr) {
+ hero->_currCoords = hero->_coords;
+ hero->_dirTab = _directionTable;
+ hero->_currDirTab = _directionTable;
+ _directionTable = nullptr;
+ if (runHeroFlag) {
+ hero->_state = Hero::kHeroStateRun;
+ } else {
+ hero->_state = Hero::kHeroStateMove;
+ }
+ if (heroId == kMainHero && _mouseFlag) {
+ moveShandria();
+ }
+ }
+ } else {
+ hero->freeOldMove();
+ hero->_state = Hero::kHeroStateTurn;
+ }
+ hero->freeHeroAnim();
+ hero->_visible = 1;
+ }
+}
+
+void PrinceEngine::leftMouseButton() {
+ _flags->setFlagValue(Flags::ESCAPED2, 1); // skip intro animation
+ _flags->setFlagValue(Flags::LMOUSE, 1);
+ if (_flags->getFlagValue(Flags::POWERENABLED)) {
+ _flags->setFlagValue(Flags::MBFLAG, 1);
+ }
+ if (_mouseFlag) {
+ int option = 0;
+ int optionEvent = -1;
+
+ if (_optionsFlag) {
+ if (_optionEnabled < _optionsNumber && _optionEnabled != -1) {
+ option = _optionEnabled;
+ _optionsFlag = 0;
+ } else {
+ return;
+ }
+ } else {
+ _optionsMob = _selectedMob;
+ if (_optionsMob == -1) {
+ walkTo();
+ return;
+ }
+ option = 0;
+ }
+ //do_option
+ if (_currentPointerNumber != 2) {
+ //skip_use_code
+ int optionScriptOffset = _room->getOptionOffset(option);
+ if (optionScriptOffset != 0) {
+ optionEvent = _script->scanMobEvents(_optionsMob, optionScriptOffset);
+ }
+ if (optionEvent == -1) {
+ if (!option) {
+ walkTo();
+ return;
+ } else {
+ optionEvent = _script->getOptionStandardOffset(option);
+ }
+ }
+ } else if (_selectedMode) {
+ //give_item
+ if (_room->_itemGive) {
+ optionEvent = _script->scanMobEventsWithItem(_optionsMob, _room->_itemGive, _selectedItem);
+ }
+ if (optionEvent == -1) {
+ //standard_giveitem
+ optionEvent = _script->_scriptInfo.stdGiveItem;
+ }
+ } else {
+ if (_room->_itemUse) {
+ optionEvent = _script->scanMobEventsWithItem(_optionsMob, _room->_itemUse, _selectedItem);
+ _flags->setFlagValue(Flags::SELITEM, _selectedItem);
+ }
+ if (optionEvent == -1) {
+ //standard_useitem
+ optionEvent = _script->_scriptInfo.stdUseItem;
+ }
+ }
+ _interpreter->storeNewPC(optionEvent);
+ _flags->setFlagValue(Flags::CURRMOB, _selectedMob);
+ _selectedMob = -1;
+ _optionsMob = -1;
+ } else {
+ if (!_flags->getFlagValue(Flags::POWERENABLED)) {
+ if (!_flags->getFlagValue(Flags::NOCLSTEXT)) {
+ for (int slot = 0; slot < kMaxTexts; slot++) {
+ if (slot != 9) {
+ Text& text = _textSlots[slot];
+ if (!text._str) {
+ continue;
+ }
+ text._str = 0;
+ text._time = 0;
+ }
+ }
+ _mainHero->_talkTime = 0;
+ _secondHero->_talkTime = 0;
+ }
+ }
+ }
+}
+
+void PrinceEngine::rightMouseButton() {
+ if (_flags->getFlagValue(Flags::POWERENABLED)) {
+ _flags->setFlagValue(Flags::MBFLAG, 2);
+ }
+ if (_mouseFlag && _mouseFlag != 3) {
+ _mainHero->freeOldMove();
+ _secondHero->freeOldMove();
+ _interpreter->storeNewPC(0);
+ if (_currentPointerNumber < 2) {
+ enableOptions(true);
+ } else {
+ _currentPointerNumber = 1;
+ changeCursor(1);
+ }
+ }
+}
+
+void PrinceEngine::inventoryLeftMouseButton() {
+ if (!_mouseFlag) {
+ _textSlots[0]._time = 0;
+ _textSlots[0]._str = nullptr;
+ stopSample(28);
+ }
+
+ if (_optionsFlag == 1) {
+ if (_selectedMob != -1) {
+ if (_optionEnabled < _invOptionsNumber) {
+ _optionsFlag = 0;
+ } else {
+ return;
+ }
+ } else {
+ error("PrinceEngine::inventoryLeftMouseButton() - optionsFlag = 1, selectedMob = 0");
+ if (_currentPointerNumber == 2) {
+ changeCursor(1);
+ _currentPointerNumber = 1;
+ _selectedMob = -1;
+ _optionsMob = -1;
+ return;
+ } else {
+ return;
+ }
+ }
+ } else {
+ if (_selectedMob != -1) {
+ if (_currentPointerNumber != 2) {
+ if (_invMobList[_selectedMob]._mask != 29) {
+ _optionEnabled = 0;
+ } else {
+ // map item
+ _optionEnabled = 1;
+ }
+ } else {
+ //use_item_on_item
+ int invObjUU = _script->scanMobEventsWithItem(_invMobList[_selectedMob]._mask, _script->_scriptInfo.invObjUU, _selectedItem);
+ if (invObjUU == -1) {
+ int textNr = 80011; // "I can't do it."
+ if (_selectedItem == 31 || _invMobList[_selectedMob]._mask == 31) {
+ textNr = 80020; // "Nothing is happening."
+ }
+ _interpreter->setCurrentString(textNr);
+ printAt(0, 216, (char *)_variaTxt->getString(textNr - 80000), kNormalWidth / 2, 100);
+ setVoice(0, 28, 1);
+ playSample(28, 0);
+ _selectedMob = -1;
+ _optionsMob = -1;
+ return;
+ } else {
+ _interpreter->storeNewPC(invObjUU);
+ _flags->setFlagValue(Flags::CURRMOB, _invMobList[_selectedMob]._mask);
+ _showInventoryFlag = false;
+ }
+ }
+ } else {
+ return;
+ }
+ }
+ //do_option
+ if (_optionEnabled == 0) {
+ int invObjExamEvent = _script->scanMobEvents(_invMobList[_selectedMob]._mask, _script->_scriptInfo.invObjExam);
+ if (invObjExamEvent == -1) {
+ // do_standard
+ printAt(0, 216, (char *)_invMobList[_selectedMob]._examText.c_str(), kNormalWidth / 2, _invExamY);
+ _interpreter->setCurrentString(_invMobList[_selectedMob]._mask + 70000);
+ setVoice(0, 28, 1);
+ playSample(28, 0);
+ // disableuseuse
+ changeCursor(0);
+ _currentPointerNumber = 1;
+ } else {
+ _interpreter->storeNewPC(invObjExamEvent);
+ _flags->setFlagValue(Flags::CURRMOB, _invMobList[_selectedMob]._mask);
+ _showInventoryFlag = false;
+ }
+ } else if (_optionEnabled == 1) {
+ // not_examine
+ int invObjUse = _script->scanMobEvents(_invMobList[_selectedMob]._mask, _script->_scriptInfo.invObjUse);
+ if (invObjUse == -1) {
+ // do_standard_use
+ _selectedMode = 0;
+ _selectedItem = _invMobList[_selectedMob]._mask;
+ makeInvCursor(_invMobList[_selectedMob]._mask);
+ _currentPointerNumber = 2;
+ changeCursor(2);
+ } else {
+ _interpreter->storeNewPC(invObjUse);
+ _flags->setFlagValue(Flags::CURRMOB, _invMobList[_selectedMob]._mask);
+ _showInventoryFlag = false;
+ }
+ } else if (_optionEnabled == 4) {
+ // do_standard_give
+ _selectedMode = 1;
+ _selectedItem = _invMobList[_selectedMob]._mask;
+ makeInvCursor(_invMobList[_selectedMob]._mask);
+ _currentPointerNumber = 2;
+ changeCursor(2);
+ } else {
+ // use_item_on_item
+ int invObjUU = _script->scanMobEventsWithItem(_invMobList[_selectedMob]._mask, _script->_scriptInfo.invObjUU, _selectedItem);
+ if (invObjUU == -1) {
+ int textNr = 80011; // "I can't do it."
+ if (_selectedItem == 31 || _invMobList[_selectedMob]._mask == 31) {
+ textNr = 80020; // "Nothing is happening."
+ }
+ _interpreter->setCurrentString(textNr);
+ printAt(0, 216, (char *)_variaTxt->getString(textNr - 80000), kNormalWidth / 2, 100);
+ setVoice(0, 28, 1);
+ playSample(28, 0);
+ } else {
+ _interpreter->storeNewPC(invObjUU);
+ _flags->setFlagValue(Flags::CURRMOB, _invMobList[_selectedMob]._mask);
+ _showInventoryFlag = false;
+ }
+ }
+ _selectedMob = -1;
+ _optionsMob = -1;
+}
+
+void PrinceEngine::inventoryRightMouseButton() {
+ if (_textSlots[0]._str == nullptr) {
+ enableOptions(false);
+ }
+}
+
+void PrinceEngine::enableOptions(bool checkType) {
+ if (_optionsFlag != 1) {
+ changeCursor(1);
+ _currentPointerNumber = 1;
+ if (_selectedMob != -1) {
+ if (checkType) {
+ if (_mobList[_selectedMob]._type & 0x100) {
+ return;
+ }
+ }
+ Common::Point mousePos = _system->getEventManager()->getMousePos();
+ int x1 = mousePos.x - _optionsWidth / 2;
+ int x2 = mousePos.x + _optionsWidth / 2;
+ if (x1 < 0) {
+ x1 = 0;
+ x2 = _optionsWidth;
+ } else if (x2 >= kNormalWidth) {
+ x1 = kNormalWidth - _optionsWidth;
+ x2 = kNormalWidth;
+ }
+ int y1 = mousePos.y - 10;
+ if (y1 < 0) {
+ y1 = 0;
+ }
+ if (y1 + _optionsHeight >= kNormalHeight) {
+ y1 = kNormalHeight - _optionsHeight;
+ }
+ _optionsMob = _selectedMob;
+ _optionsX = x1;
+ _optionsY = y1;
+ _optionsFlag = 1;
+ }
+ }
+}
+
+void PrinceEngine::checkOptions() {
+ if (_optionsFlag) {
+ Common::Rect optionsRect(_optionsX, _optionsY, _optionsX + _optionsWidth, _optionsY + _optionsHeight);
+ Common::Point mousePos = _system->getEventManager()->getMousePos();
+ if (!optionsRect.contains(mousePos)) {
+ _optionsFlag = 0;
+ _selectedMob = -1;
+ return;
+ }
+ _graph->drawAsShadowSurface(_graph->_frontScreen, _optionsX, _optionsY, _optionsPic, _graph->_shadowTable50);
+
+ _optionEnabled = -1;
+ int optionsYCord = mousePos.y - (_optionsY + 16);
+ if (optionsYCord >= 0) {
+ int selectedOptionNr = optionsYCord / _optionsStep;
+ if (selectedOptionNr < _optionsNumber) {
+ _optionEnabled = selectedOptionNr;
+ }
+ }
+ int optionsColor;
+ int textY = _optionsY + 16;
+ for (int i = 0; i < _optionsNumber; i++) {
+ if (i != _optionEnabled) {
+ optionsColor = _optionsColor1;
+ } else {
+ optionsColor = _optionsColor2;
+ }
+ Common::String optText;
+ switch(getLanguage()) {
+ case Common::PL_POL:
+ optText = optionsTextPL[i];
+ break;
+ case Common::DE_DEU:
+ optText = optionsTextDE[i];
+ break;
+ case Common::EN_ANY:
+ optText = optionsTextEN[i];
+ break;
+ default:
+ break;
+ };
+ uint16 textW = getTextWidth(optText.c_str());
+ uint16 textX = _optionsX + _optionsWidth / 2 - textW / 2;
+ _font->drawString(_graph->_frontScreen, optText, textX, textY, textW, optionsColor);
+ textY += _optionsStep;
+ }
+ }
+}
+
+void PrinceEngine::checkInvOptions() {
+ if (_optionsFlag) {
+ Common::Rect optionsRect(_optionsX, _optionsY, _optionsX + _invOptionsWidth, _optionsY + _invOptionsHeight);
+ Common::Point mousePos = _system->getEventManager()->getMousePos();
+ if (!optionsRect.contains(mousePos)) {
+ _optionsFlag = 0;
+ _selectedMob = -1;
+ return;
+ }
+ _graph->drawAsShadowSurface(_graph->_screenForInventory, _optionsX, _optionsY, _optionsPicInInventory, _graph->_shadowTable50);
+
+ _optionEnabled = -1;
+ int optionsYCord = mousePos.y - (_optionsY + 16);
+ if (optionsYCord >= 0) {
+ int selectedOptionNr = optionsYCord / _invOptionsStep;
+ if (selectedOptionNr < _invOptionsNumber) {
+ _optionEnabled = selectedOptionNr;
+ }
+ }
+ int optionsColor;
+ int textY = _optionsY + 16;
+ for (int i = 0; i < _invOptionsNumber; i++) {
+ if (i != _optionEnabled) {
+ optionsColor = _optionsColor1;
+ } else {
+ optionsColor = _optionsColor2;
+ }
+ Common::String invText;
+ switch(getLanguage()) {
+ case Common::PL_POL:
+ invText = invOptionsTextPL[i];
+ break;
+ case Common::DE_DEU:
+ invText = invOptionsTextDE[i];
+ break;
+ case Common::EN_ANY:
+ invText = invOptionsTextEN[i];
+ break;
+ default:
+ error("Unknown game language %d", getLanguage());
+ break;
+ };
+ uint16 textW = getTextWidth(invText.c_str());
+ uint16 textX = _optionsX + _invOptionsWidth / 2 - textW / 2;
+ _font->drawString(_graph->_screenForInventory, invText, textX, textY, _graph->_screenForInventory->w, optionsColor);
+ textY += _invOptionsStep;
+ }
+ }
+}
+
+void PrinceEngine::displayInventory() {
+
+ _mainHero->freeOldMove();
+ _secondHero->freeOldMove();
+
+ _interpreter->setFgOpcodePC(0);
+
+ stopAllSamples();
+
+ prepareInventoryToView();
+
+ while (!shouldQuit()) {
+
+ if (_textSlots[0]._str != nullptr) {
+ changeCursor(0);
+ } else {
+ changeCursor(_currentPointerNumber);
+
+ Common::Rect inventoryRect(_invX1, _invY1, _invX1 + _invWidth, _invY1 + _invHeight);
+ Common::Point mousePos = _system->getEventManager()->getMousePos();
+
+ if (!_invCurInside && inventoryRect.contains(mousePos)) {
+ _invCurInside = true;
+ }
+
+ if (_invCurInside && !inventoryRect.contains(mousePos)) {
+ inventoryFlagChange(false);
+ _invCurInside = false;
+ break;
+ }
+ }
+
+ rememberScreenInv();
+
+ Graphics::Surface *suitcase = _suitcaseBmp->getSurface();
+ _graph->drawTransparentSurface(_graph->_screenForInventory, 0, 0, suitcase);
+
+ drawInvItems();
+
+ showTexts(_graph->_screenForInventory);
+
+ if (!_optionsFlag && _textSlots[0]._str == nullptr) {
+ _selectedMob = checkMob(_graph->_screenForInventory, _invMobList, false);
+ }
+
+ checkInvOptions();
+
+ Common::Event event;
+ Common::EventManager *eventMan = _system->getEventManager();
+ while (eventMan->pollEvent(event)) {
+ switch (event.type) {
+ case Common::EVENT_KEYDOWN:
+ keyHandler(event);
+ break;
+ case Common::EVENT_LBUTTONDOWN:
+ inventoryLeftMouseButton();
+ break;
+ case Common::EVENT_RBUTTONDOWN:
+ inventoryRightMouseButton();
+ break;
+ default:
+ break;
+ }
+ }
+
+ if (!_showInventoryFlag) {
+ break;
+ }
+
+ if (shouldQuit())
+ return;
+
+ getDebugger()->onFrame();
+ _graph->update(_graph->_screenForInventory);
+ pausePrinceEngine();
+ }
+
+ if (_currentPointerNumber == 2) {
+ _flags->setFlagValue(Flags::SELITEM, _selectedItem);
+ } else {
+ _flags->setFlagValue(Flags::SELITEM, 0);
+ }
+}
+
+void PrinceEngine::createDialogBox(int dialogBoxNr) {
+ _dialogLines = 0;
+ int amountOfDialogOptions = 0;
+ int dialogDataValue = (int)READ_LE_UINT32(_dialogData);
+
+ byte c;
+ int sentenceNumber;
+ _dialogText = _dialogBoxAddr[dialogBoxNr];
+ byte *dialogText = _dialogText;
+
+ while ((sentenceNumber = *dialogText) != 0xFF) {
+ dialogText++;
+ if (!(dialogDataValue & (1 << sentenceNumber))) {
+ _dialogLines += calcTextLines((const char *)dialogText);
+ amountOfDialogOptions++;
+ }
+ do {
+ c = *dialogText;
+ dialogText++;
+ } while (c);
+ }
+
+ _dialogHeight = _font->getFontHeight() * _dialogLines + _dialogLineSpace * (amountOfDialogOptions + 1);
+ _dialogImage = new Graphics::Surface();
+ _dialogImage->create(_dialogWidth, _dialogHeight, Graphics::PixelFormat::createFormatCLUT8());
+ Common::Rect dBoxRect(0, 0, _dialogWidth, _dialogHeight);
+ _dialogImage->fillRect(dBoxRect, _graph->kShadowColor);
+}
+
+void PrinceEngine::dialogRun() {
+
+ _dialogFlag = true;
+
+ while (!shouldQuit()) {
+
+ _interpreter->stepBg();
+ drawScreen();
+
+ int dialogX = (640 - _dialogWidth) / 2;
+ int dialogY = 460 - _dialogHeight;
+ _graph->drawAsShadowSurface(_graph->_frontScreen, dialogX, dialogY, _dialogImage, _graph->_shadowTable50);
+
+ int dialogSkipLeft = 14;
+ int dialogSkipUp = 10;
+
+ int dialogTextX = dialogX + dialogSkipLeft;
+ int dialogTextY = dialogY + dialogSkipUp;
+
+ Common::Point mousePos = _system->getEventManager()->getMousePos();
+
+ byte c;
+ int sentenceNumber;
+ byte *dialogText = _dialogText;
+ byte *dialogCurrentText = nullptr;
+ int dialogSelected = -1;
+ int dialogDataValue = (int)READ_LE_UINT32(_dialogData);
+
+ while ((sentenceNumber = *dialogText) != 0xFF) {
+ dialogText++;
+ int actualColor = _dialogColor1;
+
+ if (!(dialogDataValue & (1 << sentenceNumber))) {
+ if (getLanguage() == Common::DE_DEU) {
+ correctStringDEU((char *)dialogText);
+ }
+ Common::Array<Common::String> lines;
+ _font->wordWrapText((const char *)dialogText, _graph->_frontScreen->w, lines);
+
+ Common::Rect dialogOption(dialogTextX, dialogTextY - dialogSkipUp / 2, dialogX + _dialogWidth - dialogSkipLeft, dialogTextY + lines.size() * _font->getFontHeight() + dialogSkipUp / 2 - 1);
+ if (dialogOption.contains(mousePos)) {
+ actualColor = _dialogColor2;
+ dialogSelected = sentenceNumber;
+ dialogCurrentText = dialogText;
+ }
+
+ for (uint j = 0; j < lines.size(); j++) {
+ _font->drawString(_graph->_frontScreen, lines[j], dialogTextX, dialogTextY, _graph->_frontScreen->w, actualColor);
+ dialogTextY += _font->getFontHeight();
+ }
+ dialogTextY += _dialogLineSpace;
+ }
+ do {
+ c = *dialogText;
+ dialogText++;
+ } while (c);
+ }
+
+ Common::Event event;
+ Common::EventManager *eventMan = _system->getEventManager();
+ while (eventMan->pollEvent(event)) {
+ switch (event.type) {
+ case Common::EVENT_KEYDOWN:
+ keyHandler(event);
+ break;
+ case Common::EVENT_LBUTTONDOWN:
+ if (dialogSelected != -1) {
+ dialogLeftMouseButton(dialogCurrentText, dialogSelected);
+ _dialogFlag = false;
+ }
+ break;
+ default:
+ break;
+ }
+ }
+
+ if (shouldQuit()) {
+ return;
+ }
+
+ if (!_dialogFlag) {
+ break;
+ }
+
+ getDebugger()->onFrame();
+ _graph->update(_graph->_frontScreen);
+ pausePrinceEngine();
+ }
+ _dialogImage->free();
+ delete _dialogImage;
+ _dialogImage = nullptr;
+ _dialogFlag = false;
+}
+
+void PrinceEngine::dialogLeftMouseButton(byte *string, int dialogSelected) {
+ _interpreter->setString(string);
+ talkHero(0);
+
+ int dialogDataValue = (int)READ_LE_UINT32(_dialogData);
+ dialogDataValue |= (1u << dialogSelected);
+ WRITE_LE_UINT32(_dialogData, dialogDataValue);
+
+ _flags->setFlagValue(Flags::BOXSEL, dialogSelected + 1);
+ setVoice(0, 28, dialogSelected + 1);
+
+ _flags->setFlagValue(Flags::VOICE_H_LINE, _dialogOptLines[dialogSelected * 4]);
+ _flags->setFlagValue(Flags::VOICE_A_LINE, _dialogOptLines[dialogSelected * 4 + 1]);
+ _flags->setFlagValue(Flags::VOICE_B_LINE, _dialogOptLines[dialogSelected * 4 + 2]);
+
+ _interpreter->setString(_dialogOptAddr[dialogSelected]);
+}
+
+void PrinceEngine::talkHero(int slot) {
+ // heroSlot = textSlot (slot 0 or 1)
+ Text &text = _textSlots[slot];
+ int lines = calcTextLines((const char *)_interpreter->getString());
+ int time = lines * 30;
+
+ if (slot == 0) {
+ text._color = 220; // TODO - test this
+ _mainHero->_state = Hero::kHeroStateTalk;
+ _mainHero->_talkTime = time;
+ text._x = _mainHero->_middleX;
+ text._y = _mainHero->_middleY - _mainHero->_scaledFrameYSize;
+ } else {
+ text._color = _flags->getFlagValue(Flags::KOLOR); // TODO - test this
+ _secondHero->_state = Hero::kHeroStateTalk;
+ _secondHero->_talkTime = time;
+ text._x = _secondHero->_middleX;
+ text._y = _secondHero->_middleY - _secondHero->_scaledFrameYSize;
+ }
+ text._time = time;
+ if (getLanguage() == Common::DE_DEU) {
+ correctStringDEU((char *)_interpreter->getString());
+ }
+ text._str = (const char *)_interpreter->getString();
+ _interpreter->increaseString();
+}
+
+void PrinceEngine::doTalkAnim(int animNumber, int slot, AnimType animType) {
+ Text &text = _textSlots[slot];
+ int lines = calcTextLines((const char *)_interpreter->getString());
+ int time = lines * 30;
+ if (animType == kNormalAnimation) {
+ Anim &normAnim = _normAnimList[animNumber];
+ if (normAnim._animData != nullptr) {
+ if (!normAnim._state) {
+ if (normAnim._currW && normAnim._currH) {
+ text._color = _flags->getFlagValue(Flags::KOLOR);
+ text._x = normAnim._currX + normAnim._currW / 2;
+ text._y = normAnim._currY - 10;
+ }
+ }
+ }
+ } else if (animType == kBackgroundAnimation) {
+ if (!_backAnimList[animNumber].backAnims.empty()) {
+ int currAnim = _backAnimList[animNumber]._seq._currRelative;
+ Anim &backAnim = _backAnimList[animNumber].backAnims[currAnim];
+ if (backAnim._animData != nullptr) {
+ if (!backAnim._state) {
+ if (backAnim._currW && backAnim._currH) {
+ text._color = _flags->getFlagValue(Flags::KOLOR);
+ text._x = backAnim._currX + backAnim._currW / 2;
+ text._y = backAnim._currY - 10;
+ }
+ }
+ }
+ }
+ } else {
+ error("doTalkAnim() - wrong animType: %d", animType);
+ }
+ text._time = time;
+ if (getLanguage() == Common::DE_DEU) {
+ correctStringDEU((char *)_interpreter->getString());
+ }
+ text._str = (const char *)_interpreter->getString();
+ _interpreter->increaseString();
+}
+
+void PrinceEngine::freeNormAnim(int slot) {
+ if (!_normAnimList.empty()) {
+ _normAnimList[slot]._state = 1;
+ if (_normAnimList[slot]._animData != nullptr) {
+ delete _normAnimList[slot]._animData;
+ _normAnimList[slot]._animData = nullptr;
+ }
+ if (_normAnimList[slot]._shadowData != nullptr) {
+ delete _normAnimList[slot]._shadowData;
+ _normAnimList[slot]._shadowData = nullptr;
+ }
+ }
+}
+
+void PrinceEngine::freeAllNormAnims() {
+ for (int i = 0; i < kMaxNormAnims; i++) {
+ freeNormAnim(i);
+ }
+}
+
+void PrinceEngine::getCurve() {
+ _flags->setFlagValue(Flags::TORX1, _curveData[_curvPos]);
+ _flags->setFlagValue(Flags::TORY1, _curveData[_curvPos + 1]);
+ _curvPos += 2;
+}
+
+void PrinceEngine::makeCurve() {
+ _curvPos = 0;
+ int x1 = _flags->getFlagValue(Flags::TORX1);
+ int y1 = _flags->getFlagValue(Flags::TORY1);
+ int x2 = _flags->getFlagValue(Flags::TORX2);
+ int y2 = _flags->getFlagValue(Flags::TORY2);
+
+ for (int i = 0; i < kCurveLen; i++) {
+ int sum1 = x1 * curveValues[i][0];
+ sum1 += (x2 + (x1 - x2) / 2) * curveValues[i][1];
+ sum1 += x2 * curveValues[i][2];
+ sum1 += x2 * curveValues[i][3];
+
+ int sum2 = y1 * curveValues[i][0];
+ sum2 += (y2 - 20) * curveValues[i][1];
+ sum2 += (y2 - 10) * curveValues[i][2];
+ sum2 += y2 * curveValues[i][3];
+
+ _curveData[i * 2] = (sum1 >> 15);
+ _curveData[i * 2 + 1] = (sum2 >> 15);
+ }
+}
+
+void PrinceEngine::mouseWeirdo() {
+ if (_mouseFlag == 3) {
+ int weirdDir = _randomSource.getRandomNumber(3);
+ Common::Point mousePos = _system->getEventManager()->getMousePos();
+ switch (weirdDir) {
+ case 0:
+ mousePos.x += kCelStep;
+ break;
+ case 1:
+ mousePos.x -= kCelStep;
+ break;
+ case 2:
+ mousePos.y += kCelStep;
+ break;
+ case 3:
+ mousePos.y -= kCelStep;
+ break;
+ }
+ mousePos.x = CLIP(mousePos.x, (int16) 315, (int16) 639);
+ _flags->setFlagValue(Flags::MXFLAG, mousePos.x);
+ mousePos.y = CLIP(mousePos.y, (int16) 0, (int16) 170);
+ _flags->setFlagValue(Flags::MYFLAG, mousePos.y);
+ _system->warpMouse(mousePos.x, mousePos.y);
+ }
+}
+
+void PrinceEngine::showPower() {
+ if (_flags->getFlagValue(Flags::POWERENABLED)) {
+ int power = _flags->getFlagValue(Flags::POWER);
+
+ byte *dst = (byte *)_graph->_frontScreen->getBasePtr(kPowerBarPosX, kPowerBarPosY);
+ for (int y = 0; y < kPowerBarHeight; y++) {
+ byte *dst2 = dst;
+ for (int x = 0; x < kPowerBarWidth; x++, dst2++) {
+ *dst2 = kPowerBarBackgroundColor;
+ }
+ dst += _graph->_frontScreen->pitch;
+ }
+
+ if (power) {
+ dst = (byte *)_graph->_frontScreen->getBasePtr(kPowerBarPosX, kPowerBarGreenPosY);
+ for (int y = 0; y < kPowerBarGreenHeight; y++) {
+ byte *dst2 = dst;
+ for (int x = 0; x < power + 1; x++, dst2++) {
+ if (x < 58) {
+ *dst2 = kPowerBarGreenColor1;
+ } else {
+ *dst2 = kPowerBarGreenColor2;
+ }
+ }
+ dst += _graph->_frontScreen->pitch;
+ }
+ }
+
+ _graph->change();
+ }
+}
+
+void PrinceEngine::scrollCredits() {
+ byte *scrollAdress = _creditsData;
+ while (!shouldQuit()) {
+ for (int scrollPos = 0; scrollPos > -23; scrollPos--) {
+ const Graphics::Surface *roomSurface = _roomBmp->getSurface();
+ if (roomSurface) {
+ _graph->draw(_graph->_frontScreen, roomSurface);
+ }
+ char *s = (char *)scrollAdress;
+ int drawY = scrollPos;
+ for (int i = 0; i < 22; i++) {
+ Common::String line;
+ char *linePos = s;
+ while ((*linePos != 13)) {
+ line += *linePos;
+ linePos++;
+ }
+ if (!line.empty()) {
+ int drawX = (kNormalWidth - getTextWidth(line.c_str())) / 2;
+ _font->drawString(_graph->_frontScreen, line, drawX, drawY, _graph->_frontScreen->w, 217);
+ }
+
+ char letter1;
+ bool gotIt1 = false;
+ do {
+ letter1 = *s;
+ s++;
+ if (letter1 == 13) {
+ if (*s == 10) {
+ s++;
+ }
+ if (*s != 35) {
+ gotIt1 = true;
+ }
+ break;
+ }
+ } while (letter1 != 35);
+
+ if (gotIt1) {
+ drawY += 23;
+ } else {
+ break;
+ }
+ }
+ Common::Event event;
+ Common::EventManager *eventMan = _system->getEventManager();
+ while (eventMan->pollEvent(event)) {
+ if (event.type == Common::EVENT_KEYDOWN) {
+ if (event.kbd.keycode == Common::KEYCODE_ESCAPE) {
+ blackPalette();
+ return;
+ }
+ }
+ }
+ if (shouldQuit()) {
+ return;
+ }
+ _graph->change();
+ _graph->update(_graph->_frontScreen);
+ pausePrinceEngine(kFPS * 2);
+ }
+ char letter2;
+ byte *scan2 = scrollAdress;
+ bool gotIt2 = false;
+ do {
+ letter2 = *scan2;
+ scan2++;
+ if (letter2 == 13) {
+ if (*scan2 == 10) {
+ scan2++;
+ }
+ if (*scan2 != 35) {
+ gotIt2 = true;
+ }
+ break;
+ }
+ } while (letter2 != 35);
+ if (gotIt2) {
+ scrollAdress = scan2;
+ } else {
+ break;
+ }
+ }
+ blackPalette();
+}
+
+// Modified version of Graphics::drawLine() to allow breaking the loop and return value
+int PrinceEngine::drawLine(int x0, int y0, int x1, int y1, int (*plotProc)(int, int, void *), void *data) {
+ // Bresenham's line algorithm, as described by Wikipedia
+ const bool steep = ABS(y1 - y0) > ABS(x1 - x0);
+
+ if (steep) {
+ SWAP(x0, y0);
+ SWAP(x1, y1);
+ }
+
+ const int delta_x = ABS(x1 - x0);
+ const int delta_y = ABS(y1 - y0);
+ const int delta_err = delta_y;
+ int x = x0;
+ int y = y0;
+ int err = 0;
+
+ const int x_step = (x0 < x1) ? 1 : -1;
+ const int y_step = (y0 < y1) ? 1 : -1;
+
+ int stopFlag = 0;
+ if (steep)
+ stopFlag = (*plotProc)(y, x, data);
+ else
+ stopFlag = (*plotProc)(x, y, data);
+
+ while (x != x1 && !stopFlag) {
+ x += x_step;
+ err += delta_err;
+ if (2 * err > delta_x) {
+ y += y_step;
+ err -= delta_x;
+ }
+ if (steep)
+ stopFlag = (*plotProc)(y, x, data);
+ else
+ stopFlag = (*plotProc)(x, y, data);
+ }
+ return stopFlag;
+}
+
+int PrinceEngine::getPixelAddr(byte *pathBitmap, int x, int y) {
+ int mask = 128 >> (x & 7);
+ byte value = pathBitmap[x / 8 + y * 80];
+ return (mask & value);
+}
+
+void PrinceEngine::findPoint(int x, int y) {
+ _fpX = x;
+ _fpY = y;
+
+ if (getPixelAddr(_roomPathBitmap, x, y)) {
+ return;
+ }
+
+ int fpL = x;
+ int fpU = y;
+ int fpR = x;
+ int fpD = y;
+
+ while (1) {
+ if (fpD != kMaxPicHeight) {
+ if (getPixelAddr(_roomPathBitmap, x, fpD)) {
+ _fpX = x;
+ _fpY = fpD;
+ break;
+ }
+ fpD++;
+ }
+ if (fpU) {
+ if (getPixelAddr(_roomPathBitmap, x, fpU)) {
+ _fpX = x;
+ _fpY = fpU;
+ break;
+ }
+ fpU--;
+ }
+ if (fpL) {
+ if (getPixelAddr(_roomPathBitmap, fpL, y)) {
+ _fpX = fpL;
+ _fpY = y;
+ break;
+ }
+ fpL--;
+ }
+ if (fpR != _sceneWidth) {
+ if (getPixelAddr(_roomPathBitmap, fpR, y)) {
+ _fpX = fpR;
+ _fpY = y;
+ break;
+ }
+ fpR++;
+ }
+ if (!fpU && (fpD == kMaxPicHeight)) {
+ if (!fpL && (fpR == _sceneWidth)) {
+ break;
+ }
+ }
+ }
+}
+
+Direction PrinceEngine::makeDirection(int x1, int y1, int x2, int y2) {
+ if (x1 != x2) {
+ if (y1 != y2) {
+ if (x1 > x2) {
+ if (y1 > y2) {
+ if (x1 - x2 >= y1 - y2) {
+ return kDirLU;
+ } else {
+ return kDirUL;
+ }
+ } else {
+ if (x1 - x2 >= y2 - y1) {
+ return kDirLD;
+ } else {
+ return kDirDL;
+ }
+ }
+ } else {
+ if (y1 > y2) {
+ if (x2 - x1 >= y1 - y2) {
+ return kDirRU;
+ } else {
+ return kDirUR;
+ }
+ } else {
+ if (x2 - x1 >= y2 - y1) {
+ return kDirRD;
+ } else {
+ return kDirDR;
+ }
+ }
+ }
+ } else {
+ if (x1 >= x2) {
+ return kDirL;
+ } else {
+ return kDirR;
+ }
+ }
+ } else {
+ if (y1 >= y2) {
+ return kDirU;
+ } else {
+ return kDirD;
+ }
+ }
+}
+
+void PrinceEngine::specialPlot(int x, int y) {
+ if (_coords < _coordsBufEnd) {
+ WRITE_LE_UINT16(_coords, x);
+ _coords += 2;
+ WRITE_LE_UINT16(_coords, y);
+ _coords += 2;
+ specialPlot2(x, y);
+ }
+}
+
+void PrinceEngine::specialPlot2(int x, int y) {
+ int mask = 128 >> (x & 7);
+ _roomPathBitmapTemp[x / 8 + y * 80] |= mask;
+}
+
+void PrinceEngine::specialPlotInside(int x, int y) {
+ if (_coords < _coordsBufEnd) {
+ WRITE_LE_UINT16(_coords, x);
+ _coords += 2;
+ WRITE_LE_UINT16(_coords, y);
+ _coords += 2;
+ }
+}
+
+int PrinceEngine::plotTraceLine(int x, int y, void *data) {
+ PrinceEngine *traceLine = (PrinceEngine *)data;
+ if (!traceLine->_traceLineFirstPointFlag) {
+ if (!traceLine->getPixelAddr(traceLine->_roomPathBitmapTemp, x, y)) {
+ if (traceLine->getPixelAddr(traceLine->_roomPathBitmap, x, y)) {
+ traceLine->specialPlotInside(x, y);
+ traceLine->_traceLineLen++;
+ return 0;
+ } else {
+ return -1;
+ }
+ } else {
+ return 1;
+ }
+ } else {
+ traceLine->_traceLineFirstPointFlag = false;
+ return 0;
+ }
+}
+
+int PrinceEngine::leftDownDir() {
+ if (!checkLeftDownDir()) {
+ specialPlot(_checkX, _checkY);
+ return 0;
+ }
+ if (!checkLeftDir()) {
+ specialPlot(_checkX, _checkY);
+ return 0;
+ }
+ if (!checkDownDir()) {
+ specialPlot(_checkX, _checkY);
+ return 0;
+ }
+ if (!checkLeftUpDir()) {
+ specialPlot(_checkX, _checkY);
+ return 0;
+ }
+ if (!checkRightDownDir()) {
+ specialPlot(_checkX, _checkY);
+ return 0;
+ }
+ if (!checkUpDir()) {
+ specialPlot(_checkX, _checkY);
+ return 0;
+ }
+ if (!checkRightDir()) {
+ specialPlot(_checkX, _checkY);
+ return 0;
+ }
+ if (!checkRightUpDir()) {
+ specialPlot(_checkX, _checkY);
+ return 0;
+ }
+ return -1;
+}
+
+int PrinceEngine::leftDir() {
+ if (!checkLeftDir()) {
+ specialPlot(_checkX, _checkY);
+ return 0;
+ }
+ if (!checkLeftUpDir()) {
+ specialPlot(_checkX, _checkY);
+ return 0;
+ }
+ if (!checkLeftDownDir()) {
+ specialPlot(_checkX, _checkY);
+ return 0;
+ }
+ if (!checkUpDir()) {
+ specialPlot(_checkX, _checkY);
+ return 0;
+ }
+ if (!checkDownDir()) {
+ specialPlot(_checkX, _checkY);
+ return 0;
+ }
+ if (!checkRightUpDir()) {
+ specialPlot(_checkX, _checkY);
+ return 0;
+ }
+ if (!checkRightDownDir()) {
+ specialPlot(_checkX, _checkY);
+ return 0;
+ }
+ if (!checkRightDir()) {
+ specialPlot(_checkX, _checkY);
+ return 0;
+ }
+ return -1;
+}
+
+int PrinceEngine::leftUpDir() {
+ if (!checkLeftUpDir()) {
+ specialPlot(_checkX, _checkY);
+ return 0;
+ }
+ if (!checkLeftDir()) {
+ specialPlot(_checkX, _checkY);
+ return 0;
+ }
+ if (!checkUpDir()) {
+ specialPlot(_checkX, _checkY);
+ return 0;
+ }
+ if (!checkLeftDownDir()) {
+ specialPlot(_checkX, _checkY);
+ return 0;
+ }
+ if (!checkRightUpDir()) {
+ specialPlot(_checkX, _checkY);
+ return 0;
+ }
+ if (!checkDownDir()) {
+ specialPlot(_checkX, _checkY);
+ return 0;
+ }
+ if (!checkRightDir()) {
+ specialPlot(_checkX, _checkY);
+ return 0;
+ }
+ if (!checkRightDownDir()) {
+ specialPlot(_checkX, _checkY);
+ return 0;
+ }
+ return -1;
+}
+
+int PrinceEngine::rightDownDir() {
+ if (!checkRightDownDir()) {
+ specialPlot(_checkX, _checkY);
+ return 0;
+ }
+ if (!checkRightDir()) {
+ specialPlot(_checkX, _checkY);
+ return 0;
+ }
+ if (!checkDownDir()) {
+ specialPlot(_checkX, _checkY);
+ return 0;
+ }
+ if (!checkRightUpDir()) {
+ specialPlot(_checkX, _checkY);
+ return 0;
+ }
+ if (!checkLeftDownDir()) {
+ specialPlot(_checkX, _checkY);
+ return 0;
+ }
+ if (!checkUpDir()) {
+ specialPlot(_checkX, _checkY);
+ return 0;
+ }
+ if (!checkLeftDir()) {
+ specialPlot(_checkX, _checkY);
+ return 0;
+ }
+ if (!checkLeftUpDir()) {
+ specialPlot(_checkX, _checkY);
+ return 0;
+ }
+ return -1;
+}
+
+int PrinceEngine::rightDir() {
+ if (!checkRightDir()) {
+ specialPlot(_checkX, _checkY);
+ return 0;
+ }
+ if (!checkRightUpDir()) {
+ specialPlot(_checkX, _checkY);
+ return 0;
+ }
+ if (!checkRightDownDir()) {
+ specialPlot(_checkX, _checkY);
+ return 0;
+ }
+ if (!checkUpDir()) {
+ specialPlot(_checkX, _checkY);
+ return 0;
+ }
+ if (!checkDownDir()) {
+ specialPlot(_checkX, _checkY);
+ return 0;
+ }
+ if (!checkLeftUpDir()) {
+ specialPlot(_checkX, _checkY);
+ return 0;
+ }
+ if (!checkLeftDownDir()) {
+ specialPlot(_checkX, _checkY);
+ return 0;
+ }
+ if (!checkLeftDir()) {
+ specialPlot(_checkX, _checkY);
+ return 0;
+ }
+ return -1;
+}
+
+int PrinceEngine::rightUpDir() {
+ if (!checkRightUpDir()) {
+ specialPlot(_checkX, _checkY);
+ return 0;
+ }
+ if (!checkRightDir()) {
+ specialPlot(_checkX, _checkY);
+ return 0;
+ }
+ if (!checkUpDir()) {
+ specialPlot(_checkX, _checkY);
+ return 0;
+ }
+ if (!checkRightDownDir()) {
+ specialPlot(_checkX, _checkY);
+ return 0;
+ }
+ if (!checkLeftUpDir()) {
+ specialPlot(_checkX, _checkY);
+ return 0;
+ }
+ if (!checkDownDir()) {
+ specialPlot(_checkX, _checkY);
+ return 0;
+ }
+ if (!checkLeftDir()) {
+ specialPlot(_checkX, _checkY);
+ return 0;
+ }
+ if (!checkLeftDownDir()) {
+ specialPlot(_checkX, _checkY);
+ return 0;
+ }
+ return -1;
+}
+
+int PrinceEngine::upLeftDir() {
+ if (!checkLeftUpDir()) {
+ specialPlot(_checkX, _checkY);
+ return 0;
+ }
+ if (!checkUpDir()) {
+ specialPlot(_checkX, _checkY);
+ return 0;
+ }
+ if (!checkLeftDir()) {
+ specialPlot(_checkX, _checkY);
+ return 0;
+ }
+ if (!checkRightUpDir()) {
+ specialPlot(_checkX, _checkY);
+ return 0;
+ }
+ if (!checkLeftDownDir()) {
+ specialPlot(_checkX, _checkY);
+ return 0;
+ }
+ if (!checkRightDir()) {
+ specialPlot(_checkX, _checkY);
+ return 0;
+ }
+ if (!checkDownDir()) {
+ specialPlot(_checkX, _checkY);
+ return 0;
+ }
+ if (!checkRightDownDir()) {
+ specialPlot(_checkX, _checkY);
+ return 0;
+ }
+ return -1;
+}
+
+int PrinceEngine::upDir() {
+ if (!checkUpDir()) {
+ specialPlot(_checkX, _checkY);
+ return 0;
+ }
+ if (!checkLeftUpDir()) {
+ specialPlot(_checkX, _checkY);
+ return 0;
+ }
+ if (!checkRightUpDir()) {
+ specialPlot(_checkX, _checkY);
+ return 0;
+ }
+ if (!checkLeftDir()) {
+ specialPlot(_checkX, _checkY);
+ return 0;
+ }
+ if (!checkRightDir()) {
+ specialPlot(_checkX, _checkY);
+ return 0;
+ }
+ if (!checkLeftDownDir()) {
+ specialPlot(_checkX, _checkY);
+ return 0;
+ }
+ if (!checkRightDownDir()) {
+ specialPlot(_checkX, _checkY);
+ return 0;
+ }
+ if (!checkDownDir()) {
+ specialPlot(_checkX, _checkY);
+ return 0;
+ }
+ return -1;
+}
+
+int PrinceEngine::upRightDir() {
+ if (!checkRightUpDir()) {
+ specialPlot(_checkX, _checkY);
+ return 0;
+ }
+ if (!checkUpDir()) {
+ specialPlot(_checkX, _checkY);
+ return 0;
+ }
+ if (!checkRightDir()) {
+ specialPlot(_checkX, _checkY);
+ return 0;
+ }
+ if (!checkLeftUpDir()) {
+ specialPlot(_checkX, _checkY);
+ return 0;
+ }
+ if (!checkRightDownDir()) {
+ specialPlot(_checkX, _checkY);
+ return 0;
+ }
+ if (!checkLeftDir()) {
+ specialPlot(_checkX, _checkY);
+ return 0;
+ }
+ if (!checkDownDir()) {
+ specialPlot(_checkX, _checkY);
+ return 0;
+ }
+ if (!checkLeftDownDir()) {
+ specialPlot(_checkX, _checkY);
+ return 0;
+ }
+ return -1;
+}
+
+int PrinceEngine::downLeftDir() {
+ if (!checkLeftDownDir()) {
+ specialPlot(_checkX, _checkY);
+ return 0;
+ }
+ if (!checkDownDir()) {
+ specialPlot(_checkX, _checkY);
+ return 0;
+ }
+ if (!checkLeftDir()) {
+ specialPlot(_checkX, _checkY);
+ return 0;
+ }
+ if (!checkRightDownDir()) {
+ specialPlot(_checkX, _checkY);
+ return 0;
+ }
+ if (!checkLeftUpDir()) {
+ specialPlot(_checkX, _checkY);
+ return 0;
+ }
+ if (!checkRightDir()) {
+ specialPlot(_checkX, _checkY);
+ return 0;
+ }
+ if (!checkUpDir()) {
+ specialPlot(_checkX, _checkY);
+ return 0;
+ }
+ if (!checkRightUpDir()) {
+ specialPlot(_checkX, _checkY);
+ return 0;
+ }
+ return -1;
+}
+
+int PrinceEngine::downDir() {
+ if (!checkDownDir()) {
+ specialPlot(_checkX, _checkY);
+ return 0;
+ }
+ if (!checkRightDownDir()) {
+ specialPlot(_checkX, _checkY);
+ return 0;
+ }
+ if (!checkLeftDownDir()) {
+ specialPlot(_checkX, _checkY);
+ return 0;
+ }
+ if (!checkRightDir()) {
+ specialPlot(_checkX, _checkY);
+ return 0;
+ }
+ if (!checkLeftDir()) {
+ specialPlot(_checkX, _checkY);
+ return 0;
+ }
+ if (!checkRightUpDir()) {
+ specialPlot(_checkX, _checkY);
+ return 0;
+ }
+ if (!checkLeftUpDir()) {
+ specialPlot(_checkX, _checkY);
+ return 0;
+ }
+ if (!checkUpDir()) {
+ specialPlot(_checkX, _checkY);
+ return 0;
+ }
+ return -1;
+}
+
+int PrinceEngine::downRightDir() {
+ if (!checkRightDownDir()) {
+ specialPlot(_checkX, _checkY);
+ return 0;
+ }
+ if (!checkDownDir()) {
+ specialPlot(_checkX, _checkY);
+ return 0;
+ }
+ if (!checkRightDir()) {
+ specialPlot(_checkX, _checkY);
+ return 0;
+ }
+ if (!checkLeftDownDir()) {
+ specialPlot(_checkX, _checkY);
+ return 0;
+ }
+ if (!checkRightUpDir()) {
+ specialPlot(_checkX, _checkY);
+ return 0;
+ }
+ if (!checkLeftDir()) {
+ specialPlot(_checkX, _checkY);
+ return 0;
+ }
+ if (!checkUpDir()) {
+ specialPlot(_checkX, _checkY);
+ return 0;
+ }
+ if (!checkLeftUpDir()) {
+ specialPlot(_checkX, _checkY);
+ return 0;
+ }
+ return -1;
+}
+
+int PrinceEngine::cpe() {
+ if ((*(_checkBitmap - kPBW) & _checkMask)) {
+ if ((*(_checkBitmap + kPBW) & _checkMask)) {
+ int value;
+ switch (_checkMask) {
+ case 128:
+ value = READ_LE_UINT16(_checkBitmap - 1);
+ value &= 0x4001;
+ if (value != 0x4001) {
+ return 0;
+ }
+ break;
+ case 64:
+ value = *_checkBitmap;
+ value &= 0xA0;
+ if (value != 0xA0) {
+ return 0;
+ }
+ break;
+ case 32:
+ value = *_checkBitmap;
+ value &= 0x50;
+ if (value != 0x50) {
+ return 0;
+ }
+ break;
+ case 16:
+ value = *_checkBitmap;
+ value &= 0x28;
+ if (value != 0x28) {
+ return 0;
+ }
+ break;
+ case 8:
+ value = *_checkBitmap;
+ value &= 0x14;
+ if (value != 0x14) {
+ return 0;
+ }
+ break;
+ case 4:
+ value = *_checkBitmap;
+ value &= 0xA;
+ if (value != 0xA) {
+ return 0;
+ }
+ break;
+ case 2:
+ value = *_checkBitmap;
+ value &= 0x5;
+ if (value != 0x5) {
+ return 0;
+ }
+ break;
+ case 1:
+ value = READ_LE_UINT16(_checkBitmap);
+ value &= 0x8002;
+ if (value != 0x8002) {
+ return 0;
+ }
+ break;
+ default:
+ error("Wrong _checkMask value - cpe()");
+ break;
+ }
+ _checkX = _rembX;
+ _checkY = _rembY;
+ _checkBitmapTemp = _rembBitmapTemp;
+ _checkBitmap = _rembBitmap;
+ _checkMask = _rembMask;
+ return -1;
+ }
+ return 0;
+ }
+ return 0;
+}
+
+int PrinceEngine::checkLeftDownDir() {
+ if (_checkX && _checkY != (kMaxPicHeight / 2 - 1)) {
+ int tempMask = _checkMask;
+ if (tempMask != 128) {
+ tempMask <<= 1;
+ if ((*(_checkBitmap + kPBW) & tempMask)) {
+ if (!(*(_checkBitmapTemp + kPBW) & tempMask)) {
+ _checkBitmap += kPBW;
+ _checkBitmapTemp += kPBW;
+ _checkMask = tempMask;
+ } else {
+ return 1;
+ }
+ } else {
+ return -1;
+ }
+ } else {
+ if ((*(_checkBitmap + kPBW - 1) & 1)) {
+ if (!(*(_checkBitmapTemp + kPBW - 1) & 1)) {
+ _checkBitmap += (kPBW - 1);
+ _checkBitmapTemp += (kPBW - 1);
+ _checkMask = 1;
+ } else {
+ return 1;
+ }
+ } else {
+ return -1;
+ }
+ }
+ _checkX--;
+ _checkY++;
+ return cpe();
+ } else {
+ return -1;
+ }
+}
+
+int PrinceEngine::checkLeftDir() {
+ if (_checkX) {
+ int tempMask = _checkMask;
+ if (tempMask != 128) {
+ tempMask <<= 1;
+ if ((*(_checkBitmap) & tempMask)) {
+ if (!(*(_checkBitmapTemp) & tempMask)) {
+ _checkMask = tempMask;
+ } else {
+ return 1;
+ }
+ } else {
+ return -1;
+ }
+ } else {
+ if ((*(_checkBitmap - 1) & 1)) {
+ if (!(*(_checkBitmapTemp - 1) & 1)) {
+ _checkBitmap--;
+ _checkBitmapTemp--;
+ _checkMask = 1;
+ } else {
+ return 1;
+ }
+ } else {
+ return -1;
+ }
+ }
+ _checkX--;
+ return cpe();
+ } else {
+ return -1;
+ }
+}
+
+int PrinceEngine::checkDownDir() {
+ if (_checkY != (kMaxPicHeight / 2 - 1)) {
+ if ((*(_checkBitmap + kPBW) & _checkMask)) {
+ if (!(*(_checkBitmapTemp + kPBW) & _checkMask)) {
+ _checkBitmap += kPBW;
+ _checkBitmapTemp += kPBW;
+ _checkY++;
+ return cpe();
+ } else {
+ return 1;
+ }
+ } else {
+ return -1;
+ }
+ } else {
+ return -1;
+ }
+}
+
+int PrinceEngine::checkUpDir() {
+ if (_checkY) {
+ if ((*(_checkBitmap - kPBW) & _checkMask)) {
+ if (!(*(_checkBitmapTemp - kPBW) & _checkMask)) {
+ _checkBitmap -= kPBW;
+ _checkBitmapTemp -= kPBW;
+ _checkY--;
+ return cpe();
+ } else {
+ return 1;
+ }
+ } else {
+ return -1;
+ }
+ } else {
+ return -1;
+ }
+}
+
+int PrinceEngine::checkRightDir() {
+ if (_checkX != (kMaxPicWidth / 2 - 1)) {
+ int tempMask = _checkMask;
+ if (tempMask != 1) {
+ tempMask >>= 1;
+ if ((*(_checkBitmap) & tempMask)) {
+ if (!(*(_checkBitmapTemp) & tempMask)) {
+ _checkMask = tempMask;
+ } else {
+ return 1;
+ }
+ } else {
+ return -1;
+ }
+ } else {
+ if ((*(_checkBitmap + 1) & 128)) {
+ if (!(*(_checkBitmapTemp + 1) & 128)) {
+ _checkBitmap++;
+ _checkBitmapTemp++;
+ _checkMask = 128;
+ } else {
+ return 1;
+ }
+ } else {
+ return -1;
+ }
+ }
+ _checkX++;
+ return cpe();
+ } else {
+ return -1;
+ }
+}
+
+int PrinceEngine::checkLeftUpDir() {
+ if (_checkX && _checkY) {
+ int tempMask = _checkMask;
+ if (tempMask != 128) {
+ tempMask <<= 1;
+ if ((*(_checkBitmap - kPBW) & tempMask)) {
+ if (!(*(_checkBitmapTemp - kPBW) & tempMask)) {
+ _checkBitmap -= kPBW;
+ _checkBitmapTemp -= kPBW;
+ _checkMask = tempMask;
+ } else {
+ return 1;
+ }
+ } else {
+ return -1;
+ }
+ } else {
+ if ((*(_checkBitmap - (kPBW + 1)) & 1)) {
+ if (!(*(_checkBitmapTemp - (kPBW + 1)) & 1)) {
+ _checkBitmap -= (kPBW + 1);
+ _checkBitmapTemp -= (kPBW + 1);
+ _checkMask = 1;
+ } else {
+ return 1;
+ }
+ } else {
+ return -1;
+ }
+ }
+ _checkX--;
+ _checkY--;
+ return cpe();
+ } else {
+ return -1;
+ }
+}
+
+int PrinceEngine::checkRightDownDir() {
+ if (_checkX != (kMaxPicWidth / 2 - 1) && _checkY != (kMaxPicHeight / 2 - 1)) {
+ int tempMask = _checkMask;
+ if (tempMask != 1) {
+ tempMask >>= 1;
+ if ((*(_checkBitmap + kPBW) & tempMask)) {
+ if (!(*(_checkBitmapTemp + kPBW) & tempMask)) {
+ _checkBitmap += kPBW;
+ _checkBitmapTemp += kPBW;
+ _checkMask = tempMask;
+ } else {
+ return 1;
+ }
+ } else {
+ return -1;
+ }
+ } else {
+ if ((*(_checkBitmap + kPBW + 1) & 128)) {
+ if (!(*(_checkBitmapTemp + kPBW + 1) & 128)) {
+ _checkBitmap += kPBW + 1;
+ _checkBitmapTemp += kPBW + 1;
+ _checkMask = 128;
+ } else {
+ return 1;
+ }
+ } else {
+ return -1;
+ }
+ }
+ _checkX++;
+ _checkY++;
+ return cpe();
+ } else {
+ return -1;
+ }
+}
+
+int PrinceEngine::checkRightUpDir() {
+ if (_checkX != (kMaxPicWidth / 2 - 1) && _checkY) {
+ int tempMask = _checkMask;
+ if (tempMask != 1) {
+ tempMask >>= 1;
+ if ((*(_checkBitmap - kPBW) & tempMask)) {
+ if (!(*(_checkBitmapTemp - kPBW) & tempMask)) {
+ _checkBitmap -= kPBW;
+ _checkBitmapTemp -= kPBW;
+ _checkMask = tempMask;
+ } else {
+ return 1;
+ }
+ } else {
+ return -1;
+ }
+ } else {
+ if ((*(_checkBitmap - kPBW + 1) & 128)) {
+ if (!(*(_checkBitmapTemp - kPBW + 1) & 128)) {
+ _checkBitmap -= (kPBW - 1);
+ _checkBitmapTemp -= (kPBW - 1);
+ _checkMask = 128;
+ } else {
+ return 1;
+ }
+ } else {
+ return -1;
+ }
+ }
+ _checkX++;
+ _checkY--;
+ return cpe();
+ } else {
+ return -1;
+ }
+}
+
+bool PrinceEngine::tracePath(int x1, int y1, int x2, int y2) {
+ for (uint i = 0; i < kPathBitmapLen; i++) {
+ _roomPathBitmapTemp[i] = 0;
+ }
+ if (x1 != x2 || y1 != y2) {
+ if (getPixelAddr(_roomPathBitmap, x1, y1)) {
+ if (getPixelAddr(_roomPathBitmap, x2, y2)) {
+ _coords = _coordsBuf;
+ specialPlot(x1, y1);
+
+ int x = x1;
+ int y = y1;
+
+ while (1) {
+ int btx = x;
+ int bty = y;
+ byte *bcad = _coords;
+
+ _traceLineLen = 0;
+ _traceLineFirstPointFlag = true;
+ int drawLineFlag = drawLine(x, y, x2, y2, &this->plotTraceLine, this);
+
+ if (!drawLineFlag) {
+ return true;
+ } else if (drawLineFlag == -1 && _traceLineLen >= 2) {
+ byte *tempCorrds = bcad;
+ while (tempCorrds != _coords) {
+ x = READ_LE_UINT16(tempCorrds);
+ y = READ_LE_UINT16(tempCorrds + 2);
+ tempCorrds += 4;
+ specialPlot2(x, y);
+ }
+ } else {
+ _coords = bcad;
+ x = btx;
+ y = bty;
+ }
+
+ Direction dir = makeDirection(x, y, x2, y2);
+
+ _rembBitmapTemp = &_roomPathBitmapTemp[x / 8 + y * 80];
+ _rembBitmap = &_roomPathBitmap[x / 8 + y * 80];
+ _rembMask = 128 >> (x & 7);
+ _rembX = x;
+ _rembY = y;
+
+ _checkBitmapTemp = _rembBitmapTemp;
+ _checkBitmap = _rembBitmap;
+ _checkMask = _rembMask;
+ _checkX = _rembX;
+ _checkY = _rembY;
+
+ int result;
+ switch (dir) {
+ case kDirLD:
+ result = leftDownDir();
+ break;
+ case kDirL:
+ result = leftDir();
+ break;
+ case kDirLU:
+ result = leftUpDir();
+ break;
+ case kDirRD:
+ result = rightDownDir();
+ break;
+ case kDirR:
+ result = rightDir();
+ break;
+ case kDirRU:
+ result = rightUpDir();
+ break;
+ case kDirUL:
+ result = upLeftDir();
+ break;
+ case kDirU:
+ result = upDir();
+ break;
+ case kDirUR:
+ result = upRightDir();
+ break;
+ case kDirDL:
+ result = downLeftDir();
+ break;
+ case kDirD:
+ result = downDir();
+ break;
+ case kDirDR:
+ result = downRightDir();
+ break;
+ default:
+ result = -1;
+ error("tracePath: wrong direction %d", dir);
+ break;
+ }
+
+ if (result) {
+ byte *tempCoords = _coords;
+ tempCoords -= 4;
+ if (tempCoords > _coordsBuf) {
+ int tempX = READ_LE_UINT16(tempCoords);
+ int tempY = READ_LE_UINT16(tempCoords + 2);
+ if (_checkX == tempX && _checkY == tempY) {
+ _coords = tempCoords;
+ }
+ x = READ_LE_UINT16(tempCoords);
+ y = READ_LE_UINT16(tempCoords + 2);
+ } else {
+ return false;
+ }
+ } else {
+ x = _checkX;
+ y = _checkY;
+ }
+ }
+ return true;
+ } else {
+ error("tracePath: wrong destination point");
+ }
+ } else {
+ error("tracePath: wrong start point");
+ }
+ } else {
+ error("tracePath: same point");
+ }
+}
+
+void PrinceEngine::specialPlotInside2(int x, int y) {
+ WRITE_LE_UINT16(_coords2, x);
+ _coords2 += 2;
+ WRITE_LE_UINT16(_coords2, y);
+ _coords2 += 2;
+}
+
+int PrinceEngine::plotTracePoint(int x, int y, void *data) {
+ PrinceEngine *tracePoint = (PrinceEngine *)data;
+ if (!tracePoint->_tracePointFirstPointFlag) {
+ if (tracePoint->getPixelAddr(tracePoint->_roomPathBitmap, x, y)) {
+ tracePoint->specialPlotInside2(x, y);
+ return 0;
+ } else {
+ return -1;
+ }
+ } else {
+ tracePoint->_tracePointFirstPointFlag = false;
+ return 0;
+ }
+}
+
+void PrinceEngine::approxPath() {
+ byte *oldCoords;
+ _coords2 = _coordsBuf2;
+ byte *tempCoordsBuf = _coordsBuf; // first point on path
+ byte *tempCoords = _coords;
+ if (tempCoordsBuf != tempCoords) {
+ tempCoords -= 4; // last point on path
+ while (tempCoordsBuf != tempCoords) {
+ int x1 = READ_LE_UINT16(tempCoords);
+ int y1 = READ_LE_UINT16(tempCoords + 2);
+ int x2 = READ_LE_UINT16(tempCoordsBuf);
+ int y2 = READ_LE_UINT16(tempCoordsBuf + 2);
+ tempCoordsBuf += 4;
+ //TracePoint
+ oldCoords = _coords2;
+ if (_coords2 == _coordsBuf2) {
+ WRITE_LE_UINT16(_coords2, x1);
+ WRITE_LE_UINT16(_coords2 + 2, y1);
+ _coords2 += 4;
+ } else {
+ int testX = READ_LE_UINT16(_coords2 - 4);
+ int testY = READ_LE_UINT16(_coords2 - 2);
+ if (testX != x1 || testY != y1) {
+ WRITE_LE_UINT16(_coords2, x1);
+ WRITE_LE_UINT16(_coords2 + 2, y1);
+ _coords2 += 4;
+ }
+ }
+ _tracePointFirstPointFlag = true;
+ bool drawLineFlag = drawLine(x1, y1, x2, y2, &this->plotTracePoint, this);
+ if (!drawLineFlag) {
+ tempCoords = tempCoordsBuf - 4;
+ tempCoordsBuf = _coordsBuf;
+ } else {
+ _coords2 = oldCoords;
+ }
+ }
+ }
+}
+
+void PrinceEngine::freeDirectionTable() {
+ if (_directionTable != nullptr) {
+ free(_directionTable);
+ _directionTable = nullptr;
+ }
+}
+
+int PrinceEngine::scanDirectionsFindNext(byte *tempCoordsBuf, int xDiff, int yDiff) {
+
+ int tempX, tempY, direction;
+
+ tempX = Hero::kHeroDirLeft;
+ if (xDiff < 0) {
+ tempX = Hero::kHeroDirRight;
+ }
+
+ tempY = Hero::kHeroDirUp;
+ if (yDiff < 0) {
+ tempY = Hero::kHeroDirDown;
+ }
+
+ while (1) {
+ int againPointX1 = READ_LE_UINT16(tempCoordsBuf);
+ int againPointY1 = READ_LE_UINT16(tempCoordsBuf + 2);
+ tempCoordsBuf += 4;
+
+ if (tempCoordsBuf == _coords) {
+ direction = tempX;
+ break;
+ }
+
+ int dX = againPointX1 - READ_LE_UINT16(tempCoordsBuf);
+ int dY = againPointY1 - READ_LE_UINT16(tempCoordsBuf + 2);
+
+ if (dX != xDiff) {
+ direction = tempY;
+ break;
+ }
+
+ if (dY != yDiff) {
+ direction = tempX;
+ break;
+ }
+ }
+ return direction;
+}
+
+void PrinceEngine::scanDirections() {
+ freeDirectionTable();
+ byte *tempCoordsBuf = _coordsBuf;
+ if (tempCoordsBuf != _coords) {
+ int size = (_coords - tempCoordsBuf) / 4 + 1; // number of coord points plus one for end marker
+ _directionTable = (byte *)malloc(size);
+ byte *tempDirTab = _directionTable;
+ int direction = -1;
+ int lastDirection = -1;
+
+ while (1) {
+ int x1 = READ_LE_UINT16(tempCoordsBuf);
+ int y1 = READ_LE_UINT16(tempCoordsBuf + 2);
+ tempCoordsBuf += 4;
+ if (tempCoordsBuf == _coords) {
+ break;
+ }
+ int x2 = READ_LE_UINT16(tempCoordsBuf);
+ int y2 = READ_LE_UINT16(tempCoordsBuf + 2);
+
+ int xDiff = x1 - x2;
+ int yDiff = y1 - y2;
+
+ if (xDiff) {
+ if (yDiff) {
+ if (lastDirection != -1) {
+ direction = lastDirection;
+ if (direction == Hero::kHeroDirLeft) {
+ if (xDiff < 0) {
+ direction = scanDirectionsFindNext(tempCoordsBuf, xDiff, yDiff);
+ }
+ } else if (direction == Hero::kHeroDirRight) {
+ if (xDiff >= 0) {
+ direction = scanDirectionsFindNext(tempCoordsBuf, xDiff, yDiff);
+ }
+ } else if (direction == Hero::kHeroDirUp) {
+ if (yDiff < 0) {
+ direction = scanDirectionsFindNext(tempCoordsBuf, xDiff, yDiff);
+ }
+ } else {
+ if (yDiff >= 0) {
+ direction = scanDirectionsFindNext(tempCoordsBuf, xDiff, yDiff);
+ }
+ }
+ } else {
+ direction = scanDirectionsFindNext(tempCoordsBuf, xDiff, yDiff);
+ }
+ } else {
+ direction = Hero::kHeroDirLeft;
+ if (xDiff < 0) {
+ direction = Hero::kHeroDirRight;
+ }
+ }
+ } else {
+ if (yDiff) {
+ direction = Hero::kHeroDirUp;
+ if (yDiff < 0) {
+ direction = Hero::kHeroDirDown;
+ }
+ } else {
+ direction = lastDirection;
+ }
+ }
+ lastDirection = direction;
+ *tempDirTab = direction;
+ tempDirTab++;
+ }
+ *tempDirTab = *(tempDirTab - 1);
+ tempDirTab++;
+ *tempDirTab = 0;
+ }
+}
+
+void PrinceEngine::moveShandria() {
+ int shanLen1 = _shanLen;
+ if (_flags->getFlagValue(Flags::SHANDOG)) {
+ _secondHero->freeHeroAnim();
+ _secondHero->freeOldMove();
+ byte *shanCoords = _mainHero->_currCoords + shanLen1 * 4 - 4;
+ int shanX = READ_LE_UINT16(shanCoords - 4);
+ int shanY = READ_LE_UINT16(shanCoords - 2);
+ int xDiff = shanX - _secondHero->_middleX;
+ if (xDiff < 0) {
+ xDiff *= -1;
+ }
+ int yDiff = shanY - _secondHero->_middleY;
+ if (yDiff < 0) {
+ yDiff *= -1;
+ }
+ shanCoords -= 4;
+ if (shanCoords != _mainHero->_currCoords) {
+ yDiff *= 1.5;
+ int shanDis = xDiff * xDiff + yDiff * yDiff;
+ if (shanDis >= kMinDistance) {
+ while (1) {
+ shanCoords -= 4;
+ if (shanCoords == _mainHero->_currCoords) {
+ break;
+ }
+ int x = READ_LE_UINT16(shanCoords);
+ int y = READ_LE_UINT16(shanCoords + 2);
+ int pointDiffX = x - shanX;
+ if (pointDiffX < 0) {
+ pointDiffX *= -1;
+ }
+ int pointDiffY = y - shanY;
+ if (pointDiffY < 0) {
+ pointDiffY *= -1;
+ }
+ pointDiffY *= 1.5;
+ int distance = pointDiffX * pointDiffX + pointDiffY * pointDiffY;
+ if (distance >= kMinDistance) {
+ break;
+ }
+ }
+ int pathSizeDiff = (shanCoords - _mainHero->_currCoords) / 4;
+ int destDir = *(_mainHero->_currDirTab + pathSizeDiff);
+ _secondHero->_destDirection = destDir;
+ int destX = READ_LE_UINT16(shanCoords);
+ int destY = READ_LE_UINT16(shanCoords + 2);
+ _secondHero->_coords = makePath(kSecondHero, _secondHero->_middleX, _secondHero->_middleY, destX, destY);
+ if (_secondHero->_coords != nullptr) {
+ _secondHero->_currCoords = _secondHero->_coords;
+ int delay = shanLen1 - _shanLen;
+ if (delay < 6) {
+ delay = 6;
+ }
+ _secondHero->_moveDelay = delay / 2;
+ _secondHero->_state = Hero::kHeroStateDelayMove;
+ _secondHero->_dirTab = _directionTable;
+ _secondHero->_currDirTab = _directionTable;
+ _directionTable = nullptr;
+ }
+ }
+ }
+ }
+}
+
+byte *PrinceEngine::makePath(int heroId, int currX, int currY, int destX, int destY) {
+ int realDestX = destX;
+ int realDestY = destY;
+ _flags->setFlagValue(Flags::MOVEDESTX, destX);
+ _flags->setFlagValue(Flags::MOVEDESTY, destY);
+
+ int x1 = currX / 2;
+ int y1 = currY / 2;
+ int x2 = destX / 2;
+ int y2 = destY / 2;
+
+ if ((x1 != x2) || (y1 != y2)) {
+ findPoint(x1, y1);
+ if (!getPixelAddr(_roomPathBitmap, _fpX, _fpY)) {
+ return nullptr;
+ }
+ if ((x1 != _fpX) || (y1 != _fpY)) {
+ x1 = _fpX;
+ y1 = _fpY;
+ }
+ findPoint(x2, y2);
+ if (!getPixelAddr(_roomPathBitmap, _fpX, _fpY)) {
+ return nullptr;
+ }
+ if ((x2 != _fpX) || (y2 != _fpY)) {
+ x2 = _fpX;
+ y2 = _fpY;
+ if (!_flags->getFlagValue(Flags::EXACTMOVE)) {
+ realDestX = x2 * 2;
+ realDestY = y2 * 2;
+ _flags->setFlagValue(Flags::MOVEDESTX, realDestX);
+ _flags->setFlagValue(Flags::MOVEDESTY, realDestY);
+ } else {
+ return nullptr;
+ }
+ }
+
+ if ((x1 == x2) && (y1 == y2)) {
+ if (!heroId) {
+ _mainHero->freeOldMove();
+ _mainHero->_state = Hero::kHeroStateTurn;
+ } else if (heroId == 1) {
+ _secondHero->freeOldMove();
+ _secondHero->_state = Hero::kHeroStateTurn;
+ }
+ return nullptr;
+ }
+
+ int pathLen1 = 0;
+ int pathLen2 = 0;
+ int stX = x1;
+ int stY = y1;
+ int sizeCoords2 = 0;
+
+ if (tracePath(x1, y1, x2, y2)) {
+ allocCoords2();
+ approxPath();
+ sizeCoords2 = _coords2 - _coordsBuf2;
+ for (int i = 0; i < sizeCoords2; i++) {
+ _coordsBuf[i] = _coordsBuf2[i];
+ }
+ _coords = _coordsBuf + sizeCoords2;
+ approxPath();
+ _coordsBuf3 = _coordsBuf2;
+ _coordsBuf2 = nullptr;
+ _coords3 = _coords2;
+ _coords2 = nullptr;
+ pathLen1 = _coords3 - _coordsBuf3;
+ }
+ if (tracePath(x2, y2, x1, y1)) {
+ allocCoords2();
+ approxPath();
+ sizeCoords2 = _coords2 - _coordsBuf2;
+ for (int i = 0; i < sizeCoords2; i++) {
+ _coordsBuf[i] = _coordsBuf2[i];
+ }
+ _coords = _coordsBuf + sizeCoords2;
+ approxPath();
+ pathLen2 = _coords2 - _coordsBuf2;
+ }
+
+ byte *chosenCoordsBuf = _coordsBuf2;
+ byte *choosenCoords = _coords2;
+ int choosenLength = pathLen1;
+ if (pathLen1 < pathLen2) {
+ chosenCoordsBuf = _coordsBuf3;
+ choosenCoords = _coords3;
+ choosenLength = pathLen2;
+ }
+
+ if (choosenLength) {
+ if (chosenCoordsBuf != nullptr) {
+ int tempXBegin = READ_LE_UINT16(chosenCoordsBuf);
+ int tempYBegin = READ_LE_UINT16(chosenCoordsBuf + 2);
+ if (stX != tempXBegin || stY != tempYBegin) {
+ SWAP(chosenCoordsBuf, choosenCoords);
+ chosenCoordsBuf -= 4;
+ byte *tempCoordsBuf = _coordsBuf;
+ while (1) {
+ int cord = READ_LE_UINT32(chosenCoordsBuf);
+ WRITE_LE_UINT32(tempCoordsBuf, cord);
+ tempCoordsBuf += 4;
+ if (chosenCoordsBuf == choosenCoords) {
+ break;
+ }
+ chosenCoordsBuf -= 4;
+ }
+ _coords = tempCoordsBuf;
+ } else {
+ int sizeChoosen = choosenCoords - chosenCoordsBuf;
+ for (int i = 0; i < sizeChoosen; i++) {
+ _coordsBuf[i] = chosenCoordsBuf[i];
+ }
+ _coords = _coordsBuf + sizeChoosen;
+ }
+ WRITE_LE_UINT32(_coords, 0xFFFFFFFF);
+ freeCoords2();
+ freeCoords3();
+ scanDirections();
+
+ byte *tempCoordsBuf = _coordsBuf;
+ byte *tempCoords = _coords;
+ byte *newCoords;
+ if (tempCoordsBuf != tempCoords) {
+ int normCoordsSize = _coords - _coordsBuf + 4;
+ newCoords = (byte *)malloc(normCoordsSize);
+ byte *newCoordsBegin = newCoords;
+ while (tempCoordsBuf != tempCoords) {
+ int newValueX = READ_LE_UINT16(tempCoordsBuf);
+ WRITE_LE_UINT16(newCoords, newValueX * 2);
+ newCoords += 2;
+ int newValueY = READ_LE_UINT16(tempCoordsBuf + 2);
+ WRITE_LE_UINT16(newCoords, newValueY * 2);
+ newCoords += 2;
+ tempCoordsBuf += 4;
+ }
+ WRITE_LE_UINT16(newCoords - 4, realDestX);
+ WRITE_LE_UINT16(newCoords - 2, realDestY);
+ WRITE_LE_UINT32(newCoords, 0xFFFFFFFF);
+ newCoords += 4;
+ _shanLen = (newCoords - newCoordsBegin);
+ _shanLen /= 4;
+ return newCoordsBegin;
+ }
+ }
+ }
+ _coords = _coordsBuf;
+ freeCoords2();
+ freeCoords3();
+ return nullptr;
+ } else {
+ if (!heroId) {
+ _mainHero->freeOldMove();
+ _mainHero->_state = Hero::kHeroStateTurn;
+ } else if (heroId == 1) {
+ _secondHero->freeOldMove();
+ _secondHero->_state = Hero::kHeroStateTurn;
+ }
+ return nullptr;
+ }
+}
+
+void PrinceEngine::allocCoords2() {
+ if (_coordsBuf2 == nullptr) {
+ _coordsBuf2 = (byte *)malloc(kTracePts * 4);
+ _coords2 = _coordsBuf2;
+ }
+}
+
+void PrinceEngine::freeCoords2() {
+ if (_coordsBuf2 != nullptr) {
+ free(_coordsBuf2);
+ _coordsBuf2 = nullptr;
+ _coords2 = nullptr;
+ }
+}
+
+void PrinceEngine::freeCoords3() {
+ if (_coordsBuf3 != nullptr) {
+ free(_coordsBuf3);
+ _coordsBuf3 = nullptr;
+ _coords3 = nullptr;
+ }
+}
+
+void PrinceEngine::openInventoryCheck() {
+ if (!_optionsFlag) {
+ if (_mouseFlag == 1 || _mouseFlag == 2) {
+ if (_mainHero->_visible) {
+ if (!_flags->getFlagValue(Flags::INVALLOWED)) {
+ // 29 - Basement, 50 - Map
+ if (_locationNr != 29 && _locationNr != 50) {
+ Common::Point mousePos = _system->getEventManager()->getMousePos();
+ if (mousePos.y < 4 && !_showInventoryFlag) {
+ _invCounter++;
+ } else {
+ _invCounter = 0;
+ }
+ if (_invCounter >= _invMaxCount) {
+ inventoryFlagChange(true);
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
+void PrinceEngine::mainLoop() {
+ changeCursor(0);
+ _currentTime = _system->getMillis();
+
+ while (!shouldQuit()) {
+ Common::Event event;
+ Common::EventManager *eventMan = _system->getEventManager();
+ while (eventMan->pollEvent(event)) {
+ switch (event.type) {
+ case Common::EVENT_KEYDOWN:
+ keyHandler(event);
+ break;
+ case Common::EVENT_LBUTTONDOWN:
+ leftMouseButton();
+ break;
+ case Common::EVENT_RBUTTONDOWN:
+ rightMouseButton();
+ break;
+ default:
+ break;
+ }
+ }
+
+ if (shouldQuit()) {
+ return;
+ }
+
+ // for "throw a rock" mini-game
+ mouseWeirdo();
+
+ _interpreter->stepBg();
+ _interpreter->stepFg();
+
+ drawScreen();
+
+ _graph->update(_graph->_frontScreen);
+
+ openInventoryCheck();
+
+ pausePrinceEngine();
+ }
+}
+
+} // End of namespace Prince
diff --git a/engines/prince/prince.h b/engines/prince/prince.h
new file mode 100644
index 0000000000..6dce044a41
--- /dev/null
+++ b/engines/prince/prince.h
@@ -0,0 +1,674 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public 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 PRINCE_H
+#define PRINCE_H
+
+#include "common/random.h"
+#include "common/system.h"
+#include "common/debug.h"
+#include "common/debug-channels.h"
+#include "common/textconsole.h"
+#include "common/rect.h"
+#include "common/events.h"
+#include "common/endian.h"
+#include "common/savefile.h"
+#include "common/serializer.h"
+
+#include "image/bmp.h"
+
+#include "gui/debugger.h"
+
+#include "engines/engine.h"
+#include "engines/util.h"
+
+#include "audio/mixer.h"
+
+#include "video/flic_decoder.h"
+
+#include "prince/mob.h"
+#include "prince/object.h"
+#include "prince/pscr.h"
+
+namespace Prince {
+
+struct PrinceGameDescription;
+struct SavegameHeader;
+
+class PrinceEngine;
+class GraphicsMan;
+class Script;
+class Interpreter;
+class InterpreterFlags;
+class Debugger;
+class MusicPlayer;
+class VariaTxt;
+class Cursor;
+class MhwanhDecoder;
+class Font;
+class Hero;
+class Animation;
+class Room;
+class Pscr;
+
+struct Text {
+ const char *_str;
+ uint16 _x, _y;
+ uint16 _time;
+ uint32 _color;
+
+ Text() : _str(nullptr), _x(0), _y(0), _time(0), _color(255){
+ }
+};
+
+struct AnimListItem {
+ uint16 _type; // type of animation - for background anims RND of frame
+ uint16 _fileNumber;
+ uint16 _startPhase; // first phase number
+ uint16 _endPhase;
+ uint16 _loopPhase;
+ int16 _x;
+ int16 _y;
+ uint16 _loopType;
+ uint16 _nextAnim; // number of animation to do for loop = 3
+ uint16 _flags; // byte 0 - draw masks, byte 1 - draw in front of mask, byte 2 - load but turn off drawing
+ bool loadFromStream(Common::SeekableReadStream &stream);
+};
+
+struct BAS {
+ int32 _type; // type of sequence
+ int32 _data; // additional data
+ int32 _anims; // number of animations
+ int32 _current; // actual number of animation
+ int32 _counter; // time counter for animation
+ int32 _currRelative; //actual relative number for animation
+ int32 _data2; // additional data for measurements
+};
+
+const int kStructSizeBAS = 28;
+
+struct BASA {
+ int16 _num; // animation number
+ int16 _start; // initial frame
+ int16 _end; // final frame
+ //int16 _pad; // fulfilment to 8 bytes
+};
+
+const int kStructSizeBASA = 8;
+
+// background and normal animation
+struct Anim {
+ BASA _basaData;
+ int32 _addr; //animation adress
+ int16 _usage;
+ int16 _state; // state of animation: 0 - turning on, 1 - turning off
+ int16 _flags;
+ int16 _frame; // number of phase to show
+ int16 _lastFrame; // last phase
+ int16 _loopFrame; // first frame of loop
+ int16 _showFrame; // actual visible frame of animation
+ int16 _loopType; // type of loop (0 - last frame; 1 - normal loop (begin from _loopFrame); 2 - no loop; 3 - load new animation)
+ int16 _nextAnim; // number of next animation to load after actual
+ int16 _x;
+ int16 _y;
+ int32 _currFrame;
+ int16 _currX;
+ int16 _currY;
+ int16 _currW;
+ int16 _currH;
+ int16 _packFlag;
+ int32 _currShadowFrame;
+ int16 _packShadowFlag;
+ int32 _shadowBack;
+ int16 _relX;
+ int16 _relY;
+ Animation *_animData;
+ Animation *_shadowData;
+
+ enum AnimOffsets {
+ kAnimState = 10,
+ kAnimFrame = 14,
+ kAnimLastFrame = 16,
+ kAnimX = 26
+ };
+
+ int16 getAnimData(Anim::AnimOffsets offset) {
+ switch (offset) {
+ case kAnimState:
+ return _state;
+ case kAnimFrame:
+ return _frame + 1; // fix for location 30 - man with a dog animation
+ case kAnimX:
+ return _x;
+ default:
+ error("getAnimData() - Wrong offset type: %d", (int) offset);
+ }
+ }
+
+ void setAnimData(Anim::AnimOffsets offset, int16 value) {
+ if (offset == kAnimX) {
+ _x = value;
+ } else {
+ error("setAnimData() - Wrong offset: %d, value: %d", (int) offset, value);
+ }
+ }
+};
+
+struct BackgroundAnim {
+ BAS _seq;
+ Common::Array<Anim> backAnims;
+};
+
+enum AnimType {
+ kBackgroundAnimation,
+ kNormalAnimation
+};
+
+// Nak (PL - Nakladka)
+struct Mask {
+ uint16 _state; // visible / invisible
+ int16 _flags; // turning on / turning off of an mask
+ int16 _x1;
+ int16 _y1;
+ int16 _x2;
+ int16 _y2;
+ int16 _z;
+ int16 _number; // number of mask for background recreating
+ int16 _width;
+ int16 _height;
+ byte *_data;
+
+ int16 getX() const {
+ return READ_LE_UINT16(_data);
+ }
+
+ int16 getY() const {
+ return READ_LE_UINT16(_data + 2);
+ }
+
+ int16 getWidth() const {
+ return READ_LE_UINT16(_data + 4);
+ }
+
+ int16 getHeight() const {
+ return READ_LE_UINT16(_data + 6);
+ }
+
+ byte *getMask() const {
+ return (byte *)(_data + 8);
+ }
+};
+
+struct InvItem {
+ int _x;
+ int _y;
+ Graphics::Surface *_surface;
+ Graphics::Surface *getSurface() const { return _surface; }
+};
+
+struct DrawNode {
+ int posX;
+ int posY;
+ int posZ;
+ int32 width;
+ int32 height;
+ int32 scaleValue;
+ Graphics::Surface *s;
+ Graphics::Surface *originalRoomSurface;
+ void *data;
+ void (*drawFunction)(Graphics::Surface *, DrawNode *);
+};
+
+struct DebugChannel {
+
+enum Type {
+ kScript,
+ kEngine
+};
+
+};
+
+class PrinceEngine : public Engine {
+protected:
+ Common::Error run();
+
+public:
+ PrinceEngine(OSystem *syst, const PrinceGameDescription *gameDesc);
+ virtual ~PrinceEngine();
+
+ virtual bool hasFeature(EngineFeature f) const;
+ virtual void pauseEngineIntern(bool pause);
+ virtual bool canSaveGameStateCurrently();
+ virtual bool canLoadGameStateCurrently();
+ virtual Common::Error saveGameState(int slot, const Common::String &desc);
+ virtual Common::Error loadGameState(int slot);
+
+ static bool readSavegameHeader(Common::InSaveFile *in, SavegameHeader &header);
+ Common::String generateSaveName(int slot);
+ void writeSavegameHeader(Common::OutSaveFile *out, SavegameHeader &header);
+ void syncGame(Common::SeekableReadStream *readStream, Common::WriteStream *writeStream);
+ bool loadGame(int slotNumber);
+ void resetGame();
+
+ int32 _creditsDataSize;
+ byte *_creditsData;
+ void scrollCredits();
+
+ int getGameType() const;
+ const char *getGameId() const;
+ uint32 getFeatures() const;
+ Common::Language getLanguage() const;
+
+ const PrinceGameDescription *_gameDescription;
+ Video::FlicDecoder _flicPlayer;
+ const Graphics::Surface *_flcFrameSurface;
+ VariaTxt *_variaTxt;
+
+ uint32 _talkTxtSize;
+ byte *_talkTxt;
+
+ uint32 _mobTranslationSize;
+ byte *_mobTranslationData;
+
+ bool loadLocation(uint16 locationNr);
+ bool loadAnim(uint16 animNr, bool loop);
+ bool loadVoice(uint32 textSlot, uint32 sampleSlot, const Common::String &name);
+ bool loadSample(uint32 sampleSlot, const Common::String &name);
+ bool loadZoom(byte *zoomBitmap, uint32 dataSize, const char *resourceName);
+ bool loadShadow(byte *shadowBitmap, uint32 dataSize, const char *resourceName1, const char *resourceName2);
+ bool loadTrans(byte *transTable, const char *resourceName);
+ bool loadMobPriority(const char *resourceName);
+
+ void loadMobTranslationTexts();
+ void setMobTranslationTexts();
+
+ bool loadMusic(int musNumber);
+ void stopMusic();
+
+ void playSample(uint16 sampleId, uint16 loopType);
+ void stopSample(uint16 sampleId);
+ void stopAllSamples();
+ void freeSample(uint16 sampleId);
+ void freeAllSamples();
+
+ void setVoice(uint16 slot, uint32 sampleSlot, uint16 flag);
+
+ virtual GUI::Debugger *getDebugger();
+
+ void changeCursor(uint16 curId);
+ void printAt(uint32 slot, uint8 color, char *s, uint16 x, uint16 y);
+ int calcTextLines(const char *s);
+ int calcTextTime(int numberOfLines);
+ void correctStringDEU(char *s);
+
+ static const uint8 kMaxTexts = 32;
+ Text _textSlots[kMaxTexts];
+
+ Hero *_mainHero;
+ Hero *_secondHero;
+
+ enum HeroId {
+ kMainHero,
+ kSecondHero
+ };
+
+ int _mouseFlag;
+ uint32 _currentTime;
+ uint16 _locationNr;
+ uint16 _sceneWidth;
+ int32 _picWindowX;
+ int32 _picWindowY;
+
+ Image::BitmapDecoder *_roomBmp;
+ MhwanhDecoder *_suitcaseBmp;
+ Room *_room;
+ Script *_script;
+ InterpreterFlags *_flags;
+ Interpreter *_interpreter;
+ GraphicsMan *_graph;
+ uint8 _currentMidi;
+ byte *_zoomBitmap;
+ byte *_shadowBitmap;
+ byte *_transTable;
+
+ int16 _scaleValue; // scale for hero or special shadow animation
+ int16 _lightX; // for hero shadow
+ int16 _lightY;
+ int32 _shadScaleValue;
+ int32 _shadLineLen;
+ byte *_shadowLine;
+ void setShadowScale(int32 shadowScale);
+ static void plotShadowLinePoint(int x, int y, int color, void *data);
+
+ static const int16 kFPS = 15;
+ static const int32 kIntMax = 2147483647;
+
+ static const int16 kMaxPicWidth = 1280;
+ static const int16 kMaxPicHeight = 480;
+ static const int16 kZoomStep = 4;
+ static const int32 kZoomBitmapLen = kMaxPicHeight / kZoomStep * kMaxPicWidth / kZoomStep;
+ static const int32 kShadowBitmapSize = kMaxPicWidth * kMaxPicHeight / 8;
+ static const int16 kShadowLineArraySize = 2 * 1280 * 4;
+ static const int16 kZoomBitmapWidth = kMaxPicWidth / kZoomStep;
+ static const int16 kZoomBitmapHeight = kMaxPicHeight / kZoomStep;
+ static const int16 kNormalWidth = 640;
+ static const int16 kNormalHeight = 480;
+ static const uint32 kTransTableSize = 256 * 256;
+
+ static const int kMaxNormAnims = 64;
+ static const int kMaxBackAnims = 64;
+ static const int kMaxObjects = 64;
+ static const int kMaxMobs = 64;
+
+ Common::Array<DrawNode> _drawNodeList;
+ Common::Array<AnimListItem> _animList;
+ Common::Array<BackgroundAnim> _backAnimList;
+ Common::Array<Anim> _normAnimList;
+ Common::Array<Mob> _mobList;
+ Common::Array<uint32> _mobPriorityList;
+ Common::Array<Mask> _maskList;
+ Common::Array<Object *> _objList;
+ uint16 *_objSlot;
+
+ void freeNormAnim(int slot);
+ void freeAllNormAnims();
+ void removeSingleBackAnim(int slot);
+
+ Common::RandomSource _randomSource;
+
+ void checkMasks(int x1, int y1, int sprWidth, int sprHeight, int z);
+ void insertMasks(Graphics::Surface *originalRoomSurface);
+ void showMask(int maskNr, Graphics::Surface *originalRoomSurface);
+ void clsMasks();
+
+ void grabMap();
+
+ int _selectedMob; // number of selected Mob / inventory item
+ int _selectedItem; // number of item on mouse cursor
+ int _selectedMode;
+ int _currentPointerNumber;
+
+ static const int16 kMaxInv = 90; // max amount of inventory items in whole game
+ static const uint16 kMaxItems = 30; // size of inventory
+
+ uint32 _invTxtSize;
+ byte *_invTxt;
+
+ Graphics::Surface *_optionsPic;
+ Graphics::Surface *_optionsPicInInventory;
+
+ bool _optionsFlag;
+ int _optionEnabled;
+ int _optionsMob;
+ int _optionsX;
+ int _optionsY;
+ int _optionsWidth;
+ int _optionsHeight;
+ int _invOptionsWidth;
+ int _invOptionsHeight;
+ int _optionsStep;
+ int _invOptionsStep;
+ int _optionsNumber;
+ int _invOptionsNumber;
+ int _optionsColor1; // color for non-selected options
+ int _optionsColor2; // color for selected option
+
+ bool _showInventoryFlag;
+ int _invExamY;
+ bool _inventoryBackgroundRemember;
+ int _invLineX;
+ int _invLineY;
+ int _invLine; // number of items in one line
+ int _invLines; // number of lines with inventory items
+ int _invLineW;
+ int _invLineH;
+ int _maxInvW;
+ int _maxInvH;
+ int _invLineSkipX;
+ int _invLineSkipY;
+ int _invX1;
+ int _invY1;
+ int _invWidth;
+ int _invHeight;
+ bool _invCurInside;
+ int _mst_shadow;
+ int _mst_shadow2; // blinking after adding new item
+ int _candleCounter; // special counter for candle inventory item
+ int _invMaxCount; // time to turn inventory on
+ int _invCounter; // turning on counter
+
+ void inventoryFlagChange(bool inventoryState);
+ bool loadAllInv();
+ void rememberScreenInv();
+ void prepareInventoryToView();
+ void drawInvItems();
+ void displayInventory();
+ void addInv(int heroId, int item, bool addItemQuiet);
+ void remInv(int heroId, int item);
+ void clearInv(int heroId);
+ void swapInv(int heroId);
+ void addInvObj();
+ void makeInvCursor(int itemNr);
+ void enableOptions(bool checkType);
+ void checkOptions();
+ void checkInvOptions();
+ void openInventoryCheck();
+
+ void leftMouseButton();
+ void rightMouseButton();
+ void inventoryLeftMouseButton();
+ void inventoryRightMouseButton();
+ void dialogLeftMouseButton(byte *string, int dialogSelected);
+
+ uint32 _dialogDatSize;
+ byte *_dialogDat;
+ byte *_dialogData; // on, off flags for lines of dialog text
+
+ byte *_dialogBoxAddr[32]; // adresses of dialog windows
+ byte *_dialogOptAddr[32]; // adresses of dialog options
+ int _dialogOptLines[4 * 32]; // numbers of initial dialog lines
+
+ byte *_dialogText;
+ int _dialogLines;
+ bool _dialogFlag;
+ int _dialogWidth;
+ int _dialogHeight;
+ int _dialogLineSpace;
+ int _dialogColor1; // color for non-selected options
+ int _dialogColor2; // color for selected option
+ Graphics::Surface *_dialogImage;
+
+ void createDialogBox(int dialogBoxNr);
+ void dialogRun();
+ void talkHero(int slot);
+ void doTalkAnim(int animNumber, int slot, AnimType animType);
+
+ static const uint8 zoomInStep = 8;
+ void initZoomIn(int slot);
+ void initZoomOut(int slot);
+ void doZoomIn(int slot);
+ void doZoomOut(int slot);
+ void freeZoomObject(int slot);
+
+ static const uint8 kFadeStep = 4;
+ void blackPalette();
+ void setPalette(const byte *palette);
+
+ int getMob(Common::Array<Mob> &mobList, bool usePriorityList, int posX, int posY);
+
+ // 'Throw a rock' mini-game:
+ static const int16 kCurveLen = 17;
+ static const int kCelStep = 4;
+ int16 *_curveData;
+ int _curvPos;
+ void makeCurve();
+ void getCurve();
+ void mouseWeirdo();
+
+ static const uint16 kPowerBarPosX = 288;
+ static const uint16 kPowerBarPosY = 430;
+ static const uint8 kPowerBarWidth = 64;
+ static const uint8 kPowerBarHeight = 16;
+ static const uint8 kPowerBarBackgroundColor = 0;
+ static const uint16 kPowerBarGreenPosY = 434;
+ static const uint8 kPowerBarGreenColor1 = 202;
+ static const uint8 kPowerBarGreenColor2 = 235;
+ static const uint8 kPowerBarGreenHeight = 8;
+ void showPower();
+
+ // Pathfinding
+ static const int16 kPathGridStep = 2;
+ static const uint32 kPathBitmapLen = (kMaxPicHeight / kPathGridStep * kMaxPicWidth / kPathGridStep) / 8;
+ static const int32 kTracePts = 8000;
+ static const int32 kPBW = kMaxPicWidth / 16; // PathBitmapWidth
+ static const int kMinDistance = 2500;
+
+ byte *_roomPathBitmap; // PL - Sala
+ byte *_roomPathBitmapTemp; // PL - SSala
+ byte *_coordsBufEnd;
+ byte *_coordsBuf; // optimal path
+ byte *_coords; // last path point adress from coordsBuf
+ byte *_coordsBuf2;
+ byte *_coords2;
+ byte *_coordsBuf3;
+ byte *_coords3;
+ int _traceLineLen;
+ bool _traceLineFirstPointFlag; // if plotTraceLine after first point
+ bool _tracePointFirstPointFlag; // if plotTracePoint after first point
+ byte *_directionTable;
+ int _shanLen;
+
+ byte *_checkBitmapTemp;
+ byte *_checkBitmap;
+ int _checkMask;
+ int _checkX;
+ int _checkY;
+
+ byte *_rembBitmapTemp;
+ byte *_rembBitmap;
+ int _rembMask;
+ int _rembX;
+ int _rembY;
+
+ int _fpX;
+ int _fpY;
+
+ int drawLine(int x0, int y0, int x1, int y1, int (*plotProc)(int, int, void *), void *data);
+ bool loadPath(const char *resourceName);
+ byte *makePath(int heroId, int currX, int currY, int destX, int destY);
+ void findPoint(int x, int y);
+ int getPixelAddr(byte *pathBitmap, int x, int y);
+ static int plotTraceLine(int x, int y, void *data);
+ void specialPlotInside(int x, int y);
+ bool tracePath(int x1, int y1, int x2, int y2);
+ Direction makeDirection(int x1, int y1, int x2, int y2);
+ void specialPlot(int x, int y);
+ void specialPlot2(int x, int y);
+ void allocCoords2();
+ void freeCoords2();
+ void freeCoords3();
+ static int plotTracePoint(int x, int y, void *data);
+ void specialPlotInside2(int x, int y);
+ void approxPath();
+ void freeDirectionTable();
+ void scanDirections();
+ int scanDirectionsFindNext(byte *coords, int xDiff, int yDiff);
+ void moveShandria();
+ void walkTo();
+ void moveRunHero(int heroId, int x, int y, int dir, bool runHeroFlag);
+
+ int leftDownDir();
+ int leftDir();
+ int leftUpDir();
+ int rightDownDir();
+ int rightDir();
+ int rightUpDir();
+ int upLeftDir();
+ int upDir();
+ int upRightDir();
+ int downLeftDir();
+ int downDir();
+ int downRightDir();
+
+ int cpe();
+ int checkLeftDownDir();
+ int checkLeftDir();
+ int checkDownDir();
+ int checkUpDir();
+ int checkRightDir();
+ int checkLeftUpDir();
+ int checkRightDownDir();
+ int checkRightUpDir();
+
+private:
+ bool playNextFLCFrame();
+ void keyHandler(Common::Event event);
+ int checkMob(Graphics::Surface *screen, Common::Array<Mob> &mobList, bool usePriorityList);
+ void drawScreen();
+ void showTexts(Graphics::Surface *screen);
+ void init();
+ void showLogo();
+ void showAnim(Anim &anim);
+ void showNormAnims();
+ void setBackAnim(Anim &backAnim);
+ void showBackAnims();
+ void clearBackAnimList();
+ bool spriteCheck(int sprWidth, int sprHeight, int destX, int destY);
+ void showSprite(Graphics::Surface *spriteSurface, int destX, int destY, int destZ);
+ void showSpriteShadow(Graphics::Surface *shadowSurface, int destX, int destY, int destZ);
+ void showObjects();
+ void showParallax();
+ static bool compareDrawNodes(DrawNode d1, DrawNode d2);
+ void runDrawNodes();
+ void makeShadowTable(int brightness);
+ void pausePrinceEngine(int fps = kFPS);
+
+ uint32 getTextWidth(const char *s);
+ void debugEngine(const char *s, ...);
+
+ uint8 _cursorNr;
+
+ Common::RandomSource *_rnd;
+ Cursor *_cursor1;
+ Graphics::Surface *_cursor2;
+ Cursor *_cursor3;
+ Debugger *_debugger;
+ Font *_font;
+ MusicPlayer *_midiPlayer;
+
+ static const int kMaxSamples = 60;
+ Audio::RewindableAudioStream *_audioStream[kMaxSamples];
+ Audio::SoundHandle _soundHandle[kMaxSamples];
+
+ Common::Array<PScr *> _pscrList;
+ Common::Array<InvItem> _allInvList;
+ Common::Array<Mob> _invMobList;
+
+ bool _flicLooped;
+
+ void mainLoop();
+
+};
+
+} // End of namespace Prince
+
+#endif
diff --git a/engines/prince/pscr.cpp b/engines/prince/pscr.cpp
new file mode 100644
index 0000000000..d9d36a3356
--- /dev/null
+++ b/engines/prince/pscr.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; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public 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/archive.h"
+#include "common/stream.h"
+
+#include "prince/pscr.h"
+
+namespace Prince {
+
+PScr::PScr() : _x(0), _y(0), _step(0), _surface(nullptr)
+{
+}
+
+PScr::~PScr() {
+ if (_surface != nullptr) {
+ _surface->free();
+ delete _surface;
+ _surface = nullptr;
+ }
+}
+
+void PScr::loadSurface(Common::SeekableReadStream &stream) {
+ stream.skip(4);
+ int width = stream.readUint16LE();
+ int height = stream.readUint16LE();
+ _surface = new Graphics::Surface();
+ _surface->create(width, height, Graphics::PixelFormat::createFormatCLUT8());
+
+ for (int h = 0; h < _surface->h; h++) {
+ stream.read(_surface->getBasePtr(0, h), _surface->w);
+ }
+}
+
+bool PScr::loadFromStream(Common::SeekableReadStream &stream) {
+ int32 pos = stream.pos();
+ uint16 file = stream.readUint16LE();
+ if (file == 0xFFFF) {
+ return false;
+ }
+ _x = stream.readUint16LE();
+ _y = stream.readUint16LE();
+ _step = stream.readUint16LE();
+
+ const Common::String pscrStreamName = Common::String::format("PS%02d", file);
+ Common::SeekableReadStream *pscrStream = SearchMan.createReadStreamForMember(pscrStreamName);
+ if (pscrStream != nullptr) {
+ loadSurface(*pscrStream);
+ }
+ delete pscrStream;
+ stream.seek(pos + 12); // size of PScrList struct
+
+ return true;
+}
+
+} // End of namespace Prince
diff --git a/engines/prince/pscr.h b/engines/prince/pscr.h
new file mode 100644
index 0000000000..fdcdb524a9
--- /dev/null
+++ b/engines/prince/pscr.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 PRINCE_PSCR_H
+#define PRINCE_PSCR_H
+
+#include "graphics/surface.h"
+
+namespace Prince {
+
+class PScr {
+public:
+ PScr();
+ ~PScr();
+ int16 _x;
+ int16 _y;
+ int16 _step;
+ static const int16 kPScrZ = 1000;
+
+ bool loadFromStream(Common::SeekableReadStream &stream);
+ Graphics::Surface *getSurface() const { return _surface; }
+private:
+ void loadSurface(Common::SeekableReadStream &stream);
+ Graphics::Surface *_surface;
+};
+
+} // End of namespace Prince
+
+#endif
diff --git a/engines/prince/resource.h b/engines/prince/resource.h
new file mode 100644
index 0000000000..f42eb87842
--- /dev/null
+++ b/engines/prince/resource.h
@@ -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.
+ *
+ */
+
+#ifndef PRINCE_RESOURCE_H
+#define PRINCE_RESOURCE_H
+
+#include "common/stream.h"
+#include "common/archive.h"
+#include "common/debug-channels.h"
+#include "common/ptr.h"
+
+namespace Prince {
+
+namespace Resource {
+
+ template <typename T>
+ bool loadFromStream(T &resource, Common::SeekableReadStream &stream) {
+ return resource.loadStream(stream);
+ }
+
+ template<typename T>
+ bool loadResource(T *resource, const char *resourceName, bool required) {
+ Common::ScopedPtr<Common::SeekableReadStream> stream(SearchMan.createReadStreamForMember(resourceName));
+ if (!stream) {
+ if (required)
+ error("Can't load %s", resourceName);
+ return false;
+ }
+
+ return loadFromStream(*resource, *stream);
+ }
+
+ template <typename T>
+ bool loadResource(Common::Array<T> &array, Common::SeekableReadStream &stream, bool required = true) {
+ T t;
+ while (t.loadFromStream(stream))
+ array.push_back(t);
+
+ return true;
+ }
+
+
+ template <typename T>
+ bool loadResource(Common::Array<T> &array, const char *resourceName, bool required = true) {
+ Common::ScopedPtr<Common::SeekableReadStream> stream(SearchMan.createReadStreamForMember(resourceName));
+ if (!stream) {
+ if (required)
+ error("Can't load %s", resourceName);
+ return false;
+ }
+
+ return loadResource(array, *stream, required);
+ }
+
+ template <typename T>
+ bool loadResource(Common::Array<T *> &array, const char *resourceName, bool required = true) {
+
+ Common::ScopedPtr<Common::SeekableReadStream> stream(SearchMan.createReadStreamForMember(resourceName));
+ if (!stream) {
+ if (required)
+ error("Can't load %s", resourceName);
+ return false;
+ }
+
+ // FIXME: This is stupid. Maybe loadFromStream should be helper method that returns initiailzed object
+ while (true) {
+ T* t = new T();
+ if (!t->loadFromStream(*stream)) {
+ delete t;
+ break;
+ }
+ array.push_back(t);
+ }
+ return true;
+ }
+
+}
+
+} // End of namespace Prince
+
+#endif
diff --git a/engines/prince/saveload.cpp b/engines/prince/saveload.cpp
new file mode 100644
index 0000000000..46e598be70
--- /dev/null
+++ b/engines/prince/saveload.cpp
@@ -0,0 +1,531 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public 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 "prince/prince.h"
+#include "prince/graphics.h"
+#include "prince/detection.h"
+#include "prince/flags.h"
+#include "prince/script.h"
+#include "prince/hero.h"
+
+#include "common/savefile.h"
+#include "common/system.h"
+#include "common/config-manager.h"
+#include "common/memstream.h"
+
+#include "graphics/thumbnail.h"
+#include "graphics/surface.h"
+#include "graphics/palette.h"
+#include "graphics/scaler.h"
+
+namespace Prince {
+
+#define kBadSVG 99
+#define kSavegameVersion 1
+#define kSavegameStrSize 14
+#define kSavegameStr "SCUMMVM_PRINCE"
+
+class InterpreterFlags;
+class Interpreter;
+
+struct SavegameHeader {
+ uint8 version;
+ Common::String saveName;
+ Graphics::Surface *thumbnail;
+ int saveYear, saveMonth, saveDay;
+ int saveHour, saveMinutes;
+};
+
+int PrinceMetaEngine::getMaximumSaveSlot() const {
+ return 99;
+}
+
+SaveStateList PrinceMetaEngine::listSaves(const char *target) const {
+ Common::SaveFileManager *saveFileMan = g_system->getSavefileManager();
+ Common::StringArray filenames;
+ Common::String pattern = target;
+ pattern += ".???";
+
+ filenames = saveFileMan->listSavefiles(pattern);
+ sort(filenames.begin(), filenames.end()); // Sort (hopefully ensuring we are sorted numerically..)
+
+ SaveStateList saveList;
+ for (Common::StringArray::const_iterator filename = filenames.begin(); filename != filenames.end(); filename++) {
+ // Obtain the last 3 digits of the filename, since they correspond to the save slot
+ int slotNum = atoi(filename->c_str() + filename->size() - 3);
+
+ if (slotNum >= 0 && slotNum <= 99) {
+
+ Common::InSaveFile *file = saveFileMan->openForLoading(*filename);
+ if (file) {
+ Prince::SavegameHeader header;
+
+ // Check to see if it's a ScummVM savegame or not
+ char buffer[kSavegameStrSize + 1];
+ file->read(buffer, kSavegameStrSize + 1);
+
+ if (!strncmp(buffer, kSavegameStr, kSavegameStrSize + 1)) {
+ // Valid savegame
+ if (Prince::PrinceEngine::readSavegameHeader(file, header)) {
+ saveList.push_back(SaveStateDescriptor(slotNum, header.saveName));
+ if (header.thumbnail) {
+ header.thumbnail->free();
+ delete header.thumbnail;
+ }
+ }
+ } else {
+ // Must be an original format savegame
+ saveList.push_back(SaveStateDescriptor(slotNum, "Unknown"));
+ }
+
+ delete file;
+ }
+ }
+ }
+
+ return saveList;
+}
+
+SaveStateDescriptor PrinceMetaEngine::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) {
+ Prince::SavegameHeader header;
+
+ // Check to see if it's a ScummVM savegame or not
+ char buffer[kSavegameStrSize + 1];
+ f->read(buffer, kSavegameStrSize + 1);
+
+ bool hasHeader = !strncmp(buffer, kSavegameStr, kSavegameStrSize + 1) &&
+ Prince::PrinceEngine::readSavegameHeader(f, header);
+ delete f;
+
+ if (!hasHeader) {
+ // Original savegame perhaps?
+ SaveStateDescriptor desc(slot, "Unknown");
+ return desc;
+ } else {
+ // Create the return descriptor
+ SaveStateDescriptor desc(slot, header.saveName);
+ desc.setThumbnail(header.thumbnail);
+ desc.setSaveDate(header.saveYear, header.saveMonth, header.saveDay);
+ desc.setSaveTime(header.saveHour, header.saveMinutes);
+
+ return desc;
+ }
+ }
+
+ return SaveStateDescriptor();
+}
+
+bool PrinceEngine::readSavegameHeader(Common::InSaveFile *in, SavegameHeader &header) {
+ header.thumbnail = nullptr;
+
+ // Get the savegame version
+ header.version = in->readByte();
+ if (header.version > kSavegameVersion)
+ 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.saveYear = in->readSint16LE();
+ header.saveMonth = in->readSint16LE();
+ header.saveDay = in->readSint16LE();
+ header.saveHour = in->readSint16LE();
+ header.saveMinutes = in->readSint16LE();
+
+ return true;
+}
+
+void PrinceMetaEngine::removeSaveState(const char *target, int slot) const {
+ Common::String fileName = Common::String::format("%s.%03d", target, slot);
+ g_system->getSavefileManager()->removeSavefile(fileName);
+}
+
+bool PrinceEngine::canSaveGameStateCurrently() {
+ if (_mouseFlag && _mouseFlag != 3) {
+ if (_mainHero->_visible) {
+ // 29 - Basement
+ if (_locationNr != 29) {
+ // No dialog box and not in inventory
+ if (!_dialogFlag && !_showInventoryFlag) {
+ return true;
+ }
+ }
+ }
+ }
+ return false;
+}
+
+bool PrinceEngine::canLoadGameStateCurrently() {
+ if (_mouseFlag && _mouseFlag != 3) {
+ if (_mainHero->_visible) {
+ // 29 - Basement
+ if (_locationNr != 29) {
+ // No dialog box and not in inventory
+ if (!_dialogFlag && !_showInventoryFlag) {
+ return true;
+ }
+ }
+ }
+ }
+ return false;
+}
+
+Common::Error PrinceEngine::saveGameState(int slot, const Common::String &desc) {
+ // Set up the serializer
+ Common::String slotName = generateSaveName(slot);
+ Common::OutSaveFile *saveFile = g_system->getSavefileManager()->openForSaving(slotName);
+
+ // Write out the ScummVM savegame header
+ SavegameHeader header;
+ header.saveName = desc;
+ header.version = kSavegameVersion;
+ writeSavegameHeader(saveFile, header);
+
+ // Write out the data of the savegame
+ syncGame(nullptr, saveFile);
+
+ // Finish writing out game data
+ saveFile->finalize();
+ delete saveFile;
+
+ return Common::kNoError;
+}
+
+Common::String PrinceEngine::generateSaveName(int slot) {
+ return Common::String::format("%s.%03d", _targetName.c_str(), slot);
+}
+
+void PrinceEngine::writeSavegameHeader(Common::OutSaveFile *out, SavegameHeader &header) {
+ // Write out a savegame header
+ out->write(kSavegameStr, kSavegameStrSize + 1);
+
+ out->writeByte(kSavegameVersion);
+
+ // Write savegame name
+ out->write(header.saveName.c_str(), header.saveName.size() + 1);
+
+ // Get the active palette
+ uint8 thumbPalette[256 * 3];
+ _system->getPaletteManager()->grabPalette(thumbPalette, 0, 256);
+
+ // Create a thumbnail and save it
+ Graphics::Surface *thumb = new Graphics::Surface();
+ Graphics::Surface *s = _graph->_frontScreen; // check inventory / map etc..
+ ::createThumbnail(thumb, (const byte *)s->getPixels(), s->w, s->h, thumbPalette);
+ Graphics::saveThumbnail(*out, *thumb);
+ thumb->free();
+ delete thumb;
+
+ // 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);
+}
+
+void PrinceEngine::syncGame(Common::SeekableReadStream *readStream, Common::WriteStream *writeStream) {
+ int emptyRoom = 0x00;
+ int normRoom = 0xFF;
+ byte endInv = 0xFF;
+
+ Common::Serializer s(readStream, writeStream);
+
+ if (s.isSaving()) {
+ // Flag values
+ for (int i = 0; i < _flags->kMaxFlags; i++) {
+ uint32 value = _flags->getFlagValue((Flags::Id)(_flags->kFlagMask + i));
+ s.syncAsUint32LE(value);
+ }
+
+ // Dialog data
+ for (uint32 i = 0; i < _dialogDatSize; i++) {
+ byte value = _dialogDat[i];
+ s.syncAsByte(value);
+ }
+
+ // Location number
+ s.syncAsUint16LE(_locationNr);
+
+ // Rooms
+ for (int roomId = 0; roomId < _script->kMaxRooms; roomId++) {
+ Room *room = new Room();
+ room->loadRoom(_script->getRoomOffset(roomId));
+
+ if (room->_mobs) {
+ s.syncAsByte(normRoom);
+ } else {
+ s.syncAsByte(emptyRoom);
+ delete room;
+ continue;
+ }
+
+ // Mobs
+ for (int mobId = 0; mobId < kMaxMobs; mobId++) {
+ byte value = _script->getMobVisible(room->_mobs, mobId);
+ s.syncAsByte(value);
+ }
+
+ // Background animations
+ for (int backAnimSlot = 0; backAnimSlot < kMaxBackAnims; backAnimSlot++) {
+ uint32 value = _script->getBackAnimId(room->_backAnim, backAnimSlot);
+ s.syncAsUint32LE(value);
+ }
+
+ // Objects
+ for (int objectSlot = 0; objectSlot < kMaxObjects; objectSlot++) {
+ byte value = _script->getObjId(room->_obj, objectSlot);
+ s.syncAsByte(value);
+ }
+
+ delete room;
+ }
+
+ // Main hero
+ s.syncAsUint16LE(_mainHero->_visible);
+ s.syncAsUint16LE(_mainHero->_middleX);
+ s.syncAsUint16LE(_mainHero->_middleY);
+ s.syncAsUint16LE(_mainHero->_lastDirection);
+ s.syncAsUint32LE(_mainHero->_color);
+ s.syncAsUint16LE(_mainHero->_maxBoredom);
+ s.syncAsUint32LE(_mainHero->_animSetNr);
+
+ for (uint inv1Slot = 0; inv1Slot < _mainHero->_inventory.size(); inv1Slot++) {
+ s.syncAsByte(_mainHero->_inventory[inv1Slot]);
+ }
+ s.syncAsByte(endInv);
+
+ for (uint inv2Slot = 0; inv2Slot < _mainHero->_inventory2.size(); inv2Slot++) {
+ s.syncAsByte(_mainHero->_inventory2[inv2Slot]);
+ }
+ s.syncAsByte(endInv);
+
+ // Second hero
+ s.syncAsUint16LE(_secondHero->_visible);
+ s.syncAsUint16LE(_secondHero->_middleX);
+ s.syncAsUint16LE(_secondHero->_middleY);
+ s.syncAsUint16LE(_secondHero->_lastDirection);
+ s.syncAsUint32LE(_secondHero->_color);
+ s.syncAsUint16LE(_secondHero->_maxBoredom);
+ s.syncAsUint32LE(_secondHero->_animSetNr);
+
+ for (uint inv1Slot = 0; inv1Slot < _secondHero->_inventory.size(); inv1Slot++) {
+ s.syncAsByte(_secondHero->_inventory[inv1Slot]);
+ }
+ s.syncAsByte(endInv);
+
+ for (uint inv2Slot = 0; inv2Slot < _secondHero->_inventory2.size(); inv2Slot++) {
+ s.syncAsByte(_secondHero->_inventory2[inv2Slot]);
+ }
+ s.syncAsByte(endInv);
+
+ } else {
+ // Cursor reset
+ changeCursor(1);
+ _currentPointerNumber = 1;
+
+ // Flag values
+ for (int i = 0; i < _flags->kMaxFlags; i++) {
+ uint32 value = 0;
+ s.syncAsUint32LE(value);
+ _flags->setFlagValue((Flags::Id)(_flags->kFlagMask + i), value);
+ }
+
+ // Dialog data
+ for (uint32 i = 0; i < _dialogDatSize; i++) {
+ byte value = 0;
+ s.syncAsByte(value);
+ _dialogDat[i] = value;
+ }
+
+ // Location number
+ int restoreRoom = 0;
+ s.syncAsUint16LE(restoreRoom);
+ _flags->setFlagValue(Flags::RESTOREROOM, restoreRoom);
+
+ // Rooms
+ for (int roomId = 0; roomId < _script->kMaxRooms; roomId++) {
+ Room *room = new Room();
+ room->loadRoom(_script->getRoomOffset(roomId));
+
+ byte roomType = emptyRoom;
+ s.syncAsByte(roomType);
+ if (roomType == emptyRoom) {
+ delete room;
+ continue;
+ }
+
+ // Mobs
+ for (int mobId = 0; mobId < kMaxMobs; mobId++) {
+ byte value = 0;
+ s.syncAsByte(value);
+ _script->setMobVisible(room->_mobs, mobId, value);
+ }
+
+ // Background animations
+ for (int backAnimSlot = 0; backAnimSlot < kMaxBackAnims; backAnimSlot++) {
+ uint32 value = 0;
+ s.syncAsUint32LE(value);
+ _script->setBackAnimId(room->_backAnim, backAnimSlot, value);
+ }
+
+ // Objects
+ for (int objectSlot = 0; objectSlot < kMaxObjects; objectSlot++) {
+ byte value = 0;
+ s.syncAsByte(value);
+ _script->setObjId(room->_obj, objectSlot, value);
+ }
+
+ delete room;
+ }
+
+ // Main hero
+ s.syncAsUint16LE(_mainHero->_visible);
+ s.syncAsUint16LE(_mainHero->_middleX);
+ s.syncAsUint16LE(_mainHero->_middleY);
+ s.syncAsUint16LE(_mainHero->_lastDirection);
+ s.syncAsUint32LE(_mainHero->_color);
+ s.syncAsUint16LE(_mainHero->_maxBoredom);
+ s.syncAsUint32LE(_mainHero->_animSetNr);
+ _mainHero->loadAnimSet(_mainHero->_animSetNr);
+
+ _mainHero->_inventory.clear();
+ byte invId = endInv;
+ while (1) {
+ s.syncAsByte(invId);
+ if (invId == endInv) {
+ break;
+ }
+ _mainHero->_inventory.push_back(invId);
+ }
+
+ _mainHero->_inventory2.clear();
+ invId = endInv;
+ while (1) {
+ s.syncAsByte(invId);
+ if (invId == endInv) {
+ break;
+ }
+ _mainHero->_inventory2.push_back(invId);
+ }
+
+ // Second hero
+ s.syncAsUint16LE(_secondHero->_visible);
+ s.syncAsUint16LE(_secondHero->_middleX);
+ s.syncAsUint16LE(_secondHero->_middleY);
+ s.syncAsUint16LE(_secondHero->_lastDirection);
+ s.syncAsUint32LE(_secondHero->_color);
+ s.syncAsUint16LE(_secondHero->_maxBoredom);
+ s.syncAsUint32LE(_secondHero->_animSetNr);
+ _secondHero->loadAnimSet(_secondHero->_animSetNr);
+
+ _secondHero->_inventory.clear();
+ invId = endInv;
+ while (1) {
+ s.syncAsByte(invId);
+ if (invId == endInv) {
+ break;
+ }
+ _secondHero->_inventory.push_back(invId);
+ }
+
+ _secondHero->_inventory2.clear();
+ invId = endInv;
+ while (1) {
+ s.syncAsByte(invId);
+ if (invId == endInv) {
+ break;
+ }
+ _secondHero->_inventory2.push_back(invId);
+ }
+
+ // Script
+ _interpreter->setBgOpcodePC(0);
+ _interpreter->setFgOpcodePC(_script->_scriptInfo.restoreGame);
+
+ }
+}
+
+Common::Error PrinceEngine::loadGameState(int slot) {
+ if (!loadGame(slot)) {
+ return Common::kReadingFailed;
+ }
+ return Common::kNoError;
+}
+
+bool PrinceEngine::loadGame(int slotNumber) {
+ Common::MemoryReadStream *readStream;
+
+ // Open up the savegame file
+ Common::String slotName = generateSaveName(slotNumber);
+ Common::InSaveFile *saveFile = g_system->getSavefileManager()->openForLoading(slotName);
+
+ // Read the data into a data buffer
+ int size = saveFile->size();
+ byte *dataBuffer = (byte *)malloc(size);
+ saveFile->read(dataBuffer, size);
+ readStream = new Common::MemoryReadStream(dataBuffer, size, DisposeAfterUse::YES);
+ delete saveFile;
+
+ // Check to see if it's a ScummVM savegame or not
+ char buffer[kSavegameStrSize + 1];
+ readStream->read(buffer, kSavegameStrSize + 1);
+
+ if (strncmp(buffer, kSavegameStr, kSavegameStrSize + 1) != 0) {
+ delete readStream;
+ return false;
+ } else {
+ SavegameHeader saveHeader;
+
+ if (!readSavegameHeader(readStream, saveHeader)) {
+ delete readStream;
+ return false;
+ }
+
+ // Delete the thumbnail
+ saveHeader.thumbnail->free();
+ delete saveHeader.thumbnail;
+ }
+
+ // Get in the savegame
+ syncGame(readStream, nullptr);
+ delete readStream;
+
+ return true;
+}
+
+} // End of namespace Prince
diff --git a/engines/prince/script.cpp b/engines/prince/script.cpp
new file mode 100644
index 0000000000..4ed3cee6f3
--- /dev/null
+++ b/engines/prince/script.cpp
@@ -0,0 +1,2082 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public 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 "prince/script.h"
+#include "prince/prince.h"
+#include "prince/flags.h"
+#include "prince/variatxt.h"
+#include "prince/font.h"
+#include "prince/hero.h"
+#include "prince/resource.h"
+#include "prince/animation.h"
+
+#include "common/debug.h"
+#include "common/debug-channels.h"
+#include "common/archive.h"
+#include "common/memstream.h"
+
+namespace Prince {
+
+static const uint16 kNumOpcodes = 144;
+
+Room::Room() {}
+
+bool Room::loadRoom(byte *roomData) {
+ int roomSize = 64;
+ Common::MemoryReadStream roomStream(roomData, roomSize);
+
+ _mobs = roomStream.readSint32LE();
+ _backAnim = roomStream.readSint32LE();
+ _obj = roomStream.readSint32LE();
+ _nak = roomStream.readSint32LE();
+ _itemUse = roomStream.readSint32LE();
+ _itemGive = roomStream.readSint32LE();
+ _walkTo = roomStream.readSint32LE();
+ _examine = roomStream.readSint32LE();
+ _pickup = roomStream.readSint32LE();
+ _use = roomStream.readSint32LE();
+ _pushOpen = roomStream.readSint32LE();
+ _pullClose = roomStream.readSint32LE();
+ _talk = roomStream.readSint32LE();
+ _give = roomStream.readSint32LE();
+
+ return true;
+}
+
+int Room::getOptionOffset(int option) {
+ switch (option) {
+ case 0:
+ return _walkTo;
+ case 1:
+ return _examine;
+ case 2:
+ return _pickup;
+ case 3:
+ return _use;
+ case 4:
+ return _pushOpen;
+ case 5:
+ return _pullClose;
+ case 6:
+ return _talk;
+ case 7:
+ return _give;
+ default:
+ error("Wrong option - nr %d", option);
+ }
+}
+
+Script::Script(PrinceEngine *vm) : _vm(vm), _data(nullptr), _dataSize(0) {
+}
+
+Script::~Script() {
+ if (_data != nullptr) {
+ free(_data);
+ _dataSize = 0;
+ _data = nullptr;
+ }
+}
+
+bool Script::loadStream(Common::SeekableReadStream &stream) {
+ _dataSize = stream.size();
+ if (!_dataSize) {
+ return false;
+ }
+
+ _data = (byte *)malloc(_dataSize);
+
+ if (!_data) {
+ return false;
+ }
+
+ stream.read(_data, _dataSize);
+
+ Common::MemoryReadStream scriptDataStream(_data, _dataSize);
+ _scriptInfo.rooms = scriptDataStream.readSint32LE();
+ _scriptInfo.startGame = scriptDataStream.readSint32LE();
+ _scriptInfo.restoreGame = scriptDataStream.readSint32LE();
+ _scriptInfo.stdExamine = scriptDataStream.readSint32LE();
+ _scriptInfo.stdPickup = scriptDataStream.readSint32LE();
+ _scriptInfo.stdUse = scriptDataStream.readSint32LE();
+ _scriptInfo.stdOpen = scriptDataStream.readSint32LE();
+ _scriptInfo.stdClose = scriptDataStream.readSint32LE();
+ _scriptInfo.stdTalk = scriptDataStream.readSint32LE();
+ _scriptInfo.stdGive = scriptDataStream.readSint32LE();
+ _scriptInfo.usdCode = scriptDataStream.readSint32LE();
+ _scriptInfo.invObjExam = scriptDataStream.readSint32LE();
+ _scriptInfo.invObjUse = scriptDataStream.readSint32LE();
+ _scriptInfo.invObjUU = scriptDataStream.readSint32LE();
+ _scriptInfo.stdUseItem = scriptDataStream.readSint32LE();
+ _scriptInfo.lightSources = scriptDataStream.readSint32LE();
+ _scriptInfo.specRout = scriptDataStream.readSint32LE();
+ _scriptInfo.invObjGive = scriptDataStream.readSint32LE();
+ _scriptInfo.stdGiveItem = scriptDataStream.readSint32LE();
+ _scriptInfo.goTester = scriptDataStream.readSint32LE();
+
+ return true;
+}
+
+uint16 Script::readScript16(uint32 address) {
+ assert((_data + address + sizeof(uint16)) <= (_data + _dataSize));
+ uint16 data = READ_LE_UINT16(&_data[address]);
+ return data;
+}
+
+uint32 Script::readScript32(uint32 address) {
+ assert((_data + address + sizeof(uint32)) <= (_data + _dataSize));
+ uint32 data = READ_LE_UINT32(&_data[address]);
+ return data;
+}
+
+int16 Script::getLightX(int locationNr) {
+ return (int)READ_LE_UINT16(&_data[_scriptInfo.lightSources + locationNr * 8]);
+}
+
+int16 Script::getLightY(int locationNr) {
+ return (int)READ_LE_UINT16(&_data[_scriptInfo.lightSources + locationNr * 8 + 2]);
+}
+
+int32 Script::getShadowScale(int locationNr) {
+ return (int)READ_LE_UINT16(&_data[_scriptInfo.lightSources + locationNr * 8 + 4]);
+}
+
+uint32 Script::getStartGameOffset() {
+ return _scriptInfo.startGame;
+}
+
+uint32 Script::getLocationInitScript(int initRoomTableOffset, int roomNr) {
+ return (uint32)READ_LE_UINT32(&_data[initRoomTableOffset + roomNr * 4]);
+}
+
+byte Script::getMobVisible(int roomMobOffset, uint16 mob) {
+ return _data[roomMobOffset + mob];
+}
+
+void Script::setMobVisible(int roomMobOffset, uint16 mob, byte value) {
+ _data[roomMobOffset + mob] = value;
+}
+
+uint8 *Script::getRoomOffset(int locationNr) {
+ return &_data[_scriptInfo.rooms + locationNr * 64];
+}
+
+int32 Script::getOptionStandardOffset(int option) {
+ switch (option) {
+ case 1:
+ return _scriptInfo.stdExamine;
+ case 2:
+ return _scriptInfo.stdPickup;
+ case 3:
+ return _scriptInfo.stdUse;
+ case 4:
+ return _scriptInfo.stdOpen;
+ case 5:
+ return _scriptInfo.stdClose;
+ case 6:
+ return _scriptInfo.stdTalk;
+ case 7:
+ return _scriptInfo.stdGive;
+ default:
+ error("Wrong standard option - nr %d", option);
+ }
+}
+
+uint8 *Script::getHeroAnimName(int offset) {
+ return &_data[offset];
+}
+
+uint32 Script::getBackAnimId(int roomBackAnimOffset, int slot) {
+ uint32 animId = READ_LE_UINT32(&_data[roomBackAnimOffset + slot * 4]);
+ return animId;
+}
+
+void Script::setBackAnimId(int roomBackAnimOffset, int slot, int animId) {
+ WRITE_LE_UINT32(&_data[roomBackAnimOffset + slot * 4], animId);
+}
+
+byte Script::getObjId(int roomObjOffset, int slot) {
+ return _data[roomObjOffset + slot];
+}
+
+void Script::setObjId(int roomObjOffset, int slot, byte objectId) {
+ _data[roomObjOffset + slot] = objectId;
+}
+
+int Script::scanMobEvents(int mobMask, int dataEventOffset) {
+ debug("mobMask: %d", mobMask);
+ int i = 0;
+ int16 mob;
+ int32 code;
+ do {
+ mob = (int)READ_LE_UINT16(&_data[dataEventOffset + i * 6]);
+ if (mob == mobMask) {
+ code = (int)READ_LE_UINT32(&_data[dataEventOffset + i * 6 + 2]);
+ debug("code: %d", code);
+ return code;
+ }
+ i++;
+ } while (mob != -1);
+ return -1;
+}
+
+int Script::scanMobEventsWithItem(int mobMask, int dataEventOffset, int itemMask) {
+ debug("mobMask: %d", mobMask);
+ int i = 0;
+ int16 mob;
+ int16 item;
+ int32 code;
+ do {
+ mob = (int)READ_LE_UINT16(&_data[dataEventOffset + i * 8]);
+ if (mob == mobMask) {
+ item = (int)READ_LE_UINT16(&_data[dataEventOffset + i * 8 + 2]);
+ if (item == itemMask) {
+ code = (int)READ_LE_UINT32(&_data[dataEventOffset + i * 8 + 4]);
+ debug("itemMask: %d", item);
+ debug("code: %d", code);
+ return code;
+ }
+ }
+ i++;
+ } while (mob != -1);
+ return -1;
+}
+
+void Script::installSingleBackAnim(Common::Array<BackgroundAnim> &backAnimList, int slot, int roomBackAnimOffset) {
+
+ _vm->removeSingleBackAnim(slot); // free slot before loading
+
+ int offset = roomBackAnimOffset + slot * 4; // BackgroundAnim offset for selected slot number
+
+ BackgroundAnim newBackgroundAnim; // BackgroundAnim seq data and its array of Anim
+
+ int animOffset = READ_LE_UINT32(&_data[offset]); // pos of BackgroundAnim data in script
+ int anims = READ_LE_UINT32(&_data[animOffset + 8]); // amount of Anim in BackgroundAnim
+
+ if (anims == 0) {
+ anims = 1; // anims with 0 as amount in game data has just 1 animation
+ }
+
+ if (animOffset != 0) {
+ Common::MemoryReadStream stream(_data, _dataSize); // stream from script data
+ for (int i = 0; i < anims; i++) {
+ Anim newAnim;
+ stream.seek(animOffset + kStructSizeBAS + kStructSizeBASA * i);
+ // Anim BASA data
+ newAnim._basaData._num = stream.readUint16LE();
+ newAnim._basaData._start = stream.readUint16LE();
+ newAnim._basaData._end = stream.readUint16LE();
+
+ // Anim number in game files
+ int animNumber = newAnim._basaData._num;
+ const Common::String animName = Common::String::format("AN%02d", animNumber);
+ const Common::String shadowName = Common::String::format("AN%02dS", animNumber);
+ newAnim._animData = new Animation();
+ newAnim._shadowData = new Animation();
+ Resource::loadResource(newAnim._animData, animName.c_str(), true);
+ if (!Resource::loadResource(newAnim._shadowData, shadowName.c_str(), false)) {
+ delete newAnim._shadowData;
+ newAnim._shadowData = nullptr;
+ }
+
+ newAnim._usage = 0;
+ newAnim._state = 0; // enabled
+ if ((_vm->_animList[animNumber]._flags & 4)) {
+ newAnim._state = 1;
+ newAnim._frame = _vm->_animList[animNumber]._endPhase;
+ newAnim._showFrame = _vm->_animList[animNumber]._endPhase;
+ } else {
+ newAnim._frame = _vm->_animList[animNumber]._startPhase;
+ newAnim._showFrame = _vm->_animList[animNumber]._startPhase;
+ }
+ newAnim._flags = _vm->_animList[animNumber]._flags;
+ newAnim._lastFrame = _vm->_animList[animNumber]._endPhase;
+ newAnim._loopFrame = _vm->_animList[animNumber]._loopPhase;
+ newAnim._loopType = _vm->_animList[animNumber]._loopType;
+ newAnim._nextAnim = _vm->_animList[animNumber]._nextAnim;
+ newAnim._x = _vm->_animList[animNumber]._x;
+ newAnim._y = _vm->_animList[animNumber]._y;
+ newAnim._currFrame = 0;
+ newAnim._currX = _vm->_animList[animNumber]._x;
+ newAnim._currY = _vm->_animList[animNumber]._y;
+ newAnim._currW = 0;
+ newAnim._currH = 0;
+ newAnim._packFlag = 0;
+ newAnim._shadowBack = _vm->_animList[animNumber]._type;
+ newBackgroundAnim.backAnims.push_back(newAnim);
+ }
+
+ // Anim BAS data
+ stream.seek(animOffset);
+ newBackgroundAnim._seq._type = stream.readUint32LE();
+ newBackgroundAnim._seq._data = stream.readUint32LE();
+ newBackgroundAnim._seq._anims = stream.readUint32LE();
+ stream.skip(12);
+ newBackgroundAnim._seq._current = newBackgroundAnim.backAnims[0]._basaData._num;
+ newBackgroundAnim._seq._counter = 0;
+ newBackgroundAnim._seq._currRelative = 0;
+ newBackgroundAnim._seq._data2 = stream.readUint32LE();
+
+ int start = newBackgroundAnim.backAnims[0]._basaData._start; // BASA_Start of first frame
+ int end = newBackgroundAnim.backAnims[0]._basaData._end; // BASA_End of first frame
+
+ if (start != -1) {
+ newBackgroundAnim.backAnims[0]._frame = start;
+ newBackgroundAnim.backAnims[0]._showFrame = start;
+ newBackgroundAnim.backAnims[0]._loopFrame = start;
+ }
+
+ if (end != -1) {
+ newBackgroundAnim.backAnims[0]._lastFrame = end;
+ }
+
+ backAnimList[slot] = newBackgroundAnim;
+ }
+}
+
+void Script::installBackAnims(Common::Array<BackgroundAnim> &backAnimList, int roomBackAnimOffset) {
+ for (int i = 0; i < _vm->kMaxBackAnims; i++) {
+ installSingleBackAnim(backAnimList, i, roomBackAnimOffset);
+ }
+}
+
+void Script::installObjects(int offset) {
+ for (int i = 0; i < _vm->kMaxObjects; i++) {
+ _vm->_objSlot[i] = _data[offset];
+ offset++;
+ }
+}
+
+bool Script::loadAllMasks(Common::Array<Mask> &maskList, int offset) {
+ Mask tempMask;
+ while (1) {
+ Common::MemoryReadStream maskStream(_data, _dataSize);
+ maskStream.seek(offset);
+ tempMask._state = maskStream.readUint16LE();
+ if (tempMask._state == 0xffff) {
+ break;
+ }
+ tempMask._flags = maskStream.readUint16LE();
+ tempMask._x1 = maskStream.readUint16LE();
+ tempMask._y1 = maskStream.readUint16LE();
+ tempMask._x2 = maskStream.readUint16LE();
+ tempMask._y2 = maskStream.readUint16LE();
+ tempMask._z = maskStream.readUint16LE();
+ tempMask._number = maskStream.readUint16LE();
+
+ const Common::String msStreamName = Common::String::format("MS%02d", tempMask._number);
+ Common::SeekableReadStream *msStream = SearchMan.createReadStreamForMember(msStreamName);
+ if (!msStream) {
+ tempMask._width = 0;
+ tempMask._height = 0;
+ tempMask._data = nullptr;
+ debug("Can't load %s", msStreamName.c_str());
+ delete msStream;
+ } else {
+ int32 dataSize = msStream->size();
+ if (dataSize != -1) {
+ tempMask._data = (byte *)malloc(dataSize);
+ if (msStream->read(tempMask._data, dataSize) != (uint32)dataSize) {
+ free(tempMask._data);
+ delete msStream;
+ return false;
+ }
+ delete msStream;
+ }
+ tempMask._width = tempMask.getWidth();
+ tempMask._height = tempMask.getHeight();
+ }
+
+ maskList.push_back(tempMask);
+ offset += 16; // size of Mask (Nak) struct
+ }
+ return true;
+}
+
+InterpreterFlags::InterpreterFlags() {
+ resetAllFlags();
+}
+
+void InterpreterFlags::resetAllFlags() {
+ memset(_flags, 0, sizeof(_flags));
+}
+
+void InterpreterFlags::setFlagValue(Flags::Id flagId, int32 value) {
+ _flags[(uint32)flagId - kFlagMask] = value;
+}
+
+int32 InterpreterFlags::getFlagValue(Flags::Id flagId) {
+ return _flags[(uint32)flagId - kFlagMask];
+}
+
+Interpreter::Interpreter(PrinceEngine *vm, Script *script, InterpreterFlags *flags) :
+ _vm(vm), _script(script), _flags(flags),
+ _stacktop(0), _opcodeNF(false), _opcodeEnd(false),
+ _waitFlag(0), _result(true) {
+
+ // Initialize the script
+ _mode = "fg";
+ _fgOpcodePC = _script->getStartGameOffset();
+ _bgOpcodePC = 0;
+}
+
+void Interpreter::debugInterpreter(const char *s, ...) {
+ char buf[STRINGBUFLEN];
+ va_list va;
+ va_start(va, s);
+ vsnprintf(buf, STRINGBUFLEN, s, va);
+ va_end(va);
+
+ Common::String str = Common::String::format("@0x%08X: ", _lastInstruction);
+ str += Common::String::format("op %04d: ", _lastOpcode);
+ //debugC(10, DebugChannel::kScript, "PrinceEngine::Script %s %s", str.c_str(), buf);
+ if (!strcmp(_mode, "fg")) {
+ debug(10, "PrinceEngine::Script %s %s", str.c_str(), buf);
+ }
+ //debug("Prince::Script mode %s %s %s", _mode, str.c_str(), buf);
+}
+
+void Interpreter::stepBg() {
+ if (_bgOpcodePC) {
+ _mode = "bg";
+ _bgOpcodePC = step(_bgOpcodePC);
+ }
+}
+
+void Interpreter::stepFg() {
+ if (_fgOpcodePC) {
+ _mode = "fg";
+ _fgOpcodePC = step(_fgOpcodePC);
+ }
+}
+
+uint32 Interpreter::step(uint32 opcodePC) {
+ _currentInstruction = opcodePC;
+
+ while (!_opcodeNF) {
+ _lastInstruction = _currentInstruction;
+
+ // Get the current opcode
+ _lastOpcode = readScript16();
+
+ if (_lastOpcode >= kNumOpcodes)
+ error(
+ "Trying to execute unknown opcode @0x%04X: %02d",
+ _currentInstruction,
+ _lastOpcode);
+
+ // Execute the current opcode
+ OpcodeFunc op = _opcodes[_lastOpcode];
+ (this->*op)();
+ if (_opcodeNF) {
+ _opcodeNF = 0;
+ break;
+ }
+ }
+
+ if (_opcodeEnd) {
+ _vm->quitGame();
+ }
+
+ return _currentInstruction;
+}
+
+void Interpreter::storeNewPC(int opcodePC) {
+ if (_flags->getFlagValue(Flags::GETACTION) == 1) {
+ _flags->setFlagValue(Flags::GETACTIONDATA, opcodePC);
+ opcodePC = _flags->getFlagValue(Flags::GETACTIONBACK);
+ }
+ _fgOpcodePC = opcodePC;
+}
+
+int Interpreter::getLastOPCode() {
+ return _lastOpcode;
+}
+
+int Interpreter::getFgOpcodePC() {
+ return _fgOpcodePC;
+}
+
+uint32 Interpreter::getCurrentString() {
+ return _currentString;
+}
+
+void Interpreter::setCurrentString(uint32 value) {
+ _currentString = value;
+}
+
+byte *Interpreter::getString() {
+ return _string;
+}
+
+void Interpreter::setString(byte *newString) {
+ _string = newString;
+}
+
+void Interpreter::increaseString() {
+ while (*_string) {
+ _string++;
+ }
+ _string++;
+}
+
+void Interpreter::setResult(byte value) {
+ _result = value;
+}
+
+void Interpreter::setBgOpcodePC(uint32 value) {
+ _bgOpcodePC = value;
+}
+
+void Interpreter::setFgOpcodePC(uint32 value) {
+ _fgOpcodePC = value;
+}
+
+uint16 Interpreter::readScript16() {
+ uint16 data = _script->readScript16(_currentInstruction);
+ _currentInstruction += sizeof(uint16);
+ return data;
+}
+
+uint32 Interpreter::readScript32() {
+ uint32 data = _script->readScript32(_currentInstruction);
+ _currentInstruction += sizeof(uint32);
+ return data;
+}
+
+int32 Interpreter::readScriptFlagValue() {
+ uint16 value = readScript16();
+ if (value & InterpreterFlags::kFlagMask) {
+ return _flags->getFlagValue((Flags::Id)value);
+ }
+ return value;
+}
+
+Flags::Id Interpreter::readScriptFlagId() {
+ return (Flags::Id)readScript16();
+}
+
+void Interpreter::O_WAITFOREVER() {
+ _vm->changeCursor(_vm->_currentPointerNumber);
+ _opcodeNF = 1;
+ _currentInstruction -= 2;
+ //debugInterpreter("O_WAITFOREVER");
+}
+
+void Interpreter::O_BLACKPALETTE() {
+ _vm->blackPalette();
+ debugInterpreter("O_BLACKPALETTE");
+}
+
+void Interpreter::O_SETUPPALETTE() {
+ _vm->setPalette(_vm->_roomBmp->getPalette());
+ debugInterpreter("O_SETUPPALETTE");
+}
+
+void Interpreter::O_INITROOM() {
+ int32 roomId = readScriptFlagValue();
+ _vm->loadLocation(roomId);
+ _opcodeNF = 1;
+ debugInterpreter("O_INITROOM %d", roomId);
+}
+
+void Interpreter::O_SETSAMPLE() {
+ int32 sampleId = readScriptFlagValue();
+ int32 sampleNameOffset = readScript32();
+ const char *sampleName = _script->getString(_currentInstruction + sampleNameOffset - 4);
+ _vm->loadSample(sampleId, sampleName);
+ debugInterpreter("O_SETSAMPLE %d %s", sampleId, sampleName);
+}
+
+void Interpreter::O_FREESAMPLE() {
+ int32 sampleId = readScriptFlagValue();
+ _vm->freeSample(sampleId);
+ debugInterpreter("O_FREESAMPLE sampleId: %d", sampleId);
+}
+
+void Interpreter::O_PLAYSAMPLE() {
+ int32 sampleId = readScriptFlagValue();
+ uint16 loopType = readScript16();
+ _vm->playSample(sampleId, loopType);
+ debugInterpreter("O_PLAYSAMPLE sampleId %d loopType %d", sampleId, loopType);
+}
+
+void Interpreter::O_PUTOBJECT() {
+ int32 roomId = readScriptFlagValue();
+ int32 slot = readScriptFlagValue();
+ int32 objectId = readScriptFlagValue();
+ Room *room = new Room();
+ room->loadRoom(_script->getRoomOffset(roomId));
+ _vm->_script->setObjId(room->_obj, slot, objectId);
+ if (_vm->_locationNr == roomId) {
+ _vm->_objSlot[slot] = objectId;
+ }
+ delete room;
+ debugInterpreter("O_PUTOBJECT roomId %d, slot %d, objectId %d", roomId, slot, objectId);
+}
+
+void Interpreter::O_REMOBJECT() {
+ int32 roomId = readScriptFlagValue();
+ int32 slot = readScriptFlagValue();
+ Room *room = new Room();
+ room->loadRoom(_script->getRoomOffset(roomId));
+ _vm->_script->setObjId(room->_obj, slot, 0xFF);
+ if (_vm->_locationNr == roomId) {
+ _vm->_objSlot[slot] = 0xFF;
+ }
+ delete room;
+ debugInterpreter("O_REMOBJECT roomId %d slot %d", roomId, slot);
+}
+
+void Interpreter::O_SHOWANIM() {
+ int32 slot = readScriptFlagValue();
+ int32 animId = readScriptFlagValue();
+ _vm->freeNormAnim(slot);
+ Anim &anim = _vm->_normAnimList[slot];
+ AnimListItem &animList = _vm->_animList[animId];
+ anim._currFrame = 0;
+ anim._packFlag = 0;
+ anim._state = 0;
+ anim._frame = animList._startPhase;
+ anim._showFrame = animList._startPhase;
+ anim._lastFrame = animList._endPhase;
+ anim._loopFrame = animList._loopPhase;
+ anim._x = animList._x;
+ anim._y = animList._y;
+ anim._loopType = animList._loopType;
+ anim._shadowBack = animList._type;
+ anim._flags = animList._flags;
+ anim._nextAnim = animList._nextAnim;
+ int fileNumber = animList._fileNumber;
+ const Common::String animName = Common::String::format("AN%02d", fileNumber);
+ const Common::String shadowName = Common::String::format("AN%02dS", fileNumber);
+ anim._animData = new Animation();
+ anim._shadowData = new Animation();
+ Resource::loadResource(anim._animData, animName.c_str(), true);
+ if (!Resource::loadResource(anim._shadowData, shadowName.c_str(), false)) {
+ delete anim._shadowData;
+ anim._shadowData = nullptr;
+ }
+
+ // WALKAROUND: fix for turning off bard's wife background animation
+ // in front of bard's house (location 7) after giving her poem (item 33)
+ // in script: GiveLetter (line 11082)
+ if (_currentInstruction == kGiveLetterScriptFix) {
+ _vm->_backAnimList[1].backAnims[0]._state = 1;
+ }
+
+ debugInterpreter("O_SHOWANIM slot %d, animId %d", slot, animId);
+}
+
+void Interpreter::O_CHECKANIMEND() {
+ int32 slot = readScriptFlagValue();
+ if (_vm->_normAnimList[slot]._frame != _vm->_normAnimList[slot]._lastFrame - 1) {
+ _currentInstruction -= 4;
+ _opcodeNF = 1;
+ }
+ debugInterpreter("O_CHECKANIMEND slot %d", slot);
+}
+
+void Interpreter::O_FREEANIM() {
+ int32 slot = readScriptFlagValue();
+ _vm->freeNormAnim(slot);
+ debugInterpreter("O_FREEANIM slot %d", slot);
+}
+
+void Interpreter::O_CHECKANIMFRAME() {
+ int32 slot = readScriptFlagValue();
+ int32 frameNumber = readScriptFlagValue();
+ if (_vm->_normAnimList[slot]._frame != frameNumber - 1) {
+ _currentInstruction -= 6;
+ _opcodeNF = 1;
+ }
+ debugInterpreter("O_CHECKANIMFRAME slot %d, frameNumber %d", slot, frameNumber);
+}
+
+void Interpreter::O_PUTBACKANIM() {
+ int32 roomId = readScriptFlagValue();
+ int32 slot = readScriptFlagValue();
+ int32 animId = readScript32();
+ Room *room = new Room();
+ room->loadRoom(_script->getRoomOffset(roomId));
+ _vm->_script->setBackAnimId(room->_backAnim, slot, animId);
+ if (_vm->_locationNr == roomId) {
+ _vm->_script->installSingleBackAnim(_vm->_backAnimList, slot, room->_backAnim);
+ }
+ delete room;
+
+ // WALKAROUND: fix for turning on 'walking bird' background animation too soon,
+ // after completing 'throw a rock' mini-game in Silmaniona location.
+ // Second bird shouldn't appear when normal animation is still in use
+ // in script lines 13814 and 13848
+ if (_currentInstruction == kSecondBirdAnimationScriptFix) {
+ if (_vm->_normAnimList[1]._state == 0) {
+ _vm->_backAnimList[0].backAnims[0]._state = 1;
+ }
+ }
+
+ debugInterpreter("O_PUTBACKANIM roomId %d, slot %d, animId %d", roomId, slot, animId);
+}
+
+void Interpreter::O_REMBACKANIM() {
+ int32 roomId = readScriptFlagValue();
+ int32 slot = readScriptFlagValue();
+ if (_vm->_locationNr == roomId) {
+ _vm->removeSingleBackAnim(slot);
+ }
+ Room *room = new Room();
+ room->loadRoom(_script->getRoomOffset(roomId));
+ _vm->_script->setBackAnimId(room->_backAnim, slot, 0);
+ delete room;
+ debugInterpreter("O_REMBACKANIM roomId %d, slot %d", roomId, slot);
+}
+
+void Interpreter::O_CHECKBACKANIMFRAME() {
+ int32 slotId = readScriptFlagValue();
+ int32 frameId = readScriptFlagValue();
+ int currAnim = _vm->_backAnimList[slotId]._seq._currRelative;
+ if (_vm->_backAnimList[slotId].backAnims[currAnim]._frame != frameId - 1) {
+ _currentInstruction -= 6;
+ _opcodeNF = 1;
+ }
+ debugInterpreter("O_CHECKBACKANIMFRAME slotId %d, frameId %d", slotId, frameId);
+}
+
+// Not used in script
+void Interpreter::O_FREEALLSAMPLES() {
+ error("O_FREEALLSAMPLES");
+}
+
+void Interpreter::O_SETMUSIC() {
+ uint16 musicId = readScript16();
+ _vm->loadMusic(musicId);
+ debugInterpreter("O_SETMUSIC musicId %d", musicId);
+}
+
+void Interpreter::O_STOPMUSIC() {
+ _vm->stopMusic();
+ debugInterpreter("O_STOPMUSIC");
+}
+
+void Interpreter::O__WAIT() {
+ int32 pause = readScriptFlagValue();
+ debugInterpreter("O__WAIT pause %d", pause);
+ if (!_waitFlag) {
+ // set new wait flag value and continue
+ _waitFlag = pause;
+ _opcodeNF = 1;
+ _currentInstruction -= 4;
+ return;
+ }
+ _waitFlag--;
+ if (_waitFlag > 0) {
+ _opcodeNF = 1;
+ _currentInstruction -= 4;
+ return;
+ }
+}
+
+// Not used in script
+void Interpreter::O_UPDATEOFF() {
+ error("O_UPDATEOFF");
+}
+
+// Not used in script
+void Interpreter::O_UPDATEON() {
+ error("O_UPDATEON");
+}
+
+// Not used in script
+void Interpreter::O_UPDATE () {
+ error("O_UPDATE");
+}
+
+// Not used in script
+void Interpreter::O_CLS() {
+ error("O_CLS");
+}
+
+void Interpreter::O__CALL() {
+ int32 address = readScript32();
+ _stack[_stacktop] = _currentInstruction;
+ _stacktop++;
+ _currentInstruction += address - 4;
+ debugInterpreter("O__CALL 0x%04X", _currentInstruction);
+}
+
+void Interpreter::O_RETURN() {
+ if (_stacktop > 0) {
+ _stacktop--;
+ _currentInstruction = _stack[_stacktop];
+ debugInterpreter("O_RETURN 0x%04X", _currentInstruction);
+ } else {
+ error("O_RETURN: Stack is empty");
+ }
+}
+
+void Interpreter::O_GO() {
+ int32 opPC = readScript32();
+ _currentInstruction += opPC - 4;
+ debugInterpreter("O_GO 0x%04X", opPC);
+}
+
+void Interpreter::O_BACKANIMUPDATEOFF() {
+ int32 slotId = readScriptFlagValue();
+ int currAnim = _vm->_backAnimList[slotId]._seq._currRelative;
+ if (!_vm->_backAnimList[slotId].backAnims.empty()) {
+ _vm->_backAnimList[slotId].backAnims[currAnim]._state = 1;
+ }
+ debugInterpreter("O_BACKANIMUPDATEOFF slotId %d", slotId);
+}
+
+void Interpreter::O_BACKANIMUPDATEON() {
+ int32 slotId = readScriptFlagValue();
+ int currAnim = _vm->_backAnimList[slotId]._seq._currRelative;
+ if (!_vm->_backAnimList[slotId].backAnims.empty()) {
+ _vm->_backAnimList[slotId].backAnims[currAnim]._state = 0;
+ }
+ debugInterpreter("O_BACKANIMUPDATEON slotId %d", slotId);
+}
+
+void Interpreter::O_CHANGECURSOR() {
+ int32 cursorId = readScriptFlagValue();
+ _vm->changeCursor(cursorId);
+ debugInterpreter("O_CHANGECURSOR %x", cursorId);
+}
+
+// Not used in script
+void Interpreter::O_CHANGEANIMTYPE() {
+ error("O_CHANGEANIMTYPE");
+}
+
+void Interpreter::O__SETFLAG() {
+ Flags::Id flagId = readScriptFlagId();
+ int32 value = readScriptFlagValue();
+ _flags->setFlagValue((Flags::Id)(flagId), value);
+ debugInterpreter("O__SETFLAG 0x%04X (%s) = %d", flagId, Flags::getFlagName(flagId), value);
+}
+
+void Interpreter::O_COMPARE() {
+ Flags::Id flagId = readScriptFlagId();
+ int32 value = readScriptFlagValue();
+ _result = _flags->getFlagValue(flagId) != value;
+ debugInterpreter("O_COMPARE flagId 0x%04X (%s), value %d == %d (%d)", flagId, Flags::getFlagName(flagId), value, _flags->getFlagValue(flagId), _result);
+}
+
+void Interpreter::O_JUMPZ() {
+ int32 offset = readScript32();
+ if (!_result) {
+ _currentInstruction += offset - 4;
+ }
+ debugInterpreter("O_JUMPZ result = %d, next %08x, offset 0x%08X", _result, _currentInstruction, offset);
+}
+
+void Interpreter::O_JUMPNZ() {
+ int32 offset = readScript32();
+ if (_result) {
+ _currentInstruction += offset - 4;
+ }
+ debugInterpreter("O_JUMPNZ result = %d, next %08x, offset 0x%08X", _result, _currentInstruction, offset);
+}
+
+void Interpreter::O_EXIT() {
+ int32 exitCode = readScriptFlagValue();
+ _opcodeEnd = true;
+ _opcodeNF = 1;
+ if (exitCode == 0x2EAD) {
+ _vm->scrollCredits();
+ }
+ debugInterpreter("O_EXIT exitCode %d", exitCode);
+}
+
+void Interpreter::O_ADDFLAG() {
+ Flags::Id flagId = readScriptFlagId();
+ int32 value = readScriptFlagValue();
+ _flags->setFlagValue(flagId, _flags->getFlagValue(flagId) + value);
+ if (_flags->getFlagValue(flagId)) {
+ _result = 1;
+ }
+ else {
+ _result = 0;
+ }
+ debugInterpreter("O_ADDFLAG flagId %04x (%s), value %d", flagId, Flags::getFlagName(flagId), value);
+}
+
+void Interpreter::O_TALKANIM() {
+ int32 animNumber = readScriptFlagValue();
+ int32 slot = readScriptFlagValue();
+ _vm->doTalkAnim(animNumber, slot, kNormalAnimation);
+ debugInterpreter("O_TALKANIM animNumber %d, slot %d", animNumber, slot);
+}
+
+void Interpreter::O_SUBFLAG() {
+ Flags::Id flagId = readScriptFlagId();
+ int32 value = readScriptFlagValue();
+ _flags->setFlagValue(flagId, _flags->getFlagValue(flagId) - value);
+ if (_flags->getFlagValue(flagId)) {
+ _result = 1;
+ }
+ else {
+ _result = 0;
+ }
+ debugInterpreter("O_SUBFLAG flagId %d, value %d", flagId, value);
+}
+
+void Interpreter::O_SETSTRING() {
+ int32 offset = readScript32();
+ _currentString = offset;
+ if (offset >= 80000) {
+ _string = _vm->_variaTxt->getString(offset - 80000);
+ debugInterpreter("GetVaria %s", _string);
+ }
+ else if (offset < 2000) {
+ _vm->_dialogData = &_vm->_dialogDat[offset * 4 - 4];
+ uint32 of = READ_LE_UINT32(_vm->_talkTxt + offset * 4);
+ const char *txt = (const char *)&_vm->_talkTxt[of];
+ _string = &_vm->_talkTxt[of];
+ debugInterpreter("TalkTxt %d %s", of, txt);
+ }
+ debugInterpreter("O_SETSTRING %04d", offset);
+}
+
+void Interpreter::O_ANDFLAG() {
+ Flags::Id flagId = readScriptFlagId();
+ int32 value = readScriptFlagValue();
+ _flags->setFlagValue(flagId, _flags->getFlagValue(flagId) & value);
+ if (_flags->getFlagValue(flagId)) {
+ _result = 1;
+ } else {
+ _result = 0;
+ }
+ debugInterpreter("O_ANDFLAG flagId %d, value %d", flagId, value);
+}
+
+void Interpreter::O_GETMOBDATA() {
+ Flags::Id flagId = readScriptFlagId();
+ int32 mobId = readScriptFlagValue();
+ int32 mobOffset = readScriptFlagValue();
+ int16 value = _vm->_mobList[mobId].getData((Mob::AttrId)mobOffset);
+ _flags->setFlagValue(flagId, value);
+ debugInterpreter("O_GETMOBDATA flagId %d, modId %d, mobOffset %d", flagId, mobId, mobOffset);
+}
+
+void Interpreter::O_ORFLAG() {
+ Flags::Id flagId = readScriptFlagId();
+ int32 value = readScriptFlagValue();
+ _flags->setFlagValue(flagId, _flags->getFlagValue(flagId) | value);
+ if (_flags->getFlagValue(flagId)) {
+ _result = 1;
+ } else {
+ _result = 0;
+ }
+ debugInterpreter("O_ORFLAG flagId %d, value %d", flagId, value);
+}
+
+void Interpreter::O_SETMOBDATA() {
+ int32 mobId = readScriptFlagValue();
+ int32 mobOffset = readScriptFlagValue();
+ int32 value = readScriptFlagValue();
+ _vm->_mobList[mobId].setData((Mob::AttrId)mobOffset, value);
+ debugInterpreter("O_SETMOBDATA mobId %d, mobOffset %d, value %d", mobId, mobOffset, value);
+}
+
+void Interpreter::O_XORFLAG() {
+ Flags::Id flagId = readScriptFlagId();
+ int32 value = readScriptFlagValue();
+ _flags->setFlagValue(flagId, _flags->getFlagValue(flagId) ^ value);
+ if (_flags->getFlagValue(flagId)) {
+ _result = 1;
+ } else {
+ _result = 0;
+ }
+ debugInterpreter("O_XORFLAG flagId %d, value %d", flagId, value);
+}
+
+void Interpreter::O_GETMOBTEXT() {
+ int32 mob = readScriptFlagValue();
+ _currentString = _vm->_locationNr * 100 + mob + 60001;
+ _string = (byte *)_vm->_mobList[mob]._examText.c_str();
+ debugInterpreter("O_GETMOBTEXT mob %d", mob);
+}
+
+void Interpreter::O_MOVEHERO() {
+ int32 heroId = readScriptFlagValue();
+ int32 x = readScriptFlagValue();
+ int32 y = readScriptFlagValue();
+ int32 dir = readScriptFlagValue();
+ _vm->moveRunHero(heroId, x, y, dir, false);
+ debugInterpreter("O_MOVEHERO heroId %d, x %d, y %d, dir %d", heroId, x, y, dir);
+}
+
+void Interpreter::O_WALKHERO() {
+ int32 heroId = readScriptFlagValue();
+ Hero *hero = nullptr;
+ if (!heroId) {
+ hero = _vm->_mainHero;
+ } else if (heroId == 1) {
+ hero = _vm->_secondHero;
+ }
+ if (hero != nullptr) {
+ if (hero->_state != Hero::kHeroStateStay) {
+ _currentInstruction -= 4;
+ _opcodeNF = 1;
+ }
+ }
+ debugInterpreter("O_WALKHERO %d", heroId);
+}
+
+void Interpreter::O_SETHERO() {
+ int32 heroId = readScriptFlagValue();
+ int32 x = readScriptFlagValue();
+ int32 y = readScriptFlagValue();
+ int32 dir = readScriptFlagValue();
+ Hero *hero = nullptr;
+ if (!heroId) {
+ hero = _vm->_mainHero;
+ } else if (heroId == 1) {
+ hero = _vm->_secondHero;
+ }
+ if (hero != nullptr) {
+ hero->setPos(x, y);
+ hero->_lastDirection = dir;
+ hero->_visible = 1;
+ hero->countDrawPosition();
+ }
+ debugInterpreter("O_SETHERO heroId %d, x %d, y %d, dir %d", heroId, x, y, dir);
+}
+
+void Interpreter::O_HEROOFF() {
+ int32 heroId = readScriptFlagValue();
+ Hero *hero = nullptr;
+ if (!heroId) {
+ hero = _vm->_mainHero;
+ } else if (heroId == 1) {
+ hero = _vm->_secondHero;
+ }
+ if (hero != nullptr) {
+ hero->setVisible(false);
+ }
+ debugInterpreter("O_HEROOFF %d", heroId);
+}
+
+void Interpreter::O_HEROON() {
+ int32 heroId = readScriptFlagValue();
+ Hero *hero = nullptr;
+ if (!heroId) {
+ hero = _vm->_mainHero;
+ } else if (heroId == 1) {
+ hero = _vm->_secondHero;
+ }
+ if (hero != nullptr) {
+ hero->setVisible(true);
+ }
+ debugInterpreter("O_HEROON %d", heroId);
+}
+
+void Interpreter::O_CLSTEXT() {
+ int32 slot = readScriptFlagValue();
+ _vm->_textSlots[slot]._str = nullptr;
+ _vm->_textSlots[slot]._time = 0;
+ debugInterpreter("O_CLSTEXT slot %d", slot);
+}
+
+void Interpreter::O_CALLTABLE() {
+ Flags::Id flagId = readScriptFlagId();
+ int roomNr = _flags->getFlagValue(flagId);
+ int32 tableOffset = readScript32();
+ int initLocationScript = _script->getLocationInitScript(tableOffset, roomNr);
+ if (initLocationScript) {
+ _stack[_stacktop] = _currentInstruction;
+ _stacktop++;
+ _currentInstruction = initLocationScript;
+ }
+ debugInterpreter("O_CALLTABLE loc %d", roomNr);
+}
+
+void Interpreter::O_CHANGEMOB() {
+ int32 mob = readScriptFlagValue();
+ int32 value = readScriptFlagValue();
+ value ^= 1;
+ _vm->_script->setMobVisible(_vm->_room->_mobs, mob, value);
+ _vm->_mobList[mob]._visible = value;
+ debugInterpreter("O_CHANGEMOB mob %d, value %d", mob, value);
+}
+
+void Interpreter::O_ADDINV() {
+ int32 hero = readScriptFlagValue();
+ int32 item = readScriptFlagValue();
+ _vm->addInv(hero, item, false);
+ debugInterpreter("O_ADDINV hero %d, item %d", hero, item);
+}
+
+void Interpreter::O_REMINV() {
+ int32 hero = readScriptFlagValue();
+ int32 item = readScriptFlagValue();
+ _vm->remInv(hero, item);
+ debugInterpreter("O_REMINV hero %d, item %d", hero, item);
+}
+
+// Not used in script
+void Interpreter::O_REPINV() {
+ error("O_REPINV");
+}
+
+// Not used in script
+void Interpreter::O_OBSOLETE_GETACTION() {
+ error("O_OBSOLETE_GETACTION");
+}
+
+// Not used in script
+void Interpreter::O_ADDWALKAREA() {
+ error("O_ADDWALKAREA");
+}
+
+// Not used in script
+void Interpreter::O_REMWALKAREA() {
+ error("O_REMWALKAREA");
+}
+
+ // Not used in script
+void Interpreter::O_RESTOREWALKAREA() {
+ error("O_RESTOREWALKAREA");
+}
+
+void Interpreter::O_WAITFRAME() {
+ _opcodeNF = true;
+ debugInterpreter("O_WAITFRAME");
+}
+
+void Interpreter::O_SETFRAME() {
+ int32 anim = readScriptFlagValue();
+ int32 frame = readScriptFlagValue();
+ _vm->_normAnimList[anim]._frame = frame;
+ debugInterpreter("O_SETFRAME anim %d, frame %d", anim, frame);
+}
+
+// Not used in script
+void Interpreter::O_RUNACTION() {
+ error("O_RUNACTION");
+}
+
+void Interpreter::O_COMPAREHI() {
+ Flags::Id flag = readScriptFlagId();
+ int32 value = readScriptFlagValue();
+ int32 flagValue = _flags->getFlagValue(flag);
+ if (flagValue > value) {
+ _result = 0;
+ } else {
+ _result = 1;
+ }
+ debugInterpreter("O_COMPAREHI flag %04x - (%s), value %d, flagValue %d, result %d", flag, Flags::getFlagName(flag), value, flagValue, _result);
+}
+
+void Interpreter::O_COMPARELO() {
+ Flags::Id flag = readScriptFlagId();
+ int32 value = readScriptFlagValue();
+ int32 flagValue = _flags->getFlagValue(flag);
+ if (flagValue < value) {
+ _result = 0;
+ } else {
+ _result = 1;
+ }
+ debugInterpreter("O_COMPARELO flag %04x - (%s), value %d, flagValue %d, result %d", flag, Flags::getFlagName(flag), value, flagValue, _result);
+}
+
+// Not used in script
+void Interpreter::O_PRELOADSET() {
+ error("O_PRELOADSET");
+}
+
+// Not used in script
+void Interpreter::O_FREEPRELOAD() {
+ error("O_FREEPRELOAD");
+}
+
+// Not used in script
+void Interpreter::O_CHECKINV() {
+ error("O_CHECKINV");
+}
+
+void Interpreter::O_TALKHERO() {
+ int32 hero = readScriptFlagValue();
+ _vm->talkHero(hero);
+ debugInterpreter("O_TALKHERO hero %d", hero);
+}
+
+void Interpreter::O_WAITTEXT() {
+ int32 slot = readScriptFlagValue();
+ Text &text = _vm->_textSlots[slot];
+ if (text._time && text._str) {
+ if (_flags->getFlagValue(Flags::ESCAPED)) {
+ text._time = 1;
+ if (!slot) {
+ _vm->_mainHero->_talkTime = 1;
+ } else if (slot == 1) {
+ _vm->_secondHero->_talkTime = 1;
+ }
+ } else {
+ _opcodeNF = 1;
+ _currentInstruction -= 4;
+ }
+ }
+ //debugInterpreter("O_WAITTEXT slot %d", slot);
+}
+
+void Interpreter::O_SETHEROANIM() {
+ int32 heroId = readScriptFlagValue();
+ int32 offset = readScript32();
+ Hero *hero = nullptr;
+ if (!heroId) {
+ hero = _vm->_mainHero;
+ } else {
+ hero = _vm->_secondHero;
+ }
+ if (hero != nullptr) {
+ hero->freeHeroAnim();
+ if (hero ->_specAnim == nullptr) {
+ hero->_specAnim = new Animation();
+ if (offset < 100) {
+ const Common::String animName = Common::String::format("AN%02d", offset);
+ Resource::loadResource(hero->_specAnim, animName.c_str(), true);
+ } else {
+ const Common::String animName = Common::String((const char *)_script->getHeroAnimName(offset));
+ Common::String normalizedPath = lastPathComponent(animName, '\\');
+ Resource::loadResource(hero->_specAnim, normalizedPath.c_str(), true);
+ }
+ hero->_phase = 0;
+ hero->_state = Hero::kHeroStateSpec;
+ }
+ }
+ debugInterpreter("O_SETHEROANIM hero %d, offset %d", hero, offset);
+}
+
+void Interpreter::O_WAITHEROANIM() {
+ int32 heroId = readScriptFlagValue();
+ Hero *hero = nullptr;
+ if (!heroId) {
+ hero = _vm->_mainHero;
+ } else {
+ hero = _vm->_secondHero;
+ }
+ if (hero != nullptr) {
+ if (hero->_state == Hero::kHeroStateSpec) {
+ _currentInstruction -= 4;
+ _opcodeNF = 1;
+ }
+ }
+ debugInterpreter("O_WAITHEROANIM heroId %d", heroId);
+}
+
+void Interpreter::O_GETHERODATA() {
+ Flags::Id flagId = readScriptFlagId();
+ int32 heroId = readScriptFlagValue();
+ int32 heroOffset = readScriptFlagValue();
+ Hero *hero = nullptr;
+ if (!heroId) {
+ hero = _vm->_mainHero;
+ } else {
+ hero = _vm->_secondHero;
+ }
+ if (hero != nullptr) {
+ _flags->setFlagValue(flagId, hero->getData((Hero::AttrId)heroOffset));
+ }
+ debugInterpreter("O_GETHERODATA flag %04x - (%s), heroId %d, heroOffset %d", flagId, Flags::getFlagName(flagId), heroId, heroOffset);
+}
+
+// No need of implementation here
+void Interpreter::O_GETMOUSEBUTTON() {
+ debugInterpreter("O_GETMOUSEBUTTON");
+}
+
+void Interpreter::O_CHANGEFRAMES() {
+ int32 anim = readScriptFlagValue();
+ int32 frame = readScriptFlagValue();
+ int32 lastFrame = readScriptFlagValue();
+ int32 loopFrame = readScriptFlagValue();
+ _vm->_normAnimList[anim]._frame = frame;
+ _vm->_normAnimList[anim]._lastFrame = lastFrame;
+ _vm->_normAnimList[anim]._loopFrame = loopFrame;
+ debugInterpreter("O_CHANGFRAMES anim %d, frame %d, lastFrame %d, loopFrame %d", anim, frame, lastFrame, loopFrame);
+}
+
+void Interpreter::O_CHANGEBACKFRAMES() {
+ int32 anim = readScriptFlagValue();
+ int32 frame = readScriptFlagValue();
+ int32 lastFrame = readScriptFlagValue();
+ int32 loopFrame = readScriptFlagValue();
+ int currAnim = _vm->_backAnimList[anim]._seq._currRelative;
+ Anim &backAnim = _vm->_backAnimList[anim].backAnims[currAnim];
+ backAnim._frame = frame;
+ backAnim._lastFrame = lastFrame;
+ backAnim._loopFrame = loopFrame;
+ debugInterpreter("O_CHANGEBACKFRAMES anim %d, frame %d, lastFrame %d, loopFrame %d", anim, frame, lastFrame, loopFrame);
+}
+
+void Interpreter::O_GETBACKANIMDATA() {
+ Flags::Id flagId = readScriptFlagId();
+ int32 animNumber = readScriptFlagValue();
+ int32 animDataOffset = readScriptFlagValue();
+ int currAnim = _vm->_backAnimList[animNumber]._seq._currRelative;
+ int16 value = _vm->_backAnimList[animNumber].backAnims[currAnim].getAnimData((Anim::AnimOffsets)(animDataOffset));
+ _flags->setFlagValue((Flags::Id)(flagId), value);
+ debugInterpreter("O_GETBACKANIMDATA flag %04X (%s), animNumber %d, animDataOffset %d, value %d", flagId, Flags::getFlagName(flagId), animNumber, animDataOffset, value);
+}
+
+void Interpreter::O_GETANIMDATA() {
+ Flags::Id flagId = readScriptFlagId();
+ int32 anim = readScriptFlagValue();
+ int32 animOffset = readScriptFlagValue();
+ if (_vm->_normAnimList[anim]._animData != nullptr) {
+ _flags->setFlagValue(flagId, _vm->_normAnimList[anim].getAnimData((Anim::AnimOffsets)(animOffset)));
+ }
+ debugInterpreter("O_GETANIMDATA flag %04X (%s), anim %d, animOffset %d", flagId, Flags::getFlagName(flagId), anim, animOffset);
+}
+
+void Interpreter::O_SETBGCODE() {
+ int32 offset = readScript32();
+ _bgOpcodePC = _currentInstruction + offset - 4;
+ debugInterpreter("O_SETBGCODE next %08x, offset %08x", _bgOpcodePC, offset);
+}
+
+void Interpreter::O_SETBACKFRAME() {
+ int32 anim = readScriptFlagValue();
+ int32 frame = readScriptFlagValue();
+ int currAnim = _vm->_backAnimList[anim]._seq._currRelative;
+ if (_vm->_backAnimList[anim].backAnims[currAnim]._animData != nullptr) {
+ _vm->_backAnimList[anim].backAnims[currAnim]._frame = frame;
+ }
+ debugInterpreter("O_SETBACKFRAME anim %d, frame %d", anim, frame);
+}
+
+void Interpreter::O_GETRND() {
+ Flags::Id flag = readScriptFlagId();
+ uint16 rndSeed = readScript16();
+ int value = _vm->_randomSource.getRandomNumber(rndSeed - 1);
+ _flags->setFlagValue(flag, value);
+ debugInterpreter("O_GETRND flag %d, rndSeed %d, value %d", flag, rndSeed, value);
+}
+
+void Interpreter::O_TALKBACKANIM() {
+ int32 animNumber = readScriptFlagValue();
+ int32 slot = readScriptFlagValue();
+ _vm->doTalkAnim(animNumber, slot, kBackgroundAnimation);
+ debugInterpreter("O_TALKBACKANIM animNumber %d, slot %d", animNumber, slot);
+}
+
+// Simplifying, because used only once in Location 20
+void Interpreter::O_LOADPATH() {
+ readScript32();
+ _vm->loadPath("path2");
+ debugInterpreter("O_LOADPATH - path2");
+}
+
+void Interpreter::O_GETCHAR() {
+ Flags::Id flagId = readScriptFlagId();
+ _flags->setFlagValue(flagId, *_string);
+ _string++;
+ debugInterpreter("O_GETCHAR %04X (%s) %02x", flagId, Flags::getFlagName(flagId), _flags->getFlagValue(flagId));
+}
+
+void Interpreter::O_SETDFLAG() {
+ Flags::Id flagId = readScriptFlagId();
+ int32 address = readScript32();
+ _flags->setFlagValue((Flags::Id)(flagId), _currentInstruction + address - 4);
+ debugInterpreter("O_SETDFLAG 0x%04X (%s) = 0x%04X", flagId, Flags::getFlagName(flagId), _currentInstruction + address - 4);
+}
+
+void Interpreter::O_CALLDFLAG() {
+ Flags::Id flagId = readScriptFlagId();
+ _stack[_stacktop] = _currentInstruction;
+ _stacktop++;
+ _currentInstruction = _flags->getFlagValue(flagId);
+ debugInterpreter("O_CALLDFLAG 0x%04X (%s) = 0x%04X", flagId, Flags::getFlagName(flagId), _currentInstruction);
+}
+
+void Interpreter::O_PRINTAT() {
+ int32 slot = readScriptFlagValue();
+ int32 x = readScriptFlagValue();
+ int32 y = readScriptFlagValue();
+ int32 color = _flags->getFlagValue(Flags::KOLOR);
+ _vm->printAt(slot, color, (char *)_string, x, y);
+ increaseString();
+ debugInterpreter("O_PRINTAT slot %d, x %d, y %d", slot, x, y);
+}
+
+void Interpreter::O_ZOOMIN() {
+ int32 slot = readScriptFlagValue();
+ _vm->initZoomIn(slot);
+ debugInterpreter("O_ZOOMIN slot %04d", slot);
+}
+
+void Interpreter::O_ZOOMOUT() {
+ int32 slot = readScriptFlagValue();
+ _vm->initZoomOut(slot);
+ debugInterpreter("O_ZOOMOUT slot %d", slot);
+}
+
+// Not used in script
+void Interpreter::O_SETSTRINGOFFSET() {
+ error("O_SETSTRINGOFFSET");
+}
+
+void Interpreter::O_GETOBJDATA() {
+ Flags::Id flag = readScriptFlagId();
+ int32 slot = readScriptFlagValue();
+ int32 objOffset = readScriptFlagValue();
+ int nr = _vm->_objSlot[slot];
+ if (nr != 0xFF) {
+ int16 value = _vm->_objList[nr]->getData((Object::AttrId)objOffset);
+ _flags->setFlagValue(flag, value);
+ }
+ debugInterpreter("O_GETOBJDATA flag %d, objSlot %d, objOffset %d", flag, slot, objOffset);
+}
+
+void Interpreter::O_SETOBJDATA() {
+ int32 slot = readScriptFlagValue();
+ int32 objOffset = readScriptFlagValue();
+ int32 value = readScriptFlagValue();
+ int nr = _vm->_objSlot[slot];
+ if (nr != 0xFF) {
+ _vm->_objList[nr]->setData((Object::AttrId)objOffset, value);
+ }
+ debugInterpreter("O_SETOBJDATA objSlot %d, objOffset %d, value %d", slot, objOffset, value);
+}
+
+// Not used in script
+void Interpreter::O_SWAPOBJECTS() {
+ error("O_SWAPOBJECTS");
+}
+
+void Interpreter::O_CHANGEHEROSET() {
+ int32 heroId = readScriptFlagValue();
+ int32 heroSet = readScriptFlagValue();
+ if (!heroId) {
+ _vm->_mainHero->loadAnimSet(heroSet);
+ } else if (heroId == 1) {
+ _vm->_secondHero->loadAnimSet(heroSet);
+ }
+ debugInterpreter("O_CHANGEHEROSET hero %d, heroSet %d", heroId, heroSet);
+}
+
+// Not used in script
+void Interpreter::O_ADDSTRING() {
+ error("O_ADDSTRING");
+}
+
+void Interpreter::O_SUBSTRING() {
+ int32 value = readScriptFlagValue();
+ _string -= value;
+ debugInterpreter("O_SUBSTRING value %d", value);
+}
+
+int Interpreter::checkSeq(byte *string) {
+ int freeHSlotIncrease = 0;
+ byte c;
+ while ((c = string[0]) != 0xFF) {
+ string++;
+ if (c < 0xF0) {
+ freeHSlotIncrease++;
+ while ((c = string[0])) {
+ string++;
+ }
+ string++;
+ } else if (c != 0xFE) {
+ string++;
+ }
+ }
+ return freeHSlotIncrease;
+}
+
+void Interpreter::O_INITDIALOG() {
+ if (_string[0] == 255) {
+ byte *stringCurrOff = _string;
+ byte *string = _string;
+ stringCurrOff++;
+ int32 adressOfFirstSequence = (int)READ_LE_UINT16(stringCurrOff);
+ stringCurrOff += 2;
+ _string = string + adressOfFirstSequence;
+
+ for (int i = 0; i < 32; i++) {
+ _vm->_dialogBoxAddr[i] = 0;
+ _vm->_dialogOptAddr[i] = 0;
+ }
+
+ for (int i = 0; i < 4 * 32; i++) {
+ _vm->_dialogOptLines[i] = 0;
+ }
+
+ int16 off;
+ byte *line = nullptr;
+
+ int dialogBox = 0;
+ while ((off = (int)READ_LE_UINT16(stringCurrOff)) != -1) {
+ stringCurrOff += 2;
+ if (off) {
+ line = string + off;
+ }
+ _vm->_dialogBoxAddr[dialogBox] = line;
+ dialogBox++;
+ }
+ stringCurrOff += 2;
+
+ int dialogOpt = 0;
+ while ((off = (int)READ_LE_UINT16(stringCurrOff)) != -1) {
+ stringCurrOff += 2;
+ if (off) {
+ line = string + off;
+ }
+ _vm->_dialogOptAddr[dialogOpt] = line;
+ dialogOpt++;
+ }
+
+ _flags->setFlagValue(Flags::VOICE_A_LINE, 0);
+ _flags->setFlagValue(Flags::VOICE_B_LINE, 0); // bx in original?
+
+ int freeHSlot = 0;
+ for (int i = 31; i >= 0; i--) {
+ if (_vm->_dialogOptAddr[i] != 0) {
+ i++;
+ freeHSlot = i;
+ _flags->setFlagValue(Flags::VOICE_H_LINE, i);
+ break;
+ }
+ }
+
+ freeHSlot += checkSeq(_string);
+
+ for (int i = 0; i < 32; i++) {
+ _vm->_dialogOptLines[i * 4] = freeHSlot;
+ _vm->_dialogOptLines[i * 4 + 1] = freeHSlot;
+ _vm->_dialogOptLines[i * 4 + 2] = freeHSlot;
+ if (_vm->_dialogOptAddr[i]) {
+ freeHSlot += checkSeq(_vm->_dialogOptAddr[i]);
+ }
+ }
+ }
+ debugInterpreter("O_INITDIALOG");
+}
+
+void Interpreter::O_ENABLEDIALOGOPT() {
+ int32 opt = readScriptFlagValue();
+ int dialogDataValue = (int)READ_LE_UINT32(_vm->_dialogData);
+ dialogDataValue &= ~(1u << opt);
+ WRITE_LE_UINT32(_vm->_dialogData, dialogDataValue);
+ debugInterpreter("O_ENABLEDIALOGOPT opt %d", opt);
+}
+
+void Interpreter::O_DISABLEDIALOGOPT() {
+ int32 opt = readScriptFlagValue();
+ int dialogDataValue = (int)READ_LE_UINT32(_vm->_dialogData);
+ dialogDataValue |= (1u << opt);
+ WRITE_LE_UINT32(_vm->_dialogData, dialogDataValue);
+ debugInterpreter("O_DISABLEDIALOGOPT opt %d", opt);
+}
+
+void Interpreter::O_SHOWDIALOGBOX() {
+ int32 box = readScriptFlagValue();
+ uint32 currInstr = _currentInstruction;
+ _vm->createDialogBox(box);
+ _flags->setFlagValue(Flags::DIALINES, _vm->_dialogLines);
+ if (_vm->_dialogLines) {
+ _vm->changeCursor(1);
+ _vm->dialogRun();
+ _vm->changeCursor(0);
+ }
+ _currentInstruction = currInstr;
+ debugInterpreter("O_SHOWDIALOGBOX box %d", box);
+}
+
+void Interpreter::O_STOPSAMPLE() {
+ int32 slot = readScriptFlagValue();
+ _vm->stopSample(slot);
+ debugInterpreter("O_STOPSAMPLE slot %d", slot);
+}
+
+void Interpreter::O_BACKANIMRANGE() {
+ int32 slotId = readScriptFlagValue();
+ uint16 animId = readScript16();
+ int32 low = readScriptFlagValue();
+ int32 high = readScriptFlagValue();
+ if (animId != 0xFFFF) {
+ if (animId & InterpreterFlags::kFlagMask) {
+ animId = _flags->getFlagValue((Flags::Id)animId);
+ }
+ }
+ _result = 1;
+ if (!_vm->_backAnimList[slotId].backAnims.empty()) {
+ int currAnim = _vm->_backAnimList[slotId]._seq._currRelative;
+ if (_vm->_backAnimList[slotId].backAnims[currAnim]._animData != nullptr) {
+ if (animId == 0xFFFF || _vm->_backAnimList[slotId]._seq._current == animId) {
+ Anim &backAnim = _vm->_backAnimList[slotId].backAnims[currAnim];
+ if (!backAnim._state) {
+ if (backAnim._frame >= low) {
+ if (backAnim._frame <= high) {
+ _result = 0;
+ }
+ }
+ }
+ }
+ }
+ }
+ debugInterpreter("O_BACKANIMRANGE slotId %d, animId %d, low %d, high %d, _result %d", slotId, animId, low, high, _result);
+}
+
+void Interpreter::O_CLEARPATH() {
+ for (uint i = 0; i < _vm->kPathBitmapLen; i++) {
+ _vm->_roomPathBitmap[i] = 255;
+ }
+ debugInterpreter("O_CLEARPATH");
+}
+
+void Interpreter::O_SETPATH() {
+ _vm->loadPath("path");
+ debugInterpreter("O_SETPATH");
+}
+
+void Interpreter::O_GETHEROX() {
+ int32 heroId = readScriptFlagValue();
+ Flags::Id flagId = readScriptFlagId();
+ if (!heroId) {
+ _flags->setFlagValue(flagId, _vm->_mainHero->_middleX);
+ } else if (heroId == 1) {
+ _flags->setFlagValue(flagId, _vm->_secondHero->_middleX);
+ }
+ debugInterpreter("O_GETHEROX heroId %d, flagId %d", heroId, flagId);
+}
+
+void Interpreter::O_GETHEROY() {
+ int32 heroId = readScriptFlagValue();
+ Flags::Id flagId = readScriptFlagId();
+ if (!heroId) {
+ _flags->setFlagValue(flagId, _vm->_mainHero->_middleY);
+ } else if (heroId == 1) {
+ _flags->setFlagValue(flagId, _vm->_secondHero->_middleY);
+ }
+ debugInterpreter("O_GETHEROY heroId %d, flagId %d", heroId, flagId);
+}
+
+void Interpreter::O_GETHEROD() {
+ int32 heroId = readScriptFlagValue();
+ Flags::Id flagId = readScriptFlagId();
+ if (!heroId) {
+ _flags->setFlagValue(flagId, _vm->_mainHero->_lastDirection);
+ } else if (heroId == 1) {
+ _flags->setFlagValue(flagId, _vm->_secondHero->_lastDirection);
+ }
+ debugInterpreter("O_GETHEROD heroId %d, flagId %d", heroId, flagId);
+}
+
+void Interpreter::O_PUSHSTRING() {
+ _stringStack.string = _string;
+ _stringStack.dialogData = _vm->_dialogData;
+ _stringStack.currentString = _currentString;
+ debugInterpreter("O_PUSHSTRING");
+}
+
+void Interpreter::O_POPSTRING() {
+ _string = _stringStack.string;
+ _vm->_dialogData = _stringStack.dialogData;
+ _currentString = _stringStack.currentString;
+ debugInterpreter("O_POPSTRING");
+}
+
+void Interpreter::O_SETFGCODE() {
+ int32 offset = readScript32();
+ _fgOpcodePC = _currentInstruction + offset - 4;
+ debugInterpreter("O_SETFGCODE next %08x, offset %08x", _fgOpcodePC, offset);
+}
+
+void Interpreter::O_STOPHERO() {
+ int32 heroId = readScriptFlagValue();
+ if (!heroId) {
+ _vm->_mainHero->freeOldMove();
+ } else if (heroId == 1) {
+ _vm->_secondHero->freeOldMove();
+ }
+ debugInterpreter("O_STOPHERO heroId %d", heroId);
+}
+
+void Interpreter::O_ANIMUPDATEOFF() {
+ int32 slotId = readScriptFlagValue();
+ _vm->_normAnimList[slotId]._state = 1;
+ debugInterpreter("O_ANIMUPDATEOFF slotId %d", slotId);
+}
+
+void Interpreter::O_ANIMUPDATEON() {
+ int32 slotId = readScriptFlagValue();
+ _vm->_normAnimList[slotId]._state = 0;
+ debugInterpreter("O_ANIMUPDATEON slotId %d", slotId);
+}
+
+void Interpreter::O_FREECURSOR() {
+ _vm->changeCursor(0);
+ _vm->_currentPointerNumber = 1;
+ // free memory here?
+ debugInterpreter("O_FREECURSOR");
+}
+
+void Interpreter::O_ADDINVQUIET() {
+ int32 hero = readScriptFlagValue();
+ int32 item = readScriptFlagValue();
+ _vm->addInv(hero, item, true);
+ debugInterpreter("O_ADDINVQUIET hero %d, item %d", hero, item);
+}
+
+void Interpreter::O_RUNHERO() {
+ int32 heroId = readScriptFlagValue();
+ int32 x = readScriptFlagValue();
+ int32 y = readScriptFlagValue();
+ int32 dir = readScriptFlagValue();
+ _vm->moveRunHero(heroId, x, y, dir, true);
+ debugInterpreter("O_RUNHERO heroId %d, x %d, y %d, dir %d", heroId, x, y, dir);
+}
+
+void Interpreter::O_SETBACKANIMDATA() {
+ uint16 animNumber = readScript16();
+ uint16 animDataOffset = readScript16();
+ Flags::Id flagId = readScriptFlagId();
+ uint16 value = _flags->getFlagValue((Flags::Id)(flagId));
+ int currAnim = _vm->_backAnimList[animNumber]._seq._currRelative;
+ _vm->_backAnimList[animNumber].backAnims[currAnim].setAnimData((Anim::AnimOffsets)(animDataOffset), value);
+ debugInterpreter("O_SETBACKANIMDATA flag %04X (%s), animNumber %d, animDataOffset %d, value %d", flagId, Flags::getFlagName(flagId), animNumber, animDataOffset, value);
+}
+
+void Interpreter::O_VIEWFLC() {
+ int32 animNr = readScriptFlagValue();
+ _vm->_flcFrameSurface = nullptr;
+ _vm->loadAnim(animNr, false);
+ debugInterpreter("O_VIEWFLC animNr %d", animNr);
+}
+
+void Interpreter::O_CHECKFLCFRAME() {
+ int32 frameNr = readScriptFlagValue();
+ debugInterpreter("O_CHECKFLCFRAME frame number %d", frameNr);
+ if (_vm->_flicPlayer.getCurFrame() != frameNr) {
+ _currentInstruction -= 4;
+ _opcodeNF = 1;
+ }
+}
+
+void Interpreter::O_CHECKFLCEND() {
+ const Video::FlicDecoder &flicPlayer = _vm->_flicPlayer;
+ debugInterpreter("O_CHECKFLCEND frameCount %d, currentFrame %d", flicPlayer.getFrameCount(), flicPlayer.getCurFrame());
+ if (flicPlayer.getFrameCount() - flicPlayer.getCurFrame() > 1) {
+ _currentInstruction -= 2;
+ _opcodeNF = 1;
+ }
+}
+
+void Interpreter::O_FREEFLC() {
+ _vm->_flcFrameSurface = nullptr;
+ debugInterpreter("O_FREEFLC");
+}
+
+void Interpreter::O_TALKHEROSTOP() {
+ int32 heroId = readScriptFlagValue();
+ if (!heroId) {
+ _vm->_mainHero->_state = Hero::kHeroStateStay;
+ } else if (heroId == 1) {
+ _vm->_secondHero->_state = Hero::kHeroStateStay;
+ }
+ debugInterpreter("O_TALKHEROSTOP %d", heroId);
+}
+
+void Interpreter::O_HEROCOLOR() {
+ int32 heroId = readScriptFlagValue();
+ int32 color = readScriptFlagValue();
+ if (!heroId) {
+ _vm->_mainHero->_color = color;
+ } else if (heroId == 1) {
+ _vm->_secondHero->_color = color;
+ }
+ debugInterpreter("O_HEROCOLOR heroId %d, color %d", heroId, color);
+}
+
+void Interpreter::O_GRABMAPA() {
+ _vm->grabMap();
+ debugInterpreter("O_GRABMAPA");
+}
+
+void Interpreter::O_ENABLENAK() {
+ int32 nakId = readScriptFlagValue();
+ _vm->_maskList[nakId]._flags = 0;
+ debugInterpreter("O_ENABLENAK nakId %d", nakId);
+}
+
+void Interpreter::O_DISABLENAK() {
+ int32 nakId = readScriptFlagValue();
+ _vm->_maskList[nakId]._flags = 1;
+ debugInterpreter("O_DISABLENAK nakId %d", nakId);
+}
+
+void Interpreter::O_GETMOBNAME() {
+ int32 modId = readScriptFlagValue();
+ _string = (byte *)_vm->_mobList[modId]._name.c_str();
+ debugInterpreter("O_GETMOBNAME modId %d", modId);
+}
+
+void Interpreter::O_SWAPINVENTORY() {
+ int32 hero = readScriptFlagValue();
+ _vm->swapInv(hero);
+ debugInterpreter("O_SWAPINVENTORY hero %d", hero);
+}
+
+void Interpreter::O_CLEARINVENTORY() {
+ int32 hero = readScriptFlagValue();
+ _vm->clearInv(hero);
+ debugInterpreter("O_CLEARINVENTORY hero %d", hero);
+}
+
+void Interpreter::O_SKIPTEXT() {
+ increaseString();
+ debugInterpreter("O_SKIPTEXT");
+}
+
+void Interpreter::O_SETVOICEH() {
+ int32 slot = readScriptFlagValue();
+ static const uint32 VOICE_H_SLOT = 28;
+ uint16 voiceLineH = _flags->getFlagValue(Flags::VOICE_H_LINE);
+ _vm->setVoice(slot, VOICE_H_SLOT, voiceLineH);
+}
+
+void Interpreter::O_SETVOICEA() {
+ int32 slot = readScriptFlagValue();
+ static const uint32 VOICE_A_SLOT = 29;
+ uint16 voiceLineH = _flags->getFlagValue(Flags::VOICE_H_LINE);
+ _vm->setVoice(slot, VOICE_A_SLOT, voiceLineH);
+}
+
+void Interpreter::O_SETVOICEB() {
+ int32 slot = readScriptFlagValue();
+ static const uint32 VOICE_B_SLOT = 30;
+ uint16 voiceLineH = _flags->getFlagValue(Flags::VOICE_H_LINE);
+ _vm->setVoice(slot, VOICE_B_SLOT, voiceLineH);
+}
+
+void Interpreter::O_SETVOICEC() {
+ int32 slot = readScriptFlagValue();
+ static const uint32 VOICE_C_SLOT = 31;
+ uint16 voiceLineH = _flags->getFlagValue(Flags::VOICE_H_LINE);
+ _vm->setVoice(slot, VOICE_C_SLOT, voiceLineH);
+}
+
+void Interpreter::O_SETVOICED() {
+ int32 slot = readScriptFlagValue();
+ static const uint32 VOICE_D_SLOT = 32;
+ uint16 voiceLineH = _flags->getFlagValue(Flags::VOICE_H_LINE);
+ _vm->setVoice(slot, VOICE_D_SLOT, voiceLineH);
+}
+
+void Interpreter::O_VIEWFLCLOOP() {
+ int32 animId = readScriptFlagValue();
+ _vm->loadAnim(animId, true);
+ debugInterpreter("O_VIEWFLCLOOP animId %d", animId);
+}
+
+// Not used in script
+void Interpreter::O_FLCSPEED() {
+ int32 speed = readScriptFlagValue();
+ error("O_FLCSPEED speed %d", speed);
+}
+
+void Interpreter::O_OPENINVENTORY() {
+ _vm->_showInventoryFlag = true;
+ _opcodeNF = 1;
+ debugInterpreter("O_OPENINVENTORY");
+}
+
+void Interpreter::O_KRZYWA() {
+ _vm->makeCurve();
+ debugInterpreter("O_KRZYWA");
+}
+
+void Interpreter::O_GETKRZYWA() {
+ _vm->getCurve();
+ debugInterpreter("O_GETKRZYWA");
+}
+
+void Interpreter::O_GETMOB() {
+ Flags::Id flagId = readScriptFlagId();
+ int32 posX = readScriptFlagValue();
+ int32 posY = readScriptFlagValue();
+ int mobNumber = _vm->getMob(_vm->_mobList, true, posX, posY);
+ _flags->setFlagValue(flagId, mobNumber + 1);
+ debugInterpreter("O_GETMOB flagId %d, posX %d, posY %d", flagId, posX, posY);
+}
+
+// Not used in game
+void Interpreter::O_INPUTLINE() {
+ error("O_INPUTLINE");
+}
+
+// Not used in script
+void Interpreter::O_BREAK_POINT() {
+ error("O_BREAK_POINT");
+}
+
+Interpreter::OpcodeFunc Interpreter::_opcodes[kNumOpcodes] = {
+ &Interpreter::O_WAITFOREVER,
+ &Interpreter::O_BLACKPALETTE,
+ &Interpreter::O_SETUPPALETTE,
+ &Interpreter::O_INITROOM,
+ &Interpreter::O_SETSAMPLE,
+ &Interpreter::O_FREESAMPLE,
+ &Interpreter::O_PLAYSAMPLE,
+ &Interpreter::O_PUTOBJECT,
+ &Interpreter::O_REMOBJECT,
+ &Interpreter::O_SHOWANIM,
+ &Interpreter::O_CHECKANIMEND,
+ &Interpreter::O_FREEANIM,
+ &Interpreter::O_CHECKANIMFRAME,
+ &Interpreter::O_PUTBACKANIM,
+ &Interpreter::O_REMBACKANIM,
+ &Interpreter::O_CHECKBACKANIMFRAME,
+ &Interpreter::O_FREEALLSAMPLES,
+ &Interpreter::O_SETMUSIC,
+ &Interpreter::O_STOPMUSIC,
+ &Interpreter::O__WAIT,
+ &Interpreter::O_UPDATEOFF,
+ &Interpreter::O_UPDATEON,
+ &Interpreter::O_UPDATE ,
+ &Interpreter::O_CLS,
+ &Interpreter::O__CALL,
+ &Interpreter::O_RETURN,
+ &Interpreter::O_GO,
+ &Interpreter::O_BACKANIMUPDATEOFF,
+ &Interpreter::O_BACKANIMUPDATEON,
+ &Interpreter::O_CHANGECURSOR,
+ &Interpreter::O_CHANGEANIMTYPE,
+ &Interpreter::O__SETFLAG,
+ &Interpreter::O_COMPARE,
+ &Interpreter::O_JUMPZ,
+ &Interpreter::O_JUMPNZ,
+ &Interpreter::O_EXIT,
+ &Interpreter::O_ADDFLAG,
+ &Interpreter::O_TALKANIM,
+ &Interpreter::O_SUBFLAG,
+ &Interpreter::O_SETSTRING,
+ &Interpreter::O_ANDFLAG,
+ &Interpreter::O_GETMOBDATA,
+ &Interpreter::O_ORFLAG,
+ &Interpreter::O_SETMOBDATA,
+ &Interpreter::O_XORFLAG,
+ &Interpreter::O_GETMOBTEXT,
+ &Interpreter::O_MOVEHERO,
+ &Interpreter::O_WALKHERO,
+ &Interpreter::O_SETHERO,
+ &Interpreter::O_HEROOFF,
+ &Interpreter::O_HEROON,
+ &Interpreter::O_CLSTEXT,
+ &Interpreter::O_CALLTABLE,
+ &Interpreter::O_CHANGEMOB,
+ &Interpreter::O_ADDINV,
+ &Interpreter::O_REMINV,
+ &Interpreter::O_REPINV,
+ &Interpreter::O_OBSOLETE_GETACTION,
+ &Interpreter::O_ADDWALKAREA,
+ &Interpreter::O_REMWALKAREA,
+ &Interpreter::O_RESTOREWALKAREA,
+ &Interpreter::O_WAITFRAME,
+ &Interpreter::O_SETFRAME,
+ &Interpreter::O_RUNACTION,
+ &Interpreter::O_COMPAREHI,
+ &Interpreter::O_COMPARELO,
+ &Interpreter::O_PRELOADSET,
+ &Interpreter::O_FREEPRELOAD,
+ &Interpreter::O_CHECKINV,
+ &Interpreter::O_TALKHERO,
+ &Interpreter::O_WAITTEXT,
+ &Interpreter::O_SETHEROANIM,
+ &Interpreter::O_WAITHEROANIM,
+ &Interpreter::O_GETHERODATA,
+ &Interpreter::O_GETMOUSEBUTTON,
+ &Interpreter::O_CHANGEFRAMES,
+ &Interpreter::O_CHANGEBACKFRAMES,
+ &Interpreter::O_GETBACKANIMDATA,
+ &Interpreter::O_GETANIMDATA,
+ &Interpreter::O_SETBGCODE,
+ &Interpreter::O_SETBACKFRAME,
+ &Interpreter::O_GETRND,
+ &Interpreter::O_TALKBACKANIM,
+ &Interpreter::O_LOADPATH,
+ &Interpreter::O_GETCHAR,
+ &Interpreter::O_SETDFLAG,
+ &Interpreter::O_CALLDFLAG,
+ &Interpreter::O_PRINTAT,
+ &Interpreter::O_ZOOMIN,
+ &Interpreter::O_ZOOMOUT,
+ &Interpreter::O_SETSTRINGOFFSET,
+ &Interpreter::O_GETOBJDATA,
+ &Interpreter::O_SETOBJDATA,
+ &Interpreter::O_SWAPOBJECTS,
+ &Interpreter::O_CHANGEHEROSET,
+ &Interpreter::O_ADDSTRING,
+ &Interpreter::O_SUBSTRING,
+ &Interpreter::O_INITDIALOG,
+ &Interpreter::O_ENABLEDIALOGOPT,
+ &Interpreter::O_DISABLEDIALOGOPT,
+ &Interpreter::O_SHOWDIALOGBOX,
+ &Interpreter::O_STOPSAMPLE,
+ &Interpreter::O_BACKANIMRANGE,
+ &Interpreter::O_CLEARPATH,
+ &Interpreter::O_SETPATH,
+ &Interpreter::O_GETHEROX,
+ &Interpreter::O_GETHEROY,
+ &Interpreter::O_GETHEROD,
+ &Interpreter::O_PUSHSTRING,
+ &Interpreter::O_POPSTRING,
+ &Interpreter::O_SETFGCODE,
+ &Interpreter::O_STOPHERO,
+ &Interpreter::O_ANIMUPDATEOFF,
+ &Interpreter::O_ANIMUPDATEON,
+ &Interpreter::O_FREECURSOR,
+ &Interpreter::O_ADDINVQUIET,
+ &Interpreter::O_RUNHERO,
+ &Interpreter::O_SETBACKANIMDATA,
+ &Interpreter::O_VIEWFLC,
+ &Interpreter::O_CHECKFLCFRAME,
+ &Interpreter::O_CHECKFLCEND,
+ &Interpreter::O_FREEFLC,
+ &Interpreter::O_TALKHEROSTOP,
+ &Interpreter::O_HEROCOLOR,
+ &Interpreter::O_GRABMAPA,
+ &Interpreter::O_ENABLENAK,
+ &Interpreter::O_DISABLENAK,
+ &Interpreter::O_GETMOBNAME,
+ &Interpreter::O_SWAPINVENTORY,
+ &Interpreter::O_CLEARINVENTORY,
+ &Interpreter::O_SKIPTEXT,
+ &Interpreter::O_SETVOICEH,
+ &Interpreter::O_SETVOICEA,
+ &Interpreter::O_SETVOICEB,
+ &Interpreter::O_SETVOICEC,
+ &Interpreter::O_VIEWFLCLOOP,
+ &Interpreter::O_FLCSPEED,
+ &Interpreter::O_OPENINVENTORY,
+ &Interpreter::O_KRZYWA,
+ &Interpreter::O_GETKRZYWA,
+ &Interpreter::O_GETMOB,
+ &Interpreter::O_INPUTLINE,
+ &Interpreter::O_SETVOICED,
+ &Interpreter::O_BREAK_POINT,
+};
+
+} // End of namespace Prince
diff --git a/engines/prince/script.h b/engines/prince/script.h
new file mode 100644
index 0000000000..fe79cf5f96
--- /dev/null
+++ b/engines/prince/script.h
@@ -0,0 +1,398 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public 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 PRINCE_SCRIPT_H
+#define PRINCE_SCRIPT_H
+
+#include "common/random.h"
+#include "common/endian.h"
+#include "common/array.h"
+#include "common/stream.h"
+
+#include "prince/flags.h"
+
+namespace Prince {
+
+class PrinceEngine;
+class Animation;
+class Object;
+struct Anim;
+struct BackgroundAnim;
+struct Mask;
+
+class Room {
+public:
+ Room();
+ int _mobs; // mob flag offset
+ int _backAnim; // offset to array of animation numbers
+ int _obj; // offset to array of object numbers
+ int _nak; // offset to array of masks
+ int _itemUse;
+ int _itemGive;
+ int _walkTo; // offset to array of WALKTO events or 0
+ int _examine; // offset to array of EXAMINE events or 0
+ int _pickup;
+ int _use;
+ int _pushOpen;
+ int _pullClose;
+ int _talk;
+ int _give;
+
+ bool loadStream(Common::SeekableReadStream &stream);
+ bool loadRoom(byte *roomData);
+ int getOptionOffset(int option);
+
+private:
+
+ typedef void (Room::*LoadingStep)(Common::SeekableReadStream &stream);
+
+ void nextLoadStep(Common::SeekableReadStream &stream, LoadingStep step);
+
+ void loadMobs(Common::SeekableReadStream &stream);
+ void loadBackAnim(Common::SeekableReadStream &stream);
+ void loadObj(Common::SeekableReadStream &stream);
+ void loadNak(Common::SeekableReadStream &stream);
+ void loadItemUse(Common::SeekableReadStream &stream);
+ void loadItemGive(Common::SeekableReadStream &stream);
+ void loadWalkTo(Common::SeekableReadStream &stream);
+ void loadExamine(Common::SeekableReadStream &stream);
+ void loadPickup(Common::SeekableReadStream &stream);
+ void loadUse(Common::SeekableReadStream &stream);
+ void loadPushOpen(Common::SeekableReadStream &stream);
+ void loadPullClose(Common::SeekableReadStream &stream);
+ void loadTalk(Common::SeekableReadStream &stream);
+ void loadGive(Common::SeekableReadStream &stream);
+};
+
+
+class Script {
+public:
+ static const int16 kMaxRooms = 60;
+
+ Script(PrinceEngine *vm);
+ ~Script();
+
+ struct ScriptInfo {
+ int rooms;
+ int startGame;
+ int restoreGame;
+ int stdExamine;
+ int stdPickup;
+ int stdUse;
+ int stdOpen;
+ int stdClose;
+ int stdTalk;
+ int stdGive;
+ int usdCode;
+ int invObjExam;
+ int invObjUse;
+ int invObjUU;
+ int stdUseItem;
+ int lightSources;
+ int specRout;
+ int invObjGive;
+ int stdGiveItem;
+ int goTester;
+ };
+
+ ScriptInfo _scriptInfo;
+
+ bool loadStream(Common::SeekableReadStream &stream);
+
+ uint16 readScript16(uint32 address);
+ uint32 readScript32(uint32 address);
+
+ uint32 getStartGameOffset();
+ uint32 getLocationInitScript(int initRoomTableOffset, int roomNr);
+ int16 getLightX(int locationNr);
+ int16 getLightY(int locationNr);
+ int32 getShadowScale(int locationNr);
+ uint8 *getRoomOffset(int locationNr);
+ int32 getOptionStandardOffset(int option);
+ uint8 *getHeroAnimName(int offset);
+
+ void installBackAnims(Common::Array<BackgroundAnim> &backAnimList, int roomBackAnimOffset);
+ void installSingleBackAnim(Common::Array<BackgroundAnim> &backAnimList, int slot, int roomBackAnimOffset);
+ void installObjects(int offset);
+ bool loadAllMasks(Common::Array<Mask> &maskList, int offset);
+
+ int scanMobEvents(int mobMask, int dataEventOffset);
+ int scanMobEventsWithItem(int mobMask, int dataEventOffset, int itemMask);
+
+ byte getMobVisible(int roomMobOffset, uint16 mob);
+ void setMobVisible(int roomMobOffset, uint16 mob, byte value);
+
+ uint32 getBackAnimId(int roomBackAnimOffset, int slot);
+ void setBackAnimId(int roomBackAnimOffset, int slot, int animId);
+
+ byte getObjId(int roomObjOffset, int slot);
+ void setObjId(int roomObjOffset, int slot, byte objectId);
+
+ const char *getString(uint32 offset) {
+ return (const char *)(&_data[offset]);
+ }
+
+private:
+ PrinceEngine *_vm;
+ uint8 *_data;
+ uint32 _dataSize;
+ Common::Array<Room> _roomList;
+};
+
+class InterpreterFlags {
+public:
+ InterpreterFlags();
+
+ void setFlagValue(Flags::Id flag, int32 value);
+ int32 getFlagValue(Flags::Id flag);
+
+ void resetAllFlags();
+
+ static const uint16 kFlagMask = 0x8000;
+ static const uint16 kMaxFlags = 2000;
+private:
+ int32 _flags[kMaxFlags];
+};
+
+class Interpreter {
+public:
+ Interpreter(PrinceEngine *vm, Script *script, InterpreterFlags *flags);
+
+ void stopBg() { _bgOpcodePC = 0; }
+
+ void stepBg();
+ void stepFg();
+ void storeNewPC(int opcodePC);
+ int getLastOPCode();
+ int getFgOpcodePC();
+
+ void setBgOpcodePC(uint32 value);
+ void setFgOpcodePC(uint32 value);
+
+ uint32 getCurrentString();
+ void setCurrentString(uint32 value);
+
+ byte *getString();
+ void setString(byte *newString);
+ void increaseString();
+
+ void setResult(byte value);
+
+private:
+ PrinceEngine *_vm;
+ Script *_script;
+ InterpreterFlags *_flags;
+
+ uint32 _currentInstruction;
+
+ uint32 _bgOpcodePC;
+ uint32 _fgOpcodePC;
+
+ uint16 _lastOpcode;
+ uint32 _lastInstruction;
+ byte _result;
+
+ bool _opcodeNF; // break interpreter loop
+ bool _opcodeEnd; // end of a game flag
+
+ static const uint32 _STACK_SIZE = 500;
+ uint32 _stack[_STACK_SIZE];
+ struct stringStack {
+ byte *string;
+ byte *dialogData;
+ uint32 currentString;
+ } _stringStack;
+ uint8 _stacktop;
+ uint32 _waitFlag;
+
+ byte *_string;
+ uint32 _currentString;
+ const char *_mode;
+
+ // Helper functions
+ uint32 step(uint32 opcodePC);
+ uint16 readScript16();
+ uint32 readScript32();
+ int32 readScriptFlagValue();
+ Flags::Id readScriptFlagId();
+ int checkSeq(byte *string);
+
+ void debugInterpreter(const char *s, ...);
+
+ typedef void (Interpreter::*OpcodeFunc)();
+ static OpcodeFunc _opcodes[];
+
+ static const uint kGiveLetterScriptFix = 79002;
+ static const uint kSecondBirdAnimationScriptFix = 45658;
+
+ // Keep opcode handlers names as they are in original code
+ // making it easier to switch back and forth
+ void O_WAITFOREVER();
+ void O_BLACKPALETTE();
+ void O_SETUPPALETTE();
+ void O_INITROOM();
+ void O_SETSAMPLE();
+ void O_FREESAMPLE();
+ void O_PLAYSAMPLE();
+ void O_PUTOBJECT();
+ void O_REMOBJECT();
+ void O_SHOWANIM();
+ void O_CHECKANIMEND();
+ void O_FREEANIM();
+ void O_CHECKANIMFRAME();
+ void O_PUTBACKANIM();
+ void O_REMBACKANIM();
+ void O_CHECKBACKANIMFRAME();
+ void O_FREEALLSAMPLES();
+ void O_SETMUSIC();
+ void O_STOPMUSIC();
+ void O__WAIT();
+ void O_UPDATEOFF();
+ void O_UPDATEON();
+ void O_UPDATE ();
+ void O_CLS();
+ void O__CALL();
+ void O_RETURN();
+ void O_GO();
+ void O_BACKANIMUPDATEOFF();
+ void O_BACKANIMUPDATEON();
+ void O_CHANGECURSOR();
+ void O_CHANGEANIMTYPE();
+ void O__SETFLAG();
+ void O_COMPARE();
+ void O_JUMPZ();
+ void O_JUMPNZ();
+ void O_EXIT();
+ void O_ADDFLAG();
+ void O_TALKANIM();
+ void O_SUBFLAG();
+ void O_SETSTRING();
+ void O_ANDFLAG();
+ void O_GETMOBDATA();
+ void O_ORFLAG();
+ void O_SETMOBDATA();
+ void O_XORFLAG();
+ void O_GETMOBTEXT();
+ void O_MOVEHERO();
+ void O_WALKHERO();
+ void O_SETHERO();
+ void O_HEROOFF();
+ void O_HEROON();
+ void O_CLSTEXT();
+ void O_CALLTABLE();
+ void O_CHANGEMOB();
+ void O_ADDINV();
+ void O_REMINV();
+ void O_REPINV();
+ void O_OBSOLETE_GETACTION();
+ void O_ADDWALKAREA();
+ void O_REMWALKAREA();
+ void O_RESTOREWALKAREA();
+ void O_WAITFRAME();
+ void O_SETFRAME();
+ void O_RUNACTION();
+ void O_COMPAREHI();
+ void O_COMPARELO();
+ void O_PRELOADSET();
+ void O_FREEPRELOAD();
+ void O_CHECKINV();
+ void O_TALKHERO();
+ void O_WAITTEXT();
+ void O_SETHEROANIM();
+ void O_WAITHEROANIM();
+ void O_GETHERODATA();
+ void O_GETMOUSEBUTTON();
+ void O_CHANGEFRAMES();
+ void O_CHANGEBACKFRAMES();
+ void O_GETBACKANIMDATA();
+ void O_GETANIMDATA();
+ void O_SETBGCODE();
+ void O_SETBACKFRAME();
+ void O_GETRND();
+ void O_TALKBACKANIM();
+ void O_LOADPATH();
+ void O_GETCHAR();
+ void O_SETDFLAG();
+ void O_CALLDFLAG();
+ void O_PRINTAT();
+ void O_ZOOMIN();
+ void O_ZOOMOUT();
+ void O_SETSTRINGOFFSET();
+ void O_GETOBJDATA();
+ void O_SETOBJDATA();
+ void O_SWAPOBJECTS();
+ void O_CHANGEHEROSET();
+ void O_ADDSTRING();
+ void O_SUBSTRING();
+ void O_INITDIALOG();
+ void O_ENABLEDIALOGOPT();
+ void O_DISABLEDIALOGOPT();
+ void O_SHOWDIALOGBOX();
+ void O_STOPSAMPLE();
+ void O_BACKANIMRANGE();
+ void O_CLEARPATH();
+ void O_SETPATH();
+ void O_GETHEROX();
+ void O_GETHEROY();
+ void O_GETHEROD();
+ void O_PUSHSTRING();
+ void O_POPSTRING();
+ void O_SETFGCODE();
+ void O_STOPHERO();
+ void O_ANIMUPDATEOFF();
+ void O_ANIMUPDATEON();
+ void O_FREECURSOR();
+ void O_ADDINVQUIET();
+ void O_RUNHERO();
+ void O_SETBACKANIMDATA();
+ void O_VIEWFLC();
+ void O_CHECKFLCFRAME();
+ void O_CHECKFLCEND();
+ void O_FREEFLC();
+ void O_TALKHEROSTOP();
+ void O_HEROCOLOR();
+ void O_GRABMAPA();
+ void O_ENABLENAK();
+ void O_DISABLENAK();
+ void O_GETMOBNAME();
+ void O_SWAPINVENTORY();
+ void O_CLEARINVENTORY();
+ void O_SKIPTEXT();
+ void O_SETVOICEH();
+ void O_SETVOICEA();
+ void O_SETVOICEB();
+ void O_SETVOICEC();
+ void O_VIEWFLCLOOP();
+ void O_FLCSPEED();
+ void O_OPENINVENTORY();
+ void O_KRZYWA();
+ void O_GETKRZYWA();
+ void O_GETMOB();
+ void O_INPUTLINE();
+ void O_SETVOICED();
+ void O_BREAK_POINT();
+
+};
+
+} // End of namespace Prince
+
+#endif
diff --git a/engines/prince/sound.cpp b/engines/prince/sound.cpp
new file mode 100644
index 0000000000..032297ee43
--- /dev/null
+++ b/engines/prince/sound.cpp
@@ -0,0 +1,211 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public 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 "prince/prince.h"
+#include "prince/sound.h"
+#include "prince/musNum.h"
+
+#include "common/config-manager.h"
+#include "common/memstream.h"
+#include "common/archive.h"
+#include "audio/decoders/raw.h"
+#include "audio/audiostream.h"
+
+namespace Prince {
+
+const char *MusicPlayer::_musTable[] = {
+ "",
+ "Battlfld.mid",
+ "Cave.mid",
+ "Cemetery.mid",
+ "Credits.mid",
+ "Fjord.mid",
+ "Guitar.mid",
+ "Hell.mid",
+ "Jingle.mid",
+ "Main.mid",
+ "Night.mid",
+ "Reality.mid",
+ "Sunlord.mid",
+ "Tavern.mid",
+ "Temple.mid",
+ "Boruta.mid",
+ "Intro.mid"
+};
+
+const uint8 MusicPlayer::_musRoomTable[] = {
+ 0,
+ ROOM01MUS,
+ ROOM02MUS,
+ ROOM03MUS,
+ ROOM04MUS,
+ ROOM05MUS,
+ ROOM06MUS,
+ ROOM07MUS,
+ ROOM08MUS,
+ ROOM09MUS,
+ ROOM10MUS,
+ ROOM11MUS,
+ ROOM12MUS,
+ ROOM13MUS,
+ ROOM14MUS,
+ ROOM15MUS,
+ ROOM16MUS,
+ ROOM17MUS,
+ ROOM18MUS,
+ ROOM19MUS,
+ ROOM20MUS,
+ ROOM21MUS,
+ ROOM22MUS,
+ ROOM23MUS,
+ ROOM24MUS,
+ ROOM25MUS,
+ ROOM26MUS,
+ ROOM27MUS,
+ ROOM28MUS,
+ ROOM29MUS,
+ ROOM30MUS,
+ ROOM31MUS,
+ ROOM32MUS,
+ ROOM33MUS,
+ ROOM34MUS,
+ ROOM35MUS,
+ ROOM36MUS,
+ ROOM37MUS,
+ ROOM38MUS,
+ ROOM39MUS,
+ ROOM40MUS,
+ ROOM41MUS,
+ ROOM42MUS,
+ ROOM43MUS,
+ 0,
+ 0,
+ ROOM46MUS,
+ ROOM47MUS,
+ ROOM48MUS,
+ ROOM49MUS,
+ ROOM50MUS,
+ ROOM51MUS,
+ ROOM52MUS,
+ ROOM53MUS,
+ ROOM54MUS,
+ ROOM55MUS,
+ ROOM56MUS,
+ ROOM57MUS,
+ ROOM58MUS,
+ ROOM59MUS,
+ ROOM60MUS,
+ ROOM61MUS
+};
+
+
+MusicPlayer::MusicPlayer(PrinceEngine *vm) : _vm(vm) {
+ _data = nullptr;
+ _isGM = false;
+
+ MidiPlayer::createDriver();
+
+ int ret = _driver->open();
+ if (ret == 0) {
+ if (_nativeMT32)
+ _driver->sendMT32Reset();
+ else
+ _driver->sendGMReset();
+
+ _driver->setTimerCallback(this, &timerCallback);
+ }
+}
+
+MusicPlayer::~MusicPlayer() {
+ killMidi();
+}
+
+void MusicPlayer::killMidi() {
+ Audio::MidiPlayer::stop();
+
+ free(_data);
+ _data = nullptr;
+}
+
+void MusicPlayer::loadMidi(const char *name) {
+ Common::SeekableReadStream *stream = SearchMan.createReadStreamForMember(name);
+ if (!stream) {
+ debug("Can't load midi stream %s", name);
+ return;
+ }
+
+ // Stop any currently playing MIDI file
+ killMidi();
+
+ // Read in the data for the file
+ _dataSize = stream->size();
+ _data = (byte *)malloc(_dataSize);
+ stream->read(_data, _dataSize);
+
+ delete stream;
+
+ // Start playing the music
+ sndMidiStart();
+}
+
+void MusicPlayer::sndMidiStart() {
+ _isGM = true;
+
+ MidiParser *parser = MidiParser::createParser_SMF();
+ if (parser->loadMusic(_data, _dataSize)) {
+ parser->setTrack(0);
+ parser->setMidiDriver(this);
+ parser->setTimerRate(_driver->getBaseTempo());
+ parser->property(MidiParser::mpCenterPitchWheelOnUnload, 1);
+
+ _parser = parser;
+
+ syncVolume();
+
+ // Al the tracks are supposed to loop
+ _isLooping = true;
+ _isPlaying = true;
+ }
+}
+
+void MusicPlayer::send(uint32 b) {
+ if ((b & 0xF0) == 0xC0 && !_isGM && !_nativeMT32) {
+ b = (b & 0xFFFF00FF) | MidiDriver::_mt32ToGm[(b >> 8) & 0xFF] << 8;
+ }
+
+ Audio::MidiPlayer::send(b);
+}
+
+void MusicPlayer::sendToChannel(byte channel, uint32 b) {
+ if (!_channelsTable[channel]) {
+ _channelsTable[channel] = (channel == 9) ? _driver->getPercussionChannel() : _driver->allocateChannel();
+ // If a new channel is allocated during the playback, make sure
+ // its volume is correctly initialized.
+ if (_channelsTable[channel])
+ _channelsTable[channel]->volume(_channelsVolume[channel] * _masterVolume / 255);
+ }
+
+ if (_channelsTable[channel])
+ _channelsTable[channel]->send(b);
+}
+
+} // End of namespace Prince
diff --git a/engines/prince/sound.h b/engines/prince/sound.h
new file mode 100644
index 0000000000..cc44b0a110
--- /dev/null
+++ b/engines/prince/sound.h
@@ -0,0 +1,67 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef PRINCE_SOUND_H
+#define PRINCE_SOUND_H
+
+#include "audio/audiostream.h"
+#include "audio/decoders/wave.h"
+#include "audio/fmopl.h"
+#include "audio/mididrv.h"
+#include "audio/midiparser.h"
+#include "audio/midiplayer.h"
+#include "audio/mixer.h"
+#include "common/memstream.h"
+
+namespace Prince {
+
+class PrinceEngine;
+
+class MusicPlayer: public Audio::MidiPlayer {
+private:
+ PrinceEngine *_vm;
+ byte *_data;
+ int _dataSize;
+ bool _isGM;
+
+ // Start MIDI File
+ void sndMidiStart();
+
+ // Stop MIDI File
+ void sndMidiStop();
+public:
+ MusicPlayer(PrinceEngine *vm);
+ ~MusicPlayer();
+
+ void loadMidi(const char *);
+ void killMidi();
+
+ virtual void send(uint32 b);
+ virtual void sendToChannel(byte channel, uint32 b);
+
+ static const char *_musTable[];
+ static const uint8 _musRoomTable[];
+};
+
+} // End of namespace Prince
+
+#endif
diff --git a/engines/prince/variatxt.cpp b/engines/prince/variatxt.cpp
new file mode 100644
index 0000000000..c38c65ce5d
--- /dev/null
+++ b/engines/prince/variatxt.cpp
@@ -0,0 +1,55 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "prince/variatxt.h"
+#include "common/debug.h"
+
+namespace Prince {
+
+VariaTxt::VariaTxt() : _dataSize(0), _data(nullptr) {
+}
+
+VariaTxt::~VariaTxt() {
+ _dataSize = 0;
+ if (_data != nullptr) {
+ free(_data);
+ _data = nullptr;
+ }
+}
+
+
+bool VariaTxt::loadStream(Common::SeekableReadStream &stream) {
+ _dataSize = stream.size();
+ _data = (byte *)malloc(_dataSize);
+ stream.read(_data, _dataSize);
+ return true;
+}
+
+byte *VariaTxt::getString(uint32 stringId) {
+ uint32 stringOffset = READ_LE_UINT32(_data + stringId * 4);
+ if (stringOffset > _dataSize) {
+ assert(false);
+ }
+ return _data + stringOffset;
+}
+
+} // End of namespace Prince
diff --git a/engines/zvision/inventory/inventory_manager.h b/engines/prince/variatxt.h
index f9d2ff294a..04c34bc0ef 100644
--- a/engines/zvision/inventory/inventory_manager.h
+++ b/engines/prince/variatxt.h
@@ -8,21 +8,33 @@
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
- *
+
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+
* You should have received a copy of the GNU General Public 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 ZVISION_INVENTORY_MANAGER_H
-#define ZVISION_INVENTORY_MANAGER_H
+#include "common/stream.h"
+
+namespace Prince {
+
+class VariaTxt {
+public:
+ VariaTxt();
+ ~VariaTxt();
+
+ bool loadStream(Common::SeekableReadStream &stream);
+ byte *getString(uint32 stringId);
-// TODO: Implement InventoryManager
+private:
+ uint32 _dataSize;
+ byte *_data;
+};
-#endif
+} // End of namespace Prince
diff --git a/engines/queen/POTFILES b/engines/queen/POTFILES
index 1baf9c24de..28624662ca 100644
--- a/engines/queen/POTFILES
+++ b/engines/queen/POTFILES
@@ -1 +1 @@
-engines/queen/queen.cpp
+engines/queen/detection.cpp
diff --git a/engines/queen/logic.cpp b/engines/queen/logic.cpp
index d48bb8a498..664a9a15f9 100644
--- a/engines/queen/logic.cpp
+++ b/engines/queen/logic.cpp
@@ -2115,9 +2115,15 @@ void LogicInterview::setupSpecialMoveTable() {
}
void LogicGame::useJournal() {
+ _vm->input()->clearKeyVerb();
+ _vm->input()->clearMouseButton();
+
_vm->command()->clear(false);
_journal->use();
_vm->walk()->stopJoe();
+
+ _vm->input()->clearKeyVerb();
+ _vm->input()->clearMouseButton();
}
bool LogicGame::changeToSpecialRoom() {
diff --git a/engines/queen/talk.cpp b/engines/queen/talk.cpp
index 1b9d72babc..e86a53d448 100644
--- a/engines/queen/talk.cpp
+++ b/engines/queen/talk.cpp
@@ -189,7 +189,7 @@ void Talk::talk(const char *filename, int personInRoom, char *cutawayFilename) {
}
}
- if (_vm->input()->talkQuit())
+ if (_vm->input()->talkQuit() || _vm->shouldQuit())
break;
retval = _dialogueTree[level][selectedSentence].dialogueNodeValue1;
@@ -1250,15 +1250,12 @@ int16 Talk::selectSentence() {
}
_vm->input()->clearKeyVerb();
+ _vm->input()->clearMouseButton();
if (sentenceCount > 0) {
int oldZone = 0;
- while (0 == selectedSentence) {
-
- if (_vm->input()->talkQuit())
- break;
-
+ while (0 == selectedSentence && !_vm->input()->talkQuit() && !_vm->shouldQuit()) {
_vm->update();
Common::Point mouse = _vm->input()->getMousePos();
@@ -1328,6 +1325,9 @@ int16 Talk::selectSentence() {
}
}
+ _vm->input()->clearKeyVerb();
+ _vm->input()->clearMouseButton();
+
debug(6, "Selected sentence %i", selectedSentence);
arrowBobUp->active = false;
diff --git a/engines/saga/actor.h b/engines/saga/actor.h
index b8a5436d76..8dc27c74be 100644
--- a/engines/saga/actor.h
+++ b/engines/saga/actor.h
@@ -468,7 +468,6 @@ public:
int actorIdToIndex(uint16 id) { return (id == ID_PROTAG) ? 0 : objectIdToIndex(id); }
uint16 actorIndexToId(int index) { return (index == 0) ? ID_PROTAG : objectIndexToId(kGameObjectActor, index); }
ActorData *getActor(uint16 actorId);
- ActorData *getFirstActor() { return &_actors.front(); }
// clarification: Obj - means game object, such Hat, Spoon etc, Object - means Actor,Obj,HitZone,StepZone
diff --git a/engines/saga/introproc_ite.cpp b/engines/saga/introproc_ite.cpp
index 0c1a2ce233..0b129dbcc0 100644
--- a/engines/saga/introproc_ite.cpp
+++ b/engines/saga/introproc_ite.cpp
@@ -374,7 +374,7 @@ int Scene::ITEIntroCaveCommonProc(int param, int caveScene) {
lang = 2;
int n_dialogues = 0;
-
+
switch (caveScene) {
case 1:
n_dialogues = ARRAYSIZE(introDialogueCave1[lang]);
diff --git a/engines/saga/saveload.cpp b/engines/saga/saveload.cpp
index 90ba62070b..e659e09ce8 100644
--- a/engines/saga/saveload.cpp
+++ b/engines/saga/saveload.cpp
@@ -215,8 +215,7 @@ void SagaEngine::save(const char *fileName, const char *saveName) {
#ifdef ENABLE_IHNM
if (getGameId() == GID_IHNM) {
out->writeSint32LE(_scene->currentChapterNumber());
- // Protagonist
- out->writeSint32LE(_scene->currentProtag());
+ out->writeSint32LE(0); // obsolete, was used for the protagonist
out->writeSint32LE(_scene->getCurrentMusicTrack());
out->writeSint32LE(_scene->getCurrentMusicRepeat());
}
@@ -316,7 +315,7 @@ void SagaEngine::load(const char *fileName) {
if (getGameId() == GID_IHNM) {
int currentChapter = _scene->currentChapterNumber();
_scene->setChapterNumber(in->readSint32LE());
- _scene->setProtag(in->readSint32LE());
+ in->skip(4); // obsolete, was used for setting the protagonist
if (_scene->currentChapterNumber() != currentChapter)
_scene->changeScene(-2, 0, kTransitionFade, _scene->currentChapterNumber());
_scene->setCurrentMusicTrack(in->readSint32LE());
@@ -366,30 +365,6 @@ void SagaEngine::load(const char *fileName) {
int volume = _music->getVolume();
_music->setVolume(0);
-#ifdef ENABLE_IHNM
- // Protagonist swapping
- if (getGameId() == GID_IHNM) {
- if (_scene->currentProtag() != 0 && _scene->currentChapterNumber() != 6) {
- ActorData *actor1 = _actor->getFirstActor();
- ActorData *actor2;
- // The original gets actor2 from the current protagonist ID, but this is sometimes wrong
- // If the current protagonist ID is not correct, use the stored protagonist
- if (!_actor->validActorId(_scene->currentProtag())) {
- actor2 = _actor->_protagonist;
- } else {
- actor2 = _actor->getActor(_scene->currentProtag());
- }
-
- SWAP(actor1->_location, actor2->_location);
-
- actor2->_flags &= ~kProtagonist;
- actor1->_flags |= kProtagonist;
- _actor->_protagonist = _actor->_centerActor = actor1;
- _scene->setProtag(actor1->_id);
- }
- }
-#endif
-
_scene->clearSceneQueue();
_scene->changeScene(sceneNumber, ACTOR_NO_ENTRANCE, kTransitionNoFade);
diff --git a/engines/saga/scene.h b/engines/saga/scene.h
index 6a9571d282..410713c5d5 100644
--- a/engines/saga/scene.h
+++ b/engines/saga/scene.h
@@ -286,8 +286,6 @@ class Scene {
#endif
return _sceneLUT[sceneNumber];
}
- int currentProtag() const { return _currentProtag; }
- void setProtag(int pr) { _currentProtag = pr; }
int currentSceneNumber() const { return _sceneNumber; }
int currentChapterNumber() const { return _chapterNumber; }
void setChapterNumber(int ch) { _chapterNumber = ch; }
@@ -341,7 +339,6 @@ class Scene {
Common::Array<uint16> _sceneLUT;
SceneQueueList _sceneQueue;
bool _sceneLoaded;
- int _currentProtag;
int _sceneNumber;
int _chapterNumber;
int _outsetSceneNumber;
diff --git a/engines/saga/sfuncs.cpp b/engines/saga/sfuncs.cpp
index cb963e23ac..2175d8f40a 100644
--- a/engines/saga/sfuncs.cpp
+++ b/engines/saga/sfuncs.cpp
@@ -748,14 +748,10 @@ void Script::sfSwapActors(SCRIPTFUNC_PARAMS) {
actor1->_flags &= ~kProtagonist;
actor2->_flags |= kProtagonist;
_vm->_actor->_protagonist = _vm->_actor->_centerActor = actor2;
- if (_vm->getGameId() == GID_IHNM)
- _vm->_scene->setProtag(actorId2);
} else if (actor2->_flags & kProtagonist) {
actor2->_flags &= ~kProtagonist;
actor1->_flags |= kProtagonist;
_vm->_actor->_protagonist = _vm->_actor->_centerActor = actor1;
- if (_vm->getGameId() == GID_IHNM)
- _vm->_scene->setProtag(actorId1);
}
}
diff --git a/engines/saga/shorten.cpp b/engines/saga/shorten.cpp
index edb12a3dd9..1e1c397212 100644
--- a/engines/saga/shorten.cpp
+++ b/engines/saga/shorten.cpp
@@ -438,7 +438,7 @@ byte *loadShortenFromStream(Common::ReadStream &stream, int &size, int &rate, by
for (i = 0; i < 64; ++i)
oldValues[curChannel][i] = 0;
- int arrayTerminator = MIN<int>(64, blockSize);
+ uint arrayTerminator = MIN<int>(64, blockSize);
for (i = 0; i < arrayTerminator; ++i)
oldValues[curChannel][i] = buffer[curChannel][blockSize - (i + 1)];
diff --git a/engines/sci/console.cpp b/engines/sci/console.cpp
index 565e9752c3..e233c4cba4 100644
--- a/engines/sci/console.cpp
+++ b/engines/sci/console.cpp
@@ -485,6 +485,7 @@ bool Console::cmdGetVersion(int argc, const char **argv) {
#endif
debugPrintf("View type: %s\n", viewTypeDesc[g_sci->getResMan()->getViewType()]);
debugPrintf("Uses palette merging: %s\n", g_sci->_gfxPalette->isMerging() ? "yes" : "no");
+ debugPrintf("Uses 16 bit color matching: %s\n", g_sci->_gfxPalette->isUsing16bitColorMatch() ? "yes" : "no");
debugPrintf("Resource volume version: %s\n", g_sci->getResMan()->getVolVersionDesc());
debugPrintf("Resource map version: %s\n", g_sci->getResMan()->getMapVersionDesc());
debugPrintf("Contains selector vocabulary (vocab.997): %s\n", hasVocab997 ? "yes" : "no");
@@ -663,7 +664,7 @@ bool Console::cmdDiskDump(int argc, const char **argv) {
int resNumFrom = 0;
int resNumTo = 0;
int resNumCur = 0;
-
+
if (argc != 3) {
debugPrintf("Dumps the specified resource to disk as a patch file\n");
debugPrintf("Usage: %s <resource type> <resource number>\n", argv[0]);
@@ -671,7 +672,7 @@ bool Console::cmdDiskDump(int argc, const char **argv) {
cmdResourceTypes(argc, argv);
return true;
}
-
+
if (strcmp(argv[2], "*") == 0) {
resNumFrom = 0;
resNumTo = 65535;
diff --git a/engines/sci/detection.cpp b/engines/sci/detection.cpp
index 4f28738508..85ff1c0062 100644
--- a/engines/sci/detection.cpp
+++ b/engines/sci/detection.cpp
@@ -563,31 +563,28 @@ const ADGameDescription *SciMetaEngine::fallbackDetect(const FileMap &allFiles,
// If these files aren't found, it can't be SCI
- if (!foundResMap && !foundRes000) {
+ if (!foundResMap && !foundRes000)
return 0;
- }
ResourceManager resMan;
- resMan.addAppropriateSources(fslist);
- resMan.init(true);
+ resMan.addAppropriateSourcesForDetection(fslist);
+ resMan.initForDetection();
// TODO: Add error handling.
#ifndef ENABLE_SCI32
// Is SCI32 compiled in? If not, and this is a SCI32 game,
// stop here
- if (getSciVersion() >= SCI_VERSION_2) {
- return (const ADGameDescription *)&s_fallbackDesc;
- }
+ if (getSciVersionForDetection() >= SCI_VERSION_2)
+ return 0;
#endif
ViewType gameViews = resMan.getViewType();
// Have we identified the game views? If not, stop here
- // Can't be SCI (or unsupported SCI views). Pinball Creep by sierra also uses resource.map/resource.000 files
- // but doesnt share sci format at all, if we dont return 0 here we will detect this game as SCI
- if (gameViews == kViewUnknown) {
+ // Can't be SCI (or unsupported SCI views). Pinball Creep by Sierra also uses resource.map/resource.000 files
+ // but doesn't share SCI format at all
+ if (gameViews == kViewUnknown)
return 0;
- }
// Set the platform to Amiga if the game is using Amiga views
if (gameViews == kViewAmiga)
@@ -597,9 +594,8 @@ const ADGameDescription *SciMetaEngine::fallbackDetect(const FileMap &allFiles,
Common::String sierraGameId = resMan.findSierraGameId();
// If we don't have a game id, the game is not SCI
- if (sierraGameId.empty()) {
+ if (sierraGameId.empty())
return 0;
- }
Common::String gameId = convertSierraGameId(sierraGameId, &s_fallbackDesc.flags, resMan);
strncpy(s_fallbackGameIdBuf, gameId.c_str(), sizeof(s_fallbackGameIdBuf) - 1);
diff --git a/engines/sci/detection_tables.h b/engines/sci/detection_tables.h
index 91b3c45c6e..32d1a58765 100644
--- a/engines/sci/detection_tables.h
+++ b/engines/sci/detection_tables.h
@@ -1832,15 +1832,12 @@ static const struct ADGameDescription SciGameDescriptions[] = {
AD_LISTEND},
Common::EN_ANY, Common::kPlatformDOS, 0, GUIO4(GUIO_NOSPEECH, GAMEOPTION_PREFER_DIGITAL_SFX, GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_FB01_MIDI) },
-#if 0
- // The resource.002 file, contained in disk 3, is broken in this version
- // (it contains a large chunk of zeroes and several broken resources,
- // e.g. pic 250 and views 250 and 251).
- // Thus this detection entry isn't accurate.
-
- // Larry 1 Remake - English Amiga (from www.back2roots.org)
+ // Larry 1 Remake - English Amiga
// Executable scanning reports "1.004.024"
// SCI interpreter version 1.000.784
+ // NOTE: The resource.002 file, contained in disk 3, is broken in the
+ // www.back2roots.org version (it contains a large chunk of zeroes and
+ // several broken resources, e.g. pic 250 and views 250 and 251).
{"lsl1sci", "SCI", {
{"resource.map", 0, "7d115a9e27dc8ac71e8d5ef33d589bd5", 3366},
{"resource.000", 0, "e67fd129d5810fc7ad8ea509d891cc00", 363073},
@@ -1849,7 +1846,6 @@ static const struct ADGameDescription SciGameDescriptions[] = {
{"resource.003", 0, "4a34c3367c2fe7eb380d741374da1989", 572251},
AD_LISTEND},
Common::EN_ANY, Common::kPlatformAmiga, 0, GUIO4(GUIO_NOSPEECH, GAMEOPTION_PREFER_DIGITAL_SFX, GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_FB01_MIDI) },
-#endif
// Larry 1 VGA Remake - English DOS (from spookypeanut)
// Executable scanning reports "1.000.577", VERSION file reports "2.1"
@@ -2073,6 +2069,20 @@ static const struct ADGameDescription SciGameDescriptions[] = {
AD_LISTEND},
Common::DE_DEU, Common::kPlatformDOS, ADGF_ADDENGLISH, GUIO5(GUIO_NOSPEECH, GAMEOPTION_EGA_UNDITHER, GAMEOPTION_PREFER_DIGITAL_SFX, GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_FB01_MIDI) },
+ // Larry 3 - German DOS (German+English, 5 1/4" floppies)
+ // SCI interpreter version S.old.114 (executable), VERSION is "1.056"
+ {"lsl3", "", {
+ {"resource.map", 0, "2468da5d664bb6ca3df866074a05e43c", 8910},
+ {"resource.001", 0, "3827a9b17b926e12dcc336860f50612a", 163326},
+ {"resource.002", 0, "3827a9b17b926e12dcc336860f50612a", 312436},
+ {"resource.003", 0, "3827a9b17b926e12dcc336860f50612a", 347307},
+ {"resource.004", 0, "3827a9b17b926e12dcc336860f50612a", 332369},
+ {"resource.005", 0, "3827a9b17b926e12dcc336860f50612a", 347654},
+ {"resource.006", 0, "3827a9b17b926e12dcc336860f50612a", 326011},
+ {"resource.007", 0, "3827a9b17b926e12dcc336860f50612a", 309553},
+ AD_LISTEND},
+ Common::DE_DEU, Common::kPlatformDOS, ADGF_ADDENGLISH, GUIO5(GUIO_NOSPEECH, GAMEOPTION_EGA_UNDITHER, GAMEOPTION_PREFER_DIGITAL_SFX, GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_FB01_MIDI) },
+
// Larry 3 - French DOS (provided by richiefs in bug report #2670691, also includes english language)
// Executable scanning reports "S.old.123"
// SCI interpreter version 0.000.572 (just a guess)
@@ -2607,6 +2617,29 @@ static const struct ADGameDescription SciGameDescriptions[] = {
AD_LISTEND},
Common::EN_ANY, Common::kPlatformDOS, ADGF_UNSTABLE, GUIO5(GUIO_NOSPEECH, GUIO_NOASPECT, GAMEOPTION_PREFER_DIGITAL_SFX, GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_FB01_MIDI) },
+ // Phantasmagoria - German DOS/Windows
+ // Windows executable scanning reports "unknown" - "Sep 19 1995 09:39:48"
+ // DOS executable scanning reports "unknown" - "Sep 19 1995 16:18:34"
+ // VERSION file reports "1.100.000"
+ // Supplied by AReim1982
+ {"phantasmagoria", "", {
+ {"resmap.001", 0, "d5048f972d2e1abd5f6b6a3ea8a466b0", 11524},
+ {"ressci.001", 0, "3aae6559aa1df273bc542d5ac6330d75", 71063082},
+ {"resmap.002", 0, "ae0105261e04826324daf7dd2d534465", 12064},
+ {"ressci.002", 0, "3aae6559aa1df273bc542d5ac6330d75", 80283368},
+ {"resmap.003", 0, "50786a4f54c6432ec31b52be90b3a8ba", 12340},
+ {"ressci.003", 0, "3aae6559aa1df273bc542d5ac6330d75", 82360370},
+ {"resmap.004", 0, "4cd3bbff8b81bad85db52c0c8407bd81", 12562},
+ {"ressci.004", 0, "3aae6559aa1df273bc542d5ac6330d75", 84453560},
+ {"resmap.005", 0, "779bd12802da6cfe54ce482140824a46", 12616},
+ {"ressci.005", 0, "3aae6559aa1df273bc542d5ac6330d75", 85113663},
+ {"resmap.006", 0, "2299f97876493cc29b6a48e1cfe9619d", 12538},
+ {"ressci.006", 0, "3aae6559aa1df273bc542d5ac6330d75", 87602346},
+ {"resmap.007", 0, "06309b8043aecb85bd507b15d16cb544", 7984},
+ //{"ressci.007", 0, "3aae6559aa1df273bc542d5ac6330d75", 26898681},
+ AD_LISTEND},
+ Common::DE_DEU, Common::kPlatformDOS, ADGF_UNSTABLE, GUIO5(GUIO_NOSPEECH, GUIO_NOASPECT, GAMEOPTION_PREFER_DIGITAL_SFX, GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_FB01_MIDI) },
+
// Phantasmagoria - French DOS
// Supplied by Kervala in bug #6574
{"phantasmagoria", "", {
@@ -2678,6 +2711,25 @@ static const struct ADGameDescription SciGameDescriptions[] = {
AD_LISTEND},
Common::EN_ANY, Common::kPlatformWindows, ADGF_UNSTABLE, GUIO5(GUIO_NOSPEECH, GUIO_NOASPECT, GAMEOPTION_PREFER_DIGITAL_SFX, GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_FB01_MIDI) },
+ // Phantasmagoria 2 - German DOS/Windows
+ // Windows executable scanning reports "unknown" - "Dec 07 1996 15:42:02"
+ // DOS executable scanning reports "unknown" - "Dec 07 1996 08:35:12"
+ // VERSION file reports "000.1.0vu" (HEX: 30 30 30 2E 31 00 2E 30 76 FA 0D 0A)
+ // Supplied by AReim1982
+ {"phantasmagoria2", "", {
+ {"resmap.001", 0, "d62f48ff8bddb39503b97e33439482c9", 1114},
+ {"ressci.001", 0, "4ebc2b8455c74ad205ae592eec27313a", 24590716},
+ {"resmap.002", 0, "642a1f85ad8a4ce1d3850b10ad082200", 1138},
+ {"ressci.002", 0, "4ebc2b8455c74ad205ae592eec27313a", 34681672},
+ {"resmap.003", 0, "e08316864ef77735bb7f8f208110c43b", 1174},
+ {"ressci.003", 0, "4ebc2b8455c74ad205ae592eec27313a", 38930933},
+ {"resmap.004", 0, "875cf07df77fbaa1518a06ffed616c5f", 1300},
+ {"ressci.004", 0, "4ebc2b8455c74ad205ae592eec27313a", 42750325},
+ {"resmap.005", 0, "2fc48a4a5a73b726994f189da51a8b2a", 1954},
+ {"ressci.005", 0, "e94005890d22dd3b7f605a2a7c025803", 68232146},
+ AD_LISTEND},
+ Common::DE_DEU, Common::kPlatformWindows, ADGF_UNSTABLE, GUIO5(GUIO_NOSPEECH, GUIO_NOASPECT, GAMEOPTION_PREFER_DIGITAL_SFX, GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_FB01_MIDI) },
+
// Phantasmagoria 2 - English DOS (GOG version) - ressci.* merged in ressci.000
// Executable scanning reports "3.000.000" - "Dec 07 1996 09:29:03"
// VERSION file reports "001.0.06"
@@ -4119,6 +4171,7 @@ static const struct ADGameDescription SciGameDescriptions[] = {
FANMADE("Knight's Quest Demo 1.0", "5e816edf993956752ed06fccfeeae6d9", 1260, "959321f88a22905fa1f8c6d897874744", 703836),
FANMADE("LockerGnome Quest", "3eeff9130206cad0c4e1551e2b9dd2c5", 420, "ae05ca90806fd90cc43f147c82d3547c", 158906),
FANMADE("LockerGnome Quest Redux", "55b0081dbdd77a07807c76cec3606970", 492, "75c9c5e8a475a7b5f1a6cb18edad67f2", 168069),
+ FANMADE("LockerGnome Quest Redux", "6299578d8ab709cc181baea6b984a0a7", 492, "c0ff4bfcc62fb111337343967e4001fd", 167383),
FANMADE("New Year's Mystery", "e4dcab1b1d3cb4a2c070a07a9c9589e0", 708, "e00ca5e44fd4e98d8174b467b31b0f21", 295425),
FANMADE("New Year's Mystery (Updated)", "efd1beb5120293725065c95959144f81", 714, "b3bd3c2372ed6efa28adb12403c4c31a", 305027),
FANMADE("Ocean Battle", "c2304a0568e0eb84f8e9a0915f01170a", 408, "46c520c1ac9b63528854d0f58c7e1b74", 142234),
diff --git a/engines/sci/engine/kernel.h b/engines/sci/engine/kernel.h
index dddf845222..a65bcb7df5 100644
--- a/engines/sci/engine/kernel.h
+++ b/engines/sci/engine/kernel.h
@@ -145,7 +145,7 @@ public:
*/
Kernel(ResourceManager *resMan, SegManager *segMan);
~Kernel();
-
+
void init();
uint getSelectorNamesSize() const;
@@ -161,7 +161,7 @@ public:
* @return The appropriate selector ID, or -1 on error
*/
int findSelector(const char *selectorName) const;
-
+
bool selectorNamesAvailable();
// Script dissection/dumping functions
diff --git a/engines/sci/engine/kfile.cpp b/engines/sci/engine/kfile.cpp
index 61fb717567..c56eb09482 100644
--- a/engines/sci/engine/kfile.cpp
+++ b/engines/sci/engine/kfile.cpp
@@ -37,6 +37,7 @@
#include "sci/engine/state.h"
#include "sci/engine/kernel.h"
#include "sci/engine/savegame.h"
+#include "sci/graphics/menu.h"
#include "sci/sound/audio.h"
#include "sci/console.h"
@@ -913,6 +914,25 @@ reg_t kRestoreGame(EngineState *s, int argc, reg_t *argv) {
// code concerning this via script patch.
s->variables[VAR_GLOBAL][0xB3].setOffset(SAVEGAMEID_OFFICIALRANGE_START + savegameId);
break;
+ case GID_JONES:
+ // HACK: The code that enables certain menu items isn't called when a game is restored from the
+ // launcher, or the "Restore game" option in the game's main menu - bugs #6537 and #6723.
+ // These menu entries are disabled when the game is launched, and are enabled when a new game is
+ // started. The code for enabling these entries is is all in script 1, room1::init, but that code
+ // path is never followed in these two cases (restoring game from the menu, or restoring a game
+ // from the ScummVM launcher). Thus, we perform the calls to enable the menus ourselves here.
+ // These two are needed when restoring from the launcher
+ // FIXME: The original interpreter saves and restores the menu state, so these attributes
+ // are automatically reset there. We may want to do the same.
+ g_sci->_gfxMenu->kernelSetAttribute(257 >> 8, 257 & 0xFF, SCI_MENU_ATTRIBUTE_ENABLED, TRUE_REG); // Sierra -> About Jones
+ g_sci->_gfxMenu->kernelSetAttribute(258 >> 8, 258 & 0xFF, SCI_MENU_ATTRIBUTE_ENABLED, TRUE_REG); // Sierra -> Help
+ // The rest are normally enabled from room1::init
+ g_sci->_gfxMenu->kernelSetAttribute(769 >> 8, 769 & 0xFF, SCI_MENU_ATTRIBUTE_ENABLED, TRUE_REG); // Options -> Delete current player
+ g_sci->_gfxMenu->kernelSetAttribute(513 >> 8, 513 & 0xFF, SCI_MENU_ATTRIBUTE_ENABLED, TRUE_REG); // Game -> Save Game
+ g_sci->_gfxMenu->kernelSetAttribute(515 >> 8, 515 & 0xFF, SCI_MENU_ATTRIBUTE_ENABLED, TRUE_REG); // Game -> Restore Game
+ g_sci->_gfxMenu->kernelSetAttribute(1025 >> 8, 1025 & 0xFF, SCI_MENU_ATTRIBUTE_ENABLED, TRUE_REG); // Status -> Statistics
+ g_sci->_gfxMenu->kernelSetAttribute(1026 >> 8, 1026 & 0xFF, SCI_MENU_ATTRIBUTE_ENABLED, TRUE_REG); // Status -> Goals
+ break;
default:
break;
}
diff --git a/engines/sci/engine/kgraphics.cpp b/engines/sci/engine/kgraphics.cpp
index c2089bcd4d..ee2249bd9d 100644
--- a/engines/sci/engine/kgraphics.cpp
+++ b/engines/sci/engine/kgraphics.cpp
@@ -354,13 +354,16 @@ reg_t kTextSize(EngineState *s, int argc, reg_t *argv) {
}
textWidth = dest[3].toUint16(); textHeight = dest[2].toUint16();
+
+ uint16 languageSplitter = 0;
+ Common::String splitText = g_sci->strSplitLanguage(text.c_str(), &languageSplitter, sep);
#ifdef ENABLE_SCI32
if (g_sci->_gfxText32)
- g_sci->_gfxText32->kernelTextSize(g_sci->strSplit(text.c_str(), sep).c_str(), font_nr, maxwidth, &textWidth, &textHeight);
+ g_sci->_gfxText32->kernelTextSize(splitText.c_str(), font_nr, maxwidth, &textWidth, &textHeight);
else
#endif
- g_sci->_gfxText16->kernelTextSize(g_sci->strSplit(text.c_str(), sep).c_str(), font_nr, maxwidth, &textWidth, &textHeight);
+ g_sci->_gfxText16->kernelTextSize(splitText.c_str(), languageSplitter, font_nr, maxwidth, &textWidth, &textHeight);
// One of the game texts in LB2 German contains loads of spaces in
// its end. We trim the text here, otherwise the graphics code will
@@ -376,7 +379,7 @@ reg_t kTextSize(EngineState *s, int argc, reg_t *argv) {
// Copy over the trimmed string...
s->_segMan->strcpy(argv[1], text.c_str());
// ...and recalculate bounding box dimensions
- g_sci->_gfxText16->kernelTextSize(g_sci->strSplit(text.c_str(), sep).c_str(), font_nr, maxwidth, &textWidth, &textHeight);
+ g_sci->_gfxText16->kernelTextSize(splitText.c_str(), languageSplitter, font_nr, maxwidth, &textWidth, &textHeight);
}
}
@@ -818,16 +821,29 @@ void _k_GenericDrawControl(EngineState *s, reg_t controlObject, bool hilite) {
if (!textReference.isNull())
text = s->_segMan->getString(textReference);
+ uint16 languageSplitter = 0;
+ Common::String splitText;
+
+ switch (type) {
+ case SCI_CONTROLS_TYPE_BUTTON:
+ case SCI_CONTROLS_TYPE_TEXTEDIT:
+ splitText = g_sci->strSplitLanguage(text.c_str(), &languageSplitter, NULL);
+ break;
+ case SCI_CONTROLS_TYPE_TEXT:
+ splitText = g_sci->strSplitLanguage(text.c_str(), &languageSplitter);
+ break;
+ }
+
switch (type) {
case SCI_CONTROLS_TYPE_BUTTON:
debugC(kDebugLevelGraphics, "drawing button %04x:%04x to %d,%d", PRINT_REG(controlObject), x, y);
- g_sci->_gfxControls16->kernelDrawButton(rect, controlObject, g_sci->strSplit(text.c_str(), NULL).c_str(), fontId, style, hilite);
+ g_sci->_gfxControls16->kernelDrawButton(rect, controlObject, splitText.c_str(), languageSplitter, fontId, style, hilite);
return;
case SCI_CONTROLS_TYPE_TEXT:
alignment = readSelectorValue(s->_segMan, controlObject, SELECTOR(mode));
debugC(kDebugLevelGraphics, "drawing text %04x:%04x ('%s') to %d,%d, mode=%d", PRINT_REG(controlObject), text.c_str(), x, y, alignment);
- g_sci->_gfxControls16->kernelDrawText(rect, controlObject, g_sci->strSplit(text.c_str()).c_str(), fontId, alignment, style, hilite);
+ g_sci->_gfxControls16->kernelDrawText(rect, controlObject, splitText.c_str(), languageSplitter, fontId, alignment, style, hilite);
s->r_acc = g_sci->_gfxText16->allocAndFillReferenceRectArray();
return;
@@ -841,7 +857,7 @@ void _k_GenericDrawControl(EngineState *s, reg_t controlObject, bool hilite) {
writeSelectorValue(s->_segMan, controlObject, SELECTOR(cursor), cursorPos);
}
debugC(kDebugLevelGraphics, "drawing edit control %04x:%04x (text %04x:%04x, '%s') to %d,%d", PRINT_REG(controlObject), PRINT_REG(textReference), text.c_str(), x, y);
- g_sci->_gfxControls16->kernelDrawTextEdit(rect, controlObject, g_sci->strSplit(text.c_str(), NULL).c_str(), fontId, mode, style, cursorPos, maxChars, hilite);
+ g_sci->_gfxControls16->kernelDrawTextEdit(rect, controlObject, splitText.c_str(), languageSplitter, fontId, mode, style, cursorPos, maxChars, hilite);
return;
case SCI_CONTROLS_TYPE_ICON:
@@ -1165,8 +1181,11 @@ reg_t kDisplay(EngineState *s, int argc, reg_t *argv) {
argc--; argc--; argv++; argv++;
text = g_sci->getKernel()->lookupText(textp, index);
}
+
+ uint16 languageSplitter = 0;
+ Common::String splitText = g_sci->strSplitLanguage(text.c_str(), &languageSplitter);
- return g_sci->_gfxPaint16->kernelDisplay(g_sci->strSplit(text.c_str()).c_str(), argc, argv);
+ return g_sci->_gfxPaint16->kernelDisplay(splitText.c_str(), languageSplitter, argc, argv);
}
reg_t kSetVideoMode(EngineState *s, int argc, reg_t *argv) {
diff --git a/engines/sci/engine/kstring.cpp b/engines/sci/engine/kstring.cpp
index 56dad583e4..eef758a0d9 100644
--- a/engines/sci/engine/kstring.cpp
+++ b/engines/sci/engine/kstring.cpp
@@ -42,10 +42,12 @@ reg_t kStrCat(EngineState *s, int argc, reg_t *argv) {
Common::String s1 = s->_segMan->getString(argv[0]);
Common::String s2 = s->_segMan->getString(argv[1]);
- // The Japanese version of PQ2 splits the two strings here
- // (check bug #3396887).
- if (g_sci->getGameId() == GID_PQ2 &&
- g_sci->getLanguage() == Common::JA_JPN) {
+ // Japanese PC-9801 interpreter splits strings here
+ // see bug #5834
+ // Verified for Police Quest 2 + Quest For Glory 1
+ // However Space Quest 4 PC-9801 doesn't
+ if ((g_sci->getLanguage() == Common::JA_JPN)
+ && (getSciVersion() <= SCI_VERSION_01)) {
s1 = g_sci->strSplit(s1.c_str(), NULL);
s2 = g_sci->strSplit(s2.c_str(), NULL);
}
diff --git a/engines/sci/engine/savegame.cpp b/engines/sci/engine/savegame.cpp
index cdcdcc41e5..0b55425406 100644
--- a/engines/sci/engine/savegame.cpp
+++ b/engines/sci/engine/savegame.cpp
@@ -640,9 +640,11 @@ void SoundCommandParser::reconstructPlayList() {
initSoundResource(*i);
if ((*i)->status == kSoundPlaying) {
- // Sync the sound object's selectors related to playing with the stored
- // ones in the playlist, as they may have been invalidated when loading.
- // Refer to bug #3104624.
+ // WORKAROUND: PQ3 (German?) scripts can set volume negative in the
+ // sound object directly without going through DoSound.
+ // Since we re-read this selector when re-playing the sound after loading,
+ // this will lead to unexpected behaviour. As a workaround we
+ // sync the sound object's selectors here. (See bug #5501)
writeSelectorValue(_segMan, (*i)->soundObj, SELECTOR(loop), (*i)->loop);
writeSelectorValue(_segMan, (*i)->soundObj, SELECTOR(priority), (*i)->priority);
if (_soundVersion >= SCI_VERSION_1_EARLY)
@@ -844,6 +846,8 @@ bool gamestate_save(EngineState *s, Common::WriteStream *fh, const Common::Strin
if (voc)
voc->saveLoadWithSerializer(ser);
+ // TODO: SSCI (at least JonesCD, presumably more) also stores the Menu state
+
return true;
}
diff --git a/engines/sci/engine/script_patches.cpp b/engines/sci/engine/script_patches.cpp
index 8bbbd713a6..03cd1d06e9 100644
--- a/engines/sci/engine/script_patches.cpp
+++ b/engines/sci/engine/script_patches.cpp
@@ -1214,6 +1214,26 @@ static const uint16 kq6CDPatchAudioTextSupportGirlInTheTower[] = {
PATCH_END
};
+// Fixes dual mode for scenes with Azure and Ariel (room 370)
+// Effectively same patch as the one for fixing "Girl In The Tower"
+// Applies to at least: PC-CD
+// Patched methods: rm370::init, caughtAtGateCD::changeState, caughtAtGateTXT::changeState, toLabyrinth::changeState
+// Fixes bug: #6750
+static const uint16 kq6CDSignatureAudioTextSupportAzureAriel[] = {
+ SIG_MAGICDWORD,
+ 0x89, 0x5a, // lsg global[5a]
+ 0x35, 0x02, // ldi 02
+ 0x1a, // eq?
+ 0x31, // bnt [jump-for-text-code]
+ SIG_END
+};
+
+static const uint16 kq6CDPatchAudioTextSupportAzureAriel[] = {
+ PATCH_ADDTOOFFSET(+4),
+ 0x12, // and
+ PATCH_END
+};
+
// Additional patch specifically for King's Quest 6
// Adds another button state for the text/audio button. We currently use the "speech" view for "dual" mode.
// View 947, loop 9, cel 0+1 -> "text"
@@ -1306,6 +1326,7 @@ static const SciScriptPatcherEntry kq6Signatures[] = {
{ false, 1009, "CD: audio + text support KQ6 Guards", 2, kq6CDSignatureAudioTextSupportGuards, kq6CDPatchAudioTextSupportGuards },
{ false, 1027, "CD: audio + text support KQ6 Stepmother", 1, kq6CDSignatureAudioTextSupportStepmother, kq6CDPatchAudioTextSupportJumpAlways },
{ false, 740, "CD: audio + text support KQ6 Girl In The Tower", 1, kq6CDSignatureAudioTextSupportGirlInTheTower, kq6CDPatchAudioTextSupportGirlInTheTower },
+ { false, 370, "CD: audio + text support KQ6 Azure & Ariel", 6, kq6CDSignatureAudioTextSupportAzureAriel, kq6CDPatchAudioTextSupportAzureAriel },
{ false, 903, "CD: audio + text support KQ6 menu", 1, kq6CDSignatureAudioTextMenuSupport, kq6CDPatchAudioTextMenuSupport },
SCI_SIGNATUREENTRY_TERMINATOR
};
@@ -1917,6 +1938,43 @@ static const SciScriptPatcherEntry pq1vgaSignatures[] = {
};
// ===========================================================================
+// At the healer's house there is a bird's nest up on the tree.
+// The player can throw rocks at it until it falls to the ground.
+// The hero will then grab the item, that is in the nest.
+//
+// When running is active, the hero will not reach the actual destination
+// and because of that, the game will get stuck.
+//
+// We just change the coordinate of the destination slightly, so that walking,
+// sneaking and running work.
+//
+// This bug was fixed by Sierra at least in the Japanese PC-9801 version.
+// Applies to at least: English floppy (1.000, 1.012)
+// Responsible method: pickItUp::changeState (script 54)
+// Fixes bug: #6407
+static const uint16 qfg1egaSignatureThrowRockAtNest[] = {
+ 0x4a, 0x04, // send 04 (nest::x)
+ 0x36, // push
+ SIG_MAGICDWORD,
+ 0x35, 0x0f, // ldi 0f (15d)
+ 0x02, // add
+ 0x36, // push
+ SIG_END
+};
+
+static const uint16 qfg1egaPatchThrowRockAtNest[] = {
+ PATCH_ADDTOOFFSET(+3),
+ 0x35, 0x12, // ldi 12 (18d)
+ PATCH_END
+};
+
+// script, description, signature patch
+static const SciScriptPatcherEntry qfg1egaSignatures[] = {
+ { true, 54, "throw rock at nest while running", 1, qfg1egaSignatureThrowRockAtNest, qfg1egaPatchThrowRockAtNest },
+ SCI_SIGNATUREENTRY_TERMINATOR
+};
+
+// ===========================================================================
// script 215 of qfg1vga pointBox::doit actually processes button-presses
// during fighting with monsters. It strangely also calls kGetEvent. Because
// the main User::doit also calls kGetEvent it's pure luck, where the event
@@ -3036,6 +3094,9 @@ void ScriptPatcher::processScript(uint16 scriptNr, byte *scriptData, const uint3
case GID_PQ1:
signatureTable = pq1vgaSignatures;
break;
+ case GID_QFG1:
+ signatureTable = qfg1egaSignatures;
+ break;
case GID_QFG1VGA:
signatureTable = qfg1vgaSignatures;
break;
diff --git a/engines/sci/engine/script_patches.h b/engines/sci/engine/script_patches.h
index 0b35792949..7023ef327e 100644
--- a/engines/sci/engine/script_patches.h
+++ b/engines/sci/engine/script_patches.h
@@ -98,7 +98,7 @@ private:
void enablePatch(const SciScriptPatcherEntry *patchTable, const char *searchDescription);
int32 findSignature(const SciScriptPatcherEntry *patchEntry, SciScriptPatcherRuntimeEntry *runtimeEntry, const byte *scriptData, const uint32 scriptSize, bool isMacSci11);
void applyPatch(const SciScriptPatcherEntry *patchEntry, byte *scriptData, const uint32 scriptSize, int32 signatureOffset, bool isMacSci11);
-
+
Selector *_selectorIdTable;
SciScriptPatcherRuntimeEntry *_runtimeTable;
};
diff --git a/engines/sci/engine/state.cpp b/engines/sci/engine/state.cpp
index 7701822f6d..527c8f0ae0 100644
--- a/engines/sci/engine/state.cpp
+++ b/engines/sci/engine/state.cpp
@@ -203,59 +203,94 @@ static kLanguage charToLanguage(const char c) {
}
}
-Common::String SciEngine::getSciLanguageString(const Common::String &str, kLanguage lang, kLanguage *lang2) const {
- kLanguage secondLang = K_LANG_NONE;
-
- const char *seeker = str.c_str();
- while (*seeker) {
- if ((*seeker == '%') || (*seeker == '#')) {
- secondLang = charToLanguage(*(seeker + 1));
-
- if (secondLang != K_LANG_NONE)
+Common::String SciEngine::getSciLanguageString(const Common::String &str, kLanguage requestedLanguage, kLanguage *secondaryLanguage, uint16 *languageSplitter) const {
+ kLanguage foundLanguage = K_LANG_NONE;
+ const byte *textPtr = (const byte *)str.c_str();
+ byte curChar = 0;
+ byte curChar2 = 0;
+
+ while (1) {
+ curChar = *textPtr;
+ if (!curChar)
+ break;
+
+ if ((curChar == '%') || (curChar == '#')) {
+ curChar2 = *(textPtr + 1);
+ foundLanguage = charToLanguage(curChar2);
+
+ if (foundLanguage != K_LANG_NONE) {
+ // Return language splitter
+ if (languageSplitter)
+ *languageSplitter = curChar | ( curChar2 << 8 );
+ // Return the secondary language found in the string
+ if (secondaryLanguage)
+ *secondaryLanguage = foundLanguage;
break;
+ }
}
-
- ++seeker;
+ textPtr++;
}
- // Return the secondary language found in the string
- if (lang2)
- *lang2 = secondLang;
-
- if (secondLang == lang) {
- if (*(++seeker) == 'J') {
+ if (foundLanguage == requestedLanguage) {
+ if (curChar2 == 'J') {
// Japanese including Kanji, displayed with system font
// Convert half-width characters to full-width equivalents
Common::String fullWidth;
- byte c;
+ uint16 mappedChar;
+
+ textPtr += 2; // skip over language splitter
+
+ while (1) {
+ curChar = *textPtr;
+
+ switch (curChar) {
+ case 0: // Terminator NUL
+ return fullWidth;
+ case '\\':
+ // "\n", "\N", "\r" and "\R" were overwritten with SPACE + 0x0D in PC-9801 SSCI
+ // inside GetLongest() (text16). We do it here, because it's much cleaner and
+ // we have to process the text here anyway.
+ // Occurs for example in Police Quest 2 intro
+ curChar2 = *(textPtr + 1);
+ switch (curChar2) {
+ case 'n':
+ case 'N':
+ case 'r':
+ case 'R':
+ fullWidth += ' ';
+ fullWidth += 0x0D; // CR
+ textPtr += 2;
+ continue;
+ }
+ }
+
+ textPtr++;
- while ((c = *(++seeker))) {
- uint16 mappedChar = s_halfWidthSJISMap[c];
+ mappedChar = s_halfWidthSJISMap[curChar];
if (mappedChar) {
fullWidth += mappedChar >> 8;
fullWidth += mappedChar & 0xFF;
} else {
// Copy double-byte character
- char c2 = *(++seeker);
- if (!c2) {
- error("SJIS character %02X is missing second byte", c);
+ curChar2 = *(textPtr++);
+ if (!curChar) {
+ error("SJIS character %02X is missing second byte", curChar);
break;
}
- fullWidth += c;
- fullWidth += c2;
+ fullWidth += curChar;
+ fullWidth += curChar2;
}
}
- return fullWidth;
} else {
- return Common::String(seeker + 1);
+ return Common::String((const char *)(textPtr + 2));
}
}
- if (*seeker)
- return Common::String(str.c_str(), seeker - str.c_str());
- else
- return str;
+ if (curChar)
+ return Common::String(str.c_str(), (const char *)textPtr - str.c_str());
+
+ return str;
}
kLanguage SciEngine::getSciLanguage() {
@@ -314,25 +349,25 @@ void SciEngine::setSciLanguage() {
setSciLanguage(getSciLanguage());
}
-Common::String SciEngine::strSplit(const char *str, const char *sep) {
- kLanguage lang = getSciLanguage();
- kLanguage subLang = K_LANG_NONE;
+Common::String SciEngine::strSplitLanguage(const char *str, uint16 *languageSplitter, const char *sep) {
+ kLanguage activeLanguage = getSciLanguage();
+ kLanguage subtitleLanguage = K_LANG_NONE;
if (SELECTOR(subtitleLang) != -1)
- subLang = (kLanguage)readSelectorValue(_gamestate->_segMan, _gameObjectAddress, SELECTOR(subtitleLang));
+ subtitleLanguage = (kLanguage)readSelectorValue(_gamestate->_segMan, _gameObjectAddress, SELECTOR(subtitleLang));
- kLanguage secondLang;
- Common::String retval = getSciLanguageString(str, lang, &secondLang);
+ kLanguage foundLanguage;
+ Common::String retval = getSciLanguageString(str, activeLanguage, &foundLanguage, languageSplitter);
// Don't add subtitle when separator is not set, subtitle language is not set, or
// string contains only one language
- if ((sep == NULL) || (subLang == K_LANG_NONE) || (secondLang == K_LANG_NONE))
+ if ((sep == NULL) || (subtitleLanguage == K_LANG_NONE) || (foundLanguage == K_LANG_NONE))
return retval;
// Add subtitle, unless the subtitle language doesn't match the languages in the string
- if ((subLang == K_LANG_ENGLISH) || (subLang == secondLang)) {
+ if ((subtitleLanguage == K_LANG_ENGLISH) || (subtitleLanguage == foundLanguage)) {
retval += sep;
- retval += getSciLanguageString(str, subLang);
+ retval += getSciLanguageString(str, subtitleLanguage);
}
return retval;
diff --git a/engines/sci/engine/workarounds.cpp b/engines/sci/engine/workarounds.cpp
index ea4dc2fe71..c5730b5345 100644
--- a/engines/sci/engine/workarounds.cpp
+++ b/engines/sci/engine/workarounds.cpp
@@ -91,7 +91,8 @@ const SciWorkaroundEntry uninitializedReadWorkarounds[] = {
{ GID_HOYLE4, 700, -1, 1, "BridgeDefense", "think", -1, -1, { WORKAROUND_FAKE, 0 } }, // sometimes while playing bridge, temp var 3, 17 and others, objects LeadReturn_Trump, ThirdSeat_Trump and others
{ GID_HOYLE4, 700, 730, 1, "BridgeDefense", "beatTheirBest", -1, 3, { WORKAROUND_FAKE, 0 } }, // rarely while playing bridge
{ GID_HOYLE4, 700, -1, 1, "Code", "doit", -1, -1, { WORKAROUND_FAKE, 0 } }, // when placing a bid in bridge (always), temp var 11, 24, 27, 46, 75, objects compete_tree, compwe_tree, other1_tree, b1 - bugs #5663 and #5794
- { GID_HOYLE4, 700, 921, 0, "Print", "addEdit", -1, -1, { WORKAROUND_FAKE, 0 } }, // when saving the game (may also occur in other situations) - bug #6601
+ { GID_HOYLE4, 700, 921, 0, "Print", "addEdit", -1, 0, { WORKAROUND_FAKE, 118 } }, // when saving the game (may also occur in other situations) - bug #6601, bug #6614
+ { GID_HOYLE4, 700, 921, 0, "Print", "addEdit", -1, 1, { WORKAROUND_FAKE, 1 } }, // see above, Text-control saves its coordinates to temp[0] and temp[1], Edit-control adjusts to those uninitialized temps, who by accident were left over from the Text-control
{ GID_HOYLE4, 300, 300, 0, "", "export 2", 0x1d4d, 0, { WORKAROUND_FAKE, 0 } }, // after passing around cards in hearts
{ GID_HOYLE4, 400, 400, 1, "GinHand", "calcRuns", -1, 4, { WORKAROUND_FAKE, 0 } }, // sometimes while playing Gin Rummy (e.g. when knocking and placing a card) - bug #5665
{ GID_HOYLE4, 500, 17, 1, "Character", "say", -1, 504, { WORKAROUND_FAKE, 0 } }, // sometimes while playing Cribbage (e.g. when the opponent says "Last Card") - bug #5662
diff --git a/engines/sci/event.cpp b/engines/sci/event.cpp
index 511d2014bd..b1c002413d 100644
--- a/engines/sci/event.cpp
+++ b/engines/sci/event.cpp
@@ -262,7 +262,7 @@ SciEvent EventManager::getScummVMEvent() {
// Scancodify if appropriate
if (modifiers & Common::KBD_ALT)
input.character = altify(input.character);
- else if ((modifiers & Common::KBD_CTRL) && input.character > 0 && input.character < 27)
+ if (getSciVersion() <= SCI_VERSION_1_MIDDLE && (modifiers & Common::KBD_CTRL) && input.character > 0 && input.character < 27)
input.character += 96; // 0x01 -> 'a'
// If no actual key was pressed (e.g. if only a modifier key was pressed),
diff --git a/engines/sci/graphics/controls16.cpp b/engines/sci/graphics/controls16.cpp
index f2b2ccdfe6..e2e250cf9d 100644
--- a/engines/sci/graphics/controls16.cpp
+++ b/engines/sci/graphics/controls16.cpp
@@ -280,7 +280,7 @@ int GfxControls16::getPicNotValid() {
return _screen->_picNotValid;
}
-void GfxControls16::kernelDrawButton(Common::Rect rect, reg_t obj, const char *text, int16 fontId, int16 style, bool hilite) {
+void GfxControls16::kernelDrawButton(Common::Rect rect, reg_t obj, const char *text, uint16 languageSplitter, int16 fontId, int16 style, bool hilite) {
int16 sci0EarlyPen = 0, sci0EarlyBack = 0;
if (!hilite) {
if (getSciVersion() == SCI_VERSION_0_EARLY) {
@@ -295,7 +295,7 @@ void GfxControls16::kernelDrawButton(Common::Rect rect, reg_t obj, const char *t
_paint16->frameRect(rect);
rect.grow(-2);
_ports->textGreyedOutput(!(style & SCI_CONTROLS_STYLE_ENABLED));
- _text16->Box(text, false, rect, SCI_TEXT16_ALIGNMENT_CENTER, fontId);
+ _text16->Box(text, languageSplitter, false, rect, SCI_TEXT16_ALIGNMENT_CENTER, fontId);
_ports->textGreyedOutput(false);
rect.grow(1);
if (style & SCI_CONTROLS_STYLE_SELECTED)
@@ -318,12 +318,12 @@ void GfxControls16::kernelDrawButton(Common::Rect rect, reg_t obj, const char *t
}
}
-void GfxControls16::kernelDrawText(Common::Rect rect, reg_t obj, const char *text, int16 fontId, TextAlignment alignment, int16 style, bool hilite) {
+void GfxControls16::kernelDrawText(Common::Rect rect, reg_t obj, const char *text, uint16 languageSplitter, int16 fontId, TextAlignment alignment, int16 style, bool hilite) {
if (!hilite) {
rect.grow(1);
_paint16->eraseRect(rect);
rect.grow(-1);
- _text16->Box(text, false, rect, alignment, fontId);
+ _text16->Box(text, languageSplitter, false, rect, alignment, fontId);
if (style & SCI_CONTROLS_STYLE_SELECTED) {
_paint16->frameRect(rect);
}
@@ -335,7 +335,7 @@ void GfxControls16::kernelDrawText(Common::Rect rect, reg_t obj, const char *tex
}
}
-void GfxControls16::kernelDrawTextEdit(Common::Rect rect, reg_t obj, const char *text, int16 fontId, int16 mode, int16 style, int16 cursorPos, int16 maxChars, bool hilite) {
+void GfxControls16::kernelDrawTextEdit(Common::Rect rect, reg_t obj, const char *text, uint16 languageSplitter, int16 fontId, int16 mode, int16 style, int16 cursorPos, int16 maxChars, bool hilite) {
Common::Rect textRect = rect;
uint16 oldFontId = _text16->GetFontId();
@@ -343,7 +343,7 @@ void GfxControls16::kernelDrawTextEdit(Common::Rect rect, reg_t obj, const char
_texteditCursorVisible = false;
texteditCursorErase();
_paint16->eraseRect(rect);
- _text16->Box(text, false, textRect, SCI_TEXT16_ALIGNMENT_LEFT, fontId);
+ _text16->Box(text, languageSplitter, false, textRect, SCI_TEXT16_ALIGNMENT_LEFT, fontId);
_paint16->frameRect(rect);
if (style & SCI_CONTROLS_STYLE_SELECTED) {
_text16->SetFont(fontId);
diff --git a/engines/sci/graphics/controls16.h b/engines/sci/graphics/controls16.h
index 6a70c71aae..39ffa243fb 100644
--- a/engines/sci/graphics/controls16.h
+++ b/engines/sci/graphics/controls16.h
@@ -55,9 +55,9 @@ public:
GfxControls16(SegManager *segMan, GfxPorts *ports, GfxPaint16 *paint16, GfxText16 *text16, GfxScreen *screen);
~GfxControls16();
- void kernelDrawButton(Common::Rect rect, reg_t obj, const char *text, int16 fontId, int16 style, bool hilite);
- void kernelDrawText(Common::Rect rect, reg_t obj, const char *text, int16 fontId, int16 alignment, int16 style, bool hilite);
- void kernelDrawTextEdit(Common::Rect rect, reg_t obj, const char *text, int16 fontId, int16 mode, int16 style, int16 cursorPos, int16 maxChars, bool hilite);
+ void kernelDrawButton(Common::Rect rect, reg_t obj, const char *text, uint16 languageSplitter, int16 fontId, int16 style, bool hilite);
+ void kernelDrawText(Common::Rect rect, reg_t obj, const char *text, uint16 languageSplitter, int16 fontId, int16 alignment, int16 style, bool hilite);
+ void kernelDrawTextEdit(Common::Rect rect, reg_t obj, const char *text, uint16 languageSplitter, int16 fontId, int16 mode, int16 style, int16 cursorPos, int16 maxChars, bool hilite);
void kernelDrawIcon(Common::Rect rect, reg_t obj, GuiResourceId viewId, int16 loopNo, int16 celNo, int16 priority, int16 style, bool hilite);
void kernelDrawList(Common::Rect rect, reg_t obj, int16 maxChars, int16 count, const char **entries, GuiResourceId fontId, int16 style, int16 upperPos, int16 cursorPos, bool isAlias, bool hilite);
void kernelTexteditChange(reg_t controlObject, reg_t eventObject);
diff --git a/engines/sci/graphics/cursor.cpp b/engines/sci/graphics/cursor.cpp
index 048ec1e9b9..1a58de073c 100644
--- a/engines/sci/graphics/cursor.cpp
+++ b/engines/sci/graphics/cursor.cpp
@@ -47,7 +47,7 @@ GfxCursor::GfxCursor(ResourceManager *resMan, GfxPalette *palette, GfxScreen *sc
_isVisible = true;
// center mouse cursor
- setPosition(Common::Point(_screen->getWidth() / 2, _screen->getHeight() / 2));
+ setPosition(Common::Point(_screen->getScriptWidth() / 2, _screen->getScriptHeight() / 2));
_moveZoneActive = false;
_zoomZoneActive = false;
@@ -151,14 +151,14 @@ void GfxCursor::kernelSetShape(GuiResourceId resourceId) {
colorMapping[0] = 0; // Black is hardcoded
colorMapping[1] = _screen->getColorWhite(); // White is also hardcoded
colorMapping[2] = SCI_CURSOR_SCI0_TRANSPARENCYCOLOR;
- colorMapping[3] = _palette->matchColor(170, 170, 170); // Grey
+ colorMapping[3] = _palette->matchColor(170, 170, 170) & SCI_PALETTE_MATCH_COLORMASK; // Grey
// TODO: Figure out if the grey color is hardcoded
// HACK for the magnifier cursor in LB1, fixes its color (bug #3487092)
if (g_sci->getGameId() == GID_LAURABOW && resourceId == 1)
colorMapping[3] = _screen->getColorWhite();
// HACK for Longbow cursors, fixes the shade of grey they're using (bug #3489101)
if (g_sci->getGameId() == GID_LONGBOW)
- colorMapping[3] = _palette->matchColor(223, 223, 223); // Light Grey
+ colorMapping[3] = _palette->matchColor(223, 223, 223) & SCI_PALETTE_MATCH_COLORMASK; // Light Grey
// Seek to actual data
resourceData += 4;
@@ -481,7 +481,7 @@ void GfxCursor::kernelSetPos(Common::Point pos) {
void GfxCursor::kernelMoveCursor(Common::Point pos) {
_coordAdjuster->moveCursor(pos);
- if (pos.x > _screen->getWidth() || pos.y > _screen->getHeight()) {
+ if (pos.x > _screen->getScriptWidth() || pos.y > _screen->getScriptHeight()) {
warning("attempt to place cursor at invalid coordinates (%d, %d)", pos.y, pos.x);
return;
}
diff --git a/engines/sci/graphics/font.cpp b/engines/sci/graphics/font.cpp
index e4684ff134..2268ec0459 100644
--- a/engines/sci/graphics/font.cpp
+++ b/engines/sci/graphics/font.cpp
@@ -48,8 +48,8 @@ GfxFontFromResource::GfxFontFromResource(ResourceManager *resMan, GfxScreen *scr
// filling info for every char
for (int16 i = 0; i < _numChars; i++) {
_chars[i].offset = READ_SCI32ENDIAN_UINT16(_resourceData + 6 + i * 2);
- _chars[i].w = _resourceData[_chars[i].offset];
- _chars[i].h = _resourceData[_chars[i].offset + 1];
+ _chars[i].width = _resourceData[_chars[i].offset];
+ _chars[i].height = _resourceData[_chars[i].offset + 1];
}
}
@@ -66,10 +66,10 @@ byte GfxFontFromResource::getHeight() {
return _fontHeight;
}
byte GfxFontFromResource::getCharWidth(uint16 chr) {
- return chr < _numChars ? _chars[chr].w : 0;
+ return chr < _numChars ? _chars[chr].width : 0;
}
byte GfxFontFromResource::getCharHeight(uint16 chr) {
- return chr < _numChars ? _chars[chr].h : 0;
+ return chr < _numChars ? _chars[chr].height : 0;
}
byte *GfxFontFromResource::getCharData(uint16 chr) {
return chr < _numChars ? _resourceData + _chars[chr].offset + 2 : 0;
diff --git a/engines/sci/graphics/font.h b/engines/sci/graphics/font.h
index 58b2ba4813..451261f315 100644
--- a/engines/sci/graphics/font.h
+++ b/engines/sci/graphics/font.h
@@ -71,9 +71,11 @@ private:
byte *_resourceData;
struct Charinfo {
- byte w, h;
+ byte width;
+ byte height;
int16 offset;
};
+
byte _fontHeight;
uint16 _numChars;
Charinfo *_chars;
diff --git a/engines/sci/graphics/frameout.cpp b/engines/sci/graphics/frameout.cpp
index 91b5b25e99..ccc362dc37 100644
--- a/engines/sci/graphics/frameout.cpp
+++ b/engines/sci/graphics/frameout.cpp
@@ -524,6 +524,10 @@ void GfxFrameout::showVideo() {
RobotDecoder *videoDecoder = g_sci->_robotDecoder;
uint16 x = videoDecoder->getPos().x;
uint16 y = videoDecoder->getPos().y;
+ uint16 screenWidth = _screen->getWidth();
+ uint16 screenHeight = _screen->getHeight();
+ uint16 outputWidth;
+ uint16 outputHeight;
if (videoDecoder->hasDirtyPalette())
g_system->getPaletteManager()->setPalette(videoDecoder->getPalette(), 0, 256);
@@ -532,7 +536,11 @@ void GfxFrameout::showVideo() {
if (videoDecoder->needsUpdate()) {
const Graphics::Surface *frame = videoDecoder->decodeNextFrame();
if (frame) {
- g_system->copyRectToScreen(frame->getPixels(), frame->pitch, x, y, frame->w, frame->h);
+ // We need to clip here
+ // At least Phantasmagoria shows a 640x390 video on a 630x450 screen during the intro
+ outputWidth = frame->w > screenWidth ? screenWidth : frame->w;
+ outputHeight = frame->h > screenHeight ? screenHeight : frame->h;
+ g_system->copyRectToScreen(frame->getPixels(), frame->pitch, x, y, outputWidth, outputHeight);
if (videoDecoder->hasDirtyPalette())
g_system->getPaletteManager()->setPalette(videoDecoder->getPalette(), 0, 256);
@@ -784,13 +792,10 @@ void GfxFrameout::kernelFrameout() {
// swapped in the GK1 inventory screen, investigate why.
// This is also needed for GK1 rooms 710 and 720 (catacombs, inner and
// outer circle), for handling the tiles and talking to Wolfgang.
- // HACK: Fix the coordinates by explicitly setting them here.
- Common::Rect objNSRect = g_sci->_gfxCompare->getNSRect(itemEntry->object);
- uint16 roomNumber = g_sci->getEngineState()->currentRoomNumber();
- if (objNSRect.top == nsRect.left && objNSRect.left == nsRect.top && nsRect.top != 0 && nsRect.left != 0 ||
- (g_sci->getGameId() == GID_GK1 && (roomNumber == 710 || roomNumber == 720))) {
+ // HACK: Fix the coordinates by explicitly setting them here for GK1.
+ // Also check bug #6729, for another case where this is needed.
+ if (g_sci->getGameId() == GID_GK1)
g_sci->_gfxCompare->setNSRect(itemEntry->object, nsRect);
- }
}
// Don't attempt to draw sprites that are outside the visible
diff --git a/engines/sci/graphics/paint16.cpp b/engines/sci/graphics/paint16.cpp
index b835eb92ca..f80703e14d 100644
--- a/engines/sci/graphics/paint16.cpp
+++ b/engines/sci/graphics/paint16.cpp
@@ -476,7 +476,7 @@ void GfxPaint16::kernelGraphRedrawBox(Common::Rect rect) {
#define SCI_DISPLAY_DUMMY3 117
#define SCI_DISPLAY_DONTSHOWBITS 121
-reg_t GfxPaint16::kernelDisplay(const char *text, int argc, reg_t *argv) {
+reg_t GfxPaint16::kernelDisplay(const char *text, uint16 languageSplitter, int argc, reg_t *argv) {
reg_t displayArg;
TextAlignment alignment = SCI_TEXT16_ALIGNMENT_LEFT;
int16 colorPen = -1, colorBack = -1, width = -1, bRedraw = 1;
@@ -572,7 +572,7 @@ reg_t GfxPaint16::kernelDisplay(const char *text, int argc, reg_t *argv) {
}
// now drawing the text
- _text16->Size(rect, text, -1, width);
+ _text16->Size(rect, text, languageSplitter, -1, width);
rect.moveTo(_ports->getPort()->curLeft, _ports->getPort()->curTop);
// Note: This code has been found in SCI1 middle and newer games. It was
// previously only for SCI1 late and newer, but the LSL1 interpreter contains
@@ -588,7 +588,7 @@ reg_t GfxPaint16::kernelDisplay(const char *text, int argc, reg_t *argv) {
result = bitsSave(rect, GFX_SCREEN_MASK_VISUAL);
if (colorBack != -1)
fillRect(rect, GFX_SCREEN_MASK_VISUAL, colorBack, 0, 0);
- _text16->Box(text, false, rect, alignment, -1);
+ _text16->Box(text, languageSplitter, false, rect, alignment, -1);
if (_screen->_picNotValid == 0 && bRedraw)
bitsShow(rect);
// restoring port and cursor pos
diff --git a/engines/sci/graphics/paint16.h b/engines/sci/graphics/paint16.h
index 882f311a5b..955cfdec8f 100644
--- a/engines/sci/graphics/paint16.h
+++ b/engines/sci/graphics/paint16.h
@@ -80,7 +80,7 @@ public:
void kernelGraphUpdateBox(const Common::Rect &rect, bool hiresMode);
void kernelGraphRedrawBox(Common::Rect rect);
- reg_t kernelDisplay(const char *text, int argc, reg_t *argv);
+ reg_t kernelDisplay(const char *text, uint16 languageSplitter, int argc, reg_t *argv);
reg_t kernelPortraitLoad(const Common::String &resourceName);
void kernelPortraitShow(const Common::String &resourceName, Common::Point position, uint16 resourceNum, uint16 noun, uint16 verb, uint16 cond, uint16 seq);
diff --git a/engines/sci/graphics/paint32.cpp b/engines/sci/graphics/paint32.cpp
index 7d106b5b02..a210a469f1 100644
--- a/engines/sci/graphics/paint32.cpp
+++ b/engines/sci/graphics/paint32.cpp
@@ -46,7 +46,7 @@ void GfxPaint32::fillRect(Common::Rect rect, byte color) {
Common::Rect clipRect = rect;
clipRect.clip(_screen->getWidth(), _screen->getHeight());
-
+
for (y = clipRect.top; y < clipRect.bottom; y++) {
for (x = clipRect.left; x < clipRect.right; x++) {
_screen->putPixel(x, y, GFX_SCREEN_MASK_VISUAL, color, 0, 0);
diff --git a/engines/sci/graphics/palette.cpp b/engines/sci/graphics/palette.cpp
index a3624c7959..59abef5550 100644
--- a/engines/sci/graphics/palette.cpp
+++ b/engines/sci/graphics/palette.cpp
@@ -65,14 +65,21 @@ GfxPalette::GfxPalette(ResourceManager *resMan, GfxScreen *screen)
// the real merging done in earlier games. If we use the copying over, we
// will get issues because some views have marked all colors as being used
// and those will overwrite the current palette in that case
- if (getSciVersion() < SCI_VERSION_1_1)
+ if (getSciVersion() < SCI_VERSION_1_1) {
_useMerging = true;
- else if (getSciVersion() == SCI_VERSION_1_1)
+ _use16bitColorMatch = true;
+ } else if (getSciVersion() == SCI_VERSION_1_1) {
// there are some games that use inbetween SCI1.1 interpreter, so we have
// to detect if the current game is merging or copying
_useMerging = _resMan->detectPaletteMergingSci11();
- else // SCI32
+ _use16bitColorMatch = _useMerging;
+ // Note: Laura Bow 2 floppy uses the new palette format and is detected
+ // as 8 bit color matching because of that.
+ } else {
+ // SCI32
_useMerging = false;
+ _use16bitColorMatch = false; // not verified that SCI32 uses 8-bit color matching
+ }
palVaryInit();
@@ -120,6 +127,10 @@ bool GfxPalette::isMerging() {
return _useMerging;
}
+bool GfxPalette::isUsing16bitColorMatch() {
+ return _use16bitColorMatch;
+}
+
// meant to get called only once during init of engine
void GfxPalette::setDefault() {
if (_resMan->getViewType() == kViewEga)
@@ -464,8 +475,8 @@ bool GfxPalette::merge(Palette *newPalette, bool force, bool forceRealMerge) {
// check if exact color could be matched
res = matchColor(newPalette->colors[i].r, newPalette->colors[i].g, newPalette->colors[i].b);
- if (res & 0x8000) { // exact match was found
- newPalette->mapping[i] = res & 0xFF;
+ if (res & SCI_PALETTE_MATCH_PERFECT) { // exact match was found
+ newPalette->mapping[i] = res & SCI_PALETTE_MATCH_COLORMASK;
continue;
}
@@ -486,8 +497,8 @@ bool GfxPalette::merge(Palette *newPalette, bool force, bool forceRealMerge) {
// if still no luck - set an approximate color
if (j == 256) {
- newPalette->mapping[i] = res & 0xFF;
- _sysPalette.colors[res & 0xFF].used |= 0x10;
+ newPalette->mapping[i] = res & SCI_PALETTE_MATCH_COLORMASK;
+ _sysPalette.colors[res & SCI_PALETTE_MATCH_COLORMASK].used |= 0x10;
}
}
@@ -509,29 +520,47 @@ void GfxPalette::drewPicture(GuiResourceId pictureId) {
}
}
-uint16 GfxPalette::matchColor(byte r, byte g, byte b) {
- byte found = 0xFF;
- int diff = 0x2FFFF, cdiff;
- int16 dr,dg,db;
-
- for (int i = 1; i < 255; i++) {
- if ((!_sysPalette.colors[i].used))
- continue;
- dr = _sysPalette.colors[i].r - r;
- dg = _sysPalette.colors[i].g - g;
- db = _sysPalette.colors[i].b - b;
-// minimum squares match
- cdiff = (dr*dr) + (dg*dg) + (db*db);
-// minimum sum match (Sierra's)
-// cdiff = ABS(dr) + ABS(dg) + ABS(db);
- if (cdiff < diff) {
- if (cdiff == 0)
- return i | 0x8000; // setting this flag to indicate exact match
- found = i;
- diff = cdiff;
+uint16 GfxPalette::matchColor(byte matchRed, byte matchGreen, byte matchBlue) {
+ int16 colorNr;
+ int16 differenceRed, differenceGreen, differenceBlue;
+ int16 differenceTotal = 0;
+ int16 bestDifference = 0x7FFF;
+ uint16 bestColorNr = 255;
+
+ if (_use16bitColorMatch) {
+ // used by SCI0 to SCI1, also by the first few SCI1.1 games
+ for (colorNr = 0; colorNr < 256; colorNr++) {
+ if ((!_sysPalette.colors[colorNr].used))
+ continue;
+ differenceRed = ABS(_sysPalette.colors[colorNr].r - matchRed);
+ differenceGreen = ABS(_sysPalette.colors[colorNr].g - matchGreen);
+ differenceBlue = ABS(_sysPalette.colors[colorNr].b - matchBlue);
+ differenceTotal = differenceRed + differenceGreen + differenceBlue;
+ if (differenceTotal <= bestDifference) {
+ bestDifference = differenceTotal;
+ bestColorNr = colorNr;
+ }
+ }
+ } else {
+ // SCI1.1, starting with QfG3 introduced a bug in the matching code
+ // we have to implement it as well, otherwise some colors will be "wrong" in comparison to the original interpreter
+ // See Space Quest 5 bug #6455
+ for (colorNr = 0; colorNr < 256; colorNr++) {
+ if ((!_sysPalette.colors[colorNr].used))
+ continue;
+ differenceRed = (uint8)ABS<int8>(_sysPalette.colors[colorNr].r - matchRed);
+ differenceGreen = (uint8)ABS<int8>(_sysPalette.colors[colorNr].g - matchGreen);
+ differenceBlue = (uint8)ABS<int8>(_sysPalette.colors[colorNr].b - matchBlue);
+ differenceTotal = differenceRed + differenceGreen + differenceBlue;
+ if (differenceTotal <= bestDifference) {
+ bestDifference = differenceTotal;
+ bestColorNr = colorNr;
+ }
}
}
- return found;
+ if (differenceTotal == 0) // original interpreter does not do this, instead it does 2 calls for merges in the worst case
+ return bestColorNr | SCI_PALETTE_MATCH_PERFECT; // we set this flag, so that we can optimize during palette merge
+ return bestColorNr;
}
void GfxPalette::getSys(Palette *pal) {
@@ -621,7 +650,7 @@ void GfxPalette::kernelSetIntensity(uint16 fromColor, uint16 toColor, uint16 int
}
int16 GfxPalette::kernelFindColor(uint16 r, uint16 g, uint16 b) {
- return matchColor(r, g, b) & 0xFF;
+ return matchColor(r, g, b) & SCI_PALETTE_MATCH_COLORMASK;
}
// Returns true, if palette got changed
diff --git a/engines/sci/graphics/palette.h b/engines/sci/graphics/palette.h
index 347695deb8..500a45eccf 100644
--- a/engines/sci/graphics/palette.h
+++ b/engines/sci/graphics/palette.h
@@ -31,6 +31,10 @@ namespace Sci {
class ResourceManager;
class GfxScreen;
+// Special flag implemented by us for optimization in palette merge
+#define SCI_PALETTE_MATCH_PERFECT 0x8000
+#define SCI_PALETTE_MATCH_COLORMASK 0xFF
+
enum ColorRemappingType {
kRemappingNone = 0,
kRemappingByRange = 1,
@@ -46,6 +50,7 @@ public:
~GfxPalette();
bool isMerging();
+ bool isUsing16bitColorMatch();
void setDefault();
void createFromData(byte *data, int bytesLeft, Palette *paletteOut);
@@ -124,6 +129,7 @@ private:
bool _sysPaletteChanged;
bool _useMerging;
+ bool _use16bitColorMatch;
Common::Array<PalSchedule> _schedules;
diff --git a/engines/sci/graphics/picture.cpp b/engines/sci/graphics/picture.cpp
index 434a490109..d7ef84dc1e 100644
--- a/engines/sci/graphics/picture.cpp
+++ b/engines/sci/graphics/picture.cpp
@@ -88,10 +88,13 @@ void GfxPicture::draw(int16 animationNr, bool mirroredFlag, bool addToFlag, int1
}
void GfxPicture::reset() {
+ int16 startY = _ports->getPort()->top;
+ int16 startX = 0;
int16 x, y;
- for (y = _ports->getPort()->top; y < _screen->getHeight(); y++) {
- for (x = 0; x < _screen->getWidth(); x++) {
- _screen->putPixel(x, y, GFX_SCREEN_MASK_ALL, 255, 0, 0);
+ _screen->vectorAdjustCoordinate(&startX, &startY);
+ for (y = startY; y < _screen->getHeight(); y++) {
+ for (x = startX; x < _screen->getWidth(); x++) {
+ _screen->vectorPutPixel(x, y, GFX_SCREEN_MASK_ALL, 255, 0, 0);
}
}
}
@@ -246,7 +249,7 @@ void GfxPicture::drawCelData(byte *inbuffer, int size, int headerPos, int rlePos
int16 y, lastY, x, leftX, rightX;
int pixelCount;
uint16 width, height;
-
+
// if the picture is not an overlay and we are also not in EGA mode, use priority 0
if (!isEGA && !_addToFlag)
priority = 0;
@@ -362,7 +365,7 @@ void GfxPicture::drawCelData(byte *inbuffer, int size, int headerPos, int rlePos
ptr = celBitmap;
ptr += skipCelBitmapPixels;
ptr += skipCelBitmapLines * width;
-
+
if ((!isEGA) || (priority < 16)) {
// VGA + EGA, EGA only checks priority, when given priority is below 16
if (!_mirroredFlag) {
@@ -482,6 +485,8 @@ enum {
PIC_OPX_VGA_PRIORITY_TABLE_EXPLICIT = 4
};
+//#define DEBUG_PICTURE_DRAW 1
+
#ifdef DEBUG_PICTURE_DRAW
const char *picOpcodeNames[] = {
"Set color",
@@ -589,6 +594,9 @@ void GfxPicture::drawVectorData(byte *data, int dataSize) {
while (curPos < dataSize) {
#ifdef DEBUG_PICTURE_DRAW
debug("Picture op: %X (%s) at %d", data[curPos], picOpcodeNames[data[curPos] - 0xF0], curPos);
+ _screen->copyToScreen();
+ g_system->updateScreen();
+ g_system->delayMillis(400);
#endif
switch (pic_op = data[curPos++]) {
case PIC_OP_SET_COLOR:
@@ -934,17 +942,17 @@ void GfxPicture::vectorFloodFill(int16 x, int16 y, byte color, byte priority, by
Common::Point p, p1;
byte screenMask = _screen->getDrawingMask(color, priority, control);
byte matchedMask, matchMask;
- int16 w, e, a_set, b_set;
bool isEGA = (_resMan->getViewType() == kViewEga);
p.x = x + curPort->left;
p.y = y + curPort->top;
- stack.push(p);
- byte searchColor = _screen->getVisual(p.x, p.y);
- byte searchPriority = _screen->getPriority(p.x, p.y);
- byte searchControl = _screen->getControl(p.x, p.y);
+ _screen->vectorAdjustCoordinate(&p.x, &p.y);
+
+ byte searchColor = _screen->vectorGetVisual(p.x, p.y);
+ byte searchPriority = _screen->vectorGetPriority(p.x, p.y);
+ byte searchControl = _screen->vectorGetControl(p.x, p.y);
if (isEGA) {
// In EGA games a pixel in the framebuffer is only 4 bits. We store
@@ -991,22 +999,31 @@ void GfxPicture::vectorFloodFill(int16 x, int16 y, byte color, byte priority, by
}
// hard borders for filling
- int l = curPort->rect.left + curPort->left;
- int t = curPort->rect.top + curPort->top;
- int r = curPort->rect.right + curPort->left - 1;
- int b = curPort->rect.bottom + curPort->top - 1;
+ int16 borderLeft = curPort->rect.left + curPort->left;
+ int16 borderTop = curPort->rect.top + curPort->top;
+ int16 borderRight = curPort->rect.right + curPort->left - 1;
+ int16 borderBottom = curPort->rect.bottom + curPort->top - 1;
+ int16 curToLeft, curToRight, a_set, b_set;
+
+ // Translate coordinates, if required (needed for Macintosh 480x300)
+ _screen->vectorAdjustCoordinate(&borderLeft, &borderTop);
+ _screen->vectorAdjustCoordinate(&borderRight, &borderBottom);
+ //return;
+
+ stack.push(p);
+
while (stack.size()) {
p = stack.pop();
- if ((matchedMask = _screen->isFillMatch(p.x, p.y, matchMask, searchColor, searchPriority, searchControl, isEGA)) == 0) // already filled
+ if ((matchedMask = _screen->vectorIsFillMatch(p.x, p.y, matchMask, searchColor, searchPriority, searchControl, isEGA)) == 0) // already filled
continue;
- _screen->putPixel(p.x, p.y, screenMask, color, priority, control);
- w = p.x;
- e = p.x;
+ _screen->vectorPutPixel(p.x, p.y, screenMask, color, priority, control);
+ curToLeft = p.x;
+ curToRight = p.x;
// moving west and east pointers as long as there is a matching color to fill
- while (w > l && (matchedMask = _screen->isFillMatch(w - 1, p.y, matchMask, searchColor, searchPriority, searchControl, isEGA)))
- _screen->putPixel(--w, p.y, screenMask, color, priority, control);
- while (e < r && (matchedMask = _screen->isFillMatch(e + 1, p.y, matchMask, searchColor, searchPriority, searchControl, isEGA)))
- _screen->putPixel(++e, p.y, screenMask, color, priority, control);
+ while (curToLeft > borderLeft && (matchedMask = _screen->vectorIsFillMatch(curToLeft - 1, p.y, matchMask, searchColor, searchPriority, searchControl, isEGA)))
+ _screen->vectorPutPixel(--curToLeft, p.y, screenMask, color, priority, control);
+ while (curToRight < borderRight && (matchedMask = _screen->vectorIsFillMatch(curToRight + 1, p.y, matchMask, searchColor, searchPriority, searchControl, isEGA)))
+ _screen->vectorPutPixel(++curToRight, p.y, screenMask, color, priority, control);
#if 0
// debug code for floodfill
_screen->copyToScreen();
@@ -1015,10 +1032,10 @@ void GfxPicture::vectorFloodFill(int16 x, int16 y, byte color, byte priority, by
#endif
// checking lines above and below for possible flood targets
a_set = b_set = 0;
- while (w <= e) {
- if (p.y > t && (matchedMask = _screen->isFillMatch(w, p.y - 1, matchMask, searchColor, searchPriority, searchControl, isEGA))) { // one line above
+ while (curToLeft <= curToRight) {
+ if (p.y > borderTop && (matchedMask = _screen->vectorIsFillMatch(curToLeft, p.y - 1, matchMask, searchColor, searchPriority, searchControl, isEGA))) { // one line above
if (a_set == 0) {
- p1.x = w;
+ p1.x = curToLeft;
p1.y = p.y - 1;
stack.push(p1);
a_set = 1;
@@ -1026,16 +1043,16 @@ void GfxPicture::vectorFloodFill(int16 x, int16 y, byte color, byte priority, by
} else
a_set = 0;
- if (p.y < b && (matchedMask = _screen->isFillMatch(w, p.y + 1, matchMask, searchColor, searchPriority, searchControl, isEGA))) { // one line below
+ if (p.y < borderBottom && (matchedMask = _screen->vectorIsFillMatch(curToLeft, p.y + 1, matchMask, searchColor, searchPriority, searchControl, isEGA))) { // one line below
if (b_set == 0) {
- p1.x = w;
+ p1.x = curToLeft;
p1.y = p.y + 1;
stack.push(p1);
b_set = 1;
}
} else
b_set = 0;
- w++;
+ curToLeft++;
}
}
}
@@ -1173,7 +1190,7 @@ void GfxPicture::vectorPatternBox(Common::Rect box, byte color, byte prio, byte
for (y = box.top; y < box.bottom; y++) {
for (x = box.left; x < box.right; x++) {
- _screen->putPixel(x, y, flag, color, prio, control);
+ _screen->vectorPutPixel(x, y, flag, color, prio, control);
}
}
}
@@ -1186,7 +1203,7 @@ void GfxPicture::vectorPatternTexturedBox(Common::Rect box, byte color, byte pri
for (y = box.top; y < box.bottom; y++) {
for (x = box.left; x < box.right; x++) {
if (*textureData) {
- _screen->putPixel(x, y, flag, color, prio, control);
+ _screen->vectorPutPixel(x, y, flag, color, prio, control);
}
textureData++;
}
@@ -1203,7 +1220,7 @@ void GfxPicture::vectorPatternCircle(Common::Rect box, byte size, byte color, by
for (y = box.top; y < box.bottom; y++) {
for (x = box.left; x < box.right; x++) {
if (bitmap & 1) {
- _screen->putPixel(x, y, flag, color, prio, control);
+ _screen->vectorPutPixel(x, y, flag, color, prio, control);
}
bitNo++;
if (bitNo == 8) {
@@ -1222,12 +1239,12 @@ void GfxPicture::vectorPatternTexturedCircle(Common::Rect box, byte size, byte c
byte bitNo = 0;
const bool *textureData = &vectorPatternTextures[vectorPatternTextureOffset[texture]];
int y, x;
-
+
for (y = box.top; y < box.bottom; y++) {
for (x = box.left; x < box.right; x++) {
if (bitmap & 1) {
if (*textureData) {
- _screen->putPixel(x, y, flag, color, prio, control);
+ _screen->vectorPutPixel(x, y, flag, color, prio, control);
}
textureData++;
}
@@ -1252,7 +1269,10 @@ void GfxPicture::vectorPattern(int16 x, int16 y, byte color, byte priority, byte
rect.top = y; rect.left = x;
rect.setHeight((size*2)+1); rect.setWidth((size*2)+2);
_ports->offsetRect(rect);
- rect.clip(_screen->getWidth(), _screen->getHeight());
+ rect.clip(_screen->getScriptWidth(), _screen->getScriptHeight());
+
+ _screen->vectorAdjustCoordinate(&rect.left, &rect.top);
+ _screen->vectorAdjustCoordinate(&rect.right, &rect.bottom);
if (code & SCI_PATTERN_CODE_RECTANGLE) {
// Rectangle
diff --git a/engines/sci/graphics/portrait.cpp b/engines/sci/graphics/portrait.cpp
index 488450485d..3311f47022 100644
--- a/engines/sci/graphics/portrait.cpp
+++ b/engines/sci/graphics/portrait.cpp
@@ -57,13 +57,39 @@ void Portrait::init() {
// 4 bytes paletteSize (base 1)
// -> 17 bytes
// paletteSize bytes paletteData
- // 14 bytes bitmap header
- // -> 4 bytes unknown
- // -> 2 bytes height
- // -> 2 bytes width
- // -> 6 bytes unknown
- // height * width bitmap data
- // another animation count times bitmap header and data
+ //
+ // bitmap-data follows, total of [animation count]
+ // 14 bytes bitmap header
+ // -> 4 bytes unknown
+ // -> 2 bytes height
+ // -> 2 bytes width
+ // -> 6 bytes unknown
+ // height * width bitmap data
+ //
+ // 4 bytes offset table size (may be larger than the actual known entries?!)
+ // 14 bytes all zeroes (dummy entry?!)
+ //
+ // 14 bytes for each entry
+ // -> 2 bytes displace X
+ // -> 2 bytes displace Y
+ // -> 2 bytes height (again)
+ // -> 2 bytes width (again)
+ // -> 6 bytes unknown (normally 01 00 00 00 00 00 for delta bitmaps, 00 00 00 00 00 00 for first bitmap)
+ // random data may be used as filler
+ //
+ // 4 bytes lip sync id table size (is [lip sync id count] * 4, should be 0x2E0 for all actors)
+ // 4 bytes per lip sync id
+ // -> 1 byte length of ID
+ // -> 3 bytes actual ID
+ //
+ // 4 bytes lip sync id data table size (seems to be the same for all actors, always 0x220 in size)
+ // 1 byte animation number or 0xFF as terminator
+ // 1 byte delay, if last byte was not terminator
+ // one array for every lip sync id
+ //
+ // 4 bytes appended, seem to be random
+ // 9E11120E for alex
+ // 9E9E9E9E for vizier
int32 fileSize = 0;
Common::SeekableReadStream *file =
SearchMan.createReadStreamForMember("actors/" + _resourceName + ".bin");
@@ -134,34 +160,34 @@ void Portrait::init() {
// raw lip-sync ID table follows
uint32 lipSyncIDTableSize;
-
+
lipSyncIDTableSize = READ_LE_UINT32(data);
data += 4;
assert( lipSyncIDTableSize == (_lipSyncIDCount * 4) );
_lipSyncIDTable = data;
data += lipSyncIDTableSize;
-
+
// raw lip-sync frame table follows
uint32 lipSyncDataTableSize;
uint32 lipSyncDataTableLastOffset;
byte lipSyncData;
uint16 lipSyncDataNr;
uint16 lipSyncCurOffset;
-
+
lipSyncDataTableSize = READ_LE_UINT32(data);
data += 4;
assert( lipSyncDataTableSize == 0x220 ); // always this size, just a safety-check
-
+
_lipSyncData = data;
lipSyncDataTableLastOffset = lipSyncDataTableSize - 1;
_lipSyncDataOffsetTable = new uint16[ _lipSyncIDCount ];
-
+
lipSyncDataNr = 0;
lipSyncCurOffset = 0;
while ( (lipSyncCurOffset < lipSyncDataTableSize) && (lipSyncDataNr < _lipSyncIDCount) ) {
// We are currently at the start of ID-frame data
_lipSyncDataOffsetTable[lipSyncDataNr] = lipSyncCurOffset;
-
+
// Look for end of ID-frame data
lipSyncData = *data++; lipSyncCurOffset++;
while ( (lipSyncData != 0xFF) && (lipSyncCurOffset < lipSyncDataTableLastOffset) ) {
@@ -195,15 +221,16 @@ void Portrait::doit(Common::Point position, uint16 resourceId, uint16 noun, uint
Resource *syncResource = _resMan->findResource(syncResourceId, true);
uint syncOffset = 0;
#endif
-
+
#ifdef DEBUG_PORTRAIT
// prints out the current lip sync ASCII data
char debugPrint[4000];
if (raveResource->size < 4000) {
memcpy(debugPrint, raveResource->data, raveResource->size);
debugPrint[raveResource->size] = 0; // set terminating NUL
+ debug("kPortrait: using actor %s", _resourceName.c_str());
debug("kPortrait (noun %d, verb %d, cond %d, seq %d)", noun, verb, cond, seq);
- debug("kPortrait: %s", debugPrint);
+ debug("kPortrait: rave data is '%s'", debugPrint);
}
#endif
@@ -246,7 +273,7 @@ void Portrait::doit(Common::Point position, uint16 resourceId, uint16 noun, uint
warning("kPortrait: no rave resource %d %X", resourceId, audioNumber);
return;
}
-
+
// Do animation depending on rave resource till audio is done playing
int16 raveTicks;
uint16 raveID;
@@ -264,7 +291,7 @@ void Portrait::doit(Common::Point position, uint16 resourceId, uint16 noun, uint
raveTicks = raveGetTicks(raveResource, &raveOffset);
if (raveTicks < 0)
break;
-
+
// get lipSyncID
raveID = raveGetID(raveResource, &raveOffset);
if (raveID) {
@@ -272,7 +299,15 @@ void Portrait::doit(Common::Point position, uint16 resourceId, uint16 noun, uint
} else {
raveLipSyncData = NULL;
}
-
+
+#ifdef DEBUG_PORTRAIT
+ if (raveID & 0x0ff) {
+ debug("kPortrait: rave '%c%c' after %d ticks", raveID >> 8, raveID & 0x0ff, raveTicks);
+ } else if (raveID) {
+ debug("kPortrait: rave '%c' after %d ticks", raveID >> 8, raveTicks);
+ }
+#endif
+
timerPosition += raveTicks;
// Wait till syncTime passed, then show specific animation bitmap
@@ -287,7 +322,7 @@ void Portrait::doit(Common::Point position, uint16 resourceId, uint16 noun, uint
curPosition = _audio->getAudioPosition();
} while ((curPosition != -1) && (curPosition < timerPosition) && (!userAbort));
}
-
+
if (raveLipSyncData) {
// lip sync data is
// Tick:Byte, Bitmap-Nr:BYTE
@@ -295,6 +330,8 @@ void Portrait::doit(Common::Point position, uint16 resourceId, uint16 noun, uint
timerPositionWithin = timerPosition;
raveLipSyncTicks = *raveLipSyncData++;
while ( (raveLipSyncData < _lipSyncDataOffsetTableEnd) && (raveLipSyncTicks != 0xFF) ) {
+ if (raveLipSyncTicks)
+ raveLipSyncTicks--; // 1 -> wait 0 ticks, 2 -> wait 1 tick, etc.
timerPositionWithin += raveLipSyncTicks;
do {
@@ -308,7 +345,14 @@ void Portrait::doit(Common::Point position, uint16 resourceId, uint16 noun, uint
} while ((curPosition != -1) && (curPosition < timerPositionWithin) && (!userAbort));
raveLipSyncBitmapNr = *raveLipSyncData++;
-
+#ifdef DEBUG_PORTRAIT
+ if (!raveLipSyncTicks) {
+ debug("kPortrait: showing frame %d", raveLipSyncBitmapNr);
+ } else {
+ debug("kPortrait: showing frame %d after %d ticks", raveLipSyncBitmapNr, raveLipSyncTicks);
+ }
+#endif
+
// bitmap nr within sync data is base 1, we need base 0
raveLipSyncBitmapNr--;
@@ -319,7 +363,7 @@ void Portrait::doit(Common::Point position, uint16 resourceId, uint16 noun, uint
} else {
warning("kPortrait: rave lip sync data tried to draw non-existent bitmap %d", raveLipSyncBitmapNr);
}
-
+
raveLipSyncTicks = *raveLipSyncData++;
}
}
@@ -372,7 +416,7 @@ void Portrait::doit(Common::Point position, uint16 resourceId, uint16 noun, uint
}
}
#endif
-
+
// Reset the portrait bitmap to "closed mouth" state (rave.dll seems to do the same)
drawBitmap(0);
bitsShow();
@@ -393,10 +437,10 @@ int16 Portrait::raveGetTicks(Resource *resource, uint *offset) {
byte *curData = resource->data + curOffset;
byte curByte;
uint16 curValue = 0;
-
+
if (curOffset >= resource->size)
return -1;
-
+
while (curOffset < resource->size) {
curByte = *curData++; curOffset++;
if ( curByte == ' ' )
@@ -418,7 +462,7 @@ uint16 Portrait::raveGetID(Resource *resource, uint *offset) {
byte *curData = resource->data + curOffset;
byte curByte = 0;
uint16 curValue = 0;
-
+
while (curOffset < resource->size) {
curByte = *curData++; curOffset++;
if ( curByte == ' ' )
@@ -429,7 +473,7 @@ uint16 Portrait::raveGetID(Resource *resource, uint *offset) {
curValue |= curByte;
}
}
-
+
*offset = curOffset;
return curValue;
}
@@ -440,17 +484,17 @@ byte *Portrait::raveGetLipSyncData(uint16 raveID) {
byte *lipSyncIDPtr = _lipSyncIDTable;
byte lipSyncIDByte1, lipSyncIDByte2;
uint16 lipSyncID;
-
+
lipSyncIDPtr++; // skip over first byte
while (lipSyncIDNr < _lipSyncIDCount) {
lipSyncIDByte1 = *lipSyncIDPtr++;
lipSyncIDByte2 = *lipSyncIDPtr++;
lipSyncID = ( lipSyncIDByte1 << 8 ) | lipSyncIDByte2;
-
+
if ( lipSyncID == raveID ) {
return _lipSyncData + _lipSyncDataOffsetTable[lipSyncIDNr];
}
-
+
lipSyncIDNr++;
lipSyncIDPtr += 2; // ID is every 4 bytes
}
diff --git a/engines/sci/graphics/portrait.h b/engines/sci/graphics/portrait.h
index 877b253bcf..e0888daa86 100644
--- a/engines/sci/graphics/portrait.h
+++ b/engines/sci/graphics/portrait.h
@@ -72,7 +72,7 @@ private:
Common::String _resourceName;
byte *_fileData;
-
+
uint32 _lipSyncIDCount;
byte *_lipSyncIDTable;
diff --git a/engines/sci/graphics/ports.cpp b/engines/sci/graphics/ports.cpp
index 56c63a7b12..bcc991081e 100644
--- a/engines/sci/graphics/ports.cpp
+++ b/engines/sci/graphics/ports.cpp
@@ -63,10 +63,10 @@ void GfxPorts::init(bool usesOldGfxFunctions, GfxPaint16 *paint16, GfxText16 *te
openPort(_menuPort);
setPort(_menuPort);
_text16->SetFont(0);
- _menuPort->rect = Common::Rect(0, 0, _screen->getWidth(), _screen->getHeight());
- _menuBarRect = Common::Rect(0, 0, _screen->getWidth(), 9);
- _menuRect = Common::Rect(0, 0, _screen->getWidth(), 10);
- _menuLine = Common::Rect(0, 9, _screen->getWidth(), 10);
+ _menuPort->rect = Common::Rect(0, 0, _screen->getScriptWidth(), _screen->getScriptHeight());
+ _menuBarRect = Common::Rect(0, 0, _screen->getScriptWidth(), 9);
+ _menuRect = Common::Rect(0, 0, _screen->getScriptWidth(), 10);
+ _menuLine = Common::Rect(0, 9, _screen->getScriptWidth(), 10);
_wmgrPort = new Port(1);
_windowsById.resize(2);
@@ -122,13 +122,13 @@ void GfxPorts::init(bool usesOldGfxFunctions, GfxPaint16 *paint16, GfxText16 *te
} else {
_wmgrPort->rect.bottom = _screen->getHeight();
}
- _wmgrPort->rect.right = _screen->getWidth();
+ _wmgrPort->rect.right = _screen->getScriptWidth();
_wmgrPort->rect.moveTo(0, 0);
_wmgrPort->curTop = 0;
_wmgrPort->curLeft = 0;
_windowList.push_front(_wmgrPort);
- _picWind = addWindow(Common::Rect(0, offTop, _screen->getWidth(), _screen->getHeight()), 0, 0, SCI_WINDOWMGR_STYLE_TRANSPARENT | SCI_WINDOWMGR_STYLE_NOFRAME, 0, true);
+ _picWind = addWindow(Common::Rect(0, offTop, _screen->getScriptWidth(), _screen->getScriptHeight()), 0, 0, SCI_WINDOWMGR_STYLE_TRANSPARENT | SCI_WINDOWMGR_STYLE_NOFRAME, 0, true);
// For SCI0 games till kq4 (.502 - not including) we set _picWind top to offTop instead
// Because of the menu/status bar
if (_usesOldGfxFunctions)
@@ -321,13 +321,13 @@ Window *GfxPorts::addWindow(const Common::Rect &dims, const Common::Rect *restor
// their interpreter even in the newer VGA games.
r.left = r.left & 0xFFFE;
- if (r.width() > _screen->getWidth()) {
+ if (r.width() > _screen->getScriptWidth()) {
// We get invalid dimensions at least at the end of sq3 (script bug!).
// Same happens very often in lsl5, sierra sci didnt fix it but it looked awful.
// Also happens frequently in the demo of GK1.
warning("Fixing too large window, left: %d, right: %d", dims.left, dims.right);
r.left = 0;
- r.right = _screen->getWidth() - 1;
+ r.right = _screen->getScriptWidth() - 1;
if ((style != _styleUser) && !(style & SCI_WINDOWMGR_STYLE_NOFRAME))
r.right--;
}
diff --git a/engines/sci/graphics/screen.cpp b/engines/sci/graphics/screen.cpp
index c5c94d7991..2f95bf7751 100644
--- a/engines/sci/graphics/screen.cpp
+++ b/engines/sci/graphics/screen.cpp
@@ -37,7 +37,15 @@ GfxScreen::GfxScreen(ResourceManager *resMan) : _resMan(resMan) {
// Scale the screen, if needed
_upscaledHires = GFX_SCREEN_UPSCALED_DISABLED;
-
+
+ // we default to scripts running at 320x200
+ _scriptWidth = 320;
+ _scriptHeight = 200;
+ _width = 0;
+ _height = 0;
+ _displayWidth = 0;
+ _displayHeight = 0;
+
// King's Quest 6 and Gabriel Knight 1 have hires content, gk1/cd was able
// to provide that under DOS as well, but as gk1/floppy does support
// upscaled hires scriptswise, but doesn't actually have the hires content
@@ -50,10 +58,33 @@ GfxScreen::GfxScreen(ResourceManager *resMan) : _resMan(resMan) {
_upscaledHires = GFX_SCREEN_UPSCALED_640x480;
#endif
}
+
+ // Japanese versions of games use hi-res font on upscaled version of the game.
+ if ((g_sci->getLanguage() == Common::JA_JPN) && (getSciVersion() <= SCI_VERSION_1_1))
+ _upscaledHires = GFX_SCREEN_UPSCALED_640x400;
+ // Macintosh SCI0 games used 480x300, while the scripts were running at 320x200
if (g_sci->getPlatform() == Common::kPlatformMacintosh) {
- if (getSciVersion() <= SCI_VERSION_01)
+ if (getSciVersion() <= SCI_VERSION_01) {
_upscaledHires = GFX_SCREEN_UPSCALED_480x300;
+ _width = 480;
+ _height = 300; // regular visual, priority and control map are 480x300 (this is different than other upscaled SCI games)
+ }
+
+ // Some Mac SCI1/1.1 games only take up 190 rows and do not
+ // have the menu bar.
+ // TODO: Verify that LSL1 and LSL5 use height 190
+ switch (g_sci->getGameId()) {
+ case GID_FREDDYPHARKAS:
+ case GID_KQ5:
+ case GID_KQ6:
+ case GID_LSL1:
+ case GID_LSL5:
+ case GID_SQ1:
+ _width = 190;
+ default:
+ break;
+ }
}
#ifdef ENABLE_SCI32
@@ -65,76 +96,77 @@ GfxScreen::GfxScreen(ResourceManager *resMan) : _resMan(resMan) {
#endif
if (_resMan->detectHires()) {
- _width = 640;
- _pitch = 640;
- _height = 480;
- } else {
- _width = 320;
- _pitch = 320;
- _height = getLowResScreenHeight();
+ _scriptWidth = 640;
+ _scriptHeight = 480;
}
#ifdef ENABLE_SCI32
- // Phantasmagoria 1 sets a window area of 630x450
+ // Phantasmagoria 1 effectively outputs 630x450
+ // Coordinate translation has to use this resolution as well
if (g_sci->getGameId() == GID_PHANTASMAGORIA) {
_width = 630;
_height = 450;
}
#endif
- // Japanese versions of games use hi-res font on upscaled version of the game.
- if ((g_sci->getLanguage() == Common::JA_JPN) && (getSciVersion() <= SCI_VERSION_1_1))
- _upscaledHires = GFX_SCREEN_UPSCALED_640x400;
+ // if not yet set, set those to script-width/height
+ if (!_width)
+ _width = _scriptWidth;
+ if (!_height)
+ _height = _scriptHeight;
- _pixels = _pitch * _height;
+ _pixels = _width * _height;
switch (_upscaledHires) {
case GFX_SCREEN_UPSCALED_480x300:
// Space Quest 3, Hoyle 1+2 on MAC use this one
- // TODO: Sierra's upscaling worked differently. We need to figure out the exact algo
_displayWidth = 480;
_displayHeight = 300;
- for (int i = 0; i <= _height; i++)
+ for (int i = 0; i <= _scriptHeight; i++)
_upscaledHeightMapping[i] = (i * 3) >> 1;
- for (int i = 0; i <= _width; i++)
+ for (int i = 0; i <= _scriptWidth; i++)
_upscaledWidthMapping[i] = (i * 3) >> 1;
break;
case GFX_SCREEN_UPSCALED_640x400:
// Police Quest 2 and Quest For Glory on PC9801 (Japanese)
_displayWidth = 640;
_displayHeight = 400;
- for (int i = 0; i <= _height; i++)
+ for (int i = 0; i <= _scriptHeight; i++)
_upscaledHeightMapping[i] = i * 2;
- for (int i = 0; i <= _width; i++)
+ for (int i = 0; i <= _scriptWidth; i++)
_upscaledWidthMapping[i] = i * 2;
break;
case GFX_SCREEN_UPSCALED_640x440:
// used by King's Quest 6 on Windows
_displayWidth = 640;
_displayHeight = 440;
- for (int i = 0; i <= _height; i++)
+ for (int i = 0; i <= _scriptHeight; i++)
_upscaledHeightMapping[i] = (i * 11) / 5;
- for (int i = 0; i <= _width; i++)
+ for (int i = 0; i <= _scriptWidth; i++)
_upscaledWidthMapping[i] = i * 2;
break;
case GFX_SCREEN_UPSCALED_640x480:
// Gabriel Knight 1 (VESA, Mac)
_displayWidth = 640;
_displayHeight = 480;
- for (int i = 0; i <= _height; i++)
+ for (int i = 0; i <= _scriptHeight; i++)
_upscaledHeightMapping[i] = (i * 12) / 5;
- for (int i = 0; i <= _width; i++)
+ for (int i = 0; i <= _scriptWidth; i++)
_upscaledWidthMapping[i] = i * 2;
break;
default:
- _displayWidth = _pitch;
- _displayHeight = _height;
+ if (!_displayWidth)
+ _displayWidth = _width;
+ if (!_displayHeight)
+ _displayHeight = _height;
memset(&_upscaledHeightMapping, 0, sizeof(_upscaledHeightMapping) );
memset(&_upscaledWidthMapping, 0, sizeof(_upscaledWidthMapping) );
break;
}
_displayPixels = _displayWidth * _displayHeight;
+
+ // Allocate visual, priority, control and display screen
_visualScreen = (byte *)calloc(_pixels, 1);
_priorityScreen = (byte *)calloc(_pixels, 1);
_controlScreen = (byte *)calloc(_pixels, 1);
@@ -179,6 +211,36 @@ GfxScreen::GfxScreen(ResourceManager *resMan) : _resMan(resMan) {
error("Unknown SCI1.1 Mac game");
} else
initGraphics(_displayWidth, _displayHeight, _displayWidth > 320);
+
+ // Initialize code pointers
+ _vectorAdjustCoordinatePtr = &GfxScreen::vectorAdjustCoordinateNOP;
+ _vectorAdjustLineCoordinatesPtr = &GfxScreen::vectorAdjustLineCoordinatesNOP;
+ _vectorIsFillMatchPtr = &GfxScreen::vectorIsFillMatchNormal;
+ _vectorPutPixelPtr = &GfxScreen::putPixelNormal;
+ _vectorPutLinePixelPtr = &GfxScreen::putPixel;
+ _vectorGetPixelPtr = &GfxScreen::getPixelNormal;
+ _putPixelPtr = &GfxScreen::putPixelNormal;
+ _getPixelPtr = &GfxScreen::getPixelNormal;
+
+ switch (_upscaledHires) {
+ case GFX_SCREEN_UPSCALED_480x300:
+ _vectorAdjustCoordinatePtr = &GfxScreen::vectorAdjustCoordinate480x300Mac;
+ _vectorAdjustLineCoordinatesPtr = &GfxScreen::vectorAdjustLineCoordinates480x300Mac;
+ // vectorPutPixel -> we already adjust coordinates for vector code, that's why we can set pixels directly
+ // vectorGetPixel -> see vectorPutPixel
+ _vectorPutLinePixelPtr = &GfxScreen::vectorPutLinePixel480x300Mac;
+ _putPixelPtr = &GfxScreen::putPixelAllUpscaled;
+ _getPixelPtr = &GfxScreen::getPixelUpscaled;
+ break;
+ case GFX_SCREEN_UPSCALED_640x400:
+ case GFX_SCREEN_UPSCALED_640x440:
+ case GFX_SCREEN_UPSCALED_640x480:
+ _vectorPutPixelPtr = &GfxScreen::putPixelDisplayUpscaled;
+ _putPixelPtr = &GfxScreen::putPixelDisplayUpscaled;
+ break;
+ case GFX_SCREEN_UPSCALED_DISABLED:
+ break;
+ }
}
GfxScreen::~GfxScreen() {
@@ -232,7 +294,7 @@ void GfxScreen::copyRectToScreen(const Common::Rect &rect, int16 x, int16 y) {
} else {
int rectHeight = _upscaledHeightMapping[rect.bottom] - _upscaledHeightMapping[rect.top];
int rectWidth = _upscaledWidthMapping[rect.right] - _upscaledWidthMapping[rect.left];
-
+
g_system->copyRectToScreen(_activeScreen + _upscaledHeightMapping[rect.top] * _displayWidth + _upscaledWidthMapping[rect.left], _displayWidth, _upscaledWidthMapping[x], _upscaledHeightMapping[y], rectWidth, rectHeight);
}
}
@@ -248,43 +310,162 @@ byte GfxScreen::getDrawingMask(byte color, byte prio, byte control) {
return flag;
}
-void GfxScreen::putPixel(int x, int y, byte drawMask, byte color, byte priority, byte control) {
- int offset = y * _pitch + x;
+void GfxScreen::vectorAdjustCoordinateNOP(int16 *x, int16 *y) {
+}
- if (drawMask & GFX_SCREEN_MASK_VISUAL) {
- _visualScreen[offset] = color;
- if (!_upscaledHires) {
- _displayScreen[offset] = color;
+void GfxScreen::vectorAdjustCoordinate480x300Mac(int16 *x, int16 *y) {
+ *x = _upscaledWidthMapping[*x];
+ *y = _upscaledHeightMapping[*y];
+}
+
+void GfxScreen::vectorAdjustLineCoordinatesNOP(int16 *left, int16 *top, int16 *right, int16 *bottom, byte drawMask, byte color, byte priority, byte control) {
+}
+
+void GfxScreen::vectorAdjustLineCoordinates480x300Mac(int16 *left, int16 *top, int16 *right, int16 *bottom, byte drawMask, byte color, byte priority, byte control) {
+ int16 displayLeft = _upscaledWidthMapping[*left];
+ int16 displayRight = _upscaledWidthMapping[*right];
+ int16 displayTop = _upscaledHeightMapping[*top];
+ int16 displayBottom = _upscaledHeightMapping[*bottom];
+
+ if (displayLeft < displayRight) {
+ // one more pixel to the left, one more pixel to the right
+ if (displayLeft > 0)
+ vectorPutLinePixel(displayLeft - 1, displayTop, drawMask, color, priority, control);
+ vectorPutLinePixel(displayRight + 1, displayBottom, drawMask, color, priority, control);
+ } else if (displayLeft > displayRight) {
+ if (displayRight > 0)
+ vectorPutLinePixel(displayRight - 1, displayBottom, drawMask, color, priority, control);
+ vectorPutLinePixel(displayLeft + 1, displayTop, drawMask, color, priority, control);
+ }
+ *left = displayLeft;
+ *top = displayTop;
+ *right = displayRight;
+ *bottom = displayBottom;
+}
+
+byte GfxScreen::vectorIsFillMatchNormal(int16 x, int16 y, byte screenMask, byte checkForColor, byte checkForPriority, byte checkForControl, bool isEGA) {
+ int offset = y * _width + x;
+ byte match = 0;
+
+ if (screenMask & GFX_SCREEN_MASK_VISUAL) {
+ if (!isEGA) {
+ if (*(_visualScreen + offset) == checkForColor)
+ match |= GFX_SCREEN_MASK_VISUAL;
} else {
- putScaledPixelOnDisplay(x, y, color);
+ // In EGA games a pixel in the framebuffer is only 4 bits. We store
+ // a full byte per pixel to allow undithering, but when comparing
+ // pixels for flood-fill purposes, we should only compare the
+ // visible color of a pixel.
+
+ byte EGAcolor = *(_visualScreen + offset);
+ if ((x ^ y) & 1)
+ EGAcolor = (EGAcolor ^ (EGAcolor >> 4)) & 0x0F;
+ else
+ EGAcolor = EGAcolor & 0x0F;
+ if (EGAcolor == checkForColor)
+ match |= GFX_SCREEN_MASK_VISUAL;
}
}
+ if ((screenMask & GFX_SCREEN_MASK_PRIORITY) && *(_priorityScreen + offset) == checkForPriority)
+ match |= GFX_SCREEN_MASK_PRIORITY;
+ if ((screenMask & GFX_SCREEN_MASK_CONTROL) && *(_controlScreen + offset) == checkForControl)
+ match |= GFX_SCREEN_MASK_CONTROL;
+ return match;
+}
+
+// Special 480x300 Mac putPixel for vector line drawing, also draws an additional pixel below the actual one
+void GfxScreen::vectorPutLinePixel480x300Mac(int16 x, int16 y, byte drawMask, byte color, byte priority, byte control) {
+ int offset = y * _width + x;
+
+ if (drawMask & GFX_SCREEN_MASK_VISUAL) {
+ _visualScreen[offset] = color;
+ _visualScreen[offset + _width] = color;
+ _displayScreen[offset] = color;
+ // also set pixel below actual pixel
+ _displayScreen[offset + _displayWidth] = color;
+ }
+ if (drawMask & GFX_SCREEN_MASK_PRIORITY) {
+ _priorityScreen[offset] = priority;
+ _priorityScreen[offset + _width] = priority;
+ }
+ if (drawMask & GFX_SCREEN_MASK_CONTROL) {
+ _controlScreen[offset] = control;
+ _controlScreen[offset + _width] = control;
+ }
+}
+
+// Directly sets a pixel on various screens, display is not upscaled
+void GfxScreen::putPixelNormal(int16 x, int16 y, byte drawMask, byte color, byte priority, byte control) {
+ int offset = y * _width + x;
+
+ if (drawMask & GFX_SCREEN_MASK_VISUAL) {
+ _visualScreen[offset] = color;
+ _displayScreen[offset] = color;
+ }
+ if (drawMask & GFX_SCREEN_MASK_PRIORITY)
+ _priorityScreen[offset] = priority;
+ if (drawMask & GFX_SCREEN_MASK_CONTROL)
+ _controlScreen[offset] = control;
+}
+
+// Directly sets a pixel on various screens, display IS upscaled
+void GfxScreen::putPixelDisplayUpscaled(int16 x, int16 y, byte drawMask, byte color, byte priority, byte control) {
+ int offset = y * _width + x;
+
+ if (drawMask & GFX_SCREEN_MASK_VISUAL) {
+ _visualScreen[offset] = color;
+ putScaledPixelOnScreen(_displayScreen, x, y, color);
+ }
if (drawMask & GFX_SCREEN_MASK_PRIORITY)
_priorityScreen[offset] = priority;
if (drawMask & GFX_SCREEN_MASK_CONTROL)
_controlScreen[offset] = control;
}
+// Directly sets a pixel on various screens, ALL screens ARE upscaled
+void GfxScreen::putPixelAllUpscaled(int16 x, int16 y, byte drawMask, byte color, byte priority, byte control) {
+ if (drawMask & GFX_SCREEN_MASK_VISUAL) {
+ putScaledPixelOnScreen(_visualScreen, x, y, color);
+ putScaledPixelOnScreen(_displayScreen, x, y, color);
+ }
+ if (drawMask & GFX_SCREEN_MASK_PRIORITY)
+ putScaledPixelOnScreen(_priorityScreen, x, y, priority);
+ if (drawMask & GFX_SCREEN_MASK_CONTROL)
+ putScaledPixelOnScreen(_controlScreen, x, y, control);
+}
+
/**
* This is used to put font pixels onto the screen - we adjust differently, so that we won't
* do triple pixel lines in any case on upscaled hires. That way the font will not get distorted
* Sierra SCI didn't do this
*/
-void GfxScreen::putFontPixel(int startingY, int x, int y, byte color) {
- int actualY = startingY + y;
+void GfxScreen::putFontPixel(int16 startingY, int16 x, int16 y, byte color) {
+ int16 actualY = startingY + y;
if (_fontIsUpscaled) {
// Do not scale ourselves, but put it on the display directly
putPixelOnDisplay(x, actualY, color);
} else {
- int offset = actualY * _pitch + x;
+ int offset = actualY * _width + x;
_visualScreen[offset] = color;
switch (_upscaledHires) {
case GFX_SCREEN_UPSCALED_DISABLED:
_displayScreen[offset] = color;
break;
+ case GFX_SCREEN_UPSCALED_640x400:
+ case GFX_SCREEN_UPSCALED_640x440:
+ case GFX_SCREEN_UPSCALED_640x480: {
+ // to 1-> 4 pixels upscaling for all of those, so that fonts won't look weird
+ int displayOffset = (_upscaledHeightMapping[startingY] + y * 2) * _displayWidth + x * 2;
+ _displayScreen[displayOffset] = color;
+ _displayScreen[displayOffset + 1] = color;
+ displayOffset += _displayWidth;
+ _displayScreen[displayOffset] = color;
+ _displayScreen[displayOffset + 1] = color;
+ break;
+ }
default:
- putScaledPixelOnDisplay(x, actualY, color);
+ putScaledPixelOnScreen(_displayScreen, x, actualY, color);
break;
}
}
@@ -295,12 +476,15 @@ void GfxScreen::putFontPixel(int startingY, int x, int y, byte color) {
* only used on upscaled-Hires games where hires content needs to get drawn ONTO
* the upscaled display screen (like japanese fonts, hires portraits, etc.).
*/
-void GfxScreen::putPixelOnDisplay(int x, int y, byte color) {
+void GfxScreen::putPixelOnDisplay(int16 x, int16 y, byte color) {
int offset = y * _displayWidth + x;
_displayScreen[offset] = color;
}
-void GfxScreen::putScaledPixelOnDisplay(int x, int y, byte color) {
+//void GfxScreen::putScaledPixelOnDisplay(int16 x, int16 y, byte color) {
+//}
+
+void GfxScreen::putScaledPixelOnScreen(byte *screen, int16 x, int16 y, byte data) {
int displayOffset = _upscaledHeightMapping[y] * _displayWidth + _upscaledWidthMapping[x];
int heightOffsetBreak = (_upscaledHeightMapping[y + 1] - _upscaledHeightMapping[y]) * _displayWidth;
int heightOffset = 0;
@@ -308,7 +492,7 @@ void GfxScreen::putScaledPixelOnDisplay(int x, int y, byte color) {
do {
int widthOffset = 0;
do {
- _displayScreen[displayOffset + heightOffset + widthOffset] = color;
+ screen[displayOffset + heightOffset + widthOffset] = data;
widthOffset++;
} while (widthOffset != widthOffsetBreak);
heightOffset += _displayWidth;
@@ -329,16 +513,18 @@ void GfxScreen::drawLine(Common::Point startPoint, Common::Point endPoint, byte
int16 top = CLIP<int16>(startPoint.y, 0, maxHeight);
int16 right = CLIP<int16>(endPoint.x, 0, maxWidth);
int16 bottom = CLIP<int16>(endPoint.y, 0, maxHeight);
-
+
//set_drawing_flag
byte drawMask = getDrawingMask(color, priority, control);
+ vectorAdjustLineCoordinates(&left, &top, &right, &bottom, drawMask, color, priority, control);
+
// horizontal line
if (top == bottom) {
if (right < left)
SWAP(right, left);
for (int i = left; i <= right; i++)
- putPixel(i, top, drawMask, color, priority, control);
+ vectorPutLinePixel(i, top, drawMask, color, priority, control);
return;
}
// vertical line
@@ -346,20 +532,20 @@ void GfxScreen::drawLine(Common::Point startPoint, Common::Point endPoint, byte
if (top > bottom)
SWAP(top, bottom);
for (int i = top; i <= bottom; i++)
- putPixel(left, i, drawMask, color, priority, control);
+ vectorPutLinePixel(left, i, drawMask, color, priority, control);
return;
}
// sloped line - draw with Bresenham algorithm
- int dy = bottom - top;
- int dx = right - left;
- int stepy = dy < 0 ? -1 : 1;
- int stepx = dx < 0 ? -1 : 1;
+ int16 dy = bottom - top;
+ int16 dx = right - left;
+ int16 stepy = dy < 0 ? -1 : 1;
+ int16 stepx = dx < 0 ? -1 : 1;
dy = ABS(dy) << 1;
dx = ABS(dx) << 1;
// setting the 1st and last pixel
- putPixel(left, top, drawMask, color, priority, control);
- putPixel(right, bottom, drawMask, color, priority, control);
+ vectorPutLinePixel(left, top, drawMask, color, priority, control);
+ vectorPutLinePixel(right, bottom, drawMask, color, priority, control);
// drawing the line
if (dx > dy) { // going horizontal
int fraction = dy - (dx >> 1);
@@ -370,7 +556,7 @@ void GfxScreen::drawLine(Common::Point startPoint, Common::Point endPoint, byte
}
left += stepx;
fraction += dy;
- putPixel(left, top, drawMask, color, priority, control);
+ vectorPutLinePixel(left, top, drawMask, color, priority, control);
}
} else { // going vertical
int fraction = dx - (dy >> 1);
@@ -381,7 +567,7 @@ void GfxScreen::drawLine(Common::Point startPoint, Common::Point endPoint, byte
}
top += stepy;
fraction += dx;
- putPixel(left, top, drawMask, color, priority, control);
+ vectorPutLinePixel(left, top, drawMask, color, priority, control);
}
}
}
@@ -394,46 +580,14 @@ void GfxScreen::putKanjiChar(Graphics::FontSJIS *commonFont, int16 x, int16 y, u
commonFont->drawChar(displayPtr, chr, _displayWidth, 1, color, 0, -1, -1);
}
-byte GfxScreen::getVisual(int x, int y) {
- return _visualScreen[y * _pitch + x];
-}
-
-byte GfxScreen::getPriority(int x, int y) {
- return _priorityScreen[y * _pitch + x];
-}
-
-byte GfxScreen::getControl(int x, int y) {
- return _controlScreen[y * _pitch + x];
+byte GfxScreen::getPixelNormal(byte *screen, int16 x, int16 y) {
+ return screen[y * _width + x];
}
-byte GfxScreen::isFillMatch(int16 x, int16 y, byte screenMask, byte t_color, byte t_pri, byte t_con, bool isEGA) {
- int offset = y * _pitch + x;
- byte match = 0;
-
- if (screenMask & GFX_SCREEN_MASK_VISUAL) {
- if (!isEGA) {
- if (*(_visualScreen + offset) == t_color)
- match |= GFX_SCREEN_MASK_VISUAL;
- } else {
- // In EGA games a pixel in the framebuffer is only 4 bits. We store
- // a full byte per pixel to allow undithering, but when comparing
- // pixels for flood-fill purposes, we should only compare the
- // visible color of a pixel.
-
- byte c = *(_visualScreen + offset);
- if ((x ^ y) & 1)
- c = (c ^ (c >> 4)) & 0x0F;
- else
- c = c & 0x0F;
- if (c == t_color)
- match |= GFX_SCREEN_MASK_VISUAL;
- }
- }
- if ((screenMask & GFX_SCREEN_MASK_PRIORITY) && *(_priorityScreen + offset) == t_pri)
- match |= GFX_SCREEN_MASK_PRIORITY;
- if ((screenMask & GFX_SCREEN_MASK_CONTROL) && *(_controlScreen + offset) == t_con)
- match |= GFX_SCREEN_MASK_CONTROL;
- return match;
+byte GfxScreen::getPixelUpscaled(byte *screen, int16 x, int16 y) {
+ int16 mappedX = _upscaledWidthMapping[x];
+ int16 mappedY = _upscaledHeightMapping[y];
+ return screen[mappedY * _width + mappedX];
}
int GfxScreen::bitsGetDataSize(Common::Rect rect, byte mask) {
@@ -469,14 +623,14 @@ void GfxScreen::bitsSave(Common::Rect rect, byte mask, byte *memoryPtr) {
memcpy(memoryPtr, (void *)&mask, sizeof(mask)); memoryPtr += sizeof(mask);
if (mask & GFX_SCREEN_MASK_VISUAL) {
- bitsSaveScreen(rect, _visualScreen, _pitch, memoryPtr);
+ bitsSaveScreen(rect, _visualScreen, _width, memoryPtr);
bitsSaveDisplayScreen(rect, memoryPtr);
}
if (mask & GFX_SCREEN_MASK_PRIORITY) {
- bitsSaveScreen(rect, _priorityScreen, _pitch, memoryPtr);
+ bitsSaveScreen(rect, _priorityScreen, _width, memoryPtr);
}
if (mask & GFX_SCREEN_MASK_CONTROL) {
- bitsSaveScreen(rect, _controlScreen, _pitch, memoryPtr);
+ bitsSaveScreen(rect, _controlScreen, _width, memoryPtr);
}
if (mask & GFX_SCREEN_MASK_DISPLAY) {
if (!_upscaledHires)
@@ -530,14 +684,14 @@ void GfxScreen::bitsRestore(byte *memoryPtr) {
memcpy((void *)&mask, memoryPtr, sizeof(mask)); memoryPtr += sizeof(mask);
if (mask & GFX_SCREEN_MASK_VISUAL) {
- bitsRestoreScreen(rect, memoryPtr, _visualScreen, _pitch);
+ bitsRestoreScreen(rect, memoryPtr, _visualScreen, _width);
bitsRestoreDisplayScreen(rect, memoryPtr);
}
if (mask & GFX_SCREEN_MASK_PRIORITY) {
- bitsRestoreScreen(rect, memoryPtr, _priorityScreen, _pitch);
+ bitsRestoreScreen(rect, memoryPtr, _priorityScreen, _width);
}
if (mask & GFX_SCREEN_MASK_CONTROL) {
- bitsRestoreScreen(rect, memoryPtr, _controlScreen, _pitch);
+ bitsRestoreScreen(rect, memoryPtr, _controlScreen, _width);
}
if (mask & GFX_SCREEN_MASK_DISPLAY) {
if (!_upscaledHires)
@@ -612,21 +766,22 @@ void GfxScreen::dither(bool addToFlag) {
byte color, ditheredColor;
byte *visualPtr = _visualScreen;
byte *displayPtr = _displayScreen;
-
+
if (!_unditheringEnabled) {
// Do dithering on visual and display-screen
for (y = 0; y < _height; y++) {
- for (x = 0; x < _pitch; x++) {
+ for (x = 0; x < _width; x++) {
color = *visualPtr;
if (color & 0xF0) {
color ^= color << 4;
color = ((x^y) & 1) ? color >> 4 : color & 0x0F;
switch (_upscaledHires) {
case GFX_SCREEN_UPSCALED_DISABLED:
+ case GFX_SCREEN_UPSCALED_480x300:
*displayPtr = color;
break;
default:
- putScaledPixelOnDisplay(x, y, color);
+ putScaledPixelOnScreen(_displayScreen, x, y, color);
break;
}
*visualPtr = color;
@@ -639,7 +794,7 @@ void GfxScreen::dither(bool addToFlag) {
memset(&_ditheredPicColors, 0, sizeof(_ditheredPicColors));
// Do dithering on visual screen and put decoded but undithered byte onto display-screen
for (y = 0; y < _height; y++) {
- for (x = 0; x < _pitch; x++) {
+ for (x = 0; x < _width; x++) {
color = *visualPtr;
if (color & 0xF0) {
color ^= color << 4;
@@ -654,10 +809,11 @@ void GfxScreen::dither(bool addToFlag) {
}
switch (_upscaledHires) {
case GFX_SCREEN_UPSCALED_DISABLED:
+ case GFX_SCREEN_UPSCALED_480x300:
*displayPtr = ditheredColor;
break;
default:
- putScaledPixelOnDisplay(x, y, ditheredColor);
+ putScaledPixelOnScreen(_displayScreen, x, y, ditheredColor);
break;
}
color = ((x^y) & 1) ? color >> 4 : color & 0x0F;
@@ -685,8 +841,8 @@ int16 *GfxScreen::unditherGetDitheredBgColors() {
}
void GfxScreen::debugShowMap(int mapNo) {
- // We cannot really support changing maps when in upscaledHires mode
- if (_upscaledHires)
+ // We cannot really support changing maps when display screen has a different resolution than visual screen
+ if ((_width != _displayWidth) || (_height != _displayHeight))
return;
switch (mapNo) {
@@ -779,8 +935,8 @@ void GfxScreen::adjustBackUpscaledCoordinates(int16 &y, int16 &x, Sci32ViewNativ
switch (_upscaledHires) {
case GFX_SCREEN_UPSCALED_480x300:
- x = (x << 1) / 3;
- y = (y << 1) / 3;
+ x = (x * 4) / 6;
+ y = (y * 4) / 6;
break;
case GFX_SCREEN_UPSCALED_640x400:
x /= 2;
@@ -816,26 +972,4 @@ int16 GfxScreen::kernelPicNotValid(int16 newPicNotValid) {
return oldPicNotValid;
}
-uint16 GfxScreen::getLowResScreenHeight() {
- // Some Mac SCI1/1.1 games only take up 190 rows and do not
- // have the menu bar.
- // TODO: Verify that LSL1 and LSL5 use height 190
- if (g_sci->getPlatform() == Common::kPlatformMacintosh) {
- switch (g_sci->getGameId()) {
- case GID_FREDDYPHARKAS:
- case GID_KQ5:
- case GID_KQ6:
- case GID_LSL1:
- case GID_LSL5:
- case GID_SQ1:
- return 190;
- default:
- break;
- }
- }
-
- // Everything else is 200
- return 200;
-}
-
} // End of namespace Sci
diff --git a/engines/sci/graphics/screen.h b/engines/sci/graphics/screen.h
index e266a4ed16..766e32614a 100644
--- a/engines/sci/graphics/screen.h
+++ b/engines/sci/graphics/screen.h
@@ -69,6 +69,8 @@ public:
uint16 getWidth() { return _width; }
uint16 getHeight() { return _height; }
+ uint16 getScriptWidth() { return _scriptWidth; }
+ uint16 getScriptHeight() { return _scriptHeight; }
uint16 getDisplayWidth() { return _displayWidth; }
uint16 getDisplayHeight() { return _displayHeight; }
byte getColorWhite() { return _colorWhite; }
@@ -81,11 +83,51 @@ public:
void copyDisplayRectToScreen(const Common::Rect &rect);
void copyRectToScreen(const Common::Rect &rect, int16 x, int16 y);
+ // calls to code pointers
+ void inline vectorAdjustCoordinate (int16 *x, int16 *y) {
+ (this->*_vectorAdjustCoordinatePtr)(x, y);
+ }
+ void inline vectorAdjustLineCoordinates (int16 *left, int16 *top, int16 *right, int16 *bottom, byte drawMask, byte color, byte priority, byte control) {
+ (this->*_vectorAdjustLineCoordinatesPtr)(left, top, right, bottom, drawMask, color, priority, control);
+ }
+ byte inline vectorIsFillMatch (int16 x, int16 y, byte screenMask, byte t_color, byte t_pri, byte t_con, bool isEGA) {
+ return (this->*_vectorIsFillMatchPtr)(x, y, screenMask, t_color, t_pri, t_con, isEGA);
+ }
+ void inline vectorPutPixel(int16 x, int16 y, byte drawMask, byte color, byte priority, byte control) {
+ (this->*_vectorPutPixelPtr)(x, y, drawMask, color, priority, control);
+ }
+ void inline vectorPutLinePixel(int16 x, int16 y, byte drawMask, byte color, byte priority, byte control) {
+ (this->*_vectorPutLinePixelPtr)(x, y, drawMask, color, priority, control);
+ }
+ byte inline vectorGetVisual(int16 x, int16 y) {
+ return (this->*_vectorGetPixelPtr)(_visualScreen, x, y);
+ }
+ byte inline vectorGetPriority(int16 x, int16 y) {
+ return (this->*_vectorGetPixelPtr)(_priorityScreen, x, y);
+ }
+ byte inline vectorGetControl(int16 x, int16 y) {
+ return (this->*_vectorGetPixelPtr)(_controlScreen, x, y);
+ }
+
+
+ void inline putPixel(int16 x, int16 y, byte drawMask, byte color, byte priority, byte control) {
+ (this->*_putPixelPtr)(x, y, drawMask, color, priority, control);
+ }
+
+ byte inline getVisual(int16 x, int16 y) {
+ return (this->*_getPixelPtr)(_visualScreen, x, y);
+ }
+ byte inline getPriority(int16 x, int16 y) {
+ return (this->*_getPixelPtr)(_priorityScreen, x, y);
+ }
+ byte inline getControl(int16 x, int16 y) {
+ return (this->*_getPixelPtr)(_controlScreen, x, y);
+ }
+
byte getDrawingMask(byte color, byte prio, byte control);
- void putPixel(int x, int y, byte drawMask, byte color, byte prio, byte control);
- void putFontPixel(int startingY, int x, int y, byte color);
- void putPixelOnDisplay(int x, int y, byte color);
- void putScaledPixelOnDisplay(int x, int y, byte color);
+ //void putPixel(int16 x, int16 y, byte drawMask, byte color, byte prio, byte control);
+ void putFontPixel(int16 startingY, int16 x, int16 y, byte color);
+ void putPixelOnDisplay(int16 x, int16 y, byte color);
void drawLine(Common::Point startPoint, Common::Point endPoint, byte color, byte prio, byte control);
void drawLine(int16 left, int16 top, int16 right, int16 bottom, byte color, byte prio, byte control) {
drawLine(Common::Point(left, top), Common::Point(right, bottom), color, prio, control);
@@ -101,10 +143,6 @@ public:
void enableUndithering(bool flag);
void putKanjiChar(Graphics::FontSJIS *commonFont, int16 x, int16 y, uint16 chr, byte color);
- byte getVisual(int x, int y);
- byte getPriority(int x, int y);
- byte getControl(int x, int y);
- byte isFillMatch(int16 x, int16 y, byte drawMask, byte t_color, byte t_pri, byte t_con, bool isEGA);
int bitsGetDataSize(Common::Rect rect, byte mask);
void bitsSave(Common::Rect rect, byte mask, byte *memoryPtr);
@@ -135,9 +173,10 @@ public:
private:
uint16 _width;
- uint16 _pitch;
uint16 _height;
uint _pixels;
+ uint16 _scriptWidth;
+ uint16 _scriptHeight;
uint16 _displayWidth;
uint16 _displayHeight;
uint _displayPixels;
@@ -190,8 +229,8 @@ private:
* This here holds a translation for vertical+horizontal coordinates between native
* (visual) and actual (display) screen.
*/
- int _upscaledHeightMapping[SCI_SCREEN_UPSCALEDMAXHEIGHT + 1];
- int _upscaledWidthMapping[SCI_SCREEN_UPSCALEDMAXWIDTH + 1];
+ int16 _upscaledHeightMapping[SCI_SCREEN_UPSCALEDMAXHEIGHT + 1];
+ int16 _upscaledWidthMapping[SCI_SCREEN_UPSCALEDMAXWIDTH + 1];
/**
* This defines whether or not the font we're drawing is already scaled
@@ -199,7 +238,38 @@ private:
*/
bool _fontIsUpscaled;
- uint16 getLowResScreenHeight();
+ // dynamic code
+ void (GfxScreen::*_vectorAdjustCoordinatePtr) (int16 *x, int16 *y);
+ void vectorAdjustCoordinateNOP (int16 *x, int16 *y);
+ void vectorAdjustCoordinate480x300Mac (int16 *x, int16 *y);
+
+ void (GfxScreen::*_vectorAdjustLineCoordinatesPtr) (int16 *left, int16 *top, int16 *right, int16 *bottom, byte drawMask, byte color, byte priority, byte control);
+ void vectorAdjustLineCoordinatesNOP (int16 *left, int16 *top, int16 *right, int16 *bottom, byte drawMask, byte color, byte priority, byte control);
+ void vectorAdjustLineCoordinates480x300Mac (int16 *left, int16 *top, int16 *right, int16 *bottom, byte drawMask, byte color, byte priority, byte control);
+
+ byte (GfxScreen::*_vectorIsFillMatchPtr) (int16 x, int16 y, byte screenMask, byte t_color, byte t_pri, byte t_con, bool isEGA);
+ byte vectorIsFillMatchNormal (int16 x, int16 y, byte screenMask, byte t_color, byte t_pri, byte t_con, bool isEGA);
+ byte vectorIsFillMatch480x300Mac (int16 x, int16 y, byte screenMask, byte t_color, byte t_pri, byte t_con, bool isEGA);
+
+ void (GfxScreen::*_vectorPutPixelPtr) (int16 x, int16 y, byte drawMask, byte color, byte priority, byte control);
+ void vectorPutPixel480x300Mac (int16 x, int16 y, byte drawMask, byte color, byte priority, byte control);
+
+ void (GfxScreen::*_vectorPutLinePixelPtr) (int16 x, int16 y, byte drawMask, byte color, byte priority, byte control);
+ void vectorPutLinePixel480x300Mac (int16 x, int16 y, byte drawMask, byte color, byte priority, byte control);
+
+ byte (GfxScreen::*_vectorGetPixelPtr) (byte *screen, int16 x, int16 y);
+
+ void (GfxScreen::*_putPixelPtr) (int16 x, int16 y, byte drawMask, byte color, byte priority, byte control);
+ void putPixelNormal (int16 x, int16 y, byte drawMask, byte color, byte priority, byte control);
+ void putPixelDisplayUpscaled (int16 x, int16 y, byte drawMask, byte color, byte priority, byte control);
+ void putPixelAllUpscaled (int16 x, int16 y, byte drawMask, byte color, byte priority, byte control);
+
+ byte (GfxScreen::*_getPixelPtr) (byte *screen, int16 x, int16 y);
+ byte getPixelNormal (byte *screen, int16 x, int16 y);
+ byte getPixelUpscaled (byte *screen, int16 x, int16 y);
+
+ // pixel helper
+ void putScaledPixelOnScreen(byte *screen, int16 x, int16 y, byte color);
};
} // End of namespace Sci
diff --git a/engines/sci/graphics/text16.cpp b/engines/sci/graphics/text16.cpp
index 245d6996cb..f463dff4b1 100644
--- a/engines/sci/graphics/text16.cpp
+++ b/engines/sci/graphics/text16.cpp
@@ -143,18 +143,30 @@ int16 GfxText16::CodeProcessing(const char *&text, GuiResourceId orgFontId, int1
return textCodeSize;
}
-static const uint16 text16_punctuationSjis[] = {
- 0x9F82, 0xA182, 0xA382, 0xA582, 0xA782, 0xC182, 0xA782, 0xC182, 0xE182, 0xE382, 0xE582, 0xEC82,
- 0x4083, 0x4283, 0x4483, 0x4683, 0x4883, 0x6283, 0x8383, 0x8583, 0x8783, 0x8E83, 0x9583, 0x9683,
- 0x5B81, 0x4181, 0x4281, 0x7681, 0x7881, 0x4981, 0x4881, 0
+// Has actually punctuation and characters in it, that may not be the first in a line
+static const uint16 text16_shiftJIS_punctuation[] = {
+ 0x9F82, 0xA182, 0xA382, 0xA582, 0xA782, 0xC182, 0xE182, 0xE382, 0xE582, 0xEC82, 0x4083, 0x4283,
+ 0x4483, 0x4683, 0x4883, 0x6283, 0x8383, 0x8583, 0x8783, 0x8E83, 0x9583, 0x9683, 0x5B81, 0x4181,
+ 0x4281, 0x7681, 0x7881, 0x4981, 0x4881, 0
};
// return max # of chars to fit maxwidth with full words, does not include
// breaking space
-int16 GfxText16::GetLongest(const char *text, int16 maxWidth, GuiResourceId orgFontId) {
+// Also adjusts text pointer to the new position for the caller
+//
+// Special cases in games:
+// Laura Bow 2 - Credits in the game menu - all the text lines start with spaces (bug #5159)
+// Act 6 Coroner questionaire - the text of all control buttons has trailing spaces
+// "Detective Ryan Hanrahan O'Riley" contains even more spaces (bug #5334)
+// Conquests of Camelot - talking with Cobb - one text box of the dialogue contains a longer word,
+// that will be broken into 2 lines (bug #5159)
+int16 GfxText16::GetLongest(const char *&textPtr, int16 maxWidth, GuiResourceId orgFontId) {
uint16 curChar = 0;
- int16 maxChars = 0, curCharCount = 0;
- uint16 width = 0;
+ const char *textStartPtr = textPtr;
+ const char *lastSpacePtr = NULL;
+ int16 lastSpaceCharCount = 0;
+ int16 curCharCount = 0, resultCharCount = 0;
+ uint16 curWidth = 0, tempWidth = 0;
GuiResourceId previousFontId = GetFontId();
int16 previousPenColor = _ports->_curPort->penClr;
@@ -162,35 +174,38 @@ int16 GfxText16::GetLongest(const char *text, int16 maxWidth, GuiResourceId orgF
if (!_font)
return 0;
- while (width <= maxWidth) {
- curChar = (*(const byte *)text++);
+ while (1) {
+ curChar = (*(const byte *)textPtr);
if (_font->isDoubleByte(curChar)) {
- curChar |= (*(const byte *)text++) << 8;
- curCharCount++;
+ curChar |= (*(const byte *)(textPtr + 1)) << 8;
}
switch (curChar) {
case 0x7C:
if (getSciVersion() >= SCI_VERSION_1_1) {
- curCharCount++;
- curCharCount += CodeProcessing(text, orgFontId, previousPenColor, false);
+ curCharCount++; textPtr++;
+ curCharCount += CodeProcessing(textPtr, orgFontId, previousPenColor, false);
continue;
}
break;
// We need to add 0xD, 0xA and 0xD 0xA to curCharCount and then exit
- // which means, we split text like
- // 'Mature, experienced software analyst available.' 0xD 0xA
- // 'Bug installation a proven speciality. "No version too clean."' (normal game text, this is from lsl2)
- // and 0xA '-------' 0xA (which is the official sierra subtitle separator)
+ // which means, we split text like for example
+ // - 'Mature, experienced software analyst available.' 0xD 0xA
+ // 'Bug installation a proven speciality. "No version too clean."' (normal game text, this is from lsl2)
+ // - 0xA '-------' 0xA (which is the official sierra subtitle separator) (found in multilingual versions)
// Sierra did it the same way.
case 0xD:
// Check, if 0xA is following, if so include it as well
- if ((*(const unsigned char *)text) == 0xA)
- curCharCount++;
+ if ((*(const byte *)(textPtr + 1)) == 0xA) {
+ curCharCount++; textPtr++;
+ }
// it's meant to pass through here
case 0xA:
case 0x9781: // this one is used by SQ4/japanese as line break as well
- curCharCount++;
+ curCharCount++; textPtr++;
+ if (curChar > 0xFF) {
+ curCharCount++; textPtr++;
+ }
// and it's also meant to pass through here
case 0:
SetFont(previousFontId);
@@ -198,55 +213,86 @@ int16 GfxText16::GetLongest(const char *text, int16 maxWidth, GuiResourceId orgF
return curCharCount;
case ' ':
- maxChars = curCharCount; // return count up to (but not including) breaking space
+ lastSpaceCharCount = curCharCount; // return count up to (but not including) breaking space
+ lastSpacePtr = textPtr + 1; // remember position right after the current space
break;
}
- // Sometimes this can go off the screen, like for example bug #3040161.
- // However, we only perform this for non-Japanese games, as these require
- // special handling, done after this loop.
- if (width + _font->getCharWidth(curChar) > maxWidth && g_sci->getLanguage() != Common::JA_JPN)
+ tempWidth += _font->getCharWidth(curChar);
+
+ // Width is too large? -> break out
+ if (tempWidth > maxWidth)
break;
- width += _font->getCharWidth(curChar);
- curCharCount++;
+
+ // still fits, remember width
+ curWidth = tempWidth;
+
+ // go to next character
+ curCharCount++; textPtr++;
+ if (curChar > 0xFF) {
+ // Double-Byte
+ curCharCount++; textPtr++;
+ }
}
- // Text without spaces, probably Kanji/Japanese
- if (maxChars == 0) {
- maxChars = curCharCount;
+ if (lastSpaceCharCount) {
+ // Break and at least one space was found before that
+ resultCharCount = lastSpaceCharCount;
- uint16 nextChar;
+ // additionally skip over all spaces, that are following that space, but don't count them for displaying purposes
+ textPtr = lastSpacePtr;
+ while (*textPtr == ' ')
+ textPtr++;
- // We remove the last char only, if maxWidth was actually equal width
- // before adding the last char. Otherwise we won't get the same cutting
- // as in sierra pc98 sci.
- if (maxWidth == (width - _font->getCharWidth(curChar))) {
- maxChars--;
- if (curChar > 0xFF)
- maxChars--;
- nextChar = curChar;
- } else {
- nextChar = (*(const byte *)text++);
- if (_font->isDoubleByte(nextChar))
- nextChar |= (*(const byte *)text++) << 8;
- }
- // sierra checked the following character against a punctuation kanji table
- if (nextChar > 0xFF) {
- // if the character is punctuation, we go back one character
- uint nonBreakingNr = 0;
- while (text16_punctuationSjis[nonBreakingNr]) {
- if (text16_punctuationSjis[nonBreakingNr] == nextChar) {
- maxChars--;
- if (curChar > 0xFF)
- maxChars--; // go back 2 chars, when last char was double byte
+ } else {
+ // Break without spaces found, we split the very first word - may also be Kanji/Japanese
+ if (curChar > 0xFF) {
+ // current charracter is Japanese
+
+ // PC-9801 SCI actually added the last character, which shouldn't fit anymore, still onto the
+ // screen in case maxWidth wasn't fully reached with the last character
+ if (( maxWidth - 1 ) > curWidth) {
+ curCharCount += 2; textPtr += 2;
+
+ curChar = (*(const byte *)textPtr);
+ if (_font->isDoubleByte(curChar)) {
+ curChar |= (*(const byte *)(textPtr + 1)) << 8;
+ }
+ }
+
+ // But it also checked, if the current character is not inside a punctuation table and it even
+ // went backwards in case it found multiple ones inside that table.
+ uint nonBreakingPos = 0;
+
+ while (1) {
+ // Look up if character shouldn't be the first on a new line
+ nonBreakingPos = 0;
+ while (text16_shiftJIS_punctuation[nonBreakingPos]) {
+ if (text16_shiftJIS_punctuation[nonBreakingPos] == curChar)
+ break;
+ nonBreakingPos++;
+ }
+ if (!text16_shiftJIS_punctuation[nonBreakingPos]) {
+ // character is fine
break;
}
- nonBreakingNr++;
+ // Character is not acceptable, seek backward in the text
+ curCharCount -= 2; textPtr -= 2;
+ if (textPtr < textStartPtr)
+ error("Seeking back went too far, data corruption?");
+
+ curChar = (*(const byte *)textPtr);
+ if (!_font->isDoubleByte(curChar))
+ error("Non double byte while seeking back");
+ curChar |= (*(const byte *)(textPtr + 1)) << 8;
}
}
+
+ // We split the word in that case
+ resultCharCount = curCharCount;
}
SetFont(previousFontId);
_ports->penColor(previousPenColor);
- return maxChars;
+ return resultCharCount;
}
void GfxText16::Width(const char *text, int16 from, int16 len, GuiResourceId orgFontId, int16 &textWidth, int16 &textHeight, bool restoreFont) {
@@ -303,7 +349,7 @@ void GfxText16::DrawString(const char *str, GuiResourceId orgFontId, int16 orgPe
Draw(str, 0, (int16)strlen(str), orgFontId, orgPenColor);
}
-int16 GfxText16::Size(Common::Rect &rect, const char *text, GuiResourceId fontId, int16 maxWidth) {
+int16 GfxText16::Size(Common::Rect &rect, const char *text, uint16 languageSplitter, GuiResourceId fontId, int16 maxWidth) {
GuiResourceId previousFontId = GetFontId();
int16 previousPenColor = _ports->_curPort->penClr;
int16 charCount;
@@ -315,12 +361,12 @@ int16 GfxText16::Size(Common::Rect &rect, const char *text, GuiResourceId fontId
else
fontId = previousFontId;
- if (g_sci->getLanguage() == Common::JA_JPN)
- SwitchToFont900OnSjis(text);
-
rect.top = rect.left = 0;
if (maxWidth < 0) { // force output as single line
+ if (g_sci->getLanguage() == Common::JA_JPN)
+ SwitchToFont900OnSjis(text, languageSplitter);
+
StringWidth(text, fontId, textWidth, textHeight);
rect.bottom = textHeight;
rect.right = textWidth;
@@ -328,17 +374,20 @@ int16 GfxText16::Size(Common::Rect &rect, const char *text, GuiResourceId fontId
// rect.right=found widest line with RTextWidth and GetLongest
// rect.bottom=num. lines * GetPointSize
rect.right = (maxWidth ? maxWidth : 192);
- const char *curPos = text;
- while (*curPos) {
- charCount = GetLongest(curPos, rect.right, fontId);
+ const char *curTextPos = text; // in work position for GetLongest()
+ const char *curTextLine = text; // starting point of current line
+ while (*curTextPos) {
+ // We need to check for Shift-JIS every line
+ if (g_sci->getLanguage() == Common::JA_JPN)
+ SwitchToFont900OnSjis(curTextPos, languageSplitter);
+
+ charCount = GetLongest(curTextPos, rect.right, fontId);
if (charCount == 0)
break;
- Width(curPos, 0, charCount, fontId, textWidth, textHeight, false);
+ Width(curTextLine, 0, charCount, fontId, textWidth, textHeight, false);
maxTextWidth = MAX(textWidth, maxTextWidth);
totalHeight += textHeight;
- curPos += charCount;
- while (*curPos == ' ')
- curPos++; // skip over breaking spaces
+ curTextLine = curTextPos;
}
rect.bottom = totalHeight;
rect.right = maxWidth ? maxWidth : MIN(rect.right, maxTextWidth);
@@ -405,34 +454,38 @@ void GfxText16::Show(const char *text, int16 from, int16 len, GuiResourceId orgF
}
// Draws a text in rect.
-void GfxText16::Box(const char *text, bool show, const Common::Rect &rect, TextAlignment alignment, GuiResourceId fontId) {
+void GfxText16::Box(const char *text, uint16 languageSplitter, bool show, const Common::Rect &rect, TextAlignment alignment, GuiResourceId fontId) {
int16 textWidth, maxTextWidth, textHeight, charCount;
int16 offset = 0;
int16 hline = 0;
GuiResourceId previousFontId = GetFontId();
int16 previousPenColor = _ports->_curPort->penClr;
bool doubleByteMode = false;
+ const char *curTextPos = text;
+ const char *curTextLine = text;
if (fontId != -1)
SetFont(fontId);
else
fontId = previousFontId;
- if (g_sci->getLanguage() == Common::JA_JPN) {
- if (SwitchToFont900OnSjis(text))
- doubleByteMode = true;
- }
-
// Reset reference code rects
_codeRefRects.clear();
_codeRefTempRect.left = _codeRefTempRect.top = -1;
maxTextWidth = 0;
- while (*text) {
- charCount = GetLongest(text, rect.width(), fontId);
+ while (*curTextPos) {
+ // We need to check for Shift-JIS every line
+ // Police Quest 2 PC-9801 often draws English + Japanese text during the same call
+ if (g_sci->getLanguage() == Common::JA_JPN) {
+ if (SwitchToFont900OnSjis(curTextPos, languageSplitter))
+ doubleByteMode = true;
+ }
+
+ charCount = GetLongest(curTextPos, rect.width(), fontId);
if (charCount == 0)
break;
- Width(text, 0, charCount, fontId, textWidth, textHeight, true);
+ Width(curTextLine, 0, charCount, fontId, textWidth, textHeight, true);
maxTextWidth = MAX<int16>(maxTextWidth, textWidth);
switch (alignment) {
case SCI_TEXT16_ALIGNMENT_RIGHT:
@@ -451,15 +504,13 @@ void GfxText16::Box(const char *text, bool show, const Common::Rect &rect, TextA
_ports->moveTo(rect.left + offset, rect.top + hline);
if (show) {
- Show(text, 0, charCount, fontId, previousPenColor);
+ Show(curTextLine, 0, charCount, fontId, previousPenColor);
} else {
- Draw(text, 0, charCount, fontId, previousPenColor);
+ Draw(curTextLine, 0, charCount, fontId, previousPenColor);
}
hline += textHeight;
- text += charCount;
- while (*text == ' ')
- text++; // skip over breaking spaces
+ curTextLine = curTextPos;
}
SetFont(previousFontId);
_ports->penColor(previousPenColor);
@@ -521,11 +572,13 @@ void GfxText16::DrawStatus(const char *text) {
// Sierra did this in their PC98 interpreter only, they identify a text as being
// sjis and then switch to font 900
-bool GfxText16::SwitchToFont900OnSjis(const char *text) {
+bool GfxText16::SwitchToFont900OnSjis(const char *text, uint16 languageSplitter) {
byte firstChar = (*(const byte *)text++);
- if (((firstChar >= 0x81) && (firstChar <= 0x9F)) || ((firstChar >= 0xE0) && (firstChar <= 0xEF))) {
- SetFont(900);
- return true;
+ if (languageSplitter != 0x6a23) { // #j prefix as language splitter
+ if (((firstChar >= 0x81) && (firstChar <= 0x9F)) || ((firstChar >= 0xE0) && (firstChar <= 0xEF))) {
+ SetFont(900);
+ return true;
+ }
}
return false;
}
@@ -554,9 +607,9 @@ reg_t GfxText16::allocAndFillReferenceRectArray() {
return NULL_REG;
}
-void GfxText16::kernelTextSize(const char *text, int16 font, int16 maxWidth, int16 *textWidth, int16 *textHeight) {
+void GfxText16::kernelTextSize(const char *text, uint16 languageSplitter, int16 font, int16 maxWidth, int16 *textWidth, int16 *textHeight) {
Common::Rect rect(0, 0, 0, 0);
- Size(rect, text, font, maxWidth);
+ Size(rect, text, languageSplitter, font, maxWidth);
*textWidth = rect.width();
*textHeight = rect.height();
}
diff --git a/engines/sci/graphics/text16.h b/engines/sci/graphics/text16.h
index ab0cb13a64..2724d97347 100644
--- a/engines/sci/graphics/text16.h
+++ b/engines/sci/graphics/text16.h
@@ -51,15 +51,20 @@ public:
void ClearChar(int16 chr);
- int16 GetLongest(const char *text, int16 maxWidth, GuiResourceId orgFontId);
+ int16 GetLongest(const char *&text, int16 maxWidth, GuiResourceId orgFontId);
void Width(const char *text, int16 from, int16 len, GuiResourceId orgFontId, int16 &textWidth, int16 &textHeight, bool restoreFont);
void StringWidth(const char *str, GuiResourceId orgFontId, int16 &textWidth, int16 &textHeight);
void ShowString(const char *str, GuiResourceId orgFontId, int16 orgPenColor);
void DrawString(const char *str, GuiResourceId orgFontId, int16 orgPenColor);
- int16 Size(Common::Rect &rect, const char *text, GuiResourceId fontId, int16 maxWidth);
+ int16 Size(Common::Rect &rect, const char *text, uint16 textLanguage, GuiResourceId fontId, int16 maxWidth);
void Draw(const char *text, int16 from, int16 len, GuiResourceId orgFontId, int16 orgPenColor);
void Show(const char *text, int16 from, int16 len, GuiResourceId orgFontId, int16 orgPenColor);
- void Box(const char *text, bool show, const Common::Rect &rect, TextAlignment alignment, GuiResourceId fontId);
+ void Box(const char *text, uint16 languageSplitter, bool show, const Common::Rect &rect, TextAlignment alignment, GuiResourceId fontId);
+
+ void Box(const char *text, bool show, const Common::Rect &rect, TextAlignment alignment, GuiResourceId fontId) {
+ Box(text, 0, show, rect, alignment, fontId);
+ }
+
void DrawString(const char *text);
void DrawStatus(const char *text);
@@ -67,13 +72,13 @@ public:
reg_t allocAndFillReferenceRectArray();
- void kernelTextSize(const char *text, int16 font, int16 maxWidth, int16 *textWidth, int16 *textHeight);
+ void kernelTextSize(const char *text, uint16 textLanguage, int16 font, int16 maxWidth, int16 *textWidth, int16 *textHeight);
void kernelTextFonts(int argc, reg_t *argv);
void kernelTextColors(int argc, reg_t *argv);
private:
void init();
- bool SwitchToFont900OnSjis(const char *text);
+ bool SwitchToFont900OnSjis(const char *text, uint16 languageSplitter);
GfxCache *_cache;
GfxPorts *_ports;
diff --git a/engines/sci/graphics/transitions.cpp b/engines/sci/graphics/transitions.cpp
index 5e7dbc6c15..ccc7a4389a 100644
--- a/engines/sci/graphics/transitions.cpp
+++ b/engines/sci/graphics/transitions.cpp
@@ -339,10 +339,10 @@ void GfxTransitions::pixelation(bool blackoutFlag) {
do {
mask = (mask & 1) ? (mask >> 1) ^ 0xB400 : mask >> 1;
- if (mask >= _screen->getWidth() * _screen->getHeight())
+ if (mask >= _screen->getScriptWidth() * _screen->getScriptHeight())
continue;
- pixelRect.left = mask % _screen->getWidth(); pixelRect.right = pixelRect.left + 1;
- pixelRect.top = mask / _screen->getWidth(); pixelRect.bottom = pixelRect.top + 1;
+ pixelRect.left = mask % _screen->getScriptWidth(); pixelRect.right = pixelRect.left + 1;
+ pixelRect.top = mask / _screen->getScriptWidth(); pixelRect.bottom = pixelRect.top + 1;
pixelRect.clip(_picRect);
if (!pixelRect.isEmpty())
copyRectToScreen(pixelRect, blackoutFlag);
diff --git a/engines/sci/graphics/view.cpp b/engines/sci/graphics/view.cpp
index f3f352e5b8..da61ecf4c3 100644
--- a/engines/sci/graphics/view.cpp
+++ b/engines/sci/graphics/view.cpp
@@ -283,6 +283,7 @@ void GfxView::initData(GuiResourceId resourceId) {
_isScaleable = false;
break;
case 0x40:
+ case 0x4F: // LSL6 Polish, seems to be garbage - bug #6718
case 0:
break; // don't do anything, we already have _isScaleable set
default:
@@ -366,7 +367,7 @@ void GfxView::initData(GuiResourceId resourceId) {
default:
error("ViewType was not detected, can't continue");
}
-
+
// Inject our own views
// Currently only used for Dual mode (speech + text) for games, that do not have a "dual" icon already
// Which is Laura Bow 2 + King's Quest 6
diff --git a/engines/sci/module.mk b/engines/sci/module.mk
index 6b6058c819..33392e3b42 100644
--- a/engines/sci/module.mk
+++ b/engines/sci/module.mk
@@ -76,8 +76,8 @@ MODULE_OBJS := \
sound/drivers/midi.o \
sound/drivers/pcjr.o \
video/seq_decoder.o
-
-
+
+
ifdef ENABLE_SCI32
MODULE_OBJS += \
engine/kgraphics32.o \
diff --git a/engines/sci/parser/vocabulary.cpp b/engines/sci/parser/vocabulary.cpp
index 3344b79e26..000b037b44 100644
--- a/engines/sci/parser/vocabulary.cpp
+++ b/engines/sci/parser/vocabulary.cpp
@@ -535,10 +535,7 @@ bool Vocabulary::tokenizeString(ResultWordListList &retval, const char *sentence
if (Common::isAlnum(c) || (c == '-' && wordLen) || (c >= 0x80)) {
currentWord[wordLen] = lowerCaseMap[c];
++wordLen;
- } else if (c == '\'' && wordLen && (sentence[pos_in_sentence] == 's' || sentence[pos_in_sentence] == 'S')) {
- // Skip apostrophe-s at the end of the word, if it exists
- pos_in_sentence++; // skip the 's'
- } else {
+ } else if (c == ' ' || c == '\0') {
// Continue on this word. Words may contain a '-', but may not start with
// one.
diff --git a/engines/sci/resource.cpp b/engines/sci/resource.cpp
index 17195c14b8..10740a8b7b 100644
--- a/engines/sci/resource.cpp
+++ b/engines/sci/resource.cpp
@@ -55,6 +55,11 @@ SciVersion getSciVersion() {
return s_sciVersion;
}
+SciVersion getSciVersionForDetection() {
+ assert(!g_sci);
+ return s_sciVersion;
+}
+
const char *getSciVersionDesc(SciVersion version) {
switch (version) {
case SCI_VERSION_NONE:
@@ -88,9 +93,6 @@ const char *getSciVersionDesc(SciVersion version) {
//////////////////////////////////////////////////////////////////////
-
-#undef SCI_REQUIRE_RESOURCE_FILES
-
//#define SCI_VERBOSE_RESMAN 1
static const char *const s_errorDescriptions[] = {
@@ -639,7 +641,7 @@ int ResourceManager::addAppropriateSources() {
return 1;
}
-int ResourceManager::addAppropriateSources(const Common::FSList &fslist) {
+int ResourceManager::addAppropriateSourcesForDetection(const Common::FSList &fslist) {
ResourceSource *map = 0;
Common::Array<ResourceSource *> sci21Maps;
@@ -858,7 +860,7 @@ void ResourceManager::freeResourceSources() {
ResourceManager::ResourceManager() {
}
-void ResourceManager::init(bool initFromFallbackDetector) {
+void ResourceManager::init() {
_memoryLocked = 0;
_memoryLRU = 0;
_LRU.clear();
@@ -890,25 +892,24 @@ void ResourceManager::init(bool initFromFallbackDetector) {
debugC(1, kDebugLevelResMan, "resMan: Detected volume version %d: %s", _volVersion, versionDescription(_volVersion));
if ((_mapVersion == kResVersionUnknown) && (_volVersion == kResVersionUnknown)) {
- warning("Volume and map version not detected, assuming that this is not a sci game");
+ warning("Volume and map version not detected, assuming that this is not a SCI game");
_viewType = kViewUnknown;
return;
}
scanNewSources();
- if (!initFromFallbackDetector) {
- if (!addAudioSources()) {
- // FIXME: This error message is not always correct.
- // OTOH, it is nice to be able to detect missing files/sources
- // So we should definitely fix addAudioSources so this error
- // only pops up when necessary. Disabling for now.
- //error("Somehow I can't seem to find the sound files I need (RESOURCE.AUD/RESOURCE.SFX), aborting");
- }
- addScriptChunkSources();
- scanNewSources();
+ if (!addAudioSources()) {
+ // FIXME: This error message is not always correct.
+ // OTOH, it is nice to be able to detect missing files/sources
+ // So we should definitely fix addAudioSources so this error
+ // only pops up when necessary. Disabling for now.
+ //error("Somehow I can't seem to find the sound files I need (RESOURCE.AUD/RESOURCE.SFX), aborting");
}
+ addScriptChunkSources();
+ scanNewSources();
+
detectSciVersion();
debugC(1, kDebugLevelResMan, "resMan: Detected %s", getSciVersionDesc(getSciVersion()));
@@ -943,6 +944,22 @@ void ResourceManager::init(bool initFromFallbackDetector) {
}
}
+void ResourceManager::initForDetection() {
+ assert(!g_sci);
+
+ _memoryLocked = 0;
+ _memoryLRU = 0;
+ _LRU.clear();
+ _resMap.clear();
+ _audioMapSCI1 = NULL;
+
+ _mapVersion = detectMapVersion();
+ _volVersion = detectVolVersion();
+
+ scanNewSources();
+ detectSciVersion();
+}
+
ResourceManager::~ResourceManager() {
// freeing resources
ResourceMap::iterator itr = _resMap.begin();
@@ -1645,6 +1662,9 @@ int ResourceManager::readResourceMapSCI1(ResourceSource *map) {
do {
type = fileStream->readByte() & 0x1F;
resMap[type].wOffset = fileStream->readUint16LE();
+ if (fileStream->eos())
+ return SCI_ERROR_RESMAP_NOT_FOUND;
+
resMap[prevtype].wSize = (resMap[type].wOffset
- resMap[prevtype].wOffset) / nEntrySize;
prevtype = type;
@@ -2330,6 +2350,9 @@ bool ResourceManager::detectPaletteMergingSci11() {
// Old palette format used in palette resource? -> it's merging
if ((data[0] == 0 && data[1] == 1) || (data[0] == 0 && data[1] == 0 && READ_LE_UINT16(data + 29) == 0))
return true;
+ // Hardcoded: Laura Bow 2 floppy uses new palette resource, but still palette merging + 16 bit color matching
+ if ((g_sci->getGameId() == GID_LAURABOW2) && (!g_sci->isCD()) && (!g_sci->isDemo()))
+ return true;
return false;
}
return false;
diff --git a/engines/sci/resource.h b/engines/sci/resource.h
index e90f52a3ce..62f3c584ac 100644
--- a/engines/sci/resource.h
+++ b/engines/sci/resource.h
@@ -312,10 +312,22 @@ public:
/**
* Initializes the resource manager.
*/
- void init(bool initFromFallbackDetector = false);
+ void init();
+ /**
+ * Similar to the function above, only called from the fallback detector
+ */
+ void initForDetection();
+
+ /**
+ * Adds all of the resource files for a game
+ */
int addAppropriateSources();
- int addAppropriateSources(const Common::FSList &fslist); // TODO: Switch from FSList to Common::Archive?
+
+ /**
+ * Similar to the function above, only called from the fallback detector
+ */
+ int addAppropriateSourcesForDetection(const Common::FSList &fslist); // TODO: Switch from FSList to Common::Archive?
/**
* Looks up a resource's data.
diff --git a/engines/sci/resource_audio.cpp b/engines/sci/resource_audio.cpp
index 4c7cd9b84a..c775f502c5 100644
--- a/engines/sci/resource_audio.cpp
+++ b/engines/sci/resource_audio.cpp
@@ -110,7 +110,7 @@ bool Resource::loadFromAudioVolumeSCI11(Common::SeekableReadStream *file) {
unalloc();
return false;
}
-
+
_headerSize = file->readByte();
if (type == kResourceTypeAudio) {
@@ -710,7 +710,6 @@ SoundResource::SoundResource(uint32 resourceNr, ResourceManager *resMan, SciVers
// 0x20 is set on rhythm channels to prevent remapping
// CHECKME: Which SCI versions need that set manually?
- channel->flags = (*channel->data) >> 4;
if (channel->number == 9)
channel->flags |= 2;
// Note: flag 1: channel start offset is 0 instead of 10
diff --git a/engines/sci/sci.cpp b/engines/sci/sci.cpp
index fc723f18cf..60a1271b89 100644
--- a/engines/sci/sci.cpp
+++ b/engines/sci/sci.cpp
@@ -219,7 +219,7 @@ Common::Error SciEngine::run() {
// Add the after market GM patches for the specified game, if they exist
_resMan->addNewGMPatch(_gameId);
_gameObjectAddress = _resMan->findGameObject();
-
+
_scriptPatcher = new ScriptPatcher();
SegManager *segMan = new SegManager(_resMan, _scriptPatcher);
@@ -896,7 +896,7 @@ void SciEngine::syncSoundSettings() {
bool SciEngine::speechAndSubtitlesEnabled() {
bool subtitlesOn = ConfMan.getBool("subtitles");
bool speechOn = !ConfMan.getBool("speech_mute");
-
+
if (isCD() && subtitlesOn && speechOn)
return true;
return false;
@@ -936,7 +936,7 @@ void SciEngine::updateScummVMAudioOptions() {
// depending on the in-game settings
if (isCD() && getSciVersion() == SCI_VERSION_1_1) {
uint16 ingameSetting = _gamestate->variables[VAR_GLOBAL][90].getOffset();
-
+
switch (ingameSetting) {
case 1:
// subtitles
diff --git a/engines/sci/sci.h b/engines/sci/sci.h
index 48bc4819d2..4928fd1b4e 100644
--- a/engines/sci/sci.h
+++ b/engines/sci/sci.h
@@ -314,13 +314,16 @@ public:
* if NULL is passed no subtitle will be added to the returned string
* @return processed string
*/
- Common::String strSplit(const char *str, const char *sep = "\r----------\r");
+ Common::String strSplitLanguage(const char *str, uint16 *splitLanguage, const char *sep = "\r----------\r");
+ Common::String strSplit(const char *str, const char *sep = "\r----------\r") {
+ return strSplitLanguage(str, NULL, sep);
+ }
kLanguage getSciLanguage();
void setSciLanguage(kLanguage lang);
void setSciLanguage();
- Common::String getSciLanguageString(const Common::String &str, kLanguage lang, kLanguage *lang2 = NULL) const;
+ Common::String getSciLanguageString(const Common::String &str, kLanguage lang, kLanguage *lang2 = NULL, uint16 *languageSplitter = NULL) const;
// Check if vocabulary needs to get switched (in multilingual parser games)
void checkVocabularySwitch();
@@ -429,6 +432,12 @@ extern SciEngine *g_sci;
SciVersion getSciVersion();
/**
+ * Same as above, but this version doesn't assert on unknown SCI versions.
+ * Only used by the fallback detector
+ */
+SciVersion getSciVersionForDetection();
+
+/**
* Convenience function converting an SCI version into a human-readable string.
*/
const char *getSciVersionDesc(SciVersion version);
diff --git a/engines/sci/sound/drivers/midi.cpp b/engines/sci/sound/drivers/midi.cpp
index 80a72b9a6f..baf85de74c 100644
--- a/engines/sci/sound/drivers/midi.cpp
+++ b/engines/sci/sound/drivers/midi.cpp
@@ -399,24 +399,42 @@ void MidiPlayer_Midi::playSwitch(bool play) {
}
bool MidiPlayer_Midi::isMt32GmPatch(const byte *data, int size) {
- if (size < 1155)
+ // WORKAROUND: Some Mac games (e.g. LSL5) may have an extra byte at the
+ // end, so compensate for that here - bug #6725.
+ if (size == 16890)
+ size--;
+
+ // Need at least 1153 + 2 bytes for a GM patch. Check readMt32GmPatch()
+ // below for more info.
+ if (size < 1153 + 2)
return false;
+ // The maximum number of bytes for an MT-32 patch is 16889. The maximum
+ // number of timbres is 64, which leads us to:
+ // 491 + 1 + 64 * 246 + 653 = 16889
if (size > 16889)
return true;
bool isMt32 = false;
bool isMt32Gm = false;
+ // First, check for a GM patch. The presence of MIDI data after the
+ // initial 1153 + 2 bytes indicates a GM patch
if (READ_LE_UINT16(data + 1153) + 1155 == size)
isMt32Gm = true;
- int pos = 492 + 246 * data[491];
+ // Now check for a regular MT-32 patch. Check readMt32Patch() below for
+ // more info.
+ // 491 = 20 + 20 + 20 + 2 + 1 + 11 + 3 * 11 + 256 + 128
+ byte timbresNr = data[491];
+ int pos = 492 + 246 * timbresNr;
+ // Patches 49-96
if ((size >= (pos + 386)) && (READ_BE_UINT16(data + pos) == 0xabcd))
- pos += 386;
+ pos += 386; // 256 + 128 + 2
+ // Rhythm key map + partial reserve
if ((size >= (pos + 267)) && (READ_BE_UINT16(data + pos) == 0xdcba))
- pos += 267;
+ pos += 267; // 256 + 9 + 2
if (size == pos)
isMt32 = true;
@@ -460,10 +478,28 @@ void MidiPlayer_Midi::sendMt32SysEx(const uint32 addr, const byte *buf, int len,
}
void MidiPlayer_Midi::readMt32Patch(const byte *data, int size) {
+ // MT-32 patch contents:
+ // - 20 bytes unkown
+ // - 20 bytes before-SysEx message
+ // - 20 bytes goodbye SysEx message
+ // - 2 bytes volume
+ // - 1 byte reverb
+ // - 11 bytes reverb Sysex message
+ // - 3 * 11 reverb data
+ // - 256 + 128 bytes patches 1-48
+ // --> total: 491 bytes
+ // - 1 byte number of timbres (64 max)
+ // - 246 * timbres timbre data
+ // - 2 bytes flag (0xabcd)
+ // - 256 + 128 bytes patches 49-96
+ // - 2 bytes flag (0xdcba)
+ // - 256 bytes rhythm key map
+ // - 9 bytes partial reserve
+
Common::MemoryReadStream *str = new Common::MemoryReadStream(data, size);
// Send before-SysEx text
- str->seek(0x14);
+ str->seek(20);
sendMt32SysEx(0x200000, str, 20);
// Save goodbye message
@@ -527,15 +563,25 @@ void MidiPlayer_Midi::readMt32Patch(const byte *data, int size) {
}
void MidiPlayer_Midi::readMt32GmPatch(const byte *data, int size) {
- memcpy(_patchMap, data, 0x80);
- memcpy(_keyShift, data + 0x80, 0x80);
- memcpy(_volAdjust, data + 0x100, 0x80);
- memcpy(_percussionMap, data + 0x180, 0x80);
- _channels[MIDI_RHYTHM_CHANNEL].volAdjust = data[0x200];
- memcpy(_velocityMapIdx, data + 0x201, 0x80);
- memcpy(_velocityMap, data + 0x281, 0x200);
-
- uint16 midiSize = READ_LE_UINT16(data + 0x481);
+ // GM patch contents:
+ // - 128 bytes patch map
+ // - 128 bytes key shift
+ // - 128 bytes volume adjustment
+ // - 128 bytes percussion map
+ // - 1 byte volume adjust for the rhythm channel
+ // - 128 bytes velocity map IDs
+ // - 512 bytes velocity map
+ // --> total: 1153 bytes
+
+ memcpy(_patchMap, data, 128);
+ memcpy(_keyShift, data + 128, 128);
+ memcpy(_volAdjust, data + 256, 128);
+ memcpy(_percussionMap, data + 384, 128);
+ _channels[MIDI_RHYTHM_CHANNEL].volAdjust = data[512];
+ memcpy(_velocityMapIdx, data + 513, 128);
+ memcpy(_velocityMap, data + 641, 512);
+
+ uint16 midiSize = READ_LE_UINT16(data + 1153);
if (midiSize > 0) {
if (size < midiSize + 1155)
diff --git a/engines/sci/sound/music.cpp b/engines/sci/sound/music.cpp
index 362cca699d..7a6eaf62b4 100644
--- a/engines/sci/sound/music.cpp
+++ b/engines/sci/sound/music.cpp
@@ -142,7 +142,7 @@ void SciMusic::init() {
_driverLastChannel = _pMidiDrv->getLastChannel();
if (getSciVersion() <= SCI_VERSION_0_LATE)
_globalReverb = _pMidiDrv->getReverb(); // Init global reverb for SCI0
-
+
_currentlyPlayingSample = NULL;
}
diff --git a/engines/sci/sound/music.h b/engines/sci/sound/music.h
index 6149bb799e..4e44074630 100644
--- a/engines/sci/sound/music.h
+++ b/engines/sci/sound/music.h
@@ -264,7 +264,7 @@ private:
int _driverFirstChannel;
int _driverLastChannel;
-
+
MusicEntry *_currentlyPlayingSample;
};
diff --git a/engines/scumm/POTFILES b/engines/scumm/POTFILES
index 6034320259..6d10537d3c 100644
--- a/engines/scumm/POTFILES
+++ b/engines/scumm/POTFILES
@@ -1,3 +1,6 @@
engines/scumm/dialogs.cpp
engines/scumm/help.cpp
engines/scumm/scumm.cpp
+engines/scumm/players/player_v3m.cpp
+engines/scumm/players/player_v5m.cpp
+
diff --git a/engines/scumm/actor.cpp b/engines/scumm/actor.cpp
index 116a953b0b..0d7ea39ec2 100644
--- a/engines/scumm/actor.cpp
+++ b/engines/scumm/actor.cpp
@@ -33,6 +33,7 @@
#include "scumm/resource.h"
#include "scumm/saveload.h"
#include "scumm/scumm_v7.h"
+#include "scumm/scumm_v0.h"
#include "scumm/he/sound_he.h"
#include "scumm/he/sprite_he.h"
#include "scumm/usage_bits.h"
@@ -42,12 +43,66 @@ namespace Scumm {
byte Actor::kInvalidBox = 0;
-static const byte v0ActorTalkArray[0x19] = {
- 0x00, 0x06, 0x06, 0x06, 0x06,
- 0x06, 0x06, 0x00, 0x46, 0x06,
- 0x06, 0x06, 0x06, 0xFF, 0xFF,
- 0x06, 0xC0, 0x06, 0x06, 0x00,
- 0xC0, 0xC0, 0x00, 0x06, 0x06
+static const byte v0ActorDemoTalk[25] = {
+ 0x00,
+ 0x06, // Syd
+ 0x06, // Razor
+ 0x06, // Dave
+ 0x06, // Michael
+ 0x06, // Bernard
+ 0x06, // Wendy
+ 0x00, // Jeff
+ 0x46, // Radiation Suit
+ 0x06, // Dr Fred
+ 0x06, // Nurse Edna
+ 0x06, // Weird Ed
+ 0x06, // Dead Cousin Ted
+ 0xE2, // Purple Tentacle
+ 0xE2, // Green Tentacle
+ 0x06, // Meteor police
+ 0xC0, // Meteor
+ 0x06, // Mark Eteer
+ 0x06, // Talkshow Host
+ 0x00, // Plant
+ 0xC0, // Meteor Radiation
+ 0xC0, // Edsel (small, outro)
+ 0x00, // Meteor (small, intro)
+ 0x06, // Sandy (Lab)
+ 0x06, // Sandy (Cut-Scene)
+};
+
+static const byte v0ActorTalk[25] = {
+ 0x00,
+ 0x06, // Syd
+ 0x06, // Razor
+ 0x06, // Dave
+ 0x06, // Michael
+ 0x06, // Bernard
+ 0x06, // Wendy
+ 0x00, // Jeff
+ 0x46, // Radiation Suit
+ 0x06, // Dr Fred
+ 0x06, // Nurse Edna
+ 0x06, // Weird Ed
+ 0x06, // Dead Cousin Ted
+ 0xFF, // Purple Tentacle
+ 0xFF, // Green Tentacle
+ 0x06, // Meteor police
+ 0xC0, // Meteor
+ 0x06, // Mark Eteer
+ 0x06, // Talkshow Host
+ 0x00, // Plant
+ 0xC0, // Meteor Radiation
+ 0xC0, // Edsel (small, outro)
+ 0x00, // Meteor (small, intro)
+ 0x06, // Sandy (Lab)
+ 0x06, // Sandy (Cut-Scene)
+};
+
+static const byte v0WalkboxSlantedModifier[0x16] = {
+ 0x00,0x01,0x02,0x03,0x03,0x04,0x05,0x06,
+ 0x06,0x07,0x08,0x09,0x09,0x0A,0x0B,
+ 0x0C,0x0C,0x0D,0x0E,0x0F,0x10,0x10
};
Actor::Actor(ScummEngine *scumm, int id) :
@@ -182,6 +237,20 @@ void Actor_v0::initActor(int mode) {
_costCommand = 0xFF;
_miscflags = 0;
_speaking = 0;
+
+ _walkCountModulo = 0;
+ _newWalkBoxEntered = false;
+ _walkDirX = 0;
+ _walkDirY = 0;
+ _walkYCountGreaterThanXCount = 0;
+ _walkXCount = 0;
+ _walkXCountInc = 0;
+ _walkYCount = 0;
+ _walkYCountInc = 0;
+ _walkMaxXYCountInc = 0;
+
+ _tmp_WalkBox = 0;
+ _tmp_NewWalkBoxEntered = 0;
_animFrameRepeat = 0;
for (int i = 0; i < 8; ++i) {
@@ -189,6 +258,12 @@ void Actor_v0::initActor(int mode) {
_limbFrameRepeat[i] = 0;
_limb_flipped[i] = false;
}
+
+ if (_vm->_game.features & GF_DEMO) {
+ _sound[0] = v0ActorDemoTalk[_number];
+ } else {
+ _sound[0] = v0ActorTalk[_number];
+ }
}
void Actor::setBox(int box) {
@@ -249,9 +324,12 @@ void Actor::stopActorMoving() {
if (_walkScript)
_vm->stopScript(_walkScript);
- _moving = 0;
- if (_vm->_game.version == 0)
+ if (_vm->_game.version == 0) {
+ _moving = 2;
setDirection(_facing);
+ } else {
+ _moving = 0;
+ }
}
void Actor::setActorWalkSpeed(uint newSpeedX, uint newSpeedY) {
@@ -339,9 +417,6 @@ int Actor::actorWalkStep() {
int distX, distY;
int nextFacing;
- if (_vm->_game.version == 0)
- ((Actor_v0 *)this)->_animFrameRepeat = -1;
-
_needRedraw = true;
nextFacing = updateActorDirection(true);
@@ -350,10 +425,6 @@ int Actor::actorWalkStep() {
startWalkAnim(1, nextFacing);
}
_moving |= MF_IN_LEG;
-
- // V0: Don't move during the turn
- if (_vm->_game.version == 0)
- return 0;
}
if (_walkbox != _walkdata.curbox && _vm->checkXYInBoxBounds(_walkdata.curbox, _pos.x, _pos.y)) {
@@ -368,13 +439,28 @@ int Actor::actorWalkStep() {
return 0;
}
- tmpX = (_pos.x << 16) + _walkdata.xfrac + (_walkdata.deltaXFactor >> 8) * _scalex;
- _walkdata.xfrac = (uint16)tmpX;
- _pos.x = (tmpX >> 16);
+ if (_vm->_game.version <= 2) {
+ if (_walkdata.deltaXFactor != 0) {
+ if (_walkdata.deltaXFactor > 0)
+ _pos.x += 1;
+ else
+ _pos.x -= 1;
+ }
+ if (_walkdata.deltaYFactor != 0) {
+ if (_walkdata.deltaYFactor > 0)
+ _pos.y += 1;
+ else
+ _pos.y -= 1;
+ }
+ } else {
+ tmpX = (_pos.x << 16) + _walkdata.xfrac + (_walkdata.deltaXFactor >> 8) * _scalex;
+ _walkdata.xfrac = (uint16)tmpX;
+ _pos.x = (tmpX >> 16);
- tmpY = (_pos.y << 16) + _walkdata.yfrac + (_walkdata.deltaYFactor >> 8) * _scaley;
- _walkdata.yfrac = (uint16)tmpY;
- _pos.y = (tmpY >> 16);
+ tmpY = (_pos.y << 16) + _walkdata.yfrac + (_walkdata.deltaYFactor >> 8) * _scaley;
+ _walkdata.yfrac = (uint16)tmpY;
+ _pos.y = (tmpY >> 16);
+ }
if (ABS(_pos.x - _walkdata.cur.x) > distX) {
_pos.x = _walkdata.next.x;
@@ -384,17 +470,118 @@ int Actor::actorWalkStep() {
_pos.y = _walkdata.next.y;
}
- if (_vm->_game.version >= 4 && _vm->_game.version <= 6 && _pos == _walkdata.next) {
+ if ((_vm->_game.version <= 2 || (_vm->_game.version >= 4 && _vm->_game.version <= 6)) && _pos == _walkdata.next) {
_moving &= ~MF_IN_LEG;
return 0;
}
- if (_vm->_game.version == 0)
- ((Actor_v0 *)this)->animateActor(newDirToOldDir(_facing));
-
return 1;
}
+bool Actor_v0::calcWalkDistances() {
+ _walkDirX = 0;
+ _walkDirY = 0;
+ _walkYCountGreaterThanXCount = 0;
+ uint16 A = 0;
+
+ if (_CurrentWalkTo.x >= _tmp_Dest.x) {
+ A = _CurrentWalkTo.x - _tmp_Dest.x;
+ _walkDirX = 1;
+ } else {
+ A = _tmp_Dest.x - _CurrentWalkTo.x;
+ }
+
+ _walkXCountInc = A;
+
+ if (_CurrentWalkTo.y >= _tmp_Dest.y) {
+ A = _CurrentWalkTo.y - _tmp_Dest.y;
+ _walkDirY = 1;
+ } else {
+ A = _tmp_Dest.y - _CurrentWalkTo.y;
+ }
+
+ _walkYCountInc = A;
+ if (!_walkXCountInc && !_walkYCountInc)
+ return true;
+
+ if (_walkXCountInc <= _walkYCountInc)
+ _walkYCountGreaterThanXCount = 1;
+
+ // 2FCC
+ A = _walkXCountInc;
+ if (A <= _walkYCountInc)
+ A = _walkYCountInc;
+
+ _walkMaxXYCountInc = A;
+ _walkXCount = _walkXCountInc;
+ _walkYCount = _walkYCountInc;
+ _walkCountModulo = _walkMaxXYCountInc;
+
+ return false;
+}
+
+byte Actor_v0::actorWalkX() {
+ byte A = _walkXCount;
+ A += _walkXCountInc;
+ if (A >= _walkCountModulo) {
+ if (!_walkDirX) {
+ _tmp_Dest.x--;
+ } else {
+ _tmp_Dest.x++;
+ }
+
+ A -= _walkCountModulo;
+ }
+ // 2EAC
+ _walkXCount = A;
+ setTmpFromActor();
+ if (updateWalkbox() == kInvalidBox) {
+ // 2EB9
+ setActorFromTmp();
+
+ return 3;
+ }
+ // 2EBF
+ if (_tmp_Dest.x == _CurrentWalkTo.x)
+ return 1;
+
+ return 0;
+}
+
+byte Actor_v0::actorWalkY() {
+ byte A = _walkYCount;
+ A += _walkYCountInc;
+ if (A >= _walkCountModulo) {
+ if (!_walkDirY) {
+ _tmp_Dest.y--;
+ } else {
+ _tmp_Dest.y++;
+ }
+
+ A -= _walkCountModulo;
+ }
+ // 2EEB
+ _walkYCount = A;
+ setTmpFromActor();
+ if (updateWalkbox() == kInvalidBox) {
+ // 2EF8
+ setActorFromTmp();
+ return 4;
+ }
+ // 2EFE
+ if (_walkYCountInc != 0) {
+ if (_walkYCountInc == 0xFF) {
+ setActorFromTmp();
+ return 4;
+ }
+ }
+ // 2F0D
+ if (_CurrentWalkTo.y == _tmp_Dest.y)
+ return 1;
+
+ return 0;
+}
+
void Actor::startWalkActor(int destX, int destY, int dir) {
AdjustBoxResult abr;
@@ -447,9 +634,16 @@ void Actor::startWalkActor(int destX, int destY, int dir) {
_walkdata.dest.y = abr.y;
_walkdata.destbox = abr.box;
_walkdata.destdir = dir;
- _moving = (_moving & MF_IN_LEG) | MF_NEW_LEG;
- _walkdata.point3.x = 32000;
+
+ if (_vm->_game.version == 0) {
+ ((Actor_v0*)this)->_newWalkBoxEntered = true;
+ } else if (_vm->_game.version <= 2) {
+ _moving = (_moving & ~(MF_LAST_LEG | MF_IN_LEG)) | MF_NEW_LEG;
+ } else {
+ _moving = (_moving & MF_IN_LEG) | MF_NEW_LEG;
+ }
+ _walkdata.point3.x = 32000;
_walkdata.curbox = _walkbox;
}
@@ -567,88 +761,206 @@ void Actor::walkActor() {
calcMovementFactor(_walkdata.dest);
}
-bool Actor_v2::checkWalkboxesHaveDirectPath(Common::Point &foundPath) {
- // only MM v0 supports walking in direct line between walkboxes.
- // MM v1 already does not support it anymore.
- return false;
-}
+void Actor_v0::walkActor() {
+ actorSetWalkTo();
-bool Actor_v0::intersectLineSegments(const Common::Point &line1Start, const Common::Point &line1End,
- const Common::Point &line2Start, const Common::Point &line2End, Common::Point &result)
-{
- const Common::Point v1 = line1End - line1Start; // line1(n1) = line1Start + n1 * v1
- const Common::Point v2 = line2End - line2Start; // line2(n2) = line2Start + n2 * v2
+ _needRedraw = true;
+ if (_NewWalkTo != _CurrentWalkTo) {
+ _CurrentWalkTo = _NewWalkTo;
- double det = v2.x * v1.y - v1.x * v2.y;
- if (det == 0)
- return false;
+L2A33:;
+ _moving &= 0xF0;
+ _tmp_Dest = _pos;
- double n1 = ((double)v2.x * (line2Start.y - line1Start.y) -
- (double)v2.y * (line2Start.x - line1Start.x)) / det;
- double n2 = ((double)v1.x * (line2Start.y - line1Start.y) -
- (double)v1.y * (line2Start.x - line1Start.x)) / det;
+ byte tmp = calcWalkDistances();
+ _moving &= 0xF0;
+ _moving |= tmp;
- // both coefficients have to be in [0, 1], otherwise the intersection is
- // not inside of at least one of the two line segments
- if (n1 < 0.0 || n1 > 1.0 || n2 < 0.0 || n2 > 1.0)
- return false;
+ if (!_walkYCountGreaterThanXCount) {
+ if (_walkDirX) {
+ _targetFacing = getAngleFromPos(V12_X_MULTIPLIER*1, V12_Y_MULTIPLIER*0, false);
+ } else {
+ _targetFacing = getAngleFromPos(V12_X_MULTIPLIER*-1, V12_Y_MULTIPLIER*0, false);
+ }
+ } else {
+ if (_walkDirY) {
+ _targetFacing = getAngleFromPos(V12_X_MULTIPLIER*0, V12_Y_MULTIPLIER*1, false);
+ } else {
+ _targetFacing = getAngleFromPos(V12_X_MULTIPLIER*0, V12_Y_MULTIPLIER*-1, false);
+ }
+ }
- result.x = line1Start.x + (int)(n1 * v1.x);
- result.y = line1Start.y + (int)(n1 * v1.y);
- return true;
-}
+ directionUpdate();
+
+ if (_moving & 0x80)
+ return;
-/*
- * MM v0 allows the actor to walk in a direct line between boxes to the target
- * if actor and target share a horizontal or vertical corridor.
- * If such a corridor is found the actor is not forced to go horizontally or
- * vertically from one box to the next but can also walk diagonally.
- *
- * Note: the original v0 interpreter sets the target destination for diagonal
- * walking only once and then rechecks whenever the actor reaches a new box if the
- * walk destination is still suitable for the current box.
- * ScummVM does not perform such a check, so it is possible to leave the walkboxes
- * in some cases, for example L-shaped rooms like the swimming pool (actor walks over water)
- * or the medical room (actor walks over examination table).
- * To solve this we intersect the new walk destination with the actor's walkbox borders,
- * so a recheck is done when the actor leaves his box. This is done by the
- * intersectLineSegments() routine calls.
- */
-bool Actor_v0::checkWalkboxesHaveDirectPath(Common::Point &foundPath) {
- BoxCoords boxCoords = _vm->getBoxCoordinates(_walkbox);
- BoxCoords curBoxCoords = _vm->getBoxCoordinates(_walkdata.curbox);
-
- // check if next walkbox is left or right to actor's box
- if (boxCoords.ll.x > curBoxCoords.lr.x || boxCoords.lr.x < curBoxCoords.ll.x) {
- // determine horizontal corridor gates
- int gateUpper = MAX(boxCoords.ul.y, curBoxCoords.ul.y);
- int gateLower = MIN(boxCoords.ll.y, curBoxCoords.ll.y);
-
- // check if actor and target are in the same horizontal corridor between the boxes
- if ((_pos.y >= gateUpper && _pos.y <= gateLower) &&
- (_walkdata.dest.y >= gateUpper && _walkdata.dest.y <= gateLower)) {
- if (boxCoords.ll.x > curBoxCoords.lr.x) // next box is left
- return intersectLineSegments(_pos, _walkdata.dest, boxCoords.ll, boxCoords.ul, foundPath);
- else // next box is right
- return intersectLineSegments(_pos, _walkdata.dest, boxCoords.lr, boxCoords.ur, foundPath);
- }
- // check if next walkbox is above or below actor's box
- } else if (boxCoords.ul.y > curBoxCoords.ll.y || boxCoords.ll.y < curBoxCoords.ul.y) {
- // determine vertical corridor gates
- int gateLeft = MAX(boxCoords.ll.x, curBoxCoords.ll.x);
- int gateRight = MIN(boxCoords.lr.x, curBoxCoords.lr.x);
-
- // check if actor and target are in the same vertical corridor between the boxes
- if ((_pos.x >= gateLeft && _pos.x <= gateRight) &&
- (_walkdata.dest.x >= gateLeft && _walkdata.dest.x <= gateRight)) {
- if (boxCoords.ul.y > curBoxCoords.ll.y) // next box is above
- return intersectLineSegments(_pos, _walkdata.dest, boxCoords.ul, boxCoords.ur, foundPath);
- else // next box is below
- return intersectLineSegments(_pos, _walkdata.dest, boxCoords.ll, boxCoords.lr, foundPath);
+ animateActor(newDirToOldDir(_facing));
+
+ } else {
+ // 2A0A
+ if ((_moving & 0x7F) != 1) {
+
+ if (_NewWalkTo == _pos)
+ return;
}
}
- return false;
+ // 2A9A
+ if (_moving == 2)
+ return;
+
+ if ((_moving & 0x0F) == 1)
+ return stopActorMoving();
+
+ // 2AAD
+ if (_moving & 0x80) {
+ directionUpdate();
+
+ if (_moving & 0x80)
+ return;
+
+ animateActor(newDirToOldDir(_facing));
+ }
+
+ if ((_moving & 0x0F) == 3) {
+L2C36:;
+ setTmpFromActor();
+
+ if (!_walkDirX) {
+ _pos.x--;
+ } else {
+ _pos.x++;
+ }
+
+ // 2C51
+ if (updateWalkbox() != kInvalidBox) {
+
+ setActorFromTmp();
+ goto L2A33;
+ }
+
+ setActorFromTmp();
+
+ if (_CurrentWalkTo.y == _tmp_Dest.y) {
+ stopActorMoving();
+ return;
+ }
+
+ if (!_walkDirY) {
+ _tmp_Dest.y--;
+ } else {
+ _tmp_Dest.y++;
+ }
+
+ setTmpFromActor();
+
+ byte A = updateWalkbox();
+ if (A == 0xFF) {
+ setActorFromTmp();
+ stopActorMoving();
+ return;
+ }
+ // 2C98: Yes, an exact copy of what just occured.. the original does this, so im doing it...
+ // Just to keep me sane when going over it :)
+ if (A == 0xFF) {
+ setActorFromTmp();
+ stopActorMoving();
+ return;
+ }
+ return;
+ }
+
+ // 2ADA
+ if ((_moving & 0x0F) == 4) {
+L2CA3:;
+ setTmpFromActor();
+
+ if (!_walkDirY) {
+ _pos.y--;
+ } else {
+ _pos.y++;
+ }
+ if (updateWalkbox() == kInvalidBox) {
+ // 2CC7
+ setActorFromTmp();
+ if (_CurrentWalkTo.x == _tmp_Dest.x) {
+ stopActorMoving();
+ return;
+ }
+
+ if (!_walkDirX) {
+ _tmp_Dest.x--;
+ } else {
+ _tmp_Dest.x++;
+ }
+ setTmpFromActor();
+
+ if (updateWalkbox() == kInvalidBox) {
+ setActorFromTmp();
+ stopActorMoving();
+ }
+
+ return;
+ } else {
+ setActorFromTmp();
+ goto L2A33;
+ }
+ }
+
+ if ((_moving & 0x0F) == 0) {
+ // 2AE8
+ byte A = actorWalkX();
+
+ if (A == 1) {
+ A = actorWalkY();
+ if (A == 1) {
+ _moving &= 0xF0;
+ _moving |= A;
+ } else {
+ if (A == 4)
+ stopActorMoving();
+ }
+
+ return;
+
+ } else {
+ // 2B0C
+ if (A == 3) {
+ _moving &= 0xF0;
+ _moving |= A;
+
+ if (_walkDirY) {
+ _targetFacing = getAngleFromPos(V12_X_MULTIPLIER*0, V12_Y_MULTIPLIER*1, false);
+ } else {
+ _targetFacing = getAngleFromPos(V12_X_MULTIPLIER*0, V12_Y_MULTIPLIER*-1, false);
+ }
+
+ directionUpdate();
+ animateActor(newDirToOldDir(_facing));
+ goto L2C36;
+
+ } else {
+ // 2B39
+ A = actorWalkY();
+ if (A != 4)
+ return;
+
+ _moving &= 0xF0;
+ _moving |= A;
+
+ if (_walkDirX) {
+ _targetFacing = getAngleFromPos(V12_X_MULTIPLIER*1, V12_Y_MULTIPLIER*0, false);
+ } else {
+ _targetFacing = getAngleFromPos(V12_X_MULTIPLIER*-1, V12_Y_MULTIPLIER*0, false);
+ }
+
+ directionUpdate();
+ animateActor(newDirToOldDir(_facing));
+ goto L2CA3;
+ }
+ }
+ }
}
void Actor_v2::walkActor() {
@@ -697,10 +1009,8 @@ void Actor_v2::walkActor() {
_walkdata.curbox = next_box;
- if (!checkWalkboxesHaveDirectPath(foundPath)) {
- getClosestPtOnBox(_vm->getBoxCoordinates(_walkdata.curbox), _pos.x, _pos.y, tmp.x, tmp.y);
- getClosestPtOnBox(_vm->getBoxCoordinates(_walkbox), tmp.x, tmp.y, foundPath.x, foundPath.y);
- }
+ getClosestPtOnBox(_vm->getBoxCoordinates(_walkdata.curbox), _pos.x, _pos.y, tmp.x, tmp.y);
+ getClosestPtOnBox(_vm->getBoxCoordinates(_walkbox), tmp.x, tmp.y, foundPath.x, foundPath.y);
}
calcMovementFactor(foundPath);
}
@@ -972,7 +1282,7 @@ void Actor::setDirection(int direction) {
}
void Actor_v0::setDirection(int direction) {
- int dir = newDirToOldDir( direction );
+ int dir = newDirToOldDir(direction);
int res = 0;
switch (dir) {
@@ -985,18 +1295,16 @@ void Actor_v0::setDirection(int direction) {
break;
case 2:
- res = 6; // Face Away
+ res = 6; // Face Camera
break;
default:
- res = 7; // Face Camera
+ res = 7; // Face Away
break;
}
_animFrameRepeat = -1;
animateActor(res);
- if (_moving)
- animateCostume();
}
void Actor::faceToObject(int obj) {
@@ -1017,8 +1325,14 @@ void Actor::turnToDirection(int newdir) {
return;
if (_vm->_game.version <= 6) {
- _moving = MF_TURN;
_targetFacing = newdir;
+
+ if (_vm->_game.version == 0) {
+ setDirection(newdir);
+ return;
+ }
+ _moving = MF_TURN;
+
} else {
_moving &= ~MF_TURN;
if (newdir != _facing) {
@@ -1085,8 +1399,14 @@ void Actor::putActor(int dstX, int dstY, int newRoom) {
}
// V0 always sets the actor to face the camera upon entering a room
- if (_vm->_game.version == 0)
+ if (_vm->_game.version == 0) {
+ _walkdata.dest = _pos;
+
+ ((Actor_v0*)this)->_newWalkBoxEntered = true;
+ ((Actor_v0*)this)->_CurrentWalkTo = _pos;
+
setDirection(oldDirToNewDir(2));
+ }
}
static bool inBoxQuickReject(const BoxCoords &box, int x, int y, int threshold) {
@@ -1200,6 +1520,59 @@ static int checkXYInBoxBounds(int boxnum, int x, int y, int &destX, int &destY)
return dist;
}
+AdjustBoxResult Actor_v0::adjustPosInBorderWalkbox(AdjustBoxResult box) {
+ AdjustBoxResult Result = box;
+ BoxCoords BoxCoord = _vm->getBoxCoordinates(box.box);
+
+ byte boxMask = _vm->getMaskFromBox(box.box);
+ if (!(boxMask & 0x80))
+ return Result;
+
+ int16 A;
+ boxMask &= 0x7C;
+ if (boxMask == 0x0C)
+ A = 2;
+ else {
+ if (boxMask != 0x08)
+ return Result;
+
+ A = 1;
+ }
+
+ // 1BC6
+ byte Modifier = box.y - BoxCoord.ul.y;
+ assert(Modifier < 0x16);
+
+ if (A == 1) {
+ // 1BCF
+ A = BoxCoord.ur.x - v0WalkboxSlantedModifier[ Modifier ];
+ if (A < box.x)
+ return box;
+
+ if (A < 0xA0 || A == 0xA0)
+ A = 0;
+
+ Result.x = A;
+ } else {
+ // 1BED
+ A = BoxCoord.ul.x + v0WalkboxSlantedModifier[ Modifier ];
+
+ if (A < box.x || A == box.x)
+ Result.x = A;
+ }
+
+ return Result;
+}
+
+AdjustBoxResult Actor_v0::adjustXYToBeInBox(int dstX, int dstY) {
+ AdjustBoxResult Result = Actor_v2::adjustXYToBeInBox(dstX, dstY);
+
+ if (Result.box == kInvalidBox)
+ return Result;
+
+ return adjustPosInBorderWalkbox(Result);
+}
+
AdjustBoxResult Actor_v2::adjustXYToBeInBox(const int dstX, const int dstY) {
AdjustBoxResult abr;
@@ -1410,6 +1783,7 @@ void Actor::showActor() {
Actor_v0 *a = ((Actor_v0 *)this);
a->_costCommand = a->_costCommandNew = 0xFF;
+ _walkdata.dest = a->_CurrentWalkTo;
for (int i = 0; i < 8; ++i) {
a->_limbFrameRepeat[i] = 0;
@@ -1451,34 +1825,6 @@ void ScummEngine::showActors() {
}
}
-// bits 0..5: sound, bit 6: ???
-static const byte v0ActorSounds[24] = {
- 0x06, // Syd
- 0x06, // Razor
- 0x06, // Dave
- 0x06, // Michael
- 0x06, // Bernard
- 0x06, // Wendy
- 0x00, // Jeff
- 0x46, // Radiation Suit
- 0x06, // Dr Fred
- 0x06, // Nurse Edna
- 0x06, // Weird Ed
- 0x06, // Dead Cousin Ted
- 0xFF, // Purple Tentacle
- 0xFF, // Green Tentacle
- 0x06, // Meteor police
- 0xC0, // Meteor
- 0x06, // Mark Eteer
- 0x06, // Talkshow Host
- 0x00, // Plant
- 0xC0, // Meteor Radiation
- 0xC0, // Edsel (small, outro)
- 0x00, // Meteor (small, intro)
- 0x06, // Sandy (Lab)
- 0x06, // Sandy (Cut-Scene)
-};
-
/* Used in Scumm v5 only. Play sounds associated with actors */
void ScummEngine::playActorSounds() {
int i, j;
@@ -1488,7 +1834,7 @@ void ScummEngine::playActorSounds() {
if (_actors[i]->_cost.soundCounter && _actors[i]->isInCurrentRoom()) {
_currentScript = 0xFF;
if (_game.version == 0) {
- sound = v0ActorSounds[i - 1] & 0x3F;
+ sound = _actors[i]->_sound[0] & 0x3F;
} else {
sound = _actors[i]->_sound[0];
}
@@ -1642,13 +1988,13 @@ void ScummEngine::processActors() {
continue;
// Sound
- if (a0->_moving && _currentRoom != 1 && _currentRoom != 44) {
+ if (a0->_moving != 2 && _currentRoom != 1 && _currentRoom != 44) {
if (a0->_cost.soundPos == 0)
a0->_cost.soundCounter++;
// Is this the correct location?
// 0x073C
- if (v0ActorTalkArray[a0->_number] & 0x3F)
+ if (a0->_sound[0] & 0x3F)
a0->_cost.soundPos = (a0->_cost.soundPos + 1) % 3;
}
}
@@ -1659,8 +2005,17 @@ void ScummEngine::processActors() {
// would hence cause regressions. See also the other big
// comment further up in this method for some details.
if (a->_costume) {
- a->drawActorCostume();
- a->animateCostume();
+
+ // Unfortunately in V0, the 'animateCostume' call happens right after the call to 'walkActor' (which is before drawing the actor)...
+ // doing it the other way with V0, causes animation glitches (when beginnning to walk, as the costume hasnt been updated).
+ // Updating the costume directly after 'walkActor' and again, after drawing... causes frame skipping
+ if (_game.version == 0) {
+ a->animateCostume();
+ a->drawActorCostume();
+ } else {
+ a->drawActorCostume();
+ a->animateCostume();
+ }
}
}
}
@@ -1948,7 +2303,7 @@ void Actor::startAnimActor(int f) {
void Actor_v0::startAnimActor(int f) {
if (f == _talkStartFrame) {
- if (v0ActorTalkArray[_number] & 0x40)
+ if (_sound[0] & 0x40)
return;
_speaking = 1;
@@ -2054,7 +2409,7 @@ void Actor_v0::animateCostume() {
}
void Actor_v0::speakCheck() {
- if (v0ActorTalkArray[_number] & 0x80)
+ if (_sound[0] & 0x80)
return;
int cmd = newDirToOldDir(_facing);
@@ -2897,6 +3252,70 @@ void Actor_v0::animateActor(int anim) {
}
}
+byte Actor_v0::updateWalkbox() {
+ if (_vm->checkXYInBoxBounds(_walkbox, _pos.x, _pos.y))
+ return 0;
+
+ int numBoxes = _vm->getNumBoxes() - 1;
+ for (int i = 0; i <= numBoxes; i++) {
+ if (_vm->checkXYInBoxBounds(i, _pos.x, _pos.y) == true) {
+ if (_walkdata.curbox == i) {
+ setBox(i);
+ directionUpdate();
+
+ _newWalkBoxEntered = true;
+ return i;
+ }
+ }
+ }
+
+ return kInvalidBox;
+}
+
+void Actor_v0::directionUpdate() {
+
+ int nextFacing = updateActorDirection(true);
+ if (_facing != nextFacing) {
+ // 2A89
+ setDirection(nextFacing);
+
+ // Still need to turn?
+ if (_facing != _targetFacing) {
+ _moving |= 0x80;
+ return;
+ }
+ }
+
+ _moving &= ~0x80;
+}
+
+void Actor_v0::setTmpFromActor() {
+ _tmp_Pos = _pos;
+ _pos = _tmp_Dest;
+ _tmp_WalkBox = _walkbox;
+ _tmp_NewWalkBoxEntered = _newWalkBoxEntered;
+}
+
+void Actor_v0::setActorFromTmp() {
+ _pos = _tmp_Pos;
+ _tmp_Dest = _tmp_Pos;
+ _walkbox = _tmp_WalkBox;
+ _newWalkBoxEntered = _tmp_NewWalkBoxEntered;
+}
+
+void Actor_v0::actorSetWalkTo() {
+
+ if (_newWalkBoxEntered == false)
+ return;
+
+ _newWalkBoxEntered = false;
+
+ int nextBox = ((ScummEngine_v0*)_vm)->walkboxFindTarget(this, _walkdata.destbox, _walkdata.dest);
+ if (nextBox != kInvalidBox) {
+ _walkdata.curbox = nextBox;
+ }
+}
+
void Actor_v0::saveLoadWithSerializer(Serializer *ser) {
Actor::saveLoadWithSerializer(ser);
@@ -2910,6 +3329,20 @@ void Actor_v0::saveLoadWithSerializer(Serializer *ser) {
MKLINE(Actor_v0, _animFrameRepeat, sleByte, VER(89)),
MKARRAY(Actor_v0, _limbFrameRepeatNew[0], sleInt8, 8, VER(89)),
MKARRAY(Actor_v0, _limbFrameRepeat[0], sleInt8, 8, VER(90)),
+ MKLINE(Actor_v0, _CurrentWalkTo.x, sleInt16, VER(97)),
+ MKLINE(Actor_v0, _CurrentWalkTo.y, sleInt16, VER(97)),
+ MKLINE(Actor_v0, _NewWalkTo.x, sleInt16, VER(97)),
+ MKLINE(Actor_v0, _NewWalkTo.y, sleInt16, VER(97)),
+ MKLINE(Actor_v0, _walkCountModulo, sleInt8, VER(97)),
+ MKLINE(Actor_v0, _newWalkBoxEntered, sleByte, VER(97)),
+ MKLINE(Actor_v0, _walkDirX, sleByte, VER(97)),
+ MKLINE(Actor_v0, _walkDirY, sleByte, VER(97)),
+ MKLINE(Actor_v0, _walkYCountGreaterThanXCount, sleByte, VER(97)),
+ MKLINE(Actor_v0, _walkXCount, sleByte, VER(97)),
+ MKLINE(Actor_v0, _walkXCountInc, sleByte, VER(97)),
+ MKLINE(Actor_v0, _walkYCount, sleByte, VER(97)),
+ MKLINE(Actor_v0, _walkYCountInc, sleByte, VER(97)),
+ MKLINE(Actor_v0, _walkMaxXYCountInc, sleByte, VER(97)),
MKEND()
};
diff --git a/engines/scumm/actor.h b/engines/scumm/actor.h
index 46dc7d0295..c1a3f23318 100644
--- a/engines/scumm/actor.h
+++ b/engines/scumm/actor.h
@@ -333,7 +333,6 @@ public:
protected:
virtual bool isPlayer();
virtual void prepareDrawActorCostume(BaseCostumeRenderer *bcr);
- virtual bool checkWalkboxesHaveDirectPath(Common::Point &foundPath);
};
enum ActorV0MiscFlags {
@@ -349,11 +348,32 @@ enum ActorV0MiscFlags {
class Actor_v0 : public Actor_v2 {
public:
+ Common::Point _CurrentWalkTo, _NewWalkTo;
+
byte _costCommandNew;
byte _costCommand;
byte _miscflags;
byte _speaking;
+ byte _walkCountModulo;
+ bool _newWalkBoxEntered;
+
+ byte _walkDirX;
+ byte _walkDirY;
+
+ byte _walkYCountGreaterThanXCount;
+ byte _walkXCount;
+ byte _walkXCountInc;
+ byte _walkYCount;
+ byte _walkYCountInc;
+
+ byte _walkMaxXYCountInc;
+
+ Common::Point _tmp_Pos;
+ Common::Point _tmp_Dest;
+ byte _tmp_WalkBox;
+ bool _tmp_NewWalkBoxEntered;
+
int8 _animFrameRepeat;
int8 _limbFrameRepeatNew[8];
int8 _limbFrameRepeat[8];
@@ -363,23 +383,32 @@ public:
public:
Actor_v0(ScummEngine *scumm, int id) : Actor_v2(scumm, id) {}
- virtual void initActor(int mode);
- virtual void animateActor(int anim);
- virtual void animateCostume();
+ void initActor(int mode);
+ void animateActor(int anim);
+ void animateCostume();
void limbFrameCheck(int limb);
+ void directionUpdate();
void speakCheck();
- virtual void setDirection(int direction);
+ void setDirection(int direction);
void startAnimActor(int f);
+ bool calcWalkDistances();
+ void walkActor();
+ void actorSetWalkTo();
+ byte actorWalkX();
+ byte actorWalkY();
+ byte updateWalkbox();
+
+ AdjustBoxResult adjustXYToBeInBox(int dstX, int dstY);
+ AdjustBoxResult adjustPosInBorderWalkbox(AdjustBoxResult box);
+
+ void setTmpFromActor();
+ void setActorFromTmp();
+
// Used by the save/load system:
virtual void saveLoadWithSerializer(Serializer *ser);
-
-protected:
- bool intersectLineSegments(const Common::Point &line1Start, const Common::Point &line1End,
- const Common::Point &line2Start, const Common::Point &line2End, Common::Point &result);
- virtual bool checkWalkboxesHaveDirectPath(Common::Point &foundPath);
};
diff --git a/engines/scumm/boxes.cpp b/engines/scumm/boxes.cpp
index 70c8f2e032..087d8425ac 100644
--- a/engines/scumm/boxes.cpp
+++ b/engines/scumm/boxes.cpp
@@ -1158,6 +1158,30 @@ bool ScummEngine::areBoxesNeighbors(int box1nr, int box2nr) {
return false;
}
+byte ScummEngine_v0::walkboxFindTarget(Actor *a, int destbox, Common::Point walkdest) {
+ Actor_v0 *Actor = (Actor_v0*)a;
+
+ byte nextBox = getNextBox(a->_walkbox, destbox);
+
+ if (nextBox != 0xFF && nextBox == destbox && areBoxesNeighbors(a->_walkbox, nextBox)) {
+
+ Actor->_NewWalkTo = walkdest;
+ return nextBox;
+ }
+
+ if (nextBox != 0xFF && nextBox != a->_walkbox) {
+
+ getClosestPtOnBox(getBoxCoordinates(nextBox), a->getPos().x, a->getPos().y, Actor->_NewWalkTo.x, Actor->_NewWalkTo.y);
+
+ } else {
+ if (walkdest.x == -1)
+ Actor->_NewWalkTo = Actor->_CurrentWalkTo;
+ else
+ Actor->_NewWalkTo = walkdest;
+ }
+ return nextBox;
+}
+
bool ScummEngine_v0::areBoxesNeighbors(int box1nr, int box2nr) {
int i;
const int numOfBoxes = getNumBoxes();
diff --git a/engines/scumm/cdda.cpp b/engines/scumm/cdda.cpp
index adb414ecce..d797712a31 100644
--- a/engines/scumm/cdda.cpp
+++ b/engines/scumm/cdda.cpp
@@ -46,7 +46,7 @@ private:
public:
CDDAStream(Common::SeekableReadStream *stream, DisposeAfterUse::Flag disposeAfterUse);
virtual ~CDDAStream();
-
+
int readBuffer(int16 *buffer, const int numSamples);
bool isStereo() const { return true; }
int getRate() const { return 44100; }
diff --git a/engines/scumm/detection.cpp b/engines/scumm/detection.cpp
index 7cd50e1f4c..45647c9bed 100644
--- a/engines/scumm/detection.cpp
+++ b/engines/scumm/detection.cpp
@@ -244,7 +244,7 @@ static Common::String generateFilenameForDetection(const char *pattern, Filename
case kGenRoomNum:
result = Common::String::format(pattern, 0);
break;
-
+
case kGenDiskNumSteam:
case kGenRoomNumSteam: {
const SteamIndexFile *indexFile = lookUpSteamIndexFile(pattern, platform);
@@ -323,6 +323,8 @@ static BaseScummFile *openDiskImage(const Common::FSNode &node, const GameFilena
gs.gameid = gfp->gameid;
gs.id = (Common::String(gfp->gameid) == "maniac" ? GID_MANIAC : GID_ZAK);
gs.platform = gfp->platform;
+ if (strcmp(gfp->pattern, "maniacdemo.d64") == 0)
+ gs.features |= GF_DEMO;
// determine second disk file name
Common::String disk2(disk1);
@@ -502,12 +504,7 @@ static void computeGameSettingsFromMD5(const Common::FSList &fslist, const GameF
// (since they have identical MD5):
if (dr.game.id == GID_MANIAC && !strcmp(gfp->pattern, "%02d.MAN")) {
dr.extra = "V1 Demo";
- }
-
- // HACK: If 'Demo' occurs in the extra string, set the GF_DEMO flag,
- // required by some game demos (e.g. Dig, FT and COMI).
- if (dr.extra && strstr(dr.extra, "Demo")) {
- dr.game.features |= GF_DEMO;
+ dr.game.features = GF_DEMO;
}
// HACK: Try to detect languages for translated games
diff --git a/engines/scumm/detection_tables.h b/engines/scumm/detection_tables.h
index ae334c201c..82a8b4452b 100644
--- a/engines/scumm/detection_tables.h
+++ b/engines/scumm/detection_tables.h
@@ -207,6 +207,7 @@ static const Engines::ObsoleteGameID obsoleteGameIDsTable[] = {
static const GameSettings gameVariantsTable[] = {
{"maniac", "Apple II", 0, GID_MANIAC, 0, 0, MDT_APPLEIIGS, 0, Common::kPlatformApple2GS, GUIO2(GUIO_NOSPEECH, GUIO_NOMIDI)},
{"maniac", "C64", 0, GID_MANIAC, 0, 0, MDT_C64, 0, Common::kPlatformC64, GUIO2(GUIO_NOSPEECH, GUIO_NOMIDI) },
+ {"maniac", "C64 Demo", 0, GID_MANIAC, 0, 0, MDT_C64, GF_DEMO, Common::kPlatformC64, GUIO2(GUIO_NOSPEECH, GUIO_NOMIDI) },
{"maniac", "V1", "v1", GID_MANIAC, 1, 0, MDT_PCSPK | MDT_PCJR, 0, Common::kPlatformDOS, GUIO2(GUIO_NOSPEECH, GUIO_NOMIDI)},
{"maniac", "V1 Demo", "v1", GID_MANIAC, 1, 0, MDT_PCSPK | MDT_PCJR, GF_DEMO, Common::kPlatformDOS, GUIO2(GUIO_NOSPEECH, GUIO_NOMIDI)},
{"maniac", "NES", 0, GID_MANIAC, 1, 0, MDT_NONE, 0, Common::kPlatformNES, GUIO3(GUIO_NOSPEECH, GUIO_NOMIDI, GUIO_NOASPECT)},
@@ -260,13 +261,16 @@ static const GameSettings gameVariantsTable[] = {
{"samnmax", "Floppy", 0, GID_SAMNMAX, 6, 0, MDT_ADLIB | MDT_MIDI | MDT_PREFER_GM, GF_USE_KEY, UNK, GUIO1(GUIO_NOSPEECH)},
#ifdef ENABLE_SCUMM_7_8
- {"ft", 0, 0, GID_FT, 7, 0, MDT_NONE, 0, UNK, GUIO1(GUIO_NOMIDI)},
+ {"ft", "", 0, GID_FT, 7, 0, MDT_NONE, 0, UNK, GUIO1(GUIO_NOMIDI)},
+ {"ft", "Demo", 0, GID_FT, 7, 0, MDT_NONE, GF_DEMO, UNK, GUIO1(GUIO_NOMIDI)},
- {"dig", "", 0, GID_DIG, 7, 0, MDT_NONE, 0, UNK, GUIO1(GUIO_NOMIDI)},
+ {"dig", "", 0, GID_DIG, 7, 0, MDT_NONE, 0, UNK, GUIO1(GUIO_NOMIDI)},
+ {"dig", "Demo", 0, GID_DIG, 7, 0, MDT_NONE, GF_DEMO, UNK, GUIO1(GUIO_NOMIDI)},
{"dig", "Steam", "steam", GID_DIG, 7, 0, MDT_NONE, 0, UNK, GUIO1(GUIO_NOMIDI)},
- {"comi", 0, 0, GID_CMI, 8, 0, MDT_NONE, 0, Common::kPlatformWindows, GUIO2(GUIO_NOMIDI, GUIO_NOASPECT)},
-#endif
+ {"comi", "", 0, GID_CMI, 8, 0, MDT_NONE, 0, Common::kPlatformWindows, GUIO2(GUIO_NOMIDI, GUIO_NOASPECT)},
+ {"comi", "Demo", 0, GID_CMI, 8, 0, MDT_NONE, GF_DEMO, Common::kPlatformWindows, GUIO2(GUIO_NOMIDI, GUIO_NOASPECT)},
+ #endif
// Humongous Entertainment Scumm Version 6
{"activity", "", 0, GID_HEGAME, 6, 62, MDT_ADLIB | MDT_MIDI, GF_USE_KEY, UNK, GUIO1(GUIO_NOLAUNCHLOAD)},
@@ -445,6 +449,7 @@ static const GameFilenamePattern gameFilenamesTable[] = {
{ "maniac", "%02d.MAN", kGenRoomNum, UNK_LANG, UNK, "V1 Demo" },
{ "maniac", "maniac1.d64", kGenUnchanged, UNK_LANG, Common::kPlatformC64, "C64" }, // ... and maniac2.d64
{ "maniac", "maniac1.dsk", kGenUnchanged, UNK_LANG, Common::kPlatformApple2GS, "Apple II" }, // ... and maniac2.dsk
+ { "maniac", "maniacdemo.d64", kGenUnchanged, UNK_LANG, Common::kPlatformC64, "C64 Demo" },
{ "maniac", "Maniac Mansion (E).prg", kGenUnchanged, Common::EN_GRB, Common::kPlatformNES, "NES" },
{ "maniac", "Maniac Mansion (F).prg", kGenUnchanged, Common::FR_FRA, Common::kPlatformNES, "NES" },
{ "maniac", "Maniac Mansion (SW).prg", kGenUnchanged, Common::SE_SWE, Common::kPlatformNES, "NES" },
@@ -661,6 +666,7 @@ static const GameFilenamePattern gameFilenamesTable[] = {
{ "dog", "Springparadijs", kGenHEMac, Common::NL_NLD, Common::kPlatformMacintosh, 0 },
{ "farm", "farm", kGenHEPC, UNK_LANG, UNK, 0 },
+ { "farm", "farm", kGenHEMac, UNK_LANG, Common::kPlatformMacintosh, 0 },
{ "farm", "farmdemo", kGenHEPC, UNK_LANG, UNK, 0 },
{ "farm", "Farm Demo", kGenHEMac, UNK_LANG, Common::kPlatformMacintosh, 0 },
@@ -677,12 +683,13 @@ static const GameFilenamePattern gameFilenamesTable[] = {
{ "freddi", "Freddi Demo", kGenHEMac, UNK_LANG, Common::kPlatformMacintosh, 0 },
{ "freddi", "Freddi Fish", kGenHEMac, UNK_LANG, Common::kPlatformMacintosh, 0 },
{ "freddi", "FreddiD", kGenHEPC, Common::NL_NLD, UNK, 0 },
+ { "freddi", "FreddiE", kGenHEPC, UNK_LANG, UNK, 0 },
{ "freddi", "Freddi Fisk", kGenHEMac, Common::SE_SWE, Common::kPlatformMacintosh, 0 },
{ "freddi", "FRITZI", kGenHEPC, Common::DE_DEU, UNK, 0 },
{ "freddi", "Marine Malice", kGenHEMac, Common::FR_FRA, Common::kPlatformMacintosh, 0 },
{ "freddi", "MM-DEMO", kGenHEPC, UNK_LANG, UNK, 0 },
- { "freddi2", "freddi2", kGenHEPC, UNK_LANG, UNK, 0 },
+ { "freddi2", "freddi2", kGenHEPC, UNK_LANG, Common::kPlatformWindows, 0 },
{ "freddi2", "FF2-demo", kGenHEMac, UNK_LANG, Common::kPlatformMacintosh, 0 },
{ "freddi2", "ff2-demo", kGenHEPC, UNK_LANG, Common::kPlatformWindows, 0 },
{ "freddi2", "FFHSDemo", kGenHEMac, UNK_LANG, Common::kPlatformMacintosh, 0 },
@@ -744,7 +751,7 @@ static const GameFilenamePattern gameFilenamesTable[] = {
{ "lost", "lost", kGenHEPC, UNK_LANG, UNK, 0 },
{ "lost", "Lost and Found", kGenHEMac, UNK_LANG, Common::kPlatformMacintosh, 0 },
{ "lost", "smaller", kGenHEPC, UNK_LANG, UNK, 0 },
- { "lost", "verloren", kGenHEPC, Common::NL_NLD, UNK, 0 },
+ { "lost", "verloren", kGenHEPC, Common::NL_NLD, Common::kPlatformWindows, 0 },
{ "lost", "Verloren", kGenHEMac, Common::NL_NLD, Common::kPlatformMacintosh, 0 },
{ "maze", "maze", kGenHEPC, UNK_LANG, UNK, 0 },
@@ -789,7 +796,7 @@ static const GameFilenamePattern gameFilenamesTable[] = {
{ "pajama2", "PJ2 Demo", kGenHEMac, Common::NL_NLD, Common::kPlatformMacintosh, 0 },
{ "pajama2", "PS2DEMO", kGenHEPC, Common::HE_ISR, UNK, 0 },
- { "pajama3", "pajama3", kGenHEPC, UNK_LANG, UNK, 0 },
+ { "pajama3", "pajama3", kGenHEPC, UNK_LANG, Common::kPlatformWindows, 0 },
{ "pajama3", "FPJ3Demo", kGenHEPC, Common::FR_FRA, UNK, 0 },
{ "pajama3", "GPJ3Demo", kGenHEPC, Common::DE_DEU, UNK, 0 },
{ "pajama3", "PajamaHTF", kGenHEMac, UNK_LANG, Common::kPlatformMacintosh, 0 },
@@ -851,7 +858,7 @@ static const GameFilenamePattern gameFilenamesTable[] = {
{ "putttime", "PuttTijd", kGenHEMac, Common::NL_NLD, Common::kPlatformMacintosh, 0 },
{ "putttime", "Putt Time", kGenHEMac, UNK_LANG, Common::kPlatformMacintosh, 0 },
{ "putttime", "PuttTTT", kGenHEMac, UNK_LANG, Common::kPlatformMacintosh, 0 },
- { "putttime", "PuttTTT", kGenHEPC, UNK_LANG, UNK, 0 },
+ { "putttime", "PuttTTT", kGenHEPC, UNK_LANG, Common::kPlatformWindows, 0 },
{ "putttime", "TIJDDEMO", kGenHEPC, Common::NL_NLD, Common::kPlatformWindows, 0 },
{ "putttime", "TijdDemo", kGenHEMac, Common::NL_NLD, Common::kPlatformMacintosh, 0 },
{ "putttime", "timedemo", kGenHEPC, UNK_LANG, UNK, 0 },
@@ -888,7 +895,7 @@ static const GameFilenamePattern gameFilenamesTable[] = {
{ "socks", "socks", kGenHEPC, UNK_LANG, UNK, 0 },
{ "socks", "SockWorks", kGenHEMac, UNK_LANG, Common::kPlatformMacintosh, 0 },
- { "socks", "SokkenSoep", kGenHEPC, Common::NL_NLD, UNK, 0 },
+ { "socks", "SokkenSoep", kGenHEPC, Common::NL_NLD, Common::kPlatformWindows, 0 },
{ "socks", "SokkenSoep", kGenHEMac, Common::NL_NLD, Common::kPlatformMacintosh, 0 },
{ "spyfox", "spyfox", kGenHEPC, UNK_LANG, Common::kPlatformWindows, 0 },
@@ -913,7 +920,7 @@ static const GameFilenamePattern gameFilenamesTable[] = {
{ "spyfox", "JR-Demo", kGenHEMac, Common::FR_FRA, Common::kPlatformMacintosh, 0 },
{ "spyfox", "game", kGenHEIOS, Common::EN_ANY, Common::kPlatformIOS, 0 },
- { "spyfox2", "spyfox2", kGenHEPC, UNK_LANG, UNK, 0 },
+ { "spyfox2", "spyfox2", kGenHEPC, UNK_LANG, Common::kPlatformWindows, 0 },
{ "spyfox2", "sf2-demo", kGenHEPC, UNK_LANG, UNK, 0 },
{ "spyfox2", "sf2demo", kGenHEPC, UNK_LANG, Common::kPlatformWindows, 0 },
{ "spyfox2", "Sf2demo", kGenHEMac, UNK_LANG, Common::kPlatformMacintosh, 0 },
diff --git a/engines/scumm/dialogs.cpp b/engines/scumm/dialogs.cpp
index 52120949cc..c22525b6f2 100644
--- a/engines/scumm/dialogs.cpp
+++ b/engines/scumm/dialogs.cpp
@@ -180,9 +180,9 @@ static const ResString string_map_table_v345[] = {
// I18N: You may specify 'Yes' symbol at the end of the line, like this:
// "Moechten Sie wirklich neu starten? (J/N)J"
// Will react to J as 'Yes'
- {5, _s("Are you sure you want to restart? (Y/N)")},
+ {5, _s("Are you sure you want to restart? (Y/N)Y")},
// I18N: you may specify 'Yes' symbol at the end of the line. See previous comment
- {6, _s("Are you sure you want to quit? (Y/N)")},
+ {6, _s("Are you sure you want to quit? (Y/N)Y")},
// Added in SCUMM4
{7, _s("Save")},
@@ -460,7 +460,7 @@ const Common::String InfoDialog::queryResString(int stringno) {
tmp += chr;
}
}
- return tmp;
+ return _(tmp);
}
#pragma mark -
diff --git a/engines/scumm/file.cpp b/engines/scumm/file.cpp
index 475ffa3238..96b46aa21a 100644
--- a/engines/scumm/file.cpp
+++ b/engines/scumm/file.cpp
@@ -221,6 +221,15 @@ static const int maniacResourcesPerFile[55] = {
3, 10, 1, 0, 0
};
+static const int maniacDemoResourcesPerFile[55] = {
+ 0, 12, 0, 2, 1, 12, 1, 13, 6, 0,
+ 31, 0, 1, 0, 0, 0, 0, 1, 1, 1,
+ 0, 1, 0, 0, 2, 0, 0, 1, 0, 0,
+ 2, 7, 1, 11, 0, 0, 5, 1, 0, 0,
+ 1, 0, 1, 3, 4, 3, 1, 0, 0, 1,
+ 2, 2, 0, 0, 0
+};
+
static const int zakResourcesPerFile[59] = {
0, 29, 12, 14, 13, 4, 4, 10, 7, 4,
14, 19, 5, 4, 7, 6, 11, 9, 4, 4,
@@ -253,9 +262,17 @@ ScummDiskImage::ScummDiskImage(const char *disk1, const char *disk2, GameSetting
_numGlobalObjects = 256;
_numRooms = 55;
_numCostumes = 25;
- _numScripts = 160;
- _numSounds = 70;
- _resourcesPerFile = maniacResourcesPerFile;
+
+ if (_game.features & GF_DEMO) {
+ _numScripts = 55;
+ _numSounds = 40;
+ _resourcesPerFile = maniacDemoResourcesPerFile;
+ } else {
+ _numScripts = 160;
+ _numSounds = 70;
+ _resourcesPerFile = maniacResourcesPerFile;
+ }
+
} else {
_numGlobalObjects = 775;
_numRooms = 59;
@@ -327,6 +344,9 @@ bool ScummDiskImage::open(const Common::String &filename) {
extractIndex(0); // Fill in resource arrays
+ if (_game.features & GF_DEMO)
+ return true;
+
openDisk(2);
if (_game.platform == Common::kPlatformApple2GS) {
diff --git a/engines/scumm/input.cpp b/engines/scumm/input.cpp
index 824dfec144..86048af57c 100644
--- a/engines/scumm/input.cpp
+++ b/engines/scumm/input.cpp
@@ -452,8 +452,16 @@ void ScummEngine_v2::processKeyboard(Common::KeyState lastKeyHit) {
lastKeyHit = Common::KeyState(Common::KEYCODE_ESCAPE);
// F7 is used to skip cutscenes in the Commodote 64 version of Maniac Mansion
} else if (_game.id == GID_MANIAC &&_game.platform == Common::kPlatformC64) {
- if (lastKeyHit.keycode == Common::KEYCODE_F7 && lastKeyHit.hasFlags(0))
- lastKeyHit = Common::KeyState(Common::KEYCODE_ESCAPE);
+ // Demo always F7 to be pressed to restart
+ if (_game.features & GF_DEMO) {
+ if (_roomResource != 0x2D && lastKeyHit.keycode == Common::KEYCODE_F7 && lastKeyHit.hasFlags(0)) {
+ restart();
+ return;
+ }
+ } else {
+ if (lastKeyHit.keycode == Common::KEYCODE_F7 && lastKeyHit.hasFlags(0))
+ lastKeyHit = Common::KeyState(Common::KEYCODE_ESCAPE);
+ }
// 'B' is used to skip cutscenes in the NES version of Maniac Mansion
} else if (_game.id == GID_MANIAC &&_game.platform == Common::kPlatformNES) {
if (lastKeyHit.keycode == Common::KEYCODE_b && lastKeyHit.hasFlags(Common::KBD_SHIFT))
diff --git a/engines/scumm/players/player_mac.cpp b/engines/scumm/players/player_mac.cpp
index fe15698494..634fd2de2b 100644
--- a/engines/scumm/players/player_mac.cpp
+++ b/engines/scumm/players/player_mac.cpp
@@ -21,7 +21,6 @@
*/
#include "common/macresman.h"
-#include "common/translation.h"
#include "engines/engine.h"
#include "gui/message.h"
#include "scumm/players/player_mac.h"
diff --git a/engines/scumm/resource_v2.cpp b/engines/scumm/resource_v2.cpp
index 7ccdfa4780..87dc132ff0 100644
--- a/engines/scumm/resource_v2.cpp
+++ b/engines/scumm/resource_v2.cpp
@@ -34,8 +34,14 @@ void ScummEngine_v2::readClassicIndexFile() {
_numGlobalObjects = 256;
_numRooms = 55;
_numCostumes = 25;
- _numScripts = 160;
- _numSounds = 70;
+ if (_game.features & GF_DEMO) {
+ _numScripts = 55;
+ _numSounds = 40;
+ } else {
+ _numScripts = 160;
+ _numSounds = 70;
+ }
+
} else if (_game.platform == Common::kPlatformNES) {
_numGlobalObjects = 775;
_numRooms = 55;
diff --git a/engines/scumm/room.cpp b/engines/scumm/room.cpp
index 3828629997..4b59e22408 100644
--- a/engines/scumm/room.cpp
+++ b/engines/scumm/room.cpp
@@ -614,6 +614,15 @@ void ScummEngine_v3old::setupRoomSubBlocks() {
}
} else {
_roomWidth = READ_LE_UINT16(&(rmhd->old.width));
+
+ // WORKAROUND: Fix bad width value for room 64 (book of maps) in
+ // Indy3. A specific version of this game (DOS/EGA v1.0, according to
+ // scumm-md5.txt) has a wrong width of 1793 stored in the data files,
+ // which causes a strange situation in which the book view may scroll
+ // towards the right depending on Indy's position from the previous room.
+ // Fixes bug #6679.
+ if (_game.id == GID_INDY3 && _roomResource == 64 && _roomWidth == 1793)
+ _roomWidth = 320;
_roomHeight = READ_LE_UINT16(&(rmhd->old.height));
}
_numObjectsInRoom = roomptr[20];
diff --git a/engines/scumm/saveload.cpp b/engines/scumm/saveload.cpp
index 7eadb042fb..e5673c1803 100644
--- a/engines/scumm/saveload.cpp
+++ b/engines/scumm/saveload.cpp
@@ -109,7 +109,12 @@ Common::Error ScummEngine::saveGameState(int slot, const Common::String &desc) {
}
bool ScummEngine::canSaveGameStateCurrently() {
- // FIXME: For now always allow loading in V0-V3 games
+ // Disallow saving in v0-v3 games when a 'prequel' to a cutscene is shown.
+ // This is a blank screen with text, and while this is shown, saving should
+ // be disabled, as no room is set.
+ if (_game.version <= 3 && _currentScript == 0xFF && _roomResource == 0 && _currentRoom == 0)
+ return false;
+
// TODO: Should we disallow saving in some more places,
// e.g. when a SAN movie is playing? Not sure whether the
// original EXE allowed this.
@@ -144,7 +149,7 @@ void ScummEngine::requestSave(int slot, const Common::String &name) {
void ScummEngine::requestLoad(int slot) {
_saveLoadSlot = slot;
- _saveTemporaryState = false;
+ _saveTemporaryState = (slot == 100);
_saveLoadFlag = 2; // 2 for load
}
diff --git a/engines/scumm/saveload.h b/engines/scumm/saveload.h
index 01ed21ece5..753287e217 100644
--- a/engines/scumm/saveload.h
+++ b/engines/scumm/saveload.h
@@ -47,7 +47,7 @@ namespace Scumm {
* only saves/loads those which are valid for the version of the savegame
* which is being loaded/saved currently.
*/
-#define CURRENT_VER 96
+#define CURRENT_VER 97
/**
* An auxillary macro, used to specify savegame versions. We use this instead
diff --git a/engines/scumm/script.cpp b/engines/scumm/script.cpp
index 2fe5333bfc..c9b37d43b1 100644
--- a/engines/scumm/script.cpp
+++ b/engines/scumm/script.cpp
@@ -1164,8 +1164,10 @@ void ScummEngine_v0::walkToActorOrObject(int object) {
VAR(7) = y;
// actor must not move if frozen
- if (a->_miscflags & kActorMiscFlagFreeze)
+ if (a->_miscflags & kActorMiscFlagFreeze) {
a->stopActorMoving();
+ a->_newWalkBoxEntered = false;
+ }
}
bool ScummEngine_v0::checkPendingWalkAction() {
@@ -1179,7 +1181,7 @@ bool ScummEngine_v0::checkPendingWalkAction() {
Actor_v0 *a = (Actor_v0 *)derefActor(actor, "checkPendingWalkAction");
// wait until walking or turning action is finished
- if (a->_moving)
+ if (a->_moving != 2)
return true;
// after walking and turning finally execute the script
diff --git a/engines/scumm/script_v0.cpp b/engines/scumm/script_v0.cpp
index a7999a2695..609cbd1e89 100644
--- a/engines/scumm/script_v0.cpp
+++ b/engines/scumm/script_v0.cpp
@@ -172,7 +172,7 @@ void ScummEngine_v0::setupOpcodes() {
/* 6C */
OPCODE(0x6c, o_stopCurrentScript);
OPCODE(0x6d, o2_putActorInRoom);
- OPCODE(0x6e, o2_dummy);
+ OPCODE(0x6e, o_screenPrepare);
OPCODE(0x6f, o2_ifState08);
/* 70 */
OPCODE(0x70, o_lights);
@@ -589,9 +589,9 @@ void ScummEngine_v0::o_loadRoomWithEgo() {
return;
}
- // The original interpreter seems to set the actors new room X/Y to the last rooms X/Y
- // This fixes a problem with MM: script 158 in room 12, the 'Oompf!' script
- // This scripts runs before the actor position is set to the correct location
+ // The original interpreter sets the actors new room X/Y to the last rooms X/Y
+ // This fixes a problem with MM: script 158 in room 12, the 'Oomph!' script
+ // This scripts runs before the actor position is set to the correct room entry location
a->putActor(a->getPos().x, a->getPos().y, room);
_egoPositioned = false;
@@ -633,12 +633,21 @@ void ScummEngine_v0::setMode(byte mode) {
switch (_currentMode) {
case kModeCutscene:
+ if (_game.features & GF_DEMO) {
+ if (VAR(11) != 0)
+ _drawDemo = true;
+ }
_redrawSentenceLine = false;
// Note: do not change freeze state here
state = USERSTATE_SET_IFACE |
USERSTATE_SET_CURSOR;
+
break;
case kModeKeypad:
+ if (_game.features & GF_DEMO) {
+ if (VAR(11) != 0)
+ _drawDemo = true;
+ }
_redrawSentenceLine = false;
state = USERSTATE_SET_IFACE |
USERSTATE_SET_CURSOR | USERSTATE_CURSOR_ON |
@@ -646,6 +655,12 @@ void ScummEngine_v0::setMode(byte mode) {
break;
case kModeNormal:
case kModeNoNewKid:
+ if (_game.features & GF_DEMO) {
+ resetVerbs();
+ _activeVerb = kVerbWalkTo;
+ _redrawSentenceLine = true;
+ _drawDemo = false;
+ }
state = USERSTATE_SET_IFACE | USERSTATE_IFACE_ALL |
USERSTATE_SET_CURSOR | USERSTATE_CURSOR_ON |
USERSTATE_SET_FREEZE;
@@ -707,17 +722,14 @@ void ScummEngine_v0::o_animateActor() {
}
a->animateActor(anim);
- a->animateCostume();
}
void ScummEngine_v0::o_getActorMoving() {
getResultPos();
int act = getVarOrDirectByte(PARAM_1);
Actor *a = derefActor(act, "o_getActorMoving");
- if (a->_moving)
- setResult(1);
- else
- setResult(2);
+
+ setResult(a->_moving);
}
void ScummEngine_v0::o_putActorAtObject() {
@@ -970,6 +982,10 @@ void ScummEngine_v0::o_setOwnerOf() {
setOwnerOf(obj, owner);
}
+void ScummEngine_v0::o_screenPrepare() {
+
+}
+
void ScummEngine_v0::resetSentence() {
_activeVerb = kVerbWalkTo;
_activeObject = 0;
diff --git a/engines/scumm/script_v2.cpp b/engines/scumm/script_v2.cpp
index 74d0aa2483..a7ec2e644f 100644
--- a/engines/scumm/script_v2.cpp
+++ b/engines/scumm/script_v2.cpp
@@ -1390,7 +1390,14 @@ void ScummEngine_v2::o2_loadRoomWithEgo() {
a = derefActor(VAR(VAR_EGO), "o2_loadRoomWithEgo");
- a->putActor(0, 0, room);
+ // The original interpreter sets the actors new room X/Y to the last rooms X/Y
+ // This fixes a problem with MM: script 161 in room 12, the 'Oomph!' script
+ // This scripts runs before the actor position is set to the correct room entry location
+ if ((_game.id == GID_MANIAC) && (_game.platform != Common::kPlatformNES)) {
+ a->putActor(a->getPos().x, a->getPos().y, room);
+ } else {
+ a->putActor(0, 0, room);
+ }
_egoPositioned = false;
x = (int8)fetchScriptByte();
diff --git a/engines/scumm/script_v5.cpp b/engines/scumm/script_v5.cpp
index 91afa859a9..4a53ca3fed 100644
--- a/engines/scumm/script_v5.cpp
+++ b/engines/scumm/script_v5.cpp
@@ -2497,10 +2497,6 @@ void ScummEngine_v5::walkActorToActor(int actor, int toActor, int dist) {
y = abr.y;
}
a->startWalkActor(x, y, -1);
-
- // WORKAROUND: See bug #2971126 for details on why this is here.
- if (_game.version == 0)
- o5_breakHere();
}
void ScummEngine_v5::o5_walkActorToActor() {
diff --git a/engines/scumm/script_v6.cpp b/engines/scumm/script_v6.cpp
index d2f4133f74..6c81f17f2f 100644
--- a/engines/scumm/script_v6.cpp
+++ b/engines/scumm/script_v6.cpp
@@ -2597,7 +2597,11 @@ void ScummEngine_v6::o6_kernelSetFunctions() {
fadeIn(args[1]);
break;
case 8:
- startManiac();
+ if (startManiac()) {
+ // This is so that the surprised exclamation happens
+ // after we return to the game again, not before.
+ o6_breakHere();
+ }
break;
case 9:
killAllScriptsExceptCurrent();
diff --git a/engines/scumm/scumm-md5.h b/engines/scumm/scumm-md5.h
index 0eeff57ff7..5be18fb990 100644
--- a/engines/scumm/scumm-md5.h
+++ b/engines/scumm/scumm-md5.h
@@ -1,5 +1,5 @@
/*
- This file was generated by the md5table tool on Wed Jun 25 10:34:07 2014
+ This file was generated by the md5table tool on Sun Dec 7 23:09:10 2014
DO NOT EDIT MANUALLY!
*/
@@ -20,7 +20,7 @@ static const MD5Table md5table[] = {
{ "0354ee0d14cde1264ec762261c04c14a", "loom", "Steam", "Steam", 585728, Common::EN_ANY, Common::kPlatformWindows },
{ "035deab53b47bc43abc763560d0f8d4b", "atlantis", "Floppy", "Demo", -1, Common::EN_ANY, Common::kPlatformDOS },
{ "037385a953789190298494d92b89b3d0", "catalog", "HE 72", "Demo", -1, Common::EN_ANY, Common::kPlatformWindows },
- { "03d3b18ee3fd68114e2a687c871e38d5", "freddi4", "HE 99", "Mini Game", -1, Common::EN_USA, Common::kPlatformWindows },
+ { "03d3b18ee3fd68114e2a687c871e38d5", "freddi4", "HE 99", "Mini Game", 13609, Common::EN_USA, Common::kPlatformWindows },
{ "0425954a9db5c340861672892c3e678d", "samnmax", "", "Demo", -1, Common::EN_ANY, Common::kPlatformUnknown },
{ "04401d747f1a2c1c4b388daff71ed378", "ft", "", "", 535405461, Common::DE_DEU, Common::kPlatformMacintosh },
{ "04687cdf7f975a89d2474929f7b80946", "indy3", "FM-TOWNS", "", 7552, Common::EN_ANY, Common::kPlatformFMTowns },
@@ -28,7 +28,7 @@ static const MD5Table md5table[] = {
{ "055ffe4f47753e47594ac67823220c54", "puttrace", "HE 99", "", -1, Common::DE_DEU, Common::kPlatformUnknown },
{ "057c9b456dedcc4d71b991a3072a20b3", "monkey", "SEGA", "", 9465, Common::JA_JPN, Common::kPlatformSegaCD },
{ "06b187468113f9ae5a400b148a847fac", "atlantis", "Floppy", "Floppy", 12075, Common::EN_ANY, Common::kPlatformMacintosh },
- { "06c3cf4f31daad8b1cd93153491db9e6", "pajama3", "", "", -1, Common::NL_NLD, Common::kPlatformMacintosh },
+ { "06c3cf4f31daad8b1cd93153491db9e6", "pajama3", "", "", 79382, Common::NL_NLD, Common::kPlatformUnknown },
{ "07433205acdca3bc553d0e731588b35f", "airport", "", "", -1, Common::EN_ANY, Common::kPlatformWindows },
{ "07a1eefd8ca95d77310311446c0f53d0", "brstorm", "", "", 5433, Common::EN_ANY, Common::kPlatformUnknown },
{ "07b810e37be7489263f7bc7627d4765d", "freddi4", "unenc", "Unencrypted", -1, Common::RU_RUS, Common::kPlatformWindows },
@@ -37,10 +37,11 @@ static const MD5Table md5table[] = {
{ "08656dd9698ddf1023ba9bf8a195e37b", "monkey", "VGA", "VGA", -1, Common::EN_ANY, Common::kPlatformDOS },
{ "08cc5c3eedaf72ebe12734eee94f7fa2", "balloon", "HE 80", "", -1, Common::EN_ANY, Common::kPlatformUnknown },
{ "09820417db26687bb7fe0c83cc4c553b", "ft", "", "Version A", 19697, Common::EN_ANY, Common::kPlatformUnknown },
+ { "09b0be55c16cd9e88b5080bf89ff281d", "freddi4", "HE 99", "Mini Game", 13609, Common::DE_DEU, Common::kPlatformWindows },
{ "0a212fa35fa8421f31c1f3961272caf0", "monkey", "VGA", "VGA", -1, Common::DE_DEU, Common::kPlatformAmiga },
{ "0a295b80f9a9edf818e8e161a0e83830", "freddi2", "HE 80", "", -1, Common::FR_FRA, Common::kPlatformUnknown },
{ "0a41311d462b6639fc45297b9044bf16", "monkey", "No AdLib", "EGA", -1, Common::ES_ESP, Common::kPlatformAtariST },
- { "0a6d7b81b850ed4a77811c60c9b5c555", "PuttTime", "HE 99", "Mini Game", -1, Common::EN_USA, Common::kPlatformWindows },
+ { "0a6d7b81b850ed4a77811c60c9b5c555", "PuttTime", "HE 99", "Mini Game", 18458, Common::EN_USA, Common::kPlatformWindows },
{ "0aa050f4ad79402fbe9c4f78fb8ac494", "loom", "PC-Engine", "", 6532, Common::EN_ANY, Common::kPlatformPCEngine },
{ "0ab19be9e2a3f6938226638b2a3744fe", "PuttTime", "HE 100", "Demo", -1, Common::EN_USA, Common::kPlatformUnknown },
{ "0ac41e2e3d2174e5a042a6b565328dba", "puttrace", "HE 98", "Demo", 13110, Common::EN_USA, Common::kPlatformUnknown },
@@ -112,12 +113,14 @@ static const MD5Table md5table[] = {
{ "2108d83dcf09f8adb4bc524669c8cf51", "PuttTime", "HE 99", "Updated", -1, Common::EN_USA, Common::kPlatformUnknown },
{ "21a6592322f92550f144f68a8a4e685e", "dig", "", "", -1, Common::FR_FRA, Common::kPlatformMacintosh },
{ "21abe302e1b1e2b66d6f5c12e241ebfd", "freddicove", "unenc", "Unencrypted", -1, Common::RU_RUS, Common::kPlatformWindows },
- { "2232b0b9411575b1f9961713ebc9de61", "balloon", "HE 80", "", -1, Common::UNK_LANG, Common::kPlatformWindows },
+ { "2232b0b9411575b1f9961713ebc9de61", "balloon", "HE 80", "", -1, Common::NL_NLD, Common::kPlatformWindows },
{ "225e18566e810c634bf7de63e7568e3e", "mustard", "", "", -1, Common::EN_USA, Common::kPlatformUnknown },
+ { "22c7432dc97a821fcfccd480e93e3911", "spyfox2", "", "Mini Game", 14689, Common::NL_NLD, Common::kPlatformWindows },
{ "22c9eb04455440131ffc157aeb8d40a8", "fbear", "HE 70", "Demo", -1, Common::EN_ANY, Common::kPlatformWindows },
{ "22de86b2f7ec6e5db745ed1123310b44", "spyfox2", "", "Demo", 15832, Common::FR_FRA, Common::kPlatformWindows },
{ "22f4ea88a09da12df9308ba30bcb7d0f", "loom", "EGA", "EGA", -1, Common::EN_ANY, Common::kPlatformDOS },
{ "23394c8d29cc63c61313959431a12476", "spyfox", "HE 100", "Updated", -1, Common::EN_ANY, Common::kPlatformWindows },
+ { "24942a4200d99bdb4bdb78f9c7e07027", "pajama3", "", "Mini Game", 13911, Common::NL_NLD, Common::kPlatformWindows },
{ "254fede2f15dbb32a23760d601b01816", "zak", "V1", "", -1, Common::EN_ANY, Common::kPlatformC64 },
{ "2723fea3dae0cb47768c424b145ae0e7", "tentacle", "Floppy", "Floppy", 7932, Common::EN_ANY, Common::kPlatformDOS },
{ "27b2ef1653089fe5b897d9cc89ce784f", "balloon", "HE 80", "", -1, Common::RU_RUS, Common::kPlatformWindows },
@@ -132,6 +135,7 @@ static const MD5Table md5table[] = {
{ "2a446817ffcabfef8716e0c456ecaf81", "puttzoo", "", "Demo", -1, Common::DE_DEU, Common::kPlatformWindows },
{ "2a8658dbd13d84d1bce64a71a35995eb", "pajama2", "HE 99", "Demo", -1, Common::HE_ISR, Common::kPlatformWindows },
{ "2c04aacffb8428f30ccf4f734fbe3adc", "activity", "", "", -1, Common::EN_ANY, Common::kPlatformDOS },
+ { "2cb46375dd5cdfd023e2f07e0a21b530", "maniac", "C64", "Demo", -1, Common::EN_ANY, Common::kPlatformC64 },
{ "2ccd8891ce4d3f1a334d21bff6a88ca2", "monkey", "CD", "", 9455, Common::EN_ANY, Common::kPlatformMacintosh },
{ "2d1e891fe52df707c30185e52c50cd92", "monkey", "CD", "CD", 8955, Common::EN_ANY, Common::kPlatformDOS },
{ "2d388339d6050d8ccaa757b64633954e", "indyloom", "FM-TOWNS", "Demo", 7520, Common::EN_ANY, Common::kPlatformFMTowns },
@@ -230,7 +234,7 @@ static const MD5Table md5table[] = {
{ "4f580a021eee026f3b4589e17d130d78", "freddi4", "", "", -1, Common::UNK_LANG, Common::kPlatformUnknown },
{ "4fa6870d9bc8c313b65d54b1da5a1891", "pajama", "", "", -1, Common::NL_NLD, Common::kPlatformUnknown },
{ "4fbbe9f64b8bc547503a379a301183ce", "tentacle", "", "CD", -1, Common::IT_ITA, Common::kPlatformUnknown },
- { "4fe6a2e8df3c4536b278fdd2fbcb181e", "pajama3", "", "Mini Game", -1, Common::EN_ANY, Common::kPlatformWindows },
+ { "4fe6a2e8df3c4536b278fdd2fbcb181e", "pajama3", "", "Mini Game", 13911, Common::EN_ANY, Common::kPlatformWindows },
{ "5057fb0e99e5aa29df1836329232f101", "freddi2", "HE 80", "", -1, Common::UNK_LANG, Common::kPlatformWindows },
{ "507bb360688dc4180fdf0d7597352a69", "freddi", "HE 73", "", 26402, Common::SE_SWE, Common::kPlatformWindows },
{ "50b831f11b8c4b83784cf81f4dcc69ea", "spyfox", "HE 101", "", -1, Common::EN_ANY, Common::kPlatformWii },
@@ -302,6 +306,7 @@ static const MD5Table md5table[] = {
{ "6a60d395b78b205c93a956100b1bf5ae", "pajama2", "HE 98.5", "", -1, Common::DE_DEU, Common::kPlatformUnknown },
{ "6a8133b63d46f6663fbcbb49d5a2edb1", "atlantis", "Steam", "Steam", 520548, Common::EN_ANY, Common::kPlatformMacintosh },
{ "6af2419fe3db5c2fdb091ae4e5833770", "puttrace", "HE 98.5", "Demo", -1, Common::NL_NLD, Common::kPlatformUnknown },
+ { "6b10c9977cad9de503642059359792b1", "spyfox2", "", "Mini Game", 14689, Common::FR_FRA, Common::kPlatformWindows },
{ "6b19d0e25cbf720d05822379b8b90ed9", "PuttTime", "HE 90", "Demo", -1, Common::NL_NLD, Common::kPlatformUnknown },
{ "6b257bb2827dd894b8109a50a1a18b5a", "freddicove", "HE 100", "Demo", -1, Common::NL_NLD, Common::kPlatformUnknown },
{ "6b27dbcd8d5697d5c918eeca0f68ef6a", "puttrace", "HE CUP", "Preview", 3901484, Common::UNK_LANG, Common::kPlatformUnknown },
@@ -310,7 +315,8 @@ static const MD5Table md5table[] = {
{ "6bca7a1a96d16e52b8f3c42b50dbdca3", "fbear", "HE 62", "", -1, Common::JA_JPN, Common::kPlatform3DO },
{ "6bf70eee5de3d24d2403e0dd3d267e8a", "spyfox", "", "", 49221, Common::UNK_LANG, Common::kPlatformWindows },
{ "6c2bff0e327f2962e809c2e1a82d7309", "monkey", "VGA", "VGA", -1, Common::EN_ANY, Common::kPlatformAmiga },
- { "6d1baa1065ac5f7b210be8ebe4235e49", "freddi", "HE 73", "", -1, Common::NL_NLD, Common::kPlatformMacintosh },
+ { "6c375c2236d99f56e6c2cf540e74e474", "farm", "", "Demo", 34333, Common::NL_NLD, Common::kPlatformWindows },
+ { "6d1baa1065ac5f7b210be8ebe4235e49", "freddi", "HE 73", "", 26384, Common::NL_NLD, Common::kPlatformMacintosh },
{ "6dead580b0ff14d5f7b33b4219f04159", "samnmax", "", "Demo", 16556335, Common::EN_ANY, Common::kPlatformMacintosh },
{ "6df20c50c1ab19799de9be7ae7716881", "fbear", "HE 62", "Demo", -1, Common::EN_ANY, Common::kPlatformMacintosh },
{ "6e959d65358eedf9b68b81e304b97fa4", "tentacle", "", "CD", 7932, Common::DE_DEU, Common::kPlatformUnknown },
@@ -324,7 +330,7 @@ static const MD5Table md5table[] = {
{ "70b0719ac3a5b47ae233c561823d5b96", "puttzoo", "", "", -1, Common::NL_NLD, Common::kPlatformMacintosh },
{ "71523b539491527d9860f4407faf0411", "monkey", "Demo", "EGA Demo", 7607, Common::EN_ANY, Common::kPlatformDOS },
{ "71d384e7676c53d513ddd333eae1d82c", "Blues123time", "", "", -1, Common::EN_ANY, Common::kPlatformUnknown },
- { "71fe97c3108678cf604f14abe342341b", "spyfox2", "", "", -1, Common::NL_NLD, Common::kPlatformWindows },
+ { "71fe97c3108678cf604f14abe342341b", "spyfox2", "", "", 51286, Common::NL_NLD, Common::kPlatformUnknown },
{ "7222f260253f325c21fcfa68b5bfab67", "spyfox2", "", "Demo", -1, Common::EN_USA, Common::kPlatformUnknown },
{ "72ac6bc980d5101c2142189d746bd62f", "spyfox", "HE 99", "", -1, Common::RU_RUS, Common::kPlatformWindows },
{ "732845548b1d6c2da572cb6a1bf81b07", "spyfox2", "", "Demo", -1, Common::DE_DEU, Common::kPlatformUnknown },
@@ -348,6 +354,7 @@ static const MD5Table md5table[] = {
{ "78c07ca088526d8d4446a4c2cb501203", "freddi3", "HE 99", "", -1, Common::FR_FRA, Common::kPlatformUnknown },
{ "7974365d3dc0f43a2748c975f91ff042", "monkey2", "", "", -1, Common::ES_ESP, Common::kPlatformDOS },
{ "79b05f628586837e7166e82b2279bb50", "loom", "PC-Engine", "", -1, Common::JA_JPN, Common::kPlatformPCEngine },
+ { "7a2b6d8e8a645c9d534c8c4edc38a9c9", "freddi4", "HE 99", "Mini Game", 13609, Common::IT_ITA, Common::kPlatformWindows },
{ "7b4ee071eecadc2d8cd0c3509110825c", "puttzoo", "HE 100", "Remastered", -1, Common::EN_ANY, Common::kPlatformWindows },
{ "7bad72e332a59f9fcc1d437f4edad32a", "puttcircus", "", "", -1, Common::RU_RUS, Common::kPlatformUnknown },
{ "7c2e76087027eeee9c8f8985f93a1cc5", "freddi4", "", "Demo", 13584, Common::EN_ANY, Common::kPlatformUnknown },
@@ -357,6 +364,7 @@ static const MD5Table md5table[] = {
{ "7e151c17adf624f1966c8fc5827c95e9", "puttputt", "HE 61", "", -1, Common::EN_ANY, Common::kPlatform3DO },
{ "7ea2da67ebabea4ac20cee9f4f9d2934", "airport", "", "Demo", -1, Common::EN_ANY, Common::kPlatformMacintosh },
{ "7edd665bbede7ea8b7233f8e650be6f8", "samnmax", "", "CD", -1, Common::FR_FRA, Common::kPlatformUnknown },
+ { "7f2578d8d33a9ff525488a2d9ba617e4", "spyfox2", "", "Mini Game", 14689, Common::DE_DEU, Common::kPlatformWindows },
{ "7f45ddd6dbfbf8f80c0c0efea4c295bc", "maniac", "V1", "V1", 1972, Common::EN_ANY, Common::kPlatformDOS },
{ "7f945525abcd48015adf1632637a44a1", "pajama", "", "Demo", -1, Common::FR_FRA, Common::kPlatformUnknown },
{ "7fbcff27c323499beaedd605e1ebd47d", "indy3", "Steam", "Steam", 561152, Common::EN_ANY, Common::kPlatformWindows },
@@ -389,13 +397,15 @@ static const MD5Table md5table[] = {
{ "8afb3cf9f95abf208358e984f0c9e738", "funpack", "", "", -1, Common::EN_ANY, Common::kPlatform3DO },
{ "8bdb0bf87b5e303dd35693afb9351215", "ft", "", "", -1, Common::DE_DEU, Common::kPlatformUnknown },
{ "8d479e36f35e80257dfc102cf4b8a912", "farm", "HE 72", "Demo", 34333, Common::EN_ANY, Common::kPlatformWindows },
+ { "8dd4d590685c19bf651b5016e749ead2", "PuttTime", "HE 99", "Mini Game", 18458, Common::FR_FRA, Common::kPlatformWindows },
{ "8de13897f0121c79d29a2377159f9ad0", "socks", "HE 99", "Updated", -1, Common::EN_ANY, Common::kPlatformWindows },
{ "8e3241ddd6c8dadf64305e8740d45e13", "balloon", "HE 100", "Updated", -1, Common::EN_ANY, Common::kPlatformUnknown },
{ "8e4ee4db46954bfe2912e259a16fad82", "monkey2", "", "", -1, Common::FR_FRA, Common::kPlatformDOS },
{ "8e9417564f33790815445b2136efa667", "atlantis", "", "CD", 11915, Common::JA_JPN, Common::kPlatformMacintosh },
- { "8e9830a6f2702be5b22c8fa0a6aaf977", "freddi2", "HE 80", "", -1, Common::NL_NLD, Common::kPlatformMacintosh },
+ { "8e9830a6f2702be5b22c8fa0a6aaf977", "freddi2", "HE 80", "", 65305, Common::NL_NLD, Common::kPlatformUnknown },
{ "8eb84cee9b429314c7f0bdcf560723eb", "monkey", "FM-TOWNS", "", 9925, Common::EN_ANY, Common::kPlatformFMTowns },
{ "8ee63cafb1fe9d62aa0d5a23117e70e7", "freddi2", "HE 100", "Updated", -1, Common::EN_USA, Common::kPlatformUnknown },
+ { "8f345db2f3f5a25ed6305001957e6f72", "freddicove", "HE 100", "", 41182, Common::NL_NLD, Common::kPlatformUnknown },
{ "8f3758ff98c9c5d78e5d635222cad026", "atlantis", "Floppy", "Floppy", -1, Common::IT_ITA, Common::kPlatformDOS },
{ "8fec68383202d38c0d25e9e3b757c5df", "comi", "Demo", "Demo", 18041, Common::UNK_LANG, Common::kPlatformWindows },
{ "8ffd618a776a4c0d8922bb28b09f8ce8", "airport", "", "Demo", -1, Common::EN_ANY, Common::kPlatformWindows },
@@ -409,11 +419,13 @@ static const MD5Table md5table[] = {
{ "92b078d9d6d9d751da9c26b8b3075779", "tentacle", "Floppy", "Floppy", -1, Common::FR_FRA, Common::kPlatformDOS },
{ "92e7727e67f5cd979d8a1070e4eb8cb3", "puttzoo", "HE 98.5", "Updated", -1, Common::EN_ANY, Common::kPlatformUnknown },
{ "92fc0073a4cf259ff36070ecb8628ba8", "thinkerk", "", "", -1, Common::EN_USA, Common::kPlatformUnknown },
+ { "9340b552b0f2dffe6d4f3d13ebebe832", "freddi4", "HE 99", "Mini Game", 13609, Common::NL_NLD, Common::kPlatformWindows },
{ "94aaedbb8f26d71ed3ad6dd34490e29e", "tentacle", "Floppy", "Floppy", -1, Common::FR_FRA, Common::kPlatformDOS },
{ "94db6519da85b8d08c976d8e9a858ea7", "baseball", "HE CUP", "Preview", 10044774, Common::UNK_LANG, Common::kPlatformUnknown },
{ "95818b178d473c989ac753574e8892aa", "readtime", "", "Demo", -1, Common::EN_ANY, Common::kPlatformUnknown },
{ "95b3806e043be08668c54c3ffe98650f", "BluesABCTime", "", "", -1, Common::EN_ANY, Common::kPlatformUnknown },
{ "95be99181bd0f10fef4872c2d4a771cb", "zak", "V1", "", -1, Common::DE_DEU, Common::kPlatformC64 },
+ { "9684c161258d68e0d464d6cab7024b9c", "spyfox2", "", "Mini Game", 14689, Common::IT_ITA, Common::kPlatformWindows },
{ "96a3069a3c63caa7329588ce1fef41ee", "spyozon", "", "", -1, Common::RU_RUS, Common::kPlatformUnknown },
{ "9708cf716ed8bcc9ff3fcfc69413b746", "puttputt", "HE 62", "", -1, Common::EN_ANY, Common::kPlatformDOS },
{ "9778341eefc6feb447ca07e7be21791c", "puttrace", "HE 99", "Demo", -1, Common::IT_ITA, Common::kPlatformWindows },
@@ -459,9 +471,11 @@ static const MD5Table md5table[] = {
{ "a59a438cb182124c30c4447d8ed469e9", "freddi", "HE 100", "", 34837, Common::NB_NOR, Common::kPlatformWii },
{ "a5c5388da9bf0e6662fdca8813a79d13", "farm", "", "", 86962, Common::EN_ANY, Common::kPlatformWindows },
{ "a654fb60c3b67d6317a7894ffd9f25c5", "pajama3", "", "Demo", -1, Common::EN_USA, Common::kPlatformUnknown },
+ { "a71014c53a6d18c66ef2ea0ee42328e9", "PuttTime", "HE 99", "Mini Game", 18458, Common::NL_NLD, Common::kPlatformWindows },
{ "a7cacad9c40c4dc9e1812abf6c8af9d5", "puttcircus", "", "Demo", -1, Common::EN_ANY, Common::kPlatformUnknown },
{ "a85856675429fe88051744f755b72f93", "farm", "", "", -1, Common::EN_ANY, Common::kPlatformWindows },
{ "a86f9c49355579c30d4a55b477c0d869", "baseball2001", "", "", -1, Common::EN_ANY, Common::kPlatformUnknown },
+ { "a8fcc3084ad5e3e569722755f205b1ef", "pajama3", "", "Mini Game", 13911, Common::DE_DEU, Common::kPlatformWindows },
{ "a9543ef0d79bcb47cd76ec197ad0a967", "puttmoon", "", "", -1, Common::EN_ANY, Common::kPlatform3DO },
{ "a99c39ba65b6086be28aef576da69595", "spyozon", "", "Demo", -1, Common::FR_FRA, Common::kPlatformWindows },
{ "a9f2f04b1ecaab9495b59befffe9bf88", "pajama3", "", "Demo", -1, Common::EN_USA, Common::kPlatformUnknown },
@@ -478,6 +492,7 @@ static const MD5Table md5table[] = {
{ "acad97ab1c6fc2a5b2d98abf6db4a190", "tentacle", "Floppy", "Floppy", -1, Common::EN_ANY, Common::kPlatformUnknown },
{ "ae94f110a14ce71fc515d5b648827a8f", "tentacle", "Floppy", "Floppy", -1, Common::ES_ESP, Common::kPlatformDOS },
{ "aeec382acef62e122bf0d5b14581cfa4", "zak", "V1", "", -1, Common::IT_ITA, Common::kPlatformC64 },
+ { "aef415cc5dc063e3668359c2657169f3", "PuttTime", "HE 99", "Mini Game", 18458, Common::DE_DEU, Common::kPlatformWindows },
{ "aefa244ea034b7cd2041f0a44be7d9ba", "pajama3", "", "", -1, Common::EN_ANY, Common::kPlatformMacintosh },
{ "af2bd1a43b50b55915d87994e093203d", "freddi", "HE 99", "Updated", 34829, Common::DE_DEU, Common::kPlatformWindows },
{ "b100abf7ff83146df50db78dbd5e9cfa", "freddicove", "HE 100", "", -1, Common::FR_FRA, Common::kPlatformUnknown },
@@ -505,7 +520,7 @@ static const MD5Table md5table[] = {
{ "be83e882b44f2767bc08d4f766ebc347", "maniac", "V2", "V2", -1, Common::DE_DEU, Common::kPlatformAtariST },
{ "bf8b52fdd9a69c67f34e8e9fec72661c", "farm", "HE 71", "Demo", -1, Common::EN_ANY, Common::kPlatformWindows },
{ "bfdf584b01503f0762baded581f6a0a2", "SoccerMLS", "", "", -1, Common::EN_ANY, Common::kPlatformWindows },
- { "c0039ad982999c92d0de81910d640fa0", "freddi", "HE 71", "", -1, Common::NL_NLD, Common::kPlatformWindows },
+ { "c0039ad982999c92d0de81910d640fa0", "freddi", "HE 71", "", 26159, Common::NL_NLD, Common::kPlatformWindows },
{ "c13225cb1bbd3bc9fe578301696d8021", "monkey", "SEGA", "", -1, Common::EN_ANY, Common::kPlatformSegaCD },
{ "c20848f53c2d48bfacdc840993843765", "freddi2", "HE 80", "Demo", -1, Common::NL_NLD, Common::kPlatformUnknown },
{ "c225bec1b6c0798a2b8c89ac226dc793", "pajama", "HE 101", "", -1, Common::EN_ANY, Common::kPlatformWii },
@@ -516,6 +531,7 @@ static const MD5Table md5table[] = {
{ "c3b22fa4654bb580b20325ebf4174841", "puttzoo", "", "", -1, Common::NL_NLD, Common::kPlatformWindows },
{ "c3df37df9d3b481b45f75283a9907c47", "loom", "EGA", "EGA", -1, Common::IT_ITA, Common::kPlatformDOS },
{ "c4787c3e8b5e2dfda90850ee800af00f", "zak", "V2", "V2", -1, Common::FR_FRA, Common::kPlatformDOS },
+ { "c486e4cfa7bd6f8efcd0740f96f7dde3", "freddi4", "HE 99", "Mini Game", 13609, Common::FR_FRA, Common::kPlatformWindows },
{ "c4ffae9fac495475d6bc3343ccc8faf9", "Soccer2004", "", "", -1, Common::EN_ANY, Common::kPlatformUnknown },
{ "c5cc7cba02a2fbd539c4439e775b0536", "puttzoo", "HE 99", "Updated", 43470, Common::DE_DEU, Common::kPlatformWindows },
{ "c5d10e190d4b4d59114b824f2fdbd00e", "loom", "FM-TOWNS", "", 7540, Common::EN_ANY, Common::kPlatformFMTowns },
@@ -555,6 +571,7 @@ static const MD5Table md5table[] = {
{ "d06fbe28818fef7bfc45c2cdf0c0849d", "zak", "V2", "V2", -1, Common::DE_DEU, Common::kPlatformDOS },
{ "d0ad929def3e9cfe39dea55bd12098d4", "puttcircus", "", "", -1, Common::FR_FRA, Common::kPlatformWindows },
{ "d0b531227a27c6662018d2bd05aac52a", "monkey", "VGA", "VGA", 8357, Common::DE_DEU, Common::kPlatformDOS },
+ { "d1a73e87564477c7c2dcc2b8f616ad0b", "pajama3", "", "Mini Game", 13911, Common::IT_ITA, Common::kPlatformWindows },
{ "d220d154aafbfa12bd6f3ab1b2dae420", "puttzoo", "", "Demo", -1, Common::DE_DEU, Common::kPlatformMacintosh },
{ "d2cc8e31bce61e6cf2951249e10638fe", "basketball", "", "", -1, Common::EN_ANY, Common::kPlatformUnknown },
{ "d37c55388294b66e53e7ced3af88fa68", "freddi2", "HE 100", "Updated Demo", -1, Common::EN_ANY, Common::kPlatformUnknown },
@@ -602,7 +619,7 @@ static const MD5Table md5table[] = {
{ "e534d29afb3c6e0ee9dc3d53c5956714", "atlantis", "Floppy", "Floppy", -1, Common::DE_DEU, Common::kPlatformAmiga },
{ "e5563c8358443c4352fcddf7402a5e0a", "pajama2", "HE 98.5", "", -1, Common::FR_FRA, Common::kPlatformWindows },
{ "e5c112140ad6574997de033a8e2a2964", "readtime", "", "", -1, Common::EN_ANY, Common::kPlatformUnknown },
- { "e62056ba675ad65d8854ab3c5ad4b3c0", "spyfox2", "", "Mini Game", -1, Common::EN_ANY, Common::kPlatformWindows },
+ { "e62056ba675ad65d8854ab3c5ad4b3c0", "spyfox2", "", "Mini Game", 14689, Common::EN_ANY, Common::kPlatformWindows },
{ "e63a0b9249b5ca4cc4d3ac34305ae360", "freddi", "HE 99", "", -1, Common::NB_NOR, Common::kPlatformWindows },
{ "e689bdf67f98b1d760ce4487ec0e8d06", "indy3", "EGA", "EGA", -1, Common::FR_FRA, Common::kPlatformAmiga },
{ "e6cd81b25ab1453a8a6d3482118c391e", "pass", "", "", 7857, Common::EN_ANY, Common::kPlatformDOS },
@@ -624,7 +641,9 @@ static const MD5Table md5table[] = {
{ "edfdb24a499d92c59f824c52987c0eec", "atlantis", "Floppy", "Floppy", -1, Common::FR_FRA, Common::kPlatformDOS },
{ "ee41f6afbc5b26fa475754b56fe92048", "puttputt", "HE 61", "", 8032, Common::JA_JPN, Common::kPlatform3DO },
{ "ee785fe2569bc9965526e774f7ab86f1", "spyfox", "HE 99", "", -1, Common::FR_FRA, Common::kPlatformMacintosh },
+ { "ee8cfeb76e55d43a01c25e0865a9db76", "puttrace", "HE 98", "Demo", 13135, Common::NL_NLD, Common::kPlatformMacintosh },
{ "eea4d9ac2fb6f145945a308e8866915b", "maniac", "C64", "", -1, Common::EN_ANY, Common::kPlatformC64 },
+ { "eeb606c2d2ec877a712a9f20c10bcdda", "farm", "", "", 87034, Common::NL_NLD, Common::kPlatformMacintosh },
{ "ef347474f3c7be3b29584eaa133cca05", "samnmax", "Floppy", "Floppy", -1, Common::FR_FRA, Common::kPlatformDOS },
{ "ef71a322b6530ac45b1a070f7c0795f7", "moonbase", "Demo", "Demo", -1, Common::EN_ANY, Common::kPlatformWindows },
{ "ef74d9071d4e564b037cb44bd6774de7", "fbear", "HE 62", "", -1, Common::HE_ISR, Common::kPlatformDOS },
@@ -649,6 +668,7 @@ static const MD5Table md5table[] = {
{ "fa30c4a7a806629626269b6dcab59a15", "BluesBirthday", "HE CUP", "Preview", 7819264, Common::UNK_LANG, Common::kPlatformUnknown },
{ "fa3cb1541f9d7cf99ccbae6249bc150c", "maniac", "NES", "", -1, Common::IT_ITA, Common::kPlatformNES },
{ "fa84cb1018103a4ee4e5fa8041c1d0d1", "freddi4", "", "Demo", 13609, Common::DE_DEU, Common::kPlatformWindows },
+ { "faa89ab5e67ba4eebb4399f584f7490c", "pajama3", "", "Mini Game", 13911, Common::FR_FRA, Common::kPlatformWindows },
{ "fb66aa42de21675116346213f176a366", "monkey", "VGA", "VGA", -1, Common::IT_ITA, Common::kPlatformAmiga },
{ "fbb697d89d2beca87360a145f467bdae", "PuttTime", "HE 90", "Demo", -1, Common::DE_DEU, Common::kPlatformUnknown },
{ "fbbbb38a81fc9d6a61d509278390a290", "farm", "", "", -1, Common::EN_ANY, Common::kPlatformMacintosh },
diff --git a/engines/scumm/scumm.cpp b/engines/scumm/scumm.cpp
index 475b146a7b..7d927b0cda 100644
--- a/engines/scumm/scumm.cpp
+++ b/engines/scumm/scumm.cpp
@@ -716,7 +716,7 @@ ScummEngine_v2::ScummEngine_v2(OSystem *syst, const DetectorResult &dr)
ScummEngine_v0::ScummEngine_v0(OSystem *syst, const DetectorResult &dr)
: ScummEngine_v2(syst, dr) {
-
+ _drawDemo = false;
_currentMode = 0;
_currentLights = 0;
@@ -731,6 +731,9 @@ ScummEngine_v0::ScummEngine_v0(OSystem *syst, const DetectorResult &dr)
VAR_ACTIVE_OBJECT2 = 0xFF;
VAR_IS_SOUND_RUNNING = 0xFF;
VAR_ACTIVE_VERB = 0xFF;
+
+ if (strcmp(dr.fp.pattern, "maniacdemo.d64") == 0 )
+ _game.features |= GF_DEMO;
}
ScummEngine_v6::ScummEngine_v6(OSystem *syst, const DetectorResult &dr)
@@ -1091,8 +1094,13 @@ Common::Error ScummEngine::init() {
const char *tmpBuf1, *tmpBuf2;
assert(_game.id == GID_MANIAC || _game.id == GID_ZAK);
if (_game.id == GID_MANIAC) {
- tmpBuf1 = "maniac1.d64";
- tmpBuf2 = "maniac2.d64";
+ if (_game.features & GF_DEMO) {
+ tmpBuf1 = "maniacdemo.d64";
+ tmpBuf2 = "maniacdemo.d64";
+ } else {
+ tmpBuf1 = "maniac1.d64";
+ tmpBuf2 = "maniac2.d64";
+ }
} else {
tmpBuf1 = "zak1.d64";
tmpBuf2 = "zak2.d64";
@@ -2572,7 +2580,7 @@ void ScummEngine::runBootscript() {
int args[NUM_SCRIPT_LOCAL];
memset(args, 0, sizeof(args));
args[0] = _bootParam;
- if (_game.id == GID_MANIAC && (_game.features & GF_DEMO))
+ if (_game.id == GID_MANIAC && (_game.features & GF_DEMO) && (_game.platform != Common::kPlatformC64))
runScript(9, 0, 0, args);
else
runScript(1, 0, 0, args);
@@ -2589,9 +2597,52 @@ void ScummEngine_v90he::runBootscript() {
}
#endif
-void ScummEngine::startManiac() {
- debug(0, "stub startManiac()");
- displayMessage(0, "%s", _("Usually, Maniac Mansion would start now. But ScummVM doesn't do that yet. To play it, go to 'Add Game' in the ScummVM start menu and select the 'Maniac' directory inside the Tentacle game directory."));
+bool ScummEngine::startManiac() {
+ Common::String currentPath = ConfMan.get("path");
+ Common::String maniacTarget;
+
+ if (!ConfMan.hasKey("easter_egg")) {
+ // Look for a game with a game path pointing to a 'Maniac' directory
+ // as a subdirectory to the current game.
+ Common::ConfigManager::DomainMap::iterator iter = ConfMan.beginGameDomains();
+ for (; iter != ConfMan.endGameDomains(); ++iter) {
+ Common::ConfigManager::Domain &dom = iter->_value;
+ Common::String path = dom.getVal("path");
+
+ if (path.hasPrefix(currentPath)) {
+ path.erase(0, currentPath.size() + 1);
+ if (path.equalsIgnoreCase("maniac")) {
+ maniacTarget = dom.getVal("gameid");
+ break;
+ }
+ }
+ }
+ } else {
+ maniacTarget = ConfMan.get("easter_egg");
+ }
+
+ if (!maniacTarget.empty()) {
+ // Request a temporary save game to be made.
+ _saveLoadFlag = 1;
+ _saveLoadSlot = 100;
+ _saveTemporaryState = true;
+
+ // Set up the chanined games to Maniac Mansion, and then back
+ // to the current game again with that save slot.
+ ChainedGamesMan.push(maniacTarget);
+ ChainedGamesMan.push(ConfMan.getActiveDomainName(), 100);
+
+ // Force a return to the launcher. This will start the first
+ // chained game.
+ Common::EventManager *eventMan = g_system->getEventManager();
+ Common::Event event;
+ event.type = Common::EVENT_RTL;
+ eventMan->pushEvent(event);
+ return true;
+ } else {
+ displayMessage(0, "%s", _("Usually, Maniac Mansion would start now. But for that to work, the game files for Maniac Mansion have to be in the 'Maniac' directory inside the Tentacle game directory, and the game has to be added to ScummVM."));
+ return false;
+ }
}
#pragma mark -
diff --git a/engines/scumm/scumm.h b/engines/scumm/scumm.h
index af118a89a1..30b4d61880 100644
--- a/engines/scumm/scumm.h
+++ b/engines/scumm/scumm.h
@@ -642,7 +642,7 @@ protected:
byte _opcode;
byte _currentScript;
int _scummStackPos;
- int _vmStack[150];
+ int _vmStack[256];
OpcodeEntry _opcodes[256];
@@ -654,7 +654,7 @@ protected:
int getScriptSlot();
void startScene(int room, Actor *a, int b);
- void startManiac();
+ bool startManiac();
public:
void runScript(int script, bool freezeResistant, bool recursive, int *lvarptr, int cycle = 0);
@@ -1362,7 +1362,7 @@ public:
byte VAR_SCRIPT_CYCLE; // Used in runScript()/runObjectScript()
byte VAR_NUM_SCRIPT_CYCLES; // Used in runAllScripts()
-
+
byte VAR_QUIT_SCRIPT; // Used in confirmExitDialog()
// Exists both in V7 and in V72HE:
diff --git a/engines/scumm/scumm_v0.h b/engines/scumm/scumm_v0.h
index 80d047ab9f..4098d639c4 100644
--- a/engines/scumm/scumm_v0.h
+++ b/engines/scumm/scumm_v0.h
@@ -46,6 +46,7 @@ protected:
};
protected:
+ bool _drawDemo;
byte _currentMode;
byte _currentLights;
@@ -67,6 +68,8 @@ public:
virtual void resetScumm();
+ byte walkboxFindTarget(Actor *a, int destbox, Common::Point walkdest);
+
protected:
virtual void resetRoomObject(ObjectData *od, const byte *room, const byte *searchptr = NULL);
@@ -99,6 +102,8 @@ protected:
virtual void handleMouseOver(bool updateInventory);
int verbPrepIdType(int verbid);
void resetVerbs();
+ void verbDemoMode();
+ void verbDrawDemoString(int VerbDemoNumber);
void clearSentenceLine();
void flushSentenceLine();
@@ -116,7 +121,7 @@ protected:
void resetSentence();
- virtual bool areBoxesNeighbors(int box1nr, int box2nr);
+ bool areBoxesNeighbors(int box1nr, int box2nr);
bool ifEqualActiveObject2Common(bool checkType);
@@ -161,6 +166,7 @@ protected:
void o_cutscene();
void o_endCutscene();
void o_setOwnerOf();
+ void o_screenPrepare();
byte VAR_ACTIVE_OBJECT2;
byte VAR_IS_SOUND_RUNNING;
diff --git a/engines/scumm/sound.cpp b/engines/scumm/sound.cpp
index cb428d1c15..84d2b37f96 100644
--- a/engines/scumm/sound.cpp
+++ b/engines/scumm/sound.cpp
@@ -1066,9 +1066,9 @@ void Sound::playCDTrackInternal(int track, int numLoops, int startFrame, int dur
Common::File *cddaFile = new Common::File();
if (cddaFile->open("CDDA.SOU")) {
Audio::Timestamp start = Audio::Timestamp(0, startFrame, 75);
- Audio::Timestamp end = Audio::Timestamp(0, startFrame + duration, 75);
+ Audio::Timestamp end = Audio::Timestamp(0, startFrame + duration, 75);
Audio::SeekableAudioStream *stream = makeCDDAStream(cddaFile, DisposeAfterUse::YES);
-
+
_mixer->playStream(Audio::Mixer::kMusicSoundType, &_loomSteamCDAudioHandle,
Audio::makeLoopingAudioStream(stream, start, end, (numLoops < 1) ? numLoops + 1 : numLoops));
} else {
diff --git a/engines/scumm/vars.cpp b/engines/scumm/vars.cpp
index a903ac5804..a6be5c3f3a 100644
--- a/engines/scumm/vars.cpp
+++ b/engines/scumm/vars.cpp
@@ -715,7 +715,7 @@ void ScummEngine_v99he::resetScummVars() {
VAR(140) = 0;
#endif
}
-
+
if (_game.id == GID_PUTTZOO && _game.heversion == 100 && _game.platform == Common::kPlatformWindows) {
// Specific to Nimbus Games version.
VAR(156) = 1;
diff --git a/engines/scumm/verbs.cpp b/engines/scumm/verbs.cpp
index fdb98a8019..fe936b550c 100644
--- a/engines/scumm/verbs.cpp
+++ b/engines/scumm/verbs.cpp
@@ -80,6 +80,19 @@ static const VerbSettings v0VerbTable_German[] = {
{kVerbWhatIs, 13, 2, "Was ist"}
};
+struct VerbDemo {
+ int color;
+ const char *str;
+};
+static VerbDemo v0DemoStr[] = {
+ {7, " MANIAC MANSION DEMO DISK "},
+ {5, " from Lucasfilm Games "},
+ {5, " Copyright = 1987 by Lucasfilm Ltd. "},
+ {5, " All Rights Reserved. "},
+ {0, " "},
+ {16, " Press F7 to return to menu. "}
+};
+
int ScummEngine_v0::verbPrepIdType(int verbid) {
switch (verbid) {
case kVerbUse: // depends on object1
@@ -93,6 +106,44 @@ int ScummEngine_v0::verbPrepIdType(int verbid) {
}
}
+void ScummEngine_v0::verbDemoMode() {
+ int i;
+
+ for (i = 1; i < 16; i++)
+ killVerb(i);
+
+ for (i = 0; i < 6; i++) {
+ verbDrawDemoString(i);
+ }
+}
+
+void ScummEngine_v0::verbDrawDemoString(int VerbDemoNumber) {
+ byte string[80];
+ const char *ptr = v0DemoStr[VerbDemoNumber].str;
+ int i = 0, len = 0;
+
+ // Maximum length of printable characters
+ int maxChars = 40;
+ while (*ptr) {
+ if (*ptr != '@')
+ len++;
+ if (len > maxChars) {
+ break;
+ }
+
+ string[i++] = *ptr++;
+
+ }
+ string[i] = 0;
+
+ _string[2].charset = 1;
+ _string[2].ypos = _virtscr[kVerbVirtScreen].topline + (8 * VerbDemoNumber);
+ _string[2].xpos = 0;
+ _string[2].right = _virtscr[kVerbVirtScreen].w - 1;
+ _string[2].color = v0DemoStr[VerbDemoNumber].color;
+ drawString(2, (byte *)string);
+}
+
void ScummEngine_v0::resetVerbs() {
VirtScreen *virt = &_virtscr[kVerbVirtScreen];
VerbSlot *vs;
@@ -708,7 +759,6 @@ void ScummEngine_v0::verbExec() {
Actor_v0 *a = (Actor_v0 *)derefActor(VAR(VAR_EGO), "verbExec");
int x = _virtualMouse.x / V12_X_MULTIPLIER;
int y = _virtualMouse.y / V12_Y_MULTIPLIER;
- //actorSetPosInBox();
// 0xB31
VAR(6) = x;
@@ -717,7 +767,6 @@ void ScummEngine_v0::verbExec() {
if (a->_miscflags & kActorMiscFlagFreeze)
return;
- a->stopActorMoving();
a->startWalkActor(VAR(6), VAR(7), -1);
}
@@ -856,6 +905,10 @@ void ScummEngine_v0::checkExecVerbs() {
}
}
}
+
+ if (_drawDemo && _game.features & GF_DEMO) {
+ verbDemoMode();
+ }
if (_redrawSentenceLine)
drawSentenceLine();
diff --git a/engines/sword1/POTFILES b/engines/sword1/POTFILES
index 849bef9060..b60d55ff22 100644
--- a/engines/sword1/POTFILES
+++ b/engines/sword1/POTFILES
@@ -1,4 +1,4 @@
engines/sword1/animation.cpp
engines/sword1/control.cpp
engines/sword1/logic.cpp
-engines/sword1/sword1.cpp
+
diff --git a/engines/sword1/console.cpp b/engines/sword1/console.cpp
index 7fabc62192..3a4b51965b 100644
--- a/engines/sword1/console.cpp
+++ b/engines/sword1/console.cpp
@@ -36,7 +36,7 @@ SwordConsole::SwordConsole(SwordEngine *vm) : GUI::Debugger(), _vm(vm) {
SwordConsole::~SwordConsole() {
}
-
+
bool SwordConsole::Cmd_SpeechEndianness(int argc, const char **argv) {
if (argc == 1) {
debugPrintf("Using %s speech\n", _vm->_sound->_bigEndianSpeech ? "be" : "le");
diff --git a/engines/sword1/sound.cpp b/engines/sword1/sound.cpp
index 9140bddb65..4deaf06edc 100644
--- a/engines/sword1/sound.cpp
+++ b/engines/sword1/sound.cpp
@@ -144,7 +144,7 @@ void Sound::checkSpeechFileEndianness() {
debug(8, "Speech endianness heuristic: average = %f for BE and %f for LE (%d samples)", be_diff, le_diff, maxSamples);
}
}
-
+
double Sound::endiannessHeuristicValue(int16* data, uint32 dataSize, uint32 &maxSamples) {
if (!data)
return 50000.; // the heuristic value for the wrong endianess is about 21000 (1/3rd of the 16 bits range)
diff --git a/engines/sword25/gfx/renderobjectmanager.cpp b/engines/sword25/gfx/renderobjectmanager.cpp
index 4927b4c58e..8aeecad6b1 100644
--- a/engines/sword25/gfx/renderobjectmanager.cpp
+++ b/engines/sword25/gfx/renderobjectmanager.cpp
@@ -107,7 +107,7 @@ bool RenderObjectManager::render() {
if (!_currQueue->exists(*it))
_uta->addRect((*it)._bbox);
}
-
+
// Add rectangles of objects which are different from the previous frame
for (RenderObjectQueue::iterator it = _currQueue->begin(); it != _currQueue->end(); ++it) {
if (!_prevQueue->exists(*it))
diff --git a/engines/sword25/kernel/outputpersistenceblock.cpp b/engines/sword25/kernel/outputpersistenceblock.cpp
index 9003b5d58a..3e25fce5c7 100644
--- a/engines/sword25/kernel/outputpersistenceblock.cpp
+++ b/engines/sword25/kernel/outputpersistenceblock.cpp
@@ -41,6 +41,13 @@ OutputPersistenceBlock::OutputPersistenceBlock() {
_data.reserve(INITIAL_BUFFER_SIZE);
}
+void OutputPersistenceBlock::write(const void *data, uint32 size) {
+ writeMarker(BLOCK_MARKER);
+
+ write(size);
+ rawWrite(data, size);
+}
+
void OutputPersistenceBlock::write(int32 value) {
writeMarker(SINT_MARKER);
value = TO_LE_32(value);
diff --git a/engines/sword25/kernel/outputpersistenceblock.h b/engines/sword25/kernel/outputpersistenceblock.h
index c7d8dfc6aa..bdbd20d3e0 100644
--- a/engines/sword25/kernel/outputpersistenceblock.h
+++ b/engines/sword25/kernel/outputpersistenceblock.h
@@ -41,6 +41,7 @@ class OutputPersistenceBlock : public PersistenceBlock {
public:
OutputPersistenceBlock();
+ void write(const void *data, uint32 size);
void write(int32 value);
void write(uint32 value);
void write(float value);
diff --git a/engines/sword25/module.mk b/engines/sword25/module.mk
index 234baec165..0842eb9aa8 100644
--- a/engines/sword25/module.mk
+++ b/engines/sword25/module.mk
@@ -82,9 +82,10 @@ MODULE_OBJS := \
util/lua/lvm.o \
util/lua/lzio.o \
util/lua/scummvm_file.o \
- util/pluto/pdep.o \
- util/pluto/pluto.o \
- util/pluto/plzio.o
+ util/double_serialization.o \
+ util/lua_persistence_util.o \
+ util/lua_persist.o \
+ util/lua_unpersist.o
# This module can be built as a plugin
ifeq ($(ENABLE_SWORD25), DYNAMIC_PLUGIN)
diff --git a/engines/sword25/script/luascript.cpp b/engines/sword25/script/luascript.cpp
index f62a08005b..e93289596b 100644
--- a/engines/sword25/script/luascript.cpp
+++ b/engines/sword25/script/luascript.cpp
@@ -29,7 +29,7 @@
*
*/
-#include "common/array.h"
+#include "common/memstream.h"
#include "common/debug-channels.h"
#include "sword25/sword25.h"
@@ -43,7 +43,7 @@
#include "sword25/util/lua/lua.h"
#include "sword25/util/lua/lualib.h"
#include "sword25/util/lua/lauxlib.h"
-#include "sword25/util/pluto/pluto.h"
+#include "sword25/util/lua_persistence.h"
namespace Sword25 {
@@ -112,10 +112,6 @@ bool LuaScriptEngine::init() {
// Place the error handler function in the Lua registry, and remember the index
_pcallErrorhandlerRegistryIndex = luaL_ref(_state, LUA_REGISTRYINDEX);
- // Initialize the Pluto-Persistence library
- luaopen_pluto(_state);
- lua_pop(_state, 1);
-
// Initialize debugging callback
if (DebugMan.isDebugChannelEnabled(kDebugScript)) {
int mask = 0;
@@ -383,19 +379,8 @@ bool pushPermanentsTable(lua_State *L, PERMANENT_TABLE_TYPE tableType) {
return true;
}
-}
-
-namespace {
-int chunkwriter(lua_State *L, const void *p, size_t sz, void *ud) {
- Common::Array<byte> & chunkData = *reinterpret_cast<Common::Array<byte> * >(ud);
- const byte *buffer = reinterpret_cast<const byte *>(p);
- while (sz--)
- chunkData.push_back(*buffer++);
-
- return 1;
-}
-}
+} // End of anonymous namespace
bool LuaScriptEngine::persist(OutputPersistenceBlock &writer) {
// Empty the Lua stack. pluto_persist() xepects that the stack is empty except for its parameters
@@ -409,12 +394,12 @@ bool LuaScriptEngine::persist(OutputPersistenceBlock &writer) {
pushPermanentsTable(_state, PTT_PERSIST);
lua_getglobal(_state, "_G");
- // Lua persists and stores the data in a Common::Array
- Common::Array<byte> chunkData;
- pluto_persist(_state, chunkwriter, &chunkData);
+ // Lua persists and stores the data in a WriteStream
+ Common::MemoryWriteStreamDynamic writeStream;
+ Lua::persistLua(_state, &writeStream);
// Persistenzdaten in den Writer schreiben.
- writer.writeByteArray(chunkData);
+ writer.write(writeStream.getData(), writeStream.size());
// Die beiden Tabellen vom Stack nehmen.
lua_pop(_state, 2);
@@ -424,24 +409,6 @@ bool LuaScriptEngine::persist(OutputPersistenceBlock &writer) {
namespace {
-struct ChunkreaderData {
- void *BufferPtr;
- size_t Size;
- bool BufferReturned;
-};
-
-const char *chunkreader(lua_State *L, void *ud, size_t *sz) {
- ChunkreaderData &cd = *reinterpret_cast<ChunkreaderData *>(ud);
-
- if (!cd.BufferReturned) {
- cd.BufferReturned = true;
- *sz = cd.Size;
- return reinterpret_cast<const char *>(cd.BufferPtr);
- } else {
- return 0;
- }
-}
-
void clearGlobalTable(lua_State *L, const char **exceptions) {
// Iterate over all elements of the global table
lua_pushvalue(L, LUA_GLOBALSINDEX);
@@ -479,7 +446,8 @@ void clearGlobalTable(lua_State *L, const char **exceptions) {
// Perform garbage collection, so that all removed elements are deleted
lua_gc(L, LUA_GCCOLLECT, 0);
}
-}
+
+} // End of anonymous namespace
bool LuaScriptEngine::unpersist(InputPersistenceBlock &reader) {
// Empty the Lua stack. pluto_persist() xepects that the stack is empty except for its parameters
@@ -512,14 +480,9 @@ bool LuaScriptEngine::unpersist(InputPersistenceBlock &reader) {
// Persisted Lua data
Common::Array<byte> chunkData;
reader.readByteArray(chunkData);
+ Common::MemoryReadStream readStream(&chunkData[0], chunkData.size(), DisposeAfterUse::NO);
- // Chunk-Reader initialisation. It is used with pluto_unpersist to restore read data
- ChunkreaderData cd;
- cd.BufferPtr = &chunkData[0];
- cd.Size = chunkData.size();
- cd.BufferReturned = false;
-
- pluto_unpersist(_state, chunkreader, &cd);
+ Lua::unpersistLua(_state, &readStream);
// Permanents-Table is removed from stack
lua_remove(_state, -2);
@@ -527,7 +490,7 @@ bool LuaScriptEngine::unpersist(InputPersistenceBlock &reader) {
// The read elements in the global table about
lua_pushnil(_state);
while (lua_next(_state, -2) != 0) {
- // The referenec to the global table (_G) must not be overwritten, or ticks from Lua total
+ // The reference to the global table (_G) must not be overwritten, or ticks from Lua total
bool isGlobalReference = lua_isstring(_state, -2) && strcmp(lua_tostring(_state, -2), "_G") == 0;
if (!isGlobalReference) {
lua_pushvalue(_state, -2);
diff --git a/engines/sword25/sword25.cpp b/engines/sword25/sword25.cpp
index bb0aab3ad4..76142c2534 100644
--- a/engines/sword25/sword25.cpp
+++ b/engines/sword25/sword25.cpp
@@ -57,7 +57,6 @@ DECLARE_SINGLETON(Sword25::RenderObjectRegistry);
namespace Sword25 {
-const char *const PACKAGE_MANAGER = "archiveFS";
const char *const DEFAULT_SCRIPT_FILE = "/system/boot.lua";
Sword25Engine::Sword25Engine(OSystem *syst, const ADGameDescription *gameDesc):
diff --git a/engines/sword25/util/double_serialization.cpp b/engines/sword25/util/double_serialization.cpp
new file mode 100644
index 0000000000..48fd75cb33
--- /dev/null
+++ b/engines/sword25/util/double_serialization.cpp
@@ -0,0 +1,138 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public 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 "sword25/util/double_serialization.h"
+
+#include "common/scummsys.h"
+
+
+namespace Util {
+
+SerializedDouble encodeDouble(double value) {
+ // Split the value into its significand and exponent
+ int exponent;
+ double significand = frexp(value, &exponent);
+
+ // Shift the the first part of the significand into the integer range
+ double shiftedsignificandPart = ldexp(abs(significand), 32);
+ uint32 significandOne = uint32(floor(shiftedsignificandPart));
+
+ // Shift the remainder of the significand into the integer range
+ shiftedsignificandPart -= significandOne;
+ uint32 significandTwo = (uint32)(ldexp(shiftedsignificandPart, 31));
+
+ SerializedDouble returnValue;
+ returnValue.significandOne = significandOne; // SignificandOne
+ returnValue.signAndSignificandTwo = ((uint32)(value < 0 ? 1 : 0) << 31) | // Sign
+ significandTwo; // SignificandTwo
+ returnValue.exponent = (int16)exponent;
+ return returnValue;
+}
+
+double decodeDouble(SerializedDouble value) {
+ // Expand the exponent and the parts of the significand
+ int exponent = (int)value.exponent;
+ double expandedsignificandOne = (double)value.significandOne;
+ double expandedsignificandTwo = (double)(value.signAndSignificandTwo & 0x7FFFFFFF);
+
+ // Deflate the significand
+ double shiftedsignificand = ldexp(expandedsignificandTwo, -21);
+ double significand = ldexp(expandedsignificandOne + shiftedsignificand, -32);
+
+ // Re-calculate the actual double
+ double returnValue = ldexp(significand, exponent);
+
+ // Check the sign bit and return
+ return ((value.signAndSignificandTwo & 0x80000000) == 0x80000000) ? -returnValue : returnValue;
+}
+
+uint64 encodeDouble_64(double value) {
+ // Split the value into its significand and exponent
+ int exponent;
+ double significand = frexp(value, &exponent);
+
+ // Shift the significand into the integer range
+ double shiftedsignificand = ldexp(abs(significand), 53);
+
+ // Combine everything using the IEEE standard
+ uint64 uintsignificand = (uint64)shiftedsignificand;
+ return ((uint64)(value < 0 ? 1 : 0) << 63) | // Sign
+ ((uint64)(exponent + 1023) << 52) | // Exponent stored as an offset to 1023
+ (uintsignificand & 0x000FFFFFFFFFFFFF); // significand with MSB inferred
+}
+
+double decodeDouble_64(uint64 value) {
+ // Expand the exponent and significand
+ int exponent = (int)((value >> 52) & 0x7FF) - 1023;
+ double expandedsignificand = (double)(0x10000000000000 /* Inferred MSB */ | (value & 0x000FFFFFFFFFFFFF));
+
+ // Deflate the significand
+ int temp;
+ double significand = frexp(expandedsignificand, &temp);
+
+ // Re-calculate the actual double
+ double returnValue = ldexp(significand, exponent);
+
+ // Check the sign bit and return
+ return ((value & 0x8000000000000000) == 0x8000000000000000) ? -returnValue : returnValue;
+}
+
+CompactSerializedDouble encodeDouble_Compact(double value) {
+ // Split the value into its significand and exponent
+ int exponent;
+ double significand = frexp(value, &exponent);
+
+ // Shift the the first part of the significand into the integer range
+ double shiftedsignificandPart = ldexp(abs(significand), 32);
+ uint32 significandOne = uint32(floor(shiftedsignificandPart));
+
+ // Shift the remainder of the significand into the integer range
+ shiftedsignificandPart -= significandOne;
+ uint32 significandTwo = (uint32)(ldexp(shiftedsignificandPart, 21));
+
+ CompactSerializedDouble returnValue;
+ returnValue.signAndSignificandOne = ((uint32)(value < 0 ? 1 : 0) << 31) | // Sign
+ (significandOne & 0x7FFFFFFF); // significandOne with MSB inferred
+ // Exponent stored as an offset to 1023
+ returnValue.exponentAndSignificandTwo = ((uint32)(exponent + 1023) << 21) | significandTwo;
+
+ return returnValue;
+}
+
+double decodeDouble_Compact(CompactSerializedDouble value) {
+ // Expand the exponent and the parts of the significand
+ int exponent = (int)(value.exponentAndSignificandTwo >> 21) - 1023;
+ double expandedsignificandOne = (double)(0x80000000 /* Inferred MSB */ | (value.signAndSignificandOne & 0x7FFFFFFF));
+ double expandedsignificandTwo = (double)(value.exponentAndSignificandTwo & 0x1FFFFF);
+
+ // Deflate the significand
+ double shiftedsignificand = ldexp(expandedsignificandTwo, -21);
+ double significand = ldexp(expandedsignificandOne + shiftedsignificand, -32);
+
+ // Re-calculate the actual double
+ double returnValue = ldexp(significand, exponent);
+
+ // Check the sign bit and return
+ return ((value.signAndSignificandOne & 0x80000000) == 0x80000000) ? -returnValue : returnValue;
+}
+
+} // End of namespace Sword25
diff --git a/engines/sword25/util/double_serialization.h b/engines/sword25/util/double_serialization.h
new file mode 100644
index 0000000000..e90338c369
--- /dev/null
+++ b/engines/sword25/util/double_serialization.h
@@ -0,0 +1,95 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public 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 DOUBLE_SERIALIZATION_H
+#define DOUBLE_SERIALIZATION_H
+
+#include "common/types.h"
+
+
+namespace Util {
+
+struct SerializedDouble {
+ uint32 significandOne;
+ uint32 signAndSignificandTwo;
+ int16 exponent;
+};
+
+struct CompactSerializedDouble {
+ uint32 signAndSignificandOne;
+ uint32 exponentAndSignificandTwo;
+};
+
+/**
+ * Encodes a double as two uint32 and a one int16
+ *
+ * Supports denormalized numbers. Does NOT support NaN, or Inf
+ *
+ * @param value The value to encode
+ * @return The encoded value
+ */
+SerializedDouble encodeDouble(double value);
+/**
+ * Decodes a previously encoded double
+ *
+ * @param value The value to decode
+ * @return The decoded value
+ */
+double decodeDouble(SerializedDouble value);
+
+/**
+ * Encodes a double as a uint64
+ *
+ * Does NOT support denormalized numbers. Does NOT support NaN, or Inf
+ *
+ * @param value The value to encode
+ * @return The encoded value
+ */
+uint64 encodeDouble_64(double value);
+/**
+ * Decodes a previously encoded double
+ *
+ * @param value The value to decode
+ * @return The decoded value
+ */
+double decodeDouble_64(uint64 value);
+
+/**
+ * Encodes a double as two uint32
+ *
+ * Does NOT support denormalized numbers. Does NOT support NaN, or Inf
+ *
+ * @param value The value to encode
+ * @return The encoded value
+ */
+CompactSerializedDouble encodeDouble_Compact(double value);
+/**
+ * Decodes a previously encoded double
+ *
+ * @param value The value to decode
+ * @return The decoded value
+ */
+double decodeDouble_Compact(CompactSerializedDouble value);
+
+} // End of namespace Sword25
+
+#endif
diff --git a/engines/sword25/util/lua/lapi.cpp b/engines/sword25/util/lua/lapi.cpp
index b97e90012c..d7ebdcbe12 100644
--- a/engines/sword25/util/lua/lapi.cpp
+++ b/engines/sword25/util/lua/lapi.cpp
@@ -30,11 +30,12 @@
#include "common/textconsole.h"
+#if 0
const char lua_ident[] =
"Lua: " LUA_RELEASE " " LUA_COPYRIGHT " \n"
"Authors: " LUA_AUTHORS " \n"
"URL: www.lua.org\n";
-
+#endif
#define api_checknelems(L, n) api_check(L, (n) <= (L->top - L->base))
diff --git a/engines/sword25/util/lua/liolib.cpp b/engines/sword25/util/lua/liolib.cpp
index 0d27f9677f..403dea2ec2 100644
--- a/engines/sword25/util/lua/liolib.cpp
+++ b/engines/sword25/util/lua/liolib.cpp
@@ -24,7 +24,7 @@
#define IO_OUTPUT 2
-static const char *const fnames[] = {"input", "output"};
+//static const char *const fnames[] = {"input", "output"};
static int pushresult (lua_State *L, int i, const char *filename) {
diff --git a/engines/sword25/util/lua_persist.cpp b/engines/sword25/util/lua_persist.cpp
new file mode 100644
index 0000000000..6fe88fe9a3
--- /dev/null
+++ b/engines/sword25/util/lua_persist.cpp
@@ -0,0 +1,804 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+/**
+ * This code is heavily based on the Pluto code base. Copyright below
+ */
+
+/* Tamed Pluto - Heavy-duty persistence for Lua
+ * Copyright (C) 2004 by Ben Sunshine-Hill, and released into the public
+ * domain. People making use of this software as part of an application
+ * are politely requested to email the author at sneftel@gmail.com
+ * with a brief description of the application, primarily to satisfy his
+ * curiosity.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Instrumented by Stefan Reich (info@luaos.net)
+ * for Mobile Lua (http://luaos.net/pages/mobile-lua.php)
+ */
+
+
+#include "sword25/util/lua_persistence.h"
+
+#include "sword25/util/double_serialization.h"
+#include "sword25/util/lua_persistence_util.h"
+
+#include "common/stream.h"
+
+#include "lua/lobject.h"
+#include "lua/lstate.h"
+#include "lua/lgc.h"
+
+
+namespace Lua {
+
+#define PERMANENT_TYPE 101
+
+struct SerializationInfo {
+ lua_State *luaState;
+ Common::WriteStream *writeStream;
+ uint counter;
+};
+
+static void persist(SerializationInfo *info);
+
+static void persistBoolean(SerializationInfo *info);
+static void persistNumber(SerializationInfo *info);
+static void persistString(SerializationInfo *info);
+static void persistTable(SerializationInfo *info);
+static void persistFunction(SerializationInfo *info);
+static void persistThread(SerializationInfo *info);
+static void persistProto(SerializationInfo *info);
+static void persistUpValue(SerializationInfo *info);
+static void persistUserData(SerializationInfo *info);
+
+
+void persistLua(lua_State *luaState, Common::WriteStream *writeStream) {
+ SerializationInfo info;
+ info.luaState = luaState;
+ info.writeStream = writeStream;
+ info.counter = 1u;
+
+ // The process starts with the lua stack as follows:
+ // >>>>> permTbl rootObj
+ // That's the table of permanents and the root object to be serialized
+
+ // Make sure there is enough room on the stack
+ lua_checkstack(luaState, 4);
+ assert(lua_gettop(luaState) == 2);
+ // And that the root isn't nil
+ assert(!lua_isnil(luaState, 2));
+
+ // Create a table to hold indexes of everything that's serialized
+ // This allows us to only serialize an object once
+ // Every other time, just reference the index
+ lua_newtable(luaState);
+ // >>>>> permTbl rootObj indexTbl
+
+ // Now we're going to make the table weakly keyed. This prevents the
+ // GC from visiting it and trying to mark things it doesn't want to
+ // mark in tables, e.g. upvalues. All objects in the table are
+ // a priori reachable, so it doesn't matter that we do this.
+
+ // Create the metatable
+ lua_newtable(luaState);
+ // >>>>> permTbl rootObj indexTbl metaTbl
+
+ lua_pushstring(luaState, "__mode");
+ // >>>>> permTbl rootObj indexTbl metaTbl "__mode"
+
+ lua_pushstring(luaState, "k");
+ // >>>>> permTbl rootObj indexTbl metaTbl "__mode" "k"
+
+ lua_settable(luaState, 4);
+ // >>>>> permTbl rootObj indexTbl metaTbl
+
+ lua_setmetatable(luaState, 3);
+ // >>>>> permTbl rootObj indexTbl
+
+ // Swap the indexTable and the rootObj
+ lua_insert(luaState, 2);
+ // >>>>> permTbl indexTbl rootObj
+
+ // Serialize the root recursively
+ persist(&info);
+
+ // Return the stack back to the original state
+ lua_remove(luaState, 2);
+ // >>>>> permTbl rootObj
+}
+
+static void persist(SerializationInfo *info) {
+ // The stack can potentially have many things on it
+ // The object we want to serialize is the item on the top of the stack
+ // >>>>> permTbl indexTbl rootObj ...... obj
+
+ // Make sure there is enough room on the stack
+ lua_checkstack(info->luaState, 2);
+
+ // If the object has already been written, don't write it again
+ // Instead write the index of the object from the indexTbl
+
+ // Check the indexTbl
+ lua_pushvalue(info->luaState, -1);
+ // >>>>> permTbl indexTbl rootObj ...... obj obj
+
+ lua_rawget(info->luaState, 2);
+ // >>>>> permTbl indexTbl rootObj ...... obj ?index?
+
+ // If the index isn't nil, the object has already been written
+ if (!lua_isnil(info->luaState, -1)) {
+ // Write out a flag that indicates that it's an index
+ info->writeStream->writeByte(0);
+
+ // Retrieve the index from the stack
+ uint *index = (uint *)lua_touserdata(info->luaState, -1);
+
+ // Write out the index
+ info->writeStream->writeUint32LE(*index);
+
+ // Pop the index off the stack
+ lua_pop(info->luaState, 1);
+
+ return;
+ }
+
+ // Pop the index/nil off the stack
+ lua_pop(info->luaState, 1);
+
+ // If the obj itself is nil, we represent it as an index of 0
+ if (lua_isnil(info->luaState, -1)) {
+ // Write out a flag that indicates that it's an index
+ info->writeStream->writeByte(0);
+ // Write out the index
+ info->writeStream->writeUint32LE(0);
+
+ return;
+ }
+
+ // Write out a flag that indicates that this is a real object
+ info->writeStream->writeByte(1);
+
+ // Add the object to the indexTbl
+
+ lua_pushvalue(info->luaState, -1);
+ // >>>>> permTbl indexTbl rootObj ...... obj obj
+
+ uint *ref = (uint *)lua_newuserdata(info->luaState, sizeof(uint));
+ *ref = ++(info->counter);
+ // >>>>> permTbl indexTbl rootObj ...... obj obj index
+
+ lua_rawset(info->luaState, 2);
+ // >>>>> permTbl indexTbl rootObj ...... obj
+
+
+ // Write out the index
+ info->writeStream->writeUint32LE(info->counter);
+
+
+ // Objects that are in the permanents table are serialized in a special way
+
+ lua_pushvalue(info->luaState, -1);
+ // >>>>> permTbl indexTbl rootObj ...... obj obj
+
+ lua_gettable(info->luaState, 1);
+ // >>>>> permTbl indexTbl rootObj ...... obj obj ?permKey?
+
+ if (!lua_isnil(info->luaState, -1)) {
+ // Write out the type
+ info->writeStream->writeSint32LE(PERMANENT_TYPE);
+
+ // Serialize the key
+ persist(info);
+
+ // Pop the key off the stack
+ lua_pop(info->luaState, 1);
+
+ return;
+ }
+
+ // Pop the nil off the stack
+ lua_pop(info->luaState, 1);
+
+ // Query the type of the object
+ int objType = lua_type(info->luaState, -1);
+
+ // Write it out
+ info->writeStream->writeSint32LE(objType);
+
+ // Serialize the object by its type
+
+ switch (objType) {
+ case LUA_TBOOLEAN:
+ persistBoolean(info);
+ break;
+ case LUA_TLIGHTUSERDATA:
+ // You can't serialize a pointer
+ // It would be meaningless on the next run
+ assert(0);
+ break;
+ case LUA_TNUMBER:
+ persistNumber(info);
+ break;
+ case LUA_TSTRING:
+ persistString(info);
+ break;
+ case LUA_TTABLE:
+ persistTable(info);
+ break;
+ case LUA_TFUNCTION:
+ persistFunction(info);
+ break;
+ case LUA_TTHREAD:
+ persistThread(info);
+ break;
+ case LUA_TPROTO:
+ persistProto(info);
+ break;
+ case LUA_TUPVAL:
+ persistUpValue(info);
+ break;
+ case LUA_TUSERDATA:
+ persistUserData(info);
+ break;
+ default:
+ assert(0);
+ }
+}
+
+static void persistBoolean(SerializationInfo *info) {
+ int value = lua_toboolean(info->luaState, -1);
+
+ info->writeStream->writeSint32LE(value);
+}
+
+static void persistNumber(SerializationInfo *info) {
+ lua_Number value = lua_tonumber(info->luaState, -1);
+
+ Util::SerializedDouble serializedValue(Util::encodeDouble(value));
+
+ info->writeStream->writeUint32LE(serializedValue.significandOne);
+ info->writeStream->writeUint32LE(serializedValue.signAndSignificandTwo);
+ info->writeStream->writeSint16LE(serializedValue.exponent);
+}
+
+static void persistString(SerializationInfo *info) {
+ // Hard cast to a uint32 to force size_t to an explicit size
+ // *Theoretically* this could truncate, but if we have a 4gb string, we have bigger problems
+ uint32 length = static_cast<uint32>(lua_strlen(info->luaState, -1));
+ info->writeStream->writeUint32LE(length);
+
+ const char *str = lua_tostring(info->luaState, -1);
+ info->writeStream->write(str, length);
+}
+
+/* Choose whether to do a regular or special persistence based on an object's
+ * metatable. "default" is whether the object, if it doesn't have a __persist
+ * entry, is literally persistable or not.
+ * Pushes the unpersist closure and returns true if special persistence is
+ * used. */
+static bool serializeSpecialObject(SerializationInfo *info, bool defaction) {
+ // Make sure there is enough room on the stack
+ lua_checkstack(info->luaState, 4);
+
+ // Check whether we should persist literally, or via the __persist metafunction
+ if (!lua_getmetatable(info->luaState, -1)) {
+ if (defaction) {
+ // Write out a flag declaring that the object isn't special and should be persisted normally
+ info->writeStream->writeSint32LE(0);
+
+ return false;
+ } else {
+ lua_pushstring(info->luaState, "Type not literally persistable by default");
+ lua_error(info->luaState);
+
+ return false; // Not reached
+ }
+ }
+
+ // >>>>> permTbl indexTbl ...... obj metaTbl
+ lua_pushstring(info->luaState, "__persist");
+ // >>>>> permTbl indexTbl rootObj ...... obj metaTbl "__persist"
+
+ lua_rawget(info->luaState, -2);
+ // >>>>> permTbl indexTbl ...... obj metaTbl ?__persist?
+
+ if (lua_isnil(info->luaState, -1)) {
+ // >>>>> permTbl indexTbl ...... obj metaTbl nil
+ lua_pop(info->luaState, 2);
+ // >>>>> permTbl indexTbl ...... obj
+
+ if (defaction) {
+ // Write out a flag declaring that the object isn't special and should be persisted normally
+ info->writeStream->writeSint32LE(0);
+
+ return false;
+ } else {
+ lua_pushstring(info->luaState, "Type not literally persistable by default");
+ lua_error(info->luaState);
+
+ return false; // Return false
+ }
+
+ } else if (lua_isboolean(info->luaState, -1)) {
+ // >>>>> permTbl indexTbl ...... obj metaTbl bool
+ if (lua_toboolean(info->luaState, -1)) {
+ // Write out a flag declaring that the object isn't special and should be persisted normally
+ info->writeStream->writeSint32LE(0);
+
+ // >>>>> permTbl indexTbl ...... obj metaTbl true */
+ lua_pop(info->luaState, 2);
+ // >>>>> permTbl indexTbl ...... obj
+
+ return false;
+ } else {
+ lua_pushstring(info->luaState, "Metatable forbade persistence");
+ lua_error(info->luaState);
+
+ return false; // Not reached
+ }
+ } else if (!lua_isfunction(info->luaState, -1)) {
+ lua_pushstring(info->luaState, "__persist not nil, boolean, or function");
+ lua_error(info->luaState);
+ }
+
+ // >>>>> permTbl indexTbl ...... obj metaTbl __persist
+ lua_pushvalue(info->luaState, -3);
+ // >>>>> permTbl indexTbl ...... obj metaTbl __persist obj
+
+ // >>>>> permTbl indexTbl ...... obj metaTbl ?func?
+
+ if (!lua_isfunction(info->luaState, -1)) {
+ lua_pushstring(info->luaState, "__persist function did not return a function");
+ lua_error(info->luaState);
+ }
+
+ // >>>>> permTbl indexTbl ...... obj metaTbl func
+
+ // Write out a flag that the function exists
+ info->writeStream->writeSint32LE(1);
+
+ // Serialize the function
+ persist(info);
+
+ lua_pop(info->luaState, 2);
+ // >>>>> permTbl indexTbl ...... obj
+
+ return true;
+}
+
+static void persistTable(SerializationInfo *info) {
+ // >>>>> permTbl indexTbl ...... tbl
+
+ // Make sure there is enough room on the stack
+ lua_checkstack(info->luaState, 3);
+
+ // Test if the object needs special serialization
+ if (serializeSpecialObject(info, 1)) {
+ return;
+ }
+
+ // >>>>> permTbl indexTbl ...... tbl
+
+ // First, serialize the metatable (if any)
+ if (!lua_getmetatable(info->luaState, -1)) {
+ lua_pushnil(info->luaState);
+ }
+
+ // >>>>> permTbl indexTbl ...... tbl metaTbl/nil */
+ persist(info);
+
+ lua_pop(info->luaState, 1);
+ // >>>>> permTbl indexTbl ...... tbl
+
+
+ lua_pushnil(info->luaState);
+ // >>>>> permTbl indexTbl ...... tbl nil
+
+ // Now, persist all k/v pairs
+ while (lua_next(info->luaState, -2)) {
+ // >>>>> permTbl indexTbl ...... tbl k v */
+
+ lua_pushvalue(info->luaState, -2);
+ // >>>>> permTbl indexTbl ...... tbl k v k */
+
+ // Serialize the key
+ persist(info);
+
+ lua_pop(info->luaState, 1);
+ // >>>>> permTbl indexTbl ...... tbl k v */
+
+ // Serialize the value
+ persist(info);
+
+ lua_pop(info->luaState, 1);
+ // >>>>> permTbl indexTbl ...... tbl k */
+ }
+
+ // >>>>> permTbl indexTbl ...... tbl
+
+ // Terminate the list with a nil
+ lua_pushnil(info->luaState);
+ // >>>>> permTbl indexTbl ...... tbl
+
+ persist(info);
+
+ lua_pop(info->luaState, 1);
+ // >>>>> permTbl indexTbl ...... tbl
+}
+
+static void persistFunction(SerializationInfo *info) {
+ // >>>>> permTbl indexTbl ...... func
+ Closure *cl = clvalue(getObject(info->luaState, -1));
+ lua_checkstack(info->luaState, 2);
+
+ if (cl->c.isC) {
+ /* It's a C function. For now, we aren't going to allow
+ * persistence of C closures, even if the "C proto" is
+ * already in the permanents table. */
+ lua_pushstring(info->luaState, "Attempt to persist a C function");
+ lua_error(info->luaState);
+ } else {
+ // It's a Lua closure
+
+ // We don't really _NEED_ the number of upvals, but it'll simplify things a bit
+ info->writeStream->writeByte(cl->l.p->nups);
+
+ // Serialize the prototype
+ pushProto(info->luaState, cl->l.p);
+ // >>>>> permTbl indexTbl ...... func proto */
+
+ persist(info);
+
+ lua_pop(info->luaState, 1);
+ // >>>>> permTbl indexTbl ...... func
+
+ // Serialize upvalue values (not the upvalue objects themselves)
+ for (byte i = 0; i < cl->l.p->nups; i++) {
+ // >>>>> permTbl indexTbl ...... func
+ pushUpValue(info->luaState, cl->l.upvals[i]);
+ // >>>>> permTbl indexTbl ...... func upval
+
+ persist(info);
+
+ lua_pop(info->luaState, 1);
+ // >>>>> permTbl indexTbl ...... func
+ }
+
+ // >>>>> permTbl indexTbl ...... func
+
+ // Serialize function environment
+ lua_getfenv(info->luaState, -1);
+ // >>>>> permTbl indexTbl ...... func fenv
+
+ if (lua_equal(info->luaState, -1, LUA_GLOBALSINDEX)) {
+ // Function has the default fenv
+
+ // >>>>> permTbl indexTbl ...... func _G
+ lua_pop(info->luaState, 1);
+ // >>>>> permTbl indexTbl ...... func
+
+ lua_pushnil(info->luaState);
+ // >>>>> permTbl indexTbl ...... func nil
+ }
+
+ // >>>>> permTbl indexTbl ...... func fenv/nil
+ persist(info);
+
+ lua_pop(info->luaState, 1);
+ // >>>>> permTbl indexTbl ...... func
+ }
+}
+
+static void persistThread(SerializationInfo *info) {
+ // >>>>> permTbl indexTbl ...... thread
+ lua_State *threadState = lua_tothread(info->luaState, -1);
+
+ // Make sure there is enough room on the stack
+ lua_checkstack(info->luaState, threadState->top - threadState->stack + 1);
+
+ if (info->luaState == threadState) {
+ lua_pushstring(info->luaState, "Can't persist currently running thread");
+ lua_error(info->luaState);
+ return; /* not reached */
+ }
+
+ // Persist the stack
+
+ // We *could* have truncation here, but if we have more than 4 billion items on a stack, we have bigger problems
+ uint32 stackSize = static_cast<uint32>(appendStackToStack_reverse(threadState, info->luaState));
+ info->writeStream->writeUint32LE(stackSize);
+
+ // >>>>> permTbl indexTbl ...... thread (reversed contents of thread stack) */
+ for (; stackSize > 0; --stackSize) {
+ persist(info);
+
+ lua_pop(info->luaState, 1);
+ }
+
+ // >>>>> permTbl indexTbl ...... thread
+
+ // Now, serialize the CallInfo stack
+
+ // Again, we *could* have truncation here, but if we have more than 4 billion items on a stack, we have bigger problems
+ uint32 numFrames = static_cast<uint32>((threadState->ci - threadState->base_ci) + 1);
+ info->writeStream->writeUint32LE(numFrames);
+
+ for (uint32 i = 0; i < numFrames; i++) {
+ CallInfo *ci = threadState->base_ci + i;
+
+ // Same argument as above about truncation
+ uint32 stackBase = static_cast<uint32>(ci->base - threadState->stack);
+ uint32 stackFunc = static_cast<uint32>(ci->func - threadState->stack);
+ uint32 stackTop = static_cast<uint32>(ci->top - threadState->stack);
+
+ info->writeStream->writeUint32LE(stackBase);
+ info->writeStream->writeUint32LE(stackFunc);
+ info->writeStream->writeUint32LE(stackTop);
+
+ info->writeStream->writeSint32LE(ci->nresults);
+
+ uint32 savedpc = (ci != threadState->base_ci) ? static_cast<uint32>(ci->savedpc - ci_func(ci)->l.p->code) : 0u;
+ info->writeStream->writeUint32LE(savedpc);
+ }
+
+
+ // Serialize the state's other parameters, with the exception of upval stuff
+
+ assert(threadState->nCcalls <= 1);
+ info->writeStream->writeByte(threadState->status);
+
+ // Same argument as above about truncation
+ uint32 stackBase = static_cast<uint32>(threadState->base - threadState->stack);
+ uint32 stackFunc = static_cast<uint32>(threadState->top - threadState->stack);
+ info->writeStream->writeUint32LE(stackBase);
+ info->writeStream->writeUint32LE(stackFunc);
+
+ // Same argument as above about truncation
+ uint32 stackOffset = static_cast<uint32>(threadState->errfunc);
+ info->writeStream->writeUint32LE(stackOffset);
+
+ // Finally, record upvalues which need to be reopened
+ // See the comment above serializeUpVal() for why we do this
+
+ UpVal *upVal;
+
+ // >>>>> permTbl indexTbl ...... thread
+ for (GCObject *gcObject = threadState->openupval; gcObject != NULL; gcObject = upVal->next) {
+ upVal = gco2uv(gcObject);
+
+ /* Make sure upvalue is really open */
+ assert(upVal->v != &upVal->u.value);
+
+ pushUpValue(info->luaState, upVal);
+ // >>>>> permTbl indexTbl ...... thread upVal
+
+ persist(info);
+
+ lua_pop(info->luaState, 1);
+ // >>>>> permTbl indexTbl ...... thread
+
+ // Same argument as above about truncation
+ uint32 stackpos = static_cast<uint32>(upVal->v - threadState->stack);
+ info->writeStream->writeUint32LE(stackpos);
+ }
+
+ // >>>>> permTbl indexTbl ...... thread
+ lua_pushnil(info->luaState);
+ // >>>>> permTbl indexTbl ...... thread nil
+
+ // Use nil as a terminator
+ persist(info);
+
+ lua_pop(info->luaState, 1);
+ // >>>>> permTbl indexTbl ...... thread
+}
+
+static void persistProto(SerializationInfo *info) {
+ // >>>>> permTbl indexTbl ...... proto
+ Proto *proto = gco2p(getObject(info->luaState, -1)->value.gc);
+
+ // Make sure there is enough room on the stack
+ lua_checkstack(info->luaState, 2);
+
+ // Serialize constant refs */
+ info->writeStream->writeSint32LE(proto->sizek);
+
+ for (int i = 0; i < proto->sizek; ++i) {
+ pushObject(info->luaState, &proto->k[i]);
+ // >>>>> permTbl indexTbl ...... proto const
+
+ persist(info);
+
+ lua_pop(info->luaState, 1);
+ // >>>>> permTbl indexTbl ...... proto
+ }
+
+ // >>>>> permTbl indexTbl ...... proto
+
+ // Serialize inner Proto refs
+ info->writeStream->writeSint32LE(proto->sizep);
+
+ for (int i = 0; i < proto->sizep; ++i)
+ {
+ pushProto(info->luaState, proto->p[i]);
+ // >>>>> permTbl indexTbl ...... proto subProto */
+
+ persist(info);
+
+ lua_pop(info->luaState, 1);
+ // >>>>> permTbl indexTbl ...... proto
+ }
+
+ // >>>>> permTbl indexTbl ...... proto
+
+ // Serialize the code
+ info->writeStream->writeSint32LE(proto->sizecode);
+
+ uint32 len = static_cast<uint32>(sizeof(Instruction) * proto->sizecode);
+ info->writeStream->write(proto->code, len);
+
+
+ // Serialize upvalue names
+ info->writeStream->writeSint32LE(proto->sizeupvalues);
+
+ for (int i = 0; i < proto->sizeupvalues; ++i)
+ {
+ pushString(info->luaState, proto->upvalues[i]);
+ // >>>>> permTbl indexTbl ...... proto str
+
+ persist(info);
+
+ lua_pop(info->luaState, 1);
+ // >>>>> permTbl indexTbl ...... proto
+ }
+
+
+ // Serialize local variable infos
+ info->writeStream->writeSint32LE(proto->sizelocvars);
+
+ for (int i = 0; i < proto->sizelocvars; ++i) {
+ pushString(info->luaState, proto->locvars[i].varname);
+ // >>>>> permTbl indexTbl ...... proto str
+
+ persist(info);
+
+ lua_pop(info->luaState, 1);
+ // >>>>> permTbl indexTbl ...... proto
+
+ info->writeStream->writeSint32LE(proto->locvars[i].startpc);
+ info->writeStream->writeSint32LE(proto->locvars[i].endpc);
+ }
+
+
+ // Serialize source string
+ pushString(info->luaState, proto->source);
+ // >>>>> permTbl indexTbl ...... proto sourceStr
+
+ persist(info);
+
+ lua_pop(info->luaState, 1);
+ // >>>>> permTbl indexTbl ...... proto
+
+ // Serialize line numbers
+ info->writeStream->writeSint32LE(proto->sizelineinfo);
+
+ if (proto->sizelineinfo) {
+ uint32 len = static_cast<uint32>(sizeof(int) * proto->sizelineinfo);
+ info->writeStream->write(proto->lineinfo, len);
+ }
+
+ // Serialize linedefined and lastlinedefined
+ info->writeStream->writeSint32LE(proto->linedefined);
+ info->writeStream->writeSint32LE(proto->lastlinedefined);
+
+
+ // Serialize misc values
+ info->writeStream->writeByte(proto->nups);
+ info->writeStream->writeByte(proto->numparams);
+ info->writeStream->writeByte(proto->is_vararg);
+ info->writeStream->writeByte(proto->maxstacksize);
+}
+
+/* Upvalues are tricky. Here's why.
+ *
+ * A particular upvalue may be either "open", in which case its member v
+ * points into a thread's stack, or "closed" in which case it points to the
+ * upvalue itself. An upvalue is closed under any of the following conditions:
+ * -- The function that initially declared the variable "local" returns
+ * -- The thread in which the closure was created is garbage collected
+ *
+ * To make things wackier, just because a thread is reachable by Lua doesn't
+ * mean it's in our root set. We need to be able to treat an open upvalue
+ * from an unreachable thread as a closed upvalue.
+ *
+ * The solution:
+ * (a) For the purposes of serializing, don't indicate whether an upvalue is
+ * closed or not.
+ * (b) When unserializing, pretend that all upvalues are closed.
+ * (c) When serializing, persist all open upvalues referenced by a thread
+ * that is persisted, and tag each one with the corresponding stack position
+ * (d) When unserializing, "reopen" each of these upvalues as the thread is
+ * unserialized
+ */
+static void persistUpValue(SerializationInfo *info) {
+ // >>>>> permTbl indexTbl ...... upval
+ assert(ttype(getObject(info->luaState, -1)) == LUA_TUPVAL);
+ UpVal *upValue = gco2uv(getObject(info->luaState, -1)->value.gc);
+
+ // Make sure there is enough room on the stack
+ lua_checkstack(info->luaState, 1);
+
+ // We can't permit the upValue to linger around on the stack, as Lua
+ // will bail if its GC finds it.
+
+ lua_pop(info->luaState, 1);
+ // >>>>> permTbl indexTbl ......
+
+ pushObject(info->luaState, upValue->v);
+ // >>>>> permTbl indexTbl ...... obj
+
+ persist(info);
+ // >>>>> permTbl indexTbl ...... obj
+}
+
+static void persistUserData(SerializationInfo *info) {
+ // >>>>> permTbl rootObj ...... udata
+
+ // Make sure there is enough room on the stack
+ lua_checkstack(info->luaState, 2);
+
+ // Test if the object needs special serialization
+ if (serializeSpecialObject(info, 0)) {
+ return;
+ }
+
+ // Use literal persistence
+
+ // Hard cast to a uint32 length
+ // This could lead to truncation, but if we have a 4gb block of data, we have bigger problems
+ uint32 length = static_cast<uint32>(uvalue(getObject(info->luaState, -1))->len);
+ info->writeStream->writeUint32LE(length);
+
+ info->writeStream->write(lua_touserdata(info->luaState, -1), length);
+
+ // Serialize the metatable (if any)
+ if (!lua_getmetatable(info->luaState, -1)) {
+ lua_pushnil(info->luaState);
+ }
+
+ // >>>>> permTbl rootObj ...... udata metaTbl/nil
+ persist(info);
+
+ lua_pop(info->luaState, 1);
+ /* perms reftbl ... udata */
+}
+
+
+} // End of namespace Lua
diff --git a/engines/sword25/util/lua_persistence.h b/engines/sword25/util/lua_persistence.h
new file mode 100644
index 0000000000..53e3dee02e
--- /dev/null
+++ b/engines/sword25/util/lua_persistence.h
@@ -0,0 +1,67 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+/**
+ * This code is heavily based on the Pluto code base. Copyright below
+ */
+
+/* Tamed Pluto - Heavy-duty persistence for Lua
+ * Copyright (C) 2004 by Ben Sunshine-Hill, and released into the public
+ * domain. People making use of this software as part of an application
+ * are politely requested to email the author at sneftel@gmail.com
+ * with a brief description of the application, primarily to satisfy his
+ * curiosity.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Instrumented by Stefan Reich (info@luaos.net)
+ * for Mobile Lua (http://luaos.net/pages/mobile-lua.php)
+ */
+
+#ifndef LUA_PERSISTENCE_H
+#define LUA_PERSISTENCE_H
+
+#include "sword25/util/lua/lua.h"
+
+
+namespace Common {
+class WriteStream;
+class ReadStream;
+}
+
+
+namespace Lua {
+
+#define PERMANENT_TYPE 101
+
+void persistLua(lua_State *luaState, Common::WriteStream *writeStream);
+void unpersistLua(lua_State *luaState, Common::ReadStream *readStream);
+
+} // End of namespace Lua
+
+#endif
diff --git a/engines/sword25/util/lua_persistence_util.cpp b/engines/sword25/util/lua_persistence_util.cpp
new file mode 100644
index 0000000000..958fb7ac3c
--- /dev/null
+++ b/engines/sword25/util/lua_persistence_util.cpp
@@ -0,0 +1,393 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distri8buted in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+/**
+ * This code is heavily based on the pluto code base. Copyright below
+ */
+
+/* Tamed Pluto - Heavy-duty persistence for Lua
+ * Copyright (C) 2004 by Ben Sunshine-Hill, and released into the public
+ * domain. People making use of this software as part of an application
+ * are politely requested to email the author at sneftel@gmail.com
+ * with a brief description of the application, primarily to satisfy his
+ * curiosity.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Instrumented by Stefan Reich (info@luaos.net)
+ * for Mobile Lua (http://luaos.net/pages/mobile-lua.php)
+ */
+
+/**
+ * This code is heavily based on the Pluto code base. Copyright below
+ */
+
+/* Tamed Pluto - Heavy-duty persistence for Lua
+ * Copyright (C) 2004 by Ben Sunshine-Hill, and released into the public
+ * domain. People making use of this software as part of an application
+ * are politely requested to email the author at sneftel@gmail.com
+ * with a brief description of the application, primarily to satisfy his
+ * curiosity.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Instrumented by Stefan Reich (info@luaos.net)
+ * for Mobile Lua (http://luaos.net/pages/mobile-lua.php)
+ */
+
+
+#include "sword25/util/lua_persistence_util.h"
+
+#include "common/scummsys.h"
+
+#include "lua/lobject.h"
+#include "lua/lstate.h"
+#include "lua/lgc.h"
+#include "lua/lopcodes.h"
+
+
+namespace Lua {
+
+void *lua_realloc(lua_State *luaState, void *block, size_t osize, size_t nsize) {
+ global_State *globalState = G(luaState);
+
+ block = (*globalState->frealloc)(globalState->ud, block, osize, nsize);
+ globalState->totalbytes = (globalState->totalbytes - osize) + nsize;
+
+ return block;
+}
+
+void pushObject(lua_State *luaState, TValue *obj) {
+ setobj2s(luaState, luaState->top, obj);
+
+ api_check(luaState, luaState->top < luaState->ci->top);
+ luaState->top++;
+}
+
+void pushProto(lua_State *luaState, Proto *proto) {
+ TValue obj;
+ setptvalue(luaState, &obj, proto);
+
+ pushObject(luaState, &obj);
+}
+
+void pushUpValue(lua_State *luaState, UpVal *upval) {
+ TValue obj;
+
+ obj.value.gc = cast(GCObject *, upval);
+ obj.tt = LUA_TUPVAL;
+ checkliveness(G(L), obj);
+
+ pushObject(luaState, &obj);
+}
+
+void pushString(lua_State *luaState, TString *str) {
+ TValue o;
+ setsvalue(luaState, &o, str);
+
+ pushObject(luaState, &o);
+}
+
+/* A simple reimplementation of the unfortunately static function luaA_index.
+ * Does not support the global table, registry, or upvalues. */
+StkId getObject(lua_State *luaState, int stackpos) {
+ if (stackpos > 0) {
+ lua_assert(luaState->base + stackpos - 1 < luaState->top);
+ return luaState->base + stackpos - 1;
+ } else {
+ lua_assert(L->top - stackpos >= L->base);
+ return luaState->top + stackpos;
+ }
+}
+
+void lua_linkObjToGC(lua_State *luaState, GCObject *obj, lu_byte type) {
+ global_State *globalState = G(luaState);
+
+ obj->gch.next = globalState->rootgc;
+ globalState->rootgc = obj;
+ obj->gch.marked = luaC_white(globalState);
+ obj->gch.tt = type;
+}
+
+Closure *lua_newLclosure(lua_State *luaState, int numElements, Table *elementTable) {
+ Closure *c = (Closure *)lua_malloc(luaState, sizeLclosure(numElements));
+ lua_linkObjToGC(luaState, obj2gco(c), LUA_TFUNCTION);
+
+ c->l.isC = 0;
+ c->l.env = elementTable;
+ c->l.nupvalues = cast_byte(numElements);
+
+ while (numElements--) {
+ c->l.upvals[numElements] = NULL;
+ }
+
+ return c;
+}
+
+void pushClosure(lua_State *luaState, Closure *closure) {
+ TValue obj;
+ setclvalue(luaState, &obj, closure);
+ pushObject(luaState, &obj);
+}
+
+Proto *createProto(lua_State *luaState) {
+ Proto *newProto = (Proto *)lua_malloc(luaState, sizeof(Proto));
+ lua_linkObjToGC(luaState, obj2gco(newProto), LUA_TPROTO);
+
+ newProto->k = NULL;
+ newProto->sizek = 0;
+ newProto->p = NULL;
+ newProto->sizep = 0;
+ newProto->code = NULL;
+ newProto->sizecode = 0;
+ newProto->sizelineinfo = 0;
+ newProto->sizeupvalues = 0;
+ newProto->nups = 0;
+ newProto->upvalues = NULL;
+ newProto->numparams = 0;
+ newProto->is_vararg = 0;
+ newProto->maxstacksize = 0;
+ newProto->lineinfo = NULL;
+ newProto->sizelocvars = 0;
+ newProto->locvars = NULL;
+ newProto->linedefined = 0;
+ newProto->lastlinedefined = 0;
+ newProto->source = NULL;
+
+ return newProto;
+}
+
+TString *createString(lua_State *luaState, const char *str, size_t len) {
+ TString *res;
+ lua_pushlstring(luaState, str, len);
+
+ res = rawtsvalue(luaState->top - 1);
+ lua_pop(luaState, 1);
+
+ return res;
+}
+
+Proto *makeFakeProto(lua_State *L, lu_byte nups) {
+ Proto *p = createProto(L);
+
+ p->sizelineinfo = 1;
+ p->lineinfo = lua_newVector(L, 1, int);
+ p->lineinfo[0] = 1;
+ p->sizecode = 1;
+ p->code = lua_newVector(L, 1, Instruction);
+ p->code[0] = CREATE_ABC(OP_RETURN, 0, 1, 0);
+ p->source = createString(L, "", 0);
+ p->maxstacksize = 2;
+ p->nups = nups;
+ p->sizek = 0;
+ p->sizep = 0;
+
+ return p;
+}
+
+UpVal *createUpValue(lua_State *luaState, int stackpos) {
+ UpVal *upValue = (UpVal *)lua_malloc(luaState, sizeof(UpVal));
+ lua_linkObjToGC(luaState, (GCObject *)upValue, LUA_TUPVAL);
+ upValue->tt = LUA_TUPVAL;
+ upValue->v = &upValue->u.value;
+ upValue->u.l.prev = NULL;
+ upValue->u.l.next = NULL;
+
+ const TValue *o2 = (TValue *)getObject(luaState, stackpos);
+ upValue->v->value = o2->value;
+ upValue->v->tt = o2->tt;
+ checkliveness(G(L), upValue->v);
+
+ return upValue;
+}
+
+void unboxUpValue(lua_State *luaState) {
+ // >>>>> ...... func
+ LClosure *lcl;
+ UpVal *uv;
+
+ lcl = (LClosure *)clvalue(getObject(luaState, -1));
+ uv = lcl->upvals[0];
+
+ lua_pop(luaState, 1);
+ // >>>>> ......
+
+ pushUpValue(luaState, uv);
+ // >>>>> ...... upValue
+}
+
+size_t appendStackToStack_reverse(lua_State *from, lua_State *to) {
+ for (StkId id = from->top - 1; id >= from->stack; --id) {
+ setobj2s(to, to->top, id);
+ to->top++;
+ }
+
+ return from->top - from->stack;
+}
+
+void correctStack(lua_State *L, TValue *oldstack) {
+ CallInfo *ci;
+ GCObject *up;
+ L->top = (L->top - oldstack) + L->stack;
+ for (up = L->openupval; up != NULL; up = up->gch.next)
+ gco2uv(up)->v = (gco2uv(up)->v - oldstack) + L->stack;
+ for (ci = L->base_ci; ci <= L->ci; ci++) {
+ ci->top = (ci->top - oldstack) + L->stack;
+ ci->base = (ci->base - oldstack) + L->stack;
+ ci->func = (ci->func - oldstack) + L->stack;
+ }
+ L->base = (L->base - oldstack) + L->stack;
+}
+
+void lua_reallocstack(lua_State *L, int newsize) {
+ TValue *oldstack = L->stack;
+ int realsize = newsize + 1 + EXTRA_STACK;
+
+ lua_reallocvector(L, L->stack, L->stacksize, realsize, TValue);
+ L->stacksize = realsize;
+ L->stack_last = L->stack + newsize;
+ correctStack(L, oldstack);
+}
+
+void lua_growstack(lua_State *L, int n) {
+ // Double size is enough?
+ if (n <= L->stacksize) {
+ lua_reallocstack(L, 2 * L->stacksize);
+ } else {
+ lua_reallocstack(L, L->stacksize + n);
+ }
+}
+
+void lua_reallocCallInfo(lua_State *lauState, int newsize) {
+ CallInfo *oldci = lauState->base_ci;
+ lua_reallocvector(lauState, lauState->base_ci, lauState->size_ci, newsize, CallInfo);
+
+ lauState->size_ci = newsize;
+ lauState->ci = (lauState->ci - oldci) + lauState->base_ci;
+ lauState->end_ci = lauState->base_ci + lauState->size_ci - 1;
+}
+
+void GCUnlink(lua_State *luaState, GCObject *gco) {
+ GCObject *prevslot;
+ if (G(luaState)->rootgc == gco) {
+ G(luaState)->rootgc = G(luaState)->rootgc->gch.next;
+ return;
+ }
+
+ prevslot = G(luaState)->rootgc;
+ while (prevslot->gch.next != gco) {
+ prevslot = prevslot->gch.next;
+ }
+
+ prevslot->gch.next = prevslot->gch.next->gch.next;
+}
+
+TString *lua_newlstr(lua_State *luaState, const char *str, size_t len) {
+ lua_pushlstring(luaState, str, len);
+ TString *luaStr = &(luaState->top - 1)->value.gc->ts;
+
+ lua_pop(luaState, 1);
+
+ return luaStr;
+}
+
+void lua_link(lua_State *luaState, GCObject *o, lu_byte tt) {
+ global_State *g = G(luaState);
+ o->gch.next = g->rootgc;
+ g->rootgc = o;
+ o->gch.marked = luaC_white(g);
+ o->gch.tt = tt;
+}
+
+Proto *lua_newproto(lua_State *luaState) {
+ Proto *f = (Proto *)lua_malloc(luaState, sizeof(Proto));
+ lua_link(luaState, obj2gco(f), LUA_TPROTO);
+ f->k = NULL;
+ f->sizek = 0;
+ f->p = NULL;
+ f->sizep = 0;
+ f->code = NULL;
+ f->sizecode = 0;
+ f->sizelineinfo = 0;
+ f->sizeupvalues = 0;
+ f->nups = 0;
+ f->upvalues = NULL;
+ f->numparams = 0;
+ f->is_vararg = 0;
+ f->maxstacksize = 0;
+ f->lineinfo = NULL;
+ f->sizelocvars = 0;
+ f->locvars = NULL;
+ f->linedefined = 0;
+ f->lastlinedefined = 0;
+ f->source = NULL;
+ return f;
+}
+
+UpVal *makeUpValue(lua_State *luaState, int stackPos) {
+ UpVal *uv = lua_new(luaState, UpVal);
+ lua_link(luaState, (GCObject *)uv, LUA_TUPVAL);
+ uv->tt = LUA_TUPVAL;
+ uv->v = &uv->u.value;
+ uv->u.l.prev = NULL;
+ uv->u.l.next = NULL;
+
+ setobj(luaState, uv->v, getObject(luaState, stackPos));
+
+ return uv;
+}
+
+void boxUpValue_start(lua_State *luaState) {
+ LClosure *closure;
+ closure = (LClosure *)lua_newLclosure(luaState, 1, hvalue(&luaState->l_gt));
+ pushClosure(luaState, (Closure *)closure);
+ // >>>>> ...... func
+ closure->p = makeFakeProto(luaState, 1);
+
+ // Temporarily initialize the upvalue to nil
+ lua_pushnil(luaState);
+ closure->upvals[0] = makeUpValue(luaState, -1);
+ lua_pop(luaState, 1);
+}
+
+void boxUpValue_finish(lua_State *luaState) {
+ // >>>>> ...... func obj
+ LClosure *lcl = (LClosure *)clvalue(getObject(luaState, -2));
+
+ lcl->upvals[0]->u.value = *getObject(luaState, -1);
+ lua_pop(luaState, 1);
+ // >>>>> ...... func
+}
+
+} // End of namespace Lua
diff --git a/engines/sword25/util/lua_persistence_util.h b/engines/sword25/util/lua_persistence_util.h
new file mode 100644
index 0000000000..4d0085e242
--- /dev/null
+++ b/engines/sword25/util/lua_persistence_util.h
@@ -0,0 +1,122 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distri8buted in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+/**
+ * This code is heavily based on the Pluto code base. Copyright below
+ */
+
+/* Tamed Pluto - Heavy-duty persistence for Lua
+ * Copyright (C) 2004 by Ben Sunshine-Hill, and released into the public
+ * domain. People making use of this software as part of an application
+ * are politely requested to email the author at sneftel@gmail.com
+ * with a brief description of the application, primarily to satisfy his
+ * curiosity.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Instrumented by Stefan Reich (info@luaos.net)
+ * for Mobile Lua (http://luaos.net/pages/mobile-lua.php)
+ */
+
+
+#ifndef LUA_PERISTENCE_UTIL_H
+#define LUA_PERISTENCE_UTIL_H
+
+
+struct lua_State;
+
+#include "lua/lobject.h"
+
+typedef TValue *StkId;
+
+namespace Lua {
+
+#define lua_malloc(luaState, nsize) lua_realloc(luaState, nullptr, 0, nsize)
+#define lua_reallocv(luaState, block, on, n, e) lua_realloc(luaState, block, (on) * (e), (n) * (e))
+#define lua_reallocvector(luaState, vec, oldn, n, T) ((vec) = (T *)(lua_reallocv(luaState, vec, oldn, n, sizeof(T))))
+#define lua_newVector(luaState, num, T) ((T *)lua_reallocv(luaState, nullptr, 0, num, sizeof(T)))
+#define lua_new(luaState,T) (T *)lua_malloc(luaState, sizeof(T))
+
+void *lua_realloc(lua_State *luaState, void *block, size_t osize, size_t nsize);
+
+void pushObject(lua_State *luaState, TValue *obj);
+void pushProto(lua_State *luaState, Proto *proto);
+void pushUpValue(lua_State *luaState, UpVal *upval);
+void pushString(lua_State *luaState, TString *str);
+
+StkId getObject(lua_State *luaState, int stackpos);
+
+void lua_linkObjToGC(lua_State *luaState, GCObject *obj, lu_byte type);
+
+#define sizeLclosure(n) ((sizeof(LClosure)) + sizeof(TValue *) * ((n) - 1))
+
+Closure *lua_newLclosure(lua_State *luaState, int numElements, Table *elementTable);
+void pushClosure(lua_State *luaState, Closure *closure);
+
+Proto *createProto(lua_State *luaState);
+Proto *makeFakeProto(lua_State *L, lu_byte nups);
+
+TString *createString(lua_State *luaState, const char *str, size_t len);
+
+UpVal *createUpValue(lua_State *luaState, int stackpos);
+void unboxUpValue(lua_State *luaState);
+
+/* Appends one stack to another stack, but the stack is reversed in the process */
+size_t appendStackToStack_reverse(lua_State *from, lua_State *to);
+void correctStack(lua_State *L, TValue *oldstack);
+void lua_reallocstack(lua_State *L, int newsize);
+void lua_growstack(lua_State *L, int n);
+
+void lua_reallocCallInfo(lua_State *lauState, int newsize);
+
+/* Does basically the opposite of luaC_link().
+ * Right now this function is rather inefficient; it requires traversing the
+ * entire root GC set in order to find one object. If the GC list were doubly
+ * linked this would be much easier, but there's no reason for Lua to have
+ * that. */
+void GCUnlink(lua_State *luaState, GCObject *gco);
+
+TString *lua_newlstr(lua_State *luaState, const char *str, size_t len);
+void lua_link(lua_State *luaState, GCObject *o, lu_byte tt);
+Proto *lua_newproto(lua_State *luaState) ;
+
+UpVal *makeUpValue(lua_State *luaState, int stackPos);
+/**
+ * The GC is not fond of finding upvalues in tables. We get around this
+ * during persistence using a weakly keyed table, so that the GC doesn't
+ * bother to mark them. This won't work in unpersisting, however, since
+ * if we make the values weak they'll be collected (since nothing else
+ * references them). Our solution, during unpersisting, is to represent
+ * upvalues as dummy functions, each with one upvalue.
+ */
+void boxUpValue_start(lua_State *luaState);
+void boxUpValue_finish(lua_State *luaState);
+
+} // End of namespace Lua
+
+#endif
diff --git a/engines/sword25/util/lua_unpersist.cpp b/engines/sword25/util/lua_unpersist.cpp
new file mode 100644
index 0000000000..ef0ef31041
--- /dev/null
+++ b/engines/sword25/util/lua_unpersist.cpp
@@ -0,0 +1,722 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+/**
+ * This code is heavily based on the Pluto code base. Copyright below
+ */
+
+/* Tamed Pluto - Heavy-duty persistence for Lua
+ * Copyright (C) 2004 by Ben Sunshine-Hill, and released into the public
+ * domain. People making use of this software as part of an application
+ * are politely requested to email the author at sneftel@gmail.com
+ * with a brief description of the application, primarily to satisfy his
+ * curiosity.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Instrumented by Stefan Reich (info@luaos.net)
+ * for Mobile Lua (http://luaos.net/pages/mobile-lua.php)
+ */
+
+
+#include "sword25/util/lua_persistence.h"
+
+#include "sword25/util/double_serialization.h"
+#include "sword25/util/lua_persistence_util.h"
+
+#include "common/stream.h"
+
+#include "lua/lobject.h"
+#include "lua/lstate.h"
+#include "lua/lgc.h"
+#include "lua/lopcodes.h"
+
+
+namespace Lua {
+
+struct UnSerializationInfo {
+ lua_State *luaState;
+ Common::ReadStream *readStream;
+};
+
+static void unpersist(UnSerializationInfo *info);
+
+static void unpersistBoolean(UnSerializationInfo *info);
+static void unpersistNumber(UnSerializationInfo *info);
+static void unpersistString(UnSerializationInfo *info);
+static void unpersistTable(UnSerializationInfo *info, int index);
+static void unpersistFunction(UnSerializationInfo *info, int index);
+static void unpersistThread(UnSerializationInfo *info, int index);
+static void unpersistProto(UnSerializationInfo *info, int index);
+static void unpersistUpValue(UnSerializationInfo *info, int index);
+static void unpersistUserData(UnSerializationInfo *info, int index);
+static void unpersistPermanent(UnSerializationInfo *info, int index);
+
+
+void unpersistLua(lua_State *luaState, Common::ReadStream *readStream) {
+ UnSerializationInfo info;
+ info.luaState = luaState;
+ info.readStream = readStream;
+
+ // The process starts with the lua stack as follows:
+ // >>>>> permTbl
+ // That's the table of permanents
+
+ // Make sure there is enough room on the stack
+ lua_checkstack(luaState, 3);
+
+ // Create a table to hold indexes of everything thats already been read
+ lua_newtable(luaState);
+ // >>>>> permTbl indexTbl
+
+ // Prevent garbage collection while we unserialize
+ lua_gc(luaState, LUA_GCSTOP, 0);
+
+ // Unserialize the root object
+ unpersist(&info);
+ // >>>>> permTbl indexTbl rootObj
+
+ // Re-start garbage collection
+ lua_gc(luaState, LUA_GCRESTART, 0);
+
+ // Remove the indexTbl
+ lua_replace(luaState, 2);
+ // >>>>> permTbl rootObj
+}
+
+/* The object is left on the stack. This is primarily used by unserialize, but
+ * may be used by GCed objects that may incur cycles in order to preregister
+ * the object. */
+static void registerObjectInIndexTable(UnSerializationInfo *info, int index) {
+ // >>>>> permTbl indexTbl ...... obj
+
+ // Make sure there is enough room on the stack
+ lua_checkstack(info->luaState, 2);
+
+ lua_pushlightuserdata(info->luaState, (void *)index);
+ // >>>>> permTbl indexTbl ...... obj index
+
+ lua_pushvalue(info->luaState, -2);
+ // >>>>> permTbl indexTbl ...... obj index obj
+
+ // Push the k/v pair into the indexTbl
+ lua_settable(info->luaState, 2);
+ // >>>>> permTbl indexTbl ...... obj
+}
+
+static void unpersist(UnSerializationInfo *info) {
+ // >>>>> permTbl indexTbl ......
+
+ // Make sure there is enough room on the stack
+ lua_checkstack(info->luaState, 2);
+
+ byte isARealValue = info->readStream->readByte();
+ if (isARealValue) {
+ int index = info->readStream->readSint32LE();
+ int type = info->readStream->readSint32LE();
+
+ switch (type) {
+ case LUA_TBOOLEAN:
+ unpersistBoolean(info);
+ break;
+ case LUA_TLIGHTUSERDATA:
+ // You can't serialize a pointer
+ // It would be meaningless on the next run
+ assert(0);
+ break;
+ case LUA_TNUMBER:
+ unpersistNumber(info);
+ break;
+ case LUA_TSTRING:
+ unpersistString(info);
+ break;
+ case LUA_TTABLE:
+ unpersistTable(info, index);
+ break;
+ case LUA_TFUNCTION:
+ unpersistFunction(info, index);
+ break;
+ case LUA_TTHREAD:
+ unpersistThread(info, index);
+ break;
+ case LUA_TPROTO:
+ unpersistProto(info, index);
+ break;
+ case LUA_TUPVAL:
+ unpersistUpValue(info, index);
+ break;
+ case LUA_TUSERDATA:
+ unpersistUserData(info, index);
+ break;
+ case PERMANENT_TYPE:
+ unpersistPermanent(info, index);
+ break;
+ default:
+ assert(0);
+ }
+
+
+ // >>>>> permTbl indexTbl ...... obj
+ assert(lua_type(info->luaState, -1) == type ||
+ type == PERMANENT_TYPE ||
+ // Remember, upvalues get a special dispensation, as described in boxUpValue
+ (lua_type(info->luaState, -1) == LUA_TFUNCTION && type == LUA_TUPVAL));
+
+ registerObjectInIndexTable(info, index);
+ // >>>>> permTbl indexTbl ...... obj
+ } else {
+ int index = info->readStream->readSint32LE();
+
+ if (index == 0) {
+ lua_pushnil(info->luaState);
+ // >>>>> permTbl indexTbl ...... nil
+ } else {
+ // Fetch the object from the indexTbl
+
+ lua_pushlightuserdata(info->luaState, (void *)index);
+ // >>>>> permTbl indexTbl ...... index
+
+ lua_gettable(info->luaState, 2);
+ // >>>>> permTbl indexTbl ...... ?obj?
+
+ assert(!lua_isnil(info->luaState, -1));
+ }
+ // >>>>> permTbl indexTbl ...... obj/nil
+ }
+
+ // >>>>> permTbl indexTbl ...... obj/nil
+}
+
+static void unpersistBoolean(UnSerializationInfo *info) {
+ // >>>>> permTbl indexTbl ......
+
+ // Make sure there is enough room on the stack
+ lua_checkstack(info->luaState, 1);
+
+ int value = info->readStream->readSint32LE();
+
+ lua_pushboolean(info->luaState, value);
+ // >>>>> permTbl indexTbl ...... bool
+}
+
+static void unpersistNumber(UnSerializationInfo *info) {
+ // >>>>> permTbl indexTbl ......
+
+ // Make sure there is enough room on the stack
+ lua_checkstack(info->luaState, 1);
+
+ // Read the serialized double
+ Util::SerializedDouble serializedValue;
+ serializedValue.significandOne = info->readStream->readUint32LE();
+ serializedValue.signAndSignificandTwo = info->readStream->readUint32LE();
+ serializedValue.exponent = info->readStream->readSint16LE();
+
+ lua_Number value = Util::decodeDouble(serializedValue);
+
+ lua_pushnumber(info->luaState, value);
+ // >>>>> permTbl indexTbl ...... num
+}
+
+static void unpersistString(UnSerializationInfo *info) {
+ // >>>>> permTbl indexTbl ......
+
+ // Make sure there is enough room on the stack
+ lua_checkstack(info->luaState, 1);
+
+ uint32 length = info->readStream->readUint32LE();
+ char *string = new char[length];
+
+ info->readStream->read(string, length);
+ lua_pushlstring(info->luaState, string, length);
+
+ // >>>>> permTbl indexTbl ...... string
+
+ delete[] string;
+}
+
+static void unserializeSpecialTable(UnSerializationInfo *info, int index) {
+ // >>>>> permTbl indexTbl ......
+
+ // Make sure there is enough room on the stack
+ lua_checkstack(info->luaState, 1);
+
+ unpersist(info);
+
+ // >>>>> permTbl indexTbl ...... spfunc
+ lua_call(info->luaState, 0, 1);
+ // >>>>> permTbl indexTbl ...... tbl
+}
+
+static void unserializeLiteralTable(UnSerializationInfo *info, int index) {
+ // >>>>> permTbl indexTbl ......
+
+ // Make sure there is enough room on the stack
+ lua_checkstack(info->luaState, 3);
+
+ // Preregister table for handling of cycles
+ lua_newtable(info->luaState);
+
+ // >>>>> permTbl indexTbl ...... tbl
+ registerObjectInIndexTable(info, index);
+ // >>>>> permTbl indexTbl ...... tbl
+
+ // Unserialize metatable
+ unpersist(info);
+ // >>>>> permTbl indexTbl ...... tbl ?metaTbl/nil?
+
+ if (lua_istable(info->luaState, -1)) {
+ // >>>>> permTbl indexTbl ...... tbl metaTbl
+ lua_setmetatable(info->luaState, -2);
+ // >>>>> permTbl indexTbl ...... tbl
+ } else {
+ // >>>>> permTbl indexTbl ...... tbl nil
+ lua_pop(info->luaState, 1);
+ // >>>>> permTbl indexTbl ...... tbl
+ }
+ // >>>>> permTbl indexTbl ...... tbl
+
+
+ while (1) {
+ // >>>>> permTbl indexTbl ...... tbl
+ unpersist(info);
+ // >>>>> permTbl indexTbl ...... tbl key/nil
+
+ // The table serialization is nil terminated
+ if (lua_isnil(info->luaState, -1)) {
+ // >>>>> permTbl indexTbl ...... tbl nil
+ lua_pop(info->luaState, 1);
+ // >>>>> permTbl indexTbl ...... tbl
+
+ break;
+ }
+
+ // >>>>> permTbl indexTbl ...... tbl key
+ unpersist(info);
+ // >>>>> permTbl indexTbl ...... tbl value
+
+ lua_rawset(info->luaState, -3);
+ // >>>>> permTbl indexTbl ...... tbl
+ }
+}
+
+void unpersistTable(UnSerializationInfo *info, int index) {
+ // >>>>> permTbl indexTbl ......
+
+ // Make sure there is enough room on the stack
+ lua_checkstack(info->luaState, 1);
+
+ int isSpecial = info->readStream->readSint32LE();
+
+ if (isSpecial) {
+ unserializeSpecialTable(info, index);
+ // >>>>> permTbl indexTbl ...... tbl
+ } else {
+ unserializeLiteralTable(info, index);
+ // >>>>> permTbl indexTbl ...... tbl
+ }
+}
+
+void unpersistFunction(UnSerializationInfo *info, int index) {
+ // >>>>> permTbl indexTbl ......
+
+ // Make sure there is enough room on the stack
+ lua_checkstack(info->luaState, 2);
+
+ byte numUpValues = info->readStream->readByte();
+
+ LClosure *lclosure = (LClosure *)lua_newLclosure(info->luaState, numUpValues, hvalue(&info->luaState->l_gt));
+ pushClosure(info->luaState, (Closure *)lclosure);
+ // >>>>> permTbl indexTbl ...... func
+
+ // Put *some* proto in the closure, before the GC can find it
+ lclosure->p = makeFakeProto(info->luaState, numUpValues);
+
+ //Also, we need to temporarily fill the upvalues
+ lua_pushnil(info->luaState);
+ // >>>>> permTbl indexTbl ...... func nil
+
+ for (byte i = 0; i < numUpValues; ++i) {
+ lclosure->upvals[i] = createUpValue(info->luaState, -1);
+ }
+
+ lua_pop(info->luaState, 1);
+ // >>>>> permTbl indexTbl ...... func
+
+ // I can't see offhand how a function would ever get to be self-
+ // referential, but just in case let's register it early
+ registerObjectInIndexTable(info, index);
+
+ // Now that it's safe, we can get the real proto
+ unpersist(info);
+ // >>>>> permTbl indexTbl ...... func proto
+
+ lclosure->p = gco2p(getObject(info->luaState, -1)->value.gc);
+
+ lua_pop(info->luaState, 1);
+ // >>>>> permTbl indexTbl ...... func
+
+ for (byte i = 0; i < numUpValues; ++i) {
+ // >>>>> permTbl indexTbl ...... func
+ unpersist(info);
+ // >>>>> permTbl indexTbl ...... func func2
+
+ unboxUpValue(info->luaState);
+ // >>>>> permTbl indexTbl ...... func upValue
+ lclosure->upvals[i] = gco2uv(getObject(info->luaState, -1)->value.gc);
+
+ lua_pop(info->luaState, 1);
+ // >>>>> permTbl indexTbl ...... func
+ }
+
+ // Finally, the fenv
+ unpersist(info);
+
+ // >>>>> permTbl indexTbl ...... func ?fenv/nil?
+ if (!lua_isnil(info->luaState, -1)) {
+ // >>>>> permTbl indexTbl ...... func fenv
+ lua_setfenv(info->luaState, -2);
+ // >>>>> permTbl indexTbl ...... func
+ } else {
+ // >>>>> permTbl indexTbl ...... func nil
+ lua_pop(info->luaState, 1);
+ // >>>>> permTbl indexTbl ...... func
+ }
+
+ // >>>>> permTbl indexTbl ...... func
+}
+
+void unpersistThread(UnSerializationInfo *info, int index) {
+ // >>>>> permTbl indexTbl ......
+
+ lua_State *L2;
+ uint32 stacklimit = 0;
+
+ L2 = lua_newthread(info->luaState);
+ lua_checkstack(info->luaState, 3);
+
+ // L1: permTbl indexTbl ...... thread
+ // L2: (empty)
+ registerObjectInIndexTable(info, index);
+
+ // First, deserialize the object stack
+ uint32 stackSize = info->readStream->readUint32LE();
+ lua_growstack(info->luaState, (int)stackSize);
+
+ // Make sure that the first stack element (a nil, representing
+ // the imaginary top-level C function) is written to the very,
+ // very bottom of the stack
+ L2->top--;
+ for (uint32 i = 0; i < stackSize; ++i) {
+ unpersist(info);
+ // L1: permTbl indexTbl ...... thread obj*
+ }
+
+ lua_xmove(info->luaState, L2, stackSize);
+ // L1: permTbl indexTbl ...... thread
+ // L2: obj*
+
+ // Hereafter, stacks refer to L1
+
+
+ // Now, deserialize the CallInfo stack
+
+ uint32 numFrames = info->readStream->readUint32LE();
+
+ lua_reallocCallInfo(L2, numFrames * 2);
+ for (uint32 i = 0; i < numFrames; ++i) {
+ CallInfo *ci = L2->base_ci + i;
+ uint32 stackbase = info->readStream->readUint32LE();
+ uint32 stackfunc = info->readStream->readUint32LE();
+ uint32 stacktop = info->readStream->readUint32LE();
+
+ ci->nresults = info->readStream->readSint32LE();
+
+ uint32 savedpc = info->readStream->readUint32LE();
+
+ if (stacklimit < stacktop) {
+ stacklimit = stacktop;
+ }
+
+ ci->base = L2->stack + stackbase;
+ ci->func = L2->stack + stackfunc;
+ ci->top = L2->stack + stacktop;
+ ci->savedpc = (ci != L2->base_ci) ? ci_func(ci)->l.p->code + savedpc : 0;
+ ci->tailcalls = 0;
+
+ // Update the pointer each time, to keep the GC happy
+ L2->ci = ci;
+ }
+
+ // >>>>> permTbl indexTbl ...... thread
+ // Deserialize the state's other parameters, with the exception of upval stuff
+
+ L2->savedpc = L2->ci->savedpc;
+ L2->status = info->readStream->readByte();
+ uint32 stackbase = info->readStream->readUint32LE();
+ uint32 stacktop = info->readStream->readUint32LE();
+
+
+ L2->errfunc = info->readStream->readUint32LE();
+
+ L2->base = L2->stack + stackbase;
+ L2->top = L2->stack + stacktop;
+
+ // Finally, "reopen" upvalues. See serializeUpVal() for why we do this
+ UpVal *uv;
+ GCObject **nextslot = &L2->openupval;
+ global_State *g = G(L2);
+
+ while (true) {
+ unpersist(info);
+ // >>>>> permTbl indexTbl ...... thread upVal/nil
+
+ // The list is terminated by a nil
+ if (lua_isnil(info->luaState, -1)) {
+ // >>>>> permTbl indexTbl ...... thread nil
+ lua_pop(info->luaState, 1);
+ // >>>>> permTbl indexTbl ...... thread
+ break;
+ }
+
+ // >>>>> permTbl indexTbl ...... thread boxedUpVal
+ unboxUpValue(info->luaState);
+ // >>>>> permTbl indexTbl ...... thread boxedUpVal
+
+ uv = &(getObject(info->luaState, -1)->value.gc->uv);
+ lua_pop(info->luaState, 1);
+ // >>>>> permTbl indexTbl ...... thread
+
+ uint32 stackpos = info->readStream->readUint32LE();
+ uv->v = L2->stack + stackpos;
+
+ GCUnlink(info->luaState, (GCObject *)uv);
+
+ uv->marked = luaC_white(g);
+ *nextslot = (GCObject *)uv;
+ nextslot = &uv->next;
+ uv->u.l.prev = &G(L2)->uvhead;
+ uv->u.l.next = G(L2)->uvhead.u.l.next;
+ uv->u.l.next->u.l.prev = uv;
+ G(L2)->uvhead.u.l.next = uv;
+ lua_assert(uv->u.l.next->u.l.prev == uv && uv->u.l.prev->u.l.next == uv);
+ }
+ *nextslot = NULL;
+
+ // The stack must be valid at least to the highest value among the CallInfos
+ // 'top' and the values up to there must be filled with 'nil'
+ lua_checkstack(L2, (int)stacklimit);
+ for (StkId o = L2->top; o <= L2->top + stacklimit; ++o) {
+ setnilvalue(o);
+ }
+}
+
+void unpersistProto(UnSerializationInfo *info, int index) {
+ // >>>>> permTbl indexTbl ......
+
+ // We have to be careful. The GC expects a lot out of protos. In particular, we need
+ // to give the function a valid string for its source, and valid code, even before we
+ // actually read in the real code.
+ TString *source = lua_newlstr(info->luaState, "", 0);
+ Proto *p = lua_newproto(info->luaState);
+ p->source = source;
+ p->sizecode = 1;
+ p->code = (Instruction *)lua_reallocv(info->luaState, NULL, 0, 1, sizeof(Instruction));
+ p->code[0] = CREATE_ABC(OP_RETURN, 0, 1, 0);
+ p->maxstacksize = 2;
+ p->sizek = 0;
+ p->sizep = 0;
+
+ lua_checkstack(info->luaState, 2);
+
+ pushProto(info->luaState, p);
+ // >>>>> permTbl indexTbl ...... proto
+
+ // We don't need to register early, since protos can never ever be
+ // involved in cyclic references
+
+ // Read in constant references
+ int sizek = info->readStream->readSint32LE();
+ lua_reallocvector(info->luaState, p->k, 0, sizek, TValue);
+ for (int i = 0; i < sizek; ++i) {
+ // >>>>> permTbl indexTbl ...... proto
+ unpersist(info);
+ // >>>>> permTbl indexTbl ...... proto k
+
+ setobj2s(info->luaState, &p->k[i], getObject(info->luaState, -1));
+ p->sizek++;
+
+ lua_pop(info->luaState, 1);
+ // >>>>> permTbl indexTbl ...... proto
+ }
+ // >>>>> permTbl indexTbl ...... proto
+
+ // Read in sub-proto references
+
+ int sizep = info->readStream->readSint32LE();
+ lua_reallocvector(info->luaState, p->p, 0, sizep, Proto *);
+ for (int i = 0; i < sizep; ++i) {
+ // >>>>> permTbl indexTbl ...... proto
+ unpersist(info);
+ // >>>>> permTbl indexTbl ...... proto subproto
+
+ p->p[i] = (Proto *)getObject(info->luaState, -1)->value.gc;
+ p->sizep++;
+
+ lua_pop(info->luaState, 1);
+ // >>>>> permTbl indexTbl ...... proto
+ }
+ // >>>>> permTbl indexTbl ...... proto
+
+
+ // Read in code
+ p->sizecode = info->readStream->readSint32LE();
+ lua_reallocvector(info->luaState, p->code, 1, p->sizecode, Instruction);
+ info->readStream->read(p->code, sizeof(Instruction) * p->sizecode);
+
+
+ /* Read in upvalue names */
+ p->sizeupvalues = info->readStream->readSint32LE();
+ if (p->sizeupvalues) {
+ lua_reallocvector(info->luaState, p->upvalues, 0, p->sizeupvalues, TString *);
+ for (int i = 0; i < p->sizeupvalues; ++i) {
+ // >>>>> permTbl indexTbl ...... proto
+ unpersist(info);
+ // >>>>> permTbl indexTbl ...... proto str
+
+ p->upvalues[i] = lua_newlstr(info->luaState, lua_tostring(info->luaState, -1), strlen(lua_tostring(info->luaState, -1)));
+ lua_pop(info->luaState, 1);
+ // >>>>> permTbl indexTbl ...... proto
+ }
+ }
+ // >>>>> permTbl indexTbl ...... proto
+
+ // Read in local variable infos
+ p->sizelocvars = info->readStream->readSint32LE();
+ if (p->sizelocvars) {
+ lua_reallocvector(info->luaState, p->locvars, 0, p->sizelocvars, LocVar);
+ for (int i = 0; i < p->sizelocvars; ++i) {
+ // >>>>> permTbl indexTbl ...... proto
+ unpersist(info);
+ // >>>>> permTbl indexTbl ...... proto str
+
+ p->locvars[i].varname = lua_newlstr(info->luaState, lua_tostring(info->luaState, -1), strlen(lua_tostring(info->luaState, -1)));
+ lua_pop(info->luaState, 1);
+ // >>>>> permTbl indexTbl ...... proto
+
+ p->locvars[i].startpc = info->readStream->readSint32LE();
+ p->locvars[i].endpc = info->readStream->readSint32LE();
+ }
+ }
+ // >>>>> permTbl indexTbl ...... proto
+
+ // Read in source string
+ unpersist(info);
+ // >>>>> permTbl indexTbl ...... proto sourceStr
+
+ p->source = lua_newlstr(info->luaState, lua_tostring(info->luaState, -1), strlen(lua_tostring(info->luaState, -1)));
+ lua_pop(info->luaState, 1);
+ // >>>>> permTbl indexTbl ...... proto
+
+ // Read in line numbers
+ p->sizelineinfo = info->readStream->readSint32LE();
+ if (p->sizelineinfo) {
+ lua_reallocvector(info->luaState, p->lineinfo, 0, p->sizelineinfo, int);
+ info->readStream->read(p->lineinfo, sizeof(int) * p->sizelineinfo);
+ }
+
+
+ /* Read in linedefined and lastlinedefined */
+ p->linedefined = info->readStream->readSint32LE();
+ p->lastlinedefined = info->readStream->readSint32LE();
+
+ // Read in misc values
+ p->nups = info->readStream->readByte();
+ p->numparams = info->readStream->readByte();
+ p->is_vararg = info->readStream->readByte();
+ p->maxstacksize = info->readStream->readByte();
+}
+
+void unpersistUpValue(UnSerializationInfo *info, int index) {
+ // >>>>> permTbl indexTbl ......
+ lua_checkstack(info->luaState, 2);
+
+ boxUpValue_start(info->luaState);
+ // >>>>> permTbl indexTbl ...... func
+ registerObjectInIndexTable(info, index);
+
+ unpersist(info);
+ // >>>>> permTbl indexTbl ...... func obj
+
+ boxUpValue_finish(info->luaState);
+ // >>>>> permTbl indexTbl ...... func
+}
+
+void unpersistUserData(UnSerializationInfo *info, int index) {
+ // >>>>> permTbl indexTbl ......
+
+ // Make sure there is enough room on the stack
+ lua_checkstack(info->luaState, 2);
+
+ int isspecial = info->readStream->readSint32LE();
+ if (isspecial) {
+ unpersist(info);
+ // >>>>> permTbl indexTbl ...... specialFunc
+
+ lua_call(info->luaState, 0, 1);
+ // >>>>> permTbl indexTbl ...... udata
+ } else {
+ uint32 length = info->readStream->readUint32LE();
+ lua_newuserdata(info->luaState, length);
+ // >>>>> permTbl indexTbl ...... udata
+ registerObjectInIndexTable(info, index);
+
+ info->readStream->read(lua_touserdata(info->luaState, -1), length);
+
+ unpersist(info);
+ // >>>>> permTbl indexTbl ...... udata metaTable/nil
+
+ lua_setmetatable(info->luaState, -2);
+ // >>>>> permTbl indexTbl ...... udata
+ }
+ // >>>>> permTbl indexTbl ...... udata
+}
+
+void unpersistPermanent(UnSerializationInfo *info, int index) {
+ // >>>>> permTbl indexTbl ......
+
+ // Make sure there is enough room on the stack
+ lua_checkstack(info->luaState, 2);
+
+ unpersist(info);
+ // >>>>> permTbl indexTbl ...... permKey
+
+ lua_gettable(info->luaState, 1);
+ // >>>>> permTbl indexTbl ...... perm
+}
+
+} // End of namespace Lua
diff --git a/engines/sword25/util/pluto/CHANGELOG b/engines/sword25/util/pluto/CHANGELOG
deleted file mode 100644
index 1be321f898..0000000000
--- a/engines/sword25/util/pluto/CHANGELOG
+++ /dev/null
@@ -1,37 +0,0 @@
-$Id$
-
--- 2.4 --
-* Changed upval unboxing to allow upvals which contain func-housed cycles
-* Added stack checking to all stack-growing functions
-* Serialized debug information for functions
-
--- 2.3 --
-* Added LUALIB_API declaration for luaopen_pluto
-
--- 2.2 --
-* Rolled all internal Lua dependencies into the Pluto distribution
-* Made the unit tests depend on dynamically loading Pluto
-
--- 2.1 --
-* Various fixes to make the GC happy
-* stack size always expanded where necessary
-* fixed some memory leaks
-* GC disabled during unpersist
-* callstack initialized for traversal
-
-This changelog is maintained as of version 2.0alpha1.
-Earlier versions are changelogged on the LuaForge site.
-
--- 2.0 --
-* Fixed a few format changes to 5.1.3
-* Fixed myriad warnings
-* GCC compliance: not incrementing cast results
-* Fix for self-referring upvals
-* Renamed loading function to work with Lua module system
-* Loading tables with __newindex works
-* unpersist makes buffer copy
-
--- 2.0alpha1 --
-* Fixed all outstanding 5.0->5.1 conversion issues
-* Made heavier use of size_t in preference to int
-* Fixed GC/Upval issue (thanks to Eric Jacobs)
diff --git a/engines/sword25/util/pluto/FILEFORMAT b/engines/sword25/util/pluto/FILEFORMAT
deleted file mode 100644
index e7716675c7..0000000000
--- a/engines/sword25/util/pluto/FILEFORMAT
+++ /dev/null
@@ -1,168 +0,0 @@
-$Id$
-
-pluto_persist() produces a "hunk" of objects. Here's the file format adhered
-to by the function, and expected by pluto_unpersist().
-
-As a developer, I feel that where file format information is given it is of
-utmost importance that that information precisely and accurately reflects the
-actual operation of the application. Therefore, if you find any discrepancy
-between this and actual operation, please lambast me thoroughly over email.
-
-Pseudo-C is used to express the file format. Padding is assumed to be
-nonexistent. The keyword "one_of" is used to express a concept similar to
-"union", except that its size is the size of the actual datatype chosen. Thus,
-objects which contain, directly or indirectly, a one_of, may vary in size.
-
-
-struct Object {
- int firstTime; /* Whether this is the first time the object
- is being referenced */
- one_of {
- RealObject o; /* if firstTime == 1 */
- Reference r; /* if firstTime == 0 */
- };
-};
-
-struct Reference {
- int ref; /* The index the object was registered with */
-};
-
-struct RealObject {
- int type; /* The type of the object */
- one_of {
- Boolean b; /* If type == LUA_TBOOLEAN */
- LightUserData l; /* If type == LUA_TLIGHTUSERDATA */
- Number n; /* If type == LUA_TNUMBER */
- String s; /* If type == LUA_TSTRING */
- Table t; /* If type == LUA_TTABLE */
- Function f; /* If type == LUA_TFUNCTION */
- Userdata u; /* If type == LUA_TUSERDATA */
- Thread th; /* If type == LUA_TTHREAD */
- Proto p; /* If type == LUA_TPROTO (from lobject.h) */
- Upval uv; /* If type == LUA_TUPVAL (from lobject.h) */
- }; /* The actual object */
-};
-
-struct Boolean {
- int32 bvalue; /* 0 for false, 1 for true */
-};
-
-struct LightUserData {
- void* luvalue; /* The actual, literal pointer */
-};
-
-struct Number {
- lua_Number nvalue; /* The actual number */
-};
-
-struct String {
- int length; /* The length of the string */
- char str[length]; /* The actual string (not null terminated) */
-};
-
-struct Table {
- int isspecial; /* 1 if SP is used; 0 otherwise */
- one_of {
- Closure c; /* if isspecial == 1; closure to refill the table */
- LiteralTable t; /* if isspecial == 0; literal table info */
- };
-};
-
-struct LiteralTable {
- Object metatable; /* nil for default metatable */
- Pair p[]; /* key/value pairs */
- Object nil = nil; /* Nil reference to terminate */
-};
-
-struct Pair {
- Object key;
- Object value;
-};
-
-struct Function { /* Actually a closure */
- lu_byte nups; /* Number of upvalues the function uses */
- Object proto; /* The proto this function uses */
- Object upvals[nups]; /* All upvalues */
- Object fenv; /* The FEnv (nil for the global table)
-};
-
-struct Upval {
- Object obj; /* The object this upval refers to */
-}
-
-struct Userdata {
- int isSpecial; /* 1 for special persistence, 0 for literal
- one_of {
- LiteralUserdata lu; /* if is_special is 0 */
- SpecialUserdata su; /* if is_special is 1 */
- };
-};
-
-struct LiteralUserdata {
- Object metatable; /* The metatable (nil for default) */
- int length; /* Size of the data */
- char data[length]; /* The actual data */
-};
-
-struct SpecialUserdata {
- int length; /* The size of the data */
- Object func; /* The closure used to fill the userdata */
-};
-
-struct Thread {
- int stacksize; /* The size of the stack filled with objects,
- * including the "nil" that is hidden below
- * the bottom of the stack visible to C */
- Object stack[stacksize];/* Indices of all stack values, bottom up */
- int callinfosize; /* Number of elements in the CallInfo stack */
- CallInfo callinfostack[callinfosize]; /* The CallInfo stack */
- int base; /* base = L->base - L->stack; */
- int top; /* top = L->top - L->stack; */
- OpenUpval openupvals[]; /* Upvalues to open */
- Object nil = nil; /* To terminate the open upvalues list */
-};
-
-struct OpenUpval {
- Object upval; /* The upvalue */
- int stackpos; /* The stack position to "reopen" it to */
-
-};
-
-struct CallInfo {
- int base; /* base = ci->base - L->stack; */
- int top; /* top = ci->top - L->stack; */
- int pc; /* pc = ci->pc - proto->code; */
- int state; /* flags used by the CallInfo */
-};
-
-struct Proto {
- int sizek; /* Number of constants referenced */
- Object k[sizek]; /* Constants referenced */
- int sizep; /* Number of inner Protos referenced */
- Object p[sizep]; /* Inner Protos referenced */
- int sizecode; /* Number of instructions in code */
- Instruction code[sizecode]; /* The proto's code */
- ProtoDebug debuginfo; /* Debug information for the proto */
- lu_byte nups; /* Number of upvalues used */
- lu_byte numparams; /* Number of parameters taken */
- lu_byte is_vararg; /* 1 if function accepts varargs, 0 otherwise */
- lu_byte maxstacksize; /* Size of stack reserved for the function */
-};
-
-struct ProtoDebug {
- int sizeupvals; /* Number of upvalue names */
- Object upvals; /* Upvalue names */
- int sizelocvars; /* Number of local variable names */
- LocVar[sizelocvars]; /* Local variable names */
- Object source; /* The source code */
- int sizelineinfo; /* Number of opcode-line mappings */
- int lineinfo[sizelineinfo]; /* opcode-line mappings */
- int linedefined; /* Start of line range */
- int lastlinedefined; /* End of line range */
-};
-
-struct LocVar {
- Object name; /* Name of the local variable */
- int startpc; /* Point where variable is active */
- int endpc; /* Point where variable is dead */
-};
diff --git a/engines/sword25/util/pluto/README b/engines/sword25/util/pluto/README
deleted file mode 100644
index 838fce498b..0000000000
--- a/engines/sword25/util/pluto/README
+++ /dev/null
@@ -1,133 +0,0 @@
-$Id$
-
-PLUTO - Heavy duty persistence for Lua
-
-Pluto is a library which allows users to write arbitrarily large portions
-of the "Lua universe" into a flat file, and later read them back into the
-same or a different Lua universe. Object references are appropriately
-handled, such that the file contains everything needed to recreate the
-objects in question.
-
-Pluto has the following major features:
-* Can persist any Lua function
-* Can persist threads
-* Works with any Lua chunkreader/chunkwriter
-* Support for "invariant" permanent objects, of all datatypes
-* Can invoke metafunctions for custom persistence of tables and userdata
-
-Pluto 2.2 requires Lua 5.1.3. If you need to use Pluto with Lua
-5.0, please use version 1.2 of Pluto.
-
-Starting with version 2.2, Pluto no longer depends on the Lua sources.
-Instead, it subsumes the required headers into its own codebase.
-As a result, it may not work properly with Lua version 5.1.4 or later.
-
-Pluto may have bugs. Users are advised to define lua_assert in
-luaconf.h to something useful when compiling in debug mode, to catch
-assertions by Pluto and Lua.
-
-The Pluto library consists of two public functions.
-
-int pluto_persist(lua_State *L, lua_Chunkwriter writer, void *ud)
-
-This function recursively persists the Lua object in stack position 2
-and all other objects which are directly or indirectly referenced by
-it, except those referenced in the permanent object table. The data
-is written using the chunk-writer given, and that writer is passed
-the arbitrary pointer value ud.
-
-The Lua stack must contain exactly and only these two items, in order:
-
-1. A table of permanent objects, that should not be persisted. For each
-permanent object, the object itself should be the key, and a unique
-object of any type should be the value. Likely candidates for this table
-include Lua functions (including those in the Lua libraries) that are
-loaded at load-time. It must include all non-persistable objects that
-are referenced by the object to be persisted. The table is not modified
-by the function. Objects in this table are considered "opaque" and are
-not examined or descended into. Objects should not appear in the table
-multiple times; the result of doing this is undefined (though probably
-harmless). NOTE: If you are planning to persist threads, keep in mind
-that all yielded threads have coroutine.yield on the tops of their
-stacks. Since it's a C function, it should be put here. For complex
-permanents, it may be a good idea to use the __index meta-function of
-the permanents table to "search" for permanents.
-
-2. The single object to be persisted. In many cases, this will be the
-global table. For more flexibility, however, it may be something like a
-table built for the occasion, with various values to keep track of. The
-object may not be nil.
-
-
-int pluto_unpersist(lua_State *L, lua_Chunkreader reader, void *ud)
-
-This function loads in a Lua object and places it on top of the stack. All
-objects directly or indirectly referenced by it are also loaded.
-
-The Lua stack must contain, as its top value, a table of permanent
-objects. This table should be like the permanent object table used when
-persisting, but with the key and value of each pair reversed. These
-objects are used as substitutes for those referenced in their positions
-when persisting, and under most circumstances should be identical objects
-to those referenced in the permanents table used for persisting. It's
-okay for multiple keys to refer to the same object.
-
-
-RUNNING PLUTO FROM LUA:
-It is also possible to invoke pluto from a Lua script. The C function
-pluto_open() will register pluto.persist and pluto.unpersist, lua functions
-which operate on strings. The first takes a permanents table and a root
-object, and returns a string; the second takes a permanents table and a
-string, and returns the root object.
-
-An error will be raised if pluto.persist is called from a thread which is
-itself referenced by the root object.
-
-SPECIAL PERSISTENCE:
-Tables and userdata have special persistence semantics. These semantics are
-keyed to the value of the object's metatable's __persist member, if any. This
-member may be any of the following four values:
-1. Boolean "true": The table or userdata is persisted literally; tables are
-persisted member-by-member, and userdata are written out as literal data.
-2. Boolean "false": An error is returned, indicating that the object cannot
-be persisted.
-3. A function: This function should take one argument, the object in question,
-and return one result, a closure. This "fixup closure", in turn, will be
-persisted, and during unpersistence will be called. The closure will be
-responsible for recreating the object with the appropriate data, based on
-its upvalues.
-4. Nil, or no metatable. In the case of tables, the table is literally
-persisted. In the case of userdata, an error is returned.
-
-Here's an example of special persistence for a simple 3d vector object:
-
-vec = { x = 2, y = 1, z = 4 }
-setmetatable(vec, { __persist = function(oldtbl)
- local x = oldtbl.x
- local y = oldtbl.y
- local z = oldtbl.z
- local mt = getmetatable(oldtbl)
- return function()
- newtbl = {}
- newtbl.x = x
- newtbl.y = y
- newtbl.z = z
- setmetatable(newtbl, mt)
- return newtbl
- end
-end })
-
-Note how x, y, z, and the mt are explicitly pulled out of the table. It is
-important that the fixup closure returned not reference the original table
-directly, as that table would again be persisted as an upvalue, leading to an
-infinite loop. Also note that the object's metatable is NOT automatically
-persisted; it is necessary for the fixup closure to reset it, if it wants.
-
-LIMITATIONS/TODO:
-* Light userdata are persisted literally, as their pointer values. This
-may or may not be what you want.
-* Closures of C functions may not be persisted. Once it becomes possible
-to specify a C function "proto" as a permanent object, this restriction
-will be relaxed.
-
-BUGS: None known. Emphasis on the 'known'.
diff --git a/engines/sword25/util/pluto/THANKS b/engines/sword25/util/pluto/THANKS
deleted file mode 100644
index 443713fa61..0000000000
--- a/engines/sword25/util/pluto/THANKS
+++ /dev/null
@@ -1,9 +0,0 @@
-Pluto is surprisingly robust and useful. This would not be the case without
-the hard work and helpfulness of the following people, mentioned in no
-particular order:
-
-Ivko Stanilov
-Goran Adrinek
-Eric Jacobs
-Anolan Milanes
-Malte Thiesen
diff --git a/engines/sword25/util/pluto/pdep.cpp b/engines/sword25/util/pluto/pdep.cpp
deleted file mode 100644
index a32c43b42d..0000000000
--- a/engines/sword25/util/pluto/pdep.cpp
+++ /dev/null
@@ -1,112 +0,0 @@
-/* This file is derived from the Lua source code. Please see lua.h for
-the copyright statement.
-*/
-
-#include "pdep/pdep.h"
-
-#define api_incr_top(L) {api_check(L, L->top < L->ci->top); L->top++;}
-
-void pdep_pushobject (lua_State *L, const TValue *o) {
- setobj2s(L, L->top, o);
- api_incr_top(L);
-}
-
-void *pdep_realloc_ (lua_State *L, void *block, size_t osize, size_t nsize) {
- global_State *g = G(L);
- lua_assert((osize == 0) == (block == NULL));
- block = (*g->frealloc)(g->ud, block, osize, nsize);
- lua_assert((nsize == 0) == (block == NULL));
- g->totalbytes = (g->totalbytes - osize) + nsize;
- return block;
-}
-
-void pdep_link (lua_State *L, GCObject *o, lu_byte tt) {
- global_State *g = G(L);
- o->gch.next = g->rootgc;
- g->rootgc = o;
- o->gch.marked = luaC_white(g);
- o->gch.tt = tt;
-}
-
-Proto *pdep_newproto (lua_State *L) {
- Proto *f = pdep_new(L, Proto);
- pdep_link(L, obj2gco(f), LUA_TPROTO);
- f->k = NULL;
- f->sizek = 0;
- f->p = NULL;
- f->sizep = 0;
- f->code = NULL;
- f->sizecode = 0;
- f->sizelineinfo = 0;
- f->sizeupvalues = 0;
- f->nups = 0;
- f->upvalues = NULL;
- f->numparams = 0;
- f->is_vararg = 0;
- f->maxstacksize = 0;
- f->lineinfo = NULL;
- f->sizelocvars = 0;
- f->locvars = NULL;
- f->linedefined = 0;
- f->lastlinedefined = 0;
- f->source = NULL;
- return f;
-}
-
-Closure *pdep_newLclosure (lua_State *L, int nelems, Table *e) {
- Closure *c = cast(Closure *, pdep_malloc(L, sizeLclosure(nelems)));
- pdep_link(L, obj2gco(c), LUA_TFUNCTION);
- c->l.isC = 0;
- c->l.env = e;
- c->l.nupvalues = cast_byte(nelems);
- while (nelems--) c->l.upvals[nelems] = NULL;
- return c;
-}
-
-static void correctstack (lua_State *L, TValue *oldstack) {
- CallInfo *ci;
- GCObject *up;
- L->top = (L->top - oldstack) + L->stack;
- for (up = L->openupval; up != NULL; up = up->gch.next)
- gco2uv(up)->v = (gco2uv(up)->v - oldstack) + L->stack;
- for (ci = L->base_ci; ci <= L->ci; ci++) {
- ci->top = (ci->top - oldstack) + L->stack;
- ci->base = (ci->base - oldstack) + L->stack;
- ci->func = (ci->func - oldstack) + L->stack;
- }
- L->base = (L->base - oldstack) + L->stack;
-}
-
-
-void pdep_reallocstack (lua_State *L, int newsize) {
- TValue *oldstack = L->stack;
- int realsize = newsize + 1 + EXTRA_STACK;
- lua_assert(L->stack_last - L->stack == L->stacksize - EXTRA_STACK - 1);
- pdep_reallocvector(L, L->stack, L->stacksize, realsize, TValue);
- L->stacksize = realsize;
- L->stack_last = L->stack+newsize;
- correctstack(L, oldstack);
-}
-
-void pdep_growstack (lua_State *L, int n) {
- if (n <= L->stacksize) /* double size is enough? */
- pdep_reallocstack(L, 2*L->stacksize);
- else
- pdep_reallocstack(L, L->stacksize + n);
-}
-
-void pdep_reallocCI (lua_State *L, int newsize) {
- CallInfo *oldci = L->base_ci;
- pdep_reallocvector(L, L->base_ci, L->size_ci, newsize, CallInfo);
- L->size_ci = newsize;
- L->ci = (L->ci - oldci) + L->base_ci;
- L->end_ci = L->base_ci + L->size_ci - 1;
-}
-
-TString *pdep_newlstr (lua_State *L, const char *str, size_t l) {
- TString *res;
- lua_pushlstring(L, str, l);
- res = rawtsvalue(L->top-1);
- lua_pop(L, 1);
- return res;
-}
diff --git a/engines/sword25/util/pluto/pdep/README b/engines/sword25/util/pluto/pdep/README
deleted file mode 100644
index 3592754da0..0000000000
--- a/engines/sword25/util/pluto/pdep/README
+++ /dev/null
@@ -1,5 +0,0 @@
-These files are directly copied from the Lua distribution, with the
-exception of lzio.h, which is s/lua{ZM}/pdep/g and has an include removed.
-
-As such, unlike the rest of Pluto, they are released under the
-same terms as Lua. See "lua.h" for the copyright notice.
diff --git a/engines/sword25/util/pluto/pdep/lzio.h b/engines/sword25/util/pluto/pdep/lzio.h
deleted file mode 100644
index 2e37f8d202..0000000000
--- a/engines/sword25/util/pluto/pdep/lzio.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
-** $Id$
-** Buffered streams
-** See Copyright Notice in lua.h
-*/
-
-
-#ifndef lzio_h
-#define lzio_h
-
-#include "sword25/util/lua/lua.h"
-
-
-#define EOZ (-1) /* end of stream */
-
-typedef struct Zio ZIO;
-
-#define char2int(c) cast(int, cast(unsigned char, (c)))
-
-#define zgetc(z) (((z)->n--)>0 ? char2int(*(z)->p++) : pdep_fill(z))
-
-typedef struct Mbuffer {
- char *buffer;
- size_t n;
- size_t buffsize;
-} Mbuffer;
-
-#define pdep_initbuffer(L, buff) ((buff)->buffer = NULL, (buff)->buffsize = 0)
-
-#define pdep_buffer(buff) ((buff)->buffer)
-#define pdep_sizebuffer(buff) ((buff)->buffsize)
-#define pdep_bufflen(buff) ((buff)->n)
-
-#define pdep_resetbuffer(buff) ((buff)->n = 0)
-
-
-#define pdep_resizebuffer(L, buff, size) \
- (pdep_reallocvector(L, (buff)->buffer, (buff)->buffsize, size, char), \
- (buff)->buffsize = size)
-
-#define pdep_freebuffer(L, buff) pdep_resizebuffer(L, buff, 0)
-
-
-LUAI_FUNC char *pdep_openspace (lua_State *L, Mbuffer *buff, size_t n);
-LUAI_FUNC void pdep_init (lua_State *L, ZIO *z, lua_Reader reader,
- void *data);
-LUAI_FUNC size_t pdep_read (ZIO* z, void* b, size_t n); /* read next n bytes */
-LUAI_FUNC int pdep_lookahead (ZIO *z);
-
-
-
-/* --------- Private Part ------------------ */
-
-struct Zio {
- size_t n; /* bytes still unread */
- const char *p; /* current position in buffer */
- lua_Reader reader;
- void* data; /* additional data */
- lua_State *L; /* Lua state (for reader) */
-};
-
-
-LUAI_FUNC int pdep_fill (ZIO *z);
-
-#endif
diff --git a/engines/sword25/util/pluto/pdep/pdep.h b/engines/sword25/util/pluto/pdep/pdep.h
deleted file mode 100644
index 664fc812b5..0000000000
--- a/engines/sword25/util/pluto/pdep/pdep.h
+++ /dev/null
@@ -1,42 +0,0 @@
-#ifndef PDEP_H
-#define PDEP_H
-
-#include "sword25/util/lua/lua.h"
-#include "sword25/util/pluto/pdep/lzio.h"
-#include "sword25/util/lua/ldo.h"
-#include "sword25/util/lua/lfunc.h"
-#include "sword25/util/lua/lgc.h"
-#include "sword25/util/lua/llimits.h"
-#include "sword25/util/lua/lobject.h"
-#include "sword25/util/lua/lopcodes.h"
-#include "sword25/util/lua/lstate.h"
-#include "sword25/util/lua/lstring.h"
-#include "sword25/util/lua/lauxlib.h"
-
-
-#define pdep_reallocv(L,b,on,n,e) \
- pdep_realloc_(L, (b), (on)*(e), (n)*(e))
-#define pdep_reallocvector(L, v,oldn,n,t) \
- ((v)=cast(t *, pdep_reallocv(L, v, oldn, n, sizeof(t))))
-#define pdep_freearray(L, b, n, t) pdep_reallocv(L, (b), n, 0, sizeof(t))
-#define pdep_newvector(L,n,t) \
- cast(t *, pdep_reallocv(L, NULL, 0, n, sizeof(t)))
-#define pdep_new(L,t) cast(t *, pdep_malloc(L, sizeof(t)))
-#define pdep_malloc(L,t) pdep_realloc_(L, NULL, 0, (t))
-#define pdep_checkstack(L,n) \
- if ((char *)L->stack_last - (char *)L->top <= (n)*(int)sizeof(TValue)) \
- pdep_growstack(L, n); \
- else pdep_reallocstack(L, L->stacksize - EXTRA_STACK - 1);
-
-
-void pdep_pushobject (lua_State *L, const TValue *o);
-void *pdep_realloc_ (lua_State *L, void *block, size_t osize, size_t nsize);
-void pdep_link (lua_State *L, GCObject *o, lu_byte tt);
-Proto *pdep_newproto (lua_State *L);
-Closure *pdep_newLclosure (lua_State *L, int nelems, Table *e);
-void pdep_reallocstack (lua_State *L, int newsize);
-void pdep_growstack (lua_State *L, int n);
-void pdep_reallocCI (lua_State *L, int newsize);
-TString *pdep_newlstr (lua_State *L, const char *str, size_t l);
-
-#endif
diff --git a/engines/sword25/util/pluto/pluto.cpp b/engines/sword25/util/pluto/pluto.cpp
deleted file mode 100644
index 78b0a815e8..0000000000
--- a/engines/sword25/util/pluto/pluto.cpp
+++ /dev/null
@@ -1,2083 +0,0 @@
-/* $Id$ */
-
-/* Tamed Pluto - Heavy-duty persistence for Lua
- * Copyright (C) 2004 by Ben Sunshine-Hill, and released into the public
- * domain. People making use of this software as part of an application
- * are politely requested to email the author at sneftel@gmail.com
- * with a brief description of the application, primarily to satisfy his
- * curiosity.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
- * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- * Instrumented by Stefan Reich (info@luaos.net)
- * for Mobile Lua (http://luaos.net/pages/mobile-lua.php)
- */
-
-#include "sword25/util/lua/lua.h"
-#include "pluto.h"
-
-#undef TOTEXT
-
-#define USE_PDEP
-
-#ifdef USE_PDEP
-#include "pdep/pdep.h"
-#define LIF(prefix, name) pdep ## _ ## name
-#else
-#include "lapi.h"
-#include "ldo.h"
-#include "lfunc.h"
-#include "lgc.h"
-#include "llimits.h"
-#include "lmem.h"
-#include "lobject.h"
-#include "lopcodes.h"
-#include "lstate.h"
-#include "lstring.h"
-#include "lauxlib.h"
-#define LIF(prefix, name) lua ## prefix ## _ ## name
-#endif
-
-#include <string.h>
-
-
-/* Define this if you want size_t values to be written in 64-bit
- (even on 32-bit systems). Should eliminate at least one source of
- 32/64 bit incompatibility. */
-#define SIZES64
-
-
-/* #define PLUTO_DEBUG */
-
-
-#ifdef SIZES64
-#define VERSION "Tamed Pluto 1.0 with SIZES64 flag"
-#else
-#define VERSION "Tamed Pluto 1.0"
-#endif
-
-
-#ifdef PLUTO_DEBUG
-#include <stdio.h>
-#endif
-
-#define PLUTO_TPERMANENT 101
-
-#define verify(x) { int v = (int)((x)); v=v; lua_assert(v); }
-
-#define NUMTYPES 9
-static const char* typenames[] = {
- "nil",
- "boolean",
- "lightuserdata",
- "number",
- "string",
- "table",
- "function",
- "userdata",
- "thread"
-};
-
-static int humanReadable = 0;
-#define hrBufSize 200
-static char hrBuf[hrBufSize];
-
-typedef struct PersistInfo_t {
- lua_State *L;
- int counter;
- lua_Chunkwriter writer;
- void *ud;
-#ifdef PLUTO_DEBUG
- int level;
-#endif
-} PersistInfo;
-
-#ifdef PLUTO_DEBUG
-void printindent(int indent)
-{
- int il;
- for(il=0; il<indent; il++) {
- printf(" ");
- }
-}
-#endif
-
-/* lua_Chunkwriter signature: (lua_State *L, const void *p, size_t sz, void *ud).
- ud is a pointer to the WriterInfo struct (holds the buffer pointer)
-*/
-
-static void pi_write(PersistInfo *pi, const void *p, size_t size, void *ud) {
- if (humanReadable) {
- uint i;
- snprintf(hrBuf, hrBufSize, " pi_write %d ", (int) size);
- pi->writer(pi->L, hrBuf, strlen(hrBuf), ud);
- for (i = 0; i < size; i++) {
- char b = ((char *)p)[i];
- snprintf(hrBuf, hrBufSize, "%X%X", (b >> 4) & 0xF, b & 0xF);
- pi->writer(pi->L, hrBuf, strlen(hrBuf), ud);
- }
- snprintf(hrBuf, hrBufSize, "\n");
- pi->writer(pi->L, hrBuf, strlen(hrBuf), ud);
- } else {
- pi->writer(pi->L, p, size, ud);
- }
-#ifdef TOTEXT
- int i;
- printf(" pi_write %d ", (int) size);
- for (i = 0; i < size; i++) {
- char b = ((char *)p)[i];
- printf("%X%X", (b >> 4) & 0xF, b & 0xF);
- }
- printf("\n");
-#endif
-}
-
-static void hrOut(PersistInfo *pi) {
- pi->writer(pi->L, hrBuf, strlen(hrBuf), pi->ud);
-}
-
-static void write_size(PersistInfo *pi, size_t *val)
-{
-#ifdef SIZES64
- int64 longval; /* yeah, you really need long long to get 8 bytes on win32... duh. */
- longval = *val;
- pi_write(pi, &longval, 8, pi->ud);
- if (humanReadable) {
- snprintf(hrBuf, hrBufSize, "write_size64 %ld\n", longval);
- hrOut(pi);
- }
-#ifdef TOTEXT
- printf("write_size64 %ld\n", longval);
-#endif
-#else
- pi_write(pi, val, sizeof(size_t), pi->ud);
- if (humanReadable) {
- snprintf(hrBuf, hrBufSize, "write_size %ld\n", *((size_t *)val));
- hrOut(pi);
- }
-#ifdef TOTEXT
- printf("write_size %ld\n", *val);
-#endif
-#endif
-}
-
-static void read_size(ZIO *zio, size_t *val)
-{
-#ifdef SIZES64
- int64 longval;
- verify(LIF(Z,read)(zio, &longval, 8) == 0);
- *val = longval;
-#else
- verify(LIF(Z,read)(zio, val, sizeof(size_t)) == 0);
-#endif
-}
-
-
-/* Mutual recursion requires prototype */
-static void persist(PersistInfo *pi);
-
-/* A simple reimplementation of the unfortunately static function luaA_index.
- * Does not support the global table, registry, or upvalues. */
-static StkId getobject(lua_State *L, int stackpos)
-{
- if(stackpos > 0) {
- lua_assert(L->base+stackpos-1 < L->top);
- return L->base+stackpos-1;
- } else {
- lua_assert(L->top-stackpos >= L->base);
- return L->top+stackpos;
- }
-}
-
-/* Choose whether to do a regular or special persistence based on an object's
- * metatable. "default" is whether the object, if it doesn't have a __persist
- * entry, is literally persistable or not.
- * Pushes the unpersist closure and returns true if special persistence is
- * used. */
-static int persistspecialobject(PersistInfo *pi, int defaction)
-{
- /* perms reftbl ... obj */
- lua_checkstack(pi->L, 4);
- /* Check whether we should persist literally, or via the __persist
- * metafunction */
- if(!lua_getmetatable(pi->L, -1)) {
- if(defaction) {
- {
- int zero = 0;
- pi_write(pi, &zero, sizeof(int), pi->ud);
- if (humanReadable) {
- snprintf(hrBuf, hrBufSize, "persistspecialobject_write_zero\n");
- hrOut(pi);
- }
-#ifdef TOTEXT
- printf("persistspecialobject_write_zero\n");
-#endif
- }
- return 0;
- } else {
- lua_pushstring(pi->L, "Type not literally persistable by default");
- lua_error(pi->L);
- }
- }
- /* perms reftbl sptbl ... obj mt */
- lua_pushstring(pi->L, "__persist");
- /* perms reftbl sptbl ... obj mt "__persist" */
- lua_rawget(pi->L, -2);
- /* perms reftbl sptbl ... obj mt __persist? */
- if(lua_isnil(pi->L, -1)) {
- /* perms reftbl sptbl ... obj mt nil */
- lua_pop(pi->L, 2);
- /* perms reftbl sptbl ... obj */
- if(defaction) {
- {
- int zero = 0;
- pi_write(pi, &zero, sizeof(int), pi->ud);
- if (humanReadable) {
- snprintf(hrBuf, hrBufSize, "persistspecialobject_write_zero2\n");
- hrOut(pi);
- }
-#ifdef TOTEXT
- printf("persistspecialobject_write_zero2\n");
-#endif
- }
- return 0;
- } else {
- lua_pushstring(pi->L, "Type not literally persistable by default");
- lua_error(pi->L);
- return 0; /* not reached */
- }
- } else if(lua_isboolean(pi->L, -1)) {
- /* perms reftbl sptbl ... obj mt bool */
- if(lua_toboolean(pi->L, -1)) {
- /* perms reftbl sptbl ... obj mt true */
- lua_pop(pi->L, 2);
- /* perms reftbl sptbl ... obj */
- {
- int zero = 0;
- pi_write(pi, &zero, sizeof(int), pi->ud);
- if (humanReadable) {
- snprintf(hrBuf, hrBufSize, "persistspecialobject_write_zero3\n");
- hrOut(pi);
- }
-#ifdef TOTEXT
- printf("persistspecialobject_write_zero3\n");
-#endif
- }
- return 0;
- } else {
- lua_pushstring(pi->L, "Metatable forbade persistence");
- lua_error(pi->L);
- return 0; /* not reached */
- }
- } else if(!lua_isfunction(pi->L, -1)) {
- lua_pushstring(pi->L, "__persist not nil, boolean, or function");
- lua_error(pi->L);
- }
- /* perms reftbl ... obj mt __persist */
- lua_pushvalue(pi->L, -3);
- /* perms reftbl ... obj mt __persist obj */
-#ifdef PLUTO_PASS_USERDATA_TO_PERSIST
- lua_pushlightuserdata(pi->L, (void *)pi->writer);
- lua_pushlightuserdata(pi->L, pi->ud);
- /* perms reftbl ... obj mt __persist obj ud */
- lua_call(pi->L, 3, 1);
- /* perms reftbl ... obj mt func? */
-#else
- lua_call(pi->L, 1, 1);
- /* perms reftbl ... obj mt func? */
-#endif
- /* perms reftbl ... obj mt func? */
- if(!lua_isfunction(pi->L, -1)) {
- lua_pushstring(pi->L, "__persist function did not return a function");
- lua_error(pi->L);
- }
- /* perms reftbl ... obj mt func */
- {
- int one = 1;
- pi_write(pi, &one, sizeof(int), pi->ud);
- if (humanReadable) {
- snprintf(hrBuf, hrBufSize, "persistspecialobject_write_one\n");
- hrOut(pi);
- }
-#ifdef TOTEXT
- printf("persistspecialobject_write_one\n");
-#endif
- }
- persist(pi);
- /* perms reftbl ... obj mt func */
- lua_pop(pi->L, 2);
- /* perms reftbl ... obj */
- return 1;
-}
-
-static void persisttable(PersistInfo *pi)
-{
- if (humanReadable) {
- snprintf(hrBuf, hrBufSize, "persisttable\n");
- hrOut(pi);
- }
-#ifdef TOTEXT
- printf("persisttable\n");
-#endif
-
- /* perms reftbl ... tbl */
- lua_checkstack(pi->L, 3);
- if(persistspecialobject(pi, 1)) {
- /* perms reftbl ... tbl */
- return;
- }
- /* perms reftbl ... tbl */
- /* First, persist the metatable (if any) */
- if(!lua_getmetatable(pi->L, -1)) {
- lua_pushnil(pi->L);
- }
- /* perms reftbl ... tbl mt/nil */
- persist(pi);
- lua_pop(pi->L, 1);
- /* perms reftbl ... tbl */
-
- /* Now, persist all k/v pairs */
- lua_pushnil(pi->L);
- /* perms reftbl ... tbl nil */
- while(lua_next(pi->L, -2)) {
- /* perms reftbl ... tbl k v */
- lua_pushvalue(pi->L, -2);
- /* perms reftbl ... tbl k v k */
- persist(pi);
- lua_pop(pi->L, 1);
- /* perms reftbl ... tbl k v */
- persist(pi);
- lua_pop(pi->L, 1);
- /* perms reftbl ... tbl k */
- }
- /* perms reftbl ... tbl */
- /* Terminate list */
- lua_pushnil(pi->L);
- /* perms reftbl ... tbl nil */
- persist(pi);
- lua_pop(pi->L, 1);
- /* perms reftbl ... tbl */
-}
-
-static void persistuserdata(PersistInfo *pi) {
- /* perms reftbl ... udata */
- lua_checkstack(pi->L, 2);
- if(persistspecialobject(pi, 0)) {
- /* perms reftbl ... udata */
- return;
- } else {
- /* Use literal persistence */
- size_t length = uvalue(getobject(pi->L, -1))->len;
- write_size(pi, &length);
- pi_write(pi, lua_touserdata(pi->L, -1), length, pi->ud);
- if (humanReadable) {
- snprintf(hrBuf, hrBufSize, "persistuserdata %ld\n", (long) length);
- hrOut(pi);
- }
-#ifdef TOTEXT
- printf("persistuserdata %ld\n", (long) length);
-#endif
- if(!lua_getmetatable(pi->L, -1)) {
- /* perms reftbl ... udata */
- lua_pushnil(pi->L);
- /* perms reftbl ... udata mt/nil */
- }
- persist(pi);
- lua_pop(pi->L, 1);
- /* perms reftbl ... udata */
- }
-}
-
-
-static Proto *toproto(lua_State *L, int stackpos)
-{
- return gco2p(getobject(L, stackpos)->value.gc);
-}
-
-static UpVal *toupval(lua_State *L, int stackpos)
-{
- lua_assert(ttype(getobject(L, stackpos)) == LUA_TUPVAL);
- return gco2uv(getobject(L, stackpos)->value.gc);
-}
-
-static void pushproto(lua_State *L, Proto *proto)
-{
- TValue o;
- setptvalue(L, &o, proto);
- LIF(A,pushobject)(L, &o);
-}
-
-#define setuvvalue(L,obj,x) \
- { TValue *i_o=(obj); \
- i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TUPVAL; \
- checkliveness(G(L),i_o); }
-
-static void pushupval(lua_State *L, UpVal *upval)
-{
- TValue o;
- setuvvalue(L, &o, upval);
- LIF(A,pushobject)(L, &o);
-}
-
-static void pushclosure(lua_State *L, Closure *closure)
-{
- TValue o;
- setclvalue(L, &o, closure);
- LIF(A,pushobject)(L, &o);
-}
-
-static void pushstring(lua_State *L, TString *s)
-{
- TValue o;
- setsvalue(L, &o, s);
- LIF(A,pushobject)(L, &o);
-}
-
-static void persistfunction(PersistInfo *pi)
-{
- /* perms reftbl ... func */
- Closure *cl = clvalue(getobject(pi->L, -1));
- lua_checkstack(pi->L, 2);
- if(cl->c.isC) {
- /* It's a C function. For now, we aren't going to allow
- * persistence of C closures, even if the "C proto" is
- * already in the permanents table. */
- lua_pushstring(pi->L, "Attempt to persist a C function");
- lua_error(pi->L);
- } else {
- /* It's a Lua closure. */
- {
- /* We don't really _NEED_ the number of upvals,
- * but it'll simplify things a bit */
- pi_write(pi, &cl->l.p->nups, sizeof(lu_byte), pi->ud);
- if (humanReadable) {
- snprintf(hrBuf, hrBufSize, "persistfunction_number_upvalues %d\n", (int) cl->l.p->nups);
- hrOut(pi);
- }
-#ifdef TOTEXT
- printf("persistfunction_number_upvalues %d\n", (int) cl->l.p->nups);
-#endif
- }
- /* Persist prototype */
- {
- pushproto(pi->L, cl->l.p);
- /* perms reftbl ... func proto */
- persist(pi);
- lua_pop(pi->L, 1);
- /* perms reftbl ... func */
- }
- /* Persist upvalue values (not the upvalue objects
- * themselves) */
- {
- int i;
- for(i=0; i<cl->l.p->nups; i++) {
- /* perms reftbl ... func */
- pushupval(pi->L, cl->l.upvals[i]);
- /* perms reftbl ... func upval */
- persist(pi);
- lua_pop(pi->L, 1);
- /* perms reftbl ... func */
- }
- /* perms reftbl ... func */
- }
- /* Persist function environment */
- {
- lua_getfenv(pi->L, -1);
- /* perms reftbl ... func fenv */
- if(lua_equal(pi->L, -1, LUA_GLOBALSINDEX)) {
- /* Function has the default fenv */
- /* perms reftbl ... func _G */
- lua_pop(pi->L, 1);
- /* perms reftbl ... func */
- lua_pushnil(pi->L);
- /* perms reftbl ... func nil */
- }
- /* perms reftbl ... func fenv/nil */
- persist(pi);
- lua_pop(pi->L, 1);
- /* perms reftbl ... func */
- }
- }
-}
-
-
-/* Upvalues are tricky. Here's why.
- *
- * A particular upvalue may be either "open", in which case its member v
- * points into a thread's stack, or "closed" in which case it points to the
- * upvalue itself. An upvalue is closed under any of the following conditions:
- * -- The function that initially declared the variable "local" returns
- * -- The thread in which the closure was created is garbage collected
- *
- * To make things wackier, just because a thread is reachable by Lua doesn't
- * mean it's in our root set. We need to be able to treat an open upvalue
- * from an unreachable thread as a closed upvalue.
- *
- * The solution:
- * (a) For the purposes of persisting, don't indicate whether an upvalue is
- * closed or not.
- * (b) When unpersisting, pretend that all upvalues are closed.
- * (c) When persisting, persist all open upvalues referenced by a thread
- * that is persisted, and tag each one with the corresponding stack position
- * (d) When unpersisting, "reopen" each of these upvalues as the thread is
- * unpersisted
- */
-static void persistupval(PersistInfo *pi)
-{
- /* perms reftbl ... upval */
- UpVal *uv = toupval(pi->L, -1);
- lua_checkstack(pi->L, 1);
-
- /* We can't permit the upval to linger around on the stack, as Lua
- * will bail if its GC finds it. */
-
- lua_pop(pi->L, 1);
- /* perms reftbl ... */
- LIF(A,pushobject)(pi->L, uv->v);
- /* perms reftbl ... obj */
- persist(pi);
- /* perms reftbl ... obj */
-}
-
-static void persistproto(PersistInfo *pi)
-{
- /* perms reftbl ... proto */
- Proto *p = toproto(pi->L, -1);
- lua_checkstack(pi->L, 2);
-
- /* Persist constant refs */
- {
- int i;
- pi_write(pi, &p->sizek, sizeof(int), pi->ud);
- if (humanReadable) {
- snprintf(hrBuf, hrBufSize, "persistproto_sizek %d\n", p->sizek);
- hrOut(pi);
- }
- #ifdef TOTEXT
- printf("persistproto_sizek %d\n", p->sizek);
- #endif
- for(i=0; i<p->sizek; i++) {
- LIF(A,pushobject)(pi->L, &p->k[i]);
- /* perms reftbl ... proto const */
- persist(pi);
- lua_pop(pi->L, 1);
- /* perms reftbl ... proto */
- }
- }
- /* perms reftbl ... proto */
-
- /* serialize inner Proto refs */
- {
- int i;
- pi_write(pi, &p->sizep, sizeof(int), pi->ud);
- if (humanReadable) {
- snprintf(hrBuf, hrBufSize, "persistproto_sizep %d\n", p->sizep);
- hrOut(pi);
- }
-#ifdef TOTEXT
- printf("persistproto_sizep %d\n", p->sizep);
-#endif
- for(i=0; i<p->sizep; i++)
- {
- pushproto(pi->L, p->p[i]);
- /* perms reftbl ... proto subproto */
- persist(pi);
- lua_pop(pi->L, 1);
- /* perms reftbl ... proto */
- }
- }
- /* perms reftbl ... proto */
-
- /* Serialize code */
- {
- int len;
- pi_write(pi, &p->sizecode, sizeof(int), pi->ud);
- if (humanReadable) {
- snprintf(hrBuf, hrBufSize, "persistproto_sizecode %d\n", p->sizecode);
- hrOut(pi);
- }
-#ifdef TOTEXT
- printf("persistproto_sizecode %d\n", p->sizecode);
-#endif
- len = sizeof(Instruction) * p->sizecode;
- pi_write(pi, p->code, len, pi->ud);
- if (humanReadable) {
- snprintf(hrBuf, hrBufSize, "persistproto_code %d\n", len);
- hrOut(pi);
- }
-#ifdef TOTEXT
- printf("persistproto_code %d\n", len);
-#endif
- }
-
- /* Serialize upvalue names */
- {
- int i;
- pi_write(pi, &p->sizeupvalues, sizeof(int), pi->ud);
- if (humanReadable) {
- snprintf(hrBuf, hrBufSize, "persistproto_upvalues %d\n", p->sizeupvalues);
- hrOut(pi);
- }
-#ifdef TOTEXT
- printf("persistproto_upvalues %d\n", p->sizeupvalues);
-#endif
- for(i=0; i<p->sizeupvalues; i++)
- {
- pushstring(pi->L, p->upvalues[i]);
- persist(pi);
- lua_pop(pi->L, 1);
- }
- }
- /* Serialize local variable infos */
- {
- int i;
- pi_write(pi, &p->sizelocvars, sizeof(int), pi->ud);
- if (humanReadable) {
- snprintf(hrBuf, hrBufSize, "persistproto_sizelocvars %d\n", p->sizelocvars);
- hrOut(pi);
- }
-#ifdef TOTEXT
- printf("persistproto_sizelocvars %d\n", p->sizelocvars);
-#endif
- for(i=0; i<p->sizelocvars; i++)
- {
- pushstring(pi->L, p->locvars[i].varname);
- persist(pi);
- lua_pop(pi->L, 1);
-
- pi_write(pi, &p->locvars[i].startpc, sizeof(int), pi->ud);
- if (humanReadable) {
- snprintf(hrBuf, hrBufSize, "persistproto_startpc %d\n", p->locvars[i].startpc);
- hrOut(pi);
- }
-#ifdef TOTEXT
- printf("persistproto_startpc %d\n", p->locvars[i].startpc);
-#endif
- pi_write(pi, &p->locvars[i].endpc, sizeof(int), pi->ud);
- if (humanReadable) {
- snprintf(hrBuf, hrBufSize, "persistproto_endpc %d\n", p->locvars[i].endpc);
- hrOut(pi);
- }
-#ifdef TOTEXT
- printf("persistproto_endpc %d\n", p->locvars[i].endpc);
-#endif
- }
- }
-
- /* Serialize source string */
- pushstring(pi->L, p->source);
- persist(pi);
- lua_pop(pi->L, 1);
-
- /* Serialize line numbers */
- {
- pi_write(pi, &p->sizelineinfo, sizeof(int), pi->ud);
- if (humanReadable) {
- snprintf(hrBuf, hrBufSize, "persistproto_sizelineinfo %d\n", p->sizelineinfo);
- hrOut(pi);
- }
-#ifdef TOTEXT
- printf("persistproto_sizelineinfo %d\n", p->sizelineinfo);
-#endif
- if (p->sizelineinfo)
- {
- int len;
- len = sizeof(int) * p->sizelineinfo;
- pi_write(pi, p->lineinfo, len, pi->ud);
- if (humanReadable) {
- snprintf(hrBuf, hrBufSize, "persistproto_lineinfo %d\n", len);
- hrOut(pi);
- }
-#ifdef TOTEXT
- printf("persistproto_lineinfo %d\n", len);
-#endif
- }
- }
-
- /* Serialize linedefined and lastlinedefined */
- pi_write(pi, &p->linedefined, sizeof(int), pi->ud);
- if (humanReadable) {
- snprintf(hrBuf, hrBufSize, "persistproto_linedefined %d\n", p->linedefined);
- hrOut(pi);
- }
-#ifdef TOTEXT
- printf("persistproto_linedefined %d\n", p->linedefined);
-#endif
- pi_write(pi, &p->lastlinedefined, sizeof(int), pi->ud);
- if (humanReadable) {
- snprintf(hrBuf, hrBufSize, "persistproto_lastlinedefined %d\n", p->lastlinedefined);
- hrOut(pi);
- }
-#ifdef TOTEXT
- printf("persistproto_lastlinedefined %d\n", p->lastlinedefined);
-#endif
-
- /* Serialize misc values */
- {
- pi_write(pi, &p->nups, sizeof(lu_byte), pi->ud);
- if (humanReadable) {
- snprintf(hrBuf, hrBufSize, "persistproto_nups %d\n", (int) p->nups);
- hrOut(pi);
- }
-#ifdef TOTEXT
- printf("persistproto_nups %d\n", (int) p->nups);
-#endif
- pi_write(pi, &p->numparams, sizeof(lu_byte), pi->ud);
- if (humanReadable) {
- snprintf(hrBuf, hrBufSize, "persistproto_numparams %d\n", (int) p->numparams);
- hrOut(pi);
- }
-#ifdef TOTEXT
- printf("persistproto_numparams %d\n", (int) p->numparams);
-#endif
- pi_write(pi, &p->is_vararg, sizeof(lu_byte), pi->ud);
- if (humanReadable) {
- snprintf(hrBuf, hrBufSize, "persistproto_is_vararg %d\n", (int) p->is_vararg);
- hrOut(pi);
- }
-#ifdef TOTEXT
- printf("persistproto_is_vararg %d\n", (int) p->is_vararg);
-#endif
- pi_write(pi, &p->maxstacksize, sizeof(lu_byte), pi->ud);
- if (humanReadable) {
- snprintf(hrBuf, hrBufSize, "persistproto_maxstacksize %d\n", (int) p->maxstacksize);
- hrOut(pi);
- }
-#ifdef TOTEXT
- printf("persistproto_maxstacksize %d\n", (int) p->maxstacksize);
-#endif
- }
- /* We do not currently persist upvalue names, local variable names,
- * variable lifetimes, line info, or source code. */
-}
-
-/* Copies a stack, but the stack is reversed in the process
- */
-static size_t revappendstack(lua_State *from, lua_State *to)
-{
- StkId o;
- for(o=from->top-1; o>=from->stack; o--) {
- setobj2s(to, to->top, o);
- to->top++;
- }
- return from->top - from->stack;
-}
-
-/* Persist all stack members
- */
-static void persistthread(PersistInfo *pi)
-{
- size_t posremaining;
- lua_State *L2;
- /* perms reftbl ... thr */
- L2 = lua_tothread(pi->L, -1);
- lua_checkstack(pi->L, L2->top - L2->stack + 1);
- if(pi->L == L2) {
- lua_pushstring(pi->L, "Can't persist currently running thread");
- lua_error(pi->L);
- return; /* not reached */
- }
-
- /* Persist the stack */
- posremaining = revappendstack(L2, pi->L);
- /* perms reftbl ... thr (rev'ed contents of L2) */
- write_size(pi, &posremaining);
- for(; posremaining > 0; posremaining--) {
- persist(pi);
- lua_pop(pi->L, 1);
- }
- /* perms reftbl ... thr */
- /* Now, persist the CallInfo stack. */
- {
- size_t i, numframes = (L2->ci - L2->base_ci) + 1;
- write_size(pi, &numframes);
- for(i=0; i<numframes; i++) {
- CallInfo *ci = L2->base_ci + i;
- size_t stackbase = ci->base - L2->stack;
- size_t stackfunc = ci->func - L2->stack;
- size_t stacktop = ci->top - L2->stack;
- size_t savedpc = (ci != L2->base_ci) ?
- ci->savedpc - ci_func(ci)->l.p->code :
- 0;
- write_size(pi, &stackbase);
- write_size(pi, &stackfunc);
- write_size(pi, &stacktop);
- pi_write(pi, &ci->nresults, sizeof(int), pi->ud);
- if (humanReadable) {
- snprintf(hrBuf, hrBufSize, "persistthread %d\n", ci->nresults);
- hrOut(pi);
- }
-#ifdef TOTEXT
- printf("persistthread %d\n", ci->nresults);
-#endif
- write_size(pi, &savedpc);
- }
- }
-
- /* Serialize the state's other parameters, with the exception of upval stuff */
- {
- size_t stackbase = L2->base - L2->stack;
- size_t stacktop = L2->top - L2->stack;
- lua_assert(L2->nCcalls <= 1);
- pi_write(pi, &L2->status, sizeof(lu_byte), pi->ud);
- if (humanReadable) {
- snprintf(hrBuf, hrBufSize, "persistthread_status %d\n", (int) L2->status);
- hrOut(pi);
- }
-#ifdef TOTEXT
- printf("persistthread_status %d\n", (int) L2->status);
-#endif
- write_size(pi, &stackbase);
- write_size(pi, &stacktop);
-
- // ptrdiff_t changes sizes based on 32/64 bit
- // Hard cast to 64 bit size if SIZE64 is defined
-#ifdef SIZES64
- uint64 ptrIndex = static_cast<uint64>(L2->errfunc);
- pi_write(pi, &ptrIndex, sizeof(uint64), pi->ud);
-#else
- pi_write(pi, &L2->errfunc, sizeof(ptrdiff_t), pi->ud);
-#endif
- //write_size(pi, (size_t *)&L2->errfunc);
- }
-
- /* Finally, record upvalues which need to be reopened */
- /* See the comment above persistupval() for why we do this */
- {
- GCObject *gco;
- UpVal *uv;
- /* perms reftbl ... thr */
- for(gco = L2->openupval; gco != NULL; gco = uv->next) {
- size_t stackpos;
- uv = gco2uv(gco);
-
- /* Make sure upvalue is really open */
- lua_assert(uv->v != &uv->u.value);
- pushupval(pi->L, uv);
- /* perms reftbl ... thr uv */
- persist(pi);
- lua_pop(pi->L, 1);
- /* perms reftbl ... thr */
- stackpos = uv->v - L2->stack;
- write_size(pi, &stackpos);
- }
- /* perms reftbl ... thr */
- lua_pushnil(pi->L);
- /* perms reftbl ... thr nil */
- persist(pi);
- lua_pop(pi->L, 1);
- /* perms reftbl ... thr */
- }
- /* perms reftbl ... thr */
-}
-
-static void persistboolean(PersistInfo *pi)
-{
- int b = lua_toboolean(pi->L, -1);
- pi_write(pi, &b, sizeof(int), pi->ud);
- if (humanReadable) {
- snprintf(hrBuf, hrBufSize, "persistboolean %d\n", b);
- hrOut(pi);
- }
-#ifdef TOTEXT
- printf("persistboolean %d\n", b);
-#endif
-}
-
-static void persistlightuserdata(PersistInfo *pi)
-{
- void *p = lua_touserdata(pi->L, -1);
- pi_write(pi, &p, sizeof(void *), pi->ud);
- if (humanReadable) {
- snprintf(hrBuf, hrBufSize, "persistlightuserdata %p\n", p);
- hrOut(pi);
- }
-#ifdef TOTEXT
- printf("persistlightuserdata %d\n", (int) p);
-#endif
-}
-
-static void persistnumber(PersistInfo *pi)
-{
- lua_Number n = lua_tonumber(pi->L, -1);
- pi_write(pi, &n, sizeof(lua_Number), pi->ud);
- if (humanReadable) {
- snprintf(hrBuf, hrBufSize, "persistnumber %d (%d)\n", (int) n, (int) sizeof(lua_Number));
- hrOut(pi);
- }
-#ifdef TOTEXT
- printf("persistnumber %d (%d)\n", (int) n, (int) sizeof(lua_Number));
-#endif
-}
-
-static void persiststring(PersistInfo *pi)
-{
- if (humanReadable) {
- snprintf(hrBuf, hrBufSize, "persiststring\n");
- hrOut(pi);
- }
-#ifdef TOTEXT
- printf("persiststring\n");
-#endif
- size_t length = lua_strlen(pi->L, -1);
- write_size(pi, &length);
- const char* s = lua_tostring(pi->L, -1);
- pi_write(pi, s, length, pi->ud);
- if (humanReadable) {
- snprintf(hrBuf, hrBufSize, "persiststring %d \"%s\"\n", (int)length, s);
- hrOut(pi);
- }
-#ifdef TOTEXT
- printf("persiststring %d \"%s\"\n", length, s);
-#endif
-}
-
-/* Top-level delegating persist function
- */
-static void persist(PersistInfo *pi)
-{
- /* perms reftbl ... obj */
- lua_checkstack(pi->L, 2);
- /* If the object has already been written, write a reference to it */
- lua_pushvalue(pi->L, -1);
- /* perms reftbl ... obj obj */
- lua_rawget(pi->L, 2);
- /* perms reftbl ... obj ref? */
- if(!lua_isnil(pi->L, -1)) {
- /* perms reftbl ... obj ref */
- int zero = 0;
- pi_write(pi, &zero, sizeof(int), pi->ud);
- if (humanReadable) {
- snprintf(hrBuf, hrBufSize, "persist_seenobject\n");
- hrOut(pi);
- }
-#ifdef TOTEXT
- printf("persist_seenobject\n");
-#endif
- int *ref = (int *)lua_touserdata(pi->L, -1);
- pi_write(pi, ref, sizeof(int), pi->ud);
- if (humanReadable) {
- snprintf(hrBuf, hrBufSize, "persist_touserdata_ref %d\n", ref);
- hrOut(pi);
- }
-#ifdef TOTEXT
- printf("persist_touserdata_ref %d\n", ref);
-#endif
- lua_pop(pi->L, 1);
- /* perms reftbl ... obj ref */
-#ifdef PLUTO_DEBUG
- printindent(pi->level);
- printf("0 %d\n", ref);
-#endif
- return;
- }
- /* perms reftbl ... obj nil */
- lua_pop(pi->L, 1);
- /* perms reftbl ... obj */
- /* If the object is nil, write the pseudoreference 0 */
- if(lua_isnil(pi->L, -1)) {
- int zero = 0;
- /* firsttime */
- pi_write(pi, &zero, sizeof(int), pi->ud);
- /* ref */
- pi_write(pi, &zero, sizeof(int), pi->ud);
- if (humanReadable) {
- snprintf(hrBuf, hrBufSize, "persist_nil (last 2 lines)\n");
- hrOut(pi);
- }
-#ifdef TOTEXT
- printf("persist_nil (last 2 lines)\n");
-#endif
-#ifdef PLUTO_DEBUG
- printindent(pi->level);
- printf("0 0\n");
-#endif
- return;
- }
- {
- /* indicate that it's the first time */
- int one = 1;
- pi_write(pi, &one, sizeof(int), pi->ud);
- if (humanReadable) {
- snprintf(hrBuf, hrBufSize, "persist_newobject\n");
- hrOut(pi);
- }
-#ifdef TOTEXT
- printf("persist_newobject\n");
-#endif
- }
- lua_pushvalue(pi->L, -1);
- /* perms reftbl ... obj obj */
- int *ref = (int *)lua_newuserdata(pi->L, sizeof(int));
- *ref = ++(pi->counter);
- /* perms reftbl ... obj obj ref */
- lua_rawset(pi->L, 2);
- /* perms reftbl ... obj */
-
- pi_write(pi, &pi->counter, sizeof(int), pi->ud);
- if (humanReadable) {
- snprintf(hrBuf, hrBufSize, "persist_counter %d\n", pi->counter);
- hrOut(pi);
- }
-#ifdef TOTEXT
- printf("persist_counter %d\n", pi->counter);
-#endif
-
-
- /* At this point, we'll give the permanents table a chance to play. */
- {
- lua_pushvalue(pi->L, -1);
- /* perms reftbl ... obj obj */
- lua_gettable(pi->L, 1);
- /* perms reftbl ... obj permkey? */
- if(!lua_isnil(pi->L, -1)) {
- /* perms reftbl ... obj permkey */
- int type = PLUTO_TPERMANENT;
-#ifdef PLUTO_DEBUG
- printindent(pi->level);
- printf("1 %d PERM\n", pi->counter);
- pi->level++;
-#endif
- pi_write(pi, &type, sizeof(int), pi->ud);
- if (humanReadable) {
- snprintf(hrBuf, hrBufSize, "persist_permtype %d\n", type);
- hrOut(pi);
- }
-#ifdef TOTEXT
- printf("persist_permtype %d\n", type);
-#endif
- persist(pi);
- lua_pop(pi->L, 1);
- /* perms reftbl ... obj */
-#ifdef PLUTO_DEBUG
- pi->level--;
-#endif
- return;
- } else {
- /* perms reftbl ... obj nil */
- lua_pop(pi->L, 1);
- /* perms reftbl ... obj */
- }
- /* perms reftbl ... obj */
- }
- {
- int type = lua_type(pi->L, -1);
- pi_write(pi, &type, sizeof(int), pi->ud);
- if (humanReadable) {
- snprintf(hrBuf, hrBufSize, "persist %s\n", type >= 0 && type < NUMTYPES ? typenames[type] : "?");
- hrOut(pi);
- }
-#ifdef TOTEXT
- printf("persist %s\n", type >= 0 && type < NUMTYPES ? typenames[type] : "?");
-#endif
-
-#ifdef PLUTO_DEBUG
- printindent(pi->level);
- printf("1 %d %d\n", pi->counter, type);
- pi->level++;
-#endif
- }
-
- switch(lua_type(pi->L, -1)) {
- case LUA_TBOOLEAN:
- persistboolean(pi);
- break;
- case LUA_TLIGHTUSERDATA:
- persistlightuserdata(pi);
- break;
- case LUA_TNUMBER:
- persistnumber(pi);
- break;
- case LUA_TSTRING:
- persiststring(pi);
- break;
- case LUA_TTABLE:
- persisttable(pi);
- break;
- case LUA_TFUNCTION:
- persistfunction(pi);
- break;
- case LUA_TTHREAD:
- persistthread(pi);
- break;
- case LUA_TPROTO:
- persistproto(pi);
- break;
- case LUA_TUPVAL:
- persistupval(pi);
- break;
- case LUA_TUSERDATA:
- persistuserdata(pi);
- break;
- default:
- lua_assert(0);
- }
-#ifdef PLUTO_DEBUG
- pi->level--;
-#endif
-}
-
-void pluto_persist(lua_State *L, lua_Chunkwriter writer, void *ud)
-{
- PersistInfo pi;
-
- pi.counter = 0;
- pi.L = L;
- pi.writer = writer;
- pi.ud = ud;
-#ifdef PLUTO_DEBUG
- pi.level = 0;
-#endif
-
- lua_checkstack(L, 4);
- /* perms? rootobj? ...? */
- lua_assert(lua_gettop(L) == 2);
- /* perms rootobj */
- lua_assert(!lua_isnil(L, 2));
- /* perms rootobj */
- lua_newtable(L);
- /* perms rootobj reftbl */
-
- /* Now we're going to make the table weakly keyed. This prevents the
- * GC from visiting it and trying to mark things it doesn't want to
- * mark in tables, e.g. upvalues. All objects in the table are
- * a priori reachable, so it doesn't matter that we do this. */
- lua_newtable(L);
- /* perms rootobj reftbl mt */
- lua_pushstring(L, "__mode");
- /* perms rootobj reftbl mt "__mode" */
- lua_pushstring(L, "k");
- /* perms rootobj reftbl mt "__mode" "k" */
- lua_settable(L, 4);
- /* perms rootobj reftbl mt */
- lua_setmetatable(L, 3);
- /* perms rootobj reftbl */
- lua_insert(L, 2);
- /* perms reftbl rootobj */
- persist(&pi);
- /* perms reftbl rootobj */
- lua_remove(L, 2);
- /* perms rootobj */
-}
-
-typedef struct WriterInfo_t {
- char* buf;
- size_t buflen;
-} WriterInfo;
-
-static int bufwriter (lua_State *L, const void *p, size_t sz, void *ud) {
- const char *cp = (const char *)p;
- WriterInfo *wi = (WriterInfo *)ud;
-
- LIF(M,reallocvector)(L, wi->buf, wi->buflen, wi->buflen+sz, char);
- while(sz)
- {
- /* how dearly I love ugly C pointer twiddling */
- wi->buf[wi->buflen++] = *cp++;
- sz--;
- }
- return 0;
-}
-
-int persist_l(lua_State *L)
-{
- /* perms? rootobj? ...? */
- WriterInfo wi;
-
- wi.buf = NULL;
- wi.buflen = 0;
-
- lua_settop(L, 2);
- /* perms? rootobj? */
- luaL_checktype(L, 1, LUA_TTABLE);
- /* perms rootobj? */
- luaL_checktype(L, 1, LUA_TTABLE);
- /* perms rootobj */
-
- pluto_persist(L, bufwriter, &wi);
-
- lua_settop(L, 0);
- /* (empty) */
- lua_pushlstring(L, wi.buf, wi.buflen);
- /* str */
- pdep_freearray(L, wi.buf, wi.buflen, char);
- return 1;
-}
-
-typedef struct UnpersistInfo_t {
- lua_State *L;
- ZIO zio;
-#ifdef PLUTO_DEBUG
- int level;
-#endif
-} UnpersistInfo;
-
-static void unpersist(UnpersistInfo *upi);
-
-/* The object is left on the stack. This is primarily used by unpersist, but
- * may be used by GCed objects that may incur cycles in order to preregister
- * the object. */
-static void registerobject(int ref, UnpersistInfo *upi)
-{
- /* perms reftbl ... obj */
- lua_checkstack(upi->L, 2);
- lua_pushlightuserdata(upi->L, (void *)ref);
- /* perms reftbl ... obj ref */
- lua_pushvalue(upi->L, -2);
- /* perms reftbl ... obj ref obj */
- lua_settable(upi->L, 2);
- /* perms reftbl ... obj */
-}
-
-static void unpersistboolean(UnpersistInfo *upi)
-{
- /* perms reftbl ... */
- int b;
- lua_checkstack(upi->L, 1);
- verify(LIF(Z,read)(&upi->zio, &b, sizeof(int)) == 0);
- lua_pushboolean(upi->L, b);
- /* perms reftbl ... bool */
-}
-
-static void unpersistlightuserdata(UnpersistInfo *upi)
-{
- /* perms reftbl ... */
- void *p;
- lua_checkstack(upi->L, 1);
- verify(LIF(Z,read)(&upi->zio, &p, sizeof(void *)) == 0);
- lua_pushlightuserdata(upi->L, p);
- /* perms reftbl ... ludata */
-}
-
-static void unpersistnumber(UnpersistInfo *upi)
-{
- /* perms reftbl ... */
- lua_Number n;
- lua_checkstack(upi->L, 1);
- verify(LIF(Z,read)(&upi->zio, &n, sizeof(lua_Number)) == 0);
- lua_pushnumber(upi->L, n);
- /* perms reftbl ... num */
-}
-
-static void unpersiststring(UnpersistInfo *upi)
-{
- /* perms reftbl sptbl ref */
- /*int length;*/
- size_t length;
- char* string;
- lua_checkstack(upi->L, 1);
- /*verify(LIF(Z,read)(&upi->zio, &length, sizeof(int)) == 0);*/
- /*verify(LIF(Z,read)(&upi->zio, &length, sizeof(size_t)) == 0);*/
- read_size(&upi->zio, &length);
- string = pdep_newvector(upi->L, length, char);
- verify(LIF(Z,read)(&upi->zio, string, length) == 0);
- lua_pushlstring(upi->L, string, length);
- /* perms reftbl sptbl ref str */
- pdep_freearray(upi->L, string, length, char);
-}
-
-static void unpersistspecialtable(int ref, UnpersistInfo *upi)
-{
- /* perms reftbl ... */
- lua_checkstack(upi->L, 1);
- unpersist(upi);
- /* perms reftbl ... spfunc? */
- lua_assert(lua_isfunction(upi->L, -1));
- /* perms reftbl ... spfunc */
- lua_call(upi->L, 0, 1);
- /* perms reftbl ... tbl? */
- lua_assert(lua_istable(upi->L, -1));
- /* perms reftbl ... tbl */
-}
-
-static void unpersistliteraltable(int ref, UnpersistInfo *upi)
-{
- /* perms reftbl ... */
- lua_checkstack(upi->L, 3);
- /* Preregister table for handling of cycles */
- lua_newtable(upi->L);
- /* perms reftbl ... tbl */
- registerobject(ref, upi);
- /* perms reftbl ... tbl */
- /* Unpersist metatable */
- {
- unpersist(upi);
- /* perms reftbl ... tbl mt/nil? */
- if(lua_istable(upi->L, -1)) {
- /* perms reftbl ... tbl mt */
- lua_setmetatable(upi->L, -2);
- /* perms reftbl ... tbl */
- } else {
- /* perms reftbl ... tbl nil? */
- lua_assert(lua_isnil(upi->L, -1));
- /* perms reftbl ... tbl nil */
- lua_pop(upi->L, 1);
- /* perms reftbl ... tbl */
- }
- /* perms reftbl ... tbl */
- }
-
- while(1)
- {
- /* perms reftbl ... tbl */
- unpersist(upi);
- /* perms reftbl ... tbl key/nil */
- if(lua_isnil(upi->L, -1)) {
- /* perms reftbl ... tbl nil */
- lua_pop(upi->L, 1);
- /* perms reftbl ... tbl */
- break;
- }
- /* perms reftbl ... tbl key */
- unpersist(upi);
- /* perms reftbl ... tbl key value? */
- lua_assert(!lua_isnil(upi->L, -1));
- /* perms reftbl ... tbl key value */
- lua_rawset(upi->L, -3);
- /* perms reftbl ... tbl */
- }
-}
-
-static void unpersisttable(int ref, UnpersistInfo *upi)
-{
- /* perms reftbl ... */
- lua_checkstack(upi->L, 1);
- {
- int isspecial;
- verify(LIF(Z,read)(&upi->zio, &isspecial, sizeof(int)) == 0);
- if(isspecial) {
- unpersistspecialtable(ref, upi);
- /* perms reftbl ... tbl */
- } else {
- unpersistliteraltable(ref, upi);
- /* perms reftbl ... tbl */
- }
- /* perms reftbl ... tbl */
- }
-}
-
-static UpVal *makeupval(lua_State *L, int stackpos)
-{
- UpVal *uv = pdep_new(L, UpVal);
- pdep_link(L, (GCObject *)uv, LUA_TUPVAL);
- uv->tt = LUA_TUPVAL;
- uv->v = &uv->u.value;
- uv->u.l.prev = NULL;
- uv->u.l.next = NULL;
- setobj(L, uv->v, getobject(L, stackpos));
- return uv;
-}
-
-static Proto *makefakeproto(lua_State *L, lu_byte nups)
-{
- Proto *p = pdep_newproto(L);
- p->sizelineinfo = 1;
- p->lineinfo = pdep_newvector(L, 1, int);
- p->lineinfo[0] = 1;
- p->sizecode = 1;
- p->code = pdep_newvector(L, 1, Instruction);
- p->code[0] = CREATE_ABC(OP_RETURN, 0, 1, 0);
- p->source = pdep_newlstr(L, "", 0);
- p->maxstacksize = 2;
- p->nups = nups;
- p->sizek = 0;
- p->sizep = 0;
-
- return p;
-}
-
-/* The GC is not fond of finding upvalues in tables. We get around this
- * during persistence using a weakly keyed table, so that the GC doesn't
- * bother to mark them. This won't work in unpersisting, however, since
- * if we make the values weak they'll be collected (since nothing else
- * references them). Our solution, during unpersisting, is to represent
- * upvalues as dummy functions, each with one upvalue. */
-static void boxupval_start(lua_State *L)
-{
- LClosure *lcl;
- lcl = (LClosure *)pdep_newLclosure(L, 1, hvalue(&L->l_gt));
- pushclosure(L, (Closure *)lcl);
- /* ... func */
- lcl->p = makefakeproto(L, 1);
-
- /* Temporarily initialize the upvalue to nil */
-
- lua_pushnil(L);
- lcl->upvals[0] = makeupval(L, -1);
- lua_pop(L, 1);
-}
-
-static void boxupval_finish(lua_State *L)
-{
- /* ... func obj */
- LClosure *lcl = (LClosure *) clvalue(getobject(L, -2));
-
- lcl->upvals[0]->u.value = *getobject(L, -1);
- lua_pop(L, 1);
-}
-
-
-static void unboxupval(lua_State *L)
-{
- /* ... func */
- LClosure *lcl;
- UpVal *uv;
-
- lcl = (LClosure *)clvalue(getobject(L, -1));
- uv = lcl->upvals[0];
- lua_pop(L, 1);
- /* ... */
- pushupval(L, uv);
- /* ... upval */
-}
-
-static void unpersistfunction(int ref, UnpersistInfo *upi)
-{
- /* perms reftbl ... */
- LClosure *lcl;
- int i;
- lu_byte nupvalues;
- lua_checkstack(upi->L, 2);
-
- verify(LIF(Z,read)(&upi->zio, &nupvalues, sizeof(lu_byte)) == 0);
-
- lcl = (LClosure *)pdep_newLclosure(upi->L, nupvalues, hvalue(&upi->L->l_gt));
- pushclosure(upi->L, (Closure *)lcl);
-
- /* perms reftbl ... func */
- /* Put *some* proto in the closure, before the GC can find it */
- lcl->p = makefakeproto(upi->L, nupvalues);
-
- /* Also, we need to temporarily fill the upvalues */
- lua_pushnil(upi->L);
- /* perms reftbl ... func nil */
- for(i=0; i<nupvalues; i++) {
- lcl->upvals[i] = makeupval(upi->L, -1);
- }
- lua_pop(upi->L, 1);
- /* perms reftbl ... func */
-
- /* I can't see offhand how a function would ever get to be self-
- * referential, but just in case let's register it early */
- registerobject(ref, upi);
-
- /* Now that it's safe, we can get the real proto */
- unpersist(upi);
- /* perms reftbl ... func proto? */
- lua_assert(lua_type(upi->L, -1) == LUA_TPROTO);
- /* perms reftbl ... func proto */
- lcl->p = toproto(upi->L, -1);
- lua_pop(upi->L, 1);
- /* perms reftbl ... func */
-
- for(i=0; i<nupvalues; i++) {
- /* perms reftbl ... func */
- unpersist(upi);
- /* perms reftbl ... func func2 */
- unboxupval(upi->L);
- /* perms reftbl ... func upval */
- lcl->upvals[i] = toupval(upi->L, -1);
- lua_pop(upi->L, 1);
- /* perms reftbl ... func */
- }
- /* perms reftbl ... func */
-
- /* Finally, the fenv */
- unpersist(upi);
- /* perms reftbl ... func fenv/nil? */
- lua_assert(lua_type(upi->L, -1) == LUA_TNIL ||
- lua_type(upi->L, -1) == LUA_TTABLE);
- /* perms reftbl ... func fenv/nil */
- if(!lua_isnil(upi->L, -1)) {
- /* perms reftbl ... func fenv */
- lua_setfenv(upi->L, -2);
- /* perms reftbl ... func */
- } else {
- /* perms reftbl ... func nil */
- lua_pop(upi->L, 1);
- /* perms reftbl ... func */
- }
- /* perms reftbl ... func */
-}
-
-static void unpersistupval(int ref, UnpersistInfo *upi)
-{
- /* perms reftbl ... */
- lua_checkstack(upi->L, 2);
-
- boxupval_start(upi->L);
- /* perms reftbl ... func */
- registerobject(ref, upi);
-
- unpersist(upi);
- /* perms reftbl ... func obj */
- boxupval_finish(upi->L);
- /* perms reftbl ... func */
-}
-
-static void unpersistproto(int ref, UnpersistInfo *upi)
-{
- /* perms reftbl ... */
- Proto *p;
- int i;
- int sizep, sizek;
-
- /* We have to be careful. The GC expects a lot out of protos. In
- * particular, we need to give the function a valid string for its
- * source, and valid code, even before we actually read in the real
- * code. */
- TString *source = pdep_newlstr(upi->L, "", 0);
- p = pdep_newproto(upi->L);
- p->source = source;
- p->sizecode=1;
- p->code = pdep_newvector(upi->L, 1, Instruction);
- p->code[0] = CREATE_ABC(OP_RETURN, 0, 1, 0);
- p->maxstacksize = 2;
- p->sizek = 0;
- p->sizep = 0;
-
- lua_checkstack(upi->L, 2);
-
- pushproto(upi->L, p);
- /* perms reftbl ... proto */
- /* We don't need to register early, since protos can never ever be
- * involved in cyclic references */
-
- /* Read in constant references */
- {
- verify(LIF(Z,read)(&upi->zio, &sizek, sizeof(int)) == 0);
- LIF(M,reallocvector)(upi->L, p->k, 0, sizek, TValue);
- for(i=0; i<sizek; i++) {
- /* perms reftbl ... proto */
- unpersist(upi);
- /* perms reftbl ... proto k */
- setobj2s(upi->L, &p->k[i], getobject(upi->L, -1));
- p->sizek++;
- lua_pop(upi->L, 1);
- /* perms reftbl ... proto */
- }
- /* perms reftbl ... proto */
- }
- /* Read in sub-proto references */
- {
- verify(LIF(Z,read)(&upi->zio, &sizep, sizeof(int)) == 0);
- LIF(M,reallocvector)(upi->L, p->p, 0, sizep, Proto*);
- for(i=0; i<sizep; i++) {
- /* perms reftbl ... proto */
- unpersist(upi);
- /* perms reftbl ... proto subproto */
- p->p[i] = toproto(upi->L, -1);
- p->sizep++;
- lua_pop(upi->L, 1);
- /* perms reftbl ... proto */
- }
- /* perms reftbl ... proto */
- }
-
- /* Read in code */
- {
- verify(LIF(Z,read)(&upi->zio, &p->sizecode, sizeof(int)) == 0);
- LIF(M,reallocvector)(upi->L, p->code, 1, p->sizecode, Instruction);
- verify(LIF(Z,read)(&upi->zio, p->code,
- sizeof(Instruction) * p->sizecode) == 0);
- }
-
- /* Read in upvalue names */
- {
- verify(LIF(Z,read)(&upi->zio, &p->sizeupvalues, sizeof(int)) == 0);
- if (p->sizeupvalues)
- {
- LIF(M,reallocvector)(upi->L, p->upvalues, 0, p->sizeupvalues, TString *);
- for(i=0; i<p->sizeupvalues; i++)
- {
- unpersist(upi);
- p->upvalues[i] = pdep_newlstr(upi->L, lua_tostring(upi->L, -1), strlen(lua_tostring(upi->L, -1)));
- lua_pop(upi->L, 1);
- }
- }
- }
-
- /* Read in local variable infos */
- {
- verify(LIF(Z,read)(&upi->zio, &p->sizelocvars, sizeof(int)) == 0);
- if (p->sizelocvars)
- {
- LIF(M,reallocvector)(upi->L, p->locvars, 0, p->sizelocvars, LocVar);
- for(i=0; i<p->sizelocvars; i++)
- {
- unpersist(upi);
- p->locvars[i].varname = pdep_newlstr(upi->L, lua_tostring(upi->L, -1), strlen(lua_tostring(upi->L, -1)));
- lua_pop(upi->L, 1);
-
- verify(LIF(Z,read)(&upi->zio, &p->locvars[i].startpc, sizeof(int)) == 0);
- verify(LIF(Z,read)(&upi->zio, &p->locvars[i].endpc, sizeof(int)) == 0);
- }
- }
- }
-
- /* Read in source string*/
- unpersist(upi);
- p->source = pdep_newlstr(upi->L, lua_tostring(upi->L, -1), strlen(lua_tostring(upi->L, -1)));
- lua_pop(upi->L, 1);
-
- /* Read in line numbers */
- {
- verify(LIF(Z,read)(&upi->zio, &p->sizelineinfo, sizeof(int)) == 0);
- if (p->sizelineinfo)
- {
- LIF(M,reallocvector)(upi->L, p->lineinfo, 0, p->sizelineinfo, int);
- verify(LIF(Z,read)(&upi->zio, p->lineinfo,
- sizeof(int) * p->sizelineinfo) == 0);
- }
- }
-
- /* Read in linedefined and lastlinedefined */
- verify(LIF(Z,read)(&upi->zio, &p->linedefined, sizeof(int)) == 0);
- verify(LIF(Z,read)(&upi->zio, &p->lastlinedefined, sizeof(int)) == 0);
-
- /* Read in misc values */
- {
- verify(LIF(Z,read)(&upi->zio, &p->nups, sizeof(lu_byte)) == 0);
- verify(LIF(Z,read)(&upi->zio, &p->numparams, sizeof(lu_byte)) == 0);
- verify(LIF(Z,read)(&upi->zio, &p->is_vararg, sizeof(lu_byte)) == 0);
- verify(LIF(Z,read)(&upi->zio, &p->maxstacksize, sizeof(lu_byte)) == 0);
- }
-}
-
-
-/* Does basically the opposite of luaC_link().
- * Right now this function is rather inefficient; it requires traversing the
- * entire root GC set in order to find one object. If the GC list were doubly
- * linked this would be much easier, but there's no reason for Lua to have
- * that. */
-static void gcunlink(lua_State *L, GCObject *gco)
-{
- GCObject *prevslot;
- if(G(L)->rootgc == gco) {
- G(L)->rootgc = G(L)->rootgc->gch.next;
- return;
- }
-
- prevslot = G(L)->rootgc;
- while(prevslot->gch.next != gco) {
- lua_assert(prevslot->gch.next != NULL);
- prevslot = prevslot->gch.next;
- }
-
- prevslot->gch.next = prevslot->gch.next->gch.next;
-}
-
-/* FIXME __ALL__ field ordering */
-static void unpersistthread(int ref, UnpersistInfo *upi)
-{
- /* perms reftbl ... */
- lua_State *L2;
- size_t stacklimit = 0;
- L2 = lua_newthread(upi->L);
- lua_checkstack(upi->L, 3);
- /* L1: perms reftbl ... thr */
- /* L2: (empty) */
- registerobject(ref, upi);
-
- /* First, deserialize the object stack. */
- {
- size_t i, stacksize;
- read_size(&upi->zio, &stacksize);
- LIF(D,growstack)(L2, (int)stacksize);
- /* Make sure that the first stack element (a nil, representing
- * the imaginary top-level C function) is written to the very,
- * very bottom of the stack */
- L2->top--;
- for(i=0; i<stacksize; i++) {
- unpersist(upi);
- /* L1: perms reftbl ... thr obj* */
- }
- lua_xmove(upi->L, L2, stacksize);
- /* L1: perms reftbl ... thr */
- /* L2: obj* */
- }
- /* (hereafter, stacks refer to L1) */
-
- /* Now, deserialize the CallInfo stack. */
- {
- size_t i, numframes;
- read_size(&upi->zio, &numframes);
- LIF(D,reallocCI)(L2,numframes*2);
- for(i=0; i<numframes; i++) {
- CallInfo *ci = L2->base_ci + i;
- size_t stackbase, stackfunc, stacktop, savedpc;
- read_size(&upi->zio, &stackbase);
- read_size(&upi->zio, &stackfunc);
- read_size(&upi->zio, &stacktop);
- verify(LIF(Z,read)(&upi->zio, &ci->nresults, sizeof(int)) == 0);
- read_size(&upi->zio, &savedpc);
-
- if(stacklimit < stacktop)
- stacklimit = stacktop;
-
- ci->base = L2->stack+stackbase;
- ci->func = L2->stack+stackfunc;
- ci->top = L2->stack+stacktop;
- ci->savedpc = (ci != L2->base_ci) ?
- ci_func(ci)->l.p->code+savedpc :
- 0;
- ci->tailcalls = 0;
- /* Update the pointer each time, to keep the GC
- * happy*/
- L2->ci = ci;
- }
- }
- /* perms reftbl ... thr */
- /* Deserialize the state's other parameters, with the exception of upval stuff */
- {
- size_t stackbase, stacktop;
- L2->savedpc = L2->ci->savedpc;
- verify(LIF(Z,read)(&upi->zio, &L2->status, sizeof(lu_byte)) == 0);
- read_size(&upi->zio, &stackbase);
- read_size(&upi->zio, &stacktop);
-
-#ifdef SIZES64
- uint64 value;
- verify(LIF(Z,read)(&upi->zio, &value, sizeof(uint64)) == 0);
-
- L2->errfunc = static_cast<ptrdiff_t>(value);
-#else
- verify(LIF(Z,read)(&upi->zio, &L2->errfunc, sizeof(ptrdiff_t)) == 0);
-#endif
-
- //read_size(&upi->zio, (size_t *)&L2->errfunc);
- L2->base = L2->stack + stackbase;
- L2->top = L2->stack + stacktop;
- }
- /* Finally, "reopen" upvalues (see persistupval() for why) */
- {
- UpVal* uv;
- GCObject **nextslot = &L2->openupval;
- global_State *g = G(L2);
- while(1) {
- size_t stackpos;
- unpersist(upi);
- /* perms reftbl ... thr uv/nil */
- if(lua_isnil(upi->L, -1)) {
- /* perms reftbl ... thr nil */
- lua_pop(upi->L, 1);
- /* perms reftbl ... thr */
- break;
- }
- /* perms reftbl ... thr boxeduv */
- unboxupval(upi->L);
- /* perms reftbl ... thr uv */
- uv = toupval(upi->L, -1);
- lua_pop(upi->L, 1);
- /* perms reftbl ... thr */
-
- read_size(&upi->zio, &stackpos);
- uv->v = L2->stack + stackpos;
- gcunlink(upi->L, (GCObject *)uv);
- uv->marked = luaC_white(g);
- *nextslot = (GCObject *)uv;
- nextslot = &uv->next;
- uv->u.l.prev = &G(L2)->uvhead;
- uv->u.l.next = G(L2)->uvhead.u.l.next;
- uv->u.l.next->u.l.prev = uv;
- G(L2)->uvhead.u.l.next = uv;
- lua_assert(uv->u.l.next->u.l.prev == uv && uv->u.l.prev->u.l.next == uv);
- }
- *nextslot = NULL;
- }
-
- /* The stack must be valid at least to the highest value among the CallInfos */
- /* 'top' and the values up to there must be filled with 'nil' */
- {
- StkId o;
- LIF(D,checkstack)(L2, (int)stacklimit);
- for (o = L2->top; o <= L2->top + stacklimit; o++)
- setnilvalue(o);
- }
-}
-
-static void unpersistuserdata(int ref, UnpersistInfo *upi)
-{
- /* perms reftbl ... */
- int isspecial;
- lua_checkstack(upi->L, 2);
- verify(LIF(Z,read)(&upi->zio, &isspecial, sizeof(int)) == 0);
- if(isspecial) {
- unpersist(upi);
- /* perms reftbl ... spfunc? */
- lua_assert(lua_isfunction(upi->L, -1));
- /* perms reftbl ... spfunc */
-#ifdef PLUTO_PASS_USERDATA_TO_PERSIST
- lua_pushlightuserdata(upi->L, &upi->zio);
- lua_call(upi->L, 1, 1);
-#else
- lua_call(upi->L, 0, 1);
-#endif
- /* perms reftbl ... udata? */
-/* This assertion might not be necessary; it's conceivable, for
- * example, that the SP function might decide to return a table
- * with equivalent functionality. For the time being, we'll
- * ignore this possibility in favor of stricter and more testable
- * requirements. */
- lua_assert(lua_isuserdata(upi->L, -1));
- /* perms reftbl ... udata */
- } else {
- size_t length;
- read_size(&upi->zio, &length);
-
- lua_newuserdata(upi->L, length);
- /* perms reftbl ... udata */
- registerobject(ref, upi);
- verify(LIF(Z,read)(&upi->zio, lua_touserdata(upi->L, -1), length) == 0);
-
- unpersist(upi);
- /* perms reftbl ... udata mt/nil? */
- lua_assert(lua_istable(upi->L, -1) || lua_isnil(upi->L, -1));
- /* perms reftbl ... udata mt/nil */
- lua_setmetatable(upi->L, -2);
- /* perms reftbl ... udata */
- }
- /* perms reftbl ... udata */
-}
-
-static void unpersistpermanent(int ref, UnpersistInfo *upi)
-{
- /* perms reftbl ... */
- lua_checkstack(upi->L, 2);
- unpersist(upi);
- /* perms reftbl permkey */
- lua_gettable(upi->L, 1);
- /* perms reftbl perm? */
- /* We assume currently that the substituted permanent value
- * shouldn't be nil. This may be a bad assumption. Real-life
- * experience is needed to evaluate this. */
- lua_assert(!lua_isnil(upi->L, -1));
- /* perms reftbl perm */
-}
-
-#if 0
-/* For debugging only; not called when lua_assert is empty */
-static int inreftable(lua_State *L, int ref)
-{
- int res;
- lua_checkstack(L, 1);
- /* perms reftbl ... */
- lua_pushlightuserdata(L, (void *)ref);
- /* perms reftbl ... ref */
- lua_gettable(L, 2);
- /* perms reftbl ... obj? */
- res = !lua_isnil(L, -1);
- lua_pop(L, 1);
- /* perms reftbl ... */
- return res;
-}
-#endif
-
-static void unpersist(UnpersistInfo *upi)
-{
- /* perms reftbl ... */
- int firstTime;
- int stacksize = lua_gettop(upi->L); stacksize = stacksize; /* DEBUG */
- lua_checkstack(upi->L, 2);
- LIF(Z,read)(&upi->zio, &firstTime, sizeof(int));
- if(firstTime) {
- int ref;
- int type;
- LIF(Z,read)(&upi->zio, &ref, sizeof(int));
- lua_assert(!inreftable(upi->L, ref));
- LIF(Z,read)(&upi->zio, &type, sizeof(int));
-#ifdef PLUTO_DEBUG
- printindent(upi->level);
- printf("1 %d %d\n", ref, type);
- upi->level++;
-#endif
- switch(type) {
- case LUA_TBOOLEAN:
- unpersistboolean(upi);
- break;
- case LUA_TLIGHTUSERDATA:
- unpersistlightuserdata(upi);
- break;
- case LUA_TNUMBER:
- unpersistnumber(upi);
- break;
- case LUA_TSTRING:
- unpersiststring(upi);
- break;
- case LUA_TTABLE:
- unpersisttable(ref, upi);
- break;
- case LUA_TFUNCTION:
- unpersistfunction(ref, upi);
- break;
- case LUA_TTHREAD:
- unpersistthread(ref, upi);
- break;
- case LUA_TPROTO:
- unpersistproto(ref, upi);
- break;
- case LUA_TUPVAL:
- unpersistupval(ref, upi);
- break;
- case LUA_TUSERDATA:
- unpersistuserdata(ref, upi);
- break;
- case PLUTO_TPERMANENT:
- unpersistpermanent(ref, upi);
- break;
- default:
- lua_assert(0);
- }
- /* perms reftbl ... obj */
- lua_assert(lua_type(upi->L, -1) == type ||
- type == PLUTO_TPERMANENT ||
- /* Remember, upvalues get a special dispensation, as
- * described in boxupval */
- (lua_type(upi->L, -1) == LUA_TFUNCTION &&
- type == LUA_TUPVAL));
- registerobject(ref, upi);
- /* perms reftbl ... obj */
-#ifdef PLUTO_DEBUG
- upi->level--;
-#endif
- } else {
- int ref;
- LIF(Z,read)(&upi->zio, &ref, sizeof(int));
-#ifdef PLUTO_DEBUG
- printindent(upi->level);
- printf("0 %d\n", ref);
-#endif
- if(ref == 0) {
- lua_pushnil(upi->L);
- /* perms reftbl ... nil */
- } else {
- lua_pushlightuserdata(upi->L, (void *)ref);
- /* perms reftbl ... ref */
- lua_gettable(upi->L, 2);
- /* perms reftbl ... obj? */
- lua_assert(!lua_isnil(upi->L, -1));
- }
- /* perms reftbl ... obj/nil */
- }
- /* perms reftbl ... obj/nil */
- lua_assert(lua_gettop(upi->L) == stacksize + 1);
-}
-
-void pluto_unpersist(lua_State *L, lua_Chunkreader reader, void *ud)
-{
- /* We use the graciously provided ZIO (what the heck does the Z stand
- * for?) library so that we don't have to deal with the reader directly.
- * Letting the reader function decide how much data to return can be
- * very unpleasant.
- */
- UnpersistInfo upi;
- upi.L = L;
-#ifdef PLUTO_DEBUG
- upi.level = 0;
-#endif
-
- lua_checkstack(L, 3);
- LIF(Z,init)(L, &upi.zio, reader, ud);
-
- /* perms */
- lua_newtable(L);
- /* perms reftbl */
- lua_gc(L, LUA_GCSTOP, 0);
- unpersist(&upi);
- lua_gc(L, LUA_GCRESTART, 0);
- /* perms reftbl rootobj */
- lua_replace(L, 2);
- /* perms rootobj */
-}
-
-typedef struct LoadInfo_t {
- char *buf;
- size_t size;
-} LoadInfo;
-
-
-static const char *bufreader(lua_State *L, void *ud, size_t *sz) {
- LoadInfo *li = (LoadInfo *)ud;
- if(li->size == 0) {
- return NULL;
- }
- *sz = li->size;
- li->size = 0;
- return li->buf;
-}
-
-int unpersist_l(lua_State *L)
-{
- LoadInfo li;
- char const *origbuf;
- char *tempbuf;
- size_t bufsize;
- /* perms? str? ...? */
- lua_settop(L, 2);
- /* perms? str? */
- origbuf = luaL_checklstring(L, 2, &bufsize);
- tempbuf = LIF(M,newvector)(L, bufsize, char);
- memcpy(tempbuf, origbuf, bufsize);
-
- li.buf = tempbuf;
- li.size = bufsize;
-
- /* perms? str */
- lua_pop(L, 1);
- /* perms? */
- luaL_checktype(L, 1, LUA_TTABLE);
- /* perms */
- pluto_unpersist(L, bufreader, &li);
- /* perms rootobj */
- LIF(M,freearray)(L, tempbuf, bufsize, char);
- return 1;
-}
-
-/* Stefan's first C function for Lua! :)
- Returns a string describing the Pluto version you're using. */
-
-int version_l(lua_State *L)
-{
- const char *version = VERSION;
-
- lua_settop(L, 0);
- /* (empty) */
- lua_pushlstring(L, version, strlen(version));
- /* str */
- return 1;
-}
-
-/* Set human-readable output on or off. */
-int human_l(lua_State *L)
-{
- /* flag? ...? */
- lua_settop(L, 1);
- /* flag? */
- /*luaL_checktype(L, 1, LUA_TBOOLEAN);*/
- /* flag */
-
- humanReadable = lua_toboolean(L, 1);
-
- lua_settop(L, 0);
- /* (empty) */
- return 0;
-}
-
-static luaL_reg pluto_reg[] = {
- { "persist", persist_l },
- { "unpersist", unpersist_l },
- { "version", version_l },
- { "human", human_l },
- { NULL, NULL }
-};
-
-LUALIB_API int luaopen_pluto(lua_State *L) {
- luaL_openlib(L, "pluto", pluto_reg, 0);
- return 1;
-}
diff --git a/engines/sword25/util/pluto/pluto.h b/engines/sword25/util/pluto/pluto.h
deleted file mode 100644
index 3674842d44..0000000000
--- a/engines/sword25/util/pluto/pluto.h
+++ /dev/null
@@ -1,25 +0,0 @@
-/* $Id$ */
-
-/* Pluto - Heavy-duty persistence for Lua
- * Copyright (C) 2004 by Ben Sunshine-Hill, and released into the public
- * domain. People making use of this software as part of an application
- * are politely requested to email the author at sneftel@gmail.com
- * with a brief description of the application, primarily to satisfy his
- * curiosity.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
- * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
-/* lua.h must be included before this file */
-
-void pluto_persist(lua_State *L, lua_Chunkwriter writer, void *ud);
-
-void pluto_unpersist(lua_State *L, lua_Chunkreader reader, void *ud);
-
-LUALIB_API int luaopen_pluto(lua_State *L);
diff --git a/engines/sword25/util/pluto/plzio.cpp b/engines/sword25/util/pluto/plzio.cpp
deleted file mode 100644
index 21f69a9e8d..0000000000
--- a/engines/sword25/util/pluto/plzio.cpp
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
-** $Id$
-** a generic input stream interface
-** See Copyright Notice in lua.h
-*/
-
-
-#include <string.h>
-
-#define lzio_c
-#define LUA_CORE
-
-#include "pdep/pdep.h"
-
-int pdep_fill (ZIO *z) {
- size_t size;
- lua_State *L = z->L;
- const char *buff;
- lua_unlock(L);
- buff = z->reader(L, z->data, &size);
- lua_lock(L);
- if (buff == NULL || size == 0) return EOZ;
- z->n = size - 1;
- z->p = buff;
- return char2int(*(z->p++));
-}
-
-
-int pdep_lookahead (ZIO *z) {
- if (z->n == 0) {
- if (pdep_fill(z) == EOZ)
- return EOZ;
- else {
- z->n++; /* pdep_fill removed first byte; put back it */
- z->p--;
- }
- }
- return char2int(*z->p);
-}
-
-
-void pdep_init (lua_State *L, ZIO *z, lua_Reader reader, void *data) {
- z->L = L;
- z->reader = reader;
- z->data = data;
- z->n = 0;
- z->p = NULL;
-}
-
-
-/* --------------------------------------------------------------- read --- */
-size_t pdep_read (ZIO *z, void *b, size_t n) {
- while (n) {
- size_t m;
- if (pdep_lookahead(z) == EOZ)
- return n; /* return number of missing bytes */
- m = (n <= z->n) ? n : z->n; /* min. between n and z->n */
- memcpy(b, z->p, m);
- z->n -= m;
- z->p += m;
- b = (char *)b + m;
- n -= m;
- }
- return 0;
-}
-
-/* ------------------------------------------------------------------------ */
-char *pdep_openspace (lua_State *L, Mbuffer *buff, size_t n) {
- if (n > buff->buffsize) {
- if (n < LUA_MINBUFFER) n = LUA_MINBUFFER;
- pdep_resizebuffer(L, buff, n);
- }
- return buff->buffer;
-}
diff --git a/engines/tinsel/tinsel.cpp b/engines/tinsel/tinsel.cpp
index 31610a8467..57d8432f0e 100644
--- a/engines/tinsel/tinsel.cpp
+++ b/engines/tinsel/tinsel.cpp
@@ -821,7 +821,8 @@ const char *const TinselEngine::_textFiles[][3] = {
TinselEngine::TinselEngine(OSystem *syst, const TinselGameDescription *gameDesc) :
- Engine(syst), _gameDescription(gameDesc), _random("tinsel") {
+ Engine(syst), _gameDescription(gameDesc), _random("tinsel"),
+ _sound(0), _midiMusic(0), _pcmMusic(0), _bmv(0) {
_vm = this;
_config = new Config(this);
@@ -846,13 +847,6 @@ TinselEngine::TinselEngine(OSystem *syst, const TinselGameDescription *gameDesc)
if (cd_num >= 0)
_system->getAudioCDManager()->openCD(cd_num);
- _midiMusic = new MidiMusicPlayer();
- _pcmMusic = new PCMMusicPlayer();
-
- _sound = new SoundManager(this);
-
- _bmv = new BMVPlayer();
-
_mousePos.x = 0;
_mousePos.y = 0;
_keyHandler = NULL;
@@ -896,6 +890,11 @@ void TinselEngine::initializePath(const Common::FSNode &gamePath) {
}
Common::Error TinselEngine::run() {
+ _midiMusic = new MidiMusicPlayer();
+ _pcmMusic = new PCMMusicPlayer();
+ _sound = new SoundManager(this);
+ _bmv = new BMVPlayer();
+
// Initialize backend
if (getGameID() == GID_DW2) {
#ifndef DW2_EXACT_SIZE
diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp
index c102242dfd..0a2c62330b 100644
--- a/engines/tony/game.cpp
+++ b/engines/tony/game.cpp
@@ -1557,14 +1557,14 @@ void RMPointer::updateCursor() {
for (int i = 0; i < 64; i++) {
uint16 *lineP = src;
for (int j = 0; j < 64; j++) {
- lineP[j] = RMGfxTargetBuffer::_precalcTable[lineP[j] & 0x7FFF];
+ lineP[j] = RMGfxTargetBuffer::_precalcTable[lineP[j]];
}
src += 64;
}
}
// Get the raw pixel data and set the cursor to it
- Graphics::PixelFormat pixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0);
+ Graphics::PixelFormat pixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0);
CursorMan.replaceCursor(cursorData, 64, 64, _cursorHotspot._x, _cursorHotspot._y, 0, 1, &pixelFormat);
}
diff --git a/engines/tony/gfxcore.cpp b/engines/tony/gfxcore.cpp
index 9254d59df6..2a32926c53 100644
--- a/engines/tony/gfxcore.cpp
+++ b/engines/tony/gfxcore.cpp
@@ -422,11 +422,11 @@ uint16 *RMGfxTargetBuffer::_precalcTable = NULL;
* called if the user selects the black & white option.
*/
void RMGfxTargetBuffer::createBWPrecalcTable() {
- _precalcTable = new uint16[0x8000];
+ _precalcTable = new uint16[0x10000];
- for (int i = 0; i < 0x8000; i++) {
- int r = (i >> 10) & 0x1F;
- int g = (i >> 5) & 0x1F;
+ for (int i = 0; i < 0x10000; i++) {
+ int r = (i >> 11) & 0x1F;
+ int g = (i >> 6) & 0x1F;
int b = i & 0x1F;
int min = MIN(r, MIN(g, b));
@@ -434,11 +434,11 @@ void RMGfxTargetBuffer::createBWPrecalcTable() {
min = (min + max) / 2;
- r = CLIP(min + 8 - 8, 0, 31);
- g = CLIP(min + 5 - 8, 0, 31);
- b = CLIP(min + 0 - 8, 0, 31);
+ r = CLIP(min + 8 - 8, 0, 0x1f);
+ g = CLIP(min + 5 - 8, 0, 0x1f);
+ b = CLIP(min + 0 - 8, 0, 0x1f);
- _precalcTable[i] = (r << 10) | (g << 5) | b;
+ _precalcTable[i] = (r << 11) | (g << 6) | b;
}
}
@@ -512,8 +512,9 @@ int RMGfxSourceBufferPal::loadPalette(const byte *buf) {
void RMGfxSourceBufferPal::preparePalette() {
for (int i = 0; i < 256; i++) {
- _palFinal[i] = (((int)_pal[i * 3 + 0] >> 3) << 10) |
- (((int)_pal[i * 3 + 1] >> 3) << 5) |
+ // we convert 555 to 565 here.
+ _palFinal[i] = (((int)_pal[i * 3 + 0] >> 3) << 11) |
+ (((int)_pal[i * 3 + 1] >> 3) << 6) |
(((int)_pal[i * 3 + 2] >> 3) << 0);
}
}
@@ -665,8 +666,8 @@ void RMGfxSourceBuffer8::create(int dimx, int dimy) {
RMGfxBuffer::create(dimx, dimy, 8);
}
-#define GETRED(x) (((x) >> 10) & 0x1F)
-#define GETGREEN(x) (((x) >> 5) & 0x1F)
+#define GETRED(x) (((x) >> 11) & 0x1F)
+#define GETGREEN(x) (((x) >> 5) & 0x3F)
#define GETBLUE(x) ((x) & 0x1F)
/****************************************************************************\
@@ -684,13 +685,13 @@ int RMGfxSourceBuffer8AB::calcTrasp(int fore, int back) {
if (r > 0x1F)
r = 0x1F;
- if (g > 0x1F)
- g = 0x1F;
+ if (g > 0x3F)
+ g = 0x3F;
if (b > 0x1F)
b = 0x1F;
- return (r << 10) | (g << 5) | b;
+ return (r << 11) | (g << 5) | b;
}
void RMGfxSourceBuffer8AB::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) {
@@ -802,8 +803,8 @@ void RMGfxSourceBuffer8RLE::preparePalette() {
// Handle RGB alpha blending
if (_alphaBlendColor != -1) {
- _alphaR = (_palFinal[_alphaBlendColor] >> 10) & 0x1F;
- _alphaG = (_palFinal[_alphaBlendColor] >> 5) & 0x1F;
+ _alphaR = (_palFinal[_alphaBlendColor] >> 11) & 0x1F;
+ _alphaG = (_palFinal[_alphaBlendColor] >> 5) & 0x3F;
_alphaB = (_palFinal[_alphaBlendColor]) & 0x1F;
}
}
@@ -1054,15 +1055,15 @@ RLEByteDoAlpha2:
if (n > nLength)
n = nLength;
for (int i = 0; i < n; i++) {
- int r = (*dst >> 10) & 0x1F;
- int g = (*dst >> 5) & 0x1F;
+ int r = (*dst >> 11) & 0x1F;
+ int g = (*dst >> 5) & 0x3F;
int b = *dst & 0x1F;
r = (r >> 2) + (_alphaR >> 1);
g = (g >> 2) + (_alphaG >> 1);
b = (b >> 2) + (_alphaB >> 1);
- *dst ++ = (r << 10) | (g << 5) | b;
+ *dst ++ = (r << 11) | (g << 5) | b;
}
nLength -= n;
@@ -1158,15 +1159,15 @@ RLEByteFlippedDoAlpha2:
if (n > nLength)
n = nLength;
for (int i = 0; i < n; i++) {
- int r = (*dst >> 10) & 0x1F;
- int g = (*dst >> 5) & 0x1F;
+ int r = (*dst >> 11) & 0x1F;
+ int g = (*dst >> 5) & 0x3F;
int b = *dst & 0x1F;
r = (r >> 2) + (_alphaR >> 1);
g = (g >> 2) + (_alphaG >> 1);
b = (b >> 2) + (_alphaB >> 1);
- *dst-- = (r << 10) | (g << 5) | b;
+ *dst-- = (r << 11) | (g << 5) | b;
}
nLength -= n;
@@ -1302,15 +1303,15 @@ RLEWordDoAlpha2:
n = nLength;
for (int i = 0; i < n; i++) {
- int r = (*dst >> 10) & 0x1F;
- int g = (*dst >> 5) & 0x1F;
+ int r = (*dst >> 11) & 0x1F;
+ int g = (*dst >> 5) & 0x3F;
int b = *dst & 0x1F;
r = (r >> 2) + (_alphaR >> 1);
g = (g >> 2) + (_alphaG >> 1);
b = (b >> 2) + (_alphaB >> 1);
- *dst++ = (r << 10) | (g << 5) | b;
+ *dst++ = (r << 11) | (g << 5) | b;
}
nLength -= n;
@@ -1416,15 +1417,15 @@ RLEWordFlippedDoAlpha2:
n = nLength;
for (int i = 0; i < n; i++) {
- int r = (*dst >> 10) & 0x1F;
- int g = (*dst >> 5) & 0x1F;
+ int r = (*dst >> 11) & 0x1F;
+ int g = (*dst >> 5) & 0x3F;
int b = *dst & 0x1F;
r = (r >> 2) + (_alphaR >> 1);
g = (g >> 2) + (_alphaG >> 1);
b = (b >> 2) + (_alphaB >> 1);
- *dst-- = (r << 10) | (g << 5) | b;
+ *dst-- = (r << 11) | (g << 5) | b;
}
nLength -= n;
@@ -1543,15 +1544,15 @@ RLEWordDoAlpha2:
// @@@ SHOULD NOT BE THERE !!!!!
for (int i = 0; i < n; i++) {
- int r = (*dst >> 10) & 0x1F;
- int g = (*dst >> 5) & 0x1F;
+ int r = (*dst >> 11) & 0x1F;
+ int g = (*dst >> 5) & 0x3F;
int b = *dst & 0x1F;
r = (r >> 2) + (_alphaR >> 1);
g = (g >> 2) + (_alphaG >> 1);
b = (b >> 2) + (_alphaB >> 1);
- *dst++ = (r << 10) | (g << 5) | b;
+ *dst++ = (r << 11) | (g << 5) | b;
}
nLength -= n;
@@ -1570,19 +1571,19 @@ RLEWordDoCopy2:
n = nLength;
for (int i = 0; i < n; i++) {
- int r = (*dst >> 10) & 0x1F;
- int g = (*dst >> 5) & 0x1F;
+ int r = (*dst >> 11) & 0x1F;
+ int g = (*dst >> 5) & 0x3F;
int b = *dst & 0x1F;
- int r2 = (_palFinal[*src] >> 10) & 0x1F;
- int g2 = (_palFinal[*src] >> 5) & 0x1F;
+ int r2 = (_palFinal[*src] >> 11) & 0x1F;
+ int g2 = (_palFinal[*src] >> 5) & 0x3F;
int b2 = _palFinal[*src] & 0x1F;
r = (r >> 1) + (r2 >> 1);
g = (g >> 1) + (g2 >> 1);
b = (b >> 1) + (b2 >> 1);
- *dst ++ = (r << 10) | (g << 5) | b;
+ *dst ++ = (r << 11) | (g << 5) | b;
src++;
}
@@ -1732,14 +1733,14 @@ void RMGfxSourceBuffer8AA::drawAA(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pri
g /= 5;
b /= 5;
- if (r > 31)
- r = 31;
- if (g > 31)
- g = 31;
- if (b > 31)
- b = 31;
+ if (r > 0x1f)
+ r = 0x1f;
+ if (g > 0x3f)
+ g = 0x3f;
+ if (b > 0x1f)
+ b = 0x1f;
- mybuf[0] = (r << 10) | (g << 5) | b;
+ mybuf[0] = (r << 11) | (g << 5) | b;
}
}
@@ -1773,14 +1774,14 @@ void RMGfxSourceBuffer8AA::drawAA(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pri
g /= 6;
b /= 6;
- if (r > 31)
- r = 31;
- if (g > 31)
- g = 31;
- if (b > 31)
- b = 31;
+ if (r > 0x1f)
+ r = 0x1f;
+ if (g > 0x3f)
+ g = 0x3f;
+ if (b > 0x1f)
+ b = 0x1f;
- mybuf[0] = (r << 10) | (g << 5) | b;
+ mybuf[0] = (r << 11) | (g << 5) | b;
}
}
@@ -1948,8 +1949,17 @@ void RMGfxSourceBuffer16::prepareImage() {
// Color space conversion if necessary!
uint16 *buf = (uint16 *)_buf;
- for (int i = 0; i < _dimx * _dimy; i++)
- buf[i] = FROM_LE_16(buf[i]) & 0x7FFF;
+ // convert 555 to 565
+ for (int i = 0; i < _dimx * _dimy; i++) {
+ uint16 pixel = FROM_LE_16(buf[i]);
+ int r = (pixel >> 10) & 0x1F;
+ int g = (pixel >> 5) & 0x1F;
+ int b = pixel & 0x1F;
+
+ pixel = (r << 11) | (g << 6) | b;
+
+ buf[i] = pixel;
+ }
}
RMGfxSourceBuffer16::RMGfxSourceBuffer16(int dimx, int dimy)
@@ -1983,7 +1993,8 @@ void RMGfxBox::setColor(byte r, byte g, byte b) {
r >>= 3;
g >>= 3;
b >>= 3;
- _wFillColor = (r << 10) | (g << 5) | b;
+ // These are hard-coded colors, so we convert 555 to 565.
+ _wFillColor = (r << 11) | (g << 6) | b;
}
void RMGfxBox::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) {
diff --git a/engines/tony/mpal/lzo.cpp b/engines/tony/mpal/lzo.cpp
index 314d6f3ed5..6cc2333315 100644
--- a/engines/tony/mpal/lzo.cpp
+++ b/engines/tony/mpal/lzo.cpp
@@ -116,7 +116,7 @@ int lzo1x_decompress(const byte *in, uint32 in_len, byte *out, uint32 *out_len)
*op++ = *ip++;
*op++ = *ip++;
*op++ = *ip++;
- do
+ do
*op++ = *ip++;
while (--t > 0);
diff --git a/engines/tony/window.cpp b/engines/tony/window.cpp
index 5c50a50a57..3b3687419b 100644
--- a/engines/tony/window.cpp
+++ b/engines/tony/window.cpp
@@ -53,9 +53,9 @@ RMWindow::~RMWindow() {
* Initializes the graphics window
*/
void RMWindow::init() {
- Graphics::PixelFormat pixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0);
+ Graphics::PixelFormat pixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0);
initGraphics(RM_SX, RM_SY, true, &pixelFormat);
-
+
reset();
}
@@ -83,7 +83,7 @@ void RMWindow::copyRectToScreen(const byte *buf, int pitch, int x, int y, int w,
for (int i = 0; i < h; i++) {
uint16 *dst = (uint16 *)screen->getBasePtr(x, y + i);
for (int j = 0; j < w; j++) {
- dst[j] = RMGfxTargetBuffer::_precalcTable[src[j] & 0x7FFF];
+ dst[j] = RMGfxTargetBuffer::_precalcTable[src[j]];
}
src += (pitch / 2);
}
@@ -291,8 +291,8 @@ void RMSnapshot::grabScreenshot(byte *lpBuf, int dezoom, uint16 *lpDestBuf) {
cursrc = &src[RM_SKIPX + x];
*curOut++ = ((*cursrc) & 0x1F) << 3;
- *curOut++ = (((*cursrc) >> 5) & 0x1F) << 3;
- *curOut++ = (((*cursrc) >> 10) & 0x1F) << 3;
+ *curOut++ = (((*cursrc) >> 5) & 0x3F) << 3;
+ *curOut++ = (((*cursrc) >> 11) & 0x1F) << 3;
if (lpDestBuf)
*lpDestBuf++ = *cursrc;
@@ -319,8 +319,8 @@ void RMSnapshot::grabScreenshot(byte *lpBuf, int dezoom, uint16 *lpDestBuf) {
curv = v;
sommab += cursrc[curv * RM_BBX + u] & 0x1F;
- sommag += (cursrc[curv * RM_BBX + u] >> 5) & 0x1F;
- sommar += (cursrc[curv * RM_BBX + u] >> 10) & 0x1F;
+ sommag += (cursrc[curv * RM_BBX + u] >> 6) & 0x1F;
+ sommar += (cursrc[curv * RM_BBX + u] >> 11) & 0x1F;
}
}
_rgb[k + 0] = (byte)(sommab * 8 / (dezoom * dezoom));
diff --git a/engines/toon/character.cpp b/engines/toon/character.cpp
index 51e8dee19f..686fe99beb 100644
--- a/engines/toon/character.cpp
+++ b/engines/toon/character.cpp
@@ -1059,7 +1059,7 @@ void Character::playAnim(int32 animId, int32 unused, int32 flags) {
_specialAnim->loadAnimation(animName);
_animSpecialId = animId;
-
+
if (_animationInstance) {
_animationInstance->setAnimation(_specialAnim);
_animationInstance->setAnimationRange(0, _specialAnim->_numFrames - 1);
diff --git a/engines/toon/state.cpp b/engines/toon/state.cpp
index 6ac5808219..000f94d659 100644
--- a/engines/toon/state.cpp
+++ b/engines/toon/state.cpp
@@ -115,7 +115,7 @@ State::State(void) {
#endif
memset(_conversationState, 0, sizeof(Conversation) * 60);
-
+
_conversationData = nullptr;
_currentConversationId = -1;
_exitConversation = true;
diff --git a/engines/touche/detection.cpp b/engines/touche/detection.cpp
index 97a14e5bc1..1d0e136d69 100644
--- a/engines/touche/detection.cpp
+++ b/engines/touche/detection.cpp
@@ -24,7 +24,6 @@
#include "engines/advancedDetector.h"
#include "common/savefile.h"
#include "common/system.h"
-#include "common/translation.h"
#include "base/plugins.h"
diff --git a/engines/tsage/POTFILES b/engines/tsage/POTFILES
new file mode 100644
index 0000000000..de18cbd072
--- /dev/null
+++ b/engines/tsage/POTFILES
@@ -0,0 +1,3 @@
+engines/tsage/dialogs.cpp
+engines/tsage/scenes.cpp
+
diff --git a/engines/tsage/blue_force/blueforce_dialogs.cpp b/engines/tsage/blue_force/blueforce_dialogs.cpp
index 2f337ac549..5be27c9ae7 100644
--- a/engines/tsage/blue_force/blueforce_dialogs.cpp
+++ b/engines/tsage/blue_force/blueforce_dialogs.cpp
@@ -20,8 +20,6 @@
*
*/
-#include "common/translation.h"
-
#include "gui/dialog.h"
#include "gui/widget.h"
diff --git a/engines/tsage/debugger.cpp b/engines/tsage/debugger.cpp
index b647807f8a..a38796717a 100644
--- a/engines/tsage/debugger.cpp
+++ b/engines/tsage/debugger.cpp
@@ -42,7 +42,7 @@ Debugger::Debugger() : GUI::Debugger() {
registerCmd("moveobject", WRAP_METHOD(Debugger, Cmd_MoveObject));
registerCmd("hotspots", WRAP_METHOD(Debugger, Cmd_Hotspots));
registerCmd("sound", WRAP_METHOD(Debugger, Cmd_Sound));
- registerCmd("setdebug", WRAP_METHOD(Debugger, Cmd_SetDebug));
+ registerCmd("setdebug", WRAP_METHOD(Debugger, Cmd_SetOutpostAlphaDebug));
}
static int strToInt(const char *s) {
@@ -344,7 +344,7 @@ bool Debugger::Cmd_Sound(int argc, const char **argv) {
/**
* Activate internal debugger, when available
*/
-bool Debugger::Cmd_SetDebug(int argc, const char **argv) {
+bool Debugger::Cmd_SetOutpostAlphaDebug(int argc, const char **argv) {
debugPrintf("Not available in this game\n");
return true;
}
@@ -720,7 +720,7 @@ bool Ringworld2Debugger::Cmd_MoveObject(int argc, const char **argv) {
/**
* Activate internal debugger, when available
*/
-bool Ringworld2Debugger::Cmd_SetDebug(int argc, const char **argv) {
+bool Ringworld2Debugger::Cmd_SetOutpostAlphaDebug(int argc, const char **argv) {
if (argc != 1) {
debugPrintf("Usage: %s\n", argv[0]);
return true;
diff --git a/engines/tsage/debugger.h b/engines/tsage/debugger.h
index 610f45de64..b0f4c665dd 100644
--- a/engines/tsage/debugger.h
+++ b/engines/tsage/debugger.h
@@ -45,7 +45,7 @@ protected:
bool Cmd_Sound(int argc, const char **argv);
virtual bool Cmd_ListObjects(int argc, const char **argv) = 0;
virtual bool Cmd_MoveObject(int argc, const char **argv) = 0;
- virtual bool Cmd_SetDebug(int argc, const char **argv);
+ virtual bool Cmd_SetOutpostAlphaDebug(int argc, const char **argv);
};
class DemoDebugger : public Debugger {
@@ -70,7 +70,7 @@ class Ringworld2Debugger : public Debugger {
protected:
virtual bool Cmd_ListObjects(int argc, const char **argv);
virtual bool Cmd_MoveObject(int argc, const char **argv);
- virtual bool Cmd_SetDebug(int argc, const char **argv);
+ virtual bool Cmd_SetOutpostAlphaDebug(int argc, const char **argv);
};
} // End of namespace TsAGE
diff --git a/engines/tsage/module.mk b/engines/tsage/module.mk
index 53c03e2e57..d62f398c20 100644
--- a/engines/tsage/module.mk
+++ b/engines/tsage/module.mk
@@ -35,13 +35,16 @@ MODULE_OBJS := \
ringworld/ringworld_scenes8.o \
ringworld/ringworld_scenes10.o \
ringworld/ringworld_speakers.o \
+ ringworld2/ringworld2_airduct.o \
ringworld2/ringworld2_dialogs.o \
ringworld2/ringworld2_logic.o \
+ ringworld2/ringworld2_outpost.o \
ringworld2/ringworld2_scenes0.o \
ringworld2/ringworld2_scenes1.o \
ringworld2/ringworld2_scenes2.o \
ringworld2/ringworld2_scenes3.o \
ringworld2/ringworld2_speakers.o \
+ ringworld2/ringworld2_vampire.o \
saveload.o \
scenes.o \
sound.o \
diff --git a/engines/tsage/ringworld/ringworld_dialogs.cpp b/engines/tsage/ringworld/ringworld_dialogs.cpp
index 226a943f08..1dd3bc158b 100644
--- a/engines/tsage/ringworld/ringworld_dialogs.cpp
+++ b/engines/tsage/ringworld/ringworld_dialogs.cpp
@@ -20,8 +20,6 @@
*
*/
-#include "common/translation.h"
-
#include "gui/dialog.h"
#include "gui/widget.h"
diff --git a/engines/tsage/ringworld2/ringworld2_airduct.cpp b/engines/tsage/ringworld2/ringworld2_airduct.cpp
new file mode 100644
index 0000000000..136e8d5d1b
--- /dev/null
+++ b/engines/tsage/ringworld2/ringworld2_airduct.cpp
@@ -0,0 +1,909 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public 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 "tsage/ringworld2/ringworld2_airduct.h"
+
+namespace TsAGE {
+
+namespace Ringworld2 {
+
+/*--------------------------------------------------------------------------
+ * Scene 1200 - Air Ducts Maze
+ *
+ *--------------------------------------------------------------------------*/
+
+Scene1200::Scene1200() {
+ _nextCrawlDirection = 0;
+ _field414 = 0;
+ _field416 = 0;
+ _field418 = 0;
+ _field41A = 0;
+ _fixupMaze = false;
+}
+
+void Scene1200::synchronize(Serializer &s) {
+ SceneExt::synchronize(s);
+
+ s.syncAsSint16LE(_nextCrawlDirection);
+ s.syncAsSint16LE(_field414);
+ s.syncAsSint16LE(_field416);
+ s.syncAsSint16LE(_field418);
+ s.syncAsSint16LE(_field41A);
+ s.syncAsSint16LE(_fixupMaze);
+}
+
+Scene1200::LaserPanel::LaserPanel() {
+}
+
+void Scene1200::LaserPanel::Jumper::init(int state) {
+ _state = state;
+
+ SceneActor::postInit();
+ setup(1003, 1, 1);
+ fixPriority(255);
+
+ switch (_state) {
+ case 1:
+ switch (R2_GLOBALS._ductMazePanel1State) {
+ case 1:
+ setFrame2(2);
+ setPosition(Common::Point(129, 101));
+ break;
+ case 2:
+ setFrame2(3);
+ setPosition(Common::Point(135, 95));
+ break;
+ default:
+ break;
+ }
+ break;
+ case 2:
+ switch (R2_GLOBALS._ductMazePanel2State) {
+ case 1:
+ setFrame2(2);
+ setPosition(Common::Point(152, 101));
+ break;
+ case 2:
+ setFrame2(3);
+ setPosition(Common::Point(158, 122));
+ break;
+ case 3:
+ setFrame2(3);
+ setPosition(Common::Point(135, 122));
+ break;
+ default:
+ break;
+ }
+ break;
+ case 3:
+ switch (R2_GLOBALS._ductMazePanel3State) {
+ case 1:
+ setFrame2(3);
+ setPosition(Common::Point(158, 95));
+ break;
+ case 2:
+ setFrame2(2);
+ setPosition(Common::Point(175, 101));
+ break;
+ default:
+ break;
+ }
+ break;
+ default:
+ break;
+ }
+
+ setDetails(1200, 12, -1, -1, 2, (SceneItem *) NULL);
+}
+
+bool Scene1200::LaserPanel::Jumper::startAction(CursorType action, Event &event) {
+ if (action != CURSOR_USE)
+ return SceneActor::startAction(action, event);
+
+ R2_GLOBALS._sound2.play(260);
+ switch (_state) {
+ case 1:
+ if (R2_GLOBALS._ductMazePanel1State == 1) {
+ R2_GLOBALS._ductMazePanel1State = 2;
+ setFrame2(3);
+ setPosition(Common::Point(135, 95));
+ } else {
+ R2_GLOBALS._ductMazePanel1State = 1;
+ setFrame2(2);
+ setPosition(Common::Point(129, 101));
+ }
+ break;
+ case 2:
+ ++R2_GLOBALS._ductMazePanel2State;
+ if (R2_GLOBALS._ductMazePanel2State == 4)
+ R2_GLOBALS._ductMazePanel2State = 1;
+
+ switch (R2_GLOBALS._ductMazePanel2State) {
+ case 1:
+ setFrame2(2);
+ setPosition(Common::Point(152, 101));
+ break;
+ case 2:
+ setFrame2(3);
+ setPosition(Common::Point(158, 122));
+ break;
+ case 3:
+ setFrame2(3);
+ setPosition(Common::Point(135, 122));
+ break;
+ default:
+ break;
+ }
+ break;
+ case 3:
+ if (R2_GLOBALS._ductMazePanel3State == 1) {
+ R2_GLOBALS._ductMazePanel3State = 2;
+ setFrame2(2);
+ setPosition(Common::Point(175, 101));
+ } else {
+ R2_GLOBALS._ductMazePanel3State = 1;
+ setFrame2(3);
+ setPosition(Common::Point(158, 95));
+ }
+ break;
+ default:
+ break;
+ }
+
+ Scene1200 *scene = (Scene1200 *)R2_GLOBALS._sceneManager._scene;
+ scene->_field418 = 0;
+
+ if ((R2_GLOBALS._ductMazePanel1State == 1) && (R2_GLOBALS._ductMazePanel2State == 1) && (R2_GLOBALS._ductMazePanel3State == 1))
+ scene->_field418 = 1;
+ else if ((R2_GLOBALS._ductMazePanel1State == 2) && (R2_GLOBALS._ductMazePanel2State == 1) && (R2_GLOBALS._ductMazePanel3State == 1))
+ scene->_field418 = 2;
+ else if ((R2_GLOBALS._ductMazePanel1State == 2) && (R2_GLOBALS._ductMazePanel2State == 1) && (R2_GLOBALS._ductMazePanel3State == 2))
+ scene->_field418 = 3;
+ else if ((R2_GLOBALS._ductMazePanel1State == 2) && (R2_GLOBALS._ductMazePanel2State == 3) && (R2_GLOBALS._ductMazePanel3State == 1))
+ scene->_field418 = 4;
+
+ return true;
+}
+
+void Scene1200::LaserPanel::postInit(SceneObjectList *OwnerList) {
+ Scene1200 *scene = (Scene1200 *)R2_GLOBALS._sceneManager._scene;
+
+ scene->_field41A = 1;
+ R2_GLOBALS._events.setCursor(CURSOR_USE);
+ setup2(1003, 1, 1, 100, 40);
+ setup3(1200, 11, -1, -1);
+ R2_GLOBALS._sound2.play(259);
+ _jumper1.init(1);
+ _jumper2.init(2);
+ _jumper3.init(3);
+
+ R2_GLOBALS._player._canWalk = false;
+}
+
+void Scene1200::LaserPanel::remove() {
+ Scene1200 *scene = (Scene1200 *)R2_GLOBALS._sceneManager._scene;
+
+ scene->_field41A = 0;
+ scene->_sceneAreas.remove(&_jumper1);
+ scene->_sceneAreas.remove(&_jumper2);
+ scene->_sceneAreas.remove(&_jumper3);
+ _jumper1.remove();
+ _jumper2.remove();
+ _jumper3.remove();
+
+ ModalWindow::remove();
+ R2_GLOBALS._player._canWalk = true;
+}
+
+void Scene1200::postInit(SceneObjectList *OwnerList) {
+ loadScene(1200);
+ SceneExt::postInit();
+
+ if (R2_GLOBALS._sceneManager._previousScene < 3200)
+ R2_GLOBALS._sound1.play(257);
+
+ _nextCrawlDirection = CRAWL_EAST;
+ _field414 = 0;
+ _field416 = 0;
+ _field418 = 0;
+ _field41A = 0;
+
+ if ((R2_GLOBALS._ductMazePanel1State == 1) && (R2_GLOBALS._ductMazePanel2State == 1) && (R2_GLOBALS._ductMazePanel3State == 1))
+ _field418 = 1;
+ else if ((R2_GLOBALS._ductMazePanel1State == 2) && (R2_GLOBALS._ductMazePanel2State == 1) && (R2_GLOBALS._ductMazePanel3State == 1))
+ _field418 = 2;
+ else if ((R2_GLOBALS._ductMazePanel1State == 2) && (R2_GLOBALS._ductMazePanel2State == 1) && (R2_GLOBALS._ductMazePanel3State == 2))
+ _field418 = 3;
+ else if ((R2_GLOBALS._ductMazePanel1State == 2) && (R2_GLOBALS._ductMazePanel2State == 3) && (R2_GLOBALS._ductMazePanel3State == 1))
+ _field418 = 4;
+
+ R2_GLOBALS._player.postInit();
+ R2_GLOBALS._player.disableControl();
+ R2_GLOBALS._player.setup(3156, 1, 6);
+ R2_GLOBALS._player.setPosition(Common::Point(160, 70));
+ R2_GLOBALS._player._numFrames = 10;
+ R2_GLOBALS._player._oldCharacterScene[R2_MIRANDA] = 1200;
+
+ _actor1.postInit();
+ _actor1.hide();
+
+ _mazeUI.setDisplayBounds(Rect(110, 20, 210, 120));
+
+ _mazeUI.postInit();
+ _mazeUI.load(1);
+ _mazeUI.setMazePosition(R2_GLOBALS._ventCellPos);
+
+ R2_GLOBALS._player.enableControl();
+ _item1.setDetails(Rect(0, 0, 320, 200), 1200, 0, 1, 2, 1, NULL);
+}
+
+void Scene1200::signal() {
+ switch (_sceneMode++) {
+ case 1:
+ // No break on purpose
+ case 1200:
+ // No break on purpose
+ case 1201:
+ // No break on purpose
+ case 1202:
+ // No break on purpose
+ case 1203:
+ R2_GLOBALS._player.enableControl();
+ // CHECKME: The original is calling _eventManager.waitEvent();
+ _sceneMode = 2;
+ break;
+ case 10:
+ _field416 = 1;
+ _field414 = 6;
+ R2_GLOBALS._player._numFrames = 5;
+ R2_GLOBALS._player.setStrip(1);
+ R2_GLOBALS._player.setFrame(5);
+ R2_GLOBALS._player.animate(ANIM_MODE_6, this);
+ break;
+ case 11:
+ // No break on purpose
+ case 21:
+ // No break on purpose
+ case 31:
+ // No break on purpose
+ case 41:
+ _field416 = 0;
+ break;
+ case 12:
+ _field414 = 14;
+ R2_GLOBALS._player._numFrames = 10;
+ R2_GLOBALS._player.setup(3155, 1, 4);
+ R2_GLOBALS._player.setPosition(Common::Point(160, 70));
+ R2_GLOBALS._player.animate(ANIM_MODE_2, NULL);
+ break;
+ case 13:
+ // No break on purpose
+ case 16:
+ // No break on purpose
+ case 23:
+ // No break on purpose
+ case 26:
+ // No break on purpose
+ case 33:
+ // No break on purpose
+ case 36:
+ // No break on purpose
+ case 43:
+ // No break on purpose
+ case 46:
+ R2_GLOBALS._player.setFrame(4);
+ _sceneMode = 1;
+ setAction(&_sequenceManager, this, 1, &R2_GLOBALS._player, NULL);
+ break;
+ case 15:
+ // No break on purpose
+ case 25:
+ // No break on purpose
+ case 35:
+ // No break on purpose
+ case 45:
+ _field414 = 20;
+ R2_GLOBALS._player.animate(ANIM_MODE_2, NULL);
+ break;
+ case 20:
+ _field416 = 1;
+ _field414 = 6;
+ R2_GLOBALS._player._numFrames = 5;
+ R2_GLOBALS._player.setStrip(2);
+ R2_GLOBALS._player.setFrame(5);
+ R2_GLOBALS._player.animate(ANIM_MODE_6, this);
+ break;
+ case 22:
+ _field414 = 14;
+ R2_GLOBALS._player._numFrames = 10;
+ R2_GLOBALS._player.setup(3155, 2, 4);
+ R2_GLOBALS._player.setPosition(Common::Point(160, 70));
+ R2_GLOBALS._player.animate(ANIM_MODE_2, NULL);
+ break;
+ case 30:
+ _field416 = 1;
+ _field414 = 6;
+ R2_GLOBALS._player._numFrames = 5;
+ R2_GLOBALS._player.setStrip(3);
+ R2_GLOBALS._player.setFrame(5);
+ R2_GLOBALS._player.animate(ANIM_MODE_6, this);
+ break;
+ case 32:
+ _field414 = 14;
+ R2_GLOBALS._player._numFrames = 10;
+ R2_GLOBALS._player.setup(3155, 3, 4);
+ R2_GLOBALS._player.setPosition(Common::Point(160, 70));
+ R2_GLOBALS._player.animate(ANIM_MODE_2, NULL);
+ break;
+ case 40:
+ _field416 = 1;
+ _field414 = 6;
+ R2_GLOBALS._player._numFrames = 5;
+ R2_GLOBALS._player.setStrip(4);
+ R2_GLOBALS._player.setFrame(5);
+ R2_GLOBALS._player.animate(ANIM_MODE_6, this);
+ break;
+ case 42:
+ _field414 = 14;
+ R2_GLOBALS._player._numFrames = 10;
+ R2_GLOBALS._player.setup(3155, 4, 4);
+ R2_GLOBALS._player.setPosition(Common::Point(160, 70));
+ R2_GLOBALS._player.animate(ANIM_MODE_2, NULL);
+ break;
+ case 50:
+ // No break on purpose
+ case 55:
+ // No break on purpose
+ case 60:
+ R2_GLOBALS._player.setup(3156, 5, 1);
+ R2_GLOBALS._player._numFrames = 5;
+ R2_GLOBALS._player.animate(ANIM_MODE_5, this);
+ break;
+ case 51:
+ // No break on purpose
+ case 56:
+ // No break on purpose
+ case 117:
+ R2_GLOBALS._player.setup(3157, 1, 1);
+ R2_GLOBALS._player.animate(ANIM_MODE_5, this);
+ break;
+ case 52:
+ // No break on purpose
+ case 82:
+ // No break on purpose
+ case 118:
+ R2_GLOBALS._player.setup(3156, 3, 6);
+ _sceneMode = 1;
+ setAction(&_sequenceManager, this, 1, &R2_GLOBALS._player, NULL);
+ break;
+ case 57:
+ // No break on purpose
+ case 91:
+ // No break on purpose
+ case 96:
+ R2_GLOBALS._player.setup(3157, 2, 1);
+ R2_GLOBALS._player.animate(ANIM_MODE_5, this);
+ break;
+ case 58:
+ // No break on purpose
+ case 92:
+ // No break on purpose
+ case 122:
+ R2_GLOBALS._player.setup(3156, 2, 6);
+ _sceneMode = 1;
+ setAction(&_sequenceManager, this, 1, &R2_GLOBALS._player, NULL);
+ break;
+ case 61:
+ R2_GLOBALS._player.setup(3157, 4, 5);
+ R2_GLOBALS._player.animate(ANIM_MODE_6, this);
+ break;
+ case 62:
+ // No break on purpose
+ case 72:
+ // No break on purpose
+ case 98:
+ R2_GLOBALS._player.setup(3156, 4, 6);
+ _sceneMode = 1;
+ setAction(&_sequenceManager, this, 1, &R2_GLOBALS._player, NULL);
+ break;
+ case 70:
+ // No break on purpose
+ case 75:
+ // No break on purpose
+ case 80:
+ R2_GLOBALS._player.setup(3156, 6, 1);
+ R2_GLOBALS._player._numFrames = 5;
+ R2_GLOBALS._player.animate(ANIM_MODE_5, this);
+ break;
+ case 71:
+ // No break on purpose
+ case 76:
+ // No break on purpose
+ case 97:
+ R2_GLOBALS._player.setup(3157, 3, 1);
+ R2_GLOBALS._player.animate(ANIM_MODE_5, this);
+ break;
+ case 77:
+ // No break on purpose
+ case 111:
+ // No break on purpose
+ case 116:
+ R2_GLOBALS._player.setup(3157, 4, 1);
+ R2_GLOBALS._player.animate(ANIM_MODE_5, this);
+ break;
+ case 78:
+ // No break on purpose
+ case 102:
+ // No break on purpose
+ case 112:
+ R2_GLOBALS._player.setup(3156, 1, 6);
+ _sceneMode = 1;
+ setAction(&_sequenceManager, this, 1, &R2_GLOBALS._player, NULL);
+ break;
+ case 81:
+ R2_GLOBALS._player.setup(3157, 2, 5);
+ R2_GLOBALS._player.animate(ANIM_MODE_6, this);
+ break;
+ case 90:
+ // No break on purpose
+ case 95:
+ // No break on purpose
+ case 100:
+ R2_GLOBALS._player.setup(3156, 7, 1);
+ R2_GLOBALS._player._numFrames = 5;
+ R2_GLOBALS._player.animate(ANIM_MODE_5, this);
+ break;
+ case 101:
+ R2_GLOBALS._player.setup(3157, 1, 5);
+ R2_GLOBALS._player.animate(ANIM_MODE_6, this);
+ break;
+ case 110:
+ // No break on purpose
+ case 115:
+ // No break on purpose
+ case 120:
+ R2_GLOBALS._player.setup(3156, 8, 1);
+ R2_GLOBALS._player._numFrames = 5;
+ R2_GLOBALS._player.animate(ANIM_MODE_5, this);
+ break;
+ case 121:
+ R2_GLOBALS._player.setup(3157, 3, 5);
+ R2_GLOBALS._player.animate(ANIM_MODE_6, this);
+ break;
+ default:
+ // CHECKME: The original is walling _eventManager.waitEvent();
+ _sceneMode = 2;
+ break;
+ }
+}
+
+void Scene1200::process(Event &event) {
+ if (_field414 != 0)
+ return;
+
+ Scene::process(event);
+
+ if (!R2_GLOBALS._player._canWalk)
+ return;
+
+ if (event.eventType == EVENT_BUTTON_DOWN) {
+ Common::Point cellPos = R2_GLOBALS._ventCellPos;
+ _mazeUI.pixelToCellXY(cellPos);
+
+ int cellId = _mazeUI.getCellFromPixelXY(event.mousePos);
+ switch (R2_GLOBALS._events.getCursor()) {
+ case CURSOR_WALK:
+ event.handled = true;
+ if ((event.mousePos.x > 179) && (event.mousePos.x < 210) && (event.mousePos.y > 50) && (event.mousePos.y < 89))
+ startCrawling(CRAWL_EAST);
+
+ if ((event.mousePos.x > 109) && (event.mousePos.x < 140) && (event.mousePos.y > 50) && (event.mousePos.y < 89))
+ startCrawling(CRAWL_WEST);
+
+ if ((event.mousePos.x > 140) && (event.mousePos.x < 179) && (event.mousePos.y > 89) && (event.mousePos.y < 120))
+ startCrawling(CRAWL_SOUTH);
+
+ if ((event.mousePos.x > 140) && (event.mousePos.x < 179) && (event.mousePos.y > 19) && (event.mousePos.y < 50))
+ startCrawling(CRAWL_NORTH);
+ break;
+ case CURSOR_USE:
+ if (cellId > 36) {
+ if ( ((cellPos.x == 3) && (cellPos.y == 33))
+ || ((cellPos.x == 7) && (cellPos.y == 33))
+ || ((cellPos.x == 33) && (cellPos.y == 41))
+ || ((cellPos.x == 5) && (cellPos.y == 5))
+ || ((cellPos.x == 13) && (cellPos.y == 21))
+ || ((cellPos.x == 17) && (cellPos.y == 21))
+ || ((cellPos.x == 17) && (cellPos.y == 5))
+ || ((cellPos.x == 17) && (cellPos.y == 9))
+ || ((cellPos.x == 29) && (cellPos.y == 17))
+ || ((cellPos.x == 33) && (cellPos.y == 17))
+ || ((cellPos.x == 35) && (cellPos.y == 17))
+ || ((cellPos.x == 41) && (cellPos.y == 21)) ) {
+ _laserPanel.postInit();
+ event.handled = true;
+ }
+ }
+
+ if ((cellId == 1) || (cellId == 4) || (cellId == 11) || (cellId == 14)) {
+ if ( ((cellPos.x == 3) && (cellPos.y == 9))
+ || ((cellPos.x == 11) && (cellPos.y == 27))
+ || ((cellPos.x == 17) && (cellPos.y == 7))
+ || ((cellPos.x == 17) && (cellPos.y == 27))
+ || ((cellPos.x == 17) && (cellPos.y == 33))
+ || (cellPos.x == 33) ) {
+ switch (cellPos.x) {
+ case 3:
+ R2_GLOBALS._sceneManager.changeScene(3150);
+ break;
+ case 33:
+ if (R2_GLOBALS._scientistConvIndex >= 4)
+ R2_GLOBALS._sceneManager.changeScene(3250);
+ else
+ SceneItem::display(1200, 6, 0, 280, 1, 160, 9, 1, 2, 20, 7, 154, LIST_END);
+ break;
+ default:
+ SceneItem::display(1200, 5, 0, 280, 1, 160, 9, 1, 2, 20, 7, 154, LIST_END);
+ break;
+ }
+ event.handled = true;
+ }
+ }
+ break;
+ case CURSOR_LOOK:
+ if ((cellId == 1) || (cellId == 4) || (cellId == 11) || (cellId == 14)) {
+ event.handled = true;
+ switch (cellPos.x) {
+ case 3:
+ // It was your cell.
+ SceneItem::display(1200, 8, 0, 280, 1, 160, 9, 1, 2, 20, 7, 7, LIST_END);
+ break;
+ case 9:
+ R2_GLOBALS._sceneManager.changeScene(3240);
+ break;
+ case 11:
+ if (cellPos.y == 27)
+ R2_GLOBALS._sceneManager.changeScene(3210);
+ else
+ // A vent grill
+ SceneItem::display(1200, 10, 0, 280, 1, 160, 9, 1, 2, 20, 7, 7, LIST_END);
+ break;
+ case 17:
+ switch (cellPos.y) {
+ case 5:
+ R2_GLOBALS._sceneManager.changeScene(3230);
+ break;
+ case 21:
+ R2_GLOBALS._sceneManager.changeScene(3220);
+ break;
+ case 33:
+ R2_GLOBALS._sceneManager.changeScene(3200);
+ break;
+ default:
+ // A vent grill
+ SceneItem::display(1200, 10, 0, 280, 1, 160, 9, 1, 2, 20, 7, 7, LIST_END);
+ break;
+ }
+ break;
+ case 33:
+ R2_GLOBALS._sceneManager.changeScene(3245);
+ break;
+ default:
+ SceneItem::display(1200, 10, 0, 280, 1, 160, 9, 1, 2, 20, 7, 7, LIST_END);
+ break;
+ }
+ }
+ if (cellId > 36) {
+ // "An anti-pest laser"
+ event.handled = true;
+ SceneItem::display(1200, 9, 0, 280, 1, 160, 9, 1, 2, 20, 7, 7, LIST_END);
+ }
+ break;
+ case CURSOR_TALK:
+ event.handled = true;
+ break;
+ default:
+ return;
+ }
+ } else if (event.eventType == EVENT_KEYPRESS) {
+ if (_field414) {
+ event.handled = false;
+ return;
+ }
+
+ switch (event.kbd.keycode) {
+ case Common::KEYCODE_KP8:
+ case Common::KEYCODE_UP:
+ startCrawling(CRAWL_NORTH);
+ break;
+ case Common::KEYCODE_KP4:
+ case Common::KEYCODE_LEFT:
+ startCrawling(CRAWL_WEST);
+ break;
+ case Common::KEYCODE_KP6:
+ case Common::KEYCODE_RIGHT:
+ startCrawling(CRAWL_EAST);
+ break;
+ case Common::KEYCODE_KP2:
+ case Common::KEYCODE_DOWN:
+ startCrawling(CRAWL_SOUTH);
+ break;
+ default:
+ event.handled = false;
+ return;
+ break;
+ }
+ } else
+ return;
+}
+
+void Scene1200::dispatch() {
+ Rect tmpRect;
+ Scene::dispatch();
+
+ if (_fixupMaze) {
+ _mazeUI.setMazePosition(R2_GLOBALS._ventCellPos);
+ //_mazeUI.draw();
+ _fixupMaze = false;
+ }
+
+ if (_field414 != 0) {
+ tmpRect.set(110, 20, 210, 120);
+ _field414--;
+
+ switch (_nextCrawlDirection) {
+ case CRAWL_EAST:
+ R2_GLOBALS._ventCellPos.x += 2;
+ break;
+ case CRAWL_WEST:
+ R2_GLOBALS._ventCellPos.x -= 2;
+ break;
+ case CRAWL_SOUTH:
+ R2_GLOBALS._ventCellPos.y += 2;
+ break;
+ case CRAWL_NORTH:
+ R2_GLOBALS._ventCellPos.y -= 2;
+ break;
+ default:
+ break;
+ }
+
+ _mazeUI.setMazePosition(R2_GLOBALS._ventCellPos);
+ //_mazeUI.draw();
+
+ if (_field416 != 0) {
+ switch(_nextCrawlDirection) {
+ case CRAWL_EAST:
+ R2_GLOBALS._player.setPosition(Common::Point(R2_GLOBALS._player._position.x - 2, R2_GLOBALS._player._position.y));
+ break;
+ case CRAWL_WEST:
+ R2_GLOBALS._player.setPosition(Common::Point(R2_GLOBALS._player._position.x + 2, R2_GLOBALS._player._position.y));
+ break;
+ case CRAWL_SOUTH:
+ R2_GLOBALS._player.setPosition(Common::Point(R2_GLOBALS._player._position.x, R2_GLOBALS._player._position.y - 2));
+ break;
+ case CRAWL_NORTH:
+ R2_GLOBALS._player.setPosition(Common::Point(R2_GLOBALS._player._position.x, R2_GLOBALS._player._position.y + 2));
+ break;
+ default:
+ break;
+ }
+ }
+ if (_field414 == 0) {
+ if (_field416 == 0)
+ R2_GLOBALS._player.animate(ANIM_MODE_NONE, NULL);
+ signal();
+ }
+ }
+}
+
+void Scene1200::saveCharacter(int characterIndex) {
+ R2_GLOBALS._sound1.fadeOut2(NULL);
+ SceneExt::saveCharacter(characterIndex);
+}
+
+void Scene1200::startCrawling(CrawlDirection dir) {
+ Common::Point cellPos = R2_GLOBALS._ventCellPos;
+ _mazeUI.pixelToCellXY(cellPos);
+
+ switch (dir) {
+ case CRAWL_EAST:
+ if ( ((_mazeUI.getCellFromPixelXY(Common::Point(200, 50)) > 36) || (_mazeUI.getCellFromPixelXY(Common::Point(200, 88)) > 36))
+ && ( ((cellPos.x == 3) && (cellPos.y == 33) && (_field418 != 4))
+ || ((cellPos.x == 13) && (cellPos.y == 21) && (_field418 != 2))
+ || ((cellPos.x == 29) && (cellPos.y == 17) && (_field418 != 1))
+ || ((cellPos.x == 33) && (cellPos.y == 41)) )
+ ) {
+ R2_GLOBALS._player.disableControl();
+ _sceneMode = 1200;
+ setAction(&_sequenceManager, this, 1200, &_actor1, NULL);
+ } else if (_mazeUI.getCellFromPixelXY(Common::Point(200, 69)) == 36) {
+ switch (_nextCrawlDirection) {
+ case CRAWL_EAST:
+ if (R2_GLOBALS._player._visage == 3155)
+ _sceneMode = 15;
+ else
+ _sceneMode = 10;
+ break;
+ case CRAWL_WEST:
+ if (R2_GLOBALS._player._visage == 3156)
+ _sceneMode = 76;
+ else
+ _sceneMode = 75;
+ break;
+ case CRAWL_SOUTH:
+ if (R2_GLOBALS._player._visage == 3156)
+ _sceneMode = 101;
+ else
+ _sceneMode = 100;
+ break;
+ case CRAWL_NORTH:
+ if (R2_GLOBALS._player._visage == 3156)
+ _sceneMode = 111;
+ else
+ _sceneMode = 110;
+ break;
+ default:
+ break;
+ }
+ R2_GLOBALS._player.disableControl();
+ _nextCrawlDirection = 1;
+ signal();
+ }
+ break;
+ case CRAWL_WEST:
+ if ( ((_mazeUI.getCellFromPixelXY(Common::Point(120, 50)) > 36) || (_mazeUI.getCellFromPixelXY(Common::Point(120, 88)) > 36))
+ && ( ((cellPos.x == 7) && (cellPos.y == 33) && (_field418 != 4))
+ || ((cellPos.x == 17) && (cellPos.y == 21) && (_field418 != 2))
+ || ((cellPos.x == 33) && (cellPos.y == 17) && (_field418 != 1))
+ || ((cellPos.x == 5) && (cellPos.y == 5)) )
+ ) {
+ R2_GLOBALS._player.disableControl();
+ _sceneMode = 1201;
+ setAction(&_sequenceManager, this, 1201, &_actor1, NULL);
+ } else if (_mazeUI.getCellFromPixelXY(Common::Point(120, 69)) == 36) {
+ switch (_nextCrawlDirection) {
+ case CRAWL_EAST:
+ if (R2_GLOBALS._player._visage == 3156)
+ _sceneMode = 56;
+ else
+ _sceneMode = 55;
+ break;
+ case CRAWL_WEST:
+ if (R2_GLOBALS._player._visage == 3155)
+ _sceneMode = 25;
+ else
+ _sceneMode = 20;
+ break;
+ case CRAWL_SOUTH:
+ if (R2_GLOBALS._player._visage == 3156)
+ _sceneMode = 91;
+ else
+ _sceneMode = 90;
+ break;
+ case CRAWL_NORTH:
+ if (R2_GLOBALS._player._visage == 3156)
+ _sceneMode = 121;
+ else
+ _sceneMode = 120;
+ break;
+ default:
+ break;
+ }
+ R2_GLOBALS._player.disableControl();
+ _nextCrawlDirection = 2;
+ signal();
+ }
+ break;
+ case CRAWL_SOUTH:
+ if ( ((_mazeUI.getCellFromPixelXY(Common::Point(140, 110)) > 36) || (_mazeUI.getCellFromPixelXY(Common::Point(178, 110)) > 36))
+ && ( ((cellPos.x == 17) && (cellPos.y == 5) && (_field418 != 3))
+ || ((cellPos.x == 41) && (cellPos.y == 21)) )
+ ) {
+ R2_GLOBALS._player.disableControl();
+ _sceneMode = 1203;
+ setAction(&_sequenceManager, this, 1203, &_actor1, NULL);
+ } else if (_mazeUI.getCellFromPixelXY(Common::Point(160, 110)) == 36) {
+ switch (_nextCrawlDirection) {
+ case CRAWL_EAST:
+ if (R2_GLOBALS._player._visage == 3156)
+ _sceneMode = 51;
+ else
+ _sceneMode = 50;
+ break;
+ case CRAWL_WEST:
+ if (R2_GLOBALS._player._visage == 3156)
+ _sceneMode = 81;
+ else
+ _sceneMode = 80;
+ break;
+ case CRAWL_SOUTH:
+ if (R2_GLOBALS._player._visage == 3155)
+ _sceneMode = 35;
+ else
+ _sceneMode = 30;
+ break;
+ case CRAWL_NORTH:
+ if (R2_GLOBALS._player._visage == 3156)
+ _sceneMode = 116;
+ else
+ _sceneMode = 115;
+ break;
+ default:
+ break;
+ }
+ R2_GLOBALS._player.disableControl();
+ _nextCrawlDirection = 3;
+ signal();
+ }
+ break;
+ case CRAWL_NORTH:
+ if ( ((_mazeUI.getCellFromPixelXY(Common::Point(140, 30)) > 36) || (_mazeUI.getCellFromPixelXY(Common::Point(178, 30)) > 36))
+ && ( ((cellPos.x == 17) && (cellPos.y == 9) && (_field418 != 3))
+ || ((cellPos.x == 35) && (cellPos.y == 17)) )
+ ) {
+ R2_GLOBALS._player.disableControl();
+ _sceneMode = 1202;
+ setAction(&_sequenceManager, this, 1202, &_actor1, NULL);
+ } else if (_mazeUI.getCellFromPixelXY(Common::Point(160, 30)) == 36) {
+ switch (_nextCrawlDirection) {
+ case CRAWL_EAST:
+ if (R2_GLOBALS._player._visage == 3156)
+ _sceneMode = 61;
+ else
+ _sceneMode = 60;
+ break;
+ case CRAWL_WEST:
+ if (R2_GLOBALS._player._visage == 3156)
+ _sceneMode = 71;
+ else
+ _sceneMode = 70;
+ break;
+ case CRAWL_SOUTH:
+ if (R2_GLOBALS._player._visage == 3156)
+ _sceneMode = 96;
+ else
+ _sceneMode = 95;
+ break;
+ case CRAWL_NORTH:
+ if (R2_GLOBALS._player._visage == 3155)
+ _sceneMode = 45;
+ else
+ _sceneMode = 40;
+ break;
+ default:
+ _sceneMode = 1;
+ R2_GLOBALS._player.setup(3156, 4, 6);
+ break;
+ }
+ R2_GLOBALS._player.disableControl();
+ _nextCrawlDirection = 4;
+ signal();
+ }
+ break;
+ default:
+ break;
+ }
+}
+
+} // End of namespace Ringworld2
+} // End of namespace TsAGE
diff --git a/engines/tsage/ringworld2/ringworld2_airduct.h b/engines/tsage/ringworld2/ringworld2_airduct.h
new file mode 100644
index 0000000000..89dfe778d0
--- /dev/null
+++ b/engines/tsage/ringworld2/ringworld2_airduct.h
@@ -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.
+ *
+ */
+
+#ifndef TSAGE_RINGWORLD2_AIRDUCT_H
+#define TSAGE_RINGWORLD2_AIRDUCT_H
+
+#include "tsage/events.h"
+#include "tsage/core.h"
+#include "tsage/scenes.h"
+#include "tsage/globals.h"
+#include "tsage/sound.h"
+#include "tsage/ringworld2/ringworld2_logic.h"
+
+namespace TsAGE {
+
+namespace Ringworld2 {
+
+using namespace TsAGE;
+
+class Scene1200 : public SceneExt {
+ enum CrawlDirection { CRAWL_EAST = 1, CRAWL_WEST = 2, CRAWL_SOUTH = 3, CRAWL_NORTH = 4 };
+
+ class LaserPanel: public ModalWindow {
+ public:
+ class Jumper : public SceneActorExt {
+ public:
+ void init(int state);
+ virtual bool startAction(CursorType action, Event &event);
+ };
+
+ Jumper _jumper1;
+ Jumper _jumper2;
+ Jumper _jumper3;
+
+ LaserPanel();
+
+ virtual void postInit(SceneObjectList *OwnerList = NULL);
+ virtual void remove();
+ };
+
+public:
+ NamedHotspot _item1;
+ SceneActor _actor1;
+ LaserPanel _laserPanel;
+ MazeUI _mazeUI;
+ SequenceManager _sequenceManager;
+
+ int _nextCrawlDirection;
+ int _field414;
+ int _field416;
+ int _field418;
+ int _field41A;
+ bool _fixupMaze;
+
+ Scene1200();
+ void synchronize(Serializer &s);
+
+ void startCrawling(CrawlDirection dir);
+
+ virtual void postInit(SceneObjectList *OwnerList = NULL);
+ virtual void signal();
+ virtual void process(Event &event);
+ virtual void dispatch();
+ virtual void saveCharacter(int characterIndex);
+};
+
+} // End of namespace Ringworld2
+} // End of namespace TsAGE
+
+#endif
diff --git a/engines/tsage/ringworld2/ringworld2_logic.cpp b/engines/tsage/ringworld2/ringworld2_logic.cpp
index 99188c1ab6..d24541932f 100644
--- a/engines/tsage/ringworld2/ringworld2_logic.cpp
+++ b/engines/tsage/ringworld2/ringworld2_logic.cpp
@@ -32,6 +32,9 @@
#include "tsage/ringworld2/ringworld2_scenes1.h"
#include "tsage/ringworld2/ringworld2_scenes2.h"
#include "tsage/ringworld2/ringworld2_scenes3.h"
+#include "tsage/ringworld2/ringworld2_airduct.h"
+#include "tsage/ringworld2/ringworld2_outpost.h"
+#include "tsage/ringworld2/ringworld2_vampire.h"
namespace TsAGE {
@@ -355,6 +358,11 @@ SceneExt::SceneExt(): Scene() {
// to make inter-scene debugging easier, I'm explicitly resetting the _animationCtr
// on scene start, since scene objects aren't drawn while it's non-zero
R2_GLOBALS._animationCtr = 0;
+
+ // WORKAROUND: We had a case where at some point the number of modal dialogs
+ // open became incorrect. So reset it on scene changes to fix the problem if
+ // it ever happens
+ R2_GLOBALS._insetUp = 0;
}
void SceneExt::synchronize(Serializer &s) {
diff --git a/engines/tsage/ringworld2/ringworld2_outpost.cpp b/engines/tsage/ringworld2/ringworld2_outpost.cpp
new file mode 100644
index 0000000000..cad21b4623
--- /dev/null
+++ b/engines/tsage/ringworld2/ringworld2_outpost.cpp
@@ -0,0 +1,4700 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public 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/cursorman.h"
+#include "tsage/tsage.h"
+#include "tsage/staticres.h"
+#include "tsage/ringworld2/ringworld2_outpost.h"
+
+namespace TsAGE {
+
+namespace Ringworld2 {
+
+/*--------------------------------------------------------------------------
+ * Scene 1337 - Card game
+ *
+ *--------------------------------------------------------------------------*/
+
+Scene1337::Card::Card() {
+ _cardId = 0;
+ _stationPos = Common::Point(0, 0);
+}
+
+void Scene1337::Card::synchronize(Serializer &s) {
+ _card.synchronize(s);
+
+ s.syncAsSint16LE(_cardId);
+ s.syncAsSint16LE(_stationPos.x);
+ s.syncAsSint16LE(_stationPos.y);
+}
+
+bool Scene1337::Card::isIn(Common::Point pt) {
+ if ((_stationPos.x > pt.x) || (_stationPos.x + 24 < pt.x))
+ return false;
+
+ if ((_stationPos.y > pt.y) || (_stationPos.y + 24 < pt.y))
+ return false;
+
+ return true;
+}
+
+Scene1337::GameBoardSide::GameBoardSide() {
+ _card1Pos = Common::Point(0, 0);
+ _card2Pos = Common::Point(0, 0);
+ _card3Pos = Common::Point(0, 0);
+ _card4Pos = Common::Point(0, 0);
+ _frameNum = 0;
+}
+
+void Scene1337::GameBoardSide::synchronize(Serializer &s) {
+ SceneHotspot::synchronize(s);
+
+ for (int i = 0; i < 4; i++)
+ _handCard[i].synchronize(s);
+
+ for (int i = 0; i < 8; i++)
+ _outpostStation[i].synchronize(s);
+
+ _delayCard.synchronize(s);
+ _emptyStationPos.synchronize(s);
+
+ s.syncAsSint16LE(_card1Pos.x);
+ s.syncAsSint16LE(_card1Pos.y);
+ s.syncAsSint16LE(_card2Pos.x);
+ s.syncAsSint16LE(_card2Pos.y);
+ s.syncAsSint16LE(_card3Pos.x);
+ s.syncAsSint16LE(_card3Pos.y);
+ s.syncAsSint16LE(_card4Pos.x);
+ s.syncAsSint16LE(_card4Pos.y);
+ s.syncAsSint16LE(_frameNum);
+}
+
+Scene1337::Scene1337() {
+ _autoplay = false;
+ _cardsAvailableNumb = 0;
+ _currentDiscardIndex = 0;
+
+ for (int i = 0; i < 100; i++)
+ _availableCardsPile[i] = 0;
+
+ _shuffleEndedFl = false;
+ _currentPlayerNumb = 0;
+ _actionPlayerIdx = 0;
+ _actionVictimIdx = 0;
+ _showPlayerTurn = false;
+ _displayHelpFl = false;
+ _winnerId = -1;
+ _instructionsDisplayedFl = false;
+ _instructionsWaitCount = 0;
+
+ _delayedFunction = nullptr;
+ _actionCard1 = nullptr;
+ _actionCard2 = nullptr;
+ _actionCard3 = nullptr;
+
+ _cursorCurRes = 0;
+ _cursorCurStrip = 0;
+ _cursorCurFrame = 0;
+}
+
+void Scene1337::synchronize(Serializer &s) {
+ _actionCard1->synchronize(s);
+ _actionCard2->synchronize(s);
+ _actionCard3->synchronize(s);
+ _animatedCard.synchronize(s);
+ _shuffleAnimation.synchronize(s);
+ _discardedPlatformCard.synchronize(s);
+ _selectedCard.synchronize(s);
+ _discardPile.synchronize(s);
+ _stockCard.synchronize(s);
+ _aSound1.synchronize(s);
+ _aSound2.synchronize(s);
+ _helpIcon.synchronize(s);
+ _stockPile.synchronize(s);
+ _actionItem.synchronize(s);
+ _currentPlayerArrow.synchronize(s);
+
+ for (int i = 0; i < 4; i++)
+ _gameBoardSide[i].synchronize(s);
+
+ for (int i = 0; i < 8; i++) {
+ _upperDisplayCard[i].synchronize(s);
+ _lowerDisplayCard[i].synchronize(s);
+ }
+
+ // TODO s.syncPointer(_delayedFunction);
+ s.syncAsByte(_autoplay);
+ s.syncAsByte(_shuffleEndedFl);
+ s.syncAsByte(_showPlayerTurn);
+ s.syncAsByte(_displayHelpFl);
+ s.syncAsByte(_instructionsDisplayedFl);
+ s.syncAsSint16LE(_currentDiscardIndex);
+ s.syncAsSint16LE(_cardsAvailableNumb);
+ s.syncAsSint16LE(_currentPlayerNumb);
+ s.syncAsSint16LE(_actionPlayerIdx);
+ s.syncAsSint16LE(_actionVictimIdx);
+ s.syncAsSint16LE(_winnerId);
+ s.syncAsSint16LE(_instructionsWaitCount);
+ s.syncAsSint16LE(_cursorCurRes);
+ s.syncAsSint16LE(_cursorCurStrip);
+ s.syncAsSint16LE(_cursorCurFrame);
+
+ for (int i = 0; i < 100; i++)
+ s.syncAsSint16LE(_availableCardsPile[i]);
+
+}
+
+void Scene1337::Action1337::waitFrames(int32 frameCount) {
+ uint32 firstFrameNumber = g_globals->_events.getFrameNumber();
+ uint32 curFrame = firstFrameNumber;
+ uint32 destFrame = firstFrameNumber + frameCount;
+
+ while ((curFrame < destFrame) && !g_vm->shouldQuit()) {
+ TsAGE::Event event;
+ g_globals->_events.getEvent(event);
+ curFrame = g_globals->_events.getFrameNumber();
+ }
+
+ // CHECKME: The original is calling _eventManager.waitEvent();
+}
+
+/**
+ * Display instructions
+ */
+void Scene1337::Action1::signal() {
+ Scene1337 *scene = (Scene1337 *)R2_GLOBALS._sceneManager._scene;
+
+ switch (_actionIndex++) {
+ case 1: {
+ scene->actionDisplay(1331, 6, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+ R2_GLOBALS._sceneObjects->draw();
+ scene->actionDisplay(1331, 7, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+ scene->actionDisplay(1331, 8, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+
+ scene->_gameBoardSide[1]._outpostStation[0]._cardId = 2;
+ scene->_gameBoardSide[1]._outpostStation[0]._card.postInit();
+ scene->_gameBoardSide[1]._outpostStation[0]._card.setVisage(1332);
+ scene->_gameBoardSide[1]._outpostStation[0]._card.setPosition(scene->_gameBoardSide[1]._outpostStation[0]._stationPos, 0);
+ scene->_gameBoardSide[1]._outpostStation[0]._card.setStrip(2);
+ scene->_gameBoardSide[1]._outpostStation[0]._card.setFrame(scene->_gameBoardSide[1]._outpostStation[0]._cardId);
+ scene->_gameBoardSide[1]._outpostStation[0]._card.fixPriority(170);
+ scene->setAnimationInfo(&scene->_gameBoardSide[1]._outpostStation[0]);
+
+ scene->_gameBoardSide[1]._outpostStation[1]._cardId = 3;
+ scene->_gameBoardSide[1]._outpostStation[1]._card.postInit();
+ scene->_gameBoardSide[1]._outpostStation[1]._card.setVisage(1332);
+ scene->_gameBoardSide[1]._outpostStation[1]._card.setPosition(scene->_gameBoardSide[1]._outpostStation[1]._stationPos, 0);
+ scene->_gameBoardSide[1]._outpostStation[1]._card.setStrip(2);
+ scene->_gameBoardSide[1]._outpostStation[1]._card.setFrame(scene->_gameBoardSide[1]._outpostStation[1]._cardId);
+ scene->_gameBoardSide[1]._outpostStation[1]._card.fixPriority(170);
+ scene->setAnimationInfo(&scene->_gameBoardSide[1]._outpostStation[1]);
+
+ scene->_gameBoardSide[2]._outpostStation[0]._cardId = 4;
+ scene->_gameBoardSide[2]._outpostStation[0]._card.postInit();
+ scene->_gameBoardSide[2]._outpostStation[0]._card.setVisage(1332);
+ scene->_gameBoardSide[2]._outpostStation[0]._card.setPosition(scene->_gameBoardSide[2]._outpostStation[0]._stationPos, 0);
+ scene->_gameBoardSide[2]._outpostStation[0]._card.setStrip(2);
+ scene->_gameBoardSide[2]._outpostStation[0]._card.setFrame(scene->_gameBoardSide[2]._outpostStation[0]._cardId);
+ scene->setAnimationInfo(&scene->_gameBoardSide[2]._outpostStation[0]);
+
+ scene->_gameBoardSide[3]._outpostStation[0]._cardId = 5;
+ scene->_gameBoardSide[3]._outpostStation[0]._card.postInit();
+ scene->_gameBoardSide[3]._outpostStation[0]._card.setVisage(1332);
+ scene->_gameBoardSide[3]._outpostStation[0]._card.setPosition(scene->_gameBoardSide[3]._outpostStation[0]._stationPos, 0);
+ scene->_gameBoardSide[3]._outpostStation[0]._card.setStrip(2);
+ scene->_gameBoardSide[3]._outpostStation[0]._card.setFrame(scene->_gameBoardSide[3]._outpostStation[0]._cardId);
+ scene->_gameBoardSide[3]._outpostStation[0]._card.fixPriority(170);
+ scene->setAnimationInfo(&scene->_gameBoardSide[3]._outpostStation[0]);
+
+ scene->_gameBoardSide[3]._outpostStation[1]._cardId = 6;
+ scene->_gameBoardSide[3]._outpostStation[1]._card.postInit();
+ scene->_gameBoardSide[3]._outpostStation[1]._card.setVisage(1332);
+ scene->_gameBoardSide[3]._outpostStation[1]._card.setPosition(scene->_gameBoardSide[3]._outpostStation[1]._stationPos, 0);
+ scene->_gameBoardSide[3]._outpostStation[1]._card.setStrip(2);
+ scene->_gameBoardSide[3]._outpostStation[1]._card.setFrame(scene->_gameBoardSide[3]._outpostStation[1]._cardId);
+ scene->_gameBoardSide[3]._outpostStation[1]._card.fixPriority(170);
+ scene->setAnimationInfo(&scene->_gameBoardSide[3]._outpostStation[1]);
+
+ scene->_gameBoardSide[3]._outpostStation[2]._cardId = 7;
+ scene->_gameBoardSide[3]._outpostStation[2]._card.postInit();
+ scene->_gameBoardSide[3]._outpostStation[2]._card.setVisage(1332);
+ scene->_gameBoardSide[3]._outpostStation[2]._card.setPosition(scene->_gameBoardSide[3]._outpostStation[2]._stationPos, 0);
+ scene->_gameBoardSide[3]._outpostStation[2]._card.setStrip(2);
+ scene->_gameBoardSide[3]._outpostStation[2]._card.setFrame(scene->_gameBoardSide[3]._outpostStation[2]._cardId);
+ scene->_gameBoardSide[3]._outpostStation[2]._card.fixPriority(170);
+ scene->setAnimationInfo(&scene->_gameBoardSide[3]._outpostStation[2]);
+
+ scene->_gameBoardSide[0]._outpostStation[0]._cardId = 8;
+ scene->_gameBoardSide[0]._outpostStation[0]._card.postInit();
+ scene->_gameBoardSide[0]._outpostStation[0]._card.setVisage(1332);
+ scene->_gameBoardSide[0]._outpostStation[0]._card.setPosition(scene->_gameBoardSide[0]._outpostStation[0]._stationPos, 0);
+ scene->_gameBoardSide[0]._outpostStation[0]._card.setStrip(2);
+ scene->_gameBoardSide[0]._outpostStation[0]._card.setFrame(scene->_gameBoardSide[0]._outpostStation[0]._cardId);
+ scene->_gameBoardSide[0]._outpostStation[0]._card.fixPriority(170);
+ scene->setAnimationInfo(&scene->_gameBoardSide[0]._outpostStation[0]);
+
+ scene->_gameBoardSide[0]._outpostStation[1]._cardId = 9;
+ scene->_gameBoardSide[0]._outpostStation[1]._card.postInit();
+ scene->_gameBoardSide[0]._outpostStation[1]._card.setVisage(1332);
+ scene->_gameBoardSide[0]._outpostStation[1]._card.setPosition(scene->_gameBoardSide[0]._outpostStation[1]._stationPos, 0);
+ scene->_gameBoardSide[0]._outpostStation[1]._card.setStrip(2);
+ scene->_gameBoardSide[0]._outpostStation[1]._card.setFrame(scene->_gameBoardSide[0]._outpostStation[1]._cardId);
+ scene->_gameBoardSide[0]._outpostStation[1]._card.fixPriority(170);
+ scene->setAnimationInfo(&scene->_gameBoardSide[0]._outpostStation[1]);
+
+ R2_GLOBALS._sceneObjects->draw();
+
+ waitFrames(60);
+ scene->actionDisplay(1331, 9, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+
+ scene->_gameBoardSide[2]._outpostStation[1]._cardId = 2;
+ scene->_gameBoardSide[2]._outpostStation[1]._card.postInit();
+ scene->_gameBoardSide[2]._outpostStation[1]._card.setVisage(1332);
+ scene->_gameBoardSide[2]._outpostStation[1]._card.setPosition(scene->_gameBoardSide[2]._outpostStation[1]._stationPos, 0);
+ scene->_gameBoardSide[2]._outpostStation[1]._card.setStrip(2);
+ scene->_gameBoardSide[2]._outpostStation[1]._card.setFrame(scene->_gameBoardSide[2]._outpostStation[1]._cardId);
+ scene->_gameBoardSide[2]._outpostStation[1]._card.fixPriority(170);
+ scene->setAnimationInfo(&scene->_gameBoardSide[2]._outpostStation[1]);
+
+ scene->_gameBoardSide[2]._outpostStation[2]._cardId = 3;
+ scene->_gameBoardSide[2]._outpostStation[2]._card.postInit();
+ scene->_gameBoardSide[2]._outpostStation[2]._card.setVisage(1332);
+ scene->_gameBoardSide[2]._outpostStation[2]._card.setPosition(scene->_gameBoardSide[2]._outpostStation[2]._stationPos, 0);
+ scene->_gameBoardSide[2]._outpostStation[2]._card.setStrip(2);
+ scene->_gameBoardSide[2]._outpostStation[2]._card.setFrame(scene->_gameBoardSide[2]._outpostStation[2]._cardId);
+ scene->_gameBoardSide[2]._outpostStation[2]._card.fixPriority(170);
+ scene->setAnimationInfo(&scene->_gameBoardSide[2]._outpostStation[2]);
+
+ scene->_gameBoardSide[2]._outpostStation[3]._cardId = 5;
+ scene->_gameBoardSide[2]._outpostStation[3]._card.postInit();
+ scene->_gameBoardSide[2]._outpostStation[3]._card.setVisage(1332);
+ scene->_gameBoardSide[2]._outpostStation[3]._card.setPosition(scene->_gameBoardSide[2]._outpostStation[3]._stationPos, 0);
+ scene->_gameBoardSide[2]._outpostStation[3]._card.setStrip(2);
+ scene->_gameBoardSide[2]._outpostStation[3]._card.setFrame(scene->_gameBoardSide[2]._outpostStation[3]._cardId);
+ scene->_gameBoardSide[2]._outpostStation[3]._card.fixPriority(170);
+ scene->setAnimationInfo(&scene->_gameBoardSide[2]._outpostStation[3]);
+
+ scene->_gameBoardSide[2]._outpostStation[4]._cardId = 6;
+ scene->_gameBoardSide[2]._outpostStation[4]._card.postInit();
+ scene->_gameBoardSide[2]._outpostStation[4]._card.setVisage(1332);
+ scene->_gameBoardSide[2]._outpostStation[4]._card.setPosition(scene->_gameBoardSide[2]._outpostStation[4]._stationPos, 0);
+ scene->_gameBoardSide[2]._outpostStation[4]._card.setStrip(2);
+ scene->_gameBoardSide[2]._outpostStation[4]._card.setFrame(scene->_gameBoardSide[2]._outpostStation[4]._cardId);
+ scene->_gameBoardSide[2]._outpostStation[4]._card.fixPriority(170);
+ scene->setAnimationInfo(&scene->_gameBoardSide[2]._outpostStation[4]);
+
+ scene->_gameBoardSide[2]._outpostStation[5]._cardId = 7;
+ scene->_gameBoardSide[2]._outpostStation[5]._card.postInit();
+ scene->_gameBoardSide[2]._outpostStation[5]._card.setVisage(1332);
+ scene->_gameBoardSide[2]._outpostStation[5]._card.setPosition(scene->_gameBoardSide[2]._outpostStation[5]._stationPos, 0);
+ scene->_gameBoardSide[2]._outpostStation[5]._card.setStrip(2);
+ scene->_gameBoardSide[2]._outpostStation[5]._card.setFrame(scene->_gameBoardSide[2]._outpostStation[5]._cardId);
+ scene->_gameBoardSide[2]._outpostStation[5]._card.fixPriority(170);
+ scene->setAnimationInfo(&scene->_gameBoardSide[2]._outpostStation[5]);
+
+ scene->_gameBoardSide[2]._outpostStation[6]._cardId = 8;
+ scene->_gameBoardSide[2]._outpostStation[6]._card.postInit();
+ scene->_gameBoardSide[2]._outpostStation[6]._card.setVisage(1332);
+ scene->_gameBoardSide[2]._outpostStation[6]._card.setPosition(scene->_gameBoardSide[2]._outpostStation[6]._stationPos, 0);
+ scene->_gameBoardSide[2]._outpostStation[6]._card.setStrip(2);
+ scene->_gameBoardSide[2]._outpostStation[6]._card.setFrame(scene->_gameBoardSide[2]._outpostStation[6]._cardId);
+ scene->_gameBoardSide[2]._outpostStation[6]._card.fixPriority(170);
+ scene->setAnimationInfo(&scene->_gameBoardSide[2]._outpostStation[6]);
+
+ scene->_gameBoardSide[2]._outpostStation[7]._cardId = 9;
+ scene->_gameBoardSide[2]._outpostStation[7]._card.postInit();
+ scene->_gameBoardSide[2]._outpostStation[7]._card.setVisage(1332);
+ scene->_gameBoardSide[2]._outpostStation[7]._card.setPosition(scene->_gameBoardSide[2]._outpostStation[7]._stationPos, 0);
+ scene->_gameBoardSide[2]._outpostStation[7]._card.setStrip(2);
+ scene->_gameBoardSide[2]._outpostStation[7]._card.setFrame(scene->_gameBoardSide[2]._outpostStation[7]._cardId);
+ scene->_gameBoardSide[2]._outpostStation[7]._card.fixPriority(170);
+ scene->setAnimationInfo(&scene->_gameBoardSide[2]._outpostStation[7]);
+
+ scene->_aSound1.play(62);
+
+ R2_GLOBALS._sceneObjects->draw();
+
+ waitFrames(120);
+ scene->_gameBoardSide[2]._outpostStation[0]._card.remove();
+ scene->_gameBoardSide[2]._outpostStation[1]._card.remove();
+ scene->_gameBoardSide[2]._outpostStation[2]._card.remove();
+ scene->_gameBoardSide[2]._outpostStation[3]._card.remove();
+ scene->_gameBoardSide[2]._outpostStation[4]._card.remove();
+ scene->_gameBoardSide[2]._outpostStation[5]._card.remove();
+ scene->_gameBoardSide[2]._outpostStation[6]._card.remove();
+ scene->_gameBoardSide[2]._outpostStation[7]._card.remove();
+
+ scene->_gameBoardSide[1]._outpostStation[0]._card.remove();
+ scene->_gameBoardSide[1]._outpostStation[1]._card.remove();
+
+ scene->_gameBoardSide[3]._outpostStation[0]._card.remove();
+ scene->_gameBoardSide[3]._outpostStation[1]._card.remove();
+ scene->_gameBoardSide[3]._outpostStation[2]._card.remove();
+
+ scene->_gameBoardSide[0]._outpostStation[0]._card.remove();
+ scene->_gameBoardSide[0]._outpostStation[1]._card.remove();
+
+ scene->_stockPile.setup(1332, 5, 1);
+ scene->_stockPile.setPosition(Common::Point(162, 95));
+ scene->_stockPile.setPriority(110);
+ scene->_stockPile._effect = EFFECT_SHADED;
+ scene->_stockPile.show();
+
+ scene->_gameBoardSide[1]._handCard[0]._card.postInit();
+ scene->_gameBoardSide[1]._handCard[0]._card.setVisage(1332);
+ scene->_gameBoardSide[1]._handCard[0]._card.setPosition(scene->_gameBoardSide[1]._handCard[0]._stationPos, 0);
+ scene->_gameBoardSide[1]._handCard[0]._card.setStrip(1);
+ scene->_gameBoardSide[1]._handCard[0]._card.setFrame(4);
+ scene->_gameBoardSide[1]._handCard[0]._card.fixPriority(170);
+
+ scene->_gameBoardSide[1]._handCard[1]._card.postInit();
+ scene->_gameBoardSide[1]._handCard[1]._card.setVisage(1332);
+ scene->_gameBoardSide[1]._handCard[1]._card.setPosition(scene->_gameBoardSide[1]._handCard[1]._stationPos, 0);
+ scene->_gameBoardSide[1]._handCard[1]._card.setStrip(1);
+ scene->_gameBoardSide[1]._handCard[1]._card.setFrame(4);
+ scene->_gameBoardSide[1]._handCard[1]._card.fixPriority(170);
+
+ scene->_gameBoardSide[1]._handCard[2]._card.postInit();
+ scene->_gameBoardSide[1]._handCard[2]._card.setVisage(1332);
+ scene->_gameBoardSide[1]._handCard[2]._card.setPosition(scene->_gameBoardSide[1]._handCard[2]._stationPos, 0);
+ scene->_gameBoardSide[1]._handCard[2]._card.setStrip(1);
+ scene->_gameBoardSide[1]._handCard[2]._card.setFrame(4);
+ scene->_gameBoardSide[1]._handCard[2]._card.fixPriority(170);
+
+ scene->_gameBoardSide[2]._handCard[0]._cardId = 30;
+ scene->_gameBoardSide[2]._handCard[0]._card.postInit();
+ scene->_gameBoardSide[2]._handCard[0]._card.setVisage(1332);
+ scene->_gameBoardSide[2]._handCard[0]._card.setPosition(scene->_gameBoardSide[2]._handCard[0]._stationPos, 0);
+ scene->_gameBoardSide[2]._handCard[0]._card.setStrip(1);
+ scene->_gameBoardSide[2]._handCard[0]._card.setFrame(2);
+ scene->_gameBoardSide[2]._handCard[0]._card.fixPriority(170);
+ scene->setAnimationInfo(&scene->_gameBoardSide[2]._handCard[0]);
+
+ scene->_gameBoardSide[2]._handCard[1]._cardId = 16;
+ scene->_gameBoardSide[2]._handCard[1]._card.postInit();
+ scene->_gameBoardSide[2]._handCard[1]._card.setVisage(1332);
+ scene->_gameBoardSide[2]._handCard[1]._card.setPosition(scene->_gameBoardSide[2]._handCard[1]._stationPos, 0);
+ scene->_gameBoardSide[2]._handCard[1]._card.setStrip(1);
+ scene->_gameBoardSide[2]._handCard[1]._card.setFrame(2);
+ scene->_gameBoardSide[2]._handCard[1]._card.fixPriority(170);
+ scene->setAnimationInfo(&scene->_gameBoardSide[2]._handCard[1]);
+
+ scene->_gameBoardSide[2]._handCard[2]._cardId = 1;
+ scene->_gameBoardSide[2]._handCard[2]._card.postInit();
+ scene->_gameBoardSide[2]._handCard[2]._card.setVisage(1332);
+ scene->_gameBoardSide[2]._handCard[2]._card.setPosition(scene->_gameBoardSide[2]._handCard[2]._stationPos, 0);
+ scene->_gameBoardSide[2]._handCard[2]._card.setStrip(1);
+ scene->_gameBoardSide[2]._handCard[2]._card.setFrame(2);
+ scene->_gameBoardSide[2]._handCard[2]._card.fixPriority(170);
+ scene->setAnimationInfo(&scene->_gameBoardSide[2]._handCard[2]);
+
+ scene->_gameBoardSide[3]._handCard[0]._card.postInit();
+ scene->_gameBoardSide[3]._handCard[0]._card.setVisage(1332);
+ scene->_gameBoardSide[3]._handCard[0]._card.setPosition(scene->_gameBoardSide[3]._handCard[0]._stationPos, 0);
+ scene->_gameBoardSide[3]._handCard[0]._card.setStrip(1);
+ scene->_gameBoardSide[3]._handCard[0]._card.setFrame(3);
+ scene->_gameBoardSide[3]._handCard[0]._card.fixPriority(170);
+
+ scene->_gameBoardSide[3]._handCard[1]._card.postInit();
+ scene->_gameBoardSide[3]._handCard[1]._card.setVisage(1332);
+ scene->_gameBoardSide[3]._handCard[1]._card.setPosition(scene->_gameBoardSide[3]._handCard[1]._stationPos, 0);
+ scene->_gameBoardSide[3]._handCard[1]._card.setStrip(1);
+ scene->_gameBoardSide[3]._handCard[1]._card.setFrame(3);
+ scene->_gameBoardSide[3]._handCard[1]._card.fixPriority(170);
+
+ scene->_gameBoardSide[3]._handCard[2]._card.postInit();
+ scene->_gameBoardSide[3]._handCard[2]._card.setVisage(1332);
+ scene->_gameBoardSide[3]._handCard[2]._card.setPosition(scene->_gameBoardSide[3]._handCard[2]._stationPos, 0);
+ scene->_gameBoardSide[3]._handCard[2]._card.setStrip(1);
+ scene->_gameBoardSide[3]._handCard[2]._card.setFrame(3);
+ scene->_gameBoardSide[3]._handCard[2]._card.fixPriority(170);
+
+ scene->_gameBoardSide[0]._handCard[0]._card.postInit();
+ scene->_gameBoardSide[0]._handCard[0]._card.setVisage(1332);
+ scene->_gameBoardSide[0]._handCard[0]._card.setPosition(scene->_gameBoardSide[0]._handCard[0]._stationPos, 0);
+ scene->_gameBoardSide[0]._handCard[0]._card.setStrip(1);
+ scene->_gameBoardSide[0]._handCard[0]._card.setFrame(2);
+ scene->_gameBoardSide[0]._handCard[0]._card.fixPriority(170);
+
+ scene->_gameBoardSide[0]._handCard[1]._card.postInit();
+ scene->_gameBoardSide[0]._handCard[1]._card.setVisage(1332);
+ scene->_gameBoardSide[0]._handCard[1]._card.setPosition(scene->_gameBoardSide[0]._handCard[1]._stationPos, 0);
+ scene->_gameBoardSide[0]._handCard[1]._card.setStrip(1);
+ scene->_gameBoardSide[0]._handCard[1]._card.setFrame(2);
+ scene->_gameBoardSide[0]._handCard[1]._card.fixPriority(170);
+
+ scene->_gameBoardSide[0]._handCard[2]._card.postInit();
+ scene->_gameBoardSide[0]._handCard[2]._card.setVisage(1332);
+ scene->_gameBoardSide[0]._handCard[2]._card.setPosition(scene->_gameBoardSide[0]._handCard[2]._stationPos, 0);
+ scene->_gameBoardSide[0]._handCard[2]._card.setStrip(1);
+ scene->_gameBoardSide[0]._handCard[2]._card.setFrame(2);
+ scene->_gameBoardSide[0]._handCard[2]._card.fixPriority(170);
+
+ R2_GLOBALS._sceneObjects->draw();
+
+ scene->actionDisplay(1331, 10, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+ scene->_animatedCard._card.setPosition(Common::Point(162, 95), 0);
+ scene->_animatedCard._card.show();
+ scene->_aSound2.play(61);
+
+ Common::Point pt(91, 174);
+ NpcMover *mover = new NpcMover();
+ scene->_animatedCard._card.addMover(mover, &pt, this);
+ }
+ break;
+ case 2: {
+ scene->_gameBoardSide[2]._handCard[3]._cardId = 2;
+ scene->_gameBoardSide[2]._handCard[3]._card.postInit();
+ scene->_gameBoardSide[2]._handCard[3]._card.setVisage(1332);
+ scene->_gameBoardSide[2]._handCard[3]._card.setPosition(scene->_gameBoardSide[2]._handCard[3]._stationPos, 0);
+ scene->_gameBoardSide[2]._handCard[3]._card.setStrip(1);
+ scene->_gameBoardSide[2]._handCard[3]._card.setFrame(2);
+ scene->_gameBoardSide[2]._handCard[3]._card.fixPriority(170);
+
+ scene->_animatedCard._card.hide();
+ scene->setAnimationInfo(&scene->_gameBoardSide[2]._handCard[3]);
+
+ R2_GLOBALS._sceneObjects->draw();
+
+ waitFrames(60);
+ scene->actionDisplay(1331, 11, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+ scene->actionDisplay(1331, 12, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+
+ scene->_gameBoardSide[2]._outpostStation[1]._cardId = 1;
+ scene->_gameBoardSide[2]._outpostStation[1]._card.postInit();
+ scene->_gameBoardSide[2]._outpostStation[1]._card.setVisage(1332);
+ scene->_gameBoardSide[2]._outpostStation[1]._card.setPosition(scene->_gameBoardSide[2]._outpostStation[1]._stationPos, 0);
+ scene->_gameBoardSide[2]._outpostStation[1]._card.hide();
+
+ scene->_animatedCard._card.setStrip(scene->_gameBoardSide[2]._handCard[2]._card._strip);
+ scene->_animatedCard._card.setFrame(scene->_gameBoardSide[2]._handCard[2]._card._frame);
+ scene->_animatedCard._card.animate(ANIM_MODE_NONE, NULL);
+
+ scene->_gameBoardSide[2]._handCard[2]._cardId = 0;
+ scene->_gameBoardSide[2]._handCard[2]._card.remove();
+
+ scene->_animatedCard._card.setPosition(scene->_gameBoardSide[2]._handCard[2]._stationPos, 0);
+ scene->_animatedCard._card.show();
+
+ NpcMover *mover = new NpcMover();
+ scene->_animatedCard._card.addMover(mover, &scene->_gameBoardSide[2]._outpostStation[1]._stationPos, this);
+ }
+ break;
+ case 3: {
+ scene->_animatedCard._card.hide();
+ scene->setAnimationInfo(&scene->_gameBoardSide[2]._outpostStation[1]);
+ scene->_aSound1.play(59);
+
+ R2_GLOBALS._sceneObjects->draw();
+
+ waitFrames(60);
+ scene->actionDisplay(1331, 13, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+
+ scene->_gameBoardSide[2]._outpostStation[1]._cardId = scene->_gameBoardSide[2]._handCard[3]._cardId;
+
+ scene->_animatedCard._card.setStrip(scene->_gameBoardSide[2]._handCard[3]._card._strip);
+ scene->_animatedCard._card.setFrame(scene->_gameBoardSide[2]._handCard[3]._card._frame);
+
+ scene->_gameBoardSide[2]._handCard[3]._cardId = 0;
+ scene->_gameBoardSide[2]._handCard[3]._card.remove();
+
+ scene->_animatedCard._card.setPosition(scene->_gameBoardSide[2]._handCard[3]._stationPos, 0);
+ scene->_animatedCard._card.show();
+
+ NpcMover *mover = new NpcMover();
+ scene->_animatedCard._card.addMover(mover, &scene->_gameBoardSide[2]._outpostStation[1]._stationPos, this);
+ }
+ break;
+ case 4: {
+ scene->_animatedCard._card.hide();
+ scene->setAnimationInfo(&scene->_gameBoardSide[2]._outpostStation[1]);
+ scene->_aSound1.play(59);
+
+ scene->_discardPile._cardId = 1;
+ scene->_discardPile._card.hide();
+
+ scene->_animatedCard._card.setStrip(5);
+ scene->_animatedCard._card.setFrame(1);
+ scene->_animatedCard._card.animate(ANIM_MODE_2, NULL);
+ scene->_animatedCard._card.setPosition(scene->_gameBoardSide[2]._outpostStation[1]._stationPos, 0);
+ scene->_animatedCard._card.show();
+
+ NpcMover *mover = new NpcMover();
+ scene->_animatedCard._card.addMover(mover, &scene->_discardPile._stationPos, this);
+ }
+ break;
+ case 5: {
+ scene->_animatedCard._card.hide();
+
+ scene->_discardPile._card.postInit();
+ scene->_discardPile._card.setVisage(1332);
+ scene->_discardPile._card.setPosition(scene->_discardPile._stationPos, 0);
+ scene->setAnimationInfo(&scene->_discardPile);
+ scene->_aSound2.play(61);
+
+ R2_GLOBALS._sceneObjects->draw();
+
+ waitFrames(60);
+ scene->actionDisplay(1331, 14, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+
+ scene->_gameBoardSide[2]._delayCard._card.postInit();
+ scene->_gameBoardSide[2]._delayCard._card.setVisage(1332);
+ scene->_gameBoardSide[2]._delayCard._card.setPosition(scene->_gameBoardSide[2]._delayCard._stationPos, 0);
+ scene->_gameBoardSide[2]._delayCard._card.hide();
+
+ scene->_gameBoardSide[3]._handCard[2]._cardId = 0;
+ scene->_gameBoardSide[3]._handCard[2].remove();
+
+ scene->_animatedCard._card.setPosition(scene->_gameBoardSide[3]._handCard[2]._stationPos, 0);
+ scene->_animatedCard._card.show();
+
+ NpcMover *mover = new NpcMover();
+ scene->_animatedCard._card.addMover(mover, &scene->_gameBoardSide[2]._delayCard._stationPos, this);
+ }
+ break;
+ case 6: {
+ scene->_animatedCard._card.hide();
+ scene->_gameBoardSide[2]._delayCard._cardId = 21;
+ scene->setAnimationInfo(&scene->_gameBoardSide[2]._delayCard);
+ scene->_aSound1.play(57);
+
+ R2_GLOBALS._sceneObjects->draw();
+
+ waitFrames(60);
+ scene->actionDisplay(1331, 15, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+
+ int tmpVal = 15;
+ int i = -1;
+
+ for (i = 0; i <= 7; i++) {
+ tmpVal += 29;
+
+ scene->_upperDisplayCard[i].postInit();
+ scene->_upperDisplayCard[i].setVisage(1332);
+ scene->_upperDisplayCard[i].setPosition(Common::Point(tmpVal, 90), 0);
+ scene->_upperDisplayCard[i].setStrip(3);
+ scene->_upperDisplayCard[i].fixPriority(190);
+
+ scene->_lowerDisplayCard[i].postInit();
+ scene->_lowerDisplayCard[i].setVisage(1332);
+ scene->_lowerDisplayCard[i].setPosition(Common::Point(tmpVal, 90), 0);
+ scene->_lowerDisplayCard[i].setStrip(7);
+ scene->_lowerDisplayCard[i].setFrame(1);
+ scene->_lowerDisplayCard[i].fixPriority(180);
+ }
+
+ scene->_upperDisplayCard[0].setFrame(1);
+ scene->_upperDisplayCard[1].setFrame(3);
+ scene->_upperDisplayCard[2].setFrame(6);
+ scene->_upperDisplayCard[3].setFrame(8);
+ scene->_upperDisplayCard[4].setFrame(9);
+ scene->_upperDisplayCard[5].setFrame(10);
+ scene->_upperDisplayCard[6].setFrame(11);
+ scene->_upperDisplayCard[7].setFrame(12);
+
+ R2_GLOBALS._sceneObjects->draw();
+
+ waitFrames(240);
+
+ scene->_upperDisplayCard[0].remove();
+ scene->_upperDisplayCard[1].remove();
+ scene->_upperDisplayCard[2].remove();
+ scene->_upperDisplayCard[3].remove();
+ scene->_upperDisplayCard[4].remove();
+ scene->_upperDisplayCard[5].remove();
+ scene->_upperDisplayCard[6].remove();
+ scene->_upperDisplayCard[7].remove();
+
+ scene->_lowerDisplayCard[0].remove();
+ scene->_lowerDisplayCard[1].remove();
+ scene->_lowerDisplayCard[2].remove();
+ scene->_lowerDisplayCard[3].remove();
+ scene->_lowerDisplayCard[4].remove();
+ scene->_lowerDisplayCard[5].remove();
+ scene->_lowerDisplayCard[6].remove();
+ scene->_lowerDisplayCard[7].remove();
+
+ scene->_discardPile._cardId = scene->_gameBoardSide[2]._delayCard._cardId;
+
+ scene->_gameBoardSide[2]._delayCard._cardId = 0;
+ scene->_gameBoardSide[2]._delayCard._card.remove();
+
+ scene->_animatedCard._card.setPosition(scene->_gameBoardSide[2]._delayCard._stationPos, 0);
+ scene->_animatedCard._card.show();
+
+ NpcMover *mover = new NpcMover();
+ scene->_animatedCard._card.addMover(mover, &scene->_discardPile._stationPos, this);
+ }
+ break;
+ case 7: {
+ scene->_animatedCard._card.hide();
+ scene->setAnimationInfo(&scene->_discardPile);
+ scene->_aSound2.play(61);
+
+ R2_GLOBALS._sceneObjects->draw();
+
+ scene->_gameBoardSide[2]._delayCard._card.postInit();
+ scene->_gameBoardSide[2]._delayCard._card.setVisage(1332);
+ scene->_gameBoardSide[2]._delayCard._card.setPosition(scene->_gameBoardSide[2]._delayCard._stationPos, 0);
+ scene->_gameBoardSide[2]._delayCard._card.hide();
+
+ scene->_gameBoardSide[3]._handCard[1]._cardId = 0;
+ scene->_gameBoardSide[3]._handCard[1].remove();
+
+ scene->_animatedCard._card.setPosition(scene->_gameBoardSide[3]._handCard[1]._stationPos, 0);
+ scene->_animatedCard._card.show();
+
+ NpcMover *mover = new NpcMover();
+ scene->_animatedCard._card.addMover(mover, &scene->_gameBoardSide[2]._delayCard._stationPos, this);
+ }
+ break;
+ case 8: {
+ scene->_animatedCard._card.hide();
+ scene->_gameBoardSide[2]._delayCard._cardId = 14;
+ scene->setAnimationInfo(&scene->_gameBoardSide[2]._delayCard);
+ scene->_aSound1.play(57);
+
+ R2_GLOBALS._sceneObjects->draw();
+
+ scene->actionDisplay(1331, 16, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+ int tmpVal = 72;
+ int i = -1;
+
+ for (i = 0; i <= 3; i++) {
+ tmpVal += 29;
+ scene->_upperDisplayCard[i].postInit();
+ scene->_upperDisplayCard[i].setVisage(1332);
+ scene->_upperDisplayCard[i].setPosition(Common::Point(tmpVal, 71), 0);
+ scene->_upperDisplayCard[i].setStrip(3);
+ scene->_upperDisplayCard[i].fixPriority(190);
+
+ scene->_lowerDisplayCard[i].postInit();
+ scene->_lowerDisplayCard[i].setVisage(1332);
+ scene->_lowerDisplayCard[i].setPosition(Common::Point(tmpVal, 71), 0);
+ scene->_lowerDisplayCard[i].setStrip(7);
+ scene->_lowerDisplayCard[i].setFrame(1);
+ scene->_lowerDisplayCard[i].fixPriority(180);
+ }
+
+ scene->_upperDisplayCard[0].setFrame(2);
+ scene->_upperDisplayCard[1].setFrame(5);
+ scene->_upperDisplayCard[2].setFrame(7);
+ scene->_upperDisplayCard[3].setFrame(15);
+
+ R2_GLOBALS._sceneObjects->draw();
+
+ waitFrames(240);
+ scene->actionDisplay(1331, 17, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+
+ tmpVal = 72;
+ for (i = 4; i <= 7; i++) {
+ tmpVal += 29;
+
+ scene->_upperDisplayCard[i].postInit();
+ scene->_upperDisplayCard[i].setVisage(1332);
+ scene->_upperDisplayCard[i].setPosition(Common::Point(tmpVal, 100), 0);
+ scene->_upperDisplayCard[i].setStrip(4);
+ scene->_upperDisplayCard[i].fixPriority(190);
+
+ scene->_lowerDisplayCard[i].postInit();
+ scene->_lowerDisplayCard[i].setVisage(1332);
+ scene->_lowerDisplayCard[i].setPosition(Common::Point(tmpVal, 100), 0);
+ scene->_lowerDisplayCard[i].setStrip(7);
+ scene->_lowerDisplayCard[i].setFrame(1);
+ scene->_lowerDisplayCard[i].fixPriority(180);
+ }
+
+ scene->_upperDisplayCard[4].setFrame(1);
+ scene->_upperDisplayCard[5].setFrame(5);
+ scene->_upperDisplayCard[6].setFrame(7);
+ scene->_upperDisplayCard[7].setFrame(3);
+
+ R2_GLOBALS._sceneObjects->draw();
+
+ waitFrames(240);
+
+ scene->_upperDisplayCard[0].remove();
+ scene->_upperDisplayCard[1].remove();
+ scene->_upperDisplayCard[2].remove();
+ scene->_upperDisplayCard[3].remove();
+ scene->_upperDisplayCard[4].remove();
+ scene->_upperDisplayCard[5].remove();
+ scene->_upperDisplayCard[6].remove();
+ scene->_upperDisplayCard[7].remove();
+
+ scene->_lowerDisplayCard[0].remove();
+ scene->_lowerDisplayCard[1].remove();
+ scene->_lowerDisplayCard[2].remove();
+ scene->_lowerDisplayCard[3].remove();
+ scene->_lowerDisplayCard[4].remove();
+ scene->_lowerDisplayCard[5].remove();
+ scene->_lowerDisplayCard[6].remove();
+ scene->_lowerDisplayCard[7].remove();
+
+ scene->_discardPile._cardId = scene->_gameBoardSide[2]._handCard[0]._cardId;
+
+ scene->_animatedCard._card.setStrip(scene->_gameBoardSide[2]._handCard[0]._card._strip);
+ scene->_animatedCard._card.setFrame(scene->_gameBoardSide[2]._handCard[0]._card._frame);
+ scene->_animatedCard._card.animate(ANIM_MODE_NONE, NULL);
+
+ scene->_gameBoardSide[2]._handCard[0]._cardId = 0;
+ scene->_gameBoardSide[2]._handCard[0]._card.remove();
+
+ scene->_animatedCard._card.setPosition(scene->_gameBoardSide[2]._handCard[0]._stationPos, 0);
+ scene->_animatedCard._card.show();
+
+ NpcMover *mover = new NpcMover();
+ scene->_animatedCard._card.addMover(mover, &scene->_gameBoardSide[2]._delayCard._stationPos, this);
+ }
+ break;
+ case 9: {
+ scene->_aSound1.play(58);
+ scene->_gameBoardSide[2]._delayCard._cardId = 0;
+ scene->_gameBoardSide[2]._delayCard.remove();
+ scene->_animatedCard._card.setStrip(5);
+ scene->_animatedCard._card.setFrame(1);
+ scene->_animatedCard._card.animate(ANIM_MODE_2, NULL);
+ scene->_animatedCard._card.setPosition(scene->_gameBoardSide[2]._delayCard._stationPos, 0);
+ scene->_animatedCard._card.show();
+
+ NpcMover *mover = new NpcMover();
+ scene->_animatedCard._card.addMover(mover, &scene->_discardPile._stationPos, this);
+ }
+ break;
+ case 10: {
+ scene->_animatedCard._card.hide();
+ scene->setAnimationInfo(&scene->_discardPile);
+ scene->_aSound2.play(61);
+
+ R2_GLOBALS._sceneObjects->draw();
+ scene->actionDisplay(1331, 18, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+
+ scene->_upperDisplayCard[0].postInit();
+ scene->_upperDisplayCard[0].setVisage(1332);
+ scene->_upperDisplayCard[0].setPosition(Common::Point(131, 71), 0);
+ scene->_upperDisplayCard[0].fixPriority(190);
+ scene->_upperDisplayCard[0].setStrip(3);
+ scene->_upperDisplayCard[0].setFrame(4);
+
+ scene->_lowerDisplayCard[0].postInit();
+ scene->_lowerDisplayCard[0].setVisage(1332);
+ scene->_lowerDisplayCard[0].setPosition(Common::Point(131, 71), 0);
+ scene->_lowerDisplayCard[0].setStrip(7);
+ scene->_lowerDisplayCard[0].setFrame(1);
+ scene->_lowerDisplayCard[0].fixPriority(180);
+
+ scene->_upperDisplayCard[1].postInit();
+ scene->_upperDisplayCard[1].setVisage(1332);
+ scene->_upperDisplayCard[1].setPosition(Common::Point(160, 71), 0);
+ scene->_upperDisplayCard[1].fixPriority(190);
+ scene->_upperDisplayCard[1].setStrip(3);
+ scene->_upperDisplayCard[1].setFrame(16);
+
+ scene->_lowerDisplayCard[1].postInit();
+ scene->_lowerDisplayCard[1].setVisage(1332);
+ scene->_lowerDisplayCard[1].setPosition(Common::Point(160, 71), 0);
+ scene->_lowerDisplayCard[1].setStrip(7);
+ scene->_lowerDisplayCard[1].setFrame(1);
+ scene->_lowerDisplayCard[1].fixPriority(180);
+
+ scene->_upperDisplayCard[2].postInit();
+ scene->_upperDisplayCard[2].setVisage(1332);
+ scene->_upperDisplayCard[2].setPosition(Common::Point(131, 100), 0);
+ scene->_upperDisplayCard[2].fixPriority(190);
+ scene->_upperDisplayCard[2].setStrip(4);
+ scene->_upperDisplayCard[2].setFrame(4);
+
+ scene->_lowerDisplayCard[2].postInit();
+ scene->_lowerDisplayCard[2].setVisage(1332);
+ scene->_lowerDisplayCard[2].setPosition(Common::Point(131, 100), 0);
+ scene->_lowerDisplayCard[2].setStrip(7);
+ scene->_lowerDisplayCard[2].setFrame(1);
+ scene->_lowerDisplayCard[2].fixPriority(180);
+
+ scene->_upperDisplayCard[3].postInit();
+ scene->_upperDisplayCard[3].setVisage(1332);
+ scene->_upperDisplayCard[3].setPosition(Common::Point(160, 100), 0);
+ scene->_upperDisplayCard[3].fixPriority(190);
+ scene->_upperDisplayCard[3].setStrip(4);
+ scene->_upperDisplayCard[3].setFrame(2);
+
+ scene->_lowerDisplayCard[3].postInit();
+ scene->_lowerDisplayCard[3].setVisage(1332);
+ scene->_lowerDisplayCard[3].setPosition(Common::Point(160, 100), 0);
+ scene->_lowerDisplayCard[3].setStrip(7);
+ scene->_lowerDisplayCard[3].setFrame(1);
+ scene->_lowerDisplayCard[3].fixPriority(180);
+
+ R2_GLOBALS._sceneObjects->draw();
+
+ waitFrames(240);
+
+ scene->_upperDisplayCard[0].remove();
+ scene->_upperDisplayCard[1].remove();
+ scene->_upperDisplayCard[2].remove();
+ scene->_upperDisplayCard[3].remove();
+
+ scene->_lowerDisplayCard[0].remove();
+ scene->_lowerDisplayCard[1].remove();
+ scene->_lowerDisplayCard[2].remove();
+ scene->_lowerDisplayCard[3].remove();
+
+ scene->_currentPlayerArrow.setFrame(1);
+ scene->_currentPlayerArrow.show();
+ scene->_currentPlayerArrow.animate(ANIM_MODE_2, NULL);
+
+ R2_GLOBALS._sceneObjects->draw();
+
+ scene->actionDisplay(1331, 19, 159, 10, 1, 220, 0, 7, 0, 154, 154);
+
+ scene->_currentPlayerArrow.hide();
+
+ scene->actionDisplay(1331, 20, 159, 10, 1, 220, 0, 7, 0, 154, 154);
+ scene->actionDisplay(1331, 21, 159, 10, 1, 220, 0, 7, 0, 154, 154);
+
+ scene->_discardPile._cardId = scene->_gameBoardSide[2]._handCard[1]._cardId;
+
+ scene->_animatedCard._card.setStrip(scene->_gameBoardSide[2]._handCard[1]._card._strip);
+ scene->_animatedCard._card.setFrame(scene->_gameBoardSide[2]._handCard[1]._card._frame);
+ scene->_animatedCard._card.animate(ANIM_MODE_NONE, NULL);
+
+ scene->_gameBoardSide[2]._handCard[1]._cardId = 0;
+ scene->_gameBoardSide[2]._handCard[1]._card.remove();
+
+ scene->_animatedCard._card.setPosition(scene->_gameBoardSide[2]._handCard[1]._stationPos, 0);
+ scene->_animatedCard._card.show();
+
+ NpcMover *mover = new NpcMover();
+ scene->_animatedCard._card.addMover(mover, &scene->_discardPile._stationPos, this);
+ }
+ break;
+ case 11: {
+ scene->_animatedCard._card.hide();
+ scene->setAnimationInfo(&scene->_discardPile);
+ scene->_aSound2.play(61);
+ scene->_animatedCard._card.setStrip(5);
+ scene->_animatedCard._card.setFrame(1);
+ scene->_animatedCard._card.animate(ANIM_MODE_2, NULL);
+
+ R2_GLOBALS._sceneObjects->draw();
+
+ scene->actionDisplay(1331, 22, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+
+ int i = -1;
+ for (i = 0; i <= 3; i ++) {
+ scene->_gameBoardSide[3]._handCard[i]._cardId = 0;
+ scene->_gameBoardSide[3]._handCard[i]._card.remove();
+
+ scene->_gameBoardSide[2]._handCard[i]._cardId = 0;
+ scene->_gameBoardSide[2]._handCard[i]._card.remove();
+
+ scene->_gameBoardSide[0]._handCard[i]._cardId = 0;
+ scene->_gameBoardSide[0]._handCard[i]._card.remove();
+
+ scene->_gameBoardSide[1]._handCard[i]._cardId = 0;
+ scene->_gameBoardSide[1]._handCard[i]._card.remove();
+ }
+
+ for (i = 0; i <= 7; i++) {
+ scene->_gameBoardSide[3]._outpostStation[i]._cardId = 0;
+ scene->_gameBoardSide[3]._outpostStation[i]._card.remove();
+
+ scene->_gameBoardSide[2]._outpostStation[i]._cardId = 0;
+ scene->_gameBoardSide[2]._outpostStation[i]._card.remove();
+
+ scene->_gameBoardSide[0]._outpostStation[i]._cardId = 0;
+ scene->_gameBoardSide[0]._outpostStation[i]._card.remove();
+
+ scene->_gameBoardSide[1]._outpostStation[i]._cardId = 0;
+ scene->_gameBoardSide[1]._outpostStation[i]._card.remove();
+ }
+
+ scene->_gameBoardSide[2]._delayCard._cardId = 0;
+ scene->_gameBoardSide[2]._delayCard._card.remove();
+
+ scene->_discardPile._cardId = 0;
+ scene->_discardPile._card.remove();
+
+ scene->_stockPile.remove();
+ }
+ // No break on purpose
+ case 0:
+ R2_GLOBALS._sceneObjects->draw();
+ signal();
+ break;
+ case 12:
+ scene->suggestInstructions();
+ remove();
+ break;
+ default:
+ break;
+ }
+}
+
+/**
+ * Shuffle cards animation
+ */
+void Scene1337::Action2::signal() {
+ Scene1337 *scene = (Scene1337 *)R2_GLOBALS._sceneManager._scene;
+
+ switch (_actionIndex++) {
+ case 0:
+ scene->_shuffleAnimation._card.postInit();
+ scene->_shuffleAnimation._card.setVisage(1332);
+ scene->_shuffleAnimation._card.setStrip(8);
+ scene->_shuffleAnimation._card.setFrame(1);
+ scene->_shuffleAnimation._card.fixPriority(300);
+ scene->_shuffleAnimation._card.setPosition(Common::Point(156, 108));
+
+ scene->_discardPile._card.remove();
+ scene->_discardPile._cardId = 0;
+
+ scene->_aSound1.play(60);
+ scene->_shuffleAnimation._card.animate(ANIM_MODE_5, this);
+ break;
+ case 1:
+ scene->_shuffleAnimation._card.setFrame(1);
+
+ scene->_aSound1.play(60);
+ scene->_shuffleAnimation._card.animate(ANIM_MODE_5, this);
+ break;
+ case 2: {
+ Common::Point pt(156, 108);
+ NpcMover *mover = new NpcMover();
+ scene->_shuffleAnimation._card.addMover(mover, &pt, this);
+ }
+ break;
+ case 3:
+ scene->_shuffleAnimation._card.remove();
+ scene->_stockPile.setup(1332, 5, 1);
+ scene->_stockPile.setPosition(Common::Point(162, 95));
+ scene->_stockPile.setPriority(110);
+ scene->_stockPile._effect = EFFECT_SHADED;
+ scene->_stockPile.show();
+ scene->_shuffleEndedFl = true;
+ break;
+ default:
+ break;
+ }
+}
+
+/**
+ * Deal cards
+ */
+void Scene1337::Action3::signal() {
+ Scene1337 *scene = (Scene1337 *)R2_GLOBALS._sceneManager._scene;
+
+ scene->_animatedCard._card.setPosition(Common::Point(162, 95), 0);
+
+ switch (_actionIndex++) {
+ case 0: {
+ scene->_animatedCard._card._moveDiff = Common::Point(30, 30);
+ scene->_animatedCard._card.setVisage(1332);
+ scene->_animatedCard._card.setStrip(5);
+ scene->_animatedCard._card.setFrame(1);
+ scene->_animatedCard._card.fixPriority(400);
+ scene->_animatedCard._card.animate(ANIM_MODE_2, NULL);
+ scene->_aSound2.play(61);
+
+ Common::Point pt(283, 146);
+ NpcMover *mover = new NpcMover();
+ scene->_animatedCard._card.addMover(mover, &pt, this);
+
+ scene->_animatedCard._card.show();
+ scene->_gameBoardSide[1]._handCard[0]._cardId = scene->_availableCardsPile[scene->_cardsAvailableNumb];
+ }
+ break;
+ case 1: {
+ scene->_gameBoardSide[1]._handCard[0]._card.postInit();
+ scene->_gameBoardSide[1]._handCard[0]._card._moveDiff = Common::Point(30, 30);
+ scene->_gameBoardSide[1]._handCard[0]._card.setVisage(1332);
+ scene->_gameBoardSide[1]._handCard[0]._card.setPosition(scene->_gameBoardSide[1]._handCard[0]._stationPos, 0);
+ scene->_gameBoardSide[1]._handCard[0]._card.setStrip(1);
+ scene->_gameBoardSide[1]._handCard[0]._card.setFrame(4);
+ scene->_gameBoardSide[1]._handCard[0]._card.fixPriority(170);
+ scene->_aSound2.play(61);
+
+ Common::Point pt(10, 174);
+ NpcMover *mover = new NpcMover();
+ scene->_animatedCard._card.addMover(mover, &pt, this);
+
+ scene->_gameBoardSide[2]._handCard[0]._cardId = scene->_availableCardsPile[scene->_cardsAvailableNumb];
+ }
+ break;
+ case 2: {
+ scene->_gameBoardSide[2]._handCard[0]._card.postInit();
+ scene->_gameBoardSide[2]._handCard[0]._card._moveDiff = Common::Point(30, 30);
+ scene->_gameBoardSide[2]._handCard[0]._card.setVisage(1332);
+ scene->_gameBoardSide[2]._handCard[0]._card.setPosition(scene->_gameBoardSide[2]._handCard[0]._stationPos, 0);
+ scene->_gameBoardSide[2]._handCard[0]._card.fixPriority(170);
+ if (scene->_gameBoardSide[2]._handCard[0]._cardId > 25) {
+ scene->_gameBoardSide[2]._handCard[0]._card.setStrip(4);
+ scene->_gameBoardSide[2]._handCard[0]._card.setFrame(scene->_gameBoardSide[2]._handCard[0]._cardId - 25);
+ } else if (scene->_gameBoardSide[2]._handCard[0]._cardId > 9) {
+ scene->_gameBoardSide[2]._handCard[0]._card.setStrip(3);
+ scene->_gameBoardSide[2]._handCard[0]._card.setFrame(scene->_gameBoardSide[2]._handCard[0]._cardId - 9);
+ } else {
+ scene->_gameBoardSide[2]._handCard[0]._card.setStrip(2);
+ scene->_gameBoardSide[2]._handCard[0]._card.setFrame(scene->_gameBoardSide[2]._handCard[0]._cardId);
+ }
+ scene->_aSound2.play(61);
+
+ Common::Point pt(14, 14);
+ NpcMover *mover = new NpcMover();
+ scene->_animatedCard._card.addMover(mover, &pt, this);
+
+ scene->_gameBoardSide[3]._handCard[0]._cardId = scene->_availableCardsPile[scene->_cardsAvailableNumb];
+ }
+ break;
+ case 3: {
+ scene->_gameBoardSide[3]._handCard[0]._card.postInit();
+ scene->_gameBoardSide[3]._handCard[0]._card._moveDiff = Common::Point(30, 30);
+ scene->_gameBoardSide[3]._handCard[0]._card.setVisage(1332);
+ scene->_gameBoardSide[3]._handCard[0]._card.setPosition(scene->_gameBoardSide[3]._handCard[0]._stationPos, 0);
+ scene->_gameBoardSide[3]._handCard[0]._card.setStrip(1);
+ scene->_gameBoardSide[3]._handCard[0]._card.setFrame(3);
+ scene->_gameBoardSide[3]._handCard[0]._card.fixPriority(170);
+ scene->_aSound2.play(61);
+
+ Common::Point pt(280, 5);
+ NpcMover *mover = new NpcMover();
+ scene->_animatedCard._card.addMover(mover, &pt, this);
+
+ scene->_gameBoardSide[0]._handCard[0]._cardId = scene->_availableCardsPile[scene->_cardsAvailableNumb];
+ }
+ break;
+ case 4: {
+ scene->_gameBoardSide[0]._handCard[0]._card.postInit();
+ scene->_gameBoardSide[0]._handCard[0]._card._moveDiff = Common::Point(30,30);
+ scene->_gameBoardSide[0]._handCard[0]._card.setVisage(1332);
+ scene->_gameBoardSide[0]._handCard[0]._card.setPosition(scene->_gameBoardSide[0]._handCard[0]._stationPos, 0);
+ scene->_gameBoardSide[0]._handCard[0]._card.setStrip(5);
+ scene->_gameBoardSide[0]._handCard[0]._card.setFrame(1);
+ scene->_gameBoardSide[0]._handCard[0]._card.fixPriority(170);
+ scene->_aSound2.play(61);
+
+ Common::Point pt(283, 124);
+ NpcMover *mover = new NpcMover();
+ scene->_animatedCard._card.addMover(mover, &pt, this);
+
+ scene->_gameBoardSide[1]._handCard[1]._cardId = scene->_availableCardsPile[scene->_cardsAvailableNumb];
+ }
+ break;
+ case 5: {
+ scene->_gameBoardSide[1]._handCard[1]._card.postInit();
+ scene->_gameBoardSide[1]._handCard[1]._card._moveDiff = Common::Point(30, 30);
+ scene->_gameBoardSide[1]._handCard[1]._card.setVisage(1332);
+ scene->_gameBoardSide[1]._handCard[1]._card.setPosition(scene->_gameBoardSide[1]._handCard[1]._stationPos, 0);
+ scene->_gameBoardSide[1]._handCard[1]._card.setStrip(1);
+ scene->_gameBoardSide[1]._handCard[1]._card.setFrame(4);
+ scene->_gameBoardSide[1]._handCard[1]._card.fixPriority(170);
+ scene->_aSound2.play(61);
+
+ Common::Point pt(37, 174);
+ NpcMover *mover = new NpcMover();
+ scene->_animatedCard._card.addMover(mover, &pt, this);
+
+ scene->_gameBoardSide[2]._handCard[1]._cardId = scene->_availableCardsPile[scene->_cardsAvailableNumb];
+ }
+ break;
+ case 6: {
+ scene->_gameBoardSide[2]._handCard[1]._card.postInit();
+ scene->_gameBoardSide[2]._handCard[1]._card._moveDiff = Common::Point(30, 30);
+ scene->_gameBoardSide[2]._handCard[1]._card.setVisage(1332);
+ scene->_gameBoardSide[2]._handCard[1]._card.setPosition(scene->_gameBoardSide[2]._handCard[1]._stationPos, 0);
+ scene->_gameBoardSide[2]._handCard[1]._card.fixPriority(170);
+
+ if (scene->_gameBoardSide[2]._handCard[1]._cardId > 25) {
+ scene->_gameBoardSide[2]._handCard[1]._card.setStrip(4);
+ scene->_gameBoardSide[2]._handCard[1]._card.setFrame(scene->_gameBoardSide[2]._handCard[1]._cardId - 25);
+ } else if (scene->_gameBoardSide[2]._handCard[1]._cardId > 9) {
+ scene->_gameBoardSide[2]._handCard[1]._card.setStrip(3);
+ scene->_gameBoardSide[2]._handCard[1]._card.setFrame(scene->_gameBoardSide[2]._handCard[1]._cardId - 9);
+ } else {
+ scene->_gameBoardSide[2]._handCard[1]._card.setStrip(2);
+ scene->_gameBoardSide[2]._handCard[1]._card.setFrame(scene->_gameBoardSide[2]._handCard[1]._cardId);
+ }
+
+ scene->_aSound2.play(61);
+
+ Common::Point pt(14, 36);
+ NpcMover *mover = new NpcMover();
+ scene->_animatedCard._card.addMover(mover, &pt, this);
+
+ scene->_gameBoardSide[3]._handCard[1]._cardId = scene->_availableCardsPile[scene->_cardsAvailableNumb];
+ }
+ break;
+ case 7: {
+ scene->_gameBoardSide[3]._handCard[1]._card.postInit();
+ scene->_gameBoardSide[3]._handCard[1]._card._moveDiff = Common::Point(30, 30);
+ scene->_gameBoardSide[3]._handCard[1]._card.setVisage(1332);
+ scene->_gameBoardSide[3]._handCard[1]._card.setPosition(scene->_gameBoardSide[3]._handCard[1]._stationPos);
+ scene->_gameBoardSide[3]._handCard[1]._card.setStrip(1);
+ scene->_gameBoardSide[3]._handCard[1]._card.setFrame(3);
+ scene->_gameBoardSide[3]._handCard[1]._card.fixPriority(170);
+ scene->_aSound2.play(61);
+
+ Common::Point pt(253, 5);
+ NpcMover *mover = new NpcMover();
+ scene->_animatedCard._card.addMover(mover, &pt, this);
+
+ scene->_gameBoardSide[0]._handCard[1]._cardId = scene->_availableCardsPile[scene->_cardsAvailableNumb];
+ }
+ break;
+ case 8: {
+ scene->_gameBoardSide[0]._handCard[1]._card.postInit();
+ scene->_gameBoardSide[0]._handCard[1]._card._moveDiff = Common::Point(30, 30);
+ scene->_gameBoardSide[0]._handCard[1]._card.setVisage(1332);
+ scene->_gameBoardSide[0]._handCard[1]._card.setPosition(scene->_gameBoardSide[0]._handCard[1]._stationPos, 0);
+ scene->_gameBoardSide[0]._handCard[1]._card.setStrip(5);
+ scene->_gameBoardSide[0]._handCard[1]._card.setFrame(1);
+ scene->_gameBoardSide[0]._handCard[1]._card.fixPriority(170);
+ scene->_aSound2.play(61);
+
+ Common::Point pt(283, 102);
+ NpcMover *mover = new NpcMover();
+ scene->_animatedCard._card.addMover(mover, &pt, this);
+
+ scene->_gameBoardSide[1]._handCard[2]._cardId = scene->_availableCardsPile[scene->_cardsAvailableNumb];
+ }
+ break;
+ case 9: {
+ scene->_gameBoardSide[1]._handCard[2]._card.postInit();
+ scene->_gameBoardSide[1]._handCard[2]._card._moveDiff = Common::Point(30, 30);
+ scene->_gameBoardSide[1]._handCard[2]._card.setVisage(1332);
+ scene->_gameBoardSide[1]._handCard[2]._card.setPosition(scene->_gameBoardSide[1]._handCard[2]._stationPos, 0);
+ scene->_gameBoardSide[1]._handCard[2]._card.setStrip(1);
+ scene->_gameBoardSide[1]._handCard[2]._card.setFrame(4);
+ scene->_gameBoardSide[1]._handCard[2]._card.fixPriority(170);
+ scene->_aSound2.play(61);
+
+ Common::Point pt(64, 174);
+ NpcMover *mover = new NpcMover();
+ scene->_animatedCard._card.addMover(mover, &pt, this);
+
+ scene->_gameBoardSide[2]._handCard[2]._cardId = scene->_availableCardsPile[scene->_cardsAvailableNumb];
+ }
+ break;
+ case 10: {
+ scene->_gameBoardSide[2]._handCard[2]._card.postInit();
+ scene->_gameBoardSide[2]._handCard[2]._card._moveDiff = Common::Point(30, 30);
+ scene->_gameBoardSide[2]._handCard[2]._card.setVisage(1332);
+ scene->_gameBoardSide[2]._handCard[2]._card.setPosition(scene->_gameBoardSide[2]._handCard[2]._stationPos, 0);
+ scene->_gameBoardSide[2]._handCard[2]._card.fixPriority(170);
+
+ if (scene->_gameBoardSide[2]._handCard[2]._cardId > 25) {
+ scene->_gameBoardSide[2]._handCard[2]._card.setStrip(4);
+ scene->_gameBoardSide[2]._handCard[2]._card.setFrame(scene->_gameBoardSide[2]._handCard[2]._cardId - 25);
+ } else if (scene->_gameBoardSide[2]._handCard[2]._cardId > 9) {
+ scene->_gameBoardSide[2]._handCard[2]._card.setStrip(3);
+ scene->_gameBoardSide[2]._handCard[2]._card.setFrame(scene->_gameBoardSide[2]._handCard[2]._cardId - 9);
+ } else {
+ scene->_gameBoardSide[2]._handCard[2]._card.setStrip(2);
+ scene->_gameBoardSide[2]._handCard[2]._card.setFrame(scene->_gameBoardSide[2]._handCard[2]._cardId);
+ }
+
+ scene->_aSound2.play(61);
+
+ Common::Point pt(14, 58);
+ NpcMover *mover = new NpcMover();
+ scene->_animatedCard._card.addMover(mover, &pt, this);
+
+ scene->_gameBoardSide[3]._handCard[2]._cardId = scene->_availableCardsPile[scene->_cardsAvailableNumb];
+ }
+ break;
+ case 11: {
+ scene->_gameBoardSide[3]._handCard[2]._card.postInit();
+ scene->_gameBoardSide[3]._handCard[2]._card._moveDiff = Common::Point(30, 30);
+ scene->_gameBoardSide[3]._handCard[2]._card.setVisage(1332);
+ scene->_gameBoardSide[3]._handCard[2]._card.setPosition(scene->_gameBoardSide[3]._handCard[2]._stationPos, 0);
+ scene->_gameBoardSide[3]._handCard[2]._card.setStrip(1);
+ scene->_gameBoardSide[3]._handCard[2]._card.setFrame(3);
+ scene->_gameBoardSide[3]._handCard[2]._card.fixPriority(170);
+ scene->_aSound2.play(61);
+
+ Common::Point pt(226, 5);
+ NpcMover *mover = new NpcMover();
+ scene->_animatedCard._card.addMover(mover, &pt, this);
+
+ scene->_gameBoardSide[0]._handCard[2]._cardId = scene->_availableCardsPile[scene->_cardsAvailableNumb];
+ }
+ break;
+ case 12:
+ scene->_gameBoardSide[0]._handCard[2]._card.postInit();
+ scene->_gameBoardSide[0]._handCard[2]._card._moveDiff = Common::Point(30, 30);
+ scene->_gameBoardSide[0]._handCard[2]._card.setVisage(1332);
+ scene->_gameBoardSide[0]._handCard[2]._card.setPosition(scene->_gameBoardSide[0]._handCard[2]._stationPos, 0);
+ scene->_gameBoardSide[0]._handCard[2]._card.setStrip(5);
+ scene->_gameBoardSide[0]._handCard[2]._card.setFrame(1);
+ scene->_gameBoardSide[0]._handCard[2]._card.fixPriority(170);
+ scene->_animatedCard._card.hide();
+ default:
+ break;
+ }
+
+ if (_actionIndex > 12) {
+ scene->_currentPlayerNumb = 0;
+ R2_GLOBALS._sceneObjects->draw();
+ scene->actionDisplay(1330, 0, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+ scene->handleNextTurn();
+ } else if (_actionIndex >= 1) {
+ scene->_availableCardsPile[scene->_cardsAvailableNumb] = 0;
+ scene->_cardsAvailableNumb--;
+ }
+}
+
+/**
+ * Action used to handle the other players' turn
+ */
+void Scene1337::Action4::signal() {
+ Scene1337 *scene = (Scene1337 *)R2_GLOBALS._sceneManager._scene;
+
+ switch (_actionIndex++) {
+ case 0:
+ if ( (scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[0]._cardId == 0)
+ && (!scene->isStationCard(scene->_gameBoardSide[scene->_currentPlayerNumb]._delayCard._cardId))) {
+ if (scene->_cardsAvailableNumb < 0)
+ scene->shuffleCards();
+ scene->_animatedCard._card.setPosition(Common::Point(162, 95), 0);
+ scene->_animatedCard._card.show();
+ scene->_aSound2.play(61);
+
+ NpcMover *mover = new NpcMover();
+ scene->_animatedCard._card.addMover(mover, &scene->_gameBoardSide[scene->_currentPlayerNumb]._card1Pos, this);
+
+ scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[0]._cardId = scene->_availableCardsPile[scene->_cardsAvailableNumb];
+ scene->_availableCardsPile[scene->_cardsAvailableNumb] = 0;
+ scene->_cardsAvailableNumb--;
+
+ if (scene->_cardsAvailableNumb < 0)
+ scene->_stockPile.remove();
+ } else {
+ // Self call, forcing next actionIndex
+ signal();
+ }
+ break;
+ case 1:
+ if ( (scene->_animatedCard._card._position.x == scene->_gameBoardSide[scene->_currentPlayerNumb]._card1Pos.x)
+ && (scene->_animatedCard._card._position.y == scene->_gameBoardSide[scene->_currentPlayerNumb]._card1Pos.y) ) {
+ scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[0]._card.postInit();
+ scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[0]._card._moveDiff = Common::Point(30, 30);
+ scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[0]._card.setVisage(1332);
+ scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[0]._card.setPosition(scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[0]._stationPos, 0);
+ scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[0]._card.setStrip(1);
+ scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[0]._card.setFrame(scene->_gameBoardSide[scene->_currentPlayerNumb]._frameNum);
+ scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[0]._card.fixPriority(170);
+ }
+
+ if ((R2_GLOBALS._debugCardGame) || (scene->_currentPlayerNumb == 2))
+ scene->setAnimationInfo(&scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[0]);
+
+ scene->_animatedCard._card.hide();
+ if ( (scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[1]._cardId == 0)
+ && (!scene->isStationCard(scene->_gameBoardSide[scene->_currentPlayerNumb]._delayCard._cardId))) {
+ if (scene->_cardsAvailableNumb < 0)
+ scene->shuffleCards();
+ scene->_animatedCard._card.setPosition(Common::Point(162, 95));
+ scene->_animatedCard._card.show();
+
+ scene->_aSound2.play(61);
+
+ NpcMover *mover = new NpcMover();
+ scene->_animatedCard._card.addMover(mover, &scene->_gameBoardSide[scene->_currentPlayerNumb]._card2Pos, this);
+
+ scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[1]._cardId = scene->_availableCardsPile[scene->_cardsAvailableNumb];
+ scene->_availableCardsPile[scene->_cardsAvailableNumb] = 0;
+ scene->_cardsAvailableNumb--;
+ if (scene->_cardsAvailableNumb < 0)
+ scene->_stockPile.remove();
+ } else
+ signal();
+ break;
+ case 2:
+ if ( (scene->_animatedCard._card._position.x == scene->_gameBoardSide[scene->_currentPlayerNumb]._card2Pos.x)
+ && (scene->_animatedCard._card._position.y == scene->_gameBoardSide[scene->_currentPlayerNumb]._card2Pos.y) ) {
+ scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[1]._card.postInit();
+ scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[1]._card._moveDiff = Common::Point(30, 30);
+ scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[1]._card.setVisage(1332);
+ scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[1]._card.setPosition(scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[1]._stationPos, 0);
+ scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[1]._card.setStrip(1);
+ scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[1]._card.setFrame(scene->_gameBoardSide[scene->_currentPlayerNumb]._frameNum);
+ scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[1]._card.fixPriority(170);
+ }
+
+ if ((R2_GLOBALS._debugCardGame) || (scene->_currentPlayerNumb == 2))
+ scene->setAnimationInfo(&scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[1]);
+
+ scene->_animatedCard._card.hide();
+ if ( (scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[2]._cardId == 0)
+ && (!scene->isStationCard(scene->_gameBoardSide[scene->_currentPlayerNumb]._delayCard._cardId))) {
+ if (scene->_cardsAvailableNumb < 0)
+ scene->shuffleCards();
+ scene->_animatedCard._card.setPosition(Common::Point(162, 95));
+ scene->_animatedCard._card.show();
+
+ scene->_aSound2.play(61);
+
+ NpcMover *mover = new NpcMover();
+ scene->_animatedCard._card.addMover(mover, &scene->_gameBoardSide[scene->_currentPlayerNumb]._card3Pos, this);
+
+ scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[2]._cardId = scene->_availableCardsPile[scene->_cardsAvailableNumb];
+ scene->_availableCardsPile[scene->_cardsAvailableNumb] = 0;
+ scene->_cardsAvailableNumb--;
+ if (scene->_cardsAvailableNumb < 0)
+ scene->_stockPile.remove();
+ } else
+ signal();
+ break;
+ case 3:
+ if ( (scene->_animatedCard._card._position.x == scene->_gameBoardSide[scene->_currentPlayerNumb]._card3Pos.x)
+ && (scene->_animatedCard._card._position.y == scene->_gameBoardSide[scene->_currentPlayerNumb]._card3Pos.y) ) {
+ scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[2]._card.postInit();
+ scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[2]._card._moveDiff = Common::Point(30, 30);
+ scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[2]._card.setVisage(1332);
+ scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[2]._card.setPosition(scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[2]._stationPos, 0);
+ scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[2]._card.setStrip(1);
+ scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[2]._card.setFrame(scene->_gameBoardSide[scene->_currentPlayerNumb]._frameNum);
+ scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[2]._card.fixPriority(170);
+ }
+
+ if ((R2_GLOBALS._debugCardGame) || (scene->_currentPlayerNumb == 2))
+ scene->setAnimationInfo(&scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[2]);
+
+ scene->_animatedCard._card.hide();
+ if ( (scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[3]._cardId == 0)
+ && (!scene->isStationCard(scene->_gameBoardSide[scene->_currentPlayerNumb]._delayCard._cardId))) {
+ if (scene->_cardsAvailableNumb < 0)
+ scene->shuffleCards();
+ scene->_animatedCard._card.setPosition(Common::Point(162, 95));
+ scene->_animatedCard._card.show();
+
+ scene->_aSound2.play(61);
+
+ NpcMover *mover = new NpcMover();
+ scene->_animatedCard._card.addMover(mover, &scene->_gameBoardSide[scene->_currentPlayerNumb]._card4Pos, this);
+
+ scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[3]._cardId = scene->_availableCardsPile[scene->_cardsAvailableNumb];
+ scene->_availableCardsPile[scene->_cardsAvailableNumb] = 0;
+ scene->_cardsAvailableNumb--;
+ if (scene->_cardsAvailableNumb < 0)
+ scene->_stockPile.remove();
+ } else
+ signal();
+ break;
+ case 4:
+ if ( (scene->_animatedCard._card._position.x == scene->_gameBoardSide[scene->_currentPlayerNumb]._card4Pos.x)
+ && (scene->_animatedCard._card._position.y == scene->_gameBoardSide[scene->_currentPlayerNumb]._card4Pos.y) ) {
+ scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[3]._card.postInit();
+ scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[3]._card._moveDiff = Common::Point(30, 30);
+ scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[3]._card.setVisage(1332);
+ scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[3]._card.setPosition(scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[3]._stationPos, 0);
+ scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[3]._card.setStrip(1);
+ scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[3]._card.setFrame(scene->_gameBoardSide[scene->_currentPlayerNumb]._frameNum);
+ scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[3]._card.fixPriority(170);
+ }
+
+ if ((R2_GLOBALS._debugCardGame) || (scene->_currentPlayerNumb == 2))
+ scene->setAnimationInfo(&scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[3]);
+
+ scene->_animatedCard._card.hide();
+ switch (scene->_currentPlayerNumb) {
+ case 0:
+ scene->handlePlayer0();
+ break;
+ case 1:
+ scene->handlePlayer1();
+ break;
+ case 2:
+ scene->handleAutoplayPlayer2();
+ break;
+ case 3:
+ scene->handlePlayer3();
+ break;
+ default:
+ break;
+ }
+ break;
+ default:
+ break;
+ }
+}
+
+/**
+ * Animations for discarding a card
+ */
+void Scene1337::Action5::signal() {
+ Scene1337 *scene = (Scene1337 *)R2_GLOBALS._sceneManager._scene;
+
+ switch (_actionIndex++) {
+ case 0: {
+ scene->_availableCardsPile[scene->_currentDiscardIndex] = scene->_actionCard1->_cardId;
+ scene->_currentDiscardIndex--;
+ if (!g_globals->_sceneObjects->contains(&scene->_discardPile._card)) {
+ // The first discarded card makes the pile appear
+ scene->_discardPile._card.postInit();
+ scene->_discardPile._card.hide();
+ scene->_discardPile._card.setVisage(1332);
+ scene->_discardPile._card.setPosition(scene->_discardPile._stationPos, 0);
+ scene->_discardPile._card.fixPriority(170);
+ }
+
+ scene->_discardPile._cardId = scene->_actionCard1->_cardId;
+ scene->_actionCard1->_cardId = 0;
+ scene->_actionCard1->_card.remove();
+
+ if (scene->_actionCard1 == &scene->_selectedCard) {
+ scene->setCursorData(5, 1, 4);
+ scene->subC4CEC();
+ }
+ scene->_animatedCard._card.setPosition(scene->_actionCard1->_stationPos, 0);
+ scene->_animatedCard._card.show();
+ Common::Point pt(128, 95);
+ NpcMover *mover = new NpcMover();
+ scene->_animatedCard._card.addMover(mover, &pt, this);
+ }
+ break;
+ case 1:
+ scene->_animatedCard._card.hide();
+ scene->setAnimationInfo(&scene->_discardPile);
+ scene->_aSound2.play(61);
+ scene->handleNextTurn();
+ break;
+ default:
+ break;
+ }
+}
+
+/**
+ * Animations for playing a platform card
+ */
+void Scene1337::Action6::signal() {
+ Scene1337 *scene = (Scene1337 *)R2_GLOBALS._sceneManager._scene;
+
+ switch (_actionIndex++) {
+ case 0: {
+ scene->_actionCard2->_cardId = 1;
+ scene->_actionCard2->_card.postInit();
+ scene->_actionCard2->_card.hide();
+ scene->_actionCard2->_card.setVisage(1332);
+ scene->_actionCard2->_card.setPosition(scene->_actionCard2->_stationPos);
+ scene->_actionCard2->_card.fixPriority(170);
+
+ scene->_actionCard1->_cardId = 0;
+ scene->_actionCard1->_card.remove();
+
+ scene->_animatedCard._card.setPosition(scene->_actionCard1->_stationPos);
+ scene->_animatedCard._card.show();
+
+ NpcMover *mover = new NpcMover();
+ scene->_animatedCard._card.addMover(mover, &scene->_actionCard2->_stationPos, this);
+ }
+ break;
+ case 1:
+ scene->_animatedCard._card.hide();
+ scene->setAnimationInfo(scene->_actionCard2);
+ scene->_aSound1.play(59);
+ if (scene->_actionCard1 == &scene->_selectedCard) {
+ scene->setCursorData(5, 1, 4);
+ scene->subC4CEC();
+ }
+ scene->handleNextTurn();
+ break;
+ default:
+ break;
+ }
+}
+
+/**
+ * Upgrade platform to station by playing a station card on top of it
+ */
+void Scene1337::Action7::signal() {
+ Scene1337 *scene = (Scene1337 *)R2_GLOBALS._sceneManager._scene;
+
+ switch (_actionIndex++) {
+ case 0: {
+ scene->_actionCard2->_cardId = scene->_actionCard1->_cardId;
+
+ scene->_actionCard1->_cardId = 0;
+ scene->_actionCard1->_card.remove();
+
+ scene->_animatedCard._card.setPosition(scene->_actionCard1->_stationPos, 0);
+ scene->_animatedCard._card.show();
+ NpcMover *mover = new NpcMover();
+ scene->_animatedCard._card.addMover(mover, &scene->_actionCard2->_stationPos, this);
+ }
+ break;
+ case 1:
+ if (scene->_actionCard1 == &scene->_selectedCard) {
+ scene->setCursorData(5, 1, 4);
+ scene->subC4CEC();
+ }
+ scene->setAnimationInfo(scene->_actionCard2);
+ scene->_aSound1.play(59);
+ scene->_discardedPlatformCard._cardId = 1;
+ scene->_discardedPlatformCard._stationPos = scene->_actionCard2->_stationPos;
+ scene->_discardedPlatformCard._card.postInit();
+ scene->_discardedPlatformCard._card.hide();
+ scene->_discardedPlatformCard._card._flags = OBJFLAG_HIDING;
+
+ scene->discardCard(&scene->_discardedPlatformCard);
+ break;
+ default:
+ break;
+ }
+}
+
+// Remove a delay card
+void Scene1337::Action8::signal() {
+ Scene1337 *scene = (Scene1337 *)R2_GLOBALS._sceneManager._scene;
+
+ switch (_actionIndex++) {
+ case 0: {
+ scene->_availableCardsPile[scene->_currentDiscardIndex] = scene->_actionCard2->_cardId;
+ scene->_currentDiscardIndex--;
+
+ scene->_actionCard2->_cardId = scene->_actionCard1->_cardId;
+ scene->_actionCard1->_card.remove();
+
+ scene->_animatedCard._card.setPosition(scene->_actionCard1->_stationPos, 0);
+ scene->_animatedCard._card.show();
+
+ NpcMover *mover = new NpcMover();
+ scene->_animatedCard._card.addMover(mover, &scene->_actionCard2->_stationPos, this);
+ }
+ break;
+ case 1:
+ scene->_animatedCard._card.hide();
+
+ if (scene->_actionCard1 == &scene->_selectedCard) {
+ scene->setCursorData(5, 1, 4);
+ scene->subC4CEC();
+ }
+ scene->setAnimationInfo(scene->_actionCard2);
+ scene->_aSound1.play(58);
+ scene->discardCard(scene->_actionCard2);
+ break;
+ default:
+ break;
+ }
+}
+
+// Play delay card
+void Scene1337::Action9::signal() {
+ Scene1337 *scene = (Scene1337 *)R2_GLOBALS._sceneManager._scene;
+
+ switch (_actionIndex++) {
+ case 0: {
+ scene->_actionCard2->_cardId = scene->_actionCard1->_cardId;
+ scene->_actionCard2->_card.postInit();
+ scene->_actionCard2->_card.hide();
+ scene->_actionCard2->_card.setVisage(1332);
+ scene->_actionCard2->_card.setPosition(scene->_actionCard2->_stationPos, 0);
+ scene->_actionCard2->_card.fixPriority(170);
+
+ scene->_actionCard1->_cardId = 0;
+ scene->_actionCard1->_card.remove();
+
+ scene->_animatedCard._card.setPosition(scene->_actionCard1->_stationPos, 0);
+ scene->_animatedCard._card.show();
+
+ NpcMover *mover = new NpcMover();
+ scene->_animatedCard._card.addMover(mover, &scene->_actionCard2->_stationPos, this);
+ }
+ break;
+ case 1:
+ scene->_animatedCard._card.hide();
+ scene->setAnimationInfo(scene->_actionCard2);
+ scene->_aSound1.play(57);
+
+ if (scene->_actionCard1 == &scene->_selectedCard) {
+ scene->setCursorData(5, 1, 4);
+ scene->subC4CEC();
+ }
+
+ scene->handleNextTurn();
+ break;
+ default:
+ break;
+ }
+}
+
+// Play a card on the central outpost.
+// This card is either a counter-trick card or a meteor card
+void Scene1337::Action10::signal() {
+ Scene1337 *scene = (Scene1337 *)R2_GLOBALS._sceneManager._scene;
+
+ switch (_actionIndex++) {
+ case 0: {
+ scene->_actionCard3->_card.postInit();
+ scene->_actionCard3->_card.hide();
+ scene->_actionCard3->_card.setVisage(1332);
+ scene->_actionCard3->_card.setPosition(scene->_actionCard3->_stationPos, 0);
+ scene->_actionCard3->_card.fixPriority(170);
+ scene->_actionCard3->_cardId = scene->_actionCard1->_cardId;
+
+ scene->_actionCard1->_cardId = 0;
+ scene->_actionCard1->_card.remove();
+
+ if (scene->_actionCard1 == &scene->_selectedCard) {
+ scene->setCursorData(5, 1, 4);
+ scene->subC4CEC();
+ }
+
+ scene->_animatedCard._card.setPosition(scene->_actionCard1->_stationPos, 0);
+ scene->_animatedCard._card.show();
+ NpcMover *mover = new NpcMover();
+ scene->_animatedCard._card.addMover(mover, &scene->_actionCard3->_stationPos, this);
+ }
+ break;
+ case 1: {
+ scene->_animatedCard._card.hide();
+ scene->setAnimationInfo(scene->_actionCard3);
+ scene->_aSound1.play(57);
+
+ bool found = false;
+ int indexFound = -1;
+
+ switch (scene->_actionPlayerIdx) {
+ case 0:
+ for (indexFound = 0; indexFound < 3; indexFound++) {
+ // Check for the presence of an interceptor card
+ if (scene->_gameBoardSide[0]._handCard[indexFound]._cardId == 29) {
+ found = true;
+ break;
+ }
+ }
+ break;
+ case 1:
+ for (indexFound = 0; indexFound < 3; indexFound++) {
+ // Check for the presence of an interceptor card
+ if (scene->_gameBoardSide[1]._handCard[indexFound]._cardId == 29) {
+ found = true;
+ break;
+ }
+ }
+ break;
+ case 2:
+ for (indexFound = 0; indexFound < 3; indexFound++) {
+ // Check for the presence of an interceptor card
+ if (scene->_gameBoardSide[2]._handCard[indexFound]._cardId == 29) {
+ found = true;
+ break;
+ }
+ }
+ break;
+ case 3:
+ for (indexFound = 0; indexFound < 3; indexFound++) {
+ // Check for the presence of an interceptor card
+ if (scene->_gameBoardSide[3]._handCard[indexFound]._cardId == 29) {
+ found = true;
+ break;
+ }
+ }
+ break;
+ default:
+ break;
+ }
+
+ bool found2 = false;
+
+ if (found) {
+ switch (scene->_actionPlayerIdx) {
+ case 0:
+ scene->playInterceptorCard(&scene->_gameBoardSide[0]._handCard[indexFound], scene->_actionCard3);
+ found2 = true;
+ break;
+ case 1:
+ scene->playInterceptorCard(&scene->_gameBoardSide[1]._handCard[indexFound], scene->_actionCard3);
+ found2 = true;
+ break;
+ case 2:
+ scene->subC4CD2();
+ if (MessageDialog::show(USE_INTERCEPTOR, NO_MSG, YES_MSG) == 0)
+ scene->subC4CEC();
+ else {
+ scene->playInterceptorCard(&scene->_gameBoardSide[2]._handCard[indexFound], scene->_actionCard3);
+ found2 = true;
+ }
+ break;
+ case 3:
+ scene->playInterceptorCard(&scene->_gameBoardSide[3]._handCard[indexFound], scene->_actionCard3);
+ found2 = true;
+ break;
+ default:
+ break;
+ }
+ }
+
+ if (found2)
+ break;
+
+ if (scene->_actionPlayerIdx == 2) {
+ int stationCount = 0;
+ for (int i = 0; i <= 7; i++) {
+ if (scene->_gameBoardSide[2]._outpostStation[i]._cardId != 0)
+ ++stationCount;
+ }
+
+ if (stationCount <= 1) {
+ for (int i = 0; i <= 7; i++) {
+ if (scene->_gameBoardSide[2]._outpostStation[i]._cardId != 0) {
+ scene->_actionCard2 = &scene->_gameBoardSide[2]._outpostStation[i];
+ break;
+ }
+ }
+ } else {
+ scene->subC4CD2();
+
+ found2 = false;
+ while (!found2) {
+ scene->actionDisplay(1330, 130, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+
+ // Wait for a mouse or keypress
+ Event event;
+ while (!g_globals->_events.getEvent(event, EVENT_BUTTON_DOWN | EVENT_KEYPRESS) && !g_vm->shouldQuit()) {
+ g_globals->_scenePalette.signalListeners();
+ R2_GLOBALS._sceneObjects->draw();
+ g_globals->_events.delay(g_globals->_sceneHandler->_delayTicks);
+ }
+
+ scene->_selectedCard._stationPos = event.mousePos;
+
+ for (int i = 0; i <= 7; i++) {
+ if (scene->_gameBoardSide[2]._outpostStation[i].isIn(scene->_selectedCard._stationPos) && (scene->_gameBoardSide[2]._outpostStation[i]._cardId != 0)) {
+ scene->_actionCard2 = &scene->_gameBoardSide[2]._outpostStation[i];
+ found2 = true;
+ break;
+ }
+ }
+ }
+ scene->subC4CEC();
+ }
+ }
+
+ scene->_availableCardsPile[scene->_currentDiscardIndex] = scene->_actionCard2->_cardId;
+ scene->_currentDiscardIndex--;
+ scene->_actionCard2->_cardId = 0;
+ scene->_actionCard2->_card.remove();
+
+ scene->_animatedCard._card.setPosition(scene->_actionCard2->_stationPos, 0);
+ scene->_animatedCard._card.show();
+
+ NpcMover *mover = new NpcMover();
+ scene->_animatedCard._card.addMover(mover, &scene->_actionCard3->_stationPos, this);
+ }
+ break;
+ case 2:
+ scene->_animatedCard._card.hide();
+ scene->discardCard(scene->_actionCard3);
+ break;
+ default:
+ break;
+ }
+}
+
+// Use Thief card (#25) and pick a card from the opponent
+void Scene1337::Action11::signal() {
+ Scene1337 *scene = (Scene1337 *)R2_GLOBALS._sceneManager._scene;
+
+ switch (_actionIndex++) {
+ case 0: {
+ scene->_actionCard2->_card.postInit();
+ scene->_actionCard2->_card.hide();
+ scene->_actionCard2->_card.setVisage(1332);
+ scene->_actionCard2->_card.setPosition(scene->_actionCard2->_stationPos, 0);
+ scene->_actionCard2->_card.fixPriority(170);
+ scene->_actionCard2->_cardId = 25;
+
+ if (scene->_actionPlayerIdx == 2) {
+ scene->_animatedCard._card.setPosition(scene->_actionCard2->_stationPos, 0);
+ scene->setCursorData(5, 1, 4);
+ } else {
+ scene->_actionCard1->_cardId = 0;
+ scene->_actionCard1->_card.remove();
+ scene->_animatedCard._card.setPosition(scene->_actionCard1->_stationPos, 0);
+ }
+ scene->_animatedCard._card.show();
+
+ NpcMover *mover = new NpcMover();
+ scene->_animatedCard._card.addMover(mover, &scene->_actionCard2->_stationPos, this);
+ }
+ break;
+ case 1: {
+ scene->_animatedCard._card.hide();
+ scene->setAnimationInfo(scene->_actionCard2);
+ scene->_aSound1.play(57);
+
+ bool found = false;
+ bool noAction = true;
+
+ int i = -1;
+
+ switch (scene->_actionVictimIdx) {
+ case 0:
+ for (i = 0; i <= 3; i++) {
+ if (scene->_gameBoardSide[0]._handCard[i]._cardId == 27) {
+ found = true;
+ break;
+ }
+ }
+
+ if ((found) && (scene->getRandomCardFromHand(scene->_actionPlayerIdx) != -1)) {
+ scene->_actionCard1 = &scene->_gameBoardSide[0]._handCard[i];
+ scene->_actionCard2 = &scene->_gameBoardSide[0]._emptyStationPos;
+ if (scene->_actionPlayerIdx != 0) {
+ int tmpVal = scene->getRandomCardFromHand(scene->_actionPlayerIdx);
+ scene->_actionCard3 = &scene->_gameBoardSide[scene->_actionPlayerIdx]._handCard[tmpVal];
+ }
+ scene->_actionItem.setAction(&scene->_action12);
+ noAction = false;
+ }
+ break;
+ case 1:
+ for (i = 0; i <= 3; i++) {
+ if (scene->_gameBoardSide[1]._handCard[i]._cardId == 27) {
+ found = true;
+ break;
+ }
+ }
+
+ if ((found) && (scene->getRandomCardFromHand(scene->_actionPlayerIdx) != -1)) {
+ scene->_actionCard1 = &scene->_gameBoardSide[1]._handCard[i];
+ scene->_actionCard2 = &scene->_gameBoardSide[1]._emptyStationPos;
+ if (scene->_actionPlayerIdx != 1) {
+ int tmpVal = scene->getRandomCardFromHand(scene->_actionPlayerIdx);
+ scene->_actionCard3 = &scene->_gameBoardSide[scene->_actionPlayerIdx]._handCard[tmpVal];
+ }
+ scene->_actionItem.setAction(&scene->_action12);
+ noAction = false;
+ }
+ break;
+ case 2:
+ for (i = 0; i <= 3; i++) {
+ if (scene->_gameBoardSide[2]._handCard[i]._cardId == 27) {
+ found = true;
+ break;
+ }
+ }
+
+ if ((found) && (scene->getRandomCardFromHand(scene->_actionPlayerIdx) != -1)) {
+ scene->subC4CD2();
+ if (MessageDialog::show(USE_DOUBLE_AGENT, NO_MSG, YES_MSG) == 0)
+ scene->subC4CEC();
+ else {
+ scene->subC4CEC();
+ scene->_actionCard1 = &scene->_gameBoardSide[2]._handCard[i];
+ scene->_actionCard2 = &scene->_gameBoardSide[2]._emptyStationPos;
+ if (scene->_actionPlayerIdx != 2) {
+ int tmpVal = scene->getRandomCardFromHand(scene->_actionPlayerIdx);
+ scene->_actionCard3 = &scene->_gameBoardSide[scene->_actionPlayerIdx]._handCard[tmpVal];
+ }
+ scene->_actionItem.setAction(&scene->_action12);
+ noAction = false;
+ }
+ }
+ break;
+ case 3:
+ for (i = 0; i <= 3; i++) {
+ if (scene->_gameBoardSide[3]._handCard[i]._cardId == 27) {
+ found = true;
+ break;
+ }
+ }
+
+ if ((found) && (scene->getRandomCardFromHand(scene->_actionPlayerIdx) != -1)) {
+ scene->_actionCard1 = &scene->_gameBoardSide[3]._handCard[i];
+ scene->_actionCard2 = &scene->_gameBoardSide[3]._emptyStationPos;
+ if (scene->_actionPlayerIdx != 3) {
+ int tmpVal = scene->getRandomCardFromHand(scene->_actionPlayerIdx);
+ scene->_actionCard3 = &scene->_gameBoardSide[scene->_actionPlayerIdx]._handCard[tmpVal];
+ }
+ scene->_actionItem.setAction(&scene->_action12);
+ noAction = false;
+ }
+ break;
+ default:
+ break;
+ }
+
+ if (!noAction)
+ break;
+
+ if (scene->_actionPlayerIdx == 2) {
+ int count = 0;
+ if (scene->_actionVictimIdx != 2) {
+ for (i = 0; i <= 3; i++) {
+ if (scene->_gameBoardSide[scene->_actionVictimIdx]._handCard[i]._cardId != 0)
+ ++count;
+ }
+ }
+
+ if (count > 1) {
+ scene->subC4CD2();
+
+ found = false;
+ while (!found) {
+ switch (scene->_actionVictimIdx) {
+ case 0:
+ scene->actionDisplay(1330, 131, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+ break;
+ case 1:
+ scene->actionDisplay(1330, 132, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+ break;
+ case 3:
+ scene->actionDisplay(1330, 133, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+ break;
+ default:
+ break;
+ }
+
+ Event event;
+ while (!g_globals->_events.getEvent(event, EVENT_BUTTON_DOWN | EVENT_KEYPRESS) && !g_vm->shouldQuit()) {
+ g_globals->_scenePalette.signalListeners();
+ R2_GLOBALS._sceneObjects->draw();
+ g_globals->_events.delay(g_globals->_sceneHandler->_delayTicks);
+ }
+
+ scene->_selectedCard._stationPos = event.mousePos;
+
+ found = false;
+
+ if (scene->_actionVictimIdx != 2) {
+ for (i = 0; i <= 3; i++) {
+ if (scene->_gameBoardSide[scene->_actionVictimIdx]._handCard[i].isIn(scene->_selectedCard._stationPos) && (scene->_gameBoardSide[scene->_actionVictimIdx]._handCard[i]._cardId != 0)) {
+ scene->_actionCard3 = &scene->_gameBoardSide[scene->_actionVictimIdx]._handCard[i];
+ found = true;
+ break;
+ }
+ }
+ }
+ } // while
+ scene->_displayHelpFl = true;
+ scene->subC4CEC();
+ } else if (scene->_actionVictimIdx != 2) {
+ int tmpVal = scene->getRandomCardFromHand(scene->_actionVictimIdx);
+ scene->_actionCard3 = &scene->_gameBoardSide[scene->_actionVictimIdx]._handCard[tmpVal];
+ }
+ }
+
+ scene->_actionCard1->_card.postInit();
+ scene->_actionCard1->_card.hide();
+ scene->_actionCard1->_card.setVisage(1332);
+ scene->_actionCard1->_card.setPosition(scene->_actionCard1->_stationPos, 0);
+ scene->_actionCard1->_card.fixPriority(170);
+ scene->_actionCard1->_card.setStrip2(1);
+ scene->_actionCard1->_cardId = scene->_actionCard3->_cardId;
+
+ scene->_actionCard3->_cardId = 0;
+ scene->_actionCard3->_card.remove();
+
+ scene->_animatedCard._card.setPosition(scene->_actionCard3->_stationPos, 0);
+ scene->_animatedCard._card.show();
+
+ NpcMover *mover = new NpcMover();
+ scene->_animatedCard._card.addMover(mover, &scene->_actionCard1->_stationPos, this);
+ }
+ break;
+ case 2:
+ scene->_animatedCard._card.hide();
+ switch (scene->_actionPlayerIdx) {
+ case 0:
+ scene->_actionCard1->_card.setFrame2(2);
+ scene->_actionCard1->_card.show();
+ break;
+ case 1:
+ scene->_actionCard1->_card.setFrame2(4);
+ scene->_actionCard1->_card.show();
+ break;
+ case 3:
+ scene->_actionCard1->_card.setFrame2(3);
+ scene->_actionCard1->_card.show();
+ break;
+ default:
+ scene->setAnimationInfo(scene->_actionCard1);
+ break;
+ }
+
+ scene->_currentPlayerNumb--;
+ scene->_showPlayerTurn = false;
+ scene->discardCard(scene->_actionCard2);
+ break;
+ default:
+ break;
+ }
+}
+
+// Pick a card in opponent hand
+void Scene1337::Action12::signal() {
+ Scene1337 *scene = (Scene1337 *)R2_GLOBALS._sceneManager._scene;
+
+ switch (_actionIndex++) {
+ case 0:
+ signal();
+ break;
+ case 1: {
+ scene->_availableCardsPile[scene->_currentDiscardIndex] = scene->_actionCard2->_cardId;
+ scene->_currentDiscardIndex++;
+ scene->_actionCard2->_cardId = scene->_actionCard1->_cardId;
+ scene->_actionCard1->_cardId = 0;
+ scene->_actionCard1->_card.remove();
+ scene->_animatedCard._card.setPosition(scene->_actionCard1->_stationPos, 0);
+ scene->_animatedCard._card.show();
+
+ NpcMover *mover = new NpcMover();
+ scene->_animatedCard._card.addMover(mover, &scene->_actionCard2->_stationPos, this);
+ }
+ break;
+ case 2:
+ scene->_animatedCard._card.hide();
+ scene->setAnimationInfo(scene->_actionCard2);
+ scene->_aSound1.play(58);
+ if (scene->_actionVictimIdx == 2) {
+ int count = 0;
+ int i = -1;
+ switch (scene->_actionPlayerIdx) {
+ case 0:
+ for (i = 0; i <= 3; i++) {
+ if (scene->_gameBoardSide[0]._handCard[i]._cardId != 0)
+ ++count;
+ }
+ break;
+ case 1:
+ for (i = 0; i <= 3; i++) {
+ // The original game was counting in the hand of player 3, which is obviously wrong
+ if (scene->_gameBoardSide[1]._handCard[i]._cardId != 0)
+ ++count;
+ }
+ break;
+ case 3:
+ for (i = 0; i <= 3; i++) {
+ if (scene->_gameBoardSide[3]._handCard[i]._cardId != 0)
+ ++count;
+ }
+ break;
+ default:
+ break;
+ }
+
+ if (count > 1) {
+ scene->subC4CD2();
+
+ bool found = false;
+
+ while (!found) {
+ switch (scene->_actionPlayerIdx) {
+ case 0:
+ scene->actionDisplay(1330, 131, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+ break;
+ case 1:
+ scene->actionDisplay(1330, 132, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+ break;
+ case 3:
+ scene->actionDisplay(1330, 133, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+ break;
+ default:
+ break;
+ }
+
+ Event event;
+ while (!g_globals->_events.getEvent(event, EVENT_BUTTON_DOWN | EVENT_KEYPRESS) && !g_vm->shouldQuit()) {
+ g_globals->_scenePalette.signalListeners();
+ R2_GLOBALS._sceneObjects->draw();
+ g_globals->_events.delay(g_globals->_sceneHandler->_delayTicks);
+ }
+
+ scene->_selectedCard._stationPos = event.mousePos;
+
+ switch (scene->_actionPlayerIdx) {
+ case 0:
+ for (i = 0; i <= 3; i++) {
+ if (scene->_gameBoardSide[0]._handCard[i].isIn(scene->_selectedCard._stationPos) && (scene->_gameBoardSide[0]._handCard[i]._cardId != 0)) {
+ found = true;
+ scene->_actionCard3 = &scene->_gameBoardSide[0]._handCard[i];
+ break;
+ }
+ }
+ break;
+ case 1:
+ for (i = 0; i <= 3; i++) {
+ if (scene->_gameBoardSide[1]._handCard[i].isIn(scene->_selectedCard._stationPos) && (scene->_gameBoardSide[1]._handCard[i]._cardId != 0)) {
+ found = true;
+ scene->_actionCard3 = &scene->_gameBoardSide[1]._handCard[i];
+ break;
+ }
+ }
+ break;
+ case 3:
+ for (i = 0; i <= 3; i++) {
+ if (scene->_gameBoardSide[3]._handCard[i].isIn(scene->_selectedCard._stationPos) && (scene->_gameBoardSide[3]._handCard[i]._cardId != 0)) {
+ found = true;
+ scene->_actionCard3 = &scene->_gameBoardSide[3]._handCard[i];
+ break;
+ }
+ }
+ break;
+ default:
+ break;
+ }
+ }
+ scene->subC4CEC();
+ } else {
+ switch (scene->_actionPlayerIdx) {
+ case 0:
+ scene->_actionCard3 = &scene->_gameBoardSide[0]._handCard[scene->getRandomCardFromHand(0)];
+ break;
+ case 1:
+ scene->_actionCard3 = &scene->_gameBoardSide[1]._handCard[scene->getRandomCardFromHand(1)];
+ break;
+ case 3:
+ scene->_actionCard3 = &scene->_gameBoardSide[3]._handCard[scene->getRandomCardFromHand(3)];
+ break;
+ default:
+ break;
+ }
+ }
+
+ scene->_actionCard1->_card.postInit();
+ scene->_actionCard1->_card.hide();
+ scene->_actionCard1->_card.setVisage(1332);
+ scene->_actionCard1->_card.setPosition(scene->_actionCard1->_stationPos);
+ scene->_actionCard1->_card.fixPriority(170);
+ scene->_actionCard1->_card.setStrip2(1);
+ scene->_actionCard1->_cardId = scene->_actionCard3->_cardId;
+
+ scene->_actionCard3->_cardId = 0;
+ scene->_actionCard3->_card.remove();
+
+ scene->_animatedCard._card.setPosition(scene->_actionCard3->_stationPos);
+ scene->_animatedCard._card.show();
+ scene->_aSound1.play(57);
+
+ NpcMover *mover = new NpcMover();
+ scene->_animatedCard._card.addMover(mover, &scene->_actionCard1->_stationPos, this);
+ }
+ break;
+ case 3:
+ scene->_animatedCard._card.hide();
+ switch (scene->_actionVictimIdx) {
+ case 0:
+ scene->_actionCard1->_card.setFrame2(2);
+ scene->_actionCard1->_card.show();
+ break;
+ case 1:
+ scene->_actionCard1->_card.setFrame2(4);
+ scene->_actionCard1->_card.show();
+ break;
+ case 3:
+ scene->_actionCard1->_card.setFrame2(3);
+ scene->_actionCard1->_card.show();
+ break;
+ default:
+ scene->setAnimationInfo(scene->_actionCard1);
+ break;
+ }
+ scene->discardCard(scene->_actionCard2);
+ break;
+ default:
+ break;
+ }
+}
+
+// Handle the animations of the interceptor card
+void Scene1337::Action13::signal() {
+ Scene1337 *scene = (Scene1337 *)R2_GLOBALS._sceneManager._scene;
+
+ switch (_actionIndex++) {
+ case 0: {
+ scene->_availableCardsPile[scene->_currentDiscardIndex] = scene->_actionCard2->_cardId;
+ scene->_currentDiscardIndex--;
+
+ scene->_actionCard2->_cardId = scene->_actionCard1->_cardId;
+
+ scene->_actionCard1->_cardId = 0;
+ scene->_actionCard1->_card.remove();
+
+ scene->_animatedCard._card.setPosition(scene->_actionCard1->_stationPos, 0);
+ scene->_animatedCard._card.show();
+
+ NpcMover *mover = new NpcMover();
+ scene->_animatedCard._card.addMover(mover, &scene->_actionCard2->_stationPos, this);
+ }
+ break;
+ case 1:
+ scene->_animatedCard._card.hide();
+ scene->setAnimationInfo(scene->_actionCard2);
+ scene->_aSound1.play(58);
+ signal();
+ break;
+ case 2:
+ scene->discardCard(scene->_actionCard2);
+ break;
+ default:
+ break;
+ }
+}
+
+void Scene1337::postInit(SceneObjectList *OwnerList) {
+// In the original, may be found in subPostInit.
+// Without it, enableControl asserts
+ loadScene(1330);
+ R2_GLOBALS._uiElements._active = false;
+ SceneExt::postInit();
+//
+
+ // Hide the user interface
+ BF_GLOBALS._interfaceY = SCREEN_HEIGHT;
+ R2_GLOBALS._uiElements._visible = false;
+
+ R2_GLOBALS._player.enableControl();
+ R2_GLOBALS._player._canWalk = false;
+ R2_GLOBALS._player._uiEnabled = false;
+
+ _delayedFunction = nullptr;
+
+ _actionCard1 = nullptr;
+ _actionCard2 = nullptr;
+ _actionCard3 = nullptr;
+
+ _gameBoardSide[2]._handCard[0]._stationPos = Common::Point(10, 174);
+ _gameBoardSide[2]._handCard[1]._stationPos = Common::Point(37, 174);
+ _gameBoardSide[2]._handCard[2]._stationPos = Common::Point(64, 174);
+ _gameBoardSide[2]._handCard[3]._stationPos = Common::Point(91, 174);
+
+ _gameBoardSide[2]._outpostStation[0]._stationPos = Common::Point(119, 174);
+ _gameBoardSide[2]._outpostStation[1]._stationPos = Common::Point(119, 148);
+ _gameBoardSide[2]._outpostStation[2]._stationPos = Common::Point(119, 122);
+ _gameBoardSide[2]._outpostStation[3]._stationPos = Common::Point(145, 122);
+ _gameBoardSide[2]._outpostStation[4]._stationPos = Common::Point(171, 122);
+ _gameBoardSide[2]._outpostStation[5]._stationPos = Common::Point(171, 148);
+ _gameBoardSide[2]._outpostStation[6]._stationPos = Common::Point(171, 174);
+ _gameBoardSide[2]._outpostStation[7]._stationPos = Common::Point(145, 174);
+
+ _gameBoardSide[2]._delayCard._stationPos = Common::Point(199, 174);
+
+ _gameBoardSide[2]._emptyStationPos._stationPos = Common::Point(145, 148);
+
+ _gameBoardSide[2]._card1Pos = Common::Point(10, 174);
+ _gameBoardSide[2]._card2Pos = Common::Point(37, 174);
+ _gameBoardSide[2]._card3Pos = Common::Point(64, 174);
+ _gameBoardSide[2]._card4Pos = Common::Point(91, 174);
+ _gameBoardSide[2]._frameNum = 2;
+
+ _gameBoardSide[3]._handCard[0]._stationPos = Common::Point(14, 14);
+ _gameBoardSide[3]._handCard[1]._stationPos = Common::Point(14, 36);
+ _gameBoardSide[3]._handCard[2]._stationPos = Common::Point(14, 58);
+ _gameBoardSide[3]._handCard[3]._stationPos = Common::Point(14, 80);
+
+ _gameBoardSide[3]._outpostStation[0]._stationPos = Common::Point(37, 66);
+ _gameBoardSide[3]._outpostStation[1]._stationPos = Common::Point(63, 66);
+ _gameBoardSide[3]._outpostStation[2]._stationPos = Common::Point(89, 66);
+ _gameBoardSide[3]._outpostStation[3]._stationPos = Common::Point(89, 92);
+ _gameBoardSide[3]._outpostStation[4]._stationPos = Common::Point(89, 118);
+ _gameBoardSide[3]._outpostStation[5]._stationPos = Common::Point(63, 118);
+ _gameBoardSide[3]._outpostStation[6]._stationPos = Common::Point(37, 118);
+ _gameBoardSide[3]._outpostStation[7]._stationPos = Common::Point(37, 92);
+
+ _gameBoardSide[3]._delayCard._stationPos = Common::Point(37, 145);
+
+ _gameBoardSide[3]._emptyStationPos._stationPos = Common::Point(63, 92);
+
+ _gameBoardSide[3]._card1Pos = Common::Point(14, 14);
+ _gameBoardSide[3]._card2Pos = Common::Point(14, 36);
+ _gameBoardSide[3]._card3Pos = Common::Point(14, 58);
+ _gameBoardSide[3]._card4Pos = Common::Point(14, 80);
+ _gameBoardSide[3]._frameNum = 3;
+
+ _gameBoardSide[0]._handCard[0]._stationPos = Common::Point(280, 5);
+ _gameBoardSide[0]._handCard[1]._stationPos = Common::Point(253, 5);
+ _gameBoardSide[0]._handCard[2]._stationPos = Common::Point(226, 5);
+ _gameBoardSide[0]._handCard[3]._stationPos = Common::Point(199, 5);
+
+ _gameBoardSide[0]._outpostStation[0]._stationPos = Common::Point(171, 16);
+ _gameBoardSide[0]._outpostStation[1]._stationPos = Common::Point(171, 42);
+ _gameBoardSide[0]._outpostStation[2]._stationPos = Common::Point(171, 68);
+ _gameBoardSide[0]._outpostStation[3]._stationPos = Common::Point(145, 68);
+ _gameBoardSide[0]._outpostStation[4]._stationPos = Common::Point(119, 68);
+ _gameBoardSide[0]._outpostStation[5]._stationPos = Common::Point(119, 42);
+ _gameBoardSide[0]._outpostStation[6]._stationPos = Common::Point(119, 16);
+ _gameBoardSide[0]._outpostStation[7]._stationPos = Common::Point(145, 16);
+
+ _gameBoardSide[0]._delayCard._stationPos = Common::Point(91, 16);
+
+ _gameBoardSide[0]._emptyStationPos._stationPos = Common::Point(145, 42);
+
+ _gameBoardSide[0]._card1Pos = Common::Point(280, 5);
+ _gameBoardSide[0]._card2Pos = Common::Point(253, 5);
+ _gameBoardSide[0]._card3Pos = Common::Point(226, 5);
+ _gameBoardSide[0]._card4Pos = Common::Point(199, 5);
+ _gameBoardSide[0]._frameNum = 2;
+
+ _gameBoardSide[1]._handCard[0]._stationPos = Common::Point(283, 146);
+ _gameBoardSide[1]._handCard[1]._stationPos = Common::Point(283, 124);
+ _gameBoardSide[1]._handCard[2]._stationPos = Common::Point(283, 102);
+ _gameBoardSide[1]._handCard[3]._stationPos = Common::Point(283, 80);
+
+ _gameBoardSide[1]._outpostStation[0]._stationPos = Common::Point(253, 122);
+ _gameBoardSide[1]._outpostStation[1]._stationPos = Common::Point(227, 122);
+ _gameBoardSide[1]._outpostStation[2]._stationPos = Common::Point(201, 122);
+ _gameBoardSide[1]._outpostStation[3]._stationPos = Common::Point(201, 96);
+ _gameBoardSide[1]._outpostStation[4]._stationPos = Common::Point(201, 70);
+ _gameBoardSide[1]._outpostStation[5]._stationPos = Common::Point(227, 70);
+ _gameBoardSide[1]._outpostStation[6]._stationPos = Common::Point(253, 70);
+ _gameBoardSide[1]._outpostStation[7]._stationPos = Common::Point(253, 96);
+
+ _gameBoardSide[1]._delayCard._stationPos = Common::Point(253, 43);
+
+ _gameBoardSide[1]._emptyStationPos._stationPos = Common::Point(227, 96);
+
+ _gameBoardSide[1]._card1Pos = Common::Point(283, 146);
+ _gameBoardSide[1]._card2Pos = Common::Point(283, 124);
+ _gameBoardSide[1]._card3Pos = Common::Point(283, 102);
+ _gameBoardSide[1]._card4Pos = Common::Point(283, 80);
+ _gameBoardSide[1]._frameNum = 4;
+
+ subPostInit();
+
+ _stockPile.postInit();
+}
+
+void Scene1337::remove() {
+ if (R2_GLOBALS._v57709 > 1) {
+ subD1917();
+ subD1940(false);
+ }
+
+ R2_GLOBALS._uiElements._active = true;
+ R2_GLOBALS._uiElements._visible = true;
+ SceneExt::remove();
+}
+
+void Scene1337::process(Event &event) {
+ if (event.eventType == EVENT_BUTTON_DOWN) {
+ if (event.btnState == BTNSHIFT_RIGHT) {
+ updateCursorId(R2_GLOBALS._mouseCursorId, true);
+ event.handled = true;
+ } else if (_delayedFunction) {
+ FunctionPtrType tmpFctPtr = _delayedFunction;
+ _delayedFunction = nullptr;
+ (this->*tmpFctPtr)();
+ event.handled = true;
+ }
+ } else if (event.eventType == EVENT_KEYPRESS) {
+ if (event.kbd.keycode == Common::KEYCODE_SPACE) {
+ if (_delayedFunction) {
+ FunctionPtrType tmpFctPtr = _delayedFunction;
+ _delayedFunction = nullptr;
+ (this->*tmpFctPtr)();
+ event.handled = true;
+ }
+ } else
+ warning("Fixme: Find proper keycode value");
+ }
+
+ if (!event.handled)
+ Scene::process(event);
+}
+
+void Scene1337::dispatch() {
+ if (!_instructionsDisplayedFl) {
+ ++_instructionsWaitCount;
+ if (_instructionsWaitCount == 4) {
+ _instructionsDisplayedFl = true;
+ suggestInstructions();
+ }
+ }
+
+ // The following code is in the original in sceneHandler::process(),
+ // which is terrible as it's checked in every scene of the game.
+ setCursorData(5, _cursorCurStrip, _cursorCurFrame);
+ //
+
+ Scene::dispatch();
+}
+
+void Scene1337::actionDisplay(int resNum, int lineNum, int x, int y, int keepOnScreen, int width, int textMode, int fontNum, int colFG, int colBGExt, int colFGExt) {
+ // TODO: Check if it's normal that arg5 is unused and replaced by an hardcoded 0 value
+ // May hide an original bug
+
+ SceneItem::display(resNum, lineNum, SET_X, x, SET_Y, y, SET_KEEP_ONSCREEN, 0,
+ SET_WIDTH, width, SET_POS_MODE, -1, SET_TEXT_MODE, textMode,
+ SET_FONT, fontNum, SET_FG_COLOR, colFG, SET_EXT_BGCOLOR, colBGExt,
+ SET_EXT_FGCOLOR, colFGExt, LIST_END);
+}
+
+void Scene1337::setAnimationInfo(Card *card) {
+ if (!card)
+ return;
+
+ if (card->_cardId > 25) {
+ card->_card.setStrip2(4);
+ card->_card.setFrame(card->_cardId - 25);
+ } else if (card->_cardId > 9) {
+ card->_card.setStrip2(3);
+ card->_card.setFrame(card->_cardId - 9);
+ } else {
+ card->_card.setStrip2(2);
+ card->_card.setFrame(card->_cardId);
+ }
+
+ card->_card.show();
+ R2_GLOBALS._sceneObjects->draw();
+}
+
+void Scene1337::handleNextTurn() {
+ switch (_winnerId) {
+ case -1:
+ ++_currentPlayerNumb;
+ if (_currentPlayerNumb > 3)
+ _currentPlayerNumb = 0;
+
+ if (_showPlayerTurn) {
+ _currentPlayerArrow.show();
+ switch (_currentPlayerNumb) {
+ case 0:
+ _currentPlayerArrow.setStrip(3);
+ break;
+ case 1:
+ _currentPlayerArrow.setStrip(4);
+ break;
+ case 2:
+ subD1975(174, 107);
+ _currentPlayerArrow.setStrip(1);
+ break;
+ case 3:
+ subC4CEC();
+ _currentPlayerArrow.setStrip(2);
+ break;
+ default:
+ break;
+ }
+
+ if (!_autoplay)
+ _delayedFunction = &Scene1337::handlePlayerTurn;
+ else
+ handlePlayerTurn();
+ } else {
+ handlePlayerTurn();
+ }
+ break;
+ case 0:
+ _aSound2.play(62);
+ actionDisplay(1330, 135, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+ actionDisplay(1330, 121, 20, 99, 1, 136, 0, 7, 0, 172, 172);
+ actionDisplay(1330, 122, 300, 99, 1, 136, 0, 7, 0, 117, 117);
+ R2_GLOBALS._sceneObjects->draw();
+ actionDisplay(1330, 123, 159, 134, 1, 200, 0, 7, 0, 105, 105);
+ break;
+ case 1:
+ _aSound2.play(62);
+ actionDisplay(1330, 151, 300, 99, 1, 136, 0, 7, 0, 117, 117);
+ actionDisplay(1330, 118, 20, 99, 1, 136, 0, 7, 0, 172, 172);
+ actionDisplay(1330, 119, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+ R2_GLOBALS._sceneObjects->draw();
+ actionDisplay(1330, 120, 159, 134, 1, 200, 0, 7, 0, 105, 105);
+ break;
+ case 2:
+ _aSound2.play(62);
+ actionDisplay(1330, 134, 159, 134, 1, 200, 0, 7, 0, 105, 105);
+ actionDisplay(1330, 124, 20, 99, 1, 136, 0, 7, 0, 172, 172);
+ actionDisplay(1330, 126, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+ R2_GLOBALS._sceneObjects->draw();
+ actionDisplay(1330, 125, 300, 99, 1, 136, 0, 7, 0, 117, 117);
+ break;
+ case 3:
+ _aSound2.play(62);
+ actionDisplay(1330, 150, 20, 99, 1, 136, 0, 7, 0, 172, 172);
+ actionDisplay(1330, 115, 300, 99, 1, 136, 0, 7, 0, 117, 117);
+ actionDisplay(1330, 116, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+ R2_GLOBALS._sceneObjects->draw();
+ actionDisplay(1330, 117, 159, 134, 1, 200, 0, 7, 0, 105, 105);
+ break;
+ default:
+ break;
+ }
+
+ if (_winnerId != -1)
+ R2_GLOBALS._sceneManager.changeScene(125);
+
+}
+
+void Scene1337::handlePlayerTurn() {
+ if (_showPlayerTurn)
+ _currentPlayerArrow.hide();
+
+ switch (_currentPlayerNumb) {
+ case 2:
+ subC4CD2();
+ if (_displayHelpFl)
+ actionDisplay(1330, 114, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+ _displayHelpFl = false;
+ // No break on purpose
+ case 0:
+ // No break on purpose
+ case 1:
+ // No break on purpose
+ case 3:
+ _actionItem.setAction(&_action4);
+ default:
+ break;
+ }
+
+ _showPlayerTurn = true;
+
+}
+
+bool Scene1337::isStationCard(int cardId) {
+ switch (cardId) {
+ case 10:
+ // No break on purpose
+ case 12:
+ // No break on purpose
+ case 15:
+ // No break on purpose
+ case 17:
+ // No break on purpose
+ case 18:
+ // No break on purpose
+ case 19:
+ // No break on purpose
+ case 20:
+ // No break on purpose
+ case 21:
+ return true;
+ default:
+ return false;
+ }
+}
+
+bool Scene1337::isStopConstructionCard(int cardId) {
+ switch (cardId) {
+ case 11:
+ // No break on purpose
+ case 14:
+ // No break on purpose
+ case 16:
+ // No break on purpose
+ case 24:
+ return true;
+ default:
+ return false;
+ }
+}
+
+int Scene1337::getStationId(int playerId, int handCardId) {
+ if ((_gameBoardSide[playerId]._handCard[handCardId]._cardId > 1) && (_gameBoardSide[playerId]._handCard[handCardId]._cardId <= 9))
+ return handCardId;
+
+ return -1;
+}
+
+int Scene1337::findPlatformCardInHand(int playerId) {
+ for (int i = 0; i <= 3; i++) {
+ if (_gameBoardSide[playerId]._handCard[i]._cardId == 1)
+ return i;
+ }
+
+ return -1;
+}
+
+int Scene1337::findMeteorCardInHand(int playerId) {
+ for (int i = 0; i <= 3; i++) {
+ if (_gameBoardSide[playerId]._handCard[i]._cardId == 13)
+ return i;
+ }
+
+ return -1;
+}
+
+int Scene1337::findThieftCardInHand(int playerId) {
+ for (int i = 0; i <= 3; i++) {
+ if (_gameBoardSide[playerId]._handCard[i]._cardId == 25)
+ return i;
+ }
+
+ return -1;
+}
+
+int Scene1337::isDelayCard(int cardId) {
+ switch (cardId) {
+ case 11:
+ // No break on purpose
+ case 14:
+ // No break on purpose
+ case 16:
+ // No break on purpose
+ case 24:
+ return cardId;
+ break;
+ default:
+ return -1;
+ break;
+ }
+}
+
+int Scene1337::getStationCardId(int cardId) {
+ switch (cardId) {
+ case 10:
+ // No break on purpose
+ case 12:
+ // No break on purpose
+ case 15:
+ // No break on purpose
+ case 17:
+ // No break on purpose
+ case 18:
+ // No break on purpose
+ case 19:
+ // No break on purpose
+ case 20:
+ // No break on purpose
+ case 21:
+ return cardId;
+ default:
+ return -1;
+ }
+}
+
+void Scene1337::handlePlayer01Discard(int playerId) {
+ switch (playerId) {
+ case 0:
+ for (int i = 0; i <= 3; i++) {
+ if (getStationCardId(_gameBoardSide[playerId]._handCard[i]._cardId) != -1) {
+ discardCard(&_gameBoardSide[playerId]._handCard[i]);
+ return;
+ }
+ }
+
+ for (int i = 0; i <= 3; i++) {
+ if (isDelayCard(_gameBoardSide[playerId]._handCard[i]._cardId) != -1) {
+ discardCard(&_gameBoardSide[playerId]._handCard[i]);
+ return;
+ }
+ }
+
+ for (int i = 0; i <= 3; i++) {
+ // Outpost Card
+ if ((_gameBoardSide[playerId]._handCard[i]._cardId > 1) && (_gameBoardSide[playerId]._handCard[i]._cardId <= 9)) {
+ discardCard(&_gameBoardSide[playerId]._handCard[i]);
+ return;
+ }
+ }
+
+ for (int i = 0; i <= 3; i++) {
+ if ((_gameBoardSide[playerId]._handCard[i]._cardId >= 26) && (_gameBoardSide[playerId]._handCard[i]._cardId <= 33)) {
+ discardCard(&_gameBoardSide[playerId]._handCard[i]);
+ return;
+ }
+ }
+
+ for (int i = 0; i <= 3; i++) {
+ // Station Card
+ if (_gameBoardSide[playerId]._handCard[i]._cardId == 1) {
+ discardCard(&_gameBoardSide[playerId]._handCard[i]);
+ return;
+ }
+ }
+
+ for (int i = 0; i <= 3; i++) {
+ // Thief card
+ if (_gameBoardSide[playerId]._handCard[i]._cardId == 25) {
+ discardCard(&_gameBoardSide[playerId]._handCard[i]);
+ return;
+ }
+ }
+
+ for (int i = 0; i <= 3; i++) {
+ // Meteor Card
+ if (_gameBoardSide[playerId]._handCard[i]._cardId == 13) {
+ discardCard(&_gameBoardSide[playerId]._handCard[i]);
+ return;
+ }
+ }
+ break;
+ case 1:
+ for (int i = 0; i <= 3; i++) {
+ if ((_gameBoardSide[playerId]._handCard[i]._cardId >= 26) && (_gameBoardSide[playerId]._handCard[i]._cardId <= 33)) {
+ discardCard(&_gameBoardSide[playerId]._handCard[i]);
+ return;
+ }
+ }
+
+ for (int i = 0; i <= 3; i++) {
+ // Station Card
+ if (_gameBoardSide[playerId]._handCard[i]._cardId == 1) {
+ discardCard(&_gameBoardSide[playerId]._handCard[i]);
+ return;
+ }
+ }
+
+ for (int i = 0; i <= 3; i++) {
+ // Outpost Card
+ if ((_gameBoardSide[playerId]._handCard[i]._cardId > 1) && (_gameBoardSide[playerId]._handCard[i]._cardId <= 9)) {
+ discardCard(&_gameBoardSide[playerId]._handCard[i]);
+ return;
+ }
+ }
+
+ for (int i = 0; i <= 3; i++) {
+ if (getStationCardId(_gameBoardSide[playerId]._handCard[i]._cardId) != -1) {
+ discardCard(&_gameBoardSide[playerId]._handCard[i]);
+ return;
+ }
+ }
+
+ for (int i = 0; i <= 3; i++) {
+ if (isDelayCard(_gameBoardSide[playerId]._handCard[i]._cardId) != -1) {
+ discardCard(&_gameBoardSide[playerId]._handCard[i]);
+ return;
+ }
+ }
+
+ for (int i = 0; i <= 3; i++) {
+ // Thief card
+ if (_gameBoardSide[playerId]._handCard[i]._cardId == 25) {
+ discardCard(&_gameBoardSide[playerId]._handCard[i]);
+ return;
+ }
+ }
+
+ for (int i = 0; i <= 3; i++) {
+ // Meteor Card
+ if (_gameBoardSide[playerId]._handCard[i]._cardId == 13) {
+ discardCard(&_gameBoardSide[playerId]._handCard[i]);
+ return;
+ }
+ }
+
+ break;
+ default:
+ break;
+ }
+}
+
+void Scene1337::playThieftCard(int playerId, Card *card, int victimId) {
+ _actionPlayerIdx = playerId;
+ _actionVictimIdx = victimId;
+
+ int randIndx;
+
+ for (;;) {
+ randIndx = R2_GLOBALS._randomSource.getRandomNumber(3);
+ if (_gameBoardSide[victimId]._handCard[randIndx]._cardId != 0)
+ break;
+ }
+
+ _actionCard1 = card;
+ _actionCard2 = &_gameBoardSide[victimId]._emptyStationPos;
+ _actionCard3 = &_gameBoardSide[victimId]._handCard[randIndx];
+
+ _actionItem.setAction(&_action11);
+}
+
+int Scene1337::getPreventionCardId(int cardId) {
+ int retVal;
+
+ switch (cardId) {
+ case 10:
+ retVal = 2;
+ break;
+ case 12:
+ retVal = 3;
+ break;
+ case 15:
+ retVal = 5;
+ break;
+ case 17:
+ retVal = 9;
+ break;
+ case 18:
+ retVal = 6;
+ break;
+ case 19:
+ retVal = 4;
+ break;
+ case 20:
+ retVal = 8;
+ break;
+ case 21:
+ retVal = 7;
+ break;
+ default:
+ retVal = -1;
+ }
+
+ return retVal;
+}
+
+bool Scene1337::isAttackPossible(int victimId, int cardId) {
+ if (victimId < 0 || victimId >= ARRAYSIZE(_gameBoardSide))
+ error("Scene1337::isAttackPossible() victimId:%d out of range 0 to %d", victimId, ARRAYSIZE(_gameBoardSide)-1);
+
+ for (int i = 0; i <= 7; i++) {
+ if (_gameBoardSide[victimId]._outpostStation[i]._cardId != 0) {
+ if (getPreventionCardId(cardId) == _gameBoardSide[victimId]._outpostStation[i]._cardId)
+ return false;
+ }
+ }
+ return true;
+}
+
+int Scene1337::getPlayerWithOutpost(int playerId) {
+ int randPlayerId = R2_GLOBALS._randomSource.getRandomNumber(3);
+
+ for (int i = 0; i <= 3; i++) {
+ if (randPlayerId != playerId) {
+ for (int j = 0; j <= 7; j++) {
+ if (_gameBoardSide[randPlayerId]._outpostStation[j]._cardId != 0)
+ return randPlayerId;
+ }
+ }
+
+ if (playerId == 1) {
+ randPlayerId--;
+ if (randPlayerId < 0)
+ randPlayerId = 3;
+ } else {
+ ++randPlayerId;
+ if (randPlayerId > 3)
+ randPlayerId = 0;
+ }
+ }
+
+ return -1;
+}
+
+bool Scene1337::checkAntiDelayCard(int delayCardId, int cardId) {
+ if ((delayCardId == 11) && (cardId == 26)) // Diplomacy
+ return true;
+
+ if ((delayCardId == 14) && (cardId == 30)) // Cure
+ return true;
+
+ if ((delayCardId == 16) && (cardId == 32)) // Agreement
+ return true;
+
+ if ((delayCardId == 24) && (cardId == 28)) // Innovation
+ return true;
+
+ return false;
+}
+
+void Scene1337::playStationCard(Card *station, Card *platform) {
+ _actionCard1 = station;
+ _actionCard2 = platform;
+ _actionItem.setAction(&_action7);
+}
+
+int Scene1337::getRandomCardFromHand(int playerId) {
+ if ( (_gameBoardSide[playerId]._handCard[0]._cardId == 0)
+ && (_gameBoardSide[playerId]._handCard[1]._cardId == 0)
+ && (_gameBoardSide[playerId]._handCard[2]._cardId == 0)
+ && (_gameBoardSide[playerId]._handCard[3]._cardId == 0))
+ return -1;
+
+ int randIndx;
+ for (;;) {
+ randIndx = R2_GLOBALS._randomSource.getRandomNumber(3);
+ if (_gameBoardSide[playerId]._handCard[randIndx]._cardId != 0)
+ break;
+ }
+
+ return randIndx;
+}
+
+void Scene1337::playPlatformCard(Card *card, Card *dest) {
+ _actionCard1 = card;
+ _actionCard2 = dest;
+
+ _actionItem.setAction(&_action6);
+}
+
+void Scene1337::playDelayCard(Card *card, Card *dest) {
+ _actionCard1 = card;
+ _actionCard2 = dest;
+
+ _actionItem.setAction(&_action9);
+}
+
+void Scene1337::playAntiDelayCard(Card *card, Card *dest) {
+ _actionCard1 = card;
+ _actionCard2 = dest;
+
+ _actionItem.setAction(&_action8);
+
+ // WORKAROUND: Restore the default cursor and for a call to signal.
+ // This works around the cursor caching we got rid of, and avoid
+ // the game ends in an eternal loop when a player reacts to another player
+ // attack.
+ setCursorData(5, 1, 4);
+ signal();
+}
+
+
+Scene1337::Card *Scene1337::getStationCard(int playerId) {
+ for (int i = 0; i <= 7; i++) {
+ if ((_gameBoardSide[playerId]._outpostStation[i]._cardId >= 1) && (_gameBoardSide[playerId]._outpostStation[i]._cardId <= 9))
+ return &_gameBoardSide[playerId]._outpostStation[i];
+ }
+
+ return nullptr;
+}
+
+void Scene1337::playCentralOutpostCard(Card *card, int playerId) {
+ _actionCard1 = card;
+ _actionCard2 = getStationCard(playerId);
+ _actionCard3 = &_gameBoardSide[playerId]._emptyStationPos;
+ _actionPlayerIdx = playerId;
+ _actionItem.setAction(&_action10);
+}
+
+void Scene1337::discardCard(Card *card) {
+ _actionCard1 = card;
+
+ _actionItem.setAction(&_action5);
+}
+
+void Scene1337::subC4CD2() {
+ if (R2_GLOBALS._v57709 > 0) {
+ subD1917();
+ subD1940(false); // _v5780C--
+ }
+}
+
+void Scene1337::subC4CEC() {
+ if (R2_GLOBALS._v57709 == 0) {
+ subD18F5();
+ subD1940(true); // _v5780C++
+ }
+}
+
+// Play Interceptor card
+void Scene1337::playInterceptorCard(Card *subObj1, Card *subObj2) {
+ _actionCard1 = subObj1;
+ _actionCard2 = subObj2;
+
+ _actionItem.setAction(&_action13);
+}
+
+void Scene1337::displayDialog(int dialogNumb) {
+ switch (dialogNumb - 1) {
+ case 0:
+ actionDisplay(1330, 53, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+ break;
+ case 1:
+ actionDisplay(1330, 57, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+ break;
+ case 2:
+ actionDisplay(1330, 58, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+ break;
+ case 3:
+ actionDisplay(1330, 59, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+ break;
+ case 4:
+ actionDisplay(1330, 60, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+ break;
+ case 5:
+ actionDisplay(1330, 61, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+ break;
+ case 6:
+ actionDisplay(1330, 62, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+ break;
+ case 7:
+ actionDisplay(1330, 63, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+ break;
+ case 8:
+ actionDisplay(1330, 64, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+ break;
+ case 9:
+ actionDisplay(1330, 65, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+ break;
+ case 10:
+ actionDisplay(1330, 67, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+ break;
+ case 11:
+ actionDisplay(1330, 69, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+ break;
+ case 12:
+ actionDisplay(1330, 71, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+ actionDisplay(1330, 72, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+ actionDisplay(1330, 73, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+ break;
+ case 13:
+ actionDisplay(1330, 79, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+ break;
+ case 14:
+ actionDisplay(1330, 81, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+ break;
+ case 15:
+ actionDisplay(1330, 83, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+ break;
+ case 16:
+ actionDisplay(1330, 85, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+ break;
+ case 17:
+ actionDisplay(1330, 87, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+ break;
+ case 18:
+ actionDisplay(1330, 89, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+ break;
+ case 19:
+ actionDisplay(1330, 91, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+ break;
+ case 20:
+ actionDisplay(1330, 93, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+ break;
+ case 23:
+ actionDisplay(1330, 95, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+ break;
+ case 24:
+ actionDisplay(1330, 97, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+ break;
+ case 25:
+ actionDisplay(1330, 104, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+ break;
+ case 26:
+ actionDisplay(1330, 105, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+ actionDisplay(1330, 106, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+ break;
+ case 27:
+ actionDisplay(1330, 110, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+ break;
+ case 28:
+ actionDisplay(1330, 108, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+ actionDisplay(1330, 109, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+ break;
+ case 29:
+ actionDisplay(1330, 111, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+ break;
+ case 31:
+ actionDisplay(1330, 112, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+ break;
+ default:
+ break;
+ }
+}
+
+void Scene1337::subPostInit() {
+ R2_GLOBALS._v57709 = 0;
+ R2_GLOBALS._v5780C = 0;
+ updateCursorId(1, false);
+ subD1940(true); // _v5780C++
+ subD18F5();
+
+// loadScene(1330);
+// SceneExt::postInit();
+
+ R2_GLOBALS._scenePalette.addRotation(224, 235, 1);
+
+ _availableCardsPile[0] = 1;
+ _availableCardsPile[1] = 1;
+ _availableCardsPile[2] = 1;
+ _availableCardsPile[3] = 1;
+ _availableCardsPile[4] = 1;
+ _availableCardsPile[5] = 1;
+ _availableCardsPile[6] = 1;
+ _availableCardsPile[7] = 1;
+ _availableCardsPile[8] = 26;
+ _availableCardsPile[9] = 2;
+ _availableCardsPile[10] = 2;
+ _availableCardsPile[11] = 2;
+ _availableCardsPile[12] = 2;
+ _availableCardsPile[13] = 2;
+ _availableCardsPile[14] = 26;
+ _availableCardsPile[15] = 3;
+ _availableCardsPile[16] = 3;
+ _availableCardsPile[17] = 3;
+ _availableCardsPile[18] = 3;
+ _availableCardsPile[19] = 3;
+ _availableCardsPile[20] = 28;
+ _availableCardsPile[21] = 4;
+ _availableCardsPile[22] = 4;
+ _availableCardsPile[23] = 4;
+ _availableCardsPile[24] = 4;
+ _availableCardsPile[25] = 4;
+ _availableCardsPile[26] = 28;
+ _availableCardsPile[27] = 5;
+ _availableCardsPile[28] = 5;
+ _availableCardsPile[29] = 5;
+ _availableCardsPile[30] = 5;
+ _availableCardsPile[31] = 5;
+ _availableCardsPile[32] = 30;
+ _availableCardsPile[33] = 6;
+ _availableCardsPile[34] = 6;
+ _availableCardsPile[35] = 6;
+ _availableCardsPile[36] = 6;
+ _availableCardsPile[37] = 6;
+ _availableCardsPile[38] = 30;
+ _availableCardsPile[39] = 7;
+ _availableCardsPile[40] = 7;
+ _availableCardsPile[41] = 7;
+ _availableCardsPile[42] = 7;
+ _availableCardsPile[43] = 7;
+ _availableCardsPile[44] = 32;
+ _availableCardsPile[45] = 8;
+ _availableCardsPile[46] = 8;
+ _availableCardsPile[47] = 8;
+ _availableCardsPile[48] = 8;
+ _availableCardsPile[49] = 8;
+ _availableCardsPile[50] = 32;
+ _availableCardsPile[51] = 9;
+ _availableCardsPile[52] = 9;
+ _availableCardsPile[53] = 9;
+ _availableCardsPile[54] = 9;
+ _availableCardsPile[55] = 9;
+ _availableCardsPile[56] = 10;
+ _availableCardsPile[57] = 11;
+ _availableCardsPile[58] = 12;
+ _availableCardsPile[59] = 13;
+ _availableCardsPile[60] = 13;
+ _availableCardsPile[61] = 14;
+ _availableCardsPile[62] = 15;
+ _availableCardsPile[63] = 16;
+ _availableCardsPile[64] = 17;
+ _availableCardsPile[65] = 18;
+ _availableCardsPile[66] = 19;
+ _availableCardsPile[67] = 20;
+ _availableCardsPile[68] = 21;
+ _availableCardsPile[69] = 26;
+ _availableCardsPile[70] = 28;
+ _availableCardsPile[71] = 24;
+ _availableCardsPile[72] = 25;
+ _availableCardsPile[73] = 25;
+ _availableCardsPile[74] = 25;
+ _availableCardsPile[75] = 25;
+ _availableCardsPile[76] = 26;
+ _availableCardsPile[77] = 26;
+ _availableCardsPile[78] = 26;
+ _availableCardsPile[79] = 27;
+ _availableCardsPile[80] = 27;
+ _availableCardsPile[81] = 28;
+ _availableCardsPile[82] = 28;
+ _availableCardsPile[83] = 28;
+ _availableCardsPile[84] = 29;
+ _availableCardsPile[85] = 29;
+ _availableCardsPile[86] = 29;
+ _availableCardsPile[87] = 30;
+ _availableCardsPile[88] = 30;
+ _availableCardsPile[89] = 30;
+ _availableCardsPile[90] = 30;
+ _availableCardsPile[91] = 32;
+ _availableCardsPile[92] = 1;
+ _availableCardsPile[93] = 32;
+ _availableCardsPile[94] = 32;
+ _availableCardsPile[95] = 32;
+ _availableCardsPile[96] = 1;
+ _availableCardsPile[97] = 1;
+ _availableCardsPile[98] = 1;
+ _availableCardsPile[99] = 0;
+
+ _cardsAvailableNumb = 98;
+ _currentDiscardIndex = 98; // CHECKME: Would make more sense at pos 99
+
+ _discardPile._cardId = 0;
+ _discardPile._stationPos = Common::Point(128, 95);
+
+ _stockCard._cardId = 0;
+ _stockCard._stationPos = Common::Point(162, 95);
+
+ _selectedCard._cardId = 0;
+
+ _animatedCard._card.postInit();
+ _animatedCard._card.setVisage(1332);
+ _animatedCard._card.setStrip(5);
+ _animatedCard._card.setFrame(1);
+ _animatedCard._card._moveDiff = Common::Point(10, 10);
+ _animatedCard._card.fixPriority(400);
+ _animatedCard._card.setPosition(Common::Point(128, 95), 0);
+ _animatedCard._card.animate(ANIM_MODE_2, NULL);
+ _animatedCard._card.hide();
+
+ _currentPlayerArrow.postInit();
+ _currentPlayerArrow.setVisage(1334);
+ _currentPlayerArrow.setStrip(1);
+ _currentPlayerArrow.setFrame(1);
+ _currentPlayerArrow._numFrames = 12;
+ _currentPlayerArrow.fixPriority(500);
+ _currentPlayerArrow.setPosition(Common::Point(174, 107), 0);
+ _currentPlayerArrow.animate(ANIM_MODE_2, NULL);
+ _currentPlayerArrow.hide();
+
+ _showPlayerTurn = true;
+ _displayHelpFl = false;
+ _winnerId = -1;
+
+ _helpIcon.postInit();
+ _helpIcon.setup(9531, 1, 1);
+ _helpIcon.setPosition(Common::Point(249, 168));
+ _helpIcon.setPriority(155);
+ _helpIcon._effect = EFFECT_NONE;
+ _helpIcon.show();
+
+ _autoplay = false;
+ _instructionsDisplayedFl = false;
+ _instructionsWaitCount = 0;
+}
+
+void Scene1337::suggestInstructions() {
+ if (R2_GLOBALS._v57709 > 0)
+ subD1917();
+
+ if (MessageDialog::show(NEED_INSTRUCTIONS, NO_MSG, YES_MSG) == 0) {
+ if (R2_GLOBALS._v57709 == 0)
+ subD18F5();
+ dealCards();
+ } else {
+ if (R2_GLOBALS._v57709 == 0)
+ subD18F5();
+ displayInstructions();
+ }
+}
+
+void Scene1337::displayInstructions() {
+ _actionItem.setAction(&_action1);
+}
+
+void Scene1337::shuffleCards() {
+ R2_GLOBALS._sceneObjects->draw();
+
+ // Remove holes in card pile
+ for (int i = 0; i <= 98; i++) {
+ if (_availableCardsPile[i] == 0) {
+ for (int j = i + 1; j <= 98; j ++) {
+ if (_availableCardsPile[j] != 0) {
+ _availableCardsPile[i] = _availableCardsPile[j];
+ _availableCardsPile[j] = 0;
+ break;
+ }
+ }
+ }
+ }
+
+ // Compute the number of available cards
+ for (int i = 0; i <= 99; i ++) {
+ if (_availableCardsPile[i] == 0) {
+ // CHECKME: This will fail if i == 0, which shouldn't happen
+ // as we don't shuffle cards when no card is available.
+ _cardsAvailableNumb = i - 1;
+ _currentDiscardIndex = 98; // CHECKME: Would make more sense at pos 99
+ break;
+ }
+ }
+
+ for (int i = 0; i < 2000; i ++) {
+ int randIndx = R2_GLOBALS._randomSource.getRandomNumber(_cardsAvailableNumb);
+ int swap = _availableCardsPile[0];
+ _availableCardsPile[0] = _availableCardsPile[randIndx];
+ _availableCardsPile[randIndx] = swap;
+ }
+
+ _shuffleEndedFl = false;
+
+ // Shuffle cards
+ _animatedCard._card.setAction(&_action2);
+
+ while(!_shuffleEndedFl && !g_vm->shouldQuit()) {
+ g_globals->_sceneObjects->recurse(SceneHandler::dispatchObject);
+ g_globals->_scenePalette.signalListeners();
+ R2_GLOBALS._sceneObjects->draw();
+ g_globals->_events.delay(g_globals->_sceneHandler->_delayTicks);
+ }
+}
+
+void Scene1337::dealCards() {
+ _animatedCard._card._moveDiff = Common::Point(30, 30);
+ shuffleCards();
+
+ // Deal cards
+ _actionItem.setAction(&_action3);
+}
+
+void Scene1337::showOptionsDialog() {
+ // Display menu with "Auto Play", "New Game", "Quit" and "Continue"
+ OptionsDialog::show();
+}
+
+void Scene1337::handleClick(int arg1, Common::Point pt) {
+ int curReg = R2_GLOBALS._sceneRegions.indexOf(g_globals->_events._mousePos);
+
+ if (arg1 == 3) {
+ bool found = false;
+ int i;
+ for (i = 0; i <= 7; i++) {
+ if ( _gameBoardSide[2]._outpostStation[i].isIn(pt)
+ || _gameBoardSide[0]._outpostStation[i].isIn(pt)
+ || _gameBoardSide[1]._outpostStation[i].isIn(pt)
+ || _gameBoardSide[3]._outpostStation[i].isIn(pt) ) {
+ found = true;
+ break;
+ }
+ }
+
+ if (found) {
+ switch (curReg) {
+ case 5:
+ if (_gameBoardSide[2]._outpostStation[i]._cardId != 0)
+ displayDialog(_gameBoardSide[2]._outpostStation[i]._cardId);
+ else
+ actionDisplay(1330, 20, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+ break;
+ case 10:
+ if (_gameBoardSide[3]._outpostStation[i]._cardId != 0)
+ displayDialog(_gameBoardSide[3]._outpostStation[i]._cardId);
+ else
+ actionDisplay(1330, 22, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+ break;
+ case 15:
+ if (_gameBoardSide[0]._outpostStation[i]._cardId != 0)
+ displayDialog(_gameBoardSide[0]._outpostStation[i]._cardId);
+ else
+ actionDisplay(1330, 21, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+ break;
+ case 20:
+ if (_gameBoardSide[1]._outpostStation[i]._cardId != 0)
+ displayDialog(_gameBoardSide[1]._outpostStation[i]._cardId);
+ else
+ actionDisplay(1330, 23, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+ break;
+ default:
+ break;
+ }
+ } else if ( _gameBoardSide[2]._delayCard.isIn(pt)
+ || _gameBoardSide[0]._delayCard.isIn(pt)
+ || _gameBoardSide[1]._delayCard.isIn(pt)
+ || _gameBoardSide[3]._delayCard.isIn(pt) ) {
+ switch (curReg) {
+ case 5:
+ if (_gameBoardSide[2]._delayCard._cardId != 0)
+ displayDialog(_gameBoardSide[2]._delayCard._cardId);
+ else
+ actionDisplay(1330, 10, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+ break;
+ case 10:
+ if (_gameBoardSide[3]._delayCard._cardId != 0)
+ displayDialog(_gameBoardSide[3]._delayCard._cardId);
+ else
+ actionDisplay(1330, 16, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+ break;
+ case 15:
+ if (_gameBoardSide[0]._delayCard._cardId != 0)
+ displayDialog(_gameBoardSide[0]._delayCard._cardId);
+ else
+ actionDisplay(1330, 13, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+ break;
+ case 20:
+ if (_gameBoardSide[1]._delayCard._cardId != 0)
+ displayDialog(_gameBoardSide[1]._delayCard._cardId);
+ else
+ actionDisplay(1330, 18, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+ break;
+ default:
+ break;
+ }
+ } else if (_discardPile.isIn(pt)) {
+ if (_discardPile._cardId != 0)
+ displayDialog(_discardPile._cardId);
+ else
+ actionDisplay(1330, 7, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+ } else if (_helpIcon._bounds.contains(pt))
+ actionDisplay(1330, 43, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+ else if (_stockCard.isIn(pt))
+ actionDisplay(1330, 4, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+ else if ( (_gameBoardSide[2]._emptyStationPos.isIn(pt))
+ || (_gameBoardSide[3]._emptyStationPos.isIn(pt))
+ || (_gameBoardSide[0]._emptyStationPos.isIn(pt))
+ || (_gameBoardSide[1]._emptyStationPos.isIn(pt)) )
+ actionDisplay(1330, 32, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+ else if (_gameBoardSide[2]._handCard[0].isIn(pt))
+ displayDialog(_gameBoardSide[2]._handCard[0]._cardId);
+ else if (_gameBoardSide[2]._handCard[1].isIn(pt))
+ displayDialog(_gameBoardSide[2]._handCard[1]._cardId);
+ else if (_gameBoardSide[2]._handCard[2].isIn(pt))
+ displayDialog(_gameBoardSide[2]._handCard[2]._cardId);
+ else if (_gameBoardSide[2]._handCard[3].isIn(pt))
+ displayDialog(_gameBoardSide[2]._handCard[3]._cardId);
+ else if ((curReg >= 6) && (curReg <= 9))
+ actionDisplay(1330, 29, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+ else if ((curReg >= 11) && (curReg <= 14))
+ actionDisplay(1330, 31, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+ else if ((curReg >= 16) && (curReg <= 19))
+ actionDisplay(1330, 30, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+ else {
+ switch (curReg) {
+ case 0:
+ actionDisplay(1330, 2, 159, 134, 1, 200, 0, 7, 0, 105, 105);
+ break;
+ case 5:
+ actionDisplay(1330, 25, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+ break;
+ case 10:
+ actionDisplay(1330, 27, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+ break;
+ case 15:
+ actionDisplay(1330, 26, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+ break;
+ case 20:
+ actionDisplay(1330, 28, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+ break;
+ case 21:
+ actionDisplay(1330, 24, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+ break;
+ default:
+ break;
+ }
+ }
+ }
+
+ if (arg1 != 1)
+ return;
+
+ for (int i = 0; i <= 7; i++) {
+ if (_gameBoardSide[2]._outpostStation[i].isIn(pt)) {
+ switch (_gameBoardSide[2]._outpostStation[i]._cardId) {
+ case 0:
+ actionDisplay(1330, 11, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+ break;
+ case 1:
+ actionDisplay(1330, 54, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+ break;
+ default:
+ actionDisplay(1330, 34, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+ break;
+ }
+ return;
+ }
+ if (_gameBoardSide[0]._outpostStation[i].isIn(pt)) {
+ switch (_gameBoardSide[0]._outpostStation[i]._cardId) {
+ case 0:
+ actionDisplay(1330, 11, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+ break;
+ default:
+ actionDisplay(1330, 1, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+ break;
+ }
+ return;
+ }
+ if (_gameBoardSide[1]._outpostStation[i].isIn(pt)) {
+ switch (_gameBoardSide[1]._outpostStation[i]._cardId) {
+ case 0:
+ actionDisplay(1330, 146, 300, 99, 1, 136, 0, 7, 0, 117, 117);
+ break;
+ default:
+ actionDisplay(1330, 144, 300, 99, 1, 136, 0, 7, 0, 117, 117);
+ break;
+ }
+ return;
+ }
+ if (_gameBoardSide[3]._outpostStation[i].isIn(pt)) {
+ switch (_gameBoardSide[3]._outpostStation[i]._cardId) {
+ case 0:
+ actionDisplay(1330, 147, 20, 99, 1, 136, 0, 7, 0, 172, 172);
+ break;
+ default:
+ actionDisplay(1330, 145, 20, 99, 1, 136, 0, 7, 0, 172, 172);
+ break;
+ }
+ return;
+ }
+ }
+
+ if (_gameBoardSide[2]._delayCard.isIn(pt)) {
+ // The original uses _gameBoardSide[0], which is obviously a bug.
+ if (_gameBoardSide[2]._delayCard._cardId != 0)
+ actionDisplay(1330, 39, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+ else
+ actionDisplay(1330, 11, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+
+ return;
+ }
+ if (_gameBoardSide[3]._delayCard.isIn(pt)) {
+ if (_gameBoardSide[3]._delayCard._cardId != 0)
+ actionDisplay(1330, 145, 20, 99, 1, 136, 0, 7, 0, 172, 172);
+ else
+ actionDisplay(1330, 147, 20, 99, 1, 136, 0, 7, 0, 172, 172);
+
+ return;
+ }
+ if (_gameBoardSide[1]._delayCard.isIn(pt)) {
+ if (_gameBoardSide[1]._delayCard._cardId != 0)
+ actionDisplay(1330, 144, 300, 99, 1, 136, 0, 7, 0, 117, 117);
+ else
+ actionDisplay(1330, 146, 300, 99, 1, 136, 0, 7, 0, 117, 117);
+
+ return;
+ }
+ if (_gameBoardSide[0]._delayCard.isIn(pt)) {
+ if (_gameBoardSide[0]._delayCard._cardId != 0)
+ actionDisplay(1330, 1, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+ else
+ actionDisplay(1330, 11, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+
+ return;
+ }
+ if (_gameBoardSide[3]._emptyStationPos.isIn(pt)) {
+ actionDisplay(1330, 147, 20, 99, 1, 136, 0, 7, 0, 172, 172);
+ return;
+ }
+ if (_gameBoardSide[1]._emptyStationPos.isIn(pt)) {
+ actionDisplay(1330, 146, 300, 99, 1, 136, 0, 7, 0, 117, 117);
+ return;
+ }
+ if (_gameBoardSide[0]._emptyStationPos.isIn(pt)) {
+ actionDisplay(1330, 11, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+ return;
+ }
+
+ if (_helpIcon._bounds.contains(pt)) {
+ showOptionsDialog();
+ return;
+ }
+
+ if (_discardPile.isIn(pt))
+ actionDisplay(1330, 9, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+ else if (_stockCard.isIn(pt))
+ actionDisplay(1330, 5, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+ else {
+ switch (curReg) {
+ case 0:
+ actionDisplay(1330, 3, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+ break;
+ case 6:
+ // no break on purpose
+ case 7:
+ // no break on purpose
+ case 8:
+ // no break on purpose
+ case 9:
+ actionDisplay(1330, 145, 20, 99, 1, 136, 0, 7, 0, 172, 172);
+ break;
+ case 10:
+ actionDisplay(1330, 147, 20, 99, 1, 136, 0, 7, 0, 172, 172);
+ break;
+ case 11:
+ // no break on purpose
+ case 12:
+ // no break on purpose
+ case 13:
+ // no break on purpose
+ case 14:
+ actionDisplay(1330, 1, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+ break;
+ case 16:
+ // no break on purpose
+ case 17:
+ // no break on purpose
+ case 18:
+ // no break on purpose
+ case 19:
+ actionDisplay(1330, 144, 300, 99, 1, 136, 0, 7, 0, 117, 117);
+ break;
+ case 20:
+ actionDisplay(1330, 146, 300, 99, 1, 136, 0, 7, 0, 117, 117);
+ break;
+ default:
+ actionDisplay(1330, 11, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+ break;
+ }
+ }
+}
+
+void Scene1337::handlePlayer0() {
+ if (_gameBoardSide[0]._delayCard._cardId != 0) {
+ switch (_gameBoardSide[0]._delayCard._cardId) {
+ case 10:
+ //No break on purpose
+ case 12:
+ //No break on purpose
+ case 15:
+ //No break on purpose
+ case 17:
+ //No break on purpose
+ case 18:
+ //No break on purpose
+ case 19:
+ //No break on purpose
+ case 20:
+ //No break on purpose
+ case 21:
+ discardCard(&_gameBoardSide[0]._delayCard);
+ return;
+ default:
+ for (int i = 0; i <= 3; i++) {
+ if (checkAntiDelayCard(_gameBoardSide[0]._delayCard._cardId, _gameBoardSide[0]._handCard[i]._cardId)) {
+ playAntiDelayCard(&_gameBoardSide[0]._handCard[i], &_gameBoardSide[0]._delayCard);
+ return;
+ }
+ }
+
+ break;
+ }
+ }
+
+ for (int i = 0; i <= 3; i++) {
+ int tmpVal = getStationId(0, i);
+
+ if (tmpVal != -1) {
+ bool stationAlreadyPresentFl = false;
+ for (int j = 0; j <= 7; j++) {
+ if (_gameBoardSide[0]._outpostStation[j]._cardId == _gameBoardSide[0]._handCard[tmpVal]._cardId) {
+ stationAlreadyPresentFl = true;
+ break;
+ }
+ }
+
+ if (!stationAlreadyPresentFl) {
+ for (int j = 0; j <= 7; j++) {
+ if ((_gameBoardSide[0]._outpostStation[j]._cardId == 1) && !isStopConstructionCard(_gameBoardSide[0]._delayCard._cardId)) {
+ int stationCount = 0;
+ for (int k = 0; k <= 7; k++) {
+ if ((_gameBoardSide[0]._outpostStation[k]._cardId > 1) && (_gameBoardSide[0]._outpostStation[k]._cardId <= 9)) {
+ ++stationCount;
+ }
+ }
+
+ if (stationCount == 7)
+ _winnerId = 0;
+
+ playStationCard(&_gameBoardSide[0]._handCard[tmpVal], &_gameBoardSide[0]._outpostStation[j]);
+ return;
+ }
+ }
+ }
+ }
+ }
+
+ int tmpVal = findPlatformCardInHand(0);
+
+ if (tmpVal != -1) {
+ for (int i = 0; i <= 7; i++) {
+ if ((_gameBoardSide[0]._outpostStation[i]._cardId == 0) && !isStopConstructionCard(_gameBoardSide[0]._delayCard._cardId)) {
+ playPlatformCard(&_gameBoardSide[0]._handCard[tmpVal], &_gameBoardSide[0]._outpostStation[i]);
+ return;
+ }
+ }
+ }
+
+ int meteorCardId = findMeteorCardInHand(0);
+ if (meteorCardId != -1) {
+ for (int i = 0; i <= 7; i++) {
+ if (_gameBoardSide[2]._outpostStation[i]._cardId != 0) {
+ playCentralOutpostCard(&_gameBoardSide[0]._handCard[meteorCardId], 2);
+ return;
+ }
+ }
+ }
+
+ int thieftId = findThieftCardInHand(0);
+ if (thieftId != -1) {
+ if ( (_gameBoardSide[2]._handCard[0]._cardId != 0)
+ || (_gameBoardSide[2]._handCard[1]._cardId != 0)
+ || (_gameBoardSide[2]._handCard[2]._cardId != 0)
+ || (_gameBoardSide[2]._handCard[3]._cardId != 0) ) {
+ playThieftCard(0, &_gameBoardSide[0]._handCard[thieftId], 2);
+ return;
+ }
+ }
+
+ for (int i = 0; i <= 3; i++) {
+ if ((isDelayCard(_gameBoardSide[0]._handCard[i]._cardId) != -1)
+ && (_gameBoardSide[2]._delayCard._cardId == 0)
+ && isAttackPossible(2, _gameBoardSide[0]._handCard[i]._cardId)) {
+ playDelayCard(&_gameBoardSide[0]._handCard[i], &_gameBoardSide[2]._delayCard);
+ return;
+ }
+ }
+
+ for (int i = 0; i <= 3; i++) {
+ if ((getStationCardId(_gameBoardSide[0]._handCard[i]._cardId) != -1)
+ && (_gameBoardSide[2]._delayCard._cardId == 0)
+ && isAttackPossible(2, _gameBoardSide[0]._handCard[i]._cardId)) {
+ playDelayCard(&_gameBoardSide[0]._handCard[i], &_gameBoardSide[2]._delayCard);
+ return;
+ }
+ }
+
+ meteorCardId = findMeteorCardInHand(0);
+ int victimId = getPlayerWithOutpost(0);
+
+ if ((meteorCardId != -1) && (victimId != -1)) {
+ playCentralOutpostCard(&_gameBoardSide[0]._handCard[meteorCardId], victimId);
+ return;
+ }
+
+ thieftId = findThieftCardInHand(0);
+ if (thieftId != -1) {
+ if ( (_gameBoardSide[1]._handCard[0]._cardId != 0)
+ || (_gameBoardSide[1]._handCard[1]._cardId != 0)
+ || (_gameBoardSide[1]._handCard[2]._cardId != 0)
+ || (_gameBoardSide[1]._handCard[3]._cardId != 0) ) {
+ playThieftCard(0, &_gameBoardSide[0]._handCard[thieftId], 1);
+ return;
+ }
+ }
+
+ for (int i = 0; i <= 3; i++) {
+ if (getStationCardId(_gameBoardSide[0]._handCard[i]._cardId) != -1) {
+ if ((_gameBoardSide[1]._delayCard._cardId == 0) && isAttackPossible(1, _gameBoardSide[0]._handCard[i]._cardId)) {
+ playDelayCard(&_gameBoardSide[0]._handCard[i], &_gameBoardSide[1]._delayCard);
+ return;
+ }
+
+ if ((_gameBoardSide[3]._delayCard._cardId == 0) && isAttackPossible(3, _gameBoardSide[0]._handCard[i]._cardId)) {
+ playDelayCard(&_gameBoardSide[0]._handCard[i], &_gameBoardSide[3]._delayCard);
+ return;
+ }
+ }
+ }
+
+ for (int i = 0; i <= 3; i++) {
+ tmpVal = isDelayCard(_gameBoardSide[0]._handCard[i]._cardId);
+ if (tmpVal != -1) {
+ if ((_gameBoardSide[1]._delayCard._cardId == 0) && isAttackPossible(1, _gameBoardSide[0]._handCard[i]._cardId)) {
+ playDelayCard(&_gameBoardSide[0]._handCard[i], &_gameBoardSide[1]._delayCard);
+ return;
+ }
+
+ if ((_gameBoardSide[3]._delayCard._cardId == 0) && isAttackPossible(3, _gameBoardSide[0]._handCard[i]._cardId)) {
+ playDelayCard(&_gameBoardSide[0]._handCard[i], &_gameBoardSide[3]._delayCard);
+ return;
+ }
+ }
+ }
+
+ handlePlayer01Discard(0);
+}
+
+void Scene1337::handlePlayer1() {
+ if (this->_gameBoardSide[1]._delayCard._cardId != 0) {
+ switch (_gameBoardSide[1]._delayCard._cardId) {
+ case 10:
+ // No break on purpose
+ case 12:
+ // No break on purpose
+ case 15:
+ // No break on purpose
+ case 17:
+ // No break on purpose
+ case 18:
+ // No break on purpose
+ case 19:
+ // No break on purpose
+ case 20:
+ // No break on purpose
+ case 21:
+ discardCard(&_gameBoardSide[1]._delayCard);
+ return;
+ default:
+ for (int i = 0; i <= 3; i++) {
+ if (checkAntiDelayCard(_gameBoardSide[1]._delayCard._cardId, _gameBoardSide[1]._handCard[i]._cardId)) {
+ playAntiDelayCard(&_gameBoardSide[1]._handCard[i], &_gameBoardSide[1]._delayCard);
+ return;
+ }
+ }
+ break;
+ }
+ }
+
+ for (int i = 0; i <= 3; i++) {
+ int tmpIndx = getStationId(1, i);
+ if (tmpIndx == -1)
+ break;
+
+ int tmpVal = 0;
+ for (int j = 0; j <= 7; j++) {
+ if (_gameBoardSide[1]._outpostStation[j]._cardId == _gameBoardSide[1]._handCard[tmpIndx]._cardId) {
+ tmpVal = 1;
+ break;
+ }
+ }
+
+ if (tmpVal == 0)
+ break;
+
+ for (int j = 0; j <= 7; j++) {
+ if ((_gameBoardSide[1]._outpostStation[j]._cardId == 1) && !isStopConstructionCard(_gameBoardSide[1]._delayCard._cardId)) {
+ int stationCount = 0;
+ for (int k = 0; k <= 7; k++) {
+ if ((_gameBoardSide[1]._outpostStation[k]._cardId > 1) && (_gameBoardSide[1]._outpostStation[k]._cardId <= 9))
+ ++stationCount;
+ }
+
+ if (stationCount == 7)
+ _winnerId = 1;
+
+ playStationCard(&_gameBoardSide[1]._handCard[tmpIndx], &_gameBoardSide[1]._outpostStation[j]);
+ return;
+ }
+ }
+ }
+
+ int normalCardId = findPlatformCardInHand(1);
+ if (normalCardId != -1) {
+ for (int i = 0; i <= 7; i++) {
+ if ((_gameBoardSide[1]._outpostStation[i]._cardId == 0) && !isStopConstructionCard(_gameBoardSide[1]._delayCard._cardId)) {
+ playPlatformCard(&_gameBoardSide[1]._handCard[normalCardId], &_gameBoardSide[1]._outpostStation[i]);
+ return;
+ }
+ }
+ }
+
+ int meterorCardId = findMeteorCardInHand(1);
+ int victimId = getPlayerWithOutpost(1);
+
+ if ((meterorCardId != -1) && (victimId != -1)) {
+ playCentralOutpostCard(&_gameBoardSide[1]._handCard[meterorCardId], victimId);
+ return;
+ }
+
+ int thieftId = findThieftCardInHand(1);
+ if (thieftId != -1) {
+ int playerIdFound = -1;
+ int rndVal = R2_GLOBALS._randomSource.getRandomNumber(3);
+ for (int i = 0; i <= 3; i++) {
+ if (rndVal != 1) {
+ if ( (_gameBoardSide[rndVal]._handCard[0]._cardId != 0)
+ || (_gameBoardSide[rndVal]._handCard[1]._cardId != 0)
+ || (_gameBoardSide[rndVal]._handCard[2]._cardId != 0)
+ || (_gameBoardSide[rndVal]._handCard[3]._cardId != 0)) {
+ playerIdFound = rndVal;
+ break;
+ }
+ }
+ // The original was only updating in the rndVal block,
+ // which was a bug as the checks were stopping at this point
+ rndVal--;
+ if (rndVal < 0)
+ rndVal = 3;
+ }
+
+ if (playerIdFound != -1) {
+ playThieftCard(1, &_gameBoardSide[1]._handCard[thieftId], playerIdFound);
+ return;
+ }
+ }
+
+ for (int i = 0; i <= 3; i++) {
+ int tmpVal = isDelayCard(_gameBoardSide[1]._handCard[i]._cardId);
+ if (tmpVal != -1) {
+ victimId = -1;
+ int rndVal = R2_GLOBALS._randomSource.getRandomNumber(3);
+
+ for (int j = 0; j <= 3; j++) {
+ if (rndVal != 1) {
+ if ((_gameBoardSide[rndVal]._delayCard._cardId == 0) && isAttackPossible(rndVal, _gameBoardSide[1]._handCard[i]._cardId))
+ victimId = rndVal;
+ }
+
+ if (victimId != -1) {
+ playDelayCard(&_gameBoardSide[1]._handCard[i], &_gameBoardSide[victimId]._delayCard);
+ return;
+ } else {
+ rndVal--;
+ if (rndVal < 0)
+ rndVal = 3;
+ }
+ }
+ }
+ }
+
+ for (int j = 0; j <= 3; j++) {
+ if (getStationCardId(_gameBoardSide[1]._handCard[j]._cardId) != -1) {
+ victimId = -1;
+ int rndVal = R2_GLOBALS._randomSource.getRandomNumber(3);
+ for (int l = 0; l <= 3; l++) {
+ if (rndVal != 1) {
+ if ((_gameBoardSide[rndVal]._delayCard._cardId == 0) && (_gameBoardSide[1]._handCard[j]._cardId == 1))
+ victimId = rndVal;
+ }
+ if (victimId != -1) {
+ playDelayCard(&_gameBoardSide[1]._handCard[j], &_gameBoardSide[victimId]._delayCard);
+ return;
+ } else {
+ rndVal--;
+ if (rndVal < 0)
+ rndVal = 3;
+ }
+ }
+ }
+ }
+
+ handlePlayer01Discard(1);
+}
+
+void Scene1337::handlePlayer3() {
+ if (_gameBoardSide[3]._delayCard._cardId != 0) {
+ switch (_gameBoardSide[3]._delayCard._cardId) {
+ case 10:
+ // No break on purpose
+ case 12:
+ // No break on purpose
+ case 15:
+ // No break on purpose
+ case 17:
+ // No break on purpose
+ case 18:
+ // No break on purpose
+ case 19:
+ // No break on purpose
+ case 20:
+ // No break on purpose
+ case 21:
+ discardCard(&_gameBoardSide[3]._delayCard);
+ return;
+ default:
+ for (int i = 0; i <= 3; i++) {
+ if (checkAntiDelayCard(_gameBoardSide[3]._delayCard._cardId, _gameBoardSide[3]._handCard[i]._cardId)) {
+ playAntiDelayCard(&_gameBoardSide[3]._handCard[i], &_gameBoardSide[3]._delayCard);
+ return;
+ }
+ }
+ break;
+ }
+ }
+
+ int randIndx = R2_GLOBALS._randomSource.getRandomNumber(3);
+ if (_gameBoardSide[3]._handCard[randIndx]._cardId == 1) {
+ // Station Card
+ for (int i = 0; i <= 7; i++) {
+ if ((_gameBoardSide[3]._outpostStation[i]._cardId == 0) && !isStopConstructionCard(_gameBoardSide[3]._delayCard._cardId)) {
+ playPlatformCard(&_gameBoardSide[3]._handCard[randIndx], &_gameBoardSide[3]._outpostStation[i]);
+ return;
+ }
+ }
+ } else if (_gameBoardSide[3]._handCard[randIndx]._cardId <= 9) {
+ // Outpost Card
+ for (int i = 0; i <= 7; i++) {
+ if (_gameBoardSide[3]._outpostStation[i]._cardId == _gameBoardSide[3]._handCard[randIndx]._cardId) {
+ discardCard(&_gameBoardSide[3]._handCard[randIndx]);
+ return;
+ }
+ }
+
+ for (int i = 0; i <= 7; i++) {
+ if ((_gameBoardSide[3]._outpostStation[i]._cardId == 1) && !isStopConstructionCard(_gameBoardSide[3]._delayCard._cardId)) {
+ int stationCount = 0;
+ for (int j = 0; j <= 7; j++) {
+ if ((_gameBoardSide[3]._outpostStation[j]._cardId > 1) && (_gameBoardSide[3]._outpostStation[j]._cardId <= 9))
+ ++stationCount;
+ }
+
+ if (stationCount == 7)
+ _winnerId = 3;
+
+ playStationCard(&_gameBoardSide[3]._handCard[randIndx], &_gameBoardSide[3]._outpostStation[i]);
+ return;
+ }
+ }
+ } else if (_gameBoardSide[3]._handCard[randIndx]._cardId == 13) {
+ // Meteor Card
+ int victimId = getPlayerWithOutpost(3);
+
+ if (victimId != -1) {
+ playCentralOutpostCard(&_gameBoardSide[3]._handCard[randIndx], victimId);
+ return;
+ }
+ } else if (_gameBoardSide[3]._handCard[randIndx]._cardId == 25) {
+ // Thief card
+ int victimId = -1;
+ int tmpRandIndx = R2_GLOBALS._randomSource.getRandomNumber(3);
+
+ for (int i = 0; i <= 3; i++) {
+ if ( (tmpRandIndx != 3)
+ && ( (_gameBoardSide[tmpRandIndx]._handCard[0]._cardId != 0)
+ || (_gameBoardSide[tmpRandIndx]._handCard[1]._cardId != 0)
+ || (_gameBoardSide[tmpRandIndx]._handCard[2]._cardId != 0)
+ || (_gameBoardSide[tmpRandIndx]._handCard[3]._cardId != 0) )) {
+ victimId = tmpRandIndx;
+ break;
+ }
+
+ ++tmpRandIndx;
+ if (tmpRandIndx > 3)
+ tmpRandIndx = 0;
+ }
+
+ if (victimId != -1) {
+ playThieftCard(3, &_gameBoardSide[3]._handCard[randIndx], victimId);
+ return;
+ }
+ } else {
+ switch (_gameBoardSide[3]._handCard[randIndx]._cardId) {
+ case 10:
+ // No break on purpose
+ case 11:
+ // No break on purpose
+ case 12:
+ // No break on purpose
+ case 14:
+ // No break on purpose
+ case 15:
+ // No break on purpose
+ case 16:
+ // No break on purpose
+ case 17:
+ // No break on purpose
+ case 18:
+ // No break on purpose
+ case 19:
+ // No break on purpose
+ case 20:
+ // No break on purpose
+ case 21:
+ // No break on purpose
+ case 24: {
+ int victimId = -1;
+ int tmpRandIndx = R2_GLOBALS._randomSource.getRandomNumber(3);
+
+ for (int i = 0; i <= 3; i++) {
+ if (tmpRandIndx != 3) {
+ if ((_gameBoardSide[tmpRandIndx]._delayCard._cardId == 0)
+ && isAttackPossible(tmpRandIndx, _gameBoardSide[3]._handCard[randIndx]._cardId))
+ victimId = tmpRandIndx;
+ }
+
+ ++tmpRandIndx;
+ if (tmpRandIndx > 3)
+ tmpRandIndx = 0;
+
+ if (victimId != -1)
+ break;
+ }
+
+ if (victimId != -1) {
+ // Useless second identical check skipped
+ playDelayCard(&_gameBoardSide[3]._handCard[randIndx], &_gameBoardSide[victimId]._delayCard);
+ return;
+ }
+ }
+ default:
+ break;
+ }
+ }
+
+ discardCard(&_gameBoardSide[3]._handCard[randIndx]);
+}
+
+void Scene1337::handleAutoplayPlayer2() {
+ if (getStationCardId(this->_gameBoardSide[2]._delayCard._cardId) == -1)
+ _delayedFunction = &Scene1337::handlePlayer2;
+ else
+ discardCard(&_gameBoardSide[2]._delayCard);
+}
+
+void Scene1337::handlePlayer2() {
+ _selectedCard._stationPos = g_globals->_events._mousePos;
+
+ if (R2_GLOBALS._v57810 == 200) {
+ // Hand
+ int i;
+ for (i = 0; i < 4; i++) {
+ if ((_gameBoardSide[2]._handCard[i].isIn(_selectedCard._stationPos)) && (_gameBoardSide[2]._handCard[i]._cardId != 0)) {
+ Card *handcard = &_gameBoardSide[2]._handCard[i];
+ _selectedCard._cardId = handcard->_cardId;
+ _selectedCard._stationPos = handcard->_stationPos;
+ //warning("_selectedCard._actorName = handcard->_actorName;");
+ //warning("_selectedCard._fieldE = handcard->_fieldE;");
+ //warning("_selectedCard._field10 = handcard->_field10;");
+ //warning("_selectedCard._field12 = handcard->_field12;");
+ //warning("_selectedCard._field14 = handcard->_field14;");
+ //warning("_selectedCard._field16 = handcard->_field16;");
+ _selectedCard._sceneRegionId = handcard->_sceneRegionId;
+ _selectedCard._position = handcard->_position;
+ _selectedCard._yDiff = handcard->_yDiff;
+ _selectedCard._bounds = handcard->_bounds;
+ _selectedCard._resNum = handcard->_resNum;
+ _selectedCard._lookLineNum = handcard->_lookLineNum;
+ _selectedCard._talkLineNum = handcard->_talkLineNum;
+ _selectedCard._useLineNum = handcard->_useLineNum;
+ _selectedCard._action = handcard->_action;
+ //warning("_selectedCard._field0 = handcard->_field0;");
+ _selectedCard._card._updateStartFrame = handcard->_card._updateStartFrame;
+ _selectedCard._card._walkStartFrame = handcard->_card._walkStartFrame;
+ _selectedCard._card._oldPosition = handcard->_card._oldPosition;
+ _selectedCard._card._percent = handcard->_card._percent;
+ _selectedCard._card._priority = handcard->_card._priority;
+ _selectedCard._card._angle = handcard->_card._angle;
+ _selectedCard._card._flags = handcard->_card._flags;
+ _selectedCard._card._xe = handcard->_card._xe;
+ _selectedCard._card._xs = handcard->_card._xs;
+ _selectedCard._card._paneRects[0] = handcard->_card._paneRects[0];
+ _selectedCard._card._paneRects[1] = handcard->_card._paneRects[1];
+ _selectedCard._card._visage = handcard->_card._visage;
+ _selectedCard._card._objectWrapper = handcard->_card._objectWrapper;
+ _selectedCard._card._strip = handcard->_card._strip;
+ _selectedCard._card._animateMode = handcard->_card._animateMode;
+ _selectedCard._card._frame = handcard->_card._frame;
+ _selectedCard._card._endFrame = handcard->_card._endFrame;
+ _selectedCard._card._loopCount = handcard->_card._loopCount;
+ _selectedCard._card._frameChange = handcard->_card._frameChange;
+ _selectedCard._card._numFrames = handcard->_card._numFrames;
+ _selectedCard._card._regionIndex = handcard->_card._regionIndex;
+ _selectedCard._card._mover = handcard->_card._mover;
+ _selectedCard._card._moveDiff = handcard->_card._moveDiff;
+ _selectedCard._card._moveRate = handcard->_card._moveRate;
+ _selectedCard._card._actorDestPos = handcard->_card._actorDestPos;
+ _selectedCard._card._endAction = handcard->_card._endAction;
+ _selectedCard._card._regionBitList = handcard->_card._regionBitList;
+ // _selectedCard._object1._actorName = handcard->_object1._actorName;
+ //warning("_selectedCard._card._fieldE = handcard->_card._fieldE;");
+ //warning("_selectedCard._card._field10 = handcard->_card._field10;");
+ //warning("_selectedCard._card._field12 = handcard->_card._field12;");
+ //warning("_selectedCard._card._field14 = handcard->_card._field14;");
+ //warning("_selectedCard._card._field16 = handcard->_card._field16;");
+
+ _gameBoardSide[2]._handCard[i]._cardId = 0;
+ _gameBoardSide[2]._handCard[i]._card.remove();
+ break;
+ }
+ }
+
+ if (i == 4) {
+ handleClick(1, _selectedCard._stationPos);
+ handleAutoplayPlayer2();
+ return;
+ } else {
+ setCursorData(1332, _selectedCard._card._strip, _selectedCard._card._frame);
+ R2_GLOBALS._sceneObjects->draw();
+ }
+ } else if (R2_GLOBALS._v57810 == 300) {
+ // Eye
+ handleClick(3, _selectedCard._stationPos);
+ handleAutoplayPlayer2();
+ return;
+ } else {
+ // The original code is calling a function full of dead code.
+ // Only this message remains after a cleanup.
+ MessageDialog::show(WRONG_ANSWER_MSG, OK_BTN_STRING);
+ //
+ handleAutoplayPlayer2();
+ return;
+ }
+
+ Event event;
+ bool found;
+ for (;;) {
+ if ( ((g_globals->_events.getEvent(event, EVENT_BUTTON_DOWN)) && (event.btnState == BTNSHIFT_RIGHT))
+ || (g_globals->_events.getEvent(event, EVENT_KEYPRESS)) ){
+ _selectedCard._stationPos = g_globals->_events._mousePos;
+ found = false;
+
+ for (int i = 0; i <= 3; i ++) {
+ if (_gameBoardSide[2]._handCard[i].isIn(Common::Point(_selectedCard._stationPos.x + 12, _selectedCard._stationPos.y + 12))) {
+ if (_gameBoardSide[2]._handCard[i]._cardId == 0) {
+ _gameBoardSide[2]._handCard[i]._cardId = _selectedCard._cardId;
+ _gameBoardSide[2]._handCard[i]._card.postInit();
+ _gameBoardSide[2]._handCard[i]._card.hide();
+ _gameBoardSide[2]._handCard[i]._card.setVisage(1332);
+ _gameBoardSide[2]._handCard[i]._card.setPosition(_gameBoardSide[2]._handCard[i]._stationPos, 0);
+ _gameBoardSide[2]._handCard[i]._card.fixPriority(170);
+ setAnimationInfo(&_gameBoardSide[2]._handCard[i]);
+ setCursorData(5, 1, 4);
+ _currentPlayerNumb--;
+ _showPlayerTurn = false;
+ handleNextTurn();
+ return;
+ } else {
+ actionDisplay(1330, 127, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+ found = true;
+ }
+ break;
+ }
+ }
+
+ if (!found) {
+ if (_discardPile.isIn(Common::Point(_selectedCard._stationPos.x + 12, _selectedCard._stationPos.y + 12))) {
+ discardCard(&_selectedCard);
+ return;
+ } else if (_selectedCard._cardId == 1) {
+ bool isInCardFl = false;
+ int i;
+ for (i = 0; i <= 7; i++) {
+ if (_gameBoardSide[2]._outpostStation[i].isIn(Common::Point(_selectedCard._stationPos.x + 12, _selectedCard._stationPos.y + 12))) {
+ isInCardFl = true;
+ break;
+ }
+ }
+
+ if ((isInCardFl) && (_gameBoardSide[2]._outpostStation[i]._cardId == 0)) {
+ if (isDelayCard(_gameBoardSide[2]._delayCard._cardId) != -1) {
+ actionDisplay(1330, 55, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+ } else {
+ playPlatformCard(&_selectedCard, &_gameBoardSide[2]._outpostStation[i]);
+ return;
+ }
+ } else {
+ actionDisplay(1330, 56, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+ }
+ } else if (_selectedCard._cardId <= 9) {
+ bool isInCardFl = false;
+ int i;
+ for (i = 0; i <= 7; i++) {
+ if (_gameBoardSide[2]._outpostStation[i].isIn(Common::Point(_selectedCard._stationPos.x + 12, _selectedCard._stationPos.y + 12))) {
+ isInCardFl = true;
+ break;
+ }
+ }
+ if ((isInCardFl) && (_gameBoardSide[2]._outpostStation[i]._cardId == 1)) {
+ isInCardFl = false;
+ for (int j = 0; j <= 7; j++) {
+ if (_selectedCard._cardId == _gameBoardSide[2]._outpostStation[j]._cardId) {
+ isInCardFl = true;
+ break;
+ }
+ }
+ if (isInCardFl) {
+ // This station is already in place
+ actionDisplay(1330, 34, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+ } else if (isDelayCard(_gameBoardSide[2]._delayCard._cardId) != -1) {
+ // You must eliminate your delay before you can play a station
+ actionDisplay(1330, 35, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+ } else {
+ int stationCount = 0;
+ for (int k = 0; k <= 7; k++) {
+ if ((_gameBoardSide[2]._outpostStation[k]._cardId > 1) && (_gameBoardSide[2]._outpostStation[k]._cardId <= 9))
+ ++stationCount;
+ }
+
+ if (stationCount == 7)
+ _winnerId = 2;
+
+ playStationCard(&_selectedCard, &_gameBoardSide[2]._outpostStation[i]);
+ return;
+ }
+ } else {
+ actionDisplay(1330, 37, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+ }
+ } else if ((_selectedCard._cardId == 26) || (_selectedCard._cardId == 30) ||(_selectedCard._cardId == 32) || (_selectedCard._cardId == 28)) {
+ // Check anti-delay card (26 = Diplomacy, 28 = Innovation, 30 = Cure, 32 = Agreement)
+ if (_gameBoardSide[2]._delayCard.isIn(Common::Point(_selectedCard._stationPos.x + 12, _selectedCard._stationPos.y + 12))) {
+ actionDisplay(1330, 42, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+ } else if (checkAntiDelayCard(_gameBoardSide[2]._delayCard._cardId, _selectedCard._cardId)) {
+ playAntiDelayCard(&_selectedCard, &_gameBoardSide[2]._delayCard);
+ return;
+ } else {
+ if (_gameBoardSide[2]._delayCard._cardId != 0) {
+ switch (_gameBoardSide[2]._delayCard._cardId) {
+ case 11:
+ actionDisplay(1330, 68, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+ break;
+ case 14:
+ actionDisplay(1330, 80, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+ break;
+ case 16:
+ actionDisplay(1330, 84, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+ break;
+ case 24:
+ actionDisplay(1330, 96, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+ break;
+ default:
+ break;
+ }
+ } else {
+ actionDisplay(1330, 41, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+ }
+ }
+ } else if ((getStationCardId(_selectedCard._cardId) == -1) && (isDelayCard(_selectedCard._cardId) == -1)) {
+ if (_selectedCard._cardId == 13) {
+ // Meteor Card
+ if (_gameBoardSide[0]._emptyStationPos.isIn(Common::Point(_selectedCard._stationPos.x + 12, _selectedCard._stationPos.y + 12))) {
+ for (int k = 0; k <= 7; k++) {
+ if (_gameBoardSide[0]._outpostStation[k]._cardId != 0) {
+ playCentralOutpostCard(&_selectedCard, 0);
+ return;
+ }
+ }
+ actionDisplay(1330, 74, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+ } else if (_gameBoardSide[3]._emptyStationPos.isIn(Common::Point(_selectedCard._stationPos.x + 12, _selectedCard._stationPos.y + 12))) {
+ for (int k = 0; k <= 7; k++) {
+ if (_gameBoardSide[3]._outpostStation[k]._cardId != 0) {
+ playCentralOutpostCard(&_selectedCard, 3);
+ return;
+ }
+ }
+ actionDisplay(1330, 74, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+ } else if (_gameBoardSide[1]._emptyStationPos.isIn(Common::Point(_selectedCard._stationPos.x + 12, _selectedCard._stationPos.y + 12))) {
+ for (int k = 0; k <= 7; k++) {
+ if (_gameBoardSide[1]._outpostStation[k]._cardId == 0) {
+ playCentralOutpostCard(&_selectedCard, 1);
+ return;
+ }
+ }
+ actionDisplay(1330, 74, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+ } else {
+ actionDisplay(1330, 128, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+ }
+ } else if (_selectedCard._cardId == 25) {
+ // Thief card
+ if (_gameBoardSide[0]._emptyStationPos.isIn(Common::Point(_selectedCard._stationPos.x + 12, _selectedCard._stationPos.y + 12))) {
+ if ( (_gameBoardSide[0]._handCard[0]._cardId != 0)
+ || (_gameBoardSide[0]._handCard[1]._cardId != 0)
+ || (_gameBoardSide[0]._handCard[2]._cardId != 0)
+ || (_gameBoardSide[0]._handCard[3]._cardId != 0) ) {
+ int k;
+ for (k = 0; k <= 3; k++){
+ if (_gameBoardSide[2]._handCard[k]._cardId == 0)
+ break;
+ }
+ playThieftCard(2, &_gameBoardSide[2]._handCard[k], 0);
+ return;
+ } else {
+ actionDisplay(1330, 99, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+ }
+ } else if (_gameBoardSide[1]._emptyStationPos.isIn(Common::Point(_selectedCard._stationPos.x + 12, _selectedCard._stationPos.y + 12))) {
+ if ( (_gameBoardSide[1]._handCard[0]._cardId != 0)
+ || (_gameBoardSide[1]._handCard[1]._cardId != 0)
+ || (_gameBoardSide[1]._handCard[2]._cardId != 0)
+ || (_gameBoardSide[1]._handCard[3]._cardId != 0) ) {
+ int k;
+ for (k = 0; k <= 3; k++){
+ if (_gameBoardSide[2]._handCard[k]._cardId == 0)
+ break;
+ }
+ playThieftCard(2, &_gameBoardSide[2]._handCard[k], 1);
+ return;
+ } else {
+ actionDisplay(1330, 99, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+ }
+ }
+
+ if (_gameBoardSide[3]._emptyStationPos.isIn(Common::Point(_selectedCard._stationPos.x + 12, _selectedCard._stationPos.y + 12))) {
+ if ( (_gameBoardSide[3]._handCard[0]._cardId != 0)
+ || (_gameBoardSide[3]._handCard[1]._cardId != 0)
+ || (_gameBoardSide[3]._handCard[2]._cardId != 0)
+ || (_gameBoardSide[3]._handCard[3]._cardId != 0) ) {
+ int k;
+ for (k = 0; k <= 3; k++){
+ if (_gameBoardSide[2]._handCard[k]._cardId == 0)
+ break;
+ }
+ playThieftCard(2, &_gameBoardSide[2]._handCard[k], 3);
+ return;
+ } else {
+ actionDisplay(1330, 99, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+ }
+ } else {
+ actionDisplay(1330, 129, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+ }
+ } else if (_selectedCard._cardId == 29) {
+ // Interceptor cards are used to prevent collision
+ actionDisplay(1330, 136, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+ } else if (_selectedCard._cardId == 27) {
+ actionDisplay(1330, 137, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+ }
+ } else if (_gameBoardSide[0]._delayCard.isIn(Common::Point(_selectedCard._stationPos.x + 12, _selectedCard._stationPos.y + 12))) {
+ if (_gameBoardSide[0]._delayCard._cardId != 0) {
+ actionDisplay(1330, 15, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+ } else if (!isAttackPossible(0, _selectedCard._cardId)) {
+ switch (_selectedCard._cardId) {
+ case 10:
+ actionDisplay(1330, 66, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+ break;
+ case 12:
+ actionDisplay(1330, 70, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+ break;
+ case 15:
+ actionDisplay(1330, 82, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+ break;
+ case 17:
+ actionDisplay(1330, 86, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+ break;
+ case 18:
+ actionDisplay(1330, 88, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+ break;
+ case 19:
+ actionDisplay(1330, 90, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+ break;
+ case 20:
+ actionDisplay(1330, 92, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+ break;
+ case 21:
+ actionDisplay(1330, 94, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+ break;
+ default:
+ break;
+ }
+ } else {
+ playDelayCard(&_selectedCard, &_gameBoardSide[0]._delayCard);
+ return;
+ }
+ } else if (_gameBoardSide[3]._delayCard.isIn(Common::Point(_selectedCard._stationPos.x + 12, _selectedCard._stationPos.y + 12))) {
+ if (_gameBoardSide[3]._delayCard._cardId != 0) {
+ actionDisplay(1330, 17, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+ } else if (!isAttackPossible(3, _selectedCard._cardId)) {
+ switch (_selectedCard._cardId) {
+ case 10:
+ actionDisplay(1330, 66, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+ break;
+ case 12:
+ actionDisplay(1330, 70, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+ break;
+ case 15:
+ actionDisplay(1330, 82, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+ break;
+ case 17:
+ actionDisplay(1330, 86, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+ break;
+ case 18:
+ actionDisplay(1330, 88, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+ break;
+ case 19:
+ actionDisplay(1330, 90, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+ break;
+ case 20:
+ actionDisplay(1330, 92, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+ break;
+ case 21:
+ actionDisplay(1330, 94, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+ break;
+ default:
+ break;
+ }
+ } else {
+ playDelayCard(&_selectedCard, &_gameBoardSide[3]._delayCard);
+ return;
+ }
+ } else if (_gameBoardSide[1]._delayCard.isIn(Common::Point(_selectedCard._stationPos.x + 12, _selectedCard._stationPos.y + 12))) {
+ if (_gameBoardSide[1]._delayCard._cardId != 0) {
+ actionDisplay(1330, 19, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+ } else if (!isAttackPossible(1, _selectedCard._cardId)) {
+ switch (_selectedCard._cardId) {
+ case 10:
+ actionDisplay(1330, 66, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+ break;
+ case 12:
+ actionDisplay(1330, 70, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+ break;
+ case 15:
+ actionDisplay(1330, 82, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+ break;
+ case 17:
+ actionDisplay(1330, 86, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+ break;
+ case 18:
+ actionDisplay(1330, 88, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+ break;
+ case 19:
+ actionDisplay(1330, 90, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+ break;
+ case 20:
+ actionDisplay(1330, 92, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+ break;
+ case 21:
+ actionDisplay(1330, 94, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+ break;
+ default:
+ break;
+ }
+ } else {
+ playDelayCard(&_selectedCard, &_gameBoardSide[1]._delayCard);
+ return;
+ }
+ } else {
+ actionDisplay(1330, 38, 159, 10, 1, 200, 0, 7, 0, 154, 154);
+ }
+ }
+ } else {
+ g_globals->_scenePalette.signalListeners();
+ R2_GLOBALS._sceneObjects->draw();
+ g_globals->_events.delay(g_globals->_sceneHandler->_delayTicks);
+ }
+
+ g_globals->_sceneObjects->recurse(SceneHandler::dispatchObject);
+ }
+}
+
+void Scene1337::updateCursorId(int cursorId, bool updateFl) {
+ if ((R2_GLOBALS._v57709 != 0) || (R2_GLOBALS._v5780C != 0))
+ return;
+
+ R2_GLOBALS._mouseCursorId = cursorId;
+
+ if (updateFl) {
+ R2_GLOBALS._mouseCursorId++;
+
+ if (R2_GLOBALS._mouseCursorId < 1)
+ R2_GLOBALS._mouseCursorId = 2;
+
+ if (R2_GLOBALS._mouseCursorId > 2)
+ R2_GLOBALS._mouseCursorId = 1;
+ }
+
+ // The original was using an intermediate function to call setCursorData.
+ // It has been removed to improve readability
+ if (R2_GLOBALS._mouseCursorId == 1) {
+ R2_GLOBALS._v57810 = 200;
+ setCursorData(5, 1, 4);
+ } else if (R2_GLOBALS._mouseCursorId == 2) {
+ R2_GLOBALS._v57810 = 300;
+ setCursorData(5, 1, 5);
+ } else {
+ R2_GLOBALS._v57810 = 0;
+ setCursorData(5, 0, 0);
+ }
+}
+
+void Scene1337::setCursorData(int resNum, int rlbNum, int frameNum) {
+ _cursorCurRes = resNum;
+ _cursorCurStrip = rlbNum;
+ _cursorCurFrame = frameNum;
+
+ if (!frameNum) {
+ // Should be a hardcoded cursor displaying only a dot.
+ // FIXME: Use another cursor when possible
+ R2_GLOBALS._events.setCursor(CURSOR_CROSSHAIRS);
+ } else {
+ // TODO: The original was using some resource caching, which was useless and complex
+ // and which has been removed. This cursor behavior clearly made intensive use of this caching...
+ // We now have to find a way to cache these cursor pointers and avoid loading them multiple times per seconds
+ uint size;
+ byte *cursor = g_resourceManager->getSubResource(resNum, rlbNum, frameNum, &size);
+ // Decode the cursor
+ GfxSurface s = surfaceFromRes(cursor);
+
+ Graphics::Surface surface = s.lockSurface();
+ const byte *cursorData = (const byte *)surface.getPixels();
+ CursorMan.replaceCursor(cursorData, surface.w, surface.h, s._centroid.x, s._centroid.y, s._transColor);
+ s.unlockSurface();
+
+ DEALLOCATE(cursor);
+ }
+}
+
+void Scene1337::subD18F5() {
+ if (R2_GLOBALS._v57709 == 0)
+ // The original restores a copy of the default cursor (the hand), which isn't possible with our implementation
+ // We reload that cursor instead.
+ setCursorData(5, 1, 4);
+
+ ++R2_GLOBALS._v57709;
+}
+
+void Scene1337::subD1917() {
+ if (R2_GLOBALS._v57709 != 0) {
+ R2_GLOBALS._v57709--;
+ if (R2_GLOBALS._v57709 == 0) {
+ // The original was using an intermediate function to call setCursorData.
+ // It has been removed to improve readability
+ setCursorData(5, _cursorCurStrip, _cursorCurFrame);
+ }
+ }
+}
+
+void Scene1337::subD1940(bool flag) {
+ if (flag)
+ ++R2_GLOBALS._v5780C;
+ else if (R2_GLOBALS._v5780C != 0)
+ --R2_GLOBALS._v5780C;
+}
+
+void Scene1337::subD1975(int arg1, int arg2) {
+ // No implementation required in ScummVM: Mouse handling with tons of caching
+}
+
+void Scene1337::OptionsDialog::show() {
+ OptionsDialog *dlg = new OptionsDialog();
+ dlg->draw();
+
+ // Show the dialog
+ GfxButton *btn = dlg->execute(NULL);
+
+ // Figure out the new selected character
+ if (btn == &dlg->_quitGame)
+ R2_GLOBALS._sceneManager.changeScene(125);
+ else if (btn == &dlg->_restartGame)
+ R2_GLOBALS._sceneManager.changeScene(1330);
+
+ // Remove the dialog
+ dlg->remove();
+ delete dlg;
+}
+
+Scene1337::OptionsDialog::OptionsDialog() {
+ // Set the elements text
+ Scene1337 *scene = (Scene1337 *)R2_GLOBALS._sceneManager._scene;
+ _autoplay.setText(scene->_autoplay ? AUTO_PLAY_ON : AUTO_PLAY_OFF);
+ _restartGame.setText(START_NEW_CARD_GAME);
+ _quitGame.setText(QUIT_CARD_GAME);
+ _continueGame.setText(CONTINUE_CARD_GAME);
+
+ // Set position of the elements
+ _autoplay._bounds.moveTo(5, 2);
+ _restartGame._bounds.moveTo(5, _autoplay._bounds.bottom + 2);
+ _quitGame._bounds.moveTo(5, _restartGame._bounds.bottom + 2);
+ _continueGame._bounds.moveTo(5, _quitGame._bounds.bottom + 2);
+
+ // Add the items to the dialog
+ addElements(&_autoplay, &_restartGame, &_quitGame, &_continueGame, NULL);
+
+ // Set the dialog size and position
+ frame();
+ _bounds.collapse(-6, -6);
+ setCenter(160, 100);
+}
+
+GfxButton *Scene1337::OptionsDialog::execute(GfxButton *defaultButton) {
+ _gfxManager.activate();
+
+ // Event loop
+ GfxButton *selectedButton = NULL;
+
+ bool breakFlag = false;
+ while (!g_vm->shouldQuit() && !breakFlag) {
+ Event event;
+ while (g_globals->_events.getEvent(event) && !breakFlag) {
+ // Adjust mouse positions to be relative within the dialog
+ event.mousePos.x -= _gfxManager._bounds.left;
+ event.mousePos.y -= _gfxManager._bounds.top;
+
+ for (GfxElementList::iterator i = _elements.begin(); i != _elements.end(); ++i) {
+ if ((*i)->process(event))
+ selectedButton = static_cast<GfxButton *>(*i);
+ }
+
+ if (selectedButton == &_autoplay) {
+ // Toggle Autoplay
+ selectedButton = NULL;
+ Scene1337 *scene = (Scene1337 *)R2_GLOBALS._sceneManager._scene;
+ scene->_autoplay = !scene->_autoplay;
+
+ _autoplay.setText(scene->_autoplay ? AUTO_PLAY_ON : AUTO_PLAY_OFF);
+ _autoplay.draw();
+ } else if (selectedButton) {
+ breakFlag = true;
+ break;
+ } else if (!event.handled) {
+ if ((event.eventType == EVENT_KEYPRESS) && (event.kbd.keycode == Common::KEYCODE_ESCAPE)) {
+ selectedButton = NULL;
+ breakFlag = true;
+ break;
+ }
+ }
+ }
+
+ g_system->delayMillis(10);
+ GLOBALS._screenSurface.updateScreen();
+ }
+
+ _gfxManager.deactivate();
+ return selectedButton;
+}
+
+} // End of namespace Ringworld2
+} // End of namespace TsAGE
diff --git a/engines/tsage/ringworld2/ringworld2_outpost.h b/engines/tsage/ringworld2/ringworld2_outpost.h
new file mode 100644
index 0000000000..6c6952c196
--- /dev/null
+++ b/engines/tsage/ringworld2/ringworld2_outpost.h
@@ -0,0 +1,259 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public 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 TSAGE_RINGWORLD2_OUTPOST_H
+#define TSAGE_RINGWORLD2_OUTPOST_H
+
+#include "tsage/events.h"
+#include "tsage/core.h"
+#include "tsage/scenes.h"
+#include "tsage/globals.h"
+#include "tsage/sound.h"
+#include "tsage/ringworld2/ringworld2_logic.h"
+
+namespace TsAGE {
+
+namespace Ringworld2 {
+
+using namespace TsAGE;
+
+class Scene1337 : public SceneExt {
+ class OptionsDialog: public GfxDialog {
+ private:
+ GfxButton _autoplay;
+ GfxButton _restartGame;
+ GfxButton _quitGame;
+ GfxButton _continueGame;
+
+ OptionsDialog();
+ virtual ~OptionsDialog() {}
+ virtual GfxButton *execute(GfxButton *defaultButton);
+ public:
+ static void show();
+ };
+
+ class Card: public SceneHotspot {
+ public:
+ SceneObject _card;
+
+ int _cardId;
+ Common::Point _stationPos;
+
+ Card();
+ void synchronize(Serializer &s);
+ bool isIn(Common::Point pt);
+ };
+
+ class GameBoardSide: public SceneHotspot {
+ public:
+ Card _handCard[4];
+ Card _outpostStation[8];
+ Card _delayCard;
+ Card _emptyStationPos;
+
+ Common::Point _card1Pos;
+ Common::Point _card2Pos;
+ Common::Point _card3Pos;
+ Common::Point _card4Pos;
+ int _frameNum;
+
+ GameBoardSide();
+ void synchronize(Serializer &s);
+ };
+
+ class Action1337: public Action {
+ public:
+ void waitFrames(int32 frameCount);
+ };
+
+ class Action1: public Action1337 {
+ public:
+ void signal();
+ };
+ class Action2: public Action1337 {
+ public:
+ void signal();
+ };
+ class Action3: public Action1337 {
+ public:
+ void signal();
+ };
+ class Action4: public Action1337 {
+ public:
+ void signal();
+ };
+ class Action5: public Action1337 {
+ public:
+ void signal();
+ };
+ class Action6: public Action1337 {
+ public:
+ void signal();
+ };
+ class Action7: public Action1337 {
+ public:
+ void signal();
+ };
+ class Action8: public Action1337 {
+ public:
+ void signal();
+ };
+ class Action9: public Action1337 {
+ public:
+ void signal();
+ };
+ class Action10: public Action1337 {
+ public:
+ void signal();
+ };
+ class Action11: public Action1337 {
+ public:
+ void signal();
+ };
+ class Action12: public Action1337 {
+ public:
+ void signal();
+ };
+ class Action13: public Action1337 {
+ public:
+ void signal();
+ };
+public:
+ Action1 _action1;
+ Action2 _action2;
+ Action3 _action3;
+ Action4 _action4;
+ Action5 _action5;
+ Action6 _action6;
+ Action7 _action7;
+ Action8 _action8;
+ Action9 _action9;
+ Action10 _action10;
+ Action11 _action11;
+ Action12 _action12;
+ Action13 _action13;
+
+ typedef void (Scene1337::*FunctionPtrType)();
+ FunctionPtrType _delayedFunction;
+
+ bool _autoplay;
+ bool _shuffleEndedFl;
+ bool _showPlayerTurn;
+ bool _displayHelpFl;
+ bool _instructionsDisplayedFl;
+
+ // Discarded cards are put in the available cards pile, with an higher index so there no conflict
+ int _currentDiscardIndex;
+ int _availableCardsPile[100];
+ int _cardsAvailableNumb;
+ int _currentPlayerNumb;
+ int _actionPlayerIdx;
+ int _actionVictimIdx;
+ int _winnerId;
+ int _instructionsWaitCount;
+ int _cursorCurRes;
+ int _cursorCurStrip;
+ int _cursorCurFrame;
+
+ ASound _aSound1;
+ ASound _aSound2;
+ GameBoardSide _gameBoardSide[4];
+ SceneActor _helpIcon;
+ SceneActor _stockPile;
+ SceneItem _actionItem;
+ SceneObject _currentPlayerArrow;
+
+ Card *_actionCard1;
+ Card *_actionCard2;
+ Card *_actionCard3;
+ Card _animatedCard;
+ Card _shuffleAnimation;
+ Card _discardedPlatformCard;
+ Card _selectedCard;
+ Card _discardPile;
+ Card _stockCard;
+
+ SceneObject _upperDisplayCard[8];
+ SceneObject _lowerDisplayCard[8];
+
+ Scene1337();
+ virtual void synchronize(Serializer &s);
+
+ void actionDisplay(int resNum, int lineNum, int x, int y, int keepOnScreen, int width, int textMode, int fontNum, int colFG, int colBGExt, int colFGExt);
+ void setAnimationInfo(Card *card);
+ void handleNextTurn();
+ void handlePlayerTurn();
+ bool isStationCard(int cardId);
+ bool isStopConstructionCard(int cardId);
+ int getStationId(int playerId, int handCardId);
+ int findPlatformCardInHand(int playerId);
+ int findMeteorCardInHand(int playerId);
+ int findThieftCardInHand(int playerId);
+ int isDelayCard(int cardId);
+ int getStationCardId(int cardId);
+ void handlePlayer01Discard(int playerId);
+ void playThieftCard(int playerId, Card *card, int victimId);
+ int getPreventionCardId(int cardId);
+ bool isAttackPossible(int victimId, int cardId);
+ int getPlayerWithOutpost(int playerId);
+ bool checkAntiDelayCard(int delayCardId, int cardId);
+ void playStationCard(Card *station, Card *platform);
+ void playDelayCard(Card *card, Card *dest);
+ void playPlatformCard(Card *card, Card *dest);
+ void playAntiDelayCard(Card *card, Card *dest);
+ Card *getStationCard(int arg1);
+ void playCentralOutpostCard(Card *card, int playerId);
+ int getRandomCardFromHand(int playerId);
+ void discardCard(Card *card);
+ void subC4CD2();
+ void subC4CEC();
+ void playInterceptorCard(Card *subObj1, Card *subObj2);
+ void displayDialog(int dialogNumb);
+ void subPostInit();
+ void displayInstructions();
+ void suggestInstructions();
+ void shuffleCards();
+ void dealCards();
+ void showOptionsDialog();
+ void handleClick(int arg1, Common::Point pt);
+ void handlePlayer0();
+ void handlePlayer1();
+ void handlePlayer2();
+ void handlePlayer3();
+ void handleAutoplayPlayer2();
+ void updateCursorId(int arg1, bool arg2);
+ void setCursorData(int resNum, int rlbNum, int frameNum);
+ void subD18F5();
+ void subD1917();
+ void subD1940(bool flag);
+ void subD1975(int arg1, int arg2);
+
+ virtual void postInit(SceneObjectList *OwnerList = NULL);
+ virtual void remove();
+ virtual void process(Event &event);
+ virtual void dispatch();
+};
+
+} // End of namespace Ringworld2
+} // End of namespace TsAGE
+
+#endif
diff --git a/engines/tsage/ringworld2/ringworld2_scenes0.cpp b/engines/tsage/ringworld2/ringworld2_scenes0.cpp
index b82565332a..573cbbb29a 100644
--- a/engines/tsage/ringworld2/ringworld2_scenes0.cpp
+++ b/engines/tsage/ringworld2/ringworld2_scenes0.cpp
@@ -627,7 +627,7 @@ void Scene125::postInit(SceneObjectList *OwnerList) {
SceneExt::postInit();
_palette.loadPalette(0);
- if (R2_GLOBALS._sceneManager._previousScene != 125)
+ if ((R2_GLOBALS._sceneManager._previousScene != 125) && (R2_GLOBALS._sceneManager._previousScene != 1337) && (R2_GLOBALS._sceneManager._previousScene != 1330))
// Save the prior scene to return to when the console is turned off
R2_GLOBALS._player._oldCharacterScene[R2_QUINN] = R2_GLOBALS._sceneManager._previousScene;
diff --git a/engines/tsage/ringworld2/ringworld2_scenes1.cpp b/engines/tsage/ringworld2/ringworld2_scenes1.cpp
index e2c22bd0b4..81dc05e2a4 100644
--- a/engines/tsage/ringworld2/ringworld2_scenes1.cpp
+++ b/engines/tsage/ringworld2/ringworld2_scenes1.cpp
@@ -1321,5469 +1321,6 @@ void Scene1100::saveCharacter(int characterIndex) {
}
/*--------------------------------------------------------------------------
- * Scene 1200 - Air Ducts Maze
- *
- *--------------------------------------------------------------------------*/
-
-Scene1200::Scene1200() {
- _nextCrawlDirection = 0;
- _field414 = 0;
- _field416 = 0;
- _field418 = 0;
- _field41A = 0;
- _fixupMaze = false;
-}
-
-void Scene1200::synchronize(Serializer &s) {
- SceneExt::synchronize(s);
-
- s.syncAsSint16LE(_nextCrawlDirection);
- s.syncAsSint16LE(_field414);
- s.syncAsSint16LE(_field416);
- s.syncAsSint16LE(_field418);
- s.syncAsSint16LE(_field41A);
- s.syncAsSint16LE(_fixupMaze);
-}
-
-Scene1200::LaserPanel::LaserPanel() {
-}
-
-void Scene1200::LaserPanel::Jumper::init(int state) {
- _state = state;
-
- SceneActor::postInit();
- setup(1003, 1, 1);
- fixPriority(255);
-
- switch (_state) {
- case 1:
- switch (R2_GLOBALS._ductMazePanel1State) {
- case 1:
- setFrame2(2);
- setPosition(Common::Point(129, 101));
- break;
- case 2:
- setFrame2(3);
- setPosition(Common::Point(135, 95));
- break;
- default:
- break;
- }
- break;
- case 2:
- switch (R2_GLOBALS._ductMazePanel2State) {
- case 1:
- setFrame2(2);
- setPosition(Common::Point(152, 101));
- break;
- case 2:
- setFrame2(3);
- setPosition(Common::Point(158, 122));
- break;
- case 3:
- setFrame2(3);
- setPosition(Common::Point(135, 122));
- break;
- default:
- break;
- }
- break;
- case 3:
- switch (R2_GLOBALS._ductMazePanel3State) {
- case 1:
- setFrame2(3);
- setPosition(Common::Point(158, 95));
- break;
- case 2:
- setFrame2(2);
- setPosition(Common::Point(175, 101));
- break;
- default:
- break;
- }
- break;
- default:
- break;
- }
-
- setDetails(1200, 12, -1, -1, 2, (SceneItem *) NULL);
-}
-
-bool Scene1200::LaserPanel::Jumper::startAction(CursorType action, Event &event) {
- if (action != CURSOR_USE)
- return SceneActor::startAction(action, event);
-
- R2_GLOBALS._sound2.play(260);
- switch (_state) {
- case 1:
- if (R2_GLOBALS._ductMazePanel1State == 1) {
- R2_GLOBALS._ductMazePanel1State = 2;
- setFrame2(3);
- setPosition(Common::Point(135, 95));
- } else {
- R2_GLOBALS._ductMazePanel1State = 1;
- setFrame2(2);
- setPosition(Common::Point(129, 101));
- }
- break;
- case 2:
- ++R2_GLOBALS._ductMazePanel2State;
- if (R2_GLOBALS._ductMazePanel2State == 4)
- R2_GLOBALS._ductMazePanel2State = 1;
-
- switch (R2_GLOBALS._ductMazePanel2State) {
- case 1:
- setFrame2(2);
- setPosition(Common::Point(152, 101));
- break;
- case 2:
- setFrame2(3);
- setPosition(Common::Point(158, 122));
- break;
- case 3:
- setFrame2(3);
- setPosition(Common::Point(135, 122));
- break;
- default:
- break;
- }
- break;
- case 3:
- if (R2_GLOBALS._ductMazePanel3State == 1) {
- R2_GLOBALS._ductMazePanel3State = 2;
- setFrame2(2);
- setPosition(Common::Point(175, 101));
- } else {
- R2_GLOBALS._ductMazePanel3State = 1;
- setFrame2(3);
- setPosition(Common::Point(158, 95));
- }
- break;
- default:
- break;
- }
-
- Scene1200 *scene = (Scene1200 *)R2_GLOBALS._sceneManager._scene;
- scene->_field418 = 0;
-
- if ((R2_GLOBALS._ductMazePanel1State == 1) && (R2_GLOBALS._ductMazePanel2State == 1) && (R2_GLOBALS._ductMazePanel3State == 1))
- scene->_field418 = 1;
- else if ((R2_GLOBALS._ductMazePanel1State == 2) && (R2_GLOBALS._ductMazePanel2State == 1) && (R2_GLOBALS._ductMazePanel3State == 1))
- scene->_field418 = 2;
- else if ((R2_GLOBALS._ductMazePanel1State == 2) && (R2_GLOBALS._ductMazePanel2State == 1) && (R2_GLOBALS._ductMazePanel3State == 2))
- scene->_field418 = 3;
- else if ((R2_GLOBALS._ductMazePanel1State == 2) && (R2_GLOBALS._ductMazePanel2State == 3) && (R2_GLOBALS._ductMazePanel3State == 1))
- scene->_field418 = 4;
-
- return true;
-}
-
-void Scene1200::LaserPanel::postInit(SceneObjectList *OwnerList) {
- Scene1200 *scene = (Scene1200 *)R2_GLOBALS._sceneManager._scene;
-
- scene->_field41A = 1;
- R2_GLOBALS._events.setCursor(CURSOR_USE);
- setup2(1003, 1, 1, 100, 40);
- setup3(1200, 11, -1, -1);
- R2_GLOBALS._sound2.play(259);
- _jumper1.init(1);
- _jumper2.init(2);
- _jumper3.init(3);
-
- R2_GLOBALS._player._canWalk = false;
-}
-
-void Scene1200::LaserPanel::remove() {
- Scene1200 *scene = (Scene1200 *)R2_GLOBALS._sceneManager._scene;
-
- scene->_field41A = 0;
- scene->_sceneAreas.remove(&_jumper1);
- scene->_sceneAreas.remove(&_jumper2);
- scene->_sceneAreas.remove(&_jumper3);
- _jumper1.remove();
- _jumper2.remove();
- _jumper3.remove();
-
- ModalWindow::remove();
- R2_GLOBALS._player._canWalk = true;
-}
-
-void Scene1200::postInit(SceneObjectList *OwnerList) {
- loadScene(1200);
- SceneExt::postInit();
-
- if (R2_GLOBALS._sceneManager._previousScene < 3200)
- R2_GLOBALS._sound1.play(257);
-
- _nextCrawlDirection = CRAWL_EAST;
- _field414 = 0;
- _field416 = 0;
- _field418 = 0;
- _field41A = 0;
-
- if ((R2_GLOBALS._ductMazePanel1State == 1) && (R2_GLOBALS._ductMazePanel2State == 1) && (R2_GLOBALS._ductMazePanel3State == 1))
- _field418 = 1;
- else if ((R2_GLOBALS._ductMazePanel1State == 2) && (R2_GLOBALS._ductMazePanel2State == 1) && (R2_GLOBALS._ductMazePanel3State == 1))
- _field418 = 2;
- else if ((R2_GLOBALS._ductMazePanel1State == 2) && (R2_GLOBALS._ductMazePanel2State == 1) && (R2_GLOBALS._ductMazePanel3State == 2))
- _field418 = 3;
- else if ((R2_GLOBALS._ductMazePanel1State == 2) && (R2_GLOBALS._ductMazePanel2State == 3) && (R2_GLOBALS._ductMazePanel3State == 1))
- _field418 = 4;
-
- R2_GLOBALS._player.postInit();
- R2_GLOBALS._player.disableControl();
- R2_GLOBALS._player.setup(3156, 1, 6);
- R2_GLOBALS._player.setPosition(Common::Point(160, 70));
- R2_GLOBALS._player._numFrames = 10;
- R2_GLOBALS._player._oldCharacterScene[R2_MIRANDA] = 1200;
-
- _actor1.postInit();
- _actor1.hide();
-
- _mazeUI.setDisplayBounds(Rect(110, 20, 210, 120));
-
- _mazeUI.postInit();
- _mazeUI.load(1);
- _mazeUI.setMazePosition(R2_GLOBALS._ventCellPos);
-
- R2_GLOBALS._player.enableControl();
- _item1.setDetails(Rect(0, 0, 320, 200), 1200, 0, 1, 2, 1, NULL);
-}
-
-void Scene1200::signal() {
- switch (_sceneMode++) {
- case 1:
- // No break on purpose
- case 1200:
- // No break on purpose
- case 1201:
- // No break on purpose
- case 1202:
- // No break on purpose
- case 1203:
- R2_GLOBALS._player.enableControl();
- // CHECKME: The original is calling _eventManager.waitEvent();
- _sceneMode = 2;
- break;
- case 10:
- _field416 = 1;
- _field414 = 6;
- R2_GLOBALS._player._numFrames = 5;
- R2_GLOBALS._player.setStrip(1);
- R2_GLOBALS._player.setFrame(5);
- R2_GLOBALS._player.animate(ANIM_MODE_6, this);
- break;
- case 11:
- // No break on purpose
- case 21:
- // No break on purpose
- case 31:
- // No break on purpose
- case 41:
- _field416 = 0;
- break;
- case 12:
- _field414 = 14;
- R2_GLOBALS._player._numFrames = 10;
- R2_GLOBALS._player.setup(3155, 1, 4);
- R2_GLOBALS._player.setPosition(Common::Point(160, 70));
- R2_GLOBALS._player.animate(ANIM_MODE_2, NULL);
- break;
- case 13:
- // No break on purpose
- case 16:
- // No break on purpose
- case 23:
- // No break on purpose
- case 26:
- // No break on purpose
- case 33:
- // No break on purpose
- case 36:
- // No break on purpose
- case 43:
- // No break on purpose
- case 46:
- R2_GLOBALS._player.setFrame(4);
- _sceneMode = 1;
- setAction(&_sequenceManager, this, 1, &R2_GLOBALS._player, NULL);
- break;
- case 15:
- // No break on purpose
- case 25:
- // No break on purpose
- case 35:
- // No break on purpose
- case 45:
- _field414 = 20;
- R2_GLOBALS._player.animate(ANIM_MODE_2, NULL);
- break;
- case 20:
- _field416 = 1;
- _field414 = 6;
- R2_GLOBALS._player._numFrames = 5;
- R2_GLOBALS._player.setStrip(2);
- R2_GLOBALS._player.setFrame(5);
- R2_GLOBALS._player.animate(ANIM_MODE_6, this);
- break;
- case 22:
- _field414 = 14;
- R2_GLOBALS._player._numFrames = 10;
- R2_GLOBALS._player.setup(3155, 2, 4);
- R2_GLOBALS._player.setPosition(Common::Point(160, 70));
- R2_GLOBALS._player.animate(ANIM_MODE_2, NULL);
- break;
- case 30:
- _field416 = 1;
- _field414 = 6;
- R2_GLOBALS._player._numFrames = 5;
- R2_GLOBALS._player.setStrip(3);
- R2_GLOBALS._player.setFrame(5);
- R2_GLOBALS._player.animate(ANIM_MODE_6, this);
- break;
- case 32:
- _field414 = 14;
- R2_GLOBALS._player._numFrames = 10;
- R2_GLOBALS._player.setup(3155, 3, 4);
- R2_GLOBALS._player.setPosition(Common::Point(160, 70));
- R2_GLOBALS._player.animate(ANIM_MODE_2, NULL);
- break;
- case 40:
- _field416 = 1;
- _field414 = 6;
- R2_GLOBALS._player._numFrames = 5;
- R2_GLOBALS._player.setStrip(4);
- R2_GLOBALS._player.setFrame(5);
- R2_GLOBALS._player.animate(ANIM_MODE_6, this);
- break;
- case 42:
- _field414 = 14;
- R2_GLOBALS._player._numFrames = 10;
- R2_GLOBALS._player.setup(3155, 4, 4);
- R2_GLOBALS._player.setPosition(Common::Point(160, 70));
- R2_GLOBALS._player.animate(ANIM_MODE_2, NULL);
- break;
- case 50:
- // No break on purpose
- case 55:
- // No break on purpose
- case 60:
- R2_GLOBALS._player.setup(3156, 5, 1);
- R2_GLOBALS._player._numFrames = 5;
- R2_GLOBALS._player.animate(ANIM_MODE_5, this);
- break;
- case 51:
- // No break on purpose
- case 56:
- // No break on purpose
- case 117:
- R2_GLOBALS._player.setup(3157, 1, 1);
- R2_GLOBALS._player.animate(ANIM_MODE_5, this);
- break;
- case 52:
- // No break on purpose
- case 82:
- // No break on purpose
- case 118:
- R2_GLOBALS._player.setup(3156, 3, 6);
- _sceneMode = 1;
- setAction(&_sequenceManager, this, 1, &R2_GLOBALS._player, NULL);
- break;
- case 57:
- // No break on purpose
- case 91:
- // No break on purpose
- case 96:
- R2_GLOBALS._player.setup(3157, 2, 1);
- R2_GLOBALS._player.animate(ANIM_MODE_5, this);
- break;
- case 58:
- // No break on purpose
- case 92:
- // No break on purpose
- case 122:
- R2_GLOBALS._player.setup(3156, 2, 6);
- _sceneMode = 1;
- setAction(&_sequenceManager, this, 1, &R2_GLOBALS._player, NULL);
- break;
- case 61:
- R2_GLOBALS._player.setup(3157, 4, 5);
- R2_GLOBALS._player.animate(ANIM_MODE_6, this);
- break;
- case 62:
- // No break on purpose
- case 72:
- // No break on purpose
- case 98:
- R2_GLOBALS._player.setup(3156, 4, 6);
- _sceneMode = 1;
- setAction(&_sequenceManager, this, 1, &R2_GLOBALS._player, NULL);
- break;
- case 70:
- // No break on purpose
- case 75:
- // No break on purpose
- case 80:
- R2_GLOBALS._player.setup(3156, 6, 1);
- R2_GLOBALS._player._numFrames = 5;
- R2_GLOBALS._player.animate(ANIM_MODE_5, this);
- break;
- case 71:
- // No break on purpose
- case 76:
- // No break on purpose
- case 97:
- R2_GLOBALS._player.setup(3157, 3, 1);
- R2_GLOBALS._player.animate(ANIM_MODE_5, this);
- break;
- case 77:
- // No break on purpose
- case 111:
- // No break on purpose
- case 116:
- R2_GLOBALS._player.setup(3157, 4, 1);
- R2_GLOBALS._player.animate(ANIM_MODE_5, this);
- break;
- case 78:
- // No break on purpose
- case 102:
- // No break on purpose
- case 112:
- R2_GLOBALS._player.setup(3156, 1, 6);
- _sceneMode = 1;
- setAction(&_sequenceManager, this, 1, &R2_GLOBALS._player, NULL);
- break;
- case 81:
- R2_GLOBALS._player.setup(3157, 2, 5);
- R2_GLOBALS._player.animate(ANIM_MODE_6, this);
- break;
- case 90:
- // No break on purpose
- case 95:
- // No break on purpose
- case 100:
- R2_GLOBALS._player.setup(3156, 7, 1);
- R2_GLOBALS._player._numFrames = 5;
- R2_GLOBALS._player.animate(ANIM_MODE_5, this);
- break;
- case 101:
- R2_GLOBALS._player.setup(3157, 1, 5);
- R2_GLOBALS._player.animate(ANIM_MODE_6, this);
- break;
- case 110:
- // No break on purpose
- case 115:
- // No break on purpose
- case 120:
- R2_GLOBALS._player.setup(3156, 8, 1);
- R2_GLOBALS._player._numFrames = 5;
- R2_GLOBALS._player.animate(ANIM_MODE_5, this);
- break;
- case 121:
- R2_GLOBALS._player.setup(3157, 3, 5);
- R2_GLOBALS._player.animate(ANIM_MODE_6, this);
- break;
- default:
- // CHECKME: The original is walling _eventManager.waitEvent();
- _sceneMode = 2;
- break;
- }
-}
-
-void Scene1200::process(Event &event) {
- if (_field414 != 0)
- return;
-
- Scene::process(event);
-
- if (!R2_GLOBALS._player._canWalk)
- return;
-
- if (event.eventType == EVENT_BUTTON_DOWN) {
- Common::Point cellPos = R2_GLOBALS._ventCellPos;
- _mazeUI.pixelToCellXY(cellPos);
-
- int cellId = _mazeUI.getCellFromPixelXY(event.mousePos);
- switch (R2_GLOBALS._events.getCursor()) {
- case CURSOR_WALK:
- event.handled = true;
- if ((event.mousePos.x > 179) && (event.mousePos.x < 210) && (event.mousePos.y > 50) && (event.mousePos.y < 89))
- startCrawling(CRAWL_EAST);
-
- if ((event.mousePos.x > 109) && (event.mousePos.x < 140) && (event.mousePos.y > 50) && (event.mousePos.y < 89))
- startCrawling(CRAWL_WEST);
-
- if ((event.mousePos.x > 140) && (event.mousePos.x < 179) && (event.mousePos.y > 89) && (event.mousePos.y < 120))
- startCrawling(CRAWL_SOUTH);
-
- if ((event.mousePos.x > 140) && (event.mousePos.x < 179) && (event.mousePos.y > 19) && (event.mousePos.y < 50))
- startCrawling(CRAWL_NORTH);
- break;
- case CURSOR_USE:
- if (cellId > 36) {
- if ( ((cellPos.x == 3) && (cellPos.y == 33))
- || ((cellPos.x == 7) && (cellPos.y == 33))
- || ((cellPos.x == 33) && (cellPos.y == 41))
- || ((cellPos.x == 5) && (cellPos.y == 5))
- || ((cellPos.x == 13) && (cellPos.y == 21))
- || ((cellPos.x == 17) && (cellPos.y == 21))
- || ((cellPos.x == 17) && (cellPos.y == 5))
- || ((cellPos.x == 17) && (cellPos.y == 9))
- || ((cellPos.x == 29) && (cellPos.y == 17))
- || ((cellPos.x == 33) && (cellPos.y == 17))
- || ((cellPos.x == 35) && (cellPos.y == 17))
- || ((cellPos.x == 41) && (cellPos.y == 21)) ) {
- _laserPanel.postInit();
- event.handled = true;
- }
- }
-
- if ((cellId == 1) || (cellId == 4) || (cellId == 11) || (cellId == 14)) {
- if ( ((cellPos.x == 3) && (cellPos.y == 9))
- || ((cellPos.x == 11) && (cellPos.y == 27))
- || ((cellPos.x == 17) && (cellPos.y == 7))
- || ((cellPos.x == 17) && (cellPos.y == 27))
- || ((cellPos.x == 17) && (cellPos.y == 33))
- || (cellPos.x == 33) ) {
- switch (cellPos.x) {
- case 3:
- R2_GLOBALS._sceneManager.changeScene(3150);
- break;
- case 33:
- if (R2_GLOBALS._scientistConvIndex >= 4)
- R2_GLOBALS._sceneManager.changeScene(3250);
- else
- SceneItem::display(1200, 6, 0, 280, 1, 160, 9, 1, 2, 20, 7, 154, LIST_END);
- break;
- default:
- SceneItem::display(1200, 5, 0, 280, 1, 160, 9, 1, 2, 20, 7, 154, LIST_END);
- break;
- }
- event.handled = true;
- }
- }
- break;
- case CURSOR_LOOK:
- if ((cellId == 1) || (cellId == 4) || (cellId == 11) || (cellId == 14)) {
- event.handled = true;
- switch (cellPos.x) {
- case 3:
- // It was your cell.
- SceneItem::display(1200, 8, 0, 280, 1, 160, 9, 1, 2, 20, 7, 7, LIST_END);
- break;
- case 9:
- R2_GLOBALS._sceneManager.changeScene(3240);
- break;
- case 11:
- if (cellPos.y == 27)
- R2_GLOBALS._sceneManager.changeScene(3210);
- else
- // A vent grill
- SceneItem::display(1200, 10, 0, 280, 1, 160, 9, 1, 2, 20, 7, 7, LIST_END);
- break;
- case 17:
- switch (cellPos.y) {
- case 5:
- R2_GLOBALS._sceneManager.changeScene(3230);
- break;
- case 21:
- R2_GLOBALS._sceneManager.changeScene(3220);
- break;
- case 33:
- R2_GLOBALS._sceneManager.changeScene(3200);
- break;
- default:
- // A vent grill
- SceneItem::display(1200, 10, 0, 280, 1, 160, 9, 1, 2, 20, 7, 7, LIST_END);
- break;
- }
- break;
- case 33:
- R2_GLOBALS._sceneManager.changeScene(3245);
- break;
- default:
- SceneItem::display(1200, 10, 0, 280, 1, 160, 9, 1, 2, 20, 7, 7, LIST_END);
- break;
- }
- }
- if (cellId > 36) {
- // "An anti-pest laser"
- event.handled = true;
- SceneItem::display(1200, 9, 0, 280, 1, 160, 9, 1, 2, 20, 7, 7, LIST_END);
- }
- break;
- case CURSOR_TALK:
- event.handled = true;
- break;
- default:
- return;
- }
- } else if (event.eventType == EVENT_KEYPRESS) {
- if (_field414) {
- event.handled = false;
- return;
- }
-
- switch (event.kbd.keycode) {
- case Common::KEYCODE_KP8:
- case Common::KEYCODE_UP:
- startCrawling(CRAWL_NORTH);
- break;
- case Common::KEYCODE_KP4:
- case Common::KEYCODE_LEFT:
- startCrawling(CRAWL_WEST);
- break;
- case Common::KEYCODE_KP6:
- case Common::KEYCODE_RIGHT:
- startCrawling(CRAWL_EAST);
- break;
- case Common::KEYCODE_KP2:
- case Common::KEYCODE_DOWN:
- startCrawling(CRAWL_SOUTH);
- break;
- default:
- event.handled = false;
- return;
- break;
- }
- } else
- return;
-}
-
-void Scene1200::dispatch() {
- Rect tmpRect;
- Scene::dispatch();
-
- if (_fixupMaze) {
- _mazeUI.setMazePosition(R2_GLOBALS._ventCellPos);
- //_mazeUI.draw();
- _fixupMaze = false;
- }
-
- if (_field414 != 0) {
- tmpRect.set(110, 20, 210, 120);
- _field414--;
-
- switch (_nextCrawlDirection) {
- case CRAWL_EAST:
- R2_GLOBALS._ventCellPos.x += 2;
- break;
- case CRAWL_WEST:
- R2_GLOBALS._ventCellPos.x -= 2;
- break;
- case CRAWL_SOUTH:
- R2_GLOBALS._ventCellPos.y += 2;
- break;
- case CRAWL_NORTH:
- R2_GLOBALS._ventCellPos.y -= 2;
- break;
- default:
- break;
- }
-
- _mazeUI.setMazePosition(R2_GLOBALS._ventCellPos);
- //_mazeUI.draw();
-
- if (_field416 != 0) {
- switch(_nextCrawlDirection) {
- case CRAWL_EAST:
- R2_GLOBALS._player.setPosition(Common::Point(R2_GLOBALS._player._position.x - 2, R2_GLOBALS._player._position.y));
- break;
- case CRAWL_WEST:
- R2_GLOBALS._player.setPosition(Common::Point(R2_GLOBALS._player._position.x + 2, R2_GLOBALS._player._position.y));
- break;
- case CRAWL_SOUTH:
- R2_GLOBALS._player.setPosition(Common::Point(R2_GLOBALS._player._position.x, R2_GLOBALS._player._position.y - 2));
- break;
- case CRAWL_NORTH:
- R2_GLOBALS._player.setPosition(Common::Point(R2_GLOBALS._player._position.x, R2_GLOBALS._player._position.y + 2));
- break;
- default:
- break;
- }
- }
- if (_field414 == 0) {
- if (_field416 == 0)
- R2_GLOBALS._player.animate(ANIM_MODE_NONE, NULL);
- signal();
- }
- }
-}
-
-void Scene1200::saveCharacter(int characterIndex) {
- R2_GLOBALS._sound1.fadeOut2(NULL);
- SceneExt::saveCharacter(characterIndex);
-}
-
-void Scene1200::startCrawling(CrawlDirection dir) {
- Common::Point cellPos = R2_GLOBALS._ventCellPos;
- _mazeUI.pixelToCellXY(cellPos);
-
- switch (dir) {
- case CRAWL_EAST:
- if ( ((_mazeUI.getCellFromPixelXY(Common::Point(200, 50)) > 36) || (_mazeUI.getCellFromPixelXY(Common::Point(200, 88)) > 36))
- && ( ((cellPos.x == 3) && (cellPos.y == 33) && (_field418 != 4))
- || ((cellPos.x == 13) && (cellPos.y == 21) && (_field418 != 2))
- || ((cellPos.x == 29) && (cellPos.y == 17) && (_field418 != 1))
- || ((cellPos.x == 33) && (cellPos.y == 41)) )
- ) {
- R2_GLOBALS._player.disableControl();
- _sceneMode = 1200;
- setAction(&_sequenceManager, this, 1200, &_actor1, NULL);
- } else if (_mazeUI.getCellFromPixelXY(Common::Point(200, 69)) == 36) {
- switch (_nextCrawlDirection) {
- case CRAWL_EAST:
- if (R2_GLOBALS._player._visage == 3155)
- _sceneMode = 15;
- else
- _sceneMode = 10;
- break;
- case CRAWL_WEST:
- if (R2_GLOBALS._player._visage == 3156)
- _sceneMode = 76;
- else
- _sceneMode = 75;
- break;
- case CRAWL_SOUTH:
- if (R2_GLOBALS._player._visage == 3156)
- _sceneMode = 101;
- else
- _sceneMode = 100;
- break;
- case CRAWL_NORTH:
- if (R2_GLOBALS._player._visage == 3156)
- _sceneMode = 111;
- else
- _sceneMode = 110;
- break;
- default:
- break;
- }
- R2_GLOBALS._player.disableControl();
- _nextCrawlDirection = 1;
- signal();
- }
- break;
- case CRAWL_WEST:
- if ( ((_mazeUI.getCellFromPixelXY(Common::Point(120, 50)) > 36) || (_mazeUI.getCellFromPixelXY(Common::Point(120, 88)) > 36))
- && ( ((cellPos.x == 7) && (cellPos.y == 33) && (_field418 != 4))
- || ((cellPos.x == 17) && (cellPos.y == 21) && (_field418 != 2))
- || ((cellPos.x == 33) && (cellPos.y == 17) && (_field418 != 1))
- || ((cellPos.x == 5) && (cellPos.y == 5)) )
- ) {
- R2_GLOBALS._player.disableControl();
- _sceneMode = 1201;
- setAction(&_sequenceManager, this, 1201, &_actor1, NULL);
- } else if (_mazeUI.getCellFromPixelXY(Common::Point(120, 69)) == 36) {
- switch (_nextCrawlDirection) {
- case CRAWL_EAST:
- if (R2_GLOBALS._player._visage == 3156)
- _sceneMode = 56;
- else
- _sceneMode = 55;
- break;
- case CRAWL_WEST:
- if (R2_GLOBALS._player._visage == 3155)
- _sceneMode = 25;
- else
- _sceneMode = 20;
- break;
- case CRAWL_SOUTH:
- if (R2_GLOBALS._player._visage == 3156)
- _sceneMode = 91;
- else
- _sceneMode = 90;
- break;
- case CRAWL_NORTH:
- if (R2_GLOBALS._player._visage == 3156)
- _sceneMode = 121;
- else
- _sceneMode = 120;
- break;
- default:
- break;
- }
- R2_GLOBALS._player.disableControl();
- _nextCrawlDirection = 2;
- signal();
- }
- break;
- case CRAWL_SOUTH:
- if ( ((_mazeUI.getCellFromPixelXY(Common::Point(140, 110)) > 36) || (_mazeUI.getCellFromPixelXY(Common::Point(178, 110)) > 36))
- && ( ((cellPos.x == 17) && (cellPos.y == 5) && (_field418 != 3))
- || ((cellPos.x == 41) && (cellPos.y == 21)) )
- ) {
- R2_GLOBALS._player.disableControl();
- _sceneMode = 1203;
- setAction(&_sequenceManager, this, 1203, &_actor1, NULL);
- } else if (_mazeUI.getCellFromPixelXY(Common::Point(160, 110)) == 36) {
- switch (_nextCrawlDirection) {
- case CRAWL_EAST:
- if (R2_GLOBALS._player._visage == 3156)
- _sceneMode = 51;
- else
- _sceneMode = 50;
- break;
- case CRAWL_WEST:
- if (R2_GLOBALS._player._visage == 3156)
- _sceneMode = 81;
- else
- _sceneMode = 80;
- break;
- case CRAWL_SOUTH:
- if (R2_GLOBALS._player._visage == 3155)
- _sceneMode = 35;
- else
- _sceneMode = 30;
- break;
- case CRAWL_NORTH:
- if (R2_GLOBALS._player._visage == 3156)
- _sceneMode = 116;
- else
- _sceneMode = 115;
- break;
- default:
- break;
- }
- R2_GLOBALS._player.disableControl();
- _nextCrawlDirection = 3;
- signal();
- }
- break;
- case CRAWL_NORTH:
- if ( ((_mazeUI.getCellFromPixelXY(Common::Point(140, 30)) > 36) || (_mazeUI.getCellFromPixelXY(Common::Point(178, 30)) > 36))
- && ( ((cellPos.x == 17) && (cellPos.y == 9) && (_field418 != 3))
- || ((cellPos.x == 35) && (cellPos.y == 17)) )
- ) {
- R2_GLOBALS._player.disableControl();
- _sceneMode = 1202;
- setAction(&_sequenceManager, this, 1202, &_actor1, NULL);
- } else if (_mazeUI.getCellFromPixelXY(Common::Point(160, 30)) == 36) {
- switch (_nextCrawlDirection) {
- case CRAWL_EAST:
- if (R2_GLOBALS._player._visage == 3156)
- _sceneMode = 61;
- else
- _sceneMode = 60;
- break;
- case CRAWL_WEST:
- if (R2_GLOBALS._player._visage == 3156)
- _sceneMode = 71;
- else
- _sceneMode = 70;
- break;
- case CRAWL_SOUTH:
- if (R2_GLOBALS._player._visage == 3156)
- _sceneMode = 96;
- else
- _sceneMode = 95;
- break;
- case CRAWL_NORTH:
- if (R2_GLOBALS._player._visage == 3155)
- _sceneMode = 45;
- else
- _sceneMode = 40;
- break;
- default:
- _sceneMode = 1;
- R2_GLOBALS._player.setup(3156, 4, 6);
- break;
- }
- R2_GLOBALS._player.disableControl();
- _nextCrawlDirection = 4;
- signal();
- }
- break;
- default:
- break;
- }
-}
-
-/*--------------------------------------------------------------------------
- * Scene 1337 - Card game
- *
- *--------------------------------------------------------------------------*/
-
-Scene1337::Card::Card() {
- _cardId = 0;
- _stationPos = Common::Point(0, 0);
-}
-
-void Scene1337::Card::synchronize(Serializer &s) {
- warning("STUBBED: Card::synchronize()");
-}
-
-bool Scene1337::Card::isIn(Common::Point pt) {
- if ((_stationPos.x > pt.x) || (_stationPos.x + 24 < pt.x))
- return false;
-
- if ((_stationPos.y > pt.y) || (_stationPos.y + 24 < pt.y))
- return false;
-
- return true;
-}
-
-Scene1337::GameBoardSide::GameBoardSide() {
- _card1Pos = Common::Point(0, 0);
- _card2Pos = Common::Point(0, 0);
- _card3Pos = Common::Point(0, 0);
- _card4Pos = Common::Point(0, 0);
- _frameNum = 0;
-}
-
-void Scene1337::GameBoardSide::synchronize(Serializer &s) {
- warning("STUBBED: GameBoardSide::synchronize()");
-}
-
-Scene1337::Scene1337() {
- _autoplay = false;
- _cardsAvailableNumb = 0;
- _currentDiscardIndex = 0;
-
- for (int i = 0; i < 100; i++)
- _availableCardsPile[i] = 0;
-
- _shuffleEndedFl = false;
- _currentPlayerNumb = 0;
- _actionIdx1 = 0;
- _actionIdx2 = 0;
- _showPlayerTurn = false;
- _displayHelpFl = false;
- _winnerId = -1;
- _instructionsDisplayedFl = false;
- _instructionsWaitCount = 0;
-
- _delayedFunction = nullptr;
- _actionCard1 = nullptr;
- _actionCard2 = nullptr;
- _actionCard3 = nullptr;
-
- _cursorCurRes = 0;
- _cursorCurStrip = 0;
- _cursorCurFrame = 0;
-}
-
-void Scene1337::synchronize(Serializer &s) {
- warning("STUBBED: Scene1337::synchronize()");
-}
-
-void Scene1337::Action1337::waitFrames(int32 frameCount) {
- uint32 firstFrameNumber = g_globals->_events.getFrameNumber();
- uint32 curFrame = firstFrameNumber;
- uint32 destFrame = firstFrameNumber + frameCount;
-
- while ((curFrame < destFrame) && !g_vm->shouldQuit()) {
- TsAGE::Event event;
- g_globals->_events.getEvent(event);
- curFrame = g_globals->_events.getFrameNumber();
- }
-
- // CHECKME: The original is calling _eventManager.waitEvent();
-}
-
-/**
- * Display instructions
- */
-void Scene1337::Action1::signal() {
- Scene1337 *scene = (Scene1337 *)R2_GLOBALS._sceneManager._scene;
-
- switch (_actionIndex++) {
- case 1: {
- scene->actionDisplay(1331, 6, 159, 10, 1, 200, 0, 7, 0, 154, 154);
- R2_GLOBALS._sceneObjects->draw();
- scene->actionDisplay(1331, 7, 159, 10, 1, 200, 0, 7, 0, 154, 154);
- scene->actionDisplay(1331, 8, 159, 10, 1, 200, 0, 7, 0, 154, 154);
-
- scene->_gameBoardSide[1]._outpostStation[0]._cardId = 2;
- scene->_gameBoardSide[1]._outpostStation[0]._card.postInit();
- scene->_gameBoardSide[1]._outpostStation[0]._card.setVisage(1332);
- scene->_gameBoardSide[1]._outpostStation[0]._card.setPosition(scene->_gameBoardSide[1]._outpostStation[0]._stationPos, 0);
- scene->_gameBoardSide[1]._outpostStation[0]._card.setStrip(2);
- scene->_gameBoardSide[1]._outpostStation[0]._card.setFrame(scene->_gameBoardSide[1]._outpostStation[0]._cardId);
- scene->_gameBoardSide[1]._outpostStation[0]._card.fixPriority(170);
- scene->setAnimationInfo(&scene->_gameBoardSide[1]._outpostStation[0]);
-
- scene->_gameBoardSide[1]._outpostStation[1]._cardId = 3;
- scene->_gameBoardSide[1]._outpostStation[1]._card.postInit();
- scene->_gameBoardSide[1]._outpostStation[1]._card.setVisage(1332);
- scene->_gameBoardSide[1]._outpostStation[1]._card.setPosition(scene->_gameBoardSide[1]._outpostStation[1]._stationPos, 0);
- scene->_gameBoardSide[1]._outpostStation[1]._card.setStrip(2);
- scene->_gameBoardSide[1]._outpostStation[1]._card.setFrame(scene->_gameBoardSide[1]._outpostStation[1]._cardId);
- scene->_gameBoardSide[1]._outpostStation[1]._card.fixPriority(170);
- scene->setAnimationInfo(&scene->_gameBoardSide[1]._outpostStation[1]);
-
- scene->_gameBoardSide[2]._outpostStation[0]._cardId = 4;
- scene->_gameBoardSide[2]._outpostStation[0]._card.postInit();
- scene->_gameBoardSide[2]._outpostStation[0]._card.setVisage(1332);
- scene->_gameBoardSide[2]._outpostStation[0]._card.setPosition(scene->_gameBoardSide[2]._outpostStation[0]._stationPos, 0);
- scene->_gameBoardSide[2]._outpostStation[0]._card.setStrip(2);
- scene->_gameBoardSide[2]._outpostStation[0]._card.setFrame(scene->_gameBoardSide[2]._outpostStation[0]._cardId);
- scene->setAnimationInfo(&scene->_gameBoardSide[2]._outpostStation[0]);
-
- scene->_gameBoardSide[3]._outpostStation[0]._cardId = 5;
- scene->_gameBoardSide[3]._outpostStation[0]._card.postInit();
- scene->_gameBoardSide[3]._outpostStation[0]._card.setVisage(1332);
- scene->_gameBoardSide[3]._outpostStation[0]._card.setPosition(scene->_gameBoardSide[3]._outpostStation[0]._stationPos, 0);
- scene->_gameBoardSide[3]._outpostStation[0]._card.setStrip(2);
- scene->_gameBoardSide[3]._outpostStation[0]._card.setFrame(scene->_gameBoardSide[3]._outpostStation[0]._cardId);
- scene->_gameBoardSide[3]._outpostStation[0]._card.fixPriority(170);
- scene->setAnimationInfo(&scene->_gameBoardSide[3]._outpostStation[0]);
-
- scene->_gameBoardSide[3]._outpostStation[1]._cardId = 6;
- scene->_gameBoardSide[3]._outpostStation[1]._card.postInit();
- scene->_gameBoardSide[3]._outpostStation[1]._card.setVisage(1332);
- scene->_gameBoardSide[3]._outpostStation[1]._card.setPosition(scene->_gameBoardSide[3]._outpostStation[1]._stationPos, 0);
- scene->_gameBoardSide[3]._outpostStation[1]._card.setStrip(2);
- scene->_gameBoardSide[3]._outpostStation[1]._card.setFrame(scene->_gameBoardSide[3]._outpostStation[1]._cardId);
- scene->_gameBoardSide[3]._outpostStation[1]._card.fixPriority(170);
- scene->setAnimationInfo(&scene->_gameBoardSide[3]._outpostStation[1]);
-
- scene->_gameBoardSide[3]._outpostStation[2]._cardId = 7;
- scene->_gameBoardSide[3]._outpostStation[2]._card.postInit();
- scene->_gameBoardSide[3]._outpostStation[2]._card.setVisage(1332);
- scene->_gameBoardSide[3]._outpostStation[2]._card.setPosition(scene->_gameBoardSide[3]._outpostStation[2]._stationPos, 0);
- scene->_gameBoardSide[3]._outpostStation[2]._card.setStrip(2);
- scene->_gameBoardSide[3]._outpostStation[2]._card.setFrame(scene->_gameBoardSide[3]._outpostStation[2]._cardId);
- scene->_gameBoardSide[3]._outpostStation[2]._card.fixPriority(170);
- scene->setAnimationInfo(&scene->_gameBoardSide[3]._outpostStation[2]);
-
- scene->_gameBoardSide[0]._outpostStation[0]._cardId = 8;
- scene->_gameBoardSide[0]._outpostStation[0]._card.postInit();
- scene->_gameBoardSide[0]._outpostStation[0]._card.setVisage(1332);
- scene->_gameBoardSide[0]._outpostStation[0]._card.setPosition(scene->_gameBoardSide[0]._outpostStation[0]._stationPos, 0);
- scene->_gameBoardSide[0]._outpostStation[0]._card.setStrip(2);
- scene->_gameBoardSide[0]._outpostStation[0]._card.setFrame(scene->_gameBoardSide[0]._outpostStation[0]._cardId);
- scene->_gameBoardSide[0]._outpostStation[0]._card.fixPriority(170);
- scene->setAnimationInfo(&scene->_gameBoardSide[0]._outpostStation[0]);
-
- scene->_gameBoardSide[0]._outpostStation[1]._cardId = 9;
- scene->_gameBoardSide[0]._outpostStation[1]._card.postInit();
- scene->_gameBoardSide[0]._outpostStation[1]._card.setVisage(1332);
- scene->_gameBoardSide[0]._outpostStation[1]._card.setPosition(scene->_gameBoardSide[0]._outpostStation[1]._stationPos, 0);
- scene->_gameBoardSide[0]._outpostStation[1]._card.setStrip(2);
- scene->_gameBoardSide[0]._outpostStation[1]._card.setFrame(scene->_gameBoardSide[0]._outpostStation[1]._cardId);
- scene->_gameBoardSide[0]._outpostStation[1]._card.fixPriority(170);
- scene->setAnimationInfo(&scene->_gameBoardSide[0]._outpostStation[1]);
-
- R2_GLOBALS._sceneObjects->draw();
-
- waitFrames(60);
- scene->actionDisplay(1331, 9, 159, 10, 1, 200, 0, 7, 0, 154, 154);
-
- scene->_gameBoardSide[2]._outpostStation[1]._cardId = 2;
- scene->_gameBoardSide[2]._outpostStation[1]._card.postInit();
- scene->_gameBoardSide[2]._outpostStation[1]._card.setVisage(1332);
- scene->_gameBoardSide[2]._outpostStation[1]._card.setPosition(scene->_gameBoardSide[2]._outpostStation[1]._stationPos, 0);
- scene->_gameBoardSide[2]._outpostStation[1]._card.setStrip(2);
- scene->_gameBoardSide[2]._outpostStation[1]._card.setFrame(scene->_gameBoardSide[2]._outpostStation[1]._cardId);
- scene->_gameBoardSide[2]._outpostStation[1]._card.fixPriority(170);
- scene->setAnimationInfo(&scene->_gameBoardSide[2]._outpostStation[1]);
-
- scene->_gameBoardSide[2]._outpostStation[2]._cardId = 3;
- scene->_gameBoardSide[2]._outpostStation[2]._card.postInit();
- scene->_gameBoardSide[2]._outpostStation[2]._card.setVisage(1332);
- scene->_gameBoardSide[2]._outpostStation[2]._card.setPosition(scene->_gameBoardSide[2]._outpostStation[2]._stationPos, 0);
- scene->_gameBoardSide[2]._outpostStation[2]._card.setStrip(2);
- scene->_gameBoardSide[2]._outpostStation[2]._card.setFrame(scene->_gameBoardSide[2]._outpostStation[2]._cardId);
- scene->_gameBoardSide[2]._outpostStation[2]._card.fixPriority(170);
- scene->setAnimationInfo(&scene->_gameBoardSide[2]._outpostStation[2]);
-
- scene->_gameBoardSide[2]._outpostStation[3]._cardId = 5;
- scene->_gameBoardSide[2]._outpostStation[3]._card.postInit();
- scene->_gameBoardSide[2]._outpostStation[3]._card.setVisage(1332);
- scene->_gameBoardSide[2]._outpostStation[3]._card.setPosition(scene->_gameBoardSide[2]._outpostStation[3]._stationPos, 0);
- scene->_gameBoardSide[2]._outpostStation[3]._card.setStrip(2);
- scene->_gameBoardSide[2]._outpostStation[3]._card.setFrame(scene->_gameBoardSide[2]._outpostStation[3]._cardId);
- scene->_gameBoardSide[2]._outpostStation[3]._card.fixPriority(170);
- scene->setAnimationInfo(&scene->_gameBoardSide[2]._outpostStation[3]);
-
- scene->_gameBoardSide[2]._outpostStation[4]._cardId = 6;
- scene->_gameBoardSide[2]._outpostStation[4]._card.postInit();
- scene->_gameBoardSide[2]._outpostStation[4]._card.setVisage(1332);
- scene->_gameBoardSide[2]._outpostStation[4]._card.setPosition(scene->_gameBoardSide[2]._outpostStation[4]._stationPos, 0);
- scene->_gameBoardSide[2]._outpostStation[4]._card.setStrip(2);
- scene->_gameBoardSide[2]._outpostStation[4]._card.setFrame(scene->_gameBoardSide[2]._outpostStation[4]._cardId);
- scene->_gameBoardSide[2]._outpostStation[4]._card.fixPriority(170);
- scene->setAnimationInfo(&scene->_gameBoardSide[2]._outpostStation[4]);
-
- scene->_gameBoardSide[2]._outpostStation[5]._cardId = 7;
- scene->_gameBoardSide[2]._outpostStation[5]._card.postInit();
- scene->_gameBoardSide[2]._outpostStation[5]._card.setVisage(1332);
- scene->_gameBoardSide[2]._outpostStation[5]._card.setPosition(scene->_gameBoardSide[2]._outpostStation[5]._stationPos, 0);
- scene->_gameBoardSide[2]._outpostStation[5]._card.setStrip(2);
- scene->_gameBoardSide[2]._outpostStation[5]._card.setFrame(scene->_gameBoardSide[2]._outpostStation[5]._cardId);
- scene->_gameBoardSide[2]._outpostStation[5]._card.fixPriority(170);
- scene->setAnimationInfo(&scene->_gameBoardSide[2]._outpostStation[5]);
-
- scene->_gameBoardSide[2]._outpostStation[6]._cardId = 8;
- scene->_gameBoardSide[2]._outpostStation[6]._card.postInit();
- scene->_gameBoardSide[2]._outpostStation[6]._card.setVisage(1332);
- scene->_gameBoardSide[2]._outpostStation[6]._card.setPosition(scene->_gameBoardSide[2]._outpostStation[6]._stationPos, 0);
- scene->_gameBoardSide[2]._outpostStation[6]._card.setStrip(2);
- scene->_gameBoardSide[2]._outpostStation[6]._card.setFrame(scene->_gameBoardSide[2]._outpostStation[6]._cardId);
- scene->_gameBoardSide[2]._outpostStation[6]._card.fixPriority(170);
- scene->setAnimationInfo(&scene->_gameBoardSide[2]._outpostStation[6]);
-
- scene->_gameBoardSide[2]._outpostStation[7]._cardId = 9;
- scene->_gameBoardSide[2]._outpostStation[7]._card.postInit();
- scene->_gameBoardSide[2]._outpostStation[7]._card.setVisage(1332);
- scene->_gameBoardSide[2]._outpostStation[7]._card.setPosition(scene->_gameBoardSide[2]._outpostStation[7]._stationPos, 0);
- scene->_gameBoardSide[2]._outpostStation[7]._card.setStrip(2);
- scene->_gameBoardSide[2]._outpostStation[7]._card.setFrame(scene->_gameBoardSide[2]._outpostStation[7]._cardId);
- scene->_gameBoardSide[2]._outpostStation[7]._card.fixPriority(170);
- scene->setAnimationInfo(&scene->_gameBoardSide[2]._outpostStation[7]);
-
- scene->_aSound1.play(62);
-
- R2_GLOBALS._sceneObjects->draw();
-
- waitFrames(120);
- scene->_gameBoardSide[2]._outpostStation[0]._card.remove();
- scene->_gameBoardSide[2]._outpostStation[1]._card.remove();
- scene->_gameBoardSide[2]._outpostStation[2]._card.remove();
- scene->_gameBoardSide[2]._outpostStation[3]._card.remove();
- scene->_gameBoardSide[2]._outpostStation[4]._card.remove();
- scene->_gameBoardSide[2]._outpostStation[5]._card.remove();
- scene->_gameBoardSide[2]._outpostStation[6]._card.remove();
- scene->_gameBoardSide[2]._outpostStation[7]._card.remove();
-
- scene->_gameBoardSide[1]._outpostStation[0]._card.remove();
- scene->_gameBoardSide[1]._outpostStation[1]._card.remove();
-
- scene->_gameBoardSide[3]._outpostStation[0]._card.remove();
- scene->_gameBoardSide[3]._outpostStation[1]._card.remove();
- scene->_gameBoardSide[3]._outpostStation[2]._card.remove();
-
- scene->_gameBoardSide[0]._outpostStation[0]._card.remove();
- scene->_gameBoardSide[0]._outpostStation[1]._card.remove();
-
- scene->_stockPile.setup(1332, 5, 1);
- scene->_stockPile.setPosition(Common::Point(165, 95));
- scene->_stockPile.setPriority(110);
- scene->_stockPile._effect = EFFECT_SHADED;
- scene->_stockPile.show();
-
- scene->_gameBoardSide[1]._handCard[0]._card.postInit();
- scene->_gameBoardSide[1]._handCard[0]._card.setVisage(1332);
- scene->_gameBoardSide[1]._handCard[0]._card.setPosition(scene->_gameBoardSide[1]._handCard[0]._stationPos, 0);
- scene->_gameBoardSide[1]._handCard[0]._card.setStrip(1);
- scene->_gameBoardSide[1]._handCard[0]._card.setFrame(4);
- scene->_gameBoardSide[1]._handCard[0]._card.fixPriority(170);
-
- scene->_gameBoardSide[1]._handCard[1]._card.postInit();
- scene->_gameBoardSide[1]._handCard[1]._card.setVisage(1332);
- scene->_gameBoardSide[1]._handCard[1]._card.setPosition(scene->_gameBoardSide[1]._handCard[1]._stationPos, 0);
- scene->_gameBoardSide[1]._handCard[1]._card.setStrip(1);
- scene->_gameBoardSide[1]._handCard[1]._card.setFrame(4);
- scene->_gameBoardSide[1]._handCard[1]._card.fixPriority(170);
-
- scene->_gameBoardSide[1]._handCard[2]._card.postInit();
- scene->_gameBoardSide[1]._handCard[2]._card.setVisage(1332);
- scene->_gameBoardSide[1]._handCard[2]._card.setPosition(scene->_gameBoardSide[1]._handCard[2]._stationPos, 0);
- scene->_gameBoardSide[1]._handCard[2]._card.setStrip(1);
- scene->_gameBoardSide[1]._handCard[2]._card.setFrame(4);
- scene->_gameBoardSide[1]._handCard[2]._card.fixPriority(170);
-
- scene->_gameBoardSide[2]._handCard[0]._cardId = 30;
- scene->_gameBoardSide[2]._handCard[0]._card.postInit();
- scene->_gameBoardSide[2]._handCard[0]._card.setVisage(1332);
- scene->_gameBoardSide[2]._handCard[0]._card.setPosition(scene->_gameBoardSide[2]._handCard[0]._stationPos, 0);
- scene->_gameBoardSide[2]._handCard[0]._card.setStrip(1);
- scene->_gameBoardSide[2]._handCard[0]._card.setFrame(2);
- scene->_gameBoardSide[2]._handCard[0]._card.fixPriority(170);
- scene->setAnimationInfo(&scene->_gameBoardSide[2]._handCard[0]);
-
- scene->_gameBoardSide[2]._handCard[1]._cardId = 16;
- scene->_gameBoardSide[2]._handCard[1]._card.postInit();
- scene->_gameBoardSide[2]._handCard[1]._card.setVisage(1332);
- scene->_gameBoardSide[2]._handCard[1]._card.setPosition(scene->_gameBoardSide[2]._handCard[1]._stationPos, 0);
- scene->_gameBoardSide[2]._handCard[1]._card.setStrip(1);
- scene->_gameBoardSide[2]._handCard[1]._card.setFrame(2);
- scene->_gameBoardSide[2]._handCard[1]._card.fixPriority(170);
- scene->setAnimationInfo(&scene->_gameBoardSide[2]._handCard[1]);
-
- scene->_gameBoardSide[2]._handCard[2]._cardId = 1;
- scene->_gameBoardSide[2]._handCard[2]._card.postInit();
- scene->_gameBoardSide[2]._handCard[2]._card.setVisage(1332);
- scene->_gameBoardSide[2]._handCard[2]._card.setPosition(scene->_gameBoardSide[2]._handCard[2]._stationPos, 0);
- scene->_gameBoardSide[2]._handCard[2]._card.setStrip(1);
- scene->_gameBoardSide[2]._handCard[2]._card.setFrame(2);
- scene->_gameBoardSide[2]._handCard[2]._card.fixPriority(170);
- scene->setAnimationInfo(&scene->_gameBoardSide[2]._handCard[2]);
-
- scene->_gameBoardSide[3]._handCard[0]._card.postInit();
- scene->_gameBoardSide[3]._handCard[0]._card.setVisage(1332);
- scene->_gameBoardSide[3]._handCard[0]._card.setPosition(scene->_gameBoardSide[3]._handCard[0]._stationPos, 0);
- scene->_gameBoardSide[3]._handCard[0]._card.setStrip(1);
- scene->_gameBoardSide[3]._handCard[0]._card.setFrame(3);
- scene->_gameBoardSide[3]._handCard[0]._card.fixPriority(170);
-
- scene->_gameBoardSide[3]._handCard[1]._card.postInit();
- scene->_gameBoardSide[3]._handCard[1]._card.setVisage(1332);
- scene->_gameBoardSide[3]._handCard[1]._card.setPosition(scene->_gameBoardSide[3]._handCard[1]._stationPos, 0);
- scene->_gameBoardSide[3]._handCard[1]._card.setStrip(1);
- scene->_gameBoardSide[3]._handCard[1]._card.setFrame(3);
- scene->_gameBoardSide[3]._handCard[1]._card.fixPriority(170);
-
- scene->_gameBoardSide[3]._handCard[2]._card.postInit();
- scene->_gameBoardSide[3]._handCard[2]._card.setVisage(1332);
- scene->_gameBoardSide[3]._handCard[2]._card.setPosition(scene->_gameBoardSide[3]._handCard[2]._stationPos, 0);
- scene->_gameBoardSide[3]._handCard[2]._card.setStrip(1);
- scene->_gameBoardSide[3]._handCard[2]._card.setFrame(3);
- scene->_gameBoardSide[3]._handCard[2]._card.fixPriority(170);
-
- scene->_gameBoardSide[0]._handCard[0]._card.postInit();
- scene->_gameBoardSide[0]._handCard[0]._card.setVisage(1332);
- scene->_gameBoardSide[0]._handCard[0]._card.setPosition(scene->_gameBoardSide[0]._handCard[0]._stationPos, 0);
- scene->_gameBoardSide[0]._handCard[0]._card.setStrip(1);
- scene->_gameBoardSide[0]._handCard[0]._card.setFrame(2);
- scene->_gameBoardSide[0]._handCard[0]._card.fixPriority(170);
-
- scene->_gameBoardSide[0]._handCard[1]._card.postInit();
- scene->_gameBoardSide[0]._handCard[1]._card.setVisage(1332);
- scene->_gameBoardSide[0]._handCard[1]._card.setPosition(scene->_gameBoardSide[0]._handCard[1]._stationPos, 0);
- scene->_gameBoardSide[0]._handCard[1]._card.setStrip(1);
- scene->_gameBoardSide[0]._handCard[1]._card.setFrame(2);
- scene->_gameBoardSide[0]._handCard[1]._card.fixPriority(170);
-
- scene->_gameBoardSide[0]._handCard[2]._card.postInit();
- scene->_gameBoardSide[0]._handCard[2]._card.setVisage(1332);
- scene->_gameBoardSide[0]._handCard[2]._card.setPosition(scene->_gameBoardSide[0]._handCard[2]._stationPos, 0);
- scene->_gameBoardSide[0]._handCard[2]._card.setStrip(1);
- scene->_gameBoardSide[0]._handCard[2]._card.setFrame(2);
- scene->_gameBoardSide[0]._handCard[2]._card.fixPriority(170);
-
- R2_GLOBALS._sceneObjects->draw();
-
- scene->actionDisplay(1331, 10, 159, 10, 1, 200, 0, 7, 0, 154, 154);
- scene->_animatedCard._card.setPosition(Common::Point(162, 95), 0);
- scene->_animatedCard._card.show();
- scene->_aSound2.play(61);
-
- Common::Point pt(91, 174);
- NpcMover *mover = new NpcMover();
- scene->_animatedCard._card.addMover(mover, &pt, this);
- }
- break;
- case 2: {
- scene->_gameBoardSide[2]._handCard[3]._cardId = 2;
- scene->_gameBoardSide[2]._handCard[3]._card.postInit();
- scene->_gameBoardSide[2]._handCard[3]._card.setVisage(1332);
- scene->_gameBoardSide[2]._handCard[3]._card.setPosition(scene->_gameBoardSide[2]._handCard[3]._stationPos, 0);
- scene->_gameBoardSide[2]._handCard[3]._card.setStrip(1);
- scene->_gameBoardSide[2]._handCard[3]._card.setFrame(2);
- scene->_gameBoardSide[2]._handCard[3]._card.fixPriority(170);
-
- scene->_animatedCard._card.hide();
- scene->setAnimationInfo(&scene->_gameBoardSide[2]._handCard[3]);
-
- R2_GLOBALS._sceneObjects->draw();
-
- waitFrames(60);
- scene->actionDisplay(1331, 11, 159, 10, 1, 200, 0, 7, 0, 154, 154);
- scene->actionDisplay(1331, 12, 159, 10, 1, 200, 0, 7, 0, 154, 154);
-
- scene->_gameBoardSide[2]._outpostStation[1]._cardId = 1;
- scene->_gameBoardSide[2]._outpostStation[1]._card.postInit();
- scene->_gameBoardSide[2]._outpostStation[1]._card.setVisage(1332);
- scene->_gameBoardSide[2]._outpostStation[1]._card.setPosition(scene->_gameBoardSide[2]._outpostStation[1]._stationPos, 0);
- scene->_gameBoardSide[2]._outpostStation[1]._card.hide();
-
- scene->_animatedCard._card.setStrip(scene->_gameBoardSide[2]._handCard[2]._card._strip);
- scene->_animatedCard._card.setFrame(scene->_gameBoardSide[2]._handCard[2]._card._frame);
- scene->_animatedCard._card.animate(ANIM_MODE_NONE, NULL);
-
- scene->_gameBoardSide[2]._handCard[2]._cardId = 0;
- scene->_gameBoardSide[2]._handCard[2]._card.remove();
-
- scene->_animatedCard._card.setPosition(scene->_gameBoardSide[2]._handCard[2]._stationPos, 0);
- scene->_animatedCard._card.show();
-
- NpcMover *mover = new NpcMover();
- scene->_animatedCard._card.addMover(mover, &scene->_gameBoardSide[2]._outpostStation[1]._stationPos, this);
- }
- break;
- case 3: {
- scene->_animatedCard._card.hide();
- scene->setAnimationInfo(&scene->_gameBoardSide[2]._outpostStation[1]);
- scene->_aSound1.play(59);
-
- R2_GLOBALS._sceneObjects->draw();
-
- waitFrames(60);
- scene->actionDisplay(1331, 13, 159, 10, 1, 200, 0, 7, 0, 154, 154);
-
- scene->_gameBoardSide[2]._outpostStation[1]._cardId = scene->_gameBoardSide[2]._handCard[3]._cardId;
-
- scene->_animatedCard._card.setStrip(scene->_gameBoardSide[2]._handCard[3]._card._strip);
- scene->_animatedCard._card.setFrame(scene->_gameBoardSide[2]._handCard[3]._card._frame);
-
- scene->_gameBoardSide[2]._handCard[3]._cardId = 0;
- scene->_gameBoardSide[2]._handCard[3]._card.remove();
-
- scene->_animatedCard._card.setPosition(scene->_gameBoardSide[2]._handCard[3]._stationPos, 0);
- scene->_animatedCard._card.show();
-
- NpcMover *mover = new NpcMover();
- scene->_animatedCard._card.addMover(mover, &scene->_gameBoardSide[2]._outpostStation[1]._stationPos, this);
- }
- break;
- case 4: {
- scene->_animatedCard._card.hide();
- scene->setAnimationInfo(&scene->_gameBoardSide[2]._outpostStation[1]);
- scene->_aSound1.play(59);
-
- scene->_discardPile._cardId = 1;
- scene->_discardPile._card.hide();
-
- scene->_animatedCard._card.setStrip(5);
- scene->_animatedCard._card.setFrame(1);
- scene->_animatedCard._card.animate(ANIM_MODE_2, NULL);
- scene->_animatedCard._card.setPosition(scene->_gameBoardSide[2]._outpostStation[1]._stationPos, 0);
- scene->_animatedCard._card.show();
-
- NpcMover *mover = new NpcMover();
- scene->_animatedCard._card.addMover(mover, &scene->_discardPile._stationPos, this);
- }
- break;
- case 5: {
- scene->_animatedCard._card.hide();
-
- scene->_discardPile._card.postInit();
- scene->_discardPile._card.setVisage(1332);
- scene->_discardPile._card.setPosition(scene->_discardPile._stationPos, 0);
- scene->setAnimationInfo(&scene->_discardPile);
- scene->_aSound2.play(61);
-
- R2_GLOBALS._sceneObjects->draw();
-
- waitFrames(60);
- scene->actionDisplay(1331, 14, 159, 10, 1, 200, 0, 7, 0, 154, 154);
-
- scene->_gameBoardSide[2]._delayCard._card.postInit();
- scene->_gameBoardSide[2]._delayCard._card.setVisage(1332);
- scene->_gameBoardSide[2]._delayCard._card.setPosition(scene->_gameBoardSide[2]._delayCard._stationPos, 0);
- scene->_gameBoardSide[2]._delayCard._card.hide();
-
- scene->_gameBoardSide[3]._handCard[2]._cardId = 0;
- scene->_gameBoardSide[3]._handCard[2].remove();
-
- scene->_animatedCard._card.setPosition(scene->_gameBoardSide[3]._handCard[2]._stationPos, 0);
- scene->_animatedCard._card.show();
-
- NpcMover *mover = new NpcMover();
- scene->_animatedCard._card.addMover(mover, &scene->_gameBoardSide[2]._delayCard._stationPos, this);
- }
- break;
- case 6: {
- scene->_animatedCard._card.hide();
- scene->_gameBoardSide[2]._delayCard._cardId = 21;
- scene->setAnimationInfo(&scene->_gameBoardSide[2]._delayCard);
- scene->_aSound1.play(57);
-
- R2_GLOBALS._sceneObjects->draw();
-
- waitFrames(60);
- scene->actionDisplay(1331, 15, 159, 10, 1, 200, 0, 7, 0, 154, 154);
-
- int tmpVal = 15;
- int i = -1;
-
- for (i = 0; i <= 7; i++) {
- tmpVal += 29;
-
- scene->_upperDisplayCard[i].postInit();
- scene->_upperDisplayCard[i].setVisage(1332);
- scene->_upperDisplayCard[i].setPosition(Common::Point(tmpVal, 90), 0);
- scene->_upperDisplayCard[i].setStrip(3);
- scene->_upperDisplayCard[i].fixPriority(190);
-
- scene->_lowerDisplayCard[i].postInit();
- scene->_lowerDisplayCard[i].setVisage(1332);
- scene->_lowerDisplayCard[i].setPosition(Common::Point(tmpVal, 90), 0);
- scene->_lowerDisplayCard[i].setStrip(7);
- scene->_lowerDisplayCard[i].setFrame(1);
- scene->_lowerDisplayCard[i].fixPriority(180);
- }
-
- scene->_upperDisplayCard[0].setFrame(1);
- scene->_upperDisplayCard[1].setFrame(3);
- scene->_upperDisplayCard[2].setFrame(6);
- scene->_upperDisplayCard[3].setFrame(8);
- scene->_upperDisplayCard[4].setFrame(9);
- scene->_upperDisplayCard[5].setFrame(10);
- scene->_upperDisplayCard[6].setFrame(11);
- scene->_upperDisplayCard[7].setFrame(12);
-
- R2_GLOBALS._sceneObjects->draw();
-
- waitFrames(240);
-
- scene->_upperDisplayCard[0].remove();
- scene->_upperDisplayCard[1].remove();
- scene->_upperDisplayCard[2].remove();
- scene->_upperDisplayCard[3].remove();
- scene->_upperDisplayCard[4].remove();
- scene->_upperDisplayCard[5].remove();
- scene->_upperDisplayCard[6].remove();
- scene->_upperDisplayCard[7].remove();
-
- scene->_lowerDisplayCard[0].remove();
- scene->_lowerDisplayCard[1].remove();
- scene->_lowerDisplayCard[2].remove();
- scene->_lowerDisplayCard[3].remove();
- scene->_lowerDisplayCard[4].remove();
- scene->_lowerDisplayCard[5].remove();
- scene->_lowerDisplayCard[6].remove();
- scene->_lowerDisplayCard[7].remove();
-
- scene->_discardPile._cardId = scene->_gameBoardSide[2]._delayCard._cardId;
-
- scene->_gameBoardSide[2]._delayCard._cardId = 0;
- scene->_gameBoardSide[2]._delayCard._card.remove();
-
- scene->_animatedCard._card.setPosition(scene->_gameBoardSide[2]._delayCard._stationPos, 0);
- scene->_animatedCard._card.show();
-
- NpcMover *mover = new NpcMover();
- scene->_animatedCard._card.addMover(mover, &scene->_discardPile._stationPos, this);
- }
- break;
- case 7: {
- scene->_animatedCard._card.hide();
- scene->setAnimationInfo(&scene->_discardPile);
- scene->_aSound2.play(61);
-
- R2_GLOBALS._sceneObjects->draw();
-
- scene->_gameBoardSide[2]._delayCard._card.postInit();
- scene->_gameBoardSide[2]._delayCard._card.setVisage(1332);
- scene->_gameBoardSide[2]._delayCard._card.setPosition(scene->_gameBoardSide[2]._delayCard._stationPos, 0);
- scene->_gameBoardSide[2]._delayCard._card.hide();
-
- scene->_gameBoardSide[3]._handCard[1]._cardId = 0;
- scene->_gameBoardSide[3]._handCard[1].remove();
-
- scene->_animatedCard._card.setPosition(scene->_gameBoardSide[3]._handCard[1]._stationPos, 0);
- scene->_animatedCard._card.show();
-
- NpcMover *mover = new NpcMover();
- scene->_animatedCard._card.addMover(mover, &scene->_gameBoardSide[2]._delayCard._stationPos, this);
- }
- break;
- case 8: {
- scene->_animatedCard._card.hide();
- scene->_gameBoardSide[2]._delayCard._cardId = 14;
- scene->setAnimationInfo(&scene->_gameBoardSide[2]._delayCard);
- scene->_aSound1.play(57);
-
- R2_GLOBALS._sceneObjects->draw();
-
- scene->actionDisplay(1331, 16, 159, 10, 1, 200, 0, 7, 0, 154, 154);
- int tmpVal = 72;
- int i = -1;
-
- for (i = 0; i <= 3; i++) {
- tmpVal += 29;
- scene->_upperDisplayCard[i].postInit();
- scene->_upperDisplayCard[i].setVisage(1332);
- scene->_upperDisplayCard[i].setPosition(Common::Point(tmpVal, 71), 0);
- scene->_upperDisplayCard[i].setStrip(3);
- scene->_upperDisplayCard[i].fixPriority(190);
-
- scene->_lowerDisplayCard[i].postInit();
- scene->_lowerDisplayCard[i].setVisage(1332);
- scene->_lowerDisplayCard[i].setPosition(Common::Point(tmpVal, 71), 0);
- scene->_lowerDisplayCard[i].setStrip(7);
- scene->_lowerDisplayCard[i].setFrame(1);
- scene->_lowerDisplayCard[i].fixPriority(180);
- }
-
- scene->_upperDisplayCard[0].setFrame(2);
- scene->_upperDisplayCard[1].setFrame(5);
- scene->_upperDisplayCard[2].setFrame(7);
- scene->_upperDisplayCard[3].setFrame(15);
-
- R2_GLOBALS._sceneObjects->draw();
-
- waitFrames(240);
- scene->actionDisplay(1331, 17, 159, 10, 1, 200, 0, 7, 0, 154, 154);
-
- tmpVal = 72;
- for (i = 4; i <= 7; i++) {
- tmpVal += 29;
-
- scene->_upperDisplayCard[i].postInit();
- scene->_upperDisplayCard[i].setVisage(1332);
- scene->_upperDisplayCard[i].setPosition(Common::Point(tmpVal, 100), 0);
- scene->_upperDisplayCard[i].setStrip(4);
- scene->_upperDisplayCard[i].fixPriority(190);
-
- scene->_lowerDisplayCard[i].postInit();
- scene->_lowerDisplayCard[i].setVisage(1332);
- scene->_lowerDisplayCard[i].setPosition(Common::Point(tmpVal, 100), 0);
- scene->_lowerDisplayCard[i].setStrip(7);
- scene->_lowerDisplayCard[i].setFrame(1);
- scene->_lowerDisplayCard[i].fixPriority(180);
- }
-
- scene->_upperDisplayCard[4].setFrame(1);
- scene->_upperDisplayCard[5].setFrame(5);
- scene->_upperDisplayCard[6].setFrame(7);
- scene->_upperDisplayCard[7].setFrame(3);
-
- R2_GLOBALS._sceneObjects->draw();
-
- waitFrames(240);
-
- scene->_upperDisplayCard[0].remove();
- scene->_upperDisplayCard[1].remove();
- scene->_upperDisplayCard[2].remove();
- scene->_upperDisplayCard[3].remove();
- scene->_upperDisplayCard[4].remove();
- scene->_upperDisplayCard[5].remove();
- scene->_upperDisplayCard[6].remove();
- scene->_upperDisplayCard[7].remove();
-
- scene->_lowerDisplayCard[0].remove();
- scene->_lowerDisplayCard[1].remove();
- scene->_lowerDisplayCard[2].remove();
- scene->_lowerDisplayCard[3].remove();
- scene->_lowerDisplayCard[4].remove();
- scene->_lowerDisplayCard[5].remove();
- scene->_lowerDisplayCard[6].remove();
- scene->_lowerDisplayCard[7].remove();
-
- scene->_discardPile._cardId = scene->_gameBoardSide[2]._handCard[0]._cardId;
-
- scene->_animatedCard._card.setStrip(scene->_gameBoardSide[2]._handCard[0]._card._strip);
- scene->_animatedCard._card.setFrame(scene->_gameBoardSide[2]._handCard[0]._card._frame);
- scene->_animatedCard._card.animate(ANIM_MODE_NONE, NULL);
-
- scene->_gameBoardSide[2]._handCard[0]._cardId = 0;
- scene->_gameBoardSide[2]._handCard[0]._card.remove();
-
- scene->_animatedCard._card.setPosition(scene->_gameBoardSide[2]._handCard[0]._stationPos, 0);
- scene->_animatedCard._card.show();
-
- NpcMover *mover = new NpcMover();
- scene->_animatedCard._card.addMover(mover, &scene->_gameBoardSide[2]._delayCard._stationPos, this);
- }
- break;
- case 9: {
- scene->_aSound1.play(58);
- scene->_gameBoardSide[2]._delayCard._cardId = 0;
- scene->_gameBoardSide[2]._delayCard.remove();
- scene->_animatedCard._card.setStrip(5);
- scene->_animatedCard._card.setFrame(1);
- scene->_animatedCard._card.animate(ANIM_MODE_2, NULL);
- scene->_animatedCard._card.setPosition(scene->_gameBoardSide[2]._delayCard._stationPos, 0);
- scene->_animatedCard._card.show();
-
- NpcMover *mover = new NpcMover();
- scene->_animatedCard._card.addMover(mover, &scene->_discardPile._stationPos, this);
- }
- break;
- case 10: {
- scene->_animatedCard._card.hide();
- scene->setAnimationInfo(&scene->_discardPile);
- scene->_aSound2.play(61);
-
- R2_GLOBALS._sceneObjects->draw();
- scene->actionDisplay(1331, 18, 159, 10, 1, 200, 0, 7, 0, 154, 154);
-
- scene->_upperDisplayCard[0].postInit();
- scene->_upperDisplayCard[0].setVisage(1332);
- scene->_upperDisplayCard[0].setPosition(Common::Point(131, 71), 0);
- scene->_upperDisplayCard[0].fixPriority(190);
- scene->_upperDisplayCard[0].setStrip(3);
- scene->_upperDisplayCard[0].setFrame(4);
-
- scene->_lowerDisplayCard[0].postInit();
- scene->_lowerDisplayCard[0].setVisage(1332);
- scene->_lowerDisplayCard[0].setPosition(Common::Point(131, 71), 0);
- scene->_lowerDisplayCard[0].setStrip(7);
- scene->_lowerDisplayCard[0].setFrame(1);
- scene->_lowerDisplayCard[0].fixPriority(180);
-
- scene->_upperDisplayCard[1].postInit();
- scene->_upperDisplayCard[1].setVisage(1332);
- scene->_upperDisplayCard[1].setPosition(Common::Point(160, 71), 0);
- scene->_upperDisplayCard[1].fixPriority(190);
- scene->_upperDisplayCard[1].setStrip(3);
- scene->_upperDisplayCard[1].setFrame(16);
-
- scene->_lowerDisplayCard[1].postInit();
- scene->_lowerDisplayCard[1].setVisage(1332);
- scene->_lowerDisplayCard[1].setPosition(Common::Point(160, 71), 0);
- scene->_lowerDisplayCard[1].setStrip(7);
- scene->_lowerDisplayCard[1].setFrame(1);
- scene->_lowerDisplayCard[1].fixPriority(180);
-
- scene->_upperDisplayCard[2].postInit();
- scene->_upperDisplayCard[2].setVisage(1332);
- scene->_upperDisplayCard[2].setPosition(Common::Point(131, 100), 0);
- scene->_upperDisplayCard[2].fixPriority(190);
- scene->_upperDisplayCard[2].setStrip(4);
- scene->_upperDisplayCard[2].setFrame(4);
-
- scene->_lowerDisplayCard[2].postInit();
- scene->_lowerDisplayCard[2].setVisage(1332);
- scene->_lowerDisplayCard[2].setPosition(Common::Point(131, 100), 0);
- scene->_lowerDisplayCard[2].setStrip(7);
- scene->_lowerDisplayCard[2].setFrame(1);
- scene->_lowerDisplayCard[2].fixPriority(180);
-
- scene->_upperDisplayCard[3].postInit();
- scene->_upperDisplayCard[3].setVisage(1332);
- scene->_upperDisplayCard[3].setPosition(Common::Point(160, 100), 0);
- scene->_upperDisplayCard[3].fixPriority(190);
- scene->_upperDisplayCard[3].setStrip(4);
- scene->_upperDisplayCard[3].setFrame(2);
-
- scene->_lowerDisplayCard[3].postInit();
- scene->_lowerDisplayCard[3].setVisage(1332);
- scene->_lowerDisplayCard[3].setPosition(Common::Point(160, 100), 0);
- scene->_lowerDisplayCard[3].setStrip(7);
- scene->_lowerDisplayCard[3].setFrame(1);
- scene->_lowerDisplayCard[3].fixPriority(180);
-
- R2_GLOBALS._sceneObjects->draw();
-
- waitFrames(240);
-
- scene->_upperDisplayCard[0].remove();
- scene->_upperDisplayCard[1].remove();
- scene->_upperDisplayCard[2].remove();
- scene->_upperDisplayCard[3].remove();
-
- scene->_lowerDisplayCard[0].remove();
- scene->_lowerDisplayCard[1].remove();
- scene->_lowerDisplayCard[2].remove();
- scene->_lowerDisplayCard[3].remove();
-
- scene->_currentPlayerArrow.setFrame(1);
- scene->_currentPlayerArrow.show();
- scene->_currentPlayerArrow.animate(ANIM_MODE_2, NULL);
-
- R2_GLOBALS._sceneObjects->draw();
-
- scene->actionDisplay(1331, 19, 159, 10, 1, 220, 0, 7, 0, 154, 154);
-
- scene->_currentPlayerArrow.hide();
-
- scene->actionDisplay(1331, 20, 159, 10, 1, 220, 0, 7, 0, 154, 154);
- scene->actionDisplay(1331, 21, 159, 10, 1, 220, 0, 7, 0, 154, 154);
-
- scene->_discardPile._cardId = scene->_gameBoardSide[2]._handCard[1]._cardId;
-
- scene->_animatedCard._card.setStrip(scene->_gameBoardSide[2]._handCard[1]._card._strip);
- scene->_animatedCard._card.setFrame(scene->_gameBoardSide[2]._handCard[1]._card._frame);
- scene->_animatedCard._card.animate(ANIM_MODE_NONE, NULL);
-
- scene->_gameBoardSide[2]._handCard[1]._cardId = 0;
- scene->_gameBoardSide[2]._handCard[1]._card.remove();
-
- scene->_animatedCard._card.setPosition(scene->_gameBoardSide[2]._handCard[1]._stationPos, 0);
- scene->_animatedCard._card.show();
-
- NpcMover *mover = new NpcMover();
- scene->_animatedCard._card.addMover(mover, &scene->_discardPile._stationPos, this);
- }
- break;
- case 11: {
- scene->_animatedCard._card.hide();
- scene->setAnimationInfo(&scene->_discardPile);
- scene->_aSound2.play(61);
- scene->_animatedCard._card.setStrip(5);
- scene->_animatedCard._card.setFrame(1);
- scene->_animatedCard._card.animate(ANIM_MODE_2, NULL);
-
- R2_GLOBALS._sceneObjects->draw();
-
- scene->actionDisplay(1331, 22, 159, 10, 1, 200, 0, 7, 0, 154, 154);
-
- int i = -1;
- for (i = 0; i <= 3; i ++) {
- scene->_gameBoardSide[3]._handCard[i]._cardId = 0;
- scene->_gameBoardSide[3]._handCard[i]._card.remove();
-
- scene->_gameBoardSide[2]._handCard[i]._cardId = 0;
- scene->_gameBoardSide[2]._handCard[i]._card.remove();
-
- scene->_gameBoardSide[0]._handCard[i]._cardId = 0;
- scene->_gameBoardSide[0]._handCard[i]._card.remove();
-
- scene->_gameBoardSide[1]._handCard[i]._cardId = 0;
- scene->_gameBoardSide[1]._handCard[i]._card.remove();
- }
-
- for (i = 0; i <= 7; i++) {
- scene->_gameBoardSide[3]._outpostStation[i]._cardId = 0;
- scene->_gameBoardSide[3]._outpostStation[i]._card.remove();
-
- scene->_gameBoardSide[2]._outpostStation[i]._cardId = 0;
- scene->_gameBoardSide[2]._outpostStation[i]._card.remove();
-
- scene->_gameBoardSide[0]._outpostStation[i]._cardId = 0;
- scene->_gameBoardSide[0]._outpostStation[i]._card.remove();
-
- scene->_gameBoardSide[1]._outpostStation[i]._cardId = 0;
- scene->_gameBoardSide[1]._outpostStation[i]._card.remove();
- }
-
- scene->_gameBoardSide[2]._delayCard._cardId = 0;
- scene->_gameBoardSide[2]._delayCard._card.remove();
-
- scene->_discardPile._cardId = 0;
- scene->_discardPile._card.remove();
-
- scene->_stockPile.remove();
- }
- // No break on purpose
- case 0:
- R2_GLOBALS._sceneObjects->draw();
- signal();
- break;
- case 12:
- scene->suggestInstructions();
- remove();
- break;
- default:
- break;
- }
-}
-
-/**
- * Shuffle cards animation
- */
-void Scene1337::Action2::signal() {
- Scene1337 *scene = (Scene1337 *)R2_GLOBALS._sceneManager._scene;
-
- switch (_actionIndex++) {
- case 0:
- scene->_shuffleAnimation._card.postInit();
- scene->_shuffleAnimation._card.setVisage(1332);
- scene->_shuffleAnimation._card.setStrip(8);
- scene->_shuffleAnimation._card.setFrame(1);
- scene->_shuffleAnimation._card.fixPriority(300);
- scene->_shuffleAnimation._card.setPosition(Common::Point(156, 108));
-
- scene->_discardPile._card.remove();
- scene->_discardPile._cardId = 0;
-
- scene->_aSound1.play(60);
- scene->_shuffleAnimation._card.animate(ANIM_MODE_5, this);
- break;
- case 1:
- scene->_shuffleAnimation._card.setFrame(1);
-
- scene->_aSound1.play(60);
- scene->_shuffleAnimation._card.animate(ANIM_MODE_5, this);
- break;
- case 2: {
- Common::Point pt(156, 108);
- NpcMover *mover = new NpcMover();
- scene->_shuffleAnimation._card.addMover(mover, &pt, this);
- }
- break;
- case 3:
- scene->_shuffleAnimation._card.remove();
- scene->_stockPile.setup(1332, 5, 1);
- scene->_stockPile.setPosition(Common::Point(162, 95));
- scene->_stockPile.setPriority(110);
- scene->_stockPile._effect = EFFECT_SHADED;
- scene->_stockPile.show();
- scene->_shuffleEndedFl = true;
- break;
- default:
- break;
- }
-}
-
-/**
- * Deal cards
- */
-void Scene1337::Action3::signal() {
- Scene1337 *scene = (Scene1337 *)R2_GLOBALS._sceneManager._scene;
-
- scene->_animatedCard._card.setPosition(Common::Point(162, 95), 0);
-
- switch (_actionIndex++) {
- case 0: {
- scene->_animatedCard._card._moveDiff = Common::Point(30, 30);
- scene->_animatedCard._card.setVisage(1332);
- scene->_animatedCard._card.setStrip(5);
- scene->_animatedCard._card.setFrame(1);
- scene->_animatedCard._card.fixPriority(400);
- scene->_animatedCard._card.animate(ANIM_MODE_2, NULL);
- scene->_aSound2.play(61);
-
- Common::Point pt(283, 146);
- NpcMover *mover = new NpcMover();
- scene->_animatedCard._card.addMover(mover, &pt, this);
-
- scene->_animatedCard._card.show();
- scene->_gameBoardSide[1]._handCard[0]._cardId = scene->_availableCardsPile[scene->_cardsAvailableNumb];
- }
- break;
- case 1: {
- scene->_gameBoardSide[1]._handCard[0]._card.postInit();
- scene->_gameBoardSide[1]._handCard[0]._card._moveDiff = Common::Point(30, 30);
- scene->_gameBoardSide[1]._handCard[0]._card.setVisage(1332);
- scene->_gameBoardSide[1]._handCard[0]._card.setPosition(scene->_gameBoardSide[1]._handCard[0]._stationPos, 0);
- scene->_gameBoardSide[1]._handCard[0]._card.setStrip(1);
- scene->_gameBoardSide[1]._handCard[0]._card.setFrame(4);
- scene->_gameBoardSide[1]._handCard[0]._card.fixPriority(170);
- scene->_aSound2.play(61);
-
- Common::Point pt(10, 174);
- NpcMover *mover = new NpcMover();
- scene->_animatedCard._card.addMover(mover, &pt, this);
-
- scene->_gameBoardSide[2]._handCard[0]._cardId = scene->_availableCardsPile[scene->_cardsAvailableNumb];
- }
- break;
- case 2: {
- scene->_gameBoardSide[2]._handCard[0]._card.postInit();
- scene->_gameBoardSide[2]._handCard[0]._card._moveDiff = Common::Point(30, 30);
- scene->_gameBoardSide[2]._handCard[0]._card.setVisage(1332);
- scene->_gameBoardSide[2]._handCard[0]._card.setPosition(scene->_gameBoardSide[2]._handCard[0]._stationPos, 0);
- scene->_gameBoardSide[2]._handCard[0]._card.fixPriority(170);
- if (scene->_gameBoardSide[2]._handCard[0]._cardId > 25) {
- scene->_gameBoardSide[2]._handCard[0]._card.setStrip(4);
- scene->_gameBoardSide[2]._handCard[0]._card.setFrame(scene->_gameBoardSide[2]._handCard[0]._cardId - 25);
- } else if (scene->_gameBoardSide[2]._handCard[0]._cardId > 9) {
- scene->_gameBoardSide[2]._handCard[0]._card.setStrip(3);
- scene->_gameBoardSide[2]._handCard[0]._card.setFrame(scene->_gameBoardSide[2]._handCard[0]._cardId - 9);
- } else {
- scene->_gameBoardSide[2]._handCard[0]._card.setStrip(2);
- scene->_gameBoardSide[2]._handCard[0]._card.setFrame(scene->_gameBoardSide[2]._handCard[0]._cardId);
- }
- scene->_aSound2.play(61);
-
- Common::Point pt(14, 14);
- NpcMover *mover = new NpcMover();
- scene->_animatedCard._card.addMover(mover, &pt, this);
-
- scene->_gameBoardSide[3]._handCard[0]._cardId = scene->_availableCardsPile[scene->_cardsAvailableNumb];
- }
- break;
- case 3: {
- scene->_gameBoardSide[3]._handCard[0]._card.postInit();
- scene->_gameBoardSide[3]._handCard[0]._card._moveDiff = Common::Point(30, 30);
- scene->_gameBoardSide[3]._handCard[0]._card.setVisage(1332);
- scene->_gameBoardSide[3]._handCard[0]._card.setPosition(scene->_gameBoardSide[3]._handCard[0]._stationPos, 0);
- scene->_gameBoardSide[3]._handCard[0]._card.setStrip(1);
- scene->_gameBoardSide[3]._handCard[0]._card.setFrame(3);
- scene->_gameBoardSide[3]._handCard[0]._card.fixPriority(170);
- scene->_aSound2.play(61);
-
- Common::Point pt(280, 5);
- NpcMover *mover = new NpcMover();
- scene->_animatedCard._card.addMover(mover, &pt, this);
-
- scene->_gameBoardSide[0]._handCard[0]._cardId = scene->_availableCardsPile[scene->_cardsAvailableNumb];
- }
- break;
- case 4: {
- scene->_gameBoardSide[0]._handCard[0]._card.postInit();
- scene->_gameBoardSide[0]._handCard[0]._card._moveDiff = Common::Point(30,30);
- scene->_gameBoardSide[0]._handCard[0]._card.setVisage(1332);
- scene->_gameBoardSide[0]._handCard[0]._card.setPosition(scene->_gameBoardSide[0]._handCard[0]._stationPos, 0);
- scene->_gameBoardSide[0]._handCard[0]._card.setStrip(5);
- scene->_gameBoardSide[0]._handCard[0]._card.setFrame(1);
- scene->_gameBoardSide[0]._handCard[0]._card.fixPriority(170);
- scene->_aSound2.play(61);
-
- Common::Point pt(283, 124);
- NpcMover *mover = new NpcMover();
- scene->_animatedCard._card.addMover(mover, &pt, this);
-
- scene->_gameBoardSide[1]._handCard[1]._cardId = scene->_availableCardsPile[scene->_cardsAvailableNumb];
- }
- break;
- case 5: {
- scene->_gameBoardSide[1]._handCard[1]._card.postInit();
- scene->_gameBoardSide[1]._handCard[1]._card._moveDiff = Common::Point(30, 30);
- scene->_gameBoardSide[1]._handCard[1]._card.setVisage(1332);
- scene->_gameBoardSide[1]._handCard[1]._card.setPosition(scene->_gameBoardSide[1]._handCard[1]._stationPos, 0);
- scene->_gameBoardSide[1]._handCard[1]._card.setStrip(1);
- scene->_gameBoardSide[1]._handCard[1]._card.setFrame(4);
- scene->_gameBoardSide[1]._handCard[1]._card.fixPriority(170);
- scene->_aSound2.play(61);
-
- Common::Point pt(37, 174);
- NpcMover *mover = new NpcMover();
- scene->_animatedCard._card.addMover(mover, &pt, this);
-
- scene->_gameBoardSide[2]._handCard[1]._cardId = scene->_availableCardsPile[scene->_cardsAvailableNumb];
- }
- break;
- case 6: {
- scene->_gameBoardSide[2]._handCard[1]._card.postInit();
- scene->_gameBoardSide[2]._handCard[1]._card._moveDiff = Common::Point(30, 30);
- scene->_gameBoardSide[2]._handCard[1]._card.setVisage(1332);
- scene->_gameBoardSide[2]._handCard[1]._card.setPosition(scene->_gameBoardSide[2]._handCard[1]._stationPos, 0);
- scene->_gameBoardSide[2]._handCard[1]._card.fixPriority(170);
-
- if (scene->_gameBoardSide[2]._handCard[1]._cardId > 25) {
- scene->_gameBoardSide[2]._handCard[1]._card.setStrip(4);
- scene->_gameBoardSide[2]._handCard[1]._card.setFrame(scene->_gameBoardSide[2]._handCard[1]._cardId - 25);
- } else if (scene->_gameBoardSide[2]._handCard[1]._cardId > 9) {
- scene->_gameBoardSide[2]._handCard[1]._card.setStrip(3);
- scene->_gameBoardSide[2]._handCard[1]._card.setFrame(scene->_gameBoardSide[2]._handCard[1]._cardId - 9);
- } else {
- scene->_gameBoardSide[2]._handCard[1]._card.setStrip(2);
- scene->_gameBoardSide[2]._handCard[1]._card.setFrame(scene->_gameBoardSide[2]._handCard[1]._cardId);
- }
-
- scene->_aSound2.play(61);
-
- Common::Point pt(14, 36);
- NpcMover *mover = new NpcMover();
- scene->_animatedCard._card.addMover(mover, &pt, this);
-
- scene->_gameBoardSide[3]._handCard[1]._cardId = scene->_availableCardsPile[scene->_cardsAvailableNumb];
- }
- break;
- case 7: {
- scene->_gameBoardSide[3]._handCard[1]._card.postInit();
- scene->_gameBoardSide[3]._handCard[1]._card._moveDiff = Common::Point(30, 30);
- scene->_gameBoardSide[3]._handCard[1]._card.setVisage(1332);
- scene->_gameBoardSide[3]._handCard[1]._card.setPosition(scene->_gameBoardSide[3]._handCard[1]._stationPos);
- scene->_gameBoardSide[3]._handCard[1]._card.setStrip(1);
- scene->_gameBoardSide[3]._handCard[1]._card.setFrame(3);
- scene->_gameBoardSide[3]._handCard[1]._card.fixPriority(170);
- scene->_aSound2.play(61);
-
- Common::Point pt(253, 5);
- NpcMover *mover = new NpcMover();
- scene->_animatedCard._card.addMover(mover, &pt, this);
-
- scene->_gameBoardSide[0]._handCard[1]._cardId = scene->_availableCardsPile[scene->_cardsAvailableNumb];
- }
- break;
- case 8: {
- scene->_gameBoardSide[0]._handCard[1]._card.postInit();
- scene->_gameBoardSide[0]._handCard[1]._card._moveDiff = Common::Point(30, 30);
- scene->_gameBoardSide[0]._handCard[1]._card.setVisage(1332);
- scene->_gameBoardSide[0]._handCard[1]._card.setPosition(scene->_gameBoardSide[0]._handCard[1]._stationPos, 0);
- scene->_gameBoardSide[0]._handCard[1]._card.setStrip(5);
- scene->_gameBoardSide[0]._handCard[1]._card.setFrame(1);
- scene->_gameBoardSide[0]._handCard[1]._card.fixPriority(170);
- scene->_aSound2.play(61);
-
- Common::Point pt(283, 102);
- NpcMover *mover = new NpcMover();
- scene->_animatedCard._card.addMover(mover, &pt, this);
-
- scene->_gameBoardSide[1]._handCard[2]._cardId = scene->_availableCardsPile[scene->_cardsAvailableNumb];
- }
- break;
- case 9: {
- scene->_gameBoardSide[1]._handCard[2]._card.postInit();
- scene->_gameBoardSide[1]._handCard[2]._card._moveDiff = Common::Point(30, 30);
- scene->_gameBoardSide[1]._handCard[2]._card.setVisage(1332);
- scene->_gameBoardSide[1]._handCard[2]._card.setPosition(scene->_gameBoardSide[1]._handCard[2]._stationPos, 0);
- scene->_gameBoardSide[1]._handCard[2]._card.setStrip(1);
- scene->_gameBoardSide[1]._handCard[2]._card.setFrame(4);
- scene->_gameBoardSide[1]._handCard[2]._card.fixPriority(170);
- scene->_aSound2.play(61);
-
- Common::Point pt(64, 174);
- NpcMover *mover = new NpcMover();
- scene->_animatedCard._card.addMover(mover, &pt, this);
-
- scene->_gameBoardSide[2]._handCard[2]._cardId = scene->_availableCardsPile[scene->_cardsAvailableNumb];
- }
- break;
- case 10: {
- scene->_gameBoardSide[2]._handCard[2]._card.postInit();
- scene->_gameBoardSide[2]._handCard[2]._card._moveDiff = Common::Point(30, 30);
- scene->_gameBoardSide[2]._handCard[2]._card.setVisage(1332);
- scene->_gameBoardSide[2]._handCard[2]._card.setPosition(scene->_gameBoardSide[2]._handCard[2]._stationPos, 0);
- scene->_gameBoardSide[2]._handCard[2]._card.fixPriority(170);
-
- if (scene->_gameBoardSide[2]._handCard[2]._cardId > 25) {
- scene->_gameBoardSide[2]._handCard[2]._card.setStrip(4);
- scene->_gameBoardSide[2]._handCard[2]._card.setFrame(scene->_gameBoardSide[2]._handCard[2]._cardId - 25);
- } else if (scene->_gameBoardSide[2]._handCard[2]._cardId > 9) {
- scene->_gameBoardSide[2]._handCard[2]._card.setStrip(3);
- scene->_gameBoardSide[2]._handCard[2]._card.setFrame(scene->_gameBoardSide[2]._handCard[2]._cardId - 9);
- } else {
- scene->_gameBoardSide[2]._handCard[2]._card.setStrip(2);
- scene->_gameBoardSide[2]._handCard[2]._card.setFrame(scene->_gameBoardSide[2]._handCard[2]._cardId);
- }
-
- scene->_aSound2.play(61);
-
- Common::Point pt(14, 58);
- NpcMover *mover = new NpcMover();
- scene->_animatedCard._card.addMover(mover, &pt, this);
-
- scene->_gameBoardSide[3]._handCard[2]._cardId = scene->_availableCardsPile[scene->_cardsAvailableNumb];
- }
- break;
- case 11: {
- scene->_gameBoardSide[3]._handCard[2]._card.postInit();
- scene->_gameBoardSide[3]._handCard[2]._card._moveDiff = Common::Point(30, 30);
- scene->_gameBoardSide[3]._handCard[2]._card.setVisage(1332);
- scene->_gameBoardSide[3]._handCard[2]._card.setPosition(scene->_gameBoardSide[3]._handCard[2]._stationPos, 0);
- scene->_gameBoardSide[3]._handCard[2]._card.setStrip(1);
- scene->_gameBoardSide[3]._handCard[2]._card.setFrame(3);
- scene->_gameBoardSide[3]._handCard[2]._card.fixPriority(170);
- scene->_aSound2.play(61);
-
- Common::Point pt(226, 5);
- NpcMover *mover = new NpcMover();
- scene->_animatedCard._card.addMover(mover, &pt, this);
-
- scene->_gameBoardSide[0]._handCard[2]._cardId = scene->_availableCardsPile[scene->_cardsAvailableNumb];
- }
- break;
- case 12:
- scene->_gameBoardSide[0]._handCard[2]._card.postInit();
- scene->_gameBoardSide[0]._handCard[2]._card._moveDiff = Common::Point(30, 30);
- scene->_gameBoardSide[0]._handCard[2]._card.setVisage(1332);
- scene->_gameBoardSide[0]._handCard[2]._card.setPosition(scene->_gameBoardSide[0]._handCard[2]._stationPos, 0);
- scene->_gameBoardSide[0]._handCard[2]._card.setStrip(5);
- scene->_gameBoardSide[0]._handCard[2]._card.setFrame(1);
- scene->_gameBoardSide[0]._handCard[2]._card.fixPriority(170);
- scene->_animatedCard._card.hide();
- default:
- break;
- }
-
- if (_actionIndex > 12) {
- scene->_currentPlayerNumb = 0;
- R2_GLOBALS._sceneObjects->draw();
- scene->actionDisplay(1330, 0, 159, 10, 1, 200, 0, 7, 0, 154, 154);
- scene->handleNextTurn();
- } else if (_actionIndex >= 1) {
- scene->_availableCardsPile[scene->_cardsAvailableNumb] = 0;
- scene->_cardsAvailableNumb--;
- }
-}
-
-/**
- * Action used to handle the other players' turn
- */
-void Scene1337::Action4::signal() {
- Scene1337 *scene = (Scene1337 *)R2_GLOBALS._sceneManager._scene;
-
- switch (_actionIndex++) {
- case 0:
- if ( (scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[0]._cardId == 0)
- && (!scene->isStationCard(scene->_gameBoardSide[scene->_currentPlayerNumb]._delayCard._cardId))) {
- if (scene->_cardsAvailableNumb < 0)
- scene->shuffleCards();
- scene->_animatedCard._card.setPosition(Common::Point(162, 95), 0);
- scene->_animatedCard._card.show();
- scene->_aSound2.play(61);
-
- NpcMover *mover = new NpcMover();
- scene->_animatedCard._card.addMover(mover, &scene->_gameBoardSide[scene->_currentPlayerNumb]._card1Pos, this);
-
- scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[0]._cardId = scene->_availableCardsPile[scene->_cardsAvailableNumb];
- scene->_availableCardsPile[scene->_cardsAvailableNumb] = 0;
- scene->_cardsAvailableNumb--;
-
- if (scene->_cardsAvailableNumb < 0)
- scene->_stockPile.remove();
- } else {
- // Self call, forcing next actionIndex
- signal();
- }
- break;
- case 1:
- if ( (scene->_animatedCard._card._position.x == scene->_gameBoardSide[scene->_currentPlayerNumb]._card1Pos.x)
- && (scene->_animatedCard._card._position.y == scene->_gameBoardSide[scene->_currentPlayerNumb]._card1Pos.y) ) {
- scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[0]._card.postInit();
- scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[0]._card._moveDiff = Common::Point(30, 30);
- scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[0]._card.setVisage(1332);
- scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[0]._card.setPosition(scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[0]._stationPos, 0);
- scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[0]._card.setStrip(1);
- scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[0]._card.setFrame(scene->_gameBoardSide[scene->_currentPlayerNumb]._frameNum);
- scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[0]._card.fixPriority(170);
- }
-
- if ((R2_GLOBALS._debugCardGame) || (scene->_currentPlayerNumb == 2))
- scene->setAnimationInfo(&scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[0]);
-
- scene->_animatedCard._card.hide();
- if ( (scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[0]._cardId == 0)
- && (!scene->isStationCard(scene->_gameBoardSide[scene->_currentPlayerNumb]._delayCard._cardId))) {
- if (scene->_cardsAvailableNumb < 0)
- scene->shuffleCards();
- scene->_animatedCard._card.setPosition(Common::Point(162, 95));
- scene->_animatedCard._card.show();
-
- scene->_aSound2.play(61);
-
- NpcMover *mover = new NpcMover();
- scene->_animatedCard._card.addMover(mover, &scene->_gameBoardSide[scene->_currentPlayerNumb]._card2Pos, this);
-
- scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[1]._cardId = scene->_availableCardsPile[scene->_cardsAvailableNumb];
- scene->_availableCardsPile[scene->_cardsAvailableNumb] = 0;
- scene->_cardsAvailableNumb--;
- if (scene->_cardsAvailableNumb < 0)
- scene->_stockPile.remove();
- } else
- signal();
- break;
- case 2:
- if ( (scene->_animatedCard._card._position.x == scene->_gameBoardSide[scene->_currentPlayerNumb]._card2Pos.x)
- && (scene->_animatedCard._card._position.y == scene->_gameBoardSide[scene->_currentPlayerNumb]._card2Pos.y) ) {
- scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[1]._card.postInit();
- scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[1]._card._moveDiff = Common::Point(30, 30);
- scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[1]._card.setVisage(1332);
- scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[1]._card.setPosition(scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[1]._stationPos, 0);
- scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[1]._card.setStrip(1);
- scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[1]._card.setFrame(scene->_gameBoardSide[scene->_currentPlayerNumb]._frameNum);
- scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[1]._card.fixPriority(170);
- }
-
- if ((R2_GLOBALS._debugCardGame) || (scene->_currentPlayerNumb == 2))
- scene->setAnimationInfo(&scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[1]);
-
- scene->_animatedCard._card.hide();
- if ( (scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[2]._cardId == 0)
- && (!scene->isStationCard(scene->_gameBoardSide[scene->_currentPlayerNumb]._delayCard._cardId))) {
- if (scene->_cardsAvailableNumb < 0)
- scene->shuffleCards();
- scene->_animatedCard._card.setPosition(Common::Point(162, 95));
- scene->_animatedCard._card.show();
-
- scene->_aSound2.play(61);
-
- NpcMover *mover = new NpcMover();
- scene->_animatedCard._card.addMover(mover, &scene->_gameBoardSide[scene->_currentPlayerNumb]._card3Pos, this);
-
- scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[2]._cardId = scene->_availableCardsPile[scene->_cardsAvailableNumb];
- scene->_availableCardsPile[scene->_cardsAvailableNumb] = 0;
- scene->_cardsAvailableNumb--;
- if (scene->_cardsAvailableNumb < 0)
- scene->_stockPile.remove();
- } else
- signal();
- break;
- case 3:
- if ( (scene->_animatedCard._card._position.x == scene->_gameBoardSide[scene->_currentPlayerNumb]._card3Pos.x)
- && (scene->_animatedCard._card._position.y == scene->_gameBoardSide[scene->_currentPlayerNumb]._card3Pos.y) ) {
- scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[2]._card.postInit();
- scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[2]._card._moveDiff = Common::Point(30, 30);
- scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[2]._card.setVisage(1332);
- scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[2]._card.setPosition(scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[2]._stationPos, 0);
- scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[2]._card.setStrip(1);
- scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[2]._card.setFrame(scene->_gameBoardSide[scene->_currentPlayerNumb]._frameNum);
- scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[2]._card.fixPriority(170);
- }
-
- if ((R2_GLOBALS._debugCardGame) || (scene->_currentPlayerNumb == 2))
- scene->setAnimationInfo(&scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[2]);
-
- scene->_animatedCard._card.hide();
- if ( (scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[3]._cardId == 0)
- && (!scene->isStationCard(scene->_gameBoardSide[scene->_currentPlayerNumb]._delayCard._cardId))) {
- if (scene->_cardsAvailableNumb < 0)
- scene->shuffleCards();
- scene->_animatedCard._card.setPosition(Common::Point(162, 95));
- scene->_animatedCard._card.show();
-
- scene->_aSound2.play(61);
-
- NpcMover *mover = new NpcMover();
- scene->_animatedCard._card.addMover(mover, &scene->_gameBoardSide[scene->_currentPlayerNumb]._card4Pos, this);
-
- scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[3]._cardId = scene->_availableCardsPile[scene->_cardsAvailableNumb];
- scene->_availableCardsPile[scene->_cardsAvailableNumb] = 0;
- scene->_cardsAvailableNumb--;
- if (scene->_cardsAvailableNumb < 0)
- scene->_stockPile.remove();
- } else
- signal();
- break;
- case 4:
- if ( (scene->_animatedCard._card._position.x == scene->_gameBoardSide[scene->_currentPlayerNumb]._card4Pos.x)
- && (scene->_animatedCard._card._position.y == scene->_gameBoardSide[scene->_currentPlayerNumb]._card4Pos.y) ) {
- scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[3]._card.postInit();
- scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[3]._card._moveDiff = Common::Point(30, 30);
- scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[3]._card.setVisage(1332);
- scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[3]._card.setPosition(scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[3]._stationPos, 0);
- scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[3]._card.setStrip(1);
- scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[3]._card.setFrame(scene->_gameBoardSide[scene->_currentPlayerNumb]._frameNum);
- scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[3]._card.fixPriority(170);
- }
-
- if ((R2_GLOBALS._debugCardGame) || (scene->_currentPlayerNumb == 2))
- scene->setAnimationInfo(&scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[3]);
-
- scene->_animatedCard._card.hide();
- switch (scene->_currentPlayerNumb) {
- case 0:
- scene->handlePlayer0();
- break;
- case 1:
- scene->handlePlayer1();
- break;
- case 2:
- scene->handleAutoplayPlayer2();
- break;
- case 3:
- scene->handlePlayer3();
- break;
- default:
- break;
- }
- break;
- default:
- break;
- }
-}
-
-/**
- * Animations for discarding a card
- */
-void Scene1337::Action5::signal() {
- Scene1337 *scene = (Scene1337 *)R2_GLOBALS._sceneManager._scene;
-
- switch (_actionIndex++) {
- case 0: {
- scene->_availableCardsPile[scene->_currentDiscardIndex] = scene->_actionCard1->_cardId;
- scene->_currentDiscardIndex--;
- if (!g_globals->_sceneObjects->contains(&scene->_discardPile._card)) {
- // The first discarded card makes the pile appear
- scene->_discardPile._card.postInit();
- scene->_discardPile._card.hide();
- scene->_discardPile._card.setVisage(1332);
- scene->_discardPile._card.setPosition(scene->_discardPile._stationPos, 0);
- scene->_discardPile._card.fixPriority(170);
- }
-
- scene->_discardPile._cardId = scene->_actionCard1->_cardId;
- scene->_actionCard1->_cardId = 0;
- scene->_actionCard1->_card.remove();
-
- if (scene->_actionCard1 == &scene->_selectedCard) {
- scene->setCursorData(5, 1, 4);
- scene->subC4CEC();
- }
- scene->_animatedCard._card.setPosition(scene->_actionCard1->_stationPos, 0);
- scene->_animatedCard._card.show();
- Common::Point pt(128, 95);
- NpcMover *mover = new NpcMover();
- scene->_animatedCard._card.addMover(mover, &pt, this);
- }
- break;
- case 1:
- scene->_animatedCard._card.hide();
- scene->setAnimationInfo(&scene->_discardPile);
- scene->_aSound2.play(61);
- scene->handleNextTurn();
- break;
- default:
- break;
- }
-}
-
-/**
- * Animations for playing a platform card
- */
-void Scene1337::Action6::signal() {
- Scene1337 *scene = (Scene1337 *)R2_GLOBALS._sceneManager._scene;
-
- switch (_actionIndex++) {
- case 0: {
- scene->_actionCard2->_cardId = 1;
- scene->_actionCard2->_card.postInit();
- scene->_actionCard2->_card.hide();
- scene->_actionCard2->_card.setVisage(1332);
- scene->_actionCard2->_card.setPosition(scene->_actionCard2->_stationPos);
- scene->_actionCard2->_card.fixPriority(170);
-
- scene->_actionCard1->_cardId = 0;
- scene->_actionCard1->_card.remove();
-
- scene->_animatedCard._card.setPosition(scene->_actionCard1->_stationPos);
- scene->_animatedCard._card.show();
-
- NpcMover *mover = new NpcMover();
- scene->_animatedCard._card.addMover(mover, &scene->_actionCard2->_stationPos, this);
- }
- break;
- case 1:
- scene->_animatedCard._card.hide();
- scene->setAnimationInfo(scene->_actionCard2);
- scene->_aSound1.play(59);
- if (scene->_actionCard1 == &scene->_selectedCard) {
- scene->setCursorData(5, 1, 4);
- scene->subC4CEC();
- }
- scene->handleNextTurn();
- break;
- default:
- break;
- }
-}
-
-/**
- * Upgrade platform to station by playing a station card on top of it
- */
-void Scene1337::Action7::signal() {
- Scene1337 *scene = (Scene1337 *)R2_GLOBALS._sceneManager._scene;
-
- switch (_actionIndex++) {
- case 0: {
- scene->_actionCard2->_cardId = scene->_actionCard1->_cardId;
-
- scene->_actionCard1->_cardId = 0;
- scene->_actionCard1->_card.remove();
-
- scene->_animatedCard._card.setPosition(scene->_actionCard1->_stationPos, 0);
- scene->_animatedCard._card.show();
- NpcMover *mover = new NpcMover();
- scene->_animatedCard._card.addMover(mover, &scene->_actionCard2->_stationPos, this);
- }
- break;
- case 1:
- if (scene->_actionCard1 == &scene->_selectedCard) {
- scene->setCursorData(5, 1, 4);
- scene->subC4CEC();
- }
- scene->setAnimationInfo(scene->_actionCard2);
- scene->_aSound1.play(59);
- scene->_discardedPlatformCard._cardId = 1;
- scene->_discardedPlatformCard._stationPos = scene->_actionCard2->_stationPos;
- scene->_discardedPlatformCard._card.postInit();
- scene->_discardedPlatformCard._card.hide();
- scene->_discardedPlatformCard._card._flags = OBJFLAG_HIDING;
-
- scene->discardCard(&scene->_discardedPlatformCard);
- break;
- default:
- break;
- }
-}
-
-void Scene1337::Action8::signal() {
- Scene1337 *scene = (Scene1337 *)R2_GLOBALS._sceneManager._scene;
-
- switch (_actionIndex++) {
- case 0: {
- scene->_availableCardsPile[scene->_currentDiscardIndex] = scene->_actionCard2->_cardId;
- scene->_currentDiscardIndex--;
-
- scene->_actionCard2->_cardId = scene->_actionCard1->_cardId;
- scene->_actionCard1->_card.remove();
-
- scene->_animatedCard._card.setPosition(scene->_actionCard1->_stationPos, 0);
- scene->_animatedCard._card.show();
-
- NpcMover *mover = new NpcMover();
- scene->_animatedCard._card.addMover(mover, &scene->_actionCard2->_stationPos, this);
- }
- break;
- case 1:
- scene->_animatedCard._card.hide();
-
- if (scene->_actionCard1 == &scene->_selectedCard) {
- scene->setCursorData(5, 1, 4);
- scene->subC4CEC();
- }
- scene->setAnimationInfo(scene->_actionCard2);
- scene->_aSound1.play(58);
- scene->discardCard(scene->_actionCard2);
- break;
- default:
- break;
- }
-}
-
-// Play delay card
-void Scene1337::Action9::signal() {
- Scene1337 *scene = (Scene1337 *)R2_GLOBALS._sceneManager._scene;
-
- switch (_actionIndex++) {
- case 0: {
- scene->_actionCard2->_cardId = scene->_actionCard1->_cardId;
- scene->_actionCard2->_card.postInit();
- scene->_actionCard2->_card.hide();
- scene->_actionCard2->_card.setVisage(1332);
- scene->_actionCard2->_card.setPosition(scene->_actionCard2->_stationPos, 0);
- scene->_actionCard2->_card.fixPriority(170);
-
- scene->_actionCard1->_cardId = 0;
- scene->_actionCard1->_card.remove();
-
- scene->_animatedCard._card.setPosition(scene->_actionCard1->_stationPos, 0);
- scene->_animatedCard._card.show();
-
- NpcMover *mover = new NpcMover();
- scene->_animatedCard._card.addMover(mover, &scene->_actionCard2->_stationPos, this);
- }
- break;
- case 1:
- scene->_animatedCard._card.hide();
- scene->setAnimationInfo(scene->_actionCard2);
- scene->_aSound1.play(57);
-
- if (scene->_actionCard1 == &scene->_selectedCard) {
- scene->setCursorData(5, 1, 4);
- scene->subC4CEC();
- }
-
- scene->handleNextTurn();
- break;
- default:
- break;
- }
-}
-
-// Counter a trick with a card
-void Scene1337::Action10::signal() {
- Scene1337 *scene = (Scene1337 *)R2_GLOBALS._sceneManager._scene;
-
- switch (_actionIndex++) {
- case 0: {
- scene->_actionCard3->_card.postInit();
- scene->_actionCard3->_card.hide();
- scene->_actionCard3->_card.setVisage(1332);
- scene->_actionCard3->_card.setPosition(scene->_actionCard3->_stationPos, 0);
- scene->_actionCard3->_card.fixPriority(170);
- scene->_actionCard3->_cardId = scene->_actionCard1->_cardId;
-
- scene->_actionCard1->_cardId = 0;
- scene->_actionCard1->_card.remove();
-
- if (scene->_actionCard1 == &scene->_selectedCard) {
- scene->setCursorData(5, 1, 4);
- scene->subC4CEC();
- }
-
- scene->_animatedCard._card.setPosition(scene->_actionCard1->_stationPos, 0);
- scene->_animatedCard._card.show();
- NpcMover *mover = new NpcMover();
- scene->_animatedCard._card.addMover(mover, &scene->_actionCard3->_stationPos, this);
- }
- break;
- case 1: {
- scene->_animatedCard._card.hide();
- scene->setAnimationInfo(scene->_actionCard3);
- scene->_aSound1.play(57);
-
- bool found = false;
- int indexFound = -1;
-
- switch (scene->_actionIdx1) {
- case 0:
- for (indexFound = 0; indexFound < 3; indexFound++) {
- if (scene->_gameBoardSide[0]._handCard[indexFound]._cardId == 29) {
- found = true;
- break;
- }
- }
- break;
- case 1:
- for (indexFound = 0; indexFound < 3; indexFound++) {
- if (scene->_gameBoardSide[1]._handCard[indexFound]._cardId == 29) {
- found = true;
- break;
- }
- }
- break;
- case 2:
- for (indexFound = 0; indexFound < 3; indexFound++) {
- if (scene->_gameBoardSide[2]._handCard[indexFound]._cardId == 29) {
- found = true;
- break;
- }
- }
- break;
- case 3:
- for (indexFound = 0; indexFound < 3; indexFound++) {
- if (scene->_gameBoardSide[3]._handCard[indexFound]._cardId == 29) {
- found = true;
- break;
- }
- }
- break;
- default:
- break;
- }
-
- bool found2 = false;
-
- if (found) {
- switch (scene->_actionIdx1) {
- case 0:
- scene->subC51A0(&scene->_gameBoardSide[0]._handCard[indexFound], scene->_actionCard3);
- found2 = true;
- break;
- case 1:
- scene->subC51A0(&scene->_gameBoardSide[1]._handCard[indexFound], scene->_actionCard3);
- found2 = true;
- break;
- case 2:
- scene->subC4CD2();
- if (MessageDialog::show(USE_INTERCEPTOR, NO_MSG, YES_MSG) == 0)
- scene->subC4CEC();
- else {
- scene->subC51A0(&scene->_gameBoardSide[2]._handCard[indexFound], scene->_actionCard3);
- found2 = true;
- }
- break;
- case 3:
- scene->subC51A0(&scene->_gameBoardSide[3]._handCard[indexFound], scene->_actionCard3);
- found2 = true;
- break;
- default:
- break;
- }
- }
-
- if (!found2)
- break;
-
- if (scene->_actionIdx1 == 2) {
- int j = 0;
- for (int i = 0; i <= 7; i++) {
- if (scene->_gameBoardSide[2]._outpostStation[i]._cardId != 0)
- ++j;
- }
-
- if (j <= 1) {
- for (int i = 0; i <= 7; i++) {
- if (scene->_gameBoardSide[2]._outpostStation[i]._cardId != 0) {
- scene->_actionCard2 = &scene->_gameBoardSide[2]._outpostStation[i];
- break;
- }
- }
- } else {
- scene->subC4CD2();
-
- found2 = false;
- while (!found2) {
- scene->actionDisplay(1330, 130, 159, 10, 1, 200, 0, 7, 0, 154, 154);
-
- // Wait for a mouse or keypress
- Event event;
- while (!g_globals->_events.getEvent(event, EVENT_BUTTON_DOWN | EVENT_KEYPRESS) && !g_vm->shouldQuit()) {
- g_globals->_scenePalette.signalListeners();
- R2_GLOBALS._sceneObjects->draw();
- g_globals->_events.delay(g_globals->_sceneHandler->_delayTicks);
- }
-
- scene->_selectedCard._stationPos = event.mousePos;
-
- for (int i = 0; i <= 7; i++) {
- if (scene->_gameBoardSide[2]._outpostStation[i].isIn(scene->_selectedCard._stationPos) && (scene->_gameBoardSide[2]._outpostStation[i]._cardId != 0)) {
- scene->_actionCard2 = &scene->_gameBoardSide[2]._outpostStation[0];
- found2 = true;
- break;
- }
- }
- }
- scene->subC4CEC();
- }
- }
-
- scene->_availableCardsPile[scene->_currentDiscardIndex] = scene->_actionCard2->_cardId;
- scene->_currentDiscardIndex--;
- scene->_actionCard2->_cardId = 0;
- scene->_actionCard2->_card.remove();
-
- scene->_animatedCard._card.setPosition(scene->_actionCard2->_stationPos, 0);
- scene->_animatedCard._card.show();
-
- NpcMover *mover = new NpcMover();
- scene->_animatedCard._card.addMover(mover, &scene->_actionCard3->_stationPos, this);
- }
- break;
- case 2:
- scene->_animatedCard._card.hide();
- scene->discardCard(scene->_actionCard3);
- break;
- default:
- break;
- }
-}
-
-// Use trick (card #25 - thieft ?) and pick a card from the opponent
-void Scene1337::Action11::signal() {
- Scene1337 *scene = (Scene1337 *)R2_GLOBALS._sceneManager._scene;
-
- switch (_actionIndex++) {
- case 0: {
- scene->_actionCard2->_card.postInit();
- scene->_actionCard2->_card.hide();
- scene->_actionCard2->_card.setVisage(1332);
- scene->_actionCard2->_card.setPosition(scene->_actionCard2->_stationPos, 0);
- scene->_actionCard2->_card.fixPriority(170);
- scene->_actionCard2->_cardId = 25;
-
- if (scene->_actionIdx1 == 2) {
- scene->_animatedCard._card.setPosition(scene->_actionCard2->_stationPos, 0);
- scene->setCursorData(5, 1, 4);
- } else {
- scene->_actionCard1->_cardId = 0;
- scene->_actionCard1->_card.remove();
- scene->_animatedCard._card.setPosition(scene->_actionCard1->_stationPos, 0);
- }
- scene->_animatedCard._card.show();
-
- NpcMover *mover = new NpcMover();
- scene->_animatedCard._card.addMover(mover, &scene->_actionCard2->_stationPos, this);
- }
- break;
- case 1: {
- scene->_animatedCard._card.hide();
- scene->setAnimationInfo(scene->_actionCard2);
- scene->_aSound1.play(57);
-
- bool found = false;
- bool noAction = true;
-
- int i = -1;
-
- switch (scene->_actionIdx2) {
- case 0:
- for (i = 0; i <= 3; i++) {
- if (scene->_gameBoardSide[0]._handCard[i]._cardId == 27) {
- found = true;
- break;
- }
- }
-
- if ((found) && (scene->getFreeHandCard(scene->_actionIdx1) != -1)) {
- scene->_actionCard1 = &scene->_gameBoardSide[0]._handCard[i];
- scene->_actionCard2 = &scene->_gameBoardSide[0]._emptyStationPos;
- if (scene->_actionIdx1 != 0) {
- int tmpVal = scene->getFreeHandCard(scene->_actionIdx1);
- scene->_actionCard3 = &scene->_gameBoardSide[scene->_actionIdx1]._handCard[tmpVal];
- }
- scene->_actionItem.setAction(&scene->_action12);
- noAction = false;
- }
- break;
- case 1:
- for (i = 0; i <= 3; i++) {
- if (scene->_gameBoardSide[1]._handCard[i]._cardId == 27) {
- found = true;
- break;
- }
- }
-
- if ((found) && (scene->getFreeHandCard(scene->_actionIdx1) != -1)) {
- scene->_actionCard1 = &scene->_gameBoardSide[1]._handCard[i];
- scene->_actionCard2 = &scene->_gameBoardSide[1]._emptyStationPos;
- if (scene->_actionIdx1 != 1) {
- int tmpVal = scene->getFreeHandCard(scene->_actionIdx1);
- scene->_actionCard3 = &scene->_gameBoardSide[scene->_actionIdx1]._handCard[tmpVal];
- }
- scene->_actionItem.setAction(&scene->_action12);
- noAction = false;
- }
- break;
- case 2:
- for (i = 0; i <= 3; i++) {
- if (scene->_gameBoardSide[2]._handCard[i]._cardId == 27) {
- found = true;
- break;
- }
- }
-
- if ((found) && (scene->getFreeHandCard(scene->_actionIdx1) != -1)) {
- scene->subC4CD2();
- if (MessageDialog::show(USE_DOUBLE_AGENT, NO_MSG, YES_MSG) == 0)
- scene->subC4CEC();
- else {
- scene->subC4CEC();
- scene->_actionCard1 = &scene->_gameBoardSide[2]._handCard[i];
- scene->_actionCard2 = &scene->_gameBoardSide[2]._emptyStationPos;
- if (scene->_actionIdx1 != 2) {
- int tmpVal = scene->getFreeHandCard(scene->_actionIdx1);
- scene->_actionCard3 = &scene->_gameBoardSide[scene->_actionIdx1]._handCard[tmpVal];
- }
- scene->_actionItem.setAction(&scene->_action12);
- noAction = false;
- }
- }
- break;
- case 3:
- for (i = 0; i <= 3; i++) {
- if (scene->_gameBoardSide[3]._handCard[i]._cardId == 27) {
- found = true;
- break;
- }
- }
-
- if ((found) && (scene->getFreeHandCard(scene->_actionIdx1) != -1)) {
- scene->_actionCard1 = &scene->_gameBoardSide[3]._handCard[i];
- scene->_actionCard2 = &scene->_gameBoardSide[3]._emptyStationPos;
- if (scene->_actionIdx1 != 3) {
- int tmpVal = scene->getFreeHandCard(scene->_actionIdx1);
- scene->_actionCard3 = &scene->_gameBoardSide[scene->_actionIdx1]._handCard[tmpVal];
- }
- scene->_actionItem.setAction(&scene->_action12);
- noAction = false;
- }
- break;
- default:
- break;
- }
-
- if (!noAction)
- return;
-
- if (scene->_actionIdx1 == 2) {
- int count = 0;
- if (scene->_actionIdx2 != 2) {
- for (i = 0; i <= 3; i++) {
- if (scene->_gameBoardSide[scene->_actionIdx2]._handCard[i]._cardId == 0)
- ++count;
- }
- }
-
- if (count > 1) {
- scene->subC4CD2();
-
- found = false;
- while (!found) {
- switch (scene->_actionIdx2) {
- case 0:
- scene->actionDisplay(1330, 131, 159, 10, 1, 200, 0, 7, 0, 154, 154);
- break;
- case 1:
- scene->actionDisplay(1330, 132, 159, 10, 1, 200, 0, 7, 0, 154, 154);
- break;
- case 3:
- scene->actionDisplay(1330, 133, 159, 10, 1, 200, 0, 7, 0, 154, 154);
- break;
- default:
- break;
- }
-
- Event event;
- while (!g_globals->_events.getEvent(event, EVENT_BUTTON_DOWN | EVENT_KEYPRESS) && !g_vm->shouldQuit()) {
- g_globals->_scenePalette.signalListeners();
- R2_GLOBALS._sceneObjects->draw();
- g_globals->_events.delay(g_globals->_sceneHandler->_delayTicks);
- }
-
- scene->_selectedCard._stationPos = event.mousePos;
-
- found = false;
-
- if (scene->_actionIdx2 != 2) {
- for (i = 0; i <= 3; i++) {
- if (scene->_gameBoardSide[scene->_actionIdx2]._handCard[i].isIn(scene->_selectedCard._stationPos) && (scene->_gameBoardSide[scene->_actionIdx2]._handCard[i]._cardId != 0)) {
- scene->_actionCard3 = &scene->_gameBoardSide[scene->_actionIdx2]._handCard[i];
- found = true;
- break;
- }
- }
- }
- } // while
- scene->_displayHelpFl = true;
- scene->subC4CEC();
- } else if (scene->_actionIdx2 != 2) {
- int tmpVal = scene->getFreeHandCard(scene->_actionIdx2);
- scene->_actionCard3 = &scene->_gameBoardSide[scene->_actionIdx2]._handCard[tmpVal];
- }
- }
-
- scene->_actionCard1->_card.postInit();
- scene->_actionCard1->_card.hide();
- scene->_actionCard1->_card.setVisage(1332);
- scene->_actionCard1->_card.setPosition(scene->_actionCard1->_stationPos, 0);
- scene->_actionCard1->_card.fixPriority(170);
- scene->_actionCard1->_card.setStrip2(1);
- scene->_actionCard1->_cardId = scene->_actionCard3->_cardId;
-
- scene->_actionCard3->_cardId = 0;
- scene->_actionCard3->_card.remove();
-
- scene->_animatedCard._card.setPosition(scene->_actionCard3->_stationPos, 0);
- scene->_animatedCard._card.show();
-
- NpcMover *mover = new NpcMover();
- scene->_animatedCard._card.addMover(mover, &scene->_actionCard1->_stationPos, this);
- }
- break;
- case 2:
- scene->_animatedCard._card.hide();
- switch (scene->_actionIdx1) {
- case 0:
- scene->_actionCard1->_card.setFrame2(2);
- scene->_actionCard1->_card.show();
- break;
- case 1:
- scene->_actionCard1->_card.setFrame2(4);
- scene->_actionCard1->_card.show();
- break;
- case 3:
- scene->_actionCard1->_card.setFrame2(3);
- scene->_actionCard1->_card.show();
- break;
- default:
- scene->setAnimationInfo(scene->_actionCard1);
- break;
- }
-
- scene->_currentPlayerNumb--;
- scene->_showPlayerTurn = false;
- scene->discardCard(scene->_actionCard2);
- break;
- default:
- break;
- }
-}
-
-// Pick a card in opponent hand
-void Scene1337::Action12::signal() {
- Scene1337 *scene = (Scene1337 *)R2_GLOBALS._sceneManager._scene;
-
- switch (_actionIndex++) {
- case 0:
- signal();
- break;
- case 1: {
- scene->_availableCardsPile[scene->_currentDiscardIndex] = scene->_actionCard2->_cardId;
- scene->_currentDiscardIndex++;
- scene->_actionCard2->_cardId = scene->_actionCard1->_cardId;
- scene->_actionCard1->_cardId = 0;
- scene->_actionCard1->_card.remove();
- scene->_animatedCard._card.setPosition(scene->_actionCard1->_stationPos, 0);
- scene->_animatedCard._card.show();
-
- NpcMover *mover = new NpcMover();
- scene->_animatedCard._card.addMover(mover, &scene->_actionCard2->_stationPos, this);
- }
- break;
- case 2:
- scene->_animatedCard._card.hide();
- scene->setAnimationInfo(scene->_actionCard2);
- scene->_aSound1.play(58);
- if (scene->_actionIdx2 == 2) {
- int count = 0;
- int i = -1;
- switch (scene->_actionIdx1) {
- case 0:
- for (i = 0; i <= 3; i++) {
- if (scene->_gameBoardSide[0]._handCard[i]._cardId != 0)
- ++count;
- }
- break;
- case 1:
- for (i = 0; i <= 3; i++) {
- // The original game was counting in the hand of player 3, which is obviously wrong
- if (scene->_gameBoardSide[1]._handCard[i]._cardId != 0)
- ++count;
- }
- break;
- case 3:
- for (i = 0; i <= 3; i++) {
- if (scene->_gameBoardSide[3]._handCard[i]._cardId != 0)
- ++count;
- }
- break;
- default:
- break;
- }
-
- if (count > 1) {
- scene->subC4CD2();
-
- bool found = false;
-
- while (!found) {
- switch (scene->_actionIdx1) {
- case 0:
- scene->actionDisplay(1330, 131, 159, 10, 1, 200, 0, 7, 0, 154, 154);
- break;
- case 1:
- scene->actionDisplay(1330, 132, 159, 10, 1, 200, 0, 7, 0, 154, 154);
- break;
- case 3:
- scene->actionDisplay(1330, 133, 159, 10, 1, 200, 0, 7, 0, 154, 154);
- break;
- default:
- break;
- }
-
- Event event;
- while (!g_globals->_events.getEvent(event, EVENT_BUTTON_DOWN | EVENT_KEYPRESS) && !g_vm->shouldQuit()) {
- g_globals->_scenePalette.signalListeners();
- R2_GLOBALS._sceneObjects->draw();
- g_globals->_events.delay(g_globals->_sceneHandler->_delayTicks);
- }
-
- scene->_selectedCard._stationPos = event.mousePos;
-
- if (scene->_actionIdx1 == 0) {
- for (i = 0; i <= 3; i++) {
- if (scene->_gameBoardSide[0]._handCard[i].isIn(scene->_selectedCard._stationPos) && (scene->_gameBoardSide[0]._handCard[i]._cardId != 0)) {
- found = true;
- scene->_actionCard3 = &scene->_gameBoardSide[0]._handCard[i];
- break;
- }
- }
- }
-
- if (scene->_actionIdx1 == 3) {
- for (i = 0; i <= 3; i++) {
- if (scene->_gameBoardSide[3]._handCard[i].isIn(scene->_selectedCard._stationPos) && (scene->_gameBoardSide[3]._handCard[i]._cardId != 0)) {
- found = true;
- scene->_actionCard3 = &scene->_gameBoardSide[3]._handCard[i];
- break;
- }
- }
- }
-
- if (scene->_actionIdx1 == 1) {
- for (i = 0; i <= 3; i++) {
- if (scene->_gameBoardSide[1]._handCard[i].isIn(scene->_selectedCard._stationPos) && (scene->_gameBoardSide[1]._handCard[i]._cardId != 0)) {
- found = true;
- scene->_actionCard3 = &scene->_gameBoardSide[1]._handCard[i];
- break;
- }
- }
- }
- }
- scene->subC4CEC();
- } else if (scene->_actionIdx1 != 1) {
- switch (scene->_actionIdx1) {
- case 0:
- scene->_actionCard3 = &scene->_gameBoardSide[0]._handCard[scene->getFreeHandCard(0)];
- break;
- case 3:
- scene->_actionCard3 = &scene->_gameBoardSide[3]._handCard[scene->getFreeHandCard(3)];
- break;
- default:
- break;
- }
- } else {
- scene->_actionCard3 = &scene->_gameBoardSide[1]._handCard[scene->getFreeHandCard(1)];
- }
-
- scene->_actionCard1->_card.postInit();
- scene->_actionCard1->_card.hide();
- scene->_actionCard1->_card.setVisage(1332);
- scene->_actionCard1->_card.setPosition(scene->_actionCard1->_stationPos);
- scene->_actionCard1->_card.fixPriority(170);
- scene->_actionCard1->_card.setStrip2(1);
- scene->_actionCard1->_cardId = scene->_actionCard3->_cardId;
-
- scene->_actionCard3->_cardId = 0;
- scene->_actionCard3->_card.remove();
-
- scene->_animatedCard._card.setPosition(scene->_actionCard3->_stationPos);
- scene->_animatedCard._card.show();
- scene->_aSound1.play(57);
-
- NpcMover *mover = new NpcMover();
- scene->_animatedCard._card.addMover(mover, &scene->_actionCard1->_stationPos, this);
- }
- break;
- case 3:
- scene->_animatedCard._card.hide();
- switch (scene->_actionIdx2) {
- case 0:
- scene->_actionCard1->_card.setFrame2(2);
- scene->_actionCard1->_card.show();
- break;
- case 1:
- scene->_actionCard1->_card.setFrame2(4);
- scene->_actionCard1->_card.show();
- break;
- case 3:
- scene->_actionCard1->_card.setFrame2(3);
- scene->_actionCard1->_card.show();
- break;
- default:
- scene->setAnimationInfo(scene->_actionCard1);
- break;
- }
- scene->discardCard(scene->_actionCard2);
- scene->handleNextTurn();
- break;
- default:
- break;
- }
-}
-
-void Scene1337::Action13::signal() {
- Scene1337 *scene = (Scene1337 *)R2_GLOBALS._sceneManager._scene;
-
- switch (_actionIndex++) {
- case 0: {
- scene->_availableCardsPile[scene->_currentDiscardIndex] = scene->_actionCard2->_cardId;
- scene->_currentDiscardIndex--;
-
- scene->_actionCard2->_cardId = scene->_actionCard1->_cardId;
-
- scene->_actionCard1->_cardId = 0;
- scene->_actionCard1->_card.remove();
-
- scene->_animatedCard._card.setPosition(scene->_actionCard1->_stationPos, 0);
- scene->_animatedCard._card.show();
-
- NpcMover *mover = new NpcMover();
- scene->_animatedCard._card.addMover(mover, &scene->_actionCard2->_stationPos, this);
- }
- break;
- case 1:
- scene->_animatedCard._card.hide();
- scene->setAnimationInfo(scene->_actionCard2);
- scene->_aSound1.play(58);
- signal();
- break;
- case 2:
- scene->discardCard(scene->_actionCard2);
- break;
- default:
- break;
- }
-}
-
-void Scene1337::postInit(SceneObjectList *OwnerList) {
-// In the original, may be found in subPostInit.
-// Without it, enableControl asserts
- loadScene(1330);
- R2_GLOBALS._uiElements._active = false;
- SceneExt::postInit();
-//
-
- // Hide the user interface
- BF_GLOBALS._interfaceY = SCREEN_HEIGHT;
- R2_GLOBALS._uiElements._visible = false;
-
- R2_GLOBALS._player.enableControl();
- R2_GLOBALS._player._canWalk = false;
- R2_GLOBALS._player._uiEnabled = false;
-
- _delayedFunction = nullptr;
-
- _actionCard1 = nullptr;
- _actionCard2 = nullptr;
- _actionCard3 = nullptr;
-
- _gameBoardSide[2]._handCard[0]._stationPos = Common::Point(10, 174);
- _gameBoardSide[2]._handCard[1]._stationPos = Common::Point(37, 174);
- _gameBoardSide[2]._handCard[2]._stationPos = Common::Point(64, 174);
- _gameBoardSide[2]._handCard[3]._stationPos = Common::Point(91, 174);
-
- _gameBoardSide[2]._outpostStation[0]._stationPos = Common::Point(119, 174);
- _gameBoardSide[2]._outpostStation[1]._stationPos = Common::Point(119, 148);
- _gameBoardSide[2]._outpostStation[2]._stationPos = Common::Point(119, 122);
- _gameBoardSide[2]._outpostStation[3]._stationPos = Common::Point(145, 122);
- _gameBoardSide[2]._outpostStation[4]._stationPos = Common::Point(171, 122);
- _gameBoardSide[2]._outpostStation[5]._stationPos = Common::Point(171, 148);
- _gameBoardSide[2]._outpostStation[6]._stationPos = Common::Point(171, 174);
- _gameBoardSide[2]._outpostStation[7]._stationPos = Common::Point(145, 174);
-
- _gameBoardSide[2]._delayCard._stationPos = Common::Point(199, 174);
-
- _gameBoardSide[2]._emptyStationPos._stationPos = Common::Point(145, 148);
-
- _gameBoardSide[2]._card1Pos = Common::Point(10, 174);
- _gameBoardSide[2]._card2Pos = Common::Point(37, 174);
- _gameBoardSide[2]._card3Pos = Common::Point(64, 174);
- _gameBoardSide[2]._card4Pos = Common::Point(91, 174);
- _gameBoardSide[2]._frameNum = 2;
-
- _gameBoardSide[3]._handCard[0]._stationPos = Common::Point(14, 14);
- _gameBoardSide[3]._handCard[1]._stationPos = Common::Point(14, 36);
- _gameBoardSide[3]._handCard[2]._stationPos = Common::Point(14, 58);
- _gameBoardSide[3]._handCard[3]._stationPos = Common::Point(14, 80);
-
- _gameBoardSide[3]._outpostStation[0]._stationPos = Common::Point(37, 66);
- _gameBoardSide[3]._outpostStation[1]._stationPos = Common::Point(63, 66);
- _gameBoardSide[3]._outpostStation[2]._stationPos = Common::Point(89, 66);
- _gameBoardSide[3]._outpostStation[3]._stationPos = Common::Point(89, 92);
- _gameBoardSide[3]._outpostStation[4]._stationPos = Common::Point(89, 118);
- _gameBoardSide[3]._outpostStation[5]._stationPos = Common::Point(63, 118);
- _gameBoardSide[3]._outpostStation[6]._stationPos = Common::Point(37, 118);
- _gameBoardSide[3]._outpostStation[7]._stationPos = Common::Point(37, 92);
-
- _gameBoardSide[3]._delayCard._stationPos = Common::Point(37, 145);
-
- _gameBoardSide[3]._emptyStationPos._stationPos = Common::Point(63, 92);
-
- _gameBoardSide[3]._card1Pos = Common::Point(14, 14);
- _gameBoardSide[3]._card2Pos = Common::Point(14, 36);
- _gameBoardSide[3]._card3Pos = Common::Point(14, 58);
- _gameBoardSide[3]._card4Pos = Common::Point(14, 80);
- _gameBoardSide[3]._frameNum = 3;
-
- _gameBoardSide[0]._handCard[0]._stationPos = Common::Point(280, 5);
- _gameBoardSide[0]._handCard[1]._stationPos = Common::Point(253, 5);
- _gameBoardSide[0]._handCard[2]._stationPos = Common::Point(226, 5);
- _gameBoardSide[0]._handCard[3]._stationPos = Common::Point(199, 5);
-
- _gameBoardSide[0]._outpostStation[0]._stationPos = Common::Point(171, 16);
- _gameBoardSide[0]._outpostStation[1]._stationPos = Common::Point(171, 42);
- _gameBoardSide[0]._outpostStation[2]._stationPos = Common::Point(171, 68);
- _gameBoardSide[0]._outpostStation[3]._stationPos = Common::Point(145, 68);
- _gameBoardSide[0]._outpostStation[4]._stationPos = Common::Point(119, 68);
- _gameBoardSide[0]._outpostStation[5]._stationPos = Common::Point(119, 42);
- _gameBoardSide[0]._outpostStation[6]._stationPos = Common::Point(119, 16);
- _gameBoardSide[0]._outpostStation[7]._stationPos = Common::Point(145, 16);
-
- _gameBoardSide[0]._delayCard._stationPos = Common::Point(91, 16);
-
- _gameBoardSide[0]._emptyStationPos._stationPos = Common::Point(145, 42);
-
- _gameBoardSide[0]._card1Pos = Common::Point(280, 5);
- _gameBoardSide[0]._card2Pos = Common::Point(253, 5);
- _gameBoardSide[0]._card3Pos = Common::Point(226, 5);
- _gameBoardSide[0]._card4Pos = Common::Point(199, 5);
- _gameBoardSide[0]._frameNum = 2;
-
- _gameBoardSide[1]._handCard[0]._stationPos = Common::Point(283, 146);
- _gameBoardSide[1]._handCard[1]._stationPos = Common::Point(283, 124);
- _gameBoardSide[1]._handCard[2]._stationPos = Common::Point(283, 102);
- _gameBoardSide[1]._handCard[3]._stationPos = Common::Point(283, 80);
-
- _gameBoardSide[1]._outpostStation[0]._stationPos = Common::Point(253, 122);
- _gameBoardSide[1]._outpostStation[1]._stationPos = Common::Point(227, 122);
- _gameBoardSide[1]._outpostStation[2]._stationPos = Common::Point(201, 122);
- _gameBoardSide[1]._outpostStation[3]._stationPos = Common::Point(201, 96);
- _gameBoardSide[1]._outpostStation[4]._stationPos = Common::Point(201, 70);
- _gameBoardSide[1]._outpostStation[5]._stationPos = Common::Point(227, 70);
- _gameBoardSide[1]._outpostStation[6]._stationPos = Common::Point(253, 70);
- _gameBoardSide[1]._outpostStation[7]._stationPos = Common::Point(253, 96);
-
- _gameBoardSide[1]._delayCard._stationPos = Common::Point(253, 43);
-
- _gameBoardSide[1]._emptyStationPos._stationPos = Common::Point(227, 96);
-
- _gameBoardSide[1]._card1Pos = Common::Point(283, 146);
- _gameBoardSide[1]._card2Pos = Common::Point(283, 124);
- _gameBoardSide[1]._card3Pos = Common::Point(283, 102);
- _gameBoardSide[1]._card4Pos = Common::Point(283, 80);
- _gameBoardSide[1]._frameNum = 4;
-
- subPostInit();
-
- _stockPile.postInit();
-}
-
-void Scene1337::remove() {
- if (R2_GLOBALS._v57709 > 1) {
- subD1917();
- subD1940(false);
- }
-
- R2_GLOBALS._uiElements._active = true;
- R2_GLOBALS._uiElements._visible = true;
- SceneExt::remove();
-}
-
-void Scene1337::process(Event &event) {
- if (event.eventType == EVENT_BUTTON_DOWN) {
- if (event.btnState == BTNSHIFT_RIGHT) {
- updateCursorId(R2_GLOBALS._mouseCursorId, true);
- event.handled = true;
- } else if (_delayedFunction) {
- FunctionPtrType tmpFctPtr = _delayedFunction;
- _delayedFunction = nullptr;
- (this->*tmpFctPtr)();
- event.handled = true;
- }
- } else if (event.eventType == EVENT_KEYPRESS) {
- if (event.kbd.keycode == Common::KEYCODE_SPACE) {
- if (_delayedFunction) {
- FunctionPtrType tmpFctPtr = _delayedFunction;
- _delayedFunction = nullptr;
- (this->*tmpFctPtr)();
- event.handled = true;
- }
- } else
- warning("Fixme: Find proper keycode value");
- }
-
- if (!event.handled)
- Scene::process(event);
-}
-
-void Scene1337::dispatch() {
- if (!_instructionsDisplayedFl) {
- ++_instructionsWaitCount;
- if (_instructionsWaitCount == 4) {
- _instructionsDisplayedFl = true;
- suggestInstructions();
- }
- }
-
- // The following code is in the original in sceneHandler::process(),
- // which is terrible as it's checked in every scene of the game.
- setCursorData(5, _cursorCurStrip, _cursorCurFrame);
- //
-
- Scene::dispatch();
-}
-
-void Scene1337::actionDisplay(int resNum, int lineNum, int x, int y, int keepOnScreen, int width, int textMode, int fontNum, int colFG, int colBGExt, int colFGExt) {
- // TODO: Check if it's normal that arg5 is unused and replaced by an hardcoded 0 value
- // May hide an original bug
-
- SceneItem::display(resNum, lineNum, SET_X, x, SET_Y, y, SET_KEEP_ONSCREEN, 0,
- SET_WIDTH, width, SET_POS_MODE, -1, SET_TEXT_MODE, textMode,
- SET_FONT, fontNum, SET_FG_COLOR, colFG, SET_EXT_BGCOLOR, colBGExt,
- SET_EXT_FGCOLOR, colFGExt, LIST_END);
-}
-
-void Scene1337::setAnimationInfo(Card *card) {
- if (!card)
- return;
-
- if (card->_cardId > 25) {
- card->_card.setStrip2(4);
- card->_card.setFrame(card->_cardId - 25);
- } else if (card->_cardId > 9) {
- card->_card.setStrip2(3);
- card->_card.setFrame(card->_cardId - 9);
- } else {
- card->_card.setStrip2(2);
- card->_card.setFrame(card->_cardId);
- }
-
- card->_card.show();
- R2_GLOBALS._sceneObjects->draw();
-}
-
-void Scene1337::handleNextTurn() {
- switch (_winnerId) {
- case -1:
- ++_currentPlayerNumb;
- if (_currentPlayerNumb > 3)
- _currentPlayerNumb = 0;
-
- if (_showPlayerTurn) {
- _currentPlayerArrow.show();
- switch (_currentPlayerNumb) {
- case 0:
- _currentPlayerArrow.setStrip(3);
- break;
- case 1:
- _currentPlayerArrow.setStrip(4);
- break;
- case 2:
- subD1975(174, 107);
- _currentPlayerArrow.setStrip(1);
- break;
- case 3:
- subC4CEC();
- _currentPlayerArrow.setStrip(2);
- break;
- default:
- break;
- }
-
- if (!_autoplay)
- _delayedFunction = &Scene1337::handlePlayerTurn;
- else
- handlePlayerTurn();
- } else {
- handlePlayerTurn();
- }
- break;
- case 0:
- _aSound2.play(62);
- actionDisplay(1330, 135, 159, 10, 1, 200, 0, 7, 0, 154, 154);
- actionDisplay(1330, 121, 20, 99, 1, 136, 0, 7, 0, 172, 172);
- actionDisplay(1330, 122, 300, 99, 1, 136, 0, 7, 0, 117, 117);
- R2_GLOBALS._sceneObjects->draw();
- actionDisplay(1330, 123, 159, 134, 1, 200, 0, 7, 0, 105, 105);
- break;
- case 1:
- _aSound2.play(62);
- actionDisplay(1330, 151, 300, 99, 1, 136, 0, 7, 0, 117, 117);
- actionDisplay(1330, 118, 20, 99, 1, 136, 0, 7, 0, 172, 172);
- actionDisplay(1330, 119, 159, 10, 1, 200, 0, 7, 0, 154, 154);
- R2_GLOBALS._sceneObjects->draw();
- actionDisplay(1330, 120, 159, 134, 1, 200, 0, 7, 0, 105, 105);
- break;
- case 2:
- _aSound2.play(62);
- actionDisplay(1330, 134, 159, 134, 1, 200, 0, 7, 0, 105, 105);
- actionDisplay(1330, 124, 20, 99, 1, 136, 0, 7, 0, 172, 172);
- actionDisplay(1330, 126, 159, 10, 1, 200, 0, 7, 0, 154, 154);
- R2_GLOBALS._sceneObjects->draw();
- actionDisplay(1330, 125, 300, 99, 1, 136, 0, 7, 0, 117, 117);
- break;
- case 3:
- _aSound2.play(62);
- actionDisplay(1330, 150, 20, 99, 1, 136, 0, 7, 0, 172, 172);
- actionDisplay(1330, 115, 300, 99, 1, 136, 0, 7, 0, 117, 117);
- actionDisplay(1330, 116, 159, 10, 1, 200, 0, 7, 0, 154, 154);
- R2_GLOBALS._sceneObjects->draw();
- actionDisplay(1330, 117, 159, 134, 1, 200, 0, 7, 0, 105, 105);
- break;
- default:
- break;
- }
-
- if (_winnerId != -1)
- R2_GLOBALS._sceneManager.changeScene(125);
-
-}
-
-void Scene1337::handlePlayerTurn() {
- if (_showPlayerTurn)
- _currentPlayerArrow.hide();
-
- switch (_currentPlayerNumb) {
- case 2:
- subC4CD2();
- if (_displayHelpFl)
- actionDisplay(1330, 114, 159, 10, 1, 200, 0, 7, 0, 154, 154);
- _displayHelpFl = false;
- // No break on purpose
- case 0:
- // No break on purpose
- case 1:
- // No break on purpose
- case 3:
- _actionItem.setAction(&_action4);
- default:
- break;
- }
-
- _showPlayerTurn = true;
-
-}
-
-bool Scene1337::isStationCard(int cardId) {
- switch (cardId) {
- case 10:
- // No break on purpose
- case 12:
- // No break on purpose
- case 15:
- // No break on purpose
- case 17:
- // No break on purpose
- case 18:
- // No break on purpose
- case 19:
- // No break on purpose
- case 20:
- // No break on purpose
- case 21:
- return true;
- default:
- return false;
- }
-}
-
-bool Scene1337::isStopConstructionCard(int cardId) {
- switch (cardId) {
- case 11:
- // No break on purpose
- case 14:
- // No break on purpose
- case 16:
- // No break on purpose
- case 24:
- return true;
- default:
- return false;
- }
-}
-
-int Scene1337::getStationId(int playerId, int handCardId) {
- if ((_gameBoardSide[playerId]._handCard[handCardId]._cardId > 1) && (_gameBoardSide[playerId]._handCard[handCardId]._cardId <= 9))
- return handCardId;
-
- return -1;
-}
-
-int Scene1337::findPlatformCardInHand(int playerId) {
- for (int i = 0; i <= 3; i++) {
- if (_gameBoardSide[playerId]._handCard[i]._cardId == 1)
- return i;
- }
-
- return -1;
-}
-
-int Scene1337::findCard13InHand(int playerId) {
- for (int i = 0; i <= 3; i++) {
- if (_gameBoardSide[playerId]._handCard[i]._cardId == 13)
- return i;
- }
-
- return -1;
-}
-
-int Scene1337::checkThieftCard(int playerId) {
- for (int i = 0; i <= 3; i++) {
- if (_gameBoardSide[playerId]._handCard[i]._cardId == 25)
- return i;
- }
-
- return -1;
-}
-
-int Scene1337::isDelayCard(int cardId) {
- switch (cardId) {
- case 11:
- // No break on purpose
- case 14:
- // No break on purpose
- case 16:
- // No break on purpose
- case 24:
- return cardId;
- break;
- default:
- return -1;
- break;
- }
-}
-
-int Scene1337::getStationCardId(int cardId) {
- switch (cardId) {
- case 10:
- // No break on purpose
- case 12:
- // No break on purpose
- case 15:
- // No break on purpose
- case 17:
- // No break on purpose
- case 18:
- // No break on purpose
- case 19:
- // No break on purpose
- case 20:
- // No break on purpose
- case 21:
- return cardId;
- default:
- return -1;
- }
-}
-
-void Scene1337::handlePlayer01Discard(int playerId) {
- switch (playerId) {
- case 0:
- for (int i = 0; i <= 3; i++) {
- if (getStationCardId(_gameBoardSide[playerId]._handCard[i]._cardId) != -1) {
- discardCard(&_gameBoardSide[playerId]._handCard[i]);
- return;
- }
- }
-
- for (int i = 0; i <= 3; i++) {
- if (isDelayCard(_gameBoardSide[playerId]._handCard[i]._cardId) != -1) {
- discardCard(&_gameBoardSide[playerId]._handCard[i]);
- return;
- }
- }
-
- for (int i = 0; i <= 3; i++) {
- if ((_gameBoardSide[playerId]._handCard[i]._cardId > 1) && (_gameBoardSide[playerId]._handCard[i]._cardId <= 9)) {
- discardCard(&_gameBoardSide[playerId]._handCard[i]);
- return;
- }
- }
-
- for (int i = 0; i <= 3; i++) {
- if ((_gameBoardSide[playerId]._handCard[i]._cardId >= 26) && (_gameBoardSide[playerId]._handCard[i]._cardId <= 33)) {
- discardCard(&_gameBoardSide[playerId]._handCard[i]);
- return;
- }
- }
-
- for (int i = 0; i <= 3; i++) {
- if (_gameBoardSide[playerId]._handCard[i]._cardId == 1) {
- discardCard(&_gameBoardSide[playerId]._handCard[i]);
- return;
- }
- }
-
- for (int i = 0; i <= 3; i++) {
- if (_gameBoardSide[playerId]._handCard[i]._cardId == 25) {
- discardCard(&_gameBoardSide[playerId]._handCard[i]);
- return;
- }
- }
-
- for (int i = 0; i <= 3; i++) {
- if (_gameBoardSide[playerId]._handCard[i]._cardId == 13) {
- discardCard(&_gameBoardSide[playerId]._handCard[i]);
- return;
- }
- }
- break;
- case 1:
- for (int i = 0; i <= 3; i++) {
- if ((_gameBoardSide[playerId]._handCard[i]._cardId >= 26) && (_gameBoardSide[playerId]._handCard[i]._cardId <= 33)) {
- discardCard(&_gameBoardSide[playerId]._handCard[i]);
- return;
- }
- }
-
- for (int i = 0; i <= 3; i++) {
- if (_gameBoardSide[playerId]._handCard[i]._cardId == 1) {
- discardCard(&_gameBoardSide[playerId]._handCard[i]);
- return;
- }
- }
-
- for (int i = 0; i <= 3; i++) {
- if ((_gameBoardSide[playerId]._handCard[i]._cardId > 1) && (_gameBoardSide[playerId]._handCard[i]._cardId <= 9)) {
- discardCard(&_gameBoardSide[playerId]._handCard[i]);
- return;
- }
- }
-
- for (int i = 0; i <= 3; i++) {
- if (getStationCardId(_gameBoardSide[playerId]._handCard[i]._cardId) != -1) {
- discardCard(&_gameBoardSide[playerId]._handCard[i]);
- return;
- }
- }
-
- for (int i = 0; i <= 3; i++) {
- if (isDelayCard(_gameBoardSide[playerId]._handCard[i]._cardId) != -1) {
- discardCard(&_gameBoardSide[playerId]._handCard[i]);
- return;
- }
- }
-
- for (int i = 0; i <= 3; i++) {
- if (_gameBoardSide[playerId]._handCard[i]._cardId == 25) {
- discardCard(&_gameBoardSide[playerId]._handCard[i]);
- return;
- }
- }
-
- for (int i = 0; i <= 3; i++) {
- if (_gameBoardSide[playerId]._handCard[i]._cardId == 13) {
- discardCard(&_gameBoardSide[playerId]._handCard[i]);
- return;
- }
- }
-
- break;
- default:
- break;
- }
-}
-
-void Scene1337::playThieftCard(int playerId, Card *card, int victimId) {
- _actionIdx1 = playerId;
- _actionIdx2 = victimId;
-
- int randIndx;
-
- for (;;) {
- randIndx = R2_GLOBALS._randomSource.getRandomNumber(3);
- if (_gameBoardSide[victimId]._handCard[randIndx]._cardId != 0)
- break;
- }
-
- _actionCard1 = card;
- _actionCard2 = &_gameBoardSide[victimId]._emptyStationPos;
- _actionCard3 = &_gameBoardSide[victimId]._handCard[randIndx];
-
- _actionItem.setAction(&_action11);
-}
-
-int Scene1337::getPreventionCardId(int cardId) {
- int retVal;
-
- switch (cardId) {
- case 10:
- retVal = 2;
- break;
- case 12:
- retVal = 3;
- break;
- case 15:
- retVal = 5;
- break;
- case 17:
- retVal = 9;
- break;
- case 18:
- retVal = 6;
- break;
- case 19:
- retVal = 4;
- break;
- case 20:
- retVal = 8;
- break;
- case 21:
- retVal = 7;
- break;
- default:
- retVal = -1;
- }
-
- return retVal;
-}
-
-bool Scene1337::isAttackPossible(int victimId, int cardId) {
- if (victimId < 0 || victimId >= ARRAYSIZE(_gameBoardSide))
- error("Scene1337::isAttackPossible() victimId:%d out of range 0 to %d", victimId, ARRAYSIZE(_gameBoardSide)-1);
-
- for (int i = 0; i <= 7; i++) {
- if (_gameBoardSide[victimId]._outpostStation[i]._cardId != 0) {
- if (getPreventionCardId(cardId) == _gameBoardSide[victimId]._outpostStation[i]._cardId)
- return false;
- }
- }
- return true;
-}
-
-int Scene1337::getPlayerWithOutpost(int playerId) {
- int randPlayerId = R2_GLOBALS._randomSource.getRandomNumber(3);
-
- for (int i = 0; i <= 3; i++) {
- if (randPlayerId != playerId) {
- for (int j = 0; j <= 7; j++) {
- if (_gameBoardSide[randPlayerId]._outpostStation[j]._cardId != 0)
- return randPlayerId;
- }
- }
-
- if (playerId == 1) {
- randPlayerId--;
- if (randPlayerId < 0)
- randPlayerId = 3;
- } else {
- ++randPlayerId;
- if (randPlayerId > 3)
- randPlayerId = 0;
- }
- }
-
- return -1;
-}
-
-bool Scene1337::checkAntiDelayCard(int delayCardId, int cardId) {
- if ((delayCardId == 11) && (cardId == 26))
- return true;
-
- if ((delayCardId == 14) && (cardId == 30))
- return true;
-
- if ((delayCardId == 16) && (cardId == 32))
- return true;
-
- if ((delayCardId == 24) && (cardId == 28))
- return true;
-
- return false;
-}
-
-void Scene1337::playStationCard(Card *station, Card *platform) {
- _actionCard1 = station;
- _actionCard2 = platform;
- _actionItem.setAction(&_action7);
-}
-
-int Scene1337::getFreeHandCard(int playerId) {
- if ( (_gameBoardSide[playerId]._handCard[0]._cardId == 0)
- && (_gameBoardSide[playerId]._handCard[1]._cardId == 0)
- && (_gameBoardSide[playerId]._handCard[2]._cardId == 0)
- && (_gameBoardSide[playerId]._handCard[3]._cardId == 0))
- return -1;
-
- int randIndx;
- for (;;) {
- randIndx = R2_GLOBALS._randomSource.getRandomNumber(3);
- if (_gameBoardSide[playerId]._handCard[randIndx]._cardId == 0)
- break;
- }
-
- return randIndx;
-}
-
-void Scene1337::playPlatformCard(Card *card, Card *dest) {
- _actionCard1 = card;
- _actionCard2 = dest;
-
- _actionItem.setAction(&_action6);
-}
-
-void Scene1337::playDelayCard(Card *card, Card *dest) {
- _actionCard1 = card;
- _actionCard2 = dest;
-
- _actionItem.setAction(&_action9);
-}
-
-void Scene1337::playAntiDelayCard(Card *card, Card *dest) {
- _actionCard1 = card;
- _actionCard2 = dest;
-
- _actionItem.setAction(&_action8);
-
- handleNextTurn();
-}
-
-
-Scene1337::Card *Scene1337::getStationCard(int playerId) {
- for (int i = 0; i <= 7; i++) {
- if ((_gameBoardSide[playerId]._outpostStation[i]._cardId >= 1) && (_gameBoardSide[playerId]._outpostStation[i]._cardId <= 9))
- return &_gameBoardSide[playerId]._outpostStation[i];
- }
-
- return nullptr;
-}
-
-void Scene1337::playCounterTrickCard(Card *card, int playerId) {
- _actionCard1 = card;
- _actionCard2 = getStationCard(playerId);
- _actionCard3 = &_gameBoardSide[playerId]._emptyStationPos;
- _actionIdx1 = playerId;
- _actionItem.setAction(&_action10);
- handleNextTurn();
-}
-
-void Scene1337::discardCard(Card *card) {
- _actionCard1 = card;
-
- _actionItem.setAction(&_action5);
-}
-
-void Scene1337::subC4CD2() {
- if (R2_GLOBALS._v57709 > 0) {
- subD1917();
- subD1940(false); // _v5780C--
- }
-}
-
-void Scene1337::subC4CEC() {
- if (R2_GLOBALS._v57709 == 0) {
- subD18F5();
- subD1940(true); // _v5780C++
- }
-}
-
-void Scene1337::subC51A0(Card *subObj1, Card *subObj2) {
- _actionCard1 = subObj1;
- _actionCard2 = subObj2;
-
- _actionItem.setAction(&_action13);
-}
-
-void Scene1337::displayDialog(int dialogNumb) {
- switch (dialogNumb - 1) {
- case 0:
- actionDisplay(1330, 53, 159, 10, 1, 200, 0, 7, 0, 154, 154);
- break;
- case 1:
- actionDisplay(1330, 57, 159, 10, 1, 200, 0, 7, 0, 154, 154);
- break;
- case 2:
- actionDisplay(1330, 58, 159, 10, 1, 200, 0, 7, 0, 154, 154);
- break;
- case 3:
- actionDisplay(1330, 59, 159, 10, 1, 200, 0, 7, 0, 154, 154);
- break;
- case 4:
- actionDisplay(1330, 60, 159, 10, 1, 200, 0, 7, 0, 154, 154);
- break;
- case 5:
- actionDisplay(1330, 61, 159, 10, 1, 200, 0, 7, 0, 154, 154);
- break;
- case 6:
- actionDisplay(1330, 62, 159, 10, 1, 200, 0, 7, 0, 154, 154);
- break;
- case 7:
- actionDisplay(1330, 63, 159, 10, 1, 200, 0, 7, 0, 154, 154);
- break;
- case 8:
- actionDisplay(1330, 64, 159, 10, 1, 200, 0, 7, 0, 154, 154);
- break;
- case 9:
- actionDisplay(1330, 65, 159, 10, 1, 200, 0, 7, 0, 154, 154);
- break;
- case 10:
- actionDisplay(1330, 67, 159, 10, 1, 200, 0, 7, 0, 154, 154);
- break;
- case 11:
- actionDisplay(1330, 69, 159, 10, 1, 200, 0, 7, 0, 154, 154);
- break;
- case 12:
- actionDisplay(1330, 71, 159, 10, 1, 200, 0, 7, 0, 154, 154);
- actionDisplay(1330, 72, 159, 10, 1, 200, 0, 7, 0, 154, 154);
- actionDisplay(1330, 73, 159, 10, 1, 200, 0, 7, 0, 154, 154);
- break;
- case 13:
- actionDisplay(1330, 79, 159, 10, 1, 200, 0, 7, 0, 154, 154);
- break;
- case 14:
- actionDisplay(1330, 81, 159, 10, 1, 200, 0, 7, 0, 154, 154);
- break;
- case 15:
- actionDisplay(1330, 83, 159, 10, 1, 200, 0, 7, 0, 154, 154);
- break;
- case 16:
- actionDisplay(1330, 85, 159, 10, 1, 200, 0, 7, 0, 154, 154);
- break;
- case 17:
- actionDisplay(1330, 87, 159, 10, 1, 200, 0, 7, 0, 154, 154);
- break;
- case 18:
- actionDisplay(1330, 89, 159, 10, 1, 200, 0, 7, 0, 154, 154);
- break;
- case 19:
- actionDisplay(1330, 91, 159, 10, 1, 200, 0, 7, 0, 154, 154);
- break;
- case 20:
- actionDisplay(1330, 93, 159, 10, 1, 200, 0, 7, 0, 154, 154);
- break;
- case 23:
- actionDisplay(1330, 95, 159, 10, 1, 200, 0, 7, 0, 154, 154);
- break;
- case 24:
- actionDisplay(1330, 97, 159, 10, 1, 200, 0, 7, 0, 154, 154);
- break;
- case 25:
- actionDisplay(1330, 104, 159, 10, 1, 200, 0, 7, 0, 154, 154);
- break;
- case 26:
- actionDisplay(1330, 105, 159, 10, 1, 200, 0, 7, 0, 154, 154);
- actionDisplay(1330, 106, 159, 10, 1, 200, 0, 7, 0, 154, 154);
- break;
- case 27:
- actionDisplay(1330, 110, 159, 10, 1, 200, 0, 7, 0, 154, 154);
- break;
- case 28:
- actionDisplay(1330, 108, 159, 10, 1, 200, 0, 7, 0, 154, 154);
- actionDisplay(1330, 109, 159, 10, 1, 200, 0, 7, 0, 154, 154);
- break;
- case 29:
- actionDisplay(1330, 111, 159, 10, 1, 200, 0, 7, 0, 154, 154);
- break;
- case 31:
- actionDisplay(1330, 112, 159, 10, 1, 200, 0, 7, 0, 154, 154);
- break;
- default:
- break;
- }
-}
-
-void Scene1337::subPostInit() {
- R2_GLOBALS._v57709 = 0;
- R2_GLOBALS._v5780C = 0;
- updateCursorId(1, false);
- subD1940(true); // _v5780C++
- subD18F5();
-
-// loadScene(1330);
-// SceneExt::postInit();
-
- R2_GLOBALS._scenePalette.addRotation(224, 235, 1);
-
- _availableCardsPile[0] = 1;
- _availableCardsPile[1] = 1;
- _availableCardsPile[2] = 1;
- _availableCardsPile[3] = 1;
- _availableCardsPile[4] = 1;
- _availableCardsPile[5] = 1;
- _availableCardsPile[6] = 1;
- _availableCardsPile[7] = 1;
- _availableCardsPile[8] = 26;
- _availableCardsPile[9] = 2;
- _availableCardsPile[10] = 2;
- _availableCardsPile[11] = 2;
- _availableCardsPile[12] = 2;
- _availableCardsPile[13] = 2;
- _availableCardsPile[14] = 26;
- _availableCardsPile[15] = 3;
- _availableCardsPile[16] = 3;
- _availableCardsPile[17] = 3;
- _availableCardsPile[18] = 3;
- _availableCardsPile[19] = 3;
- _availableCardsPile[20] = 28;
- _availableCardsPile[21] = 4;
- _availableCardsPile[22] = 4;
- _availableCardsPile[23] = 4;
- _availableCardsPile[24] = 4;
- _availableCardsPile[25] = 4;
- _availableCardsPile[26] = 28;
- _availableCardsPile[27] = 5;
- _availableCardsPile[28] = 5;
- _availableCardsPile[29] = 5;
- _availableCardsPile[30] = 5;
- _availableCardsPile[31] = 5;
- _availableCardsPile[32] = 30;
- _availableCardsPile[33] = 6;
- _availableCardsPile[34] = 6;
- _availableCardsPile[35] = 6;
- _availableCardsPile[36] = 6;
- _availableCardsPile[37] = 6;
- _availableCardsPile[38] = 30;
- _availableCardsPile[39] = 7;
- _availableCardsPile[40] = 7;
- _availableCardsPile[41] = 7;
- _availableCardsPile[42] = 7;
- _availableCardsPile[43] = 7;
- _availableCardsPile[44] = 32;
- _availableCardsPile[45] = 8;
- _availableCardsPile[46] = 8;
- _availableCardsPile[47] = 8;
- _availableCardsPile[48] = 8;
- _availableCardsPile[49] = 8;
- _availableCardsPile[50] = 32;
- _availableCardsPile[51] = 9;
- _availableCardsPile[52] = 9;
- _availableCardsPile[53] = 9;
- _availableCardsPile[54] = 9;
- _availableCardsPile[55] = 9;
- _availableCardsPile[56] = 10;
- _availableCardsPile[57] = 11;
- _availableCardsPile[58] = 12;
- _availableCardsPile[59] = 13;
- _availableCardsPile[60] = 13;
- _availableCardsPile[61] = 14;
- _availableCardsPile[62] = 15;
- _availableCardsPile[63] = 16;
- _availableCardsPile[64] = 17;
- _availableCardsPile[65] = 18;
- _availableCardsPile[66] = 19;
- _availableCardsPile[67] = 20;
- _availableCardsPile[68] = 21;
- _availableCardsPile[69] = 26;
- _availableCardsPile[70] = 28;
- _availableCardsPile[71] = 24;
- _availableCardsPile[72] = 25;
- _availableCardsPile[73] = 25;
- _availableCardsPile[74] = 25;
- _availableCardsPile[75] = 25;
- _availableCardsPile[76] = 26;
- _availableCardsPile[77] = 26;
- _availableCardsPile[78] = 26;
- _availableCardsPile[79] = 27;
- _availableCardsPile[80] = 27;
- _availableCardsPile[81] = 28;
- _availableCardsPile[82] = 28;
- _availableCardsPile[83] = 28;
- _availableCardsPile[84] = 29;
- _availableCardsPile[85] = 29;
- _availableCardsPile[86] = 29;
- _availableCardsPile[87] = 30;
- _availableCardsPile[88] = 30;
- _availableCardsPile[89] = 30;
- _availableCardsPile[90] = 30;
- _availableCardsPile[91] = 32;
- _availableCardsPile[92] = 1;
- _availableCardsPile[93] = 32;
- _availableCardsPile[94] = 32;
- _availableCardsPile[95] = 32;
- _availableCardsPile[96] = 1;
- _availableCardsPile[97] = 1;
- _availableCardsPile[98] = 1;
- _availableCardsPile[99] = 0;
-
- _cardsAvailableNumb = 98;
- _currentDiscardIndex = 98; // CHECKME: Would make more sense at pos 99
-
- _discardPile._cardId = 0;
- _discardPile._stationPos = Common::Point(128, 95);
-
- _stockCard._cardId = 0;
- _stockCard._stationPos = Common::Point(162, 95);
-
- _selectedCard._cardId = 0;
-
- _animatedCard._card.postInit();
- _animatedCard._card.setVisage(1332);
- _animatedCard._card.setStrip(5);
- _animatedCard._card.setFrame(1);
- _animatedCard._card._moveDiff = Common::Point(10, 10);
- _animatedCard._card.fixPriority(400);
- _animatedCard._card.setPosition(Common::Point(128, 95), 0);
- _animatedCard._card.animate(ANIM_MODE_2, NULL);
- _animatedCard._card.hide();
-
- _currentPlayerArrow.postInit();
- _currentPlayerArrow.setVisage(1334);
- _currentPlayerArrow.setStrip(1);
- _currentPlayerArrow.setFrame(1);
- _currentPlayerArrow._numFrames = 12;
- _currentPlayerArrow.fixPriority(500);
- _currentPlayerArrow.setPosition(Common::Point(174, 107), 0);
- _currentPlayerArrow.animate(ANIM_MODE_2, NULL);
- _currentPlayerArrow.hide();
-
- _showPlayerTurn = true;
- _displayHelpFl = false;
- _winnerId = -1;
-
- _helpIcon.postInit();
- _helpIcon.setup(9531, 1, 1);
- _helpIcon.setPosition(Common::Point(249, 168));
- _helpIcon.setPriority(155);
- _helpIcon._effect = EFFECT_NONE;
- _helpIcon.show();
-
- _autoplay = false;
- _instructionsDisplayedFl = false;
- _instructionsWaitCount = 0;
-}
-
-void Scene1337::suggestInstructions() {
- if (R2_GLOBALS._v57709 > 0)
- subD1917();
-
- if (MessageDialog::show(NEED_INSTRUCTIONS, NO_MSG, YES_MSG) == 0) {
- if (R2_GLOBALS._v57709 == 0)
- subD18F5();
- dealCards();
- } else {
- if (R2_GLOBALS._v57709 == 0)
- subD18F5();
- displayInstructions();
- }
-}
-
-void Scene1337::displayInstructions() {
- _actionItem.setAction(&_action1);
-}
-
-void Scene1337::shuffleCards() {
- R2_GLOBALS._sceneObjects->draw();
-
- // Remove holes in card pile
- for (int i = 0; i <= 98; i++) {
- if (_availableCardsPile[i] == 0) {
- for (int j = i + 1; j <= 98; j ++) {
- if (_availableCardsPile[j] != 0) {
- _availableCardsPile[i] = _availableCardsPile[j];
- _availableCardsPile[j] = 0;
- break;
- }
- }
- }
- }
-
- // Compute the number of available cards
- for (int i = 0; i <= 99; i ++) {
- if (_availableCardsPile[i] == 0) {
- // CHECKME: This will fail if i == 0, which shouldn't happen
- // as we don't shuffle cards when no card is available.
- _cardsAvailableNumb = i - 1;
- _currentDiscardIndex = 98; // CHECKME: Would make more sense at pos 99
- break;
- }
- }
-
- for (int i = 0; i < 2000; i ++) {
- int randIndx = R2_GLOBALS._randomSource.getRandomNumber(_cardsAvailableNumb);
- int swap = _availableCardsPile[0];
- _availableCardsPile[0] = _availableCardsPile[randIndx];
- _availableCardsPile[randIndx] = swap;
- }
-
- _shuffleEndedFl = false;
-
- // Shuffle cards
- _animatedCard._card.setAction(&_action2);
-
- while(!_shuffleEndedFl && !g_vm->shouldQuit()) {
- g_globals->_sceneObjects->recurse(SceneHandler::dispatchObject);
- g_globals->_scenePalette.signalListeners();
- R2_GLOBALS._sceneObjects->draw();
- g_globals->_events.delay(g_globals->_sceneHandler->_delayTicks);
- }
-}
-
-void Scene1337::dealCards() {
- _animatedCard._card._moveDiff = Common::Point(30, 30);
- shuffleCards();
-
- // Deal cards
- _actionItem.setAction(&_action3);
-}
-
-void Scene1337::showOptionsDialog() {
- // Display menu with "Auto Play", "New Game", "Quit" and "Continue"
- OptionsDialog::show();
-}
-
-void Scene1337::handleClick(int arg1, Common::Point pt) {
- int curReg = R2_GLOBALS._sceneRegions.indexOf(g_globals->_events._mousePos);
-
- if (arg1 == 3) {
- bool found = false;
- int i;
- for (i = 0; i <= 7; i++) {
- if ( _gameBoardSide[2]._outpostStation[i].isIn(pt)
- || _gameBoardSide[0]._outpostStation[i].isIn(pt)
- || _gameBoardSide[1]._outpostStation[i].isIn(pt)
- || _gameBoardSide[3]._outpostStation[i].isIn(pt) ) {
- found = true;
- break;
- }
- }
-
- if (found) {
- switch (curReg) {
- case 5:
- if (_gameBoardSide[2]._outpostStation[i]._cardId != 0)
- displayDialog(_gameBoardSide[2]._outpostStation[i]._cardId);
- else
- actionDisplay(1330, 20, 159, 10, 1, 200, 0, 7, 0, 154, 154);
- break;
- case 10:
- if (_gameBoardSide[3]._outpostStation[i]._cardId != 0)
- displayDialog(_gameBoardSide[3]._outpostStation[i]._cardId);
- else
- actionDisplay(1330, 22, 159, 10, 1, 200, 0, 7, 0, 154, 154);
- break;
- case 15:
- if (_gameBoardSide[0]._outpostStation[i]._cardId != 0)
- displayDialog(_gameBoardSide[0]._outpostStation[i]._cardId);
- else
- actionDisplay(1330, 21, 159, 10, 1, 200, 0, 7, 0, 154, 154);
- break;
- case 20:
- if (_gameBoardSide[1]._outpostStation[i]._cardId != 0)
- displayDialog(_gameBoardSide[1]._outpostStation[i]._cardId);
- else
- actionDisplay(1330, 23, 159, 10, 1, 200, 0, 7, 0, 154, 154);
- break;
- default:
- break;
- }
- } else if ( _gameBoardSide[2]._delayCard.isIn(pt)
- || _gameBoardSide[0]._delayCard.isIn(pt)
- || _gameBoardSide[1]._delayCard.isIn(pt)
- || _gameBoardSide[3]._delayCard.isIn(pt) ) {
- switch (curReg) {
- case 5:
- if (_gameBoardSide[2]._delayCard._cardId != 0)
- displayDialog(_gameBoardSide[2]._delayCard._cardId);
- else
- actionDisplay(1330, 10, 159, 10, 1, 200, 0, 7, 0, 154, 154);
- break;
- case 10:
- if (_gameBoardSide[3]._delayCard._cardId != 0)
- displayDialog(_gameBoardSide[3]._delayCard._cardId);
- else
- actionDisplay(1330, 16, 159, 10, 1, 200, 0, 7, 0, 154, 154);
- break;
- case 15:
- if (_gameBoardSide[0]._delayCard._cardId != 0)
- displayDialog(_gameBoardSide[0]._delayCard._cardId);
- else
- actionDisplay(1330, 13, 159, 10, 1, 200, 0, 7, 0, 154, 154);
- break;
- case 20:
- if (_gameBoardSide[1]._delayCard._cardId != 0)
- displayDialog(_gameBoardSide[1]._delayCard._cardId);
- else
- actionDisplay(1330, 18, 159, 10, 1, 200, 0, 7, 0, 154, 154);
- break;
- default:
- break;
- }
- } else if (_discardPile.isIn(pt)) {
- if (_discardPile._cardId != 0)
- displayDialog(_discardPile._cardId);
- else
- actionDisplay(1330, 7, 159, 10, 1, 200, 0, 7, 0, 154, 154);
- } else if (_helpIcon._bounds.contains(pt))
- actionDisplay(1330, 43, 159, 10, 1, 200, 0, 7, 0, 154, 154);
- else if (_stockCard.isIn(pt))
- actionDisplay(1330, 4, 159, 10, 1, 200, 0, 7, 0, 154, 154);
- else if ( (_gameBoardSide[2]._emptyStationPos.isIn(pt))
- || (_gameBoardSide[3]._emptyStationPos.isIn(pt))
- || (_gameBoardSide[0]._emptyStationPos.isIn(pt))
- || (_gameBoardSide[1]._emptyStationPos.isIn(pt)) )
- actionDisplay(1330, 32, 159, 10, 1, 200, 0, 7, 0, 154, 154);
- else if (_gameBoardSide[2]._handCard[0].isIn(pt))
- displayDialog(_gameBoardSide[2]._handCard[0]._cardId);
- else if (_gameBoardSide[2]._handCard[1].isIn(pt))
- displayDialog(_gameBoardSide[2]._handCard[1]._cardId);
- else if (_gameBoardSide[2]._handCard[2].isIn(pt))
- displayDialog(_gameBoardSide[2]._handCard[2]._cardId);
- else if (_gameBoardSide[2]._handCard[3].isIn(pt))
- displayDialog(_gameBoardSide[2]._handCard[3]._cardId);
- else if ((curReg >= 6) && (curReg <= 9))
- actionDisplay(1330, 29, 159, 10, 1, 200, 0, 7, 0, 154, 154);
- else if ((curReg >= 11) && (curReg <= 14))
- actionDisplay(1330, 31, 159, 10, 1, 200, 0, 7, 0, 154, 154);
- else if ((curReg >= 16) && (curReg <= 19))
- actionDisplay(1330, 30, 159, 10, 1, 200, 0, 7, 0, 154, 154);
- else {
- switch (curReg) {
- case 0:
- actionDisplay(1330, 2, 159, 134, 1, 200, 0, 7, 0, 105, 105);
- break;
- case 5:
- actionDisplay(1330, 25, 159, 10, 1, 200, 0, 7, 0, 154, 154);
- break;
- case 10:
- actionDisplay(1330, 27, 159, 10, 1, 200, 0, 7, 0, 154, 154);
- break;
- case 15:
- actionDisplay(1330, 26, 159, 10, 1, 200, 0, 7, 0, 154, 154);
- break;
- case 20:
- actionDisplay(1330, 28, 159, 10, 1, 200, 0, 7, 0, 154, 154);
- break;
- case 21:
- actionDisplay(1330, 24, 159, 10, 1, 200, 0, 7, 0, 154, 154);
- break;
- default:
- break;
- }
- }
- }
-
- if (arg1 != 1)
- return;
-
- for (int i = 0; i <= 7; i++) {
- if (_gameBoardSide[2]._outpostStation[i].isIn(pt)) {
- switch (_gameBoardSide[2]._outpostStation[i]._cardId) {
- case 0:
- actionDisplay(1330, 11, 159, 10, 1, 200, 0, 7, 0, 154, 154);
- break;
- case 1:
- actionDisplay(1330, 54, 159, 10, 1, 200, 0, 7, 0, 154, 154);
- break;
- default:
- actionDisplay(1330, 34, 159, 10, 1, 200, 0, 7, 0, 154, 154);
- break;
- }
- return;
- }
- if (_gameBoardSide[0]._outpostStation[i].isIn(pt)) {
- switch (_gameBoardSide[0]._outpostStation[i]._cardId) {
- case 0:
- actionDisplay(1330, 11, 159, 10, 1, 200, 0, 7, 0, 154, 154);
- break;
- default:
- actionDisplay(1330, 1, 159, 10, 1, 200, 0, 7, 0, 154, 154);
- break;
- }
- return;
- }
- if (_gameBoardSide[1]._outpostStation[i].isIn(pt)) {
- switch (_gameBoardSide[1]._outpostStation[i]._cardId) {
- case 0:
- actionDisplay(1330, 146, 300, 99, 1, 136, 0, 7, 0, 117, 117);
- break;
- default:
- actionDisplay(1330, 144, 300, 99, 1, 136, 0, 7, 0, 117, 117);
- break;
- }
- return;
- }
- if (_gameBoardSide[3]._outpostStation[i].isIn(pt)) {
- switch (_gameBoardSide[3]._outpostStation[i]._cardId) {
- case 0:
- actionDisplay(1330, 147, 20, 99, 1, 136, 0, 7, 0, 172, 172);
- break;
- default:
- actionDisplay(1330, 145, 20, 99, 1, 136, 0, 7, 0, 172, 172);
- break;
- }
- return;
- }
- }
-
- if (_gameBoardSide[2]._delayCard.isIn(pt)) {
- // The original uses _gameBoardSide[0], which is obviously a bug.
- if (_gameBoardSide[2]._delayCard._cardId != 0)
- actionDisplay(1330, 39, 159, 10, 1, 200, 0, 7, 0, 154, 154);
- else
- actionDisplay(1330, 11, 159, 10, 1, 200, 0, 7, 0, 154, 154);
-
- return;
- }
- if (_gameBoardSide[3]._delayCard.isIn(pt)) {
- if (_gameBoardSide[3]._delayCard._cardId != 0)
- actionDisplay(1330, 145, 20, 99, 1, 136, 0, 7, 0, 172, 172);
- else
- actionDisplay(1330, 147, 20, 99, 1, 136, 0, 7, 0, 172, 172);
-
- return;
- }
- if (_gameBoardSide[1]._delayCard.isIn(pt)) {
- if (_gameBoardSide[1]._delayCard._cardId != 0)
- actionDisplay(1330, 144, 300, 99, 1, 136, 0, 7, 0, 117, 117);
- else
- actionDisplay(1330, 146, 300, 99, 1, 136, 0, 7, 0, 117, 117);
-
- return;
- }
- if (_gameBoardSide[0]._delayCard.isIn(pt)) {
- if (_gameBoardSide[0]._delayCard._cardId != 0)
- actionDisplay(1330, 1, 159, 10, 1, 200, 0, 7, 0, 154, 154);
- else
- actionDisplay(1330, 11, 159, 10, 1, 200, 0, 7, 0, 154, 154);
-
- return;
- }
- if (_gameBoardSide[3]._emptyStationPos.isIn(pt)) {
- actionDisplay(1330, 147, 20, 99, 1, 136, 0, 7, 0, 172, 172);
- return;
- }
- if (_gameBoardSide[1]._emptyStationPos.isIn(pt)) {
- actionDisplay(1330, 146, 300, 99, 1, 136, 0, 7, 0, 117, 117);
- return;
- }
- if (_gameBoardSide[0]._emptyStationPos.isIn(pt)) {
- actionDisplay(1330, 11, 159, 10, 1, 200, 0, 7, 0, 154, 154);
- return;
- }
-
- if (_helpIcon._bounds.contains(pt)) {
- showOptionsDialog();
- return;
- }
-
- if (_discardPile.isIn(pt))
- actionDisplay(1330, 9, 159, 10, 1, 200, 0, 7, 0, 154, 154);
- else if (_stockCard.isIn(pt))
- actionDisplay(1330, 5, 159, 10, 1, 200, 0, 7, 0, 154, 154);
- else {
- switch (curReg) {
- case 0:
- actionDisplay(1330, 3, 159, 10, 1, 200, 0, 7, 0, 154, 154);
- break;
- case 6:
- // no break on purpose
- case 7:
- // no break on purpose
- case 8:
- // no break on purpose
- case 9:
- actionDisplay(1330, 145, 20, 99, 1, 136, 0, 7, 0, 172, 172);
- break;
- case 10:
- actionDisplay(1330, 147, 20, 99, 1, 136, 0, 7, 0, 172, 172);
- break;
- case 11:
- // no break on purpose
- case 12:
- // no break on purpose
- case 13:
- // no break on purpose
- case 14:
- actionDisplay(1330, 1, 159, 10, 1, 200, 0, 7, 0, 154, 154);
- break;
- case 16:
- // no break on purpose
- case 17:
- // no break on purpose
- case 18:
- // no break on purpose
- case 19:
- actionDisplay(1330, 144, 300, 99, 1, 136, 0, 7, 0, 117, 117);
- break;
- case 20:
- actionDisplay(1330, 146, 300, 99, 1, 136, 0, 7, 0, 117, 117);
- break;
- default:
- actionDisplay(1330, 11, 159, 10, 1, 200, 0, 7, 0, 154, 154);
- break;
- }
- }
-}
-
-void Scene1337::handlePlayer0() {
- if (_gameBoardSide[0]._delayCard._cardId != 0) {
- switch (_gameBoardSide[0]._delayCard._cardId) {
- case 10:
- //No break on purpose
- case 12:
- //No break on purpose
- case 15:
- //No break on purpose
- case 17:
- //No break on purpose
- case 18:
- //No break on purpose
- case 19:
- //No break on purpose
- case 20:
- //No break on purpose
- case 21:
- discardCard(&_gameBoardSide[0]._delayCard);
- break;
- default:
- for (int i = 0; i <= 3; i++) {
- if (checkAntiDelayCard(_gameBoardSide[0]._delayCard._cardId, _gameBoardSide[0]._handCard[i]._cardId)) {
- playAntiDelayCard(&_gameBoardSide[0]._handCard[i], &_gameBoardSide[0]._delayCard);
- return;
- }
- }
-
- break;
- }
- }
-
- for (int i = 0; i <= 3; i++) {
- int tmpVal = getStationId(0, i);
-
- if (tmpVal != -1) {
- bool stationAlreadyPresentFl = false;
- for (int j = 0; j <= 7; j++) {
- if (_gameBoardSide[0]._outpostStation[j]._cardId == _gameBoardSide[0]._handCard[tmpVal]._cardId) {
- stationAlreadyPresentFl = true;
- break;
- }
- }
-
- if (!stationAlreadyPresentFl) {
- for (int j = 0; j <= 7; j++) {
- if ((_gameBoardSide[0]._outpostStation[j]._cardId == 1) && !isStopConstructionCard(_gameBoardSide[0]._delayCard._cardId)) {
- int stationCount = 0;
- for (int k = 0; k <= 7; k++) {
- if ((_gameBoardSide[0]._outpostStation[k]._cardId > 1) && (_gameBoardSide[0]._outpostStation[k]._cardId <= 9)) {
- ++stationCount;
- }
- }
-
- if (stationCount == 7)
- _winnerId = 0;
-
- playStationCard(&_gameBoardSide[0]._handCard[tmpVal], &_gameBoardSide[0]._outpostStation[j]);
- return;
- }
- }
- }
- }
- }
-
- int tmpVal = findPlatformCardInHand(0);
-
- if (tmpVal != -1) {
- for (int i = 0; i <= 7; i++) {
- if ((_gameBoardSide[0]._outpostStation[i]._cardId == 0) && !isStopConstructionCard(_gameBoardSide[0]._delayCard._cardId)) {
- playPlatformCard(&_gameBoardSide[0]._handCard[tmpVal], &_gameBoardSide[0]._outpostStation[i]);
- return;
- }
- }
- }
-
- int card13Id = findCard13InHand(0);
- if (card13Id != -1) {
- for (int i = 0; i <= 7; i++) {
- if (_gameBoardSide[2]._outpostStation[i]._cardId != 0) {
- playCounterTrickCard(&_gameBoardSide[0]._handCard[card13Id], 2);
- return;
- }
- }
- }
-
- int thieftId = checkThieftCard(0);
- if (thieftId != -1) {
- if ( (_gameBoardSide[2]._handCard[0]._cardId != 0)
- || (_gameBoardSide[2]._handCard[1]._cardId != 0)
- || (_gameBoardSide[2]._handCard[2]._cardId != 0)
- || (_gameBoardSide[2]._handCard[3]._cardId != 0) ) {
- playThieftCard(0, &_gameBoardSide[0]._handCard[thieftId], 2);
- return;
- }
- }
-
- for (int i = 0; i <= 3; i++) {
- if ((isDelayCard(_gameBoardSide[0]._handCard[i]._cardId) != -1)
- && (_gameBoardSide[2]._delayCard._cardId == 0)
- && isAttackPossible(2, _gameBoardSide[0]._handCard[i]._cardId)) {
- playDelayCard(&_gameBoardSide[0]._handCard[i], &_gameBoardSide[2]._delayCard);
- return;
- }
- }
-
- for (int i = 0; i <= 3; i++) {
- if ((getStationCardId(_gameBoardSide[0]._handCard[i]._cardId) != -1)
- && (_gameBoardSide[2]._delayCard._cardId == 0)
- && isAttackPossible(2, _gameBoardSide[0]._handCard[i]._cardId)) {
- playDelayCard(&_gameBoardSide[0]._handCard[i], &_gameBoardSide[2]._delayCard);
- return;
- }
- }
-
- card13Id = findCard13InHand(0);
- int victimPlayerId = getPlayerWithOutpost(0);
-
- if ((card13Id != -1) && (victimPlayerId != -1)) {
- playCounterTrickCard(&_gameBoardSide[0]._handCard[card13Id], victimPlayerId);
- return;
- }
-
- thieftId = checkThieftCard(0);
- if (thieftId != -1) {
- if ( (_gameBoardSide[1]._handCard[0]._cardId != 0)
- || (_gameBoardSide[1]._handCard[1]._cardId != 0)
- || (_gameBoardSide[1]._handCard[2]._cardId != 0)
- || (_gameBoardSide[1]._handCard[3]._cardId != 0) ) {
- playThieftCard(0, &_gameBoardSide[0]._handCard[thieftId], 1);
- return;
- }
- }
-
- for (int i = 0; i <= 3; i++) {
- if (getStationCardId(_gameBoardSide[0]._handCard[i]._cardId) != -1) {
- if ((_gameBoardSide[1]._delayCard._cardId == 0) && isAttackPossible(1, _gameBoardSide[0]._handCard[i]._cardId)) {
- playDelayCard(&_gameBoardSide[0]._handCard[i], &_gameBoardSide[1]._delayCard);
- return;
- }
-
- if ((_gameBoardSide[3]._delayCard._cardId == 0) && isAttackPossible(3, _gameBoardSide[0]._handCard[i]._cardId)) {
- playDelayCard(&_gameBoardSide[0]._handCard[i], &_gameBoardSide[3]._delayCard);
- return;
- }
- }
- }
-
- for (int i = 0; i <= 3; i++) {
- tmpVal = isDelayCard(_gameBoardSide[0]._handCard[i]._cardId);
- if (tmpVal != -1) {
- if ((_gameBoardSide[1]._delayCard._cardId == 0) && isAttackPossible(1, _gameBoardSide[0]._handCard[i]._cardId)) {
- playDelayCard(&_gameBoardSide[0]._handCard[i], &_gameBoardSide[1]._delayCard);
- return;
- }
-
- if ((_gameBoardSide[3]._delayCard._cardId == 0) && isAttackPossible(3, _gameBoardSide[0]._handCard[i]._cardId)) {
- playDelayCard(&_gameBoardSide[0]._handCard[i], &_gameBoardSide[3]._delayCard);
- return;
- }
- }
- }
-
- handlePlayer01Discard(0);
-}
-
-void Scene1337::handlePlayer1() {
- if (this->_gameBoardSide[1]._delayCard._cardId != 0) {
- switch (_gameBoardSide[1]._delayCard._cardId) {
- case 10:
- // No break on purpose
- case 12:
- // No break on purpose
- case 15:
- // No break on purpose
- case 17:
- // No break on purpose
- case 18:
- // No break on purpose
- case 19:
- // No break on purpose
- case 20:
- // No break on purpose
- case 21:
- discardCard(&_gameBoardSide[1]._delayCard);
- return;
- default:
- for (int i = 0; i <= 3; i++) {
- if (checkAntiDelayCard(_gameBoardSide[1]._delayCard._cardId, _gameBoardSide[1]._handCard[i]._cardId)) {
- playAntiDelayCard(&_gameBoardSide[1]._handCard[i], &_gameBoardSide[1]._delayCard);
- return;
- }
- }
- break;
- }
- }
-
- for (int i = 0; i <= 3; i++) {
- int tmpIndx = getStationId(1, i);
- if (tmpIndx == -1)
- break;
-
- int tmpVal = 0;
- for (int j = 0; j <= 7; j++) {
- if (_gameBoardSide[1]._outpostStation[j]._cardId == _gameBoardSide[1]._handCard[tmpIndx]._cardId) {
- tmpVal = 1;
- break;
- }
- }
-
- if (tmpVal == 0)
- break;
-
- for (int j = 0; j <= 7; j++) {
- if ((_gameBoardSide[1]._outpostStation[j]._cardId == 1) && !isStopConstructionCard(_gameBoardSide[1]._delayCard._cardId)) {
- int stationCount = 0;
- for (int k = 0; k <= 7; k++) {
- if ((_gameBoardSide[1]._outpostStation[k]._cardId > 1) && (_gameBoardSide[1]._outpostStation[k]._cardId <= 9))
- ++stationCount;
- }
-
- if (stationCount == 7)
- _winnerId = 1;
-
- playStationCard(&_gameBoardSide[1]._handCard[tmpIndx], &_gameBoardSide[1]._outpostStation[j]);
- return;
- }
- }
- }
-
- int normalCardId = findPlatformCardInHand(1);
- if (normalCardId != -1) {
- for (int i = 0; i <= 7; i++) {
- if ((_gameBoardSide[1]._outpostStation[i]._cardId == 0) && !isStopConstructionCard(_gameBoardSide[1]._delayCard._cardId)) {
- playPlatformCard(&_gameBoardSide[1]._handCard[normalCardId], &_gameBoardSide[1]._outpostStation[i]);
- return;
- }
- }
- }
-
- int card13Id = findCard13InHand(1);
- int tmpVal2 = getPlayerWithOutpost(1);
-
- if ((card13Id != -1) && (tmpVal2 != -1)) {
- playCounterTrickCard(&_gameBoardSide[1]._handCard[card13Id], tmpVal2);
- return;
- }
-
- int thieftId = checkThieftCard(1);
- if (thieftId != -1) {
- int playerIdFound = -1;
- int rndVal = R2_GLOBALS._randomSource.getRandomNumber(3);
- for (int i = 0; i <= 3; i++) {
- if (rndVal != 1) {
- if ( (_gameBoardSide[rndVal]._handCard[0]._cardId != 0)
- || (_gameBoardSide[rndVal]._handCard[1]._cardId != 0)
- || (_gameBoardSide[rndVal]._handCard[2]._cardId != 0)
- || (_gameBoardSide[rndVal]._handCard[3]._cardId == 0)) {
- playerIdFound = rndVal;
- break;
- }
- }
- // The original was only updating in the rndVal block,
- // which was a bug as the checks were stopping at this point
- rndVal--;
- if (rndVal < 0)
- rndVal = 3;
- }
-
- if (playerIdFound != -1) {
- playThieftCard(1, &_gameBoardSide[1]._handCard[thieftId], playerIdFound);
- return;
- }
- }
-
- int count = -1;
- int i;
- for (i = 0; i <= 3; i++) {
- int tmpVal = isDelayCard(_gameBoardSide[1]._handCard[i]._cardId);
- if (tmpVal != -1) {
- int rndVal = R2_GLOBALS._randomSource.getRandomNumber(3);
-
- for (int j = 0; j <= 3; j++) {
- //CHECKME: tmpVal or rndVal?
- // FIXME: This is probably meant to be rndVal, but not clear...
- if (tmpVal < 0 || tmpVal >= ARRAYSIZE(_gameBoardSide))
- error("Scene1337::handlePlayer1() tmpVal:%d out of range 0 to %d", tmpVal, ARRAYSIZE(_gameBoardSide)-1);
-
- if (tmpVal != 1) {
- if ((_gameBoardSide[tmpVal]._delayCard._cardId == 0) && isAttackPossible(tmpVal, _gameBoardSide[1]._handCard[i]._cardId))
- count = tmpVal;
- }
-
- if (count < 0 || count >= ARRAYSIZE(_gameBoardSide))
- error("Scene1337::handlePlayer1() count:%d out of range 0 to %d", count, ARRAYSIZE(_gameBoardSide)-1);
-
- if (count != -1) {
- playDelayCard(&_gameBoardSide[1]._handCard[i], &_gameBoardSide[count]._delayCard);
- return;
- } else {
- rndVal--;
- if (rndVal < 0)
- rndVal = 3;
- }
- }
- }
- }
-
- int j;
- for (j = 0; j <= 3; j++) {
- if (getStationCardId(_gameBoardSide[1]._handCard[j]._cardId) != -1) {
- count = -1;
- int rndVal = R2_GLOBALS._randomSource.getRandomNumber(3);
- for (int l = 0; l <= 3; l++) {
- if (rndVal != 1) {
- if ((_gameBoardSide[rndVal]._delayCard._cardId == 0) && (_gameBoardSide[1]._handCard[j]._cardId == 1))
- count = rndVal;
- }
- if (count != -1) {
- playDelayCard(&_gameBoardSide[1]._handCard[j], &_gameBoardSide[count]._delayCard);
- return;
- } else {
- rndVal--;
- if (rndVal < 0)
- rndVal = 3;
- }
- }
- }
- }
-
- handlePlayer01Discard(1);
-}
-
-void Scene1337::handlePlayer3() {
- if (_gameBoardSide[3]._delayCard._cardId != 0) {
- switch (_gameBoardSide[3]._delayCard._cardId) {
- case 10:
- // No break on purpose
- case 12:
- // No break on purpose
- case 15:
- // No break on purpose
- case 17:
- // No break on purpose
- case 18:
- // No break on purpose
- case 19:
- // No break on purpose
- case 20:
- // No break on purpose
- case 21:
- discardCard(&_gameBoardSide[3]._delayCard);
- return;
- default:
- for (int i = 0; i <= 3; i++) {
- if (checkAntiDelayCard(_gameBoardSide[3]._delayCard._cardId, _gameBoardSide[3]._handCard[i]._cardId)) {
- playAntiDelayCard(&_gameBoardSide[3]._handCard[i], &_gameBoardSide[3]._delayCard);
- return;
- }
- }
- break;
- }
- }
-
- int randIndx = R2_GLOBALS._randomSource.getRandomNumber(3);
-
- if (_gameBoardSide[3]._handCard[randIndx]._cardId == 1) {
- for (int i = 0; i <= 7; i++) {
- if ((_gameBoardSide[3]._outpostStation[i]._cardId == 0) && !isStopConstructionCard(_gameBoardSide[3]._delayCard._cardId)) {
- playPlatformCard(&_gameBoardSide[3]._handCard[randIndx], &_gameBoardSide[3]._outpostStation[i]);
- return;
- }
- }
- } else if (_gameBoardSide[3]._handCard[randIndx]._cardId <= 9) {
- for (int i = 0; i <= 7; i++) {
- if (_gameBoardSide[3]._outpostStation[i]._cardId == _gameBoardSide[3]._handCard[randIndx]._cardId) {
- discardCard(&_gameBoardSide[3]._handCard[randIndx]);
- return;
- }
- }
-
- for (int i = 0; i <= 7; i++) {
- if ((_gameBoardSide[3]._outpostStation[i]._cardId == 1) && !isStopConstructionCard(_gameBoardSide[3]._delayCard._cardId)) {
- int stationCount = 0;
- for (int j = 0; j <= 7; j++) {
- if ((_gameBoardSide[3]._outpostStation[j]._cardId > 1) && (_gameBoardSide[3]._outpostStation[j]._cardId <= 9))
- ++stationCount;
- }
-
- if (stationCount == 7)
- _winnerId = 3;
-
- playStationCard(&_gameBoardSide[3]._handCard[randIndx], &_gameBoardSide[3]._outpostStation[i]);
- return;
- }
- }
- } else if (_gameBoardSide[3]._handCard[randIndx]._cardId == 13) {
- int victimId = getPlayerWithOutpost(3);
-
- if (victimId != -1) {
- playCounterTrickCard(&_gameBoardSide[3]._handCard[randIndx], victimId);
- return;
- }
- } else if (_gameBoardSide[3]._handCard[randIndx]._cardId == 25) {
- int victimId = -1;
- int tmpRandIndx = R2_GLOBALS._randomSource.getRandomNumber(3);
-
- for (int i = 0; i <= 3; i++) {
- if ( (tmpRandIndx != 3)
- && ( (_gameBoardSide[tmpRandIndx]._handCard[0]._cardId != 0)
- || (_gameBoardSide[tmpRandIndx]._handCard[1]._cardId != 0)
- || (_gameBoardSide[tmpRandIndx]._handCard[2]._cardId != 0)
- || (_gameBoardSide[tmpRandIndx]._handCard[3]._cardId != 0) )) {
- victimId = tmpRandIndx;
- break;
- }
-
- ++tmpRandIndx;
- if (tmpRandIndx > 3)
- tmpRandIndx = 0;
- }
-
- if (victimId != -1) {
- playThieftCard(3, &_gameBoardSide[3]._handCard[randIndx], victimId);
- return;
- }
- } else {
- switch (_gameBoardSide[3]._handCard[randIndx]._cardId) {
- case 10:
- // No break on purpose
- case 11:
- // No break on purpose
- case 12:
- // No break on purpose
- case 14:
- // No break on purpose
- case 15:
- // No break on purpose
- case 16:
- // No break on purpose
- case 17:
- // No break on purpose
- case 18:
- // No break on purpose
- case 19:
- // No break on purpose
- case 20:
- // No break on purpose
- case 21:
- // No break on purpose
- case 24: {
- int victimId = -1;
- int tmpRandIndx = R2_GLOBALS._randomSource.getRandomNumber(3);
-
- for (int i = 0; i <= 3; i++) {
- if (tmpRandIndx != 3) {
- if ((_gameBoardSide[tmpRandIndx]._delayCard._cardId == 0)
- && isAttackPossible(tmpRandIndx, _gameBoardSide[3]._handCard[randIndx]._cardId))
- victimId = tmpRandIndx;
- }
-
- ++tmpRandIndx;
- if (tmpRandIndx > 3)
- tmpRandIndx = 0;
-
- if (victimId != -1)
- break;
- }
-
- if (victimId != -1) {
- // Useless second identical check skipped
- playDelayCard(&_gameBoardSide[3]._handCard[randIndx], &_gameBoardSide[victimId]._delayCard);
- return;
- }
- }
- default:
- break;
- }
- }
-
- discardCard(&_gameBoardSide[3]._handCard[randIndx]);
-}
-
-void Scene1337::handleAutoplayPlayer2() {
- if (getStationCardId(this->_gameBoardSide[2]._delayCard._cardId) == -1)
- _delayedFunction = &Scene1337::handlePlayer2;
- else
- discardCard(&_gameBoardSide[2]._delayCard);
-}
-
-void Scene1337::handlePlayer2() {
- _selectedCard._stationPos = g_globals->_events._mousePos;
-
- if (R2_GLOBALS._v57810 == 200) {
- // Hand
- int i;
- for (i = 0; i < 4; i++) {
- if ((_gameBoardSide[2]._handCard[i].isIn(_selectedCard._stationPos)) && (_gameBoardSide[2]._handCard[i]._cardId != 0)) {
- Card *handcard = &_gameBoardSide[2]._handCard[i];
- _selectedCard._cardId = handcard->_cardId;
- _selectedCard._stationPos = handcard->_stationPos;
- //warning("_selectedCard._actorName = handcard->_actorName;");
- //warning("_selectedCard._fieldE = handcard->_fieldE;");
- //warning("_selectedCard._field10 = handcard->_field10;");
- //warning("_selectedCard._field12 = handcard->_field12;");
- //warning("_selectedCard._field14 = handcard->_field14;");
- //warning("_selectedCard._field16 = handcard->_field16;");
- _selectedCard._sceneRegionId = handcard->_sceneRegionId;
- _selectedCard._position = handcard->_position;
- _selectedCard._yDiff = handcard->_yDiff;
- _selectedCard._bounds = handcard->_bounds;
- _selectedCard._resNum = handcard->_resNum;
- _selectedCard._lookLineNum = handcard->_lookLineNum;
- _selectedCard._talkLineNum = handcard->_talkLineNum;
- _selectedCard._useLineNum = handcard->_useLineNum;
- _selectedCard._action = handcard->_action;
- //warning("_selectedCard._field0 = handcard->_field0;");
- _selectedCard._card._updateStartFrame = handcard->_card._updateStartFrame;
- _selectedCard._card._walkStartFrame = handcard->_card._walkStartFrame;
- // _field2E is named _field3C in R2R
- _selectedCard._card._oldPosition = handcard->_card._oldPosition;
- _selectedCard._card._percent = handcard->_card._percent;
- _selectedCard._card._priority = handcard->_card._priority;
- _selectedCard._card._angle = handcard->_card._angle;
- _selectedCard._card._flags = handcard->_card._flags;
- _selectedCard._card._xe = handcard->_card._xe;
- _selectedCard._card._xs = handcard->_card._xs;
- _selectedCard._card._paneRects[0] = handcard->_card._paneRects[0];
- _selectedCard._card._paneRects[1] = handcard->_card._paneRects[1];
- _selectedCard._card._visage = handcard->_card._visage;
- _selectedCard._card._objectWrapper = handcard->_card._objectWrapper;
- _selectedCard._card._strip = handcard->_card._strip;
- _selectedCard._card._animateMode = handcard->_card._animateMode;
- _selectedCard._card._frame = handcard->_card._frame;
- _selectedCard._card._endFrame = handcard->_card._endFrame;
- // _field68 is named _field76 in R2R
- _selectedCard._card._loopCount = handcard->_card._loopCount;
- _selectedCard._card._frameChange = handcard->_card._frameChange;
- _selectedCard._card._numFrames = handcard->_card._numFrames;
- _selectedCard._card._regionIndex = handcard->_card._regionIndex;
- _selectedCard._card._mover = handcard->_card._mover;
- _selectedCard._card._moveDiff = handcard->_card._moveDiff;
- _selectedCard._card._moveRate = handcard->_card._moveRate;
- _selectedCard._card._actorDestPos = handcard->_card._actorDestPos;
- _selectedCard._card._endAction = handcard->_card._endAction;
- _selectedCard._card._regionBitList = handcard->_card._regionBitList;
- // _selectedCard._object1._actorName = handcard->_object1._actorName;
- //warning("_selectedCard._card._fieldE = handcard->_card._fieldE;");
- //warning("_selectedCard._card._field10 = handcard->_card._field10;");
- //warning("_selectedCard._card._field12 = handcard->_card._field12;");
- //warning("_selectedCard._card._field14 = handcard->_card._field14;");
- //warning("_selectedCard._card._field16 = handcard->_card._field16;");
-
- _gameBoardSide[2]._handCard[i]._cardId = 0;
- _gameBoardSide[2]._handCard[i]._card.remove();
- break;
- }
- }
-
- if (i == 4) {
- handleClick(1, _selectedCard._stationPos);
- handleAutoplayPlayer2();
- return;
- } else {
- setCursorData(1332, _selectedCard._card._strip, _selectedCard._card._frame);
- R2_GLOBALS._sceneObjects->draw();
- }
- } else if (R2_GLOBALS._v57810 == 300) {
- // Eye
- handleClick(3, _selectedCard._stationPos);
- handleAutoplayPlayer2();
- return;
- } else {
- // The original code is calling a function full of dead code.
- // Only this message remains after a cleanup.
- MessageDialog::show(WRONG_ANSWER_MSG, OK_BTN_STRING);
- //
- handleAutoplayPlayer2();
- return;
- }
-
- Event event;
- bool found;
- for (;;) {
- if ( ((g_globals->_events.getEvent(event, EVENT_BUTTON_DOWN)) && (event.btnState == BTNSHIFT_RIGHT))
- || (g_globals->_events.getEvent(event, EVENT_KEYPRESS)) ){
- _selectedCard._stationPos = g_globals->_events._mousePos;
- found = false;
-
- for (int i = 0; i <= 3; i ++) {
- if (_gameBoardSide[2]._handCard[i].isIn(Common::Point(_selectedCard._stationPos.x + 12, _selectedCard._stationPos.y + 12))) {
- if (_gameBoardSide[2]._handCard[i]._cardId == 0) {
- _gameBoardSide[2]._handCard[i]._cardId = _selectedCard._cardId;
- _gameBoardSide[2]._handCard[i]._card.postInit();
- _gameBoardSide[2]._handCard[i]._card.hide();
- _gameBoardSide[2]._handCard[i]._card.setVisage(1332);
- _gameBoardSide[2]._handCard[i]._card.setPosition(_gameBoardSide[2]._handCard[i]._stationPos, 0);
- _gameBoardSide[2]._handCard[i]._card.fixPriority(170);
- setAnimationInfo(&_gameBoardSide[2]._handCard[i]);
- setCursorData(5, 1, 4);
- _currentPlayerNumb--;
- _showPlayerTurn = false;
- handleNextTurn();
- return;
- } else {
- actionDisplay(1330, 127, 159, 10, 1, 200, 0, 7, 0, 154, 154);
- found = true;
- }
- break;
- }
- }
-
- if (!found) {
- if (_discardPile.isIn(Common::Point(_selectedCard._stationPos.x + 12, _selectedCard._stationPos.y + 12))) {
- discardCard(&_selectedCard);
- return;
- } else if (_selectedCard._cardId == 1) {
- bool isInCardFl = false;
- int i;
- for (i = 0; i <= 7; i++) {
- if (_gameBoardSide[2]._outpostStation[i].isIn(Common::Point(_selectedCard._stationPos.x + 12, _selectedCard._stationPos.y + 12))) {
- isInCardFl = true;
- break;
- }
- }
-
- if ((isInCardFl) && (_gameBoardSide[2]._outpostStation[i]._cardId == 0)) {
- if (isDelayCard(_gameBoardSide[2]._delayCard._cardId) != -1) {
- actionDisplay(1330, 55, 159, 10, 1, 200, 0, 7, 0, 154, 154);
- } else {
- playPlatformCard(&_selectedCard, &_gameBoardSide[2]._outpostStation[i]);
- return;
- }
- } else {
- actionDisplay(1330, 56, 159, 10, 1, 200, 0, 7, 0, 154, 154);
- }
- } else if (_selectedCard._cardId <= 9) {
- bool isInCardFl = false;
- int i;
- for (i = 0; i <= 7; i++) {
- if (_gameBoardSide[2]._outpostStation[i].isIn(Common::Point(_selectedCard._stationPos.x + 12, _selectedCard._stationPos.y + 12))) {
- isInCardFl = true;
- break;
- }
- }
- if ((isInCardFl) && (_gameBoardSide[2]._outpostStation[i]._cardId == 1)) {
- isInCardFl = false;
- for (int j = 0; j <= 7; j++) {
- if (_selectedCard._cardId == _gameBoardSide[2]._outpostStation[j]._cardId) {
- isInCardFl = true;
- break;
- }
- }
- if (isInCardFl) {
- // This station is already in place
- actionDisplay(1330, 34, 159, 10, 1, 200, 0, 7, 0, 154, 154);
- } else if (isDelayCard(_gameBoardSide[2]._delayCard._cardId) != -1) {
- // You must eliminate your delay before you can play a station
- actionDisplay(1330, 35, 159, 10, 1, 200, 0, 7, 0, 154, 154);
- } else {
- int stationCount = 0;
- for (int k = 0; k <= 7; k++) {
- if ((_gameBoardSide[2]._outpostStation[k]._cardId > 1) && (_gameBoardSide[2]._outpostStation[k]._cardId <= 9))
- ++stationCount;
- }
-
- if (stationCount == 7)
- _winnerId = 2;
-
- playStationCard(&_selectedCard, &_gameBoardSide[2]._outpostStation[i]);
- return;
- }
- } else {
- actionDisplay(1330, 37, 159, 10, 1, 200, 0, 7, 0, 154, 154);
- }
- } else if ((_selectedCard._cardId == 26) || (_selectedCard._cardId == 30) ||(_selectedCard._cardId == 32) || (_selectedCard._cardId == 28)) {
- // Check anti-delay card
- if (_gameBoardSide[2]._delayCard.isIn(Common::Point(_selectedCard._stationPos.x + 12, _selectedCard._stationPos.y + 12))) {
- actionDisplay(1330, 42, 159, 10, 1, 200, 0, 7, 0, 154, 154);
- } else if (checkAntiDelayCard(_gameBoardSide[2]._delayCard._cardId, _selectedCard._cardId)) {
- playAntiDelayCard(&_selectedCard, &_gameBoardSide[2]._delayCard);
- return;
- } else {
- if (_gameBoardSide[2]._delayCard._cardId != 0) {
- switch (_gameBoardSide[2]._delayCard._cardId) {
- case 11:
- actionDisplay(1330, 68, 159, 10, 1, 200, 0, 7, 0, 154, 154);
- break;
- case 14:
- actionDisplay(1330, 80, 159, 10, 1, 200, 0, 7, 0, 154, 154);
- break;
- case 16:
- actionDisplay(1330, 84, 159, 10, 1, 200, 0, 7, 0, 154, 154);
- break;
- case 24:
- actionDisplay(1330, 96, 159, 10, 1, 200, 0, 7, 0, 154, 154);
- break;
- default:
- break;
- }
- } else {
- actionDisplay(1330, 41, 159, 10, 1, 200, 0, 7, 0, 154, 154);
- }
- }
- } else if ((getStationCardId(_selectedCard._cardId) == -1) && (isDelayCard(_selectedCard._cardId) == -1)) {
- if (_selectedCard._cardId == 13) {
- if (_gameBoardSide[0]._emptyStationPos.isIn(Common::Point(_selectedCard._stationPos.x + 12, _selectedCard._stationPos.y + 12))) {
- for (int k = 0; k <= 7; k++) {
- if (_gameBoardSide[0]._outpostStation[k]._cardId != 0) {
- playCounterTrickCard(&_selectedCard, 0);
- return;
- }
- }
- actionDisplay(1330, 74, 159, 10, 1, 200, 0, 7, 0, 154, 154);
- } else if (_gameBoardSide[3]._emptyStationPos.isIn(Common::Point(_selectedCard._stationPos.x + 12, _selectedCard._stationPos.y + 12))) {
- for (int k = 0; k <= 7; k++) {
- if (_gameBoardSide[3]._outpostStation[k]._cardId != 0) {
- playCounterTrickCard(&_selectedCard, 3);
- return;
- }
- }
- actionDisplay(1330, 74, 159, 10, 1, 200, 0, 7, 0, 154, 154);
- } else if (_gameBoardSide[1]._emptyStationPos.isIn(Common::Point(_selectedCard._stationPos.x + 12, _selectedCard._stationPos.y + 12))) {
- for (int k = 0; k <= 7; k++) {
- if (_gameBoardSide[1]._outpostStation[k]._cardId == 0) {
- playCounterTrickCard(&_selectedCard, 1);
- return;
- }
- }
- actionDisplay(1330, 74, 159, 10, 1, 200, 0, 7, 0, 154, 154);
- } else {
- actionDisplay(1330, 128, 159, 10, 1, 200, 0, 7, 0, 154, 154);
- }
- } else if (_selectedCard._cardId == 25) {
- if (_gameBoardSide[0]._emptyStationPos.isIn(Common::Point(_selectedCard._stationPos.x + 12, _selectedCard._stationPos.y + 12))) {
- if ( (_gameBoardSide[0]._handCard[0]._cardId != 0)
- || (_gameBoardSide[0]._handCard[1]._cardId != 0)
- || (_gameBoardSide[0]._handCard[2]._cardId != 0)
- || (_gameBoardSide[0]._handCard[3]._cardId != 0) ) {
- int k;
- for (k = 0; k <= 3; k++){
- if (_gameBoardSide[2]._handCard[k]._cardId == 0)
- break;
- }
- playThieftCard(2, &_gameBoardSide[2]._handCard[k], 0);
- return;
- } else {
- actionDisplay(1330, 99, 159, 10, 1, 200, 0, 7, 0, 154, 154);
- }
- } else if (_gameBoardSide[1]._emptyStationPos.isIn(Common::Point(_selectedCard._stationPos.x + 12, _selectedCard._stationPos.y + 12))) {
- if ( (_gameBoardSide[1]._handCard[0]._cardId != 0)
- || (_gameBoardSide[1]._handCard[1]._cardId != 0)
- || (_gameBoardSide[1]._handCard[2]._cardId != 0)
- || (_gameBoardSide[1]._handCard[3]._cardId != 0) ) {
- int k;
- for (k = 0; k <= 3; k++){
- if (_gameBoardSide[2]._handCard[k]._cardId == 0)
- break;
- }
- playThieftCard(2, &_gameBoardSide[2]._handCard[k], 1);
- return;
- } else {
- actionDisplay(1330, 99, 159, 10, 1, 200, 0, 7, 0, 154, 154);
- }
- }
-
- if (_gameBoardSide[3]._emptyStationPos.isIn(Common::Point(_selectedCard._stationPos.x + 12, _selectedCard._stationPos.y + 12))) {
- if ( (_gameBoardSide[3]._handCard[0]._cardId != 0)
- || (_gameBoardSide[3]._handCard[1]._cardId != 0)
- || (_gameBoardSide[3]._handCard[2]._cardId != 0)
- || (_gameBoardSide[3]._handCard[3]._cardId != 0) ) {
- int k;
- for (k = 0; k <= 3; k++){
- if (_gameBoardSide[2]._handCard[k]._cardId == 0)
- break;
- }
- playThieftCard(2, &_gameBoardSide[2]._handCard[k], 3);
- return;
- } else {
- actionDisplay(1330, 99, 159, 10, 1, 200, 0, 7, 0, 154, 154);
- }
- } else {
- actionDisplay(1330, 129, 159, 10, 1, 200, 0, 7, 0, 154, 154);
- }
- } else if (_selectedCard._cardId == 29) {
- // Interceptor cards are used to prevent collision
- actionDisplay(1330, 136, 159, 10, 1, 200, 0, 7, 0, 154, 154);
- } else if (_selectedCard._cardId == 27) {
- actionDisplay(1330, 137, 159, 10, 1, 200, 0, 7, 0, 154, 154);
- }
- } else if (_gameBoardSide[0]._delayCard.isIn(Common::Point(_selectedCard._stationPos.x + 12, _selectedCard._stationPos.y + 12))) {
- if (_gameBoardSide[0]._delayCard._cardId != 0) {
- actionDisplay(1330, 15, 159, 10, 1, 200, 0, 7, 0, 154, 154);
- } else if (!isAttackPossible(0, _selectedCard._cardId)) {
- switch (_selectedCard._cardId) {
- case 10:
- actionDisplay(1330, 66, 159, 10, 1, 200, 0, 7, 0, 154, 154);
- break;
- case 12:
- actionDisplay(1330, 70, 159, 10, 1, 200, 0, 7, 0, 154, 154);
- break;
- case 15:
- actionDisplay(1330, 82, 159, 10, 1, 200, 0, 7, 0, 154, 154);
- break;
- case 17:
- actionDisplay(1330, 86, 159, 10, 1, 200, 0, 7, 0, 154, 154);
- break;
- case 18:
- actionDisplay(1330, 88, 159, 10, 1, 200, 0, 7, 0, 154, 154);
- break;
- case 19:
- actionDisplay(1330, 90, 159, 10, 1, 200, 0, 7, 0, 154, 154);
- break;
- case 20:
- actionDisplay(1330, 92, 159, 10, 1, 200, 0, 7, 0, 154, 154);
- break;
- case 21:
- actionDisplay(1330, 94, 159, 10, 1, 200, 0, 7, 0, 154, 154);
- break;
- default:
- break;
- }
- } else {
- playDelayCard(&_selectedCard, &_gameBoardSide[0]._delayCard);
- return;
- }
- } else if (_gameBoardSide[3]._delayCard.isIn(Common::Point(_selectedCard._stationPos.x + 12, _selectedCard._stationPos.y + 12))) {
- if (_gameBoardSide[3]._delayCard._cardId != 0) {
- actionDisplay(1330, 17, 159, 10, 1, 200, 0, 7, 0, 154, 154);
- } else if (!isAttackPossible(3, _selectedCard._cardId)) {
- switch (_selectedCard._cardId) {
- case 10:
- actionDisplay(1330, 66, 159, 10, 1, 200, 0, 7, 0, 154, 154);
- break;
- case 12:
- actionDisplay(1330, 70, 159, 10, 1, 200, 0, 7, 0, 154, 154);
- break;
- case 15:
- actionDisplay(1330, 82, 159, 10, 1, 200, 0, 7, 0, 154, 154);
- break;
- case 17:
- actionDisplay(1330, 86, 159, 10, 1, 200, 0, 7, 0, 154, 154);
- break;
- case 18:
- actionDisplay(1330, 88, 159, 10, 1, 200, 0, 7, 0, 154, 154);
- break;
- case 19:
- actionDisplay(1330, 90, 159, 10, 1, 200, 0, 7, 0, 154, 154);
- break;
- case 20:
- actionDisplay(1330, 92, 159, 10, 1, 200, 0, 7, 0, 154, 154);
- break;
- case 21:
- actionDisplay(1330, 94, 159, 10, 1, 200, 0, 7, 0, 154, 154);
- break;
- default:
- break;
- }
- } else {
- playDelayCard(&_selectedCard, &_gameBoardSide[3]._delayCard);
- return;
- }
- } else if (_gameBoardSide[1]._delayCard.isIn(Common::Point(_selectedCard._stationPos.x + 12, _selectedCard._stationPos.y + 12))) {
- if (_gameBoardSide[1]._delayCard._cardId != 0) {
- actionDisplay(1330, 19, 159, 10, 1, 200, 0, 7, 0, 154, 154);
- } else if (!isAttackPossible(1, _selectedCard._cardId)) {
- switch (_selectedCard._cardId) {
- case 10:
- actionDisplay(1330, 66, 159, 10, 1, 200, 0, 7, 0, 154, 154);
- break;
- case 12:
- actionDisplay(1330, 70, 159, 10, 1, 200, 0, 7, 0, 154, 154);
- break;
- case 15:
- actionDisplay(1330, 82, 159, 10, 1, 200, 0, 7, 0, 154, 154);
- break;
- case 17:
- actionDisplay(1330, 86, 159, 10, 1, 200, 0, 7, 0, 154, 154);
- break;
- case 18:
- actionDisplay(1330, 88, 159, 10, 1, 200, 0, 7, 0, 154, 154);
- break;
- case 19:
- actionDisplay(1330, 90, 159, 10, 1, 200, 0, 7, 0, 154, 154);
- break;
- case 20:
- actionDisplay(1330, 92, 159, 10, 1, 200, 0, 7, 0, 154, 154);
- break;
- case 21:
- actionDisplay(1330, 94, 159, 10, 1, 200, 0, 7, 0, 154, 154);
- break;
- default:
- break;
- }
- } else {
- playDelayCard(&_selectedCard, &_gameBoardSide[1]._delayCard);
- return;
- }
- } else {
- actionDisplay(1330, 38, 159, 10, 1, 200, 0, 7, 0, 154, 154);
- }
- }
- } else {
- g_globals->_scenePalette.signalListeners();
- R2_GLOBALS._sceneObjects->draw();
- g_globals->_events.delay(g_globals->_sceneHandler->_delayTicks);
- }
-
- g_globals->_sceneObjects->recurse(SceneHandler::dispatchObject);
- }
-}
-
-void Scene1337::updateCursorId(int cursorId, bool updateFl) {
- if ((R2_GLOBALS._v57709 != 0) || (R2_GLOBALS._v5780C != 0))
- return;
-
- R2_GLOBALS._mouseCursorId = cursorId;
-
- if (updateFl) {
- R2_GLOBALS._mouseCursorId++;
-
- if (R2_GLOBALS._mouseCursorId < 1)
- R2_GLOBALS._mouseCursorId = 2;
-
- if (R2_GLOBALS._mouseCursorId > 2)
- R2_GLOBALS._mouseCursorId = 1;
- }
-
- // The original was using an intermediate function to call setCursorData.
- // It has been removed to improve readability
- if (R2_GLOBALS._mouseCursorId == 1) {
- R2_GLOBALS._v57810 = 200;
- setCursorData(5, 1, 4);
- } else if (R2_GLOBALS._mouseCursorId == 2) {
- R2_GLOBALS._v57810 = 300;
- setCursorData(5, 1, 5);
- } else {
- R2_GLOBALS._v57810 = 0;
- setCursorData(5, 0, 0);
- }
-}
-
-void Scene1337::setCursorData(int resNum, int rlbNum, int frameNum) {
- _cursorCurRes = resNum;
- _cursorCurStrip = rlbNum;
- _cursorCurFrame = frameNum;
-
- if (!frameNum) {
- // Should be a hardcoded cursor displaying only a dot.
- // FIXME: Use another cursor when possible
- R2_GLOBALS._events.setCursor(CURSOR_CROSSHAIRS);
- } else {
- // TODO: The original was using some ressource caching, which was useless and complex
- // and which has been removed. This cursor behavior clearly made intensive use of this caching...
- // We now have to find a way to cache these cursor pointers and avoid loading them multiple times per seconds
- uint size;
- byte *cursor = g_resourceManager->getSubResource(resNum, rlbNum, frameNum, &size);
- // Decode the cursor
- GfxSurface s = surfaceFromRes(cursor);
-
- Graphics::Surface surface = s.lockSurface();
- const byte *cursorData = (const byte *)surface.getPixels();
- CursorMan.replaceCursor(cursorData, surface.w, surface.h, s._centroid.x, s._centroid.y, s._transColor);
- s.unlockSurface();
-
- DEALLOCATE(cursor);
- }
-}
-
-void Scene1337::subD18F5() {
- if (R2_GLOBALS._v57709 == 0)
- R2_GLOBALS._events.setCursor(CURSOR_CROSSHAIRS);
-
- ++R2_GLOBALS._v57709;
-}
-
-void Scene1337::subD1917() {
- if (R2_GLOBALS._v57709 != 0) {
- R2_GLOBALS._v57709--;
- if (R2_GLOBALS._v57709 != 0) {
- // The original was using an intermediate function to call setCursorData.
- // It has been removed to improve readability
- setCursorData(5, _cursorCurStrip, _cursorCurFrame);
- }
- }
-}
-
-void Scene1337::subD1940(bool flag) {
- if (flag)
- ++R2_GLOBALS._v5780C;
- else if (R2_GLOBALS._v5780C != 0)
- --R2_GLOBALS._v5780C;
-}
-
-void Scene1337::subD1975(int arg1, int arg2) {
- warning("STUBBED lvl2 Scene1337::subD1975()");
-}
-
-void Scene1337::OptionsDialog::show() {
- OptionsDialog *dlg = new OptionsDialog();
- dlg->draw();
-
- // Show the dialog
- GfxButton *btn = dlg->execute(NULL);
-
- // Figure out the new selected character
- if (btn == &dlg->_quitGame)
- R2_GLOBALS._sceneManager.changeScene(125);
- else if (btn == &dlg->_restartGame)
- R2_GLOBALS._sceneManager.changeScene(1330);
-
- // Remove the dialog
- dlg->remove();
- delete dlg;
-}
-
-Scene1337::OptionsDialog::OptionsDialog() {
- // Set the elements text
- Scene1337 *scene = (Scene1337 *)R2_GLOBALS._sceneManager._scene;
- _autoplay.setText(scene->_autoplay ? AUTO_PLAY_ON : AUTO_PLAY_OFF);
- _restartGame.setText(START_NEW_CARD_GAME);
- _quitGame.setText(QUIT_CARD_GAME);
- _continueGame.setText(CONTINUE_CARD_GAME);
-
- // Set position of the elements
- _autoplay._bounds.moveTo(5, 2);
- _restartGame._bounds.moveTo(5, _autoplay._bounds.bottom + 2);
- _quitGame._bounds.moveTo(5, _restartGame._bounds.bottom + 2);
- _continueGame._bounds.moveTo(5, _quitGame._bounds.bottom + 2);
-
- // Add the items to the dialog
- addElements(&_autoplay, &_restartGame, &_quitGame, &_continueGame, NULL);
-
- // Set the dialog size and position
- frame();
- _bounds.collapse(-6, -6);
- setCenter(160, 100);
-}
-
-GfxButton *Scene1337::OptionsDialog::execute(GfxButton *defaultButton) {
- _gfxManager.activate();
-
- // Event loop
- GfxButton *selectedButton = NULL;
-
- bool breakFlag = false;
- while (!g_vm->shouldQuit() && !breakFlag) {
- Event event;
- while (g_globals->_events.getEvent(event) && !breakFlag) {
- // Adjust mouse positions to be relative within the dialog
- event.mousePos.x -= _gfxManager._bounds.left;
- event.mousePos.y -= _gfxManager._bounds.top;
-
- for (GfxElementList::iterator i = _elements.begin(); i != _elements.end(); ++i) {
- if ((*i)->process(event))
- selectedButton = static_cast<GfxButton *>(*i);
- }
-
- if (selectedButton == &_autoplay) {
- // Toggle Autoplay
- selectedButton = NULL;
- Scene1337 *scene = (Scene1337 *)R2_GLOBALS._sceneManager._scene;
- scene->_autoplay = !scene->_autoplay;
-
- _autoplay.setText(scene->_autoplay ? AUTO_PLAY_ON : AUTO_PLAY_OFF);
- _autoplay.draw();
- } else if (selectedButton) {
- breakFlag = true;
- break;
- } else if (!event.handled) {
- if ((event.eventType == EVENT_KEYPRESS) && (event.kbd.keycode == Common::KEYCODE_ESCAPE)) {
- selectedButton = NULL;
- breakFlag = true;
- break;
- }
- }
- }
-
- g_system->delayMillis(10);
- GLOBALS._screenSurface.updateScreen();
- }
-
- _gfxManager.deactivate();
- return selectedButton;
-}
-
-/*--------------------------------------------------------------------------
* Scene 1500 - Cutscene: Ship landing
*
*--------------------------------------------------------------------------*/
@@ -13433,1796 +7970,5 @@ void Scene1945::signal() {
R2_GLOBALS._player._canWalk = false;
}
-/*--------------------------------------------------------------------------
- * Scene 1950 - Flup Tube Corridor Maze
- *
- *--------------------------------------------------------------------------*/
-
-Scene1950::KeypadWindow::KeypadWindow() {
- _buttonIndex = 0;
-}
-
-void Scene1950::KeypadWindow::synchronize(Serializer &s) {
- SceneArea::synchronize(s);
-
- s.syncAsSint16LE(_buttonIndex);
-}
-
-Scene1950::KeypadWindow::KeypadButton::KeypadButton() {
- _buttonIndex = 0;
- _pressed = false;
- _toggled = false;
-}
-
-void Scene1950::KeypadWindow::KeypadButton::synchronize(Serializer &s) {
- SceneActor::synchronize(s);
-
- s.syncAsSint16LE(_buttonIndex);
- s.syncAsSint16LE(_pressed);
- s.syncAsSint16LE(_toggled);
-}
-
-void Scene1950::KeypadWindow::KeypadButton::init(int indx) {
- Scene1950 *scene = (Scene1950 *)R2_GLOBALS._sceneManager._scene;
-
- _buttonIndex = indx;
- _pressed = false;
- _toggled = false;
-
- postInit();
- setup(1971, 2, 1);
- fixPriority(249);
- setPosition(Common::Point(((_buttonIndex % 4) * 22) + 127, ((_buttonIndex / 4) * 19) + 71));
- scene->_sceneAreas.push_front(this);
-}
-
-void Scene1950::KeypadWindow::KeypadButton::process(Event &event) {
- if ((event.eventType == EVENT_BUTTON_DOWN) && (R2_GLOBALS._events.getCursor() == CURSOR_USE)
- && (_bounds.contains(event.mousePos)) && !_pressed) {
- R2_GLOBALS._sound2.play(227);
- if (!_toggled) {
- setFrame(2);
- _toggled = true;
- } else {
- setFrame(1);
- _toggled = false;
- }
- _pressed = true;
- event.handled = true;
- }
-
- if ((event.eventType == EVENT_BUTTON_UP) && _pressed) {
- _pressed = false;
- event.handled = true;
- Scene1950 *scene = (Scene1950 *)R2_GLOBALS._sceneManager._scene;
- scene->doButtonPress(_buttonIndex);
- }
-}
-
-bool Scene1950::KeypadWindow::KeypadButton::startAction(CursorType action, Event &event) {
- if (action == CURSOR_USE)
- return false;
- return SceneActor::startAction(action, event);
-}
-
-void Scene1950::KeypadWindow::remove() {
- Scene1950 *scene = (Scene1950 *)R2_GLOBALS._sceneManager._scene;
- for (_buttonIndex = 0; _buttonIndex < 16; ++_buttonIndex) {
- scene->_sceneAreas.remove(&_buttons[_buttonIndex]);
- _buttons[_buttonIndex].remove();
- }
-
- ModalWindow::remove();
-
- if (!R2_GLOBALS.getFlag(37))
- R2_GLOBALS._sound2.play(278);
-
- R2_GLOBALS._player.disableControl(CURSOR_WALK);
- scene->_eastExit._enabled = true;
-
- if (!R2_GLOBALS.getFlag(37)) {
- if (R2_GLOBALS.getFlag(36)) {
- scene->_sceneMode = 1964;
- scene->setAction(&scene->_sequenceManager, scene, 1964, &R2_GLOBALS._player, NULL);
- } else {
- scene->_sceneMode = 1965;
- scene->setAction(&scene->_sequenceManager, scene, 1965, &R2_GLOBALS._player, NULL);
- }
- }
-}
-
-void Scene1950::KeypadWindow::setup2(int visage, int stripFrameNum, int frameNum, int posX, int posY) {
- Scene1950 *scene = (Scene1950 *)R2_GLOBALS._sceneManager._scene;
-
- if (R2_GLOBALS._player._mover)
- R2_GLOBALS._player.addMover(NULL);
- R2_GLOBALS._player._canWalk = false;
-
- ModalWindow::setup2(visage, stripFrameNum, frameNum, posX, posY);
-
- _object1.fixPriority(248);
- scene->_eastExit._enabled = false;
- setup3(1950, 27, 28, 27);
-
- for (_buttonIndex = 0; _buttonIndex < 16; _buttonIndex++)
- _buttons[_buttonIndex].init(_buttonIndex);
-}
-
-void Scene1950::KeypadWindow::setup3(int resNum, int lookLineNum, int talkLineNum, int useLineNum) {
- // Copy of Scene1200::LaserPanel::proc13()
- _areaActor.setDetails(resNum, lookLineNum, talkLineNum, useLineNum, 2, (SceneItem *) NULL);
-}
-
-/*--------------------------------------------------------------------------*/
-
-bool Scene1950::Keypad::startAction(CursorType action, Event &event) {
- if ((action != CURSOR_USE) || (R2_GLOBALS.getFlag(37)))
- return SceneHotspot::startAction(action, event);
-
- Scene1950 *scene = (Scene1950 *)R2_GLOBALS._sceneManager._scene;
-
- R2_GLOBALS._player.disableControl();
- if (R2_GLOBALS.getFlag(36)) {
- scene->_sceneMode = 1962;
- scene->setAction(&scene->_sequenceManager, scene, 1962, &R2_GLOBALS._player, NULL);
- } else {
- scene->_sceneMode = 1963;
- scene->setAction(&scene->_sequenceManager, scene, 1963, &R2_GLOBALS._player, NULL);
- }
- return true;
-}
-
-bool Scene1950::Door::startAction(CursorType action, Event &event) {
- if (action != R2_SCRITH_KEY)
- return SceneActor::startAction(action, event);
-
- Scene1950 *scene = (Scene1950 *)R2_GLOBALS._sceneManager._scene;
-
- R2_GLOBALS._player.disableControl();
- R2_INVENTORY.setObjectScene(R2_SCRITH_KEY, 0);
- scene->_sceneMode = 1958;
- scene->setAction(&scene->_sequenceManager, scene, 1958, &R2_GLOBALS._player, &scene->_door, NULL);
- return true;
-}
-
-bool Scene1950::Scrolls::startAction(CursorType action, Event &event) {
- if ((action != CURSOR_USE) || (R2_INVENTORY.getObjectScene(R2_ANCIENT_SCROLLS) != 1950))
- return SceneActor::startAction(action, event);
-
- Scene1950 *scene = (Scene1950 *)R2_GLOBALS._sceneManager._scene;
-
- R2_GLOBALS._player.disableControl();
- scene->_sceneMode = 1968;
- scene->setAction(&scene->_sequenceManager, scene, 1968, &R2_GLOBALS._player, NULL);
-
- return true;
-}
-
-bool Scene1950::Gem::startAction(CursorType action, Event &event) {
- if ((action != CURSOR_USE) || (!R2_GLOBALS.getFlag(37)))
- return SceneActor::startAction(action, event);
-
- Scene1950 *scene = (Scene1950 *)R2_GLOBALS._sceneManager._scene;
-
- R2_GLOBALS._player.disableControl();
- scene->_sceneMode = 1967;
- scene->setAction(&scene->_sequenceManager, scene, 1967, &R2_GLOBALS._player, NULL);
-
- return true;
-}
-
-/*--------------------------------------------------------------------------*/
-
-Scene1950::Vampire::Vampire() {
- _deadPosition = Common::Point(0, 0);
- _deltaX = 0;
- _deltaY = 0;
- _vampireMode = 0;
-}
-
-void Scene1950::Vampire::synchronize(Serializer &s) {
- SceneActor::synchronize(s);
-
- s.syncAsSint16LE(_deadPosition.x);
- s.syncAsSint16LE(_deadPosition.y);
- s.syncAsSint16LE(_deltaX);
- s.syncAsSint16LE(_deltaY);
- s.syncAsSint16LE(_vampireMode);
-}
-
-void Scene1950::Vampire::signal() {
- Scene1950 *scene = (Scene1950 *)R2_GLOBALS._sceneManager._scene;
-
- switch (_vampireMode) {
- case 19: {
- _vampireMode = 0;
- setVisage(1960);
- if (R2_GLOBALS._flubMazeEntryDirection == 3)
- setStrip(2);
- else
- setStrip(1);
-
- NpcMover *mover = new NpcMover();
- addMover(mover, &scene->_vampireDestPos, scene);
- }
- break;
- case 20: {
- // Non fatal shot
- _vampireMode = 19;
- R2_GLOBALS._player.setVisage(22);
- if (R2_GLOBALS._flubMazeEntryDirection == 3)
- R2_GLOBALS._player.setStrip(1);
- else
- R2_GLOBALS._player.setStrip(2);
- R2_GLOBALS._player.animate(ANIM_MODE_1, NULL);
- R2_GLOBALS._vampireData[scene->_vampireIndex - 1]._shotsRequired--;
-
- if (R2_GLOBALS._flubMazeEntryDirection == 3)
- _deadPosition.x = _position.x + 10;
- else
- _deadPosition.x = _position.x - 10;
- _deadPosition.y = _position.y - 4;
-
- setVisage(1961);
-
- if (R2_GLOBALS._flubMazeEntryDirection == 3)
- setStrip(2);
- else
- setStrip(1);
-
- animate(ANIM_MODE_2, NULL);
- Common::Point pt = _deadPosition;
- PlayerMover *mover = new PlayerMover();
- addMover(mover, &pt, this);
-
- R2_GLOBALS._player.enableControl();
- }
- break;
- case 21: {
- // Fatal shot
- R2_GLOBALS._player.setVisage(22);
- if (R2_GLOBALS._flubMazeEntryDirection == 3)
- R2_GLOBALS._player.setStrip(1);
- else
- R2_GLOBALS._player.setStrip(2);
- R2_GLOBALS._player.animate(ANIM_MODE_1, NULL);
-
- setVisage(1961);
- if (R2_GLOBALS._flubMazeEntryDirection == 3)
- setStrip(4);
- else
- setStrip(3);
- setDetails(1950, 15, -1, 17, 2, (SceneItem *) NULL);
- addMover(NULL);
- _numFrames = 8;
- R2_GLOBALS._sound2.play(226);
- animate(ANIM_MODE_5, NULL);
- fixPriority(10);
-
- R2_GLOBALS._vampireData[scene->_vampireIndex - 1]._isAlive = false;
- R2_GLOBALS._vampireData[scene->_vampireIndex - 1]._shotsRequired--;
- R2_GLOBALS._vampireData[scene->_vampireIndex - 1]._position = _position;
- _deltaX = (_position.x - R2_GLOBALS._player._position.x) / 2;
- _deltaY = (_position.y - R2_GLOBALS._player._position.y) / 2;
-
- byte vampireCount = 0;
- for (byte i = 0; i < 18; ++i) {
- if (!R2_GLOBALS._vampireData[i]._isAlive)
- ++vampireCount;
- }
-
- if (vampireCount == 18) {
- R2_GLOBALS.setFlag(36);
- _vampireMode = 23;
- Common::Point pt(R2_GLOBALS._player._position.x + _deltaX, R2_GLOBALS._player._position.y + _deltaY);
- NpcMover *mover = new NpcMover();
- R2_GLOBALS._player.addMover(mover, &pt, this);
- } else if (vampireCount == 1) {
- _vampireMode = 22;
- Common::Point pt(R2_GLOBALS._player._position.x + _deltaX, R2_GLOBALS._player._position.y + _deltaY);
- NpcMover *mover = new NpcMover();
- R2_GLOBALS._player.addMover(mover, &pt, this);
- } else {
- R2_GLOBALS._player.enableControl(CURSOR_WALK);
- }
-
- if (R2_GLOBALS._flubMazeEntryDirection == 3)
- scene->_eastExit._enabled = true;
- else
- scene->_westExit._enabled = true;
-
- scene->_vampireActive = false;
- }
- break;
- case 22:
- SceneItem::display(1950, 18, 0, 280, 1, 160, 9, 1, 2, 20, 7, 7, LIST_END);
- R2_GLOBALS._player.enableControl(CURSOR_WALK);
- break;
- case 23:
- SceneItem::display(1950, 25, 0, 280, 1, 160, 9, 1, 2, 20, 7, 7, LIST_END);
- scene->_sceneMode = R2_GLOBALS._flubMazeEntryDirection;
- scene->setAction(&scene->_sequenceManager, scene, 1960, &R2_GLOBALS._player, NULL);
- break;
- default:
- break;
- }
-}
-
-bool Scene1950::Vampire::startAction(CursorType action, Event &event) {
- Scene1950 *scene = (Scene1950 *)R2_GLOBALS._sceneManager._scene;
-
- if (!R2_GLOBALS._vampireData[scene->_vampireIndex - 1]._isAlive ||
- (action != R2_PHOTON_STUNNER))
- return SceneActor::startAction(action, event);
-
- R2_GLOBALS._player.disableControl();
-
- if (R2_GLOBALS._vampireData[scene->_vampireIndex - 1]._shotsRequired <= 1)
- _vampireMode = 21;
- else
- _vampireMode = 20;
-
- R2_GLOBALS._player.setVisage(25);
- if (R2_GLOBALS._flubMazeEntryDirection == 3)
- R2_GLOBALS._player.setStrip(2);
- else
- R2_GLOBALS._player.setStrip(1);
- R2_GLOBALS._player.animate(ANIM_MODE_5, this);
- R2_GLOBALS._sound3.play(99);
-
- return true;
-}
-
-/*--------------------------------------------------------------------------*/
-
-void Scene1950::NorthExit::changeScene() {
- Scene1950 *scene = (Scene1950 *)R2_GLOBALS._sceneManager._scene;
-
- _enabled = false;
- R2_GLOBALS._player.disableControl(CURSOR_WALK);
- R2_GLOBALS._flubMazeEntryDirection = 1;
- scene->_sceneMode = 11;
-
- Common::Point pt(160, 127);
- PlayerMover *mover = new PlayerMover();
- R2_GLOBALS._player.addMover(mover, &pt, scene);
-}
-
-void Scene1950::UpExit::changeScene() {
- Scene1950 *scene = (Scene1950 *)R2_GLOBALS._sceneManager._scene;
-
- _enabled = false;
- R2_GLOBALS._player.disableControl(CURSOR_WALK);
- R2_GLOBALS._flubMazeEntryDirection = 2;
- scene->_sceneMode = 12;
-
- if (!scene->_upExitStyle) {
- if (R2_GLOBALS.getFlag(36))
- scene->setAction(&scene->_sequenceManager, scene, 1953, &R2_GLOBALS._player, NULL);
- else
- scene->setAction(&scene->_sequenceManager, scene, 1970, &R2_GLOBALS._player, NULL);
- } else {
- if (R2_GLOBALS.getFlag(36))
- scene->setAction(&scene->_sequenceManager, scene, 1952, &R2_GLOBALS._player, NULL);
- else
- scene->setAction(&scene->_sequenceManager, scene, 1969, &R2_GLOBALS._player, NULL);
- }
-}
-
-void Scene1950::EastExit::changeScene() {
- Scene1950 *scene = (Scene1950 *)R2_GLOBALS._sceneManager._scene;
-
- _enabled = false;
- R2_GLOBALS._player.disableControl(CURSOR_WALK);
- R2_GLOBALS._flubMazeEntryDirection = 3;
- scene->_sceneMode = 13;
-
- if (scene->_vampireActive)
- R2_GLOBALS._player.animate(ANIM_MODE_9);
-
- Common::Point pt(340, 160);
- NpcMover *mover = new NpcMover();
- R2_GLOBALS._player.addMover(mover, &pt, scene);
-}
-
-void Scene1950::DownExit::changeScene() {
- Scene1950 *scene = (Scene1950 *)R2_GLOBALS._sceneManager._scene;
-
- _enabled = false;
- R2_GLOBALS._player.disableControl(CURSOR_WALK);
- R2_GLOBALS._flubMazeEntryDirection = 4;
- scene->_sceneMode = 14;
-
- if (R2_GLOBALS.getFlag(36))
- scene->setAction(&scene->_sequenceManager, scene, 1956, &R2_GLOBALS._player, NULL);
- else
- scene->setAction(&scene->_sequenceManager, scene, 1973, &R2_GLOBALS._player, NULL);
-}
-
-void Scene1950::SouthExit::changeScene() {
- Scene1950 *scene = (Scene1950 *)R2_GLOBALS._sceneManager._scene;
-
- _enabled = false;
- R2_GLOBALS._player.disableControl(CURSOR_WALK);
- R2_GLOBALS._flubMazeEntryDirection = 5;
- scene->_sceneMode = 15;
-
- Common::Point pt(160, 213);
- NpcMover *mover = new NpcMover();
- R2_GLOBALS._player.addMover(mover, &pt, scene);
-}
-
-void Scene1950::WestExit::changeScene() {
- Scene1950 *scene = (Scene1950 *)R2_GLOBALS._sceneManager._scene;
-
- _enabled = false;
- R2_GLOBALS._player.disableControl(CURSOR_WALK);
- R2_GLOBALS._flubMazeEntryDirection = 6;
-
- if (R2_GLOBALS._flubMazeArea == 2) {
- // In the very first corridor area after the Scrith Door
- if ((R2_GLOBALS.getFlag(36)) && (R2_INVENTORY.getObjectScene(R2_SAPPHIRE_BLUE) == 2) && (R2_INVENTORY.getObjectScene(R2_ANCIENT_SCROLLS) == 2)) {
- scene->_sceneMode = 1961;
- Common::Point pt(-20, 160);
- NpcMover *mover = new NpcMover();
- R2_GLOBALS._player.addMover(mover, &pt, scene);
- } else {
- if (!R2_GLOBALS.getFlag(36))
- SceneItem::display(1950, 33, 0, 280, 1, 160, 9, 1, 2, 20, 7, 7, LIST_END);
- if ((R2_INVENTORY.getObjectScene(R2_SAPPHIRE_BLUE) == 1950) || (R2_INVENTORY.getObjectScene(R2_ANCIENT_SCROLLS) == 1950))
- SceneItem::display(1950, 34, 0, 280, 1, 160, 9, 1, 2, 20, 7, 7, LIST_END);
- scene->_sceneMode = 0;
- Common::Point pt(30, 160);
- NpcMover *mover = new NpcMover();
- R2_GLOBALS._player.addMover(mover, &pt, scene);
- }
- } else {
- if (scene->_vampireActive)
- R2_GLOBALS._player.animate(ANIM_MODE_9);
-
- scene->_sceneMode = 16;
- Common::Point pt(-20, 160);
- NpcMover *mover = new NpcMover();
- R2_GLOBALS._player.addMover(mover, &pt, scene);
- }
-}
-
-void Scene1950::ShaftExit::changeScene() {
- Scene1950 *scene = (Scene1950 *)R2_GLOBALS._sceneManager._scene;
-
- _enabled = false;
- R2_GLOBALS._player.disableControl(CURSOR_WALK);
- R2_GLOBALS._flubMazeEntryDirection = 0;
- scene->_sceneMode = 1951;
- scene->setAction(&scene->_sequenceManager, scene, 1951, &R2_GLOBALS._player, NULL);
-}
-
-void Scene1950::DoorExit::changeScene() {
- Scene1950 *scene = (Scene1950 *)R2_GLOBALS._sceneManager._scene;
-
- _enabled = false;
- R2_GLOBALS._player.disableControl(CURSOR_WALK);
- R2_GLOBALS._flubMazeEntryDirection = 3;
- if (R2_GLOBALS._player._visage == 22) {
- scene->_sceneMode = 1975;
- scene->setAction(&scene->_sequenceManager, scene, 1975, &R2_GLOBALS._player, NULL);
- } else {
- SceneItem::display(1950, 22, 0, 280, 1, 160, 9, 1, 2, 20, 7, 7, LIST_END);
- R2_GLOBALS._flubMazeEntryDirection = 0;
- scene->_sceneMode = 0;
- Common::Point pt(250, 150);
- NpcMover *mover = new NpcMover();
- R2_GLOBALS._player.addMover(mover, &pt, scene);
- _enabled = true;
- }
-}
-
-/*--------------------------------------------------------------------------*/
-
-Scene1950::Scene1950() {
- _upExitStyle = false;
- _removeFlag = false;
- _vampireActive = false;
- _vampireDestPos = Common::Point(0, 0);
- _vampireIndex = 0;
-}
-
-void Scene1950::synchronize(Serializer &s) {
- SceneExt::synchronize(s);
-
- s.syncAsSint16LE(_upExitStyle);
- s.syncAsSint16LE(_removeFlag);
- s.syncAsSint16LE(_vampireActive);
- s.syncAsSint16LE(_vampireDestPos.x);
- s.syncAsSint16LE(_vampireDestPos.y);
- s.syncAsSint16LE(_vampireIndex);
-}
-
-void Scene1950::initArea() {
- _northExit._enabled = false;
- _upExit._enabled = false;
- _eastExit._enabled = false;
- _downExit._enabled = false;
- _southExit._enabled = false;
- _westExit._enabled = false;
- _shaftExit._enabled = false;
- _doorExit._enabled = false;
- _northExit._insideArea = false;
- _upExit._insideArea = false;
- _eastExit._insideArea = false;
- _downExit._insideArea = false;
- _southExit._insideArea = false;
- _westExit._insideArea = false;
- _shaftExit._insideArea = false;
- _doorExit._insideArea = false;
- _northExit._moving = false;
- _upExit._moving = false;
- _eastExit._moving = false;
- _downExit._moving = false;
- _southExit._moving = false;
- _westExit._moving = false;
- _shaftExit._moving = false;
- _doorExit._moving = false;
- _upExitStyle = false;
-
- switch (R2_GLOBALS._flubMazeArea - 1) {
- case 0:
- loadScene(1948);
- break;
- case 1:
- // No break on purpose
- case 8:
- // No break on purpose
- case 10:
- // No break on purpose
- case 12:
- // No break on purpose
- case 16:
- // No break on purpose
- case 19:
- // No break on purpose
- case 23:
- // No break on purpose
- case 30:
- // No break on purpose
- case 44:
- // No break on purpose
- case 72:
- // No break on purpose
- case 74:
- // No break on purpose
- case 86:
- // No break on purpose
- case 96:
- // No break on purpose
- case 103:
- loadScene(1950);
- break;
- case 2:
- // No break on purpose
- case 29:
- loadScene(1965);
- break;
- case 3:
- // No break on purpose
- case 9:
- // No break on purpose
- case 11:
- // No break on purpose
- case 15:
- // No break on purpose
- case 24:
- // No break on purpose
- case 39:
- // No break on purpose
- case 45:
- // No break on purpose
- case 71:
- // No break on purpose
- case 73:
- // No break on purpose
- case 75:
- // No break on purpose
- case 79:
- // No break on purpose
- case 85:
- // No break on purpose
- case 87:
- // No break on purpose
- case 95:
- loadScene(1955);
- break;
- case 4:
- // No break on purpose
- case 6:
- // No break on purpose
- case 13:
- // No break on purpose
- case 27:
- // No break on purpose
- case 41:
- // No break on purpose
- case 48:
- // No break on purpose
- case 50:
- // No break on purpose
- case 54:
- // No break on purpose
- case 76:
- // No break on purpose
- case 80:
- // No break on purpose
- case 90:
- // No break on purpose
- case 104:
- loadScene(1975);
- break;
- case 5:
- // No break on purpose
- case 7:
- // No break on purpose
- case 14:
- // No break on purpose
- case 28:
- // No break on purpose
- case 32:
- // No break on purpose
- case 47:
- // No break on purpose
- case 53:
- loadScene(1997);
- break;
- case 17:
- // No break on purpose
- case 20:
- // No break on purpose
- case 25:
- // No break on purpose
- case 31:
- // No break on purpose
- case 33:
- // No break on purpose
- case 46:
- loadScene(1995);
- break;
- case 18:
- // No break on purpose
- case 22:
- // No break on purpose
- case 26:
- // No break on purpose
- case 36:
- // No break on purpose
- case 38:
- // No break on purpose
- case 43:
- // No break on purpose
- case 51:
- // No break on purpose
- case 70:
- // No break on purpose
- case 78:
- // No break on purpose
- case 84:
- // No break on purpose
- case 89:
- // No break on purpose
- case 101:
- loadScene(1970);
- break;
- case 21:
- // No break on purpose
- case 34:
- // No break on purpose
- case 57:
- // No break on purpose
- case 58:
- // No break on purpose
- case 59:
- // No break on purpose
- case 62:
- // No break on purpose
- case 65:
- loadScene(1980);
- break;
- case 35:
- // No break on purpose
- case 61:
- // No break on purpose
- case 77:
- // No break on purpose
- case 83:
- loadScene(1982);
- break;
- case 37:
- // No break on purpose
- case 52:
- // No break on purpose
- case 82:
- // No break on purpose
- case 88:
- // No break on purpose
- case 92:
- // No break on purpose
- case 97:
- // No break on purpose
- case 100:
- loadScene(1962);
- break;
- case 40:
- // No break on purpose
- case 102:
- loadScene(1960);
- break;
- case 42:
- // No break on purpose
- case 55:
- // No break on purpose
- case 60:
- // No break on purpose
- case 66:
- // No break on purpose
- case 68:
- // No break on purpose
- case 69:
- // No break on purpose
- case 93:
- // No break on purpose
- case 98:
- loadScene(1990);
- break;
- case 49:
- // No break on purpose
- case 81:
- // No break on purpose
- case 91:
- // No break on purpose
- case 94:
- // No break on purpose
- case 99:
- loadScene(1967);
- break;
- case 56:
- // No break on purpose
- case 63:
- // No break on purpose
- case 64:
- // No break on purpose
- case 67:
- loadScene(1985);
- _upExitStyle = true;
- break;
- default:
- break;
- }
-
- if (R2_GLOBALS._flubMazeArea != 1)
- R2_GLOBALS._walkRegions.load(1950);
-
- switch (R2_GLOBALS._flubMazeArea - 1) {
- case 0:
- _shaftExit._enabled = true;
- if ((R2_INVENTORY.getObjectScene(R2_SCRITH_KEY) == 0) && (R2_INVENTORY.getObjectScene(R2_SAPPHIRE_BLUE) == 1950))
- _doorExit._enabled = true;
- R2_GLOBALS._walkRegions.disableRegion(2);
- R2_GLOBALS._walkRegions.disableRegion(3);
- R2_GLOBALS._walkRegions.disableRegion(4);
- R2_GLOBALS._walkRegions.disableRegion(5);
- R2_GLOBALS._walkRegions.disableRegion(6);
- break;
- case 1:
- // No break on purpose
- case 2:
- // No break on purpose
- case 3:
- // No break on purpose
- case 8:
- // No break on purpose
- case 9:
- // No break on purpose
- case 10:
- // No break on purpose
- case 11:
- // No break on purpose
- case 12:
- // No break on purpose
- case 15:
- // No break on purpose
- case 16:
- // No break on purpose
- case 19:
- // No break on purpose
- case 23:
- // No break on purpose
- case 24:
- // No break on purpose
- case 29:
- // No break on purpose
- case 30:
- // No break on purpose
- case 39:
- // No break on purpose
- case 40:
- // No break on purpose
- case 44:
- // No break on purpose
- case 45:
- // No break on purpose
- case 71:
- // No break on purpose
- case 72:
- // No break on purpose
- case 73:
- // No break on purpose
- case 74:
- // No break on purpose
- case 75:
- // No break on purpose
- case 79:
- // No break on purpose
- case 85:
- // No break on purpose
- case 86:
- // No break on purpose
- case 87:
- // No break on purpose
- case 95:
- // No break on purpose
- case 96:
- // No break on purpose
- case 102:
- // No break on purpose
- case 103:
- _eastExit._enabled = true;
- _westExit._enabled = true;
- break;
- case 4:
- // No break on purpose
- case 6:
- // No break on purpose
- case 13:
- // No break on purpose
- case 17:
- // No break on purpose
- case 20:
- // No break on purpose
- case 25:
- // No break on purpose
- case 27:
- // No break on purpose
- case 31:
- // No break on purpose
- case 33:
- // No break on purpose
- case 37:
- // No break on purpose
- case 41:
- // No break on purpose
- case 46:
- // No break on purpose
- case 48:
- // No break on purpose
- case 50:
- // No break on purpose
- case 52:
- // No break on purpose
- case 54:
- // No break on purpose
- case 76:
- // No break on purpose
- case 80:
- // No break on purpose
- case 82:
- // No break on purpose
- case 88:
- // No break on purpose
- case 90:
- // No break on purpose
- case 92:
- // No break on purpose
- case 97:
- // No break on purpose
- case 100:
- // No break on purpose
- case 104:
- _westExit._enabled = true;
- R2_GLOBALS._walkRegions.disableRegion(6);
- R2_GLOBALS._walkRegions.disableRegion(9);
- break;
- case 5:
- // No break on purpose
- case 7:
- // No break on purpose
- case 14:
- // No break on purpose
- case 18:
- // No break on purpose
- case 22:
- // No break on purpose
- case 26:
- // No break on purpose
- case 28:
- // No break on purpose
- case 32:
- // No break on purpose
- case 36:
- // No break on purpose
- case 38:
- // No break on purpose
- case 43:
- // No break on purpose
- case 47:
- // No break on purpose
- case 49:
- // No break on purpose
- case 51:
- // No break on purpose
- case 53:
- // No break on purpose
- case 70:
- // No break on purpose
- case 78:
- // No break on purpose
- case 81:
- // No break on purpose
- case 84:
- // No break on purpose
- case 89:
- // No break on purpose
- case 91:
- // No break on purpose
- case 94:
- // No break on purpose
- case 99:
- // No break on purpose
- case 101:
- _eastExit._enabled = true;
- R2_GLOBALS._walkRegions.disableRegion(1);
- R2_GLOBALS._walkRegions.disableRegion(7);
- R2_GLOBALS._walkRegions.disableRegion(13);
- break;
- default:
- R2_GLOBALS._walkRegions.disableRegion(1);
- R2_GLOBALS._walkRegions.disableRegion(6);
- R2_GLOBALS._walkRegions.disableRegion(7);
- R2_GLOBALS._walkRegions.disableRegion(9);
- R2_GLOBALS._walkRegions.disableRegion(13);
- break;
- }
-
- _northDoorway.remove();
- _northDoorway.removeObject();
- _southDoorway.remove();
-
- switch (R2_GLOBALS._flubMazeArea - 4) {
- case 0:
- // No break on purpose
- case 3:
- // No break on purpose
- case 16:
- // No break on purpose
- case 22:
- // No break on purpose
- case 24:
- // No break on purpose
- case 32:
- // No break on purpose
- case 33:
- // No break on purpose
- case 45:
- // No break on purpose
- case 46:
- // No break on purpose
- case 48:
- // No break on purpose
- case 51:
- // No break on purpose
- case 56:
- // No break on purpose
- case 59:
- // No break on purpose
- case 67:
- // No break on purpose
- case 68:
- // No break on purpose
- case 70:
- // No break on purpose
- case 73:
- // No break on purpose
- case 82:
- // No break on purpose
- case 90:
- _northExit._enabled = true;
- _northDoorway.setup(1950, (R2_GLOBALS._flubMazeArea % 2) + 1, 1, 160, 137, 25);
- //visage,strip,frame,px,py,priority,effect
- _southDoorway.postInit();
- _southDoorway.setVisage(1950);
- _southDoorway.setStrip((((R2_GLOBALS._flubMazeArea - 1) / 35) % 2) + 1);
- _southDoorway.setFrame(2);
- _southDoorway.setPosition(Common::Point(160, 167));
- _southDoorway.fixPriority(220);
- R2_GLOBALS._walkRegions.disableRegion(3);
- R2_GLOBALS._walkRegions.disableRegion(4);
- break;
- case 7:
- // No break on purpose
- case 10:
- // No break on purpose
- case 23:
- // No break on purpose
- case 29:
- // No break on purpose
- case 31:
- // No break on purpose
- case 39:
- // No break on purpose
- case 40:
- // No break on purpose
- case 52:
- // No break on purpose
- case 53:
- // No break on purpose
- case 55:
- // No break on purpose
- case 63:
- // No break on purpose
- case 65:
- // No break on purpose
- case 66:
- // No break on purpose
- case 75:
- // No break on purpose
- case 77:
- // No break on purpose
- case 81:
- // No break on purpose
- case 87:
- // No break on purpose
- case 89:
- // No break on purpose
- case 97:
- _southExit._enabled = true;
-
- _southDoorway.postInit();
- _southDoorway.setVisage(1950);
- _southDoorway.setStrip((((R2_GLOBALS._flubMazeArea - 1) / 35) % 2) + 1);
- _southDoorway.setFrame(3);
- _southDoorway.setPosition(Common::Point(160, 167));
- _southDoorway.fixPriority(220);
- break;
- case 58:
- // No break on purpose
- case 74:
- // No break on purpose
- case 80:
- _northExit._enabled = true;
- _southExit._enabled = true;
-
- _northDoorway.setup(1950, (R2_GLOBALS._flubMazeArea % 2) + 1, 1, 160, 137, 25);
-
- _southDoorway.postInit();
- _southDoorway.setVisage(1950);
- _southDoorway.setStrip((((R2_GLOBALS._flubMazeArea - 1) / 35) % 2) + 1);
- _southDoorway.setFrame(3);
- _southDoorway.setPosition(Common::Point(160, 167));
- _southDoorway.fixPriority(220);
- R2_GLOBALS._walkRegions.disableRegion(3);
- R2_GLOBALS._walkRegions.disableRegion(4);
- break;
- default:
- _southDoorway.postInit();
- _southDoorway.setVisage(1950);
- _southDoorway.setStrip(((R2_GLOBALS._flubMazeArea - 1) / 35) % 2 + 1);
- _southDoorway.setFrame(2);
- _southDoorway.setPosition(Common::Point(160, 167));
- _southDoorway.fixPriority(220);
- break;
- }
-
- switch (R2_GLOBALS._flubMazeArea - 3) {
- case 0:
- // No break on purpose
- case 3:
- // No break on purpose
- case 5:
- // No break on purpose
- case 12:
- // No break on purpose
- case 15:
- // No break on purpose
- case 18:
- // No break on purpose
- case 19:
- // No break on purpose
- case 23:
- // No break on purpose
- case 26:
- // No break on purpose
- case 27:
- // No break on purpose
- case 29:
- // No break on purpose
- case 30:
- // No break on purpose
- case 31:
- // No break on purpose
- case 32:
- // No break on purpose
- case 44:
- // No break on purpose
- case 45:
- // No break on purpose
- case 51:
- // No break on purpose
- case 55:
- // No break on purpose
- case 56:
- // No break on purpose
- case 57:
- // No break on purpose
- case 60:
- // No break on purpose
- case 63:
- _upExit._enabled = true;
- break;
- case 54:
- // No break on purpose
- case 61:
- // No break on purpose
- case 62:
- // No break on purpose
- case 65:
- _upExit._enabled = true;
- // No break on purpose
- case 35:
- // No break on purpose
- case 38:
- // No break on purpose
- case 40:
- // No break on purpose
- case 47:
- // No break on purpose
- case 50:
- // No break on purpose
- case 53:
- // No break on purpose
- case 58:
- // No break on purpose
- case 64:
- // No break on purpose
- case 66:
- // No break on purpose
- case 67:
- // No break on purpose
- case 79:
- // No break on purpose
- case 80:
- // No break on purpose
- case 86:
- // No break on purpose
- case 89:
- // No break on purpose
- case 90:
- // No break on purpose
- case 91:
- // No break on purpose
- case 92:
- // No break on purpose
- case 95:
- // No break on purpose
- case 96:
- // No break on purpose
- case 97:
- // No break on purpose
- case 98:
- // No break on purpose
- case 100:
- _downExit._enabled = true;
- R2_GLOBALS._walkRegions.disableRegion(4);
- R2_GLOBALS._walkRegions.disableRegion(5);
- R2_GLOBALS._walkRegions.disableRegion(6);
- R2_GLOBALS._walkRegions.disableRegion(10);
- R2_GLOBALS._walkRegions.disableRegion(11);
- default:
- break;
- }
- R2_GLOBALS._uiElements.draw();
-}
-
-void Scene1950::enterArea() {
- R2_GLOBALS._player.disableControl();
- R2_GLOBALS._player.animate(ANIM_MODE_1, NULL);
-
- _vampire.remove();
- _door.remove();
- _scrolls.remove();
-
- _vampireActive = false;
- _vampireIndex = 0;
-
- // Certain areas have a vampire in them
- switch (R2_GLOBALS._flubMazeArea) {
- case 10:
- _vampireIndex = 1;
- break;
- case 13:
- _vampireIndex = 2;
- break;
- case 16:
- _vampireIndex = 3;
- break;
- case 17:
- _vampireIndex = 4;
- break;
- case 24:
- _vampireIndex = 5;
- break;
- case 25:
- _vampireIndex = 6;
- break;
- case 31:
- _vampireIndex = 7;
- break;
- case 40:
- _vampireIndex = 8;
- break;
- case 45:
- _vampireIndex = 9;
- break;
- case 46:
- _vampireIndex = 10;
- break;
- case 73:
- _vampireIndex = 11;
- break;
- case 75:
- _vampireIndex = 12;
- break;
- case 80:
- _vampireIndex = 13;
- break;
- case 87:
- _vampireIndex = 14;
- break;
- case 88:
- _vampireIndex = 15;
- break;
- case 96:
- _vampireIndex = 16;
- break;
- case 97:
- _vampireIndex = 17;
- break;
- case 104:
- _vampireIndex = 18;
- break;
- default:
- break;
- }
-
- if (_vampireIndex != 0) {
- _vampire.postInit();
- _vampire._numFrames = 6;
- _vampire._moveRate = 6;
- _vampire._moveDiff = Common::Point(3, 2);
- _vampire._effect = EFFECT_SHADED;
-
- if (!R2_GLOBALS._vampireData[_vampireIndex - 1]._isAlive) {
- // Show vampire ashes
- _vampire.setPosition(Common::Point(R2_GLOBALS._vampireData[_vampireIndex - 1]._position));
- _vampire.animate(ANIM_MODE_NONE, NULL);
- _vampire.addMover(NULL);
- _vampire.setVisage(1961);
- _vampire.setStrip(4);
- _vampire.setFrame(10);
- _vampire.fixPriority(10);
- _vampire.setDetails(1950, 15, -1, 17, 2, (SceneItem *) NULL);
- } else {
- // Start the vampire
- _vampire.setVisage(1960);
- _vampire.setPosition(Common::Point(160, 130));
- _vampire.animate(ANIM_MODE_2, NULL);
- _vampire.setDetails(1950, 12, -1, 14, 2, (SceneItem *) NULL);
- _vampireActive = true;
- }
- }
- if ((R2_GLOBALS._flubMazeArea == 1) && (R2_INVENTORY.getObjectScene(R2_SCRITH_KEY) != 0)) {
- // Show doorway at the right hand side of the very first flub corridor
- _door.postInit();
- _door.setVisage(1948);
- _door.setStrip(3);
- _door.setPosition(Common::Point(278, 155));
- _door.fixPriority(100);
- _door.setDetails(1950, 19, 20, 23, 2, (SceneItem *) NULL);
- }
-
- if (R2_GLOBALS._flubMazeArea == 102) {
- R2_GLOBALS._walkRegions.load(1951);
- R2_GLOBALS._walkRegions.disableRegion(1);
- R2_GLOBALS._walkRegions.disableRegion(5);
- R2_GLOBALS._walkRegions.disableRegion(6);
- R2_GLOBALS._walkRegions.disableRegion(7);
-
- _cube.postInit();
- _cube.setVisage(1970);
- _cube.setStrip(1);
- if (R2_GLOBALS.getFlag(37))
- _cube.setFrame(3);
- else
- _cube.setFrame(1);
- _cube.setPosition(Common::Point(193, 158));
- _cube.setDetails(1950, 3, 4, 5, 2, (SceneItem *) NULL);
-
- _pulsingLights.postInit();
- _pulsingLights.setVisage(1970);
- _pulsingLights.setStrip(3);
- _pulsingLights.animate(ANIM_MODE_2, NULL);
- _pulsingLights._numFrames = 6;
- _pulsingLights.setPosition(Common::Point(194, 158));
- _pulsingLights.fixPriority(159);
-
- _keypad.setDetails(Rect(188, 124, 199, 133), 1950, 27, 28, -1, 2, NULL);
-
- if (R2_INVENTORY.getObjectScene(R2_SAPPHIRE_BLUE) == 1950) {
- _gem.postInit();
- _gem.setVisage(1970);
- _gem.setStrip(1);
- _gem.setFrame(2);
- _gem.fixPriority(160);
- }
-
- if (R2_GLOBALS.getFlag(37)) {
- _gem.setPosition(Common::Point(192, 118));
- _gem.setDetails(1950, 9, 4, -1, 2, (SceneItem *) NULL);
- } else {
- _containmentField.postInit();
- _containmentField.setVisage(1970);
- _containmentField.setStrip(4);
- _containmentField._numFrames = 4;
- _containmentField.animate(ANIM_MODE_8, 0, NULL);
- _containmentField.setPosition(Common::Point(192, 121));
- _containmentField.fixPriority(159);
- _containmentField.setDetails(1950, 6, 7, 8, 2, (SceneItem *) NULL);
-
- _gem.setPosition(Common::Point(192, 109));
- _gem.setDetails(1950, 9, 7, 8, 2, (SceneItem *) NULL);
- }
-
- _scrolls.postInit();
- _scrolls.setVisage(1972);
- _scrolls.setStrip(1);
- _scrolls.setPosition(Common::Point(76, 94));
- _scrolls.fixPriority(25);
- _scrolls.setDetails(1950, 30, -1, -1, 2, (SceneItem *) NULL);
- if (R2_INVENTORY.getObjectScene(R2_ANCIENT_SCROLLS) == 2)
- _scrolls.setFrame(2);
- else
- _scrolls.setFrame(1);
-
- _removeFlag = true;
- } else if (_removeFlag) {
- _cube.remove();
- _containmentField.remove();
- _gem.remove();
- _pulsingLights.remove();
- _scrolls.remove();
-
- R2_GLOBALS._sceneItems.remove(&_background);
- _background.setDetails(Rect(0, 0, 320, 200), 1950, 0, 1, 2, 2, NULL);
-
- _removeFlag = false;
- }
-
- switch (R2_GLOBALS._flubMazeEntryDirection) {
- case 0:
- _sceneMode = 1950;
- if (R2_INVENTORY.getObjectScene(R2_SCRITH_KEY) == 0)
- // The original uses CURSOR_ARROW. CURSOR_WALK is much more coherent
- R2_GLOBALS._player.enableControl(CURSOR_WALK);
- else
- setAction(&_sequenceManager, this, 1950, &R2_GLOBALS._player, NULL);
-
- break;
- case 1: {
- _sceneMode = R2_GLOBALS._flubMazeEntryDirection;
- R2_GLOBALS._player.setPosition(Common::Point(160, 213));
- Common::Point pt(160, 160);
- NpcMover *mover = new NpcMover();
- R2_GLOBALS._player.addMover(mover, &pt, this);
- }
- break;
- case 2:
- _sceneMode = R2_GLOBALS._flubMazeEntryDirection;
- if (R2_GLOBALS.getFlag(36))
- setAction(&_sequenceManager, this, 1957, &R2_GLOBALS._player, NULL);
- else
- setAction(&_sequenceManager, this, 1974, &R2_GLOBALS._player, NULL);
- break;
- case 3:
- // Entering from the left
- if (!_vampireActive) {
- _sceneMode = R2_GLOBALS._flubMazeEntryDirection;
- R2_GLOBALS._player.setPosition(Common::Point(-20, 160));
- Common::Point pt(30, 160);
- NpcMover *mover = new NpcMover();
- R2_GLOBALS._player.addMover(mover, &pt, this);
- } else {
- _sceneMode = 18;
- _eastExit._enabled = false;
- _vampireDestPos = Common::Point(60, 152);
- R2_GLOBALS._player.enableControl(CURSOR_USE);
- R2_GLOBALS._player._canWalk = false;
-
- _vampire.setStrip(2);
- NpcMover *mover = new NpcMover();
- _vampire.addMover(mover, &_vampireDestPos, this);
-
- R2_GLOBALS._player.setPosition(Common::Point(-20, 160));
- Common::Point pt2(30, 160);
- NpcMover *mover2 = new NpcMover();
- R2_GLOBALS._player.addMover(mover2, &pt2, NULL);
- }
- break;
- case 4:
- _sceneMode = R2_GLOBALS._flubMazeEntryDirection;
- if (!_upExitStyle) {
- if (R2_GLOBALS.getFlag(36))
- setAction(&_sequenceManager, this, 1955, &R2_GLOBALS._player, NULL);
- else
- setAction(&_sequenceManager, this, 1972, &R2_GLOBALS._player, NULL);
- } else {
- if (R2_GLOBALS.getFlag(36))
- setAction(&_sequenceManager, this, 1954, &R2_GLOBALS._player, NULL);
- else
- setAction(&_sequenceManager, this, 1971, &R2_GLOBALS._player, NULL);
- }
- break;
- case 5: {
- _sceneMode = R2_GLOBALS._flubMazeEntryDirection;
- R2_GLOBALS._player.setPosition(Common::Point(160, 127));
- Common::Point pt(160, 160);
- NpcMover *mover = new NpcMover();
- R2_GLOBALS._player.addMover(mover, &pt, this);
- }
- break;
- case 6:
- // Entering from the right
- if (!_vampireActive) {
- _sceneMode = R2_GLOBALS._flubMazeEntryDirection;
- if (R2_GLOBALS._flubMazeArea == 1) {
- setAction(&_sequenceManager, this, 1961, &R2_GLOBALS._player, NULL);
- } else {
- R2_GLOBALS._player.setPosition(Common::Point(340, 160));
- Common::Point pt(289, 160);
- NpcMover *mover = new NpcMover();
- R2_GLOBALS._player.addMover(mover, &pt, this);
- }
- } else {
- _sceneMode = 17;
- _westExit._enabled = false;
- _vampireDestPos = Common::Point(259, 152);
-
- R2_GLOBALS._player.enableControl(CURSOR_USE);
- R2_GLOBALS._player._canWalk = false;
-
- _vampire.setStrip(1);
- NpcMover *mover = new NpcMover();
- _vampire.addMover(mover, &_vampireDestPos, this);
-
- R2_GLOBALS._player.setPosition(Common::Point(340, 160));
- Common::Point pt2(289, 160);
- NpcMover *mover2 = new NpcMover();
- R2_GLOBALS._player.addMover(mover2, &pt2, NULL);
- }
- break;
- default:
- break;
- }
-}
-
-void Scene1950::doButtonPress(int indx) {
- Scene1950 *scene = (Scene1950 *)R2_GLOBALS._sceneManager._scene;
- R2_GLOBALS._player.disableControl();
-
- int prevIndex = indx - 1;
- if ((indx / 4) == (prevIndex / 4)) {
- if (prevIndex < 0)
- prevIndex = 3;
- } else {
- prevIndex += 4;
- }
-
- assert(prevIndex >= 0 && prevIndex < 16);
- if (!_KeypadWindow._buttons[prevIndex]._toggled) {
- _KeypadWindow._buttons[prevIndex].setFrame(2);
- _KeypadWindow._buttons[prevIndex]._toggled = true;
- } else {
- _KeypadWindow._buttons[prevIndex].setFrame(1);
- _KeypadWindow._buttons[prevIndex]._toggled = false;
- }
-
- prevIndex = indx + 1;
- if ((indx / 4) == (prevIndex / 4)) {
- if (prevIndex > 15)
- prevIndex = 12;
- } else {
- prevIndex -= 4;
- }
-
- assert(prevIndex >= 0 && prevIndex < 16);
- if (!_KeypadWindow._buttons[prevIndex]._toggled) {
- _KeypadWindow._buttons[prevIndex].setFrame(2);
- _KeypadWindow._buttons[prevIndex]._toggled = true;
- } else {
- _KeypadWindow._buttons[prevIndex].setFrame(1);
- _KeypadWindow._buttons[prevIndex]._toggled = false;
- }
-
- prevIndex = indx - 4;
- if (prevIndex < 0)
- prevIndex += 16;
-
- assert(prevIndex >= 0 && prevIndex < 16);
- if (!_KeypadWindow._buttons[prevIndex]._toggled) {
- _KeypadWindow._buttons[prevIndex].setFrame(2);
- _KeypadWindow._buttons[prevIndex]._toggled = true;
- } else {
- _KeypadWindow._buttons[prevIndex].setFrame(1);
- _KeypadWindow._buttons[prevIndex]._toggled = false;
- }
-
- prevIndex = indx + 4;
- if (prevIndex > 15)
- prevIndex -= 16;
-
- assert(prevIndex >= 0 && prevIndex < 16);
- if (!_KeypadWindow._buttons[prevIndex]._toggled) {
- _KeypadWindow._buttons[prevIndex].setFrame(2);
- _KeypadWindow._buttons[prevIndex]._toggled = true;
- } else {
- _KeypadWindow._buttons[prevIndex].setFrame(1);
- _KeypadWindow._buttons[prevIndex]._toggled = false;
- }
-
- // Check whether all the buttons are highlighted
- int cpt = 0;
- for (prevIndex = 0; prevIndex < 16; prevIndex++) {
- if (_KeypadWindow._buttons[prevIndex]._toggled)
- ++cpt;
- }
-
- if (cpt != 16) {
- R2_GLOBALS._player.enableControl();
- R2_GLOBALS._player._canWalk = false;
- } else {
- R2_GLOBALS.setFlag(37);
- _sceneMode = 24;
- setAction(&_sequenceManager, scene, 1976, NULL);
- }
-}
-
-void Scene1950::postInit(SceneObjectList *OwnerList) {
- _upExitStyle = false;
- _removeFlag = false;
- _vampireActive = false;
- _vampireIndex = 0;
- if (R2_GLOBALS._sceneManager._previousScene == 300)
- R2_GLOBALS._flubMazeArea = 103;
-
- initArea();
- SceneExt::postInit();
- R2_GLOBALS._sound1.play(105);
-
- _northExit.setDetails(Rect(130, 46, 189, 135), SHADECURSOR_UP, 1950);
- _northExit.setDest(Common::Point(160, 145));
-
- _upExit.setDetails(Rect(208, 0, 255, 73), EXITCURSOR_N, 1950);
- _upExit.setDest(Common::Point(200, 151));
-
- _eastExit.setDetails(Rect(305, 95, 320, 147), EXITCURSOR_E, 1950);
- _eastExit.setDest(Common::Point(312, 160));
-
- _downExit.setDetails(Rect(208, 99, 255, 143), EXITCURSOR_S, 1950);
- _downExit.setDest(Common::Point(200, 151));
-
- _southExit.setDetails(Rect(113, 154, 206, 168), SHADECURSOR_DOWN, 1950);
- _southExit.setDest(Common::Point(160, 165));
-
- _westExit.setDetails(Rect(0, 95, 14, 147), EXITCURSOR_W, 1950);
- _westExit.setDest(Common::Point(7, 160));
-
- _shaftExit.setDetails(Rect(72, 54, 120, 128), EXITCURSOR_NW, 1950);
- _shaftExit.setDest(Common::Point(120, 140));
-
- _doorExit.setDetails(Rect(258, 60, 300, 145), EXITCURSOR_NE, 1950);
- _doorExit.setDest(Common::Point(268, 149));
-
- R2_GLOBALS._player.postInit();
- if ( (R2_INVENTORY.getObjectScene(R2_TANNER_MASK) == 0) && (R2_INVENTORY.getObjectScene(R2_PURE_GRAIN_ALCOHOL) == 0)
- && (R2_INVENTORY.getObjectScene(R2_SOAKED_FACEMASK) == 0) && (!R2_GLOBALS.getFlag(36)) )
- R2_GLOBALS._player.setVisage(22);
- else
- R2_GLOBALS._player.setVisage(20);
-
- R2_GLOBALS._player._moveDiff = Common::Point(5, 3);
- _background.setDetails(Rect(0, 0, 320, 200), 1950, 0, 1, 2, 1, NULL);
-
- enterArea();
-}
-
-void Scene1950::remove() {
- R2_GLOBALS._sound1.stop();
- R2_GLOBALS._sound2.fadeOut2(NULL);
- SceneExt::remove();
-}
-
-void Scene1950::signal() {
- switch (_sceneMode) {
- case 11:
- R2_GLOBALS._flubMazeArea += 7;
- initArea();
- enterArea();
- break;
- case 12:
- // Moving up a ladder within the Flub maze
- R2_GLOBALS._flubMazeArea += 35;
- initArea();
- enterArea();
- break;
- case 1975:
- SceneItem::display(1950, 21, SET_WIDTH, 280, SET_X, 160, SET_POS_MODE, 1,
- SET_Y, 20, SET_EXT_BGCOLOR, 7, LIST_END);
- // No break on purpose
- case 13:
- // Moving east within the Flub maze
- ++R2_GLOBALS._flubMazeArea;
- initArea();
- enterArea();
- break;
- case 14:
- // Moving down a ladder within the Flub maze
- R2_GLOBALS._flubMazeArea -= 35;
- initArea();
- enterArea();
- break;
- case 15:
- R2_GLOBALS._flubMazeArea -= 7;
- initArea();
- enterArea();
- break;
- case 16:
- // Moving west within the Flub maze
- // No break on purpose
- case 1961:
- --R2_GLOBALS._flubMazeArea;
- initArea();
- enterArea();
- break;
- case 17: {
- _sceneMode = 13;
- R2_GLOBALS._flubMazeEntryDirection = 3;
- _vampireActive = false;
- R2_GLOBALS._player.disableControl(CURSOR_WALK);
- R2_GLOBALS._player._canWalk = true;
- R2_GLOBALS._player.setVisage(22);
- R2_GLOBALS._player.animate(ANIM_MODE_9);
- Common::Point pt(340, 160);
- NpcMover *mover = new NpcMover();
- R2_GLOBALS._player.addMover(mover, &pt, this);
- Common::Point pt2(289, 160);
- NpcMover *mover2 = new NpcMover();
- _vampire.addMover(mover2, &pt2, NULL);
- }
- break;
- case 18: {
- _sceneMode = 16;
- R2_GLOBALS._flubMazeEntryDirection = 6;
- _vampireActive = false;
- R2_GLOBALS._player.disableControl(CURSOR_WALK);
- R2_GLOBALS._player._canWalk = true;
- R2_GLOBALS._player.setVisage(22);
- R2_GLOBALS._player.animate(ANIM_MODE_9);
- Common::Point pt(-20, 160);
- NpcMover *mover = new NpcMover();
- R2_GLOBALS._player.addMover(mover, &pt, this);
- Common::Point pt2(30, 160);
- NpcMover *mover2 = new NpcMover();
- _vampire.addMover(mover2, &pt2, NULL);
- }
- break;
- case 24:
- _KeypadWindow.remove();
- _sceneMode = 1966;
- _cube.setFrame(3);
- setAction(&_sequenceManager, this, 1966, &_containmentField, &_gem, NULL);
- break;
- case 1951:
- R2_GLOBALS._sound1.fadeOut2(NULL);
- R2_GLOBALS._sceneManager.changeScene(1945);
- break;
- case 1958:
- SceneItem::display(1950, 24, 0, 280, 1, 160, 9, 1, 2, 20, 7, 7, LIST_END);
- R2_GLOBALS._player.enableControl(CURSOR_WALK);
- _doorExit._enabled = true;
- break;
- case 1959:
- R2_INVENTORY.setObjectScene(R2_SOAKED_FACEMASK, 0);
- R2_GLOBALS._player.enableControl(CURSOR_WALK);
- _doorExit._enabled = true;
- break;
- case 1962:
- // No break on purpose
- case 1963:
- R2_GLOBALS._player.enableControl();
- _KeypadWindow.setup2(1971, 1, 1, 160, 135);
- break;
- case 1964:
- // No break on purpose
- case 1965:
- if (!R2_GLOBALS.getFlag(37))
- SceneItem::display(1950, 26, 0, 280, 1, 160, 9, 1, 2, 20, 7, 7, LIST_END);
-
- R2_GLOBALS._player.enableControl();
- break;
- case 1966:
- _containmentField.remove();
- if (R2_GLOBALS.getFlag(36)) {
- _sceneMode = 1964;
- setAction(&_sequenceManager, this, 1964, &R2_GLOBALS._player, NULL);
- } else {
- _sceneMode = 1965;
- setAction(&_sequenceManager, this, 1965, &R2_GLOBALS._player, NULL);
- }
- _gem.setDetails(1950, 9, -1, -1, 2, (SceneItem *) NULL);
- break;
- case 1967: {
- _sceneMode = 0;
- R2_INVENTORY.setObjectScene(R2_SAPPHIRE_BLUE, 2);
- _gem.remove();
- if (R2_GLOBALS.getFlag(36))
- R2_GLOBALS._player.setVisage(20);
- else
- R2_GLOBALS._player.setVisage(22);
-
- R2_GLOBALS._player.animate(ANIM_MODE_1, NULL);
- // This is a hack to work around a pathfinding issue. original destination is (218, 165)
- Common::Point pt(128, 165);
- NpcMover *mover = new NpcMover();
- R2_GLOBALS._player.addMover(mover, &pt, this);
- }
- break;
- case 1968:
- R2_GLOBALS._player.enableControl();
- R2_INVENTORY.setObjectScene(R2_ANCIENT_SCROLLS, 2);
- _scrolls.setFrame(2);
- if (R2_GLOBALS.getFlag(36))
- R2_GLOBALS._player.setVisage(20);
- else
- R2_GLOBALS._player.setVisage(22);
- R2_GLOBALS._player.animate(ANIM_MODE_1, NULL);
- break;
- default:
- R2_GLOBALS._player.enableControl(CURSOR_WALK);
- break;
- }
-}
-
-void Scene1950::process(Event &event) {
- if ( (event.eventType == EVENT_BUTTON_DOWN)
- && (R2_GLOBALS._player._uiEnabled)
- && (R2_GLOBALS._events.getCursor() == R2_SOAKED_FACEMASK)
- && (R2_GLOBALS._player._bounds.contains(event.mousePos))
- && (R2_INVENTORY.getObjectScene(R2_SCRITH_KEY) == 0)) {
- event.handled = true;
- R2_GLOBALS._player.disableControl();
- _shaftExit._enabled = false;
- _doorExit._enabled = false;
- _sceneMode = 1959;
- setAction(&_sequenceManager, this, 1959, &R2_GLOBALS._player, NULL);
- }
-
- Scene::process(event);
-}
-
} // End of namespace Ringworld2
} // End of namespace TsAGE
diff --git a/engines/tsage/ringworld2/ringworld2_scenes1.h b/engines/tsage/ringworld2/ringworld2_scenes1.h
index 91c4b88391..e6f5e0ab97 100644
--- a/engines/tsage/ringworld2/ringworld2_scenes1.h
+++ b/engines/tsage/ringworld2/ringworld2_scenes1.h
@@ -135,270 +135,6 @@ public:
virtual void saveCharacter(int characterIndex);
};
-class Scene1200 : public SceneExt {
- enum CrawlDirection { CRAWL_EAST = 1, CRAWL_WEST = 2, CRAWL_SOUTH = 3, CRAWL_NORTH = 4 };
-
- class LaserPanel: public ModalWindow {
- public:
- class Jumper : public SceneActorExt {
- public:
- void init(int state);
- virtual bool startAction(CursorType action, Event &event);
- };
-
- Jumper _jumper1;
- Jumper _jumper2;
- Jumper _jumper3;
-
- LaserPanel();
-
- virtual void postInit(SceneObjectList *OwnerList = NULL);
- virtual void remove();
- };
-
-public:
- NamedHotspot _item1;
- SceneActor _actor1;
- LaserPanel _laserPanel;
- MazeUI _mazeUI;
- SequenceManager _sequenceManager;
-
- int _nextCrawlDirection;
- int _field414;
- int _field416;
- int _field418;
- int _field41A;
- bool _fixupMaze;
-
- Scene1200();
- void synchronize(Serializer &s);
-
- void startCrawling(CrawlDirection dir);
-
- virtual void postInit(SceneObjectList *OwnerList = NULL);
- virtual void signal();
- virtual void process(Event &event);
- virtual void dispatch();
- virtual void saveCharacter(int characterIndex);
-};
-
-class Scene1337 : public SceneExt {
- class OptionsDialog: public GfxDialog {
- private:
- GfxButton _autoplay;
- GfxButton _restartGame;
- GfxButton _quitGame;
- GfxButton _continueGame;
-
- OptionsDialog();
- virtual ~OptionsDialog() {}
- virtual GfxButton *execute(GfxButton *defaultButton);
- public:
- static void show();
- };
-
- class Card: public SceneHotspot {
- public:
- SceneObject _card;
-
- int _cardId;
- Common::Point _stationPos;
-
- Card();
- void synchronize(Serializer &s);
- bool isIn(Common::Point pt);
- };
-
- class GameBoardSide: public SceneHotspot {
- public:
- Card _handCard[4];
- Card _outpostStation[8];
- Card _delayCard;
- Card _emptyStationPos;
-
- Common::Point _card1Pos;
- Common::Point _card2Pos;
- Common::Point _card3Pos;
- Common::Point _card4Pos;
- int _frameNum;
-
- GameBoardSide();
- void synchronize(Serializer &s);
- };
-
- class Action1337: public Action {
- public:
- void waitFrames(int32 frameCount);
- };
-
- class Action1: public Action1337 {
- public:
- void signal();
- };
- class Action2: public Action1337 {
- public:
- void signal();
- };
- class Action3: public Action1337 {
- public:
- void signal();
- };
- class Action4: public Action1337 {
- public:
- void signal();
- };
- class Action5: public Action1337 {
- public:
- void signal();
- };
- class Action6: public Action1337 {
- public:
- void signal();
- };
- class Action7: public Action1337 {
- public:
- void signal();
- };
- class Action8: public Action1337 {
- public:
- void signal();
- };
- class Action9: public Action1337 {
- public:
- void signal();
- };
- class Action10: public Action1337 {
- public:
- void signal();
- };
- class Action11: public Action1337 {
- public:
- void signal();
- };
- class Action12: public Action1337 {
- public:
- void signal();
- };
- class Action13: public Action1337 {
- public:
- void signal();
- };
-public:
- Action1 _action1;
- Action2 _action2;
- Action3 _action3;
- Action4 _action4;
- Action5 _action5;
- Action6 _action6;
- Action7 _action7;
- Action8 _action8;
- Action9 _action9;
- Action10 _action10;
- Action11 _action11;
- Action12 _action12;
- Action13 _action13;
-
- typedef void (Scene1337::*FunctionPtrType)();
- FunctionPtrType _delayedFunction;
-
- bool _autoplay;
- bool _shuffleEndedFl;
- bool _showPlayerTurn;
- bool _displayHelpFl;
- bool _instructionsDisplayedFl;
-
- // Discarded cards are put in the available cards pile, with an higher index so there no conflict
- int _currentDiscardIndex;
- int _availableCardsPile[100];
- int _cardsAvailableNumb;
- int _currentPlayerNumb;
- int _actionIdx1;
- int _actionIdx2;
- int _winnerId;
- int _instructionsWaitCount;
- int _cursorCurRes;
- int _cursorCurStrip;
- int _cursorCurFrame;
-
- ASound _aSound1;
- ASound _aSound2;
- GameBoardSide _gameBoardSide[4];
- SceneActor _helpIcon;
- SceneActor _stockPile;
- SceneItem _actionItem;
- SceneObject _currentPlayerArrow;
-
- Card *_actionCard1;
- Card *_actionCard2;
- Card *_actionCard3;
- Card _animatedCard;
- Card _shuffleAnimation;
- Card _discardedPlatformCard;
- Card _selectedCard;
- Card _discardPile;
- Card _stockCard;
-
- SceneObject _upperDisplayCard[8];
- SceneObject _lowerDisplayCard[8];
-
- Scene1337();
- virtual void synchronize(Serializer &s);
-
- void actionDisplay(int resNum, int lineNum, int x, int y, int keepOnScreen, int width, int textMode, int fontNum, int colFG, int colBGExt, int colFGExt);
- void setAnimationInfo(Card *card);
- void handleNextTurn();
- void handlePlayerTurn();
- bool isStationCard(int cardId);
- bool isStopConstructionCard(int cardId);
- int getStationId(int playerId, int handCardId);
- int findPlatformCardInHand(int playerId);
- int findCard13InHand(int playerId);
- int checkThieftCard(int playerId);
- int isDelayCard(int cardId);
- int getStationCardId(int cardId);
- void handlePlayer01Discard(int playerId);
- void playThieftCard(int playerId, Card *card, int victimId);
- int getPreventionCardId(int cardId);
- bool isAttackPossible(int victimId, int cardId);
- int getPlayerWithOutpost(int playerId);
- bool checkAntiDelayCard(int delayCardId, int cardId);
- void playStationCard(Card *station, Card *platform);
- void playDelayCard(Card *card, Card *dest);
- void playPlatformCard(Card *card, Card *dest);
- void playAntiDelayCard(Card *card, Card *dest);
- Card *getStationCard(int arg1);
- void playCounterTrickCard(Card *card, int playerId);
- int getFreeHandCard(int playerId);
- void discardCard(Card *card);
- void subC4CD2();
- void subC4CEC();
- void subC51A0(Card *subObj1, Card *subObj2);
- void displayDialog(int dialogNumb);
- void subPostInit();
- void displayInstructions();
- void suggestInstructions();
- void shuffleCards();
- void dealCards();
- void showOptionsDialog();
- void handleClick(int arg1, Common::Point pt);
- void handlePlayer0();
- void handlePlayer1();
- void handlePlayer2();
- void handlePlayer3();
- void handleAutoplayPlayer2();
- void updateCursorId(int arg1, bool arg2);
- void setCursorData(int resNum, int rlbNum, int frameNum);
- void subD18F5();
- void subD1917();
- void subD1940(bool flag);
- void subD1975(int arg1, int arg2);
-
- virtual void postInit(SceneObjectList *OwnerList = NULL);
- virtual void remove();
- virtual void process(Event &event);
- virtual void dispatch();
-};
-
class Scene1500 : public SceneExt {
public:
SceneActor _starship;
@@ -1097,143 +833,6 @@ public:
virtual void signal();
};
-class Scene1950 : public SceneExt {
- /* Windows */
- class KeypadWindow: public ModalWindow {
- public:
- class KeypadButton : public SceneActor {
- public:
- int _buttonIndex;
- bool _pressed;
- bool _toggled;
-
- KeypadButton();
- void synchronize(Serializer &s);
-
- void init(int indx);
- virtual void process(Event &event);
- virtual bool startAction(CursorType action, Event &event);
- };
-
- SceneActor _areaActor;
- KeypadButton _buttons[16];
-
- int _buttonIndex;
-
- KeypadWindow();
- virtual void synchronize(Serializer &s);
- virtual void remove();
- virtual void setup2(int visage, int stripFrameNum, int frameNum, int posX, int posY);
- virtual void setup3(int resNum, int lookLineNum, int talkLineNum, int useLineNum);
- };
-
- class Keypad : public NamedHotspot {
- public:
- virtual bool startAction(CursorType action, Event &event);
- };
-
- /* Actors */
- class Door : public SceneActor {
- public:
- virtual bool startAction(CursorType action, Event &event);
- };
- class Scrolls : public SceneActor {
- public:
- virtual bool startAction(CursorType action, Event &event);
- };
- class Gem : public SceneActor {
- public:
- virtual bool startAction(CursorType action, Event &event);
- };
- class Vampire : public SceneActor {
- public:
- Common::Point _deadPosition;
- int _deltaX;
- int _deltaY;
- int _vampireMode;
-
- Vampire();
- void synchronize(Serializer &s);
-
- virtual void signal();
- virtual bool startAction(CursorType action, Event &event);
- };
-
- /* Exits */
- class NorthExit : public SceneExit {
- public:
- virtual void changeScene();
- };
- class UpExit : public SceneExit {
- public:
- virtual void changeScene();
- };
- class EastExit : public SceneExit {
- public:
- virtual void changeScene();
- };
- class DownExit : public SceneExit {
- public:
- virtual void changeScene();
- };
- class SouthExit : public SceneExit {
- public:
- virtual void changeScene();
- };
- class WestExit : public SceneExit {
- public:
- virtual void changeScene();
- };
- class ShaftExit : public SceneExit {
- public:
- virtual void changeScene();
- };
- class DoorExit : public SceneExit {
- public:
- virtual void changeScene();
- };
-private:
- void initArea();
- void enterArea();
- void doButtonPress(int indx);
-public:
- NamedHotspot _background;
- Keypad _keypad;
- SceneActor _southDoorway;
- SceneObject _northDoorway;
- Door _door;
- Scrolls _scrolls;
- SceneActor _containmentField;
- Gem _gem;
- SceneActor _cube;
- SceneActor _pulsingLights;
- Vampire _vampire;
- KeypadWindow _KeypadWindow;
- NorthExit _northExit;
- UpExit _upExit;
- EastExit _eastExit;
- DownExit _downExit;
- SouthExit _southExit;
- WestExit _westExit;
- ShaftExit _shaftExit;
- DoorExit _doorExit;
- SequenceManager _sequenceManager;
-
- bool _upExitStyle;
- bool _removeFlag;
- bool _vampireActive;
- Common::Point _vampireDestPos;
- int _vampireIndex;
-
- Scene1950();
- void synchronize(Serializer &s);
-
- virtual void postInit(SceneObjectList *OwnerList = NULL);
- virtual void remove();
- virtual void signal();
- virtual void process(Event &event);
-};
-
} // End of namespace Ringworld2
} // End of namespace TsAGE
diff --git a/engines/tsage/ringworld2/ringworld2_scenes3.cpp b/engines/tsage/ringworld2/ringworld2_scenes3.cpp
index 9eaead630b..8610e0c8bc 100644
--- a/engines/tsage/ringworld2/ringworld2_scenes3.cpp
+++ b/engines/tsage/ringworld2/ringworld2_scenes3.cpp
@@ -3878,7 +3878,7 @@ void Scene3500::dispatch() {
Scene::dispatch();
// WORKAROUND: The _mazeUI wasn't originally added to the scene in postInit.
- // This is only needed to fix old savegames
+ // This is only needed to fix old savegames
if (!R2_GLOBALS._sceneObjects->contains(&_mazeUI))
_mazeUI.draw();
diff --git a/engines/tsage/ringworld2/ringworld2_vampire.cpp b/engines/tsage/ringworld2/ringworld2_vampire.cpp
new file mode 100644
index 0000000000..9d3b7f91a5
--- /dev/null
+++ b/engines/tsage/ringworld2/ringworld2_vampire.cpp
@@ -0,0 +1,1821 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public 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 "tsage/ringworld2/ringworld2_vampire.h"
+
+namespace TsAGE {
+
+namespace Ringworld2 {
+
+/*--------------------------------------------------------------------------
+ * Scene 1950 - Flup Tube Corridor Maze
+ *
+ *--------------------------------------------------------------------------*/
+
+Scene1950::KeypadWindow::KeypadWindow() {
+ _buttonIndex = 0;
+}
+
+void Scene1950::KeypadWindow::synchronize(Serializer &s) {
+ SceneArea::synchronize(s);
+
+ s.syncAsSint16LE(_buttonIndex);
+}
+
+Scene1950::KeypadWindow::KeypadButton::KeypadButton() {
+ _buttonIndex = 0;
+ _pressed = false;
+ _toggled = false;
+}
+
+void Scene1950::KeypadWindow::KeypadButton::synchronize(Serializer &s) {
+ SceneActor::synchronize(s);
+
+ s.syncAsSint16LE(_buttonIndex);
+ s.syncAsSint16LE(_pressed);
+ s.syncAsSint16LE(_toggled);
+}
+
+void Scene1950::KeypadWindow::KeypadButton::init(int indx) {
+ Scene1950 *scene = (Scene1950 *)R2_GLOBALS._sceneManager._scene;
+
+ _buttonIndex = indx;
+ _pressed = false;
+ _toggled = false;
+
+ postInit();
+ setup(1971, 2, 1);
+ fixPriority(249);
+ setPosition(Common::Point(((_buttonIndex % 4) * 22) + 127, ((_buttonIndex / 4) * 19) + 71));
+ scene->_sceneAreas.push_front(this);
+}
+
+void Scene1950::KeypadWindow::KeypadButton::process(Event &event) {
+ if ((event.eventType == EVENT_BUTTON_DOWN) && (R2_GLOBALS._events.getCursor() == CURSOR_USE)
+ && (_bounds.contains(event.mousePos)) && !_pressed) {
+ R2_GLOBALS._sound2.play(227);
+ if (!_toggled) {
+ setFrame(2);
+ _toggled = true;
+ } else {
+ setFrame(1);
+ _toggled = false;
+ }
+ _pressed = true;
+ event.handled = true;
+ }
+
+ if ((event.eventType == EVENT_BUTTON_UP) && _pressed) {
+ _pressed = false;
+ event.handled = true;
+ Scene1950 *scene = (Scene1950 *)R2_GLOBALS._sceneManager._scene;
+ scene->doButtonPress(_buttonIndex);
+ }
+}
+
+bool Scene1950::KeypadWindow::KeypadButton::startAction(CursorType action, Event &event) {
+ if (action == CURSOR_USE)
+ return false;
+ return SceneActor::startAction(action, event);
+}
+
+void Scene1950::KeypadWindow::remove() {
+ Scene1950 *scene = (Scene1950 *)R2_GLOBALS._sceneManager._scene;
+ for (_buttonIndex = 0; _buttonIndex < 16; ++_buttonIndex) {
+ scene->_sceneAreas.remove(&_buttons[_buttonIndex]);
+ _buttons[_buttonIndex].remove();
+ }
+
+ ModalWindow::remove();
+
+ if (!R2_GLOBALS.getFlag(37))
+ R2_GLOBALS._sound2.play(278);
+
+ R2_GLOBALS._player.disableControl(CURSOR_WALK);
+ scene->_eastExit._enabled = true;
+
+ if (!R2_GLOBALS.getFlag(37)) {
+ if (R2_GLOBALS.getFlag(36)) {
+ scene->_sceneMode = 1964;
+ scene->setAction(&scene->_sequenceManager, scene, 1964, &R2_GLOBALS._player, NULL);
+ } else {
+ scene->_sceneMode = 1965;
+ scene->setAction(&scene->_sequenceManager, scene, 1965, &R2_GLOBALS._player, NULL);
+ }
+ }
+}
+
+void Scene1950::KeypadWindow::setup2(int visage, int stripFrameNum, int frameNum, int posX, int posY) {
+ Scene1950 *scene = (Scene1950 *)R2_GLOBALS._sceneManager._scene;
+
+ if (R2_GLOBALS._player._mover)
+ R2_GLOBALS._player.addMover(NULL);
+ R2_GLOBALS._player._canWalk = false;
+
+ ModalWindow::setup2(visage, stripFrameNum, frameNum, posX, posY);
+
+ _object1.fixPriority(248);
+ scene->_eastExit._enabled = false;
+ setup3(1950, 27, 28, 27);
+
+ for (_buttonIndex = 0; _buttonIndex < 16; _buttonIndex++)
+ _buttons[_buttonIndex].init(_buttonIndex);
+}
+
+void Scene1950::KeypadWindow::setup3(int resNum, int lookLineNum, int talkLineNum, int useLineNum) {
+ // Copy of Scene1200::LaserPanel::proc13()
+ _areaActor.setDetails(resNum, lookLineNum, talkLineNum, useLineNum, 2, (SceneItem *) NULL);
+}
+
+/*--------------------------------------------------------------------------*/
+
+bool Scene1950::Keypad::startAction(CursorType action, Event &event) {
+ if ((action != CURSOR_USE) || (R2_GLOBALS.getFlag(37)))
+ return SceneHotspot::startAction(action, event);
+
+ Scene1950 *scene = (Scene1950 *)R2_GLOBALS._sceneManager._scene;
+
+ R2_GLOBALS._player.disableControl();
+ if (R2_GLOBALS.getFlag(36)) {
+ scene->_sceneMode = 1962;
+ scene->setAction(&scene->_sequenceManager, scene, 1962, &R2_GLOBALS._player, NULL);
+ } else {
+ scene->_sceneMode = 1963;
+ scene->setAction(&scene->_sequenceManager, scene, 1963, &R2_GLOBALS._player, NULL);
+ }
+ return true;
+}
+
+bool Scene1950::Door::startAction(CursorType action, Event &event) {
+ if (action != R2_SCRITH_KEY)
+ return SceneActor::startAction(action, event);
+
+ Scene1950 *scene = (Scene1950 *)R2_GLOBALS._sceneManager._scene;
+
+ R2_GLOBALS._player.disableControl();
+ R2_INVENTORY.setObjectScene(R2_SCRITH_KEY, 0);
+ scene->_sceneMode = 1958;
+ scene->setAction(&scene->_sequenceManager, scene, 1958, &R2_GLOBALS._player, &scene->_door, NULL);
+ return true;
+}
+
+bool Scene1950::Scrolls::startAction(CursorType action, Event &event) {
+ if ((action != CURSOR_USE) || (R2_INVENTORY.getObjectScene(R2_ANCIENT_SCROLLS) != 1950))
+ return SceneActor::startAction(action, event);
+
+ Scene1950 *scene = (Scene1950 *)R2_GLOBALS._sceneManager._scene;
+
+ R2_GLOBALS._player.disableControl();
+ scene->_sceneMode = 1968;
+ scene->setAction(&scene->_sequenceManager, scene, 1968, &R2_GLOBALS._player, NULL);
+
+ return true;
+}
+
+bool Scene1950::Gem::startAction(CursorType action, Event &event) {
+ if ((action != CURSOR_USE) || (!R2_GLOBALS.getFlag(37)))
+ return SceneActor::startAction(action, event);
+
+ Scene1950 *scene = (Scene1950 *)R2_GLOBALS._sceneManager._scene;
+
+ R2_GLOBALS._player.disableControl();
+ scene->_sceneMode = 1967;
+ scene->setAction(&scene->_sequenceManager, scene, 1967, &R2_GLOBALS._player, NULL);
+
+ return true;
+}
+
+/*--------------------------------------------------------------------------*/
+
+Scene1950::Vampire::Vampire() {
+ _deadPosition = Common::Point(0, 0);
+ _deltaX = 0;
+ _deltaY = 0;
+ _vampireMode = 0;
+}
+
+void Scene1950::Vampire::synchronize(Serializer &s) {
+ SceneActor::synchronize(s);
+
+ s.syncAsSint16LE(_deadPosition.x);
+ s.syncAsSint16LE(_deadPosition.y);
+ s.syncAsSint16LE(_deltaX);
+ s.syncAsSint16LE(_deltaY);
+ s.syncAsSint16LE(_vampireMode);
+}
+
+void Scene1950::Vampire::signal() {
+ Scene1950 *scene = (Scene1950 *)R2_GLOBALS._sceneManager._scene;
+
+ switch (_vampireMode) {
+ case 19: {
+ _vampireMode = 0;
+ setVisage(1960);
+ if (R2_GLOBALS._flubMazeEntryDirection == 3)
+ setStrip(2);
+ else
+ setStrip(1);
+
+ NpcMover *mover = new NpcMover();
+ addMover(mover, &scene->_vampireDestPos, scene);
+ }
+ break;
+ case 20: {
+ // Non fatal shot
+ _vampireMode = 19;
+ R2_GLOBALS._player.setVisage(22);
+ if (R2_GLOBALS._flubMazeEntryDirection == 3)
+ R2_GLOBALS._player.setStrip(1);
+ else
+ R2_GLOBALS._player.setStrip(2);
+ R2_GLOBALS._player.animate(ANIM_MODE_1, NULL);
+ R2_GLOBALS._vampireData[scene->_vampireIndex - 1]._shotsRequired--;
+
+ if (R2_GLOBALS._flubMazeEntryDirection == 3)
+ _deadPosition.x = _position.x + 10;
+ else
+ _deadPosition.x = _position.x - 10;
+ _deadPosition.y = _position.y - 4;
+
+ setVisage(1961);
+
+ if (R2_GLOBALS._flubMazeEntryDirection == 3)
+ setStrip(2);
+ else
+ setStrip(1);
+
+ animate(ANIM_MODE_2, NULL);
+ Common::Point pt = _deadPosition;
+ PlayerMover *mover = new PlayerMover();
+ addMover(mover, &pt, this);
+
+ R2_GLOBALS._player.enableControl();
+ }
+ break;
+ case 21: {
+ // Fatal shot
+ R2_GLOBALS._player.setVisage(22);
+ if (R2_GLOBALS._flubMazeEntryDirection == 3)
+ R2_GLOBALS._player.setStrip(1);
+ else
+ R2_GLOBALS._player.setStrip(2);
+ R2_GLOBALS._player.animate(ANIM_MODE_1, NULL);
+
+ setVisage(1961);
+ if (R2_GLOBALS._flubMazeEntryDirection == 3)
+ setStrip(4);
+ else
+ setStrip(3);
+ setDetails(1950, 15, -1, 17, 2, (SceneItem *) NULL);
+ addMover(NULL);
+ _numFrames = 8;
+ R2_GLOBALS._sound2.play(226);
+ animate(ANIM_MODE_5, NULL);
+ fixPriority(10);
+
+ R2_GLOBALS._vampireData[scene->_vampireIndex - 1]._isAlive = false;
+ R2_GLOBALS._vampireData[scene->_vampireIndex - 1]._shotsRequired--;
+ R2_GLOBALS._vampireData[scene->_vampireIndex - 1]._position = _position;
+ _deltaX = (_position.x - R2_GLOBALS._player._position.x) / 2;
+ _deltaY = (_position.y - R2_GLOBALS._player._position.y) / 2;
+
+ byte vampireCount = 0;
+ for (byte i = 0; i < 18; ++i) {
+ if (!R2_GLOBALS._vampireData[i]._isAlive)
+ ++vampireCount;
+ }
+
+ if (vampireCount == 18) {
+ R2_GLOBALS.setFlag(36);
+ _vampireMode = 23;
+ Common::Point pt(R2_GLOBALS._player._position.x + _deltaX, R2_GLOBALS._player._position.y + _deltaY);
+ NpcMover *mover = new NpcMover();
+ R2_GLOBALS._player.addMover(mover, &pt, this);
+ } else if (vampireCount == 1) {
+ _vampireMode = 22;
+ Common::Point pt(R2_GLOBALS._player._position.x + _deltaX, R2_GLOBALS._player._position.y + _deltaY);
+ NpcMover *mover = new NpcMover();
+ R2_GLOBALS._player.addMover(mover, &pt, this);
+ } else {
+ R2_GLOBALS._player.enableControl(CURSOR_WALK);
+ }
+
+ if (R2_GLOBALS._flubMazeEntryDirection == 3)
+ scene->_eastExit._enabled = true;
+ else
+ scene->_westExit._enabled = true;
+
+ scene->_vampireActive = false;
+ }
+ break;
+ case 22:
+ SceneItem::display(1950, 18, 0, 280, 1, 160, 9, 1, 2, 20, 7, 7, LIST_END);
+ R2_GLOBALS._player.enableControl(CURSOR_WALK);
+ break;
+ case 23:
+ SceneItem::display(1950, 25, 0, 280, 1, 160, 9, 1, 2, 20, 7, 7, LIST_END);
+ scene->_sceneMode = R2_GLOBALS._flubMazeEntryDirection;
+ scene->setAction(&scene->_sequenceManager, scene, 1960, &R2_GLOBALS._player, NULL);
+ break;
+ default:
+ break;
+ }
+}
+
+bool Scene1950::Vampire::startAction(CursorType action, Event &event) {
+ Scene1950 *scene = (Scene1950 *)R2_GLOBALS._sceneManager._scene;
+
+ if (!R2_GLOBALS._vampireData[scene->_vampireIndex - 1]._isAlive ||
+ (action != R2_PHOTON_STUNNER))
+ return SceneActor::startAction(action, event);
+
+ R2_GLOBALS._player.disableControl();
+
+ if (R2_GLOBALS._vampireData[scene->_vampireIndex - 1]._shotsRequired <= 1)
+ _vampireMode = 21;
+ else
+ _vampireMode = 20;
+
+ R2_GLOBALS._player.setVisage(25);
+ if (R2_GLOBALS._flubMazeEntryDirection == 3)
+ R2_GLOBALS._player.setStrip(2);
+ else
+ R2_GLOBALS._player.setStrip(1);
+ R2_GLOBALS._player.animate(ANIM_MODE_5, this);
+ R2_GLOBALS._sound3.play(99);
+
+ return true;
+}
+
+/*--------------------------------------------------------------------------*/
+
+void Scene1950::NorthExit::changeScene() {
+ Scene1950 *scene = (Scene1950 *)R2_GLOBALS._sceneManager._scene;
+
+ _enabled = false;
+ R2_GLOBALS._player.disableControl(CURSOR_WALK);
+ R2_GLOBALS._flubMazeEntryDirection = 1;
+ scene->_sceneMode = 11;
+
+ Common::Point pt(160, 127);
+ PlayerMover *mover = new PlayerMover();
+ R2_GLOBALS._player.addMover(mover, &pt, scene);
+}
+
+void Scene1950::UpExit::changeScene() {
+ Scene1950 *scene = (Scene1950 *)R2_GLOBALS._sceneManager._scene;
+
+ _enabled = false;
+ R2_GLOBALS._player.disableControl(CURSOR_WALK);
+ R2_GLOBALS._flubMazeEntryDirection = 2;
+ scene->_sceneMode = 12;
+
+ if (!scene->_upExitStyle) {
+ if (R2_GLOBALS.getFlag(36))
+ scene->setAction(&scene->_sequenceManager, scene, 1953, &R2_GLOBALS._player, NULL);
+ else
+ scene->setAction(&scene->_sequenceManager, scene, 1970, &R2_GLOBALS._player, NULL);
+ } else {
+ if (R2_GLOBALS.getFlag(36))
+ scene->setAction(&scene->_sequenceManager, scene, 1952, &R2_GLOBALS._player, NULL);
+ else
+ scene->setAction(&scene->_sequenceManager, scene, 1969, &R2_GLOBALS._player, NULL);
+ }
+}
+
+void Scene1950::EastExit::changeScene() {
+ Scene1950 *scene = (Scene1950 *)R2_GLOBALS._sceneManager._scene;
+
+ _enabled = false;
+ R2_GLOBALS._player.disableControl(CURSOR_WALK);
+ R2_GLOBALS._flubMazeEntryDirection = 3;
+ scene->_sceneMode = 13;
+
+ if (scene->_vampireActive)
+ R2_GLOBALS._player.animate(ANIM_MODE_9);
+
+ Common::Point pt(340, 160);
+ NpcMover *mover = new NpcMover();
+ R2_GLOBALS._player.addMover(mover, &pt, scene);
+}
+
+void Scene1950::DownExit::changeScene() {
+ Scene1950 *scene = (Scene1950 *)R2_GLOBALS._sceneManager._scene;
+
+ _enabled = false;
+ R2_GLOBALS._player.disableControl(CURSOR_WALK);
+ R2_GLOBALS._flubMazeEntryDirection = 4;
+ scene->_sceneMode = 14;
+
+ if (R2_GLOBALS.getFlag(36))
+ scene->setAction(&scene->_sequenceManager, scene, 1956, &R2_GLOBALS._player, NULL);
+ else
+ scene->setAction(&scene->_sequenceManager, scene, 1973, &R2_GLOBALS._player, NULL);
+}
+
+void Scene1950::SouthExit::changeScene() {
+ Scene1950 *scene = (Scene1950 *)R2_GLOBALS._sceneManager._scene;
+
+ _enabled = false;
+ R2_GLOBALS._player.disableControl(CURSOR_WALK);
+ R2_GLOBALS._flubMazeEntryDirection = 5;
+ scene->_sceneMode = 15;
+
+ Common::Point pt(160, 213);
+ NpcMover *mover = new NpcMover();
+ R2_GLOBALS._player.addMover(mover, &pt, scene);
+}
+
+void Scene1950::WestExit::changeScene() {
+ Scene1950 *scene = (Scene1950 *)R2_GLOBALS._sceneManager._scene;
+
+ _enabled = false;
+ R2_GLOBALS._player.disableControl(CURSOR_WALK);
+ R2_GLOBALS._flubMazeEntryDirection = 6;
+
+ if (R2_GLOBALS._flubMazeArea == 2) {
+ // In the very first corridor area after the Scrith Door
+ if ((R2_GLOBALS.getFlag(36)) && (R2_INVENTORY.getObjectScene(R2_SAPPHIRE_BLUE) == 2) && (R2_INVENTORY.getObjectScene(R2_ANCIENT_SCROLLS) == 2)) {
+ scene->_sceneMode = 1961;
+ Common::Point pt(-20, 160);
+ NpcMover *mover = new NpcMover();
+ R2_GLOBALS._player.addMover(mover, &pt, scene);
+ } else {
+ if (!R2_GLOBALS.getFlag(36))
+ SceneItem::display(1950, 33, 0, 280, 1, 160, 9, 1, 2, 20, 7, 7, LIST_END);
+ if ((R2_INVENTORY.getObjectScene(R2_SAPPHIRE_BLUE) == 1950) || (R2_INVENTORY.getObjectScene(R2_ANCIENT_SCROLLS) == 1950))
+ SceneItem::display(1950, 34, 0, 280, 1, 160, 9, 1, 2, 20, 7, 7, LIST_END);
+ scene->_sceneMode = 0;
+ Common::Point pt(30, 160);
+ NpcMover *mover = new NpcMover();
+ R2_GLOBALS._player.addMover(mover, &pt, scene);
+ }
+ } else {
+ if (scene->_vampireActive)
+ R2_GLOBALS._player.animate(ANIM_MODE_9);
+
+ scene->_sceneMode = 16;
+ Common::Point pt(-20, 160);
+ NpcMover *mover = new NpcMover();
+ R2_GLOBALS._player.addMover(mover, &pt, scene);
+ }
+}
+
+void Scene1950::ShaftExit::changeScene() {
+ Scene1950 *scene = (Scene1950 *)R2_GLOBALS._sceneManager._scene;
+
+ _enabled = false;
+ R2_GLOBALS._player.disableControl(CURSOR_WALK);
+ R2_GLOBALS._flubMazeEntryDirection = 0;
+ scene->_sceneMode = 1951;
+ scene->setAction(&scene->_sequenceManager, scene, 1951, &R2_GLOBALS._player, NULL);
+}
+
+void Scene1950::DoorExit::changeScene() {
+ Scene1950 *scene = (Scene1950 *)R2_GLOBALS._sceneManager._scene;
+
+ _enabled = false;
+ R2_GLOBALS._player.disableControl(CURSOR_WALK);
+ R2_GLOBALS._flubMazeEntryDirection = 3;
+ if (R2_GLOBALS._player._visage == 22) {
+ scene->_sceneMode = 1975;
+ scene->setAction(&scene->_sequenceManager, scene, 1975, &R2_GLOBALS._player, NULL);
+ } else {
+ SceneItem::display(1950, 22, 0, 280, 1, 160, 9, 1, 2, 20, 7, 7, LIST_END);
+ R2_GLOBALS._flubMazeEntryDirection = 0;
+ scene->_sceneMode = 0;
+ Common::Point pt(250, 150);
+ NpcMover *mover = new NpcMover();
+ R2_GLOBALS._player.addMover(mover, &pt, scene);
+ _enabled = true;
+ }
+}
+
+/*--------------------------------------------------------------------------*/
+
+Scene1950::Scene1950() {
+ _upExitStyle = false;
+ _removeFlag = false;
+ _vampireActive = false;
+ _vampireDestPos = Common::Point(0, 0);
+ _vampireIndex = 0;
+}
+
+void Scene1950::synchronize(Serializer &s) {
+ SceneExt::synchronize(s);
+
+ s.syncAsSint16LE(_upExitStyle);
+ s.syncAsSint16LE(_removeFlag);
+ s.syncAsSint16LE(_vampireActive);
+ s.syncAsSint16LE(_vampireDestPos.x);
+ s.syncAsSint16LE(_vampireDestPos.y);
+ s.syncAsSint16LE(_vampireIndex);
+}
+
+void Scene1950::initArea() {
+ _northExit._enabled = false;
+ _upExit._enabled = false;
+ _eastExit._enabled = false;
+ _downExit._enabled = false;
+ _southExit._enabled = false;
+ _westExit._enabled = false;
+ _shaftExit._enabled = false;
+ _doorExit._enabled = false;
+ _northExit._insideArea = false;
+ _upExit._insideArea = false;
+ _eastExit._insideArea = false;
+ _downExit._insideArea = false;
+ _southExit._insideArea = false;
+ _westExit._insideArea = false;
+ _shaftExit._insideArea = false;
+ _doorExit._insideArea = false;
+ _northExit._moving = false;
+ _upExit._moving = false;
+ _eastExit._moving = false;
+ _downExit._moving = false;
+ _southExit._moving = false;
+ _westExit._moving = false;
+ _shaftExit._moving = false;
+ _doorExit._moving = false;
+ _upExitStyle = false;
+
+ switch (R2_GLOBALS._flubMazeArea - 1) {
+ case 0:
+ loadScene(1948);
+ break;
+ case 1:
+ // No break on purpose
+ case 8:
+ // No break on purpose
+ case 10:
+ // No break on purpose
+ case 12:
+ // No break on purpose
+ case 16:
+ // No break on purpose
+ case 19:
+ // No break on purpose
+ case 23:
+ // No break on purpose
+ case 30:
+ // No break on purpose
+ case 44:
+ // No break on purpose
+ case 72:
+ // No break on purpose
+ case 74:
+ // No break on purpose
+ case 86:
+ // No break on purpose
+ case 96:
+ // No break on purpose
+ case 103:
+ loadScene(1950);
+ break;
+ case 2:
+ // No break on purpose
+ case 29:
+ loadScene(1965);
+ break;
+ case 3:
+ // No break on purpose
+ case 9:
+ // No break on purpose
+ case 11:
+ // No break on purpose
+ case 15:
+ // No break on purpose
+ case 24:
+ // No break on purpose
+ case 39:
+ // No break on purpose
+ case 45:
+ // No break on purpose
+ case 71:
+ // No break on purpose
+ case 73:
+ // No break on purpose
+ case 75:
+ // No break on purpose
+ case 79:
+ // No break on purpose
+ case 85:
+ // No break on purpose
+ case 87:
+ // No break on purpose
+ case 95:
+ loadScene(1955);
+ break;
+ case 4:
+ // No break on purpose
+ case 6:
+ // No break on purpose
+ case 13:
+ // No break on purpose
+ case 27:
+ // No break on purpose
+ case 41:
+ // No break on purpose
+ case 48:
+ // No break on purpose
+ case 50:
+ // No break on purpose
+ case 54:
+ // No break on purpose
+ case 76:
+ // No break on purpose
+ case 80:
+ // No break on purpose
+ case 90:
+ // No break on purpose
+ case 104:
+ loadScene(1975);
+ break;
+ case 5:
+ // No break on purpose
+ case 7:
+ // No break on purpose
+ case 14:
+ // No break on purpose
+ case 28:
+ // No break on purpose
+ case 32:
+ // No break on purpose
+ case 47:
+ // No break on purpose
+ case 53:
+ loadScene(1997);
+ break;
+ case 17:
+ // No break on purpose
+ case 20:
+ // No break on purpose
+ case 25:
+ // No break on purpose
+ case 31:
+ // No break on purpose
+ case 33:
+ // No break on purpose
+ case 46:
+ loadScene(1995);
+ break;
+ case 18:
+ // No break on purpose
+ case 22:
+ // No break on purpose
+ case 26:
+ // No break on purpose
+ case 36:
+ // No break on purpose
+ case 38:
+ // No break on purpose
+ case 43:
+ // No break on purpose
+ case 51:
+ // No break on purpose
+ case 70:
+ // No break on purpose
+ case 78:
+ // No break on purpose
+ case 84:
+ // No break on purpose
+ case 89:
+ // No break on purpose
+ case 101:
+ loadScene(1970);
+ break;
+ case 21:
+ // No break on purpose
+ case 34:
+ // No break on purpose
+ case 57:
+ // No break on purpose
+ case 58:
+ // No break on purpose
+ case 59:
+ // No break on purpose
+ case 62:
+ // No break on purpose
+ case 65:
+ loadScene(1980);
+ break;
+ case 35:
+ // No break on purpose
+ case 61:
+ // No break on purpose
+ case 77:
+ // No break on purpose
+ case 83:
+ loadScene(1982);
+ break;
+ case 37:
+ // No break on purpose
+ case 52:
+ // No break on purpose
+ case 82:
+ // No break on purpose
+ case 88:
+ // No break on purpose
+ case 92:
+ // No break on purpose
+ case 97:
+ // No break on purpose
+ case 100:
+ loadScene(1962);
+ break;
+ case 40:
+ // No break on purpose
+ case 102:
+ loadScene(1960);
+ break;
+ case 42:
+ // No break on purpose
+ case 55:
+ // No break on purpose
+ case 60:
+ // No break on purpose
+ case 66:
+ // No break on purpose
+ case 68:
+ // No break on purpose
+ case 69:
+ // No break on purpose
+ case 93:
+ // No break on purpose
+ case 98:
+ loadScene(1990);
+ break;
+ case 49:
+ // No break on purpose
+ case 81:
+ // No break on purpose
+ case 91:
+ // No break on purpose
+ case 94:
+ // No break on purpose
+ case 99:
+ loadScene(1967);
+ break;
+ case 56:
+ // No break on purpose
+ case 63:
+ // No break on purpose
+ case 64:
+ // No break on purpose
+ case 67:
+ loadScene(1985);
+ _upExitStyle = true;
+ break;
+ default:
+ break;
+ }
+
+ if (R2_GLOBALS._flubMazeArea != 1)
+ R2_GLOBALS._walkRegions.load(1950);
+
+ switch (R2_GLOBALS._flubMazeArea - 1) {
+ case 0:
+ _shaftExit._enabled = true;
+ if ((R2_INVENTORY.getObjectScene(R2_SCRITH_KEY) == 0) && (R2_INVENTORY.getObjectScene(R2_SAPPHIRE_BLUE) == 1950))
+ _doorExit._enabled = true;
+ R2_GLOBALS._walkRegions.disableRegion(2);
+ R2_GLOBALS._walkRegions.disableRegion(3);
+ R2_GLOBALS._walkRegions.disableRegion(4);
+ R2_GLOBALS._walkRegions.disableRegion(5);
+ R2_GLOBALS._walkRegions.disableRegion(6);
+ break;
+ case 1:
+ // No break on purpose
+ case 2:
+ // No break on purpose
+ case 3:
+ // No break on purpose
+ case 8:
+ // No break on purpose
+ case 9:
+ // No break on purpose
+ case 10:
+ // No break on purpose
+ case 11:
+ // No break on purpose
+ case 12:
+ // No break on purpose
+ case 15:
+ // No break on purpose
+ case 16:
+ // No break on purpose
+ case 19:
+ // No break on purpose
+ case 23:
+ // No break on purpose
+ case 24:
+ // No break on purpose
+ case 29:
+ // No break on purpose
+ case 30:
+ // No break on purpose
+ case 39:
+ // No break on purpose
+ case 40:
+ // No break on purpose
+ case 44:
+ // No break on purpose
+ case 45:
+ // No break on purpose
+ case 71:
+ // No break on purpose
+ case 72:
+ // No break on purpose
+ case 73:
+ // No break on purpose
+ case 74:
+ // No break on purpose
+ case 75:
+ // No break on purpose
+ case 79:
+ // No break on purpose
+ case 85:
+ // No break on purpose
+ case 86:
+ // No break on purpose
+ case 87:
+ // No break on purpose
+ case 95:
+ // No break on purpose
+ case 96:
+ // No break on purpose
+ case 102:
+ // No break on purpose
+ case 103:
+ _eastExit._enabled = true;
+ _westExit._enabled = true;
+ break;
+ case 4:
+ // No break on purpose
+ case 6:
+ // No break on purpose
+ case 13:
+ // No break on purpose
+ case 17:
+ // No break on purpose
+ case 20:
+ // No break on purpose
+ case 25:
+ // No break on purpose
+ case 27:
+ // No break on purpose
+ case 31:
+ // No break on purpose
+ case 33:
+ // No break on purpose
+ case 37:
+ // No break on purpose
+ case 41:
+ // No break on purpose
+ case 46:
+ // No break on purpose
+ case 48:
+ // No break on purpose
+ case 50:
+ // No break on purpose
+ case 52:
+ // No break on purpose
+ case 54:
+ // No break on purpose
+ case 76:
+ // No break on purpose
+ case 80:
+ // No break on purpose
+ case 82:
+ // No break on purpose
+ case 88:
+ // No break on purpose
+ case 90:
+ // No break on purpose
+ case 92:
+ // No break on purpose
+ case 97:
+ // No break on purpose
+ case 100:
+ // No break on purpose
+ case 104:
+ _westExit._enabled = true;
+ R2_GLOBALS._walkRegions.disableRegion(6);
+ R2_GLOBALS._walkRegions.disableRegion(9);
+ break;
+ case 5:
+ // No break on purpose
+ case 7:
+ // No break on purpose
+ case 14:
+ // No break on purpose
+ case 18:
+ // No break on purpose
+ case 22:
+ // No break on purpose
+ case 26:
+ // No break on purpose
+ case 28:
+ // No break on purpose
+ case 32:
+ // No break on purpose
+ case 36:
+ // No break on purpose
+ case 38:
+ // No break on purpose
+ case 43:
+ // No break on purpose
+ case 47:
+ // No break on purpose
+ case 49:
+ // No break on purpose
+ case 51:
+ // No break on purpose
+ case 53:
+ // No break on purpose
+ case 70:
+ // No break on purpose
+ case 78:
+ // No break on purpose
+ case 81:
+ // No break on purpose
+ case 84:
+ // No break on purpose
+ case 89:
+ // No break on purpose
+ case 91:
+ // No break on purpose
+ case 94:
+ // No break on purpose
+ case 99:
+ // No break on purpose
+ case 101:
+ _eastExit._enabled = true;
+ R2_GLOBALS._walkRegions.disableRegion(1);
+ R2_GLOBALS._walkRegions.disableRegion(7);
+ R2_GLOBALS._walkRegions.disableRegion(13);
+ break;
+ default:
+ R2_GLOBALS._walkRegions.disableRegion(1);
+ R2_GLOBALS._walkRegions.disableRegion(6);
+ R2_GLOBALS._walkRegions.disableRegion(7);
+ R2_GLOBALS._walkRegions.disableRegion(9);
+ R2_GLOBALS._walkRegions.disableRegion(13);
+ break;
+ }
+
+ _northDoorway.remove();
+ _northDoorway.removeObject();
+ _southDoorway.remove();
+
+ switch (R2_GLOBALS._flubMazeArea - 4) {
+ case 0:
+ // No break on purpose
+ case 3:
+ // No break on purpose
+ case 16:
+ // No break on purpose
+ case 22:
+ // No break on purpose
+ case 24:
+ // No break on purpose
+ case 32:
+ // No break on purpose
+ case 33:
+ // No break on purpose
+ case 45:
+ // No break on purpose
+ case 46:
+ // No break on purpose
+ case 48:
+ // No break on purpose
+ case 51:
+ // No break on purpose
+ case 56:
+ // No break on purpose
+ case 59:
+ // No break on purpose
+ case 67:
+ // No break on purpose
+ case 68:
+ // No break on purpose
+ case 70:
+ // No break on purpose
+ case 73:
+ // No break on purpose
+ case 82:
+ // No break on purpose
+ case 90:
+ _northExit._enabled = true;
+ _northDoorway.setup(1950, (R2_GLOBALS._flubMazeArea % 2) + 1, 1, 160, 137, 25);
+ //visage,strip,frame,px,py,priority,effect
+ _southDoorway.postInit();
+ _southDoorway.setVisage(1950);
+ _southDoorway.setStrip((((R2_GLOBALS._flubMazeArea - 1) / 35) % 2) + 1);
+ _southDoorway.setFrame(2);
+ _southDoorway.setPosition(Common::Point(160, 167));
+ _southDoorway.fixPriority(220);
+ R2_GLOBALS._walkRegions.disableRegion(3);
+ R2_GLOBALS._walkRegions.disableRegion(4);
+ break;
+ case 7:
+ // No break on purpose
+ case 10:
+ // No break on purpose
+ case 23:
+ // No break on purpose
+ case 29:
+ // No break on purpose
+ case 31:
+ // No break on purpose
+ case 39:
+ // No break on purpose
+ case 40:
+ // No break on purpose
+ case 52:
+ // No break on purpose
+ case 53:
+ // No break on purpose
+ case 55:
+ // No break on purpose
+ case 63:
+ // No break on purpose
+ case 65:
+ // No break on purpose
+ case 66:
+ // No break on purpose
+ case 75:
+ // No break on purpose
+ case 77:
+ // No break on purpose
+ case 81:
+ // No break on purpose
+ case 87:
+ // No break on purpose
+ case 89:
+ // No break on purpose
+ case 97:
+ _southExit._enabled = true;
+
+ _southDoorway.postInit();
+ _southDoorway.setVisage(1950);
+ _southDoorway.setStrip((((R2_GLOBALS._flubMazeArea - 1) / 35) % 2) + 1);
+ _southDoorway.setFrame(3);
+ _southDoorway.setPosition(Common::Point(160, 167));
+ _southDoorway.fixPriority(220);
+ break;
+ case 58:
+ // No break on purpose
+ case 74:
+ // No break on purpose
+ case 80:
+ _northExit._enabled = true;
+ _southExit._enabled = true;
+
+ _northDoorway.setup(1950, (R2_GLOBALS._flubMazeArea % 2) + 1, 1, 160, 137, 25);
+
+ _southDoorway.postInit();
+ _southDoorway.setVisage(1950);
+ _southDoorway.setStrip((((R2_GLOBALS._flubMazeArea - 1) / 35) % 2) + 1);
+ _southDoorway.setFrame(3);
+ _southDoorway.setPosition(Common::Point(160, 167));
+ _southDoorway.fixPriority(220);
+ R2_GLOBALS._walkRegions.disableRegion(3);
+ R2_GLOBALS._walkRegions.disableRegion(4);
+ break;
+ default:
+ _southDoorway.postInit();
+ _southDoorway.setVisage(1950);
+ _southDoorway.setStrip(((R2_GLOBALS._flubMazeArea - 1) / 35) % 2 + 1);
+ _southDoorway.setFrame(2);
+ _southDoorway.setPosition(Common::Point(160, 167));
+ _southDoorway.fixPriority(220);
+ break;
+ }
+
+ switch (R2_GLOBALS._flubMazeArea - 3) {
+ case 0:
+ // No break on purpose
+ case 3:
+ // No break on purpose
+ case 5:
+ // No break on purpose
+ case 12:
+ // No break on purpose
+ case 15:
+ // No break on purpose
+ case 18:
+ // No break on purpose
+ case 19:
+ // No break on purpose
+ case 23:
+ // No break on purpose
+ case 26:
+ // No break on purpose
+ case 27:
+ // No break on purpose
+ case 29:
+ // No break on purpose
+ case 30:
+ // No break on purpose
+ case 31:
+ // No break on purpose
+ case 32:
+ // No break on purpose
+ case 44:
+ // No break on purpose
+ case 45:
+ // No break on purpose
+ case 51:
+ // No break on purpose
+ case 55:
+ // No break on purpose
+ case 56:
+ // No break on purpose
+ case 57:
+ // No break on purpose
+ case 60:
+ // No break on purpose
+ case 63:
+ _upExit._enabled = true;
+ break;
+ case 54:
+ // No break on purpose
+ case 61:
+ // No break on purpose
+ case 62:
+ // No break on purpose
+ case 65:
+ _upExit._enabled = true;
+ // No break on purpose
+ case 35:
+ // No break on purpose
+ case 38:
+ // No break on purpose
+ case 40:
+ // No break on purpose
+ case 47:
+ // No break on purpose
+ case 50:
+ // No break on purpose
+ case 53:
+ // No break on purpose
+ case 58:
+ // No break on purpose
+ case 64:
+ // No break on purpose
+ case 66:
+ // No break on purpose
+ case 67:
+ // No break on purpose
+ case 79:
+ // No break on purpose
+ case 80:
+ // No break on purpose
+ case 86:
+ // No break on purpose
+ case 89:
+ // No break on purpose
+ case 90:
+ // No break on purpose
+ case 91:
+ // No break on purpose
+ case 92:
+ // No break on purpose
+ case 95:
+ // No break on purpose
+ case 96:
+ // No break on purpose
+ case 97:
+ // No break on purpose
+ case 98:
+ // No break on purpose
+ case 100:
+ _downExit._enabled = true;
+ R2_GLOBALS._walkRegions.disableRegion(4);
+ R2_GLOBALS._walkRegions.disableRegion(5);
+ R2_GLOBALS._walkRegions.disableRegion(6);
+ R2_GLOBALS._walkRegions.disableRegion(10);
+ R2_GLOBALS._walkRegions.disableRegion(11);
+ default:
+ break;
+ }
+ R2_GLOBALS._uiElements.draw();
+}
+
+void Scene1950::enterArea() {
+ R2_GLOBALS._player.disableControl();
+ R2_GLOBALS._player.animate(ANIM_MODE_1, NULL);
+
+ _vampire.remove();
+ _door.remove();
+ _scrolls.remove();
+
+ _vampireActive = false;
+ _vampireIndex = 0;
+
+ // Certain areas have a vampire in them
+ switch (R2_GLOBALS._flubMazeArea) {
+ case 10:
+ _vampireIndex = 1;
+ break;
+ case 13:
+ _vampireIndex = 2;
+ break;
+ case 16:
+ _vampireIndex = 3;
+ break;
+ case 17:
+ _vampireIndex = 4;
+ break;
+ case 24:
+ _vampireIndex = 5;
+ break;
+ case 25:
+ _vampireIndex = 6;
+ break;
+ case 31:
+ _vampireIndex = 7;
+ break;
+ case 40:
+ _vampireIndex = 8;
+ break;
+ case 45:
+ _vampireIndex = 9;
+ break;
+ case 46:
+ _vampireIndex = 10;
+ break;
+ case 73:
+ _vampireIndex = 11;
+ break;
+ case 75:
+ _vampireIndex = 12;
+ break;
+ case 80:
+ _vampireIndex = 13;
+ break;
+ case 87:
+ _vampireIndex = 14;
+ break;
+ case 88:
+ _vampireIndex = 15;
+ break;
+ case 96:
+ _vampireIndex = 16;
+ break;
+ case 97:
+ _vampireIndex = 17;
+ break;
+ case 104:
+ _vampireIndex = 18;
+ break;
+ default:
+ break;
+ }
+
+ if (_vampireIndex != 0) {
+ _vampire.postInit();
+ _vampire._numFrames = 6;
+ _vampire._moveRate = 6;
+ _vampire._moveDiff = Common::Point(3, 2);
+ _vampire._effect = EFFECT_SHADED;
+
+ if (!R2_GLOBALS._vampireData[_vampireIndex - 1]._isAlive) {
+ // Show vampire ashes
+ _vampire.setPosition(Common::Point(R2_GLOBALS._vampireData[_vampireIndex - 1]._position));
+ _vampire.animate(ANIM_MODE_NONE, NULL);
+ _vampire.addMover(NULL);
+ _vampire.setVisage(1961);
+ _vampire.setStrip(4);
+ _vampire.setFrame(10);
+ _vampire.fixPriority(10);
+ _vampire.setDetails(1950, 15, -1, 17, 2, (SceneItem *) NULL);
+ } else {
+ // Start the vampire
+ _vampire.setVisage(1960);
+ _vampire.setPosition(Common::Point(160, 130));
+ _vampire.animate(ANIM_MODE_2, NULL);
+ _vampire.setDetails(1950, 12, -1, 14, 2, (SceneItem *) NULL);
+ _vampireActive = true;
+ }
+ }
+ if ((R2_GLOBALS._flubMazeArea == 1) && (R2_INVENTORY.getObjectScene(R2_SCRITH_KEY) != 0)) {
+ // Show doorway at the right hand side of the very first flub corridor
+ _door.postInit();
+ _door.setVisage(1948);
+ _door.setStrip(3);
+ _door.setPosition(Common::Point(278, 155));
+ _door.fixPriority(100);
+ _door.setDetails(1950, 19, 20, 23, 2, (SceneItem *) NULL);
+ }
+
+ if (R2_GLOBALS._flubMazeArea == 102) {
+ R2_GLOBALS._walkRegions.load(1951);
+ R2_GLOBALS._walkRegions.disableRegion(1);
+ R2_GLOBALS._walkRegions.disableRegion(5);
+ R2_GLOBALS._walkRegions.disableRegion(6);
+ R2_GLOBALS._walkRegions.disableRegion(7);
+
+ _cube.postInit();
+ _cube.setVisage(1970);
+ _cube.setStrip(1);
+ if (R2_GLOBALS.getFlag(37))
+ _cube.setFrame(3);
+ else
+ _cube.setFrame(1);
+ _cube.setPosition(Common::Point(193, 158));
+ _cube.setDetails(1950, 3, 4, 5, 2, (SceneItem *) NULL);
+
+ _pulsingLights.postInit();
+ _pulsingLights.setVisage(1970);
+ _pulsingLights.setStrip(3);
+ _pulsingLights.animate(ANIM_MODE_2, NULL);
+ _pulsingLights._numFrames = 6;
+ _pulsingLights.setPosition(Common::Point(194, 158));
+ _pulsingLights.fixPriority(159);
+
+ _keypad.setDetails(Rect(188, 124, 199, 133), 1950, 27, 28, -1, 2, NULL);
+
+ if (R2_INVENTORY.getObjectScene(R2_SAPPHIRE_BLUE) == 1950) {
+ _gem.postInit();
+ _gem.setVisage(1970);
+ _gem.setStrip(1);
+ _gem.setFrame(2);
+ _gem.fixPriority(160);
+ }
+
+ if (R2_GLOBALS.getFlag(37)) {
+ _gem.setPosition(Common::Point(192, 118));
+ _gem.setDetails(1950, 9, 4, -1, 2, (SceneItem *) NULL);
+ } else {
+ _containmentField.postInit();
+ _containmentField.setVisage(1970);
+ _containmentField.setStrip(4);
+ _containmentField._numFrames = 4;
+ _containmentField.animate(ANIM_MODE_8, 0, NULL);
+ _containmentField.setPosition(Common::Point(192, 121));
+ _containmentField.fixPriority(159);
+ _containmentField.setDetails(1950, 6, 7, 8, 2, (SceneItem *) NULL);
+
+ _gem.setPosition(Common::Point(192, 109));
+ _gem.setDetails(1950, 9, 7, 8, 2, (SceneItem *) NULL);
+ }
+
+ _scrolls.postInit();
+ _scrolls.setVisage(1972);
+ _scrolls.setStrip(1);
+ _scrolls.setPosition(Common::Point(76, 94));
+ _scrolls.fixPriority(25);
+ _scrolls.setDetails(1950, 30, -1, -1, 2, (SceneItem *) NULL);
+ if (R2_INVENTORY.getObjectScene(R2_ANCIENT_SCROLLS) == 2)
+ _scrolls.setFrame(2);
+ else
+ _scrolls.setFrame(1);
+
+ _removeFlag = true;
+ } else if (_removeFlag) {
+ _cube.remove();
+ _containmentField.remove();
+ _gem.remove();
+ _pulsingLights.remove();
+ _scrolls.remove();
+
+ R2_GLOBALS._sceneItems.remove(&_background);
+ _background.setDetails(Rect(0, 0, 320, 200), 1950, 0, 1, 2, 2, NULL);
+
+ _removeFlag = false;
+ }
+
+ switch (R2_GLOBALS._flubMazeEntryDirection) {
+ case 0:
+ _sceneMode = 1950;
+ if (R2_INVENTORY.getObjectScene(R2_SCRITH_KEY) == 0)
+ // The original uses CURSOR_ARROW. CURSOR_WALK is much more coherent
+ R2_GLOBALS._player.enableControl(CURSOR_WALK);
+ else
+ setAction(&_sequenceManager, this, 1950, &R2_GLOBALS._player, NULL);
+
+ break;
+ case 1: {
+ _sceneMode = R2_GLOBALS._flubMazeEntryDirection;
+ R2_GLOBALS._player.setPosition(Common::Point(160, 213));
+ Common::Point pt(160, 160);
+ NpcMover *mover = new NpcMover();
+ R2_GLOBALS._player.addMover(mover, &pt, this);
+ }
+ break;
+ case 2:
+ _sceneMode = R2_GLOBALS._flubMazeEntryDirection;
+ if (R2_GLOBALS.getFlag(36))
+ setAction(&_sequenceManager, this, 1957, &R2_GLOBALS._player, NULL);
+ else
+ setAction(&_sequenceManager, this, 1974, &R2_GLOBALS._player, NULL);
+ break;
+ case 3:
+ // Entering from the left
+ if (!_vampireActive) {
+ _sceneMode = R2_GLOBALS._flubMazeEntryDirection;
+ R2_GLOBALS._player.setPosition(Common::Point(-20, 160));
+ Common::Point pt(30, 160);
+ NpcMover *mover = new NpcMover();
+ R2_GLOBALS._player.addMover(mover, &pt, this);
+ } else {
+ _sceneMode = 18;
+ _eastExit._enabled = false;
+ _vampireDestPos = Common::Point(60, 152);
+ R2_GLOBALS._player.enableControl(CURSOR_USE);
+ R2_GLOBALS._player._canWalk = false;
+
+ _vampire.setStrip(2);
+ NpcMover *mover = new NpcMover();
+ _vampire.addMover(mover, &_vampireDestPos, this);
+
+ R2_GLOBALS._player.setPosition(Common::Point(-20, 160));
+ Common::Point pt2(30, 160);
+ NpcMover *mover2 = new NpcMover();
+ R2_GLOBALS._player.addMover(mover2, &pt2, NULL);
+ }
+ break;
+ case 4:
+ _sceneMode = R2_GLOBALS._flubMazeEntryDirection;
+ if (!_upExitStyle) {
+ if (R2_GLOBALS.getFlag(36))
+ setAction(&_sequenceManager, this, 1955, &R2_GLOBALS._player, NULL);
+ else
+ setAction(&_sequenceManager, this, 1972, &R2_GLOBALS._player, NULL);
+ } else {
+ if (R2_GLOBALS.getFlag(36))
+ setAction(&_sequenceManager, this, 1954, &R2_GLOBALS._player, NULL);
+ else
+ setAction(&_sequenceManager, this, 1971, &R2_GLOBALS._player, NULL);
+ }
+ break;
+ case 5: {
+ _sceneMode = R2_GLOBALS._flubMazeEntryDirection;
+ R2_GLOBALS._player.setPosition(Common::Point(160, 127));
+ Common::Point pt(160, 160);
+ NpcMover *mover = new NpcMover();
+ R2_GLOBALS._player.addMover(mover, &pt, this);
+ }
+ break;
+ case 6:
+ // Entering from the right
+ if (!_vampireActive) {
+ _sceneMode = R2_GLOBALS._flubMazeEntryDirection;
+ if (R2_GLOBALS._flubMazeArea == 1) {
+ setAction(&_sequenceManager, this, 1961, &R2_GLOBALS._player, NULL);
+ } else {
+ R2_GLOBALS._player.setPosition(Common::Point(340, 160));
+ Common::Point pt(289, 160);
+ NpcMover *mover = new NpcMover();
+ R2_GLOBALS._player.addMover(mover, &pt, this);
+ }
+ } else {
+ _sceneMode = 17;
+ _westExit._enabled = false;
+ _vampireDestPos = Common::Point(259, 152);
+
+ R2_GLOBALS._player.enableControl(CURSOR_USE);
+ R2_GLOBALS._player._canWalk = false;
+
+ _vampire.setStrip(1);
+ NpcMover *mover = new NpcMover();
+ _vampire.addMover(mover, &_vampireDestPos, this);
+
+ R2_GLOBALS._player.setPosition(Common::Point(340, 160));
+ Common::Point pt2(289, 160);
+ NpcMover *mover2 = new NpcMover();
+ R2_GLOBALS._player.addMover(mover2, &pt2, NULL);
+ }
+ break;
+ default:
+ break;
+ }
+}
+
+void Scene1950::doButtonPress(int indx) {
+ Scene1950 *scene = (Scene1950 *)R2_GLOBALS._sceneManager._scene;
+ R2_GLOBALS._player.disableControl();
+
+ int prevIndex = indx - 1;
+ if ((indx / 4) == (prevIndex / 4)) {
+ if (prevIndex < 0)
+ prevIndex = 3;
+ } else {
+ prevIndex += 4;
+ }
+
+ assert(prevIndex >= 0 && prevIndex < 16);
+ if (!_KeypadWindow._buttons[prevIndex]._toggled) {
+ _KeypadWindow._buttons[prevIndex].setFrame(2);
+ _KeypadWindow._buttons[prevIndex]._toggled = true;
+ } else {
+ _KeypadWindow._buttons[prevIndex].setFrame(1);
+ _KeypadWindow._buttons[prevIndex]._toggled = false;
+ }
+
+ prevIndex = indx + 1;
+ if ((indx / 4) == (prevIndex / 4)) {
+ if (prevIndex > 15)
+ prevIndex = 12;
+ } else {
+ prevIndex -= 4;
+ }
+
+ assert(prevIndex >= 0 && prevIndex < 16);
+ if (!_KeypadWindow._buttons[prevIndex]._toggled) {
+ _KeypadWindow._buttons[prevIndex].setFrame(2);
+ _KeypadWindow._buttons[prevIndex]._toggled = true;
+ } else {
+ _KeypadWindow._buttons[prevIndex].setFrame(1);
+ _KeypadWindow._buttons[prevIndex]._toggled = false;
+ }
+
+ prevIndex = indx - 4;
+ if (prevIndex < 0)
+ prevIndex += 16;
+
+ assert(prevIndex >= 0 && prevIndex < 16);
+ if (!_KeypadWindow._buttons[prevIndex]._toggled) {
+ _KeypadWindow._buttons[prevIndex].setFrame(2);
+ _KeypadWindow._buttons[prevIndex]._toggled = true;
+ } else {
+ _KeypadWindow._buttons[prevIndex].setFrame(1);
+ _KeypadWindow._buttons[prevIndex]._toggled = false;
+ }
+
+ prevIndex = indx + 4;
+ if (prevIndex > 15)
+ prevIndex -= 16;
+
+ assert(prevIndex >= 0 && prevIndex < 16);
+ if (!_KeypadWindow._buttons[prevIndex]._toggled) {
+ _KeypadWindow._buttons[prevIndex].setFrame(2);
+ _KeypadWindow._buttons[prevIndex]._toggled = true;
+ } else {
+ _KeypadWindow._buttons[prevIndex].setFrame(1);
+ _KeypadWindow._buttons[prevIndex]._toggled = false;
+ }
+
+ // Check whether all the buttons are highlighted
+ int cpt = 0;
+ for (prevIndex = 0; prevIndex < 16; prevIndex++) {
+ if (_KeypadWindow._buttons[prevIndex]._toggled)
+ ++cpt;
+ }
+
+ if (cpt != 16) {
+ R2_GLOBALS._player.enableControl();
+ R2_GLOBALS._player._canWalk = false;
+ } else {
+ R2_GLOBALS.setFlag(37);
+ _sceneMode = 24;
+ setAction(&_sequenceManager, scene, 1976, NULL);
+ }
+}
+
+void Scene1950::postInit(SceneObjectList *OwnerList) {
+ _upExitStyle = false;
+ _removeFlag = false;
+ _vampireActive = false;
+ _vampireIndex = 0;
+ if (R2_GLOBALS._sceneManager._previousScene == 300)
+ R2_GLOBALS._flubMazeArea = 103;
+
+ initArea();
+ SceneExt::postInit();
+ R2_GLOBALS._sound1.play(105);
+
+ _northExit.setDetails(Rect(130, 46, 189, 135), SHADECURSOR_UP, 1950);
+ _northExit.setDest(Common::Point(160, 145));
+
+ _upExit.setDetails(Rect(208, 0, 255, 73), EXITCURSOR_N, 1950);
+ _upExit.setDest(Common::Point(200, 151));
+
+ _eastExit.setDetails(Rect(305, 95, 320, 147), EXITCURSOR_E, 1950);
+ _eastExit.setDest(Common::Point(312, 160));
+
+ _downExit.setDetails(Rect(208, 99, 255, 143), EXITCURSOR_S, 1950);
+ _downExit.setDest(Common::Point(200, 151));
+
+ _southExit.setDetails(Rect(113, 154, 206, 168), SHADECURSOR_DOWN, 1950);
+ _southExit.setDest(Common::Point(160, 165));
+
+ _westExit.setDetails(Rect(0, 95, 14, 147), EXITCURSOR_W, 1950);
+ _westExit.setDest(Common::Point(7, 160));
+
+ _shaftExit.setDetails(Rect(72, 54, 120, 128), EXITCURSOR_NW, 1950);
+ _shaftExit.setDest(Common::Point(120, 140));
+
+ _doorExit.setDetails(Rect(258, 60, 300, 145), EXITCURSOR_NE, 1950);
+ _doorExit.setDest(Common::Point(268, 149));
+
+ R2_GLOBALS._player.postInit();
+ if ( (R2_INVENTORY.getObjectScene(R2_TANNER_MASK) == 0) && (R2_INVENTORY.getObjectScene(R2_PURE_GRAIN_ALCOHOL) == 0)
+ && (R2_INVENTORY.getObjectScene(R2_SOAKED_FACEMASK) == 0) && (!R2_GLOBALS.getFlag(36)) )
+ R2_GLOBALS._player.setVisage(22);
+ else
+ R2_GLOBALS._player.setVisage(20);
+
+ R2_GLOBALS._player._moveDiff = Common::Point(5, 3);
+ _background.setDetails(Rect(0, 0, 320, 200), 1950, 0, 1, 2, 1, NULL);
+
+ enterArea();
+}
+
+void Scene1950::remove() {
+ R2_GLOBALS._sound1.stop();
+ R2_GLOBALS._sound2.fadeOut2(NULL);
+ SceneExt::remove();
+}
+
+void Scene1950::signal() {
+ switch (_sceneMode) {
+ case 11:
+ R2_GLOBALS._flubMazeArea += 7;
+ initArea();
+ enterArea();
+ break;
+ case 12:
+ // Moving up a ladder within the Flub maze
+ R2_GLOBALS._flubMazeArea += 35;
+ initArea();
+ enterArea();
+ break;
+ case 1975:
+ SceneItem::display(1950, 21, SET_WIDTH, 280, SET_X, 160, SET_POS_MODE, 1,
+ SET_Y, 20, SET_EXT_BGCOLOR, 7, LIST_END);
+ // No break on purpose
+ case 13:
+ // Moving east within the Flub maze
+ ++R2_GLOBALS._flubMazeArea;
+ initArea();
+ enterArea();
+ break;
+ case 14:
+ // Moving down a ladder within the Flub maze
+ R2_GLOBALS._flubMazeArea -= 35;
+ initArea();
+ enterArea();
+ break;
+ case 15:
+ R2_GLOBALS._flubMazeArea -= 7;
+ initArea();
+ enterArea();
+ break;
+ case 16:
+ // Moving west within the Flub maze
+ // No break on purpose
+ case 1961:
+ --R2_GLOBALS._flubMazeArea;
+ initArea();
+ enterArea();
+ break;
+ case 17: {
+ _sceneMode = 13;
+ R2_GLOBALS._flubMazeEntryDirection = 3;
+ _vampireActive = false;
+ R2_GLOBALS._player.disableControl(CURSOR_WALK);
+ R2_GLOBALS._player._canWalk = true;
+ R2_GLOBALS._player.setVisage(22);
+ R2_GLOBALS._player.animate(ANIM_MODE_9);
+ Common::Point pt(340, 160);
+ NpcMover *mover = new NpcMover();
+ R2_GLOBALS._player.addMover(mover, &pt, this);
+ Common::Point pt2(289, 160);
+ NpcMover *mover2 = new NpcMover();
+ _vampire.addMover(mover2, &pt2, NULL);
+ }
+ break;
+ case 18: {
+ _sceneMode = 16;
+ R2_GLOBALS._flubMazeEntryDirection = 6;
+ _vampireActive = false;
+ R2_GLOBALS._player.disableControl(CURSOR_WALK);
+ R2_GLOBALS._player._canWalk = true;
+ R2_GLOBALS._player.setVisage(22);
+ R2_GLOBALS._player.animate(ANIM_MODE_9);
+ Common::Point pt(-20, 160);
+ NpcMover *mover = new NpcMover();
+ R2_GLOBALS._player.addMover(mover, &pt, this);
+ Common::Point pt2(30, 160);
+ NpcMover *mover2 = new NpcMover();
+ _vampire.addMover(mover2, &pt2, NULL);
+ }
+ break;
+ case 24:
+ _KeypadWindow.remove();
+ _sceneMode = 1966;
+ _cube.setFrame(3);
+ setAction(&_sequenceManager, this, 1966, &_containmentField, &_gem, NULL);
+ break;
+ case 1951:
+ R2_GLOBALS._sound1.fadeOut2(NULL);
+ R2_GLOBALS._sceneManager.changeScene(1945);
+ break;
+ case 1958:
+ SceneItem::display(1950, 24, 0, 280, 1, 160, 9, 1, 2, 20, 7, 7, LIST_END);
+ R2_GLOBALS._player.enableControl(CURSOR_WALK);
+ _doorExit._enabled = true;
+ break;
+ case 1959:
+ R2_INVENTORY.setObjectScene(R2_SOAKED_FACEMASK, 0);
+ R2_GLOBALS._player.enableControl(CURSOR_WALK);
+ _doorExit._enabled = true;
+ break;
+ case 1962:
+ // No break on purpose
+ case 1963:
+ R2_GLOBALS._player.enableControl();
+ _KeypadWindow.setup2(1971, 1, 1, 160, 135);
+ break;
+ case 1964:
+ // No break on purpose
+ case 1965:
+ if (!R2_GLOBALS.getFlag(37))
+ SceneItem::display(1950, 26, 0, 280, 1, 160, 9, 1, 2, 20, 7, 7, LIST_END);
+
+ R2_GLOBALS._player.enableControl();
+ break;
+ case 1966:
+ _containmentField.remove();
+ if (R2_GLOBALS.getFlag(36)) {
+ _sceneMode = 1964;
+ setAction(&_sequenceManager, this, 1964, &R2_GLOBALS._player, NULL);
+ } else {
+ _sceneMode = 1965;
+ setAction(&_sequenceManager, this, 1965, &R2_GLOBALS._player, NULL);
+ }
+ _gem.setDetails(1950, 9, -1, -1, 2, (SceneItem *) NULL);
+ break;
+ case 1967: {
+ _sceneMode = 0;
+ R2_INVENTORY.setObjectScene(R2_SAPPHIRE_BLUE, 2);
+ _gem.remove();
+ if (R2_GLOBALS.getFlag(36))
+ R2_GLOBALS._player.setVisage(20);
+ else
+ R2_GLOBALS._player.setVisage(22);
+
+ R2_GLOBALS._player.animate(ANIM_MODE_1, NULL);
+ // This is a hack to work around a pathfinding issue. original destination is (218, 165)
+ Common::Point pt(128, 165);
+ NpcMover *mover = new NpcMover();
+ R2_GLOBALS._player.addMover(mover, &pt, this);
+ }
+ break;
+ case 1968:
+ R2_GLOBALS._player.enableControl();
+ R2_INVENTORY.setObjectScene(R2_ANCIENT_SCROLLS, 2);
+ _scrolls.setFrame(2);
+ if (R2_GLOBALS.getFlag(36))
+ R2_GLOBALS._player.setVisage(20);
+ else
+ R2_GLOBALS._player.setVisage(22);
+ R2_GLOBALS._player.animate(ANIM_MODE_1, NULL);
+ break;
+ default:
+ R2_GLOBALS._player.enableControl(CURSOR_WALK);
+ break;
+ }
+}
+
+void Scene1950::process(Event &event) {
+ if ( (event.eventType == EVENT_BUTTON_DOWN)
+ && (R2_GLOBALS._player._uiEnabled)
+ && (R2_GLOBALS._events.getCursor() == R2_SOAKED_FACEMASK)
+ && (R2_GLOBALS._player._bounds.contains(event.mousePos))
+ && (R2_INVENTORY.getObjectScene(R2_SCRITH_KEY) == 0)) {
+ event.handled = true;
+ R2_GLOBALS._player.disableControl();
+ _shaftExit._enabled = false;
+ _doorExit._enabled = false;
+ _sceneMode = 1959;
+ setAction(&_sequenceManager, this, 1959, &R2_GLOBALS._player, NULL);
+ }
+
+ Scene::process(event);
+}
+
+} // End of namespace Ringworld2
+} // End of namespace TsAGE
diff --git a/engines/tsage/ringworld2/ringworld2_vampire.h b/engines/tsage/ringworld2/ringworld2_vampire.h
new file mode 100644
index 0000000000..ca7aa34544
--- /dev/null
+++ b/engines/tsage/ringworld2/ringworld2_vampire.h
@@ -0,0 +1,179 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public 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 TSAGE_RINGWORLD2_VAMPIRE_H
+#define TSAGE_RINGWORLD2_VAMPIRE_H
+
+#include "tsage/events.h"
+#include "tsage/core.h"
+#include "tsage/scenes.h"
+#include "tsage/globals.h"
+#include "tsage/sound.h"
+#include "tsage/ringworld2/ringworld2_logic.h"
+
+namespace TsAGE {
+
+namespace Ringworld2 {
+
+using namespace TsAGE;
+
+class Scene1950 : public SceneExt {
+ /* Windows */
+ class KeypadWindow: public ModalWindow {
+ public:
+ class KeypadButton : public SceneActor {
+ public:
+ int _buttonIndex;
+ bool _pressed;
+ bool _toggled;
+
+ KeypadButton();
+ void synchronize(Serializer &s);
+
+ void init(int indx);
+ virtual void process(Event &event);
+ virtual bool startAction(CursorType action, Event &event);
+ };
+
+ SceneActor _areaActor;
+ KeypadButton _buttons[16];
+
+ int _buttonIndex;
+
+ KeypadWindow();
+ virtual void synchronize(Serializer &s);
+ virtual void remove();
+ virtual void setup2(int visage, int stripFrameNum, int frameNum, int posX, int posY);
+ virtual void setup3(int resNum, int lookLineNum, int talkLineNum, int useLineNum);
+ };
+
+ class Keypad : public NamedHotspot {
+ public:
+ virtual bool startAction(CursorType action, Event &event);
+ };
+
+ /* Actors */
+ class Door : public SceneActor {
+ public:
+ virtual bool startAction(CursorType action, Event &event);
+ };
+ class Scrolls : public SceneActor {
+ public:
+ virtual bool startAction(CursorType action, Event &event);
+ };
+ class Gem : public SceneActor {
+ public:
+ virtual bool startAction(CursorType action, Event &event);
+ };
+ class Vampire : public SceneActor {
+ public:
+ Common::Point _deadPosition;
+ int _deltaX;
+ int _deltaY;
+ int _vampireMode;
+
+ Vampire();
+ void synchronize(Serializer &s);
+
+ virtual void signal();
+ virtual bool startAction(CursorType action, Event &event);
+ };
+
+ /* Exits */
+ class NorthExit : public SceneExit {
+ public:
+ virtual void changeScene();
+ };
+ class UpExit : public SceneExit {
+ public:
+ virtual void changeScene();
+ };
+ class EastExit : public SceneExit {
+ public:
+ virtual void changeScene();
+ };
+ class DownExit : public SceneExit {
+ public:
+ virtual void changeScene();
+ };
+ class SouthExit : public SceneExit {
+ public:
+ virtual void changeScene();
+ };
+ class WestExit : public SceneExit {
+ public:
+ virtual void changeScene();
+ };
+ class ShaftExit : public SceneExit {
+ public:
+ virtual void changeScene();
+ };
+ class DoorExit : public SceneExit {
+ public:
+ virtual void changeScene();
+ };
+private:
+ void initArea();
+ void enterArea();
+ void doButtonPress(int indx);
+public:
+ NamedHotspot _background;
+ Keypad _keypad;
+ SceneActor _southDoorway;
+ SceneObject _northDoorway;
+ Door _door;
+ Scrolls _scrolls;
+ SceneActor _containmentField;
+ Gem _gem;
+ SceneActor _cube;
+ SceneActor _pulsingLights;
+ Vampire _vampire;
+ KeypadWindow _KeypadWindow;
+ NorthExit _northExit;
+ UpExit _upExit;
+ EastExit _eastExit;
+ DownExit _downExit;
+ SouthExit _southExit;
+ WestExit _westExit;
+ ShaftExit _shaftExit;
+ DoorExit _doorExit;
+ SequenceManager _sequenceManager;
+
+ bool _upExitStyle;
+ bool _removeFlag;
+ bool _vampireActive;
+ Common::Point _vampireDestPos;
+ int _vampireIndex;
+
+ Scene1950();
+ void synchronize(Serializer &s);
+
+ virtual void postInit(SceneObjectList *OwnerList = NULL);
+ virtual void remove();
+ virtual void signal();
+ virtual void process(Event &event);
+};
+
+} // End of namespace Ringworld2
+} // End of namespace TsAGE
+
+#endif
diff --git a/engines/wintermute/POTFILES b/engines/wintermute/POTFILES
new file mode 100644
index 0000000000..e9422415b2
--- /dev/null
+++ b/engines/wintermute/POTFILES
@@ -0,0 +1 @@
+engines/wintermute/detection.cpp
diff --git a/engines/wintermute/base/base_engine.cpp b/engines/wintermute/base/base_engine.cpp
index 7c2e9c8468..2166a3e070 100644
--- a/engines/wintermute/base/base_engine.cpp
+++ b/engines/wintermute/base/base_engine.cpp
@@ -61,10 +61,11 @@ BaseEngine::~BaseEngine() {
delete _classReg;
}
-void BaseEngine::createInstance(const Common::String &targetName, const Common::String &gameId, Common::Language lang) {
+void BaseEngine::createInstance(const Common::String &targetName, const Common::String &gameId, Common::Language lang, WMETargetExecutable targetExecutable) {
instance()._targetName = targetName;
instance()._gameId = gameId;
instance()._language = lang;
+ instance()._targetExecutable = targetExecutable;
instance().init();
}
diff --git a/engines/wintermute/base/base_engine.h b/engines/wintermute/base/base_engine.h
index dd82cf9c29..0f4a6b0775 100644
--- a/engines/wintermute/base/base_engine.h
+++ b/engines/wintermute/base/base_engine.h
@@ -34,6 +34,8 @@
#include "common/random.h"
#include "common/language.h"
+#include "engines/wintermute/game_description.h"
+
namespace Wintermute {
class BaseFileManager;
@@ -53,10 +55,12 @@ class BaseEngine : public Common::Singleton<Wintermute::BaseEngine> {
Common::RandomSource *_rnd;
SystemClassRegistry *_classReg;
Common::Language _language;
+ WMETargetExecutable _targetExecutable;
public:
BaseEngine();
~BaseEngine();
- static void createInstance(const Common::String &targetName, const Common::String &gameId, Common::Language lang);
+ static void createInstance(const Common::String &targetName, const Common::String &gameId, Common::Language lang, WMETargetExecutable targetExecutable = LATEST_VERSION);
+
void setGameRef(BaseGame *gameRef) { _gameRef = gameRef; }
Common::RandomSource *getRandomSource() { return _rnd; }
@@ -73,6 +77,9 @@ public:
const char *getGameTargetName() const { return _targetName.c_str(); }
Common::String getGameId() const { return _gameId; }
Common::Language getLanguage() const { return _language; }
+ WMETargetExecutable getTargetExecutable() const {
+ return _targetExecutable;
+ }
};
} // End of namespace Wintermute
diff --git a/engines/wintermute/base/base_game.cpp b/engines/wintermute/base/base_game.cpp
index 8df39c825a..668053bb3a 100644
--- a/engines/wintermute/base/base_game.cpp
+++ b/engines/wintermute/base/base_game.cpp
@@ -3896,6 +3896,11 @@ void BaseGame::expandStringByStringTable(char **str) const {
_settings->expandStringByStringTable(str);
}
+//////////////////////////////////////////////////////////////////////////
+void BaseGame::expandStringByStringTable(Common::String &str) const {
+ _settings->expandStringByStringTable(str);
+}
+
char *BaseGame::getKeyFromStringTable(const char *str) const {
return _settings->getKeyFromStringTable(str);
}
diff --git a/engines/wintermute/base/base_game.h b/engines/wintermute/base/base_game.h
index cdbbff6c93..e535cc9618 100644
--- a/engines/wintermute/base/base_game.h
+++ b/engines/wintermute/base/base_game.h
@@ -123,6 +123,7 @@ public:
inline BaseObject *getMainObject() { return _mainObject; }
inline BaseFont *getSystemFont() { return _systemFont; }
+ inline BaseFont *getVideoFont() { return _videoFont; }
bool initInput();
bool initLoop();
@@ -140,6 +141,7 @@ public:
// String Table
void expandStringByStringTable(char **str) const;
+ void expandStringByStringTable(Common::String &str) const;
char *getKeyFromStringTable(const char *str) const;
void LOG(bool res, const char *fmt, ...);
diff --git a/engines/wintermute/base/base_game_settings.cpp b/engines/wintermute/base/base_game_settings.cpp
index 61c5894be3..996bada997 100644
--- a/engines/wintermute/base/base_game_settings.cpp
+++ b/engines/wintermute/base/base_game_settings.cpp
@@ -215,6 +215,11 @@ void BaseGameSettings::expandStringByStringTable(char **str) const {
_stringTable->expand(str);
}
+//////////////////////////////////////////////////////////////////////////
+void BaseGameSettings::expandStringByStringTable(Common::String &str) const {
+ _stringTable->expand(str);
+}
+
char *BaseGameSettings::getKeyFromStringTable(const char *str) const {
return _stringTable->getKey(str);
}
diff --git a/engines/wintermute/base/base_game_settings.h b/engines/wintermute/base/base_game_settings.h
index 2059cb075e..15afb06450 100644
--- a/engines/wintermute/base/base_game_settings.h
+++ b/engines/wintermute/base/base_game_settings.h
@@ -46,6 +46,7 @@ public:
bool loadSettings(const char *filename);
bool loadStringTable(const char *filename, bool clearOld);
void expandStringByStringTable(char **str) const;
+ void expandStringByStringTable(Common::String &str) const;
char *getKeyFromStringTable(const char *str) const;
bool persist(BasePersistenceManager *persistMgr);
diff --git a/engines/wintermute/base/base_keyboard_state.cpp b/engines/wintermute/base/base_keyboard_state.cpp
index 61087c5836..0babc07586 100644
--- a/engines/wintermute/base/base_keyboard_state.cpp
+++ b/engines/wintermute/base/base_keyboard_state.cpp
@@ -278,10 +278,24 @@ uint32 BaseKeyboardState::keyCodeToVKey(Common::Event *event) {
enum VKeyCodes {
kVkEscape = 27,
kVkSpace = 32,
+ kVkHome = 36,
kVkLeft = 37,
kVkUp = 38,
kVkRight = 39,
- kVkDown = 40
+ kVkDown = 40,
+
+ kVkF1 = 112,
+ kVkF2 = 113,
+ kVkF3 = 114,
+ kVkF4 = 115,
+ kVkF5 = 116,
+ kVkF6 = 117,
+ kVkF7 = 118,
+ kVkF8 = 119,
+ kVkF9 = 120,
+ kVkF10 = 121,
+ kVkF11 = 122,
+ kVkF12 = 123
};
//////////////////////////////////////////////////////////////////////////
@@ -290,22 +304,42 @@ Common::KeyCode BaseKeyboardState::vKeyToKeyCode(uint32 vkey) {
switch (vkey) {
case kVkEscape:
return Common::KEYCODE_ESCAPE;
- break;
case kVkSpace:
return Common::KEYCODE_SPACE;
- break;
+ case kVkHome:
+ return Common::KEYCODE_HOME;
case kVkLeft:
return Common::KEYCODE_LEFT;
- break;
case kVkRight:
return Common::KEYCODE_RIGHT;
- break;
case kVkUp:
return Common::KEYCODE_UP;
- break;
case kVkDown:
return Common::KEYCODE_DOWN;
- break;
+ case kVkF1:
+ return Common::KEYCODE_F1;
+ case kVkF2:
+ return Common::KEYCODE_F2;
+ case kVkF3:
+ return Common::KEYCODE_F3;
+ case kVkF4:
+ return Common::KEYCODE_F4;
+ case kVkF5:
+ return Common::KEYCODE_F5;
+ case kVkF6:
+ return Common::KEYCODE_F6;
+ case kVkF7:
+ return Common::KEYCODE_F7;
+ case kVkF8:
+ return Common::KEYCODE_F8;
+ case kVkF9:
+ return Common::KEYCODE_F9;
+ case kVkF10:
+ return Common::KEYCODE_F10;
+ case kVkF11:
+ return Common::KEYCODE_F11;
+ case kVkF12:
+ return Common::KEYCODE_F12;
default:
warning("Unknown VKEY: %d", vkey);
return (Common::KeyCode)vkey;
diff --git a/engines/wintermute/base/base_sprite.cpp b/engines/wintermute/base/base_sprite.cpp
index 04060bff32..09e138a1fd 100644
--- a/engines/wintermute/base/base_sprite.cpp
+++ b/engines/wintermute/base/base_sprite.cpp
@@ -41,6 +41,7 @@
#include "engines/wintermute/base/scriptables/script_value.h"
#include "engines/wintermute/base/scriptables/script.h"
#include "engines/wintermute/base/scriptables/script_stack.h"
+#include "engines/wintermute/game_description.h"
namespace Wintermute {
@@ -347,9 +348,17 @@ void BaseSprite::reset() {
} else {
_currentFrame = -1;
}
-
- killAllSounds();
-
+ if (BaseEngine::instance().getTargetExecutable() >= WME_1_8_6) {
+ /*
+ * This was added in WME 1.8.6
+ *
+ * 5MA and possibly other games ship with pre-1.8.6 WME, and
+ * depends (e.g.: menu sounds, etc) on this not being triggered.
+ *
+ * See bug #6647
+ */
+ killAllSounds();
+ }
_lastFrameTime = 0;
_finished = false;
_moveX = _moveY = 0;
diff --git a/engines/wintermute/base/base_string_table.cpp b/engines/wintermute/base/base_string_table.cpp
index 89407a7b0e..4c750ebc93 100644
--- a/engines/wintermute/base/base_string_table.cpp
+++ b/engines/wintermute/base/base_string_table.cpp
@@ -147,6 +147,15 @@ void BaseStringTable::expand(char **str) const {
}
}
+//////////////////////////////////////////////////////////////////////////
+void BaseStringTable::expand(Common::String &str) const {
+ char *tmp = new char[str.size()+1];
+ strcpy(tmp, str.c_str());
+ expand(&tmp);
+ str = tmp;
+ delete[] tmp;
+}
+
//////////////////////////////////////////////////////////////////////////
const char *BaseStringTable::expandStatic(const char *string) const {
diff --git a/engines/wintermute/base/base_string_table.h b/engines/wintermute/base/base_string_table.h
index cdcf11917d..cfa3eeb226 100644
--- a/engines/wintermute/base/base_string_table.h
+++ b/engines/wintermute/base/base_string_table.h
@@ -41,6 +41,7 @@ class BaseStringTable : public BaseClass {
public:
bool loadFile(const char *filename, bool deleteAll = true);
void expand(char **str) const;
+ void expand(Common::String &str) const;
const char *expandStatic(const char *string) const;
bool addString(const char *key, const char *val, bool reportDuplicities = true);
BaseStringTable(BaseGame *inGame);
diff --git a/engines/wintermute/base/sound/base_sound.cpp b/engines/wintermute/base/sound/base_sound.cpp
index fa452cc0d6..b5b12d55f9 100644
--- a/engines/wintermute/base/sound/base_sound.cpp
+++ b/engines/wintermute/base/sound/base_sound.cpp
@@ -89,7 +89,7 @@ bool BaseSound::setSoundSimple() {
_sound->setLooping(_soundLooping);
_sound->setPrivateVolume(_soundPrivateVolume);
_sound->setLoopStart(_soundLoopStart);
- _sound->_freezePaused = _soundFreezePaused;
+ _sound->setFreezePaused(_soundFreezePaused);
if (_soundPlaying) {
return _sound->resume();
} else {
@@ -130,7 +130,7 @@ bool BaseSound::pause(bool freezePaused) {
if (_sound) {
_soundPaused = true;
if (freezePaused) {
- _sound->_freezePaused = true;
+ _sound->setFreezePaused(true);
}
return _sound->pause();
} else {
@@ -150,13 +150,13 @@ bool BaseSound::resume() {
bool BaseSound::persist(BasePersistenceManager *persistMgr) {
if (persistMgr->getIsSaving() && _sound) {
_soundPlaying = _sound->isPlaying();
- _soundLooping = _sound->_looping;
- _soundPrivateVolume = _sound->_privateVolume;
+ _soundLooping = _sound->isLooping();
+ _soundPrivateVolume = _sound->getPrivateVolume();
if (_soundPlaying) {
_soundPosition = _sound->getPosition();
}
- _soundLoopStart = _sound->_loopStart;
- _soundFreezePaused = _sound->_freezePaused;
+ _soundLoopStart = _sound->getLoopStart();
+ _soundFreezePaused = _sound->isFreezePaused();
}
if (persistMgr->getIsSaving()) {
@@ -232,7 +232,7 @@ bool BaseSound::setPrivateVolume(int volume) {
if (!_sound) {
return STATUS_FAILED;
} else {
- _sound->_privateVolume = volume;
+ _sound->setPrivateVolume(volume);
return STATUS_OK;
}
}
@@ -241,7 +241,7 @@ int BaseSound::getVolumePercent() {
if (!_sound) {
return 0;
} else {
- return _sound->_privateVolume * 100 / 255;
+ return _sound->getPrivateVolume() * 100 / 255;
}
}
@@ -249,7 +249,7 @@ int BaseSound::getVolume() {
if (!_sound) {
return 0;
} else {
- return _sound->_privateVolume;
+ return _sound->getPrivateVolume();
}
}
diff --git a/engines/wintermute/base/sound/base_sound_buffer.cpp b/engines/wintermute/base/sound/base_sound_buffer.cpp
index 7ec68ea752..5fdac12cef 100644
--- a/engines/wintermute/base/sound/base_sound_buffer.cpp
+++ b/engines/wintermute/base/sound/base_sound_buffer.cpp
@@ -143,8 +143,13 @@ bool BaseSoundBuffer::play(bool looping, uint32 startSample) {
_stream->seek(startSample);
_handle = new Audio::SoundHandle;
if (_looping) {
- Audio::AudioStream *loopStream = new Audio::LoopingAudioStream(_stream, 0, DisposeAfterUse::NO);
- g_system->getMixer()->playStream(_type, _handle, loopStream, -1, _volume, _pan, DisposeAfterUse::YES);
+ if (_loopStart != 0) {
+ Audio::AudioStream *loopStream = new Audio::SubLoopingAudioStream(_stream, 0, Audio::Timestamp(_loopStart, _stream->getRate()), _stream->getLength(), DisposeAfterUse::NO);
+ g_system->getMixer()->playStream(_type, _handle, loopStream, -1, _volume, _pan, DisposeAfterUse::YES);
+ } else {
+ Audio::AudioStream *loopStream = new Audio::LoopingAudioStream(_stream, 0, DisposeAfterUse::NO);
+ g_system->getMixer()->playStream(_type, _handle, loopStream, -1, _volume, _pan, DisposeAfterUse::YES);
+ }
} else {
g_system->getMixer()->playStream(_type, _handle, _stream, -1, _volume, _pan, DisposeAfterUse::NO);
}
@@ -296,4 +301,24 @@ bool BaseSoundBuffer::applyFX(TSFXType type, float param1, float param2, float p
return STATUS_OK;
}
+int32 BaseSoundBuffer::getPrivateVolume() const {
+ return _privateVolume;
+}
+
+bool BaseSoundBuffer::isLooping() const {
+ return _looping;
+}
+
+bool BaseSoundBuffer::isFreezePaused() const {
+ return _freezePaused;
+}
+
+void BaseSoundBuffer::setFreezePaused(bool freezePaused) {
+ _freezePaused = freezePaused;
+}
+
+Audio::Mixer::SoundType BaseSoundBuffer::getType() const {
+ return _type;
+}
+
} // End of namespace Wintermute
diff --git a/engines/wintermute/base/sound/base_sound_buffer.h b/engines/wintermute/base/sound/base_sound_buffer.h
index 94bc8dc6ad..b3f3046674 100644
--- a/engines/wintermute/base/sound/base_sound_buffer.h
+++ b/engines/wintermute/base/sound/base_sound_buffer.h
@@ -71,23 +71,26 @@ public:
void updateVolume();
void setType(Audio::Mixer::SoundType Type);
+ Audio::Mixer::SoundType getType() const;
bool loadFromFile(const Common::String &filename, bool forceReload = false);
void setStreaming(bool streamed, uint32 numBlocks = 0, uint32 blockSize = 0);
bool applyFX(TSFXType type, float param1, float param2, float param3, float param4);
-
+ int32 getPrivateVolume() const;
+ void setFreezePaused(bool freezePaused);
+ bool isFreezePaused() const;
+ bool isLooping() const;
//HSTREAM _stream;
//HSYNC _sync;
+
+private:
+ Audio::Mixer::SoundType _type;
Audio::SeekableAudioStream *_stream;
Audio::SoundHandle *_handle;
-
bool _freezePaused;
- uint32 _loopStart;
- Audio::Mixer::SoundType _type;
bool _looping;
-
int32 _privateVolume;
-private:
+ uint32 _loopStart;
uint32 _startPos;
Common::String _filename;
bool _streamed;
diff --git a/engines/wintermute/base/sound/base_sound_manager.cpp b/engines/wintermute/base/sound/base_sound_manager.cpp
index 41cfe5ea62..f1e0c3b1f9 100644
--- a/engines/wintermute/base/sound/base_sound_manager.cpp
+++ b/engines/wintermute/base/sound/base_sound_manager.cpp
@@ -254,9 +254,9 @@ byte BaseSoundMgr::getMasterVolume() {
bool BaseSoundMgr::pauseAll(bool includingMusic) {
for (uint32 i = 0; i < _sounds.size(); i++) {
- if (_sounds[i]->isPlaying() && (_sounds[i]->_type != Audio::Mixer::kMusicSoundType || includingMusic)) {
+ if (_sounds[i]->isPlaying() && (_sounds[i]->getType() != Audio::Mixer::kMusicSoundType || includingMusic)) {
_sounds[i]->pause();
- _sounds[i]->_freezePaused = true;
+ _sounds[i]->setFreezePaused(true);
}
}
@@ -268,9 +268,9 @@ bool BaseSoundMgr::pauseAll(bool includingMusic) {
bool BaseSoundMgr::resumeAll() {
for (uint32 i = 0; i < _sounds.size(); i++) {
- if (_sounds[i]->_freezePaused) {
+ if (_sounds[i]->isFreezePaused()) {
_sounds[i]->resume();
- _sounds[i]->_freezePaused = false;
+ _sounds[i]->setFreezePaused(false);
}
}
diff --git a/engines/wintermute/detection.cpp b/engines/wintermute/detection.cpp
index a659c434d0..aca682ae99 100644
--- a/engines/wintermute/detection.cpp
+++ b/engines/wintermute/detection.cpp
@@ -74,7 +74,7 @@ static const char *directoryGlobs[] = {
class WintermuteMetaEngine : public AdvancedMetaEngine {
public:
- WintermuteMetaEngine() : AdvancedMetaEngine(Wintermute::gameDescriptions, sizeof(ADGameDescription), Wintermute::wintermuteGames, gameGuiOptions) {
+ WintermuteMetaEngine() : AdvancedMetaEngine(Wintermute::gameDescriptions, sizeof(WMEGameDescription), Wintermute::wintermuteGames, gameGuiOptions) {
_singleid = "wintermute";
_guioptions = GUIO2(GUIO_NOMIDI, GAMEOPTION_SHOW_FPS);
_maxScanDepth = 2;
@@ -127,8 +127,8 @@ public:
virtual bool createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const {
assert(syst);
assert(engine);
-
- *engine = new Wintermute::WintermuteEngine(syst, desc);
+ const WMEGameDescription *gd = (const WMEGameDescription *)desc;
+ *engine = new Wintermute::WintermuteEngine(syst, gd);
return true;
}
diff --git a/engines/wintermute/detection_tables.h b/engines/wintermute/detection_tables.h
index 8206ca9643..4e3320159a 100644
--- a/engines/wintermute/detection_tables.h
+++ b/engines/wintermute/detection_tables.h
@@ -90,1342 +90,458 @@ static const PlainGameDescriptor wintermuteGames[] = {
{0, 0}
};
-static const ADGameDescription gameDescriptions[] = {
+// Duplicates WME_ENTRY1s, for consistency
+#define WME_ENTRY1s(f1, h1, s1) { {f1, 0, h1, s1}, AD_LISTEND }
+#define WME_ENTRY2s(f1, h1, s1, f2, h2, s2) { {f1, 0, h1, s1}, {f2, 0, h2, s2}, AD_LISTEND }
+#define WME_ENTRY3s(f1, h1, s1, f2, h2, s2, f3, h3, s3) { {f1, 0, h1, s1}, {f2, 0, h2, s2}, {f3, 0, h3, s3}, AD_LISTEND }
+
+#define WME_PLATENTRY(shortName, extraName, hashEntry, lang, plat, status, version) \
+ { \
+ { \
+ shortName, \
+ extraName, \
+ hashEntry, \
+ lang, \
+ plat, \
+ status, \
+ GUIO0(), \
+ }, \
+ version \
+ }
+
+// Convenience variant, as most of the games are Windows-games
+#define WME_WINENTRY(shortName, extraName, hashEntry, lang, status, version) \
+ { \
+ { \
+ shortName, \
+ extraName, \
+ hashEntry, \
+ lang, \
+ Common::kPlatformWindows, \
+ status, \
+ GUIO0(), \
+ }, \
+ version \
+ }
+
+/* To add new entries:
+ * Make sure you have a target name defined at the top of the file
+ *
+ * If the game has only one language, and can be detected using only one file,
+ * then use WME_WINENTRY, with WME_ENTRY1s as exemplified below.
+ *
+ * If the game has more than one language, and the main data file is common across
+ * the versions, then you should use WME_WINENTRY with WME_ENTRY2s/WME_ENTRY3s, with
+ * the language file as the first hit, and the data file as the second. (Make sure to
+ * NOT create a WME_ENTRY1s matching the same data file as the 2/3 file match)
+ */
+
+static const WMEGameDescription gameDescriptions[] = {
// Five Lethal Demons
- {
- "5ld",
- "",
- AD_ENTRY1s("data.dcp", "1037a77cbd001e0644898addc022322c", 15407750),
- Common::EN_ANY,
- Common::kPlatformWindows,
- ADGF_UNSTABLE,
- GUIO0()
- },
+ WME_WINENTRY("5ld", "",
+ WME_ENTRY1s("data.dcp", "1037a77cbd001e0644898addc022322c", 15407750), Common::EN_ANY, ADGF_UNSTABLE, LATEST_VERSION),
// Five Magical Amulets
- {
- "5ma",
- "",
- AD_ENTRY1s("data.dcp", "0134e92bcd5fd2837df3971087e96067", 163316498),
- Common::EN_ANY,
- Common::kPlatformWindows,
- ADGF_UNSTABLE,
- GUIO0()
- },
+ WME_WINENTRY("5ma", "",
+ WME_ENTRY1s("data.dcp", "0134e92bcd5fd2837df3971087e96067", 163316498), Common::EN_ANY, ADGF_UNSTABLE, WME_1_7_0),
// Actual Destination
- {
- "actualdest",
- "",
- AD_ENTRY1s("data.dcp", "6926f44b26f21ceb1d840eaab9aeb510", 9081740),
- Common::EN_ANY,
- Common::kPlatformWindows,
- ADGF_UNSTABLE,
- GUIO0()
- },
+ WME_WINENTRY("actualdest", "",
+ WME_ENTRY1s("data.dcp", "6926f44b26f21ceb1d840eaab9aeb510", 9081740), Common::EN_ANY, ADGF_UNSTABLE, LATEST_VERSION),
// Boredom of Agustin Cordes
- {
- "agustin",
- "",
- AD_ENTRY1s("data.dcp", "abb79c16c9b92e9b06525a4c7c3f5861", 2461949),
- Common::EN_ANY,
- Common::kPlatformWindows,
- ADGF_UNSTABLE,
- GUIO0()
- },
+ WME_WINENTRY("agustin", "",
+ WME_ENTRY1s("data.dcp", "abb79c16c9b92e9b06525a4c7c3f5861", 2461949), Common::EN_ANY, ADGF_UNSTABLE, LATEST_VERSION),
// Beyond the Threshold
- {
- "bthreshold",
- "",
- AD_ENTRY1s("data.dcp", "d49bf9ccb2e74507447c82d6ad3e2bc4", 12773712),
- Common::EN_ANY,
- Common::kPlatformWindows,
- ADGF_UNSTABLE,
- GUIO0()
- },
+ WME_WINENTRY("bthreshold", "",
+ WME_ENTRY1s("data.dcp", "d49bf9ccb2e74507447c82d6ad3e2bc4", 12773712), Common::EN_ANY, ADGF_UNSTABLE, LATEST_VERSION),
// Bickadoodle
- {
- "bickadoodle",
- "",
- AD_ENTRY1s("data.dcp", "84db4d1594cac95e25614985775d10a8", 35303844),
- Common::EN_ANY,
- Common::kPlatformWindows,
- ADGF_UNSTABLE,
- GUIO0()
- },
+ WME_WINENTRY("bickadoodle", "",
+ WME_ENTRY1s("data.dcp", "84db4d1594cac95e25614985775d10a8", 35303844), Common::EN_ANY, ADGF_UNSTABLE, LATEST_VERSION),
// Bickadoodle (Ver 1.1)
- {
- "bickadoodle",
- "Version 1.1",
- AD_ENTRY1s("data.dcp", "8bb52ac9a9ee129c5059e8e808b669d7", 35337760),
- Common::EN_ANY,
- Common::kPlatformWindows,
- ADGF_UNSTABLE,
- GUIO0()
- },
+ WME_WINENTRY("bickadoodle", "Version 1.1",
+ WME_ENTRY1s("data.dcp", "8bb52ac9a9ee129c5059e8e808b669d7", 35337760), Common::EN_ANY, ADGF_UNSTABLE, LATEST_VERSION),
+ // Bickadoodle (Ver 1.2)
+ WME_WINENTRY("bickadoodle", "Version 1.2",
+ WME_ENTRY1s("data.dcp", "1796a48f3ed72dd785ce93334ab883cc", 35337760), Common::EN_ANY, ADGF_UNSTABLE, LATEST_VERSION),
// Bickadoodle (download from http://aethericgames.com/games/bickadoodle/download-bickadoodle/)
- {
- "bickadoodle",
- "",
- AD_ENTRY1s("data.dcp", "1584d83577c32add0fce27fae91141a2", 35337728),
- Common::EN_ANY,
- Common::kPlatformWindows,
- ADGF_UNSTABLE,
- GUIO0()
- },
+ WME_WINENTRY("bickadoodle", "",
+ WME_ENTRY1s("data.dcp", "1584d83577c32add0fce27fae91141a2", 35337728), Common::EN_ANY, ADGF_UNSTABLE, LATEST_VERSION),
// Book of Gron Part One
- {
- "bookofgron",
- "",
- AD_ENTRY1s("data.dcp", "e61b2ebee044a82fa0f8ca0fce2c8946", 83129531),
- Common::RU_RUS,
- Common::kPlatformWindows,
- ADGF_UNSTABLE,
- GUIO0()
- },
+ WME_WINENTRY("bookofgron", "",
+ WME_ENTRY1s("data.dcp", "e61b2ebee044a82fa0f8ca0fce2c8946", 83129531), Common::RU_RUS, ADGF_UNSTABLE, LATEST_VERSION),
// Carol Reed 4 - East Side Story (Demo)
- {
- "carolreed4",
- "Demo",
- AD_ENTRY1s("data.dcp", "b3f8b09bb4b05ee3e9d14697525257f9", 59296246),
- Common::EN_ANY,
- Common::kPlatformWindows,
- ADGF_UNSTABLE |
- ADGF_DEMO,
- GUIO0()
- },
+ WME_WINENTRY("carolreed4", "Demo",
+ WME_ENTRY1s("data.dcp", "b3f8b09bb4b05ee3e9d14697525257f9", 59296246), Common::EN_ANY, ADGF_UNSTABLE | ADGF_DEMO, LATEST_VERSION),
// Carol Reed 4 - East Side Story
- {
- "carolreed4",
- "",
- AD_ENTRY1s("data.dcp", "b26377797f060afc2d440d820100c1ce", 529320536),
- Common::EN_ANY,
- Common::kPlatformWindows,
- ADGF_UNSTABLE |
- ADGF_DEMO,
- GUIO0()
- },
+ WME_WINENTRY("carolreed4", "",
+ WME_ENTRY1s("data.dcp", "b26377797f060afc2d440d820100c1ce", 529320536), Common::EN_ANY, ADGF_UNSTABLE | ADGF_DEMO, LATEST_VERSION),
// Carol Reed 5 - The Colour of Murder
- {
- "carolreed5",
- "",
- AD_ENTRY1s("data.dcp", "3fcfca44209545d0e26774156427b494", 603660415),
- Common::EN_ANY,
- Common::kPlatformWindows,
- ADGF_UNSTABLE,
- GUIO0()
- },
+ WME_WINENTRY("carolreed5", "",
+ WME_ENTRY1s("data.dcp", "3fcfca44209545d0e26774156427b494", 603660415), Common::EN_ANY, ADGF_UNSTABLE, LATEST_VERSION),
// Carol Reed 6 - Black Circle
- {
- "carolreed6",
- "",
- AD_ENTRY1s("data.dcp", "0e4c532beecf23d85012168753f41189", 456258147),
- Common::EN_ANY,
- Common::kPlatformWindows,
- ADGF_UNSTABLE,
- GUIO0()
- },
+ WME_WINENTRY("carolreed6", "",
+ WME_ENTRY1s("data.dcp", "0e4c532beecf23d85012168753f41189", 456258147), Common::EN_ANY, ADGF_UNSTABLE, LATEST_VERSION),
// Carol Reed 7 - Blue Madonna (Demo)
- {
- "carolreed7",
- "Demo",
- AD_ENTRY1s("data.dcp", "0372ad0c775266f6355e9e8ae397a2f1", 103719442),
- Common::EN_ANY,
- Common::kPlatformWindows,
- ADGF_UNSTABLE |
- ADGF_DEMO,
- GUIO0()
- },
+ WME_WINENTRY("carolreed7", "Demo",
+ WME_ENTRY1s("data.dcp", "0372ad0c775266f6355e9e8ae397a2f1", 103719442), Common::EN_ANY, ADGF_UNSTABLE | ADGF_DEMO, LATEST_VERSION),
// Carol Reed 7 - Blue Madonna
- {
- "carolreed7",
- "",
- AD_ENTRY1s("data.dcp", "24e3db3e2fabfc956713796d87a3efb0", 495471147),
- Common::EN_ANY,
- Common::kPlatformWindows,
- ADGF_UNSTABLE,
- GUIO0()
- },
+ WME_WINENTRY("carolreed7", "",
+ WME_ENTRY1s("data.dcp", "24e3db3e2fabfc956713796d87a3efb0", 495471147), Common::EN_ANY, ADGF_UNSTABLE, LATEST_VERSION),
// Carol Reed 8 - Amber's Blood
- {
- "carolreed8",
- "",
- AD_ENTRY1s("data.dcp", "859d16b0d5b9b255e470cbded2c6cedc", 502714557),
- Common::EN_ANY,
- Common::kPlatformWindows,
- ADGF_UNSTABLE,
- GUIO0()
- },
+ WME_WINENTRY("carolreed8", "",
+ WME_ENTRY1s("data.dcp", "859d16b0d5b9b255e470cbded2c6cedc", 502714557), Common::EN_ANY, ADGF_UNSTABLE, LATEST_VERSION),
// Carol Reed 9 - Cold Case Summer
- {
- "carolreed9",
- "",
- AD_ENTRY1s("data.dcp", "2b343b48a7aee508d728a546b414a255", 620005266),
- Common::EN_ANY,
- Common::kPlatformWindows,
- ADGF_UNSTABLE,
- GUIO0()
- },
+ WME_WINENTRY("carolreed9", "",
+ WME_ENTRY1s("data.dcp", "2b343b48a7aee508d728a546b414a255", 620005266), Common::EN_ANY, ADGF_UNSTABLE, LATEST_VERSION),
// Chivalry is Not Dead
- {
- "chivalry",
- "",
- AD_ENTRY1s("data.dcp", "ebd0915d9a12df5224be22f53bb23eb6", 7278306),
- Common::EN_ANY,
- Common::kPlatformWindows,
- ADGF_TESTING,
- GUIO0()
- },
+ WME_WINENTRY("chivalry", "",
+ WME_ENTRY1s("data.dcp", "ebd0915d9a12df5224be22f53bb23eb6", 7278306), Common::EN_ANY, ADGF_TESTING, LATEST_VERSION),
// Chivalry is Not Dead (Version from deirdrakai.com)
- {
- "chivalry",
- "",
- AD_ENTRY1s("data.dcp", "ae6d91b9517f4d2851a8ad94c96951c8", 7278302),
- Common::EN_ANY,
- Common::kPlatformWindows,
- ADGF_TESTING,
- GUIO0()
- },
+ WME_WINENTRY("chivalry", "",
+ WME_ENTRY1s("data.dcp", "ae6d91b9517f4d2851a8ad94c96951c8", 7278302), Common::EN_ANY, ADGF_TESTING, LATEST_VERSION),
// Conspiracao Dumont
- {
- "conspiracao",
- "",
- AD_ENTRY1s("ConspiracaoDumont.exe", "106f3f2c8f18bb5ffffeed634ace256c", 32908032),
- Common::EN_ANY,
- Common::kPlatformWindows,
- ADGF_UNSTABLE |
- ADGF_DEMO,
- GUIO0()
- },
+ WME_WINENTRY("conspiracao", "",
+ WME_ENTRY1s("ConspiracaoDumont.exe", "106f3f2c8f18bb5ffffeed634ace256c", 32908032), Common::EN_ANY, ADGF_UNSTABLE | ADGF_DEMO, LATEST_VERSION),
// Corrosion: Cold Winter Waiting
- {
- "corrosion",
- "",
- AD_ENTRY1s("data.dcp", "ae885b1a8faa0b27f43c0e8f0df02fc9", 525931618),
- Common::EN_ANY,
- Common::kPlatformWindows,
- ADGF_TESTING,
- GUIO0()
- },
+ WME_WINENTRY("corrosion", "",
+ WME_ENTRY1s("data.dcp", "ae885b1a8faa0b27f43c0e8f0df02fc9", 525931618), Common::EN_ANY, ADGF_TESTING, LATEST_VERSION),
// Dead City (Czech)
- {
- "deadcity",
- "",
- {
- // The Czech data are in data.dcp, so in this case we'll have to
- // just detect the english version twice, to give the user a choice.
- {"english.dcp", 0, "c591046d6de7e381d76f70e0787b2b1f", 415935},
- {"data.dcp", 0, "7ebfd50d1a22370ed7b079bcaa631d62", 9070205},
- AD_LISTEND
- },
- Common::CZ_CZE,
- Common::kPlatformWindows,
- ADGF_UNSTABLE,
- GUIO0()
- },
+ // The Czech data are in data.dcp, so in this case we'll have to
+ // just detect the english version twice, to give the user a choice.
+ WME_WINENTRY("deadcity", "",
+ WME_ENTRY2s("english.dcp", "c591046d6de7e381d76f70e0787b2b1f", 415935,
+ "data.dcp", "7ebfd50d1a22370ed7b079bcaa631d62", 9070205), Common::CZ_CZE, ADGF_UNSTABLE, LATEST_VERSION),
// Dead City (English)
- {
- "deadcity",
- "",
- {
- {"english.dcp", 0, "c591046d6de7e381d76f70e0787b2b1f", 415935},
- {"data.dcp", 0, "7ebfd50d1a22370ed7b079bcaa631d62", 9070205},
- AD_LISTEND
- },
- Common::EN_ANY,
- Common::kPlatformWindows,
- ADGF_UNSTABLE,
- GUIO0()
- },
+ WME_WINENTRY("deadcity", "",
+ WME_ENTRY2s("english.dcp", "c591046d6de7e381d76f70e0787b2b1f", 415935,
+ "data.dcp", "7ebfd50d1a22370ed7b079bcaa631d62", 9070205), Common::EN_ANY, ADGF_UNSTABLE, LATEST_VERSION),
// Dead City (Italian)
- {
- "deadcity",
- "",
- {
- {"italian.dcp", 0, "92d8efb94436bec7bd1b7fe0b548192e", 454037},
- {"data.dcp", 0, "7ebfd50d1a22370ed7b079bcaa631d62", 9070205},
- AD_LISTEND
- },
- Common::IT_ITA,
- Common::kPlatformWindows,
- ADGF_UNSTABLE,
- GUIO0()
- },
+ WME_WINENTRY("deadcity", "",
+ WME_ENTRY2s("italian.dcp", "92d8efb94436bec7bd1b7fe0b548192e", 454037,
+ "data.dcp", "7ebfd50d1a22370ed7b079bcaa631d62", 9070205), Common::IT_ITA, ADGF_UNSTABLE, LATEST_VERSION),
// Dead City (Russian)
- {
- "deadcity",
- "",
- {
- {"russian.dcp", 0, "a0ae71e9e1185596fffb07ad2c951eb9", 653317},
- {"data.dcp", 0, "7ebfd50d1a22370ed7b079bcaa631d62", 9070205},
- AD_LISTEND
- },
- Common::RU_RUS,
- Common::kPlatformWindows,
- ADGF_UNSTABLE,
- GUIO0()
- },
+ WME_WINENTRY("deadcity", "",
+ WME_ENTRY2s("russian.dcp", "a0ae71e9e1185596fffb07ad2c951eb9", 653317,
+ "data.dcp", "7ebfd50d1a22370ed7b079bcaa631d62", 9070205), Common::RU_RUS, ADGF_UNSTABLE, LATEST_VERSION),
// Dirty Split (Czech)
- {
- "dirtysplit",
- "",
- {
- {"czech.dcp", 0, "08a71446467cf8f9444cfea446b46ad6", 127697934},
- {"data.dcp", 0, "8b4b81b718bf65f30a67fc0b1e329eb5", 88577623},
- },
- Common::CZ_CZE,
- Common::kPlatformWindows,
- ADGF_UNSTABLE,
- GUIO0()
- },
+ WME_WINENTRY("dirtysplit", "",
+ WME_ENTRY2s("czech.dcp", "08a71446467cf8f9444cfea446b46ad6", 127697934,
+ "data.dcp", "8b4b81b718bf65f30a67fc0b1e329eb5", 88577623), Common::CZ_CZE, ADGF_UNSTABLE, LATEST_VERSION),
// Dirty Split (English)
- {
- "dirtysplit",
- "",
- AD_ENTRY1s("data.dcp", "8f3dae199361ece0f59fb20cfff6eed3", 88577621),
- Common::EN_ANY,
- Common::kPlatformWindows,
- ADGF_UNSTABLE,
- GUIO0()
- },
+ WME_WINENTRY("dirtysplit", "",
+ WME_ENTRY1s("data.dcp", "8f3dae199361ece0f59fb20cfff6eed3", 88577621), Common::EN_ANY, ADGF_UNSTABLE, LATEST_VERSION),
// Dirty Split (French)
- {
- "dirtysplit",
- "",
- {
- {"french.dcp", 0, "a0508dedebd0fe478d0158fa4c2a1136", 125534323},
- {"data.dcp", 0, "e6d70c7f5d181b761cfcf974adf9186a", 88577623},
- AD_LISTEND
- },
- Common::FR_FRA,
- Common::kPlatformWindows,
- ADGF_UNSTABLE,
- GUIO0()
- },
+ WME_WINENTRY("dirtysplit", "",
+ WME_ENTRY2s("french.dcp", "a0508dedebd0fe478d0158fa4c2a1136", 125534323,
+ "data.dcp", "e6d70c7f5d181b761cfcf974adf9186a", 88577623), Common::FR_FRA, ADGF_UNSTABLE, LATEST_VERSION),
// Dirty Split (German)
- {
- "dirtysplit",
- "",
- AD_ENTRY1s("data.dcp", "139d8a25579e969f8b37d20e6e3de5f9", 92668291),
- Common::DE_DEU,
- Common::kPlatformWindows,
- ADGF_UNSTABLE,
- GUIO0()
- },
+ WME_WINENTRY("dirtysplit", "",
+ WME_ENTRY1s("data.dcp", "139d8a25579e969f8b37d20e6e3de5f9", 92668291), Common::DE_DEU, ADGF_UNSTABLE, LATEST_VERSION),
// Dirty Split (Italian)
- {
- "dirtysplit",
- "",
- {
- {"italian.dcp", 0, "8108807fbd8af70be1ec452d0fd1131b", 125513726},
- {"data.dcp", 0, "35a150e22af274185883fdbb142c6fb1", 88577623},
- },
- Common::IT_ITA,
- Common::kPlatformWindows,
- ADGF_UNSTABLE,
- GUIO0()
- },
+ WME_WINENTRY("dirtysplit", "",
+ WME_ENTRY2s("italian.dcp", "8108807fbd8af70be1ec452d0fd1131b", 125513726,
+ "data.dcp", "35a150e22af274185883fdbb142c6fb1", 88577623), Common::IT_ITA, ADGF_UNSTABLE, LATEST_VERSION),
// Dirty Split (Spanish)
- {
- "dirtysplit",
- "",
- {
- {"spanish.dcp", 0, "b3982c0a5e85b42e1e38240fef004aa4", 164428596},
- {"data.dcp", 0, "63766d6c68b9f00b632ea1736fc8a95c", 88577621},
- },
- Common::ES_ESP,
- Common::kPlatformWindows,
- ADGF_UNSTABLE,
- GUIO0()
- },
+ WME_WINENTRY("dirtysplit", "",
+ WME_ENTRY2s("spanish.dcp", "b3982c0a5e85b42e1e38240fef004aa4", 164428596,
+ "data.dcp", "63766d6c68b9f00b632ea1736fc8a95c", 88577621), Common::ES_ESP, ADGF_UNSTABLE, LATEST_VERSION),
// Des Reves Elastiques Avec Mille Insectes Nommes Georges
- {
- "dreaming",
- "",
- AD_ENTRY1s("data.dcp", "4af26d97ea063fc1277ce30ae431de90", 8804073),
- Common::EN_ANY,
- Common::kPlatformWindows,
- ADGF_UNSTABLE,
- GUIO0()
- },
+ WME_WINENTRY("dreaming", "",
+ WME_ENTRY1s("data.dcp", "4af26d97ea063fc1277ce30ae431de90", 8804073), Common::EN_ANY, ADGF_UNSTABLE, LATEST_VERSION),
// Dreamscape
- {
- "dreamscape",
- "",
- AD_ENTRY1s("data.dcp", "7a5752ed4446c862be9f02d7932acf54", 17034377),
- Common::EN_ANY,
- Common::kPlatformWindows,
- ADGF_UNSTABLE,
- GUIO0()
- },
+ WME_WINENTRY("dreamscape", "",
+ WME_ENTRY1s("data.dcp", "7a5752ed4446c862be9f02d7932acf54", 17034377), Common::EN_ANY, ADGF_UNSTABLE, LATEST_VERSION),
// Escape from the Mansion
- {
- "escapemansion",
- "Beta 1",
- AD_ENTRY1s("data.dcp", "d8e348b2312cc36a929cad75f12e0b3a", 21452380),
- Common::EN_ANY,
- Common::kPlatformWindows,
- ADGF_UNSTABLE,
- GUIO0()
- },
+ WME_WINENTRY("escapemansion", "Beta 1",
+ WME_ENTRY1s("data.dcp", "d8e348b2312cc36a929cad75f12e0b3a", 21452380), Common::EN_ANY, ADGF_UNSTABLE, LATEST_VERSION),
// Escape from the Mansion
- {
- "escapemansion",
- "Beta 2",
- AD_ENTRY1s("data.dcp", "ded5fa6c5f2afdaf2cafb53e52cd3dd8", 21455763),
- Common::EN_ANY,
- Common::kPlatformWindows,
- ADGF_UNSTABLE,
- GUIO0()
- },
+ WME_WINENTRY("escapemansion", "Beta 2",
+ WME_ENTRY1s("data.dcp", "ded5fa6c5f2afdaf2cafb53e52cd3dd8", 21455763), Common::EN_ANY, ADGF_UNSTABLE, LATEST_VERSION),
// Escape from the Mansion
- {
- "escapemansion",
- "1.3",
- AD_ENTRY1s("data.dcp", "1e5d231b56c8a228cd15cb690f50253e", 29261972),
- Common::EN_ANY,
- Common::kPlatformWindows,
- ADGF_UNSTABLE,
- GUIO0()
- },
+ WME_WINENTRY("escapemansion", "1.3",
+ WME_ENTRY1s("data.dcp", "1e5d231b56c8a228cd15cb690f50253e", 29261972), Common::EN_ANY, ADGF_UNSTABLE, LATEST_VERSION),
// Four
- {
- "four",
- "",
- AD_ENTRY1s("data.dcp", "ec05cd5e37c9a524053b8859635a4234", 62599855),
- Common::EN_ANY,
- Common::kPlatformWindows,
- ADGF_UNSTABLE,
- GUIO0()
- },
+ WME_WINENTRY("four", "",
+ WME_ENTRY1s("data.dcp", "ec05cd5e37c9a524053b8859635a4234", 62599855), Common::EN_ANY, ADGF_UNSTABLE, LATEST_VERSION),
// Framed
- {
- "framed",
- "",
- AD_ENTRY1s("data.dcp", "e7259fb36f2c6f9f28242291e0c3de98", 34690568),
- Common::EN_ANY,
- Common::kPlatformWindows,
- ADGF_UNSTABLE,
- GUIO0()
- },
+ WME_WINENTRY("framed", "",
+ WME_ENTRY1s("data.dcp", "e7259fb36f2c6f9f28242291e0c3de98", 34690568), Common::EN_ANY, ADGF_UNSTABLE, LATEST_VERSION),
// Ghost in the Sheet
- {
- "ghostsheet",
- "",
- {
- {"english.dcp", 0, "e6d0aad2c89996bcabe416105a3d6d3a", 12221017},
- {"data.dcp", 0, "b2f8b05328e4881e15e98e845b63f451", 168003},
- AD_LISTEND
- },
- Common::EN_ANY,
- Common::kPlatformWindows,
- ADGF_UNSTABLE,
- GUIO0()
- },
+ WME_WINENTRY("ghostsheet", "",
+ WME_ENTRY2s("english.dcp", "e6d0aad2c89996bcabe416105a3d6d3a", 12221017,
+ "data.dcp", "b2f8b05328e4881e15e98e845b63f451", 168003), Common::EN_ANY, ADGF_UNSTABLE, LATEST_VERSION),
// Ghost in the Sheet (Demo)
- {
- "ghostsheet",
- "Demo",
- AD_ENTRY1s("data.dcp", "dc1f6595f412ac25a52eaf47dad4ab81", 169083),
- Common::EN_ANY,
- Common::kPlatformWindows,
- ADGF_UNSTABLE |
- ADGF_DEMO,
- GUIO0()
- },
+ WME_WINENTRY("ghostsheet", "Demo",
+ WME_ENTRY1s("data.dcp", "dc1f6595f412ac25a52eaf47dad4ab81", 169083), Common::EN_ANY, ADGF_UNSTABLE | ADGF_DEMO, LATEST_VERSION),
// Hamlet or the last game without MMORPS features, shaders and product placement
- {
- "hamlet",
- "",
- AD_ENTRY1s("data.dcp", "f624add957a77c9930529fb28cc2450f", 88183022),
- Common::EN_ANY,
- Common::kPlatformWindows,
- ADGF_UNSTABLE,
- GUIO0()
- },
+ WME_WINENTRY("hamlet", "",
+
+ WME_ENTRY1s("data.dcp", "f624add957a77c9930529fb28cc2450f", 88183022), Common::EN_ANY, ADGF_UNSTABLE, LATEST_VERSION),
// Helga Deep In Trouble (English)
- {
- "helga",
- "",
- {
- {"english.dcp", 0, "bfa136b21bdbc7d8691c0770a6d40bc3", 135931},
- {"data.dcp", 0, "25cb955a60b58326f2eeda1ce288fb37", 183251259},
- AD_LISTEND
- },
- Common::EN_ANY,
- Common::kPlatformWindows,
- ADGF_UNSTABLE,
- GUIO0()
- },
+ WME_WINENTRY("helga", "",
+ WME_ENTRY2s("english.dcp", "bfa136b21bdbc7d8691c0770a6d40bc3", 135931,
+ "data.dcp", "25cb955a60b58326f2eeda1ce288fb37", 183251259), Common::EN_ANY, ADGF_UNSTABLE, LATEST_VERSION),
// Helga Deep In Trouble (Demo) (English)
- {
- "helga",
- "Demo",
- {
- {"english.dcp", 0, "b3a93e678f0ef97200f691cd1724643f", 135864},
- {"data.dcp", 0, "45134ed93bc391edf148b79cdcbf2a09", 154266028},
- AD_LISTEND
- },
- Common::EN_ANY,
- Common::kPlatformWindows,
- ADGF_UNSTABLE |
- ADGF_DEMO,
- GUIO0()
- },
+ WME_WINENTRY("helga", "Demo",
+ WME_ENTRY2s("english.dcp", "b3a93e678f0ef97200f691cd1724643f", 135864,
+ "data.dcp", "45134ed93bc391edf148b79cdcbf2a09", 154266028), Common::EN_ANY, ADGF_UNSTABLE | ADGF_DEMO, LATEST_VERSION),
// James Peris: No License Nor Control (English)
- {
- "jamesperis",
- "",
- AD_ENTRY1s("data.dcp", "a420961e170cb7d168a0d2bae2fe5218", 225294032),
- Common::EN_ANY,
- Common::kPlatformWindows,
- ADGF_UNSTABLE,
- GUIO0()
- },
+ WME_WINENTRY("jamesperis", "",
+ WME_ENTRY1s("data.dcp", "a420961e170cb7d168a0d2bae2fe5218", 225294032), Common::EN_ANY, ADGF_UNSTABLE, LATEST_VERSION),
// James Peris: No License Nor Control (Spanish)
- {
- "jamesperis",
- "",
- AD_ENTRY1s("data.dcp", "a420961e170cb7d168a0d2bae2fe5218", 225294032),
- Common::ES_ESP,
- Common::kPlatformWindows,
- ADGF_UNSTABLE,
- GUIO0()
- },
+ WME_WINENTRY("jamesperis", "",
+ WME_ENTRY1s("data.dcp", "a420961e170cb7d168a0d2bae2fe5218", 225294032), Common::ES_ESP, ADGF_UNSTABLE, LATEST_VERSION),
// James Peris: No License Nor Control (Demo) (English)
- {
- "jamesperis",
- "Demo",
- AD_ENTRY1s("data.dcp", "edb9f9c7a08993c1e28f4e477b5f9830", 116113507),
- Common::EN_ANY,
- Common::kPlatformWindows,
- ADGF_UNSTABLE |
- ADGF_DEMO,
- GUIO0()
- },
+ WME_WINENTRY("jamesperis", "Demo",
+ WME_ENTRY1s("data.dcp", "edb9f9c7a08993c1e28f4e477b5f9830", 116113507), Common::EN_ANY, ADGF_UNSTABLE | ADGF_DEMO, LATEST_VERSION),
// James Peris: No License Nor Control (Demo) (Spanish)
- {
- "jamesperis",
- "Demo",
- AD_ENTRY1s("data.dcp", "edb9f9c7a08993c1e28f4e477b5f9830", 116113507),
- Common::ES_ESP,
- Common::kPlatformWindows,
- ADGF_UNSTABLE |
- ADGF_DEMO,
- GUIO0()
- },
+ WME_WINENTRY("jamesperis", "Demo",
+ WME_ENTRY1s("data.dcp", "edb9f9c7a08993c1e28f4e477b5f9830", 116113507), Common::ES_ESP, ADGF_UNSTABLE | ADGF_DEMO, LATEST_VERSION),
// J.U.L.I.A. (English)
- {
- "julia",
- "",
- AD_ENTRY1s("data.dcp", "c2264b4f8fcd132d2913ff5b6076a24f", 10109741),
- Common::EN_ANY,
- Common::kPlatformWindows,
- ADGF_UNSTABLE,
- GUIO0()
- },
+ WME_WINENTRY("julia", "",
+ WME_ENTRY1s("data.dcp", "c2264b4f8fcd132d2913ff5b6076a24f", 10109741), Common::EN_ANY, ADGF_UNSTABLE, LATEST_VERSION),
// J.U.L.I.A. (English, Bundle in a box-version)
- {
- "julia",
- "Version 1.2",
- AD_ENTRY1s("data.dcp", "fe90023ccc22f35185b40b910e0d03a2", 10101373),
- Common::EN_ANY,
- Common::kPlatformWindows,
- ADGF_UNSTABLE,
- GUIO0()
- },
+ WME_WINENTRY("julia", "Version 1.2",
+ WME_ENTRY1s("data.dcp", "fe90023ccc22f35185b40b910e0d03a2", 10101373), Common::EN_ANY, ADGF_UNSTABLE, LATEST_VERSION),
// J.U.L.I.A. (English) (Demo)
- {
- "julia",
- "Demo",
- AD_ENTRY1s("data.dcp", "f0bbc3394555a9811f6050dae428cab6", 7655237),
- Common::EN_ANY,
- Common::kPlatformWindows,
- ADGF_UNSTABLE |
- ADGF_DEMO,
- GUIO0()
- },
+ WME_WINENTRY("julia", "Demo",
+ WME_ENTRY1s("data.dcp", "f0bbc3394555a9811f6050dae428cab6", 7655237), Common::EN_ANY, ADGF_UNSTABLE | ADGF_DEMO, LATEST_VERSION),
// J.U.L.I.A. (English) (Greenlight Demo)
- {
- "julia",
- "Greenlight Demo",
- AD_ENTRY1s("data.dcp", "4befd448d36b0dae9c3ab1aa7cb8b78d", 7271886),
- Common::EN_ANY,
- Common::kPlatformWindows,
- ADGF_UNSTABLE |
- ADGF_DEMO,
- GUIO0()
- },
+ WME_WINENTRY("julia", "Greenlight Demo",
+ WME_ENTRY1s("data.dcp", "4befd448d36b0dae9c3ab1aa7cb8b78d", 7271886), Common::EN_ANY, ADGF_UNSTABLE | ADGF_DEMO, LATEST_VERSION),
// Kulivocko (Czech)
- {
- "kulivocko",
- "",
- AD_ENTRY1s("data.dcp", "44306dc470e9b27474043932eccee02f", 155106392),
- Common::CZ_CZE,
- Common::kPlatformWindows,
- ADGF_UNSTABLE,
- GUIO0()
- },
+ WME_WINENTRY("kulivocko", "",
+ WME_ENTRY1s("data.dcp", "44306dc470e9b27474043932eccee02f", 155106392), Common::CZ_CZE, ADGF_UNSTABLE, LATEST_VERSION),
// Kulivocko (Czech) (Demo)
- {
- "kulivocko",
- "Demo",
- AD_ENTRY1s("data.dcp", "63b164bdfadecbb0deb5da691afb8154", 48362234),
- Common::CZ_CZE,
- Common::kPlatformWindows,
- ADGF_UNSTABLE |
- ADGF_DEMO,
- GUIO0()
- },
+ WME_WINENTRY("kulivocko", "Demo",
+ WME_ENTRY1s("data.dcp", "63b164bdfadecbb0deb5da691afb8154", 48362234), Common::CZ_CZE, ADGF_UNSTABLE | ADGF_DEMO, LATEST_VERSION),
// Life In 3 Minutes
- {
- "lifein3minutes",
- "",
- AD_ENTRY1s("data.dcp", "c6368950e37a95bf098b02b4eaa5b929", 141787214),
- Common::EN_ANY,
- Common::kPlatformWindows,
- ADGF_UNSTABLE,
- GUIO0()
- },
+ WME_WINENTRY("lifein3minutes", "",
+ WME_ENTRY1s("data.dcp", "c6368950e37a95bf098b02b4eaa5b929", 141787214), Common::EN_ANY, ADGF_UNSTABLE, LATEST_VERSION),
// Looky Demo (English)
- {
- "looky",
- "Demo",
- {
- {"english.dcp", 0, "1388e1dd320f4d553dea3b0316812f9d", 1358442},
- {"data.dcp", 0, "7074bcd7bc7ad7eb04c271aafb964c32", 13815660},
- AD_LISTEND
- },
- Common::EN_ANY,
- Common::kPlatformWindows,
- ADGF_UNSTABLE |
- ADGF_DEMO,
- GUIO0()
- },
+ WME_WINENTRY("looky", "Demo",
+ WME_ENTRY2s("english.dcp", "1388e1dd320f4d553dea3b0316812f9d", 1358442,
+ "data.dcp", "7074bcd7bc7ad7eb04c271aafb964c32", 13815660), Common::EN_ANY, ADGF_UNSTABLE | ADGF_DEMO, LATEST_VERSION),
// Looky Demo (German)
- {
- "looky",
- "Demo",
- {
- {"german.dcp", 0, "606c048426dfbe94442b59fd34a5c76e", 14339496},
- {"data.dcp", 0, "7074bcd7bc7ad7eb04c271aafb964c32", 13815660},
- AD_LISTEND
- },
- Common::DE_DEU,
- Common::kPlatformWindows,
- ADGF_UNSTABLE |
- ADGF_DEMO,
- GUIO0()
- },
+ WME_WINENTRY("looky", "Demo",
+ WME_ENTRY2s("german.dcp", "606c048426dfbe94442b59fd34a5c76e", 14339496,
+ "data.dcp", "7074bcd7bc7ad7eb04c271aafb964c32", 13815660), Common::DE_DEU, ADGF_UNSTABLE | ADGF_DEMO, LATEST_VERSION),
// Looky (German)
- {
- "looky",
- "",
- {
- {"german.dcp", 0, "bf4c2b8c26342342441a6d64934ab832", 107027865},
- {"data.dcp", 0, "50de0beaa5ad621aa9f020df901d1e74", 1342214},
- AD_LISTEND
- },
- Common::DE_DEU,
- Common::kPlatformWindows,
- ADGF_UNSTABLE,
- GUIO0()
- },
+ WME_WINENTRY("looky", "",
+ WME_ENTRY2s("german.dcp", "bf4c2b8c26342342441a6d64934ab832", 107027865,
+ "data.dcp", "50de0beaa5ad621aa9f020df901d1e74", 1342214), Common::DE_DEU, ADGF_UNSTABLE, LATEST_VERSION),
// Mirage
- {
- "mirage",
- "",
- AD_ENTRY1s("data.dcp", "d230b0b99c0aa77b9ecd094d8ee5573b", 17844056),
- Common::EN_ANY,
- Common::kPlatformWindows,
- ADGF_UNSTABLE,
- GUIO0()
- },
+ WME_WINENTRY("mirage", "",
+ WME_ENTRY1s("data.dcp", "d230b0b99c0aa77b9ecd094d8ee5573b", 17844056), Common::EN_ANY, ADGF_UNSTABLE, LATEST_VERSION),
// Oknytt
- {
- "oknytt",
- "Version 1.0",
- AD_ENTRY1s("data.dcp", "6456cf8f429905c83f07509f9da536dd", 109502959),
- Common::EN_ANY,
- Common::kPlatformWindows,
- ADGF_UNSTABLE,
- GUIO0()
- },
+ WME_WINENTRY("oknytt", "Version 1.0",
+ WME_ENTRY1s("data.dcp", "6456cf8f429905c83f07509f9da536dd", 109502959), Common::EN_ANY, ADGF_UNSTABLE, LATEST_VERSION),
// Night Train Demo
- {
- "nighttrain",
- "",
- AD_ENTRY1s("data.dcp", "5a027ef84b083a730c9a4c85ec1d3a32", 131760816),
- Common::EN_ANY,
- Common::kPlatformWindows,
- ADGF_UNSTABLE |
- ADGF_DEMO,
- GUIO0()
- },
+ WME_WINENTRY("nighttrain", "",
+ WME_ENTRY1s("data.dcp", "5a027ef84b083a730c9a4c85ec1d3a32", 131760816), Common::EN_ANY, ADGF_UNSTABLE | ADGF_DEMO, LATEST_VERSION),
// Paintaria
- {
- "paintaria",
- "",
- AD_ENTRY1s("data.dcp", "354c08440c98150ff0d4008dd2865880", 48326040),
- Common::EN_ANY,
- Common::kPlatformWindows,
- ADGF_UNSTABLE,
- GUIO0()
- },
+ WME_WINENTRY("paintaria", "",
+ WME_ENTRY1s("data.dcp", "354c08440c98150ff0d4008dd2865880", 48326040), Common::EN_ANY, ADGF_UNSTABLE, LATEST_VERSION),
// Pigeons in the Park
- {
- "pigeons",
- "",
- AD_ENTRY1s("data.dcp", "9143a5b6ff8206aefe3c4c643add3ec7", 2611100),
- Common::EN_ANY,
- Common::kPlatformWindows,
- ADGF_UNSTABLE,
- GUIO0()
- },
+ WME_WINENTRY("pigeons", "",
+ WME_ENTRY1s("data.dcp", "9143a5b6ff8206aefe3c4c643add3ec7", 2611100), Common::EN_ANY, ADGF_UNSTABLE, LATEST_VERSION),
// Project: Doom
- {
- "projectdoom",
- "",
- AD_ENTRY1s("data.dcp", "d5894b65a40706845434b99870bcab92", 99223761),
- Common::EN_ANY,
- Common::kPlatformWindows,
- ADGF_UNSTABLE,
- GUIO0()
- },
+ WME_WINENTRY("projectdoom", "",
+ WME_ENTRY1s("data.dcp", "d5894b65a40706845434b99870bcab92", 99223761), Common::EN_ANY, ADGF_UNSTABLE, LATEST_VERSION),
// Project Joe
- {
- "projectjoe",
- "",
- AD_ENTRY1s("data.dcp", "ada3c08542901295076b5349e655e73f", 160780037),
- Common::EN_ANY,
- Common::kPlatformWindows,
- ADGF_UNSTABLE |
- ADGF_DEMO,
- GUIO0()
- },
+ WME_WINENTRY("projectjoe", "",
+ WME_ENTRY1s("data.dcp", "ada3c08542901295076b5349e655e73f", 160780037), Common::EN_ANY, ADGF_UNSTABLE | ADGF_DEMO, LATEST_VERSION),
// Project Lonely Robot
- {
- "lonelyrobot",
- "beta",
- AD_ENTRY1s("data.dcp", "a0cf7ad5bab957416dcda454e9f28ef0", 3420120),
- Common::EN_ANY,
- Common::kPlatformWindows,
- ADGF_UNSTABLE |
- ADGF_DEMO,
- GUIO0()
- },
+ WME_WINENTRY("lonelyrobot", "beta",
+ WME_ENTRY1s("data.dcp", "a0cf7ad5bab957416dcda454e9f28ef0", 3420120), Common::EN_ANY, ADGF_UNSTABLE | ADGF_DEMO, LATEST_VERSION),
// Reversion: The Escape Version 1.0
- {
- "reversion1",
- "Version 1.0",
- AD_ENTRY1s("data.dcp", "cd616f98ebfd047e0c540b50b4b70761", 254384531),
- Common::EN_ANY,
- Common::kPlatformWindows,
- ADGF_UNSTABLE,
- GUIO0()
- },
+ WME_WINENTRY("reversion1", "Version 1.0",
+ WME_ENTRY1s("data.dcp", "cd616f98ebfd047e0c540b50b4b70761", 254384531), Common::EN_ANY, ADGF_UNSTABLE, LATEST_VERSION),
// Reversion: The Escape Version 1.1 (Chinese)
- {
- "reversion1",
- "Version 1.1",
- {
- {"chinese.dcp", 0, "cf97150739499a4c15f51dc534ff85a1", 6330561},
- {"data.dcp", 0, "cb9865dc7e1db2990a8cf4bc13cf4999", 257643032},
- AD_LISTEND
- },
- Common::ZH_CNA,
- Common::kPlatformWindows,
- ADGF_UNSTABLE,
- GUIO0()
- },
+ WME_WINENTRY("reversion1", "Version 1.1",
+ WME_ENTRY2s("chinese.dcp", "cf97150739499a4c15f51dc534ff85a1", 6330561,
+ "data.dcp", "cb9865dc7e1db2990a8cf4bc13cf4999", 257643032), Common::ZH_CNA, ADGF_UNSTABLE, LATEST_VERSION),
// Reversion: The Escape Version 1.1 (English)
- {
- "reversion1",
- "Version 1.1",
- {
- {"english.dcp", 0, "7b2f061d7c91365c5d04605f1de032b3", 5702699},
- {"data.dcp", 0, "cb9865dc7e1db2990a8cf4bc13cf4999", 257643032},
- AD_LISTEND
- },
- Common::EN_ANY,
- Common::kPlatformWindows,
- ADGF_UNSTABLE,
- GUIO0()
- },
+ WME_WINENTRY("reversion1", "Version 1.1",
+ WME_ENTRY2s("english.dcp", "7b2f061d7c91365c5d04605f1de032b3", 5702699,
+ "data.dcp", "cb9865dc7e1db2990a8cf4bc13cf4999", 257643032), Common::EN_ANY, ADGF_UNSTABLE, LATEST_VERSION),
// Reversion: The Escape Version 1.1 (French)
- {
- "reversion1",
- "Version 1.1",
- {
- {"french.dcp", 0, "214204b6022c5ed67fada44557690faf", 6327400},
- {"data.dcp", 0, "cb9865dc7e1db2990a8cf4bc13cf4999", 257643032},
- AD_LISTEND
- },
- Common::FR_FRA,
- Common::kPlatformWindows,
- ADGF_UNSTABLE,
- GUIO0()
- },
+ WME_WINENTRY("reversion1", "Version 1.1",
+ WME_ENTRY2s("french.dcp", "214204b6022c5ed67fada44557690faf", 6327400,
+ "data.dcp", "cb9865dc7e1db2990a8cf4bc13cf4999", 257643032), Common::FR_FRA, ADGF_UNSTABLE, LATEST_VERSION),
// Reversion: The Escape Version 1.1 (German)
- {
- "reversion1",
- "Version 1.1",
- {
- {"german.dcp", 0, "96677823b36d580a4a29e3659071071c", 6340699},
- {"data.dcp", 0, "cb9865dc7e1db2990a8cf4bc13cf4999", 257643032},
- AD_LISTEND
- },
- Common::DE_DEU,
- Common::kPlatformWindows,
- ADGF_UNSTABLE,
- GUIO0()
- },
+ WME_WINENTRY("reversion1", "Version 1.1",
+ WME_ENTRY2s("german.dcp", "96677823b36d580a4a29e3659071071c", 6340699,
+ "data.dcp", "cb9865dc7e1db2990a8cf4bc13cf4999", 257643032), Common::DE_DEU, ADGF_UNSTABLE, LATEST_VERSION),
// Reversion: The Escape Version 1.1 (Italian)
- {
- "reversion1",
- "Version 1.1",
- {
- {"italian.dcp", 0, "9ce80c1835108f10170a02969f71efe1", 6301836},
- {"data.dcp", 0, "cb9865dc7e1db2990a8cf4bc13cf4999", 257643032},
- AD_LISTEND
- },
- Common::IT_ITA,
- Common::kPlatformWindows,
- ADGF_UNSTABLE,
- GUIO0()
- },
+ WME_WINENTRY("reversion1", "Version 1.1",
+ WME_ENTRY2s("italian.dcp", "9ce80c1835108f10170a02969f71efe1", 6301836,
+ "data.dcp", "cb9865dc7e1db2990a8cf4bc13cf4999", 257643032), Common::IT_ITA, ADGF_UNSTABLE, LATEST_VERSION),
// Reversion: The Escape Version 1.1 (Portuguese)
- {
- "reversion1",
- "Version 1.1",
- {
- {"portugues.dcp", 0, "8772501afa2c630a7c697eb99e9c7bda", 5053303},
- {"data.dcp", 0, "cb9865dc7e1db2990a8cf4bc13cf4999", 257643032},
- AD_LISTEND
- },
- Common::PT_BRA,
- Common::kPlatformWindows,
- ADGF_UNSTABLE,
- GUIO0()
- },
+ WME_WINENTRY("reversion1", "Version 1.1",
+ WME_ENTRY2s("portugues.dcp", "8772501afa2c630a7c697eb99e9c7bda", 5053303,
+ "data.dcp", "cb9865dc7e1db2990a8cf4bc13cf4999", 257643032), Common::PT_BRA, ADGF_UNSTABLE, LATEST_VERSION),
// Reversion: The Escape Version 1.3 (Chinese)
- {
- "reversion1",
- "Version 1.3",
- {
- {"xlanguage_nz.dcp", 0, "92c4065156e464211685bf799b3279fd", 5130600},
- {"data.dcp", 0, "9ebb12f6fd7c038d079f81beb3bd96d5", 254185907},
- AD_LISTEND
- },
- Common::ZH_CNA,
- Common::kPlatformWindows,
- ADGF_UNSTABLE,
- GUIO0()
- },
+ WME_WINENTRY("reversion1", "Version 1.3",
+ WME_ENTRY2s("xlanguage_nz.dcp", "92c4065156e464211685bf799b3279fd", 5130600,
+ "data.dcp", "9ebb12f6fd7c038d079f81beb3bd96d5", 254185907), Common::ZH_CNA, ADGF_UNSTABLE, LATEST_VERSION),
// Reversion: The Escape Version 1.3 (English)
- {
- "reversion1",
- "Version 1.3",
- {
- {"xlanguage_en.dcp", 0, "05845e1283920a6e4044f2a54f7a9519", 4818543},
- {"data.dcp", 0, "9ebb12f6fd7c038d079f81beb3bd96d5", 254185907},
- AD_LISTEND
- },
- Common::EN_ANY,
- Common::kPlatformWindows,
- ADGF_UNSTABLE,
- GUIO0()
- },
+ WME_WINENTRY("reversion1", "Version 1.3",
+ WME_ENTRY2s("xlanguage_en.dcp", "05845e1283920a6e4044f2a54f7a9519", 4818543,
+ "data.dcp", "9ebb12f6fd7c038d079f81beb3bd96d5", 254185907), Common::EN_ANY, ADGF_UNSTABLE, LATEST_VERSION),
// Reversion: The Escape Version 1.3 (French)
- {
- "reversion1",
- "Version 1.3",
- {
- {"xlanguage_fr.dcp", 0, "441795490e9307eb2ed07830779881ac", 5425959},
- {"data.dcp", 0, "9ebb12f6fd7c038d079f81beb3bd96d5", 254185907},
- AD_LISTEND
- },
- Common::FR_FRA,
- Common::kPlatformWindows,
- ADGF_UNSTABLE,
- GUIO0()
- },
+ WME_WINENTRY("reversion1", "Version 1.3",
+ WME_ENTRY2s("xlanguage_fr.dcp", "441795490e9307eb2ed07830779881ac", 5425959,
+ "data.dcp", "9ebb12f6fd7c038d079f81beb3bd96d5", 254185907), Common::FR_FRA, ADGF_UNSTABLE, LATEST_VERSION),
// Reversion: The Escape Version 1.3 (German)
- {
- "reversion1",
- "Version 1.3",
- {
- {"xlanguage_de.dcp", 0, "b588041015b93e54b4c246ca77d01e76", 5423798},
- {"data.dcp", 0, "9ebb12f6fd7c038d079f81beb3bd96d5", 254185907},
- AD_LISTEND
- },
- Common::DE_DEU,
- Common::kPlatformWindows,
- ADGF_UNSTABLE,
- GUIO0()
- },
+ WME_WINENTRY("reversion1", "Version 1.3",
+ WME_ENTRY2s("xlanguage_de.dcp", "b588041015b93e54b4c246ca77d01e76", 5423798,
+ "data.dcp", "9ebb12f6fd7c038d079f81beb3bd96d5", 254185907), Common::DE_DEU, ADGF_UNSTABLE, LATEST_VERSION),
// Reversion: The Escape Version 1.3 (Italian)
- {
- "reversion1",
- "Version 1.3",
- {
- {"xlanguage_it.dcp", 0, "a1f4199079b75ee10cded41f05b45d5f", 5386424},
- {"data.dcp", 0, "9ebb12f6fd7c038d079f81beb3bd96d5", 254185907},
- AD_LISTEND
- },
- Common::IT_ITA,
- Common::kPlatformWindows,
- ADGF_UNSTABLE,
- GUIO0()
- },
+ WME_WINENTRY("reversion1", "Version 1.3",
+ WME_ENTRY2s("xlanguage_it.dcp", "a1f4199079b75ee10cded41f05b45d5f", 5386424,
+ "data.dcp", "9ebb12f6fd7c038d079f81beb3bd96d5", 254185907), Common::IT_ITA, ADGF_UNSTABLE, LATEST_VERSION),
// Reversion: The Escape Version 1.3 (Portuguese)
- {
- "reversion1",
- "Version 1.3",
- {
- {"xlanguage_pt.dcp", 0, "3d653debd37e56756a79401e1004c4d2", 4149165},
- {"data.dcp", 0, "9ebb12f6fd7c038d079f81beb3bd96d5", 254185907},
- AD_LISTEND
- },
- Common::PT_BRA,
- Common::kPlatformWindows,
- ADGF_UNSTABLE,
- GUIO0()
- },
+ WME_WINENTRY("reversion1", "Version 1.3",
+ WME_ENTRY2s("xlanguage_pt.dcp", "3d653debd37e56756a79401e1004c4d2", 4149165,
+ "data.dcp", "9ebb12f6fd7c038d079f81beb3bd96d5", 254185907), Common::PT_BRA, ADGF_UNSTABLE, LATEST_VERSION),
// Reversion: The Escape Version 1.3.2369 (Chinese)
- {
- "reversion1",
- "Version 1.3.2369",
- {
- {"xlanguage_nz.dcp", 0, "7146dfa43ffdf0886e034fffe2c8a0c0", 13722261},
- {"data.dcp", 0, "aecb5deeea7b0baa871fbd0cef35a648", 254219204},
- AD_LISTEND
- },
- Common::ZH_CNA,
- Common::kPlatformWindows,
- ADGF_UNSTABLE,
- GUIO0()
- },
+ WME_WINENTRY("reversion1", "Version 1.3.2369",
+ WME_ENTRY2s("xlanguage_nz.dcp", "7146dfa43ffdf0886e034fffe2c8a0c0", 13722261,
+ "data.dcp", "aecb5deeea7b0baa871fbd0cef35a648", 254219204), Common::ZH_CNA, ADGF_UNSTABLE, LATEST_VERSION),
// Reversion: The Escape Version 1.3.2369 (English)
- {
- "reversion1",
- "Version 1.3.2369",
- {
- {"xlanguage_en.dcp", 0, "64b6fa7eedc09c231f6ce046e77fee05", 11339619},
- {"data.dcp", 0, "aecb5deeea7b0baa871fbd0cef35a648", 254219204},
- AD_LISTEND
- },
- Common::EN_ANY,
- Common::kPlatformWindows,
- ADGF_UNSTABLE,
- GUIO0()
- },
+ WME_WINENTRY("reversion1", "Version 1.3.2369",
+ WME_ENTRY2s("xlanguage_en.dcp", "64b6fa7eedc09c231f6ce046e77fee05", 11339619,
+ "data.dcp", "aecb5deeea7b0baa871fbd0cef35a648", 254219204), Common::EN_ANY, ADGF_UNSTABLE, LATEST_VERSION),
// Reversion: The Escape Version 1.3.2369 (French)
- {
- "reversion1",
- "Version 1.3.2369",
- {
- {"xlanguage_fr.dcp", 0, "d561d562224afea809153a1fd9fdb0c0", 11963210},
- {"data.dcp", 0, "aecb5deeea7b0baa871fbd0cef35a648", 254219204},
- AD_LISTEND
- },
- Common::FR_FRA,
- Common::kPlatformWindows,
- ADGF_UNSTABLE,
- GUIO0()
- },
+ WME_WINENTRY("reversion1", "Version 1.3.2369",
+ WME_ENTRY2s("xlanguage_fr.dcp", "d561d562224afea809153a1fd9fdb0c0", 11963210,
+ "data.dcp", "aecb5deeea7b0baa871fbd0cef35a648", 254219204), Common::FR_FRA, ADGF_UNSTABLE, LATEST_VERSION),
// Reversion: The Escape Version 1.3.2369 (German)
- {
- "reversion1",
- "Version 1.3.2369",
- {
- {"xlanguage_de.dcp", 0, "4e3f614c36bd6bae74b8cc83e663a8f0", 14040310},
- {"data.dcp", 0, "aecb5deeea7b0baa871fbd0cef35a648", 254219204},
- AD_LISTEND
- },
- Common::DE_DEU,
- Common::kPlatformWindows,
- ADGF_UNSTABLE,
- GUIO0()
- },
+ WME_WINENTRY("reversion1", "Version 1.3.2369",
+ WME_ENTRY2s("xlanguage_de.dcp", "4e3f614c36bd6bae74b8cc83e663a8f0", 14040310,
+ "data.dcp", "aecb5deeea7b0baa871fbd0cef35a648", 254219204), Common::DE_DEU, ADGF_UNSTABLE, LATEST_VERSION),
// Reversion: The Escape Version 1.3.2369 (Italian)
- {
- "reversion1",
- "Version 1.3.2369",
- {
- {"xlanguage_it.dcp", 0, "10d09b7fe61946f09dd91d5e8d090f94", 11913752},
- {"data.dcp", 0, "aecb5deeea7b0baa871fbd0cef35a648", 254219204},
- AD_LISTEND
- },
- Common::IT_ITA,
- Common::kPlatformWindows,
- ADGF_UNSTABLE,
- GUIO0()
- },
+ WME_WINENTRY("reversion1", "Version 1.3.2369",
+ WME_ENTRY2s("xlanguage_it.dcp", "10d09b7fe61946f09dd91d5e8d090f94", 11913752,
+ "data.dcp", "aecb5deeea7b0baa871fbd0cef35a648", 254219204), Common::IT_ITA, ADGF_UNSTABLE, LATEST_VERSION),
// Reversion: The Escape Version 1.3.2369 (Latvian)
- {
- "reversion1",
- "Version 1.3.2369",
- {
- {"xlanguage_lv.dcp", 0, "704359ab5040b0dab6545064d7aa6eb9", 11414925},
- {"data.dcp", 0, "aecb5deeea7b0baa871fbd0cef35a648", 254219204},
- AD_LISTEND
- },
- Common::LV_LAT,
- Common::kPlatformWindows,
- ADGF_UNSTABLE,
- GUIO0()
- },
+ WME_WINENTRY("reversion1", "Version 1.3.2369",
+ WME_ENTRY2s("xlanguage_lv.dcp", "704359ab5040b0dab6545064d7aa6eb9", 11414925,
+ "data.dcp", "aecb5deeea7b0baa871fbd0cef35a648", 254219204), Common::LV_LAT, ADGF_UNSTABLE, LATEST_VERSION),
// Reversion: The Escape Version 1.3.2369 (Polish)
- {
- "reversion1",
- "Version 1.3.2369",
- {
- {"xlanguage_pl.dcp", 0, "c4ad33f57e1e998169552d521c1d6638", 11532215},
- {"data.dcp", 0, "aecb5deeea7b0baa871fbd0cef35a648", 254219204},
- AD_LISTEND
- },
- Common::PL_POL,
- Common::kPlatformWindows,
- ADGF_UNSTABLE,
- GUIO0()
- },
+ WME_WINENTRY("reversion1", "Version 1.3.2369",
+ WME_ENTRY2s("xlanguage_pl.dcp", "c4ad33f57e1e998169552d521c1d6638", 11532215,
+ "data.dcp", "aecb5deeea7b0baa871fbd0cef35a648", 254219204), Common::PL_POL, ADGF_UNSTABLE, LATEST_VERSION),
// Reversion: The Escape Version 1.3.2369 (Portuguese)
- {
- "reversion1",
- "Version 1.3.2369",
- {
- {"xlanguage_pt.dcp", 0, "886886b6b14aadac844078de856799a6", 10620797},
- {"data.dcp", 0, "aecb5deeea7b0baa871fbd0cef35a648", 254219204},
- AD_LISTEND
- },
- Common::PT_BRA,
- Common::kPlatformWindows,
- ADGF_UNSTABLE,
- GUIO0()
- },
+ WME_WINENTRY("reversion1", "Version 1.3.2369",
+ WME_ENTRY2s("xlanguage_pt.dcp", "886886b6b14aadac844078de856799a6", 10620797,
+ "data.dcp", "aecb5deeea7b0baa871fbd0cef35a648", 254219204), Common::PT_BRA, ADGF_UNSTABLE, LATEST_VERSION),
// Reversion: The Meeting (Chinese)
- {
- "reversion2",
- "",
- {
- {"xlanguage_nz.dcp", 0, "8c3709474a87a7876109025dff41ff3f", 8746015},
- {"data.dcp", 0, "cb9865dc7e1db2990a8cf4bc13cf4999", 257643032},
- AD_LISTEND
- },
- Common::ZH_CNA,
- Common::kPlatformWindows,
- ADGF_UNSTABLE,
- GUIO0()
- },
+ WME_WINENTRY("reversion2", "",
+ WME_ENTRY2s("xlanguage_nz.dcp", "8c3709474a87a7876109025dff41ff3f", 8746015,
+ "data.dcp", "cb9865dc7e1db2990a8cf4bc13cf4999", 257643032), Common::ZH_CNA, ADGF_UNSTABLE, LATEST_VERSION),
// Reversion: The Meeting (English)
- {
- "reversion2",
- "",
- {
- {"xlanguage_en.dcp", 0, "ca357d86618d1ab76a21c913f4403cbd", 8414976},
- {"data.dcp", 0, "f7938cbfdc48f07934550245a3286921", 255672016},
- AD_LISTEND
- },
- Common::EN_ANY,
- Common::kPlatformWindows,
- ADGF_UNSTABLE,
- GUIO0()
- },
+ WME_WINENTRY("reversion2", "",
+ WME_ENTRY2s("xlanguage_en.dcp", "ca357d86618d1ab76a21c913f4403cbd", 8414976,
+ "data.dcp", "f7938cbfdc48f07934550245a3286921", 255672016), Common::EN_ANY, ADGF_UNSTABLE, LATEST_VERSION),
// Reversion: The Meeting (Spanish)
- {
- "reversion2",
- "",
- AD_ENTRY1s("data.dcp", "f7938cbfdc48f07934550245a3286921", 255672016),
- Common::ES_ESP,
- Common::kPlatformWindows,
- ADGF_UNSTABLE,
- GUIO0()
- },
+ WME_WINENTRY("reversion2", "",
+ WME_ENTRY1s("data.dcp", "f7938cbfdc48f07934550245a3286921", 255672016), Common::ES_ESP, ADGF_UNSTABLE, LATEST_VERSION),
// Reversion: The Meeting Version 2.0.2412 (Chinese)
- {
- "reversion2",
- "Version 2.0.2412",
- {
- {"data.dcp", 0, "f4ffc4df24b7bebad56a24930f33a2bc", 255766600},
- {"xlanguage_nz.dcp", 0, "17c79af4928e24484bee77a7e807cc2a", 10737127},
- {"Linux.dcp", 0, "21858bd77dc86b03f701fd47900e2f51", 984535},
- AD_LISTEND
- },
- Common::ZH_CNA,
- Common::kPlatformLinux,
- ADGF_UNSTABLE,
- GUIO0()
- },
+ WME_PLATENTRY("reversion2", "Version 2.0.2412",
+ WME_ENTRY3s("data.dcp", "f4ffc4df24b7bebad56a24930f33a2bc", 255766600,
+ "xlanguage_nz.dcp", "17c79af4928e24484bee77a7e807cc2a", 10737127,
+ "Linux.dcp", "21858bd77dc86b03f701fd47900e2f51", 984535), Common::ZH_CNA, Common::kPlatformLinux, ADGF_UNSTABLE, LATEST_VERSION),
// Reversion: The Meeting Version 2.0.2412 (English)
- {
- "reversion2",
- "Version 2.0.2412",
- {
- {"data.dcp", 0, "f4ffc4df24b7bebad56a24930f33a2bc", 255766600},
- {"xlanguage_en.dcp", 0, "0598bf752ce93b42bcaf1094df537c7b", 8533057},
- {"Linux.dcp", 0, "21858bd77dc86b03f701fd47900e2f51", 984535},
- AD_LISTEND
- },
- Common::EN_ANY,
- Common::kPlatformLinux,
- ADGF_UNSTABLE,
- GUIO0()
- },
+ WME_PLATENTRY("reversion2", "Version 2.0.2412",
+ WME_ENTRY3s("data.dcp", "f4ffc4df24b7bebad56a24930f33a2bc", 255766600,
+ "xlanguage_en.dcp", "0598bf752ce93b42bcaf1094df537c7b", 8533057,
+ "Linux.dcp", "21858bd77dc86b03f701fd47900e2f51", 984535), Common::EN_ANY, Common::kPlatformLinux, ADGF_UNSTABLE, LATEST_VERSION),
// Rhiannon: Curse of the four Branches
- {
- "rhiannon",
- "",
- AD_ENTRY1s("data.dcp", "870f348900b735f1cc79c0608ce32b0e", 1046169851),
- Common::EN_ANY,
- Common::kPlatformWindows,
- ADGF_UNSTABLE,
- GUIO0()
- },
+ WME_WINENTRY("rhiannon", "",
+ WME_ENTRY1s("data.dcp", "870f348900b735f1cc79c0608ce32b0e", 1046169851), Common::EN_ANY, ADGF_UNSTABLE, LATEST_VERSION),
// Rhiannon: Curse of the four Branches (English PC DVD)
- {
- "rhiannon",
- "DVD",
- AD_ENTRY1s("data.dcp", "6736bbc921bb6ce5161b3ad095a97bd4", 1053441028),
- Common::EN_ANY,
- Common::kPlatformWindows,
- ADGF_UNSTABLE,
- GUIO0()
- },
+ WME_WINENTRY("rhiannon", "DVD",
+ WME_ENTRY1s("data.dcp", "6736bbc921bb6ce5161b3ad095a97bd4", 1053441028), Common::EN_ANY, ADGF_UNSTABLE, LATEST_VERSION),
// 1 1/2 Ritter: Auf der Suche nach der hinreissenden Herzelinde
- {
- "ritter",
- "",
- AD_ENTRY1s("data.dcp", "5ac416cee605d3a30f4d59687b1cdab2", 364260278),
- Common::DE_DEU,
- Common::kPlatformWindows,
- ADGF_UNSTABLE,
- GUIO0()
- },
+ WME_WINENTRY("ritter", "",
+ WME_ENTRY1s("data.dcp", "5ac416cee605d3a30f4d59687b1cdab2", 364260278), Common::DE_DEU, ADGF_UNSTABLE, LATEST_VERSION),
// Satan and Son
- {
- "satanandson",
- "",
- AD_ENTRY1s("data.dcp", "16a6ba8174b697bbba9299619d1e20c4", 67539054),
- Common::EN_ANY,
- Common::kPlatformWindows,
- ADGF_UNSTABLE |
- ADGF_DEMO,
- GUIO0()
- },
+ WME_WINENTRY("satanandson", "",
+ WME_ENTRY1s("data.dcp", "16a6ba8174b697bbba9299619d1e20c4", 67539054), Common::EN_ANY, ADGF_UNSTABLE | ADGF_DEMO, LATEST_VERSION),
// Rosemary
- {
- "rosemary",
- "",
- AD_ENTRY1s("data.dcp", "4f2631138bd4d27587d9043f8aeff3df", 29483643),
- Common::EN_ANY,
- Common::kPlatformWindows,
- ADGF_UNSTABLE,
- GUIO0()
- },
+ WME_WINENTRY("rosemary", "",
+ WME_ENTRY1s("data.dcp", "4f2631138bd4d27587d9043f8aeff3df", 29483643), Common::EN_ANY, ADGF_UNSTABLE, LATEST_VERSION),
// Securanote
- {
- "securanote",
- "",
- AD_ENTRY1s("data.dcp", "5213d3e59b9e95b7fbd5c56f7de5341a", 2625554),
- Common::EN_ANY,
- Common::kPlatformIOS,
- ADGF_UNSTABLE,
- GUIO0()
- },
+ WME_PLATENTRY("securanote", "",
+ WME_ENTRY1s("data.dcp", "5213d3e59b9e95b7fbd5c56f7de5341a", 2625554), Common::EN_ANY, Common::kPlatformIOS, ADGF_UNSTABLE, LATEST_VERSION),
// Shaban
- {
- "shaban",
- "",
- AD_ENTRY1s("data.dcp", "35f702ca9baabc5c620e0be230195c8a", 755388466),
- Common::EN_ANY,
- Common::kPlatformWindows,
- ADGF_UNSTABLE,
- GUIO0()
- },
+ WME_WINENTRY("shaban", "",
+ WME_ENTRY1s("data.dcp", "35f702ca9baabc5c620e0be230195c8a", 755388466), Common::EN_ANY, ADGF_UNSTABLE, LATEST_VERSION),
// The Shine of a Star
- {
- "shinestar",
- "",
- AD_ENTRY1s("data.dcp", "f05abe9e2427a5e4f73648fa09c4ba8e", 94113060),
- Common::EN_ANY,
- Common::kPlatformWindows,
- ADGF_UNSTABLE,
- GUIO0()
- },
+ WME_WINENTRY("shinestar", "",
+ WME_ENTRY1s("data.dcp", "f05abe9e2427a5e4f73648fa09c4ba8e", 94113060), Common::EN_ANY, ADGF_UNSTABLE, LATEST_VERSION),
// Sofia's Debt
- {
- "sofiasdebt",
- "",
- AD_ENTRY1s("SD.exe", "e9515f9ba1a2925bb6733476a826a650", 9915047),
- Common::EN_ANY,
- Common::kPlatformWindows,
- ADGF_UNSTABLE,
- GUIO0()
- },
+ WME_WINENTRY("sofiasdebt", "",
+ WME_ENTRY1s("SD.exe", "e9515f9ba1a2925bb6733476a826a650", 9915047), Common::EN_ANY, ADGF_UNSTABLE, LATEST_VERSION),
// Space Invaders (Demo)
- {
- "spaceinvaders",
- "Demo",
- AD_ENTRY1s("data.dcp", "3f27adefdf72f2c1601cf555c80a509f", 1308361),
- Common::EN_ANY,
- Common::kPlatformWindows,
- ADGF_UNSTABLE |
- ADGF_DEMO,
- GUIO0()
- },
+ WME_WINENTRY("spaceinvaders", "Demo",
+ WME_ENTRY1s("data.dcp", "3f27adefdf72f2c1601cf555c80a509f", 1308361), Common::EN_ANY, ADGF_UNSTABLE | ADGF_DEMO, LATEST_VERSION),
// Space Madness
- {
- "spacemadness",
- "1.0.2",
- AD_ENTRY1s("data.dcp", "b9b83135dc7a9e1b4b5f50195dbeb630", 39546622),
- Common::EN_ANY,
- Common::kPlatformWindows,
- ADGF_UNSTABLE,
- GUIO0()
- },
+ WME_WINENTRY("spacemadness", "1.0.2",
+ WME_ENTRY1s("data.dcp", "b9b83135dc7a9e1b4b5f50195dbeb630", 39546622), Common::EN_ANY, ADGF_UNSTABLE, LATEST_VERSION),
// The Ancient Mark - Episode 1
- {
- "theancientmark1",
- "",
- AD_ENTRY1s("data.dcp", "ca04c26f03b2bd307368b306b297ddd7", 364664692),
- Common::EN_ANY,
- Common::kPlatformWindows,
- ADGF_UNSTABLE,
- GUIO0()
- },
+ WME_WINENTRY("theancientmark1", "",
+ WME_ENTRY1s("data.dcp", "ca04c26f03b2bd307368b306b297ddd7", 364664692), Common::EN_ANY, ADGF_UNSTABLE, LATEST_VERSION),
// The Box
- {
- "thebox",
- "",
- AD_ENTRY1s("data.dcp", "ec5f0c7e8174e307701447b53afe7e2f", 108372483),
- Common::EN_ANY,
- Common::kPlatformWindows,
- ADGF_UNSTABLE,
- GUIO0()
- },
+ WME_WINENTRY("thebox", "",
+ WME_ENTRY1s("data.dcp", "ec5f0c7e8174e307701447b53afe7e2f", 108372483), Common::EN_ANY, ADGF_UNSTABLE, LATEST_VERSION),
// The Kite (Version 1.1)
- {
- "thekite",
- "Version 1.1",
- AD_ENTRY1s("data.dcp", "92d29428f464469bda2d81b03d4d5c3e", 47332296),
- Common::EN_ANY,
- Common::kPlatformWindows,
- ADGF_UNSTABLE,
- GUIO0()
- },
+ WME_WINENTRY("thekite", "Version 1.1",
+ WME_ENTRY1s("data.dcp", "92d29428f464469bda2d81b03d4d5c3e", 47332296), Common::EN_ANY, ADGF_UNSTABLE, LATEST_VERSION),
// The Kite (Version 1.2.e)
- {
- "thekite",
- "Version 1.2.e",
- AD_ENTRY1s("data.dcp", "92451578b1bdd2b32a1db592a4f6d5fc", 47360539),
- Common::EN_ANY,
- Common::kPlatformWindows,
- ADGF_UNSTABLE,
- GUIO0()
- },
+ WME_WINENTRY("thekite", "Version 1.2.e",
+ WME_ENTRY1s("data.dcp", "92451578b1bdd2b32a1db592a4f6d5fc", 47360539), Common::EN_ANY, ADGF_UNSTABLE, LATEST_VERSION),
// The Kite (Version 1.2.i) (Italian)
- {
- "thekite",
- "Version 1.2.i",
- AD_ENTRY1s("data.dcp", "d3435b106a1b3b4c1df8ad596d271586", 47509274),
- Common::IT_ITA,
- Common::kPlatformWindows,
- ADGF_UNSTABLE,
- GUIO0()
- },
+ WME_WINENTRY("thekite", "Version 1.2.i",
+ WME_ENTRY1s("data.dcp", "d3435b106a1b3b4c1df8ad596d271586", 47509274), Common::IT_ITA, ADGF_UNSTABLE, LATEST_VERSION),
// The Kite (Version 1.2.r) (Russian)
- {
- "thekite",
- "Version 1.2.r",
- AD_ENTRY1s("data.dcp", "d531e097dd884737469da014ed882cde", 47554582 ),
- Common::RU_RUS,
- Common::kPlatformWindows,
- ADGF_UNSTABLE,
- GUIO0()
- },
+ WME_WINENTRY("thekite", "Version 1.2.r",
+ WME_ENTRY1s("data.dcp", "d531e097dd884737469da014ed882cde", 47554582 ), Common::RU_RUS, ADGF_UNSTABLE, LATEST_VERSION),
// The Kite (Version 1.3.e)
- {
- "thekite",
- "Version 1.3.e",
- AD_ENTRY1s("data.dcp", "9761827b51370263b7623721545d7627", 47382987),
- Common::EN_ANY,
- Common::kPlatformWindows,
- ADGF_UNSTABLE,
- GUIO0()
- },
+ WME_WINENTRY("thekite", "Version 1.3.e",
+ WME_ENTRY1s("data.dcp", "9761827b51370263b7623721545d7627", 47382987), Common::EN_ANY, ADGF_UNSTABLE, LATEST_VERSION),
// Fairy Tales About Toshechka and Boshechka
- {
- "tib",
- "",
- AD_ENTRY1s("data.dcp", "87d296ef3f46570ed18f000d3885db77", 340264526),
- Common::RU_RUS,
- Common::kPlatformWindows,
- ADGF_UNSTABLE,
- GUIO0()
- },
+ WME_WINENTRY("tib", "",
+ WME_ENTRY1s("data.dcp", "87d296ef3f46570ed18f000d3885db77", 340264526), Common::RU_RUS, ADGF_UNSTABLE, LATEST_VERSION),
// The Trader of Stories
- {
- "tradestory",
- "Demo",
- AD_ENTRY1s("data.dcp", "0a0b51191636cc8ead89b905281c3218", 40401902),
- Common::EN_ANY,
- Common::kPlatformWindows,
- ADGF_UNSTABLE |
- ADGF_DEMO,
- GUIO0()
- },
+ WME_WINENTRY("tradestory", "Demo",
+ WME_ENTRY1s("data.dcp", "0a0b51191636cc8ead89b905281c3218", 40401902), Common::EN_ANY, ADGF_UNSTABLE | ADGF_DEMO, LATEST_VERSION),
// the white chamber (multi-language)
- {
- "twc",
- "",
- AD_ENTRY1s("data.dcp", "0011d01142547c61e51ba24dc42b579e", 186451273),
- Common::UNK_LANG,
- Common::kPlatformWindows,
- ADGF_UNSTABLE,
- GUIO0()
- },
+ WME_WINENTRY("twc", "",
+ WME_ENTRY1s("data.dcp", "0011d01142547c61e51ba24dc42b579e", 186451273), Common::UNK_LANG, ADGF_UNSTABLE, LATEST_VERSION),
// Vsevolod Prologue (Demo)
- {
- "vsevolod",
- "Prologue",
- AD_ENTRY1s("data.dcp", "f2dcffd2692dbfcc9371fa1a87970fe7", 388669493),
- Common::EN_ANY,
- Common::kPlatformWindows,
- ADGF_UNSTABLE |
- ADGF_DEMO,
- GUIO0()
- },
+ WME_WINENTRY("vsevolod", "Prologue",
+ WME_ENTRY1s("data.dcp", "f2dcffd2692dbfcc9371fa1a87970fe7", 388669493), Common::EN_ANY, ADGF_UNSTABLE | ADGF_DEMO, LATEST_VERSION),
// War
- {
- "war",
- "",
- AD_ENTRY1s("data.dcp", "003e317cda6d0137bbd5e5d7f089ee4d", 32591890),
- Common::EN_ANY,
- Common::kPlatformWindows,
- ADGF_UNSTABLE,
- GUIO0()
- },
+ WME_WINENTRY("war", "",
+ WME_ENTRY1s("data.dcp", "003e317cda6d0137bbd5e5d7f089ee4d", 32591890), Common::EN_ANY, ADGF_UNSTABLE, LATEST_VERSION),
// Wilma Tetris
- {
- "wtetris",
- "",
- AD_ENTRY1s("data.dcp", "946e3a0496e6c12fb344c9ed861ff015", 2780093),
- Common::EN_ANY,
- Common::kPlatformWindows,
- ADGF_UNSTABLE,
- GUIO0()
- },
+ WME_WINENTRY("wtetris", "",
+ WME_ENTRY1s("data.dcp", "946e3a0496e6c12fb344c9ed861ff015", 2780093), Common::EN_ANY, ADGF_UNSTABLE, LATEST_VERSION),
// Zilm: A Game of Reflex 1.0
+ WME_WINENTRY("Zilm", "1.0",
+ WME_ENTRY1s("data.dcp", "098dffaf03d8adbb4cb5633e4733e63c", 351726), Common::EN_ANY, ADGF_UNSTABLE, LATEST_VERSION),
{
- "Zilm",
- "1.0",
- AD_ENTRY1s("data.dcp", "098dffaf03d8adbb4cb5633e4733e63c", 351726),
- Common::EN_ANY,
- Common::kPlatformWindows,
- ADGF_UNSTABLE,
- GUIO0()
- },
- AD_TABLE_END_MARKER
+ AD_TABLE_END_MARKER,
+ LATEST_VERSION
+ }
};
} // End of namespace Wintermute
+#undef WEM_ENTRY1s
+#undef WEM_ENTRY2s
+#undef WEM_ENTRY3s
+#undef WME_WINENTRY
+#undef WME_PLATENTRY
+
diff --git a/engines/wintermute/game_description.h b/engines/wintermute/game_description.h
new file mode 100644
index 0000000000..313fff8bbf
--- /dev/null
+++ b/engines/wintermute/game_description.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 WINTERMUTE_GAME_DESCRIPTION_H
+#define WINTERMUTE_GAME_DESCRIPTION_H
+
+#include "engines/advancedDetector.h"
+
+namespace Wintermute {
+
+enum WMETargetExecutable {
+ OLDEST_VERSION,
+ WME_1_0_0,
+ WME_1_1_0,
+ WME_1_2_0,
+ WME_1_3_0,
+ WME_1_4_0,
+ WME_1_5_0,
+ WME_1_6_0,
+ WME_1_7_0,
+ WME_1_8_0,
+ WME_1_8_6,
+ WME_1_9_0,
+ LATEST_VERSION
+};
+
+struct WMEGameDescription {
+ ADGameDescription adDesc;
+ WMETargetExecutable targetExecutable;
+};
+
+}
+
+#endif /* WINTERMUTE_GAME_DESCRIPTION_H_ */
diff --git a/engines/wintermute/math/rect32.h b/engines/wintermute/math/rect32.h
index 93b5c68a30..00326d6747 100644
--- a/engines/wintermute/math/rect32.h
+++ b/engines/wintermute/math/rect32.h
@@ -50,7 +50,7 @@ struct Point32 {
y -= delta.y;
return *this;
}
-
+
operator FloatPoint() {
return FloatPoint(x,y);
}
diff --git a/engines/wintermute/module.mk b/engines/wintermute/module.mk
index 1b6c52e0b7..4c95314a02 100644
--- a/engines/wintermute/module.mk
+++ b/engines/wintermute/module.mk
@@ -108,7 +108,9 @@ MODULE_OBJS := \
utils/path_util.o \
utils/string_util.o \
utils/utils.o \
+ video/subtitle_card.o \
video/video_player.o \
+ video/video_subtitler.o \
video/video_theora_player.o \
debugger.o \
wintermute.o \
diff --git a/engines/wintermute/video/subtitle_card.cpp b/engines/wintermute/video/subtitle_card.cpp
new file mode 100644
index 0000000000..5d882502fd
--- /dev/null
+++ b/engines/wintermute/video/subtitle_card.cpp
@@ -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.
+ *
+ */
+
+/*
+ * This file is based on Wintermute Engine
+ * http://dead-code.org/redir.php?target=wme
+ * Copyright (c) 2011 Jan Nedoma
+ */
+
+#include "engines/wintermute/video/subtitle_card.h"
+#include "engines/wintermute/base/base_game.h"
+
+namespace Wintermute {
+
+SubtitleCard::SubtitleCard(BaseGame *inGame,
+ const Common::String &text,
+ const uint &startFrame,
+ const uint &endFrame) : _gameRef(inGame),
+ _startFrame(startFrame),
+ _endFrame(endFrame) {
+ _text = text;
+ _gameRef->expandStringByStringTable(_text);
+}
+
+uint32 SubtitleCard::getStartFrame() const {
+ return _startFrame;
+}
+
+uint32 SubtitleCard::getEndFrame() const {
+ return _endFrame;
+}
+
+Common::String SubtitleCard::getText() const {
+ return _text;
+}
+
+} // End of namespace Wintermute
diff --git a/engines/wintermute/video/subtitle_card.h b/engines/wintermute/video/subtitle_card.h
new file mode 100644
index 0000000000..629df77287
--- /dev/null
+++ b/engines/wintermute/video/subtitle_card.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.
+ *
+ */
+
+/*
+ * This file is based on Wintermute Engine
+ * http://dead-code.org/redir.php?target=wme
+ * Copyright (c) 2011 Jan Nedoma
+ */
+
+#ifndef WINTERMUTE_SUBTITLECARD_H
+#define WINTERMUTE_SUBTITLECARD_H
+
+#include "common/str.h"
+
+namespace Wintermute {
+
+class BaseGame;
+
+class SubtitleCard {
+public:
+ SubtitleCard(BaseGame *inGame, const Common::String &text, const uint &startFrame, const uint &endFrame);
+ uint32 getEndFrame() const;
+ uint32 getStartFrame() const;
+ Common::String getText() const;
+private:
+ BaseGame *_gameRef;
+ uint32 _endFrame;
+ uint32 _startFrame;
+ Common::String _text;
+};
+
+} // End of namespace Wintermute
+
+#endif
diff --git a/engines/wintermute/video/video_subtitler.cpp b/engines/wintermute/video/video_subtitler.cpp
new file mode 100644
index 0000000000..95d938574b
--- /dev/null
+++ b/engines/wintermute/video/video_subtitler.cpp
@@ -0,0 +1,266 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+/*
+ * This file is based on Wintermute Engine
+ * http://dead-code.org/redir.php?target=wme
+ * Copyright (c) 2011 Jan Nedoma
+ */
+
+#include "engines/wintermute/video/video_subtitler.h"
+#include "engines/wintermute/base/base_file_manager.h"
+#include "engines/wintermute/utils/path_util.h"
+#include "engines/wintermute/base/font/base_font.h"
+#include "engines/wintermute/base/base_game.h"
+#include "engines/wintermute/base/gfx/base_renderer.h"
+
+namespace Wintermute {
+
+VideoSubtitler::VideoSubtitler(BaseGame *inGame): BaseClass(inGame) {
+ _lastSample = -1;
+ _currentSubtitle = 0;
+ _showSubtitle = false;
+}
+
+VideoSubtitler::~VideoSubtitler(void) {
+ _subtitles.clear();
+}
+
+bool VideoSubtitler::loadSubtitles(const Common::String &filename, const Common::String &subtitleFile) {
+ if (filename.size() == 0) {
+ return false;
+ }
+
+ _subtitles.clear();
+
+ _lastSample = -1;
+ _currentSubtitle = 0;
+ _showSubtitle = false;
+
+ Common::String newFile;
+
+ /*
+ * Okay, the expected behaviour is this: either we are
+ * provided with a subtitle file to use by the script when
+ * calling PlayTheora(), or we try to autodetect a suitable
+ * one which, for /some/path/movie/ogg is to be called
+ * /some/path/movie.sub
+ */
+ if (subtitleFile.size() != 0) {
+ newFile = subtitleFile;
+ } else {
+ Common::String path = PathUtil::getDirectoryName(filename);
+ Common::String name = PathUtil::getFileNameWithoutExtension(filename);
+ Common::String ext = ".SUB";
+ newFile = PathUtil::combine(path, name + ext);
+ }
+
+ Common::SeekableReadStream *file = BaseFileManager::getEngineInstance()->openFile(newFile, true, false);
+
+ if (file == nullptr) {
+ return false; // no subtitles
+ }
+
+ int fileSize = file->size();
+ char *buffer = new char[fileSize];
+
+ file->read(buffer, fileSize);
+
+ /* This is where we parse .sub files.
+ * Subtitles cards are in the form
+ * {StartFrame}{EndFrame} FirstLine | SecondLine \n
+ */
+ int pos = 0;
+
+ while (pos < fileSize) {
+ char *tokenStart = 0;
+ int tokenLength = 0;
+ int tokenPos = -1;
+ int lineLength = 0;
+ int start = -1;
+ int end = -1;
+ bool inToken = false;
+
+ while (pos + lineLength < fileSize &&
+ buffer[pos + lineLength] != '\n' &&
+ buffer[pos + lineLength] != '\0') {
+ // Measure the line until we hit EOL, EOS or just hit the boundary
+ lineLength++;
+ }
+
+ int realLength;
+
+ if (pos + lineLength >= fileSize) {
+ realLength = lineLength - 0;
+ } else {
+ // If we got here the above loop exited after hitting "\0" "\n"
+ realLength = lineLength - 1;
+ }
+
+ Common::String cardText;
+ char *fileLine = (char *)&buffer[pos];
+
+ for (int i = 0; i < realLength; i++) {
+ if (fileLine[i] == '{') {
+ if (!inToken) {
+ // We've hit the start of a Start/EndFrame token
+ inToken = true;
+ tokenStart = fileLine + i + 1;
+ tokenLength = 0;
+ tokenPos++;
+ } else {
+ // Actually, we were already inside an (invalid) one.
+ tokenLength++;
+ }
+ } else if (fileLine[i] == '}') {
+ if (inToken) {
+ // we were /inside/ a {.*} token, so this is the end of the block
+ inToken = false;
+ char *token = new char[tokenLength + 1];
+ strncpy(token, tokenStart, tokenLength);
+ token[tokenLength] = '\0';
+ if (tokenPos == 0) {
+ // Was this StartFrame...
+ start = atoi(token);
+ } else if (tokenPos == 1) {
+ // Or the EndFrame?
+ end = atoi(token);
+ }
+ delete[] token;
+ } else {
+ // This char is part of the plain text, just append it
+ cardText += fileLine[i];
+ }
+ } else {
+ if (inToken) {
+ tokenLength++;
+ } else {
+ if (fileLine[i] == '|') {
+ // The pipe character signals a linebreak in the text
+ cardText += '\n';
+ } else {
+ // This char is part of the plain text, just append it
+ cardText += fileLine[i];
+ }
+ }
+ }
+ }
+
+ if (start != -1 && cardText.size() > 0 && (start != 1 || end != 1)){
+ // Add a subtitlecard based on the line we have just parsed
+ _subtitles.push_back(SubtitleCard(_gameRef, cardText, start, end));
+ }
+
+ pos += lineLength + 1;
+ }
+
+ delete[] buffer;
+ // Succeeded loading subtitles!
+
+ return true;
+}
+
+void VideoSubtitler::display() {
+ if (_showSubtitle) {
+
+ BaseFont *font;
+
+ if (_gameRef->getVideoFont() == nullptr) {
+ font = _gameRef->getSystemFont();
+ } else {
+ font = _gameRef->getVideoFont();
+ }
+
+ int textHeight = font->getTextHeight(
+ (const byte *)_subtitles[_currentSubtitle].getText().c_str(),
+ _gameRef->_renderer->getWidth());
+
+ font->drawText(
+ (const byte *)_subtitles[_currentSubtitle].getText().c_str(),
+ 0,
+ (_gameRef->_renderer->getHeight() - textHeight - 5),
+ (_gameRef->_renderer->getWidth()),
+ TAL_CENTER);
+ }
+}
+
+void VideoSubtitler::update(uint32 frame) {
+ if (_subtitles.size() == 0) {
+ // Edge case: we have loaded subtitles early on... from a blank file.
+ return;
+ }
+
+ if ((int32)frame != _lastSample) {
+ /*
+ * If the frame count hasn't advanced the previous state still matches
+ * the current frame (obviously).
+ */
+
+ _lastSample = frame;
+ // Otherwise, we update _lastSample; see above.
+
+ _showSubtitle = false;
+
+ bool overdue = (frame > _subtitles[_currentSubtitle].getEndFrame());
+ bool hasNext = (_currentSubtitle + 1 < _subtitles.size());
+ bool nextStarted = false;
+ if (hasNext) {
+ nextStarted = (_subtitles[_currentSubtitle + 1].getStartFrame() <= frame);
+ }
+
+ while (_currentSubtitle < _subtitles.size() &&
+ overdue && hasNext && nextStarted) {
+ /*
+ * We advance until we get past all overdue subtitles.
+ * We should exit the cycle when we either reach the first
+ * subtitle which is not overdue whose subsequent subtitle
+ * has not started yet (aka the one we must display now or
+ * the one which WILL be displayed when its time comes)
+ * and / or when we reach the last one.
+ */
+
+ _currentSubtitle++;
+
+ overdue = (frame > _subtitles[_currentSubtitle].getEndFrame());
+ hasNext = (_currentSubtitle + 1 < _subtitles.size());
+ if (hasNext) {
+ nextStarted = (_subtitles[_currentSubtitle + 1].getStartFrame() <= frame);
+ } else {
+ nextStarted = false;
+ }
+ }
+
+ bool currentValid = (_subtitles[_currentSubtitle].getEndFrame() != 0);
+ /*
+ * No idea why we do this check, carried over from Mnemonic's code.
+ * Possibly a workaround for buggy subtitles or some kind of sentinel? :-\
+ */
+
+ bool currentStarted = frame >= _subtitles[_currentSubtitle].getStartFrame();
+
+ if (currentStarted && !overdue && currentValid) {
+ _showSubtitle = true;
+ }
+ }
+}
+
+} // End of namespace Wintermute
diff --git a/engines/wintermute/video/video_subtitler.h b/engines/wintermute/video/video_subtitler.h
new file mode 100644
index 0000000000..94f22909a1
--- /dev/null
+++ b/engines/wintermute/video/video_subtitler.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.
+ *
+ */
+
+/*
+ * This file is based on Wintermute Engine
+ * http://dead-code.org/redir.php?target=wme
+ * Copyright (c) 2011 Jan Nedoma
+ */
+
+#ifndef WINTERMUTE_VIDSUBTITLER_H
+#define WINTERMUTE_VIDSUBTITLER_H
+
+#include "engines/wintermute/base/base.h"
+#include "engines/wintermute/video/subtitle_card.h"
+
+namespace Wintermute {
+
+class VideoSubtitler : public BaseClass {
+public:
+ VideoSubtitler(BaseGame *inGame);
+ virtual ~VideoSubtitler(void);
+ bool loadSubtitles(const Common::String &filename, const Common::String &subtitleFile);
+ void display();
+ void update(uint32 frame);
+private:
+ Common::Array<SubtitleCard> _subtitles;
+ int32 _lastSample;
+ bool _showSubtitle;
+ uint32 _currentSubtitle;
+};
+
+} // End of namespace Wintermute
+
+#endif
diff --git a/engines/wintermute/video/video_theora_player.cpp b/engines/wintermute/video/video_theora_player.cpp
index e1553580ec..22c235c848 100644
--- a/engines/wintermute/video/video_theora_player.cpp
+++ b/engines/wintermute/video/video_theora_player.cpp
@@ -85,14 +85,14 @@ void VideoTheoraPlayer::SetDefaults() {
_volume = 100;
_theoraDecoder = nullptr;
- // TODO: Add subtitles-support
- //_subtitler = nullptr;
+ _subtitler = new VideoSubtitler(_gameRef);
+ _foundSubtitles = false;
}
//////////////////////////////////////////////////////////////////////////
VideoTheoraPlayer::~VideoTheoraPlayer(void) {
cleanup();
-// SAFE_DELETE(_subtitler);
+ delete _subtitler;
}
//////////////////////////////////////////////////////////////////////////
@@ -130,6 +130,9 @@ bool VideoTheoraPlayer::initialize(const Common::String &filename, const Common:
warning("VideoTheoraPlayer::initialize - Theora support not compiled in, video will be skipped: %s", filename.c_str());
return STATUS_FAILED;
#endif
+
+ _foundSubtitles = _subtitler->loadSubtitles(_filename, subtitleFile);
+
_theoraDecoder->loadStream(_file);
if (!_theoraDecoder->isVideoLoaded()) {
@@ -214,7 +217,10 @@ bool VideoTheoraPlayer::play(TVideoPlayback type, int x, int y, bool freezeGame,
_state = THEORA_STATE_PLAYING;
_looping = looping;
_playbackType = type;
-
+ if (_subtitler && _foundSubtitles && _gameRef->_subtitles) {
+ _subtitler->update(_theoraDecoder->getFrameCount());
+ _subtitler->display();
+ }
_startTime = startTime;
_volume = volume;
_posX = x;
@@ -256,7 +262,7 @@ bool VideoTheoraPlayer::play(TVideoPlayback type, int x, int y, bool freezeGame,
#if 0 // Stubbed for now as theora isn't seekable
if (StartTime) SeekToTime(StartTime);
- Update();
+ update();
#endif
return STATUS_FAILED;
}
@@ -289,6 +295,10 @@ bool VideoTheoraPlayer::update() {
}
if (_theoraDecoder) {
+ if (_subtitler && _foundSubtitles && _gameRef->_subtitles) {
+ _subtitler->update(_theoraDecoder->getCurFrame());
+ }
+
if (_theoraDecoder->endOfVideo() && _looping) {
warning("Should loop movie %s, hacked for now", _filename.c_str());
_theoraDecoder->rewind();
@@ -412,11 +422,10 @@ bool VideoTheoraPlayer::display(uint32 alpha) {
} else {
res = STATUS_FAILED;
}
- // TODO: Add subtitles-support
-/* if (m_Subtitler && _gameRef->m_VideoSubtitles) {
- m_Subtitler->display();
- }*/
+ if (_subtitler && _foundSubtitles && _gameRef->_subtitles) {
+ _subtitler->display();
+ }
return res;
}
diff --git a/engines/wintermute/video/video_theora_player.h b/engines/wintermute/video/video_theora_player.h
index 8274a1444f..0b9b3d487a 100644
--- a/engines/wintermute/video/video_theora_player.h
+++ b/engines/wintermute/video/video_theora_player.h
@@ -31,6 +31,7 @@
#include "engines/wintermute/base/base.h"
#include "engines/wintermute/persistent.h"
+#include "engines/wintermute/video/video_subtitler.h"
#include "video/video_decoder.h"
#include "common/stream.h"
#include "graphics/surface.h"
@@ -59,7 +60,7 @@ public:
Common::String _filename;
BaseSurface *_texture;
- //CVidSubtitler *_subtitler;
+ VideoSubtitler *_subtitler;
// control methods
bool initialize(const Common::String &filename, const Common::String &subtitleFile = Common::String());
@@ -137,9 +138,10 @@ private:
bool _playbackStarted;
+ bool _foundSubtitles;
+
// helpers
void SetDefaults();
-
};
} // End of namespace Wintermute
diff --git a/engines/wintermute/wintermute.cpp b/engines/wintermute/wintermute.cpp
index 81b6e53c9f..e35bb60c3d 100644
--- a/engines/wintermute/wintermute.cpp
+++ b/engines/wintermute/wintermute.cpp
@@ -53,7 +53,7 @@ WintermuteEngine::WintermuteEngine() : Engine(g_system) {
_gameDescription = nullptr;
}
-WintermuteEngine::WintermuteEngine(OSystem *syst, const ADGameDescription *desc)
+WintermuteEngine::WintermuteEngine(OSystem *syst, const WMEGameDescription *desc)
: Engine(syst), _gameDescription(desc) {
// Put your engine in a sane state, but do nothing big yet;
// in particular, do not load data from files; rather, if you
@@ -133,7 +133,7 @@ Common::Error WintermuteEngine::run() {
}
int WintermuteEngine::init() {
- BaseEngine::createInstance(_targetName, _gameDescription->gameid, _gameDescription->language);
+ BaseEngine::createInstance(_targetName, _gameDescription->adDesc.gameid, _gameDescription->adDesc.language, _gameDescription->targetExecutable);
_game = new AdGame(_targetName);
if (!_game) {
return 1;
diff --git a/engines/wintermute/wintermute.h b/engines/wintermute/wintermute.h
index 017809d56a..f8f5fc7deb 100644
--- a/engines/wintermute/wintermute.h
+++ b/engines/wintermute/wintermute.h
@@ -26,6 +26,7 @@
#include "engines/engine.h"
#include "engines/advancedDetector.h"
#include "gui/debugger.h"
+#include "engines/wintermute/game_description.h"
namespace Wintermute {
@@ -44,7 +45,7 @@ enum {
class WintermuteEngine : public Engine {
public:
- WintermuteEngine(OSystem *syst, const ADGameDescription *desc);
+ WintermuteEngine(OSystem *syst, const WMEGameDescription *desc);
WintermuteEngine();
~WintermuteEngine();
@@ -67,7 +68,7 @@ private:
int messageLoop();
GUI::Debugger *_debugger;
BaseGame *_game;
- const ADGameDescription *_gameDescription;
+ const WMEGameDescription *_gameDescription;
friend class Console;
};
diff --git a/engines/zvision/POTFILES b/engines/zvision/POTFILES
new file mode 100644
index 0000000000..48e2782648
--- /dev/null
+++ b/engines/zvision/POTFILES
@@ -0,0 +1 @@
+engines/zvision/detection.cpp
diff --git a/engines/zvision/animation/rlf_animation.cpp b/engines/zvision/animation/rlf_animation.cpp
deleted file mode 100644
index 945461e7b2..0000000000
--- a/engines/zvision/animation/rlf_animation.cpp
+++ /dev/null
@@ -1,331 +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 "common/scummsys.h"
-
-#include "zvision/animation/rlf_animation.h"
-
-#include "common/str.h"
-#include "common/file.h"
-#include "common/textconsole.h"
-#include "common/debug.h"
-#include "common/endian.h"
-
-#include "graphics/colormasks.h"
-
-
-namespace ZVision {
-
-RlfAnimation::RlfAnimation(const Common::String &fileName, bool stream)
- : _stream(stream),
- _lastFrameRead(0),
- _frameCount(0),
- _width(0),
- _height(0),
- _frameTime(0),
- _frames(0),
- _currentFrame(-1),
- _frameBufferByteSize(0) {
- if (!_file.open(fileName)) {
- warning("RLF animation file %s could not be opened", fileName.c_str());
- return;
- }
-
- if (!readHeader()) {
- warning("%s is not a RLF animation file. Wrong magic number", fileName.c_str());
- return;
- }
-
- _currentFrameBuffer.create(_width, _height, Graphics::createPixelFormat<565>());
- _frameBufferByteSize = _width * _height * sizeof(uint16);
-
- if (!stream) {
- _frames = new Frame[_frameCount];
-
- // Read in each frame
- for (uint i = 0; i < _frameCount; ++i) {
- _frames[i] = readNextFrame();
- }
- }
-}
-
-RlfAnimation::~RlfAnimation() {
- for (uint i = 0; i < _frameCount; ++i) {
- delete[] _frames[i].encodedData;
- }
- delete[] _frames;
- _currentFrameBuffer.free();
-}
-
-bool RlfAnimation::readHeader() {
- if (_file.readUint32BE() != MKTAG('F', 'E', 'L', 'R')) {
- return false;
- }
-
- // Read the header
- _file.readUint32LE(); // Size1
- _file.readUint32LE(); // Unknown1
- _file.readUint32LE(); // Unknown2
- _frameCount = _file.readUint32LE(); // Frame count
-
- // Since we don't need any of the data, we can just seek right to the
- // entries we need rather than read in all the individual entries.
- _file.seek(136, SEEK_CUR);
-
- //// Read CIN header
- //_file.readUint32BE(); // Magic number FNIC
- //_file.readUint32LE(); // Size2
- //_file.readUint32LE(); // Unknown3
- //_file.readUint32LE(); // Unknown4
- //_file.readUint32LE(); // Unknown5
- //_file.seek(0x18, SEEK_CUR); // VRLE
- //_file.readUint32LE(); // LRVD
- //_file.readUint32LE(); // Unknown6
- //_file.seek(0x18, SEEK_CUR); // HRLE
- //_file.readUint32LE(); // ELHD
- //_file.readUint32LE(); // Unknown7
- //_file.seek(0x18, SEEK_CUR); // HKEY
- //_file.readUint32LE(); // ELRH
-
- //// Read MIN info header
- //_file.readUint32BE(); // Magic number FNIM
- //_file.readUint32LE(); // Size3
- //_file.readUint32LE(); // OEDV
- //_file.readUint32LE(); // Unknown8
- //_file.readUint32LE(); // Unknown9
- //_file.readUint32LE(); // Unknown10
- _width = _file.readUint32LE(); // Width
- _height = _file.readUint32LE(); // Height
-
- // Read time header
- _file.readUint32BE(); // Magic number EMIT
- _file.readUint32LE(); // Size4
- _file.readUint32LE(); // Unknown11
- _frameTime = _file.readUint32LE() / 10; // Frame time in microseconds
-
- return true;
-}
-
-RlfAnimation::Frame RlfAnimation::readNextFrame() {
- RlfAnimation::Frame frame;
-
- _file.readUint32BE(); // Magic number MARF
- uint32 size = _file.readUint32LE(); // Size
- _file.readUint32LE(); // Unknown1
- _file.readUint32LE(); // Unknown2
- uint32 type = _file.readUint32BE(); // Either ELHD or ELRH
- uint32 headerSize = _file.readUint32LE(); // Offset from the beginning of this frame to the frame data. Should always be 28
- _file.readUint32LE(); // Unknown3
-
- frame.encodedSize = size - headerSize;
- frame.encodedData = new int8[frame.encodedSize];
- _file.read(frame.encodedData, frame.encodedSize);
-
- if (type == MKTAG('E', 'L', 'H', 'D')) {
- frame.type = Masked;
- } else if (type == MKTAG('E', 'L', 'R', 'H')) {
- frame.type = Simple;
- _completeFrames.push_back(_lastFrameRead);
- } else {
- warning("Frame %u doesn't have type that can be decoded", _lastFrameRead);
- }
-
- _lastFrameRead++;
- return frame;
-}
-
-void RlfAnimation::seekToFrame(int frameNumber) {
- assert(!_stream);
- assert(frameNumber < (int)_frameCount || frameNumber >= -1);
-
- if (frameNumber == -1) {
- _currentFrame = -1;
- return;
- }
-
- int closestFrame = _currentFrame;
- int distance = (int)frameNumber - _currentFrame;
- for (uint i = 0; i < _completeFrames.size(); ++i) {
- int newDistance = (int)frameNumber - (int)(_completeFrames[i]);
- if (newDistance > 0 && (closestFrame == -1 || newDistance < distance)) {
- closestFrame = _completeFrames[i];
- distance = newDistance;
- }
- }
-
- for (int i = closestFrame; i <= frameNumber; ++i) {
- applyFrameToCurrent(i);
- }
-
- _currentFrame = frameNumber;
-}
-
-const Graphics::Surface *RlfAnimation::getFrameData(uint frameNumber) {
- assert(!_stream);
- assert(frameNumber < _frameCount);
-
- // Since this method is so expensive, first check to see if we can use
- // getNextFrame() it's cheap.
- if ((int)frameNumber == _currentFrame) {
- return &_currentFrameBuffer;
- } else if (_currentFrame + 1 == (int)frameNumber) {
- return getNextFrame();
- }
-
- seekToFrame(frameNumber);
- return &_currentFrameBuffer;
-}
-
-const Graphics::Surface *RlfAnimation::getNextFrame() {
- assert(_currentFrame + 1 < (int)_frameCount);
-
- if (_stream) {
- applyFrameToCurrent(readNextFrame());
- } else {
- applyFrameToCurrent(_currentFrame + 1);
- }
-
- _currentFrame++;
- return &_currentFrameBuffer;
-}
-
-void RlfAnimation::applyFrameToCurrent(uint frameNumber) {
- if (_frames[frameNumber].type == Masked) {
- decodeMaskedRunLengthEncoding(_frames[frameNumber].encodedData, (int8 *)_currentFrameBuffer.getPixels(), _frames[frameNumber].encodedSize, _frameBufferByteSize);
- } else if (_frames[frameNumber].type == Simple) {
- decodeSimpleRunLengthEncoding(_frames[frameNumber].encodedData, (int8 *)_currentFrameBuffer.getPixels(), _frames[frameNumber].encodedSize, _frameBufferByteSize);
- }
-}
-
-void RlfAnimation::applyFrameToCurrent(const RlfAnimation::Frame &frame) {
- if (frame.type == Masked) {
- decodeMaskedRunLengthEncoding(frame.encodedData, (int8 *)_currentFrameBuffer.getPixels(), frame.encodedSize, _frameBufferByteSize);
- } else if (frame.type == Simple) {
- decodeSimpleRunLengthEncoding(frame.encodedData, (int8 *)_currentFrameBuffer.getPixels(), frame.encodedSize, _frameBufferByteSize);
- }
-}
-
-void RlfAnimation::decodeMaskedRunLengthEncoding(int8 *source, int8 *dest, uint32 sourceSize, uint32 destSize) const {
- uint32 sourceOffset = 0;
- uint32 destOffset = 0;
-
- while (sourceOffset < sourceSize) {
- int8 numberOfSamples = source[sourceOffset];
- sourceOffset++;
-
- // If numberOfSamples is negative, the next abs(numberOfSamples) samples should
- // be copied directly from source to dest
- if (numberOfSamples < 0) {
- numberOfSamples = ABS(numberOfSamples);
-
- while (numberOfSamples > 0) {
- if (sourceOffset + 1 >= sourceSize) {
- return;
- } else if (destOffset + 1 >= destSize) {
- debug(2, "Frame decoding overflow\n\tsourceOffset=%u\tsourceSize=%u\n\tdestOffset=%u\tdestSize=%u", sourceOffset, sourceSize, destOffset, destSize);
- return;
- }
-
- byte r, g, b;
- Graphics::colorToRGB<Graphics::ColorMasks<555> >(READ_LE_UINT16(source + sourceOffset), r, g, b);
- uint16 destColor = Graphics::RGBToColor<Graphics::ColorMasks<565> >(r, g, b);
- WRITE_UINT16(dest + destOffset, destColor);
-
- sourceOffset += 2;
- destOffset += 2;
- numberOfSamples--;
- }
-
- // If numberOfSamples is >= 0, move destOffset forward ((numberOfSamples * 2) + 2)
- // This function assumes the dest buffer has been memset with 0's.
- } else {
- if (sourceOffset + 1 >= sourceSize) {
- return;
- } else if (destOffset + 1 >= destSize) {
- debug(2, "Frame decoding overflow\n\tsourceOffset=%u\tsourceSize=%u\n\tdestOffset=%u\tdestSize=%u", sourceOffset, sourceSize, destOffset, destSize);
- return;
- }
-
- destOffset += (numberOfSamples * 2) + 2;
- }
- }
-}
-
-void RlfAnimation::decodeSimpleRunLengthEncoding(int8 *source, int8 *dest, uint32 sourceSize, uint32 destSize) const {
- uint32 sourceOffset = 0;
- uint32 destOffset = 0;
-
- while (sourceOffset < sourceSize) {
- int8 numberOfSamples = source[sourceOffset];
- sourceOffset++;
-
- // If numberOfSamples is negative, the next abs(numberOfSamples) samples should
- // be copied directly from source to dest
- if (numberOfSamples < 0) {
- numberOfSamples = ABS(numberOfSamples);
-
- while (numberOfSamples > 0) {
- if (sourceOffset + 1 >= sourceSize) {
- return;
- } else if (destOffset + 1 >= destSize) {
- debug(2, "Frame decoding overflow\n\tsourceOffset=%u\tsourceSize=%u\n\tdestOffset=%u\tdestSize=%u", sourceOffset, sourceSize, destOffset, destSize);
- return;
- }
-
- byte r, g, b;
- Graphics::colorToRGB<Graphics::ColorMasks<555> >(READ_LE_UINT16(source + sourceOffset), r, g, b);
- uint16 destColor = Graphics::RGBToColor<Graphics::ColorMasks<565> >(r, g, b);
- WRITE_UINT16(dest + destOffset, destColor);
-
- sourceOffset += 2;
- destOffset += 2;
- numberOfSamples--;
- }
-
- // If numberOfSamples is >= 0, copy one sample from source to the
- // next (numberOfSamples + 2) dest spots
- } else {
- if (sourceOffset + 1 >= sourceSize) {
- return;
- }
-
- byte r, g, b;
- Graphics::colorToRGB<Graphics::ColorMasks<555> >(READ_LE_UINT16(source + sourceOffset), r, g, b);
- uint16 sampleColor = Graphics::RGBToColor<Graphics::ColorMasks<565> >(r, g, b);
- sourceOffset += 2;
-
- numberOfSamples += 2;
- while (numberOfSamples > 0) {
- if (destOffset + 1 >= destSize) {
- debug(2, "Frame decoding overflow\n\tsourceOffset=%u\tsourceSize=%u\n\tdestOffset=%u\tdestSize=%u", sourceOffset, sourceSize, destOffset, destSize);
- return;
- }
-
- WRITE_UINT16(dest + destOffset, sampleColor);
- destOffset += 2;
- numberOfSamples--;
- }
- }
- }
-}
-
-} // End of namespace ZVision
diff --git a/engines/zvision/animation/rlf_animation.h b/engines/zvision/animation/rlf_animation.h
deleted file mode 100644
index 4bb779301b..0000000000
--- a/engines/zvision/animation/rlf_animation.h
+++ /dev/null
@@ -1,163 +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 ZVISION_RLF_ANIMATION_H
-#define ZVISION_RLF_ANIMATION_H
-
-#include "common/file.h"
-
-#include "graphics/surface.h"
-
-
-namespace Common {
-class String;
-}
-
-namespace ZVision {
-
-class RlfAnimation {
-public:
- RlfAnimation(const Common::String &fileName, bool stream = true);
- ~RlfAnimation();
-
-private:
- enum EncodingType {
- Masked,
- Simple
- };
-
- struct Frame {
- EncodingType type;
- int8 *encodedData;
- uint32 encodedSize;
- };
-
-private:
- Common::File _file;
- bool _stream;
- uint _lastFrameRead;
-
- uint _frameCount;
- uint _width;
- uint _height;
- uint32 _frameTime; // In milliseconds
- Frame *_frames;
- Common::Array<uint> _completeFrames;
-
- int _currentFrame;
- Graphics::Surface _currentFrameBuffer;
- uint32 _frameBufferByteSize;
-
-public:
- uint frameCount() { return _frameCount; }
- uint width() { return _width; }
- uint height() { return _height; }
- uint32 frameTime() { return _frameTime; }
-
- /**
- * Seeks to the frameNumber and updates the internal Surface with
- * the new frame data. If frameNumber == -1, it only sets _currentFrame,
- * the internal Surface is unchanged. This function requires _stream = false
- *
- * @param frameNumber The frame number to seek to
- */
- void seekToFrame(int frameNumber);
-
- /**
- * Returns the pixel data of the frame specified. It will try to use
- * getNextFrame() if possible. If not, it uses seekToFrame() to
- * update the internal Surface and then returns a pointer to it.
- * This function requires _stream = false
- *
- * @param frameNumber The frame number to get data for
- * @return A pointer to the pixel data. Do NOT delete this.
- */
- const Graphics::Surface *getFrameData(uint frameNumber);
- /**
- * Returns the pixel data of the next frame. It is up to the user to
- * check if the next frame is valid before calling this.
- * IE. Use endOfAnimation()
- *
- * @return A pointer to the pixel data. Do NOT delete this.
- */
- const Graphics::Surface *getNextFrame();
-
- /**
- * @return Is the currentFrame is the last frame in the animation?
- */
- bool endOfAnimation() { return _currentFrame == (int)_frameCount - 1; }
-
-private:
- /**
- * Reads in the header of the RLF file
- *
- * @return Will return false if the header magic number is wrong
- */
- bool readHeader();
- /**
- * Reads the next frame from the RLF file, stores the data in
- * a Frame object, then returns the object
- *
- * @return A Frame object representing the frame data
- */
- Frame readNextFrame();
-
- /**
- * Applies the frame corresponding to frameNumber on top of _currentFrameBuffer.
- * This function requires _stream = false so it can look up the Frame object
- * referenced by frameNumber.
- *
- * @param frameNumber The frame number to apply to _currentFrameBuffer
- */
- void applyFrameToCurrent(uint frameNumber);
- /**
- * Applies the data from a Frame object on top of a _currentFrameBuffer.
- *
- * @param frame A Frame object to apply to _currentFrameBuffer
- */
- void applyFrameToCurrent(const RlfAnimation::Frame &frame);
-
- /**
- * Decode frame data that uses masked run length encoding. This is the encoding
- * used by P-frames.
- *
- * @param source The source pixel data
- * @param dest The destination buffer
- * @param sourceSize The size of the source pixel data
- * @param destSize The size of the destination buffer
- */
- void decodeMaskedRunLengthEncoding(int8 *source, int8 *dest, uint32 sourceSize, uint32 destSize) const;
- /**
- * Decode frame data that uses simple run length encoding. This is the encoding
- * used by I-frames.
- *
- * @param source The source pixel data
- * @param dest The destination buffer
- * @param sourceSize The size of the source pixel data
- * @param destSize The size of the destination buffer
- */
- void decodeSimpleRunLengthEncoding(int8 *source, int8 *dest, uint32 sourceSize, uint32 destSize) const;
-};
-
-} // End of namespace ZVision
-
-#endif
diff --git a/engines/zvision/utility/clock.cpp b/engines/zvision/core/clock.cpp
index 45ab23ab65..1425d550b7 100644
--- a/engines/zvision/utility/clock.cpp
+++ b/engines/zvision/core/clock.cpp
@@ -22,11 +22,10 @@
#include "common/scummsys.h"
-#include "zvision/utility/clock.h"
+#include "zvision/core/clock.h"
#include "common/system.h"
-
namespace ZVision {
Clock::Clock(OSystem *system)
diff --git a/engines/zvision/utility/clock.h b/engines/zvision/core/clock.h
index 6ae0f86161..cbf52be560 100644
--- a/engines/zvision/utility/clock.h
+++ b/engines/zvision/core/clock.h
@@ -47,24 +47,31 @@ public:
* when the last update() was called.
*/
void update();
+
/**
* Get the delta time since the last frame. (The time between update() calls)
*
* @return Delta time since the last frame (in milliseconds)
*/
- uint32 getDeltaTime() const { return _deltaTime; }
+ uint32 getDeltaTime() const {
+ return _deltaTime;
+ }
+
/**
* Get the time from the program starting to the last update() call
*
* @return Time from program start to last update() call (in milliseconds)
*/
- uint32 getLastMeasuredTime() { return _lastTime; }
+ uint32 getLastMeasuredTime() {
+ return _lastTime;
+ }
/**
* Pause the clock. Any future delta times will take this pause into account.
* Has no effect if the clock is already paused.
*/
void start();
+
/**
* Un-pause the clock.
* Has no effect if the clock is already un-paused.
diff --git a/engines/zvision/core/console.cpp b/engines/zvision/core/console.cpp
index e610f34474..b5e542d777 100644
--- a/engines/zvision/core/console.cpp
+++ b/engines/zvision/core/console.cpp
@@ -1,24 +1,24 @@
/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
+*
+* ScummVM is the legal property of its developers, whose names
+* are too numerous to list here. Please refer to the COPYRIGHT
+* file distributed with this source distribution.
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License
+* as published by the Free Software Foundation; either version 2
+* of the License, or (at your option) any later version.
+
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+
+* You should have received a copy of the GNU General Public 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"
@@ -27,11 +27,10 @@
#include "zvision/zvision.h"
#include "zvision/scripting/script_manager.h"
#include "zvision/graphics/render_manager.h"
-#include "zvision/strings/string_manager.h"
+#include "zvision/text/string_manager.h"
#include "zvision/video/zork_avi_decoder.h"
#include "zvision/sound/zork_raw.h"
-#include "zvision/utility/utility.h"
-#include "zvision/cursors/cursor.h"
+#include "zvision/graphics/cursors/cursor.h"
#include "common/system.h"
#include "common/file.h"
@@ -41,11 +40,9 @@
#include "audio/mixer.h"
-
namespace ZVision {
Console::Console(ZVision *engine) : GUI::Debugger(), _engine(engine) {
- registerCmd("loadimage", WRAP_METHOD(Console, cmdLoadImage));
registerCmd("loadvideo", WRAP_METHOD(Console, cmdLoadVideo));
registerCmd("loadsound", WRAP_METHOD(Console, cmdLoadSound));
registerCmd("raw2wav", WRAP_METHOD(Console, cmdRawToWav));
@@ -53,26 +50,14 @@ Console::Console(ZVision *engine) : GUI::Debugger(), _engine(engine) {
registerCmd("generaterendertable", WRAP_METHOD(Console, cmdGenerateRenderTable));
registerCmd("setpanoramafov", WRAP_METHOD(Console, cmdSetPanoramaFoV));
registerCmd("setpanoramascale", WRAP_METHOD(Console, cmdSetPanoramaScale));
- registerCmd("changelocation", WRAP_METHOD(Console, cmdChangeLocation));
+ registerCmd("location", WRAP_METHOD(Console, cmdLocation));
registerCmd("dumpfile", WRAP_METHOD(Console, cmdDumpFile));
- registerCmd("parseallscrfiles", WRAP_METHOD(Console, cmdParseAllScrFiles));
- registerCmd("rendertext", WRAP_METHOD(Console, cmdRenderText));
-}
-
-bool Console::cmdLoadImage(int argc, const char **argv) {
- if (argc == 4)
- _engine->getRenderManager()->renderImageToScreen(argv[1], atoi(argv[2]), atoi(argv[3]));
- else {
- debugPrintf("Use loadimage <fileName> <destinationX> <destinationY> to load an image to the screen\n");
- return true;
- }
-
- return true;
+ registerCmd("dumpfiles", WRAP_METHOD(Console, cmdDumpFiles));
}
bool Console::cmdLoadVideo(int argc, const char **argv) {
if (argc != 2) {
- debugPrintf("Use loadvideo <fileName> to load a video to the screen\n");
+ debugPrintf("Use %s <fileName> to load a video to the screen\n", argv[0]);
return true;
}
@@ -94,18 +79,20 @@ bool Console::cmdLoadSound(int argc, const char **argv) {
Audio::AudioStream *soundStream = makeRawZorkStream(argv[1], _engine);
Audio::SoundHandle handle;
_engine->_mixer->playStream(Audio::Mixer::kPlainSoundType, &handle, soundStream, -1, 100, 0, DisposeAfterUse::YES, false, false);
-
} else if (argc == 4) {
int isStereo = atoi(argv[3]);
Common::File *file = new Common::File();
- file->open(argv[1]);
+ if (!_engine->getSearchManager()->openFile(*file, argv[1])) {
+ warning("File not found: %s", argv[1]);
+ return true;
+ }
Audio::AudioStream *soundStream = makeRawZorkStream(file, atoi(argv[2]), isStereo == 0 ? false : true);
Audio::SoundHandle handle;
_engine->_mixer->playStream(Audio::Mixer::kPlainSoundType, &handle, soundStream, -1, 100, 0, DisposeAfterUse::YES, false, false);
} else {
- debugPrintf("Use loadsound <fileName> [<rate> <isStereo: 1 or 0>] to load a sound\n");
+ debugPrintf("Use %s <fileName> [<rate> <isStereo: 1 or 0>] to load a sound\n", argv[0]);
return true;
}
@@ -114,17 +101,58 @@ bool Console::cmdLoadSound(int argc, const char **argv) {
bool Console::cmdRawToWav(int argc, const char **argv) {
if (argc != 3) {
- debugPrintf("Use raw2wav <rawFilePath> <wavFileName> to dump a .RAW file to .WAV\n");
+ debugPrintf("Use %s <rawFilePath> <wavFileName> to dump a .RAW file to .WAV\n", argv[0]);
return true;
}
- convertRawToWav(argv[1], _engine, argv[2]);
+ Common::File file;
+ if (!_engine->getSearchManager()->openFile(file, argv[1])) {
+ warning("File not found: %s", argv[1]);
+ return true;
+ }
+
+ Audio::AudioStream *audioStream = makeRawZorkStream(argv[1], _engine);
+
+ Common::DumpFile output;
+ output.open(argv[2]);
+
+ output.writeUint32BE(MKTAG('R', 'I', 'F', 'F'));
+ output.writeUint32LE(file.size() * 2 + 36);
+ output.writeUint32BE(MKTAG('W', 'A', 'V', 'E'));
+ output.writeUint32BE(MKTAG('f', 'm', 't', ' '));
+ output.writeUint32LE(16);
+ output.writeUint16LE(1);
+ uint16 numChannels;
+ if (audioStream->isStereo()) {
+ numChannels = 2;
+ output.writeUint16LE(2);
+ } else {
+ numChannels = 1;
+ output.writeUint16LE(1);
+ }
+ output.writeUint32LE(audioStream->getRate());
+ output.writeUint32LE(audioStream->getRate() * numChannels * 2);
+ output.writeUint16LE(numChannels * 2);
+ output.writeUint16LE(16);
+ output.writeUint32BE(MKTAG('d', 'a', 't', 'a'));
+ output.writeUint32LE(file.size() * 2);
+ int16 *buffer = new int16[file.size()];
+ audioStream->readBuffer(buffer, file.size());
+#ifndef SCUMM_LITTLE_ENDIAN
+ for (int i = 0; i < file.size(); ++i)
+ buffer[i] = TO_LE_16(buffer[i]);
+#endif
+ output.write(buffer, file.size() * 2);
+
+ delete[] buffer;
+
+
return true;
}
bool Console::cmdSetRenderState(int argc, const char **argv) {
if (argc != 2) {
- debugPrintf("Use setrenderstate <RenderState: panorama, tilt, flat> to change the current render state\n");
+ debugPrintf("Use %s <RenderState: panorama, tilt, flat> to change the current render state\n", argv[0]);
return true;
}
@@ -137,7 +165,7 @@ bool Console::cmdSetRenderState(int argc, const char **argv) {
else if (renderState.matchString("flat", true))
_engine->getRenderManager()->getRenderTable()->setRenderState(RenderTable::FLAT);
else
- debugPrintf("Use setrenderstate <RenderState: panorama, tilt, flat> to change the current render state\n");
+ debugPrintf("Use %s <RenderState: panorama, tilt, flat> to change the current render state\n", argv[0]);
return true;
}
@@ -150,7 +178,7 @@ bool Console::cmdGenerateRenderTable(int argc, const char **argv) {
bool Console::cmdSetPanoramaFoV(int argc, const char **argv) {
if (argc != 2) {
- debugPrintf("Use setpanoramafov <fieldOfView> to change the current panorama field of view\n");
+ debugPrintf("Use %s <fieldOfView> to change the current panorama field of view\n", argv[0]);
return true;
}
@@ -161,7 +189,7 @@ bool Console::cmdSetPanoramaFoV(int argc, const char **argv) {
bool Console::cmdSetPanoramaScale(int argc, const char **argv) {
if (argc != 2) {
- debugPrintf("Use setpanoramascale <scale> to change the current panorama scale\n");
+ debugPrintf("Use %s <scale> to change the current panorama scale\n", argv[0]);
return true;
}
@@ -170,9 +198,14 @@ bool Console::cmdSetPanoramaScale(int argc, const char **argv) {
return true;
}
-bool Console::cmdChangeLocation(int argc, const char **argv) {
+bool Console::cmdLocation(int argc, const char **argv) {
+ Location curLocation = _engine->getScriptManager()->getCurrentLocation();
+ Common::String scrFile = Common::String::format("%c%c%c%c.scr", curLocation.world, curLocation.room, curLocation.node, curLocation.view);
+ debugPrintf("Current location: world '%c', room '%c', node '%c', view '%c', offset %d, script %s\n",
+ curLocation.world, curLocation.room, curLocation.node, curLocation.view, curLocation.offset, scrFile.c_str());
+
if (argc != 6) {
- debugPrintf("Use changelocation <char: world> <char: room> <char:node> <char:view> <int: x position> to change your location\n");
+ debugPrintf("Use %s <char: world> <char: room> <char:node> <char:view> <int: x offset> to change your location\n", argv[0]);
return true;
}
@@ -181,36 +214,57 @@ bool Console::cmdChangeLocation(int argc, const char **argv) {
return true;
}
+void dumpFile(Common::SeekableReadStream *s, const char *outName) {
+ byte *buffer = new byte[s->size()];
+ s->read(buffer, s->size());
+
+ Common::DumpFile dumpFile;
+ dumpFile.open(outName);
+
+ dumpFile.write(buffer, s->size());
+ dumpFile.flush();
+ dumpFile.close();
+
+ delete[] buffer;
+}
+
bool Console::cmdDumpFile(int argc, const char **argv) {
if (argc != 2) {
- debugPrintf("Use dumpfile <fileName> to dump a file\n");
+ debugPrintf("Use %s <fileName> to dump a file\n", argv[0]);
+ return true;
+ }
+
+ Common::File f;
+ if (!_engine->getSearchManager()->openFile(f, argv[1])) {
+ warning("File not found: %s", argv[1]);
return true;
}
- writeFileContentsToFile(argv[1], argv[1]);
+ dumpFile(&f, argv[1]);
return true;
}
-bool Console::cmdParseAllScrFiles(int argc, const char **argv) {
- Common::ArchiveMemberList list;
- SearchMan.listMatchingMembers(list, "*.scr");
+bool Console::cmdDumpFiles(int argc, const char **argv) {
+ Common::String fileName;
+ Common::SeekableReadStream *in;
- for (Common::ArchiveMemberList::iterator iter = list.begin(); iter != list.end(); ++iter) {
- _engine->getScriptManager()->parseScrFile((*iter)->getName());
+ if (argc != 2) {
+ debugPrintf("Use %s <file extension> to dump all files with a specific extension\n", argv[0]);
+ return true;
}
- return true;
-}
+ SearchManager::MatchList fileList;
+ _engine->getSearchManager()->listMembersWithExtension(fileList, argv[1]);
-bool Console::cmdRenderText(int argc, const char **argv) {
- if (argc != 7) {
- debugPrintf("Use rendertext <text> <fontNumber> <destX> <destY> <maxWidth> <1 or 0: wrap> to render text\n");
- return true;
- }
+ for (SearchManager::MatchList::iterator iter = fileList.begin(); iter != fileList.end(); ++iter) {
+ fileName = iter->_value.name;
+ debugPrintf("Dumping %s\n", fileName.c_str());
- StringManager::TextStyle style = _engine->getStringManager()->getTextStyle(atoi(argv[2]));
- _engine->getRenderManager()->renderTextToWorkingWindow(333, Common::String(argv[1]), style.font, atoi(argv[3]), atoi(argv[4]), style.color, atoi(argv[5]), -1, Graphics::kTextAlignLeft, atoi(argv[6]) == 0 ? false : true);
+ in = iter->_value.arch->createReadStreamForMember(iter->_value.name);
+ dumpFile(in, fileName.c_str());
+ delete in;
+ }
return true;
}
diff --git a/engines/zvision/core/console.h b/engines/zvision/core/console.h
index 29523c57ee..a7bd88ebc3 100644
--- a/engines/zvision/core/console.h
+++ b/engines/zvision/core/console.h
@@ -37,7 +37,6 @@ public:
private:
ZVision *_engine;
- bool cmdLoadImage(int argc, const char **argv);
bool cmdLoadVideo(int argc, const char **argv);
bool cmdLoadSound(int argc, const char **argv);
bool cmdRawToWav(int argc, const char **argv);
@@ -45,10 +44,9 @@ private:
bool cmdGenerateRenderTable(int argc, const char **argv);
bool cmdSetPanoramaFoV(int argc, const char **argv);
bool cmdSetPanoramaScale(int argc, const char **argv);
- bool cmdChangeLocation(int argc, const char **argv);
+ bool cmdLocation(int argc, const char **argv);
bool cmdDumpFile(int argc, const char **argv);
- bool cmdParseAllScrFiles(int argc, const char **argv);
- bool cmdRenderText(int argc, const char **argv);
+ bool cmdDumpFiles(int argc, const char **argv);
};
} // End of namespace ZVision
diff --git a/engines/zvision/core/events.cpp b/engines/zvision/core/events.cpp
index 83d6c17dec..7804130e2a 100644
--- a/engines/zvision/core/events.cpp
+++ b/engines/zvision/core/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.
@@ -25,10 +25,12 @@
#include "zvision/zvision.h"
#include "zvision/core/console.h"
-#include "zvision/cursors/cursor_manager.h"
+#include "zvision/graphics/cursors/cursor_manager.h"
#include "zvision/graphics/render_manager.h"
#include "zvision/scripting/script_manager.h"
-#include "zvision/animation/rlf_animation.h"
+#include "zvision/scripting/menu.h"
+#include "zvision/sound/zork_raw.h"
+#include "zvision/text/string_manager.h"
#include "common/events.h"
#include "common/system.h"
@@ -36,29 +38,186 @@
#include "engines/util.h"
-
namespace ZVision {
+void ZVision::pushKeyToCheatBuf(uint8 key) {
+ for (int i = 0; i < KEYBUF_SIZE - 1; i++)
+ _cheatBuffer[i] = _cheatBuffer[i + 1];
+
+ _cheatBuffer[KEYBUF_SIZE - 1] = key;
+}
+
+bool ZVision::checkCode(const char *code) {
+ int codeLen = strlen(code);
+
+ if (codeLen > KEYBUF_SIZE)
+ return false;
+
+ for (int i = 0; i < codeLen; i++)
+ if (code[i] != _cheatBuffer[KEYBUF_SIZE - codeLen + i] && code[i] != '?')
+ return false;
+
+ return true;
+}
+
+uint8 ZVision::getBufferedKey(uint8 pos) {
+ if (pos >= KEYBUF_SIZE)
+ return 0;
+ else
+ return _cheatBuffer[KEYBUF_SIZE - pos - 1];
+}
+
+void ZVision::shortKeys(Common::Event event) {
+ if (event.kbd.hasFlags(Common::KBD_CTRL)) {
+ switch (event.kbd.keycode) {
+ case Common::KEYCODE_s:
+ if (_menu->getEnable() & kMenubarSave)
+ _scriptManager->changeLocation('g', 'j', 's', 'e', 0);
+ break;
+ case Common::KEYCODE_r:
+ if (_menu->getEnable() & kMenubarRestore)
+ _scriptManager->changeLocation('g', 'j', 'r', 'e', 0);
+ break;
+ case Common::KEYCODE_p:
+ if (_menu->getEnable() & kMenubarSettings)
+ _scriptManager->changeLocation('g', 'j', 'p', 'e', 0);
+ break;
+ case Common::KEYCODE_q:
+ if (_menu->getEnable() & kMenubarExit)
+ ifQuit();
+ break;
+ default:
+ break;
+ }
+ }
+}
+
+void ZVision::cheatCodes(uint8 key) {
+ pushKeyToCheatBuf(key);
+
+ if (getGameId() == GID_GRANDINQUISITOR) {
+ if (checkCode("IMNOTDEAF")) {
+ // Unknown cheat
+ _renderManager->showDebugMsg(Common::String::format("IMNOTDEAF cheat or debug, not implemented"));
+ }
+
+ if (checkCode("3100OPB")) {
+ _renderManager->showDebugMsg(Common::String::format("Current location: %c%c%c%c",
+ _scriptManager->getStateValue(StateKey_World),
+ _scriptManager->getStateValue(StateKey_Room),
+ _scriptManager->getStateValue(StateKey_Node),
+ _scriptManager->getStateValue(StateKey_View)));
+ }
+
+ if (checkCode("KILLMENOW")) {
+ _scriptManager->changeLocation('g', 'j', 'd', 'e', 0);
+ _scriptManager->setStateValue(2201, 35);
+ }
+
+ if (checkCode("MIKESPANTS")) {
+ _scriptManager->changeLocation('g', 'j', 't', 'm', 0);
+ }
+
+ // There are 3 more cheats in script files:
+ // - "WHOAMI": gjcr.scr
+ // - "HUISOK": hp1e.scr
+ // - "EAT ME": uh1f.scr
+ } else if (getGameId() == GID_NEMESIS) {
+ if (checkCode("CHLOE")) {
+ _scriptManager->changeLocation('t', 'm', '2', 'g', 0);
+ _scriptManager->setStateValue(224, 1);
+ }
+
+ if (checkCode("77MASSAVE")) {
+ _renderManager->showDebugMsg(Common::String::format("Current location: %c%c%c%c",
+ _scriptManager->getStateValue(StateKey_World),
+ _scriptManager->getStateValue(StateKey_Room),
+ _scriptManager->getStateValue(StateKey_Node),
+ _scriptManager->getStateValue(StateKey_View)));
+ }
+
+ if (checkCode("IDKFA")) {
+ _scriptManager->changeLocation('t', 'w', '3', 'f', 0);
+ _scriptManager->setStateValue(249, 1);
+ }
+
+ if (checkCode("309NEWDORMA")) {
+ _scriptManager->changeLocation('g', 'j', 'g', 'j', 0);
+ }
+
+ if (checkCode("HELLOSAILOR")) {
+ Location loc = _scriptManager->getCurrentLocation();
+ Audio::AudioStream *soundStream;
+ if (loc.world == 'v' && loc.room == 'b' && loc.node == '1' && loc.view == '0') {
+ soundStream = makeRawZorkStream("v000hpta.raw", this);
+ } else {
+ soundStream = makeRawZorkStream("v000hnta.raw", this);
+ }
+ Audio::SoundHandle handle;
+ _mixer->playStream(Audio::Mixer::kPlainSoundType, &handle, soundStream);
+ }
+ }
+
+ if (checkCode("FRAME")) {
+ Common::String fpsStr = Common::String::format("FPS: %d", getFPS());
+ _renderManager->showDebugMsg(fpsStr);
+ }
+
+ if (checkCode("COMPUTERARCH"))
+ _renderManager->showDebugMsg("COMPUTERARCH: var-viewer not implemented");
+
+ // This cheat essentially toggles the GOxxxx cheat below
+ if (checkCode("XYZZY"))
+ _scriptManager->setStateValue(StateKey_DebugCheats, 1 - _scriptManager->getStateValue(StateKey_DebugCheats));
+
+ if (_scriptManager->getStateValue(StateKey_DebugCheats) == 1)
+ if (checkCode("GO????"))
+ _scriptManager->changeLocation(getBufferedKey(3),
+ getBufferedKey(2),
+ getBufferedKey(1),
+ getBufferedKey(0), 0);
+
+ // Show the Venus screen when "?" or "/" is pressed while inside the temple world
+ if (_scriptManager->getStateValue(StateKey_VenusEnable) == 1)
+ if (getBufferedKey(0) == 0xBF && _scriptManager->getStateValue(StateKey_World) == 't')
+ _scriptManager->changeLocation('g', 'j', 'h', 'e', 0);
+}
+
void ZVision::processEvents() {
while (_eventMan->pollEvent(_event)) {
switch (_event.type) {
case Common::EVENT_LBUTTONDOWN:
- onMouseDown(_event.mouse);
+ _cursorManager->cursorDown(true);
+ _scriptManager->setStateValue(StateKey_LMouse, 1);
+ _menu->onMouseDown(_event.mouse);
+ _scriptManager->addEvent(_event);
break;
case Common::EVENT_LBUTTONUP:
- onMouseUp(_event.mouse);
+ _cursorManager->cursorDown(false);
+ _scriptManager->setStateValue(StateKey_LMouse, 0);
+ _menu->onMouseUp(_event.mouse);
+ _scriptManager->addEvent(_event);
break;
case Common::EVENT_RBUTTONDOWN:
- // TODO: Inventory logic
+ _cursorManager->cursorDown(true);
+ _scriptManager->setStateValue(StateKey_RMouse, 1);
+
+ if (getGameId() == GID_NEMESIS)
+ _scriptManager->inventoryCycle();
+ break;
+
+ case Common::EVENT_RBUTTONUP:
+ _cursorManager->cursorDown(false);
+ _scriptManager->setStateValue(StateKey_RMouse, 0);
break;
case Common::EVENT_MOUSEMOVE:
onMouseMove(_event.mouse);
break;
- case Common::EVENT_KEYDOWN:
+ case Common::EVENT_KEYDOWN: {
switch (_event.kbd.keycode) {
case Common::KEYCODE_d:
if (_event.kbd.hasFlags(Common::KBD_CTRL)) {
@@ -67,18 +226,57 @@ void ZVision::processEvents() {
_console->onFrame();
}
break;
- case Common::KEYCODE_q:
- if (_event.kbd.hasFlags(Common::KBD_CTRL))
- quitGame();
+
+ case Common::KEYCODE_LEFT:
+ case Common::KEYCODE_RIGHT:
+ if (_renderManager->getRenderTable()->getRenderState() == RenderTable::PANORAMA)
+ _keyboardVelocity = (_event.kbd.keycode == Common::KEYCODE_LEFT ?
+ -_scriptManager->getStateValue(StateKey_KbdRotateSpeed) :
+ _scriptManager->getStateValue(StateKey_KbdRotateSpeed)) * 2;
+ break;
+
+ case Common::KEYCODE_UP:
+ case Common::KEYCODE_DOWN:
+ if (_renderManager->getRenderTable()->getRenderState() == RenderTable::TILT)
+ _keyboardVelocity = (_event.kbd.keycode == Common::KEYCODE_UP ?
+ -_scriptManager->getStateValue(StateKey_KbdRotateSpeed) :
+ _scriptManager->getStateValue(StateKey_KbdRotateSpeed)) * 2;
+ break;
+
+ case Common::KEYCODE_F10: {
+ Common::String fpsStr = Common::String::format("FPS: %d", getFPS());
+ _renderManager->showDebugMsg(fpsStr);
+ }
break;
default:
break;
}
- _scriptManager->onKeyDown(_event.kbd);
- break;
+ uint8 vkKey = getZvisionKey(_event.kbd.keycode);
+
+ _scriptManager->setStateValue(StateKey_KeyPress, vkKey);
+
+ _scriptManager->addEvent(_event);
+ shortKeys(_event);
+ cheatCodes(vkKey);
+ }
+ break;
case Common::EVENT_KEYUP:
- _scriptManager->onKeyUp(_event.kbd);
+ _scriptManager->addEvent(_event);
+ switch (_event.kbd.keycode) {
+ case Common::KEYCODE_LEFT:
+ case Common::KEYCODE_RIGHT:
+ if (_renderManager->getRenderTable()->getRenderState() == RenderTable::PANORAMA)
+ _keyboardVelocity = 0;
+ break;
+ case Common::KEYCODE_UP:
+ case Common::KEYCODE_DOWN:
+ if (_renderManager->getRenderTable()->getRenderState() == RenderTable::TILT)
+ _keyboardVelocity = 0;
+ break;
+ default:
+ break;
+ }
break;
default:
break;
@@ -86,24 +284,11 @@ void ZVision::processEvents() {
}
}
-void ZVision::onMouseDown(const Common::Point &pos) {
- _cursorManager->cursorDown(true);
-
- Common::Point imageCoord(_renderManager->screenSpaceToImageSpace(pos));
- _scriptManager->onMouseDown(pos, imageCoord);
-}
-
-void ZVision::onMouseUp(const Common::Point &pos) {
- _cursorManager->cursorDown(false);
-
- Common::Point imageCoord(_renderManager->screenSpaceToImageSpace(pos));
- _scriptManager->onMouseUp(pos, imageCoord);
-}
-
void ZVision::onMouseMove(const Common::Point &pos) {
+ _menu->onMouseMove(pos);
Common::Point imageCoord(_renderManager->screenSpaceToImageSpace(pos));
- bool cursorWasChanged = _scriptManager->onMouseMove(pos, imageCoord);
+ bool cursorWasChanged = false;
// Graph of the function governing rotation velocity:
//
@@ -135,52 +320,183 @@ void ZVision::onMouseMove(const Common::Point &pos) {
// |
// ^
- if (_workingWindow.contains(pos)) {
+ // Clip the horizontal mouse position to the working window
+ Common::Point clippedPos = pos;
+ clippedPos.x = CLIP<int16>(pos.x, _workingWindow.left + 1, _workingWindow.right - 1);
+
+ if (_workingWindow.contains(clippedPos)) {
+ cursorWasChanged = _scriptManager->onMouseMove(clippedPos, imageCoord);
+
RenderTable::RenderState renderState = _renderManager->getRenderTable()->getRenderState();
if (renderState == RenderTable::PANORAMA) {
- if (pos.x >= _workingWindow.left && pos.x < _workingWindow.left + ROTATION_SCREEN_EDGE_OFFSET) {
- // Linear function of distance to the left edge (y = -mx + b)
- // We use fixed point math to get better accuracy
- Common::Rational velocity = (Common::Rational(MAX_ROTATION_SPEED, ROTATION_SCREEN_EDGE_OFFSET) * (pos.x - _workingWindow.left)) - MAX_ROTATION_SPEED;
- _renderManager->setBackgroundVelocity(velocity.toInt());
- _cursorManager->setLeftCursor();
+ if (clippedPos.x >= _workingWindow.left && clippedPos.x < _workingWindow.left + ROTATION_SCREEN_EDGE_OFFSET) {
+
+ int16 mspeed = _scriptManager->getStateValue(StateKey_RotateSpeed) >> 4;
+ if (mspeed <= 0) {
+ mspeed = 25;
+ }
+ _mouseVelocity = MIN(((Common::Rational(mspeed, ROTATION_SCREEN_EDGE_OFFSET) * (clippedPos.x - _workingWindow.left)) - mspeed).toInt(), -1);
+
+
+ _cursorManager->changeCursor(CursorIndex_Left);
cursorWasChanged = true;
- } else if (pos.x <= _workingWindow.right && pos.x > _workingWindow.right - ROTATION_SCREEN_EDGE_OFFSET) {
- // Linear function of distance to the right edge (y = mx)
- // We use fixed point math to get better accuracy
- Common::Rational velocity = Common::Rational(MAX_ROTATION_SPEED, ROTATION_SCREEN_EDGE_OFFSET) * (pos.x - _workingWindow.right + ROTATION_SCREEN_EDGE_OFFSET);
- _renderManager->setBackgroundVelocity(velocity.toInt());
- _cursorManager->setRightCursor();
+ } else if (clippedPos.x <= _workingWindow.right && clippedPos.x > _workingWindow.right - ROTATION_SCREEN_EDGE_OFFSET) {
+
+ int16 mspeed = _scriptManager->getStateValue(StateKey_RotateSpeed) >> 4;
+ if (mspeed <= 0) {
+ mspeed = 25;
+ }
+ _mouseVelocity = MAX((Common::Rational(mspeed, ROTATION_SCREEN_EDGE_OFFSET) * (clippedPos.x - _workingWindow.right + ROTATION_SCREEN_EDGE_OFFSET)).toInt(), 1);
+
+ _cursorManager->changeCursor(CursorIndex_Right);
cursorWasChanged = true;
} else {
- _renderManager->setBackgroundVelocity(0);
+ _mouseVelocity = 0;
}
} else if (renderState == RenderTable::TILT) {
- if (pos.y >= _workingWindow.top && pos.y < _workingWindow.top + ROTATION_SCREEN_EDGE_OFFSET) {
- // Linear function of distance to top edge
- // We use fixed point math to get better accuracy
- Common::Rational velocity = (Common::Rational(MAX_ROTATION_SPEED, ROTATION_SCREEN_EDGE_OFFSET) * (pos.y - _workingWindow.top)) - MAX_ROTATION_SPEED;
- _renderManager->setBackgroundVelocity(velocity.toInt());
- _cursorManager->setUpCursor();
+ if (clippedPos.y >= _workingWindow.top && clippedPos.y < _workingWindow.top + ROTATION_SCREEN_EDGE_OFFSET) {
+
+ int16 mspeed = _scriptManager->getStateValue(StateKey_RotateSpeed) >> 4;
+ if (mspeed <= 0) {
+ mspeed = 25;
+ }
+ _mouseVelocity = MIN(((Common::Rational(mspeed, ROTATION_SCREEN_EDGE_OFFSET) * (pos.y - _workingWindow.top)) - mspeed).toInt(), -1);
+
+ _cursorManager->changeCursor(CursorIndex_UpArr);
cursorWasChanged = true;
- } else if (pos.y <= _workingWindow.bottom && pos.y > _workingWindow.bottom - ROTATION_SCREEN_EDGE_OFFSET) {
- // Linear function of distance to the bottom edge (y = mx)
- // We use fixed point math to get better accuracy
- Common::Rational velocity = Common::Rational(MAX_ROTATION_SPEED, ROTATION_SCREEN_EDGE_OFFSET) * (pos.y - _workingWindow.bottom + ROTATION_SCREEN_EDGE_OFFSET);
- _renderManager->setBackgroundVelocity(velocity.toInt());
- _cursorManager->setDownCursor();
+ } else if (clippedPos.y <= _workingWindow.bottom && clippedPos.y > _workingWindow.bottom - ROTATION_SCREEN_EDGE_OFFSET) {
+
+ int16 mspeed = _scriptManager->getStateValue(StateKey_RotateSpeed) >> 4;
+ if (mspeed <= 0) {
+ mspeed = 25;
+ }
+ _mouseVelocity = MAX((Common::Rational(MAX_ROTATION_SPEED, ROTATION_SCREEN_EDGE_OFFSET) * (pos.y - _workingWindow.bottom + ROTATION_SCREEN_EDGE_OFFSET)).toInt(), 1);
+
+ _cursorManager->changeCursor(CursorIndex_DownArr);
cursorWasChanged = true;
} else {
- _renderManager->setBackgroundVelocity(0);
+ _mouseVelocity = 0;
}
+ } else {
+ _mouseVelocity = 0;
}
} else {
- _renderManager->setBackgroundVelocity(0);
+ _mouseVelocity = 0;
}
if (!cursorWasChanged) {
- _cursorManager->revertToIdle();
+ _cursorManager->changeCursor(CursorIndex_Idle);
+ }
+}
+
+uint8 ZVision::getZvisionKey(Common::KeyCode scummKeyCode) {
+ if (scummKeyCode >= Common::KEYCODE_a && scummKeyCode <= Common::KEYCODE_z)
+ return 0x41 + scummKeyCode - Common::KEYCODE_a;
+ if (scummKeyCode >= Common::KEYCODE_0 && scummKeyCode <= Common::KEYCODE_9)
+ return 0x30 + scummKeyCode - Common::KEYCODE_0;
+ if (scummKeyCode >= Common::KEYCODE_F1 && scummKeyCode <= Common::KEYCODE_F15)
+ return 0x70 + scummKeyCode - Common::KEYCODE_F1;
+ if (scummKeyCode >= Common::KEYCODE_KP0 && scummKeyCode <= Common::KEYCODE_KP9)
+ return 0x60 + scummKeyCode - Common::KEYCODE_KP0;
+
+ switch (scummKeyCode) {
+ case Common::KEYCODE_BACKSPACE:
+ return 0x8;
+ case Common::KEYCODE_TAB:
+ return 0x9;
+ case Common::KEYCODE_CLEAR:
+ return 0xC;
+ case Common::KEYCODE_RETURN:
+ return 0xD;
+ case Common::KEYCODE_CAPSLOCK:
+ return 0x14;
+ case Common::KEYCODE_ESCAPE:
+ return 0x1B;
+ case Common::KEYCODE_SPACE:
+ return 0x20;
+ case Common::KEYCODE_PAGEUP:
+ return 0x21;
+ case Common::KEYCODE_PAGEDOWN:
+ return 0x22;
+ case Common::KEYCODE_END:
+ return 0x23;
+ case Common::KEYCODE_HOME:
+ return 0x24;
+ case Common::KEYCODE_LEFT:
+ return 0x25;
+ case Common::KEYCODE_UP:
+ return 0x26;
+ case Common::KEYCODE_RIGHT:
+ return 0x27;
+ case Common::KEYCODE_DOWN:
+ return 0x28;
+ case Common::KEYCODE_PRINT:
+ return 0x2A;
+ case Common::KEYCODE_INSERT:
+ return 0x2D;
+ case Common::KEYCODE_DELETE:
+ return 0x2E;
+ case Common::KEYCODE_HELP:
+ return 0x2F;
+ case Common::KEYCODE_KP_MULTIPLY:
+ return 0x6A;
+ case Common::KEYCODE_KP_PLUS:
+ return 0x6B;
+ case Common::KEYCODE_KP_MINUS:
+ return 0x6D;
+ case Common::KEYCODE_KP_PERIOD:
+ return 0x6E;
+ case Common::KEYCODE_KP_DIVIDE:
+ return 0x6F;
+ case Common::KEYCODE_NUMLOCK:
+ return 0x90;
+ case Common::KEYCODE_SCROLLOCK:
+ return 0x91;
+ case Common::KEYCODE_LSHIFT:
+ return 0xA0;
+ case Common::KEYCODE_RSHIFT:
+ return 0xA1;
+ case Common::KEYCODE_LCTRL:
+ return 0xA2;
+ case Common::KEYCODE_RCTRL:
+ return 0xA3;
+ case Common::KEYCODE_MENU:
+ return 0xA5;
+ case Common::KEYCODE_LEFTBRACKET:
+ return 0xDB;
+ case Common::KEYCODE_RIGHTBRACKET:
+ return 0xDD;
+ case Common::KEYCODE_SEMICOLON:
+ return 0xBA;
+ case Common::KEYCODE_BACKSLASH:
+ return 0xDC;
+ case Common::KEYCODE_QUOTE:
+ return 0xDE;
+ case Common::KEYCODE_SLASH:
+ return 0xBF;
+ case Common::KEYCODE_TILDE:
+ return 0xC0;
+ case Common::KEYCODE_COMMA:
+ return 0xBC;
+ case Common::KEYCODE_PERIOD:
+ return 0xBE;
+ case Common::KEYCODE_MINUS:
+ return 0xBD;
+ case Common::KEYCODE_PLUS:
+ return 0xBB;
+ default:
+ return 0;
+ }
+
+ return 0;
+}
+
+bool ZVision::ifQuit() {
+ if (_renderManager->askQuestion(_stringManager->getTextLine(StringManager::ZVISION_STR_EXITPROMT))) {
+ quitGame();
+ return true;
}
+ return false;
}
} // End of namespace ZVision
diff --git a/engines/zvision/core/save_manager.cpp b/engines/zvision/core/save_manager.cpp
deleted file mode 100644
index 07fb7637e7..0000000000
--- a/engines/zvision/core/save_manager.cpp
+++ /dev/null
@@ -1,206 +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 "common/scummsys.h"
-
-#include "zvision/core/save_manager.h"
-
-#include "zvision/zvision.h"
-#include "zvision/scripting/script_manager.h"
-#include "zvision/graphics/render_manager.h"
-
-#include "common/system.h"
-
-#include "graphics/surface.h"
-#include "graphics/thumbnail.h"
-
-#include "gui/message.h"
-
-
-namespace ZVision {
-
-const uint32 SaveManager::SAVEGAME_ID = MKTAG('Z', 'E', 'N', 'G');
-
-void SaveManager::saveGame(uint slot, const Common::String &saveName) {
- // The games only support 20 slots
- assert(slot <= 1 && slot <= 20);
-
- Common::SaveFileManager *saveFileManager = g_system->getSavefileManager();
- Common::OutSaveFile *file = saveFileManager->openForSaving(_engine->generateSaveFileName(slot));
-
- // Write out the savegame header
- file->writeUint32BE(SAVEGAME_ID);
-
- // Write version
- file->writeByte(SAVE_VERSION);
-
- // Write savegame name
- file->writeString(saveName);
- file->writeByte(0);
-
- // We can't call writeGameSaveData because the save menu is actually
- // a room, so writeGameSaveData would save us in the save menu.
- // However, an auto save is performed before each room change, so we
- // can copy the data from there. We can guarantee that an auto save file will
- // exist before this is called because the save menu can only be accessed
- // after the first room (the main menu) has loaded.
- Common::InSaveFile *autoSaveFile = saveFileManager->openForLoading(_engine->generateAutoSaveFileName());
-
- // Skip over the header info
- autoSaveFile->readSint32BE(); // SAVEGAME_ID
- autoSaveFile->readByte(); // Version
- autoSaveFile->seek(5, SEEK_CUR); // The string "auto" with terminating NULL
-
- // Read the rest to a buffer
- uint32 size = autoSaveFile->size() - autoSaveFile->pos();
- byte *buffer = new byte[size];
- autoSaveFile->read(buffer, size);
-
- // Then write the buffer to the new file
- file->write(buffer, size);
-
- // Cleanup
- delete[] buffer;
- file->finalize();
- delete file;
-}
-
-void SaveManager::autoSave() {
- Common::OutSaveFile *file = g_system->getSavefileManager()->openForSaving(_engine->generateAutoSaveFileName());
-
- // Write out the savegame header
- file->writeUint32BE(SAVEGAME_ID);
-
- // Version
- file->writeByte(SAVE_VERSION);
-
- file->writeString("auto");
- file->writeByte(0);
-
- writeSaveGameData(file);
-
- // Cleanup
- file->finalize();
- delete file;
-}
-
-void SaveManager::writeSaveGameData(Common::OutSaveFile *file) {
- // Create a thumbnail and save it
- Graphics::saveThumbnail(*file);
-
- // Write out the save date/time
- TimeDate td;
- g_system->getTimeAndDate(td);
- file->writeSint16LE(td.tm_year + 1900);
- file->writeSint16LE(td.tm_mon + 1);
- file->writeSint16LE(td.tm_mday);
- file->writeSint16LE(td.tm_hour);
- file->writeSint16LE(td.tm_min);
-
- ScriptManager *scriptManager = _engine->getScriptManager();
- // Write out the current location
- Location currentLocation = scriptManager->getCurrentLocation();
- file->writeByte(currentLocation.world);
- file->writeByte(currentLocation.room);
- file->writeByte(currentLocation.node);
- file->writeByte(currentLocation.view);
- file->writeUint32LE(currentLocation.offset);
-
- // Write out the current state table values
- scriptManager->serializeStateTable(file);
-
- // Write out any controls needing to save state
- scriptManager->serializeControls(file);
-}
-
-Common::Error SaveManager::loadGame(uint slot) {
- // The games only support 20 slots
- assert(slot <= 1 && slot <= 20);
-
- Common::InSaveFile *saveFile = g_system->getSavefileManager()->openForLoading(_engine->generateSaveFileName(slot));
- if (saveFile == 0) {
- return Common::kPathDoesNotExist;
- }
-
- // Read the header
- SaveGameHeader header;
- if (!readSaveGameHeader(saveFile, header)) {
- return Common::kUnknownError;
- }
-
- char world = (char)saveFile->readByte();
- char room = (char)saveFile->readByte();
- char node = (char)saveFile->readByte();
- char view = (char)saveFile->readByte();
- uint32 offset = (char)saveFile->readUint32LE();
-
- ScriptManager *scriptManager = _engine->getScriptManager();
- // Update the state table values
- scriptManager->deserializeStateTable(saveFile);
-
- // Load the room
- scriptManager->changeLocation(world, room, node, view, offset);
-
- // Update the controls
- scriptManager->deserializeControls(saveFile);
-
- return Common::kNoError;
-}
-
-bool SaveManager::readSaveGameHeader(Common::InSaveFile *in, SaveGameHeader &header) {
- if (in->readUint32BE() != SAVEGAME_ID) {
- warning("File is not a ZVision save file. Aborting load");
- return false;
- }
-
- // Read in the version
- header.version = in->readByte();
-
- // Check that the save version isn't newer than this binary
- if (header.version > SAVE_VERSION) {
- uint tempVersion = header.version;
- GUI::MessageDialog dialog(Common::String::format("This save file uses version %u, but this engine only supports up to version %d. You will need an updated version of the engine to use this save file.", tempVersion, SAVE_VERSION), "OK");
- dialog.runModal();
- }
-
- // Read in the save name
- 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.saveYear = in->readSint16LE();
- header.saveMonth = in->readSint16LE();
- header.saveDay = in->readSint16LE();
- header.saveHour = in->readSint16LE();
- header.saveMinutes = in->readSint16LE();
-
- return true;
-}
-
-} // End of namespace ZVision
diff --git a/engines/zvision/cursors/cursor.cpp b/engines/zvision/cursors/cursor.cpp
deleted file mode 100644
index 9b9b9a3f71..0000000000
--- a/engines/zvision/cursors/cursor.cpp
+++ /dev/null
@@ -1,94 +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 "common/scummsys.h"
-
-#include "zvision/cursors/cursor.h"
-
-#include "common/str.h"
-#include "common/file.h"
-
-
-namespace ZVision {
-
-ZorkCursor::ZorkCursor()
- : _width(0),
- _height(0),
- _hotspotX(0),
- _hotspotY(0) {
-}
-
-ZorkCursor::ZorkCursor(const Common::String &fileName)
- : _width(0),
- _height(0),
- _hotspotX(0),
- _hotspotY(0) {
- Common::File file;
- if (!file.open(fileName))
- return;
-
- uint32 magic = file.readUint32BE();
- if (magic != MKTAG('Z', 'C', 'R', '1')) {
- warning("%s is not a Zork Cursor file", fileName.c_str());
- return;
- }
-
- _hotspotX = file.readUint16LE();
- _hotspotY = file.readUint16LE();
- _width = file.readUint16LE();
- _height = file.readUint16LE();
-
- uint dataSize = _width * _height * sizeof(uint16);
- _surface.create(_width, _height, Graphics::PixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0));
- uint32 bytesRead = file.read(_surface.getPixels(), dataSize);
- assert(bytesRead == dataSize);
-
- // Convert to RGB 565
- _surface.convertToInPlace(Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0));
-}
-
-ZorkCursor::ZorkCursor(const ZorkCursor &other) {
- _width = other._width;
- _height = other._height;
- _hotspotX = other._hotspotX;
- _hotspotY = other._hotspotY;
-
- _surface.copyFrom(other._surface);
-}
-
-ZorkCursor &ZorkCursor::operator=(const ZorkCursor &other) {
- _width = other._width;
- _height = other._height;
- _hotspotX = other._hotspotX;
- _hotspotY = other._hotspotY;
-
- _surface.free();
- _surface.copyFrom(other._surface);
-
- return *this;
-}
-
-ZorkCursor::~ZorkCursor() {
- _surface.free();
-}
-
-} // End of namespace ZVision
diff --git a/engines/zvision/cursors/cursor_manager.cpp b/engines/zvision/cursors/cursor_manager.cpp
deleted file mode 100644
index 7f70c8b4e3..0000000000
--- a/engines/zvision/cursors/cursor_manager.cpp
+++ /dev/null
@@ -1,152 +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 "common/scummsys.h"
-
-#include "zvision/cursors/cursor_manager.h"
-
-#include "zvision/zvision.h"
-
-#include "common/system.h"
-
-#include "graphics/pixelformat.h"
-#include "graphics/cursorman.h"
-
-
-namespace ZVision {
-
-const char *CursorManager::_cursorNames[NUM_CURSORS] = { "active", "arrow", "backward", "downarrow", "forward", "handpt", "handpu", "hdown", "hleft",
- "hright", "hup", "idle", "leftarrow", "rightarrow", "suggest_surround", "suggest_tilt", "turnaround", "zuparrow" };
-
-const char *CursorManager::_zgiCursorFileNames[NUM_CURSORS] = { "g0gbc011.zcr", "g0gac001.zcr", "g0gac021.zcr", "g0gac031.zcr", "g0gac041.zcr", "g0gac051.zcr", "g0gac061.zcr", "g0gac071.zcr", "g0gac081.zcr",
- "g0gac091.zcr", "g0gac101.zcr", "g0gac011.zcr", "g0gac111.zcr", "g0gac121.zcr", "g0gac131.zcr", "g0gac141.zcr", "g0gac151.zcr", "g0gac161.zcr" };
-
-const char *CursorManager::_zNemCursorFileNames[NUM_CURSORS] = { "00act", "arrow", "back", "down", "forw", "handpt", "handpu", "hdown", "hleft",
- "hright", "hup", "00idle", "left", "right", "ssurr", "stilt", "turn", "up" };
-
-
-CursorManager::CursorManager(ZVision *engine, const Graphics::PixelFormat *pixelFormat)
- : _engine(engine),
- _pixelFormat(pixelFormat),
- _cursorIsPushed(false) {
- // WARNING: The index IDLE_CURSOR_INDEX is hardcoded. If you change the order of _cursorNames/_zgiCursorFileNames/_zNemCursorFileNames, you HAVE to change the index accordingly
- if (_engine->getGameId() == GID_NEMESIS) {
- Common::String name(Common::String::format("%sa.zcr", _zNemCursorFileNames[IDLE_CURSOR_INDEX]));
- _idleCursor = ZorkCursor(name);
- } else if (_engine->getGameId() == GID_GRANDINQUISITOR) {
- _idleCursor = ZorkCursor(_zgiCursorFileNames[IDLE_CURSOR_INDEX]);
- }
-}
-
-void CursorManager::initialize() {
- revertToIdle();
- CursorMan.showMouse(true);
-}
-
-void CursorManager::changeCursor(const Common::String &cursorName) {
- changeCursor(cursorName, _cursorIsPushed);
-}
-
-void CursorManager::changeCursor(const Common::String &cursorName, bool pushed) {
- if (_currentCursor.equals(cursorName) && _cursorIsPushed == pushed)
- return;
-
- if (_cursorIsPushed != pushed)
- _cursorIsPushed = pushed;
-
- if (cursorName == "idle" && !pushed) {
- CursorMan.replaceCursor(_idleCursor.getSurface(), _idleCursor.getWidth(), _idleCursor.getHeight(), _idleCursor.getHotspotX(), _idleCursor.getHotspotY(), _idleCursor.getKeyColor(), false, _pixelFormat);
- return;
- }
-
- for (int i = 0; i < NUM_CURSORS; ++i) {
- if (_engine->getGameId() == GID_NEMESIS) {
- if (cursorName.equals(_cursorNames[i])) {
- _currentCursor = cursorName;
-
- // ZNem uses a/b at the end of the file to signify not pushed/pushed respectively
- Common::String pushedFlag = pushed ? "b" : "a";
- Common::String name = Common::String::format("%s%s.zcr", _zNemCursorFileNames[i], pushedFlag.c_str());
-
- changeCursor(ZorkCursor(name));
- return;
- }
- } else if (_engine->getGameId() == GID_GRANDINQUISITOR) {
- if (cursorName.equals(_cursorNames[i])) {
- _currentCursor = cursorName;
-
- if (!pushed) {
- changeCursor(ZorkCursor(_zgiCursorFileNames[i]));
- } else {
- // ZGI flips not pushed/pushed between a/c and b/d
- // It flips the 4th character of the name
- char buffer[25];
- strcpy(buffer, _zgiCursorFileNames[i]);
- buffer[3] += 2;
- changeCursor(ZorkCursor(buffer));
- }
- return;
- }
- }
- }
-
- // If we get here, something went wrong
- warning("No cursor found for identifier %s", cursorName.c_str());
-}
-
-void CursorManager::changeCursor(const ZorkCursor &cursor) {
- CursorMan.replaceCursor(cursor.getSurface(), cursor.getWidth(), cursor.getHeight(), cursor.getHotspotX(), cursor.getHotspotY(), cursor.getKeyColor(), false, _pixelFormat);
-}
-
-void CursorManager::cursorDown(bool pushed) {
- if (_cursorIsPushed == pushed)
- return;
-
- _cursorIsPushed = pushed;
- changeCursor(_currentCursor, pushed);
-}
-
-void CursorManager::setLeftCursor() {
- changeCursor("leftarrow");
-}
-
-void CursorManager::setRightCursor() {
- changeCursor("rightarrow");
-}
-
-void CursorManager::setUpCursor() {
- changeCursor("zuparrow");
-}
-
-void CursorManager::setDownCursor() {
- changeCursor("downarrow");
-}
-
-void CursorManager::revertToIdle() {
- _currentCursor = "idle";
- if (!_cursorIsPushed)
- CursorMan.replaceCursor(_idleCursor.getSurface(), _idleCursor.getWidth(), _idleCursor.getHeight(), _idleCursor.getHotspotX(), _idleCursor.getHotspotY(), _idleCursor.getKeyColor(), false, _pixelFormat);
- else
- changeCursor(_currentCursor, _cursorIsPushed);
-}
-
-} // End of namespace ZVision
diff --git a/engines/zvision/detection.cpp b/engines/zvision/detection.cpp
index 9961db1215..1eaff83413 100644
--- a/engines/zvision/detection.cpp
+++ b/engines/zvision/detection.cpp
@@ -26,13 +26,14 @@
#include "zvision/zvision.h"
#include "zvision/detection.h"
+#include "zvision/file/save_manager.h"
+#include "zvision/scripting/script_manager.h"
#include "common/translation.h"
#include "common/savefile.h"
#include "common/str-array.h"
#include "common/system.h"
-
namespace ZVision {
uint32 ZVision::getFeatures() const {
@@ -45,7 +46,6 @@ Common::Language ZVision::getLanguage() const {
} // End of namespace ZVision
-
static const PlainGameDescriptor zVisionGames[] = {
{"zvision", "ZVision Game"},
{"znemesis", "Zork Nemesis: The Forbidden Lands"},
@@ -53,9 +53,13 @@ static const PlainGameDescriptor zVisionGames[] = {
{0, 0}
};
-
namespace ZVision {
+#define GAMEOPTION_ORIGINAL_SAVELOAD GUIO_GAMEOPTIONS1
+#define GAMEOPTION_DOUBLE_FPS GUIO_GAMEOPTIONS2
+#define GAMEOPTION_ENABLE_VENUS GUIO_GAMEOPTIONS3
+#define GAMEOPTION_DISABLE_ANIM_WHILE_TURNING GUIO_GAMEOPTIONS4
+
static const ZVisionGameDescription gameDescriptions[] = {
{
@@ -67,21 +71,63 @@ static const ZVisionGameDescription gameDescriptions[] = {
Common::EN_ANY,
Common::kPlatformDOS,
ADGF_NO_FLAGS,
- GUIO1(GUIO_NONE)
+ GUIO4(GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_DOUBLE_FPS, GAMEOPTION_ENABLE_VENUS, GAMEOPTION_DISABLE_ANIM_WHILE_TURNING)
},
GID_NEMESIS
},
{
- // Zork Grand Inquisitor English version
+ // Zork Nemesis English demo version
+ {
+ "znemesis",
+ "Demo",
+ AD_ENTRY1s("SCRIPTS.ZFS", "64f1e881394e9462305104f99513c833", 380539),
+ Common::EN_ANY,
+ Common::kPlatformWindows,
+ ADGF_DEMO,
+ GUIO4(GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_DOUBLE_FPS, GAMEOPTION_ENABLE_VENUS, GAMEOPTION_DISABLE_ANIM_WHILE_TURNING)
+ },
+ GID_NEMESIS
+ },
+
+ {
+ // Zork Grand Inquisitor English CD version
{
"zgi",
- 0,
+ "CD",
AD_ENTRY1s("SCRIPTS.ZFS", "81efd40ecc3d22531e211368b779f17f", 8336944),
Common::EN_ANY,
Common::kPlatformWindows,
ADGF_NO_FLAGS,
- GUIO1(GUIO_NONE)
+ GUIO3(GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_DOUBLE_FPS, GAMEOPTION_DISABLE_ANIM_WHILE_TURNING)
+ },
+ GID_GRANDINQUISITOR
+ },
+
+ {
+ // Zork Grand Inquisitor English DVD version
+ {
+ "zgi",
+ "DVD",
+ AD_ENTRY1s("SCRIPTS.ZFS", "03157a3399513bfaaf8dc6d5ab798b36", 8433326),
+ Common::EN_ANY,
+ Common::kPlatformWindows,
+ ADGF_NO_FLAGS,
+ GUIO3(GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_DOUBLE_FPS, GAMEOPTION_DISABLE_ANIM_WHILE_TURNING)
+ },
+ GID_GRANDINQUISITOR
+ },
+
+ {
+ // Zork Grand Inquisitor English demo version
+ {
+ "zgi",
+ "Demo",
+ AD_ENTRY1s("SCRIPTS.ZFS", "71a2494fd2fb999347deb13401e9b998", 304239),
+ Common::EN_ANY,
+ Common::kPlatformWindows,
+ ADGF_DEMO,
+ GUIO3(GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_DOUBLE_FPS, GAMEOPTION_DISABLE_ANIM_WHILE_TURNING)
},
GID_GRANDINQUISITOR
},
@@ -99,16 +145,53 @@ static const char *directoryGlobs[] = {
0
};
-static const ExtraGuiOption ZVisionExtraGuiOption = {
- _s("Use original save/load screens"),
- _s("Use the original save/load screens, instead of the ScummVM ones"),
- "originalsaveload",
- false
+static const ADExtraGuiOptionsMap optionsList[] = {
+ {
+ GAMEOPTION_ORIGINAL_SAVELOAD,
+ {
+ _s("Use original save/load screens"),
+ _s("Use the original save/load screens, instead of the ScummVM ones"),
+ "originalsaveload",
+ false
+ }
+ },
+
+ {
+ GAMEOPTION_DOUBLE_FPS,
+ {
+ _s("Double FPS"),
+ _s("Halve the update delay"),
+ "doublefps",
+ false
+ }
+ },
+
+ {
+ GAMEOPTION_ENABLE_VENUS,
+ {
+ _s("Enable Venus"),
+ _s("Enable the Venus help system"),
+ "venusenabled",
+ true
+ }
+ },
+
+ {
+ GAMEOPTION_DISABLE_ANIM_WHILE_TURNING,
+ {
+ _s("Disable animation while turning"),
+ _s("Disable animation while turning in panoramic mode"),
+ "noanimwhileturning",
+ false
+ }
+ },
+
+ AD_EXTRA_GUI_OPTIONS_TERMINATOR
};
class ZVisionMetaEngine : public AdvancedMetaEngine {
public:
- ZVisionMetaEngine() : AdvancedMetaEngine(ZVision::gameDescriptions, sizeof(ZVision::ZVisionGameDescription), zVisionGames) {
+ ZVisionMetaEngine() : AdvancedMetaEngine(ZVision::gameDescriptions, sizeof(ZVision::ZVisionGameDescription), zVisionGames, optionsList) {
_maxScanDepth = 2;
_directoryGlobs = directoryGlobs;
_singleid = "zvision";
@@ -124,7 +207,6 @@ public:
virtual bool hasFeature(MetaEngineFeature f) const;
virtual bool createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const;
- virtual const ExtraGuiOptions getExtraGuiOptions(const Common::String &target) const;
SaveStateList listSaves(const char *target) const;
virtual int getMaximumSaveSlot() const;
void removeSaveState(const char *target, int slot) const;
@@ -132,24 +214,40 @@ public:
};
bool ZVisionMetaEngine::hasFeature(MetaEngineFeature f) const {
- return false;
- /*
- (f == kSupportsListSaves) ||
- (f == kSupportsLoadingDuringStartup) ||
- (f == kSupportsDeleteSave) ||
- (f == kSavesSupportMetaInfo) ||
- (f == kSavesSupportThumbnail) ||
- (f == kSavesSupportCreationDate) ||
- (f == kSavesSupportPlayTime);
- */
+ return
+ (f == kSupportsListSaves) ||
+ (f == kSupportsLoadingDuringStartup) ||
+ (f == kSupportsDeleteSave) ||
+ (f == kSavesSupportMetaInfo) ||
+ (f == kSavesSupportThumbnail) ||
+ (f == kSavesSupportCreationDate);
+ //(f == kSavesSupportPlayTime);
}
-/*bool ZVision::ZVision::hasFeature(EngineFeature f) const {
- return
- (f == kSupportsRTL) ||
- (f == kSupportsLoadingDuringRuntime) ||
- (f == kSupportsSavingDuringRuntime);
-}*/
+bool ZVision::ZVision::hasFeature(EngineFeature f) const {
+ return
+ (f == kSupportsRTL) ||
+ (f == kSupportsLoadingDuringRuntime) ||
+ (f == kSupportsSavingDuringRuntime);
+}
+
+Common::Error ZVision::ZVision::loadGameState(int slot) {
+ return _saveManager->loadGame(slot);
+}
+
+Common::Error ZVision::ZVision::saveGameState(int slot, const Common::String &desc) {
+ _saveManager->saveGame(slot, desc);
+ return Common::kNoError;
+}
+
+bool ZVision::ZVision::canLoadGameStateCurrently() {
+ return !_videoIsPlaying;
+}
+
+bool ZVision::ZVision::canSaveGameStateCurrently() {
+ Location currentLocation = _scriptManager->getCurrentLocation();
+ return !_videoIsPlaying && currentLocation.world != 'g' && !(currentLocation.room == 'j' || currentLocation.room == 'a');
+}
bool ZVisionMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const {
const ZVision::ZVisionGameDescription *gd = (const ZVision::ZVisionGameDescription *)desc;
@@ -159,37 +257,36 @@ bool ZVisionMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADG
return gd != 0;
}
-const ExtraGuiOptions ZVisionMetaEngine::getExtraGuiOptions(const Common::String &target) const {
- ExtraGuiOptions options;
- options.push_back(ZVisionExtraGuiOption);
- return options;
-}
-
SaveStateList ZVisionMetaEngine::listSaves(const char *target) const {
- //Common::SaveFileManager *saveFileMan = g_system->getSavefileManager();
- /*ZVision::ZVision::SaveHeader header;
+ Common::SaveFileManager *saveFileMan = g_system->getSavefileManager();
+ ZVision::SaveGameHeader header;
Common::String pattern = target;
pattern += ".???";
Common::StringArray filenames;
filenames = saveFileMan->listSavefiles(pattern.c_str());
- Common::sort(filenames.begin(), filenames.end()); // Sort (hopefully ensuring we are sorted numerically..)*/
+ Common::sort(filenames.begin(), filenames.end()); // Sort (hopefully ensuring we are sorted numerically..)*/
SaveStateList saveList;
-/* for (Common::StringArray::const_iterator file = filenames.begin(); file != filenames.end(); file++) {
- // Obtain the last 3 digits of the filename, since they correspond to the save slot
- int slotNum = atoi(file->c_str() + file->size() - 3);
-
- if (slotNum >= 0 && slotNum <= 999) {
- Common::InSaveFile *in = saveFileMan->openForLoading(file->c_str());
- if (in) {
- if (ZVision::ZVision::readSaveHeader(in, false, header) == ZVision::ZVision::kRSHENoError) {
- saveList.push_back(SaveStateDescriptor(slotNum, header.description));
- }
- delete in;
- }
- }
- }*/
+ // We only use readSaveGameHeader() here, which doesn't need an engine callback
+ ZVision::SaveManager *zvisionSaveMan = new ZVision::SaveManager(NULL);
+
+ for (Common::StringArray::const_iterator file = filenames.begin(); file != filenames.end(); file++) {
+ // Obtain the last 3 digits of the filename, since they correspond to the save slot
+ int slotNum = atoi(file->c_str() + file->size() - 3);
+
+ if (slotNum >= 0 && slotNum <= 999) {
+ Common::InSaveFile *in = saveFileMan->openForLoading(file->c_str());
+ if (in) {
+ if (zvisionSaveMan->readSaveGameHeader(in, header)) {
+ saveList.push_back(SaveStateDescriptor(slotNum, header.saveName));
+ }
+ delete in;
+ }
+ }
+ }
+
+ delete zvisionSaveMan;
return saveList;
}
@@ -199,9 +296,8 @@ int ZVisionMetaEngine::getMaximumSaveSlot() const {
}
void ZVisionMetaEngine::removeSaveState(const char *target, int slot) const {
- /*
Common::SaveFileManager *saveFileMan = g_system->getSavefileManager();
- Common::String filename = ZVision::ZVision::getSavegameFilename(target, slot);
+ Common::String filename = Common::String::format("%s.%03u", target, slot);
saveFileMan->removeSavefile(filename.c_str());
@@ -209,63 +305,67 @@ void ZVisionMetaEngine::removeSaveState(const char *target, int slot) const {
Common::String pattern = target;
pattern += ".???";
filenames = saveFileMan->listSavefiles(pattern.c_str());
- Common::sort(filenames.begin(), filenames.end()); // Sort (hopefully ensuring we are sorted numerically..)
+ Common::sort(filenames.begin(), filenames.end()); // Sort (hopefully ensuring we are sorted numerically..)
for (Common::StringArray::const_iterator file = filenames.begin(); file != filenames.end(); ++file) {
- // Obtain the last 3 digits of the filename, since they correspond to the save slot
- int slotNum = atoi(file->c_str() + file->size() - 3);
-
- // Rename every slot greater than the deleted slot,
- if (slotNum > slot) {
- saveFileMan->renameSavefile(file->c_str(), filename.c_str());
- filename = ZVision::ZVision::getSavegameFilename(target, ++slot);
- }
+ // Obtain the last 3 digits of the filename, since they correspond to the save slot
+ int slotNum = atoi(file->c_str() + file->size() - 3);
+
+ // Rename every slot greater than the deleted slot,
+ if (slotNum > slot) {
+ saveFileMan->renameSavefile(file->c_str(), filename.c_str());
+ filename = Common::String::format("%s.%03u", target, ++slot);
+ }
}
- */
}
SaveStateDescriptor ZVisionMetaEngine::querySaveMetaInfos(const char *target, int slot) const {
- /*
- Common::String filename = ZVision::ZVision::getSavegameFilename(target, slot);
+ Common::String filename = Common::String::format("%s.%03u", target, slot);
Common::InSaveFile *in = g_system->getSavefileManager()->openForLoading(filename.c_str());
if (in) {
- ZVision::ZVision::SaveHeader header;
- ZVision::ZVision::kReadSaveHeaderError error;
+ ZVision::SaveGameHeader header;
- error = ZVision::ZVision::readSaveHeader(in, true, header);
- delete in;
+ // We only use readSaveGameHeader() here, which doesn't need an engine callback
+ ZVision::SaveManager *zvisionSaveMan = new ZVision::SaveManager(NULL);
+ bool successfulRead = zvisionSaveMan->readSaveGameHeader(in, header);
+ delete zvisionSaveMan;
+ delete in;
- if (error == ZVision::ZVision::kRSHENoError) {
- SaveStateDescriptor desc(slot, header.description);
+ if (successfulRead) {
+ SaveStateDescriptor desc(slot, header.saveName);
- desc.setThumbnail(header.thumbnail);
+ // Do not allow save slot 0 (used for auto-saving) to be deleted or
+ // overwritten.
+ desc.setDeletableFlag(slot != 0);
+ desc.setWriteProtectedFlag(slot == 0);
- if (header.version > 0) {
- int day = (header.saveDate >> 24) & 0xFF;
- int month = (header.saveDate >> 16) & 0xFF;
- int year = header.saveDate & 0xFFFF;
+ desc.setThumbnail(header.thumbnail);
- desc.setSaveDate(year, month, day);
+ if (header.version > 0) {
+ int day = header.saveDay;
+ int month = header.saveMonth;
+ int year = header.saveYear;
- int hour = (header.saveTime >> 16) & 0xFF;
- int minutes = (header.saveTime >> 8) & 0xFF;
+ desc.setSaveDate(year, month, day);
- desc.setSaveTime(hour, minutes);
+ int hour = header.saveHour;
+ int minutes = header.saveMinutes;
- desc.setPlayTime(header.playTime * 1000);
- }
+ desc.setSaveTime(hour, minutes);
- return desc;
- }
+ //desc.setPlayTime(header.playTime * 1000);
+ }
+
+ return desc;
+ }
}
- */
return SaveStateDescriptor();
}
#if PLUGIN_ENABLED_DYNAMIC(ZVISION)
- REGISTER_PLUGIN_DYNAMIC(ZVISION, PLUGIN_TYPE_ENGINE, ZVisionMetaEngine);
+REGISTER_PLUGIN_DYNAMIC(ZVISION, PLUGIN_TYPE_ENGINE, ZVisionMetaEngine);
#else
- REGISTER_PLUGIN_STATIC(ZVISION, PLUGIN_TYPE_ENGINE, ZVisionMetaEngine);
+REGISTER_PLUGIN_STATIC(ZVISION, PLUGIN_TYPE_ENGINE, ZVisionMetaEngine);
#endif
diff --git a/engines/zvision/detection.h b/engines/zvision/detection.h
index a788e710b7..f80cac79ec 100644
--- a/engines/zvision/detection.h
+++ b/engines/zvision/detection.h
@@ -25,7 +25,6 @@
#include "engines/advancedDetector.h"
-
namespace ZVision {
enum ZVisionGameId {
diff --git a/engines/zvision/utility/lzss_read_stream.cpp b/engines/zvision/file/lzss_read_stream.cpp
index e094188ef6..6f27eaa765 100644
--- a/engines/zvision/utility/lzss_read_stream.cpp
+++ b/engines/zvision/file/lzss_read_stream.cpp
@@ -22,16 +22,15 @@
#include "common/scummsys.h"
-#include "zvision/utility/lzss_read_stream.h"
-
+#include "zvision/file/lzss_read_stream.h"
namespace ZVision {
LzssReadStream::LzssReadStream(Common::SeekableReadStream *source)
- : _source(source),
- // It's convention to set the starting cursor position to blockSize - 16
- _windowCursor(0x0FEE),
- _eosFlag(false) {
+ : _source(source),
+ // It's convention to set the starting cursor position to blockSize - 16
+ _windowCursor(0x0FEE),
+ _eosFlag(false) {
// Clear the window to null
memset(_window, 0, BLOCK_SIZE);
}
@@ -69,9 +68,9 @@ uint32 LzssReadStream::decompressBytes(byte *destination, uint32 numberOfBytes)
}
uint16 length = (high & 0xF) + 2;
- uint16 offset = low | ((high & 0xF0)<<4);
+ uint16 offset = low | ((high & 0xF0) << 4);
- for(int j = 0; j <= length; ++j) {
+ for (int j = 0; j <= length; ++j) {
byte temp = _window[(offset + j) & 0xFFF];
_window[_windowCursor] = temp;
destination[destinationCursor++] = temp;
diff --git a/engines/zvision/utility/lzss_read_stream.h b/engines/zvision/file/lzss_read_stream.h
index b51cf3905f..1420621f13 100644
--- a/engines/zvision/utility/lzss_read_stream.h
+++ b/engines/zvision/file/lzss_read_stream.h
@@ -26,7 +26,6 @@
#include "common/stream.h"
#include "common/array.h"
-
namespace Common {
class SeekableReadStream;
}
@@ -64,7 +63,7 @@ private:
*
* @param numberOfBytes How many bytes to decompress. This is a count of source bytes, not destination bytes
*/
- uint32 decompressBytes(byte* destination, uint32 numberOfBytes);
+ uint32 decompressBytes(byte *destination, uint32 numberOfBytes);
};
}
diff --git a/engines/zvision/file/save_manager.cpp b/engines/zvision/file/save_manager.cpp
new file mode 100644
index 0000000000..042fafd38e
--- /dev/null
+++ b/engines/zvision/file/save_manager.cpp
@@ -0,0 +1,290 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public 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 "zvision/zvision.h"
+#include "zvision/file/save_manager.h"
+#include "zvision/scripting/script_manager.h"
+#include "zvision/graphics/render_manager.h"
+
+#include "common/system.h"
+#include "common/translation.h"
+
+#include "graphics/surface.h"
+#include "graphics/thumbnail.h"
+
+#include "gui/message.h"
+#include "gui/saveload.h"
+
+namespace ZVision {
+
+const uint32 SaveManager::SAVEGAME_ID = MKTAG('Z', 'E', 'N', 'G');
+
+bool SaveManager::scummVMSaveLoadDialog(bool isSave) {
+ GUI::SaveLoadChooser *dialog;
+ Common::String desc;
+ int slot;
+
+ if (isSave) {
+ dialog = new GUI::SaveLoadChooser(_("Save game:"), _("Save"), true);
+
+ slot = dialog->runModalWithCurrentTarget();
+ desc = dialog->getResultString();
+
+ if (desc.empty()) {
+ // create our own description for the saved game, the user didnt enter it
+ desc = dialog->createDefaultSaveDescription(slot);
+ }
+
+ if (desc.size() > 28)
+ desc = Common::String(desc.c_str(), 28);
+ } else {
+ dialog = new GUI::SaveLoadChooser(_("Restore game:"), _("Restore"), false);
+ slot = dialog->runModalWithCurrentTarget();
+ }
+
+ delete dialog;
+
+ if (slot < 0)
+ return false;
+
+ if (isSave) {
+ saveGame(slot, desc);
+ return true;
+ } else {
+ Common::ErrorCode result = loadGame(slot).getCode();
+ return (result == Common::kNoError);
+ }
+}
+
+void SaveManager::saveGame(uint slot, const Common::String &saveName) {
+ Common::SaveFileManager *saveFileManager = g_system->getSavefileManager();
+ Common::OutSaveFile *file = saveFileManager->openForSaving(_engine->generateSaveFileName(slot));
+
+ writeSaveGameHeader(file, saveName);
+
+ _engine->getScriptManager()->serialize(file);
+
+ file->finalize();
+ delete file;
+
+ _lastSaveTime = g_system->getMillis();
+}
+
+void SaveManager::saveGame(uint slot, const Common::String &saveName, Common::MemoryWriteStreamDynamic *stream) {
+ Common::SaveFileManager *saveFileManager = g_system->getSavefileManager();
+ Common::OutSaveFile *file = saveFileManager->openForSaving(_engine->generateSaveFileName(slot));
+
+ writeSaveGameHeader(file, saveName);
+
+ file->write(stream->getData(), stream->size());
+
+ file->finalize();
+ delete file;
+
+ _lastSaveTime = g_system->getMillis();
+}
+
+void SaveManager::saveGameBuffered(uint slot, const Common::String &saveName) {
+ if (_tempSave) {
+ saveGame(slot, saveName, _tempSave);
+ flushSaveBuffer();
+ }
+}
+
+void SaveManager::autoSave() {
+ saveGame(0, "Auto save");
+}
+
+void SaveManager::writeSaveGameHeader(Common::OutSaveFile *file, const Common::String &saveName) {
+ file->writeUint32BE(SAVEGAME_ID);
+
+ // Write version
+ file->writeByte(SAVE_VERSION);
+
+ // Write savegame name
+ file->writeString(saveName);
+ file->writeByte(0);
+
+ // Create a thumbnail and save it
+ Graphics::saveThumbnail(*file);
+
+ // Write out the save date/time
+ TimeDate td;
+ g_system->getTimeAndDate(td);
+ file->writeSint16LE(td.tm_year + 1900);
+ file->writeSint16LE(td.tm_mon + 1);
+ file->writeSint16LE(td.tm_mday);
+ file->writeSint16LE(td.tm_hour);
+ file->writeSint16LE(td.tm_min);
+}
+
+Common::Error SaveManager::loadGame(uint slot) {
+ Common::SeekableReadStream *saveFile = getSlotFile(slot);
+ if (saveFile == 0) {
+ return Common::kPathDoesNotExist;
+ }
+
+ // Read the header
+ SaveGameHeader header;
+ if (!readSaveGameHeader(saveFile, header)) {
+ return Common::kUnknownError;
+ }
+
+ ScriptManager *scriptManager = _engine->getScriptManager();
+ // Update the state table values
+ scriptManager->deserialize(saveFile);
+
+ delete saveFile;
+ if (header.thumbnail)
+ delete header.thumbnail;
+
+ return Common::kNoError;
+}
+
+Common::Error SaveManager::loadGame(const Common::String &saveName) {
+ Common::File *saveFile = _engine->getSearchManager()->openFile(saveName);
+ if (saveFile == NULL) {
+ saveFile = new Common::File;
+ if (!saveFile->open(saveName)) {
+ delete saveFile;
+ return Common::kPathDoesNotExist;
+ }
+ }
+
+ // Read the header
+ SaveGameHeader header;
+ if (!readSaveGameHeader(saveFile, header)) {
+ return Common::kUnknownError;
+ }
+
+ ScriptManager *scriptManager = _engine->getScriptManager();
+ // Update the state table values
+ scriptManager->deserialize(saveFile);
+
+ delete saveFile;
+ if (header.thumbnail)
+ delete header.thumbnail;
+
+ return Common::kNoError;
+}
+
+bool SaveManager::readSaveGameHeader(Common::InSaveFile *in, SaveGameHeader &header) {
+ uint32 tag = in->readUint32BE();
+ // Check if it's original savegame than fill header structure
+ if (tag == MKTAG('Z', 'N', 'S', 'G')) {
+ header.saveYear = 0;
+ header.saveMonth = 0;
+ header.saveDay = 0;
+ header.saveHour = 0;
+ header.saveMinutes = 0;
+ header.saveName = "Original Save";
+ header.thumbnail = NULL;
+ header.version = SAVE_ORIGINAL;
+ in->seek(-4, SEEK_CUR);
+ return true;
+ }
+ if (tag != SAVEGAME_ID) {
+ warning("File is not a ZVision save file. Aborting load");
+ return false;
+ }
+
+ // Read in the version
+ header.version = in->readByte();
+
+ // Check that the save version isn't newer than this binary
+ if (header.version > SAVE_VERSION) {
+ uint tempVersion = header.version;
+ GUI::MessageDialog dialog(
+ Common::String::format(
+ "This save file uses version %u, but this engine only "
+ "supports up to version %d. You will need an updated version "
+ "of the engine to use this save file.", tempVersion, SAVE_VERSION
+ ),
+ "OK");
+ dialog.runModal();
+ }
+
+ // Read in the save name
+ 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.saveYear = in->readSint16LE();
+ header.saveMonth = in->readSint16LE();
+ header.saveDay = in->readSint16LE();
+ header.saveHour = in->readSint16LE();
+ header.saveMinutes = in->readSint16LE();
+
+ return true;
+}
+
+Common::SeekableReadStream *SaveManager::getSlotFile(uint slot) {
+ Common::SeekableReadStream *saveFile = g_system->getSavefileManager()->openForLoading(_engine->generateSaveFileName(slot));
+ if (saveFile == NULL) {
+ // Try to load standard save file
+ Common::String filename;
+ if (_engine->getGameId() == GID_GRANDINQUISITOR)
+ filename = Common::String::format("inqsav%u.sav", slot);
+ else if (_engine->getGameId() == GID_NEMESIS)
+ filename = Common::String::format("nemsav%u.sav", slot);
+
+ saveFile = _engine->getSearchManager()->openFile(filename);
+ if (saveFile == NULL) {
+ Common::File *tmpFile = new Common::File;
+ if (!tmpFile->open(filename)) {
+ delete tmpFile;
+ } else {
+ saveFile = tmpFile;
+ }
+ }
+
+ }
+
+ return saveFile;
+}
+
+void SaveManager::prepareSaveBuffer() {
+ if (_tempSave)
+ delete _tempSave;
+
+ _tempSave = new Common::MemoryWriteStreamDynamic;
+
+ _engine->getScriptManager()->serialize(_tempSave);
+}
+
+void SaveManager::flushSaveBuffer() {
+ if (_tempSave)
+ delete _tempSave;
+
+ _tempSave = NULL;
+}
+
+} // End of namespace ZVision
diff --git a/engines/zvision/core/save_manager.h b/engines/zvision/file/save_manager.h
index 43fb0c0faf..fc8db67566 100644
--- a/engines/zvision/core/save_manager.h
+++ b/engines/zvision/file/save_manager.h
@@ -24,6 +24,7 @@
#define ZVISION_SAVE_MANAGER_H
#include "common/savefile.h"
+#include "common/memstream.h"
namespace Common {
class String;
@@ -47,21 +48,31 @@ struct SaveGameHeader {
class SaveManager {
public:
- SaveManager(ZVision *engine) : _engine(engine) {}
+ SaveManager(ZVision *engine) : _engine(engine), _tempSave(NULL), _lastSaveTime(0) {}
+ ~SaveManager() {
+ flushSaveBuffer();
+ }
+
+ uint32 getLastSaveTime() const {
+ return _lastSaveTime;
+ }
private:
ZVision *_engine;
+ uint32 _lastSaveTime;
static const uint32 SAVEGAME_ID;
enum {
+ SAVE_ORIGINAL = 0,
SAVE_VERSION = 1
};
+ Common::MemoryWriteStreamDynamic *_tempSave;
+
public:
/**
* Called every room change. Saves the state of the room just before
- * we switched rooms. Uses ZVision::generateAutoSaveFileName() to
- * create the save file name.
+ * the room changes.
*/
void autoSave();
/**
@@ -73,6 +84,8 @@ public:
* @param saveName The internal name for this save. This is NOT the name of the actual save file.
*/
void saveGame(uint slot, const Common::String &saveName);
+ void saveGame(uint slot, const Common::String &saveName, Common::MemoryWriteStreamDynamic *stream);
+ void saveGameBuffered(uint slot, const Common::String &saveName);
/**
* Loads the state data from the save file that slot references. Uses
* ZVision::generateSaveFileName(slot) to get the save file name.
@@ -80,10 +93,16 @@ public:
* @param slot The save slot to load. Must be [1, 20]
*/
Common::Error loadGame(uint slot);
+ Common::Error loadGame(const Common::String &saveName);
+
+ Common::SeekableReadStream *getSlotFile(uint slot);
+ bool readSaveGameHeader(Common::SeekableReadStream *in, SaveGameHeader &header);
+ void prepareSaveBuffer();
+ void flushSaveBuffer();
+ bool scummVMSaveLoadDialog(bool isSave);
private:
- void writeSaveGameData(Common::OutSaveFile *file);
- bool readSaveGameHeader(Common::InSaveFile *in, SaveGameHeader &header);
+ void writeSaveGameHeader(Common::OutSaveFile *file, const Common::String &saveName);
};
} // End of namespace ZVision
diff --git a/engines/zvision/file/search_manager.cpp b/engines/zvision/file/search_manager.cpp
new file mode 100644
index 0000000000..ec250ff648
--- /dev/null
+++ b/engines/zvision/file/search_manager.cpp
@@ -0,0 +1,290 @@
+/* ScummVM - Graphic Adventure Engine
+*
+* ScummVM is the legal property of its developers, whose names
+* are too numerous to list here. Please refer to the COPYRIGHT
+* file distributed with this source distribution.
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License
+* as published by the Free Software Foundation; either version 2
+* of the License, or (at your option) any later version.
+
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+
+* You should have received a copy of the GNU General Public 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/fs.h"
+#include "common/stream.h"
+
+#include "zvision/file/search_manager.h"
+#include "zvision/file/zfs_archive.h"
+
+namespace ZVision {
+
+SearchManager::SearchManager(const Common::String &rootPath, int depth) {
+ _root = rootPath;
+ if (_root[_root.size() - 1] == '\\' || _root[_root.size() - 1] == '/')
+ _root.deleteLastChar();
+
+ Common::FSNode fsNode(_root);
+
+ listDirRecursive(_dirList, fsNode, depth);
+
+ for (Common::List<Common::String>::iterator it = _dirList.begin(); it != _dirList.end();) {
+ if ((*it).hasSuffix("\\") || (*it).hasSuffix("/"))
+ (*it).deleteLastChar();
+
+ if (it->size() == _root.size())
+ it = _dirList.erase(it);
+ else if (it->size() > _root.size()) {
+ *it = Common::String(it->c_str() + _root.size() + 1);
+ it++;
+ } else
+ it++;
+ }
+}
+
+SearchManager::~SearchManager() {
+ Common::List<Common::Archive *>::iterator it = _archList.begin();
+ while (it != _archList.end()) {
+ delete *it;
+ it++;
+ }
+
+ _archList.clear();
+}
+
+void SearchManager::addPatch(const Common::String &src, const Common::String &dst) {
+ Common::String lowerCaseName = dst;
+ lowerCaseName.toLowercase();
+
+ SearchManager::MatchList::iterator it = _files.find(lowerCaseName);
+
+ if (it != _files.end()) {
+ lowerCaseName = src;
+ lowerCaseName.toLowercase();
+ _files[lowerCaseName] = it->_value;
+ }
+}
+
+void SearchManager::addFile(const Common::String &name, Common::Archive *arch) {
+ bool addArch = true;
+ Common::List<Common::Archive *>::iterator it = _archList.begin();
+ while (it != _archList.end()) {
+ if (*it == arch) {
+ addArch = false;
+ break;
+ }
+ it++;
+ }
+ if (addArch)
+ _archList.push_back(arch);
+
+ Common::String lowerCaseName = name;
+ lowerCaseName.toLowercase();
+
+ SearchManager::Node nod;
+ nod.name = lowerCaseName;
+ nod.arch = arch;
+
+ SearchManager::MatchList::iterator fit = _files.find(lowerCaseName);
+
+ if (fit == _files.end()) {
+ _files[lowerCaseName] = nod;
+ } else {
+ Common::SeekableReadStream *stream = fit->_value.arch->createReadStreamForMember(fit->_value.name);
+ if (stream) {
+ if (stream->size() < 10)
+ fit->_value.arch = arch;
+ delete stream;
+ } else {
+ _files[lowerCaseName] = nod;
+ }
+ }
+}
+
+Common::File *SearchManager::openFile(const Common::String &name) {
+ Common::String lowerCaseName = name;
+ lowerCaseName.toLowercase();
+
+ SearchManager::MatchList::iterator fit = _files.find(lowerCaseName);
+
+ if (fit != _files.end()) {
+ Common::File *tmp = new Common::File();
+ tmp->open(fit->_value.name, *fit->_value.arch);
+ return tmp;
+ }
+ return NULL;
+}
+
+bool SearchManager::openFile(Common::File &file, const Common::String &name) {
+ Common::String lowerCaseName = name;
+ lowerCaseName.toLowercase();
+
+ SearchManager::MatchList::iterator fit = _files.find(lowerCaseName);
+
+ if (fit != _files.end())
+ return file.open(fit->_value.name, *fit->_value.arch);
+ return false;
+}
+
+bool SearchManager::hasFile(const Common::String &name) {
+ Common::String lowerCaseName = name;
+ lowerCaseName.toLowercase();
+
+ SearchManager::MatchList::iterator fit = _files.find(lowerCaseName);
+
+ if (fit != _files.end())
+ return true;
+ return false;
+}
+
+void SearchManager::loadZix(const Common::String &name) {
+ Common::File file;
+ file.open(name);
+
+ Common::String line;
+
+ while (!file.eos()) {
+ line = file.readLine();
+ if (line.matchString("----------*", true))
+ break;
+ }
+
+ if (file.eos())
+ return;
+
+ Common::Array<Common::Archive *> archives;
+
+ while (!file.eos()) {
+ line = file.readLine();
+ line.trim();
+ if (line.matchString("----------*", true))
+ break;
+ else if (line.matchString("DIR:*", true) || line.matchString("CD0:*", true) || line.matchString("CD1:*", true)) {
+ Common::String path(line.c_str() + 5);
+ // Check if INQUIS.ZIX refers to the ZGI folder, and check the game
+ // root folder instead
+ if (path.hasPrefix("zgi\\"))
+ path = Common::String(path.c_str() + 4);
+
+ Common::Archive *arc;
+ char tempPath[128];
+ strcpy(tempPath, path.c_str());
+ for (uint i = 0; i < path.size(); i++)
+ if (tempPath[i] == '\\')
+ tempPath[i] = '/';
+
+ path = Common::String(tempPath);
+ if (path.size() && path[0] == '.')
+ path.deleteChar(0);
+ if (path.size() && path[0] == '/')
+ path.deleteChar(0);
+
+ if (path.matchString("*.zfs", true))
+ arc = new ZfsArchive(path);
+ else {
+ if (path.size()) {
+ if (path[path.size() - 1] == '\\' || path[path.size() - 1] == '/')
+ path.deleteLastChar();
+ if (path.size())
+ for (Common::List<Common::String>::iterator it = _dirList.begin(); it != _dirList.end(); ++it)
+ if (path.equalsIgnoreCase(*it)) {
+ path = *it;
+ break;
+ }
+ }
+
+ path = Common::String::format("%s/%s", _root.c_str(), path.c_str());
+
+ arc = new Common::FSDirectory(path);
+ }
+ archives.push_back(arc);
+ }
+ }
+
+ if (file.eos())
+ return;
+
+ while (!file.eos()) {
+ line = file.readLine();
+ line.trim();
+ uint dr = 0;
+ char buf[32];
+ if (sscanf(line.c_str(), "%u %s", &dr, buf) == 2) {
+ if (dr <= archives.size() && dr > 0) {
+ addFile(Common::String(buf), archives[dr - 1]);
+ }
+ }
+ }
+}
+
+void SearchManager::addDir(const Common::String &name) {
+ Common::String path;
+ for (Common::List<Common::String>::iterator it = _dirList.begin(); it != _dirList.end(); ++it)
+ if (name.equalsIgnoreCase(*it)) {
+ path = *it;
+ break;
+ }
+
+ if (path.size() == 0)
+ return;
+
+ path = Common::String::format("%s/%s", _root.c_str(), path.c_str());
+
+ Common::FSDirectory *dir = new Common::FSDirectory(path);
+
+ Common::ArchiveMemberList list;
+ dir->listMatchingMembers(list, "*.zfs");
+
+ for (Common::ArchiveMemberList::iterator iter = list.begin(); iter != list.end(); ++iter) {
+ Common::String flname = (*iter)->getName();
+
+ ZfsArchive *zfs = new ZfsArchive(Common::String::format("%s/%s", name.c_str(), flname.c_str()));
+
+ Common::ArchiveMemberList zfslist;
+ zfs->listMembers(zfslist);
+
+ for (Common::ArchiveMemberList::iterator ziter = zfslist.begin(); ziter != zfslist.end(); ++ziter) {
+ Common::String zfsFileName = (*ziter)->getName();
+ addFile(zfsFileName, zfs);
+ }
+ }
+
+ list.clear();
+ dir->listMembers(list);
+
+ for (Common::ArchiveMemberList::iterator iter = list.begin(); iter != list.end(); ++iter) {
+ Common::String flname = (*iter)->getName();
+ addFile(flname, dir);
+ }
+}
+
+void SearchManager::listDirRecursive(Common::List<Common::String> &_list, const Common::FSNode &fsNode, int depth) {
+ Common::FSList fsList;
+ if (fsNode.getChildren(fsList)) {
+
+ _list.push_back(fsNode.getPath());
+
+ if (depth > 1)
+ for (Common::FSList::const_iterator it = fsList.begin(); it != fsList.end(); ++it)
+ listDirRecursive(_list, *it, depth - 1);
+ }
+}
+
+void SearchManager::listMembersWithExtension(MatchList &fileList, Common::String extension) {
+ for (SearchManager::MatchList::iterator it = _files.begin(); it != _files.end(); ++it) {
+ if (it->_key.hasSuffix(extension))
+ fileList[it->_key] = it->_value;
+ }
+}
+
+} // End of namespace ZVision
diff --git a/engines/zvision/file/search_manager.h b/engines/zvision/file/search_manager.h
new file mode 100644
index 0000000000..b9ed02ec13
--- /dev/null
+++ b/engines/zvision/file/search_manager.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 ZVISION_SEARCH_MANAGER_H
+#define ZVISION_SEARCH_MANAGER_H
+
+#include "common/str.h"
+#include "common/hash-str.h"
+#include "common/hashmap.h"
+#include "common/archive.h"
+#include "common/file.h"
+#include "common/list.h"
+
+namespace ZVision {
+
+class SearchManager {
+public:
+ SearchManager(const Common::String &rootPath, int depth);
+ ~SearchManager();
+
+ void addFile(const Common::String &name, Common::Archive *arch);
+ void addDir(const Common::String &name);
+ void addPatch(const Common::String &src, const Common::String &dst);
+
+ Common::File *openFile(const Common::String &name);
+ bool openFile(Common::File &file, const Common::String &name);
+ bool hasFile(const Common::String &name);
+
+ void loadZix(const Common::String &name);
+
+ struct Node {
+ Common::String name;
+ Common::Archive *arch;
+ };
+
+ typedef Common::HashMap<Common::String, Node, Common::IgnoreCase_Hash, Common::IgnoreCase_EqualTo> MatchList;
+
+ void listMembersWithExtension(MatchList &fileList, Common::String extension);
+
+private:
+
+ void listDirRecursive(Common::List<Common::String> &dirList, const Common::FSNode &fsNode, int depth);
+
+ Common::List<Common::String> _dirList;
+ Common::List<Common::Archive *> _archList;
+ Common::String _root;
+ MatchList _files;
+};
+
+}
+
+#endif // ZVISION_SEARCH_MANAGER_H
diff --git a/engines/zvision/archives/zfs_archive.cpp b/engines/zvision/file/zfs_archive.cpp
index f5fa6fc9bf..3a385cd8fd 100644
--- a/engines/zvision/archives/zfs_archive.cpp
+++ b/engines/zvision/file/zfs_archive.cpp
@@ -21,17 +21,17 @@
*/
#include "common/scummsys.h"
-
-#include "zvision/archives/zfs_archive.h"
-
#include "common/memstream.h"
#include "common/debug.h"
#include "common/file.h"
+#include "zvision/file/zfs_archive.h"
+
namespace ZVision {
ZfsArchive::ZfsArchive(const Common::String &fileName) : _fileName(fileName) {
Common::File zfsFile;
+ memset(&_header, 0, sizeof(_header));
if (!zfsFile.open(_fileName)) {
warning("ZFSArchive::ZFSArchive(): Could not find the archive file");
@@ -52,7 +52,7 @@ ZfsArchive::ZfsArchive(const Common::String &fileName, Common::SeekableReadStrea
ZfsArchive::~ZfsArchive() {
debug(1, "ZfsArchive Destructor Called");
ZfsEntryHeaderMap::iterator it = _entryHeaders.begin();
- for ( ; it != _entryHeaders.end(); ++it) {
+ for (; it != _entryHeaders.end(); ++it) {
delete it->_value;
}
}
@@ -79,7 +79,7 @@ void ZfsArchive::readHeaders(Common::SeekableReadStream *stream) {
// Read in each entry header
for (uint32 i = 0; i < _header.filesPerBlock; ++i) {
ZfsEntryHeader entryHeader;
-
+
entryHeader.name = readEntryName(stream);
entryHeader.offset = stream->readUint32LE();
entryHeader.id = stream->readUint32LE();
@@ -138,10 +138,10 @@ Common::SeekableReadStream *ZfsArchive::createReadStreamForMember(const Common::
zfsArchive.seek(entryHeader->offset);
// This *HAS* to be malloc (not new[]) because MemoryReadStream uses free() to free the memory
- byte* buffer = (byte *)malloc(entryHeader->size);
+ byte *buffer = (byte *)malloc(entryHeader->size);
zfsArchive.read(buffer, entryHeader->size);
// Decrypt the data in place
- if (_header.xorKey != 0)
+ if (_header.xorKey[0] + _header.xorKey[1] + _header.xorKey[2] + _header.xorKey[3] != 0)
unXor(buffer, entryHeader->size, _header.xorKey);
return new Common::MemoryReadStream(buffer, entryHeader->size, DisposeAfterUse::YES);
@@ -153,5 +153,3 @@ void ZfsArchive::unXor(byte *buffer, uint32 length, const byte *xorKey) const {
}
} // End of namespace ZVision
-
-
diff --git a/engines/zvision/archives/zfs_archive.h b/engines/zvision/file/zfs_archive.h
index 3509cfee26..fe0221416d 100644
--- a/engines/zvision/archives/zfs_archive.h
+++ b/engines/zvision/file/zfs_archive.h
@@ -27,7 +27,6 @@
#include "common/hashmap.h"
#include "common/hash-str.h"
-
namespace Common {
class String;
}
@@ -40,7 +39,7 @@ struct ZfsHeader {
uint32 maxNameLength;
uint32 filesPerBlock;
uint32 fileCount;
- byte xorKey[4];
+ uint8 xorKey[4];
uint32 fileSectionOffset;
};
@@ -53,7 +52,7 @@ struct ZfsEntryHeader {
uint32 unknown;
};
-typedef Common::HashMap<Common::String, ZfsEntryHeader*, Common::IgnoreCase_Hash, Common::IgnoreCase_EqualTo> ZfsEntryHeaderMap;
+typedef Common::HashMap<Common::String, ZfsEntryHeader *, Common::IgnoreCase_Hash, Common::IgnoreCase_EqualTo> ZfsEntryHeaderMap;
class ZfsArchive : public Common::Archive {
public:
diff --git a/engines/zvision/fonts/truetype_font.cpp b/engines/zvision/fonts/truetype_font.cpp
deleted file mode 100644
index ba4d72bde8..0000000000
--- a/engines/zvision/fonts/truetype_font.cpp
+++ /dev/null
@@ -1,113 +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 "common/scummsys.h"
-
-#include "zvision/fonts/truetype_font.h"
-
-#include "zvision/zvision.h"
-#include "zvision/graphics/render_manager.h"
-
-#include "common/debug.h"
-#include "common/file.h"
-#include "common/system.h"
-
-#include "graphics/font.h"
-#include "graphics/fonts/ttf.h"
-#include "graphics/surface.h"
-
-
-namespace ZVision {
-
-TruetypeFont::TruetypeFont(ZVision *engine, int32 fontHeight)
- : _fontHeight(fontHeight),
- _font(0),
- _lineHeight(0) {
-}
-
-TruetypeFont::~TruetypeFont(void) {
- delete _font;
-}
-
-bool TruetypeFont::loadFile(const Common::String &filename) {
- Common::File file;
-
- bool fileOpened = false;
- if (!Common::File::exists(filename)) {
- debug("TTF font file %s was not found. Reverting to arial.ttf", filename.c_str());
- fileOpened = file.open("arial.ttf");
- } else {
- fileOpened = file.open(filename);
- }
-
- if (!fileOpened) {
- debug("TTF file could not be opened");
- return false;
- }
-
- _font = Graphics::loadTTFFont(file, _fontHeight);
- _lineHeight = _font->getFontHeight();
-
- return true;
-}
-
-Graphics::Surface *TruetypeFont::drawTextToSurface(const Common::String &text, uint16 textColor, int maxWidth, int maxHeight, Graphics::TextAlign align, bool wrap) {
- if (text.equals("")) {
- return nullptr;
- }
-
- Graphics::Surface *surface = new Graphics::Surface();
-
- if (!wrap) {
- int width = MIN(_font->getStringWidth(text), maxWidth);
- surface->create(width, _lineHeight, Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0));
- // TODO: Add better alpha support by getting the pixels from the backbuffer.
- // However doing that requires some kind of caching system so future text doesn't try to use this text as it's alpha background.
- surface->fillRect(Common::Rect(0, 0, surface->w, surface->h), 0);
-
- _font->drawString(surface, text, 0, 0, maxWidth, textColor, align);
- return surface;
- }
-
- Common::Array<Common::String> lines;
- _font->wordWrapText(text, maxWidth, lines);
-
- while (maxHeight > 0 && (int)lines.size() * _lineHeight > maxHeight) {
- lines.pop_back();
- }
- if (lines.size() == 0) {
- return nullptr;
- }
-
- surface->create(maxWidth, lines.size() * _lineHeight, Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0));
- surface->fillRect(Common::Rect(0, 0, surface->w, surface->h), 0);
-
- int heightOffset = 0;
- for (Common::Array<Common::String>::iterator it = lines.begin(); it != lines.end(); it++) {
- _font->drawString(surface, *it, 0, 0 + heightOffset, maxWidth, textColor, align);
- heightOffset += _lineHeight;
- }
-
- return surface;
-}
-
-} // End of namespace ZVision
diff --git a/engines/zvision/graphics/cursors/cursor.cpp b/engines/zvision/graphics/cursors/cursor.cpp
new file mode 100644
index 0000000000..f32c68645d
--- /dev/null
+++ b/engines/zvision/graphics/cursors/cursor.cpp
@@ -0,0 +1,96 @@
+/* ScummVM - Graphic Adventure Engine
+*
+* ScummVM is the legal property of its developers, whose names
+* are too numerous to list here. Please refer to the COPYRIGHT
+* file distributed with this source distribution.
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License
+* as published by the Free Software Foundation; either version 2
+* of the License, or (at your option) any later version.
+
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+*
+*/
+
+#include "common/scummsys.h"
+
+#include "zvision/graphics/cursors/cursor.h"
+
+#include "common/str.h"
+#include "common/file.h"
+
+namespace ZVision {
+
+ZorkCursor::ZorkCursor()
+ : _width(0),
+ _height(0),
+ _hotspotX(0),
+ _hotspotY(0) {
+}
+
+ZorkCursor::ZorkCursor(ZVision *engine, const Common::String &fileName)
+ : _width(0),
+ _height(0),
+ _hotspotX(0),
+ _hotspotY(0) {
+ Common::File file;
+ if (!engine->getSearchManager()->openFile(file, fileName))
+ return;
+
+ uint32 magic = file.readUint32BE();
+ if (magic != MKTAG('Z', 'C', 'R', '1')) {
+ warning("%s is not a Zork Cursor file", fileName.c_str());
+ return;
+ }
+
+ _hotspotX = file.readUint16LE();
+ _hotspotY = file.readUint16LE();
+ _width = file.readUint16LE();
+ _height = file.readUint16LE();
+
+ uint dataSize = _width * _height * sizeof(uint16);
+ _surface.create(_width, _height, engine->_resourcePixelFormat);
+ uint32 bytesRead = file.read(_surface.getPixels(), dataSize);
+ assert(bytesRead == dataSize);
+
+#ifndef SCUMM_LITTLE_ENDIAN
+ int16 *buffer = (int16 *)_surface.getPixels();
+ for (uint32 i = 0; i < dataSize / 2; ++i)
+ buffer[i] = FROM_LE_16(buffer[i]);
+#endif
+}
+
+ZorkCursor::ZorkCursor(const ZorkCursor &other) {
+ _width = other._width;
+ _height = other._height;
+ _hotspotX = other._hotspotX;
+ _hotspotY = other._hotspotY;
+
+ _surface.copyFrom(other._surface);
+}
+
+ZorkCursor &ZorkCursor::operator=(const ZorkCursor &other) {
+ _width = other._width;
+ _height = other._height;
+ _hotspotX = other._hotspotX;
+ _hotspotY = other._hotspotY;
+
+ _surface.free();
+ _surface.copyFrom(other._surface);
+
+ return *this;
+}
+
+ZorkCursor::~ZorkCursor() {
+ _surface.free();
+}
+
+} // End of namespace ZVision
diff --git a/engines/zvision/cursors/cursor.h b/engines/zvision/graphics/cursors/cursor.h
index be9fae64da..6e0083520a 100644
--- a/engines/zvision/cursors/cursor.h
+++ b/engines/zvision/graphics/cursors/cursor.h
@@ -24,7 +24,7 @@
#define ZVISION_CURSOR_H
#include "graphics/surface.h"
-
+#include "zvision/zvision.h"
namespace Common {
class String;
@@ -39,7 +39,7 @@ namespace ZVision {
class ZorkCursor {
public:
ZorkCursor();
- ZorkCursor(const Common::String &fileName);
+ ZorkCursor(ZVision *engine, const Common::String &fileName);
ZorkCursor(const ZorkCursor &other);
~ZorkCursor();
@@ -53,12 +53,24 @@ private:
public:
ZorkCursor &operator=(const ZorkCursor &other);
- uint16 getWidth() const { return _width; }
- uint16 getHeight() const { return _height; }
- uint16 getHotspotX() const { return _hotspotX; }
- uint16 getHotspotY() const { return _hotspotY; }
- byte getKeyColor() const { return 0; }
- const byte *getSurface() const { return (const byte *)_surface.getPixels(); }
+ uint16 getWidth() const {
+ return _width;
+ }
+ uint16 getHeight() const {
+ return _height;
+ }
+ uint16 getHotspotX() const {
+ return _hotspotX;
+ }
+ uint16 getHotspotY() const {
+ return _hotspotY;
+ }
+ byte getKeyColor() const {
+ return 0;
+ }
+ const byte *getSurface() const {
+ return (const byte *)_surface.getPixels();
+ }
};
} // End of namespace ZVision
diff --git a/engines/zvision/graphics/cursors/cursor_manager.cpp b/engines/zvision/graphics/cursors/cursor_manager.cpp
new file mode 100644
index 0000000000..c364426bad
--- /dev/null
+++ b/engines/zvision/graphics/cursors/cursor_manager.cpp
@@ -0,0 +1,154 @@
+/* ScummVM - Graphic Adventure Engine
+*
+* ScummVM is the legal property of its developers, whose names
+* are too numerous to list here. Please refer to the COPYRIGHT
+* file distributed with this source distribution.
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License
+* as published by the Free Software Foundation; either version 2
+* of the License, or (at your option) any later version.
+
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+
+* You should have received a copy of the GNU General Public 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 "zvision/graphics/cursors/cursor_manager.h"
+
+#include "zvision/zvision.h"
+
+#include "common/system.h"
+
+#include "graphics/pixelformat.h"
+#include "graphics/cursorman.h"
+
+namespace ZVision {
+
+const char *CursorManager::_cursorNames[NUM_CURSORS] = { "active", "arrow", "backward", "downarrow", "forward", "handpt", "handpu", "hdown", "hleft",
+ "hright", "hup", "idle", "leftarrow", "rightarrow", "suggest_surround", "suggest_tilt", "turnaround", "zuparrow"
+ };
+
+const char *CursorManager::_zgiCursorFileNames[NUM_CURSORS] = { "g0gbc011.zcr", "g0gac001.zcr", "g0gac021.zcr", "g0gac031.zcr", "g0gac041.zcr", "g0gac051.zcr", "g0gac061.zcr", "g0gac071.zcr", "g0gac081.zcr",
+ "g0gac091.zcr", "g0gac101.zcr", "g0gac011.zcr", "g0gac111.zcr", "g0gac121.zcr", "g0gac131.zcr", "g0gac141.zcr", "g0gac151.zcr", "g0gac161.zcr"
+ };
+
+const char *CursorManager::_zNemCursorFileNames[NUM_CURSORS] = { "00act", "arrow", "back", "down", "forw", "handpt", "handpu", "hdown", "hleft",
+ "hright", "hup", "00idle", "left", "right", "ssurr", "stilt", "turn", "up"
+ };
+
+CursorManager::CursorManager(ZVision *engine, const Graphics::PixelFormat pixelFormat)
+ : _engine(engine),
+ _pixelFormat(pixelFormat),
+ _cursorIsPushed(false),
+ _item(0),
+ _lastitem(0),
+ _currentCursor(CursorIndex_Idle) {
+ for (int i = 0; i < NUM_CURSORS; i++) {
+ if (_engine->getGameId() == GID_NEMESIS) {
+ Common::String name;
+ name = Common::String::format("%sa.zcr", _zNemCursorFileNames[i]);
+ _cursors[i][0] = ZorkCursor(_engine, name); // Up cursor
+ name = Common::String::format("%sb.zcr", _zNemCursorFileNames[i]);
+ _cursors[i][1] = ZorkCursor(_engine, name); // Down cursor
+ } else if (_engine->getGameId() == GID_GRANDINQUISITOR) {
+ _cursors[i][0] = ZorkCursor(_engine, _zgiCursorFileNames[i]); // Up cursor
+ char buffer[25];
+ memset(buffer, 0, 25);
+ strncpy(buffer, _zgiCursorFileNames[i], 24);
+ buffer[3] += 2;
+ _cursors[i][1] = ZorkCursor(_engine, buffer); // Down cursor
+ }
+ }
+}
+
+void CursorManager::setItemID(int id) {
+ if (id != _item) {
+ if (id) {
+ Common::String file;
+ if (_engine->getGameId() == GID_NEMESIS) {
+ file = Common::String::format("%2.2d%s%c.zcr", id, "idle", 'a');
+ _cursors[NUM_CURSORS][0] = ZorkCursor(_engine, file);
+ file = Common::String::format("%2.2d%s%c.zcr", id, "idle", 'b');
+ _cursors[NUM_CURSORS][1] = ZorkCursor(_engine, file);
+ file = Common::String::format("%2.2d%s%c.zcr", id, "act", 'a');
+ _cursors[NUM_CURSORS + 1][0] = ZorkCursor(_engine, file);
+ file = Common::String::format("%2.2d%s%c.zcr", id, "act", 'b');
+ _cursors[NUM_CURSORS + 1][0] = ZorkCursor(_engine, file);
+ } else if (_engine->getGameId() == GID_GRANDINQUISITOR) {
+ file = Common::String::format("g0b%cc%2.2x1.zcr", 'a' , id);
+ _cursors[NUM_CURSORS][0] = ZorkCursor(_engine, file);
+ file = Common::String::format("g0b%cc%2.2x1.zcr", 'c' , id);
+ _cursors[NUM_CURSORS][1] = ZorkCursor(_engine, file);
+ file = Common::String::format("g0b%cc%2.2x1.zcr", 'b' , id);
+ _cursors[NUM_CURSORS + 1][0] = ZorkCursor(_engine, file);
+ file = Common::String::format("g0b%cc%2.2x1.zcr", 'd' , id);
+ _cursors[NUM_CURSORS + 1][1] = ZorkCursor(_engine, file);
+ } else
+ return;
+ }
+ _item = id;
+ changeCursor(CursorIndex_Idle);
+ }
+}
+
+void CursorManager::initialize() {
+ changeCursor(_cursors[CursorIndex_Idle][_cursorIsPushed]);
+ showMouse(true);
+}
+
+void CursorManager::changeCursor(const ZorkCursor &cursor) {
+ CursorMan.replaceCursor(cursor.getSurface(), cursor.getWidth(), cursor.getHeight(), cursor.getHotspotX(), cursor.getHotspotY(), cursor.getKeyColor(), false, &_pixelFormat);
+}
+
+void CursorManager::cursorDown(bool pushed) {
+ if (_cursorIsPushed == pushed)
+ return;
+
+ _cursorIsPushed = pushed;
+
+ changeCursor(_cursors[_currentCursor][_cursorIsPushed]);
+}
+
+void CursorManager::changeCursor(int id) {
+ int _id = id;
+
+ if (_item &&
+ (_id == CursorIndex_Active ||
+ _id == CursorIndex_Idle ||
+ _id == CursorIndex_HandPu)) {
+
+ if (_id == CursorIndex_Idle)
+ _id = CursorIndex_ItemIdle;
+ else
+ _id = CursorIndex_ItemAct;
+ }
+
+ if (_currentCursor != _id ||
+ ((_id == CursorIndex_ItemAct || _id == CursorIndex_ItemIdle) && _lastitem != _item)) {
+ _currentCursor = _id;
+ _lastitem = _item;
+ changeCursor(_cursors[_currentCursor][_cursorIsPushed]);
+ }
+}
+
+int CursorManager::getCursorId(const Common::String &name) {
+ for (int i = 0; i < NUM_CURSORS; i++)
+ if (name.equals(_cursorNames[i]))
+ return i;
+ return CursorIndex_Idle;
+}
+
+void CursorManager::showMouse(bool vis) {
+ CursorMan.showMouse(vis);
+}
+
+} // End of namespace ZVision
diff --git a/engines/zvision/cursors/cursor_manager.h b/engines/zvision/graphics/cursors/cursor_manager.h
index 0576517f58..35c605baf8 100644
--- a/engines/zvision/cursors/cursor_manager.h
+++ b/engines/zvision/graphics/cursors/cursor_manager.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.
@@ -23,11 +23,10 @@
#ifndef ZVISION_CURSOR_MANAGER_H
#define ZVISION_CURSOR_MANAGER_H
-#include "zvision/cursors/cursor.h"
+#include "zvision/graphics/cursors/cursor.h"
#include "common/str.h"
-
namespace Graphics {
struct PixelFormat;
}
@@ -37,6 +36,21 @@ namespace ZVision {
class ZVision;
/**
+ * Mostly usable cursors
+ */
+enum CursorIndex {
+ CursorIndex_Active = 0,
+ CursorIndex_DownArr = 3,
+ CursorIndex_HandPu = 6,
+ CursorIndex_Idle = 11,
+ CursorIndex_Left = 12,
+ CursorIndex_Right = 13,
+ CursorIndex_UpArr = 17,
+ CursorIndex_ItemIdle = 18,
+ CursorIndex_ItemAct = 19
+};
+
+/**
* Class to manage cursor changes. The actual changes have to be done
* through CursorMan. Otherwise the cursor will disappear after GMM
* or debug console.
@@ -44,20 +58,20 @@ class ZVision;
*/
class CursorManager {
public:
- CursorManager(ZVision *engine, const Graphics::PixelFormat *pixelFormat);
+ CursorManager(ZVision *engine, const Graphics::PixelFormat pixelFormat);
private:
- enum {
- NUM_CURSORS = 18,
- // WARNING: The index 11 is hardcoded. If you change the order of _cursorNames/_zgiCursorFileNames/_zNemCursorFileNames, you HAVE to change the index accordingly
- IDLE_CURSOR_INDEX = 11
- };
+ static const int NUM_CURSORS = 18;
+
+ // 18 default cursors in up/down states, +2 for items idle/act cursors
+ ZorkCursor _cursors[NUM_CURSORS + 2][2];
ZVision *_engine;
- const Graphics::PixelFormat *_pixelFormat;
- ZorkCursor _idleCursor;
- Common::String _currentCursor;
+ const Graphics::PixelFormat _pixelFormat;
bool _cursorIsPushed;
+ int _item;
+ int _lastitem;
+ int _currentCursor;
static const char *_cursorNames[];
static const char *_zgiCursorFileNames[];
@@ -68,19 +82,30 @@ public:
void initialize();
/**
- * Parses a cursor name into a cursor file then creates and shows that cursor.
- * It will use the current _isCursorPushed state to choose the correct cursor
+ * Change cursor to specified cursor ID. If item setted to not 0 and cursor id idle/acrive/handpu change cursor to item.
+ *
+ * @param id Wanted cursor id.
+ */
+
+ void changeCursor(int id);
+
+ /**
+ * Return founded id for string contains cursor name
*
- * @param cursorName The name of a cursor. This *HAS* to correspond to one of the entries in _cursorNames[]
+ * @param name Cursor name
+ * @return Id of cursor or idle cursor id if not found
*/
- void changeCursor(const Common::String &cursorName);
+
+ int getCursorId(const Common::String &name);
+
/**
- * Parses a cursor name into a cursor file then creates and shows that cursor.
+ * Load cursor for item by id, and try to change cursor to item cursor if it's not 0
*
- * @param cursorName The name of a cursor. This *HAS* to correspond to one of the entries in _cursorNames[]
- * @param pushed Should the cursor be pushed (true) or not pushed (false) (Another way to say it: down or up)
+ * @param id Item id or 0 for no item cursor
*/
- void changeCursor(const Common::String &cursorName, bool pushed);
+
+ void setItemID(int id);
+
/**
* Change the cursor to a certain push state. If the cursor is already in the specified push state, nothing will happen.
*
@@ -88,17 +113,12 @@ public:
*/
void cursorDown(bool pushed);
- /** Set the cursor to 'Left Arrow'. It will retain the current _isCursorPushed state */
- void setLeftCursor();
- /** Set the cursor to 'Right Arrow'. It will retain the current _isCursorPushed state */
- void setRightCursor();
- /** Set the cursor to 'Up Arrow'. It will retain the current _isCursorPushed state */
- void setUpCursor();
- /** Set the cursor to 'Down Arrow'. It will retain the current _isCursorPushed state */
- void setDownCursor();
-
- /** Set the cursor to 'Idle'. It will retain the current _isCursorPushed state */
- void revertToIdle();
+ /**
+ * Show or hide mouse cursor.
+ *
+ * @param vis Should the cursor be showed (true) or hide (false)
+ */
+ void showMouse(bool vis);
private:
/**
diff --git a/engines/zvision/graphics/effects/fog.cpp b/engines/zvision/graphics/effects/fog.cpp
new file mode 100644
index 0000000000..32a01915d3
--- /dev/null
+++ b/engines/zvision/graphics/effects/fog.cpp
@@ -0,0 +1,173 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public 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 "zvision/graphics/effects/fog.h"
+
+#include "zvision/zvision.h"
+#include "zvision/graphics/render_manager.h"
+#include "zvision/scripting/script_manager.h"
+
+namespace ZVision {
+
+FogFx::FogFx(ZVision *engine, uint32 key, Common::Rect region, bool ported, EffectMap *Map, const Common::String &clouds):
+ GraphicsEffect(engine, key, region, ported) {
+
+ _map = Map;
+
+ _r = 0;
+ _g = 0;
+ _b = 0;
+
+ _pos = 0;
+
+ if (_engine->getSearchManager()->hasFile(clouds))
+ _engine->getRenderManager()->readImageToSurface(clouds, _fog);
+ else
+ _engine->getRenderManager()->readImageToSurface("cloud.tga", _fog);
+
+ _mp.resize(_fog.h);
+ for (int16 i = 0; i < _fog.h; i++) {
+ _mp[i].resize(_fog.w);
+ for (int16 j = 0; j < _fog.w; j++)
+ _mp[i][j] = true;
+ }
+
+ for (uint8 i = 0; i < 32; i++)
+ _colorMap[i] = 0;
+}
+
+FogFx::~FogFx() {
+ if (_map)
+ delete _map;
+
+ for (uint16 i = 0; i < _mp.size(); i++)
+ _mp[i].clear();
+ _mp.clear();
+}
+
+const Graphics::Surface *FogFx::draw(const Graphics::Surface &srcSubRect) {
+ _surface.copyFrom(srcSubRect);
+ EffectMap::iterator it = _map->begin();
+
+ uint32 cnt = 0;
+
+ for (uint16 j = 0; j < _surface.h; j++) {
+ uint16 *lineBuf = (uint16 *)_surface.getBasePtr(0, j);
+
+ for (uint16 i = 0; i < _surface.w; i++) {
+ if (it->inEffect) {
+ // Not 100% equivalent, but looks nice and not buggy
+ uint8 sr, sg, sb;
+ _engine->_resourcePixelFormat.colorToRGB(lineBuf[i], sr, sg, sb);
+ uint16 fogColor = *(uint16 *)_fog.getBasePtr((i + _pos) % _fog.w, j);
+ uint8 dr, dg, db;
+ _engine->_resourcePixelFormat.colorToRGB(_colorMap[fogColor & 0x1F], dr, dg, db);
+ uint16 fr = dr + sr;
+ if (fr > 255)
+ fr = 255;
+ uint16 fg = dg + sg;
+ if (fg > 255)
+ fg = 255;
+ uint16 fb = db + sb;
+ if (fb > 255)
+ fb = 255;
+ lineBuf[i] = _engine->_resourcePixelFormat.RGBToColor(fr, fg, fb);
+ }
+ cnt++;
+ if (cnt >= it->count) {
+ it++;
+ cnt = 0;
+ }
+ if (it == _map->end())
+ break;
+ }
+ if (it == _map->end())
+ break;
+ }
+
+ return &_surface;
+}
+
+void FogFx::update() {
+ _pos += _engine->getScriptManager()->getStateValue(StateKey_EF9_Speed);
+ _pos %= _fog.w;
+
+ uint8 dr = _engine->getScriptManager()->getStateValue(StateKey_EF9_R);
+ uint8 dg = _engine->getScriptManager()->getStateValue(StateKey_EF9_G);
+ uint8 db = _engine->getScriptManager()->getStateValue(StateKey_EF9_B);
+ dr = CLIP((int)dr, 0, 31);
+ dg = CLIP((int)dg, 0, 31);
+ db = CLIP((int)db, 0, 31);
+
+ if (dr != _r || dg != _g || db != _b) {
+ if (_r > dr)
+ _r--;
+ else if (_r < dr)
+ _r++;
+
+ if (_g > dg)
+ _g--;
+ else if (_g < dg)
+ _g++;
+
+ if (_b > db)
+ _b--;
+ else if (_b < db)
+ _b++;
+
+ // Not 100% equivalent, but looks nice and not buggy
+
+ _colorMap[31] = _engine->_resourcePixelFormat.RGBToColor(_r << 3, _g << 3, _b << 3);
+
+ for (uint8 i = 0; i < 31; i++) {
+ float perc = (float)i / 31.0;
+ uint8 cr = (float)_r * perc;
+ uint8 cg = (float)_g * perc;
+ uint8 cb = (float)_b * perc;
+ _colorMap[i] = _engine->_resourcePixelFormat.RGBToColor(cr << 3, cg << 3, cb << 3);
+ }
+ }
+
+ for (uint16 j = 0; j < _fog.h; j++) {
+ uint16 *pix = (uint16 *)_fog.getBasePtr(0, j);
+
+ for (uint16 i = 0; i < _fog.w; i++) {
+ if (_mp[j][i]) {
+ if ((pix[i] & 0x1F) == 0x1F) {
+ pix[i]--;
+ _mp[j][i] = false;
+ } else
+ pix[i]++;
+ } else {
+ if ((pix[i] & 0x1F) == 0) {
+ pix[i]++;
+ _mp[j][i] = true;
+ } else
+ pix[i]--;
+ }
+ }
+ }
+}
+
+} // End of namespace ZVision
diff --git a/engines/zvision/graphics/effects/fog.h b/engines/zvision/graphics/effects/fog.h
new file mode 100644
index 0000000000..498347609e
--- /dev/null
+++ b/engines/zvision/graphics/effects/fog.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 ZVISION_FOG_H
+#define ZVISION_FOG_H
+
+#include "zvision/graphics/graphics_effect.h"
+
+namespace ZVision {
+
+class ZVision;
+
+// Used by Zork: Nemesis for the mixing chamber gas effect in the gas puzzle (location tt5e, when the blinds are down)
+class FogFx : public GraphicsEffect {
+public:
+
+ FogFx(ZVision *engine, uint32 key, Common::Rect region, bool ported, EffectMap *Map, const Common::String &clouds);
+ ~FogFx();
+
+ const Graphics::Surface *draw(const Graphics::Surface &srcSubRect);
+
+ void update();
+
+private:
+ EffectMap *_map;
+ Graphics::Surface _fog;
+ uint8 _r, _g, _b;
+ int32 _pos;
+ Common::Array< Common::Array< bool > > _mp;
+ uint16 _colorMap[32];
+};
+} // End of namespace ZVision
+
+#endif // ZVISION_FOG_H
diff --git a/engines/zvision/graphics/effects/light.cpp b/engines/zvision/graphics/effects/light.cpp
new file mode 100644
index 0000000000..39341687f8
--- /dev/null
+++ b/engines/zvision/graphics/effects/light.cpp
@@ -0,0 +1,109 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public 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 "zvision/graphics/effects/light.h"
+
+#include "zvision/zvision.h"
+#include "zvision/graphics/render_manager.h"
+
+namespace ZVision {
+
+LightFx::LightFx(ZVision *engine, uint32 key, Common::Rect region, bool ported, EffectMap *Map, int8 delta, int8 minD, int8 maxD):
+ GraphicsEffect(engine, key, region, ported) {
+ _map = Map;
+ _delta = delta;
+ _up = true;
+ _pos = 0;
+
+ _minD = minD;
+ if (_minD < -delta)
+ _minD = -delta;
+
+ _maxD = maxD;
+ if (_maxD > delta)
+ _maxD = delta;
+}
+
+LightFx::~LightFx() {
+ if (_map)
+ delete _map;
+}
+
+const Graphics::Surface *LightFx::draw(const Graphics::Surface &srcSubRect) {
+ _surface.copyFrom(srcSubRect);
+ EffectMap::iterator it = _map->begin();
+ uint32 cnt = 0;
+
+ uint32 dcolor = 0;
+
+ if (_pos < 0) {
+ uint8 cc = ((-_pos) & 0x1F) << 3;
+ dcolor = _engine->_resourcePixelFormat.RGBToColor(cc, cc, cc);
+ } else {
+ uint8 cc = (_pos & 0x1F) << 3;
+ dcolor = _engine->_resourcePixelFormat.RGBToColor(cc, cc, cc);
+ }
+
+ for (uint16 j = 0; j < _surface.h; j++) {
+ uint16 *lineBuf = (uint16 *)_surface.getBasePtr(0, j);
+
+ for (uint16 i = 0; i < _surface.w; i++) {
+ if (it->inEffect) {
+ if (_pos < 0) {
+ lineBuf[i] -= dcolor;
+ } else {
+ lineBuf[i] += dcolor;
+ }
+ }
+ cnt++;
+ if (cnt >= it->count) {
+ it++;
+ cnt = 0;
+ }
+ if (it == _map->end())
+ break;
+ }
+ if (it == _map->end())
+ break;
+ }
+
+ return &_surface;
+}
+
+void LightFx::update() {
+ if (_up)
+ _pos++;
+ else
+ _pos--;
+
+ if (_pos <= _minD) {
+ _up = !_up;
+ _pos = _minD;
+ } else if (_pos >= _maxD) {
+ _up = !_up;
+ _pos = _maxD;
+ }
+}
+
+} // End of namespace ZVision
diff --git a/engines/zvision/graphics/effects/light.h b/engines/zvision/graphics/effects/light.h
new file mode 100644
index 0000000000..cd73a585ec
--- /dev/null
+++ b/engines/zvision/graphics/effects/light.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 LIGHTFX_H_INCLUDED
+#define LIGHTFX_H_INCLUDED
+
+#include "zvision/graphics/graphics_effect.h"
+
+namespace ZVision {
+
+class ZVision;
+
+class LightFx : public GraphicsEffect {
+public:
+
+ LightFx(ZVision *engine, uint32 key, Common::Rect region, bool ported, EffectMap *Map, int8 delta, int8 minD = -127, int8 maxD = 127);
+ ~LightFx();
+
+ const Graphics::Surface *draw(const Graphics::Surface &srcSubRect);
+
+ void update();
+
+private:
+ EffectMap *_map;
+ int32 _delta;
+ bool _up;
+ int32 _pos;
+
+ int8 _minD;
+ int8 _maxD;
+};
+} // End of namespace ZVision
+
+#endif // LIGHTFX_H_INCLUDED
diff --git a/engines/zvision/graphics/effects/wave.cpp b/engines/zvision/graphics/effects/wave.cpp
new file mode 100644
index 0000000000..cec631611b
--- /dev/null
+++ b/engines/zvision/graphics/effects/wave.cpp
@@ -0,0 +1,145 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "common/scummsys.h"
+
+#include "zvision/graphics/effects/wave.h"
+
+#include "zvision/zvision.h"
+#include "zvision/graphics/render_manager.h"
+
+namespace ZVision {
+
+WaveFx::WaveFx(ZVision *engine, uint32 key, Common::Rect region, bool ported, int16 frames, int16 centerX, int16 centerY, float ampl, float waveln, float spd):
+ GraphicsEffect(engine, key, region, ported) {
+
+ _frame = 0;
+ _frameCount = frames;
+
+ _ampls.resize(_frameCount);
+ _halfWidth = _region.width() / 2;
+ _halfHeight = _region.height() / 2;
+
+ int32 frmsize = _halfWidth * _halfHeight;
+
+ float phase = 0;
+
+ int16 quarterWidth = _halfWidth / 2;
+ int16 quarterHeight = _halfHeight / 2;
+
+ for (int16 i = 0; i < _frameCount; i++) {
+ _ampls[i].resize(frmsize);
+
+ for (int16 y = 0; y < _halfHeight; y++)
+ for (int16 x = 0; x < _halfWidth; x++) {
+ int16 dx = (x - quarterWidth);
+ int16 dy = (y - quarterHeight);
+
+ _ampls[i][x + y * _halfWidth] = ampl * sin(sqrt(dx * dx / (float)centerX + dy * dy / (float)centerY) / (-waveln * 3.1415926) + phase);
+ }
+ phase += spd;
+ }
+}
+
+WaveFx::~WaveFx() {
+ for (uint16 i = 0; i < _ampls.size(); i++)
+ _ampls[i].clear();
+ _ampls.clear();
+}
+
+const Graphics::Surface *WaveFx::draw(const Graphics::Surface &srcSubRect) {
+ for (int16 y = 0; y < _halfHeight; y++) {
+ uint16 *abc = (uint16 *)_surface.getBasePtr(0, y);
+ uint16 *abc2 = (uint16 *)_surface.getBasePtr(0, _halfHeight + y);
+ uint16 *abc3 = (uint16 *)_surface.getBasePtr(_halfWidth, y);
+ uint16 *abc4 = (uint16 *)_surface.getBasePtr(_halfWidth, _halfHeight + y);
+
+ for (int16 x = 0; x < _halfWidth; x++) {
+ int8 amnt = _ampls[_frame][x + _halfWidth * y];
+
+ int16 nX = x + amnt;
+ int16 nY = y + amnt;
+
+ if (nX < 0)
+ nX = 0;
+ if (nX >= _region.width())
+ nX = _region.width() - 1;
+ if (nY < 0)
+ nY = 0;
+ if (nY >= _region.height())
+ nY = _region.height() - 1;
+ *abc = *(const uint16 *)srcSubRect.getBasePtr(nX, nY);
+
+ nX = x + amnt + _halfWidth;
+ nY = y + amnt;
+
+ if (nX < 0)
+ nX = 0;
+ if (nX >= _region.width())
+ nX = _region.width() - 1;
+ if (nY < 0)
+ nY = 0;
+ if (nY >= _region.height())
+ nY = _region.height() - 1;
+ *abc3 = *(const uint16 *)srcSubRect.getBasePtr(nX, nY);
+
+ nX = x + amnt;
+ nY = y + amnt + _halfHeight;
+
+ if (nX < 0)
+ nX = 0;
+ if (nX >= _region.width())
+ nX = _region.width() - 1;
+ if (nY < 0)
+ nY = 0;
+ if (nY >= _region.height())
+ nY = _region.height() - 1;
+ *abc2 = *(const uint16 *)srcSubRect.getBasePtr(nX, nY);
+
+ nX = x + amnt + _halfWidth;
+ nY = y + amnt + _halfHeight;
+
+ if (nX < 0)
+ nX = 0;
+ if (nX >= _region.width())
+ nX = _region.width() - 1;
+ if (nY < 0)
+ nY = 0;
+ if (nY >= _region.height())
+ nY = _region.height() - 1;
+ *abc4 = *(const uint16 *)srcSubRect.getBasePtr(nX, nY);
+
+ abc++;
+ abc2++;
+ abc3++;
+ abc4++;
+ }
+ }
+
+ return &_surface;
+}
+
+void WaveFx::update() {
+ _frame = (_frame + 1) % _frameCount;
+}
+
+} // End of namespace ZVision
diff --git a/engines/zvision/graphics/effects/wave.h b/engines/zvision/graphics/effects/wave.h
new file mode 100644
index 0000000000..8e912372d7
--- /dev/null
+++ b/engines/zvision/graphics/effects/wave.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 WAVEFX_H_INCLUDED
+#define WAVEFX_H_INCLUDED
+
+#include "common/array.h"
+#include "zvision/graphics/graphics_effect.h"
+
+namespace ZVision {
+
+class ZVision;
+
+class WaveFx : public GraphicsEffect {
+public:
+
+ WaveFx(ZVision *engine, uint32 key, Common::Rect region, bool ported, int16 frames, int16 centerX, int16 centerY, float ampl, float waveln, float spd);
+ ~WaveFx();
+
+ const Graphics::Surface *draw(const Graphics::Surface &srcSubRect);
+
+ void update();
+
+private:
+ int16 _frame;
+ int16 _frameCount;
+ int16 _halfWidth, _halfHeight;
+ Common::Array< Common::Array< int8 > > _ampls;
+};
+} // End of namespace ZVision
+
+#endif // WAVEFX_H_INCLUDED
diff --git a/engines/zvision/graphics/graphics_effect.h b/engines/zvision/graphics/graphics_effect.h
new file mode 100644
index 0000000000..bfa266b11d
--- /dev/null
+++ b/engines/zvision/graphics/graphics_effect.h
@@ -0,0 +1,83 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef GRAPHICS_EFFECT_H_INCLUDED
+#define GRAPHICS_EFFECT_H_INCLUDED
+
+#include "common/rect.h"
+#include "common/list.h"
+#include "graphics/surface.h"
+
+#include "zvision/zvision.h"
+
+namespace ZVision {
+
+class ZVision;
+
+class GraphicsEffect {
+public:
+
+ GraphicsEffect(ZVision *engine, uint32 key, Common::Rect region, bool ported) : _engine(engine), _key(key), _region(region), _ported(ported) {
+ _surface.create(_region.width(), _region.height(), _engine->_resourcePixelFormat);
+ }
+ virtual ~GraphicsEffect() {}
+
+ uint32 getKey() {
+ return _key;
+ }
+
+ Common::Rect getRegion() {
+ return _region;
+ }
+
+ bool isPort() {
+ return _ported;
+ }
+
+ virtual const Graphics::Surface *draw(const Graphics::Surface &srcSubRect) {
+ return &_surface;
+ }
+
+ virtual void update() {}
+
+protected:
+ ZVision *_engine;
+ uint32 _key;
+ Common::Rect _region;
+ bool _ported;
+ Graphics::Surface _surface;
+
+// Static member functions
+public:
+
+};
+
+struct EffectMapUnit {
+ uint32 count;
+ bool inEffect;
+};
+
+typedef Common::List<EffectMapUnit> EffectMap;
+
+} // End of namespace ZVision
+
+#endif // GRAPHICS_EFFECT_H_INCLUDED
diff --git a/engines/zvision/graphics/render_manager.cpp b/engines/zvision/graphics/render_manager.cpp
index aed30ea12c..a1cc8ac53c 100644
--- a/engines/zvision/graphics/render_manager.cpp
+++ b/engines/zvision/graphics/render_manager.cpp
@@ -1,30 +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.
- *
- */
+*
+* ScummVM is the legal property of its developers, whose names
+* are too numerous to list here. Please refer to the COPYRIGHT
+* file distributed with this source distribution.
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License
+* as published by the Free Software Foundation; either version 2
+* of the License, or (at your option) any later version.
+
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+
+* You should have received a copy of the GNU General Public 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 "zvision/zvision.h"
#include "zvision/graphics/render_manager.h"
+#include "zvision/scripting/script_manager.h"
+#include "zvision/text/text.h"
-#include "zvision/utility/lzss_read_stream.h"
+#include "zvision/file/lzss_read_stream.h"
#include "common/file.h"
#include "common/system.h"
@@ -34,200 +37,156 @@
#include "image/tga.h"
-
namespace ZVision {
-RenderManager::RenderManager(OSystem *system, uint32 windowWidth, uint32 windowHeight, const Common::Rect workingWindow, const Graphics::PixelFormat pixelFormat)
- : _system(system),
- _workingWidth(workingWindow.width()),
- _workingHeight(workingWindow.height()),
- _screenCenterX(_workingWidth / 2),
- _screenCenterY(_workingHeight / 2),
- _workingWindow(workingWindow),
- _pixelFormat(pixelFormat),
- _backgroundWidth(0),
- _backgroundHeight(0),
- _backgroundInverseVelocity(0),
- _backgroundOffset(0, 0),
- _accumulatedVelocityMilliseconds(0),
- _renderTable(_workingWidth, _workingHeight) {
-
- _workingWindowBuffer.create(_workingWidth, _workingHeight, _pixelFormat);
- _backBuffer.create(windowWidth, windowHeight, pixelFormat);
+RenderManager::RenderManager(ZVision *engine, uint32 windowWidth, uint32 windowHeight, const Common::Rect workingWindow, const Graphics::PixelFormat pixelFormat, bool doubleFPS)
+ : _engine(engine),
+ _system(engine->_system),
+ _workingWidth(workingWindow.width()),
+ _workingHeight(workingWindow.height()),
+ _screenCenterX(_workingWidth / 2),
+ _screenCenterY(_workingHeight / 2),
+ _workingWindow(workingWindow),
+ _pixelFormat(pixelFormat),
+ _backgroundWidth(0),
+ _backgroundHeight(0),
+ _backgroundOffset(0),
+ _renderTable(_workingWidth, _workingHeight),
+ _doubleFPS(doubleFPS) {
+
+ _backgroundSurface.create(_workingWidth, _workingHeight, _pixelFormat);
+ _effectSurface.create(_workingWidth, _workingHeight, _pixelFormat);
+ _warpedSceneSurface.create(_workingWidth, _workingHeight, _pixelFormat);
+ _menuSurface.create(windowWidth, workingWindow.top, _pixelFormat);
+ _subtitleSurface.create(windowWidth, windowHeight - workingWindow.bottom, _pixelFormat);
+
+ _menuArea = Common::Rect(0, 0, windowWidth, workingWindow.top);
+ _subtitleArea = Common::Rect(0, workingWindow.bottom, windowWidth, windowHeight);
+
+ _subid = 0;
}
RenderManager::~RenderManager() {
- _workingWindowBuffer.free();
- _currentBackground.free();
- _backBuffer.free();
-
- for (AlphaEntryMap::iterator iter = _alphaDataEntries.begin(); iter != _alphaDataEntries.end(); ++iter) {
- iter->_value.data->free();
- delete iter->_value.data;
- }
-}
-
-void RenderManager::update(uint deltaTimeInMillis) {
- // An inverse velocity of 0 would be infinitely fast, so we'll let 0 mean no velocity.
- if (_backgroundInverseVelocity != 0) {
- _accumulatedVelocityMilliseconds += deltaTimeInMillis;
-
- uint absVelocity = uint(abs(_backgroundInverseVelocity));
-
- int numberOfSteps = 0;
- while (_accumulatedVelocityMilliseconds >= absVelocity) {
- _accumulatedVelocityMilliseconds -= absVelocity;
- numberOfSteps++;
- }
-
- // Choose the direction of movement using the sign of the velocity
- moveBackground(_backgroundInverseVelocity < 0 ? -numberOfSteps : numberOfSteps);
- }
+ _currentBackgroundImage.free();
+ _backgroundSurface.free();
+ _effectSurface.free();
+ _warpedSceneSurface.free();
+ _menuSurface.free();
+ _subtitleSurface.free();
}
-void RenderManager::renderBackbufferToScreen() {
- if (!_workingWindowDirtyRect.isEmpty()) {
- RenderTable::RenderState state = _renderTable.getRenderState();
- if (state == RenderTable::PANORAMA || state == RenderTable::TILT) {
- _renderTable.mutateImage((uint16 *)_workingWindowBuffer.getPixels(), (uint16 *)_backBuffer.getBasePtr(_workingWindow.left + _workingWindowDirtyRect.left, _workingWindow.top + _workingWindowDirtyRect.top), _backBuffer.w, _workingWindowDirtyRect);
- } else {
- _backBuffer.copyRectToSurface(_workingWindowBuffer.getBasePtr(_workingWindowDirtyRect.left, _workingWindowDirtyRect.top), _workingWindowBuffer.pitch, _workingWindow.left + _workingWindowDirtyRect.left, _workingWindow.top + _workingWindowDirtyRect.top, _workingWindowDirtyRect.width(), _workingWindowDirtyRect.height());
- }
-
- // Translate the working window dirty rect to screen coords
- _workingWindowDirtyRect.translate(_workingWindow.left, _workingWindow.top);
- // Then extend the backbuffer dirty rect to contain it
- if (_backBufferDirtyRect.isEmpty()) {
- _backBufferDirtyRect = _workingWindowDirtyRect;
- } else {
- _backBufferDirtyRect.extend(_workingWindowDirtyRect);
- }
-
- // Clear the dirty rect
- _workingWindowDirtyRect = Common::Rect();
- }
+void RenderManager::renderSceneToScreen() {
+ Graphics::Surface *out = &_warpedSceneSurface;
+ Graphics::Surface *in = &_backgroundSurface;
+ Common::Rect outWndDirtyRect;
- // TODO: Add menu rendering
+ // If we have graphical effects, we apply them using a temporary buffer
+ if (!_effects.empty()) {
+ bool copied = false;
+ Common::Rect windowRect(_workingWidth, _workingHeight);
- // Render alpha entries
- processAlphaEntries();
+ for (EffectsList::iterator it = _effects.begin(); it != _effects.end(); it++) {
+ Common::Rect rect = (*it)->getRegion();
+ Common::Rect screenSpaceLocation = rect;
- if (!_backBufferDirtyRect.isEmpty()) {
- _system->copyRectToScreen(_backBuffer.getBasePtr(_backBufferDirtyRect.left, _backBufferDirtyRect.top), _backBuffer.pitch, _backBufferDirtyRect.left, _backBufferDirtyRect.top, _backBufferDirtyRect.width(), _backBufferDirtyRect.height());
- _backBufferDirtyRect = Common::Rect();
- }
-}
-
-void RenderManager::processAlphaEntries() {
- // TODO: Add dirty rectangling support. AKA only draw an entry if the _backbufferDirtyRect intersects/contains the entry Rect
-
- for (AlphaEntryMap::iterator iter = _alphaDataEntries.begin(); iter != _alphaDataEntries.end(); ++iter) {
- uint32 destOffset = 0;
- uint32 sourceOffset = 0;
- uint16 *backbufferPtr = (uint16 *)_backBuffer.getBasePtr(iter->_value.destX + _workingWindow.left, iter->_value.destY + _workingWindow.top);
- uint16 *entryPtr = (uint16 *)iter->_value.data->getPixels();
+ if ((*it)->isPort()) {
+ screenSpaceLocation = transformBackgroundSpaceRectToScreenSpace(screenSpaceLocation);
+ }
- for (int32 y = 0; y < iter->_value.height; ++y) {
- for (int32 x = 0; x < iter->_value.width; ++x) {
- uint16 color = entryPtr[sourceOffset + x];
- if (color != iter->_value.alphaColor) {
- backbufferPtr[destOffset + x] = color;
+ if (windowRect.intersects(screenSpaceLocation)) {
+ if (!copied) {
+ copied = true;
+ _effectSurface.copyFrom(_backgroundSurface);
+ in = &_effectSurface;
+ }
+ const Graphics::Surface *post;
+ if ((*it)->isPort())
+ post = (*it)->draw(_currentBackgroundImage.getSubArea(rect));
+ else
+ post = (*it)->draw(_effectSurface.getSubArea(rect));
+ Common::Rect empty;
+ blitSurfaceToSurface(*post, empty, _effectSurface, screenSpaceLocation.left, screenSpaceLocation.top);
+ screenSpaceLocation.clip(windowRect);
+ if (_backgroundSurfaceDirtyRect .isEmpty()) {
+ _backgroundSurfaceDirtyRect = screenSpaceLocation;
+ } else {
+ _backgroundSurfaceDirtyRect.extend(screenSpaceLocation);
}
}
-
- destOffset += _backBuffer.w;
- sourceOffset += iter->_value.width;
}
+ }
- if (_backBufferDirtyRect.isEmpty()) {
- _backBufferDirtyRect = Common::Rect(iter->_value.destX + _workingWindow.left, iter->_value.destY + _workingWindow.top, iter->_value.destX + _workingWindow.left + iter->_value.width, iter->_value.destY + _workingWindow.top + iter->_value.height);
- } else {
- _backBufferDirtyRect.extend(Common::Rect(iter->_value.destX + _workingWindow.left, iter->_value.destY + _workingWindow.top, iter->_value.destX + _workingWindow.left + iter->_value.width, iter->_value.destY + _workingWindow.top + iter->_value.height));
+ RenderTable::RenderState state = _renderTable.getRenderState();
+ if (state == RenderTable::PANORAMA || state == RenderTable::TILT) {
+ if (!_backgroundSurfaceDirtyRect.isEmpty()) {
+ _renderTable.mutateImage(&_warpedSceneSurface, in);
+ out = &_warpedSceneSurface;
+ outWndDirtyRect = Common::Rect(_workingWidth, _workingHeight);
}
+ } else {
+ out = in;
+ outWndDirtyRect = _backgroundSurfaceDirtyRect;
}
-}
-
-void RenderManager::clearWorkingWindowTo555Color(uint16 color) {
- uint32 workingWindowSize = _workingWidth * _workingHeight;
- byte r, g, b;
- Graphics::PixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0).colorToRGB(color, r, g, b);
- uint16 colorIn565 = _pixelFormat.RGBToColor(r, g, b);
- uint16 *bufferPtr = (uint16 *)_workingWindowBuffer.getPixels();
- for (uint32 i = 0; i < workingWindowSize; ++i) {
- bufferPtr[i] = colorIn565;
+ if (!outWndDirtyRect.isEmpty()) {
+ Common::Rect rect(
+ outWndDirtyRect.left + _workingWindow.left,
+ outWndDirtyRect.top + _workingWindow.top,
+ outWndDirtyRect.left + _workingWindow.left + outWndDirtyRect.width(),
+ outWndDirtyRect.top + _workingWindow.top + outWndDirtyRect.height()
+ );
+ copyToScreen(*out, rect, outWndDirtyRect.left, outWndDirtyRect.top);
}
}
-void RenderManager::renderSubRectToScreen(Graphics::Surface &surface, int16 destinationX, int16 destinationY, bool wrap) {
- int16 subRectX = 0;
- int16 subRectY = 0;
-
- // Take care of negative destinations
- if (destinationX < 0) {
- subRectX = -destinationX;
- destinationX = 0;
- } else if (destinationX >= surface.w) {
- // Take care of extreme positive destinations
- destinationX -= surface.w;
- }
-
- // Take care of negative destinations
- if (destinationY < 0) {
- subRectY = -destinationY;
- destinationY = 0;
- } else if (destinationY >= surface.h) {
- // Take care of extreme positive destinations
- destinationY -= surface.h;
- }
-
- if (wrap) {
- _backgroundWidth = surface.w;
- _backgroundHeight = surface.h;
-
- if (destinationX > 0) {
- // Move destinationX to 0
- subRectX = surface.w - destinationX;
- destinationX = 0;
- }
-
- if (destinationY > 0) {
- // Move destinationY to 0
- subRectY = surface.h - destinationY;
- destinationY = 0;
- }
- }
+void RenderManager::copyToScreen(const Graphics::Surface &surface, Common::Rect &rect, int16 srcLeft, int16 srcTop) {
+ // Convert the surface to RGB565, if needed
+ Graphics::Surface *outSurface = surface.convertTo(_engine->_screenPixelFormat);
+ _system->copyRectToScreen(outSurface->getBasePtr(srcLeft, srcTop),
+ outSurface->pitch,
+ rect.left,
+ rect.top,
+ rect.width(),
+ rect.height());
+ outSurface->free();
+ delete outSurface;
+}
- // Clip subRect to working window bounds
- Common::Rect subRect(subRectX, subRectY, subRectX + _workingWidth, subRectY + _workingHeight);
+void RenderManager::renderImageToBackground(const Common::String &fileName, int16 destX, int16 destY) {
+ Graphics::Surface surface;
+ readImageToSurface(fileName, surface);
- if (!wrap) {
- // Clip to image bounds
- subRect.clip(surface.w, surface.h);
- }
+ blitSurfaceToBkg(surface, destX, destY);
+ surface.free();
+}
- // Check destRect for validity
- if (!subRect.isValidRect() || subRect.isEmpty())
- return;
+void RenderManager::renderImageToBackground(const Common::String &fileName, int16 destX, int16 destY, uint32 keycolor) {
+ Graphics::Surface surface;
+ readImageToSurface(fileName, surface);
- copyRectToWorkingWindow((const uint16 *)surface.getBasePtr(subRect.left, subRect.top), destinationX, destinationY, surface.w, subRect.width(), subRect.height());
+ blitSurfaceToBkg(surface, destX, destY, keycolor);
+ surface.free();
}
-void RenderManager::renderImageToScreen(const Common::String &fileName, int16 destinationX, int16 destinationY, bool wrap) {
+void RenderManager::renderImageToBackground(const Common::String &fileName, int16 destX, int16 destY, int16 keyX, int16 keyY) {
Graphics::Surface surface;
readImageToSurface(fileName, surface);
- renderSubRectToScreen(surface, destinationX, destinationY, wrap);
-}
+ uint16 keycolor = *(uint16 *)surface.getBasePtr(keyX, keyY);
-void RenderManager::renderImageToScreen(Graphics::Surface &surface, int16 destinationX, int16 destinationY, bool wrap) {
- renderSubRectToScreen(surface, destinationX, destinationY, wrap);
+ blitSurfaceToBkg(surface, destX, destY, keycolor);
+ surface.free();
}
void RenderManager::readImageToSurface(const Common::String &fileName, Graphics::Surface &destination) {
+ bool isTransposed = _renderTable.getRenderState() == RenderTable::PANORAMA;
+ readImageToSurface(fileName, destination, isTransposed);
+}
+
+void RenderManager::readImageToSurface(const Common::String &fileName, Graphics::Surface &destination, bool transposed) {
Common::File file;
- if (!file.open(fileName)) {
+ if (!_engine->getSearchManager()->openFile(file, fileName)) {
warning("Could not open file %s", fileName.c_str());
return;
}
@@ -240,10 +199,8 @@ void RenderManager::readImageToSurface(const Common::String &fileName, Graphics:
uint32 imageHeight;
Image::TGADecoder tga;
uint16 *buffer;
- bool isTransposed = _renderTable.getRenderState() == RenderTable::PANORAMA;
// All ZVision images are in RGB 555
- Graphics::PixelFormat pixelFormat555 = Graphics::PixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0);
- destination.format = pixelFormat555;
+ destination.format = _engine->_resourcePixelFormat;
bool isTGZ;
@@ -252,13 +209,17 @@ void RenderManager::readImageToSurface(const Common::String &fileName, Graphics:
isTGZ = true;
// TGZ files have a header and then Bitmap data that is compressed with LZSS
- uint32 decompressedSize = file.readSint32LE();
+ uint32 decompressedSize = file.readSint32LE() / 2;
imageWidth = file.readSint32LE();
imageHeight = file.readSint32LE();
LzssReadStream lzssStream(&file);
buffer = (uint16 *)(new uint16[decompressedSize]);
- lzssStream.read(buffer, decompressedSize);
+ lzssStream.read(buffer, 2 * decompressedSize);
+#ifndef SCUMM_LITTLE_ENDIAN
+ for (uint32 i = 0; i < decompressedSize; ++i)
+ buffer[i] = FROM_LE_16(buffer[i]);
+#endif
} else {
isTGZ = false;
@@ -279,7 +240,7 @@ void RenderManager::readImageToSurface(const Common::String &fileName, Graphics:
}
// Flip the width and height if transposed
- if (isTransposed) {
+ if (transposed) {
uint16 temp = imageHeight;
imageHeight = imageWidth;
imageWidth = temp;
@@ -288,12 +249,12 @@ void RenderManager::readImageToSurface(const Common::String &fileName, Graphics:
// If the destination internal buffer is the same size as what we're copying into it,
// there is no need to free() and re-create
if (imageWidth != destination.w || imageHeight != destination.h) {
- destination.create(imageWidth, imageHeight, pixelFormat555);
+ destination.create(imageWidth, imageHeight, _engine->_resourcePixelFormat);
}
// If transposed, 'un-transpose' the data while copying it to the destination
// Otherwise, just do a simple copy
- if (isTransposed) {
+ if (transposed) {
uint16 *dest = (uint16 *)destination.getPixels();
for (uint32 y = 0; y < imageHeight; ++y) {
@@ -304,7 +265,7 @@ void RenderManager::readImageToSurface(const Common::String &fileName, Graphics:
}
}
} else {
- memcpy(destination.getPixels(), buffer, imageWidth * imageHeight * _pixelFormat.bytesPerPixel);
+ memcpy(destination.getPixels(), buffer, imageWidth * imageHeight * destination.format.bytesPerPixel);
}
// Cleanup
@@ -313,214 +274,902 @@ void RenderManager::readImageToSurface(const Common::String &fileName, Graphics:
} else {
tga.destroy();
}
-
- // Convert in place to RGB 565 from RGB 555
- destination.convertToInPlace(_pixelFormat);
}
-void RenderManager::copyRectToWorkingWindow(const uint16 *buffer, int32 destX, int32 destY, int32 imageWidth, int32 width, int32 height) {
- uint32 destOffset = 0;
- uint32 sourceOffset = 0;
- uint16 *workingWindowBufferPtr = (uint16 *)_workingWindowBuffer.getBasePtr(destX, destY);
+const Common::Point RenderManager::screenSpaceToImageSpace(const Common::Point &point) {
+ if (_workingWindow.contains(point)) {
+ // Convert from screen space to working window space
+ Common::Point newPoint(point - Common::Point(_workingWindow.left, _workingWindow.top));
- for (int32 y = 0; y < height; ++y) {
- for (int32 x = 0; x < width; ++x) {
- workingWindowBufferPtr[destOffset + x] = buffer[sourceOffset + x];
+ RenderTable::RenderState state = _renderTable.getRenderState();
+ if (state == RenderTable::PANORAMA || state == RenderTable::TILT) {
+ newPoint = _renderTable.convertWarpedCoordToFlatCoord(newPoint);
}
- destOffset += _workingWidth;
- sourceOffset += imageWidth;
+ if (state == RenderTable::PANORAMA) {
+ newPoint += (Common::Point(_backgroundOffset - _screenCenterX, 0));
+ } else if (state == RenderTable::TILT) {
+ newPoint += (Common::Point(0, _backgroundOffset - _screenCenterY));
+ }
+
+ if (_backgroundWidth)
+ newPoint.x %= _backgroundWidth;
+ if (_backgroundHeight)
+ newPoint.y %= _backgroundHeight;
+
+ if (newPoint.x < 0)
+ newPoint.x += _backgroundWidth;
+ if (newPoint.y < 0)
+ newPoint.y += _backgroundHeight;
+
+ return newPoint;
+ } else {
+ return Common::Point(0, 0);
}
+}
+
+RenderTable *RenderManager::getRenderTable() {
+ return &_renderTable;
+}
- if (_workingWindowDirtyRect.isEmpty()) {
- _workingWindowDirtyRect = Common::Rect(destX, destY, destX + width, destY + height);
+void RenderManager::setBackgroundImage(const Common::String &fileName) {
+ readImageToSurface(fileName, _currentBackgroundImage);
+ _backgroundWidth = _currentBackgroundImage.w;
+ _backgroundHeight = _currentBackgroundImage.h;
+ _backgroundDirtyRect = Common::Rect(_backgroundWidth, _backgroundHeight);
+}
+
+void RenderManager::setBackgroundPosition(int offset) {
+ RenderTable::RenderState state = _renderTable.getRenderState();
+ if (state == RenderTable::TILT || state == RenderTable::PANORAMA)
+ if (_backgroundOffset != offset)
+ _backgroundDirtyRect = Common::Rect(_backgroundWidth, _backgroundHeight);
+ _backgroundOffset = offset;
+
+ _engine->getScriptManager()->setStateValue(StateKey_ViewPos, offset);
+}
+
+uint32 RenderManager::getCurrentBackgroundOffset() {
+ RenderTable::RenderState state = _renderTable.getRenderState();
+
+ if (state == RenderTable::PANORAMA) {
+ return _backgroundOffset;
+ } else if (state == RenderTable::TILT) {
+ return _backgroundOffset;
} else {
- _workingWindowDirtyRect.extend(Common::Rect(destX, destY, destX + width, destY + height));
+ return 0;
}
+}
+
+Graphics::Surface *RenderManager::tranposeSurface(const Graphics::Surface *surface) {
+ Graphics::Surface *tranposedSurface = new Graphics::Surface();
+ tranposedSurface->create(surface->h, surface->w, surface->format);
- // TODO: Remove this from release. It's here to make sure code that uses this function clips their destinations correctly
- assert(_workingWindowDirtyRect.width() <= _workingWidth && _workingWindowDirtyRect.height() <= _workingHeight);
+ const uint16 *source = (const uint16 *)surface->getPixels();
+ uint16 *dest = (uint16 *)tranposedSurface->getPixels();
+
+ for (uint32 y = 0; y < tranposedSurface->h; ++y) {
+ uint32 columnIndex = y * tranposedSurface->w;
+
+ for (uint32 x = 0; x < tranposedSurface->w; ++x) {
+ dest[columnIndex + x] = source[x * surface->w + y];
+ }
+ }
+
+ return tranposedSurface;
}
-void RenderManager::copyRectToWorkingWindow(const uint16 *buffer, int32 destX, int32 destY, int32 imageWidth, int32 width, int32 height, int16 alphaColor, uint32 idNumber) {
- AlphaDataEntry entry;
- entry.alphaColor = alphaColor;
- entry.data = new Graphics::Surface();
- entry.data->create(width, height, _pixelFormat);
- entry.destX = destX;
- entry.destY = destY;
- entry.width = width;
- entry.height = height;
+void RenderManager::scaleBuffer(const void *src, void *dst, uint32 srcWidth, uint32 srcHeight, byte bytesPerPixel, uint32 dstWidth, uint32 dstHeight) {
+ assert(bytesPerPixel == 1 || bytesPerPixel == 2);
- uint32 sourceOffset = 0;
- uint32 destOffset = 0;
- uint16 *surfacePtr = (uint16 *)entry.data->getPixels();
+ const float xscale = (float)srcWidth / (float)dstWidth;
+ const float yscale = (float)srcHeight / (float)dstHeight;
- for (int32 y = 0; y < height; ++y) {
- for (int32 x = 0; x < width; ++x) {
- surfacePtr[destOffset + x] = buffer[sourceOffset + x];
+ if (bytesPerPixel == 1) {
+ const byte *srcPtr = (const byte *)src;
+ byte *dstPtr = (byte *)dst;
+ for (uint32 y = 0; y < dstHeight; ++y) {
+ for (uint32 x = 0; x < dstWidth; ++x) {
+ *dstPtr = srcPtr[(int)(x * xscale) + (int)(y * yscale) * srcWidth];
+ dstPtr++;
+ }
}
+ } else if (bytesPerPixel == 2) {
+ const uint16 *srcPtr = (const uint16 *)src;
+ uint16 *dstPtr = (uint16 *)dst;
+ for (uint32 y = 0; y < dstHeight; ++y) {
+ for (uint32 x = 0; x < dstWidth; ++x) {
+ *dstPtr = srcPtr[(int)(x * xscale) + (int)(y * yscale) * srcWidth];
+ dstPtr++;
+ }
+ }
+ }
+}
+
+void RenderManager::blitSurfaceToSurface(const Graphics::Surface &src, const Common::Rect &_srcRect , Graphics::Surface &dst, int _x, int _y) {
+ Common::Rect srcRect = _srcRect;
+ if (srcRect.isEmpty())
+ srcRect = Common::Rect(src.w, src.h);
+ srcRect.clip(src.w, src.h);
+ Common::Rect dstRect = Common::Rect(-_x + srcRect.left , -_y + srcRect.top, -_x + srcRect.left + dst.w, -_y + srcRect.top + dst.h);
+ srcRect.clip(dstRect);
+
+ if (srcRect.isEmpty() || !srcRect.isValidRect())
+ return;
+
+ Graphics::Surface *srcAdapted = src.convertTo(dst.format);
+
+ // Copy srcRect from src surface to dst surface
+ const byte *srcBuffer = (const byte *)srcAdapted->getBasePtr(srcRect.left, srcRect.top);
- destOffset += width;
- sourceOffset += imageWidth;
+ int xx = _x;
+ int yy = _y;
+
+ if (xx < 0)
+ xx = 0;
+ if (yy < 0)
+ yy = 0;
+
+ if (_x >= dst.w || _y >= dst.h) {
+ srcAdapted->free();
+ delete srcAdapted;
+ return;
}
- _alphaDataEntries[idNumber] = entry;
+ byte *dstBuffer = (byte *)dst.getBasePtr(xx, yy);
+
+ int32 w = srcRect.width();
+ int32 h = srcRect.height();
+
+ for (int32 y = 0; y < h; y++) {
+ memcpy(dstBuffer, srcBuffer, w * srcAdapted->format.bytesPerPixel);
+ srcBuffer += srcAdapted->pitch;
+ dstBuffer += dst.pitch;
+ }
+
+ srcAdapted->free();
+ delete srcAdapted;
}
-Common::Rect RenderManager::renderTextToWorkingWindow(uint32 idNumber, const Common::String &text, TruetypeFont *font, int destX, int destY, uint16 textColor, int maxWidth, int maxHeight, Graphics::TextAlign align, bool wrap) {
- AlphaDataEntry entry;
- entry.alphaColor = 0;
- entry.destX = destX;
- entry.destY = destY;
+void RenderManager::blitSurfaceToSurface(const Graphics::Surface &src, const Common::Rect &_srcRect , Graphics::Surface &dst, int _x, int _y, uint32 colorkey) {
+ Common::Rect srcRect = _srcRect;
+ if (srcRect.isEmpty())
+ srcRect = Common::Rect(src.w, src.h);
+ srcRect.clip(src.w, src.h);
+ Common::Rect dstRect = Common::Rect(-_x + srcRect.left , -_y + srcRect.top, -_x + srcRect.left + dst.w, -_y + srcRect.top + dst.h);
+ srcRect.clip(dstRect);
- // Draw the text to the working window
- entry.data = font->drawTextToSurface(text, textColor, maxWidth, maxHeight, align, wrap);
- entry.width = entry.data->w;
- entry.height = entry.data->h;
+ if (srcRect.isEmpty() || !srcRect.isValidRect())
+ return;
- _alphaDataEntries[idNumber] = entry;
+ Graphics::Surface *srcAdapted = src.convertTo(dst.format);
+ uint32 keycolor = colorkey & ((1 << (src.format.bytesPerPixel << 3)) - 1);
- return Common::Rect(destX, destY, destX + entry.width, destY + entry.height);
-}
+ // Copy srcRect from src surface to dst surface
+ const byte *srcBuffer = (const byte *)srcAdapted->getBasePtr(srcRect.left, srcRect.top);
-const Common::Point RenderManager::screenSpaceToImageSpace(const Common::Point &point) {
- // Convert from screen space to working window space
- Common::Point newPoint(point - Common::Point(_workingWindow.left, _workingWindow.top));
+ int xx = _x;
+ int yy = _y;
- RenderTable::RenderState state = _renderTable.getRenderState();
- if (state == RenderTable::PANORAMA || state == RenderTable::TILT) {
- newPoint = _renderTable.convertWarpedCoordToFlatCoord(newPoint);
+ if (xx < 0)
+ xx = 0;
+ if (yy < 0)
+ yy = 0;
+
+ if (_x >= dst.w || _y >= dst.h) {
+ srcAdapted->free();
+ delete srcAdapted;
+ return;
}
- if (state == RenderTable::PANORAMA) {
- newPoint -= (Common::Point(_screenCenterX, 0) - _backgroundOffset);
- } else if (state == RenderTable::TILT) {
- newPoint -= (Common::Point(0, _screenCenterY) - _backgroundOffset);
+ byte *dstBuffer = (byte *)dst.getBasePtr(xx, yy);
+
+ int32 w = srcRect.width();
+ int32 h = srcRect.height();
+
+ for (int32 y = 0; y < h; y++) {
+ switch (srcAdapted->format.bytesPerPixel) {
+ case 1: {
+ const uint *srcTemp = (const uint *)srcBuffer;
+ uint *dstTemp = (uint *)dstBuffer;
+ for (int32 x = 0; x < w; x++) {
+ if (*srcTemp != keycolor)
+ *dstTemp = *srcTemp;
+ srcTemp++;
+ dstTemp++;
+ }
+ }
+ break;
+
+ case 2: {
+ const uint16 *srcTemp = (const uint16 *)srcBuffer;
+ uint16 *dstTemp = (uint16 *)dstBuffer;
+ for (int32 x = 0; x < w; x++) {
+ if (*srcTemp != keycolor)
+ *dstTemp = *srcTemp;
+ srcTemp++;
+ dstTemp++;
+ }
+ }
+ break;
+
+ case 4: {
+ const uint32 *srcTemp = (const uint32 *)srcBuffer;
+ uint32 *dstTemp = (uint32 *)dstBuffer;
+ for (int32 x = 0; x < w; x++) {
+ if (*srcTemp != keycolor)
+ *dstTemp = *srcTemp;
+ srcTemp++;
+ dstTemp++;
+ }
+ }
+ break;
+
+ default:
+ break;
+ }
+ srcBuffer += srcAdapted->pitch;
+ dstBuffer += dst.pitch;
+ }
+
+ srcAdapted->free();
+ delete srcAdapted;
+}
+
+void RenderManager::blitSurfaceToBkg(const Graphics::Surface &src, int x, int y, int32 colorkey) {
+ Common::Rect empt;
+ if (colorkey >= 0)
+ blitSurfaceToSurface(src, empt, _currentBackgroundImage, x, y, colorkey);
+ else
+ blitSurfaceToSurface(src, empt, _currentBackgroundImage, x, y);
+ Common::Rect dirty(src.w, src.h);
+ dirty.translate(x, y);
+ if (_backgroundDirtyRect.isEmpty())
+ _backgroundDirtyRect = dirty;
+ else
+ _backgroundDirtyRect.extend(dirty);
+}
+
+void RenderManager::blitSurfaceToBkgScaled(const Graphics::Surface &src, const Common::Rect &_dstRect, int32 colorkey) {
+ if (src.w == _dstRect.width() && src.h == _dstRect.height()) {
+ blitSurfaceToBkg(src, _dstRect.left, _dstRect.top, colorkey);
+ } else {
+ Graphics::Surface *tmp = new Graphics::Surface;
+ tmp->create(_dstRect.width(), _dstRect.height(), src.format);
+ scaleBuffer(src.getPixels(), tmp->getPixels(), src.w, src.h, src.format.bytesPerPixel, _dstRect.width(), _dstRect.height());
+ blitSurfaceToBkg(*tmp, _dstRect.left, _dstRect.top, colorkey);
+ tmp->free();
+ delete tmp;
}
+}
+
+void RenderManager::blitSurfaceToMenu(const Graphics::Surface &src, int x, int y, int32 colorkey) {
+ Common::Rect empt;
+ if (colorkey >= 0)
+ blitSurfaceToSurface(src, empt, _menuSurface, x, y, colorkey);
+ else
+ blitSurfaceToSurface(src, empt, _menuSurface, x, y);
+ Common::Rect dirty(src.w, src.h);
+ dirty.translate(x, y);
+ if (_menuSurfaceDirtyRect.isEmpty())
+ _menuSurfaceDirtyRect = dirty;
+ else
+ _menuSurfaceDirtyRect.extend(dirty);
+}
+
+Graphics::Surface *RenderManager::getBkgRect(Common::Rect &rect) {
+ Common::Rect dst = rect;
+ dst.clip(_backgroundWidth, _backgroundHeight);
+
+ if (dst.isEmpty() || !dst.isValidRect())
+ return NULL;
- if (newPoint.x < 0)
- newPoint.x += _backgroundWidth;
- else if (newPoint.x >= _backgroundWidth)
- newPoint.x -= _backgroundWidth;
- if (newPoint.y < 0)
- newPoint.y += _backgroundHeight;
- else if (newPoint.y >= _backgroundHeight)
- newPoint.y -= _backgroundHeight;
+ Graphics::Surface *srf = new Graphics::Surface;
+ srf->create(dst.width(), dst.height(), _currentBackgroundImage.format);
- return newPoint;
+ srf->copyRectToSurface(_currentBackgroundImage, 0, 0, Common::Rect(dst));
+
+ return srf;
}
-const Common::Point RenderManager::imageSpaceToWorkingWindowSpace(const Common::Point &point) {
- Common::Point newPoint(point);
+Graphics::Surface *RenderManager::loadImage(Common::String file) {
+ Graphics::Surface *tmp = new Graphics::Surface;
+ readImageToSurface(file, *tmp);
+ return tmp;
+}
+Graphics::Surface *RenderManager::loadImage(Common::String file, bool transposed) {
+ Graphics::Surface *tmp = new Graphics::Surface;
+ readImageToSurface(file, *tmp, transposed);
+ return tmp;
+}
+
+void RenderManager::prepareBackground() {
+ _backgroundDirtyRect.clip(_backgroundWidth, _backgroundHeight);
RenderTable::RenderState state = _renderTable.getRenderState();
+
if (state == RenderTable::PANORAMA) {
- newPoint += (Common::Point(_screenCenterX, 0) - _backgroundOffset);
+ // Calculate the visible portion of the background
+ Common::Rect viewPort(_workingWidth, _workingHeight);
+ viewPort.translate(-(_screenCenterX - _backgroundOffset), 0);
+ Common::Rect drawRect = _backgroundDirtyRect;
+ drawRect.clip(viewPort);
+
+ // Render the visible portion
+ if (!drawRect.isEmpty()) {
+ blitSurfaceToSurface(_currentBackgroundImage, drawRect, _backgroundSurface, _screenCenterX - _backgroundOffset + drawRect.left, drawRect.top);
+ }
+
+ // Mark the dirty portion of the surface
+ _backgroundSurfaceDirtyRect = _backgroundDirtyRect;
+ _backgroundSurfaceDirtyRect.translate(_screenCenterX - _backgroundOffset, 0);
+
+ // Panorama mode allows the user to spin in circles. Therefore, we need to render
+ // the portion of the image that wrapped to the other side of the screen
+ if (_backgroundOffset < _screenCenterX) {
+ viewPort.moveTo(-(_screenCenterX - (_backgroundOffset + _backgroundWidth)), 0);
+ drawRect = _backgroundDirtyRect;
+ drawRect.clip(viewPort);
+
+ if (!drawRect.isEmpty())
+ blitSurfaceToSurface(_currentBackgroundImage, drawRect, _backgroundSurface, _screenCenterX - (_backgroundOffset + _backgroundWidth) + drawRect.left, drawRect.top);
+
+ Common::Rect tmp = _backgroundDirtyRect;
+ tmp.translate(_screenCenterX - (_backgroundOffset + _backgroundWidth), 0);
+ if (!tmp.isEmpty())
+ _backgroundSurfaceDirtyRect.extend(tmp);
+
+ } else if (_backgroundWidth - _backgroundOffset < _screenCenterX) {
+ viewPort.moveTo(-(_screenCenterX + _backgroundWidth - _backgroundOffset), 0);
+ drawRect = _backgroundDirtyRect;
+ drawRect.clip(viewPort);
+
+ if (!drawRect.isEmpty())
+ blitSurfaceToSurface(_currentBackgroundImage, drawRect, _backgroundSurface, _screenCenterX + _backgroundWidth - _backgroundOffset + drawRect.left, drawRect.top);
+
+ Common::Rect tmp = _backgroundDirtyRect;
+ tmp.translate(_screenCenterX + _backgroundWidth - _backgroundOffset, 0);
+ if (!tmp.isEmpty())
+ _backgroundSurfaceDirtyRect.extend(tmp);
+
+ }
} else if (state == RenderTable::TILT) {
- newPoint += (Common::Point(0, _screenCenterY) - _backgroundOffset);
+ // Tilt doesn't allow wrapping, so we just do a simple clip
+ Common::Rect viewPort(_workingWidth, _workingHeight);
+ viewPort.translate(0, -(_screenCenterY - _backgroundOffset));
+ Common::Rect drawRect = _backgroundDirtyRect;
+ drawRect.clip(viewPort);
+ if (!drawRect.isEmpty())
+ blitSurfaceToSurface(_currentBackgroundImage, drawRect, _backgroundSurface, drawRect.left, _screenCenterY - _backgroundOffset + drawRect.top);
+
+ // Mark the dirty portion of the surface
+ _backgroundSurfaceDirtyRect = _backgroundDirtyRect;
+ _backgroundSurfaceDirtyRect.translate(0, _screenCenterY - _backgroundOffset);
+
+ } else {
+ if (!_backgroundDirtyRect.isEmpty())
+ blitSurfaceToSurface(_currentBackgroundImage, _backgroundDirtyRect, _backgroundSurface, _backgroundDirtyRect.left, _backgroundDirtyRect.top);
+ _backgroundSurfaceDirtyRect = _backgroundDirtyRect;
}
- return newPoint;
+ // Clear the dirty rect since everything is clean now
+ _backgroundDirtyRect = Common::Rect();
+
+ _backgroundSurfaceDirtyRect.clip(_workingWidth, _workingHeight);
}
-bool RenderManager::clipRectToWorkingWindow(Common::Rect &rect) {
- if (!_workingWindow.contains(rect)) {
- return false;
+void RenderManager::clearMenuSurface() {
+ _menuSurfaceDirtyRect = Common::Rect(0, 0, _menuSurface.w, _menuSurface.h);
+ _menuSurface.fillRect(_menuSurfaceDirtyRect, 0);
+}
+
+void RenderManager::clearMenuSurface(const Common::Rect &r) {
+ if (_menuSurfaceDirtyRect.isEmpty())
+ _menuSurfaceDirtyRect = r;
+ else
+ _menuSurfaceDirtyRect.extend(r);
+ _menuSurface.fillRect(r, 0);
+}
+
+void RenderManager::renderMenuToScreen() {
+ if (!_menuSurfaceDirtyRect.isEmpty()) {
+ _menuSurfaceDirtyRect.clip(Common::Rect(_menuSurface.w, _menuSurface.h));
+ if (!_menuSurfaceDirtyRect.isEmpty()) {
+ Common::Rect rect(
+ _menuSurfaceDirtyRect.left + _menuArea.left,
+ _menuSurfaceDirtyRect.top + _menuArea.top,
+ _menuSurfaceDirtyRect.left + _menuArea.left + _menuSurfaceDirtyRect.width(),
+ _menuSurfaceDirtyRect.top + _menuArea.top + _menuSurfaceDirtyRect.height()
+ );
+ copyToScreen(_menuSurface, rect, _menuSurfaceDirtyRect.left, _menuSurfaceDirtyRect.top);
+ }
+ _menuSurfaceDirtyRect = Common::Rect();
}
+}
- // We can't clip against the actual working window rect because it's in screen space
- // But rect is in working window space
- rect.clip(_workingWidth, _workingHeight);
- return true;
+uint16 RenderManager::createSubArea(const Common::Rect &area) {
+ _subid++;
+
+ OneSubtitle sub;
+ sub.redraw = false;
+ sub.timer = -1;
+ sub.todelete = false;
+ sub.r = area;
+
+ _subsList[_subid] = sub;
+
+ return _subid;
}
-RenderTable *RenderManager::getRenderTable() {
- return &_renderTable;
+uint16 RenderManager::createSubArea() {
+ Common::Rect r(_subtitleArea.left, _subtitleArea.top, _subtitleArea.right, _subtitleArea.bottom);
+ r.translate(-_workingWindow.left, -_workingWindow.top);
+ return createSubArea(r);
}
-void RenderManager::setBackgroundImage(const Common::String &fileName) {
- readImageToSurface(fileName, _currentBackground);
+void RenderManager::deleteSubArea(uint16 id) {
+ if (_subsList.contains(id))
+ _subsList[id].todelete = true;
+}
- moveBackground(0);
+void RenderManager::deleteSubArea(uint16 id, int16 delay) {
+ if (_subsList.contains(id))
+ _subsList[id].timer = delay;
}
-void RenderManager::setBackgroundPosition(int offset) {
- RenderTable::RenderState state = _renderTable.getRenderState();
- if (state == RenderTable::TILT) {
- _backgroundOffset.x = 0;
- _backgroundOffset.y = offset;
- } else if (state == RenderTable::PANORAMA) {
- _backgroundOffset.x = offset;
- _backgroundOffset.y = 0;
- } else {
- _backgroundOffset.x = 0;
- _backgroundOffset.y = 0;
+void RenderManager::updateSubArea(uint16 id, const Common::String &txt) {
+ if (_subsList.contains(id)) {
+ OneSubtitle *sub = &_subsList[id];
+ sub->txt = txt;
+ sub->redraw = true;
}
}
-void RenderManager::setBackgroundVelocity(int velocity) {
- // setBackgroundVelocity(0) will be called quite often, so make sure
- // _backgroundInverseVelocity isn't already 0 to prevent an extraneous assignment
- if (velocity == 0) {
- if (_backgroundInverseVelocity != 0) {
- _backgroundInverseVelocity = 0;
+void RenderManager::processSubs(uint16 deltatime) {
+ bool redraw = false;
+ for (SubtitleMap::iterator it = _subsList.begin(); it != _subsList.end(); it++) {
+ if (it->_value.timer != -1) {
+ it->_value.timer -= deltatime;
+ if (it->_value.timer <= 0)
+ it->_value.todelete = true;
+ }
+ if (it->_value.todelete) {
+ _subsList.erase(it);
+ redraw = true;
+ } else if (it->_value.redraw) {
+ redraw = true;
}
- } else {
- _backgroundInverseVelocity = 1000 / velocity;
}
-}
-void RenderManager::moveBackground(int offset) {
- RenderTable::RenderState state = _renderTable.getRenderState();
- if (state == RenderTable::TILT) {
- _backgroundOffset += Common::Point(0, offset);
+ if (redraw) {
+ _subtitleSurface.fillRect(Common::Rect(_subtitleSurface.w, _subtitleSurface.h), 0);
+
+ for (SubtitleMap::iterator it = _subsList.begin(); it != _subsList.end(); it++) {
+ OneSubtitle *sub = &it->_value;
+ if (sub->txt.size()) {
+ Graphics::Surface *rndr = new Graphics::Surface();
+ rndr->create(sub->r.width(), sub->r.height(), _engine->_resourcePixelFormat);
+ _engine->getTextRenderer()->drawTxtInOneLine(sub->txt, *rndr);
+ Common::Rect empty;
+ blitSurfaceToSurface(*rndr, empty, _subtitleSurface, sub->r.left - _subtitleArea.left + _workingWindow.left, sub->r.top - _subtitleArea.top + _workingWindow.top);
+ rndr->free();
+ delete rndr;
+ }
+ sub->redraw = false;
+ }
- _backgroundOffset.y = CLIP<int16>(_backgroundOffset.y, _screenCenterY, (int16)_backgroundHeight - _screenCenterY);
+ Common::Rect rect(
+ _subtitleArea.left,
+ _subtitleArea.top,
+ _subtitleArea.left + _subtitleSurface.w,
+ _subtitleArea.top + _subtitleSurface.h
+ );
+ copyToScreen(_subtitleSurface, rect, 0, 0);
+ }
+}
- renderImageToScreen(_currentBackground, 0, _screenCenterY - _backgroundOffset.y, true);
- } else if (state == RenderTable::PANORAMA) {
- _backgroundOffset += Common::Point(offset, 0);
+Common::Point RenderManager::getBkgSize() {
+ return Common::Point(_backgroundWidth, _backgroundHeight);
+}
- if (_backgroundOffset.x <= -_backgroundWidth)
- _backgroundOffset.x += _backgroundWidth;
- else if (_backgroundOffset.x >= _backgroundWidth)
- _backgroundOffset.x -= _backgroundWidth;
+void RenderManager::addEffect(GraphicsEffect *_effect) {
+ _effects.push_back(_effect);
+}
- renderImageToScreen(_currentBackground, _screenCenterX - _backgroundOffset.x, 0, true);
- } else {
- renderImageToScreen(_currentBackground, 0, 0);
+void RenderManager::deleteEffect(uint32 ID) {
+ for (EffectsList::iterator it = _effects.begin(); it != _effects.end(); it++) {
+ if ((*it)->getKey() == ID) {
+ delete *it;
+ it = _effects.erase(it);
+ }
}
}
-uint32 RenderManager::getCurrentBackgroundOffset() {
+Common::Rect RenderManager::transformBackgroundSpaceRectToScreenSpace(const Common::Rect &src) {
+ Common::Rect tmp = src;
RenderTable::RenderState state = _renderTable.getRenderState();
if (state == RenderTable::PANORAMA) {
- return _backgroundOffset.x;
+ if (_backgroundOffset < _screenCenterX) {
+ Common::Rect rScreen(_screenCenterX + _backgroundOffset, _workingHeight);
+ Common::Rect lScreen(_workingWidth - rScreen.width(), _workingHeight);
+ lScreen.translate(_backgroundWidth - lScreen.width(), 0);
+ lScreen.clip(src);
+ rScreen.clip(src);
+ if (rScreen.width() < lScreen.width()) {
+ tmp.translate(_screenCenterX - _backgroundOffset - _backgroundWidth, 0);
+ } else {
+ tmp.translate(_screenCenterX - _backgroundOffset, 0);
+ }
+ } else if (_backgroundWidth - _backgroundOffset < _screenCenterX) {
+ Common::Rect rScreen(_screenCenterX - (_backgroundWidth - _backgroundOffset), _workingHeight);
+ Common::Rect lScreen(_workingWidth - rScreen.width(), _workingHeight);
+ lScreen.translate(_backgroundWidth - lScreen.width(), 0);
+ lScreen.clip(src);
+ rScreen.clip(src);
+ if (lScreen.width() < rScreen.width()) {
+ tmp.translate(_screenCenterX + (_backgroundWidth - _backgroundOffset), 0);
+ } else {
+ tmp.translate(_screenCenterX - _backgroundOffset, 0);
+ }
+ } else {
+ tmp.translate(_screenCenterX - _backgroundOffset, 0);
+ }
} else if (state == RenderTable::TILT) {
- return _backgroundOffset.y;
- } else {
- return 0;
+ tmp.translate(0, (_screenCenterY - _backgroundOffset));
}
+
+ return tmp;
}
-Graphics::Surface *RenderManager::tranposeSurface(const Graphics::Surface *surface) {
- Graphics::Surface *tranposedSurface = new Graphics::Surface();
- tranposedSurface->create(surface->h, surface->w, surface->format);
+EffectMap *RenderManager::makeEffectMap(const Common::Point &xy, int16 depth, const Common::Rect &rect, int8 *_minComp, int8 *_maxComp) {
+ Common::Rect bkgRect(_backgroundWidth, _backgroundHeight);
+ if (!bkgRect.contains(xy))
+ return NULL;
+
+ if (!bkgRect.intersects(rect))
+ return NULL;
+
+ uint16 color = *(uint16 *)_currentBackgroundImage.getBasePtr(xy.x, xy.y);
+ uint8 stC1, stC2, stC3;
+ _currentBackgroundImage.format.colorToRGB(color, stC1, stC2, stC3);
+ EffectMap *newMap = new EffectMap;
+
+ EffectMapUnit unit;
+ unit.count = 0;
+ unit.inEffect = false;
+
+ int16 w = rect.width();
+ int16 h = rect.height();
+
+ bool first = true;
+
+ uint8 minComp = MIN(MIN(stC1, stC2), stC3);
+ uint8 maxComp = MAX(MAX(stC1, stC2), stC3);
+
+ uint8 depth8 = depth << 3;
+
+ for (int16 j = 0; j < h; j++) {
+ uint16 *pix = (uint16 *)_currentBackgroundImage.getBasePtr(rect.left, rect.top + j);
+ for (int16 i = 0; i < w; i++) {
+ uint16 curClr = pix[i];
+ uint8 cC1, cC2, cC3;
+ _currentBackgroundImage.format.colorToRGB(curClr, cC1, cC2, cC3);
+
+ bool use = false;
+
+ if (curClr == color)
+ use = true;
+ else if (curClr > color) {
+ if ((cC1 - stC1 < depth8) &&
+ (cC2 - stC2 < depth8) &&
+ (cC3 - stC3 < depth8))
+ use = true;
+ } else { /* if (curClr < color) */
+ if ((stC1 - cC1 < depth8) &&
+ (stC2 - cC2 < depth8) &&
+ (stC3 - cC3 < depth8))
+ use = true;
+ }
- const uint16 *source = (const uint16 *)surface->getPixels();
- uint16 *dest = (uint16 *)tranposedSurface->getPixels();
+ if (first) {
+ unit.inEffect = use;
+ first = false;
+ }
- for (uint32 y = 0; y < tranposedSurface->h; ++y) {
- uint32 columnIndex = y * tranposedSurface->w;
+ if (use) {
+ uint8 cMinComp = MIN(MIN(cC1, cC2), cC3);
+ uint8 cMaxComp = MAX(MAX(cC1, cC2), cC3);
+ if (cMinComp < minComp)
+ minComp = cMinComp;
+ if (cMaxComp > maxComp)
+ maxComp = cMaxComp;
+ }
- for (uint32 x = 0; x < tranposedSurface->w; ++x) {
- dest[columnIndex + x] = source[x * surface->w + y];
+ if (unit.inEffect == use)
+ unit.count++;
+ else {
+ newMap->push_back(unit);
+ unit.count = 1;
+ unit.inEffect = use;
+ }
}
}
+ newMap->push_back(unit);
- return tranposedSurface;
+ if (_minComp) {
+ if (minComp - depth8 < 0)
+ *_minComp = -(minComp >> 3);
+ else
+ *_minComp = -depth;
+ }
+ if (_maxComp) {
+ if ((int16)maxComp + (int16)depth8 > 255)
+ *_maxComp = (255 - maxComp) >> 3;
+ else
+ *_maxComp = depth;
+ }
+
+ return newMap;
+}
+
+EffectMap *RenderManager::makeEffectMap(const Graphics::Surface &surf, uint16 transp) {
+ EffectMapUnit unit;
+ unit.count = 0;
+ unit.inEffect = false;
+
+ int16 w = surf.w;
+ int16 h = surf.h;
+
+ EffectMap *newMap = new EffectMap;
+
+ bool first = true;
+
+ for (int16 j = 0; j < h; j++) {
+ const uint16 *pix = (const uint16 *)surf.getBasePtr(0, j);
+ for (int16 i = 0; i < w; i++) {
+ bool use = false;
+ if (pix[i] != transp)
+ use = true;
+
+ if (first) {
+ unit.inEffect = use;
+ first = false;
+ }
+
+ if (unit.inEffect == use)
+ unit.count++;
+ else {
+ newMap->push_back(unit);
+ unit.count = 1;
+ unit.inEffect = use;
+ }
+ }
+ }
+ newMap->push_back(unit);
+
+ return newMap;
+}
+
+void RenderManager::markDirty() {
+ _backgroundDirtyRect = Common::Rect(_backgroundWidth, _backgroundHeight);
+}
+
+#if 0
+void RenderManager::bkgFill(uint8 r, uint8 g, uint8 b) {
+ _currentBackgroundImage.fillRect(Common::Rect(_currentBackgroundImage.w, _currentBackgroundImage.h), _currentBackgroundImage.format.RGBToColor(r, g, b));
+ markDirty();
+}
+#endif
+
+void RenderManager::timedMessage(const Common::String &str, uint16 milsecs) {
+ uint16 msgid = createSubArea();
+ updateSubArea(msgid, str);
+ processSubs(0);
+ renderSceneToScreen();
+ deleteSubArea(msgid, milsecs);
+}
+
+bool RenderManager::askQuestion(const Common::String &str) {
+ uint16 msgid = createSubArea();
+ updateSubArea(msgid, str);
+ processSubs(0);
+ renderSceneToScreen();
+ _engine->stopClock();
+
+ int result = 0;
+
+ while (result == 0) {
+ Common::Event evnt;
+ while (_engine->getEventManager()->pollEvent(evnt)) {
+ if (evnt.type == Common::EVENT_KEYDOWN) {
+ switch (evnt.kbd.keycode) {
+ case Common::KEYCODE_y:
+ result = 2;
+ break;
+ case Common::KEYCODE_n:
+ result = 1;
+ break;
+ default:
+ break;
+ }
+ }
+ }
+ _system->updateScreen();
+ if (_doubleFPS)
+ _system->delayMillis(33);
+ else
+ _system->delayMillis(66);
+ }
+ deleteSubArea(msgid);
+ _engine->startClock();
+ return result == 2;
+}
+
+void RenderManager::delayedMessage(const Common::String &str, uint16 milsecs) {
+ uint16 msgid = createSubArea();
+ updateSubArea(msgid, str);
+ processSubs(0);
+ renderSceneToScreen();
+ _engine->stopClock();
+
+ uint32 stopTime = _system->getMillis() + milsecs;
+ while (_system->getMillis() < stopTime) {
+ Common::Event evnt;
+ while (_engine->getEventManager()->pollEvent(evnt)) {
+ if (evnt.type == Common::EVENT_KEYDOWN &&
+ (evnt.kbd.keycode == Common::KEYCODE_SPACE ||
+ evnt.kbd.keycode == Common::KEYCODE_RETURN ||
+ evnt.kbd.keycode == Common::KEYCODE_ESCAPE))
+ break;
+ }
+ _system->updateScreen();
+ if (_doubleFPS)
+ _system->delayMillis(33);
+ else
+ _system->delayMillis(66);
+ }
+ deleteSubArea(msgid);
+ _engine->startClock();
+}
+
+void RenderManager::showDebugMsg(const Common::String &msg, int16 delay) {
+ uint16 msgid = createSubArea();
+ updateSubArea(msgid, msg);
+ deleteSubArea(msgid, delay);
+}
+
+void RenderManager::updateRotation() {
+ int16 _velocity = _engine->getMouseVelocity() + _engine->getKeyboardVelocity();
+ ScriptManager *scriptManager = _engine->getScriptManager();
+
+ if (_doubleFPS)
+ _velocity /= 2;
+
+ if (_velocity) {
+ RenderTable::RenderState renderState = _renderTable.getRenderState();
+ if (renderState == RenderTable::PANORAMA) {
+ int16 startPosition = scriptManager->getStateValue(StateKey_ViewPos);
+
+ int16 newPosition = startPosition + (_renderTable.getPanoramaReverse() ? -_velocity : _velocity);
+
+ int16 zeroPoint = _renderTable.getPanoramaZeroPoint();
+ if (startPosition >= zeroPoint && newPosition < zeroPoint)
+ scriptManager->setStateValue(StateKey_Rounds, scriptManager->getStateValue(StateKey_Rounds) - 1);
+ if (startPosition <= zeroPoint && newPosition > zeroPoint)
+ scriptManager->setStateValue(StateKey_Rounds, scriptManager->getStateValue(StateKey_Rounds) + 1);
+
+ int16 screenWidth = getBkgSize().x;
+ if (screenWidth)
+ newPosition %= screenWidth;
+
+ if (newPosition < 0)
+ newPosition += screenWidth;
+
+ setBackgroundPosition(newPosition);
+ } else if (renderState == RenderTable::TILT) {
+ int16 startPosition = scriptManager->getStateValue(StateKey_ViewPos);
+
+ int16 newPosition = startPosition + _velocity;
+
+ int16 screenHeight = getBkgSize().y;
+ int16 tiltGap = _renderTable.getTiltGap();
+
+ if (newPosition >= (screenHeight - tiltGap))
+ newPosition = screenHeight - tiltGap;
+ if (newPosition <= tiltGap)
+ newPosition = tiltGap;
+
+ setBackgroundPosition(newPosition);
+ }
+ }
+}
+
+void RenderManager::checkBorders() {
+ RenderTable::RenderState renderState = _renderTable.getRenderState();
+ if (renderState == RenderTable::PANORAMA) {
+ int16 startPosition = _engine->getScriptManager()->getStateValue(StateKey_ViewPos);
+
+ int16 newPosition = startPosition;
+
+ int16 screenWidth = getBkgSize().x;
+
+ if (screenWidth)
+ newPosition %= screenWidth;
+
+ if (newPosition < 0)
+ newPosition += screenWidth;
+
+ if (startPosition != newPosition)
+ setBackgroundPosition(newPosition);
+ } else if (renderState == RenderTable::TILT) {
+ int16 startPosition = _engine->getScriptManager()->getStateValue(StateKey_ViewPos);
+
+ int16 newPosition = startPosition;
+
+ int16 screenHeight = getBkgSize().y;
+ int16 tiltGap = _renderTable.getTiltGap();
+
+ if (newPosition >= (screenHeight - tiltGap))
+ newPosition = screenHeight - tiltGap;
+ if (newPosition <= tiltGap)
+ newPosition = tiltGap;
+
+ if (startPosition != newPosition)
+ setBackgroundPosition(newPosition);
+ }
+}
+
+void RenderManager::rotateTo(int16 _toPos, int16 _time) {
+ if (_renderTable.getRenderState() != RenderTable::PANORAMA)
+ return;
+
+ if (_time == 0)
+ _time = 1;
+
+ int32 maxX = getBkgSize().x;
+ int32 curX = getCurrentBackgroundOffset();
+ int32 dx = 0;
+
+ if (curX == _toPos)
+ return;
+
+ if (curX > _toPos) {
+ if (curX - _toPos > maxX / 2)
+ dx = (_toPos + (maxX - curX)) / _time;
+ else
+ dx = -(curX - _toPos) / _time;
+ } else {
+ if (_toPos - curX > maxX / 2)
+ dx = -((maxX - _toPos) + curX) / _time;
+ else
+ dx = (_toPos - curX) / _time;
+ }
+
+ _engine->stopClock();
+
+ for (int16 i = 0; i <= _time; i++) {
+ if (i == _time)
+ curX = _toPos;
+ else
+ curX += dx;
+
+ if (curX < 0)
+ curX = maxX - curX;
+ else if (curX >= maxX)
+ curX %= maxX;
+
+ setBackgroundPosition(curX);
+
+ prepareBackground();
+ renderSceneToScreen();
+
+ _system->updateScreen();
+
+ _system->delayMillis(500 / _time);
+ }
+
+ _engine->startClock();
}
} // End of namespace ZVision
diff --git a/engines/zvision/graphics/render_manager.h b/engines/zvision/graphics/render_manager.h
index 9feff4c030..c22f9a78c9 100644
--- a/engines/zvision/graphics/render_manager.h
+++ b/engines/zvision/graphics/render_manager.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.
@@ -24,13 +24,14 @@
#define ZVISION_RENDER_MANAGER_H
#include "zvision/graphics/render_table.h"
-#include "zvision/fonts/truetype_font.h"
+#include "zvision/text/truetype_font.h"
#include "common/rect.h"
#include "common/hashmap.h"
#include "graphics/surface.h"
+#include "graphics_effect.h"
class OSystem;
@@ -47,171 +48,136 @@ namespace ZVision {
class RenderManager {
public:
- RenderManager(OSystem *system, uint32 windowWidth, uint32 windowHeight, const Common::Rect workingWindow, const Graphics::PixelFormat pixelFormat);
+ RenderManager(ZVision *engine, uint32 windowWidth, uint32 windowHeight, const Common::Rect workingWindow, const Graphics::PixelFormat pixelFormat, bool doubleFPS);
~RenderManager();
private:
- struct AlphaDataEntry {
- Graphics::Surface *data;
- uint16 alphaColor;
- uint16 destX;
- uint16 destY;
- uint16 width;
- uint16 height;
+ struct OneSubtitle {
+ Common::Rect r;
+ Common::String txt;
+ int16 timer;
+ bool todelete;
+ bool redraw;
};
- typedef Common::HashMap<uint32, AlphaDataEntry> AlphaEntryMap;
+ typedef Common::HashMap<uint16, OneSubtitle> SubtitleMap;
+ typedef Common::List<GraphicsEffect *> EffectsList;
private:
+ ZVision *_engine;
OSystem *_system;
const Graphics::PixelFormat _pixelFormat;
- // A buffer the exact same size as the workingWindow
- // This buffer stores everything un-warped, then does a warp at the end of the frame
- Graphics::Surface _workingWindowBuffer;
- // A buffer representing the entire screen. Any graphical updates are first done with this buffer
- // before actually being blitted to the screen
- Graphics::Surface _backBuffer;
- // A list of Alpha Entries that need to be blitted to the backbuffer
- AlphaEntryMap _alphaDataEntries;
-
- // A rectangle representing the portion of the working window where the pixels have been changed since last frame
- Common::Rect _workingWindowDirtyRect;
- // A rectangle representing the portion of the backbuffer where the pixels have been changed since last frame
- Common::Rect _backBufferDirtyRect;
-
- /** Width of the working window. Saved to prevent extraneous calls to _workingWindow.width() */
- const int _workingWidth;
- /** Height of the working window. Saved to prevent extraneous calls to _workingWindow.height() */
- const int _workingHeight;
- /** Center of the screen in the x direction */
- const int _screenCenterX;
- /** Center of the screen in the y direction */
- const int _screenCenterY;
-
/**
* A Rectangle centered inside the actual window. All in-game coordinates
* are given in this coordinate space. Also, all images are clipped to the
* edges of this Rectangle
*/
const Common::Rect _workingWindow;
- /** Used to warp the background image */
- RenderTable _renderTable;
- Graphics::Surface _currentBackground;
- /** The (x1,y1) coordinates of the subRectangle of the background that is currently displayed on the screen */
- Common::Point _backgroundOffset;
+ // Width of the working window. Saved to prevent extraneous calls to _workingWindow.width()
+ const int _workingWidth;
+ // Height of the working window. Saved to prevent extraneous calls to _workingWindow.height()
+ const int _workingHeight;
+ // Center of the screen in the x direction
+ const int _screenCenterX;
+ // Center of the screen in the y direction
+ const int _screenCenterY;
+
+ /** A buffer for background image that's being used to create the background */
+ Graphics::Surface _currentBackgroundImage;
+ Common::Rect _backgroundDirtyRect;
+
+ /**
+ * The x1 or y1 offset of the subRectangle of the background that is currently displayed on the screen
+ * It will be x1 if PANORAMA, or y1 if TILT
+ */
+ int16 _backgroundOffset;
/** The width of the current background image */
uint16 _backgroundWidth;
/** The height of the current background image */
uint16 _backgroundHeight;
- /**
- * The "velocity" at which the background image is panning. We actually store the inverse of velocity (ms/pixel instead of pixels/ms)
- * because it allows you to accumulate whole pixels 'steps' instead of rounding pixels every frame
- */
- int _backgroundInverseVelocity;
- /** Holds any 'leftover' milliseconds between frames */
- uint _accumulatedVelocityMilliseconds;
+ // A buffer that holds the portion of the background that is used to render the final image
+ // If it's a normal scene, the pixels will be blitted directly to the screen
+ // If it's a panorma / tilt scene, the pixels will be first warped to _warpedSceneSurface
+ Graphics::Surface _backgroundSurface;
+ Common::Rect _backgroundSurfaceDirtyRect;
-public:
- void initialize();
- /**
- * Rotates the background image in accordance to the current _backgroundInverseVelocity
- *
- * @param deltaTimeInMillis The amount of time that has passed since the last frame
- */
- void update(uint deltaTimeInMillis);
+ // A buffer for subtitles
+ Graphics::Surface _subtitleSurface;
+ Common::Rect _subtitleSurfaceDirtyRect;
- /**
- * Renders the current state of the backbuffer to the screen
- */
- void renderBackbufferToScreen();
+ // Rectangle for subtitles area
+ Common::Rect _subtitleArea;
- /**
- * Renders all AlphaEntries to the backbuffer
- */
- void processAlphaEntries();
- /**
- * Clears the AlphaEntry list
- */
- void clearAlphaEntries() { _alphaDataEntries.clear(); }
- /**
- * Removes a specific AlphaEntry from the list
- *
- * @param idNumber The id number identifing the AlphaEntry
- */
- void removeAlphaEntry(uint32 idNumber) { _alphaDataEntries.erase(idNumber); }
+ // A buffer for menu drawing
+ Graphics::Surface _menuSurface;
+ Common::Rect _menuSurfaceDirtyRect;
- /**
- * Copies a sub-rectangle of a buffer to the working window
- *
- * @param buffer The pixel data to copy to the working window
- * @param destX The X destination in the working window where the subRect of data should be put
- * @param destY The Y destination in the working window where the subRect of data should be put
- * @param imageWidth The width of the source image
- * @param width The width of the sub rectangle
- * @param height The height of the sub rectangle
- */
- void copyRectToWorkingWindow(const uint16 *buffer, int32 destX, int32 destY, int32 imageWidth, int32 width, int32 height);
- /**
- * Copies a sub-rectangle of a buffer to the working window with binary alpha support.
- *
- * @param buffer The pixel data to copy to the working window
- * @param destX The X destination in the working window where the subRect of data should be put
- * @param destY The Y destination in the working window where the subRect of data should be put
- * @param imageWidth The width of the source image
- * @param width The width of the sub rectangle
- * @param height The height of the sub rectangle
- * @param alphaColor The color to interpret as meaning 'transparent'
- * @param idNumber A unique identifier for the data being copied over.
- */
- void copyRectToWorkingWindow(const uint16 *buffer, int32 destX, int32 destY, int32 imageWidth, int32 width, int32 height, int16 alphaColor, uint32 idNumber);
+ // Rectangle for menu area
+ Common::Rect _menuArea;
- /**
- * Renders the supplied text to the working window
- *
- * @param idNumber A unique identifier for the text
- * @param text The text to be rendered
- * @param font The font to use to render the text
- * @param destX The X destination in the working window where the text should be rendered
- * @param destY The Y destination in the working window where the text should be rendered
- * @param textColor The color to render the text with (in RBG 565)
- * @param maxWidth The max width the text should take up.
- * @param maxHeight The max height the text should take up.
- * @param align The alignment of the text within the bounds of maxWidth
- * @param wrap If true, any words extending past maxWidth will wrap to a new line. If false, ellipses will be rendered to show that the text didn't fit
- * @return A rectangle representing where the text was drawn in the working window
- */
- Common::Rect renderTextToWorkingWindow(uint32 idNumber, const Common::String &text, TruetypeFont *font, int destX, int destY, uint16 textColor, int maxWidth, int maxHeight = -1, Graphics::TextAlign align = Graphics::kTextAlignLeft, bool wrap = true);
+ // A buffer used for apply graphics effects
+ Graphics::Surface _effectSurface;
+
+ // A buffer to store the result of the panorama / tilt warps
+ Graphics::Surface _warpedSceneSurface;
+
+
+ /** Used to warp the background image */
+ RenderTable _renderTable;
+
+ // Internal subtitles counter
+ uint16 _subid;
+
+ // Subtitle list
+ SubtitleMap _subsList;
+
+ // Visual effects list
+ EffectsList _effects;
+
+ bool _doubleFPS;
+
+public:
+ void initialize();
/**
- * Fills the entire workingWindow with the specified color. Internally, the color
- * will be converted to RGB 565 and then blitted.
- *
- * @param color The color to fill the working window with. (In RGB 555)
+ * Renders the scene to the screen
*/
- void clearWorkingWindowTo555Color(uint16 color);
+ void renderSceneToScreen();
+
+ void copyToScreen(const Graphics::Surface &surface, Common::Rect &rect, int16 srcLeft, int16 srcTop);
/**
- * Blits the image or a portion of the image to the backbuffer. Actual screen updates won't happen until the end of the frame.
- * The image will be clipped to fit inside the working window. Coords are in working window space, not screen space!
+ * Blits the image or a portion of the image to the background.
*
* @param fileName Name of the image file
* @param destinationX X position where the image should be put. Coords are in working window space, not screen space!
* @param destinationY Y position where the image should be put. Coords are in working window space, not screen space!
*/
- void renderImageToScreen(const Common::String &fileName, int16 destinationX, int16 destinationY, bool wrap = false);
+ void renderImageToBackground(const Common::String &fileName, int16 destinationX, int16 destinationY);
/**
- * Blits the image or a portion of the image to the backbuffer. Actual screen updates won't happen until the end of the frame.
- * The image will be clipped to fit inside the working window. Coords are in working window space, not screen space!
+ * Blits the image or a portion of the image to the background.
*
- * @param stream Surface to read the image data from
- * @param destinationX X position where the image should be put. Coords are in working window space, not screen space!
- * @param destinationY Y position where the image should be put. Coords are in working window space, not screen space!
+ * @param fileName Name of the image file
+ * @param destX X position where the image should be put. Coords are in working window space, not screen space!
+ * @param destY Y position where the image should be put. Coords are in working window space, not screen space!
+ * @param colorkey Transparent color
+ */
+ void renderImageToBackground(const Common::String &fileName, int16 destX, int16 destY, uint32 colorkey);
+
+ /**
+ * Blits the image or a portion of the image to the background.
+ *
+ * @param fileName Name of the image file
+ * @param destX X position where the image should be put. Coords are in working window space, not screen space!
+ * @param destY Y position where the image should be put. Coords are in working window space, not screen space!
+ * @param keyX X position of transparent color
+ * @param keyY Y position of transparent color
*/
- void renderImageToScreen(Graphics::Surface &surface, int16 destinationX, int16 destinationY, bool wrap = false);
+ void renderImageToBackground(const Common::String &fileName, int16 destX, int16 destY, int16 keyX, int16 keyY);
/**
* Sets the current background image to be used by the RenderManager and immediately
@@ -234,41 +200,18 @@ public:
void setBackgroundPosition(int offset);
/**
- * Set the background scroll velocity. Negative velocities correspond to left / up scrolling and
- * positive velocities correspond to right / down scrolling
- *
- * @param velocity Velocity
- */
- void setBackgroundVelocity(int velocity);
-
- /**
* Converts a point in screen coordinate space to image coordinate space
*
* @param point Point in screen coordinate space
* @return Point in image coordinate space
*/
const Common::Point screenSpaceToImageSpace(const Common::Point &point);
- /**
- * Converts a point in image coordinate space to ***PRE-WARP***
- * working window coordinate space
- *
- * @param point Point in image coordinate space
- * @return Point in PRE-WARP working window coordinate space
- */
- const Common::Point imageSpaceToWorkingWindowSpace(const Common::Point &point);
-
- /**
- * Clip a rectangle to the working window. If it returns false, the original rect
- * is not inside the working window.
- *
- * @param rect The rectangle to clip against the working window
- * @return Is rect at least partially inside the working window (true) or completely outside (false)
- */
- bool clipRectToWorkingWindow(Common::Rect &rect);
+ // Return pointer of RenderTable object
RenderTable *getRenderTable();
+
+ // Return current background offset
uint32 getCurrentBackgroundOffset();
- const Graphics::Surface *getBackBuffer() { return &_backBuffer; }
/**
* Creates a copy of surface and transposes the data.
@@ -281,25 +224,60 @@ public:
*/
static Graphics::Surface *tranposeSurface(const Graphics::Surface *surface);
-private:
- /**
- * Renders a subRectangle of an image to the backbuffer. The destinationRect and SubRect
- * will be clipped to image bound and to working window bounds
- *
- * @param buffer Pointer to (0, 0) of the image data
- * @param imageWidth The width of the original image (not of the subRectangle)
- * @param imageHeight The width of the original image (not of the subRectangle)
- * @param horizontalPitch The horizontal pitch of the original image
- * @param destinationX The x coordinate (in working window space) of where to put the final image
- * @param destinationY The y coordinate (in working window space) of where to put the final image
- * @param subRectangle A rectangle representing the part of the image that should be rendered
- * @param wrap Should the image wrap (tile) if it doesn't completely fill the screen?
- */
- void renderSubRectToScreen(Graphics::Surface &surface, int16 destinationX, int16 destinationY, bool wrap);
+ // Scale buffer (nearest)
+ void scaleBuffer(const void *src, void *dst, uint32 srcWidth, uint32 srcHeight, byte bytesPerPixel, uint32 dstWidth, uint32 dstHeight);
+
+ // Blitting surface-to-surface methods
+ void blitSurfaceToSurface(const Graphics::Surface &src, const Common::Rect &_srcRect , Graphics::Surface &dst, int x, int y);
+ void blitSurfaceToSurface(const Graphics::Surface &src, const Common::Rect &_srcRect , Graphics::Surface &dst, int _x, int _y, uint32 colorkey);
+
+ // Blitting surface-to-background methods
+ void blitSurfaceToBkg(const Graphics::Surface &src, int x, int y, int32 colorkey = -1);
+
+ // Blitting surface-to-background methods with scale
+ void blitSurfaceToBkgScaled(const Graphics::Surface &src, const Common::Rect &_dstRect, int32 colorkey = -1);
+
+ // Blitting surface-to-menu methods
+ void blitSurfaceToMenu(const Graphics::Surface &src, int x, int y, int32 colorkey = -1);
+
+ // Subtitles methods
+
+ // Create subtitle area and return ID
+ uint16 createSubArea(const Common::Rect &area);
+ uint16 createSubArea();
+
+ // Delete subtitle by ID
+ void deleteSubArea(uint16 id);
+ void deleteSubArea(uint16 id, int16 delay);
+
+ // Update subtitle area
+ void updateSubArea(uint16 id, const Common::String &txt);
+
+ // Processing subtitles
+ void processSubs(uint16 deltatime);
+
+ // Return background size
+ Common::Point getBkgSize();
+
+ // Return portion of background as new surface
+ Graphics::Surface *getBkgRect(Common::Rect &rect);
+
+ // Load image into new surface
+ Graphics::Surface *loadImage(Common::String file);
+ Graphics::Surface *loadImage(Common::String file, bool transposed);
+
+ // Clear whole/area of menu surface
+ void clearMenuSurface();
+ void clearMenuSurface(const Common::Rect &r);
+
+ // Copy menu buffer to screen
+ void renderMenuToScreen();
+
+ // Copy needed portion of background surface to workingWindow surface
+ void prepareBackground();
/**
- * Reads an image file pixel data into a Surface buffer. In the process
- * it converts the pixel data from RGB 555 to RGB 565. Also, if the image
+ * Reads an image file pixel data into a Surface buffer. Also, if the image
* is transposed, it will un-transpose the pixel data. The function will
* call destination::create() if the dimensions of destination do not match
* up with the dimensions of the image.
@@ -310,17 +288,53 @@ private:
void readImageToSurface(const Common::String &fileName, Graphics::Surface &destination);
/**
- * Move the background image by an offset. If we are currently in Panorama mode,
- * the offset will correspond to a horizontal motion. If we are currently in Tilt mode,
- * the offset will correspond to a vertical motion. This function should not be called
- * if we are in Flat mode.
- *
- * The RenderManager will take care of wrapping the image.
- * Ex: If the image has width 1400px, it is legal to offset 1500px.
+ * Reads an image file pixel data into a Surface buffer. Also, if the image
+ * is transposed, it will un-transpose the pixel data. The function will
+ * call destination::create() if the dimensions of destination do not match
+ * up with the dimensions of the image.
*
- * @param offset The amount to move the background
+ * @param fileName The name of a .tga file
+ * @param destination A reference to the Surface to store the pixel data in
+ * @param transposed Transpose flag
*/
- void moveBackground(int offset);
+ void readImageToSurface(const Common::String &fileName, Graphics::Surface &destination, bool transposed);
+
+ // Add visual effect to effects list
+ void addEffect(GraphicsEffect *_effect);
+
+ // Delete effect(s) by ID (ID equal to slot of action:region that create this effect)
+ void deleteEffect(uint32 ID);
+
+ // Create "mask" for effects - (color +/- depth) will be selected as not transparent. Like color selection
+ // xy - base color
+ // depth - +/- of base color
+ // rect - rectangle where select pixels
+ // minD - if not NULL will recieve real bottom border of depth
+ // maxD - if not NULL will recieve real top border of depth
+ EffectMap *makeEffectMap(const Common::Point &xy, int16 depth, const Common::Rect &rect, int8 *minD, int8 *maxD);
+
+ // Create "mask" for effects by simple transparent color
+ EffectMap *makeEffectMap(const Graphics::Surface &surf, uint16 transp);
+
+ // Return background rectangle in screen coordinates
+ Common::Rect transformBackgroundSpaceRectToScreenSpace(const Common::Rect &src);
+
+ // Mark whole background surface as dirty
+ void markDirty();
+
+#if 0
+ // Fill background surface by color
+ void bkgFill(uint8 r, uint8 g, uint8 b);
+#endif
+
+ bool askQuestion(const Common::String &str);
+ void delayedMessage(const Common::String &str, uint16 milsecs);
+ void timedMessage(const Common::String &str, uint16 milsecs);
+ void showDebugMsg(const Common::String &msg, int16 delay = 3000);
+
+ void checkBorders();
+ void rotateTo(int16 to, int16 time);
+ void updateRotation();
};
} // End of namespace ZVision
diff --git a/engines/zvision/graphics/render_table.cpp b/engines/zvision/graphics/render_table.cpp
index 49b934dc37..df73247344 100644
--- a/engines/zvision/graphics/render_table.cpp
+++ b/engines/zvision/graphics/render_table.cpp
@@ -21,23 +21,22 @@
*/
#include "common/scummsys.h"
-
#include "zvision/graphics/render_table.h"
-
#include "common/rect.h"
-
#include "graphics/colormasks.h"
-
namespace ZVision {
RenderTable::RenderTable(uint numColumns, uint numRows)
- : _numRows(numRows),
- _numColumns(numColumns),
- _renderState(FLAT) {
+ : _numRows(numRows),
+ _numColumns(numColumns),
+ _renderState(FLAT) {
assert(numRows != 0 && numColumns != 0);
_internalBuffer = new Common::Point[numRows * numColumns];
+
+ memset(&_panoramaOptions, 0, sizeof(_panoramaOptions));
+ memset(&_tiltOptions, 0, sizeof(_tiltOptions));
}
RenderTable::~RenderTable() {
@@ -52,10 +51,11 @@ void RenderTable::setRenderState(RenderState newState) {
_panoramaOptions.fieldOfView = 27.0f;
_panoramaOptions.linearScale = 0.55f;
_panoramaOptions.reverse = false;
+ _panoramaOptions.zeroPoint = 0;
break;
case TILT:
_tiltOptions.fieldOfView = 27.0f;
- _tiltOptions.linearScale = 0.55f;
+ _tiltOptions.linearScale = 0.65f;
_tiltOptions.reverse = false;
break;
case FLAT:
@@ -81,28 +81,7 @@ const Common::Point RenderTable::convertWarpedCoordToFlatCoord(const Common::Poi
return newPoint;
}
-uint16 mixTwoRGB(uint16 colorOne, uint16 colorTwo, float percentColorOne) {
- assert(percentColorOne < 1.0f);
-
- float rOne = float((colorOne & Graphics::ColorMasks<555>::kRedMask) >> Graphics::ColorMasks<555>::kRedShift);
- float rTwo = float((colorTwo & Graphics::ColorMasks<555>::kRedMask) >> Graphics::ColorMasks<555>::kRedShift);
- float gOne = float((colorOne & Graphics::ColorMasks<555>::kGreenMask) >> Graphics::ColorMasks<555>::kGreenShift);
- float gTwo = float((colorTwo & Graphics::ColorMasks<555>::kGreenMask) >> Graphics::ColorMasks<555>::kGreenShift);
- float bOne = float((colorOne & Graphics::ColorMasks<555>::kBlueMask) >> Graphics::ColorMasks<555>::kBlueShift);
- float bTwo = float((colorTwo & Graphics::ColorMasks<555>::kBlueMask) >> Graphics::ColorMasks<555>::kBlueShift);
-
- float rFinal = rOne * percentColorOne + rTwo * (1.0f - percentColorOne);
- float gFinal = gOne * percentColorOne + gTwo * (1.0f - percentColorOne);
- float bFinal = bOne * percentColorOne + bTwo * (1.0f - percentColorOne);
-
- uint16 returnColor = (byte(rFinal + 0.5f) << Graphics::ColorMasks<555>::kRedShift) |
- (byte(gFinal + 0.5f) << Graphics::ColorMasks<555>::kGreenShift) |
- (byte(bFinal + 0.5f) << Graphics::ColorMasks<555>::kBlueShift);
-
- return returnColor;
-}
-
-void RenderTable::mutateImage(uint16 *sourceBuffer, uint16* destBuffer, uint32 destWidth, const Common::Rect &subRect) {
+void RenderTable::mutateImage(uint16 *sourceBuffer, uint16 *destBuffer, uint32 destWidth, const Common::Rect &subRect) {
uint32 destOffset = 0;
for (int16 y = subRect.top; y < subRect.bottom; ++y) {
@@ -123,6 +102,28 @@ void RenderTable::mutateImage(uint16 *sourceBuffer, uint16* destBuffer, uint32 d
}
}
+void RenderTable::mutateImage(Graphics::Surface *dstBuf, Graphics::Surface *srcBuf) {
+ uint32 destOffset = 0;
+
+ uint16 *sourceBuffer = (uint16 *)srcBuf->getPixels();
+ uint16 *destBuffer = (uint16 *)dstBuf->getPixels();
+
+ for (int16 y = 0; y < srcBuf->h; ++y) {
+ uint32 sourceOffset = y * _numColumns;
+
+ for (int16 x = 0; x < srcBuf->w; ++x) {
+ uint32 index = sourceOffset + x;
+
+ // RenderTable only stores offsets from the original coordinates
+ uint32 sourceYIndex = y + _internalBuffer[index].y;
+ uint32 sourceXIndex = x + _internalBuffer[index].x;
+
+ destBuffer[destOffset] = sourceBuffer[sourceYIndex * _numColumns + sourceXIndex];
+ destOffset++;
+ }
+ }
+}
+
void RenderTable::generateRenderTable() {
switch (_renderState) {
case ZVision::RenderTable::PANORAMA:
@@ -177,6 +178,7 @@ void RenderTable::generateTiltLookupTable() {
float fovInRadians = (_tiltOptions.fieldOfView * M_PI / 180.0f);
float cylinderRadius = halfWidth / tan(fovInRadians);
+ _tiltOptions.gap = cylinderRadius * atan2((float)(halfHeight / cylinderRadius), 1.0f) * _tiltOptions.linearScale;
for (uint y = 0; y < _numRows; ++y) {
@@ -221,6 +223,18 @@ void RenderTable::setPanoramaReverse(bool reverse) {
_panoramaOptions.reverse = reverse;
}
+bool RenderTable::getPanoramaReverse() {
+ return _panoramaOptions.reverse;
+}
+
+void RenderTable::setPanoramaZeroPoint(uint16 point) {
+ _panoramaOptions.zeroPoint = point;
+}
+
+uint16 RenderTable::getPanoramaZeroPoint() {
+ return _panoramaOptions.zeroPoint;
+}
+
void RenderTable::setTiltFoV(float fov) {
assert(fov > 0.0f);
@@ -237,4 +251,26 @@ void RenderTable::setTiltReverse(bool reverse) {
_tiltOptions.reverse = reverse;
}
+float RenderTable::getTiltGap() {
+ return _tiltOptions.gap;
+}
+
+float RenderTable::getAngle() {
+ if (_renderState == TILT)
+ return _tiltOptions.fieldOfView;
+ else if (_renderState == PANORAMA)
+ return _panoramaOptions.fieldOfView;
+ else
+ return 1.0;
+}
+
+float RenderTable::getLinscale() {
+ if (_renderState == TILT)
+ return _tiltOptions.linearScale;
+ else if (_renderState == PANORAMA)
+ return _panoramaOptions.linearScale;
+ else
+ return 1.0;
+}
+
} // End of namespace ZVision
diff --git a/engines/zvision/graphics/render_table.h b/engines/zvision/graphics/render_table.h
index f066187ad1..7455d9ba39 100644
--- a/engines/zvision/graphics/render_table.h
+++ b/engines/zvision/graphics/render_table.h
@@ -24,7 +24,7 @@
#define ZVISION_RENDER_TABLE_H
#include "common/rect.h"
-
+#include "graphics/surface.h"
namespace ZVision {
@@ -49,6 +49,7 @@ private:
float fieldOfView;
float linearScale;
bool reverse;
+ uint16 zeroPoint;
} _panoramaOptions;
// TODO: See if tilt and panorama need to have separate options
@@ -56,25 +57,36 @@ private:
float fieldOfView;
float linearScale;
bool reverse;
+ float gap;
} _tiltOptions;
public:
- RenderState getRenderState() { return _renderState; }
+ RenderState getRenderState() {
+ return _renderState;
+ }
void setRenderState(RenderState newState);
const Common::Point convertWarpedCoordToFlatCoord(const Common::Point &point);
- void mutateImage(uint16 *sourceBuffer, uint16* destBuffer, uint32 destWidth, const Common::Rect &subRect);
+ void mutateImage(uint16 *sourceBuffer, uint16 *destBuffer, uint32 destWidth, const Common::Rect &subRect);
+ void mutateImage(Graphics::Surface *dstBuf, Graphics::Surface *srcBuf);
void generateRenderTable();
void setPanoramaFoV(float fov);
void setPanoramaScale(float scale);
void setPanoramaReverse(bool reverse);
+ void setPanoramaZeroPoint(uint16 point);
+ uint16 getPanoramaZeroPoint();
+ bool getPanoramaReverse();
void setTiltFoV(float fov);
void setTiltScale(float scale);
void setTiltReverse(bool reverse);
+ float getTiltGap();
+ float getAngle();
+ float getLinscale();
+
private:
void generatePanoramaLookupTable();
void generateTiltLookupTable();
diff --git a/engines/zvision/module.mk b/engines/zvision/module.mk
index 2e298f24c6..93fba2879d 100644
--- a/engines/zvision/module.mk
+++ b/engines/zvision/module.mk
@@ -1,32 +1,51 @@
MODULE := engines/zvision
MODULE_OBJS := \
- animation/rlf_animation.o \
- archives/zfs_archive.o \
core/console.o \
+ core/clock.o \
core/events.o \
- core/save_manager.o \
- cursors/cursor.o \
- cursors/cursor_manager.o \
detection.o \
- fonts/truetype_font.o \
+ file/lzss_read_stream.o \
+ file/save_manager.o \
+ file/search_manager.o \
+ file/zfs_archive.o \
+ graphics/cursors/cursor_manager.o \
+ graphics/cursors/cursor.o \
+ graphics/effects/fog.o \
+ graphics/effects/light.o \
+ graphics/effects/wave.o \
graphics/render_manager.o \
graphics/render_table.o \
scripting/actions.o \
scripting/control.o \
- scripting/controls/animation_control.o \
+ scripting/controls/fist_control.o \
+ scripting/controls/hotmov_control.o \
scripting/controls/input_control.o \
scripting/controls/lever_control.o \
+ scripting/controls/paint_control.o \
scripting/controls/push_toggle_control.o \
- scripting/controls/timer_node.o \
+ scripting/controls/safe_control.o \
+ scripting/controls/save_control.o \
+ scripting/controls/slot_control.o \
+ scripting/controls/titler_control.o \
+ scripting/inventory.o \
+ scripting/menu.o \
scripting/scr_file_handling.o \
scripting/script_manager.o \
+ scripting/effects/animation_effect.o \
+ scripting/effects/distort_effect.o \
+ scripting/effects/music_effect.o \
+ scripting/effects/region_effect.o \
+ scripting/effects/syncsound_effect.o \
+ scripting/effects/timer_effect.o \
+ scripting/effects/ttytext_effect.o \
+ sound/midi.o \
sound/zork_raw.o \
- strings/string_manager.o \
- utility/clock.o \
- utility/lzss_read_stream.o \
- utility/single_value_container.o \
- utility/utility.o \
+ text/string_manager.o \
+ text/subtitles.o \
+ text/text.o \
+ text/truetype_font.o \
+ video/rlf_decoder.o \
video/video.o \
video/zork_avi_decoder.o \
zvision.o
diff --git a/engines/zvision/scripting/actions.cpp b/engines/zvision/scripting/actions.cpp
index 517278e155..a61fa26223 100644
--- a/engines/zvision/scripting/actions.cpp
+++ b/engines/zvision/scripting/actions.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.
@@ -29,372 +29,1018 @@
#include "zvision/graphics/render_manager.h"
#include "zvision/sound/zork_raw.h"
#include "zvision/video/zork_avi_decoder.h"
-#include "zvision/scripting/controls/timer_node.h"
-#include "zvision/scripting/controls/animation_control.h"
+#include "zvision/file/save_manager.h"
+#include "zvision/scripting/menu.h"
+#include "zvision/scripting/effects/timer_effect.h"
+#include "zvision/scripting/effects/music_effect.h"
+#include "zvision/scripting/effects/syncsound_effect.h"
+#include "zvision/scripting/effects/animation_effect.h"
+#include "zvision/scripting/effects/distort_effect.h"
+#include "zvision/scripting/effects/ttytext_effect.h"
+#include "zvision/scripting/effects/region_effect.h"
+#include "zvision/scripting/controls/titler_control.h"
+#include "zvision/graphics/render_table.h"
+#include "zvision/graphics/graphics_effect.h"
+#include "zvision/graphics/effects/fog.h"
+#include "zvision/graphics/effects/light.h"
+#include "zvision/graphics/effects/wave.h"
+#include "zvision/graphics/cursors/cursor_manager.h"
#include "common/file.h"
#include "audio/decoders/wave.h"
-
namespace ZVision {
//////////////////////////////////////////////////////////////////////////////
// ActionAdd
//////////////////////////////////////////////////////////////////////////////
-ActionAdd::ActionAdd(const Common::String &line) {
- sscanf(line.c_str(), "%*[^(](%u,%u)", &_key, &_value);
+ActionAdd::ActionAdd(ZVision *engine, int32 slotkey, const Common::String &line) :
+ ResultAction(engine, slotkey) {
+ _key = 0;
+ _value = 0;
+
+ sscanf(line.c_str(), "%u,%d", &_key, &_value);
}
-bool ActionAdd::execute(ZVision *engine) {
- engine->getScriptManager()->addToStateValue(_key, _value);
+bool ActionAdd::execute() {
+ _engine->getScriptManager()->setStateValue(_key, _engine->getScriptManager()->getStateValue(_key) + _value);
return true;
}
-
//////////////////////////////////////////////////////////////////////////////
// ActionAssign
//////////////////////////////////////////////////////////////////////////////
-ActionAssign::ActionAssign(const Common::String &line) {
- sscanf(line.c_str(), "%*[^(](%u, %u)", &_key, &_value);
+ActionAssign::ActionAssign(ZVision *engine, int32 slotkey, const Common::String &line) :
+ ResultAction(engine, slotkey) {
+ _key = 0;
+
+ char buf[64];
+ memset(buf, 0, 64);
+ sscanf(line.c_str(), "%u, %s", &_key, buf);
+ _value = new ValueSlot(_engine->getScriptManager(), buf);
}
-bool ActionAssign::execute(ZVision *engine) {
- engine->getScriptManager()->setStateValue(_key, _value);
- return true;
+ActionAssign::~ActionAssign() {
+ if (_value)
+ delete _value;
}
+bool ActionAssign::execute() {
+ _engine->getScriptManager()->setStateValue(_key, _value->getValue());
+ return true;
+}
//////////////////////////////////////////////////////////////////////////////
// ActionAttenuate
//////////////////////////////////////////////////////////////////////////////
-ActionAttenuate::ActionAttenuate(const Common::String &line) {
- sscanf(line.c_str(), "%*[^(](%u, %d)", &_key, &_attenuation);
+ActionAttenuate::ActionAttenuate(ZVision *engine, int32 slotkey, const Common::String &line) :
+ ResultAction(engine, slotkey) {
+ _key = 0;
+ _attenuation = 0;
+
+ sscanf(line.c_str(), "%u, %d", &_key, &_attenuation);
}
-bool ActionAttenuate::execute(ZVision *engine) {
- // TODO: Implement
+bool ActionAttenuate::execute() {
+ ScriptingEffect *fx = _engine->getScriptManager()->getSideFX(_key);
+ if (fx && fx->getType() == ScriptingEffect::SCRIPTING_EFFECT_AUDIO) {
+ MusicNode *mus = (MusicNode *)fx;
+ mus->setVolume(255 - (abs(_attenuation) >> 7));
+ }
return true;
}
-
//////////////////////////////////////////////////////////////////////////////
// ActionChangeLocation
//////////////////////////////////////////////////////////////////////////////
-ActionChangeLocation::ActionChangeLocation(const Common::String &line) {
- sscanf(line.c_str(), "%*[^(](%c,%c,%c%c,%u)", &_world, &_room, &_node, &_view, &_offset);
+ActionChangeLocation::ActionChangeLocation(ZVision *engine, int32 slotkey, const Common::String &line) :
+ ResultAction(engine, slotkey) {
+ _world = 'g';
+ _room = 'a';
+ _node = 'r';
+ _view = 'y';
+ _offset = 0;
+
+ sscanf(line.c_str(), "%c, %c, %c%c, %u", &_world, &_room, &_node, &_view, &_offset);
}
-bool ActionChangeLocation::execute(ZVision *engine) {
+bool ActionChangeLocation::execute() {
// We can't directly call ScriptManager::ChangeLocationIntern() because doing so clears all the Puzzles, and thus would corrupt the current puzzle checking
- engine->getScriptManager()->changeLocation(_world, _room, _node, _view, _offset);
+ _engine->getScriptManager()->changeLocation(_world, _room, _node, _view, _offset);
// Tell the puzzle system to stop checking any more puzzles
return false;
}
-
//////////////////////////////////////////////////////////////////////////////
// ActionCrossfade
//////////////////////////////////////////////////////////////////////////////
-ActionCrossfade::ActionCrossfade(const Common::String &line) {
+ActionCrossfade::ActionCrossfade(ZVision *engine, int32 slotkey, const Common::String &line) :
+ ResultAction(engine, slotkey) {
+ _keyOne = 0;
+ _keyTwo = 0;
+ _oneStartVolume = 0;
+ _twoStartVolume = 0;
+ _oneEndVolume = 0;
+ _twoEndVolume = 0;
+ _timeInMillis = 0;
+
sscanf(line.c_str(),
- "%*[^(](%u %u %u %u %u %u %u)",
- &_keyOne, &_keyTwo, &_oneStartVolume, &_twoStartVolume, &_oneEndVolume, &_twoEndVolume, &_timeInMillis);
+ "%u %u %d %d %d %d %d",
+ &_keyOne, &_keyTwo, &_oneStartVolume, &_twoStartVolume, &_oneEndVolume, &_twoEndVolume, &_timeInMillis);
+}
+
+bool ActionCrossfade::execute() {
+ if (_keyOne) {
+ ScriptingEffect *fx = _engine->getScriptManager()->getSideFX(_keyOne);
+ if (fx && fx->getType() == ScriptingEffect::SCRIPTING_EFFECT_AUDIO) {
+ MusicNode *mus = (MusicNode *)fx;
+ if (_oneStartVolume >= 0)
+ mus->setVolume((_oneStartVolume * 255) / 100);
+
+ mus->setFade(_timeInMillis, (_oneEndVolume * 255) / 100);
+ }
+ }
+
+ if (_keyTwo) {
+ ScriptingEffect *fx = _engine->getScriptManager()->getSideFX(_keyTwo);
+ if (fx && fx->getType() == ScriptingEffect::SCRIPTING_EFFECT_AUDIO) {
+ MusicNode *mus = (MusicNode *)fx;
+ if (_twoStartVolume >= 0)
+ mus->setVolume((_twoStartVolume * 255) / 100);
+
+ mus->setFade(_timeInMillis, (_twoEndVolume * 255) / 100);
+ }
+ }
+ return true;
+}
+
+//////////////////////////////////////////////////////////////////////////////
+// ActionCursor
+//////////////////////////////////////////////////////////////////////////////
+
+ActionCursor::ActionCursor(ZVision *engine, int32 slotkey, const Common::String &line) :
+ ResultAction(engine, slotkey) {
+ Common::String up = line;
+ up.toUppercase();
+ _action = 0;
+
+ if (up[0] == 'B')
+ _action = 2;
+ else if (up[0] == 'I')
+ _action = 3;
+ else if (up[0] == 'U')
+ _action = 0;
+ else if (up[0] == 'H')
+ _action = 1;
}
-bool ActionCrossfade::execute(ZVision *engine) {
- // TODO: Implement
+bool ActionCursor::execute() {
+ switch (_action) {
+ case 1:
+ _engine->getCursorManager()->showMouse(false);
+ break;
+ default:
+ _engine->getCursorManager()->showMouse(true);
+ break;
+ }
return true;
}
+//////////////////////////////////////////////////////////////////////////////
+// ActionDelayRender
+//////////////////////////////////////////////////////////////////////////////
+
+ActionDelayRender::ActionDelayRender(ZVision *engine, int32 slotkey, const Common::String &line) :
+ ResultAction(engine, slotkey) {
+ _framesToDelay = 0;
+ sscanf(line.c_str(), "%u", &_framesToDelay);
+}
+
+bool ActionDelayRender::execute() {
+ _engine->setRenderDelay(_framesToDelay);
+ return true;
+}
//////////////////////////////////////////////////////////////////////////////
// ActionDisableControl
//////////////////////////////////////////////////////////////////////////////
-ActionDisableControl::ActionDisableControl(const Common::String &line) {
- sscanf(line.c_str(), "%*[^(](%u)", &_key);
+ActionDisableControl::ActionDisableControl(ZVision *engine, int32 slotkey, const Common::String &line) :
+ ResultAction(engine, slotkey) {
+ _key = 0;
+
+ sscanf(line.c_str(), "%u", &_key);
+}
+
+bool ActionDisableControl::execute() {
+ _engine->getScriptManager()->setStateFlag(_key, Puzzle::DISABLED);
+ return true;
+}
+
+//////////////////////////////////////////////////////////////////////////////
+// ActionDisplayMessage
+//////////////////////////////////////////////////////////////////////////////
+
+ActionDisplayMessage::ActionDisplayMessage(ZVision *engine, int32 slotkey, const Common::String &line) :
+ ResultAction(engine, slotkey) {
+ _control = 0;
+ _msgid = 0;
+
+ sscanf(line.c_str(), "%hd %hd", &_control, &_msgid);
+}
+
+bool ActionDisplayMessage::execute() {
+ Control *ctrl = _engine->getScriptManager()->getControl(_control);
+ if (ctrl && ctrl->getType() == Control::CONTROL_TITLER) {
+ TitlerControl *titler = (TitlerControl *)ctrl;
+ titler->setString(_msgid);
+ }
+ return true;
}
-bool ActionDisableControl::execute(ZVision *engine) {
- debug("Disabling control %u", _key);
-
- ScriptManager *scriptManager = engine->getScriptManager();
- scriptManager->setStateFlags(_key, scriptManager->getStateFlags(_key) | ScriptManager::DISABLED);
+//////////////////////////////////////////////////////////////////////////////
+// ActionDissolve
+//////////////////////////////////////////////////////////////////////////////
+
+ActionDissolve::ActionDissolve(ZVision *engine) :
+ ResultAction(engine, 0) {
+}
+bool ActionDissolve::execute() {
+ // Cause black screen flick
+ // _engine->getRenderManager()->bkgFill(0, 0, 0);
return true;
}
+//////////////////////////////////////////////////////////////////////////////
+// ActionDistort - only used by Zork: Nemesis for the "treatment" puzzle in the Sanitarium (aj30)
+//////////////////////////////////////////////////////////////////////////////
+
+ActionDistort::ActionDistort(ZVision *engine, int32 slotkey, const Common::String &line) :
+ ResultAction(engine, slotkey) {
+ _distSlot = 0;
+ _speed = 0;
+ _startAngle = 60.0;
+ _endAngle = 60.0;
+ _startLineScale = 1.0;
+ _endLineScale = 1.0;
+
+ sscanf(line.c_str(), "%hd %hd %f %f %f %f", &_distSlot, &_speed, &_startAngle, &_endAngle, &_startLineScale, &_endLineScale);
+}
+
+ActionDistort::~ActionDistort() {
+ _engine->getScriptManager()->killSideFx(_distSlot);
+}
+
+bool ActionDistort::execute() {
+ if (_engine->getScriptManager()->getSideFX(_distSlot))
+ return true;
+
+ _engine->getScriptManager()->addSideFX(new DistortNode(_engine, _distSlot, _speed, _startAngle, _endAngle, _startLineScale, _endLineScale));
+
+ return true;
+}
//////////////////////////////////////////////////////////////////////////////
// ActionEnableControl
//////////////////////////////////////////////////////////////////////////////
-ActionEnableControl::ActionEnableControl(const Common::String &line) {
- sscanf(line.c_str(), "%*[^(](%u)", &_key);
+ActionEnableControl::ActionEnableControl(ZVision *engine, int32 slotkey, const Common::String &line) :
+ ResultAction(engine, slotkey) {
+ _key = 0;
+
+ sscanf(line.c_str(), "%u", &_key);
+}
+
+bool ActionEnableControl::execute() {
+ _engine->getScriptManager()->unsetStateFlag(_key, Puzzle::DISABLED);
+ return true;
+}
+
+//////////////////////////////////////////////////////////////////////////////
+// ActionFlushMouseEvents
+//////////////////////////////////////////////////////////////////////////////
+
+ActionFlushMouseEvents::ActionFlushMouseEvents(ZVision *engine, int32 slotkey) :
+ ResultAction(engine, slotkey) {
}
-bool ActionEnableControl::execute(ZVision *engine) {
- debug("Enabling control %u", _key);
+bool ActionFlushMouseEvents::execute() {
+ _engine->getScriptManager()->flushEvent(Common::EVENT_LBUTTONUP);
+ _engine->getScriptManager()->flushEvent(Common::EVENT_LBUTTONDOWN);
+ return true;
+}
+
+//////////////////////////////////////////////////////////////////////////////
+// ActionInventory
+//////////////////////////////////////////////////////////////////////////////
+
+ActionInventory::ActionInventory(ZVision *engine, int32 slotkey, const Common::String &line) :
+ ResultAction(engine, slotkey) {
+ _type = -1;
+ _key = 0;
+
+ char buf[25];
+ sscanf(line.c_str(), "%24s %d", buf, &_key);
+
+ if (strcmp(buf, "add") == 0) {
+ _type = 0;
+ } else if (strcmp(buf, "addi") == 0) {
+ _type = 1;
+ } else if (strcmp(buf, "drop") == 0) {
+ _type = 2;
+ } else if (strcmp(buf, "dropi") == 0) {
+ _type = 3;
+ } else if (strcmp(buf, "cycle") == 0) {
+ _type = 4;
+ }
+
+}
+
+bool ActionInventory::execute() {
+ switch (_type) {
+ case 0: // add
+ _engine->getScriptManager()->inventoryAdd(_key);
+ break;
+ case 1: // addi
+ _engine->getScriptManager()->inventoryAdd(_engine->getScriptManager()->getStateValue(_key));
+ break;
+ case 2: // drop
+ if (_key >= 0)
+ _engine->getScriptManager()->inventoryDrop(_key);
+ else
+ _engine->getScriptManager()->inventoryDrop(_engine->getScriptManager()->getStateValue(StateKey_InventoryItem));
+ break;
+ case 3: // dropi
+ _engine->getScriptManager()->inventoryDrop(_engine->getScriptManager()->getStateValue(_key));
+ break;
+ case 4: // cycle
+ _engine->getScriptManager()->inventoryCycle();
+ break;
+ default:
+ break;
+ }
+ return true;
+}
+
+//////////////////////////////////////////////////////////////////////////////
+// ActionKill - only used by ZGI
+//////////////////////////////////////////////////////////////////////////////
- ScriptManager *scriptManager = engine->getScriptManager();
- scriptManager->setStateFlags(_key, scriptManager->getStateFlags(_key) & ~ScriptManager::DISABLED);
+ActionKill::ActionKill(ZVision *engine, int32 slotkey, const Common::String &line) :
+ ResultAction(engine, slotkey) {
+ _key = 0;
+ _type = 0;
+ char keytype[25];
+ sscanf(line.c_str(), "%24s", keytype);
+ if (keytype[0] == '"') {
+ if (!scumm_stricmp(keytype, "\"ANIM\""))
+ _type = ScriptingEffect::SCRIPTING_EFFECT_ANIM;
+ else if (!scumm_stricmp(keytype, "\"AUDIO\""))
+ _type = ScriptingEffect::SCRIPTING_EFFECT_AUDIO;
+ else if (!scumm_stricmp(keytype, "\"DISTORT\""))
+ _type = ScriptingEffect::SCRIPTING_EFFECT_DISTORT;
+ else if (!scumm_stricmp(keytype, "\"PANTRACK\""))
+ _type = ScriptingEffect::SCRIPTING_EFFECT_PANTRACK;
+ else if (!scumm_stricmp(keytype, "\"REGION\""))
+ _type = ScriptingEffect::SCRIPTING_EFFECT_REGION;
+ else if (!scumm_stricmp(keytype, "\"TIMER\""))
+ _type = ScriptingEffect::SCRIPTING_EFFECT_TIMER;
+ else if (!scumm_stricmp(keytype, "\"TTYTEXT\""))
+ _type = ScriptingEffect::SCRIPTING_EFFECT_TTYTXT;
+ else if (!scumm_stricmp(keytype, "\"ALL\""))
+ _type = ScriptingEffect::SCRIPTING_EFFECT_ALL;
+ } else
+ _key = atoi(keytype);
+}
+bool ActionKill::execute() {
+ if (_type)
+ _engine->getScriptManager()->killSideFxType((ScriptingEffect::ScriptingEffectType)_type);
+ else
+ _engine->getScriptManager()->killSideFx(_key);
return true;
}
+//////////////////////////////////////////////////////////////////////////////
+// ActionMenuBarEnable
+//////////////////////////////////////////////////////////////////////////////
+
+ActionMenuBarEnable::ActionMenuBarEnable(ZVision *engine, int32 slotkey, const Common::String &line) :
+ ResultAction(engine, slotkey) {
+ _menus = 0xFFFF;
+
+ sscanf(line.c_str(), "%hu", &_menus);
+}
+
+bool ActionMenuBarEnable::execute() {
+ _engine->getMenuHandler()->setEnable(_menus);
+ return true;
+}
//////////////////////////////////////////////////////////////////////////////
// ActionMusic
//////////////////////////////////////////////////////////////////////////////
-ActionMusic::ActionMusic(const Common::String &line) : _volume(255) {
- uint type;
- char fileNameBuffer[26];
- uint loop;
+ActionMusic::ActionMusic(ZVision *engine, int32 slotkey, const Common::String &line, bool global) :
+ ResultAction(engine, slotkey),
+ _volume(255),
+ _note(0),
+ _prog(0),
+ _universe(global) {
+ uint type = 0;
+ char fileNameBuffer[25];
+ uint loop = 0;
uint volume = 255;
- sscanf(line.c_str(), "%*[^:]:%*[^:]:%u(%u %25s %u %u)", &_key, &type, fileNameBuffer, &loop, &volume);
+ sscanf(line.c_str(), "%u %24s %u %u", &type, fileNameBuffer, &loop, &volume);
- // type 4 are midi sound effect files
+ // Type 4 actions are MIDI commands, not files. These are only used by
+ // Zork: Nemesis, for the flute and piano puzzles (tj4e and ve6f, as well
+ // as vr)
if (type == 4) {
- _soundType = Audio::Mixer::kSFXSoundType;
- _fileName = Common::String::format("midi/%s/%u.wav", fileNameBuffer, loop);
- _loop = false;
+ _midi = true;
+ int note;
+ int prog;
+ sscanf(line.c_str(), "%u %d %d %u", &type, &prog, &note, &volume);
+ _volume = volume;
+ _note = note;
+ _prog = prog;
} else {
- // TODO: See what the other types are so we can specify the correct Mixer::SoundType. In the meantime use kPlainSoundType
- _soundType = Audio::Mixer::kPlainSoundType;
+ _midi = false;
_fileName = Common::String(fileNameBuffer);
_loop = loop == 1 ? true : false;
- }
- // Volume is optional. If it doesn't appear, assume full volume
- if (volume != 255) {
- // Volume in the script files is mapped to [0, 100], but the ScummVM mixer uses [0, 255]
- _volume = volume * 255 / 100;
+ // Volume is optional. If it doesn't appear, assume full volume
+ if (volume != 255) {
+ // Volume in the script files is mapped to [0, 100], but the ScummVM mixer uses [0, 255]
+ _volume = volume * 255 / 100;
+ }
}
}
-bool ActionMusic::execute(ZVision *engine) {
- Audio::RewindableAudioStream *audioStream;
+ActionMusic::~ActionMusic() {
+ if (!_universe)
+ _engine->getScriptManager()->killSideFx(_slotKey);
+}
- if (_fileName.contains(".wav")) {
- Common::File *file = new Common::File();
- if (file->open(_fileName)) {
- audioStream = Audio::makeWAVStream(file, DisposeAfterUse::YES);
- } else {
- warning("Unable to open %s", _fileName.c_str());
- return false;
- }
- } else {
- audioStream = makeRawZorkStream(_fileName, engine);
- }
-
- if (_loop) {
- Audio::LoopingAudioStream *loopingAudioStream = new Audio::LoopingAudioStream(audioStream, 0, DisposeAfterUse::YES);
- engine->_mixer->playStream(_soundType, 0, loopingAudioStream, -1, _volume);
+bool ActionMusic::execute() {
+ if (_engine->getScriptManager()->getSideFX(_slotKey))
+ return true;
+
+ if (_midi) {
+ _engine->getScriptManager()->addSideFX(new MusicMidiNode(_engine, _slotKey, _prog, _note, _volume));
} else {
- engine->_mixer->playStream(_soundType, 0, audioStream, -1, _volume);
+ if (!_engine->getSearchManager()->hasFile(_fileName))
+ return true;
+
+ _engine->getScriptManager()->addSideFX(new MusicNode(_engine, _slotKey, _fileName, _loop, _volume));
}
return true;
}
+//////////////////////////////////////////////////////////////////////////////
+// ActionPanTrack
+//////////////////////////////////////////////////////////////////////////////
+
+ActionPanTrack::ActionPanTrack(ZVision *engine, int32 slotkey, const Common::String &line) :
+ ResultAction(engine, slotkey),
+ _pos(0),
+ _musicSlot(0) {
+
+ sscanf(line.c_str(), "%u %d", &_musicSlot, &_pos);
+}
+
+ActionPanTrack::~ActionPanTrack() {
+ _engine->getScriptManager()->killSideFx(_slotKey);
+}
+
+bool ActionPanTrack::execute() {
+ if (_engine->getScriptManager()->getSideFX(_slotKey))
+ return true;
+
+ _engine->getScriptManager()->addSideFX(new PanTrackNode(_engine, _slotKey, _musicSlot, _pos));
+
+ return true;
+}
+
+//////////////////////////////////////////////////////////////////////////////
+// ActionPreferences
+//////////////////////////////////////////////////////////////////////////////
+
+ActionPreferences::ActionPreferences(ZVision *engine, int32 slotkey, const Common::String &line) :
+ ResultAction(engine, slotkey) {
+ if (line.compareToIgnoreCase("save") == 0)
+ _save = true;
+ else
+ _save = false;
+}
+
+bool ActionPreferences::execute() {
+ if (_save)
+ _engine->saveSettings();
+ else
+ _engine->loadSettings();
+
+ return true;
+}
//////////////////////////////////////////////////////////////////////////////
// ActionPreloadAnimation
//////////////////////////////////////////////////////////////////////////////
-ActionPreloadAnimation::ActionPreloadAnimation(const Common::String &line) {
- char fileName[26];
+ActionPreloadAnimation::ActionPreloadAnimation(ZVision *engine, int32 slotkey, const Common::String &line) :
+ ResultAction(engine, slotkey) {
+ _mask = 0;
+ _framerate = 0;
- // The two %*u are always 0 and dont seem to have a use
- sscanf(line.c_str(), "%*[^:]:%*[^:]:%u(%25s %*u %*u %u %u)", &_key, fileName, &_mask, &_framerate);
+ char fileName[25];
+
+ // The two %*u are usually 0 and dont seem to have a use
+ sscanf(line.c_str(), "%24s %*u %*u %d %d", fileName, &_mask, &_framerate);
+
+ // Mask 0 means "no transparency" in this case. Since we use a common blitting
+ // code for images and animations, we set it to -1 to avoid confusion with
+ // color 0, which is used as a mask in some images
+ if (_mask == 0)
+ _mask = -1;
_fileName = Common::String(fileName);
}
-bool ActionPreloadAnimation::execute(ZVision *engine) {
- // TODO: We ignore the mask and framerate atm. Mask refers to a key color used for binary alpha. We assume the framerate is the default framerate embedded in the videos
-
- // TODO: Check if the Control already exists
+ActionPreloadAnimation::~ActionPreloadAnimation() {
+ _engine->getScriptManager()->deleteSideFx(_slotKey);
+}
- // Create the control, but disable it until PlayPreload is called
- ScriptManager *scriptManager = engine->getScriptManager();
- scriptManager->addControl(new AnimationControl(engine, _key, _fileName));
- scriptManager->setStateFlags(_key, scriptManager->getStateFlags(_key) | ScriptManager::DISABLED);
+bool ActionPreloadAnimation::execute() {
+ AnimationEffect *nod = (AnimationEffect *)_engine->getScriptManager()->getSideFX(_slotKey);
+ if (!nod) {
+ nod = new AnimationEffect(_engine, _slotKey, _fileName, _mask, _framerate, false);
+ _engine->getScriptManager()->addSideFX(nod);
+ } else
+ nod->stop();
+ _engine->getScriptManager()->setStateValue(_slotKey, 2);
return true;
}
+//////////////////////////////////////////////////////////////////////////////
+// ActionUnloadAnimation
+//////////////////////////////////////////////////////////////////////////////
+
+ActionUnloadAnimation::ActionUnloadAnimation(ZVision *engine, int32 slotkey, const Common::String &line) :
+ ResultAction(engine, slotkey) {
+ _key = 0;
+
+ sscanf(line.c_str(), "%u", &_key);
+}
+
+bool ActionUnloadAnimation::execute() {
+ AnimationEffect *nod = (AnimationEffect *)_engine->getScriptManager()->getSideFX(_key);
+
+ if (nod && nod->getType() == ScriptingEffect::SCRIPTING_EFFECT_ANIM)
+ _engine->getScriptManager()->deleteSideFx(_key);
+
+ return true;
+}
//////////////////////////////////////////////////////////////////////////////
// ActionPlayAnimation
//////////////////////////////////////////////////////////////////////////////
-ActionPlayAnimation::ActionPlayAnimation(const Common::String &line) {
- char fileName[26];
+ActionPlayAnimation::ActionPlayAnimation(ZVision *engine, int32 slotkey, const Common::String &line) :
+ ResultAction(engine, slotkey) {
+ _x = 0;
+ _y = 0;
+ _x2 = 0;
+ _y2 = 0;
+ _start = 0;
+ _end = 0;
+ _loopCount = 0;
+ _mask = 0;
+ _framerate = 0;
+
+ char fileName[25];
// The two %*u are always 0 and dont seem to have a use
sscanf(line.c_str(),
- "%*[^:]:%*[^:]:%u(%25s %u %u %u %u %u %u %u %*u %*u %u %u)",
- &_key, fileName, &_x, &_y, &_width, &_height, &_start, &_end, &_loopCount, &_mask, &_framerate);
+ "%24s %u %u %u %u %u %u %d %*u %*u %d %d",
+ fileName, &_x, &_y, &_x2, &_y2, &_start, &_end, &_loopCount, &_mask, &_framerate);
+
+ // Mask 0 means "no transparency" in this case. Since we use a common blitting
+ // code for images and animations, we set it to -1 to avoid confusion with
+ // color 0, which is used as a mask in some images
+ if (_mask == 0)
+ _mask = -1;
_fileName = Common::String(fileName);
}
-bool ActionPlayAnimation::execute(ZVision *engine) {
- // TODO: Implement
- return true;
+ActionPlayAnimation::~ActionPlayAnimation() {
+ _engine->getScriptManager()->deleteSideFx(_slotKey);
}
+bool ActionPlayAnimation::execute() {
+ AnimationEffect *nod = (AnimationEffect *)_engine->getScriptManager()->getSideFX(_slotKey);
+
+ if (!nod) {
+ nod = new AnimationEffect(_engine, _slotKey, _fileName, _mask, _framerate);
+ _engine->getScriptManager()->addSideFX(nod);
+ } else
+ nod->stop();
+
+ if (nod)
+ nod->addPlayNode(_slotKey, _x, _y, _x2, _y2, _start, _end, _loopCount);
+
+ return true;
+}
//////////////////////////////////////////////////////////////////////////////
// ActionPlayPreloadAnimation
//////////////////////////////////////////////////////////////////////////////
-ActionPlayPreloadAnimation::ActionPlayPreloadAnimation(const Common::String &line) {
+ActionPlayPreloadAnimation::ActionPlayPreloadAnimation(ZVision *engine, int32 slotkey, const Common::String &line) :
+ ResultAction(engine, slotkey) {
+ _controlKey = 0;
+ _x1 = 0;
+ _y1 = 0;
+ _x2 = 0;
+ _y2 = 0;
+ _startFrame = 0;
+ _endFrame = 0;
+ _loopCount = 0;
+
sscanf(line.c_str(),
- "%*[^:]:%*[^:]:%u(%u %u %u %u %u %u %u %u)",
- &_animationKey, &_controlKey, &_x1, &_y1, &_x2, &_y2, &_startFrame, &_endFrame, &_loopCount);
+ "%u %u %u %u %u %u %u %u",
+ &_controlKey, &_x1, &_y1, &_x2, &_y2, &_startFrame, &_endFrame, &_loopCount);
}
-bool ActionPlayPreloadAnimation::execute(ZVision *engine) {
- // Find the control
- AnimationControl *control = (AnimationControl *)engine->getScriptManager()->getControl(_controlKey);
+bool ActionPlayPreloadAnimation::execute() {
+ AnimationEffect *nod = (AnimationEffect *)_engine->getScriptManager()->getSideFX(_controlKey);
- // Set the needed values within the control
- control->setAnimationKey(_animationKey);
- control->setLoopCount(_loopCount);
- control->setXPos(_x1);
- control->setYPost(_y1);
-
- // Enable the control. ScriptManager will take care of the rest
- control->enable();
+ if (nod)
+ nod->addPlayNode(_slotKey, _x1, _y1, _x2, _y2, _startFrame, _endFrame, _loopCount);
return true;
}
-
//////////////////////////////////////////////////////////////////////////////
// ActionQuit
//////////////////////////////////////////////////////////////////////////////
-bool ActionQuit::execute(ZVision *engine) {
- engine->quitGame();
+bool ActionQuit::execute() {
+ _engine->quitGame();
return true;
}
+//////////////////////////////////////////////////////////////////////////////
+// ActionRegion - only used by Zork: Nemesis
+//////////////////////////////////////////////////////////////////////////////
+
+ActionRegion::ActionRegion(ZVision *engine, int32 slotkey, const Common::String &line) :
+ ResultAction(engine, slotkey) {
+ _delay = 0;
+ _type = 0;
+ _unk1 = 0;
+ _unk2 = 0;
+
+ char art[64];
+ char custom[64];
+
+ int32 x1 = 0, x2 = 0, y1 = 0, y2 = 0;
+
+ sscanf(line.c_str(), "%s %d %d %d %d %hu %hu %hu %hu %s", art, &x1, &y1, &x2, &y2, &_delay, &_type, &_unk1, &_unk2, custom);
+ _art = Common::String(art);
+ _custom = Common::String(custom);
+ _rect = Common::Rect(x1, y1, x2 + 1, y2 + 1);
+}
+
+ActionRegion::~ActionRegion() {
+ _engine->getScriptManager()->killSideFx(_slotKey);
+}
+
+bool ActionRegion::execute() {
+ if (_engine->getScriptManager()->getSideFX(_slotKey))
+ return true;
+
+ GraphicsEffect *effect = NULL;
+ switch (_type) {
+ case 0: {
+ uint16 centerX, centerY, frames;
+ double amplitude, waveln, speed;
+ sscanf(_custom.c_str(), "%hu,%hu,%hu,%lf,%lf,%lf,", &centerX, &centerY, &frames, &amplitude, &waveln, &speed);
+ effect = new WaveFx(_engine, _slotKey, _rect, _unk1, frames, centerX, centerY, amplitude, waveln, speed);
+ }
+ break;
+ case 1: {
+ uint16 aX, aY, aD;
+ if (_engine->getRenderManager()->getRenderTable()->getRenderState() == RenderTable::PANORAMA)
+ sscanf(_art.c_str(), "useart[%hu,%hu,%hu]", &aY, &aX, &aD);
+ else
+ sscanf(_art.c_str(), "useart[%hu,%hu,%hu]", &aX, &aY, &aD);
+ int8 minD;
+ int8 maxD;
+ EffectMap *_map = _engine->getRenderManager()->makeEffectMap(Common::Point(aX, aY), aD, _rect, &minD, &maxD);
+ effect = new LightFx(_engine, _slotKey, _rect, _unk1, _map, atoi(_custom.c_str()), minD, maxD);
+ }
+ break;
+ case 9: {
+ int16 dum1;
+ int32 dum2;
+ char buf[64];
+ sscanf(_custom.c_str(), "%hd,%d,%s", &dum1, &dum2, buf);
+ Graphics::Surface tempMask;
+ _engine->getRenderManager()->readImageToSurface(_art, tempMask);
+ if (_rect.width() != tempMask.w)
+ _rect.setWidth(tempMask.w);
+ if (_rect.height() != tempMask.h)
+ _rect.setHeight(tempMask.h);
+
+ EffectMap *_map = _engine->getRenderManager()->makeEffectMap(tempMask, 0);
+ effect = new FogFx(_engine, _slotKey, _rect, _unk1, _map, Common::String(buf));
+ }
+ break;
+ default:
+ break;
+ }
+
+ if (effect) {
+ _engine->getScriptManager()->addSideFX(new RegionNode(_engine, _slotKey, effect, _delay));
+ _engine->getRenderManager()->addEffect(effect);
+ }
+
+ return true;
+}
//////////////////////////////////////////////////////////////////////////////
// ActionRandom
//////////////////////////////////////////////////////////////////////////////
-ActionRandom::ActionRandom(const Common::String &line) {
- sscanf(line.c_str(), "%*[^:]:%*[^:]:%u, %u)", &_key, &_max);
+ActionRandom::ActionRandom(ZVision *engine, int32 slotkey, const Common::String &line) :
+ ResultAction(engine, slotkey) {
+ char maxBuffer[64];
+ memset(maxBuffer, 0, 64);
+ sscanf(line.c_str(), "%s", maxBuffer);
+ _max = new ValueSlot(_engine->getScriptManager(), maxBuffer);
+}
+
+ActionRandom::~ActionRandom() {
+ if (_max)
+ delete _max;
}
-bool ActionRandom::execute(ZVision *engine) {
- uint randNumber = engine->getRandomSource()->getRandomNumber(_max);
- engine->getScriptManager()->setStateValue(_key, randNumber);
+bool ActionRandom::execute() {
+ uint randNumber = _engine->getRandomSource()->getRandomNumber(_max->getValue());
+ _engine->getScriptManager()->setStateValue(_slotKey, randNumber);
return true;
}
+//////////////////////////////////////////////////////////////////////////////
+// ActionRestoreGame
+//////////////////////////////////////////////////////////////////////////////
+
+ActionRestoreGame::ActionRestoreGame(ZVision *engine, int32 slotkey, const Common::String &line) :
+ ResultAction(engine, slotkey) {
+ char buf[128];
+ sscanf(line.c_str(), "%s", buf);
+ _fileName = Common::String(buf);
+}
+
+bool ActionRestoreGame::execute() {
+ _engine->getSaveManager()->loadGame(_fileName);
+ return false;
+}
+
+//////////////////////////////////////////////////////////////////////////////
+// ActionRotateTo
+//////////////////////////////////////////////////////////////////////////////
+
+ActionRotateTo::ActionRotateTo(ZVision *engine, int32 slotkey, const Common::String &line) :
+ ResultAction(engine, slotkey) {
+ _time = 0;
+ _toPos = 0;
+
+ sscanf(line.c_str(), "%d, %d", &_toPos, &_time);
+}
+
+bool ActionRotateTo::execute() {
+ _engine->getRenderManager()->rotateTo(_toPos, _time);
+
+ return true;
+}
//////////////////////////////////////////////////////////////////////////////
// ActionSetPartialScreen
//////////////////////////////////////////////////////////////////////////////
-ActionSetPartialScreen::ActionSetPartialScreen(const Common::String &line) {
- char fileName[26];
- uint color;
+ActionSetPartialScreen::ActionSetPartialScreen(ZVision *engine, int32 slotkey, const Common::String &line) :
+ ResultAction(engine, slotkey) {
+ _x = 0;
+ _y = 0;
- sscanf(line.c_str(), "%*[^(](%u %u %25s %*u %u)", &_x, &_y, fileName, &color);
+ char fileName[25];
+
+ sscanf(line.c_str(), "%u %u %24s %*u %d", &_x, &_y, fileName, &_backgroundColor);
_fileName = Common::String(fileName);
- if (color > 0xFFFF) {
+ if (_backgroundColor > 65535) {
warning("Background color for ActionSetPartialScreen is bigger than a uint16");
}
- _backgroundColor = color;
}
-bool ActionSetPartialScreen::execute(ZVision *engine) {
- RenderManager *renderManager = engine->getRenderManager();
-
- if (_backgroundColor > 0) {
- renderManager->clearWorkingWindowTo555Color(_backgroundColor);
+bool ActionSetPartialScreen::execute() {
+ RenderManager *renderManager = _engine->getRenderManager();
+
+ if (_engine->getGameId() == GID_NEMESIS) {
+ if (_backgroundColor)
+ renderManager->renderImageToBackground(_fileName, _x, _y, 0, 0);
+ else
+ renderManager->renderImageToBackground(_fileName, _x, _y);
+ } else {
+ if (_backgroundColor >= 0)
+ renderManager->renderImageToBackground(_fileName, _x, _y, _backgroundColor);
+ else if (_backgroundColor == -2)
+ renderManager->renderImageToBackground(_fileName, _x, _y, 0, 0);
+ else
+ renderManager->renderImageToBackground(_fileName, _x, _y);
}
- renderManager->renderImageToScreen(_fileName, _x, _y);
return true;
}
-
//////////////////////////////////////////////////////////////////////////////
// ActionSetScreen
//////////////////////////////////////////////////////////////////////////////
-ActionSetScreen::ActionSetScreen(const Common::String &line) {
- char fileName[26];
- sscanf(line.c_str(), "%*[^(](%25[^)])", fileName);
+ActionSetScreen::ActionSetScreen(ZVision *engine, int32 slotkey, const Common::String &line) :
+ ResultAction(engine, slotkey) {
+ char fileName[25];
+ sscanf(line.c_str(), "%24s", fileName);
_fileName = Common::String(fileName);
}
-bool ActionSetScreen::execute(ZVision *engine) {
- engine->getRenderManager()->setBackgroundImage(_fileName);
+bool ActionSetScreen::execute() {
+ _engine->getRenderManager()->setBackgroundImage(_fileName);
return true;
}
+//////////////////////////////////////////////////////////////////////////////
+// ActionStop
+//////////////////////////////////////////////////////////////////////////////
+
+ActionStop::ActionStop(ZVision *engine, int32 slotkey, const Common::String &line) :
+ ResultAction(engine, slotkey) {
+ _key = 0;
+ sscanf(line.c_str(), "%u", &_key);
+}
+
+bool ActionStop::execute() {
+ _engine->getScriptManager()->stopSideFx(_key);
+ return true;
+}
//////////////////////////////////////////////////////////////////////////////
// ActionStreamVideo
//////////////////////////////////////////////////////////////////////////////
-ActionStreamVideo::ActionStreamVideo(const Common::String &line) {
- char fileName[26];
- uint skippable;
+ActionStreamVideo::ActionStreamVideo(ZVision *engine, int32 slotkey, const Common::String &line) :
+ ResultAction(engine, slotkey) {
+ _x1 = 0;
+ _x2 = 0;
+ _y1 = 0;
+ _y2 = 0;
+ _flags = 0;
+
+ char fileName[25];
+ uint skipline = 0; //skipline - render video with skip every second line, not skippable.
- sscanf(line.c_str(), "%*[^(](%25s %u %u %u %u %u %u)", fileName, &_x1, &_y1, &_x2, &_y2, &_flags, &skippable);
+ sscanf(line.c_str(), "%24s %u %u %u %u %u %u", fileName, &_x1, &_y1, &_x2, &_y2, &_flags, &skipline);
_fileName = Common::String(fileName);
- _skippable = (skippable == 0) ? false : true;
+ _skippable = true;
}
-bool ActionStreamVideo::execute(ZVision *engine) {
+bool ActionStreamVideo::execute() {
ZorkAVIDecoder decoder;
- if (!decoder.loadFile(_fileName)) {
- return true;
- }
+ Common::File *_file = _engine->getSearchManager()->openFile(_fileName);
+
+ if (_file) {
+ if (!decoder.loadStream(_file)) {
+ return true;
+ }
+
+ _engine->getCursorManager()->showMouse(false);
+
+ Common::Rect destRect = Common::Rect(_x1, _y1, _x2 + 1, _y2 + 1);
+
+ Common::String subname = _fileName;
+ subname.setChar('s', subname.size() - 3);
+ subname.setChar('u', subname.size() - 2);
+ subname.setChar('b', subname.size() - 1);
+
+ Subtitle *sub = NULL;
+
+ if (_engine->getSearchManager()->hasFile(subname))
+ sub = new Subtitle(_engine, subname);
+
+ _engine->playVideo(decoder, destRect, _skippable, sub);
- Common::Rect destRect;
- if ((_flags & DIFFERENT_DIMENSIONS) == DIFFERENT_DIMENSIONS) {
- destRect = Common::Rect(_x1, _y1, _x2, _y2);
+ _engine->getCursorManager()->showMouse(true);
+
+ if (sub)
+ delete sub;
}
- engine->playVideo(decoder, destRect, _skippable);
return true;
}
+//////////////////////////////////////////////////////////////////////////////
+// ActionSyncSound
+//////////////////////////////////////////////////////////////////////////////
+
+ActionSyncSound::ActionSyncSound(ZVision *engine, int32 slotkey, const Common::String &line) :
+ ResultAction(engine, slotkey) {
+ _syncto = 0;
+
+ char fileName[25];
+ int notUsed = 0;
+
+ sscanf(line.c_str(), "%d %d %24s", &_syncto, &notUsed, fileName);
+
+ _fileName = Common::String(fileName);
+}
+
+bool ActionSyncSound::execute() {
+ ScriptingEffect *fx = _engine->getScriptManager()->getSideFX(_syncto);
+ if (!fx)
+ return true;
+
+ if (!(fx->getType() & ScriptingEffect::SCRIPTING_EFFECT_ANIM))
+ return true;
+
+ _engine->getScriptManager()->addSideFX(new SyncSoundNode(_engine, _slotKey, _fileName, _syncto));
+ return true;
+}
//////////////////////////////////////////////////////////////////////////////
// ActionTimer
//////////////////////////////////////////////////////////////////////////////
-ActionTimer::ActionTimer(const Common::String &line) {
- sscanf(line.c_str(), "%*[^:]:%*[^:]:%u(%u)", &_key, &_time);
+ActionTimer::ActionTimer(ZVision *engine, int32 slotkey, const Common::String &line) :
+ ResultAction(engine, slotkey) {
+ char timeBuffer[64];
+ memset(timeBuffer, 0, 64);
+ sscanf(line.c_str(), "%s", timeBuffer);
+ _time = new ValueSlot(_engine->getScriptManager(), timeBuffer);
}
-bool ActionTimer::execute(ZVision *engine) {
- engine->getScriptManager()->addControl(new TimerNode(engine, _key, _time));
+ActionTimer::~ActionTimer() {
+ if (_time)
+ delete _time;
+ _engine->getScriptManager()->killSideFx(_slotKey);
+}
+
+bool ActionTimer::execute() {
+ if (_engine->getScriptManager()->getSideFX(_slotKey))
+ return true;
+ _engine->getScriptManager()->addSideFX(new TimerNode(_engine, _slotKey, _time->getValue()));
+ return true;
+}
+
+//////////////////////////////////////////////////////////////////////////////
+// ActionTtyText
+//////////////////////////////////////////////////////////////////////////////
+
+ActionTtyText::ActionTtyText(ZVision *engine, int32 slotkey, const Common::String &line) :
+ ResultAction(engine, slotkey) {
+ _delay = 0;
+
+ char filename[64];
+ int32 x1 = 0, y1 = 0, x2 = 0, y2 = 0;
+ sscanf(line.c_str(), "%d %d %d %d %64s %u", &x1, &y1, &x2, &y2, filename, &_delay);
+ _r = Common::Rect(x1, y1, x2, y2);
+ _filename = Common::String(filename);
+}
+
+ActionTtyText::~ActionTtyText() {
+ _engine->getScriptManager()->killSideFx(_slotKey);
+}
+
+bool ActionTtyText::execute() {
+ if (_engine->getScriptManager()->getSideFX(_slotKey))
+ return true;
+ _engine->getScriptManager()->addSideFX(new ttyTextNode(_engine, _slotKey, _filename, _r, _delay));
return true;
}
diff --git a/engines/zvision/scripting/actions.h b/engines/zvision/scripting/actions.h
index 01457d21cc..8d43309b74 100644
--- a/engines/zvision/scripting/actions.h
+++ b/engines/zvision/scripting/actions.h
@@ -24,14 +24,15 @@
#define ZVISION_ACTIONS_H
#include "common/str.h"
+#include "common/rect.h"
#include "audio/mixer.h"
-
namespace ZVision {
// Forward declaration of ZVision. This file is included before ZVision is declared
class ZVision;
+class ValueSlot;
/**
* The base class that represents any action that a Puzzle can take.
@@ -39,6 +40,7 @@ class ZVision;
*/
class ResultAction {
public:
+ ResultAction(ZVision *engine, int32 slotkey) : _engine(engine), _slotKey(slotkey) {}
virtual ~ResultAction() {}
/**
* This is called by the script system whenever a Puzzle's criteria are found to be true.
@@ -48,75 +50,47 @@ public:
* @param engine A pointer to the base engine so the ResultAction can access all the necessary methods
* @return Should the script system continue to test any remaining puzzles (true) or immediately break and go on to the next frame (false)
*/
- virtual bool execute(ZVision *engine) = 0;
-};
-
-
-// The different types of actions
-// DEBUG,
-// DISABLE_CONTROL,
-// DISABLE_VENUS,
-// DISPLAY_MESSAGE,
-// DISSOLVE,
-// DISTORT,
-// ENABLE_CONTROL,
-// FLUSH_MOUSE_EVENTS,
-// INVENTORY,
-// KILL,
-// MENU_BAR_ENABLE,
-// MUSIC,
-// PAN_TRACK,
-// PLAY_PRELOAD,
-// PREFERENCES,
-// QUIT,
-// RANDOM,
-// REGION,
-// RESTORE_GAME,
-// ROTATE_TO,
-// SAVE_GAME,
-// SET_PARTIAL_SCREEN,
-// SET_SCREEN,
-// SET_VENUS,
-// STOP,
-// STREAM_VIDEO,
-// SYNC_SOUND,
-// TTY_TEXT,
-// UNIVERSE_MUSIC,
+ virtual bool execute() = 0;
+protected:
+ ZVision *_engine;
+ int32 _slotKey;
+};
class ActionAdd : public ResultAction {
public:
- ActionAdd(const Common::String &line);
- bool execute(ZVision *engine);
+ ActionAdd(ZVision *engine, int32 slotkey, const Common::String &line);
+ bool execute();
private:
uint32 _key;
- uint _value;
+ int _value;
};
class ActionAssign : public ResultAction {
public:
- ActionAssign(const Common::String &line);
- bool execute(ZVision *engine);
+ ActionAssign(ZVision *engine, int32 slotkey, const Common::String &line);
+ ~ActionAssign();
+ bool execute();
private:
uint32 _key;
- uint _value;
+ ValueSlot *_value;
};
class ActionAttenuate : public ResultAction {
public:
- ActionAttenuate(const Common::String &line);
- bool execute(ZVision *engine);
+ ActionAttenuate(ZVision *engine, int32 slotkey, const Common::String &line);
+ bool execute();
private:
uint32 _key;
- int _attenuation;
+ int32 _attenuation;
};
class ActionChangeLocation : public ResultAction {
public:
- ActionChangeLocation(const Common::String &line);
- bool execute(ZVision *engine);
+ ActionChangeLocation(ZVision *engine, int32 slotkey, const Common::String &line);
+ bool execute();
private:
char _world;
@@ -128,121 +102,169 @@ private:
class ActionCrossfade : public ResultAction {
public:
- ActionCrossfade(const Common::String &line);
- bool execute(ZVision *engine);
+ ActionCrossfade(ZVision *engine, int32 slotkey, const Common::String &line);
+ bool execute();
private:
uint32 _keyOne;
uint32 _keyTwo;
- uint _oneStartVolume;
- uint _twoStartVolume;
- uint _oneEndVolume;
- uint _twoEndVolume;
- uint _timeInMillis;
+ int32 _oneStartVolume;
+ int32 _twoStartVolume;
+ int32 _oneEndVolume;
+ int32 _twoEndVolume;
+ int32 _timeInMillis;
};
-class ActionDebug : public ResultAction {
+class ActionCursor : public ResultAction {
public:
- ActionDebug(const Common::String &line);
- bool execute(ZVision *engine);
+ ActionCursor(ZVision *engine, int32 slotkey, const Common::String &line);
+ bool execute();
private:
+ uint8 _action;
};
class ActionDelayRender : public ResultAction {
public:
- ActionDelayRender(const Common::String &line);
- bool execute(ZVision *engine);
+ ActionDelayRender(ZVision *engine, int32 slotkey, const Common::String &line);
+ bool execute();
private:
- // TODO: Check if this should actually be frames or if it should be milliseconds/seconds
- uint32 framesToDelay;
+ uint32 _framesToDelay;
};
class ActionDisableControl : public ResultAction {
public:
- ActionDisableControl(const Common::String &line);
- bool execute(ZVision *engine);
+ ActionDisableControl(ZVision *engine, int32 slotkey, const Common::String &line);
+ bool execute();
private:
uint32 _key;
};
-class ActionDisableVenus : public ResultAction {
+class ActionDisplayMessage : public ResultAction {
public:
- ActionDisableVenus(const Common::String &line);
- bool execute(ZVision *engine);
+ ActionDisplayMessage(ZVision *engine, int32 slotkey, const Common::String &line);
+ bool execute();
private:
+ int16 _control;
+ int16 _msgid;
};
-class ActionDisplayMessage : public ResultAction {
+class ActionDissolve : public ResultAction {
public:
- ActionDisplayMessage(const Common::String &line);
- bool execute(ZVision *engine);
+ ActionDissolve(ZVision *engine);
+ bool execute();
+};
+
+class ActionDistort : public ResultAction {
+public:
+ ActionDistort(ZVision *engine, int32 slotkey, const Common::String &line);
+ ~ActionDistort();
+ bool execute();
private:
+ int16 _distSlot;
+ int16 _speed;
+ float _startAngle;
+ float _endAngle;
+ float _startLineScale;
+ float _endLineScale;
};
-class ActionDissolve : public ResultAction {
+class ActionEnableControl : public ResultAction {
public:
- ActionDissolve();
- bool execute(ZVision *engine);
+ ActionEnableControl(ZVision *engine, int32 slotkey, const Common::String &line);
+ bool execute();
+
+private:
+ uint32 _key;
};
-class ActionDistort : public ResultAction {
+class ActionFlushMouseEvents : public ResultAction {
public:
- ActionDistort(const Common::String &line);
- bool execute(ZVision *engine);
+ ActionFlushMouseEvents(ZVision *engine, int32 slotkey);
+ bool execute();
+};
+class ActionInventory : public ResultAction {
+public:
+ ActionInventory(ZVision *engine, int32 slotkey, const Common::String &line);
+ bool execute();
private:
+ int8 _type;
+ int32 _key;
};
-class ActionEnableControl : public ResultAction {
+class ActionKill : public ResultAction {
public:
- ActionEnableControl(const Common::String &line);
- bool execute(ZVision *engine);
+ ActionKill(ZVision *engine, int32 slotkey, const Common::String &line);
+ bool execute();
private:
uint32 _key;
+ uint32 _type;
+};
+
+class ActionMenuBarEnable : public ResultAction {
+public:
+ ActionMenuBarEnable(ZVision *engine, int32 slotkey, const Common::String &line);
+ bool execute();
+private:
+ uint16 _menus;
};
class ActionMusic : public ResultAction {
public:
- ActionMusic(const Common::String &line);
- bool execute(ZVision *engine);
+ ActionMusic(ZVision *engine, int32 slotkey, const Common::String &line, bool global);
+ ~ActionMusic();
+ bool execute();
private:
- uint32 _key;
- Audio::Mixer::SoundType _soundType;
Common::String _fileName;
bool _loop;
byte _volume;
+ bool _universe;
+ bool _midi;
+ int8 _note;
+ int8 _prog;
+};
+
+class ActionPanTrack : public ResultAction {
+public:
+ ActionPanTrack(ZVision *engine, int32 slotkey, const Common::String &line);
+ ~ActionPanTrack();
+ bool execute();
+
+private:
+ int32 _pos;
+ uint32 _musicSlot;
};
class ActionPlayAnimation : public ResultAction {
public:
- ActionPlayAnimation(const Common::String &line);
- bool execute(ZVision *engine);
+ ActionPlayAnimation(ZVision *engine, int32 slotkey, const Common::String &line);
+ ~ActionPlayAnimation();
+ bool execute();
private:
- uint32 _key;
Common::String _fileName;
uint32 _x;
uint32 _y;
- uint32 _width;
- uint32 _height;
+ uint32 _x2;
+ uint32 _y2;
uint32 _start;
uint32 _end;
- uint _mask;
- uint _framerate;
- uint _loopCount;
+ int32 _mask;
+ int32 _framerate;
+ int32 _loopCount;
};
class ActionPlayPreloadAnimation : public ResultAction {
public:
- ActionPlayPreloadAnimation(const Common::String &line);
- bool execute(ZVision *engine);
+ ActionPlayPreloadAnimation(ZVision *engine, int32 slotkey, const Common::String &line);
+ bool execute();
private:
uint32 _animationKey;
@@ -258,64 +280,119 @@ private:
class ActionPreloadAnimation : public ResultAction {
public:
- ActionPreloadAnimation(const Common::String &line);
- bool execute(ZVision *engine);
+ ActionPreloadAnimation(ZVision *engine, int32 slotkey, const Common::String &line);
+ ~ActionPreloadAnimation();
+ bool execute();
private:
- uint32 _key;
Common::String _fileName;
- uint _mask;
- uint _framerate;
+ int32 _mask;
+ int32 _framerate;
+};
+
+class ActionPreferences : public ResultAction {
+public:
+ ActionPreferences(ZVision *engine, int32 slotkey, const Common::String &line);
+ bool execute();
+
+private:
+ bool _save;
};
class ActionQuit : public ResultAction {
public:
- ActionQuit() {}
- bool execute(ZVision *engine);
+ ActionQuit(ZVision *engine, int32 slotkey) : ResultAction(engine, slotkey) {}
+ bool execute();
};
-// TODO: See if this exists in ZGI. It doesn't in ZNem
+class ActionRegion : public ResultAction {
+public:
+ ActionRegion(ZVision *engine, int32 slotkey, const Common::String &line);
+ ~ActionRegion();
+ bool execute();
+
+private:
+ Common::String _art;
+ Common::String _custom;
+ Common::Rect _rect;
+ uint16 _delay;
+ uint16 _type;
+ uint16 _unk1;
+ uint16 _unk2;
+};
+
+// Only used by ZGI (locations cd6e, cd6k, dg2f, dg4e, dv1j)
class ActionUnloadAnimation : public ResultAction {
public:
- ActionUnloadAnimation(const Common::String &line);
- bool execute(ZVision *engine);
+ ActionUnloadAnimation(ZVision *engine, int32 slotkey, const Common::String &line);
+ bool execute();
+private:
+ uint32 _key;
};
class ActionRandom : public ResultAction {
public:
- ActionRandom(const Common::String &line);
- bool execute(ZVision *engine);
+ ActionRandom(ZVision *engine, int32 slotkey, const Common::String &line);
+ ~ActionRandom();
+ bool execute();
private:
- uint32 _key;
- uint _max;
+ ValueSlot *_max;
+};
+
+class ActionRestoreGame : public ResultAction {
+public:
+ ActionRestoreGame(ZVision *engine, int32 slotkey, const Common::String &line);
+ bool execute();
+
+private:
+ Common::String _fileName;
+};
+
+class ActionRotateTo : public ResultAction {
+public:
+ ActionRotateTo(ZVision *engine, int32 slotkey, const Common::String &line);
+ bool execute();
+
+private:
+ int32 _toPos;
+ int32 _time;
};
class ActionSetPartialScreen : public ResultAction {
public:
- ActionSetPartialScreen(const Common::String &line);
- bool execute(ZVision *engine);
+ ActionSetPartialScreen(ZVision *engine, int32 slotkey, const Common::String &line);
+ bool execute();
private:
uint _x;
uint _y;
Common::String _fileName;
- uint16 _backgroundColor;
+ int32 _backgroundColor;
};
class ActionSetScreen : public ResultAction {
public:
- ActionSetScreen(const Common::String &line);
- bool execute(ZVision *engine);
+ ActionSetScreen(ZVision *engine, int32 slotkey, const Common::String &line);
+ bool execute();
private:
Common::String _fileName;
};
+class ActionStop : public ResultAction {
+public:
+ ActionStop(ZVision *engine, int32 slotkey, const Common::String &line);
+ bool execute();
+
+private:
+ uint32 _key;
+};
+
class ActionStreamVideo : public ResultAction {
public:
- ActionStreamVideo(const Common::String &line);
- bool execute(ZVision *engine);
+ ActionStreamVideo(ZVision *engine, int32 slotkey, const Common::String &line);
+ bool execute();
private:
enum {
@@ -331,16 +408,36 @@ private:
bool _skippable;
};
-class ActionTimer : public ResultAction {
+class ActionSyncSound : public ResultAction {
public:
- ActionTimer(const Common::String &line);
- bool execute(ZVision *engine);
+ ActionSyncSound(ZVision *engine, int32 slotkey, const Common::String &line);
+ bool execute();
private:
- uint32 _key;
- uint _time;
+ int _syncto;
+ Common::String _fileName;
};
+class ActionTimer : public ResultAction {
+public:
+ ActionTimer(ZVision *engine, int32 slotkey, const Common::String &line);
+ ~ActionTimer();
+ bool execute();
+private:
+ ValueSlot *_time;
+};
+
+class ActionTtyText : public ResultAction {
+public:
+ ActionTtyText(ZVision *engine, int32 slotkey, const Common::String &line);
+ ~ActionTtyText();
+ bool execute();
+
+private:
+ Common::String _filename;
+ uint32 _delay;
+ Common::Rect _r;
+};
} // End of namespace ZVision
#endif
diff --git a/engines/zvision/scripting/control.cpp b/engines/zvision/scripting/control.cpp
index 2343c83c56..81123eb99b 100644
--- a/engines/zvision/scripting/control.cpp
+++ b/engines/zvision/scripting/control.cpp
@@ -23,34 +23,15 @@
#include "common/scummsys.h"
#include "zvision/scripting/control.h"
+#include "zvision/scripting/script_manager.h"
#include "zvision/zvision.h"
#include "zvision/graphics/render_manager.h"
-#include "zvision/utility/utility.h"
#include "common/stream.h"
-
namespace ZVision {
-void Control::enable() {
- if (!_enabled) {
- _enabled = true;
- return;
- }
-
- debug("Control %u is already enabled", _key);
-}
-
-void Control::disable() {
- if (_enabled) {
- _enabled = false;
- return;
- }
-
- debug("Control %u is already disabled", _key);
-}
-
void Control::parseFlatControl(ZVision *engine) {
engine->getRenderManager()->getRenderTable()->setRenderState(RenderTable::FLAT);
}
@@ -61,7 +42,7 @@ void Control::parsePanoramaControl(ZVision *engine, Common::SeekableReadStream &
// Loop until we find the closing brace
Common::String line = stream.readLine();
- trimCommentsAndWhiteSpace(&line);
+ engine->getScriptManager()->trimCommentsAndWhiteSpace(&line);
while (!stream.eos() && !line.contains('}')) {
if (line.matchString("angle*", true)) {
@@ -79,23 +60,26 @@ void Control::parsePanoramaControl(ZVision *engine, Common::SeekableReadStream &
renderTable->setPanoramaReverse(true);
}
} else if (line.matchString("zeropoint*", true)) {
- // TODO: Implement
+ uint point;
+ sscanf(line.c_str(), "zeropoint(%u)", &point);
+ renderTable->setPanoramaZeroPoint(point);
}
line = stream.readLine();
- trimCommentsAndWhiteSpace(&line);
+ engine->getScriptManager()->trimCommentsAndWhiteSpace(&line);
}
renderTable->generateRenderTable();
}
+// Only used in Zork Nemesis, handles tilt controls (ZGI doesn't have a tilt view)
void Control::parseTiltControl(ZVision *engine, Common::SeekableReadStream &stream) {
RenderTable *renderTable = engine->getRenderManager()->getRenderTable();
renderTable->setRenderState(RenderTable::TILT);
// Loop until we find the closing brace
Common::String line = stream.readLine();
- trimCommentsAndWhiteSpace(&line);
+ engine->getScriptManager()->trimCommentsAndWhiteSpace(&line);
while (!stream.eos() && !line.contains('}')) {
if (line.matchString("angle*", true)) {
@@ -115,10 +99,40 @@ void Control::parseTiltControl(ZVision *engine, Common::SeekableReadStream &stre
}
line = stream.readLine();
- trimCommentsAndWhiteSpace(&line);
+ engine->getScriptManager()->trimCommentsAndWhiteSpace(&line);
}
renderTable->generateRenderTable();
}
+void Control::getParams(const Common::String &inputStr, Common::String &parameter, Common::String &values) {
+ const char *chrs = inputStr.c_str();
+ uint lbr;
+
+ for (lbr = 0; lbr < inputStr.size(); lbr++)
+ if (chrs[lbr] == '(')
+ break;
+
+ if (lbr >= inputStr.size())
+ return;
+
+ uint rbr;
+
+ for (rbr = lbr + 1; rbr < inputStr.size(); rbr++)
+ if (chrs[rbr] == ')')
+ break;
+
+ if (rbr >= inputStr.size())
+ return;
+
+ parameter = Common::String(chrs, chrs + lbr);
+ values = Common::String(chrs + lbr + 1, chrs + rbr);
+}
+
+void Control::setVenus() {
+ if (_venusId >= 0)
+ if (_engine->getScriptManager()->getStateValue(_venusId) > 0)
+ _engine->getScriptManager()->setStateValue(StateKey_Venus, _venusId);
+}
+
} // End of namespace ZVision
diff --git a/engines/zvision/scripting/control.h b/engines/zvision/scripting/control.h
index ffeacb273d..108b83fd00 100644
--- a/engines/zvision/scripting/control.h
+++ b/engines/zvision/scripting/control.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.
@@ -24,7 +24,7 @@
#define ZVISION_CONTROL_H
#include "common/keyboard.h"
-
+#include "common/str.h"
namespace Common {
class SeekableReadStream;
@@ -36,16 +36,39 @@ namespace ZVision {
class ZVision;
+/**
+ * The base class for all Controls.
+ *
+ * Controls are the things that the user interacts with. Ex: A lever on the door
+ */
class Control {
public:
- Control() : _engine(0), _key(0), _enabled(false) {}
- Control(ZVision *engine, uint32 key) : _engine(engine), _key(key), _enabled(false) {}
+
+ enum ControlType {
+ CONTROL_UNKNOW,
+ CONTROL_INPUT,
+ CONTROL_PUSHTGL,
+ CONTROL_SLOT,
+ CONTROL_LEVER,
+ CONTROL_SAVE,
+ CONTROL_SAFE,
+ CONTROL_FIST,
+ CONTROL_TITLER,
+ CONTROL_HOTMOV,
+ CONTROL_PAINT
+ };
+
+ Control(ZVision *engine, uint32 key, ControlType type) : _engine(engine), _key(key), _type(type), _venusId(-1) {}
virtual ~Control() {}
- uint32 getKey() { return _key; }
+ uint32 getKey() {
+ return _key;
+ }
+
+ ControlType getType() {
+ return _type;
+ }
- virtual void enable();
- virtual void disable();
virtual void focus() {}
virtual void unfocus() {}
/**
@@ -54,14 +77,18 @@ public:
* @param screenSpacePos The position of the mouse in screen space
* @param backgroundImageSpacePos The position of the mouse in background image space
*/
- virtual void onMouseDown(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {}
+ virtual bool onMouseDown(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {
+ return false;
+ }
/**
* Called when LeftMouse is lifted. Default is NOP.
*
* @param screenSpacePos The position of the mouse in screen space
* @param backgroundImageSpacePos The position of the mouse in background image space
*/
- virtual void onMouseUp(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {}
+ virtual bool onMouseUp(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {
+ return false;
+ }
/**
* Called on every MouseMove. Default is NOP.
*
@@ -69,78 +96,52 @@ public:
* @param backgroundImageSpacePos The position of the mouse in background image space
* @return Was the cursor changed?
*/
- virtual bool onMouseMove(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) { return false; }
+ virtual bool onMouseMove(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {
+ return false;
+ }
/**
* Called when a key is pressed. Default is NOP.
*
* @param keycode The key that was pressed
*/
- virtual void onKeyDown(Common::KeyState keyState) {}
+ virtual bool onKeyDown(Common::KeyState keyState) {
+ return false;
+ }
/**
* Called when a key is released. Default is NOP.
*
* @param keycode The key that was pressed
*/
- virtual void onKeyUp(Common::KeyState keyState) {}
+ virtual bool onKeyUp(Common::KeyState keyState) {
+ return false;
+ }
/**
* Processes the node given the deltaTime since last frame. Default is NOP.
*
* @param deltaTimeInMillis The number of milliseconds that have passed since last frame
* @return If true, the node can be deleted after process() finishes
*/
- virtual bool process(uint32 deltaTimeInMillis) { return false; }
- /**
- * Serialize a Control for save game use. This should only be used if a Control needs
- * to save values that would be different from initialization. AKA a TimerNode needs to
- * store the amount of time left on the timer. Any Controls overriding this *MUST* write
- * their key as the first data outputted. The default implementation is NOP.
- *
- * NOTE: If this method is overridden, you MUST also override deserialize()
- * and needsSerialization()
- *
- * @param stream Stream to write any needed data to
- */
- virtual void serialize(Common::WriteStream *stream) {}
- /**
- * De-serialize data from a save game stream. This should only be implemented if the
- * Control also implements serialize(). The calling method assumes the size of the
- * data read from the stream exactly equals that written in serialize(). The default
- * implementation is NOP.
- *
- * NOTE: If this method is overridden, you MUST also override serialize()
- * and needsSerialization()
- *
- * @param stream Save game file stream
- */
- virtual void deserialize(Common::SeekableReadStream *stream) {}
- /**
- * If a Control overrides serialize() and deserialize(), this should return true
- *
- * @return Does the Control need save game serialization?
- */
- virtual inline bool needsSerialization() { return false; }
+ virtual bool process(uint32 deltaTimeInMillis) {
+ return false;
+ }
+
+ void setVenus();
protected:
- ZVision * _engine;
+ ZVision *_engine;
uint32 _key;
- bool _enabled;
+ int32 _venusId;
+ void getParams(const Common::String &inputStr, Common::String &parameter, Common::String &values);
// Static member functions
public:
static void parseFlatControl(ZVision *engine);
static void parsePanoramaControl(ZVision *engine, Common::SeekableReadStream &stream);
static void parseTiltControl(ZVision *engine, Common::SeekableReadStream &stream);
+private:
+ ControlType _type;
};
-// TODO: Implement InputControl
-// TODO: Implement SaveControl
-// TODO: Implement SlotControl
-// TODO: Implement SafeControl
-// TODO: Implement FistControl
-// TODO: Implement HotMovieControl
-// TODO: Implement PaintControl
-// TODO: Implement TilterControl
-
} // End of namespace ZVision
#endif
diff --git a/engines/zvision/scripting/controls/animation_control.cpp b/engines/zvision/scripting/controls/animation_control.cpp
deleted file mode 100644
index e351e81d25..0000000000
--- a/engines/zvision/scripting/controls/animation_control.cpp
+++ /dev/null
@@ -1,263 +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 "common/scummsys.h"
-
-#include "zvision/scripting/controls/animation_control.h"
-
-#include "zvision/zvision.h"
-#include "zvision/graphics/render_manager.h"
-#include "zvision/scripting/script_manager.h"
-#include "zvision/animation/rlf_animation.h"
-#include "zvision/video/zork_avi_decoder.h"
-
-#include "video/video_decoder.h"
-
-#include "graphics/surface.h"
-
-
-namespace ZVision {
-
-AnimationControl::AnimationControl(ZVision *engine, uint32 controlKey, const Common::String &fileName)
- : Control(engine, controlKey),
- _fileType(RLF),
- _loopCount(1),
- _currentLoop(0),
- _accumulatedTime(0),
- _cachedFrame(0),
- _cachedFrameNeedsDeletion(false) {
- if (fileName.hasSuffix(".rlf")) {
- _fileType = RLF;
- _animation.rlf = new RlfAnimation(fileName, false);
- } else if (fileName.hasSuffix(".avi")) {
- _fileType = AVI;
- _animation.avi = new ZorkAVIDecoder();
- _animation.avi->loadFile(fileName);
- } else {
- warning("Unrecognized animation file type: %s", fileName.c_str());
- }
-
- _cachedFrame = new Graphics::Surface();
-}
-
-AnimationControl::~AnimationControl() {
- if (_fileType == RLF) {
- delete _animation.rlf;
- } else if (_fileType == AVI) {
- delete _animation.avi;
- }
-
- _cachedFrame->free();
- delete _cachedFrame;
-}
-
-bool AnimationControl::process(uint32 deltaTimeInMillis) {
- if (!_enabled) {
- return false;
- }
-
- bool finished = false;
-
- if (_fileType == RLF) {
- _accumulatedTime += deltaTimeInMillis;
-
- uint32 frameTime = _animation.rlf->frameTime();
- if (_accumulatedTime >= frameTime) {
- while (_accumulatedTime >= frameTime) {
- _accumulatedTime -= frameTime;
-
- // Make sure the frame is inside the working window
- // If it's not, then just return
-
- RenderManager *renderManager = _engine->getRenderManager();
- Common::Point workingWindowPoint = renderManager->imageSpaceToWorkingWindowSpace(Common::Point(_x, _y));
- Common::Rect subRect(workingWindowPoint.x, workingWindowPoint.y, workingWindowPoint.x + _animation.rlf->width(), workingWindowPoint.y + _animation.rlf->height());
-
- // If the clip returns false, it means the animation is outside the working window
- if (!renderManager->clipRectToWorkingWindow(subRect)) {
- return false;
- }
-
- const Graphics::Surface *frame = _animation.rlf->getNextFrame();
-
- // Animation frames for PANORAMAs are transposed, so un-transpose them
- RenderTable::RenderState state = renderManager->getRenderTable()->getRenderState();
- if (state == RenderTable::PANORAMA) {
- Graphics::Surface *tranposedFrame = RenderManager::tranposeSurface(frame);
-
- renderManager->copyRectToWorkingWindow((uint16 *)tranposedFrame->getBasePtr(tranposedFrame->w - subRect.width(), tranposedFrame->h - subRect.height()), subRect.left, subRect.top, _animation.rlf->width(), subRect.width(), subRect.height());
-
- // If the background can move, we need to cache the last frame so it can be rendered during background movement
- if (state == RenderTable::PANORAMA || state == RenderTable::TILT) {
- if (_cachedFrameNeedsDeletion) {
- _cachedFrame->free();
- delete _cachedFrame;
- _cachedFrameNeedsDeletion = false;
- }
- _cachedFrame = tranposedFrame;
- _cachedFrameNeedsDeletion = true;
- } else {
- // Cleanup
- tranposedFrame->free();
- delete tranposedFrame;
- }
- } else {
- renderManager->copyRectToWorkingWindow((const uint16 *)frame->getBasePtr(frame->w - subRect.width(), frame->h - subRect.height()), subRect.left, subRect.top, _animation.rlf->width(), subRect.width(), subRect.height());
-
- // If the background can move, we need to cache the last frame so it can be rendered during background movement
- if (state == RenderTable::PANORAMA || state == RenderTable::TILT) {
- if (_cachedFrameNeedsDeletion) {
- _cachedFrame->free();
- delete _cachedFrame;
- _cachedFrameNeedsDeletion = false;
- }
- _cachedFrame->copyFrom(*frame);
- }
- }
-
- // Check if we should continue looping
- if (_animation.rlf->endOfAnimation()) {
- _animation.rlf->seekToFrame(-1);
- if (_loopCount > 0) {
- _currentLoop++;
- if (_currentLoop >= _loopCount) {
- finished = true;
- }
- }
- }
- }
- } else {
- // If the background can move, we have to keep rendering animation frames, otherwise the animation flickers during background movement
- RenderManager *renderManager = _engine->getRenderManager();
- RenderTable::RenderState state = renderManager->getRenderTable()->getRenderState();
-
- if (state == RenderTable::PANORAMA || state == RenderTable::TILT) {
- Common::Point workingWindowPoint = renderManager->imageSpaceToWorkingWindowSpace(Common::Point(_x, _y));
- Common::Rect subRect(workingWindowPoint.x, workingWindowPoint.y, workingWindowPoint.x + _cachedFrame->w, workingWindowPoint.y + _cachedFrame->h);
-
- // If the clip returns false, it means the animation is outside the working window
- if (!renderManager->clipRectToWorkingWindow(subRect)) {
- return false;
- }
-
- renderManager->copyRectToWorkingWindow((uint16 *)_cachedFrame->getBasePtr(_cachedFrame->w - subRect.width(), _cachedFrame->h - subRect.height()), subRect.left, subRect.top, _cachedFrame->w, subRect.width(), subRect.height());
- }
- }
- } else if (_fileType == AVI) {
- if (!_animation.avi->isPlaying()) {
- _animation.avi->start();
- }
-
- if (_animation.avi->needsUpdate()) {
- const Graphics::Surface *frame = _animation.avi->decodeNextFrame();
-
- if (frame) {
- // Make sure the frame is inside the working window
- // If it's not, then just return
-
- RenderManager *renderManager = _engine->getRenderManager();
- Common::Point workingWindowPoint = renderManager->imageSpaceToWorkingWindowSpace(Common::Point(_x, _y));
- Common::Rect subRect(workingWindowPoint.x, workingWindowPoint.y, workingWindowPoint.x + frame->w, workingWindowPoint.y + frame->h);
-
- // If the clip returns false, it means the animation is outside the working window
- if (!renderManager->clipRectToWorkingWindow(subRect)) {
- return false;
- }
-
- // Animation frames for PANORAMAs are transposed, so un-transpose them
- RenderTable::RenderState state = renderManager->getRenderTable()->getRenderState();
- if (state == RenderTable::PANORAMA) {
- Graphics::Surface *tranposedFrame = RenderManager::tranposeSurface(frame);
-
- renderManager->copyRectToWorkingWindow((uint16 *)tranposedFrame->getBasePtr(tranposedFrame->w - subRect.width(), tranposedFrame->h - subRect.height()), subRect.left, subRect.top, frame->w, subRect.width(), subRect.height());
-
- // If the background can move, we need to cache the last frame so it can be rendered during background movement
- if (state == RenderTable::PANORAMA || state == RenderTable::TILT) {
- if (_cachedFrameNeedsDeletion) {
- _cachedFrame->free();
- delete _cachedFrame;
- _cachedFrameNeedsDeletion = false;
- }
- _cachedFrame = tranposedFrame;
- _cachedFrameNeedsDeletion = true;
- } else {
- // Cleanup
- tranposedFrame->free();
- delete tranposedFrame;
- }
- } else {
- renderManager->copyRectToWorkingWindow((const uint16 *)frame->getBasePtr(frame->w - subRect.width(), frame->h - subRect.height()), subRect.left, subRect.top, frame->w, subRect.width(), subRect.height());
-
- // If the background can move, we need to cache the last frame so it can be rendered during background movement
- if (state == RenderTable::PANORAMA || state == RenderTable::TILT) {
- if (_cachedFrameNeedsDeletion) {
- _cachedFrame->free();
- delete _cachedFrame;
- _cachedFrameNeedsDeletion = false;
- }
- _cachedFrame->copyFrom(*frame);
- }
- }
- } else {
- // If the background can move, we have to keep rendering animation frames, otherwise the animation flickers during background movement
- RenderManager *renderManager = _engine->getRenderManager();
- RenderTable::RenderState state = renderManager->getRenderTable()->getRenderState();
-
- if (state == RenderTable::PANORAMA || state == RenderTable::TILT) {
- Common::Point workingWindowPoint = renderManager->imageSpaceToWorkingWindowSpace(Common::Point(_x, _y));
- Common::Rect subRect(workingWindowPoint.x, workingWindowPoint.y, workingWindowPoint.x + _cachedFrame->w, workingWindowPoint.y + _cachedFrame->h);
-
- // If the clip returns false, it means the animation is outside the working window
- if (!renderManager->clipRectToWorkingWindow(subRect)) {
- return false;
- }
-
- renderManager->copyRectToWorkingWindow((uint16 *)_cachedFrame->getBasePtr(_cachedFrame->w - subRect.width(), _cachedFrame->h - subRect.height()), subRect.left, subRect.top, _cachedFrame->w, subRect.width(), subRect.height());
- }
- }
- }
-
- // Check if we should continue looping
- if (_animation.avi->endOfVideo()) {
- _animation.avi->rewind();
- if (_loopCount > 0) {
- _currentLoop++;
- if (_currentLoop >= _loopCount) {
- _animation.avi->stop();
- finished = true;
- }
- }
- }
- }
-
- // If we're done, set _animation key = 2 (Why 2? I don't know. It's just the value that they used)
- // Then disable the control. DON'T delete it. It can be re-used
- if (finished) {
- _engine->getScriptManager()->setStateValue(_animationKey, 2);
- disable();
- _currentLoop = 0;
- }
-
- return false;
-}
-
-} // End of namespace ZVision
diff --git a/engines/zvision/scripting/controls/fist_control.cpp b/engines/zvision/scripting/controls/fist_control.cpp
new file mode 100644
index 0000000000..4a8e8b1bbd
--- /dev/null
+++ b/engines/zvision/scripting/controls/fist_control.cpp
@@ -0,0 +1,299 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public 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 "zvision/zvision.h"
+#include "zvision/scripting/script_manager.h"
+#include "zvision/scripting/controls/fist_control.h"
+#include "zvision/graphics/render_manager.h"
+#include "zvision/graphics/cursors/cursor_manager.h"
+#include "zvision/video/rlf_decoder.h"
+
+#include "common/stream.h"
+#include "common/file.h"
+#include "common/system.h"
+#include "graphics/surface.h"
+#include "video/video_decoder.h"
+
+namespace ZVision {
+
+FistControl::FistControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream)
+ : Control(engine, key, CONTROL_FIST) {
+ _cursor = CursorIndex_Idle;
+ _animation = NULL;
+ _soundKey = 0;
+ _fiststatus = 0;
+ _order = 0;
+ _fistnum = 0;
+
+ _animationId = 0;
+
+ clearFistArray(_fistsUp);
+ clearFistArray(_fistsDwn);
+
+ _numEntries = 0;
+ _entries.clear();
+
+ _anmRect = Common::Rect();
+
+ // Loop until we find the closing brace
+ Common::String line = stream.readLine();
+ _engine->getScriptManager()->trimCommentsAndWhiteSpace(&line);
+ Common::String param;
+ Common::String values;
+ getParams(line, param, values);
+
+ while (!stream.eos() && !line.contains('}')) {
+ if (param.matchString("sound_key", true)) {
+ _soundKey = atoi(values.c_str());
+ } else if (param.matchString("cursor", true)) {
+ _cursor = _engine->getCursorManager()->getCursorId(values);
+ } else if (param.matchString("descfile", true)) {
+ readDescFile(values);
+ } else if (param.matchString("animation_id", true)) {
+ _animationId = atoi(values.c_str());
+ } else if (param.matchString("venus_id", true)) {
+ _venusId = atoi(values.c_str());
+ }
+
+ line = stream.readLine();
+ _engine->getScriptManager()->trimCommentsAndWhiteSpace(&line);
+ getParams(line, param, values);
+ }
+}
+
+FistControl::~FistControl() {
+ if (_animation)
+ delete _animation;
+
+ clearFistArray(_fistsUp);
+ clearFistArray(_fistsDwn);
+ _entries.clear();
+}
+
+bool FistControl::process(uint32 deltaTimeInMillis) {
+ if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED)
+ return false;
+
+ if (_animation && _animation->isPlaying()) {
+ if (_animation->endOfVideo()) {
+ _animation->stop();
+ _engine->getScriptManager()->setStateValue(_animationId, 2);
+ return false;
+ }
+
+ if (_animation->needsUpdate()) {
+ const Graphics::Surface *frameData = _animation->decodeNextFrame();
+ if (frameData)
+ _engine->getRenderManager()->blitSurfaceToBkgScaled(*frameData, _anmRect);
+ }
+ }
+
+ return false;
+}
+
+bool FistControl::onMouseMove(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {
+ if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED)
+ return false;
+
+ if (mouseIn(screenSpacePos, backgroundImageSpacePos) >= 0) {
+ _engine->getCursorManager()->changeCursor(_cursor);
+ return true;
+ }
+
+ return false;
+}
+
+bool FistControl::onMouseUp(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {
+ if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED)
+ return false;
+
+ int fistNumber = mouseIn(screenSpacePos, backgroundImageSpacePos);
+
+ if (fistNumber >= 0) {
+ setVenus();
+
+ uint32 oldStatus = _fiststatus;
+ _fiststatus ^= (1 << fistNumber);
+
+ for (int i = 0; i < _numEntries; i++)
+ if (_entries[i]._bitsStrt == oldStatus && _entries[i]._bitsEnd == _fiststatus) {
+ if (_animation) {
+ _animation->stop();
+ _animation->seekToFrame(_entries[i]._anmStrt);
+ _animation->setEndFrame(_entries[i]._anmEnd);
+ _animation->start();
+ }
+
+ _engine->getScriptManager()->setStateValue(_animationId, 1);
+ _engine->getScriptManager()->setStateValue(_soundKey, _entries[i]._sound);
+ break;
+ }
+
+ _engine->getScriptManager()->setStateValue(_key, _fiststatus);
+ }
+
+ return false;
+}
+
+void FistControl::readDescFile(const Common::String &fileName) {
+ Common::File file;
+ if (!_engine->getSearchManager()->openFile(file, fileName)) {
+ warning("Desc file %s could could be opened", fileName.c_str());
+ return;
+ }
+
+ Common::String line;
+ Common::String param;
+ Common::String values;
+
+ while (!file.eos()) {
+ line = file.readLine();
+ getFistParams(line, param, values);
+
+ if (param.matchString("animation_id", true)) {
+ // Not used
+ } else if (param.matchString("animation", true)) {
+ _animation = _engine->loadAnimation(values);
+ } else if (param.matchString("anim_rect", true)) {
+ int left, top, right, bottom;
+ sscanf(values.c_str(), "%d %d %d %d", &left, &top, &right, &bottom);
+ _anmRect = Common::Rect(left, top, right, bottom);
+ } else if (param.matchString("num_fingers", true)) {
+ sscanf(values.c_str(), "%d", &_fistnum);
+ _fistsUp.resize(_fistnum);
+ _fistsDwn.resize(_fistnum);
+ } else if (param.matchString("entries", true)) {
+ sscanf(values.c_str(), "%d", &_numEntries);
+ _entries.resize(_numEntries);
+ } else if (param.matchString("eval_order_ascending", true)) {
+ sscanf(values.c_str(), "%d", &_order);
+ } else if (param.matchString("up_hs_num_*", true)) {
+ int fist, num;
+ num = atoi(values.c_str());
+
+ sscanf(param.c_str(), "up_hs_num_%d", &fist);
+ _fistsUp[fist].resize(num);
+ } else if (param.matchString("up_hs_*", true)) {
+ int16 fist, box, x1, y1, x2, y2;
+ sscanf(param.c_str(), "up_hs_%hd_%hd", &fist, &box);
+ sscanf(values.c_str(), "%hd %hd %hd %hd", &x1, &y1, &x2, &y2);
+ (_fistsUp[fist])[box] = Common::Rect(x1, y1, x2, y2);
+ } else if (param.matchString("down_hs_num_*", true)) {
+ int fist, num;
+ num = atoi(values.c_str());
+
+ sscanf(param.c_str(), "down_hs_num_%d", &fist);
+ _fistsDwn[fist].resize(num);
+ } else if (param.matchString("down_hs_*", true)) {
+ int16 fist, box, x1, y1, x2, y2;
+ sscanf(param.c_str(), "down_hs_%hd_%hd", &fist, &box);
+ sscanf(values.c_str(), "%hd %hd %hd %hd", &x1, &y1, &x2, &y2);
+ (_fistsDwn[fist])[box] = Common::Rect(x1, y1, x2, y2);
+ } else {
+ int entry, start, end, sound;
+ char bitsStart[33];
+ char bitsEnd[33];
+ entry = atoi(param.c_str());
+ if (sscanf(values.c_str(), "%s %s %d %d (%d)", bitsStart, bitsEnd, &start, &end, &sound) == 5) {
+ _entries[entry]._bitsStrt = readBits(bitsStart);
+ _entries[entry]._bitsEnd = readBits(bitsEnd);
+ _entries[entry]._anmStrt = start;
+ _entries[entry]._anmEnd = end;
+ _entries[entry]._sound = sound;
+ }
+ }
+ }
+ file.close();
+}
+
+void FistControl::clearFistArray(Common::Array< Common::Array<Common::Rect> > &arr) {
+ for (uint i = 0; i < arr.size(); i++)
+ arr[i].clear();
+
+ arr.clear();
+}
+
+uint32 FistControl::readBits(const char *str) {
+ uint32 bfield = 0;
+ int len = strlen(str);
+ for (int i = 0; i < len; i++)
+ if (str[i] != '0')
+ bfield |= (1 << i);
+ return bfield;
+}
+
+int FistControl::mouseIn(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {
+ if (_order) {
+ for (int i = 0; i < _fistnum; i++) {
+ if (((_fiststatus >> i) & 1) == 1) {
+ for (uint j = 0; j < _fistsDwn[i].size(); j++)
+ if ((_fistsDwn[i])[j].contains(backgroundImageSpacePos))
+ return i;
+ } else {
+ for (uint j = 0; j < _fistsUp[i].size(); j++)
+ if ((_fistsUp[i])[j].contains(backgroundImageSpacePos))
+ return i;
+ }
+ }
+ } else {
+ for (int i = _fistnum - 1; i >= 0; i--) {
+ if (((_fiststatus >> i) & 1) == 1) {
+ for (uint j = 0; j < _fistsDwn[i].size(); j++)
+ if ((_fistsDwn[i])[j].contains(backgroundImageSpacePos))
+ return i;
+ } else {
+ for (uint j = 0; j < _fistsUp[i].size(); j++)
+ if ((_fistsUp[i])[j].contains(backgroundImageSpacePos))
+ return i;
+ }
+ }
+ }
+ return -1;
+}
+
+void FistControl::getFistParams(const Common::String &inputStr, Common::String &parameter, Common::String &values) {
+ const char *chrs = inputStr.c_str();
+ uint lbr;
+
+ for (lbr = 0; lbr < inputStr.size(); lbr++)
+ if (chrs[lbr] == ':')
+ break;
+
+ if (lbr >= inputStr.size())
+ return;
+
+ uint rbr;
+
+ for (rbr = lbr + 1; rbr < inputStr.size(); rbr++)
+ if (chrs[rbr] == '~')
+ break;
+
+ if (rbr >= inputStr.size())
+ return;
+
+ parameter = Common::String(chrs, chrs + lbr);
+ values = Common::String(chrs + lbr + 1, chrs + rbr);
+}
+
+} // End of namespace ZVision
diff --git a/engines/zvision/scripting/controls/fist_control.h b/engines/zvision/scripting/controls/fist_control.h
new file mode 100644
index 0000000000..d7cbcb1f71
--- /dev/null
+++ b/engines/zvision/scripting/controls/fist_control.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 ZVISION_FIST_CONTROL_H
+#define ZVISION_FIST_CONTROL_H
+
+#include "zvision/scripting/control.h"
+
+#include "common/array.h"
+#include "common/rect.h"
+
+namespace Video {
+ class VideoDecoder;
+}
+
+namespace ZVision {
+
+// Only used in Zork Nemesis, handles the door lock puzzle with the skeletal fingers (td9e)
+class FistControl : public Control {
+public:
+ FistControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream);
+ ~FistControl();
+
+private:
+ uint32 _fiststatus;
+ int _fistnum;
+ int16 _cursor;
+ int _order;
+
+ Common::Array< Common::Array<Common::Rect> > _fistsUp;
+ Common::Array< Common::Array<Common::Rect> > _fistsDwn;
+
+ int32 _numEntries;
+
+ struct entries {
+ uint32 _bitsStrt;
+ uint32 _bitsEnd;
+ int32 _anmStrt;
+ int32 _anmEnd;
+ int32 _sound;
+ };
+
+ Common::Array<entries> _entries;
+
+ Video::VideoDecoder *_animation;
+ Common::Rect _anmRect;
+ int32 _soundKey;
+ int32 _animationId;
+
+public:
+ bool onMouseUp(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos);
+ bool onMouseMove(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos);
+ bool process(uint32 deltaTimeInMillis);
+
+private:
+ void readDescFile(const Common::String &fileName);
+ void clearFistArray(Common::Array< Common::Array<Common::Rect> > &arr);
+ uint32 readBits(const char *str);
+ int mouseIn(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos);
+ void getFistParams(const Common::String &inputStr, Common::String &parameter, Common::String &values);
+};
+
+} // End of namespace ZVision
+
+#endif
diff --git a/engines/zvision/scripting/controls/hotmov_control.cpp b/engines/zvision/scripting/controls/hotmov_control.cpp
new file mode 100644
index 0000000000..182447a990
--- /dev/null
+++ b/engines/zvision/scripting/controls/hotmov_control.cpp
@@ -0,0 +1,188 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public 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 "zvision/scripting/controls/hotmov_control.h"
+
+#include "zvision/zvision.h"
+#include "zvision/scripting/script_manager.h"
+#include "zvision/graphics/render_manager.h"
+#include "zvision/graphics/cursors/cursor_manager.h"
+
+#include "common/stream.h"
+#include "common/file.h"
+#include "common/system.h"
+#include "graphics/surface.h"
+#include "video/video_decoder.h"
+
+namespace ZVision {
+
+HotMovControl::HotMovControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream)
+ : Control(engine, key, CONTROL_HOTMOV) {
+ _animation = NULL;
+ _cycle = 0;
+ _frames.clear();
+ _cyclesCount = 0;
+ _framesCount = 0;
+
+ _engine->getScriptManager()->setStateValue(_key, 0);
+
+ // Loop until we find the closing brace
+ Common::String line = stream.readLine();
+ _engine->getScriptManager()->trimCommentsAndWhiteSpace(&line);
+ Common::String param;
+ Common::String values;
+ getParams(line, param, values);
+
+ while (!stream.eos() && !line.contains('}')) {
+ if (param.matchString("hs_frame_list", true)) {
+ readHsFile(values);
+ } else if (param.matchString("rectangle", true)) {
+ int x;
+ int y;
+ int width;
+ int height;
+
+ sscanf(values.c_str(), "%d %d %d %d", &x, &y, &width, &height);
+
+ _rectangle = Common::Rect(x, y, width, height);
+ } else if (param.matchString("num_frames", true)) {
+ _framesCount = atoi(values.c_str());
+ } else if (param.matchString("num_cycles", true)) {
+ _cyclesCount = atoi(values.c_str());
+ } else if (param.matchString("animation", true)) {
+ char filename[64];
+ sscanf(values.c_str(), "%s", filename);
+ values = Common::String(filename);
+ _animation = _engine->loadAnimation(values);
+ _animation->start();
+ } else if (param.matchString("venus_id", true)) {
+ _venusId = atoi(values.c_str());
+ }
+
+ line = stream.readLine();
+ _engine->getScriptManager()->trimCommentsAndWhiteSpace(&line);
+ getParams(line, param, values);
+ }
+}
+
+HotMovControl::~HotMovControl() {
+ if (_animation)
+ delete _animation;
+
+ _frames.clear();
+}
+
+bool HotMovControl::process(uint32 deltaTimeInMillis) {
+ if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED)
+ return false;
+
+ if (_cycle < _cyclesCount) {
+ if (_animation && _animation->endOfVideo()) {
+ _cycle++;
+
+ if (_cycle == _cyclesCount) {
+ _engine->getScriptManager()->setStateValue(_key, 2);
+ return false;
+ }
+
+ _animation->rewind();
+ }
+
+ if (_animation && _animation->needsUpdate()) {
+ const Graphics::Surface *frameData = _animation->decodeNextFrame();
+ if (frameData)
+ _engine->getRenderManager()->blitSurfaceToBkgScaled(*frameData, _rectangle);
+ }
+ }
+
+ return false;
+}
+
+bool HotMovControl::onMouseMove(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {
+ if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED)
+ return false;
+
+ if (!_animation)
+ return false;
+
+ if (_cycle < _cyclesCount) {
+ if (_frames[_animation->getCurFrame()].contains(backgroundImageSpacePos)) {
+ _engine->getCursorManager()->changeCursor(CursorIndex_Active);
+ return true;
+ }
+ }
+
+ return false;
+}
+
+bool HotMovControl::onMouseUp(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {
+ if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED)
+ return false;
+
+ if (!_animation)
+ return false;
+
+ if (_cycle < _cyclesCount) {
+ if (_frames[_animation->getCurFrame()].contains(backgroundImageSpacePos)) {
+ setVenus();
+ _engine->getScriptManager()->setStateValue(_key, 1);
+ return true;
+ }
+ }
+
+ return false;
+}
+
+void HotMovControl::readHsFile(const Common::String &fileName) {
+ if (_framesCount == 0)
+ return;
+
+ Common::File file;
+ if (!_engine->getSearchManager()->openFile(file, fileName)) {
+ warning("HS file %s could could be opened", fileName.c_str());
+ return;
+ }
+
+ Common::String line;
+
+ _frames.resize(_framesCount);
+
+ while (!file.eos()) {
+ line = file.readLine();
+
+ int frame;
+ int x;
+ int y;
+ int width;
+ int height;
+
+ sscanf(line.c_str(), "%d:%d %d %d %d~", &frame, &x, &y, &width, &height);
+
+ if (frame >= 0 && frame < _framesCount)
+ _frames[frame] = Common::Rect(x, y, width, height);
+ }
+ file.close();
+}
+
+} // End of namespace ZVision
diff --git a/engines/zvision/scripting/controls/hotmov_control.h b/engines/zvision/scripting/controls/hotmov_control.h
new file mode 100644
index 0000000000..99d1fd0979
--- /dev/null
+++ b/engines/zvision/scripting/controls/hotmov_control.h
@@ -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.
+ *
+ */
+
+#ifndef ZVISION_HOTMOV_CONTROL_H
+#define ZVISION_HOTMOV_CONTROL_H
+
+#include "zvision/scripting/control.h"
+
+#include "common/array.h"
+#include "common/rect.h"
+
+namespace Video {
+ class VideoDecoder;
+}
+
+namespace ZVision {
+
+// Only used in Zork Nemesis, handles movies where the player needs to click on something (mj7g, vw3g)
+class HotMovControl : public Control {
+public:
+ HotMovControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream);
+ ~HotMovControl();
+
+private:
+ int32 _framesCount;
+ int32 _cycle;
+ int32 _cyclesCount;
+ Video::VideoDecoder *_animation;
+ Common::Rect _rectangle;
+ Common::Array<Common::Rect> _frames;
+public:
+ bool onMouseUp(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos);
+ bool onMouseMove(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos);
+ bool process(uint32 deltaTimeInMillis);
+
+private:
+ void readHsFile(const Common::String &fileName);
+};
+
+} // End of namespace ZVision
+
+#endif
diff --git a/engines/zvision/scripting/controls/input_control.cpp b/engines/zvision/scripting/controls/input_control.cpp
index a35548d02e..47da27fa08 100644
--- a/engines/zvision/scripting/controls/input_control.cpp
+++ b/engines/zvision/scripting/controls/input_control.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.
@@ -23,120 +23,227 @@
#include "common/scummsys.h"
#include "zvision/scripting/controls/input_control.h"
+#include "zvision/graphics/cursors/cursor_manager.h"
#include "zvision/zvision.h"
#include "zvision/scripting/script_manager.h"
-#include "zvision/strings/string_manager.h"
+#include "zvision/text/string_manager.h"
#include "zvision/graphics/render_manager.h"
-#include "zvision/utility/utility.h"
#include "common/str.h"
#include "common/stream.h"
#include "common/rect.h"
-
+#include "video/video_decoder.h"
namespace ZVision {
InputControl::InputControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream)
- : Control(engine, key),
- _nextTabstop(0),
- _focused(false),
- _textChanged(false),
- _cursorOffset(0) {
+ : Control(engine, key, CONTROL_INPUT),
+ _nextTabstop(0),
+ _focused(false),
+ _textChanged(false),
+ _cursorOffset(0),
+ _enterPressed(false),
+ _readOnly(false),
+ _txtWidth(0),
+ _animation(NULL) {
// Loop until we find the closing brace
Common::String line = stream.readLine();
- trimCommentsAndWhiteSpace(&line);
+ _engine->getScriptManager()->trimCommentsAndWhiteSpace(&line);
+ Common::String param;
+ Common::String values;
+ getParams(line, param, values);
while (!stream.eos() && !line.contains('}')) {
- if (line.matchString("*rectangle*", true)) {
+ if (param.matchString("rectangle", true)) {
int x1;
int y1;
int x2;
int y2;
- sscanf(line.c_str(), "%*[^(](%d %d %d %d)", &x1, &y1, &x2, &y2);
+ sscanf(values.c_str(), "%d %d %d %d", &x1, &y1, &x2, &y2);
_textRectangle = Common::Rect(x1, y1, x2, y2);
- } else if (line.matchString("*aux_hotspot*", true)) {
+ } else if (param.matchString("aux_hotspot", true)) {
int x1;
int y1;
int x2;
int y2;
- sscanf(line.c_str(), "%*[^(](%d %d %d %d)", &x1, &y1, &x2, &y2);
+ sscanf(values.c_str(), "%d %d %d %d", &x1, &y1, &x2, &y2);
_headerRectangle = Common::Rect(x1, y1, x2, y2);
- } else if (line.matchString("*string_init*", true)) {
+ } else if (param.matchString("string_init", true)) {
uint fontFormatNumber;
- sscanf(line.c_str(), "%*[^(](%u)", &fontFormatNumber);
+ sscanf(values.c_str(), "%u", &fontFormatNumber);
- _textStyle = _engine->getStringManager()->getTextStyle(fontFormatNumber);
- } else if (line.matchString("*next_tabstop*", true)) {
- sscanf(line.c_str(), "%*[^(](%u)", &_nextTabstop);
- } else if (line.matchString("*cursor_animation*", true)) {
- char fileName[26];
+ _stringInit.readAllStyle(_engine->getStringManager()->getTextLine(fontFormatNumber));
+ } else if (param.matchString("chooser_init_string", true)) {
+ uint fontFormatNumber;
- sscanf(line.c_str(), "%*[^(](%25s %*u)", fileName);
+ sscanf(values.c_str(), "%u", &fontFormatNumber);
- _cursorAnimationFileName = Common::String(fileName);
- } else if (line.matchString("*cursor_dimensions*", true)) {
+ _stringChooserInit.readAllStyle(_engine->getStringManager()->getTextLine(fontFormatNumber));
+ } else if (param.matchString("next_tabstop", true)) {
+ sscanf(values.c_str(), "%u", &_nextTabstop);
+ } else if (param.matchString("cursor_dimensions", true)) {
// Ignore, use the dimensions in the animation file
- } else if (line.matchString("*cursor_animation_frames*", true)) {
+ } else if (param.matchString("cursor_animation_frames", true)) {
// Ignore, use the frame count in the animation file
- } else if (line.matchString("*focus*", true)) {
+ } else if (param.matchString("cursor_animation", true)) {
+ char fileName[25];
+
+ sscanf(values.c_str(), "%24s %*u", fileName);
+
+ _animation = _engine->loadAnimation(fileName);
+ _animation->start();
+ } else if (param.matchString("focus", true)) {
_focused = true;
+ _engine->getScriptManager()->setFocusControlKey(_key);
+ } else if (param.matchString("venus_id", true)) {
+ _venusId = atoi(values.c_str());
}
line = stream.readLine();
- trimCommentsAndWhiteSpace(&line);
+ _engine->getScriptManager()->trimCommentsAndWhiteSpace(&line);
+ getParams(line, param, values);
}
}
-void InputControl::onMouseUp(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {
- _engine->getScriptManager()->focusControl(_key);
+bool InputControl::onMouseUp(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {
+ if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED)
+ return false;
+
+ if (_textRectangle.contains(backgroundImageSpacePos)) {
+ if (!_readOnly) {
+ // Save
+ _engine->getScriptManager()->focusControl(_key);
+ setVenus();
+ } else {
+ // Restore
+ if (_currentInputText.size()) {
+ setVenus();
+ _enterPressed = true;
+ }
+ }
+ }
+ return false;
}
-void InputControl::onKeyDown(Common::KeyState keyState) {
+bool InputControl::onMouseMove(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {
+ if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED)
+ return false;
+
+ if (_textRectangle.contains(backgroundImageSpacePos)) {
+ if (!_readOnly) {
+ // Save
+ _engine->getCursorManager()->changeCursor(CursorIndex_Active);
+ return true;
+ } else {
+ // Restore
+ if (_currentInputText.size()) {
+ _engine->getCursorManager()->changeCursor(CursorIndex_Active);
+ _engine->getScriptManager()->focusControl(_key);
+ return true;
+ }
+ }
+ }
+ return false;
+}
+
+bool InputControl::onKeyDown(Common::KeyState keyState) {
+ if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED)
+ return false;
+
if (!_focused) {
- return;
+ return false;
}
if (keyState.keycode == Common::KEYCODE_BACKSPACE) {
- _currentInputText.deleteLastChar();
+ if (!_readOnly) {
+ _currentInputText.deleteLastChar();
+ _textChanged = true;
+ }
+ } else if (keyState.keycode == Common::KEYCODE_RETURN) {
+ _enterPressed = true;
} else if (keyState.keycode == Common::KEYCODE_TAB) {
- _focused = false;
+ unfocus();
// Focus the next input control
_engine->getScriptManager()->focusControl(_nextTabstop);
+ // Don't process this event for other controls
+ return true;
} else {
- // Otherwise, append the new character to the end of the current text
-
- uint16 asciiValue = keyState.ascii;
- // We only care about text values
- if (asciiValue >= 32 && asciiValue <= 126) {
- _currentInputText += (char)asciiValue;
- _textChanged = true;
+ if (!_readOnly) {
+ // Otherwise, append the new character to the end of the current text
+ uint16 asciiValue = keyState.ascii;
+ // We only care about text values
+ if (asciiValue >= 32 && asciiValue <= 126) {
+ _currentInputText += (char)asciiValue;
+ _textChanged = true;
+ }
}
}
+ return false;
}
bool InputControl::process(uint32 deltaTimeInMillis) {
- if (!_focused) {
+ if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED)
return false;
- }
// First see if we need to render the text
if (_textChanged) {
// Blit the text using the RenderManager
- Common::Rect destRect = _engine->getRenderManager()->renderTextToWorkingWindow(_key, _currentInputText, _textStyle.font, _textRectangle.left, _textRectangle.top, _textStyle.color, _textRectangle.width());
- _cursorOffset = destRect.left - _textRectangle.left;
+ Graphics::Surface txt;
+ txt.create(_textRectangle.width(), _textRectangle.height(), _engine->_resourcePixelFormat);
+
+ if (!_readOnly || !_focused)
+ _txtWidth = _engine->getTextRenderer()->drawTxt(_currentInputText, _stringInit, txt);
+ else
+ _txtWidth = _engine->getTextRenderer()->drawTxt(_currentInputText, _stringChooserInit, txt);
+
+ _engine->getRenderManager()->blitSurfaceToBkg(txt, _textRectangle.left, _textRectangle.top);
+
+ txt.free();
}
- // Render the next frame of the animation
- // TODO: Implement animation handling
+ if (_animation && !_readOnly && _focused) {
+ if (_animation->endOfVideo())
+ _animation->rewind();
+ if (_animation->needsUpdate()) {
+ const Graphics::Surface *srf = _animation->decodeNextFrame();
+ int16 xx = _textRectangle.left + _txtWidth;
+ if (xx >= _textRectangle.left + (_textRectangle.width() - (int16)_animation->getWidth()))
+ xx = _textRectangle.left + _textRectangle.width() - (int16)_animation->getWidth();
+ _engine->getRenderManager()->blitSurfaceToBkg(*srf, xx, _textRectangle.top);
+ }
+ }
+
+ _textChanged = false;
+ return false;
+}
+
+bool InputControl::enterPress() {
+ if (_enterPressed) {
+ _enterPressed = false;
+ return true;
+ }
return false;
}
+void InputControl::setText(const Common::String &_str) {
+ _currentInputText = _str;
+ _textChanged = true;
+}
+
+const Common::String InputControl::getText() {
+ return _currentInputText;
+}
+
+void InputControl::setReadOnly(bool readonly) {
+ _readOnly = readonly;
+}
+
} // End of namespace ZVision
diff --git a/engines/zvision/scripting/controls/input_control.h b/engines/zvision/scripting/controls/input_control.h
index 32432438bb..99f7f5287d 100644
--- a/engines/zvision/scripting/controls/input_control.h
+++ b/engines/zvision/scripting/controls/input_control.h
@@ -24,10 +24,14 @@
#define ZVISION_INPUT_CONTROL_H
#include "zvision/scripting/control.h"
-#include "zvision/strings/string_manager.h"
+#include "zvision/text/text.h"
+#include "zvision/text/string_manager.h"
#include "common/rect.h"
+namespace Video {
+ class VideoDecoder;
+}
namespace ZVision {
@@ -38,21 +42,39 @@ public:
private:
Common::Rect _textRectangle;
Common::Rect _headerRectangle;
- StringManager::TextStyle _textStyle;
+ cTxtStyle _stringInit;
+ cTxtStyle _stringChooserInit;
uint32 _nextTabstop;
- Common::String _cursorAnimationFileName;
bool _focused;
Common::String _currentInputText;
bool _textChanged;
uint _cursorOffset;
+ bool _enterPressed;
+ bool _readOnly;
+
+ int16 _txtWidth;
+ Video::VideoDecoder *_animation;
+ int32 _frameDelay;
+ int16 _frame;
public:
- void focus() { _focused = true; }
- void unfocus() { _focused = false; }
- void onMouseUp(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos);
- void onKeyDown(Common::KeyState keyState);
+ void focus() {
+ _focused = true;
+ _textChanged = true;
+ }
+ void unfocus() {
+ _focused = false;
+ _textChanged = true;
+ }
+ bool onMouseUp(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos);
+ bool onMouseMove(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos);
+ bool onKeyDown(Common::KeyState keyState);
bool process(uint32 deltaTimeInMillis);
+ void setText(const Common::String &_str);
+ const Common::String getText();
+ bool enterPress();
+ void setReadOnly(bool);
};
} // End of namespace ZVision
diff --git a/engines/zvision/scripting/controls/lever_control.cpp b/engines/zvision/scripting/controls/lever_control.cpp
index 9724e661b7..bef51f0e91 100644
--- a/engines/zvision/scripting/controls/lever_control.cpp
+++ b/engines/zvision/scripting/controls/lever_control.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.
@@ -27,130 +27,128 @@
#include "zvision/zvision.h"
#include "zvision/scripting/script_manager.h"
#include "zvision/graphics/render_manager.h"
-#include "zvision/cursors/cursor_manager.h"
-#include "zvision/animation/rlf_animation.h"
-#include "zvision/video/zork_avi_decoder.h"
-#include "zvision/utility/utility.h"
+#include "zvision/graphics/cursors/cursor_manager.h"
#include "common/stream.h"
#include "common/file.h"
#include "common/tokenizer.h"
#include "common/system.h"
-
#include "graphics/surface.h"
-
+#include "video/video_decoder.h"
namespace ZVision {
LeverControl::LeverControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream)
- : Control(engine, key),
- _frameInfo(0),
- _frameCount(0),
- _startFrame(0),
- _currentFrame(0),
- _lastRenderedFrame(0),
- _mouseIsCaptured(false),
- _isReturning(false),
- _accumulatedTime(0),
- _returnRoutesCurrentFrame(0) {
+ : Control(engine, key, CONTROL_LEVER),
+ _frameInfo(0),
+ _frameCount(0),
+ _startFrame(0),
+ _currentFrame(0),
+ _lastRenderedFrame(0),
+ _mouseIsCaptured(false),
+ _isReturning(false),
+ _accumulatedTime(0),
+ _returnRoutesCurrentFrame(0),
+ _animation(NULL),
+ _cursor(CursorIndex_Active),
+ _mirrored(false) {
// Loop until we find the closing brace
Common::String line = stream.readLine();
- trimCommentsAndWhiteSpace(&line);
+ _engine->getScriptManager()->trimCommentsAndWhiteSpace(&line);
+
+ Common::String param;
+ Common::String values;
+ getParams(line, param, values);
while (!stream.eos() && !line.contains('}')) {
- if (line.matchString("*descfile*", true)) {
+ if (param.matchString("descfile", true)) {
char levFileName[25];
- sscanf(line.c_str(), "%*[^(](%25[^)])", levFileName);
+ sscanf(values.c_str(), "%24s", levFileName);
parseLevFile(levFileName);
- } else if (line.matchString("*cursor*", true)) {
+ } else if (param.matchString("cursor", true)) {
char cursorName[25];
- sscanf(line.c_str(), "%*[^(](%25[^)])", cursorName);
+ sscanf(values.c_str(), "%24s", cursorName);
- _cursorName = Common::String(cursorName);
+ _cursor = _engine->getCursorManager()->getCursorId(Common::String(cursorName));
}
line = stream.readLine();
- trimCommentsAndWhiteSpace(&line);
+ _engine->getScriptManager()->trimCommentsAndWhiteSpace(&line);
+ getParams(line, param, values);
}
renderFrame(_currentFrame);
}
LeverControl::~LeverControl() {
- if (_fileType == AVI) {
- delete _animation.avi;
- } else if (_fileType == RLF) {
- delete _animation.rlf;
- }
-
+ if (_animation)
+ delete _animation;
+
delete[] _frameInfo;
}
void LeverControl::parseLevFile(const Common::String &fileName) {
Common::File file;
- if (!file.open(fileName)) {
+ if (!_engine->getSearchManager()->openFile(file, fileName)) {
warning("LEV file %s could could be opened", fileName.c_str());
return;
}
- Common::String line = file.readLine();
+ Common::String line;
+ Common::String param;
+ Common::String values;
while (!file.eos()) {
- if (line.matchString("*animation_id*", true)) {
+ line = file.readLine();
+ getLevParams(line, param, values);
+
+ if (param.matchString("animation_id", true)) {
// Not used
- } else if (line.matchString("*filename*", true)) {
- char fileNameBuffer[25];
- sscanf(line.c_str(), "%*[^:]:%25[^~]~", fileNameBuffer);
-
- Common::String animationFileName(fileNameBuffer);
-
- if (animationFileName.hasSuffix(".avi")) {
- _animation.avi = new ZorkAVIDecoder();
- _animation.avi->loadFile(animationFileName);
- _fileType = AVI;
- } else if (animationFileName.hasSuffix(".rlf")) {
- _animation.rlf = new RlfAnimation(animationFileName, false);
- _fileType = RLF;
- }
- } else if (line.matchString("*skipcolor*", true)) {
+ } else if (param.matchString("filename", true)) {
+ _animation = _engine->loadAnimation(values);
+ } else if (param.matchString("skipcolor", true)) {
// Not used
- } else if (line.matchString("*anim_coords*", true)) {
+ } else if (param.matchString("anim_coords", true)) {
int left, top, right, bottom;
- sscanf(line.c_str(), "%*[^:]:%d %d %d %d~", &left, &top, &right, &bottom);
+ sscanf(values.c_str(), "%d %d %d %d", &left, &top, &right, &bottom);
_animationCoords.left = left;
_animationCoords.top = top;
_animationCoords.right = right;
_animationCoords.bottom = bottom;
- } else if (line.matchString("*mirrored*", true)) {
+ } else if (param.matchString("mirrored", true)) {
uint mirrored;
- sscanf(line.c_str(), "%*[^:]:%u~", &mirrored);
+ sscanf(values.c_str(), "%u", &mirrored);
_mirrored = mirrored == 0 ? false : true;
- } else if (line.matchString("*frames*", true)) {
- sscanf(line.c_str(), "%*[^:]:%u~", &_frameCount);
+ } else if (param.matchString("frames", true)) {
+ sscanf(values.c_str(), "%u", &_frameCount);
_frameInfo = new FrameInfo[_frameCount];
- } else if (line.matchString("*elsewhere*", true)) {
+ } else if (param.matchString("elsewhere", true)) {
// Not used
- } else if (line.matchString("*out_of_control*", true)) {
+ } else if (param.matchString("out_of_control", true)) {
// Not used
- } else if (line.matchString("*start_pos*", true)) {
- sscanf(line.c_str(), "%*[^:]:%u~", &_startFrame);
+ } else if (param.matchString("start_pos", true)) {
+ sscanf(values.c_str(), "%u", &_startFrame);
_currentFrame = _startFrame;
- } else if (line.matchString("*hotspot_deltas*", true)) {
+ } else if (param.matchString("hotspot_deltas", true)) {
uint x;
uint y;
- sscanf(line.c_str(), "%*[^:]:%u %u~", &x, &y);
+ sscanf(values.c_str(), "%u %u", &x, &y);
_hotspotDelta.x = x;
_hotspotDelta.y = y;
+ } else if (param.matchString("venus_id", true)) {
+ _venusId = atoi(values.c_str());
} else {
uint frameNumber;
uint x, y;
+ line.toLowercase();
+
if (sscanf(line.c_str(), "%u:%u %u", &frameNumber, &x, &y) == 3) {
_frameInfo[frameNumber].hotspot.left = x;
_frameInfo[frameNumber].hotspot.top = y;
@@ -158,13 +156,13 @@ void LeverControl::parseLevFile(const Common::String &fileName) {
_frameInfo[frameNumber].hotspot.bottom = y + _hotspotDelta.y;
}
- Common::StringTokenizer tokenizer(line, " ^=()");
+ Common::StringTokenizer tokenizer(line, " ^=()~");
tokenizer.nextToken();
tokenizer.nextToken();
Common::String token = tokenizer.nextToken();
while (!tokenizer.empty()) {
- if (token == "D") {
+ if (token == "d") {
token = tokenizer.nextToken();
uint angle;
@@ -172,7 +170,7 @@ void LeverControl::parseLevFile(const Common::String &fileName) {
sscanf(token.c_str(), "%u,%u", &toFrame, &angle);
_frameInfo[frameNumber].directions.push_back(Direction(angle, toFrame));
- } else if (token.hasPrefix("P")) {
+ } else if (token.hasPrefix("p")) {
// Format: P(<from> to <to>)
tokenizer.nextToken();
tokenizer.nextToken();
@@ -186,26 +184,26 @@ void LeverControl::parseLevFile(const Common::String &fileName) {
}
}
- line = file.readLine();
+ // Don't read lines in this place because last will not be parsed.
}
}
-void LeverControl::onMouseDown(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {
- if (!_enabled) {
- return;
- }
-
+bool LeverControl::onMouseDown(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {
+ if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED)
+ return false;
+
if (_frameInfo[_currentFrame].hotspot.contains(backgroundImageSpacePos)) {
+ setVenus();
_mouseIsCaptured = true;
_lastMousePos = backgroundImageSpacePos;
}
+ return false;
}
-void LeverControl::onMouseUp(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {
- if (!_enabled) {
- return;
- }
-
+bool LeverControl::onMouseUp(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {
+ if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED)
+ return false;
+
if (_mouseIsCaptured) {
_mouseIsCaptured = false;
_engine->getScriptManager()->setStateValue(_key, _currentFrame);
@@ -214,20 +212,19 @@ void LeverControl::onMouseUp(const Common::Point &screenSpacePos, const Common::
_returnRoutesCurrentProgress = _frameInfo[_currentFrame].returnRoute.begin();
_returnRoutesCurrentFrame = _currentFrame;
}
+ return false;
}
bool LeverControl::onMouseMove(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {
- if (!_enabled) {
+ if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED)
return false;
- }
-
+
bool cursorWasChanged = false;
if (_mouseIsCaptured) {
- // Make sure the square distance between the last point and the current point is greater than 64
+ // Make sure the square distance between the last point and the current point is greater than 16
// This is a heuristic. This determines how responsive the lever is to mouse movement.
- // TODO: Fiddle with the heuristic to get a good lever responsiveness 'feel'
- if (_lastMousePos.sqrDist(backgroundImageSpacePos) >= 64) {
+ if (_lastMousePos.sqrDist(backgroundImageSpacePos) >= 16) {
int angle = calculateVectorAngle(_lastMousePos, backgroundImageSpacePos);
_lastMousePos = backgroundImageSpacePos;
@@ -240,7 +237,7 @@ bool LeverControl::onMouseMove(const Common::Point &screenSpacePos, const Common
}
}
} else if (_frameInfo[_currentFrame].hotspot.contains(backgroundImageSpacePos)) {
- _engine->getCursorManager()->changeCursor(_cursorName);
+ _engine->getCursorManager()->changeCursor(_cursor);
cursorWasChanged = true;
}
@@ -248,9 +245,8 @@ bool LeverControl::onMouseMove(const Common::Point &screenSpacePos, const Common
}
bool LeverControl::process(uint32 deltaTimeInMillis) {
- if (!_enabled) {
+ if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED)
return false;
- }
if (_isReturning) {
_accumulatedTime += deltaTimeInMillis;
@@ -276,7 +272,7 @@ bool LeverControl::process(uint32 deltaTimeInMillis) {
renderFrame(_returnRoutesCurrentFrame);
}
}
-
+
return false;
}
@@ -301,7 +297,7 @@ int LeverControl::calculateVectorAngle(const Common::Point &pointOne, const Comm
// Calculate the angle using arctan
// Then convert to degrees. (180 / 3.14159 = 57.2958)
- int angle = int(atan((float)yDist / (float)xDist) * 57);
+ int angle = int(atan((float)yDist / (float)abs(xDist)) * 57);
// Calculate what quadrant pointTwo is in
uint quadrant = ((yDist > 0 ? 1 : 0) << 1) | (xDist < 0 ? 1 : 0);
@@ -350,16 +346,16 @@ int LeverControl::calculateVectorAngle(const Common::Point &pointOne, const Comm
// Convert the local angles to unit circle angles
switch (quadrant) {
case 0:
- angle = 180 + angle;
+ angle = -angle;
break;
case 1:
- // Do nothing
+ angle = angle + 180;
break;
case 2:
- angle = 180 + angle;
+ angle = 360 - angle;
break;
case 3:
- angle = 360 + angle;
+ angle = 180 + angle;
break;
}
@@ -377,26 +373,36 @@ void LeverControl::renderFrame(uint frameNumber) {
_lastRenderedFrame = frameNumber;
}
- const uint16 *frameData = 0;
- int x = _animationCoords.left;
- int y = _animationCoords.top;
- int width = 0;
- int height = 0;
-
- if (_fileType == RLF) {
- // getFrameData() will automatically optimize to getNextFrame() / getPreviousFrame() if it can
- frameData = (const uint16 *)_animation.rlf->getFrameData(frameNumber)->getPixels();
- width = _animation.rlf->width(); // Use the animation width instead of _animationCoords.width()
- height = _animation.rlf->height(); // Use the animation height instead of _animationCoords.height()
- } else if (_fileType == AVI) {
- _animation.avi->seekToFrame(frameNumber);
- const Graphics::Surface *surface = _animation.avi->decodeNextFrame();
- frameData = (const uint16 *)surface->getPixels();
- width = surface->w;
- height = surface->h;
- }
+ const Graphics::Surface *frameData;
+
+ _animation->seekToFrame(frameNumber);
+ frameData = _animation->decodeNextFrame();
+ if (frameData)
+ _engine->getRenderManager()->blitSurfaceToBkgScaled(*frameData, _animationCoords);
+}
+
+void LeverControl::getLevParams(const Common::String &inputStr, Common::String &parameter, Common::String &values) {
+ const char *chrs = inputStr.c_str();
+ uint lbr;
+
+ for (lbr = 0; lbr < inputStr.size(); lbr++)
+ if (chrs[lbr] == ':')
+ break;
+
+ if (lbr >= inputStr.size())
+ return;
+
+ uint rbr;
+
+ for (rbr = lbr + 1; rbr < inputStr.size(); rbr++)
+ if (chrs[rbr] == '~')
+ break;
+
+ if (rbr >= inputStr.size())
+ return;
- _engine->getRenderManager()->copyRectToWorkingWindow(frameData, x, y, width, width, height);
+ parameter = Common::String(chrs, chrs + lbr);
+ values = Common::String(chrs + lbr + 1, chrs + rbr);
}
} // End of namespace ZVision
diff --git a/engines/zvision/scripting/controls/lever_control.h b/engines/zvision/scripting/controls/lever_control.h
index 49e4fd3806..8787234c51 100644
--- a/engines/zvision/scripting/controls/lever_control.h
+++ b/engines/zvision/scripting/controls/lever_control.h
@@ -28,22 +28,19 @@
#include "common/list.h"
#include "common/rect.h"
+namespace Video {
+ class VideoDecoder;
+}
namespace ZVision {
-class ZorkAVIDecoder;
-class RlfAnimation;
-
+// Only used in Zork Nemesis, handles draggable levers (te2e, tm7e, tp2e, tt2e, tz2e)
class LeverControl : public Control {
public:
LeverControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream);
~LeverControl();
private:
- enum FileType {
- RLF = 1,
- AVI = 2
- };
struct Direction {
Direction(uint a, uint t) : angle(a), toFrame(t) {}
@@ -64,13 +61,9 @@ private:
};
private:
- union {
- RlfAnimation *rlf;
- ZorkAVIDecoder *avi;
- } _animation;
- FileType _fileType;
+ Video::VideoDecoder *_animation;
- Common::String _cursorName;
+ int _cursor;
Common::Rect _animationCoords;
bool _mirrored;
uint _frameCount;
@@ -88,8 +81,8 @@ private:
uint32 _accumulatedTime;
public:
- void onMouseDown(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos);
- void onMouseUp(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos);
+ bool onMouseDown(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos);
+ bool onMouseUp(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos);
bool onMouseMove(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos);
bool process(uint32 deltaTimeInMillis);
@@ -120,6 +113,7 @@ private:
*/
static int calculateVectorAngle(const Common::Point &pointOne, const Common::Point &pointTwo);
void renderFrame(uint frameNumber);
+ void getLevParams(const Common::String &inputStr, Common::String &parameter, Common::String &values);
};
} // End of namespace ZVision
diff --git a/engines/zvision/scripting/controls/paint_control.cpp b/engines/zvision/scripting/controls/paint_control.cpp
new file mode 100644
index 0000000000..62dde3d170
--- /dev/null
+++ b/engines/zvision/scripting/controls/paint_control.cpp
@@ -0,0 +1,219 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public 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 "zvision/scripting/controls/paint_control.h"
+
+#include "zvision/zvision.h"
+#include "zvision/scripting/script_manager.h"
+#include "zvision/graphics/cursors/cursor_manager.h"
+#include "zvision/graphics/render_manager.h"
+
+namespace ZVision {
+
+PaintControl::PaintControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream)
+ : Control(engine, key, CONTROL_PAINT) {
+
+ _cursor = CursorIndex_Active;
+ _paint = NULL;
+ _bkg = NULL;
+ _brush = NULL;
+ _colorKey = 0;
+ _mouseDown = false;
+
+ // Loop until we find the closing brace
+ Common::String line = stream.readLine();
+ _engine->getScriptManager()->trimCommentsAndWhiteSpace(&line);
+ Common::String param;
+ Common::String values;
+ getParams(line, param, values);
+
+ while (!stream.eos() && !line.contains('}')) {
+ if (param.matchString("rectangle", true)) {
+ int x;
+ int y;
+ int width;
+ int height;
+
+ sscanf(values.c_str(), "%d %d %d %d", &x, &y, &width, &height);
+
+ _rectangle = Common::Rect(x, y, width + x, height + y);
+ } else if (param.matchString("cursor", true)) {
+ _cursor = _engine->getCursorManager()->getCursorId(values);
+ } else if (param.matchString("brush_file", true)) {
+ _brush = _engine->getRenderManager()->loadImage(values, false);
+ } else if (param.matchString("venus_id", true)) {
+ _venusId = atoi(values.c_str());
+ } else if (param.matchString("paint_file", true)) {
+ _paint = _engine->getRenderManager()->loadImage(values, false);
+ } else if (param.matchString("eligible_objects", true)) {
+ char buf[256];
+ memset(buf, 0, 256);
+ strncpy(buf, values.c_str(), 255);
+
+ char *curpos = buf;
+ char *strend = buf + strlen(buf);
+ while (true) {
+ char *st = curpos;
+
+ if (st >= strend)
+ break;
+
+ while (*curpos != ' ' && curpos < strend)
+ curpos++;
+
+ *curpos = 0;
+ curpos++;
+
+ int obj = atoi(st);
+
+ _eligibleObjects.push_back(obj);
+ }
+ }
+
+ line = stream.readLine();
+ _engine->getScriptManager()->trimCommentsAndWhiteSpace(&line);
+ getParams(line, param, values);
+ }
+
+ if (_paint) {
+ _colorKey = _paint->format.RGBToColor(255, 0, 255);
+ _bkg = new Graphics::Surface;
+ _bkg->create(_rectangle.width(), _rectangle.height(), _paint->format);
+ _bkg->fillRect(Common::Rect(_rectangle.width(), _rectangle.height()), _colorKey);
+
+ Graphics::Surface *tmp = new Graphics::Surface;
+ tmp->create(_rectangle.width(), _rectangle.height(), _paint->format);
+ _engine->getRenderManager()->blitSurfaceToSurface(*_paint, _rectangle, *tmp, 0, 0);
+ _paint->free();
+ delete _paint;
+ _paint = tmp;
+ }
+}
+
+PaintControl::~PaintControl() {
+ // Clear the state value back to 0
+ //_engine->getScriptManager()->setStateValue(_key, 0);
+ if (_paint) {
+ _paint->free();
+ delete _paint;
+ }
+ if (_brush) {
+ _brush->free();
+ delete _brush;
+ }
+ if (_bkg) {
+ _bkg->free();
+ delete _bkg;
+ }
+}
+
+bool PaintControl::onMouseUp(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {
+ if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED)
+ return false;
+
+ _mouseDown = false;
+
+ return false;
+}
+
+bool PaintControl::onMouseDown(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {
+ if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED)
+ return false;
+
+ if (_rectangle.contains(backgroundImageSpacePos)) {
+ int mouseItem = _engine->getScriptManager()->getStateValue(StateKey_InventoryItem);
+
+ if (eligeblity(mouseItem)) {
+ setVenus();
+ _mouseDown = true;
+ }
+ }
+
+ return false;
+}
+
+bool PaintControl::onMouseMove(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {
+ if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED)
+ return false;
+
+ if (_rectangle.contains(backgroundImageSpacePos)) {
+ int mouseItem = _engine->getScriptManager()->getStateValue(StateKey_InventoryItem);
+
+ if (eligeblity(mouseItem)) {
+ _engine->getCursorManager()->changeCursor(_cursor);
+
+ if (_mouseDown) {
+ Common::Rect bkgRect = paint(backgroundImageSpacePos);
+ if (!bkgRect.isEmpty()) {
+ Common::Rect imgRect = bkgRect;
+ imgRect.translate(-_rectangle.left, -_rectangle.top);
+
+ Graphics::Surface imgUpdate = _bkg->getSubArea(imgRect);
+
+ _engine->getRenderManager()->blitSurfaceToBkg(imgUpdate, bkgRect.left, bkgRect.top, _colorKey);
+ }
+ }
+ return true;
+ }
+ }
+
+ return false;
+}
+
+bool PaintControl::eligeblity(int itemId) {
+ for (Common::List<int>::iterator it = _eligibleObjects.begin(); it != _eligibleObjects.end(); it++)
+ if (*it == itemId)
+ return true;
+ return false;
+}
+
+Common::Rect PaintControl::paint(const Common::Point &point) {
+ Common::Rect paintRect = Common::Rect(_brush->w, _brush->h);
+ paintRect.moveTo(point);
+ paintRect.clip(_rectangle);
+
+ if (!paintRect.isEmpty()) {
+ Common::Rect brushRect = paintRect;
+ brushRect.translate(-point.x, -point.y);
+
+ Common::Rect bkgRect = paintRect;
+ bkgRect.translate(-_rectangle.left, -_rectangle.top);
+
+ for (int yy = 0; yy < brushRect.height(); yy++) {
+ uint16 *mask = (uint16 *)_brush->getBasePtr(brushRect.left, brushRect.top + yy);
+ uint16 *from = (uint16 *)_paint->getBasePtr(bkgRect.left, bkgRect.top + yy);
+ uint16 *to = (uint16 *)_bkg->getBasePtr(bkgRect.left, bkgRect.top + yy);
+ for (int xx = 0; xx < brushRect.width(); xx++) {
+ if (*mask != 0)
+ *(to + xx) = *(from + xx);
+
+ mask++;
+ }
+ }
+
+ }
+ return paintRect;
+}
+
+} // End of namespace ZVision
diff --git a/engines/zvision/scripting/controls/paint_control.h b/engines/zvision/scripting/controls/paint_control.h
new file mode 100644
index 0000000000..8c01f0e68a
--- /dev/null
+++ b/engines/zvision/scripting/controls/paint_control.h
@@ -0,0 +1,92 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public 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 ZVISION_PAINT_CONTROL_H
+#define ZVISION_PAINT_CONTROL_H
+
+#include "zvision/scripting/control.h"
+
+#include "graphics/surface.h"
+
+#include "common/rect.h"
+#include "common/list.h"
+
+namespace ZVision {
+
+// Only used in Zork Nemesis, handles the painting puzzle screen in Lucien's room in Irondune (ch4g)
+class PaintControl : public Control {
+public:
+ PaintControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream);
+ ~PaintControl();
+
+ /**
+ * @param screenSpacePos The position of the mouse in screen space
+ * @param backgroundImageSpacePos The position of the mouse in background image space
+ */
+ bool onMouseUp(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos);
+
+ /**
+ * @param screenSpacePos The position of the mouse in screen space
+ * @param backgroundImageSpacePos The position of the mouse in background image space
+ */
+ bool onMouseDown(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos);
+ /**
+ * Called on every MouseMove. Tests if the mouse is inside _hotspot, and if so, sets the cursor.
+ *
+ * @param engine The base engine
+ * @param screenSpacePos The position of the mouse in screen space
+ * @param backgroundImageSpacePos The position of the mouse in background image space
+ * @return Was the cursor changed?
+ */
+ bool onMouseMove(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos);
+
+ bool process(uint32 deltaTimeInMillis) {
+ return false;
+ };
+
+private:
+ /**
+ * The area that will trigger the event
+ * This is in image space coordinates, NOT screen space
+ */
+
+ uint32 _colorKey;
+
+ Graphics::Surface *_paint;
+ Graphics::Surface *_bkg;
+ Graphics::Surface *_brush;
+
+ Common::List<int> _eligibleObjects;
+
+ int _cursor;
+ Common::Rect _rectangle;
+
+ bool _mouseDown;
+
+ bool eligeblity(int itemId);
+ Common::Rect paint(const Common::Point &point);
+
+};
+
+} // End of namespace ZVision
+
+#endif
diff --git a/engines/zvision/scripting/controls/push_toggle_control.cpp b/engines/zvision/scripting/controls/push_toggle_control.cpp
index 82736b7576..f51a28d644 100644
--- a/engines/zvision/scripting/controls/push_toggle_control.cpp
+++ b/engines/zvision/scripting/controls/push_toggle_control.cpp
@@ -26,73 +26,122 @@
#include "zvision/zvision.h"
#include "zvision/scripting/script_manager.h"
-#include "zvision/cursors/cursor_manager.h"
-#include "zvision/utility/utility.h"
+#include "zvision/graphics/cursors/cursor_manager.h"
#include "common/stream.h"
-
namespace ZVision {
PushToggleControl::PushToggleControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream)
- : Control(engine, key) {
+ : Control(engine, key, CONTROL_PUSHTGL),
+ _countTo(2),
+ _cursor(CursorIndex_Active),
+ _event(Common::EVENT_LBUTTONUP) {
+
+ _hotspots.clear();
+
// Loop until we find the closing brace
Common::String line = stream.readLine();
- trimCommentsAndWhiteSpace(&line);
+ _engine->getScriptManager()->trimCommentsAndWhiteSpace(&line);
+ Common::String param;
+ Common::String values;
+ getParams(line, param, values);
while (!stream.eos() && !line.contains('}')) {
- if (line.matchString("*_hotspot*", true)) {
+ if (param.matchString("*_hotspot", true)) {
uint x;
uint y;
uint width;
uint height;
- sscanf(line.c_str(), "%*[^(](%u,%u,%u,%u)", &x, &y, &width, &height);
-
- _hotspot = Common::Rect(x, y, x + width, y + height);
- } else if (line.matchString("cursor*", true)) {
- char nameBuffer[25];
-
- sscanf(line.c_str(), "%*[^(](%25[^)])", nameBuffer);
-
- _hoverCursor = Common::String(nameBuffer);
+ sscanf(values.c_str(), "%u,%u,%u,%u", &x, &y, &width, &height);
+
+ _hotspots.push_back(Common::Rect(x, y, x + width + 1, y + height + 1));
+ } else if (param.matchString("cursor", true)) {
+ _cursor = _engine->getCursorManager()->getCursorId(values);
+ } else if (param.matchString("animation", true)) {
+ // Not used
+ } else if (param.matchString("sound", true)) {
+ // Not used
+ } else if (param.matchString("count_to", true)) {
+ sscanf(values.c_str(), "%u", &_countTo);
+ } else if (param.matchString("mouse_event", true)) {
+ if (values.equalsIgnoreCase("up")) {
+ _event = Common::EVENT_LBUTTONUP;
+ } else if (values.equalsIgnoreCase("down")) {
+ _event = Common::EVENT_LBUTTONDOWN;
+ } else if (values.equalsIgnoreCase("double")) {
+ // Not used
+ }
+ } else if (param.matchString("venus_id", true)) {
+ _venusId = atoi(values.c_str());
}
line = stream.readLine();
- trimCommentsAndWhiteSpace(&line);
+ _engine->getScriptManager()->trimCommentsAndWhiteSpace(&line);
+ getParams(line, param, values);
}
- if (_hotspot.isEmpty() || _hoverCursor.empty()) {
- warning("Push_toggle cursor %u was parsed incorrectly", key);
+ if (_hotspots.size() == 0) {
+ warning("Push_toggle %u was parsed incorrectly", key);
}
}
PushToggleControl::~PushToggleControl() {
- // Clear the state value back to 0
- _engine->getScriptManager()->setStateValue(_key, 0);
+ _hotspots.clear();
}
-void PushToggleControl::onMouseUp(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {
- if (!_enabled) {
- return;
+bool PushToggleControl::onMouseUp(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {
+ if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED)
+ return false;
+
+ if (_event != Common::EVENT_LBUTTONUP)
+ return false;
+
+ if (contain(backgroundImageSpacePos)) {
+ setVenus();
+ int32 val = _engine->getScriptManager()->getStateValue(_key);
+ val = (val + 1) % _countTo;
+ _engine->getScriptManager()->setStateValue(_key, val);
+ return true;
}
-
- if (_hotspot.contains(backgroundImageSpacePos)) {
- _engine->getScriptManager()->setStateValue(_key, 1);
+ return false;
+}
+
+bool PushToggleControl::onMouseDown(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {
+ if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED)
+ return false;
+
+ if (_event != Common::EVENT_LBUTTONDOWN)
+ return false;
+
+ if (contain(backgroundImageSpacePos)) {
+ setVenus();
+ int32 val = _engine->getScriptManager()->getStateValue(_key);
+ val = (val + 1) % _countTo;
+ _engine->getScriptManager()->setStateValue(_key, val);
+ return true;
}
+ return false;
}
bool PushToggleControl::onMouseMove(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {
- if (!_enabled) {
+ if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED)
return false;
- }
-
- if (_hotspot.contains(backgroundImageSpacePos)) {
- _engine->getCursorManager()->changeCursor(_hoverCursor);
+
+ if (contain(backgroundImageSpacePos)) {
+ _engine->getCursorManager()->changeCursor(_cursor);
return true;
}
return false;
}
+bool PushToggleControl::contain(const Common::Point &point) {
+ for (uint i = 0; i < _hotspots.size(); i++)
+ if (_hotspots[i].contains(point))
+ return true;
+ return false;
+}
+
} // End of namespace ZVision
diff --git a/engines/zvision/scripting/controls/push_toggle_control.h b/engines/zvision/scripting/controls/push_toggle_control.h
index 3854fc2005..9444c77cb6 100644
--- a/engines/zvision/scripting/controls/push_toggle_control.h
+++ b/engines/zvision/scripting/controls/push_toggle_control.h
@@ -26,7 +26,8 @@
#include "zvision/scripting/control.h"
#include "common/rect.h"
-
+#include "common/events.h"
+#include "common/array.h"
namespace ZVision {
@@ -36,12 +37,19 @@ public:
~PushToggleControl();
/**
+ * Called when LeftMouse is pushed. Default is NOP.
+ *
+ * @param screenSpacePos The position of the mouse in screen space
+ * @param backgroundImageSpacePos The position of the mouse in background image space
+ */
+ bool onMouseDown(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos);
+ /**
* Called when LeftMouse is lifted. Calls ScriptManager::setStateValue(_key, 1);
*
* @param screenSpacePos The position of the mouse in screen space
* @param backgroundImageSpacePos The position of the mouse in background image space
*/
- void onMouseUp(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos);
+ bool onMouseUp(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos);
/**
* Called on every MouseMove. Tests if the mouse is inside _hotspot, and if so, sets the cursor.
*
@@ -57,9 +65,15 @@ private:
* The area that will trigger the event
* This is in image space coordinates, NOT screen space
*/
- Common::Rect _hotspot;
+ Common::Array<Common::Rect> _hotspots;
/** The cursor to use when hovering over _hotspot */
- Common::String _hoverCursor;
+ int _cursor;
+ /** Button maximal values count */
+ uint _countTo;
+
+ Common::EventType _event;
+
+ bool contain(const Common::Point &point);
};
} // End of namespace ZVision
diff --git a/engines/zvision/scripting/controls/safe_control.cpp b/engines/zvision/scripting/controls/safe_control.cpp
new file mode 100644
index 0000000000..6ba34106d0
--- /dev/null
+++ b/engines/zvision/scripting/controls/safe_control.cpp
@@ -0,0 +1,180 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public 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 "zvision/scripting/controls/safe_control.h"
+
+#include "zvision/zvision.h"
+#include "zvision/scripting/script_manager.h"
+#include "zvision/graphics/render_manager.h"
+#include "zvision/graphics/cursors/cursor_manager.h"
+
+#include "common/stream.h"
+#include "common/file.h"
+#include "common/tokenizer.h"
+#include "common/system.h"
+#include "graphics/surface.h"
+#include "video/video_decoder.h"
+
+namespace ZVision {
+
+SafeControl::SafeControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream)
+ : Control(engine, key, CONTROL_SAFE) {
+ _statesCount = 0;
+ _curState = 0;
+ _animation = NULL;
+ _innerRaduis = 0;
+ _innerRadiusSqr = 0;
+ _outerRadius = 0;
+ _outerRadiusSqr = 0;
+ _zeroPointer = 0;
+ _startPointer = 0;
+ _targetFrame = 0;
+
+ // Loop until we find the closing brace
+ Common::String line = stream.readLine();
+ _engine->getScriptManager()->trimCommentsAndWhiteSpace(&line);
+ Common::String param;
+ Common::String values;
+ getParams(line, param, values);
+
+ while (!stream.eos() && !line.contains('}')) {
+ if (param.matchString("animation", true)) {
+ _animation = _engine->loadAnimation(values);
+ _animation->start();
+ } else if (param.matchString("rectangle", true)) {
+ int x;
+ int y;
+ int width;
+ int height;
+
+ sscanf(values.c_str(), "%d %d %d %d", &x, &y, &width, &height);
+
+ _rectangle = Common::Rect(x, y, width, height);
+ } else if (param.matchString("num_states", true)) {
+ _statesCount = atoi(values.c_str());
+ } else if (param.matchString("center", true)) {
+ int x;
+ int y;
+
+ sscanf(values.c_str(), "%d %d", &x, &y);
+ _center = Common::Point(x, y);
+ } else if (param.matchString("dial_inner_radius", true)) {
+ _innerRaduis = atoi(values.c_str());
+ _innerRadiusSqr = _innerRaduis * _innerRaduis;
+ } else if (param.matchString("radius", true)) {
+ _outerRadius = atoi(values.c_str());
+ _outerRadiusSqr = _outerRadius * _outerRadius;
+ } else if (param.matchString("zero_radians_offset", true)) {
+ _zeroPointer = atoi(values.c_str());
+ } else if (param.matchString("pointer_offset", true)) {
+ _startPointer = atoi(values.c_str());
+ _curState = _startPointer;
+ } else if (param.matchString("cursor", true)) {
+ // Not used
+ } else if (param.matchString("mirrored", true)) {
+ // Not used
+ } else if (param.matchString("venus_id", true)) {
+ _venusId = atoi(values.c_str());
+ }
+
+ line = stream.readLine();
+ _engine->getScriptManager()->trimCommentsAndWhiteSpace(&line);
+ getParams(line, param, values);
+ }
+
+ if (_animation)
+ _animation->seekToFrame(_curState);
+}
+
+SafeControl::~SafeControl() {
+ if (_animation)
+ delete _animation;
+
+}
+
+bool SafeControl::process(uint32 deltaTimeInMillis) {
+ if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED)
+ return false;
+
+ if (_animation && _animation->getCurFrame() != _targetFrame && _animation->needsUpdate()) {
+ // If we're past the target frame, move back one
+ if (_animation->getCurFrame() > _targetFrame)
+ _animation->seekToFrame(_animation->getCurFrame() - 1);
+
+ const Graphics::Surface *frameData = _animation->decodeNextFrame();
+ if (frameData)
+ _engine->getRenderManager()->blitSurfaceToBkg(*frameData, _rectangle.left, _rectangle.top);
+ }
+
+ return false;
+}
+
+bool SafeControl::onMouseMove(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {
+ if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED)
+ return false;
+
+ if (_rectangle.contains(backgroundImageSpacePos)) {
+ int32 mR = backgroundImageSpacePos.sqrDist(_center);
+ if (mR <= _outerRadiusSqr && mR >= _innerRadiusSqr) {
+ _engine->getCursorManager()->changeCursor(CursorIndex_Active);
+ return true;
+ }
+ }
+ return false;
+}
+
+bool SafeControl::onMouseUp(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {
+ if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED)
+ return false;
+
+ if (_rectangle.contains(backgroundImageSpacePos)) {
+ int32 mR = backgroundImageSpacePos.sqrDist(_center);
+ if (mR <= _outerRadiusSqr && mR >= _innerRadiusSqr) {
+ setVenus();
+
+ Common::Point tmp = backgroundImageSpacePos - _center;
+
+ float dd = atan2((float)tmp.x, (float)tmp.y) * 57.29578;
+
+ int16 dp_state = 360 / _statesCount;
+
+ int16 m_state = (_statesCount - ((((int16)dd + 540) % 360) / dp_state)) % _statesCount;
+
+ int16 tmp2 = (m_state + _curState - _zeroPointer + _statesCount - 1) % _statesCount;
+
+ if (_animation)
+ _animation->seekToFrame((_curState + _statesCount - _startPointer) % _statesCount);
+
+ _curState = (_statesCount * 2 + tmp2) % _statesCount;
+
+ _targetFrame = (_curState + _statesCount - _startPointer) % _statesCount;
+
+ _engine->getScriptManager()->setStateValue(_key, _curState);
+ return true;
+ }
+ }
+ return false;
+}
+
+} // End of namespace ZVision
diff --git a/engines/zvision/scripting/controls/safe_control.h b/engines/zvision/scripting/controls/safe_control.h
new file mode 100644
index 0000000000..3e8c17635c
--- /dev/null
+++ b/engines/zvision/scripting/controls/safe_control.h
@@ -0,0 +1,65 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef ZVISION_SAFE_CONTROL_H
+#define ZVISION_SAFE_CONTROL_H
+
+#include "zvision/scripting/control.h"
+
+#include "common/list.h"
+#include "common/rect.h"
+
+namespace Video {
+ class VideoDecoder;
+}
+
+namespace ZVision {
+
+// Only used in Zork Nemesis, handles the safe in the Asylum (ac4g)
+class SafeControl : public Control {
+public:
+ SafeControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream);
+ ~SafeControl();
+
+private:
+ int16 _statesCount;
+ int16 _curState;
+ Video::VideoDecoder *_animation;
+ Common::Point _center;
+ Common::Rect _rectangle;
+ int16 _innerRaduis;
+ int32 _innerRadiusSqr;
+ int16 _outerRadius;
+ int32 _outerRadiusSqr;
+ int16 _zeroPointer;
+ int16 _startPointer;
+ int16 _targetFrame;
+
+public:
+ bool onMouseUp(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos);
+ bool onMouseMove(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos);
+ bool process(uint32 deltaTimeInMillis);
+};
+
+} // End of namespace ZVision
+
+#endif
diff --git a/engines/zvision/scripting/controls/save_control.cpp b/engines/zvision/scripting/controls/save_control.cpp
new file mode 100644
index 0000000000..6cedddffeb
--- /dev/null
+++ b/engines/zvision/scripting/controls/save_control.cpp
@@ -0,0 +1,125 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public 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 "zvision/scripting/controls/input_control.h"
+#include "zvision/scripting/controls/save_control.h"
+
+#include "zvision/zvision.h"
+#include "zvision/scripting/script_manager.h"
+#include "zvision/text/string_manager.h"
+
+#include "zvision/file/save_manager.h"
+#include "zvision/graphics/render_manager.h"
+
+#include "common/str.h"
+#include "common/stream.h"
+
+namespace ZVision {
+
+SaveControl::SaveControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream)
+ : Control(engine, key, CONTROL_SAVE),
+ _saveControl(false) {
+ // Loop until we find the closing brace
+ Common::String line = stream.readLine();
+ _engine->getScriptManager()->trimCommentsAndWhiteSpace(&line);
+ Common::String param;
+ Common::String values;
+ getParams(line, param, values);
+
+ while (!stream.eos() && !line.contains('}')) {
+ if (param.matchString("savebox", true)) {
+ int saveId;
+ int inputId;
+
+ sscanf(values.c_str(), "%d %d", &saveId, &inputId);
+ saveElement elmnt;
+ elmnt.inputKey = inputId;
+ elmnt.saveId = saveId;
+ elmnt.exist = false;
+ _inputs.push_back(elmnt);
+ } else if (param.matchString("control_type", true)) {
+ if (values.contains("save"))
+ _saveControl = true;
+ else
+ _saveControl = false;
+ }
+
+ line = stream.readLine();
+ _engine->getScriptManager()->trimCommentsAndWhiteSpace(&line);
+ getParams(line, param, values);
+ }
+
+ for (saveElmntList::iterator iter = _inputs.begin(); iter != _inputs.end(); ++iter) {
+ Control *ctrl = _engine->getScriptManager()->getControl(iter->inputKey);
+ if (ctrl && ctrl->getType() == Control::CONTROL_INPUT) {
+ InputControl *inp = (InputControl *)ctrl;
+ inp->setReadOnly(!_saveControl);
+ Common::SeekableReadStream *save = _engine->getSaveManager()->getSlotFile(iter->saveId);
+ if (save) {
+ SaveGameHeader header;
+ if (_engine->getSaveManager()->readSaveGameHeader(save, header)) {
+ inp->setText(header.saveName);
+ iter->exist = true;
+ }
+ delete save;
+ }
+ }
+ }
+}
+
+bool SaveControl::process(uint32 deltaTimeInMillis) {
+ for (saveElmntList::iterator iter = _inputs.begin(); iter != _inputs.end(); ++iter) {
+ Control *ctrl = _engine->getScriptManager()->getControl(iter->inputKey);
+ if (ctrl && ctrl->getType() == Control::CONTROL_INPUT) {
+ InputControl *inp = (InputControl *)ctrl;
+ if (inp->enterPress()) {
+ if (_saveControl) {
+ if (inp->getText().size() > 0) {
+ bool toSave = true;
+ if (iter->exist)
+ if (!_engine->getRenderManager()->askQuestion(_engine->getStringManager()->getTextLine(StringManager::ZVISION_STR_SAVEEXIST)))
+ toSave = false;
+
+ if (toSave) {
+ // FIXME: At this point, the screen shows the save control, so the save game thumbnails will always
+ // show the save control
+ _engine->getSaveManager()->saveGameBuffered(iter->saveId, inp->getText());
+ _engine->getRenderManager()->delayedMessage(_engine->getStringManager()->getTextLine(StringManager::ZVISION_STR_SAVED), 2000);
+ _engine->getScriptManager()->changeLocation(_engine->getScriptManager()->getLastMenuLocation());
+ }
+ } else {
+ _engine->getRenderManager()->timedMessage(_engine->getStringManager()->getTextLine(StringManager::ZVISION_STR_SAVEEMPTY), 2000);
+ }
+ } else {
+ _engine->getSaveManager()->loadGame(iter->saveId);
+ return true;
+ }
+ break;
+ }
+ }
+ }
+ return false;
+}
+
+} // End of namespace ZVision
diff --git a/engines/zvision/scripting/controls/save_control.h b/engines/zvision/scripting/controls/save_control.h
new file mode 100644
index 0000000000..cdc50eb54d
--- /dev/null
+++ b/engines/zvision/scripting/controls/save_control.h
@@ -0,0 +1,55 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef ZVISION_SAVE_CONTROL_H
+#define ZVISION_SAVE_CONTROL_H
+
+#include "zvision/scripting/control.h"
+
+#include "common/list.h"
+
+namespace ZVision {
+
+class SaveControl : public Control {
+public:
+ SaveControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream);
+
+private:
+ struct saveElement {
+ int saveId;
+ int inputKey;
+ bool exist;
+ };
+ typedef Common::List<saveElement> saveElmntList;
+ saveElmntList _inputs;
+
+ bool _saveControl;
+
+public:
+
+ bool process(uint32 deltaTimeInMillis);
+
+};
+
+} // End of namespace ZVision
+
+#endif
diff --git a/engines/zvision/scripting/controls/slot_control.cpp b/engines/zvision/scripting/controls/slot_control.cpp
new file mode 100644
index 0000000000..42b54a9ab5
--- /dev/null
+++ b/engines/zvision/scripting/controls/slot_control.cpp
@@ -0,0 +1,219 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public 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 "zvision/scripting/controls/slot_control.h"
+
+#include "zvision/zvision.h"
+#include "zvision/scripting/script_manager.h"
+#include "zvision/graphics/cursors/cursor_manager.h"
+#include "zvision/graphics/render_manager.h"
+
+#include "common/stream.h"
+
+namespace ZVision {
+
+SlotControl::SlotControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream)
+ : Control(engine, key, CONTROL_SLOT),
+ _cursor(CursorIndex_Active),
+ _distanceId('0') {
+
+ _renderedItem = 0;
+ _bkg = NULL;
+
+ // Loop until we find the closing brace
+ Common::String line = stream.readLine();
+ _engine->getScriptManager()->trimCommentsAndWhiteSpace(&line);
+ Common::String param;
+ Common::String values;
+ getParams(line, param, values);
+
+ while (!stream.eos() && !line.contains('}')) {
+ if (param.matchString("hotspot", true)) {
+ int x;
+ int y;
+ int width;
+ int height;
+
+ sscanf(values.c_str(), "%d %d %d %d", &x, &y, &width, &height);
+
+ _hotspot = Common::Rect(x, y, width, height);
+ } else if (param.matchString("rectangle", true)) {
+ int x;
+ int y;
+ int width;
+ int height;
+
+ sscanf(values.c_str(), "%d %d %d %d", &x, &y, &width, &height);
+
+ _rectangle = Common::Rect(x, y, width, height);
+ } else if (param.matchString("cursor", true)) {
+ _cursor = _engine->getCursorManager()->getCursorId(values);
+ } else if (param.matchString("distance_id", true)) {
+ sscanf(values.c_str(), "%c", &_distanceId);
+ } else if (param.matchString("venus_id", true)) {
+ _venusId = atoi(values.c_str());
+ } else if (param.matchString("eligible_objects", true)) {
+ char buf[256];
+ memset(buf, 0, 256);
+ strncpy(buf, values.c_str(), 255);
+
+ char *curpos = buf;
+ char *strend = buf + strlen(buf);
+ while (true) {
+ char *st = curpos;
+
+ if (st >= strend)
+ break;
+
+ while (*curpos != ' ' && curpos < strend)
+ curpos++;
+
+ *curpos = 0;
+ curpos++;
+
+ int obj = atoi(st);
+
+ _eligibleObjects.push_back(obj);
+ }
+ }
+
+ line = stream.readLine();
+ _engine->getScriptManager()->trimCommentsAndWhiteSpace(&line);
+ getParams(line, param, values);
+ }
+
+ if (_hotspot.isEmpty() || _rectangle.isEmpty()) {
+ warning("Slot %u was parsed incorrectly", key);
+ }
+}
+
+SlotControl::~SlotControl() {
+ // Clear the state value back to 0
+ //_engine->getScriptManager()->setStateValue(_key, 0);
+
+ if (_bkg)
+ delete _bkg;
+}
+
+bool SlotControl::onMouseUp(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {
+ if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED)
+ return false;
+
+ if (_hotspot.contains(backgroundImageSpacePos)) {
+ setVenus();
+
+ int item = _engine->getScriptManager()->getStateValue(_key);
+ int mouseItem = _engine->getScriptManager()->getStateValue(StateKey_InventoryItem);
+ if (item != 0) {
+ if (mouseItem != 0) {
+ if (eligeblity(mouseItem)) {
+ _engine->getScriptManager()->inventoryDrop(mouseItem);
+ _engine->getScriptManager()->inventoryAdd(item);
+ _engine->getScriptManager()->setStateValue(_key, mouseItem);
+ }
+ } else {
+ _engine->getScriptManager()->inventoryAdd(item);
+ _engine->getScriptManager()->setStateValue(_key, 0);
+ }
+ } else if (mouseItem == 0) {
+ if (eligeblity(0)) {
+ _engine->getScriptManager()->inventoryDrop(0);
+ _engine->getScriptManager()->setStateValue(_key, 0);
+ }
+ } else if (eligeblity(mouseItem)) {
+ _engine->getScriptManager()->setStateValue(_key, mouseItem);
+ _engine->getScriptManager()->inventoryDrop(mouseItem);
+ }
+ }
+ return false;
+}
+
+bool SlotControl::onMouseMove(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {
+ if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED)
+ return false;
+
+ if (_hotspot.contains(backgroundImageSpacePos)) {
+ _engine->getCursorManager()->changeCursor(_cursor);
+ return true;
+ }
+
+ return false;
+}
+
+bool SlotControl::process(uint32 deltaTimeInMillis) {
+ if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED)
+ return false;
+
+ if (_engine->canRender()) {
+ int curItem = _engine->getScriptManager()->getStateValue(_key);
+ if (curItem != _renderedItem) {
+ if (_renderedItem != 0 && curItem == 0) {
+ _engine->getRenderManager()->blitSurfaceToBkg(*_bkg, _rectangle.left, _rectangle.top);
+ _renderedItem = curItem;
+ } else {
+ if (_renderedItem == 0) {
+ if (_bkg)
+ delete _bkg;
+
+ _bkg = _engine->getRenderManager()->getBkgRect(_rectangle);
+ } else {
+ _engine->getRenderManager()->blitSurfaceToBkg(*_bkg, _rectangle.left, _rectangle.top);
+ }
+
+ char buf[16];
+ if (_engine->getGameId() == GID_NEMESIS)
+ sprintf(buf, "%d%cobj.tga", curItem, _distanceId);
+ else
+ sprintf(buf, "g0z%cu%2.2x1.tga", _distanceId, curItem);
+
+ Graphics::Surface *srf = _engine->getRenderManager()->loadImage(buf);
+
+ int16 drawx = _rectangle.left;
+ int16 drawy = _rectangle.top;
+
+ if (_rectangle.width() > srf->w)
+ drawx = _rectangle.left + (_rectangle.width() - srf->w) / 2;
+
+ if (_rectangle.height() > srf->h)
+ drawy = _rectangle.top + (_rectangle.height() - srf->h) / 2;
+
+ _engine->getRenderManager()->blitSurfaceToBkg(*srf, drawx, drawy, 0);
+
+ delete srf;
+
+ _renderedItem = curItem;
+ }
+ }
+ }
+ return false;
+}
+
+bool SlotControl::eligeblity(int itemId) {
+ for (Common::List<int>::iterator it = _eligibleObjects.begin(); it != _eligibleObjects.end(); it++)
+ if (*it == itemId)
+ return true;
+ return false;
+}
+
+} // End of namespace ZVision
diff --git a/engines/zvision/scripting/controls/slot_control.h b/engines/zvision/scripting/controls/slot_control.h
new file mode 100644
index 0000000000..e776d99311
--- /dev/null
+++ b/engines/zvision/scripting/controls/slot_control.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 ZVISION_SLOT_CONTROL_H
+#define ZVISION_SLOT_CONTROL_H
+
+#include "zvision/scripting/control.h"
+
+#include "graphics/surface.h"
+
+#include "common/rect.h"
+#include "common/list.h"
+
+namespace ZVision {
+
+class SlotControl : public Control {
+public:
+ SlotControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream);
+ ~SlotControl();
+
+ /**
+ * Called when LeftMouse is lifted. Calls ScriptManager::setStateValue(_key, 1);
+ *
+ * @param screenSpacePos The position of the mouse in screen space
+ * @param backgroundImageSpacePos The position of the mouse in background image space
+ */
+ bool onMouseUp(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos);
+ /**
+ * Called on every MouseMove. Tests if the mouse is inside _hotspot, and if so, sets the cursor.
+ *
+ * @param engine The base engine
+ * @param screenSpacePos The position of the mouse in screen space
+ * @param backgroundImageSpacePos The position of the mouse in background image space
+ * @return Was the cursor changed?
+ */
+ bool onMouseMove(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos);
+
+ bool process(uint32 deltaTimeInMillis);
+
+private:
+ /**
+ * The area that will trigger the event
+ * This is in image space coordinates, NOT screen space
+ */
+ Common::Rect _rectangle;
+ Common::Rect _hotspot;
+
+ int _cursor;
+ char _distanceId;
+
+ int _renderedItem;
+
+ Common::List<int> _eligibleObjects;
+
+ bool eligeblity(int itemId);
+
+ Graphics::Surface *_bkg;
+
+ /** The cursor to use when hovering over _hotspot */
+ Common::String _hoverCursor;
+};
+
+} // End of namespace ZVision
+
+#endif
diff --git a/engines/zvision/scripting/controls/titler_control.cpp b/engines/zvision/scripting/controls/titler_control.cpp
new file mode 100644
index 0000000000..542e0a0b67
--- /dev/null
+++ b/engines/zvision/scripting/controls/titler_control.cpp
@@ -0,0 +1,108 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "common/scummsys.h"
+
+#include "zvision/scripting/controls/titler_control.h"
+
+#include "zvision/zvision.h"
+#include "zvision/text/text.h"
+#include "zvision/scripting/script_manager.h"
+#include "zvision/graphics/render_manager.h"
+
+#include "common/stream.h"
+
+namespace ZVision {
+
+TitlerControl::TitlerControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream)
+ : Control(engine, key, CONTROL_TITLER) {
+
+ _surface = NULL;
+ _curString = -1;
+
+ // Loop until we find the closing brace
+ Common::String line = stream.readLine();
+ _engine->getScriptManager()->trimCommentsAndWhiteSpace(&line);
+ Common::String param;
+ Common::String values;
+ getParams(line, param, values);
+
+ while (!stream.eos() && !line.contains('}')) {
+ if (param.matchString("string_resource_file", true)) {
+ readStringsFile(values);
+ } else if (param.matchString("rectangle", true)) {
+ int x;
+ int y;
+ int x2;
+ int y2;
+
+ sscanf(values.c_str(), "%d %d %d %d", &x, &y, &x2, &y2);
+
+ _rectangle = Common::Rect(x, y, x2, y2);
+ }
+
+ line = stream.readLine();
+ _engine->getScriptManager()->trimCommentsAndWhiteSpace(&line);
+ getParams(line, param, values);
+ }
+
+ if (!_rectangle.isEmpty()) {
+ _surface = new Graphics::Surface;
+ _surface->create(_rectangle.width(), _rectangle.height(), _engine->_resourcePixelFormat);
+ _surface->fillRect(Common::Rect(_surface->w, _surface->h), 0);
+ }
+}
+
+TitlerControl::~TitlerControl() {
+ if (_surface) {
+ _surface->free();
+ delete _surface;
+ }
+}
+
+void TitlerControl::setString(int strLine) {
+ if (strLine != _curString && strLine >= 0 && strLine < (int)_strings.size()) {
+ _surface->fillRect(Common::Rect(_surface->w, _surface->h), 0);
+ _engine->getTextRenderer()->drawTxtInOneLine(_strings[strLine], *_surface);
+ _engine->getRenderManager()->blitSurfaceToBkg(*_surface, _rectangle.left, _rectangle.top);
+ _curString = strLine;
+ }
+}
+
+void TitlerControl::readStringsFile(const Common::String &fileName) {
+ Common::File file;
+ if (!_engine->getSearchManager()->openFile(file, fileName)) {
+ warning("String_resource_file %s could could be opened", fileName.c_str());
+ return;
+ }
+
+ _strings.clear();
+
+ while (!file.eos()) {
+
+ Common::String line = readWideLine(file);
+ _strings.push_back(line);
+ }
+ file.close();
+}
+
+} // End of namespace ZVision
diff --git a/engines/zvision/scripting/controls/titler_control.h b/engines/zvision/scripting/controls/titler_control.h
new file mode 100644
index 0000000000..dd96e4a846
--- /dev/null
+++ b/engines/zvision/scripting/controls/titler_control.h
@@ -0,0 +1,55 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef ZVISION_TITLER_CONTROL_H
+#define ZVISION_TITLER_CONTROL_H
+
+#include "zvision/scripting/control.h"
+
+#include "graphics/surface.h"
+
+#include "common/rect.h"
+#include "common/array.h"
+
+namespace ZVision {
+
+// Only used in Zork Nemesis, handles the death screen with the Restore/Exit buttons
+class TitlerControl : public Control {
+public:
+ TitlerControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream);
+ ~TitlerControl();
+
+ void setString(int strLine);
+
+private:
+
+ Common::Array< Common::String > _strings;
+ Common::Rect _rectangle;
+ int16 _curString;
+ Graphics::Surface *_surface;
+
+ void readStringsFile(const Common::String &fileName);
+};
+
+} // End of namespace ZVision
+
+#endif
diff --git a/engines/zvision/scripting/effects/animation_effect.cpp b/engines/zvision/scripting/effects/animation_effect.cpp
new file mode 100644
index 0000000000..511a0db353
--- /dev/null
+++ b/engines/zvision/scripting/effects/animation_effect.cpp
@@ -0,0 +1,217 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public 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 "zvision/scripting/effects/animation_effect.h"
+
+#include "zvision/zvision.h"
+#include "zvision/graphics/render_manager.h"
+#include "zvision/scripting/script_manager.h"
+
+#include "graphics/surface.h"
+#include "video/video_decoder.h"
+
+namespace ZVision {
+
+AnimationEffect::AnimationEffect(ZVision *engine, uint32 controlKey, const Common::String &fileName, int32 mask, int32 frate, bool disposeAfterUse)
+ : ScriptingEffect(engine, controlKey, SCRIPTING_EFFECT_ANIM),
+ _disposeAfterUse(disposeAfterUse),
+ _mask(mask),
+ _animation(NULL) {
+
+ _animation = engine->loadAnimation(fileName);
+
+ if (frate > 0) {
+ _frmDelayOverride = (int32)(1000.0 / frate);
+
+ // WORKAROUND: We do not allow the engine to delay more than 66 msec
+ // per frame (15fps max)
+ if (_frmDelayOverride > 66)
+ _frmDelayOverride = 66;
+ } else {
+ _frmDelayOverride = 0;
+ }
+}
+
+AnimationEffect::~AnimationEffect() {
+ if (_animation)
+ delete _animation;
+
+ _engine->getScriptManager()->setStateValue(_key, 2);
+
+ PlayNodes::iterator it = _playList.begin();
+ if (it != _playList.end()) {
+ _engine->getScriptManager()->setStateValue((*it).slot, 2);
+
+ if ((*it)._scaled) {
+ (*it)._scaled->free();
+ delete(*it)._scaled;
+ }
+ }
+
+ _playList.clear();
+}
+
+bool AnimationEffect::process(uint32 deltaTimeInMillis) {
+ ScriptManager *scriptManager = _engine->getScriptManager();
+ RenderManager *renderManager = _engine->getRenderManager();
+ RenderTable::RenderState renderState = renderManager->getRenderTable()->getRenderState();
+ bool isPanorama = (renderState == RenderTable::PANORAMA);
+ int16 velocity = _engine->getMouseVelocity() + _engine->getKeyboardVelocity();
+
+ // Do not update animation nodes in panoramic mode while turning, if the user
+ // has set this option
+ if (scriptManager->getStateValue(StateKey_NoTurnAnim) == 1 && isPanorama && velocity)
+ return false;
+
+ PlayNodes::iterator it = _playList.begin();
+ if (it != _playList.end()) {
+ playnode *nod = &(*it);
+
+ if (nod->_curFrame == -1) {
+ // The node is just beginning playback
+ nod->_curFrame = nod->start;
+
+ _animation->start();
+ _animation->seekToFrame(nod->start);
+ _animation->setEndFrame(nod->stop);
+
+ nod->_delay = deltaTimeInMillis; // Force the frame to draw
+ if (nod->slot)
+ scriptManager->setStateValue(nod->slot, 1);
+ } else if (_animation->endOfVideo()) {
+ // The node has reached the end; check if we need to loop
+ nod->loop--;
+
+ if (nod->loop == 0) {
+ if (nod->slot >= 0)
+ scriptManager->setStateValue(nod->slot, 2);
+ if (nod->_scaled) {
+ nod->_scaled->free();
+ delete nod->_scaled;
+ }
+ _playList.erase(it);
+ return _disposeAfterUse;
+ }
+
+ nod->_curFrame = nod->start;
+ _animation->seekToFrame(nod->start);
+ }
+
+ // Check if we need to draw a frame
+ bool needsUpdate = false;
+ if (_frmDelayOverride == 0) {
+ // If not overridden, use the VideoDecoder's check
+ needsUpdate = _animation->needsUpdate();
+ } else {
+ // Otherwise, implement our own timing
+ nod->_delay -= deltaTimeInMillis;
+
+ if (nod->_delay <= 0) {
+ nod->_delay += _frmDelayOverride;
+ needsUpdate = true;
+ }
+ }
+
+ if (needsUpdate) {
+ const Graphics::Surface *frame = _animation->decodeNextFrame();
+
+ if (frame) {
+ uint32 dstw;
+ uint32 dsth;
+ if (isPanorama) {
+ dstw = nod->pos.height();
+ dsth = nod->pos.width();
+ } else {
+ dstw = nod->pos.width();
+ dsth = nod->pos.height();
+ }
+
+ // We only scale down the animation to fit its frame, not up, otherwise we
+ // end up with distorted animations - e.g. the armor visor in location cz1e
+ // in Nemesis (one of the armors inside Irondune), or the planet in location
+ // aa10 in Nemesis (Juperon, outside the asylum). We do allow scaling up only
+ // when a simple 2x filter is requested (e.g. the alchemists and cup sequence
+ // in Nemesis)
+ if (frame->w > dstw || frame->h > dsth || (frame->w == dstw / 2 && frame->h == dsth / 2)) {
+ if (nod->_scaled)
+ if (nod->_scaled->w != dstw || nod->_scaled->h != dsth) {
+ nod->_scaled->free();
+ delete nod->_scaled;
+ nod->_scaled = NULL;
+ }
+
+ if (!nod->_scaled) {
+ nod->_scaled = new Graphics::Surface;
+ nod->_scaled->create(dstw, dsth, frame->format);
+ }
+
+ renderManager->scaleBuffer(frame->getPixels(), nod->_scaled->getPixels(), frame->w, frame->h, frame->format.bytesPerPixel, dstw, dsth);
+ frame = nod->_scaled;
+ }
+
+ if (isPanorama) {
+ Graphics::Surface *transposed = RenderManager::tranposeSurface(frame);
+ renderManager->blitSurfaceToBkg(*transposed, nod->pos.left, nod->pos.top, _mask);
+ transposed->free();
+ delete transposed;
+ } else {
+ renderManager->blitSurfaceToBkg(*frame, nod->pos.left, nod->pos.top, _mask);
+ }
+ }
+ }
+ }
+
+ return false;
+}
+
+void AnimationEffect::addPlayNode(int32 slot, int x, int y, int x2, int y2, int startFrame, int endFrame, int loops) {
+ playnode nod;
+ nod.loop = loops;
+ nod.pos = Common::Rect(x, y, x2 + 1, y2 + 1);
+ nod.start = startFrame;
+ nod.stop = CLIP<int>(endFrame, 0, _animation->getFrameCount() - 1);
+ nod.slot = slot;
+ nod._curFrame = -1;
+ nod._delay = 0;
+ nod._scaled = NULL;
+ _playList.push_back(nod);
+}
+
+bool AnimationEffect::stop() {
+ PlayNodes::iterator it = _playList.begin();
+ if (it != _playList.end()) {
+ _engine->getScriptManager()->setStateValue((*it).slot, 2);
+ if ((*it)._scaled) {
+ (*it)._scaled->free();
+ delete(*it)._scaled;
+ }
+ }
+
+ _playList.clear();
+
+ // We don't need to delete, it's may be reused
+ return false;
+}
+
+} // End of namespace ZVision
diff --git a/engines/zvision/scripting/controls/animation_control.h b/engines/zvision/scripting/effects/animation_effect.h
index 6c4d6dfcf7..fd6e24ab8b 100644
--- a/engines/zvision/scripting/controls/animation_control.h
+++ b/engines/zvision/scripting/effects/animation_effect.h
@@ -8,78 +8,70 @@
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
- *
+
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+
* You should have received a copy of the GNU General Public 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 ZVISION_ANIMATION_CONTROL_H
-#define ZVISION_ANIMATION_CONTROL_H
+#ifndef ZVISION_ANIMATION_NODE_H
+#define ZVISION_ANIMATION_NODE_H
-#include "zvision/scripting/control.h"
+#include "zvision/scripting/scripting_effect.h"
+#include "common/rect.h"
+#include "common/list.h"
-
-namespace Common {
-class String;
+namespace Graphics {
+struct Surface;
}
namespace Video {
-class VideoDecoder;
-}
-
-namespace Graphics {
-struct Surface;
+ class VideoDecoder;
}
namespace ZVision {
class ZVision;
-class RlfAnimation;
-class AnimationControl : public Control {
+class AnimationEffect : public ScriptingEffect {
public:
- AnimationControl(ZVision *engine, uint32 controlKey, const Common::String &fileName);
- ~AnimationControl();
-
-private:
- enum FileType {
- RLF = 1,
- AVI = 2
+ AnimationEffect(ZVision *engine, uint32 controlKey, const Common::String &fileName, int32 mask, int32 frate, bool disposeAfterUse = true);
+ ~AnimationEffect();
+
+ struct playnode {
+ Common::Rect pos;
+ int32 slot;
+ int32 start;
+ int32 stop;
+ int32 loop;
+ int32 _curFrame;
+ int32 _delay;
+ Graphics::Surface *_scaled;
};
private:
- uint32 _animationKey;
-
- union {
- RlfAnimation *rlf;
- Video::VideoDecoder *avi;
- } _animation;
+ typedef Common::List<playnode> PlayNodes;
- FileType _fileType;
- uint _loopCount;
- int32 _x;
- int32 _y;
+ PlayNodes _playList;
- uint _accumulatedTime;
- uint _currentLoop;
+ int32 _mask;
+ bool _disposeAfterUse;
- Graphics::Surface *_cachedFrame;
- bool _cachedFrameNeedsDeletion;
+ Video::VideoDecoder *_animation;
+ int32 _frmDelayOverride;
public:
bool process(uint32 deltaTimeInMillis);
- void setAnimationKey(uint32 animationKey) { _animationKey = animationKey; }
- void setLoopCount(uint loopCount) { _loopCount = loopCount; }
- void setXPos(int32 x) { _x = x; }
- void setYPost(int32 y) { _y = y; }
+ void addPlayNode(int32 slot, int x, int y, int x2, int y2, int startFrame, int endFrame, int loops = 1);
+
+ bool stop();
};
} // End of namespace ZVision
diff --git a/engines/zvision/scripting/effects/distort_effect.cpp b/engines/zvision/scripting/effects/distort_effect.cpp
new file mode 100644
index 0000000000..78c4a1b9a8
--- /dev/null
+++ b/engines/zvision/scripting/effects/distort_effect.cpp
@@ -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.
+ *
+ */
+
+#include "common/scummsys.h"
+
+#include "zvision/scripting/effects/distort_effect.h"
+
+#include "zvision/zvision.h"
+#include "zvision/scripting/script_manager.h"
+#include "zvision/graphics/render_manager.h"
+#include "zvision/graphics/render_table.h"
+
+#include "common/stream.h"
+
+namespace ZVision {
+
+DistortNode::DistortNode(ZVision *engine, uint32 key, int16 speed, float startAngle, float endAngle, float startLineScale, float endLineScale)
+ : ScriptingEffect(engine, key, SCRIPTING_EFFECT_DISTORT) {
+
+ _angle = _engine->getRenderManager()->getRenderTable()->getAngle();
+ _linScale = _engine->getRenderManager()->getRenderTable()->getLinscale();
+
+ _speed = speed;
+ _incr = true;
+ _startAngle = startAngle;
+ _endAngle = endAngle;
+ _startLineScale = startLineScale;
+ _endLineScale = endLineScale;
+
+ _curFrame = 1.0;
+
+ _diffAngle = endAngle - startAngle;
+ _diffLinScale = endLineScale - startLineScale;
+
+ _frmSpeed = (float)speed / 15.0;
+ _frames = ceil((5.0 - _frmSpeed * 2.0) / _frmSpeed);
+ if (_frames <= 0)
+ _frames = 1;
+
+ if (_key != StateKey_NotSet)
+ _engine->getScriptManager()->setStateValue(_key, 1);
+}
+
+DistortNode::~DistortNode() {
+ setParams(_angle, _linScale);
+}
+
+bool DistortNode::process(uint32 deltaTimeInMillis) {
+ float updTime = deltaTimeInMillis / (1000.0 / 60.0);
+
+ if (_incr)
+ _curFrame += updTime;
+ else
+ _curFrame -= updTime;
+
+ if (_curFrame < 1.0) {
+ _curFrame = 1.0;
+ _incr = true;
+ } else if (_curFrame > _frames) {
+ _curFrame = _frames;
+ _incr = false;
+ }
+
+ float diff = (1.0 / (5.0 - (_curFrame * _frmSpeed))) / (5.0 - _frmSpeed);
+ setParams(_startAngle + diff * _diffAngle, _startLineScale + diff * _diffLinScale);
+
+ return false;
+}
+
+void DistortNode::setParams(float angl, float linScale) {
+ RenderTable *table = _engine->getRenderManager()->getRenderTable();
+ if (table->getRenderState() == RenderTable::PANORAMA) {
+ table->setPanoramaFoV(angl);
+ table->setPanoramaScale(linScale);
+ table->generateRenderTable();
+ _engine->getRenderManager()->markDirty();
+ } else if (table->getRenderState() == RenderTable::TILT) {
+ table->setTiltFoV(angl);
+ table->setTiltScale(linScale);
+ table->generateRenderTable();
+ _engine->getRenderManager()->markDirty();
+ }
+}
+
+} // End of namespace ZVision
diff --git a/engines/zvision/scripting/effects/distort_effect.h b/engines/zvision/scripting/effects/distort_effect.h
new file mode 100644
index 0000000000..c64f10e6ff
--- /dev/null
+++ b/engines/zvision/scripting/effects/distort_effect.h
@@ -0,0 +1,63 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef ZVISION_DISTORT_NODE_H
+#define ZVISION_DISTORT_NODE_H
+
+#include "zvision/scripting/scripting_effect.h"
+
+namespace ZVision {
+
+class ZVision;
+
+class DistortNode : public ScriptingEffect {
+public:
+ DistortNode(ZVision *engine, uint32 key, int16 speed, float startAngle, float endAngle, float startLineScale, float endLineScale);
+ ~DistortNode();
+
+ bool process(uint32 deltaTimeInMillis);
+
+private:
+ int16 _speed;
+ float _startAngle;
+ float _endAngle;
+ float _startLineScale;
+ float _endLineScale;
+
+ float _frmSpeed;
+ float _diffAngle;
+ float _diffLinScale;
+ bool _incr;
+ int16 _frames;
+
+ float _curFrame;
+
+ float _angle;
+ float _linScale;
+
+private:
+ void setParams(float angl, float linScale);
+};
+
+} // End of namespace ZVision
+
+#endif
diff --git a/engines/zvision/scripting/effects/music_effect.cpp b/engines/zvision/scripting/effects/music_effect.cpp
new file mode 100644
index 0000000000..102f330305
--- /dev/null
+++ b/engines/zvision/scripting/effects/music_effect.cpp
@@ -0,0 +1,248 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public 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 "zvision/scripting/effects/music_effect.h"
+
+#include "zvision/zvision.h"
+#include "zvision/scripting/script_manager.h"
+#include "zvision/graphics/render_manager.h"
+#include "zvision/sound/midi.h"
+#include "zvision/sound/zork_raw.h"
+
+#include "common/stream.h"
+#include "common/file.h"
+#include "audio/decoders/wave.h"
+
+namespace ZVision {
+
+MusicNode::MusicNode(ZVision *engine, uint32 key, Common::String &filename, bool loop, int8 volume)
+ : MusicNodeBASE(engine, key, SCRIPTING_EFFECT_AUDIO) {
+ _loop = loop;
+ _volume = volume;
+ _crossfade = false;
+ _crossfadeTarget = 0;
+ _crossfadeTime = 0;
+ _attenuate = 0;
+ _pantrack = false;
+ _pantrackPosition = 0;
+ _sub = NULL;
+ _stereo = false;
+ _loaded = false;
+
+ Audio::RewindableAudioStream *audioStream = NULL;
+
+ if (filename.contains(".wav")) {
+ Common::File *file = new Common::File();
+ if (_engine->getSearchManager()->openFile(*file, filename)) {
+ audioStream = Audio::makeWAVStream(file, DisposeAfterUse::YES);
+ }
+ } else {
+ audioStream = makeRawZorkStream(filename, _engine);
+ }
+
+ if (audioStream) {
+ _stereo = audioStream->isStereo();
+
+ if (_loop) {
+ Audio::LoopingAudioStream *loopingAudioStream = new Audio::LoopingAudioStream(audioStream, 0, DisposeAfterUse::YES);
+ _engine->_mixer->playStream(Audio::Mixer::kPlainSoundType, &_handle, loopingAudioStream, -1, _volume);
+ } else {
+ _engine->_mixer->playStream(Audio::Mixer::kPlainSoundType, &_handle, audioStream, -1, _volume);
+ }
+
+ if (_key != StateKey_NotSet)
+ _engine->getScriptManager()->setStateValue(_key, 1);
+
+ // Change filename.raw into filename.sub
+ Common::String subname = filename;
+ subname.setChar('s', subname.size() - 3);
+ subname.setChar('u', subname.size() - 2);
+ subname.setChar('b', subname.size() - 1);
+
+ if (_engine->getSearchManager()->hasFile(subname))
+ _sub = new Subtitle(_engine, subname);
+
+ _loaded = true;
+ }
+}
+
+MusicNode::~MusicNode() {
+ if (_loaded)
+ _engine->_mixer->stopHandle(_handle);
+ if (_key != StateKey_NotSet)
+ _engine->getScriptManager()->setStateValue(_key, 2);
+ if (_sub)
+ delete _sub;
+ debug(1, "MusicNode: %d destroyed\n", _key);
+}
+
+void MusicNode::setPanTrack(int16 pos) {
+ if (!_stereo) {
+ _pantrack = true;
+ _pantrackPosition = pos;
+ setVolume(_volume);
+ }
+}
+
+void MusicNode::unsetPanTrack() {
+ _pantrack = false;
+ setVolume(_volume);
+}
+
+void MusicNode::setFade(int32 time, uint8 target) {
+ _crossfadeTarget = target;
+ _crossfadeTime = time;
+ _crossfade = true;
+}
+
+bool MusicNode::process(uint32 deltaTimeInMillis) {
+ if (!_loaded || ! _engine->_mixer->isSoundHandleActive(_handle))
+ return stop();
+ else {
+ uint8 _newvol = _volume;
+
+ if (_crossfade) {
+ if (_crossfadeTime > 0) {
+ if ((int32)deltaTimeInMillis > _crossfadeTime)
+ deltaTimeInMillis = _crossfadeTime;
+ _newvol += floor(((float)(_crossfadeTarget - _newvol) / (float)_crossfadeTime)) * (float)deltaTimeInMillis;
+ _crossfadeTime -= deltaTimeInMillis;
+ } else {
+ _crossfade = false;
+ _newvol = _crossfadeTarget;
+ }
+ }
+
+ if (_pantrack || _volume != _newvol)
+ setVolume(_newvol);
+
+ if (_sub && _engine->getScriptManager()->getStateValue(StateKey_Subtitles) == 1)
+ _sub->process(_engine->_mixer->getSoundElapsedTime(_handle) / 100);
+ }
+ return false;
+}
+
+void MusicNode::setVolume(uint8 newVolume) {
+ if (!_loaded)
+ return;
+ if (_pantrack) {
+ int curX = _engine->getScriptManager()->getStateValue(StateKey_ViewPos);
+ curX -= _pantrackPosition;
+ int32 _width = _engine->getRenderManager()->getBkgSize().x;
+ if (curX < (-_width) / 2)
+ curX += _width;
+ else if (curX >= _width / 2)
+ curX -= _width;
+
+ float norm = (float)curX / ((float)_width / 2.0);
+ float lvl = fabs(norm);
+ if (lvl > 0.5)
+ lvl = (lvl - 0.5) * 1.7;
+ else
+ lvl = 1.0;
+
+ float bal = sin(-norm * 3.1415926) * 127.0;
+
+ if (_engine->_mixer->isSoundHandleActive(_handle)) {
+ _engine->_mixer->setChannelBalance(_handle, bal);
+ _engine->_mixer->setChannelVolume(_handle, newVolume * lvl);
+ }
+ } else {
+ if (_engine->_mixer->isSoundHandleActive(_handle)) {
+ _engine->_mixer->setChannelBalance(_handle, 0);
+ _engine->_mixer->setChannelVolume(_handle, newVolume);
+ }
+ }
+
+ _volume = newVolume;
+}
+
+PanTrackNode::PanTrackNode(ZVision *engine, uint32 key, uint32 slot, int16 pos)
+ : ScriptingEffect(engine, key, SCRIPTING_EFFECT_PANTRACK) {
+ _slot = slot;
+
+ ScriptingEffect *fx = _engine->getScriptManager()->getSideFX(slot);
+ if (fx && fx->getType() == SCRIPTING_EFFECT_AUDIO) {
+ MusicNodeBASE *mus = (MusicNodeBASE *)fx;
+ mus->setPanTrack(pos);
+ }
+}
+
+PanTrackNode::~PanTrackNode() {
+ ScriptingEffect *fx = _engine->getScriptManager()->getSideFX(_slot);
+ if (fx && fx->getType() == SCRIPTING_EFFECT_AUDIO) {
+ MusicNodeBASE *mus = (MusicNodeBASE *)fx;
+ mus->unsetPanTrack();
+ }
+}
+
+MusicMidiNode::MusicMidiNode(ZVision *engine, uint32 key, int8 program, int8 note, int8 volume)
+ : MusicNodeBASE(engine, key, SCRIPTING_EFFECT_AUDIO) {
+ _volume = volume;
+ _prog = program;
+ _noteNumber = note;
+ _pan = 0;
+
+ _chan = _engine->getMidiManager()->getFreeChannel();
+
+ if (_chan >= 0) {
+ _engine->getMidiManager()->setVolume(_chan, _volume);
+ _engine->getMidiManager()->setPan(_chan, _pan);
+ _engine->getMidiManager()->setProgram(_chan, _prog);
+ _engine->getMidiManager()->noteOn(_chan, _noteNumber, _volume);
+ }
+
+ if (_key != StateKey_NotSet)
+ _engine->getScriptManager()->setStateValue(_key, 1);
+}
+
+MusicMidiNode::~MusicMidiNode() {
+ if (_chan >= 0) {
+ _engine->getMidiManager()->noteOff(_chan);
+ }
+ if (_key != StateKey_NotSet)
+ _engine->getScriptManager()->setStateValue(_key, 2);
+}
+
+void MusicMidiNode::setPanTrack(int16 pos) {
+}
+
+void MusicMidiNode::unsetPanTrack() {
+}
+
+void MusicMidiNode::setFade(int32 time, uint8 target) {
+}
+
+bool MusicMidiNode::process(uint32 deltaTimeInMillis) {
+ return false;
+}
+
+void MusicMidiNode::setVolume(uint8 newVolume) {
+ if (_chan >= 0) {
+ _engine->getMidiManager()->setVolume(_chan, newVolume);
+ }
+ _volume = newVolume;
+}
+
+} // End of namespace ZVision
diff --git a/engines/zvision/scripting/effects/music_effect.h b/engines/zvision/scripting/effects/music_effect.h
new file mode 100644
index 0000000000..31d538f668
--- /dev/null
+++ b/engines/zvision/scripting/effects/music_effect.h
@@ -0,0 +1,135 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef ZVISION_MUSIC_NODE_H
+#define ZVISION_MUSIC_NODE_H
+
+#include "audio/mixer.h"
+#include "zvision/scripting/scripting_effect.h"
+#include "zvision/text/subtitles.h"
+
+namespace Common {
+class String;
+}
+
+namespace ZVision {
+
+class MusicNodeBASE : public ScriptingEffect {
+public:
+ MusicNodeBASE(ZVision *engine, uint32 key, ScriptingEffectType type) : ScriptingEffect(engine, key, type) {}
+ ~MusicNodeBASE() {}
+
+ /**
+ * Decrement the timer by the delta time. If the timer is finished, set the status
+ * in _globalState and let this node be deleted
+ *
+ * @param deltaTimeInMillis The number of milliseconds that have passed since last frame
+ * @return If true, the node can be deleted after process() finishes
+ */
+ virtual bool process(uint32 deltaTimeInMillis) = 0;
+
+ virtual void setVolume(uint8 volume) = 0;
+
+ virtual void setPanTrack(int16 pos) = 0;
+ virtual void unsetPanTrack() = 0;
+
+ virtual void setFade(int32 time, uint8 target) = 0;
+};
+
+class MusicNode : public MusicNodeBASE {
+public:
+ MusicNode(ZVision *engine, uint32 key, Common::String &file, bool loop, int8 volume);
+ ~MusicNode();
+
+ /**
+ * Decrement the timer by the delta time. If the timer is finished, set the status
+ * in _globalState and let this node be deleted
+ *
+ * @param deltaTimeInMillis The number of milliseconds that have passed since last frame
+ * @return If true, the node can be deleted after process() finishes
+ */
+ bool process(uint32 deltaTimeInMillis);
+
+ void setVolume(uint8 volume);
+
+ void setPanTrack(int16 pos);
+ void unsetPanTrack();
+
+ void setFade(int32 time, uint8 target);
+
+private:
+ bool _pantrack;
+ int32 _pantrackPosition;
+ int32 _attenuate;
+ uint8 _volume;
+ bool _loop;
+ bool _crossfade;
+ uint8 _crossfadeTarget;
+ int32 _crossfadeTime;
+ bool _stereo;
+ Audio::SoundHandle _handle;
+ Subtitle *_sub;
+ bool _loaded;
+};
+
+// Only used by Zork: Nemesis, for the flute and piano puzzles (tj4e and ve6f, as well as vr)
+class MusicMidiNode : public MusicNodeBASE {
+public:
+ MusicMidiNode(ZVision *engine, uint32 key, int8 program, int8 note, int8 volume);
+ ~MusicMidiNode();
+
+ /**
+ * Decrement the timer by the delta time. If the timer is finished, set the status
+ * in _globalState and let this node be deleted
+ *
+ * @param deltaTimeInMillis The number of milliseconds that have passed since last frame
+ * @return If true, the node can be deleted after process() finishes
+ */
+ bool process(uint32 deltaTimeInMillis);
+
+ void setVolume(uint8 volume);
+
+ void setPanTrack(int16 pos);
+ void unsetPanTrack();
+
+ void setFade(int32 time, uint8 target);
+
+private:
+ int8 _chan;
+ int8 _noteNumber;
+ int8 _pan;
+ int8 _volume;
+ int8 _prog;
+};
+
+class PanTrackNode : public ScriptingEffect {
+public:
+ PanTrackNode(ZVision *engine, uint32 key, uint32 slot, int16 pos);
+ ~PanTrackNode();
+
+private:
+ uint32 _slot;
+};
+
+} // End of namespace ZVision
+
+#endif
diff --git a/engines/zvision/scripting/effects/region_effect.cpp b/engines/zvision/scripting/effects/region_effect.cpp
new file mode 100644
index 0000000000..78061cf4de
--- /dev/null
+++ b/engines/zvision/scripting/effects/region_effect.cpp
@@ -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.
+ *
+ */
+
+#include "common/scummsys.h"
+
+#include "zvision/scripting/effects/region_effect.h"
+
+#include "zvision/zvision.h"
+#include "zvision/scripting/script_manager.h"
+#include "zvision/graphics/render_manager.h"
+
+namespace ZVision {
+
+RegionNode::RegionNode(ZVision *engine, uint32 key, GraphicsEffect *effect, uint32 delay)
+ : ScriptingEffect(engine, key, SCRIPTING_EFFECT_REGION) {
+ _effect = effect;
+ _delay = delay;
+ _timeLeft = 0;
+}
+
+RegionNode::~RegionNode() {
+ _engine->getRenderManager()->deleteEffect(_key);
+}
+
+bool RegionNode::process(uint32 deltaTimeInMillis) {
+ _timeLeft -= deltaTimeInMillis;
+
+ if (_timeLeft <= 0) {
+ _timeLeft = _delay;
+ if (_effect)
+ _effect->update();
+ }
+
+ return false;
+}
+
+} // End of namespace ZVision
diff --git a/engines/zvision/scripting/effects/region_effect.h b/engines/zvision/scripting/effects/region_effect.h
new file mode 100644
index 0000000000..4fc16224ff
--- /dev/null
+++ b/engines/zvision/scripting/effects/region_effect.h
@@ -0,0 +1,57 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public 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 ZVISION_REGION_NODE_H
+#define ZVISION_REGION_NODE_H
+
+#include "graphics/surface.h"
+
+#include "zvision/scripting/scripting_effect.h"
+#include "zvision/graphics/graphics_effect.h"
+
+namespace ZVision {
+
+class ZVision;
+
+class RegionNode : public ScriptingEffect {
+public:
+ RegionNode(ZVision *engine, uint32 key, GraphicsEffect *effect, uint32 delay);
+ ~RegionNode();
+
+ /**
+ * Decrement the timer by the delta time. If the timer is finished, set the status
+ * in _globalState and let this node be deleted
+ *
+ * @param deltaTimeInMillis The number of milliseconds that have passed since last frame
+ * @return If true, the node can be deleted after process() finishes
+ */
+ bool process(uint32 deltaTimeInMillis);
+
+private:
+ int32 _timeLeft;
+ uint32 _delay;
+ GraphicsEffect *_effect;
+};
+
+} // End of namespace ZVision
+
+#endif
diff --git a/engines/zvision/scripting/effects/syncsound_effect.cpp b/engines/zvision/scripting/effects/syncsound_effect.cpp
new file mode 100644
index 0000000000..70ba97deb8
--- /dev/null
+++ b/engines/zvision/scripting/effects/syncsound_effect.cpp
@@ -0,0 +1,85 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "common/scummsys.h"
+
+#include "zvision/scripting/effects/syncsound_effect.h"
+
+#include "zvision/zvision.h"
+#include "zvision/scripting/script_manager.h"
+#include "zvision/graphics/render_manager.h"
+#include "zvision/sound/zork_raw.h"
+
+#include "common/stream.h"
+#include "common/file.h"
+#include "audio/decoders/wave.h"
+
+namespace ZVision {
+
+SyncSoundNode::SyncSoundNode(ZVision *engine, uint32 key, Common::String &filename, int32 syncto)
+ : ScriptingEffect(engine, key, SCRIPTING_EFFECT_AUDIO) {
+ _syncto = syncto;
+ _sub = NULL;
+
+ Audio::RewindableAudioStream *audioStream = NULL;
+
+ if (filename.contains(".wav")) {
+ Common::File *file = new Common::File();
+ if (_engine->getSearchManager()->openFile(*file, filename)) {
+ audioStream = Audio::makeWAVStream(file, DisposeAfterUse::YES);
+ }
+ } else {
+ audioStream = makeRawZorkStream(filename, _engine);
+ }
+
+ _engine->_mixer->playStream(Audio::Mixer::kPlainSoundType, &_handle, audioStream);
+
+ Common::String subname = filename;
+ subname.setChar('s', subname.size() - 3);
+ subname.setChar('u', subname.size() - 2);
+ subname.setChar('b', subname.size() - 1);
+
+ if (_engine->getSearchManager()->hasFile(subname))
+ _sub = new Subtitle(_engine, subname);
+}
+
+SyncSoundNode::~SyncSoundNode() {
+ _engine->_mixer->stopHandle(_handle);
+ if (_sub)
+ delete _sub;
+}
+
+bool SyncSoundNode::process(uint32 deltaTimeInMillis) {
+ if (! _engine->_mixer->isSoundHandleActive(_handle))
+ return stop();
+ else {
+
+ if (_engine->getScriptManager()->getSideFX(_syncto) == NULL)
+ return stop();
+
+ if (_sub && _engine->getScriptManager()->getStateValue(StateKey_Subtitles) == 1)
+ _sub->process(_engine->_mixer->getSoundElapsedTime(_handle) / 100);
+ }
+ return false;
+}
+
+} // End of namespace ZVision
diff --git a/engines/zvision/scripting/effects/syncsound_effect.h b/engines/zvision/scripting/effects/syncsound_effect.h
new file mode 100644
index 0000000000..0eabff77a3
--- /dev/null
+++ b/engines/zvision/scripting/effects/syncsound_effect.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 ZVISION_SYNCSOUND_NODE_H
+#define ZVISION_SYNCSOUND_NODE_H
+
+#include "audio/mixer.h"
+#include "zvision/scripting/scripting_effect.h"
+#include "zvision/text/subtitles.h"
+
+namespace Common {
+class String;
+}
+
+namespace ZVision {
+class SyncSoundNode : public ScriptingEffect {
+public:
+ SyncSoundNode(ZVision *engine, uint32 key, Common::String &file, int32 syncto);
+ ~SyncSoundNode();
+
+ /**
+ * Decrement the timer by the delta time. If the timer is finished, set the status
+ * in _globalState and let this node be deleted
+ *
+ * @param deltaTimeInMillis The number of milliseconds that have passed since last frame
+ * @return If true, the node can be deleted after process() finishes
+ */
+ bool process(uint32 deltaTimeInMillis);
+private:
+ int32 _syncto;
+ Audio::SoundHandle _handle;
+ Subtitle *_sub;
+};
+
+} // End of namespace ZVision
+
+#endif
diff --git a/engines/zvision/scripting/controls/timer_node.cpp b/engines/zvision/scripting/effects/timer_effect.cpp
index c8c8a85d34..778f9dec6c 100644
--- a/engines/zvision/scripting/controls/timer_node.cpp
+++ b/engines/zvision/scripting/effects/timer_effect.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.
@@ -22,46 +22,54 @@
#include "common/scummsys.h"
-#include "zvision/scripting/controls/timer_node.h"
+#include "zvision/scripting/effects/timer_effect.h"
#include "zvision/zvision.h"
#include "zvision/scripting/script_manager.h"
#include "common/stream.h"
-
namespace ZVision {
-
+
TimerNode::TimerNode(ZVision *engine, uint32 key, uint timeInSeconds)
- : Control(engine, key) {
- if (_engine->getGameId() == GID_NEMESIS) {
+ : ScriptingEffect(engine, key, SCRIPTING_EFFECT_TIMER) {
+ _timeLeft = 0;
+
+ if (_engine->getGameId() == GID_NEMESIS)
_timeLeft = timeInSeconds * 1000;
- } else if (_engine->getGameId() == GID_GRANDINQUISITOR) {
+ else if (_engine->getGameId() == GID_GRANDINQUISITOR)
_timeLeft = timeInSeconds * 100;
- }
- _engine->getScriptManager()->setStateValue(_key, 1);
+ if (_key != StateKey_NotSet)
+ _engine->getScriptManager()->setStateValue(_key, 1);
}
TimerNode::~TimerNode() {
- if (_timeLeft <= 0)
+ if (_key != StateKey_NotSet)
_engine->getScriptManager()->setStateValue(_key, 2);
- else
- _engine->getScriptManager()->setStateValue(_key, _timeLeft); // If timer was stopped by stop or kill
+ int32 timeLeft = _timeLeft / (_engine->getGameId() == GID_NEMESIS ? 1000 : 100);
+ if (timeLeft > 0)
+ _engine->getScriptManager()->setStateValue(_key, timeLeft); // If timer was stopped by stop or kill
}
bool TimerNode::process(uint32 deltaTimeInMillis) {
_timeLeft -= deltaTimeInMillis;
- if (_timeLeft <= 0) {
- // Let the destructor reset the state value
- return true;
- }
+ if (_timeLeft <= 0)
+ return stop();
return false;
}
+bool TimerNode::stop() {
+ if (_key != StateKey_NotSet)
+ _engine->getScriptManager()->setStateValue(_key, 2);
+ return true;
+}
+
void TimerNode::serialize(Common::WriteStream *stream) {
+ stream->writeUint32BE(MKTAG('T', 'I', 'M', 'R'));
+ stream->writeUint32LE(8); // size
stream->writeUint32LE(_key);
stream->writeUint32LE(_timeLeft);
}
diff --git a/engines/zvision/scripting/controls/timer_node.h b/engines/zvision/scripting/effects/timer_effect.h
index 48b5fad1e9..5e45d54d7d 100644
--- a/engines/zvision/scripting/controls/timer_node.h
+++ b/engines/zvision/scripting/effects/timer_effect.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.
@@ -23,13 +23,13 @@
#ifndef ZVISION_TIMER_NODE_H
#define ZVISION_TIMER_NODE_H
-#include "zvision/scripting/control.h"
+#include "zvision/scripting/scripting_effect.h"
namespace ZVision {
class ZVision;
-class TimerNode : public Control {
+class TimerNode : public ScriptingEffect {
public:
TimerNode(ZVision *engine, uint32 key, uint timeInSeconds);
~TimerNode();
@@ -44,7 +44,11 @@ public:
bool process(uint32 deltaTimeInMillis);
void serialize(Common::WriteStream *stream);
void deserialize(Common::SeekableReadStream *stream);
- inline bool needsSerialization() { return true; }
+ inline bool needsSerialization() {
+ return true;
+ }
+
+ bool stop();
private:
int32 _timeLeft;
diff --git a/engines/zvision/scripting/effects/ttytext_effect.cpp b/engines/zvision/scripting/effects/ttytext_effect.cpp
new file mode 100644
index 0000000000..c60b3aa8c5
--- /dev/null
+++ b/engines/zvision/scripting/effects/ttytext_effect.cpp
@@ -0,0 +1,174 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public 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 "zvision/scripting/effects/ttytext_effect.h"
+
+#include "zvision/zvision.h"
+#include "zvision/scripting/script_manager.h"
+#include "zvision/graphics/render_manager.h"
+#include "zvision/text/text.h"
+
+#include "common/stream.h"
+#include "common/file.h"
+
+namespace ZVision {
+
+ttyTextNode::ttyTextNode(ZVision *engine, uint32 key, const Common::String &file, const Common::Rect &r, int32 delay) :
+ ScriptingEffect(engine, key, SCRIPTING_EFFECT_TTYTXT),
+ _fnt(engine) {
+ _delay = delay;
+ _r = r;
+ _txtpos = 0;
+ _nexttime = 0;
+ _dx = 0;
+ _dy = 0;
+
+ Common::File *infile = _engine->getSearchManager()->openFile(file);
+ if (infile) {
+ while (!infile->eos()) {
+ Common::String asciiLine = readWideLine(*infile);
+ if (asciiLine.empty()) {
+ continue;
+ }
+ _txtbuf += asciiLine;
+ }
+
+ delete infile;
+ }
+ _img.create(_r.width(), _r.height(), _engine->_resourcePixelFormat);
+ _style._sharp = true;
+ _style.readAllStyle(_txtbuf);
+ _style.setFont(_fnt);
+ _engine->getScriptManager()->setStateValue(_key, 1);
+}
+
+ttyTextNode::~ttyTextNode() {
+ _engine->getScriptManager()->setStateValue(_key, 2);
+ _img.free();
+}
+
+bool ttyTextNode::process(uint32 deltaTimeInMillis) {
+ _nexttime -= deltaTimeInMillis;
+
+ if (_nexttime < 0) {
+ if (_txtpos < _txtbuf.size()) {
+ if (_txtbuf[_txtpos] == '<') {
+ int32 strt = _txtpos;
+ int32 endt = 0;
+ int16 ret = 0;
+ while (_txtbuf[_txtpos] != '>' && _txtpos < _txtbuf.size())
+ _txtpos++;
+ endt = _txtpos;
+ if (strt != -1)
+ if ((endt - strt - 1) > 0)
+ ret = _style.parseStyle(_txtbuf.c_str() + strt + 1, endt - strt - 1);
+
+ if (ret & (TXT_RET_FNTCHG | TXT_RET_FNTSTL | TXT_RET_NEWLN)) {
+ if (ret & TXT_RET_FNTCHG)
+ _style.setFont(_fnt);
+ if (ret & TXT_RET_FNTSTL)
+ _style.setFontStyle(_fnt);
+
+ if (ret & TXT_RET_NEWLN)
+ newline();
+ }
+
+ if (ret & TXT_RET_HASSTBOX) {
+ Common::String buf;
+ buf = Common::String::format("%d", _engine->getScriptManager()->getStateValue(_style._statebox));
+
+ for (uint8 j = 0; j < buf.size(); j++)
+ outchar(buf[j]);
+ }
+
+ _txtpos++;
+ } else {
+ int8 charsz = getUtf8CharSize(_txtbuf[_txtpos]);
+
+ uint16 chr = readUtf8Char(_txtbuf.c_str() + _txtpos);
+
+ if (chr == ' ') {
+ uint32 i = _txtpos + charsz;
+ uint16 width = _fnt.getCharWidth(chr);
+
+ while (i < _txtbuf.size() && _txtbuf[i] != ' ' && _txtbuf[i] != '<') {
+
+ int8 chsz = getUtf8CharSize(_txtbuf[i]);
+ uint16 uchr = readUtf8Char(_txtbuf.c_str() + _txtpos);
+
+ width += _fnt.getCharWidth(uchr);
+
+ i += chsz;
+ }
+
+ if (_dx + width > _r.width())
+ newline();
+ else
+ outchar(chr);
+ } else
+ outchar(chr);
+
+ _txtpos += charsz;
+ }
+ _nexttime = _delay;
+ _engine->getRenderManager()->blitSurfaceToBkg(_img, _r.left, _r.top);
+ } else
+ return stop();
+ }
+
+ return false;
+}
+
+void ttyTextNode::scroll() {
+ int32 scrl = 0;
+ while (_dy - scrl > _r.height() - _fnt.getFontHeight())
+ scrl += _fnt.getFontHeight();
+ int8 *pixels = (int8 *)_img.getPixels();
+ for (uint16 h = scrl; h < _img.h; h++)
+ memcpy(pixels + _img.pitch * (h - scrl), pixels + _img.pitch * h, _img.pitch);
+
+ _img.fillRect(Common::Rect(0, _img.h - scrl, _img.w, _img.h), 0);
+ _dy -= scrl;
+}
+
+void ttyTextNode::newline() {
+ _dy += _fnt.getFontHeight();
+ _dx = 0;
+}
+
+void ttyTextNode::outchar(uint16 chr) {
+ uint32 clr = _engine->_resourcePixelFormat.RGBToColor(_style._red, _style._green, _style._blue);
+
+ if (_dx + _fnt.getCharWidth(chr) > _r.width())
+ newline();
+
+ if (_dy + _fnt.getFontHeight() >= _r.height())
+ scroll();
+
+ _fnt.drawChar(&_img, chr, _dx, _dy, clr);
+
+ _dx += _fnt.getCharWidth(chr);
+}
+
+} // End of namespace ZVision
diff --git a/engines/zvision/scripting/effects/ttytext_effect.h b/engines/zvision/scripting/effects/ttytext_effect.h
new file mode 100644
index 0000000000..8d8a2518c7
--- /dev/null
+++ b/engines/zvision/scripting/effects/ttytext_effect.h
@@ -0,0 +1,73 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef ZVISION_TTYTEXT_NODE_H
+#define ZVISION_TTYTEXT_NODE_H
+
+#include "common/rect.h"
+#include "graphics/surface.h"
+
+#include "zvision/scripting/scripting_effect.h"
+#include "zvision/text/text.h"
+#include "zvision/text/truetype_font.h"
+
+namespace Common {
+class String;
+}
+
+namespace ZVision {
+class ttyTextNode : public ScriptingEffect {
+public:
+ ttyTextNode(ZVision *engine, uint32 key, const Common::String &file, const Common::Rect &r, int32 delay);
+ ~ttyTextNode();
+
+ /**
+ * Decrement the timer by the delta time. If the timer is finished, set the status
+ * in _globalState and let this node be deleted
+ *
+ * @param deltaTimeInMillis The number of milliseconds that have passed since last frame
+ * @return If true, the node can be deleted after process() finishes
+ */
+ bool process(uint32 deltaTimeInMillis);
+private:
+ Common::Rect _r;
+
+ cTxtStyle _style;
+ StyledTTFont _fnt;
+ Common::String _txtbuf;
+ uint32 _txtpos;
+
+ int32 _delay;
+ int32 _nexttime;
+ Graphics::Surface _img;
+ int16 _dx;
+ int16 _dy;
+private:
+
+ void newline();
+ void scroll();
+ void outchar(uint16 chr);
+};
+
+} // End of namespace ZVision
+
+#endif
diff --git a/engines/zvision/scripting/inventory.cpp b/engines/zvision/scripting/inventory.cpp
new file mode 100644
index 0000000000..76d43b200b
--- /dev/null
+++ b/engines/zvision/scripting/inventory.cpp
@@ -0,0 +1,122 @@
+/* ScummVM - Graphic Adventure Engine
+*
+* ScummVM is the legal property of its developers, whose names
+* are too numerous to list here. Please refer to the COPYRIGHT
+* file distributed with this source distribution.
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License
+* as published by the Free Software Foundation; either version 2
+* of the License, or (at your option) any later version.
+
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+*
+*/
+
+#include "common/scummsys.h"
+
+#include "zvision/scripting/script_manager.h"
+
+namespace ZVision {
+
+int8 ScriptManager::inventoryGetCount() {
+ return getStateValue(StateKey_Inv_Cnt_Slot);
+}
+
+void ScriptManager::inventorySetCount(int8 cnt) {
+ setStateValue(StateKey_Inv_Cnt_Slot, cnt);
+}
+
+int16 ScriptManager::inventoryGetItem(int8 id) {
+ if (id < 49 && id >= 0)
+ return getStateValue(StateKey_Inv_1_Slot + id);
+ return -1;
+}
+
+void ScriptManager::inventorySetItem(int8 id, int16 item) {
+ if (id < 49 && id >= 0)
+ setStateValue(StateKey_Inv_1_Slot + id, item);
+}
+
+void ScriptManager::inventoryAdd(int16 item) {
+ int8 cnt = inventoryGetCount();
+
+ if (cnt < 49) {
+ bool notExist = true;
+
+ if (cnt == 0) {
+ inventorySetItem(0, 0);
+ inventorySetCount(1); // we needed empty item for cycle code
+ cnt = 1;
+ }
+
+ for (int8 cur = 0; cur < cnt; cur++)
+ if (inventoryGetItem(cur) == item) {
+ notExist = false;
+ break;
+ }
+
+ if (notExist) {
+ for (int8 i = cnt; i > 0; i--)
+ inventorySetItem(i, inventoryGetItem(i - 1));
+
+ inventorySetItem(0, item);
+
+ setStateValue(StateKey_InventoryItem, item);
+
+ inventorySetCount(cnt + 1);
+ }
+ }
+}
+
+void ScriptManager::inventoryDrop(int16 item) {
+ int8 itemCount = inventoryGetCount();
+
+ // if items in inventory > 0
+ if (itemCount != 0) {
+ int8 index = 0;
+
+ // finding needed item
+ while (index < itemCount) {
+ if (inventoryGetItem(index) == item)
+ break;
+
+ index++;
+ }
+
+ // if item in the inventory
+ if (itemCount != index) {
+ // shift all items left with rewrite founded item
+ for (int8 v = index; v < itemCount - 1 ; v++)
+ inventorySetItem(v, inventoryGetItem(v + 1));
+
+ // del last item
+ inventorySetItem(itemCount - 1, 0);
+ inventorySetCount(inventoryGetCount() - 1);
+
+ setStateValue(StateKey_InventoryItem, inventoryGetItem(0));
+ }
+ }
+}
+void ScriptManager::inventoryCycle() {
+ int8 itemCount = inventoryGetCount();
+ int8 curItem = inventoryGetItem(0);
+ if (itemCount > 1) {
+ for (int8 i = 0; i < itemCount - 1; i++)
+ inventorySetItem(i, inventoryGetItem(i + 1));
+
+ inventorySetItem(itemCount - 1, curItem);
+
+ setStateValue(StateKey_InventoryItem, inventoryGetItem(0));
+
+ }
+}
+
+} // End of namespace ZVision
diff --git a/engines/zvision/scripting/menu.cpp b/engines/zvision/scripting/menu.cpp
new file mode 100644
index 0000000000..16aa57e3ae
--- /dev/null
+++ b/engines/zvision/scripting/menu.cpp
@@ -0,0 +1,761 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public 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 "zvision/graphics/render_manager.h"
+#include "zvision/scripting/menu.h"
+
+namespace ZVision {
+
+enum {
+ kMainMenuSave = 0,
+ kMainMenuLoad = 1,
+ kMainMenuPrefs = 2,
+ kMainMenuExit = 3
+};
+
+enum {
+ kMenuItem = 0,
+ kMenuMagic = 1,
+ kMenuMain = 2
+};
+
+MenuHandler::MenuHandler(ZVision *engine) {
+ _engine = engine;
+ menuBarFlag = 0xFFFF;
+}
+
+MenuZGI::MenuZGI(ZVision *engine) :
+ MenuHandler(engine) {
+ menuMouseFocus = -1;
+ inmenu = false;
+ scrolled[0] = false;
+ scrolled[1] = false;
+ scrolled[2] = false;
+ scrollPos[0] = 0.0;
+ scrollPos[1] = 0.0;
+ scrollPos[2] = 0.0;
+ mouseOnItem = -1;
+ redraw = false;
+ clean = false;
+
+ char buf[24];
+ for (int i = 1; i < 4; i++) {
+ sprintf(buf, "gmzau%2.2x1.tga", i);
+ _engine->getRenderManager()->readImageToSurface(buf, menuback[i - 1][0], false);
+ sprintf(buf, "gmzau%2.2x1.tga", i + 0x10);
+ _engine->getRenderManager()->readImageToSurface(buf, menuback[i - 1][1], false);
+ }
+ for (int i = 0; i < 4; i++) {
+ sprintf(buf, "gmzmu%2.2x1.tga", i);
+ _engine->getRenderManager()->readImageToSurface(buf, menubar[i][0], false);
+ sprintf(buf, "gmznu%2.2x1.tga", i);
+ _engine->getRenderManager()->readImageToSurface(buf, menubar[i][1], false);
+ }
+
+ for (int i = 0; i < 50; i++) {
+ items[i][0] = NULL;
+ items[i][1] = NULL;
+ itemId[i] = 0;
+ }
+
+ for (int i = 0; i < 12; i++) {
+ magic[i][0] = NULL;
+ magic[i][1] = NULL;
+ magicId[i] = 0;
+ }
+}
+
+MenuZGI::~MenuZGI() {
+ for (int i = 0; i < 3; i++) {
+ menuback[i][0].free();
+ menuback[i][1].free();
+ }
+ for (int i = 0; i < 4; i++) {
+ menubar[i][0].free();
+ menubar[i][1].free();
+ }
+ for (int i = 0; i < 50; i++) {
+ if (items[i][0]) {
+ items[i][0]->free();
+ delete items[i][0];
+ }
+ if (items[i][1]) {
+ items[i][1]->free();
+ delete items[i][1];
+ }
+ }
+ for (int i = 0; i < 12; i++) {
+ if (magic[i][0]) {
+ magic[i][0]->free();
+ delete magic[i][0];
+ }
+ if (magic[i][1]) {
+ magic[i][1]->free();
+ delete magic[i][1];
+ }
+ }
+}
+
+void MenuZGI::onMouseUp(const Common::Point &Pos) {
+ if (Pos.y < 40) {
+ switch (menuMouseFocus) {
+ case kMenuItem:
+ if (menuBarFlag & kMenubarItems) {
+ int itemCount = _engine->getScriptManager()->getStateValue(StateKey_Inv_TotalSlots);
+ if (itemCount == 0)
+ itemCount = 20;
+
+ for (int i = 0; i < itemCount; i++) {
+ int itemspace = (600 - 28) / itemCount;
+
+ if (Common::Rect(scrollPos[kMenuItem] + itemspace * i, 0,
+ scrollPos[kMenuItem] + itemspace * i + 28, 32).contains(Pos)) {
+ int32 mouseItem = _engine->getScriptManager()->getStateValue(StateKey_InventoryItem);
+ if (mouseItem >= 0 && mouseItem < 0xE0) {
+ _engine->getScriptManager()->inventoryDrop(mouseItem);
+ _engine->getScriptManager()->inventoryAdd(_engine->getScriptManager()->getStateValue(StateKey_Inv_StartSlot + i));
+ _engine->getScriptManager()->setStateValue(StateKey_Inv_StartSlot + i, mouseItem);
+
+ redraw = true;
+ }
+ }
+ }
+ }
+ break;
+
+ case kMenuMagic:
+ if (menuBarFlag & kMenubarMagic) {
+ for (int i = 0; i < 12; i++) {
+
+ uint itemnum = _engine->getScriptManager()->getStateValue(StateKey_Spell_1 + i);
+ if (itemnum != 0) {
+ if (_engine->getScriptManager()->getStateValue(StateKey_Reversed_Spellbooc) == 1)
+ itemnum = 0xEE + i;
+ else
+ itemnum = 0xE0 + i;
+ }
+ if (itemnum)
+ if (_engine->getScriptManager()->getStateValue(StateKey_InventoryItem) == 0 || _engine->getScriptManager()->getStateValue(StateKey_InventoryItem) >= 0xE0)
+ if (Common::Rect(668 + 47 * i - scrollPos[kMenuMagic], 0,
+ 668 + 47 * i - scrollPos[kMenuMagic] + 28, 32).contains(Pos))
+ _engine->getScriptManager()->setStateValue(StateKey_Active_Spell, itemnum);
+ }
+
+ }
+ break;
+
+ case kMenuMain:
+
+ // Exit
+ if (menuBarFlag & kMenubarExit)
+ if (Common::Rect(320 + 135,
+ scrollPos[kMenuMain],
+ 320 + 135 + 135,
+ scrollPos[kMenuMain] + 32).contains(Pos)) {
+ _engine->ifQuit();
+ }
+
+ // Settings
+ if (menuBarFlag & kMenubarSettings)
+ if (Common::Rect(320 ,
+ scrollPos[kMenuMain],
+ 320 + 135,
+ scrollPos[kMenuMain] + 32).contains(Pos)) {
+ _engine->getScriptManager()->changeLocation('g', 'j', 'p', 'e', 0);
+ }
+
+ // Load
+ if (menuBarFlag & kMenubarRestore)
+ if (Common::Rect(320 - 135,
+ scrollPos[kMenuMain],
+ 320,
+ scrollPos[kMenuMain] + 32).contains(Pos)) {
+ _engine->getScriptManager()->changeLocation('g', 'j', 'r', 'e', 0);
+ }
+
+ // Save
+ if (menuBarFlag & kMenubarSave)
+ if (Common::Rect(320 - 135 * 2,
+ scrollPos[kMenuMain],
+ 320 - 135,
+ scrollPos[kMenuMain] + 32).contains(Pos)) {
+ _engine->getScriptManager()->changeLocation('g', 'j', 's', 'e', 0);
+ }
+ break;
+ }
+ }
+}
+
+void MenuZGI::onMouseMove(const Common::Point &Pos) {
+ if (Pos.y < 40) {
+
+ if (!inmenu)
+ redraw = true;
+ inmenu = true;
+ switch (menuMouseFocus) {
+ case kMenuItem:
+ if (menuBarFlag & kMenubarItems) {
+ int itemCount = _engine->getScriptManager()->getStateValue(StateKey_Inv_TotalSlots);
+ if (itemCount == 0)
+ itemCount = 20;
+ else if (itemCount > 50)
+ itemCount = 50;
+
+ int lastItem = mouseOnItem;
+
+ mouseOnItem = -1;
+
+ for (int i = 0; i < itemCount; i++) {
+ int itemspace = (600 - 28) / itemCount;
+
+ if (Common::Rect(scrollPos[kMenuItem] + itemspace * i, 0,
+ scrollPos[kMenuItem] + itemspace * i + 28, 32).contains(Pos)) {
+ mouseOnItem = i;
+ break;
+ }
+ }
+
+ if (lastItem != mouseOnItem)
+ if (_engine->getScriptManager()->getStateValue(StateKey_Inv_StartSlot + mouseOnItem) ||
+ _engine->getScriptManager()->getStateValue(StateKey_Inv_StartSlot + lastItem))
+ redraw = true;
+ }
+ break;
+
+ case kMenuMagic:
+ if (menuBarFlag & kMenubarMagic) {
+ int lastItem = mouseOnItem;
+ mouseOnItem = -1;
+ for (int i = 0; i < 12; i++) {
+ if (Common::Rect(668 + 47 * i - scrollPos[kMenuMagic], 0,
+ 668 + 47 * i - scrollPos[kMenuMagic] + 28, 32).contains(Pos)) {
+ mouseOnItem = i;
+ break;
+ }
+ }
+
+ if (lastItem != mouseOnItem)
+ if (_engine->getScriptManager()->getStateValue(StateKey_Spell_1 + mouseOnItem) ||
+ _engine->getScriptManager()->getStateValue(StateKey_Spell_1 + lastItem))
+ redraw = true;
+
+ }
+ break;
+
+ case kMenuMain: {
+ int lastItem = mouseOnItem;
+ mouseOnItem = -1;
+
+ // Exit
+ if (menuBarFlag & kMenubarExit)
+ if (Common::Rect(320 + 135,
+ scrollPos[kMenuMain],
+ 320 + 135 + 135,
+ scrollPos[kMenuMain] + 32).contains(Pos)) {
+ mouseOnItem = kMainMenuExit;
+ }
+
+ // Settings
+ if (menuBarFlag & kMenubarSettings)
+ if (Common::Rect(320 ,
+ scrollPos[kMenuMain],
+ 320 + 135,
+ scrollPos[kMenuMain] + 32).contains(Pos)) {
+ mouseOnItem = kMainMenuPrefs;
+ }
+
+ // Load
+ if (menuBarFlag & kMenubarRestore)
+ if (Common::Rect(320 - 135,
+ scrollPos[kMenuMain],
+ 320,
+ scrollPos[kMenuMain] + 32).contains(Pos)) {
+ mouseOnItem = kMainMenuLoad;
+ }
+
+ // Save
+ if (menuBarFlag & kMenubarSave)
+ if (Common::Rect(320 - 135 * 2,
+ scrollPos[kMenuMain],
+ 320 - 135,
+ scrollPos[kMenuMain] + 32).contains(Pos)) {
+ mouseOnItem = kMainMenuSave;
+ }
+
+ if (lastItem != mouseOnItem)
+ redraw = true;
+ }
+ break;
+
+ default:
+ int cur_menu = menuMouseFocus;
+ if (Common::Rect(64, 0, 64 + 512, 8).contains(Pos)) { // Main
+ menuMouseFocus = kMenuMain;
+ scrolled[kMenuMain] = false;
+ scrollPos[kMenuMain] = menuback[kMenuMain][1].h - menuback[kMenuMain][0].h;
+ _engine->getScriptManager()->setStateValue(StateKey_MenuState, 2);
+ }
+
+ if (menuBarFlag & kMenubarMagic)
+ if (Common::Rect(640 - 28, 0, 640, 32).contains(Pos)) { // Magic
+ menuMouseFocus = kMenuMagic;
+ scrolled[kMenuMagic] = false;
+ scrollPos[kMenuMagic] = 28;
+ _engine->getScriptManager()->setStateValue(StateKey_MenuState, 3);
+ }
+
+ if (menuBarFlag & kMenubarItems)
+ if (Common::Rect(0, 0, 28, 32).contains(Pos)) { // Items
+ menuMouseFocus = kMenuItem;
+ scrolled[kMenuItem] = false;
+ scrollPos[kMenuItem] = 28 - 600;
+ _engine->getScriptManager()->setStateValue(StateKey_MenuState, 1);
+ }
+
+ if (cur_menu != menuMouseFocus)
+ clean = true;
+
+ break;
+ }
+ } else {
+ if (inmenu)
+ clean = true;
+ inmenu = false;
+ if (_engine->getScriptManager()->getStateValue(StateKey_MenuState) != 0)
+ _engine->getScriptManager()->setStateValue(StateKey_MenuState, 0);
+ menuMouseFocus = -1;
+ }
+}
+
+void MenuZGI::process(uint32 deltatime) {
+ if (clean) {
+ _engine->getRenderManager()->clearMenuSurface();
+ clean = false;
+ }
+ switch (menuMouseFocus) {
+ case kMenuItem:
+ if (menuBarFlag & kMenubarItems)
+ if (!scrolled[kMenuItem]) {
+ redraw = true;
+ float scrl = 600.0 * (deltatime / 1000.0);
+
+ if (scrl == 0)
+ scrl = 1.0;
+
+ scrollPos [kMenuItem] += scrl;
+
+ if (scrollPos[kMenuItem] >= 0) {
+ scrolled[kMenuItem] = true;
+ scrollPos [kMenuItem] = 0;
+ }
+ }
+ if (redraw) {
+ _engine->getRenderManager()->blitSurfaceToMenu(menuback[kMenuItem][0], scrollPos[kMenuItem], 0);
+
+ int itemCount = _engine->getScriptManager()->getStateValue(StateKey_Inv_TotalSlots);
+ if (itemCount == 0)
+ itemCount = 20;
+ else if (itemCount > 50)
+ itemCount = 50;
+
+ for (int i = 0; i < itemCount; i++) {
+ int itemspace = (600 - 28) / itemCount;
+
+ bool inrect = false;
+
+ if (mouseOnItem == i)
+ inrect = true;
+
+ uint curItemId = _engine->getScriptManager()->getStateValue(StateKey_Inv_StartSlot + i);
+
+ if (curItemId != 0) {
+ if (itemId[i] != curItemId) {
+ char buf[16];
+ sprintf(buf, "gmzwu%2.2x1.tga", curItemId);
+ items[i][0] = _engine->getRenderManager()->loadImage(buf, false);
+ sprintf(buf, "gmzxu%2.2x1.tga", curItemId);
+ items[i][1] = _engine->getRenderManager()->loadImage(buf, false);
+ itemId[i] = curItemId;
+ }
+
+ if (inrect)
+ _engine->getRenderManager()->blitSurfaceToMenu(*items[i][1], scrollPos[kMenuItem] + itemspace * i, 0, 0);
+ else
+ _engine->getRenderManager()->blitSurfaceToMenu(*items[i][0], scrollPos[kMenuItem] + itemspace * i, 0, 0);
+
+ } else {
+ if (items[i][0]) {
+ items[i][0]->free();
+ delete items[i][0];
+ items[i][0] = NULL;
+ }
+ if (items[i][1]) {
+ items[i][1]->free();
+ delete items[i][1];
+ items[i][1] = NULL;
+ }
+ itemId[i] = 0;
+ }
+ }
+
+ redraw = false;
+ }
+ break;
+
+ case kMenuMagic:
+ if (menuBarFlag & kMenubarMagic)
+ if (!scrolled[kMenuMagic]) {
+ redraw = true;
+ float scrl = 600.0 * (deltatime / 1000.0);
+
+ if (scrl == 0)
+ scrl = 1.0;
+
+ scrollPos [kMenuMagic] += scrl;
+
+ if (scrollPos[kMenuMagic] >= 600) {
+ scrolled[kMenuMagic] = true;
+ scrollPos [kMenuMagic] = 600;
+ }
+ }
+ if (redraw) {
+ _engine->getRenderManager()->blitSurfaceToMenu(menuback[kMenuMagic][0], 640 - scrollPos[kMenuMagic], 0);
+
+ for (int i = 0; i < 12; i++) {
+ bool inrect = false;
+
+ if (mouseOnItem == i)
+ inrect = true;
+
+ uint curItemId = _engine->getScriptManager()->getStateValue(StateKey_Spell_1 + i);
+ if (curItemId) {
+ if (_engine->getScriptManager()->getStateValue(StateKey_Reversed_Spellbooc) == 1)
+ curItemId = 0xEE + i;
+ else
+ curItemId = 0xE0 + i;
+ }
+
+ if (curItemId != 0) {
+ if (itemId[i] != curItemId) {
+ char buf[16];
+ sprintf(buf, "gmzwu%2.2x1.tga", curItemId);
+ magic[i][0] = _engine->getRenderManager()->loadImage(buf, false);
+ sprintf(buf, "gmzxu%2.2x1.tga", curItemId);
+ magic[i][1] = _engine->getRenderManager()->loadImage(buf, false);
+ magicId[i] = curItemId;
+ }
+
+ if (inrect)
+ _engine->getRenderManager()->blitSurfaceToMenu(*magic[i][1], 668 + 47 * i - scrollPos[kMenuMagic], 0, 0);
+ else
+ _engine->getRenderManager()->blitSurfaceToMenu(*magic[i][0], 668 + 47 * i - scrollPos[kMenuMagic], 0, 0);
+
+ } else {
+ if (magic[i][0]) {
+ magic[i][0]->free();
+ delete magic[i][0];
+ magic[i][0] = NULL;
+ }
+ if (magic[i][1]) {
+ magic[i][1]->free();
+ delete magic[i][1];
+ magic[i][1] = NULL;
+ }
+ magicId[i] = 0;
+ }
+ }
+ redraw = false;
+ }
+ break;
+
+ case kMenuMain:
+ if (!scrolled[kMenuMain]) {
+ redraw = true;
+ float scrl = 32.0 * 2.0 * (deltatime / 1000.0);
+
+ if (scrl == 0)
+ scrl = 1.0;
+
+ scrollPos [kMenuMain] += scrl;
+
+ if (scrollPos[kMenuMain] >= 0) {
+ scrolled[kMenuMain] = true;
+ scrollPos [kMenuMain] = 0;
+ }
+ }
+ if (redraw) {
+ _engine->getRenderManager()->blitSurfaceToMenu(menuback[kMenuMain][0], 30, scrollPos[kMenuMain]);
+
+ if (menuBarFlag & kMenubarExit) {
+ if (mouseOnItem == kMainMenuExit)
+ _engine->getRenderManager()->blitSurfaceToMenu(menubar[kMainMenuExit][1], 320 + 135, scrollPos[kMenuMain]);
+ else
+ _engine->getRenderManager()->blitSurfaceToMenu(menubar[kMainMenuExit][0], 320 + 135, scrollPos[kMenuMain]);
+ }
+ if (menuBarFlag & kMenubarSettings) {
+ if (mouseOnItem == kMainMenuPrefs)
+ _engine->getRenderManager()->blitSurfaceToMenu(menubar[kMainMenuPrefs][1], 320, scrollPos[kMenuMain]);
+ else
+ _engine->getRenderManager()->blitSurfaceToMenu(menubar[kMainMenuPrefs][0], 320, scrollPos[kMenuMain]);
+ }
+ if (menuBarFlag & kMenubarRestore) {
+ if (mouseOnItem == kMainMenuLoad)
+ _engine->getRenderManager()->blitSurfaceToMenu(menubar[kMainMenuLoad][1], 320 - 135, scrollPos[kMenuMain]);
+ else
+ _engine->getRenderManager()->blitSurfaceToMenu(menubar[kMainMenuLoad][0], 320 - 135, scrollPos[kMenuMain]);
+ }
+ if (menuBarFlag & kMenubarSave) {
+ if (mouseOnItem == kMainMenuSave)
+ _engine->getRenderManager()->blitSurfaceToMenu(menubar[kMainMenuSave][1], 320 - 135 * 2, scrollPos[kMenuMain]);
+ else
+ _engine->getRenderManager()->blitSurfaceToMenu(menubar[kMainMenuSave][0], 320 - 135 * 2, scrollPos[kMenuMain]);
+ }
+ redraw = false;
+ }
+ break;
+ default:
+ if (redraw) {
+ if (inmenu) {
+ _engine->getRenderManager()->blitSurfaceToMenu(menuback[kMenuMain][1], 30, 0);
+
+ if (menuBarFlag & kMenubarItems)
+ _engine->getRenderManager()->blitSurfaceToMenu(menuback[kMenuItem][1], 0, 0);
+
+ if (menuBarFlag & kMenubarMagic)
+ _engine->getRenderManager()->blitSurfaceToMenu(menuback[kMenuMagic][1], 640 - 28, 0);
+ }
+ redraw = false;
+ }
+ break;
+ }
+}
+
+MenuNemesis::MenuNemesis(ZVision *engine) :
+ MenuHandler(engine) {
+ inmenu = false;
+ scrolled = false;
+ scrollPos = 0.0;
+ mouseOnItem = -1;
+ redraw = false;
+ delay = 0;
+
+ char buf[24];
+ for (int i = 0; i < 4; i++)
+ for (int j = 0; j < 6; j++) {
+ sprintf(buf, "butfrm%d%d.tga", i + 1, j);
+ _engine->getRenderManager()->readImageToSurface(buf, but[i][j], false);
+ }
+
+ _engine->getRenderManager()->readImageToSurface("bar.tga", menubar, false);
+
+ frm = 0;
+}
+
+MenuNemesis::~MenuNemesis() {
+ for (int i = 0; i < 4; i++)
+ for (int j = 0; j < 6; j++)
+ but[i][j].free();
+
+ menubar.free();
+}
+
+static const int16 buts[4][2] = { {120 , 64}, {144, 184}, {128, 328}, {120, 456} };
+
+void MenuNemesis::onMouseUp(const Common::Point &Pos) {
+ if (Pos.y < 40) {
+ // Exit
+ if (menuBarFlag & kMenubarExit)
+ if (Common::Rect(buts[3][1],
+ scrollPos,
+ buts[3][0] + buts[3][1],
+ scrollPos + 32).contains(Pos)) {
+ _engine->ifQuit();
+ frm = 5;
+ redraw = true;
+ }
+
+ // Settings
+ if (menuBarFlag & kMenubarSettings)
+ if (Common::Rect(buts[2][1],
+ scrollPos,
+ buts[2][0] + buts[2][1],
+ scrollPos + 32).contains(Pos)) {
+ _engine->getScriptManager()->changeLocation('g', 'j', 'p', 'e', 0);
+ frm = 5;
+ redraw = true;
+ }
+
+ // Load
+ if (menuBarFlag & kMenubarRestore)
+ if (Common::Rect(buts[1][1],
+ scrollPos,
+ buts[1][0] + buts[1][1],
+ scrollPos + 32).contains(Pos)) {
+ _engine->getScriptManager()->changeLocation('g', 'j', 'r', 'e', 0);
+ frm = 5;
+ redraw = true;
+ }
+
+ // Save
+ if (menuBarFlag & kMenubarSave)
+ if (Common::Rect(buts[0][1],
+ scrollPos,
+ buts[0][0] + buts[0][1],
+ scrollPos + 32).contains(Pos)) {
+ _engine->getScriptManager()->changeLocation('g', 'j', 's', 'e', 0);
+ frm = 5;
+ redraw = true;
+ }
+ }
+}
+
+void MenuNemesis::onMouseMove(const Common::Point &Pos) {
+ if (Pos.y < 40) {
+
+ inmenu = true;
+
+ if (_engine->getScriptManager()->getStateValue(StateKey_MenuState) != 2)
+ _engine->getScriptManager()->setStateValue(StateKey_MenuState, 2);
+
+ int lastItem = mouseOnItem;
+ mouseOnItem = -1;
+
+ // Exit
+ if (menuBarFlag & kMenubarExit)
+ if (Common::Rect(buts[3][1],
+ scrollPos,
+ buts[3][0] + buts[3][1],
+ scrollPos + 32).contains(Pos)) {
+ mouseOnItem = kMainMenuExit;
+ }
+
+ // Settings
+ if (menuBarFlag & kMenubarSettings)
+ if (Common::Rect(buts[2][1],
+ scrollPos,
+ buts[2][0] + buts[2][1],
+ scrollPos + 32).contains(Pos)) {
+ mouseOnItem = kMainMenuPrefs;
+ }
+
+ // Load
+ if (menuBarFlag & kMenubarRestore)
+ if (Common::Rect(buts[1][1],
+ scrollPos,
+ buts[1][0] + buts[1][1],
+ scrollPos + 32).contains(Pos)) {
+ mouseOnItem = kMainMenuLoad;
+ }
+
+ // Save
+ if (menuBarFlag & kMenubarSave)
+ if (Common::Rect(buts[0][1],
+ scrollPos,
+ buts[0][0] + buts[0][1],
+ scrollPos + 32).contains(Pos)) {
+ mouseOnItem = kMainMenuSave;
+ }
+
+ if (lastItem != mouseOnItem) {
+ redraw = true;
+ frm = 0;
+ delay = 200;
+ }
+ } else {
+ inmenu = false;
+ if (_engine->getScriptManager()->getStateValue(StateKey_MenuState) != 0)
+ _engine->getScriptManager()->setStateValue(StateKey_MenuState, 0);
+ mouseOnItem = -1;
+ }
+}
+
+void MenuNemesis::process(uint32 deltatime) {
+ if (inmenu) {
+ if (!scrolled) {
+ float scrl = 32.0 * 2.0 * (deltatime / 1000.0);
+
+ if (scrl == 0)
+ scrl = 1.0;
+
+ scrollPos += scrl;
+ redraw = true;
+ }
+
+ if (scrollPos >= 0) {
+ scrolled = true;
+ scrollPos = 0;
+ }
+
+ if (mouseOnItem != -1) {
+ delay -= deltatime;
+ if (delay <= 0 && frm < 4) {
+ delay = 200;
+ frm++;
+ redraw = true;
+ }
+ }
+
+ if (redraw) {
+ _engine->getRenderManager()->blitSurfaceToMenu(menubar, 64, scrollPos);
+
+ if (menuBarFlag & kMenubarExit)
+ if (mouseOnItem == kMainMenuExit)
+ _engine->getRenderManager()->blitSurfaceToMenu(but[3][frm], buts[3][1], scrollPos);
+
+ if (menuBarFlag & kMenubarSettings)
+ if (mouseOnItem == kMainMenuPrefs)
+ _engine->getRenderManager()->blitSurfaceToMenu(but[2][frm], buts[2][1], scrollPos);
+
+ if (menuBarFlag & kMenubarRestore)
+ if (mouseOnItem == kMainMenuLoad)
+ _engine->getRenderManager()->blitSurfaceToMenu(but[1][frm], buts[1][1], scrollPos);
+
+ if (menuBarFlag & kMenubarSave)
+ if (mouseOnItem == kMainMenuSave)
+ _engine->getRenderManager()->blitSurfaceToMenu(but[0][frm], buts[0][1], scrollPos);
+
+ redraw = false;
+ }
+ } else {
+ scrolled = false;
+ if (scrollPos > -32) {
+ float scrl = 32.0 * 2.0 * (deltatime / 1000.0);
+
+ if (scrl == 0)
+ scrl = 1.0;
+
+ Common::Rect cl(64, 32 + scrollPos - scrl, 64 + 512, 32 + scrollPos + 1);
+ _engine->getRenderManager()->clearMenuSurface(cl);
+
+ scrollPos -= scrl;
+ redraw = true;
+ } else
+ scrollPos = -32;
+
+ if (redraw) {
+ _engine->getRenderManager()->blitSurfaceToMenu(menubar, 64, scrollPos);
+ redraw = false;
+ }
+ }
+}
+
+} // End of namespace ZVision
diff --git a/engines/zvision/scripting/menu.h b/engines/zvision/scripting/menu.h
new file mode 100644
index 0000000000..a88587966f
--- /dev/null
+++ b/engines/zvision/scripting/menu.h
@@ -0,0 +1,119 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public 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 ZVISION_MENU_H
+#define ZVISION_MENU_H
+
+#include "graphics/surface.h"
+#include "common/rect.h"
+
+#include "zvision/zvision.h"
+#include "zvision/scripting/script_manager.h"
+
+namespace ZVision {
+
+enum menuBar {
+ kMenubarExit = 0x1,
+ kMenubarSettings = 0x2,
+ kMenubarRestore = 0x4,
+ kMenubarSave = 0x8,
+ kMenubarItems = 0x100,
+ kMenubarMagic = 0x200
+};
+
+class MenuHandler {
+public:
+ MenuHandler(ZVision *engine);
+ virtual ~MenuHandler() {};
+ virtual void onMouseMove(const Common::Point &Pos) {};
+ virtual void onMouseDown(const Common::Point &Pos) {};
+ virtual void onMouseUp(const Common::Point &Pos) {};
+ virtual void process(uint32 deltaTimeInMillis) {};
+
+ void setEnable(uint16 flags) {
+ menuBarFlag = flags;
+ }
+ uint16 getEnable() {
+ return menuBarFlag;
+ }
+protected:
+ uint16 menuBarFlag;
+ ZVision *_engine;
+};
+
+class MenuZGI: public MenuHandler {
+public:
+ MenuZGI(ZVision *engine);
+ ~MenuZGI();
+ void onMouseMove(const Common::Point &Pos);
+ void onMouseUp(const Common::Point &Pos);
+ void process(uint32 deltaTimeInMillis);
+private:
+ Graphics::Surface menuback[3][2];
+ Graphics::Surface menubar[4][2];
+ Graphics::Surface *items[50][2];
+ uint itemId[50];
+
+ Graphics::Surface *magic[12][2];
+ uint magicId[12];
+
+ int menuMouseFocus;
+ bool inmenu;
+
+ int mouseOnItem;
+
+ bool scrolled[3];
+ int16 scrollPos[3];
+
+ bool clean;
+ bool redraw;
+
+};
+
+class MenuNemesis: public MenuHandler {
+public:
+ MenuNemesis(ZVision *engine);
+ ~MenuNemesis();
+ void onMouseMove(const Common::Point &Pos);
+ void onMouseUp(const Common::Point &Pos);
+ void process(uint32 deltaTimeInMillis);
+private:
+ Graphics::Surface but[4][6];
+ Graphics::Surface menubar;
+
+ bool inmenu;
+
+ int mouseOnItem;
+
+ bool scrolled;
+ int16 scrollPos;
+
+ bool redraw;
+
+ int frm;
+ int16 delay;
+
+};
+
+}
+
+#endif
diff --git a/engines/zvision/scripting/puzzle.h b/engines/zvision/scripting/puzzle.h
index ee9ce521c9..7d64357b0a 100644
--- a/engines/zvision/scripting/puzzle.h
+++ b/engines/zvision/scripting/puzzle.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.
@@ -28,11 +28,10 @@
#include "common/list.h"
#include "common/ptr.h"
-
namespace ZVision {
struct Puzzle {
- Puzzle() : key(0) {}
+ Puzzle() : key(0), addedBySetState(false) {}
~Puzzle() {
for (Common::List<ResultAction *>::iterator iter = resultActions.begin(); iter != resultActions.end(); ++iter) {
@@ -63,10 +62,17 @@ struct Puzzle {
bool argumentIsAKey;
};
+ enum StateFlags {
+ ONCE_PER_INST = 0x01,
+ DISABLED = 0x02,
+ DO_ME_NOW = 0x04
+ };
+
uint32 key;
Common::List<Common::List <CriteriaEntry> > criteriaList;
// This has to be list of pointers because ResultAction is abstract
Common::List<ResultAction *> resultActions;
+ bool addedBySetState;
};
} // End of namespace ZVision
diff --git a/engines/zvision/scripting/scr_file_handling.cpp b/engines/zvision/scripting/scr_file_handling.cpp
index 753ce4ac6a..227c43557c 100644
--- a/engines/zvision/scripting/scr_file_handling.cpp
+++ b/engines/zvision/scripting/scr_file_handling.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.
@@ -22,29 +22,36 @@
#include "common/scummsys.h"
+#include "zvision/zvision.h"
#include "zvision/scripting/script_manager.h"
-#include "zvision/utility/utility.h"
#include "zvision/scripting/puzzle.h"
#include "zvision/scripting/actions.h"
#include "zvision/scripting/controls/push_toggle_control.h"
#include "zvision/scripting/controls/lever_control.h"
+#include "zvision/scripting/controls/slot_control.h"
+#include "zvision/scripting/controls/save_control.h"
+#include "zvision/scripting/controls/input_control.h"
+#include "zvision/scripting/controls/safe_control.h"
+#include "zvision/scripting/controls/hotmov_control.h"
+#include "zvision/scripting/controls/fist_control.h"
+#include "zvision/scripting/controls/paint_control.h"
+#include "zvision/scripting/controls/titler_control.h"
#include "common/textconsole.h"
#include "common/file.h"
#include "common/tokenizer.h"
-
namespace ZVision {
-void ScriptManager::parseScrFile(const Common::String &fileName, bool isGlobal) {
+void ScriptManager::parseScrFile(const Common::String &fileName, ScriptScope &scope) {
Common::File file;
- if (!file.open(fileName)) {
+ if (!_engine->getSearchManager()->openFile(file, fileName)) {
warning("Script file not found: %s", fileName.c_str());
return;
}
- while(!file.eos()) {
+ while (!file.eos()) {
Common::String line = file.readLine();
if (file.err()) {
warning("Error parsing scr file: %s", fileName.c_str());
@@ -57,18 +64,19 @@ void ScriptManager::parseScrFile(const Common::String &fileName, bool isGlobal)
if (line.matchString("puzzle:*", true)) {
Puzzle *puzzle = new Puzzle();
- sscanf(line.c_str(),"puzzle:%u",&(puzzle->key));
-
+ sscanf(line.c_str(), "puzzle:%u", &(puzzle->key));
+ if (getStateFlag(puzzle->key) & Puzzle::ONCE_PER_INST)
+ setStateValue(puzzle->key, 0);
parsePuzzle(puzzle, file);
- if (isGlobal) {
- _globalPuzzles.push_back(puzzle);
- } else {
- _activePuzzles.push_back(puzzle);
- }
+ scope.puzzles.push_back(puzzle);
+
} else if (line.matchString("control:*", true)) {
- parseControl(line, file);
+ Control *ctrl = parseControl(line, file);
+ if (ctrl)
+ scope.controls.push_back(ctrl);
}
}
+ scope.procCount = 0;
}
void ScriptManager::parsePuzzle(Puzzle *puzzle, Common::SeekableReadStream &stream) {
@@ -81,12 +89,14 @@ void ScriptManager::parsePuzzle(Puzzle *puzzle, Common::SeekableReadStream &stre
} else if (line.matchString("results {", true)) {
parseResults(stream, puzzle->resultActions);
} else if (line.matchString("flags {", true)) {
- setStateFlags(puzzle->key, parseFlags(stream));
+ setStateFlag(puzzle->key, parseFlags(stream));
}
line = stream.readLine();
trimCommentsAndWhiteSpace(&line);
}
+
+ puzzle->addedBySetState = false;
}
bool ScriptManager::parseCriteria(Common::SeekableReadStream &stream, Common::List<Common::List<Puzzle::CriteriaEntry> > &criteriaList) const {
@@ -148,103 +158,152 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis
// Loop until we find the closing brace
Common::String line = stream.readLine();
trimCommentsAndWhiteSpace(&line);
+ line.toLowercase();
// TODO: Re-order the if-then statements in order of highest occurrence
while (!stream.eos() && !line.contains('}')) {
if (line.empty()) {
line = stream.readLine();
trimCommentsAndWhiteSpace(&line);
-
+ line.toLowercase();
continue;
}
- // Parse for the action type
- if (line.matchString("*:add*", true)) {
- actionList.push_back(new ActionAdd(line));
- } else if (line.matchString("*:animplay*", true)) {
- actionList.push_back(new ActionPlayAnimation(line));
- } else if (line.matchString("*:animpreload*", true)) {
- actionList.push_back(new ActionPreloadAnimation(line));
- } else if (line.matchString("*:animunload*", true)) {
- //actionList.push_back(new ActionUnloadAnimation(line));
- } else if (line.matchString("*:attenuate*", true)) {
- // TODO: Implement ActionAttenuate
- } else if (line.matchString("*:assign*", true)) {
- actionList.push_back(new ActionAssign(line));
- } else if (line.matchString("*:change_location*", true)) {
- actionList.push_back(new ActionChangeLocation(line));
- } else if (line.matchString("*:crossfade*", true)) {
- // TODO: Implement ActionCrossfade
- } else if (line.matchString("*:debug*", true)) {
- // TODO: Implement ActionDebug
- } else if (line.matchString("*:delay_render*", true)) {
- // TODO: Implement ActionDelayRender
- } else if (line.matchString("*:disable_control*", true)) {
- actionList.push_back(new ActionDisableControl(line));
- } else if (line.matchString("*:disable_venus*", true)) {
- // TODO: Implement ActionDisableVenus
- } else if (line.matchString("*:display_message*", true)) {
- // TODO: Implement ActionDisplayMessage
- } else if (line.matchString("*:dissolve*", true)) {
- // TODO: Implement ActionDissolve
- } else if (line.matchString("*:distort*", true)) {
- // TODO: Implement ActionDistort
- } else if (line.matchString("*:enable_control*", true)) {
- actionList.push_back(new ActionEnableControl(line));
- } else if (line.matchString("*:flush_mouse_events*", true)) {
- // TODO: Implement ActionFlushMouseEvents
- } else if (line.matchString("*:inventory*", true)) {
- // TODO: Implement ActionInventory
- } else if (line.matchString("*:kill*", true)) {
- // TODO: Implement ActionKill
- } else if (line.matchString("*:menu_bar_enable*", true)) {
- // TODO: Implement ActionMenuBarEnable
- } else if (line.matchString("*:music*", true)) {
- actionList.push_back(new ActionMusic(line));
- } else if (line.matchString("*:pan_track*", true)) {
- // TODO: Implement ActionPanTrack
- } else if (line.matchString("*:playpreload*", true)) {
- actionList.push_back(new ActionPlayPreloadAnimation(line));
- } else if (line.matchString("*:preferences*", true)) {
- // TODO: Implement ActionPreferences
- } else if (line.matchString("*:quit*", true)) {
- actionList.push_back(new ActionQuit());
- } else if (line.matchString("*:random*", true)) {
- actionList.push_back(new ActionRandom(line));
- } else if (line.matchString("*:region*", true)) {
- // TODO: Implement ActionRegion
- } else if (line.matchString("*:restore_game*", true)) {
- // TODO: Implement ActionRestoreGame
- } else if (line.matchString("*:rotate_to*", true)) {
- // TODO: Implement ActionRotateTo
- } else if (line.matchString("*:save_game*", true)) {
- // TODO: Implement ActionSaveGame
- } else if (line.matchString("*:set_partial_screen*", true)) {
- actionList.push_back(new ActionSetPartialScreen(line));
- } else if (line.matchString("*:set_screen*", true)) {
- actionList.push_back(new ActionSetScreen(line));
- } else if (line.matchString("*:set_venus*", true)) {
- // TODO: Implement ActionSetVenus
- } else if (line.matchString("*:stop*", true)) {
- // TODO: Implement ActionStop
- } else if (line.matchString("*:streamvideo*", true)) {
- actionList.push_back(new ActionStreamVideo(line));
- } else if (line.matchString("*:syncsound*", true)) {
- // TODO: Implement ActionSyncSound
- } else if (line.matchString("*:timer*", true)) {
- actionList.push_back(new ActionTimer(line));
- } else if (line.matchString("*:ttytext*", true)) {
- // TODO: Implement ActionTTYText
- } else if (line.matchString("*:universe_music*", true)) {
- // TODO: Implement ActionUniverseMusic
- } else if (line.matchString("*:copy_file*", true)) {
- // Not used. Purposely left empty
- } else {
- warning("Unhandled result action type: %s", line.c_str());
+ const char *chrs = line.c_str();
+ uint pos;
+ for (pos = 0; pos < line.size(); pos++)
+ if (chrs[pos] == ':')
+ break;
+
+ if (pos < line.size()) {
+
+ uint startpos = pos + 1;
+
+ for (pos = startpos; pos < line.size(); pos++)
+ if (chrs[pos] == ':' || chrs[pos] == '(')
+ break;
+
+ if (pos < line.size()) {
+ int32 slot = 11;
+ Common::String args = "";
+ Common::String act(chrs + startpos, chrs + pos);
+
+ startpos = pos + 1;
+
+ if (chrs[pos] == ':') {
+ for (pos = startpos; pos < line.size(); pos++)
+ if (chrs[pos] == '(')
+ break;
+ Common::String strSlot(chrs + startpos, chrs + pos);
+ slot = atoi(strSlot.c_str());
+
+ startpos = pos + 1;
+ }
+
+ if (pos < line.size()) {
+ for (pos = startpos; pos < line.size(); pos++)
+ if (chrs[pos] == ')')
+ break;
+
+ args = Common::String(chrs + startpos, chrs + pos);
+ }
+
+ // Parse for the action type
+ if (act.matchString("add", true)) {
+ actionList.push_back(new ActionAdd(_engine, slot, args));
+ } else if (act.matchString("animplay", true)) {
+ actionList.push_back(new ActionPlayAnimation(_engine, slot, args));
+ } else if (act.matchString("animpreload", true)) {
+ actionList.push_back(new ActionPreloadAnimation(_engine, slot, args));
+ } else if (act.matchString("animunload", true)) {
+ // Only used by ZGI (locations cd6e, cd6k, dg2f, dg4e, dv1j)
+ actionList.push_back(new ActionUnloadAnimation(_engine, slot, args));
+ } else if (act.matchString("attenuate", true)) {
+ actionList.push_back(new ActionAttenuate(_engine, slot, args));
+ } else if (act.matchString("assign", true)) {
+ actionList.push_back(new ActionAssign(_engine, slot, args));
+ } else if (act.matchString("change_location", true)) {
+ actionList.push_back(new ActionChangeLocation(_engine, slot, args));
+ } else if (act.matchString("crossfade", true)) {
+ actionList.push_back(new ActionCrossfade(_engine, slot, args));
+ } else if (act.matchString("cursor", true)) {
+ actionList.push_back(new ActionCursor(_engine, slot, args));
+ } else if (act.matchString("debug", true)) {
+ // Not used. Purposely left empty
+ } else if (act.matchString("delay_render", true)) {
+ actionList.push_back(new ActionDelayRender(_engine, slot, args));
+ } else if (act.matchString("disable_control", true)) {
+ actionList.push_back(new ActionDisableControl(_engine, slot, args));
+ } else if (act.matchString("disable_venus", true)) {
+ // Not used. Purposely left empty
+ } else if (act.matchString("display_message", true)) {
+ actionList.push_back(new ActionDisplayMessage(_engine, slot, args));
+ } else if (act.matchString("dissolve", true)) {
+ actionList.push_back(new ActionDissolve(_engine));
+ } else if (act.matchString("distort", true)) {
+ // Only used by Zork: Nemesis for the "treatment" puzzle in the Sanitarium (aj30)
+ actionList.push_back(new ActionDistort(_engine, slot, args));
+ } else if (act.matchString("enable_control", true)) {
+ actionList.push_back(new ActionEnableControl(_engine, slot, args));
+ } else if (act.matchString("flush_mouse_events", true)) {
+ actionList.push_back(new ActionFlushMouseEvents(_engine, slot));
+ } else if (act.matchString("inventory", true)) {
+ actionList.push_back(new ActionInventory(_engine, slot, args));
+ } else if (act.matchString("kill", true)) {
+ // Only used by ZGI
+ actionList.push_back(new ActionKill(_engine, slot, args));
+ } else if (act.matchString("menu_bar_enable", true)) {
+ actionList.push_back(new ActionMenuBarEnable(_engine, slot, args));
+ } else if (act.matchString("music", true)) {
+ actionList.push_back(new ActionMusic(_engine, slot, args, false));
+ } else if (act.matchString("pan_track", true)) {
+ actionList.push_back(new ActionPanTrack(_engine, slot, args));
+ } else if (act.matchString("playpreload", true)) {
+ actionList.push_back(new ActionPlayPreloadAnimation(_engine, slot, args));
+ } else if (act.matchString("preferences", true)) {
+ actionList.push_back(new ActionPreferences(_engine, slot, args));
+ } else if (act.matchString("quit", true)) {
+ actionList.push_back(new ActionQuit(_engine, slot));
+ } else if (act.matchString("random", true)) {
+ actionList.push_back(new ActionRandom(_engine, slot, args));
+ } else if (act.matchString("region", true)) {
+ // Only used by Zork: Nemesis
+ actionList.push_back(new ActionRegion(_engine, slot, args));
+ } else if (act.matchString("restore_game", true)) {
+ actionList.push_back(new ActionRestoreGame(_engine, slot, args));
+ } else if (act.matchString("rotate_to", true)) {
+ actionList.push_back(new ActionRotateTo(_engine, slot, args));
+ } else if (act.matchString("save_game", true)) {
+ // Not used. Purposely left empty
+ } else if (act.matchString("set_partial_screen", true)) {
+ actionList.push_back(new ActionSetPartialScreen(_engine, slot, args));
+ } else if (act.matchString("set_screen", true)) {
+ actionList.push_back(new ActionSetScreen(_engine, slot, args));
+ } else if (act.matchString("set_venus", true)) {
+ // Not used. Purposely left empty
+ } else if (act.matchString("stop", true)) {
+ actionList.push_back(new ActionStop(_engine, slot, args));
+ } else if (act.matchString("streamvideo", true)) {
+ actionList.push_back(new ActionStreamVideo(_engine, slot, args));
+ } else if (act.matchString("syncsound", true)) {
+ actionList.push_back(new ActionSyncSound(_engine, slot, args));
+ } else if (act.matchString("timer", true)) {
+ actionList.push_back(new ActionTimer(_engine, slot, args));
+ } else if (act.matchString("ttytext", true)) {
+ actionList.push_back(new ActionTtyText(_engine, slot, args));
+ } else if (act.matchString("universe_music", true)) {
+ actionList.push_back(new ActionMusic(_engine, slot, args, true));
+ } else if (act.matchString("copy_file", true)) {
+ // Not used. Purposely left empty
+ } else {
+ warning("Unhandled result action type: %s", line.c_str());
+ }
+ }
}
line = stream.readLine();
trimCommentsAndWhiteSpace(&line);
+ line.toLowercase();
}
return;
@@ -259,11 +318,11 @@ uint ScriptManager::parseFlags(Common::SeekableReadStream &stream) const {
while (!stream.eos() && !line.contains('}')) {
if (line.matchString("ONCE_PER_INST", true)) {
- flags |= ONCE_PER_INST;
+ flags |= Puzzle::ONCE_PER_INST;
} else if (line.matchString("DO_ME_NOW", true)) {
- flags |= DO_ME_NOW;
+ flags |= Puzzle::DO_ME_NOW;
} else if (line.matchString("DISABLED", true)) {
- flags |= DISABLED;
+ flags |= Puzzle::DISABLED;
}
line = stream.readLine();
@@ -273,7 +332,7 @@ uint ScriptManager::parseFlags(Common::SeekableReadStream &stream) const {
return flags;
}
-void ScriptManager::parseControl(Common::String &line, Common::SeekableReadStream &stream) {
+Control *ScriptManager::parseControl(Common::String &line, Common::SeekableReadStream &stream) {
uint32 key;
char controlTypeBuffer[20];
@@ -282,21 +341,43 @@ void ScriptManager::parseControl(Common::String &line, Common::SeekableReadStrea
Common::String controlType(controlTypeBuffer);
if (controlType.equalsIgnoreCase("push_toggle")) {
- _activeControls.push_back(new PushToggleControl(_engine, key, stream));
- return;
+ return new PushToggleControl(_engine, key, stream);
} else if (controlType.equalsIgnoreCase("flat")) {
Control::parseFlatControl(_engine);
- return;
+ return NULL;
} else if (controlType.equalsIgnoreCase("pana")) {
Control::parsePanoramaControl(_engine, stream);
- return;
+ return NULL;
} else if (controlType.equalsIgnoreCase("tilt")) {
+ // Only used in Zork Nemesis, handles tilt controls (ZGI doesn't have a tilt view)
Control::parseTiltControl(_engine, stream);
- return;
+ return NULL;
+ } else if (controlType.equalsIgnoreCase("slot")) {
+ return new SlotControl(_engine, key, stream);
+ } else if (controlType.equalsIgnoreCase("input")) {
+ return new InputControl(_engine, key, stream);
+ } else if (controlType.equalsIgnoreCase("save")) {
+ return new SaveControl(_engine, key, stream);
} else if (controlType.equalsIgnoreCase("lever")) {
- _activeControls.push_back(new LeverControl(_engine, key, stream));
- return;
+ // Only used in Zork Nemesis, handles draggable levers (te2e, tm7e, tp2e, tt2e, tz2e)
+ return new LeverControl(_engine, key, stream);
+ } else if (controlType.equalsIgnoreCase("safe")) {
+ // Only used in Zork Nemesis, handles the safe in the Asylum (ac4g)
+ return new SafeControl(_engine, key, stream);
+ } else if (controlType.equalsIgnoreCase("hotmovie")) {
+ // Only used in Zork Nemesis, handles movies where the player needs to click on something (mj7g, vw3g)
+ return new HotMovControl(_engine, key, stream);
+ } else if (controlType.equalsIgnoreCase("fist")) {
+ // Only used in Zork Nemesis, handles the door lock puzzle with the skeletal fingers (td9e)
+ return new FistControl(_engine, key, stream);
+ } else if (controlType.equalsIgnoreCase("paint")) {
+ // Only used in Zork Nemesis, handles the painting puzzle screen in Lucien's room in Irondune (ch4g)
+ return new PaintControl(_engine, key, stream);
+ } else if (controlType.equalsIgnoreCase("titler")) {
+ // Only used in Zork Nemesis, handles the death screen with the Restore/Exit buttons (cjde)
+ return new TitlerControl(_engine, key, stream);
}
+ return NULL;
}
} // End of namespace ZVision
diff --git a/engines/zvision/scripting/script_manager.cpp b/engines/zvision/scripting/script_manager.cpp
index 41b835e550..464e8bfe4d 100644
--- a/engines/zvision/scripting/script_manager.cpp
+++ b/engines/zvision/scripting/script_manager.cpp
@@ -1,24 +1,24 @@
/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
+*
+* ScummVM is the legal property of its developers, whose names
+* are too numerous to list here. Please refer to the COPYRIGHT
+* file distributed with this source distribution.
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License
+* as published by the Free Software Foundation; either version 2
+* of the License, or (at your option) any later version.
+
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+
+* You should have received a copy of the GNU General Public 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"
@@ -26,172 +26,237 @@
#include "zvision/zvision.h"
#include "zvision/graphics/render_manager.h"
-#include "zvision/cursors/cursor_manager.h"
-#include "zvision/core/save_manager.h"
+#include "zvision/graphics/cursors/cursor_manager.h"
+#include "zvision/file/save_manager.h"
#include "zvision/scripting/actions.h"
-#include "zvision/utility/utility.h"
+#include "zvision/scripting/menu.h"
+#include "zvision/scripting/effects/timer_effect.h"
#include "common/algorithm.h"
#include "common/hashmap.h"
#include "common/debug.h"
#include "common/stream.h"
-
+#include "common/config-manager.h"
namespace ZVision {
ScriptManager::ScriptManager(ZVision *engine)
: _engine(engine),
- _currentlyFocusedControl(0) {
+ _currentlyFocusedControl(0),
+ _activeControls(NULL) {
}
ScriptManager::~ScriptManager() {
- for (PuzzleList::iterator iter = _activePuzzles.begin(); iter != _activePuzzles.end(); ++iter) {
- delete (*iter);
- }
- for (PuzzleList::iterator iter = _globalPuzzles.begin(); iter != _globalPuzzles.end(); ++iter) {
- delete (*iter);
- }
- for (ControlList::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) {
- delete (*iter);
- }
+ cleanScriptScope(universe);
+ cleanScriptScope(world);
+ cleanScriptScope(room);
+ cleanScriptScope(nodeview);
+ _controlEvents.clear();
}
void ScriptManager::initialize() {
- parseScrFile("universe.scr", true);
+ cleanScriptScope(universe);
+ cleanScriptScope(world);
+ cleanScriptScope(room);
+ cleanScriptScope(nodeview);
+
+ _currentLocation.node = 0;
+ _currentLocation.world = 0;
+ _currentLocation.room = 0;
+ _currentLocation.view = 0;
+
+ parseScrFile("universe.scr", universe);
changeLocation('g', 'a', 'r', 'y', 0);
+
+ _controlEvents.clear();
}
void ScriptManager::update(uint deltaTimeMillis) {
+ if (_currentLocation.node != _nextLocation.node ||
+ _currentLocation.room != _nextLocation.room ||
+ _currentLocation.view != _nextLocation.view ||
+ _currentLocation.world != _nextLocation.world)
+ ChangeLocationReal();
+
updateNodes(deltaTimeMillis);
- checkPuzzleCriteria();
+ if (! execScope(nodeview))
+ return;
+ if (! execScope(room))
+ return;
+ if (! execScope(world))
+ return;
+ if (! execScope(universe))
+ return;
+ updateControls(deltaTimeMillis);
}
-void ScriptManager::createReferenceTable() {
- // Iterate through each local Puzzle
- for (PuzzleList::iterator activePuzzleIter = _activePuzzles.begin(); activePuzzleIter != _activePuzzles.end(); ++activePuzzleIter) {
- Puzzle *puzzlePtr = (*activePuzzleIter);
-
- // Iterate through each CriteriaEntry and add a reference from the criteria key to the Puzzle
- for (Common::List<Common::List<Puzzle::CriteriaEntry> >::iterator criteriaIter = (*activePuzzleIter)->criteriaList.begin(); criteriaIter != (*activePuzzleIter)->criteriaList.end(); ++criteriaIter) {
- for (Common::List<Puzzle::CriteriaEntry>::iterator entryIter = criteriaIter->begin(); entryIter != criteriaIter->end(); ++entryIter) {
- _referenceTable[entryIter->key].push_back(puzzlePtr);
-
- // If the argument is a key, add a reference to it as well
- if (entryIter->argumentIsAKey) {
- _referenceTable[entryIter->argument].push_back(puzzlePtr);
- }
- }
- }
+bool ScriptManager::execScope(ScriptScope &scope) {
+ // Swap queues
+ PuzzleList *tmp = scope.execQueue;
+ scope.execQueue = scope.scopeQueue;
+ scope.scopeQueue = tmp;
+ scope.scopeQueue->clear();
+
+ for (PuzzleList::iterator PuzzleIter = scope.puzzles.begin(); PuzzleIter != scope.puzzles.end(); ++PuzzleIter)
+ (*PuzzleIter)->addedBySetState = false;
+
+ if (scope.procCount < 2 || getStateValue(StateKey_ExecScopeStyle)) {
+ for (PuzzleList::iterator PuzzleIter = scope.puzzles.begin(); PuzzleIter != scope.puzzles.end(); ++PuzzleIter)
+ if (!checkPuzzleCriteria(*PuzzleIter, scope.procCount))
+ return false;
+ } else {
+ for (PuzzleList::iterator PuzzleIter = scope.execQueue->begin(); PuzzleIter != scope.execQueue->end(); ++PuzzleIter)
+ if (!checkPuzzleCriteria(*PuzzleIter, scope.procCount))
+ return false;
}
- // Iterate through each global Puzzle
- for (PuzzleList::iterator globalPuzzleIter = _globalPuzzles.begin(); globalPuzzleIter != _globalPuzzles.end(); ++globalPuzzleIter) {
- Puzzle *puzzlePtr = (*globalPuzzleIter);
+ if (scope.procCount < 2) {
+ scope.procCount++;
+ }
+ return true;
+}
- // Iterate through each CriteriaEntry and add a reference from the criteria key to the Puzzle
- for (Common::List<Common::List<Puzzle::CriteriaEntry> >::iterator criteriaIter = (*globalPuzzleIter)->criteriaList.begin(); criteriaIter != (*globalPuzzleIter)->criteriaList.end(); ++criteriaIter) {
- for (Common::List<Puzzle::CriteriaEntry>::iterator entryIter = criteriaIter->begin(); entryIter != criteriaIter->end(); ++entryIter) {
- _referenceTable[entryIter->key].push_back(puzzlePtr);
-
- // If the argument is a key, add a reference to it as well
- if (entryIter->argumentIsAKey) {
- _referenceTable[entryIter->argument].push_back(puzzlePtr);
- }
- }
- }
+void ScriptManager::referenceTableAddPuzzle(uint32 key, PuzzleRef ref) {
+ if (_referenceTable.contains(key)) {
+ Common::Array<PuzzleRef> *arr = &_referenceTable[key];
+ for (uint32 i = 0; i < arr->size(); i++)
+ if ((*arr)[i].puz == ref.puz)
+ return;
}
- // Remove duplicate entries
- for (PuzzleMap::iterator referenceTableIter = _referenceTable.begin(); referenceTableIter != _referenceTable.end(); ++referenceTableIter) {
- removeDuplicateEntries(referenceTableIter->_value);
+ _referenceTable[key].push_back(ref);
+}
+
+void ScriptManager::addPuzzlesToReferenceTable(ScriptScope &scope) {
+ // Iterate through each local Puzzle
+ for (PuzzleList::iterator PuzzleIter = scope.puzzles.begin(); PuzzleIter != scope.puzzles.end(); ++PuzzleIter) {
+ Puzzle *puzzlePtr = (*PuzzleIter);
+
+ PuzzleRef ref;
+ ref.scope = &scope;
+ ref.puz = puzzlePtr;
+
+ referenceTableAddPuzzle(puzzlePtr->key, ref);
+
+ // Iterate through each CriteriaEntry and add a reference from the criteria key to the Puzzle
+ for (Common::List<Common::List<Puzzle::CriteriaEntry> >::iterator criteriaIter = (*PuzzleIter)->criteriaList.begin(); criteriaIter != (*PuzzleIter)->criteriaList.end(); ++criteriaIter)
+ for (Common::List<Puzzle::CriteriaEntry>::iterator entryIter = criteriaIter->begin(); entryIter != criteriaIter->end(); ++entryIter)
+ referenceTableAddPuzzle(entryIter->key, ref);
}
}
void ScriptManager::updateNodes(uint deltaTimeMillis) {
// If process() returns true, it means the node can be deleted
- for (ControlList::iterator iter = _activeControls.begin(); iter != _activeControls.end();) {
+ for (SideFXList::iterator iter = _activeSideFx.begin(); iter != _activeSideFx.end();) {
if ((*iter)->process(deltaTimeMillis)) {
- delete (*iter);
+ delete(*iter);
// Remove the node
- iter = _activeControls.erase(iter);
+ iter = _activeSideFx.erase(iter);
} else {
++iter;
}
}
}
-void ScriptManager::checkPuzzleCriteria() {
- while (!_puzzlesToCheck.empty()) {
- Puzzle *puzzle = _puzzlesToCheck.pop();
-
- // Check if the puzzle is already finished
- // Also check that the puzzle isn't disabled
- if (getStateValue(puzzle->key) == 1 && (getStateFlags(puzzle->key) & DISABLED) == 0) {
- continue;
+void ScriptManager::updateControls(uint deltaTimeMillis) {
+ if (!_activeControls)
+ return;
+
+ // Process only one event
+ if (!_controlEvents.empty()) {
+ Common::Event _event = _controlEvents.front();
+ Common::Point imageCoord;
+ switch (_event.type) {
+ case Common::EVENT_LBUTTONDOWN:
+ imageCoord = _engine->getRenderManager()->screenSpaceToImageSpace(_event.mouse);
+ onMouseDown(_event.mouse, imageCoord);
+ break;
+ case Common::EVENT_LBUTTONUP:
+ imageCoord = _engine->getRenderManager()->screenSpaceToImageSpace(_event.mouse);
+ onMouseUp(_event.mouse, imageCoord);
+ break;
+ case Common::EVENT_KEYDOWN:
+ onKeyDown(_event.kbd);
+ break;
+ case Common::EVENT_KEYUP:
+ onKeyUp(_event.kbd);
+ break;
+ default:
+ break;
}
+ _controlEvents.pop_front();
+ }
+
+ for (ControlList::iterator iter = _activeControls->begin(); iter != _activeControls->end(); iter++)
+ if ((*iter)->process(deltaTimeMillis))
+ break;
+}
- // Check each Criteria
-
- bool criteriaMet = false;
- for (Common::List<Common::List<Puzzle::CriteriaEntry> >::iterator criteriaIter = puzzle->criteriaList.begin(); criteriaIter != puzzle->criteriaList.end(); ++criteriaIter) {
- criteriaMet = false;
-
- for (Common::List<Puzzle::CriteriaEntry>::iterator entryIter = criteriaIter->begin(); entryIter != criteriaIter->end(); ++entryIter) {
- // Get the value to compare against
- uint argumentValue;
- if (entryIter->argumentIsAKey)
- argumentValue = getStateValue(entryIter->argument);
- else
- argumentValue = entryIter->argument;
-
- // Do the comparison
- switch (entryIter->criteriaOperator) {
- case Puzzle::EQUAL_TO:
- criteriaMet = getStateValue(entryIter->key) == argumentValue;
- break;
- case Puzzle::NOT_EQUAL_TO:
- criteriaMet = getStateValue(entryIter->key) != argumentValue;
- break;
- case Puzzle::GREATER_THAN:
- criteriaMet = getStateValue(entryIter->key) > argumentValue;
- break;
- case Puzzle::LESS_THAN:
- criteriaMet = getStateValue(entryIter->key) < argumentValue;
- break;
- }
-
- // If one check returns false, don't keep checking
- if (!criteriaMet) {
- break;
- }
+bool ScriptManager::checkPuzzleCriteria(Puzzle *puzzle, uint counter) {
+ // Check if the puzzle is already finished
+ // Also check that the puzzle isn't disabled
+ if (getStateValue(puzzle->key) == 1 || (getStateFlag(puzzle->key) & Puzzle::DISABLED) == Puzzle::DISABLED) {
+ return true;
+ }
+
+ // Check each Criteria
+ if (counter == 0 && (getStateFlag(puzzle->key) & Puzzle::DO_ME_NOW) == 0)
+ return true;
+
+ bool criteriaMet = false;
+ for (Common::List<Common::List<Puzzle::CriteriaEntry> >::iterator criteriaIter = puzzle->criteriaList.begin(); criteriaIter != puzzle->criteriaList.end(); ++criteriaIter) {
+ criteriaMet = false;
+
+ for (Common::List<Puzzle::CriteriaEntry>::iterator entryIter = criteriaIter->begin(); entryIter != criteriaIter->end(); ++entryIter) {
+ // Get the value to compare against
+ int argumentValue;
+ if (entryIter->argumentIsAKey)
+ argumentValue = getStateValue(entryIter->argument);
+ else
+ argumentValue = entryIter->argument;
+
+ // Do the comparison
+ switch (entryIter->criteriaOperator) {
+ case Puzzle::EQUAL_TO:
+ criteriaMet = getStateValue(entryIter->key) == argumentValue;
+ break;
+ case Puzzle::NOT_EQUAL_TO:
+ criteriaMet = getStateValue(entryIter->key) != argumentValue;
+ break;
+ case Puzzle::GREATER_THAN:
+ criteriaMet = getStateValue(entryIter->key) > argumentValue;
+ break;
+ case Puzzle::LESS_THAN:
+ criteriaMet = getStateValue(entryIter->key) < argumentValue;
+ break;
}
- // If any of the Criteria are *fully* met, then execute the results
- if (criteriaMet) {
+ // If one check returns false, don't keep checking
+ if (!criteriaMet) {
break;
}
}
- // criteriaList can be empty. Aka, the puzzle should be executed immediately
- if (puzzle->criteriaList.empty() || criteriaMet) {
- debug(1, "Puzzle %u criteria passed. Executing its ResultActions", puzzle->key);
+ // If any of the Criteria are *fully* met, then execute the results
+ if (criteriaMet) {
+ break;
+ }
+ }
- // Set the puzzle as completed
- setStateValue(puzzle->key, 1);
+ // criteriaList can be empty. Aka, the puzzle should be executed immediately
+ if (puzzle->criteriaList.empty() || criteriaMet) {
+ debug(1, "Puzzle %u criteria passed. Executing its ResultActions", puzzle->key);
- bool shouldContinue = true;
- for (Common::List<ResultAction *>::iterator resultIter = puzzle->resultActions.begin(); resultIter != puzzle->resultActions.end(); ++resultIter) {
- shouldContinue = shouldContinue && (*resultIter)->execute(_engine);
- if (!shouldContinue) {
- break;
- }
- }
+ // Set the puzzle as completed
+ setStateValue(puzzle->key, 1);
- if (!shouldContinue) {
- break;
- }
+ for (Common::List<ResultAction *>::iterator resultIter = puzzle->resultActions.begin(); resultIter != puzzle->resultActions.end(); ++resultIter) {
+ if (!(*resultIter)->execute())
+ return false;
}
}
+
+ return true;
}
void ScriptManager::cleanStateTable() {
@@ -205,62 +270,104 @@ void ScriptManager::cleanStateTable() {
}
}
-uint ScriptManager::getStateValue(uint32 key) {
+void ScriptManager::cleanScriptScope(ScriptScope &scope) {
+ scope.privQueueOne.clear();
+ scope.privQueueTwo.clear();
+ scope.scopeQueue = &scope.privQueueOne;
+ scope.execQueue = &scope.privQueueTwo;
+ for (PuzzleList::iterator iter = scope.puzzles.begin(); iter != scope.puzzles.end(); ++iter)
+ delete(*iter);
+
+ scope.puzzles.clear();
+
+ for (ControlList::iterator iter = scope.controls.begin(); iter != scope.controls.end(); ++iter)
+ delete(*iter);
+
+ scope.controls.clear();
+
+ scope.procCount = 0;
+}
+
+int ScriptManager::getStateValue(uint32 key) {
if (_globalState.contains(key))
return _globalState[key];
else
return 0;
}
-void ScriptManager::setStateValue(uint32 key, uint value) {
- _globalState[key] = value;
-
+void ScriptManager::queuePuzzles(uint32 key) {
if (_referenceTable.contains(key)) {
- for (Common::Array<Puzzle *>::iterator iter = _referenceTable[key].begin(); iter != _referenceTable[key].end(); ++iter) {
- _puzzlesToCheck.push((*iter));
- }
+ Common::Array<PuzzleRef> *arr = &_referenceTable[key];
+ for (int32 i = arr->size() - 1; i >= 0; i--)
+ if (!(*arr)[i].puz->addedBySetState) {
+ (*arr)[i].scope->scopeQueue->push_back((*arr)[i].puz);
+ (*arr)[i].puz->addedBySetState = true;
+ }
}
}
-uint ScriptManager::getStateFlags(uint32 key) {
+void ScriptManager::setStateValue(uint32 key, int value) {
+ if (value == 0)
+ _globalState.erase(key);
+ else
+ _globalState[key] = value;
+
+ queuePuzzles(key);
+}
+
+void ScriptManager::setStateValueSilent(uint32 key, int value) {
+ if (value == 0)
+ _globalState.erase(key);
+ else
+ _globalState[key] = value;
+}
+
+uint ScriptManager::getStateFlag(uint32 key) {
if (_globalStateFlags.contains(key))
return _globalStateFlags[key];
else
return 0;
}
-void ScriptManager::setStateFlags(uint32 key, uint flags) {
- _globalStateFlags[key] = flags;
+void ScriptManager::setStateFlag(uint32 key, uint value) {
+ queuePuzzles(key);
- if (_referenceTable.contains(key)) {
- for (Common::Array<Puzzle *>::iterator iter = _referenceTable[key].begin(); iter != _referenceTable[key].end(); ++iter) {
- _puzzlesToCheck.push((*iter));
- }
- }
+ _globalStateFlags[key] |= value;
}
-void ScriptManager::addToStateValue(uint32 key, uint valueToAdd) {
- _globalState[key] += valueToAdd;
+void ScriptManager::setStateFlagSilent(uint32 key, uint value) {
+ if (value == 0)
+ _globalStateFlags.erase(key);
+ else
+ _globalStateFlags[key] = value;
}
-void ScriptManager::addControl(Control *control) {
- _activeControls.push_back(control);
-}
+void ScriptManager::unsetStateFlag(uint32 key, uint value) {
+ queuePuzzles(key);
-Control *ScriptManager::getControl(uint32 key) {
- for (ControlList::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) {
- if ((*iter)->getKey() == key) {
- return (*iter);
- }
+ if (_globalStateFlags.contains(key)) {
+ _globalStateFlags[key] &= ~value;
+
+ if (_globalStateFlags[key] == 0)
+ _globalStateFlags.erase(key);
}
+}
+Control *ScriptManager::getControl(uint32 key) {
+ for (ControlList::iterator iter = _activeControls->begin(); iter != _activeControls->end(); ++iter)
+ if ((*iter)->getKey() == key)
+ return *iter;
return nullptr;
}
void ScriptManager::focusControl(uint32 key) {
- for (ControlList::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) {
+ if (!_activeControls)
+ return;
+ if (_currentlyFocusedControl == key)
+ return;
+ for (ControlList::iterator iter = _activeControls->begin(); iter != _activeControls->end(); ++iter) {
uint32 controlKey = (*iter)->getKey();
-
+
if (controlKey == key) {
(*iter)->focus();
} else if (controlKey == _currentlyFocusedControl) {
@@ -271,167 +378,390 @@ void ScriptManager::focusControl(uint32 key) {
_currentlyFocusedControl = key;
}
+void ScriptManager::setFocusControlKey(uint32 key) {
+ _currentlyFocusedControl = key;
+}
+
+void ScriptManager::addSideFX(ScriptingEffect *fx) {
+ _activeSideFx.push_back(fx);
+}
+
+ScriptingEffect *ScriptManager::getSideFX(uint32 key) {
+ for (SideFXList::iterator iter = _activeSideFx.begin(); iter != _activeSideFx.end(); ++iter) {
+ if ((*iter)->getKey() == key) {
+ return (*iter);
+ }
+ }
+
+ return nullptr;
+}
+
+void ScriptManager::deleteSideFx(uint32 key) {
+ for (SideFXList::iterator iter = _activeSideFx.begin(); iter != _activeSideFx.end(); ++iter) {
+ if ((*iter)->getKey() == key) {
+ delete(*iter);
+ _activeSideFx.erase(iter);
+ break;
+ }
+ }
+}
+
+void ScriptManager::stopSideFx(uint32 key) {
+ for (SideFXList::iterator iter = _activeSideFx.begin(); iter != _activeSideFx.end(); ++iter) {
+ if ((*iter)->getKey() == key) {
+ bool ret = (*iter)->stop();
+ if (ret) {
+ delete(*iter);
+ _activeSideFx.erase(iter);
+ }
+ break;
+ }
+ }
+}
+
+void ScriptManager::killSideFx(uint32 key) {
+ for (SideFXList::iterator iter = _activeSideFx.begin(); iter != _activeSideFx.end(); ++iter) {
+ if ((*iter)->getKey() == key) {
+ (*iter)->kill();
+ delete(*iter);
+ _activeSideFx.erase(iter);
+ break;
+ }
+ }
+}
+
+void ScriptManager::killSideFxType(ScriptingEffect::ScriptingEffectType type) {
+ for (SideFXList::iterator iter = _activeSideFx.begin(); iter != _activeSideFx.end();) {
+ if ((*iter)->getType() & type) {
+ (*iter)->kill();
+ delete(*iter);
+ iter = _activeSideFx.erase(iter);
+ } else {
+ ++iter;
+ }
+ }
+}
+
void ScriptManager::onMouseDown(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {
- for (ControlList::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) {
- (*iter)->onMouseDown(screenSpacePos, backgroundImageSpacePos);
+ if (!_activeControls)
+ return;
+ for (ControlList::iterator iter = _activeControls->reverse_begin(); iter != _activeControls->end(); iter--) {
+ if ((*iter)->onMouseDown(screenSpacePos, backgroundImageSpacePos))
+ return;
}
}
void ScriptManager::onMouseUp(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {
- for (ControlList::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) {
- (*iter)->onMouseUp(screenSpacePos, backgroundImageSpacePos);
+ if (!_activeControls)
+ return;
+ for (ControlList::iterator iter = _activeControls->reverse_begin(); iter != _activeControls->end(); iter--) {
+ if ((*iter)->onMouseUp(screenSpacePos, backgroundImageSpacePos))
+ return;
}
}
bool ScriptManager::onMouseMove(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {
- bool cursorWasChanged = false;
- for (ControlList::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) {
- cursorWasChanged = cursorWasChanged || (*iter)->onMouseMove(screenSpacePos, backgroundImageSpacePos);
+ if (!_activeControls)
+ return false;
+
+ for (ControlList::iterator iter = _activeControls->reverse_begin(); iter != _activeControls->end(); iter--) {
+ if ((*iter)->onMouseMove(screenSpacePos, backgroundImageSpacePos))
+ return true;
}
- return cursorWasChanged;
+ return false;
}
void ScriptManager::onKeyDown(Common::KeyState keyState) {
- for (ControlList::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) {
- (*iter)->onKeyDown(keyState);
+ if (!_activeControls)
+ return;
+ for (ControlList::iterator iter = _activeControls->begin(); iter != _activeControls->end(); ++iter) {
+ if ((*iter)->onKeyDown(keyState))
+ return;
}
}
void ScriptManager::onKeyUp(Common::KeyState keyState) {
- for (ControlList::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) {
- (*iter)->onKeyUp(keyState);
+ if (!_activeControls)
+ return;
+ for (ControlList::iterator iter = _activeControls->begin(); iter != _activeControls->end(); ++iter) {
+ if ((*iter)->onKeyUp(keyState))
+ return;
}
}
-void ScriptManager::changeLocation(char world, char room, char node, char view, uint32 offset) {
- assert(world != 0);
- debug(1, "Changing location to: %c %c %c %c %u", world, room, node, view, offset);
+void ScriptManager::changeLocation(const Location &_newLocation) {
+ changeLocation(_newLocation.world, _newLocation.room, _newLocation.node, _newLocation.view, _newLocation.offset);
+}
- // Auto save
- _engine->getSaveManager()->autoSave();
+void ScriptManager::changeLocation(char _world, char _room, char _node, char _view, uint32 offset) {
+ _nextLocation.world = _world;
+ _nextLocation.room = _room;
+ _nextLocation.node = _node;
+ _nextLocation.view = _view;
+ _nextLocation.offset = offset;
+ // If next location 0000 - it's indicate to go to previous location.
+ if (_nextLocation.world == '0' && _nextLocation.room == '0' && _nextLocation.node == '0' && _nextLocation.view == '0') {
+ if (getStateValue(StateKey_World) != 'g' || getStateValue(StateKey_Room) != 'j') {
+ _nextLocation.world = getStateValue(StateKey_LastWorld);
+ _nextLocation.room = getStateValue(StateKey_LastRoom);
+ _nextLocation.node = getStateValue(StateKey_LastNode);
+ _nextLocation.view = getStateValue(StateKey_LastView);
+ _nextLocation.offset = getStateValue(StateKey_LastViewPos);
+ } else {
+ _nextLocation.world = getStateValue(StateKey_Menu_LastWorld);
+ _nextLocation.room = getStateValue(StateKey_Menu_LastRoom);
+ _nextLocation.node = getStateValue(StateKey_Menu_LastNode);
+ _nextLocation.view = getStateValue(StateKey_Menu_LastView);
+ _nextLocation.offset = getStateValue(StateKey_Menu_LastViewPos);
+ }
+ }
+}
- // Clear all the containers
- _referenceTable.clear();
- _puzzlesToCheck.clear();
- for (PuzzleList::iterator iter = _activePuzzles.begin(); iter != _activePuzzles.end(); ++iter) {
- delete (*iter);
+void ScriptManager::ChangeLocationReal() {
+ assert(_nextLocation.world != 0);
+ debug(1, "Changing location to: %c %c %c %c %u", _nextLocation.world, _nextLocation.room, _nextLocation.node, _nextLocation.view, _nextLocation.offset);
+
+ if (_nextLocation.world == 'g' && _nextLocation.room == 'j' && !ConfMan.getBool("originalsaveload")) {
+ if ((_nextLocation.node == 's' || _nextLocation.node == 'r') && _nextLocation.view == 'e') {
+ // Hook up the ScummVM save/restore dialog
+ bool isSave = (_nextLocation.node == 's');
+ bool gameSavedOrLoaded = _engine->getSaveManager()->scummVMSaveLoadDialog(isSave);
+ if (!gameSavedOrLoaded || isSave) {
+ // Reload the current room
+ _nextLocation.world = _currentLocation.world;
+ _nextLocation.room = _currentLocation.room;
+ _nextLocation.node = _currentLocation.node;
+ _nextLocation.view = _currentLocation.view;
+ _nextLocation.offset = _currentLocation.offset;
+ _currentLocation.world = '0';
+ _currentLocation.room = '0';
+ _currentLocation.node = '0';
+ _currentLocation.view = '0';
+ _currentLocation.offset = 0;
+ } else
+ return;
+ }
}
- _activePuzzles.clear();
- for (ControlList::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) {
- delete (*iter);
+
+ _engine->setRenderDelay(2);
+
+ if (getStateValue(StateKey_World) != 'g' || getStateValue(StateKey_Room) != 'j') {
+ if (_nextLocation.world != 'g' || _nextLocation.room != 'j') {
+ setStateValue(StateKey_LastWorld, getStateValue(StateKey_World));
+ setStateValue(StateKey_LastRoom, getStateValue(StateKey_Room));
+ setStateValue(StateKey_LastNode, getStateValue(StateKey_Node));
+ setStateValue(StateKey_LastView, getStateValue(StateKey_View));
+ setStateValue(StateKey_LastViewPos, getStateValue(StateKey_ViewPos));
+ } else {
+ setStateValue(StateKey_Menu_LastWorld, getStateValue(StateKey_World));
+ setStateValue(StateKey_Menu_LastRoom, getStateValue(StateKey_Room));
+ setStateValue(StateKey_Menu_LastNode, getStateValue(StateKey_Node));
+ setStateValue(StateKey_Menu_LastView, getStateValue(StateKey_View));
+ setStateValue(StateKey_Menu_LastViewPos, getStateValue(StateKey_ViewPos));
+ }
}
- _activeControls.clear();
- // Revert to the idle cursor
- _engine->getCursorManager()->revertToIdle();
+ if (_nextLocation.world == 'g' && _nextLocation.room == 'j') {
+ if (_nextLocation.node == 's' && _nextLocation.view == 'e' &&
+ _currentLocation.world != 'g' && _currentLocation.room != 'j')
+ _engine->getSaveManager()->prepareSaveBuffer();
+ } else {
+ if (_currentLocation.world == 'g' && _currentLocation.room == 'j')
+ _engine->getSaveManager()->flushSaveBuffer();
+ }
- // Reset the background velocity
- _engine->getRenderManager()->setBackgroundVelocity(0);
+ setStateValue(StateKey_World, _nextLocation.world);
+ setStateValue(StateKey_Room, _nextLocation.room);
+ setStateValue(StateKey_Node, _nextLocation.node);
+ setStateValue(StateKey_View, _nextLocation.view);
+ setStateValue(StateKey_ViewPos, _nextLocation.offset);
- // Remove any alphaEntries
- _engine->getRenderManager()->clearAlphaEntries();
+ _referenceTable.clear();
+ addPuzzlesToReferenceTable(universe);
- // Clean the global state table
- cleanStateTable();
+ _engine->getMenuHandler()->setEnable(0xFFFF);
- // Parse into puzzles and controls
- Common::String fileName = Common::String::format("%c%c%c%c.scr", world, room, node, view);
- parseScrFile(fileName);
+ if (_nextLocation.world != _currentLocation.world) {
+ cleanScriptScope(nodeview);
+ cleanScriptScope(room);
+ cleanScriptScope(world);
- // Change the background position
- _engine->getRenderManager()->setBackgroundPosition(offset);
+ Common::String fileName = Common::String::format("%c%c%c%c.scr", _nextLocation.world, _nextLocation.room, _nextLocation.node, _nextLocation.view);
+ parseScrFile(fileName, nodeview);
+ addPuzzlesToReferenceTable(nodeview);
- // Enable all the controls
- for (ControlList::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) {
- (*iter)->enable();
- }
+ fileName = Common::String::format("%c%c.scr", _nextLocation.world, _nextLocation.room);
+ parseScrFile(fileName, room);
+ addPuzzlesToReferenceTable(room);
- // Add all the local puzzles to the queue to be checked
- for (PuzzleList::iterator iter = _activePuzzles.begin(); iter != _activePuzzles.end(); ++iter) {
- // Reset any Puzzles that have the flag ONCE_PER_INST
- if ((getStateFlags((*iter)->key) & ONCE_PER_INST) == ONCE_PER_INST) {
- setStateValue((*iter)->key, 0);
- }
+ fileName = Common::String::format("%c.scr", _nextLocation.world);
+ parseScrFile(fileName, world);
+ addPuzzlesToReferenceTable(world);
+ } else if (_nextLocation.room != _currentLocation.room) {
+ cleanScriptScope(nodeview);
+ cleanScriptScope(room);
- _puzzlesToCheck.push((*iter));
- }
+ addPuzzlesToReferenceTable(world);
- // Add all the global puzzles to the queue to be checked
- for (PuzzleList::iterator iter = _globalPuzzles.begin(); iter != _globalPuzzles.end(); ++iter) {
- // Reset any Puzzles that have the flag ONCE_PER_INST
- if ((getStateFlags((*iter)->key) & ONCE_PER_INST) == ONCE_PER_INST) {
- setStateValue((*iter)->key, 0);
- }
+ Common::String fileName = Common::String::format("%c%c%c%c.scr", _nextLocation.world, _nextLocation.room, _nextLocation.node, _nextLocation.view);
+ parseScrFile(fileName, nodeview);
+ addPuzzlesToReferenceTable(nodeview);
+
+ fileName = Common::String::format("%c%c.scr", _nextLocation.world, _nextLocation.room);
+ parseScrFile(fileName, room);
+ addPuzzlesToReferenceTable(room);
+
+ } else if (_nextLocation.node != _currentLocation.node || _nextLocation.view != _currentLocation.view) {
+ cleanScriptScope(nodeview);
- _puzzlesToCheck.push((*iter));
+ addPuzzlesToReferenceTable(room);
+ addPuzzlesToReferenceTable(world);
+
+ Common::String fileName = Common::String::format("%c%c%c%c.scr", _nextLocation.world, _nextLocation.room, _nextLocation.node, _nextLocation.view);
+ parseScrFile(fileName, nodeview);
+ addPuzzlesToReferenceTable(nodeview);
}
- // Create the puzzle reference table
- createReferenceTable();
+ _activeControls = &nodeview.controls;
+
+ // Revert to the idle cursor
+ _engine->getCursorManager()->changeCursor(CursorIndex_Idle);
+
+ // Change the background position
+ _engine->getRenderManager()->setBackgroundPosition(_nextLocation.offset);
+
+ if (_currentLocation.world == 0 && _currentLocation.room == 0 && _currentLocation.node == 0 && _currentLocation.view == 0) {
+ _currentLocation = _nextLocation;
+ execScope(world);
+ execScope(room);
+ execScope(nodeview);
+ } else if (_nextLocation.world != _currentLocation.world) {
+ _currentLocation = _nextLocation;
+ execScope(room);
+ execScope(nodeview);
+ } else if (_nextLocation.room != _currentLocation.room) {
+ _currentLocation = _nextLocation;
+ execScope(room);
+ execScope(nodeview);
+ } else if (_nextLocation.node != _currentLocation.node || _nextLocation.view != _currentLocation.view) {
+ _currentLocation = _nextLocation;
+ execScope(nodeview);
+ }
- // Update _currentLocation
- _currentLocation.world = world;
- _currentLocation.room = room;
- _currentLocation.node = node;
- _currentLocation.view = view;
- _currentLocation.offset = offset;
+ _engine->getRenderManager()->checkBorders();
}
-void ScriptManager::serializeStateTable(Common::WriteStream *stream) {
- // Write the number of state value entries
- stream->writeUint32LE(_globalState.size());
+void ScriptManager::serialize(Common::WriteStream *stream) {
+ stream->writeUint32BE(MKTAG('Z', 'N', 'S', 'G'));
+ stream->writeUint32LE(4);
+ stream->writeUint32LE(0);
+ stream->writeUint32BE(MKTAG('L', 'O', 'C', ' '));
+ stream->writeUint32LE(8);
+ stream->writeByte(getStateValue(StateKey_World));
+ stream->writeByte(getStateValue(StateKey_Room));
+ stream->writeByte(getStateValue(StateKey_Node));
+ stream->writeByte(getStateValue(StateKey_View));
+ stream->writeUint32LE(getStateValue(StateKey_ViewPos));
+
+ for (SideFXList::iterator iter = _activeSideFx.begin(); iter != _activeSideFx.end(); ++iter)
+ (*iter)->serialize(stream);
- for (StateMap::iterator iter = _globalState.begin(); iter != _globalState.end(); ++iter) {
- // Write out the key/value pair
- stream->writeUint32LE(iter->_key);
- stream->writeUint32LE(iter->_value);
- }
+ stream->writeUint32BE(MKTAG('F', 'L', 'A', 'G'));
+
+ int32 slots = 20000;
+ if (_engine->getGameId() == GID_NEMESIS)
+ slots = 30000;
+
+ stream->writeUint32LE(slots * 2);
+
+ for (int32 i = 0; i < slots; i++)
+ stream->writeUint16LE(getStateFlag(i));
+
+ stream->writeUint32BE(MKTAG('P', 'U', 'Z', 'Z'));
+
+ stream->writeUint32LE(slots * 2);
+
+ for (int32 i = 0; i < slots; i++)
+ stream->writeSint16LE(getStateValue(i));
}
-void ScriptManager::deserializeStateTable(Common::SeekableReadStream *stream) {
+void ScriptManager::deserialize(Common::SeekableReadStream *stream) {
// Clear out the current table values
_globalState.clear();
+ _globalStateFlags.clear();
- // Read the number of key/value pairs
- uint32 numberOfPairs = stream->readUint32LE();
+ cleanScriptScope(nodeview);
+ cleanScriptScope(room);
+ cleanScriptScope(world);
- for (uint32 i = 0; i < numberOfPairs; ++i) {
- uint32 key = stream->readUint32LE();
- uint32 value = stream->readUint32LE();
- // Directly access the state table so we don't trigger Puzzle checks
- _globalState[key] = value;
- }
-}
+ _currentLocation.node = 0;
+ _currentLocation.world = 0;
+ _currentLocation.room = 0;
+ _currentLocation.view = 0;
-void ScriptManager::serializeControls(Common::WriteStream *stream) {
- // Count how many controls need to save their data
- // Because WriteStream isn't seekable
- uint32 numberOfControlsNeedingSerialization = 0;
- for (ControlList::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) {
- if ((*iter)->needsSerialization()) {
- numberOfControlsNeedingSerialization++;
- }
- }
- stream->writeUint32LE(numberOfControlsNeedingSerialization);
+ for (SideFXList::iterator iter = _activeSideFx.begin(); iter != _activeSideFx.end(); iter++)
+ delete(*iter);
- for (ControlList::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) {
- (*iter)->serialize(stream);
+ _activeSideFx.clear();
+
+ _referenceTable.clear();
+
+ if (stream->readUint32BE() != MKTAG('Z', 'N', 'S', 'G') || stream->readUint32LE() != 4) {
+ changeLocation('g', 'a', 'r', 'y', 0);
+ return;
}
-}
-void ScriptManager::deserializeControls(Common::SeekableReadStream *stream) {
- uint32 numberOfControls = stream->readUint32LE();
+ stream->seek(4, SEEK_CUR);
- for (uint32 i = 0; i < numberOfControls; ++i) {
- uint32 key = stream->readUint32LE();
- for (ControlList::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) {
- if ((*iter)->getKey() == key) {
- (*iter)->deserialize(stream);
- break;
- }
+ if (stream->readUint32BE() != MKTAG('L', 'O', 'C', ' ') || stream->readUint32LE() != 8) {
+ changeLocation('g', 'a', 'r', 'y', 0);
+ return;
+ }
+
+ Location nextLocation;
+
+ nextLocation.world = stream->readByte();
+ nextLocation.room = stream->readByte();
+ nextLocation.node = stream->readByte();
+ nextLocation.view = stream->readByte();
+ nextLocation.offset = stream->readUint32LE() & 0x0000FFFF;
+
+ while (stream->pos() < stream->size()) {
+ uint32 tag = stream->readUint32BE();
+ uint32 tagSize = stream->readUint32LE();
+ switch (tag) {
+ case MKTAG('T', 'I', 'M', 'R'): {
+ uint32 key = stream->readUint32LE();
+ uint32 time = stream->readUint32LE();
+ if (_engine->getGameId() == GID_GRANDINQUISITOR)
+ time /= 100;
+ else if (_engine->getGameId() == GID_NEMESIS)
+ time /= 1000;
+ addSideFX(new TimerNode(_engine, key, time));
+ }
+ break;
+ case MKTAG('F', 'L', 'A', 'G'):
+ for (uint32 i = 0; i < tagSize / 2; i++)
+ setStateFlagSilent(i, stream->readUint16LE());
+ break;
+ case MKTAG('P', 'U', 'Z', 'Z'):
+ for (uint32 i = 0; i < tagSize / 2; i++)
+ setStateValueSilent(i, stream->readUint16LE());
+ break;
+ default:
+ stream->seek(tagSize, SEEK_CUR);
}
}
+
+ _nextLocation = nextLocation;
+
+ ChangeLocationReal();
+
+ _engine->setRenderDelay(10);
+ setStateValue(StateKey_RestoreFlag, 1);
+
+ _engine->loadSettings();
}
Location ScriptManager::getCurrentLocation() const {
@@ -441,4 +771,74 @@ Location ScriptManager::getCurrentLocation() const {
return location;
}
+Location ScriptManager::getLastLocation() {
+ Location location;
+ location.world = getStateValue(StateKey_LastWorld);
+ location.room = getStateValue(StateKey_LastRoom);
+ location.node = getStateValue(StateKey_LastNode);
+ location.view = getStateValue(StateKey_LastView);
+ location.offset = getStateValue(StateKey_LastViewPos);
+
+ return location;
+}
+
+Location ScriptManager::getLastMenuLocation() {
+ Location location;
+ location.world = getStateValue(StateKey_Menu_LastWorld);
+ location.room = getStateValue(StateKey_Menu_LastRoom);
+ location.node = getStateValue(StateKey_Menu_LastNode);
+ location.view = getStateValue(StateKey_Menu_LastView);
+ location.offset = getStateValue(StateKey_Menu_LastViewPos);
+
+ return location;
+}
+
+void ScriptManager::addEvent(Common::Event event) {
+ _controlEvents.push_back(event);
+}
+
+void ScriptManager::flushEvent(Common::EventType type) {
+ EventList::iterator it = _controlEvents.begin();
+ while (it != _controlEvents.end()) {
+
+ if ((*it).type == type)
+ it = _controlEvents.erase(it);
+ else
+ it++;
+ }
+}
+
+void ScriptManager::trimCommentsAndWhiteSpace(Common::String *string) const {
+ for (int i = string->size() - 1; i >= 0; i--) {
+ if ((*string)[i] == '#') {
+ string->erase(i);
+ }
+ }
+
+ string->trim();
+}
+
+ValueSlot::ValueSlot(ScriptManager *scriptManager, const char *slotValue):
+ _scriptManager(scriptManager) {
+ value = 0;
+ slot = false;
+ const char *isSlot = strstr(slotValue, "[");
+ if (isSlot) {
+ slot = true;
+ value = atoi(isSlot + 1);
+ } else {
+ slot = false;
+ value = atoi(slotValue);
+ }
+}
+int16 ValueSlot::getValue() {
+ if (slot) {
+ if (value >= 0)
+ return _scriptManager->getStateValue(value);
+ else
+ return 0;
+ } else
+ return value;
+}
+
} // End of namespace ZVision
diff --git a/engines/zvision/scripting/script_manager.h b/engines/zvision/scripting/script_manager.h
index 4d1b1f359b..78c1b77dea 100644
--- a/engines/zvision/scripting/script_manager.h
+++ b/engines/zvision/scripting/script_manager.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.
@@ -25,10 +25,11 @@
#include "zvision/scripting/puzzle.h"
#include "zvision/scripting/control.h"
+#include "zvision/scripting/scripting_effect.h"
#include "common/hashmap.h"
#include "common/queue.h"
-
+#include "common/events.h"
namespace Common {
class String;
@@ -39,6 +40,68 @@ namespace ZVision {
class ZVision;
+enum StateKey {
+ StateKey_World = 3,
+ StateKey_Room = 4,
+ StateKey_Node = 5,
+ StateKey_View = 6,
+ StateKey_ViewPos = 7,
+ StateKey_KeyPress = 8,
+ StateKey_InventoryItem = 9,
+ StateKey_LMouse = 10,
+ StateKey_NotSet = 11, // This key doesn't set
+ StateKey_Rounds = 12,
+ StateKey_Venus = 13,
+ StateKey_RMouse = 18,
+ StateKey_MenuState = 19,
+ StateKey_RestoreFlag = 20,
+ StateKey_Quitting = 39,
+ StateKey_LastWorld = 40,
+ StateKey_LastRoom = 41,
+ StateKey_LastNode = 42,
+ StateKey_LastView = 43,
+ StateKey_LastViewPos = 44,
+ StateKey_Menu_LastWorld = 45,
+ StateKey_Menu_LastRoom = 46,
+ StateKey_Menu_LastNode = 47,
+ StateKey_Menu_LastView = 48,
+ StateKey_Menu_LastViewPos = 49,
+ StateKey_KbdRotateSpeed = 50,
+ StateKey_Subtitles = 51,
+ StateKey_StreamSkipKey = 52,
+ StateKey_RotateSpeed = 53,
+ StateKey_Volume = 56,
+ StateKey_Qsound = 57,
+ StateKey_VenusEnable = 58,
+ StateKey_HighQuality = 59,
+ StateKey_VideoLineSkip = 65,
+ StateKey_Platform = 66,
+ StateKey_InstallLevel = 67,
+ StateKey_CountryCode = 68,
+ StateKey_CPU = 69,
+ StateKey_MovieCursor = 70,
+ StateKey_NoTurnAnim = 71,
+ StateKey_WIN958 = 72,
+ StateKey_ShowErrorDlg = 73,
+ StateKey_DebugCheats = 74,
+ StateKey_JapanFonts = 75,
+ StateKey_ExecScopeStyle = 76,
+ StateKey_Brightness = 77,
+ StateKey_EF9_R = 91,
+ StateKey_EF9_G = 92,
+ StateKey_EF9_B = 93,
+ StateKey_EF9_Speed = 94,
+ StateKey_Inv_Cnt_Slot = 100,
+ StateKey_Inv_1_Slot = 101,
+ StateKey_Inv_49_Slot = 149,
+ // ZGI only
+ StateKey_Inv_TotalSlots = 150,
+ StateKey_Inv_StartSlot = 151,
+ StateKey_Spell_1 = 191,
+ StateKey_Active_Spell = 205,
+ StateKey_Reversed_Spellbooc = 206
+};
+
struct Location {
Location() : world('g'), room('a'), node('r'), view('y'), offset(0) {}
@@ -49,68 +112,99 @@ struct Location {
uint32 offset;
};
-typedef Common::HashMap<uint32, Common::Array<Puzzle *> > PuzzleMap;
typedef Common::List<Puzzle *> PuzzleList;
typedef Common::Queue<Puzzle *> PuzzleQueue;
typedef Common::List<Control *> ControlList;
-typedef Common::HashMap<uint32, uint32> StateMap;
-typedef Common::HashMap<uint32, uint> StateFlagMap;
+typedef Common::HashMap<uint32, int32> StateMap;
+typedef Common::List<ScriptingEffect *> SideFXList;
+typedef Common::List<Common::Event> EventList;
class ScriptManager {
public:
ScriptManager(ZVision *engine);
~ScriptManager();
-public:
- enum StateFlags {
- ONCE_PER_INST = 0x01,
- DO_ME_NOW = 0x02, // Somewhat useless flag since anything that needs to be done immediately has no criteria
- DISABLED = 0x04
- };
-
private:
ZVision *_engine;
+
+ struct ScriptScope {
+ uint32 procCount;
+
+ PuzzleList *scopeQueue; // For adding puzzles to queue
+ PuzzleList *execQueue; // Switch to it when execute
+ PuzzleList privQueueOne;
+ PuzzleList privQueueTwo;
+
+ PuzzleList puzzles;
+ ControlList controls;
+ };
+
+ struct PuzzleRef {
+ Puzzle *puz;
+ ScriptScope *scope;
+ };
+
+ typedef Common::HashMap<uint32, Common::Array<PuzzleRef> > PuzzleMap;
+
/**
* Holds the global state variable. Do NOT directly modify this. Use the accessors and
* mutators getStateValue() and setStateValue(). This ensures that Puzzles that reference a
* particular state key are checked after the key is modified.
*/
StateMap _globalState;
- /**
- * Holds the flags for the global states. This is used to enable/disable puzzles and/or
- * controls as well as which puzzles should are allowed to be re-executed
- */
- StateFlagMap _globalStateFlags;
+ /** Holds execute flags */
+ StateMap _globalStateFlags;
/** References _globalState keys to Puzzles */
PuzzleMap _referenceTable;
- /** Holds the Puzzles that should be checked this frame */
- PuzzleQueue _puzzlesToCheck;
- /** Holds the currently active puzzles */
- PuzzleList _activePuzzles;
- /** Holds the global puzzles */
- PuzzleList _globalPuzzles;
/** Holds the currently active controls */
- ControlList _activeControls;
+ ControlList *_activeControls;
+
+ EventList _controlEvents;
+
+ ScriptScope universe;
+ ScriptScope world;
+ ScriptScope room;
+ ScriptScope nodeview;
+
+ /** Holds the currently active timers, musics, other */
+ SideFXList _activeSideFx;
Location _currentLocation;
+ Location _nextLocation;
uint32 _currentlyFocusedControl;
public:
void initialize();
void update(uint deltaTimeMillis);
+ void queuePuzzles(uint32 key);
- uint getStateValue(uint32 key);
- void setStateValue(uint32 key, uint value);
- void addToStateValue(uint32 key, uint valueToAdd);
+ int getStateValue(uint32 key);
+ void setStateValue(uint32 key, int value);
- uint getStateFlags(uint32 key);
- void setStateFlags(uint32 key, uint flags);
+ uint getStateFlag(uint32 key);
+ void setStateFlag(uint32 key, uint value);
+ void unsetStateFlag(uint32 key, uint value);
void addControl(Control *control);
Control *getControl(uint32 key);
+ void enableControl(uint32 key);
+ void disableControl(uint32 key);
+
void focusControl(uint32 key);
+ // Only change focus control without call focus/unfocus.
+ void setFocusControlKey(uint32 key);
+
+ void addSideFX(ScriptingEffect *fx);
+ ScriptingEffect *getSideFX(uint32 key);
+ void deleteSideFx(uint32 key);
+ void stopSideFx(uint32 key);
+ void killSideFx(uint32 key);
+ void killSideFxType(ScriptingEffect::ScriptingEffectType type);
+
+ void addEvent(Common::Event);
+ void flushEvent(Common::EventType type);
/**
* Called when LeftMouse is pushed.
@@ -147,32 +241,61 @@ public:
*/
void onKeyUp(Common::KeyState keyState);
+ /** Mark next location */
void changeLocation(char world, char room, char node, char view, uint32 offset);
+ void changeLocation(const Location &_newLocation);
- void serializeStateTable(Common::WriteStream *stream);
- void deserializeStateTable(Common::SeekableReadStream *stream);
- void serializeControls(Common::WriteStream *stream);
- void deserializeControls(Common::SeekableReadStream *stream);
+ void serialize(Common::WriteStream *stream);
+ void deserialize(Common::SeekableReadStream *stream);
Location getCurrentLocation() const;
+ Location getLastLocation();
+ Location getLastMenuLocation();
+
+ /**
+ * Removes any line comments using '#' as a sequence start.
+ * Then removes any trailing and leading 'whitespace' using String::trim()
+ * Note: String::trim uses isspace() to determine what is whitespace and what is not.
+ *
+ * @param string The string to modify. It is modified in place
+ */
+ void trimCommentsAndWhiteSpace(Common::String *string) const;
private:
- void createReferenceTable();
+ void referenceTableAddPuzzle(uint32 key, PuzzleRef ref);
+ void addPuzzlesToReferenceTable(ScriptScope &scope);
void updateNodes(uint deltaTimeMillis);
- void checkPuzzleCriteria();
+ void updateControls(uint deltaTimeMillis);
+ bool checkPuzzleCriteria(Puzzle *puzzle, uint counter);
void cleanStateTable();
+ void cleanScriptScope(ScriptScope &scope);
+ bool execScope(ScriptScope &scope);
+
+ /** Perform change location */
+ void ChangeLocationReal();
+
+ int8 inventoryGetCount();
+ void inventorySetCount(int8 cnt);
+ int16 inventoryGetItem(int8 id);
+ void inventorySetItem(int8 id, int16 item);
+
+ void setStateFlagSilent(uint32 key, uint value);
+ void setStateValueSilent(uint32 key, int value);
-// TODO: Make this private. It was only made public so Console::cmdParseAllScrFiles() could use it
public:
+ void inventoryAdd(int16 item);
+ void inventoryDrop(int16 item);
+ void inventoryCycle();
+
+private:
/**
* Parses a script file into triggers and events
*
* @param fileName Name of the .scr file
* @param isGlobal Are the puzzles included in the file global (true). AKA, the won't be purged during location changes
*/
- void parseScrFile(const Common::String &fileName, bool isGlobal = false);
+ void parseScrFile(const Common::String &fileName, ScriptScope &scope);
-private:
/**
* Parses the stream into a Puzzle object
* Helper method for parseScrFile.
@@ -216,9 +339,18 @@ private:
* @param line The line initially read
* @param stream Scr file stream
*/
- void parseControl(Common::String &line, Common::SeekableReadStream &stream);
+ Control *parseControl(Common::String &line, Common::SeekableReadStream &stream);
};
+class ValueSlot {
+public:
+ ValueSlot(ScriptManager *scriptManager, const char *slotValue);
+ int16 getValue();
+private:
+ int16 value;
+ bool slot;
+ ScriptManager *_scriptManager;
+};
} // End of namespace ZVision
diff --git a/engines/zvision/scripting/scripting_effect.h b/engines/zvision/scripting/scripting_effect.h
new file mode 100644
index 0000000000..0af1d9c21c
--- /dev/null
+++ b/engines/zvision/scripting/scripting_effect.h
@@ -0,0 +1,124 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public 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 SCRIPTING_EFFECT_H_INCLUDED
+#define SCRIPTING_EFFECT_H_INCLUDED
+
+namespace Common {
+class SeekableReadStream;
+struct Point;
+class WriteStream;
+}
+
+namespace ZVision {
+
+class ZVision;
+
+/**
+ * The base class that represents effects created from Actions.
+ * This class is virtual.
+ *
+ * Detailed Description:
+ * A scene has Controls. By interacting with the controls, the user
+ * causes Actions to execute. Certain Actions create 'effects', for
+ * example, a sound or an animation. This is the base class for
+ * those effects.
+ */
+class ScriptingEffect {
+public:
+
+ enum ScriptingEffectType {
+ SCRIPTING_EFFECT_ANIM = 1,
+ SCRIPTING_EFFECT_AUDIO = 2,
+ SCRIPTING_EFFECT_DISTORT = 4,
+ SCRIPTING_EFFECT_PANTRACK = 8,
+ SCRIPTING_EFFECT_REGION = 16,
+ SCRIPTING_EFFECT_TIMER = 32,
+ SCRIPTING_EFFECT_TTYTXT = 64,
+ SCRIPTING_EFFECT_UNKNOWN = 128,
+ SCRIPTING_EFFECT_ALL = 255
+ };
+
+ ScriptingEffect() : _engine(0), _key(0), _type(SCRIPTING_EFFECT_UNKNOWN) {}
+ ScriptingEffect(ZVision *engine, uint32 key, ScriptingEffectType type) : _engine(engine), _key(key), _type(type) {}
+ virtual ~ScriptingEffect() {}
+
+ uint32 getKey() {
+ return _key;
+ }
+ ScriptingEffectType getType() {
+ return _type;
+ }
+
+ virtual bool process(uint32 deltaTimeInMillis) {
+ return false;
+ }
+ /**
+ * Serialize a SideFX for save game use. This should only be used if a SideFX needs
+ * to save values that would be different from initialization. AKA a TimerNode needs to
+ * store the amount of time left on the timer. Any Controls overriding this *MUST* write
+ * their key as the first data outputted. The default implementation is NOP.
+ *
+ * NOTE: If this method is overridden, you MUST also override deserialize()
+ * and needsSerialization()
+ *
+ * @param stream Stream to write any needed data to
+ */
+ virtual void serialize(Common::WriteStream *stream) {}
+ /**
+ * De-serialize data from a save game stream. This should only be implemented if the
+ * SideFX also implements serialize(). The calling method assumes the size of the
+ * data read from the stream exactly equals that written in serialize(). The default
+ * implementation is NOP.
+ *
+ * NOTE: If this method is overridden, you MUST also override serialize()
+ * and needsSerialization()
+ *
+ * @param stream Save game file stream
+ */
+ virtual void deserialize(Common::SeekableReadStream *stream) {}
+ /**
+ * If a SideFX overrides serialize() and deserialize(), this should return true
+ *
+ * @return Does the SideFX need save game serialization?
+ */
+ virtual inline bool needsSerialization() {
+ return false;
+ }
+
+ virtual bool stop() {
+ return true;
+ }
+ virtual void kill() {}
+
+protected:
+ ZVision *_engine;
+ uint32 _key;
+ ScriptingEffectType _type;
+
+// Static member functions
+public:
+
+};
+} // End of namespace ZVision
+
+#endif // SCRIPTING_EFFECT_H_INCLUDED
diff --git a/engines/zvision/sound/midi.cpp b/engines/zvision/sound/midi.cpp
new file mode 100644
index 0000000000..3dd66ff2d4
--- /dev/null
+++ b/engines/zvision/sound/midi.cpp
@@ -0,0 +1,91 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public 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/textconsole.h"
+
+#include "zvision/sound/midi.h"
+
+namespace ZVision {
+
+MidiManager::MidiManager() {
+ MidiDriver::DeviceHandle dev = MidiDriver::detectDevice(MDT_MIDI | MDT_ADLIB);
+ _driver = MidiDriver::createMidi(dev);
+ if (_driver->open())
+ warning("Can't open MIDI, no MIDI output!");
+}
+
+MidiManager::~MidiManager() {
+ stop();
+ _driver->close();
+ delete _driver;
+}
+
+void MidiManager::stop() {
+ for (int8 i = 0; i < 16; i++)
+ if (_playChannels[i].playing)
+ noteOff(i);
+}
+
+void MidiManager::noteOn(int8 channel, int8 note, int8 velocity) {
+ assert(channel <= 15);
+
+ _playChannels[channel].playing = true;
+ _playChannels[channel].note = note;
+ _driver->send(channel | (velocity << 16) | (note << 8) | 0x90);
+}
+
+void MidiManager::noteOff(int8 channel) {
+ assert(channel <= 15);
+
+ if (_playChannels[channel].playing) {
+ _playChannels[channel].playing = false;
+ _driver->send(channel | (_playChannels[channel].note << 8) | 0x80);
+ }
+}
+
+int8 MidiManager::getFreeChannel() {
+ for (int8 i = 0; i < 16; i++)
+ if (!_playChannels[i].playing)
+ return i;
+ return -1;
+}
+
+void MidiManager::setPan(int8 channel, int8 pan) {
+ assert(channel <= 15);
+
+ _driver->send(channel | (pan << 16) | 0xAB0);
+}
+
+void MidiManager::setVolume(int8 channel, int8 volume) {
+ assert(channel <= 15);
+
+ _driver->send(channel | (volume << 16) | 0x7B0);
+}
+
+void MidiManager::setProgram(int8 channel, int8 prog) {
+ assert(channel <= 15);
+
+ _driver->send(channel | (prog << 8) | 0xC0);
+}
+
+} // End of namespace ZVision
diff --git a/engines/zvision/sound/midi.h b/engines/zvision/sound/midi.h
new file mode 100644
index 0000000000..a3bac19636
--- /dev/null
+++ b/engines/zvision/sound/midi.h
@@ -0,0 +1,59 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public 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 ZVISION_MIDI_H
+#define ZVISION_MIDI_H
+
+#include "audio/mididrv.h"
+
+namespace ZVision {
+
+class MidiManager {
+public:
+ MidiManager();
+ ~MidiManager();
+
+ void stop();
+ void noteOn(int8 channel, int8 noteNumber, int8 velocity);
+ void noteOff(int8 channel);
+ void setPan(int8 channel, int8 pan);
+ void setVolume(int8 channel, int8 volume);
+ void setProgram(int8 channel, int8 prog);
+
+ int8 getFreeChannel();
+
+protected:
+
+ struct chan {
+ bool playing;
+ int8 note;
+
+ chan() : playing(false), note(0) {};
+ };
+
+ MidiDriver *_driver;
+ chan _playChannels[16];
+};
+
+}
+
+#endif
diff --git a/engines/zvision/sound/zork_raw.cpp b/engines/zvision/sound/zork_raw.cpp
index edee1fd16e..6d1980b1af 100644
--- a/engines/zvision/sound/zork_raw.cpp
+++ b/engines/zvision/sound/zork_raw.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.
@@ -21,85 +21,78 @@
*/
#include "common/scummsys.h"
-
-#include "zvision/sound/zork_raw.h"
-
-#include "zvision/zvision.h"
-#include "zvision/detection.h"
-#include "zvision/utility/utility.h"
-
#include "common/file.h"
#include "common/str.h"
#include "common/stream.h"
#include "common/memstream.h"
#include "common/bufferedstream.h"
#include "common/util.h"
-
+#include "common/tokenizer.h"
#include "audio/audiostream.h"
#include "audio/decoders/raw.h"
+#include "zvision/sound/zork_raw.h"
+#include "zvision/zvision.h"
+#include "zvision/detection.h"
namespace ZVision {
-const int16 RawZorkStream::_stepAdjustmentTable[8] = {-1, -1, -1, 1, 4, 7, 10, 12};
-
-const int32 RawZorkStream::_amplitudeLookupTable[89] = {0x0007, 0x0008, 0x0009, 0x000A, 0x000B, 0x000C, 0x000D, 0x000E,
- 0x0010, 0x0011, 0x0013, 0x0015, 0x0017, 0x0019, 0x001C, 0x001F,
- 0x0022, 0x0025, 0x0029, 0x002D, 0x0032, 0x0037, 0x003C, 0x0042,
- 0x0049, 0x0050, 0x0058, 0x0061, 0x006B, 0x0076, 0x0082, 0x008F,
- 0x009D, 0x00AD, 0x00BE, 0x00D1, 0x00E6, 0x00FD, 0x0117, 0x0133,
- 0x0151, 0x0173, 0x0198, 0x01C1, 0x01EE, 0x0220, 0x0256, 0x0292,
- 0x02D4, 0x031C, 0x036C, 0x03C3, 0x0424, 0x048E, 0x0502, 0x0583,
- 0x0610, 0x06AB, 0x0756, 0x0812, 0x08E0, 0x09C3, 0x0ABD, 0x0BD0,
- 0x0CFF, 0x0E4C, 0x0FBA, 0x114C, 0x1307, 0x14EE, 0x1706, 0x1954,
- 0x1BDC, 0x1EA5, 0x21B6, 0x2515, 0x28CA, 0x2CDF, 0x315B, 0x364B,
- 0x3BB9, 0x41B2, 0x4844, 0x4F7E, 0x5771, 0x602F, 0x69CE, 0x7462, 0x7FFF};
-
-const SoundParams RawZorkStream::_zNemSoundParamLookupTable[6] = {{'6', 0x2B11, false, false},
- {'a', 0x5622, false, true},
- {'b', 0x5622, true, true},
- {'n', 0x2B11, false, true},
- {'s', 0x5622, false, true},
- {'t', 0x5622, true, true}
-};
-
-const SoundParams RawZorkStream::_zgiSoundParamLookupTable[5] = {{'a',0x5622, false, false},
- {'k',0x2B11, true, true},
- {'p',0x5622, false, true},
- {'q',0x5622, true, true},
- {'u',0xAC44, true, true}
-};
-
-RawZorkStream::RawZorkStream(uint32 rate, bool stereo, DisposeAfterUse::Flag disposeStream, Common::SeekableReadStream *stream)
- : _rate(rate),
- _stereo(0),
- _stream(stream, disposeStream),
- _endOfData(false) {
+const int16 RawChunkStream::_stepAdjustmentTable[8] = { -1, -1, -1, 1, 4, 7, 10, 12};
+
+const int32 RawChunkStream::_amplitudeLookupTable[89] = {0x0007, 0x0008, 0x0009, 0x000A, 0x000B, 0x000C, 0x000D, 0x000E,
+ 0x0010, 0x0011, 0x0013, 0x0015, 0x0017, 0x0019, 0x001C, 0x001F,
+ 0x0022, 0x0025, 0x0029, 0x002D, 0x0032, 0x0037, 0x003C, 0x0042,
+ 0x0049, 0x0050, 0x0058, 0x0061, 0x006B, 0x0076, 0x0082, 0x008F,
+ 0x009D, 0x00AD, 0x00BE, 0x00D1, 0x00E6, 0x00FD, 0x0117, 0x0133,
+ 0x0151, 0x0173, 0x0198, 0x01C1, 0x01EE, 0x0220, 0x0256, 0x0292,
+ 0x02D4, 0x031C, 0x036C, 0x03C3, 0x0424, 0x048E, 0x0502, 0x0583,
+ 0x0610, 0x06AB, 0x0756, 0x0812, 0x08E0, 0x09C3, 0x0ABD, 0x0BD0,
+ 0x0CFF, 0x0E4C, 0x0FBA, 0x114C, 0x1307, 0x14EE, 0x1706, 0x1954,
+ 0x1BDC, 0x1EA5, 0x21B6, 0x2515, 0x28CA, 0x2CDF, 0x315B, 0x364B,
+ 0x3BB9, 0x41B2, 0x4844, 0x4F7E, 0x5771, 0x602F, 0x69CE, 0x7462, 0x7FFF
+ };
+
+RawChunkStream::RawChunkStream(bool stereo) {
if (stereo)
_stereo = 1;
+ else
+ _stereo = 0;
+
+ init();
+}
+void RawChunkStream::init() {
_lastSample[0].index = 0;
_lastSample[0].sample = 0;
_lastSample[1].index = 0;
_lastSample[1].sample = 0;
+}
- // Calculate the total playtime of the stream
- if (stereo)
- _playtime = Audio::Timestamp(0, _stream->size() / 2, rate);
- else
- _playtime = Audio::Timestamp(0, _stream->size(), rate);
+RawChunkStream::RawChunk RawChunkStream::readNextChunk(Common::SeekableReadStream *stream) {
+ RawChunk tmp;
+ tmp.size = 0;
+ tmp.data = NULL;
+
+ if (!stream || stream->size() == 0 || stream->eos())
+ return tmp;
+
+ tmp.size = (stream->size() - stream->pos()) * 2;
+ tmp.data = (int16 *)calloc(tmp.size, 1);
+
+ readBuffer(tmp.data, stream, stream->size() - stream->pos());
+
+ return tmp;
}
-int RawZorkStream::readBuffer(int16 *buffer, const int numSamples) {
- int bytesRead = 0;
+int RawChunkStream::readBuffer(int16 *buffer, Common::SeekableReadStream *stream, const int numSamples) {
+ int32 bytesRead = 0;
// 0: Left, 1: Right
uint channel = 0;
while (bytesRead < numSamples) {
- byte encodedSample = _stream->readByte();
- if (_stream->eos()) {
- _endOfData = true;
+ byte encodedSample = stream->readByte();
+ if (stream->eos()) {
return bytesRead;
}
bytesRead++;
@@ -140,6 +133,90 @@ int RawZorkStream::readBuffer(int16 *buffer, const int numSamples) {
// Increment and wrap the channel
channel = (channel + 1) & _stereo;
}
+ return bytesRead;
+}
+
+const SoundParams RawZorkStream::_zNemSoundParamLookupTable[32] = {{'0', 0x1F40, false, false, false},
+ {'1', 0x1F40, true, false, false},
+ {'2', 0x1F40, false, false, true},
+ {'3', 0x1F40, true, false, true},
+ {'4', 0x2B11, false, false, false},
+ {'5', 0x2B11, true, false, false},
+ {'6', 0x2B11, false, false, true},
+ {'7', 0x2B11, true, false, true},
+ {'8', 0x5622, false, false, false},
+ {'9', 0x5622, true, false, false},
+ {'a', 0x5622, false, false, true},
+ {'b', 0x5622, true, false, true},
+ {'c', 0xAC44, false, false, false},
+ {'d', 0xAC44, true, false, false},
+ {'e', 0xAC44, false, false, true},
+ {'f', 0xAC44, true, false, true},
+ {'g', 0x1F40, false, true, false},
+ {'h', 0x1F40, true, true, false},
+ {'j', 0x1F40, false, true, true},
+ {'k', 0x1F40, true, true, true},
+ {'l', 0x2B11, false, true, false},
+ {'m', 0x2B11, true, true, false},
+ {'n', 0x2B11, false, true, true},
+ {'p', 0x2B11, true, true, true},
+ {'q', 0x5622, false, true, false},
+ {'r', 0x5622, true, true, false},
+ {'s', 0x5622, false, true, true},
+ {'t', 0x5622, true, true, true},
+ {'u', 0xAC44, false, true, false},
+ {'v', 0xAC44, true, true, false},
+ {'w', 0xAC44, false, true, true},
+ {'x', 0xAC44, true, true, true}
+};
+
+const SoundParams RawZorkStream::_zgiSoundParamLookupTable[24] = {{'4', 0x2B11, false, false, false},
+ {'5', 0x2B11, true, false, false},
+ {'6', 0x2B11, false, false, true},
+ {'7', 0x2B11, true, false, true},
+ {'8', 0x5622, false, false, false},
+ {'9', 0x5622, true, false, false},
+ {'a', 0x5622, false, false, true},
+ {'b', 0x5622, true, false, true},
+ {'c', 0xAC44, false, false, false},
+ {'d', 0xAC44, true, false, false},
+ {'e', 0xAC44, false, false, true},
+ {'f', 0xAC44, true, false, true},
+ {'g', 0x2B11, false, true, false},
+ {'h', 0x2B11, true, true, false},
+ {'j', 0x2B11, false, true, true},
+ {'k', 0x2B11, true, true, true},
+ {'m', 0x5622, false, true, false},
+ {'n', 0x5622, true, true, false},
+ {'p', 0x5622, false, true, true},
+ {'q', 0x5622, true, true, true},
+ {'r', 0xAC44, false, true, false},
+ {'s', 0xAC44, true, true, false},
+ {'t', 0xAC44, false, true, true},
+ {'u', 0xAC44, true, true, true}
+};
+
+RawZorkStream::RawZorkStream(uint32 rate, bool stereo, DisposeAfterUse::Flag disposeStream, Common::SeekableReadStream *stream)
+ : _rate(rate),
+ _stereo(0),
+ _stream(stream, disposeStream),
+ _endOfData(false),
+ _streamReader(stereo) {
+ if (stereo)
+ _stereo = 1;
+
+ // Calculate the total playtime of the stream
+ if (stereo)
+ _playtime = Audio::Timestamp(0, _stream->size() / 2, rate);
+ else
+ _playtime = Audio::Timestamp(0, _stream->size(), rate);
+}
+
+int RawZorkStream::readBuffer(int16 *buffer, const int numSamples) {
+ int32 bytesRead = _streamReader.readBuffer(buffer, _stream.get(), numSamples);
+
+ if (_stream->eos())
+ _endOfData = true;
return bytesRead;
}
@@ -148,69 +225,62 @@ bool RawZorkStream::rewind() {
_stream->seek(0, 0);
_stream->clearErr();
_endOfData = false;
- _lastSample[0].index = 0;
- _lastSample[0].sample = 0;
- _lastSample[1].index = 0;
- _lastSample[1].sample = 0;
+ _streamReader.init();
return true;
}
Audio::RewindableAudioStream *makeRawZorkStream(Common::SeekableReadStream *stream,
- int rate,
- bool stereo,
- DisposeAfterUse::Flag disposeAfterUse) {
+ int rate,
+ bool stereo,
+ DisposeAfterUse::Flag disposeAfterUse) {
if (stereo)
assert(stream->size() % 2 == 0);
return new RawZorkStream(rate, stereo, disposeAfterUse, stream);
}
-Audio::RewindableAudioStream *makeRawZorkStream(const byte *buffer, uint32 size,
- int rate,
- bool stereo,
- DisposeAfterUse::Flag disposeAfterUse) {
- return makeRawZorkStream(new Common::MemoryReadStream(buffer, size, disposeAfterUse), rate, stereo, DisposeAfterUse::YES);
-}
-
Audio::RewindableAudioStream *makeRawZorkStream(const Common::String &filePath, ZVision *engine) {
Common::File *file = new Common::File();
- assert(file->open(filePath));
+ if (!engine->getSearchManager()->openFile(*file, filePath))
+ error("File not found: %s", filePath.c_str());
+
+ // Get the file name
+ Common::StringTokenizer tokenizer(filePath, "/\\");
+ Common::String fileName;
+ while (!tokenizer.empty()) {
+ fileName = tokenizer.nextToken();
+ }
- Common::String fileName = getFileName(filePath);
fileName.toLowercase();
- SoundParams soundParams = { ' ', 0, false, false };
- bool foundParams = false;
- char fileIdentifier = (engine->getGameId() == GID_NEMESIS) ? fileName[6] : fileName[7];
+ const SoundParams *soundParams = NULL;
if (engine->getGameId() == GID_NEMESIS) {
- for (uint i = 0; i < ARRAYSIZE(RawZorkStream::_zNemSoundParamLookupTable); ++i) {
- if (RawZorkStream::_zNemSoundParamLookupTable[i].identifier == fileIdentifier) {
- soundParams = RawZorkStream::_zNemSoundParamLookupTable[i];
- foundParams = true;
- }
+ for (int i = 0; i < 32; ++i) {
+ if (RawZorkStream::_zNemSoundParamLookupTable[i].identifier == (fileName[6]))
+ soundParams = &RawZorkStream::_zNemSoundParamLookupTable[i];
}
} else if (engine->getGameId() == GID_GRANDINQUISITOR) {
- for (uint i = 0; i < ARRAYSIZE(RawZorkStream::_zgiSoundParamLookupTable); ++i) {
- if (RawZorkStream::_zgiSoundParamLookupTable[i].identifier == fileIdentifier) {
- soundParams = RawZorkStream::_zgiSoundParamLookupTable[i];
- foundParams = true;
- }
+ for (int i = 0; i < 24; ++i) {
+ if (RawZorkStream::_zgiSoundParamLookupTable[i].identifier == (fileName[7]))
+ soundParams = &RawZorkStream::_zgiSoundParamLookupTable[i];
}
}
- if (!foundParams)
- error("Unable to find sound params for file '%s'. File identifier is '%c'", filePath.c_str(), fileIdentifier);
+ if (soundParams == NULL)
+ return NULL;
- if (soundParams.packed) {
- return makeRawZorkStream(wrapBufferedSeekableReadStream(file, 2048, DisposeAfterUse::YES), soundParams.rate, soundParams.stereo, DisposeAfterUse::YES);
+ if (soundParams->packed) {
+ return makeRawZorkStream(wrapBufferedSeekableReadStream(file, 2048, DisposeAfterUse::YES), soundParams->rate, soundParams->stereo, DisposeAfterUse::YES);
} else {
byte flags = 0;
- if (soundParams.stereo)
+ if (soundParams->bits16)
+ flags |= Audio::FLAG_16BITS | Audio::FLAG_LITTLE_ENDIAN;
+ if (soundParams->stereo)
flags |= Audio::FLAG_STEREO;
- return Audio::makeRawStream(file, soundParams.rate, flags, DisposeAfterUse::YES);
+ return Audio::makeRawStream(file, soundParams->rate, flags, DisposeAfterUse::YES);
}
}
diff --git a/engines/zvision/sound/zork_raw.h b/engines/zvision/sound/zork_raw.h
index ef98e3e1ef..892bad4d5f 100644
--- a/engines/zvision/sound/zork_raw.h
+++ b/engines/zvision/sound/zork_raw.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.
@@ -25,7 +25,6 @@
#include "audio/audiostream.h"
-
namespace Common {
class SeekableReadStream;
}
@@ -39,27 +38,19 @@ struct SoundParams {
uint32 rate;
bool stereo;
bool packed;
+ bool bits16;
};
/**
- * This is a stream, which allows for playing raw ADPCM data from a stream.
+ * This is a ADPCM stream-reader, this class holds context for multi-chunk reading and no buffers.
*/
-class RawZorkStream : public Audio::RewindableAudioStream {
+class RawChunkStream {
public:
- RawZorkStream(uint32 rate, bool stereo, DisposeAfterUse::Flag disposeStream, Common::SeekableReadStream *stream);
+ RawChunkStream(bool stereo);
- ~RawZorkStream() {
+ ~RawChunkStream() {
}
-
-public:
- static const SoundParams _zNemSoundParamLookupTable[6];
- static const SoundParams _zgiSoundParamLookupTable[5];
-
private:
- const int _rate; // Sample rate of stream
- Audio::Timestamp _playtime; // Calculated total play time
- Common::DisposablePtr<Common::SeekableReadStream> _stream; // Stream to read data from
- bool _endOfData; // Whether the stream end has been reached
uint _stereo;
/**
@@ -75,30 +66,61 @@ private:
static const int32 _amplitudeLookupTable[89];
public:
- int readBuffer(int16 *buffer, const int numSamples);
- bool isStereo() const { return true; }
- bool endOfData() const { return _endOfData; }
+ struct RawChunk {
+ int16 *data;
+ uint32 size;
+ };
- int getRate() const { return _rate; }
- Audio::Timestamp getLength() const { return _playtime; }
-
- bool rewind();
+ void init();
+ //Read next audio portion in new stream (needed for avi), return structure with buffer
+ RawChunk readNextChunk(Common::SeekableReadStream *stream);
+ //Read numSamples from stream to buffer
+ int readBuffer(int16 *buffer, Common::SeekableReadStream *stream, const int numSamples);
};
/**
- * Creates an audio stream, which plays from the given buffer.
- *
- * @param buffer Buffer to play from.
- * @param size Size of the buffer in bytes.
- * @param rate Rate of the sound data.
- * @param dispose AfterUse Whether to free the buffer after use (with free!).
- * @return The new SeekableAudioStream (or 0 on failure).
+ * This is a stream, which allows for playing raw ADPCM data from a stream.
*/
-Audio::RewindableAudioStream *makeRawZorkStream(const byte *buffer, uint32 size,
- int rate,
- bool stereo,
- DisposeAfterUse::Flag disposeAfterUse = DisposeAfterUse::YES);
+class RawZorkStream : public Audio::RewindableAudioStream {
+public:
+ RawZorkStream(uint32 rate, bool stereo, DisposeAfterUse::Flag disposeStream, Common::SeekableReadStream *stream);
+
+ ~RawZorkStream() {
+ }
+
+public:
+ static const SoundParams _zNemSoundParamLookupTable[32];
+ static const SoundParams _zgiSoundParamLookupTable[24];
+
+private:
+ const int _rate; // Sample rate of stream
+ Audio::Timestamp _playtime; // Calculated total play time
+ Common::DisposablePtr<Common::SeekableReadStream> _stream; // Stream to read data from
+ bool _endOfData; // Whether the stream end has been reached
+ uint _stereo;
+
+ RawChunkStream _streamReader;
+
+public:
+ int readBuffer(int16 *buffer, const int numSamples);
+
+ bool isStereo() const {
+ return _stereo;
+ }
+ bool endOfData() const {
+ return _endOfData;
+ }
+
+ int getRate() const {
+ return _rate;
+ }
+ Audio::Timestamp getLength() const {
+ return _playtime;
+ }
+
+ bool rewind();
+};
/**
* Creates an audio stream, which plays from the given stream.
@@ -109,9 +131,9 @@ Audio::RewindableAudioStream *makeRawZorkStream(const byte *buffer, uint32 size,
* @return The new SeekableAudioStream (or 0 on failure).
*/
Audio::RewindableAudioStream *makeRawZorkStream(Common::SeekableReadStream *stream,
- int rate,
- bool stereo,
- DisposeAfterUse::Flag disposeAfterUse = DisposeAfterUse::YES);
+ int rate,
+ bool stereo,
+ DisposeAfterUse::Flag disposeAfterUse = DisposeAfterUse::YES);
Audio::RewindableAudioStream *makeRawZorkStream(const Common::String &filePath, ZVision *engine);
diff --git a/engines/zvision/strings/string_manager.cpp b/engines/zvision/strings/string_manager.cpp
deleted file mode 100644
index 22331d8a24..0000000000
--- a/engines/zvision/strings/string_manager.cpp
+++ /dev/null
@@ -1,255 +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 "common/scummsys.h"
-
-#include "zvision/strings/string_manager.h"
-
-#include "zvision/fonts/truetype_font.h"
-
-#include "common/file.h"
-#include "common/tokenizer.h"
-#include "common/debug.h"
-
-#include "graphics/fontman.h"
-#include "graphics/colormasks.h"
-
-
-namespace ZVision {
-
-StringManager::StringManager(ZVision *engine)
- : _engine(engine) {
-}
-
-StringManager::~StringManager() {
- for (Common::HashMap<Common::String, TruetypeFont *>::iterator iter = _fonts.begin(); iter != _fonts.end(); ++iter) {
- delete iter->_value;
- }
-}
-
-void StringManager::initialize(ZVisionGameId gameId) {
- if (gameId == GID_NEMESIS) {
- // TODO: Check this hardcoded filename against all versions of Nemesis
- parseStrFile("nemesis.str");
- } else if (gameId == GID_GRANDINQUISITOR) {
- // TODO: Check this hardcoded filename against all versions of Grand Inquisitor
- parseStrFile("inquis.str");
- }
-}
-
-void StringManager::parseStrFile(const Common::String &fileName) {
- Common::File file;
- if (!file.open(fileName)) {
- warning("%s does not exist. String parsing failed", fileName.c_str());
- return;
- }
-
- uint lineNumber = 0;
- while (!file.eos()) {
- _lastStyle.align = Graphics::kTextAlignLeft;
- _lastStyle.color = 0;
- _lastStyle.font = nullptr;
-
- Common::String asciiLine = readWideLine(file);
- if (asciiLine.empty()) {
- continue;
- }
-
- char tagString[150];
- uint tagStringCursor = 0;
- char textString[150];
- uint textStringCursor = 0;
- bool inTag = false;
-
- for (uint i = 0; i < asciiLine.size(); ++i) {
- switch (asciiLine[i]) {
- case '<':
- inTag = true;
- if (!_inGameText[lineNumber].fragments.empty()) {
- _inGameText[lineNumber].fragments.back().text = Common::String(textString, textStringCursor);
- textStringCursor = 0;
- }
- break;
- case '>':
- inTag = false;
- parseTag(Common::String(tagString, tagStringCursor), lineNumber);
- tagStringCursor = 0;
- break;
- default:
- if (inTag) {
- tagString[tagStringCursor] = asciiLine[i];
- tagStringCursor++;
- } else {
- textString[textStringCursor] = asciiLine[i];
- textStringCursor++;
- }
- break;
- }
- }
-
- if (textStringCursor > 0) {
- _inGameText[lineNumber].fragments.back().text = Common::String(textString, textStringCursor);
- }
-
- lineNumber++;
- assert(lineNumber <= NUM_TEXT_LINES);
- }
-}
-
-void StringManager::parseTag(const Common::String &tagString, uint lineNumber) {
- Common::StringTokenizer tokenizer(tagString);
-
- Common::String token = tokenizer.nextToken();
-
- Common::String fontName;
- bool bold = false;
- Graphics::TextAlign align = _lastStyle.align;
- int point = _lastStyle.font != nullptr ? _lastStyle.font->_fontHeight : 12;
- int red = 0;
- int green = 0;
- int blue = 0;
-
- while (!token.empty()) {
- if (token.matchString("font", true)) {
- fontName = tokenizer.nextToken();
- } else if (token.matchString("bold", true)) {
- token = tokenizer.nextToken();
- if (token.matchString("on", false)) {
- bold = true;
- }
- } else if (token.matchString("justify", true)) {
- token = tokenizer.nextToken();
- if (token.matchString("center", false)) {
- align = Graphics::kTextAlignCenter;
- } else if (token.matchString("right", false)) {
- align = Graphics::kTextAlignRight;
- }
- } else if (token.matchString("point", true)) {
- point = atoi(tokenizer.nextToken().c_str());
- } else if (token.matchString("red", true)) {
- red = atoi(tokenizer.nextToken().c_str());
- } else if (token.matchString("green", true)) {
- green = atoi(tokenizer.nextToken().c_str());
- } else if (token.matchString("blue", true)) {
- blue = atoi(tokenizer.nextToken().c_str());
- }
-
- token = tokenizer.nextToken();
- }
-
- TextFragment fragment;
-
- if (fontName.empty()) {
- fragment.style.font = _lastStyle.font;
- } else {
- Common::String newFontName;
- if (fontName.matchString("*times new roman*", true)) {
- if (bold) {
- newFontName = "timesbd.ttf";
- } else {
- newFontName = "times.ttf";
- }
- } else if (fontName.matchString("*courier new*", true)) {
- if (bold) {
- newFontName = "courbd.ttf";
- } else {
- newFontName = "cour.ttf";
- }
- } else if (fontName.matchString("*century schoolbook*", true)) {
- if (bold) {
- newFontName = "censcbkbd.ttf";
- } else {
- newFontName = "censcbk.ttf";
- }
- } else if (fontName.matchString("*garamond*", true)) {
- if (bold) {
- newFontName = "garabd.ttf";
- } else {
- newFontName = "gara.ttf";
- }
- } else {
- debug("Could not identify font: %s. Reverting to Arial", fontName.c_str());
- if (bold) {
- newFontName = "zorknorm.ttf";
- } else {
- newFontName = "arial.ttf";
- }
- }
-
- Common::String fontKey = Common::String::format("%s-%d", newFontName.c_str(), point);
- if (_fonts.contains(fontKey)) {
- fragment.style.font = _fonts[fontKey];
- } else {
- fragment.style.font = new TruetypeFont(_engine, point);
- fragment.style.font->loadFile(newFontName);
- _fonts[fontKey] = fragment.style.font;
- }
- }
-
- fragment.style.align = align;
- fragment.style.color = Graphics::ARGBToColor<Graphics::ColorMasks<565> >(0, red, green, blue);
- _inGameText[lineNumber].fragments.push_back(fragment);
-
- _lastStyle = fragment.style;
-}
-
-Common::String StringManager::readWideLine(Common::SeekableReadStream &stream) {
- Common::String asciiString;
-
- // Don't spam the user with warnings about UTF-16 support.
- // Just do one warning per String
- bool charOverflowWarning = false;
-
- uint16 value = stream.readUint16LE();
- while (!stream.eos()) {
- // Check for CRLF
- if (value == 0x0A0D) {
- // Read in the extra NULL char
- stream.readByte(); // \0
- // End of the line. Break
- break;
- }
-
- // Crush each octet pair to a single octet with a simple cast
- if (value > 255) {
- charOverflowWarning = true;
- value = '?';
- }
- char charValue = (char)value;
-
- asciiString += charValue;
-
- value = stream.readUint16LE();
- }
-
- if (charOverflowWarning) {
- warning("UTF-16 is not supported. Characters greater than 255 are replaced with '?'");
- }
-
- return asciiString;
-}
-
-StringManager::TextStyle StringManager::getTextStyle(uint stringNumber) {
- return _inGameText[stringNumber].fragments.front().style;
-}
-
-} // End of namespace ZVision
diff --git a/engines/zvision/text/string_manager.cpp b/engines/zvision/text/string_manager.cpp
new file mode 100644
index 0000000000..6b870d0b8d
--- /dev/null
+++ b/engines/zvision/text/string_manager.cpp
@@ -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.
+ *
+ */
+
+#include "common/scummsys.h"
+#include "common/file.h"
+#include "common/tokenizer.h"
+#include "common/debug.h"
+#include "graphics/fontman.h"
+#include "graphics/colormasks.h"
+
+#include "zvision/zvision.h"
+#include "zvision/file/search_manager.h"
+#include "zvision/text/string_manager.h"
+#include "zvision/text/text.h"
+
+namespace ZVision {
+
+StringManager::StringManager(ZVision *engine)
+ : _engine(engine) {
+}
+
+StringManager::~StringManager() {
+
+}
+
+void StringManager::initialize(ZVisionGameId gameId) {
+ if (gameId == GID_NEMESIS)
+ loadStrFile("nemesis.str");
+ else if (gameId == GID_GRANDINQUISITOR)
+ loadStrFile("inquis.str");
+}
+
+void StringManager::loadStrFile(const Common::String &fileName) {
+ Common::File file;
+ if (!_engine->getSearchManager()->openFile(file, fileName)) {
+ error("%s does not exist. String parsing failed", fileName.c_str());
+ }
+
+ uint lineNumber = 0;
+ while (!file.eos()) {
+ _lines[lineNumber] = readWideLine(file);
+
+ lineNumber++;
+ assert(lineNumber <= NUM_TEXT_LINES);
+ }
+}
+
+const Common::String StringManager::getTextLine(uint stringNumber) {
+ return _lines[stringNumber];
+}
+
+} // End of namespace ZVision
diff --git a/engines/zvision/strings/string_manager.h b/engines/zvision/text/string_manager.h
index af8324b890..f4564ee1ec 100644
--- a/engines/zvision/strings/string_manager.h
+++ b/engines/zvision/text/string_manager.h
@@ -24,8 +24,7 @@
#define ZVISION_STRING_MANAGER_H
#include "zvision/detection.h"
-#include "zvision/fonts/truetype_font.h"
-
+#include "zvision/text/truetype_font.h"
namespace Graphics {
class FontManager;
@@ -41,42 +40,28 @@ public:
~StringManager();
public:
- struct TextStyle {
- TruetypeFont *font;
- uint16 color; // In RBG 565
- Graphics::TextAlign align;
- };
-
- struct TextFragment {
- TextStyle style;
- Common::String text;
+ enum {
+ ZVISION_STR_SAVEEXIST = 23,
+ ZVISION_STR_SAVED = 4,
+ ZVISION_STR_SAVEEMPTY = 21,
+ ZVISION_STR_EXITPROMT = 6
};
private:
- struct InGameText {
- Common::List<TextFragment> fragments;
- };
-
enum {
NUM_TEXT_LINES = 56 // Max number of lines in a .str file. We hardcode this number because we know ZNem uses 42 strings and ZGI uses 56
};
private:
ZVision *_engine;
- InGameText _inGameText[NUM_TEXT_LINES];
- Common::HashMap<Common::String, TruetypeFont *> _fonts;
-
- TextStyle _lastStyle;
+ Common::String _lines[NUM_TEXT_LINES];
public:
void initialize(ZVisionGameId gameId);
- StringManager::TextStyle getTextStyle(uint stringNumber);
+ const Common::String getTextLine(uint stringNumber);
private:
- void parseStrFile(const Common::String &fileName);
- void parseTag(const Common::String &tagString, uint lineNumber);
-
- static Common::String readWideLine(Common::SeekableReadStream &stream);
+ void loadStrFile(const Common::String &fileName);
};
} // End of namespace ZVision
diff --git a/engines/zvision/text/subtitles.cpp b/engines/zvision/text/subtitles.cpp
new file mode 100644
index 0000000000..acf4c37c2f
--- /dev/null
+++ b/engines/zvision/text/subtitles.cpp
@@ -0,0 +1,108 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "zvision/graphics/render_manager.h"
+#include "zvision/text/subtitles.h"
+#include "zvision/file/search_manager.h"
+#include "zvision/text/text.h"
+
+namespace ZVision {
+
+Subtitle::Subtitle(ZVision *engine, const Common::String &subname) :
+ _engine(engine),
+ _areaId(-1),
+ _subId(-1) {
+ Common::File file;
+ if (_engine->getSearchManager()->openFile(file, subname)) {
+ while (!file.eos()) {
+ Common::String str = file.readLine();
+ if (str.lastChar() == '~')
+ str.deleteLastChar();
+
+ if (str.matchString("*Initialization*", true)) {
+ // Not used
+ } else if (str.matchString("*Rectangle*", true)) {
+ int32 x1, y1, x2, y2;
+ sscanf(str.c_str(), "%*[^:]:%d %d %d %d", &x1, &y1, &x2, &y2);
+ Common::Rect rct = Common::Rect(x1, y1, x2, y2);
+ _areaId = _engine->getRenderManager()->createSubArea(rct);
+ } else if (str.matchString("*TextFile*", true)) {
+ char filename[64];
+ sscanf(str.c_str(), "%*[^:]:%s", filename);
+ Common::File txt;
+ if (_engine->getSearchManager()->openFile(txt, filename)) {
+ while (!txt.eos()) {
+ Common::String txtline = readWideLine(txt);
+ sub curSubtitle;
+ curSubtitle.start = -1;
+ curSubtitle.stop = -1;
+ curSubtitle.subStr = txtline;
+
+ _subs.push_back(curSubtitle);
+ }
+ txt.close();
+ }
+ } else {
+ int32 st;
+ int32 en;
+ int32 sb;
+ if (sscanf(str.c_str(), "%*[^:]:(%d,%d)=%d", &st, &en, &sb) == 3) {
+ if (sb <= (int32)_subs.size()) {
+ _subs[sb].start = st;
+ _subs[sb].stop = en;
+ }
+ }
+ }
+ }
+ }
+}
+
+Subtitle::~Subtitle() {
+ if (_areaId != -1)
+ _engine->getRenderManager()->deleteSubArea(_areaId);
+
+ _subs.clear();
+}
+
+void Subtitle::process(int32 time) {
+ int16 j = -1;
+ for (uint16 i = 0; i < _subs.size(); i++)
+ if (time >= _subs[i].start && time <= _subs[i].stop) {
+ j = i;
+ break;
+ }
+
+ if (j == -1 && _subId != -1) {
+ if (_areaId != -1)
+ _engine->getRenderManager()->updateSubArea(_areaId, "");
+ _subId = -1;
+ }
+
+ if (j != -1 && j != _subId) {
+ if (_subs[j].subStr.size())
+ if (_areaId != -1)
+ _engine->getRenderManager()->updateSubArea(_areaId, _subs[j].subStr);
+ _subId = j;
+ }
+}
+
+} // End of namespace ZVision
diff --git a/engines/zvision/subtitles/subtitles.h b/engines/zvision/text/subtitles.h
index 776ddd3a97..c3da6583a4 100644
--- a/engines/zvision/subtitles/subtitles.h
+++ b/engines/zvision/text/subtitles.h
@@ -23,6 +23,32 @@
#ifndef ZVISION_SUBTITLES_H
#define ZVISION_SUBTITLES_H
-// TODO: Implement Subtitles
+#include "zvision/zvision.h"
+
+namespace ZVision {
+
+class ZVision;
+
+class Subtitle {
+public:
+ Subtitle(ZVision *engine, const Common::String &subname);
+ ~Subtitle();
+
+ void process(int32 time);
+private:
+ ZVision *_engine;
+ int32 _areaId;
+ int16 _subId;
+
+ struct sub {
+ int start;
+ int stop;
+ Common::String subStr;
+ };
+
+ Common::Array<sub> _subs;
+};
+
+}
#endif
diff --git a/engines/zvision/text/text.cpp b/engines/zvision/text/text.cpp
new file mode 100644
index 0000000000..a5ed044424
--- /dev/null
+++ b/engines/zvision/text/text.cpp
@@ -0,0 +1,557 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public 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/file.h"
+#include "common/tokenizer.h"
+#include "common/debug.h"
+#include "common/rect.h"
+#include "graphics/fontman.h"
+#include "graphics/colormasks.h"
+#include "graphics/surface.h"
+#include "graphics/font.h"
+#include "graphics/fonts/ttf.h"
+
+#include "zvision/text/text.h"
+#include "zvision/graphics/render_manager.h"
+#include "zvision/text/truetype_font.h"
+#include "zvision/scripting/script_manager.h"
+
+namespace ZVision {
+
+cTxtStyle::cTxtStyle() {
+ _fontname = "Arial";
+ _blue = 255;
+ _green = 255;
+ _red = 255;
+ _bold = false;
+#if 0
+ _newline = false;
+ _escapement = 0;
+#endif
+ _italic = false;
+ _justify = TXT_JUSTIFY_LEFT;
+ _size = 12;
+#if 0
+ _skipcolor = false;
+#endif
+ _strikeout = false;
+ _underline = false;
+ _statebox = 0;
+ _sharp = false;
+}
+
+txtReturn cTxtStyle::parseStyle(const Common::String &strin, int16 ln) {
+ Common::String buf = Common::String(strin.c_str(), ln);
+
+ int8 retval = TXT_RET_NOTHING;
+
+ Common::StringTokenizer tokenizer(buf, " ");
+ Common::String token;
+
+ while (!tokenizer.empty()) {
+ token = tokenizer.nextToken();
+
+ if (token.matchString("font", true)) {
+ token = tokenizer.nextToken();
+ if (token[0] == '"') {
+ Common::String _tmp = Common::String(token.c_str() + 1);
+
+ while (token.lastChar() != '"' && !tokenizer.empty()) {
+ token = tokenizer.nextToken();
+ _tmp += " " + token;
+ }
+
+ if (_tmp.lastChar() == '"')
+ _tmp.deleteLastChar();
+
+ _fontname = _tmp;
+ } else {
+ if (!tokenizer.empty())
+ _fontname = token;
+ }
+ retval |= TXT_RET_FNTCHG;
+
+ } else if (token.matchString("blue", true)) {
+ if (!tokenizer.empty()) {
+ token = tokenizer.nextToken();
+ int32 tmp = atoi(token.c_str());
+ if (_blue != tmp) {
+ _blue = tmp;
+ retval |= TXT_RET_FNTSTL;
+ }
+ }
+ } else if (token.matchString("red", true)) {
+ if (!tokenizer.empty()) {
+ token = tokenizer.nextToken();
+ int32 tmp = atoi(token.c_str());
+ if (_red != tmp) {
+ _red = tmp;
+ retval |= TXT_RET_FNTSTL;
+ }
+ }
+ } else if (token.matchString("green", true)) {
+ if (!tokenizer.empty()) {
+ token = tokenizer.nextToken();
+ int32 tmp = atoi(token.c_str());
+ if (_green != tmp) {
+ _green = tmp;
+ retval |= TXT_RET_FNTSTL;
+ }
+ }
+ } else if (token.matchString("newline", true)) {
+#if 0
+ if ((retval & TXT_RET_NEWLN) == 0)
+ _newline = 0;
+
+ _newline++;
+#endif
+ retval |= TXT_RET_NEWLN;
+ } else if (token.matchString("point", true)) {
+ if (!tokenizer.empty()) {
+ token = tokenizer.nextToken();
+ int32 tmp = atoi(token.c_str());
+ if (_size != tmp) {
+ _size = tmp;
+ retval |= TXT_RET_FNTCHG;
+ }
+ }
+ } else if (token.matchString("escapement", true)) {
+ if (!tokenizer.empty()) {
+ token = tokenizer.nextToken();
+#if 0
+ int32 tmp = atoi(token.c_str());
+ _escapement = tmp;
+#endif
+ }
+ } else if (token.matchString("italic", true)) {
+ if (!tokenizer.empty()) {
+ token = tokenizer.nextToken();
+ if (token.matchString("on", true)) {
+ if (_italic != true) {
+ _italic = true;
+ retval |= TXT_RET_FNTSTL;
+ }
+ } else if (token.matchString("off", true)) {
+ if (_italic != false) {
+ _italic = false;
+ retval |= TXT_RET_FNTSTL;
+ }
+ }
+ }
+ } else if (token.matchString("underline", true)) {
+ if (!tokenizer.empty()) {
+ token = tokenizer.nextToken();
+ if (token.matchString("on", true)) {
+ if (_underline != true) {
+ _underline = true;
+ retval |= TXT_RET_FNTSTL;
+ }
+ } else if (token.matchString("off", true)) {
+ if (_underline != false) {
+ _underline = false;
+ retval |= TXT_RET_FNTSTL;
+ }
+ }
+ }
+ } else if (token.matchString("strikeout", true)) {
+ if (!tokenizer.empty()) {
+ token = tokenizer.nextToken();
+ if (token.matchString("on", true)) {
+ if (_strikeout != true) {
+ _strikeout = true;
+ retval |= TXT_RET_FNTSTL;
+ }
+ } else if (token.matchString("off", true)) {
+ if (_strikeout != false) {
+ _strikeout = false;
+ retval |= TXT_RET_FNTSTL;
+ }
+ }
+ }
+ } else if (token.matchString("bold", true)) {
+ if (!tokenizer.empty()) {
+ token = tokenizer.nextToken();
+ if (token.matchString("on", true)) {
+ if (_bold != true) {
+ _bold = true;
+ retval |= TXT_RET_FNTSTL;
+ }
+ } else if (token.matchString("off", true)) {
+ if (_bold != false) {
+ _bold = false;
+ retval |= TXT_RET_FNTSTL;
+ }
+ }
+ }
+ } else if (token.matchString("skipcolor", true)) {
+ if (!tokenizer.empty()) {
+ token = tokenizer.nextToken();
+#if 0
+ if (token.matchString("on", true)) {
+ _skipcolor = true;
+ } else if (token.matchString("off", true)) {
+ _skipcolor = false;
+ }
+#endif
+ }
+ } else if (token.matchString("image", true)) {
+ // Not used
+ } else if (token.matchString("statebox", true)) {
+ if (!tokenizer.empty()) {
+ token = tokenizer.nextToken();
+ _statebox = atoi(token.c_str());
+ retval |= TXT_RET_HASSTBOX;
+ }
+ } else if (token.matchString("justify", true)) {
+ if (!tokenizer.empty()) {
+ token = tokenizer.nextToken();
+ if (token.matchString("center", true))
+ _justify = TXT_JUSTIFY_CENTER;
+ else if (token.matchString("left", true))
+ _justify = TXT_JUSTIFY_LEFT;
+ else if (token.matchString("right", true))
+ _justify = TXT_JUSTIFY_RIGHT;
+ }
+ }
+ }
+ return (txtReturn)retval;
+}
+
+void cTxtStyle::readAllStyle(const Common::String &txt) {
+ int16 startTextPosition = -1;
+ int16 endTextPosition = -1;
+
+ for (uint16 i = 0; i < txt.size(); i++) {
+ if (txt[i] == '<')
+ startTextPosition = i;
+ else if (txt[i] == '>') {
+ endTextPosition = i;
+ if (startTextPosition != -1)
+ if ((endTextPosition - startTextPosition - 1) > 0)
+ parseStyle(Common::String(txt.c_str() + startTextPosition + 1), endTextPosition - startTextPosition - 1);
+ }
+
+ }
+}
+
+void cTxtStyle::setFontStyle(StyledTTFont &font) {
+ uint tempStyle = 0;
+
+ if (_bold)
+ tempStyle |= StyledTTFont::STTF_BOLD;
+
+ if (_italic)
+ tempStyle |= StyledTTFont::STTF_ITALIC;
+
+ if (_underline)
+ tempStyle |= StyledTTFont::STTF_UNDERLINE;
+
+ if (_strikeout)
+ tempStyle |= StyledTTFont::STTF_STRIKEOUT;
+
+ if (_sharp)
+ tempStyle |= StyledTTFont::STTF_SHARP;
+
+ font.setStyle(tempStyle);
+}
+
+void cTxtStyle::setFont(StyledTTFont &font) {
+ uint tempStyle = 0;
+
+ if (_bold)
+ tempStyle |= StyledTTFont::STTF_BOLD;
+
+ if (_italic)
+ tempStyle |= StyledTTFont::STTF_ITALIC;
+
+ if (_underline)
+ tempStyle |= StyledTTFont::STTF_UNDERLINE;
+
+ if (_strikeout)
+ tempStyle |= StyledTTFont::STTF_STRIKEOUT;
+
+ if (_sharp)
+ tempStyle |= StyledTTFont::STTF_SHARP;
+
+ font.loadFont(_fontname, _size, tempStyle);
+}
+
+Graphics::Surface *TextRenderer::render(StyledTTFont &fnt, const Common::String &txt, cTxtStyle &style) {
+ style.setFontStyle(fnt);
+ uint32 clr = _engine->_resourcePixelFormat.RGBToColor(style._red, style._green, style._blue);
+ return fnt.renderSolidText(txt, clr);
+}
+
+void TextRenderer::drawTxtWithJustify(const Common::String &txt, StyledTTFont &fnt, uint32 color, Graphics::Surface &dst, int lineY, txtJustify justify) {
+ if (justify == TXT_JUSTIFY_LEFT)
+ fnt.drawString(&dst, txt, 0, lineY, dst.w, color, Graphics::kTextAlignLeft);
+ else if (justify == TXT_JUSTIFY_CENTER)
+ fnt.drawString(&dst, txt, 0, lineY, dst.w, color, Graphics::kTextAlignCenter);
+ else if (justify == TXT_JUSTIFY_RIGHT)
+ fnt.drawString(&dst, txt, 0, lineY, dst.w, color, Graphics::kTextAlignRight);
+}
+
+int32 TextRenderer::drawTxt(const Common::String &txt, cTxtStyle &fontStyle, Graphics::Surface &dst) {
+ StyledTTFont font(_engine);
+ fontStyle.setFont(font);
+
+ dst.fillRect(Common::Rect(dst.w, dst.h), 0);
+
+ uint32 clr = _engine->_resourcePixelFormat.RGBToColor(fontStyle._red, fontStyle._green, fontStyle._blue);
+
+ int16 w;
+
+ w = font.getStringWidth(txt);
+
+ drawTxtWithJustify(txt, font, clr, dst, 0, fontStyle._justify);
+
+ return w;
+}
+
+void TextRenderer::drawTxtInOneLine(const Common::String &text, Graphics::Surface &dst) {
+ const int16 TXT_CFG_TEXTURES_LINES = 256; // For now I don't want remake it
+ const int TXT_CFG_TEXTURES_PER_LINE = 6;
+ cTxtStyle style, style2;
+ int16 startTextPosition = -1;
+ int16 endTextPosition = -1;
+ int16 i = 0;
+ int16 dx = 0, dy = 0;
+ int16 textPixelWidth;
+ int16 textPosition = 0;
+ Common::String buf;
+ Common::String buf2;
+
+ Graphics::Surface *TxtSurfaces[TXT_CFG_TEXTURES_LINES][TXT_CFG_TEXTURES_PER_LINE];
+ int16 currentline = 0, currentlineitm = 0;
+
+ int TxtJustify[TXT_CFG_TEXTURES_LINES];
+ int TxtPoint[TXT_CFG_TEXTURES_LINES];
+
+ for (int16 k = 0; k < TXT_CFG_TEXTURES_LINES; k++) {
+ TxtPoint[k] = 0;
+ for (int j = 0; j < TXT_CFG_TEXTURES_PER_LINE; j++)
+ TxtSurfaces[k][j] = NULL;
+ }
+
+ int16 stringlen = text.size();
+
+ StyledTTFont font(_engine);
+
+ style.setFont(font);
+
+ int16 prevbufspace = 0, prevtxtspace = 0;
+
+ while (i < stringlen) {
+ TxtJustify[currentline] = style._justify;
+ if (text[i] == '<') {
+ int16 ret = 0;
+
+ startTextPosition = i;
+ while (i < stringlen && text[i] != '>')
+ i++;
+ endTextPosition = i;
+ if (startTextPosition != -1)
+ if ((endTextPosition - startTextPosition - 1) > 0) {
+ style2 = style;
+ ret = style.parseStyle(Common::String(text.c_str() + startTextPosition + 1), endTextPosition - startTextPosition - 1);
+ }
+
+ if (ret & (TXT_RET_FNTCHG | TXT_RET_FNTSTL | TXT_RET_NEWLN)) {
+ if (buf.size() > 0) {
+ textPixelWidth = font.getStringWidth(buf);
+
+ TxtSurfaces[currentline][currentlineitm] = render(font, buf, style2);
+ TxtPoint[currentline] = MAX(font.getFontHeight(), TxtPoint[currentline]);
+
+ currentlineitm++;
+
+ buf.clear();
+ prevbufspace = 0;
+ textPosition = 0;
+ dx += textPixelWidth;
+
+ }
+ if (ret & TXT_RET_FNTCHG) {
+ style.setFont(font);
+ }
+ if (ret & TXT_RET_FNTSTL)
+ style.setFontStyle(font);
+
+ if (ret & TXT_RET_NEWLN) {
+ currentline++;
+ currentlineitm = 0;
+ dx = 0;
+ }
+ }
+
+ if (ret & TXT_RET_HASSTBOX) {
+ Common::String buf3;
+ buf3 = Common::String::format("%d", _engine->getScriptManager()->getStateValue(style._statebox));
+ buf += buf3;
+ textPosition += buf3.size();
+ }
+
+ } else {
+
+ buf += text[i];
+ textPosition++;
+
+ if (text[i] == ' ') {
+ prevbufspace = textPosition - 1;
+ prevtxtspace = i;
+ }
+
+ if (font.isLoaded()) {
+ textPixelWidth = font.getStringWidth(buf);
+ if (textPixelWidth + dx > dst.w) {
+ if (prevbufspace == 0) {
+ prevtxtspace = i;
+ prevbufspace = textPosition - 1;
+ }
+ buf2 = Common::String(buf.c_str(), prevbufspace + 1);
+
+ if (buf2.size() > 0) {
+ TxtSurfaces[currentline][currentlineitm] = render(font, buf2, style);
+ TxtPoint[currentline] = MAX(font.getFontHeight(), TxtPoint[currentline]);
+ }
+
+ buf.clear();
+ i = prevtxtspace;
+ prevbufspace = 0;
+ textPosition = 0;
+ currentline++;
+ currentlineitm = 0;
+ dx = 0;
+ }
+ }
+ }
+ i++;
+ }
+
+ if (buf.size() > 0) {
+ TxtSurfaces[currentline][currentlineitm] = render(font, buf, style);
+ TxtPoint[currentline] = MAX(font.getFontHeight(), TxtPoint[currentline]);
+ }
+
+ dy = 0;
+ for (i = 0; i <= currentline; i++) {
+ int16 j = 0;
+ int16 width = 0;
+ while (TxtSurfaces[i][j] != NULL) {
+ width += TxtSurfaces[i][j]->w;
+ j++;
+ }
+ dx = 0;
+ Common::Rect empty;
+ for (int32 jj = 0; jj < j; jj++) {
+ if (TxtJustify[i] == TXT_JUSTIFY_LEFT)
+ _engine->getRenderManager()->blitSurfaceToSurface(*TxtSurfaces[i][jj], empty, dst, dx, dy + TxtPoint[i] - TxtSurfaces[i][jj]->h, 0);
+
+ else if (TxtJustify[i] == TXT_JUSTIFY_CENTER)
+ _engine->getRenderManager()->blitSurfaceToSurface(*TxtSurfaces[i][jj], empty, dst, ((dst.w - width) / 2) + dx, dy + TxtPoint[i] - TxtSurfaces[i][jj]->h, 0);
+
+ else if (TxtJustify[i] == TXT_JUSTIFY_RIGHT)
+ _engine->getRenderManager()->blitSurfaceToSurface(*TxtSurfaces[i][jj], empty, dst, dst.w - width + dx, dy + TxtPoint[i] - TxtSurfaces[i][jj]->h, 0);
+
+ dx += TxtSurfaces[i][jj]->w;
+ }
+
+ dy += TxtPoint[i];
+ }
+
+ for (i = 0; i < TXT_CFG_TEXTURES_LINES; i++)
+ for (int32 j = 0; j < TXT_CFG_TEXTURES_PER_LINE; j++)
+ if (TxtSurfaces[i][j] != NULL) {
+ TxtSurfaces[i][j]->free();
+ delete TxtSurfaces[i][j];
+ }
+}
+
+Common::String readWideLine(Common::SeekableReadStream &stream) {
+ Common::String asciiString;
+
+ while (!stream.eos()) {
+ uint32 value = stream.readUint16LE();
+ // Check for CRLF
+ if (value == 0x0A0D) {
+ // Read in the extra NULL char
+ stream.readByte(); // \0
+ // End of the line. Break
+ break;
+ }
+
+ // Crush each octet pair to a UTF-8 sequence
+ if (value < 0x80) {
+ asciiString += (char)(value & 0x7F);
+ } else if (value >= 0x80 && value < 0x800) {
+ asciiString += (char)(0xC0 | ((value >> 6) & 0x1F));
+ asciiString += (char)(0x80 | (value & 0x3F));
+ } else if (value >= 0x800 && value < 0x10000 && value != 0xCCCC) {
+ asciiString += (char)(0xE0 | ((value >> 12) & 0xF));
+ asciiString += (char)(0x80 | ((value >> 6) & 0x3F));
+ asciiString += (char)(0x80 | (value & 0x3F));
+ } else if (value == 0xCCCC) {
+ // Ignore, this character is used as newline sometimes
+ } else if (value >= 0x10000 && value < 0x200000) {
+ asciiString += (char)(0xF0);
+ asciiString += (char)(0x80 | ((value >> 12) & 0x3F));
+ asciiString += (char)(0x80 | ((value >> 6) & 0x3F));
+ asciiString += (char)(0x80 | (value & 0x3F));
+ }
+ }
+
+ return asciiString;
+}
+
+int8 getUtf8CharSize(char chr) {
+ if ((chr & 0x80) == 0)
+ return 1;
+ else if ((chr & 0xE0) == 0xC0)
+ return 2;
+ else if ((chr & 0xF0) == 0xE0)
+ return 3;
+ else if ((chr & 0xF8) == 0xF0)
+ return 4;
+ else if ((chr & 0xFC) == 0xF8)
+ return 5;
+ else if ((chr & 0xFE) == 0xFC)
+ return 6;
+
+ return 1;
+}
+
+uint16 readUtf8Char(const char *chr) {
+ uint16 result = 0;
+ if ((chr[0] & 0x80) == 0)
+ result = chr[0];
+ else if ((chr[0] & 0xE0) == 0xC0)
+ result = ((chr[0] & 0x1F) << 6) | (chr[1] & 0x3F);
+ else if ((chr[0] & 0xF0) == 0xE0)
+ result = ((chr[0] & 0x0F) << 12) | ((chr[1] & 0x3F) << 6) | (chr[2] & 0x3F);
+ else
+ result = chr[0];
+
+ return result;
+}
+
+} // End of namespace ZVision
diff --git a/engines/zvision/text/text.h b/engines/zvision/text/text.h
new file mode 100644
index 0000000000..c942b8141a
--- /dev/null
+++ b/engines/zvision/text/text.h
@@ -0,0 +1,99 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ *
+ */
+
+#ifndef ZVISION_TEXT_H
+#define ZVISION_TEXT_H
+
+#include "zvision/detection.h"
+#include "zvision/text/truetype_font.h"
+#include "zvision/zvision.h"
+
+namespace ZVision {
+
+class ZVision;
+
+enum txtJustify {
+ TXT_JUSTIFY_CENTER = 0,
+ TXT_JUSTIFY_LEFT = 1,
+ TXT_JUSTIFY_RIGHT = 2
+};
+
+enum txtReturn {
+ TXT_RET_NOTHING = 0x0,
+ TXT_RET_FNTCHG = 0x1,
+ TXT_RET_FNTSTL = 0x2,
+ TXT_RET_NEWLN = 0x4,
+ TXT_RET_HASSTBOX = 0x8
+};
+
+class cTxtStyle {
+public:
+ cTxtStyle();
+ txtReturn parseStyle(const Common::String &strin, int16 len);
+ void readAllStyle(const Common::String &txt);
+ void setFontStyle(StyledTTFont &font);
+ void setFont(StyledTTFont &font);
+
+public:
+ Common::String _fontname;
+ txtJustify _justify; // 0 - center, 1-left, 2-right
+ int16 _size;
+ uint8 _red; // 0-255
+ uint8 _green; // 0-255
+ uint8 _blue; // 0-255
+#if 0
+ int8 _newline;
+ int8 _escapement;
+#endif
+ bool _italic;
+ bool _bold;
+ bool _underline;
+ bool _strikeout;
+#if 0
+ bool _skipcolor;
+#endif
+ int32 _statebox;
+ bool _sharp;
+ // char image ??
+};
+
+class TextRenderer {
+public:
+ TextRenderer(ZVision *engine): _engine(engine) {};
+
+ void drawTxtWithJustify(const Common::String &txt, StyledTTFont &fnt, uint32 color, Graphics::Surface &dst, int lineY, txtJustify justify);
+ int32 drawTxt(const Common::String &txt, cTxtStyle &fontStyle, Graphics::Surface &dst);
+ Graphics::Surface *render(StyledTTFont &fnt, const Common::String &txt, cTxtStyle &style);
+ void drawTxtInOneLine(const Common::String &txt, Graphics::Surface &dst);
+
+private:
+ ZVision *_engine;
+};
+
+Common::String readWideLine(Common::SeekableReadStream &stream);
+int8 getUtf8CharSize(char chr);
+uint16 readUtf8Char(const char *chr);
+
+} // End of namespace ZVision
+
+#endif
diff --git a/engines/zvision/text/truetype_font.cpp b/engines/zvision/text/truetype_font.cpp
new file mode 100644
index 0000000000..622a02a6a8
--- /dev/null
+++ b/engines/zvision/text/truetype_font.cpp
@@ -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.
+ *
+ */
+
+#include "common/scummsys.h"
+#include "common/config-manager.h"
+#include "common/debug.h"
+#include "common/file.h"
+#include "common/system.h"
+#include "common/unzip.h"
+#include "graphics/font.h"
+#include "graphics/fonts/ttf.h"
+#include "graphics/surface.h"
+
+#include "zvision/zvision.h"
+#include "zvision/graphics/render_manager.h"
+#include "zvision/text/truetype_font.h"
+
+namespace ZVision {
+
+StyledTTFont::StyledTTFont(ZVision *engine) {
+ _engine = engine;
+ _style = 0;
+ _font = NULL;
+ _lineHeight = 0;
+}
+
+StyledTTFont::~StyledTTFont() {
+ if (_font)
+ delete _font;
+}
+
+bool StyledTTFont::loadFont(const Common::String &fontName, int32 point, uint style) {
+ _style = style;
+ return loadFont(fontName, point);
+}
+
+bool StyledTTFont::loadFont(const Common::String &fontName, int32 point) {
+ struct FontStyle {
+ const char *zorkFont;
+ const char *fontBase;
+ const char *freeFontBase;
+ const char *freeFontItalicName;
+ };
+
+ const FontStyle systemFonts[] = {
+ { "*times new roman*", "times", "FreeSerif", "Italic" },
+ { "*times*", "times", "FreeSerif", "Italic" },
+ { "*century schoolbook*", "censcbk", "FreeSerif", "Italic" },
+ { "*garamond*", "gara", "FreeSerif", "Italic" },
+ { "*courier new*", "cour", "FreeMono", "Oblique" },
+ { "*courier*", "cour", "FreeMono", "Oblique" },
+ { "*ZorkDeath*", "cour", "FreeMono", "Oblique" },
+ { "*arial*", "arial", "FreeSans", "Oblique" },
+ { "*ZorkNormal*", "arial", "FreeSans", "Oblique" },
+ };
+
+ Common::String newFontName;
+ Common::String freeFontName;
+
+ for (int i = 0; i < ARRAYSIZE(systemFonts); i++) {
+ if (fontName.matchString(systemFonts[i].zorkFont, true)) {
+ newFontName = systemFonts[i].fontBase;
+ freeFontName = systemFonts[i].freeFontBase;
+
+ if ((_style & STTF_BOLD) && (_style & STTF_ITALIC)) {
+ newFontName += "bi";
+ freeFontName += "Bold";
+ freeFontName += systemFonts[i].freeFontItalicName;
+ } else if (_style & STTF_BOLD) {
+ newFontName += "bd";
+ freeFontName += "Bold";
+ } else if (_style & STTF_ITALIC) {
+ newFontName += "i";
+ freeFontName += systemFonts[i].freeFontItalicName;
+ }
+
+ newFontName += ".ttf";
+ freeFontName += ".ttf";
+ break;
+ }
+ }
+
+ if (newFontName.empty()) {
+ debug("Could not identify font: %s. Reverting to Arial", fontName.c_str());
+ newFontName = "arial.ttf";
+ freeFontName = "FreeSans.ttf";
+ }
+
+ bool sharp = (_style & STTF_SHARP) == STTF_SHARP;
+
+ Common::File file;
+ if (!file.open(newFontName) && !file.open(freeFontName) && !_engine->getSearchManager()->openFile(file, newFontName) && !_engine->getSearchManager()->openFile(file, freeFontName))
+ error("Unable to open font file %s (free alternative: %s)", newFontName.c_str(), freeFontName.c_str());
+
+ Graphics::Font *_newFont = Graphics::loadTTFFont(file, point, 60, (sharp ? Graphics::kTTFRenderModeMonochrome : Graphics::kTTFRenderModeNormal)); // 66 dpi for 640 x 480 on 14" display
+ if (_newFont) {
+ if (!_font)
+ delete _font;
+ _font = _newFont;
+ }
+
+ _fntName = fontName;
+ _lineHeight = point;
+
+ if (_font)
+ return true;
+ return false;
+}
+
+void StyledTTFont::setStyle(uint newStyle) {
+ if ((_style & (STTF_BOLD | STTF_ITALIC | STTF_SHARP)) != (newStyle & (STTF_BOLD | STTF_ITALIC | STTF_SHARP))) {
+ _style = newStyle;
+ loadFont(_fntName, _lineHeight);
+ } else {
+ _style = newStyle;
+ }
+}
+
+int StyledTTFont::getFontHeight() {
+ if (_font)
+ return _font->getFontHeight();
+ return 0;
+}
+
+int StyledTTFont::getMaxCharWidth() {
+ if (_font)
+ return _font->getMaxCharWidth();
+ return 0;
+}
+
+int StyledTTFont::getCharWidth(byte chr) {
+ if (_font)
+ return _font->getCharWidth(chr);
+ return 0;
+}
+
+int StyledTTFont::getKerningOffset(byte left, byte right) {
+ if (_font)
+ return _font->getKerningOffset(left, right);
+ return 0;
+}
+
+void StyledTTFont::drawChar(Graphics::Surface *dst, byte chr, int x, int y, uint32 color) {
+ if (_font) {
+ _font->drawChar(dst, chr, x, y, color);
+ if (_style & STTF_UNDERLINE) {
+ int16 pos = floor(_font->getFontHeight() * 0.87);
+ int thk = MAX((int)(_font->getFontHeight() * 0.05), 1);
+ dst->fillRect(Common::Rect(x, y + pos, x + _font->getCharWidth(chr), y + pos + thk), color);
+ }
+ if (_style & STTF_STRIKEOUT) {
+ int16 pos = floor(_font->getFontHeight() * 0.60);
+ int thk = MAX((int)(_font->getFontHeight() * 0.05), 1);
+ dst->fillRect(Common::Rect(x, y + pos, x + _font->getCharWidth(chr), y + pos + thk), color);
+ }
+ }
+}
+
+void StyledTTFont::drawString(Graphics::Surface *dst, const Common::String &str, int x, int y, int w, uint32 color, Graphics::TextAlign align) {
+ if (_font) {
+ _font->drawString(dst, str, x, y, w, color, align);
+ if (_style & STTF_UNDERLINE) {
+ int16 pos = floor(_font->getFontHeight() * 0.87);
+ int16 wd = MIN(_font->getStringWidth(str), w);
+ int16 stX = x;
+ if (align == Graphics::kTextAlignCenter)
+ stX += (w - wd) / 2;
+ else if (align == Graphics::kTextAlignRight)
+ stX += (w - wd);
+
+ int thk = MAX((int)(_font->getFontHeight() * 0.05), 1);
+
+ dst->fillRect(Common::Rect(stX, y + pos, stX + wd, y + pos + thk), color);
+ }
+ if (_style & STTF_STRIKEOUT) {
+ int16 pos = floor(_font->getFontHeight() * 0.60);
+ int16 wd = MIN(_font->getStringWidth(str), w);
+ int16 stX = x;
+ if (align == Graphics::kTextAlignCenter)
+ stX += (w - wd) / 2;
+ else if (align == Graphics::kTextAlignRight)
+ stX += (w - wd);
+
+ int thk = MAX((int)(_font->getFontHeight() * 0.05), 1);
+
+ dst->fillRect(Common::Rect(stX, y + pos, stX + wd, y + pos + thk), color);
+ }
+ }
+}
+
+int StyledTTFont::getStringWidth(const Common::String &str) {
+ if (_font)
+ return _font->getStringWidth(str);
+ return 0;
+}
+
+Graphics::Surface *StyledTTFont::renderSolidText(const Common::String &str, uint32 color) {
+ Graphics::Surface *tmp = new Graphics::Surface;
+ if (_font) {
+ int16 w = _font->getStringWidth(str);
+ if (w && w < 1024) {
+ tmp->create(w, _font->getFontHeight(), _engine->_resourcePixelFormat);
+ drawString(tmp, str, 0, 0, w, color);
+ }
+ }
+ return tmp;
+}
+
+} // End of namespace ZVision
diff --git a/engines/zvision/fonts/truetype_font.h b/engines/zvision/text/truetype_font.h
index 64f53a2c3b..b5fac4af8a 100644
--- a/engines/zvision/fonts/truetype_font.h
+++ b/engines/zvision/text/truetype_font.h
@@ -28,7 +28,6 @@
#include "graphics/font.h"
#include "graphics/pixelformat.h"
-
namespace Graphics {
struct Surface;
}
@@ -37,43 +36,47 @@ namespace ZVision {
class ZVision;
-class TruetypeFont {
+// Styled TTF
+class StyledTTFont {
public:
- TruetypeFont(ZVision *engine, int32 fontHeight);
- ~TruetypeFont();
+ StyledTTFont(ZVision *engine);
+ ~StyledTTFont();
+
+ enum {
+ STTF_BOLD = 1,
+ STTF_ITALIC = 2,
+ STTF_UNDERLINE = 4,
+ STTF_STRIKEOUT = 8,
+ STTF_SHARP = 16
+ };
private:
-// ZVision *_engine;
+ ZVision *_engine;
Graphics::Font *_font;
int _lineHeight;
-
-// size_t _maxCharWidth;
-// size_t _maxCharHeight;
+ uint _style;
+ Common::String _fntName;
public:
- int32 _fontHeight;
+ bool loadFont(const Common::String &fontName, int32 point);
+ bool loadFont(const Common::String &fontName, int32 point, uint style);
+ void setStyle(uint newStyle);
-public:
- /**
- * Loads a .ttf file into memory. This must be called
- * before any calls to drawTextToSurface
- *
- * @param filename The file name of the .ttf file to load
- */
- bool loadFile(const Common::String &filename);
- /**
- * Renders the supplied text to a Surface using 0x0 as the
- * background color.
- *
- * @param text The to render
- * @param textColor The color to render the text with
- * @param maxWidth The max width the text should take up.
- * @param maxHeight The max height the text should take up.
- * @param align The alignment of the text within the bounds of maxWidth
- * @param wrap If true, any words extending past maxWidth will wrap to a new line. If false, ellipses will be rendered to show that the text didn't fit
- * @return A Surface containing the rendered text
- */
- Graphics::Surface *drawTextToSurface(const Common::String &text, uint16 textColor, int maxWidth, int maxHeight, Graphics::TextAlign align, bool wrap);
+ int getFontHeight();
+ int getMaxCharWidth();
+ int getCharWidth(byte chr);
+ int getKerningOffset(byte left, byte right);
+
+ void drawChar(Graphics::Surface *dst, byte chr, int x, int y, uint32 color);
+
+ void drawString(Graphics::Surface *dst, const Common::String &str, int x, int y, int w, uint32 color, Graphics::TextAlign align = Graphics::kTextAlignLeft);
+ int getStringWidth(const Common::String &str);
+
+ Graphics::Surface *renderSolidText(const Common::String &str, uint32 color);
+
+ bool isLoaded() {
+ return _font != NULL;
+ };
};
} // End of namespace ZVision
diff --git a/engines/zvision/utility/single_value_container.cpp b/engines/zvision/utility/single_value_container.cpp
deleted file mode 100644
index e609474285..0000000000
--- a/engines/zvision/utility/single_value_container.cpp
+++ /dev/null
@@ -1,348 +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 "common/scummsys.h"
-
-#include "zvision/utility/single_value_container.h"
-
-#include "common/textconsole.h"
-#include "common/str.h"
-
-
-namespace ZVision {
-
-SingleValueContainer::SingleValueContainer(ValueType type) : _objectType(type) { }
-
-SingleValueContainer::SingleValueContainer(bool value) : _objectType(BOOL) {
- _value.boolVal = value;
-}
-
-SingleValueContainer::SingleValueContainer(byte value) : _objectType(BYTE) {
- _value.byteVal = value;
-}
-
-SingleValueContainer::SingleValueContainer(int16 value) : _objectType(INT16) {
- _value.int16Val = value;
-}
-
-SingleValueContainer::SingleValueContainer(uint16 value) : _objectType(UINT16) {
- _value.uint16Val = value;
-}
-
-SingleValueContainer::SingleValueContainer(int32 value) : _objectType(INT32) {
- _value.int32Val = value;
-}
-
-SingleValueContainer::SingleValueContainer(uint32 value) : _objectType(UINT32) {
- _value.uint32Val = value;
-}
-
-SingleValueContainer::SingleValueContainer(float value) : _objectType(FLOAT) {
- _value.floatVal = value;
-}
-
-SingleValueContainer::SingleValueContainer(double value) : _objectType(DOUBLE) {
- _value.doubleVal = value;
-}
-
-SingleValueContainer::SingleValueContainer(Common::String value) : _objectType(BYTE) {
- _value.stringVal = new char[value.size() + 1];
- memcpy(_value.stringVal, value.c_str(), value.size() + 1);
-}
-
-SingleValueContainer::SingleValueContainer(const SingleValueContainer &other) {
- _objectType = other._objectType;
-
- switch (_objectType) {
- case BOOL:
- _value.boolVal = other._value.boolVal;
- break;
- case BYTE:
- _value.byteVal = other._value.byteVal;
- break;
- case INT16:
- _value.int16Val = other._value.int16Val;
- break;
- case UINT16:
- _value.uint16Val = other._value.uint16Val;
- break;
- case INT32:
- _value.int32Val = other._value.int32Val;
- break;
- case UINT32:
- _value.uint32Val = other._value.uint32Val;
- break;
- case FLOAT:
- _value.floatVal = other._value.floatVal;
- break;
- case DOUBLE:
- _value.doubleVal = other._value.doubleVal;
- break;
- case STRING:
- uint32 length = strlen(other._value.stringVal);
- _value.stringVal = new char[length + 1];
- memcpy(_value.stringVal, other._value.stringVal, length + 1);
- break;
- }
-}
-
-SingleValueContainer::~SingleValueContainer() {
- deleteCharPointer();
-}
-
-void SingleValueContainer::deleteCharPointer() {
- if (_objectType == STRING)
- delete[] _value.stringVal;
-}
-
-
-SingleValueContainer &SingleValueContainer::operator=(const bool &rhs) {
- if (_objectType == BOOL) {
- _value.boolVal = rhs;
- return *this;
- }
-
- deleteCharPointer();
- _objectType = BOOL;
- _value.boolVal = rhs;
-
- return *this;
-}
-
-SingleValueContainer &SingleValueContainer::operator=(const byte &rhs) {
- if (_objectType == BYTE) {
- _value.byteVal = rhs;
- return *this;
- }
-
- deleteCharPointer();
- _objectType = BYTE;
- _value.byteVal = rhs;
-
- return *this;
-}
-
-SingleValueContainer &SingleValueContainer::operator=(const int16 &rhs) {
- if (_objectType == INT16) {
- _value.int16Val = rhs;
- return *this;
- }
-
- deleteCharPointer();
- _objectType = INT16;
- _value.int16Val = rhs;
-
- return *this;
-}
-
-SingleValueContainer &SingleValueContainer::operator=(const uint16 &rhs) {
- if (_objectType == UINT16) {
- _value.uint16Val = rhs;
- return *this;
- }
-
- deleteCharPointer();
- _objectType = UINT16;
- _value.uint16Val = rhs;
-
- return *this;
-}
-
-SingleValueContainer &SingleValueContainer::operator=(const int32 &rhs) {
- if (_objectType == INT32) {
- _value.int32Val = rhs;
- return *this;
- }
-
- deleteCharPointer();
- _objectType = INT32;
- _value.int32Val = rhs;
-
- return *this;
-}
-
-SingleValueContainer &SingleValueContainer::operator=(const uint32 &rhs) {
- if (_objectType == UINT32) {
- _value.uint32Val = rhs;
- return *this;
- }
-
- deleteCharPointer();
- _objectType = UINT32;
- _value.uint32Val = rhs;
-
- return *this;
-}
-
-SingleValueContainer &SingleValueContainer::operator=(const float &rhs) {
- if (_objectType == FLOAT) {
- _value.floatVal = rhs;
- return *this;
- }
-
- deleteCharPointer();
- _objectType = FLOAT;
- _value.floatVal = rhs;
-
- return *this;
-}
-
-SingleValueContainer &SingleValueContainer::operator=(const double &rhs) {
- if (_objectType == DOUBLE) {
- _value.doubleVal = rhs;
- return *this;
- }
-
- deleteCharPointer();
- _objectType = DOUBLE;
- _value.doubleVal = rhs;
-
- return *this;
-}
-
-SingleValueContainer &SingleValueContainer::operator=(const Common::String &rhs) {
- if (_objectType != STRING) {
- _objectType = STRING;
- _value.stringVal = new char[rhs.size() + 1];
- memcpy(_value.stringVal, rhs.c_str(), rhs.size() + 1);
-
- return *this;
- }
-
- uint32 length = strlen(_value.stringVal);
- if (length <= rhs.size() + 1) {
- memcpy(_value.stringVal, rhs.c_str(), rhs.size() + 1);
- } else {
- delete[] _value.stringVal;
- _value.stringVal = new char[rhs.size() + 1];
- memcpy(_value.stringVal, rhs.c_str(), rhs.size() + 1);
- }
-
- return *this;
-}
-
-SingleValueContainer &SingleValueContainer::operator=(const SingleValueContainer &rhs) {
- switch (_objectType) {
- case BOOL:
- return operator=(rhs._value.boolVal);
- case BYTE:
- return operator=(rhs._value.byteVal);
- case INT16:
- return operator=(rhs._value.int16Val);
- case UINT16:
- return operator=(rhs._value.uint16Val);
- case INT32:
- return operator=(rhs._value.int32Val);
- case UINT32:
- return operator=(rhs._value.uint32Val);
- case FLOAT:
- return operator=(rhs._value.floatVal);
- case DOUBLE:
- return operator=(rhs._value.doubleVal);
- case STRING:
- uint32 length = strlen(rhs._value.stringVal);
-
- _value.stringVal = new char[length + 1];
- memcpy(_value.stringVal, rhs._value.stringVal, length + 1);
-
- return *this;
- }
-
- return *this;
-}
-
-
-bool SingleValueContainer::getBoolValue(bool *returnValue) const {
- if (_objectType != BOOL) {
- warning("'Object' is not storing a bool.");
- return false;
- }
-
- *returnValue = _value.boolVal;
- return true;
-}
-
-bool SingleValueContainer::getByteValue(byte *returnValue) const {
- if (_objectType != BYTE)
- warning("'Object' is not storing a byte.");
-
- *returnValue = _value.byteVal;
- return true;
-}
-
-bool SingleValueContainer::getInt16Value(int16 *returnValue) const {
- if (_objectType != INT16)
- warning("'Object' is not storing an int16.");
-
- *returnValue = _value.int16Val;
- return true;
-}
-
-bool SingleValueContainer::getUInt16Value(uint16 *returnValue) const {
- if (_objectType != UINT16)
- warning("'Object' is not storing a uint16.");
-
- *returnValue = _value.uint16Val;
- return true;
-}
-
-bool SingleValueContainer::getInt32Value(int32 *returnValue) const {
- if (_objectType != INT32)
- warning("'Object' is not storing an int32.");
-
- *returnValue = _value.int32Val;
- return true;
-}
-
-bool SingleValueContainer::getUInt32Value(uint32 *returnValue) const {
- if (_objectType != UINT32)
- warning("'Object' is not storing a uint32.");
-
- *returnValue = _value.uint32Val;
- return true;
-}
-
-bool SingleValueContainer::getFloatValue(float *returnValue) const {
- if (_objectType != FLOAT)
- warning("'Object' is not storing a float.");
-
- *returnValue = _value.floatVal;
- return true;
-}
-
-bool SingleValueContainer::getDoubleValue(double *returnValue) const {
- if (_objectType != DOUBLE)
- warning("'Object' is not storing a double.");
-
- *returnValue = _value.doubleVal;
- return true;
-}
-
-bool SingleValueContainer::getStringValue(Common::String *returnValue) const {
- if (_objectType != STRING)
- warning("'Object' is not storing a Common::String.");
-
- *returnValue = _value.stringVal;
- return true;
-}
-
-} // End of namespace ZVision
diff --git a/engines/zvision/utility/single_value_container.h b/engines/zvision/utility/single_value_container.h
deleted file mode 100644
index 951383661a..0000000000
--- a/engines/zvision/utility/single_value_container.h
+++ /dev/null
@@ -1,183 +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 ZVISION_SINGLE_VALUE_CONTAINER_H
-#define ZVISION_SINGLE_VALUE_CONTAINER_H
-
-namespace Common {
-class String;
-}
-
-namespace ZVision {
-
-/**
- * A generic single value storage class. It is useful for storing different
- * value types in a single List, Hashmap, etc.
- */
-class SingleValueContainer {
-public:
- enum ValueType {
- BOOL,
- BYTE,
- INT16,
- UINT16,
- INT32,
- UINT32,
- FLOAT,
- DOUBLE,
- STRING
- };
-
- // Constructors
- explicit SingleValueContainer(ValueType type);
- explicit SingleValueContainer(bool value);
- explicit SingleValueContainer(byte value);
- explicit SingleValueContainer(int16 value);
- explicit SingleValueContainer(uint16 value);
- explicit SingleValueContainer(int32 value);
- explicit SingleValueContainer(uint32 value);
- explicit SingleValueContainer(float value);
- explicit SingleValueContainer(double value);
- explicit SingleValueContainer(Common::String value);
-
- // Copy constructor
- explicit SingleValueContainer(const SingleValueContainer& other);
-
- // Destructor
- ~SingleValueContainer();
-
-private:
- ValueType _objectType;
-
- union {
- bool boolVal;
- byte byteVal;
- int16 int16Val;
- uint16 uint16Val;
- int32 int32Val;
- uint32 uint32Val;
- float floatVal;
- double doubleVal;
- char *stringVal;
- } _value;
-
-public:
- SingleValueContainer &operator=(const bool &rhs);
- SingleValueContainer &operator=(const byte &rhs);
- SingleValueContainer &operator=(const int16 &rhs);
- SingleValueContainer &operator=(const uint16 &rhs);
- SingleValueContainer &operator=(const int32 &rhs);
- SingleValueContainer &operator=(const uint32 &rhs);
- SingleValueContainer &operator=(const float &rhs);
- SingleValueContainer &operator=(const double &rhs);
- SingleValueContainer &operator=(const Common::String &rhs);
-
- SingleValueContainer& operator=(const SingleValueContainer &rhs);
-
- /**
- * Retrieve a bool from the container. If the container is not storing a
- * bool, this will return false and display a warning().
- *
- * @param returnValue Pointer to where you want the value stored
- * @return Value indicating whether the value assignment was successful
- */
- bool getBoolValue(bool *returnValue) const;
- /**
- * Retrieve a byte from the container. If the container is not storing a
- * byte, this will return false and display a warning().
- *
- * @param returnValue Pointer to where you want the value stored
- * @return Value indicating whether the value assignment was successful
- */
- bool getByteValue(byte *returnValue) const;
- /**
- * Retrieve an int16 from the container. If the container is not storing an
- * int16, this will return false and display a warning().
- *
- * @param returnValue Pointer to where you want the value stored
- * @return Value indicating whether the value assignment was successful
- */
- bool getInt16Value(int16 *returnValue) const;
- /**
- * Retrieve a uint16 from the container. If the container is not storing a
- * uint16, this will return false and display a warning().
- *
- * @param returnValue Pointer to where you want the value stored
- * @return Value indicating whether the value assignment was successful
- */
- bool getUInt16Value(uint16 *returnValue) const;
- /**
- * Retrieve an int32 from the container. If the container is not storing an
- * int32, this will return false and display a warning().
- *
- * @param returnValue Pointer to where you want the value stored
- * @return Value indicating whether the value assignment was successful
- */
- bool getInt32Value(int32 *returnValue) const;
- /**
- * Retrieve a uint32 from the container. If the container is not storing a
- * uint32, this will return false and display a warning().
- *
- * @param returnValue Pointer to where you want the value stored
- * @return Value indicating whether the value assignment was successful
- */
- bool getUInt32Value(uint32 *returnValue) const;
- /**
- * Retrieve a float from the container. If the container is not storing a
- * float, this will return false and display a warning().
- *
- * @param returnValue Pointer to where you want the value stored
- * @return Value indicating whether the value assignment was successful
- */
- bool getFloatValue(float *returnValue) const;
- /**
- * Retrieve a double from the container. If the container is not storing a
- * double, this will return false and display a warning().
- *
- * @param returnValue Pointer to where you want the value stored
- * @return Value indicating whether the value assignment was successful
- */
- bool getDoubleValue(double *returnValue) const;
- /**
- * Retrieve a String from the container. If the container is not storing a
- * string, this will return false and display a warning().
- *
- * Caution: Strings are internally stored as char[]. getStringValue uses
- * Common::String::operator=(char *) to do the assigment, which uses both
- * strlen() AND memmove().
- *
- * @param returnValue Pointer to where you want the value stored
- * @return Value indicating whether the value assignment was successful
- */
- bool getStringValue(Common::String *returnValue) const;
-
-private:
- /**
- * Helper method for destruction and assignment. It checks to see
- * if the char pointer is being used, and if so calls delete on it
- */
- void deleteCharPointer();
-};
-
-} // End of namespace ZVision
-
-#endif
diff --git a/engines/zvision/utility/utility.cpp b/engines/zvision/utility/utility.cpp
deleted file mode 100644
index 905bc4513a..0000000000
--- a/engines/zvision/utility/utility.cpp
+++ /dev/null
@@ -1,237 +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 "common/scummsys.h"
-
-#include "zvision/utility/utility.h"
-
-#include "zvision/zvision.h"
-#include "zvision/sound/zork_raw.h"
-
-#include "common/tokenizer.h"
-#include "common/file.h"
-
-
-namespace ZVision {
-
-void writeFileContentsToFile(const Common::String &sourceFile, const Common::String &destFile) {
- Common::File f;
- if (!f.open(sourceFile)) {
- return;
- }
-
- byte* buffer = new byte[f.size()];
- f.read(buffer, f.size());
-
- Common::DumpFile dumpFile;
- dumpFile.open(destFile);
-
- dumpFile.write(buffer, f.size());
- dumpFile.flush();
- dumpFile.close();
-
- delete[] buffer;
-}
-
-void trimCommentsAndWhiteSpace(Common::String *string) {
- for (int i = string->size() - 1; i >= 0; i--) {
- if ((*string)[i] == '#') {
- string->erase(i);
- }
- }
-
- string->trim();
-}
-
-void tryToDumpLine(const Common::String &key,
- Common::String &line,
- Common::HashMap<Common::String, byte> *count,
- Common::HashMap<Common::String, bool> *fileAlreadyUsed,
- Common::DumpFile &output) {
- const byte numberOfExamplesPerType = 8;
-
- if ((*count)[key] < numberOfExamplesPerType && !(*fileAlreadyUsed)[key]) {
- output.writeString(line);
- output.writeByte('\n');
- (*count)[key]++;
- (*fileAlreadyUsed)[key] = true;
- }
-}
-
-void dumpEveryResultAction(const Common::String &destFile) {
- Common::HashMap<Common::String, byte> count;
- Common::HashMap<Common::String, bool> fileAlreadyUsed;
-
- Common::DumpFile output;
- output.open(destFile);
-
- // Find scr files
- Common::ArchiveMemberList list;
- SearchMan.listMatchingMembers(list, "*.scr");
-
- for (Common::ArchiveMemberList::iterator iter = list.begin(); iter != list.end(); ++iter) {
- Common::SeekableReadStream *stream = (*iter)->createReadStream();
-
- Common::String line = stream->readLine();
- trimCommentsAndWhiteSpace(&line);
-
- while (!stream->eos()) {
- if (line.matchString("*:add*", true)) {
- tryToDumpLine("add", line, &count, &fileAlreadyUsed, output);
- } else if (line.matchString("*:animplay*", true)) {
- tryToDumpLine("animplay", line, &count, &fileAlreadyUsed, output);
- } else if (line.matchString("*:animpreload*", true)) {
- tryToDumpLine("animpreload", line, &count, &fileAlreadyUsed, output);
- } else if (line.matchString("*:animunload*", true)) {
- tryToDumpLine("animunload", line, &count, &fileAlreadyUsed, output);
- } else if (line.matchString("*:attenuate*", true)) {
- tryToDumpLine("attenuate", line, &count, &fileAlreadyUsed, output);
- } else if (line.matchString("*:assign*", true)) {
- tryToDumpLine("assign", line, &count, &fileAlreadyUsed, output);
- } else if (line.matchString("*:change_location*", true)) {
- tryToDumpLine("change_location", line, &count, &fileAlreadyUsed, output);
- } else if (line.matchString("*:crossfade*", true) && !fileAlreadyUsed["add"]) {
- tryToDumpLine("crossfade", line, &count, &fileAlreadyUsed, output);
- } else if (line.matchString("*:debug*", true)) {
- tryToDumpLine("debug", line, &count, &fileAlreadyUsed, output);
- } else if (line.matchString("*:delay_render*", true)) {
- tryToDumpLine("delay_render", line, &count, &fileAlreadyUsed, output);
- } else if (line.matchString("*:disable_control*", true)) {
- tryToDumpLine("disable_control", line, &count, &fileAlreadyUsed, output);
- } else if (line.matchString("*:disable_venus*", true)) {
- tryToDumpLine("disable_venus", line, &count, &fileAlreadyUsed, output);
- } else if (line.matchString("*:display_message*", true)) {
- tryToDumpLine("display_message", line, &count, &fileAlreadyUsed, output);
- } else if (line.matchString("*:dissolve*", true)) {
- tryToDumpLine("dissolve", line, &count, &fileAlreadyUsed, output);
- } else if (line.matchString("*:distort*", true)) {
- tryToDumpLine("distort", line, &count, &fileAlreadyUsed, output);
- } else if (line.matchString("*:enable_control*", true)) {
- tryToDumpLine("enable_control", line, &count, &fileAlreadyUsed, output);
- } else if (line.matchString("*:flush_mouse_events*", true)) {
- tryToDumpLine("flush_mouse_events", line, &count, &fileAlreadyUsed, output);
- } else if (line.matchString("*:inventory*", true)) {
- tryToDumpLine("inventory", line, &count, &fileAlreadyUsed, output);
- } else if (line.matchString("*:kill*", true)) {
- tryToDumpLine("kill", line, &count, &fileAlreadyUsed, output);
- } else if (line.matchString("*:menu_bar_enable*", true)) {
- tryToDumpLine("menu_bar_enable", line, &count, &fileAlreadyUsed, output);
- } else if (line.matchString("*:music*", true)) {
- tryToDumpLine("music", line, &count, &fileAlreadyUsed, output);
- } else if (line.matchString("*:pan_track*", true)) {
- tryToDumpLine("pan_track", line, &count, &fileAlreadyUsed, output);
- } else if (line.matchString("*:playpreload*", true)) {
- tryToDumpLine("playpreload", line, &count, &fileAlreadyUsed, output);
- } else if (line.matchString("*:preferences*", true)) {
- tryToDumpLine("preferences", line, &count, &fileAlreadyUsed, output);
- } else if (line.matchString("*:quit*", true)) {
- tryToDumpLine("quit", line, &count, &fileAlreadyUsed, output);
- } else if (line.matchString("*:random*", true)) {
- tryToDumpLine("random", line, &count, &fileAlreadyUsed, output);
- } else if (line.matchString("*:region*", true)) {
- tryToDumpLine("region", line, &count, &fileAlreadyUsed, output);
- } else if (line.matchString("*:restore_game*", true)) {
- tryToDumpLine("restore_game", line, &count, &fileAlreadyUsed, output);
- } else if (line.matchString("*:rotate_to*", true)) {
- tryToDumpLine("rotate_to", line, &count, &fileAlreadyUsed, output);
- } else if (line.matchString("*:save_game*", true)) {
- tryToDumpLine("save_game", line, &count, &fileAlreadyUsed, output);
- } else if (line.matchString("*:set_partial_screen*", true)) {
- tryToDumpLine("set_partial_screen", line, &count, &fileAlreadyUsed, output);
- } else if (line.matchString("*:set_screen*", true)) {
- tryToDumpLine("set_screen", line, &count, &fileAlreadyUsed, output);
- } else if (line.matchString("*:set_venus*", true)) {
- tryToDumpLine("set_venus", line, &count, &fileAlreadyUsed, output);
- } else if (line.matchString("*:stop*", true)) {
- tryToDumpLine("stop", line, &count, &fileAlreadyUsed, output);
- } else if (line.matchString("*:streamvideo*", true)) {
- tryToDumpLine("streamvideo", line, &count, &fileAlreadyUsed, output);
- } else if (line.matchString("*:syncsound*", true)) {
- tryToDumpLine("syncsound", line, &count, &fileAlreadyUsed, output);
- } else if (line.matchString("*:timer*", true)) {
- tryToDumpLine("timer", line, &count, &fileAlreadyUsed, output);
- } else if (line.matchString("*:ttytext*", true)) {
- tryToDumpLine("ttytext", line, &count, &fileAlreadyUsed, output);
- } else if (line.matchString("*:universe_music*", true)) {
- tryToDumpLine("universe_music", line, &count, &fileAlreadyUsed, output);
- }
-
- line = stream->readLine();
- trimCommentsAndWhiteSpace(&line);
- }
-
- for (Common::HashMap<Common::String, bool>::iterator fileUsedIter = fileAlreadyUsed.begin(); fileUsedIter != fileAlreadyUsed.end(); ++fileUsedIter) {
- fileUsedIter->_value = false;
- }
- }
-
- output.close();
-}
-
-Common::String getFileName(const Common::String &fullPath) {
- Common::StringTokenizer tokenizer(fullPath, "/\\");
- Common::String token;
- while (!tokenizer.empty()) {
- token = tokenizer.nextToken();
- }
-
- return token;
-}
-
-void convertRawToWav(const Common::String &inputFile, ZVision *engine, const Common::String &outputFile) {
- Common::File file;
- if (!file.open(inputFile))
- return;
-
- Audio::AudioStream *audioStream = makeRawZorkStream(inputFile, engine);
-
- Common::DumpFile output;
- output.open(outputFile);
-
- output.writeUint32BE(MKTAG('R', 'I', 'F', 'F'));
- output.writeUint32LE(file.size() * 2 + 36);
- output.writeUint32BE(MKTAG('W', 'A', 'V', 'E'));
- output.writeUint32BE(MKTAG('f', 'm', 't', ' '));
- output.writeUint32LE(16);
- output.writeUint16LE(1);
- uint16 numChannels;
- if (audioStream->isStereo()) {
- numChannels = 2;
- output.writeUint16LE(2);
- } else {
- numChannels = 1;
- output.writeUint16LE(1);
- }
- output.writeUint32LE(audioStream->getRate());
- output.writeUint32LE(audioStream->getRate() * numChannels * 2);
- output.writeUint16LE(numChannels * 2);
- output.writeUint16LE(16);
- output.writeUint32BE(MKTAG('d', 'a', 't', 'a'));
- output.writeUint32LE(file.size() * 2);
- int16 *buffer = new int16[file.size()];
- audioStream->readBuffer(buffer, file.size());
- output.write(buffer, file.size() * 2);
-
- delete[] buffer;
-}
-
-} // End of namespace ZVision
diff --git a/engines/zvision/utility/utility.h b/engines/zvision/utility/utility.h
deleted file mode 100644
index 063d4c0663..0000000000
--- a/engines/zvision/utility/utility.h
+++ /dev/null
@@ -1,114 +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 ZVISION_UTILITY_H
-#define ZVISION_UTILITY_H
-
-#include "common/array.h"
-
-
-namespace Common {
-class String;
-}
-
-namespace ZVision {
-
-class ZVision;
-
-/**
- * Opens the sourceFile utilizing Common::File (aka SearchMan) and writes the
- * contents to destFile. destFile is created in the working directory
- *
- * @param sourceFile The 'file' you want the contents of
- * @param destFile The name of the file where the content will be written to
- */
-void writeFileContentsToFile(const Common::String &sourceFile, const Common::String &destFile);
-
-/**
- * Removes any line comments using '#' as a sequence start.
- * Then removes any trailing and leading 'whitespace' using String::trim()
- * Note: String::trim uses isspace() to determine what is whitespace and what is not.
- *
- * @param string The string to modify. It is modified in place
- */
-void trimCommentsAndWhiteSpace(Common::String *string);
-
-/**
- * Searches through all the .scr files and dumps 'numberOfExamplesPerType' examples of each type of ResultAction
- * ZVision::initialize() must have been called before this function can be used.
- *
- * @param destFile Where to write the examples
- */
-void dumpEveryResultAction(const Common::String &destFile);
-
-/**
- * Removes all duplicate entries from container. Relative order will be preserved.
- *
- * @param container The Array to remove duplicate entries from
- */
-template<class T>
-void removeDuplicateEntries(Common::Array<T> &container) {
- // Length of modified array
- uint newLength = 1;
- uint j;
-
- for(uint i = 1; i < container.size(); i++) {
- for(j = 0; j < newLength; j++) {
- if (container[i] == container[j]) {
- break;
- }
- }
-
- // If none of the values in index[0..j] of container are the same as array[i],
- // then copy the current value to corresponding new position in array
- if (j == newLength) {
- container[newLength++] = container[i];
- }
- }
-
- // Actually remove the unneeded space
- while (container.size() < newLength) {
- container.pop_back();
- }
-}
-
-/**
- * Gets the name of the file (including extension). Forward or back slashes
- * are interpreted as directory changes
- *
- * @param fullPath A full or partial path to the file. Ex: folderOne/folderTwo/file.txt
- * @return The name of the file without any preceding directories. Ex: file.txt
- */
-Common::String getFileName(const Common::String &fullPath);
-
-/**
- * Converts a ZVision .RAW file to a .WAV
- * The .WAV will be created in the working directory and will overwrite any existing file
- *
- * @param inputFile The path to the input .RAW file
- * @param outputFile The name of the output .WAV file
- */
-void convertRawToWav(const Common::String &inputFile, ZVision *engine, const Common::String &outputFile);
-
-} // End of namespace ZVision
-
-#endif
diff --git a/engines/zvision/video/rlf_decoder.cpp b/engines/zvision/video/rlf_decoder.cpp
new file mode 100644
index 0000000000..db598a25b6
--- /dev/null
+++ b/engines/zvision/video/rlf_decoder.cpp
@@ -0,0 +1,313 @@
+/* ScummVM - Graphic Adventure Engine
+*
+* ScummVM is the legal property of its developers, whose names
+* are too numerous to list here. Please refer to the COPYRIGHT
+* file distributed with this source distribution.
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License
+* as published by the Free Software Foundation; either version 2
+* of the License, or (at your option) any later version.
+
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+
+* You should have received a copy of the GNU General Public 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 "zvision/video/rlf_decoder.h"
+
+#include "common/str.h"
+#include "common/file.h"
+#include "common/textconsole.h"
+#include "common/debug.h"
+#include "common/endian.h"
+
+namespace ZVision {
+
+RLFDecoder::~RLFDecoder() {
+ close();
+}
+
+bool RLFDecoder::loadStream(Common::SeekableReadStream *stream) {
+ close();
+
+ // Check if the stream is valid
+ if (stream && !stream->err() && stream->readUint32BE() == MKTAG('F', 'E', 'L', 'R')) {
+ addTrack(new RLFVideoTrack(stream));
+ return true;
+ } else {
+ return false;
+ }
+}
+
+RLFDecoder::RLFVideoTrack::RLFVideoTrack(Common::SeekableReadStream *stream)
+ : _readStream(stream),
+ _lastFrameRead(0),
+ _frameCount(0),
+ _width(0),
+ _height(0),
+ _frameTime(0),
+ _frames(0),
+ _displayedFrame(-1),
+ _frameBufferByteSize(0) {
+
+ if (!readHeader()) {
+ warning("Not a RLF animation file. Wrong magic number");
+ return;
+ }
+
+ _currentFrameBuffer.create(_width, _height, getPixelFormat());
+ _frameBufferByteSize = _width * _height * sizeof(uint16);
+
+ _frames = new Frame[_frameCount];
+
+ // Read in each frame
+ for (uint i = 0; i < _frameCount; ++i) {
+ _frames[i] = readNextFrame();
+ }
+}
+
+RLFDecoder::RLFVideoTrack::~RLFVideoTrack() {
+ for (uint i = 0; i < _frameCount; ++i) {
+ delete[] _frames[i].encodedData;
+ }
+ delete[] _frames;
+ delete _readStream;
+ _currentFrameBuffer.free();
+}
+
+bool RLFDecoder::RLFVideoTrack::readHeader() {
+ // Read the header
+ _readStream->readUint32LE(); // Size1
+ _readStream->readUint32LE(); // Unknown1
+ _readStream->readUint32LE(); // Unknown2
+ _frameCount = _readStream->readUint32LE(); // Frame count
+
+ // Since we don't need any of the data, we can just seek right to the
+ // entries we need rather than read in all the individual entries.
+ _readStream->seek(136, SEEK_CUR);
+
+ //// Read CIN header
+ //_readStream->readUint32BE(); // Magic number FNIC
+ //_readStream->readUint32LE(); // Size2
+ //_readStream->readUint32LE(); // Unknown3
+ //_readStream->readUint32LE(); // Unknown4
+ //_readStream->readUint32LE(); // Unknown5
+ //_readStream->seek(0x18, SEEK_CUR); // VRLE
+ //_readStream->readUint32LE(); // LRVD
+ //_readStream->readUint32LE(); // Unknown6
+ //_readStream->seek(0x18, SEEK_CUR); // HRLE
+ //_readStream->readUint32LE(); // ELHD
+ //_readStream->readUint32LE(); // Unknown7
+ //_readStream->seek(0x18, SEEK_CUR); // HKEY
+ //_readStream->readUint32LE(); // ELRH
+
+ //// Read MIN info header
+ //_readStream->readUint32BE(); // Magic number FNIM
+ //_readStream->readUint32LE(); // Size3
+ //_readStream->readUint32LE(); // OEDV
+ //_readStream->readUint32LE(); // Unknown8
+ //_readStream->readUint32LE(); // Unknown9
+ //_readStream->readUint32LE(); // Unknown10
+ _width = _readStream->readUint32LE(); // Width
+ _height = _readStream->readUint32LE(); // Height
+
+ // Read time header
+ _readStream->readUint32BE(); // Magic number EMIT
+ _readStream->readUint32LE(); // Size4
+ _readStream->readUint32LE(); // Unknown11
+ _frameTime = _readStream->readUint32LE() / 10; // Frame time in microseconds
+
+ return true;
+}
+
+RLFDecoder::RLFVideoTrack::Frame RLFDecoder::RLFVideoTrack::readNextFrame() {
+ RLFDecoder::RLFVideoTrack::Frame frame;
+
+ _readStream->readUint32BE(); // Magic number MARF
+ uint32 size = _readStream->readUint32LE(); // Size
+ _readStream->readUint32LE(); // Unknown1
+ _readStream->readUint32LE(); // Unknown2
+ uint32 type = _readStream->readUint32BE(); // Either ELHD or ELRH
+ uint32 headerSize = _readStream->readUint32LE(); // Offset from the beginning of this frame to the frame data. Should always be 28
+ _readStream->readUint32LE(); // Unknown3
+
+ frame.encodedSize = size - headerSize;
+ frame.encodedData = new int8[frame.encodedSize];
+ _readStream->read(frame.encodedData, frame.encodedSize);
+
+ if (type == MKTAG('E', 'L', 'H', 'D')) {
+ frame.type = Masked;
+ } else if (type == MKTAG('E', 'L', 'R', 'H')) {
+ frame.type = Simple;
+ _completeFrames.push_back(_lastFrameRead);
+ } else {
+ warning("Frame %u doesn't have type that can be decoded", _lastFrameRead);
+ }
+
+ _lastFrameRead++;
+ return frame;
+}
+
+bool RLFDecoder::RLFVideoTrack::seek(const Audio::Timestamp &time) {
+ uint frame = getFrameAtTime(time);
+ assert(frame < (int)_frameCount);
+
+ if ((uint)_displayedFrame == frame)
+ return true;
+
+ int closestFrame = _displayedFrame;
+ int distance = (int)frame - closestFrame;
+
+ if (distance < 0) {
+ for (uint i = 0; i < _completeFrames.size(); ++i) {
+ if ((int)_completeFrames[i] > frame)
+ break;
+ closestFrame = _completeFrames[i];
+ }
+ } else {
+ for (uint i = 0; i < _completeFrames.size(); ++i) {
+ int newDistance = (int)frame - (int)(_completeFrames[i]);
+ if (newDistance < 0)
+ break;
+ if (newDistance < distance) {
+ closestFrame = _completeFrames[i];
+ distance = newDistance;
+ }
+ }
+ }
+
+ for (uint i = closestFrame; i < frame; ++i) {
+ applyFrameToCurrent(i);
+ }
+
+ _displayedFrame = frame - 1;
+
+ return true;
+}
+
+const Graphics::Surface *RLFDecoder::RLFVideoTrack::decodeNextFrame() {
+ if (_displayedFrame >= (int)_frameCount)
+ return NULL;
+
+ _displayedFrame++;
+ applyFrameToCurrent(_displayedFrame);
+
+ return &_currentFrameBuffer;
+}
+
+void RLFDecoder::RLFVideoTrack::applyFrameToCurrent(uint frameNumber) {
+ if (_frames[frameNumber].type == Masked) {
+ decodeMaskedRunLengthEncoding(_frames[frameNumber].encodedData, (int8 *)_currentFrameBuffer.getPixels(), _frames[frameNumber].encodedSize, _frameBufferByteSize);
+ } else if (_frames[frameNumber].type == Simple) {
+ decodeSimpleRunLengthEncoding(_frames[frameNumber].encodedData, (int8 *)_currentFrameBuffer.getPixels(), _frames[frameNumber].encodedSize, _frameBufferByteSize);
+ }
+}
+
+void RLFDecoder::RLFVideoTrack::decodeMaskedRunLengthEncoding(int8 *source, int8 *dest, uint32 sourceSize, uint32 destSize) const {
+ uint32 sourceOffset = 0;
+ uint32 destOffset = 0;
+ int16 numberOfCopy = 0;
+
+ while (sourceOffset < sourceSize) {
+ int8 numberOfSamples = source[sourceOffset];
+ sourceOffset++;
+
+ // If numberOfSamples is negative, the next abs(numberOfSamples) samples should
+ // be copied directly from source to dest
+ if (numberOfSamples < 0) {
+ numberOfCopy = -numberOfSamples;
+
+ while (numberOfCopy > 0) {
+ if (sourceOffset + 1 >= sourceSize) {
+ return;
+ } else if (destOffset + 1 >= destSize) {
+ debug(2, "Frame decoding overflow\n\tsourceOffset=%u\tsourceSize=%u\n\tdestOffset=%u\tdestSize=%u", sourceOffset, sourceSize, destOffset, destSize);
+ return;
+ }
+
+ WRITE_UINT16(dest + destOffset, READ_LE_UINT16(source + sourceOffset));
+
+ sourceOffset += 2;
+ destOffset += 2;
+ numberOfCopy--;
+ }
+
+ // If numberOfSamples is >= 0, move destOffset forward ((numberOfSamples * 2) + 2)
+ // This function assumes the dest buffer has been memset with 0's.
+ } else {
+ if (sourceOffset + 1 >= sourceSize) {
+ return;
+ } else if (destOffset + 1 >= destSize) {
+ debug(2, "Frame decoding overflow\n\tsourceOffset=%u\tsourceSize=%u\n\tdestOffset=%u\tdestSize=%u", sourceOffset, sourceSize, destOffset, destSize);
+ return;
+ }
+
+ destOffset += (numberOfSamples * 2) + 2;
+ }
+ }
+}
+
+void RLFDecoder::RLFVideoTrack::decodeSimpleRunLengthEncoding(int8 *source, int8 *dest, uint32 sourceSize, uint32 destSize) const {
+ uint32 sourceOffset = 0;
+ uint32 destOffset = 0;
+ int16 numberOfCopy = 0;
+
+ while (sourceOffset < sourceSize) {
+ int8 numberOfSamples = source[sourceOffset];
+ sourceOffset++;
+
+ // If numberOfSamples is negative, the next abs(numberOfSamples) samples should
+ // be copied directly from source to dest
+ if (numberOfSamples < 0) {
+ numberOfCopy = -numberOfSamples;
+
+ while (numberOfCopy > 0) {
+ if (sourceOffset + 1 >= sourceSize) {
+ return;
+ } else if (destOffset + 1 >= destSize) {
+ debug(2, "Frame decoding overflow\n\tsourceOffset=%u\tsourceSize=%u\n\tdestOffset=%u\tdestSize=%u", sourceOffset, sourceSize, destOffset, destSize);
+ return;
+ }
+
+ WRITE_UINT16(dest + destOffset, READ_LE_UINT16(source + sourceOffset));
+
+ sourceOffset += 2;
+ destOffset += 2;
+ numberOfCopy--;
+ }
+
+ // If numberOfSamples is >= 0, copy one sample from source to the
+ // next (numberOfSamples + 2) dest spots
+ } else {
+ if (sourceOffset + 1 >= sourceSize) {
+ return;
+ }
+
+ uint16 sampleColor = READ_LE_UINT16(source + sourceOffset);
+ sourceOffset += 2;
+
+ numberOfCopy = numberOfSamples + 2;
+ while (numberOfCopy > 0) {
+ if (destOffset + 1 >= destSize) {
+ debug(2, "Frame decoding overflow\n\tsourceOffset=%u\tsourceSize=%u\n\tdestOffset=%u\tdestSize=%u", sourceOffset, sourceSize, destOffset, destSize);
+ return;
+ }
+
+ WRITE_UINT16(dest + destOffset, sampleColor);
+ destOffset += 2;
+ numberOfCopy--;
+ }
+ }
+ }
+}
+
+} // End of namespace ZVision
diff --git a/engines/zvision/video/rlf_decoder.h b/engines/zvision/video/rlf_decoder.h
new file mode 100644
index 0000000000..8b8cbaecd5
--- /dev/null
+++ b/engines/zvision/video/rlf_decoder.h
@@ -0,0 +1,134 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public 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 ZVISION_RLF_DECODER_H
+#define ZVISION_RLF_DECODER_H
+
+#include "common/file.h"
+#include "video/video_decoder.h"
+
+#include "graphics/surface.h"
+
+namespace ZVision {
+
+class RLFDecoder : public Video::VideoDecoder {
+public:
+ RLFDecoder() {}
+ ~RLFDecoder();
+
+ bool loadStream(Common::SeekableReadStream *stream);
+
+private:
+ class RLFVideoTrack : public FixedRateVideoTrack {
+ public:
+ RLFVideoTrack(Common::SeekableReadStream *stream);
+ ~RLFVideoTrack();
+
+ uint16 getWidth() const { return _width; }
+ uint16 getHeight() const { return _height; }
+ Graphics::PixelFormat getPixelFormat() const { return Graphics::PixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0); /* RGB 555 */ }
+ int getCurFrame() const { return _displayedFrame; }
+ int getFrameCount() const { return _frameCount; }
+ const Graphics::Surface *decodeNextFrame();
+ bool isSeekable() const { return true; }
+ bool seek(const Audio::Timestamp &time);
+
+ protected:
+ Common::Rational getFrameRate() const { return Common::Rational(1000, _frameTime); }
+
+ private:
+ enum EncodingType {
+ Masked,
+ Simple
+ };
+
+ struct Frame {
+ EncodingType type;
+ int8 *encodedData;
+ uint32 encodedSize;
+ };
+
+ /**
+ * Reads in the header of the RLF file
+ *
+ * @return Will return false if the header magic number is wrong
+ */
+ bool readHeader();
+
+ /**
+ * Reads the next frame from the RLF file, stores the data in
+ * a Frame object, then returns the object
+ *
+ * @return A Frame object representing the frame data
+ */
+ Frame readNextFrame();
+
+ /**
+ * Applies the frame corresponding to frameNumber on top of _currentFrameBuffer.
+ * This function requires _stream = false so it can look up the Frame object
+ * referenced by frameNumber.
+ *
+ * @param frameNumber The frame number to apply to _currentFrameBuffer
+ */
+ void applyFrameToCurrent(uint frameNumber);
+
+ /**
+ * Decode frame data that uses masked run length encoding. This is the encoding
+ * used by P-frames.
+ *
+ * @param source The source pixel data
+ * @param dest The destination buffer
+ * @param sourceSize The size of the source pixel data
+ * @param destSize The size of the destination buffer
+ */
+ void decodeMaskedRunLengthEncoding(int8 *source, int8 *dest, uint32 sourceSize, uint32 destSize) const;
+ /**
+ * Decode frame data that uses simple run length encoding. This is the encoding
+ * used by I-frames.
+ *
+ * @param source The source pixel data
+ * @param dest The destination buffer
+ * @param sourceSize The size of the source pixel data
+ * @param destSize The size of the destination buffer
+ */
+ void decodeSimpleRunLengthEncoding(int8 *source, int8 *dest, uint32 sourceSize, uint32 destSize) const;
+
+ uint _lastFrameRead;
+
+ uint _frameCount;
+ uint _width;
+ uint _height;
+ uint32 _frameTime; // In milliseconds
+ Frame *_frames;
+ Common::Array<uint> _completeFrames;
+
+ int _displayedFrame;
+ Graphics::Surface _currentFrameBuffer;
+ uint32 _frameBufferByteSize;
+
+ Common::SeekableReadStream *_readStream;
+ }; // RLFVideoTrack
+};
+
+} // End of namespace ZVision
+
+#endif
diff --git a/engines/zvision/video/video.cpp b/engines/zvision/video/video.cpp
index d1fff30408..0913b28818 100644
--- a/engines/zvision/video/video.cpp
+++ b/engines/zvision/video/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.
@@ -21,107 +21,71 @@
*/
#include "common/scummsys.h"
-
-#include "zvision/zvision.h"
-
-#include "zvision/utility/clock.h"
-#include "zvision/graphics/render_manager.h"
-
#include "common/system.h"
-
#include "video/video_decoder.h"
-
#include "engines/util.h"
-
#include "graphics/surface.h"
+#include "zvision/zvision.h"
+#include "zvision/core/clock.h"
+#include "zvision/graphics/render_manager.h"
+#include "zvision/scripting//script_manager.h"
+#include "zvision/text/subtitles.h"
+#include "zvision/video/rlf_decoder.h"
+#include "zvision/video/zork_avi_decoder.h"
namespace ZVision {
-// Taken/modified from SCI
-void scaleBuffer(const byte *src, byte *dst, uint32 srcWidth, uint32 srcHeight, byte bytesPerPixel, uint scaleAmount) {
- assert(bytesPerPixel == 1 || bytesPerPixel == 2);
-
- const uint32 newWidth = srcWidth * scaleAmount;
- const uint32 pitch = newWidth * bytesPerPixel;
- const byte *srcPtr = src;
-
- if (bytesPerPixel == 1) {
- for (uint32 y = 0; y < srcHeight; ++y) {
- for (uint32 x = 0; x < srcWidth; ++x) {
- const byte color = *srcPtr++;
-
- for (uint i = 0; i < scaleAmount; ++i) {
- dst[i] = color;
- dst[pitch + i] = color;
- }
- dst += scaleAmount;
- }
- dst += pitch;
- }
- } else if (bytesPerPixel == 2) {
- for (uint32 y = 0; y < srcHeight; ++y) {
- for (uint32 x = 0; x < srcWidth; ++x) {
- const byte color = *srcPtr++;
- const byte color2 = *srcPtr++;
-
- for (uint i = 0; i < scaleAmount; ++i) {
- uint index = i *2;
-
- dst[index] = color;
- dst[index + 1] = color2;
- dst[pitch + index] = color;
- dst[pitch + index + 1] = color2;
- }
- dst += 2 * scaleAmount;
- }
- dst += pitch;
- }
- }
+Video::VideoDecoder *ZVision::loadAnimation(const Common::String &fileName) {
+ Common::String tmpFileName = fileName;
+ tmpFileName.toLowercase();
+ Video::VideoDecoder *animation = NULL;
+
+ if (tmpFileName.hasSuffix(".rlf"))
+ animation = new RLFDecoder();
+ else if (tmpFileName.hasSuffix(".avi"))
+ animation = new ZorkAVIDecoder();
+ else
+ error("Unknown suffix for animation %s", fileName.c_str());
+
+ Common::File *_file = getSearchManager()->openFile(tmpFileName);
+ if (!_file)
+ error("Error opening %s", tmpFileName.c_str());
+
+ bool loaded = animation->loadStream(_file);
+ if (!loaded)
+ error("Error loading animation %s", tmpFileName.c_str());
+
+ return animation;
}
-void ZVision::playVideo(Video::VideoDecoder &videoDecoder, const Common::Rect &destRect, bool skippable) {
- byte bytesPerPixel = videoDecoder.getPixelFormat().bytesPerPixel;
-
- uint16 origWidth = videoDecoder.getWidth();
- uint16 origHeight = videoDecoder.getHeight();
-
- uint scale = 1;
+void ZVision::playVideo(Video::VideoDecoder &vid, const Common::Rect &destRect, bool skippable, Subtitle *sub) {
+ Common::Rect dst = destRect;
// If destRect is empty, no specific scaling was requested. However, we may choose to do scaling anyway
- if (destRect.isEmpty()) {
- // Most videos are very small. Therefore we do a simple 2x scale
- if (origWidth * 2 <= 640 && origHeight * 2 <= 480) {
- scale = 2;
- }
- } else {
- // Assume bilinear scaling. AKA calculate the scale from just the width.
- // Also assume that the scaling is in integral intervals. AKA no 1.5x scaling
- // TODO: Test ^these^ assumptions
- scale = destRect.width() / origWidth;
-
- // TODO: Test if we need to support downscale.
- }
-
- uint16 pitch = origWidth * bytesPerPixel;
+ if (dst.isEmpty())
+ dst = Common::Rect(vid.getWidth(), vid.getHeight());
- uint16 finalWidth = origWidth * scale;
- uint16 finalHeight = origHeight * scale;
+ Graphics::Surface *scaled = NULL;
- byte *scaledVideoFrameBuffer = 0;
- if (scale != 1) {
- scaledVideoFrameBuffer = new byte[finalWidth * finalHeight * bytesPerPixel];
+ if (vid.getWidth() != dst.width() || vid.getHeight() != dst.height()) {
+ scaled = new Graphics::Surface;
+ scaled->create(dst.width(), dst.height(), vid.getPixelFormat());
}
- uint16 x = ((WINDOW_WIDTH - finalWidth) / 2) + destRect.left;
- uint16 y = ((WINDOW_HEIGHT - finalHeight) / 2) + destRect.top;
+ uint16 x = _workingWindow.left + dst.left;
+ uint16 y = _workingWindow.top + dst.top;
+ uint16 finalWidth = dst.width() < _workingWindow.width() ? dst.width() : _workingWindow.width();
+ uint16 finalHeight = dst.height() < _workingWindow.height() ? dst.height() : _workingWindow.height();
+ bool showSubs = (_scriptManager->getStateValue(StateKey_Subtitles) == 1);
_clock.stop();
- videoDecoder.start();
+ vid.start();
+ _videoIsPlaying = true;
// Only continue while the video is still playing
- while (!shouldQuit() && !videoDecoder.endOfVideo() && videoDecoder.isPlaying()) {
+ while (!shouldQuit() && !vid.endOfVideo() && vid.isPlaying()) {
// Check for engine quit and video stop key presses
- while (!videoDecoder.endOfVideo() && videoDecoder.isPlaying() && _eventMan->pollEvent(_event)) {
+ while (_eventMan->pollEvent(_event)) {
switch (_event.type) {
case Common::EVENT_KEYDOWN:
switch (_event.kbd.keycode) {
@@ -131,7 +95,7 @@ void ZVision::playVideo(Video::VideoDecoder &videoDecoder, const Common::Rect &d
break;
case Common::KEYCODE_SPACE:
if (skippable) {
- videoDecoder.stop();
+ vid.stop();
}
break;
default:
@@ -142,29 +106,34 @@ void ZVision::playVideo(Video::VideoDecoder &videoDecoder, const Common::Rect &d
}
}
- if (videoDecoder.needsUpdate()) {
- const Graphics::Surface *frame = videoDecoder.decodeNextFrame();
+ if (vid.needsUpdate()) {
+ const Graphics::Surface *frame = vid.decodeNextFrame();
+ if (sub && showSubs)
+ sub->process(vid.getCurFrame());
if (frame) {
- if (scale != 1) {
- scaleBuffer((const byte *)frame->getPixels(), scaledVideoFrameBuffer, origWidth, origHeight, bytesPerPixel, scale);
- _system->copyRectToScreen(scaledVideoFrameBuffer, pitch * 2, x, y, finalWidth, finalHeight);
- } else {
- _system->copyRectToScreen((const byte *)frame->getPixels(), pitch, x, y, finalWidth, finalHeight);
+ if (scaled) {
+ _renderManager->scaleBuffer(frame->getPixels(), scaled->getPixels(), frame->w, frame->h, frame->format.bytesPerPixel, scaled->w, scaled->h);
+ frame = scaled;
}
+ Common::Rect rect = Common::Rect(x, y, x + finalWidth, y + finalHeight);
+ _renderManager->copyToScreen(*frame, rect, 0, 0);
+ _renderManager->processSubs(0);
}
}
// Always update the screen so the mouse continues to render
_system->updateScreen();
- _system->delayMillis(videoDecoder.getTimeToNextFrame());
+ _system->delayMillis(vid.getTimeToNextFrame() / 2);
}
+ _videoIsPlaying = false;
_clock.start();
- if (scale != 1) {
- delete[] scaledVideoFrameBuffer;
+ if (scaled) {
+ scaled->free();
+ delete scaled;
}
}
diff --git a/engines/zvision/video/zork_avi_decoder.cpp b/engines/zvision/video/zork_avi_decoder.cpp
index f22a4203ab..5618250d79 100644
--- a/engines/zvision/video/zork_avi_decoder.cpp
+++ b/engines/zvision/video/zork_avi_decoder.cpp
@@ -29,7 +29,7 @@
#include "common/stream.h"
#include "audio/audiostream.h"
-
+#include "audio/decoders/raw.h"
namespace ZVision {
@@ -42,11 +42,25 @@ void ZorkAVIDecoder::ZorkAVIAudioTrack::queueSound(Common::SeekableReadStream *s
if (_audStream) {
if (_wvInfo.tag == kWaveFormatZorkPCM) {
assert(_wvInfo.size == 8);
- _audStream->queueAudioStream(makeRawZorkStream(stream, _wvInfo.samplesPerSec, _audStream->isStereo(), DisposeAfterUse::YES), DisposeAfterUse::YES);
+ RawChunkStream::RawChunk chunk = decoder->readNextChunk(stream);
+ delete stream;
+
+ if (chunk.data) {
+ byte flags = Audio::FLAG_16BITS | Audio::FLAG_STEREO;
+#ifdef SCUMM_LITTLE_ENDIAN
+ // RawChunkStream produces native endianness int16
+ flags |= Audio::FLAG_LITTLE_ENDIAN;
+#endif
+ _audStream->queueBuffer((byte *)chunk.data, chunk.size, DisposeAfterUse::YES, flags);
+ }
+ } else {
+ AVIAudioTrack::queueSound(stream);
}
- } else {
- delete stream;
}
}
+void ZorkAVIDecoder::ZorkAVIAudioTrack::resetStream() {
+ decoder->init();
+}
+
} // End of namespace ZVision
diff --git a/engines/zvision/video/zork_avi_decoder.h b/engines/zvision/video/zork_avi_decoder.h
index c47f007f9b..89c0d1e4b9 100644
--- a/engines/zvision/video/zork_avi_decoder.h
+++ b/engines/zvision/video/zork_avi_decoder.h
@@ -8,41 +8,53 @@
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
- *
+
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+
* You should have received a copy of the GNU General Public 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 ZORK_AVI_DECODER_H
#define ZORK_AVI_DECODER_H
#include "video/avi_decoder.h"
-
+#include "zvision/sound/zork_raw.h"
namespace ZVision {
class ZorkAVIDecoder : public Video::AVIDecoder {
public:
ZorkAVIDecoder(Audio::Mixer::SoundType soundType = Audio::Mixer::kPlainSoundType) :
- Video::AVIDecoder(soundType) {}
+ Video::AVIDecoder(soundType) {}
- virtual ~ZorkAVIDecoder() {}
+ virtual ~ZorkAVIDecoder() {}
private:
class ZorkAVIAudioTrack : public Video::AVIDecoder::AVIAudioTrack {
public:
ZorkAVIAudioTrack(const AVIStreamHeader &streamHeader, const PCMWaveFormat &waveFormat, Audio::Mixer::SoundType soundType) :
- Video::AVIDecoder::AVIAudioTrack(streamHeader, waveFormat, soundType) {}
- virtual ~ZorkAVIAudioTrack() {}
+ Video::AVIDecoder::AVIAudioTrack(streamHeader, waveFormat, soundType),
+ decoder(NULL) {
+ if (_audStream) {
+ decoder = new RawChunkStream(_audStream->isStereo());
+ }
+ }
+ virtual ~ZorkAVIAudioTrack() {
+ if (decoder)
+ delete decoder;
+ }
void queueSound(Common::SeekableReadStream *stream);
+ void resetStream();
+ private:
+ RawChunkStream *decoder;
};
Video::AVIDecoder::AVIAudioTrack *createAudioTrack(Video::AVIDecoder::AVIStreamHeader sHeader, Video::AVIDecoder::PCMWaveFormat wvInfo);
@@ -50,7 +62,7 @@ private:
private:
// Audio Codecs
enum {
- kWaveFormatZorkPCM = 17 // special Zork PCM audio format (clashes with MS IMA ADPCM)
+ kWaveFormatZorkPCM = 17 // special Zork PCM audio format (clashes with MS IMA ADPCM)
};
};
diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp
index b464f6ee81..54991aced3 100644
--- a/engines/zvision/zvision.cpp
+++ b/engines/zvision/zvision.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.
@@ -23,17 +23,22 @@
#include "common/scummsys.h"
#include "zvision/zvision.h"
-
#include "zvision/core/console.h"
#include "zvision/scripting/script_manager.h"
#include "zvision/graphics/render_manager.h"
-#include "zvision/cursors/cursor_manager.h"
-#include "zvision/core/save_manager.h"
-#include "zvision/strings/string_manager.h"
-#include "zvision/archives/zfs_archive.h"
+#include "zvision/graphics/cursors/cursor_manager.h"
+#include "zvision/file/save_manager.h"
+#include "zvision/text/string_manager.h"
#include "zvision/detection.h"
+#include "zvision/scripting/menu.h"
+#include "zvision/file/search_manager.h"
+#include "zvision/text/text.h"
+#include "zvision/text/truetype_font.h"
+#include "zvision/sound/midi.h"
+#include "zvision/file/zfs_archive.h"
#include "common/config-manager.h"
+#include "common/str.h"
#include "common/debug.h"
#include "common/debug-channels.h"
#include "common/textconsole.h"
@@ -41,28 +46,75 @@
#include "common/system.h"
#include "common/file.h"
+#include "gui/message.h"
#include "engines/util.h"
-
#include "audio/mixer.h"
-
namespace ZVision {
+#define ZVISION_SETTINGS_KEYS_COUNT 11
+
+struct zvisionIniSettings {
+ const char *name;
+ int16 slot;
+ int16 defaultValue; // -1: use the bool value
+ bool defaultBoolValue;
+ bool allowEditing;
+} settingsKeys[ZVISION_SETTINGS_KEYS_COUNT] = {
+ // Hardcoded settings
+ {"countrycode", StateKey_CountryCode, 0, false, false}, // always 0 = US, subtitles are shown for codes 0 - 4, unused
+ {"lineskipvideo", StateKey_VideoLineSkip, 0, false, false}, // video line skip, 0 = default, 1 = always, 2 = pixel double when possible, unused
+ {"installlevel", StateKey_InstallLevel, 0, false, false}, // 0 = full, checked by universe.scr
+ {"highquality", StateKey_HighQuality, -1, true, false}, // high panorama quality, unused
+ {"qsoundenabled", StateKey_Qsound, -1, true, false}, // 1 = enable QSound - TODO: not supported yet
+ {"debugcheats", StateKey_DebugCheats, -1, true, false}, // always start with the GOxxxx cheat enabled
+ // Editable settings
+ {"keyboardturnspeed", StateKey_KbdRotateSpeed, 5, false, true},
+ {"panarotatespeed", StateKey_RotateSpeed, 540, false, true}, // checked by universe.scr
+ {"noanimwhileturning", StateKey_NoTurnAnim, -1, false, true}, // toggle playing animations during pana rotation
+ {"venusenabled", StateKey_VenusEnable, -1, true, true},
+ {"subtitles", StateKey_Subtitles, -1, true, true}
+};
+
ZVision::ZVision(OSystem *syst, const ZVisionGameDescription *gameDesc)
- : Engine(syst),
- _gameDescription(gameDesc),
- _workingWindow(gameDesc->gameId == GID_NEMESIS ? Common::Rect((WINDOW_WIDTH - ZNEM_WORKING_WINDOW_WIDTH) / 2, (WINDOW_HEIGHT - ZNEM_WORKING_WINDOW_HEIGHT) / 2, ((WINDOW_WIDTH - ZNEM_WORKING_WINDOW_WIDTH) / 2) + ZNEM_WORKING_WINDOW_WIDTH, ((WINDOW_HEIGHT - ZNEM_WORKING_WINDOW_HEIGHT) / 2) + ZNEM_WORKING_WINDOW_HEIGHT) :
- Common::Rect((WINDOW_WIDTH - ZGI_WORKING_WINDOW_WIDTH) / 2, (WINDOW_HEIGHT - ZGI_WORKING_WINDOW_HEIGHT) / 2, ((WINDOW_WIDTH - ZGI_WORKING_WINDOW_WIDTH) / 2) + ZGI_WORKING_WINDOW_WIDTH, ((WINDOW_HEIGHT - ZGI_WORKING_WINDOW_HEIGHT) / 2) + ZGI_WORKING_WINDOW_HEIGHT)),
- _pixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0), /*RGB 565*/
- _desiredFrameTime(33), /* ~30 fps */
- _clock(_system),
- _scriptManager(nullptr),
- _renderManager(nullptr),
- _saveManager(nullptr),
- _stringManager(nullptr),
- _cursorManager(nullptr) {
+ : Engine(syst),
+ _gameDescription(gameDesc),
+ _resourcePixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0), /* RGB 555 */
+ _screenPixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0), /* RGB 565 */
+ _desiredFrameTime(33), /* ~30 fps */
+ _clock(_system),
+ _scriptManager(nullptr),
+ _renderManager(nullptr),
+ _saveManager(nullptr),
+ _stringManager(nullptr),
+ _cursorManager(nullptr),
+ _midiManager(nullptr),
+ _rnd(nullptr),
+ _console(nullptr),
+ _menu(nullptr),
+ _searchManager(nullptr),
+ _textRenderer(nullptr),
+ _doubleFPS(false),
+ _audioId(0),
+ _frameRenderDelay(2),
+ _keyboardVelocity(0),
+ _mouseVelocity(0),
+ _videoIsPlaying(false),
+ _renderedFrameCount(0),
+ _fps(0) {
debug(1, "ZVision::ZVision");
+
+ uint16 workingWindowWidth = (gameDesc->gameId == GID_NEMESIS) ? ZNM_WORKING_WINDOW_WIDTH : ZGI_WORKING_WINDOW_WIDTH;
+ uint16 workingWindowHeight = (gameDesc->gameId == GID_NEMESIS) ? ZNM_WORKING_WINDOW_HEIGHT : ZGI_WORKING_WINDOW_HEIGHT;
+ _workingWindow = Common::Rect(
+ (WINDOW_WIDTH - workingWindowWidth) / 2,
+ (WINDOW_HEIGHT - workingWindowHeight) / 2,
+ ((WINDOW_WIDTH - workingWindowWidth) / 2) + workingWindowWidth,
+ ((WINDOW_HEIGHT - workingWindowHeight) / 2) + workingWindowHeight
+ );
+
+ memset(_cheatBuffer, 0, sizeof(_cheatBuffer));
}
ZVision::~ZVision() {
@@ -73,90 +125,192 @@ ZVision::~ZVision() {
delete _cursorManager;
delete _stringManager;
delete _saveManager;
- delete _renderManager;
delete _scriptManager;
+ delete _renderManager; // should be deleted after the script manager
delete _rnd;
+ delete _midiManager;
+
+ getTimerManager()->removeTimerProc(&fpsTimerCallback);
// Remove all of our debug levels
DebugMan.clearAllDebugChannels();
}
+void ZVision::registerDefaultSettings() {
+ for (int i = 0; i < ZVISION_SETTINGS_KEYS_COUNT; i++) {
+ if (settingsKeys[i].allowEditing) {
+ if (settingsKeys[i].defaultValue >= 0)
+ ConfMan.registerDefault(settingsKeys[i].name, settingsKeys[i].defaultValue);
+ else
+ ConfMan.registerDefault(settingsKeys[i].name, settingsKeys[i].defaultBoolValue);
+ }
+ }
+
+ ConfMan.registerDefault("originalsaveload", false);
+ ConfMan.registerDefault("doublefps", false);
+}
+
+void ZVision::loadSettings() {
+ int16 value = 0;
+ bool boolValue = false;
+
+ for (int i = 0; i < ZVISION_SETTINGS_KEYS_COUNT; i++) {
+ if (settingsKeys[i].defaultValue >= 0) {
+ value = (settingsKeys[i].allowEditing) ? ConfMan.getInt(settingsKeys[i].name) : settingsKeys[i].defaultValue;
+ } else {
+ boolValue = (settingsKeys[i].allowEditing) ? ConfMan.getBool(settingsKeys[i].name) : settingsKeys[i].defaultBoolValue;
+ value = (boolValue) ? 1 : 0;
+ }
+
+ _scriptManager->setStateValue(settingsKeys[i].slot, value);
+ }
+
+ if (getGameId() == GID_NEMESIS)
+ _scriptManager->setStateValue(StateKey_ExecScopeStyle, 1);
+ else
+ _scriptManager->setStateValue(StateKey_ExecScopeStyle, 0);
+}
+
+void ZVision::saveSettings() {
+ for (int i = 0; i < ZVISION_SETTINGS_KEYS_COUNT; i++) {
+ if (settingsKeys[i].allowEditing) {
+ if (settingsKeys[i].defaultValue >= 0)
+ ConfMan.setInt(settingsKeys[i].name, _scriptManager->getStateValue(settingsKeys[i].slot));
+ else
+ ConfMan.setBool(settingsKeys[i].name, (_scriptManager->getStateValue(settingsKeys[i].slot) == 1));
+ }
+ }
+
+ ConfMan.flushToDisk();
+}
+
void ZVision::initialize() {
const Common::FSNode gameDataDir(ConfMan.get("path"));
- // TODO: There are 10 file clashes when we flatten the directories.
- // From a quick look, the files are exactly the same, so it shouldn't matter.
- // But I'm noting it here just in-case it does become a problem.
- SearchMan.addSubDirectoryMatching(gameDataDir, "data1", 0, 4, true);
- SearchMan.addSubDirectoryMatching(gameDataDir, "data2", 0, 4, true);
- SearchMan.addSubDirectoryMatching(gameDataDir, "data3", 0, 4, true);
- SearchMan.addSubDirectoryMatching(gameDataDir, "zassets1", 0, 2, true);
- SearchMan.addSubDirectoryMatching(gameDataDir, "zassets2", 0, 2, true);
- SearchMan.addSubDirectoryMatching(gameDataDir, "znemmx", 0, 1, true);
- SearchMan.addSubDirectoryMatching(gameDataDir, "zgi", 0, 4, true);
- SearchMan.addSubDirectoryMatching(gameDataDir, "fonts", 0, 1, true);
-
- // Find zfs archive files
- Common::ArchiveMemberList list;
- SearchMan.listMatchingMembers(list, "*.zfs");
-
- // Register the file entries within the zfs archives with the SearchMan
- for (Common::ArchiveMemberList::iterator iter = list.begin(); iter != list.end(); ++iter) {
- Common::String name = (*iter)->getName();
- Common::SeekableReadStream *stream = (*iter)->createReadStream();
- ZfsArchive *archive = new ZfsArchive(name, stream);
-
- delete stream;
-
- SearchMan.add(name, archive);
- }
- initGraphics(WINDOW_WIDTH, WINDOW_HEIGHT, true, &_pixelFormat);
+ _searchManager = new SearchManager(ConfMan.get("path"), 6);
+
+ _searchManager->addDir("FONTS");
+ _searchManager->addDir("addon");
+
+ if (_gameDescription->gameId == GID_GRANDINQUISITOR) {
+ _searchManager->loadZix("INQUIS.ZIX");
+ _searchManager->addPatch("C000H01Q.RAW", "C000H01Q.SRC");
+ _searchManager->addPatch("CM00H01Q.RAW", "CM00H01Q.SRC");
+ _searchManager->addPatch("DM00H01Q.RAW", "DM00H01Q.SRC");
+ _searchManager->addPatch("E000H01Q.RAW", "E000H01Q.SRC");
+ _searchManager->addPatch("EM00H50Q.RAW", "EM00H50Q.SRC");
+ _searchManager->addPatch("GJNPH65P.RAW", "GJNPH65P.SRC");
+ _searchManager->addPatch("GJNPH72P.RAW", "GJNPH72P.SRC");
+ _searchManager->addPatch("H000H01Q.RAW", "H000H01Q.SRC");
+ _searchManager->addPatch("M000H01Q.RAW", "M000H01Q.SRC");
+ _searchManager->addPatch("P000H01Q.RAW", "P000H01Q.SRC");
+ _searchManager->addPatch("Q000H01Q.RAW", "Q000H01Q.SRC");
+ _searchManager->addPatch("SW00H01Q.RAW", "SW00H01Q.SRC");
+ _searchManager->addPatch("T000H01Q.RAW", "T000H01Q.SRC");
+ _searchManager->addPatch("U000H01Q.RAW", "U000H01Q.SRC");
+ } else if (_gameDescription->gameId == GID_NEMESIS)
+ _searchManager->loadZix("NEMESIS.ZIX");
+
+ initGraphics(WINDOW_WIDTH, WINDOW_HEIGHT, true, &_screenPixelFormat);
// Register random source
_rnd = new Common::RandomSource("zvision");
// Create managers
_scriptManager = new ScriptManager(this);
- _renderManager = new RenderManager(_system, WINDOW_WIDTH, WINDOW_HEIGHT, _workingWindow, _pixelFormat);
+ _renderManager = new RenderManager(this, WINDOW_WIDTH, WINDOW_HEIGHT, _workingWindow, _resourcePixelFormat, _doubleFPS);
_saveManager = new SaveManager(this);
_stringManager = new StringManager(this);
- _cursorManager = new CursorManager(this, &_pixelFormat);
+ _cursorManager = new CursorManager(this, _resourcePixelFormat);
+ _textRenderer = new TextRenderer(this);
+ _midiManager = new MidiManager();
+
+ if (_gameDescription->gameId == GID_GRANDINQUISITOR)
+ _menu = new MenuZGI(this);
+ else
+ _menu = new MenuNemesis(this);
// Initialize the managers
_cursorManager->initialize();
_scriptManager->initialize();
_stringManager->initialize(_gameDescription->gameId);
+ registerDefaultSettings();
+
+ loadSettings();
+
// Create debugger console. It requires GFX to be initialized
_console = new Console(this);
+ _doubleFPS = ConfMan.getBool("doublefps");
+
+ // Initialize FPS timer callback
+ getTimerManager()->installTimerProc(&fpsTimerCallback, 1000000, this, "zvisionFPS");
}
Common::Error ZVision::run() {
initialize();
+ // Check if a saved game is to be loaded from the launcher
+ if (ConfMan.hasKey("save_slot"))
+ _saveManager->loadGame(ConfMan.getInt("save_slot"));
+
+ // Before starting, make absolutely sure that the user has copied the needed fonts
+ if (!Common::File::exists("arial.ttf") && !Common::File::exists("FreeSans.ttf") && !_searchManager->hasFile("arial.ttf") && !_searchManager->hasFile("FreeSans.ttf") ) {
+ GUI::MessageDialog dialog(
+ "Before playing this game, you'll need to copy the required "
+ "fonts into ScummVM's extras directory, or into the game directory. "
+ "On Windows, you'll need the following font files from the Windows "
+ "font directory: Times New Roman, Century Schoolbook, Garamond, "
+ "Courier New and Arial. Alternatively, you can download the GNU "
+ "FreeFont package. You'll need all the fonts from that package, "
+ "i.e., FreeMono, FreeSans and FreeSerif."
+ );
+ dialog.runModal();
+ quitGame();
+ return Common::kUnknownError;
+ }
+
// Main loop
while (!shouldQuit()) {
_clock.update();
uint32 currentTime = _clock.getLastMeasuredTime();
uint32 deltaTime = _clock.getDeltaTime();
+ _cursorManager->setItemID(_scriptManager->getStateValue(StateKey_InventoryItem));
+
processEvents();
+ _renderManager->updateRotation();
- // Call _renderManager->update() first so the background renders
- // before anything that puzzles/controls will render
- _renderManager->update(deltaTime);
_scriptManager->update(deltaTime);
+ _menu->process(deltaTime);
// Render the backBuffer to the screen
- _renderManager->renderBackbufferToScreen();
+ _renderManager->prepareBackground();
+ _renderManager->renderMenuToScreen();
+ _renderManager->processSubs(deltaTime);
+ _renderManager->renderSceneToScreen();
// Update the screen
- _system->updateScreen();
+ if (canRender()) {
+ _system->updateScreen();
+ _renderedFrameCount++;
+ } else {
+ _frameRenderDelay--;
+ }
// Calculate the frame delay based off a desired frame time
int delay = _desiredFrameTime - int32(_system->getMillis() - currentTime);
// Ensure non-negative
delay = delay < 0 ? 0 : delay;
+
+ if (_doubleFPS) {
+ delay >>= 1;
+ }
+
+ if (canSaveGameStateCurrently() && shouldPerformAutoSave(_saveManager->getLastSaveTime())) {
+ _saveManager->autoSave();
+ }
+
_system->delayMillis(delay);
}
@@ -174,11 +328,34 @@ void ZVision::pauseEngineIntern(bool pause) {
}
Common::String ZVision::generateSaveFileName(uint slot) {
- return Common::String::format("%s.%02u", _targetName.c_str(), slot);
+ return Common::String::format("%s.%03u", _targetName.c_str(), slot);
+}
+
+void ZVision::setRenderDelay(uint delay) {
+ _frameRenderDelay = delay;
+}
+
+bool ZVision::canRender() {
+ return _frameRenderDelay <= 0;
+}
+
+GUI::Debugger *ZVision::getDebugger() {
+ return _console;
+}
+
+void ZVision::syncSoundSettings() {
+ Engine::syncSoundSettings();
+
+ _scriptManager->setStateValue(StateKey_Subtitles, ConfMan.getBool("subtitles") ? 1 : 0);
+}
+
+void ZVision::fpsTimerCallback(void *refCon) {
+ ((ZVision *)refCon)->fpsTimer();
}
-Common::String ZVision::generateAutoSaveFileName() {
- return Common::String::format("%s.auto", _targetName.c_str());
+void ZVision::fpsTimer() {
+ _fps = _renderedFrameCount;
+ _renderedFrameCount = 0;
}
} // End of namespace ZVision
diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h
index 0b5a86f370..ad22ddaaa2 100644
--- a/engines/zvision/zvision.h
+++ b/engines/zvision/zvision.h
@@ -8,24 +8,25 @@
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
- *
+
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+
* You should have received a copy of the GNU General Public 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 ZVISION_ZVISION_H
#define ZVISION_ZVISION_H
-#include "zvision/core/console.h"
#include "zvision/detection.h"
-#include "zvision/utility/clock.h"
+#include "zvision/core/clock.h"
+#include "zvision/file/search_manager.h"
#include "common/random.h"
#include "common/events.h"
@@ -36,20 +37,35 @@
#include "gui/debugger.h"
-
namespace Video {
class VideoDecoder;
}
+/**
+ * This is the namespace of the ZVision engine.
+ *
+ * Status of this engine: complete
+ *
+ * Games using this engine:
+ * - Zork Nemesis: The Forbidden Lands
+ * - Zork: Grand Inquisitor
+ *
+ */
+
namespace ZVision {
struct ZVisionGameDescription;
+class Console;
class ScriptManager;
class RenderManager;
class CursorManager;
class StringManager;
class SaveManager;
-class RlfAnimation;
+class RLFDecoder;
+class MenuHandler;
+class TextRenderer;
+class Subtitle;
+class MidiManager;
class ZVision : public Engine {
public:
@@ -62,24 +78,27 @@ public:
* are given in this coordinate space. Also, all images are clipped to the
* edges of this Rectangle
*/
- const Common::Rect _workingWindow;
- const Graphics::PixelFormat _pixelFormat;
+ Common::Rect _workingWindow;
+ const Graphics::PixelFormat _resourcePixelFormat;
+ const Graphics::PixelFormat _screenPixelFormat;
private:
enum {
WINDOW_WIDTH = 640,
WINDOW_HEIGHT = 480,
- //Zork nemesis working window sizes
- ZNEM_WORKING_WINDOW_WIDTH = 512,
- ZNEM_WORKING_WINDOW_HEIGHT = 320,
+ // Zork nemesis working window sizes
+ ZNM_WORKING_WINDOW_WIDTH = 512,
+ ZNM_WORKING_WINDOW_HEIGHT = 320,
- //ZGI(and default) working window sizes
- ZGI_WORKING_WINDOW_WIDTH = 640,
+ // ZGI working window sizes
+ ZGI_WORKING_WINDOW_WIDTH = 640,
ZGI_WORKING_WINDOW_HEIGHT = 344,
ROTATION_SCREEN_EDGE_OFFSET = 60,
- MAX_ROTATION_SPEED = 400 // Pixels per second
+ MAX_ROTATION_SPEED = 400, // Pixels per second
+
+ KEYBUF_SIZE = 20
};
Console *_console;
@@ -96,27 +115,84 @@ private:
CursorManager *_cursorManager;
SaveManager *_saveManager;
StringManager *_stringManager;
+ MenuHandler *_menu;
+ SearchManager *_searchManager;
+ TextRenderer *_textRenderer;
+ MidiManager *_midiManager;
// Clock
Clock _clock;
+ // Audio ID
+ int _audioId;
+
// To prevent allocation every time we process events
Common::Event _event;
+ int _frameRenderDelay;
+ int _renderedFrameCount;
+ int _fps;
+ int16 _mouseVelocity;
+ int16 _keyboardVelocity;
+ bool _doubleFPS;
+ bool _videoIsPlaying;
+
+ uint8 _cheatBuffer[KEYBUF_SIZE];
public:
uint32 getFeatures() const;
Common::Language getLanguage() const;
Common::Error run();
void pauseEngineIntern(bool pause);
- ScriptManager *getScriptManager() const { return _scriptManager; }
- RenderManager *getRenderManager() const { return _renderManager; }
- CursorManager *getCursorManager() const { return _cursorManager; }
- SaveManager *getSaveManager() const { return _saveManager; }
- StringManager *getStringManager() const { return _stringManager; }
- Common::RandomSource *getRandomSource() const { return _rnd; }
- ZVisionGameId getGameId() const { return _gameDescription->gameId; }
- GUI::Debugger *getDebugger() { return _console; }
+ ScriptManager *getScriptManager() const {
+ return _scriptManager;
+ }
+ RenderManager *getRenderManager() const {
+ return _renderManager;
+ }
+ CursorManager *getCursorManager() const {
+ return _cursorManager;
+ }
+ SaveManager *getSaveManager() const {
+ return _saveManager;
+ }
+ StringManager *getStringManager() const {
+ return _stringManager;
+ }
+ SearchManager *getSearchManager() const {
+ return _searchManager;
+ }
+ TextRenderer *getTextRenderer() const {
+ return _textRenderer;
+ }
+ MidiManager *getMidiManager() const {
+ return _midiManager;
+ }
+ MenuHandler *getMenuHandler() const {
+ return _menu;
+ }
+ Common::RandomSource *getRandomSource() const {
+ return _rnd;
+ }
+ ZVisionGameId getGameId() const {
+ return _gameDescription->gameId;
+ }
+ int16 getKeyboardVelocity() const {
+ return _keyboardVelocity;
+ }
+ int16 getMouseVelocity() const {
+ return _mouseVelocity;
+ }
+
+ uint8 getZvisionKey(Common::KeyCode scummKeyCode);
+
+ void startClock() {
+ _clock.start();
+ }
+
+ void stopClock() {
+ _clock.stop();
+ }
/**
* Play a video until it is finished. This is a blocking call. It will call
@@ -127,11 +203,33 @@ public:
* @param destRect Where to put the video. (In working window coords)
* @param skippable If true, the video can be skipped at any time using [Spacebar]
*/
- void playVideo(Video::VideoDecoder &videoDecoder, const Common::Rect &destRect = Common::Rect(0, 0, 0, 0), bool skippable = true);
+ void playVideo(Video::VideoDecoder &videoDecoder, const Common::Rect &destRect = Common::Rect(0, 0, 0, 0), bool skippable = true, Subtitle *sub = NULL);
+ Video::VideoDecoder *loadAnimation(const Common::String &fileName);
Common::String generateSaveFileName(uint slot);
- Common::String generateAutoSaveFileName();
+ void setRenderDelay(uint);
+ bool canRender();
+ static void fpsTimerCallback(void *refCon);
+ void fpsTimer();
+ int getFPS() const {
+ return _fps;
+ }
+
+ GUI::Debugger *getDebugger();
+ void syncSoundSettings();
+
+ void loadSettings();
+ void saveSettings();
+
+ bool ifQuit();
+
+ // Engine features
+ bool hasFeature(EngineFeature f) const;
+ bool canLoadGameStateCurrently();
+ bool canSaveGameStateCurrently();
+ Common::Error loadGameState(int slot);
+ Common::Error saveGameState(int slot, const Common::String &desc);
private:
void initialize();
void initFonts();
@@ -141,9 +239,15 @@ private:
/** Called every frame from ZVision::run() to process any events from EventMan */
void processEvents();
- void onMouseDown(const Common::Point &pos);
- void onMouseUp(const Common::Point &pos);
void onMouseMove(const Common::Point &pos);
+
+ void registerDefaultSettings();
+ void shortKeys(Common::Event);
+
+ void cheatCodes(uint8 key);
+ void pushKeyToCheatBuf(uint8 key);
+ bool checkCode(const char *code);
+ uint8 getBufferedKey(uint8 pos);
};
} // End of namespace ZVision
diff --git a/graphics/VectorRenderer.h b/graphics/VectorRenderer.h
index 703da68182..6b657f758d 100644
--- a/graphics/VectorRenderer.h
+++ b/graphics/VectorRenderer.h
@@ -105,7 +105,7 @@ VectorRenderer *createRenderer(int mode);
*/
class VectorRenderer {
public:
- VectorRenderer() : _activeSurface(NULL), _fillMode(kFillDisabled), _shadowOffset(0), _shadowFillMode(kShadowExponential),
+ VectorRenderer() : _activeSurface(NULL), _fillMode(kFillDisabled), _shadowOffset(0), _shadowFillMode(kShadowExponential),
_disableShadows(false), _strokeWidth(1), _gradientFactor(1) {
}
diff --git a/graphics/VectorRendererSpec.cpp b/graphics/VectorRendererSpec.cpp
index a9594f7dd2..81a0c04441 100644
--- a/graphics/VectorRendererSpec.cpp
+++ b/graphics/VectorRendererSpec.cpp
@@ -1134,7 +1134,7 @@ void VectorRendererSpec<PixelType>::
drawTabShadow(int x1, int y1, int w, int h, int r) {
int offset = 3;
int pitch = _activeSurface->pitch / _activeSurface->format.bytesPerPixel;
-
+
// "Harder" shadows when having lower BPP, since we will have artifacts (greenish tint on the modern theme)
uint8 expFactor = 3;
uint16 alpha = (_activeSurface->format.bytesPerPixel > 2) ? 4 : 8;
@@ -1162,7 +1162,7 @@ drawTabShadow(int x1, int y1, int w, int h, int r) {
// this is ok on filled circles, but when blending on surfaces,
// we cannot let it blend twice. awful.
uint32 hb = 0;
-
+
while (x++ < y) {
BE_ALGORITHM();
@@ -1176,7 +1176,7 @@ drawTabShadow(int x1, int y1, int w, int h, int r) {
hb |= (1 << y);
}
}
-
+
ptr_fill += pitch * r;
while (short_h--) {
blendFill(ptr_fill, ptr_fill + width + 1, color, (uint8)alpha);
@@ -1189,7 +1189,7 @@ drawTabShadow(int x1, int y1, int w, int h, int r) {
alpha = (alpha * (expFactor << 8)) >> 9;
}
}
-
+
/** BEVELED TABS FOR CLASSIC THEME **/
template<typename PixelType>
void VectorRendererSpec<PixelType>::
@@ -1647,7 +1647,7 @@ drawBorderRoundedSquareAlg(int x1, int y1, int r, int w, int h, PixelType color,
BE_RESET();
r--;
-
+
int alphaStep_tr = ((alpha_t - alpha_r)/(y+1));
int alphaStep_br = ((alpha_r - alpha_b)/(y+1));
int alphaStep_bl = ((alpha_b - alpha_l)/(y+1));
@@ -1657,16 +1657,16 @@ drawBorderRoundedSquareAlg(int x1, int y1, int r, int w, int h, PixelType color,
while (x++ < (y - 2)) {
BE_ALGORITHM();
- BE_DRAWCIRCLE_BCOLOR_TR_CW(ptr_tr, x, y, px, py, (uint8)(alpha_r + (alphaStep_tr * x)));
+ BE_DRAWCIRCLE_BCOLOR_TR_CW(ptr_tr, x, y, px, py, (uint8)(alpha_r + (alphaStep_tr * x)));
BE_DRAWCIRCLE_BCOLOR_BR_CW(ptr_br, x, y, px, py, (uint8)(alpha_b + (alphaStep_br * x)));
BE_DRAWCIRCLE_BCOLOR_BL_CW(ptr_bl, x, y, px, py, (uint8)(alpha_l + (alphaStep_bl * x)));
BE_DRAWCIRCLE_BCOLOR_TL_CW(ptr_tl, x, y, px, py, (uint8)(alpha_t + (alphaStep_tl * x)));
-
+
BE_DRAWCIRCLE_BCOLOR_TR_CCW(ptr_tr, x, y, px, py, (uint8)(alpha_t - (alphaStep_tr * x)));
BE_DRAWCIRCLE_BCOLOR_BR_CCW(ptr_br, x, y, px, py, (uint8)(alpha_r - (alphaStep_br * x)));
BE_DRAWCIRCLE_BCOLOR_BL_CCW(ptr_bl, x, y, px, py, (uint8)(alpha_b - (alphaStep_bl * x)));
BE_DRAWCIRCLE_BCOLOR_TL_CCW(ptr_tl, x, y, px, py, (uint8)(alpha_l - (alphaStep_tl * x)));
-
+
if (Base::_strokeWidth > 1) {
BE_DRAWCIRCLE_BCOLOR(ptr_tr, ptr_tl, ptr_bl, ptr_br, x - 1, y, px, py);
BE_DRAWCIRCLE_BCOLOR(ptr_tr, ptr_tl, ptr_bl, ptr_br, x, y, px - pitch, py);
@@ -1754,7 +1754,7 @@ void VectorRendererSpec<PixelType>::
drawRoundedSquareAlg(int x1, int y1, int r, int w, int h, PixelType color, VectorRenderer::FillMode fill_m) {
const uint8 borderAlpha_t = 0;
const uint8 borderAlpha_r = 127;
- const uint8 borderAlpha_b = 255;
+ const uint8 borderAlpha_b = 255;
const uint8 borderAlpha_l = 63;
const uint8 bevelAlpha_t = 255;
@@ -1876,7 +1876,7 @@ drawRoundedSquareShadow(int x1, int y1, int r, int w, int h, int offset) {
// "Harder" shadows when having lower BPP, since we will have artifacts (greenish tint on the modern theme)
uint8 expFactor = 3;
uint16 alpha = (_activeSurface->format.bytesPerPixel > 2) ? 4 : 8;
-
+
// These constants ensure a border of 2px on the left and of each rounded square
int xstart = (x1 > 2) ? x1 - 2 : x1;
int ystart = y1;
@@ -1886,7 +1886,7 @@ drawRoundedSquareShadow(int x1, int y1, int r, int w, int h, int offset) {
for (int i = offset; i >= 0; i--) {
int f, ddF_x, ddF_y;
int x, y, px, py;
-
+
PixelType *ptr_tl = (PixelType *)Base::_activeSurface->getBasePtr(xstart + r, ystart + r);
PixelType *ptr_tr = (PixelType *)Base::_activeSurface->getBasePtr(xstart + width - r, ystart + r);
PixelType *ptr_bl = (PixelType *)Base::_activeSurface->getBasePtr(xstart + r, ystart + height - r);
@@ -1903,14 +1903,14 @@ drawRoundedSquareShadow(int x1, int y1, int r, int w, int h, int offset) {
// this is ok on filled circles, but when blending on surfaces,
// we cannot let it blend twice. awful.
uint32 hb = 0;
-
+
while (x++ < y) {
BE_ALGORITHM();
if (((1 << x) & hb) == 0) {
blendFill(ptr_tl - y - px, ptr_tr + y - px, color, (uint8)alpha);
-
+
// Will create a dark line of pixles if left out
if (hb > 0) {
blendFill(ptr_bl - y + px, ptr_br + y + px, color, (uint8)alpha);
@@ -1924,7 +1924,7 @@ drawRoundedSquareShadow(int x1, int y1, int r, int w, int h, int offset) {
hb |= (1 << y);
}
}
-
+
ptr_fill += pitch * r;
while (short_h--) {
blendFill(ptr_fill, ptr_fill + width + 1, color, (uint8)alpha);
@@ -1936,7 +1936,7 @@ drawRoundedSquareShadow(int x1, int y1, int r, int w, int h, int offset) {
ystart += 1;
width -= 2;
height -= 2;
-
+
if (_shadowFillMode == kShadowExponential)
// Multiply with expfactor
alpha = (alpha * (expFactor << 8)) >> 9;
@@ -2178,14 +2178,14 @@ drawBorderRoundedSquareAlg(int x1, int y1, int r, int w, int h, PixelType color,
// only when the inside isn't filled
if (sw != strokeWidth || fill_m != Base::kFillDisabled)
a2 = 255;
-
- // inner arc
- WU_DRAWCIRCLE_BCOLOR_TR_CW(ptr_tr, (x - 1), y, (px - pitch), py, (uint8)((uint32)(((alpha_t - (alphaStep_tr * y)) << 8) * a2) >> 16));
+
+ // inner arc
+ WU_DRAWCIRCLE_BCOLOR_TR_CW(ptr_tr, (x - 1), y, (px - pitch), py, (uint8)((uint32)(((alpha_t - (alphaStep_tr * y)) << 8) * a2) >> 16));
WU_DRAWCIRCLE_BCOLOR_BR_CW(ptr_br, (x - 1), y, (px - pitch), py, (uint8)((uint32)(((alpha_r - (alphaStep_br * y)) << 8) * a2) >> 16));
WU_DRAWCIRCLE_BCOLOR_BL_CW(ptr_bl, (x - 1), y, (px - pitch), py, (uint8)((uint32)(((alpha_b - (alphaStep_bl * y)) << 8) * a2) >> 16));
WU_DRAWCIRCLE_BCOLOR_TL_CW(ptr_tl, (x - 1), y, (px - pitch), py, (uint8)((uint32)(((alpha_l - (alphaStep_tl * y)) << 8) * a2) >> 16));
-
- WU_DRAWCIRCLE_BCOLOR_TR_CCW(ptr_tr, (x - 1), y, (px - pitch), py, (uint8)((uint32)(((alpha_r + (alphaStep_tr * y)) << 8) * a2) >> 16));
+
+ WU_DRAWCIRCLE_BCOLOR_TR_CCW(ptr_tr, (x - 1), y, (px - pitch), py, (uint8)((uint32)(((alpha_r + (alphaStep_tr * y)) << 8) * a2) >> 16));
WU_DRAWCIRCLE_BCOLOR_BR_CCW(ptr_br, (x - 1), y, (px - pitch), py, (uint8)((uint32)(((alpha_b + (alphaStep_br * y)) << 8) * a2) >> 16));
WU_DRAWCIRCLE_BCOLOR_BL_CCW(ptr_bl, (x - 1), y, (px - pitch), py, (uint8)((uint32)(((alpha_l + (alphaStep_bl * y)) << 8) * a2) >> 16));
WU_DRAWCIRCLE_BCOLOR_TL_CCW(ptr_tl, (x - 1), y, (px - pitch), py, (uint8)((uint32)(((alpha_t + (alphaStep_tl * y)) << 8) * a2) >> 16));
@@ -2196,8 +2196,8 @@ drawBorderRoundedSquareAlg(int x1, int y1, int r, int w, int h, PixelType color,
WU_DRAWCIRCLE_BCOLOR_BR_CW(ptr_br, x, y, px, py, (uint8)((uint32)(((alpha_r - (alphaStep_br * y)) << 8) * a1) >> 16));
WU_DRAWCIRCLE_BCOLOR_BL_CW(ptr_bl, x, y, px, py, (uint8)((uint32)(((alpha_b - (alphaStep_bl * y)) << 8) * a1) >> 16));
WU_DRAWCIRCLE_BCOLOR_TL_CW(ptr_tl, x, y, px, py, (uint8)((uint32)(((alpha_l - (alphaStep_tl * y)) << 8) * a1) >> 16));
-
- WU_DRAWCIRCLE_BCOLOR_TR_CCW(ptr_tr, x, y, px, py, (uint8)((uint32)(((alpha_r + (alphaStep_tr * y)) << 8) * a1) >> 16));
+
+ WU_DRAWCIRCLE_BCOLOR_TR_CCW(ptr_tr, x, y, px, py, (uint8)((uint32)(((alpha_r + (alphaStep_tr * y)) << 8) * a1) >> 16));
WU_DRAWCIRCLE_BCOLOR_BR_CCW(ptr_br, x, y, px, py, (uint8)((uint32)(((alpha_b + (alphaStep_br * y)) << 8) * a1) >> 16));
WU_DRAWCIRCLE_BCOLOR_BL_CCW(ptr_bl, x, y, px, py, (uint8)((uint32)(((alpha_l + (alphaStep_bl * y)) << 8) * a1) >> 16));
WU_DRAWCIRCLE_BCOLOR_TL_CCW(ptr_tl, x, y, px, py, (uint8)((uint32)(((alpha_t + (alphaStep_tl * y)) << 8) * a1) >> 16));
@@ -2220,7 +2220,7 @@ drawInteriorRoundedSquareAlg(int x1, int y1, int r, int w, int h, PixelType colo
int x, y;
const int pitch = Base::_activeSurface->pitch / Base::_activeSurface->format.bytesPerPixel;
int px, py;
-
+
uint32 rsq = r*r;
frac_t T = 0, oldT;
uint8 a1, a2;
@@ -2318,14 +2318,14 @@ void VectorRendererAA<PixelType>::
drawRoundedSquareAlg(int x1, int y1, int r, int w, int h, PixelType color, VectorRenderer::FillMode fill_m) {
const uint8 borderAlpha_t = 0;
const uint8 borderAlpha_r = 127;
- const uint8 borderAlpha_b = 255;
+ const uint8 borderAlpha_b = 255;
const uint8 borderAlpha_l = 63;
const uint8 bevelAlpha_t = 255;
const uint8 bevelAlpha_r = 31;
const uint8 bevelAlpha_b = 0;
const uint8 bevelAlpha_l = 127;
-
+
if (Base::_strokeWidth) {
if (r != 0 && Base::_bevel > 0) {
drawBorderRoundedSquareAlg(x1, y1, r, w, h, color, fill_m, borderAlpha_t, borderAlpha_r, borderAlpha_b, borderAlpha_l);
@@ -2334,7 +2334,7 @@ drawRoundedSquareAlg(int x1, int y1, int r, int w, int h, PixelType color, Vecto
drawBorderRoundedSquareAlg(x1, y1, r, w, h, color, fill_m, 255, 255, 255, 255);
}
}
-
+
// If only border is visible
if ((!(w <= 0 || h <= 0)) && (fill_m != Base::kFillDisabled)) {
if (fill_m == Base::kFillBackground)
diff --git a/graphics/VectorRendererSpec.h b/graphics/VectorRendererSpec.h
index c035ca0e19..f47cc3997a 100644
--- a/graphics/VectorRendererSpec.h
+++ b/graphics/VectorRendererSpec.h
@@ -301,7 +301,7 @@ protected:
virtual void drawRoundedSquareAlg(int x1, int y1, int r, int w, int h, PixelType color, VectorRenderer::FillMode fill_m);
virtual void drawBorderRoundedSquareAlg(int x1, int y1, int r, int w, int h, PixelType color, VectorRenderer::FillMode fill_m, uint8 alpha_t, uint8 alpha_l, uint8 alpha_r, uint8 alpha_b);
-
+
virtual void drawInteriorRoundedSquareAlg(int x1, int y1, int r, int w, int h, PixelType color, VectorRenderer::FillMode fill_m);
virtual void drawRoundedSquareShadow(int x, int y, int r, int w, int h, int offset) {
diff --git a/graphics/surface.h b/graphics/surface.h
index ad15944361..aaa386b168 100644
--- a/graphics/surface.h
+++ b/graphics/surface.h
@@ -228,7 +228,7 @@ public:
* @param srcSurface The source of the bitmap data
* @param destX The x coordinate of the destination rectangle
* @param destY The y coordinate of the destination rectangle
- * @param subRect The subRect of surface to be blitted
+ * @param subRect The subRect of surface to be blitted
*/
void copyRectToSurface(const Graphics::Surface &srcSurface, int destX, int destY, const Common::Rect subRect);
diff --git a/graphics/transform_struct.h b/graphics/transform_struct.h
index 640daf9f4c..1d37492de4 100644
--- a/graphics/transform_struct.h
+++ b/graphics/transform_struct.h
@@ -48,7 +48,7 @@ const int32 kDefaultHotspotX = 0;
const int32 kDefaultHotspotY = 0;
const int32 kDefaultOffsetX = 0;
const int32 kDefaultOffsetY = 0;
-const int32 kDefaultAngle = 0;
+const int32 kDefaultAngle = 0;
struct TransformStruct {
private:
diff --git a/graphics/transform_tools.h b/graphics/transform_tools.h
index a51c8ee229..ec739f9ad0 100644
--- a/graphics/transform_tools.h
+++ b/graphics/transform_tools.h
@@ -28,7 +28,7 @@
namespace Graphics {
- static const float kEpsilon = 0.00001; // arbitrarily taken number
+ static const float kEpsilon = 0.00001f; // arbitrarily taken number
struct FloatPoint {
float x;
diff --git a/gui/EventRecorder.cpp b/gui/EventRecorder.cpp
index ab284aaa6e..d0371f5e78 100644
--- a/gui/EventRecorder.cpp
+++ b/gui/EventRecorder.cpp
@@ -49,7 +49,6 @@ namespace GUI {
const int kMaxRecordsNames = 0x64;
const int kDefaultScreenshotPeriod = 60000;
-const int kDefaultBPP = 2;
uint32 readTime(Common::ReadStream *inFile) {
uint32 d = inFile->readByte();
diff --git a/gui/about.cpp b/gui/about.cpp
index fe726df750..b25efc1cd0 100644
--- a/gui/about.cpp
+++ b/gui/about.cpp
@@ -241,7 +241,7 @@ void AboutDialog::drawDialog() {
while (*str && *str == ' ')
str++;
- if (*str)
+ if (*str)
g_gui.theme()->drawText(Common::Rect(_x + _xOff, y, _x + _w - _xOff, y + g_gui.theme()->getFontHeight()), str, state, align, ThemeEngine::kTextInversionNone, 0, false, ThemeEngine::kFontStyleBold, ThemeEngine::kFontColorNormal, true, _textDrawableArea);
y += _lineHeight;
}
diff --git a/gui/browser_osx.mm b/gui/browser_osx.mm
index 0e80410032..18cbd134f3 100644
--- a/gui/browser_osx.mm
+++ b/gui/browser_osx.mm
@@ -154,7 +154,11 @@ int BrowserDialog::runModal() {
[showHiddenFilesButton setAction:@selector(showHiddenFiles:)];
}
+#if MAC_OS_X_VERSION_MAX_ALLOWED <= 1090
if ([panel runModal] == NSOKButton) {
+#else
+ if ([panel runModal] == NSModalResponseOK) {
+#endif
NSURL *url = [panel URL];
if ([url isFileURL]) {
const char *filename = [[url path] UTF8String];
diff --git a/gui/credits.h b/gui/credits.h
index e32a0705bf..c7d9199db9 100644
--- a/gui/credits.h
+++ b/gui/credits.h
@@ -320,9 +320,12 @@ static const char *credits[] = {
"C1""Wintermute",
"A0""Einar Johan T. Somaaen",
"C0""Einar Johan T. S\370m\345en",
+"C0""Tobia Tesan",
"",
"C1""ZVision",
"C0""Adrian Astley",
+"C0""Filippos Karapetis",
+"C0""Anton Yarcev",
"",
"",
"C1""Backend Teams",
@@ -629,6 +632,18 @@ static const char *credits[] = {
"C0""Alejandro G\363mez de la Mu\361oza",
"C2""Soltys Spanish translation",
"",
+"C1""CGE2",
+"A0""Arnaud Boutonne",
+"C0""Arnaud Boutonn\351",
+"C2""Sfinx English translation",
+"C0""Thierry Crozat",
+"C2""Sfinx English translation",
+"A0""Peter Bozso",
+"C0""Peter Bozs\363",
+"C2""Sfinx English translation editor",
+"C0""Ryan Clark",
+"C2""Sfinx English translation editor",
+"",
"C1""Drascula",
"C0""Thierry Crozat",
"C2""Improve French translation",
@@ -810,7 +825,7 @@ static const char *credits[] = {
"C0""DOSBox Team",
"C2""For their awesome OPL2 and OPL3 emulator",
"C0""Yusuke Kamiyamane",
-"C2""For contributing some GUI icons ",
+"C2""For contributing some GUI icons",
"C0""Till Kresslein",
"C2""For design of modern ScummVM GUI",
"C0""Jezar",
@@ -850,7 +865,7 @@ static const char *credits[] = {
"C0""",
"C0""Neil Dodwell and David Dew from Creative Reality for providing the source of Dreamweb and for their tremendous support.",
"C0""",
-"C0""Janusz Wisniewski and Miroslaw Liminowicz from Laboratorium Komputerowe Avalon for providing full source code for Soltys and letting us redistribute the game.",
+"C0""Janusz Wisniewski and Miroslaw Liminowicz from Laboratorium Komputerowe Avalon for providing full source code for Soltys and Sfinx and letting us redistribute the games.",
"C0""",
"C0""Jan Nedoma for providing the sources to the Wintermute-engine, and for his support while porting the engine to ScummVM.",
"C0""",
diff --git a/gui/debugger.cpp b/gui/debugger.cpp
index dcdc18d7b9..466681e89d 100644
--- a/gui/debugger.cpp
+++ b/gui/debugger.cpp
@@ -27,6 +27,13 @@
#include "common/debug-channels.h"
#include "common/system.h"
+#ifndef DISABLE_MD5
+#include "common/md5.h"
+#include "common/archive.h"
+#include "common/macresman.h"
+#include "common/stream.h"
+#endif
+
#include "engines/engine.h"
#include "gui/debugger.h"
@@ -61,6 +68,10 @@ Debugger::Debugger() {
registerCmd("help", WRAP_METHOD(Debugger, cmdHelp));
registerCmd("openlog", WRAP_METHOD(Debugger, cmdOpenLog));
+#ifndef DISABLE_MD5
+ registerCmd("md5", WRAP_METHOD(Debugger, cmdMd5));
+ registerCmd("md5mac", WRAP_METHOD(Debugger, cmdMd5Mac));
+#endif
registerCmd("debuglevel", WRAP_METHOD(Debugger, cmdDebugLevel));
registerCmd("debugflag_list", WRAP_METHOD(Debugger, cmdDebugFlagsList));
@@ -502,6 +513,104 @@ bool Debugger::cmdOpenLog(int argc, const char **argv) {
return true;
}
+#ifndef DISABLE_MD5
+struct ArchiveMemberLess {
+ bool operator()(const Common::ArchiveMemberPtr &x, const Common::ArchiveMemberPtr &y) const {
+ return (*x).getDisplayName().compareToIgnoreCase((*y).getDisplayName()) < 0;
+ }
+};
+
+bool Debugger::cmdMd5(int argc, const char **argv) {
+ if (argc < 2) {
+ debugPrintf("md5 [-n length] <filename | pattern>\n");
+ } else {
+ uint32 length = 0;
+ uint paramOffset = 0;
+
+ // If the user supplied an -n parameter, set the bytes to read
+ if (!strcmp(argv[1], "-n")) {
+ // Make sure that we have at least two more parameters
+ if (argc < 4) {
+ debugPrintf("md5 [-n length] <filename | pattern>\n");
+ return true;
+ }
+ length = atoi(argv[2]);
+ paramOffset = 2;
+ }
+
+ // Assume that spaces are part of a single filename.
+ Common::String filename = argv[1 + paramOffset];
+ for (int i = 2 + paramOffset; i < argc; i++) {
+ filename = filename + " " + argv[i];
+ }
+ Common::ArchiveMemberList list;
+ SearchMan.listMatchingMembers(list, filename);
+ if (list.empty()) {
+ debugPrintf("File '%s' not found\n", filename.c_str());
+ } else {
+ sort(list.begin(), list.end(), ArchiveMemberLess());
+ for (Common::ArchiveMemberList::iterator iter = list.begin(); iter != list.end(); ++iter) {
+ Common::SeekableReadStream *stream = (*iter)->createReadStream();
+ Common::String md5 = Common::computeStreamMD5AsString(*stream, length);
+ debugPrintf("%s %s %d\n", md5.c_str(), (*iter)->getDisplayName().c_str(), stream->size());
+ delete stream;
+ }
+ }
+ }
+ return true;
+}
+
+bool Debugger::cmdMd5Mac(int argc, const char **argv) {
+ if (argc < 2) {
+ debugPrintf("md5mac [-n length] <base filename>\n");
+ } else {
+ uint32 length = 0;
+ uint paramOffset = 0;
+
+ // If the user supplied an -n parameter, set the bytes to read
+ if (!strcmp(argv[1], "-n")) {
+ // Make sure that we have at least two more parameters
+ if (argc < 4) {
+ debugPrintf("md5mac [-n length] <base filename>\n");
+ return true;
+ }
+ length = atoi(argv[2]);
+ paramOffset = 2;
+ }
+
+ // Assume that spaces are part of a single filename.
+ Common::String filename = argv[1 + paramOffset];
+ for (int i = 2 + paramOffset; i < argc; i++) {
+ filename = filename + " " + argv[i];
+ }
+ Common::MacResManager macResMan;
+ // FIXME: There currently isn't any way to tell the Mac resource
+ // manager to open a specific file. Instead, it takes a "base name"
+ // and constructs a file name out of that. While usually a desirable
+ // thing, it's not ideal here.
+ if (!macResMan.open(filename)) {
+ debugPrintf("Resource file '%s' not found\n", filename.c_str());
+ } else {
+ if (!macResMan.hasResFork() && !macResMan.hasDataFork()) {
+ debugPrintf("'%s' has neither data not resource fork\n", macResMan.getBaseFileName().c_str());
+ } else {
+ // The resource fork is probably the most relevant one.
+ if (macResMan.hasResFork()) {
+ Common::String md5 = macResMan.computeResForkMD5AsString(length);
+ debugPrintf("%s %s (resource) %d\n", md5.c_str(), macResMan.getBaseFileName().c_str(), macResMan.getResForkDataSize());
+ }
+ if (macResMan.hasDataFork()) {
+ Common::SeekableReadStream *stream = macResMan.getDataFork();
+ Common::String md5 = Common::computeStreamMD5AsString(*stream, length);
+ debugPrintf("%s %s (data) %d\n", md5.c_str(), macResMan.getBaseFileName().c_str(), stream->size());
+ }
+ }
+ macResMan.close();
+ }
+ }
+ return true;
+}
+#endif
bool Debugger::cmdDebugLevel(int argc, const char **argv) {
if (argc == 1) { // print level
diff --git a/gui/debugger.h b/gui/debugger.h
index 175eb33960..ef6f900974 100644
--- a/gui/debugger.h
+++ b/gui/debugger.h
@@ -213,6 +213,10 @@ protected:
bool cmdExit(int argc, const char **argv);
bool cmdHelp(int argc, const char **argv);
bool cmdOpenLog(int argc, const char **argv);
+#ifndef DISABLE_MD5
+ bool cmdMd5(int argc, const char **argv);
+ bool cmdMd5Mac(int argc, const char **argv);
+#endif
bool cmdDebugLevel(int argc, const char **argv);
bool cmdDebugFlagsList(int argc, const char **argv);
bool cmdDebugFlagEnable(int argc, const char **argv);
diff --git a/gui/saveload-dialog.cpp b/gui/saveload-dialog.cpp
index 339ec95c50..a333c5fe57 100644
--- a/gui/saveload-dialog.cpp
+++ b/gui/saveload-dialog.cpp
@@ -654,16 +654,25 @@ void SaveLoadChooserGrid::open() {
// In case there was a gap found use the slot.
if (lastSlot + 1 < curSlot) {
- _nextFreeSaveSlot = lastSlot + 1;
- break;
+ // Check that the save slot can be used for user saves.
+ SaveStateDescriptor desc = _metaEngine->querySaveMetaInfos(_target.c_str(), lastSlot + 1);
+ if (!desc.getWriteProtectedFlag()) {
+ _nextFreeSaveSlot = lastSlot + 1;
+ break;
+ }
}
lastSlot = curSlot;
}
// Use the next available slot otherwise.
- if (_nextFreeSaveSlot == -1 && lastSlot + 1 < _metaEngine->getMaximumSaveSlot()) {
- _nextFreeSaveSlot = lastSlot + 1;
+ const int maxSlot = _metaEngine->getMaximumSaveSlot();
+ for (int i = lastSlot; _nextFreeSaveSlot == -1 && i < maxSlot; ++i) {
+ // Check that the save slot can be used for user saves.
+ SaveStateDescriptor desc = _metaEngine->querySaveMetaInfos(_target.c_str(), i + 1);
+ if (!desc.getWriteProtectedFlag()) {
+ _nextFreeSaveSlot = i + 1;
+ }
}
}
diff --git a/gui/themes/scummmodern.zip b/gui/themes/scummmodern.zip
index e40e8b1e26..c7c585654d 100644
--- a/gui/themes/scummmodern.zip
+++ b/gui/themes/scummmodern.zip
Binary files differ
diff --git a/gui/themes/scummmodern/scummmodern_layout.stx b/gui/themes/scummmodern/scummmodern_layout.stx
index b760e15919..7e61d6820e 100644
--- a/gui/themes/scummmodern/scummmodern_layout.stx
+++ b/gui/themes/scummmodern/scummmodern_layout.stx
@@ -1169,9 +1169,9 @@
height = 'Globals.Line.Height'
/>
<widget name = 'HelpText'
- height = '220'
+ height = '228'
/>
- <layout type = 'horizontal' padding = '0, 0, 16, 0'>
+ <layout type = 'horizontal' padding = '0, 0, 8, 0'>
<widget name = 'Prev'
type = 'Button'
/>
diff --git a/gui/themes/translations.dat b/gui/themes/translations.dat
index 90eac48c84..bfa33d4feb 100644
--- a/gui/themes/translations.dat
+++ b/gui/themes/translations.dat
Binary files differ
diff --git a/gui/widgets/edittext.cpp b/gui/widgets/edittext.cpp
index 3e72350c99..550b1bd153 100644
--- a/gui/widgets/edittext.cpp
+++ b/gui/widgets/edittext.cpp
@@ -94,7 +94,7 @@ void EditTextWidget::drawWidget() {
// Draw the text
adjustOffset();
-
+
const Common::Rect &r = Common::Rect(_x + 2 + _leftPadding, _y + 2, _x + _leftPadding + getEditRect().width() + 8, _y + _h);
setTextDrawableArea(r);
diff --git a/gui/widgets/tab.h b/gui/widgets/tab.h
index a01ee2d9dc..148f164fbb 100644
--- a/gui/widgets/tab.h
+++ b/gui/widgets/tab.h
@@ -28,7 +28,7 @@
#include "common/array.h"
namespace GUI {
-
+
enum {
kTabForwards = 1,
kTabBackwards = -1
diff --git a/image/codecs/mjpeg.cpp b/image/codecs/mjpeg.cpp
index 4ad72f259d..6e7faf1045 100644
--- a/image/codecs/mjpeg.cpp
+++ b/image/codecs/mjpeg.cpp
@@ -87,9 +87,11 @@ static const byte s_mjpegValDC[12] = {
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11
};
+#if 0
static const byte s_mjpegBitsDCChrominance[17] = {
/* 0-base */ 0, 0, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0
};
+#endif
static const byte s_mjpegBitsACLuminance[17] = {
/* 0-base */ 0, 0, 2, 1, 3, 3, 2, 4, 3, 5, 5, 4, 4, 0, 0, 1, 0x7d
diff --git a/image/codecs/mpeg.h b/image/codecs/mpeg.h
index 6cb10f21ac..82c3ad19ac 100644
--- a/image/codecs/mpeg.h
+++ b/image/codecs/mpeg.h
@@ -62,7 +62,7 @@ namespace Graphics {
struct Surface;
}
-namespace Image {
+namespace Image {
/**
* MPEG 1/2 video decoder.
diff --git a/image/iff.cpp b/image/iff.cpp
index d93e9ff878..d75fffb31f 100644
--- a/image/iff.cpp
+++ b/image/iff.cpp
@@ -31,7 +31,7 @@ namespace Image {
IFFDecoder::IFFDecoder() {
_surface = 0;
_palette = 0;
-
+
// these 2 properties are not reset by destroy(), so the default is set here.
_numRelevantPlanes = 8;
_pixelPacking = false;
diff --git a/image/image_decoder.h b/image/image_decoder.h
index 4d3512e0f6..2018cebd37 100644
--- a/image/image_decoder.h
+++ b/image/image_decoder.h
@@ -48,7 +48,7 @@ public:
/**
* Load an image from the specified stream
- *
+ *
* loadStream() should implicitly call destroy() to free the memory
* of the last loadStream() call.
*
diff --git a/po/be_BY.po b/po/be_BY.po
index a0ae61c9c7..868ade94fb 100644
--- a/po/be_BY.po
+++ b/po/be_BY.po
@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: ScummVM 1.7.0git\n"
"Report-Msgid-Bugs-To: scummvm-devel@lists.sf.net\n"
-"POT-Creation-Date: 2014-09-03 07:39+0200\n"
+"POT-Creation-Date: 2014-10-04 00:58+0100\n"
"PO-Revision-Date: 2014-07-02 17:22+0300\n"
"Last-Translator: Ivan Lukyanov <greencis@mail.ru>\n"
"Language-Team: Ivan Lukyanov <greencis@mail.ru>\n"
@@ -110,12 +110,14 @@ msgstr "Прызначыць"
#: engines/agos/animation.cpp:558 engines/drascula/saveload.cpp:49
#: engines/groovie/script.cpp:399 engines/parallaction/saveload.cpp:274
#: engines/scumm/dialogs.cpp:193 engines/scumm/scumm.cpp:1825
-#: engines/sky/compact.cpp:131 engines/sky/compact.cpp:141
-#: engines/sword1/animation.cpp:524 engines/sword1/animation.cpp:545
-#: engines/sword1/animation.cpp:561 engines/sword1/animation.cpp:569
-#: engines/sword1/control.cpp:865 engines/sword1/logic.cpp:1633
-#: engines/sword2/animation.cpp:425 engines/sword2/animation.cpp:445
-#: engines/sword2/animation.cpp:461 engines/sword2/animation.cpp:471
+#: engines/scumm/players/player_v3m.cpp:130
+#: engines/scumm/players/player_v5m.cpp:108 engines/sky/compact.cpp:131
+#: engines/sky/compact.cpp:141 engines/sword1/animation.cpp:524
+#: engines/sword1/animation.cpp:545 engines/sword1/animation.cpp:561
+#: engines/sword1/animation.cpp:569 engines/sword1/control.cpp:865
+#: engines/sword1/logic.cpp:1633 engines/sword2/animation.cpp:425
+#: engines/sword2/animation.cpp:445 engines/sword2/animation.cpp:461
+#: engines/sword2/animation.cpp:471
msgid "OK"
msgstr "OK"
@@ -454,7 +456,7 @@ msgstr "Пошук:"
#: gui/launcher.cpp:685 engines/dialogs.cpp:115 engines/cruise/menu.cpp:214
#: engines/mohawk/myst.cpp:245 engines/mohawk/riven.cpp:718
-#: engines/pegasus/pegasus.cpp:353
+#: engines/pegasus/pegasus.cpp:353 engines/tsage/scenes.cpp:600
msgid "Load game:"
msgstr "Загрузіць гульню:"
@@ -463,7 +465,7 @@ msgstr "Загрузіць гульню:"
#: backends/platform/wince/CEActionsSmartphone.cpp:231
#: engines/cruise/menu.cpp:214 engines/mohawk/myst.cpp:245
#: engines/mohawk/riven.cpp:718 engines/pegasus/pegasus.cpp:353
-#: engines/scumm/dialogs.cpp:189
+#: engines/scumm/dialogs.cpp:189 engines/tsage/scenes.cpp:600
msgid "Load"
msgstr "Загрузіць"
@@ -481,6 +483,7 @@ msgstr ""
#: backends/platform/wince/CEActionsPocket.cpp:326
#: backends/platform/wince/CEActionsSmartphone.cpp:287
#: backends/platform/wince/CELauncherDialog.cpp:83
+#: engines/kyra/saveload_eob.cpp:557 engines/kyra/saveload_eob.cpp:590
msgid "Yes"
msgstr "Так"
@@ -490,6 +493,7 @@ msgstr "Так"
#: backends/platform/wince/CEActionsPocket.cpp:326
#: backends/platform/wince/CEActionsSmartphone.cpp:287
#: backends/platform/wince/CELauncherDialog.cpp:83
+#: engines/kyra/saveload_eob.cpp:557 engines/kyra/saveload_eob.cpp:590
msgid "No"
msgstr "Не"
@@ -1271,8 +1275,9 @@ msgstr "Г~а~лоўнае меню"
#: engines/dialogs.cpp:116 engines/agi/saveload.cpp:803
#: engines/cruise/menu.cpp:212 engines/drascula/saveload.cpp:336
-#: engines/neverhood/menumodule.cpp:873 engines/pegasus/pegasus.cpp:377
-#: engines/sci/engine/kfile.cpp:758 engines/toltecs/menu.cpp:281
+#: engines/dreamweb/saveload.cpp:261 engines/neverhood/menumodule.cpp:873
+#: engines/pegasus/pegasus.cpp:377 engines/sci/engine/kfile.cpp:758
+#: engines/toltecs/menu.cpp:281 engines/tsage/scenes.cpp:598
msgid "Save game:"
msgstr "Захаваць гульню:"
@@ -1282,9 +1287,10 @@ msgstr "Захаваць гульню:"
#: backends/platform/wince/CEActionsSmartphone.cpp:45
#: backends/platform/wince/CEActionsSmartphone.cpp:231
#: engines/agi/saveload.cpp:803 engines/cruise/menu.cpp:212
-#: engines/drascula/saveload.cpp:336 engines/neverhood/menumodule.cpp:873
-#: engines/pegasus/pegasus.cpp:377 engines/sci/engine/kfile.cpp:758
-#: engines/scumm/dialogs.cpp:188 engines/toltecs/menu.cpp:281
+#: engines/drascula/saveload.cpp:336 engines/dreamweb/saveload.cpp:261
+#: engines/neverhood/menumodule.cpp:873 engines/pegasus/pegasus.cpp:377
+#: engines/sci/engine/kfile.cpp:758 engines/scumm/dialogs.cpp:188
+#: engines/toltecs/menu.cpp:281 engines/tsage/scenes.cpp:598
msgid "Save"
msgstr "Захаваць"
@@ -1309,12 +1315,12 @@ msgstr ""
"дапамогу."
#: engines/dialogs.cpp:307 engines/mohawk/dialogs.cpp:109
-#: engines/mohawk/dialogs.cpp:170
+#: engines/mohawk/dialogs.cpp:170 engines/tsage/dialogs.cpp:106
msgid "~O~K"
msgstr "~О~К"
#: engines/dialogs.cpp:308 engines/mohawk/dialogs.cpp:110
-#: engines/mohawk/dialogs.cpp:171
+#: engines/mohawk/dialogs.cpp:171 engines/tsage/dialogs.cpp:107
msgid "~C~ancel"
msgstr "~А~дмена"
@@ -2080,26 +2086,28 @@ msgstr "Пстрычкі выключаны"
#: engines/agi/detection.cpp:142 engines/drascula/detection.cpp:302
#: engines/dreamweb/detection.cpp:47 engines/neverhood/detection.cpp:160
#: engines/sci/detection.cpp:394 engines/toltecs/detection.cpp:200
+#: engines/zvision/detection.cpp:103
msgid "Use original save/load screens"
msgstr "Выкарыстоўваць арыгінальныя экраны запісу/чытанні гульні"
#: engines/agi/detection.cpp:143 engines/drascula/detection.cpp:303
#: engines/dreamweb/detection.cpp:48 engines/neverhood/detection.cpp:161
#: engines/sci/detection.cpp:395 engines/toltecs/detection.cpp:201
+#: engines/zvision/detection.cpp:104
msgid "Use the original save/load screens, instead of the ScummVM ones"
msgstr ""
"Выкарыстоўваць арыгінальныя экраны запісу і захавання гульні замест "
"зробленых у ScummVM"
#: engines/agi/saveload.cpp:816 engines/drascula/saveload.cpp:349
-#: engines/neverhood/menumodule.cpp:886 engines/sci/engine/kfile.cpp:857
-#: engines/toltecs/menu.cpp:256
+#: engines/dreamweb/saveload.cpp:169 engines/neverhood/menumodule.cpp:886
+#: engines/sci/engine/kfile.cpp:857 engines/toltecs/menu.cpp:256
msgid "Restore game:"
msgstr "Узнавіць гульню:"
#: engines/agi/saveload.cpp:816 engines/drascula/saveload.cpp:349
-#: engines/neverhood/menumodule.cpp:886 engines/sci/engine/kfile.cpp:857
-#: engines/toltecs/menu.cpp:256
+#: engines/dreamweb/saveload.cpp:169 engines/neverhood/menumodule.cpp:886
+#: engines/sci/engine/kfile.cpp:857 engines/toltecs/menu.cpp:256
msgid "Restore"
msgstr "Узнавіць"
@@ -2141,6 +2149,15 @@ msgstr ""
msgid "Cutscene file '%s' not found!"
msgstr "Файл застаўкі '%s' не знойдзены!"
+#: engines/cge/detection.cpp:105 engines/cge2/detection.cpp:81
+#, fuzzy
+msgid "Color Blind Mode"
+msgstr "Рэжым пстрычкі"
+
+#: engines/cge/detection.cpp:106 engines/cge2/detection.cpp:82
+msgid "Enable Color Blind Mode by default"
+msgstr ""
+
#: engines/drascula/saveload.cpp:47
msgid ""
"ScummVM found that you have old savefiles for Drascula that should be "
@@ -2167,11 +2184,12 @@ msgid "Display graphics using the game's bright palette"
msgstr "Малюе графіку з выкарыстаннем яркай палітры гульні"
#: engines/gob/inter_playtoons.cpp:256 engines/gob/inter_v2.cpp:1470
-#: engines/tinsel/saveload.cpp:532
+#: engines/gob/inter_geisha.cpp:232 engines/tinsel/saveload.cpp:532
msgid "Failed to load game state from file."
msgstr "Не атрымалася загрузіць захаваную гульню з файла."
-#: engines/gob/inter_v2.cpp:1540 engines/tinsel/saveload.cpp:545
+#: engines/gob/inter_v2.cpp:1540 engines/gob/inter_geisha.cpp:263
+#: engines/tinsel/saveload.cpp:545
msgid "Failed to save game state to file."
msgstr "Не атрымалася захаваць гульню ў файл."
@@ -2191,6 +2209,14 @@ msgstr "Прайгравае відэа на павялічанай хуткасці"
msgid "Failed to save game"
msgstr "Не атрымалася захаваць гульню"
+#: engines/hopkins/detection.cpp:76 engines/hopkins/detection.cpp:86
+msgid "Gore Mode"
+msgstr ""
+
+#: engines/hopkins/detection.cpp:77 engines/hopkins/detection.cpp:87
+msgid "Enable Gore Mode when available"
+msgstr ""
+
#. I18N: Studio audience adds an applause and cheering sounds whenever
#. Malcolm makes a joke.
#: engines/kyra/detection.cpp:62
@@ -2312,6 +2338,35 @@ msgstr ""
"можа так атрымацца, што некаторыя трэкі будуць\n"
"сыграныя няправільна."
+#: engines/kyra/saveload_eob.cpp:557
+#, c-format
+msgid ""
+"The following original save game file has been found in your game path:\n"
+"\n"
+"%s %s\n"
+"\n"
+"Do you wish to use this save game file with ScummVM?\n"
+"\n"
+msgstr ""
+
+#: engines/kyra/saveload_eob.cpp:590
+#, c-format
+msgid ""
+"A save game file was found in the specified slot %d. Overwrite?\n"
+"\n"
+msgstr ""
+
+#: engines/kyra/saveload_eob.cpp:623
+#, c-format
+msgid ""
+"%d original save game files have been successfully imported into\n"
+"ScummVM. If you want to manually import original save game files later you "
+"will\n"
+"need to open the ScummVM debug console and use the command "
+"'import_savefile'.\n"
+"\n"
+msgstr ""
+
#. I18N: Option for fast scene switching
#: engines/mohawk/dialogs.cpp:92 engines/mohawk/dialogs.cpp:167
msgid "~Z~ip Mode Activated"
@@ -2439,6 +2494,14 @@ msgstr "Паказаць/схаваць інфаэкран"
msgid "Display/Hide Pause Menu"
msgstr "Паказаць/схаваць меню паўзы"
+#: engines/queen/detection.cpp:56
+msgid "Alternative intro"
+msgstr "Альтэрнатыўны ўступ"
+
+#: engines/queen/detection.cpp:57
+msgid "Use an alternative game intro (CD version only)"
+msgstr "Выкарыстоўваць альтэрнатыўны ўступ (толькі для CD версіі гульні)"
+
#: engines/sci/detection.cpp:374
msgid "EGA undithering"
msgstr "EGA без растру"
@@ -3142,6 +3205,18 @@ msgstr ""
"ўмее. Каб згуляць, націсніце 'Новая гульня' у стартавым меню ScummVM, а "
"затым абярыце дырэкторыю Maniac у дырэкторыі з гульнёй Tentacle."
+#: engines/scumm/players/player_v3m.cpp:129
+msgid ""
+"Could not find the 'Loom' Macintosh executable to read the\n"
+"instruments from. Music will be disabled."
+msgstr ""
+
+#: engines/scumm/players/player_v5m.cpp:107
+msgid ""
+"Could not find the 'Monkey Island' Macintosh executable to read the\n"
+"instruments from. Music will be disabled."
+msgstr ""
+
#: engines/sky/compact.cpp:130
msgid ""
"Unable to find \"sky.cpt\" file!\n"
@@ -3255,6 +3330,14 @@ msgstr ""
"Файл teenagent.dat зжаты, але zlib не ўключана ў гэту праграму. Калі ласка, "
"распакуйце яго"
+#: engines/wintermute/detection.cpp:58
+msgid "Show FPS-counter"
+msgstr ""
+
+#: engines/wintermute/detection.cpp:59
+msgid "Show the current number of frames per second in the upper left corner"
+msgstr ""
+
#~ msgid "MPEG-2 cutscenes found but ScummVM has been built without MPEG-2"
#~ msgstr ""
#~ "Знойдзены застаўкі ў фармаце MPEG-2, але ScummVM быў сабраны без "
@@ -3276,12 +3359,6 @@ msgstr ""
#~ msgid "Standard (16bpp)"
#~ msgstr "Стандартны растарызатар (16bpp)"
-#~ msgid "Alternative intro"
-#~ msgstr "Альтэрнатыўны ўступ"
-
-#~ msgid "Use an alternative game intro (CD version only)"
-#~ msgstr "Выкарыстоўваць альтэрнатыўны ўступ (толькі для CD версіі гульні)"
-
#~ msgid "MPEG2 cutscenes are no longer supported"
#~ msgstr "Застаўкі ў фармаце MPEG2 больш не падтрымліваюцца"
diff --git a/po/ca_ES.po b/po/ca_ES.po
index c80564a6c3..86f8bbed86 100644
--- a/po/ca_ES.po
+++ b/po/ca_ES.po
@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: ScummVM 1.6.0git\n"
"Report-Msgid-Bugs-To: scummvm-devel@lists.sf.net\n"
-"POT-Creation-Date: 2014-09-03 07:39+0200\n"
+"POT-Creation-Date: 2014-10-04 00:58+0100\n"
"PO-Revision-Date: 2013-05-05 14:16+0100\n"
"Last-Translator: Jordi Vilalta Prat <jvprat@jvprat.com>\n"
"Language-Team: Catalan <scummvm-devel@lists.sf.net>\n"
@@ -107,12 +107,14 @@ msgstr "Assigna"
#: engines/agos/animation.cpp:558 engines/drascula/saveload.cpp:49
#: engines/groovie/script.cpp:399 engines/parallaction/saveload.cpp:274
#: engines/scumm/dialogs.cpp:193 engines/scumm/scumm.cpp:1825
-#: engines/sky/compact.cpp:131 engines/sky/compact.cpp:141
-#: engines/sword1/animation.cpp:524 engines/sword1/animation.cpp:545
-#: engines/sword1/animation.cpp:561 engines/sword1/animation.cpp:569
-#: engines/sword1/control.cpp:865 engines/sword1/logic.cpp:1633
-#: engines/sword2/animation.cpp:425 engines/sword2/animation.cpp:445
-#: engines/sword2/animation.cpp:461 engines/sword2/animation.cpp:471
+#: engines/scumm/players/player_v3m.cpp:130
+#: engines/scumm/players/player_v5m.cpp:108 engines/sky/compact.cpp:131
+#: engines/sky/compact.cpp:141 engines/sword1/animation.cpp:524
+#: engines/sword1/animation.cpp:545 engines/sword1/animation.cpp:561
+#: engines/sword1/animation.cpp:569 engines/sword1/control.cpp:865
+#: engines/sword1/logic.cpp:1633 engines/sword2/animation.cpp:425
+#: engines/sword2/animation.cpp:445 engines/sword2/animation.cpp:461
+#: engines/sword2/animation.cpp:471
msgid "OK"
msgstr "D'acord"
@@ -454,7 +456,7 @@ msgstr "Cerca:"
#: gui/launcher.cpp:685 engines/dialogs.cpp:115 engines/cruise/menu.cpp:214
#: engines/mohawk/myst.cpp:245 engines/mohawk/riven.cpp:718
-#: engines/pegasus/pegasus.cpp:353
+#: engines/pegasus/pegasus.cpp:353 engines/tsage/scenes.cpp:600
msgid "Load game:"
msgstr "Carrega partida:"
@@ -463,7 +465,7 @@ msgstr "Carrega partida:"
#: backends/platform/wince/CEActionsSmartphone.cpp:231
#: engines/cruise/menu.cpp:214 engines/mohawk/myst.cpp:245
#: engines/mohawk/riven.cpp:718 engines/pegasus/pegasus.cpp:353
-#: engines/scumm/dialogs.cpp:189
+#: engines/scumm/dialogs.cpp:189 engines/tsage/scenes.cpp:600
msgid "Load"
msgstr "Carrega"
@@ -481,6 +483,7 @@ msgstr ""
#: backends/platform/wince/CEActionsPocket.cpp:326
#: backends/platform/wince/CEActionsSmartphone.cpp:287
#: backends/platform/wince/CELauncherDialog.cpp:83
+#: engines/kyra/saveload_eob.cpp:557 engines/kyra/saveload_eob.cpp:590
msgid "Yes"
msgstr "Sэ"
@@ -490,6 +493,7 @@ msgstr "Sэ"
#: backends/platform/wince/CEActionsPocket.cpp:326
#: backends/platform/wince/CEActionsSmartphone.cpp:287
#: backends/platform/wince/CELauncherDialog.cpp:83
+#: engines/kyra/saveload_eob.cpp:557 engines/kyra/saveload_eob.cpp:590
msgid "No"
msgstr "No"
@@ -1279,8 +1283,9 @@ msgstr "~R~etorna al Llanчador"
#: engines/dialogs.cpp:116 engines/agi/saveload.cpp:803
#: engines/cruise/menu.cpp:212 engines/drascula/saveload.cpp:336
-#: engines/neverhood/menumodule.cpp:873 engines/pegasus/pegasus.cpp:377
-#: engines/sci/engine/kfile.cpp:758 engines/toltecs/menu.cpp:281
+#: engines/dreamweb/saveload.cpp:261 engines/neverhood/menumodule.cpp:873
+#: engines/pegasus/pegasus.cpp:377 engines/sci/engine/kfile.cpp:758
+#: engines/toltecs/menu.cpp:281 engines/tsage/scenes.cpp:598
msgid "Save game:"
msgstr "Desa la partida:"
@@ -1290,9 +1295,10 @@ msgstr "Desa la partida:"
#: backends/platform/wince/CEActionsSmartphone.cpp:45
#: backends/platform/wince/CEActionsSmartphone.cpp:231
#: engines/agi/saveload.cpp:803 engines/cruise/menu.cpp:212
-#: engines/drascula/saveload.cpp:336 engines/neverhood/menumodule.cpp:873
-#: engines/pegasus/pegasus.cpp:377 engines/sci/engine/kfile.cpp:758
-#: engines/scumm/dialogs.cpp:188 engines/toltecs/menu.cpp:281
+#: engines/drascula/saveload.cpp:336 engines/dreamweb/saveload.cpp:261
+#: engines/neverhood/menumodule.cpp:873 engines/pegasus/pegasus.cpp:377
+#: engines/sci/engine/kfile.cpp:758 engines/scumm/dialogs.cpp:188
+#: engines/toltecs/menu.cpp:281 engines/tsage/scenes.cpp:598
msgid "Save"
msgstr "Desa"
@@ -1315,12 +1321,12 @@ msgstr ""
"informaciѓ bрsica i les instruccions sobre com obtenir mщs assistшncia."
#: engines/dialogs.cpp:307 engines/mohawk/dialogs.cpp:109
-#: engines/mohawk/dialogs.cpp:170
+#: engines/mohawk/dialogs.cpp:170 engines/tsage/dialogs.cpp:106
msgid "~O~K"
msgstr "~D~'acord"
#: engines/dialogs.cpp:308 engines/mohawk/dialogs.cpp:110
-#: engines/mohawk/dialogs.cpp:171
+#: engines/mohawk/dialogs.cpp:171 engines/tsage/dialogs.cpp:107
msgid "~C~ancel"
msgstr "~C~ancelЗla"
@@ -2085,25 +2091,27 @@ msgstr "Clicat desactivat"
#: engines/agi/detection.cpp:142 engines/drascula/detection.cpp:302
#: engines/dreamweb/detection.cpp:47 engines/neverhood/detection.cpp:160
#: engines/sci/detection.cpp:394 engines/toltecs/detection.cpp:200
+#: engines/zvision/detection.cpp:103
msgid "Use original save/load screens"
msgstr "Utilitza les pantalles originals de desat/cрrrega"
#: engines/agi/detection.cpp:143 engines/drascula/detection.cpp:303
#: engines/dreamweb/detection.cpp:48 engines/neverhood/detection.cpp:161
#: engines/sci/detection.cpp:395 engines/toltecs/detection.cpp:201
+#: engines/zvision/detection.cpp:104
msgid "Use the original save/load screens, instead of the ScummVM ones"
msgstr ""
"Utilitza les pantalles originals de desat/cрrrega, en lloc de les de ScummVM"
#: engines/agi/saveload.cpp:816 engines/drascula/saveload.cpp:349
-#: engines/neverhood/menumodule.cpp:886 engines/sci/engine/kfile.cpp:857
-#: engines/toltecs/menu.cpp:256
+#: engines/dreamweb/saveload.cpp:169 engines/neverhood/menumodule.cpp:886
+#: engines/sci/engine/kfile.cpp:857 engines/toltecs/menu.cpp:256
msgid "Restore game:"
msgstr "Recupera la partida:"
#: engines/agi/saveload.cpp:816 engines/drascula/saveload.cpp:349
-#: engines/neverhood/menumodule.cpp:886 engines/sci/engine/kfile.cpp:857
-#: engines/toltecs/menu.cpp:256
+#: engines/dreamweb/saveload.cpp:169 engines/neverhood/menumodule.cpp:886
+#: engines/sci/engine/kfile.cpp:857 engines/toltecs/menu.cpp:256
msgid "Restore"
msgstr "Restaura"
@@ -2145,6 +2153,15 @@ msgstr ""
msgid "Cutscene file '%s' not found!"
msgstr "No s'ha trobat el fitxer d'escena '%s'!"
+#: engines/cge/detection.cpp:105 engines/cge2/detection.cpp:81
+#, fuzzy
+msgid "Color Blind Mode"
+msgstr "Mode clic"
+
+#: engines/cge/detection.cpp:106 engines/cge2/detection.cpp:82
+msgid "Enable Color Blind Mode by default"
+msgstr ""
+
#: engines/drascula/saveload.cpp:47
msgid ""
"ScummVM found that you have old savefiles for Drascula that should be "
@@ -2172,11 +2189,12 @@ msgid "Display graphics using the game's bright palette"
msgstr "Mostra els grрfics utilitzant la paleta brillant del joc"
#: engines/gob/inter_playtoons.cpp:256 engines/gob/inter_v2.cpp:1470
-#: engines/tinsel/saveload.cpp:532
+#: engines/gob/inter_geisha.cpp:232 engines/tinsel/saveload.cpp:532
msgid "Failed to load game state from file."
msgstr "No s'ha pogut carregar l'estat del joc del fitxer."
-#: engines/gob/inter_v2.cpp:1540 engines/tinsel/saveload.cpp:545
+#: engines/gob/inter_v2.cpp:1540 engines/gob/inter_geisha.cpp:263
+#: engines/tinsel/saveload.cpp:545
msgid "Failed to save game state to file."
msgstr "No s'ha pogut desar l'estat del joc al fitxer."
@@ -2196,6 +2214,14 @@ msgstr "Reprodueix les pelЗlэcules a major velocitat"
msgid "Failed to save game"
msgstr "No s'ha pogut desar l'estat del joc"
+#: engines/hopkins/detection.cpp:76 engines/hopkins/detection.cpp:86
+msgid "Gore Mode"
+msgstr ""
+
+#: engines/hopkins/detection.cpp:77 engines/hopkins/detection.cpp:87
+msgid "Enable Gore Mode when available"
+msgstr ""
+
#. I18N: Studio audience adds an applause and cheering sounds whenever
#. Malcolm makes a joke.
#: engines/kyra/detection.cpp:62
@@ -2316,6 +2342,35 @@ msgstr ""
"Roland MT32 als de General MIDI. Щs possible\n"
"que algunes pistes no es reprodueixin correctament."
+#: engines/kyra/saveload_eob.cpp:557
+#, c-format
+msgid ""
+"The following original save game file has been found in your game path:\n"
+"\n"
+"%s %s\n"
+"\n"
+"Do you wish to use this save game file with ScummVM?\n"
+"\n"
+msgstr ""
+
+#: engines/kyra/saveload_eob.cpp:590
+#, c-format
+msgid ""
+"A save game file was found in the specified slot %d. Overwrite?\n"
+"\n"
+msgstr ""
+
+#: engines/kyra/saveload_eob.cpp:623
+#, c-format
+msgid ""
+"%d original save game files have been successfully imported into\n"
+"ScummVM. If you want to manually import original save game files later you "
+"will\n"
+"need to open the ScummVM debug console and use the command "
+"'import_savefile'.\n"
+"\n"
+msgstr ""
+
#. I18N: Option for fast scene switching
#: engines/mohawk/dialogs.cpp:92 engines/mohawk/dialogs.cpp:167
msgid "~Z~ip Mode Activated"
@@ -2444,6 +2499,14 @@ msgstr "Mostra/Oculta la pantalla d'informaciѓ"
msgid "Display/Hide Pause Menu"
msgstr "Mostra/Oculta el menњ de pausa"
+#: engines/queen/detection.cpp:56
+msgid "Alternative intro"
+msgstr "Introducciѓ alternativa"
+
+#: engines/queen/detection.cpp:57
+msgid "Use an alternative game intro (CD version only)"
+msgstr "Utilitza una introducciѓ del joc alternativa (nomщs per la versiѓ CD)"
+
#: engines/sci/detection.cpp:374
msgid "EGA undithering"
msgstr "Elimina el tramat d'EGA"
@@ -3147,6 +3210,18 @@ msgstr ""
"fa encara. Per jugar-hi, aneu a 'Afegir joc' al menњ principal de ScummVM i "
"seleccioneu el directori 'Maniac' de dins del directori del joc Tentacle."
+#: engines/scumm/players/player_v3m.cpp:129
+msgid ""
+"Could not find the 'Loom' Macintosh executable to read the\n"
+"instruments from. Music will be disabled."
+msgstr ""
+
+#: engines/scumm/players/player_v5m.cpp:107
+msgid ""
+"Could not find the 'Monkey Island' Macintosh executable to read the\n"
+"instruments from. Music will be disabled."
+msgstr ""
+
#: engines/sky/compact.cpp:130
msgid ""
"Unable to find \"sky.cpt\" file!\n"
@@ -3263,6 +3338,14 @@ msgstr ""
"El fitxer teenagent.dat estр comprimit perђ aquest executable no contщ zlib. "
"Descomprimiu-lo, si us plau."
+#: engines/wintermute/detection.cpp:58
+msgid "Show FPS-counter"
+msgstr ""
+
+#: engines/wintermute/detection.cpp:59
+msgid "Show the current number of frames per second in the upper left corner"
+msgstr ""
+
#, fuzzy
#~ msgid "MPEG-2 cutscenes found but ScummVM has been built without MPEG-2"
#~ msgstr ""
@@ -3285,13 +3368,6 @@ msgstr ""
#~ msgid "Standard (16bpp)"
#~ msgstr "Estрndard (16bpp)"
-#~ msgid "Alternative intro"
-#~ msgstr "Introducciѓ alternativa"
-
-#~ msgid "Use an alternative game intro (CD version only)"
-#~ msgstr ""
-#~ "Utilitza una introducciѓ del joc alternativa (nomщs per la versiѓ CD)"
-
#~ msgid "MPEG2 cutscenes are no longer supported"
#~ msgstr "Les escenes MPEG2 ja no estan suportades"
diff --git a/po/cs_CZ.po b/po/cs_CZ.po
index 0eee65ba1c..0b5a3c88bf 100644
--- a/po/cs_CZ.po
+++ b/po/cs_CZ.po
@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: ScummVM 1.7.0git\n"
"Report-Msgid-Bugs-To: scummvm-devel@lists.sf.net\n"
-"POT-Creation-Date: 2014-09-03 07:39+0200\n"
+"POT-Creation-Date: 2014-10-04 00:58+0100\n"
"PO-Revision-Date: 2014-02-27 21:43+0100\n"
"Last-Translator: Zbynьk Schwarz <zbynek.schwarz@gmail.com>\n"
"Language-Team: \n"
@@ -111,12 +111,14 @@ msgstr "Mapovat"
#: engines/agos/animation.cpp:558 engines/drascula/saveload.cpp:49
#: engines/groovie/script.cpp:399 engines/parallaction/saveload.cpp:274
#: engines/scumm/dialogs.cpp:193 engines/scumm/scumm.cpp:1825
-#: engines/sky/compact.cpp:131 engines/sky/compact.cpp:141
-#: engines/sword1/animation.cpp:524 engines/sword1/animation.cpp:545
-#: engines/sword1/animation.cpp:561 engines/sword1/animation.cpp:569
-#: engines/sword1/control.cpp:865 engines/sword1/logic.cpp:1633
-#: engines/sword2/animation.cpp:425 engines/sword2/animation.cpp:445
-#: engines/sword2/animation.cpp:461 engines/sword2/animation.cpp:471
+#: engines/scumm/players/player_v3m.cpp:130
+#: engines/scumm/players/player_v5m.cpp:108 engines/sky/compact.cpp:131
+#: engines/sky/compact.cpp:141 engines/sword1/animation.cpp:524
+#: engines/sword1/animation.cpp:545 engines/sword1/animation.cpp:561
+#: engines/sword1/animation.cpp:569 engines/sword1/control.cpp:865
+#: engines/sword1/logic.cpp:1633 engines/sword2/animation.cpp:425
+#: engines/sword2/animation.cpp:445 engines/sword2/animation.cpp:461
+#: engines/sword2/animation.cpp:471
msgid "OK"
msgstr "OK"
@@ -453,7 +455,7 @@ msgstr "Hledat:"
#: gui/launcher.cpp:685 engines/dialogs.cpp:115 engines/cruise/menu.cpp:214
#: engines/mohawk/myst.cpp:245 engines/mohawk/riven.cpp:718
-#: engines/pegasus/pegasus.cpp:353
+#: engines/pegasus/pegasus.cpp:353 engines/tsage/scenes.cpp:600
msgid "Load game:"
msgstr "Nahrсt hru:"
@@ -462,7 +464,7 @@ msgstr "Nahrсt hru:"
#: backends/platform/wince/CEActionsSmartphone.cpp:231
#: engines/cruise/menu.cpp:214 engines/mohawk/myst.cpp:245
#: engines/mohawk/riven.cpp:718 engines/pegasus/pegasus.cpp:353
-#: engines/scumm/dialogs.cpp:189
+#: engines/scumm/dialogs.cpp:189 engines/tsage/scenes.cpp:600
msgid "Load"
msgstr "Nahrсt"
@@ -480,6 +482,7 @@ msgstr ""
#: backends/platform/wince/CEActionsPocket.cpp:326
#: backends/platform/wince/CEActionsSmartphone.cpp:287
#: backends/platform/wince/CELauncherDialog.cpp:83
+#: engines/kyra/saveload_eob.cpp:557 engines/kyra/saveload_eob.cpp:590
msgid "Yes"
msgstr "Ano"
@@ -489,6 +492,7 @@ msgstr "Ano"
#: backends/platform/wince/CEActionsPocket.cpp:326
#: backends/platform/wince/CEActionsSmartphone.cpp:287
#: backends/platform/wince/CELauncherDialog.cpp:83
+#: engines/kyra/saveload_eob.cpp:557 engines/kyra/saveload_eob.cpp:590
msgid "No"
msgstr "Ne"
@@ -1267,8 +1271,9 @@ msgstr "~N~сvrat do SpouЙtьшe"
#: engines/dialogs.cpp:116 engines/agi/saveload.cpp:803
#: engines/cruise/menu.cpp:212 engines/drascula/saveload.cpp:336
-#: engines/neverhood/menumodule.cpp:873 engines/pegasus/pegasus.cpp:377
-#: engines/sci/engine/kfile.cpp:758 engines/toltecs/menu.cpp:281
+#: engines/dreamweb/saveload.cpp:261 engines/neverhood/menumodule.cpp:873
+#: engines/pegasus/pegasus.cpp:377 engines/sci/engine/kfile.cpp:758
+#: engines/toltecs/menu.cpp:281 engines/tsage/scenes.cpp:598
msgid "Save game:"
msgstr "UloОit hru:"
@@ -1278,9 +1283,10 @@ msgstr "UloОit hru:"
#: backends/platform/wince/CEActionsSmartphone.cpp:45
#: backends/platform/wince/CEActionsSmartphone.cpp:231
#: engines/agi/saveload.cpp:803 engines/cruise/menu.cpp:212
-#: engines/drascula/saveload.cpp:336 engines/neverhood/menumodule.cpp:873
-#: engines/pegasus/pegasus.cpp:377 engines/sci/engine/kfile.cpp:758
-#: engines/scumm/dialogs.cpp:188 engines/toltecs/menu.cpp:281
+#: engines/drascula/saveload.cpp:336 engines/dreamweb/saveload.cpp:261
+#: engines/neverhood/menumodule.cpp:873 engines/pegasus/pegasus.cpp:377
+#: engines/sci/engine/kfile.cpp:758 engines/scumm/dialogs.cpp:188
+#: engines/toltecs/menu.cpp:281 engines/tsage/scenes.cpp:598
msgid "Save"
msgstr "UloОit"
@@ -1304,12 +1310,12 @@ msgstr ""
"informace a pokyny k zэskсnэ dalЙэ podpory."
#: engines/dialogs.cpp:307 engines/mohawk/dialogs.cpp:109
-#: engines/mohawk/dialogs.cpp:170
+#: engines/mohawk/dialogs.cpp:170 engines/tsage/dialogs.cpp:106
msgid "~O~K"
msgstr "~O~K"
#: engines/dialogs.cpp:308 engines/mohawk/dialogs.cpp:110
-#: engines/mohawk/dialogs.cpp:171
+#: engines/mohawk/dialogs.cpp:171 engines/tsage/dialogs.cpp:107
msgid "~C~ancel"
msgstr "~Z~ruЙit"
@@ -2075,24 +2081,26 @@ msgstr "Kliknutэ Zakсzсno"
#: engines/agi/detection.cpp:142 engines/drascula/detection.cpp:302
#: engines/dreamweb/detection.cpp:47 engines/neverhood/detection.cpp:160
#: engines/sci/detection.cpp:394 engines/toltecs/detection.cpp:200
+#: engines/zvision/detection.cpp:103
msgid "Use original save/load screens"
msgstr "PouОэt pљvodnэ obrazovky naшtenэ/uloОenэ"
#: engines/agi/detection.cpp:143 engines/drascula/detection.cpp:303
#: engines/dreamweb/detection.cpp:48 engines/neverhood/detection.cpp:161
#: engines/sci/detection.cpp:395 engines/toltecs/detection.cpp:201
+#: engines/zvision/detection.cpp:104
msgid "Use the original save/load screens, instead of the ScummVM ones"
msgstr "PouОэt pљvodnэ obrazovky naшtenэ/uloОenэ mэsto ze ScummVM"
#: engines/agi/saveload.cpp:816 engines/drascula/saveload.cpp:349
-#: engines/neverhood/menumodule.cpp:886 engines/sci/engine/kfile.cpp:857
-#: engines/toltecs/menu.cpp:256
+#: engines/dreamweb/saveload.cpp:169 engines/neverhood/menumodule.cpp:886
+#: engines/sci/engine/kfile.cpp:857 engines/toltecs/menu.cpp:256
msgid "Restore game:"
msgstr "Obnovit hru"
#: engines/agi/saveload.cpp:816 engines/drascula/saveload.cpp:349
-#: engines/neverhood/menumodule.cpp:886 engines/sci/engine/kfile.cpp:857
-#: engines/toltecs/menu.cpp:256
+#: engines/dreamweb/saveload.cpp:169 engines/neverhood/menumodule.cpp:886
+#: engines/sci/engine/kfile.cpp:857 engines/toltecs/menu.cpp:256
msgid "Restore"
msgstr "Obnovit"
@@ -2134,6 +2142,15 @@ msgstr ""
msgid "Cutscene file '%s' not found!"
msgstr "Soubor videa '%s' nenalezen'"
+#: engines/cge/detection.cpp:105 engines/cge2/detection.cpp:81
+#, fuzzy
+msgid "Color Blind Mode"
+msgstr "ReОim kliknutэ"
+
+#: engines/cge/detection.cpp:106 engines/cge2/detection.cpp:82
+msgid "Enable Color Blind Mode by default"
+msgstr ""
+
#: engines/drascula/saveload.cpp:47
msgid ""
"ScummVM found that you have old savefiles for Drascula that should be "
@@ -2161,11 +2178,12 @@ msgid "Display graphics using the game's bright palette"
msgstr "Zobrazit grafiku pomocэ jasnщ palety hry"
#: engines/gob/inter_playtoons.cpp:256 engines/gob/inter_v2.cpp:1470
-#: engines/tinsel/saveload.cpp:532
+#: engines/gob/inter_geisha.cpp:232 engines/tinsel/saveload.cpp:532
msgid "Failed to load game state from file."
msgstr "Nelze naшэst stav hry ze souboru."
-#: engines/gob/inter_v2.cpp:1540 engines/tinsel/saveload.cpp:545
+#: engines/gob/inter_v2.cpp:1540 engines/gob/inter_geisha.cpp:263
+#: engines/tinsel/saveload.cpp:545
msgid "Failed to save game state to file."
msgstr "Nelze uloОit stav hry do souboru."
@@ -2185,6 +2203,14 @@ msgstr "Pјehrсt videa se zv§Йenou rychlostэ"
msgid "Failed to save game"
msgstr "Nelze uloОit hru."
+#: engines/hopkins/detection.cpp:76 engines/hopkins/detection.cpp:86
+msgid "Gore Mode"
+msgstr ""
+
+#: engines/hopkins/detection.cpp:77 engines/hopkins/detection.cpp:87
+msgid "Enable Gore Mode when available"
+msgstr ""
+
#. I18N: Studio audience adds an applause and cheering sounds whenever
#. Malcolm makes a joke.
#: engines/kyra/detection.cpp:62
@@ -2305,6 +2331,35 @@ msgstr ""
"ty od General MIDI. Je stсle moОnщ, Оe\n"
"nьkterщ stopy nebudou znэt sprсvnь."
+#: engines/kyra/saveload_eob.cpp:557
+#, c-format
+msgid ""
+"The following original save game file has been found in your game path:\n"
+"\n"
+"%s %s\n"
+"\n"
+"Do you wish to use this save game file with ScummVM?\n"
+"\n"
+msgstr ""
+
+#: engines/kyra/saveload_eob.cpp:590
+#, c-format
+msgid ""
+"A save game file was found in the specified slot %d. Overwrite?\n"
+"\n"
+msgstr ""
+
+#: engines/kyra/saveload_eob.cpp:623
+#, c-format
+msgid ""
+"%d original save game files have been successfully imported into\n"
+"ScummVM. If you want to manually import original save game files later you "
+"will\n"
+"need to open the ScummVM debug console and use the command "
+"'import_savefile'.\n"
+"\n"
+msgstr ""
+
#. I18N: Option for fast scene switching
#: engines/mohawk/dialogs.cpp:92 engines/mohawk/dialogs.cpp:167
msgid "~Z~ip Mode Activated"
@@ -2432,6 +2487,14 @@ msgstr "Zobrazit/Skr§to obrazovku informacэ"
msgid "Display/Hide Pause Menu"
msgstr "Zobrazit/Skr§t "
+#: engines/queen/detection.cpp:56
+msgid "Alternative intro"
+msgstr "Alternativnэ њvod"
+
+#: engines/queen/detection.cpp:57
+msgid "Use an alternative game intro (CD version only)"
+msgstr "PouОэt jinou verzi њvodu (Pouze verze CD)"
+
#: engines/sci/detection.cpp:374
msgid "EGA undithering"
msgstr "Nerozklсdсnэ EGA"
@@ -3130,6 +3193,18 @@ msgstr ""
"Abyste toto mohli hrсt, pјejdьte do 'Pјidat Hru' v poшсteшnэm menu ScummVM a "
"vyberte adresсј 'Maniac' uvnitј hernэho adresсјe Tentacle."
+#: engines/scumm/players/player_v3m.cpp:129
+msgid ""
+"Could not find the 'Loom' Macintosh executable to read the\n"
+"instruments from. Music will be disabled."
+msgstr ""
+
+#: engines/scumm/players/player_v5m.cpp:107
+msgid ""
+"Could not find the 'Monkey Island' Macintosh executable to read the\n"
+"instruments from. Music will be disabled."
+msgstr ""
+
#: engines/sky/compact.cpp:130
msgid ""
"Unable to find \"sky.cpt\" file!\n"
@@ -3238,6 +3313,14 @@ msgstr ""
"Soubor teenagent.dat je komprimovсn a zlib nenэ souшсstэ spustitelnщho "
"souboru. Prosэm dekomprimujte ho"
+#: engines/wintermute/detection.cpp:58
+msgid "Show FPS-counter"
+msgstr ""
+
+#: engines/wintermute/detection.cpp:59
+msgid "Show the current number of frames per second in the upper left corner"
+msgstr ""
+
#~ msgid "MPEG-2 cutscenes found but ScummVM has been built without MPEG-2"
#~ msgstr "Videa MPEG-2 nalezena, ale ScummVM byl sestaven bez MPEG-2"
@@ -3256,12 +3339,6 @@ msgstr ""
#~ msgid "Standard (16bpp)"
#~ msgstr "Standardnэ (16bpp)"
-#~ msgid "Alternative intro"
-#~ msgstr "Alternativnэ њvod"
-
-#~ msgid "Use an alternative game intro (CD version only)"
-#~ msgstr "PouОэt jinou verzi њvodu (Pouze verze CD)"
-
#~ msgid "MPEG2 cutscenes are no longer supported"
#~ msgstr "Videa MPGE2 jiО nejsou podporovсna"
diff --git a/po/da_DA.po b/po/da_DA.po
index 65abad2f9e..480e2005d0 100644
--- a/po/da_DA.po
+++ b/po/da_DA.po
@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: ScummVM 1.3.0svn\n"
"Report-Msgid-Bugs-To: scummvm-devel@lists.sf.net\n"
-"POT-Creation-Date: 2014-09-03 07:39+0200\n"
+"POT-Creation-Date: 2014-10-04 00:58+0100\n"
"PO-Revision-Date: 2014-07-09 17:34+0100\n"
"Last-Translator: Steffen Nyeland <steffen@nyeland.dk>\n"
"Language-Team: Steffen Nyeland <steffen@nyeland.dk>\n"
@@ -109,12 +109,14 @@ msgstr "Kortlцg"
#: engines/agos/animation.cpp:558 engines/drascula/saveload.cpp:49
#: engines/groovie/script.cpp:399 engines/parallaction/saveload.cpp:274
#: engines/scumm/dialogs.cpp:193 engines/scumm/scumm.cpp:1825
-#: engines/sky/compact.cpp:131 engines/sky/compact.cpp:141
-#: engines/sword1/animation.cpp:524 engines/sword1/animation.cpp:545
-#: engines/sword1/animation.cpp:561 engines/sword1/animation.cpp:569
-#: engines/sword1/control.cpp:865 engines/sword1/logic.cpp:1633
-#: engines/sword2/animation.cpp:425 engines/sword2/animation.cpp:445
-#: engines/sword2/animation.cpp:461 engines/sword2/animation.cpp:471
+#: engines/scumm/players/player_v3m.cpp:130
+#: engines/scumm/players/player_v5m.cpp:108 engines/sky/compact.cpp:131
+#: engines/sky/compact.cpp:141 engines/sword1/animation.cpp:524
+#: engines/sword1/animation.cpp:545 engines/sword1/animation.cpp:561
+#: engines/sword1/animation.cpp:569 engines/sword1/control.cpp:865
+#: engines/sword1/logic.cpp:1633 engines/sword2/animation.cpp:425
+#: engines/sword2/animation.cpp:445 engines/sword2/animation.cpp:461
+#: engines/sword2/animation.cpp:471
msgid "OK"
msgstr "OK"
@@ -453,7 +455,7 @@ msgstr "Sјg:"
#: gui/launcher.cpp:685 engines/dialogs.cpp:115 engines/cruise/menu.cpp:214
#: engines/mohawk/myst.cpp:245 engines/mohawk/riven.cpp:718
-#: engines/pegasus/pegasus.cpp:353
+#: engines/pegasus/pegasus.cpp:353 engines/tsage/scenes.cpp:600
msgid "Load game:"
msgstr "Indlцs spil:"
@@ -462,7 +464,7 @@ msgstr "Indlцs spil:"
#: backends/platform/wince/CEActionsSmartphone.cpp:231
#: engines/cruise/menu.cpp:214 engines/mohawk/myst.cpp:245
#: engines/mohawk/riven.cpp:718 engines/pegasus/pegasus.cpp:353
-#: engines/scumm/dialogs.cpp:189
+#: engines/scumm/dialogs.cpp:189 engines/tsage/scenes.cpp:600
msgid "Load"
msgstr "Indlцs"
@@ -480,6 +482,7 @@ msgstr ""
#: backends/platform/wince/CEActionsPocket.cpp:326
#: backends/platform/wince/CEActionsSmartphone.cpp:287
#: backends/platform/wince/CELauncherDialog.cpp:83
+#: engines/kyra/saveload_eob.cpp:557 engines/kyra/saveload_eob.cpp:590
msgid "Yes"
msgstr "Ja"
@@ -489,6 +492,7 @@ msgstr "Ja"
#: backends/platform/wince/CEActionsPocket.cpp:326
#: backends/platform/wince/CEActionsSmartphone.cpp:287
#: backends/platform/wince/CELauncherDialog.cpp:83
+#: engines/kyra/saveload_eob.cpp:557 engines/kyra/saveload_eob.cpp:590
msgid "No"
msgstr "Nej"
@@ -1267,8 +1271,9 @@ msgstr "~R~etur til oversigt"
#: engines/dialogs.cpp:116 engines/agi/saveload.cpp:803
#: engines/cruise/menu.cpp:212 engines/drascula/saveload.cpp:336
-#: engines/neverhood/menumodule.cpp:873 engines/pegasus/pegasus.cpp:377
-#: engines/sci/engine/kfile.cpp:758 engines/toltecs/menu.cpp:281
+#: engines/dreamweb/saveload.cpp:261 engines/neverhood/menumodule.cpp:873
+#: engines/pegasus/pegasus.cpp:377 engines/sci/engine/kfile.cpp:758
+#: engines/toltecs/menu.cpp:281 engines/tsage/scenes.cpp:598
msgid "Save game:"
msgstr "Gemmer:"
@@ -1278,9 +1283,10 @@ msgstr "Gemmer:"
#: backends/platform/wince/CEActionsSmartphone.cpp:45
#: backends/platform/wince/CEActionsSmartphone.cpp:231
#: engines/agi/saveload.cpp:803 engines/cruise/menu.cpp:212
-#: engines/drascula/saveload.cpp:336 engines/neverhood/menumodule.cpp:873
-#: engines/pegasus/pegasus.cpp:377 engines/sci/engine/kfile.cpp:758
-#: engines/scumm/dialogs.cpp:188 engines/toltecs/menu.cpp:281
+#: engines/drascula/saveload.cpp:336 engines/dreamweb/saveload.cpp:261
+#: engines/neverhood/menumodule.cpp:873 engines/pegasus/pegasus.cpp:377
+#: engines/sci/engine/kfile.cpp:758 engines/scumm/dialogs.cpp:188
+#: engines/toltecs/menu.cpp:281 engines/tsage/scenes.cpp:598
msgid "Save"
msgstr "Gem"
@@ -1304,12 +1310,12 @@ msgstr ""
"oplysninger, og for at fх instruktioner om, hvordan man fхr yderligere hjцlp."
#: engines/dialogs.cpp:307 engines/mohawk/dialogs.cpp:109
-#: engines/mohawk/dialogs.cpp:170
+#: engines/mohawk/dialogs.cpp:170 engines/tsage/dialogs.cpp:106
msgid "~O~K"
msgstr "~O~K"
#: engines/dialogs.cpp:308 engines/mohawk/dialogs.cpp:110
-#: engines/mohawk/dialogs.cpp:171
+#: engines/mohawk/dialogs.cpp:171 engines/tsage/dialogs.cpp:107
msgid "~C~ancel"
msgstr "~F~ortryd"
@@ -2074,24 +2080,26 @@ msgstr "Klik deaktiveret"
#: engines/agi/detection.cpp:142 engines/drascula/detection.cpp:302
#: engines/dreamweb/detection.cpp:47 engines/neverhood/detection.cpp:160
#: engines/sci/detection.cpp:394 engines/toltecs/detection.cpp:200
+#: engines/zvision/detection.cpp:103
msgid "Use original save/load screens"
msgstr "Brug original gem/indlцs skцrme"
#: engines/agi/detection.cpp:143 engines/drascula/detection.cpp:303
#: engines/dreamweb/detection.cpp:48 engines/neverhood/detection.cpp:161
#: engines/sci/detection.cpp:395 engines/toltecs/detection.cpp:201
+#: engines/zvision/detection.cpp:104
msgid "Use the original save/load screens, instead of the ScummVM ones"
msgstr "Brug de originale gem/indlцs skцrme, istedet for dem fra ScummVM"
#: engines/agi/saveload.cpp:816 engines/drascula/saveload.cpp:349
-#: engines/neverhood/menumodule.cpp:886 engines/sci/engine/kfile.cpp:857
-#: engines/toltecs/menu.cpp:256
+#: engines/dreamweb/saveload.cpp:169 engines/neverhood/menumodule.cpp:886
+#: engines/sci/engine/kfile.cpp:857 engines/toltecs/menu.cpp:256
msgid "Restore game:"
msgstr "Gendan spil:"
#: engines/agi/saveload.cpp:816 engines/drascula/saveload.cpp:349
-#: engines/neverhood/menumodule.cpp:886 engines/sci/engine/kfile.cpp:857
-#: engines/toltecs/menu.cpp:256
+#: engines/dreamweb/saveload.cpp:169 engines/neverhood/menumodule.cpp:886
+#: engines/sci/engine/kfile.cpp:857 engines/toltecs/menu.cpp:256
msgid "Restore"
msgstr "Gendan"
@@ -2133,6 +2141,15 @@ msgstr ""
msgid "Cutscene file '%s' not found!"
msgstr "Filmsekvens fil '%s' ikke fundet!"
+#: engines/cge/detection.cpp:105 engines/cge2/detection.cpp:81
+#, fuzzy
+msgid "Color Blind Mode"
+msgstr "Klik tilstand"
+
+#: engines/cge/detection.cpp:106 engines/cge2/detection.cpp:82
+msgid "Enable Color Blind Mode by default"
+msgstr ""
+
#: engines/drascula/saveload.cpp:47
msgid ""
"ScummVM found that you have old savefiles for Drascula that should be "
@@ -2160,11 +2177,12 @@ msgid "Display graphics using the game's bright palette"
msgstr "Vis grafik ved hjцlp af spillets lyse palette"
#: engines/gob/inter_playtoons.cpp:256 engines/gob/inter_v2.cpp:1470
-#: engines/tinsel/saveload.cpp:532
+#: engines/gob/inter_geisha.cpp:232 engines/tinsel/saveload.cpp:532
msgid "Failed to load game state from file."
msgstr "Mislykkedes at indlцse spil tilstand fra fil."
-#: engines/gob/inter_v2.cpp:1540 engines/tinsel/saveload.cpp:545
+#: engines/gob/inter_v2.cpp:1540 engines/gob/inter_geisha.cpp:263
+#: engines/tinsel/saveload.cpp:545
msgid "Failed to save game state to file."
msgstr "Mislykkedes at gemme spil tilstand til fil."
@@ -2184,6 +2202,14 @@ msgstr "Afspil film med forhјjet hastighed"
msgid "Failed to save game"
msgstr "Mislykkedes at gemme spil"
+#: engines/hopkins/detection.cpp:76 engines/hopkins/detection.cpp:86
+msgid "Gore Mode"
+msgstr ""
+
+#: engines/hopkins/detection.cpp:77 engines/hopkins/detection.cpp:87
+msgid "Enable Gore Mode when available"
+msgstr ""
+
#. I18N: Studio audience adds an applause and cheering sounds whenever
#. Malcolm makes a joke.
#: engines/kyra/detection.cpp:62
@@ -2304,6 +2330,35 @@ msgstr ""
"dem i Generel MIDI. Trods det kan det ske\n"
"at nogle stykker ikke lyder korrekt."
+#: engines/kyra/saveload_eob.cpp:557
+#, c-format
+msgid ""
+"The following original save game file has been found in your game path:\n"
+"\n"
+"%s %s\n"
+"\n"
+"Do you wish to use this save game file with ScummVM?\n"
+"\n"
+msgstr ""
+
+#: engines/kyra/saveload_eob.cpp:590
+#, c-format
+msgid ""
+"A save game file was found in the specified slot %d. Overwrite?\n"
+"\n"
+msgstr ""
+
+#: engines/kyra/saveload_eob.cpp:623
+#, c-format
+msgid ""
+"%d original save game files have been successfully imported into\n"
+"ScummVM. If you want to manually import original save game files later you "
+"will\n"
+"need to open the ScummVM debug console and use the command "
+"'import_savefile'.\n"
+"\n"
+msgstr ""
+
#. I18N: Option for fast scene switching
#: engines/mohawk/dialogs.cpp:92 engines/mohawk/dialogs.cpp:167
msgid "~Z~ip Mode Activated"
@@ -2433,6 +2488,14 @@ msgstr "Vis/Skjul Info skцrm"
msgid "Display/Hide Pause Menu"
msgstr "Vis/Skjul Pause menu"
+#: engines/queen/detection.cpp:56
+msgid "Alternative intro"
+msgstr "Alternativ intro"
+
+#: engines/queen/detection.cpp:57
+msgid "Use an alternative game intro (CD version only)"
+msgstr "Brug en alternativ spil intro (kun CD version)"
+
#: engines/sci/detection.cpp:374
msgid "EGA undithering"
msgstr "EGA farveforјgelse"
@@ -3132,6 +3195,18 @@ msgstr ""
"endnu. For at spille det, gх til 'Tilfјj spil' i ScummVM start-menuen og "
"vцlg 'Maniac' mappen inde i Tentacle spillets mappe."
+#: engines/scumm/players/player_v3m.cpp:129
+msgid ""
+"Could not find the 'Loom' Macintosh executable to read the\n"
+"instruments from. Music will be disabled."
+msgstr ""
+
+#: engines/scumm/players/player_v5m.cpp:107
+msgid ""
+"Could not find the 'Monkey Island' Macintosh executable to read the\n"
+"instruments from. Music will be disabled."
+msgstr ""
+
#: engines/sky/compact.cpp:130
msgid ""
"Unable to find \"sky.cpt\" file!\n"
@@ -3243,6 +3318,14 @@ msgstr ""
"Teenagent.dat filen er komprimeret og zlib er ikke blevet inkluderet i dette "
"program. Udpak den venligst"
+#: engines/wintermute/detection.cpp:58
+msgid "Show FPS-counter"
+msgstr ""
+
+#: engines/wintermute/detection.cpp:59
+msgid "Show the current number of frames per second in the upper left corner"
+msgstr ""
+
#~ msgid "MPEG-2 cutscenes found but ScummVM has been built without MPEG-2"
#~ msgstr "MPEG-2 filmsekvenser fundet, men ScummVM er bygget uden MPEG-2"
@@ -3260,12 +3343,6 @@ msgstr ""
#~ msgid "Standard (16bpp)"
#~ msgstr "Standard (16bpp)"
-#~ msgid "Alternative intro"
-#~ msgstr "Alternativ intro"
-
-#~ msgid "Use an alternative game intro (CD version only)"
-#~ msgstr "Brug en alternativ spil intro (kun CD version)"
-
#~ msgid "MPEG2 cutscenes are no longer supported"
#~ msgstr "MPEG2 filmsekvenser understјttes ikke lцngere"
diff --git a/po/de_DE.po b/po/de_DE.po
index 3fb083d8a2..c127f109bf 100644
--- a/po/de_DE.po
+++ b/po/de_DE.po
@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: ScummVM 1.5.0git\n"
"Report-Msgid-Bugs-To: scummvm-devel@lists.sf.net\n"
-"POT-Creation-Date: 2014-09-03 07:39+0200\n"
+"POT-Creation-Date: 2014-10-04 00:58+0100\n"
"PO-Revision-Date: 2014-06-14 19:34+0100\n"
"Last-Translator: Simon Sawatzki <SimSaw@gmx.de>\n"
"Language-Team: Simon Sawatzki <SimSaw@gmx.de>, Lothar Serra Mari (retired)\n"
@@ -108,12 +108,14 @@ msgstr "Zuweisen"
#: engines/agos/animation.cpp:558 engines/drascula/saveload.cpp:49
#: engines/groovie/script.cpp:399 engines/parallaction/saveload.cpp:274
#: engines/scumm/dialogs.cpp:193 engines/scumm/scumm.cpp:1825
-#: engines/sky/compact.cpp:131 engines/sky/compact.cpp:141
-#: engines/sword1/animation.cpp:524 engines/sword1/animation.cpp:545
-#: engines/sword1/animation.cpp:561 engines/sword1/animation.cpp:569
-#: engines/sword1/control.cpp:865 engines/sword1/logic.cpp:1633
-#: engines/sword2/animation.cpp:425 engines/sword2/animation.cpp:445
-#: engines/sword2/animation.cpp:461 engines/sword2/animation.cpp:471
+#: engines/scumm/players/player_v3m.cpp:130
+#: engines/scumm/players/player_v5m.cpp:108 engines/sky/compact.cpp:131
+#: engines/sky/compact.cpp:141 engines/sword1/animation.cpp:524
+#: engines/sword1/animation.cpp:545 engines/sword1/animation.cpp:561
+#: engines/sword1/animation.cpp:569 engines/sword1/control.cpp:865
+#: engines/sword1/logic.cpp:1633 engines/sword2/animation.cpp:425
+#: engines/sword2/animation.cpp:445 engines/sword2/animation.cpp:461
+#: engines/sword2/animation.cpp:471
msgid "OK"
msgstr "OK"
@@ -454,7 +456,7 @@ msgstr "Suchen:"
#: gui/launcher.cpp:685 engines/dialogs.cpp:115 engines/cruise/menu.cpp:214
#: engines/mohawk/myst.cpp:245 engines/mohawk/riven.cpp:718
-#: engines/pegasus/pegasus.cpp:353
+#: engines/pegasus/pegasus.cpp:353 engines/tsage/scenes.cpp:600
msgid "Load game:"
msgstr "Spiel laden:"
@@ -463,7 +465,7 @@ msgstr "Spiel laden:"
#: backends/platform/wince/CEActionsSmartphone.cpp:231
#: engines/cruise/menu.cpp:214 engines/mohawk/myst.cpp:245
#: engines/mohawk/riven.cpp:718 engines/pegasus/pegasus.cpp:353
-#: engines/scumm/dialogs.cpp:189
+#: engines/scumm/dialogs.cpp:189 engines/tsage/scenes.cpp:600
msgid "Load"
msgstr "Laden"
@@ -481,6 +483,7 @@ msgstr ""
#: backends/platform/wince/CEActionsPocket.cpp:326
#: backends/platform/wince/CEActionsSmartphone.cpp:287
#: backends/platform/wince/CELauncherDialog.cpp:83
+#: engines/kyra/saveload_eob.cpp:557 engines/kyra/saveload_eob.cpp:590
msgid "Yes"
msgstr "Ja"
@@ -490,6 +493,7 @@ msgstr "Ja"
#: backends/platform/wince/CEActionsPocket.cpp:326
#: backends/platform/wince/CEActionsSmartphone.cpp:287
#: backends/platform/wince/CELauncherDialog.cpp:83
+#: engines/kyra/saveload_eob.cpp:557 engines/kyra/saveload_eob.cpp:590
msgid "No"
msgstr "Nein"
@@ -1284,8 +1288,9 @@ msgstr "Zur Spiele~l~iste"
#: engines/dialogs.cpp:116 engines/agi/saveload.cpp:803
#: engines/cruise/menu.cpp:212 engines/drascula/saveload.cpp:336
-#: engines/neverhood/menumodule.cpp:873 engines/pegasus/pegasus.cpp:377
-#: engines/sci/engine/kfile.cpp:758 engines/toltecs/menu.cpp:281
+#: engines/dreamweb/saveload.cpp:261 engines/neverhood/menumodule.cpp:873
+#: engines/pegasus/pegasus.cpp:377 engines/sci/engine/kfile.cpp:758
+#: engines/toltecs/menu.cpp:281 engines/tsage/scenes.cpp:598
msgid "Save game:"
msgstr "Speichern:"
@@ -1295,9 +1300,10 @@ msgstr "Speichern:"
#: backends/platform/wince/CEActionsSmartphone.cpp:45
#: backends/platform/wince/CEActionsSmartphone.cpp:231
#: engines/agi/saveload.cpp:803 engines/cruise/menu.cpp:212
-#: engines/drascula/saveload.cpp:336 engines/neverhood/menumodule.cpp:873
-#: engines/pegasus/pegasus.cpp:377 engines/sci/engine/kfile.cpp:758
-#: engines/scumm/dialogs.cpp:188 engines/toltecs/menu.cpp:281
+#: engines/drascula/saveload.cpp:336 engines/dreamweb/saveload.cpp:261
+#: engines/neverhood/menumodule.cpp:873 engines/pegasus/pegasus.cpp:377
+#: engines/sci/engine/kfile.cpp:758 engines/scumm/dialogs.cpp:188
+#: engines/toltecs/menu.cpp:281 engines/tsage/scenes.cpp:598
msgid "Save"
msgstr "Speichern"
@@ -1320,12 +1326,12 @@ msgstr ""
"Datei fќr grundlegende Informationen und Anweisungen zu weiterer Hilfe."
#: engines/dialogs.cpp:307 engines/mohawk/dialogs.cpp:109
-#: engines/mohawk/dialogs.cpp:170
+#: engines/mohawk/dialogs.cpp:170 engines/tsage/dialogs.cpp:106
msgid "~O~K"
msgstr "~O~K"
#: engines/dialogs.cpp:308 engines/mohawk/dialogs.cpp:110
-#: engines/mohawk/dialogs.cpp:171
+#: engines/mohawk/dialogs.cpp:171 engines/tsage/dialogs.cpp:107
msgid "~C~ancel"
msgstr "~A~bbrechen"
@@ -2095,25 +2101,27 @@ msgstr "Klicken deaktiviert"
#: engines/agi/detection.cpp:142 engines/drascula/detection.cpp:302
#: engines/dreamweb/detection.cpp:47 engines/neverhood/detection.cpp:160
#: engines/sci/detection.cpp:394 engines/toltecs/detection.cpp:200
+#: engines/zvision/detection.cpp:103
msgid "Use original save/load screens"
msgstr "Originale Spielstand-Menќs"
#: engines/agi/detection.cpp:143 engines/drascula/detection.cpp:303
#: engines/dreamweb/detection.cpp:48 engines/neverhood/detection.cpp:161
#: engines/sci/detection.cpp:395 engines/toltecs/detection.cpp:201
+#: engines/zvision/detection.cpp:104
msgid "Use the original save/load screens, instead of the ScummVM ones"
msgstr ""
"Verwendet die originalen Menќs zum Speichern und Laden statt der von ScummVM."
#: engines/agi/saveload.cpp:816 engines/drascula/saveload.cpp:349
-#: engines/neverhood/menumodule.cpp:886 engines/sci/engine/kfile.cpp:857
-#: engines/toltecs/menu.cpp:256
+#: engines/dreamweb/saveload.cpp:169 engines/neverhood/menumodule.cpp:886
+#: engines/sci/engine/kfile.cpp:857 engines/toltecs/menu.cpp:256
msgid "Restore game:"
msgstr "Spiel laden:"
#: engines/agi/saveload.cpp:816 engines/drascula/saveload.cpp:349
-#: engines/neverhood/menumodule.cpp:886 engines/sci/engine/kfile.cpp:857
-#: engines/toltecs/menu.cpp:256
+#: engines/dreamweb/saveload.cpp:169 engines/neverhood/menumodule.cpp:886
+#: engines/sci/engine/kfile.cpp:857 engines/toltecs/menu.cpp:256
msgid "Restore"
msgstr "Laden"
@@ -2155,6 +2163,15 @@ msgstr ""
msgid "Cutscene file '%s' not found!"
msgstr "Zwischensequenz \"%s\" nicht gefunden!"
+#: engines/cge/detection.cpp:105 engines/cge2/detection.cpp:81
+#, fuzzy
+msgid "Color Blind Mode"
+msgstr "Klickmodus"
+
+#: engines/cge/detection.cpp:106 engines/cge2/detection.cpp:82
+msgid "Enable Color Blind Mode by default"
+msgstr ""
+
#: engines/drascula/saveload.cpp:47
msgid ""
"ScummVM found that you have old savefiles for Drascula that should be "
@@ -2182,11 +2199,12 @@ msgid "Display graphics using the game's bright palette"
msgstr "Zeigt Grafiken ќber helle Spielpalette an."
#: engines/gob/inter_playtoons.cpp:256 engines/gob/inter_v2.cpp:1470
-#: engines/tinsel/saveload.cpp:532
+#: engines/gob/inter_geisha.cpp:232 engines/tinsel/saveload.cpp:532
msgid "Failed to load game state from file."
msgstr "Konnte Spielstand aus Datei nicht laden."
-#: engines/gob/inter_v2.cpp:1540 engines/tinsel/saveload.cpp:545
+#: engines/gob/inter_v2.cpp:1540 engines/gob/inter_geisha.cpp:263
+#: engines/tinsel/saveload.cpp:545
msgid "Failed to save game state to file."
msgstr "Konnte Spielstand nicht in Datei speichern."
@@ -2206,6 +2224,14 @@ msgstr "Spielt Filme mit erhіhter Geschwindigkeit ab."
msgid "Failed to save game"
msgstr "Konnte Spielstand nicht speichern."
+#: engines/hopkins/detection.cpp:76 engines/hopkins/detection.cpp:86
+msgid "Gore Mode"
+msgstr ""
+
+#: engines/hopkins/detection.cpp:77 engines/hopkins/detection.cpp:87
+msgid "Enable Gore Mode when available"
+msgstr ""
+
#. I18N: Studio audience adds an applause and cheering sounds whenever
#. Malcolm makes a joke.
#: engines/kyra/detection.cpp:62
@@ -2328,6 +2354,35 @@ msgstr ""
"mіglich, dass ein paar Musikstќcke nicht\n"
"richtig abgespielt werden."
+#: engines/kyra/saveload_eob.cpp:557
+#, c-format
+msgid ""
+"The following original save game file has been found in your game path:\n"
+"\n"
+"%s %s\n"
+"\n"
+"Do you wish to use this save game file with ScummVM?\n"
+"\n"
+msgstr ""
+
+#: engines/kyra/saveload_eob.cpp:590
+#, c-format
+msgid ""
+"A save game file was found in the specified slot %d. Overwrite?\n"
+"\n"
+msgstr ""
+
+#: engines/kyra/saveload_eob.cpp:623
+#, c-format
+msgid ""
+"%d original save game files have been successfully imported into\n"
+"ScummVM. If you want to manually import original save game files later you "
+"will\n"
+"need to open the ScummVM debug console and use the command "
+"'import_savefile'.\n"
+"\n"
+msgstr ""
+
#. I18N: Option for fast scene switching
#: engines/mohawk/dialogs.cpp:92 engines/mohawk/dialogs.cpp:167
msgid "~Z~ip Mode Activated"
@@ -2459,6 +2514,14 @@ msgstr "Info-Bildschirm anzeigen/verbergen"
msgid "Display/Hide Pause Menu"
msgstr "Pause-Menќ anzeigen/verbergen"
+#: engines/queen/detection.cpp:56
+msgid "Alternative intro"
+msgstr "Alternativer Vorspann"
+
+#: engines/queen/detection.cpp:57
+msgid "Use an alternative game intro (CD version only)"
+msgstr "Verwendet einen alternativen Vorspann (nur bei CD-Version)."
+
#: engines/sci/detection.cpp:374
msgid "EGA undithering"
msgstr "Antifehlerdiffusion fќr EGA"
@@ -3163,6 +3226,18 @@ msgstr ""
"im Startmenќ von ScummVM und wфhlen das Verzeichnis \"Maniac\" im "
"Verzeichnis dieses Spiels aus."
+#: engines/scumm/players/player_v3m.cpp:129
+msgid ""
+"Could not find the 'Loom' Macintosh executable to read the\n"
+"instruments from. Music will be disabled."
+msgstr ""
+
+#: engines/scumm/players/player_v5m.cpp:107
+msgid ""
+"Could not find the 'Monkey Island' Macintosh executable to read the\n"
+"instruments from. Music will be disabled."
+msgstr ""
+
#: engines/sky/compact.cpp:130
msgid ""
"Unable to find \"sky.cpt\" file!\n"
@@ -3282,6 +3357,14 @@ msgstr ""
"Die Datei teenagent.dat ist gepackt und zlib zum Entpacken wurde in dieser "
"ausfќhrbaren Datei nicht miteingebunden. Bitte entpacken Sie die Datei."
+#: engines/wintermute/detection.cpp:58
+msgid "Show FPS-counter"
+msgstr ""
+
+#: engines/wintermute/detection.cpp:59
+msgid "Show the current number of frames per second in the upper left corner"
+msgstr ""
+
#~ msgid "MPEG-2 cutscenes found but ScummVM has been built without MPEG-2"
#~ msgstr ""
#~ "MPEG-2-Zwischensequenzen gefunden, aber ScummVM wurde ohne Unterstќtzung "
@@ -3303,12 +3386,6 @@ msgstr ""
#~ msgid "Standard (16bpp)"
#~ msgstr "Standard (16bpp)"
-#~ msgid "Alternative intro"
-#~ msgstr "Alternativer Vorspann"
-
-#~ msgid "Use an alternative game intro (CD version only)"
-#~ msgstr "Verwendet einen alternativen Vorspann (nur bei CD-Version)."
-
#~ msgid "MPEG2 cutscenes are no longer supported"
#~ msgstr "MPEG2-Zwischensequenzen werden nicht mehr unterstќtzt."
diff --git a/po/es_ES.po b/po/es_ES.po
index 312eeed5f1..479747bb20 100644
--- a/po/es_ES.po
+++ b/po/es_ES.po
@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: ScummVM 1.4.0svn\n"
"Report-Msgid-Bugs-To: scummvm-devel@lists.sf.net\n"
-"POT-Creation-Date: 2014-09-03 07:39+0200\n"
+"POT-Creation-Date: 2014-10-04 00:58+0100\n"
"PO-Revision-Date: 2014-07-06 20:39+0100\n"
"Last-Translator: \n"
"Language-Team: \n"
@@ -108,12 +108,14 @@ msgstr "Asignar"
#: engines/agos/animation.cpp:558 engines/drascula/saveload.cpp:49
#: engines/groovie/script.cpp:399 engines/parallaction/saveload.cpp:274
#: engines/scumm/dialogs.cpp:193 engines/scumm/scumm.cpp:1825
-#: engines/sky/compact.cpp:131 engines/sky/compact.cpp:141
-#: engines/sword1/animation.cpp:524 engines/sword1/animation.cpp:545
-#: engines/sword1/animation.cpp:561 engines/sword1/animation.cpp:569
-#: engines/sword1/control.cpp:865 engines/sword1/logic.cpp:1633
-#: engines/sword2/animation.cpp:425 engines/sword2/animation.cpp:445
-#: engines/sword2/animation.cpp:461 engines/sword2/animation.cpp:471
+#: engines/scumm/players/player_v3m.cpp:130
+#: engines/scumm/players/player_v5m.cpp:108 engines/sky/compact.cpp:131
+#: engines/sky/compact.cpp:141 engines/sword1/animation.cpp:524
+#: engines/sword1/animation.cpp:545 engines/sword1/animation.cpp:561
+#: engines/sword1/animation.cpp:569 engines/sword1/control.cpp:865
+#: engines/sword1/logic.cpp:1633 engines/sword2/animation.cpp:425
+#: engines/sword2/animation.cpp:445 engines/sword2/animation.cpp:461
+#: engines/sword2/animation.cpp:471
msgid "OK"
msgstr "Aceptar"
@@ -452,7 +454,7 @@ msgstr "Buscar:"
#: gui/launcher.cpp:685 engines/dialogs.cpp:115 engines/cruise/menu.cpp:214
#: engines/mohawk/myst.cpp:245 engines/mohawk/riven.cpp:718
-#: engines/pegasus/pegasus.cpp:353
+#: engines/pegasus/pegasus.cpp:353 engines/tsage/scenes.cpp:600
msgid "Load game:"
msgstr "Cargar juego:"
@@ -461,7 +463,7 @@ msgstr "Cargar juego:"
#: backends/platform/wince/CEActionsSmartphone.cpp:231
#: engines/cruise/menu.cpp:214 engines/mohawk/myst.cpp:245
#: engines/mohawk/riven.cpp:718 engines/pegasus/pegasus.cpp:353
-#: engines/scumm/dialogs.cpp:189
+#: engines/scumm/dialogs.cpp:189 engines/tsage/scenes.cpp:600
msgid "Load"
msgstr "Cargar"
@@ -479,6 +481,7 @@ msgstr ""
#: backends/platform/wince/CEActionsPocket.cpp:326
#: backends/platform/wince/CEActionsSmartphone.cpp:287
#: backends/platform/wince/CELauncherDialog.cpp:83
+#: engines/kyra/saveload_eob.cpp:557 engines/kyra/saveload_eob.cpp:590
msgid "Yes"
msgstr "Sэ"
@@ -488,6 +491,7 @@ msgstr "Sэ"
#: backends/platform/wince/CEActionsPocket.cpp:326
#: backends/platform/wince/CEActionsSmartphone.cpp:287
#: backends/platform/wince/CELauncherDialog.cpp:83
+#: engines/kyra/saveload_eob.cpp:557 engines/kyra/saveload_eob.cpp:590
msgid "No"
msgstr "No"
@@ -1273,8 +1277,9 @@ msgstr "~V~olver al lanzador"
#: engines/dialogs.cpp:116 engines/agi/saveload.cpp:803
#: engines/cruise/menu.cpp:212 engines/drascula/saveload.cpp:336
-#: engines/neverhood/menumodule.cpp:873 engines/pegasus/pegasus.cpp:377
-#: engines/sci/engine/kfile.cpp:758 engines/toltecs/menu.cpp:281
+#: engines/dreamweb/saveload.cpp:261 engines/neverhood/menumodule.cpp:873
+#: engines/pegasus/pegasus.cpp:377 engines/sci/engine/kfile.cpp:758
+#: engines/toltecs/menu.cpp:281 engines/tsage/scenes.cpp:598
msgid "Save game:"
msgstr "Guardar partida"
@@ -1284,9 +1289,10 @@ msgstr "Guardar partida"
#: backends/platform/wince/CEActionsSmartphone.cpp:45
#: backends/platform/wince/CEActionsSmartphone.cpp:231
#: engines/agi/saveload.cpp:803 engines/cruise/menu.cpp:212
-#: engines/drascula/saveload.cpp:336 engines/neverhood/menumodule.cpp:873
-#: engines/pegasus/pegasus.cpp:377 engines/sci/engine/kfile.cpp:758
-#: engines/scumm/dialogs.cpp:188 engines/toltecs/menu.cpp:281
+#: engines/drascula/saveload.cpp:336 engines/dreamweb/saveload.cpp:261
+#: engines/neverhood/menumodule.cpp:873 engines/pegasus/pegasus.cpp:377
+#: engines/sci/engine/kfile.cpp:758 engines/scumm/dialogs.cpp:188
+#: engines/toltecs/menu.cpp:281 engines/tsage/scenes.cpp:598
msgid "Save"
msgstr "Guardar"
@@ -1311,12 +1317,12 @@ msgstr ""
"obtener mсs ayuda."
#: engines/dialogs.cpp:307 engines/mohawk/dialogs.cpp:109
-#: engines/mohawk/dialogs.cpp:170
+#: engines/mohawk/dialogs.cpp:170 engines/tsage/dialogs.cpp:106
msgid "~O~K"
msgstr "~S~э"
#: engines/dialogs.cpp:308 engines/mohawk/dialogs.cpp:110
-#: engines/mohawk/dialogs.cpp:171
+#: engines/mohawk/dialogs.cpp:171 engines/tsage/dialogs.cpp:107
msgid "~C~ancel"
msgstr "~C~ancelar"
@@ -2082,25 +2088,27 @@ msgstr "Clic desactivado"
#: engines/agi/detection.cpp:142 engines/drascula/detection.cpp:302
#: engines/dreamweb/detection.cpp:47 engines/neverhood/detection.cpp:160
#: engines/sci/detection.cpp:394 engines/toltecs/detection.cpp:200
+#: engines/zvision/detection.cpp:103
msgid "Use original save/load screens"
msgstr "Usar pantallas de guardar/cargar originales"
#: engines/agi/detection.cpp:143 engines/drascula/detection.cpp:303
#: engines/dreamweb/detection.cpp:48 engines/neverhood/detection.cpp:161
#: engines/sci/detection.cpp:395 engines/toltecs/detection.cpp:201
+#: engines/zvision/detection.cpp:104
msgid "Use the original save/load screens, instead of the ScummVM ones"
msgstr ""
"Utilizar las pantallas de guardar/cargar originales, en vez de las de ScummVM"
#: engines/agi/saveload.cpp:816 engines/drascula/saveload.cpp:349
-#: engines/neverhood/menumodule.cpp:886 engines/sci/engine/kfile.cpp:857
-#: engines/toltecs/menu.cpp:256
+#: engines/dreamweb/saveload.cpp:169 engines/neverhood/menumodule.cpp:886
+#: engines/sci/engine/kfile.cpp:857 engines/toltecs/menu.cpp:256
msgid "Restore game:"
msgstr "Cargar partida:"
#: engines/agi/saveload.cpp:816 engines/drascula/saveload.cpp:349
-#: engines/neverhood/menumodule.cpp:886 engines/sci/engine/kfile.cpp:857
-#: engines/toltecs/menu.cpp:256
+#: engines/dreamweb/saveload.cpp:169 engines/neverhood/menumodule.cpp:886
+#: engines/sci/engine/kfile.cpp:857 engines/toltecs/menu.cpp:256
msgid "Restore"
msgstr "Cargar"
@@ -2142,6 +2150,15 @@ msgstr ""
msgid "Cutscene file '%s' not found!"
msgstr "No se ha encontrado el vэdeo '%s'"
+#: engines/cge/detection.cpp:105 engines/cge2/detection.cpp:81
+#, fuzzy
+msgid "Color Blind Mode"
+msgstr "Modo clic"
+
+#: engines/cge/detection.cpp:106 engines/cge2/detection.cpp:82
+msgid "Enable Color Blind Mode by default"
+msgstr ""
+
#: engines/drascula/saveload.cpp:47
msgid ""
"ScummVM found that you have old savefiles for Drascula that should be "
@@ -2169,11 +2186,12 @@ msgid "Display graphics using the game's bright palette"
msgstr "Utilizar los niveles de brillo originales del juego"
#: engines/gob/inter_playtoons.cpp:256 engines/gob/inter_v2.cpp:1470
-#: engines/tinsel/saveload.cpp:532
+#: engines/gob/inter_geisha.cpp:232 engines/tinsel/saveload.cpp:532
msgid "Failed to load game state from file."
msgstr "Fallo al cargar el estado del juego desde el archivo."
-#: engines/gob/inter_v2.cpp:1540 engines/tinsel/saveload.cpp:545
+#: engines/gob/inter_v2.cpp:1540 engines/gob/inter_geisha.cpp:263
+#: engines/tinsel/saveload.cpp:545
msgid "Failed to save game state to file."
msgstr "Fallo al guardar el estado del juego en el archivo."
@@ -2193,6 +2211,14 @@ msgstr "Reproducir vэdeos a mayor velocidad"
msgid "Failed to save game"
msgstr "Fallo al guardar la partida"
+#: engines/hopkins/detection.cpp:76 engines/hopkins/detection.cpp:86
+msgid "Gore Mode"
+msgstr ""
+
+#: engines/hopkins/detection.cpp:77 engines/hopkins/detection.cpp:87
+msgid "Enable Gore Mode when available"
+msgstr ""
+
#. I18N: Studio audience adds an applause and cheering sounds whenever
#. Malcolm makes a joke.
#: engines/kyra/detection.cpp:62
@@ -2313,6 +2339,35 @@ msgstr ""
"a los de General MIDI, pero es posible que algunas\n"
"de las pistas no suenen correctamente."
+#: engines/kyra/saveload_eob.cpp:557
+#, c-format
+msgid ""
+"The following original save game file has been found in your game path:\n"
+"\n"
+"%s %s\n"
+"\n"
+"Do you wish to use this save game file with ScummVM?\n"
+"\n"
+msgstr ""
+
+#: engines/kyra/saveload_eob.cpp:590
+#, c-format
+msgid ""
+"A save game file was found in the specified slot %d. Overwrite?\n"
+"\n"
+msgstr ""
+
+#: engines/kyra/saveload_eob.cpp:623
+#, c-format
+msgid ""
+"%d original save game files have been successfully imported into\n"
+"ScummVM. If you want to manually import original save game files later you "
+"will\n"
+"need to open the ScummVM debug console and use the command "
+"'import_savefile'.\n"
+"\n"
+msgstr ""
+
#. I18N: Option for fast scene switching
#: engines/mohawk/dialogs.cpp:92 engines/mohawk/dialogs.cpp:167
msgid "~Z~ip Mode Activated"
@@ -2442,6 +2497,15 @@ msgstr "Mostrar/Ocultar pantalla de informaciѓn"
msgid "Display/Hide Pause Menu"
msgstr "Mostrar/Ocultar menњ de pausa"
+#: engines/queen/detection.cpp:56
+msgid "Alternative intro"
+msgstr "Introducciѓn alternativa"
+
+#: engines/queen/detection.cpp:57
+msgid "Use an alternative game intro (CD version only)"
+msgstr ""
+"Usa una introducciѓn alternativa para el juego (solo para la versiѓn CD)"
+
#: engines/sci/detection.cpp:374
msgid "EGA undithering"
msgstr "Difuminado EGA"
@@ -3142,6 +3206,18 @@ msgstr ""
"permite. Para jugar, ve a 'Aёadir juego' en el menњ de inicio de ScummVM y "
"selecciona el directorio 'Maniac', dentro del directorio de DOTT."
+#: engines/scumm/players/player_v3m.cpp:129
+msgid ""
+"Could not find the 'Loom' Macintosh executable to read the\n"
+"instruments from. Music will be disabled."
+msgstr ""
+
+#: engines/scumm/players/player_v5m.cpp:107
+msgid ""
+"Could not find the 'Monkey Island' Macintosh executable to read the\n"
+"instruments from. Music will be disabled."
+msgstr ""
+
#: engines/sky/compact.cpp:130
msgid ""
"Unable to find \"sky.cpt\" file!\n"
@@ -3259,6 +3335,14 @@ msgstr ""
"El archivo teenagent.dat estс comprimido y este ejecutable no incluye zlib. "
"Por favor, descomprэmelo"
+#: engines/wintermute/detection.cpp:58
+msgid "Show FPS-counter"
+msgstr ""
+
+#: engines/wintermute/detection.cpp:59
+msgid "Show the current number of frames per second in the upper left corner"
+msgstr ""
+
#~ msgid "MPEG-2 cutscenes found but ScummVM has been built without MPEG-2"
#~ msgstr ""
#~ "Se han encontrado vэdeos MPEG-2, pero se ha compilado ScummVM sin MPEG-2"
@@ -3278,13 +3362,6 @@ msgstr ""
#~ msgid "Standard (16bpp)"
#~ msgstr "Estсndar (16bpp)"
-#~ msgid "Alternative intro"
-#~ msgstr "Introducciѓn alternativa"
-
-#~ msgid "Use an alternative game intro (CD version only)"
-#~ msgstr ""
-#~ "Usa una introducciѓn alternativa para el juego (solo para la versiѓn CD)"
-
#~ msgid "MPEG2 cutscenes are no longer supported"
#~ msgstr "Los vэdeos MPEG2 ya no son compatibles"
diff --git a/po/eu.po b/po/eu.po
index 3836897589..7babff50b6 100644
--- a/po/eu.po
+++ b/po/eu.po
@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: ScummVM 1.5.0git\n"
"Report-Msgid-Bugs-To: scummvm-devel@lists.sf.net\n"
-"POT-Creation-Date: 2014-09-03 07:39+0200\n"
+"POT-Creation-Date: 2014-10-04 00:58+0100\n"
"PO-Revision-Date: 2011-12-15 14:53+0100\n"
"Last-Translator: Mikel Iturbe Urretxa <mikel@hamahiru.org>\n"
"Language-Team: Librezale <librezale@librezale.org>\n"
@@ -108,12 +108,14 @@ msgstr "Esleitu"
#: engines/agos/animation.cpp:558 engines/drascula/saveload.cpp:49
#: engines/groovie/script.cpp:399 engines/parallaction/saveload.cpp:274
#: engines/scumm/dialogs.cpp:193 engines/scumm/scumm.cpp:1825
-#: engines/sky/compact.cpp:131 engines/sky/compact.cpp:141
-#: engines/sword1/animation.cpp:524 engines/sword1/animation.cpp:545
-#: engines/sword1/animation.cpp:561 engines/sword1/animation.cpp:569
-#: engines/sword1/control.cpp:865 engines/sword1/logic.cpp:1633
-#: engines/sword2/animation.cpp:425 engines/sword2/animation.cpp:445
-#: engines/sword2/animation.cpp:461 engines/sword2/animation.cpp:471
+#: engines/scumm/players/player_v3m.cpp:130
+#: engines/scumm/players/player_v5m.cpp:108 engines/sky/compact.cpp:131
+#: engines/sky/compact.cpp:141 engines/sword1/animation.cpp:524
+#: engines/sword1/animation.cpp:545 engines/sword1/animation.cpp:561
+#: engines/sword1/animation.cpp:569 engines/sword1/control.cpp:865
+#: engines/sword1/logic.cpp:1633 engines/sword2/animation.cpp:425
+#: engines/sword2/animation.cpp:445 engines/sword2/animation.cpp:461
+#: engines/sword2/animation.cpp:471
msgid "OK"
msgstr "Ados"
@@ -452,7 +454,7 @@ msgstr "Bilatu:"
#: gui/launcher.cpp:685 engines/dialogs.cpp:115 engines/cruise/menu.cpp:214
#: engines/mohawk/myst.cpp:245 engines/mohawk/riven.cpp:718
-#: engines/pegasus/pegasus.cpp:353
+#: engines/pegasus/pegasus.cpp:353 engines/tsage/scenes.cpp:600
msgid "Load game:"
msgstr "Jokoa kargatu:"
@@ -461,7 +463,7 @@ msgstr "Jokoa kargatu:"
#: backends/platform/wince/CEActionsSmartphone.cpp:231
#: engines/cruise/menu.cpp:214 engines/mohawk/myst.cpp:245
#: engines/mohawk/riven.cpp:718 engines/pegasus/pegasus.cpp:353
-#: engines/scumm/dialogs.cpp:189
+#: engines/scumm/dialogs.cpp:189 engines/tsage/scenes.cpp:600
msgid "Load"
msgstr "Kargatu"
@@ -479,6 +481,7 @@ msgstr ""
#: backends/platform/wince/CEActionsPocket.cpp:326
#: backends/platform/wince/CEActionsSmartphone.cpp:287
#: backends/platform/wince/CELauncherDialog.cpp:83
+#: engines/kyra/saveload_eob.cpp:557 engines/kyra/saveload_eob.cpp:590
msgid "Yes"
msgstr "Bai"
@@ -488,6 +491,7 @@ msgstr "Bai"
#: backends/platform/wince/CEActionsPocket.cpp:326
#: backends/platform/wince/CEActionsSmartphone.cpp:287
#: backends/platform/wince/CELauncherDialog.cpp:83
+#: engines/kyra/saveload_eob.cpp:557 engines/kyra/saveload_eob.cpp:590
msgid "No"
msgstr "Ez"
@@ -1281,8 +1285,9 @@ msgstr "It~z~uli abiarazlera"
#: engines/dialogs.cpp:116 engines/agi/saveload.cpp:803
#: engines/cruise/menu.cpp:212 engines/drascula/saveload.cpp:336
-#: engines/neverhood/menumodule.cpp:873 engines/pegasus/pegasus.cpp:377
-#: engines/sci/engine/kfile.cpp:758 engines/toltecs/menu.cpp:281
+#: engines/dreamweb/saveload.cpp:261 engines/neverhood/menumodule.cpp:873
+#: engines/pegasus/pegasus.cpp:377 engines/sci/engine/kfile.cpp:758
+#: engines/toltecs/menu.cpp:281 engines/tsage/scenes.cpp:598
msgid "Save game:"
msgstr "Gorde jokoa:"
@@ -1292,9 +1297,10 @@ msgstr "Gorde jokoa:"
#: backends/platform/wince/CEActionsSmartphone.cpp:45
#: backends/platform/wince/CEActionsSmartphone.cpp:231
#: engines/agi/saveload.cpp:803 engines/cruise/menu.cpp:212
-#: engines/drascula/saveload.cpp:336 engines/neverhood/menumodule.cpp:873
-#: engines/pegasus/pegasus.cpp:377 engines/sci/engine/kfile.cpp:758
-#: engines/scumm/dialogs.cpp:188 engines/toltecs/menu.cpp:281
+#: engines/drascula/saveload.cpp:336 engines/dreamweb/saveload.cpp:261
+#: engines/neverhood/menumodule.cpp:873 engines/pegasus/pegasus.cpp:377
+#: engines/sci/engine/kfile.cpp:758 engines/scumm/dialogs.cpp:188
+#: engines/toltecs/menu.cpp:281 engines/tsage/scenes.cpp:598
msgid "Save"
msgstr "Gorde"
@@ -1317,12 +1323,12 @@ msgstr ""
"informaziorako eta laguntza gehiago nola jaso jakiteko."
#: engines/dialogs.cpp:307 engines/mohawk/dialogs.cpp:109
-#: engines/mohawk/dialogs.cpp:170
+#: engines/mohawk/dialogs.cpp:170 engines/tsage/dialogs.cpp:106
msgid "~O~K"
msgstr "~A~dos"
#: engines/dialogs.cpp:308 engines/mohawk/dialogs.cpp:110
-#: engines/mohawk/dialogs.cpp:171
+#: engines/mohawk/dialogs.cpp:171 engines/tsage/dialogs.cpp:107
msgid "~C~ancel"
msgstr "~U~tzi"
@@ -2089,24 +2095,26 @@ msgstr "Klikatzea desgaituta"
#: engines/agi/detection.cpp:142 engines/drascula/detection.cpp:302
#: engines/dreamweb/detection.cpp:47 engines/neverhood/detection.cpp:160
#: engines/sci/detection.cpp:394 engines/toltecs/detection.cpp:200
+#: engines/zvision/detection.cpp:103
msgid "Use original save/load screens"
msgstr ""
#: engines/agi/detection.cpp:143 engines/drascula/detection.cpp:303
#: engines/dreamweb/detection.cpp:48 engines/neverhood/detection.cpp:161
#: engines/sci/detection.cpp:395 engines/toltecs/detection.cpp:201
+#: engines/zvision/detection.cpp:104
msgid "Use the original save/load screens, instead of the ScummVM ones"
msgstr ""
#: engines/agi/saveload.cpp:816 engines/drascula/saveload.cpp:349
-#: engines/neverhood/menumodule.cpp:886 engines/sci/engine/kfile.cpp:857
-#: engines/toltecs/menu.cpp:256
+#: engines/dreamweb/saveload.cpp:169 engines/neverhood/menumodule.cpp:886
+#: engines/sci/engine/kfile.cpp:857 engines/toltecs/menu.cpp:256
msgid "Restore game:"
msgstr "Jokoa kargatu:"
#: engines/agi/saveload.cpp:816 engines/drascula/saveload.cpp:349
-#: engines/neverhood/menumodule.cpp:886 engines/sci/engine/kfile.cpp:857
-#: engines/toltecs/menu.cpp:256
+#: engines/dreamweb/saveload.cpp:169 engines/neverhood/menumodule.cpp:886
+#: engines/sci/engine/kfile.cpp:857 engines/toltecs/menu.cpp:256
msgid "Restore"
msgstr "Kargatu"
@@ -2148,6 +2156,15 @@ msgstr ""
msgid "Cutscene file '%s' not found!"
msgstr "'%s' bideo fitxategia ez da aurkitu!"
+#: engines/cge/detection.cpp:105 engines/cge2/detection.cpp:81
+#, fuzzy
+msgid "Color Blind Mode"
+msgstr "Klikatzeko modua"
+
+#: engines/cge/detection.cpp:106 engines/cge2/detection.cpp:82
+msgid "Enable Color Blind Mode by default"
+msgstr ""
+
#: engines/drascula/saveload.cpp:47
#, fuzzy
msgid ""
@@ -2177,11 +2194,12 @@ msgid "Display graphics using the game's bright palette"
msgstr ""
#: engines/gob/inter_playtoons.cpp:256 engines/gob/inter_v2.cpp:1470
-#: engines/tinsel/saveload.cpp:532
+#: engines/gob/inter_geisha.cpp:232 engines/tinsel/saveload.cpp:532
msgid "Failed to load game state from file."
msgstr "Ezin izan da fitxategitik jokoa kargatu."
-#: engines/gob/inter_v2.cpp:1540 engines/tinsel/saveload.cpp:545
+#: engines/gob/inter_v2.cpp:1540 engines/gob/inter_geisha.cpp:263
+#: engines/tinsel/saveload.cpp:545
msgid "Failed to save game state to file."
msgstr "Ezin izan da jokoa fitxategira gorde."
@@ -2202,6 +2220,14 @@ msgstr ""
msgid "Failed to save game"
msgstr "Ezin izan da jokoa gorde"
+#: engines/hopkins/detection.cpp:76 engines/hopkins/detection.cpp:86
+msgid "Gore Mode"
+msgstr ""
+
+#: engines/hopkins/detection.cpp:77 engines/hopkins/detection.cpp:87
+msgid "Enable Gore Mode when available"
+msgstr ""
+
#. I18N: Studio audience adds an applause and cheering sounds whenever
#. Malcolm makes a joke.
#: engines/kyra/detection.cpp:62
@@ -2325,6 +2351,35 @@ msgstr ""
"General MIDIkoetara egokitzen saiatuko gara,\n"
"baina posible da pista batzuk egoki ez entzutea."
+#: engines/kyra/saveload_eob.cpp:557
+#, c-format
+msgid ""
+"The following original save game file has been found in your game path:\n"
+"\n"
+"%s %s\n"
+"\n"
+"Do you wish to use this save game file with ScummVM?\n"
+"\n"
+msgstr ""
+
+#: engines/kyra/saveload_eob.cpp:590
+#, c-format
+msgid ""
+"A save game file was found in the specified slot %d. Overwrite?\n"
+"\n"
+msgstr ""
+
+#: engines/kyra/saveload_eob.cpp:623
+#, c-format
+msgid ""
+"%d original save game files have been successfully imported into\n"
+"ScummVM. If you want to manually import original save game files later you "
+"will\n"
+"need to open the ScummVM debug console and use the command "
+"'import_savefile'.\n"
+"\n"
+msgstr ""
+
#. I18N: Option for fast scene switching
#: engines/mohawk/dialogs.cpp:92 engines/mohawk/dialogs.cpp:167
msgid "~Z~ip Mode Activated"
@@ -2454,6 +2509,14 @@ msgstr ""
msgid "Display/Hide Pause Menu"
msgstr ""
+#: engines/queen/detection.cpp:56
+msgid "Alternative intro"
+msgstr ""
+
+#: engines/queen/detection.cpp:57
+msgid "Use an alternative game intro (CD version only)"
+msgstr ""
+
#: engines/sci/detection.cpp:374
msgid "EGA undithering"
msgstr "EGA lausotzea"
@@ -3153,6 +3216,18 @@ msgstr ""
"baimentzen oraindik. Jolasteko , joan 'Jokoa gehitu' hasierako menura eta "
"aukeratu 'Maniac' direktorioa Tentacle-ren joko-direktorioaren barruan."
+#: engines/scumm/players/player_v3m.cpp:129
+msgid ""
+"Could not find the 'Loom' Macintosh executable to read the\n"
+"instruments from. Music will be disabled."
+msgstr ""
+
+#: engines/scumm/players/player_v5m.cpp:107
+msgid ""
+"Could not find the 'Monkey Island' Macintosh executable to read the\n"
+"instruments from. Music will be disabled."
+msgstr ""
+
#: engines/sky/compact.cpp:130
msgid ""
"Unable to find \"sky.cpt\" file!\n"
@@ -3264,6 +3339,14 @@ msgid ""
"executable. Please decompress it"
msgstr ""
+#: engines/wintermute/detection.cpp:58
+msgid "Show FPS-counter"
+msgstr ""
+
+#: engines/wintermute/detection.cpp:59
+msgid "Show the current number of frames per second in the upper left corner"
+msgstr ""
+
#, fuzzy
#~ msgid "MPEG-2 cutscenes found but ScummVM has been built without MPEG-2"
#~ msgstr ""
diff --git a/po/fi_FI.po b/po/fi_FI.po
index 4a34148f39..1958be3139 100644
--- a/po/fi_FI.po
+++ b/po/fi_FI.po
@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: ScummVM 1.6.0git\n"
"Report-Msgid-Bugs-To: scummvm-devel@lists.sf.net\n"
-"POT-Creation-Date: 2014-09-03 07:39+0200\n"
+"POT-Creation-Date: 2014-10-04 00:58+0100\n"
"PO-Revision-Date: 2012-12-01 19:37+0200\n"
"Last-Translator: Toni Saarela <saarela@gmail.com>\n"
"Language-Team: Finnish\n"
@@ -109,12 +109,14 @@ msgstr "Nфppфinkartta"
#: engines/agos/animation.cpp:558 engines/drascula/saveload.cpp:49
#: engines/groovie/script.cpp:399 engines/parallaction/saveload.cpp:274
#: engines/scumm/dialogs.cpp:193 engines/scumm/scumm.cpp:1825
-#: engines/sky/compact.cpp:131 engines/sky/compact.cpp:141
-#: engines/sword1/animation.cpp:524 engines/sword1/animation.cpp:545
-#: engines/sword1/animation.cpp:561 engines/sword1/animation.cpp:569
-#: engines/sword1/control.cpp:865 engines/sword1/logic.cpp:1633
-#: engines/sword2/animation.cpp:425 engines/sword2/animation.cpp:445
-#: engines/sword2/animation.cpp:461 engines/sword2/animation.cpp:471
+#: engines/scumm/players/player_v3m.cpp:130
+#: engines/scumm/players/player_v5m.cpp:108 engines/sky/compact.cpp:131
+#: engines/sky/compact.cpp:141 engines/sword1/animation.cpp:524
+#: engines/sword1/animation.cpp:545 engines/sword1/animation.cpp:561
+#: engines/sword1/animation.cpp:569 engines/sword1/control.cpp:865
+#: engines/sword1/logic.cpp:1633 engines/sword2/animation.cpp:425
+#: engines/sword2/animation.cpp:445 engines/sword2/animation.cpp:461
+#: engines/sword2/animation.cpp:471
msgid "OK"
msgstr "Tallenna"
@@ -453,7 +455,7 @@ msgstr "Etsi:"
#: gui/launcher.cpp:685 engines/dialogs.cpp:115 engines/cruise/menu.cpp:214
#: engines/mohawk/myst.cpp:245 engines/mohawk/riven.cpp:718
-#: engines/pegasus/pegasus.cpp:353
+#: engines/pegasus/pegasus.cpp:353 engines/tsage/scenes.cpp:600
msgid "Load game:"
msgstr "Lataa peli:"
@@ -462,7 +464,7 @@ msgstr "Lataa peli:"
#: backends/platform/wince/CEActionsSmartphone.cpp:231
#: engines/cruise/menu.cpp:214 engines/mohawk/myst.cpp:245
#: engines/mohawk/riven.cpp:718 engines/pegasus/pegasus.cpp:353
-#: engines/scumm/dialogs.cpp:189
+#: engines/scumm/dialogs.cpp:189 engines/tsage/scenes.cpp:600
msgid "Load"
msgstr "Lataa"
@@ -480,6 +482,7 @@ msgstr ""
#: backends/platform/wince/CEActionsPocket.cpp:326
#: backends/platform/wince/CEActionsSmartphone.cpp:287
#: backends/platform/wince/CELauncherDialog.cpp:83
+#: engines/kyra/saveload_eob.cpp:557 engines/kyra/saveload_eob.cpp:590
msgid "Yes"
msgstr "Kyllф"
@@ -489,6 +492,7 @@ msgstr "Kyllф"
#: backends/platform/wince/CEActionsPocket.cpp:326
#: backends/platform/wince/CEActionsSmartphone.cpp:287
#: backends/platform/wince/CELauncherDialog.cpp:83
+#: engines/kyra/saveload_eob.cpp:557 engines/kyra/saveload_eob.cpp:590
msgid "No"
msgstr "Ei"
@@ -1281,8 +1285,9 @@ msgstr "Palaa p~e~livalitsimeen"
#: engines/dialogs.cpp:116 engines/agi/saveload.cpp:803
#: engines/cruise/menu.cpp:212 engines/drascula/saveload.cpp:336
-#: engines/neverhood/menumodule.cpp:873 engines/pegasus/pegasus.cpp:377
-#: engines/sci/engine/kfile.cpp:758 engines/toltecs/menu.cpp:281
+#: engines/dreamweb/saveload.cpp:261 engines/neverhood/menumodule.cpp:873
+#: engines/pegasus/pegasus.cpp:377 engines/sci/engine/kfile.cpp:758
+#: engines/toltecs/menu.cpp:281 engines/tsage/scenes.cpp:598
msgid "Save game:"
msgstr "Tallenna peli:"
@@ -1292,9 +1297,10 @@ msgstr "Tallenna peli:"
#: backends/platform/wince/CEActionsSmartphone.cpp:45
#: backends/platform/wince/CEActionsSmartphone.cpp:231
#: engines/agi/saveload.cpp:803 engines/cruise/menu.cpp:212
-#: engines/drascula/saveload.cpp:336 engines/neverhood/menumodule.cpp:873
-#: engines/pegasus/pegasus.cpp:377 engines/sci/engine/kfile.cpp:758
-#: engines/scumm/dialogs.cpp:188 engines/toltecs/menu.cpp:281
+#: engines/drascula/saveload.cpp:336 engines/dreamweb/saveload.cpp:261
+#: engines/neverhood/menumodule.cpp:873 engines/pegasus/pegasus.cpp:377
+#: engines/sci/engine/kfile.cpp:758 engines/scumm/dialogs.cpp:188
+#: engines/toltecs/menu.cpp:281 engines/tsage/scenes.cpp:598
msgid "Save"
msgstr "Tallenna"
@@ -1317,12 +1323,12 @@ msgstr ""
"lisфtietoa."
#: engines/dialogs.cpp:307 engines/mohawk/dialogs.cpp:109
-#: engines/mohawk/dialogs.cpp:170
+#: engines/mohawk/dialogs.cpp:170 engines/tsage/dialogs.cpp:106
msgid "~O~K"
msgstr "~H~yvфksy"
#: engines/dialogs.cpp:308 engines/mohawk/dialogs.cpp:110
-#: engines/mohawk/dialogs.cpp:171
+#: engines/mohawk/dialogs.cpp:171 engines/tsage/dialogs.cpp:107
msgid "~C~ancel"
msgstr "~P~eruuta"
@@ -2090,24 +2096,26 @@ msgstr "Klikkaus pois pффltф"
#: engines/agi/detection.cpp:142 engines/drascula/detection.cpp:302
#: engines/dreamweb/detection.cpp:47 engines/neverhood/detection.cpp:160
#: engines/sci/detection.cpp:394 engines/toltecs/detection.cpp:200
+#: engines/zvision/detection.cpp:103
msgid "Use original save/load screens"
msgstr "Kфytф alkuperфisiф tallenna/lataa valikkoja"
#: engines/agi/detection.cpp:143 engines/drascula/detection.cpp:303
#: engines/dreamweb/detection.cpp:48 engines/neverhood/detection.cpp:161
#: engines/sci/detection.cpp:395 engines/toltecs/detection.cpp:201
+#: engines/zvision/detection.cpp:104
msgid "Use the original save/load screens, instead of the ScummVM ones"
msgstr "Kфytф alkuperфisiф tallenna/lataa valikkoja, ScummVM valikoiden sijaan"
#: engines/agi/saveload.cpp:816 engines/drascula/saveload.cpp:349
-#: engines/neverhood/menumodule.cpp:886 engines/sci/engine/kfile.cpp:857
-#: engines/toltecs/menu.cpp:256
+#: engines/dreamweb/saveload.cpp:169 engines/neverhood/menumodule.cpp:886
+#: engines/sci/engine/kfile.cpp:857 engines/toltecs/menu.cpp:256
msgid "Restore game:"
msgstr "Lataa pelitallenne:"
#: engines/agi/saveload.cpp:816 engines/drascula/saveload.cpp:349
-#: engines/neverhood/menumodule.cpp:886 engines/sci/engine/kfile.cpp:857
-#: engines/toltecs/menu.cpp:256
+#: engines/dreamweb/saveload.cpp:169 engines/neverhood/menumodule.cpp:886
+#: engines/sci/engine/kfile.cpp:857 engines/toltecs/menu.cpp:256
msgid "Restore"
msgstr "Lataa tallenne"
@@ -2149,6 +2157,15 @@ msgstr ""
msgid "Cutscene file '%s' not found!"
msgstr "Videotiedostoa '%s' ei lіytynyt!"
+#: engines/cge/detection.cpp:105 engines/cge2/detection.cpp:81
+#, fuzzy
+msgid "Color Blind Mode"
+msgstr "Klikkaus moodi"
+
+#: engines/cge/detection.cpp:106 engines/cge2/detection.cpp:82
+msgid "Enable Color Blind Mode by default"
+msgstr ""
+
#: engines/drascula/saveload.cpp:47
#, fuzzy
msgid ""
@@ -2175,11 +2192,12 @@ msgid "Display graphics using the game's bright palette"
msgstr "Nфytф grafiikat kфyttфen pelin kirkasta palettia"
#: engines/gob/inter_playtoons.cpp:256 engines/gob/inter_v2.cpp:1470
-#: engines/tinsel/saveload.cpp:532
+#: engines/gob/inter_geisha.cpp:232 engines/tinsel/saveload.cpp:532
msgid "Failed to load game state from file."
msgstr "Pelitallenteen lataaminen tiedostosta epфonnistui."
-#: engines/gob/inter_v2.cpp:1540 engines/tinsel/saveload.cpp:545
+#: engines/gob/inter_v2.cpp:1540 engines/gob/inter_geisha.cpp:263
+#: engines/tinsel/saveload.cpp:545
msgid "Failed to save game state to file."
msgstr "Pelin tallentaminen tiedostoon epфonnistui."
@@ -2200,6 +2218,14 @@ msgstr ""
msgid "Failed to save game"
msgstr "Pelin tallentaminen epфonnistui."
+#: engines/hopkins/detection.cpp:76 engines/hopkins/detection.cpp:86
+msgid "Gore Mode"
+msgstr ""
+
+#: engines/hopkins/detection.cpp:77 engines/hopkins/detection.cpp:87
+msgid "Enable Gore Mode when available"
+msgstr ""
+
#. I18N: Studio audience adds an applause and cheering sounds whenever
#. Malcolm makes a joke.
#: engines/kyra/detection.cpp:62
@@ -2318,6 +2344,35 @@ msgstr ""
"tukee vain Roland MT-32:sta. Jotkut ффniraidat\n"
"eivфt ehkф kuulosta siltф miltф niiden pitфisi."
+#: engines/kyra/saveload_eob.cpp:557
+#, c-format
+msgid ""
+"The following original save game file has been found in your game path:\n"
+"\n"
+"%s %s\n"
+"\n"
+"Do you wish to use this save game file with ScummVM?\n"
+"\n"
+msgstr ""
+
+#: engines/kyra/saveload_eob.cpp:590
+#, c-format
+msgid ""
+"A save game file was found in the specified slot %d. Overwrite?\n"
+"\n"
+msgstr ""
+
+#: engines/kyra/saveload_eob.cpp:623
+#, c-format
+msgid ""
+"%d original save game files have been successfully imported into\n"
+"ScummVM. If you want to manually import original save game files later you "
+"will\n"
+"need to open the ScummVM debug console and use the command "
+"'import_savefile'.\n"
+"\n"
+msgstr ""
+
#. I18N: Option for fast scene switching
#: engines/mohawk/dialogs.cpp:92 engines/mohawk/dialogs.cpp:167
msgid "~Z~ip Mode Activated"
@@ -2445,6 +2500,14 @@ msgstr ""
msgid "Display/Hide Pause Menu"
msgstr ""
+#: engines/queen/detection.cpp:56
+msgid "Alternative intro"
+msgstr "Vaihtoehtoinen intro"
+
+#: engines/queen/detection.cpp:57
+msgid "Use an alternative game intro (CD version only)"
+msgstr "Kфytф vaihtoehtoista pelin introa (vain CD versiossa)"
+
#: engines/sci/detection.cpp:374
msgid "EGA undithering"
msgstr "EGA unditterіinti"
@@ -3144,6 +3207,18 @@ msgstr ""
"Pelataksesi Maniac Mansionia, mene ScummVM:n pффvalikkoon ja paina 'Lisфф "
"peli'. Valitse 'Maniac' hakemisto Tentacle hakemiston sisфltф."
+#: engines/scumm/players/player_v3m.cpp:129
+msgid ""
+"Could not find the 'Loom' Macintosh executable to read the\n"
+"instruments from. Music will be disabled."
+msgstr ""
+
+#: engines/scumm/players/player_v5m.cpp:107
+msgid ""
+"Could not find the 'Monkey Island' Macintosh executable to read the\n"
+"instruments from. Music will be disabled."
+msgstr ""
+
#: engines/sky/compact.cpp:130
msgid ""
"Unable to find \"sky.cpt\" file!\n"
@@ -3255,6 +3330,14 @@ msgstr ""
"Tiedosto teenagent.dat on pakattu, mutta zlib-kirjastoa ei ole kффnnetty "
"ScummVM:ффn. Pura teenagent.dat."
+#: engines/wintermute/detection.cpp:58
+msgid "Show FPS-counter"
+msgstr ""
+
+#: engines/wintermute/detection.cpp:59
+msgid "Show the current number of frames per second in the upper left corner"
+msgstr ""
+
#, fuzzy
#~ msgid "MPEG-2 cutscenes found but ScummVM has been built without MPEG-2"
#~ msgstr "PSX videoita lіydetty, mutta ScummVM on kффnnetty ilman RGB tukea"
@@ -3273,12 +3356,6 @@ msgstr ""
#~ msgid "Standard (16bpp)"
#~ msgstr "Standardi (16 bpp)"
-#~ msgid "Alternative intro"
-#~ msgstr "Vaihtoehtoinen intro"
-
-#~ msgid "Use an alternative game intro (CD version only)"
-#~ msgstr "Kфytф vaihtoehtoista pelin introa (vain CD versiossa)"
-
#~ msgid "MPEG2 cutscenes are no longer supported"
#~ msgstr "MPEG2 videotiedostoja ei enфф tueta"
diff --git a/po/fr_FR.po b/po/fr_FR.po
index 300882ff94..6e47183fe3 100644
--- a/po/fr_FR.po
+++ b/po/fr_FR.po
@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: ScummVM 1.3.0svn\n"
"Report-Msgid-Bugs-To: scummvm-devel@lists.sf.net\n"
-"POT-Creation-Date: 2014-09-03 07:39+0200\n"
+"POT-Creation-Date: 2014-10-04 00:58+0100\n"
"PO-Revision-Date: 2014-07-05 13:49-0000\n"
"Last-Translator: Thierry Crozat <criezy@scummvm.org>\n"
"Language-Team: French <scummvm-devel@lists.sf.net>\n"
@@ -109,12 +109,14 @@ msgstr "Affecter"
#: engines/agos/animation.cpp:558 engines/drascula/saveload.cpp:49
#: engines/groovie/script.cpp:399 engines/parallaction/saveload.cpp:274
#: engines/scumm/dialogs.cpp:193 engines/scumm/scumm.cpp:1825
-#: engines/sky/compact.cpp:131 engines/sky/compact.cpp:141
-#: engines/sword1/animation.cpp:524 engines/sword1/animation.cpp:545
-#: engines/sword1/animation.cpp:561 engines/sword1/animation.cpp:569
-#: engines/sword1/control.cpp:865 engines/sword1/logic.cpp:1633
-#: engines/sword2/animation.cpp:425 engines/sword2/animation.cpp:445
-#: engines/sword2/animation.cpp:461 engines/sword2/animation.cpp:471
+#: engines/scumm/players/player_v3m.cpp:130
+#: engines/scumm/players/player_v5m.cpp:108 engines/sky/compact.cpp:131
+#: engines/sky/compact.cpp:141 engines/sword1/animation.cpp:524
+#: engines/sword1/animation.cpp:545 engines/sword1/animation.cpp:561
+#: engines/sword1/animation.cpp:569 engines/sword1/control.cpp:865
+#: engines/sword1/logic.cpp:1633 engines/sword2/animation.cpp:425
+#: engines/sword2/animation.cpp:445 engines/sword2/animation.cpp:461
+#: engines/sword2/animation.cpp:471
msgid "OK"
msgstr "OK"
@@ -454,7 +456,7 @@ msgstr "Filtre:"
#: gui/launcher.cpp:685 engines/dialogs.cpp:115 engines/cruise/menu.cpp:214
#: engines/mohawk/myst.cpp:245 engines/mohawk/riven.cpp:718
-#: engines/pegasus/pegasus.cpp:353
+#: engines/pegasus/pegasus.cpp:353 engines/tsage/scenes.cpp:600
msgid "Load game:"
msgstr "Charger le jeu:"
@@ -463,7 +465,7 @@ msgstr "Charger le jeu:"
#: backends/platform/wince/CEActionsSmartphone.cpp:231
#: engines/cruise/menu.cpp:214 engines/mohawk/myst.cpp:245
#: engines/mohawk/riven.cpp:718 engines/pegasus/pegasus.cpp:353
-#: engines/scumm/dialogs.cpp:189
+#: engines/scumm/dialogs.cpp:189 engines/tsage/scenes.cpp:600
msgid "Load"
msgstr "Charger"
@@ -481,6 +483,7 @@ msgstr ""
#: backends/platform/wince/CEActionsPocket.cpp:326
#: backends/platform/wince/CEActionsSmartphone.cpp:287
#: backends/platform/wince/CELauncherDialog.cpp:83
+#: engines/kyra/saveload_eob.cpp:557 engines/kyra/saveload_eob.cpp:590
msgid "Yes"
msgstr "Oui"
@@ -490,6 +493,7 @@ msgstr "Oui"
#: backends/platform/wince/CEActionsPocket.cpp:326
#: backends/platform/wince/CEActionsSmartphone.cpp:287
#: backends/platform/wince/CELauncherDialog.cpp:83
+#: engines/kyra/saveload_eob.cpp:557 engines/kyra/saveload_eob.cpp:590
msgid "No"
msgstr "Non"
@@ -1280,8 +1284,9 @@ msgstr "Retour au ~L~anceur"
#: engines/dialogs.cpp:116 engines/agi/saveload.cpp:803
#: engines/cruise/menu.cpp:212 engines/drascula/saveload.cpp:336
-#: engines/neverhood/menumodule.cpp:873 engines/pegasus/pegasus.cpp:377
-#: engines/sci/engine/kfile.cpp:758 engines/toltecs/menu.cpp:281
+#: engines/dreamweb/saveload.cpp:261 engines/neverhood/menumodule.cpp:873
+#: engines/pegasus/pegasus.cpp:377 engines/sci/engine/kfile.cpp:758
+#: engines/toltecs/menu.cpp:281 engines/tsage/scenes.cpp:598
msgid "Save game:"
msgstr "Sauvegarde:"
@@ -1291,9 +1296,10 @@ msgstr "Sauvegarde:"
#: backends/platform/wince/CEActionsSmartphone.cpp:45
#: backends/platform/wince/CEActionsSmartphone.cpp:231
#: engines/agi/saveload.cpp:803 engines/cruise/menu.cpp:212
-#: engines/drascula/saveload.cpp:336 engines/neverhood/menumodule.cpp:873
-#: engines/pegasus/pegasus.cpp:377 engines/sci/engine/kfile.cpp:758
-#: engines/scumm/dialogs.cpp:188 engines/toltecs/menu.cpp:281
+#: engines/drascula/saveload.cpp:336 engines/dreamweb/saveload.cpp:261
+#: engines/neverhood/menumodule.cpp:873 engines/pegasus/pegasus.cpp:377
+#: engines/sci/engine/kfile.cpp:758 engines/scumm/dialogs.cpp:188
+#: engines/toltecs/menu.cpp:281 engines/tsage/scenes.cpp:598
msgid "Save"
msgstr "Sauver"
@@ -1317,12 +1323,12 @@ msgstr ""
"de base et les instructions pour obtenir de l'aide supplщmentaire."
#: engines/dialogs.cpp:307 engines/mohawk/dialogs.cpp:109
-#: engines/mohawk/dialogs.cpp:170
+#: engines/mohawk/dialogs.cpp:170 engines/tsage/dialogs.cpp:106
msgid "~O~K"
msgstr "~O~K"
#: engines/dialogs.cpp:308 engines/mohawk/dialogs.cpp:110
-#: engines/mohawk/dialogs.cpp:171
+#: engines/mohawk/dialogs.cpp:171 engines/tsage/dialogs.cpp:107
msgid "~C~ancel"
msgstr "~A~nnuler"
@@ -2088,26 +2094,28 @@ msgstr "Clic Dщsactivщ"
#: engines/agi/detection.cpp:142 engines/drascula/detection.cpp:302
#: engines/dreamweb/detection.cpp:47 engines/neverhood/detection.cpp:160
#: engines/sci/detection.cpp:394 engines/toltecs/detection.cpp:200
+#: engines/zvision/detection.cpp:103
msgid "Use original save/load screens"
msgstr "Dialogues sauvegarde/chargement d'origine"
#: engines/agi/detection.cpp:143 engines/drascula/detection.cpp:303
#: engines/dreamweb/detection.cpp:48 engines/neverhood/detection.cpp:161
#: engines/sci/detection.cpp:395 engines/toltecs/detection.cpp:201
+#: engines/zvision/detection.cpp:104
msgid "Use the original save/load screens, instead of the ScummVM ones"
msgstr ""
"Utiliser les dialogues sauvegarde/chargement d'origine plutєt que ceux de "
"ScummVM"
#: engines/agi/saveload.cpp:816 engines/drascula/saveload.cpp:349
-#: engines/neverhood/menumodule.cpp:886 engines/sci/engine/kfile.cpp:857
-#: engines/toltecs/menu.cpp:256
+#: engines/dreamweb/saveload.cpp:169 engines/neverhood/menumodule.cpp:886
+#: engines/sci/engine/kfile.cpp:857 engines/toltecs/menu.cpp:256
msgid "Restore game:"
msgstr "Charger le jeu:"
#: engines/agi/saveload.cpp:816 engines/drascula/saveload.cpp:349
-#: engines/neverhood/menumodule.cpp:886 engines/sci/engine/kfile.cpp:857
-#: engines/toltecs/menu.cpp:256
+#: engines/dreamweb/saveload.cpp:169 engines/neverhood/menumodule.cpp:886
+#: engines/sci/engine/kfile.cpp:857 engines/toltecs/menu.cpp:256
msgid "Restore"
msgstr "Charger"
@@ -2149,6 +2157,15 @@ msgstr ""
msgid "Cutscene file '%s' not found!"
msgstr "Fichier de sщquence '%s' non trouvщ!"
+#: engines/cge/detection.cpp:105 engines/cge2/detection.cpp:81
+#, fuzzy
+msgid "Color Blind Mode"
+msgstr "Mode Clic"
+
+#: engines/cge/detection.cpp:106 engines/cge2/detection.cpp:82
+msgid "Enable Color Blind Mode by default"
+msgstr ""
+
#: engines/drascula/saveload.cpp:47
msgid ""
"ScummVM found that you have old savefiles for Drascula that should be "
@@ -2176,11 +2193,12 @@ msgid "Display graphics using the game's bright palette"
msgstr "Utiliser la palette lumineuse du jeu pour l'affichage"
#: engines/gob/inter_playtoons.cpp:256 engines/gob/inter_v2.cpp:1470
-#: engines/tinsel/saveload.cpp:532
+#: engines/gob/inter_geisha.cpp:232 engines/tinsel/saveload.cpp:532
msgid "Failed to load game state from file."
msgstr "Щchec du chargement de l'щtat du jeu depuis le disque."
-#: engines/gob/inter_v2.cpp:1540 engines/tinsel/saveload.cpp:545
+#: engines/gob/inter_v2.cpp:1540 engines/gob/inter_geisha.cpp:263
+#: engines/tinsel/saveload.cpp:545
msgid "Failed to save game state to file."
msgstr "Щchec de l'enregistrement de l'щtat du jeu sur le disque."
@@ -2200,6 +2218,14 @@ msgstr "Joue les vidщos plus rapidement"
msgid "Failed to save game"
msgstr "Щchec de la sauvegarde."
+#: engines/hopkins/detection.cpp:76 engines/hopkins/detection.cpp:86
+msgid "Gore Mode"
+msgstr ""
+
+#: engines/hopkins/detection.cpp:77 engines/hopkins/detection.cpp:87
+msgid "Enable Gore Mode when available"
+msgstr ""
+
#. I18N: Studio audience adds an applause and cheering sounds whenever
#. Malcolm makes a joke.
#: engines/kyra/detection.cpp:62
@@ -2320,6 +2346,35 @@ msgstr ""
"MIDI. Cependant il est possible que quelques pistes ne soient\n"
" pas jouщes correctement."
+#: engines/kyra/saveload_eob.cpp:557
+#, c-format
+msgid ""
+"The following original save game file has been found in your game path:\n"
+"\n"
+"%s %s\n"
+"\n"
+"Do you wish to use this save game file with ScummVM?\n"
+"\n"
+msgstr ""
+
+#: engines/kyra/saveload_eob.cpp:590
+#, c-format
+msgid ""
+"A save game file was found in the specified slot %d. Overwrite?\n"
+"\n"
+msgstr ""
+
+#: engines/kyra/saveload_eob.cpp:623
+#, c-format
+msgid ""
+"%d original save game files have been successfully imported into\n"
+"ScummVM. If you want to manually import original save game files later you "
+"will\n"
+"need to open the ScummVM debug console and use the command "
+"'import_savefile'.\n"
+"\n"
+msgstr ""
+
#. I18N: Option for fast scene switching
#: engines/mohawk/dialogs.cpp:92 engines/mohawk/dialogs.cpp:167
msgid "~Z~ip Mode Activated"
@@ -2449,6 +2504,14 @@ msgstr "Montrer/Cacher l'Щcran d'Info"
msgid "Display/Hide Pause Menu"
msgstr "Montrer/Cacher le Menu de Pause"
+#: engines/queen/detection.cpp:56
+msgid "Alternative intro"
+msgstr "Intro alternative"
+
+#: engines/queen/detection.cpp:57
+msgid "Use an alternative game intro (CD version only)"
+msgstr "Utiliser une intro alternative (version CD uniquement)"
+
#: engines/sci/detection.cpp:374
msgid "EGA undithering"
msgstr "Dщtramage EGA"
@@ -3152,6 +3215,18 @@ msgstr ""
"choisissez 'Ajouter...' dans le Lanceur de ScummVM et sщlectionnez le "
"rщpertoire 'Maniac Mansion' dans le rщpertoire du jeu Day Of The Tentacle."
+#: engines/scumm/players/player_v3m.cpp:129
+msgid ""
+"Could not find the 'Loom' Macintosh executable to read the\n"
+"instruments from. Music will be disabled."
+msgstr ""
+
+#: engines/scumm/players/player_v5m.cpp:107
+msgid ""
+"Could not find the 'Monkey Island' Macintosh executable to read the\n"
+"instruments from. Music will be disabled."
+msgstr ""
+
#: engines/sky/compact.cpp:130
msgid ""
"Unable to find \"sky.cpt\" file!\n"
@@ -3269,6 +3344,14 @@ msgstr ""
"Le fichier teenagent.dat est compressщ et cet exщcutable n'inclus pas zlib. "
"Veuillez le dщcompresser."
+#: engines/wintermute/detection.cpp:58
+msgid "Show FPS-counter"
+msgstr ""
+
+#: engines/wintermute/detection.cpp:59
+msgid "Show the current number of frames per second in the upper left corner"
+msgstr ""
+
#~ msgid "MPEG-2 cutscenes found but ScummVM has been built without MPEG-2"
#~ msgstr ""
#~ "Scшnes cinщmatiques MPEG-2 dщtectщes mais ScummVM a щtщ compilщ sans le "
@@ -3288,12 +3371,6 @@ msgstr ""
#~ msgid "Standard (16bpp)"
#~ msgstr "Standard (16bpp)"
-#~ msgid "Alternative intro"
-#~ msgstr "Intro alternative"
-
-#~ msgid "Use an alternative game intro (CD version only)"
-#~ msgstr "Utiliser une intro alternative (version CD uniquement)"
-
#~ msgid "MPEG2 cutscenes are no longer supported"
#~ msgstr "Les sщquences MPEG2 ne sont plus supportщes"
diff --git a/po/gl_ES.po b/po/gl_ES.po
index cb2b7b31c9..cc8569d2f1 100644
--- a/po/gl_ES.po
+++ b/po/gl_ES.po
@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: ScummVM 1.6.0git\n"
"Report-Msgid-Bugs-To: scummvm-devel@lists.sf.net\n"
-"POT-Creation-Date: 2014-09-03 07:39+0200\n"
+"POT-Creation-Date: 2014-10-04 00:58+0100\n"
"PO-Revision-Date: 2014-07-02 09:51+0100\n"
"Last-Translator: Santiago G. Sanz <s.sanz@uvigo.es>\n"
"Language-Team: Santiago G. Sanz <s.sanz@uvigo.es>\n"
@@ -108,12 +108,14 @@ msgstr "Asignar"
#: engines/agos/animation.cpp:558 engines/drascula/saveload.cpp:49
#: engines/groovie/script.cpp:399 engines/parallaction/saveload.cpp:274
#: engines/scumm/dialogs.cpp:193 engines/scumm/scumm.cpp:1825
-#: engines/sky/compact.cpp:131 engines/sky/compact.cpp:141
-#: engines/sword1/animation.cpp:524 engines/sword1/animation.cpp:545
-#: engines/sword1/animation.cpp:561 engines/sword1/animation.cpp:569
-#: engines/sword1/control.cpp:865 engines/sword1/logic.cpp:1633
-#: engines/sword2/animation.cpp:425 engines/sword2/animation.cpp:445
-#: engines/sword2/animation.cpp:461 engines/sword2/animation.cpp:471
+#: engines/scumm/players/player_v3m.cpp:130
+#: engines/scumm/players/player_v5m.cpp:108 engines/sky/compact.cpp:131
+#: engines/sky/compact.cpp:141 engines/sword1/animation.cpp:524
+#: engines/sword1/animation.cpp:545 engines/sword1/animation.cpp:561
+#: engines/sword1/animation.cpp:569 engines/sword1/control.cpp:865
+#: engines/sword1/logic.cpp:1633 engines/sword2/animation.cpp:425
+#: engines/sword2/animation.cpp:445 engines/sword2/animation.cpp:461
+#: engines/sword2/animation.cpp:471
msgid "OK"
msgstr "Aceptar"
@@ -450,7 +452,7 @@ msgstr "Buscar:"
#: gui/launcher.cpp:685 engines/dialogs.cpp:115 engines/cruise/menu.cpp:214
#: engines/mohawk/myst.cpp:245 engines/mohawk/riven.cpp:718
-#: engines/pegasus/pegasus.cpp:353
+#: engines/pegasus/pegasus.cpp:353 engines/tsage/scenes.cpp:600
msgid "Load game:"
msgstr "Cargar partida:"
@@ -459,7 +461,7 @@ msgstr "Cargar partida:"
#: backends/platform/wince/CEActionsSmartphone.cpp:231
#: engines/cruise/menu.cpp:214 engines/mohawk/myst.cpp:245
#: engines/mohawk/riven.cpp:718 engines/pegasus/pegasus.cpp:353
-#: engines/scumm/dialogs.cpp:189
+#: engines/scumm/dialogs.cpp:189 engines/tsage/scenes.cpp:600
msgid "Load"
msgstr "Cargar"
@@ -477,6 +479,7 @@ msgstr ""
#: backends/platform/wince/CEActionsPocket.cpp:326
#: backends/platform/wince/CEActionsSmartphone.cpp:287
#: backends/platform/wince/CELauncherDialog.cpp:83
+#: engines/kyra/saveload_eob.cpp:557 engines/kyra/saveload_eob.cpp:590
msgid "Yes"
msgstr "Si"
@@ -486,6 +489,7 @@ msgstr "Si"
#: backends/platform/wince/CEActionsPocket.cpp:326
#: backends/platform/wince/CEActionsSmartphone.cpp:287
#: backends/platform/wince/CELauncherDialog.cpp:83
+#: engines/kyra/saveload_eob.cpp:557 engines/kyra/saveload_eob.cpp:590
msgid "No"
msgstr "Non"
@@ -1267,8 +1271,9 @@ msgstr "~V~olver ao Iniciador"
#: engines/dialogs.cpp:116 engines/agi/saveload.cpp:803
#: engines/cruise/menu.cpp:212 engines/drascula/saveload.cpp:336
-#: engines/neverhood/menumodule.cpp:873 engines/pegasus/pegasus.cpp:377
-#: engines/sci/engine/kfile.cpp:758 engines/toltecs/menu.cpp:281
+#: engines/dreamweb/saveload.cpp:261 engines/neverhood/menumodule.cpp:873
+#: engines/pegasus/pegasus.cpp:377 engines/sci/engine/kfile.cpp:758
+#: engines/toltecs/menu.cpp:281 engines/tsage/scenes.cpp:598
msgid "Save game:"
msgstr "Gardar partida:"
@@ -1278,9 +1283,10 @@ msgstr "Gardar partida:"
#: backends/platform/wince/CEActionsSmartphone.cpp:45
#: backends/platform/wince/CEActionsSmartphone.cpp:231
#: engines/agi/saveload.cpp:803 engines/cruise/menu.cpp:212
-#: engines/drascula/saveload.cpp:336 engines/neverhood/menumodule.cpp:873
-#: engines/pegasus/pegasus.cpp:377 engines/sci/engine/kfile.cpp:758
-#: engines/scumm/dialogs.cpp:188 engines/toltecs/menu.cpp:281
+#: engines/drascula/saveload.cpp:336 engines/dreamweb/saveload.cpp:261
+#: engines/neverhood/menumodule.cpp:873 engines/pegasus/pegasus.cpp:377
+#: engines/sci/engine/kfile.cpp:758 engines/scumm/dialogs.cpp:188
+#: engines/toltecs/menu.cpp:281 engines/tsage/scenes.cpp:598
msgid "Save"
msgstr "Gardar"
@@ -1304,12 +1310,12 @@ msgstr ""
"bсsica e mсis instruciѓns para acadar asistencia adicional."
#: engines/dialogs.cpp:307 engines/mohawk/dialogs.cpp:109
-#: engines/mohawk/dialogs.cpp:170
+#: engines/mohawk/dialogs.cpp:170 engines/tsage/dialogs.cpp:106
msgid "~O~K"
msgstr "~A~ceptar"
#: engines/dialogs.cpp:308 engines/mohawk/dialogs.cpp:110
-#: engines/mohawk/dialogs.cpp:171
+#: engines/mohawk/dialogs.cpp:171 engines/tsage/dialogs.cpp:107
msgid "~C~ancel"
msgstr "~C~ancelar"
@@ -2073,25 +2079,27 @@ msgstr "Premer desactivado"
#: engines/agi/detection.cpp:142 engines/drascula/detection.cpp:302
#: engines/dreamweb/detection.cpp:47 engines/neverhood/detection.cpp:160
#: engines/sci/detection.cpp:394 engines/toltecs/detection.cpp:200
+#: engines/zvision/detection.cpp:103
msgid "Use original save/load screens"
msgstr "Empregar pantallas orixinais de gardado e carga"
#: engines/agi/detection.cpp:143 engines/drascula/detection.cpp:303
#: engines/dreamweb/detection.cpp:48 engines/neverhood/detection.cpp:161
#: engines/sci/detection.cpp:395 engines/toltecs/detection.cpp:201
+#: engines/zvision/detection.cpp:104
msgid "Use the original save/load screens, instead of the ScummVM ones"
msgstr ""
"Empregar as pantallas orixinais de gardado e carga, no canto das de ScummVM"
#: engines/agi/saveload.cpp:816 engines/drascula/saveload.cpp:349
-#: engines/neverhood/menumodule.cpp:886 engines/sci/engine/kfile.cpp:857
-#: engines/toltecs/menu.cpp:256
+#: engines/dreamweb/saveload.cpp:169 engines/neverhood/menumodule.cpp:886
+#: engines/sci/engine/kfile.cpp:857 engines/toltecs/menu.cpp:256
msgid "Restore game:"
msgstr "Restaurar xogo:"
#: engines/agi/saveload.cpp:816 engines/drascula/saveload.cpp:349
-#: engines/neverhood/menumodule.cpp:886 engines/sci/engine/kfile.cpp:857
-#: engines/toltecs/menu.cpp:256
+#: engines/dreamweb/saveload.cpp:169 engines/neverhood/menumodule.cpp:886
+#: engines/sci/engine/kfile.cpp:857 engines/toltecs/menu.cpp:256
msgid "Restore"
msgstr "Restaurar"
@@ -2133,6 +2141,15 @@ msgstr ""
msgid "Cutscene file '%s' not found!"
msgstr "Non se atopou o ficheiro de secuencia %s!"
+#: engines/cge/detection.cpp:105 engines/cge2/detection.cpp:81
+#, fuzzy
+msgid "Color Blind Mode"
+msgstr "Modo rato"
+
+#: engines/cge/detection.cpp:106 engines/cge2/detection.cpp:82
+msgid "Enable Color Blind Mode by default"
+msgstr ""
+
#: engines/drascula/saveload.cpp:47
msgid ""
"ScummVM found that you have old savefiles for Drascula that should be "
@@ -2160,11 +2177,12 @@ msgid "Display graphics using the game's bright palette"
msgstr "Mostrar os grсficos coa paletta intensa do xogo"
#: engines/gob/inter_playtoons.cpp:256 engines/gob/inter_v2.cpp:1470
-#: engines/tinsel/saveload.cpp:532
+#: engines/gob/inter_geisha.cpp:232 engines/tinsel/saveload.cpp:532
msgid "Failed to load game state from file."
msgstr "Erro ao cargar a partida do ficheiro."
-#: engines/gob/inter_v2.cpp:1540 engines/tinsel/saveload.cpp:545
+#: engines/gob/inter_v2.cpp:1540 engines/gob/inter_geisha.cpp:263
+#: engines/tinsel/saveload.cpp:545
msgid "Failed to save game state to file."
msgstr "Erro ao gardar a partida no ficheiro."
@@ -2184,6 +2202,14 @@ msgstr "Reproducir vэdeos a mсis velocidade"
msgid "Failed to save game"
msgstr "Erro ao gardar a partida"
+#: engines/hopkins/detection.cpp:76 engines/hopkins/detection.cpp:86
+msgid "Gore Mode"
+msgstr ""
+
+#: engines/hopkins/detection.cpp:77 engines/hopkins/detection.cpp:87
+msgid "Enable Gore Mode when available"
+msgstr ""
+
#. I18N: Studio audience adds an applause and cheering sounds whenever
#. Malcolm makes a joke.
#: engines/kyra/detection.cpp:62
@@ -2304,6 +2330,35 @@ msgstr ""
"aos de General MIDI. No entanto, existe a posibilidade\n"
"de que algunhas pistas non soen correctamente."
+#: engines/kyra/saveload_eob.cpp:557
+#, c-format
+msgid ""
+"The following original save game file has been found in your game path:\n"
+"\n"
+"%s %s\n"
+"\n"
+"Do you wish to use this save game file with ScummVM?\n"
+"\n"
+msgstr ""
+
+#: engines/kyra/saveload_eob.cpp:590
+#, c-format
+msgid ""
+"A save game file was found in the specified slot %d. Overwrite?\n"
+"\n"
+msgstr ""
+
+#: engines/kyra/saveload_eob.cpp:623
+#, c-format
+msgid ""
+"%d original save game files have been successfully imported into\n"
+"ScummVM. If you want to manually import original save game files later you "
+"will\n"
+"need to open the ScummVM debug console and use the command "
+"'import_savefile'.\n"
+"\n"
+msgstr ""
+
#. I18N: Option for fast scene switching
#: engines/mohawk/dialogs.cpp:92 engines/mohawk/dialogs.cpp:167
msgid "~Z~ip Mode Activated"
@@ -2432,6 +2487,14 @@ msgstr "Mostrar/Ocultar pantalla de informaciѓn"
msgid "Display/Hide Pause Menu"
msgstr "Mostrar/Ocultar menњ de pausa"
+#: engines/queen/detection.cpp:56
+msgid "Alternative intro"
+msgstr "Intro alternativa"
+
+#: engines/queen/detection.cpp:57
+msgid "Use an alternative game intro (CD version only)"
+msgstr "Empregar unha introduciѓn alternativa para o xogo (sѓ versiѓn en CD)"
+
#: engines/sci/detection.cpp:374
msgid "EGA undithering"
msgstr "Non interpolaciѓn EGA"
@@ -3134,6 +3197,18 @@ msgstr ""
"facelo. Para xogar, vai a Engadir xogo no menњ de inicio de ScummVM e "
"selecciona o directorio Maniac que estс dentro do directorio Tentacle."
+#: engines/scumm/players/player_v3m.cpp:129
+msgid ""
+"Could not find the 'Loom' Macintosh executable to read the\n"
+"instruments from. Music will be disabled."
+msgstr ""
+
+#: engines/scumm/players/player_v5m.cpp:107
+msgid ""
+"Could not find the 'Monkey Island' Macintosh executable to read the\n"
+"instruments from. Music will be disabled."
+msgstr ""
+
#: engines/sky/compact.cpp:130
msgid ""
"Unable to find \"sky.cpt\" file!\n"
@@ -3249,6 +3324,14 @@ msgstr ""
"O ficheiro teenagent.dat estс comprimido e zlib non foi incluэdo neste "
"executable. Descomprime o ficheiro"
+#: engines/wintermute/detection.cpp:58
+msgid "Show FPS-counter"
+msgstr ""
+
+#: engines/wintermute/detection.cpp:59
+msgid "Show the current number of frames per second in the upper left corner"
+msgstr ""
+
#~ msgid "MPEG-2 cutscenes found but ScummVM has been built without MPEG-2"
#~ msgstr "Atopсronse secuencias MPEG-2, mais ScummVM foi compilado sen MPEG-2"
@@ -3266,13 +3349,6 @@ msgstr ""
#~ msgid "Standard (16bpp)"
#~ msgstr "Estсndar (16 bpp)"
-#~ msgid "Alternative intro"
-#~ msgstr "Intro alternativa"
-
-#~ msgid "Use an alternative game intro (CD version only)"
-#~ msgstr ""
-#~ "Empregar unha introduciѓn alternativa para o xogo (sѓ versiѓn en CD)"
-
#~ msgid "MPEG2 cutscenes are no longer supported"
#~ msgstr "Xa non hai compatibilidade coas secuencias en MPEG2"
diff --git a/po/hu_HU.po b/po/hu_HU.po
index c0648e4602..ef3507be98 100644
--- a/po/hu_HU.po
+++ b/po/hu_HU.po
@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: ScummVM 1.3.0svn\n"
"Report-Msgid-Bugs-To: scummvm-devel@lists.sf.net\n"
-"POT-Creation-Date: 2014-09-03 07:39+0200\n"
+"POT-Creation-Date: 2014-10-04 00:58+0100\n"
"PO-Revision-Date: 2014-02-18 06:30+0100\n"
"Last-Translator: George Kormendi <grubycza@hotmail.com>\n"
"Language-Team: Hungarian\n"
@@ -110,12 +110,14 @@ msgstr "Kiosztсs"
#: engines/agos/animation.cpp:558 engines/drascula/saveload.cpp:49
#: engines/groovie/script.cpp:399 engines/parallaction/saveload.cpp:274
#: engines/scumm/dialogs.cpp:193 engines/scumm/scumm.cpp:1825
-#: engines/sky/compact.cpp:131 engines/sky/compact.cpp:141
-#: engines/sword1/animation.cpp:524 engines/sword1/animation.cpp:545
-#: engines/sword1/animation.cpp:561 engines/sword1/animation.cpp:569
-#: engines/sword1/control.cpp:865 engines/sword1/logic.cpp:1633
-#: engines/sword2/animation.cpp:425 engines/sword2/animation.cpp:445
-#: engines/sword2/animation.cpp:461 engines/sword2/animation.cpp:471
+#: engines/scumm/players/player_v3m.cpp:130
+#: engines/scumm/players/player_v5m.cpp:108 engines/sky/compact.cpp:131
+#: engines/sky/compact.cpp:141 engines/sword1/animation.cpp:524
+#: engines/sword1/animation.cpp:545 engines/sword1/animation.cpp:561
+#: engines/sword1/animation.cpp:569 engines/sword1/control.cpp:865
+#: engines/sword1/logic.cpp:1633 engines/sword2/animation.cpp:425
+#: engines/sword2/animation.cpp:445 engines/sword2/animation.cpp:461
+#: engines/sword2/animation.cpp:471
msgid "OK"
msgstr "OK"
@@ -452,7 +454,7 @@ msgstr "Keresщs:"
#: gui/launcher.cpp:685 engines/dialogs.cpp:115 engines/cruise/menu.cpp:214
#: engines/mohawk/myst.cpp:245 engines/mohawk/riven.cpp:718
-#: engines/pegasus/pegasus.cpp:353
+#: engines/pegasus/pegasus.cpp:353 engines/tsage/scenes.cpp:600
msgid "Load game:"
msgstr "Jсtщk betіltщse:"
@@ -461,7 +463,7 @@ msgstr "Jсtщk betіltщse:"
#: backends/platform/wince/CEActionsSmartphone.cpp:231
#: engines/cruise/menu.cpp:214 engines/mohawk/myst.cpp:245
#: engines/mohawk/riven.cpp:718 engines/pegasus/pegasus.cpp:353
-#: engines/scumm/dialogs.cpp:189
+#: engines/scumm/dialogs.cpp:189 engines/tsage/scenes.cpp:600
msgid "Load"
msgstr "Betіltщs"
@@ -479,6 +481,7 @@ msgstr ""
#: backends/platform/wince/CEActionsPocket.cpp:326
#: backends/platform/wince/CEActionsSmartphone.cpp:287
#: backends/platform/wince/CELauncherDialog.cpp:83
+#: engines/kyra/saveload_eob.cpp:557 engines/kyra/saveload_eob.cpp:590
msgid "Yes"
msgstr "Igen"
@@ -488,6 +491,7 @@ msgstr "Igen"
#: backends/platform/wince/CEActionsPocket.cpp:326
#: backends/platform/wince/CEActionsSmartphone.cpp:287
#: backends/platform/wince/CELauncherDialog.cpp:83
+#: engines/kyra/saveload_eob.cpp:557 engines/kyra/saveload_eob.cpp:590
msgid "No"
msgstr "Nem"
@@ -1264,8 +1268,9 @@ msgstr "Visszatщrщs az indэtѓba"
#: engines/dialogs.cpp:116 engines/agi/saveload.cpp:803
#: engines/cruise/menu.cpp:212 engines/drascula/saveload.cpp:336
-#: engines/neverhood/menumodule.cpp:873 engines/pegasus/pegasus.cpp:377
-#: engines/sci/engine/kfile.cpp:758 engines/toltecs/menu.cpp:281
+#: engines/dreamweb/saveload.cpp:261 engines/neverhood/menumodule.cpp:873
+#: engines/pegasus/pegasus.cpp:377 engines/sci/engine/kfile.cpp:758
+#: engines/toltecs/menu.cpp:281 engines/tsage/scenes.cpp:598
msgid "Save game:"
msgstr "Jсtщk mentщse:"
@@ -1275,9 +1280,10 @@ msgstr "Jсtщk mentщse:"
#: backends/platform/wince/CEActionsSmartphone.cpp:45
#: backends/platform/wince/CEActionsSmartphone.cpp:231
#: engines/agi/saveload.cpp:803 engines/cruise/menu.cpp:212
-#: engines/drascula/saveload.cpp:336 engines/neverhood/menumodule.cpp:873
-#: engines/pegasus/pegasus.cpp:377 engines/sci/engine/kfile.cpp:758
-#: engines/scumm/dialogs.cpp:188 engines/toltecs/menu.cpp:281
+#: engines/drascula/saveload.cpp:336 engines/dreamweb/saveload.cpp:261
+#: engines/neverhood/menumodule.cpp:873 engines/pegasus/pegasus.cpp:377
+#: engines/sci/engine/kfile.cpp:758 engines/scumm/dialogs.cpp:188
+#: engines/toltecs/menu.cpp:281 engines/tsage/scenes.cpp:598
msgid "Save"
msgstr "Mentщs"
@@ -1300,12 +1306,12 @@ msgstr ""
"informсciѓkrѓl, щs hogy hogyan segэthetsz a kщsѕbbiekben."
#: engines/dialogs.cpp:307 engines/mohawk/dialogs.cpp:109
-#: engines/mohawk/dialogs.cpp:170
+#: engines/mohawk/dialogs.cpp:170 engines/tsage/dialogs.cpp:106
msgid "~O~K"
msgstr "~O~K"
#: engines/dialogs.cpp:308 engines/mohawk/dialogs.cpp:110
-#: engines/mohawk/dialogs.cpp:171
+#: engines/mohawk/dialogs.cpp:171 engines/tsage/dialogs.cpp:107
msgid "~C~ancel"
msgstr "Mщgse"
@@ -2065,24 +2071,26 @@ msgstr "Kattintсs tiltva"
#: engines/agi/detection.cpp:142 engines/drascula/detection.cpp:302
#: engines/dreamweb/detection.cpp:47 engines/neverhood/detection.cpp:160
#: engines/sci/detection.cpp:394 engines/toltecs/detection.cpp:200
+#: engines/zvision/detection.cpp:103
msgid "Use original save/load screens"
msgstr "Eredeti ment/tіlt kщpernyѕk hasznсlata"
#: engines/agi/detection.cpp:143 engines/drascula/detection.cpp:303
#: engines/dreamweb/detection.cpp:48 engines/neverhood/detection.cpp:161
#: engines/sci/detection.cpp:395 engines/toltecs/detection.cpp:201
+#: engines/zvision/detection.cpp:104
msgid "Use the original save/load screens, instead of the ScummVM ones"
msgstr "Az eredeti mentщs/betіltщs kщpernyѕ hasznсlata a ScummVM kщpek helyett"
#: engines/agi/saveload.cpp:816 engines/drascula/saveload.cpp:349
-#: engines/neverhood/menumodule.cpp:886 engines/sci/engine/kfile.cpp:857
-#: engines/toltecs/menu.cpp:256
+#: engines/dreamweb/saveload.cpp:169 engines/neverhood/menumodule.cpp:886
+#: engines/sci/engine/kfile.cpp:857 engines/toltecs/menu.cpp:256
msgid "Restore game:"
msgstr "Jсtщkmenet visszaсllэtсsa:"
#: engines/agi/saveload.cpp:816 engines/drascula/saveload.cpp:349
-#: engines/neverhood/menumodule.cpp:886 engines/sci/engine/kfile.cpp:857
-#: engines/toltecs/menu.cpp:256
+#: engines/dreamweb/saveload.cpp:169 engines/neverhood/menumodule.cpp:886
+#: engines/sci/engine/kfile.cpp:857 engines/toltecs/menu.cpp:256
msgid "Restore"
msgstr "Visszaсllэtсs"
@@ -2124,6 +2132,15 @@ msgstr ""
msgid "Cutscene file '%s' not found!"
msgstr "'%s' сtvezetѕ fсjl nem talсlhatѓ"
+#: engines/cge/detection.cpp:105 engines/cge2/detection.cpp:81
+#, fuzzy
+msgid "Color Blind Mode"
+msgstr "Kattintсs Mѓd"
+
+#: engines/cge/detection.cpp:106 engines/cge2/detection.cpp:82
+msgid "Enable Color Blind Mode by default"
+msgstr ""
+
#: engines/drascula/saveload.cpp:47
msgid ""
"ScummVM found that you have old savefiles for Drascula that should be "
@@ -2150,11 +2167,12 @@ msgid "Display graphics using the game's bright palette"
msgstr "Grafikus megjelenэtщsre hasznсlja a jсtщk fщnyes palettсjсt"
#: engines/gob/inter_playtoons.cpp:256 engines/gob/inter_v2.cpp:1470
-#: engines/tinsel/saveload.cpp:532
+#: engines/gob/inter_geisha.cpp:232 engines/tinsel/saveload.cpp:532
msgid "Failed to load game state from file."
msgstr "Jсtщkсllсs betіltщse fсjlbѓl nem sikerќlt."
-#: engines/gob/inter_v2.cpp:1540 engines/tinsel/saveload.cpp:545
+#: engines/gob/inter_v2.cpp:1540 engines/gob/inter_geisha.cpp:263
+#: engines/tinsel/saveload.cpp:545
msgid "Failed to save game state to file."
msgstr "Jсtщkсllсs mentщse fсjlba nem sikerќlt."
@@ -2174,6 +2192,14 @@ msgstr "Filmek lejсtszсsa nagyobb sebessщggel"
msgid "Failed to save game"
msgstr "Jсtщk mentщs nem sikerќlt"
+#: engines/hopkins/detection.cpp:76 engines/hopkins/detection.cpp:86
+msgid "Gore Mode"
+msgstr ""
+
+#: engines/hopkins/detection.cpp:77 engines/hopkins/detection.cpp:87
+msgid "Enable Gore Mode when available"
+msgstr ""
+
#. I18N: Studio audience adds an applause and cheering sounds whenever
#. Malcolm makes a joke.
#: engines/kyra/detection.cpp:62
@@ -2294,6 +2320,35 @@ msgstr ""
"General MIDIre. Tovсbbra is lehetsщges hogy\n"
"nщhсny hangsсv helytelenќl hangzik."
+#: engines/kyra/saveload_eob.cpp:557
+#, c-format
+msgid ""
+"The following original save game file has been found in your game path:\n"
+"\n"
+"%s %s\n"
+"\n"
+"Do you wish to use this save game file with ScummVM?\n"
+"\n"
+msgstr ""
+
+#: engines/kyra/saveload_eob.cpp:590
+#, c-format
+msgid ""
+"A save game file was found in the specified slot %d. Overwrite?\n"
+"\n"
+msgstr ""
+
+#: engines/kyra/saveload_eob.cpp:623
+#, c-format
+msgid ""
+"%d original save game files have been successfully imported into\n"
+"ScummVM. If you want to manually import original save game files later you "
+"will\n"
+"need to open the ScummVM debug console and use the command "
+"'import_savefile'.\n"
+"\n"
+msgstr ""
+
#. I18N: Option for fast scene switching
#: engines/mohawk/dialogs.cpp:92 engines/mohawk/dialogs.cpp:167
msgid "~Z~ip Mode Activated"
@@ -2422,6 +2477,14 @@ msgstr "Infѓkщpernyѕ Kщpre/Elrejt"
msgid "Display/Hide Pause Menu"
msgstr "Szќnet menќ Kщpre/Elrejt"
+#: engines/queen/detection.cpp:56
+msgid "Alternative intro"
+msgstr "Alternatэv intro"
+
+#: engines/queen/detection.cpp:57
+msgid "Use an alternative game intro (CD version only)"
+msgstr "Alternatэv jсtщkintro hasznсlata (csak CD verziѓnсl)"
+
#: engines/sci/detection.cpp:374
msgid "EGA undithering"
msgstr "EGA szinjavэtсs"
@@ -3120,6 +3183,18 @@ msgstr ""
"jсtszani akarsz vele menj a ScummVM fѕmenќben a 'Jсtщk hozzсadсs' ra щs "
"vсlaszd a 'Maniac' mappсt a 'Tentacle' kіnyvtсrсban."
+#: engines/scumm/players/player_v3m.cpp:129
+msgid ""
+"Could not find the 'Loom' Macintosh executable to read the\n"
+"instruments from. Music will be disabled."
+msgstr ""
+
+#: engines/scumm/players/player_v5m.cpp:107
+msgid ""
+"Could not find the 'Monkey Island' Macintosh executable to read the\n"
+"instruments from. Music will be disabled."
+msgstr ""
+
#: engines/sky/compact.cpp:130
msgid ""
"Unable to find \"sky.cpt\" file!\n"
@@ -3232,6 +3307,14 @@ msgstr ""
"A teenagent.dat fсjl tіmіrэtett щs a zlib nem rщsze ennek a futtathatѓ "
"сllomсnynak. Kщrlek tіmіrэtsd ki"
+#: engines/wintermute/detection.cpp:58
+msgid "Show FPS-counter"
+msgstr ""
+
+#: engines/wintermute/detection.cpp:59
+msgid "Show the current number of frames per second in the upper left corner"
+msgstr ""
+
#~ msgid "MPEG-2 cutscenes found but ScummVM has been built without MPEG-2"
#~ msgstr ""
#~ "MPEG-2 сtvezetѕfilmet talсltam, de a ScummVM MPEG-2 nщlkќl van lefordэtva"
@@ -3250,12 +3333,6 @@ msgstr ""
#~ msgid "Standard (16bpp)"
#~ msgstr "Standard (16bpp)"
-#~ msgid "Alternative intro"
-#~ msgstr "Alternatэv intro"
-
-#~ msgid "Use an alternative game intro (CD version only)"
-#~ msgstr "Alternatэv jсtщkintro hasznсlata (csak CD verziѓnсl)"
-
#~ msgid "MPEG2 cutscenes are no longer supported"
#~ msgstr "MPEG2 сtvezetѕk mсr nem tсmogatottak"
diff --git a/po/it_IT.po b/po/it_IT.po
index 27c7ebe3eb..a0192b29bb 100644
--- a/po/it_IT.po
+++ b/po/it_IT.po
@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: ScummVM 1.3.0svn\n"
"Report-Msgid-Bugs-To: scummvm-devel@lists.sf.net\n"
-"POT-Creation-Date: 2014-09-03 07:39+0200\n"
+"POT-Creation-Date: 2014-10-04 00:58+0100\n"
"PO-Revision-Date: 2014-07-03 17:59-0600\n"
"Last-Translator: Matteo 'Maff' Angelino <matteo.maff at gmail dot com>\n"
"Language-Team: Italian\n"
@@ -107,12 +107,14 @@ msgstr "Mappa"
#: engines/agos/animation.cpp:558 engines/drascula/saveload.cpp:49
#: engines/groovie/script.cpp:399 engines/parallaction/saveload.cpp:274
#: engines/scumm/dialogs.cpp:193 engines/scumm/scumm.cpp:1825
-#: engines/sky/compact.cpp:131 engines/sky/compact.cpp:141
-#: engines/sword1/animation.cpp:524 engines/sword1/animation.cpp:545
-#: engines/sword1/animation.cpp:561 engines/sword1/animation.cpp:569
-#: engines/sword1/control.cpp:865 engines/sword1/logic.cpp:1633
-#: engines/sword2/animation.cpp:425 engines/sword2/animation.cpp:445
-#: engines/sword2/animation.cpp:461 engines/sword2/animation.cpp:471
+#: engines/scumm/players/player_v3m.cpp:130
+#: engines/scumm/players/player_v5m.cpp:108 engines/sky/compact.cpp:131
+#: engines/sky/compact.cpp:141 engines/sword1/animation.cpp:524
+#: engines/sword1/animation.cpp:545 engines/sword1/animation.cpp:561
+#: engines/sword1/animation.cpp:569 engines/sword1/control.cpp:865
+#: engines/sword1/logic.cpp:1633 engines/sword2/animation.cpp:425
+#: engines/sword2/animation.cpp:445 engines/sword2/animation.cpp:461
+#: engines/sword2/animation.cpp:471
msgid "OK"
msgstr "OK"
@@ -450,7 +452,7 @@ msgstr "Cerca:"
#: gui/launcher.cpp:685 engines/dialogs.cpp:115 engines/cruise/menu.cpp:214
#: engines/mohawk/myst.cpp:245 engines/mohawk/riven.cpp:718
-#: engines/pegasus/pegasus.cpp:353
+#: engines/pegasus/pegasus.cpp:353 engines/tsage/scenes.cpp:600
msgid "Load game:"
msgstr "Carica gioco:"
@@ -459,7 +461,7 @@ msgstr "Carica gioco:"
#: backends/platform/wince/CEActionsSmartphone.cpp:231
#: engines/cruise/menu.cpp:214 engines/mohawk/myst.cpp:245
#: engines/mohawk/riven.cpp:718 engines/pegasus/pegasus.cpp:353
-#: engines/scumm/dialogs.cpp:189
+#: engines/scumm/dialogs.cpp:189 engines/tsage/scenes.cpp:600
msgid "Load"
msgstr "Carica"
@@ -477,6 +479,7 @@ msgstr ""
#: backends/platform/wince/CEActionsPocket.cpp:326
#: backends/platform/wince/CEActionsSmartphone.cpp:287
#: backends/platform/wince/CELauncherDialog.cpp:83
+#: engines/kyra/saveload_eob.cpp:557 engines/kyra/saveload_eob.cpp:590
msgid "Yes"
msgstr "Sь"
@@ -486,6 +489,7 @@ msgstr "Sь"
#: backends/platform/wince/CEActionsPocket.cpp:326
#: backends/platform/wince/CEActionsSmartphone.cpp:287
#: backends/platform/wince/CELauncherDialog.cpp:83
+#: engines/kyra/saveload_eob.cpp:557 engines/kyra/saveload_eob.cpp:590
msgid "No"
msgstr "No"
@@ -1272,8 +1276,9 @@ msgstr "~V~ai a elenco giochi"
#: engines/dialogs.cpp:116 engines/agi/saveload.cpp:803
#: engines/cruise/menu.cpp:212 engines/drascula/saveload.cpp:336
-#: engines/neverhood/menumodule.cpp:873 engines/pegasus/pegasus.cpp:377
-#: engines/sci/engine/kfile.cpp:758 engines/toltecs/menu.cpp:281
+#: engines/dreamweb/saveload.cpp:261 engines/neverhood/menumodule.cpp:873
+#: engines/pegasus/pegasus.cpp:377 engines/sci/engine/kfile.cpp:758
+#: engines/toltecs/menu.cpp:281 engines/tsage/scenes.cpp:598
msgid "Save game:"
msgstr "Salva gioco:"
@@ -1283,9 +1288,10 @@ msgstr "Salva gioco:"
#: backends/platform/wince/CEActionsSmartphone.cpp:45
#: backends/platform/wince/CEActionsSmartphone.cpp:231
#: engines/agi/saveload.cpp:803 engines/cruise/menu.cpp:212
-#: engines/drascula/saveload.cpp:336 engines/neverhood/menumodule.cpp:873
-#: engines/pegasus/pegasus.cpp:377 engines/sci/engine/kfile.cpp:758
-#: engines/scumm/dialogs.cpp:188 engines/toltecs/menu.cpp:281
+#: engines/drascula/saveload.cpp:336 engines/dreamweb/saveload.cpp:261
+#: engines/neverhood/menumodule.cpp:873 engines/pegasus/pegasus.cpp:377
+#: engines/sci/engine/kfile.cpp:758 engines/scumm/dialogs.cpp:188
+#: engines/toltecs/menu.cpp:281 engines/tsage/scenes.cpp:598
msgid "Save"
msgstr "Salva"
@@ -1310,12 +1316,12 @@ msgstr ""
"assistenza."
#: engines/dialogs.cpp:307 engines/mohawk/dialogs.cpp:109
-#: engines/mohawk/dialogs.cpp:170
+#: engines/mohawk/dialogs.cpp:170 engines/tsage/dialogs.cpp:106
msgid "~O~K"
msgstr "~O~K"
#: engines/dialogs.cpp:308 engines/mohawk/dialogs.cpp:110
-#: engines/mohawk/dialogs.cpp:171
+#: engines/mohawk/dialogs.cpp:171 engines/tsage/dialogs.cpp:107
msgid "~C~ancel"
msgstr "~A~nnulla"
@@ -2080,26 +2086,28 @@ msgstr "Clic disattivato"
#: engines/agi/detection.cpp:142 engines/drascula/detection.cpp:302
#: engines/dreamweb/detection.cpp:47 engines/neverhood/detection.cpp:160
#: engines/sci/detection.cpp:394 engines/toltecs/detection.cpp:200
+#: engines/zvision/detection.cpp:103
msgid "Use original save/load screens"
msgstr "Usa schermate di salvataggio originali"
#: engines/agi/detection.cpp:143 engines/drascula/detection.cpp:303
#: engines/dreamweb/detection.cpp:48 engines/neverhood/detection.cpp:161
#: engines/sci/detection.cpp:395 engines/toltecs/detection.cpp:201
+#: engines/zvision/detection.cpp:104
msgid "Use the original save/load screens, instead of the ScummVM ones"
msgstr ""
"Usa le schermate originali di salvataggio e caricamento, al posto di quelle "
"di ScummVM"
#: engines/agi/saveload.cpp:816 engines/drascula/saveload.cpp:349
-#: engines/neverhood/menumodule.cpp:886 engines/sci/engine/kfile.cpp:857
-#: engines/toltecs/menu.cpp:256
+#: engines/dreamweb/saveload.cpp:169 engines/neverhood/menumodule.cpp:886
+#: engines/sci/engine/kfile.cpp:857 engines/toltecs/menu.cpp:256
msgid "Restore game:"
msgstr "Ripristina gioco:"
#: engines/agi/saveload.cpp:816 engines/drascula/saveload.cpp:349
-#: engines/neverhood/menumodule.cpp:886 engines/sci/engine/kfile.cpp:857
-#: engines/toltecs/menu.cpp:256
+#: engines/dreamweb/saveload.cpp:169 engines/neverhood/menumodule.cpp:886
+#: engines/sci/engine/kfile.cpp:857 engines/toltecs/menu.cpp:256
msgid "Restore"
msgstr "Ripristina"
@@ -2141,6 +2149,15 @@ msgstr ""
msgid "Cutscene file '%s' not found!"
msgstr "File della scena di intermezzo '%s' non trovato!"
+#: engines/cge/detection.cpp:105 engines/cge2/detection.cpp:81
+#, fuzzy
+msgid "Color Blind Mode"
+msgstr "Modalitр clic"
+
+#: engines/cge/detection.cpp:106 engines/cge2/detection.cpp:82
+msgid "Enable Color Blind Mode by default"
+msgstr ""
+
#: engines/drascula/saveload.cpp:47
msgid ""
"ScummVM found that you have old savefiles for Drascula that should be "
@@ -2168,11 +2185,12 @@ msgid "Display graphics using the game's bright palette"
msgstr "Visualizza la grafica con i colori brillanti del gioco"
#: engines/gob/inter_playtoons.cpp:256 engines/gob/inter_v2.cpp:1470
-#: engines/tinsel/saveload.cpp:532
+#: engines/gob/inter_geisha.cpp:232 engines/tinsel/saveload.cpp:532
msgid "Failed to load game state from file."
msgstr "Impossibile caricare il gioco dal file."
-#: engines/gob/inter_v2.cpp:1540 engines/tinsel/saveload.cpp:545
+#: engines/gob/inter_v2.cpp:1540 engines/gob/inter_geisha.cpp:263
+#: engines/tinsel/saveload.cpp:545
msgid "Failed to save game state to file."
msgstr "Impossibile salvare il gioco nel file."
@@ -2192,6 +2210,14 @@ msgstr "Aumenta la velocitр di riproduzione dei filmati"
msgid "Failed to save game"
msgstr "Impossibile salvare il gioco"
+#: engines/hopkins/detection.cpp:76 engines/hopkins/detection.cpp:86
+msgid "Gore Mode"
+msgstr ""
+
+#: engines/hopkins/detection.cpp:77 engines/hopkins/detection.cpp:87
+msgid "Enable Gore Mode when available"
+msgstr ""
+
#. I18N: Studio audience adds an applause and cheering sounds whenever
#. Malcolm makes a joke.
#: engines/kyra/detection.cpp:62
@@ -2312,6 +2338,35 @@ msgstr ""
"Roland MT32 in quelli General MIDI. Alcune tracce\n"
"potrebbero avere un suono non corretto."
+#: engines/kyra/saveload_eob.cpp:557
+#, c-format
+msgid ""
+"The following original save game file has been found in your game path:\n"
+"\n"
+"%s %s\n"
+"\n"
+"Do you wish to use this save game file with ScummVM?\n"
+"\n"
+msgstr ""
+
+#: engines/kyra/saveload_eob.cpp:590
+#, c-format
+msgid ""
+"A save game file was found in the specified slot %d. Overwrite?\n"
+"\n"
+msgstr ""
+
+#: engines/kyra/saveload_eob.cpp:623
+#, c-format
+msgid ""
+"%d original save game files have been successfully imported into\n"
+"ScummVM. If you want to manually import original save game files later you "
+"will\n"
+"need to open the ScummVM debug console and use the command "
+"'import_savefile'.\n"
+"\n"
+msgstr ""
+
#. I18N: Option for fast scene switching
#: engines/mohawk/dialogs.cpp:92 engines/mohawk/dialogs.cpp:167
msgid "~Z~ip Mode Activated"
@@ -2440,6 +2495,14 @@ msgstr "Mostra/nascondi schermana info"
msgid "Display/Hide Pause Menu"
msgstr "Mostra/nascondi menu pausa"
+#: engines/queen/detection.cpp:56
+msgid "Alternative intro"
+msgstr "Intro alternativa"
+
+#: engines/queen/detection.cpp:57
+msgid "Use an alternative game intro (CD version only)"
+msgstr "Usa un'intro del gioco alternativa (solo versione CD)"
+
#: engines/sci/detection.cpp:374
msgid "EGA undithering"
msgstr "Undithering EGA"
@@ -3142,6 +3205,18 @@ msgstr ""
"principale di ScummVM e seleziona la cartella \"Maniac\" all'interno della "
"cartella di Day Of The Tentacle."
+#: engines/scumm/players/player_v3m.cpp:129
+msgid ""
+"Could not find the 'Loom' Macintosh executable to read the\n"
+"instruments from. Music will be disabled."
+msgstr ""
+
+#: engines/scumm/players/player_v5m.cpp:107
+msgid ""
+"Could not find the 'Monkey Island' Macintosh executable to read the\n"
+"instruments from. Music will be disabled."
+msgstr ""
+
#: engines/sky/compact.cpp:130
msgid ""
"Unable to find \"sky.cpt\" file!\n"
@@ -3257,6 +3332,14 @@ msgstr ""
"Il file teenagent.dat ш compresso e zlib non ш stata inclusa in questo "
"eseguibile. Si prega di decomprimerlo"
+#: engines/wintermute/detection.cpp:58
+msgid "Show FPS-counter"
+msgstr ""
+
+#: engines/wintermute/detection.cpp:59
+msgid "Show the current number of frames per second in the upper left corner"
+msgstr ""
+
#~ msgid "MPEG-2 cutscenes found but ScummVM has been built without MPEG-2"
#~ msgstr ""
#~ "Sono state trovare scene di intermezzo MPEG-2 ma ScummVM ш stato "
@@ -3278,12 +3361,6 @@ msgstr ""
#~ msgid "Standard (16bpp)"
#~ msgstr "Standard (16bpp)"
-#~ msgid "Alternative intro"
-#~ msgstr "Intro alternativa"
-
-#~ msgid "Use an alternative game intro (CD version only)"
-#~ msgstr "Usa un'intro del gioco alternativa (solo versione CD)"
-
#~ msgid "MPEG2 cutscenes are no longer supported"
#~ msgstr "Le scene di intermezzo MPEG2 non sono piљ supportate"
diff --git a/po/nb_NO.po b/po/nb_NO.po
index 172b402324..cf211a46a4 100644
--- a/po/nb_NO.po
+++ b/po/nb_NO.po
@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: ScummVM 1.3.0svn\n"
"Report-Msgid-Bugs-To: scummvm-devel@lists.sf.net\n"
-"POT-Creation-Date: 2014-09-03 07:39+0200\n"
+"POT-Creation-Date: 2014-10-04 00:58+0100\n"
"PO-Revision-Date: 2014-07-11 00:02+0100\n"
"Last-Translator: Einar Johan Trјan Sјmхen <einarjohants@gmail.com>\n"
"Language-Team: somaen <einarjohants@gmail.com>\n"
@@ -110,12 +110,14 @@ msgstr "Koble"
#: engines/agos/animation.cpp:558 engines/drascula/saveload.cpp:49
#: engines/groovie/script.cpp:399 engines/parallaction/saveload.cpp:274
#: engines/scumm/dialogs.cpp:193 engines/scumm/scumm.cpp:1825
-#: engines/sky/compact.cpp:131 engines/sky/compact.cpp:141
-#: engines/sword1/animation.cpp:524 engines/sword1/animation.cpp:545
-#: engines/sword1/animation.cpp:561 engines/sword1/animation.cpp:569
-#: engines/sword1/control.cpp:865 engines/sword1/logic.cpp:1633
-#: engines/sword2/animation.cpp:425 engines/sword2/animation.cpp:445
-#: engines/sword2/animation.cpp:461 engines/sword2/animation.cpp:471
+#: engines/scumm/players/player_v3m.cpp:130
+#: engines/scumm/players/player_v5m.cpp:108 engines/sky/compact.cpp:131
+#: engines/sky/compact.cpp:141 engines/sword1/animation.cpp:524
+#: engines/sword1/animation.cpp:545 engines/sword1/animation.cpp:561
+#: engines/sword1/animation.cpp:569 engines/sword1/control.cpp:865
+#: engines/sword1/logic.cpp:1633 engines/sword2/animation.cpp:425
+#: engines/sword2/animation.cpp:445 engines/sword2/animation.cpp:461
+#: engines/sword2/animation.cpp:471
msgid "OK"
msgstr "OK"
@@ -454,7 +456,7 @@ msgstr "Sјk:"
#: gui/launcher.cpp:685 engines/dialogs.cpp:115 engines/cruise/menu.cpp:214
#: engines/mohawk/myst.cpp:245 engines/mohawk/riven.cpp:718
-#: engines/pegasus/pegasus.cpp:353
+#: engines/pegasus/pegasus.cpp:353 engines/tsage/scenes.cpp:600
msgid "Load game:"
msgstr "Хpne spill:"
@@ -463,7 +465,7 @@ msgstr "Хpne spill:"
#: backends/platform/wince/CEActionsSmartphone.cpp:231
#: engines/cruise/menu.cpp:214 engines/mohawk/myst.cpp:245
#: engines/mohawk/riven.cpp:718 engines/pegasus/pegasus.cpp:353
-#: engines/scumm/dialogs.cpp:189
+#: engines/scumm/dialogs.cpp:189 engines/tsage/scenes.cpp:600
msgid "Load"
msgstr "Хpne"
@@ -481,6 +483,7 @@ msgstr ""
#: backends/platform/wince/CEActionsPocket.cpp:326
#: backends/platform/wince/CEActionsSmartphone.cpp:287
#: backends/platform/wince/CELauncherDialog.cpp:83
+#: engines/kyra/saveload_eob.cpp:557 engines/kyra/saveload_eob.cpp:590
msgid "Yes"
msgstr "Ja"
@@ -490,6 +493,7 @@ msgstr "Ja"
#: backends/platform/wince/CEActionsPocket.cpp:326
#: backends/platform/wince/CEActionsSmartphone.cpp:287
#: backends/platform/wince/CELauncherDialog.cpp:83
+#: engines/kyra/saveload_eob.cpp:557 engines/kyra/saveload_eob.cpp:590
msgid "No"
msgstr "Nei"
@@ -1267,8 +1271,9 @@ msgstr "~T~ilbake til oppstarter"
#: engines/dialogs.cpp:116 engines/agi/saveload.cpp:803
#: engines/cruise/menu.cpp:212 engines/drascula/saveload.cpp:336
-#: engines/neverhood/menumodule.cpp:873 engines/pegasus/pegasus.cpp:377
-#: engines/sci/engine/kfile.cpp:758 engines/toltecs/menu.cpp:281
+#: engines/dreamweb/saveload.cpp:261 engines/neverhood/menumodule.cpp:873
+#: engines/pegasus/pegasus.cpp:377 engines/sci/engine/kfile.cpp:758
+#: engines/toltecs/menu.cpp:281 engines/tsage/scenes.cpp:598
msgid "Save game:"
msgstr "Lagret spill:"
@@ -1278,9 +1283,10 @@ msgstr "Lagret spill:"
#: backends/platform/wince/CEActionsSmartphone.cpp:45
#: backends/platform/wince/CEActionsSmartphone.cpp:231
#: engines/agi/saveload.cpp:803 engines/cruise/menu.cpp:212
-#: engines/drascula/saveload.cpp:336 engines/neverhood/menumodule.cpp:873
-#: engines/pegasus/pegasus.cpp:377 engines/sci/engine/kfile.cpp:758
-#: engines/scumm/dialogs.cpp:188 engines/toltecs/menu.cpp:281
+#: engines/drascula/saveload.cpp:336 engines/dreamweb/saveload.cpp:261
+#: engines/neverhood/menumodule.cpp:873 engines/pegasus/pegasus.cpp:377
+#: engines/sci/engine/kfile.cpp:758 engines/scumm/dialogs.cpp:188
+#: engines/toltecs/menu.cpp:281 engines/tsage/scenes.cpp:598
msgid "Save"
msgstr "Lagre"
@@ -1304,12 +1310,12 @@ msgstr ""
"grunnleggende informasjon og instruksjon om hvordan du fхr ytterligere hjelp."
#: engines/dialogs.cpp:307 engines/mohawk/dialogs.cpp:109
-#: engines/mohawk/dialogs.cpp:170
+#: engines/mohawk/dialogs.cpp:170 engines/tsage/dialogs.cpp:106
msgid "~O~K"
msgstr "~O~K"
#: engines/dialogs.cpp:308 engines/mohawk/dialogs.cpp:110
-#: engines/mohawk/dialogs.cpp:171
+#: engines/mohawk/dialogs.cpp:171 engines/tsage/dialogs.cpp:107
msgid "~C~ancel"
msgstr "~A~vbryt"
@@ -2074,24 +2080,26 @@ msgstr "Klikking deaktivert"
#: engines/agi/detection.cpp:142 engines/drascula/detection.cpp:302
#: engines/dreamweb/detection.cpp:47 engines/neverhood/detection.cpp:160
#: engines/sci/detection.cpp:394 engines/toltecs/detection.cpp:200
+#: engines/zvision/detection.cpp:103
msgid "Use original save/load screens"
msgstr "Bruk originale lagre/laste-skjermer"
#: engines/agi/detection.cpp:143 engines/drascula/detection.cpp:303
#: engines/dreamweb/detection.cpp:48 engines/neverhood/detection.cpp:161
#: engines/sci/detection.cpp:395 engines/toltecs/detection.cpp:201
+#: engines/zvision/detection.cpp:104
msgid "Use the original save/load screens, instead of the ScummVM ones"
msgstr "Bruk de originale lagre/laste-skjermene, istedenfor ScummVM-variantene"
#: engines/agi/saveload.cpp:816 engines/drascula/saveload.cpp:349
-#: engines/neverhood/menumodule.cpp:886 engines/sci/engine/kfile.cpp:857
-#: engines/toltecs/menu.cpp:256
+#: engines/dreamweb/saveload.cpp:169 engines/neverhood/menumodule.cpp:886
+#: engines/sci/engine/kfile.cpp:857 engines/toltecs/menu.cpp:256
msgid "Restore game:"
msgstr "Gjennopprett spill:"
#: engines/agi/saveload.cpp:816 engines/drascula/saveload.cpp:349
-#: engines/neverhood/menumodule.cpp:886 engines/sci/engine/kfile.cpp:857
-#: engines/toltecs/menu.cpp:256
+#: engines/dreamweb/saveload.cpp:169 engines/neverhood/menumodule.cpp:886
+#: engines/sci/engine/kfile.cpp:857 engines/toltecs/menu.cpp:256
msgid "Restore"
msgstr "Gjenopprett"
@@ -2133,6 +2141,15 @@ msgstr ""
msgid "Cutscene file '%s' not found!"
msgstr "Fant ikke cutscenefil '%s'!"
+#: engines/cge/detection.cpp:105 engines/cge2/detection.cpp:81
+#, fuzzy
+msgid "Color Blind Mode"
+msgstr "Klikkmodus"
+
+#: engines/cge/detection.cpp:106 engines/cge2/detection.cpp:82
+msgid "Enable Color Blind Mode by default"
+msgstr ""
+
#: engines/drascula/saveload.cpp:47
msgid ""
"ScummVM found that you have old savefiles for Drascula that should be "
@@ -2160,11 +2177,12 @@ msgid "Display graphics using the game's bright palette"
msgstr "Vis grafikk med spillets lyse palett"
#: engines/gob/inter_playtoons.cpp:256 engines/gob/inter_v2.cpp:1470
-#: engines/tinsel/saveload.cpp:532
+#: engines/gob/inter_geisha.cpp:232 engines/tinsel/saveload.cpp:532
msgid "Failed to load game state from file."
msgstr "Klarte ikke хpne spilltilstand fra fil."
-#: engines/gob/inter_v2.cpp:1540 engines/tinsel/saveload.cpp:545
+#: engines/gob/inter_v2.cpp:1540 engines/gob/inter_geisha.cpp:263
+#: engines/tinsel/saveload.cpp:545
msgid "Failed to save game state to file."
msgstr "Klarte ikke lagre spilltilstand fra fil."
@@ -2184,6 +2202,14 @@ msgstr "Spill filmer med јkt hastighet"
msgid "Failed to save game"
msgstr "Klarte ikke х lagre spill."
+#: engines/hopkins/detection.cpp:76 engines/hopkins/detection.cpp:86
+msgid "Gore Mode"
+msgstr ""
+
+#: engines/hopkins/detection.cpp:77 engines/hopkins/detection.cpp:87
+msgid "Enable Gore Mode when available"
+msgstr ""
+
#. I18N: Studio audience adds an applause and cheering sounds whenever
#. Malcolm makes a joke.
#: engines/kyra/detection.cpp:62
@@ -2305,6 +2331,35 @@ msgstr ""
"General MIDI-instrumentene. Allikevel, kan det\n"
"skje at enkelte spor ikke vil spilles riktig."
+#: engines/kyra/saveload_eob.cpp:557
+#, c-format
+msgid ""
+"The following original save game file has been found in your game path:\n"
+"\n"
+"%s %s\n"
+"\n"
+"Do you wish to use this save game file with ScummVM?\n"
+"\n"
+msgstr ""
+
+#: engines/kyra/saveload_eob.cpp:590
+#, c-format
+msgid ""
+"A save game file was found in the specified slot %d. Overwrite?\n"
+"\n"
+msgstr ""
+
+#: engines/kyra/saveload_eob.cpp:623
+#, c-format
+msgid ""
+"%d original save game files have been successfully imported into\n"
+"ScummVM. If you want to manually import original save game files later you "
+"will\n"
+"need to open the ScummVM debug console and use the command "
+"'import_savefile'.\n"
+"\n"
+msgstr ""
+
#. I18N: Option for fast scene switching
#: engines/mohawk/dialogs.cpp:92 engines/mohawk/dialogs.cpp:167
msgid "~Z~ip Mode Activated"
@@ -2433,6 +2488,14 @@ msgstr "Vis/Skjul Infoskjerm"
msgid "Display/Hide Pause Menu"
msgstr "Vis/Skjul Pausemeny"
+#: engines/queen/detection.cpp:56
+msgid "Alternative intro"
+msgstr "Alternativ intro"
+
+#: engines/queen/detection.cpp:57
+msgid "Use an alternative game intro (CD version only)"
+msgstr "Bruk en alternativ intro (Kun for CD-versjon)"
+
#: engines/sci/detection.cpp:374
msgid "EGA undithering"
msgstr "EGA av-dithering"
@@ -3132,6 +3195,18 @@ msgstr ""
"ennх. Sх, for х spille Maniac Mansion, gх til 'Legg til spill' i ScummVM-"
"hovedmenyen og velg 'Maniac'-undermappa i Tentacle-mappa."
+#: engines/scumm/players/player_v3m.cpp:129
+msgid ""
+"Could not find the 'Loom' Macintosh executable to read the\n"
+"instruments from. Music will be disabled."
+msgstr ""
+
+#: engines/scumm/players/player_v5m.cpp:107
+msgid ""
+"Could not find the 'Monkey Island' Macintosh executable to read the\n"
+"instruments from. Music will be disabled."
+msgstr ""
+
#: engines/sky/compact.cpp:130
msgid ""
"Unable to find \"sky.cpt\" file!\n"
@@ -3240,6 +3315,14 @@ msgstr ""
"teenagent.dat-fila er komprimert og zlib har ikke blitt inkludert i denne "
"programfilen. Vennligst pakk den ut"
+#: engines/wintermute/detection.cpp:58
+msgid "Show FPS-counter"
+msgstr ""
+
+#: engines/wintermute/detection.cpp:59
+msgid "Show the current number of frames per second in the upper left corner"
+msgstr ""
+
#~ msgid "MPEG-2 cutscenes found but ScummVM has been built without MPEG-2"
#~ msgstr "MPEG2-cutscener funnet men ScummVM er bygd uten MPEG2-stјtte"
@@ -3257,12 +3340,6 @@ msgstr ""
#~ msgid "Standard (16bpp)"
#~ msgstr "Standard (16bpp)"
-#~ msgid "Alternative intro"
-#~ msgstr "Alternativ intro"
-
-#~ msgid "Use an alternative game intro (CD version only)"
-#~ msgstr "Bruk en alternativ intro (Kun for CD-versjon)"
-
#~ msgid "MPEG2 cutscenes are no longer supported"
#~ msgstr "MPEG2-cutscener stјttes ikke lengre"
diff --git a/po/nl_NL.po b/po/nl_NL.po
index 2d43470fd5..3a9e6d8172 100644
--- a/po/nl_NL.po
+++ b/po/nl_NL.po
@@ -1,21 +1,21 @@
# LANGUAGE translation for ScummVM.
# Copyright (C) YEAR ScummVM Team
# This file is distributed under the same license as the ScummVM package.
-# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
+# FIRST AUTHOR scummvm@bencastricum.nl, 2014.
#
msgid ""
msgstr ""
"Project-Id-Version: ScummVM 1.8.0git\n"
"Report-Msgid-Bugs-To: scummvm-devel@lists.sf.net\n"
-"POT-Creation-Date: 2014-09-03 07:39+0200\n"
-"PO-Revision-Date: 2014-09-03 07:42+0100\n"
+"POT-Creation-Date: 2014-11-25 20:41+0100\n"
+"PO-Revision-Date: 2014-11-25 20:46+0100\n"
"Last-Translator: Ben Castricum <scummvm@bencastricum.nl>\n"
"Language-Team: Ben Castricum <scummvm@bencastricum.nl>\n"
"Language: Nederlands\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=iso-8859-1\n"
"Content-Transfer-Encoding: 8bit\n"
-"X-Generator: Poedit 1.5.3\n"
+"X-Generator: Poedit 1.6.10\n"
"X-Poedit-SourceCharset: iso-8859-1\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
@@ -34,11 +34,11 @@ msgstr "Beschikbare engines:"
#: gui/browser.cpp:68
msgid "Show hidden files"
-msgstr "Verborgen bestanden weergeven"
+msgstr "Toon verborgen bestanden"
#: gui/browser.cpp:68
msgid "Show files marked with the hidden attribute"
-msgstr "Toon de bestanden die met het verborgen kenmerk hebben."
+msgstr "Toon bestanden die het verborgen kenmerk hebben."
#: gui/browser.cpp:72
msgid "Go up"
@@ -108,14 +108,16 @@ msgstr "Koppel"
#: backends/platform/wii/options.cpp:47
#: backends/platform/wince/CELauncherDialog.cpp:54
#: engines/agos/animation.cpp:558 engines/drascula/saveload.cpp:49
-#: engines/groovie/script.cpp:399 engines/parallaction/saveload.cpp:274
+#: engines/groovie/script.cpp:408 engines/parallaction/saveload.cpp:274
#: engines/scumm/dialogs.cpp:193 engines/scumm/scumm.cpp:1825
-#: engines/sky/compact.cpp:131 engines/sky/compact.cpp:141
-#: engines/sword1/animation.cpp:524 engines/sword1/animation.cpp:545
-#: engines/sword1/animation.cpp:561 engines/sword1/animation.cpp:569
-#: engines/sword1/control.cpp:865 engines/sword1/logic.cpp:1633
-#: engines/sword2/animation.cpp:425 engines/sword2/animation.cpp:445
-#: engines/sword2/animation.cpp:461 engines/sword2/animation.cpp:471
+#: engines/scumm/players/player_v3m.cpp:130
+#: engines/scumm/players/player_v5m.cpp:108 engines/sky/compact.cpp:131
+#: engines/sky/compact.cpp:141 engines/sword1/animation.cpp:524
+#: engines/sword1/animation.cpp:545 engines/sword1/animation.cpp:561
+#: engines/sword1/animation.cpp:569 engines/sword1/control.cpp:865
+#: engines/sword1/logic.cpp:1633 engines/sword2/animation.cpp:425
+#: engines/sword2/animation.cpp:445 engines/sword2/animation.cpp:461
+#: engines/sword2/animation.cpp:471
msgid "OK"
msgstr "OK"
@@ -212,7 +214,7 @@ msgstr "Engine"
#: gui/launcher.cpp:245 gui/options.cpp:1073 gui/options.cpp:1090
msgid "Graphics"
-msgstr "Grafisch"
+msgstr "Beeld"
#: gui/launcher.cpp:245 gui/options.cpp:1073 gui/options.cpp:1090
msgid "GFX"
@@ -229,7 +231,7 @@ msgstr "Negeer algemene grafische instellingen"
#: gui/launcher.cpp:257 gui/options.cpp:1096
msgid "Audio"
-msgstr "Audio"
+msgstr "Geluid"
#: gui/launcher.cpp:260
msgid "Override global audio settings"
@@ -317,7 +319,7 @@ msgstr "Extra Pad:"
#: gui/launcher.cpp:339 gui/options.cpp:1134
msgid "Save Path:"
-msgstr "Save Pad:"
+msgstr "Bewaar Pad:"
#: gui/launcher.cpp:339 gui/launcher.cpp:341 gui/launcher.cpp:342
#: gui/options.cpp:1134 gui/options.cpp:1136 gui/options.cpp:1137
@@ -327,7 +329,7 @@ msgstr "Bepaalt waar opgeslagen spellen worden bewaard."
#: gui/launcher.cpp:341 gui/options.cpp:1136
msgctxt "lowres"
msgid "Save Path:"
-msgstr "Save Pad:"
+msgstr "Bewaar Pad:"
#: gui/launcher.cpp:360 gui/launcher.cpp:459 gui/launcher.cpp:517
#: gui/launcher.cpp:571 gui/options.cpp:1145 gui/options.cpp:1153
@@ -456,7 +458,7 @@ msgstr "Zoeken:"
#: gui/launcher.cpp:685 engines/dialogs.cpp:115 engines/cruise/menu.cpp:214
#: engines/mohawk/myst.cpp:245 engines/mohawk/riven.cpp:718
-#: engines/pegasus/pegasus.cpp:353
+#: engines/pegasus/pegasus.cpp:353 engines/tsage/scenes.cpp:600
msgid "Load game:"
msgstr "Laad spel:"
@@ -465,7 +467,7 @@ msgstr "Laad spel:"
#: backends/platform/wince/CEActionsSmartphone.cpp:231
#: engines/cruise/menu.cpp:214 engines/mohawk/myst.cpp:245
#: engines/mohawk/riven.cpp:718 engines/pegasus/pegasus.cpp:353
-#: engines/scumm/dialogs.cpp:189
+#: engines/scumm/dialogs.cpp:189 engines/tsage/scenes.cpp:600
msgid "Load"
msgstr "Laden"
@@ -483,6 +485,7 @@ msgstr ""
#: backends/platform/wince/CEActionsPocket.cpp:326
#: backends/platform/wince/CEActionsSmartphone.cpp:287
#: backends/platform/wince/CELauncherDialog.cpp:83
+#: engines/kyra/saveload_eob.cpp:557 engines/kyra/saveload_eob.cpp:590
msgid "Yes"
msgstr "Ja"
@@ -492,6 +495,7 @@ msgstr "Ja"
#: backends/platform/wince/CEActionsPocket.cpp:326
#: backends/platform/wince/CEActionsSmartphone.cpp:287
#: backends/platform/wince/CELauncherDialog.cpp:83
+#: engines/kyra/saveload_eob.cpp:557 engines/kyra/saveload_eob.cpp:590
msgid "No"
msgstr "Nee"
@@ -600,8 +604,7 @@ msgstr "Geen"
#: gui/options.cpp:389
msgid "Failed to apply some of the graphic options changes:"
-msgstr ""
-"Het is niet gelukt om enkele veranderingen in grafische opties toe te passen:"
+msgstr "Sommige grafische opties konden niet worden toegepast:"
#: gui/options.cpp:401
msgid "the video mode could not be changed."
@@ -777,7 +780,7 @@ msgstr "Geen Roland MT-32 muziek gebruiken"
#: gui/options.cpp:927
msgid "Text and Speech:"
-msgstr "Spraak en/of ondertitels:"
+msgstr "Spraak en/of tekst:"
#: gui/options.cpp:931 gui/options.cpp:941
msgid "Speech"
@@ -785,7 +788,7 @@ msgstr "Spraak"
#: gui/options.cpp:932 gui/options.cpp:942
msgid "Subtitles"
-msgstr "Ondertitels"
+msgstr "Tekst"
#: gui/options.cpp:933
msgid "Both"
@@ -793,7 +796,7 @@ msgstr "Beide"
#: gui/options.cpp:935
msgid "Subtitle speed:"
-msgstr "Snelheid ondertitels:"
+msgstr "Snelheid tekst:"
#: gui/options.cpp:937
msgctxt "lowres"
@@ -815,7 +818,7 @@ msgstr "Beide"
#: gui/options.cpp:943
msgid "Show subtitles and play speech"
-msgstr "Toon ondertitels en speel spraak af"
+msgstr "Toon tekst en speel spraak af"
#: gui/options.cpp:945
msgctxt "lowres"
@@ -1273,17 +1276,18 @@ msgstr "O~v~er"
#: engines/dialogs.cpp:105 engines/dialogs.cpp:181
msgid "~R~eturn to Launcher"
-msgstr "~T~erug naar het startmenu"
+msgstr "Terug naar s~t~artmenu"
#: engines/dialogs.cpp:107 engines/dialogs.cpp:183
msgctxt "lowres"
msgid "~R~eturn to Launcher"
-msgstr "~T~erug naar startmenu"
+msgstr "S~t~artmenu"
#: engines/dialogs.cpp:116 engines/agi/saveload.cpp:803
#: engines/cruise/menu.cpp:212 engines/drascula/saveload.cpp:336
-#: engines/neverhood/menumodule.cpp:873 engines/pegasus/pegasus.cpp:377
-#: engines/sci/engine/kfile.cpp:758 engines/toltecs/menu.cpp:281
+#: engines/dreamweb/saveload.cpp:261 engines/neverhood/menumodule.cpp:873
+#: engines/pegasus/pegasus.cpp:377 engines/sci/engine/kfile.cpp:759
+#: engines/toltecs/menu.cpp:281 engines/tsage/scenes.cpp:598
msgid "Save game:"
msgstr "Spel opslaan:"
@@ -1293,9 +1297,10 @@ msgstr "Spel opslaan:"
#: backends/platform/wince/CEActionsSmartphone.cpp:45
#: backends/platform/wince/CEActionsSmartphone.cpp:231
#: engines/agi/saveload.cpp:803 engines/cruise/menu.cpp:212
-#: engines/drascula/saveload.cpp:336 engines/neverhood/menumodule.cpp:873
-#: engines/pegasus/pegasus.cpp:377 engines/sci/engine/kfile.cpp:758
-#: engines/scumm/dialogs.cpp:188 engines/toltecs/menu.cpp:281
+#: engines/drascula/saveload.cpp:336 engines/dreamweb/saveload.cpp:261
+#: engines/neverhood/menumodule.cpp:873 engines/pegasus/pegasus.cpp:377
+#: engines/sci/engine/kfile.cpp:759 engines/scumm/dialogs.cpp:188
+#: engines/toltecs/menu.cpp:281 engines/tsage/scenes.cpp:598
msgid "Save"
msgstr "Opslaan"
@@ -1320,12 +1325,12 @@ msgstr ""
"assistentie."
#: engines/dialogs.cpp:307 engines/mohawk/dialogs.cpp:109
-#: engines/mohawk/dialogs.cpp:170
+#: engines/mohawk/dialogs.cpp:170 engines/tsage/dialogs.cpp:106
msgid "~O~K"
msgstr "~O~K"
#: engines/dialogs.cpp:308 engines/mohawk/dialogs.cpp:110
-#: engines/mohawk/dialogs.cpp:171
+#: engines/mohawk/dialogs.cpp:171 engines/tsage/dialogs.cpp:107
msgid "~C~ancel"
msgstr "~A~nnuleer"
@@ -1534,7 +1539,7 @@ msgstr "~I~ndy vecht besturing"
#: backends/platform/ds/arm9/source/dsoptions.cpp:65
msgid "Show mouse cursor"
-msgstr "Toon muis wijzer"
+msgstr "Toon muiswijzer"
#: backends/platform/ds/arm9/source/dsoptions.cpp:66
msgid "Snap to edges"
@@ -1763,7 +1768,7 @@ msgstr "Video"
#: backends/platform/wii/options.cpp:54
msgid "Current video mode:"
-msgstr "Huidige video modus:"
+msgstr "Huidige videomodus:"
#: backends/platform/wii/options.cpp:56
msgid "Double-strike"
@@ -2093,25 +2098,27 @@ msgstr "Klikken Uitgeschakeld"
#: engines/agi/detection.cpp:142 engines/drascula/detection.cpp:302
#: engines/dreamweb/detection.cpp:47 engines/neverhood/detection.cpp:160
#: engines/sci/detection.cpp:394 engines/toltecs/detection.cpp:200
+#: engines/zvision/detection.cpp:103
msgid "Use original save/load screens"
msgstr "Gebruik originele opslaan/laad schermen"
#: engines/agi/detection.cpp:143 engines/drascula/detection.cpp:303
#: engines/dreamweb/detection.cpp:48 engines/neverhood/detection.cpp:161
#: engines/sci/detection.cpp:395 engines/toltecs/detection.cpp:201
+#: engines/zvision/detection.cpp:104
msgid "Use the original save/load screens, instead of the ScummVM ones"
msgstr ""
"Gebruik de originele opslaan/laden schermen, in plaats van die van ScummVM"
#: engines/agi/saveload.cpp:816 engines/drascula/saveload.cpp:349
-#: engines/neverhood/menumodule.cpp:886 engines/sci/engine/kfile.cpp:857
-#: engines/toltecs/menu.cpp:256
+#: engines/dreamweb/saveload.cpp:169 engines/neverhood/menumodule.cpp:886
+#: engines/sci/engine/kfile.cpp:858 engines/toltecs/menu.cpp:256
msgid "Restore game:"
msgstr "Laad opgeslagen spel:"
#: engines/agi/saveload.cpp:816 engines/drascula/saveload.cpp:349
-#: engines/neverhood/menumodule.cpp:886 engines/sci/engine/kfile.cpp:857
-#: engines/toltecs/menu.cpp:256
+#: engines/dreamweb/saveload.cpp:169 engines/neverhood/menumodule.cpp:886
+#: engines/sci/engine/kfile.cpp:858 engines/toltecs/menu.cpp:256
msgid "Restore"
msgstr "Laad"
@@ -2153,6 +2160,14 @@ msgstr ""
msgid "Cutscene file '%s' not found!"
msgstr "Cutscene bestand '%s' niet gevonden!"
+#: engines/cge/detection.cpp:105 engines/cge2/detection.cpp:91
+msgid "Color Blind Mode"
+msgstr "Kleurenblind Modus"
+
+#: engines/cge/detection.cpp:106 engines/cge2/detection.cpp:92
+msgid "Enable Color Blind Mode by default"
+msgstr "Schakel Kleurenblind modus standaard in"
+
#: engines/drascula/saveload.cpp:47
msgid ""
"ScummVM found that you have old savefiles for Drascula that should be "
@@ -2180,11 +2195,12 @@ msgid "Display graphics using the game's bright palette"
msgstr "Gebruik het heldere palet van het spel voor grafische zaken."
#: engines/gob/inter_playtoons.cpp:256 engines/gob/inter_v2.cpp:1470
-#: engines/tinsel/saveload.cpp:532
+#: engines/gob/inter_geisha.cpp:232 engines/tinsel/saveload.cpp:532
msgid "Failed to load game state from file."
msgstr "Laden van opgeslagen spel mislukt."
-#: engines/gob/inter_v2.cpp:1540 engines/tinsel/saveload.cpp:545
+#: engines/gob/inter_v2.cpp:1540 engines/gob/inter_geisha.cpp:263
+#: engines/tinsel/saveload.cpp:545
msgid "Failed to save game state to file."
msgstr "Opslaan van spel in bestand is mislukt."
@@ -2200,10 +2216,18 @@ msgstr "Film snel afspelen"
msgid "Play movies at an increased speed"
msgstr "Speel films sneller af"
-#: engines/groovie/script.cpp:399
+#: engines/groovie/script.cpp:408
msgid "Failed to save game"
msgstr "Opslaan van spel mislukt."
+#: engines/hopkins/detection.cpp:76 engines/hopkins/detection.cpp:86
+msgid "Gore Mode"
+msgstr "Gore Modus"
+
+#: engines/hopkins/detection.cpp:77 engines/hopkins/detection.cpp:87
+msgid "Enable Gore Mode when available"
+msgstr "Gore modus inschakelen waar mogelijk"
+
#. I18N: Studio audience adds an applause and cheering sounds whenever
#. Malcolm makes a joke.
#: engines/kyra/detection.cpp:62
@@ -2323,6 +2347,49 @@ msgstr ""
"We zullen proberen te Roland MT32 instrumenten te vertalen naar General MIDI "
"instrumenten. Het is mogelijk dat somige tracks niet goed klinken."
+#: engines/kyra/saveload_eob.cpp:557
+#, c-format
+msgid ""
+"The following original save game file has been found in your game path:\n"
+"\n"
+"%s %s\n"
+"\n"
+"Do you wish to use this save game file with ScummVM?\n"
+"\n"
+msgstr ""
+"Het volgende originele opgeslagen spel was gevonden in uw spel pad:\n"
+"\n"
+"%s %s\n"
+"\n"
+"Wilt u dit opgeslagen spel gebruiken in ScummVM?\n"
+"\n"
+
+#: engines/kyra/saveload_eob.cpp:590
+#, c-format
+msgid ""
+"A save game file was found in the specified slot %d. Overwrite?\n"
+"\n"
+msgstr ""
+"Er is al een opgeslagen spel in slot %d. Deze overschrijven?\n"
+"\n"
+
+#: engines/kyra/saveload_eob.cpp:623
+#, c-format
+msgid ""
+"%d original save game files have been successfully imported into\n"
+"ScummVM. If you want to manually import original save game files later you "
+"will\n"
+"need to open the ScummVM debug console and use the command "
+"'import_savefile'.\n"
+"\n"
+msgstr ""
+"%d origneel opgeslagen spellen zijn succesvol geimporteerd in ScummVM.\n"
+"Als u later handmatig origineel opgeslagen spellen wilt importeren dan zult "
+"u de\n"
+"ScummVM debug console moeten openen en het commando 'import_savefile' "
+"gebruiken.\n"
+"\n"
+
#. I18N: Option for fast scene switching
#: engines/mohawk/dialogs.cpp:92 engines/mohawk/dialogs.cpp:167
msgid "~Z~ip Mode Activated"
@@ -2378,7 +2445,7 @@ msgstr ""
#: engines/parallaction/saveload.cpp:204
msgid "Loading game..."
-msgstr "Laden spel..."
+msgstr "Spel laden..."
#: engines/parallaction/saveload.cpp:219
msgid "Saving game..."
@@ -2453,6 +2520,15 @@ msgstr "Toon/Verberg Infoscherm"
msgid "Display/Hide Pause Menu"
msgstr "Toon/Verberg Pauze-Menu"
+#: engines/queen/detection.cpp:56
+msgid "Alternative intro"
+msgstr "Alternatieve intro"
+
+#: engines/queen/detection.cpp:57
+msgid "Use an alternative game intro (CD version only)"
+msgstr ""
+"Gebruik een alternatieve versie van de intro (alleen voor de CD versie)"
+
#: engines/sci/detection.cpp:374
msgid "EGA undithering"
msgstr "EGA undithering"
@@ -2534,12 +2610,12 @@ msgstr "Spel is gepauzeerd. Druk op de spatiebalk om verder te gaan."
#. "Moechten Sie wirklich neu starten? (J/N)J"
#. Will react to J as 'Yes'
#: engines/scumm/dialogs.cpp:183
-msgid "Are you sure you want to restart? (Y/N)"
+msgid "Are you sure you want to restart? (Y/N)Y"
msgstr "Weet u zeker dat u opnieuw wilt beginnen? (J/N)J"
#. I18N: you may specify 'Yes' symbol at the end of the line. See previous comment
#: engines/scumm/dialogs.cpp:185
-msgid "Are you sure you want to quit? (Y/N)"
+msgid "Are you sure you want to quit? (Y/N)Y"
msgstr "Weet u zeker dat u wilt stoppen? (J/N)J"
#: engines/scumm/dialogs.cpp:190
@@ -3155,6 +3231,22 @@ msgstr ""
"niet. Om het te spelen, ga naar \"Spel Toevoegen\" in het ScummVM start menu "
"en selecteer de map 'Maniac' in de Tentacle map."
+#: engines/scumm/players/player_v3m.cpp:129
+msgid ""
+"Could not find the 'Loom' Macintosh executable to read the\n"
+"instruments from. Music will be disabled."
+msgstr ""
+"De 'Loom' Macintosh executable is niet gevonden om de instrumenten van te "
+"laden. Muziek wordt uitgeschakeld."
+
+#: engines/scumm/players/player_v5m.cpp:107
+msgid ""
+"Could not find the 'Monkey Island' Macintosh executable to read the\n"
+"instruments from. Music will be disabled."
+msgstr ""
+"De 'Monkey Island' Macintosh executable is niet gevonden om de instrumenten "
+"van te laden. Muziek wordt uitgeschakeld."
+
#: engines/sky/compact.cpp:130
msgid ""
"Unable to find \"sky.cpt\" file!\n"
@@ -3236,7 +3328,7 @@ msgstr "Houd de nieuwe"
#: engines/sword1/logic.cpp:1633
msgid "This is the end of the Broken Sword 1 Demo"
-msgstr "Dit is het einde van de Broken Sword 1 Demo"
+msgstr "Dit is het einde van de Broken Sword 1 demo."
#: engines/sword2/animation.cpp:425
msgid ""
@@ -3267,3 +3359,11 @@ msgid ""
msgstr ""
"Het \"teenagent.dat\" bestand is gecomprimeerd en zlib is niet meegenomen in "
"deze versie van ScummVM. Decomprimeer a.u.b. het bestand."
+
+#: engines/wintermute/detection.cpp:58
+msgid "Show FPS-counter"
+msgstr "Toon FPS-teller"
+
+#: engines/wintermute/detection.cpp:59
+msgid "Show the current number of frames per second in the upper left corner"
+msgstr "Toon de huidige Frames Per Second teller in de linkerbovenhoek"
diff --git a/po/nn_NO.po b/po/nn_NO.po
index 496b00703b..de5698e61d 100644
--- a/po/nn_NO.po
+++ b/po/nn_NO.po
@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: ScummVM 1.3.0svn\n"
"Report-Msgid-Bugs-To: scummvm-devel@lists.sf.net\n"
-"POT-Creation-Date: 2014-09-03 07:39+0200\n"
+"POT-Creation-Date: 2014-10-04 00:58+0100\n"
"PO-Revision-Date: 2014-07-11 00:04+0100\n"
"Last-Translator: Einar Johan Trјan Sјmхen <einarjohants@gmail.com>\n"
"Language-Team: somaen <einarjohants@gmail.com>\n"
@@ -110,12 +110,14 @@ msgstr "Kople"
#: engines/agos/animation.cpp:558 engines/drascula/saveload.cpp:49
#: engines/groovie/script.cpp:399 engines/parallaction/saveload.cpp:274
#: engines/scumm/dialogs.cpp:193 engines/scumm/scumm.cpp:1825
-#: engines/sky/compact.cpp:131 engines/sky/compact.cpp:141
-#: engines/sword1/animation.cpp:524 engines/sword1/animation.cpp:545
-#: engines/sword1/animation.cpp:561 engines/sword1/animation.cpp:569
-#: engines/sword1/control.cpp:865 engines/sword1/logic.cpp:1633
-#: engines/sword2/animation.cpp:425 engines/sword2/animation.cpp:445
-#: engines/sword2/animation.cpp:461 engines/sword2/animation.cpp:471
+#: engines/scumm/players/player_v3m.cpp:130
+#: engines/scumm/players/player_v5m.cpp:108 engines/sky/compact.cpp:131
+#: engines/sky/compact.cpp:141 engines/sword1/animation.cpp:524
+#: engines/sword1/animation.cpp:545 engines/sword1/animation.cpp:561
+#: engines/sword1/animation.cpp:569 engines/sword1/control.cpp:865
+#: engines/sword1/logic.cpp:1633 engines/sword2/animation.cpp:425
+#: engines/sword2/animation.cpp:445 engines/sword2/animation.cpp:461
+#: engines/sword2/animation.cpp:471
msgid "OK"
msgstr "OK"
@@ -455,7 +457,7 @@ msgstr "Sјk:"
#: gui/launcher.cpp:685 engines/dialogs.cpp:115 engines/cruise/menu.cpp:214
#: engines/mohawk/myst.cpp:245 engines/mohawk/riven.cpp:718
-#: engines/pegasus/pegasus.cpp:353
+#: engines/pegasus/pegasus.cpp:353 engines/tsage/scenes.cpp:600
msgid "Load game:"
msgstr "Хpne spel:"
@@ -464,7 +466,7 @@ msgstr "Хpne spel:"
#: backends/platform/wince/CEActionsSmartphone.cpp:231
#: engines/cruise/menu.cpp:214 engines/mohawk/myst.cpp:245
#: engines/mohawk/riven.cpp:718 engines/pegasus/pegasus.cpp:353
-#: engines/scumm/dialogs.cpp:189
+#: engines/scumm/dialogs.cpp:189 engines/tsage/scenes.cpp:600
msgid "Load"
msgstr "Хpne"
@@ -480,6 +482,7 @@ msgstr ""
#: backends/platform/wince/CEActionsPocket.cpp:326
#: backends/platform/wince/CEActionsSmartphone.cpp:287
#: backends/platform/wince/CELauncherDialog.cpp:83
+#: engines/kyra/saveload_eob.cpp:557 engines/kyra/saveload_eob.cpp:590
msgid "Yes"
msgstr "Ja"
@@ -489,6 +492,7 @@ msgstr "Ja"
#: backends/platform/wince/CEActionsPocket.cpp:326
#: backends/platform/wince/CEActionsSmartphone.cpp:287
#: backends/platform/wince/CELauncherDialog.cpp:83
+#: engines/kyra/saveload_eob.cpp:557 engines/kyra/saveload_eob.cpp:590
msgid "No"
msgstr "Nei"
@@ -1266,8 +1270,9 @@ msgstr "Tilbake til Oppsta~r~tar"
#: engines/dialogs.cpp:116 engines/agi/saveload.cpp:803
#: engines/cruise/menu.cpp:212 engines/drascula/saveload.cpp:336
-#: engines/neverhood/menumodule.cpp:873 engines/pegasus/pegasus.cpp:377
-#: engines/sci/engine/kfile.cpp:758 engines/toltecs/menu.cpp:281
+#: engines/dreamweb/saveload.cpp:261 engines/neverhood/menumodule.cpp:873
+#: engines/pegasus/pegasus.cpp:377 engines/sci/engine/kfile.cpp:758
+#: engines/toltecs/menu.cpp:281 engines/tsage/scenes.cpp:598
msgid "Save game:"
msgstr "Lagra spel:"
@@ -1277,9 +1282,10 @@ msgstr "Lagra spel:"
#: backends/platform/wince/CEActionsSmartphone.cpp:45
#: backends/platform/wince/CEActionsSmartphone.cpp:231
#: engines/agi/saveload.cpp:803 engines/cruise/menu.cpp:212
-#: engines/drascula/saveload.cpp:336 engines/neverhood/menumodule.cpp:873
-#: engines/pegasus/pegasus.cpp:377 engines/sci/engine/kfile.cpp:758
-#: engines/scumm/dialogs.cpp:188 engines/toltecs/menu.cpp:281
+#: engines/drascula/saveload.cpp:336 engines/dreamweb/saveload.cpp:261
+#: engines/neverhood/menumodule.cpp:873 engines/pegasus/pegasus.cpp:377
+#: engines/sci/engine/kfile.cpp:758 engines/scumm/dialogs.cpp:188
+#: engines/toltecs/menu.cpp:281 engines/tsage/scenes.cpp:598
msgid "Save"
msgstr "Lagre"
@@ -1298,12 +1304,12 @@ msgid ""
msgstr ""
#: engines/dialogs.cpp:307 engines/mohawk/dialogs.cpp:109
-#: engines/mohawk/dialogs.cpp:170
+#: engines/mohawk/dialogs.cpp:170 engines/tsage/dialogs.cpp:106
msgid "~O~K"
msgstr "~O~K"
#: engines/dialogs.cpp:308 engines/mohawk/dialogs.cpp:110
-#: engines/mohawk/dialogs.cpp:171
+#: engines/mohawk/dialogs.cpp:171 engines/tsage/dialogs.cpp:107
msgid "~C~ancel"
msgstr "~A~vbryt"
@@ -2068,24 +2074,26 @@ msgstr "Klikking Deaktivert"
#: engines/agi/detection.cpp:142 engines/drascula/detection.cpp:302
#: engines/dreamweb/detection.cpp:47 engines/neverhood/detection.cpp:160
#: engines/sci/detection.cpp:394 engines/toltecs/detection.cpp:200
+#: engines/zvision/detection.cpp:103
msgid "Use original save/load screens"
msgstr "Nytt opprinnelege skjermar for lagring/lasting"
#: engines/agi/detection.cpp:143 engines/drascula/detection.cpp:303
#: engines/dreamweb/detection.cpp:48 engines/neverhood/detection.cpp:161
#: engines/sci/detection.cpp:395 engines/toltecs/detection.cpp:201
+#: engines/zvision/detection.cpp:104
msgid "Use the original save/load screens, instead of the ScummVM ones"
msgstr ""
#: engines/agi/saveload.cpp:816 engines/drascula/saveload.cpp:349
-#: engines/neverhood/menumodule.cpp:886 engines/sci/engine/kfile.cpp:857
-#: engines/toltecs/menu.cpp:256
+#: engines/dreamweb/saveload.cpp:169 engines/neverhood/menumodule.cpp:886
+#: engines/sci/engine/kfile.cpp:857 engines/toltecs/menu.cpp:256
msgid "Restore game:"
msgstr "Gjenopprett spel:"
#: engines/agi/saveload.cpp:816 engines/drascula/saveload.cpp:349
-#: engines/neverhood/menumodule.cpp:886 engines/sci/engine/kfile.cpp:857
-#: engines/toltecs/menu.cpp:256
+#: engines/dreamweb/saveload.cpp:169 engines/neverhood/menumodule.cpp:886
+#: engines/sci/engine/kfile.cpp:857 engines/toltecs/menu.cpp:256
msgid "Restore"
msgstr "Gjenopprett"
@@ -2118,6 +2126,15 @@ msgstr ""
msgid "Cutscene file '%s' not found!"
msgstr ""
+#: engines/cge/detection.cpp:105 engines/cge2/detection.cpp:81
+#, fuzzy
+msgid "Color Blind Mode"
+msgstr "Klikkmodus"
+
+#: engines/cge/detection.cpp:106 engines/cge2/detection.cpp:82
+msgid "Enable Color Blind Mode by default"
+msgstr ""
+
#: engines/drascula/saveload.cpp:47
msgid ""
"ScummVM found that you have old savefiles for Drascula that should be "
@@ -2139,11 +2156,12 @@ msgid "Display graphics using the game's bright palette"
msgstr ""
#: engines/gob/inter_playtoons.cpp:256 engines/gob/inter_v2.cpp:1470
-#: engines/tinsel/saveload.cpp:532
+#: engines/gob/inter_geisha.cpp:232 engines/tinsel/saveload.cpp:532
msgid "Failed to load game state from file."
msgstr "Kunne ikkje laste lagra spel frх fil."
-#: engines/gob/inter_v2.cpp:1540 engines/tinsel/saveload.cpp:545
+#: engines/gob/inter_v2.cpp:1540 engines/gob/inter_geisha.cpp:263
+#: engines/tinsel/saveload.cpp:545
msgid "Failed to save game state to file."
msgstr "Klarte ikkje lagre speltilstand til fil."
@@ -2165,6 +2183,14 @@ msgstr "Spel filmar med auka hastighet"
msgid "Failed to save game"
msgstr "Lagra spel:"
+#: engines/hopkins/detection.cpp:76 engines/hopkins/detection.cpp:86
+msgid "Gore Mode"
+msgstr ""
+
+#: engines/hopkins/detection.cpp:77 engines/hopkins/detection.cpp:87
+msgid "Enable Gore Mode when available"
+msgstr ""
+
#. I18N: Studio audience adds an applause and cheering sounds whenever
#. Malcolm makes a joke.
#: engines/kyra/detection.cpp:62
@@ -2293,6 +2319,35 @@ msgid ""
"some tracks sound incorrect."
msgstr ""
+#: engines/kyra/saveload_eob.cpp:557
+#, c-format
+msgid ""
+"The following original save game file has been found in your game path:\n"
+"\n"
+"%s %s\n"
+"\n"
+"Do you wish to use this save game file with ScummVM?\n"
+"\n"
+msgstr ""
+
+#: engines/kyra/saveload_eob.cpp:590
+#, c-format
+msgid ""
+"A save game file was found in the specified slot %d. Overwrite?\n"
+"\n"
+msgstr ""
+
+#: engines/kyra/saveload_eob.cpp:623
+#, c-format
+msgid ""
+"%d original save game files have been successfully imported into\n"
+"ScummVM. If you want to manually import original save game files later you "
+"will\n"
+"need to open the ScummVM debug console and use the command "
+"'import_savefile'.\n"
+"\n"
+msgstr ""
+
#. I18N: Option for fast scene switching
#: engines/mohawk/dialogs.cpp:92 engines/mohawk/dialogs.cpp:167
msgid "~Z~ip Mode Activated"
@@ -2413,6 +2468,15 @@ msgstr "Skjul/Vis infoskjerm"
msgid "Display/Hide Pause Menu"
msgstr "Skjul/Vis pausemeny"
+#: engines/queen/detection.cpp:56
+msgid "Alternative intro"
+msgstr ""
+
+#: engines/queen/detection.cpp:57
+#, fuzzy
+msgid "Use an alternative game intro (CD version only)"
+msgstr "Nytt diskettversjonens хpning (Kun CD-versjon)"
+
#: engines/sci/detection.cpp:374
msgid "EGA undithering"
msgstr ""
@@ -3111,6 +3175,18 @@ msgstr ""
"det enno. For х spele Maniac Mansion, gх til 'Legg til spel' i ScummVM-"
"menyen og vel 'Maniac'-undermappa i 'Tentacle'-mappa."
+#: engines/scumm/players/player_v3m.cpp:129
+msgid ""
+"Could not find the 'Loom' Macintosh executable to read the\n"
+"instruments from. Music will be disabled."
+msgstr ""
+
+#: engines/scumm/players/player_v5m.cpp:107
+msgid ""
+"Could not find the 'Monkey Island' Macintosh executable to read the\n"
+"instruments from. Music will be disabled."
+msgstr ""
+
#: engines/sky/compact.cpp:130
msgid ""
"Unable to find \"sky.cpt\" file!\n"
@@ -3207,6 +3283,14 @@ msgid ""
"executable. Please decompress it"
msgstr ""
+#: engines/wintermute/detection.cpp:58
+msgid "Show FPS-counter"
+msgstr ""
+
+#: engines/wintermute/detection.cpp:59
+msgid "Show the current number of frames per second in the upper left corner"
+msgstr ""
+
#~ msgctxt "lowres"
#~ msgid "Mass Add..."
#~ msgstr "Legg til fleire..."
diff --git a/po/pl_PL.po b/po/pl_PL.po
index bc78909234..83df595da5 100644
--- a/po/pl_PL.po
+++ b/po/pl_PL.po
@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: ScummVM 1.3.0\n"
"Report-Msgid-Bugs-To: scummvm-devel@lists.sf.net\n"
-"POT-Creation-Date: 2014-09-03 07:39+0200\n"
+"POT-Creation-Date: 2014-10-04 00:58+0100\n"
"PO-Revision-Date: 2014-07-02 12:28+0100\n"
"Last-Translator: MichaГ ZiБbkowski <mziab@o2.pl>\n"
"Language-Team: Grajpopolsku.pl <grajpopolsku@gmail.com>\n"
@@ -111,12 +111,14 @@ msgstr "Przypisz"
#: engines/agos/animation.cpp:558 engines/drascula/saveload.cpp:49
#: engines/groovie/script.cpp:399 engines/parallaction/saveload.cpp:274
#: engines/scumm/dialogs.cpp:193 engines/scumm/scumm.cpp:1825
-#: engines/sky/compact.cpp:131 engines/sky/compact.cpp:141
-#: engines/sword1/animation.cpp:524 engines/sword1/animation.cpp:545
-#: engines/sword1/animation.cpp:561 engines/sword1/animation.cpp:569
-#: engines/sword1/control.cpp:865 engines/sword1/logic.cpp:1633
-#: engines/sword2/animation.cpp:425 engines/sword2/animation.cpp:445
-#: engines/sword2/animation.cpp:461 engines/sword2/animation.cpp:471
+#: engines/scumm/players/player_v3m.cpp:130
+#: engines/scumm/players/player_v5m.cpp:108 engines/sky/compact.cpp:131
+#: engines/sky/compact.cpp:141 engines/sword1/animation.cpp:524
+#: engines/sword1/animation.cpp:545 engines/sword1/animation.cpp:561
+#: engines/sword1/animation.cpp:569 engines/sword1/control.cpp:865
+#: engines/sword1/logic.cpp:1633 engines/sword2/animation.cpp:425
+#: engines/sword2/animation.cpp:445 engines/sword2/animation.cpp:461
+#: engines/sword2/animation.cpp:471
msgid "OK"
msgstr "OK"
@@ -453,7 +455,7 @@ msgstr "Szukaj"
#: gui/launcher.cpp:685 engines/dialogs.cpp:115 engines/cruise/menu.cpp:214
#: engines/mohawk/myst.cpp:245 engines/mohawk/riven.cpp:718
-#: engines/pegasus/pegasus.cpp:353
+#: engines/pegasus/pegasus.cpp:353 engines/tsage/scenes.cpp:600
msgid "Load game:"
msgstr "Wczytaj grъ:"
@@ -462,7 +464,7 @@ msgstr "Wczytaj grъ:"
#: backends/platform/wince/CEActionsSmartphone.cpp:231
#: engines/cruise/menu.cpp:214 engines/mohawk/myst.cpp:245
#: engines/mohawk/riven.cpp:718 engines/pegasus/pegasus.cpp:353
-#: engines/scumm/dialogs.cpp:189
+#: engines/scumm/dialogs.cpp:189 engines/tsage/scenes.cpp:600
msgid "Load"
msgstr "Wczytaj"
@@ -479,6 +481,7 @@ msgstr ""
#: backends/platform/wince/CEActionsPocket.cpp:326
#: backends/platform/wince/CEActionsSmartphone.cpp:287
#: backends/platform/wince/CELauncherDialog.cpp:83
+#: engines/kyra/saveload_eob.cpp:557 engines/kyra/saveload_eob.cpp:590
msgid "Yes"
msgstr "Tak"
@@ -488,6 +491,7 @@ msgstr "Tak"
#: backends/platform/wince/CEActionsPocket.cpp:326
#: backends/platform/wince/CEActionsSmartphone.cpp:287
#: backends/platform/wince/CELauncherDialog.cpp:83
+#: engines/kyra/saveload_eob.cpp:557 engines/kyra/saveload_eob.cpp:590
msgid "No"
msgstr "Nie"
@@ -1266,8 +1270,9 @@ msgstr "~P~owrѓt do launchera"
#: engines/dialogs.cpp:116 engines/agi/saveload.cpp:803
#: engines/cruise/menu.cpp:212 engines/drascula/saveload.cpp:336
-#: engines/neverhood/menumodule.cpp:873 engines/pegasus/pegasus.cpp:377
-#: engines/sci/engine/kfile.cpp:758 engines/toltecs/menu.cpp:281
+#: engines/dreamweb/saveload.cpp:261 engines/neverhood/menumodule.cpp:873
+#: engines/pegasus/pegasus.cpp:377 engines/sci/engine/kfile.cpp:758
+#: engines/toltecs/menu.cpp:281 engines/tsage/scenes.cpp:598
msgid "Save game:"
msgstr "Zapis:"
@@ -1277,9 +1282,10 @@ msgstr "Zapis:"
#: backends/platform/wince/CEActionsSmartphone.cpp:45
#: backends/platform/wince/CEActionsSmartphone.cpp:231
#: engines/agi/saveload.cpp:803 engines/cruise/menu.cpp:212
-#: engines/drascula/saveload.cpp:336 engines/neverhood/menumodule.cpp:873
-#: engines/pegasus/pegasus.cpp:377 engines/sci/engine/kfile.cpp:758
-#: engines/scumm/dialogs.cpp:188 engines/toltecs/menu.cpp:281
+#: engines/drascula/saveload.cpp:336 engines/dreamweb/saveload.cpp:261
+#: engines/neverhood/menumodule.cpp:873 engines/pegasus/pegasus.cpp:377
+#: engines/sci/engine/kfile.cpp:758 engines/scumm/dialogs.cpp:188
+#: engines/toltecs/menu.cpp:281 engines/tsage/scenes.cpp:598
msgid "Save"
msgstr "Zapisz"
@@ -1303,12 +1309,12 @@ msgstr ""
"dowiedzieц jak szukaц dalszej pomocy, sprawdМ plik README."
#: engines/dialogs.cpp:307 engines/mohawk/dialogs.cpp:109
-#: engines/mohawk/dialogs.cpp:170
+#: engines/mohawk/dialogs.cpp:170 engines/tsage/dialogs.cpp:106
msgid "~O~K"
msgstr "~O~K"
#: engines/dialogs.cpp:308 engines/mohawk/dialogs.cpp:110
-#: engines/mohawk/dialogs.cpp:171
+#: engines/mohawk/dialogs.cpp:171 engines/tsage/dialogs.cpp:107
msgid "~C~ancel"
msgstr "~A~nuluj"
@@ -2066,24 +2072,26 @@ msgstr "Klikanie wyГБczone"
#: engines/agi/detection.cpp:142 engines/drascula/detection.cpp:302
#: engines/dreamweb/detection.cpp:47 engines/neverhood/detection.cpp:160
#: engines/sci/detection.cpp:394 engines/toltecs/detection.cpp:200
+#: engines/zvision/detection.cpp:103
msgid "Use original save/load screens"
msgstr "UПyj oryginalnych ekranѓw odczytu/zapisu"
#: engines/agi/detection.cpp:143 engines/drascula/detection.cpp:303
#: engines/dreamweb/detection.cpp:48 engines/neverhood/detection.cpp:161
#: engines/sci/detection.cpp:395 engines/toltecs/detection.cpp:201
+#: engines/zvision/detection.cpp:104
msgid "Use the original save/load screens, instead of the ScummVM ones"
msgstr "UПyj oryginalnych ekranѓw odczytu/zapisu zamiast tych ze ScummVM"
#: engines/agi/saveload.cpp:816 engines/drascula/saveload.cpp:349
-#: engines/neverhood/menumodule.cpp:886 engines/sci/engine/kfile.cpp:857
-#: engines/toltecs/menu.cpp:256
+#: engines/dreamweb/saveload.cpp:169 engines/neverhood/menumodule.cpp:886
+#: engines/sci/engine/kfile.cpp:857 engines/toltecs/menu.cpp:256
msgid "Restore game:"
msgstr "Wznѓw grъ:"
#: engines/agi/saveload.cpp:816 engines/drascula/saveload.cpp:349
-#: engines/neverhood/menumodule.cpp:886 engines/sci/engine/kfile.cpp:857
-#: engines/toltecs/menu.cpp:256
+#: engines/dreamweb/saveload.cpp:169 engines/neverhood/menumodule.cpp:886
+#: engines/sci/engine/kfile.cpp:857 engines/toltecs/menu.cpp:256
msgid "Restore"
msgstr "Wznѓw"
@@ -2125,6 +2133,15 @@ msgstr ""
msgid "Cutscene file '%s' not found!"
msgstr "Nie znaleziono pliku przerywnika '%s'!"
+#: engines/cge/detection.cpp:105 engines/cge2/detection.cpp:81
+#, fuzzy
+msgid "Color Blind Mode"
+msgstr "Tryb klikania"
+
+#: engines/cge/detection.cpp:106 engines/cge2/detection.cpp:82
+msgid "Enable Color Blind Mode by default"
+msgstr ""
+
#: engines/drascula/saveload.cpp:47
msgid ""
"ScummVM found that you have old savefiles for Drascula that should be "
@@ -2151,11 +2168,12 @@ msgid "Display graphics using the game's bright palette"
msgstr "WyЖwietlaj grafikъ za pomocБ jasnej palety gry"
#: engines/gob/inter_playtoons.cpp:256 engines/gob/inter_v2.cpp:1470
-#: engines/tinsel/saveload.cpp:532
+#: engines/gob/inter_geisha.cpp:232 engines/tinsel/saveload.cpp:532
msgid "Failed to load game state from file."
msgstr "Nie udaГo siъ wczytaц stanu gry z pliku."
-#: engines/gob/inter_v2.cpp:1540 engines/tinsel/saveload.cpp:545
+#: engines/gob/inter_v2.cpp:1540 engines/gob/inter_geisha.cpp:263
+#: engines/tinsel/saveload.cpp:545
msgid "Failed to save game state to file."
msgstr "Nie udaГo siъ zapisaц stanu gry do pliku."
@@ -2175,6 +2193,14 @@ msgstr "Odtwarzaj filmy ze zwiъkszonБ prъdkoЖciБ"
msgid "Failed to save game"
msgstr "Nie udaГo siъ zapisaц stanu gry"
+#: engines/hopkins/detection.cpp:76 engines/hopkins/detection.cpp:86
+msgid "Gore Mode"
+msgstr ""
+
+#: engines/hopkins/detection.cpp:77 engines/hopkins/detection.cpp:87
+msgid "Enable Gore Mode when available"
+msgstr ""
+
#. I18N: Studio audience adds an applause and cheering sounds whenever
#. Malcolm makes a joke.
#: engines/kyra/detection.cpp:62
@@ -2294,6 +2320,35 @@ msgstr ""
"Prѓbujemy przypisaц instrumenty Rolanda MT32 do instrumentѓw General MIDI. "
"Niektѓre utwory mogБ byц Мle odtwarzane."
+#: engines/kyra/saveload_eob.cpp:557
+#, c-format
+msgid ""
+"The following original save game file has been found in your game path:\n"
+"\n"
+"%s %s\n"
+"\n"
+"Do you wish to use this save game file with ScummVM?\n"
+"\n"
+msgstr ""
+
+#: engines/kyra/saveload_eob.cpp:590
+#, c-format
+msgid ""
+"A save game file was found in the specified slot %d. Overwrite?\n"
+"\n"
+msgstr ""
+
+#: engines/kyra/saveload_eob.cpp:623
+#, c-format
+msgid ""
+"%d original save game files have been successfully imported into\n"
+"ScummVM. If you want to manually import original save game files later you "
+"will\n"
+"need to open the ScummVM debug console and use the command "
+"'import_savefile'.\n"
+"\n"
+msgstr ""
+
#. I18N: Option for fast scene switching
#: engines/mohawk/dialogs.cpp:92 engines/mohawk/dialogs.cpp:167
msgid "~Z~ip Mode Activated"
@@ -2421,6 +2476,14 @@ msgstr "PokaП/schowaj ekran informacji"
msgid "Display/Hide Pause Menu"
msgstr "PokaП/schowaj menu pauzy"
+#: engines/queen/detection.cpp:56
+msgid "Alternative intro"
+msgstr "Alternatywne intro"
+
+#: engines/queen/detection.cpp:57
+msgid "Use an alternative game intro (CD version only)"
+msgstr "UПyj alternatywnego intra (tylko dla wersji CD)"
+
#: engines/sci/detection.cpp:374
msgid "EGA undithering"
msgstr "Anty-dithering EGA"
@@ -3121,6 +3184,18 @@ msgstr ""
"tego nie obsГuguje. Aby zagraц, uПyj \"Dodaj grъ...\" z menu startowego "
"ScummVM i wybierz podkatalog \"Maniac\" z katalogu gry Tentacle."
+#: engines/scumm/players/player_v3m.cpp:129
+msgid ""
+"Could not find the 'Loom' Macintosh executable to read the\n"
+"instruments from. Music will be disabled."
+msgstr ""
+
+#: engines/scumm/players/player_v5m.cpp:107
+msgid ""
+"Could not find the 'Monkey Island' Macintosh executable to read the\n"
+"instruments from. Music will be disabled."
+msgstr ""
+
#: engines/sky/compact.cpp:130
msgid ""
"Unable to find \"sky.cpt\" file!\n"
@@ -3237,6 +3312,14 @@ msgstr ""
"Plik teenagent.dat jest skompresowany, a ScummVM nie zawiera obsГugi zlib. "
"Rozpakuj plik."
+#: engines/wintermute/detection.cpp:58
+msgid "Show FPS-counter"
+msgstr ""
+
+#: engines/wintermute/detection.cpp:59
+msgid "Show the current number of frames per second in the upper left corner"
+msgstr ""
+
#~ msgid "MPEG-2 cutscenes found but ScummVM has been built without MPEG-2"
#~ msgstr ""
#~ "Znaleziono przerywniki w formacie MPEG-2, ale ScummVM jest skompilowany "
@@ -3257,12 +3340,6 @@ msgstr ""
#~ msgid "Standard (16bpp)"
#~ msgstr "Standardowy (16bpp)"
-#~ msgid "Alternative intro"
-#~ msgstr "Alternatywne intro"
-
-#~ msgid "Use an alternative game intro (CD version only)"
-#~ msgstr "UПyj alternatywnego intra (tylko dla wersji CD)"
-
#~ msgid "MPEG2 cutscenes are no longer supported"
#~ msgstr "Przerywniki w formacie MPEG2 nie sБ juП obsГugiwane"
diff --git a/po/pt_BR.po b/po/pt_BR.po
index 64d7ff8933..71161bde14 100644
--- a/po/pt_BR.po
+++ b/po/pt_BR.po
@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: ScummVM 1.3.0svn\n"
"Report-Msgid-Bugs-To: scummvm-devel@lists.sf.net\n"
-"POT-Creation-Date: 2014-09-03 07:39+0200\n"
+"POT-Creation-Date: 2014-10-04 00:58+0100\n"
"PO-Revision-Date: 2011-10-21 21:30-0300\n"
"Last-Translator: Saulo Benigno <saulobenigno@gmail.com>\n"
"Language-Team: ScummBR (www.scummbr.com) <scummbr@yahoo.com.br>\n"
@@ -113,12 +113,14 @@ msgstr "Mapear"
#: engines/agos/animation.cpp:558 engines/drascula/saveload.cpp:49
#: engines/groovie/script.cpp:399 engines/parallaction/saveload.cpp:274
#: engines/scumm/dialogs.cpp:193 engines/scumm/scumm.cpp:1825
-#: engines/sky/compact.cpp:131 engines/sky/compact.cpp:141
-#: engines/sword1/animation.cpp:524 engines/sword1/animation.cpp:545
-#: engines/sword1/animation.cpp:561 engines/sword1/animation.cpp:569
-#: engines/sword1/control.cpp:865 engines/sword1/logic.cpp:1633
-#: engines/sword2/animation.cpp:425 engines/sword2/animation.cpp:445
-#: engines/sword2/animation.cpp:461 engines/sword2/animation.cpp:471
+#: engines/scumm/players/player_v3m.cpp:130
+#: engines/scumm/players/player_v5m.cpp:108 engines/sky/compact.cpp:131
+#: engines/sky/compact.cpp:141 engines/sword1/animation.cpp:524
+#: engines/sword1/animation.cpp:545 engines/sword1/animation.cpp:561
+#: engines/sword1/animation.cpp:569 engines/sword1/control.cpp:865
+#: engines/sword1/logic.cpp:1633 engines/sword2/animation.cpp:425
+#: engines/sword2/animation.cpp:445 engines/sword2/animation.cpp:461
+#: engines/sword2/animation.cpp:471
msgid "OK"
msgstr "OK"
@@ -457,7 +459,7 @@ msgstr "Pesquisar:"
#: gui/launcher.cpp:685 engines/dialogs.cpp:115 engines/cruise/menu.cpp:214
#: engines/mohawk/myst.cpp:245 engines/mohawk/riven.cpp:718
-#: engines/pegasus/pegasus.cpp:353
+#: engines/pegasus/pegasus.cpp:353 engines/tsage/scenes.cpp:600
msgid "Load game:"
msgstr "Carregar jogo:"
@@ -466,7 +468,7 @@ msgstr "Carregar jogo:"
#: backends/platform/wince/CEActionsSmartphone.cpp:231
#: engines/cruise/menu.cpp:214 engines/mohawk/myst.cpp:245
#: engines/mohawk/riven.cpp:718 engines/pegasus/pegasus.cpp:353
-#: engines/scumm/dialogs.cpp:189
+#: engines/scumm/dialogs.cpp:189 engines/tsage/scenes.cpp:600
msgid "Load"
msgstr "Carregar"
@@ -484,6 +486,7 @@ msgstr ""
#: backends/platform/wince/CEActionsPocket.cpp:326
#: backends/platform/wince/CEActionsSmartphone.cpp:287
#: backends/platform/wince/CELauncherDialog.cpp:83
+#: engines/kyra/saveload_eob.cpp:557 engines/kyra/saveload_eob.cpp:590
msgid "Yes"
msgstr "Sim"
@@ -493,6 +496,7 @@ msgstr "Sim"
#: backends/platform/wince/CEActionsPocket.cpp:326
#: backends/platform/wince/CEActionsSmartphone.cpp:287
#: backends/platform/wince/CELauncherDialog.cpp:83
+#: engines/kyra/saveload_eob.cpp:557 engines/kyra/saveload_eob.cpp:590
msgid "No"
msgstr "Nуo"
@@ -1291,8 +1295,9 @@ msgstr "~V~oltar ao menu"
#: engines/dialogs.cpp:116 engines/agi/saveload.cpp:803
#: engines/cruise/menu.cpp:212 engines/drascula/saveload.cpp:336
-#: engines/neverhood/menumodule.cpp:873 engines/pegasus/pegasus.cpp:377
-#: engines/sci/engine/kfile.cpp:758 engines/toltecs/menu.cpp:281
+#: engines/dreamweb/saveload.cpp:261 engines/neverhood/menumodule.cpp:873
+#: engines/pegasus/pegasus.cpp:377 engines/sci/engine/kfile.cpp:758
+#: engines/toltecs/menu.cpp:281 engines/tsage/scenes.cpp:598
msgid "Save game:"
msgstr "Salvar jogo:"
@@ -1302,9 +1307,10 @@ msgstr "Salvar jogo:"
#: backends/platform/wince/CEActionsSmartphone.cpp:45
#: backends/platform/wince/CEActionsSmartphone.cpp:231
#: engines/agi/saveload.cpp:803 engines/cruise/menu.cpp:212
-#: engines/drascula/saveload.cpp:336 engines/neverhood/menumodule.cpp:873
-#: engines/pegasus/pegasus.cpp:377 engines/sci/engine/kfile.cpp:758
-#: engines/scumm/dialogs.cpp:188 engines/toltecs/menu.cpp:281
+#: engines/drascula/saveload.cpp:336 engines/dreamweb/saveload.cpp:261
+#: engines/neverhood/menumodule.cpp:873 engines/pegasus/pegasus.cpp:377
+#: engines/sci/engine/kfile.cpp:758 engines/scumm/dialogs.cpp:188
+#: engines/toltecs/menu.cpp:281 engines/tsage/scenes.cpp:598
msgid "Save"
msgstr "Salvar"
@@ -1329,12 +1335,12 @@ msgstr ""
"instruчѕes sobre como obter assistъncia adicional."
#: engines/dialogs.cpp:307 engines/mohawk/dialogs.cpp:109
-#: engines/mohawk/dialogs.cpp:170
+#: engines/mohawk/dialogs.cpp:170 engines/tsage/dialogs.cpp:106
msgid "~O~K"
msgstr "~O~K"
#: engines/dialogs.cpp:308 engines/mohawk/dialogs.cpp:110
-#: engines/mohawk/dialogs.cpp:171
+#: engines/mohawk/dialogs.cpp:171 engines/tsage/dialogs.cpp:107
msgid "~C~ancel"
msgstr "~C~ancelar"
@@ -2104,24 +2110,26 @@ msgstr "Clicando Desabilitado"
#: engines/agi/detection.cpp:142 engines/drascula/detection.cpp:302
#: engines/dreamweb/detection.cpp:47 engines/neverhood/detection.cpp:160
#: engines/sci/detection.cpp:394 engines/toltecs/detection.cpp:200
+#: engines/zvision/detection.cpp:103
msgid "Use original save/load screens"
msgstr ""
#: engines/agi/detection.cpp:143 engines/drascula/detection.cpp:303
#: engines/dreamweb/detection.cpp:48 engines/neverhood/detection.cpp:161
#: engines/sci/detection.cpp:395 engines/toltecs/detection.cpp:201
+#: engines/zvision/detection.cpp:104
msgid "Use the original save/load screens, instead of the ScummVM ones"
msgstr ""
#: engines/agi/saveload.cpp:816 engines/drascula/saveload.cpp:349
-#: engines/neverhood/menumodule.cpp:886 engines/sci/engine/kfile.cpp:857
-#: engines/toltecs/menu.cpp:256
+#: engines/dreamweb/saveload.cpp:169 engines/neverhood/menumodule.cpp:886
+#: engines/sci/engine/kfile.cpp:857 engines/toltecs/menu.cpp:256
msgid "Restore game:"
msgstr "Restaurar jogo:"
#: engines/agi/saveload.cpp:816 engines/drascula/saveload.cpp:349
-#: engines/neverhood/menumodule.cpp:886 engines/sci/engine/kfile.cpp:857
-#: engines/toltecs/menu.cpp:256
+#: engines/dreamweb/saveload.cpp:169 engines/neverhood/menumodule.cpp:886
+#: engines/sci/engine/kfile.cpp:857 engines/toltecs/menu.cpp:256
msgid "Restore"
msgstr "Restaurar"
@@ -2163,6 +2171,14 @@ msgstr ""
msgid "Cutscene file '%s' not found!"
msgstr "Arquivo de vэdeo '%s' nуo encontrado!"
+#: engines/cge/detection.cpp:105 engines/cge2/detection.cpp:81
+msgid "Color Blind Mode"
+msgstr ""
+
+#: engines/cge/detection.cpp:106 engines/cge2/detection.cpp:82
+msgid "Enable Color Blind Mode by default"
+msgstr ""
+
#: engines/drascula/saveload.cpp:47
#, fuzzy
msgid ""
@@ -2192,14 +2208,15 @@ msgid "Display graphics using the game's bright palette"
msgstr ""
#: engines/gob/inter_playtoons.cpp:256 engines/gob/inter_v2.cpp:1470
-#: engines/tinsel/saveload.cpp:532
+#: engines/gob/inter_geisha.cpp:232 engines/tinsel/saveload.cpp:532
msgid "Failed to load game state from file."
msgstr ""
"Falha ao carregar o estado do jogo a partir do arquivo:\n"
"\n"
"%s"
-#: engines/gob/inter_v2.cpp:1540 engines/tinsel/saveload.cpp:545
+#: engines/gob/inter_v2.cpp:1540 engines/gob/inter_geisha.cpp:263
+#: engines/tinsel/saveload.cpp:545
msgid "Failed to save game state to file."
msgstr ""
"Falha ao salvar o estado do jogo para o arquivo:\n"
@@ -2223,6 +2240,14 @@ msgstr ""
msgid "Failed to save game"
msgstr "Falha ao salvar o jogo"
+#: engines/hopkins/detection.cpp:76 engines/hopkins/detection.cpp:86
+msgid "Gore Mode"
+msgstr ""
+
+#: engines/hopkins/detection.cpp:77 engines/hopkins/detection.cpp:87
+msgid "Enable Gore Mode when available"
+msgstr ""
+
#. I18N: Studio audience adds an applause and cheering sounds whenever
#. Malcolm makes a joke.
#: engines/kyra/detection.cpp:62
@@ -2352,6 +2377,35 @@ msgstr ""
"o modelo General MIDI. Talvez possa acontecer\n"
"que algumas faixas nуo sejam corretamente tocadas."
+#: engines/kyra/saveload_eob.cpp:557
+#, c-format
+msgid ""
+"The following original save game file has been found in your game path:\n"
+"\n"
+"%s %s\n"
+"\n"
+"Do you wish to use this save game file with ScummVM?\n"
+"\n"
+msgstr ""
+
+#: engines/kyra/saveload_eob.cpp:590
+#, c-format
+msgid ""
+"A save game file was found in the specified slot %d. Overwrite?\n"
+"\n"
+msgstr ""
+
+#: engines/kyra/saveload_eob.cpp:623
+#, c-format
+msgid ""
+"%d original save game files have been successfully imported into\n"
+"ScummVM. If you want to manually import original save game files later you "
+"will\n"
+"need to open the ScummVM debug console and use the command "
+"'import_savefile'.\n"
+"\n"
+msgstr ""
+
#. I18N: Option for fast scene switching
#: engines/mohawk/dialogs.cpp:92 engines/mohawk/dialogs.cpp:167
msgid "~Z~ip Mode Activated"
@@ -2481,6 +2535,14 @@ msgstr ""
msgid "Display/Hide Pause Menu"
msgstr ""
+#: engines/queen/detection.cpp:56
+msgid "Alternative intro"
+msgstr ""
+
+#: engines/queen/detection.cpp:57
+msgid "Use an alternative game intro (CD version only)"
+msgstr ""
+
#: engines/sci/detection.cpp:374
msgid "EGA undithering"
msgstr "EGA sem dithering"
@@ -3182,6 +3244,18 @@ msgstr ""
"adicione o jogo normalmente no ScummVM. Ele se encontra em um diretѓrio "
"dentro da pasta do jogo Day of the Tentacle."
+#: engines/scumm/players/player_v3m.cpp:129
+msgid ""
+"Could not find the 'Loom' Macintosh executable to read the\n"
+"instruments from. Music will be disabled."
+msgstr ""
+
+#: engines/scumm/players/player_v5m.cpp:107
+msgid ""
+"Could not find the 'Monkey Island' Macintosh executable to read the\n"
+"instruments from. Music will be disabled."
+msgstr ""
+
#: engines/sky/compact.cpp:130
msgid ""
"Unable to find \"sky.cpt\" file!\n"
@@ -3296,6 +3370,14 @@ msgid ""
"executable. Please decompress it"
msgstr ""
+#: engines/wintermute/detection.cpp:58
+msgid "Show FPS-counter"
+msgstr ""
+
+#: engines/wintermute/detection.cpp:59
+msgid "Show the current number of frames per second in the upper left corner"
+msgstr ""
+
#, fuzzy
#~ msgid "MPEG-2 cutscenes found but ScummVM has been built without MPEG-2"
#~ msgstr ""
diff --git a/po/ru_RU.po b/po/ru_RU.po
index 5c5690a746..89ee15e7ce 100644
--- a/po/ru_RU.po
+++ b/po/ru_RU.po
@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: ScummVM 1.3.0svn\n"
"Report-Msgid-Bugs-To: scummvm-devel@lists.sf.net\n"
-"POT-Creation-Date: 2014-09-03 07:39+0200\n"
+"POT-Creation-Date: 2014-10-04 00:58+0100\n"
"PO-Revision-Date: 2014-07-02 17:20+0300\n"
"Last-Translator: Eugene Sandulenko <sev@scummvm.org>\n"
"Language-Team: Russian\n"
@@ -110,12 +110,14 @@ msgstr "Назначить"
#: engines/agos/animation.cpp:558 engines/drascula/saveload.cpp:49
#: engines/groovie/script.cpp:399 engines/parallaction/saveload.cpp:274
#: engines/scumm/dialogs.cpp:193 engines/scumm/scumm.cpp:1825
-#: engines/sky/compact.cpp:131 engines/sky/compact.cpp:141
-#: engines/sword1/animation.cpp:524 engines/sword1/animation.cpp:545
-#: engines/sword1/animation.cpp:561 engines/sword1/animation.cpp:569
-#: engines/sword1/control.cpp:865 engines/sword1/logic.cpp:1633
-#: engines/sword2/animation.cpp:425 engines/sword2/animation.cpp:445
-#: engines/sword2/animation.cpp:461 engines/sword2/animation.cpp:471
+#: engines/scumm/players/player_v3m.cpp:130
+#: engines/scumm/players/player_v5m.cpp:108 engines/sky/compact.cpp:131
+#: engines/sky/compact.cpp:141 engines/sword1/animation.cpp:524
+#: engines/sword1/animation.cpp:545 engines/sword1/animation.cpp:561
+#: engines/sword1/animation.cpp:569 engines/sword1/control.cpp:865
+#: engines/sword1/logic.cpp:1633 engines/sword2/animation.cpp:425
+#: engines/sword2/animation.cpp:445 engines/sword2/animation.cpp:461
+#: engines/sword2/animation.cpp:471
msgid "OK"
msgstr "OK"
@@ -453,7 +455,7 @@ msgstr "Поиск:"
#: gui/launcher.cpp:685 engines/dialogs.cpp:115 engines/cruise/menu.cpp:214
#: engines/mohawk/myst.cpp:245 engines/mohawk/riven.cpp:718
-#: engines/pegasus/pegasus.cpp:353
+#: engines/pegasus/pegasus.cpp:353 engines/tsage/scenes.cpp:600
msgid "Load game:"
msgstr "Загрузить игру:"
@@ -462,7 +464,7 @@ msgstr "Загрузить игру:"
#: backends/platform/wince/CEActionsSmartphone.cpp:231
#: engines/cruise/menu.cpp:214 engines/mohawk/myst.cpp:245
#: engines/mohawk/riven.cpp:718 engines/pegasus/pegasus.cpp:353
-#: engines/scumm/dialogs.cpp:189
+#: engines/scumm/dialogs.cpp:189 engines/tsage/scenes.cpp:600
msgid "Load"
msgstr "Загрузить"
@@ -480,6 +482,7 @@ msgstr ""
#: backends/platform/wince/CEActionsPocket.cpp:326
#: backends/platform/wince/CEActionsSmartphone.cpp:287
#: backends/platform/wince/CELauncherDialog.cpp:83
+#: engines/kyra/saveload_eob.cpp:557 engines/kyra/saveload_eob.cpp:590
msgid "Yes"
msgstr "Да"
@@ -489,6 +492,7 @@ msgstr "Да"
#: backends/platform/wince/CEActionsPocket.cpp:326
#: backends/platform/wince/CEActionsSmartphone.cpp:287
#: backends/platform/wince/CELauncherDialog.cpp:83
+#: engines/kyra/saveload_eob.cpp:557 engines/kyra/saveload_eob.cpp:590
msgid "No"
msgstr "Нет"
@@ -1273,8 +1277,9 @@ msgstr "~В~ главное меню"
#: engines/dialogs.cpp:116 engines/agi/saveload.cpp:803
#: engines/cruise/menu.cpp:212 engines/drascula/saveload.cpp:336
-#: engines/neverhood/menumodule.cpp:873 engines/pegasus/pegasus.cpp:377
-#: engines/sci/engine/kfile.cpp:758 engines/toltecs/menu.cpp:281
+#: engines/dreamweb/saveload.cpp:261 engines/neverhood/menumodule.cpp:873
+#: engines/pegasus/pegasus.cpp:377 engines/sci/engine/kfile.cpp:758
+#: engines/toltecs/menu.cpp:281 engines/tsage/scenes.cpp:598
msgid "Save game:"
msgstr "Сохранить игру:"
@@ -1284,9 +1289,10 @@ msgstr "Сохранить игру:"
#: backends/platform/wince/CEActionsSmartphone.cpp:45
#: backends/platform/wince/CEActionsSmartphone.cpp:231
#: engines/agi/saveload.cpp:803 engines/cruise/menu.cpp:212
-#: engines/drascula/saveload.cpp:336 engines/neverhood/menumodule.cpp:873
-#: engines/pegasus/pegasus.cpp:377 engines/sci/engine/kfile.cpp:758
-#: engines/scumm/dialogs.cpp:188 engines/toltecs/menu.cpp:281
+#: engines/drascula/saveload.cpp:336 engines/dreamweb/saveload.cpp:261
+#: engines/neverhood/menumodule.cpp:873 engines/pegasus/pegasus.cpp:377
+#: engines/sci/engine/kfile.cpp:758 engines/scumm/dialogs.cpp:188
+#: engines/toltecs/menu.cpp:281 engines/tsage/scenes.cpp:598
msgid "Save"
msgstr "Сохранить"
@@ -1311,12 +1317,12 @@ msgstr ""
"помощь."
#: engines/dialogs.cpp:307 engines/mohawk/dialogs.cpp:109
-#: engines/mohawk/dialogs.cpp:170
+#: engines/mohawk/dialogs.cpp:170 engines/tsage/dialogs.cpp:106
msgid "~O~K"
msgstr "~O~K"
#: engines/dialogs.cpp:308 engines/mohawk/dialogs.cpp:110
-#: engines/mohawk/dialogs.cpp:171
+#: engines/mohawk/dialogs.cpp:171 engines/tsage/dialogs.cpp:107
msgid "~C~ancel"
msgstr "О~т~мена"
@@ -2080,26 +2086,28 @@ msgstr "Щелчки выключены"
#: engines/agi/detection.cpp:142 engines/drascula/detection.cpp:302
#: engines/dreamweb/detection.cpp:47 engines/neverhood/detection.cpp:160
#: engines/sci/detection.cpp:394 engines/toltecs/detection.cpp:200
+#: engines/zvision/detection.cpp:103
msgid "Use original save/load screens"
msgstr "Использовать оригинальные экраны записи/чтения игры"
#: engines/agi/detection.cpp:143 engines/drascula/detection.cpp:303
#: engines/dreamweb/detection.cpp:48 engines/neverhood/detection.cpp:161
#: engines/sci/detection.cpp:395 engines/toltecs/detection.cpp:201
+#: engines/zvision/detection.cpp:104
msgid "Use the original save/load screens, instead of the ScummVM ones"
msgstr ""
"Использовать оригинальные экраны записи и сохранения игры вместо сделанных в "
"ScummVM"
#: engines/agi/saveload.cpp:816 engines/drascula/saveload.cpp:349
-#: engines/neverhood/menumodule.cpp:886 engines/sci/engine/kfile.cpp:857
-#: engines/toltecs/menu.cpp:256
+#: engines/dreamweb/saveload.cpp:169 engines/neverhood/menumodule.cpp:886
+#: engines/sci/engine/kfile.cpp:857 engines/toltecs/menu.cpp:256
msgid "Restore game:"
msgstr "Восстановить игру:"
#: engines/agi/saveload.cpp:816 engines/drascula/saveload.cpp:349
-#: engines/neverhood/menumodule.cpp:886 engines/sci/engine/kfile.cpp:857
-#: engines/toltecs/menu.cpp:256
+#: engines/dreamweb/saveload.cpp:169 engines/neverhood/menumodule.cpp:886
+#: engines/sci/engine/kfile.cpp:857 engines/toltecs/menu.cpp:256
msgid "Restore"
msgstr "Восстановить"
@@ -2141,6 +2149,15 @@ msgstr ""
msgid "Cutscene file '%s' not found!"
msgstr "Файл заставки '%s' не найден!"
+#: engines/cge/detection.cpp:105 engines/cge2/detection.cpp:81
+#, fuzzy
+msgid "Color Blind Mode"
+msgstr "Режим щелчка"
+
+#: engines/cge/detection.cpp:106 engines/cge2/detection.cpp:82
+msgid "Enable Color Blind Mode by default"
+msgstr ""
+
#: engines/drascula/saveload.cpp:47
msgid ""
"ScummVM found that you have old savefiles for Drascula that should be "
@@ -2168,11 +2185,12 @@ msgid "Display graphics using the game's bright palette"
msgstr "Рисует графику с использованием яркой палитры игры"
#: engines/gob/inter_playtoons.cpp:256 engines/gob/inter_v2.cpp:1470
-#: engines/tinsel/saveload.cpp:532
+#: engines/gob/inter_geisha.cpp:232 engines/tinsel/saveload.cpp:532
msgid "Failed to load game state from file."
msgstr "Не удалось загрузить сохранённую игру из файла."
-#: engines/gob/inter_v2.cpp:1540 engines/tinsel/saveload.cpp:545
+#: engines/gob/inter_v2.cpp:1540 engines/gob/inter_geisha.cpp:263
+#: engines/tinsel/saveload.cpp:545
msgid "Failed to save game state to file."
msgstr "Не удалось сохранить игру в файл."
@@ -2192,6 +2210,14 @@ msgstr "Воспроизводит видеоролики с увеличенной скоростью"
msgid "Failed to save game"
msgstr "Не удалось сохранить игру"
+#: engines/hopkins/detection.cpp:76 engines/hopkins/detection.cpp:86
+msgid "Gore Mode"
+msgstr ""
+
+#: engines/hopkins/detection.cpp:77 engines/hopkins/detection.cpp:87
+msgid "Enable Gore Mode when available"
+msgstr ""
+
#. I18N: Studio audience adds an applause and cheering sounds whenever
#. Malcolm makes a joke.
#: engines/kyra/detection.cpp:62
@@ -2313,6 +2339,35 @@ msgstr ""
"может так получиться, что некоторые треки будут\n"
"сыграны неверно."
+#: engines/kyra/saveload_eob.cpp:557
+#, c-format
+msgid ""
+"The following original save game file has been found in your game path:\n"
+"\n"
+"%s %s\n"
+"\n"
+"Do you wish to use this save game file with ScummVM?\n"
+"\n"
+msgstr ""
+
+#: engines/kyra/saveload_eob.cpp:590
+#, c-format
+msgid ""
+"A save game file was found in the specified slot %d. Overwrite?\n"
+"\n"
+msgstr ""
+
+#: engines/kyra/saveload_eob.cpp:623
+#, c-format
+msgid ""
+"%d original save game files have been successfully imported into\n"
+"ScummVM. If you want to manually import original save game files later you "
+"will\n"
+"need to open the ScummVM debug console and use the command "
+"'import_savefile'.\n"
+"\n"
+msgstr ""
+
#. I18N: Option for fast scene switching
#: engines/mohawk/dialogs.cpp:92 engines/mohawk/dialogs.cpp:167
msgid "~Z~ip Mode Activated"
@@ -2440,6 +2495,14 @@ msgstr "Показать/Спрятать инфоэкран"
msgid "Display/Hide Pause Menu"
msgstr "Показать/Спрятать меню паузы"
+#: engines/queen/detection.cpp:56
+msgid "Alternative intro"
+msgstr "Альтернативное вступление"
+
+#: engines/queen/detection.cpp:57
+msgid "Use an alternative game intro (CD version only)"
+msgstr "Использовать альтернативное вступление (только для CD версии игры)"
+
#: engines/sci/detection.cpp:374
msgid "EGA undithering"
msgstr "EGA без растра"
@@ -3144,6 +3207,18 @@ msgstr ""
"умеет. Чтобы сыграть, нажмите 'Новая игра' в стартовом меню ScummVM, а затем "
"выберите директорию Maniac внутри директории с игрой Tentacle."
+#: engines/scumm/players/player_v3m.cpp:129
+msgid ""
+"Could not find the 'Loom' Macintosh executable to read the\n"
+"instruments from. Music will be disabled."
+msgstr ""
+
+#: engines/scumm/players/player_v5m.cpp:107
+msgid ""
+"Could not find the 'Monkey Island' Macintosh executable to read the\n"
+"instruments from. Music will be disabled."
+msgstr ""
+
#: engines/sky/compact.cpp:130
msgid ""
"Unable to find \"sky.cpt\" file!\n"
@@ -3256,6 +3331,14 @@ msgstr ""
"Файл teenagent.dat сжат, но zlib не включено в эту программу. Пожалуйста, "
"распакуйте его"
+#: engines/wintermute/detection.cpp:58
+msgid "Show FPS-counter"
+msgstr ""
+
+#: engines/wintermute/detection.cpp:59
+msgid "Show the current number of frames per second in the upper left corner"
+msgstr ""
+
#~ msgid "MPEG-2 cutscenes found but ScummVM has been built without MPEG-2"
#~ msgstr ""
#~ "Найдены заставки в формате MPEG-2, но ScummVM был собран без поддержки "
@@ -3277,12 +3360,6 @@ msgstr ""
#~ msgid "Standard (16bpp)"
#~ msgstr "Стандартный растеризатор (16bpp)"
-#~ msgid "Alternative intro"
-#~ msgstr "Альтернативное вступление"
-
-#~ msgid "Use an alternative game intro (CD version only)"
-#~ msgstr "Использовать альтернативное вступление (только для CD версии игры)"
-
#~ msgid "MPEG2 cutscenes are no longer supported"
#~ msgstr "Заставки в формате MPEG2 больше не поддерживаются"
diff --git a/po/scummvm.pot b/po/scummvm.pot
index 073ddeb029..72600ff994 100644
--- a/po/scummvm.pot
+++ b/po/scummvm.pot
@@ -8,10 +8,11 @@ msgid ""
msgstr ""
"Project-Id-Version: ScummVM 1.8.0git\n"
"Report-Msgid-Bugs-To: scummvm-devel@lists.sf.net\n"
-"POT-Creation-Date: 2014-09-03 07:39+0200\n"
+"POT-Creation-Date: 2014-10-04 00:58+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
+"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n"
@@ -107,12 +108,14 @@ msgstr ""
#: engines/agos/animation.cpp:558 engines/drascula/saveload.cpp:49
#: engines/groovie/script.cpp:399 engines/parallaction/saveload.cpp:274
#: engines/scumm/dialogs.cpp:193 engines/scumm/scumm.cpp:1825
-#: engines/sky/compact.cpp:131 engines/sky/compact.cpp:141
-#: engines/sword1/animation.cpp:524 engines/sword1/animation.cpp:545
-#: engines/sword1/animation.cpp:561 engines/sword1/animation.cpp:569
-#: engines/sword1/control.cpp:865 engines/sword1/logic.cpp:1633
-#: engines/sword2/animation.cpp:425 engines/sword2/animation.cpp:445
-#: engines/sword2/animation.cpp:461 engines/sword2/animation.cpp:471
+#: engines/scumm/players/player_v3m.cpp:130
+#: engines/scumm/players/player_v5m.cpp:108 engines/sky/compact.cpp:131
+#: engines/sky/compact.cpp:141 engines/sword1/animation.cpp:524
+#: engines/sword1/animation.cpp:545 engines/sword1/animation.cpp:561
+#: engines/sword1/animation.cpp:569 engines/sword1/control.cpp:865
+#: engines/sword1/logic.cpp:1633 engines/sword2/animation.cpp:425
+#: engines/sword2/animation.cpp:445 engines/sword2/animation.cpp:461
+#: engines/sword2/animation.cpp:471
msgid "OK"
msgstr ""
@@ -447,7 +450,7 @@ msgstr ""
#: gui/launcher.cpp:685 engines/dialogs.cpp:115 engines/cruise/menu.cpp:214
#: engines/mohawk/myst.cpp:245 engines/mohawk/riven.cpp:718
-#: engines/pegasus/pegasus.cpp:353
+#: engines/pegasus/pegasus.cpp:353 engines/tsage/scenes.cpp:600
msgid "Load game:"
msgstr ""
@@ -456,7 +459,7 @@ msgstr ""
#: backends/platform/wince/CEActionsSmartphone.cpp:231
#: engines/cruise/menu.cpp:214 engines/mohawk/myst.cpp:245
#: engines/mohawk/riven.cpp:718 engines/pegasus/pegasus.cpp:353
-#: engines/scumm/dialogs.cpp:189
+#: engines/scumm/dialogs.cpp:189 engines/tsage/scenes.cpp:600
msgid "Load"
msgstr ""
@@ -472,6 +475,7 @@ msgstr ""
#: backends/platform/wince/CEActionsPocket.cpp:326
#: backends/platform/wince/CEActionsSmartphone.cpp:287
#: backends/platform/wince/CELauncherDialog.cpp:83
+#: engines/kyra/saveload_eob.cpp:557 engines/kyra/saveload_eob.cpp:590
msgid "Yes"
msgstr ""
@@ -481,6 +485,7 @@ msgstr ""
#: backends/platform/wince/CEActionsPocket.cpp:326
#: backends/platform/wince/CEActionsSmartphone.cpp:287
#: backends/platform/wince/CELauncherDialog.cpp:83
+#: engines/kyra/saveload_eob.cpp:557 engines/kyra/saveload_eob.cpp:590
msgid "No"
msgstr ""
@@ -1247,8 +1252,9 @@ msgstr ""
#: engines/dialogs.cpp:116 engines/agi/saveload.cpp:803
#: engines/cruise/menu.cpp:212 engines/drascula/saveload.cpp:336
-#: engines/neverhood/menumodule.cpp:873 engines/pegasus/pegasus.cpp:377
-#: engines/sci/engine/kfile.cpp:758 engines/toltecs/menu.cpp:281
+#: engines/dreamweb/saveload.cpp:261 engines/neverhood/menumodule.cpp:873
+#: engines/pegasus/pegasus.cpp:377 engines/sci/engine/kfile.cpp:758
+#: engines/toltecs/menu.cpp:281 engines/tsage/scenes.cpp:598
msgid "Save game:"
msgstr ""
@@ -1258,9 +1264,10 @@ msgstr ""
#: backends/platform/wince/CEActionsSmartphone.cpp:45
#: backends/platform/wince/CEActionsSmartphone.cpp:231
#: engines/agi/saveload.cpp:803 engines/cruise/menu.cpp:212
-#: engines/drascula/saveload.cpp:336 engines/neverhood/menumodule.cpp:873
-#: engines/pegasus/pegasus.cpp:377 engines/sci/engine/kfile.cpp:758
-#: engines/scumm/dialogs.cpp:188 engines/toltecs/menu.cpp:281
+#: engines/drascula/saveload.cpp:336 engines/dreamweb/saveload.cpp:261
+#: engines/neverhood/menumodule.cpp:873 engines/pegasus/pegasus.cpp:377
+#: engines/sci/engine/kfile.cpp:758 engines/scumm/dialogs.cpp:188
+#: engines/toltecs/menu.cpp:281 engines/tsage/scenes.cpp:598
msgid "Save"
msgstr ""
@@ -1279,12 +1286,12 @@ msgid ""
msgstr ""
#: engines/dialogs.cpp:307 engines/mohawk/dialogs.cpp:109
-#: engines/mohawk/dialogs.cpp:170
+#: engines/mohawk/dialogs.cpp:170 engines/tsage/dialogs.cpp:106
msgid "~O~K"
msgstr ""
#: engines/dialogs.cpp:308 engines/mohawk/dialogs.cpp:110
-#: engines/mohawk/dialogs.cpp:171
+#: engines/mohawk/dialogs.cpp:171 engines/tsage/dialogs.cpp:107
msgid "~C~ancel"
msgstr ""
@@ -2021,24 +2028,26 @@ msgstr ""
#: engines/agi/detection.cpp:142 engines/drascula/detection.cpp:302
#: engines/dreamweb/detection.cpp:47 engines/neverhood/detection.cpp:160
#: engines/sci/detection.cpp:394 engines/toltecs/detection.cpp:200
+#: engines/zvision/detection.cpp:103
msgid "Use original save/load screens"
msgstr ""
#: engines/agi/detection.cpp:143 engines/drascula/detection.cpp:303
#: engines/dreamweb/detection.cpp:48 engines/neverhood/detection.cpp:161
#: engines/sci/detection.cpp:395 engines/toltecs/detection.cpp:201
+#: engines/zvision/detection.cpp:104
msgid "Use the original save/load screens, instead of the ScummVM ones"
msgstr ""
#: engines/agi/saveload.cpp:816 engines/drascula/saveload.cpp:349
-#: engines/neverhood/menumodule.cpp:886 engines/sci/engine/kfile.cpp:857
-#: engines/toltecs/menu.cpp:256
+#: engines/dreamweb/saveload.cpp:169 engines/neverhood/menumodule.cpp:886
+#: engines/sci/engine/kfile.cpp:857 engines/toltecs/menu.cpp:256
msgid "Restore game:"
msgstr ""
#: engines/agi/saveload.cpp:816 engines/drascula/saveload.cpp:349
-#: engines/neverhood/menumodule.cpp:886 engines/sci/engine/kfile.cpp:857
-#: engines/toltecs/menu.cpp:256
+#: engines/dreamweb/saveload.cpp:169 engines/neverhood/menumodule.cpp:886
+#: engines/sci/engine/kfile.cpp:857 engines/toltecs/menu.cpp:256
msgid "Restore"
msgstr ""
@@ -2071,6 +2080,14 @@ msgstr ""
msgid "Cutscene file '%s' not found!"
msgstr ""
+#: engines/cge/detection.cpp:105 engines/cge2/detection.cpp:81
+msgid "Color Blind Mode"
+msgstr ""
+
+#: engines/cge/detection.cpp:106 engines/cge2/detection.cpp:82
+msgid "Enable Color Blind Mode by default"
+msgstr ""
+
#: engines/drascula/saveload.cpp:47
msgid ""
"ScummVM found that you have old savefiles for Drascula that should be "
@@ -2091,11 +2108,12 @@ msgid "Display graphics using the game's bright palette"
msgstr ""
#: engines/gob/inter_playtoons.cpp:256 engines/gob/inter_v2.cpp:1470
-#: engines/tinsel/saveload.cpp:532
+#: engines/gob/inter_geisha.cpp:232 engines/tinsel/saveload.cpp:532
msgid "Failed to load game state from file."
msgstr ""
-#: engines/gob/inter_v2.cpp:1540 engines/tinsel/saveload.cpp:545
+#: engines/gob/inter_v2.cpp:1540 engines/gob/inter_geisha.cpp:263
+#: engines/tinsel/saveload.cpp:545
msgid "Failed to save game state to file."
msgstr ""
@@ -2115,6 +2133,14 @@ msgstr ""
msgid "Failed to save game"
msgstr ""
+#: engines/hopkins/detection.cpp:76 engines/hopkins/detection.cpp:86
+msgid "Gore Mode"
+msgstr ""
+
+#: engines/hopkins/detection.cpp:77 engines/hopkins/detection.cpp:87
+msgid "Enable Gore Mode when available"
+msgstr ""
+
#. I18N: Studio audience adds an applause and cheering sounds whenever
#. Malcolm makes a joke.
#: engines/kyra/detection.cpp:62
@@ -2230,6 +2256,35 @@ msgid ""
"some tracks sound incorrect."
msgstr ""
+#: engines/kyra/saveload_eob.cpp:557
+#, c-format
+msgid ""
+"The following original save game file has been found in your game path:\n"
+"\n"
+"%s %s\n"
+"\n"
+"Do you wish to use this save game file with ScummVM?\n"
+"\n"
+msgstr ""
+
+#: engines/kyra/saveload_eob.cpp:590
+#, c-format
+msgid ""
+"A save game file was found in the specified slot %d. Overwrite?\n"
+"\n"
+msgstr ""
+
+#: engines/kyra/saveload_eob.cpp:623
+#, c-format
+msgid ""
+"%d original save game files have been successfully imported into\n"
+"ScummVM. If you want to manually import original save game files later you "
+"will\n"
+"need to open the ScummVM debug console and use the command "
+"'import_savefile'.\n"
+"\n"
+msgstr ""
+
#. I18N: Option for fast scene switching
#: engines/mohawk/dialogs.cpp:92 engines/mohawk/dialogs.cpp:167
msgid "~Z~ip Mode Activated"
@@ -2345,6 +2400,14 @@ msgstr ""
msgid "Display/Hide Pause Menu"
msgstr ""
+#: engines/queen/detection.cpp:56
+msgid "Alternative intro"
+msgstr ""
+
+#: engines/queen/detection.cpp:57
+msgid "Use an alternative game intro (CD version only)"
+msgstr ""
+
#: engines/sci/detection.cpp:374
msgid "EGA undithering"
msgstr ""
@@ -3036,6 +3099,18 @@ msgid ""
"directory inside the Tentacle game directory."
msgstr ""
+#: engines/scumm/players/player_v3m.cpp:129
+msgid ""
+"Could not find the 'Loom' Macintosh executable to read the\n"
+"instruments from. Music will be disabled."
+msgstr ""
+
+#: engines/scumm/players/player_v5m.cpp:107
+msgid ""
+"Could not find the 'Monkey Island' Macintosh executable to read the\n"
+"instruments from. Music will be disabled."
+msgstr ""
+
#: engines/sky/compact.cpp:130
msgid ""
"Unable to find \"sky.cpt\" file!\n"
@@ -3128,3 +3203,11 @@ msgid ""
"The teenagent.dat file is compressed and zlib hasn't been included in this "
"executable. Please decompress it"
msgstr ""
+
+#: engines/wintermute/detection.cpp:58
+msgid "Show FPS-counter"
+msgstr ""
+
+#: engines/wintermute/detection.cpp:59
+msgid "Show the current number of frames per second in the upper left corner"
+msgstr ""
diff --git a/po/se_SE.po b/po/se_SE.po
index b2da26bc8a..d08f6962c9 100644
--- a/po/se_SE.po
+++ b/po/se_SE.po
@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: ScummVM 1.5.0svn\n"
"Report-Msgid-Bugs-To: scummvm-devel@lists.sf.net\n"
-"POT-Creation-Date: 2014-09-03 07:39+0200\n"
+"POT-Creation-Date: 2014-10-04 00:58+0100\n"
"PO-Revision-Date: 2014-07-02 16:30+0100\n"
"Last-Translator: Hampus Flink <hampus.flink@gmail.com>\n"
"Language-Team: \n"
@@ -110,12 +110,14 @@ msgstr "Stфll in"
#: engines/agos/animation.cpp:558 engines/drascula/saveload.cpp:49
#: engines/groovie/script.cpp:399 engines/parallaction/saveload.cpp:274
#: engines/scumm/dialogs.cpp:193 engines/scumm/scumm.cpp:1825
-#: engines/sky/compact.cpp:131 engines/sky/compact.cpp:141
-#: engines/sword1/animation.cpp:524 engines/sword1/animation.cpp:545
-#: engines/sword1/animation.cpp:561 engines/sword1/animation.cpp:569
-#: engines/sword1/control.cpp:865 engines/sword1/logic.cpp:1633
-#: engines/sword2/animation.cpp:425 engines/sword2/animation.cpp:445
-#: engines/sword2/animation.cpp:461 engines/sword2/animation.cpp:471
+#: engines/scumm/players/player_v3m.cpp:130
+#: engines/scumm/players/player_v5m.cpp:108 engines/sky/compact.cpp:131
+#: engines/sky/compact.cpp:141 engines/sword1/animation.cpp:524
+#: engines/sword1/animation.cpp:545 engines/sword1/animation.cpp:561
+#: engines/sword1/animation.cpp:569 engines/sword1/control.cpp:865
+#: engines/sword1/logic.cpp:1633 engines/sword2/animation.cpp:425
+#: engines/sword2/animation.cpp:445 engines/sword2/animation.cpp:461
+#: engines/sword2/animation.cpp:471
msgid "OK"
msgstr "OK"
@@ -454,7 +456,7 @@ msgstr "Sіk:"
#: gui/launcher.cpp:685 engines/dialogs.cpp:115 engines/cruise/menu.cpp:214
#: engines/mohawk/myst.cpp:245 engines/mohawk/riven.cpp:718
-#: engines/pegasus/pegasus.cpp:353
+#: engines/pegasus/pegasus.cpp:353 engines/tsage/scenes.cpp:600
msgid "Load game:"
msgstr "Ladda spel:"
@@ -463,7 +465,7 @@ msgstr "Ladda spel:"
#: backends/platform/wince/CEActionsSmartphone.cpp:231
#: engines/cruise/menu.cpp:214 engines/mohawk/myst.cpp:245
#: engines/mohawk/riven.cpp:718 engines/pegasus/pegasus.cpp:353
-#: engines/scumm/dialogs.cpp:189
+#: engines/scumm/dialogs.cpp:189 engines/tsage/scenes.cpp:600
msgid "Load"
msgstr "Ladda"
@@ -481,6 +483,7 @@ msgstr ""
#: backends/platform/wince/CEActionsPocket.cpp:326
#: backends/platform/wince/CEActionsSmartphone.cpp:287
#: backends/platform/wince/CELauncherDialog.cpp:83
+#: engines/kyra/saveload_eob.cpp:557 engines/kyra/saveload_eob.cpp:590
msgid "Yes"
msgstr "Ja"
@@ -490,6 +493,7 @@ msgstr "Ja"
#: backends/platform/wince/CEActionsPocket.cpp:326
#: backends/platform/wince/CEActionsSmartphone.cpp:287
#: backends/platform/wince/CELauncherDialog.cpp:83
+#: engines/kyra/saveload_eob.cpp:557 engines/kyra/saveload_eob.cpp:590
msgid "No"
msgstr "Nej"
@@ -1272,8 +1276,9 @@ msgstr "Хte~r~vфnd till launcher"
#: engines/dialogs.cpp:116 engines/agi/saveload.cpp:803
#: engines/cruise/menu.cpp:212 engines/drascula/saveload.cpp:336
-#: engines/neverhood/menumodule.cpp:873 engines/pegasus/pegasus.cpp:377
-#: engines/sci/engine/kfile.cpp:758 engines/toltecs/menu.cpp:281
+#: engines/dreamweb/saveload.cpp:261 engines/neverhood/menumodule.cpp:873
+#: engines/pegasus/pegasus.cpp:377 engines/sci/engine/kfile.cpp:758
+#: engines/toltecs/menu.cpp:281 engines/tsage/scenes.cpp:598
msgid "Save game:"
msgstr "Spara spelet:"
@@ -1283,9 +1288,10 @@ msgstr "Spara spelet:"
#: backends/platform/wince/CEActionsSmartphone.cpp:45
#: backends/platform/wince/CEActionsSmartphone.cpp:231
#: engines/agi/saveload.cpp:803 engines/cruise/menu.cpp:212
-#: engines/drascula/saveload.cpp:336 engines/neverhood/menumodule.cpp:873
-#: engines/pegasus/pegasus.cpp:377 engines/sci/engine/kfile.cpp:758
-#: engines/scumm/dialogs.cpp:188 engines/toltecs/menu.cpp:281
+#: engines/drascula/saveload.cpp:336 engines/dreamweb/saveload.cpp:261
+#: engines/neverhood/menumodule.cpp:873 engines/pegasus/pegasus.cpp:377
+#: engines/sci/engine/kfile.cpp:758 engines/scumm/dialogs.cpp:188
+#: engines/toltecs/menu.cpp:281 engines/tsage/scenes.cpp:598
msgid "Save"
msgstr "Spara"
@@ -1309,12 +1315,12 @@ msgstr ""
"information och instruktioner fіr hur du kan fх mer hjфlp."
#: engines/dialogs.cpp:307 engines/mohawk/dialogs.cpp:109
-#: engines/mohawk/dialogs.cpp:170
+#: engines/mohawk/dialogs.cpp:170 engines/tsage/dialogs.cpp:106
msgid "~O~K"
msgstr "~O~K"
#: engines/dialogs.cpp:308 engines/mohawk/dialogs.cpp:110
-#: engines/mohawk/dialogs.cpp:171
+#: engines/mohawk/dialogs.cpp:171 engines/tsage/dialogs.cpp:107
msgid "~C~ancel"
msgstr "A~v~bryt"
@@ -2079,24 +2085,26 @@ msgstr "Klickning deaktiverad"
#: engines/agi/detection.cpp:142 engines/drascula/detection.cpp:302
#: engines/dreamweb/detection.cpp:47 engines/neverhood/detection.cpp:160
#: engines/sci/detection.cpp:394 engines/toltecs/detection.cpp:200
+#: engines/zvision/detection.cpp:103
msgid "Use original save/load screens"
msgstr "Anvфnd originalskфrmar fіr spara/ladda"
#: engines/agi/detection.cpp:143 engines/drascula/detection.cpp:303
#: engines/dreamweb/detection.cpp:48 engines/neverhood/detection.cpp:161
#: engines/sci/detection.cpp:395 engines/toltecs/detection.cpp:201
+#: engines/zvision/detection.cpp:104
msgid "Use the original save/load screens, instead of the ScummVM ones"
msgstr "Anvфnder originalskфrmarna fіr spara/ladda istфllet fіr ScummVM:s"
#: engines/agi/saveload.cpp:816 engines/drascula/saveload.cpp:349
-#: engines/neverhood/menumodule.cpp:886 engines/sci/engine/kfile.cpp:857
-#: engines/toltecs/menu.cpp:256
+#: engines/dreamweb/saveload.cpp:169 engines/neverhood/menumodule.cpp:886
+#: engines/sci/engine/kfile.cpp:857 engines/toltecs/menu.cpp:256
msgid "Restore game:"
msgstr "Хterstфll spel:"
#: engines/agi/saveload.cpp:816 engines/drascula/saveload.cpp:349
-#: engines/neverhood/menumodule.cpp:886 engines/sci/engine/kfile.cpp:857
-#: engines/toltecs/menu.cpp:256
+#: engines/dreamweb/saveload.cpp:169 engines/neverhood/menumodule.cpp:886
+#: engines/sci/engine/kfile.cpp:857 engines/toltecs/menu.cpp:256
msgid "Restore"
msgstr "Хterstфll"
@@ -2138,6 +2146,15 @@ msgstr ""
msgid "Cutscene file '%s' not found!"
msgstr "Filmscensfilen '%s' hittades ej!"
+#: engines/cge/detection.cpp:105 engines/cge2/detection.cpp:81
+#, fuzzy
+msgid "Color Blind Mode"
+msgstr "Klicklфge"
+
+#: engines/cge/detection.cpp:106 engines/cge2/detection.cpp:82
+msgid "Enable Color Blind Mode by default"
+msgstr ""
+
#: engines/drascula/saveload.cpp:47
msgid ""
"ScummVM found that you have old savefiles for Drascula that should be "
@@ -2165,11 +2182,12 @@ msgid "Display graphics using the game's bright palette"
msgstr "Visa grafik med spelets ljusa palett"
#: engines/gob/inter_playtoons.cpp:256 engines/gob/inter_v2.cpp:1470
-#: engines/tinsel/saveload.cpp:532
+#: engines/gob/inter_geisha.cpp:232 engines/tinsel/saveload.cpp:532
msgid "Failed to load game state from file."
msgstr "Kunde inte lфsa spardata frхn filen"
-#: engines/gob/inter_v2.cpp:1540 engines/tinsel/saveload.cpp:545
+#: engines/gob/inter_v2.cpp:1540 engines/gob/inter_geisha.cpp:263
+#: engines/tinsel/saveload.cpp:545
msgid "Failed to save game state to file."
msgstr "Kunde inte skriva spardata till filen."
@@ -2189,6 +2207,14 @@ msgstr "Spela filmer i hіgre hastighet"
msgid "Failed to save game"
msgstr "Kunde inte spara spelet."
+#: engines/hopkins/detection.cpp:76 engines/hopkins/detection.cpp:86
+msgid "Gore Mode"
+msgstr ""
+
+#: engines/hopkins/detection.cpp:77 engines/hopkins/detection.cpp:87
+msgid "Enable Gore Mode when available"
+msgstr ""
+
#. I18N: Studio audience adds an applause and cheering sounds whenever
#. Malcolm makes a joke.
#: engines/kyra/detection.cpp:62
@@ -2309,6 +2335,35 @@ msgstr ""
"General MIDI-instrument. Det kan trots allt hфnda\n"
"att ett fхtal ljudspхr inte spelas korrekt."
+#: engines/kyra/saveload_eob.cpp:557
+#, c-format
+msgid ""
+"The following original save game file has been found in your game path:\n"
+"\n"
+"%s %s\n"
+"\n"
+"Do you wish to use this save game file with ScummVM?\n"
+"\n"
+msgstr ""
+
+#: engines/kyra/saveload_eob.cpp:590
+#, c-format
+msgid ""
+"A save game file was found in the specified slot %d. Overwrite?\n"
+"\n"
+msgstr ""
+
+#: engines/kyra/saveload_eob.cpp:623
+#, c-format
+msgid ""
+"%d original save game files have been successfully imported into\n"
+"ScummVM. If you want to manually import original save game files later you "
+"will\n"
+"need to open the ScummVM debug console and use the command "
+"'import_savefile'.\n"
+"\n"
+msgstr ""
+
#. I18N: Option for fast scene switching
#: engines/mohawk/dialogs.cpp:92 engines/mohawk/dialogs.cpp:167
msgid "~Z~ip Mode Activated"
@@ -2437,6 +2492,14 @@ msgstr "Visa/dіlj informationsskфrm"
msgid "Display/Hide Pause Menu"
msgstr "Visa/dіlj pausmeny"
+#: engines/queen/detection.cpp:56
+msgid "Alternative intro"
+msgstr "Alternativt intro"
+
+#: engines/queen/detection.cpp:57
+msgid "Use an alternative game intro (CD version only)"
+msgstr "Anvфnd alternativt spelintro (endast CD-version)"
+
#: engines/sci/detection.cpp:374
msgid "EGA undithering"
msgstr "EGA anti-gitter"
@@ -3137,6 +3200,18 @@ msgstr ""
"фn. Fіr att spela spelet, gх till \"Lфgg till spel\" i ScummVM:s huvudmeny "
"och vфlj \"Maniac\"-katalogen inuti \"Tentacle\" katalogen."
+#: engines/scumm/players/player_v3m.cpp:129
+msgid ""
+"Could not find the 'Loom' Macintosh executable to read the\n"
+"instruments from. Music will be disabled."
+msgstr ""
+
+#: engines/scumm/players/player_v5m.cpp:107
+msgid ""
+"Could not find the 'Monkey Island' Macintosh executable to read the\n"
+"instruments from. Music will be disabled."
+msgstr ""
+
#: engines/sky/compact.cpp:130
msgid ""
"Unable to find \"sky.cpt\" file!\n"
@@ -3245,6 +3320,14 @@ msgstr ""
"Teenagent.dat-filen фr komprimerad och zlib har inte inkluderats i det hфr "
"programmet. Var god dekomprimera den"
+#: engines/wintermute/detection.cpp:58
+msgid "Show FPS-counter"
+msgstr ""
+
+#: engines/wintermute/detection.cpp:59
+msgid "Show the current number of frames per second in the upper left corner"
+msgstr ""
+
#~ msgid "MPEG-2 cutscenes found but ScummVM has been built without MPEG-2"
#~ msgstr "MPEG-2-filmscener hittades men ScummVM har byggts utan MPEG-2"
@@ -3263,12 +3346,6 @@ msgstr ""
#~ msgid "Standard (16bpp)"
#~ msgstr "Standard (16 bpp)"
-#~ msgid "Alternative intro"
-#~ msgstr "Alternativt intro"
-
-#~ msgid "Use an alternative game intro (CD version only)"
-#~ msgstr "Anvфnd alternativt spelintro (endast CD-version)"
-
#~ msgid "MPEG2 cutscenes are no longer supported"
#~ msgstr "MPEG2 filmscener stіds inte lфngre"
diff --git a/po/uk_UA.po b/po/uk_UA.po
index 52427ce3c5..5a7554189e 100644
--- a/po/uk_UA.po
+++ b/po/uk_UA.po
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: ScummVM 1.3.0svn\n"
"Report-Msgid-Bugs-To: scummvm-devel@lists.sf.net\n"
-"POT-Creation-Date: 2014-09-03 07:39+0200\n"
+"POT-Creation-Date: 2014-10-04 00:58+0100\n"
"PO-Revision-Date: 2014-07-01 02:34+0300\n"
"Last-Translator: Eugene Sandulenko <sev@scummvm.org>\n"
"Language-Team: Ukrainian\n"
@@ -110,12 +110,14 @@ msgstr "Призначити"
#: engines/agos/animation.cpp:558 engines/drascula/saveload.cpp:49
#: engines/groovie/script.cpp:399 engines/parallaction/saveload.cpp:274
#: engines/scumm/dialogs.cpp:193 engines/scumm/scumm.cpp:1825
-#: engines/sky/compact.cpp:131 engines/sky/compact.cpp:141
-#: engines/sword1/animation.cpp:524 engines/sword1/animation.cpp:545
-#: engines/sword1/animation.cpp:561 engines/sword1/animation.cpp:569
-#: engines/sword1/control.cpp:865 engines/sword1/logic.cpp:1633
-#: engines/sword2/animation.cpp:425 engines/sword2/animation.cpp:445
-#: engines/sword2/animation.cpp:461 engines/sword2/animation.cpp:471
+#: engines/scumm/players/player_v3m.cpp:130
+#: engines/scumm/players/player_v5m.cpp:108 engines/sky/compact.cpp:131
+#: engines/sky/compact.cpp:141 engines/sword1/animation.cpp:524
+#: engines/sword1/animation.cpp:545 engines/sword1/animation.cpp:561
+#: engines/sword1/animation.cpp:569 engines/sword1/control.cpp:865
+#: engines/sword1/logic.cpp:1633 engines/sword2/animation.cpp:425
+#: engines/sword2/animation.cpp:445 engines/sword2/animation.cpp:461
+#: engines/sword2/animation.cpp:471
msgid "OK"
msgstr "OK"
@@ -454,7 +456,7 @@ msgstr "Пошук:"
#: gui/launcher.cpp:685 engines/dialogs.cpp:115 engines/cruise/menu.cpp:214
#: engines/mohawk/myst.cpp:245 engines/mohawk/riven.cpp:718
-#: engines/pegasus/pegasus.cpp:353
+#: engines/pegasus/pegasus.cpp:353 engines/tsage/scenes.cpp:600
msgid "Load game:"
msgstr "Завантажити гру:"
@@ -463,7 +465,7 @@ msgstr "Завантажити гру:"
#: backends/platform/wince/CEActionsSmartphone.cpp:231
#: engines/cruise/menu.cpp:214 engines/mohawk/myst.cpp:245
#: engines/mohawk/riven.cpp:718 engines/pegasus/pegasus.cpp:353
-#: engines/scumm/dialogs.cpp:189
+#: engines/scumm/dialogs.cpp:189 engines/tsage/scenes.cpp:600
msgid "Load"
msgstr "Завантажити"
@@ -481,6 +483,7 @@ msgstr ""
#: backends/platform/wince/CEActionsPocket.cpp:326
#: backends/platform/wince/CEActionsSmartphone.cpp:287
#: backends/platform/wince/CELauncherDialog.cpp:83
+#: engines/kyra/saveload_eob.cpp:557 engines/kyra/saveload_eob.cpp:590
msgid "Yes"
msgstr "Так"
@@ -490,6 +493,7 @@ msgstr "Так"
#: backends/platform/wince/CEActionsPocket.cpp:326
#: backends/platform/wince/CEActionsSmartphone.cpp:287
#: backends/platform/wince/CELauncherDialog.cpp:83
+#: engines/kyra/saveload_eob.cpp:557 engines/kyra/saveload_eob.cpp:590
msgid "No"
msgstr "Ні"
@@ -1272,8 +1276,9 @@ msgstr "~П~овер.в головне меню"
#: engines/dialogs.cpp:116 engines/agi/saveload.cpp:803
#: engines/cruise/menu.cpp:212 engines/drascula/saveload.cpp:336
-#: engines/neverhood/menumodule.cpp:873 engines/pegasus/pegasus.cpp:377
-#: engines/sci/engine/kfile.cpp:758 engines/toltecs/menu.cpp:281
+#: engines/dreamweb/saveload.cpp:261 engines/neverhood/menumodule.cpp:873
+#: engines/pegasus/pegasus.cpp:377 engines/sci/engine/kfile.cpp:758
+#: engines/toltecs/menu.cpp:281 engines/tsage/scenes.cpp:598
msgid "Save game:"
msgstr "Зберегти гру: "
@@ -1283,9 +1288,10 @@ msgstr "Зберегти гру: "
#: backends/platform/wince/CEActionsSmartphone.cpp:45
#: backends/platform/wince/CEActionsSmartphone.cpp:231
#: engines/agi/saveload.cpp:803 engines/cruise/menu.cpp:212
-#: engines/drascula/saveload.cpp:336 engines/neverhood/menumodule.cpp:873
-#: engines/pegasus/pegasus.cpp:377 engines/sci/engine/kfile.cpp:758
-#: engines/scumm/dialogs.cpp:188 engines/toltecs/menu.cpp:281
+#: engines/drascula/saveload.cpp:336 engines/dreamweb/saveload.cpp:261
+#: engines/neverhood/menumodule.cpp:873 engines/pegasus/pegasus.cpp:377
+#: engines/sci/engine/kfile.cpp:758 engines/scumm/dialogs.cpp:188
+#: engines/toltecs/menu.cpp:281 engines/tsage/scenes.cpp:598
msgid "Save"
msgstr "Записати"
@@ -1309,12 +1315,12 @@ msgstr ""
"основної інормації, а також інструкцій, як отримати подальшу допомогу."
#: engines/dialogs.cpp:307 engines/mohawk/dialogs.cpp:109
-#: engines/mohawk/dialogs.cpp:170
+#: engines/mohawk/dialogs.cpp:170 engines/tsage/dialogs.cpp:106
msgid "~O~K"
msgstr "~O~K"
#: engines/dialogs.cpp:308 engines/mohawk/dialogs.cpp:110
-#: engines/mohawk/dialogs.cpp:171
+#: engines/mohawk/dialogs.cpp:171 engines/tsage/dialogs.cpp:107
msgid "~C~ancel"
msgstr "Ві~д~міна"
@@ -2078,25 +2084,27 @@ msgstr "Кліки вимкнено"
#: engines/agi/detection.cpp:142 engines/drascula/detection.cpp:302
#: engines/dreamweb/detection.cpp:47 engines/neverhood/detection.cpp:160
#: engines/sci/detection.cpp:394 engines/toltecs/detection.cpp:200
+#: engines/zvision/detection.cpp:103
msgid "Use original save/load screens"
msgstr "Використовувати ориг. збереження/завантаження екрани"
#: engines/agi/detection.cpp:143 engines/drascula/detection.cpp:303
#: engines/dreamweb/detection.cpp:48 engines/neverhood/detection.cpp:161
#: engines/sci/detection.cpp:395 engines/toltecs/detection.cpp:201
+#: engines/zvision/detection.cpp:104
msgid "Use the original save/load screens, instead of the ScummVM ones"
msgstr ""
"Використовувати оригінальні збереження/завантаження екрани, замість ScummVM"
#: engines/agi/saveload.cpp:816 engines/drascula/saveload.cpp:349
-#: engines/neverhood/menumodule.cpp:886 engines/sci/engine/kfile.cpp:857
-#: engines/toltecs/menu.cpp:256
+#: engines/dreamweb/saveload.cpp:169 engines/neverhood/menumodule.cpp:886
+#: engines/sci/engine/kfile.cpp:857 engines/toltecs/menu.cpp:256
msgid "Restore game:"
msgstr "Відновити гру:"
#: engines/agi/saveload.cpp:816 engines/drascula/saveload.cpp:349
-#: engines/neverhood/menumodule.cpp:886 engines/sci/engine/kfile.cpp:857
-#: engines/toltecs/menu.cpp:256
+#: engines/dreamweb/saveload.cpp:169 engines/neverhood/menumodule.cpp:886
+#: engines/sci/engine/kfile.cpp:857 engines/toltecs/menu.cpp:256
msgid "Restore"
msgstr "Відновити"
@@ -2138,6 +2146,15 @@ msgstr ""
msgid "Cutscene file '%s' not found!"
msgstr "Файл ролику '%s' не знайдено!"
+#: engines/cge/detection.cpp:105 engines/cge2/detection.cpp:81
+#, fuzzy
+msgid "Color Blind Mode"
+msgstr "Режим кліків"
+
+#: engines/cge/detection.cpp:106 engines/cge2/detection.cpp:82
+msgid "Enable Color Blind Mode by default"
+msgstr ""
+
#: engines/drascula/saveload.cpp:47
msgid ""
"ScummVM found that you have old savefiles for Drascula that should be "
@@ -2164,11 +2181,12 @@ msgid "Display graphics using the game's bright palette"
msgstr "Відображення графіки з використанням яскравої палітри ігр"
#: engines/gob/inter_playtoons.cpp:256 engines/gob/inter_v2.cpp:1470
-#: engines/tinsel/saveload.cpp:532
+#: engines/gob/inter_geisha.cpp:232 engines/tinsel/saveload.cpp:532
msgid "Failed to load game state from file."
msgstr "Не вдалося завантажити стан гри з файлу."
-#: engines/gob/inter_v2.cpp:1540 engines/tinsel/saveload.cpp:545
+#: engines/gob/inter_v2.cpp:1540 engines/gob/inter_geisha.cpp:263
+#: engines/tinsel/saveload.cpp:545
msgid "Failed to save game state to file."
msgstr "Не вдалося зберегти стан гри у файл."
@@ -2188,6 +2206,14 @@ msgstr "Програвати відео з підвищенною швидкістю"
msgid "Failed to save game"
msgstr "Не вдалося записати гру"
+#: engines/hopkins/detection.cpp:76 engines/hopkins/detection.cpp:86
+msgid "Gore Mode"
+msgstr ""
+
+#: engines/hopkins/detection.cpp:77 engines/hopkins/detection.cpp:87
+msgid "Enable Gore Mode when available"
+msgstr ""
+
#. I18N: Studio audience adds an applause and cheering sounds whenever
#. Malcolm makes a joke.
#: engines/kyra/detection.cpp:62
@@ -2308,6 +2334,35 @@ msgstr ""
"MT32 на General MIDI. Але в результаті може\n"
"статися, що деякі треки будуть грати неправильно."
+#: engines/kyra/saveload_eob.cpp:557
+#, c-format
+msgid ""
+"The following original save game file has been found in your game path:\n"
+"\n"
+"%s %s\n"
+"\n"
+"Do you wish to use this save game file with ScummVM?\n"
+"\n"
+msgstr ""
+
+#: engines/kyra/saveload_eob.cpp:590
+#, c-format
+msgid ""
+"A save game file was found in the specified slot %d. Overwrite?\n"
+"\n"
+msgstr ""
+
+#: engines/kyra/saveload_eob.cpp:623
+#, c-format
+msgid ""
+"%d original save game files have been successfully imported into\n"
+"ScummVM. If you want to manually import original save game files later you "
+"will\n"
+"need to open the ScummVM debug console and use the command "
+"'import_savefile'.\n"
+"\n"
+msgstr ""
+
#. I18N: Option for fast scene switching
#: engines/mohawk/dialogs.cpp:92 engines/mohawk/dialogs.cpp:167
msgid "~Z~ip Mode Activated"
@@ -2435,6 +2490,14 @@ msgstr "Показати/Сховати інфоекран"
msgid "Display/Hide Pause Menu"
msgstr "Показувати/Сховати меню паузи"
+#: engines/queen/detection.cpp:56
+msgid "Alternative intro"
+msgstr "Алтернативний вступ"
+
+#: engines/queen/detection.cpp:57
+msgid "Use an alternative game intro (CD version only)"
+msgstr "Використовувати альтернативний вступ гри (тільки CD версія)"
+
#: engines/sci/detection.cpp:374
msgid "EGA undithering"
msgstr "EGA без растрування"
@@ -3135,6 +3198,18 @@ msgstr ""
"вміє. Щоб грати у нього, оберіть 'Додати гру' у початковому меню ScummVM, і "
"виберіть папку Maniac всередені пвпки з грою Tentacle."
+#: engines/scumm/players/player_v3m.cpp:129
+msgid ""
+"Could not find the 'Loom' Macintosh executable to read the\n"
+"instruments from. Music will be disabled."
+msgstr ""
+
+#: engines/scumm/players/player_v5m.cpp:107
+msgid ""
+"Could not find the 'Monkey Island' Macintosh executable to read the\n"
+"instruments from. Music will be disabled."
+msgstr ""
+
#: engines/sky/compact.cpp:130
msgid ""
"Unable to find \"sky.cpt\" file!\n"
@@ -3245,6 +3320,14 @@ msgstr ""
"Файл teenagent.dat запаковано, але zlib не було включено в цю программу.Будь-"
"ласка розпакуйте його"
+#: engines/wintermute/detection.cpp:58
+msgid "Show FPS-counter"
+msgstr ""
+
+#: engines/wintermute/detection.cpp:59
+msgid "Show the current number of frames per second in the upper left corner"
+msgstr ""
+
#~ msgid "MPEG-2 cutscenes found but ScummVM has been built without MPEG-2"
#~ msgstr ""
#~ "Знайдені ролики MPEG-2, але ScummVM був зібраний без підтримки MPEG-2"
@@ -3264,12 +3347,6 @@ msgstr ""
#~ msgid "Standard (16bpp)"
#~ msgstr "Стандартний растеризатор (16bpp)"
-#~ msgid "Alternative intro"
-#~ msgstr "Алтернативний вступ"
-
-#~ msgid "Use an alternative game intro (CD version only)"
-#~ msgstr "Використовувати альтернативний вступ гри (тільки CD версія)"
-
#~ msgid "MPEG2 cutscenes are no longer supported"
#~ msgstr "Ролики MPEG2 більше не підтримуються"
diff --git a/ports.mk b/ports.mk
index 97b43fe92e..fdab7e23af 100644
--- a/ports.mk
+++ b/ports.mk
@@ -12,6 +12,8 @@ install:
$(INSTALL) -c -m 644 "$(srcdir)/dists/scummvm.6" "$(DESTDIR)$(mandir)/man6/scummvm.6"
$(INSTALL) -d "$(DESTDIR)$(datarootdir)/pixmaps/"
$(INSTALL) -c -m 644 "$(srcdir)/icons/scummvm.xpm" "$(DESTDIR)$(datarootdir)/pixmaps/scummvm.xpm"
+ $(INSTALL) -d "$(DESTDIR)$(datarootdir)/icons/hicolor/scalable/apps/"
+ $(INSTALL) -c -m 644 "$(srcdir)/icons/scummvm.svg" "$(DESTDIR)$(datarootdir)/icons/hicolor/scalable/apps/scummvm.svg"
$(INSTALL) -d "$(DESTDIR)$(docdir)"
$(INSTALL) -c -m 644 $(DIST_FILES_DOCS) "$(DESTDIR)$(docdir)"
$(INSTALL) -d "$(DESTDIR)$(datadir)"
@@ -28,6 +30,8 @@ install-strip:
$(INSTALL) -c -m 644 "$(srcdir)/dists/scummvm.6" "$(DESTDIR)$(mandir)/man6/scummvm.6"
$(INSTALL) -d "$(DESTDIR)$(datarootdir)/pixmaps/"
$(INSTALL) -c -m 644 "$(srcdir)/icons/scummvm.xpm" "$(DESTDIR)$(datarootdir)/pixmaps/scummvm.xpm"
+ $(INSTALL) -d "$(DESTDIR)$(datarootdir)/icons/hicolor/scalable/apps/"
+ $(INSTALL) -c -m 644 "$(srcdir)/icons/scummvm.svg" "$(DESTDIR)$(datarootdir)/icons/hicolor/scalable/apps/scummvm.svg"
$(INSTALL) -d "$(DESTDIR)$(docdir)"
$(INSTALL) -c -m 644 $(DIST_FILES_DOCS) "$(DESTDIR)$(docdir)"
$(INSTALL) -d "$(DESTDIR)$(datadir)"
@@ -41,6 +45,7 @@ uninstall:
rm -f "$(DESTDIR)$(bindir)/$(EXECUTABLE)"
rm -f "$(DESTDIR)$(mandir)/man6/scummvm.6"
rm -f "$(DESTDIR)$(datarootdir)/pixmaps/scummvm.xpm"
+ rm -f "$(DESTDIR)$(datarootdir)/icons/hicolor/scalable/apps/scummvm.svg"
rm -rf "$(DESTDIR)$(docdir)"
rm -rf "$(DESTDIR)$(datadir)"
ifdef DYNAMIC_MODULES
diff --git a/test/audio/timestamp.h b/test/audio/timestamp.h
index ca56e34a4d..ec42a55ec4 100644
--- a/test/audio/timestamp.h
+++ b/test/audio/timestamp.h
@@ -2,6 +2,8 @@
#include "audio/timestamp.h"
+#include <limits.h>
+
class TimestampTestSuite : public CxxTest::TestSuite
{
public:
@@ -238,4 +240,15 @@ class TimestampTestSuite : public CxxTest::TestSuite
TS_ASSERT_EQUALS(c.numberOfFrames(), 11025);
TS_ASSERT_EQUALS(c.totalNumberOfFrames(), 33075);
}
+
+ void test_no_overflow() {
+ // The constructor should not overflow and give incoherent values
+ const Audio::Timestamp a = Audio::Timestamp(0, UINT_MAX, 1000);
+
+ int secs = UINT_MAX / 1000;
+ int frames = UINT_MAX % 1000;
+
+ TS_ASSERT_EQUALS(a.secs(), secs);
+ TS_ASSERT_EQUALS(a.numberOfFrames(), frames);
+ }
};
diff --git a/video/avi_decoder.cpp b/video/avi_decoder.cpp
index 39deaea204..7119c72f07 100644
--- a/video/avi_decoder.cpp
+++ b/video/avi_decoder.cpp
@@ -149,7 +149,7 @@ bool AVIDecoder::parseNextChunk() {
skipChunk(size);
break;
case ID_IDX1:
- readOldIndex(size);
+ readOldIndex(size);
break;
default:
error("Unknown tag \'%s\' found", tag2str(tag));
@@ -319,8 +319,25 @@ bool AVIDecoder::loadStream(Common::SeekableReadStream *stream) {
return false;
}
- // Seek back to the start of the MOVI list
- _fileStream->seek(_movieListStart);
+ // Create the status entries
+ uint32 index = 0;
+ for (TrackListIterator it = getTrackListBegin(); it != getTrackListEnd(); it++, index++) {
+ TrackStatus status;
+ status.track = *it;
+ status.index = index;
+ status.chunkSearchOffset = _movieListStart;
+
+ if ((*it)->getTrackType() == Track::kTrackTypeVideo)
+ _videoTracks.push_back(status);
+ else
+ _audioTracks.push_back(status);
+ }
+
+ if (_videoTracks.size() != 1) {
+ warning("Unhandled AVI video track count: %d", _videoTracks.size());
+ close();
+ return false;
+ }
// Check if this is a special Duck Truemotion video
checkTruemotion1();
@@ -340,79 +357,138 @@ void AVIDecoder::close() {
_indexEntries.clear();
memset(&_header, 0, sizeof(_header));
+
+ _videoTracks.clear();
+ _audioTracks.clear();
}
void AVIDecoder::readNextPacket() {
- if ((uint32)_fileStream->pos() >= _movieListEnd) {
- // Ugh, reached the end premature.
- forceVideoEnd();
+ // Shouldn't get this unless called on a non-open video
+ if (_videoTracks.empty())
return;
- }
- uint32 nextTag = _fileStream->readUint32BE();
- uint32 size = _fileStream->readUint32LE();
+ // Get the video frame first
+ handleNextPacket(_videoTracks[0]);
+
+ // Handle audio tracks next
+ for (uint32 i = 0; i < _audioTracks.size(); i++)
+ handleNextPacket(_audioTracks[i]);
+}
+
+void AVIDecoder::handleNextPacket(TrackStatus &status) {
+ // If there's no more to search, bail out
+ if (status.chunkSearchOffset + 8 >= _movieListEnd) {
+ if (status.track->getTrackType() == Track::kTrackTypeVideo) {
+ // Horrible AVI video has a premature end
+ // Force the frame to be the last frame
+ debug(0, "Forcing end of AVI video");
+ ((AVIVideoTrack *)status.track)->forceTrackEnd();
+ }
- if (_fileStream->eos()) {
- // Also premature end.
- forceVideoEnd();
return;
}
- if (nextTag == ID_LIST) {
- // A list of audio/video chunks
- int32 startPos = _fileStream->pos();
+ // See if audio needs to be buffered and break out if not
+ if (status.track->getTrackType() == Track::kTrackTypeAudio && !shouldQueueAudio(status))
+ return;
- if (_fileStream->readUint32BE() != ID_REC)
- error("Expected 'rec ' LIST");
+ // Seek to where we shall start searching
+ _fileStream->seek(status.chunkSearchOffset);
+
+ for (;;) {
+ // If there's no more to search, bail out
+ if ((uint32)_fileStream->pos() + 8 >= _movieListEnd) {
+ if (status.track->getTrackType() == Track::kTrackTypeVideo) {
+ // Horrible AVI video has a premature end
+ // Force the frame to be the last frame
+ debug(0, "Forcing end of AVI video");
+ ((AVIVideoTrack *)status.track)->forceTrackEnd();
+ }
- size -= 4; // subtract list type
+ break;
+ }
- // Decode chunks in the list
- while (_fileStream->pos() < startPos + (int32)size)
- readNextPacket();
+ uint32 nextTag = _fileStream->readUint32BE();
+ uint32 size = _fileStream->readUint32LE();
- return;
- } else if (nextTag == ID_JUNK || nextTag == ID_IDX1) {
- skipChunk(size);
- return;
- }
+ if (nextTag == ID_LIST) {
+ // A list of audio/video chunks
+ if (_fileStream->readUint32BE() != ID_REC)
+ error("Expected 'rec ' LIST");
- Track *track = getTrack(getStreamIndex(nextTag));
+ continue;
+ } else if (nextTag == ID_JUNK || nextTag == ID_IDX1) {
+ skipChunk(size);
+ continue;
+ }
- if (!track)
- error("Cannot get track from tag '%s'", tag2str(nextTag));
+ // Only accept chunks for this stream
+ uint32 streamIndex = getStreamIndex(nextTag);
+ if (streamIndex != status.index) {
+ skipChunk(size);
+ continue;
+ }
- Common::SeekableReadStream *chunk = 0;
+ Common::SeekableReadStream *chunk = 0;
- if (size != 0) {
- chunk = _fileStream->readStream(size);
- _fileStream->skip(size & 1);
- }
+ if (size != 0) {
+ chunk = _fileStream->readStream(size);
+ _fileStream->skip(size & 1);
+ }
- if (track->getTrackType() == Track::kTrackTypeAudio) {
- if (getStreamType(nextTag) != kStreamTypeAudio)
- error("Invalid audio track tag '%s'", tag2str(nextTag));
+ if (status.track->getTrackType() == Track::kTrackTypeAudio) {
+ if (getStreamType(nextTag) != kStreamTypeAudio)
+ error("Invalid audio track tag '%s'", tag2str(nextTag));
- assert(chunk);
- ((AVIAudioTrack *)track)->queueSound(chunk);
- } else {
- AVIVideoTrack *videoTrack = (AVIVideoTrack *)track;
+ assert(chunk);
+ ((AVIAudioTrack *)status.track)->queueSound(chunk);
- if (getStreamType(nextTag) == kStreamTypePaletteChange) {
- // Palette Change
- videoTrack->loadPaletteFromChunk(chunk);
+ // Break out if we have enough audio
+ if (!shouldQueueAudio(status))
+ break;
} else {
- // Otherwise, assume it's a compressed frame
- videoTrack->decodeFrame(chunk);
+ AVIVideoTrack *videoTrack = (AVIVideoTrack *)status.track;
+
+ if (getStreamType(nextTag) == kStreamTypePaletteChange) {
+ // Palette Change
+ videoTrack->loadPaletteFromChunk(chunk);
+ } else {
+ // Otherwise, assume it's a compressed frame
+ videoTrack->decodeFrame(chunk);
+ break;
+ }
}
}
+
+ // Start us off in this position next time
+ status.chunkSearchOffset = _fileStream->pos();
+}
+
+bool AVIDecoder::shouldQueueAudio(TrackStatus& status) {
+ // Sanity check:
+ if (status.track->getTrackType() != Track::kTrackTypeAudio)
+ return false;
+
+ // If video is done, make sure that the rest of the audio is queued
+ // (I guess this is also really a sanity check)
+ AVIVideoTrack *videoTrack = (AVIVideoTrack *)_videoTracks[0].track;
+ if (videoTrack->endOfTrack())
+ return true;
+
+ // Being three frames ahead should be enough for any video.
+ return ((AVIAudioTrack *)status.track)->getCurChunk() < (uint32)(videoTrack->getCurFrame() + 3);
}
bool AVIDecoder::rewind() {
if (!VideoDecoder::rewind())
return false;
- _fileStream->seek(_movieListStart);
+ for (uint32 i = 0; i < _videoTracks.size(); i++)
+ _videoTracks[i].chunkSearchOffset = _movieListStart;
+
+ for (uint32 i = 0; i < _audioTracks.size(); i++)
+ _audioTracks[i].chunkSearchOffset = _movieListStart;
+
return true;
}
@@ -421,29 +497,9 @@ bool AVIDecoder::seekIntern(const Audio::Timestamp &time) {
if (time > getDuration())
return false;
- // Track down our video track.
- // We only support seeking with one video track right now.
- AVIVideoTrack *videoTrack = 0;
- int videoIndex = -1;
- uint trackID = 0;
-
- for (TrackListIterator it = getTrackListBegin(); it != getTrackListEnd(); it++, trackID++) {
- if ((*it)->getTrackType() == Track::kTrackTypeVideo) {
- if (videoTrack) {
- // Already have one
- // -> Not supported
- return false;
- }
-
- videoTrack = (AVIVideoTrack *)*it;
- videoIndex = trackID;
- }
- }
-
- // Need a video track to go forwards
- // If there isn't a video track, why would anyone be using AVI then?
- if (!videoTrack)
- return false;
+ // Get our video
+ AVIVideoTrack *videoTrack = (AVIVideoTrack *)_videoTracks[0].track;
+ uint32 videoIndex = _videoTracks[0].index;
// If we seek directly to the end, just mark the tracks as over
if (time == getDuration()) {
@@ -464,7 +520,6 @@ bool AVIDecoder::seekIntern(const Audio::Timestamp &time) {
int lastKeyFrame = -1;
int frameIndex = -1;
- int lastRecord = -1;
uint curFrame = 0;
// Go through and figure out where we should be
@@ -472,40 +527,40 @@ bool AVIDecoder::seekIntern(const Audio::Timestamp &time) {
for (uint32 i = 0; i < _indexEntries.size(); i++) {
const OldIndex &index = _indexEntries[i];
- if (index.id == ID_REC) {
- // Keep track of any records we find
- lastRecord = i;
- } else {
- if (getStreamIndex(index.id) != videoIndex)
- continue;
+ // We don't care about RECs
+ if (index.id == ID_REC)
+ continue;
- uint16 streamType = getStreamType(index.id);
+ // We're only looking at entries for this track
+ if (getStreamIndex(index.id) != videoIndex)
+ continue;
- if (streamType == kStreamTypePaletteChange) {
- // We need to handle any palette change we see since there's no
- // flag to tell if this is a "key" palette.
- // Decode the palette
- _fileStream->seek(_indexEntries[i].offset + 8);
- Common::SeekableReadStream *chunk = 0;
+ uint16 streamType = getStreamType(index.id);
- if (_indexEntries[i].size != 0)
- chunk = _fileStream->readStream(_indexEntries[i].size);
+ if (streamType == kStreamTypePaletteChange) {
+ // We need to handle any palette change we see since there's no
+ // flag to tell if this is a "key" palette.
+ // Decode the palette
+ _fileStream->seek(_indexEntries[i].offset + 8);
+ Common::SeekableReadStream *chunk = 0;
- videoTrack->loadPaletteFromChunk(chunk);
- } else {
- // Check to see if this is a keyframe
- // The first frame has to be a keyframe
- if ((_indexEntries[i].flags & AVIIF_INDEX) || curFrame == 0)
- lastKeyFrame = i;
-
- // Did we find the target frame?
- if (frame == curFrame) {
- frameIndex = i;
- break;
- }
+ if (_indexEntries[i].size != 0)
+ chunk = _fileStream->readStream(_indexEntries[i].size);
- curFrame++;
+ videoTrack->loadPaletteFromChunk(chunk);
+ } else {
+ // Check to see if this is a keyframe
+ // The first frame has to be a keyframe
+ if ((_indexEntries[i].flags & AVIIF_INDEX) || curFrame == 0)
+ lastKeyFrame = i;
+
+ // Did we find the target frame?
+ if (frame == curFrame) {
+ frameIndex = i;
+ break;
}
+
+ curFrame++;
}
}
@@ -513,52 +568,34 @@ bool AVIDecoder::seekIntern(const Audio::Timestamp &time) {
return false;
// Update all the audio tracks
- uint audioIndex = 0;
-
- for (TrackListIterator it = getTrackListBegin(); it != getTrackListEnd(); it++, audioIndex++) {
- if ((*it)->getTrackType() != Track::kTrackTypeAudio)
- continue;
-
- AVIAudioTrack *audioTrack = (AVIAudioTrack *)*it;
-
- // We need to find where the start of audio should be.
- // Which is exactly 'initialFrames' audio chunks back from where
- // our found frame is.
+ for (uint32 i = 0; i < _audioTracks.size(); i++) {
+ AVIAudioTrack *audioTrack = (AVIAudioTrack *)_audioTracks[i].track;
// Recreate the audio stream
audioTrack->resetStream();
- uint framesNeeded = _header.initialFrames;
- uint startAudioChunk = 0;
- int startAudioSearch = (lastRecord < 0) ? (frameIndex - 1) : (lastRecord - 1);
-
- for (int i = startAudioSearch; i >= 0; i--) {
- if (getStreamIndex(_indexEntries[i].id) != audioIndex)
- continue;
-
- assert(getStreamType(_indexEntries[i].id) == kStreamTypeAudio);
+ // Set the chunk index for the track
+ audioTrack->setCurChunk(frame);
- framesNeeded--;
+ uint32 chunksFound = 0;
+ for (uint32 j = 0; j < _indexEntries.size(); j++) {
+ const OldIndex &index = _indexEntries[j];
- if (framesNeeded == 0) {
- startAudioChunk = i;
- break;
- }
- }
-
- // Now go forward and queue them all
- for (int i = startAudioChunk; i <= startAudioSearch; i++) {
- if (_indexEntries[i].id == ID_REC)
- continue;
-
- if (getStreamIndex(_indexEntries[i].id) != audioIndex)
+ // Continue ignoring RECs
+ if (index.id == ID_REC)
continue;
- assert(getStreamType(_indexEntries[i].id) == kStreamTypeAudio);
+ if (getStreamIndex(index.id) == _audioTracks[i].index) {
+ if (chunksFound == frame) {
+ _fileStream->seek(index.offset + 8);
+ Common::SeekableReadStream *audioChunk = _fileStream->readStream(index.size);
+ audioTrack->queueSound(audioChunk);
+ _audioTracks[i].chunkSearchOffset = (j == _indexEntries.size() - 1) ? _movieListEnd : _indexEntries[j + 1].offset;
+ break;
+ }
- _fileStream->seek(_indexEntries[i].offset + 8);
- Common::SeekableReadStream *chunk = _fileStream->readStream(_indexEntries[i].size);
- audioTrack->queueSound(chunk);
+ chunksFound++;
+ }
}
// Skip any audio to bring us to the right time
@@ -589,15 +626,11 @@ bool AVIDecoder::seekIntern(const Audio::Timestamp &time) {
videoTrack->decodeFrame(chunk);
}
- // Seek to the right spot
- // To the beginning of the last record, or frame if that doesn't exist
- if (lastRecord >= 0)
- _fileStream->seek(_indexEntries[lastRecord].offset);
- else
- _fileStream->seek(_indexEntries[frameIndex].offset);
-
+ // Set the video track's frame
videoTrack->setCurFrame((int)frame - 1);
+ // Set the video track's search offset to the right spot
+ _videoTracks[0].chunkSearchOffset = _indexEntries[frameIndex].offset;
return true;
}
@@ -620,7 +653,7 @@ void AVIDecoder::readOldIndex(uint32 size) {
OldIndex firstEntry;
firstEntry.id = _fileStream->readUint32BE();
firstEntry.flags = _fileStream->readUint32LE();
- firstEntry.offset = _fileStream->readUint32LE();
+ firstEntry.offset = _fileStream->readUint32LE();
firstEntry.size = _fileStream->readUint32LE();
// Check if the offset is already absolute
@@ -651,45 +684,22 @@ void AVIDecoder::readOldIndex(uint32 size) {
}
}
-void AVIDecoder::forceVideoEnd() {
- // Horrible AVI video has a premature end
- // Force the frame to be the last frame
- debug(0, "Forcing end of AVI video");
-
- for (TrackListIterator it = getTrackListBegin(); it != getTrackListEnd(); it++)
- if ((*it)->getTrackType() == Track::kTrackTypeVideo)
- ((AVIVideoTrack *)*it)->forceTrackEnd();
-}
-
void AVIDecoder::checkTruemotion1() {
- AVIVideoTrack *track = 0;
-
- for (TrackListIterator it = getTrackListBegin(); it != getTrackListEnd(); it++) {
- if ((*it)->getTrackType() == Track::kTrackTypeVideo) {
- if (track) {
- // Multiple tracks; isn't going to be truemotion 1
- return;
- }
-
- track = (AVIVideoTrack *)*it;
- }
- }
+ // If we got here from loadStream(), we know the track is valid
+ assert(!_videoTracks.empty());
- // No track found?
- if (!track)
- return;
+ TrackStatus &status = _videoTracks[0];
+ AVIVideoTrack *track = (AVIVideoTrack *)status.track;
// Ignore non-truemotion tracks
if (!track->isTruemotion1())
return;
- // Search for a non-empty frame
- const Graphics::Surface *frame = 0;
- for (int i = 0; i < 10 && !frame; i++)
- frame = decodeNextFrame();
+ // Read the next video packet
+ handleNextPacket(status);
+ const Graphics::Surface *frame = track->decodeNextFrame();
if (!frame) {
- // Probably shouldn't happen
rewind();
return;
}
@@ -806,7 +816,7 @@ void AVIDecoder::AVIVideoTrack::forceTrackEnd() {
}
AVIDecoder::AVIAudioTrack::AVIAudioTrack(const AVIStreamHeader &streamHeader, const PCMWaveFormat &waveFormat, Audio::Mixer::SoundType soundType)
- : _audsHeader(streamHeader), _wvInfo(waveFormat), _soundType(soundType) {
+ : _audsHeader(streamHeader), _wvInfo(waveFormat), _soundType(soundType), _curChunk(0) {
_audStream = createAudioStream();
}
@@ -833,12 +843,12 @@ void AVIDecoder::AVIAudioTrack::queueSound(Common::SeekableReadStream *stream) {
_audStream->queueAudioStream(Audio::makeADPCMStream(stream, DisposeAfterUse::YES, stream->size(), Audio::kADPCMMSIma, _wvInfo.samplesPerSec, _wvInfo.channels, _wvInfo.blockAlign), DisposeAfterUse::YES);
} else if (_wvInfo.tag == kWaveFormatDK3) {
_audStream->queueAudioStream(Audio::makeADPCMStream(stream, DisposeAfterUse::YES, stream->size(), Audio::kADPCMDK3, _wvInfo.samplesPerSec, _wvInfo.channels, _wvInfo.blockAlign), DisposeAfterUse::YES);
- } else if (_wvInfo.tag == kWaveFormatMP3) {
- warning("AVI: MP3 audio stream is not supported");
}
} else {
delete stream;
}
+
+ _curChunk++;
}
void AVIDecoder::AVIAudioTrack::skipAudio(const Audio::Timestamp &time, const Audio::Timestamp &frameTime) {
@@ -859,6 +869,7 @@ void AVIDecoder::AVIAudioTrack::skipAudio(const Audio::Timestamp &time, const Au
void AVIDecoder::AVIAudioTrack::resetStream() {
delete _audStream;
_audStream = createAudioStream();
+ _curChunk = 0;
}
bool AVIDecoder::AVIAudioTrack::rewind() {
@@ -871,12 +882,17 @@ Audio::AudioStream *AVIDecoder::AVIAudioTrack::getAudioStream() const {
}
Audio::QueuingAudioStream *AVIDecoder::AVIAudioTrack::createAudioStream() {
- if (_wvInfo.tag == kWaveFormatPCM || _wvInfo.tag == kWaveFormatMSADPCM || _wvInfo.tag == kWaveFormatMSIMAADPCM || _wvInfo.tag == kWaveFormatDK3 || _wvInfo.tag == kWaveFormatMP3)
+ if (_wvInfo.tag == kWaveFormatPCM || _wvInfo.tag == kWaveFormatMSADPCM || _wvInfo.tag == kWaveFormatMSIMAADPCM || _wvInfo.tag == kWaveFormatDK3)
return Audio::makeQueuingAudioStream(_wvInfo.samplesPerSec, _wvInfo.channels == 2);
+ else if (_wvInfo.tag == kWaveFormatMP3)
+ warning("Unsupported AVI MP3 tracks");
else if (_wvInfo.tag != kWaveFormatNone) // No sound
warning("Unsupported AVI audio format %d", _wvInfo.tag);
return 0;
}
+AVIDecoder::TrackStatus::TrackStatus() : track(0), chunkSearchOffset(0) {
+}
+
} // End of namespace Video
diff --git a/video/avi_decoder.h b/video/avi_decoder.h
index 4461e537c5..8941ff4e75 100644
--- a/video/avi_decoder.h
+++ b/video/avi_decoder.h
@@ -215,7 +215,9 @@ protected:
virtual void queueSound(Common::SeekableReadStream *stream);
Audio::Mixer::SoundType getSoundType() const { return _soundType; }
void skipAudio(const Audio::Timestamp &time, const Audio::Timestamp &frameTime);
- void resetStream();
+ virtual void resetStream();
+ uint32 getCurChunk() const { return _curChunk; }
+ void setCurChunk(uint32 chunk) { _curChunk = chunk; }
bool isRewindable() const { return true; }
bool rewind();
@@ -238,6 +240,15 @@ protected:
Audio::Mixer::SoundType _soundType;
Audio::QueuingAudioStream *_audStream;
Audio::QueuingAudioStream *createAudioStream();
+ uint32 _curChunk;
+ };
+
+ struct TrackStatus {
+ TrackStatus();
+
+ Track *track;
+ uint32 index;
+ uint32 chunkSearchOffset;
};
AVIHeader _header;
@@ -260,9 +271,12 @@ protected:
void handleStreamHeader(uint32 size);
uint16 getStreamType(uint32 tag) const { return tag & 0xFFFF; }
byte getStreamIndex(uint32 tag) const;
- void forceVideoEnd();
void checkTruemotion1();
+ void handleNextPacket(TrackStatus& status);
+ bool shouldQueueAudio(TrackStatus& status);
+ Common::Array<TrackStatus> _videoTracks, _audioTracks;
+
public:
virtual AVIAudioTrack *createAudioTrack(AVIStreamHeader sHeader, PCMWaveFormat wvInfo);
};
diff --git a/video/theora_decoder.h b/video/theora_decoder.h
index b85388426b..feb4c6b49e 100644
--- a/video/theora_decoder.h
+++ b/video/theora_decoder.h
@@ -50,6 +50,7 @@ namespace Video {
*
* Decoder for Theora videos.
* Video decoder used in engines:
+ * - pegasus
* - sword25
* - wintermute
*/
diff --git a/video/video_decoder.cpp b/video/video_decoder.cpp
index dce96aae03..a4bc5b81a2 100644
--- a/video/video_decoder.cpp
+++ b/video/video_decoder.cpp
@@ -530,7 +530,9 @@ Audio::Timestamp VideoDecoder::FixedRateVideoTrack::getFrameTime(uint frame) con
// (which Audio::Timestamp doesn't support).
Common::Rational frameRate = getFrameRate();
- if (frameRate == frameRate.toInt()) // The nice case (a whole number)
+ // Try to keep it in terms of the frame rate, if the frame rate is a whole
+ // number.
+ if (frameRate.getDenominator() == 1)
return Audio::Timestamp(0, frame, frameRate.toInt());
// Convert as best as possible