Path: blob/master/RSDKv5/RSDK/Graphics/Legacy/v4/DrawingLegacyv4.cpp
1171 views
12void RSDK::Legacy::v4::DrawObjectList(int32 group)3{4for (int32 i = 0; i < drawListEntries[group].listSize; ++i) {5objectEntityPos = drawListEntries[group].entityRefs[i];67int32 type = objectEntityList[objectEntityPos].type;8if (type) {9if (scriptCode[objectScriptList[type].eventDraw.scriptCodePtr] > 0)10ProcessScript(objectScriptList[type].eventDraw.scriptCodePtr, objectScriptList[type].eventDraw.jumpTablePtr, EVENT_DRAW);11}12}13}14void RSDK::Legacy::v4::DrawStageGFX()15{16waterDrawPos = waterLevel - yScrollOffset;1718if (waterDrawPos < 0)19waterDrawPos = 0;2021if (waterDrawPos > SCREEN_YSIZE)22waterDrawPos = SCREEN_YSIZE;2324if (tLayerMidPoint < 3) {25DrawObjectList(0);2627if (activeTileLayers[0] < LEGACY_LAYER_COUNT) {28switch (stageLayouts[activeTileLayers[0]].type) {29case LAYER_HSCROLL: DrawHLineScrollLayer(0); break;30case LAYER_VSCROLL: DrawVLineScrollLayer(0); break;31case LAYER_3DFLOOR: Draw3DFloorLayer(0); break;32case LAYER_3DSKY: Draw3DSkyLayer(0); break;3334default: break;35}36}3738DrawObjectList(1);3940if (activeTileLayers[1] < LEGACY_LAYER_COUNT) {41switch (stageLayouts[activeTileLayers[1]].type) {42case LAYER_HSCROLL: DrawHLineScrollLayer(1); break;43case LAYER_VSCROLL: DrawVLineScrollLayer(1); break;44case LAYER_3DFLOOR: Draw3DFloorLayer(1); break;45case LAYER_3DSKY: Draw3DSkyLayer(1); break;46default: break;47}48}4950DrawObjectList(2);51DrawObjectList(3);52DrawObjectList(4);5354if (activeTileLayers[2] < LEGACY_LAYER_COUNT) {55switch (stageLayouts[activeTileLayers[2]].type) {56case LAYER_HSCROLL: DrawHLineScrollLayer(2); break;57case LAYER_VSCROLL: DrawVLineScrollLayer(2); break;58case LAYER_3DFLOOR: Draw3DFloorLayer(2); break;59case LAYER_3DSKY: Draw3DSkyLayer(2); break;60default: break;61}62}63}64else if (tLayerMidPoint < 6) {65DrawObjectList(0);6667if (activeTileLayers[0] < LEGACY_LAYER_COUNT) {68switch (stageLayouts[activeTileLayers[0]].type) {69case LAYER_HSCROLL: DrawHLineScrollLayer(0); break;70case LAYER_VSCROLL: DrawVLineScrollLayer(0); break;71case LAYER_3DFLOOR: Draw3DFloorLayer(0); break;72case LAYER_3DSKY: Draw3DSkyLayer(0); break;73default: break;74}75}7677DrawObjectList(1);7879if (activeTileLayers[1] < LEGACY_LAYER_COUNT) {80switch (stageLayouts[activeTileLayers[1]].type) {81case LAYER_HSCROLL: DrawHLineScrollLayer(1); break;82case LAYER_VSCROLL: DrawVLineScrollLayer(1); break;83case LAYER_3DFLOOR: Draw3DFloorLayer(1); break;84case LAYER_3DSKY: Draw3DSkyLayer(1); break;85default: break;86}87}8889DrawObjectList(2);9091if (activeTileLayers[2] < LEGACY_LAYER_COUNT) {92switch (stageLayouts[activeTileLayers[2]].type) {93case LAYER_HSCROLL: DrawHLineScrollLayer(2); break;94case LAYER_VSCROLL: DrawVLineScrollLayer(2); break;95case LAYER_3DFLOOR: Draw3DFloorLayer(2); break;96case LAYER_3DSKY: Draw3DSkyLayer(2); break;97default: break;98}99}100101DrawObjectList(3);102DrawObjectList(4);103}104105if (tLayerMidPoint < 6) {106if (activeTileLayers[3] < LEGACY_LAYER_COUNT) {107switch (stageLayouts[activeTileLayers[3]].type) {108case LAYER_HSCROLL: DrawHLineScrollLayer(3); break;109case LAYER_VSCROLL: DrawVLineScrollLayer(3); break;110case LAYER_3DFLOOR: Draw3DFloorLayer(3); break;111case LAYER_3DSKY: Draw3DSkyLayer(3); break;112default: break;113}114}115116DrawObjectList(5);117DrawObjectList(7); // ???118DrawObjectList(6);119}120121if (fadeMode > 0)122DrawRectangle(0, 0, SCREEN_XSIZE, SCREEN_YSIZE, fadeR, fadeG, fadeB, fadeA);123124#if !RETRO_USE_ORIGINAL_CODE125DrawDebugOverlays();126#endif127}128129#if !RETRO_USE_ORIGINAL_CODE130void RSDK::Legacy::v4::DrawDebugOverlays()131{132if (showHitboxes) {133for (int32 i = 0; i < debugHitboxCount; ++i) {134DebugHitboxInfo *info = &debugHitboxList[i];135int32 x = info->pos.x + (info->hitbox.left << 16);136int32 y = info->pos.y + (info->hitbox.top << 16);137int32 w = abs((info->pos.x + (info->hitbox.right << 16)) - x) >> 16;138int32 h = abs((info->pos.y + (info->hitbox.bottom << 16)) - y) >> 16;139x = (x >> 16) - xScrollOffset;140y = (y >> 16) - yScrollOffset;141142switch (info->type) {143case H_TYPE_TOUCH:144if (showHitboxes & 1)145DrawRectangle(x, y, w, h, info->collision ? 0x80 : 0xFF, info->collision ? 0x80 : 0x00, 0x00, 0x60);146break;147148case H_TYPE_BOX:149if (showHitboxes & 1) {150DrawRectangle(x, y, w, h, 0x00, 0x00, 0xFF, 0x60);151if (info->collision & 1) // top152DrawRectangle(x, y, w, 1, 0xFF, 0xFF, 0x00, 0xC0);153if (info->collision & 8) // bottom154DrawRectangle(x, y + h, w, 1, 0xFF, 0xFF, 0x00, 0xC0);155if (info->collision & 2) { // left156int32 sy = y;157int32 sh = h;158if (info->collision & 1) {159sy++;160sh--;161}162if (info->collision & 8)163sh--;164DrawRectangle(x, sy, 1, sh, 0xFF, 0xFF, 0x00, 0xC0);165}166if (info->collision & 4) { // right167int32 sy = y;168int32 sh = h;169if (info->collision & 1) {170sy++;171sh--;172}173if (info->collision & 8)174sh--;175DrawRectangle(x + w, sy, 1, sh, 0xFF, 0xFF, 0x00, 0xC0);176}177}178break;179180case H_TYPE_PLAT:181if (showHitboxes & 1) {182DrawRectangle(x, y, w, h, 0x00, 0xFF, 0x00, 0x60);183if (info->collision & 1) // top184DrawRectangle(x, y, w, 1, 0xFF, 0xFF, 0x00, 0xC0);185if (info->collision & 8) // bottom186DrawRectangle(x, y + h, w, 1, 0xFF, 0xFF, 0x00, 0xC0);187}188break;189}190}191}192193if (engine.showPaletteOverlay) {194for (int32 p = 0; p < LEGACY_PALETTE_COUNT; ++p) {195int32 x = (SCREEN_XSIZE - (0x10 << 3));196int32 y = (SCREEN_YSIZE - (0x10 << 2));197198for (int32 c = 0; c < PALETTE_BANK_SIZE; ++c) {199uint32 clr = GetPaletteEntryPacked(p, c);200201DrawRectangle(x + ((c & 0xF) << 1) + ((p % (LEGACY_PALETTE_COUNT / 2)) * (2 * 16)),202y + ((c >> 4) << 1) + ((p / (LEGACY_PALETTE_COUNT / 2)) * (2 * 16)), 2, 2, (clr >> 16) & 0xFF, (clr >> 8) & 0xFF,203(clr >> 0) & 0xFF, 0xFF);204}205}206}207}208#endif209210