Commit Graph

112 Commits

Author SHA1 Message Date
Max Horn
b75c969e66 Moved class File and the MD5 stuff to namespace Common
svn-id: r18037
2005-05-10 22:56:25 +00:00
Torbjörn Andersson
781472641e Made it possible to quit while the game is asking for a CD.
svn-id: r17963
2005-05-08 13:05:31 +00:00
Torbjörn Andersson
7298987bba Whitespace changes.
svn-id: r16913
2005-02-25 14:19:30 +00:00
Max Horn
457ee7f582 Fix compilation on BE systems
svn-id: r16861
2005-02-22 18:09:38 +00:00
Torbjörn Andersson
9bb1414818 Moved some debugging stuff into the debugger class.
svn-id: r16859
2005-02-22 07:37:50 +00:00
Robert Göffringmann
fd5a9be26e removed lots of unnecessary seek()s and read()s by keeping the datafiles' index tables in memory instead of accessing them over and over again, which caused major slowdowns with cd accesses.
Also, the caching of datafiles depends on the memory usage now, not on the number of screens that the player entered in the meantime.
The old behaviour made the engine run out of memory on the PS2.

svn-id: r16843
2005-02-21 02:29:18 +00:00
Torbjörn Andersson
43cfe01f3d This is the second part of the BS2 restructuring. There are two new
classes: Screen and Mouse. Screen handles most of the drawing, except the
mouse cursor and in-game menus.

The old Graphics class is no more.

I've also fixed some "reverse stereo" regressions from the first part of
the restructuring.

I'm not sure what the next step will be, but hopefully it will be smaller
than this one was.

svn-id: r16812
2005-02-19 14:02:16 +00:00
Torbjörn Andersson
fe3e01a110 Now there are two file handles for the music: one for each CD. This is not
the same thing as one for each music stream. If both music streams are
playing music from the same CD, they will both take turns at using the same
file handle.

The only case where both file handles are used is when music from one CD is
fading in while music from the other CD is fading out. Which of course can
only happen if you play the game from hard disk. If the game has to ask for
the other CD, it kills the music immediately.

The reason for doing this is that there was some concern about whether
having two file handles open to the same file was portable or not. I don't
think that question was ever fully answered, so I avoid the situation.

svn-id: r16753
2005-02-08 08:32:50 +00:00
Torbjörn Andersson
c0a3816e17 Began what I hope is the final major restructuring of the BS2 engine.
In this first step, I have moved all opcode functions into functions.cpp,
instead of having them scattered all over the place.

To get things to compile again, I had to rewrite the overly complicated
sound effects handling. It's much simpler now.

The next step will be to move any non-trivial code out of the opcode
functions and into the appropriate object. This, I hope, will make it
easier to create well-separated objects, instead of the current mess.

I also want to tear down the artificial boundary between the main directory
and the "driver" directory. We already have a cross-platform layer; there's
no need to have yet another one. (Actually, the rewriting of the sound
effects code took one first step in this direction.)

At the final stage, I'd like to get rid of the "drivers" directory
completely, but I'll probably need some help with that if I want to
preserve the CVS history of the code.

Things will probably be a bit bumpy along the way, but I seem to have
reached a point of relative stability again, which is why I'm commiting
this now.

svn-id: r16668
2005-01-28 16:33:14 +00:00
Torbjörn Andersson
0b461c8506 Updated copyright header, as discussed on the mailing list.
svn-id: r16580
2005-01-17 10:57:15 +00:00
Torbjörn Andersson
5178822833 Updated copyright year.
svn-id: r16397
2005-01-01 15:10:22 +00:00
Max Horn
b78ac6a18b Make use of our String class instead of juggling with char pointers; added File::exists method
svn-id: r15913
2004-11-27 15:09:53 +00:00
Torbjörn Andersson
0cfd573951 Cleanup
svn-id: r15810
2004-11-14 15:00:01 +00:00
Torbjörn Andersson
095035e9c7 Removed obsolete comment.
svn-id: r15193
2004-09-19 18:19:30 +00:00
Torbjörn Andersson
d010b9e560 As an experiment, expire SCREEN_FILE resources faster than other resources.
They're generally the largest resources in the cache by far (though some
ANIMATION_FILE resources are about as big).

I still don't know how much benefit there is to resource caching, but some
of it is definitely needed, or the game won't work properly. Oh well, as
long as no one complains about the extra memory usage...

svn-id: r15079
2004-09-12 17:10:59 +00:00
Torbjörn Andersson
412f7105f0 Fixed evil regression #2. Restarting the game, or using the "start" debug
command, would close the global script variables and player object
resources, without reopening them again. This made them fair game for the
resource expiration mechanism. The player object is probably referenced
often enough to stay alive, but the variables died on me pretty quickly,
causing ScummVM to crash.

I've also added a "reslist" debug command to make this sort of things
easier to spot. By default it only lists resources with refCount > 0. Use
"reslist 0" to see all the cached resources as well.

svn-id: r14958
2004-09-08 07:10:54 +00:00
Max Horn
b8ad54b3af Reversed param order of File::open() -- this allowed me to get rid of a few more getGameDataPath() calls
svn-id: r14090
2004-06-27 22:14:35 +00:00
Torbjörn Andersson
3c70f5a85c If the 'time' parameter to displayMsg() is 0, wait until the user clicks
or presses a button. This is how displayMsg() was always used, so the only
difference is that the code to check for events is no longer outside the
function.

In the process, it turned out that removeMsg() was probably unnecessary so
I have removed it. May cause regressions, but we can deal with them later.

svn-id: r13953
2004-06-10 06:48:50 +00:00
Torbjörn Andersson
fc970b3c75 Removed the buffering of mouse and keyboard events. I don't think any of
our other engines do this, so there is little reason for BS2 to. I did add
a filtering mechanism so that mouse button releases and scroll wheeling is
ignored during normal gameplay, but I don't know if that was necessary
either.

Since this left little more than an empty husk where the Input class used
to be, I've eliminated that class and buried its remains in Sword2Engine.

svn-id: r13812
2004-05-09 13:32:04 +00:00
Torbjörn Andersson
ed9bac56b0 My recent sound changes broke "restart". This should un-break it again.
svn-id: r13810
2004-05-09 13:20:12 +00:00
Torbjörn Andersson
bc77ba431a Simplified the handling of sound effects. It's not necessary for the driver
to keep its own copy of the sound data. It could be even further simplified
(I don't really see any reason for having two different sound queues), but
I seem to have reached a point of stability here and I don't want to jinx
it by making further changes yet.

svn-id: r13705
2004-05-01 10:42:23 +00:00
Torbjörn Andersson
0ac8c4bd3f I forgot to clear the reference counter when a resource is forcibly removed
and I may as well clear it when a resource is read from disk as well.

svn-id: r13606
2004-04-23 11:36:06 +00:00
Torbjörn Andersson
8f8185f035 Major revamping of the BS2 memory manager and, some small changes to the
resource manager. All new code! All new bugs!

svn-id: r13603
2004-04-23 07:02:11 +00:00
Torbjörn Andersson
4c3a68027f Use the same syntax for accessing script variables as BS1 does, i.e. now
it's Logic::_scriptVars[ID] instead of just ID. Apart from looking cool, it
makes it much easier to tell the difference between variables and constants
when looking at the code.

Of course, this sort of sweeping changes is jolly good for introducing
truly weird regressions, which is why I waited until after 0.6.0.

svn-id: r13331
2004-03-17 09:03:15 +00:00
Torbjörn Andersson
ece97788ac If the user has previous savegames, display a restart/restore dialog when
the game starts. (I know it could look prettier, but I don't have much to
work with here...)

svn-id: r13178
2004-03-04 08:03:32 +00:00
Torbjörn Andersson
802a301a16 Removed some of the #includes from sword2.h
svn-id: r12739
2004-02-05 14:19:07 +00:00
Paweł Kołodziejski
2c3dd03d26 fix warnings
svn-id: r12504
2004-01-18 20:57:46 +00:00
Oliver Kiehl
d794488645 fixed bug that was causing lots of havoc on BE machines. Thanks eriktorbjorn
svn-id: r12348
2004-01-12 20:04:22 +00:00
Torbjörn Andersson
7309705db5 cleanup
svn-id: r12322
2004-01-11 16:53:33 +00:00
Torbjörn Andersson
6d0dd6aee8 Valgrind fixes. Mostly about memory not being freed when the engine is
deleted.

svn-id: r12211
2004-01-07 07:42:00 +00:00
Torbjörn Andersson
065f2bb9eb It's a new year in BS2 land, too!
svn-id: r12181
2004-01-06 13:44:17 +00:00
Torbjörn Andersson
fa523f7f7e It was pointed out to me that we can't use the DEMO variable here, because
the missing file may be the one with the resource for the global variables.

svn-id: r12112
2004-01-03 14:49:52 +00:00
Torbjörn Andersson
ea39ef6d7d The game sets its own DEMO variable, so we might as well check that one as
checking the GF_DEMO flag. (There's still one "unnecessary" reference to
GF_DEMO in functions.cpp, but I plan on rewriting that function soon so I
don't want to touch it right now.)

svn-id: r12009
2003-12-29 15:30:10 +00:00
Torbjörn Andersson
6ae8218d53 Hopefully the last big renaming. Now the datatypes have names like
"StandardHeader" instead of "_standardHeader".

svn-id: r11997
2003-12-28 15:08:12 +00:00
Torbjörn Andersson
8b12be81e5 cleanup
svn-id: r11704
2003-12-17 08:01:59 +00:00
Torbjörn Andersson
5c539040e4 Shut up Valgrind warnings.
svn-id: r11528
2003-12-08 07:30:22 +00:00
Torbjörn Andersson
9fdaf04a21 Some formatting changes, and a few debug message corrections.
svn-id: r11384
2003-11-28 07:55:25 +00:00
Torbjörn Andersson
6f23e2c211 Mostly whitespace changes, but also a few modifications to the still
experimental resource dumping code.

svn-id: r11382
2003-11-27 07:34:19 +00:00
Torbjörn Andersson
509235e176 Added experimental (i.e. not tested) resource dumping code.
Added tentative workaround for the bug (a script bug, I think) that causes
the game to hang when examining the lift at the top of the pyramid.

And, of course, some misc. cleanup.

svn-id: r11359
2003-11-23 13:40:24 +00:00
Torbjörn Andersson
083c328077 Eliminated some more references to g_sword2. I think the only thing that
still uses it are the engine's global variables which, on the other hand,
are used *everywhere*.

I'll have to think some more about those. I guess I should take a closer
look at how the other engines handle them. (That goes for a lot of things
by the way.)

svn-id: r11349
2003-11-19 18:40:53 +00:00
Torbjörn Andersson
fa2b8ba8de More cleanup. I've eliminated all the temporary global variables I've added
over the past few weeks, except for g_sword2. (Of course, this doesn't
necessarily make the code any prettier, but we can work on that later.)

svn-id: r11309
2003-11-16 14:18:29 +00:00
Torbjörn Andersson
aaa5631a99 Mostly cleanup. Also prevented what would probably have been an infinite
loop if ScummVM failed to find a file in the demo. (Now it should error out
instead, which is marginally preferable.)

svn-id: r11298
2003-11-15 09:38:00 +00:00
Torbjörn Andersson
30670deb2c cleanup
svn-id: r11290
2003-11-14 07:41:22 +00:00
Torbjörn Andersson
66d9b4315a Re-enabled the CD swapping code, after rewriting it a bit.
If a cluster file isn't found the resource manager will first check if it's
one of the files that it expects to find on the hard disk. If so, it's
considered a fatal error.

Otherwise it will present the user with an "Insert CD1" or "Insert CD2"
message, just like the original did. Unlike the original, the user will
have to press a button or click the mouse to indicate when he's done. I
don't know if we even can detect the CD automatically in any portable way.

As far as I can see, we'll need at least two separate path settings for
this to actually work: one for the HD install directory, and one or two for
the CDs. The file that are supposed to be found on the HD are only on one
of the CDs, so the amount of CD swapping would probably be unbearable
otherwise.

As a consequence, I haven't actually tried running the game from CD yet.

By the way, the old caching code has been removed completely now. All it
did was to copy the cluster file to HD for faster access. ScummVM never did
that, but so far no one has complained.

svn-id: r11273
2003-11-13 07:59:52 +00:00
Torbjörn Andersson
c16d20c72f Slight refinement to the last patch. There are four different possibilities
for which CD to look for: 0 (both CDs - not used?), 1, 2 and 3 (not used?)

svn-id: r11263
2003-11-11 15:16:41 +00:00
Torbjörn Andersson
ce619b254e Extended the "res" debugger command to print information about where the
game expects to find the various cluster files. I plan to look into making
the game playable from CD, and this should help during the testing.

svn-id: r11262
2003-11-11 15:07:35 +00:00
Torbjörn Andersson
446a01ba09 Moved low-level keyboard and mouse handling to a new Input class, and
renamed the Display class Graphics for no better reason than me liking the
phrase "sound and graphics" better than "sound and display".

svn-id: r11258
2003-11-11 07:43:02 +00:00
Torbjörn Andersson
9106229bef Removed some now redundant header files.
svn-id: r11209
2003-11-08 18:15:35 +00:00
Torbjörn Andersson
688c80b062 Moved more stuff into classes, changed some static allocation to dynamic,
and removed some of the references to global variables.

At this point I believe everything in the main game engine has been moved
into classes - not necessarily the correct ones, but still... However,
there is some stuff in the driver directory that need to be taken care of
as well.

svn-id: r11207
2003-11-08 15:47:51 +00:00
Jonathan Gray
9a1cfe838f spelling fixes
svn-id: r11175
2003-11-07 01:36:53 +00:00