Mercurial > sdl-ios-xcode
annotate src/video/nanox/SDL_nximage.c @ 4066:58a5055da431 SDL-1.2
More improvements for bug #373
Show the SDL cursor in the window and the arrow cursor outside the window.
This is also supposed to show the SDL cursor when activated, but that code
isn't working yet...
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sat, 14 Jul 2007 08:27:06 +0000 |
parents | d910939febfa |
children | 782fd950bd46 c121d94672cb a1b03ba2fcd0 |
rev | line source |
---|---|
30
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1 /* |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
2 SDL - Simple DirectMedia Layer |
769
b8d311d90021
Updated copyright information for 2004 (Happy New Year!)
Sam Lantinga <slouken@libsdl.org>
parents:
700
diff
changeset
|
3 Copyright (C) 1997-2004 Sam Lantinga |
30
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
4 Copyright (C) 2001 Hsieh-Fu Tsai |
471
26dafefeebb2
Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
5 Copyright (C) 2002 Greg Haerr <greg@censoft.com> |
30
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
6 |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
7 This library is free software; you can redistribute it and/or |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
8 modify it under the terms of the GNU Library General Public |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
9 License as published by the Free Software Foundation; either |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
10 version 2 of the License, or (at your option) any later version. |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
11 |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
12 This library is distributed in the hope that it will be useful, |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
13 but WITHOUT ANY WARRANTY; without even the implied warranty of |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
15 Library General Public License for more details. |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
16 |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
17 You should have received a copy of the GNU Library General Public |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
18 License along with this library; if not, write to the Free |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
20 |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
21 Sam Lantinga |
252
e8157fcb3114
Updated the source with the correct e-mail address
Sam Lantinga <slouken@libsdl.org>
parents:
30
diff
changeset
|
22 slouken@libsdl.org |
30
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
23 |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
24 Hsieh-Fu Tsai |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
25 clare@setabox.com |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
26 */ |
1402
d910939febfa
Use consistent identifiers for the various platforms we support.
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
27 #include "SDL_config.h" |
30
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
28 |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
29 #include "SDL_nximage_c.h" |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
30 |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
31 void NX_NormalUpdate (_THIS, int numrects, SDL_Rect * rects) |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
32 { |
471
26dafefeebb2
Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
33 int i, j, xinc, yinc, destinc, rowinc ; |
30
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
34 int x, y, w, h ; |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
35 unsigned char * src = NULL, * dest = NULL ; |
471
26dafefeebb2
Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
36 |
30
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
37 Dprintf ("enter NX_NormalUpdate\n") ; |
471
26dafefeebb2
Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
38 |
26dafefeebb2
Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
39 /* These are the values for the incoming image */ |
30
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
40 xinc = this -> screen -> format -> BytesPerPixel ; |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
41 yinc = this -> screen -> pitch ; |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
42 |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
43 for (i = 0; i < numrects; ++ i) { |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
44 x = rects [i].x, y = rects [i].y ; |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
45 w = rects [i].w, h = rects [i].h ; |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
46 src = SDL_Image + y * yinc + x * xinc ; |
471
26dafefeebb2
Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
47 #ifdef ENABLE_NANOX_DIRECT_FB |
699
d3b2e93629eb
Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents:
698
diff
changeset
|
48 if (Clientfb) { |
d3b2e93629eb
Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents:
698
diff
changeset
|
49 if (currently_fullscreen) |
d3b2e93629eb
Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents:
698
diff
changeset
|
50 dest = fbinfo.winpixels + (((y+OffsetY) * fbinfo.pitch) + |
d3b2e93629eb
Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents:
698
diff
changeset
|
51 ((x+OffsetX) * fbinfo.bytespp)); |
d3b2e93629eb
Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents:
698
diff
changeset
|
52 else |
d3b2e93629eb
Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents:
698
diff
changeset
|
53 dest = fbinfo.winpixels + ((y * fbinfo.pitch) + (x * fbinfo.bytespp)); |
d3b2e93629eb
Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents:
698
diff
changeset
|
54 destinc = fbinfo.pitch; |
d3b2e93629eb
Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents:
698
diff
changeset
|
55 } |
d3b2e93629eb
Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents:
698
diff
changeset
|
56 else |
471
26dafefeebb2
Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
57 #endif |
699
d3b2e93629eb
Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents:
698
diff
changeset
|
58 { |
471
26dafefeebb2
Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
59 dest = Image_buff ; |
26dafefeebb2
Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
60 destinc = w * xinc ; |
699
d3b2e93629eb
Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents:
698
diff
changeset
|
61 } |
d3b2e93629eb
Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents:
698
diff
changeset
|
62 rowinc = w * xinc; |
30
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
63 |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
64 // apply GammaRamp table |
471
26dafefeebb2
Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
65 if ((pixel_type == MWPF_TRUECOLOR0888 || pixel_type == MWPF_TRUECOLOR888) |
699
d3b2e93629eb
Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents:
698
diff
changeset
|
66 && GammaRamp_R && GammaRamp_G && GammaRamp_B) { |
d3b2e93629eb
Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents:
698
diff
changeset
|
67 Uint8 * ptrsrc ; |
d3b2e93629eb
Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents:
698
diff
changeset
|
68 Uint8 * ptrdst ; |
30
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
69 int k ; |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
70 |
699
d3b2e93629eb
Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents:
698
diff
changeset
|
71 for (j = h; j > 0; -- j, src += yinc, dest += destinc) { |
d3b2e93629eb
Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents:
698
diff
changeset
|
72 ptrsrc = src ; |
d3b2e93629eb
Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents:
698
diff
changeset
|
73 ptrdst = dest ; |
30
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
74 for (k = w; k > 0; -- k) { |
699
d3b2e93629eb
Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents:
698
diff
changeset
|
75 *ptrdst++ = GammaRamp_B [*ptrsrc++] >> 8; |
d3b2e93629eb
Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents:
698
diff
changeset
|
76 *ptrdst++ = GammaRamp_G [*ptrsrc++] >> 8; |
d3b2e93629eb
Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents:
698
diff
changeset
|
77 *ptrdst++ = GammaRamp_R [*ptrsrc++] >> 8; |
d3b2e93629eb
Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents:
698
diff
changeset
|
78 *ptrdst++ = 0; |
d3b2e93629eb
Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents:
698
diff
changeset
|
79 ++ptrsrc; |
30
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
80 } |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
81 } |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
82 } |
700
c35edafc84d1
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
699
diff
changeset
|
83 #if 1 /* This is needed for microwindows 0.90 or older */ |
699
d3b2e93629eb
Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents:
698
diff
changeset
|
84 else if (pixel_type == MWPF_TRUECOLOR0888 || pixel_type == MWPF_TRUECOLOR888) { |
d3b2e93629eb
Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents:
698
diff
changeset
|
85 Uint8 * ptrsrc ; |
d3b2e93629eb
Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents:
698
diff
changeset
|
86 Uint8 * ptrdst ; |
d3b2e93629eb
Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents:
698
diff
changeset
|
87 int k ; |
30
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
88 |
699
d3b2e93629eb
Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents:
698
diff
changeset
|
89 for (j = h; j > 0; -- j, src += yinc, dest += destinc) { |
d3b2e93629eb
Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents:
698
diff
changeset
|
90 ptrsrc = src ; |
d3b2e93629eb
Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents:
698
diff
changeset
|
91 ptrdst = dest ; |
d3b2e93629eb
Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents:
698
diff
changeset
|
92 for (k = w; k > 0; -- k) { |
d3b2e93629eb
Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents:
698
diff
changeset
|
93 *ptrdst++ = *ptrsrc++; |
d3b2e93629eb
Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents:
698
diff
changeset
|
94 *ptrdst++ = *ptrsrc++; |
d3b2e93629eb
Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents:
698
diff
changeset
|
95 *ptrdst++ = *ptrsrc++; |
d3b2e93629eb
Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents:
698
diff
changeset
|
96 *ptrdst++ = 0; |
d3b2e93629eb
Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents:
698
diff
changeset
|
97 ++ptrsrc; |
d3b2e93629eb
Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents:
698
diff
changeset
|
98 } |
d3b2e93629eb
Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents:
698
diff
changeset
|
99 } |
d3b2e93629eb
Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents:
698
diff
changeset
|
100 } |
d3b2e93629eb
Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents:
698
diff
changeset
|
101 #endif |
d3b2e93629eb
Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents:
698
diff
changeset
|
102 else |
d3b2e93629eb
Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents:
698
diff
changeset
|
103 { |
d3b2e93629eb
Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents:
698
diff
changeset
|
104 for (j = h; j > 0; -- j, src += yinc, dest += destinc) |
1338
604d73db6802
Removed uses of stdlib.h and string.h
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
105 SDL_memcpy (dest, src, rowinc) ; |
699
d3b2e93629eb
Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents:
698
diff
changeset
|
106 } |
d3b2e93629eb
Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents:
698
diff
changeset
|
107 if (!Clientfb) { |
471
26dafefeebb2
Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
108 if (currently_fullscreen) { |
26dafefeebb2
Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
109 GrArea (FSwindow, SDL_GC, x + OffsetX, y + OffsetY, w, h, Image_buff, |
26dafefeebb2
Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
110 pixel_type) ; |
26dafefeebb2
Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
111 } else { |
26dafefeebb2
Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
112 GrArea (SDL_Window, SDL_GC, x, y, w, h, Image_buff, pixel_type) ; |
26dafefeebb2
Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
113 } |
699
d3b2e93629eb
Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents:
698
diff
changeset
|
114 } |
30
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
115 } |
471
26dafefeebb2
Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
116 GrFlush(); |
30
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
117 |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
118 Dprintf ("leave NX_NormalUpdate\n") ; |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
119 } |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
120 |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
121 int NX_SetupImage (_THIS, SDL_Surface * screen) |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
122 { |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
123 int size = screen -> h * screen -> pitch ; |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
124 |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
125 Dprintf ("enter NX_SetupImage\n") ; |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
126 |
1338
604d73db6802
Removed uses of stdlib.h and string.h
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
127 screen -> pixels = (void *) SDL_malloc (size) ; |
471
26dafefeebb2
Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
128 |
26dafefeebb2
Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
129 if (!Clientfb) { |
1338
604d73db6802
Removed uses of stdlib.h and string.h
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
130 Image_buff = (unsigned char *) SDL_malloc (size) ; |
471
26dafefeebb2
Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
131 if (screen -> pixels == NULL || Image_buff == NULL) { |
1338
604d73db6802
Removed uses of stdlib.h and string.h
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
132 SDL_free (screen -> pixels) ; |
604d73db6802
Removed uses of stdlib.h and string.h
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
133 SDL_free (Image_buff) ; |
471
26dafefeebb2
Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
134 SDL_OutOfMemory () ; |
26dafefeebb2
Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
135 return -1 ; |
26dafefeebb2
Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
136 } |
30
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
137 } |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
138 |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
139 SDL_Image = (unsigned char *) screen -> pixels ; |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
140 |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
141 this -> UpdateRects = NX_NormalUpdate ; |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
142 |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
143 Dprintf ("leave NX_SetupImage\n") ; |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
144 return 0 ; |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
145 } |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
146 |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
147 void NX_DestroyImage (_THIS, SDL_Surface * screen) |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
148 { |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
149 Dprintf ("enter NX_DestroyImage\n") ; |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
150 |
1338
604d73db6802
Removed uses of stdlib.h and string.h
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
151 if (SDL_Image) SDL_free (SDL_Image) ; |
604d73db6802
Removed uses of stdlib.h and string.h
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
152 if (Image_buff) SDL_free (Image_buff) ; |
30
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
153 if (screen) screen -> pixels = NULL ; |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
154 |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
155 Dprintf ("leave NX_DestroyImage\n") ; |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
156 } |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
157 |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
158 int NX_ResizeImage (_THIS, SDL_Surface * screen, Uint32 flags) |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
159 { |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
160 int retval ; |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
161 GR_SCREEN_INFO si ; |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
162 |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
163 Dprintf ("enter NX_ResizeImage\n") ; |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
164 |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
165 NX_DestroyImage (this, screen) ; |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
166 retval = NX_SetupImage (this, screen) ; |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
167 |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
168 GrGetScreenInfo (& si) ; |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
169 OffsetX = (si.cols - screen -> w) / 2 ; |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
170 OffsetY = (si.rows - screen -> h) / 2 ; |
471
26dafefeebb2
Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
171 |
26dafefeebb2
Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
172 #ifdef ENABLE_NANOX_DIRECT_FB |
26dafefeebb2
Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
173 if (Clientfb) { |
26dafefeebb2
Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
174 /* Get current window position and fb pointer*/ |
26dafefeebb2
Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
175 if (currently_fullscreen) |
26dafefeebb2
Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
176 GrGetWindowFBInfo(FSwindow, &fbinfo); |
26dafefeebb2
Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
177 else |
26dafefeebb2
Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
178 GrGetWindowFBInfo(SDL_Window, &fbinfo); |
26dafefeebb2
Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
179 } |
26dafefeebb2
Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
180 #endif |
30
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
181 Dprintf ("leave NX_ResizeImage\n") ; |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
182 return retval ; |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
183 } |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
184 |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
185 void NX_RefreshDisplay (_THIS) |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
186 { |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
187 Dprintf ("enter NX_RefreshDisplay\n") ; |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
188 |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
189 // Don't refresh a display that doesn't have an image (like GL) |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
190 if (! SDL_Image) { |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
191 return; |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
192 } |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
193 |
471
26dafefeebb2
Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
194 #ifdef ENABLE_NANOX_DIRECT_FB |
26dafefeebb2
Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
195 if (Clientfb) { |
26dafefeebb2
Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
196 int j; |
26dafefeebb2
Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
197 char *src, *dest = NULL; |
26dafefeebb2
Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
198 int xinc, yinc, rowinc; |
26dafefeebb2
Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
199 |
699
d3b2e93629eb
Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents:
698
diff
changeset
|
200 GrGetWindowFBInfo(SDL_Window, &fbinfo); |
471
26dafefeebb2
Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
201 |
699
d3b2e93629eb
Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents:
698
diff
changeset
|
202 xinc = this -> screen -> format -> BytesPerPixel ; |
d3b2e93629eb
Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents:
698
diff
changeset
|
203 yinc = this -> screen -> pitch ; |
471
26dafefeebb2
Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
204 |
699
d3b2e93629eb
Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents:
698
diff
changeset
|
205 src = SDL_Image; |
d3b2e93629eb
Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents:
698
diff
changeset
|
206 if (currently_fullscreen) |
d3b2e93629eb
Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents:
698
diff
changeset
|
207 dest = fbinfo.winpixels + ((OffsetY * fbinfo.pitch) + |
d3b2e93629eb
Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents:
698
diff
changeset
|
208 (OffsetX * fbinfo.bytespp)); |
d3b2e93629eb
Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents:
698
diff
changeset
|
209 else |
d3b2e93629eb
Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents:
698
diff
changeset
|
210 dest = fbinfo.winpixels; |
d3b2e93629eb
Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents:
698
diff
changeset
|
211 rowinc = xinc * this -> screen -> w; |
471
26dafefeebb2
Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
212 |
699
d3b2e93629eb
Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents:
698
diff
changeset
|
213 for (j = this -> screen -> h; j > 0; -- j, src += yinc, dest += fbinfo.pitch) |
1338
604d73db6802
Removed uses of stdlib.h and string.h
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
214 SDL_memcpy (dest, src, rowinc) ; |
699
d3b2e93629eb
Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents:
698
diff
changeset
|
215 } |
d3b2e93629eb
Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents:
698
diff
changeset
|
216 else |
471
26dafefeebb2
Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
217 #endif |
699
d3b2e93629eb
Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents:
698
diff
changeset
|
218 { |
471
26dafefeebb2
Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
219 if (currently_fullscreen) { |
26dafefeebb2
Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
220 GrArea (FSwindow, SDL_GC, OffsetX, OffsetY, this -> screen -> w, |
26dafefeebb2
Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
221 this -> screen -> h, SDL_Image, pixel_type) ; |
699
d3b2e93629eb
Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents:
698
diff
changeset
|
222 } else { |
471
26dafefeebb2
Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
223 GrArea (SDL_Window, SDL_GC, 0, 0, this -> screen -> w, |
26dafefeebb2
Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
224 this -> screen -> h, SDL_Image, pixel_type) ; |
699
d3b2e93629eb
Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents:
698
diff
changeset
|
225 } |
30
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
226 } |
471
26dafefeebb2
Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
227 GrFlush(); |
30
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
228 |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
229 Dprintf ("leave NX_RefreshDisplay\n") ; |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
230 } |