diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 3c7f3ff5d6..4dbb484ee7 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,6 +8,19 @@ 2002-12-01 13:30 UTC+0100 Foo Bar */ +2008-03-26 16:54 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) + * harbour/source/rtl/gtos2/gtos2.c + * small changes, removed some un-needed code + - by Maurilio Longo in xHarbour + ! use screen buffer in BYTEs instead of USHORTs to avoid possible + problems on big endian machines. I do not know if such OS2 ports + exist but this code should be also endian independent like rest + of Harbour code + + * harbour/source/rtl/hbgtcore.c + ! Fixed screen buffer corruption on little-endian platforms in + hb_gt_def_ColdArea() - fixed by Phil Krylov in xHarbour - many thanks + 2008-03-25 12:26 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/common.mak * harbour/source/lang/Makefile diff --git a/harbour/source/rtl/gtos2/gtos2.c b/harbour/source/rtl/gtos2/gtos2.c index 2d243cd6f7..a9be38e448 100644 --- a/harbour/source/rtl/gtos2/gtos2.c +++ b/harbour/source/rtl/gtos2/gtos2.c @@ -136,13 +136,7 @@ static int s_iCursorStyle; /* buffer for single screen line */ static int s_iLineBufSize = 0; -static USHORT * s_sLineBuf; - -/* pointer to offscreen video buffer */ -static ULONG s_ulLVBptr; -/* length of video buffer */ -static USHORT s_usLVBlength; - +static BYTE * s_sLineBuf; /* Code page ID of active codepage at the time harbour program was start */ static USHORT s_usOldCodePage; @@ -496,19 +490,19 @@ static void hb_gt_os2_SetCursorStyle( int iStyle ) static void hb_gt_os2_GetScreenContents( PHB_GT pGT ) { - BYTE Cell[2]; int iRow, iCol; - USHORT usSize; + BYTE * pBufPtr; HB_TRACE(HB_TR_DEBUG, ("hb_gt_os2_GetScreenContents(%p)", pGT)); for( iRow = 0; iRow < s_vi.row; ++iRow ) { - for( iCol = 0; iCol < s_vi.col; ++iCol ) + USHORT usSize = s_vi.col << 1; + VioReadCellStr( ( PCH ) s_sLineBuf, &usSize, iRow, 0, 0 ); + + for( iCol = 0, pBufPtr = s_sLineBuf; iCol < s_vi.col; ++iCol, pBufPtr += 2 ) { - usSize = 2; - VioReadCellStr( ( PBYTE ) Cell, &usSize, iRow, iCol, 0 ); - HB_GTSELF_PUTSCRCHAR( pGT, iRow, iCol, Cell[ 1 ], 0, Cell[ 0 ] ); + HB_GTSELF_PUTSCRCHAR( pGT, iRow, iCol, pBufPtr[ 1 ], 0, pBufPtr[ 0 ] ); } } HB_GTSELF_COLDAREA( pGT, 0, 0, s_vi.row, s_vi.col ); @@ -533,16 +527,6 @@ static void hb_gt_os2_Init( PHB_GT pGT, FHANDLE hFilenoStdin, FHANDLE hFilenoStd s_vi.cb = sizeof( VIOMODEINFO ); VioGetMode( &s_vi, 0 ); /* fill structure with current video mode settings */ - if( VioGetBuf( &s_ulLVBptr, &s_usLVBlength, 0 ) == NO_ERROR ) - { - s_ulLVBptr = ( ULONG ) SELTOFLAT( s_ulLVBptr ); - VioShowBuf( 0, s_usLVBlength, 0 ); - } - else - { - s_ulLVBptr = ( ULONG ) NULL; - } - /* Alloc tileable memory for calling a 16 subsystem */ s_hk = ( PHKBD ) hb_gt_os2_allocMem( sizeof( HKBD ) ); /* it is a long after all, so I set it to zero only one time since it never changes */ @@ -735,7 +719,7 @@ static BOOL hb_gt_os2_Resize( PHB_GT pGT, int iRows, int iCols ) if( s_iLineBufSize != 0 ) DosFreeMem( ( PVOID ) s_sLineBuf ); if( iRows ) - s_sLineBuf = ( USHORT * ) hb_gt_os2_allocMem( iRows ); + s_sLineBuf = ( BYTE * ) hb_gt_os2_allocMem( iRows ); s_iLineBufSize = iRows; } return TRUE; @@ -802,7 +786,7 @@ static BOOL hb_gt_os2_Resume( PHB_GT pGT ) static void hb_gt_os2_Redraw( PHB_GT pGT, int iRow, int iCol, int iSize ) { - BYTE bColor, bAttr; + BYTE *pBufPtr = s_sLineBuf, bColor, bAttr; USHORT usChar; int iLen = 0; @@ -813,10 +797,12 @@ static void hb_gt_os2_Redraw( PHB_GT pGT, int iRow, int iCol, int iSize ) if( !HB_GTSELF_GETSCRCHAR( pGT, iRow, iCol + iLen, &bColor, &bAttr, &usChar ) ) break; - s_sLineBuf[ iLen++ ] = ( bColor << 8 ) + ( usChar & 0xff ); + *pBufPtr++ = ( BYTE ) usChar; + *pBufPtr++ = bColor; + ++iLen; } - VioWrtCellStr( ( PCH ) s_sLineBuf, iSize << 1, iRow, iCol, 0 ); + VioWrtCellStr( ( PCH ) s_sLineBuf, iLen << 1, iRow, iCol, 0 ); } static void hb_gt_os2_Refresh( PHB_GT pGT ) diff --git a/harbour/source/rtl/hbgtcore.c b/harbour/source/rtl/hbgtcore.c index 758407477d..243c699619 100644 --- a/harbour/source/rtl/hbgtcore.c +++ b/harbour/source/rtl/hbgtcore.c @@ -2002,8 +2002,8 @@ static void hb_gt_def_ColdArea( PHB_GT pGT, int iTop, int iLeft, int iBottom, in { if( HB_GTSELF_CHECKPOS( pGT, iTop, i, &lIndex ) ) { - pGT->prevBuffer[ lIndex ].uiValue = - ( pGT->screenBuffer[ lIndex ].uiValue &= ~HB_GT_ATTR_REFRESH ); + pGT->screenBuffer[ lIndex ].c.bAttr &= ~HB_GT_ATTR_REFRESH; + pGT->prevBuffer[ lIndex ].uiValue = pGT->screenBuffer[ lIndex ].uiValue; } } if( iLeft == 0 && iRight == pGT->iWidth - 1 )