Skip to content

Commit 8db7390

Browse files
committed
Fix last cursor line not drawn, make mouse acceleration optional
1 parent 9231d7e commit 8db7390

File tree

3 files changed

+16
-8
lines changed

3 files changed

+16
-8
lines changed

elkscmd/gui/cursor.c

+10-5
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
#include "mouse.h"
1919
#include "vgalib.h"
2020

21-
#define USE_XOR_CURSOR 1 /* =1 use XOR drawing for slow systems*/
22-
#define USE_VGA_DRAWCURSOR defined(__ia16__)
21+
#define USE_XOR_CURSOR 1 /* =1 use XOR drawpixel vs full cursor & mask draw */
22+
#define USE_VGA_DRAWCURSOR (__ia16__ || __WATCOMC__) /* VGA hardware XOR cursor */
2323

2424
#define MWMAX_CURSOR_SIZE 16 /* maximum cursor x and y size*/
2525
#define MWMAX_CURSOR_BUFLEN MWIMAGE_SIZE(MWMAX_CURSOR_SIZE,MWMAX_CURSOR_SIZE)
@@ -150,6 +150,10 @@ static MWIMAGEBITS lgcursormask[16] = {
150150
MASK(_,_,_,_,_,_,_,_,_,_,_,_,X,X,X,_), // 000E
151151
MASK(_,_,_,_,_,_,_,_,_,_,_,_,_,X,_,_) // 0004
152152
};
153+
154+
struct cursor cursor_lg = {
155+
16, 16, 0, 0, WHITE, BLACK, lgcursorbits, lgcursormask
156+
};
153157
#else
154158
static MWIMAGEBITS lgcursorbits[16] = {
155159
// 8 4 2 1 8 4 2 1 8 4 2 1 8 4 2 1
@@ -189,10 +193,11 @@ static MWIMAGEBITS lgcursormask[16] = {
189193
MASK(X,X,_,_,X,X,X,X,_,_,_,_,_,_,_,_),
190194
MASK(X,_,_,_,_,X,X,X,_,_,_,_,_,_,_,_)
191195
};
192-
#endif
196+
193197
struct cursor cursor_lg = {
194198
11, 16, 0, 0, WHITE, BLACK, lgcursorbits, lgcursormask
195199
};
200+
#endif
196201

197202
void initcursor(void)
198203
{
@@ -288,7 +293,7 @@ int showcursor(void)
288293
* Loop through bits, resetting to firstbit at end of each row
289294
*/
290295
#if USE_VGA_DRAWCURSOR
291-
vga_drawcursor(curminx, curminy, curmaxy - curminy, cursormask);
296+
vga_drawcursor(curminx, curminy, curmaxy - curminy + 1, cursormask);
292297
#elif USE_XOR_CURSOR
293298
set_op(0x18);
294299
for (y = curminy; y <= curmaxy; y++) {
@@ -365,7 +370,7 @@ int hidecursor(void)
365370
return prevcursor;
366371

367372
#if USE_VGA_DRAWCURSOR
368-
vga_drawcursor(cursavx, cursavy, cursavy2 - cursavy, cursormask);
373+
vga_drawcursor(cursavx, cursavy, cursavy2 - cursavy + 1, cursormask);
369374
#elif USE_XOR_CURSOR
370375
set_op(0x18);
371376
for (y = cursavy; y <= cursavy2; y++) {

elkscmd/gui/graphics.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -105,14 +105,14 @@ void drawvline(int x, int y1, int y2, int c)
105105
#endif /* __WATCOMC__ */
106106

107107
#if defined(__WATCOMC__) || defined(__ia16__)
108-
/* draw 8 bits horizontally using XOR amd one or two memory writes */
108+
/* draw 8 bits horizontally using XOR and one or two memory writes w/clipping */
109109
static void drawbits(int x, int y, unsigned char bits)
110110
{
111111
set_op(0x18);
112112
set_color(15);
113113
unsigned int dst = (y<<6) + (y<<4) + (x>>3); /* y * 80 + x / 8 */
114114
if (x < SCREENWIDTH) {
115-
set_mask(bits >> ((x & 7)));
115+
set_mask(bits >> (x & 7));
116116
asm_orbyte(dst);
117117
}
118118
if (x < SCREENWIDTH-8) {

elkscmd/gui/mouse.c

+4-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#define MOUSE_PC 0 /* pc/logitech mouse*/
2525
#define MOUSE_PS2 0 /* PS/2 mouse */
2626

27+
#define USE_MOUSE_ACCEL 0 /* =1 to use mouse acceleration */
2728
#define SCALE 2 /* default scaling factor for acceleration */
2829
#define THRESH 5 /* default threshhold for acceleration */
2930

@@ -168,6 +169,7 @@ void close_mouse(void)
168169
mouse_fd = -1;
169170
}
170171

172+
#if USE_MOUSE_ACCEL
171173
static void
172174
filter_relative(int *xpos, int *ypos, int x, int y)
173175
{
@@ -196,6 +198,7 @@ filter_relative(int *xpos, int *ypos, int x, int y)
196198
*xpos = x;
197199
*ypos = y;
198200
}
201+
#endif
199202

200203
#if MOUSE_PS2
201204
/* IntelliMouse PS/2 protocol uses four byte reports
@@ -290,7 +293,7 @@ int read_mouse(int *dx, int *dy, int *dz, int *bptr)
290293
*/
291294
while (nbytes-- > 0) {
292295
if ((*parse)((int) *bp++)) {
293-
#if MOUSE_MICROSOFT
296+
#if USE_MOUSE_ACCEL && MOUSE_MICROSOFT
294297
filter_relative(&xd, &yd, xd, yd);
295298
#endif
296299
*dx = xd;

0 commit comments

Comments
 (0)