diff options
-rw-r--r-- | saga/objectmap.cpp | 26 | ||||
-rw-r--r-- | saga/palanim.cpp | 16 | ||||
-rw-r--r-- | saga/rscfile.cpp | 12 | ||||
-rw-r--r-- | saga/scene.cpp | 28 | ||||
-rw-r--r-- | saga/script.cpp | 40 | ||||
-rw-r--r-- | saga/sdebug.cpp | 107 | ||||
-rw-r--r-- | saga/sndres.cpp | 32 | ||||
-rw-r--r-- | saga/sprite.cpp | 36 | ||||
-rw-r--r-- | saga/sthread.cpp | 110 |
9 files changed, 203 insertions, 204 deletions
diff --git a/saga/objectmap.cpp b/saga/objectmap.cpp index 254c11a649..18ce29279b 100644 --- a/saga/objectmap.cpp +++ b/saga/objectmap.cpp @@ -79,7 +79,7 @@ int OBJECTMAP_Load(const byte *om_res, size_t om_res_len) { int i, k, m; - MemoryReadStream *readS = new MemoryReadStream(om_res, om_res_len); + MemoryReadStream readS(om_res, om_res_len); if (!OMInfo.initialized) { warning("Error: Object map module not initialized"); @@ -91,7 +91,7 @@ int OBJECTMAP_Load(const byte *om_res, size_t om_res_len) { } // Obtain object count N and allocate space for N objects - OMInfo.n_objects = readS->readUint16LE(); + OMInfo.n_objects = readS.readUint16LE(); OMInfo.object_maps = (R_OBJECTMAP_ENTRY *)malloc(OMInfo.n_objects * sizeof *OMInfo.object_maps); @@ -103,11 +103,11 @@ int OBJECTMAP_Load(const byte *om_res, size_t om_res_len) { // Load all N objects for (i = 0; i < OMInfo.n_objects; i++) { object_map = &OMInfo.object_maps[i]; - object_map->unknown0 = readS->readByte(); - object_map->n_clickareas = readS->readByte(); - object_map->flags = readS->readUint16LE(); - object_map->object_num = readS->readUint16LE(); - object_map->script_num = readS->readUint16LE(); + object_map->unknown0 = readS.readByte(); + object_map->n_clickareas = readS.readByte(); + object_map->flags = readS.readUint16LE(); + object_map->object_num = readS.readUint16LE(); + object_map->script_num = readS.readUint16LE(); object_map->clickareas = (R_CLICKAREA *)malloc(object_map->n_clickareas * sizeof *(object_map->clickareas)); if (object_map->clickareas == NULL) { @@ -118,7 +118,7 @@ int OBJECTMAP_Load(const byte *om_res, size_t om_res_len) { // Load all clickareas for this object for (k = 0; k < object_map->n_clickareas; k++) { clickarea = &object_map->clickareas[k]; - clickarea->n_points = readS->readUint16LE(); + clickarea->n_points = readS.readUint16LE(); assert(clickarea->n_points != 0); clickarea->points = (R_POINT *)malloc(clickarea->n_points * sizeof *(clickarea->points)); @@ -130,8 +130,8 @@ int OBJECTMAP_Load(const byte *om_res, size_t om_res_len) { // Load all points for this clickarea for (m = 0; m < clickarea->n_points; m++) { point = &clickarea->points[m]; - point->x = readS->readSint16LE(); - point->y = readS->readSint16LE(); + point->x = readS.readSint16LE(); + point->y = readS.readSint16LE(); } debug(2, "OBJECTMAP_Load(): Read %d points for clickarea %d in object %d.", clickarea->n_points, k, object_map->object_num); @@ -180,13 +180,13 @@ int OBJECTMAP_LoadNames(const unsigned char *onl_res, size_t onl_res_len) { int i; - MemoryReadStream *readS = new MemoryReadStream(onl_res, onl_res_len); + MemoryReadStream readS(onl_res, onl_res_len); if (OMInfo.names_loaded) { OBJECTMAP_FreeNames(); } - table_len = readS->readUint16LE(); + table_len = readS.readUint16LE(); n_names = table_len / 2 - 2; OMInfo.n_names = n_names; @@ -200,7 +200,7 @@ int OBJECTMAP_LoadNames(const unsigned char *onl_res, size_t onl_res_len) { } for (i = 0; i < n_names; i++) { - name_offset = readS->readUint16LE(); + name_offset = readS.readUint16LE(); OMInfo.names[i] = (const char *)(onl_res + name_offset); debug(3, "Loaded object name string: %s", OMInfo.names[i]); diff --git a/saga/palanim.cpp b/saga/palanim.cpp index 6cd8ee89e5..2dfa96b78c 100644 --- a/saga/palanim.cpp +++ b/saga/palanim.cpp @@ -48,13 +48,13 @@ int PALANIM_Load(const byte *resdata, size_t resdata_len) { return R_FAILURE; } - MemoryReadStream *readS = new MemoryReadStream(resdata, resdata_len); + MemoryReadStream readS(resdata, resdata_len); if (GAME_GetGameType() == R_GAMETYPE_IHNM) { return R_SUCCESS; } - PAnimData.entry_count = readS->readUint16LE(); + PAnimData.entry_count = readS.readUint16LE(); debug(0, "PALANIM_Load(): Loading %d PALANIM entries.", PAnimData.entry_count); @@ -71,8 +71,8 @@ int PALANIM_Load(const byte *resdata, size_t resdata_len) { int pal_count; int p, c; - color_count = readS->readUint16LE(); - pal_count = readS->readUint16LE(); + color_count = readS.readUint16LE(); + pal_count = readS.readUint16LE(); PAnimData.entries[i].pal_count = pal_count; PAnimData.entries[i].color_count = color_count; @@ -98,13 +98,13 @@ int PALANIM_Load(const byte *resdata, size_t resdata_len) { PAnimData.entries[i].colors = (R_COLOR *)test_p; for (p = 0; p < pal_count; p++) { - PAnimData.entries[i].pal_index[p] = readS->readByte(); + PAnimData.entries[i].pal_index[p] = readS.readByte(); } for (c = 0; c < color_count; c++) { - PAnimData.entries[i].colors[c].red = readS->readByte(); - PAnimData.entries[i].colors[c].green = readS->readByte(); - PAnimData.entries[i].colors[c].blue = readS->readByte(); + PAnimData.entries[i].colors[c].red = readS.readByte(); + PAnimData.entries[i].colors[c].green = readS.readByte(); + PAnimData.entries[i].colors[c].blue = readS.readByte(); } } diff --git a/saga/rscfile.cpp b/saga/rscfile.cpp index afbac86585..f38aa9d321 100644 --- a/saga/rscfile.cpp +++ b/saga/rscfile.cpp @@ -113,10 +113,10 @@ int RSC_LoadRSC(R_RSCFILE_CONTEXT *rsc) { return R_FAILURE; } - MemoryReadStream *readS = new MemoryReadStream(tblinfo_buf, RSC_TABLEINFO_SIZE); + MemoryReadStream readS(tblinfo_buf, RSC_TABLEINFO_SIZE); - res_tbl_offset = readS->readUint32LE(); - res_tbl_ct = readS->readUint32LE(); + res_tbl_offset = readS.readUint32LE(); + res_tbl_ct = readS.readUint32LE(); // Check for sane table offset if (res_tbl_offset != rsc->rc_file.size() - RSC_TABLEINFO_SIZE - RSC_TABLEENTRY_SIZE * res_tbl_ct) { @@ -145,11 +145,11 @@ int RSC_LoadRSC(R_RSCFILE_CONTEXT *rsc) { return R_FAILURE; } - readS = new MemoryReadStream(tbl_buf, tbl_len); + MemoryReadStream readS1(tbl_buf, tbl_len); for (i = 0; i < res_tbl_ct; i++) { - rsc_restbl[i].res_offset = readS->readUint32LE(); - rsc_restbl[i].res_size = readS->readUint32LE(); + rsc_restbl[i].res_offset = readS1.readUint32LE(); + rsc_restbl[i].res_size = readS1.readUint32LE(); if ((rsc_restbl[i].res_offset > rsc->rc_file.size()) || (rsc_restbl[i].res_size > rsc->rc_file.size())) { free(tbl_buf); free(rsc_restbl); diff --git a/saga/scene.cpp b/saga/scene.cpp index 97150f5699..7ae33da15b 100644 --- a/saga/scene.cpp +++ b/saga/scene.cpp @@ -97,10 +97,10 @@ int SCENE_Init() { return R_MEM; } - MemoryReadStream *readS = new MemoryReadStream(scene_lut_p, scene_lut_len); + MemoryReadStream readS(scene_lut_p, scene_lut_len); for (i = 0; i < SceneModule.scene_max; i++) { - SceneModule.scene_lut[i] = readS->readUint16LE(); + SceneModule.scene_lut[i] = readS.readUint16LE(); } free(scene_lut_p); @@ -507,16 +507,16 @@ int LoadSceneDescriptor(uint32 res_number) { return R_FAILURE; } - MemoryReadStream *readS = new MemoryReadStream(scene_desc_data, scene_desc_len); + MemoryReadStream readS(scene_desc_data, scene_desc_len); - SceneModule.desc.unknown0 = readS->readUint16LE(); - SceneModule.desc.res_list_rn = readS->readUint16LE(); - SceneModule.desc.end_slope = readS->readUint16LE(); - SceneModule.desc.begin_slope = readS->readUint16LE(); - SceneModule.desc.script_num = readS->readUint16LE(); - SceneModule.desc.scene_scriptnum = readS->readUint16LE(); - SceneModule.desc.start_scriptnum = readS->readUint16LE(); - SceneModule.desc.music_rn = readS->readSint16LE(); + SceneModule.desc.unknown0 = readS.readUint16LE(); + SceneModule.desc.res_list_rn = readS.readUint16LE(); + SceneModule.desc.end_slope = readS.readUint16LE(); + SceneModule.desc.begin_slope = readS.readUint16LE(); + SceneModule.desc.script_num = readS.readUint16LE(); + SceneModule.desc.scene_scriptnum = readS.readUint16LE(); + SceneModule.desc.start_scriptnum = readS.readUint16LE(); + SceneModule.desc.music_rn = readS.readSint16LE(); RSC_FreeResource(scene_desc_data); @@ -536,7 +536,7 @@ int LoadSceneResourceList(uint32 reslist_rn) { return R_FAILURE; } - MemoryReadStream *readS = new MemoryReadStream(resource_list, resource_list_len); + MemoryReadStream readS(resource_list, resource_list_len); // Allocate memory for scene resource list SceneModule.reslist_entries = resource_list_len / SAGA_RESLIST_ENTRY_LEN; @@ -553,8 +553,8 @@ int LoadSceneResourceList(uint32 reslist_rn) { debug(0, "Loading scene resource list..."); for (i = 0; i < SceneModule.reslist_entries; i++) { - SceneModule.reslist[i].res_number = readS->readUint16LE(); - SceneModule.reslist[i].res_type = readS->readUint16LE(); + SceneModule.reslist[i].res_number = readS.readUint16LE(); + SceneModule.reslist[i].res_type = readS.readUint16LE(); } RSC_FreeResource(resource_list); diff --git a/saga/script.cpp b/saga/script.cpp index de692d0485..b3ebae9fa5 100644 --- a/saga/script.cpp +++ b/saga/script.cpp @@ -109,15 +109,15 @@ Script::Script() { } // Convert LUT resource to logical LUT - MemoryReadStream *readS = new MemoryReadStream(rsc_ptr, rsc_len); + MemoryReadStream readS(rsc_ptr, rsc_len); for (i = 0; i < _script_lut_max; i++) { - prevTell = readS->pos(); - _script_lut[i].script_rn = readS->readUint16LE(); - _script_lut[i].diag_list_rn = readS->readUint16LE(); - _script_lut[i].voice_lut_rn = readS->readUint16LE(); + prevTell = readS.pos(); + _script_lut[i].script_rn = readS.readUint16LE(); + _script_lut[i].diag_list_rn = readS.readUint16LE(); + _script_lut[i].voice_lut_rn = readS.readUint16LE(); // Skip the unused portion of the structure - for (j = readS->pos(); j < prevTell + _script_lut_entrylen; j++) - readS->readByte(); + for (j = readS.pos(); j < prevTell + _script_lut_entrylen; j++) + readS.readByte(); } RSC_FreeResource(rsc_ptr); @@ -328,12 +328,12 @@ R_SCRIPT_BYTECODE *Script::loadBytecode(byte *bytecode_p, size_t bytecode_len) { debug(0, "Loading script bytecode..."); - MemoryReadStream *readS = new MemoryReadStream(bytecode_p, bytecode_len); + MemoryReadStream readS(bytecode_p, bytecode_len); // The first two uint32 values are the number of entrypoints, and the // offset to the entrypoint table, respectively. - n_entrypoints = readS->readUint32LE(); - ep_tbl_offset = readS->readUint32LE(); + n_entrypoints = readS.readUint32LE(); + ep_tbl_offset = readS.readUint32LE(); // Check that the entrypoint table offset is valid. if ((bytecode_len - ep_tbl_offset) < (n_entrypoints * R_SCRIPT_TBLENTRY_LEN)) { @@ -364,15 +364,15 @@ R_SCRIPT_BYTECODE *Script::loadBytecode(byte *bytecode_p, size_t bytecode_len) { // Read in the entrypoint table - while (readS->pos() < ep_tbl_offset) - readS->readByte(); + while (readS.pos() < ep_tbl_offset) + readS.readByte(); for (i = 0; i < n_entrypoints; i++) { // First uint16 is the offset of the entrypoint name from the start // of the bytecode resource, second uint16 is the offset of the // bytecode itself for said entrypoint - bc_ep_tbl[i].name_offset = readS->readUint16LE(); - bc_ep_tbl[i].offset = readS->readUint16LE(); + bc_ep_tbl[i].name_offset = readS.readUint16LE(); + bc_ep_tbl[i].offset = readS.readUint16LE(); // Perform a simple range check on offset values if ((bc_ep_tbl[i].name_offset > bytecode_len) || (bc_ep_tbl[i].offset > bytecode_len)) { @@ -409,10 +409,10 @@ R_DIALOGUE_LIST *Script::loadDialogue(const byte *dialogue_p, size_t dialogue_le return NULL; } - MemoryReadStream *readS = new MemoryReadStream(dialogue_p, dialogue_len); + MemoryReadStream readS(dialogue_p, dialogue_len); // First uint16 is the offset of the first string - offset = readS->readUint16LE(); + offset = readS.readUint16LE(); if (offset > dialogue_len) { warning("Error, invalid string offset"); return NULL; @@ -438,9 +438,9 @@ R_DIALOGUE_LIST *Script::loadDialogue(const byte *dialogue_p, size_t dialogue_le } // Read in tables from dialogue list resource - readS->seek(0); + readS.seek(0); for (i = 0; i < n_dialogue; i++) { - offset = readS->readUint16LE(); + offset = readS.readUint16LE(); if (offset > dialogue_len) { warning("Error, invalid string offset"); free(dialogue_list->str); @@ -480,10 +480,10 @@ R_VOICE_LUT *Script::loadVoiceLUT(const byte *voicelut_p, size_t voicelut_len, R return NULL; } - MemoryReadStream *readS = new MemoryReadStream(voicelut_p, voicelut_len); + MemoryReadStream readS(voicelut_p, voicelut_len); for (i = 0; i < n_voices; i++) { - voice_lut->voices[i] = readS->readUint16LE(); + voice_lut->voices[i] = readS.readUint16LE(); } return voice_lut; diff --git a/saga/sdebug.cpp b/saga/sdebug.cpp index 8e88fb5afd..034375777c 100644 --- a/saga/sdebug.cpp +++ b/saga/sdebug.cpp @@ -68,12 +68,11 @@ int SDEBUG_PrintInstr(R_SCRIPT_THREAD *thread) { tl_e.display = 1; // XXX - MemoryReadStream *readS = - new MemoryReadStream(_vm->_script->_current_script->bytecode->bytecode_p + MemoryReadStream readS(_vm->_script->_current_script->bytecode->bytecode_p + thread->i_offset, _vm->_script->_current_script->bytecode->bytecode_len - thread->i_offset); - in_char = readS->readByte(); + in_char = readS.readByte(); sprintf(tmp_buf, "%04lX | %02X | ", thread->i_offset, in_char); strncat(disp_buf, tmp_buf, SD_DISPLAY_LEN); @@ -104,7 +103,7 @@ int SDEBUG_PrintInstr(R_SCRIPT_THREAD *thread) { int param; SD_ADDTXT("PSHD | "); - param = readS->readUint16LE(); + param = readS.readUint16LE(); sprintf(tmp_buf, "%02X", param); SD_ADDTXT(tmp_buf); /* @@ -123,7 +122,7 @@ int SDEBUG_PrintInstr(R_SCRIPT_THREAD *thread) { int param; SD_ADDTXT("PUSH | "); - param = readS->readUint16LE(); + param = readS.readUint16LE(); sprintf(tmp_buf, "%04X", param); SD_ADDTXT(tmp_buf); } @@ -135,8 +134,8 @@ int SDEBUG_PrintInstr(R_SCRIPT_THREAD *thread) { int param2; SD_ADDTXT("TSTF | "); - param1 = readS->readByte(); - param2 = readS->readUint16LE(); + param1 = readS.readByte(); + param2 = readS.readUint16LE(); sprintf(tmp_buf, "%02X %04X", param1, param2); SD_ADDTXT(tmp_buf); } @@ -148,8 +147,8 @@ int SDEBUG_PrintInstr(R_SCRIPT_THREAD *thread) { int param2; SD_ADDTXT("GETW | "); - param1 = readS->readByte(); - param2 = readS->readUint16LE(); + param1 = readS.readByte(); + param2 = readS.readUint16LE(); sprintf(tmp_buf, "%02X %04X", param1, param2); SD_ADDTXT(tmp_buf); } @@ -161,8 +160,8 @@ int SDEBUG_PrintInstr(R_SCRIPT_THREAD *thread) { int param2; SD_ADDTXT("MODF | "); - param1 = readS->readByte(); - param2 = readS->readUint16LE(); + param1 = readS.readByte(); + param2 = readS.readUint16LE(); sprintf(tmp_buf, "%02X %04X", param1, param2); SD_ADDTXT(tmp_buf); } @@ -174,8 +173,8 @@ int SDEBUG_PrintInstr(R_SCRIPT_THREAD *thread) { int param2; SD_ADDTXT("PUTW | "); - param1 = readS->readByte(); - param2 = readS->readUint16LE(); + param1 = readS.readByte(); + param2 = readS.readUint16LE(); sprintf(tmp_buf, "%02X %04X", param1, param2); SD_ADDTXT(tmp_buf); } @@ -187,8 +186,8 @@ int SDEBUG_PrintInstr(R_SCRIPT_THREAD *thread) { int param2; SD_ADDTXT("MDFP | "); - param1 = readS->readByte(); - param2 = readS->readUint16LE(); + param1 = readS.readByte(); + param2 = readS.readUint16LE(); sprintf(tmp_buf, "%02X %04X", param1, param2); SD_ADDTXT(tmp_buf); } @@ -200,8 +199,8 @@ int SDEBUG_PrintInstr(R_SCRIPT_THREAD *thread) { int param2; SD_ADDTXT("PTWP | "); - param1 = readS->readByte(); - param2 = readS->readUint16LE(); + param1 = readS.readByte(); + param2 = readS.readUint16LE(); sprintf(tmp_buf, "%02X %04X", param1, param2); SD_ADDTXT(tmp_buf); @@ -215,9 +214,9 @@ int SDEBUG_PrintInstr(R_SCRIPT_THREAD *thread) { int param3; SD_ADDTXT("GOSB | "); - param1 = readS->readByte(); - param2 = readS->readByte(); - param3 = readS->readUint16LE(); + param1 = readS.readByte(); + param2 = readS.readByte(); + param3 = readS.readUint16LE(); sprintf(tmp_buf, "%02X %02X %04X", param1, param2, param3); SD_ADDTXT(tmp_buf); } @@ -230,10 +229,10 @@ int SDEBUG_PrintInstr(R_SCRIPT_THREAD *thread) { int param; SD_ADDTXT("CALL | "); - func_num = readS->readByte(); + func_num = readS.readByte(); sprintf(tmp_buf, "%02X ", func_num); SD_ADDTXT(tmp_buf); - param = readS->readUint16LE(); + param = readS.readUint16LE(); sprintf(tmp_buf, "%04X ", param); SD_ADDTXT(tmp_buf); } @@ -244,7 +243,7 @@ int SDEBUG_PrintInstr(R_SCRIPT_THREAD *thread) { int param; SD_ADDTXT("ENTR | "); - param = readS->readUint16LE(); + param = readS.readUint16LE(); sprintf(tmp_buf, "%04X ", param); SD_ADDTXT(tmp_buf); /* @@ -270,7 +269,7 @@ int SDEBUG_PrintInstr(R_SCRIPT_THREAD *thread) { int param1; SD_ADDTXT("JMP | "); - param1 = readS->readUint16LE(); + param1 = readS.readUint16LE(); sprintf(tmp_buf, "%04X", param1); SD_ADDTXT(tmp_buf); } @@ -281,7 +280,7 @@ int SDEBUG_PrintInstr(R_SCRIPT_THREAD *thread) { int param1; SD_ADDTXT("JNZP | "); - param1 = readS->readUint16LE(); + param1 = readS.readUint16LE(); sprintf(tmp_buf, "%04X", param1); SD_ADDTXT(tmp_buf); } @@ -292,7 +291,7 @@ int SDEBUG_PrintInstr(R_SCRIPT_THREAD *thread) { int param1; SD_ADDTXT("JZP | "); - param1 = readS->readUint16LE(); + param1 = readS.readUint16LE(); sprintf(tmp_buf, "%04X", param1); SD_ADDTXT(tmp_buf); } @@ -302,7 +301,7 @@ int SDEBUG_PrintInstr(R_SCRIPT_THREAD *thread) { { int param1; SD_ADDTXT("JNZ | "); - param1 = readS->readUint16LE(); + param1 = readS.readUint16LE(); sprintf(tmp_buf, "%04X", param1); SD_ADDTXT(tmp_buf); } @@ -314,7 +313,7 @@ int SDEBUG_PrintInstr(R_SCRIPT_THREAD *thread) { int param1; SD_ADDTXT("JZ | "); - param1 = readS->readUint16LE(); + param1 = readS.readUint16LE(); sprintf(tmp_buf, "%04X", param1); SD_ADDTXT(tmp_buf); } @@ -327,15 +326,15 @@ int SDEBUG_PrintInstr(R_SCRIPT_THREAD *thread) { int default_jmp; SD_ADDTXT("SWCH | "); - n_switch = readS->readUint16LE(); + n_switch = readS.readUint16LE(); sprintf(tmp_buf, "%02X\n", n_switch); SD_ADDTXT(tmp_buf); for (i = 0; i < n_switch; i++) { - switch_num = readS->readUint16LE(); - switch_jmp = readS->readUint16LE(); + switch_num = readS.readUint16LE(); + switch_jmp = readS.readUint16LE(); // printf( R_TAB "CASE %04X, %04X\n", switch_num, switch_jmp); } - default_jmp = readS->readUint16LE(); + default_jmp = readS.readUint16LE(); //printf( R_TAB "DEF %04X", default_jmp); } break; @@ -348,14 +347,14 @@ int SDEBUG_PrintInstr(R_SCRIPT_THREAD *thread) { SD_ADDTXT("RJMP | "); // Ignored? - readS->readUint16LE(); - n_switch2 = readS->readUint16LE(); + readS.readUint16LE(); + n_switch2 = readS.readUint16LE(); sprintf(tmp_buf, "%04X", n_switch2); SD_ADDTXT(tmp_buf); for (i = 0; i < n_switch2; i++) { //printf("\n"); - switch_num = readS->readUint16LE(); - switch_jmp = readS->readUint16LE(); + switch_num = readS.readUint16LE(); + switch_jmp = readS.readUint16LE(); //printf( R_TAB "WEIGHT %04X, %04X", switch_num, switch_jmp); } } @@ -371,23 +370,23 @@ int SDEBUG_PrintInstr(R_SCRIPT_THREAD *thread) { break; case 0x28: SD_ADDTXT("??? "); - readS->readByte(); - readS->readUint16LE(); + readS.readByte(); + readS.readUint16LE(); break; case 0x29: SD_ADDTXT("??? "); - readS->readByte(); - readS->readUint16LE(); + readS.readByte(); + readS.readUint16LE(); break; case 0x2A: SD_ADDTXT("??? "); - readS->readByte(); - readS->readUint16LE(); + readS.readByte(); + readS.readUint16LE(); break; case 0x2B: SD_ADDTXT("??? "); - readS->readByte(); - readS->readUint16LE(); + readS.readByte(); + readS.readUint16LE(); break; // Addition case 0x2C: @@ -464,11 +463,11 @@ int SDEBUG_PrintInstr(R_SCRIPT_THREAD *thread) { int param2; SD_ADDTXT("DLGP | "); - n_voices = readS->readByte(); - param1 = readS->readUint16LE(); - param2 = readS->readByte(); + n_voices = readS.readByte(); + param1 = readS.readUint16LE(); + param2 = readS.readByte(); // ignored ? - readS->readUint16LE(); + readS.readUint16LE(); sprintf(tmp_buf, "%02X %04X %02X", n_voices, param1, param2); SD_ADDTXT(tmp_buf); } @@ -486,12 +485,12 @@ int SDEBUG_PrintInstr(R_SCRIPT_THREAD *thread) { int param3; SD_ADDTXT("DLGO | "); - param1 = readS->readByte(); - param2 = readS->readByte(); + param1 = readS.readByte(); + param2 = readS.readByte(); sprintf(tmp_buf, "%02X %02X ", param1, param2); SD_ADDTXT(tmp_buf); if (param2 > 0) { - param3 = readS->readUint16LE(); + param3 = readS.readUint16LE(); sprintf(tmp_buf, "%04X", param3); SD_ADDTXT(tmp_buf); } @@ -504,9 +503,9 @@ int SDEBUG_PrintInstr(R_SCRIPT_THREAD *thread) { int param3; SD_ADDTXT("JMPS | "); - param1 = readS->readUint16LE(); - param2 = readS->readUint16LE(); - param3 = readS->readByte(); + param1 = readS.readUint16LE(); + param2 = readS.readUint16LE(); + param3 = readS.readByte(); sprintf(tmp_buf, "%04X %04X %02X", param1, param2, param3); SD_ADDTXT(tmp_buf); } diff --git a/saga/sndres.cpp b/saga/sndres.cpp index 3df489c2fe..d964ec738d 100644 --- a/saga/sndres.cpp +++ b/saga/sndres.cpp @@ -141,45 +141,45 @@ int SndRes::loadVocSound(byte *snd_res, size_t snd_res_len, R_SOUNDBUFFER *snd_b return R_FAILURE; } - MemoryReadStream *readS = new MemoryReadStream(snd_res, snd_res_len); + MemoryReadStream readS(snd_res, snd_res_len); for (i = 0; i < R_VOC_FILE_DESC_LEN; i++) - voc_hb.ft_desc[i] = readS->readByte(); + voc_hb.ft_desc[i] = readS.readByte(); if (memcmp(voc_hb.ft_desc, R_VOC_FILE_DESC, R_VOC_FILE_DESC_LEN) != 0) { /* Voc file desc string not found */ return R_FAILURE; } - voc_hb.db_offset = readS->readUint16LE(); - voc_hb.voc_version = readS->readUint16LE(); - voc_hb.voc_fileid = readS->readUint16LE(); + voc_hb.db_offset = readS.readUint16LE(); + voc_hb.voc_version = readS.readUint16LE(); + voc_hb.voc_fileid = readS.readUint16LE(); - if ((int32)(snd_res_len - readS->pos()) < (int32)(voc_hb.db_offset + R_VOC_GENBLOCK_LEN)) { + if ((int32)(snd_res_len - readS.pos()) < (int32)(voc_hb.db_offset + R_VOC_GENBLOCK_LEN)) { return R_FAILURE; } - while (readS->pos() < voc_hb.db_offset) - readS->readByte(); + while (readS.pos() < voc_hb.db_offset) + readS.readByte(); for (;;) { /* Read generic block header */ - if (snd_res_len - readS->pos() < R_VOC_GENBLOCK_LEN) { + if (snd_res_len - readS.pos() < R_VOC_GENBLOCK_LEN) { return R_FAILURE; } - voc_gb.block_id = readS->readByte(); + voc_gb.block_id = readS.readByte(); if (voc_gb.block_id == 0) { return R_FAILURE; } - voc_gb.block_len = readS->readUint24LE(); + voc_gb.block_len = readS.readUint24LE(); /* Process block */ switch (voc_gb.block_id) { case 1: /* Sound data block */ - voc_b1.time_constant = readS->readByte(); - voc_b1.pack_method = readS->readByte(); + voc_b1.time_constant = readS.readByte(); + voc_b1.pack_method = readS.readByte(); if (voc_b1.pack_method != 0) { debug(0, "Packed VOC files not supported"); @@ -195,15 +195,15 @@ int SndRes::loadVocSound(byte *snd_res, size_t snd_res_len, R_SOUNDBUFFER *snd_b snd_buf_i->res_data = snd_res; snd_buf_i->res_len = snd_res_len; - snd_buf_i->s_buf = snd_res + readS->pos(); - snd_buf_i->s_buf_len = snd_res_len - readS->pos() - 1; /* -1 for end block */ + snd_buf_i->s_buf = snd_res + readS.pos(); + snd_buf_i->s_buf_len = snd_res_len - readS.pos() - 1; /* -1 for end block */ snd_buf_i->s_signed = 0; return R_SUCCESS; break; default: for (i = 0; i < voc_gb.block_len; i++) - readS->readByte(); + readS.readByte(); break; } } diff --git a/saga/sprite.cpp b/saga/sprite.cpp index 4bb600de0b..de18fed493 100644 --- a/saga/sprite.cpp +++ b/saga/sprite.cpp @@ -94,9 +94,9 @@ int SPRITE_LoadList(int resource_num, R_SPRITELIST **sprite_list_p) { return R_FAILURE; } - MemoryReadStream *readS = new MemoryReadStream(spritelist_data, spritelist_len); + MemoryReadStream readS(spritelist_data, spritelist_len); - sprite_count = readS->readUint16LE(); + sprite_count = readS.readUint16LE(); new_slist->sprite_count = sprite_count; @@ -108,7 +108,7 @@ int SPRITE_LoadList(int resource_num, R_SPRITELIST **sprite_list_p) { for (i = 0; i < sprite_count; i++) { new_slist->offset_list[i].data_idx = 0; - new_slist->offset_list[i].offset = readS->readUint16LE(); + new_slist->offset_list[i].offset = readS.readUint16LE(); } new_slist->slist_rn = resource_num; @@ -137,9 +137,9 @@ int SPRITE_AppendList(int resource_num, R_SPRITELIST *spritelist) { return R_FAILURE; } - MemoryReadStream *readS = new MemoryReadStream(spritelist_data, spritelist_len); + MemoryReadStream readS(spritelist_data, spritelist_len); - sprite_count = readS->readUint16LE(); + sprite_count = readS.readUint16LE(); old_sprite_count = spritelist->sprite_count; new_sprite_count = spritelist->sprite_count + sprite_count; @@ -156,7 +156,7 @@ int SPRITE_AppendList(int resource_num, R_SPRITELIST *spritelist) { for (i = old_sprite_count; i < spritelist->sprite_count; i++) { spritelist->offset_list[i].data_idx = spritelist->append_count; - spritelist->offset_list[i].offset = readS->readUint16LE(); + spritelist->offset_list[i].offset = readS.readUint16LE(); } spritelist->sprite_data[spritelist->append_count] = spritelist_data; @@ -207,15 +207,15 @@ int SPRITE_Draw(R_SURFACE *ds, R_SPRITELIST *sprite_list, int sprite_num, int sp sprite_p = sprite_list->sprite_data[offset_idx]; sprite_p += offset; - MemoryReadStream *readS = new MemoryReadStream(sprite_p, 5); + MemoryReadStream readS(sprite_p, 5); - x_align = readS->readSByte(); - y_align = readS->readSByte(); + x_align = readS.readSByte(); + y_align = readS.readSByte(); - s_width = readS->readByte(); - s_height = readS->readByte(); + s_width = readS.readByte(); + s_height = readS.readByte(); - sprite_data_p = sprite_p + readS->pos(); + sprite_data_p = sprite_p + readS.pos(); spr_x += x_align; spr_y += y_align; @@ -315,17 +315,17 @@ int SPRITE_DrawOccluded(R_SURFACE *ds, R_SPRITELIST *sprite_list, int sprite_num sprite_p = sprite_list->sprite_data[offset_idx]; sprite_p += offset; - MemoryReadStream *readS = new MemoryReadStream(sprite_p, 5); + MemoryReadStream readS(sprite_p, 5); // Read sprite dimensions -- should probably cache this stuff in // sprite list - x_align = readS->readSByte(); - y_align = readS->readSByte(); + x_align = readS.readSByte(); + y_align = readS.readSByte(); - s_width = readS->readByte(); - s_height = readS->readByte(); + s_width = readS.readByte(); + s_height = readS.readByte(); - sprite_data_p = sprite_p + readS->pos(); + sprite_data_p = sprite_p + readS.pos(); // Create actor Z occlusion LUT SCENE_GetZInfo(&zinfo); diff --git a/saga/sthread.cpp b/saga/sthread.cpp index 7263b8e653..be43c57d38 100644 --- a/saga/sthread.cpp +++ b/saga/sthread.cpp @@ -221,9 +221,9 @@ int STHREAD_Run(R_SCRIPT_THREAD *thread, int instr_limit, int msec) { saved_offset = thread->i_offset; debug(2, "Executing thread offset: %lu", thread->i_offset); - MemoryReadStream *readS = new MemoryReadStream(GetReadPtr(thread), GetReadLen(thread)); + MemoryReadStream readS(GetReadPtr(thread), GetReadLen(thread)); - in_char = readS->readByte(); + in_char = readS.readByte(); switch (in_char) { // Align (ALGN) @@ -250,12 +250,12 @@ int STHREAD_Run(R_SCRIPT_THREAD *thread, int instr_limit, int msec) { break; // Push word (PUSH) case 0x06: - param1 = (SDataWord_T)readS->readUint16LE(); + param1 = (SDataWord_T)readS.readUint16LE(); SSTACK_Push(thread->stack, param1); break; // Push word (PSHD) (dialogue string index) case 0x08: - param1 = (SDataWord_T)readS->readUint16LE(); + param1 = (SDataWord_T)readS.readUint16LE(); SSTACK_Push(thread->stack, param1); break; @@ -263,22 +263,22 @@ int STHREAD_Run(R_SCRIPT_THREAD *thread, int instr_limit, int msec) { // Test flag (TSTF) case 0x0B: - n_buf = readS->readByte(); - param1 = (SDataWord_T)readS->readUint16LE(); + n_buf = readS.readByte(); + param1 = (SDataWord_T)readS.readUint16LE(); _vm->_sdata->getBit(n_buf, param1, &bitstate); SSTACK_Push(thread->stack, bitstate); break; // Get word (GETW) case 0x0C: - n_buf = readS->readByte(); - param1 = readS->readUint16LE(); + n_buf = readS.readByte(); + param1 = readS.readUint16LE(); _vm->_sdata->getWord(n_buf, param1, &data); SSTACK_Push(thread->stack, data); break; // Modify flag (MODF) case 0x0F: - n_buf = readS->readByte(); - param1 = (SDataWord_T)readS->readUint16LE(); + n_buf = readS.readByte(); + param1 = (SDataWord_T)readS.readUint16LE(); bitstate = _vm->_sdata->readWordU(param1); SSTACK_Top(thread->stack, &data); if (bitstate) { @@ -289,15 +289,15 @@ int STHREAD_Run(R_SCRIPT_THREAD *thread, int instr_limit, int msec) { break; // Put word (PUTW) case 0x10: - n_buf = readS->readByte(); - param1 = (SDataWord_T)readS->readUint16LE(); + n_buf = readS.readByte(); + param1 = (SDataWord_T)readS.readUint16LE(); SSTACK_Top(thread->stack, &data); _vm->_sdata->putWord(n_buf, param1, data); break; // Modify flag and pop (MDFP) case 0x13: - n_buf = readS->readByte(); - param1 = (SDataWord_T)readS->readUint16LE(); + n_buf = readS.readByte(); + param1 = (SDataWord_T)readS.readUint16LE(); SSTACK_Pop(thread->stack, ¶m1); bitstate = _vm->_sdata->readWordU(param1); if (bitstate) { @@ -308,8 +308,8 @@ int STHREAD_Run(R_SCRIPT_THREAD *thread, int instr_limit, int msec) { break; // Put word and pop (PTWP) case 0x14: - n_buf = readS->readByte(); - param1 = (SDataWord_T)readS->readUint16LE(); + n_buf = readS.readByte(); + param1 = (SDataWord_T)readS.readUint16LE(); SSTACK_Top(thread->stack, &data); _vm->_sdata->putWord(n_buf, param1, data); break; @@ -322,10 +322,10 @@ int STHREAD_Run(R_SCRIPT_THREAD *thread, int instr_limit, int msec) { int temp; int temp2; - temp = readS->readByte(); - temp2 = readS->readByte(); - param1 = (SDataWord_T)readS->readUint16LE(); - data = readS->pos(); + temp = readS.readByte(); + temp2 = readS.readByte(); + param1 = (SDataWord_T)readS.readUint16LE(); + data = readS.pos(); //SSTACK_Push(thread->stack, (SDataWord_T)temp); SSTACK_Push(thread->stack, data); thread->i_offset = (unsigned long)param1; @@ -340,8 +340,8 @@ int STHREAD_Run(R_SCRIPT_THREAD *thread, int instr_limit, int msec) { int FIXME_SHADOWED_result; SFunc_T sfunc; - n_args = readS->readByte(); - func_num = readS->readUint16LE(); + n_args = readS.readByte(); + func_num = readS.readUint16LE(); if (func_num >= R_SFUNC_NUM) { CON_Print(S_ERROR_PREFIX "Invalid script function number: (%X)\n", func_num); thread->executing = 0; @@ -366,7 +366,7 @@ int STHREAD_Run(R_SCRIPT_THREAD *thread, int instr_limit, int msec) { break; // (ENTR) Enter the dragon case 0x1A: - param1 = readS->readUint16LE(); + param1 = readS.readUint16LE(); break; // (?) Unknown case 0x1B: @@ -387,12 +387,12 @@ int STHREAD_Run(R_SCRIPT_THREAD *thread, int instr_limit, int msec) { // (JMP): Unconditional jump case 0x1D: - param1 = readS->readUint16LE(); + param1 = readS.readUint16LE(); thread->i_offset = (unsigned long)param1; break; // (JNZP): Jump if nonzero + POP case 0x1E: - param1 = readS->readUint16LE(); + param1 = readS.readUint16LE(); SSTACK_Pop(thread->stack, &data); if (data) { thread->i_offset = (unsigned long)param1; @@ -400,7 +400,7 @@ int STHREAD_Run(R_SCRIPT_THREAD *thread, int instr_limit, int msec) { break; // (JZP): Jump if zero + POP case 0x1F: - param1 = readS->readUint16LE(); + param1 = readS.readUint16LE(); SSTACK_Pop(thread->stack, &data); if (!data) { thread->i_offset = (unsigned long)param1; @@ -408,7 +408,7 @@ int STHREAD_Run(R_SCRIPT_THREAD *thread, int instr_limit, int msec) { break; // (JNZ): Jump if nonzero case 0x20: - param1 = readS->readUint16LE(); + param1 = readS.readUint16LE(); SSTACK_Top(thread->stack, &data); if (data) { thread->i_offset = (unsigned long)param1; @@ -416,7 +416,7 @@ int STHREAD_Run(R_SCRIPT_THREAD *thread, int instr_limit, int msec) { break; // (JZ): Jump if zero case 0x21: - param1 = readS->readUint16LE(); + param1 = readS.readUint16LE(); SSTACK_Top(thread->stack, &data); if (!data) { thread->i_offset = (unsigned long)param1; @@ -425,9 +425,9 @@ int STHREAD_Run(R_SCRIPT_THREAD *thread, int instr_limit, int msec) { // (JMPR): Relative jump case 0x57: // ignored? - readS->readUint16LE(); - readS->readUint16LE(); - iparam1 = (long)readS->readByte(); + readS.readUint16LE(); + readS.readUint16LE(); + iparam1 = (long)readS.readByte(); thread->i_offset += iparam1; break; // (SWCH): Switch @@ -440,10 +440,10 @@ int STHREAD_Run(R_SCRIPT_THREAD *thread, int instr_limit, int msec) { int case_found = 0; SSTACK_Pop(thread->stack, &data); - n_switch = readS->readUint16LE(); + n_switch = readS.readUint16LE(); for (i = 0; i < n_switch; i++) { - switch_num = readS->readUint16LE(); - switch_jmp = readS->readUint16LE(); + switch_num = readS.readUint16LE(); + switch_jmp = readS.readUint16LE(); // Found the specified case if (data == (SDataWord_T) switch_num) { thread->i_offset = switch_jmp; @@ -454,7 +454,7 @@ int STHREAD_Run(R_SCRIPT_THREAD *thread, int instr_limit, int msec) { // Jump to default case if (!case_found) { - default_jmp = readS->readUint16LE(); + default_jmp = readS.readUint16LE(); thread->i_offset = default_jmp; } } @@ -469,11 +469,11 @@ int STHREAD_Run(R_SCRIPT_THREAD *thread, int instr_limit, int msec) { int branch_found = 0; // Ignored? - readS->readUint16LE(); - n_branch = readS->readUint16LE(); + readS.readUint16LE(); + n_branch = readS.readUint16LE(); for (i = 0; i < n_branch; i++) { - branch_wt = readS->readUint16LE(); - branch_jmp = readS->readUint16LE(); + branch_wt = readS.readUint16LE(); + branch_jmp = readS.readUint16LE(); if (rand_sel == i) { thread->i_offset = branch_jmp; branch_found = 1; @@ -511,29 +511,29 @@ int STHREAD_Run(R_SCRIPT_THREAD *thread, int instr_limit, int msec) { case 0x28: unhandled = 1; printf("??? "); - readS->readByte(); - readS->readUint16LE(); + readS.readByte(); + readS.readUint16LE(); break; // (?) case 0x29: unhandled = 1; printf("??? "); - readS->readByte(); - readS->readUint16LE(); + readS.readByte(); + readS.readUint16LE(); break; // (?) case 0x2A: unhandled = 1; printf("??? "); - readS->readByte(); - readS->readUint16LE(); + readS.readByte(); + readS.readUint16LE(); break; // (?) case 0x2B: unhandled = 1; printf("??? "); - readS->readByte(); - readS->readUint16LE(); + readS.readByte(); + readS.readUint16LE(); break; // ARITHMETIC INSTRUCTIONS @@ -715,11 +715,11 @@ int STHREAD_Run(R_SCRIPT_THREAD *thread, int instr_limit, int msec) { int a_index; int voice_rn; - n_voices = readS->readByte(); - param1 = (SDataWord_T) readS->readUint16LE(); + n_voices = readS.readByte(); + param1 = (SDataWord_T) readS.readUint16LE(); // ignored ? - readS->readByte(); - readS->readUint16LE(); + readS.readByte(); + readS.readUint16LE(); a_index = ACTOR_GetActorIndex(param1); if (a_index < 0) { @@ -753,12 +753,12 @@ int STHREAD_Run(R_SCRIPT_THREAD *thread, int instr_limit, int msec) { int FIXME_SHADOWED_param3; printf("DLGO | "); - FIXME_SHADOWED_param1 = readS->readByte(); - FIXME_SHADOWED_param2 = readS->readByte(); + FIXME_SHADOWED_param1 = readS.readByte(); + FIXME_SHADOWED_param2 = readS.readByte(); printf("%02X %02X ", FIXME_SHADOWED_param1, FIXME_SHADOWED_param2); if (FIXME_SHADOWED_param2 > 0) { - FIXME_SHADOWED_param3 = readS->readUint16LE(); + FIXME_SHADOWED_param3 = readS.readUint16LE(); printf("%04X", FIXME_SHADOWED_param3); } } @@ -775,7 +775,7 @@ int STHREAD_Run(R_SCRIPT_THREAD *thread, int instr_limit, int msec) { // Set instruction offset only if a previous instruction didn't branch if (saved_offset == thread->i_offset) { - thread->i_offset = readS->pos(); + thread->i_offset = readS.pos(); } if (unhandled) { CON_Print(S_ERROR_PREFIX "%X: Unhandled opcode.\n", thread->i_offset); |