Home » Recent acquisitions » Acorn ADFS disks » adfs_AcornUser_199610.adf » Regulars » StarInfo/Wood/Smudge/!Help

StarInfo/Wood/Smudge/!Help

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 » Recent acquisitions » Acorn ADFS disks » adfs_AcornUser_199610.adf » Regulars
Filename: StarInfo/Wood/Smudge/!Help
Read OK:
File size: 0605 bytes
Load address: 0000
Exec address: 0000
File contents
!Help

!Smudge was written by Keith Wood. It demonstrates the use of full screen pixel softening in a 16 colour mode. This program should work in any 16 colour mode.

    Controls
    --------

 Mouse controls position of brush

 Mouse buttons: Left   - Paint with brush
                Middle - Change brush
                Right  - Pause


    About this program
    ------------------

 The idea behind pixel softening in a 16 colour mode is that, unlike 256 colour mode, there are no RGB components to separate. Instead the colours are set up so that white is colour 15 and black is 0, and all the colours in-between follow a uniform grey scale. Softening is then a simple matter of taking a weighted average of a 3x3 grid of pixels and storing the result in the middle pixel.
 The pixels are weighted are as follows:

 -------------
 | 1 | 2 | 1 |
 -------------
 | 2 | 4 | 2 |
 -------------
 | 1 | 2 | 1 |
 -------------

 To get this weighting, a horizontal softening routine is applied to the screen, and written back to memory, before applying a vertical routine.
 
 The real problem is realising that a word of eight pixels is stored back to front with interleaving?!! So some approximations were made to ignore the interleaving, and use the fact that many pixels can be operated on simultaneously to speed up the code - not as simple as it sounds. However, most computers will not exhibit any lasting side effects after executing the code, and neither will the code exhibit any lasting side effects after executing the computer.
00000000  21 48 65 6c 70 0a 0a 21  53 6d 75 64 67 65 20 77  |!Help..!Smudge w|
00000010  61 73 20 77 72 69 74 74  65 6e 20 62 79 20 4b 65  |as written by Ke|
00000020  69 74 68 20 57 6f 6f 64  2e 20 49 74 20 64 65 6d  |ith Wood. It dem|
00000030  6f 6e 73 74 72 61 74 65  73 20 74 68 65 20 75 73  |onstrates the us|
00000040  65 20 6f 66 20 66 75 6c  6c 20 73 63 72 65 65 6e  |e of full screen|
00000050  20 70 69 78 65 6c 20 73  6f 66 74 65 6e 69 6e 67  | pixel softening|
00000060  20 69 6e 20 61 20 31 36  20 63 6f 6c 6f 75 72 20  | in a 16 colour |
00000070  6d 6f 64 65 2e 20 54 68  69 73 20 70 72 6f 67 72  |mode. This progr|
00000080  61 6d 20 73 68 6f 75 6c  64 20 77 6f 72 6b 20 69  |am should work i|
00000090  6e 20 61 6e 79 20 31 36  20 63 6f 6c 6f 75 72 20  |n any 16 colour |
000000a0  6d 6f 64 65 2e 0a 0a 20  20 20 20 43 6f 6e 74 72  |mode...    Contr|
000000b0  6f 6c 73 0a 20 20 20 20  2d 2d 2d 2d 2d 2d 2d 2d  |ols.    --------|
000000c0  0a 0a 20 4d 6f 75 73 65  20 63 6f 6e 74 72 6f 6c  |.. Mouse control|
000000d0  73 20 70 6f 73 69 74 69  6f 6e 20 6f 66 20 62 72  |s position of br|
000000e0  75 73 68 0a 0a 20 4d 6f  75 73 65 20 62 75 74 74  |ush.. Mouse butt|
000000f0  6f 6e 73 3a 20 4c 65 66  74 20 20 20 2d 20 50 61  |ons: Left   - Pa|
00000100  69 6e 74 20 77 69 74 68  20 62 72 75 73 68 0a 20  |int with brush. |
00000110  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 4d  |               M|
00000120  69 64 64 6c 65 20 2d 20  43 68 61 6e 67 65 20 62  |iddle - Change b|
00000130  72 75 73 68 0a 20 20 20  20 20 20 20 20 20 20 20  |rush.           |
00000140  20 20 20 20 20 52 69 67  68 74 20 20 2d 20 50 61  |     Right  - Pa|
00000150  75 73 65 0a 0a 0a 20 20  20 20 41 62 6f 75 74 20  |use...    About |
00000160  74 68 69 73 20 70 72 6f  67 72 61 6d 0a 20 20 20  |this program.   |
00000170  20 2d 2d 2d 2d 2d 2d 2d  2d 2d 2d 2d 2d 2d 2d 2d  | ---------------|
00000180  2d 2d 2d 0a 0a 20 54 68  65 20 69 64 65 61 20 62  |---.. The idea b|
00000190  65 68 69 6e 64 20 70 69  78 65 6c 20 73 6f 66 74  |ehind pixel soft|
000001a0  65 6e 69 6e 67 20 69 6e  20 61 20 31 36 20 63 6f  |ening in a 16 co|
000001b0  6c 6f 75 72 20 6d 6f 64  65 20 69 73 20 74 68 61  |lour mode is tha|
000001c0  74 2c 20 75 6e 6c 69 6b  65 20 32 35 36 20 63 6f  |t, unlike 256 co|
000001d0  6c 6f 75 72 20 6d 6f 64  65 2c 20 74 68 65 72 65  |lour mode, there|
000001e0  20 61 72 65 20 6e 6f 20  52 47 42 20 63 6f 6d 70  | are no RGB comp|
000001f0  6f 6e 65 6e 74 73 20 74  6f 20 73 65 70 61 72 61  |onents to separa|
00000200  74 65 2e 20 49 6e 73 74  65 61 64 20 74 68 65 20  |te. Instead the |
00000210  63 6f 6c 6f 75 72 73 20  61 72 65 20 73 65 74 20  |colours are set |
00000220  75 70 20 73 6f 20 74 68  61 74 20 77 68 69 74 65  |up so that white|
00000230  20 69 73 20 63 6f 6c 6f  75 72 20 31 35 20 61 6e  | is colour 15 an|
00000240  64 20 62 6c 61 63 6b 20  69 73 20 30 2c 20 61 6e  |d black is 0, an|
00000250  64 20 61 6c 6c 20 74 68  65 20 63 6f 6c 6f 75 72  |d all the colour|
00000260  73 20 69 6e 2d 62 65 74  77 65 65 6e 20 66 6f 6c  |s in-between fol|
00000270  6c 6f 77 20 61 20 75 6e  69 66 6f 72 6d 20 67 72  |low a uniform gr|
00000280  65 79 20 73 63 61 6c 65  2e 20 53 6f 66 74 65 6e  |ey scale. Soften|
00000290  69 6e 67 20 69 73 20 74  68 65 6e 20 61 20 73 69  |ing is then a si|
000002a0  6d 70 6c 65 20 6d 61 74  74 65 72 20 6f 66 20 74  |mple matter of t|
000002b0  61 6b 69 6e 67 20 61 20  77 65 69 67 68 74 65 64  |aking a weighted|
000002c0  20 61 76 65 72 61 67 65  20 6f 66 20 61 20 33 78  | average of a 3x|
000002d0  33 20 67 72 69 64 20 6f  66 20 70 69 78 65 6c 73  |3 grid of pixels|
000002e0  20 61 6e 64 20 73 74 6f  72 69 6e 67 20 74 68 65  | and storing the|
000002f0  20 72 65 73 75 6c 74 20  69 6e 20 74 68 65 20 6d  | result in the m|
00000300  69 64 64 6c 65 20 70 69  78 65 6c 2e 0a 20 54 68  |iddle pixel.. Th|
00000310  65 20 70 69 78 65 6c 73  20 61 72 65 20 77 65 69  |e pixels are wei|
00000320  67 68 74 65 64 20 61 72  65 20 61 73 20 66 6f 6c  |ghted are as fol|
00000330  6c 6f 77 73 3a 0a 0a 20  2d 2d 2d 2d 2d 2d 2d 2d  |lows:.. --------|
00000340  2d 2d 2d 2d 2d 0a 20 7c  20 31 20 7c 20 32 20 7c  |-----. | 1 | 2 ||
00000350  20 31 20 7c 0a 20 2d 2d  2d 2d 2d 2d 2d 2d 2d 2d  | 1 |. ----------|
00000360  2d 2d 2d 0a 20 7c 20 32  20 7c 20 34 20 7c 20 32  |---. | 2 | 4 | 2|
00000370  20 7c 0a 20 2d 2d 2d 2d  2d 2d 2d 2d 2d 2d 2d 2d  | |. ------------|
00000380  2d 0a 20 7c 20 31 20 7c  20 32 20 7c 20 31 20 7c  |-. | 1 | 2 | 1 ||
00000390  0a 20 2d 2d 2d 2d 2d 2d  2d 2d 2d 2d 2d 2d 2d 0a  |. -------------.|
000003a0  0a 20 54 6f 20 67 65 74  20 74 68 69 73 20 77 65  |. To get this we|
000003b0  69 67 68 74 69 6e 67 2c  20 61 20 68 6f 72 69 7a  |ighting, a horiz|
000003c0  6f 6e 74 61 6c 20 73 6f  66 74 65 6e 69 6e 67 20  |ontal softening |
000003d0  72 6f 75 74 69 6e 65 20  69 73 20 61 70 70 6c 69  |routine is appli|
000003e0  65 64 20 74 6f 20 74 68  65 20 73 63 72 65 65 6e  |ed to the screen|
000003f0  2c 20 61 6e 64 20 77 72  69 74 74 65 6e 20 62 61  |, and written ba|
00000400  63 6b 20 74 6f 20 6d 65  6d 6f 72 79 2c 20 62 65  |ck to memory, be|
00000410  66 6f 72 65 20 61 70 70  6c 79 69 6e 67 20 61 20  |fore applying a |
00000420  76 65 72 74 69 63 61 6c  20 72 6f 75 74 69 6e 65  |vertical routine|
00000430  2e 0a 20 0a 20 54 68 65  20 72 65 61 6c 20 70 72  |.. . The real pr|
00000440  6f 62 6c 65 6d 20 69 73  20 72 65 61 6c 69 73 69  |oblem is realisi|
00000450  6e 67 20 74 68 61 74 20  61 20 77 6f 72 64 20 6f  |ng that a word o|
00000460  66 20 65 69 67 68 74 20  70 69 78 65 6c 73 20 69  |f eight pixels i|
00000470  73 20 73 74 6f 72 65 64  20 62 61 63 6b 20 74 6f  |s stored back to|
00000480  20 66 72 6f 6e 74 20 77  69 74 68 20 69 6e 74 65  | front with inte|
00000490  72 6c 65 61 76 69 6e 67  3f 21 21 20 53 6f 20 73  |rleaving?!! So s|
000004a0  6f 6d 65 20 61 70 70 72  6f 78 69 6d 61 74 69 6f  |ome approximatio|
000004b0  6e 73 20 77 65 72 65 20  6d 61 64 65 20 74 6f 20  |ns were made to |
000004c0  69 67 6e 6f 72 65 20 74  68 65 20 69 6e 74 65 72  |ignore the inter|
000004d0  6c 65 61 76 69 6e 67 2c  20 61 6e 64 20 75 73 65  |leaving, and use|
000004e0  20 74 68 65 20 66 61 63  74 20 74 68 61 74 20 6d  | the fact that m|
000004f0  61 6e 79 20 70 69 78 65  6c 73 20 63 61 6e 20 62  |any pixels can b|
00000500  65 20 6f 70 65 72 61 74  65 64 20 6f 6e 20 73 69  |e operated on si|
00000510  6d 75 6c 74 61 6e 65 6f  75 73 6c 79 20 74 6f 20  |multaneously to |
00000520  73 70 65 65 64 20 75 70  20 74 68 65 20 63 6f 64  |speed up the cod|
00000530  65 20 2d 20 6e 6f 74 20  61 73 20 73 69 6d 70 6c  |e - not as simpl|
00000540  65 20 61 73 20 69 74 20  73 6f 75 6e 64 73 2e 20  |e as it sounds. |
00000550  48 6f 77 65 76 65 72 2c  20 6d 6f 73 74 20 63 6f  |However, most co|
00000560  6d 70 75 74 65 72 73 20  77 69 6c 6c 20 6e 6f 74  |mputers will not|
00000570  20 65 78 68 69 62 69 74  20 61 6e 79 20 6c 61 73  | exhibit any las|
00000580  74 69 6e 67 20 73 69 64  65 20 65 66 66 65 63 74  |ting side effect|
00000590  73 20 61 66 74 65 72 20  65 78 65 63 75 74 69 6e  |s after executin|
000005a0  67 20 74 68 65 20 63 6f  64 65 2c 20 61 6e 64 20  |g the code, and |
000005b0  6e 65 69 74 68 65 72 20  77 69 6c 6c 20 74 68 65  |neither will the|
000005c0  20 63 6f 64 65 20 65 78  68 69 62 69 74 20 61 6e  | code exhibit an|
000005d0  79 20 6c 61 73 74 69 6e  67 20 73 69 64 65 20 65  |y lasting side e|
000005e0  66 66 65 63 74 73 20 61  66 74 65 72 20 65 78 65  |ffects after exe|
000005f0  63 75 74 69 6e 67 20 74  68 65 20 63 6f 6d 70 75  |cuting the compu|
00000600  74 65 72 2e 0a                                    |ter..|
00000605