Class | Joyau |
In: |
main.cpp
Drawable.cpp Audio.cpp Kernel.cpp Manager.cpp Keys.cpp Graphics.cpp Buffer.cpp |
Changes the current directory.
/* call-seq: cd(dirname) Changes the current directory. */ VALUE Kernel_cd(VALUE self, VALUE dir) { sceIoChdir(StringValuePtr(dir)); return Qnil; }
Frees all the fonts.
/* Frees all the fonts. */ VALUE clearFonts(VALUE self) { Manager &m = Manager::getInstance(); m.clearFonts(); return Qnil; }
Frees the pictures. When manipulating the memory by yourself, be carefull: you have to reload the ressource you still want to use (If you don’t, a crash will occur).
/* Frees the pictures. When manipulating the memory by yourself, be carefull: you have to reload the ressource you still want to use (If you don't, a crash will occur). */ VALUE clearImages(VALUE self) { Manager &m = Manager::getInstance(); m.clearImages(); return Qnil; }
Clears the screen.
/* Clears the screen. */ VALUE Graphics_clear(VALUE self) { oslCls(); return Qnil; }
Frees the sound buffers.
/* Frees the sound buffers. */ VALUE clearBuffers(VALUE self) { Manager &m = Manager::getInstance(); m.clearBuffers(); return Qnil; }
Creates a new color hash.
/* call-seq: color(r, g, b, a = 255) Creates a new color hash. */ VALUE Graphics_color(int argc, VALUE *argv, VALUE self) { if (argc >= 3) { VALUE hash = rb_hash_new(); rb_hash_aset(hash, rb_str_new2("r"), argv[0]); rb_hash_aset(hash, rb_str_new2("g"), argv[1]); rb_hash_aset(hash, rb_str_new2("b"), argv[2]); if (argc < 4) rb_hash_aset(hash, rb_str_new2("a"), INT2FIX(255)); else rb_hash_aset(hash, rb_str_new2("a"), argv[3]); return hash; } else return Qfalse; // not enough arguments. }
Prints something on a nice debugging screen. Joyau.initGfx should have been called before.
/* call-seq: debug(string) -> nil Prints something on a nice debugging screen. +Joyau.initGfx+ should have been called before. */ VALUE debug(VALUE self, VALUE text) { oslDebug(StringValuePtr(text)); return Qnil; }
Three keys are checked in the given hash : “:buffer” which is the buffer on which manipulation are done (by default, the actual buffer is taken), “:painter”, which tell us to yield a +Joyau::Painter+ instead of a +Joyau::Buffer+ when true (false by default), and “:auto_update“ which tell us whether we should update the buffer (true by default).
It is mandatory to give a block to this function.
Examples:
Joyau.draw(:buffer => a_buffer, :painter => true) Joyau.draw(:auto_update => false) Joyau.draw(:painter => true) Joyau.draw(:buffer => a_buffer)
/* call-seq: draw(hash = nil) { ... } -> nil Three keys are checked in the given hash : ":buffer" which is the buffer on which manipulation are done (by default, the actual buffer is taken), ":painter", which tell us to yield a +Joyau::Painter+ instead of a +Joyau::Buffer+ when true (false by default), and ":auto_update" which tell us whether we should update the buffer (true by default). It is mandatory to give a block to this function. Examples: Joyau.draw(:buffer => a_buffer, :painter => true) Joyau.draw(:auto_update => false) Joyau.draw(:painter => true) Joyau.draw(:buffer => a_buffer) */ VALUE Joyau_draw(int argc, VALUE *argv, VALUE self)
Draws a circle on the screen.
/* call-seq: drawCircle(x, y, radius, color) Draws a circle on the screen. */ VALUE Graphics_drawCircle(VALUE self, VALUE x, VALUE y, VALUE radius, VALUE col) { OSL_COLOR c = hash2col(col); int _x = FIX2INT(x); int _y = FIX2INT(y); int _radius = FIX2INT(radius); oslDrawCircle(_x, _y, _radius, c); return Qnil; }
Draws a filled circle on the screen.
/* call-seq: drawFillCircle(x, y, radius, color) Draws a filled circle on the screen. */ VALUE Graphics_drawFillCircle(VALUE self, VALUE x, VALUE y, VALUE radius, VALUE col) { OSL_COLOR c = hash2col(col); int _x = FIX2INT(x); int _y = FIX2INT(y); int _radius = FIX2INT(radius); oslDrawFillCircle(_x, _y, _radius, c); return Qnil; }
Draws a filled rect on the screen.
/* call-seq: drawFillRect(x1, y1, x2, y2, color) Draws a filled rect on the screen. */ VALUE Graphics_drawFillRect(VALUE self, VALUE x1, VALUE y1, VALUE x2, VALUE y2, VALUE color) { OSL_COLOR c = hash2col(color); oslDrawFillRect(FIX2INT(x1), FIX2INT(y1), FIX2INT(x2), FIX2INT(y2), c); return Qnil; }
Draws a line on the screen.
/* call-seq: drawLine(x1, y1, x2, y2, color) Draws a line on the screen. */ VALUE Graphics_drawLine(VALUE self, VALUE x1, VALUE y1, VALUE x2, VALUE y2, VALUE color) { OSL_COLOR c = hash2col(color); oslDrawLine(FIX2INT(x1), FIX2INT(y1), FIX2INT(x2), FIX2INT(y2), c); return Qnil; }
Draws a rect on the screen.
/* call-seq: drawRect(x1, y1, x2, y2, color) Draws a rect on the screen. */ VALUE Graphics_drawRect(VALUE self, VALUE x1, VALUE y1, VALUE x2, VALUE y2, VALUE color) { OSL_COLOR c = hash2col(color); oslDrawRect(FIX2INT(x1), FIX2INT(y1), FIX2INT(x2), FIX2INT(y2), c); return Qnil; }
Draws a scripted (i.e. which may use n, …) text on the screen.
/* call-seq: drawScripted(x, y, txt) Draws a scripted (i.e. which may use \n, ...) text on the screen. */ VALUE drawScripted(VALUE self, VALUE x, VALUE y, VALUE text) { oslScriptText(FIX2INT(x), FIX2INT(y), StringValuePtr(text)); return Qnil; }
Draws a stirring text on the screen.
/* call-seq: drawStirringText(x, y, text) Draws a stirring text on the screen. */ VALUE drawStirringText(VALUE self, VALUE x, VALUE y, VALUE text) { oslPrintStirringString(FIX2INT(x), FIX2INT(y), StringValuePtr(text)); return Qnil; }
Draws a text on the screen.
/* call-seq: drawText(x, y, text) Draws a text on the screen. */ VALUE drawText(VALUE self, VALUE x, VALUE y, VALUE text) { oslDrawString(FIX2INT(x), FIX2INT(y), StringValuePtr(text)); return Qnil; }
Draws a triangle on the screen.
/* call-seq: drawTriangle(x1, y1, x2, y2, x3, y3, col1, col2, col3) Draws a triangle on the screen. */ VALUE Graphics_drawTriangle(VALUE self, VALUE x1, VALUE y1, VALUE x2, VALUE y2, VALUE x3, VALUE y3, VALUE col1, VALUE col2, VALUE col3) { int _x1 = FIX2INT(x1); int _x2 = FIX2INT(x2); int _x3 = FIX2INT(x3); int _y1 = FIX2INT(y1); int _y2 = FIX2INT(y2); int _y3 = FIX2INT(y3); OSL_COLOR _col1 = hash2col(col1); OSL_COLOR _col2 = hash2col(col2); OSL_COLOR _col3 = hash2col(col3); oslDrawGradientTriangle(_x1, _y1, _x2, _y2, _x3, _y3, _col1, _col2, _col3); return Qnil; }
Call this when you’ve finished to draw on the screen.
/* Call this when you've finished to draw on the screen. */ VALUE Graphics_endDraw(VALUE self) { oslEndDrawing(); return Qnil; }
Exits from the game.
/* call-seq: exit Exits from the game. */ VALUE Joyau_exit(VALUE self) { sceKernelExitGame(); return Qnil; }
Fades the screen.
/* Fades the screen. */ VALUE Graphics_fade(VALUE self) { oslFadeInEffect(); return Qnil; }
Sets how many frames can be skipped. By default, your program is running at 60 FPS.
/* call-seq: frameskip(min, max) Sets how many frames can be skipped. By default, your program is running at 60 FPS. */ VALUE Graphics_frameskip(VALUE self, VALUE min, VALUE max) { oslSetFrameskip(FIX2INT(min)); oslSetMaxFrameskip(FIX2INT(max)); return Qnil; }
call-seq: getLength Returns the width of a text if it were drawn on the screen with the actual fonts.
/* call-seq: getLength Returns the width of a text if it were drawn on the screen with the actual fonts. */ VALUE getTextSize(VALUE self, VALUE text) { int val = oslGetStringWidth(StringValuePtr(text)); return INT2FIX(val); }
Returns a string typed through the PSP built-in keyboard.
/* Returns a string typed through the PSP built-in keyboard. */ VALUE Joyau_gets(VALUE self) { SceUtilityOskData data; SceUtilityOskParams params; unsigned short input[128] = { 'E', 'n', 't', 'e', 'r', ' ', 'y', 'o', 'u', 'r', ' ', 't', 'e','x', 't', 0 }; unsigned short output[128] = { 0 }; memset(&data, 0, sizeof(data)); data.lines = 1; data.unk_24 = 1; data.inputtype = PSP_UTILITY_OSK_INPUTTYPE_ALL; data.desc = input; data.intext = input; data.outtextlength = 128; data.outtextlimit = 128; data.outtext = output; memset(¶ms, 0, sizeof(params)); params.base.size = sizeof(params); sceUtilityGetSystemParamInt(PSP_SYSTEMPARAM_ID_INT_LANGUAGE, ¶ms.base.language); sceUtilityGetSystemParamInt(PSP_SYSTEMPARAM_ID_INT_UNKNOWN, ¶ms.base.buttonSwap); params.base.graphicsThread = 17; params.base.accessThread = 19; params.base.fontThread = 18; params.base.soundThread = 16; params.datacount = 1; params.data = &data; sceUtilityOskInitStart(¶ms); bool done = false; while (!done) { oslStartDrawing(); oslDrawFillRect(0, 0, 480, 272, RGBA(0, 0, 0, 255)); oslEndDrawing(); switch(sceUtilityOskGetStatus()) { case PSP_UTILITY_DIALOG_INIT: break; case PSP_UTILITY_DIALOG_VISIBLE: sceUtilityOskUpdate(1); break; case PSP_UTILITY_DIALOG_QUIT: sceUtilityOskShutdownStart(); break; case PSP_UTILITY_DIALOG_FINISHED: break; case PSP_UTILITY_DIALOG_NONE: done = true; default : break; } oslEndDrawing(); oslEndFrame(); oslSyncFrame(); } char *ret = new char[128]; for (int i = 0; i < 128; ++i) ret[i] = (char)data.outtext[i]; return rb_str_new2(ret); }
Inits the audio module from Joyau, which allows to use classes like +Joyau::Stream+ and +Joyau::Audio+.
See +Joyau::stopAudio+ in order to stop it.
/* call-seq: initAudio Inits the audio module from Joyau, which allows to use classes like +Joyau::Stream+ and +Joyau::Audio+. See +Joyau::stopAudio+ in order to stop it. */ VALUE Audio_init(VALUE self) { initOpenAl(); return Qnil; }
Inits the graphics module.
/* Inits the graphics module. */ VALUE Graphics_init(VALUE self) { oslInitGfx(OSL_PF_8888, 1); Buffer::updateScreen(); return Qnil; }
Inits Joyau’s library. Use this before graphics module.
/* Inits Joyau's library. Use this before graphics module. */ VALUE lib_start(VALUE self) { oslInit(OSL_IF_USEOWNCALLBACKS); return Qnil; }
Returns true untill the user has exited through the home button.
/* Returns true untill the user has exited through the home button. */ VALUE Graphics_mayPlay(VALUE self) { return osl_quit ? Qfalse : Qtrue; }
Creates a directory.
/* call-seq: mkdir(dir) Creates a directory. */ VALUE File_mkdir(VALUE self, VALUE dir) { sceIoMkdir(StringValuePtr(dir), 0777); return Qnil; }
Renames a file.
/* call-seq: rename(old, new) Renames a file. */ VALUE File_rename(VALUE self, VALUE old, VALUE newName) { sceIoRename(StringValuePtr(old), StringValuePtr(newName)); return Qnil; }
Returns the battery life percentage.
/* Returns the battery life percentage. */ VALUE Kernel_getPowerPercent(VALUE self) { return INT2FIX(scePowerGetBatteryLifePercent()); }
Returns the battery lifetime.
/* Returns the battery lifetime. */ VALUE Kernel_getPowerTime(VALUE self) { return INT2FIX(scePowerGetBatteryLifeTime()); }
Prints all the given strings on the debug screen, on per line. They’re printed in +$stdout+ too.
/* call-seq: puts(str1, str2, str3, ...) Prints all the given strings on the debug screen, on per line. They're printed in +$stdout+ too. */ VALUE Joyau_puts(int argc, VALUE *argv, VALUE self) { for (int i = 0; i < argc; ++i) { pspDebugScreenPrintf("%s\n", StringValuePtr(argv[i])); std::cout << StringValuePtr(argv[i]) << std::endl; } return Qnil; }
This is an old, and deprecated function which checks the pad. Do not use this, use Pad’s methods directly.
/* This is an old, and deprecated function which checks the pad. Do not use this, use Pad's methods directly. */ VALUE checkKeys(VALUE self) { VALUE keys = rb_gv_get("$keys"); std::string keys_str[] = { "select", "start", "up", "down", "left", "right", "L", "R", "cross", "triangle", "square", "hold" }; Pad &pad = Pad::getInstance(); pad.update(); for (int i = 0; i < 12; ++i) { if (pad.held(keys_str[i])) rb_hash_aset(keys, rb_str_new2(keys_str[i].c_str()), Qtrue); else rb_hash_aset(keys, rb_str_new2(keys_str[i].c_str()), Qfalse); if (pad.pressed(keys_str[i])) rb_hash_aset(keys, rb_str_new2(("pressed_" + keys_str[i]).c_str()), Qtrue); else rb_hash_aset(keys, rb_str_new2(("pressed_" + keys_str[i]).c_str()), Qfalse); if (pad.released(keys_str[i])) rb_hash_aset(keys, rb_str_new2(("released_" + keys_str[i]).c_str()), Qtrue); else rb_hash_aset(keys, rb_str_new2(("released_" + keys_str[i]).c_str()), Qfalse); } int analogX = pad.getStickX(); int analogY = pad.getStickY(); rb_hash_aset(keys, rb_str_new2("analogX"), INT2FIX(analogX)); rb_hash_aset(keys, rb_str_new2("analogY"), INT2FIX(analogY)); rb_gv_set("$keys", keys); return Qnil; }
Removes a file.
/* call-seq: rm(file) Removes a file. */ VALUE File_remove(VALUE self, VALUE file) { sceIoRemove(StringValuePtr(file)); return Qnil; }
Removes a directory.
/* call-seq: rmdir(dir) Removes a directory. */ VALUE File_rmdir(VALUE self, VALUE dir) { sceIoRmdir(StringValuePtr(dir)); return Qnil; }
Takes a screenshot.
/* call-seq: screenshot(pic) Takes a screenshot. */ VALUE Graphics_screenshot(VALUE self, VALUE pic) { char *filename = StringValuePtr(pic); oslWriteImageFile(OSL_SECONDARY_BUFFER, filename, 0); return Qnil; }
Changes the actual font.
/* call-seq: setFont(fontname) Changes the actual font. */ VALUE setTextFont(VALUE self, VALUE fontname) { Manager &manager = Manager::getInstance(); oslSetFont(manager.getFont(StringValuePtr(fontname))); return Qnil; }
Sets the color in which the text’s color.
/* call-seq: setTextColor(color) Sets the color in which the text's color. */ VALUE setTextColor(VALUE self, VALUE color) { OSL_COLOR c = hash2col(color); oslSetTextColor(c); return Qnil; }
Allows to draw something on the screen.
/* Allows to draw something on the screen. */ VALUE Graphics_startDraw(VALUE self) { oslStartDrawing(); return Qnil; }
Stops the Graphics module.
/* Stops the Graphics module. */ VALUE Graphics_stop(VALUE self) { oslEndGfx(); return Qnil; }
Stops Joyau’s library.
/* Stops Joyau's library. */ VALUE lib_stop(VALUE self) { oslQuit(); return Qnil; }
Enables auto swizzling for pictures.
/* Enables auto swizzling for pictures. */ VALUE setAutoSwizzle(VALUE self) { oslSetImageAutoSwizzle(1); return Qnil; }
Updates the screen. If false is returned, you shouldn’t draw anything during the next loop.
/* Updates the screen. If false is returned, you shouldn't draw anything during the next loop. */ VALUE Graphics_sync(VALUE self) { oslEndFrame(); if (oslSyncFrame()) return Qtrue; return Qfalse; }