menu option to print current DOS screen

This commit is contained in:
Wengier
2021-05-20 19:45:32 -04:00
parent b12c94fd76
commit e86c764dd2
5 changed files with 51 additions and 5 deletions

View File

@@ -48,6 +48,9 @@
for printing too when using TTF output. (Wengier)
- Improved handling of Ctrl+C/Ctrl+Break for shell-
based DOS programs. (Wengier)
- Added menu option "Print text screen" (under "DOS")
to print current DOS text screen, if the printer
feature has been enabled. (Wengier)
- Added menu options "Display TTF blinking cursor",
"CJK: Switch DBCS/SBCS mode", and "CJK: Auto-detect
box-drawing symbols" under "Video" => "TTF options"

View File

@@ -518,6 +518,7 @@ static const char *def_menu_dos[] =
"--",
"mapper_rescanall",
#if C_PRINTER
"print_textscreen",
"mapper_ejectpage",
#endif
NULL

View File

@@ -863,6 +863,27 @@ bool list_ideinfo_menu_callback(DOSBoxMenu * const menu,DOSBoxMenu::item * const
return true;
}
#if C_PRINTER
bool PRINTER_isInited();
void PrintScreen(const char *text, uint16_t len);
bool print_screen_menu_callback(DOSBoxMenu * const menu,DOSBoxMenu::item * const menuitem) {
(void)menu;//UNUSED
(void)menuitem;//UNUSED
if (!PRINTER_isInited()) {
systemmessagebox("Error","Printer support is not enabled in the configuration.","ok", "error", 1);
return false;
}
if (!CurMode||CurMode->type!=M_TEXT) {
systemmessagebox("Error","The current DOS screen is not in text mode.","ok", "error", 1);
return false;
}
uint16_t len=0;
const char* text = Mouse_GetSelected(0,0,(int)(currentWindowWidth-1-sdl.clip.x),(int)(currentWindowHeight-1-sdl.clip.y),(int)(currentWindowWidth-sdl.clip.x),(int)(currentWindowHeight-sdl.clip.y), &len);
if (len) PrintScreen(text, len);
return true;
}
#endif
const char *drive_opts[][2] = {
#if defined(WIN32)
{ "mountauto", "Auto-mount Windows drive" },
@@ -13825,7 +13846,9 @@ int main(int argc, char* argv[]) SDL_MAIN_NOEXCEPT {
mainMenu.alloc_item(DOSBoxMenu::item_type_id,"make_diskimage").set_text("Create blank disk image...").set_callback_function(make_diskimage_menu_callback);
mainMenu.alloc_item(DOSBoxMenu::item_type_id,"list_drivenum").set_text("Show mounted drive numbers").set_callback_function(list_drivenum_menu_callback);
mainMenu.alloc_item(DOSBoxMenu::item_type_id,"list_ideinfo").set_text("Show IDE disk or CD status").set_callback_function(list_ideinfo_menu_callback);
#if C_PRINTER
mainMenu.alloc_item(DOSBoxMenu::item_type_id,"print_textscreen").set_text("Print text screen").set_callback_function(print_screen_menu_callback);
#endif
mainMenu.alloc_item(DOSBoxMenu::item_type_id,"pc98_use_uskb").set_text("Use US keyboard layout").set_callback_function(pc98_force_uskb_menu_callback).check(pc98_force_ibm_layout);
MSG_Init();
@@ -13901,7 +13924,9 @@ int main(int argc, char* argv[]) SDL_MAIN_NOEXCEPT {
mainMenu.get_item("ttf_dbcs_sbcs").enable(TTF_using()&&!IS_PC98_ARCH&&enable_dbcs_tables).check(dbcs_sbcs);
mainMenu.get_item("ttf_autoboxdraw").enable(TTF_using()&&!IS_PC98_ARCH&&enable_dbcs_tables).check(autoboxdraw);
#endif
#if C_PRINTER
mainMenu.get_item("print_textscreen").enable(!IS_PC98_ARCH);
#endif
mainMenu.get_item("pc98_5mhz_gdc").enable(IS_PC98_ARCH);
mainMenu.get_item("pc98_allow_200scanline").enable(IS_PC98_ARCH);
mainMenu.get_item("pc98_allow_4partitions").enable(IS_PC98_ARCH);

View File

@@ -32,6 +32,7 @@
#include "timer.h"
#include "render.h"
#include "dos_inc.h"
#include "../../ints/int10.h"
#if defined(USE_TTF)
extern unsigned char DOSBoxTTFbi[48868];
@@ -1440,6 +1441,15 @@ void CPrinter::printChar(uint8_t ch, int box)
dbcs=true;
lastlead=false;
lasttick=0;
} else if (lastlead && ch<0x40 && lastchar && lasttick) {
if (box!=0) {
box2=box3=false;
last3=last2=0;
}
ll=lastchar;
lastlead=false;
lastchar=lasttick=0;
printChar(ll, 1);
} else {
if (box!=0) box2=box3=false;
for (int i=0; i<6; i++) lead[i] = 0;
@@ -1447,7 +1457,7 @@ void CPrinter::printChar(uint8_t ch, int box)
lead[i] = mem_readb(Real2Phys(dos.tables.dbcs)+i);
if (lead[i] == 0) break;
}
lastlead=isDBCSLB(ch, lead);
lastlead=box==1?0:isDBCSLB(ch, lead);
if (lastlead) {
lastchar=ch;
lasttick=GetTicks();
@@ -2369,6 +2379,13 @@ static void FormFeed(bool pressed)
}
}
const char* Mouse_GetSelected(int x1, int y1, int x2, int y2, int w, int h, uint16_t *textlen);
void PrintScreen(const char *text, uint16_t len)
{
if (!defaultPrinter) defaultPrinter = new CPrinter(confdpi, confwidth, confheight, confoutputDevice, confmultipageOutput);
for (int i=0; i<len; i++) defaultPrinter->printChar(text[i]);
FormFeed(true);
}
static void PRINTER_EventHandler(Bitu param)
{

View File

@@ -720,8 +720,6 @@ uint8_t Mouse_GetButtonState(void) {
return mouse.buttons;
}
#if defined(WIN32) || defined(MACOSX) || defined(C_SDL2)
#include "render.h"
char text[5000];
extern bool isDBCSCP();
const char* Mouse_GetSelected(int x1, int y1, int x2, int y2, int w, int h, uint16_t *textlen) {
@@ -788,6 +786,8 @@ const char* Mouse_GetSelected(int x1, int y1, int x2, int y2, int w, int h, uint
return text;
}
#if defined(WIN32) || defined(MACOSX) || defined(C_SDL2)
#include "render.h"
void Mouse_Select(int x1, int y1, int x2, int y2, int w, int h, bool select) {
int c1=x1, r1=y1, c2=x2, r2=y2, t;
uint8_t page = real_readb(BIOSMEM_SEG,BIOSMEM_CURRENT_PAGE);