loader.c (a3907569cb648b92b09b4854131a106aafecab36) loader.c (9890ff8357a674572254e0be06b175a1e8eab4b0)
1/*
2 * Copyright (c) 2000 Daniel Capo Sobral
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 29 unchanged lines hidden (view full) ---

38#include <fcntl.h>
39#include <stdio.h>
40#include <stdlib.h>
41#include <unistd.h>
42#include <strings.h>
43#include <termios.h>
44#else
45#include <stand.h>
1/*
2 * Copyright (c) 2000 Daniel Capo Sobral
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 29 unchanged lines hidden (view full) ---

38#include <fcntl.h>
39#include <stdio.h>
40#include <stdlib.h>
41#include <unistd.h>
42#include <strings.h>
43#include <termios.h>
44#else
45#include <stand.h>
46#include <gfx_fb.h>
46#include "bootstrap.h"
47#endif
48#ifdef _STANDALONE
49#include <uuid.h>
50#else
51#include <uuid/uuid.h>
52#endif
53#include <string.h>

--- 10 unchanged lines hidden (view full) ---

64 * copyout ( addr addr' len -- )
65 * findfile ( name len type len' -- addr )
66 * ccall ( [[...[p10] p9] ... p1] n addr -- result )
67 * uuid-from-string ( addr n -- addr' )
68 * uuid-to-string ( addr' -- addr n | -1 )
69 * .# ( value -- )
70 */
71
47#include "bootstrap.h"
48#endif
49#ifdef _STANDALONE
50#include <uuid.h>
51#else
52#include <uuid/uuid.h>
53#endif
54#include <string.h>

--- 10 unchanged lines hidden (view full) ---

65 * copyout ( addr addr' len -- )
66 * findfile ( name len type len' -- addr )
67 * ccall ( [[...[p10] p9] ... p1] n addr -- result )
68 * uuid-from-string ( addr n -- addr' )
69 * uuid-to-string ( addr' -- addr n | -1 )
70 * .# ( value -- )
71 */
72
73#ifdef _STANDALONE
72void
74void
75ficl_fb_putimage(ficlVm *pVM)
76{
77 char *namep, *name;
78 ficlUnsigned names;
79 ficlInteger ret = FICL_FALSE;
80 png_t png;
81
82 FICL_STACK_CHECK(ficlVmGetDataStack(pVM), 2, 1);
83
84 names = ficlStackPopUnsigned(ficlVmGetDataStack(pVM));
85 namep = (char *)ficlStackPopPointer(ficlVmGetDataStack(pVM));
86
87 name = ficlMalloc(names+1);
88 if (!name)
89 ficlVmThrowError(pVM, "Error: out of memory");
90 strncpy(name, namep, names);
91 name[names] = '\0';
92
93 if (png_open(&png, name) != PNG_NO_ERROR) {
94 ret = FICL_FALSE;
95 ficlFree(name);
96 ficlStackPushInteger(ficlVmGetDataStack(pVM), ret);
97 return;
98 }
99
100 if (gfx_fb_putimage(&png) == 0)
101 ret = FICL_TRUE; /* success */
102 png_close(&png);
103 ficlFree(name);
104 ficlStackPushInteger(ficlVmGetDataStack(pVM), ret);
105}
106
107void
108ficl_fb_setpixel(ficlVm *pVM)
109{
110 ficlUnsigned x, y;
111
112 FICL_STACK_CHECK(ficlVmGetDataStack(pVM), 2, 0);
113
114 y = ficlStackPopUnsigned(ficlVmGetDataStack(pVM));
115 x = ficlStackPopUnsigned(ficlVmGetDataStack(pVM));
116 gfx_fb_setpixel(x, y);
117}
118
119void
120ficl_fb_line(ficlVm *pVM)
121{
122 ficlUnsigned x0, y0, x1, y1, wd;
123
124 FICL_STACK_CHECK(ficlVmGetDataStack(pVM), 5, 0);
125
126 wd = ficlStackPopUnsigned(ficlVmGetDataStack(pVM));
127 y1 = ficlStackPopUnsigned(ficlVmGetDataStack(pVM));
128 x1 = ficlStackPopUnsigned(ficlVmGetDataStack(pVM));
129 y0 = ficlStackPopUnsigned(ficlVmGetDataStack(pVM));
130 x0 = ficlStackPopUnsigned(ficlVmGetDataStack(pVM));
131 gfx_fb_line(x0, y0, x1, y1, wd);
132}
133
134void
135ficl_fb_bezier(ficlVm *pVM)
136{
137 ficlUnsigned x0, y0, x1, y1, x2, y2, width;
138
139 FICL_STACK_CHECK(ficlVmGetDataStack(pVM), 7, 0);
140
141 width = ficlStackPopUnsigned(ficlVmGetDataStack(pVM));
142 y2 = ficlStackPopUnsigned(ficlVmGetDataStack(pVM));
143 x2 = ficlStackPopUnsigned(ficlVmGetDataStack(pVM));
144 y1 = ficlStackPopUnsigned(ficlVmGetDataStack(pVM));
145 x1 = ficlStackPopUnsigned(ficlVmGetDataStack(pVM));
146 y0 = ficlStackPopUnsigned(ficlVmGetDataStack(pVM));
147 x0 = ficlStackPopUnsigned(ficlVmGetDataStack(pVM));
148 gfx_fb_bezier(x0, y0, x1, y1, x2, y2, width);
149}
150
151void
152ficl_fb_drawrect(ficlVm *pVM)
153{
154 ficlUnsigned x1, x2, y1, y2, fill;
155
156 FICL_STACK_CHECK(ficlVmGetDataStack(pVM), 5, 0);
157
158 fill = ficlStackPopUnsigned(ficlVmGetDataStack(pVM));
159 y2 = ficlStackPopUnsigned(ficlVmGetDataStack(pVM));
160 x2 = ficlStackPopUnsigned(ficlVmGetDataStack(pVM));
161 y1 = ficlStackPopUnsigned(ficlVmGetDataStack(pVM));
162 x1 = ficlStackPopUnsigned(ficlVmGetDataStack(pVM));
163 gfx_fb_drawrect(x1, y1, x2, y2, fill);
164}
165
166void
167ficl_term_drawrect(ficlVm *pVM)
168{
169 ficlUnsigned x1, x2, y1, y2;
170
171 FICL_STACK_CHECK(ficlVmGetDataStack(pVM), 4, 0);
172
173 y2 = ficlStackPopUnsigned(ficlVmGetDataStack(pVM));
174 x2 = ficlStackPopUnsigned(ficlVmGetDataStack(pVM));
175 y1 = ficlStackPopUnsigned(ficlVmGetDataStack(pVM));
176 x1 = ficlStackPopUnsigned(ficlVmGetDataStack(pVM));
177 gfx_term_drawrect(x1, y1, x2, y2);
178}
179#endif /* _STANDALONE */
180
181void
73ficlSetenv(ficlVm *pVM)
74{
75 char *name, *value;
76 char *namep, *valuep;
77 int names, values;
78
79 FICL_STACK_CHECK(ficlVmGetDataStack(pVM), 4, 0);
80

--- 829 unchanged lines hidden (view full) ---

910 ficlDictionarySetPrimitive(dp, "findfile", ficlFindfile,
911 FICL_WORD_DEFAULT);
912 ficlDictionarySetPrimitive(dp, "ccall", ficlCcall, FICL_WORD_DEFAULT);
913 ficlDictionarySetPrimitive(dp, "uuid-from-string", ficlUuidFromString,
914 FICL_WORD_DEFAULT);
915 ficlDictionarySetPrimitive(dp, "uuid-to-string", ficlUuidToString,
916 FICL_WORD_DEFAULT);
917#ifdef _STANDALONE
182ficlSetenv(ficlVm *pVM)
183{
184 char *name, *value;
185 char *namep, *valuep;
186 int names, values;
187
188 FICL_STACK_CHECK(ficlVmGetDataStack(pVM), 4, 0);
189

--- 829 unchanged lines hidden (view full) ---

1019 ficlDictionarySetPrimitive(dp, "findfile", ficlFindfile,
1020 FICL_WORD_DEFAULT);
1021 ficlDictionarySetPrimitive(dp, "ccall", ficlCcall, FICL_WORD_DEFAULT);
1022 ficlDictionarySetPrimitive(dp, "uuid-from-string", ficlUuidFromString,
1023 FICL_WORD_DEFAULT);
1024 ficlDictionarySetPrimitive(dp, "uuid-to-string", ficlUuidToString,
1025 FICL_WORD_DEFAULT);
1026#ifdef _STANDALONE
1027 ficlDictionarySetPrimitive(dp, "fb-setpixel", ficl_fb_setpixel,
1028 FICL_WORD_DEFAULT);
1029 ficlDictionarySetPrimitive(dp, "fb-line", ficl_fb_line,
1030 FICL_WORD_DEFAULT);
1031 ficlDictionarySetPrimitive(dp, "fb-bezier", ficl_fb_bezier,
1032 FICL_WORD_DEFAULT);
1033 ficlDictionarySetPrimitive(dp, "fb-drawrect", ficl_fb_drawrect,
1034 FICL_WORD_DEFAULT);
1035 ficlDictionarySetPrimitive(dp, "fb-putimage", ficl_fb_putimage,
1036 FICL_WORD_DEFAULT);
1037 ficlDictionarySetPrimitive(dp, "term-drawrect", ficl_term_drawrect,
1038 FICL_WORD_DEFAULT);
918 /* Register words from linker set. */
919 SET_FOREACH(fnpp, Xficl_compile_set)
920 (*fnpp)(pSys);
921#endif
922
923#if defined(__i386__) || defined(__amd64__)
924 ficlDictionarySetConstant(env, "arch-i386", FICL_TRUE);
925 ficlDictionarySetConstant(env, "arch-sparc", FICL_FALSE);
926#endif
927#ifdef __sparc
928 ficlDictionarySetConstant(env, "arch-i386", FICL_FALSE);
929 ficlDictionarySetConstant(env, "arch-sparc", FICL_TRUE);
930#endif
931}
1039 /* Register words from linker set. */
1040 SET_FOREACH(fnpp, Xficl_compile_set)
1041 (*fnpp)(pSys);
1042#endif
1043
1044#if defined(__i386__) || defined(__amd64__)
1045 ficlDictionarySetConstant(env, "arch-i386", FICL_TRUE);
1046 ficlDictionarySetConstant(env, "arch-sparc", FICL_FALSE);
1047#endif
1048#ifdef __sparc
1049 ficlDictionarySetConstant(env, "arch-i386", FICL_FALSE);
1050 ficlDictionarySetConstant(env, "arch-sparc", FICL_TRUE);
1051#endif
1052}