forked from HACKERCHANNEL/PSL1GHT
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of http://github.com/hermesEOL/PSL1GHT
Conflicts: psl1ght/sprx/libsysutil/exports.h
- Loading branch information
Showing
6 changed files
with
468 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#pragma once | ||
|
||
#include <psl1ght/types.h> | ||
#include <stdlib.h> | ||
|
||
EXTERN_BEGIN | ||
|
||
|
||
typedef enum { | ||
|
||
MSGDIALOG_ERROR = 0, | ||
MSGDIALOG_NORMAL = 1, | ||
MSGDIALOG_MUTE_ON = 2, | ||
MSGDIALOG_BACKGROUND_INVISIBLE = 4, | ||
MSGDIALOG_BUTTON_TYPE_YESNO = 16, | ||
MSGDIALOG_BUTTON_TYPE_OK = 32, | ||
MSGDIALOG_DISABLE_CANCEL_ON = 128, | ||
MSGDIALOG_DEFAULT_CURSOR_NO = 256, | ||
|
||
MSGDIALOG_SINGLE_PROGRESSBAR = 4096, | ||
MSGDIALOG_DOUBLE_PROGRESSBAR = 8192 | ||
|
||
} msgtype; | ||
|
||
typedef enum { | ||
|
||
MSGDIALOG_BUTTON_NONE = -1, | ||
MSGDIALOG_BUTTON_INVALID, | ||
MSGDIALOG_BUTTON_OK, | ||
MSGDIALOG_BUTTON_YES = 1, | ||
MSGDIALOG_BUTTON_NO, | ||
MSGDIALOG_BUTTON_ESCAPE | ||
|
||
} msgbutton; | ||
|
||
typedef void (*MsgDialog)(msgbutton button, void *userdata); | ||
|
||
s32 MsgDialogOpen(msgtype type, const char * msg, MsgDialog func, void * userdata, void *unused); | ||
s32 MsgDialogOpen_ex(msgtype type, const char * msg, opd32 * func, void * userdata, void *unused); | ||
s32 MsgDialogClose(void); | ||
s32 MsgDialogDelayedClose(float ms); | ||
|
||
s32 MsgDialogErrorCode(u32 errorcode, MsgDialog func, void * userdata, void *unused); | ||
s32 MsgDialogErrorCode_ex(u32 errorcode, opd32 * func, void * userdata, void *unused); | ||
|
||
#define PROGRESSBAR_INDEX0 0 | ||
#define PROGRESSBAR_INDEX1 1 | ||
|
||
s32 MsgDialogProgressBarMessage(u32 index, const char * msg); | ||
s32 MsgDialogResetProgressBar(u32 index); | ||
s32 MsgDialogIncProgressBar(u32 index, u32 percent); | ||
|
||
EXTERN_END |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,17 @@ | ||
#include "sysutil/events.h" | ||
#include "sysutil/msgdialog.h" | ||
|
||
s32 sysRegisterCallback(sysEventSlot slot, sysCallback func, void * userdata) | ||
{ | ||
return sysRegisterCallback_ex(slot, OPD32(func), userdata); | ||
} | ||
|
||
s32 MsgDialogOpen(u32 type, const char * msg, MsgDialog func, void * userdata, void *unused) | ||
{ | ||
return MsgDialogOpen_ex(type, msg, OPD32(func), userdata, unused); | ||
} | ||
|
||
s32 MsgDialogErrorCode(u32 errorcode, MsgDialog func, void * userdata, void *unused) | ||
{ | ||
return MsgDialogErrorCode_ex(errorcode, OPD32(func), userdata, unused); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
.SUFFIXES: | ||
ifeq ($(strip $(PSL1GHT)),) | ||
$(error "PSL1GHT must be set in the environment.") | ||
endif | ||
|
||
include $(PSL1GHT)/Makefile.base | ||
|
||
TARGET := $(notdir $(CURDIR)) | ||
BUILD := build | ||
SOURCE := source | ||
INCLUDE := include | ||
DATA := data | ||
LIBS := -lgcm_sys -lreality -lsysutil -lio -lm | ||
|
||
TITLE := Template - PSL1GHT | ||
APPID := TEST00003 | ||
CONTENTID := UP0001-$(APPID)_00-0000000000000000 | ||
|
||
CFLAGS += -g -O2 -Wall --std=gnu99 | ||
CXXFLAGS += -g -O2 -Wall | ||
|
||
ifneq ($(BUILD),$(notdir $(CURDIR))) | ||
|
||
export OUTPUT := $(CURDIR)/$(TARGET) | ||
export VPATH := $(foreach dir,$(SOURCE),$(CURDIR)/$(dir)) \ | ||
$(foreach dir,$(DATA),$(CURDIR)/$(dir)) | ||
export BUILDDIR := $(CURDIR)/$(BUILD) | ||
export DEPSDIR := $(BUILDDIR) | ||
|
||
CFILES := $(foreach dir,$(SOURCE),$(notdir $(wildcard $(dir)/*.c))) | ||
CXXFILES := $(foreach dir,$(SOURCE),$(notdir $(wildcard $(dir)/*.cpp))) | ||
SFILES := $(foreach dir,$(SOURCE),$(notdir $(wildcard $(dir)/*.S))) | ||
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.bin))) | ||
VCGFILES := $(foreach dir,$(SOURCE),$(notdir $(wildcard $(dir)/*.vcg))) | ||
|
||
export OFILES := $(CFILES:.c=.o) \ | ||
$(CXXFILES:.cpp=.o) \ | ||
$(SFILES:.S=.o) \ | ||
$(BINFILES:.bin=.bin.o) \ | ||
$(VCGFILES:.vcg=.vcg.o) | ||
|
||
export BINFILES := $(BINFILES:.bin=.bin.h) | ||
export VCGFILES := $(VCGFILES:.vcg=.vcg.h) | ||
|
||
export INCLUDES := $(foreach dir,$(INCLUDE),-I$(CURDIR)/$(dir)) \ | ||
-I$(CURDIR)/$(BUILD) | ||
|
||
.PHONY: $(BUILD) clean | ||
|
||
$(BUILD): | ||
@[ -d $@ ] || mkdir -p $@ | ||
@make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile | ||
|
||
clean: | ||
@echo Clean... | ||
@rm -rf $(BUILD) $(OUTPUT).elf $(OUTPUT).self $(OUTPUT).a $(OUTPUT).pkg | ||
|
||
pkg: $(BUILD) | ||
@echo Creating PKG... | ||
@mkdir -p $(BUILD)/pkg | ||
@mkdir -p $(BUILD)/pkg/USRDIR | ||
@cp $(ICON0) $(BUILD)/pkg/ | ||
@$(FSELF) -n $(BUILD)/$(TARGET).elf $(BUILD)/pkg/USRDIR/EBOOT.BIN | ||
@$(SFO) --title "$(TITLE)" --appid "$(APPID)" -f $(SFOXML) $(BUILD)/pkg/PARAM.SFO | ||
@$(PKG) --contentid $(CONTENTID) $(BUILD)/pkg/ $(OUTPUT).pkg | ||
|
||
run: $(BUILD) | ||
@$(PS3LOADAPP) $(OUTPUT).self | ||
|
||
else | ||
|
||
DEPENDS := $(OFILES:.o=.d) | ||
|
||
$(OUTPUT).self: $(OUTPUT).elf | ||
$(OUTPUT).elf: $(OFILES) | ||
$(OFILES): $(BINFILES) $(VCGFILES) | ||
|
||
-include $(DEPENDS) | ||
|
||
endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#pragma once | ||
|
||
#include <sysutil/video.h> | ||
#include <rsx/gcm.h> | ||
|
||
extern u32 *buffer[2]; | ||
extern gcmContextData *context; | ||
extern VideoResolution res; | ||
|
||
// Initilize the screen and rsx | ||
void init_screen(); | ||
|
||
// Block the PPU thread untill the previous flip operation has finished. | ||
void waitFlip(); | ||
|
||
void flip(s32 buffer); | ||
|
||
// Needs to be called each frame to map the buffers and setup render target | ||
void setupRenderTarget(u32 currentBuffer); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,197 @@ | ||
|
||
#include <stdio.h> | ||
#include <malloc.h> | ||
#include <string.h> | ||
#include <assert.h> | ||
#include <unistd.h> | ||
#include <math.h> | ||
|
||
#include <rsx/commands.h> | ||
#include <rsx/nv40.h> | ||
#include <rsx/reality.h> | ||
|
||
#include <io/pad.h> | ||
|
||
#include <sysmodule/sysmodule.h> | ||
|
||
#include "rsxutil.h" | ||
|
||
// for msgdialogs | ||
#include "sysutil/events.h" | ||
#include "sysutil/msgdialog.h" | ||
|
||
int currentBuffer = 0; | ||
|
||
void my_flip() | ||
{ | ||
//tiny3d_Flip(); | ||
|
||
flip(currentBuffer); // Flip buffer onto screen | ||
waitFlip(); // Wait for the last flip to finish, so we can draw to the old buffer | ||
currentBuffer = !currentBuffer; | ||
} | ||
|
||
|
||
|
||
|
||
volatile int dialog_action = 0; | ||
|
||
void my_dialog(msgbutton button, void *userdata) | ||
{ | ||
switch(button) { | ||
|
||
case MSGDIALOG_BUTTON_OK: | ||
dialog_action = 1; | ||
break; | ||
case MSGDIALOG_BUTTON_NO: | ||
case MSGDIALOG_BUTTON_ESCAPE: | ||
dialog_action = 2; | ||
break; | ||
case MSGDIALOG_BUTTON_NONE: | ||
dialog_action = -1; | ||
break; | ||
default: | ||
break; | ||
} | ||
} | ||
|
||
|
||
void dialog() | ||
{ | ||
int response; | ||
u32 happypercent; | ||
u32 moneypercent; | ||
|
||
// error code message | ||
|
||
MsgDialogErrorCode(0xBEBACAFE, my_dialog, (void *) 0xEEEE0001, NULL); | ||
MsgDialogDelayedClose(3000.0f); // 3 seconds | ||
|
||
dialog_action = 0; | ||
while(dialog_action!=-1) | ||
{ | ||
sysCheckCallback();my_flip(); | ||
} | ||
|
||
MsgDialogClose(); | ||
|
||
// yes/no message | ||
|
||
msgtype mdialogyesno = MSGDIALOG_NORMAL | MSGDIALOG_BUTTON_TYPE_YESNO | MSGDIALOG_DISABLE_CANCEL_ON | MSGDIALOG_DEFAULT_CURSOR_NO; | ||
|
||
MsgDialogOpen(mdialogyesno, "Hey!!\nYou are Happy?", my_dialog, (void *) 0x11110001, NULL); | ||
|
||
dialog_action = 0; | ||
while(!dialog_action) | ||
{ | ||
sysCheckCallback();my_flip(); | ||
} | ||
|
||
MsgDialogClose(); | ||
|
||
response = dialog_action; | ||
|
||
// OK message | ||
|
||
msgtype mdialogok = MSGDIALOG_NORMAL | MSGDIALOG_BUTTON_TYPE_OK; | ||
|
||
if(response == 1) | ||
MsgDialogOpen(mdialogok, "I'm glad you're happy :)\nMerry Christmas!!!", my_dialog, (void *) 0x22220001, NULL); | ||
else | ||
MsgDialogOpen(mdialogok, "Ok, but removes your vinegar face :p\nIt's Christmas!!!", my_dialog, (void *) 0x22220002, NULL); | ||
|
||
dialog_action = 0; | ||
while(!dialog_action) | ||
{ | ||
sysCheckCallback();my_flip(); | ||
} | ||
|
||
MsgDialogClose(); | ||
|
||
// Single Progress bar | ||
|
||
msgtype mdialogprogress = MSGDIALOG_SINGLE_PROGRESSBAR; | ||
|
||
happypercent = 0; | ||
|
||
MsgDialogOpen(mdialogprogress, "Recharging happiness batteries...", my_dialog, (void *) 0x33330001, NULL); | ||
MsgDialogProgressBarMessage(PROGRESSBAR_INDEX0, "You're Happy"); | ||
MsgDialogResetProgressBar(PROGRESSBAR_INDEX0); | ||
|
||
dialog_action = 0; | ||
while(!dialog_action) | ||
{ | ||
MsgDialogIncProgressBar(PROGRESSBAR_INDEX0, happypercent); | ||
sysCheckCallback();my_flip(); | ||
if(happypercent < 100) happypercent++; | ||
usleep(100*1000); | ||
} | ||
|
||
MsgDialogClose(); | ||
|
||
// Double Progress bar | ||
|
||
mdialogprogress = MSGDIALOG_DOUBLE_PROGRESSBAR; | ||
|
||
moneypercent = 0; | ||
|
||
MsgDialogOpen(mdialogprogress, "Recharging Virtual money...", my_dialog, (void *) 0x33330002, NULL); | ||
MsgDialogProgressBarMessage(PROGRESSBAR_INDEX0, "You're Happy"); | ||
MsgDialogResetProgressBar(PROGRESSBAR_INDEX0); | ||
MsgDialogProgressBarMessage(PROGRESSBAR_INDEX1, "Virtual money"); | ||
MsgDialogResetProgressBar(PROGRESSBAR_INDEX1); | ||
|
||
dialog_action = 0; | ||
while(!dialog_action) | ||
{ | ||
MsgDialogIncProgressBar(PROGRESSBAR_INDEX0, happypercent); | ||
MsgDialogIncProgressBar(PROGRESSBAR_INDEX1, moneypercent); | ||
sysCheckCallback();my_flip(); | ||
if(happypercent < 100) happypercent++; | ||
if(moneypercent < 100) moneypercent++; | ||
usleep(100*1000); | ||
} | ||
|
||
MsgDialogClose(); | ||
|
||
// OK with delay time | ||
|
||
MsgDialogOpen(mdialogok, "Congratulations!!!\nYou are now happy and you have virtual money :p", my_dialog, (void *) 0x22220003, NULL); | ||
MsgDialogDelayedClose(3000.0f); // 3 seconds | ||
|
||
dialog_action = 0; | ||
while(!dialog_action) | ||
{ | ||
sysCheckCallback();my_flip(); | ||
} | ||
|
||
MsgDialogClose(); | ||
|
||
// OK with delay time | ||
|
||
MsgDialogOpen(mdialogok, "Good bye!!", my_dialog, (void *) 0x22220004, NULL); | ||
MsgDialogDelayedClose(2000.0f); // 2 seconds | ||
|
||
dialog_action = 0; | ||
while(!dialog_action) | ||
{ | ||
sysCheckCallback();my_flip(); | ||
} | ||
|
||
MsgDialogClose(); | ||
|
||
} | ||
|
||
s32 main(s32 argc, const char* argv[]) | ||
{ | ||
|
||
init_screen(); | ||
ioPadInit(7); | ||
|
||
waitFlip(); | ||
|
||
dialog(); | ||
|
||
return 0; | ||
} | ||
|
Oops, something went wrong.