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

Function scrollrt_draw_cursor_item

Source/scrollrt.cpp:131–207  ·  view source on GitHub ↗

* @brief Draw the cursor on the back buffer */

Source from the content-addressed store, hash-verified

129 * @brief Draw the cursor on the back buffer
130 */
131static void scrollrt_draw_cursor_item()
132{
133 int i, mx, my, col;
134 BYTE *src, *dst;
135
136 assert(! sgdwCursWdt);
137
138 if (pcurs <= 0 || cursW == 0 || cursH == 0) {
139 return;
140 }
141
142 if (sgbControllerActive && pcurs != CURSOR_TELEPORT && !invflag && (!chrflag || plr[myplr]._pStatPts <= 0)) {
143 return;
144 }
145
146 mx = MouseX - 1;
147 if (mx < 0 - cursW - 1) {
148 return;
149 } else if (mx > SCREEN_WIDTH - 1) {
150 return;
151 }
152 my = MouseY - 1;
153 if (my < 0 - cursH - 1) {
154 return;
155 } else if (my > SCREEN_HEIGHT - 1) {
156 return;
157 }
158
159 sgdwCursX = mx;
160 sgdwCursWdt = sgdwCursX + cursW + 1;
161 if (sgdwCursWdt > SCREEN_WIDTH - 1) {
162 sgdwCursWdt = SCREEN_WIDTH - 1;
163 }
164 sgdwCursX &= ~3;
165 sgdwCursWdt |= 3;
166 sgdwCursWdt -= sgdwCursX;
167 sgdwCursWdt++;
168
169 sgdwCursY = my;
170 sgdwCursHgt = sgdwCursY + cursH + 1;
171 if (sgdwCursHgt > SCREEN_HEIGHT - 1) {
172 sgdwCursHgt = SCREEN_HEIGHT - 1;
173 }
174 sgdwCursHgt -= sgdwCursY;
175 sgdwCursHgt++;
176
177 assert(sgdwCursWdt * sgdwCursHgt < sizeof sgSaveBack);
178 assert(gpBuffer);
179 dst = sgSaveBack;
180 src = &gpBuffer[SCREENXY(sgdwCursX, sgdwCursY)];
181
182 for (i = sgdwCursHgt; i != 0; i--, dst += sgdwCursWdt, src += BUFFER_WIDTH) {
183 memcpy(dst, src, sgdwCursWdt);
184 }
185
186 mx++;
187 my++;
188 gpBufEnd = &gpBuffer[BUFFER_WIDTH * (SCREEN_HEIGHT + SCREEN_Y) - cursW - 2];

Callers 2

DrawAndBlitFunction · 0.85

Calls 3

CelBlitOutlineFunction · 0.85
CelClippedDrawSafeFunction · 0.85
CelDrawLightRedSafeFunction · 0.85

Tested by

no test coverage detected