0 Members and 1 Guest are viewing this topic.
void AlphaSprite(short* data, int x, int y, int width, int height, char alpha) { short* VRAM = (short*)0xA8000000; int CurColor = 0; VRAM += (LCD_WIDTH_PX*y)+x; for(int j=y; j<y+height; j++) { for(int i=x; i<x+width; i++) { CurColor = (*(VRAM) + (alpha*(*(data++))/256))/2; *(VRAM++) = CurColor % (65536); } VRAM += (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 getpixel(short x, short y) { short *VRAM = (short *)0xA8000000; return *(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; } }}
void PutCustC(*bool map, short x, short y, short width, short height, short color, bool DrawBackColor, short backcolor) { 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++) = backcolor; } else { VRAM++; } } VRAM += (LCD_WIDTH_PX-width); }}
void DrawCircle(short x0, short y0, short radius, short color){ short f = 1 - radius; short ddF_x = 1; short ddF_y = -2 * radius; short x = 0; short y = radius; Bdisp_SetPoint_VRAM(x0, y0 + radius, color); Bdisp_SetPoint_VRAM(x0, y0 - radius, color); Bdisp_SetPoint_VRAM(x0 + radius, y0, color); Bdisp_SetPoint_VRAM(x0 - radius, y0, color); while(x < y) { // ddF_x == 2 * x + 1; // ddF_y == -2 * y; // f == x*x + y*y - radius*radius + 2*x - y + 1; if(f >= 0) { y--; ddF_y += 2; f += ddF_y; } x++; ddF_x += 2; f += ddF_x; Bdisp_SetPoint_VRAM(x0 + x, y0 + y, color); Bdisp_SetPoint_VRAM(x0 - x, y0 + y, color); Bdisp_SetPoint_VRAM(x0 + x, y0 - y, color); Bdisp_SetPoint_VRAM(x0 - x, y0 - y, color); Bdisp_SetPoint_VRAM(x0 + y, y0 + x, color); Bdisp_SetPoint_VRAM(x0 - y, y0 + x, color); Bdisp_SetPoint_VRAM(x0 + y, y0 - x, color); Bdisp_SetPoint_VRAM(x0 - y, y0 - x, color); }}
#define O_READ 0x01#define O_READ_SHARE 0x80#define O_WRITE 0x02#define O_READWRITE 0x03#define O_READWRITE_SHARE 0x83int Bfile_OpenFile_OS( const unsigned short*filename, int mode );int Bfile_CloseFile_OS( int HANDLE );int Bfile_ReadFile_OS( int HANDLE, void *buf, int size, int readpos );int Bfile_CreateEntry_OS( const unsigned short*filename, int mode, int*size );int Bfile_WriteFile_OS( int HANDLE, const void *buf, int size );int Bfile_DeleteEntry( const unsigned short *filename );void Bfile_StrToName_ncpy( unsigned short*dest, const unsigned char*source, int n );
Please, use Syscall 0x01E6 to obtain the VRAM address.Interface: void *GetVRAMAddress(void);
Could the address possibly change in future OS versions? I hope not....
bool pointInPolygon(int polySides, float polyX[], float polyY[], float x, float y) { int i, j=polySides-1 ; boolean oddNodes=0 ; for (i=0; i<polySides; i++) { if (polyY[i]<y && polyY[j]>=y || polyY[j]<y && polyY[i]>=y) { if (polyX[i]+(y-polyY[i])/(polyY[j]-polyY[i])*(polyX[j]-polyX[i])<x) { oddNodes=!oddNodes; }} j=i; } return oddNodes;}
I could, but since the address is known, it's a whole lot easier in many cases just to remember the magic number 0xA8000000.
short GetPixel(short x, short y){ MOV.W (width),R2 MOV.L (VRAM),R3 MULU.W r2,R5 ADD R4,R3 STS MACL,R2 ADD R3,R2 MOV.W @R2,R0 RTS EXTU.W R0 align.4 width: word 384 VRAM: long VRAM_address