1
0
mirror of https://github.com/Interlisp/maiko.git synced 2026-03-01 09:30:56 +00:00
Commit Graph

524 Commits

Author SHA1 Message Date
Nick Briggs
ffd86beb52 Cleanup, strip some debug/performance code in display update, minor formatting 2021-11-23 17:45:01 -08:00
Nick Briggs
31a244c0e6 Implement bitblt to texture at bit level rather than word level, some cleanup
sdl_bitblt_to_texture2 is an experiment, parallel to sdl_bitblt_to_texture
that only moves as many bits as are required, rather than rounding down(up) to the
nearest (16-bit) word boundary for the start(end) of the line.

Introduces some name changes to make things a little clearer.
2021-11-20 18:26:50 -08:00
Nick Briggs
2eae377e5f Take pixelscale into account when repositioning cursor 2021-11-17 12:27:13 -08:00
Nick Briggs
c32233b824 Speedups in texture based display path
Instead of checking "do_invert" at each pixel assignment, assign the
foreground and background colors appropriately when responding to the
(VIDEOCOLOR x) call.

Modify sdl_bitblt_to_texture() so that it does less arithmetic in the inner loop,
including using a table of masks rather than computing 1<<n on each pixel.
Modify sdl_bitblt_to_texture() so that it accesses the Lisp display region
16-bits at a time with the correct ordering for whether we are on a byte-swapped
system or not.
2021-11-15 18:38:16 -08:00
Nick Briggs
fabfca2486 When updating the window surface directly, at scale 1, avoid the intermediate buffer
Adds an sdl_blt_to_window_surface() that goes directly from the Lisp bitmap
to the window surface avoiding the intermediate copy.  This is only coded for a
scale factor of 1.  Uses the intermediate buffer if the scale is not 1.

Corrects an error where the damage rectangle was not properly reset.
2021-11-09 20:15:00 -08:00
Nick Briggs
e430513d6a Avoid intermediate buffer and bitblt Lisp screen changes directly into the texture pixels
Using SDL_LockTexture/SDL_UnlockTexture we can gain more direct access to the pixels of the
texture and update them directly from the Lisp screen bitmap.

At the same time, for both the rendering case and the display surface case,
update the pixel format used to be either the first (presumably preferred?)
format for a texture, or the surface format of the window.

Use the SDL routines to pick out the pixel value for Black and White based on the
destination it will be placed in.
2021-11-09 13:57:25 -08:00
Nick Briggs
184f02d0c1 Introduce alternative method for updating window from Lisp bitmap
If the preprocessor symbol SDLRENDERING is defined the code operates as
it previously did.  In the absence of that, we process the Lisp bitmap
into an intermediate form (as before) but then use SDL bitblt to
redraw the intermediate form on the window's surface.
2021-11-08 22:18:08 -08:00
Nick Briggs
0606015793 Move display update into separate procedure 2021-11-08 22:02:43 -08:00
Nick Briggs
d64e1d1b38 Width, but not height, must be multiple of 32 2021-11-08 21:28:06 -08:00
Nick Briggs
f59e4395b8 Bounds check indexing into intermediate screen buffer
When building with -DCMAKE_BUILD_TYPE=Debug, we assert() that the
index into the intermediate screen buffer is in bounds.
2021-11-08 20:40:30 -08:00
Nick Briggs
f7588b8c8e Keep damage notification boundaries within the current screen
On startup, bitblt calls may be made for the original screen size
and if the new screen size is smaller than that, we must ensure
that damage notifications are contained within the new screen.

Move definition of min() so we can use it in sdl_notify_damage()
2021-11-08 18:21:38 -08:00
Peter
241e5fe9a9 Cache cursors for SDL. 2021-11-08 21:10:23 +01:00
Peter
f9d1e51456 Change Pixelformat to 332 (one byte) instead of 8888 (four bytes). 2021-11-08 20:03:28 +01:00
Nick Briggs
ba6e365cc8 Fix "error: implicit declaration of function" from dspsubrs
Creates an sdldefs.h, declares a few more functions in sdl.c static,
and includes sdldefs.h in dspsubrs.c when necessary.
2021-11-07 11:26:46 -08:00
Peter
37aed57027 Add support for setting the mouse cursor. Not finished!
Currently this just allocates a new X cursor each time, should be
amended to cache the cursor, just like X does at the moment.
2021-11-07 19:37:33 +01:00
Peter
ecfd4048e0 Add support for inverting video and setting mouse position.
Use (IL:VIDEOCOLOR T/NIL) to change inversion.
2021-11-07 19:37:33 +01:00
Peter
a3fdf18edc Add mouse wheel diagnostics. 2021-11-07 19:37:33 +01:00
Peter
8a872d7d85 Only update texture on damage. 2021-11-07 19:37:33 +01:00
Peter
5413934525 Add support for key repeating. 2021-11-07 19:37:33 +01:00
Peter
784d9f61cb For now, some more extern functions declarations. 2021-11-07 19:37:33 +01:00
Peter
00c4d65aff Maybe fix cmake for SDL2. 2021-11-07 19:37:33 +01:00
Peter
bab9213120 Remove SDL2 directory from include SDL2/SDL.h. 2021-11-07 19:37:33 +01:00
Peter
e9968a211b Try to placate the macos build. 2021-11-07 19:37:33 +01:00
Peter
ccfacb23a7 Try to make builds pass again. 2021-11-07 19:37:33 +01:00
Peter
ab94538d0c Add support for -t / -title. 2021-11-07 19:37:33 +01:00
Peter
8f7067943f Try to get CI running again ;) 2021-11-07 19:37:33 +01:00
Peter
2092a74869 Add command line parameters -sc WxH and -pixelscale n for SDL. 2021-11-07 19:37:33 +01:00
Peter
4821dac4c0 Add more #ifdef XWINDOW 2021-11-07 19:37:33 +01:00
Peter
28931acd36 Remove extra directory from includes for SDL. 2021-11-07 19:37:33 +01:00
Peter
7b7db9aac5 Refactor, only bitblt once per "frame". 2021-11-07 19:37:33 +01:00
Peter
333c132e40 Refactor, don't update texture on every bitblt. 2021-11-07 19:37:33 +01:00
Peter
87ede7cee1 Only bitblt on damage.
Also add an alternative for key handling, which does not work any better...
2021-11-07 19:37:33 +01:00
Peter
78e42b7217 Change SDL backend to accelerated renderer, support pixel scaling.
Edit main.c, init_SDL(1600, 1024, 1) means lisp display size 1600x1024, pixel scaling 1.

Try init_SDL(800, 512, 2) or even init_SDL(608, 1023, 3).
2021-11-07 19:37:33 +01:00
Peter
f73b4d1ff5 Merge remote-tracking branch 'upstream/master' 2021-11-07 19:37:24 +01:00
Nick Briggs
de5ea2110f Correct integer type warnings (#405)
* Correct warning: cast to smaller integer type -- X_init/lispbitmap

* Fixes to INTRSAFE, INTRSAFE0 and ensure TIMEOUT, TIMEOUT0 used appropriately

INTRSAFE and INTRSAFE0 must clear errno before executing the library or system
call because not all library calls set errno on success.
Avoid casting pointers or larger integer values down to smaller ints before
comparing to 0 or -1, and use NULL (a pointer) rather than 0.

Fix cases where the result of the library call is a pointer rather than an int
to use TIMEOUT0 instead of TIMEOUT, testing for NULL rather than -1
on timeout (errno == EINTR)

* Remove useless validity check of LASTVMEMFILEPAGE_word pointer

* Convert pointer arithmetic type in drawline from int to ptrdiff_t

* Add NOTE warning about a 32-bit vs 64-bit issue affecting currently unused GET_NATIVE_ADDR_FROM_LISP_PTR
2021-11-04 09:08:55 -07:00
Nick Briggs
6c241f1eaa Make opcode_table (names of opcodes) visible as useful debug aid. 2021-10-29 10:02:47 -07:00
Nick Briggs
19688bc314 Drop setuid privilege correctly. (#401) 2021-10-29 09:52:51 -07:00
Nick Briggs
c39b751f42 Rework make_atom() to allow removal of parse_number() (#404)
No calls to make_atom() depend on the ability to parse the atom's
pname as a number.  Additionally, the parse_number() implementation
used here was non-functional.

We remove parse_number() and adjust the parameter list of make_atom()
to remove the non_numericp flag.
2021-10-29 09:51:32 -07:00
Peter
f58abe36ee Add prototypical SDL support.
Build with cmake. This will create a new backend (ldesdl).
- Resolution can only be set by editing the variables in sdl.c.
- Key repeat does not work.
- Still problems with keysyms that implicitly contain modifiers.
- The entire screen is bitblted onto the SDL display every frame.

Support keyboard, and work on mouse.

Kind of working...

Fix display resolution problems.
2021-10-20 10:12:04 +02:00
Nick Briggs
75c668f1cd The pointers Atomspace, Spospspace, Snegspace, Arrayspace can be removed (#402)
These pointers are neither initialized nor referenced anywhere in the code.
2021-10-10 16:55:33 -07:00
Nick Briggs
a25368714f Use SHELL rather than /bin/csh when forking shells. Issue Interlisp/medley#384 (#400)
As long as $(SHELL) names an executable that appears in /etc/shells (as determined
by the getusershell() function) use that.  It used to always use /bin/csh, but some
modern distros do not ship with csh installed.  Using the user's preferred shell
seems like a better choice, while allowing the choice from /etc/shells gives some
additional flexibility.
2021-10-08 17:58:29 -07:00
Nick Briggs
3cdbccd0c7 Implement -noscroll option to ldex to disable X window scroll bars (#399)
Adds a -noscroll option, parsed as an X option, also accessible via
resource ldex*noscroll, which avoids adding the bottom and side scroll
bars and the bit-gravity control buttons to the main Lisp display window.

Unless the geometry given for the X window in which the Lisp screen is
displayed is at least as big as the Lisp screen part of the Lisp screen
(bottom, right) will not be visible.

On macOS with XQuartz, maximizing the X window will bring it to
the size of the Lisp screen (or the size of the display, whichever is smaller)
2021-09-30 10:44:37 -07:00
Nick Briggs
f7e40d1ed5 Use symbolic constants for COLOR related subrs rather than numbers
cases for subrs UNCOLORIZE-BITMAP, COLORIZE-BITMAP, COLOR-8BPPDRAWLINE (which
are not compiled into current code) can have the numbers replaced by the
symbolic constants that are now defined in subrs.h
2021-09-19 14:19:42 -07:00
Nick Briggs
9bb5a4298c Use symbolic constant for subr CAUSE-INTERRUPT switch/case rather than number (0222) 2021-09-19 14:12:47 -07:00
Nick Briggs
533c935e72 Fix various bugprone warnings (#397)
* Fix some warnings in main.c

main.c:678: narrowing conversion from 'unsigned long' to signed type 'int' is implementation-defined
main.c:493: The return value from the call to 'seteuid' is not checked.

* Fix some warnings in array operations

Instead of extracting typenumbers to an 'int', use the unsigned typenumber directly

array3.c:49: narrowing conversion from 'unsigned int' to signed type 'int' is implementation-defined
array4.c:61: narrowing conversion from 'unsigned int' to signed type 'int' is implementation-defined
array5.c:63: narrowing conversion from 'unsigned int' to signed type 'int' is implementation-defined
array6.c:50: narrowing conversion from 'unsigned int' to signed type 'int' is implementation-defined

* Resolve type mismatches for version numbers and propp flag

dir.c:1849: narrowing conversion from 'unsigned int' to signed type 'int'
dir.c:1850: narrowing conversion from 'unsigned int' to signed type 'int'
dir.c:2114: narrowing conversion from 'unsigned long' to signed type 'int'
dir.c:2207: narrowing conversion from 'unsigned int' to signed type 'int'

* Resolve type mismatches for version numbers and strlen result type

dsk.c:1072: narrowing conversion from 'unsigned long' to signed type 'int'
dsk.c:1108: narrowing conversion from 'unsigned long' to signed type 'int'
dsk.c:1549: narrowing conversion from 'unsigned long' to signed type 'int'
dsk.c:1712: narrowing conversion from 'unsigned long' to signed type 'int'
dsk.c:1751: narrowing conversion from 'unsigned long' to signed type 'int'
dsk.c:3426: narrowing conversion from 'unsigned int' to signed type 'int'

* Resolve type mismatches for strlen result type

ufs.c:213: narrowing conversion from 'unsigned long' to signed type 'int'
ufs.c:404: narrowing conversion from 'unsigned long' to signed type 'int'

* Resolve type error

uutils.c:117: 'signed char' to 'int' conversion [bugprone-signed-char-misuse,cert-str34-c]
2021-09-16 17:24:25 -07:00
Nick Briggs
6fedd97d21 add yield subr (#398)
* Add experimental SUBR to call nanosleep() for experiments in reducing CPU load

This adds a SUBR, sb_YIELD, value (octal) 0322 which takes a single number
0..999999999 which is the number of nanoseconds to pass to nanosleep().

The return value is T if the call to nanosleep() was executed or NIL
if it was not (argument out-of-range, or other error in getting the
number from the argument).

To use this experimental SUBR in a sysout you should:

   (SETQ \INITSUBRS (CONS '(YIELD #o322) \INITSUBRS))

then you can define functions that use that SUBR:

   (DEFINEQ (BACKGROUND-YIELD () (SUBRCALL YIELD 833333)))
   (COMPILE 'BACKGROUND-YIELD)
   (SETQ BACKGROUNDFNS (CONS 'BACKGROUND-YIELD BACKGROUNDFNS))

* Update to use subrs.h newly generated from LLSUBRS

The subrs.h include file is generated by WRITECALLSUBRS based on the \INITSUBRS
list.  This update provides for the new YIELD subr in the generated file,
and makes some necessary updates to the C code implementations for some subr
names which have changed.
2021-09-15 10:30:04 -07:00
Nick Briggs
a70b18d444 Avoid use of sscanf() for parsing simple integer values (#396)
There is no reason to use sscanf() rather than strtol()/strtoul()
for parsing simple integer values from a string.
Resolves a number of cert-str34-c warnings from clang-tidy.
2021-09-12 14:24:05 -07:00
Nick Briggs
b1545e4ccc fix 'signed char' to 'int' conversion [cert-str34-c]
Fortunately here we don't need to convert to unsigned char then int,
we can do the only comparisons we need staying in the char domain.
2021-09-09 18:01:02 -07:00
Nick Briggs
4f79f55c20 Replace uses of atoi() with strtol() or stroul() as appropriate (#394)
As a side-effect of this change, we also resolve a a problem with
signed file version numbers, so that instead of version 2147483647
wrapping to -2147483648 we can go as far as 4294967296 before we
have issues.  Various sprintf() formats get changed from %d to %u.
The DOS version code is left behind as int versions.
2021-09-08 09:58:01 -07:00
Nick Briggs
0de1b1438b Left shift is undefined if left argument is negative (#454) (#393) 2021-09-03 12:46:21 -07:00