| 1 | /****************************************************************************** |
|---|
| 2 | *_Copyright (c) 2009 Digital Stream Technology Inc. All Rights Reserved. |
|---|
| 3 | * |
|---|
| 4 | * Module: dstddgfx.c |
|---|
| 5 | * |
|---|
| 6 | * Description |
|---|
| 7 | * |
|---|
| 8 | * @author |
|---|
| 9 | * @version $Revision: 1.1 $ |
|---|
| 10 | * |
|---|
| 11 | ******************************************************************************/ |
|---|
| 12 | |
|---|
| 13 | #include "dsthalcommon.h" |
|---|
| 14 | #include "dstoslayer.h" |
|---|
| 15 | #include "dsthalgfx.h" |
|---|
| 16 | #include "dstddsys.h" |
|---|
| 17 | |
|---|
| 18 | #include "SDL.h" |
|---|
| 19 | |
|---|
| 20 | /****************************************************************************** |
|---|
| 21 | * Global variable declaration |
|---|
| 22 | ******************************************************************************/ |
|---|
| 23 | |
|---|
| 24 | /****************************************************************************** |
|---|
| 25 | * Imported variable declaration |
|---|
| 26 | ******************************************************************************/ |
|---|
| 27 | |
|---|
| 28 | /****************************************************************************** |
|---|
| 29 | * Imported function declaration |
|---|
| 30 | ******************************************************************************/ |
|---|
| 31 | |
|---|
| 32 | /****************************************************************************** |
|---|
| 33 | * Local definitions |
|---|
| 34 | ******************************************************************************/ |
|---|
| 35 | #define MAX_SDL_MESSAGES 256 |
|---|
| 36 | |
|---|
| 37 | /****************************************************************************** |
|---|
| 38 | * Local typedefs |
|---|
| 39 | ******************************************************************************/ |
|---|
| 40 | typedef enum |
|---|
| 41 | { |
|---|
| 42 | cmdSDL_Init, |
|---|
| 43 | cmdSDL_Quit, |
|---|
| 44 | cmdSDL_AllocFrameBuffer, |
|---|
| 45 | cmdSDL_FreeFrameBuffer, |
|---|
| 46 | cmdSDL_DrawBox, |
|---|
| 47 | cmdSDL_DrawImage, |
|---|
| 48 | cmdSDL_CopyBlock, |
|---|
| 49 | cmdSDL_UpdateScreen, |
|---|
| 50 | cmdSDL_ReadPixels, |
|---|
| 51 | |
|---|
| 52 | cmdSDL_MAX |
|---|
| 53 | } SDLMessageType; |
|---|
| 54 | |
|---|
| 55 | struct SdlInitParam |
|---|
| 56 | { |
|---|
| 57 | DS_U16 width, height; |
|---|
| 58 | DS_U32 flags; |
|---|
| 59 | |
|---|
| 60 | int psize; |
|---|
| 61 | }; |
|---|
| 62 | |
|---|
| 63 | struct SdlCopyBlockParam |
|---|
| 64 | { |
|---|
| 65 | DS_U32 p_src_buffer_id; |
|---|
| 66 | DS_U32 p_dst_buffer_id; |
|---|
| 67 | SDL_Rect src_rect; |
|---|
| 68 | SDL_Rect dst_rect; |
|---|
| 69 | DS_BOOL bUpdateScreen; |
|---|
| 70 | }; |
|---|
| 71 | |
|---|
| 72 | |
|---|
| 73 | struct SdlDrawBoxParam |
|---|
| 74 | { |
|---|
| 75 | DS_U32 pBufferId; |
|---|
| 76 | int x, y, w, h; |
|---|
| 77 | DS_PIXEL_t color; |
|---|
| 78 | }; |
|---|
| 79 | |
|---|
| 80 | struct SdlAllocFrameBuffer |
|---|
| 81 | { |
|---|
| 82 | int width; |
|---|
| 83 | int height; |
|---|
| 84 | int fmt; |
|---|
| 85 | }; |
|---|
| 86 | |
|---|
| 87 | typedef struct tag_SdlMessage |
|---|
| 88 | { |
|---|
| 89 | int type; |
|---|
| 90 | void *param; |
|---|
| 91 | |
|---|
| 92 | DS_BOOL bFreeParam; |
|---|
| 93 | DS_BOOL bWaitForComplete; |
|---|
| 94 | DS_U32 *pReturnParam; |
|---|
| 95 | DS_U32 *pReturnStatus; |
|---|
| 96 | OS_SEMAPHORE_ID sema4; |
|---|
| 97 | } SDLMessage; |
|---|
| 98 | |
|---|
| 99 | /****************************************************************************** |
|---|
| 100 | * Local variables declaration |
|---|
| 101 | ******************************************************************************/ |
|---|
| 102 | static DS_U16 g_OutputWidth, g_OutputHeight, g_OutputBPP; |
|---|
| 103 | |
|---|
| 104 | static SDL_Surface *ScrSurf; |
|---|
| 105 | static SDL_Surface *PhySurf; |
|---|
| 106 | static SDL_Surface *VidSurf; |
|---|
| 107 | static SDL_Surface *PrimSurf, *ScndSurf; |
|---|
| 108 | static SDL_Surface *bmp_surface = 0; |
|---|
| 109 | static int s_EnablePlane[MAX_PLANE] = {0}; |
|---|
| 110 | // |
|---|
| 111 | // SDL surface variables |
|---|
| 112 | // |
|---|
| 113 | |
|---|
| 114 | static DS_BOOL bSDLThread = DS_FALSE; |
|---|
| 115 | static OS_TASK_ID SdlTaskId = (OS_TASK_ID)NULL; |
|---|
| 116 | static OS_MESSAGEQUEUE_ID SdlQueue = (OS_MESSAGEQUEUE_ID)NULL; |
|---|
| 117 | //static OS_SEMAPHORE_ID semSdlWait = (OS_SEMAPHORE_ID)NULL; |
|---|
| 118 | // |
|---|
| 119 | // SDL thread variables |
|---|
| 120 | // |
|---|
| 121 | |
|---|
| 122 | /****************************************************************************** |
|---|
| 123 | * Local function prototypes |
|---|
| 124 | ******************************************************************************/ |
|---|
| 125 | static void _InitSDLThread(void); |
|---|
| 126 | static void _CloseSDLThread(void); |
|---|
| 127 | |
|---|
| 128 | static int _SendSdlCommand(SDLMessageType Type, void *Param, DS_BOOL bWaitForComplete, DS_BOOL bFreeParam, void *ReturnParam); |
|---|
| 129 | |
|---|
| 130 | static int doCmd_SDLInit(struct SdlInitParam *p); |
|---|
| 131 | static int doCmd_SDLCopyBlock(SDL_Surface *src_surf, SDL_Rect *sr, SDL_Surface *dst_surf, SDL_Rect *dr, DS_BOOL ); |
|---|
| 132 | static int doCmd_SDLUpdateScreen(SDL_Rect *src_rect, SDL_Rect *dst_rect); |
|---|
| 133 | static DS_U32 doCmd_SDLAllocFrameBuffer( int width, int height, int fmt ); |
|---|
| 134 | static int doCmd_SDLDrawBox(DS_U32 pBufferId, int x, int y, int w, int h, DS_PIXEL_t color); |
|---|
| 135 | |
|---|
| 136 | #if 0 |
|---|
| 137 | ___Lower_Graphic_APIs___() |
|---|
| 138 | #endif |
|---|
| 139 | DHL_RESULT DD_GFX_Init(DS_U16 offsetX, DS_U16 offsetY, DS_U16 width, DS_U16 height, int BPP) |
|---|
| 140 | { |
|---|
| 141 | DHL_RESULT dhlResult = DHL_OK; |
|---|
| 142 | struct SdlInitParam param; |
|---|
| 143 | int err; |
|---|
| 144 | |
|---|
| 145 | _InitSDLThread(); |
|---|
| 146 | |
|---|
| 147 | memset(¶m, 0, sizeof(param)); |
|---|
| 148 | param.width = width; |
|---|
| 149 | param.height = height; |
|---|
| 150 | param.psize = BPP; |
|---|
| 151 | |
|---|
| 152 | err = _SendSdlCommand( cmdSDL_Init, (void *)¶m, DS_TRUE, DS_FALSE, (void *)NULL ); |
|---|
| 153 | if (err) |
|---|
| 154 | dhlResult = DHL_FAIL; |
|---|
| 155 | |
|---|
| 156 | return dhlResult; |
|---|
| 157 | } |
|---|
| 158 | |
|---|
| 159 | DHL_RESULT DD_GFX_Close(void) |
|---|
| 160 | { |
|---|
| 161 | DHL_RESULT dhlResult = DHL_OK; |
|---|
| 162 | |
|---|
| 163 | _CloseSDLThread(); |
|---|
| 164 | |
|---|
| 165 | return dhlResult; |
|---|
| 166 | } |
|---|
| 167 | |
|---|
| 168 | DS_U32 DD_GFX_SetPlane(int Plane, DS_U16 HStart, DS_U16 VStart, DS_U16 InHWidth, DS_U16 InVLength, DS_U16 OutHWidth, DS_U16 OutVLength, int BPP) |
|---|
| 169 | { |
|---|
| 170 | static DS_BOOL bInit = DS_FALSE; |
|---|
| 171 | int err=0; |
|---|
| 172 | |
|---|
| 173 | if ( bInit == DS_FALSE ) |
|---|
| 174 | { |
|---|
| 175 | |
|---|
| 176 | g_OutputWidth = OutHWidth; |
|---|
| 177 | g_OutputHeight = OutVLength; |
|---|
| 178 | g_OutputBPP = BPP; |
|---|
| 179 | |
|---|
| 180 | err=DD_GFX_Init(HStart, VStart, OutHWidth, OutVLength, BPP); |
|---|
| 181 | //err=doCmd_SDLInit(OutHWidth, OutVLength, BPP, 0); |
|---|
| 182 | if ( err ) |
|---|
| 183 | return 0; |
|---|
| 184 | |
|---|
| 185 | bInit = DS_TRUE; |
|---|
| 186 | } |
|---|
| 187 | |
|---|
| 188 | SysASSERT( InHWidth == OutHWidth ); |
|---|
| 189 | SysASSERT( InVLength == OutVLength ); |
|---|
| 190 | |
|---|
| 191 | if (Plane == 0/*Primary*/ && !PrimSurf) |
|---|
| 192 | { |
|---|
| 193 | #if (DHL_GFX_FMT32 == DHL_GFX_FORMAT) |
|---|
| 194 | PrimSurf=SDL_CreateRGBSurface( SDL_SWSURFACE, OutHWidth, OutVLength, BPP, 0xFF0000, 0xFF00, 0xFF, 0xFF000000); |
|---|
| 195 | #else |
|---|
| 196 | PrimSurf=SDL_CreateRGBSurface( SDL_SWSURFACE, OutHWidth, OutVLength, BPP, 0xF00, 0xF0, 0xF, 0x0000); |
|---|
| 197 | #endif |
|---|
| 198 | if (!PrimSurf) |
|---|
| 199 | { |
|---|
| 200 | printf("SDL_CreateRGBSurface()\n"); |
|---|
| 201 | //SDL_Quit(); |
|---|
| 202 | return 0; |
|---|
| 203 | } |
|---|
| 204 | |
|---|
| 205 | #if (DHL_GFX_FMT32 == DHL_GFX_FORMAT) |
|---|
| 206 | ScrSurf=SDL_CreateRGBSurface( SDL_SWSURFACE, OutHWidth, OutVLength, BPP, 0xFF0000, 0xFF00, 0xFF, 0x00000000); |
|---|
| 207 | #else |
|---|
| 208 | ScrSurf=SDL_CreateRGBSurface( SDL_SWSURFACE, OutHWidth, OutVLength, BPP, 0xF00, 0xF0, 0xF, 0x0000); |
|---|
| 209 | #endif |
|---|
| 210 | if (!ScrSurf) |
|---|
| 211 | { |
|---|
| 212 | printf("SDL_CreateRGBSurface()\n"); |
|---|
| 213 | //SDL_Quit(); |
|---|
| 214 | return 0; |
|---|
| 215 | } |
|---|
| 216 | |
|---|
| 217 | s_EnablePlane[Plane] = 0; |
|---|
| 218 | err=SDL_FillRect( PrimSurf, 0, 0 ); |
|---|
| 219 | if (err) |
|---|
| 220 | exit(1); |
|---|
| 221 | |
|---|
| 222 | return (DS_U32)PrimSurf; |
|---|
| 223 | } |
|---|
| 224 | else if (Plane == 1/*Secondary*/ && !ScndSurf ) |
|---|
| 225 | { |
|---|
| 226 | #if (DHL_GFX_FMT32 == DHL_GFX_FORMAT) |
|---|
| 227 | ScndSurf=SDL_CreateRGBSurface( SDL_SWSURFACE, OutHWidth, OutVLength, BPP, 0xFF0000, 0xFF00, 0xFF, 0xFF000000); |
|---|
| 228 | #else |
|---|
| 229 | ScndSurf=SDL_CreateRGBSurface( SDL_SWSURFACE, OutHWidth, OutVLength, BPP, 0xF00, 0xF0, 0xF, 0x0000); |
|---|
| 230 | #endif |
|---|
| 231 | if (!ScndSurf) |
|---|
| 232 | { |
|---|
| 233 | printf("SDL_CreateRGBSurface()\n"); |
|---|
| 234 | //SDL_Quit(); |
|---|
| 235 | return 0; |
|---|
| 236 | } |
|---|
| 237 | |
|---|
| 238 | s_EnablePlane[Plane] = 0; |
|---|
| 239 | err=SDL_FillRect( ScndSurf, 0, 0 ); |
|---|
| 240 | if (err) |
|---|
| 241 | exit(1); |
|---|
| 242 | |
|---|
| 243 | return (DS_U32)ScndSurf; |
|---|
| 244 | } |
|---|
| 245 | |
|---|
| 246 | return 0; |
|---|
| 247 | } |
|---|
| 248 | |
|---|
| 249 | DS_U32 DD_GFX_GetPhysicalFrameBuffer(void) |
|---|
| 250 | { |
|---|
| 251 | return (DS_U32)ScrSurf; |
|---|
| 252 | //return (DS_U32)PrimSurf; |
|---|
| 253 | } |
|---|
| 254 | |
|---|
| 255 | DS_U32 DD_GFX_GetVideoFrameBuffer(void) |
|---|
| 256 | { |
|---|
| 257 | return (DS_U32)VidSurf; |
|---|
| 258 | } |
|---|
| 259 | |
|---|
| 260 | DS_U32 DD_GFX_AllocFrameBuffer( int width, int height, int fmt ) |
|---|
| 261 | { |
|---|
| 262 | DS_U32 bufId=0; |
|---|
| 263 | struct SdlAllocFrameBuffer param; |
|---|
| 264 | int err; |
|---|
| 265 | |
|---|
| 266 | param.width = width; |
|---|
| 267 | param.height = height; |
|---|
| 268 | param.fmt = fmt; |
|---|
| 269 | |
|---|
| 270 | err = _SendSdlCommand( cmdSDL_AllocFrameBuffer, (void *)¶m, DS_TRUE, DS_FALSE, (void *)&bufId ); |
|---|
| 271 | if (bufId==0) |
|---|
| 272 | { |
|---|
| 273 | fprintf(stderr, "bufId: 0x%08lX\n", bufId); |
|---|
| 274 | } |
|---|
| 275 | |
|---|
| 276 | return bufId; |
|---|
| 277 | } |
|---|
| 278 | |
|---|
| 279 | DHL_RESULT DD_GFX_FreeFrameBuffer( DS_U32 pBufferId ) |
|---|
| 280 | { |
|---|
| 281 | int err; |
|---|
| 282 | |
|---|
| 283 | err = _SendSdlCommand( cmdSDL_FreeFrameBuffer, (void *)pBufferId, DS_FALSE, DS_FALSE, (void *)NULL ); |
|---|
| 284 | |
|---|
| 285 | if (err) |
|---|
| 286 | return DHL_FAIL; |
|---|
| 287 | |
|---|
| 288 | return DHL_OK; |
|---|
| 289 | } |
|---|
| 290 | |
|---|
| 291 | DS_U32 DD_GFX_GetFrameBuffer( DS_U32 pBufferId ) |
|---|
| 292 | { |
|---|
| 293 | SDL_Surface *surf = (SDL_Surface *)pBufferId; |
|---|
| 294 | |
|---|
| 295 | // printf("\n\n\n\n\n%s()\n\n\n\n\n", __func__); |
|---|
| 296 | |
|---|
| 297 | return (DS_U32)surf->pixels; |
|---|
| 298 | } |
|---|
| 299 | |
|---|
| 300 | void DD_GFX_ReadPixels( DS_U32 pBufferId, int offsetX, int offsetY, int w, int h, DS_PIXEL_t *pPixels ) |
|---|
| 301 | { |
|---|
| 302 | SDL_Surface *surf = (SDL_Surface *)pBufferId; |
|---|
| 303 | int x, y; |
|---|
| 304 | int surf_w, surf_h; |
|---|
| 305 | DS_PIXEL_t *p = (DS_PIXEL_t *)surf->pixels; |
|---|
| 306 | |
|---|
| 307 | printf("\n\n\n\n\n%s()\n\n\n\n\n", __func__); |
|---|
| 308 | |
|---|
| 309 | SysASSERT( pPixels ); |
|---|
| 310 | |
|---|
| 311 | surf_w = surf->w; |
|---|
| 312 | surf_h = surf->h; |
|---|
| 313 | if ( (offsetX+w) > surf_w ) |
|---|
| 314 | w = surf_w - offsetX; |
|---|
| 315 | |
|---|
| 316 | if ( (offsetY+h) > surf_h ) |
|---|
| 317 | h = surf_h - offsetY; |
|---|
| 318 | |
|---|
| 319 | for (y=0; y<h; y++) |
|---|
| 320 | { |
|---|
| 321 | for (x=0; x<w; x++) |
|---|
| 322 | { |
|---|
| 323 | pPixels[x+y*w] = p[(x+offsetX)+(y+offsetY)*surf_w]; |
|---|
| 324 | } |
|---|
| 325 | } |
|---|
| 326 | } |
|---|
| 327 | |
|---|
| 328 | int DD_GFX_EnablePlane(int Plane, int Enable) |
|---|
| 329 | { |
|---|
| 330 | SysENSURE( Plane < MAX_PLANE ); |
|---|
| 331 | |
|---|
| 332 | s_EnablePlane[Plane] = Enable; |
|---|
| 333 | |
|---|
| 334 | /* |
|---|
| 335 | * Do update the physical screen here. |
|---|
| 336 | */ |
|---|
| 337 | |
|---|
| 338 | return 0; |
|---|
| 339 | } |
|---|
| 340 | |
|---|
| 341 | |
|---|
| 342 | void DD_GFX_ClosePlane(int Plane) |
|---|
| 343 | { |
|---|
| 344 | if (Plane == 0 && PrimSurf) |
|---|
| 345 | { |
|---|
| 346 | SDL_FreeSurface(PrimSurf); |
|---|
| 347 | PrimSurf = (SDL_Surface *)NULL; |
|---|
| 348 | } |
|---|
| 349 | |
|---|
| 350 | if (Plane == 1 && ScndSurf) |
|---|
| 351 | { |
|---|
| 352 | SDL_FreeSurface(ScndSurf); |
|---|
| 353 | ScndSurf = (SDL_Surface *)NULL; |
|---|
| 354 | } |
|---|
| 355 | |
|---|
| 356 | if (!PrimSurf && !ScndSurf) |
|---|
| 357 | { |
|---|
| 358 | SDL_FreeSurface(PhySurf); |
|---|
| 359 | SDL_FreeSurface(ScrSurf); |
|---|
| 360 | PhySurf = (SDL_Surface *)NULL; |
|---|
| 361 | SDL_Quit(); |
|---|
| 362 | } |
|---|
| 363 | } |
|---|
| 364 | |
|---|
| 365 | DS_U32 DD_GFX_SetPlaneEx(int Plane, DS_U16 HStart, DS_U16 VStart, DS_U16 InHWidth, DS_U16 InVLength, DS_U16 OutHWidth, DS_U16 OutVLength, DS_U32 BaseFBAddr, DS_U32 BaseVAddr, int BPP, int bInterlaced) |
|---|
| 366 | { |
|---|
| 367 | return 0; |
|---|
| 368 | } |
|---|
| 369 | |
|---|
| 370 | void DD_GFX_SetBlendPixMap(int Plane, int Fore, int Bgnd) |
|---|
| 371 | { |
|---|
| 372 | } |
|---|
| 373 | |
|---|
| 374 | int DD_GFX_SetPallete(int Plane, int StartIdx, int Length, DS_U32 *pal) |
|---|
| 375 | { |
|---|
| 376 | return 0; |
|---|
| 377 | } |
|---|
| 378 | |
|---|
| 379 | void DD_GFX_DrawBox(DS_U32 pBufferId, int offsetX, int offsetY, int w, int h, DS_PIXEL_t color) |
|---|
| 380 | { |
|---|
| 381 | struct SdlDrawBoxParam param; |
|---|
| 382 | int err; |
|---|
| 383 | |
|---|
| 384 | param.pBufferId = pBufferId; |
|---|
| 385 | param.x = offsetX; |
|---|
| 386 | param.y = offsetY; |
|---|
| 387 | param.w = w; |
|---|
| 388 | param.h = h; |
|---|
| 389 | param.color = color; |
|---|
| 390 | |
|---|
| 391 | err = _SendSdlCommand( cmdSDL_DrawBox, (void *)¶m, DS_TRUE, DS_FALSE, (void *)NULL ); |
|---|
| 392 | |
|---|
| 393 | if (err) |
|---|
| 394 | printf("!!! Cannot send SDL_DrawBox command.\n"); |
|---|
| 395 | } |
|---|
| 396 | |
|---|
| 397 | void DD_GFX_CopyBlock(DS_U32 p_src_buffer_id, DS_U32 p_dst_buffer_id, |
|---|
| 398 | int src_x, int src_y, int src_w, int src_h, |
|---|
| 399 | int dst_x, int dst_y, int dst_w, int dst_h, int bUpdateScreen) |
|---|
| 400 | { |
|---|
| 401 | struct SdlCopyBlockParam *param; |
|---|
| 402 | int err; |
|---|
| 403 | |
|---|
| 404 | param = (struct SdlCopyBlockParam *)malloc(sizeof(struct SdlCopyBlockParam)); |
|---|
| 405 | SysASSERT(param); |
|---|
| 406 | |
|---|
| 407 | memset(param, 0, sizeof(struct SdlCopyBlockParam)); |
|---|
| 408 | |
|---|
| 409 | param->p_src_buffer_id = p_src_buffer_id; |
|---|
| 410 | param->src_rect.x = src_x; |
|---|
| 411 | param->src_rect.y = src_y; |
|---|
| 412 | param->src_rect.w = src_w; |
|---|
| 413 | param->src_rect.h = src_h; |
|---|
| 414 | |
|---|
| 415 | param->p_dst_buffer_id = p_dst_buffer_id; |
|---|
| 416 | param->dst_rect.x = dst_x; |
|---|
| 417 | param->dst_rect.y = dst_y; |
|---|
| 418 | param->dst_rect.w = dst_w; |
|---|
| 419 | param->dst_rect.h = dst_h; |
|---|
| 420 | |
|---|
| 421 | param->bUpdateScreen = bUpdateScreen; |
|---|
| 422 | |
|---|
| 423 | err = _SendSdlCommand( cmdSDL_CopyBlock, (void *)param, DS_FALSE, DS_TRUE, (void *)NULL ); |
|---|
| 424 | |
|---|
| 425 | if (err) |
|---|
| 426 | printf("!!! Cannot send SDL_CopyBlock command.\n"); |
|---|
| 427 | } |
|---|
| 428 | |
|---|
| 429 | void DD_GFX_UpdateScreen(void) |
|---|
| 430 | { |
|---|
| 431 | int err; |
|---|
| 432 | |
|---|
| 433 | err = _SendSdlCommand( cmdSDL_UpdateScreen, (void *)NULL, DS_FALSE, DS_FALSE, (void *)NULL ); |
|---|
| 434 | if (err) |
|---|
| 435 | printf("!!! Cannot send SDL_UpdateScreen command.\n"); |
|---|
| 436 | } |
|---|
| 437 | |
|---|
| 438 | void DD_GFX_DrawImage( DS_U32 pBufferId, int offsetX, int offsetY, int w, int h, DS_PIXEL_t *pPixels) |
|---|
| 439 | { |
|---|
| 440 | SDL_Surface *surf = (SDL_Surface *)pBufferId; |
|---|
| 441 | DS_PIXEL_t *p; |
|---|
| 442 | int x, y, surf_h, surf_w; |
|---|
| 443 | DS_PIXEL_t c; |
|---|
| 444 | |
|---|
| 445 | SysENSURE( surf ); |
|---|
| 446 | |
|---|
| 447 | surf_h = surf->h; |
|---|
| 448 | surf_w = surf->w; |
|---|
| 449 | p = (DS_PIXEL_t *)surf->pixels; |
|---|
| 450 | SysASSERT( p ); |
|---|
| 451 | |
|---|
| 452 | if ( (offsetX+w) > surf_w ) |
|---|
| 453 | w = surf_w - offsetX; |
|---|
| 454 | |
|---|
| 455 | if ( (offsetY+h) > surf_h ) |
|---|
| 456 | h = surf_h - offsetY; |
|---|
| 457 | |
|---|
| 458 | for (y=0; y<h; y++) |
|---|
| 459 | { |
|---|
| 460 | for (x=0; x<w; x++) |
|---|
| 461 | { |
|---|
| 462 | c = pPixels[x+y*w]; |
|---|
| 463 | p[(x+offsetX)+(y+offsetY)*surf_w] = c; |
|---|
| 464 | } |
|---|
| 465 | } |
|---|
| 466 | } |
|---|
| 467 | |
|---|
| 468 | void dump_phy_buf(int x, int y, int len) |
|---|
| 469 | { |
|---|
| 470 | DS_PIXEL_t *p; |
|---|
| 471 | int surf_h, surf_w; |
|---|
| 472 | int i; |
|---|
| 473 | |
|---|
| 474 | if (!PhySurf) |
|---|
| 475 | return; |
|---|
| 476 | |
|---|
| 477 | surf_w = VidSurf->w; |
|---|
| 478 | surf_h = VidSurf->h; |
|---|
| 479 | p = (DS_PIXEL_t *)PhySurf->pixels; |
|---|
| 480 | |
|---|
| 481 | for (i=0; i<len; i++) |
|---|
| 482 | #if (DHL_GFX_FMT32 == DHL_GFX_FORMAT) |
|---|
| 483 | printf("0x%08lX \n", p[x+y*surf_w+i]); |
|---|
| 484 | #elif (DHL_GFX_FMT16 == DHL_GFX_FORMAT) |
|---|
| 485 | printf("0x%04X \n", p[x+y*surf_w+i]); |
|---|
| 486 | #else |
|---|
| 487 | printf("0x%02X \n", p[x+y*surf_w+i]); |
|---|
| 488 | #endif |
|---|
| 489 | |
|---|
| 490 | printf("\n"); |
|---|
| 491 | } |
|---|
| 492 | |
|---|
| 493 | void dump_prim_buf(int x, int y, int len) |
|---|
| 494 | { |
|---|
| 495 | DS_PIXEL_t *p; |
|---|
| 496 | int surf_h, surf_w; |
|---|
| 497 | int i; |
|---|
| 498 | |
|---|
| 499 | if (!PrimSurf) |
|---|
| 500 | return; |
|---|
| 501 | |
|---|
| 502 | surf_w = PrimSurf->w; |
|---|
| 503 | surf_h = PrimSurf->h; |
|---|
| 504 | p = (DS_PIXEL_t *)PrimSurf->pixels; |
|---|
| 505 | for (i=0; i<len; i++) |
|---|
| 506 | #if (DHL_GFX_FMT32 == DHL_GFX_FORMAT) |
|---|
| 507 | printf("0x%08lX \n", p[x+y*surf_w+i]); |
|---|
| 508 | #elif (DHL_GFX_FMT16 == DHL_GFX_FORMAT) |
|---|
| 509 | printf("0x%04X \n", p[x+y*surf_w+i]); |
|---|
| 510 | #else |
|---|
| 511 | printf("0x%02X \n", p[x+y*surf_w+i]); |
|---|
| 512 | #endif |
|---|
| 513 | printf("\n"); |
|---|
| 514 | } |
|---|
| 515 | |
|---|
| 516 | #if 0 |
|---|
| 517 | ___SDL_Thread___() |
|---|
| 518 | #endif |
|---|
| 519 | void DHL_IR_Input(DS_U32 Code, int bPressed); |
|---|
| 520 | static void ProcessSDLEvent(void) |
|---|
| 521 | { |
|---|
| 522 | int i_max_cnt = 10; |
|---|
| 523 | SDL_Event event; |
|---|
| 524 | int n; |
|---|
| 525 | |
|---|
| 526 | /* |
|---|
| 527 | * Process i_max_cnt event at once. |
|---|
| 528 | */ |
|---|
| 529 | do { |
|---|
| 530 | n = SDL_PollEvent(&event); |
|---|
| 531 | if (n==0) |
|---|
| 532 | return; |
|---|
| 533 | |
|---|
| 534 | switch(event.type) |
|---|
| 535 | { |
|---|
| 536 | case SDL_KEYDOWN: |
|---|
| 537 | DHL_IR_Input((DS_U32)(event.key.keysym.sym|0xCAFE0000),1); |
|---|
| 538 | break; |
|---|
| 539 | |
|---|
| 540 | case SDL_KEYUP: |
|---|
| 541 | DHL_IR_Input((DS_U32)(event.key.keysym.sym|0xCAFE0000),0); |
|---|
| 542 | break; |
|---|
| 543 | case SDL_MOUSEBUTTONDOWN: |
|---|
| 544 | if (event.button.button == SDL_BUTTON_LEFT) |
|---|
| 545 | { |
|---|
| 546 | //int x = event.button.x; |
|---|
| 547 | //int y = event.button.y; |
|---|
| 548 | //printf("SDL_MOUSEBUTTONDOWN SDL_BUTTON_LEFT x = %d, y= %d\n", x,y); |
|---|
| 549 | DHL_IR_Input((DS_U32)(event.button.x * 0x10000 + event.button.y), 2); |
|---|
| 550 | } |
|---|
| 551 | break; |
|---|
| 552 | |
|---|
| 553 | case SDL_QUIT: |
|---|
| 554 | SDL_Quit(); |
|---|
| 555 | exit(0); |
|---|
| 556 | break; |
|---|
| 557 | |
|---|
| 558 | case SDL_VIDEORESIZE: |
|---|
| 559 | { |
|---|
| 560 | FILE *fp = fopen("win_size.txt", "r"); |
|---|
| 561 | int nWidth = 0; |
|---|
| 562 | int nHeight = 0; |
|---|
| 563 | int nSize = 0; |
|---|
| 564 | fscanf(fp,"%d,%d,%d", &nWidth, &nHeight, &nSize); |
|---|
| 565 | fclose(fp); |
|---|
| 566 | nWidth = event.resize.w; |
|---|
| 567 | nHeight = event.resize.h; |
|---|
| 568 | fp = fopen("win_size.txt", "w"); |
|---|
| 569 | fprintf(fp,"%d,%d,%d", nWidth, nHeight, nSize); |
|---|
| 570 | fclose(fp); |
|---|
| 571 | |
|---|
| 572 | PhySurf=SDL_SetVideoMode(nWidth, nHeight, nSize, SDL_RESIZABLE); |
|---|
| 573 | if ( DHL_GFX_IsInit(0) ) |
|---|
| 574 | DHL_GFX_UpdateScreen(0); |
|---|
| 575 | |
|---|
| 576 | if ( DHL_GFX_IsInit(1) ) |
|---|
| 577 | DHL_GFX_UpdateScreen(1); |
|---|
| 578 | break; |
|---|
| 579 | } |
|---|
| 580 | break; |
|---|
| 581 | case SDL_VIDEOEXPOSE: |
|---|
| 582 | if ( DHL_GFX_IsInit(0) ) |
|---|
| 583 | doCmd_SDLUpdateScreen(NULL, NULL);//DHL_GFX_UpdateScreen(0); |
|---|
| 584 | |
|---|
| 585 | if ( DHL_GFX_IsInit(1) ) |
|---|
| 586 | doCmd_SDLUpdateScreen(NULL, NULL);//DHL_GFX_UpdateScreen(1); |
|---|
| 587 | break; |
|---|
| 588 | |
|---|
| 589 | default: |
|---|
| 590 | break; |
|---|
| 591 | } |
|---|
| 592 | } while (n && i_max_cnt--); |
|---|
| 593 | } |
|---|
| 594 | |
|---|
| 595 | // |
|---|
| 596 | // SDL thread controls all the SDL stuff including initialization and events. |
|---|
| 597 | // |
|---|
| 598 | static void _tSDLMonitor(DS_U32 arg) |
|---|
| 599 | { |
|---|
| 600 | DS_U32 err=0; |
|---|
| 601 | SDLMessage msg; |
|---|
| 602 | DS_U32 msgLen; |
|---|
| 603 | DS_U32 returnParam; |
|---|
| 604 | |
|---|
| 605 | while(1) |
|---|
| 606 | { |
|---|
| 607 | if ( SdlQueue == (OS_MESSAGEQUEUE_ID)NULL ) |
|---|
| 608 | { |
|---|
| 609 | OS_mDelay(10); |
|---|
| 610 | continue; |
|---|
| 611 | } |
|---|
| 612 | |
|---|
| 613 | memset(&msg, 0, sizeof(msg)); |
|---|
| 614 | msgLen = 0; |
|---|
| 615 | err=OS_ReceiveMessage_NoWait(SdlQueue, (DS_U32 *) &msg, sizeof(SDLMessage), (DS_U32 *)&msgLen); |
|---|
| 616 | if (err == OS_TIMEOUT) |
|---|
| 617 | { |
|---|
| 618 | /* Since there are no available messages, have to do event process. */ |
|---|
| 619 | |
|---|
| 620 | ProcessSDLEvent(); |
|---|
| 621 | //OS_mDelay(10); |
|---|
| 622 | continue; |
|---|
| 623 | } |
|---|
| 624 | |
|---|
| 625 | if (err || msgLen != sizeof(SDLMessage)) |
|---|
| 626 | { |
|---|
| 627 | printf("!!! %s cannot receive message (%ld). err:0x%lx\n", __FUNCTION__, msgLen, err); |
|---|
| 628 | //OS_mDelay(10); |
|---|
| 629 | continue; |
|---|
| 630 | } |
|---|
| 631 | |
|---|
| 632 | SysASSERT( msg.type < cmdSDL_MAX ); |
|---|
| 633 | |
|---|
| 634 | /* |
|---|
| 635 | * Here we do message process. |
|---|
| 636 | */ |
|---|
| 637 | switch(msg.type) |
|---|
| 638 | { |
|---|
| 639 | case cmdSDL_Init: |
|---|
| 640 | { |
|---|
| 641 | struct SdlInitParam *p = (struct SdlInitParam *)msg.param; |
|---|
| 642 | |
|---|
| 643 | err = doCmd_SDLInit( p ); |
|---|
| 644 | break; |
|---|
| 645 | } |
|---|
| 646 | |
|---|
| 647 | case cmdSDL_CopyBlock: |
|---|
| 648 | { |
|---|
| 649 | struct SdlCopyBlockParam *p = (struct SdlCopyBlockParam *)msg.param; |
|---|
| 650 | |
|---|
| 651 | err = doCmd_SDLCopyBlock( (SDL_Surface *)p->p_src_buffer_id, &p->src_rect, |
|---|
| 652 | (SDL_Surface *)p->p_dst_buffer_id, &p->dst_rect, p->bUpdateScreen ); |
|---|
| 653 | break; |
|---|
| 654 | } |
|---|
| 655 | |
|---|
| 656 | case cmdSDL_DrawBox: |
|---|
| 657 | { |
|---|
| 658 | struct SdlDrawBoxParam *p = (struct SdlDrawBoxParam *)msg.param; |
|---|
| 659 | |
|---|
| 660 | err = doCmd_SDLDrawBox( p->pBufferId, p->x, p->y, p->w, p->h, p->color ); |
|---|
| 661 | break; |
|---|
| 662 | } |
|---|
| 663 | |
|---|
| 664 | case cmdSDL_AllocFrameBuffer: |
|---|
| 665 | { |
|---|
| 666 | struct SdlAllocFrameBuffer *p = (struct SdlAllocFrameBuffer *)msg.param; |
|---|
| 667 | |
|---|
| 668 | returnParam = doCmd_SDLAllocFrameBuffer( p->width, p->height, p->fmt ); |
|---|
| 669 | break; |
|---|
| 670 | } |
|---|
| 671 | |
|---|
| 672 | case cmdSDL_FreeFrameBuffer: |
|---|
| 673 | { |
|---|
| 674 | SDL_Surface *surf = (SDL_Surface *)msg.param; |
|---|
| 675 | SDL_FreeSurface( surf ); |
|---|
| 676 | |
|---|
| 677 | break; |
|---|
| 678 | } |
|---|
| 679 | |
|---|
| 680 | case cmdSDL_UpdateScreen: |
|---|
| 681 | { |
|---|
| 682 | err = doCmd_SDLUpdateScreen(NULL, NULL); |
|---|
| 683 | break; |
|---|
| 684 | } |
|---|
| 685 | |
|---|
| 686 | default: |
|---|
| 687 | { |
|---|
| 688 | |
|---|
| 689 | printf("!!! Invalid SDL message 0x%x\n", msg.type); |
|---|
| 690 | break; |
|---|
| 691 | } |
|---|
| 692 | } |
|---|
| 693 | |
|---|
| 694 | if (msg.bFreeParam) |
|---|
| 695 | { |
|---|
| 696 | if (msg.param) |
|---|
| 697 | { |
|---|
| 698 | free(msg.param); |
|---|
| 699 | } |
|---|
| 700 | } |
|---|
| 701 | |
|---|
| 702 | if (msg.bWaitForComplete) |
|---|
| 703 | { |
|---|
| 704 | if(msg.pReturnParam) |
|---|
| 705 | { |
|---|
| 706 | *msg.pReturnParam = returnParam; |
|---|
| 707 | } |
|---|
| 708 | |
|---|
| 709 | if(msg.pReturnStatus) |
|---|
| 710 | { |
|---|
| 711 | *msg.pReturnStatus = err; |
|---|
| 712 | OS_GiveSemaphore(msg.sema4); |
|---|
| 713 | } |
|---|
| 714 | else |
|---|
| 715 | { |
|---|
| 716 | printf("!!! Command need to wait for completion but return status field is NULL.\n"); |
|---|
| 717 | } |
|---|
| 718 | } |
|---|
| 719 | |
|---|
| 720 | ProcessSDLEvent(); |
|---|
| 721 | //OS_mDelay(10); |
|---|
| 722 | } |
|---|
| 723 | } |
|---|
| 724 | |
|---|
| 725 | static int _SendSdlCommand(SDLMessageType Type, void *Param, DS_BOOL bWaitForComplete, DS_BOOL bFreeParam, void *ReturnParam) |
|---|
| 726 | { |
|---|
| 727 | DS_U32 err=0; |
|---|
| 728 | SDLMessage msg; |
|---|
| 729 | DS_U32 status=0; |
|---|
| 730 | |
|---|
| 731 | memset(&msg, 0, sizeof(msg)); |
|---|
| 732 | msg.type = Type; |
|---|
| 733 | msg.bFreeParam = bFreeParam; |
|---|
| 734 | msg.param = Param; |
|---|
| 735 | msg.bWaitForComplete = bWaitForComplete; |
|---|
| 736 | msg.pReturnStatus = &status; |
|---|
| 737 | msg.pReturnParam = ReturnParam; |
|---|
| 738 | |
|---|
| 739 | if (msg.bWaitForComplete) |
|---|
| 740 | { |
|---|
| 741 | msg.sema4 = OS_CreateBinarySemaphore("SdlWaitSem", 0, DS_FALSE); |
|---|
| 742 | SysASSERT( msg.sema4 ); |
|---|
| 743 | } |
|---|
| 744 | |
|---|
| 745 | err=OS_SendMessage(SdlQueue, (DS_U32 *)&msg, sizeof(msg)); |
|---|
| 746 | if (err) |
|---|
| 747 | { |
|---|
| 748 | printf("!!! %s cannot send %d message. err: %lx\n", __FUNCTION__, Type, err); |
|---|
| 749 | goto _SendSdlCommandExit; |
|---|
| 750 | } |
|---|
| 751 | |
|---|
| 752 | if (bWaitForComplete) |
|---|
| 753 | { |
|---|
| 754 | OS_TakeSemaphore(msg.sema4); |
|---|
| 755 | OS_DeleteSemaphore(msg.sema4); |
|---|
| 756 | err=status; |
|---|
| 757 | } |
|---|
| 758 | |
|---|
| 759 | _SendSdlCommandExit: |
|---|
| 760 | if (err) |
|---|
| 761 | return -1; |
|---|
| 762 | |
|---|
| 763 | return 0; |
|---|
| 764 | } |
|---|
| 765 | |
|---|
| 766 | static int doCmd_SDLInit(struct SdlInitParam *p) |
|---|
| 767 | { |
|---|
| 768 | int err=0; |
|---|
| 769 | |
|---|
| 770 | SDL_version compiled; |
|---|
| 771 | SDL_VERSION(&compiled); |
|---|
| 772 | printf("SDL version %d.%d.%d ...\n", compiled.major, compiled.minor, compiled.patch); |
|---|
| 773 | |
|---|
| 774 | if(SDL_Init(SDL_INIT_VIDEO)==-1) |
|---|
| 775 | { |
|---|
| 776 | printf("SDL_Init: %s\n", SDL_GetError()); |
|---|
| 777 | err = -1; |
|---|
| 778 | goto SDLInit_Exit; |
|---|
| 779 | } |
|---|
| 780 | |
|---|
| 781 | { |
|---|
| 782 | FILE *fp = fopen("win_size.txt", "r"); |
|---|
| 783 | int nWidth = p->width; |
|---|
| 784 | int nHeight = p->height; |
|---|
| 785 | int nSize = p->psize; |
|---|
| 786 | if (fp != 0) |
|---|
| 787 | { |
|---|
| 788 | fscanf(fp,"%d,%d,%d", &nWidth, &nHeight, &nSize); |
|---|
| 789 | fclose(fp); |
|---|
| 790 | } |
|---|
| 791 | else |
|---|
| 792 | { |
|---|
| 793 | fp = fopen("win_size.txt", "w"); |
|---|
| 794 | fprintf(fp,"%d,%d,%d", nWidth, nHeight, nSize); |
|---|
| 795 | fclose(fp); |
|---|
| 796 | } |
|---|
| 797 | PhySurf=SDL_SetVideoMode(nWidth, nHeight, nSize, SDL_RESIZABLE); |
|---|
| 798 | if(!PhySurf) |
|---|
| 799 | { |
|---|
| 800 | printf("SDL_SetVideoMode: %s\n", SDL_GetError()); |
|---|
| 801 | //SDL_Quit(); |
|---|
| 802 | err = -1; |
|---|
| 803 | goto SDLInit_Exit; |
|---|
| 804 | } |
|---|
| 805 | } |
|---|
| 806 | |
|---|
| 807 | if(!PhySurf) |
|---|
| 808 | { |
|---|
| 809 | printf("SDL_SetVideoMode: %s\n", SDL_GetError()); |
|---|
| 810 | //SDL_Quit(); |
|---|
| 811 | err = -1; |
|---|
| 812 | goto SDLInit_Exit; |
|---|
| 813 | } |
|---|
| 814 | |
|---|
| 815 | err=SDL_FillRect( PhySurf, 0, 0 ); |
|---|
| 816 | SysASSERT(err==0); |
|---|
| 817 | |
|---|
| 818 | ScndSurf = PrimSurf = (SDL_Surface *)NULL; |
|---|
| 819 | #if 0 |
|---|
| 820 | VidSurf=SDL_CreateRGBSurface( SDL_SWSURFACE, g_OutputWidth, g_OutputHeight, g_OutputBPP, 0, 0, 0, 0); |
|---|
| 821 | #else |
|---|
| 822 | srand(time(NULL)); |
|---|
| 823 | int r = (rand() % 5); |
|---|
| 824 | switch(r) |
|---|
| 825 | { |
|---|
| 826 | case 0: |
|---|
| 827 | VidSurf=SDL_LoadBMP("background.bmp"); // ¹è°æ ±×¸²¿ë bmp ¼Çǽº »ý¼º |
|---|
| 828 | break; |
|---|
| 829 | case 1: |
|---|
| 830 | VidSurf=SDL_LoadBMP("background1.bmp"); // ¹è°æ ±×¸²¿ë bmp ¼Çǽº »ý¼º |
|---|
| 831 | break; |
|---|
| 832 | case 2: |
|---|
| 833 | VidSurf=SDL_LoadBMP("background2.bmp"); // ¹è°æ ±×¸²¿ë bmp ¼Çǽº »ý¼º |
|---|
| 834 | break; |
|---|
| 835 | case 3: |
|---|
| 836 | VidSurf=SDL_LoadBMP("background3.bmp"); // ¹è°æ ±×¸²¿ë bmp ¼Çǽº »ý¼º |
|---|
| 837 | break; |
|---|
| 838 | case 4: |
|---|
| 839 | VidSurf=SDL_LoadBMP("background4.bmp"); // ¹è°æ ±×¸²¿ë bmp ¼Çǽº »ý¼º |
|---|
| 840 | break; |
|---|
| 841 | default: |
|---|
| 842 | VidSurf=SDL_LoadBMP("sosi.bmp"); // ¹è°æ ±×¸²¿ë bmp ¼Çǽº »ý¼º |
|---|
| 843 | break; |
|---|
| 844 | } |
|---|
| 845 | #endif |
|---|
| 846 | if (!VidSurf) |
|---|
| 847 | { |
|---|
| 848 | printf("SDL_CreateRGBSurface()\n"); |
|---|
| 849 | //SDL_Quit(); |
|---|
| 850 | err = -1; |
|---|
| 851 | goto SDLInit_Exit; |
|---|
| 852 | } |
|---|
| 853 | //err=SDL_FillRect( VidSurf, 0, 0 ); |
|---|
| 854 | SysASSERT(err==0); |
|---|
| 855 | |
|---|
| 856 | SDLInit_Exit: |
|---|
| 857 | return err; |
|---|
| 858 | } |
|---|
| 859 | |
|---|
| 860 | static int doCmd_SDLCopyBlock(SDL_Surface *src_surf, SDL_Rect *sr, SDL_Surface *dst_surf, SDL_Rect *dr, DS_BOOL bUpdateScreen ) |
|---|
| 861 | { |
|---|
| 862 | int err=0; |
|---|
| 863 | |
|---|
| 864 | if (src_surf == dst_surf) |
|---|
| 865 | return err; |
|---|
| 866 | |
|---|
| 867 | if (0)//dst_surf == (SDL_Surface *)DHL_GFX_GetPhysicalFrameBuffer()) |
|---|
| 868 | { |
|---|
| 869 | int x = 0, y =0; |
|---|
| 870 | for (y = 0; y < dst_surf->h; y++) |
|---|
| 871 | { |
|---|
| 872 | for (x = 0; x < dst_surf->w; x++) |
|---|
| 873 | { |
|---|
| 874 | int xx = (x * src_surf->w) / dst_surf->w; |
|---|
| 875 | int yy = (y * src_surf->h) / dst_surf->h; |
|---|
| 876 | DS_PIXEL_t Pixel; |
|---|
| 877 | DD_GFX_ReadPixels((DS_U32)src_surf, xx, yy, 1, 1, &Pixel); |
|---|
| 878 | DHL_GFX_DrawImage((DS_U32)dst_surf, x, y, 1, 1, &Pixel); |
|---|
| 879 | } |
|---|
| 880 | } |
|---|
| 881 | } |
|---|
| 882 | else |
|---|
| 883 | { |
|---|
| 884 | // SDL_Rect sr, dr; |
|---|
| 885 | // |
|---|
| 886 | // sr.x = p->src_x; |
|---|
| 887 | // sr.y = p->src_y; |
|---|
| 888 | // sr.w = p->src_w; |
|---|
| 889 | // sr.h = p->src_h; |
|---|
| 890 | // |
|---|
| 891 | // dr.x = p->dst_x; |
|---|
| 892 | // dr.y = p->dst_y; |
|---|
| 893 | // dr.w = p->dst_w; |
|---|
| 894 | // dr.h = p->dst_h; |
|---|
| 895 | #if 0 |
|---|
| 896 | if (dst_surf != ScrSurf && dst_surf != VidSurf) |
|---|
| 897 | //if (dst_surf == PrimSurf || dst_surf == ScndSurf ) |
|---|
| 898 | SDL_FillRect( dst_surf, dr, 0x000000 ); |
|---|
| 899 | #endif |
|---|
| 900 | |
|---|
| 901 | if ( (err=SDL_BlitSurface( src_surf, sr, dst_surf, dr )) < 0 ) |
|---|
| 902 | { |
|---|
| 903 | printf("SDL_BlitSurface(): %s (%d)\n", SDL_GetError(), err); |
|---|
| 904 | err = -1; |
|---|
| 905 | } |
|---|
| 906 | } |
|---|
| 907 | |
|---|
| 908 | if ( bUpdateScreen ) |
|---|
| 909 | { |
|---|
| 910 | doCmd_SDLUpdateScreen(sr, dr); |
|---|
| 911 | } |
|---|
| 912 | return 0; |
|---|
| 913 | } |
|---|
| 914 | |
|---|
| 915 | static int doCmd_SDLUpdateScreen(SDL_Rect *src_rect, SDL_Rect *dst_rect) |
|---|
| 916 | { |
|---|
| 917 | // SDL_Flip( PhySurf ); |
|---|
| 918 | int err; |
|---|
| 919 | |
|---|
| 920 | err=SDL_FillRect( ScrSurf, dst_rect, 0x000000 ); |
|---|
| 921 | SysASSERT(err==0); |
|---|
| 922 | |
|---|
| 923 | err=SDL_BlitSurface( VidSurf, src_rect, ScrSurf, dst_rect ); |
|---|
| 924 | SysASSERT(err==0); |
|---|
| 925 | |
|---|
| 926 | if ( DHL_GFX_IsEnabled(PLANE_CC) ) |
|---|
| 927 | { |
|---|
| 928 | err=SDL_BlitSurface( ScndSurf, src_rect, ScrSurf, dst_rect ); |
|---|
| 929 | SysASSERT(err==0); |
|---|
| 930 | } |
|---|
| 931 | if ( DHL_GFX_IsEnabled(PLANE_OSD) ) |
|---|
| 932 | { |
|---|
| 933 | err=SDL_BlitSurface( PrimSurf, src_rect, ScrSurf, dst_rect ); |
|---|
| 934 | SysASSERT(err==0); |
|---|
| 935 | } |
|---|
| 936 | |
|---|
| 937 | if ( dst_rect ) |
|---|
| 938 | { |
|---|
| 939 | //SDL_UpdateRect( ScrSurf, dst_rect->x, dst_rect->y, dst_rect->w, dst_rect->h ); |
|---|
| 940 | err=SDL_BlitSurface( ScrSurf, dst_rect, PhySurf, dst_rect ); |
|---|
| 941 | SysASSERT(err==0); |
|---|
| 942 | |
|---|
| 943 | SDL_UpdateRect( PhySurf, dst_rect->x, dst_rect->y, dst_rect->w, dst_rect->h ); |
|---|
| 944 | } |
|---|
| 945 | else |
|---|
| 946 | { |
|---|
| 947 | //SDL_UpdateRect( ScrSurf, 0, 0, 0, 0 ); |
|---|
| 948 | err=SDL_BlitSurface( ScrSurf, NULL, PhySurf, NULL ); |
|---|
| 949 | SysASSERT(err==0); |
|---|
| 950 | SDL_UpdateRect( PhySurf, 0, 0, 0, 0 ); |
|---|
| 951 | } |
|---|
| 952 | |
|---|
| 953 | |
|---|
| 954 | //SDL_Flip( PhySurf ); |
|---|
| 955 | |
|---|
| 956 | return 0; |
|---|
| 957 | } |
|---|
| 958 | |
|---|
| 959 | static DS_U32 doCmd_SDLAllocFrameBuffer( int width, int height, int fmt ) |
|---|
| 960 | { |
|---|
| 961 | SDL_Surface *surf = (SDL_Surface *)NULL; |
|---|
| 962 | |
|---|
| 963 | SysENSURE( fmt == 8 || fmt == 16 || fmt == 32 ); |
|---|
| 964 | |
|---|
| 965 | #if (DHL_GFX_FMT32 == DHL_GFX_FORMAT) |
|---|
| 966 | surf=SDL_CreateRGBSurface( SDL_SWSURFACE | SDL_SRCALPHA, width, height, fmt, 0xFF0000, 0xFF00, 0xFF, 0xFF000000); |
|---|
| 967 | #else |
|---|
| 968 | surf=SDL_CreateRGBSurface( SDL_SWSURFACE | SDL_SRCALPHA, width, height, fmt, 0xF00, 0xF0, 0xF, 0xF000); |
|---|
| 969 | #endif |
|---|
| 970 | //surf=SDL_CreateRGBSurface( SDL_SWSURFACE, width, height, fmt, 0xFF0000, 0xFF00, 0xFF, 0xFF000000); |
|---|
| 971 | //surf=SDL_CreateRGBSurface( SDL_SWSURFACE, width, height, fmt, 0, 0, 0, 0); |
|---|
| 972 | if (!surf) |
|---|
| 973 | { |
|---|
| 974 | fprintf(stderr, "ERROR: SDL_CreateRGBSurface()\n"); |
|---|
| 975 | return 0; |
|---|
| 976 | } |
|---|
| 977 | |
|---|
| 978 | SDL_SetAlpha( surf, 0, 0xFF ); |
|---|
| 979 | //SDL_SetColorKey( surf, 0, 0xFF000000 ); |
|---|
| 980 | |
|---|
| 981 | return (DS_U32)surf; |
|---|
| 982 | } |
|---|
| 983 | |
|---|
| 984 | static int doCmd_SDLDrawBox(DS_U32 pBufferId, int x, int y, int w, int h, DS_PIXEL_t color) |
|---|
| 985 | { |
|---|
| 986 | SDL_Surface *surf = (SDL_Surface *)pBufferId; |
|---|
| 987 | SDL_Rect rect; |
|---|
| 988 | int err; |
|---|
| 989 | |
|---|
| 990 | SysREQUIRE( surf ); |
|---|
| 991 | |
|---|
| 992 | rect.x = x; |
|---|
| 993 | rect.y = y; |
|---|
| 994 | rect.w = w; |
|---|
| 995 | rect.h = h; |
|---|
| 996 | |
|---|
| 997 | err=SDL_FillRect( surf, &rect, color ); |
|---|
| 998 | |
|---|
| 999 | return err; |
|---|
| 1000 | } |
|---|
| 1001 | |
|---|
| 1002 | static void _InitSDLThread(void) |
|---|
| 1003 | { |
|---|
| 1004 | if ( bSDLThread == DS_TRUE ) |
|---|
| 1005 | { |
|---|
| 1006 | printf("!!! SDL thread is already created.\n"); |
|---|
| 1007 | return; |
|---|
| 1008 | } |
|---|
| 1009 | |
|---|
| 1010 | SdlQueue = OS_CreateMessageQueue("qSdl", 0, MAX_SDL_MESSAGES, sizeof(SDLMessage)); |
|---|
| 1011 | SysASSERT( SdlQueue ); |
|---|
| 1012 | |
|---|
| 1013 | SdlTaskId = OS_SpawnTask( _tSDLMonitor, "tSDLMonitor", 0, 4096, (DS_U32)0); |
|---|
| 1014 | SysASSERT( SdlTaskId ); |
|---|
| 1015 | |
|---|
| 1016 | bSDLThread = DS_TRUE; |
|---|
| 1017 | |
|---|
| 1018 | return; |
|---|
| 1019 | } |
|---|
| 1020 | |
|---|
| 1021 | static void _CloseSDLThread(void) |
|---|
| 1022 | { |
|---|
| 1023 | if ( bSDLThread == DS_FALSE ) |
|---|
| 1024 | { |
|---|
| 1025 | printf("!!! SDL thread is already deleted.\n"); |
|---|
| 1026 | return; |
|---|
| 1027 | } |
|---|
| 1028 | |
|---|
| 1029 | bSDLThread = DS_FALSE; |
|---|
| 1030 | |
|---|
| 1031 | return; |
|---|
| 1032 | } |
|---|
| 1033 | |
|---|
| 1034 | // 2009.03.18 megakiss |
|---|
| 1035 | // OSD Plane ¿Í Video Plane ÀÌ Àû¿ëµÈ »õ·Î¿î 8ºñÆ® ¹öÀü |
|---|
| 1036 | |
|---|
| 1037 | static SDL_Surface *screen_surface = 0; |
|---|
| 1038 | static SDL_Surface *osd_surface = 0; |
|---|
| 1039 | static SDL_Surface *video_surface = 0; |
|---|
| 1040 | static int g_OSDWidth = 0; |
|---|
| 1041 | static int g_OSDHeight = 0; |
|---|
| 1042 | static DS_BOOL g_OSDInitialized = DS_FALSE; |
|---|
| 1043 | |
|---|
| 1044 | void SDL_ScaleBlit(SDL_Surface *src, SDL_Surface *des) |
|---|
| 1045 | { |
|---|
| 1046 | int x = 0, y = 0; |
|---|
| 1047 | for (y = 0; y < des->h; y++) |
|---|
| 1048 | { |
|---|
| 1049 | for (x = 0; x < des->w; x++) |
|---|
| 1050 | { |
|---|
| 1051 | int xx = (x * src->w) / des->w; |
|---|
| 1052 | int yy = (y * src->h) / des->h; |
|---|
| 1053 | SDL_Rect rectSrc = {xx,yy,1,1}; |
|---|
| 1054 | SDL_Rect rectDes = {x,y,1,1}; |
|---|
| 1055 | SDL_BlitSurface(src, &rectSrc, des, &rectDes); |
|---|
| 1056 | } |
|---|
| 1057 | } |
|---|
| 1058 | } |
|---|
| 1059 | |
|---|
| 1060 | static void LoadSize(int *w, int *h) |
|---|
| 1061 | { |
|---|
| 1062 | FILE *fp = fopen("win_size.txt", "r"); |
|---|
| 1063 | if (fp == 0) return; |
|---|
| 1064 | fscanf(fp,"%d,%d", w, h); |
|---|
| 1065 | fclose(fp); |
|---|
| 1066 | } |
|---|
| 1067 | |
|---|
| 1068 | static void SaveSize(int w, int h) |
|---|
| 1069 | { |
|---|
| 1070 | FILE *fp = fopen("win_size.txt", "w"); |
|---|
| 1071 | fprintf(fp,"%d,%d", w, h); |
|---|
| 1072 | fclose(fp); |
|---|
| 1073 | } |
|---|
| 1074 | |
|---|
| 1075 | static int SDLCALL ThreadFunc(void *n) |
|---|
| 1076 | { |
|---|
| 1077 | int nWidth = g_OSDWidth, nHeight = g_OSDHeight; |
|---|
| 1078 | SDL_Event event; |
|---|
| 1079 | SDL_Init(SDL_INIT_VIDEO); // SDL ÃÖ±âÈ |
|---|
| 1080 | LoadSize(&nWidth, &nHeight); // ¸¶Áö¸· ÀúÀåÇß´ø À©µµ¿ì »çÀÌÁî ·Îµù |
|---|
| 1081 | screen_surface=SDL_SetVideoMode(nWidth, nHeight, 32, SDL_RESIZABLE); // ½ºÅ©¸° ¼Çǽº »ý¼º |
|---|
| 1082 | SDL_WM_SetCaption("DST PC Emulator",0); // ŸÀÌÆ² ¹Ù |
|---|
| 1083 | bmp_surface = SDL_LoadBMP("sosi.bmp"); // ¹è°æ ±×¸²¿ë bmp ¼Çǽº »ý¼º |
|---|
| 1084 | // ºñµð¿À ¼Çǽº´Â bmp ¼Çǽº¸¦ ÇöÀç ȸé Å©±â¿¡ ¸ÂÃß¾î È®´ëÇÑ °ÍÀÌ´Ù. |
|---|
| 1085 | video_surface = SDL_CreateRGBSurface(SDL_SWSURFACE, nWidth, nHeight, 32, 0, 0, 0, 0); |
|---|
| 1086 | SDL_ScaleBlit(bmp_surface, video_surface); |
|---|
| 1087 | // ºñµð¿À ¼Çǽº¸¦ ½ºÅ©¸° ¼Çǽº¿¡ º¹»ç |
|---|
| 1088 | SDL_BlitSurface(video_surface, 0, screen_surface, 0); |
|---|
| 1089 | // OSD ¼Çǽº »ý¼º ÆÈ·¹Æ®´Â ARGB(8:8:8:8) |
|---|
| 1090 | osd_surface = SDL_CreateRGBSurface(SDL_SWSURFACE, g_OSDWidth, g_OSDHeight, 32, 0x00FF0000, 0xFF00, 0xFF, 0xFF000000); |
|---|
| 1091 | // ȸ鿡 º¸ÀδÙ. |
|---|
| 1092 | SDL_Flip(screen_surface); |
|---|
| 1093 | // ÃʱâÈ ¿Ï·á |
|---|
| 1094 | g_OSDInitialized = DS_TRUE; // À̰ªÀÌ TRUE À϶§±îÁö initÇÔ¼ö¿¡¼ ±â´Ù¸°´Ù. |
|---|
| 1095 | while (SDL_WaitEvent(&event)) |
|---|
| 1096 | { |
|---|
| 1097 | switch (event.type) |
|---|
| 1098 | { |
|---|
| 1099 | case SDL_VIDEORESIZE: |
|---|
| 1100 | SaveSize(event.resize.w, event.resize.h); // À©µµ »çÀÌÁî ÀúÀå |
|---|
| 1101 | // º¯°æµÈ »çÀÌÁî¿¡ ¸Â°Ô ºñµð¿À ¸ðµå Àç¼³Á¤ |
|---|
| 1102 | screen_surface = SDL_SetVideoMode(event.resize.w, event.resize.h, 32, SDL_RESIZABLE); |
|---|
| 1103 | // º¯°æµÈ ȸé Å©±â¿¡ ¸Â°Ô bmp ¼Çǽº¸¦ º¯ÇüÇÑ video surface¸¦ Àç»ý¼ºÇÑ´Ù. |
|---|
| 1104 | SDL_FreeSurface(video_surface); |
|---|
| 1105 | video_surface = SDL_CreateRGBSurface(SDL_SWSURFACE, event.resize.w, event.resize.h, 32, 0, 0, 0, 0); |
|---|
| 1106 | SDL_ScaleBlit(bmp_surface, video_surface); |
|---|
| 1107 | // ºñµð¿À ¼Çǽº¸¦ ½ºÅ©¸° ¼Çǽº¿¡ º¹»ç |
|---|
| 1108 | SDL_BlitSurface(video_surface, 0, screen_surface, 0); |
|---|
| 1109 | // OSD ¼Çǽº¸¦ ½ºÅ©¸° ¼Çǽº¿¡ º¹»ç |
|---|
| 1110 | SDL_ScaleBlit(osd_surface, screen_surface); |
|---|
| 1111 | // ȸéÀ» º¸ÀδÙ. |
|---|
| 1112 | SDL_Flip(screen_surface); |
|---|
| 1113 | break; |
|---|
| 1114 | |
|---|
| 1115 | case SDL_KEYDOWN: |
|---|
| 1116 | DHL_IR_Input((DS_U32)(event.key.keysym.sym|0xCAFE0000),1); |
|---|
| 1117 | break; |
|---|
| 1118 | |
|---|
| 1119 | case SDL_KEYUP: |
|---|
| 1120 | DHL_IR_Input((DS_U32)(event.key.keysym.sym|0xCAFE0000),0); |
|---|
| 1121 | break; |
|---|
| 1122 | |
|---|
| 1123 | case SDL_QUIT: |
|---|
| 1124 | SDL_Quit(); |
|---|
| 1125 | exit(0); |
|---|
| 1126 | break; |
|---|
| 1127 | } |
|---|
| 1128 | } |
|---|
| 1129 | return(0); |
|---|
| 1130 | } |
|---|
| 1131 | |
|---|
| 1132 | void DD_GFX8_Init(int w, int h) |
|---|
| 1133 | { |
|---|
| 1134 | //±×·¡ÇÈ ÃʱâÈ ÇÔ¼ö ¾²·¹µå¸¦ »ý¼ºÇϰí ÃʱâȰ¡ ¿Ï·áµÉ¶§±îÁö ±â´Ù¸°´Ù. |
|---|
| 1135 | g_OSDWidth = w; |
|---|
| 1136 | g_OSDHeight = h; |
|---|
| 1137 | SDL_CreateThread(ThreadFunc, 0); |
|---|
| 1138 | while (g_OSDInitialized == DS_FALSE) OS_Delay(10); |
|---|
| 1139 | } |
|---|
| 1140 | |
|---|
| 1141 | unsigned int Pallette[256]; |
|---|
| 1142 | void DD_GFX8_BlockCopy(int x, int y, int w, int h, unsigned char *buff) |
|---|
| 1143 | { |
|---|
| 1144 | // OSD_Surface(32bit)¿¡ 8ºñÆ® ¹öÆÛ¸¦ º¹»çÇÑ´Ù. |
|---|
| 1145 | int xx = 0, yy = 0; |
|---|
| 1146 | if (g_OSDInitialized == DS_FALSE) return; |
|---|
| 1147 | for (yy = 0 ; yy < h; yy++) |
|---|
| 1148 | { |
|---|
| 1149 | for (xx = 0; xx < w; xx++) |
|---|
| 1150 | { |
|---|
| 1151 | SDL_Rect rect = {x+xx,y+yy,1,1}; |
|---|
| 1152 | Uint32 pixel = Pallette[buff[yy*w+xx]]; |
|---|
| 1153 | SDL_FillRect(osd_surface, &rect, pixel); |
|---|
| 1154 | } |
|---|
| 1155 | } |
|---|
| 1156 | #if 0 |
|---|
| 1157 | SDL_BlitSurface(video_surface, 0, screen_surface, 0); |
|---|
| 1158 | // OSD ¼Çǽº¸¦ ½ºÅ©¸° ¼Çǽº¿¡ º¹»ç |
|---|
| 1159 | SDL_ScaleBlit(osd_surface, screen_surface); |
|---|
| 1160 | // ȸéÀ» º¸ÀδÙ. |
|---|
| 1161 | SDL_Flip(screen_surface); |
|---|
| 1162 | #else |
|---|
| 1163 | // 1:1 ȸéÀÌ ¾Æ´Ï¹Ç·Î º¸¿©Áö´Â À©µµ¿ì »ó¿¡ ¾÷µ¥ÀÌÆ® ÇÒ ¿µ¿ªÀ» ±¸ÇÑ´Ù. |
|---|
| 1164 | SDL_Rect rect; |
|---|
| 1165 | rect.x = (x * video_surface->w) / osd_surface->w; |
|---|
| 1166 | rect.y = (y * video_surface->h) / osd_surface->h; |
|---|
| 1167 | rect.w = (w * video_surface->w) / osd_surface->w; |
|---|
| 1168 | rect.h = (h * video_surface->h) / osd_surface->h; |
|---|
| 1169 | |
|---|
| 1170 | // ¿µ¿ª ¿¬»ê ÀÌÈÄ ³ª´©±â ¿¬»ê¿¡ ÀÇÇÑ º¸Á¤ÀÌ ÇÊ¿äÇÏ´Ù. |
|---|
| 1171 | rect.x-=2; |
|---|
| 1172 | rect.y-=2; |
|---|
| 1173 | rect.w+=4; |
|---|
| 1174 | rect.h+=4; |
|---|
| 1175 | |
|---|
| 1176 | if (rect.x < 0) rect.x = 0; |
|---|
| 1177 | if (rect.y < 0) rect.y = 0; |
|---|
| 1178 | if (rect.x + rect.w > screen_surface->w) rect.w=screen_surface->w - rect.x; |
|---|
| 1179 | if (rect.y + rect.h < screen_surface->h) rect.h=screen_surface->h - rect.y; |
|---|
| 1180 | |
|---|
| 1181 | // ºñµð¿À ¹öÆÛ¸¦ ½ºÅ©¸° ¹öÆÛ·Î º¹»ç |
|---|
| 1182 | SDL_BlitSurface(video_surface, &rect, screen_surface, &rect); |
|---|
| 1183 | // OSD ¹öÆÛ¸¦ ½ºÄÉÀϸµÇÏ¿© ½ºÅ©¸° ¹öÆÛ·Î º¹»ç |
|---|
| 1184 | for (yy = rect.y; yy < rect.y+rect.h; yy++) |
|---|
| 1185 | { |
|---|
| 1186 | for (xx = rect.x; xx < rect.x+rect.w; xx++) |
|---|
| 1187 | { |
|---|
| 1188 | int src_x = (xx * osd_surface->w) / screen_surface->w; |
|---|
| 1189 | int src_y = (yy * osd_surface->h) / screen_surface->h; |
|---|
| 1190 | SDL_Rect rectSrc = {src_x, src_y,1,1}; |
|---|
| 1191 | SDL_Rect rectDes = {xx,yy,1,1}; |
|---|
| 1192 | SDL_BlitSurface(osd_surface, &rectSrc, screen_surface, &rectDes); |
|---|
| 1193 | } |
|---|
| 1194 | } |
|---|
| 1195 | // ½ºÅ©¸° ¹öÆÛ¸¦ ȸéÀ¸·Î ¾÷µ¥ÀÌÆ® |
|---|
| 1196 | SDL_UpdateRect(screen_surface, rect.x, rect.y, rect.w, rect.h); |
|---|
| 1197 | #endif |
|---|
| 1198 | } |
|---|
| 1199 | |
|---|
| 1200 | void DD_GFX8_SetPallete(unsigned int *pal) |
|---|
| 1201 | { |
|---|
| 1202 | memcpy(Pallette,pal, sizeof(unsigned int)*256); |
|---|
| 1203 | } |
|---|
| 1204 | |
|---|
| 1205 | void DD_GFX32_Init(int w, int h) |
|---|
| 1206 | { |
|---|
| 1207 | //±×·¡ÇÈ ÃʱâÈ ÇÔ¼ö ¾²·¹µå¸¦ »ý¼ºÇϰí ÃʱâȰ¡ ¿Ï·áµÉ¶§±îÁö ±â´Ù¸°´Ù. |
|---|
| 1208 | g_OSDWidth = w; |
|---|
| 1209 | g_OSDHeight = h; |
|---|
| 1210 | SDL_CreateThread(ThreadFunc, 0); |
|---|
| 1211 | while (g_OSDInitialized == DS_FALSE) OS_Delay(10); |
|---|
| 1212 | } |
|---|
| 1213 | |
|---|
| 1214 | unsigned int Pallette[256]; |
|---|
| 1215 | void DD_GFX32_BlockCopy(int x, int y, int w, int h, unsigned long *buff) |
|---|
| 1216 | { |
|---|
| 1217 | // OSD_Surface(32bit)¿¡ 8ºñÆ® ¹öÆÛ¸¦ º¹»çÇÑ´Ù. |
|---|
| 1218 | int xx = 0, yy = 0; |
|---|
| 1219 | if (g_OSDInitialized == DS_FALSE) return; |
|---|
| 1220 | for (yy = 0 ; yy < h; yy++) |
|---|
| 1221 | { |
|---|
| 1222 | for (xx = 0; xx < w; xx++) |
|---|
| 1223 | { |
|---|
| 1224 | SDL_Rect rect = {x+xx,y+yy,1,1}; |
|---|
| 1225 | Uint32 pixel = buff[yy*w+xx]; |
|---|
| 1226 | SDL_FillRect(osd_surface, &rect, pixel); |
|---|
| 1227 | } |
|---|
| 1228 | } |
|---|
| 1229 | #if 0 |
|---|
| 1230 | SDL_BlitSurface(video_surface, 0, screen_surface, 0); |
|---|
| 1231 | // OSD ¼Çǽº¸¦ ½ºÅ©¸° ¼Çǽº¿¡ º¹»ç |
|---|
| 1232 | SDL_ScaleBlit(osd_surface, screen_surface); |
|---|
| 1233 | // ȸéÀ» º¸ÀδÙ. |
|---|
| 1234 | SDL_Flip(screen_surface); |
|---|
| 1235 | #else |
|---|
| 1236 | // 1:1 ȸéÀÌ ¾Æ´Ï¹Ç·Î º¸¿©Áö´Â À©µµ¿ì »ó¿¡ ¾÷µ¥ÀÌÆ® ÇÒ ¿µ¿ªÀ» ±¸ÇÑ´Ù. |
|---|
| 1237 | SDL_Rect rect; |
|---|
| 1238 | rect.x = (x * video_surface->w) / osd_surface->w; |
|---|
| 1239 | rect.y = (y * video_surface->h) / osd_surface->h; |
|---|
| 1240 | rect.w = (w * video_surface->w) / osd_surface->w; |
|---|
| 1241 | rect.h = (h * video_surface->h) / osd_surface->h; |
|---|
| 1242 | |
|---|
| 1243 | // ¿µ¿ª ¿¬»ê ÀÌÈÄ ³ª´©±â ¿¬»ê¿¡ ÀÇÇÑ º¸Á¤ÀÌ ÇÊ¿äÇÏ´Ù. |
|---|
| 1244 | rect.x-=2; |
|---|
| 1245 | rect.y-=2; |
|---|
| 1246 | rect.w+=4; |
|---|
| 1247 | rect.h+=4; |
|---|
| 1248 | |
|---|
| 1249 | if (rect.x < 0) rect.x = 0; |
|---|
| 1250 | if (rect.y < 0) rect.y = 0; |
|---|
| 1251 | if (rect.x + rect.w > screen_surface->w) rect.w=screen_surface->w - rect.x; |
|---|
| 1252 | if (rect.y + rect.h < screen_surface->h) rect.h=screen_surface->h - rect.y; |
|---|
| 1253 | |
|---|
| 1254 | // ºñµð¿À ¹öÆÛ¸¦ ½ºÅ©¸° ¹öÆÛ·Î º¹»ç |
|---|
| 1255 | SDL_BlitSurface(video_surface, &rect, screen_surface, &rect); |
|---|
| 1256 | // OSD ¹öÆÛ¸¦ ½ºÄÉÀϸµÇÏ¿© ½ºÅ©¸° ¹öÆÛ·Î º¹»ç |
|---|
| 1257 | for (yy = rect.y; yy < rect.y+rect.h; yy++) |
|---|
| 1258 | { |
|---|
| 1259 | for (xx = rect.x; xx < rect.x+rect.w; xx++) |
|---|
| 1260 | { |
|---|
| 1261 | int src_x = (xx * osd_surface->w) / screen_surface->w; |
|---|
| 1262 | int src_y = (yy * osd_surface->h) / screen_surface->h; |
|---|
| 1263 | SDL_Rect rectSrc = {src_x, src_y,1,1}; |
|---|
| 1264 | SDL_Rect rectDes = {xx,yy,1,1}; |
|---|
| 1265 | SDL_BlitSurface(osd_surface, &rectSrc, screen_surface, &rectDes); |
|---|
| 1266 | } |
|---|
| 1267 | } |
|---|
| 1268 | // ½ºÅ©¸° ¹öÆÛ¸¦ ȸéÀ¸·Î ¾÷µ¥ÀÌÆ® |
|---|
| 1269 | SDL_UpdateRect(screen_surface, rect.x, rect.y, rect.w, rect.h); |
|---|
| 1270 | #endif |
|---|
| 1271 | } |
|---|