
;*---------------------------------------------------------------------
;* $VER: example.a 1.0 (16.6.98)
;*
;* Assembler example for Spirit1.5+
;*---------------------------------------------------------------------

		MC68020
		INCLUDE	"misc/spirit.i"

KEY_LENGTH	EQU	512

;*---------------------------------------------------------------------
;* KeyModule Tags
;*---------------------------------------------------------------------

		KEYHEAD	KeyModTags

		dc.b	"$VER: Example_keymodule 1.0 (16.6.98)",13,10,0
		cnop	0,2

KeyModTags	dc.l	SPT_Name,Name
		dc.l	SPT_Version,Version
		dc.l	SPT_Cracker,Cracker
		dc.l	SPT_Group,Group
		dc.l	SPT_Date,Date
		dc.l	SPT_KeyLength,KEY_LENGTH
		dc.l	SPT_KeyName,KeyName
		dc.l	SPT_KeyPath,KeyPath
		dc.l	SPT_Encrypt,MakeKey
		dc.l	SPT_TempBuff,3000
		dc.l	SPT_Flags,FLGF_CHECKEMPTY!FLGF_HEXSER!FLGF_RNDFILL!FLGF_DYNAMIC
		dc.l	SPT_Anno,Anno
		dc.l	SPT_NameLen,20
		dc.l	SPT_SerialLen,8
		dc.l	SPT_StreetLen,10
		dc.l	SPT_CityLen,30
		dc.l	SPT_CountryLen,3
		dc.l	SPT_ComputerLen,50
		dc.l	SPT_eMailLen,50
		dc.l	SPT_PhoneLen,20
		dc.l	SPT_EncryptLen,CodeLength
		dc.l	SPT_SpiritVer,SPIRITVERSION
		dc.l	SPT_CPU,CPU_68020
		dc.l	TAG_DONE

;*---------------------------------------------------------------------
;* Encrypt Routine
;*---------------------------------------------------------------------

MakeKey		bra.s	Main

Name		dc.b	"!Example",0			;yep. the crypter
Version		dc.b	"1.0",0				;crypts this strings
Cracker		dc.b	"Sunbeam",0			;too ;)
Group		dc.b	"DC",0
Date		dc.b	"16.6.98",0
KeyName		dc.b	"Example.key",0
KeyPath		dc.b	"T:",0
Anno		dc.b	"Example SPT_Anno",10
		dc.b	"Cool eh? :-)",0
		cnop	0,2

Main		move.l	kb_TempBuffer(a5),a1
		lea	TempStr(pc),a0
Copy1		move.b	(a0)+,(a1)+
		bne.s	Copy1

		move.l	kb_KeyBuffer(a5),a1
		move.l	kb_Name(a5),a0
Copy2		move.b	(a0)+,(a1)+
		bne.s	Copy2

		lea	TempName(pc),a0
		move.l	a0,d1
		move.l	#TempStrLen-1,d2
		move.l	kb_TempBuffer(a5),d3
		move.l	kb_SaveFile(a5),a0
		jsr	(a0)
		tst.l	d0				;bool
		bne.s	SaveError
		mulu.l	d0,d0				;we need 020+ of coz ;)
		;divu.l	d0,d0				;crash? hmm why? :^)
		;clc					;set CPU_6510 :)
		move.l	#KEY_LENGTH,d1
		moveq	#RETURN_NOERR,d0
SaveError	rts

TempName	dc.b	"T:kb_TempBuffer",0
TempStr		dc.b	"I don't really need this buffer :-)",0
TempStrLen	EQU	*-TempStr

		cnop	0,4				;lets make it longalign
CodeLength	EQU	*-MakeKey
		END