	ttl 'Save blanker module'

 		incdir	"Includes:"
		include	"exec/funcdef.i"
		include "exec/memory.i"
		include	"dos/dosextens.i"
		include "dos/dos_lib.i"
		include	"exec/exec_lib.i"
		include "intuition/intuition.i"
		include "intuition/intuition_lib.i"
		include "graphics/displayinfo.i"
		include "graphics/gfx.i"
		include "graphics/graphics_lib.i"
		include "graphics/scale.i"
		include	"libraries/commodities.i"
		include "libraries/gadtools.i"
		include	"workbench/startup.i"
		include	"workbench/workbench.i"

		include "//MB_Develop/module.i"

		bra	DataSave

module_name	dc.b "//MB_Modules/Forces.blm",0

		cnop 0,4
blm_start	dcb.b	blm_SIZEOF,0

;all pointers are relatives to blm_start
settings	EQU	*-blm_start

		dc.l	CHECKBOX_KIND
maskcheck	;MASK
		dc.l	NULL
		dc.l	TRUE
		dc.l	NULL

		dc.l	LINK_KIND
		dc.l	CHECKBOX_KIND
dbufcheck	;DBLBUF
		dc.l	NULL
		dc.l	TRUE
		dc.l	NULL

		dc.l	CYCLE_KIND
modecycle	;MODE
		dc.l	NULL
		dc.l	0
		dc.l	5
		dc.l	NULL
		dc.l	NULL
		dc.l	NULL
		dc.l	NULL
		dc.l	NULL
		dc.l	NULL
		dc.l	NULL

		dc.l	LINK_KIND
		dc.l	CYCLE_KIND
mascycle	;MASSES
		dc.l	NULL
		dc.l	0
		dc.l	3
		dc.l	NULL
		dc.l	NULL
		dc.l	NULL
		dc.l	NULL
		dc.l	NULL

		dc.l	SLIDER_KIND
sdslider	;SCREENDEPTH
		dc.l	NULL
		dc.l	4
		dc.l	1
		dc.l	4
		dc.l	NULL

		dc.l	LINK_KIND
		dc.l	SLIDER_KIND
objslider	;OBJECTS
		dc.l	NULL
		dc.l	7
		dc.l	2
		dc.l	100
		dc.l	NULL

		dc.l	SLIDER_KIND
mfslider	;M_FORCE
		dc.l	NULL
		dc.l	300
		dc.l	50
		dc.l	2000
		dc.l	NULL

		dc.l	LINK_KIND
		dc.l	SLIDER_KIND
gfslider	;G_FORCE
		dc.l	NULL
		dc.l	200
		dc.l	50
		dc.l	2000
		dc.l	NULL

		dc.l	CYCLE_KIND
mdircycle	;M_DIRECTION
		dc.l	NULL
		dc.l	0
		dc.l	3
		dc.l	NULL
		dc.l	NULL
		dc.l	NULL
		dc.l	NULL
		dc.l	NULL

		dc.l	LINK_KIND
		dc.l	CYCLE_KIND
gscycle		;G_SOURCE
		dc.l	NULL
		dc.l	0
		dc.l	4
		dc.l	NULL
		dc.l	NULL
		dc.l	NULL
		dc.l	NULL
		dc.l	NULL
		dc.l	NULL

		dc.l	SLIDER_KIND
mrslider	;M_RADIUS
		dc.l	NULL
		dc.l	800
		dc.l	2
		dc.l	2000
		dc.l	NULL

		dc.l	LINK_KIND
		dc.l	SLIDER_KIND
nsslider	;NOVA_SPEED
		dc.l	NULL
		dc.l	10
		dc.l	1
		dc.l	30
		dc.l	NULL
				
		dc.l	SLIDER_KIND
afslider	;AIR_FRICTION
		dc.l	NULL
		dc.l	5
		dc.l	1
		dc.l	1000
		dc.l	NULL

		dc.l	LINK_KIND
		dc.l	SLIDER_KIND
wfslider	;WALL_FRICTION
		dc.l	NULL
		dc.l	150
		dc.l	1
		dc.l	1000
		dc.l	NULL

;other structures follow first, then string-data
		dc.l	-1	;end of settings flag

maskttname	EQU	*-blm_start
		dc.b	'MASK',0,0,0,0,0,0
maskgtext	EQU	*-blm_start
		dc.b	'Use RenderMask',NULL
dbufttname	EQU	*-blm_start
		dc.b	'DBLBUF',0,0,0,0,0,0
dbufgtext	EQU	*-blm_start
		dc.b	'DblBuf. Screen',NULL

modettname	EQU	*-blm_start
		dc.b	'MODE',0,0,0,0,0,0,0,0,0,0,0,0,0
modegtext	EQU	*-blm_start
		dc.b	'Play Mode',NULL
modeitem1	EQU	*-blm_start
		dc.b	'AUTO',NULL
modeitem2	EQU	*-blm_start
		dc.b	'MAGNETIC',NULL
modeitem3	EQU	*-blm_start
		dc.b	'GRAVITY',NULL
modeitem4	EQU	*-blm_start
		dc.b	'MAGRAV',NULL
modeitem5	EQU	*-blm_start
		dc.b	'PLAIN',NULL

masttname	EQU	*-blm_start
		dc.b	'MASSES',0,0,0,0,0,0,0,0,0,0,0
masgtext	EQU	*-blm_start
		dc.b	'Obj. Masses',NULL
masitem1	EQU	*-blm_start
		dc.b	'RANDOM',NULL
masitem2	EQU	*-blm_start
		dc.b	'ORDER',NULL
masitem3	EQU	*-blm_start
		dc.b	'EQUAL',NULL

gsttname	EQU	*-blm_start
		dc.b	'G_SOURCE',0,0,0,0,0,0,0,0,0,0
gsgtext		EQU	*-blm_start
		dc.b	'Grav. Src.',NULL
gsitem1		EQU	*-blm_start
		dc.b	'BOTTOM',NULL
gsitem2		EQU	*-blm_start
		dc.b	'TOP',NULL
gsitem3		EQU	*-blm_start
		dc.b	'LEFT',NULL
gsitem4		EQU	*-blm_start
		dc.b	'RIGHT',NULL

mdirttname	EQU	*-blm_start
		dc.b	'M_DIRECTION',0,0,0,0,0,0,0,0
mdirgtext	EQU	*-blm_start
		dc.b	'MForce Dir.',NULL
mdiritem1	EQU	*-blm_start
		dc.b	'PULL',NULL
mdiritem2	EQU	*-blm_start
		dc.b	'PUSH',NULL
mdiritem3	EQU	*-blm_start
		dc.b	'MIX',NULL

sdttname	EQU	*-blm_start
		dc.b	'SCREENDEPTH',NULL,0,0,0,0
sdgtext		EQU	*-blm_start
		dc.b	'ScreenDepth (1-4)',NULL
objttname	EQU	*-blm_start
		dc.b	'OBJECTS',NULL,0,0,0,0,0,0,0,0,0,0
objgtext	EQU	*-blm_start
		dc.b	'Objects (2-100)',NULL
mrttname	EQU	*-blm_start
		dc.b	'M_RADIUS',NULL,0,0,0,0,0,0,0,0,0,0
mrgtext		EQU	*-blm_start
		dc.b	'MRadius (1-2000)',NULL
gfttname	EQU	*-blm_start
		dc.b	'G_FORCE',NULL,0,0,0,0,0,0,0,0,0,0
gfgtext		EQU	*-blm_start
		dc.b	'GForce (50-2000)',NULL
mfttname	EQU	*-blm_start
		dc.b	'M_FORCE',NULL,0,0,0,0,0,0,0,0,0,0
mfgtext		EQU	*-blm_start
		dc.b	'MForce (50-2000)',NULL

nsttname	EQU	*-blm_start
		dc.b	'NOVA_SPEED',NULL,0,0,0,0,0
nsgtext		EQU	*-blm_start
		dc.b	'ExplodeSpeed (1-30)',NULL
afttname	EQU	*-blm_start
		dc.b	'AIR_FRICTION',NULL,0,0,0,0,0,0,0,0
afgtext		EQU	*-blm_start
		dc.b	'AirFric. (5-1000)',NULL
wfttname	EQU	*-blm_start
		dc.b	'WALL_FRICTION',NULL,0,0,0,0,0,0,0,0
wfgtext		EQU	*-blm_start
		dc.b	'WallFric. (5-1000)',NULL

   dc.b '$VER:MBlank Forces 0.00 (??-??-1997) damian@cybercomm.nl',NULL

;insert your taglist or whatever here
		cnop	0,4
codeentry	EQU	*-blm_start

; Insert position-independant code here:
; 	a5	=	APTR AllGlobals (may be trashed)
;--------------------------------------------------------------------------

;Code for external module for Blanker of type 'BLMS'

		include "Equ+Macro.forces"
		include "Main.forces"
		cnop	0,4
		include	"Calculations.forces"
		include "Magnetics.forces"
		cnop	0,4
		include "Data.forces"
		cnop	0,4
		include "TTparsing.forces"
		cnop	0,4
		include	"DownScale.forces"
				
;--------------------------------------------------------------------------
; Here it should be finished
		cnop 0,4
modulesize	EQU	*-blm_start


; Data_saver: saves code+hunks to binary file
; code starts at buffer
;
DataSave	lea	blm_start(pc),a0
		move.l	#'BLMS',blm_ID(a0)
		move.l	#modulesize,blm_Length(a0)
		move.l	#codeentry,blm_Code(a0)
		move.l	#settings,blm_Settings(a0)

		lea	maskcheck(pc),a0
		move.l	#maskttname,check_TTName(a0)
		move.l	#maskgtext,check_GText(a0)

		lea	dbufcheck(pc),a0
		move.l	#dbufttname,check_TTName(a0)
		move.l	#dbufgtext,check_GText(a0)

		lea	modecycle(pc),a0
		move.l	#modettname,cycle_TTName(a0)
		move.l	#modegtext,cycle_GText(a0)
		move.l	#modeitem1,cycle_Items(a0)
		move.l	#modeitem2,cycle_Items+4(a0)
		move.l	#modeitem3,cycle_Items+8(a0)
		move.l	#modeitem4,cycle_Items+12(a0)
		move.l	#modeitem5,cycle_Items+16(a0)

		lea	mascycle(pc),a0
		move.l	#masttname,cycle_TTName(a0)
		move.l	#masgtext,cycle_GText(a0)
		move.l	#masitem1,cycle_Items(a0)
		move.l	#masitem2,cycle_Items+4(a0)
		move.l	#masitem3,cycle_Items+8(a0)

		lea	mdircycle(pc),a0
		move.l	#mdirttname,cycle_TTName(a0)
		move.l	#mdirgtext,cycle_GText(a0)
		move.l	#mdiritem1,cycle_Items(a0)
		move.l	#mdiritem2,cycle_Items+4(a0)
		move.l	#mdiritem3,cycle_Items+8(a0)

		lea	gscycle(pc),a0
		move.l	#gsttname,cycle_TTName(a0)
		move.l	#gsgtext,cycle_GText(a0)
		move.l	#gsitem1,cycle_Items(a0)
		move.l	#gsitem2,cycle_Items+4(a0)
		move.l	#gsitem3,cycle_Items+8(a0)
		move.l	#gsitem4,cycle_Items+12(a0)

		lea	sdslider(pc),a0
		move.l	#sdttname,slide_TTName(a0)
		move.l	#sdgtext,slide_GText(a0)

		lea	objslider(pc),a0
		move.l	#objttname,slide_TTName(a0)
		move.l	#objgtext,slide_GText(a0)

		lea	mrslider(pc),a0
		move.l	#mrttname,slide_TTName(a0)
		move.l	#mrgtext,slide_GText(a0)

		lea	gfslider(pc),a0
		move.l	#gfttname,slide_TTName(a0)
		move.l	#gfgtext,slide_GText(a0)

		lea	mfslider(pc),a0
		move.l	#mfttname,slide_TTName(a0)
		move.l	#mfgtext,slide_GText(a0)

		lea	nsslider(pc),a0
		move.l	#nsttname,slide_TTName(a0)
		move.l	#nsgtext,slide_GText(a0)

		lea	afslider(pc),a0
		move.l	#afttname,slide_TTName(a0)
		move.l	#afgtext,slide_GText(a0)

		lea	wfslider(pc),a0
		move.l	#wfttname,slide_TTName(a0)
		move.l	#wfgtext,slide_GText(a0)
				
Openl		move.l	#4,a6			;Open dos.library
		move.l	(a6),a6
		move.l	#$0,d0			;Version irrelevant
		lea	libname,a1
		jsr	-552(a6)
		move.l	d0,a5
		beq	exit			;If enable to open, exit
usel		move.l	a5,a6
		lea	module_name,a0
		move.l	a0,d1			;Point at name
		move.l	#1006,d2		;Open new file-modus
		jsr	-30(a6)			;Open functie in Dos.lib
		move.l	d0,a4			;store handle(ID) for later use
		beq	Closel			;Unable to open file
		move.l	a4,d1			;file-ID
		lea	blm_start,a0
		move.l	a0,d2			;Data to write to file
		move.l	#modulesize,d3		;aantal bytes
		jsr 	-48(a6)			;Write functie in Dos.lib
closef		move.l	a4,d1			;Close file, IMPORTANT!!!
		jsr	-36(a6)
		
Closel  	move.l	#4,a6
		move.l	(a6),a6		
		move.l	a5,a1			;Close Library
		jsr	-414(a6)
exit		rts	

libname		dc.b "dos.library",0
