MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / bm_AllocNoMemBitmap

Function bm_AllocNoMemBitmap

bitmap/bitmain.cpp:541–574  ·  view source on GitHub ↗

Just like bm_AllocBitmap but doesn't actually allocate memory. Useful for paging!

Source from the content-addressed store, hash-verified

539}
540// Just like bm_AllocBitmap but doesn't actually allocate memory. Useful for paging!
541int bm_AllocNoMemBitmap(int w, int h) {
542 int n = 0, i;
543 if (!Bitmaps_initted) {
544 Int3();
545 mprintf(0, "Bitmaps not initted!!!\n");
546 return -1;
547 }
548
549 for (i = 0; i < MAX_BITMAPS; i++) {
550 if (GameBitmaps[i].used == 0) {
551 n = i;
552 break;
553 }
554 }
555 // If we can't find a free slot in which to alloc, bail out
556 if (i == MAX_BITMAPS) {
557 Int3();
558 mprintf(0, "ERROR! Couldn't find a free bitmap to alloc!\n");
559 return -1;
560 }
561 // If no go on the malloc, bail out with -1
562
563 memset(&GameBitmaps[n], 0, sizeof(bms_bitmap));
564
565 GameBitmaps[n].width = w;
566 GameBitmaps[n].height = h;
567 GameBitmaps[n].used = 1;
568 GameBitmaps[n].format = BITMAP_FORMAT_STANDARD;
569 GameBitmaps[n].flags = BF_NOT_RESIDENT | BF_CHANGED | BF_BRAND_NEW;
570 GameBitmaps[n].cache_slot = -1;
571
572 Num_of_bitmaps++;
573 return n;
574}
575// Searches thru all bitmaps for a specific name, returns -1 if not found
576// or index of bitmap with name
577int bm_FindBitmapName(const char *name) {

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected