mirror of
https://github.com/GRRLIB/GRRLIB.git
synced 2024-11-26 08:42:19 +00:00
Included ScrShot from GRRLIB_addon as embedded code - cleaned headers and makefile to build with v4.1.0
This commit is contained in:
parent
309547cb4d
commit
ace9d24f0c
2 changed files with 160 additions and 143 deletions
|
@ -1,140 +1,139 @@
|
||||||
#---------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------
|
||||||
# Clear the implicit built in rules
|
# Clear the implicit built in rules
|
||||||
#---------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------
|
||||||
.SUFFIXES:
|
.SUFFIXES:
|
||||||
#---------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------
|
||||||
ifeq ($(strip $(DEVKITPPC)),)
|
ifeq ($(strip $(DEVKITPPC)),)
|
||||||
$(error "Please set DEVKITPPC in your environment. export DEVKITPPC=<path to>devkitPPC)
|
$(error "Please set DEVKITPPC in your environment. export DEVKITPPC=<path to>devkitPPC)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
include $(DEVKITPPC)/wii_rules
|
include $(DEVKITPPC)/wii_rules
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------
|
||||||
# TARGET is the name of the output
|
# TARGET is the name of the output
|
||||||
# BUILD is the directory where object files & intermediate files will be placed
|
# BUILD is the directory where object files & intermediate files will be placed
|
||||||
# SOURCES is a list of directories containing source code
|
# SOURCES is a list of directories containing source code
|
||||||
# INCLUDES is a list of directories containing extra header files
|
# INCLUDES is a list of directories containing extra header files
|
||||||
#---------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------
|
||||||
GRRLIB := ../../GRRLIB
|
TARGET := $(notdir $(CURDIR))
|
||||||
TARGET := $(notdir $(CURDIR))
|
BUILD := build
|
||||||
BUILD := build
|
SOURCES := source source/gfx GRRLIB_addon
|
||||||
SOURCES := source source/gfx $(GRRLIB)/GRRLIB $(GRRLIB)/lib/libpng/pngu
|
DATA := data
|
||||||
DATA := data
|
INCLUDES :=
|
||||||
INCLUDES :=
|
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
#---------------------------------------------------------------------------------
|
# options for code generation
|
||||||
# options for code generation
|
#---------------------------------------------------------------------------------
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
|
CFLAGS = -g -O2 -mrvl -Wall $(MACHDEP) $(INCLUDE)
|
||||||
CFLAGS = -g -O2 -mrvl -Wall $(MACHDEP) $(INCLUDE)
|
CXXFLAGS = $(CFLAGS)
|
||||||
CXXFLAGS = $(CFLAGS)
|
|
||||||
|
LDFLAGS = -g $(MACHDEP) -mrvl -Wl,-Map,$(notdir $@).map
|
||||||
LDFLAGS = -g $(MACHDEP) -mrvl -Wl,-Map,$(notdir $@).map
|
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
#---------------------------------------------------------------------------------
|
# any extra libraries we wish to link with the project
|
||||||
# any extra libraries we wish to link with the project
|
#---------------------------------------------------------------------------------
|
||||||
#---------------------------------------------------------------------------------
|
LIBS := -lgrrlib -lpngu -lpng -ljpeg -lz -lfat -lwiiuse -lbte -logc -lm
|
||||||
LIBS := -lpng -ljpeg -lz -lfat -lwiiuse -lbte -logc -lm
|
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
#---------------------------------------------------------------------------------
|
# list of directories containing libraries, this must be the top level containing
|
||||||
# list of directories containing libraries, this must be the top level containing
|
# include and lib
|
||||||
# include and lib
|
#---------------------------------------------------------------------------------
|
||||||
#---------------------------------------------------------------------------------
|
LIBDIRS := $(CURDIR)/$(GRRLIB)
|
||||||
LIBDIRS := $(CURDIR)/$(GRRLIB)
|
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
#---------------------------------------------------------------------------------
|
# no real need to edit anything past this point unless you need to add additional
|
||||||
# no real need to edit anything past this point unless you need to add additional
|
# rules for different file extensions
|
||||||
# rules for different file extensions
|
#---------------------------------------------------------------------------------
|
||||||
#---------------------------------------------------------------------------------
|
ifneq ($(BUILD),$(notdir $(CURDIR)))
|
||||||
ifneq ($(BUILD),$(notdir $(CURDIR)))
|
#---------------------------------------------------------------------------------
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
|
export OUTPUT := $(CURDIR)/$(TARGET)
|
||||||
export OUTPUT := $(CURDIR)/$(TARGET)
|
|
||||||
|
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
|
||||||
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
|
$(foreach dir,$(DATA),$(CURDIR)/$(dir))
|
||||||
$(foreach dir,$(DATA),$(CURDIR)/$(dir))
|
|
||||||
|
export DEPSDIR := $(CURDIR)/$(BUILD)
|
||||||
export DEPSDIR := $(CURDIR)/$(BUILD)
|
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
#---------------------------------------------------------------------------------
|
# automatically build a list of object files for our project
|
||||||
# automatically build a list of object files for our project
|
#---------------------------------------------------------------------------------
|
||||||
#---------------------------------------------------------------------------------
|
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
|
||||||
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
|
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
|
||||||
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
|
sFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
|
||||||
sFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
|
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.S)))
|
||||||
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.S)))
|
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
|
||||||
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
|
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
#---------------------------------------------------------------------------------
|
# use CXX for linking C++ projects, CC for standard C
|
||||||
# use CXX for linking C++ projects, CC for standard C
|
#---------------------------------------------------------------------------------
|
||||||
#---------------------------------------------------------------------------------
|
ifeq ($(strip $(CPPFILES)),)
|
||||||
ifeq ($(strip $(CPPFILES)),)
|
export LD := $(CC)
|
||||||
export LD := $(CC)
|
else
|
||||||
else
|
export LD := $(CXX)
|
||||||
export LD := $(CXX)
|
endif
|
||||||
endif
|
|
||||||
|
export OFILES := $(addsuffix .o,$(BINFILES)) \
|
||||||
export OFILES := $(addsuffix .o,$(BINFILES)) \
|
$(CPPFILES:.cpp=.o) $(CFILES:.c=.o) \
|
||||||
$(CPPFILES:.cpp=.o) $(CFILES:.c=.o) \
|
$(sFILES:.s=.o) $(SFILES:.S=.o)
|
||||||
$(sFILES:.s=.o) $(SFILES:.S=.o)
|
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
#---------------------------------------------------------------------------------
|
# build a list of include paths
|
||||||
# build a list of include paths
|
#---------------------------------------------------------------------------------
|
||||||
#---------------------------------------------------------------------------------
|
export INCLUDE := $(foreach dir,$(INCLUDES), -iquote $(CURDIR)/$(dir)) \
|
||||||
export INCLUDE := $(foreach dir,$(INCLUDES), -iquote $(CURDIR)/$(dir)) \
|
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
|
||||||
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
|
-I$(CURDIR)/$(BUILD) \
|
||||||
-I$(CURDIR)/$(BUILD) \
|
-I$(LIBOGC_INC)
|
||||||
-I$(LIBOGC_INC)
|
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
#---------------------------------------------------------------------------------
|
# build a list of library paths
|
||||||
# build a list of library paths
|
#---------------------------------------------------------------------------------
|
||||||
#---------------------------------------------------------------------------------
|
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) \
|
||||||
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) \
|
-L$(LIBOGC_LIB)
|
||||||
-L$(LIBOGC_LIB)
|
|
||||||
|
export OUTPUT := $(CURDIR)/$(TARGET)
|
||||||
export OUTPUT := $(CURDIR)/$(TARGET)
|
.PHONY: $(BUILD) clean
|
||||||
.PHONY: $(BUILD) clean
|
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
#---------------------------------------------------------------------------------
|
$(BUILD):
|
||||||
$(BUILD):
|
@[ -d $@ ] || mkdir -p $@
|
||||||
@[ -d $@ ] || mkdir -p $@
|
@make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
|
||||||
@make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
|
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
#---------------------------------------------------------------------------------
|
clean:
|
||||||
clean:
|
@echo clean ...
|
||||||
@echo clean ...
|
@rm -fr $(BUILD) $(OUTPUT).elf $(OUTPUT).dol
|
||||||
@rm -fr $(BUILD) $(OUTPUT).elf $(OUTPUT).dol
|
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
#---------------------------------------------------------------------------------
|
run:
|
||||||
run:
|
psoload $(TARGET).dol
|
||||||
psoload $(TARGET).dol
|
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
#---------------------------------------------------------------------------------
|
reload:
|
||||||
reload:
|
psoload -r $(TARGET).dol
|
||||||
psoload -r $(TARGET).dol
|
|
||||||
|
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
#---------------------------------------------------------------------------------
|
else
|
||||||
else
|
|
||||||
|
DEPENDS := $(OFILES:.o=.d)
|
||||||
DEPENDS := $(OFILES:.o=.d)
|
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
#---------------------------------------------------------------------------------
|
# main targets
|
||||||
# main targets
|
#---------------------------------------------------------------------------------
|
||||||
#---------------------------------------------------------------------------------
|
$(OUTPUT).dol: $(OUTPUT).elf
|
||||||
$(OUTPUT).dol: $(OUTPUT).elf
|
$(OUTPUT).elf: $(OFILES)
|
||||||
$(OUTPUT).elf: $(OFILES)
|
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
#---------------------------------------------------------------------------------
|
# This rule links in binary data with the .jpg extension
|
||||||
# This rule links in binary data with the .jpg extension
|
#---------------------------------------------------------------------------------
|
||||||
#---------------------------------------------------------------------------------
|
%.jpg.o : %.jpg
|
||||||
%.jpg.o : %.jpg
|
#---------------------------------------------------------------------------------
|
||||||
#---------------------------------------------------------------------------------
|
@echo $(notdir $<)
|
||||||
@echo $(notdir $<)
|
$(bin2o)
|
||||||
$(bin2o)
|
|
||||||
|
-include $(DEPENDS)
|
||||||
-include $(DEPENDS)
|
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
#---------------------------------------------------------------------------------
|
endif
|
||||||
endif
|
#---------------------------------------------------------------------------------
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
|
|
|
@ -4,12 +4,13 @@
|
||||||
|
|
||||||
How To use Bitmap Fonts
|
How To use Bitmap Fonts
|
||||||
============================================*/
|
============================================*/
|
||||||
#include "../../../GRRLIB/GRRLIB/GRRLIB.h"
|
#include <grrlib.h>
|
||||||
#include "../../../GRRLIB/GRRLIB/GRRLIB_addon.h"
|
|
||||||
|
|
||||||
#include <ogc/lwp_watchdog.h> // Needed for gettime and ticks_to_millisecs
|
#include <ogc/lwp_watchdog.h> // Needed for gettime and ticks_to_millisecs
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <wiiuse/wpad.h>
|
#include <wiiuse/wpad.h>
|
||||||
|
#include <wiiuse/wpad.h>
|
||||||
|
#include <fat.h>
|
||||||
|
|
||||||
#include "gfx/BMfont1.h"
|
#include "gfx/BMfont1.h"
|
||||||
#include "gfx/BMfont2.h"
|
#include "gfx/BMfont2.h"
|
||||||
|
@ -52,6 +53,23 @@
|
||||||
|
|
||||||
static u8 CalculateFrameRate();
|
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 main() {
|
||||||
int left = 0, top = 0, page = 0, frame = TILE_DOWN + 1;
|
int left = 0, top = 0, page = 0, frame = TILE_DOWN + 1;
|
||||||
unsigned int wait = TILE_DELAY, direction = TILE_DOWN, direction_new = TILE_DOWN;
|
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) {
|
if(wpadheld & WPAD_BUTTON_1 && wpadheld & WPAD_BUTTON_2) {
|
||||||
WPAD_Rumble(WPAD_CHAN_0, 1); // Rumble on
|
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
|
WPAD_Rumble(WPAD_CHAN_0, 0); // Rumble off
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue