make the linux-ppc packags be in synch with other platforms
[tangerine.git] / arch / m68k-mac / exec / screen.c
blob642b0e55a6f4455f55bfc6d1b223a68741aa3fb9
1 #include <stddef.h>
2 #include <stdio.h>
3 #include <string.h>
5 #include "ep_info.h"
6 #include "6x10.h"
8 #if 1
9 #define mybug(col,var) __asm__ __volatile__("move.l #"#col",0xf9002000+"#var"" :: );
10 #else
11 #define mybug(col,var)
12 #endif
14 extern char tab[127];
16 #ifdef rkprintf
17 # undef rkprintf
18 #endif
19 #define rkprintf(x...) scr_RawPutChars(tab, snprintf(tab,126, x))
21 extern unsigned long _end;
22 extern unsigned long _edata;
23 extern struct mac68k_init_stuff init_stuff;
25 void vputc(char c);
26 void fontinit(void);
27 void setcursor(unsigned char col, unsigned char row);
28 void clearscreen(void);
29 void screen_init(void);
30 void scr_RawPutChars(char *chr, int lim);
32 void screen_init(void)
34 #if 0
35 init_stuff.vidaddr = 0xf9000e00;
36 init_stuff.vidrow = 832;
37 init_stuff.vidwidth = 832;
38 init_stuff.vidheight = 624;
39 init_stuff.viddepth = 8;
40 #endif
42 if(init_stuff.vidaddr)
44 unsigned long i,j,k;
46 init_stuff.chrrows = init_stuff.vidheight / 10 - 1;
47 init_stuff.chrcols = init_stuff.vidwidth / 8 - 1;
48 init_stuff.currow = 0;
49 init_stuff.curcol = 0;
51 clearscreen();
53 for(j=0;j<=init_stuff.vidheight;j++)
55 k=j*init_stuff.vidrow;
56 for(i=0;i<=init_stuff.vidrow;i++)
58 *(volatile unsigned char *)(init_stuff.vidaddr+i+k) = (unsigned char)i;
61 fontinit();
65 void fontinit(void)
67 unsigned char font_lut2[16] = {
68 0x00, 0x03, 0x0c, 0x0f,
69 0x30, 0x33, 0x3c, 0x3f,
70 0xc0, 0xc3, 0xcc, 0xcf,
71 0xf0, 0xf3, 0xfc, 0xff
73 unsigned char font_lut4[4] = {
74 0x00, 0x0f, 0xf0, 0xff
76 unsigned char i,j,k,m,temp;
78 for(j=0;j<128;j++)
80 for(i=0;i<10;i++)
82 temp = ~(Font6x10[j*10+i]);
84 switch(init_stuff.viddepth)
86 case 1:
87 init_stuff.fontbyte[j][i][0] = temp;
88 break;
89 case 2:
90 init_stuff.fontbyte[j][i][1] = font_lut2[temp&0x0f];
91 temp = temp >> 4;
92 init_stuff.fontbyte[j][i][0] = font_lut2[temp&0x0f];
93 break;
94 case 4:
95 init_stuff.fontbyte[j][i][3] = font_lut4[temp&0x03];
96 temp = temp >> 2;
97 init_stuff.fontbyte[j][i][2] = font_lut4[temp&0x03];
98 temp = temp >> 2;
99 init_stuff.fontbyte[j][i][1] = font_lut4[temp&0x03];
100 temp = temp >> 2;
101 init_stuff.fontbyte[j][i][0] = font_lut4[temp&0x03];
102 break;
103 default:
104 for(k=0,m=7;k<8;k++,m--)
106 if((temp>>k) & 0x1)
108 init_stuff.fontbyte[j][i][m] = 0xff;
110 else
112 init_stuff.fontbyte[j][i][m] = 0x00;
115 break;
121 void setcursor(unsigned char col, unsigned char row)
123 init_stuff.curcol = col;
124 init_stuff.currow = row;
127 void vputc(char c)
129 unsigned long caddr,pixel32;
130 unsigned long i,j,m;
131 unsigned short pixel16;
132 unsigned char temp;
134 if(c == '\n')
136 init_stuff.currow++;
137 init_stuff.curcol = 0;
140 caddr = init_stuff.vidaddr + (init_stuff.curcol*init_stuff.viddepth) + (init_stuff.currow*10*init_stuff.vidrow);
142 for(i=0;i<10;i++)
144 switch(init_stuff.viddepth)
146 case 1:
147 case 2:
148 case 4:
149 case 8:
150 memcpy((unsigned long *)(caddr), &(init_stuff.fontbyte[c][i][0]),init_stuff.viddepth);
151 break;
152 case 16:
153 for(m=0;m<=8;m++)
155 temp = init_stuff.fontbyte[c][i][m];
156 pixel16 = ~((0x01<<15)|(temp<<11)|(temp<<6)|((0xf1&temp)>>3));
157 *(volatile unsigned short *)(caddr+m*2) = pixel16;
159 break;
160 case 24:
161 case 32:
162 for(m=0;m<=8;m++)
164 temp = init_stuff.fontbyte[c][i][m];
165 pixel32 = ~(0xff<<24|(temp << 16)|(temp << 8)|temp);
167 *(volatile unsigned long *)(caddr+m*4) = pixel32;
169 break;
170 default:
171 break;
173 caddr += init_stuff.vidrow;
176 if(init_stuff.curcol < init_stuff.chrcols)
178 init_stuff.curcol++;
180 else
182 init_stuff.curcol = 0;
183 init_stuff.currow++;
187 void clearscreen(void)
189 unsigned long i,j,k;
191 for(j=0;j<=init_stuff.vidheight;j++)
193 k=j*init_stuff.vidrow;
194 for(i=0;i<=init_stuff.vidrow;i+=4)
196 *(volatile unsigned long *)(init_stuff.vidaddr+i+k) = (unsigned long)0xffffffff;
201 void scr_RawPutChars(char *chr, int lim)
203 int i;
205 for (i=0; i<lim; i++)
206 vputc(*chr++);
209 #define scc_b_ctrl 0x0
210 #define scc_a_ctrl 0x2
211 #define scc_b_data 0x4
212 #define scc_a_data 0x6
214 void sputc(char c)
216 unsigned char *sccbase = (unsigned char *)0x50f0c020;
218 while(0x4 & sccbase[scc_b_ctrl]);
220 sccbase[scc_b_data] = c;