libdgl/TEST/PAL.C
Gered 62af8575c6 various updates i've left uncommitted for many months
- rename standard integer types to a more familiar (u)int(8/16/32)
- many function/struct renames. i don't _really_ know if what i've done
  for this is better, but it "feels" better to me. many draw/blit
  function names are shorter which is nice, at least. kinda important
  to me because i develop this on a real DOS machine in 80x50 text mode.
- add 'extern "C"' blocks to headers for C++ compiler usage
- draw/pixel color value arguments for functions should all have been
  changed to be uint8 instead of a full 32-bit int. feels right, but
  maybe should've left alone...
- small fix to keyboard handler. noticed a problem on one thinkpad
  laptop. was a result of what i think was a typo in a constant value
  used during the part of the interrupt handler that tells the keyboard
  controller the key event was processed
- fix uncommon potential crash function return in draw_filled_rect
- renamed low-level "direct" assembly functions to "lowlevel_xxx" to
  be a little bit more explicit about what they are
- add some convenience event helper functions for determining event
  types
- add fixed point atan2
- fixed some tabs/spaces inconsistences (should all be spaces now?)
- maybe some other minor things i've forgotten
2020-07-19 19:24:48 -04:00

67 lines
1.3 KiB
C
Executable file

#include "pal.h"
#include "dglgfx.h"
#include "dgldraw.h"
#include "dglpal.h"
#include <stdio.h>
#include "helpers.h"
// displays the entire palette in a grid, waits for a keypress, then changes
// color 15's RGB values.
void test_palette(void) {
int i, x, y;
uint8 r, g, b;
surface_clear(screen, 0);
i = 0;
for (y = 0; y < 16; ++y) {
for (x = 0; x < 16; ++x) {
draw_filled_rect(screen, x * 8, y * 8, x * 8 + 7, y * 8 + 7, i);
++i;
}
}
getch();
pal_get_color(15, &r, &g, &b);
ASSERT(r == 63 && g == 63 && b == 63);
pal_set_color(15, r / 2, g / 2, b / 2);
getch();
pal_set_color(15, r, g, b);
}
void test_palette_fading(void) {
int i, x, y;
uint8 palette[768];
surface_clear(screen, 0);
i = 0;
for (y = 0; y < 16; ++y) {
for (x = 0; x < 16; ++x) {
draw_filled_rect(screen, x * 8, y * 8, x * 8 + 7, y * 8 + 7, i);
++i;
}
}
pal_get(palette);
getch();
pal_fade_range_to_color(16, 31, 0, 0, 0, 1);
getch();
pal_fade_range_to_palette(16, 31, palette, 1);
getch();
pal_fade_to_color(0, 0, 0, 1);
getch();
pal_fade_to_palette(palette, 1);
getch();
}