Hi all
I have a question regarding memory allocation.
Recently I have been playing around with Iris 3d's ability load png files on polygons...I know that the dreamcast has roughly 16mb of memory and the pvr has about 4mb (please correct me if I'm wrong) after loading about 20 or so png files I run out of memory in the pvr (The files I am loading are 256 x 256) I assume that Iris 3d is loading these images directly into the pvr and only using the pvr to render the images. I wonder how I can access the other memory within the dreamcast. I want to access the other memory so that I have more space for my png files and to only load them into the pvr when they are requested.
My two thoughts on this are:
1) maybe it is possble to change this in my regular code
2) maybe IrisMaterial.hpp needs to be modified so that the png is loaded into other memory instead of the pvr (I did a search and this function has pvr coding in it that Mr novice over here does not understand)
I would like to keep using Iris 3d if possible because I am comfortable coding within it.
1)
/*********************************************************
** Character Stance and Duck Anim
*********************************************************/
#include "Iris.hpp"
#include "time.h"
//#include "timer.h"
int main(int ac, char **av)
{
// the object to display
//IrisObject psyrax;
//int paddle = 1;
// get the context
IrisContext &c = IrisContext::Get();
c.InitContext(1024 * 1024);
// load Iris Object (must be done after Init)
//psyrax.LoadFromFile("/rd/", "psyrax_x.IMD");
// look for paddle
if (c.GetInputManager().ControllerCount() == 0)
{
printf("no controller found\n");
return (-1);
}
//setup project, viewport and camera(view) matrix
c.GetGeometryPipeline().SetProjection(90.0f, 1, 10000.0f);
c.GetGeometryPipeline().SetViewport(0.0f, 0.0f, 320.0f, 240.0f);
c.GetGeometryPipeline().SetView(vect3d(0.0, 100.0f, 0.0),vect3d(0, 0.0, 1.0f),vect3d(0.0, 1.0, 0.0));
c.GetGeometryPipeline().Update();
// set ambient color
c.GetLightingPipeline().SetAmbientColor(IrisColor(0.7f, 0.7f, 0.7f));
c.GetLightingPipeline().Update();
// get the first paddle in mapple bus
IrisController &p = c.GetInputManager().GetController(0);
IrisController &p2 = c.GetInputManager().GetController(1);
int count = 0;
int pushed_down = 0;
int flag = 1;
//CHARACTER1 TRANSPARENCY
IrisMaterial *wolverine_material[17];
wolverine_material[0] = c.GetMaterialManager().LoadMaterial("/rd/Wstance0.png",texture_alpha);
wolverine_material[1] = c.GetMaterialManager().LoadMaterial("/rd/Wstance1.png",texture_alpha);
wolverine_material[2] = c.GetMaterialManager().LoadMaterial("/rd/Wstance2.png",texture_alpha);
wolverine_material[3] = c.GetMaterialManager().LoadMaterial("/rd/Wstance3.png",texture_alpha);
wolverine_material[4] = c.GetMaterialManager().LoadMaterial("/rd/Wstance4.png",texture_alpha);
wolverine_material[5] = c.GetMaterialManager().LoadMaterial("/rd/Wstance5.png",texture_alpha);
wolverine_material[6] = c.GetMaterialManager().LoadMaterial("/rd/Wstance6.png",texture_alpha);
wolverine_material[7] = c.GetMaterialManager().LoadMaterial("/rd/Wstance7.png",texture_alpha);
wolverine_material[8] = c.GetMaterialManager().LoadMaterial("/rd/Wstance8.png",texture_alpha);
wolverine_material[9] = c.GetMaterialManager().LoadMaterial("/rd/Wstance9.png",texture_alpha);
wolverine_material[10] = c.GetMaterialManager().LoadMaterial("/rd/Wstance10.png",texture_alpha);
wolverine_material[11] = c.GetMaterialManager().LoadMaterial("/rd/Wstance11.png",texture_alpha);
wolverine_material[12] = c.GetMaterialManager().LoadMaterial("/rd/Wstance12.png",texture_alpha);
wolverine_material[13] = c.GetMaterialManager().LoadMaterial("/rd/Wstance13.png",texture_alpha);
wolverine_material[14] = c.GetMaterialManager().LoadMaterial("/rd/Wstance14.png",texture_alpha);
wolverine_material[15] = c.GetMaterialManager().LoadMaterial("/rd/Wstance15.png",texture_alpha);
wolverine_material[16] = c.GetMaterialManager().LoadMaterial("/rd/Wstance16.png",texture_alpha);
IrisManualObject alpha_object1;
alpha_object1.Allocate(4);
alpha_object1.GetVertex(0) = vect3d(0.0f, 0.0f, 1.0f);
alpha_object1.GetVertex(1) = vect3d(256.0f, 0.0f, 1.0f);
alpha_object1.GetVertex(2) = vect3d(0.0f, 256.0f, 1.0f);
alpha_object1.GetVertex(3) = vect3d(256.0f, 256.0f, 1.0f);
alpha_object1.SetColor(IrisColor(1.0f, 1.0f, 1.0f, 1.0f));
alpha_object1.SetMaterial(wolverine_material[0]);
alpha_object1.SetUV(0, 0.0f, 0.0f);
alpha_object1.SetUV(1, 1.0f, 0.0f);
alpha_object1.SetUV(2, 0.0f, 1.0f);
alpha_object1.SetUV(3, 1.0f, 1.0f);
alpha_object1.Precalculate2D();
//CHARACTER1 TRANSPARENCY
IrisMaterial *wolverine1_material[12];
wolverine1_material[0] = c.GetMaterialManager().LoadMaterial("/rd/Wduck0.png",texture_alpha);
wolverine1_material[1] = c.GetMaterialManager().LoadMaterial("/rd/Wduck1.png",texture_alpha);
wolverine1_material[2] = c.GetMaterialManager().LoadMaterial("/rd/Wduck2.png",texture_alpha);
wolverine1_material[3] = c.GetMaterialManager().LoadMaterial("/rd/Wduck3.png",texture_alpha);
wolverine1_material[4] = c.GetMaterialManager().LoadMaterial("/rd/Wduck4.png",texture_alpha);
wolverine1_material[5] = c.GetMaterialManager().LoadMaterial("/rd/Wduck5.png",texture_alpha);
wolverine1_material[6] = c.GetMaterialManager().LoadMaterial("/rd/Wduck6.png",texture_alpha);
wolverine1_material[7] = c.GetMaterialManager().LoadMaterial("/rd/Wduck7.png",texture_alpha);
wolverine1_material[8] = c.GetMaterialManager().LoadMaterial("/rd/Wduck8.png",texture_alpha);
wolverine1_material[9] = c.GetMaterialManager().LoadMaterial("/rd/Wduck9.png",texture_alpha);
wolverine1_material[10] = c.GetMaterialManager().LoadMaterial("/rd/Wduck10.png",texture_alpha);
wolverine1_material[11] = c.GetMaterialManager().LoadMaterial("/rd/Wduck11.png",texture_alpha);
IrisManualObject alpha_object2;
alpha_object2.Allocate(4);
alpha_object2.GetVertex(0) = vect3d(0.0f, 0.0f, 1.0f);
alpha_object2.GetVertex(1) = vect3d(256.0f, 0.0f, 1.0f);
alpha_object2.GetVertex(2) = vect3d(0.0f, 256.0f, 1.0f);
alpha_object2.GetVertex(3) = vect3d(256.0f, 256.0f, 1.0f);
alpha_object2.SetColor(IrisColor(1.0f, 1.0f, 1.0f, 1.0f));
alpha_object2.SetMaterial(wolverine_material[0]);
alpha_object2.SetUV(0, 0.0f, 0.0f);
alpha_object2.SetUV(1, 1.0f, 0.0f);
alpha_object2.SetUV(2, 0.0f, 1.0f);
alpha_object2.SetUV(3, 1.0f, 1.0f);
alpha_object2.Precalculate2D();
int stance [55] =
{
1,1,1,
2,2,2,
3,3,3,3,
4,4,4,4,
5,5,5,5,
6,6,6,
7,7,7,7,
8,8,8,
9,9,9,
10,10,10,10,
11,11,11,
12,12,12,12,
13,13,13,
14,14,14,14,
15,15,15,
16,16,16
};
int duck [45] =
{
0,0,0,
1,1,1,1,1,1,
2,2,2,
3,3,3,
4,4,4,
5,5,5,
6,6,6,6,
7,7,7,
8,8,8,
9,9,9,
10,10,10,10,10,
11,11,11,11,11,11
};
//uint32 sec, msec;
//timer_ms_gettime(&sec, &msec);
while (!p. Start() && !p2.Start())
{
timer_spin_sleep(16);
//stance
if (!p.Up() & !p.Down() & !p.Left() & !p.Right() & !p.a() & !p.b() & pushed_down == 0 ){
//printf("\nmill: %f\n\n", msec);
alpha_object1.SetMaterial(wolverine_material[stance[count]]);
count++;
if (count == 55)
count = 0;
}
//stance
//duck
if ( p.Down() & !p.a() & !p.b() ){
if (pushed_down == 0){
count = 0;
pushed_down = 1;
}
alpha_object2.SetMaterial(wolverine1_material[duck[count]]);
//pvr_mem_free(back_tex);
count++;
if (count == 9)
count = 3;
}
//*come up from duck
if ( !p.Down() & !p.a() & !p.b() & pushed_down == 1){
if (flag == 1){
count = 10;
flag = 0;
}
alpha_object2.SetMaterial(wolverine1_material[duck[count]]);
//pvr_mem_free(back_tex);
count++;
if (count == 11)
pushed_down = 0;
}
//duck
c.BeginScene();
c.BeginBlending();
c.SetBlendSrc(BT_SRC_ALPHA);
c.SetBlendDst(BT_ONE);
alpha_object1.SetColor(IrisColor(1.0f, 1.0f, 1.0f, 1));
//c.SetDepthWrite(false);
if (pushed_down == 1)
alpha_object2.Render2D();
else
alpha_object1.Render2D();
//c.SetDepthWrite(true);
c.EndScene();
}
return (0);
}
2)
/*********************************************************
** File name : IrisMaterial.hpp
** Iris Engine V0.9 "alllaiii"
** Date Of Creation: 18/06/2002
** Author : Olivier Chatry - Epitech Console Laboratory
** (http://www.epitech.net/labconsole/)
*********************************************************/
#ifndef CIRISMATERIAL_H
#define CIRISMATERIAL_H
//! TextureType enum.
/*!
This enum give information about texture type.
*/
enum TextureType
{
texture_alpha = PNG_FULL_ALPHA,
texture_noalpha = PNG_NO_ALPHA,
texture_punchtru = PNG_MASK_ALPHA,
texture_vqf
};
/*
* Iris Texture class.
*/
//! IrisTexture class.
/*!
Class used for operations on textures, to load and manipulate them.
IrisTexure objects are difined by an id and the file name of the used texture.
*/
class IrisTexture
{
public:
//! Constructor of the IrsisTexture class.
/*!
Create an empty IrisTexture object.
*/
IrisTexture(void)
{
_id = 0;
_file_name = NULL;
}
//! Destructor of the IrsisTexture class.
/*!
Create an empty IrisTexture object.
*/
~IrisTexture(void);
//! TODO SetTexture function.
/*!
Does nothing.
\return a boolean, true if the assignement is successfull else false.
*/
bool SetTexture(unsigned short *buffer, int size_x, int size_y)
{
return (_id >= 0);
}
//! SetFileName function.
/*!
Set the file name of a texture in IrisTexture object.
\param file_name : a string, the file name of a texture.
\return nothing.
*/
void SetFileName(char *file_name)
{
if (_file_name)
delete [] _file_name;
_file_name = new char [strlen(file_name) + 1];
strcpy(_file_name, file_name);
}
//! GetFileName function.
/*!
Get the file name of the texture in IrisTexture object.
\return a string, the file name of the texture.
*/
char * GetFileName(void)
{
return _file_name;
}
//! GetId function.
/*!
\return an uint32, the id of the IrisTexture object.
*/
uint32 GetId(void)
{
return _id;
}
//! SetId function.
/*!
Set the id of the IrisTexture object.
\param id : an uint32, the id of the IrisTexture object.
\return nothing.
*/
void SetId(uint32 id)
{
_id = id;
}
//! SetType function.
/*!
Set the type of texture in the IrisTexture object.
\param type : the TextureType of the IrisTexture object.
\return nothing.
*/
void SetType(TextureType type)
{
type = _type;
}
protected:
char * _file_name;
uint32 _id;
TextureType _type;
};
/*cxt.txr.format = PVR_TXRFMT_RGB565;
cxt.txr.format = PVR_TXRFMT_ARGB4444;
cxt.txr.format = PVR_TXRFMT_ARGB1555;
#define ARGB4444(a, r, g, b) ((a >> 4) << 12 )
#define ARGB1555(a, r, g, b)
#define RGB565(a, r, g, b)
*/
/**
* Iris Material class.
*/
class IrisMaterial
{
public:
IrisMaterial ()
{
_texture = NULL;
};
~IrisMaterial ()
{
Destroy();
}
void IrisMaterial::Generate(void (*fct_generate)(unsigned short *buffer, int size_x, int size_y), int size_x, int size_y, TextureType type = texture_noalpha);
/*! Load material from a .mat file (for now, .mat is in fact .PNG)
* \param file_name file name of the texture to load. must be a PNG file.
* \param tex texture type (noalpha, alpha, punchthru.)
*/
bool LoadFromFile(char *file_name, TextureType tex = texture_noalpha);
/*! Return a pointer to a given texture index
* \param id index of the texture, for now, always 0.
* \return a pointer to an IrisTexture obejesct.
*/
IrisTexture * GetTexture(int id) { return &(_texture[id]); }
/*! Return number of texture in the material*/
int GetNumTexture() {return _num_texture;};
void SetTempId(int temp_id){_temp_id = temp_id;};
int GetTempId(void) {return (_temp_id);}
pvr_poly_cxt_t *GetCxt(){return &_cxt;}
protected:
void Destroy();
IrisTexture *_texture;
int _num_texture;
int _temp_id;
pvr_poly_cxt_t _cxt;
};
#endif //CIRISMATERIAL_H
PVR AND IRIS 3D
-
- DCEmu Junior
- Posts: 42
- https://www.artistsworkshop.eu/meble-kuchenne-na-wymiar-warszawa-gdzie-zamowic/
- Joined: Thu Feb 06, 2003 3:51 pm
- Has thanked: 0
- Been thanked: 0
-
- Damn Dirty Ape
- Posts: 5031
- Joined: Thu Nov 07, 2002 11:11 pm
- Location: Saugerties, NY
- Has thanked: 0
- Been thanked: 0
I thought the DC had 8MB video memory? I could be wrong on that.
I'm not at all familiar with Iris, but if it is uploading everything to the PVR in one shot, basically, what I can think of two simple-ish options. One would be faster, and the other would consume less of your 16 MB of main memory.
1) You would need a pointer to each of the textures in the PVR, and some equally-sized chunks allocated in main memory. Use the sq_cpy or memcpy function to copy from the PVR to main memory, and then reuse the pointer to the PVR texture to store different data.
2) Basically, the same thing, but you would have a copy of all of your textures in main memory, so you'd only be copying over the ones the PVR needs each frame. This would be faster, but consume more memory. In either case, you'll want to keep track of which textures are available and which are swapped out to main memory.
I'm not at all familiar with Iris, but if it is uploading everything to the PVR in one shot, basically, what I can think of two simple-ish options. One would be faster, and the other would consume less of your 16 MB of main memory.
1) You would need a pointer to each of the textures in the PVR, and some equally-sized chunks allocated in main memory. Use the sq_cpy or memcpy function to copy from the PVR to main memory, and then reuse the pointer to the PVR texture to store different data.
2) Basically, the same thing, but you would have a copy of all of your textures in main memory, so you'd only be copying over the ones the PVR needs each frame. This would be faster, but consume more memory. In either case, you'll want to keep track of which textures are available and which are swapped out to main memory.
- GyroVorbis
- Elysian Shadows Developer
- Posts: 1874
- Joined: Mon Mar 22, 2004 4:55 pm
- Location: #%^&*!!!11one Super Sonic
- Has thanked: 80 times
- Been thanked: 62 times
- Contact:
- GyroVorbis
- Elysian Shadows Developer
- Posts: 1874
- Joined: Mon Mar 22, 2004 4:55 pm
- Location: #%^&*!!!11one Super Sonic
- Has thanked: 80 times
- Been thanked: 62 times
- Contact:
I must be the sh#!@yist programmer know to man. Yet I am determined to code a quality piece for the dreamcast.
Thanks very much to Fragger and OneThirty8 for your input on this problem.
I have combed the forums and found reference to these functions that could be helpful to this cause
fs_mmap function
memcpy function
fs_unlink
I have realized that I can dump all of my textures into a ram folder that I never knew existed before but I cannot for the life of me put the theory's OneThirty8 mentions into practice.
I have since modified my code to load from ram instead of romdisk
but iris cannot seem to locate the file in ram
Even if my lame attempt worked the problem I'm having would still remain
b/c everything would be loaded from ram to the pvr and it would over flow the pvr again hooray.
I even have trouble understanding the kos manual
example: memcpy(dest, pointer, size);
I understand what pointer is but am unsure how to get an accurate size and destination is size determined by 256 x 256 x 2 =131072? or am I totally off. Other things in the manual seem to baffle me like reference to
file_t hnd, const char among others is there a manual to get me up to speed on these terms? I know experienced programmers look at this and probably say don't try but I am too old and too interested to stop now.
I am reposting my source code in hopes someone can shed light on my problem
i am using kos 1.1.9 and referencing the kos 1.1.8 manual
thanks in advance
/*********************************************************
#include "Iris.hpp"
#include "time.h"
//#include "timer.h"
int main(int ac, char **av)
{
// the object to display
//IrisObject psyrax;
//int paddle = 1;
// get the context
IrisContext &c = IrisContext::Get();
c.InitContext(1024 * 1024);
// load Iris Object (must be done after Init)
//psyrax.LoadFromFile("/rd/", "psyrax_x.IMD");
// look for paddle
if (c.GetInputManager().ControllerCount() == 0)
{
printf("no controller found\n");
return (-1);
}
//setup project, viewport and camera(view) matrix
c.GetGeometryPipeline().SetProjection(90.0f, 1, 10000.0f);
c.GetGeometryPipeline().SetViewport(0.0f, 0.0f, 320.0f, 240.0f);
c.GetGeometryPipeline().SetView(vect3d(0.0, 100.0f, 0.0),vect3d(0, 0.0, 1.0f),vect3d(0.0, 1.0, 0.0));
c.GetGeometryPipeline().Update();
// set ambient color
c.GetLightingPipeline().SetAmbientColor(IrisColor(0.7f, 0.7f, 0.7f));
c.GetLightingPipeline().Update();
// get the first paddle in mapple bus
IrisController &p = c.GetInputManager().GetController(0);
IrisController &p2 = c.GetInputManager().GetController(1);
int count = 0;
int pushed_down = 0;
int flag = 1;
void *fs_mmap(file_t hnd);
int *text;
//CHARACTER1 TRANSPARENCY
IrisMaterial *wolverine_material[17];
wolverine_material[0] = c.GetMaterialManager().LoadMaterial("/ram/Wstance1.png",texture_alpha);
wolverine_material[1] = c.GetMaterialManager().LoadMaterial("/ram/Wstance1.png",texture_alpha);
wolverine_material[2] = c.GetMaterialManager().LoadMaterial("/ram/Wstance2.png",texture_alpha);
wolverine_material[3] = c.GetMaterialManager().LoadMaterial("/ram/Wstance3.png",texture_alpha);
wolverine_material[4] = c.GetMaterialManager().LoadMaterial("/ram/Wstance4.png",texture_alpha);
wolverine_material[5] = c.GetMaterialManager().LoadMaterial("/ram/Wstance5.png",texture_alpha);
wolverine_material[6] = c.GetMaterialManager().LoadMaterial("/ram/Wstance6.png",texture_alpha);
wolverine_material[7] = c.GetMaterialManager().LoadMaterial("/ram/Wstance7.png",texture_alpha);
wolverine_material[8] = c.GetMaterialManager().LoadMaterial("/ram/Wstance8.png",texture_alpha);
wolverine_material[9] = c.GetMaterialManager().LoadMaterial("/ram/Wstance9.png",texture_alpha);
wolverine_material[10] = c.GetMaterialManager().LoadMaterial("/ram/Wstance10.png",texture_alpha);
wolverine_material[11] = c.GetMaterialManager().LoadMaterial("/ram/Wstance11.png",texture_alpha);
wolverine_material[12] = c.GetMaterialManager().LoadMaterial("/ram/Wstance12.png",texture_alpha);
wolverine_material[13] = c.GetMaterialManager().LoadMaterial("/ram/Wstance13.png",texture_alpha);
wolverine_material[14] = c.GetMaterialManager().LoadMaterial("/ram/Wstance14.png",texture_alpha);
wolverine_material[15] = c.GetMaterialManager().LoadMaterial("/ram/Wstance15.png",texture_alpha);
wolverine_material[16] = c.GetMaterialManager().LoadMaterial("/ram/Wstance16.png",texture_alpha);
IrisManualObject alpha_object1;
alpha_object1.Allocate(4);
alpha_object1.GetVertex(0) = vect3d(0.0f, 0.0f, 1.0f);
alpha_object1.GetVertex(1) = vect3d(256.0f, 0.0f, 1.0f);
alpha_object1.GetVertex(2) = vect3d(0.0f, 256.0f, 1.0f);
alpha_object1.GetVertex(3) = vect3d(256.0f, 256.0f, 1.0f);
alpha_object1.SetColor(IrisColor(1.0f, 1.0f, 1.0f, 1.0f));
alpha_object1.SetMaterial(wolverine_material[0]);
alpha_object1.SetUV(0, 0.0f, 0.0f);
alpha_object1.SetUV(1, 1.0f, 0.0f);
alpha_object1.SetUV(2, 0.0f, 1.0f);
alpha_object1.SetUV(3, 1.0f, 1.0f);
alpha_object1.Precalculate2D();
//CHARACTER1 TRANSPARENCY
IrisMaterial *wolverine1_material[12];
wolverine1_material[0] = c.GetMaterialManager().LoadMaterial("/ram/Wduck0.png",texture_alpha);
wolverine1_material[1] = c.GetMaterialManager().LoadMaterial("/ram/Wduck1.png",texture_alpha);
wolverine1_material[2] = c.GetMaterialManager().LoadMaterial("/ram/Wduck2.png",texture_alpha);
wolverine1_material[3] = c.GetMaterialManager().LoadMaterial("/ram/Wduck3.png",texture_alpha);
wolverine1_material[4] = c.GetMaterialManager().LoadMaterial("/ram/Wduck4.png",texture_alpha);
wolverine1_material[5] = c.GetMaterialManager().LoadMaterial("/ram/Wduck5.png",texture_alpha);
wolverine1_material[6] = c.GetMaterialManager().LoadMaterial("/ram/Wduck6.png",texture_alpha);
wolverine1_material[7] = c.GetMaterialManager().LoadMaterial("/ram/Wduck7.png",texture_alpha);
wolverine1_material[8] = c.GetMaterialManager().LoadMaterial("/ram/Wduck8.png",texture_alpha);
wolverine1_material[9] = c.GetMaterialManager().LoadMaterial("/ram/Wduck9.png",texture_alpha);
wolverine1_material[10] = c.GetMaterialManager().LoadMaterial("/ram/Wduck10.png",texture_alpha);
wolverine1_material[11] = c.GetMaterialManager().LoadMaterial("/ram/Wduck11.png",texture_alpha);
IrisManualObject alpha_object2;
alpha_object2.Allocate(4);
alpha_object2.GetVertex(0) = vect3d(0.0f, 0.0f, 1.0f);
alpha_object2.GetVertex(1) = vect3d(256.0f, 0.0f, 1.0f);
alpha_object2.GetVertex(2) = vect3d(0.0f, 256.0f, 1.0f);
alpha_object2.GetVertex(3) = vect3d(256.0f, 256.0f, 1.0f);
alpha_object2.SetColor(IrisColor(1.0f, 1.0f, 1.0f, 1.0f));
alpha_object2.SetMaterial(wolverine1_material[0]);
alpha_object2.SetUV(0, 0.0f, 0.0f);
alpha_object2.SetUV(1, 1.0f, 0.0f);
alpha_object2.SetUV(2, 0.0f, 1.0f);
alpha_object2.SetUV(3, 1.0f, 1.0f);
alpha_object2.Precalculate2D();
int stance [55] =
{
1,1,1,
2,2,2,
3,3,3,3,
4,4,4,4,
5,5,5,5,
6,6,6,
7,7,7,7,
8,8,8,
9,9,9,
10,10,10,10,
11,11,11,
12,12,12,12,
13,13,13,
14,14,14,14,
15,15,15,
16,16,16
};
int duck [45] =
{
0,0,0,
1,1,1,1,1,1,
2,2,2,
3,3,3,
4,4,4,
5,5,5,
6,6,6,6,
7,7,7,
8,8,8,
9,9,9,
10,10,10,10,10,
11,11,11,11,11,11
};
//uint32 sec, msec;
//timer_ms_gettime(&sec, &msec);
while (!p. Start() && !p2.Start())
{
timer_spin_sleep(16);
//stance
if (!p.Up() & !p.Down() & !p.Left() & !p.Right() & !p.a() & !p.b() & pushed_down == 0 ){
//printf("\nmill: %f\n\n", msec);
alpha_object1.SetMaterial(wolverine_material[stance[count]]);
count++;
if (count == 55)
count = 0;
}
//stance
//duck
if ( p.Down() & !p.a() & !p.b() ){
if (pushed_down == 0){
count = 0;
pushed_down = 1;
}
alpha_object2.SetMaterial(wolverine1_material[duck[count]]);
//pvr_mem_free(back_tex);
count++;
printf("\ncount: %f\n\n", count);
if (count == 35)
count = 13;
}
//*come up from duck
if ( !p.Down() & !p.a() & !p.b() & pushed_down == 1){
if (flag == 1){
count = 35;
flag = 0;
}
alpha_object2.SetMaterial(wolverine1_material[duck[count]]);
count++;
if (count == 45)
pushed_down = 0;
}
//duck
c.BeginScene();
c.BeginBlending();
c.SetBlendSrc(BT_SRC_ALPHA);
c.SetBlendDst(BT_ONE);
//alpha_object1.SetColor(IrisColor(1.0f, 1.0f, 1.0f, 1));
//c.SetDepthWrite(false);
if (pushed_down == 1)
alpha_object2.Render2D();
else
alpha_object1.Render2D();
//c.SetDepthWrite(true);
c.EndScene();
}
return (0);
}
Thanks very much to Fragger and OneThirty8 for your input on this problem.
I have combed the forums and found reference to these functions that could be helpful to this cause
fs_mmap function
memcpy function
fs_unlink
I have realized that I can dump all of my textures into a ram folder that I never knew existed before but I cannot for the life of me put the theory's OneThirty8 mentions into practice.
I have since modified my code to load from ram instead of romdisk
but iris cannot seem to locate the file in ram
Even if my lame attempt worked the problem I'm having would still remain
b/c everything would be loaded from ram to the pvr and it would over flow the pvr again hooray.
I even have trouble understanding the kos manual
example: memcpy(dest, pointer, size);
I understand what pointer is but am unsure how to get an accurate size and destination is size determined by 256 x 256 x 2 =131072? or am I totally off. Other things in the manual seem to baffle me like reference to
file_t hnd, const char among others is there a manual to get me up to speed on these terms? I know experienced programmers look at this and probably say don't try but I am too old and too interested to stop now.
I am reposting my source code in hopes someone can shed light on my problem
i am using kos 1.1.9 and referencing the kos 1.1.8 manual
thanks in advance
/*********************************************************
#include "Iris.hpp"
#include "time.h"
//#include "timer.h"
int main(int ac, char **av)
{
// the object to display
//IrisObject psyrax;
//int paddle = 1;
// get the context
IrisContext &c = IrisContext::Get();
c.InitContext(1024 * 1024);
// load Iris Object (must be done after Init)
//psyrax.LoadFromFile("/rd/", "psyrax_x.IMD");
// look for paddle
if (c.GetInputManager().ControllerCount() == 0)
{
printf("no controller found\n");
return (-1);
}
//setup project, viewport and camera(view) matrix
c.GetGeometryPipeline().SetProjection(90.0f, 1, 10000.0f);
c.GetGeometryPipeline().SetViewport(0.0f, 0.0f, 320.0f, 240.0f);
c.GetGeometryPipeline().SetView(vect3d(0.0, 100.0f, 0.0),vect3d(0, 0.0, 1.0f),vect3d(0.0, 1.0, 0.0));
c.GetGeometryPipeline().Update();
// set ambient color
c.GetLightingPipeline().SetAmbientColor(IrisColor(0.7f, 0.7f, 0.7f));
c.GetLightingPipeline().Update();
// get the first paddle in mapple bus
IrisController &p = c.GetInputManager().GetController(0);
IrisController &p2 = c.GetInputManager().GetController(1);
int count = 0;
int pushed_down = 0;
int flag = 1;
void *fs_mmap(file_t hnd);
int *text;
//CHARACTER1 TRANSPARENCY
IrisMaterial *wolverine_material[17];
wolverine_material[0] = c.GetMaterialManager().LoadMaterial("/ram/Wstance1.png",texture_alpha);
wolverine_material[1] = c.GetMaterialManager().LoadMaterial("/ram/Wstance1.png",texture_alpha);
wolverine_material[2] = c.GetMaterialManager().LoadMaterial("/ram/Wstance2.png",texture_alpha);
wolverine_material[3] = c.GetMaterialManager().LoadMaterial("/ram/Wstance3.png",texture_alpha);
wolverine_material[4] = c.GetMaterialManager().LoadMaterial("/ram/Wstance4.png",texture_alpha);
wolverine_material[5] = c.GetMaterialManager().LoadMaterial("/ram/Wstance5.png",texture_alpha);
wolverine_material[6] = c.GetMaterialManager().LoadMaterial("/ram/Wstance6.png",texture_alpha);
wolverine_material[7] = c.GetMaterialManager().LoadMaterial("/ram/Wstance7.png",texture_alpha);
wolverine_material[8] = c.GetMaterialManager().LoadMaterial("/ram/Wstance8.png",texture_alpha);
wolverine_material[9] = c.GetMaterialManager().LoadMaterial("/ram/Wstance9.png",texture_alpha);
wolverine_material[10] = c.GetMaterialManager().LoadMaterial("/ram/Wstance10.png",texture_alpha);
wolverine_material[11] = c.GetMaterialManager().LoadMaterial("/ram/Wstance11.png",texture_alpha);
wolverine_material[12] = c.GetMaterialManager().LoadMaterial("/ram/Wstance12.png",texture_alpha);
wolverine_material[13] = c.GetMaterialManager().LoadMaterial("/ram/Wstance13.png",texture_alpha);
wolverine_material[14] = c.GetMaterialManager().LoadMaterial("/ram/Wstance14.png",texture_alpha);
wolverine_material[15] = c.GetMaterialManager().LoadMaterial("/ram/Wstance15.png",texture_alpha);
wolverine_material[16] = c.GetMaterialManager().LoadMaterial("/ram/Wstance16.png",texture_alpha);
IrisManualObject alpha_object1;
alpha_object1.Allocate(4);
alpha_object1.GetVertex(0) = vect3d(0.0f, 0.0f, 1.0f);
alpha_object1.GetVertex(1) = vect3d(256.0f, 0.0f, 1.0f);
alpha_object1.GetVertex(2) = vect3d(0.0f, 256.0f, 1.0f);
alpha_object1.GetVertex(3) = vect3d(256.0f, 256.0f, 1.0f);
alpha_object1.SetColor(IrisColor(1.0f, 1.0f, 1.0f, 1.0f));
alpha_object1.SetMaterial(wolverine_material[0]);
alpha_object1.SetUV(0, 0.0f, 0.0f);
alpha_object1.SetUV(1, 1.0f, 0.0f);
alpha_object1.SetUV(2, 0.0f, 1.0f);
alpha_object1.SetUV(3, 1.0f, 1.0f);
alpha_object1.Precalculate2D();
//CHARACTER1 TRANSPARENCY
IrisMaterial *wolverine1_material[12];
wolverine1_material[0] = c.GetMaterialManager().LoadMaterial("/ram/Wduck0.png",texture_alpha);
wolverine1_material[1] = c.GetMaterialManager().LoadMaterial("/ram/Wduck1.png",texture_alpha);
wolverine1_material[2] = c.GetMaterialManager().LoadMaterial("/ram/Wduck2.png",texture_alpha);
wolverine1_material[3] = c.GetMaterialManager().LoadMaterial("/ram/Wduck3.png",texture_alpha);
wolverine1_material[4] = c.GetMaterialManager().LoadMaterial("/ram/Wduck4.png",texture_alpha);
wolverine1_material[5] = c.GetMaterialManager().LoadMaterial("/ram/Wduck5.png",texture_alpha);
wolverine1_material[6] = c.GetMaterialManager().LoadMaterial("/ram/Wduck6.png",texture_alpha);
wolverine1_material[7] = c.GetMaterialManager().LoadMaterial("/ram/Wduck7.png",texture_alpha);
wolverine1_material[8] = c.GetMaterialManager().LoadMaterial("/ram/Wduck8.png",texture_alpha);
wolverine1_material[9] = c.GetMaterialManager().LoadMaterial("/ram/Wduck9.png",texture_alpha);
wolverine1_material[10] = c.GetMaterialManager().LoadMaterial("/ram/Wduck10.png",texture_alpha);
wolverine1_material[11] = c.GetMaterialManager().LoadMaterial("/ram/Wduck11.png",texture_alpha);
IrisManualObject alpha_object2;
alpha_object2.Allocate(4);
alpha_object2.GetVertex(0) = vect3d(0.0f, 0.0f, 1.0f);
alpha_object2.GetVertex(1) = vect3d(256.0f, 0.0f, 1.0f);
alpha_object2.GetVertex(2) = vect3d(0.0f, 256.0f, 1.0f);
alpha_object2.GetVertex(3) = vect3d(256.0f, 256.0f, 1.0f);
alpha_object2.SetColor(IrisColor(1.0f, 1.0f, 1.0f, 1.0f));
alpha_object2.SetMaterial(wolverine1_material[0]);
alpha_object2.SetUV(0, 0.0f, 0.0f);
alpha_object2.SetUV(1, 1.0f, 0.0f);
alpha_object2.SetUV(2, 0.0f, 1.0f);
alpha_object2.SetUV(3, 1.0f, 1.0f);
alpha_object2.Precalculate2D();
int stance [55] =
{
1,1,1,
2,2,2,
3,3,3,3,
4,4,4,4,
5,5,5,5,
6,6,6,
7,7,7,7,
8,8,8,
9,9,9,
10,10,10,10,
11,11,11,
12,12,12,12,
13,13,13,
14,14,14,14,
15,15,15,
16,16,16
};
int duck [45] =
{
0,0,0,
1,1,1,1,1,1,
2,2,2,
3,3,3,
4,4,4,
5,5,5,
6,6,6,6,
7,7,7,
8,8,8,
9,9,9,
10,10,10,10,10,
11,11,11,11,11,11
};
//uint32 sec, msec;
//timer_ms_gettime(&sec, &msec);
while (!p. Start() && !p2.Start())
{
timer_spin_sleep(16);
//stance
if (!p.Up() & !p.Down() & !p.Left() & !p.Right() & !p.a() & !p.b() & pushed_down == 0 ){
//printf("\nmill: %f\n\n", msec);
alpha_object1.SetMaterial(wolverine_material[stance[count]]);
count++;
if (count == 55)
count = 0;
}
//stance
//duck
if ( p.Down() & !p.a() & !p.b() ){
if (pushed_down == 0){
count = 0;
pushed_down = 1;
}
alpha_object2.SetMaterial(wolverine1_material[duck[count]]);
//pvr_mem_free(back_tex);
count++;
printf("\ncount: %f\n\n", count);
if (count == 35)
count = 13;
}
//*come up from duck
if ( !p.Down() & !p.a() & !p.b() & pushed_down == 1){
if (flag == 1){
count = 35;
flag = 0;
}
alpha_object2.SetMaterial(wolverine1_material[duck[count]]);
count++;
if (count == 45)
pushed_down = 0;
}
//duck
c.BeginScene();
c.BeginBlending();
c.SetBlendSrc(BT_SRC_ALPHA);
c.SetBlendDst(BT_ONE);
//alpha_object1.SetColor(IrisColor(1.0f, 1.0f, 1.0f, 1));
//c.SetDepthWrite(false);
if (pushed_down == 1)
alpha_object2.Render2D();
else
alpha_object1.Render2D();
//c.SetDepthWrite(true);
c.EndScene();
}
return (0);
}