1
0
Fork 0

added support for echoing characters

Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@557
This commit is contained in:
Peter Veenstra 2002-12-03 17:27:59 +00:00
parent 84e09e2a65
commit 581774e9bc
3 changed files with 45 additions and 17 deletions

View file

@ -16,6 +16,8 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "dos_inc.h"
class device_CON : public DOS_Device {
public:
device_CON();
@ -27,13 +29,18 @@ public:
private:
Bit8u cache;
};
void INT10_TeletypeOutput(Bit8u chr,Bit8u attr,bool showattr, Bit8u page);
bool device_CON::Read(Bit8u * data,Bit16u * size) {
Bit16u oldax=reg_ax;
Bit16u count=0;
if ((cache) && (*size)) {
data[count++]=cache;
cache=0;
if(dos.echo) {
INT10_TeletypeOutput(cache,7,false,0);
}
cache=0;
}
while (*size>count) {
reg_ah=0;
@ -41,11 +48,22 @@ bool device_CON::Read(Bit8u * data,Bit16u * size) {
switch(reg_al) {
case 13:
data[count++]=0x0D;
if (*size>count) data[count++]=0x0A;
//else cache=0x0A; // it's only expanded if there is room for it.
*size=count;
if (*size>count) data[count++]=0x0A; // it's only expanded if there is room for it. (NO cache)
*size=count;
reg_ax=oldax;
return true;
break;
case 8:
if(*size==1) data[count++]=reg_al; //one char at the time so give back that BS
else if(count) { //Remove data if it exists (extended keys don't go right)
data[count--]=0;
INT10_TeletypeOutput(8,7,false,0);
INT10_TeletypeOutput(' ',7,false,0);
} else {
continue; //no data read yet so restart whileloop.
}
break;
default:
data[count++]=reg_al;
break;
@ -54,14 +72,18 @@ bool device_CON::Read(Bit8u * data,Bit16u * size) {
if (*size>count) data[count++]=reg_ah;
else cache=reg_ah;
break;
}
}
if(dos.echo) { //what to do if *size==1 and character is BS ?????
INT10_TeletypeOutput(reg_al,7,false,0);
}
}
*size=count;
reg_ax=oldax;
return true;
}
extern void INT10_TeletypeOutput(Bit8u chr,Bit8u attr,bool showattr, Bit8u page);
bool device_CON::Write(Bit8u * data,Bit16u * size) {
Bit16u count=0;
while (*size>count) {

View file

@ -46,9 +46,11 @@ static Bitu DOS_21Handler(void) {
case 0x01: /* Read character from STDIN, with echo */
{
Bit8u c;Bit16u n=1;
dos.echo=true;
DOS_ReadFile(STDIN,&c,&n);
reg_al=c;
DOS_WriteFile(STDOUT,&c,&n);
dos.echo=false;
}
break;
case 0x02: /* Write character to STDOUT */
@ -452,6 +454,7 @@ static Bitu DOS_21Handler(void) {
case 0x3f: /* READ Read from file or device */
{
Bit16u toread=reg_cx;
dos.echo=true;
if (DOS_ReadFile(reg_bx,dos_copybuf,&toread)) {
MEM_BlockWrite(SegPhys(ds)+reg_dx,dos_copybuf,toread);
reg_ax=toread;
@ -460,6 +463,7 @@ static Bitu DOS_21Handler(void) {
reg_ax=dos.errorcode;
CALLBACK_SCF(true);
}
dos.echo=false;
break;
}
case 0x40: /* WRITE Write to file or device */
@ -806,19 +810,20 @@ static Bitu DOS_21Handler(void) {
CALLBACK_SCF(true);
LOG_WARN("DOS:Windows long file name support call %2X",reg_al);
break;
case 0x68: /* FFLUSH Commit file */
case 0xE0:
case 0x18: /* NULL Function for CP/M compatibility or Extended rename FCB */
case 0x1d: /* NULL Function for CP/M compatibility or Extended rename FCB */
case 0x1e: /* NULL Function for CP/M compatibility or Extended rename FCB */
case 0x20: /* NULL Function for CP/M compatibility or Extended rename FCB */
case 0x6b: /* NULL Function */
case 0x61: /* UNUSED */
case 0x63: /* Weirdo double byte stuff (fails but say it succeeded) */
case 0x68: /* FFLUSH Commit file */
case 0x63: /* Weirdo double byte stuff (fails but say it succeeded) available only in MSDOS 2.25 */
CALLBACK_SCF(false); //mirek
case 0xE0:
case 0x18: /* NULL Function for CP/M compatibility or Extended rename FCB */
case 0x1d: /* NULL Function for CP/M compatibility or Extended rename FCB */
case 0x1e: /* NULL Function for CP/M compatibility or Extended rename FCB */
case 0x20: /* NULL Function for CP/M compatibility or Extended rename FCB */
case 0x6b: /* NULL Function */
case 0x61: /* UNUSED */
case 0xEF: /* Used in Ancient Art Of War CGA */
case 0x5d: /* Network Functions */
default:
LOG_DEBUG("DOS:Unhandled call %02X al=%02X. Set al to default of 0 no carry",reg_ah,reg_al);
LOG_DEBUG("DOS:Unhandled call %02X al=%02X. Set al to default of 0",reg_ah,reg_al);
reg_al=0x00; /* default value */
break;
};

View file

@ -47,6 +47,7 @@ void DOS_Shell::InputCommand(char * line) {
Bitu str_len=0;Bitu str_index=0;
while (size) {
dos.echo=false;
DOS_ReadFile(input_handle,&c,&n);
if (!n) {
size=0; //Kill the while loop