TRAP fix, start of new text driver
Fixed erroneous code on 68040 trying to set TRAP #15 handler, getting new text driver layer working on A2560K channel A.
This commit is contained in:
parent
1d98d4dd23
commit
5cf2c1fcab
|
@ -4,7 +4,7 @@
|
|||
# and where the MCP will run (ram or flash)
|
||||
#
|
||||
UNIT := a2560k
|
||||
MEMORY := flash
|
||||
MEMORY := ram
|
||||
|
||||
# CPU_WDC65816 0x16 /* CPU code for the Western Design Center 65816 */
|
||||
# CPU_M68000 0x20 /* CPU code for the Motorola 68000 */
|
||||
|
@ -67,9 +67,9 @@ cpu_c_src := $(wildcard $(cpu)/*.c)
|
|||
cpu_assembly_obj := $(subst .s,.o,$(cpu_assembly_src))
|
||||
cpu_c_obj := $(subst .c,.o,$(cpu_c_src))
|
||||
|
||||
dev_base_sources = dev/block.c dev/channel.c dev/console.c dev/fsys.c dev/pata.c dev/ps2.c dev/rtc.c dev/sdc.c dev/text_screen_iii.c dev/uart.c
|
||||
dev_base_sources = dev/block.c dev/channel.c dev/console.c dev/fsys.c dev/pata.c dev/ps2.c dev/rtc.c dev/sdc.c dev/text_screen_iii.c dev/txt_screen.o dev/uart.c
|
||||
ifeq ($(UNIT),a2560k)
|
||||
dev_c_src := $(dev_base_sources) dev/fdc.c dev/kbd_mo.c dev/lpt.c dev/midi.c
|
||||
dev_c_src := $(dev_base_sources) dev/fdc.c dev/kbd_mo.c dev/lpt.c dev/midi.c dev/txt_a2560k_a.o
|
||||
else
|
||||
dev_c_src := $(dev_base_sources)
|
||||
endif
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
[DEFAULT]
|
||||
port=COM9
|
||||
port=COM5
|
||||
labels=sample.lbl
|
||||
flash_address=380000
|
||||
|
|
670
src/dev/txt_a2560k_a.c
Normal file
670
src/dev/txt_a2560k_a.c
Normal file
|
@ -0,0 +1,670 @@
|
|||
/** @file txt_a2560k_a.c
|
||||
*
|
||||
* Text screen driver for A2560K Channel A
|
||||
*/
|
||||
|
||||
extern const unsigned char MSX_CP437_8x8_bin[];
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include "log.h"
|
||||
#include "dev/txt_screen.h"
|
||||
#include "dev/txt_a2560k_a.h"
|
||||
|
||||
/** Master Control Register for Channel A, and its supported bits */
|
||||
#define VKY3_A_MCR ((volatile unsigned long *)0xFEC40000)
|
||||
#define VKY3_A_MCR_TEXT 0x00000001 /**< Text mode enable bit */
|
||||
#define VKY3_A_MCR_SLEEP 0x00040000 /**< Monitor sleep (synch disable) bit */
|
||||
#define VKY3_A_1024x768 0x00000100 /**< Bit to select 1024x768 screen resolution */
|
||||
|
||||
/** Border control register for Channel A */
|
||||
#define VKY3_A_BCR ((volatile unsigned long *)0xFEC40004)
|
||||
#define VKY3_A_BCR_ENABLE 0x00000001 /**< Bit to enable the display of the border */
|
||||
|
||||
/** Border color register for Channel A */
|
||||
#define VKY3_A_BRDCOLOR ((volatile unsigned long *)0xFEC40008)
|
||||
|
||||
/** Cursor Control Register for Channel A */
|
||||
#define VKY3_A_CCR ((volatile unsigned long *)0xFEC40010)
|
||||
#define VKY3_A_CCR_ENABLE 0x00000001 /**< Bit to enable the display of the cursor */
|
||||
#define VKY3_A_CCR_RATE0 0x00000002 /**< Bit0 to specify the blink rate */
|
||||
#define VKY3_A_CCR_RATE1 0x00000004 /**< Bit1 to specify the blink rate */
|
||||
|
||||
/** Cursor Position Register for Channel A */
|
||||
#define VKY3_A_CPR ((volatile unsigned long *)0xFEC40014)
|
||||
|
||||
/** Font Manager Registers for Channel A */
|
||||
#define VKY3_A_FM0 ((volatile unsigned long *)0xFEC40020)
|
||||
#define VKY3_A_FM1 ((volatile unsigned long *)0xFEC40024)
|
||||
|
||||
/** Font memory block for Channel A */
|
||||
#define VKY3_A_FONT_MEMORY ((volatile unsigned char *)0xFEC48000)
|
||||
|
||||
/** Text Matrix for Channel A */
|
||||
#define VKY3_A_TEXT_MATRIX ((volatile unsigned char *)0xFEC60000)
|
||||
|
||||
/** Color Matrix for Channel A */
|
||||
#define VKY3_A_COLOR_MATRIX ((volatile unsigned char *)0xFEC68000)
|
||||
|
||||
/* Text Color LUTs for Channel A */
|
||||
#define VKY3_A_LUT_SIZE 16
|
||||
#define VKY3_A_TEXT_LUT_FG ((volatile unsigned char *)0xFEC6C400) /**< Text foreground color look up table for channel A */
|
||||
#define VKY3_A_TEXT_LUT_BG ((volatile unsigned char *)0xFEC6C440) /**< Text background color look up table for channel A */
|
||||
|
||||
/* Default text color lookup table values (AARRGGBB) */
|
||||
const unsigned long a2560k_a_lut[VKY3_A_LUT_SIZE] = {
|
||||
0xFF000000, // Black (transparent)
|
||||
0xFF800000, // Mid-Tone Red
|
||||
0xFF008000, // Mid-Tone Green
|
||||
0xFF808000, // Mid-Tone Yellow
|
||||
0xFF000080, // Mid-Tone Blue
|
||||
0xFFAA5500, // Mid-Tone Orange
|
||||
0xFF008080, // Mid-Tone Cian
|
||||
0xFF808080, // 50% Grey
|
||||
0xFF555555, // Dark Grey
|
||||
0xFFFF5555, // Bright Red
|
||||
0xFF55FF55, // Bright Green
|
||||
0xFFFFFF55, // Bright Yellow
|
||||
0xFF5555FF, // Bright Blue
|
||||
0xFFFF7FFF, // Bright Orange
|
||||
0xFF55FFFF, // Bright Cyan
|
||||
0xFFFFFFFF // White
|
||||
};
|
||||
|
||||
/*
|
||||
* Driver level variables for the screen
|
||||
*/
|
||||
|
||||
unsigned char a2560k_a_enable_set_sizes; /* Flag to enable set_sizes to actually do its computation */
|
||||
t_txt_capabilities a2560k_a_caps; /* The capabilities of Channel A */
|
||||
t_extent a2560k_a_resolutions[2]; /* The list of display resolutions */
|
||||
t_extent a2560k_a_fonts[2]; /* The list of font resolutions */
|
||||
t_rect a2560k_a_region; /* The current region */
|
||||
t_point a2560k_a_cursor; /* The current cursor position */
|
||||
t_extent a2560k_a_resolution; /* The current display resolution */
|
||||
t_extent a2560k_a_font_size; /* The current font size */
|
||||
t_extent a2560k_a_max_size; /* The size of the screen in characters (without border removed) */
|
||||
t_extent a2560k_a_visible_size; /* The size of the visible screen in characters (with border removed) */
|
||||
short a2560k_a_border_width; /* Width of the border on one side */
|
||||
short a2560k_a_border_height; /* Height of the border on one side */
|
||||
unsigned char a2560k_a_color; /* The current color */
|
||||
unsigned long msr_shadow; /* A shadow register for the Master Control Register */
|
||||
|
||||
/**
|
||||
* Gets the description of a screen's capabilities
|
||||
*
|
||||
* @return a pointer to the read-only description (0 on error)
|
||||
*/
|
||||
const p_txt_capabilities txt_a2560k_a_get_capabilities() {
|
||||
return &a2560k_a_caps;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate the size of the text screen in rows and columns so that
|
||||
* the kernel printing routines can work correctly.
|
||||
*
|
||||
* NOTE: this should be called whenever the VKY3 Channel A registers are changed
|
||||
*/
|
||||
void txt_a2560k_a_set_sizes() {
|
||||
if (a2560k_a_enable_set_sizes) {
|
||||
/* Only recalculate after initialization is mostly completed */
|
||||
|
||||
/*
|
||||
* Calculate the maximum number of characters visible on the screen
|
||||
* This controls text layout in memory
|
||||
*/
|
||||
a2560k_a_max_size.width = a2560k_a_resolution.width / a2560k_a_font_size.width;
|
||||
a2560k_a_max_size.height = a2560k_a_resolution.height / a2560k_a_font_size.height;
|
||||
|
||||
// /* Set the font manager register */
|
||||
// *VKY3_A_FM1 = (a2560k_a_max_size.height & 0xff) << 8 | (a2560k_a_max_size.width * 0xff);
|
||||
|
||||
/*
|
||||
* Calculate the characters that are visible in whole or in part
|
||||
*/
|
||||
short border_width = (2 * a2560k_a_border_width) / a2560k_a_font_size.width;
|
||||
short border_height = (2 * a2560k_a_border_height) / a2560k_a_font_size.height;
|
||||
a2560k_a_visible_size.width = a2560k_a_max_size.width - border_width;
|
||||
a2560k_a_visible_size.height = a2560k_a_max_size.height - border_height;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the display mode for the screen
|
||||
*
|
||||
* @param mode a bitfield of desired display mode options
|
||||
*
|
||||
* @return 0 on success, any other number means the mode is invalid for the screen
|
||||
*/
|
||||
short txt_a2560k_a_set_mode(short mode) {
|
||||
/* Turn off anything not set */
|
||||
msr_shadow &= ~(TXT_MODE_SLEEP | TXT_MODE_TEXT);
|
||||
|
||||
if (mode & TXT_MODE_SLEEP) {
|
||||
/* Put the monitor to sleep */
|
||||
msr_shadow |= VKY3_A_MCR_SLEEP;
|
||||
*VKY3_A_MCR = msr_shadow;
|
||||
return 0;
|
||||
|
||||
} else if (mode & TXT_MODE_TEXT) {
|
||||
/* Put on text mode */
|
||||
msr_shadow |= VKY3_A_MCR_TEXT;
|
||||
*VKY3_A_MCR = msr_shadow;
|
||||
return 0;
|
||||
|
||||
} else {
|
||||
/* Unsupported mode */
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the display resolution of the screen
|
||||
*
|
||||
* @param width the desired horizontal resolution in pixels
|
||||
* @param height the desired veritical resolution in pixels
|
||||
*
|
||||
* @return 0 on success, any other number means the resolution is unsupported
|
||||
*/
|
||||
short txt_a2560k_a_set_resolution(short width, short height) {
|
||||
/* Turn off resolution bits */
|
||||
msr_shadow &= ~(VKY3_A_1024x768);
|
||||
|
||||
if ((width == 800) && (height == 600)) {
|
||||
a2560k_a_resolution.width = width;
|
||||
a2560k_a_resolution.height = height;
|
||||
*VKY3_A_MCR = msr_shadow;
|
||||
return 0;
|
||||
|
||||
} else if ((width == 1024) && (height == 768)) {
|
||||
msr_shadow |= VKY3_A_1024x768;
|
||||
a2560k_a_resolution.width = width;
|
||||
a2560k_a_resolution.height = height;
|
||||
*VKY3_A_MCR = msr_shadow;
|
||||
return 0;
|
||||
|
||||
} else {
|
||||
/* Unsupported resolution */
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the size of the border of the screen (if supported)
|
||||
*
|
||||
* @param width the horizontal size of one side of the border (0 - 32 pixels)
|
||||
* @param height the vertical size of one side of the border (0 - 32 pixels)
|
||||
*/
|
||||
void txt_a2560k_a_set_border(short width, short height) {
|
||||
if ((width > 0) || (height > 0)) {
|
||||
a2560k_a_border_width = width;
|
||||
a2560k_a_border_height = height;
|
||||
*VKY3_A_BCR = (height & 0x3f) << 16 | (width & 0x3f) << 8 | VKY3_A_BCR_ENABLE;
|
||||
|
||||
} else {
|
||||
a2560k_a_border_width = 0;
|
||||
a2560k_a_border_height = 0;
|
||||
*VKY3_A_BCR = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the size of the border of the screen (if supported)
|
||||
*
|
||||
* @param red the red component of the color (0 - 255)
|
||||
* @param green the green component of the color (0 - 255)
|
||||
* @param blue the blue component of the color (0 - 255)
|
||||
*/
|
||||
void txt_a2560k_a_set_border_color(unsigned char red, unsigned char green, unsigned char blue) {
|
||||
*VKY3_A_BRDCOLOR = (unsigned long)(((red & 0xff) << 16) | ((green & 0xff) << 8) | (blue & 0xff));
|
||||
}
|
||||
|
||||
/**
|
||||
* Load a font as the current font for the screen
|
||||
*
|
||||
* @param width width of a character in pixels
|
||||
* @param height of a character in pixels
|
||||
* @param data pointer to the raw font data to be loaded
|
||||
*/
|
||||
short txt_a2560k_a_set_font(short width, short height, unsigned char * data) {
|
||||
if (((width == 8) && (height == 8)) || ((width == 8) && (height == 16))) {
|
||||
int i;
|
||||
|
||||
/* The size is valid... set the font */
|
||||
a2560k_a_font_size.width = width;
|
||||
a2560k_a_font_size.height = height;
|
||||
|
||||
/* Set the size of the character and container */
|
||||
*VKY3_A_FM0 = ((height & 0xff) << 24) | ((width & 0xff) << 16) | ((height & 0xff) << 8) | (width & 0xff);
|
||||
|
||||
/* Copy the font data... this assumes a width of one byte! */
|
||||
/* TODO: generalize this for all possible font sizes */
|
||||
for (i = 0; i < 256 * height; i++) {
|
||||
VKY3_A_FONT_MEMORY[i] = data[i];
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the appearance of the cursor
|
||||
*
|
||||
* @param enable 0 to hide, any other number to make visible
|
||||
* @param rate the blink rate for the cursor (0=1s, 1=0.5s, 2=0.25s, 3=1/5s)
|
||||
* @param c the character in the current font to use as a cursor
|
||||
*/
|
||||
void txt_a2560k_a_set_cursor(short enable, short rate, char c) {
|
||||
*VKY3_A_CCR = ((a2560k_a_color & 0xff) << 24) | ((c & 0xff) << 16) | ((rate & 0x03) << 1) | (enable & 0x01);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a region to restrict further character display, scrolling, etc.
|
||||
* Note that a region of zero size will reset the region to the full size of the screen.
|
||||
*
|
||||
* @param region pointer to a t_rect describing the rectangular region (using character cells for size and size)
|
||||
*
|
||||
* @return 0 on success, any other number means the region was invalid
|
||||
*/
|
||||
short txt_a2560k_a_set_region(p_rect region) {
|
||||
if ((region->size.width == 0) || (region->size.height == 0)) {
|
||||
/* Set the region to the default (full screen) */
|
||||
a2560k_a_region.origin.x = 0;
|
||||
a2560k_a_region.origin.y = 0;
|
||||
a2560k_a_region.size.width = a2560k_a_visible_size.width;
|
||||
a2560k_a_region.size.height = a2560k_a_visible_size.height;
|
||||
|
||||
} else {
|
||||
a2560k_a_region.origin.x = region->origin.x;
|
||||
a2560k_a_region.origin.y = region->origin.y;
|
||||
a2560k_a_region.size.width = region->size.width;
|
||||
a2560k_a_region.size.height = region->size.height;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the default foreground and background colors for printing
|
||||
*
|
||||
* @param foreground the Text LUT index of the new current foreground color (0 - 15)
|
||||
* @param background the Text LUT index of the new current background color (0 - 15)
|
||||
*/
|
||||
short txt_a2560k_a_set_color(unsigned char foreground, unsigned char background) {
|
||||
a2560k_a_color = ((foreground & 0x0f) << 4) | (background & 0x0f);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Scroll the text in the current region
|
||||
*
|
||||
* @param screen the number of the text device
|
||||
* @param horizontal the number of columns to scroll (negative is left, positive is right)
|
||||
* @param vertical the number of rows to scroll (negative is down, positive is up)
|
||||
*/
|
||||
void txt_a2560k_a_scroll(short horizontal, short vertical) {
|
||||
long offset_from, offset_to;
|
||||
short x, y;
|
||||
|
||||
if (vertical < 0) {
|
||||
if (horizontal < 0) {
|
||||
/* moving to upper left */
|
||||
for (y = 0; y < a2560k_a_region.size.height; y++) {
|
||||
offset_to = (a2560k_a_region.origin.y + y) * a2560k_a_max_size.width;
|
||||
offset_from = (a2560k_a_region.origin.y + y - vertical) * a2560k_a_max_size.width;
|
||||
for (x = 0; x < a2560k_a_region.size.width; x++) {
|
||||
offset_to += a2560k_a_region.origin.x + x;
|
||||
if ((y > a2560k_a_region.size.height + vertical) || (x > a2560k_a_region.size.width + horizontal)) {
|
||||
/* In area that should be made blank */
|
||||
VKY3_A_TEXT_MATRIX[offset_to] = ' ';
|
||||
VKY3_A_COLOR_MATRIX[offset_to] = a2560k_a_color;
|
||||
|
||||
} else {
|
||||
/* Copy the character and color */
|
||||
offset_from += a2560k_a_region.origin.x + x - horizontal;
|
||||
VKY3_A_TEXT_MATRIX[offset_to] = VKY3_A_TEXT_MATRIX[offset_from];
|
||||
VKY3_A_COLOR_MATRIX[offset_to] = VKY3_A_COLOR_MATRIX[offset_from];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
/* move to upper right */
|
||||
for (y = 0; y < a2560k_a_region.size.height; y++) {
|
||||
offset_to = (a2560k_a_region.origin.y + y) * a2560k_a_max_size.width;
|
||||
offset_from = (a2560k_a_region.origin.y + y - vertical) * a2560k_a_max_size.width;
|
||||
for (x = a2560k_a_region.size.width - 1; x >= 0; x--) {
|
||||
offset_to += a2560k_a_region.origin.x + x;
|
||||
if ((y > a2560k_a_region.size.height + vertical) || (x < horizontal)) {
|
||||
/* In area that should be made blank */
|
||||
VKY3_A_TEXT_MATRIX[offset_to] = ' ';
|
||||
VKY3_A_COLOR_MATRIX[offset_to] = a2560k_a_color;
|
||||
|
||||
} else {
|
||||
/* Copy the character and color */
|
||||
offset_from += a2560k_a_region.origin.x + x - horizontal;
|
||||
VKY3_A_TEXT_MATRIX[offset_to] = VKY3_A_TEXT_MATRIX[offset_from];
|
||||
VKY3_A_COLOR_MATRIX[offset_to] = VKY3_A_COLOR_MATRIX[offset_from];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (horizontal < 0) {
|
||||
/* move to lower left */
|
||||
for (y = a2560k_a_region.size.height - 1; y >= 0; y--) {
|
||||
offset_to = (a2560k_a_region.origin.y + y) * a2560k_a_max_size.width;
|
||||
offset_from = (a2560k_a_region.origin.y + y - vertical) * a2560k_a_max_size.width;
|
||||
for (x = 0; x < a2560k_a_region.size.width; x++) {
|
||||
offset_to += a2560k_a_region.origin.x + x;
|
||||
if ((y < vertical) || (x > a2560k_a_region.size.width + horizontal)) {
|
||||
/* In area that should be made blank */
|
||||
VKY3_A_TEXT_MATRIX[offset_to] = ' ';
|
||||
VKY3_A_COLOR_MATRIX[offset_to] = a2560k_a_color;
|
||||
|
||||
} else {
|
||||
/* Copy the character and color */
|
||||
offset_from += a2560k_a_region.origin.x + x - horizontal;
|
||||
VKY3_A_TEXT_MATRIX[offset_to] = VKY3_A_TEXT_MATRIX[offset_from];
|
||||
VKY3_A_COLOR_MATRIX[offset_to] = VKY3_A_COLOR_MATRIX[offset_from];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
/* move to lower right */
|
||||
for (y = a2560k_a_region.size.height - 1; y >= 0; y--) {
|
||||
offset_to = (a2560k_a_region.origin.y + y) * a2560k_a_max_size.width;
|
||||
offset_from = (a2560k_a_region.origin.y + y - vertical) * a2560k_a_max_size.width;
|
||||
for (x = a2560k_a_region.size.width - 1; x >= 0; x--) {
|
||||
offset_to += a2560k_a_region.origin.x + x;
|
||||
if ((y < vertical) || (x < horizontal)) {
|
||||
/* In area that should be made blank */
|
||||
VKY3_A_TEXT_MATRIX[offset_to] = ' ';
|
||||
VKY3_A_COLOR_MATRIX[offset_to] = a2560k_a_color;
|
||||
|
||||
} else {
|
||||
/* Copy the character and color */
|
||||
offset_from += a2560k_a_region.origin.x + x - horizontal;
|
||||
VKY3_A_TEXT_MATRIX[offset_to] = VKY3_A_TEXT_MATRIX[offset_from];
|
||||
VKY3_A_COLOR_MATRIX[offset_to] = VKY3_A_COLOR_MATRIX[offset_from];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fill the current region with a character in the current color
|
||||
*
|
||||
* @param screen the number of the text device
|
||||
* @param c the character to fill the region with
|
||||
*/
|
||||
void txt_a2560k_a_fill(char c) {
|
||||
int x;
|
||||
int y;
|
||||
|
||||
for (y = 0; y < a2560k_a_region.size.height; y++) {
|
||||
int offset_row = (a2560k_a_region.origin.y + y) * a2560k_a_max_size.width;
|
||||
for (x = 0; x < a2560k_a_region.size.width; x++) {
|
||||
int offset = offset_row + a2560k_a_region.origin.x + x;
|
||||
VKY3_A_TEXT_MATRIX[offset] = c;
|
||||
VKY3_A_COLOR_MATRIX[offset] = a2560k_a_color;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the position of the cursor to (x, y) relative to the current region
|
||||
* If the (x, y) coordinate is outside the region, it will be clipped to the region.
|
||||
* If y is greater than the height of the region, the region will scroll until that relative
|
||||
* position would be within view.
|
||||
*
|
||||
* @param x the column for the cursor
|
||||
* @param y the row for the cursor
|
||||
*/
|
||||
void txt_a2560k_a_set_xy(short x, short y) {
|
||||
/* Make sure X is within range for the current region... "print" a newline if not */
|
||||
if (x < 0) {
|
||||
x = 0;
|
||||
} else if (x >= a2560k_a_region.size.width) {
|
||||
x = 0;
|
||||
y++;
|
||||
}
|
||||
|
||||
/* Make sure Y is within range for the current region... scroll if not */
|
||||
if (y < 0) {
|
||||
y = 0;
|
||||
} else if (y >= a2560k_a_region.size.width) {
|
||||
txt_a2560k_a_scroll(0, y - a2560k_a_region.size.height + 1);
|
||||
y = a2560k_a_region.size.height - 1;
|
||||
}
|
||||
|
||||
a2560k_a_cursor.x = x;
|
||||
a2560k_a_cursor.y = y;
|
||||
|
||||
/* Set register */
|
||||
*VKY3_A_CPR = (((a2560k_a_region.origin.y + y) & 0xffff) << 8) || ((a2560k_a_region.origin.x + x) & 0xffff);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the position of the cursor (x, y) relative to the current region
|
||||
*
|
||||
* @param screen the number of the text device
|
||||
* @param position pointer to a t_point record to fill out
|
||||
*/
|
||||
void txt_a2560k_a_get_xy(p_point position) {
|
||||
position->x = a2560k_a_cursor.x;
|
||||
position->y = a2560k_a_cursor.y;
|
||||
}
|
||||
|
||||
/**
|
||||
* Print a character to the current cursor position in the current color
|
||||
*
|
||||
* Most character codes will result in a glyph being displayed at the current
|
||||
* cursor position, advancing the cursor one spot. There are some exceptions that
|
||||
* will be treated as control codes:
|
||||
*
|
||||
* 0x08 - BS - Move the cursor back one position, erasing the character underneath
|
||||
* 0x09 - HT - Move forward to the next TAB stop
|
||||
* 0x0A - LF - Move the cursor down one line (line feed)
|
||||
* 0x0D - CR - Move the cursor to column 0 (carriage return)
|
||||
*
|
||||
* @param screen the number of the text device
|
||||
* @param c the character to print
|
||||
*/
|
||||
void txt_a2560k_a_put(char c) {
|
||||
short x;
|
||||
short y;
|
||||
unsigned int offset;
|
||||
|
||||
switch (c) {
|
||||
case 0x08:
|
||||
/* Backspace */
|
||||
break;
|
||||
|
||||
case 0x09:
|
||||
/* horizontal tab */
|
||||
break;
|
||||
|
||||
case 0x0A:
|
||||
/* line feed */
|
||||
txt_a2560k_a_set_xy(a2560k_a_cursor.x, a2560k_a_cursor.y + 1);
|
||||
break;
|
||||
|
||||
case 0x0D:
|
||||
/* carriage return */
|
||||
txt_a2560k_a_set_xy(0, a2560k_a_cursor.y);
|
||||
break;
|
||||
|
||||
default:
|
||||
x = a2560k_a_region.origin.x + a2560k_a_cursor.x;
|
||||
y = a2560k_a_region.origin.y + a2560k_a_cursor.y;
|
||||
offset = y * a2560k_a_max_size.width + x;
|
||||
VKY3_A_TEXT_MATRIX[offset] = c;
|
||||
VKY3_A_COLOR_MATRIX[offset] = a2560k_a_color;
|
||||
|
||||
txt_a2560k_a_set_xy(a2560k_a_cursor.x + 1, a2560k_a_cursor.y);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the screen
|
||||
*/
|
||||
void txt_a2560k_a_init() {
|
||||
char buffer[255];
|
||||
t_rect region;
|
||||
int i;
|
||||
|
||||
a2560k_a_resolution.width = 0;
|
||||
a2560k_a_resolution.height = 0;
|
||||
a2560k_a_font_size.width = 0;
|
||||
a2560k_a_font_size.height = 0;
|
||||
|
||||
/* Disable the set_sizes call for now */
|
||||
a2560k_a_enable_set_sizes = 0;
|
||||
|
||||
/* Start with nothing on */
|
||||
msr_shadow = 0;
|
||||
|
||||
/* Define the capabilities */
|
||||
|
||||
/* Specify the screen number */
|
||||
a2560k_a_caps.number = TXT_SCREEN_A2560K_A;
|
||||
|
||||
/* This screen can be text or can be put to sleep */
|
||||
a2560k_a_caps.supported_modes = TXT_MODE_TEXT | TXT_MODE_SLEEP;
|
||||
|
||||
/* Resolutions supported: 800x600, 1024x768 */
|
||||
a2560k_a_resolutions[0].width = 800;
|
||||
a2560k_a_resolutions[0].height = 600;
|
||||
a2560k_a_resolutions[1].width = 1024;
|
||||
a2560k_a_resolutions[1].height = 768;
|
||||
a2560k_a_caps.resolution_count = 2;
|
||||
a2560k_a_caps.resolutions = a2560k_a_resolutions;
|
||||
|
||||
/* At the moment, support only 8x8 and 8x16 fonts */
|
||||
/* TODO: add support for all possible font sizes */
|
||||
a2560k_a_fonts[0].width = 8;
|
||||
a2560k_a_fonts[0].height = 8;
|
||||
a2560k_a_fonts[1].width = 8;
|
||||
a2560k_a_fonts[1].height = 16;
|
||||
a2560k_a_caps.font_size_count = 2;
|
||||
a2560k_a_caps.font_sizes = a2560k_a_fonts;
|
||||
|
||||
/* Initialze the color lookup tables */
|
||||
for (i = 0; i < VKY3_A_LUT_SIZE; i++) {
|
||||
VKY3_A_TEXT_LUT_FG[i] = a2560k_a_lut[i];
|
||||
VKY3_A_TEXT_LUT_BG[i] = a2560k_a_lut[i];
|
||||
}
|
||||
|
||||
/* Set the mode to text */
|
||||
txt_a2560k_a_set_mode(TXT_MODE_TEXT);
|
||||
|
||||
/* Set the resolution */
|
||||
txt_a2560k_a_set_resolution(800, 600); /* Default resolution is 800x600 */
|
||||
|
||||
/* Set the default color: light grey on blue */
|
||||
txt_a2560k_a_set_color(0x07, 0x04);
|
||||
|
||||
/* Set the font */
|
||||
txt_a2560k_a_set_font(8, 8, MSX_CP437_8x8_bin); /* Use 8x8 font */
|
||||
|
||||
/* Set the cursor */
|
||||
txt_a2560k_a_set_cursor(1, 0, 0xB1);
|
||||
|
||||
/* Set the border */
|
||||
txt_a2560k_a_set_border(32, 32); /* No border for now */
|
||||
txt_a2560k_a_set_border_color(0x7f, 0x00, 0x7f);
|
||||
|
||||
/*
|
||||
* Enable set_sizes, now that everything is set up initially
|
||||
* And calculate the size of the screen
|
||||
*/
|
||||
a2560k_a_enable_set_sizes = 1;
|
||||
txt_a2560k_a_set_sizes();
|
||||
|
||||
/* Set region to default */
|
||||
region.origin.x = 0;
|
||||
region.origin.y = 0;
|
||||
region.size.width = 0;
|
||||
region.size.height = 0;
|
||||
txt_a2560k_a_set_region(®ion);
|
||||
|
||||
/* Home the cursor */
|
||||
txt_a2560k_a_set_xy(0, 0);
|
||||
|
||||
// /* Clear the screen */
|
||||
txt_a2560k_a_fill('.');
|
||||
|
||||
/* Set region to default */
|
||||
region.origin.x = 50;
|
||||
region.origin.y = 10;
|
||||
region.size.width = 20;
|
||||
region.size.height = 20;
|
||||
txt_a2560k_a_set_region(®ion);
|
||||
|
||||
// /* Clear the screen */
|
||||
txt_a2560k_a_fill(0x01);
|
||||
|
||||
/* Set region to default */
|
||||
region.origin.x = 0;
|
||||
region.origin.y = 0;
|
||||
region.size.width = 0;
|
||||
region.size.height = 0;
|
||||
txt_a2560k_a_set_region(®ion);
|
||||
|
||||
sprintf(buffer, "Resolution: %dx%d pixels", a2560k_a_resolution.width, a2560k_a_resolution.height);
|
||||
log(LOG_ERROR, buffer);
|
||||
|
||||
sprintf(buffer, "Font Size: %dx%d pixels", a2560k_a_font_size.width, a2560k_a_font_size.height);
|
||||
log(LOG_ERROR, buffer);
|
||||
|
||||
sprintf(buffer, "Region: (%d, %d) - (%d, %d)", a2560k_a_region.origin.x, a2560k_a_region.origin.y,
|
||||
a2560k_a_region.size.width, a2560k_a_region.size.height);
|
||||
log(LOG_ERROR, buffer);
|
||||
|
||||
sprintf(buffer, "Buffer Size: %dx%d characters", a2560k_a_max_size.width, a2560k_a_max_size.height);
|
||||
log(LOG_ERROR, buffer);
|
||||
|
||||
sprintf(buffer, "Visible Size: %dx%d characters", a2560k_a_visible_size.width, a2560k_a_visible_size.height);
|
||||
log(LOG_ERROR, buffer);
|
||||
|
||||
sprintf(buffer, "Color: %02X", a2560k_a_color);
|
||||
log(LOG_ERROR, buffer);
|
||||
|
||||
log(LOG_ERROR, "txt_a2560k_a_init complete");
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize and install the driver
|
||||
*
|
||||
* @return 0 on success, any other number is an error
|
||||
*/
|
||||
short txt_a2560k_a_install() {
|
||||
t_txt_device device;
|
||||
|
||||
device.number = TXT_SCREEN_A2560K_A;
|
||||
device.name = "SCREEN A";
|
||||
|
||||
device.init = txt_a2560k_a_init;
|
||||
device.get_capabilities = txt_a2560k_a_get_capabilities;
|
||||
device.set_mode = txt_a2560k_a_set_mode;
|
||||
device.set_resolution = txt_a2560k_a_set_resolution;
|
||||
device.set_border = txt_a2560k_a_set_border;
|
||||
device.set_font = txt_a2560k_a_set_font;
|
||||
device.set_region = txt_a2560k_a_set_region;
|
||||
device.set_color = txt_a2560k_a_set_color;
|
||||
device.set_xy = txt_a2560k_a_set_xy;
|
||||
device.get_xy = txt_a2560k_a_get_xy;
|
||||
device.put = txt_a2560k_a_put;
|
||||
device.scroll = txt_a2560k_a_scroll;
|
||||
device.fill = txt_a2560k_a_fill;
|
||||
|
||||
return txt_register(&device);
|
||||
}
|
18
src/dev/txt_a2560k_a.h
Normal file
18
src/dev/txt_a2560k_a.h
Normal file
|
@ -0,0 +1,18 @@
|
|||
/** @file txt_a2560k_a.h
|
||||
*
|
||||
* Text screen driver for A2560K Channel A
|
||||
*/
|
||||
|
||||
#ifndef __TXT_A2560K_A_H
|
||||
#define __TXT_A2560K_A_H
|
||||
|
||||
#define TXT_SCREEN_A2560K_A 1
|
||||
|
||||
/**
|
||||
* Initialize and install the driver
|
||||
*
|
||||
* @return 0 on success, any other number is an error
|
||||
*/
|
||||
extern short txt_a2560k_a_install();
|
||||
|
||||
#endif
|
367
src/dev/txt_screen.c
Normal file
367
src/dev/txt_screen.c
Normal file
|
@ -0,0 +1,367 @@
|
|||
/**
|
||||
* @file txt_screen.c
|
||||
*
|
||||
* Uniform routines to manage the text screens
|
||||
*
|
||||
* The console code will call this layer, which will dispatch those calls
|
||||
* to the low level drivers (e.g. txt_a2560k_a) registered with it.
|
||||
*/
|
||||
|
||||
#include "log.h"
|
||||
#include "dev/txt_screen.h"
|
||||
|
||||
/**
|
||||
* The array of device drivers.
|
||||
*
|
||||
* If the number of the driver record is 0, no driver is registered for that device
|
||||
*/
|
||||
static t_txt_device txt_device_driver[TXT_CNT_SCREENS];
|
||||
|
||||
/**
|
||||
* Initialize the text system.
|
||||
*/
|
||||
void txt_init() {
|
||||
int i;
|
||||
|
||||
/* Initialize all the drivers to blank... */
|
||||
for (i = 0; i < TXT_CNT_SCREENS; i++) {
|
||||
txt_device_driver[i].number = 0;
|
||||
txt_device_driver[i].name = 0;
|
||||
|
||||
txt_device_driver[i].init = 0;
|
||||
txt_device_driver[i].get_capabilities = 0;
|
||||
txt_device_driver[i].set_mode = 0;
|
||||
txt_device_driver[i].set_resolution = 0;
|
||||
txt_device_driver[i].set_border = 0;
|
||||
txt_device_driver[i].set_font = 0;
|
||||
txt_device_driver[i].set_region = 0;
|
||||
txt_device_driver[i].set_color = 0;
|
||||
txt_device_driver[i].set_xy = 0;
|
||||
txt_device_driver[i].get_xy = 0;
|
||||
txt_device_driver[i].put = 0;
|
||||
txt_device_driver[i].scroll = 0;
|
||||
txt_device_driver[i].fill = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a device driver for a text screen
|
||||
*
|
||||
* The data in the provided structure will be copied to the kernel's
|
||||
* internal structures. Also, the driver data provided will over-write
|
||||
* any previous driver data for the device number, if one was previously
|
||||
* registered.
|
||||
*
|
||||
* @param device the pointer to the device driver
|
||||
*
|
||||
* @return 0 on success, any other number is an error
|
||||
*/
|
||||
short txt_register(p_txt_device device) {
|
||||
if (device->number < TXT_CNT_SCREENS) {
|
||||
int i = device->number;
|
||||
|
||||
txt_device_driver[i].number = device->number;
|
||||
txt_device_driver[i].name = device->name;
|
||||
|
||||
txt_device_driver[i].init = device->init;
|
||||
txt_device_driver[i].get_capabilities = device->get_capabilities;
|
||||
txt_device_driver[i].set_mode = device->set_mode;
|
||||
txt_device_driver[i].set_resolution = device->set_resolution;
|
||||
txt_device_driver[i].set_border = device->set_border;
|
||||
txt_device_driver[i].set_font = device->set_font;
|
||||
txt_device_driver[i].set_region = device->set_region;
|
||||
txt_device_driver[i].set_color = device->set_color;
|
||||
txt_device_driver[i].set_xy = device->set_xy;
|
||||
txt_device_driver[i].get_xy = device->get_xy;
|
||||
txt_device_driver[i].put = device->put;
|
||||
txt_device_driver[i].scroll = device->scroll;
|
||||
txt_device_driver[i].fill = device->fill;
|
||||
|
||||
return 0;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Find the device driver for the screen, if installed
|
||||
*
|
||||
* @param device the pointer to the device driver
|
||||
*
|
||||
* @return pointer to the device driver structure, 0 if invalid or not found
|
||||
*/
|
||||
p_txt_device txt_get_device(short screen) {
|
||||
if (screen < TXT_CNT_SCREENS) {
|
||||
p_txt_device device = &(txt_device_driver[screen]);
|
||||
if (device->number == screen) {
|
||||
return device;
|
||||
} else {
|
||||
log_num(LOG_ERROR, "txt_get_device: number mismatch ", screen);
|
||||
log_num(LOG_ERROR, "txt_get_device: number mismatch ", device->number);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize a screen
|
||||
*
|
||||
* @param screen the number of the text device
|
||||
*/
|
||||
void txt_init_screen(short screen) {
|
||||
p_txt_device device = txt_get_device(screen);
|
||||
if (device) {
|
||||
if (device->init) {
|
||||
device->init();
|
||||
}
|
||||
} else {
|
||||
log_num(LOG_ERROR, "Could not find screen ", screen);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the description of a screen's capabilities
|
||||
*
|
||||
* @param screen the number of the text device
|
||||
*
|
||||
* @return a pointer to the read-only description (0 on error)
|
||||
*/
|
||||
const p_txt_capabilities txt_get_capabilities(short screen) {
|
||||
p_txt_device device = txt_get_device(screen);
|
||||
if (device) {
|
||||
if (device->get_capabilities) {
|
||||
return device->get_capabilities();
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the display mode for the screen
|
||||
*
|
||||
* @param mode a bitfield of desired display mode options
|
||||
*
|
||||
* @return 0 on success, any other number means the mode is invalid for the screen
|
||||
*/
|
||||
short txt_set_mode(short screen, short mode) {
|
||||
p_txt_device device = txt_get_device(screen);
|
||||
if (device) {
|
||||
if (device->set_mode) {
|
||||
return device->set_mode(mode);
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the display resolution of the screen
|
||||
*
|
||||
* @param screen the number of the text device
|
||||
* @param width the desired horizontal resolution in pixels
|
||||
* @param height the desired veritical resolution in pixels
|
||||
*
|
||||
* @return 0 on success, any other number means the resolution is unsupported
|
||||
*/
|
||||
short txt_set_resolution(short screen, short width, short height) {
|
||||
p_txt_device device = txt_get_device(screen);
|
||||
if (device) {
|
||||
if (device->set_resolution) {
|
||||
return device->set_resolution(width, height);
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the size of the border of the screen (if supported)
|
||||
*
|
||||
* @param screen the number of the text device
|
||||
* @param width the horizontal size of one side of the border (0 - 32 pixels)
|
||||
* @param height the vertical size of one side of the border (0 - 32 pixels)
|
||||
*/
|
||||
void txt_set_border(short screen, short width, short height) {
|
||||
p_txt_device device = txt_get_device(screen);
|
||||
if (device) {
|
||||
if (device->set_border) {
|
||||
device->set_border(width, height);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the size of the border of the screen (if supported)
|
||||
*
|
||||
* @param screen the number of the text device
|
||||
* @param red the red component of the color (0 - 255)
|
||||
* @param green the green component of the color (0 - 255)
|
||||
* @param blue the blue component of the color (0 - 255)
|
||||
*/
|
||||
void txt_set_border_color(short screen, unsigned char red, unsigned char green, unsigned char blue) {
|
||||
p_txt_device device = txt_get_device(screen);
|
||||
if (device) {
|
||||
if (device->set_border_color) {
|
||||
device->set_border_color(red, green, blue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Load a font as the current font for the screen
|
||||
*
|
||||
* @param screen the number of the text device
|
||||
* @param width width of a character in pixels
|
||||
* @param height of a character in pixels
|
||||
* @param data pointer to the raw font data to be loaded
|
||||
*/
|
||||
short txt_set_font(short screen, short width, short height, unsigned char * data) {
|
||||
p_txt_device device = txt_get_device(screen);
|
||||
if (device) {
|
||||
if (device->set_font) {
|
||||
return device->set_font(width, height, data);
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the appearance of the cursor
|
||||
*
|
||||
* @param screen the number of the text device
|
||||
* @param enable 0 to hide, any other number to make visible
|
||||
* @param rate the blink rate for the cursor (0=1s, 1=0.5s, 2=0.25s, 3=1/5s)
|
||||
* @param c the character in the current font to use as a cursor
|
||||
*/
|
||||
void txt_set_cursor(short screen, short enable, short rate, char c) {
|
||||
p_txt_device device = txt_get_device(screen);
|
||||
if (device) {
|
||||
if (device->set_cursor) {
|
||||
return device->set_cursor(enable, rate, c);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a region to restrict further character display, scrolling, etc.
|
||||
* Note that a region of zero size will reset the region to the full size of the screen.
|
||||
*
|
||||
* @param screen the number of the text device
|
||||
* @param region pointer to a t_rect describing the rectangular region (using character cells for size and size)
|
||||
*
|
||||
* @return 0 on success, any other number means the region was invalid
|
||||
*/
|
||||
short txt_set_region(short screen, p_rect region) {
|
||||
p_txt_device device = txt_get_device(screen);
|
||||
if (device) {
|
||||
if (device->set_region) {
|
||||
return device->set_region(region);
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the default foreground and background colors for printing
|
||||
*
|
||||
* @param screen the number of the text device
|
||||
* @param foreground the Text LUT index of the new current foreground color (0 - 15)
|
||||
* @param background the Text LUT index of the new current background color (0 - 15)
|
||||
*/
|
||||
short txt_set_color(short screen, unsigned char foreground, unsigned char background) {
|
||||
p_txt_device device = txt_get_device(screen);
|
||||
if (device) {
|
||||
if (device->set_color) {
|
||||
return device->set_color(foreground, background);
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the position of the cursor to (x, y) relative to the current region
|
||||
* If the (x, y) coordinate is outside the region, it will be clipped to the region.
|
||||
* If y is greater than the height of the region, the region will scroll until that relative
|
||||
* position would be within view.
|
||||
*
|
||||
* @param screen the number of the text device
|
||||
* @param x the column for the cursor
|
||||
* @param y the row for the cursor
|
||||
*/
|
||||
void txt_set_xy(short screen, short x, short y) {
|
||||
p_txt_device device = txt_get_device(screen);
|
||||
if (device) {
|
||||
if (device->set_xy) {
|
||||
device->set_xy(x, y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the position of the cursor (x, y) relative to the current region
|
||||
*
|
||||
* @param screen the number of the text device
|
||||
* @param position pointer to a t_point record to fill out
|
||||
*/
|
||||
void txt_get_xy(short screen, p_point position) {
|
||||
p_txt_device device = txt_get_device(screen);
|
||||
if (device) {
|
||||
if (device->get_xy) {
|
||||
device->get_xy(position);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Print a character to the current cursor position in the current color
|
||||
*
|
||||
* Most character codes will result in a glyph being displayed at the current
|
||||
* cursor position, advancing the cursor one spot. There are some exceptions that
|
||||
* will be treated as control codes:
|
||||
*
|
||||
* 0x08 - BS - Move the cursor back one position, erasing the character underneath
|
||||
* 0x09 - HT - Move forward to the next TAB stop
|
||||
* 0x0A - LF - Move the cursor down one line (line feed)
|
||||
* 0x0D - CR - Move the cursor to column 0 (carriage return)
|
||||
*
|
||||
* @param screen the number of the text device
|
||||
* @param c the character to print
|
||||
*/
|
||||
void txt_put(short screen, char c) {
|
||||
p_txt_device device = txt_get_device(screen);
|
||||
if (device) {
|
||||
if (device->put) {
|
||||
device->put(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Scroll the text in the current region
|
||||
*
|
||||
* @param screen the number of the text device
|
||||
* @param horizontal the number of columns to scroll (negative is left, positive is right)
|
||||
* @param vertical the number of rows to scroll (negative is down, positive is up)
|
||||
*/
|
||||
void txt_scroll(short screen, short horizontal, short vertical) {
|
||||
p_txt_device device = txt_get_device(screen);
|
||||
if (device) {
|
||||
if (device->scroll) {
|
||||
device->scroll(horizontal, vertical);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fill the current region with a character in the current color
|
||||
*
|
||||
* @param screen the number of the text device
|
||||
* @param c the character to fill the region with
|
||||
*/
|
||||
void txt_fill(short screen, char c) {
|
||||
p_txt_device device = txt_get_device(screen);
|
||||
if (device) {
|
||||
if (device->fill) {
|
||||
device->fill(c);
|
||||
}
|
||||
}
|
||||
}
|
271
src/dev/txt_screen.h
Normal file
271
src/dev/txt_screen.h
Normal file
|
@ -0,0 +1,271 @@
|
|||
/**
|
||||
* @file txt_screen.h
|
||||
*
|
||||
* Uniform routines to manage the text screens
|
||||
*/
|
||||
|
||||
#ifndef __TXT_SCREEN_H
|
||||
#define __TXT_SCREEN_H
|
||||
|
||||
#define TXT_CNT_SCREENS 5 /**< The maximum number of screens supported */
|
||||
|
||||
#define TXT_MODE_TEXT 0x0001 /**< The bit to enable text mode */
|
||||
#define TXT_MODE_BITMAP 0x0002 /**< The bit to enable bitmap graphics mode */
|
||||
#define TXT_MODE_SPRITE 0x0004 /**< The bit to enable sprite graphics mode */
|
||||
#define TXT_MODE_TILE 0x0008 /**< The bit to enable tile graphics mode */
|
||||
#define TXT_MODE_SLEEP 0x0010 /**< The bit to put the monitor to sleep by disabling sync */
|
||||
|
||||
/**
|
||||
* @struct s_extent
|
||||
*
|
||||
* An extent or size of a rectangular area
|
||||
*/
|
||||
typedef struct s_extent {
|
||||
short width; /**< The width of the region */
|
||||
short height; /**< The height of the region */
|
||||
} t_extent, *p_extent;
|
||||
|
||||
/**
|
||||
* @struct s_point
|
||||
*
|
||||
* A point on a plane
|
||||
*/
|
||||
typedef struct s_point {
|
||||
short x; /**< The column of the point */
|
||||
short y; /**< The row of the point */
|
||||
} t_point, *p_point;
|
||||
|
||||
/**
|
||||
* @struct s_rect
|
||||
*
|
||||
* A rectangle on the screen
|
||||
*/
|
||||
typedef struct s_rect {
|
||||
t_point origin; /**< The upper-left corner of the rectangle */
|
||||
t_extent size; /**< The size of the rectangle */
|
||||
} t_rect, *p_rect;
|
||||
|
||||
/**
|
||||
* @struct s_txt_capabilities
|
||||
*
|
||||
* A description of a screen's capabilities
|
||||
*/
|
||||
typedef struct s_txt_capabilities {
|
||||
short number; /**< The unique ID of the screen */
|
||||
short supported_modes; /**< The display modes supported on this screen */
|
||||
short font_size_count; /**< The number of supported font sizes */
|
||||
p_extent font_sizes; /**< Pointer to a list of t_extent listing all supported font sizes */
|
||||
short resolution_count; /**< The number of supported display resolutions */
|
||||
p_extent resolutions; /**< Pointer to a list of t_extent listing all supported display resolutions (in pixels) */
|
||||
} t_txt_capabilities, *p_txt_capabilities;
|
||||
|
||||
typedef void (*p_init)();
|
||||
typedef const p_txt_capabilities (*p_get_capabilities)();
|
||||
typedef short (*p_set_mode)(short mode);
|
||||
typedef short (*p_set_resolution)(short width, short height);
|
||||
typedef void (*p_set_border)(short width, short height);
|
||||
typedef void (*p_set_border_color)(unsigned char red, unsigned char green, unsigned char blue);
|
||||
typedef short (*p_set_font)(short width, short height, unsigned char * data);
|
||||
typedef void (*p_set_cursor)(short enable, short rate, char c);
|
||||
typedef short (*p_set_region)(p_rect region);
|
||||
typedef short (*p_set_color)(unsigned char foreground, unsigned char background);
|
||||
typedef void (*p_set_xy)(short x, short y);
|
||||
typedef void (*p_get_xy)(p_point position);
|
||||
typedef void (*p_put)(char c);
|
||||
typedef void (*p_scroll)(short horiztonal, short vertical);
|
||||
typedef void (*p_fill)(char c);
|
||||
|
||||
/**
|
||||
* @struct s_txt_device
|
||||
*
|
||||
* A device driver for a text screen
|
||||
*
|
||||
* The driver contains basic information about the device and pointers
|
||||
* to all the functions that implement actions the driver can take.
|
||||
*/
|
||||
typedef struct s_txt_device {
|
||||
short number; /**< The unique ID of the screen */
|
||||
const char * name; /**< A human-readable (mostly) name for the screen */
|
||||
|
||||
p_init init; /**< Pointer to the device's init function */
|
||||
p_get_capabilities get_capabilities; /**< Pointer to the device's get_capabilities function */
|
||||
p_set_mode set_mode; /**< Pointer to the device's set_mode function */
|
||||
p_set_resolution set_resolution; /**< Pointer to the device's set_resolution function */
|
||||
p_set_border set_border; /**< Pointer to the device's set_border function */
|
||||
p_set_border_color set_border_color; /**< Pointer to the device's set_border function */
|
||||
p_set_font set_font; /**< Pointer to the device's set_font function */
|
||||
p_set_region set_region; /**< Pointer to the device's set_region function */
|
||||
p_set_color set_color; /**< Pointer to the device's set_color function */
|
||||
p_set_cursor set_cursor; /**< Pointer to the device's set_cursor function */
|
||||
p_set_xy set_xy; /**< Pointer to the device's set_xy function */
|
||||
p_get_xy get_xy; /**< Pointer to the device's get_xy function */
|
||||
p_put put; /**< Pointer to the device's put function */
|
||||
p_scroll scroll; /**< Pointer to the device's scroll function */
|
||||
p_fill fill; /**< Pointer to the device's fill function */
|
||||
} t_txt_device, *p_txt_device;
|
||||
|
||||
/**
|
||||
* Initialize the text system.
|
||||
*/
|
||||
extern void txt_init();
|
||||
|
||||
/**
|
||||
* Register a device driver for a text screen
|
||||
*
|
||||
* @param device the pointer to the device driver (all will be copied into the kernel's internal storage)
|
||||
*
|
||||
* @return 0 on success, any other number is an error
|
||||
*/
|
||||
extern short txt_register(p_txt_device device);
|
||||
|
||||
/**
|
||||
* Initialize a screen
|
||||
*
|
||||
* @param screen the number of the text device
|
||||
*/
|
||||
extern void txt_init_screen(short screen);
|
||||
|
||||
/**
|
||||
* Gets the description of a screen's capabilities
|
||||
*
|
||||
* @param screen the number of the text device
|
||||
*
|
||||
* @return a pointer to the read-only description (0 on error)
|
||||
*/
|
||||
extern const p_txt_capabilities txt_get_capabilities(short screen);
|
||||
|
||||
/**
|
||||
* Set the display mode for the screen
|
||||
*
|
||||
* @param screen the number of the text device
|
||||
* @param mode a bitfield of desired display mode options
|
||||
*
|
||||
* @return 0 on success, any other number means the mode is invalid for the screen
|
||||
*/
|
||||
extern short txt_set_mode(short screen, short mode);
|
||||
|
||||
/**
|
||||
* Set the display resolution of the screen
|
||||
*
|
||||
* @param screen the number of the text device
|
||||
* @param width the desired horizontal resolution in pixels
|
||||
* @param height the desired veritical resolution in pixels
|
||||
*
|
||||
* @return 0 on success, any other number means the resolution is unsupported
|
||||
*/
|
||||
extern short txt_set_resolution(short screen, short width, short height);
|
||||
|
||||
/**
|
||||
* Set the size of the border of the screen (if supported)
|
||||
*
|
||||
* @param screen the number of the text device
|
||||
* @param width the horizontal size of one side of the border (0 - 32 pixels)
|
||||
* @param height the vertical size of one side of the border (0 - 32 pixels)
|
||||
*/
|
||||
extern void txt_set_border(short screen, short width, short height);
|
||||
|
||||
/**
|
||||
* Set the size of the border of the screen (if supported)
|
||||
*
|
||||
* @param screen the number of the text device
|
||||
* @param red the red component of the color (0 - 255)
|
||||
* @param green the green component of the color (0 - 255)
|
||||
* @param blue the blue component of the color (0 - 255)
|
||||
*/
|
||||
extern void txt_set_border_color(short screen, unsigned char red, unsigned char green, unsigned char blue);
|
||||
|
||||
/**
|
||||
* Load a font as the current font for the screen
|
||||
*
|
||||
* @param screen the number of the text device
|
||||
* @param width width of a character in pixels
|
||||
* @param height of a character in pixels
|
||||
* @param data pointer to the raw font data to be loaded
|
||||
*/
|
||||
extern short txt_set_font(short screen, short width, short height, unsigned char * data);
|
||||
|
||||
/**
|
||||
* Set the appearance of the cursor
|
||||
*
|
||||
* @param screen the number of the text device
|
||||
* @param enable 0 to hide, any other number to make visible
|
||||
* @param rate the blink rate for the cursor (0=1s, 1=0.5s, 2=0.25s, 3=1/5s)
|
||||
* @param c the character in the current font to use as a cursor
|
||||
*/
|
||||
extern void txt_set_cursor(short screen, short enable, short rate, char c);
|
||||
|
||||
/**
|
||||
* Set a region to restrict further character display, scrolling, etc.
|
||||
* Note that a region of zero size will reset the region to the full size of the screen.
|
||||
*
|
||||
* @param screen the number of the text device
|
||||
* @param region pointer to a t_rect describing the rectangular region (using character cells for size and size)
|
||||
*
|
||||
* @return 0 on success, any other number means the region was invalid
|
||||
*/
|
||||
extern short txt_set_region(short screen, p_rect region);
|
||||
|
||||
/**
|
||||
* Set the default foreground and background colors for printing
|
||||
*
|
||||
* @param screen the number of the text device
|
||||
* @param foreground the Text LUT index of the new current foreground color (0 - 15)
|
||||
* @param background the Text LUT index of the new current background color (0 - 15)
|
||||
*/
|
||||
extern short txt_set_color(short screen, unsigned char foreground, unsigned char background);
|
||||
|
||||
/**
|
||||
* Set the position of the cursor to (x, y) relative to the current region
|
||||
* If the (x, y) coordinate is outside the region, it will be clipped to the region.
|
||||
* If y is greater than the height of the region, the region will scroll until that relative
|
||||
* position would be within view.
|
||||
*
|
||||
* @param screen the number of the text device
|
||||
* @param x the column for the cursor
|
||||
* @param y the row for the cursor
|
||||
*/
|
||||
extern void txt_set_xy(short screen, short x, short y);
|
||||
|
||||
/**
|
||||
* Get the position of the cursor (x, y) relative to the current region
|
||||
*
|
||||
* @param screen the number of the text device
|
||||
* @param position pointer to a t_point record to fill out
|
||||
*/
|
||||
extern void txt_get_xy(short screen, p_point position);
|
||||
|
||||
/**
|
||||
* Print a character to the current cursor position in the current color
|
||||
*
|
||||
* Most character codes will result in a glyph being displayed at the current
|
||||
* cursor position, advancing the cursor one spot. There are some exceptions that
|
||||
* will be treated as control codes:
|
||||
*
|
||||
* 0x08 - BS - Move the cursor back one position, erasing the character underneath
|
||||
* 0x09 - HT - Move forward to the next TAB stop
|
||||
* 0x0A - LF - Move the cursor down one line (line feed)
|
||||
* 0x0D - CR - Move the cursor to column 0 (carriage return)
|
||||
*
|
||||
* @param screen the number of the text device
|
||||
* @param c the character to print
|
||||
*/
|
||||
extern void txt_put(short screen, char c);
|
||||
|
||||
/**
|
||||
* Scroll the text in the current region
|
||||
*
|
||||
* @param screen the number of the text device
|
||||
* @param horizontal the number of columns to scroll (negative is left, positive is right)
|
||||
* @param vertical the number of rows to scroll (negative is down, positive is up)
|
||||
*/
|
||||
extern void txt_scroll(short screen, short horiztonal, short vertical);
|
||||
|
||||
/**
|
||||
* Fill the current region with a character in the current color
|
||||
*
|
||||
* @param screen the number of the text device
|
||||
* @param c the character to fill the region with
|
||||
*/
|
||||
extern void txt_fill(short screen, char c);
|
||||
|
||||
#endif
|
|
@ -1,344 +0,0 @@
|
|||
/*
|
||||
* Text screen driver framework
|
||||
*/
|
||||
|
||||
#include "errors.h"
|
||||
#include "dev/text_device.h"
|
||||
|
||||
/* How many text devices do we support */
|
||||
#define MAX_TXT_DEVICES 4
|
||||
|
||||
/* The list of known text devices */
|
||||
t_txt_device txt_devices[MAX_TXT_DEVICES];
|
||||
|
||||
/*
|
||||
* Initialize the display system
|
||||
*/
|
||||
void txt_init() {
|
||||
int i;
|
||||
for (i = 0; i < MAX_TXT_DEVICES; i++) {
|
||||
p_txt_device dev = &txt_devices[i];
|
||||
dev.number = 0;
|
||||
dev.name = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Install the device driver for a text display
|
||||
*
|
||||
* Inputs:
|
||||
* driver = pointer to the t_txt_device record for the text display
|
||||
*
|
||||
* Returns:
|
||||
* 0 on success, any other number is an error code
|
||||
*/
|
||||
short txt_install(p_txt_device driver) {
|
||||
if (driver->number < MAX_TXT_DEVICES) {
|
||||
p_txt_device dev = &txt_devices[driver->number];
|
||||
|
||||
// Try to make a copy of the name
|
||||
dev->name = (char *)malloc(strlen(driver->name) + 1);
|
||||
if (dev->name != 0) {
|
||||
// Copy the driver data
|
||||
dev->number = driver->number;
|
||||
strcpy(dev->name, driver->name);
|
||||
dev->init = driver->init;
|
||||
dev->get_caps = driver->get_caps;
|
||||
dev->set_mode = driver->set_mode;
|
||||
dev->set_resolution = driver->set_resolution;
|
||||
dev->set_font = driver->set_font;
|
||||
dev->set_border = driver->set_border;
|
||||
dev->set_sizes = driver->set_sizes;
|
||||
dev->put = driver->put;
|
||||
dev->move = driver->move;
|
||||
dev->fill = driver->fill;
|
||||
|
||||
// Initialize the text display
|
||||
return dev->init();
|
||||
} else {
|
||||
// Could not allocate a copy of the device name
|
||||
return ERR_OUT_OF_MEMORY;
|
||||
}
|
||||
} else {
|
||||
// The device number was out of range
|
||||
return DEV_ERR_BADDEV;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Find the driver for device
|
||||
*
|
||||
* Inputs:
|
||||
* device = the number of the device
|
||||
*
|
||||
* Returns:
|
||||
* pointer to the device driver for that device, 0 if not found
|
||||
*/
|
||||
p_txt_device txt_find_device(short device) {
|
||||
p_txt_device dev = 0;
|
||||
|
||||
if (device < MAX_TXT_DEVICES) {
|
||||
dev = &txt_devices[device];
|
||||
if (dev != 0) {
|
||||
if (dev->number == 0) {
|
||||
// Found a record, but no driver was installed for it...
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return dev;
|
||||
}
|
||||
|
||||
/*
|
||||
* Get the list of supported display resolutions
|
||||
*
|
||||
* Inputs:
|
||||
* display = the number of the display
|
||||
*
|
||||
* Returns:
|
||||
* a pointer to a table describing the supported resolutions (w, h) in pixels of the display
|
||||
* A sentinel entry with w = h = 0 marks the end of the list.
|
||||
*/
|
||||
const p_rect txt_get_resolutions(short display) {
|
||||
p_txt_device dev = txt_find_device(display);
|
||||
if (dev != 0) {
|
||||
p_disp_caps capabilities = dev->get_caps();
|
||||
return capabilities->resolutions;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the base resolution of the display.
|
||||
* It is an error if the requested resolution is not supported.
|
||||
*
|
||||
* Inputs:
|
||||
* display = the number of the display
|
||||
* width = the number of pixels across
|
||||
* height = the number of pixels down
|
||||
*
|
||||
* Returns:
|
||||
* 0 on success, any other number means the requested resolution is not supported
|
||||
*/
|
||||
short txt_set_resolution(short display, short width, short height) {
|
||||
p_txt_device dev = txt_find_device(display);
|
||||
if (dev != 0) {
|
||||
dev->set_resolution(width, height);
|
||||
return 0;
|
||||
} else {
|
||||
return DEV_ERR_BADDEV;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Get the list of supported font sizes
|
||||
*
|
||||
* Inputs:
|
||||
* display = the number of the display
|
||||
*
|
||||
* Returns:
|
||||
* a pointer to a table describing the supported font sizes (w, h) in pixels
|
||||
* A sentinel entry with w = h = 0 marks the end of the list.
|
||||
*/
|
||||
const p_rect txt_get_font_sizes(short display) {
|
||||
p_txt_device dev = txt_find_device(display);
|
||||
if (dev != 0) {
|
||||
p_disp_caps capabilities = dev->get_caps();
|
||||
return capabilities->fonts;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the font (size and bitmap) for display
|
||||
* It is an error if the font size is not supported.
|
||||
*
|
||||
* Inputs:
|
||||
* display = the number of the display
|
||||
* width = the number of pixels across per character
|
||||
* height = the number of pixels down per character
|
||||
* data = pointer to the raw pixel data for the font
|
||||
*
|
||||
* Returns:
|
||||
* 0 on success, any other number means the requested resolution is not supported
|
||||
*/
|
||||
short txt_set_font(short display, short width, short height, unsigned char * data) {
|
||||
p_txt_device dev = txt_find_device(display);
|
||||
if (dev != 0) {
|
||||
dev->set_font(width, height, data);
|
||||
return 0;
|
||||
} else {
|
||||
return DEV_ERR_BADDEV;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the border of the display
|
||||
*
|
||||
* Inputs:
|
||||
* display = the number of the display
|
||||
* visible = 0 for disabled, 1 for enabled (visible)
|
||||
* horizontal = the width of the border in pixels
|
||||
* vertical = the height of the border in pixels
|
||||
* color = pointer to the color structure specifying the color of the border
|
||||
*/
|
||||
void txt_set_border(short display, short visible, short horizontal, short vertical, p_color3 color) {
|
||||
p_txt_device dev = txt_find_device(display);
|
||||
if (dev != 0) {
|
||||
dev->set_border(visible, width, height, color);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the display region to limit all character operations
|
||||
* Changes to the characters, scrolling, deleting, cursor positions, etc.
|
||||
* will be limited to the rectangular region provided.
|
||||
*
|
||||
* Setting a width or height of 0 in the region will reset the region to the
|
||||
* full screen, which is the default.
|
||||
*
|
||||
* Inputs:
|
||||
* display = the number of the display
|
||||
* region = pointer to rectangle describing the region (in character positions)
|
||||
*/
|
||||
void txt_set_region(short display, p_rect region) {
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the color of the text for future puts
|
||||
*
|
||||
* Inputs:
|
||||
* display = the number of the display
|
||||
* foreground = the color of the character
|
||||
* background = the color of the background
|
||||
*/
|
||||
void txt_set_colors(short display, short foreground, short background) {
|
||||
p_txt_device dev = txt_find_device(display);
|
||||
if (dev != 0) {
|
||||
dev->foreground = foreground;
|
||||
dev->background = background;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Setup the text cursor
|
||||
*
|
||||
* Inputs:
|
||||
* display = the number of the display
|
||||
* c = the character to display for the cursor
|
||||
* visible = 0 for invisible, any other number for visible
|
||||
* foreground = the color of the cursor foreground
|
||||
* background = the color of the cursor background
|
||||
* rate = the flash rate for the cursor
|
||||
*/
|
||||
void txt_set_cursor(short display, short visible, char c, short foreground, short background, short rate) {
|
||||
p_txt_device dev = txt_find_device(display);
|
||||
if (dev != 0) {
|
||||
dev->set_cursor(visible, c, foreground, background, rate);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Recompute shorternal size information about the display based on the hardware settings.
|
||||
*
|
||||
* This call allows the user program to alter VICKY registers itself and still allow the kernel text drivers
|
||||
* to display data correctly.
|
||||
*
|
||||
* Inputs:
|
||||
* display = the number of the display
|
||||
*/
|
||||
void txt_set_sizes(short display) {
|
||||
p_txt_device dev = txt_find_device(display);
|
||||
if (dev != 0) {
|
||||
dev->set_sizes();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the position of the cursor within the current region
|
||||
*
|
||||
* Inputs:
|
||||
* display = the number of the display
|
||||
* column = the horizontal position of the cursor (within the region)
|
||||
* row = the vertical position of the cursor (within the region)
|
||||
*/
|
||||
void txt_set_position(short display, short column, short row) {
|
||||
p_txt_device dev = txt_find_device(display);
|
||||
if (dev != 0) {
|
||||
dev->set_cursor(column, row);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Put a character on the screen at the cursor position
|
||||
*
|
||||
* Inputs:
|
||||
* display = the number of the display
|
||||
* c = the character to put on the display
|
||||
*/
|
||||
void txt_put(short display, char c) {
|
||||
p_txt_device dev = txt_find_device(display);
|
||||
if (dev != 0) {
|
||||
dev->set_put(c, dev->foreground, dev->background);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Clear all or part of the line the cursor is on (within the current region)
|
||||
*
|
||||
* Inputs:
|
||||
* display = the number of the display
|
||||
* mode = 2 = all, 1 = from cursor to end of line, 0 = from beginning of line to cursor
|
||||
*/
|
||||
void txt_clear_line(short display, short mode) {
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Clear all or part of the region
|
||||
*
|
||||
* Inputs:
|
||||
* display = the number of the display
|
||||
* mode = 2 = all, 1 = from cursor to end of region, 0 = from beginning of region to cursor
|
||||
*/
|
||||
void txt_clear(short display, short mode) {
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Insert a number of blanks at the cursor position
|
||||
*
|
||||
* Inputs:
|
||||
* display = the number of the display
|
||||
* n = number of blanks to insert
|
||||
*/
|
||||
void txt_insert(short display, short n) {
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Delete a number of blanks at the cursor position
|
||||
*
|
||||
* Inputs:
|
||||
* display = the number of the display
|
||||
* n = number of blanks to delete
|
||||
*/
|
||||
void txt_delete(short display, short n) {
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Scroll the current region horizontally or vertically
|
||||
*
|
||||
* Inputs:
|
||||
* display = the number of the display
|
||||
* horizontal = columns to scroll left (negative) or right (positive)
|
||||
* vertical = rows to scroll up (negative) or right (positive)
|
||||
*/
|
||||
void txt_scroll(short display, short horizontal, short vertical) {
|
||||
|
||||
}
|
|
@ -1,275 +0,0 @@
|
|||
/*
|
||||
* Text screen driver framework
|
||||
*/
|
||||
|
||||
#ifndef __TEXT_DEVICE_H
|
||||
#define __TEXT_DEVICE_H
|
||||
|
||||
#include "types.h"
|
||||
|
||||
/**
|
||||
* Flags to indicate which display capabilities are available and active
|
||||
*/
|
||||
const short MODE_TEXT = 0x01; // Display text
|
||||
const short MODE_BITMAP = 0x02; // Display a bitmap
|
||||
const short MODE_SPRITE = 0x04; // Display sprites
|
||||
const short MODE_TILE = 0x08; // Display tilesets
|
||||
const short MODE_BLANK = 0x10; // Display a blank screen
|
||||
const short MODE_DISABLE = 0x20; // Disable graphics engine
|
||||
|
||||
/**
|
||||
* Structure representing the capabilities of the display
|
||||
*/
|
||||
typedef struct s_disp_caps {
|
||||
short modes; // Flags indicating which display modes are supported
|
||||
const p_rect resolutions; // Array of rectangles listing supported screen resolutions (in pixels)
|
||||
const p_rect fonts; // Array of rectangles listing supported font sizes (in pixels)
|
||||
} t_disp_caps, *p_disp_caps;
|
||||
|
||||
/**
|
||||
* Driver function types
|
||||
*/
|
||||
typedef short (*p_txt_init)();
|
||||
typedef p_disp_caps (*p_txt_get_caps)();
|
||||
typedef void (*p_txt_set_mode)(short);
|
||||
typedef void (*p_txt_set_res)(short, short);
|
||||
typedef short (*p_txt_set_font)(p_rect, p_rect, char *);
|
||||
typedef void (*p_txt_set_border)(short, short, short, p_color3);
|
||||
typedef void (*p_txt_set_cursor)(short, char, short, short, short);
|
||||
typedef void (*p_txt_set_xy)(short, short);
|
||||
typedef p_rect (*p_txt_set_sizes)();
|
||||
typedef void (*p_txt_put)(char, short, short);
|
||||
typedef void (*p_txt_move)(p_rect, p_rect);
|
||||
typedef void (*p_txt_fill)(char, short, short, p_rect);
|
||||
|
||||
/**
|
||||
* Structure representing a low level text mode screen. This is essentially a text mode driver for a screen
|
||||
*
|
||||
* I anticipate that there will be several such drivers:
|
||||
* C256 -- A driver for the main screen, and a driver for the EVID
|
||||
* A2560U -- A single driver for its main screen. If an EVID ever comes out for it, there will be another for that
|
||||
* A2560K -- A driver for channel A, and a driver for channel B
|
||||
* A2560 GenX -- Probably similar to A2560K... might use the same drivers, if possible
|
||||
*
|
||||
* All coordinates and sizes used in the driver will be in native rows and columns of character cells
|
||||
* with the exception of the resolution and font size information, which will be in pixels.
|
||||
* Region support in the general text layer will be provided by the general code, not the driver
|
||||
*/
|
||||
typedef struct s_txt_device {
|
||||
short number; // Number of the text device
|
||||
const char * name; // Human readable name for the text device
|
||||
|
||||
short foreground; // The current foreground color
|
||||
short background; // The current background color
|
||||
|
||||
t_rect clip_region; // The current clipping region
|
||||
|
||||
p_txt_init init; // short init() -- Initialize the device
|
||||
p_txt_get_caps get_caps // p_disp_caps get_caps() -- Gets the capabilities of the display
|
||||
p_txt_set_mode set_mode; // void set_mode(short flags) -- Set the graphics modes
|
||||
p_txt_set_res set_resolution; // void set_resolution(short width, short height) -- Set the display resolution
|
||||
p_txt_set_font set_font; // short set_font(p_rect char_size, p_rect container_size, unsigned char * data) -- Set the font
|
||||
p_txt_set_border set_border; // void set_border(short visible, short width, short height, p_color3 color) -- Set the border
|
||||
p_txt_set_cursor set_cursor; // void set_cursor(short visible, char c, short foreground, short background, short rate) -- Set the cursor
|
||||
p_txt_set_xy set_xy; // void set_xy(short column, short row) -- Set the cursor's position
|
||||
p_txt_set_sizes set_sizes; // const p_rect set_sizes() -- Compute and return the text screen size
|
||||
p_txt_put put; // void put(char c, short foreground, short background) -- Put character and color at position
|
||||
p_txt_move move; // void move(p_rect from, p_rect to) -- Move character and color data
|
||||
p_txt_fill fill; // void fill(char c, short foreground, short background, p_rect to) -- Fill a rectangle with a character and color data
|
||||
} t_txt_device, *p_txt_device;
|
||||
|
||||
/*
|
||||
* Initialize the display system
|
||||
*/
|
||||
extern void txt_init();
|
||||
|
||||
/*
|
||||
* Install the device driver for a text display
|
||||
*
|
||||
* Inputs:
|
||||
* driver = pointer to the t_txt_device record for the text display
|
||||
*
|
||||
* Returns:
|
||||
* 0 on success, any other number is an error code
|
||||
*/
|
||||
extern short txt_install(p_txt_device driver);
|
||||
|
||||
/*
|
||||
* Get the list of supported display resolutions
|
||||
*
|
||||
* Inputs:
|
||||
* display = the number of the display
|
||||
*
|
||||
* Returns:
|
||||
* a poshorter to a table describing the supported resolutions (w, h) in pixels of the display
|
||||
* A sentinel entry with w = h = 0 marks the end of the list.
|
||||
*/
|
||||
extern const p_rect txt_get_resolutions(short display);
|
||||
|
||||
/*
|
||||
* Set the base resolution of the display.
|
||||
* It is an error if the requested resolution is not supported.
|
||||
*
|
||||
* Inputs:
|
||||
* display = the number of the display
|
||||
* width = the number of pixels across
|
||||
* height = the number of pixels down
|
||||
*
|
||||
* Returns:
|
||||
* 0 on success, any other number means the requested resolution is not supported
|
||||
*/
|
||||
extern short txt_set_resolution(short display, short width, short height);
|
||||
|
||||
/*
|
||||
* Get the list of supported font sizes
|
||||
*
|
||||
* Inputs:
|
||||
* display = the number of the display
|
||||
*
|
||||
* Returns:
|
||||
* a poshorter to a table describing the supported font sizes (w, h) in pixels
|
||||
* A sentinel entry with w = h = 0 marks the end of the list.
|
||||
*/
|
||||
extern const p_rect txt_get_font_sizes(short display);
|
||||
|
||||
/*
|
||||
* Set the font (size and bitmap) for display
|
||||
* It is an error if the font size is not supported.
|
||||
*
|
||||
* Inputs:
|
||||
* display = the number of the display
|
||||
* width = the number of pixels across per character
|
||||
* height = the number of pixels down per character
|
||||
* data = poshorter to the raw pixel data for the font
|
||||
*
|
||||
* Returns:
|
||||
* 0 on success, any other number means the requested resolution is not supported
|
||||
*/
|
||||
extern short txt_set_font(short display, short width, short height, unsigned char * data);
|
||||
|
||||
/*
|
||||
* Set the border of the display
|
||||
*
|
||||
* Inputs:
|
||||
* display = the number of the display
|
||||
* visible = 0 for disabled, 1 for enabled (visible)
|
||||
* horizontal = the width of the border in pixels
|
||||
* vertical = the height of the border in pixels
|
||||
* color = pointer to the color structure specifying the color of the border
|
||||
*/
|
||||
extern void txt_set_border(short display, short visible, short horizontal, short vertical, p_color3 color);
|
||||
|
||||
/*
|
||||
* Set the display region to limit all character operations
|
||||
* Changes to the characters, scrolling, deleting, cursor positions, etc.
|
||||
* will be limited to the rectangular region provided.
|
||||
*
|
||||
* Setting a width or height of 0 in the region will reset the region to the
|
||||
* full screen, which is the default.
|
||||
*
|
||||
* Inputs:
|
||||
* display = the number of the display
|
||||
* region = poshorter to rectangle describing the region (in character positions)
|
||||
*/
|
||||
extern void txt_set_region(short display, p_rect region);
|
||||
|
||||
/*
|
||||
* Set the color of the text for future puts
|
||||
*
|
||||
* Inputs:
|
||||
* display = the number of the display
|
||||
* foreground = the color of the character
|
||||
* background = the color of the background
|
||||
*/
|
||||
extern void txt_set_colors(short display, short foreground, short background);
|
||||
|
||||
/*
|
||||
* Setup the text cursor
|
||||
*
|
||||
* Inputs:
|
||||
* display = the number of the display
|
||||
* c = the character to display for the cursor
|
||||
* visible = 0 for invisible, any other number for visible
|
||||
* foreground = the color of the cursor foreground
|
||||
* background = the color of the cursor background
|
||||
* rate = the flash rate for the cursor
|
||||
*/
|
||||
extern void txt_set_cursor(short display, short visible, char c, short foreground, short background, short rate);
|
||||
|
||||
/*
|
||||
* Recompute shorternal size information about the display based on the hardware settings.
|
||||
*
|
||||
* This call allows the user program to alter VICKY registers itself and still allow the kernel text drivers
|
||||
* to display data correctly.
|
||||
*
|
||||
* Inputs:
|
||||
* display = the number of the display
|
||||
*/
|
||||
extern void txt_set_sizes(short display);
|
||||
|
||||
/*
|
||||
* Set the position of the cursor within the current region
|
||||
*
|
||||
* Inputs:
|
||||
* display = the number of the display
|
||||
* column = the horizontal position of the cursor (within the region)
|
||||
* row = the vertical position of the cursor (within the region)
|
||||
*/
|
||||
extern void txt_set_position(short display, short column, short row);
|
||||
|
||||
/*
|
||||
* Put a character on the screen at the cursor position
|
||||
*
|
||||
* Inputs:
|
||||
* display = the number of the display
|
||||
* c = the character to put on the display
|
||||
*/
|
||||
extern void txt_put(short display, char c);
|
||||
|
||||
/*
|
||||
* Clear all or part of the line the cursor is on (within the current region)
|
||||
*
|
||||
* Inputs:
|
||||
* display = the number of the display
|
||||
* mode = 2 = all, 1 = from cursor to end of line, 0 = from beginning of line to cursor
|
||||
*/
|
||||
extern void txt_clear_line(short display, short mode);
|
||||
|
||||
/*
|
||||
* Clear all or part of the region
|
||||
*
|
||||
* Inputs:
|
||||
* display = the number of the display
|
||||
* mode = 2 = all, 1 = from cursor to end of region, 0 = from beginning of region to cursor
|
||||
*/
|
||||
extern void txt_clear_region(short display, short mode);
|
||||
|
||||
/*
|
||||
* Insert a number of blanks at the cursor position
|
||||
*
|
||||
* Inputs:
|
||||
* display = the number of the display
|
||||
* n = number of blanks to insert
|
||||
*/
|
||||
extern void txt_insert(short display, short n);
|
||||
|
||||
/*
|
||||
* Delete a number of blanks at the cursor position
|
||||
*
|
||||
* Inputs:
|
||||
* display = the number of the display
|
||||
* n = number of blanks to delete
|
||||
*/
|
||||
extern void txt_delete(short display, short n);
|
||||
|
||||
/*
|
||||
* Scroll the current region horizontally or vertically
|
||||
*
|
||||
* Inputs:
|
||||
* display = the number of the display
|
||||
* horizontal = columns to scroll left (negative) or right (positive)
|
||||
* vertical = rows to scroll up (negative) or right (positive)
|
||||
*/
|
||||
extern void txt_scroll(short display, short horizontal, short vertical);
|
||||
|
||||
#endif
|
|
@ -24,6 +24,10 @@
|
|||
#include "dev/console.h"
|
||||
#include "dev/fdc.h"
|
||||
#include "dev/text_screen_iii.h"
|
||||
|
||||
#include "dev/txt_screen.h"
|
||||
#include "dev/txt_a2560k_a.h"
|
||||
|
||||
#include "dev/pata.h"
|
||||
#include "dev/ps2.h"
|
||||
#include "dev/rtc.h"
|
||||
|
@ -190,6 +194,16 @@ void initialize() {
|
|||
ind_init();
|
||||
log(LOG_INFO, "Indicators initialized");
|
||||
|
||||
// txt_init();
|
||||
// if (res = txt_a2560k_a_install()) {
|
||||
// log(LOG_ERROR, "Could not install A2560K Channel A driver");
|
||||
// } else {
|
||||
// log(LOG_ERROR, "A2560K Channel A driver installed");
|
||||
// }
|
||||
// txt_init_screen(TXT_SCREEN_A2560K_A);
|
||||
//
|
||||
// while (1) ;
|
||||
|
||||
/* Initialize the interrupt system */
|
||||
int_init();
|
||||
|
||||
|
|
9049
src/foenixmcp.s68
9049
src/foenixmcp.s68
File diff suppressed because it is too large
Load diff
|
@ -135,11 +135,6 @@ clrloop: move.l #0,(a0)+
|
|||
subq.l #4,d0
|
||||
bne clrloop
|
||||
|
||||
; Set TRAP #15 vector handler
|
||||
lea h_trap_15,a0 ; Address of the handler
|
||||
move.l #(13+32)<<2,a1 ; TRAP#15 vector address
|
||||
move.l a0,(a1) ; Set the vector
|
||||
|
||||
callmain: jsr ___main ; call __main to transfer to the C code
|
||||
|
||||
; endless loop; can be changed accordingly
|
||||
|
|
17834
src/mapfile
17834
src/mapfile
File diff suppressed because it is too large
Load diff
|
@ -1,3 +1,7 @@
|
|||
#ifndef __BM437_IBM_Model3_Alt4_H
|
||||
#define __BM437_IBM_Model3_Alt4_H
|
||||
|
||||
|
||||
// Filename : BM437_IBM_Alt4_RevB.c
|
||||
// Font Size : 8x16
|
||||
// Memory usage : 4085 bytes
|
||||
|
@ -266,3 +270,9 @@ const unsigned char BM437_IBM_Model3_Alt4[] = {
|
|||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3C, 0x3C, 0x3C, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // #254
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // #255
|
||||
};
|
||||
|
||||
#else
|
||||
|
||||
extern const unsigned char BM437_IBM_Model3_Alt4[];
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
unsigned char MSX_CP437_8x8_bin[] = {
|
||||
const unsigned char MSX_CP437_8x8_bin[] = {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x81, 0xa5, 0x81,
|
||||
0xbd, 0x99, 0x81, 0x7e, 0x7e, 0xff, 0xdb, 0xff, 0xff, 0xc3, 0xe7, 0x7e,
|
||||
0x00, 0x6c, 0xfe, 0xfe, 0x7c, 0x38, 0x10, 0x00, 0x10, 0x38, 0x7c, 0xfe,
|
||||
|
|
|
@ -7,6 +7,6 @@
|
|||
|
||||
#define VER_MAJOR 0
|
||||
#define VER_MINOR 3
|
||||
#define VER_BUILD 1
|
||||
#define VER_BUILD 2
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue