My main.c file:
Code: Select all
#include <stdlib.h>
#include <stdio.h>
#include <kos.h>
#include <dc/sound/sound.h>
#include <dc/sound/sfxmgr.h>
#include <oggvorbis/sndoggvorbis.h>
#include "pvrfuncts.h"
#include "../../src/game.h"
#include "patches.h"
#include "joymousekey.h"
extern pvr_ptr_t back_tex;
yeti_t yeti;
int done=0; // Keeps track of whether or not we're still playing.
#define title (YETI_STR_TITLE "Yeti PVR Demo" YETI_STR_VERSION " - " YETI_STR_COPYRIGHT)
void keyboard_update()
{
yeti.keyboard.up = up_joy();
yeti.keyboard.down = down_joy();
yeti.keyboard.left = left_joy();
yeti.keyboard.right = right_joy();
yeti.keyboard.a = shoot_but();
yeti.keyboard.b = jump_but();
yeti.keyboard.l = ltrig_key();
yeti.keyboard.r = rtrig_key();
yeti.keyboard.select = start_but();
}
int main(int argc, char *argv[])
{
fs_chdir("/cd");
pvr_setup();
snd_init();
sndoggvorbis_init();
enemyfire = snd_sfx_load("enemyfire.wav");
if((dangerous = fopen("dangerous.ogg", "rb"))==NULL){fprintf(stdout,"the ogg file isn't there!!!111oneoneone");};
//Initiallize Yeti3D
lua_fix(); // fixes to render properly in RGB565
sprite_fix(); // fixes sprites to render properly in RGB565
yeti_init(&yeti, (framebuffer_t*)back_tex, (framebuffer_t*)back_tex, textures, palette, lua);
game_init(&yeti);
while(done==0) // While we're not done playing, keep looping.
{
game_loop(&yeti);
draw_frame();
keyboard_update();
if(!sndoggvorbis_isplaying())
{
sndoggvorbis_start_fd(dangerous, 1);
}
}
return 0;
}
Code: Select all
#include <kos.h>
/* textures */
pvr_ptr_t back_tex;
/* init background */
void back_init()
{
back_tex = pvr_mem_malloc(512*512*2);
}
/* draw background */
void draw_back()
{
pvr_poly_cxt_t cxt;
pvr_poly_hdr_t hdr;
pvr_vertex_t vert;
pvr_poly_cxt_txr(&cxt, PVR_LIST_OP_POLY, PVR_TXRFMT_RGB565|PVR_TXRFMT_NONTWIDDLED, 512, 512, back_tex, PVR_FILTER_BILINEAR);
pvr_poly_compile(&hdr, &cxt);
pvr_prim(&hdr, sizeof(hdr));
vert.argb = PVR_PACK_COLOR(1.0f, 1.0f, 1.0f, 1.0f);
vert.oargb = 0;
vert.flags = PVR_CMD_VERTEX;
vert.x = 1;
vert.y = 1;
vert.z = 1;
vert.u = 0.0;
vert.v = 0.0;
pvr_prim(&vert, sizeof(vert));
vert.x = 640;
vert.y = 1;
vert.z = 1;
vert.u = 1.0;
vert.v = 0.0;
pvr_prim(&vert, sizeof(vert));
vert.x = 1;
vert.y = 480;
vert.z = 1;
vert.u = 0.0;
vert.v = 1.0;
pvr_prim(&vert, sizeof(vert));
vert.x = 640;
vert.y = 480;
vert.z = 1;
vert.u = 1.0;
vert.v = 1.0;
vert.flags = PVR_CMD_VERTEX_EOL;
pvr_prim(&vert, sizeof(vert));
}
/* base y coordinate */
int y = 0;
/* draw one frame */
void draw_frame()
{
pvr_wait_ready();
pvr_scene_begin();
pvr_list_begin(PVR_LIST_OP_POLY);
draw_back();
pvr_list_finish();
pvr_scene_finish();
}
void pvr_setup()
{
/* init kos */
pvr_init_defaults();
/* init background */
back_init();
}