
;**** SpeedTest ***********************************************************
;*
;* Assembled by Olly Koenders with the excellent Maxon Assembler.
;*
;* This proggy tests the speed of your Amiga and will run on all models and
;* all Kickstart versions.  a small change will need to be made for NTSC
;* Amiga's that run on American standard 60 Hz.
;*
;* Tallies a value every .5 seconds.  (x& = x& + 1 --> loop for .5 seconds)
;*
;* 14 Mhz 68000 A500 with fast ram tallies approx 117860 - see what
;* your 68060 does and tell somebody!!!
;*
;* Pentium 133 tallies approx 70000 in DOS (Windows slows the system by
;* about 20-30%).  Note that DOS don't multitask either...
;*
;* If you don't have an assembler - or know little of programming in this
;* fast language, then get a hex-editor (like Zap) or something suitable
;* and change the 83rd byte in the file that should show "19" in hex, and
;* change it to "1E" if you run an NTSC (200 scanlines high) screen.
;*
;* If you want to force the progam to run in chip memory exclusively then
;* change the 20th byte from a "00" in hex to a "40".
;*
;* Remember - I'm counting starting from 0 - NOT 1...
;*
;* Our output looks (something) like this on the Workbench:
;*
;*	 ________
;*	|xxxxxxxx| "x" being the numbers in decimal
;*	 --------
;**************************************************************************

	section go ,code ,public	;public ram - will run in chip if
					;no fast is available -
					;but remember that it'll run at
					;only about HALF the speed if you
					;don't have any fast ram!


WBENCHSCREEN equ 1

openlib=-408
execbase=4
openwindow=-204		;some references here
closewindow=-72		;so we don't need a whole
printitext=-216		;pile of "includes"!!!
disable=-120
enable=-126

;	. . .			;no startup code for the workbench
;	. . .			;so MUST be run from CLI

	move.l execbase,a6
	lea intname(pc),a1
	jsr openlib(a6)		;open intuition.library for a window
	move.l d0,intbase	;store library base address
	move.l d0,a6
	lea windowdef(pc),a0	;get window parameters our data area
	jsr openwindow(a6)	;do the icky
	move.l d0,windowhd	;save it for later

more:
	move.l execbase,a6
	jsr disable(a6)		;disable the multitasking (only 6% faster)
	move.b $bfe801,d6	;get timer value and store
	add.b #25,d6		;add .5 secs (use 30 for NTSC!)
	moveq #0,d0		;clear our register for our tally value

timer:
	addq.l #1,d0		;add 1 to our tally every loop
	move.b $bfe801,d5	;get the timer value again
	cmp.b d6,d5		;check if our half sec is up
	bmi.b timer		;if not - then do this little loop again
	bsr.b convert		;if done, then convert our tally to text
	jsr enable(a6)		;might as well put the multitask back
	move.l intbase(pc),a6	;intuition library base in a6
	move.l windowhd(pc),a0	;our window pointer in a0 temporarily
	move.l 50(a0),a0	;rastport address in a0 (offset 50)
	lea mainmsg(pc),a1	;message address in a1
	moveq #0,d0		;just some offsets
	moveq #0,d1		;for the text
	jsr printitext(a6)	;print our value
	btst #6,$bfe001		;test for mouse click
	bne.b more		;if not - then continue
	move.l windowhd(pc),a0	;window pointer
	jsr closewindow(a6)	;close it
	moveq #0,d0
	rts			;quit this proggy

convert:			;our conversion routine from value to text
	lea table(pc),a0
	lea address(pc),a1	;address of the text area in a1

pad:
	move.l (a0)+,d1
	move.b #"0",(a1)+	;clear the area with "0" bytes ($30)
	cmp.l d1,d0
	bcs.B pad

nextdigit:
	move.b #10,d2

getdigit:
	subq.l #1,d2
	sub.l d1,d0
	bcc.B getdigit
	add.l d1,d0
	move.b #"9",d1
	sub.b d2,d1
	move.b d1,(a1)+
	move.l (a0)+,d1
	bne.B nextdigit
	add.b #$30,d0
	move.b d0,(a1)
	rts

intname:
	dc.b "intuition.library",0	;our wonderful library
	even

intbase:
	dc.l 0			;variable address for our library base

windowdef:			;the window definitions
	dc.w 276,120		;x,y
	dc.w 88,15		;width,height
	dc.b -1,-1		;standard colours
	dc.l 0			;no care about IDCMP flags
	dc.l 0			;don't need any attributes or system gadgets
	dc.l 0			;no custom gadgets
	dc.l 0			;no checkmark or pulldown menus
	dc.l 0			;no window title
	dc.l 0			;no custom screen - we'll use the Workbench
	dc.l 0			;no custom bitmap for GFX either
	dc.w 0,0,0,0		;minimum width/height - don't care
	dc.w WBENCHSCREEN	;on the workbench

windowhd:
	dc.l 0			;variable address for our window pointer

mainmsg:			;text structure
	dc.b 1,0
	dc.b 1,0
	even
	dc.w 8,4		;x,y location
	dc.l 0
	dc.l address		;the text data for this structure to use
	dc.l 0

address:
	dc.b "        ",0	;conversion routine writes text to here
	even

table:				;the table for our tally value
	dc.l 10000000
	dc.l 1000000
	dc.l 100000
	dc.l 10000
	dc.l 1000
	dc.l 100
	dc.l 10
	dc.l 0
	end
