Home » Archimedes archive » Acorn User » AU 1998-06 A.adf » Regulars » StarInfo/Mellor/c/SyrupSmall

StarInfo/Mellor/c/SyrupSmall

This website contains an archive of files for the Acorn Electron, BBC Micro, Acorn Archimedes, Commodore 16 and Commodore 64 computers, which Dominic Ford has rescued from his private collection of floppy disks and cassettes.

Some of these files were originally commercial releases in the 1980s and 1990s, but they are now widely available online. I assume that copyright over them is no longer being asserted. If you own the copyright and would like files to be removed, please contact me.

Tape/disk: Home » Archimedes archive » Acorn User » AU 1998-06 A.adf » Regulars
Filename: StarInfo/Mellor/c/SyrupSmall
Read OK:
File size: 0FF6 bytes
Load address: 0000
Exec address: 0000
File contents
/*      SyrupSmall source code  By Philip Mellor
   Written within 24 hours of buying Easy C++ ! */

#include "stdio.h"
#include "roslib.h"
#include "swis.h"
#include "math.h"
#include "kernel.h"
#include "stdlib.h"

/* global variables */
int bank_num=1;

int swap_banks()
{
  _kernel_swi_regs r_in, r_out;
  bank_num = 3 - bank_num;
  r_in.r[0] = 112;
  r_in.r[1] = bank_num;
  _kernel_swi(6, &r_in, &r_out);
}

int main(void)
{ _kernel_swi_regs r_in, r_out;

/* select screen mode 15 first to ensure 2x80k screens */
  os_mode(15);
  os_mode(13);
  os_cursor(0);

  r_in.r[0] = 2;
  _kernel_swi(OS_ReadDynamicArea, &r_in, &r_out);
  if (r_out.r[1] < (160*1024))
  { printf("You need at least 160k screen memory.");
    exit(EXIT_FAILURE);
  }

/* some lovely variables */
  int num, mx, my, sx, sy, xpos, offset;
  int oldangle, angle, a;

/* set up all that memory gubbins */
  int *ptr;
  ptr = malloc(256);

  char *screen_address;
  char *screen_address_bank;
  char *screen_address_temp;

/*find out the location of the screen memory*/
  *(ptr) = 148;
  *(ptr+1) = -1;
  r_in.r[0] = ptr;
  r_in.r[1] = ptr;
  _kernel_swi(OS_ReadVduVariables, &r_in, &r_out);
  int start = *(ptr);
  screen_address=(char *)start;

/*select the screen bank*/
  r_in.r[0] = 112;
  r_in.r[1] = 3-bank_num;
  _kernel_swi(6, &r_in, &r_out);

/*find out the location of the screen bank memory*/
  *(ptr) = 148;
  *(ptr+1) = -1;
  r_in.r[0] = ptr;
  r_in.r[1] = ptr;
  _kernel_swi(OS_ReadVduVariables, &r_in, &r_out);
  start = *(ptr);
  screen_address_bank=(char *)start;

/*select the first bank*/
  r_in.r[0] = 112;
  r_in.r[1] = bank_num;
  _kernel_swi(6, &r_in, &r_out);

/* calculate colour look-up table */

  int red, green, blue, c2;
  struct colourdata {
   int d1 [256];
   int d2 [256];
  };

  struct colourdata colour;
  float fraction;

  for (float c=0; c<256; c+=1)
  {

/* use the ever-popular ColourTrans_ConvertHSVToRGB
   to choose the colours */

  fraction = c*1.40625*65536;
  r_in.r[0] = fraction;
  r_in.r[1] = 65000;
  r_in.r[2] = 255;
  _kernel_swi(ColourTrans_ConvertHSVToRGB, &r_in, &r_out);
  red = r_out.r[0];
  green = r_out.r[1];
  blue = r_out.r[2];

/* a bit of a cheat to select the colour
   but never mind, it works, and that's the main thing... */
  r_in.r[0] = (red<<8) + (green<<16) + (blue<<24);
  r_in.r[3] = 256;
  r_in.r[4] = 0;
  _kernel_swi(ColourTrans_SetGCOL, &r_in, &r_out);

  os_circlefill(0,1023,32);                   /* hello mr. bodge... */
  c2 = (float) c;
  colour.d1[c2] = *(screen_address + 321);    /* selects 2 colours */
  colour.d2[c2] = *(screen_address + 322);    /* so we can do dithering */
  }

/* quick mr bodge! remove your evidence! */
  os_cls();

  os_gcol(0,63);
  os_tint(2, 3);

/* keep on going 'till we hit Escape */
  while (!os_inkey(-113))
  {

/* change the offset every loop to add to
   the colour cycling effect type thing */
  offset+=1;
  if (offset>255)
   offset=0;

  xpos = 80;

  for (int i=(320*48)+79; i<(320*208)-160; i+=2)
  {
  xpos+=2;
  
  if (xpos==240)
    { xpos = 80;
      i+=480;
    }

  /* read screen memory and smooth it all out... */
  num =(
         *(screen_address_bank + i - 2)
       + *(screen_address_bank + i + 2)
       + *(screen_address_bank + i + 640)
       + *(screen_address_bank + i - 640)
       ) >> 2;

  /* re-write it again */
  *(screen_address_bank + i) = num;

  /* offset it by the colour shift offset effort gubbins */
  num+=offset;
  if (num>255)
    num-=255;
  if (num<0)
    num+=255;

  /* plot 4 pixels on screen with dithering (d1 and d2) */
  *(screen_address + i) = colour.d1[num];
  *(screen_address + i + 1) = colour.d2[num];
  *(screen_address + i +320) = colour.d2[num];
  *(screen_address + i + 321) = colour.d1[num];
  }

  /* wait for that there v-sync */
  os_cli("fx19");

  /* mousetrap! */
  _kernel_swi(OS_Mouse, &r_in, &r_out);

  /* plot the mouse 'pointer' onto the screen bank */
  swap_banks();
  os_circlefill(r_out.r[0], r_out.r[1], (r_out.r[2]+2)*8 );
  swap_banks();

  /* round and round we go... */
  }

/* that's all folks */
}

00000000  2f 2a 20 20 20 20 20 20  53 79 72 75 70 53 6d 61  |/*      SyrupSma|
00000010  6c 6c 20 73 6f 75 72 63  65 20 63 6f 64 65 20 20  |ll source code  |
00000020  42 79 20 50 68 69 6c 69  70 20 4d 65 6c 6c 6f 72  |By Philip Mellor|
00000030  0a 20 20 20 57 72 69 74  74 65 6e 20 77 69 74 68  |.   Written with|
00000040  69 6e 20 32 34 20 68 6f  75 72 73 20 6f 66 20 62  |in 24 hours of b|
00000050  75 79 69 6e 67 20 45 61  73 79 20 43 2b 2b 20 21  |uying Easy C++ !|
00000060  20 2a 2f 0a 0a 23 69 6e  63 6c 75 64 65 20 22 73  | */..#include "s|
00000070  74 64 69 6f 2e 68 22 0a  23 69 6e 63 6c 75 64 65  |tdio.h".#include|
00000080  20 22 72 6f 73 6c 69 62  2e 68 22 0a 23 69 6e 63  | "roslib.h".#inc|
00000090  6c 75 64 65 20 22 73 77  69 73 2e 68 22 0a 23 69  |lude "swis.h".#i|
000000a0  6e 63 6c 75 64 65 20 22  6d 61 74 68 2e 68 22 0a  |nclude "math.h".|
000000b0  23 69 6e 63 6c 75 64 65  20 22 6b 65 72 6e 65 6c  |#include "kernel|
000000c0  2e 68 22 0a 23 69 6e 63  6c 75 64 65 20 22 73 74  |.h".#include "st|
000000d0  64 6c 69 62 2e 68 22 0a  0a 2f 2a 20 67 6c 6f 62  |dlib.h"../* glob|
000000e0  61 6c 20 76 61 72 69 61  62 6c 65 73 20 2a 2f 0a  |al variables */.|
000000f0  69 6e 74 20 62 61 6e 6b  5f 6e 75 6d 3d 31 3b 0a  |int bank_num=1;.|
00000100  0a 69 6e 74 20 73 77 61  70 5f 62 61 6e 6b 73 28  |.int swap_banks(|
00000110  29 0a 7b 0a 20 20 5f 6b  65 72 6e 65 6c 5f 73 77  |).{.  _kernel_sw|
00000120  69 5f 72 65 67 73 20 72  5f 69 6e 2c 20 72 5f 6f  |i_regs r_in, r_o|
00000130  75 74 3b 0a 20 20 62 61  6e 6b 5f 6e 75 6d 20 3d  |ut;.  bank_num =|
00000140  20 33 20 2d 20 62 61 6e  6b 5f 6e 75 6d 3b 0a 20  | 3 - bank_num;. |
00000150  20 72 5f 69 6e 2e 72 5b  30 5d 20 3d 20 31 31 32  | r_in.r[0] = 112|
00000160  3b 0a 20 20 72 5f 69 6e  2e 72 5b 31 5d 20 3d 20  |;.  r_in.r[1] = |
00000170  62 61 6e 6b 5f 6e 75 6d  3b 0a 20 20 5f 6b 65 72  |bank_num;.  _ker|
00000180  6e 65 6c 5f 73 77 69 28  36 2c 20 26 72 5f 69 6e  |nel_swi(6, &r_in|
00000190  2c 20 26 72 5f 6f 75 74  29 3b 0a 7d 0a 0a 69 6e  |, &r_out);.}..in|
000001a0  74 20 6d 61 69 6e 28 76  6f 69 64 29 0a 7b 20 5f  |t main(void).{ _|
000001b0  6b 65 72 6e 65 6c 5f 73  77 69 5f 72 65 67 73 20  |kernel_swi_regs |
000001c0  72 5f 69 6e 2c 20 72 5f  6f 75 74 3b 0a 0a 2f 2a  |r_in, r_out;../*|
000001d0  20 73 65 6c 65 63 74 20  73 63 72 65 65 6e 20 6d  | select screen m|
000001e0  6f 64 65 20 31 35 20 66  69 72 73 74 20 74 6f 20  |ode 15 first to |
000001f0  65 6e 73 75 72 65 20 32  78 38 30 6b 20 73 63 72  |ensure 2x80k scr|
00000200  65 65 6e 73 20 2a 2f 0a  20 20 6f 73 5f 6d 6f 64  |eens */.  os_mod|
00000210  65 28 31 35 29 3b 0a 20  20 6f 73 5f 6d 6f 64 65  |e(15);.  os_mode|
00000220  28 31 33 29 3b 0a 20 20  6f 73 5f 63 75 72 73 6f  |(13);.  os_curso|
00000230  72 28 30 29 3b 0a 0a 20  20 72 5f 69 6e 2e 72 5b  |r(0);..  r_in.r[|
00000240  30 5d 20 3d 20 32 3b 0a  20 20 5f 6b 65 72 6e 65  |0] = 2;.  _kerne|
00000250  6c 5f 73 77 69 28 4f 53  5f 52 65 61 64 44 79 6e  |l_swi(OS_ReadDyn|
00000260  61 6d 69 63 41 72 65 61  2c 20 26 72 5f 69 6e 2c  |amicArea, &r_in,|
00000270  20 26 72 5f 6f 75 74 29  3b 0a 20 20 69 66 20 28  | &r_out);.  if (|
00000280  72 5f 6f 75 74 2e 72 5b  31 5d 20 3c 20 28 31 36  |r_out.r[1] < (16|
00000290  30 2a 31 30 32 34 29 29  0a 20 20 7b 20 70 72 69  |0*1024)).  { pri|
000002a0  6e 74 66 28 22 59 6f 75  20 6e 65 65 64 20 61 74  |ntf("You need at|
000002b0  20 6c 65 61 73 74 20 31  36 30 6b 20 73 63 72 65  | least 160k scre|
000002c0  65 6e 20 6d 65 6d 6f 72  79 2e 22 29 3b 0a 20 20  |en memory.");.  |
000002d0  20 20 65 78 69 74 28 45  58 49 54 5f 46 41 49 4c  |  exit(EXIT_FAIL|
000002e0  55 52 45 29 3b 0a 20 20  7d 0a 0a 2f 2a 20 73 6f  |URE);.  }../* so|
000002f0  6d 65 20 6c 6f 76 65 6c  79 20 76 61 72 69 61 62  |me lovely variab|
00000300  6c 65 73 20 2a 2f 0a 20  20 69 6e 74 20 6e 75 6d  |les */.  int num|
00000310  2c 20 6d 78 2c 20 6d 79  2c 20 73 78 2c 20 73 79  |, mx, my, sx, sy|
00000320  2c 20 78 70 6f 73 2c 20  6f 66 66 73 65 74 3b 0a  |, xpos, offset;.|
00000330  20 20 69 6e 74 20 6f 6c  64 61 6e 67 6c 65 2c 20  |  int oldangle, |
00000340  61 6e 67 6c 65 2c 20 61  3b 0a 0a 2f 2a 20 73 65  |angle, a;../* se|
00000350  74 20 75 70 20 61 6c 6c  20 74 68 61 74 20 6d 65  |t up all that me|
00000360  6d 6f 72 79 20 67 75 62  62 69 6e 73 20 2a 2f 0a  |mory gubbins */.|
00000370  20 20 69 6e 74 20 2a 70  74 72 3b 0a 20 20 70 74  |  int *ptr;.  pt|
00000380  72 20 3d 20 6d 61 6c 6c  6f 63 28 32 35 36 29 3b  |r = malloc(256);|
00000390  0a 0a 20 20 63 68 61 72  20 2a 73 63 72 65 65 6e  |..  char *screen|
000003a0  5f 61 64 64 72 65 73 73  3b 0a 20 20 63 68 61 72  |_address;.  char|
000003b0  20 2a 73 63 72 65 65 6e  5f 61 64 64 72 65 73 73  | *screen_address|
000003c0  5f 62 61 6e 6b 3b 0a 20  20 63 68 61 72 20 2a 73  |_bank;.  char *s|
000003d0  63 72 65 65 6e 5f 61 64  64 72 65 73 73 5f 74 65  |creen_address_te|
000003e0  6d 70 3b 0a 0a 2f 2a 66  69 6e 64 20 6f 75 74 20  |mp;../*find out |
000003f0  74 68 65 20 6c 6f 63 61  74 69 6f 6e 20 6f 66 20  |the location of |
00000400  74 68 65 20 73 63 72 65  65 6e 20 6d 65 6d 6f 72  |the screen memor|
00000410  79 2a 2f 0a 20 20 2a 28  70 74 72 29 20 3d 20 31  |y*/.  *(ptr) = 1|
00000420  34 38 3b 0a 20 20 2a 28  70 74 72 2b 31 29 20 3d  |48;.  *(ptr+1) =|
00000430  20 2d 31 3b 0a 20 20 72  5f 69 6e 2e 72 5b 30 5d  | -1;.  r_in.r[0]|
00000440  20 3d 20 70 74 72 3b 0a  20 20 72 5f 69 6e 2e 72  | = ptr;.  r_in.r|
00000450  5b 31 5d 20 3d 20 70 74  72 3b 0a 20 20 5f 6b 65  |[1] = ptr;.  _ke|
00000460  72 6e 65 6c 5f 73 77 69  28 4f 53 5f 52 65 61 64  |rnel_swi(OS_Read|
00000470  56 64 75 56 61 72 69 61  62 6c 65 73 2c 20 26 72  |VduVariables, &r|
00000480  5f 69 6e 2c 20 26 72 5f  6f 75 74 29 3b 0a 20 20  |_in, &r_out);.  |
00000490  69 6e 74 20 73 74 61 72  74 20 3d 20 2a 28 70 74  |int start = *(pt|
000004a0  72 29 3b 0a 20 20 73 63  72 65 65 6e 5f 61 64 64  |r);.  screen_add|
000004b0  72 65 73 73 3d 28 63 68  61 72 20 2a 29 73 74 61  |ress=(char *)sta|
000004c0  72 74 3b 0a 0a 2f 2a 73  65 6c 65 63 74 20 74 68  |rt;../*select th|
000004d0  65 20 73 63 72 65 65 6e  20 62 61 6e 6b 2a 2f 0a  |e screen bank*/.|
000004e0  20 20 72 5f 69 6e 2e 72  5b 30 5d 20 3d 20 31 31  |  r_in.r[0] = 11|
000004f0  32 3b 0a 20 20 72 5f 69  6e 2e 72 5b 31 5d 20 3d  |2;.  r_in.r[1] =|
00000500  20 33 2d 62 61 6e 6b 5f  6e 75 6d 3b 0a 20 20 5f  | 3-bank_num;.  _|
00000510  6b 65 72 6e 65 6c 5f 73  77 69 28 36 2c 20 26 72  |kernel_swi(6, &r|
00000520  5f 69 6e 2c 20 26 72 5f  6f 75 74 29 3b 0a 0a 2f  |_in, &r_out);../|
00000530  2a 66 69 6e 64 20 6f 75  74 20 74 68 65 20 6c 6f  |*find out the lo|
00000540  63 61 74 69 6f 6e 20 6f  66 20 74 68 65 20 73 63  |cation of the sc|
00000550  72 65 65 6e 20 62 61 6e  6b 20 6d 65 6d 6f 72 79  |reen bank memory|
00000560  2a 2f 0a 20 20 2a 28 70  74 72 29 20 3d 20 31 34  |*/.  *(ptr) = 14|
00000570  38 3b 0a 20 20 2a 28 70  74 72 2b 31 29 20 3d 20  |8;.  *(ptr+1) = |
00000580  2d 31 3b 0a 20 20 72 5f  69 6e 2e 72 5b 30 5d 20  |-1;.  r_in.r[0] |
00000590  3d 20 70 74 72 3b 0a 20  20 72 5f 69 6e 2e 72 5b  |= ptr;.  r_in.r[|
000005a0  31 5d 20 3d 20 70 74 72  3b 0a 20 20 5f 6b 65 72  |1] = ptr;.  _ker|
000005b0  6e 65 6c 5f 73 77 69 28  4f 53 5f 52 65 61 64 56  |nel_swi(OS_ReadV|
000005c0  64 75 56 61 72 69 61 62  6c 65 73 2c 20 26 72 5f  |duVariables, &r_|
000005d0  69 6e 2c 20 26 72 5f 6f  75 74 29 3b 0a 20 20 73  |in, &r_out);.  s|
000005e0  74 61 72 74 20 3d 20 2a  28 70 74 72 29 3b 0a 20  |tart = *(ptr);. |
000005f0  20 73 63 72 65 65 6e 5f  61 64 64 72 65 73 73 5f  | screen_address_|
00000600  62 61 6e 6b 3d 28 63 68  61 72 20 2a 29 73 74 61  |bank=(char *)sta|
00000610  72 74 3b 0a 0a 2f 2a 73  65 6c 65 63 74 20 74 68  |rt;../*select th|
00000620  65 20 66 69 72 73 74 20  62 61 6e 6b 2a 2f 0a 20  |e first bank*/. |
00000630  20 72 5f 69 6e 2e 72 5b  30 5d 20 3d 20 31 31 32  | r_in.r[0] = 112|
00000640  3b 0a 20 20 72 5f 69 6e  2e 72 5b 31 5d 20 3d 20  |;.  r_in.r[1] = |
00000650  62 61 6e 6b 5f 6e 75 6d  3b 0a 20 20 5f 6b 65 72  |bank_num;.  _ker|
00000660  6e 65 6c 5f 73 77 69 28  36 2c 20 26 72 5f 69 6e  |nel_swi(6, &r_in|
00000670  2c 20 26 72 5f 6f 75 74  29 3b 0a 0a 2f 2a 20 63  |, &r_out);../* c|
00000680  61 6c 63 75 6c 61 74 65  20 63 6f 6c 6f 75 72 20  |alculate colour |
00000690  6c 6f 6f 6b 2d 75 70 20  74 61 62 6c 65 20 2a 2f  |look-up table */|
000006a0  0a 0a 20 20 69 6e 74 20  72 65 64 2c 20 67 72 65  |..  int red, gre|
000006b0  65 6e 2c 20 62 6c 75 65  2c 20 63 32 3b 0a 20 20  |en, blue, c2;.  |
000006c0  73 74 72 75 63 74 20 63  6f 6c 6f 75 72 64 61 74  |struct colourdat|
000006d0  61 20 7b 0a 20 20 20 69  6e 74 20 64 31 20 5b 32  |a {.   int d1 [2|
000006e0  35 36 5d 3b 0a 20 20 20  69 6e 74 20 64 32 20 5b  |56];.   int d2 [|
000006f0  32 35 36 5d 3b 0a 20 20  7d 3b 0a 0a 20 20 73 74  |256];.  };..  st|
00000700  72 75 63 74 20 63 6f 6c  6f 75 72 64 61 74 61 20  |ruct colourdata |
00000710  63 6f 6c 6f 75 72 3b 0a  20 20 66 6c 6f 61 74 20  |colour;.  float |
00000720  66 72 61 63 74 69 6f 6e  3b 0a 0a 20 20 66 6f 72  |fraction;..  for|
00000730  20 28 66 6c 6f 61 74 20  63 3d 30 3b 20 63 3c 32  | (float c=0; c<2|
00000740  35 36 3b 20 63 2b 3d 31  29 0a 20 20 7b 0a 0a 2f  |56; c+=1).  {../|
00000750  2a 20 75 73 65 20 74 68  65 20 65 76 65 72 2d 70  |* use the ever-p|
00000760  6f 70 75 6c 61 72 20 43  6f 6c 6f 75 72 54 72 61  |opular ColourTra|
00000770  6e 73 5f 43 6f 6e 76 65  72 74 48 53 56 54 6f 52  |ns_ConvertHSVToR|
00000780  47 42 0a 20 20 20 74 6f  20 63 68 6f 6f 73 65 20  |GB.   to choose |
00000790  74 68 65 20 63 6f 6c 6f  75 72 73 20 2a 2f 0a 0a  |the colours */..|
000007a0  20 20 66 72 61 63 74 69  6f 6e 20 3d 20 63 2a 31  |  fraction = c*1|
000007b0  2e 34 30 36 32 35 2a 36  35 35 33 36 3b 0a 20 20  |.40625*65536;.  |
000007c0  72 5f 69 6e 2e 72 5b 30  5d 20 3d 20 66 72 61 63  |r_in.r[0] = frac|
000007d0  74 69 6f 6e 3b 0a 20 20  72 5f 69 6e 2e 72 5b 31  |tion;.  r_in.r[1|
000007e0  5d 20 3d 20 36 35 30 30  30 3b 0a 20 20 72 5f 69  |] = 65000;.  r_i|
000007f0  6e 2e 72 5b 32 5d 20 3d  20 32 35 35 3b 0a 20 20  |n.r[2] = 255;.  |
00000800  5f 6b 65 72 6e 65 6c 5f  73 77 69 28 43 6f 6c 6f  |_kernel_swi(Colo|
00000810  75 72 54 72 61 6e 73 5f  43 6f 6e 76 65 72 74 48  |urTrans_ConvertH|
00000820  53 56 54 6f 52 47 42 2c  20 26 72 5f 69 6e 2c 20  |SVToRGB, &r_in, |
00000830  26 72 5f 6f 75 74 29 3b  0a 20 20 72 65 64 20 3d  |&r_out);.  red =|
00000840  20 72 5f 6f 75 74 2e 72  5b 30 5d 3b 0a 20 20 67  | r_out.r[0];.  g|
00000850  72 65 65 6e 20 3d 20 72  5f 6f 75 74 2e 72 5b 31  |reen = r_out.r[1|
00000860  5d 3b 0a 20 20 62 6c 75  65 20 3d 20 72 5f 6f 75  |];.  blue = r_ou|
00000870  74 2e 72 5b 32 5d 3b 0a  0a 2f 2a 20 61 20 62 69  |t.r[2];../* a bi|
00000880  74 20 6f 66 20 61 20 63  68 65 61 74 20 74 6f 20  |t of a cheat to |
00000890  73 65 6c 65 63 74 20 74  68 65 20 63 6f 6c 6f 75  |select the colou|
000008a0  72 0a 20 20 20 62 75 74  20 6e 65 76 65 72 20 6d  |r.   but never m|
000008b0  69 6e 64 2c 20 69 74 20  77 6f 72 6b 73 2c 20 61  |ind, it works, a|
000008c0  6e 64 20 74 68 61 74 27  73 20 74 68 65 20 6d 61  |nd that's the ma|
000008d0  69 6e 20 74 68 69 6e 67  2e 2e 2e 20 2a 2f 0a 20  |in thing... */. |
000008e0  20 72 5f 69 6e 2e 72 5b  30 5d 20 3d 20 28 72 65  | r_in.r[0] = (re|
000008f0  64 3c 3c 38 29 20 2b 20  28 67 72 65 65 6e 3c 3c  |d<<8) + (green<<|
00000900  31 36 29 20 2b 20 28 62  6c 75 65 3c 3c 32 34 29  |16) + (blue<<24)|
00000910  3b 0a 20 20 72 5f 69 6e  2e 72 5b 33 5d 20 3d 20  |;.  r_in.r[3] = |
00000920  32 35 36 3b 0a 20 20 72  5f 69 6e 2e 72 5b 34 5d  |256;.  r_in.r[4]|
00000930  20 3d 20 30 3b 0a 20 20  5f 6b 65 72 6e 65 6c 5f  | = 0;.  _kernel_|
00000940  73 77 69 28 43 6f 6c 6f  75 72 54 72 61 6e 73 5f  |swi(ColourTrans_|
00000950  53 65 74 47 43 4f 4c 2c  20 26 72 5f 69 6e 2c 20  |SetGCOL, &r_in, |
00000960  26 72 5f 6f 75 74 29 3b  0a 0a 20 20 6f 73 5f 63  |&r_out);..  os_c|
00000970  69 72 63 6c 65 66 69 6c  6c 28 30 2c 31 30 32 33  |irclefill(0,1023|
00000980  2c 33 32 29 3b 20 20 20  20 20 20 20 20 20 20 20  |,32);           |
00000990  20 20 20 20 20 20 20 20  2f 2a 20 68 65 6c 6c 6f  |        /* hello|
000009a0  20 6d 72 2e 20 62 6f 64  67 65 2e 2e 2e 20 2a 2f  | mr. bodge... */|
000009b0  0a 20 20 63 32 20 3d 20  28 66 6c 6f 61 74 29 20  |.  c2 = (float) |
000009c0  63 3b 0a 20 20 63 6f 6c  6f 75 72 2e 64 31 5b 63  |c;.  colour.d1[c|
000009d0  32 5d 20 3d 20 2a 28 73  63 72 65 65 6e 5f 61 64  |2] = *(screen_ad|
000009e0  64 72 65 73 73 20 2b 20  33 32 31 29 3b 20 20 20  |dress + 321);   |
000009f0  20 2f 2a 20 73 65 6c 65  63 74 73 20 32 20 63 6f  | /* selects 2 co|
00000a00  6c 6f 75 72 73 20 2a 2f  0a 20 20 63 6f 6c 6f 75  |lours */.  colou|
00000a10  72 2e 64 32 5b 63 32 5d  20 3d 20 2a 28 73 63 72  |r.d2[c2] = *(scr|
00000a20  65 65 6e 5f 61 64 64 72  65 73 73 20 2b 20 33 32  |een_address + 32|
00000a30  32 29 3b 20 20 20 20 2f  2a 20 73 6f 20 77 65 20  |2);    /* so we |
00000a40  63 61 6e 20 64 6f 20 64  69 74 68 65 72 69 6e 67  |can do dithering|
00000a50  20 2a 2f 0a 20 20 7d 0a  0a 2f 2a 20 71 75 69 63  | */.  }../* quic|
00000a60  6b 20 6d 72 20 62 6f 64  67 65 21 20 72 65 6d 6f  |k mr bodge! remo|
00000a70  76 65 20 79 6f 75 72 20  65 76 69 64 65 6e 63 65  |ve your evidence|
00000a80  21 20 2a 2f 0a 20 20 6f  73 5f 63 6c 73 28 29 3b  |! */.  os_cls();|
00000a90  0a 0a 20 20 6f 73 5f 67  63 6f 6c 28 30 2c 36 33  |..  os_gcol(0,63|
00000aa0  29 3b 0a 20 20 6f 73 5f  74 69 6e 74 28 32 2c 20  |);.  os_tint(2, |
00000ab0  33 29 3b 0a 0a 2f 2a 20  6b 65 65 70 20 6f 6e 20  |3);../* keep on |
00000ac0  67 6f 69 6e 67 20 27 74  69 6c 6c 20 77 65 20 68  |going 'till we h|
00000ad0  69 74 20 45 73 63 61 70  65 20 2a 2f 0a 20 20 77  |it Escape */.  w|
00000ae0  68 69 6c 65 20 28 21 6f  73 5f 69 6e 6b 65 79 28  |hile (!os_inkey(|
00000af0  2d 31 31 33 29 29 0a 20  20 7b 0a 0a 2f 2a 20 63  |-113)).  {../* c|
00000b00  68 61 6e 67 65 20 74 68  65 20 6f 66 66 73 65 74  |hange the offset|
00000b10  20 65 76 65 72 79 20 6c  6f 6f 70 20 74 6f 20 61  | every loop to a|
00000b20  64 64 20 74 6f 0a 20 20  20 74 68 65 20 63 6f 6c  |dd to.   the col|
00000b30  6f 75 72 20 63 79 63 6c  69 6e 67 20 65 66 66 65  |our cycling effe|
00000b40  63 74 20 74 79 70 65 20  74 68 69 6e 67 20 2a 2f  |ct type thing */|
00000b50  0a 20 20 6f 66 66 73 65  74 2b 3d 31 3b 0a 20 20  |.  offset+=1;.  |
00000b60  69 66 20 28 6f 66 66 73  65 74 3e 32 35 35 29 0a  |if (offset>255).|
00000b70  20 20 20 6f 66 66 73 65  74 3d 30 3b 0a 0a 20 20  |   offset=0;..  |
00000b80  78 70 6f 73 20 3d 20 38  30 3b 0a 0a 20 20 66 6f  |xpos = 80;..  fo|
00000b90  72 20 28 69 6e 74 20 69  3d 28 33 32 30 2a 34 38  |r (int i=(320*48|
00000ba0  29 2b 37 39 3b 20 69 3c  28 33 32 30 2a 32 30 38  |)+79; i<(320*208|
00000bb0  29 2d 31 36 30 3b 20 69  2b 3d 32 29 0a 20 20 7b  |)-160; i+=2).  {|
00000bc0  0a 20 20 78 70 6f 73 2b  3d 32 3b 0a 20 20 0a 20  |.  xpos+=2;.  . |
00000bd0  20 69 66 20 28 78 70 6f  73 3d 3d 32 34 30 29 0a  | if (xpos==240).|
00000be0  20 20 20 20 7b 20 78 70  6f 73 20 3d 20 38 30 3b  |    { xpos = 80;|
00000bf0  0a 20 20 20 20 20 20 69  2b 3d 34 38 30 3b 0a 20  |.      i+=480;. |
00000c00  20 20 20 7d 0a 0a 20 20  2f 2a 20 72 65 61 64 20  |   }..  /* read |
00000c10  73 63 72 65 65 6e 20 6d  65 6d 6f 72 79 20 61 6e  |screen memory an|
00000c20  64 20 73 6d 6f 6f 74 68  20 69 74 20 61 6c 6c 20  |d smooth it all |
00000c30  6f 75 74 2e 2e 2e 20 2a  2f 0a 20 20 6e 75 6d 20  |out... */.  num |
00000c40  3d 28 0a 20 20 20 20 20  20 20 20 20 2a 28 73 63  |=(.         *(sc|
00000c50  72 65 65 6e 5f 61 64 64  72 65 73 73 5f 62 61 6e  |reen_address_ban|
00000c60  6b 20 2b 20 69 20 2d 20  32 29 0a 20 20 20 20 20  |k + i - 2).     |
00000c70  20 20 2b 20 2a 28 73 63  72 65 65 6e 5f 61 64 64  |  + *(screen_add|
00000c80  72 65 73 73 5f 62 61 6e  6b 20 2b 20 69 20 2b 20  |ress_bank + i + |
00000c90  32 29 0a 20 20 20 20 20  20 20 2b 20 2a 28 73 63  |2).       + *(sc|
00000ca0  72 65 65 6e 5f 61 64 64  72 65 73 73 5f 62 61 6e  |reen_address_ban|
00000cb0  6b 20 2b 20 69 20 2b 20  36 34 30 29 0a 20 20 20  |k + i + 640).   |
00000cc0  20 20 20 20 2b 20 2a 28  73 63 72 65 65 6e 5f 61  |    + *(screen_a|
00000cd0  64 64 72 65 73 73 5f 62  61 6e 6b 20 2b 20 69 20  |ddress_bank + i |
00000ce0  2d 20 36 34 30 29 0a 20  20 20 20 20 20 20 29 20  |- 640).       ) |
00000cf0  3e 3e 20 32 3b 0a 0a 20  20 2f 2a 20 72 65 2d 77  |>> 2;..  /* re-w|
00000d00  72 69 74 65 20 69 74 20  61 67 61 69 6e 20 2a 2f  |rite it again */|
00000d10  0a 20 20 2a 28 73 63 72  65 65 6e 5f 61 64 64 72  |.  *(screen_addr|
00000d20  65 73 73 5f 62 61 6e 6b  20 2b 20 69 29 20 3d 20  |ess_bank + i) = |
00000d30  6e 75 6d 3b 0a 0a 20 20  2f 2a 20 6f 66 66 73 65  |num;..  /* offse|
00000d40  74 20 69 74 20 62 79 20  74 68 65 20 63 6f 6c 6f  |t it by the colo|
00000d50  75 72 20 73 68 69 66 74  20 6f 66 66 73 65 74 20  |ur shift offset |
00000d60  65 66 66 6f 72 74 20 67  75 62 62 69 6e 73 20 2a  |effort gubbins *|
00000d70  2f 0a 20 20 6e 75 6d 2b  3d 6f 66 66 73 65 74 3b  |/.  num+=offset;|
00000d80  0a 20 20 69 66 20 28 6e  75 6d 3e 32 35 35 29 0a  |.  if (num>255).|
00000d90  20 20 20 20 6e 75 6d 2d  3d 32 35 35 3b 0a 20 20  |    num-=255;.  |
00000da0  69 66 20 28 6e 75 6d 3c  30 29 0a 20 20 20 20 6e  |if (num<0).    n|
00000db0  75 6d 2b 3d 32 35 35 3b  0a 0a 20 20 2f 2a 20 70  |um+=255;..  /* p|
00000dc0  6c 6f 74 20 34 20 70 69  78 65 6c 73 20 6f 6e 20  |lot 4 pixels on |
00000dd0  73 63 72 65 65 6e 20 77  69 74 68 20 64 69 74 68  |screen with dith|
00000de0  65 72 69 6e 67 20 28 64  31 20 61 6e 64 20 64 32  |ering (d1 and d2|
00000df0  29 20 2a 2f 0a 20 20 2a  28 73 63 72 65 65 6e 5f  |) */.  *(screen_|
00000e00  61 64 64 72 65 73 73 20  2b 20 69 29 20 3d 20 63  |address + i) = c|
00000e10  6f 6c 6f 75 72 2e 64 31  5b 6e 75 6d 5d 3b 0a 20  |olour.d1[num];. |
00000e20  20 2a 28 73 63 72 65 65  6e 5f 61 64 64 72 65 73  | *(screen_addres|
00000e30  73 20 2b 20 69 20 2b 20  31 29 20 3d 20 63 6f 6c  |s + i + 1) = col|
00000e40  6f 75 72 2e 64 32 5b 6e  75 6d 5d 3b 0a 20 20 2a  |our.d2[num];.  *|
00000e50  28 73 63 72 65 65 6e 5f  61 64 64 72 65 73 73 20  |(screen_address |
00000e60  2b 20 69 20 2b 33 32 30  29 20 3d 20 63 6f 6c 6f  |+ i +320) = colo|
00000e70  75 72 2e 64 32 5b 6e 75  6d 5d 3b 0a 20 20 2a 28  |ur.d2[num];.  *(|
00000e80  73 63 72 65 65 6e 5f 61  64 64 72 65 73 73 20 2b  |screen_address +|
00000e90  20 69 20 2b 20 33 32 31  29 20 3d 20 63 6f 6c 6f  | i + 321) = colo|
00000ea0  75 72 2e 64 31 5b 6e 75  6d 5d 3b 0a 20 20 7d 0a  |ur.d1[num];.  }.|
00000eb0  0a 20 20 2f 2a 20 77 61  69 74 20 66 6f 72 20 74  |.  /* wait for t|
00000ec0  68 61 74 20 74 68 65 72  65 20 76 2d 73 79 6e 63  |hat there v-sync|
00000ed0  20 2a 2f 0a 20 20 6f 73  5f 63 6c 69 28 22 66 78  | */.  os_cli("fx|
00000ee0  31 39 22 29 3b 0a 0a 20  20 2f 2a 20 6d 6f 75 73  |19");..  /* mous|
00000ef0  65 74 72 61 70 21 20 2a  2f 0a 20 20 5f 6b 65 72  |etrap! */.  _ker|
00000f00  6e 65 6c 5f 73 77 69 28  4f 53 5f 4d 6f 75 73 65  |nel_swi(OS_Mouse|
00000f10  2c 20 26 72 5f 69 6e 2c  20 26 72 5f 6f 75 74 29  |, &r_in, &r_out)|
00000f20  3b 0a 0a 20 20 2f 2a 20  70 6c 6f 74 20 74 68 65  |;..  /* plot the|
00000f30  20 6d 6f 75 73 65 20 27  70 6f 69 6e 74 65 72 27  | mouse 'pointer'|
00000f40  20 6f 6e 74 6f 20 74 68  65 20 73 63 72 65 65 6e  | onto the screen|
00000f50  20 62 61 6e 6b 20 2a 2f  0a 20 20 73 77 61 70 5f  | bank */.  swap_|
00000f60  62 61 6e 6b 73 28 29 3b  0a 20 20 6f 73 5f 63 69  |banks();.  os_ci|
00000f70  72 63 6c 65 66 69 6c 6c  28 72 5f 6f 75 74 2e 72  |rclefill(r_out.r|
00000f80  5b 30 5d 2c 20 72 5f 6f  75 74 2e 72 5b 31 5d 2c  |[0], r_out.r[1],|
00000f90  20 28 72 5f 6f 75 74 2e  72 5b 32 5d 2b 32 29 2a  | (r_out.r[2]+2)*|
00000fa0  38 20 29 3b 0a 20 20 73  77 61 70 5f 62 61 6e 6b  |8 );.  swap_bank|
00000fb0  73 28 29 3b 0a 0a 20 20  2f 2a 20 72 6f 75 6e 64  |s();..  /* round|
00000fc0  20 61 6e 64 20 72 6f 75  6e 64 20 77 65 20 67 6f  | and round we go|
00000fd0  2e 2e 2e 20 2a 2f 0a 20  20 7d 0a 0a 2f 2a 20 74  |... */.  }../* t|
00000fe0  68 61 74 27 73 20 61 6c  6c 20 66 6f 6c 6b 73 20  |hat's all folks |
00000ff0  2a 2f 0a 7d 0a 0a                                 |*/.}..|
00000ff6