Changeset 1160f8d in mainline
- Timestamp:
- 2006-06-04T14:31:43Z (19 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 7bc1e74
- Parents:
- 26f48570
- Location:
- fb
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
fb/ega.c
r26f48570 r1160f8d 26 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 27 */ 28 28 #include <stdlib.h> 29 #include <unistd.h> 29 30 #include <align.h> 30 31 #include <async.h> … … 44 45 #include "main.h" 45 46 47 #define MAX_SAVED_SCREENS 256 48 typedef struct saved_screen { 49 short *data; 50 } saved_screen; 51 52 saved_screen saved_screens[MAX_SAVED_SCREENS]; 53 46 54 47 55 #define EGA_IO_ADDRESS 0x3d4 … … 60 68 static char *scr_addr; 61 69 62 static unsigned int style = 0x 0f;70 static unsigned int style = 0x1e; 63 71 64 72 static inline void outb(u16 port, u8 b) … … 114 122 } 115 123 116 void cursor_goto(unsigned int row, unsigned int col)124 static void cursor_goto(unsigned int row, unsigned int col) 117 125 { 118 126 int ega_cursor; … … 126 134 } 127 135 128 void cursor_disable(void)136 static void cursor_disable(void) 129 137 { 130 138 u8 stat; … … 135 143 } 136 144 137 void cursor_enable(void)145 static void cursor_enable(void) 138 146 { 139 147 u8 stat; … … 144 152 } 145 153 154 static void scroll(int rows) 155 { 156 int i; 157 if (rows > 0) { 158 memcpy(scr_addr,((char *)scr_addr)+rows*scr_width*2,scr_width*scr_height*2-rows*scr_width*2); 159 for(i=0;i<rows*scr_width;i++) 160 (((short *)scr_addr)+scr_width*scr_height-rows*scr_width)[i]=((style<<8)+' '); 161 } else if (rows < 0) { 162 163 memcpy(((char *)scr_addr)-rows*scr_width*2,scr_addr,scr_width*scr_height*2+rows*scr_width*2); 164 for(i=0;i<-rows*scr_width;i++) 165 ((short *)scr_addr)[i]=((style<<8)+' '); 166 } 167 } 168 146 169 static void printchar(char c, unsigned int row, unsigned int col) 147 170 { … … 159 182 scr_addr[i*2] = data[i].character; 160 183 if (data[i].style.fg_color > data[i].style.bg_color) 161 scr_addr[i*2+1] = 0x 0f;184 scr_addr[i*2+1] = 0x1e; 162 185 else 163 scr_addr[i*2+1] = 0xf0; 164 } 165 } 186 scr_addr[i*2+1] = 0xe1; 187 } 188 } 189 190 static int save_screen(void) 191 { 192 int i; 193 short *mem; 194 for(i=0;(i<MAX_SAVED_SCREENS)&&(saved_screens[i].data);i++); 195 if(i==MAX_SAVED_SCREENS) return EINVAL; 196 if(!(saved_screens[i].data=malloc(2*scr_width*scr_height))) return ENOMEM; 197 memcpy(saved_screens[i].data,scr_addr,2*scr_width*scr_height); 198 return i; 199 } 200 201 static int print_screen(int i) 202 { 203 if(saved_screens[i].data) 204 memcpy(scr_addr,saved_screens[i].data,2*scr_width*scr_height); 205 else return EINVAL; 206 return i; 207 } 208 166 209 167 210 static void ega_client_connection(ipc_callid_t iid, ipc_call_t *icall) … … 175 218 keyfield_t *interbuf = NULL; 176 219 size_t intersize = 0; 220 int i; 177 221 178 222 if (client_connected) { … … 235 279 retval = 0; 236 280 break; 281 case FB_SCROLL: 282 i = IPC_GET_ARG1(call); 283 if (i > scr_height || i < (- (int)scr_height)) { 284 retval = EINVAL; 285 break; 286 } 287 scroll(i); 288 retval = 0; 289 break; 237 290 case FB_CURSOR_VISIBILITY: 238 291 if(IPC_GET_ARG1(call)) … … 246 299 bgcolor = IPC_GET_ARG2(call); 247 300 if (fgcolor > bgcolor) 248 style = 0x 0f;301 style = 0x1e; 249 302 else 250 style = 0xf0; 303 style = 0xe1; 304 305 case FB_VP_DRAW_PIXMAP: 306 i = IPC_GET_ARG2(call); 307 retval = print_screen(i); 308 break; 309 case FB_VP2PIXMAP: 310 retval = save_screen(); 311 break; 312 case FB_DROP_PIXMAP: 313 i = IPC_GET_ARG1(call); 314 if (i >= MAX_SAVED_SCREENS) { 315 retval = EINVAL; 316 break; 317 } 318 if (saved_screens[i].data) { 319 free(saved_screens[i].data); 320 saved_screens[i].data = NULL; 321 } 322 break; 323 251 324 default: 252 325 retval = ENOENT; … … 275 348 async_set_client_connection(ega_client_connection); 276 349 277 clrscr();278 279 350 return 0; 280 351 } -
fb/fb.c
r26f48570 r1160f8d 700 700 memcpy(screen.fbaddress + tmp, pmap->data + y * srcrowsize, realrowsize); 701 701 } 702 return pm; 702 703 } 703 704
Note:
See TracChangeset
for help on using the changeset viewer.