Subversion Repositories pspware

Rev

Rev 345 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
345 Oobles 1
/*
2
 * Lua Player for PSP
3
 * ------------------------------------------------------------------------
4
 * Licensed under the BSD license, see LICENSE for details.
5
 *
6
 * Copyright (c) 2005 Frank Buss <fb@frank-buss.de> (aka Shine)
7
 *
8
 * Credits:
9
 *   many thanks to the authors of the PSPSDK from http://forums.ps2dev.org
10
 *   and to the hints and discussions from #pspdev on freenode.net
11
 *
12
 * $Id: main.cpp 290 2005-12-03 08:49:10Z shine $
13
 */
14
 
15
#include <pspkernel.h>
16
#include <pspdebug.h>
17
#include <pspdisplay.h>
18
#include <pspctrl.h>
19
#include <pspsdk.h>
20
#include <psputility.h>
21
#include <time.h>
22
#include <stdlib.h>
23
#include <string.h>
24
#include <unistd.h>
25
#include <stdio.h>
350 Oobles 26
#include <stdarg.h>
345 Oobles 27
 
28
#include "sio.h"
29
 
30
/* Define the module info section */
350 Oobles 31
PSP_MODULE_INFO(LUABOOT, 0x1000, 1, 1);
345 Oobles 32
PSP_MAIN_THREAD_ATTR(0);
33
PSP_MAIN_THREAD_STACK_SIZE_KB(32);
34
PSP_HEAP_SIZE_KB(32);
35
 
36
// startup path
37
char path[256];
38
 
350 Oobles 39
int debugOutput(const char *format, ...)
345 Oobles 40
{
350 Oobles 41
        va_list opt;
42
        char buffer[2048];
43
        int bufsz;
44
 
345 Oobles 45
        static int debugInitialized = 0;
350 Oobles 46
        if(!format) {
345 Oobles 47
                debugInitialized = 0;
48
                return 0;
49
        }
50
        if (!debugInitialized) {
51
                //disableGraphics();
52
                pspDebugScreenInit();
53
                debugInitialized = 1;
54
        }
350 Oobles 55
        va_start(opt, format);
56
        bufsz = vsnprintf( buffer, (size_t) sizeof(buffer), format, opt);
57
        return pspDebugScreenPrintData(buffer, bufsz);
345 Oobles 58
}
59
 
350 Oobles 60
 
345 Oobles 61
int loadModule( char * moduleLocation )
62
{
63
        char path[256];
64
        getcwd(path, 256);
65
        strcat(path, moduleLocation );
66
 
67
        int retVal = sceKernelLoadModule( path, 0, NULL );
68
        if (retVal < 0)
69
        {
350 Oobles 70
                debugOutput("Error: loadModule %s %x\n", path, retVal);
71
                debugOutput("Loading from %s\n", path );
345 Oobles 72
                return retVal;
73
        }
74
 
75
        int fd;
76
        retVal = sceKernelStartModule( retVal, strlen(path)+1, path, &fd, NULL );
77
        if ( retVal < 0 )
78
        {
350 Oobles 79
                debugOutput("Error: strtModule %s %x\n", path, retVal);
345 Oobles 80
                return retVal;
81
        }
82
 
83
        return 0;
84
}
85
 
350 Oobles 86
int main( SceSize args, void *argp )
345 Oobles 87
{
88
        pspSdkInstallNoDeviceCheckPatch();
89
        pspSdkInstallNoPlainModuleCheckPatch();
350 Oobles 90
        registerSIODriver();
91
 
345 Oobles 92
 
93
        getcwd(path, 256);
94
        int err = pspSdkLoadInetModules();
95
        if (err != 0) {
96
                pspDebugScreenInit();
97
                pspDebugScreenPrintf("pspSdkLoadInetModules failed with %x\n", err);
98
                sceKernelDelayThread(5*1000000); // 5 sec to read error
99
        }
100
 
350 Oobles 101
        int retVal = loadModule( "/loadlib.prx" );
102
        if (retVal < 0 )
103
        {
104
                debugOutput("Error: failed loadModule loadlib.prx\n");
105
                sceKernelSleepThread();
106
        }
107
 
108
        retVal = loadModule( "/luaplayer.prx" );
345 Oobles 109
        if (retVal < 0)
110
        {
350 Oobles 111
                debugOutput("Error: failed loadModule luaplayer.prx\n");
345 Oobles 112
                sceKernelSleepThread();
113
        }
350 Oobles 114
 
345 Oobles 115
        sceKernelSleepThread();
116
        return 0;
117
}
118