@@ -1945,30 +1945,24 @@ static Bitu DOS_21Handler(void) {
19451945 }
19461946
19471947 dos.echo =true ;
1948-
1949- if (handle >= DOS_FILES) {
1950- DOS_SetError (DOSERR_INVALID_HANDLE);
1951- } else
1952- if (!Files[handle] || !Files[handle]->IsOpen ())
1948+ if (handle >= DOS_FILES || !Files[handle] || !Files[handle]->IsOpen ()) {
19531949 DOS_SetError (DOSERR_INVALID_HANDLE);
1954- else if (Files[handle]-> GetInformation () & EXT_DEVICE_BIT)
1955- {
1950+ }
1951+ else if (Files[handle]-> GetInformation () & EXT_DEVICE_BIT) {
19561952 fRead = !(((DOS_ExtDevice*)Files[handle])->CallDeviceFunction (4 , 26 , SegValue (ds), reg_dx, toread) & 0x8000 );
19571953#if defined(USE_TTF)
1958- if (fRead && ttf.inUse && reg_bx == WPvga512CHMhandle)
1959- MEM_BlockRead (SegPhys (ds) + reg_dx, dos_copybuf, toread);
1954+ fRead &= ttf.inUse && reg_bx == WPvga512CHMhandle;
19601955#endif
19611956 }
1962- else
1963- {
1964- if ((fRead = DOS_ReadFile (reg_bx, dos_copybuf, &toread)))
1965- MEM_BlockWrite (SegPhys (ds) + reg_dx, dos_copybuf, toread);
1957+ else {
1958+ fRead = DOS_ReadFile (reg_bx, dos_copybuf, &toread);
19661959 }
19671960
19681961 if (fRead ) {
1962+ MEM_BlockWrite (SegPhys (ds) + reg_dx, dos_copybuf, toread);
19691963 reg_ax=toread;
19701964#if defined(USE_TTF)
1971- if (ttf.inUse && reg_bx == WPvga512CHMhandle){
1965+ if (ttf.inUse && reg_bx == WPvga512CHMhandle) {
19721966 if (toread == 26 || toread == 2 ) {
19731967 if (toread == 2 )
19741968 WP5chars = *(uint16_t *)dos_copybuf;
@@ -2037,17 +2031,15 @@ static Bitu DOS_21Handler(void) {
20372031 {
20382032 uint32_t handle = RealHandle (reg_bx);
20392033
2040- if (handle >= DOS_FILES) {
2034+ if (handle >= DOS_FILES || !Files[handle] || !Files[handle]-> IsOpen () ) {
20412035 DOS_SetError (DOSERR_INVALID_HANDLE);
20422036 }
2043- else
2044- if (!Files[handle] || !Files[handle]->IsOpen ())
2045- DOS_SetError (DOSERR_INVALID_HANDLE);
2046- else if (Files[handle]->GetInformation () & EXT_DEVICE_BIT)
2047- {
2048- fWritten = !(((DOS_ExtDevice*)Files[handle])->CallDeviceFunction (8 , 26 , SegValue (ds), reg_dx, towrite) & 0x8000 );
2049- }
2050- else fWritten = DOS_WriteFile (reg_bx, dos_copybuf, &towrite);
2037+ else if (Files[handle]->GetInformation () & EXT_DEVICE_BIT) {
2038+ fWritten = !(((DOS_ExtDevice*)Files[handle])->CallDeviceFunction (8 , 26 , SegValue (ds), reg_dx, towrite) & 0x8000 );
2039+ }
2040+ else {
2041+ fWritten = DOS_WriteFile (reg_bx, dos_copybuf, &towrite);
2042+ }
20512043 }
20522044 if (fWritten ) {
20532045 reg_ax=towrite;
0 commit comments