Skip to content

Commit 4ec21fb

Browse files
committed
[CHG] GRRLIB update to 4.1.0 (svn 171)
git-svn-id: https://wii-tac-toe.googlecode.com/svn/trunk@57 bba1cac1-252d-79fd-420d-80adb1f9fa09
1 parent ae6c542 commit 4ec21fb

26 files changed

+2684
-2531
lines changed

Wii-Tac-Toe/meta.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<name>Wii-Tac-Toe</name>
44
<coder>Crayon</coder>
55
<version>0.7</version>
6-
<release_date>200909130000</release_date>
6+
<release_date>200909260000</release_date>
77
<short_description>Tic-Tac-Toe game</short_description>
88
<long_description>Wii-Tac-Toe is a Tic-Tac-Toe game for the Nintendo Wii. It was programmed in C++ using devkitPro along with GRRLIB.
99

source/grrlib/GRRLIB.h

Lines changed: 262 additions & 264 deletions
Large diffs are not rendered by default.

source/grrlib/GRRLIB_addon.c

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,6 @@
22

33
#include <fat.h>
44

5-
/**
6-
* Make a PNG screenshot on the SD card.
7-
* libfat is required to use the function.
8-
* @param File name of the file to write.
9-
* @return true if every thing worked, false otherwise.
10-
*/
11-
bool GRRLIB_ScrShot(const char* File) {
12-
int ErrorCode = -1;
13-
IMGCTX pngContext;
14-
15-
if(fatInitDefault() && (pngContext = PNGU_SelectImageFromDevice(File))) {
16-
ErrorCode = PNGU_EncodeFromYCbYCr(pngContext, rmode->fbWidth, rmode->efbHeight, xfb[fb], 0);
17-
PNGU_ReleaseImageContext(pngContext);
18-
}
19-
return !ErrorCode;
20-
}
21-
225
/**
236
* Fade in, than fade out.
247
* @param data Texture.

source/grrlib/GRRLIB_bmf.c

Lines changed: 115 additions & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -1,114 +1,115 @@
1-
/*------------------------------------------------------------------------------
2-
Copyright (c) 2009 The GRRLIB Team
3-
4-
Permission is hereby granted, free of charge, to any person obtaining a copy
5-
of this software and associated documentation files (the "Software"), to deal
6-
in the Software without restriction, including without limitation the rights
7-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8-
copies of the Software, and to permit persons to whom the Software is
9-
furnished to do so, subject to the following conditions:
10-
11-
The above copyright notice and this permission notice shall be included in
12-
all copies or substantial portions of the Software.
13-
14-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20-
THE SOFTWARE.
21-
------------------------------------------------------------------------------*/
22-
23-
#include <malloc.h>
24-
#include <string.h>
25-
26-
#include "grrlib.h"
27-
28-
/**
29-
* Load a ByteMap font structure from a buffer.
30-
* @param my_bmf The ByteMap font buffer to load.
31-
* @return A GRRLIB_bytemapFont structure filled with BMF informations.
32-
*/
33-
GRRLIB_bytemapFont* GRRLIB_LoadBMF (const u8 my_bmf[] ) {
34-
GRRLIB_bytemapFont *fontArray = (struct GRRLIB_bytemapFont *)malloc(sizeof(GRRLIB_bytemapFont));
35-
int i, j = 1;
36-
u8 lineheight, usedcolors, highestcolor, nbPalette;
37-
short int sizeover, sizeunder, sizeinner, numcolpal;
38-
u16 nbPixels;
39-
40-
if (fontArray != NULL && my_bmf[0]==0xE1 && my_bmf[1]==0xE6 && my_bmf[2]==0xD5 && my_bmf[3]==0x1A) {
41-
fontArray->version = my_bmf[4];
42-
lineheight = my_bmf[5];
43-
sizeover = my_bmf[6];
44-
sizeunder = my_bmf[7];
45-
fontArray->tracking = my_bmf[8];
46-
sizeinner = my_bmf[9];
47-
usedcolors = my_bmf[10];
48-
highestcolor = my_bmf[11];
49-
nbPalette = my_bmf[16];
50-
numcolpal = 3 * nbPalette;
51-
fontArray->palette = (u32 *)calloc(nbPalette + 1, sizeof(u32));
52-
for (i=0; i < numcolpal; i+=3) {
53-
fontArray->palette[j++] = ((((my_bmf[i+17]<<2)+3)<<24) | (((my_bmf[i+18]<<2)+3)<<16) | (((my_bmf[i+19]<<2)+3)<<8) | 0xFF);
54-
}
55-
j = my_bmf[17 + numcolpal];
56-
fontArray->name = (char *)calloc(j + 1, sizeof(char));
57-
memcpy(fontArray->name, &my_bmf[18 + numcolpal], j);
58-
j = 18 + numcolpal + j;
59-
fontArray->nbChar = (my_bmf[j] | my_bmf[j+1]<<8);
60-
fontArray->charDef = (GRRLIB_bytemapChar *)calloc(fontArray->nbChar, sizeof(GRRLIB_bytemapChar));
61-
j++;
62-
for (i=0; i < fontArray->nbChar; i++) {
63-
fontArray->charDef[i].character = my_bmf[++j];
64-
fontArray->charDef[i].width = my_bmf[++j];
65-
fontArray->charDef[i].height = my_bmf[++j];
66-
fontArray->charDef[i].relx = my_bmf[++j];
67-
fontArray->charDef[i].rely = my_bmf[++j];
68-
fontArray->charDef[i].kerning = my_bmf[++j];
69-
nbPixels = fontArray->charDef[i].width * fontArray->charDef[i].height;
70-
fontArray->charDef[i].data = (u8 *)malloc(nbPixels);
71-
if (nbPixels && fontArray->charDef[i].data) {
72-
memcpy(fontArray->charDef[i].data, &my_bmf[++j], nbPixels);
73-
j += (nbPixels - 1);
74-
}
75-
}
76-
}
77-
return fontArray;
78-
}
79-
80-
/**
81-
* Free memory allocated by ByteMap fonts.
82-
* @param bmf A GRRLIB_bytemapFont structure.
83-
*/
84-
void GRRLIB_FreeBMF (const GRRLIB_bytemapFont *bmf) {
85-
unsigned int i;
86-
87-
for (i=0; i<bmf->nbChar; i++) {
88-
free(bmf->charDef[i].data);
89-
}
90-
free(bmf->charDef);
91-
free(bmf->palette);
92-
free(bmf->name);
93-
}
94-
95-
/**
96-
* Initialize a tile set.
97-
* @param tex The texture to initialize.
98-
* @param tilew Width of the tile.
99-
* @param tileh Height of the tile.
100-
* @param tilestart Offset for starting position (Used in fonts).
101-
*/
102-
void GRRLIB_InitTileSet (GRRLIB_texImg *tex,
103-
const uint tilew, const uint tileh,
104-
const uint tilestart) {
105-
tex->tilew = tilew;
106-
tex->tileh = tileh;
107-
if (tilew) // Avoid division by zero
108-
tex->nbtilew = tex->w / tilew;
109-
if (tileh) // Avoid division by zero
110-
tex->nbtileh = tex->h / tileh;
111-
tex->tilestart = tilestart;
112-
tex->tiledtex = true;
113-
GRRLIB_SetHandle( tex, 0, 0 );
114-
}
1+
/*------------------------------------------------------------------------------
2+
Copyright (c) 2009 The GRRLIB Team
3+
4+
Permission is hereby granted, free of charge, to any person obtaining a copy
5+
of this software and associated documentation files (the "Software"), to deal
6+
in the Software without restriction, including without limitation the rights
7+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
copies of the Software, and to permit persons to whom the Software is
9+
furnished to do so, subject to the following conditions:
10+
11+
The above copyright notice and this permission notice shall be included in
12+
all copies or substantial portions of the Software.
13+
14+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20+
THE SOFTWARE.
21+
------------------------------------------------------------------------------*/
22+
23+
#include <malloc.h>
24+
#include <string.h>
25+
26+
#include "grrlib.h"
27+
28+
/**
29+
* Load a ByteMap font structure from a buffer.
30+
* @param my_bmf The ByteMap font buffer to load.
31+
* @return A GRRLIB_bytemapFont structure filled with BMF informations.
32+
* @see GRRLIB_FreeBMF
33+
*/
34+
GRRLIB_bytemapFont* GRRLIB_LoadBMF (const u8 my_bmf[] ) {
35+
GRRLIB_bytemapFont *fontArray = (struct GRRLIB_bytemapFont *)malloc(sizeof(GRRLIB_bytemapFont));
36+
int i, j = 1;
37+
u8 lineheight, usedcolors, highestcolor, nbPalette;
38+
short int sizeover, sizeunder, sizeinner, numcolpal;
39+
u16 nbPixels;
40+
41+
if (fontArray != NULL && my_bmf[0]==0xE1 && my_bmf[1]==0xE6 && my_bmf[2]==0xD5 && my_bmf[3]==0x1A) {
42+
fontArray->version = my_bmf[4];
43+
lineheight = my_bmf[5];
44+
sizeover = my_bmf[6];
45+
sizeunder = my_bmf[7];
46+
fontArray->tracking = my_bmf[8];
47+
sizeinner = my_bmf[9];
48+
usedcolors = my_bmf[10];
49+
highestcolor = my_bmf[11];
50+
nbPalette = my_bmf[16];
51+
numcolpal = 3 * nbPalette;
52+
fontArray->palette = (u32 *)calloc(nbPalette + 1, sizeof(u32));
53+
for (i=0; i < numcolpal; i+=3) {
54+
fontArray->palette[j++] = ((((my_bmf[i+17]<<2)+3)<<24) | (((my_bmf[i+18]<<2)+3)<<16) | (((my_bmf[i+19]<<2)+3)<<8) | 0xFF);
55+
}
56+
j = my_bmf[17 + numcolpal];
57+
fontArray->name = (char *)calloc(j + 1, sizeof(char));
58+
memcpy(fontArray->name, &my_bmf[18 + numcolpal], j);
59+
j = 18 + numcolpal + j;
60+
fontArray->nbChar = (my_bmf[j] | my_bmf[j+1]<<8);
61+
fontArray->charDef = (GRRLIB_bytemapChar *)calloc(fontArray->nbChar, sizeof(GRRLIB_bytemapChar));
62+
j++;
63+
for (i=0; i < fontArray->nbChar; i++) {
64+
fontArray->charDef[i].character = my_bmf[++j];
65+
fontArray->charDef[i].width = my_bmf[++j];
66+
fontArray->charDef[i].height = my_bmf[++j];
67+
fontArray->charDef[i].relx = my_bmf[++j];
68+
fontArray->charDef[i].rely = my_bmf[++j];
69+
fontArray->charDef[i].kerning = my_bmf[++j];
70+
nbPixels = fontArray->charDef[i].width * fontArray->charDef[i].height;
71+
fontArray->charDef[i].data = (u8 *)malloc(nbPixels);
72+
if (nbPixels && fontArray->charDef[i].data) {
73+
memcpy(fontArray->charDef[i].data, &my_bmf[++j], nbPixels);
74+
j += (nbPixels - 1);
75+
}
76+
}
77+
}
78+
return fontArray;
79+
}
80+
81+
/**
82+
* Free memory allocated by ByteMap fonts.
83+
* @param bmf A GRRLIB_bytemapFont structure.
84+
*/
85+
void GRRLIB_FreeBMF (const GRRLIB_bytemapFont *bmf) {
86+
unsigned int i;
87+
88+
for (i=0; i<bmf->nbChar; i++) {
89+
free(bmf->charDef[i].data);
90+
}
91+
free(bmf->charDef);
92+
free(bmf->palette);
93+
free(bmf->name);
94+
}
95+
96+
/**
97+
* Initialize a tile set.
98+
* @param tex The texture to initialize.
99+
* @param tilew Width of the tile.
100+
* @param tileh Height of the tile.
101+
* @param tilestart Offset for starting position (Used in fonts).
102+
*/
103+
void GRRLIB_InitTileSet (GRRLIB_texImg *tex,
104+
const uint tilew, const uint tileh,
105+
const uint tilestart) {
106+
tex->tilew = tilew;
107+
tex->tileh = tileh;
108+
if (tilew) // Avoid division by zero
109+
tex->nbtilew = tex->w / tilew;
110+
if (tileh) // Avoid division by zero
111+
tex->nbtileh = tex->h / tileh;
112+
tex->tilestart = tilestart;
113+
tex->tiledtex = true;
114+
GRRLIB_SetHandle( tex, 0, 0 );
115+
}

0 commit comments

Comments
 (0)