Changeset dc5a0fe1 in mainline


Ignore:
Timestamp:
2006-06-03T16:16:44Z (19 years ago)
Author:
Jakub Vana <jakub.vana@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
429acb9
Parents:
90f5d64
Message:

Ega cursor movement support

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • fb/ega.c

    r90f5d64 rdc5a0fe1  
    4444#include "main.h"
    4545
     46
     47#define EGA_IO_ADDRESS 0x3d4
     48#define EGA_IO_SIZE 2
     49
     50typedef unsigned char u8;
     51typedef unsigned short u16;
     52typedef unsigned int u32;
     53
     54
    4655/* Allow only 1 connection */
    4756static int client_connected = 0;
     
    5261
    5362static unsigned int style = 0x0f;
     63
     64static inline void outb(u16 port, u8 b)
     65{
     66        asm volatile ("outb %0, %1\n" :: "a" (b), "d" (port));
     67}
     68
     69static inline void outw(u16 port, u16 w)
     70{
     71        asm volatile ("outw %0, %1\n" :: "a" (w), "d" (port));
     72}
     73
     74static inline void outl(u16 port, u32 l)
     75{
     76        asm volatile ("outl %0, %1\n" :: "a" (l), "d" (port));
     77}
     78
     79static inline u8 inb(u16 port)
     80{
     81        u8 val;
     82
     83        asm volatile ("inb %1, %0 \n" : "=a" (val) : "d"(port));
     84        return val;
     85}
     86
     87static inline u16 inw(u16 port)
     88{
     89        u16 val;
     90
     91        asm volatile ("inw %1, %0 \n" : "=a" (val) : "d"(port));
     92        return val;
     93}
     94
     95static inline u32 inl(u16 port)
     96{
     97        u32 val;
     98
     99        asm volatile ("inl %1, %0 \n" : "=a" (val) : "d"(port));
     100        return val;
     101}
     102
     103
     104
    54105
    55106static void clrscr(void)
     
    63114}
    64115
     116void cursor_goto(unsigned int row, unsigned int col)
     117{
     118        int ega_cursor;
     119
     120        ega_cursor=col+scr_width*row;
     121       
     122        outb(EGA_IO_ADDRESS    , 0xe);
     123        outb(EGA_IO_ADDRESS + 1, (ega_cursor >>8) & 0xff);
     124        outb(EGA_IO_ADDRESS    , 0xf);
     125        outb(EGA_IO_ADDRESS + 1, ega_cursor & 0xff);
     126}
     127
     128void cursor_disable(void)
     129{
     130        u8 stat;
     131        outb(EGA_IO_ADDRESS , 0xa);
     132        stat=inb(EGA_IO_ADDRESS + 1);
     133        outb(EGA_IO_ADDRESS , 0xa);
     134        outb(EGA_IO_ADDRESS +1 ,stat | (1<<5) );
     135}
     136
     137void cursor_enable(void)
     138{
     139        u8 stat;
     140        outb(EGA_IO_ADDRESS , 0xa);
     141        stat=inb(EGA_IO_ADDRESS + 1);
     142        outb(EGA_IO_ADDRESS , 0xa);
     143        outb(EGA_IO_ADDRESS +1 ,stat & (~(1<<5)) );
     144}
     145
    65146static void printchar(char c, unsigned int row, unsigned int col)
    66147{
    67148        scr_addr[(row*scr_width + col)*2] = c;
    68149        scr_addr[(row*scr_width + col)*2+1] = style;
     150       
     151        cursor_goto(row,col+1);
    69152}
    70153
     
    142225                        retval = 0;
    143226                        break;
     227                case FB_CURSOR_GOTO:
     228                        row = IPC_GET_ARG1(call);
     229                        col = IPC_GET_ARG2(call);
     230                        if (row >= scr_height || col >= scr_width) {
     231                                retval = EINVAL;
     232                                break;
     233                        }
     234                        cursor_goto(row,col);
     235                        retval = 0;
     236                        break;
     237                case FB_CURSOR_VISIBILITY:
     238                        if(IPC_GET_ARG1(call))
     239                                cursor_enable();
     240                        else
     241                                cursor_disable();
     242                        retval = 0;
     243                        break;
    144244                case FB_SET_STYLE:
    145245                        fgcolor = IPC_GET_ARG1(call);
     
    165265        scr_width=sysinfo_value("fb.width");
    166266        scr_height=sysinfo_value("fb.height");
     267        iospace_enable(task_get_id(),(void *)EGA_IO_ADDRESS,2);
    167268
    168269        sz = scr_width*scr_height*2;
     
    178279        return 0;
    179280}
     281
  • tetris/screen.c

    r90f5d64 rdc5a0fe1  
    5656static int curscore;
    5757static int isset;               /* true => terminal is in game mode */
    58 static struct termios oldtt;
    5958static void (*tstp)(int);
    6059
Note: See TracChangeset for help on using the changeset viewer.