3 #define WINDOW_X_SIZE 640
4 #define WINDOW_Y_SIZE 480
7 static prom_handle videodev;
8 static prom_handle videop;
10 static int Xstart, Ystart;
13 static unsigned char *address;
15 static int scrSetColorMap( unsigned char color,
16 unsigned char r, unsigned char g, unsigned char b );
23 videodev = (prom_handle)call_prom( "open", 1, 1, "screen" );
24 if( videodev == PROM_INVALID_HANDLE )
26 videop = (prom_handle)call_prom( "instance-to-package", 1, 1, videodev );
27 if( videop == PROM_INVALID_HANDLE )
30 result |= prom_getprop(videop, "width", &Xres, 4 );
31 result |= prom_getprop(videop, "height", &Yres, 4 );
32 result |= prom_getprop(videop, "address", &address, 4 );
33 result |= prom_getprop(videop, "linebytes", &rowbytes, 4 );
35 prom_map (address, address, rowbytes * Xres);
38 prom_printf("width : %d\n", Xres);
39 prom_printf("height : %d\n", Yres);
40 prom_printf("address : 0x%08lx\n", address);
41 prom_printf("linebytes : %d\n", rowbytes);
42 prom_printf("result : %d\n", result);
48 zoom = Xres / WINDOW_X_SIZE > Yres / WINDOW_Y_SIZE ? Yres / WINDOW_Y_SIZE : Xres / WINDOW_X_SIZE;
50 Xstart = Xres / 2 - WINDOW_X_SIZE / 2 * zoom;
51 Ystart = Yres / 2 - WINDOW_Y_SIZE / 2 * zoom;
54 prom_printf("zoom : %d\n", zoom);
55 prom_printf("Xstart : %d\n", Xstart);
56 prom_printf("Ystart : %d\n", Ystart);
63 void scrClear( unsigned char c )
67 for (y = 0; y < Yres; y++)
68 for (x = 0; x < Xres; x++)
69 address[y * rowbytes + x] = c;
75 call_prom( "close", 1, 0, videodev );
83 extern unsigned char color_table_red[],
87 for( c = 0; c < 16; ++c )
88 scrSetColorMap( c, color_table_red[c],
90 color_table_blue[c] );
94 static void inline do_pix( int x, int y, unsigned char c )
96 address[ y * rowbytes + x ] = c;
100 void scrPutPixel( int x, int y, unsigned char c )
104 for( zy = 0; zy < zoom; ++zy )
105 for( zx = 0; zx < zoom; ++zx )
106 do_pix( x * zoom + zx + Xstart, y * zoom + zy + Ystart, c );
110 int scrSetColorMap( unsigned char color, unsigned char r, unsigned char g, unsigned char b )
114 result = (int)call_prom( "call-method", 6, 1, "color!", videodev, color, b, g, r );
120 void scrFillColorMap( unsigned char r, unsigned char g, unsigned char b )
124 for( c = 0; c < 256; ++c )
125 scrSetColorMap( c, r, g, b );
129 void scrSetEntireColorMap( unsigned char *map )
133 for( c = 0; c < 256; ++c )
134 scrSetColorMap( c, map[c * 3], map[c * 3 + 1], map[c * 3 + 2] );
138 void scrFadeColorMap( unsigned char *first, unsigned char *last, int rate )
142 for( inc = 0; inc < 256; inc += rate )
143 for( c = 0; c < 256; ++c )
144 scrSetColorMap( c, first[c * 3 + 0] * (255 - inc) / 255 + last[c * 3 + 0] * inc / 255,
145 first[c * 3 + 1] * (255 - inc) / 255 + last[c * 3 + 1] * inc / 255,
146 first[c * 3 + 2] * (255 - inc) / 255 + last[c * 3 + 2] * inc / 255 );