diff options
author | Travis Howell | 2006-04-06 00:54:26 +0000 |
---|---|---|
committer | Travis Howell | 2006-04-06 00:54:26 +0000 |
commit | d967db266cb237457d5542007047fc5b61f3773b (patch) | |
tree | f36a68ca22d5c55163feed32e5910526a43bd839 /engines | |
parent | 95eb4604179dbb31c5cad4581ad7c38a867ee4dd (diff) | |
download | scummvm-rg350-d967db266cb237457d5542007047fc5b61f3773b.tar.gz scummvm-rg350-d967db266cb237457d5542007047fc5b61f3773b.tar.bz2 scummvm-rg350-d967db266cb237457d5542007047fc5b61f3773b.zip |
Add more icon differences in FF and cleanup
svn-id: r21635
Diffstat (limited to 'engines')
-rw-r--r-- | engines/simon/icons.cpp | 360 | ||||
-rw-r--r-- | engines/simon/items.cpp | 14 | ||||
-rw-r--r-- | engines/simon/simon.cpp | 206 | ||||
-rw-r--r-- | engines/simon/simon.h | 14 |
4 files changed, 365 insertions, 229 deletions
diff --git a/engines/simon/icons.cpp b/engines/simon/icons.cpp index 9e11eaa70f..02e1af048c 100644 --- a/engines/simon/icons.cpp +++ b/engines/simon/icons.cpp @@ -173,7 +173,6 @@ static void decompressIcon(byte *dst, byte *src, uint w, uint h_org, byte base, } } - void SimonEngine::draw_icon_c(WindowBlock *window, uint icon, uint x, uint y) { byte *dst; byte *src; @@ -213,23 +212,310 @@ void SimonEngine::draw_icon_c(WindowBlock *window, uint icon, uint x, uint y) { _lockWord &= ~0x8000; } -uint SimonEngine::setup_icon_hit_area(WindowBlock *window, uint x, uint y, uint icon_number, - Item *item_ptr) { +void SimonEngine::drawIconArray(uint num, Item *itemRef, int line, int classMask) { + if (getGameType() == GType_FF) { + drawIconArray_FF(num, itemRef, line, classMask); + } else { + drawIconArray_Simon(num, itemRef, line, classMask); + } +} + +void SimonEngine::drawIconArray_Simon(uint num, Item *itemRef, int line, int classMask) { + Item *item_ptr_org = itemRef; + WindowBlock *window; + uint width_div_3, height_div_3; + uint j, k, i, num_sibs_with_flag; + bool item_again; + uint x_pos, y_pos; + + window = _windowArray[num & 7]; + + if (getGameType() == GType_SIMON1) { + width_div_3 = window->width / 3; + height_div_3 = window->height / 3; + } else { + width_div_3 = 100; + height_div_3 = 40; + } + + i = 0; + + if (window == NULL) + return; + + if (window->iconPtr) + removeIconArray(num); + + window->iconPtr = (IconBlock *) malloc(sizeof(IconBlock)); + window->iconPtr->itemRef = itemRef; + window->iconPtr->upArrow = -1; + window->iconPtr->downArrow = -1; + window->iconPtr->line = line; + window->iconPtr->classMask = classMask; + + itemRef = derefItem(itemRef->child); + + while (itemRef && line-- != 0) { + num_sibs_with_flag = 0; + while (itemRef && width_div_3 > num_sibs_with_flag) { + if ((classMask == 0 || itemRef->classFlags & classMask) && has_item_childflag_0x10(itemRef)) + if (getGameType() == GType_SIMON1) { + num_sibs_with_flag++; + } else { + num_sibs_with_flag += 20; + } + itemRef = derefItem(itemRef->sibling); + } + } + + if (itemRef == NULL) { + window->iconPtr->line = 0; + itemRef = derefItem(item_ptr_org->child); + } + + x_pos = 0; + y_pos = 0; + item_again = false; + k = 0; + j = 0; + + while (itemRef) { + if ((classMask == 0 || itemRef->classFlags & classMask) && has_item_childflag_0x10(itemRef)) { + if (item_again == false) { + window->iconPtr->iconArray[k].item = itemRef; + if (getGameType() == GType_SIMON1) { + draw_icon_c(window, itemGetIconNumber(itemRef), x_pos * 3, y_pos); + window->iconPtr->iconArray[k].boxCode = + setupIconHitArea(window, 0, x_pos * 3, y_pos, itemRef); + } else { + draw_icon_c(window, itemGetIconNumber(itemRef), x_pos, y_pos); + window->iconPtr->iconArray[k].boxCode = + setupIconHitArea(window, 0, x_pos, y_pos, itemRef); + } + k++; + } else { + window->iconPtr->iconArray[k].item = NULL; + j = 1; + } + x_pos += (getGameType() == GType_SIMON1) ? 1 : 20; + + if (x_pos >= width_div_3) { + x_pos = 0; + + y_pos += (getGameType() == GType_SIMON1) ? 1 : 20; + if (y_pos >= height_div_3) + item_again = true; + } + } + itemRef = derefItem(itemRef->sibling); + } + + window->iconPtr->iconArray[k].item = NULL; + + if (j != 0 || window->iconPtr->line != 0) { + addArrows(window, num); + } +} + +void SimonEngine::drawIconArray_FF(uint num, Item *itemRef, int line, int classMask) { + Item *item_ptr_org = itemRef; + WindowBlock *window; + uint16 flagnumber = 201; + uint16 iconperline = 458; + uint16 iconsdown = 384; + uint16 idone = 0; + uint16 icount = 0; + uint16 xp = 188, yp = 306; + int k; + _iOverflow = 0; + + line = _variableArray[30]; + if (line == 0) + _variableArray[31] = 0; + + window = _windowArray[num & 7]; + if (window == NULL) + return; + + for (k = flagnumber; k <= flagnumber + 18; k++) + _variableArray[k] = 0; + + if (window->iconPtr) + removeIconArray(num); + + window->iconPtr=(IconBlock *)malloc(sizeof(IconBlock)); + window->iconPtr->itemRef = itemRef; + window->iconPtr->upArrow = -1; + window->iconPtr->downArrow = -1; + window->iconPtr->line = line; + window->iconPtr->classMask = classMask; + + itemRef = derefItem(itemRef->child); + k = flagnumber; + + while (itemRef && (line > 65)) { + uint16 ct = xp; + while (itemRef && ct < iconperline) { + if ((classMask == 0) || ((itemRef->classFlags & classMask) != 0)) { + if (has_item_childflag_0x10(itemRef)) { + ct += 45; + k++; + } + } + itemRef = derefItem(itemRef->sibling); + } + line -= 52; + if (k == (flagnumber + 18)) + k = flagnumber; + } + yp -= line; // Adjust starting y + + if (itemRef == NULL) { + window->iconPtr->line = 0; + itemRef = derefItem(item_ptr_org->child); + } + + while (itemRef) { + if ((classMask != 0) && ((itemRef->classFlags & classMask) == 0)) + goto l1; + if (has_item_childflag_0x10(itemRef) == 0) + goto l1; + if (!idone) { +/* + * Create thee icon and graphics rendering + */ + window->iconPtr->iconArray[icount].item = itemRef; + _variableArray[k] = itemGetIconNumber(itemRef); + window->iconPtr->iconArray[icount++].boxCode = + setupIconHitArea(window, k++, xp, yp, itemRef); + } else { +/* + * Just remember the overflow has occured + */ + window->iconPtr->iconArray[icount].item = NULL; /* END MARKINGS */ + _iOverflow = 1; + } + xp += 45; + if (xp >= iconperline) { /* End of line ? */ + if (k == (flagnumber + 18)) + k = flagnumber; + xp = 188; + yp += 52; /* Move down */ + if (yp >= iconsdown) { /* Full ? */ + idone = 1; /* Note completed screen */ + } + } +l1:; itemRef = derefItem(itemRef->sibling); + } + window->iconPtr->iconArray[icount].item = NULL; /* END MARKINGS */ + if (_variableArray[30] == 0) { + if (yp != 306) + _variableArray[31] = 52; + if ((xp == 188) && (yp == 358)) + _variableArray[31] = 0; + } + addArrows(window, num); /* Plot arrows and add their boxes */ +} + +void SimonEngine::addArrows(WindowBlock *window, uint num) { + setArrowHitAreas(window, num); + + window->iconPtr->upArrow = _scrollUpHitArea; + window->iconPtr->downArrow = _scrollDownHitArea; +} + +void SimonEngine::setArrowHitAreas(WindowBlock *window, uint num) { + HitArea *ha; + + ha = findEmptyHitArea(); + _scrollUpHitArea = ha - _hitAreas; + if (getGameType() == GType_FF) { + ha->x = 496; + ha->y = 279; + ha->width = 30; + ha->height = 45; + ha->flags = 0x24; + ha->id = 0x7FFB; + ha->priority = 100; + ha->window = window; + ha->verb = 1; + } else if (getGameType() == GType_SIMON2) { + ha->x = 81; + ha->y = 158; + ha->width = 12; + ha->height = 26; + ha->flags = 36; + ha->id = 0x7FFB; + ha->priority = 100; + ha->window = window; + ha->verb = 1; + } else { + ha->x = 308; + ha->y = 149; + ha->width = 12; + ha->height = 17; + ha->flags = 0x24; + ha->id = 0x7FFB; + ha->priority = 100; + ha->window = window; + ha->verb = 1; + } + + ha = findEmptyHitArea(); + _scrollDownHitArea = ha - _hitAreas; + + if (getGameType() == GType_FF) { + ha->x = 496; + ha->y = 324; + ha->width = 30; + ha->height = 44; + ha->flags = 0x24; + ha->id = 0x7FFC; + ha->priority = 100; + ha->window = window; + ha->verb = 1; + } else if (getGameType() == GType_SIMON2) { + ha->x = 227; + ha->y = 162; + ha->width = 12; + ha->height = 26; + ha->flags = 36; + ha->id = 0x7FFC; + ha->priority = 100; + ha->window = window; + ha->verb = 1; + } else { + ha->x = 308; + ha->y = 176; + ha->width = 12; + ha->height = 17; + ha->flags = 0x24; + ha->id = 0x7FFC; + ha->priority = 100; + ha->window = window; + ha->verb = 1; + + o_kill_sprite_simon1(128); + loadSprite(0, 1, 128, 0, 0, 14); + } +} + +uint SimonEngine::setupIconHitArea(WindowBlock *window, uint num, uint x, uint y, Item *item_ptr) { HitArea *ha; ha = findEmptyHitArea(); - if (getGameType() == GType_SIMON1) { - ha->x = (x + window->x) * 8; - ha->y = y * 25 + window->y; + if (getGameType() == GType_FF) { + ha->x = x + window->x; + ha->y = y + window->y; ha->item_ptr = item_ptr; - ha->width = 24; - ha->height = 24; - ha->flags = 0xB0; - ha->id = 0x7FFD; + ha->width = 45; + ha->height = 44; + ha->flags = 0xA0; + ha->id = num; ha->priority = 100; ha->verb = 208; - } else { + } else if (getGameType() == GType_SIMON2) { ha->x = x + 110; ha->y = window->y + y; ha->item_ptr = item_ptr; @@ -239,9 +525,61 @@ uint SimonEngine::setup_icon_hit_area(WindowBlock *window, uint x, uint y, uint ha->id = 0x7FFD; ha->priority = 100; ha->verb = 208; + } else { + ha->x = (x + window->x) * 8; + ha->y = y * 25 + window->y; + ha->item_ptr = item_ptr; + ha->width = 24; + ha->height = 24; + ha->flags = 0xB0; + ha->id = 0x7FFD; + ha->priority = 100; + ha->verb = 208; } return ha - _hitAreas; } +void SimonEngine::removeIconArray(uint num) { + WindowBlock *window; + uint16 curWindow; + uint16 i; + + window = _windowArray[num & 7]; + curWindow = _curWindow; + + if (window == NULL || window->iconPtr == NULL) + return; + + if (getGameType() == GType_SIMON1 || getGameType() == GType_SIMON2) { + changeWindow(num); + fcs_putchar(12); + changeWindow(curWindow); + } + + for (i = 0; window->iconPtr->iconArray[i].item != NULL; i++) { + delete_hitarea_by_index(window->iconPtr->iconArray[i].boxCode); + } + + if (window->iconPtr->upArrow != -1) { + delete_hitarea_by_index(window->iconPtr->upArrow); + } + + if (window->iconPtr->downArrow != -1) { + delete_hitarea_by_index(window->iconPtr->downArrow); + if (getGameType() == GType_SIMON1) + removeArrows(window, num); + } + + free(window->iconPtr); + window->iconPtr = NULL; + + _fcsData1[num] = 0; + _fcsData2[num] = 0; +} + +void SimonEngine::removeArrows(WindowBlock *window, uint num) { + o_kill_sprite_simon1(128); +} + } // End of namespace Simon diff --git a/engines/simon/items.cpp b/engines/simon/items.cpp index e6213a337c..7d23e2764f 100644 --- a/engines/simon/items.cpp +++ b/engines/simon/items.cpp @@ -654,9 +654,9 @@ int SimonEngine::runScript() { case 114:{ Item *item = getNextItemPtr(); - uint fcs_index = getVarOrByte(); + uint num = getVarOrByte(); mouseOff(); - drawIconArray(fcs_index, item, 0, 0); + drawIconArray(num, item, 0, 0); mouseOn(); } break; @@ -734,10 +734,10 @@ int SimonEngine::runScript() { case 126:{ Item *item = getNextItemPtr(); - uint fcs_index = getVarOrByte(); + uint num = getVarOrByte(); uint a = 1 << getVarOrByte(); mouseOff(); - drawIconArray(fcs_index, item, 1, a); + drawIconArray(num, item, 1, a); mouseOn(); } break; @@ -1504,13 +1504,13 @@ void SimonEngine::o_confirmQuit() { } } -void SimonEngine::o_restoreIconArray(uint fcs_index) { +void SimonEngine::o_restoreIconArray(uint num) { WindowBlock *window; - window = _windowArray[fcs_index & 7]; + window = _windowArray[num & 7]; if (window->iconPtr == NULL) return; - drawIconArray(fcs_index, window->iconPtr->itemRef, window->iconPtr->line, window->iconPtr->classMask); + drawIconArray(num, window->iconPtr->itemRef, window->iconPtr->line, window->iconPtr->classMask); } void SimonEngine::o_freezeBottom() { diff --git a/engines/simon/simon.cpp b/engines/simon/simon.cpp index c015585229..9eb4db7094 100644 --- a/engines/simon/simon.cpp +++ b/engines/simon/simon.cpp @@ -1776,175 +1776,12 @@ get_out: _needHitAreaRecalc = 0; } -void SimonEngine::drawIconArray(uint fcs_index, Item *itemRef, int line, int classMask) { - Item *item_ptr_org = itemRef; - WindowBlock *fcs_ptr; - uint width_div_3, height_div_3; - uint j, k, i, num_sibs_with_flag; - bool item_again; - uint x_pos, y_pos; - - fcs_ptr = _windowArray[fcs_index & 7]; - - if (getGameType() == GType_SIMON1) { - width_div_3 = fcs_ptr->width / 3; - height_div_3 = fcs_ptr->height / 3; - } else { - width_div_3 = 100; - height_div_3 = 40; - } - - i = 0; - - if (fcs_ptr == NULL) - return; - - if (fcs_ptr->iconPtr) - removeIconArray(fcs_index); - - fcs_ptr->iconPtr = (IconBlock *) malloc(sizeof(IconBlock)); - fcs_ptr->iconPtr->itemRef = itemRef; - fcs_ptr->iconPtr->upArrow = -1; - fcs_ptr->iconPtr->downArrow = -1; - fcs_ptr->iconPtr->line = line; - fcs_ptr->iconPtr->classMask = classMask; - - itemRef = derefItem(itemRef->child); - - while (itemRef && line-- != 0) { - num_sibs_with_flag = 0; - while (itemRef && width_div_3 > num_sibs_with_flag) { - if ((classMask == 0 || itemRef->classFlags & classMask) && has_item_childflag_0x10(itemRef)) - if (getGameType() == GType_SIMON1) { - num_sibs_with_flag++; - } else { - num_sibs_with_flag += 20; - } - itemRef = derefItem(itemRef->sibling); - } - } - - if (itemRef == NULL) { - fcs_ptr->iconPtr->line = 0; - itemRef = derefItem(item_ptr_org->child); - } - - x_pos = 0; - y_pos = 0; - item_again = false; - k = 0; - j = 0; - - while (itemRef) { - if ((classMask == 0 || itemRef->classFlags & classMask) && has_item_childflag_0x10(itemRef)) { - if (item_again == false) { - fcs_ptr->iconPtr->iconArray[k].item = itemRef; - if (getGameType() == GType_SIMON1) { - draw_icon_c(fcs_ptr, item_get_icon_number(itemRef), x_pos * 3, y_pos); - fcs_ptr->iconPtr->iconArray[k].boxCode = - setup_icon_hit_area(fcs_ptr, x_pos * 3, y_pos, - item_get_icon_number(itemRef), itemRef); - } else { - draw_icon_c(fcs_ptr, item_get_icon_number(itemRef), x_pos, y_pos); - fcs_ptr->iconPtr->iconArray[k].boxCode = - setup_icon_hit_area(fcs_ptr, x_pos, y_pos, item_get_icon_number(itemRef), itemRef); - } - k++; - } else { - fcs_ptr->iconPtr->iconArray[k].item = NULL; - j = 1; - } - x_pos += (getGameType() == GType_SIMON1) ? 1 : 20; - - if (x_pos >= width_div_3) { - x_pos = 0; - - y_pos += (getGameType() == GType_SIMON1) ? 1 : 20; - if (y_pos >= height_div_3) - item_again = true; - } - } - itemRef = derefItem(itemRef->sibling); - } - - fcs_ptr->iconPtr->iconArray[k].item = NULL; - - if (j != 0 || fcs_ptr->iconPtr->line != 0) { - addArrows(fcs_ptr, fcs_index); - } -} - -void SimonEngine::addArrows(WindowBlock *window, uint fcs_index) { - setArrowHitAreas(window, fcs_index); - - window->iconPtr->upArrow = _scrollUpHitArea; - window->iconPtr->downArrow = _scrollDownHitArea; -} - -void SimonEngine::setArrowHitAreas(WindowBlock *window, uint fcs_index) { - HitArea *ha; - - ha = findEmptyHitArea(); - _scrollUpHitArea = ha - _hitAreas; - if (getGameType() == GType_SIMON1) { - ha->x = 308; - ha->y = 149; - ha->width = 12; - ha->height = 17; - ha->flags = 0x24; - ha->id = 0x7FFB; - ha->priority = 100; - ha->window = window; - ha->verb = 1; - } else { - ha->x = 81; - ha->y = 158; - ha->width = 12; - ha->height = 26; - ha->flags = 36; - ha->id = 0x7FFB; - ha->priority = 100; - ha->window = window; - ha->verb = 1; - } - - ha = findEmptyHitArea(); - _scrollDownHitArea = ha - _hitAreas; - - if (getGameType() == GType_SIMON1) { - ha->x = 308; - ha->y = 176; - ha->width = 12; - ha->height = 17; - ha->flags = 0x24; - ha->id = 0x7FFC; - ha->priority = 100; - ha->window = window; - ha->verb = 1; - - // Simon1 specific - o_kill_sprite_simon1(128); - loadSprite(0, 1, 128, 0, 0, 14); - } else { - ha->x = 227; - ha->y = 162; - ha->width = 12; - ha->height = 26; - ha->flags = 36; - ha->id = 0x7FFC; - ha->priority = 100; - ha->window = window; - ha->verb = 1; - } -} - - bool SimonEngine::has_item_childflag_0x10(Item *item) { Child2 *child = (Child2 *)findChildOfType(item, 2); return child && (child->avail_props & 0x10) != 0; } -uint SimonEngine::item_get_icon_number(Item *item) { +uint SimonEngine::itemGetIconNumber(Item *item) { Child2 *child = (Child2 *)findChildOfType(item, 2); uint offs; @@ -3101,47 +2938,6 @@ void SimonEngine::o_pathfind(int x, int y, uint var_1, uint var_2) { } // ok -void SimonEngine::removeIconArray(uint fcs_index) { - WindowBlock *window; - uint16 fcsunk1; - uint16 i; - - window = _windowArray[fcs_index & 7]; - fcsunk1 = _curWindow; - - if (window == NULL || window->iconPtr == NULL) - return; - - changeWindow(fcs_index); - fcs_putchar(12); - changeWindow(fcsunk1); - - for (i = 0; window->iconPtr->iconArray[i].item != NULL; i++) { - delete_hitarea_by_index(window->iconPtr->iconArray[i].boxCode); - } - - if (window->iconPtr->upArrow != -1) { - delete_hitarea_by_index(window->iconPtr->upArrow); - } - - if (window->iconPtr->downArrow != -1) { - delete_hitarea_by_index(window->iconPtr->downArrow); - if (getGameType() == GType_SIMON1) - removeArrows(window, fcs_index); - } - - free(window->iconPtr); - window->iconPtr = NULL; - - _fcsData1[fcs_index] = 0; - _fcsData2[fcs_index] = 0; -} - -// ok -void SimonEngine::removeArrows(WindowBlock *window, uint fcs_index) { - o_kill_sprite_simon1(128); -} - void SimonEngine::delete_hitarea_by_index(uint index) { CHECK_BOUNDS(index, _hitAreas); _hitAreas[index].flags = 0; diff --git a/engines/simon/simon.h b/engines/simon/simon.h index eab05cb435..c5cc75fde0 100644 --- a/engines/simon/simon.h +++ b/engines/simon/simon.h @@ -612,6 +612,8 @@ protected: void mouseOn(); void drawIconArray(uint i, Item *item_ptr, int line, int classMask); + void drawIconArray_FF(uint i, Item *item_ptr, int line, int classMask); + void drawIconArray_Simon(uint i, Item *item_ptr, int line, int classMask); void loadTextIntoMem(uint string_id); void loadTablesIntoMem(uint subr_id); @@ -660,12 +662,12 @@ protected: void pollMouseXY(); void drawMousePointer(); - void removeIconArray(uint fcs_index); + void removeIconArray(uint num); void draw_icon_c(WindowBlock *window, uint icon, uint x, uint y); bool has_item_childflag_0x10(Item *item); - uint item_get_icon_number(Item *item); - uint setup_icon_hit_area(WindowBlock *window, uint x, uint y, uint icon_number, Item *item_ptr); - void addArrows(WindowBlock *window, uint fcs_index); + uint itemGetIconNumber(Item *item); + uint setupIconHitArea(WindowBlock *window, uint num, uint x, uint y, Item *item_ptr); + void addArrows(WindowBlock *window, uint num); void loadIconData(); void loadIconFile(); @@ -693,7 +695,7 @@ protected: void render_string_amiga(uint vga_sprite_id, uint color, uint width, uint height, const char *txt); void render_string(uint vga_sprite_id, uint color, uint width, uint height, const char *txt); - void setArrowHitAreas(WindowBlock *window, uint fcs_index); + void setArrowHitAreas(WindowBlock *window, uint num); byte *setup_vga_destination(uint32 size); void vga_buf_unk_proc3(byte *end); @@ -830,7 +832,7 @@ protected: void video_copy_if_flag_0x8_c(WindowBlock *window); void delete_hitarea_by_index(uint index); - void removeArrows(WindowBlock *window, uint fcs_index); + void removeArrows(WindowBlock *window, uint num); void fcs_putchar(uint a); void restoreWindow(WindowBlock *window); |