Allocs a bitmap of w x h size If add_mem is nonzero, adds that to the amount alloced Returns bitmap handle if successful, -1 if otherwise
| 510 | // If add_mem is nonzero, adds that to the amount alloced |
| 511 | // Returns bitmap handle if successful, -1 if otherwise |
| 512 | int bm_AllocBitmap(int w, int h, int add_mem) { |
| 513 | int n = 0, i; |
| 514 | if (!Bitmaps_initted) { |
| 515 | Int3(); |
| 516 | mprintf(0, "Bitmaps not initted!!!\n"); |
| 517 | return -1; |
| 518 | } |
| 519 | |
| 520 | for (i = 0; i < MAX_BITMAPS; i++) { |
| 521 | if (GameBitmaps[i].used == 0) { |
| 522 | n = i; |
| 523 | break; |
| 524 | } |
| 525 | } |
| 526 | // If we can't find a free slot in which to alloc, bail out |
| 527 | if (i == MAX_BITMAPS) { |
| 528 | Int3(); |
| 529 | mprintf(0, "ERROR! Couldn't find a free bitmap to alloc!\n"); |
| 530 | return -1; |
| 531 | } |
| 532 | memset(&GameBitmaps[n], 0, sizeof(bms_bitmap)); |
| 533 | int ret = bm_AllocateMemoryForIndex(n, w, h, add_mem); |
| 534 | if (ret >= 0) { |
| 535 | GameBitmaps[n].used = 1; |
| 536 | GameBitmaps[n].cache_slot = -1; |
| 537 | } |
| 538 | return ret; |
| 539 | } |
| 540 | // Just like bm_AllocBitmap but doesn't actually allocate memory. Useful for paging! |
| 541 | int bm_AllocNoMemBitmap(int w, int h) { |
| 542 | int n = 0, i; |
no test coverage detected