Okey, i'm going to make a casino game. The problem here is sound. I want that there are 2 songs playing in a loop.
The problem in my code is where i added :// PROBLEM IS HERE!!!!!
There should be something like this :
MP3_Load("sound" AND ADD THIS VAR songtel AND ADD THIS STRING".mp3");
so the output would be : sound2.mp3, for example, but I don't know how to 'attach' them.
Code: Select all
//Casino!
//By Miklas 'Miki' hoet
//Started on 29 Aug 2008
#include <pspkernel.h>
#include <pspdebug.h>
#include <pspdisplay.h>
#include <pspctrl.h>
#include <pspgu.h>
#include <png.h>
#include <stdio.h>
#include "graphics.h"
#include <psppower.h>
#include "mp3player.h"
#include <pspaudio.h>
PSP_MODULE_INFO("Casino",0,1,1);
#define printf pspDebugScreenPrintf
#define MAX(X,Y) ((X) > (Y) ? (X) : (Y))
#define RGB(r, g, b) ((r)|((g)<<8)|((b)<<16))
// BEGIN BLOCK
/* Exit callback */
int exit_callback(int arg1, int arg2, void *common) {
sceKernelExitGame();
return 0;
}
/* Callback thread */
int CallbackThread(SceSize args, void *argp) {
int cbid;
cbid = sceKernelCreateCallback("Exit Callback", exit_callback, NULL);
sceKernelRegisterExitCallback(cbid);
sceKernelSleepThreadCB();
return 0;
}
/* Sets up the callback thread and returns its thread id */
int SetupCallbacks(void) {
int thid = 0;
thid = sceKernelCreateThread("update_thread", CallbackThread, 0x11, 0xFA0, 0, 0);
if(thid >= 0) {
sceKernelStartThread(thid, 0, 0);
}
return thid;
}
// MAIN BLOCK
int main(){
SetupCallbacks();
scePowerSetClockFrequency(333,333,166);
initGraphics();
pspAudioInit();
SceCtrlData pad;
MP3_Init(1);
MP3_Load("sound1.mp3");
MP3_Play();
int j;
int i;
int songs;
int songtel;
songtel = 1;
songs = 2;
int selComponent = 0;
char filler[10];
int bgR = 0;
int bgG = 0;
int bgB = 0;
Color highlightColor = RGB(200,200,200);
Color dimmedColor = RGB(100,100,100);
Color shadowColorH = RGB(55,55,55);
Color shadowColorD = RGB(55,55,55);
//Begin loop (Button_press)
while (0){
// MUZIEK
sceCtrlReadBufferPositive(&pad, 1);
if(pad.Buttons & PSP_CTRL_CIRCLE) {
MP3_Pause();
for(j=0; j<10; j++) {
sceDisplayWaitVblankStart();
}
}
if (MP3_EndOfStream() == 1) {
MP3_Stop();
songtel++;
if (songtel > songs){
songtel = 1;
}
// PROBLEM IS HERE!!!!!
MP3_Play();
}
// MUZIEK
//sceCtrlReadBufferPositive(&pad, 1); //in commentaar, bij muziek eerder gebruikt
if(pad.Buttons & PSP_CTRL_UP) {
if(selComponent > 0) {
selComponent--;
}
for(i=0; i<10; i++) {
sceDisplayWaitVblankStart();
}
} else if(pad.Buttons & PSP_CTRL_DOWN) {
if(selComponent < 2) {
selComponent++;
}
for(i=0; i<10; i++) {
sceDisplayWaitVblankStart();
}
}
if(pad.Buttons & PSP_CTRL_RIGHT) {
switch(selComponent) {
case 0:
bgR++;
break;
case 1:
bgG++;
break;
case 2:
bgB++;
break;
default:
//SHOULD NEVER EXECUTE
break;
}
} else if(pad.Buttons & PSP_CTRL_LEFT) {
switch(selComponent) {
case 0:
bgR--;
break;
case 1:
bgG--;
break;
case 2:
bgB--;
break;
default:
//SHOULD NEVER EXECUTE
break;
}
}
if(bgR < 0) {
bgR = 0;
} else if(bgR > 255) {
bgR = 255;
}
if(bgG < 0) {
bgG = 0;
} else if(bgG > 255) {
bgG = 255;
}
if(bgB < 0) {
bgB = 0;
} else if(bgB > 255) {
bgB = 255;
}
fillScreenRect(RGB(bgR, bgG, bgB),0,0,SCREEN_WIDTH, SCREEN_HEIGHT);
sprintf(filler, "RED: %i", bgR);
if(selComponent == 0) {
printTextScreen(11, 10, filler, shadowColorH);
printTextScreen(10, 10, filler, highlightColor);
} else {
printTextScreen(11, 10, filler, shadowColorD);
printTextScreen(10, 10, filler, dimmedColor);
}
sprintf(filler, "GREEN: %i", bgG);
if(selComponent == 1) {
printTextScreen(11, 20, filler, shadowColorH);
printTextScreen(10, 20, filler, highlightColor);
} else {
printTextScreen(11, 20, filler, shadowColorD);
printTextScreen(10, 20, filler, dimmedColor);
}
sprintf(filler, "BLUE: %i", bgB);
if(selComponent == 2) {
printTextScreen(11, 30, filler, shadowColorH);
printTextScreen(10, 30, filler, highlightColor);
} else {
printTextScreen(11, 30, filler, shadowColorD);
printTextScreen(10, 30, filler, dimmedColor);
}
flipScreen();
for(i=0; i<1; i++) {
sceDisplayWaitVblankStart();
}
}
return 0;
}
// MAIN BLOCK