2 * Creation Date: <2002/10/23 20:26:40 samuel>
3 * Time-stamp: <2004/01/07 19:39:15 samuel>
7 * Mac-on-Linux display node
9 * Copyright (C) 2002, 2003, 2004 Samuel Rydh (samuel@ibrium.se)
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation
18 #include "libopenbios/bindings.h"
19 #include "libc/diskio.h"
20 #include "libopenbios/ofmem.h"
21 #include "drivers/drivers.h"
22 #include "packages/video.h"
23 #include "libopenbios/video.h"
24 #include "drivers/vga.h"
27 /************************************************************************/
29 /************************************************************************/
31 DECLARE_NODE( video, 0, 0, "Tdisplay" );
33 /* ( r g b index -- ) */
35 molvideo_color_bang( void )
41 unsigned long col = ((r << 16) & 0xff0000) | ((g << 8) & 0x00ff00) | (b & 0xff);
42 /* printk("color!: %08lx %08lx %08lx %08lx\n", r, g, b, index ); */
44 if( VIDEO_DICT_VALUE(video.depth) == 8 ) {
45 OSI_SetColor( index, col );
50 /* ( -- ) - really should be reworked as draw-logo */
52 molvideo_startup_splash( void )
54 int fd, s, i, y, x, dx, dy;
59 /* only draw logo in 24-bit mode (for now) */
60 if( VIDEO_DICT_VALUE(video.depth) < 15 )
63 for( i=0; i<2; i++ ) {
64 if( !BootHGetStrResInd("bootlogo", buf, sizeof(buf), 0, i) )
66 *(!i ? &width : &height) = atol(buf);
69 if( (s=width * height * 3) > 0x20000 )
72 if( (fd=open_io("pseudo:,bootlogo")) >= 0 ) {
74 if( read_io(fd, p, s) != s )
75 printk("bootlogo size error\n");
78 dx = (VIDEO_DICT_VALUE(video.w) - width)/2;
79 dy = (VIDEO_DICT_VALUE(video.h) - height)/3;
81 pp = (char*)VIDEO_DICT_VALUE(video.mvirt) + dy * VIDEO_DICT_VALUE(video.rb) + dx * (VIDEO_DICT_VALUE(video.depth) >= 24 ? 4 : 2);
83 for( y=0 ; y<height; y++, pp += VIDEO_DICT_VALUE(video.rb) ) {
84 if( VIDEO_DICT_VALUE(video.depth) >= 24 ) {
85 unsigned long *d = (unsigned long*)pp;
86 for( x=0; x<width; x++, p+=3, d++ )
87 *d = ((int)p[0] << 16) | ((int)p[1] << 8) | p[2];
88 } else if( VIDEO_DICT_VALUE(video.depth) == 15 ) {
89 unsigned short *d = (unsigned short*)pp;
90 for( x=0; x<width; x++, p+=3, d++ ) {
91 int col = ((int)p[0] << 16) | ((int)p[1] << 8) | p[2];
92 *d = ((col>>9) & 0x7c00) | ((col>>6) & 0x03e0) | ((col>>3) & 0x1f);
99 /* No bootlogo support yet on other platforms */
104 NODE_METHODS( video ) = {
105 {"mol-startup-splash", molvideo_startup_splash },
109 /************************************************************************/
111 /************************************************************************/
118 REGISTER_NODE( video );
120 /* Bind the MOL graphic routines to the mol-color! defer */
121 color_bang = bind_noname_func(molvideo_color_bang);
123 feval(" to mol-color!");