SCUMM: Implement basic basketball court data parsing

This commit is contained in:
Matthew Hoops 2011-08-12 16:41:16 -04:00
parent b631104fd0
commit c109a60a92
2 changed files with 92 additions and 0 deletions

View File

@ -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
*

View File

@ -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 {