Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Now both demos/triangle.4k and lib/shader.4k works

* bootstrap.4k: Remove RTLD_GLOBAL for lib word.
* lib/display.4k: Remove spurious LoadSymbols.
* lib/meta.4k: Fix problem with non terminated by zero token string.
* lib/shader.4k: Remove unnededed call for meta-symbols.
* lib/symbols.4k: Allow loading libc.so returning NULL.
* src/Makefile: Remove -lc from the built options.
  • Loading branch information...
commit 9446da291b290cc66e6d6fd9309a99548c7f955f 1 parent 49a870b
@danmey authored
View
2  bootstrap.4k
@@ -241,7 +241,7 @@ symbol: dlsym
| Convert string to zero terminated string
: >cstr drop ;
| Load library
-: lib >cstr $100 $2 or swap dlopen ;
+: lib >cstr $2 swap dlopen ;
| Load symbol
: sym >cstr swap dlsym ;
variable #ithere
View
2  lib/display.4k
@@ -49,6 +49,7 @@ Lib: libGL.so
1 Symbol: glMatrixMode
0 Symbol: glLoadIdentity
12 Symbol: glFrustum
+LoadSymbols
$00000100 constant GL_DEPTH_BUFFER_BIT
$00004000 constant GL_COLOR_BUFFER_BIT
@@ -59,7 +60,6 @@ $00000002 constant SDL_OPENGL
: display-ratio ( -- ratio )
finit display-height @ >f display-width @ >f f/ f>
;
-LoadSymbols
: init-display
SDL_OPENGL 0 display-height @ display-width @ SDL_SetVideoMode drop
View
26 lib/meta.4k
@@ -21,7 +21,7 @@
|
require" lib/stackx.4k"
-
+require" lib/symbols.4k"
create token-table 512 allot
variable ptr token-table ptr !
@@ -29,25 +29,24 @@ variable #tokens 0 #tokens !
| Bind some useful functions
-symbol: malloc
-symbol: puts
-: libc " /usr/lib/libc.so" lib ;
-: function >r sym r> cells add-handle ;
-: meta-symbols ( -- )
- libc " malloc" 1 function
- libc " puts" 1 function ;
-|
+Lib: libc.so
+1 Symbol: malloc
+1 Symbol: puts
+LoadSymbols
+
| Copy string to malloced block
+
+| : token token over over + 0 swap c! ;
: malloc-token ( cstr -- cstr )
dup count dup 1+ malloc swap
- 1- 0 do over over swap i + c@ swap i + c! loop swap drop dup dup count + 0 swap c! ;
+ 0 do over over swap i + c@ swap i + c! loop swap drop dup dup count + 0 swap c! ;
| Get token as Forth string
: tok ( token -- str n ) dup c@ swap 1+ swap ;
|
| DeclareX
: declarex ( -- )
- here @ >r ptr @ here ! token dup c, 1- 0
- do dup i + c@ c, loop 0 c,
+ here @ >r ptr @ here ! token dup c, 1-
+ 0 do dup i + c@ c, loop 0 c,
here @ r> here !
ptr @ tok 2dup (:) drop rliteral postpone malloc-token postpone >x postpone ; ptr ! 0 ptr @ c! #tokens 1+! ;
|
@@ -68,3 +67,6 @@ symbol: puts
| Concat words on the X-stack
: |> x> x> concat-malloc >x ;
+Ident ala
+: a ala ;
+a
View
2  lib/shader.4k
@@ -68,8 +68,6 @@ Ident zy Ident xyz Ident xzy Ident zxy Ident zyx
: main
0 #tokens !
token-table ptr !
- meta-symbols
-
v1 vec3 ,, v2 vec3 ,, shader 2 Function
gl_ModelViewMatrix gl_Vertex ~* gl_Position ~! ~;
End x> printc cr cr
View
10 lib/symbols.4k
@@ -58,9 +58,10 @@ begin
0 current-lib @ c@ 0 <>
found-symbol @ 0 = and
while
- current-lib @ dup count lib dup
- 0 <>
- if
+ current-lib @ dup count lib
+ | dup
+ | 0 <>
+| if
current-sym @ dup count sym dup
0 <>
if
@@ -71,7 +72,7 @@ begin
#ccall @ #ccall 1+! postpone ccall c, postpone ;
-1 found-symbol !
then
- then
+ | then
current-lib @ count 1+ current-lib +!
repeat
current-sym @ count 1+ current-sym +!
@@ -81,3 +82,4 @@ begin
current-sym @ c@ 0 = if ;; then
again
;
+
View
2  src/Makefile
@@ -66,7 +66,7 @@ $(BIN)/4k-debug: $(SRC_FILES)
m4 -DDEBUG $(CYWGIN) -s $(SRC) > $(BIN)/t.s
./m4patch.pl > $(BIN)/t.P
mv $(BIN)/t.P $(BIN)/t.S
- gcc -m32 -ggdb3 $(BIN)/t.S -o $(BIN)/4k-debug -ldl -lsigsegv -lGL -lc
+ gcc -m32 -ggdb3 $(BIN)/t.S -o $(BIN)/4k-debug -lGL -ldl -lsigsegv
cp $@ $(PREFIX)
Please sign in to comment.
Something went wrong with that request. Please try again.