PAlib
Macros | Functions
Bitmap mode

Macros

#define PA_Get16bitPixel(screen, x, y)   PA_DrawBg[screen][(x) + ((y) << 8)]
 Get the pixel's color in 16 bit Draw mode...
 
#define PA_SetDrawSize(screen, draw_size)   PA_drawsize[screen] = draw_size;
 Set the size of the pen when drawing.
 
#define PA_Load8bitBitmap(screen, bitmap)
 Load a bitmap on the screen for an 8 bit drawable background.
 
#define PA_Load16bitBitmap(screen, bitmap)
 Load a bitmap on the screen for an 16 bit drawable background.
 
#define PA_Clear8bitBg(screen)   dmaFillWords(0, (void*)PA_DrawBg[screen], 256*96*2);
 Clears the screen... for an 8 bit drawable background.
 
#define PA_Clear16bitBg(screen)   dmaFillWords(0, (void*)PA_DrawBg[screen], 256*192*2)
 Clears the screen... for an 16 bit drawable background.
 

Functions

void PA_Init8bitBg (u8 screen, u8 bg_priority)
 Initialise 8 bit draw mode (palette mode)... Chose the screen and the background priority (0-3). This drawable background will replace Background 3, and must be loaded before all other backgrounds. Takes about 3/8 of the VRAM.
 
void PA_InitBig8bitBg (u8 screen, u8 bg_priority)
 Same as PA_Init8bitBg, but with an available size of 256x256. Takes up a little more space but allows correct vertical scrolling...
 
void PA_Init16bitBg (u8 screen, u8 bg_priority)
 Initialise 16 bit draw mode (no palette mode, true colors)... Chose the screen and the background priority (0-3). This drawable background will replace Background 3, and must be loaded before all other backgrounds. Takes about 6/8 of the VRAM, so almost all the space !
 
static void PA_Put8bitPixel (u8 screen, s16 x, s16 y, u8 color)
 Draw a pixel on screen, on an 8 bit background.
 
static void PA_Put2_8bitPixels (u8 screen, s16 x, s16 y, u16 colors)
 Draw 2 pixels on screen, on an 8 bit background. These pixels are next to another, and the first pixel must be with a pair X. WAY faster than drawing both pixels separately.
 
static void PA_PutDouble8bitPixels (u8 screen, s16 x, s16 y, u8 color1, u8 color2)
 Draw 2 pixels on screen, on an 8 bit background. These pixels are next to another, and the first pixel must be with a pair X. WAY faster than drawing both pixels separately.
 
static void PA_Put4_8bitPixels (u8 screen, s16 x, s16 y, u32 colors)
 Draw 4 pixels on screen, on an 8 bit background. These pixels are next to another, and the first pixel must be with a pair X. Fastest way to draw on the screen...
 
static u8 PA_Get8bitPixel (u8 screen, u8 x, u8 y)
 Get the pixel's color in 8 bit Draw mode...
 
static void PA_Put16bitPixel (u8 screen, s16 x, s16 y, u16 color)
 Draw a pixel on screen, on an 16 bit background.
 
void PA_Draw8bitLine (u8 screen, u16 x1, u16 y1, u16 x2, u16 y2, u8 color)
 Draw a line in Draw mode... for 8 bit drawable background.
 
void PA_Draw16bitLine (u8 screen, u16 x1, u16 y1, u16 x2, u16 y2, u16 color)
 Draw a line in Draw mode... for 16 bit drawable background.
 
void PA_Draw16bitLineEx (u8 screen, s16 basex, s16 basey, s16 endx, s16 endy, u16 color, s8 size)
 Draw a thick line in Draw mode... for 16 bit drawable background.
 
void PA_Draw8bitLineEx (u8 screen, s16 basex, s16 basey, s16 endx, s16 endy, u8 color, s8 size)
 Draw a thick line in Draw mode... for 8 bit drawable background.
 
void PA_Draw16bitRect (u8 screen, s16 basex, s16 basey, s16 endx, s16 endy, u16 color)
 Draw a rectangle in Draw mode... for 16 bit drawable background.
 
void PA_8bitDraw (u8 screen, u8 color)
 For 8 bit background : Nice little function that draws on screen ! All you need to do is chose the color, it'll do the rest. If the PA VBL isn't initialised, don't forget to update the stylus position every frame... Juste execute PA_Draw every cycle...
 
void PA_16bitDraw (u8 screen, u16 color)
 For 16 bit : Nice little function that draws on screen ! All you need to do is chose the color, it'll do the rest. If the PA VBL isn't initialised, don't forget to update the stylus position every frame... Juste execute PA_Draw every cycle...
 
static void PA_LoadJpeg (u8 screen, void *jpeg)
 Load a jpeg on a 16 bit background... Don't forget to Init the background !
 
void PA_LoadBmpToBuffer (u16 *Buffer, s16 x, s16 y, void *bmp, s16 SWidth)
 Load a BMP in a 16 bit Buffer.
 
static void PA_LoadBmpEx (u8 screen, s16 x, s16 y, void *bmp)
 Load a BMP on a 16 bit background... Don't forget to Init the background !
 
static void PA_LoadBmp (u8 screen, void *bmp)
 Load a BMP on a 16 bit background... Don't forget to Init the background !
 
static u16 PA_GetBmpWidth (void *bmpdata)
 Get a BMP's width in pixels.
 
static u16 PA_GetBmpHeight (void *bmpdata)
 Get a BMP's height in pixels.
 

Detailed Description

Draw on screen, either a pixel or a line, or anything ! Load a Bitmap, a Jpeg...

Macro Definition Documentation

◆ PA_Get16bitPixel

#define PA_Get16bitPixel (   screen,
  x,
 
)    PA_DrawBg[screen][(x) + ((y) << 8)]

Get the pixel's color in 16 bit Draw mode...

Parameters
screenChose de screen (0 or 1)
xX position. Be carefull, if X is not between 0 and 255, it'll give unwanted results
yY position. Be carefull, if Y is not between 0 and 191, it'll give unwanted results

◆ PA_SetDrawSize

#define PA_SetDrawSize (   screen,
  draw_size 
)    PA_drawsize[screen] = draw_size;

Set the size of the pen when drawing.

Parameters
screenChose de screen (0 or 1)
draw_sizeSize...

◆ PA_Load8bitBitmap

#define PA_Load8bitBitmap (   screen,
  bitmap 
)
Value:
do{ \
DC_FlushRange(bitmap, 256 * 192); \
dmaCopy(bitmap, (void*)PA_DrawBg[screen], 256 * 192); \
} while(0)

Load a bitmap on the screen for an 8 bit drawable background.

Parameters
screenChose de screen (0 or 1)
bitmapBitmap name

◆ PA_Load16bitBitmap

#define PA_Load16bitBitmap (   screen,
  bitmap 
)
Value:
do{u32 PA_temp; \
for (PA_temp = 0; PA_temp < 256*192; PA_temp++)\
PA_DrawBg[screen][PA_temp] = bitmap[PA_temp] | (1 << 15);}while(0)

Load a bitmap on the screen for an 16 bit drawable background.

Parameters
screenChose de screen (0 or 1)
bitmapBitmap name

◆ PA_Clear8bitBg

#define PA_Clear8bitBg (   screen)    dmaFillWords(0, (void*)PA_DrawBg[screen], 256*96*2);

Clears the screen... for an 8 bit drawable background.

Parameters
screenChose de screen (0 or 1)

◆ PA_Clear16bitBg

#define PA_Clear16bitBg (   screen)    dmaFillWords(0, (void*)PA_DrawBg[screen], 256*192*2)

Clears the screen... for an 16 bit drawable background.

Parameters
screenChose de screen (0 or 1)

Function Documentation

◆ PA_Init8bitBg()

void PA_Init8bitBg ( u8  screen,
u8  bg_priority 
)

Initialise 8 bit draw mode (palette mode)... Chose the screen and the background priority (0-3). This drawable background will replace Background 3, and must be loaded before all other backgrounds. Takes about 3/8 of the VRAM.

Parameters
screenChose de screen (0 or 1)
bg_priorityBackground priority (0-3) Background priority (0-3)

◆ PA_InitBig8bitBg()

void PA_InitBig8bitBg ( u8  screen,
u8  bg_priority 
)

Same as PA_Init8bitBg, but with an available size of 256x256. Takes up a little more space but allows correct vertical scrolling...

Parameters
screenChose de screen (0 or 1)
bg_priorityBackground priority (0-3) Background priority (0-3)

◆ PA_Init16bitBg()

void PA_Init16bitBg ( u8  screen,
u8  bg_priority 
)

Initialise 16 bit draw mode (no palette mode, true colors)... Chose the screen and the background priority (0-3). This drawable background will replace Background 3, and must be loaded before all other backgrounds. Takes about 6/8 of the VRAM, so almost all the space !

Parameters
screenChose de screen (0 or 1)
bg_priorityBackground priority (0-3) Background priority (0-3)

◆ PA_Put8bitPixel()

static inline void PA_Put8bitPixel ( u8  screen,
s16  x,
s16  y,
u8  color 
)
inlinestatic

Draw a pixel on screen, on an 8 bit background.

Parameters
screenChose de screen (0 or 1)
xX position (0-255)
yY position (0-191)
colorColor in the background palette (0-255)

◆ PA_Put2_8bitPixels()

static inline void PA_Put2_8bitPixels ( u8  screen,
s16  x,
s16  y,
u16  colors 
)
inlinestatic

Draw 2 pixels on screen, on an 8 bit background. These pixels are next to another, and the first pixel must be with a pair X. WAY faster than drawing both pixels separately.

Parameters
screenChose de screen (0 or 1)
xX position (0-254), must be PAIR
yY position (0-191)
colorsColors of the first and second pixels (*256 for the second)

◆ PA_PutDouble8bitPixels()

static inline void PA_PutDouble8bitPixels ( u8  screen,
s16  x,
s16  y,
u8  color1,
u8  color2 
)
inlinestatic

Draw 2 pixels on screen, on an 8 bit background. These pixels are next to another, and the first pixel must be with a pair X. WAY faster than drawing both pixels separately.

Parameters
screenChose de screen (0 or 1)
xX position (0-254), must be PAIR
yY position (0-191)
color1Color of the first pixel, in the background palette (0-255)
color2Color of the second pixel, in the background palette (0-255)

◆ PA_Put4_8bitPixels()

static inline void PA_Put4_8bitPixels ( u8  screen,
s16  x,
s16  y,
u32  colors 
)
inlinestatic

Draw 4 pixels on screen, on an 8 bit background. These pixels are next to another, and the first pixel must be with a pair X. Fastest way to draw on the screen...

Parameters
screenChose de screen (0 or 1)
xX position (0-254), must be PAIR
yY position (0-191)
colorsColors of the 4 pixels

◆ PA_Get8bitPixel()

static inline u8 PA_Get8bitPixel ( u8  screen,
u8  x,
u8  y 
)
inlinestatic

Get the pixel's color in 8 bit Draw mode...

Parameters
screenChose de screen (0 or 1)
xX position. Be carefull, if X is not between 0 and 255, it'll give unwanted results
yY position. Be carefull, if Y is not between 0 and 191, it'll give unwanted results

◆ PA_Put16bitPixel()

static inline void PA_Put16bitPixel ( u8  screen,
s16  x,
s16  y,
u16  color 
)
inlinestatic

Draw a pixel on screen, on an 16 bit background.

Parameters
screenChose de screen (0 or 1)
xX position (0-255)
yY position (0-191)
color16 bit color, obtained using PA_RGB(red, green, blue)

◆ PA_Draw8bitLine()

void PA_Draw8bitLine ( u8  screen,
u16  x1,
u16  y1,
u16  x2,
u16  y2,
u8  color 
)

Draw a line in Draw mode... for 8 bit drawable background.

Parameters
screenChose de screen (0 or 1)
x1X position of the first point. Be carefull, if X is not between 0 and 255, it'll give unwanted results
y1Y position of the first point. Be carefull, if Y is not between 0 and 191, it'll give unwanted results
x2X position of the second point. Be carefull, if X is not between 0 and 255, it'll give unwanted results
y2Y position of the second point. Be carefull, if Y is not between 0 and 191, it'll give unwanted results
colorColor in the background palette (0-255)

◆ PA_Draw16bitLine()

void PA_Draw16bitLine ( u8  screen,
u16  x1,
u16  y1,
u16  x2,
u16  y2,
u16  color 
)

Draw a line in Draw mode... for 16 bit drawable background.

Parameters
screenChose de screen (0 or 1)
x1X position of the first point. Be carefull, if X is not between 0 and 255, it'll give unwanted results
y1Y position of the first point. Be carefull, if Y is not between 0 and 191, it'll give unwanted results
x2X position of the second point. Be carefull, if X is not between 0 and 255, it'll give unwanted results
y2Y position of the second point. Be carefull, if Y is not between 0 and 191, it'll give unwanted results
color15 bits color. You can use the PA_RGB macro to set the RGB values...

◆ PA_Draw16bitLineEx()

void PA_Draw16bitLineEx ( u8  screen,
s16  basex,
s16  basey,
s16  endx,
s16  endy,
u16  color,
s8  size 
)

Draw a thick line in Draw mode... for 16 bit drawable background.

Parameters
screenChose de screen (0 or 1)
basexX position of the first point. Be carefull, if X is not between 0 and 255, it'll give unwanted results
baseyY position of the first point. Be carefull, if Y is not between 0 and 191, it'll give unwanted results
endxX position of the second point. Be carefull, if X is not between 0 and 255, it'll give unwanted results
endyY position of the second point. Be carefull, if Y is not between 0 and 191, it'll give unwanted results
color15 bits color. You can use the PA_RGB macro to set the RGB values...
sizeWidth of the line, in pixels

◆ PA_Draw8bitLineEx()

void PA_Draw8bitLineEx ( u8  screen,
s16  basex,
s16  basey,
s16  endx,
s16  endy,
u8  color,
s8  size 
)

Draw a thick line in Draw mode... for 8 bit drawable background.

Parameters
screenChose de screen (0 or 1)
basexX position of the first point. Be carefull, if X is not between 0 and 255, it'll give unwanted results
baseyY position of the first point. Be carefull, if Y is not between 0 and 191, it'll give unwanted results
endxX position of the second point. Be carefull, if X is not between 0 and 255, it'll give unwanted results
endyY position of the second point. Be carefull, if Y is not between 0 and 191, it'll give unwanted results
color15 bits color. You can use the PA_RGB macro to set the RGB values...
sizeWidth of the line, in pixels

◆ PA_Draw16bitRect()

void PA_Draw16bitRect ( u8  screen,
s16  basex,
s16  basey,
s16  endx,
s16  endy,
u16  color 
)

Draw a rectangle in Draw mode... for 16 bit drawable background.

Parameters
screenChose de screen (0 or 1)
basexX position of the first point. Be carefull, if X is not between 0 and 255, it'll give unwanted results
baseyY position of the first point. Be carefull, if Y is not between 0 and 191, it'll give unwanted results
endxX position of the second point. Be carefull, if X is not between 0 and 255, it'll give unwanted results
endyY position of the second point. Be carefull, if Y is not between 0 and 191, it'll give unwanted results
color15 bits color. You can use the PA_RGB macro to set the RGB values...

◆ PA_8bitDraw()

PA_8bitDraw ( u8  screen,
u8  color 
)

For 8 bit background : Nice little function that draws on screen ! All you need to do is chose the color, it'll do the rest. If the PA VBL isn't initialised, don't forget to update the stylus position every frame... Juste execute PA_Draw every cycle...

Parameters
screenChose de screen (0 or 1)
colorColor number in the palette (0-255)

◆ PA_16bitDraw()

PA_16bitDraw ( u8  screen,
u16  color 
)

For 16 bit : Nice little function that draws on screen ! All you need to do is chose the color, it'll do the rest. If the PA VBL isn't initialised, don't forget to update the stylus position every frame... Juste execute PA_Draw every cycle...

Parameters
screenChose de screen (0 or 1)
color15 bits color. You can use the PA_RGB macro to set the RGB values...

◆ PA_LoadJpeg()

static inline void PA_LoadJpeg ( u8  screen,
void *  jpeg 
)
inlinestatic

Load a jpeg on a 16 bit background... Don't forget to Init the background !

Parameters
screenChose de screen (0 or 1)
jpegjpeg image...

◆ PA_LoadBmpToBuffer()

void PA_LoadBmpToBuffer ( u16 *  Buffer,
s16  x,
s16  y,
void *  bmp,
s16  SWidth 
)

Load a BMP in a 16 bit Buffer.

Parameters
BufferBuffer...
xX position of the top left corner
yY position of the top left corner
bmpBMP image...
SWidthBuffer width to use (256 for screen width...)

◆ PA_LoadBmpEx()

static inline void PA_LoadBmpEx ( u8  screen,
s16  x,
s16  y,
void *  bmp 
)
inlinestatic

Load a BMP on a 16 bit background... Don't forget to Init the background !

Parameters
screenChose de screen (0 or 1)
xX position of the top left corner
yY position of the top left corner
bmpBMP image...

◆ PA_LoadBmp()

static inline void PA_LoadBmp ( u8  screen,
void *  bmp 
)
inlinestatic

Load a BMP on a 16 bit background... Don't forget to Init the background !

Parameters
screenChose de screen (0 or 1)
bmpBMP image...

◆ PA_GetBmpWidth()

static inline u16 PA_GetBmpWidth ( void *  bmp)
inlinestatic

Get a BMP's width in pixels.

Parameters
bmpBMP image...

◆ PA_GetBmpHeight()

static inline u16 PA_GetBmpHeight ( void *  bmp)
inlinestatic

Get a BMP's height in pixels.

Parameters
bmpBMP image...