📄 cdosx32.c
字号:
EAX = sys_read(BX, EDX, ECX);
if ((long) EAX < 0) {
EAX = - (long)EAX;
return CARRY_ON;
} else
return CARRY_OFF;
case 0x40: /* WRITE to file */
if (EDX != iobuf_linear) {
TEST_ILLEGAL_WRITE(EDX, ECX);
}
EAX = sys_write(BX, EDX, ECX);
if ((long)EAX < 0) {
EAX = - (long)EAX;
return CARRY_ON;
} else
return CARRY_OFF;
case 0x38: /* GET COUNTRY INFO */
if (DX != 0xFFFF) {
TEST_ILLEGAL_WRITE(EDX, 34);
put_regs(&tr);
SET_SEG_OFF(iobuf, tr.ds, tr.edx);
if (!realdos(&tr))
cpy16_32(DS, EDX, iobuf, 34L);
get_regs(&tr);
} else {
put_regs(&tr);
realdos(&tr);
get_regs(&tr);
}
return CARRY_NON;
case 0x47: /* GET CURR DIRECTORY */
TEST_ILLEGAL_WRITE(ESI, 64);
put_regs(&tr);
SET_SEG_OFF(iobuf, tr.ds, tr.esi);
if (!realdos(&tr))
cpy16_32(DS, ESI, iobuf, 64L);
get_regs(&tr);
return CARRY_NON;
case 0x4e: /* FINDFIRST */
/* DTA: iobuf byte 0-42 , wild _string: iobuf + 64 */
if (npz->p_flags & PF_EMX_FILE) {
/* set dta address to iobuf */
user_dta = ESI;
SET_SEG_OFF(iobuf, tr.ds, tr.edx);
tr.eax = 0x1a00;
realdos(&tr);
}
TEST_ILLEGAL(EDX, 2);
TEST_ILLEGAL_WRITE(user_dta, 43);
strcpy32_16(DS, EDX, iobuf + 64);
tr.eax = EAX;
tr.ecx = ECX;
SET_SEG_OFF((iobuf+64), tr.ds, tr.edx);
if (realdos(&tr))
EAX = tr.eax;
else
cpy16_32(DS, user_dta, iobuf, 43);
FLAGS = tr.flags;
return CARRY_NON;
case 0x4f: /* FINDNEXT */
/* DTA: iobuf byte 0-42 */
if (npz->p_flags & PF_EMX_FILE) {
user_dta = ESI;
SET_SEG_OFF(iobuf, tr.ds, tr.edx);
tr.eax = 0x1a00;
/* set dta address */
realdos(&tr);
}
TEST_ILLEGAL_WRITE(user_dta, 43);
/* put user dta in iobuf */
cpy32_16(DS, user_dta, iobuf, 43);
tr.eax = EAX;
if (realdos(&tr))
EAX = tr.eax;
else
cpy16_32(DS, user_dta, iobuf, 43);
FLAGS = tr.flags;
return CARRY_NON;
/*
** some special handling
*/
case 0x1a: /* SET DTA */
TEST_ILLEGAL(EDX, 2);
user_dta = EDX;
tr.eax = 0x1a00;
SET_SEG_OFF(iobuf, tr.ds, tr.edx);
realdos(&tr);
return CARRY_OFF;
case 0x2f: /* GET DTA */
EBX = user_dta;
return CARRY_OFF;
case 0x62: /* GET PSP */
EBX = (DWORD) _psp;
return CARRY_OFF;
/*
** functions complete changed
** need to call DPMI-functions
*/
case 0x48: /* ALLOC MEM */
case 0x49: /* FREE MEM */
EAX = EMX_EIO;
return CARRY_ON;
case 0x4a: /* RESIZE MEM */
if (npz->p_flags & PF_EMX_FILE) {
EAX = EMX_EIO;
return CARRY_ON;
} else {
if (EAX & 0xff)
EAX = getmem(EBX, npz);
else
EAX = npz->brk_value;
if (EAX == -1)
EAX = 0;
return CARRY_OFF; /* sbrk.s didn't check carry */
}
case 0x4c:
return do_exit4c(0);
case 0x4d:
{
unsigned status = 0;
/* sys_wait(&status); */
AX = status >> 8; /* al = return code */
return CARRY_OFF;
}
default:
printf("Warning: Not implemented DOS function ah=%02X\n", rAH);
EAX = EMX_EIO;
return CARRY_ON;
} /* switch R_AH */
}
#include "DJIO.H"
/*
** read for dos handles
*/
ARGUSER cdosx_read(int handle, ARGUSER buf, ARGUSER count)
{
long org_bytes;
int iob_bytes;
int ret_bytes;
/* termio check */
if ((npz->p_flags & PF_TERMIO) && rm_isatty(handle)) {
if ((ret_bytes = termio_read(DS, buf, (int)count)) < 0) {
emx_errno = -ret_bytes;
return -1;
} else
return ret_bytes;
}
if ((npz->p_flags & PF_DJGPP_FILE) && buf == (ARGUSER)iobuf_linear)
return dj_read(handle, iobuf+4096, (unsigned)count);
org_bytes = count;
while (count > 0) {
iob_bytes = (count <= IOBUF_SIZE) ? (int) count : IOBUF_SIZE;
if (npz->p_flags & PF_DJGPP_FILE) {
if ((ret_bytes = dj_read(handle, iobuf, iob_bytes)) == -1)
return -(long)errno_djgpp(emx_errno);
} else {
if ((ret_bytes = rm_read(handle, iobuf, iob_bytes)) == -1)
return -(long)emx_errno;
}
cpy16_32(DS, buf, iobuf, (long) ret_bytes);
count -= (long) ret_bytes;
if (ret_bytes < iob_bytes) /* EOF */
break;
buf += ret_bytes;
}
return (org_bytes - count);
}
/*
** write for dos handles
*/
ARGUSER cdosx_write(int handle, ARGUSER buf, ARGUSER count)
{
long org_bytes;
int iob_bytes;
int ret_bytes;
if (!count)
return (ARGUSER) rm_write(handle, &iobuf, 0);
if ((npz->p_flags & PF_DJGPP_FILE) && buf == (ARGUSER) iobuf_linear)
return dj_write(handle, iobuf+4096, (unsigned)count);
org_bytes = count;
while (count > 0) {
iob_bytes = (count <= IOBUF_SIZE) ? (int) count : IOBUF_SIZE;
cpy32_16(DS, buf, iobuf, (long)iob_bytes);
if (npz->p_flags & PF_DJGPP_FILE) {
if ((ret_bytes = dj_write(handle, iobuf, iob_bytes)) == -1)
return -(long)errno_djgpp(emx_errno);
} else {
if ((ret_bytes = rm_write(handle, iobuf, iob_bytes)) == -1)
return -(long)emx_errno;
}
count -= (long) ret_bytes;
if (ret_bytes < iob_bytes) /* disk full */
break;
buf += ret_bytes;
}
return (org_bytes - count);
}
typedef union {
unsigned long flat;
struct FarPtr {
unsigned short off16;
unsigned short seg16;
} farptr;
} PTR;
#pragma pack(1)
typedef struct {
char signatur[4];
char version[2];
PTR oem_name;
char capabilities[4];
PTR modes;
char blocks[2];
} VESAINFO;
#pragma pack()
static unsigned real_mode_vio10(TRANSLATION *pTrans)
{
pTrans->sp = pTrans->ss = 0;
pTrans->flags = 0x3200;
return SimulateRMint(0x10, 0, 0, pTrans);
}
static unsigned real_mode_mou33(TRANSLATION *pTrans)
{
pTrans->sp = pTrans->ss = 0;
pTrans->flags = 0x3200;
return SimulateRMint(0x33, 0, 0, pTrans);
}
/*
** support for vesa modes ah = 0x4F, al = 00 - 08
*/
static void vio10(void)
{
unsigned char rAH, rAL;
TRANSLATION tr;
VESAINFO *pInfo;
DWORD offset;
rAH = (BYTE) (AX >> 8);
rAL = (BYTE) EAX;
if (rAH != 0x4F)
return;
switch (rAL) {
case 0x00:
SET_SEG_OFF(iobuf, tr.es, tr.edi);
put_regs(&tr);
real_mode_vio10(&tr);
if ((tr.eax & 0xFF) != 0x4f)
break;
else
EAX = tr.eax; /* success */
pInfo = (VESAINFO *) iobuf;
offset = ((DWORD) pInfo->oem_name.farptr.seg16 << 4)
+ (DWORD) pInfo->oem_name.farptr.off16;
pInfo->oem_name.flat = (dpmi10) ?
offset + DPMI_PRG_DATA :
offset - npz->memaddress;
offset = ((DWORD) pInfo->modes.farptr.seg16 << 4)
+ (DWORD) pInfo->modes.farptr.off16;
pInfo->modes.flat = (dpmi10) ?
offset + DPMI_PRG_DATA :
offset - npz->memaddress;
cpy16_32(ES, EDI, iobuf, 256);
break;
case 0x01:
SET_SEG_OFF(iobuf, tr.es, tr.edi);
put_regs(&tr);
real_mode_vio10(&tr);
if ((tr.eax & 0xFF) != 0x4f)
break;
else
EAX = tr.eax;
* (DWORD *) (iobuf + 0x0C) = 0; /* zero far function */
cpy16_32(ES, EDI, iobuf, 256);
break;
case 0x02: /* set SVGA mode */
case 0x03: /* get SVGA mode */
case 0x05: /* return ax */
case 0x06: /* return ax,bx,cx,dx */
case 0x07: /* return ax */
case 0x08: /* return ax,bx */
put_regs(&tr);
real_mode_vio10(&tr);
get_regs(&tr);
break;
case 0x04: /* unsupported */
default:
printf("Not supported Vesa call %X", AX);
return;
}
}
/*
** support for mouse calls
*/
static void mou33(void)
{
TRANSLATION tr;
unsigned char rAH = (BYTE) EAX;
if (rAH > 0x35) /* not supported */
return;
switch (rAH) {
case 0x0C: /* Define IRQ routine */
case 0x14: /* Exchange IRQ routines */
case 0x16: /* Save state */
case 0x17: /* Restore state */
case 0x18: /* Set event handler */
case 0x19: /* Return event handler */
case 0x29: /* Enumerate video modes */
case 0x2B: /* Load acceleration prof. */
case 0x2C: /* Get acceleration prof. */
case 0x2D: /* Select acc. profile */
case 0x2E: /* Set acc. profile names */
case 0x33: /* Switch settings etc. */
case 0x34: /* Get initialization file */
break; /* not supported */
case 0x09: /* define graphic cursor es:dx */
put_regs(&tr);
cpy32_16(ES, EDX, iobuf, 32);
SET_SEG_OFF(iobuf, tr.es, tr.edx);
real_mode_mou33(&tr);
EAX = tr.eax;
break;
case 0x12: /* graphic cursor block es:dx ; bh*ch*4 bytes */
put_regs(&tr);
cpy32_16(ES, EDX, iobuf, BH * CH * 4);
SET_SEG_OFF(iobuf, tr.es, tr.edx);
real_mode_mou33(&tr);
get_regs(&tr);
break;
default:
put_regs(&tr);
real_mode_mou33(&tr);
get_regs(&tr);
break;
}
}
void prot_mode_interrupt(void)
{
int int_no = (int) npz->regs.faultno;
if (int_no == 0x10)
return vio10();
else if (int_no == 0x33)
return mou33();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -