Fixed palette index issue with wxor.c

This commit is contained in:
Adam Greenwood-Byrne 2021-04-17 21:18:30 +01:00
parent 32f99ca5d9
commit e7af63ed34
5 changed files with 273 additions and 273 deletions

View file

@ -1,7 +1,7 @@
#include "mb.h" #include "mb.h"
#define NULL 0 #define NULL 0
#define rgb(r,g,b) (r<<16)|(g<<8)|b #define rgb(i,r,g,b) (i<<24)|(r<<16)|(g<<8)|b
typedef struct { typedef struct {
short xres; short xres;

View file

@ -63,10 +63,10 @@ void wgt36()
do { /* Draws a filled xorbox using mouse coordinates as one corner. */ do { /* Draws a filled xorbox using mouse coordinates as one corner. */
ox = mx; ox = mx;
oy = my; oy = my;
wxorbox (50, 50, ox, oy, vgapal[128]); /* Draw the box */ wxorbox (50, 50, ox, oy, 128); /* Draw the box */
while ((mx == ox) && (my == oy) && (!but)); /* Do nothing while mouse is while ((mx == ox) && (my == oy) && (!but)); /* Do nothing while mouse is
stationary. */ stationary. */
wxorbox (50, 50, ox, oy, vgapal[128]); wxorbox (50, 50, ox, oy, 128);
/* Erase the box by drawing the same thing */ /* Erase the box by drawing the same thing */
} while (but == 0); } while (but == 0);
@ -75,16 +75,16 @@ void wgt36()
do { /* Draws a hollow rubber box using mouse coordinates as one corner. */ do { /* Draws a hollow rubber box using mouse coordinates as one corner. */
ox = mx; ox = mx;
oy = my; oy = my;
wxorbox (50, 50, ox, 50, vgapal[128]); wxorbox (50, 50, ox, 50, 128);
wxorbox (ox, 50, ox, oy, vgapal[128]); /* Draw the box */ wxorbox (ox, 50, ox, oy, 128); /* Draw the box */
wxorbox (50, oy, ox, oy, vgapal[128]); wxorbox (50, oy, ox, oy, 128);
wxorbox (50, 50, 50, oy, vgapal[128]); wxorbox (50, 50, 50, oy, 128);
while ((mx == ox) && (my == oy) && (!but)); /* Do nothing while mouse is while ((mx == ox) && (my == oy) && (!but)); /* Do nothing while mouse is
stationary. */ stationary. */
wxorbox (50, 50, ox, 50, vgapal[128]); wxorbox (50, 50, ox, 50, 128);
wxorbox (ox, 50, ox, oy, vgapal[128]); /* Erase the box */ wxorbox (ox, 50, ox, oy, 128); /* Erase the box */
wxorbox (50, oy, ox, oy, vgapal[128]); wxorbox (50, oy, ox, oy, 128);
wxorbox (50, 50, 50, oy, vgapal[128]); wxorbox (50, 50, 50, oy, 128);
} while (but == 0); } while (but == 0);
mdeinit (); /* Deinitialize the mouse handler */ mdeinit (); /* Deinitialize the mouse handler */
} }

View file

@ -21,260 +21,260 @@ void wloadpalette (unsigned char *data, color *pal)
/* VGA 256 colour default palette */ /* VGA 256 colour default palette */
unsigned int vgapal[256] = { unsigned int vgapal[256] = {
rgb( 0, 0, 0), rgb(0, 0, 0, 0),
rgb( 0, 0,170), rgb(1, 0, 0,170),
rgb( 0,170, 0), rgb(2, 0,170, 0),
rgb( 0,170,170), rgb(3, 0,170,170),
rgb(170, 0, 0), rgb(4, 170, 0, 0),
rgb(170, 0,170), rgb(5, 170, 0,170),
rgb(170, 85, 0), rgb(6, 170, 85, 0),
rgb(170,170,170), rgb(7, 170,170,170),
rgb( 85, 85, 85), rgb(8, 85, 85, 85),
rgb( 85, 85,255), rgb(9, 85, 85,255),
rgb( 85,255, 85), rgb(10, 85,255, 85),
rgb( 85,255,255), rgb(11, 85,255,255),
rgb(255, 85, 85), rgb(12, 255, 85, 85),
rgb(255, 85,255), rgb(13, 255, 85,255),
rgb(255,255, 85), rgb(14, 255,255, 85),
rgb(255,255,255), rgb(15, 255,255,255),
rgb( 0, 0, 0), rgb(16, 0, 0, 0),
rgb( 20, 20, 20), rgb(17, 20, 20, 20),
rgb( 32, 32, 32), rgb(18, 32, 32, 32),
rgb( 44, 44, 44), rgb(19, 44, 44, 44),
rgb( 56, 56, 56), rgb(20, 56, 56, 56),
rgb( 68, 68, 68), rgb(21, 68, 68, 68),
rgb( 80, 80, 80), rgb(22, 80, 80, 80),
rgb( 97, 97, 97), rgb(23, 97, 97, 97),
rgb(113,113,113), rgb(24, 113,113,113),
rgb(129,129,129), rgb(25, 129,129,129),
rgb(145,145,145), rgb(26, 145,145,145),
rgb(161,161,161), rgb(27, 161,161,161),
rgb(182,182,182), rgb(28, 182,182,182),
rgb(202,202,202), rgb(29, 202,202,202),
rgb(226,226,226), rgb(30, 226,226,226),
rgb(255,255,255), rgb(31, 255,255,255),
rgb( 0, 0,255), rgb(32, 0, 0,255),
rgb( 64, 0,255), rgb(33, 64, 0,255),
rgb(125, 0,255), rgb(34, 125, 0,255),
rgb(190, 0,255), rgb(35, 190, 0,255),
rgb(255, 0,255), rgb(36, 255, 0,255),
rgb(255, 0,190), rgb(37, 255, 0,190),
rgb(255, 0,125), rgb(38, 255, 0,125),
rgb(255, 0, 64), rgb(39, 255, 0, 64),
rgb(255, 0, 0), rgb(40, 255, 0, 0),
rgb(255, 64, 0), rgb(41, 255, 64, 0),
rgb(255,125, 0), rgb(42, 255,125, 0),
rgb(255,190, 0), rgb(43, 255,190, 0),
rgb(255,255, 0), rgb(44, 255,255, 0),
rgb(190,255, 0), rgb(45, 190,255, 0),
rgb(125,255, 0), rgb(46, 125,255, 0),
rgb( 64,255, 0), rgb(47, 64,255, 0),
rgb( 0,255, 0), rgb(48, 0,255, 0),
rgb( 0,255, 64), rgb(49, 0,255, 64),
rgb( 0,255,125), rgb(50, 0,255,125),
rgb( 0,255,190), rgb(51, 0,255,190),
rgb( 0,255,255), rgb(52, 0,255,255),
rgb( 0,190,255), rgb(53, 0,190,255),
rgb( 0,125,255), rgb(54, 0,125,255),
rgb( 0, 64,255), rgb(55, 0, 64,255),
rgb(125,125,255), rgb(56, 125,125,255),
rgb(157,125,255), rgb(57, 157,125,255),
rgb(190,125,255), rgb(58, 190,125,255),
rgb(222,125,255), rgb(59, 222,125,255),
rgb(255,125,255), rgb(60, 255,125,255),
rgb(255,125,222), rgb(61, 255,125,222),
rgb(255,125,190), rgb(62, 255,125,190),
rgb(255,125,157), rgb(63, 255,125,157),
rgb(255,125,125), rgb(64, 255,125,125),
rgb(255,157,125), rgb(65, 255,157,125),
rgb(255,190,125), rgb(66, 255,190,125),
rgb(255,222,125), rgb(67, 255,222,125),
rgb(255,255,125), rgb(68, 255,255,125),
rgb(222,255,125), rgb(69, 222,255,125),
rgb(190,255,125), rgb(70, 190,255,125),
rgb(157,255,125), rgb(71, 157,255,125),
rgb(125,255,125), rgb(72, 125,255,125),
rgb(125,255,157), rgb(73, 125,255,157),
rgb(125,255,190), rgb(74, 125,255,190),
rgb(125,255,222), rgb(75, 125,255,222),
rgb(125,255,255), rgb(76, 125,255,255),
rgb(125,222,255), rgb(77, 125,222,255),
rgb(125,190,255), rgb(78, 125,190,255),
rgb(125,157,255), rgb(79, 125,157,255),
rgb(182,182,255), rgb(80, 182,182,255),
rgb(198,182,255), rgb(81, 198,182,255),
rgb(218,182,255), rgb(82, 218,182,255),
rgb(234,182,255), rgb(83, 234,182,255),
rgb(255,182,255), rgb(84, 255,182,255),
rgb(255,182,234), rgb(85, 255,182,234),
rgb(255,182,218), rgb(86, 255,182,218),
rgb(255,182,198), rgb(87, 255,182,198),
rgb(255,182,182), rgb(88, 255,182,182),
rgb(255,198,182), rgb(89, 255,198,182),
rgb(255,218,182), rgb(90, 255,218,182),
rgb(255,234,182), rgb(91, 255,234,182),
rgb(255,255,182), rgb(92, 255,255,182),
rgb(234,255,182), rgb(93, 234,255,182),
rgb(218,255,182), rgb(94, 218,255,182),
rgb(198,255,182), rgb(95, 198,255,182),
rgb(182,255,182), rgb(96, 182,255,182),
rgb(182,255,198), rgb(97, 182,255,198),
rgb(182,255,218), rgb(98, 182,255,218),
rgb(182,255,234), rgb(99, 182,255,234),
rgb(182,255,255), rgb(100, 182,255,255),
rgb(182,234,255), rgb(101, 182,234,255),
rgb(182,218,255), rgb(102, 182,218,255),
rgb(182,198,255), rgb(103, 182,198,255),
rgb( 0, 0,113), rgb(104, 0, 0,113),
rgb( 28, 0,113), rgb(105, 28, 0,113),
rgb( 56, 0,113), rgb(106, 56, 0,113),
rgb( 85, 0,113), rgb(107, 85, 0,113),
rgb(113, 0,113), rgb(108, 113, 0,113),
rgb(113, 0, 85), rgb(109, 113, 0, 85),
rgb(113, 0, 56), rgb(110, 113, 0, 56),
rgb(113, 0, 28), rgb(111, 113, 0, 28),
rgb(113, 0, 0), rgb(112, 113, 0, 0),
rgb(113, 28, 0), rgb(113, 113, 28, 0),
rgb(113, 56, 0), rgb(114, 113, 56, 0),
rgb(113, 85, 0), rgb(115, 113, 85, 0),
rgb(113,113, 0), rgb(116, 113,113, 0),
rgb( 85,113, 0), rgb(117, 85,113, 0),
rgb( 56,113, 0), rgb(118, 56,113, 0),
rgb( 28,113, 0), rgb(119, 28,113, 0),
rgb( 0,113, 0), rgb(120, 0,113, 0),
rgb( 0,113, 28), rgb(121, 0,113, 28),
rgb( 0,113, 56), rgb(122, 0,113, 56),
rgb( 0,113, 85), rgb(123, 0,113, 85),
rgb( 0,113,113), rgb(124, 0,113,113),
rgb( 0, 85,113), rgb(125, 0, 85,113),
rgb( 0, 56,113), rgb(126, 0, 56,113),
rgb( 0, 28,113), rgb(127, 0, 28,113),
rgb( 56, 56,113), rgb(128, 56, 56,113),
rgb( 68, 56,113), rgb(129, 68, 56,113),
rgb( 85, 56,113), rgb(130, 85, 56,113),
rgb( 97, 56,113), rgb(131, 97, 56,113),
rgb(113, 56,113), rgb(132, 113, 56,113),
rgb(113, 56, 97), rgb(133, 113, 56, 97),
rgb(113, 56, 85), rgb(134, 113, 56, 85),
rgb(113, 56, 68), rgb(135, 113, 56, 68),
rgb(113, 56, 56), rgb(136, 113, 56, 56),
rgb(113, 68, 56), rgb(137, 113, 68, 56),
rgb(113, 85, 56), rgb(138, 113, 85, 56),
rgb(113, 97, 56), rgb(139, 113, 97, 56),
rgb(113,113, 56), rgb(140, 113,113, 56),
rgb( 97,113, 56), rgb(141, 97,113, 56),
rgb( 85,113, 56), rgb(142, 85,113, 56),
rgb( 68,113, 56), rgb(143, 68,113, 56),
rgb( 56,113, 56), rgb(144, 56,113, 56),
rgb( 56,113, 68), rgb(145, 56,113, 68),
rgb( 56,113, 85), rgb(146, 56,113, 85),
rgb( 56,113, 97), rgb(147, 56,113, 97),
rgb( 56,113,113), rgb(148, 56,113,113),
rgb( 56, 97,113), rgb(149, 56, 97,113),
rgb( 56, 85,113), rgb(150, 56, 85,113),
rgb( 56, 68,113), rgb(151, 56, 68,113),
rgb( 80, 80,113), rgb(152, 80, 80,113),
rgb( 89, 80,113), rgb(153, 89, 80,113),
rgb( 97, 80,113), rgb(154, 97, 80,113),
rgb(105, 80,113), rgb(155, 105, 80,113),
rgb(113, 80,113), rgb(156, 113, 80,113),
rgb(113, 80,105), rgb(157, 113, 80,105),
rgb(113, 80, 97), rgb(158, 113, 80, 97),
rgb(113, 80, 89), rgb(159, 113, 80, 89),
rgb(113, 80, 80), rgb(160, 113, 80, 80),
rgb(113, 89, 80), rgb(161, 113, 89, 80),
rgb(113, 97, 80), rgb(162, 113, 97, 80),
rgb(113,105, 80), rgb(163, 113,105, 80),
rgb(113,113, 80), rgb(164, 113,113, 80),
rgb(105,113, 80), rgb(165, 105,113, 80),
rgb( 97,113, 80), rgb(166, 97,113, 80),
rgb( 89,113, 80), rgb(167, 89,113, 80),
rgb( 80,113, 80), rgb(168, 80,113, 80),
rgb( 80,113, 89), rgb(169, 80,113, 89),
rgb( 80,113, 97), rgb(170, 80,113, 97),
rgb( 80,113,105), rgb(171, 80,113,105),
rgb( 80,113,113), rgb(172, 80,113,113),
rgb( 80,105,113), rgb(173, 80,105,113),
rgb( 80, 97,113), rgb(174, 80, 97,113),
rgb( 80, 89,113), rgb(175, 80, 89,113),
rgb( 0, 0, 64), rgb(176, 0, 0, 64),
rgb( 16, 0, 64), rgb(177, 16, 0, 64),
rgb( 32, 0, 64), rgb(178, 32, 0, 64),
rgb( 48, 0, 64), rgb(179, 48, 0, 64),
rgb( 64, 0, 64), rgb(180, 64, 0, 64),
rgb( 64, 0, 48), rgb(181, 64, 0, 48),
rgb( 64, 0, 32), rgb(182, 64, 0, 32),
rgb( 64, 0, 16), rgb(183, 64, 0, 16),
rgb( 64, 0, 0), rgb(184, 64, 0, 0),
rgb( 64, 16, 0), rgb(185, 64, 16, 0),
rgb( 64, 32, 0), rgb(186, 64, 32, 0),
rgb( 64, 48, 0), rgb(187, 64, 48, 0),
rgb( 64, 64, 0), rgb(188, 64, 64, 0),
rgb( 48, 64, 0), rgb(189, 48, 64, 0),
rgb( 32, 64, 0), rgb(190, 32, 64, 0),
rgb( 16, 64, 0), rgb(191, 16, 64, 0),
rgb( 0, 64, 0), rgb(192, 0, 64, 0),
rgb( 0, 64, 16), rgb(193, 0, 64, 16),
rgb( 0, 64, 32), rgb(194, 0, 64, 32),
rgb( 0, 64, 48), rgb(195, 0, 64, 48),
rgb( 0, 64, 64), rgb(196, 0, 64, 64),
rgb( 0, 48, 64), rgb(197, 0, 48, 64),
rgb( 0, 32, 64), rgb(198, 0, 32, 64),
rgb( 0, 16, 64), rgb(199, 0, 16, 64),
rgb( 32, 32, 64), rgb(200, 32, 32, 64),
rgb( 40, 32, 64), rgb(201, 40, 32, 64),
rgb( 48, 32, 64), rgb(202, 48, 32, 64),
rgb( 56, 32, 64), rgb(203, 56, 32, 64),
rgb( 64, 32, 64), rgb(204, 64, 32, 64),
rgb( 64, 32, 56), rgb(205, 64, 32, 56),
rgb( 64, 32, 48), rgb(206, 64, 32, 48),
rgb( 64, 32, 40), rgb(207, 64, 32, 40),
rgb( 64, 32, 32), rgb(208, 64, 32, 32),
rgb( 64, 40, 32), rgb(209, 64, 40, 32),
rgb( 64, 48, 32), rgb(210, 64, 48, 32),
rgb( 64, 56, 32), rgb(211, 64, 56, 32),
rgb( 64, 64, 32), rgb(212, 64, 64, 32),
rgb( 56, 64, 32), rgb(213, 56, 64, 32),
rgb( 48, 64, 32), rgb(214, 48, 64, 32),
rgb( 40, 64, 32), rgb(215, 40, 64, 32),
rgb( 32, 64, 32), rgb(216, 32, 64, 32),
rgb( 32, 64, 40), rgb(217, 32, 64, 40),
rgb( 32, 64, 48), rgb(218, 32, 64, 48),
rgb( 32, 64, 56), rgb(219, 32, 64, 56),
rgb( 32, 64, 64), rgb(220, 32, 64, 64),
rgb( 32, 56, 64), rgb(221, 32, 56, 64),
rgb( 32, 48, 64), rgb(222, 32, 48, 64),
rgb( 32, 40, 64), rgb(223, 32, 40, 64),
rgb( 44, 44, 64), rgb(224, 44, 44, 64),
rgb( 48, 44, 64), rgb(225, 48, 44, 64),
rgb( 52, 44, 64), rgb(226, 52, 44, 64),
rgb( 60, 44, 64), rgb(227, 60, 44, 64),
rgb( 64, 44, 64), rgb(228, 64, 44, 64),
rgb( 64, 44, 60), rgb(229, 64, 44, 60),
rgb( 64, 44, 52), rgb(230, 64, 44, 52),
rgb( 64, 44, 48), rgb(231, 64, 44, 48),
rgb( 64, 44, 44), rgb(232, 64, 44, 44),
rgb( 64, 48, 44), rgb(233, 64, 48, 44),
rgb( 64, 52, 44), rgb(234, 64, 52, 44),
rgb( 64, 60, 44), rgb(235, 64, 60, 44),
rgb( 64, 64, 44), rgb(236, 64, 64, 44),
rgb( 60, 64, 44), rgb(237, 60, 64, 44),
rgb( 52, 64, 44), rgb(238, 52, 64, 44),
rgb( 48, 64, 44), rgb(239, 48, 64, 44),
rgb( 44, 64, 44), rgb(240, 44, 64, 44),
rgb( 44, 64, 48), rgb(241, 44, 64, 48),
rgb( 44, 64, 52), rgb(242, 44, 64, 52),
rgb( 44, 64, 60), rgb(243, 44, 64, 60),
rgb( 44, 64, 64), rgb(244, 44, 64, 64),
rgb( 44, 60, 64), rgb(245, 44, 60, 64),
rgb( 44, 52, 64), rgb(246, 44, 52, 64),
rgb( 44, 48, 64), rgb(247, 44, 48, 64),
rgb( 0, 0, 0), rgb(248, 0, 0, 0),
rgb( 0, 0, 0), rgb(249, 0, 0, 0),
rgb( 0, 0, 0), rgb(250, 0, 0, 0),
rgb( 0, 0, 0), rgb(251, 0, 0, 0),
rgb( 0, 0, 0), rgb(252, 0, 0, 0),
rgb( 0, 0, 0), rgb(253, 0, 0, 0),
rgb( 0, 0, 0), rgb(254, 0, 0, 0),
rgb( 0, 0, 0) rgb(255, 0, 0, 0)
}; };

View file

@ -21,7 +21,7 @@ void wsetpalette (unsigned char start, unsigned char finish, color *pal)
{ {
for (int i = start; i <= finish; i++) for (int i = start; i <= finish; i++)
{ {
vgapal[i] = (i << 24) + rgb(pal[i].r, pal[i].g, pal[i].b); vgapal[i] = rgb(i, pal[i].r, pal[i].g, pal[i].b);
} }
} }

View file

@ -34,7 +34,7 @@ void wxorbox (short x, short y, short x2, short y2, unsigned char col)
{ {
/* This can be change to perform any logical operation /* This can be change to perform any logical operation
on the pixels, such as & or | */ on the pixels, such as & or | */
*temp = *temp ^ col; /* XOR the pixel on screen with col and put it back on screen */ *temp = vgapal[(*temp >> 24) ^ col]; /* XOR the pixel on screen with col and put it back on screen */
temp++; /* Go to next pixel */ temp++; /* Go to next pixel */
} /* x loop */ } /* x loop */
temp += (WGT_SYS.xres - 1) - (x2 - x); /* Advance to next row */ temp += (WGT_SYS.xres - 1) - (x2 - x); /* Advance to next row */