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

StarInfo/Mellor/c/Syrup

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/Syrup
Read OK:
File size: 0FE7 bytes
Load address: 0000
Exec address: 0000
File contents
/*      Syrup source code  By Philip Mellor
   Completed 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 = 0;

  for (int i=(640); i<(320*252); i+=2)
  {
  xpos+=2;
  
  if (xpos==320)
    { xpos = 0;
      i+=320;
    }

  /* 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 20 73 6f  |/*      Syrup so|
00000010  75 72 63 65 20 63 6f 64  65 20 20 42 79 20 50 68  |urce code  By Ph|
00000020  69 6c 69 70 20 4d 65 6c  6c 6f 72 0a 20 20 20 43  |ilip Mellor.   C|
00000030  6f 6d 70 6c 65 74 65 64  20 77 69 74 68 69 6e 20  |ompleted within |
00000040  32 34 20 68 6f 75 72 73  20 6f 66 20 62 75 79 69  |24 hours of buyi|
00000050  6e 67 20 45 61 73 79 20  43 2b 2b 20 21 20 2a 2f  |ng Easy C++ ! */|
00000060  0a 0a 23 69 6e 63 6c 75  64 65 20 22 73 74 64 69  |..#include "stdi|
00000070  6f 2e 68 22 0a 23 69 6e  63 6c 75 64 65 20 22 72  |o.h".#include "r|
00000080  6f 73 6c 69 62 2e 68 22  0a 23 69 6e 63 6c 75 64  |oslib.h".#includ|
00000090  65 20 22 73 77 69 73 2e  68 22 0a 23 69 6e 63 6c  |e "swis.h".#incl|
000000a0  75 64 65 20 22 6d 61 74  68 2e 68 22 0a 23 69 6e  |ude "math.h".#in|
000000b0  63 6c 75 64 65 20 22 6b  65 72 6e 65 6c 2e 68 22  |clude "kernel.h"|
000000c0  0a 23 69 6e 63 6c 75 64  65 20 22 73 74 64 6c 69  |.#include "stdli|
000000d0  62 2e 68 22 0a 0a 2f 2a  20 67 6c 6f 62 61 6c 20  |b.h"../* global |
000000e0  76 61 72 69 61 62 6c 65  73 20 2a 2f 0a 69 6e 74  |variables */.int|
000000f0  20 62 61 6e 6b 5f 6e 75  6d 3d 31 3b 0a 0a 69 6e  | bank_num=1;..in|
00000100  74 20 73 77 61 70 5f 62  61 6e 6b 73 28 29 0a 7b  |t swap_banks().{|
00000110  0a 20 20 5f 6b 65 72 6e  65 6c 5f 73 77 69 5f 72  |.  _kernel_swi_r|
00000120  65 67 73 20 72 5f 69 6e  2c 20 72 5f 6f 75 74 3b  |egs r_in, r_out;|
00000130  0a 20 20 62 61 6e 6b 5f  6e 75 6d 20 3d 20 33 20  |.  bank_num = 3 |
00000140  2d 20 62 61 6e 6b 5f 6e  75 6d 3b 0a 20 20 72 5f  |- bank_num;.  r_|
00000150  69 6e 2e 72 5b 30 5d 20  3d 20 31 31 32 3b 0a 20  |in.r[0] = 112;. |
00000160  20 72 5f 69 6e 2e 72 5b  31 5d 20 3d 20 62 61 6e  | r_in.r[1] = ban|
00000170  6b 5f 6e 75 6d 3b 0a 20  20 5f 6b 65 72 6e 65 6c  |k_num;.  _kernel|
00000180  5f 73 77 69 28 36 2c 20  26 72 5f 69 6e 2c 20 26  |_swi(6, &r_in, &|
00000190  72 5f 6f 75 74 29 3b 0a  7d 0a 0a 69 6e 74 20 6d  |r_out);.}..int m|
000001a0  61 69 6e 28 76 6f 69 64  29 0a 7b 20 5f 6b 65 72  |ain(void).{ _ker|
000001b0  6e 65 6c 5f 73 77 69 5f  72 65 67 73 20 72 5f 69  |nel_swi_regs r_i|
000001c0  6e 2c 20 72 5f 6f 75 74  3b 0a 0a 2f 2a 20 73 65  |n, r_out;../* se|
000001d0  6c 65 63 74 20 73 63 72  65 65 6e 20 6d 6f 64 65  |lect screen mode|
000001e0  20 31 35 20 66 69 72 73  74 20 74 6f 20 65 6e 73  | 15 first to ens|
000001f0  75 72 65 20 32 78 38 30  6b 20 73 63 72 65 65 6e  |ure 2x80k screen|
00000200  73 20 2a 2f 0a 20 20 6f  73 5f 6d 6f 64 65 28 31  |s */.  os_mode(1|
00000210  35 29 3b 0a 20 20 6f 73  5f 6d 6f 64 65 28 31 33  |5);.  os_mode(13|
00000220  29 3b 0a 20 20 6f 73 5f  63 75 72 73 6f 72 28 30  |);.  os_cursor(0|
00000230  29 3b 0a 0a 20 20 72 5f  69 6e 2e 72 5b 30 5d 20  |);..  r_in.r[0] |
00000240  3d 20 32 3b 0a 20 20 5f  6b 65 72 6e 65 6c 5f 73  |= 2;.  _kernel_s|
00000250  77 69 28 4f 53 5f 52 65  61 64 44 79 6e 61 6d 69  |wi(OS_ReadDynami|
00000260  63 41 72 65 61 2c 20 26  72 5f 69 6e 2c 20 26 72  |cArea, &r_in, &r|
00000270  5f 6f 75 74 29 3b 0a 20  20 69 66 20 28 72 5f 6f  |_out);.  if (r_o|
00000280  75 74 2e 72 5b 31 5d 20  3c 20 28 31 36 30 2a 31  |ut.r[1] < (160*1|
00000290  30 32 34 29 29 0a 20 20  7b 20 70 72 69 6e 74 66  |024)).  { printf|
000002a0  28 22 59 6f 75 20 6e 65  65 64 20 61 74 20 6c 65  |("You need at le|
000002b0  61 73 74 20 31 36 30 6b  20 73 63 72 65 65 6e 20  |ast 160k screen |
000002c0  6d 65 6d 6f 72 79 2e 22  29 3b 0a 20 20 20 20 65  |memory.");.    e|
000002d0  78 69 74 28 45 58 49 54  5f 46 41 49 4c 55 52 45  |xit(EXIT_FAILURE|
000002e0  29 3b 0a 20 20 7d 0a 0a  2f 2a 20 73 6f 6d 65 20  |);.  }../* some |
000002f0  6c 6f 76 65 6c 79 20 76  61 72 69 61 62 6c 65 73  |lovely variables|
00000300  20 2a 2f 0a 20 20 69 6e  74 20 6e 75 6d 2c 20 6d  | */.  int num, m|
00000310  78 2c 20 6d 79 2c 20 73  78 2c 20 73 79 2c 20 78  |x, my, sx, sy, x|
00000320  70 6f 73 2c 20 6f 66 66  73 65 74 3b 0a 20 20 69  |pos, offset;.  i|
00000330  6e 74 20 6f 6c 64 61 6e  67 6c 65 2c 20 61 6e 67  |nt oldangle, ang|
00000340  6c 65 2c 20 61 3b 0a 0a  2f 2a 20 73 65 74 20 75  |le, a;../* set u|
00000350  70 20 61 6c 6c 20 74 68  61 74 20 6d 65 6d 6f 72  |p all that memor|
00000360  79 20 67 75 62 62 69 6e  73 20 2a 2f 0a 20 20 69  |y gubbins */.  i|
00000370  6e 74 20 2a 70 74 72 3b  0a 20 20 70 74 72 20 3d  |nt *ptr;.  ptr =|
00000380  20 6d 61 6c 6c 6f 63 28  32 35 36 29 3b 0a 0a 20  | malloc(256);.. |
00000390  20 63 68 61 72 20 2a 73  63 72 65 65 6e 5f 61 64  | char *screen_ad|
000003a0  64 72 65 73 73 3b 0a 20  20 63 68 61 72 20 2a 73  |dress;.  char *s|
000003b0  63 72 65 65 6e 5f 61 64  64 72 65 73 73 5f 62 61  |creen_address_ba|
000003c0  6e 6b 3b 0a 20 20 63 68  61 72 20 2a 73 63 72 65  |nk;.  char *scre|
000003d0  65 6e 5f 61 64 64 72 65  73 73 5f 74 65 6d 70 3b  |en_address_temp;|
000003e0  0a 0a 2f 2a 66 69 6e 64  20 6f 75 74 20 74 68 65  |../*find out the|
000003f0  20 6c 6f 63 61 74 69 6f  6e 20 6f 66 20 74 68 65  | location of the|
00000400  20 73 63 72 65 65 6e 20  6d 65 6d 6f 72 79 2a 2f  | screen memory*/|
00000410  0a 20 20 2a 28 70 74 72  29 20 3d 20 31 34 38 3b  |.  *(ptr) = 148;|
00000420  0a 20 20 2a 28 70 74 72  2b 31 29 20 3d 20 2d 31  |.  *(ptr+1) = -1|
00000430  3b 0a 20 20 72 5f 69 6e  2e 72 5b 30 5d 20 3d 20  |;.  r_in.r[0] = |
00000440  70 74 72 3b 0a 20 20 72  5f 69 6e 2e 72 5b 31 5d  |ptr;.  r_in.r[1]|
00000450  20 3d 20 70 74 72 3b 0a  20 20 5f 6b 65 72 6e 65  | = ptr;.  _kerne|
00000460  6c 5f 73 77 69 28 4f 53  5f 52 65 61 64 56 64 75  |l_swi(OS_ReadVdu|
00000470  56 61 72 69 61 62 6c 65  73 2c 20 26 72 5f 69 6e  |Variables, &r_in|
00000480  2c 20 26 72 5f 6f 75 74  29 3b 0a 20 20 69 6e 74  |, &r_out);.  int|
00000490  20 73 74 61 72 74 20 3d  20 2a 28 70 74 72 29 3b  | start = *(ptr);|
000004a0  0a 20 20 73 63 72 65 65  6e 5f 61 64 64 72 65 73  |.  screen_addres|
000004b0  73 3d 28 63 68 61 72 20  2a 29 73 74 61 72 74 3b  |s=(char *)start;|
000004c0  0a 0a 2f 2a 73 65 6c 65  63 74 20 74 68 65 20 73  |../*select the s|
000004d0  63 72 65 65 6e 20 62 61  6e 6b 2a 2f 0a 20 20 72  |creen bank*/.  r|
000004e0  5f 69 6e 2e 72 5b 30 5d  20 3d 20 31 31 32 3b 0a  |_in.r[0] = 112;.|
000004f0  20 20 72 5f 69 6e 2e 72  5b 31 5d 20 3d 20 33 2d  |  r_in.r[1] = 3-|
00000500  62 61 6e 6b 5f 6e 75 6d  3b 0a 20 20 5f 6b 65 72  |bank_num;.  _ker|
00000510  6e 65 6c 5f 73 77 69 28  36 2c 20 26 72 5f 69 6e  |nel_swi(6, &r_in|
00000520  2c 20 26 72 5f 6f 75 74  29 3b 0a 0a 2f 2a 66 69  |, &r_out);../*fi|
00000530  6e 64 20 6f 75 74 20 74  68 65 20 6c 6f 63 61 74  |nd out the locat|
00000540  69 6f 6e 20 6f 66 20 74  68 65 20 73 63 72 65 65  |ion of the scree|
00000550  6e 20 62 61 6e 6b 20 6d  65 6d 6f 72 79 2a 2f 0a  |n bank memory*/.|
00000560  20 20 2a 28 70 74 72 29  20 3d 20 31 34 38 3b 0a  |  *(ptr) = 148;.|
00000570  20 20 2a 28 70 74 72 2b  31 29 20 3d 20 2d 31 3b  |  *(ptr+1) = -1;|
00000580  0a 20 20 72 5f 69 6e 2e  72 5b 30 5d 20 3d 20 70  |.  r_in.r[0] = p|
00000590  74 72 3b 0a 20 20 72 5f  69 6e 2e 72 5b 31 5d 20  |tr;.  r_in.r[1] |
000005a0  3d 20 70 74 72 3b 0a 20  20 5f 6b 65 72 6e 65 6c  |= ptr;.  _kernel|
000005b0  5f 73 77 69 28 4f 53 5f  52 65 61 64 56 64 75 56  |_swi(OS_ReadVduV|
000005c0  61 72 69 61 62 6c 65 73  2c 20 26 72 5f 69 6e 2c  |ariables, &r_in,|
000005d0  20 26 72 5f 6f 75 74 29  3b 0a 20 20 73 74 61 72  | &r_out);.  star|
000005e0  74 20 3d 20 2a 28 70 74  72 29 3b 0a 20 20 73 63  |t = *(ptr);.  sc|
000005f0  72 65 65 6e 5f 61 64 64  72 65 73 73 5f 62 61 6e  |reen_address_ban|
00000600  6b 3d 28 63 68 61 72 20  2a 29 73 74 61 72 74 3b  |k=(char *)start;|
00000610  0a 0a 2f 2a 73 65 6c 65  63 74 20 74 68 65 20 66  |../*select the f|
00000620  69 72 73 74 20 62 61 6e  6b 2a 2f 0a 20 20 72 5f  |irst bank*/.  r_|
00000630  69 6e 2e 72 5b 30 5d 20  3d 20 31 31 32 3b 0a 20  |in.r[0] = 112;. |
00000640  20 72 5f 69 6e 2e 72 5b  31 5d 20 3d 20 62 61 6e  | r_in.r[1] = ban|
00000650  6b 5f 6e 75 6d 3b 0a 20  20 5f 6b 65 72 6e 65 6c  |k_num;.  _kernel|
00000660  5f 73 77 69 28 36 2c 20  26 72 5f 69 6e 2c 20 26  |_swi(6, &r_in, &|
00000670  72 5f 6f 75 74 29 3b 0a  0a 2f 2a 20 63 61 6c 63  |r_out);../* calc|
00000680  75 6c 61 74 65 20 63 6f  6c 6f 75 72 20 6c 6f 6f  |ulate colour loo|
00000690  6b 2d 75 70 20 74 61 62  6c 65 20 2a 2f 0a 0a 20  |k-up table */.. |
000006a0  20 69 6e 74 20 72 65 64  2c 20 67 72 65 65 6e 2c  | int red, green,|
000006b0  20 62 6c 75 65 2c 20 63  32 3b 0a 20 20 73 74 72  | blue, c2;.  str|
000006c0  75 63 74 20 63 6f 6c 6f  75 72 64 61 74 61 20 7b  |uct colourdata {|
000006d0  0a 20 20 20 69 6e 74 20  64 31 20 5b 32 35 36 5d  |.   int d1 [256]|
000006e0  3b 0a 20 20 20 69 6e 74  20 64 32 20 5b 32 35 36  |;.   int d2 [256|
000006f0  5d 3b 0a 20 20 7d 3b 0a  0a 20 20 73 74 72 75 63  |];.  };..  struc|
00000700  74 20 63 6f 6c 6f 75 72  64 61 74 61 20 63 6f 6c  |t colourdata col|
00000710  6f 75 72 3b 0a 20 20 66  6c 6f 61 74 20 66 72 61  |our;.  float fra|
00000720  63 74 69 6f 6e 3b 0a 0a  20 20 66 6f 72 20 28 66  |ction;..  for (f|
00000730  6c 6f 61 74 20 63 3d 30  3b 20 63 3c 32 35 36 3b  |loat c=0; c<256;|
00000740  20 63 2b 3d 31 29 0a 20  20 7b 0a 0a 2f 2a 20 75  | c+=1).  {../* u|
00000750  73 65 20 74 68 65 20 65  76 65 72 2d 70 6f 70 75  |se the ever-popu|
00000760  6c 61 72 20 43 6f 6c 6f  75 72 54 72 61 6e 73 5f  |lar ColourTrans_|
00000770  43 6f 6e 76 65 72 74 48  53 56 54 6f 52 47 42 0a  |ConvertHSVToRGB.|
00000780  20 20 20 74 6f 20 63 68  6f 6f 73 65 20 74 68 65  |   to choose the|
00000790  20 63 6f 6c 6f 75 72 73  20 2a 2f 0a 0a 20 20 66  | colours */..  f|
000007a0  72 61 63 74 69 6f 6e 20  3d 20 63 2a 31 2e 34 30  |raction = c*1.40|
000007b0  36 32 35 2a 36 35 35 33  36 3b 0a 20 20 72 5f 69  |625*65536;.  r_i|
000007c0  6e 2e 72 5b 30 5d 20 3d  20 66 72 61 63 74 69 6f  |n.r[0] = fractio|
000007d0  6e 3b 0a 20 20 72 5f 69  6e 2e 72 5b 31 5d 20 3d  |n;.  r_in.r[1] =|
000007e0  20 36 35 30 30 30 3b 0a  20 20 72 5f 69 6e 2e 72  | 65000;.  r_in.r|
000007f0  5b 32 5d 20 3d 20 32 35  35 3b 0a 20 20 5f 6b 65  |[2] = 255;.  _ke|
00000800  72 6e 65 6c 5f 73 77 69  28 43 6f 6c 6f 75 72 54  |rnel_swi(ColourT|
00000810  72 61 6e 73 5f 43 6f 6e  76 65 72 74 48 53 56 54  |rans_ConvertHSVT|
00000820  6f 52 47 42 2c 20 26 72  5f 69 6e 2c 20 26 72 5f  |oRGB, &r_in, &r_|
00000830  6f 75 74 29 3b 0a 20 20  72 65 64 20 3d 20 72 5f  |out);.  red = r_|
00000840  6f 75 74 2e 72 5b 30 5d  3b 0a 20 20 67 72 65 65  |out.r[0];.  gree|
00000850  6e 20 3d 20 72 5f 6f 75  74 2e 72 5b 31 5d 3b 0a  |n = r_out.r[1];.|
00000860  20 20 62 6c 75 65 20 3d  20 72 5f 6f 75 74 2e 72  |  blue = r_out.r|
00000870  5b 32 5d 3b 0a 0a 2f 2a  20 61 20 62 69 74 20 6f  |[2];../* a bit o|
00000880  66 20 61 20 63 68 65 61  74 20 74 6f 20 73 65 6c  |f a cheat to sel|
00000890  65 63 74 20 74 68 65 20  63 6f 6c 6f 75 72 0a 20  |ect the colour. |
000008a0  20 20 62 75 74 20 6e 65  76 65 72 20 6d 69 6e 64  |  but never mind|
000008b0  2c 20 69 74 20 77 6f 72  6b 73 2c 20 61 6e 64 20  |, it works, and |
000008c0  74 68 61 74 27 73 20 74  68 65 20 6d 61 69 6e 20  |that's the main |
000008d0  74 68 69 6e 67 2e 2e 2e  20 2a 2f 0a 20 20 72 5f  |thing... */.  r_|
000008e0  69 6e 2e 72 5b 30 5d 20  3d 20 28 72 65 64 3c 3c  |in.r[0] = (red<<|
000008f0  38 29 20 2b 20 28 67 72  65 65 6e 3c 3c 31 36 29  |8) + (green<<16)|
00000900  20 2b 20 28 62 6c 75 65  3c 3c 32 34 29 3b 0a 20  | + (blue<<24);. |
00000910  20 72 5f 69 6e 2e 72 5b  33 5d 20 3d 20 32 35 36  | r_in.r[3] = 256|
00000920  3b 0a 20 20 72 5f 69 6e  2e 72 5b 34 5d 20 3d 20  |;.  r_in.r[4] = |
00000930  30 3b 0a 20 20 5f 6b 65  72 6e 65 6c 5f 73 77 69  |0;.  _kernel_swi|
00000940  28 43 6f 6c 6f 75 72 54  72 61 6e 73 5f 53 65 74  |(ColourTrans_Set|
00000950  47 43 4f 4c 2c 20 26 72  5f 69 6e 2c 20 26 72 5f  |GCOL, &r_in, &r_|
00000960  6f 75 74 29 3b 0a 0a 20  20 6f 73 5f 63 69 72 63  |out);..  os_circ|
00000970  6c 65 66 69 6c 6c 28 30  2c 31 30 32 33 2c 33 32  |lefill(0,1023,32|
00000980  29 3b 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |);              |
00000990  20 20 20 20 20 2f 2a 20  68 65 6c 6c 6f 20 6d 72  |     /* hello mr|
000009a0  2e 20 62 6f 64 67 65 2e  2e 2e 20 2a 2f 0a 20 20  |. bodge... */.  |
000009b0  63 32 20 3d 20 28 66 6c  6f 61 74 29 20 63 3b 0a  |c2 = (float) c;.|
000009c0  20 20 63 6f 6c 6f 75 72  2e 64 31 5b 63 32 5d 20  |  colour.d1[c2] |
000009d0  3d 20 2a 28 73 63 72 65  65 6e 5f 61 64 64 72 65  |= *(screen_addre|
000009e0  73 73 20 2b 20 33 32 31  29 3b 20 20 20 20 2f 2a  |ss + 321);    /*|
000009f0  20 73 65 6c 65 63 74 73  20 32 20 63 6f 6c 6f 75  | selects 2 colou|
00000a00  72 73 20 2a 2f 0a 20 20  63 6f 6c 6f 75 72 2e 64  |rs */.  colour.d|
00000a10  32 5b 63 32 5d 20 3d 20  2a 28 73 63 72 65 65 6e  |2[c2] = *(screen|
00000a20  5f 61 64 64 72 65 73 73  20 2b 20 33 32 32 29 3b  |_address + 322);|
00000a30  20 20 20 20 2f 2a 20 73  6f 20 77 65 20 63 61 6e  |    /* so we can|
00000a40  20 64 6f 20 64 69 74 68  65 72 69 6e 67 20 2a 2f  | do dithering */|
00000a50  0a 20 20 7d 0a 0a 2f 2a  20 71 75 69 63 6b 20 6d  |.  }../* quick m|
00000a60  72 20 62 6f 64 67 65 21  20 72 65 6d 6f 76 65 20  |r bodge! remove |
00000a70  79 6f 75 72 20 65 76 69  64 65 6e 63 65 21 20 2a  |your evidence! *|
00000a80  2f 0a 20 20 6f 73 5f 63  6c 73 28 29 3b 0a 0a 20  |/.  os_cls();.. |
00000a90  20 6f 73 5f 67 63 6f 6c  28 30 2c 36 33 29 3b 0a  | os_gcol(0,63);.|
00000aa0  20 20 6f 73 5f 74 69 6e  74 28 32 2c 20 33 29 3b  |  os_tint(2, 3);|
00000ab0  0a 0a 2f 2a 20 6b 65 65  70 20 6f 6e 20 67 6f 69  |../* keep on goi|
00000ac0  6e 67 20 27 74 69 6c 6c  20 77 65 20 68 69 74 20  |ng 'till we hit |
00000ad0  45 73 63 61 70 65 20 2a  2f 0a 20 20 77 68 69 6c  |Escape */.  whil|
00000ae0  65 20 28 21 6f 73 5f 69  6e 6b 65 79 28 2d 31 31  |e (!os_inkey(-11|
00000af0  33 29 29 0a 20 20 7b 0a  0a 2f 2a 20 63 68 61 6e  |3)).  {../* chan|
00000b00  67 65 20 74 68 65 20 6f  66 66 73 65 74 20 65 76  |ge the offset ev|
00000b10  65 72 79 20 6c 6f 6f 70  20 74 6f 20 61 64 64 20  |ery loop to add |
00000b20  74 6f 0a 20 20 20 74 68  65 20 63 6f 6c 6f 75 72  |to.   the colour|
00000b30  20 63 79 63 6c 69 6e 67  20 65 66 66 65 63 74 20  | cycling effect |
00000b40  74 79 70 65 20 74 68 69  6e 67 20 2a 2f 0a 20 20  |type thing */.  |
00000b50  6f 66 66 73 65 74 2b 3d  31 3b 0a 20 20 69 66 20  |offset+=1;.  if |
00000b60  28 6f 66 66 73 65 74 3e  32 35 35 29 0a 20 20 20  |(offset>255).   |
00000b70  6f 66 66 73 65 74 3d 30  3b 0a 0a 20 20 78 70 6f  |offset=0;..  xpo|
00000b80  73 20 3d 20 30 3b 0a 0a  20 20 66 6f 72 20 28 69  |s = 0;..  for (i|
00000b90  6e 74 20 69 3d 28 36 34  30 29 3b 20 69 3c 28 33  |nt i=(640); i<(3|
00000ba0  32 30 2a 32 35 32 29 3b  20 69 2b 3d 32 29 0a 20  |20*252); i+=2). |
00000bb0  20 7b 0a 20 20 78 70 6f  73 2b 3d 32 3b 0a 20 20  | {.  xpos+=2;.  |
00000bc0  0a 20 20 69 66 20 28 78  70 6f 73 3d 3d 33 32 30  |.  if (xpos==320|
00000bd0  29 0a 20 20 20 20 7b 20  78 70 6f 73 20 3d 20 30  |).    { xpos = 0|
00000be0  3b 0a 20 20 20 20 20 20  69 2b 3d 33 32 30 3b 0a  |;.      i+=320;.|
00000bf0  20 20 20 20 7d 0a 0a 20  20 2f 2a 20 72 65 61 64  |    }..  /* read|
00000c00  20 73 63 72 65 65 6e 20  6d 65 6d 6f 72 79 20 61  | screen memory a|
00000c10  6e 64 20 73 6d 6f 6f 74  68 20 69 74 20 61 6c 6c  |nd smooth it all|
00000c20  20 6f 75 74 2e 2e 2e 20  2a 2f 0a 20 20 6e 75 6d  | out... */.  num|
00000c30  20 3d 28 0a 20 20 20 20  20 20 20 20 20 2a 28 73  | =(.         *(s|
00000c40  63 72 65 65 6e 5f 61 64  64 72 65 73 73 5f 62 61  |creen_address_ba|
00000c50  6e 6b 20 2b 20 69 20 2d  20 32 29 0a 20 20 20 20  |nk + i - 2).    |
00000c60  20 20 20 2b 20 2a 28 73  63 72 65 65 6e 5f 61 64  |   + *(screen_ad|
00000c70  64 72 65 73 73 5f 62 61  6e 6b 20 2b 20 69 20 2b  |dress_bank + i +|
00000c80  20 32 29 0a 20 20 20 20  20 20 20 2b 20 2a 28 73  | 2).       + *(s|
00000c90  63 72 65 65 6e 5f 61 64  64 72 65 73 73 5f 62 61  |creen_address_ba|
00000ca0  6e 6b 20 2b 20 69 20 2b  20 36 34 30 29 0a 20 20  |nk + i + 640).  |
00000cb0  20 20 20 20 20 2b 20 2a  28 73 63 72 65 65 6e 5f  |     + *(screen_|
00000cc0  61 64 64 72 65 73 73 5f  62 61 6e 6b 20 2b 20 69  |address_bank + i|
00000cd0  20 2d 20 36 34 30 29 0a  20 20 20 20 20 20 20 29  | - 640).       )|
00000ce0  20 3e 3e 20 32 3b 0a 0a  20 20 2f 2a 20 72 65 2d  | >> 2;..  /* re-|
00000cf0  77 72 69 74 65 20 69 74  20 61 67 61 69 6e 20 2a  |write it again *|
00000d00  2f 0a 20 20 2a 28 73 63  72 65 65 6e 5f 61 64 64  |/.  *(screen_add|
00000d10  72 65 73 73 5f 62 61 6e  6b 20 2b 20 69 29 20 3d  |ress_bank + i) =|
00000d20  20 6e 75 6d 3b 0a 0a 20  20 2f 2a 20 6f 66 66 73  | num;..  /* offs|
00000d30  65 74 20 69 74 20 62 79  20 74 68 65 20 63 6f 6c  |et it by the col|
00000d40  6f 75 72 20 73 68 69 66  74 20 6f 66 66 73 65 74  |our shift offset|
00000d50  20 65 66 66 6f 72 74 20  67 75 62 62 69 6e 73 20  | effort gubbins |
00000d60  2a 2f 0a 20 20 6e 75 6d  2b 3d 6f 66 66 73 65 74  |*/.  num+=offset|
00000d70  3b 0a 20 20 69 66 20 28  6e 75 6d 3e 32 35 35 29  |;.  if (num>255)|
00000d80  0a 20 20 20 20 6e 75 6d  2d 3d 32 35 35 3b 0a 20  |.    num-=255;. |
00000d90  20 69 66 20 28 6e 75 6d  3c 30 29 0a 20 20 20 20  | if (num<0).    |
00000da0  6e 75 6d 2b 3d 32 35 35  3b 0a 0a 20 20 2f 2a 20  |num+=255;..  /* |
00000db0  70 6c 6f 74 20 34 20 70  69 78 65 6c 73 20 6f 6e  |plot 4 pixels on|
00000dc0  20 73 63 72 65 65 6e 20  77 69 74 68 20 64 69 74  | screen with dit|
00000dd0  68 65 72 69 6e 67 20 28  64 31 20 61 6e 64 20 64  |hering (d1 and d|
00000de0  32 29 20 2a 2f 0a 20 20  2a 28 73 63 72 65 65 6e  |2) */.  *(screen|
00000df0  5f 61 64 64 72 65 73 73  20 2b 20 69 29 20 3d 20  |_address + i) = |
00000e00  63 6f 6c 6f 75 72 2e 64  31 5b 6e 75 6d 5d 3b 0a  |colour.d1[num];.|
00000e10  20 20 2a 28 73 63 72 65  65 6e 5f 61 64 64 72 65  |  *(screen_addre|
00000e20  73 73 20 2b 20 69 20 2b  20 31 29 20 3d 20 63 6f  |ss + i + 1) = co|
00000e30  6c 6f 75 72 2e 64 32 5b  6e 75 6d 5d 3b 0a 20 20  |lour.d2[num];.  |
00000e40  2a 28 73 63 72 65 65 6e  5f 61 64 64 72 65 73 73  |*(screen_address|
00000e50  20 2b 20 69 20 2b 33 32  30 29 20 3d 20 63 6f 6c  | + i +320) = col|
00000e60  6f 75 72 2e 64 32 5b 6e  75 6d 5d 3b 0a 20 20 2a  |our.d2[num];.  *|
00000e70  28 73 63 72 65 65 6e 5f  61 64 64 72 65 73 73 20  |(screen_address |
00000e80  2b 20 69 20 2b 20 33 32  31 29 20 3d 20 63 6f 6c  |+ i + 321) = col|
00000e90  6f 75 72 2e 64 31 5b 6e  75 6d 5d 3b 0a 20 20 7d  |our.d1[num];.  }|
00000ea0  0a 0a 20 20 2f 2a 20 77  61 69 74 20 66 6f 72 20  |..  /* wait for |
00000eb0  74 68 61 74 20 74 68 65  72 65 20 76 2d 73 79 6e  |that there v-syn|
00000ec0  63 20 2a 2f 0a 20 20 6f  73 5f 63 6c 69 28 22 66  |c */.  os_cli("f|
00000ed0  78 31 39 22 29 3b 0a 0a  20 20 2f 2a 20 6d 6f 75  |x19");..  /* mou|
00000ee0  73 65 74 72 61 70 21 20  2a 2f 0a 20 20 5f 6b 65  |setrap! */.  _ke|
00000ef0  72 6e 65 6c 5f 73 77 69  28 4f 53 5f 4d 6f 75 73  |rnel_swi(OS_Mous|
00000f00  65 2c 20 26 72 5f 69 6e  2c 20 26 72 5f 6f 75 74  |e, &r_in, &r_out|
00000f10  29 3b 0a 0a 20 20 2f 2a  20 70 6c 6f 74 20 74 68  |);..  /* plot th|
00000f20  65 20 6d 6f 75 73 65 20  27 70 6f 69 6e 74 65 72  |e mouse 'pointer|
00000f30  27 20 6f 6e 74 6f 20 74  68 65 20 73 63 72 65 65  |' onto the scree|
00000f40  6e 20 62 61 6e 6b 20 2a  2f 0a 20 20 73 77 61 70  |n bank */.  swap|
00000f50  5f 62 61 6e 6b 73 28 29  3b 0a 20 20 6f 73 5f 63  |_banks();.  os_c|
00000f60  69 72 63 6c 65 66 69 6c  6c 28 72 5f 6f 75 74 2e  |irclefill(r_out.|
00000f70  72 5b 30 5d 2c 20 72 5f  6f 75 74 2e 72 5b 31 5d  |r[0], r_out.r[1]|
00000f80  2c 20 28 72 5f 6f 75 74  2e 72 5b 32 5d 2b 32 29  |, (r_out.r[2]+2)|
00000f90  2a 38 20 29 3b 0a 20 20  73 77 61 70 5f 62 61 6e  |*8 );.  swap_ban|
00000fa0  6b 73 28 29 3b 0a 0a 20  20 2f 2a 20 72 6f 75 6e  |ks();..  /* roun|
00000fb0  64 20 61 6e 64 20 72 6f  75 6e 64 20 77 65 20 67  |d and round we g|
00000fc0  6f 2e 2e 2e 20 2a 2f 0a  20 20 7d 0a 0a 2f 2a 20  |o... */.  }../* |
00000fd0  74 68 61 74 27 73 20 61  6c 6c 20 66 6f 6c 6b 73  |that's all folks|
00000fe0  20 2a 2f 0a 7d 0a 0a                              | */.}..|
00000fe7