2016-07-25 09:04:22 +02:00
|
|
|
#include <internals/bopti.h>
|
2016-07-25 22:38:47 +02:00
|
|
|
#include <internals/display.h>
|
2016-07-06 11:28:51 +02:00
|
|
|
|
|
|
|
/*
|
2017-02-25 19:02:07 +01:00
|
|
|
dimage_part()
|
|
|
|
Draws a portion of an image, defined by its bounding rectangle.
|
|
|
|
Point (left, top) is included, but (left + width, top + height) is
|
|
|
|
excluded.
|
2016-07-06 11:28:51 +02:00
|
|
|
*/
|
2017-03-26 18:38:32 +02:00
|
|
|
void dimage_part(int x, int y, image_t *img, int left, int top, int width,
|
|
|
|
int height)
|
2016-07-06 11:28:51 +02:00
|
|
|
{
|
2017-04-17 13:05:46 +02:00
|
|
|
if(!img || img->magic != 0x01) return;
|
2016-07-14 21:10:51 +02:00
|
|
|
|
2017-04-13 21:59:13 +02:00
|
|
|
structure_t s;
|
|
|
|
command_t command;
|
2017-04-22 21:59:39 +02:00
|
|
|
int actual_width, actual_height;
|
|
|
|
int format = img->format;
|
2016-07-06 11:28:51 +02:00
|
|
|
|
2017-04-13 21:59:13 +02:00
|
|
|
if(format != format_mono && format != format_mono_alpha) return;
|
2016-07-14 21:10:51 +02:00
|
|
|
getStructure(img, &s);
|
2017-02-25 19:02:07 +01:00
|
|
|
if(width < 0) width = s.width;
|
|
|
|
if(height < 0) height = s.height;
|
2016-07-14 21:10:51 +02:00
|
|
|
|
|
|
|
//---
|
2017-02-25 19:02:07 +01:00
|
|
|
// Adjusting the bounding rectangle.
|
2016-07-14 21:10:51 +02:00
|
|
|
//---
|
|
|
|
|
2017-02-25 19:02:07 +01:00
|
|
|
// This is what happens when the bounding rectangle overflows from the
|
|
|
|
// image...
|
|
|
|
if(left < 0) left = 0;
|
|
|
|
if(top < 0) top = 0;
|
|
|
|
if(left + width > s.width) width = s.width - left;
|
|
|
|
if(top + height > s.height) height = s.height - top;
|
2016-07-14 21:10:51 +02:00
|
|
|
|
2017-04-22 21:59:39 +02:00
|
|
|
if(x + width <= 0 || x > 127 || y + height <= 0 || y > 63
|
|
|
|
|| width <= 0 || height <= 0)
|
2017-02-25 19:02:07 +01:00
|
|
|
return;
|
|
|
|
|
|
|
|
command.top = (y < 0) ? (top - y) : top;
|
2017-04-22 21:59:39 +02:00
|
|
|
actual_height = (y + height > 64) ? (64 - y) : height;
|
|
|
|
command.bottom = top + actual_height;
|
|
|
|
|
2017-02-25 19:02:07 +01:00
|
|
|
command.left = ((x < 0) ? (left - x) : left) >> 5;
|
|
|
|
actual_width = (x + width > 128) ? (128 - x) : width;
|
2017-04-22 21:59:39 +02:00
|
|
|
command.right = (left + actual_width - 1) >> 5;
|
2016-07-14 21:10:51 +02:00
|
|
|
|
|
|
|
command.op = bopti_op_mono;
|
2016-07-06 11:28:51 +02:00
|
|
|
|
2016-07-25 09:04:22 +02:00
|
|
|
if(x >= 0) getMasks(x, x + actual_width - 1, command.masks);
|
|
|
|
else getMasks(0, actual_width + x - 1, command.masks);
|
2016-07-06 11:28:51 +02:00
|
|
|
|
2016-07-25 22:38:47 +02:00
|
|
|
bopti_vram = display_getCurrentVRAM();
|
2016-07-06 11:28:51 +02:00
|
|
|
|
2017-04-22 21:59:39 +02:00
|
|
|
for(int i = 0; format; format >>= 1, i++) if(format & 1)
|
2016-07-06 11:28:51 +02:00
|
|
|
{
|
2017-04-22 21:59:39 +02:00
|
|
|
command.x = x - left;
|
|
|
|
command.y = y - top;
|
|
|
|
command.channel = (1 << i);
|
2016-07-06 11:28:51 +02:00
|
|
|
|
2017-04-22 21:59:39 +02:00
|
|
|
bopti(s.data, &s, &command);
|
|
|
|
s.data += s.layer_size;
|
2016-07-06 11:28:51 +02:00
|
|
|
}
|
2017-02-25 19:02:07 +01:00
|
|
|
}
|
2016-07-06 11:28:51 +02:00
|
|
|
|
2017-02-25 19:02:07 +01:00
|
|
|
/*
|
|
|
|
dimage()
|
|
|
|
Displays a monochrome image in the video ram.
|
|
|
|
*/
|
2017-03-26 18:38:32 +02:00
|
|
|
void dimage(int x, int y, image_t *img)
|
2017-02-25 19:02:07 +01:00
|
|
|
{
|
|
|
|
dimage_part(x, y, img, 0, 0, -1, -1);
|
2016-07-06 11:28:51 +02:00
|
|
|
}
|