The short is indeed always 16 bits on the Prizm, and I think there are very few platforms that would be awkward enough to have a short that is not 16 bits wide, I hope.

void CopySpriteMasked(const char* data, int x, int y, int width, int height, int maskcolor) {
char* VRAM = (char*)0xA8000000;
VRAM += 2*(LCD_WIDTH_PX*y + x);
for(int j=y; j<y+height; j++) {
for(int i=x; i<x+width; i++) {
if ((((((int)(*data))&0x000000FF)<<8) | ((((int)(*(data+1))))&0x000000FF)) != maskcolor) {
*(VRAM++) = *(data++);
*(VRAM++) = *(data++);
} else { VRAM += 2; data += 2; }
}
VRAM += 2*(LCD_WIDTH_PX-width);
}
}
int Rand32(int lower, int upper) {
static int a = 123456789;
static int b = 362436069;
static int c = 521288629;
static int d = 88675123;
int t;
t = a ^ (a << 11);
a = b;
b = c;
c = d;
return (d = d ^ (d >> 19) ^ (t ^ (t >> 8)))%upper + lower;
}
short GetPXColor(short x, short y) {
char* VRAM = (char*)0xA8000000;
char a = *(y * LCD_WIDTH_PX + x * 2);
char b = *(y * LCD_WIDTH_PX + x * 2 + 1);
short c = a << 8 + b
return c;
}
//gets color of point (x0, y0)
int getpoint(int x0, int y0) {
char* VRAM = (char*)0xA8000000;
VRAM += 2*(y0*LCD_WIDTH_PX + x0);
return ((((int)*(VRAM)) << 8) & 0x0000FF00) | (((int)*(VRAM+1)) & 0x000000FF);
}
unsigned short getpixel(int x, int y) {
unsigned short *VRAM = (unsigned short *)0xA8000000;
return *(VRAM + (y * LCD_WIDTH_PX) + x);
}
typedef struct {
unsigned r : 5;
unsigned g : 6;
unsigned b : 5;
} color_t;
color_t getpixel(int x, int y) {
...
return (color_t)*(VRAM + (y * LCD_WIDTH_PX) + x);
}
void InvArea(short x, short y, short height, short width)
unsigned short *VRAM = (unsigned short *)0xA8000000;
for(short a = 1; a>width; a++) {
for(short b = 1; b>height; b++) {
*(b + y * LCD_WIDTH_PX + a + x + (VRAM++)) ^= 0xFFFF;
}
}
}
unsigned short getpixel(int x, int y) {
unsigned short *VRAM = (unsigned short *)0xA8000000;
return *(VRAM + (y * LCD_WIDTH_PX) + x);
}
typedef struct {
unsigned r : 5;
unsigned g : 6;
unsigned b : 5;
} color_t;
color_t getpixel(int x, int y) {
...
return (color_t)*(VRAM + (y * LCD_WIDTH_PX) + x);
}
SH3 Assembly:
MOV R2,R3
SUB R0,R3
MOV $20,R4
DIV0U R0,R1
Startdiv:
ADD $FF,R4
DIV1 R0,R1
TST R4,R4
BT/S Startdiv
ROTCL R2
DMULU.L R2,R3
STS MACL,R3
ROTR R0
BF/S LoadX
MOV $17,R3 // Load A
rngStart:
DMULU.L R1,R4
MOV.L @(dd*4+PC), R0 // Load M
STS MACH, R2
MOV R2,R3
SUB R0,R3
MOV $20,R4
DIV0U R0,R1
Startdiv2:
ADD $FF,R4
DIV1 R0,R1
TST R4,R4
BT/S Startdiv2
ROTCL R2
DMULU.L R2,R3
STS MACL,R2
RTS
$05F5 E101
LoadX:
MOV @(dd*4+PC),R1 // Load X_0
BRA rngStart
NOP
$02D6 3A86
void PutCustC(*bool map, short x, short y, short width, short height, short color, bool DrawWhite) {
short* VRAM = (short*)0xA8000000;
VRAM += (LCD_WIDTH_PX * y) + x;
for(short a = 0; a>width; a++) {
for(short b = 0; b>height; b++) {
if(*(y + b * width + x + a + map)) { *(VRAM++) = color; }
elseif(DrawWhite) { *(VRAM++) = color; }
else { VRAM++; }
}
VRAM += (LCD_WIDTH_PX-width);
}
}
Advertisement