Changeset 1160f8d in mainline


Ignore:
Timestamp:
2006-06-04T14:31:43Z (19 years ago)
Author:
Jakub Vana <jakub.vana@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
7bc1e74
Parents:
26f48570
Message:

Ega scrolling and screen saving

Location:
fb
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • fb/ega.c

    r26f48570 r1160f8d  
    2626 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2727 */
    28 
     28#include <stdlib.h>
     29#include <unistd.h>
    2930#include <align.h>
    3031#include <async.h>
     
    4445#include "main.h"
    4546
     47#define MAX_SAVED_SCREENS 256
     48typedef struct saved_screen {
     49        short *data;
     50} saved_screen;
     51
     52saved_screen saved_screens[MAX_SAVED_SCREENS];
     53
    4654
    4755#define EGA_IO_ADDRESS 0x3d4
     
    6068static char *scr_addr;
    6169
    62 static unsigned int style = 0x0f;
     70static unsigned int style = 0x1e;
    6371
    6472static inline void outb(u16 port, u8 b)
     
    114122}
    115123
    116 void cursor_goto(unsigned int row, unsigned int col)
     124static void cursor_goto(unsigned int row, unsigned int col)
    117125{
    118126        int ega_cursor;
     
    126134}
    127135
    128 void cursor_disable(void)
     136static void cursor_disable(void)
    129137{
    130138        u8 stat;
     
    135143}
    136144
    137 void cursor_enable(void)
     145static void cursor_enable(void)
    138146{
    139147        u8 stat;
     
    144152}
    145153
     154static 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
    146169static void printchar(char c, unsigned int row, unsigned int col)
    147170{
     
    159182                scr_addr[i*2] = data[i].character;
    160183                if (data[i].style.fg_color > data[i].style.bg_color)
    161                         scr_addr[i*2+1] = 0x0f;
     184                        scr_addr[i*2+1] = 0x1e;
    162185                else
    163                         scr_addr[i*2+1] = 0xf0;
    164         }
    165 }
     186                        scr_addr[i*2+1] = 0xe1;
     187        }
     188}
     189
     190static 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
     201static 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
    166209
    167210static void ega_client_connection(ipc_callid_t iid, ipc_call_t *icall)
     
    175218        keyfield_t *interbuf = NULL;
    176219        size_t intersize = 0;
     220        int i;
    177221
    178222        if (client_connected) {
     
    235279                        retval = 0;
    236280                        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;
    237290                case FB_CURSOR_VISIBILITY:
    238291                        if(IPC_GET_ARG1(call))
     
    246299                        bgcolor = IPC_GET_ARG2(call);
    247300                        if (fgcolor > bgcolor)
    248                                 style = 0x0f;
     301                                style = 0x1e;
    249302                        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
    251324                default:
    252325                        retval = ENOENT;
     
    275348        async_set_client_connection(ega_client_connection);
    276349
    277         clrscr();
    278 
    279350        return 0;
    280351}
  • fb/fb.c

    r26f48570 r1160f8d  
    700700                memcpy(screen.fbaddress + tmp, pmap->data + y * srcrowsize, realrowsize);
    701701        }
     702        return pm;
    702703}
    703704
Note: See TracChangeset for help on using the changeset viewer.