1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113
|
/*
* GamesPak
*
* Copyright (C) Evan Harris, 1994, 1995.
*
* Permission is granted to freely redistribute and modify this code,
* providing the author(s) get credit for having written it.
*/
#include "vga16.h"
#include "mouse.h"
#define LIGHT 0
#define DARK 1
#define MOUSE_IMAGE_PTS 37
struct mouse_image_data {
int x_offset;
int y_offset;
int colour;
};
struct mouse_image_data mouse_image_data[MOUSE_IMAGE_PTS] = {
{ 0, 0, LIGHT },
{ 1, 0, LIGHT },
{ 2, 0, LIGHT },
{ 3, 0, LIGHT },
{ 4, 0, LIGHT },
{ 5, 0, LIGHT },
{ 0, 1, LIGHT },
{ 1, 1, DARK },
{ 2, 1, DARK },
{ 3, 1, LIGHT },
{ 0, 2, LIGHT },
{ 1, 2, DARK },
{ 2, 2, DARK },
{ 3, 2, LIGHT },
{ 4, 2, LIGHT },
{ 0, 3, LIGHT },
{ 1, 3, LIGHT },
{ 2, 3, LIGHT },
{ 3, 3, DARK },
{ 4, 3, LIGHT },
{ 5, 3, LIGHT },
{ 0, 4, LIGHT },
{ 2, 4, LIGHT },
{ 3, 4, LIGHT },
{ 4, 4, DARK },
{ 5, 4, LIGHT },
{ 6, 4, LIGHT },
{ 0, 5, LIGHT },
{ 3, 5, LIGHT },
{ 4, 5, LIGHT },
{ 5, 5, DARK },
{ 6, 5, LIGHT },
{ 7, 5, LIGHT },
{ 4, 6, LIGHT },
{ 5, 6, LIGHT },
{ 6, 6, LIGHT },
{ 5, 7, LIGHT },
};
void
RenderMousePointer(int x, int y, int light, int dark, int width, int height)
{
int i;
for (i = 0; i < MOUSE_IMAGE_PTS; i++) {
if (x + mouse_image_data[i].x_offset < width &&
y + mouse_image_data[i].y_offset < height) {
if (mouse_image_data[i].colour == LIGHT) {
vga16_setpixel(light, x + mouse_image_data[i].x_offset,
y + mouse_image_data[i].y_offset);
} else {
vga16_setpixel(dark, x + mouse_image_data[i].x_offset,
y + mouse_image_data[i].y_offset);
}
}
}
}
void
RestoreUnderMousePointer(int x, int y, int width, int height, int *colour)
{
int i;
for (i = 0; i < MOUSE_IMAGE_PTS; i++) {
if (x + mouse_image_data[i].x_offset < width &&
y + mouse_image_data[i].y_offset < height) {
vga16_setpixel(colour[i], x + mouse_image_data[i].x_offset,
y + mouse_image_data[i].y_offset);
}
}
}
void
SaveUnderMousePointer(int x, int y, int width, int height, int *colour)
{
int i;
for (i = 0; i < MOUSE_IMAGE_PTS; i++) {
if (x + mouse_image_data[i].x_offset < width &&
y + mouse_image_data[i].y_offset < height) {
colour[i] = vga16_getpixel(x + mouse_image_data[i].x_offset,
y + mouse_image_data[i].y_offset);
}
}
}
|