2006-03-20 17:12:09 +00:00
|
|
|
/*
|
2014-06-01 17:55:23 +00:00
|
|
|
* Portions of this file are copyright Rebirth contributors and licensed as
|
|
|
|
* described in COPYING.txt.
|
|
|
|
* Portions of this file are copyright Parallax Software and licensed
|
|
|
|
* according to the Parallax license below.
|
|
|
|
* See COPYING.txt for license details.
|
|
|
|
|
2006-03-20 17:12:09 +00:00
|
|
|
THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
|
|
|
|
SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO
|
|
|
|
END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
|
|
|
|
ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
|
|
|
|
IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
|
|
|
|
SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
|
|
|
|
FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
|
|
|
|
CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS
|
2013-02-24 02:40:43 +00:00
|
|
|
AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
|
2006-03-20 17:12:09 +00:00
|
|
|
COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
|
|
|
|
*/
|
|
|
|
|
2014-07-30 03:12:52 +00:00
|
|
|
#include <algorithm>
|
2006-03-20 17:12:09 +00:00
|
|
|
#include "u_mem.h"
|
|
|
|
#include "gr.h"
|
|
|
|
|
2015-12-13 18:00:49 +00:00
|
|
|
namespace dcx {
|
2015-12-05 22:57:23 +00:00
|
|
|
|
2020-12-26 21:17:29 +00:00
|
|
|
namespace {
|
|
|
|
|
2020-07-16 02:31:04 +00:00
|
|
|
static void gr_ubox0(grs_canvas &canvas, const int left, const int top, const int right, const int bot, const color_palette_index color)
|
2006-03-20 17:12:09 +00:00
|
|
|
{
|
2014-09-26 02:42:13 +00:00
|
|
|
int d;
|
2016-12-29 03:27:10 +00:00
|
|
|
const auto rowsize = canvas.cv_bitmap.bm_rowsize;
|
|
|
|
const auto ptr1 = &canvas.cv_bitmap.get_bitmap_data()[rowsize * top + left];
|
2020-07-16 02:31:04 +00:00
|
|
|
auto ptr2 = ptr1;
|
2006-03-20 17:12:09 +00:00
|
|
|
d = right - left;
|
|
|
|
|
2015-02-05 03:03:49 +00:00
|
|
|
std::fill_n(ptr1 + 1, (right - left) - 1, color);
|
2015-02-14 22:48:27 +00:00
|
|
|
for (uint_fast32_t i = bot - top + 1; i--;)
|
2006-03-20 17:12:09 +00:00
|
|
|
{
|
2016-07-06 01:54:24 +00:00
|
|
|
ptr2[0] = color;
|
|
|
|
ptr2[d] = color;
|
2016-12-29 03:27:10 +00:00
|
|
|
ptr2 += rowsize;
|
2006-03-20 17:12:09 +00:00
|
|
|
}
|
2015-01-29 04:27:37 +00:00
|
|
|
std::fill_n(ptr2 + 1, (right - left) - 1, color);
|
2006-03-20 17:12:09 +00:00
|
|
|
}
|
|
|
|
|
2020-07-16 02:31:04 +00:00
|
|
|
static void gr_ubox12(grs_canvas &canvas, const int left, const int top, const int right, const int bot, const color_palette_index color)
|
2006-03-20 17:12:09 +00:00
|
|
|
{
|
2016-12-29 03:27:11 +00:00
|
|
|
gr_uline(canvas, i2f(left), i2f(top), i2f(right), i2f(top), color);
|
|
|
|
gr_uline(canvas, i2f(right), i2f(top), i2f(right), i2f(bot), color);
|
|
|
|
gr_uline(canvas, i2f(left), i2f(top), i2f(left), i2f(bot), color);
|
|
|
|
gr_uline(canvas, i2f(left), i2f(bot), i2f(right), i2f(bot), color);
|
2006-03-20 17:12:09 +00:00
|
|
|
}
|
|
|
|
|
2016-09-11 18:49:16 +00:00
|
|
|
#if DXX_USE_EDITOR
|
2020-07-16 02:31:04 +00:00
|
|
|
static void gr_box0(grs_canvas &canvas, const uint_fast32_t left, const uint_fast32_t top, uint_fast32_t right, uint_fast32_t bot, const color_palette_index color)
|
2016-12-29 03:27:10 +00:00
|
|
|
{
|
|
|
|
const auto maxy = canvas.cv_bitmap.bm_h - 1;
|
|
|
|
if (top > maxy)
|
|
|
|
return;
|
|
|
|
const auto maxx = canvas.cv_bitmap.bm_w - 1;
|
|
|
|
if (left > maxx)
|
|
|
|
return;
|
|
|
|
if (bot > maxy)
|
|
|
|
bot = maxy;
|
|
|
|
if (right > maxx)
|
|
|
|
right = maxx;
|
|
|
|
gr_ubox0(canvas, left, top, right, bot, color);
|
|
|
|
}
|
|
|
|
|
2020-07-16 02:31:04 +00:00
|
|
|
static void gr_box12(grs_canvas &canvas, const uint_fast32_t left, const uint_fast32_t top, uint_fast32_t right, uint_fast32_t bot, const color_palette_index color)
|
2006-03-20 17:12:09 +00:00
|
|
|
{
|
2016-12-29 03:27:11 +00:00
|
|
|
const auto maxy = canvas.cv_bitmap.bm_h - 1;
|
|
|
|
if (top > maxy)
|
|
|
|
return;
|
|
|
|
const auto maxx = canvas.cv_bitmap.bm_w - 1;
|
|
|
|
if (left > maxx)
|
|
|
|
return;
|
|
|
|
if (bot > maxy)
|
|
|
|
bot = maxy;
|
|
|
|
if (right > maxx)
|
|
|
|
right = maxx;
|
|
|
|
gr_ubox12(canvas, left, top, right, bot, color);
|
2006-03-20 17:12:09 +00:00
|
|
|
}
|
2016-02-12 04:02:28 +00:00
|
|
|
#endif
|
2006-03-20 17:12:09 +00:00
|
|
|
|
2020-12-26 21:17:29 +00:00
|
|
|
}
|
|
|
|
|
2020-07-16 02:31:04 +00:00
|
|
|
void gr_ubox(grs_canvas &canvas, const int left, const int top, const int right, const int bot, const color_palette_index color)
|
2006-03-20 17:12:09 +00:00
|
|
|
{
|
2017-01-01 00:45:44 +00:00
|
|
|
if (canvas.cv_bitmap.get_type() == bm_mode::linear)
|
|
|
|
gr_ubox0(canvas, left, top, right, bot, color);
|
2006-03-20 17:12:09 +00:00
|
|
|
else
|
2017-01-01 00:45:44 +00:00
|
|
|
gr_ubox12(canvas, left, top, right, bot, color);
|
2006-03-20 17:12:09 +00:00
|
|
|
}
|
|
|
|
|
2016-09-11 18:49:16 +00:00
|
|
|
#if DXX_USE_EDITOR
|
2020-07-16 02:31:04 +00:00
|
|
|
void gr_box(grs_canvas &canvas, const uint_fast32_t left, const uint_fast32_t top, const uint_fast32_t right, const uint_fast32_t bot, const color_palette_index color)
|
2006-03-20 17:12:09 +00:00
|
|
|
{
|
2017-01-01 00:45:44 +00:00
|
|
|
if (canvas.cv_bitmap.get_type() == bm_mode::linear)
|
|
|
|
gr_box0(canvas, left, top, right, bot, color);
|
2006-03-20 17:12:09 +00:00
|
|
|
else
|
2017-01-01 00:45:44 +00:00
|
|
|
gr_box12(canvas, left, top, right, bot, color);
|
2006-03-20 17:12:09 +00:00
|
|
|
}
|
2016-02-12 04:02:28 +00:00
|
|
|
#endif
|
2015-12-05 22:57:23 +00:00
|
|
|
|
|
|
|
}
|