Home » Archimedes archive » Acorn User » AU 1998-05 A.adf » Regulars » StarInfo/Johns/c/Screen
StarInfo/Johns/c/Screen
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-05 A.adf » Regulars |
Filename: | StarInfo/Johns/c/Screen |
Read OK: | ✔ |
File size: | 0333 bytes |
Load address: | 0000 |
Exec address: | 0000 |
File contents
/* ** Screen ** ------ ** Functions to do stuff with the screen ;) */ #include "kernel.h" #include "swis.h" #include "screen.h" #define ModeVar(X) _swi(OS_ReadModeVariable,_IN(0)|_IN(1)|_RETURN(2),-1,X) // finds the screen size void screensize(int *x,int *y) { *x = ModeVar(11)+1; *y = ModeVar(12)+1; } // finds the screen bpp int screenbpp(void) { int l2bpp = ModeVar(9); return 1<<l2bpp; } // finds the no. of colours int screencols(void) { return ModeVar(3); } // finds the eig values void screeneig(int *xeig,int *yeig) { *xeig = ModeVar(4); *yeig = ModeVar(5); } // finds the screen address void *screenaddr(void) { unsigned block[2] = {149,-1}; _kernel_swi_regs r; r.r[0] = (int) █ r.r[1] = (int) █ _kernel_swi(OS_ReadVduVariables,&r,&r); return (void *) block[0]; }
00000000 2f 2a 0a 2a 2a 20 53 63 72 65 65 6e 0a 2a 2a 20 |/*.** Screen.** | 00000010 2d 2d 2d 2d 2d 2d 0a 2a 2a 20 46 75 6e 63 74 69 |------.** Functi| 00000020 6f 6e 73 20 74 6f 20 64 6f 20 73 74 75 66 66 20 |ons to do stuff | 00000030 77 69 74 68 20 74 68 65 20 73 63 72 65 65 6e 20 |with the screen | 00000040 3b 29 0a 2a 2f 0a 0a 23 69 6e 63 6c 75 64 65 20 |;).*/..#include | 00000050 22 6b 65 72 6e 65 6c 2e 68 22 0a 23 69 6e 63 6c |"kernel.h".#incl| 00000060 75 64 65 20 22 73 77 69 73 2e 68 22 0a 23 69 6e |ude "swis.h".#in| 00000070 63 6c 75 64 65 20 22 73 63 72 65 65 6e 2e 68 22 |clude "screen.h"| 00000080 0a 0a 23 64 65 66 69 6e 65 20 4d 6f 64 65 56 61 |..#define ModeVa| 00000090 72 28 58 29 20 5f 73 77 69 28 4f 53 5f 52 65 61 |r(X) _swi(OS_Rea| 000000a0 64 4d 6f 64 65 56 61 72 69 61 62 6c 65 2c 5f 49 |dModeVariable,_I| 000000b0 4e 28 30 29 7c 5f 49 4e 28 31 29 7c 5f 52 45 54 |N(0)|_IN(1)|_RET| 000000c0 55 52 4e 28 32 29 2c 2d 31 2c 58 29 0a 0a 2f 2f |URN(2),-1,X)..//| 000000d0 20 66 69 6e 64 73 20 74 68 65 20 73 63 72 65 65 | finds the scree| 000000e0 6e 20 73 69 7a 65 0a 76 6f 69 64 20 73 63 72 65 |n size.void scre| 000000f0 65 6e 73 69 7a 65 28 69 6e 74 20 2a 78 2c 69 6e |ensize(int *x,in| 00000100 74 20 2a 79 29 0a 7b 0a 20 20 2a 78 20 3d 20 4d |t *y).{. *x = M| 00000110 6f 64 65 56 61 72 28 31 31 29 2b 31 3b 0a 20 20 |odeVar(11)+1;. | 00000120 2a 79 20 3d 20 4d 6f 64 65 56 61 72 28 31 32 29 |*y = ModeVar(12)| 00000130 2b 31 3b 0a 7d 0a 0a 2f 2f 20 66 69 6e 64 73 20 |+1;.}..// finds | 00000140 74 68 65 20 73 63 72 65 65 6e 20 62 70 70 0a 69 |the screen bpp.i| 00000150 6e 74 20 73 63 72 65 65 6e 62 70 70 28 76 6f 69 |nt screenbpp(voi| 00000160 64 29 0a 7b 0a 20 20 69 6e 74 20 6c 32 62 70 70 |d).{. int l2bpp| 00000170 20 3d 20 4d 6f 64 65 56 61 72 28 39 29 3b 0a 20 | = ModeVar(9);. | 00000180 20 72 65 74 75 72 6e 20 31 3c 3c 6c 32 62 70 70 | return 1<<l2bpp| 00000190 3b 0a 7d 0a 0a 2f 2f 20 66 69 6e 64 73 20 74 68 |;.}..// finds th| 000001a0 65 20 6e 6f 2e 20 6f 66 20 63 6f 6c 6f 75 72 73 |e no. of colours| 000001b0 0a 69 6e 74 20 73 63 72 65 65 6e 63 6f 6c 73 28 |.int screencols(| 000001c0 76 6f 69 64 29 0a 7b 0a 20 20 72 65 74 75 72 6e |void).{. return| 000001d0 20 4d 6f 64 65 56 61 72 28 33 29 3b 0a 7d 0a 0a | ModeVar(3);.}..| 000001e0 2f 2f 20 66 69 6e 64 73 20 74 68 65 20 65 69 67 |// finds the eig| 000001f0 20 76 61 6c 75 65 73 0a 76 6f 69 64 20 73 63 72 | values.void scr| 00000200 65 65 6e 65 69 67 28 69 6e 74 20 2a 78 65 69 67 |eeneig(int *xeig| 00000210 2c 69 6e 74 20 2a 79 65 69 67 29 0a 7b 0a 20 20 |,int *yeig).{. | 00000220 2a 78 65 69 67 20 3d 20 4d 6f 64 65 56 61 72 28 |*xeig = ModeVar(| 00000230 34 29 3b 0a 20 20 2a 79 65 69 67 20 3d 20 4d 6f |4);. *yeig = Mo| 00000240 64 65 56 61 72 28 35 29 3b 0a 7d 0a 0a 2f 2f 20 |deVar(5);.}..// | 00000250 66 69 6e 64 73 20 74 68 65 20 73 63 72 65 65 6e |finds the screen| 00000260 20 61 64 64 72 65 73 73 0a 76 6f 69 64 20 2a 73 | address.void *s| 00000270 63 72 65 65 6e 61 64 64 72 28 76 6f 69 64 29 0a |creenaddr(void).| 00000280 7b 0a 20 20 75 6e 73 69 67 6e 65 64 20 62 6c 6f |{. unsigned blo| 00000290 63 6b 5b 32 5d 20 3d 20 7b 31 34 39 2c 2d 31 7d |ck[2] = {149,-1}| 000002a0 3b 0a 20 20 5f 6b 65 72 6e 65 6c 5f 73 77 69 5f |;. _kernel_swi_| 000002b0 72 65 67 73 20 72 3b 0a 20 20 72 2e 72 5b 30 5d |regs r;. r.r[0]| 000002c0 20 3d 20 28 69 6e 74 29 20 26 62 6c 6f 63 6b 3b | = (int) █| 000002d0 0a 20 20 72 2e 72 5b 31 5d 20 3d 20 28 69 6e 74 |. r.r[1] = (int| 000002e0 29 20 26 62 6c 6f 63 6b 3b 0a 20 20 5f 6b 65 72 |) █. _ker| 000002f0 6e 65 6c 5f 73 77 69 28 4f 53 5f 52 65 61 64 56 |nel_swi(OS_ReadV| 00000300 64 75 56 61 72 69 61 62 6c 65 73 2c 26 72 2c 26 |duVariables,&r,&| 00000310 72 29 3b 0a 20 20 72 65 74 75 72 6e 20 28 76 6f |r);. return (vo| 00000320 69 64 20 2a 29 20 62 6c 6f 63 6b 5b 30 5d 3b 0a |id *) block[0];.| 00000330 7d 0a 0a |}..| 00000333