From 84aecfa823c5808e5946dbfd58be6e85414aca59 Mon Sep 17 00:00:00 2001 From: Alexander Batalov Date: Sat, 2 Sep 2023 20:07:02 +0300 Subject: [PATCH] Add draw_rect --- src/mapper/map_func.cc | 26 ++++++++++++++++++++++++++ src/mapper/map_func.h | 1 + 2 files changed, 27 insertions(+) diff --git a/src/mapper/map_func.cc b/src/mapper/map_func.cc index f328b0a..8b032f2 100644 --- a/src/mapper/map_func.cc +++ b/src/mapper/map_func.cc @@ -1,6 +1,8 @@ #include "mapper/map_func.h" +#include "memory.h" #include "proto.h" +#include "svga.h" #include "window_manager.h" namespace fallout { @@ -20,6 +22,30 @@ void copy_proto_lists() // TODO: Incomplete. } +// 0x4842D4 +void draw_rect(Rect* rect, unsigned char color) +{ + int width = rect->right - rect->left; + int height = rect->bottom - rect->top; + int max_dimension; + + if (height < width) { + max_dimension = width; + } else { + max_dimension = height; + } + + unsigned char* buffer = (unsigned char*)internal_malloc(max_dimension); + if (buffer != NULL) { + memset(buffer, color, max_dimension); + _scr_blit(buffer, width, 1, 0, 0, width, 1, rect->left, rect->top); + _scr_blit(buffer, 1, height, 0, 0, 1, height, rect->left, rect->top); + _scr_blit(buffer, width, 1, 0, 0, width, 1, rect->left, rect->bottom); + _scr_blit(buffer, 1, height, 0, 0, 1, height, rect->right, rect->top); + internal_free(buffer); + } +} + // 0x4843A0 void erase_rect(Rect* rect) { diff --git a/src/mapper/map_func.h b/src/mapper/map_func.h index 0961c90..3d03b42 100644 --- a/src/mapper/map_func.h +++ b/src/mapper/map_func.h @@ -7,6 +7,7 @@ namespace fallout { void setup_map_dirs(); void copy_proto_lists(); +void draw_rect(Rect* rect); void erase_rect(Rect* rect); int toolbar_proto(int type, int id); bool map_toggle_block_obj_viewing_on();