#include "bmpload.h" #include "const.h" #include "arena.h" #include "system/vga.h" char arenaLayout[10][10] = { { 1, 1, 1, 1, 0, 0, 1, 1, 1, 1 }, { 1, 0, 0, 0, 0, 0, 0, 0, 0, 1 }, { 1, 0, 0, 0, 0, 0, 0, 0, 0, 1 }, { 1, 0, 0, 0, 0, 0, 0, 0, 0, 1 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, { 1, 0, 0, 0, 0, 0, 0, 0, 0, 1 }, { 1, 0, 0, 0, 0, 0, 0, 0, 0, 1 }, { 1, 0, 0, 0, 0, 0, 0, 0, 0, 1 }, { 1, 1, 1, 1, 0, 0, 1, 1, 1, 1 } }; struct SpriteRender arenaWallTop, arenaWallSide, arenaFloor; void setupWallSprites(struct BMPImage *spritesheetImage) { buildSpriteFromSpritesheet( spritesheetImage, &arenaWallTop, 0, 0, 20, 20 ); buildSpriteFromSpritesheet( spritesheetImage, &arenaWallSide, 20, 0, 20, 20 ); buildSpriteFromSpritesheet( spritesheetImage, &arenaFloor, 40, 0, 20, 20 ); } extern void renderFloorTile(byte *); // push items onto stack #pragma aux (__cdecl) renderFloorTile "renderFloorTile_" void renderArenaTile(int x, int y) { char tile; struct SpriteRender *target; byte *drawBuffer; tile = arenaLayout[y][x]; switch (tile) { case 0: target = &arenaFloor; break; case 1: target = &arenaWallTop; break; case 2: target = &arenaWallSide; break; } target->x = x * TILE_SIZE; target->y = y * TILE_SIZE; if (tile == 0) { drawBuffer = getDrawBuffer(); renderFloorTile( drawBuffer + target->x + target->y * VGA_DISPLAY_WIDTH ); } else { drawSprite(target); } } char arenaRedrawRequests[ARENA_HEIGHT_TILES][ARENA_WIDTH_TILES]; void clearArenaRedrawRequests() { int x, y; for (y = 0; y < ARENA_HEIGHT_TILES; ++y) { for (x = 0; x < ARENA_WIDTH_TILES; ++x) { arenaRedrawRequests[y][x] = 0; } } } void redrawArena() { int x, y; for (y = 0; y < ARENA_HEIGHT_TILES; ++y) { for (x = 0; x < ARENA_WIDTH_TILES; ++x) { if (arenaRedrawRequests[y][x]) { renderArenaTile(x, y); arenaRedrawRequests[y][x] = 0; } } } } void drawOnlyArena(struct SpriteBounds *bounds) { int leftTileX, rightTileX, topTileY, bottomTileY; leftTileX = bounds->left / TILE_SIZE; rightTileX = bounds->right / TILE_SIZE; topTileY = bounds->top / TILE_SIZE; bottomTileY = bounds->bottom / TILE_SIZE; arenaRedrawRequests[topTileY][leftTileX] = 1; arenaRedrawRequests[topTileY][rightTileX] = 1; arenaRedrawRequests[bottomTileY][leftTileX] = 1; arenaRedrawRequests[bottomTileY][rightTileX] = 1; } void buildArena() { int x, y; for (y = 0; y < 10; ++y) { for (x = 0; x < 10; ++x) { renderArenaTile(x, y); } } }