Word of the month: "Cheese" (it was going to be onomatopoeia for various reasons, but cheese is much easier to type).
Mystery of the month: Why did Rob just give me a jar of Irish coffee? (Albeit very nice Irish coffee, thank you).

Well, it's been a while, but I'm back to annoy you some more. I know I promised some people a while ago that I'd upload some MOD's for my next Stuchat, but I didn't think it'd be this long before I got round to it. Sheesh.

Anyway, this time I have two things for you.

First, "timing on the Mac"; this is fun and easy. Secondly, I have another top MOD list for you to "Cheese out" to. Why another? Well the last one I did was of older, classic mods. This time it's up to date and covers mainly s3m's, XM's and IT's. Not much use if you don't have a Quadra or PowerMac, but that's the way the world is.

Before we dive in, why not go have a look at the "user wants" page? If you have anything to add, why not send it right in? We'll post it up for all the world to see.

And finally, thanks to all those of you over the last six weeks or so, who have told us how wonderful these pages are. We know it's fairly quiet around here at the moment, but that's because we're flat out developing new stuff for you. I see they got to the front end of the pages and sanitised things up a bit. Don't worry, the men in suits won't get in to the Proggies Dream. Look, I can say "Bollocks" and it stays. Yay.

And (finally, finally), even if MacFormat does completely screw up a distribution (there was Eddie, but no Fantasm!) we still get orders from it. Thanks and welcome to those of you joining us for the first time. And do you know what, when we complained to MacFormat (which we did fairly bloody quickly) we didn't even get a reply. Thank you. Thank you. Thank you.


So, for the last six weeks I've been coding for 12-18 hours a day non-stop, and poor old Rob, well... During that time I got to use lots of techniques and bits of the O.S. maybe you wouldn't normally want to go near. One of those areas was the time manager, which, as it turns out is pretty impressive, specially if you've been used to configuring your own chips to generate an interrupt for repetitive things - say music generation, screen updating etc.

So what can you do? Well, two things mainly.

1). You can time things to a very high accuracy, far more accurate than a tick (1/60.15 seconds), although some would have you believe it's 1/60.

2). You can set a task to run at given intervals, again to a high degree of accuracy and at a very high frequency should you need.

Timing

The easiest way of timing something is to call _Tickcount at the start, then again at the end of whatever you want to time, and subtract the start ticks from the end ticks. Fine. But what if what you are timing is all over and done with in a couple of microseconds? (bearing in mind that a Mac tick is roughly 16 milliseconds).

How do you do it? Well, you can add up all the instruction timings in whatever you were timing, and then factor it against the processor clock speed, like the bad old days, or you can use the _Microseconds call. Because I'm not completely insane, I prefer the latter to be honest.

Now, before we start messing with _Microseconds a few (one actually) caveats you should be aware of. Microseconds returns 64 bits, and you need to use 64 bit maths to calculate the elapsed time. This is a pain in C, but a doddle in either 68k or PPC assembly language, as I'll show.

In C, the definition looks like this:
pascal void Microseconds (UnsignedWide *microTickCount)

And you'd call it thus:
Microseconds(&myTime);
where myTime is defined as an UnsignedWide (that's 64 bits -- I prefer int64).

So, now to time our code, we can get the value of microseconds at the start of the routine, and again at the end, subtract start time from end time and voila - how long your code took to a millionth of a second.

The all important code to get at the current value of microseconds.

68k:
(this is compiler glue code version)

	pea	my_time(pc) *Save where we want the result
	dc.w	_Microseconds *returns in a0 and d0
	move.l	(sp)+,a1 *get result area
	move.l	a0,(a1)+ *save result
	move.l	d0,(a1)
my_time:	ds.l 2		*8 bytes

In assembly language we can speed this up:
	dc.w	_Microseconds
	move.l a0,d1	*now we have upper 32 bits in d1, and lower 32 bits in d0

PPC:

	lwz	r3,my_time(rtoc)
	Xcall	Microseconds
my_time:	ds.w 2	*8 bytes

These calls will return the current value of the microseconds counter, which funnily enough is incremented once every microsecond, or one million times per second. This actual counter is in the VIA (versatile Interface adapter) chip.


Now we move onto the issue of subtracting 64 bit data. As I said above, a pain in C, a doddle (and fun too!) in assembler.

68k:

	move.l	microseconds_end(a5),d0
	move.l	microseconds_end+4(a5),d1
	move.l	microseconds_start(a5),d2
	move.l	microseconds_start+4(a5),d3
	subx.l	d3,d1 *Cheesy instruction!
	subx.l	d2,d0
**Elapsed time in d1,d0 - d1-high32, d0=low32

PPC:
There are a few ways, I'm going for the "cheesed out" method and using the FPU:

	lwz	r3,microseconds_start(rtoc)
	lfd	f10,(r3)
	lwz	r3,microseconds_end(rtoc)
	lfd	f11,(r3)
	fsub	f12,f11,f10 *result in f12. Do with it what you want.

Note: You can remove the two lwz r3 instructions from this code by creating two "in toc" variables for both microseconds_start and end, and then it would be:
lfd r11,microseconds_start(rtoc)
etc.

So, that in a nutshell is how to determine elapsed time to a micro second. Of course for accurate timing, for example, in a scientific environment, you need to factor out the actual time it takes to call Microseconds; a rough guesstimate can be obtained by putting two calls next to each other. On my machine currently it comes out as 49 microseconds when called from PPC code. My Microseconds call switches to 68k - (currently OS 7.5.5.) so there's overhead in and out.

Next time I'll show you how to set up timer tasks. i.e. tasks that run repeatedly at given intervals. A use for these might be sound processing and/or generation, periodic calculations or anything that needs to happen at regular intervals. Even more fun (lots!). And it's the closest you're going to get to the VIA, honestly. Unless you're a complete nutter, in which case, you get the chip address from 1d4 (VIA), and the i/o space you may be interested in could be 1a00 from whatever is in 1d4.

As a taster, here's some 68k code - - exercise of the month is to figure out what it does. ("Oh, give us a hard one!" cried the crowd).
NOTE: Code assumes you have a valid window ptr in my_wind_ptr(a5)

setup_slow_timer:
**Set up slow timer task
	lea		my_a5(pc),a0
	move.l 	a5,(a0)
	lea 	my_slow_timer_task_rec(pc),a0
	lea 	my_slow_timer_task(pc),a1
	move.l 	a1,6(a0) *insert task pointer
	dc.w 	_InsTime
	lea 	my_slow_timer_task_rec(pc),a0
	move.l 	#500,d0
	dc.w 	_PrimeTime *reset timer
	clr.b 	slow_timer_flag(a5)
	rts_ 	"setup_my_slow_timer"

**This gets called when timer times out
**DO NOT MOVE MEMORY - interrupt routine
**task record is passed to us in a1
my_slow_timer_task:
	reset_locals
	local.l	stl_old_port,1
	movem.l	d3-d7/a3-a6,-(sp) 	*preserve non-volatile regs.
	link 	a4,#-100 			*local vars, Ok, so there's only one.
	lea 	my_a5(pc),a0
	move.l 	(a0),a5 			*get our a5 (I hope we're still running!)
	move.l 	a1,-(sp) 			*save record
**now do what we want
	pea 	stl_old_port(a4)
	dc.w 	_getport 			*waste of code
	move.l 	my_wind_ptr(a5),-(Sp)
	dc.w 	_Setport 			*not necessary
	move.l 	my_wind_ptr(a5),a0 	*grafport
	move.l 	2(A0),a0 			*handle!
	move.l 	(a0),a0 			*bitmap
	move.l 	(a0),a1 			*vram base addr
	clr.l 	d5
	clr.l 	d6
	move.w 	32(a0),d5 			*bits per pixel from bitmap
	lsr.w 	#3,d5 				*h count
	move.l 	d5,d6 				*hcount 2
	move.l 	#0xc0c0c0c0,d2		*Colour
	eori.b 	#0xff,slow_timer_flag(a5)
	beq.s 	done_colour
	neg.l 	d2 					*flip colour
done_colour:
	clr.l 	d1
	move.w 	4(a0),d1 			*byte/row
	andi.w 	#0x7fff,d1 			*so we don't get silly values
	move.l 	d1,d3 				*add value
	lsl.l 	#5,d1 				*down 32 lines
	moveq 	#2,d7 				*(move.l d5,d7, lsl.l d7)
	mulu 	d5,d7
	add.l 	d7,d1 				*x offset
	add.l 	d1,a1
	move.l 	a1,a2
hloop1:
	move.l 	d2,(A2)+ 			*fill first h line
	subq.l 	#1,d5
	bgt.s 	hloop1
	moveq 	#4,d4
	move.l 	d6,d7
loop:
	add.l 	d3,a1
	move.l 	a1,a2 				*next line
hloop2:
	move.l 	d2,(A2)+ 			*fill it
	subq.l 	#1,d6
	bgt.s 	hloop2
	move.l 	d7,d6
	dbra 	d4,loop 			*next h line
**now reset for next call
	move.l 	stl_old_port(a4),-(sp)
	dc.w 	_setport
	move.l 	(sp)+,a0 			*timer record
	move.l	#500,d0
	dc.w 	_PrimeTime 			*reset timer
	unlk	a4
	movem.l (sp)+,d3-d7/a3-a6
	rts_	"my_slow_task"
**call to remove the timer task
remove_task:
	lea		my_slow_timer_task_rec(pc),a0
	dc.w	_RmvTime
	rts_	"Remove_slow_task"
my_a5:		ds.l 1 				*my a5 goes here
my_slow_timer_task_rec: ds.b 32
	align						*habit


Now then, talking of MODS (what d'ya mean "we weren't"?), and as previously noted, I have now uploaded the tracks that made up my original top ten list. The complete archive was over 1.8 megabytes, so I've split it into two parts for easier downloading.

Download part1 (980k)
Download part2 (860k)

You'll need either PlayerPro or The Sound Trecker to play these. There are of course other MOD players for the Mac (and some sterling work being done on Mac mod players in general--long live the Alliance- Death to the Darkside!), but these two are the most fully featured and usable, with Player Pro being useful for composing as well. Any Mac capable of running these programs will be able to play these mods, which unfortunately is not the case with the following list of more up to date and higher quality tracks.

Just FYI, I was on alt.music.mods the other week. Two PeeCee owners were discussing "bits". One asks about 24 bit sound. The other responds that no computer has 24 bit sound capabilities because "it would cost thousands!", and you certainly can't get 24 bit sound out of a PeeCee. Hmm. Why not just get a nice Mac instead.

So, big Fanfare...


Stu's current top 6 current MOD's.

As usual, I had about twenty I wanted to get it, but ultimately had to whittle it down.

Six

Suburbia/High Hopes. Basehead. 1995. S3M. 16 channels. 790k. 7:05.
This one has been reviewed - here's the text:

Wow, a short Basehead track! Just seven minutes. Good grief, what is the world coming to? There'll be Sonny Bono in the White House next!

I'm not going to beat about the bush with this one; it's good (I had "shit hot" there but decided good would be more understandable).

We have two tracks in one, with the switch at partition 63 (3:56) from "Suburbia" which is described as "deep house groove" to "High Hopes" remixed from 1992. The two tracks are merged effortlessly by Basehead, so much so that you wouldn't know it is two tracks.

Dealing with Suburbia first (hang on, my book of superlatives has just fallen off my desk) it has some of the best fx I've heard in a long time. Not effects generated by the player (although they are used), but via the samples. The echoes and volume variations are terrific and really make you smile the first time you hear it. A "Groove", yes indeed. Sometimes you get darkness, sometimes you don't. Dance? Yup. Rhythm? Yup. Will you fall asleep? Ummm, no.

With the tempo increasing we move into High Hopes. The word here is "energy" with a capital E. A fast paced romp with classic chord play and sequencing on many keyboards would be a starting point for a description of High Hopes.

Amazingly it's all done in 16 channels with 43 instruments! There's sounds here I can't even begin to describe. I'd make a stab at the lead "bass" as a slidy, slightly ring modulated, soft clipped, mildly echoed "thing". Oh, it has clapping as well, that's one I can pinpoint with a fair degree of accuracy.

Get it. Give it lots of watts and watch the neighbours dance.

(Just one word of warning. The sampletext contains an "adult" word, so if you are playing this one with your kids you may like to watch out for that).

Five

Boston Lover - Mercure / GMF. 1996. XM. 700k. 14 channels (16 bit). 2:35
This is another that has been reviewed - text:

Normally, I can take or leave Jazz, which I realised this track is pretending to be after writing this review. Maybe I'm getting older or maybe this is just an outstanding track. Of course it's probably a bit of both, but what the hey. Umm, that's all pretty incomprehensible so I'd better get on with the review...

Here we go! This'll get your feet tapping. In the rhythm section we have well put together drum lines and a seriously slapped bass all served up with funky "quick waaah" Fender work. Up front there is an excellent electric piano coupled with a Sax that is just gorgeous.

Ok, so it's over 700k uncompressed. Sounds big huh? Well, I guess so, but if you want quality you have to pay for it, right? This is quality music no doubt. Jazz on the "right" side of life (i.e. a rhythm you can easily follow, not that there's anything wrong with the other type) which really wouldn't be out of place at any party after midnight. Mild funk? Probably. Maybe event reminiscent of some old "Camel" stuff if memory serves me right.

Listen to the drum work and pulses of energy! For this style of music it's outstanding. Indeed in it's class the whole piece is outstanding. I'm giving it 90, no, 91. And special mention must go to the work done on the electric piano. The style of play almost reminds me of early Keith Emerson which is just fantastic. This is particularly evident at about 0:40 and again at 1:22 on.

The samples are gold standard, all being 16 bit. The sax is of note (no pun intended) and is used most effectively towards the end when echoed across the sound field.

If you have any inclination at all to Jazz erring towards Funk (or maybe Funk wavering towards Jazz?), then I recommend it. It's music.

Can I find anything wrong with this seemingly masterful piece of work?

Yup! At 2 minutes 35 seconds it's way too short.

Four

Jaunt - WolfSong. 1996. XM. 20 channels. 630k. 2:49.

Again, this has been reviewed:

Yay! A straight up, no nonsense, honest to goodness, "in yer face" compo entry. And it's executed with all the style of a master craftsman. Wolfsong set out to win with this one and it shows.

With very little messing about (about 30 seconds actually) we get straight into what can only be described as a short reference piece for aspiring authors.

A 20 track XM is easily wasted; is it necessary to use all those tracks when each track is eating up memory and CPU cycles? It's a common question and in this case Wolfsong answers it quite positively; he uses the tracks well.

These kind of MODs are fortunately becoming more common. What do I mean by "these kind of MODs"? Well, the kind where it doesn't sound like a MOD.

The type of track that has no flaws you notice on the first play. The type of track that is executed so well you tape it for playing when you can't get at some silicon with 16 bit sound.

Effects? It's got them. Thing is, they fit so well into the overall picture that you don't even notice them. That's good 'cause it means the next time you listen to it, you'll find something you didn't find the first time; that will make you feel good (it makes me feel good anyway). And you'll need to listen to this one a few times just to get a handle on it.

The only real flaw is the end. It just kinda stutters and stops.

Three

Under the sea - FBY. 1996. XM. 12 channels. 700k. 3:15.

FBY has been around a while, is a talented musician and pretty much in the top five trackers worldwide. "Under the sea" marked a transition for this composer. Previous work, whilst complex and ambitious, didn't quite have what it takes. With Under the sea FBY broke through to the cutting edge of tracking, and currently this track ranks in the top three worldwide, never mind in my top 6.
This is an ambient guitar track. The lead play is phenomenal. Nuff said.

Two

I couldn't separate these two totally different tracks, so they both currently get second place.

Little Man - Elwood. 1995. 1995. XM. 500k. 26 channels. 4:07.

Typical demo style MOD. The melody is reminiscent of "Electric Dreams" from the film of the same title. Put this on to wake yourself up in the morning!
Elwood has been quite prolific, but this is, in my opinion, his best so far.


Kingdom Skies - Jase. 1996. S3M. 16 channels. 450k. 4:44.

This is a modern classical piece. Jase doesn't normally write in any particular style, but prefers to explore a variety. This is his classical offering, and is, in my opinion currently the best track of it's type. It knocks "Symphony" into a cocked hat, and "Symphony" got a very decent rating when reviewed. Kingdom Skies came first in the MC3 veteran section.

One

Chronologie part 4. Karsten Koch. 1994. S3M. 500k. 16 channels. 4:04
Original: J. M. Jarre.

OK, I know this is bad because this is a completely unoriginal piece, being a cover of JMJ's Chronologie part 4. It's still the best modern MOD in the world though :-) We're I to officially review this, it'd get 100%

Karsten Koch does not appear to produce many MOD's but I suspect this is because the ones he does produce are of such a high quality.


Others well worth the effort:
Synth Candy. Strago/ NW/ Xor. 1996. XM. 22 Channels. 420k. 2:46.
The Last Ballad - Siren. 1996. S3M. 540k. 16 channels. 4:43.
Winter Dreams - Blue Shadow. 1996. S3M. 16 channels. 400k. 5:25.

All of these MOD's should be available from the Weekly Module Review with the exception of Chronologie pt 4 and Kingdom Skies which you'll have trouble finding most anywhere, so I've put them on site:
Chronologie4 (400k ish).
Kingdom Skies (280k)


The end

Question: Why do comments in a C program always looks so "serious" and yet assembly language writers always have more upbeat and witty comments? Is it because assembly language programmers are more confident?

I have seen some C with "confident" comments. In it the author drops into 68k assembly with a suitably off hand comment. He then goes on to code:
move.l #0,d0
Smack in the middle of a tight loop. I do hope the compiler optimised it for him, but I doubt it :-)

Question: Is the WWW getting worse or what? Last night we went on a little "trawl" just viewing some things over and looking for "info". Man, all we got was advertisement after advertisement, and when we did get to where we thought we wanted to go, say manufacturer "a", there was scant little info anyway - and this was a leading company in the field! The actual content on the web seems to be decreasing at a rapid rate. Any articles of interest seem to be very short, and only point you to the hard copy version (available for n bucks). I fear, as big business takes over the web, the actual usefulness will decrease in direct proportion. If I had to recommend just one web site worth visiting, it would be Apple's, which even though people moan about it, is like, 16000% better than Microsofts.

Till the next time,

Code on!

Stu.

Just in case you think I'm going mad, I'm not. I know this should be Stuchat21. Indeed, there is a #21, but at the very last minute I decided to reschedule it for another time.


Send mail to Stu



Back to Stu's Page Top Level

Back to Lightsoft Home Page