revert between 56095 -> 55830 in arch
[AROS.git] / arch / m68k-mac / exec / screen.c
blob78a81688dfa85d188d2478cfce675bea0eb94ef9
1 /*
2 Copyright © 1995-2014, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include <stddef.h>
7 #include <stdio.h>
8 #include <string.h>
10 #include "ep_info.h"
11 #include "6x10.h"
13 #if 1
14 #define mybug(col,var) __asm__ __volatile__("move.l #"#col",0xf9002000+"#var"" :: );
15 #else
16 #define mybug(col,var)
17 #endif
19 extern char tab[127];
21 #ifdef rkprintf
22 # undef rkprintf
23 #endif
24 #define rkprintf(x...) scr_RawPutChars(tab, snprintf(tab,126, x))
26 extern unsigned long _end;
27 extern unsigned long _edata;
28 extern struct mac68k_init_stuff init_stuff;
30 void vputc(char c);
31 void fontinit(void);
32 void setcursor(unsigned char col, unsigned char row);
33 void clearscreen(void);
34 void screen_init(void);
35 void scr_RawPutChars(char *chr, int lim);
37 void screen_init(void)
39 #if 0
40 init_stuff.vidaddr = 0xf9000e00;
41 init_stuff.vidrow = 832;
42 init_stuff.vidwidth = 832;
43 init_stuff.vidheight = 624;
44 init_stuff.viddepth = 8;
45 #endif
47 if(init_stuff.vidaddr)
49 unsigned long i,j,k;
51 init_stuff.chrrows = init_stuff.vidheight / 10 - 1;
52 init_stuff.chrcols = init_stuff.vidwidth / 8 - 1;
53 init_stuff.currow = 0;
54 init_stuff.curcol = 0;
56 clearscreen();
58 for(j=0;j<=init_stuff.vidheight;j++)
60 k=j*init_stuff.vidrow;
61 for(i=0;i<=init_stuff.vidrow;i++)
63 *(volatile unsigned char *)(init_stuff.vidaddr+i+k) = (unsigned char)i;
66 fontinit();
70 void fontinit(void)
72 unsigned char font_lut2[16] = {
73 0x00, 0x03, 0x0c, 0x0f,
74 0x30, 0x33, 0x3c, 0x3f,
75 0xc0, 0xc3, 0xcc, 0xcf,
76 0xf0, 0xf3, 0xfc, 0xff
78 unsigned char font_lut4[4] = {
79 0x00, 0x0f, 0xf0, 0xff
81 unsigned char i,j,k,m,temp;
83 for(j=0;j<128;j++)
85 for(i=0;i<10;i++)
87 temp = ~(Font6x10[j*10+i]);
89 switch(init_stuff.viddepth)
91 case 1:
92 init_stuff.fontbyte[j][i][0] = temp;
93 break;
94 case 2:
95 init_stuff.fontbyte[j][i][1] = font_lut2[temp&0x0f];
96 temp = temp >> 4;
97 init_stuff.fontbyte[j][i][0] = font_lut2[temp&0x0f];
98 break;
99 case 4:
100 init_stuff.fontbyte[j][i][3] = font_lut4[temp&0x03];
101 temp = temp >> 2;
102 init_stuff.fontbyte[j][i][2] = font_lut4[temp&0x03];
103 temp = temp >> 2;
104 init_stuff.fontbyte[j][i][1] = font_lut4[temp&0x03];
105 temp = temp >> 2;
106 init_stuff.fontbyte[j][i][0] = font_lut4[temp&0x03];
107 break;
108 default:
109 for(k=0,m=7;k<8;k++,m--)
111 if((temp>>k) & 0x1)
113 init_stuff.fontbyte[j][i][m] = 0xff;
115 else
117 init_stuff.fontbyte[j][i][m] = 0x00;
120 break;
126 void setcursor(unsigned char col, unsigned char row)
128 init_stuff.curcol = col;
129 init_stuff.currow = row;
132 void vputc(char c)
134 unsigned long caddr,pixel32;
135 unsigned long i,j,m;
136 unsigned short pixel16;
137 unsigned char temp;
139 if(c == '\n')
141 init_stuff.currow++;
142 init_stuff.curcol = 0;
145 caddr = init_stuff.vidaddr + (init_stuff.curcol*init_stuff.viddepth) + (init_stuff.currow*10*init_stuff.vidrow);
147 for(i=0;i<10;i++)
149 switch(init_stuff.viddepth)
151 case 1:
152 case 2:
153 case 4:
154 case 8:
155 memcpy((unsigned long *)(caddr), &(init_stuff.fontbyte[c][i][0]),init_stuff.viddepth);
156 break;
157 case 16:
158 for(m=0;m<=8;m++)
160 temp = init_stuff.fontbyte[c][i][m];
161 pixel16 = ~((0x01<<15)|(temp<<11)|(temp<<6)|((0xf1&temp)>>3));
162 *(volatile unsigned short *)(caddr+m*2) = pixel16;
164 break;
165 case 24:
166 case 32:
167 for(m=0;m<=8;m++)
169 temp = init_stuff.fontbyte[c][i][m];
170 pixel32 = ~(0xff<<24|(temp << 16)|(temp << 8)|temp);
172 *(volatile unsigned long *)(caddr+m*4) = pixel32;
174 break;
175 default:
176 break;
178 caddr += init_stuff.vidrow;
181 if(init_stuff.curcol < init_stuff.chrcols)
183 init_stuff.curcol++;
185 else
187 init_stuff.curcol = 0;
188 init_stuff.currow++;
192 void clearscreen(void)
194 unsigned long i,j,k;
196 for(j=0;j<=init_stuff.vidheight;j++)
198 k=j*init_stuff.vidrow;
199 for(i=0;i<=init_stuff.vidrow;i+=4)
201 *(volatile unsigned long *)(init_stuff.vidaddr+i+k) = (unsigned long)0xffffffff;
206 void scr_RawPutChars(char *chr, int lim)
208 int i;
210 for (i=0; i<lim; i++)
211 vputc(*chr++);
214 #define scc_b_ctrl 0x0
215 #define scc_a_ctrl 0x2
216 #define scc_b_data 0x4
217 #define scc_a_data 0x6
219 void sputc(char c)
221 unsigned char *sccbase = (unsigned char *)0x50f0c020;
223 while(0x4 & sccbase[scc_b_ctrl]);
225 sccbase[scc_b_data] = c;