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

Method MapTiles_Draw

Source/PC/Graphics_PC.cpp:286–342  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

284}
285
286void cGraphics_PC::MapTiles_Draw() {
287
288 uint8* Target = mSurface->GetSurfaceBuffer();
289
290 uint8* CurrentMapPtr = mFodder->mMap->data() + mFodder->mMapTile_Ptr;
291
292 // Y
293 for (uint16 cx = 0; cx <= g_Fodder->getWindowRows() + 1; ++cx) {
294 uint8* MapPtr = CurrentMapPtr;
295 uint8* TargetRow = Target;
296
297 uint16 StartY = 0;
298
299 if (cx == 0)
300 StartY = mFodder->mMapTile_RowOffset;
301
302 // X
303 for (uint16 cx2 = 0; cx2 <= g_Fodder->getWindowColumns() + 1; ++cx2) {
304 uint8* TargetTmp = TargetRow;
305
306 // Verify we are inside the actual map data
307 if (MapPtr >= mFodder->mMap->data()) {
308
309 if (MapPtr >= mFodder->mMap->data() + mFodder->mMap->size())
310 continue;
311
312 uint16 Tile = readLE<uint16>(MapPtr) & 0x1FF;
313 if (Tile > 0x1DF)
314 Tile = 0;
315
316 uint8* TilePtr = mTile_Gfx_Ptrs[Tile];
317 uint16 StartX = 0;
318
319 TilePtr += StartY * 0x140;
320
321 if (cx2 == 0)
322 StartX = mFodder->mMapTile_ColumnOffset;
323
324 // Each Tile Row
325 for (uint16 i = StartY; i < 16; ++i) {
326
327 memcpy(TargetTmp, TilePtr + StartX, 16 - StartX);
328
329 TilePtr += 0x140;
330 TargetTmp += mSurface->GetWidth();
331 }
332
333 MapPtr += 2;
334 TargetRow += (16 - StartX);
335 }
336 }
337
338 Target += mSurface->GetWidth() * (16 - StartY);
339 CurrentMapPtr += mFodder->mMapLoaded->getWidth() << 1;
340 }
341 mSurface->Save();
342}
343

Callers

nothing calls this directly

Calls 7

GetSurfaceBufferMethod · 0.80
getWindowRowsMethod · 0.80
getWindowColumnsMethod · 0.80
GetWidthMethod · 0.80
SaveMethod · 0.80
sizeMethod · 0.45
getWidthMethod · 0.45

Tested by

no test coverage detected