@@ -184,35 +184,10 @@ bool cGraphics_Amiga::Sprite_OnScreen_Check(bool p16bit) {
184184 else
185185 drawColumns = (mFodder ->mVideo_Draw_Columns << 3 );
186186
187- if (mFodder ->mVideo_Draw_PosY < 0 ) {
188- ax = mFodder ->mVideo_Draw_PosY + mFodder ->mVideo_Draw_Rows ;
189- --ax;
190- if (ax < 0 )
191- return false ;
192-
193- ax -= 0 ;
194- ax -= mFodder ->mVideo_Draw_Rows ;
195- ++ax;
196- ax = -ax;
197- mFodder ->mVideo_Draw_PosY += ax;
198- mFodder ->mVideo_Draw_Rows -= ax;
199-
200- ax *= 40 ;
201-
202- mFodder ->mVideo_Draw_FrameDataPtr += ax;
203- }
204-
205- ax = mFodder ->mVideo_Draw_PosY + mFodder ->mVideo_Draw_Rows ;
206- --ax;
207-
208- auto maxHeight = g_Window->GetScreenSize ().getHeight () + 31 ;
209- if (ax > maxHeight) {
210- if (mFodder ->mVideo_Draw_PosY > maxHeight)
211- return false ;
212-
213- ax -= maxHeight;
214- mFodder ->mVideo_Draw_Rows -= ax;
215- }
187+ if (!Sprite_OnScreen_ClipY (40 ))
188+ return false ;
189+ if (!Sprite_OnScreen_ClipBottom ())
190+ return false ;
216191
217192 if (mFodder ->mVideo_Draw_PosX < 0 ) {
218193
@@ -385,10 +360,7 @@ void cGraphics_Amiga::Load_Service_Data() {
385360}
386361
387362void cGraphics_Amiga::Load_And_Draw_Image (const std::string& pFilename, unsigned int pColors, size_t pBackColor) {
388- std::string Filename = pFilename;
389-
390- if (Filename.find (' .' ) == std::string::npos)
391- Filename.append (" .raw" );
363+ std::string Filename = EnsureExtension (pFilename, " .raw" );
392364
393365 // Try it as an IFF
394366 auto Decoded = DecodeIFF (Filename);
@@ -1065,33 +1037,7 @@ void cGraphics_Amiga::Video_Draw_16(const uint8* RowPallete) {
10651037}
10661038
10671039void cGraphics_Amiga::Sidebar_Copy_To_Surface (int16 pStartY, cSurface* pSurface) {
1068- uint8* Buffer = mSurface ->GetSurfaceBuffer ();
1069-
1070- if (pSurface)
1071- Buffer = pSurface->GetSurfaceBuffer ();
1072-
1073- uint8* si = (uint8*)mFodder ->mSidebar_Screen_Buffer ;
1074-
1075- // Start 16 rows down
1076- Buffer += (16 * mSurface ->GetWidth ()) + 16 ;
1077-
1078- // Start further in?
1079- if (pStartY) {
1080- Buffer += (mSurface ->GetWidth () * pStartY);
1081- si += (0x30 * pStartY);
1082- }
1083-
1084- // Entire Height of Sidebar
1085- for (unsigned int Y = 17 + pStartY; Y < mSurface ->GetHeight (); ++Y) {
1086-
1087- // Width of Sidebar
1088- for (unsigned int X = 0 ; X < 0x30 ; X++) {
1089- Buffer[X] = *si++;
1090- }
1091-
1092- // Next Row
1093- Buffer += mSurface ->GetWidth ();
1094- }
1040+ Sidebar_Copy_To_Surface_Common (pStartY, pSurface, true );
10951041
10961042}
10971043
@@ -1118,65 +1064,19 @@ void cGraphics_Amiga::Sidebar_Copy_Sprite_To_ScreenBufPtr(int16 pSpriteType, siz
11181064 uint8* di = ((uint8*)mFodder ->mSidebar_Screen_BufferPtr ) + (0x30 * pY) + pX;
11191065 uint8* si = mFodder ->mVideo_Draw_FrameDataPtr ;
11201066
1121- // Height
1122- for (int16 dx = mFodder ->mVideo_Draw_Rows ; dx > 0 ; --dx) {
1123-
1124- // Width
1125- for (int16 cx = 0 ; cx < mFodder ->mVideo_Draw_Columns / 2 ; ++cx) {
1126-
1127- DrawPixels_16 (si, di, mFodder ->mVideo_Draw_PaletteIndex );
1067+ auto drawPixels = [this ](uint8*& src, uint8*& dst) {
1068+ DrawPixels_16 (src, dst, mFodder ->mVideo_Draw_PaletteIndex );
1069+ dst += 16 ;
1070+ src += 2 ;
1071+ };
11281072
1129- di += 16 ;
1130- si += 2 ;
1131- }
1132-
1133- si += mFodder ->mDraw_Source_SkipPixelsPerRow ;
1134- di += mFodder ->mDraw_Dest_SkipPixelsPerRow ;
1135- }
1073+ Sidebar_Copy_Sprite_Loop (
1074+ si, di, mFodder ->mVideo_Draw_Rows , (mFodder ->mVideo_Draw_Columns / 2 ),
1075+ mFodder ->mDraw_Source_SkipPixelsPerRow , mFodder ->mDraw_Dest_SkipPixelsPerRow , drawPixels);
11361076}
11371077
11381078void cGraphics_Amiga::Sidebar_Copy_ScreenBuffer (uint16 pRow, int16 pRows, int16 pCopyToScreen, uint32*& pBuffer) {
1139- pRow += 8 ;
1140- pRows *= 4 ;
1141- uint8* SptPtr = (uint8*)mFodder ->mSidebar_Screen_Buffer ;
1142- uint32* BuffPtr = (uint32*)(SptPtr + (0x30 * pRow));
1143-
1144- if (pCopyToScreen == 0 ) {
1145- for (int16 cx = pRows; cx > 0 ; --cx) {
1146- *pBuffer++ = *BuffPtr++;
1147- *pBuffer++ = *BuffPtr++;
1148- *pBuffer++ = *BuffPtr++;
1149- *pBuffer++ = *BuffPtr++;
1150-
1151- *pBuffer++ = *BuffPtr++;
1152- *pBuffer++ = *BuffPtr++;
1153- *pBuffer++ = *BuffPtr++;
1154- *pBuffer++ = *BuffPtr++;
1155-
1156- *pBuffer++ = *BuffPtr++;
1157- *pBuffer++ = *BuffPtr++;
1158- *pBuffer++ = *BuffPtr++;
1159- *pBuffer++ = *BuffPtr++;
1160- }
1161- }
1162- else {
1163- for (int16 cx = pRows; cx > 0 ; --cx) {
1164- *BuffPtr++ = *pBuffer++;
1165- *BuffPtr++ = *pBuffer++;
1166- *BuffPtr++ = *pBuffer++;
1167- *BuffPtr++ = *pBuffer++;
1168-
1169- *BuffPtr++ = *pBuffer++;
1170- *BuffPtr++ = *pBuffer++;
1171- *BuffPtr++ = *pBuffer++;
1172- *BuffPtr++ = *pBuffer++;
1173-
1174- *BuffPtr++ = *pBuffer++;
1175- *BuffPtr++ = *pBuffer++;
1176- *BuffPtr++ = *pBuffer++;
1177- *BuffPtr++ = *pBuffer++;
1178- }
1179- }
1079+ Sidebar_Copy_ScreenBuffer_Common (pRow, pRows, pCopyToScreen, pBuffer, 8 , 4 );
11801080}
11811081
11821082void cGraphics_Amiga::Recruit_Draw_Hill () {
0 commit comments