MCPcopy Create free account
hub / github.com/diasurgical/devilution / DrawGame

Function DrawGame

Source/scrollrt.cpp:799–941  ·  view source on GitHub ↗

* @brief Configure render and process screen rows * @param x Center of view in dPiece coordinate * @param y Center of view in dPiece coordinate */

Source from the content-addressed store, hash-verified

797 * @param y Center of view in dPiece coordinate
798 */
799static void DrawGame(int x, int y)
800{
801 int i, sx, sy, chunks, blocks;
802 int wdt, nSrcOff, nDstOff;
803
804 sx = (SCREEN_WIDTH % 64) / 2;
805 sy = (VIEWPORT_HEIGHT % 32) / 2;
806
807 if (zoomflag) {
808 chunks = ceil(SCREEN_WIDTH / 64);
809 blocks = ceil(VIEWPORT_HEIGHT / 32);
810
811 gpBufStart = &gpBuffer[BUFFER_WIDTH * SCREEN_Y];
812 gpBufEnd = &gpBuffer[BUFFER_WIDTH * (VIEWPORT_HEIGHT + SCREEN_Y)];
813 } else {
814 sy -= 32;
815
816 chunks = ceil(SCREEN_WIDTH / 2 / 64) + 1; // TODO why +1?
817 blocks = ceil(VIEWPORT_HEIGHT / 2 / 32);
818
819 gpBufStart = &gpBuffer[(-17 + SCREEN_Y) * BUFFER_WIDTH];
820 gpBufEnd = &gpBuffer[(160 + SCREEN_Y) * BUFFER_WIDTH];
821 }
822
823 sx += ScrollInfo._sxoff + SCREEN_X;
824 sy += ScrollInfo._syoff + SCREEN_Y + 15;
825
826 // Center screen
827 x -= chunks;
828 y--;
829
830 // Keep evaulating untill MicroTiles can't affect screen
831 blocks += ceil(MicroTileLen / 2);
832
833 if (PANELS_COVER) {
834 if (zoomflag) {
835 if (chrflag || questlog) {
836 x += 2;
837 y -= 2;
838 sx += 288;
839 chunks -= 4;
840 }
841 if (invflag || sbookflag) {
842 x += 2;
843 y -= 2;
844 sx -= 32;
845 chunks -= 4;
846 }
847 }
848 }
849
850 switch (ScrollInfo._sdir) {
851 case SDIR_N:
852 sy -= 32;
853 x--;
854 y--;
855 blocks++;
856 break;

Callers 1

DrawViewFunction · 0.85

Calls 1

scrollrt_drawFunction · 0.85

Tested by

no test coverage detected