
* AES Library Copyright (C) HiSoft 1988
* this MUST be assembled to either executable or GST linkable, NOT DRI code

* sets section order to TEXT,DATA,BSS

* 27.7.88	adjusted table and addr_in for TOS 1.4 calls
* 3.10.88	control made 5 words instead of 4!
* 1.5.90	adjusted table for form_button/form_keybd
* 29.3.93	Additions for Falcon TOS & MultiToS

* the actual calling of the AES

	MODULE	LowLevelAES

	XDEF	CALL_AES,control,global,int_in,int_out
	XDEF	addr_in,addr_out,aes_params

	SECTION	TEXT
* call an AES routine
* in:	d0.w=AES function number
* out	d0.w=int_out value
* uses	d0-d2/a0-a2
* (assumes control4 needs to be zero)
CALL_AES	lea	control,a1
	move.w	d0,(a1)+			store the op code
	sub.w	#10,d0
	mulu	#3,d0			size is the priority, not speed
	lea	gem_ctrl_list,a0
	add.w	d0,a0			points to the entry
	moveq	#0,d0
	move.b	(a0)+,d0
	move.w	d0,(a1)+		do control1
	move.b	(a0)+,d0
	move.w	d0,(a1)+		and control2
	move.b	(a0)+,d0
	move.w	d0,(a1)+		and control3
	clr.w	(a1)			assumes control4=0 (all except RSRC_GADDR)
	move.l	#aes_params,d1
	move.w	#200,d0			function number
	trap	#2
	move.w	int_out,d0		usually a returned value
	rts

	SECTION	DATA
* this is a table of pointers to all the AES arrays
aes_params	dc.l	control,global,int_in,int_out,addr_in,addr_out

* this is the list of Control parameters for the AES calls
* contains control(1..3), comment is the function number
* (an asterisk indicates it is not defined)
gem_ctrl_list
	dc.b	0,1,0	10
	dc.b	2,1,1	11
	dc.b	2,1,1	12
	dc.b	0,1,1	13
	dc.b	2,1,1	14
	dc.b	1,1,1	15
	dc.b	0,0,0	16*
	dc.b	0,0,0	17*
	dc.b	1,3,1	18
	dc.b	0,1,0	19
	dc.b	0,1,0	20
	dc.b	3,5,0	21
	dc.b	5,5,0	22
	dc.b	0,1,1	23
	dc.b	2,1,0	24
	dc.b	16,7,1	25
	dc.b	2,1,0	26
	dc.b	0,0,0	27*
	dc.b	0,0,0	28*
	dc.b	0,0,0	29*
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	dc.b	5,1,0	101
	dc.b	1,1,0	102
	dc.b	1,1,0	103
	dc.b	6,5,0	104
	dc.b	6,1,0	105
	dc.b	2,1,0	106
	dc.b	1,1,0	107
	dc.b	6,5,0	108
	dc.b	0,0,0	109
	dc.b	0,1,1	110
	dc.b	0,1,0	111
	dc.b	2,1,0	112 ** Control(4)=1 **
	dc.b	2,1,1	113
	dc.b	1,1,1	114
	dc.b	0,1,1	115
	dc.b	0,0,0	116
	dc.b	0,0,0	117
	dc.b	0,0,0	118
	dc.b	0,0,0	119
	dc.b	0,1,2	120
	dc.b	3,1,2	121
	dc.b	1,1,1	122
	dc.b	1,1,1	123
	dc.b	0,1,1	124
	dc.b	0,1,3	125
	dc.b	0,0,0	126*
	dc.b	0,0,0	127*
	dc.b	0,0,0	128*
	dc.b	0,0,0	129*
	dc.b	1,5,0	130
	even

	SECTION	BSS
* these don't need initialising so can go in the BSS section
control		ds.w	5
global		ds.w	14
int_in		ds.w	16
int_out		ds.w	7
addr_in		ds.l	3
addr_out	ds.l	1


*********** END OF AES *****************

