1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110
|
/// G_SETIMG fmt: set image formats
#define G_IM_FMT_RGBA 0
#define G_IM_FMT_YUV 1
#define G_IM_FMT_CI 2
#define G_IM_FMT_IA 3
#define G_IM_FMT_I 4
/// Size Types
#define G_IM_SIZ_4b 0
#define G_IM_SIZ_8b 1
#define G_IM_SIZ_16b 2
#define G_IM_SIZ_32b 3
#define G_IM_SIZ_4b_LOAD_BLOCK G_IM_SIZ_16b
#define G_IM_SIZ_8b_LOAD_BLOCK G_IM_SIZ_16b
#define G_IM_SIZ_16b_LOAD_BLOCK G_IM_SIZ_16b
#define G_IM_SIZ_32b_LOAD_BLOCK G_IM_SIZ_32b
#define G_IM_SIZ_4b_INCR 3
#define G_IM_SIZ_8b_INCR 1
#define G_IM_SIZ_16b_INCR 0
#define G_IM_SIZ_32b_INCR 0
#define G_IM_SIZ_4b_SHIFT 2
#define G_IM_SIZ_8b_SHIFT 1
#define G_IM_SIZ_16b_SHIFT 0
#define G_IM_SIZ_32b_SHIFT 0
#define G_IM_SIZ_4b_BYTES 0
#define G_IM_SIZ_4b_TILE_BYTES G_IM_SIZ_4b_BYTES
#define G_IM_SIZ_4b_LINE_BYTES G_IM_SIZ_4b_BYTES
#define G_IM_SIZ_8b_BYTES 1
#define G_IM_SIZ_8b_TILE_BYTES G_IM_SIZ_8b_BYTES
#define G_IM_SIZ_8b_LINE_BYTES G_IM_SIZ_8b_BYTES
#define G_IM_SIZ_16b_BYTES 2
#define G_IM_SIZ_16b_TILE_BYTES G_IM_SIZ_16b_BYTES
#define G_IM_SIZ_16b_LINE_BYTES G_IM_SIZ_16b_BYTES
#define G_IM_SIZ_32b_BYTES 4
#define G_IM_SIZ_32b_TILE_BYTES 2
#define G_IM_SIZ_32b_LINE_BYTES 2
/// Stuff that I'm getting gDPLoadTextureBlock to write to
unsigned char * gDPLTB_CMD = NULL;
unsigned int gDPLTB_LEN = 0x0000;
int i = 0;
/// gDPLoadTextureBlock
#define gDPLoadTextureBlock(pkt, timg, fmt, siz, width, height, pal, cms, cmt, masks, maskt, shifts, shiftt) \
{ \
gDPSetTextureImage(pkt, fmt, siz##_LOAD_BLOCK, 1, timg); \
add_pkt_cmd(pkt); \
gDPSetTile(pkt, fmt, siz##_LOAD_BLOCK, 0, 0, G_TX_LOADTILE, 0 , cmt, maskt, shiftt, cms, masks, shifts); \
add_pkt_cmd(pkt); \
gDPLoadSync(pkt); \
add_pkt_cmd(pkt); \
gDPLoadBlock(pkt, G_TX_LOADTILE, 0, 0, (((width)*(height) + siz##_INCR) >> siz##_SHIFT) -1, CALC_DXT(width, siz##_BYTES)); \
add_pkt_cmd(pkt); \
gDPSetTile(pkt, fmt, siz, (((width) * siz##_LINE_BYTES)+7)>>3, 0, G_TX_RENDERTILE, pal, cmt, maskt, shiftt, cms, masks, shifts); \
add_pkt_cmd(pkt); \
gDPSetTileSize(pkt, G_TX_RENDERTILE, 0, 0, ((width)-1) << G_TEXTURE_IMAGE_FRAC, ((height)-1) << G_TEXTURE_IMAGE_FRAC) \
add_pkt_cmd(pkt); \
}
/// Adds commands onto the gDPLTB_CMD array
#define add_pkt_cmd(pkt) \
{ \
gDPLTB_CMD = (unsigned char*) realloc(gDPLTB_CMD, gDPLTB_LEN + 0x08); \
Gfx * _g = (Gfx *)(pkt); \
\
for (i = 0; i < 4; i++) \
{ \
gDPLTB_CMD[gDPLTB_LEN + i] = ((_g->words.w0 >> (32 - ((i + 1) * 8))) & 0xFF); \
} \
gDPLTB_LEN += 4; \
for (i = 0; i < 4; i++) \
{ \
gDPLTB_CMD[gDPLTB_LEN + i] = ((_g->words.w1 >> (32 - ((i + 1) * 8))) & 0xFF); \
} \
gDPLTB_LEN += 4; \
}
unsigned char * main(int argc, char** argv)
{
if (argc < 14)
{
printf("Incorrect usage.\nUsage: gDPLoadTextureBlock.exe [pkt] [timg] [fmt] [siz] [width] [height] [pal] [cms] [cmt] [masks] [maskt] [shifts] [shiftt]\n");
return NULL;
}
Gfx * pkt = (Gfx *) strtoul(argv[1], NULL, 16);
unsigned int timg = strtoul(argv[2], NULL, 16);
unsigned int fmt = strtoul(argv[3], NULL, 16);
unsigned int siz = strtoul(argv[4], NULL, 16);
unsigned int width = strtoul(argv[5], NULL, 16);
unsigned int height = strtoul(argv[6], NULL, 16);
unsigned int pal = strtoul(argv[7], NULL, 16);
unsigned int cms = strtoul(argv[8], NULL, 16);
unsigned int cmt = strtoul(argv[9], NULL, 16);
unsigned int masks = strtoul(argv[10], NULL, 16);
unsigned int maskt = strtoul(argv[11], NULL, 16);
unsigned int shifts = strtoul(argv[12], NULL, 16);
unsigned int shiftt = strtoul(argv[13], NULL, 16);
gDPLoadTextureBlock(pkt, timg, fmt, siz, width, height, pal, cms, cmt, masks, maskt, shifts, shiftt);
return gDPLTB_CMD;
}
|