Add command to test the bitmap background

This commit is contained in:
Vincent Barrilliot 2023-11-12 18:30:38 +01:00
parent 8952c193c3
commit 6ded32fc94
2 changed files with 55 additions and 16 deletions

View file

@ -920,8 +920,34 @@ static short cli_test_textscroll (short screen, int argc, const char * argv[]) {
return 0; return 0;
} }
static short cli_test_background (short screen, int argc, const char * argv[]) {
if (argc != 2) {
print (screen, "AARRGGBB color code missing.");
return 0;
}
uint32_t jiffies = sys_time_jiffies() + 60*3;
uint32_t old_ctrl = *MasterControlReg_A;
uint32_t old_rgb = *BackGroundControlReg_A;
uint32_t rgb = (uint32_t)cli_eval_number(argv[1]);
*MasterControlReg_A = (old_ctrl & 0xfffffff0) | (VKY3_MCR_TEXT_EN|VKY3_MCR_TEXT_OVRLY|VKY3_MCR_GRAPH_EN);
*BackGroundControlReg_A = rgb;
// Wait a bit
while (sys_time_jiffies() < jiffies);
*MasterControlReg_A = old_ctrl; // Bitmap+screen overlay
*BackGroundControlReg_A = old_rgb;
return 0;
}
const t_cli_test_feature cli_test_features[] = { const t_cli_test_feature cli_test_features[] = {
{"ANSI", "ANSI: test the ANSI escape codes", cmd_test_ansi}, {"ANSI", "ANSI: test the ANSI escape codes", cmd_test_ansi},
{"BACKGROUND", "BACKGROUND <0xaarrggbb>: set the background color to the give RGB color", cli_test_background},
{"BITMAP", "BITMAP: test the bitmap screen", cli_test_bitmap}, {"BITMAP", "BITMAP: test the bitmap screen", cli_test_bitmap},
{"CREATE", "CREATE <path>: test creating a file", cli_test_create}, {"CREATE", "CREATE <path>: test creating a file", cli_test_create},
{"IDE", "IDE: test reading the MBR of the IDE drive", cli_test_ide}, {"IDE", "IDE: test reading the MBR of the IDE drive", cli_test_ide},

View file

@ -132,20 +132,33 @@ static void txt_a2560u_get_sizes(p_extent text_size, p_extent pixel_size) {
*/ */
static short txt_a2560u_set_mode(short mode) { static short txt_a2560u_set_mode(short mode) {
/* Turn off anything not set */ /* Turn off anything not set */
msr_shadow &= ~(TXT_MODE_SLEEP | TXT_MODE_TEXT); uint32_t old_msr = *MasterControlReg_A;
uint32_t new_msr = old_msr & ~(VKY3_MCR_BLANK_EN|VKY3_MCR_TEXT_EN|VKY3_MCR_TEXT_OVRLY|VKY3_MCR_GRAPH_EN|VKY3_MCR_BITMAP_EN); // Mask out bits we'll set here
if (mode & TXT_MODE_SLEEP) { if (mode & TXT_MODE_SLEEP) {
/* Put the monitor to sleep */ /* Put the monitor to sleep (preserve settings) */
msr_shadow |= VKY3_MCR_BLANK_EN; new_msr |= VKY3_MCR_BLANK_EN;
} else {
if (mode & TXT_MODE_TEXT) {
new_msr |= VKY3_MCR_TEXT_EN;
} else if (mode & TXT_MODE_BITMAP) {
new_msr |= VKY3_MCR_BITMAP_EN|VKY3_MCR_GRAPH_EN/*Is this really required?*/;
// Disable gamma (as I'm not sure it functional, but I may as well not understand it)
new_msr |= VKY3_MCR_GAMMA_EN;
new_msr &= ~VKY3_MCR_MANUAL_GAMMA_EN;
}
/* If we want text and graphics, enable the overlay mode */
if ((mode & (TXT_MODE_BITMAP|TXT_MODE_TEXT)) == (TXT_MODE_BITMAP|TXT_MODE_TEXT)) {
// It seems just doing 'new_msr |= VKY3_MCR_TEXT_OVRLY' doesn't work
new_msr |= (VKY3_MCR_TEXT_EN|VKY3_MCR_TEXT_OVRLY|VKY3_MCR_GRAPH_EN|VKY3_MCR_BITMAP_EN);
}
}
if (new_msr != old_msr) {
msr_shadow = new_msr;
*MasterControlReg_A = msr_shadow; *MasterControlReg_A = msr_shadow;
return 0; return 0;
} else if (mode & TXT_MODE_TEXT) {
/* Put on text mode */
msr_shadow |= VKY3_MCR_TEXT_EN;
*MasterControlReg_A = msr_shadow;
return 0;
} else { } else {
/* Unsupported mode */ /* Unsupported mode */
return -1; return -1;
@ -382,14 +395,14 @@ static short txt_a2560u_set_color(unsigned char foreground, unsigned char backgr
* (possibly color as well ?) are inverted. Ie if the memory contains AB, A beint on an * (possibly color as well ?) are inverted. Ie if the memory contains AB, A beint on an
* even address, then when reading A you'll get B and reading B you'll get A. This * even address, then when reading A you'll get B and reading B you'll get A. This
* functions can be removed if the FPGA is corrected. */ * functions can be removed if the FPGA is corrected. */
static char read_swapped_byte(char *addr) { static char read_swapped_byte(const uint8_t *addr) {
if ((long)addr & 1) { if ((long)addr & 1) {
short w = *(short*)(addr-1); uint16_t w = *(uint16_t*)(addr-1);
return (char)w; return (char)w;
} }
else { else {
short w = *(short*)(addr); uint16_t w = *(uint16_t*)(addr);
return ((char*)&w)[0]; return ((uint8_t*)&w)[0];
} }
} }
@ -447,8 +460,8 @@ static void txt_a2560u_scroll(short horizontal, short vertical) {
} }
/* Copy the rectangle. We can't copy byte by byte, they get swapped (FPGA bug) */ /* Copy the rectangle. We can't copy byte by byte, they get swapped (FPGA bug) */
char * const text_mem = (char*)ScreenText_A; volatile uint8_t * const text_mem = ScreenText_A;
char * const color_mem = (char*)ColorText_A; volatile uint8_t * const color_mem = ColorText_A;
int delta_y = dy * a2560u_max_size.width; int delta_y = dy * a2560u_max_size.width;
int row_dst = y0 * a2560u_max_size.width - delta_y; int row_dst = y0 * a2560u_max_size.width - delta_y;