Mercurial > sdl-ios-xcode
annotate src/video/nanox/SDL_nximage.c @ 1358:c71e05b4dc2e
More header massaging... works great on Windows. ;-)
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Fri, 10 Feb 2006 06:48:43 +0000 |
parents | 604d73db6802 |
children | d910939febfa |
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 */ |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
27 |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
28 #include "SDL_nximage_c.h" |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
29 |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
30 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
|
31 { |
471
26dafefeebb2
Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
32 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
|
33 int x, y, w, h ; |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
34 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
|
35 |
30
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
36 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
|
37 |
26dafefeebb2
Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
38 /* 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
|
39 xinc = this -> screen -> format -> BytesPerPixel ; |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
40 yinc = this -> screen -> pitch ; |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
41 |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
42 for (i = 0; i < numrects; ++ i) { |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
43 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
|
44 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
|
45 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
|
46 #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
|
47 if (Clientfb) { |
d3b2e93629eb
Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents:
698
diff
changeset
|
48 if (currently_fullscreen) |
d3b2e93629eb
Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents:
698
diff
changeset
|
49 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
|
50 ((x+OffsetX) * fbinfo.bytespp)); |
d3b2e93629eb
Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents:
698
diff
changeset
|
51 else |
d3b2e93629eb
Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents:
698
diff
changeset
|
52 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
|
53 destinc = fbinfo.pitch; |
d3b2e93629eb
Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents:
698
diff
changeset
|
54 } |
d3b2e93629eb
Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents:
698
diff
changeset
|
55 else |
471
26dafefeebb2
Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
56 #endif |
699
d3b2e93629eb
Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents:
698
diff
changeset
|
57 { |
471
26dafefeebb2
Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
58 dest = Image_buff ; |
26dafefeebb2
Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
59 destinc = w * xinc ; |
699
d3b2e93629eb
Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents:
698
diff
changeset
|
60 } |
d3b2e93629eb
Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents:
698
diff
changeset
|
61 rowinc = w * xinc; |
30
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
62 |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
63 // apply GammaRamp table |
471
26dafefeebb2
Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
64 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
|
65 && 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
|
66 Uint8 * ptrsrc ; |
d3b2e93629eb
Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents:
698
diff
changeset
|
67 Uint8 * ptrdst ; |
30
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
68 int k ; |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
69 |
699
d3b2e93629eb
Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents:
698
diff
changeset
|
70 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
|
71 ptrsrc = src ; |
d3b2e93629eb
Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents:
698
diff
changeset
|
72 ptrdst = dest ; |
30
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
73 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
|
74 *ptrdst++ = GammaRamp_B [*ptrsrc++] >> 8; |
d3b2e93629eb
Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents:
698
diff
changeset
|
75 *ptrdst++ = GammaRamp_G [*ptrsrc++] >> 8; |
d3b2e93629eb
Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents:
698
diff
changeset
|
76 *ptrdst++ = GammaRamp_R [*ptrsrc++] >> 8; |
d3b2e93629eb
Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents:
698
diff
changeset
|
77 *ptrdst++ = 0; |
d3b2e93629eb
Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents:
698
diff
changeset
|
78 ++ptrsrc; |
30
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
79 } |
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 } |
700
c35edafc84d1
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
699
diff
changeset
|
82 #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
|
83 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
|
84 Uint8 * ptrsrc ; |
d3b2e93629eb
Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents:
698
diff
changeset
|
85 Uint8 * ptrdst ; |
d3b2e93629eb
Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents:
698
diff
changeset
|
86 int k ; |
30
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
87 |
699
d3b2e93629eb
Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents:
698
diff
changeset
|
88 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
|
89 ptrsrc = src ; |
d3b2e93629eb
Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents:
698
diff
changeset
|
90 ptrdst = dest ; |
d3b2e93629eb
Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents:
698
diff
changeset
|
91 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
|
92 *ptrdst++ = *ptrsrc++; |
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++ = 0; |
d3b2e93629eb
Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents:
698
diff
changeset
|
96 ++ptrsrc; |
d3b2e93629eb
Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents:
698
diff
changeset
|
97 } |
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 #endif |
d3b2e93629eb
Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents:
698
diff
changeset
|
101 else |
d3b2e93629eb
Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents:
698
diff
changeset
|
102 { |
d3b2e93629eb
Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents:
698
diff
changeset
|
103 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
|
104 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
|
105 } |
d3b2e93629eb
Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents:
698
diff
changeset
|
106 if (!Clientfb) { |
471
26dafefeebb2
Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
107 if (currently_fullscreen) { |
26dafefeebb2
Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
108 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
|
109 pixel_type) ; |
26dafefeebb2
Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
110 } else { |
26dafefeebb2
Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
111 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
|
112 } |
699
d3b2e93629eb
Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents:
698
diff
changeset
|
113 } |
30
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
114 } |
471
26dafefeebb2
Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
115 GrFlush(); |
30
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
116 |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
117 Dprintf ("leave NX_NormalUpdate\n") ; |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
118 } |
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 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
|
121 { |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
122 int size = screen -> h * screen -> pitch ; |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
123 |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
124 Dprintf ("enter NX_SetupImage\n") ; |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
125 |
1338
604d73db6802
Removed uses of stdlib.h and string.h
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
126 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
|
127 |
26dafefeebb2
Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
128 if (!Clientfb) { |
1338
604d73db6802
Removed uses of stdlib.h and string.h
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
129 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
|
130 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
|
131 SDL_free (screen -> pixels) ; |
604d73db6802
Removed uses of stdlib.h and string.h
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
132 SDL_free (Image_buff) ; |
471
26dafefeebb2
Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
133 SDL_OutOfMemory () ; |
26dafefeebb2
Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
134 return -1 ; |
26dafefeebb2
Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
135 } |
30
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
136 } |
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 SDL_Image = (unsigned char *) screen -> pixels ; |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
139 |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
140 this -> UpdateRects = NX_NormalUpdate ; |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
141 |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
142 Dprintf ("leave NX_SetupImage\n") ; |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
143 return 0 ; |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
144 } |
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 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
|
147 { |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
148 Dprintf ("enter NX_DestroyImage\n") ; |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
149 |
1338
604d73db6802
Removed uses of stdlib.h and string.h
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
150 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
|
151 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
|
152 if (screen) screen -> pixels = NULL ; |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
153 |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
154 Dprintf ("leave NX_DestroyImage\n") ; |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
155 } |
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 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
|
158 { |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
159 int retval ; |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
160 GR_SCREEN_INFO si ; |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
161 |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
162 Dprintf ("enter NX_ResizeImage\n") ; |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
163 |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
164 NX_DestroyImage (this, screen) ; |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
165 retval = NX_SetupImage (this, screen) ; |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
166 |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
167 GrGetScreenInfo (& si) ; |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
168 OffsetX = (si.cols - screen -> w) / 2 ; |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
169 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
|
170 |
26dafefeebb2
Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
171 #ifdef ENABLE_NANOX_DIRECT_FB |
26dafefeebb2
Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
172 if (Clientfb) { |
26dafefeebb2
Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
173 /* 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
|
174 if (currently_fullscreen) |
26dafefeebb2
Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
175 GrGetWindowFBInfo(FSwindow, &fbinfo); |
26dafefeebb2
Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
176 else |
26dafefeebb2
Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
177 GrGetWindowFBInfo(SDL_Window, &fbinfo); |
26dafefeebb2
Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
178 } |
26dafefeebb2
Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
179 #endif |
30
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
180 Dprintf ("leave NX_ResizeImage\n") ; |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
181 return retval ; |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
182 } |
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 void NX_RefreshDisplay (_THIS) |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
185 { |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
186 Dprintf ("enter NX_RefreshDisplay\n") ; |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
187 |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
188 // 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
|
189 if (! SDL_Image) { |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
190 return; |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
191 } |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
192 |
471
26dafefeebb2
Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
193 #ifdef ENABLE_NANOX_DIRECT_FB |
26dafefeebb2
Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
194 if (Clientfb) { |
26dafefeebb2
Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
195 int j; |
26dafefeebb2
Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
196 char *src, *dest = NULL; |
26dafefeebb2
Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
197 int xinc, yinc, rowinc; |
26dafefeebb2
Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
198 |
699
d3b2e93629eb
Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents:
698
diff
changeset
|
199 GrGetWindowFBInfo(SDL_Window, &fbinfo); |
471
26dafefeebb2
Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
200 |
699
d3b2e93629eb
Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents:
698
diff
changeset
|
201 xinc = this -> screen -> format -> BytesPerPixel ; |
d3b2e93629eb
Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents:
698
diff
changeset
|
202 yinc = this -> screen -> pitch ; |
471
26dafefeebb2
Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
203 |
699
d3b2e93629eb
Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents:
698
diff
changeset
|
204 src = SDL_Image; |
d3b2e93629eb
Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents:
698
diff
changeset
|
205 if (currently_fullscreen) |
d3b2e93629eb
Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents:
698
diff
changeset
|
206 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
|
207 (OffsetX * fbinfo.bytespp)); |
d3b2e93629eb
Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents:
698
diff
changeset
|
208 else |
d3b2e93629eb
Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents:
698
diff
changeset
|
209 dest = fbinfo.winpixels; |
d3b2e93629eb
Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents:
698
diff
changeset
|
210 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
|
211 |
699
d3b2e93629eb
Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents:
698
diff
changeset
|
212 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
|
213 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
|
214 } |
d3b2e93629eb
Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents:
698
diff
changeset
|
215 else |
471
26dafefeebb2
Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
216 #endif |
699
d3b2e93629eb
Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents:
698
diff
changeset
|
217 { |
471
26dafefeebb2
Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
218 if (currently_fullscreen) { |
26dafefeebb2
Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
219 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
|
220 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
|
221 } else { |
471
26dafefeebb2
Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
222 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
|
223 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
|
224 } |
30
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
225 } |
471
26dafefeebb2
Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
226 GrFlush(); |
30
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
227 |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
228 Dprintf ("leave NX_RefreshDisplay\n") ; |
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
229 } |