Fixing xlib test.

This commit is contained in:
Brad Nelson
2021-01-05 22:30:11 -08:00
parent da8b3f59b6
commit c5af341f88
4 changed files with 25 additions and 19 deletions

View File

@ -19,17 +19,19 @@ typedef uint64_t udcell_t;
#define COMMA(n) *g_sys.heap++ = (n) #define COMMA(n) *g_sys.heap++ = (n)
#define IMMEDIATE() g_sys.last[-1] |= 1 #define IMMEDIATE() g_sys.last[-1] |= 1
#define DOES(ip) *g_sys.last = (cell_t) && OP_DODOES; g_sys.last[1] = (cell_t) ip #define DOES(ip) *g_sys.last = (cell_t) && OP_DODOES; g_sys.last[1] = (cell_t) ip
#define UMSMOD ud = *(udcell_t *) &sp[-1]; \
--sp; *sp = (cell_t) (ud % tos); \
tos = (cell_t) (ud / tos)
#define SSMOD d = (dcell_t) *sp * (dcell_t) sp[-1]; \
--sp; *sp = (cell_t) (((udcell_t) d) % tos); \
tos = (cell_t) (d < 0 ? ~(~d / tos) : d / tos)
#define OPCODE_LIST \ #define OPCODE_LIST \
X("0=", OP_ZEQUAL, tos = !tos ? -1 : 0) \ X("0=", OP_ZEQUAL, tos = !tos ? -1 : 0) \
X("0<", OP_ZLESS, tos = tos < 0 ? -1 : 0) \ X("0<", OP_ZLESS, tos = tos < 0 ? -1 : 0) \
X("+", OP_PLUS, tos = (tos + *sp) | 0; --sp) \ X("+", OP_PLUS, tos = (tos + *sp) | 0; --sp) \
X("UM/MOD", OP_UMSMOD, ud = *(udcell_t *) &sp[-1]; \ X("UM/MOD", OP_UMSMOD, UMSMOD) \
--sp; *sp = (cell_t) (ud % tos); \ X("*/MOD", OP_SSMOD, SSMOD) \
tos = (cell_t) (ud / tos)) \
X("*/MOD", OP_SSMOD, d = (dcell_t) *sp * (dcell_t) sp[-1]; \
--sp; *sp = (cell_t) (((udcell_t) d) % tos); \
tos = (cell_t) (d < 0 ? ~(~d / tos) : d / tos)) \
X("AND", OP_AND, tos = tos & *sp; --sp) \ X("AND", OP_AND, tos = tos & *sp; --sp) \
X("OR", OP_OR, tos = tos | *sp; --sp) \ X("OR", OP_OR, tos = tos | *sp; --sp) \
X("XOR", OP_XOR, tos = tos ^ *sp; --sp) \ X("XOR", OP_XOR, tos = tos ^ *sp; --sp) \

View File

@ -22,16 +22,19 @@ variable width
variable height variable height
create event xevent-size allot create event xevent-size allot
: draw
width @ . height @ .
display gc black XSetForeground drop
display gc black XSetBackground drop
display window gc 0 0 width @ height @ XFillRectangle drop
display gc white XSetForeground drop
display gc white XSetBackground drop
display window gc 0 0 width @ 2/ height @ 2/ XFillRectangle drop
;
: de event xevent-size : de event xevent-size
event c@ . event c@ .
event c@ Expose = if = event c@ Expose = if
width @ . height @ . draw
display gc black XSetForeground drop
display gc black XSetBackground drop
display window gc 0 0 width @ height @ XFillRectangle drop
display gc white XSetForeground drop
display gc white XSetBackground drop
display window gc 0 0 width @ 2/ height @ 2/ XFillRectangle drop
." Expose" ." Expose"
then then
event c@ ButtonPress = if ." ButtonPress" then event c@ ButtonPress = if ." ButtonPress" then
@ -43,10 +46,10 @@ create event xevent-size allot
event c@ ConfigureNotify = if event c@ ConfigureNotify = if
event 3 16 * 8 + + l@ width ! event 3 16 * 8 + + l@ width !
event 3 16 * 12 + + l@ height ! event 3 16 * 12 + + l@ height !
width @ . height @ . ." width & height: " width @ . height @ .
." ConfigureNotify" ." ConfigureNotify"
then then
event c@ MapNotify = if ." MapNotify" then event c@ MapNotify = if ." MapNotify" then
cr ; cr ;
: 1e display event XNextEvent drop de ; : 1e display event XNextEvent drop de ;
: gg begin 1e again ; : gg begin draw 1e again ;

View File

@ -41,6 +41,7 @@ cases = ReplaceAll(cases, 'g_sys.DOEXIT_XT', 'i32[(i32[g_sys>>2] + (11 * 4))>>2]
cases = ReplaceAll(cases, '&g_sys', 'g_sys'); cases = ReplaceAll(cases, '&g_sys', 'g_sys');
cases = ReplaceAll(cases, '&& OP_DOCOLON', '0'); cases = ReplaceAll(cases, '&& OP_DOCOLON', '0');
cases = ReplaceAll(cases, '&& OP_DOCREATE', '1'); cases = ReplaceAll(cases, '&& OP_DOCREATE', '1');
cases = ReplaceAll(cases, 'goto **(void **) w', 'break decode');
code = code.replace('{{boot}}', function() { return boot; }); code = code.replace('{{boot}}', function() { return boot; });
code = code.replace('{{dict}}', function() { return dict; }); code = code.replace('{{dict}}', function() { return dict; });

View File

@ -67,10 +67,10 @@ function Interpreter(stdlib, foreign, heap) {
tos = i32[sp>>2]|0; sp = (sp - 4)|0; tos = i32[sp>>2]|0; sp = (sp - 4)|0;
for (;;) { for (;;) {
w = i32[ip>>2]|0; w = i32[ip>>2]|0;
for (;;) { decode: for (;;) {
ir = i32[((ip + (w<<2))|0)>>2]|0; ir = u8[w]|0;
ip = (ip + 4)|0; ip = (ip + 4)|0;
switch (ir & 0xff) { switch (ir) {
case 0: // OP_DOCOLON case 0: // OP_DOCOLON
rp = (rp + 4) | 0; i32[rp] = ip; ip = (w + 4) | 0; rp = (rp + 4) | 0; i32[rp] = ip; ip = (w + 4) | 0;
break; break;