//--------------------------------------------------------------------------- void g2_fill_rect(s16 x0, s16 y0, s16 x1, s16 y1) { x0 += gs_origin_x; y0 += gs_origin_y; x1 += gs_origin_x; y1 += gs_origin_y; BEGIN_GS_PACKET(gs_dma_buf); GIF_TAG_AD(gs_dma_buf, 4, 1, 0, 0, 0); GIF_DATA_AD(gs_dma_buf, prim, GS_PRIM(PRIM_SPRITE, 0, 0, 0, 0, 0, 0, 0, 0)); GIF_DATA_AD(gs_dma_buf, rgbaq, GS_RGBAQ(g2_fill_r, g2_fill_g, g2_fill_b, 0x80, 0)); GIF_DATA_AD(gs_dma_buf, xyz2, GS_XYZ2(x0<<4, y0<<4, 0)); // It looks like the default operation for the SPRITE primitive is to // not draw the right and bottom 'lines' of the rectangle refined by // the parameters. Add +1 to change this. GIF_DATA_AD(gs_dma_buf, xyz2, GS_XYZ2((x1+1)<<4, (y1+1)<<4, 0)); SEND_GS_PACKET(gs_dma_buf); }
//--------------------------------------------------------------------------- void g2_set_font_color(u8 red, u8 green, u8 blue) { u64 x0; u64 y0; u64 x1; u64 y1; x0 = gs_origin_x-10; y0 = gs_origin_y-10; x1 = g2_fontbuf_w + gs_origin_x; y1 = g2_fontbuf_h + gs_origin_y; BEGIN_GS_PACKET(gs_dma_buf); GIF_TAG_AD(gs_dma_buf, 6, 1, 0, 0, 0); // Restore the frame buffer to the current active frame buffer. GIF_DATA_AD(gs_dma_buf, frame_1, GS_FRAME( g2_fontbuf_addr/8192, cur_mode->width/64, cur_mode->psm, 0)); // Draw the colored rectangle over the entire Font Bitmap. GIF_DATA_AD(gs_dma_buf, prim, GS_PRIM(PRIM_LINE, 0, 0, 0, 0, 0, 0, 0, 0)); // GS_PRIM(PRIM_SPRITE, 0, 0, 0, 0, 0, 0, 0, 0)); GIF_DATA_AD(gs_dma_buf, rgbaq, GS_RGBAQ(red, green, blue, 0x80, 0)); GIF_DATA_AD(gs_dma_buf, xyz2, GS_XYZ2(x0<<4, y0<<4, 0)); GIF_DATA_AD(gs_dma_buf, xyz2, GS_XYZ2(x1<<4, y1<<4, 0)); // Restore the frame buffer to the current active frame buffer. GIF_DATA_AD(gs_dma_buf, frame_1, GS_FRAME( g2_frame_addr[g2_active_frame]/8192, cur_mode->width/64, cur_mode->psm, 0)); SEND_GS_PACKET(gs_dma_buf); }
//--------------------------------------------------------------------------- void g2_line(s16 x0, s16 y0, s16 x1, s16 y1) { x0 += gs_origin_x; y0 += gs_origin_y; x1 += gs_origin_x; y1 += gs_origin_y; BEGIN_GS_PACKET(gs_dma_buf); GIF_TAG_AD(gs_dma_buf, 4, 1, 0, 0, 0); GIF_DATA_AD(gs_dma_buf, prim, GS_PRIM(PRIM_LINE, 0, 0, 0, 0, 0, 0, 0, 0)); GIF_DATA_AD(gs_dma_buf, rgbaq, GS_RGBAQ(g2_col_r, g2_col_g, g2_col_b, 0x80, 0)); GIF_DATA_AD(gs_dma_buf, xyz2, GS_XYZ2(x0<<4, y0<<4, 0)); GIF_DATA_AD(gs_dma_buf, xyz2, GS_XYZ2(x1<<4, y1<<4, 0)); SEND_GS_PACKET(gs_dma_buf); }
//--------------------------------------------------------------------------- void g2_put_pixel(s16 x, s16 y) { x += gs_origin_x; y += gs_origin_y; BEGIN_GS_PACKET(gs_dma_buf); GIF_TAG_AD(gs_dma_buf, 4, 1, 0, 0, 0); GIF_DATA_AD(gs_dma_buf, prim, GS_PRIM(PRIM_POINT, 0, 0, 0, 0, 0, 0, 0, 0)); GIF_DATA_AD(gs_dma_buf, rgbaq, GS_RGBAQ(g2_col_r, g2_col_g, g2_col_b, 0x80, 0)); // The XYZ coordinates are actually floating point numbers between // 0 and 4096 represented as unsigned integers where the lowest order // four bits are the fractional point. That's why all coordinates are // shifted left 4 bits. GIF_DATA_AD(gs_dma_buf, xyz2, GS_XYZ2(x<<4, y<<4, 0)); SEND_GS_PACKET(gs_dma_buf); }
s32 Branch::beginRender(Dma& dmaChain) { s32 start = 0; #ifndef PS2_EMU Vu1::instance()->clearCache(); start = Vu1::instance()->getProgram(dmaChain, ps2::Vu1::BranchRenderer, &Render_Branch_CodeStart, &Render_Branch_CodeEnd); #endif dmaChain.addSrcCntTag(); dmaChain.add32(0); dmaChain.add32(0); dmaChain.add32(VIF_STCYCL(1, 1)); dmaChain.add32(VIF_UNPACK(vif::V4_32, 2, 22)); dmaChain.add64(GIFTAG(0, 0, gif::Pre, GS_PRIM(gs::Tristrip, gs::Gouraud, 0, 0, 0, 0, gs::Stq, gs::Context1, 0), gif::Packed, 1)); dmaChain.add64(0x5); dmaChain.add64(GIFTAG(0, 0, gif::Pre, GS_PRIM(gs::Tristrip, gs::Gouraud, 0, 0, 0, 0, gs::Stq, gs::Context1, 0), gif::Packed, 1)); dmaChain.add64(0x5); dmaChain.add32(VIF_BASE(24)); dmaChain.add32(VIF_OFFSET(524)); dmaChain.add32(0); dmaChain.add32(VIF_DIRECT(2)); dmaChain.add128(GIFTAG(1, gif::Eop, 0, 0, gif::Packed, 1), gif::A_D); dmaChain.add128(GS_RGBAQ(0, 0, 0, 0, 0.0f), GS_REG(RGBAQ)); dmaChain.endPacket(); return start; }