; -----------------------------------------------------------------------------
;    ~     RetroForth on Linux
;   . .    http://www.retroforth.tk
;   /V\    
;  // \\   Release 6.20 (Final) for NASM
; /(   )\  libSDL Graphics
;  ^'~'^
; -----------------------------------------------------------------------------
; This is primarily a wrapper for the other files. It loads the
; macros, sets up memory + stacks, and initializes the Forth
; system. It includes the following files automatically:
;  * macros
;  * forth.asm + forth-ic.asm + forth.f
;  * drivers.asm + drivers.f
;  * user.asm + user.f
; If you're porting RF, you should only need to edit the startup
; code and drivers. The rest should work "out of the box".
; -----------------------------------------------------------------------------
%include "macros"

section .text
	global main
main:
	mov eax, 07dh              ;sys mprotect (pinched from IsForth :-)
	mov ebx, 08048000h
	mov ecx, 00100000h
	mov edx, 7
	int 080h                   ;make the entire program space rwx	

	; The stack is bigger than in the svgalib version, because
	; SDL needs it. It could probably be a _lot_ smaller than
	; 0x2000 though...
        mov esi, sp0
	
	call sdl_init
 	mov eax,[screen]
	mov eax,[eax+PIXELS_OFS]
 	mov [frame],eax

MAIN:   upsh startup            ;Load startup code (startup.f)
        upsh startup.1 - startup
        call eval
        call user_init
	call interpret
;---------------------------------------------------------------------
%include "../forth-ic.asm"
%include "drivers.asm"
%include "user.asm"
%include "../forth.asm"
;---------------------------------------------------------------------
section .data
startup: incbin "../forth.f"
         incbin "drivers.f"
         incbin "user.f"
         db 'red color ! .( Retro)'
         db 'blue color ! .( Forth)'
         db 'black color ! "  6.20" type cr'
.1
END
