Included ScrShot from GRRLIB_addon as embedded code - cleaned headers and makefile to build with v4.1.0

This commit is contained in:
csBlueChip 2009-08-23 14:40:20 +00:00
parent 309547cb4d
commit ace9d24f0c
2 changed files with 160 additions and 143 deletions

View file

@ -15,10 +15,9 @@ include $(DEVKITPPC)/wii_rules
# SOURCES is a list of directories containing source code
# INCLUDES is a list of directories containing extra header files
#---------------------------------------------------------------------------------
GRRLIB := ../../GRRLIB
TARGET := $(notdir $(CURDIR))
BUILD := build
SOURCES := source source/gfx $(GRRLIB)/GRRLIB $(GRRLIB)/lib/libpng/pngu
SOURCES := source source/gfx GRRLIB_addon
DATA := data
INCLUDES :=
@ -34,7 +33,7 @@ LDFLAGS = -g $(MACHDEP) -mrvl -Wl,-Map,$(notdir $@).map
#---------------------------------------------------------------------------------
# any extra libraries we wish to link with the project
#---------------------------------------------------------------------------------
LIBS := -lpng -ljpeg -lz -lfat -lwiiuse -lbte -logc -lm
LIBS := -lgrrlib -lpngu -lpng -ljpeg -lz -lfat -lwiiuse -lbte -logc -lm
#---------------------------------------------------------------------------------
# list of directories containing libraries, this must be the top level containing

View file

@ -4,12 +4,13 @@
How To use Bitmap Fonts
============================================*/
#include "../../../GRRLIB/GRRLIB/GRRLIB.h"
#include "../../../GRRLIB/GRRLIB/GRRLIB_addon.h"
#include <grrlib.h>
#include <ogc/lwp_watchdog.h> // Needed for gettime and ticks_to_millisecs
#include <stdlib.h>
#include <wiiuse/wpad.h>
#include <wiiuse/wpad.h>
#include <fat.h>
#include "gfx/BMfont1.h"
#include "gfx/BMfont2.h"
@ -52,6 +53,23 @@
static u8 CalculateFrameRate();
/**
* Make a PNG screenshot on the SD card.
* libfat is required to use the function.
* @param File name of the file to write.
* @return true if every thing worked, false otherwise.
*/
bool ScrShot(const char* File) {
int ErrorCode = -1;
IMGCTX pngContext;
if(fatInitDefault() && (pngContext = PNGU_SelectImageFromDevice(File))) {
ErrorCode = PNGU_EncodeFromYCbYCr(pngContext, rmode->fbWidth, rmode->efbHeight, xfb[fb], 0);
PNGU_ReleaseImageContext(pngContext);
}
return !ErrorCode;
}
int main() {
int left = 0, top = 0, page = 0, frame = TILE_DOWN + 1;
unsigned int wait = TILE_DELAY, direction = TILE_DOWN, direction_new = TILE_DOWN;
@ -212,7 +230,7 @@ int main() {
}
if(wpadheld & WPAD_BUTTON_1 && wpadheld & WPAD_BUTTON_2) {
WPAD_Rumble(WPAD_CHAN_0, 1); // Rumble on
GRRLIB_ScrShot("sd:/grrlib.png");
ScrShot("sd:/grrlib.png");
WPAD_Rumble(WPAD_CHAN_0, 0); // Rumble off
}
}