From: Alan Cox Date: Sun, 4 Oct 2015 13:07:03 +0000 (+0100) Subject: graphics: text mode tidy up X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=f03c34432e2f7d6efa57a69bc6c817dccd230f33;p=FUZIX.git graphics: text mode tidy up Now we have text modes as modes we can get rid of GFX_ENABLE stuff --- diff --git a/Applications/util/mode.c b/Applications/util/mode.c index 18a26619..6b167256 100644 --- a/Applications/util/mode.c +++ b/Applications/util/mode.c @@ -85,8 +85,6 @@ static void decode_mode_c(int c) printf("offscreen "); if (disp.features & GFX_VBLANK) printf("vblank "); - if (disp.features & GFX_ENABLE) - printf("enable "); if (disp.features & GFX_MULTIMODE) printf("multimode "); if (disp.features & GFX_PALETTE_SET) diff --git a/Kernel/include/graphics.h b/Kernel/include/graphics.h index 62759c6f..324bec8c 100644 --- a/Kernel/include/graphics.h +++ b/Kernel/include/graphics.h @@ -26,7 +26,6 @@ struct display { #define GFX_PALETTE 2 /* Has colour palette */ #define GFX_OFFSCREEN 4 /* Offscreen memory */ #define GFX_VBLANK 8 -#define GFX_ENABLE 16 /* Separate mode we enable/disable */ #define GFX_MULTIMODE 32 /* Has multiple modes */ #define GFX_PALETTE_SET 64 /* Has settable colour palette */ #define GFX_TEXT 128 /* Console text works in this mode */ @@ -74,8 +73,6 @@ struct videomap { }; #define GFXIOC_GETINFO 0x0300 /* Query display info for this tty */ -#define GFXIOC_ENABLE 0x0301 /* Enter graphics mode */ -#define GFXIOC_DISABLE 0x0302 /* Exit graphics mode */ #define GFXIOC_GETPALETTE 0x0303 /* Get a palette entry */ #define GFXIOC_SETPALETTE 0x0304 /* Set a palette entry */ #define GFXIOC_MAP 0x0305 /* Map into process if supported */ diff --git a/Kernel/platform-trs80/devgfx.c b/Kernel/platform-trs80/devgfx.c index 07b9f90c..5e1dfc41 100644 --- a/Kernel/platform-trs80/devgfx.c +++ b/Kernel/platform-trs80/devgfx.c @@ -11,16 +11,31 @@ #include #include -static const struct display trsdisplay = { - 0, - 640, 240, - 1024, 256, - 1, 1, /* Need adding to ioctls */ - FMT_MONO_BW, - HW_TRS80GFX, - GFX_ENABLE|GFX_MAPPABLE|GFX_OFFSCREEN, /* Can in theory do pans */ - 32, - GFX_DRAW|GFX_READ|GFX_WRITE +static const struct display trsdisplay[2] = { + { + /* Once we get around to it this is probably best described as + 160 x 72 sixel */ + 0, + 80, 24, + 80, 24, + 255, 255, + FMT_TEXT, + HW_UNACCEL, + 0, + 2, + 0 + }, + { + 1, + 640, 240, + 1024, 256, + 1, 1, /* Need adding to ioctls */ + FMT_MONO_BW, + HW_TRS80GFX, + GFX_MAPPABLE|GFX_OFFSCREEN, /* Can in theory do pans */ + 32, + GFX_DRAW|GFX_READ|GFX_WRITE + } }; /* Assumes a Tandy board */ @@ -35,6 +50,8 @@ static const struct videomap trsmap = { __sfr __at 0x83 gfx_ctrl; +static uint8_t vmode; + static int gfx_draw_op(uarg_t arg, char *ptr, uint8_t *buf) { int l; @@ -77,6 +94,7 @@ static int gfx_draw_op(uarg_t arg, char *ptr, uint8_t *buf) int gfx_ioctl(uint8_t minor, uarg_t arg, char *ptr) { uint8_t *tmp; + uint8_t m; int err; if (arg >> 8 != 0x03) @@ -84,31 +102,40 @@ int gfx_ioctl(uint8_t minor, uarg_t arg, char *ptr) switch(arg) { case GFXIOC_GETINFO: - return uput(&trsdisplay, ptr, sizeof(trsdisplay)); - case GFXIOC_ENABLE: - gfx_ctrl = 3; /* we might want 1 for special cases */ + return uput(&trsdisplay[vmode], ptr, sizeof(struct display)); + case GFXIOC_GETMODE: + case GFXIOC_SETMODE: + m = ugetc(ptr); + if (m > 1) + break; + if (arg == GFXIOC_GETMODE) + return uput(&trsdisplay[m], ptr, sizeof(struct display)); + vmode = m; + gfx_ctrl = m ? 3 : 0; /* we might want 1 for special cases */ return 0; - case GFXIOC_DISABLE: - gfx_ctrl = 0; case GFXIOC_UNMAP: return 0; /* Users can "map" 8) the I/O ports into their process and use the card directly */ case GFXIOC_MAP: + if (vmode == 0) + break; return uput(&trsmap, ptr, sizeof(trsmap)); case GFXIOC_DRAW: case GFXIOC_READ: case GFXIOC_WRITE: - tmp = (uint8_t *)tmpbuf(); - err = gfx_draw_op(arg, ptr, tmp); - brelse((bufptr) tmp); - if (err) { - udata.u_error = err; - err = -1; + if (vmode == 1) { + tmp = (uint8_t *)tmpbuf(); + err = gfx_draw_op(arg, ptr, tmp); + brelse((bufptr) tmp); + if (err) { + udata.u_error = err; + err = -1; + } + return err; } - return err; - default: - udata.u_error = EINVAL; - return -1; + /* Fall through */ } + udata.u_error = EINVAL; + return -1; } diff --git a/Library/include/sys/graphics.h b/Library/include/sys/graphics.h index 768fd118..33b594fc 100644 --- a/Library/include/sys/graphics.h +++ b/Library/include/sys/graphics.h @@ -26,7 +26,6 @@ struct display { #define GFX_PALETTE 2 /* Has colour palette */ #define GFX_OFFSCREEN 4 /* Offscreen memory */ #define GFX_VBLANK 8 -#define GFX_ENABLE 16 /* Separate mode we enable/disable */ #define GFX_MULTIMODE 32 /* Has multiple modes */ #define GFX_PALETTE_SET 64 /* Has settable colour palette */ #define GFX_TEXT 128 /* Console text works in this mode */ @@ -74,8 +73,6 @@ struct videomap { }; #define GFXIOC_GETINFO 0x0300 /* Query display info for this tty */ -#define GFXIOC_ENABLE 0x0301 /* Enter graphics mode */ -#define GFXIOC_DISABLE 0x0302 /* Exit graphics mode */ #define GFXIOC_GETPALETTE 0x0303 /* Get a palette entry */ #define GFXIOC_SETPALETTE 0x0304 /* Set a palette entry */ #define GFXIOC_MAP 0x0305 /* Map into process if supported */