Pad reading tests master
authorslack <slack@codemaniacs.com>
Sat, 1 Nov 2008 02:10:36 +0000 (03:10 +0100)
committerslack <slack@codemaniacs.com>
Sat, 1 Nov 2008 02:10:36 +0000 (03:10 +0100)
entity.h
game.cc
gfx.cc
gfx.h

index 7fc6d9a1023b23156f9a5ac6dc53c845f6086f2d..b2f8edaa43adf88e0d6c4e4071e11fb5d4add8c2 100644 (file)
--- a/entity.h
+++ b/entity.h
@@ -29,6 +29,8 @@ class Entity
                radius(radius)
        {}
 
+       void set_velocity(ScePspFVector3 v) { velocity = v; }
+       void set_position(ScePspFVector3 p) { position = p; }
        void draw() const;
        void update_position(float dt);
        bool collides(const Entity& other);
diff --git a/game.cc b/game.cc
index 8c6d0e6c8b644ef424bfec887c6cbae633534db5..cf3e49f774e2478387fe4ef74afee100f222e3db 100644 (file)
--- a/game.cc
+++ b/game.cc
@@ -9,12 +9,14 @@
 #include <psptypes.h>
 #include <pspdisplay.h>
 #include <pspkernel.h>
-
+#include <pspctrl.h>
+#include <stdio.h>
 
 float triangle[]={1,-1,0,-1,-1,0,0,1,0};
 
 int game_main(int argc, char **argv)
 {
+       SceCtrlData pad;
        GFX.init();
 
        Model ship_model("data/shipdawhip.lob");
@@ -37,15 +39,17 @@ int game_main(int argc, char **argv)
        ScePspFVector3 camera_up     = {0, 1, 0};
        GFX.look_at(&camera_pos, &camera_center, &camera_up);
 
-       sceGumMatrixMode(GU_MODEL);
-       int i=0;
+       sceCtrlSetSamplingMode(PSP_CTRL_MODE_ANALOG);
        while(1)
        {
                GFX.begin_frame();
-               i++;
 
-               ship.draw();    
-               
+               sceCtrlPeekBufferPositive(&pad, 1);
+               ship.draw();
+
+               char buf[200];
+               sprintf(buf, "timestamp=%d, LX=%d, LY=%d", pad.TimeStamp, int(pad.Lx), int(pad.Ly));
+               GFX.set_status_string(buf);
                GFX.end_frame();        
        }
 
diff --git a/gfx.cc b/gfx.cc
index cce683de45ea790c20c2aa1025b71d64fad6a8b7..a5d6685b01954749e95eadbbbd39275ffee3648c 100644 (file)
--- a/gfx.cc
+++ b/gfx.cc
@@ -79,8 +79,8 @@ void Gfx::update_fps( void )
        if( ((fps_tick_now - fps_tick_last)/((float)tick_resolution)) >= 1.0f )
        {
                fps_tick_last = fps_tick_now;
-               //sprintf( fps_display, "ticks=%f, FPS: %d", ((double)fps_tick_now/(double)tick_resolution), frames_drawn );
-               sprintf(fps_display, "FPS: %d", frames_drawn);
+               sprintf(fps_display, "FPS: %d -- %s", frames_drawn, status_string);
+               //sprintf(fps_display, "FPS: %d", frames_drawn);
                frames_drawn = 0;
        }
        pspDebugScreenSetOffset((int)fbp0);
diff --git a/gfx.h b/gfx.h
index 95f15344dd9637a846957cb60557739adff518c6..c5ea79a446f3ba04a5d667db8634273b9897ea4d 100644 (file)
--- a/gfx.h
+++ b/gfx.h
@@ -9,12 +9,12 @@
 class Gfx: public Singleton<Gfx>
 {
        void *fbp0; //< frame buffer
-
        int  frames_drawn;
        char fps_display[200];
        u32  tick_resolution;
        u64  fps_tick_now, fps_tick_last;
 
+       const char *status_string;
        public:
        void *display_list;
        static const int SCR_WIDTH=480;
@@ -29,6 +29,7 @@ class Gfx: public Singleton<Gfx>
        
        void begin_frame();
        void end_frame();
+       void set_status_string(const char *str) { status_string = str; }
 
        // Camera controls;
        void perspective(float fov, float aspect, float znear, float zfar);