Path: blob/master/RSDKv5/RSDK/Graphics/Legacy/v3/DrawingLegacyv3.cpp
1171 views
1void RSDK::Legacy::v3::DrawObjectList(int32 group)2{3int32 size = drawListEntries[group].listSize;4for (int32 i = 0; i < size; ++i) {5objectLoop = drawListEntries[group].entityRefs[i];6int32 type = objectEntityList[objectLoop].type;78if (type) {9activePlayer = 0;10if (scriptCode[objectScriptList[type].subDraw.scriptCodePtr] > 0)11ProcessScript(objectScriptList[type].subDraw.scriptCodePtr, objectScriptList[type].subDraw.jumpTablePtr, SUB_DRAW);12}13}14}1516void RSDK::Legacy::v3::DrawStageGFX()17{18waterDrawPos = waterLevel - yScrollOffset;1920if (waterDrawPos < 0)21waterDrawPos = 0;2223if (waterDrawPos > SCREEN_YSIZE)24waterDrawPos = SCREEN_YSIZE;2526DrawObjectList(0);27if (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;33default: break;34}35}3637DrawObjectList(1);38if (activeTileLayers[1] < LEGACY_LAYER_COUNT) {39switch (stageLayouts[activeTileLayers[1]].type) {40case LAYER_HSCROLL: DrawHLineScrollLayer(1); break;41case LAYER_VSCROLL: DrawVLineScrollLayer(1); break;42case LAYER_3DFLOOR: Draw3DFloorLayer(1); break;43case LAYER_3DSKY: Draw3DSkyLayer(1); break;44default: break;45}46}4748DrawObjectList(2);49if (activeTileLayers[2] < LEGACY_LAYER_COUNT) {50switch (stageLayouts[activeTileLayers[2]].type) {51case LAYER_HSCROLL: DrawHLineScrollLayer(2); break;52case LAYER_VSCROLL: DrawVLineScrollLayer(2); break;53case LAYER_3DFLOOR: Draw3DFloorLayer(2); break;54case LAYER_3DSKY: Draw3DSkyLayer(2); break;55default: break;56}57}5859DrawObjectList(3);60DrawObjectList(4);61if (activeTileLayers[3] < LEGACY_LAYER_COUNT) {62switch (stageLayouts[activeTileLayers[3]].type) {63case LAYER_HSCROLL: DrawHLineScrollLayer(3); break;64case LAYER_VSCROLL: DrawVLineScrollLayer(3); break;65case LAYER_3DFLOOR: Draw3DFloorLayer(3); break;66case LAYER_3DSKY: Draw3DSkyLayer(3); break;67default: break;68}69}7071DrawObjectList(5);72// Extra Origins draw list73DrawObjectList(7);74DrawObjectList(6);7576if (fadeMode > 0)77DrawRectangle(0, 0, SCREEN_XSIZE, SCREEN_YSIZE, fadeR, fadeG, fadeB, fadeA);7879#if !RETRO_USE_ORIGINAL_CODE80DrawDebugOverlays();81#endif82}8384#if !RETRO_USE_ORIGINAL_CODE85void RSDK::Legacy::v3::DrawDebugOverlays()86{87if (showHitboxes) {8889for (int32 i = 0; i < debugHitboxCount; ++i) {90DebugHitboxInfo *info = &debugHitboxList[i];91int32 x = info->pos.x + (info->hitbox.left << 16);92int32 y = info->pos.y + (info->hitbox.top << 16);93int32 w = abs((info->pos.x + (info->hitbox.right << 16)) - x) >> 16;94int32 h = abs((info->pos.y + (info->hitbox.bottom << 16)) - y) >> 16;95x = (x >> 16) - xScrollOffset;96y = (y >> 16) - yScrollOffset;9798switch (info->type) {99case H_TYPE_TOUCH:100if (showHitboxes & 1)101DrawRectangle(x, y, w, h, info->collision ? 0x80 : 0xFF, info->collision ? 0x80 : 0x00, 0x00, 0x60);102break;103104case H_TYPE_BOX:105if (showHitboxes & 1) {106DrawRectangle(x, y, w, h, 0x00, 0x00, 0xFF, 0x60);107if (info->collision & 1) // top108DrawRectangle(x, y, w, 1, 0xFF, 0xFF, 0x00, 0xC0);109110if (info->collision & 8) // bottom111DrawRectangle(x, y + h, w, 1, 0xFF, 0xFF, 0x00, 0xC0);112113if (info->collision & 2) { // left114int32 sy = y;115int32 sh = h;116if (info->collision & 1) {117sy++;118sh--;119}120if (info->collision & 8)121sh--;122DrawRectangle(x, sy, 1, sh, 0xFF, 0xFF, 0x00, 0xC0);123}124125if (info->collision & 4) { // right126int32 sy = y;127int32 sh = h;128if (info->collision & 1) {129sy++;130sh--;131}132if (info->collision & 8)133sh--;134DrawRectangle(x + w, sy, 1, sh, 0xFF, 0xFF, 0x00, 0xC0);135}136}137break;138139case H_TYPE_PLAT:140if (showHitboxes & 1) {141DrawRectangle(x, y, w, h, 0x00, 0xFF, 0x00, 0x60);142143if (info->collision & 1) // top144DrawRectangle(x, y, w, 1, 0xFF, 0xFF, 0x00, 0xC0);145146if (info->collision & 8) // bottom147DrawRectangle(x, y + h, w, 1, 0xFF, 0xFF, 0x00, 0xC0);148}149break;150151case H_TYPE_HAMMER:152if (showHitboxes & 1)153DrawRectangle(x, y, w, h, info->collision ? 0xA0 : 0xFF, info->collision ? 0xA0 : 0xFF, 0x00, 0x60);154break;155}156}157}158159if (engine.showPaletteOverlay) {160for (int32 p = 0; p < LEGACY_PALETTE_COUNT; ++p) {161int32 x = (SCREEN_XSIZE - (0x10 << 3));162int32 y = (SCREEN_YSIZE - (0x10 << 2));163164for (int32 c = 0; c < PALETTE_BANK_SIZE; ++c) {165uint32 clr = GetPaletteEntryPacked(p, c);166167DrawRectangle(x + ((c & 0xF) << 1) + ((p % (LEGACY_PALETTE_COUNT / 2)) * (2 * 16)),168y + ((c >> 4) << 1) + ((p / (LEGACY_PALETTE_COUNT / 2)) * (2 * 16)), 2, 2, (clr >> 16) & 0xFF, (clr >> 8) & 0xFF,169(clr >> 0) & 0xFF, 0xFF);170}171}172}173}174#endif175176bool32 RSDK::Legacy::v3::VideoSkipCB() { return controller->keyStart.press || controller->keyA.press || controller->keyB.press; }177178