MCPcopy Create free account
hub / github.com/OpenFodder/openfodder / HeliIntroBlit_OpaqueAlignedX

Method HeliIntroBlit_OpaqueAlignedX

Source/PC/Graphics_PC.cpp:881–961  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

879}
880
881void cGraphics_PC::HeliIntroBlit_OpaqueAlignedX(tSharedBuffer pDsSi, int16 pCx)
882{
883 uint8* Ds = pDsSi->data();
884
885 // Original logic works in 4-pixel groups (80 groups for 320px wide).
886 const int16 groupX = (pCx >> 2);
887 int16 ax = groupX;
888 int16 dx = ax;
889
890 ax -= 80;
891 int16 word_4285F = -ax;
892
893 const int planeShift = (pCx & 3); // <-- the bit the old code discards
894
895 // Base points at the first 4-pixel group for pCx, Y offset unchanged.
896 uint8* base = mSurface->GetSurfaceBuffer() + mMission_Intro_DrawY + (groupX * 4);
897
898 ++dx;
899
900 for (uint8 srcPlane = 0; srcPlane < 4; ++srcPlane)
901 {
902 // Map source plane (0..3) to the correct destination plane for pixel-accurate X.
903 const int dstPlane = (srcPlane + planeShift) & 3;
904
905 // If the plane rotation wraps (e.g. planeShift=3, srcPlane=2 -> 5),
906 // that plane's pixels start one 4-pixel group later.
907 const int groupCarry = ((srcPlane + planeShift) >> 2) & 1;
908
909 // we might start in the next group depending on carry.
910 uint8* destPtr = base + (groupCarry * 4) + dstPlane;
911 uint8* di = destPtr;
912
913 for (int16 bx = mMission_Intro_DrawX; bx > 0; --bx)
914 {
915 int16 cx = word_4285F;
916
917 if (cx & 1)
918 {
919 *di = *Ds++;
920 di += 4;
921 }
922
923 cx >>= 1;
924 while (cx > 0)
925 {
926 *di = *Ds++;
927 di += 4;
928
929 *di = *Ds++;
930 di += 4;
931
932 --cx;
933 }
934
935 cx = dx;
936
937 di -= mSurface->GetWidth() - 12 - 16;
938 --Ds;

Callers

nothing calls this directly

Calls 2

GetSurfaceBufferMethod · 0.80
GetWidthMethod · 0.80

Tested by

no test coverage detected