Home » Archimedes archive » Acorn User » AU 1995-11.adf » !Regulars » Regulars/StarInfo/Ord/!OrdFSI/Pal-332

Regulars/StarInfo/Ord/!OrdFSI/Pal-332

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 1995-11.adf » !Regulars
Filename: Regulars/StarInfo/Ord/!OrdFSI/Pal-332
Read OK:
File size: 026B bytes
Load address: 0000
Exec address: 0000
File contents
   10REM Create Palette Lookup Table
   20REM By Andrew Ord
   30
   40file$="Palettes.R3G3B2"
   50
   60REM Memory required to store palette and lookup table
   70DIM pal% 1024+32768
   80
   90REM routine to make 3bits red, 3bits green, 2bits blue
   91p%=pal%
  100FOR r%=0 TO 7
  110 FOR g%=0 TO 7
  111  FOR b%=0 TO 3
  112   R%=r%*255/7
  113   G%=g%*255/7
  114   B%=b%*255/3
  115   !p%=(B%<<24) + (G%<<16) + (R%<<8)
  116   p%+=4
  117  NEXT
  118 NEXT
  119NEXT
  160
  170REM Create the lookup table
  180SYS"Hourglass_On"
  190SYS"IPC_CreateTables",pal%,pal%+1024,256
  200SYS"Hourglass_Smash"
  210
  220REM Save the definition to disk
  230SYS"OS_File",10,file$,&00F,,pal%,pal%+(1024+32768)
  240END

!� Create Palette Lookup Table
� By Andrew Ord

(file$="Palettes.R3G3B2"
2
<7� Memory required to store palette and lookup table
F� pal% 1024+32768
P
Z8� routine to make 3bits red, 3bits green, 2bits blue
[p%=pal%
d� r%=0 � 7
n � g%=0 � 7
o  � b%=0 � 3
p   R%=r%*255/7
q   G%=g%*255/7
r   B%=b%*255/3
s(   !p%=(B%<<24) + (G%<<16) + (R%<<8)
t   p%+=4
u  �
v �
w�
�
�� Create the lookup table
�ș"Hourglass_On"
�+ș"IPC_CreateTables",pal%,pal%+1024,256
�ș"Hourglass_Smash"
�
�!� Save the definition to disk
�5ș"OS_File",10,file$,&00F,,pal%,pal%+(1024+32768)
��
�
00000000  0d 00 0a 21 f4 20 43 72  65 61 74 65 20 50 61 6c  |...!. Create Pal|
00000010  65 74 74 65 20 4c 6f 6f  6b 75 70 20 54 61 62 6c  |ette Lookup Tabl|
00000020  65 0d 00 14 13 f4 20 42  79 20 41 6e 64 72 65 77  |e..... By Andrew|
00000030  20 4f 72 64 0d 00 1e 04  0d 00 28 1b 66 69 6c 65  | Ord......(.file|
00000040  24 3d 22 50 61 6c 65 74  74 65 73 2e 52 33 47 33  |$="Palettes.R3G3|
00000050  42 32 22 0d 00 32 04 0d  00 3c 37 f4 20 4d 65 6d  |B2"..2...<7. Mem|
00000060  6f 72 79 20 72 65 71 75  69 72 65 64 20 74 6f 20  |ory required to |
00000070  73 74 6f 72 65 20 70 61  6c 65 74 74 65 20 61 6e  |store palette an|
00000080  64 20 6c 6f 6f 6b 75 70  20 74 61 62 6c 65 0d 00  |d lookup table..|
00000090  46 15 de 20 70 61 6c 25  20 31 30 32 34 2b 33 32  |F.. pal% 1024+32|
000000a0  37 36 38 0d 00 50 04 0d  00 5a 38 f4 20 72 6f 75  |768..P...Z8. rou|
000000b0  74 69 6e 65 20 74 6f 20  6d 61 6b 65 20 33 62 69  |tine to make 3bi|
000000c0  74 73 20 72 65 64 2c 20  33 62 69 74 73 20 67 72  |ts red, 3bits gr|
000000d0  65 65 6e 2c 20 32 62 69  74 73 20 62 6c 75 65 0d  |een, 2bits blue.|
000000e0  00 5b 0b 70 25 3d 70 61  6c 25 0d 00 64 0e e3 20  |.[.p%=pal%..d.. |
000000f0  72 25 3d 30 20 b8 20 37  0d 00 6e 0f 20 e3 20 67  |r%=0 . 7..n. . g|
00000100  25 3d 30 20 b8 20 37 0d  00 6f 10 20 20 e3 20 62  |%=0 . 7..o.  . b|
00000110  25 3d 30 20 b8 20 33 0d  00 70 12 20 20 20 52 25  |%=0 . 3..p.   R%|
00000120  3d 72 25 2a 32 35 35 2f  37 0d 00 71 12 20 20 20  |=r%*255/7..q.   |
00000130  47 25 3d 67 25 2a 32 35  35 2f 37 0d 00 72 12 20  |G%=g%*255/7..r. |
00000140  20 20 42 25 3d 62 25 2a  32 35 35 2f 33 0d 00 73  |  B%=b%*255/3..s|
00000150  28 20 20 20 21 70 25 3d  28 42 25 3c 3c 32 34 29  |(   !p%=(B%<<24)|
00000160  20 2b 20 28 47 25 3c 3c  31 36 29 20 2b 20 28 52  | + (G%<<16) + (R|
00000170  25 3c 3c 38 29 0d 00 74  0c 20 20 20 70 25 2b 3d  |%<<8)..t.   p%+=|
00000180  34 0d 00 75 07 20 20 ed  0d 00 76 06 20 ed 0d 00  |4..u.  ...v. ...|
00000190  77 05 ed 0d 00 a0 04 0d  00 aa 1d f4 20 43 72 65  |w........... Cre|
000001a0  61 74 65 20 74 68 65 20  6c 6f 6f 6b 75 70 20 74  |ate the lookup t|
000001b0  61 62 6c 65 0d 00 b4 14  c8 99 22 48 6f 75 72 67  |able......"Hourg|
000001c0  6c 61 73 73 5f 4f 6e 22  0d 00 be 2b c8 99 22 49  |lass_On"...+.."I|
000001d0  50 43 5f 43 72 65 61 74  65 54 61 62 6c 65 73 22  |PC_CreateTables"|
000001e0  2c 70 61 6c 25 2c 70 61  6c 25 2b 31 30 32 34 2c  |,pal%,pal%+1024,|
000001f0  32 35 36 0d 00 c8 17 c8  99 22 48 6f 75 72 67 6c  |256......"Hourgl|
00000200  61 73 73 5f 53 6d 61 73  68 22 0d 00 d2 04 0d 00  |ass_Smash"......|
00000210  dc 21 f4 20 53 61 76 65  20 74 68 65 20 64 65 66  |.!. Save the def|
00000220  69 6e 69 74 69 6f 6e 20  74 6f 20 64 69 73 6b 0d  |inition to disk.|
00000230  00 e6 35 c8 99 22 4f 53  5f 46 69 6c 65 22 2c 31  |..5.."OS_File",1|
00000240  30 2c 66 69 6c 65 24 2c  26 30 30 46 2c 2c 70 61  |0,file$,&00F,,pa|
00000250  6c 25 2c 70 61 6c 25 2b  28 31 30 32 34 2b 33 32  |l%,pal%+(1024+32|
00000260  37 36 38 29 0d 00 f0 05  e0 0d ff                 |768).......|
0000026b