Wii TowerDefense 0.92

PlaatSoft has released TowerDefense v0.92. The following changes were made:

16-01-2010 Version 0.92
GUI:
– Added 6 animated weapons. Thanks Applicant!
– Improve enemy animated sprite frame sequence.
– Improve help and level select screens.
– Lots of other small changes.
Core:
– Weapons now fire on strongest enemy in range.
– Increase bonus money when wave is cleared.
– Increase initial weapon power.
– Decrease weapon prices.
– Added weapon sell functionality with minus button.
– User initials are now default based on Wii nickname.
– Bugfix: Monsters can not be shooted before launch.
– Build game with devkitPPC r19 compiler.

GRRLIB 4.2.X Freetype support

In this post i have add information how to add freetype library support to the GRRLIB 4.2.X library

GRRLIB_free_print.h

void GRRLIB_InitFreetype();

void GRRLIB_initTexture(void);

void GRRLIB_Printf2(	int x, 
							int y, 
							const char *string, 
							unsigned int fontSize, 
							int color); 

GRRLIB_texImg* GRRLIB_GetTexture(void);

GRRLIB_free_print.c

#include <malloc.h>
#include <stdarg.h>
#include <stdio.h>

#include <grrlib.h>

#include <ft2build.h> /* I presume you have freetype for the Wii installed */
#include FT_FREETYPE_H

#include "font_ttf.h"

static FT_Library ftLibrary;
static FT_Face ftFace;

void *fontTempLayer=NULL;
void *fontTexture=NULL;
GRRLIB_texImg image;

extern  Mtx                  GXmodelView2D;

/* Static function prototypes */
static void BitmapTo4x4RGBA(const unsigned char *src, void *dst, const unsigned int width, const unsigned int height);
static bool BlitGlyph(FT_Bitmap *bitmap, int offset, int top, int color) ;

void GRRLIB_InitFreetype(void) 
{
	unsigned int error = FT_Init_FreeType(&ftLibrary);
	if (error) 
	{
		exit(0);
	}

	error = FT_New_Memory_Face(ftLibrary, font_ttf, font_ttf_size, 0, &ftFace);
	if (error == FT_Err_Unknown_File_Format) 
	{
		exit(0);
	} 
	else if (error) 
	{
		/* Some other error */
		exit(0);
	}
}

void GRRLIB_initTexture(void)
{
   // Clear previous video frame buffer
   if (fontTexture!=NULL) free(fontTexture);

   fontTempLayer = (void*) calloc(1, 640 * 528 * 4);

   if (fontTempLayer == NULL) 
   {
	  /* Oops! Something went wrong! */
	  exit(0);
   }
}

void GRRLIB_Printf2(int x, int y, const char *string, unsigned int fontSize, int color) 
{
	unsigned int error = 0;
	int penX = 0;
	int penY = fontSize;
	FT_GlyphSlot slot = ftFace->glyph;
	FT_UInt glyphIndex = 0;
	FT_UInt previousGlyph = 0;
	FT_Bool hasKerning = FT_HAS_KERNING(ftFace);

    error = FT_Set_Pixel_Sizes(ftFace, 0, fontSize);
	if (error) 
	{
		/* Failed to set the font size to the requested size. 
		 * You probably should set a default size or something. 
		 * I'll leave that up to the reader. */
		 FT_Set_Pixel_Sizes(ftFace, 0, 12);
	}
	
	/* Convert the string to UTF32 */
	size_t length = strlen(string);
	wchar_t *utf32 = (wchar_t*)malloc(length * sizeof(wchar_t)); 
	length = mbstowcs(utf32, string, length);
	
	/* Loop over each character, drawing it on to the 4, until the 
	 * end of the string is reached, or until the pixel width is too wide */
	unsigned int loop = 0;
	for (loop = 0; loop < length; ++loop)
    {
		glyphIndex = FT_Get_Char_Index(ftFace, utf32[ loop ]);
		
		/* To the best of my knowledge, none of the other freetype 
		 * implementations use kerning, so my method ends up looking
		 * slightly better :) */
		if (hasKerning && previousGlyph && glyphIndex) 
		{
			FT_Vector delta;
			FT_Get_Kerning(ftFace, previousGlyph, glyphIndex, FT_KERNING_DEFAULT, &delta);
			penX += delta.x >> 6;
		}
	
		error = FT_Load_Glyph(ftFace, glyphIndex, FT_LOAD_RENDER);
		if (error)
        {
			/* Whoops, something went wrong trying to load the glyph 
			 * for this character... you should handle this better */
			continue;
		}
	
		if (BlitGlyph(&slot->bitmap, penX + slot->bitmap_left+x, penY - slot->bitmap_top+y, color) == true) 
		{
			/* The glyph was successfully blitted to the buffer, move the pen forwards */
			penX += slot->advance.x >> 6;
			previousGlyph = glyphIndex;
		} 
		else 
		{
			/* BlitGlyph returned false, the line must be full */
			free(utf32);
			return;
		}
	}

	free(utf32);
}

/* Returns true if the character was draw on to the buffer, false if otherwise */
bool BlitGlyph(FT_Bitmap *bitmap, int offset, int top, int color) 
{
	int bitmapWidth = bitmap->width;
	int bitmapHeight = bitmap->rows;

	if (offset + bitmapWidth > 640) 
	{
		/* Drawing this character would over run the buffer, so don't draw it */
		return false;
	}

	/* Draw the glyph onto the buffer, blitting from the bottom up */
	/* CREDIT: Derived from a function by DragonMinded */
	unsigned char *p = fontTempLayer;
	unsigned int y = 0;
	for (y = 0; y < bitmapHeight; ++y) 
	{
		int sywidth = y * bitmapWidth;
		int dywidth = (y + top) * 640;

		unsigned int column = 0;
		for (column = 0; column < bitmapWidth; ++column)
        {
			unsigned int srcloc = column + sywidth;
			unsigned int dstloc = ((column + offset) + dywidth) << 2;
			
			/* Copy the alpha value for this pixel into the texture buffer */
			p[ dstloc + 0 ] = (color & 0xff);
			p[ dstloc + 1 ] = ((color >> 8) & 0xff);
			p[ dstloc + 2 ] = ((color >> 16) & 0xff);
			p[ dstloc + 3 ] = (bitmap->buffer[ srcloc ]);
		}
	}
	
	return true;
}

/* Render the text string to a 4x4RGBA texture, return a pointer to this texture */
GRRLIB_texImg* GRRLIB_GetTexture(void) 
{
	/* Create a new buffer, this time to hold the final texture 
	 * in a format suitable for the Wii */
	fontTexture = memalign(32, 640 * 528 * 4);

	/* Convert the RGBA temp buffer to a format usuable by GX */
	BitmapTo4x4RGBA(fontTempLayer, fontTexture, 640, 528);
	DCFlushRange(fontTexture, 640 * 528 * 4);

	/* The temp buffer is no longer required */
	free(fontTempLayer);
	image.data=fontTexture;
	image.w=640;
	image.h=528;
	
	return &image;
}

void BitmapTo4x4RGBA(const unsigned char *src, void *dst, const unsigned int width, const unsigned int height)
{
	unsigned int block = 0;
	unsigned int i = 0;
	unsigned int c = 0;
	unsigned int ar = 0;
	unsigned int gb = 0;
	unsigned char *p = (unsigned char*)dst;

	for (block = 0; block < height; block += 4) {
		for (i = 0; i < width; i += 4) {
			/* Alpha and Red */
			for (c = 0; c < 4; ++c) {
				for (ar = 0; ar < 4; ++ar) {
					/* Alpha pixels */
					*p++ = src[(((i + ar) + ((block + c) * width)) * 4) + 3];
					/* Red pixels */	
					*p++ = src[((i + ar) + ((block + c) * width)) * 4];
				}
			}
			
			/* Green and Blue */
			for (c = 0; c < 4; ++c) {
				for (gb = 0; gb < 4; ++gb) {
					/* Green pixels */
					*p++ = src[(((i + gb) + ((block + c) * width)) * 4) + 1];
					/* Blue pixels */
					*p++ = src[(((i + gb) + ((block + c) * width)) * 4) + 2];
				}
			}
		} /* i */
	} /* block */
}

Wii trace module

To debug better a Wii application / game i have created a trace C++ module with is logging trace event to file. Please checkout the following code. I hope it benefit someone!

trace.h

#ifndef TRACE_H
#define TRACE_H

class Trace
{
  private:
	FILE * fp;
	char * getDate();

  public:
  	// Constructor & Destructor
	Trace();
 	~Trace();
	
	// Methodes
	int open(const char *filename);
	int event( const char *functionName, int threadNr, const char *event, ...);
	int eventRaw( char character);
	int close();
};

#endif

trace.cpp

#include <stdio.h>
#include <gccore.h>
#include <ogcsys.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <ogcsys.h>
#include <stdarg.h>
#include <time.h>

#include "trace.h"

// Enable / Disable trace file functionality
bool traceOn = false;

// ------------------------------
// Constructor
// ------------------------------

Trace::Trace()
{
	fp=NULL;
}

// ------------------------------
// Destructor
// ------------------------------

Trace::~Trace()
{
  close();
}

// ------------------------------
// Methods
// ------------------------------

// Open trace file
int Trace::open(const char *filename)
{
   int returnValue=0;
   
   if (!traceOn) return -1;
         
   if((fp=fopen(filename, "wb"))==NULL) 
   {
      printf("Error: Cannot open trace file.\n");
      returnValue=-2;
   }   
   return returnValue;
}


// Close trace file
int Trace::close()
{
   int returnValue=0;
   
   if (fp!=NULL)
   {
       fclose(fp);
   }	
   return returnValue;
}


// Create trace timestamp
char * Trace::getDate()
{
  struct tm *now = NULL;
  time_t time_value = 0;
  static char buf[ 128 ] ;
  
  // Clear memory  
  memset(buf, sizeof(buf), 0x00);
  
  /* Get time value */
  time_value = time(NULL);          
  
  /* Get time and date structure */
  now = localtime(&time_value);     

  // Create time stamp
  sprintf(buf,"%02d-%02d-%04d %02d:%02d:%02d",
	now->tm_mday, now->tm_mon+1, now->tm_year+1900, 
	now->tm_hour,now->tm_min,now->tm_sec);
	
  return buf;
}

// Save trace event in trace file
int Trace::event( const char *functionName, int threadNr, const char *event, ...)
{
   int returnValue=0;
   char buf[ MAX_LEN ];
   
   // Clear memory  
   memset(buf, MAX_LEN, 0x00);
   
   if (!traceOn) return -1;
   
   // Expend event string
   va_list list;
   va_start(list, event );
   vsprintf(buf, event, list);
   
   if (fp!=NULL)
   {
      // Save string to file
	  fprintf(fp,"%s [thread%d-%s] %s\n",getDate(), threadNr, functionName, buf); 
	  fflush(fp); 
   }
   
   return returnValue;
}


// Save trace event in trace file
int Trace::eventRaw( char character)
{
   int returnValue=0;
   
   if (!traceOn) return -1;
     
   if (fp!=NULL)
   {
      // Save string to file
	  fprintf(fp,"%c",character); 
	  fflush(fp); 
   }
   
   return returnValue;
}

Wii RedSquare 0.94

This evening RedSquare 0.94 for Nitendo Wii is released by PlaatSoft. The following changes were made:

11-01-2010 Version 0.94
– Added improve score calculation.
– Added extra help screen.
– Improve webservice call to store high score.
– Added support for 60HZ (640×480) TV mode.
– Use libogc 1.8.1 library as Wii interface engine.
– Use GRRLIB v4.2.0 as graphical engine.
– Build game with devkitPPC r19 compiler.

If anybody has a good idea how to improve this game, please post a comment

Wii TowerDefense 0.91

PlaatSoft has released TowerDefense v0.91. The following changes were made:

09-01-2010 Version 0.91
GUI:
– Added 25 animated enemy sprites. Thanks Applicant!
– Added game setting screen.
– Added intro screen 3
– Improve winter theme sprites.
– Improve first help screen.
– Improve main menu screen.
– Lots of other small GUI changes.
Core:
– Make game harder to play!
– Less start money.
– Enemy minimum / maximum speed depend on wave nr.
– Increase weapon prices.
– Increase maximum concurrent monsters in action.
– Decrease weapons effective range.
– Build game with devkitPPC r19 compiler.

Wii SpaceBubble 0.93

This evening SpaceBubble 0.93 is released by PlaatSoft. The following changes were made:

08-01-2010 Version 0.93
– Improve main menu screen.
– Added 60Hz (640×480) TV Mode support.
– Increase local highscore list to maximum 100 entries.
– Store current game score in highscore area also when game is quited.
– Added extra help screen with WiiMote control information.
– Use GRRLIB v4.2.0 library as graphical engine.
– Use libogc v1.8.1 library as Wii interface engine.
– Build game with devkitPPC r19 compiler.

If anybody has a good idea how to improve this game, please post a comment

Progress report TowerDefense

Hi everybody, Here a small update about the continues development of TowerDefense. On this moment Appliciant is designing new animated enemy and weapon sprites for the game. If all the enemies and weapons are ready i will bring out the next major release. To give your some idea were it is going too, check out the following art drawing. In the mean time if there are any bugs or new ideas please post them below!

Wii TowerDefense 0.90

PlaatSoft has released TowerDefense v0.90. The following changes were made:

02-01-2010 Version 0.90
GUI:
– Improve background images.
– Remove some english typos.
– Improve first intro screen.
– Added WiiMote control help screen.
Core:
– Improve first music track.
– Enable B button for faster building.
– Enable left and right button for faster weapon type selection.
– Build game with devkitPPC r19 compiler.

PlaatSoft 100.000 downloads!

Hi everybody, This year starts great. On the first day of 2010 PlaatSoft reach officially 100.000 game downloads. This is great news! Thanks for all the PlaatSoft Wii Homebrew supporters around the world 😆 Looking forward to provide you with more high quality Wii Homebrew games in 2010!

Official Count

Game PlaatSoft CodeMii Google Code Totals
Wii Pong2 3.077 33.718 0 36.795
Wii BibleQuiz 1.945 13.384 0 15.329
Wii RedSquare 2.620 15.735 0 18.355
Wii SpaceBubble 2.484 19.796 0 22.280
Wii TowerDefense 857 6.386 0 7.243
Totals 10.983 89.019 0 100.002

Wii TowerDefense 0.80

PlaatSoft has released this evening TowerDefense 0.80. The following changes were made:

30-12-2009 Version 0.80
GUI:
– Added map id column to local highscore screen.
– Improve background images.
– Remove typo (nuck->nuke).
– Added 60Hz (640×480 pixel) TV Mode support
– Improve sound setting screen.
– Optimised enemy images.
Core:
– Adapt game parameters to make game play better.
– Increase start money depending on game level.
– Enemy walk speed is now a randomized value.
– Map id information is added to webservice call.
– Only scores above 20.000 points are send to webservice.
– Store the best 100 entries in the local highscore.
– Build game with devkitPPC r19 compiler.

Wii BibleQuiz 15.000 downloads

Since the launch (15 November 2008) of BibleQuiz, it is downloaded over 15.000 times. Wow ❗ . So a very special thanks to everyone who’s been downloading, playing and commenting this game.

I personally think that this game needs a lot of more quiz questions. Who can help me with this work. I also search for someone who can translate the existing English questions to Germans, French and Spanish. Who can help me with this! Reactions can be send to info@plaatsoft.nl Many thanks in advance.

Official download count

Homebrew Browser 13.170 times
My website 1.904 times
Total 15.074 times

Wii TowerDefense 0.70

Today plaatsoft has released TowerDefense v0.70. The following changes were made:

27-12-2009 Version 0.70
GUI:
– Added “Easy, Medium, Hard” level select screen.
– Added six medium level and six hard level maps.
– Added version information is webservice call.
– BugFix: Highscore screens now show correct amount of entries!
Core:
– Adapted weapon specifications (Weapons are more powerfull).
– Adapted enemy specifications (enemies are less powerfull).
– Adapted six easy maps to be more easy.
– Increase enemy walk speed after each 20 waves.
– Build game with devkitPPC r19 compiler.

Wii TowerDefense available in Homebrew Browser

This evening, after a christmas family party, i started the Homebrew Browser on my Wii an saw that TowerDefense v0.60 is available for download. In a few hours already 574 dowloads were registered. That is great news! 🙂 I hope everybody will enjoy the game as i did creating it. Good night everybody!

Wii TowerDefense 0.60

This is the second official release for the wii homebrew scene. I hope everybody like the game! Comments are still welcome.

24/12/2009 Version 0.60
GUI:
– Update credit screen.
– Improve game information panel design.
– Show price and strengh information about new weapons.
– Show detail information about selected weapon.
– Show mini enemies moving on map select screen.
– Bugfix: Map six background images are now showed correct.
– Snap weapons to 32×32 grid!
Core:
– Increase enemy walk speed after each 25 waves.
– Only allow to build weapons on land (not bridges or road)
– Not allowed anymore to stack weapons on same place.
– BugfiX: The rumble is now working for all the four WiiMotes.
– Build game with devkitPPC r19 compiler.

Wii TowerDefense 0.50

This is the first official release for the wii homebrew scene:!: I hope everybody like the game! Comments are welcome.

20/12/2009 Version 0.50
– First official release for the Wii Homebrew Scene.
– Process most of the comments of the Beta testers.
GUI:
– Improve “Game Over” screen.
– Improve game information panel on screen.
– Improve scroll bar button design.
– Improve Help text.
Core:
– Reduced amount of enemies in one wave.
– Increase user initials for 3 to 6 digits.
– Balance sound effect volume.
– Improve weapons upgrade ranges.
– Use GRRLib v4.2.0 as graphic engine.
– Build game with devkitPPC r19 compiler.

Website Upgrade

This morning I have upgraded my website.

The following changes were implemented:
– Upgrade to WordPress 2.9.0
– Upgrade all used plugins to latest available version.
– Remove all Ads because revenue was really poor so far!
– Remove total website page counter.
– Upgrade Atahualpa thema from v3.1.8 to v3.4.4 because old version did not working anymore correct with WordPress 2.9.0. Posted comments were not visible anymore!

Because of the Atahualpa theme upgrade the following functionality was initially not working anymore:
– Show page view counter (Fixed)
– Comment spam protection (Fixed)
– Show category icons (Fixed)
– Post rating (Disabled plug-in, not needed anymore)