diff options
author | Max Horn | 2002-10-21 13:23:25 +0000 |
---|---|---|
committer | Max Horn | 2002-10-21 13:23:25 +0000 |
commit | 8af300fec3a760cc5c153c5be92134c1a99169a4 (patch) | |
tree | 422e11a861066b333615f602a0357944007c99e0 /simon | |
parent | 0006197cf11187fc9756c7aba5de239cf719c4a4 (diff) | |
download | scummvm-rg350-8af300fec3a760cc5c153c5be92134c1a99169a4.tar.gz scummvm-rg350-8af300fec3a760cc5c153c5be92134c1a99169a4.tar.bz2 scummvm-rg350-8af300fec3a760cc5c153c5be92134c1a99169a4.zip |
The terms Word and DWord are somewhat Windows centric; in fact there are systems on which word is 32bit, as opposed to our 16 bits. Hence, use the uin16/uint32 naming scheme, which is not ambigious
svn-id: r5216
Diffstat (limited to 'simon')
-rw-r--r-- | simon/midi.cpp | 21 | ||||
-rw-r--r-- | simon/res.cpp | 38 | ||||
-rw-r--r-- | simon/simon.cpp | 98 |
3 files changed, 79 insertions, 78 deletions
diff --git a/simon/midi.cpp b/simon/midi.cpp index f59d7c42cd..19d573a935 100644 --- a/simon/midi.cpp +++ b/simon/midi.cpp @@ -59,17 +59,17 @@ void MidiPlayer::read_mthd(File *in, Song *s, bool old) uint i; if (!old) { - if (in->readDwordBE() != 6) + if (in->readUint32BE() != 6) error("Invalid 'MThd' chunk size"); - s->midi_format = in->readWordBE(); - s->num_tracks = in->readWordBE(); - s->ppqn = in->readWordBE(); + s->midi_format = in->readUint16BE(); + s->num_tracks = in->readUint16BE(); + s->ppqn = in->readUint16BE(); } else { s->midi_format = 0; s->num_tracks = 1; s->ppqn = 0xc0; - in->readWordBE(); + in->readUint16BE(); in->readByte(); } @@ -79,10 +79,11 @@ void MidiPlayer::read_mthd(File *in, Song *s, bool old) for (i = 0; i != s->num_tracks; i++, t++) { if (!old) { - if (in->readDwordBE() != 'MTrk') - error("Midi track has no 'MTrk'"); + uint32 foo = in->readUint32BE(); + if (foo != 'MTrk') + error("Midi track has no 'MTrk' (%d, %08x)", i, foo); - t->data_size = in->readDwordLE(); + t->data_size = in->readUint32LE(); } else { uint32 pos = in->pos(); in->seek(0, SEEK_END); @@ -93,7 +94,7 @@ void MidiPlayer::read_mthd(File *in, Song *s, bool old) t->data_ptr = (byte *)calloc(t->data_size, 1); if (t->data_ptr == NULL) - error("Out of memory when allocating MIDI track data"); + error("Out of memory when allocating MIDI track data (%d)", t->data_size); in->read(t->data_ptr, t->data_size); @@ -122,7 +123,7 @@ void MidiPlayer::read_one_song(File *in, Song *s) s->num_tracks = 0; s->tracks = NULL; - uint32 id = in->readDwordBE(); + uint32 id = in->readUint32BE(); switch (id) { case 'MThd': diff --git a/simon/res.cpp b/simon/res.cpp index ad66db8895..6cf2d219c4 100644 --- a/simon/res.cpp +++ b/simon/res.cpp @@ -156,7 +156,7 @@ void SimonState::readGamePcText(File *in) uint text_size; byte *text_mem; - _text_size = text_size = in->readDwordBE(); + _text_size = text_size = in->readUint32BE(); text_mem = (byte *)malloc(text_size); if (text_mem == NULL) error("Out of text memory"); @@ -170,19 +170,19 @@ void SimonState::readItemFromGamePc(File *in, Item *item) { uint32 type; - item->unk2 = in->readWordBE(); - item->unk1 = in->readWordBE(); - item->unk3 = in->readWordBE(); + item->unk2 = in->readUint16BE(); + item->unk1 = in->readUint16BE(); + item->unk3 = in->readUint16BE(); item->sibling = (uint16)fileReadItemID(in); item->child = (uint16)fileReadItemID(in); item->parent = (uint16)fileReadItemID(in); - in->readWordBE(); - item->unk4 = in->readWordBE(); + in->readUint16BE(); + item->unk4 = in->readUint16BE(); item->children = NULL; - type = in->readDwordBE(); + type = in->readUint32BE(); while (type) { - type = in->readWordBE(); + type = in->readUint16BE(); if (type != 0) readItemChildren(in, item, type); } @@ -191,8 +191,8 @@ void SimonState::readItemFromGamePc(File *in, Item *item) void SimonState::readItemChildren(File *in, Item *item, uint type) { if (type == 1) { - uint fr1 = in->readWordBE(); - uint fr2 = in->readWordBE(); + uint fr1 = in->readUint16BE(); + uint fr2 = in->readUint16BE(); uint i, size; uint j, k; Child1 *child; @@ -210,7 +210,7 @@ void SimonState::readItemChildren(File *in, Item *item, uint type) if (j & 3) child->array[k++] = (uint16)fileReadItemID(in); } else if (type == 2) { - uint32 fr = in->readDwordBE(); + uint32 fr = in->readUint32BE(); uint i, k, size; Child2 *child; @@ -224,13 +224,13 @@ void SimonState::readItemChildren(File *in, Item *item, uint type) k = 0; if (fr & 1) { - child->array[k++] = (uint16)in->readDwordBE(); + child->array[k++] = (uint16)in->readUint32BE(); } for (i = 1; i != 16; i++) if (fr & (1 << i)) - child->array[k++] = in->readWordBE(); + child->array[k++] = in->readUint16BE(); - child->string_id = (uint16)in->readDwordBE(); + child->string_id = (uint16)in->readUint32BE(); } else { error("readItemChildren: invalid mode"); } @@ -238,7 +238,7 @@ void SimonState::readItemChildren(File *in, Item *item, uint type) uint fileReadItemID(File *in) { - uint32 val = in->readDwordBE(); + uint32 val = in->readUint32BE(); if (val == 0xFFFFFFFF) return 0; return val + 2; @@ -288,7 +288,7 @@ byte *SimonState::readSingleOpcode(File *in, byte *ptr) case 'n': case 'p': case 'v': - val = in->readWordBE(); + val = in->readUint16BE(); *ptr++ = val >> 8; *ptr++ = val & 255; break; @@ -301,7 +301,7 @@ byte *SimonState::readSingleOpcode(File *in, byte *ptr) break; case 'I': - val = in->readWordBE(); + val = in->readUint16BE(); switch (val) { case 1: val = 0xFFFF; @@ -326,7 +326,7 @@ byte *SimonState::readSingleOpcode(File *in, byte *ptr) break; case 'T': - val = in->readWordBE(); + val = in->readUint16BE(); switch (val) { case 0: val = 0xFFFF; @@ -335,7 +335,7 @@ byte *SimonState::readSingleOpcode(File *in, byte *ptr) val = 0xFFFD; break; default: - val = (uint16)in->readDwordBE(); + val = (uint16)in->readUint32BE(); break; } *ptr++ = val >> 8; diff --git a/simon/simon.cpp b/simon/simon.cpp index cefc4bc0a2..65469215ad 100644 --- a/simon/simon.cpp +++ b/simon/simon.cpp @@ -190,10 +190,10 @@ int SimonState::allocGamePcVars(File *in) uint32 version; uint i; - item_array_size = in->readDwordBE(); - version = in->readDwordBE(); - item_array_inited = in->readDwordBE(); - stringtable_num = in->readDwordBE(); + item_array_size = in->readUint32BE(); + version = in->readUint32BE(); + item_array_inited = in->readUint32BE(); + stringtable_num = in->readUint32BE(); item_array_inited += 2; /* first two items are predefined */ item_array_size += 2; @@ -297,14 +297,14 @@ void SimonState::readSubroutineLine(File *in, SubroutineLine *sl, Subroutine *su int size; if (sub->id == 0) { - sl->cond_a = in->readWordBE(); - sl->cond_b = in->readWordBE(); - sl->cond_c = in->readWordBE(); + sl->cond_a = in->readUint16BE(); + sl->cond_b = in->readUint16BE(); + sl->cond_c = in->readUint16BE(); } while ((*q = in->readByte()) != 0xFF) { if (*q == 87) { - in->readWordBE(); + in->readUint16BE(); } else { q = readSingleOpcode(in, q); } @@ -351,7 +351,7 @@ SubroutineLine *SimonState::createSubroutineLine(Subroutine *sub, int where) void SimonState::readSubroutine(File *in, Subroutine *sub) { - while (in->readWordBE() == 0) { + while (in->readUint16BE() == 0) { readSubroutineLine(in, createSubroutineLine(sub, 0xFFFF), sub); } } @@ -372,8 +372,8 @@ Subroutine *SimonState::createSubroutine(uint id) void SimonState::readSubroutineBlock(File *in) { - while (in->readWordBE() == 0) { - readSubroutine(in, createSubroutine(in->readWordBE())); + while (in->readUint16BE() == 0) { + readSubroutine(in, createSubroutine(in->readUint16BE())); } } @@ -4436,34 +4436,34 @@ bool SimonState::save_game(uint slot, const char *caption) f.write((char*)caption, 0x12); - f.writeDwordBE(_itemarray_inited - 1); - f.writeDwordBE(0xFFFFFFFF); - f.writeDwordBE(0); - f.writeDwordBE(0); + f.writeUint32BE(_itemarray_inited - 1); + f.writeUint32BE(0xFFFFFFFF); + f.writeUint32BE(0); + f.writeUint32BE(0); i = 0; for (te = _first_time_struct; te; te = te->next) i++; - f.writeDwordBE(i); + f.writeUint32BE(i); for (te = _first_time_struct; te; te = te->next) { - f.writeDwordBE(te->time + _base_time); - f.writeWordBE(te->subroutine_id); + f.writeUint32BE(te->time + _base_time); + f.writeUint16BE(te->subroutine_id); } item_index = 1; for (num_item = _itemarray_inited - 1; num_item; num_item--) { Item *item = _itemarray_ptr[item_index++]; - f.writeWordBE(item->parent); - f.writeWordBE(item->sibling); - f.writeWordBE(item->unk3); - f.writeWordBE(item->unk4); + f.writeUint16BE(item->parent); + f.writeUint16BE(item->sibling); + f.writeUint16BE(item->unk3); + f.writeUint16BE(item->unk4); { Child1 *child1 = findChildOfType1(item); if (child1) { - f.writeWordBE(child1->fr2); + f.writeUint16BE(child1->fr2); } } @@ -4472,12 +4472,12 @@ bool SimonState::save_game(uint slot, const char *caption) uint i, j; if (child2) { - f.writeDwordBE(child2->avail_props); + f.writeUint32BE(child2->avail_props); i = child2->avail_props & 1; for (j = 1; j < 16; j++) { if ((1 << j) & child2->avail_props) { - f.writeWordBE(child2->array[i++]); + f.writeUint16BE(child2->array[i++]); } } } @@ -4488,7 +4488,7 @@ bool SimonState::save_game(uint slot, const char *caption) if (child9) { uint i; for (i = 0; i != 4; i++) { - f.writeWordBE(child9->array[i]); + f.writeUint16BE(child9->array[i]); } } } @@ -4496,17 +4496,17 @@ bool SimonState::save_game(uint slot, const char *caption) /* write the 255 variables */ for (i = 0; i != 255; i++) { - f.writeWordBE(readVariable(i)); + f.writeUint16BE(readVariable(i)); } /* write the items in array 6 */ for (i = 0; i != 10; i++) { - f.writeWordBE(itemPtrToID(_item_array_6[i])); + f.writeUint16BE(itemPtrToID(_item_array_6[i])); } /* Write the bits in array 1 & 2 */ for (i = 0; i != 32; i++) - f.writeWordBE(_bit_array[i]); + f.writeUint16BE(_bit_array[i]); f.close(); @@ -4543,24 +4543,24 @@ bool SimonState::load_game(uint slot) f.read(ident, 18); - num = f.readDwordBE(); + num = f.readUint32BE(); - if (f.readDwordBE() != 0xFFFFFFFF || num != _itemarray_inited - 1) { + if (f.readUint32BE() != 0xFFFFFFFF || num != _itemarray_inited - 1) { f.close(); _lock_word &= ~0x100; return false; } - f.readDwordBE(); - f.readDwordBE(); + f.readUint32BE(); + f.readUint32BE(); _no_parent_notify = true; /* add all timers */ killAllTimers(); - for (num = f.readDwordBE(); num; num--) { - uint32 timeout = f.readDwordBE(); - uint16 func_to_call = f.readWordBE(); + for (num = f.readUint32BE(); num; num--) { + uint32 timeout = f.readUint32BE(); + uint16 func_to_call = f.readUint16BE(); addTimeEvent(timeout, func_to_call); } @@ -4568,8 +4568,8 @@ bool SimonState::load_game(uint slot) for (num = _itemarray_inited - 1; num; num--) { Item *item = _itemarray_ptr[item_index++], *parent_item; - uint parent = f.readWordBE(); - uint sibling = f.readWordBE(); + uint parent = f.readUint16BE(); + uint sibling = f.readUint16BE(); parent_item = derefItem(parent); @@ -4580,13 +4580,13 @@ bool SimonState::load_game(uint slot) item->sibling = sibling; } - item->unk3 = f.readWordBE(); - item->unk4 = f.readWordBE(); + item->unk3 = f.readUint16BE(); + item->unk4 = f.readUint16BE(); { Child1 *child1 = findChildOfType1(item); if (child1 != NULL) { - child1->fr2 = f.readWordBE(); + child1->fr2 = f.readUint16BE(); } } @@ -4594,12 +4594,12 @@ bool SimonState::load_game(uint slot) Child2 *child2 = findChildOfType2(item); uint i, j; if (child2 != NULL) { - child2->avail_props = f.readDwordBE(); + child2->avail_props = f.readUint32BE(); i = child2->avail_props & 1; for (j = 1; j < 16; j++) { if ((1 << j) & child2->avail_props) { - child2->array[i++] = f.readWordBE(); + child2->array[i++] = f.readUint16BE(); } } } @@ -4610,7 +4610,7 @@ bool SimonState::load_game(uint slot) if (child9) { uint i; for (i = 0; i != 4; i++) { - child9->array[i] = f.readWordBE(); + child9->array[i] = f.readUint16BE(); } } } @@ -4619,17 +4619,17 @@ bool SimonState::load_game(uint slot) /* read the 255 variables */ for (i = 0; i != 255; i++) { - writeVariable(i, f.readWordBE()); + writeVariable(i, f.readUint16BE()); } /* write the items in array 6 */ for (i = 0; i != 10; i++) { - _item_array_6[i] = derefItem(f.readWordBE()); + _item_array_6[i] = derefItem(f.readUint16BE()); } /* Write the bits in array 1 & 2 */ for (i = 0; i != 32; i++) - _bit_array[i] = f.readWordBE(); + _bit_array[i] = f.readUint16BE(); f.close(); @@ -4761,8 +4761,8 @@ void SimonState::playVoice(uint voice) _voice_file->seek(READ_LE_UINT32(&wave_hdr.size) - sizeof(wave_hdr) + 20, SEEK_CUR); - data[0] = _voice_file->readDwordLE(); - data[1] = _voice_file->readDwordLE(); + data[0] = _voice_file->readUint32LE(); + data[1] = _voice_file->readUint32LE(); if ( //fread(data, sizeof(data), 1, _voice_file) != 1 || data[0] != 'atad') { warning("playVoice(%d): cannot read data header", voice); |