Co-routines was Re: [PDP8-Lovers] if you hadn't already known this about the PDP-8

From: Doug Coward <mranalog_at_attbi.com>
Date: Sat Dec 15 04:06:43 2001

 "Sean 'Captain Napalm' Conner" <spc_at_conman.org> wrote:
> So what, exactly is a co-routine? I've heard the term before, but I'm not
> entirely sure what they are, or how they would work.
> -spc (I may have used them in assembly, but not knew the proper term ... )

  The only time I remember using a coroutine was a time when
I had no interrupts to use.
  The Sega Genesis has a 68000 with main program memory, plus
a sound system controlled by a Z80 with it's own sound memory.
Sound memory is loaded with a sound driver written in Z80
assembly. Now the sound system has a free running timer but
no interrupts, so most games had a sound driver that played
FM sounds or a sound driver that played digitized sound.
My job was to take an FM sound driver and make it play
digitized sound at the same time.
 So I wrote a routine that quickly checked if a digitized
sound was playing and if it was, then check if it was time
to stuff the next value of the digitized sound. The hard part
was then to pepper the existing sound driver with calls to
this coroutine such that the existing sound driver would
not be slowed down and that the digitized sound would be
played at a constant rate. It worked great.

 Oh! "what, exactly is a co-routine?"
  A coroutine is a procedure that executes from the point it
last suspended execution up to the next instruction that suspends
its execution. That is, it preserves state between invocations.
  Regards,
  --Doug
=========================================
Doug Coward
_at_ home in Poulsbo, WA

Analog Computer Online Museum and History Center
http://www.best.com/~dcoward/analog
=========================================
Received on Sat Dec 15 2001 - 04:06:43 GMT

This archive was generated by hypermail 2.3.0 : Fri Oct 10 2014 - 23:33:39 BST