aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Hoops2011-08-12 16:41:16 -0400
committerMatthew Hoops2011-08-12 16:41:48 -0400
commitc109a60a9233bfe6f30475abf4814ad5c6bc2f70 (patch)
treece0720f05a44d5fa1d174f743f60e2ac7141d604
parentb631104fd0220190841423614156b76334f59f39 (diff)
downloadscummvm-rg350-c109a60a9233bfe6f30475abf4814ad5c6bc2f70.tar.gz
scummvm-rg350-c109a60a9233bfe6f30475abf4814ad5c6bc2f70.tar.bz2
scummvm-rg350-c109a60a9233bfe6f30475abf4814ad5c6bc2f70.zip
SCUMM: Implement basic basketball court data parsing
-rw-r--r--engines/scumm/he/logic_he.cpp73
-rw-r--r--engines/scumm/he/logic_he.h19
2 files changed, 92 insertions, 0 deletions
diff --git a/engines/scumm/he/logic_he.cpp b/engines/scumm/he/logic_he.cpp
index ffdc365d2d..495af1c217 100644
--- a/engines/scumm/he/logic_he.cpp
+++ b/engines/scumm/he/logic_he.cpp
@@ -1393,6 +1393,7 @@ int32 LogicHEbasketball::dispatch(int op, int numArgs, int32 *args) {
break;
case 1050:
+ res = op_1050(args);
break;
case 1051:
@@ -1401,6 +1402,10 @@ int32 LogicHEbasketball::dispatch(int op, int numArgs, int32 *args) {
case 1052:
break;
+ case 1053:
+ res = op_1053();
+ break;
+
case 1056:
break;
@@ -1459,6 +1464,74 @@ int LogicHEbasketball::op_1012() {
return 1;
}
+int LogicHEbasketball::op_1050(int32 *args) {
+ // This function loads the court data
+ static const char *courtNames[] = {
+ "Dobbaguchi", "Jocindas", "SandyFlats", "Queens",
+ "Park", "Scheffler", "Polk", "McMillan",
+ "CrownHill", "Memorial", "TechState", "Garden",
+ "Moon", "Barn"
+ };
+
+ Common::String courtFileName = Common::String::format("data/courts/%s.cof", courtNames[args[0] - 1]);
+
+ Common::File file;
+ if (!file.open(courtFileName))
+ error("Could not open file '%s'", courtFileName.c_str());
+
+ debug(0, "Loading court data from '%s'", courtFileName.c_str());
+
+ // First, read in the header
+ file.readUint32LE(); // Header size (?)
+
+ char version[6];
+ file.read(version, 5);
+ version[5] = 0;
+
+ if (strcmp(version, "01.05"))
+ error("Invalid court version field: %s", version);
+
+ uint32 objectCount = file.readUint32LE();
+
+ for (uint32 i = 0; i < objectCount; i++) {
+ char nameBuf[100];
+ memset(nameBuf, 0, sizeof(nameBuf));
+
+ uint32 nameLength = file.readUint32LE();
+ assert(nameLength < sizeof(nameBuf) - 1);
+ file.read(nameBuf, nameLength);
+
+ CourtObject object;
+ object.name = nameBuf;
+ object.type = (CourtObjectType)file.readUint32LE();
+ for (uint32 j = 0; j < 10; j++)
+ object.data[j] = file.readUint32LE();
+
+ debug(1, "Found court object '%s' - Type %d", nameBuf, object.type);
+
+ // Store backboard object indices for later
+ if (object.type == kObjectTypeBackboard) {
+ if (object.data[7] + object.data[4] / 2 >= 6000)
+ _backboardObjectRight = i;
+ else
+ _backboardObjectLeft = i;
+ }
+
+ _courtObjects.push_back(object);
+ }
+
+ // TODO: Some other variables are initialized with constants here
+
+ return 1;
+}
+
+int LogicHEbasketball::op_1053() {
+ _courtObjects.clear();
+ // TODO: This also calls op_1065 with one argument (5)
+
+ return 1;
+}
+
/***********************
* Moonbase Commander
*
diff --git a/engines/scumm/he/logic_he.h b/engines/scumm/he/logic_he.h
index e649a93e72..4e0d084325 100644
--- a/engines/scumm/he/logic_he.h
+++ b/engines/scumm/he/logic_he.h
@@ -177,6 +177,25 @@ public:
private:
int op_1012();
+ int op_1050(int32 *args);
+ int op_1053();
+
+ // op_1050 loads court object data
+ enum CourtObjectType {
+ kObjectTypeBackboard = 1,
+ kObjectTypeRim = 2,
+ kObjectTypeOther = 3,
+ kObjectTypeFloor = 4
+ };
+
+ struct CourtObject {
+ Common::String name;
+ CourtObjectType type;
+ uint32 data[10];
+ };
+
+ Common::Array<CourtObject> _courtObjects;
+ uint32 _backboardObjectLeft, _backboardObjectRight;
};
class LogicHEmoonbase : public LogicHE {