Terrain rendering

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
Grover
Posts: 50
Joined: Wed Feb 23, 2005 3:13 am

Terrain rendering

Post by Grover »

This is my first effort on PSP .. and after 10 hrs.. I must say this little device is damn sweet.

Image

Im using alot of nems gear, and will post all the source with some minor additions (like a sin/cos and few other bits). Also I have made a simple windows output too - so you can test on windows before making an EBOOT.PBP. Will post this in the next day or so, once I have clean it up a bit :-)

Heres the EBOOT.PBP.. controls are actually on the triangle, cross, square and circle, for forwards, back, left and right. Cheers..

http://users.on.net/~dlannan//Files/PSP/Terrain.zip
Bye.
ace11
Posts: 3
Joined: Thu May 12, 2005 3:57 pm

Re: Terrain rendering

Post by ace11 »

WoW! Great work!
User avatar
Thanhda
Posts: 331
Joined: Sat Apr 09, 2005 2:08 am
Location: Canada
Contact:

Post by Thanhda »

nice work, too bad dont have psp1.0. too bad doesnt work on pspe
Last edited by Thanhda on Mon May 16, 2005 3:32 pm, edited 1 time in total.
There are 10 types of people in the world: Those who understand binary, and those who don't...
Grover
Posts: 50
Joined: Wed Feb 23, 2005 3:13 am

Post by Grover »

Heres the source.. it wasnt _that_ bad :-) ..

Also I must send thanks to Nem and the original writer of glvox.. Andrea. Theres alot of their code that did this.. I just tied it together :-) .. Also in the TerrainSrc.zip I have included a simple image convertor. Converts almost any standard windows image type to unsigned short data array.. (JPGs, PNG, BMP, TGA.. etc etc).
Usage: ConvImage <image file> <target name>
Target name gets attached to the word Data. So then you can ref the image in your code easily.

Also included in the source, for people who want to do some dev (with Nems PG lib only!!) you can run the code on windows and see it runnning without a V1.0 PSP. Its just a simple blit .. but useful for quick dev. I expect most of Nems other source should work with this.. once the sce functions are complete - let those with V1.5 out there do some sort of dev too..

http://users.on.net/~dlannan//Files/PSP/TerrainSrc.zip

I havent filled out many sce functions yet.. but should have most done in a day or so, including audio and threads..
Bye.
User avatar
Drakonite
Site Admin
Posts: 990
Joined: Sat Jan 17, 2004 1:30 am
Contact:

Post by Drakonite »

Screenshot looks nifty but please keep release announcements in the general forum. Thanks.
Shoot Pixels Not People!
Makeshift Development
Shito
Posts: 21
Joined: Wed May 11, 2005 1:38 am

Post by Shito »

Well, the guy also posted the sources after all.
And with an image convertor that could be quite handy to anyone wanting to code a little bit. Ok by now we all have developped our own ways of converting a bitmap or whatever image into a c file for the weird BGR PSP format, but I sure know mine is not as handy as this simple exe, and I'll be giving it a try as soon as I get home.

So I vote let him live. :)
Grover
Posts: 50
Joined: Wed Feb 23, 2005 3:13 am

Post by Grover »

Soz Drakonite - I never look at general discussions cos I thought it perm locked :-) .. good to see it back! :-)

BTW the sources has an emul of sorts to play with too - so people without v1.0 PSPs can dev.. and see what ppl are making.
Last edited by Grover on Wed May 18, 2005 2:41 am, edited 1 time in total.
Bye.
Grover
Posts: 50
Joined: Wed Feb 23, 2005 3:13 am

Post by Grover »

I found lots of bugs in ImageConv.. sorry to those who tried it. I really dont know how I got any usable data!!! Anyhow.. its all fixed now, and I am providing the source so you can see how simple it actually is to do :-)
http://users.on.net/~dlannan//Files/PSP/ConvImage16.zip

Also I have fixed a fair bit in the Windows emul part of the code, along with the BGR thing. It may run a bit slow depending on your processor. Also fixed up alot of very silly coding errors..
http://users.on.net/~dlannan//Files/PSP/TerrainSrc2.zip

Finally heres a screeny of the Windows PC Emul.. and it actaully looks like this on PSP now :-)
Image

And on PSP..
Image

hopefully game demo following soon.. :-)

Also, those who build the terrain source will need to add a sky map.. at the moment it doesnt move.. but anything > 480x150 would work fine.

Cheers..
Bye.
annerajb
Posts: 40
Joined: Thu Mar 31, 2005 6:16 am

Post by annerajb »

i have to make the sky.c but how do i do it
and how can i add custom heightmaps what tool do i need?
Grover
Posts: 50
Joined: Wed Feb 23, 2005 3:13 am

Post by Grover »

hi. to make a sky.c use:
ConvImage <image name> Sky
there should be a working ConvImage.exe in the Src zip.

As for heightfiled, it currently uses a simple perlin noise function to build it:
ComputeMap() does this.
To place your own heightmap, simply dont call ComputeMap(). And set the array HMap to a list of height values (0->255).

Many things can be modified to change the way the height map is made/used. And at the moment the height map is a 256x256 map, this also is easily modified.
Bye.
annerajb
Posts: 40
Joined: Thu Mar 31, 2005 6:16 am

Post by annerajb »

if it isn to much trouble to you grover could you edit for me the glvox.c
computemap and change it so the terrain is all flat.
and how can i change the camera angles so it aims higher or lower.
thx for your help
Grover
Posts: 50
Joined: Wed Feb 23, 2005 3:13 am

Post by Grover »

Replace your xmain in glvox with this.
Also make a RED 256x256 pixel height map. Convert it with ConvImage using this:
ConvImage16.exe <your red image> HeightMap

Full red represents highest point, black represents lowest.. and shade in between.. is.. erm.. inbetween :-)


Also at the top of the glvox file add the line:

Code: Select all

#include "HeightMap.c"
The following is the xmain replacement.

Code: Select all

// *******************************************************************

int xmain&#40; void &#41;
&#123;
	static char flipper = 1;
	int x, y;
    //
    // Main loop
    //
    //   a     = angle
    //   x0,y0 = current position
    //   s     = speed constant
    //   ss    = current forward/backward speed
    //   sa    = angular speed
    //
    gl_a=0;
	gl_x0=0x0;
	gl_y0=0x0;
    gl_s=4096;
    gl_ss=100.0f;
    gl_sa=0;

    //
    // Compute the height map
    //

	// Uncomment this to have a perlin noise generated heightmap
//	ComputeMap&#40;&#41;;

	// Copy in a heightmap into the HMap array
	for&#40;y=0; y<256; y++&#41;
	&#123;
		for&#40;x=0; x<256; x++&#41;
		&#123;
			HMap&#91;x + y * 256&#93; = HeightMapData&#91;x + y * 256&#93;;
		&#125;
	&#125;
	calc_light&#40;0,0,255,255&#41;;

	pgcPuts&#40;"Loading..."&#41;;
	
	while&#40;app_running&#41;
	&#123;
		Video = pgGetVramAddr&#40;0,0&#41;;
		pgScreenFrame&#40;2,flipper&#41;;

//		pgcCls&#40;&#41;;
		// Rather than a screen clear, render half of the screen as a background
		pgBitBlt&#40;0, 0, 1694, 150, 1, SkyData, 1&#41;;

		flipper = 1-flipper;
		glvox_main&#40;&#41;;
		input_key&#40;&#41;;
		pgScreenFlipV&#40;&#41;;
	&#125;

	pgScreenFrame&#40;1,0&#41;;
	pgcCls&#40;&#41;;

	return 0;
&#125;

// *******************************************************************

Bye.
annerajb
Posts: 40
Joined: Thu Mar 31, 2005 6:16 am

Post by annerajb »

thx now i am adding a menu screen but how can i make the the apps change from MenuInput (); to input_key();
right now what it does is continue running MenuInput ();
and does not run input_key()

Code: Select all

// *******************************************************************
// 
// This is a port of a classic old voxel terrain renderer. Andrea kindly
// released his code back in 2000 so here it is again but on PSP!!!
//
// The other person that needs thanking is Nem - your hello world, sound
// and pg lib made there way here, I hope thats ok? &#58;-&#41;
//
// The rest of it is written by Grover.. for anyone to use, and abuse.
// The windows rendering is incomplete and only a few sce functions have
// been emulated - its an ongoing thing, so it will get filled out in the
// next week or so...
//								Grover - May 2005.
//								[email protected]
//

// *******************************************************************
// Credits for Original Glvox writer -  Andrea "6502" Griffini, programmer
//                                             [email protected]
//                                         http&#58;//vv.val.net/~agriffini
//
// *******************************************************************

#include "syscall.h"
#include "pg.h"
#include "_clib.h"

// *******************************************************************
// Not yet used.. yet..
#include "HeightMap.c"
#include "Sky.c"
//#include "Pause.c"
//#include "Water1.c"

// *******************************************************************

#ifdef WIN32
#include "win32_psp.h"
#endif

// *******************************************************************

#define PIXELSKIP		4

#define CLOCKS_PER_SEC	1000000

float FOV=3.141592654/4;   // half of the xy field of view

// *******************************************************************

#define BUFFER_WIDTH    &#40;&#40;512/PIXELSKIP&#41;+1&#41;
#define BUFFER_HEIGHT   271

// *******************************************************************
// These dont seem to hurt the ps2 compiler.. 

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>

// *******************************************************************

typedef unsigned char byte;

#define MAP_W		256
#define MAP_H		256
#define MAP_MASK	0xFFFF

// *******************************************************************

unsigned char app_running = 1;

//unsigned short *HMap = &#40;unsigned short *&#41;Water1Data;						// Height field

unsigned char HMap&#91;MAP_W*MAP_H&#93;;						// Color map
unsigned char CMap&#91;MAP_W*MAP_H&#93;;						// Color map
unsigned char LMap&#91;MAP_W*MAP_H&#93;;

unsigned short *Video;
// unsigned char Video&#91;BUFFER_WIDTH * BUFFER_HEIGHT&#93;;		// Off-screen buffer

static float gl_ss, gl_sa, gl_a, gl_s;
static int gl_x0, gl_y0;

// *******************************************************************
//
// Reduces a value to 0..255 &#40;used in height field computation&#41;
//
int Clamp&#40;int x&#41;
&#123;
  return &#40;x<0 ? 0 &#58; &#40;x>255 ? 255 &#58; x&#41;&#41;;
&#125;

// *******************************************************************

static void calc_light&#40; int x1, int y1, int x2, int y2 &#41;
&#123;
  int i, j, k, c, z ;
  int max=0;
  float norm;
  float t;

  for&#40;z = 0; z < 256 * 256; z++&#41;
	  LMap&#91;z&#93; = 0;

//for&#40; k = 2 ; k >= 1; k -- &#41;
  for&#40; c = 0 ; c < 2 ; c ++ &#41;
  &#123;
    for&#40; i = y1 ; i <= y2 ; i ++ &#41;
    &#123;
      for&#40; j = x1 ; j <= x2 ; j ++ &#41;
      &#123;
        int h00 = HMap&#91; &#40;&#40;i-1&#41; * MAP_W + &#40;j-1&#41;&#41; & MAP_MASK &#93;;
        int h01 = HMap&#91; &#40;&#40;i-1&#41; * MAP_W + &#40;j+1&#41;&#41; & MAP_MASK &#93;;
        int h10 = HMap&#91; &#40;&#40;i+1&#41; * MAP_W + &#40;j-1&#41;&#41; & MAP_MASK &#93;;
        int h11 = HMap&#91; &#40;&#40;i+1&#41; * MAP_W + &#40;j+1&#41;&#41; & MAP_MASK &#93;;
        int dx  = h11 - h00 ;
        int dy  = h10 - h01 ;
        int d   = dx * dx + dy * dy ;

        if&#40; c == 0 &#41;
        &#123;
           if&#40; max < d &#41; max = d;
        &#125; else
        &#123;
//           t = &#40;float&#41;sqrtu&#40;d&#41; * norm * 0.5f;
           t = &#40;float&#41;sqrtu&#40;d&#41; * norm;
//		   t -= 2.0f;
		   t *= 0.5f;
		   // Some evil replacements until I find a solution for the gcc c.lt.s problem
           if&#40; &#40;*&#40;unsigned int *&#41;&t&#41; & 0x80000000 &#41; t = 0.0f;
//           if&#40; t < 0.0f &#41; t = 0.0f;
           if&#40; &#40;&#40;int &#41;t&#41; > 255&#41; t = 255.0f;
//           if&#40; t > 255.0f &#41; t = 255.0f;
           LMap&#91; &#40;i * MAP_W + j&#41; & MAP_MASK &#93; = &#40;&#40;int&#41;t&#41;;
           LMap&#91; &#40;i * MAP_W + j&#41; & MAP_MASK &#93; ^= 0xFF;
        &#125;
      &#125;
	  norm = 512.0f / &#40;float&#41;sqrtu&#40;max&#41;;
    &#125;
  &#125;
&#125;

// *******************************************************************
//
// Heightfield and colormap computation
//
void MakeMap1&#40;void&#41;
&#123;
  int x,y,p,i,j,k,k2,p2;

  //
  // Start from a plasma clouds fractal
  //
  for&#40;y=0; y<256; y++&#41;
   &#123;
      for&#40;x=0; x<256; x++&#41;
      &#123;
        HMap&#91;x + y * 256&#93; = HeightMapData1&#91;x + y * 256&#93;;
      &#125;
   &#125;
  calc_light&#40;0,0,255,255&#41;;// all terrain black if uncommented
  //
  // Color computation &#40;derivative of the height field&#41;
  //
  /*for &#40; i=0; i<256*256; i+=256 &#41;
    for &#40; j=0; j<256; j++ &#41;
    &#123;
      k=128+&#40;HMap&#91;&#40;&#40;i+256&#41;&0xFF00&#41;+&#40;&#40;j+1&#41;&255&#41;&#93;-HMap&#91;i+j&#93;&#41;*4;
      if &#40; k<0 &#41; k=0; if &#40;k>255&#41; k=255;
      CMap&#91;i+j&#93;=k;
    &#125;
	
	calc_light&#40;0,0,255,255&#41;;
  //
  // Smoothing
  //
    for &#40; i=0; i<256*256; i+=256 &#41;
      for &#40; j=0; j<256; j++ &#41;
      &#123;
        HMap&#91;i+j&#93;=&#40;HMap&#91;&#40;&#40;i+256&#41;&0xFF00&#41;+j&#93;+HMap&#91;i+&#40;&#40;j+1&#41;&0xFF&#41;&#93;+
                   HMap&#91;&#40;&#40;i-256&#41;&0xFF00&#41;+j&#93;+HMap&#91;i+&#40;&#40;j-1&#41;&0xFF&#41;&#93;&#41;>>2;
      &#125;*/
&#125;

// *******************************************************************

int lasty&#91;BUFFER_WIDTH&#93;,         // Last pixel drawn on a given column
    lastc&#91;BUFFER_WIDTH&#93;;         // Color of last pixel on a column
    lastx0&#91;BUFFER_WIDTH&#93;;         // Color of last pixel on a column
    lasty0&#91;BUFFER_WIDTH&#93;;         // Color of last pixel on a column
	lastl&#91;BUFFER_WIDTH&#93;;

//
// Draw a "section" of the landscape; x0,y0 and x1,y1 and the xy coordinates
// on the height field, hy is the viewpoint height, s is the scaling factor
// for the distance. x0,y0,x1,y1 are 16.16 fixed point numbers and the
// scaling factor is a 16.8 fixed point value.
//
void Line&#40;int x0,int y0,int x1,int y1,int hy,int s,int depth&#41;
&#123;
	int	state = 0;
  int i,sx,sy;
  int hys=hy*s;

  // Compute xy speed
  sx=&#40;x1-x0&#41;/BUFFER_WIDTH; sy=&#40;y1-y0&#41;/BUFFER_WIDTH;
  for &#40; i=0; i<BUFFER_WIDTH-PIXELSIZE; i++ &#41;
  &#123;
    int l,c,y,h,u0,v0,u1,v1,a,b,h0,h1,h2,h3;

    //
    // Compute the xy coordinates; a and b will be the position inside the
    // single map cell &#40;0..255&#41;.
    //
    u0=&#40;x0>>16&#41;&0xFF;    a=&#40;x0>>8&#41;&255;
    v0=&#40;&#40;y0>>8&#41;&0xFF00&#41;; b=&#40;y0>>8&#41;&255;
    u1=&#40;u0+1&#41;&0xFF;
    v1=&#40;v0+256&#41;&0xFF00;

    //
    // Fetch the height at the four corners of the square the point is in
    //
    h0=HMap&#91;u0+v0&#93;; h2=HMap&#91;u0+v1&#93;;
    h1=HMap&#91;u1+v0&#93;; h3=HMap&#91;u1+v1&#93;;
    h0=&#40;h0<<8&#41;+a*&#40;h1-h0&#41;;
    h2=&#40;h2<<8&#41;+a*&#40;h3-h2&#41;;
    h= &#40;h0<<8&#41;+b*&#40;h2-h0&#41;;

    //
    // Fetch the color at the four corners of the square the point is in
    //
    h0=LMap&#91;u0+v0&#93;; h2=LMap&#91;u0+v1&#93;;
    h1=LMap&#91;u1+v0&#93;; h3=LMap&#91;u1+v1&#93;;
    h0=&#40;h0<<8&#41;+a*&#40;h1-h0&#41;;
    h2=&#40;h2<<8&#41;+a*&#40;h3-h2&#41;;
    l=&#40;&#40;h0<<8&#41;+b*&#40;h2-h0&#41;&#41;;


    //
    // Compute screen height using the scaling factor
    //
	y=&#40;h/256.0f&#41;*&#40;s/256.0f&#41;;
	y-=hys;
	y>>=11;
	y+=BUFFER_HEIGHT/2;

    //
    // Draw the column
    //
    if &#40; y<&#40;a=lasty&#91;i&#93;&#41; && y > 0 &#41;
    &#123;
		int ubl= l;
		int lastubl= lastl&#91;i&#93;;
		int lastlastubl = lastl&#91;i-1&#93;;
		int ubstep;
		int sc,cc;

		int endy = BUFFER_HEIGHT;
		if&#40;lasty&#91;i&#93;<BUFFER_HEIGHT&#41;
			endy = lasty&#91;i&#93;;
		ubstep = &#40;&#40;&#40;lastubl - ubl&#41;&#41; / &#40;endy-y&#41;&#41; ;

		for&#40;a = y; &#40;a<lasty&#91;i&#93;&#41; && &#40;a < BUFFER_HEIGHT&#41;; a++&#41;
		&#123;
			unsigned short *Vptr = &Video&#91;i*PIXELSKIP + a * 512&#93;;
			unsigned short Val = &#40;&#40;ubl & 0x7fffffff&#41; >> 16&#41;;// & 0x001f | 0x0e0 | 0x7c00;
			Val = &#40;&#40;Val >> 3&#41; & 0x1f&#41; | &#40;&#40;&#40;Val >> 3&#41; & 0x1f&#41; << 10&#41; | &#40;&#40;&#40;Val >> 3&#41; & 0x1f&#41; << 5&#41;;
			cc = PIXELSKIP;

			while&#40;cc--&#41;
				*Vptr++ = Val;
            
			ubl +=ubstep;
		&#125;
		lasty&#91;i&#93;=y;
    &#125;

	lastx0&#91;i&#93;=x0;
	lasty0&#91;i&#93;=y0;
    lastc&#91;i&#93;=c;
	lastl&#91;i&#93;=l;

    //
    // Advance to next xy position
    //
    x0+=sx; y0+=sy;
  &#125;
&#125;

// *******************************************************************
//
// Draw the view from the point x0,y0 &#40;16.16&#41; looking at angle a
//
void View&#40;int x0,int y0,float aa&#41;
&#123;
  int d,p;
  int a,b,h,u0,v0,u1,v1,h0,h1,h2,h3;

  int p1, p2, p3, p4;

  for &#40; d=0; d<BUFFER_WIDTH; d++ &#41;
  &#123;
    lasty&#91;d&#93;=BUFFER_HEIGHT;
    lastc&#91;d&#93;=-1;
    lastx0&#91;d&#93;=0;
    lasty0&#91;d&#93;=0;
  &#125;

  u0=&#40;x0>>16&#41;&0xFF;    a=&#40;x0>>8&#41;&255;
  v0=&#40;&#40;y0>>8&#41;&0xFF00&#41;; b=&#40;y0>>8&#41;&255;
  u1=&#40;u0+1&#41;&0xFF;
  v1=&#40;v0+256&#41;&0xFF00;

  h0=HMap&#91;u0+v0&#93;; h2=HMap&#91;u0+v1&#93;;
  h1=HMap&#91;u1+v0&#93;; h3=HMap&#91;u1+v1&#93;;
  h0=&#40;h0<<8&#41;+a*&#40;h1-h0&#41;;
  h2=&#40;h2<<8&#41;+a*&#40;h3-h2&#41;;
  h=&#40;&#40;h0<<8&#41;+b*&#40;h2-h0&#41;&#41;>>16;

  p=0;
  for &#40; d=0; d<500; d+=1+&#40;d>>6&#41;&#41;
  &#123;

    p1 = &#40;int&#41;&#40;&#40;float&#41;x0+&#40;float&#41;d*65535.0f*fcos&#40;aa-FOV&#41;&#41; ;//<< 16;
	p2 = &#40;int&#41;&#40;&#40;float&#41;y0+&#40;float&#41;d*65535.0f*fsin&#40;aa-FOV&#41;&#41; ;//<< 16;
	p3 = &#40;int&#41;&#40;&#40;float&#41;x0+&#40;float&#41;d*65535.0f*fcos&#40;aa+FOV&#41;&#41; ;//<< 16;
	p4 = &#40;int&#41;&#40;&#40;float&#41;y0+&#40;float&#41;d*65535.0f*fsin&#40;aa+FOV&#41;&#41; ;//<< 16;
    Line&#40;p1,p2,p3,p4,
         h-30,BUFFER_HEIGHT*128/&#40;d+1&#41;,d &#41;;
  &#125;
&#125;

// *******************************************************************
void IngameMenuInput&#40; void &#41;//aqui van lo q hace cada booton en el menu ingame

	&#123;
	static unsigned long pad,pad1,lastpad;
	pad1=pgiGetpad&#40;&#41;;
		
	if &#40;&#40;pad1&CTRL_START&#41;!=0&#41; &#123;
		//;//	sesupone q corra makemap1
	&#125;
	lastpad=pad;
&#125;

// *******************************************************************
void InGameMenu&#40; void &#41;
	&#123;
	pgcPuts&#40;"Pause"&#41;;
	pgScreenFrame&#40;1,0&#41;;
	//pgBitBlt&#40;0, 0, 1694, 272, 1, Pause, 1&#41;;// Rather than a screen clear, render half of the screen as a background
	IngameMenuInput&#40;&#41;;
	pgScreenFrame&#40;1,0&#41;;
	&#125;
// *******************************************************************
void input_key&#40; void &#41;
&#123;
	static unsigned long pad,pad1,lastpad;
	pad1=pgiGetpad&#40;&#41;;
		
	if &#40;&#40;pad1&CTRL_START&#41;!=0&#41; &#123;//MENU
		gl_ss = 0;
		gl_sa = 0;
		InGameMenu;// pause screen
	&#125;
	if &#40;&#40;pad1&CTRL_SELECT&#41;!=0&#41; &#123;//jump now stop
		gl_ss = 0;
	&#125;
	if &#40;&#40;pad1&CTRL_LEFT &#41;!=0&#41; &#123;//left changed the CTRL_CIRCLE to CTRL_LEFT 
		gl_sa += 0.005f;
	&#125;
	if &#40;&#40;pad1&CTRL_RIGHT&#41;!=0&#41; &#123;//right changed the CTRL_SQUARE to CTRL_RIGHT
		gl_sa -= 0.005f;
	&#125;
	if &#40;&#40;pad1&CTRL_TRIANGLE&#41;!=0&#41; &#123;
	    gl_ss = gl_s;//up modified original should have +=
		
	&#125;
	if &#40;&#40;pad1&CTRL_CROSS&#41;!=0&#41; &#123;
		gl_ss -= gl_s;//problem if you remove -  dosnt stop
	&#125;
	lastpad=pad;
&#125;

// *******************************************************************


void Run&#40; void &#41;
	&#123;
	
	pgScreenFrame&#40;1,0&#41;;
	MakeMap1&#40;&#41;; 
	pgBitBlt&#40;0, 0, 1694, 150, 1, SkyData, 1&#41;;// Rather than a screen clear, render half of the screen as a background
		
	&#125;
// *******************************************************************

void MenuInput&#40; void &#41;
	&#123;
	static unsigned long pad,pad1,lastpad;
	pad1=pgiGetpad&#40;&#41;;
	
	if &#40;&#40;pad1&CTRL_CROSS&#41;!=0&#41; &#123;
		
		pgcPuts&#40;"Running"&#41;;
		Run&#40;&#41;;//	sesupone q corra makemap1
		
	&#125;
	lastpad=pad;
	
&#125;

// *******************************************************************
	

void glvox_main&#40; void &#41;
&#123;
		View&#40;gl_x0,gl_y0,gl_a&#41;;

		//
		// Update position/angle
		//
		gl_x0+=gl_ss*fcos&#40;gl_a&#41;;
		gl_y0+=gl_ss*fsin&#40;gl_a&#41;;
		gl_a+=gl_sa;
		gl_sa*=0.975f;
&#125;

// *******************************************************************


int xmain&#40; void &#41;
&#123;
   static char flipper = 1;
   
    //
    // Main loop
    //
    //   a     = angle
    //   x0,y0 = current position
    //   s     = speed constant
    //   ss    = current forward/backward speed
    //   sa    = angular speed
    //
    gl_a=0;
   gl_x0=0x0;
   gl_y0=0x0;
    gl_s=4096;
    gl_ss=100.0f;
    gl_sa=0;

    //
    // Compute the height map
	
   // Uncomment this to have a perlin noise generated heightmap
	

   // Copy in a heightmap into the HMap array
   
   

   
   
   while&#40;app_running&#41;
   &#123;
      Video = pgGetVramAddr&#40;0,0&#41;;
      pgScreenFrame&#40;2,flipper&#41;;

      pgcCls&#40;&#41;;
		pgcPuts&#40;"Menu"&#41;;
		MenuInput&#40;&#41;;//this are menu screen controls i have problems here how can i change the input from MenuInput &#40;&#41;; to input_key&#40;&#41;;
		flipper = 1-flipper;
      glvox_main&#40;&#41;;
      
	  
      pgScreenFlipV&#40;&#41;;
   &#125;

   pgScreenFrame&#40;1,0&#41;;
   pgcCls&#40;&#41;;

   return 0;
&#125; 

// *******************************************************************

skippy911
Posts: 46
Joined: Fri May 06, 2005 10:20 am

Post by skippy911 »

Grover can you post a binary of your emu I cant get it to compile :(
Grover
Posts: 50
Joined: Wed Feb 23, 2005 3:13 am

Post by Grover »

No probs.. but erm.. it will be just my demo? Its basically a dev tool - so you really need to be able to build it to try your own apps.

Heres the PC exe:
http://users.on.net/~dlannan//Files/PSP/GLVOX.exe


The idea is that you can make your own demos without a PSP.. then when you get access to a V1.0 PSP.. you can build an EBOOT.PBP and run it without modifying your code. BTW close the command window to exit the app. I use the command line window for stdout.. and stderr.. very useful.

BTW there are a few 'known' bugs I have left in the Src.. this source is for everyone to use, but please dont expect me to write your game/demo for you :-)
Bye.
skippy911
Posts: 46
Joined: Fri May 06, 2005 10:20 am

Post by skippy911 »

Maybe it is just my pc, windows xp japanese, but I cant get the exe to run :( Says it is not a vlid win32 application.
Shito
Posts: 21
Joined: Wed May 11, 2005 1:38 am

Post by Shito »

Grover wrote:I found lots of bugs in ImageConv.. sorry to those who tried it. I really dont know how I got any usable data!!! Anyhow.. its all fixed now, and I am providing the source so you can see how simple it actually is to do :-)
http://users.on.net/~dlannan//Files/PSP/ConvImage16.zip
Can't seem to compile this code, could you post the exe please ? ^^
User avatar
Thanhda
Posts: 331
Joined: Sat Apr 09, 2005 2:08 am
Location: Canada
Contact:

Post by Thanhda »

Shito wrote:
Grover wrote:I found lots of bugs in ImageConv.. sorry to those who tried it. I really dont know how I got any usable data!!! Anyhow.. its all fixed now, and I am providing the source so you can see how simple it actually is to do :-)
http://users.on.net/~dlannan//Files/PSP/ConvImage16.zip
Can't seem to compile this code, could you post the exe please ? ^^
it converts the sky image to a c file. the sky.c is not included. this program converts the image file to a c file.

you can also run the program without the sky, you just got to comment out 2 lines of code.
There are 10 types of people in the world: Those who understand binary, and those who don't...
User avatar
Thanhda
Posts: 331
Joined: Sat Apr 09, 2005 2:08 am
Location: Canada
Contact:

Post by Thanhda »

Grover wrote:No probs.. but erm.. it will be just my demo? Its basically a dev tool - so you really need to be able to build it to try your own apps.

Heres the PC exe:
http://users.on.net/~dlannan//Files/PSP/GLVOX.exe


The idea is that you can make your own demos without a PSP.. then when you get access to a V1.0 PSP.. you can build an EBOOT.PBP and run it without modifying your code. BTW close the command window to exit the app. I use the command line window for stdout.. and stderr.. very useful.

BTW there are a few 'known' bugs I have left in the Src.. this source is for everyone to use, but please dont expect me to write your game/demo for you :-)
this is a definetly good idea. i myself have done this for the ps2. but remember to make sure that the code will work on both psp and pc, you have to make sure that the code can compile into both an exe and a pbp. for example. if you toss a DX call to the windows version, it may work, but will not work under psp.

to skippy911: to clear this out, Grover isnt running a emu. its just that he written 2 mains that run on both pc and the psp.
skippy911 wrote:Maybe it is just my pc, windows xp japanese, but I cant get the exe to run :( Says it is not a vlid win32 application.
What code line is not exactly working?
if you want to run a quick test and too lazy to convert the sky file
comment the line

Code: Select all

#include "Sky.c"

pgBitBlt&#40;0, 0, 1694, 150, 1, SkyData, 1&#41;;
located in glvox.c

what ends up happening is that the sky is no longer there, and you may see some trails of the terrain because it does not refresh the sky.

this is what it should end up looking like

http://geocities.com/tsune_l/GLVOX.zip
There are 10 types of people in the world: Those who understand binary, and those who don't...
Shito
Posts: 21
Joined: Wed May 11, 2005 1:38 am

Post by Shito »

Thanhda wrote:
Shito wrote:
Grover wrote:I found lots of bugs in ImageConv.. sorry to those who tried it. I really dont know how I got any usable data!!! Anyhow.. its all fixed now, and I am providing the source so you can see how simple it actually is to do :-)
http://users.on.net/~dlannan//Files/PSP/ConvImage16.zip
Can't seem to compile this code, could you post the exe please ? ^^
it converts the sky image to a c file. the sky.c is not included. this program converts the image file to a c file.
you can also run the program without the sky, you just got to comment out 2 lines of code.
Mmm, actually I was just asking for ConvImage.exe ^^
User avatar
Thanhda
Posts: 331
Joined: Sat Apr 09, 2005 2:08 am
Location: Canada
Contact:

Post by Thanhda »

Shito wrote:
Thanhda wrote:
Shito wrote: Can't seem to compile this code, could you post the exe please ? ^^
it converts the sky image to a c file. the sky.c is not included. this program converts the image file to a c file.
you can also run the program without the sky, you just got to comment out 2 lines of code.
Mmm, actually I was just asking for ConvImage.exe ^^
do you have visual studio?

if not i uploaded the binary at http://geocities.com/tsune_l/ConvImage16.zip
There are 10 types of people in the world: Those who understand binary, and those who don't...
Grover
Posts: 50
Joined: Wed Feb 23, 2005 3:13 am

Post by Grover »

Skippy - not your fault.. GLVOX.exe was corrupted on upload.. Reuploading now.. sorry about that.

Have a new one in a zip try this:
http://users.on.net/~dlannan//Files/PSP/GLVOX.zip

Turns out my host doesnt like exe's :-) .. thats why convimage16 probably is broken.. fixing now.. use this like to dl
http://users.on.net/~dlannan//Files/PSP/ConvImage16.zip

Sorry for all the trouble.. will have to remember that little gotcha.
Bye.
Post Reply