示例#1
0
    /* bl */
  gsDPSetRenderMode(G_RM_OPA_SURF, G_RM_OPA_SURF2),
  gsDPSetColorDither(G_CD_BAYER),
  gsDPSetFogColor(255, 0, 0, 255),
  gsDPSetScissor(G_SC_NON_INTERLACE, 0,0, 319,239),
  gsDPPipeSync(),
  gsSPEndDisplayList(),
};

/* intialize the RSP state: */
Gfx setup_rspstate[] = {
  gsSPViewport(&vp),
  gsSPClearGeometryMode((G_ZBUFFER | G_SHADE | G_SHADING_SMOOTH | 
			 G_CULL_BOTH | G_FOG | G_LIGHTING)),
  gsSPTexture(0, 0, 0, 0, G_OFF),
  gsSPSetLights1(sun_light),
  gsSPFogPosition(996, 1000),
  gsSPEndDisplayList(),
};

Vtx bullet_vtx[] = {
  {   1,    0,   20,   0,   0,   0, 0xff, 0xff, 0x00, 0xff},
  {  -1,    0,   20,   0,   0,   0, 0xff, 0xff, 0x00, 0xff},
  {  -1,    0,  -20,   0,   0,   0, 0xff, 0xff, 0x00, 0xff},
  {   1,    0,  -20,   0,   0,   0, 0xff, 0xff, 0x00, 0xff},
};

Gfx bullet_dl[] = {
  gsDPPipeSync(),
  gsDPSetCycleType(G_CYC_1CYCLE),
示例#2
0
static void draw_crosshair(struct menu_item *item)
{
  struct item_data *data = item->data;
  struct gfx_texture *texture = resource_get(RES_TEXTURE_CROSSHAIR);
  /* define meshes */
  static Vtx lat_mesh[] =
  {
    gdSPDefVtx(-16, 0, 16,  0,  0),
    gdSPDefVtx(16,  0, 16,  62, 0),
    gdSPDefVtx(-16, 0, -16, 0,  62),
    gdSPDefVtx(16,  0, -16, 62, 62),
  };
  static Vtx vert_mesh[] =
  {
    gdSPDefVtx(-16, 16,  0, 0,  0),
    gdSPDefVtx(16,  16,  0, 62, 0),
    gdSPDefVtx(-16, -16, 0, 0,  62),
    gdSPDefVtx(16,  -16, 0, 62, 62),
  };
  /* create modelview matrices */
  float xscale = 1.5f;
  float yscale = 1.5f;
  float zscale = 1.5f;
  Mtx m;
  MtxF mf;
  MtxF mt;
  {
    guTranslateF(&mf, data->x, data->y, data->z);
  }
  {
    guScaleF(&mt, xscale, yscale, zscale);
    guMtxCatF(&mt, &mf, &mf);
  }
  guMtxF2L(&mf, &m);
  Mtx *p_latz_mtx = gDisplayListData(&data->gfx.poly_xlu.d, m);
  {
    guRotateF(&mt, -M_PI / 2.f, 0.f, 1.f, 0.f);
    guMtxCatF(&mt, &mf, &mf);
  }
  guMtxF2L(&mf, &m);
  Mtx *p_latx_mtx = gDisplayListData(&data->gfx.poly_xlu.d, m);
  {
    guTranslateF(&mf, data->x, data->y, data->z);
  }
  {
    guRotateF(&mt, data->yaw, 0.f, 1.f, 0.f);
    guMtxCatF(&mt, &mf, &mf);
  }
  {
    guScaleF(&mt, xscale, yscale, zscale);
    guMtxCatF(&mt, &mf, &mf);
  }
  guMtxF2L(&mf, &m);
  Mtx *p_vert_mtx = gDisplayListData(&data->gfx.poly_xlu.d, m);
  /* build dlist */
  gDisplayListAppend(&data->gfx.poly_xlu.p,
    gsDPPipeSync(),
    /* rsp state */
    gsSPLoadGeometryMode(G_ZBUFFER),
    /* rdp state */
    gsDPSetCycleType(G_CYC_1CYCLE),
    /* texture engine */
    gsSPTexture(0x8000, 0x8000, 0, G_TX_RENDERTILE, G_ON),
    gsDPSetTexturePersp(G_TP_PERSP),
    gsDPSetTextureDetail(G_TD_CLAMP),
    gsDPSetTextureLUT(G_TT_NONE),
    /* texture filter */
    gsDPSetTextureFilter(G_TF_BILERP),
    gsDPSetTextureConvert(G_TC_FILT),
    /* color combiner */
    gsDPSetCombineMode(G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM),
    /* blender */
    gsDPSetAlphaCompare(G_AC_NONE),
    gsDPSetDepthSource(G_ZS_PIXEL),
    gsDPSetRenderMode(G_RM_AA_ZB_XLU_SURF, G_RM_AA_ZB_XLU_SURF2),
    /* memory interface */
    gsDPSetColorDither(G_CD_DISABLE),
    gsDPSetAlphaDither(G_AD_DISABLE),
    /* load meshes */
    gsSPMatrix(p_latx_mtx, G_MTX_MODELVIEW | G_MTX_LOAD),
    gsSPVertex(&lat_mesh, 4, 0),
    gsSPMatrix(p_vert_mtx, G_MTX_MODELVIEW | G_MTX_LOAD),
    gsSPVertex(&vert_mesh, 4, 4),
    gsSPMatrix(p_latz_mtx, G_MTX_MODELVIEW | G_MTX_LOAD),
    gsSPVertex(&lat_mesh, 4, 8),
  );
  /* render navigation indicator primitives */
  gDPSetPrimColor(data->gfx.poly_xlu.p++, 0, 0, 0xFF, 0xFF, 0xFF, 0x40);
  if (input_pad() & BUTTON_Z) {
    gfx_disp_rdp_load_tile(&data->gfx.poly_xlu.p, texture, 2);
    gSP2Triangles(data->gfx.poly_xlu.p++, 4, 5, 6, 0, 6, 5, 7, 0);
  }
  else {
    gfx_disp_rdp_load_tile(&data->gfx.poly_xlu.p, texture, 1);
    gSP2Triangles(data->gfx.poly_xlu.p++, 0, 1, 2, 0, 2, 1, 3, 0);
  }
  /* render crosshair primitives */
  gfx_disp_rdp_load_tile(&data->gfx.poly_xlu.p, texture, 0);
  gDisplayListAppend(&data->gfx.poly_xlu.p,
    gsDPSetPrimColor(0, 0, 0x00, 0x00, 0xFF, 0x40),
    gsSP2Triangles(8, 9, 10, 0, 10, 9, 11, 0),
    gsDPPipeSync(),
    gsDPSetPrimColor(0, 0, 0xFF, 0x00, 0x00, 0x40),
    gsSP2Triangles(0, 1, 2, 0, 2, 1, 3, 0),
    gsDPPipeSync(),
    gsDPSetPrimColor(0, 0, 0x00, 0xFF, 0x00, 0x40),
    gsSP2Triangles(4, 5, 6, 0, 6, 5, 7, 0),
  );
}