wolfenstein 3d

  unrolling loops
  c2p part I (st)
  c2p part II (st)
  avoiding c2p (st)
  interlacing (st)
  fat mapping
  3d pipeline
  portal rendering
  8bpp color mixing
  fixedpoint math
  blitter (mst/ste)
  sample replay (st)
  blitter gouraud (falc)
  blitter fading (falc)
  arbitrary mapping
  frustrum clipping etc.

  mc68000 math lib
  32 bytes sin-gen
  24 bit tga-viewer
  blitter example
  lz77 packer
  lz78 packer
  protracker replayer
high color interlacing

haven't you ever wondered how to display more than 16 colors on the ST and compatibles ? Sure you could lock the whole system and use a routine that relies on the mc68000 clock-timing to display more colors by constantly changing the color palette like spectrum 512 did - but what if you want to run it on a 16Mhz or faster cpu where the timing is diffrent or if you want to display a realtime-effect instead of a static picture ?
well, the solution is quite easy: use a technique called "interlacing". the term interlacing is used in situations where a picture is splitted up into two or more pictures which get displayed alternately in order to emulate a higher resolution or color depth (on the falcon this trick is implemented as a hardware-feature to be able display resolutions with 400 lines on RGB monitors which actually can't show this amount of rows. i even coded a little tsr that installs an interlace diver on Mega STs doing exactly the same).
now, of course this just works because our sluggish eyes won't be able to resolute the elemental pictures being interlaced. nevertheless you will most likely notice a strong flicker so first of all i'd recommend you to switch to 60Hz to gain an effective refresh rate of 30Hz instead of 25Hz which would be aimed working in a 50Hz mode.
let's concentrate on applying this with demo effects:
the first thing you need to know is that your effects will have to run less than or exatly in 1vbl to make sure your flicker doesn't get too heavy, this means 60fps working in 60Hz NTSC mode or 50fps working in PAL mode (note: the vertical synchronization can be swiched by altering bit 1 of $ffff820a.w, where a 1 means 50Hz, a 0 equals 60Hz. however this doesn't work on TTs, so be careful).
so imagine you'd try to display a transparent effect on top of a static picture. the first thing that'd need to be done was finding a common palette for your picture and effect. then you would copy the picture into one of your screenbuffers which would get displayed every 2nd vbl, during the vbl the picture gets displayed you would then map your effect into a 2nd buffer which would get activated from the next vbl (here you might see why it's recommendable to use an effect that runs in 1vbl :). voilá you would have just created a transparent effect using 256 colors, nice isn't it ?
hmmm, try it and you will notice an obvious flicker that badly hurts your eyes if you try looking at it for more than 10 seconds. don't worry, there's a way to heavily reduce this flicker. it works by simply mixing your fore- and background picture in a certain pattern, which even has a further advantage as you will just have to map half of the pixels needed for your effect every vbl as long as performed properly.
the following pattern tries to illustrate the way it can be done:

1st vbl   2nd vbl
    pixels of effect 1
    pixels of static picture/effect 2

according to the table you might realize that it's even possible to mix 2 effects. furthermore, as only half of the pixels will need to be drawn while the effect gets updated each vbl a nice blurring can be achieved, even 1*1 effects are possible if you only update every 4th pixel per vbl for instance. and the results might really look quite astonishing ! if you want to see this trick in action you should definetly watch "two in one" or the "ucm 16 intro" by dhs who were one of the first groups using it on the Atari ST and compatibles to my knowledge.

- 2002 ray//.tscc. -