]>
git.ipfire.org Git - people/ms/u-boot.git/blob - board/MAI/AmigaOneG3SE/video.c
3 * Hyperion Entertainment, Hans-JoergF@hyperion-entertainment.com
5 * See file CREDITS for list of people who contributed to this
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
29 unsigned char *cursor_position
;
30 unsigned int cursor_row
;
31 unsigned int cursor_col
;
33 unsigned char current_attr
;
35 unsigned int video_numrows
= 25;
36 unsigned int video_numcols
= 80;
37 unsigned int video_scrolls
= 0;
39 #define VIDEO_BASE (unsigned char *)0xFD0B8000
40 #define VIDEO_ROWS video_numrows
41 #define VIDEO_COLS video_numcols
42 #define VIDEO_PITCH (2 * video_numcols)
43 #define VIDEO_SIZE (video_numrows * video_numcols * 2)
44 #define VIDEO_NAME "vga"
46 void video_test(void);
47 void video_putc(char ch
);
48 void video_puts(char *string
);
49 void video_scroll(int rows
);
50 void video_banner(void);
52 int video_start(void);
56 char *prompt_string
= "=>";
58 void video_set_color(unsigned char attr
)
60 unsigned char *fb
= (unsigned char *)VIDEO_BASE
;
63 current_attr
= video_get_attr();
65 for (i
=0; i
<VIDEO_SIZE
; i
+=2)
67 *(fb
+i
+1) = current_attr
;
71 unsigned char video_get_attr(void)
78 s
= getenv("vga_fg_color");
84 s
= getenv("vga_bg_color");
95 int drv_video_init(void)
97 int error
, devices
= 1 ;
99 if (video_inited
) return 1;
102 memset (&vgadev
, 0, sizeof(vgadev
));
104 strcpy(vgadev
.name
, VIDEO_NAME
);
105 vgadev
.flags
= DEV_FLAGS_OUTPUT
| DEV_FLAGS_SYSTEM
;
106 vgadev
.putc
= video_putc
;
107 vgadev
.puts
= video_puts
;
110 vgadev
.start
= video_start
;
112 error
= device_register (&vgadev
);
116 char *s
= getenv("stdout");
117 if (s
&& strcmp(s
, VIDEO_NAME
)==0)
119 if (overwrite_console()) return 1;
120 error
= console_assign(stdout
, VIDEO_NAME
);
121 if (error
== 0) return 1;
132 cursor_position
= VIDEO_BASE
; /* Color text display base */
135 current_attr
= video_get_attr(); /* Currently selected value for attribute. */
137 video_set_color(current_attr
);
142 void video_set_cursor(int line
, int column
)
144 unsigned short offset
= line
*video_numcols
+ column
;
145 cursor_position
= VIDEO_BASE
+ line
*VIDEO_PITCH
+ column
*2;
146 out_byte(0x3D4, 0x0E);
147 out_byte(0x3D5, offset
/256);
148 out_byte(0x3D4, 0x0F);
149 out_byte(0x3D5, offset
%256);
152 void video_write_char(int character
)
154 *cursor_position
= character
;
155 *(cursor_position
+1) = current_attr
;
158 void video_test(void)
163 void video_putc(char ch
)
175 if (cursor_col
) cursor_col
--;
179 cursor_col
= (cursor_col
/8+1)*8;
182 video_write_char(ch
);
184 if (cursor_col
> VIDEO_COLS
-1)
191 if (cursor_row
> VIDEO_ROWS
-1)
193 video_set_cursor(cursor_row
, cursor_col
);
196 void video_scroll(int rows
)
198 unsigned short clear
= ((unsigned short)current_attr
) | (' '<<8);
199 unsigned short* addr16
= &((unsigned short *)VIDEO_BASE
)[(VIDEO_ROWS
-rows
)*VIDEO_COLS
];
203 s
= getenv("vga_askscroll");
204 video_scrolls
+= rows
;
206 if (video_scrolls
>= video_numrows
)
208 if (s
&& strcmp(s
, "yes"))
210 while (-1 == tstc());
217 memcpy(VIDEO_BASE
, VIDEO_BASE
+rows
*(VIDEO_COLS
*2), (VIDEO_ROWS
-rows
)*(VIDEO_COLS
*2));
218 for (i
= 0 ; i
< rows
* VIDEO_COLS
; i
++)
224 void video_puts(char *string
)
233 int video_start(void)
238 unsigned char video_single_box
[] =
245 unsigned char video_double_box
[] =
252 unsigned char video_single_title
[] =
254 195, 196, 180, 180, 195
257 unsigned char video_double_title
[] =
259 204, 205, 185, 181, 198
265 unsigned char *video_addr(int x
, int y
)
267 return VIDEO_BASE
+ 2*(VIDEO_COLS
*y
) + 2*x
;
270 void video_bios_print_string(char *s
, int x
, int y
, int attr
, int count
)
272 int cattr
= current_attr
;
273 if (attr
!= -1) current_attr
= attr
;
274 video_set_cursor(x
,y
);
278 if (attr
== -1) current_attr
= *s
++;
284 void video_draw_box(int style
, int attr
, char *title
, int separate
, int x
, int y
, int w
, int h
)
286 unsigned char *fb
, *fb2
;
287 unsigned char *st
= (style
== SINGLE_BOX
)?video_single_box
: video_double_box
;
288 unsigned char *ti
= (style
== SINGLE_BOX
)?video_single_title
: video_double_title
;
291 fb
= video_addr(x
,y
);
296 fb2
= video_addr(x
,y
+h
-1);
320 fb
= video_addr(x
, y
+1);
321 fb2
= video_addr(x
+w
-1, y
+1);
322 for (i
=0; i
<h
-2; i
++)
325 *(fb
+1) = attr
; fb
+= 2*VIDEO_COLS
;
328 *(fb2
+1) = attr
; fb2
+= 2*VIDEO_COLS
;
336 fb
= video_addr(x
+1, y
);
354 fb
= video_addr(x
, y
+2);
357 for (i
=0; i
<w
-2; i
++)
365 fb
= video_addr(x
+1, y
+1);
366 for (i
=0; i
<w
-2; i
++)
372 fb
= video_addr(x
+2, y
+1);
386 void video_draw_text(int x
, int y
, int attr
, char *text
)
388 unsigned char *fb
= video_addr(x
,y
);
396 void video_save_rect(int x
, int y
, int w
, int h
, void *save_area
, int clearchar
, int clearattr
)
398 unsigned char *save
= (unsigned char *)save_area
;
399 unsigned char *fb
= video_addr(x
,y
);
403 unsigned char *fbb
= fb
;
407 if (clearchar
> 0) *fb
= clearchar
;
410 if (clearattr
> 0) *fb
= clearattr
;
412 fb
= fbb
+ 2*VIDEO_COLS
;
416 void video_restore_rect(int x
, int y
, int w
, int h
, void *save_area
)
418 unsigned char *save
= (unsigned char *)save_area
;
419 unsigned char *fb
= video_addr(x
,y
);
423 unsigned char *fbb
= fb
;
429 fb
= fbb
+ 2*VIDEO_COLS
;
444 void video_size(int cols
, int rows
)
446 video_numrows
= rows
;
447 video_numcols
= cols
;
450 void video_clear(void)
452 unsigned short *fbb
= (unsigned short *)0xFD0B8000;
454 unsigned short val
= 0x2000 | current_attr
;
456 for (i
=0; i
<video_rows(); i
++)
458 for (j
=0; j
<video_cols(); j
++)
463 video_set_cursor(0,0);
469 int video_easteregg_active
= 0;
471 void video_easteregg(void)
473 video_easteregg_active
= 1;
477 extern block_dev_desc_t
* ide_get_dev(int dev
);
478 extern char version_string
[];
480 void video_banner(void)
482 block_dev_desc_t
*ide
;
483 DECLARE_GLOBAL_DATA_PTR
;
489 if (video_inited
== 0) return;
491 if (video_easteregg_active
)
496 printf(" **** COMMODORE 64 BASIC X2 ****\n\n");
497 printf(" 64K RAM SYSTEM 38911 BASIC BYTES FREE\n\n");
503 s
= getenv("ide_maxbus");
505 maxdev
= atoi(s
) * 2;
509 s
= getenv("stdout");
510 if (s
&& strcmp(s
, "serial") == 0)
514 printf("%s\n\nCPU: ", version_string
);
516 printf("DRAM: %ld MB\n", gd
->bd
->bi_memsize
/(1024*1024));
517 printf("FSB: %ld MHz\n", gd
->bd
->bi_busfreq
/1000000);
519 printf("\n---- Disk summary ----\n");
520 for (i
= 0; i
< maxdev
; i
++)
522 ide
= ide_get_dev(i
);
523 printf("Device %d: ", i
);
528 video_draw_box(SINGLE_BOX, 0x0F, "Test 1", 0, 0,18, 72, 4);
529 video_draw_box(DOUBLE_BOX, 0x0F, "Test 2", 1, 4,10, 50, 6);
530 video_draw_box(DOUBLE_BOX, 0x0F, "Test 3", 0, 40, 3, 20, 5);
532 video_draw_text(1, 4, 0x2F, "Highlighted options");
533 video_draw_text(1, 5, 0x0F, "Non-selected option");
534 video_draw_text(1, 6, 0x07, "disabled option");