Commit c8199e97 authored by Owen Love's avatar Owen Love
Browse files

D

D
Added code to look at safe area of TV to
parent cc86df78
......@@ -34,6 +34,8 @@
#define APP_NAME "SaverAni"
#define ModeFiles_SafeArea 0x4d481 /* Safe area SWI */
#define OSKB_XEIG_FN 4 /* parameters to OS_ReadModeVariable */
#define OSKB_YEIG_FN 5 /* to read screen parameters such as */
#define OSKB_XLIMIT_FN 11 /* number of bits per pixel and */
......@@ -48,6 +50,11 @@
#define LOOP_IMAGE 12 /* First Sprite of Looping Sequence */
#define MAX_IMAGE 18 /* Last Sprite of Looping Sequence */
#define LEFT_WASTE 4 /* Amount of blank space left of sprite */
#define RIGHT_WASTE 16 /* Amount of blank space right of sprite */
#define TOP_WASTE 4 /* Amount of blank space at top of sprite */
#define BOTTOM_WASTE 10 /* Amount of blank space at bottom of sprite */
#define PI 3.14159265
/***************************************************************************/
......@@ -87,6 +94,16 @@ int current_image; /* The current image number */
BOOL intro_done = FALSE; /* Has the intro animation been done */
BOOL sprites_loaded = FALSE; /* Are sprites present in memory ? */
int left_edge; /* Left limit of movement */
int right_edge; /* Right limit of movement */
int top_edge; /* Top limit of movement */
int bottom_edge; /* Bottom limit of movement */
int left_safearea; /* Left edge of safe area */
int right_safearea; /* Right edge of safe area */
int top_safearea; /* Top edge of safe area */
int bottom_safearea; /* Bottom edge of safe area */
/***************************************/
/* Read the mode variable defined in the parameter */
......@@ -161,6 +178,49 @@ static int calc_to_nearest_even_number(int value)
return (value);
}
/* Set up the safearea x,y values for the current mode */
static void set_up_safearea_values(void)
{
_kernel_swi_regs regs;
_kernel_oserror *err;
err = _kernel_swi(ModeFiles_SafeArea, &regs, &regs);
if (err)
{
left_safearea = 0;
right_safearea = xscreenlimit;
bottom_safearea = 0;
top_safearea = yscreenlimit;
}
else
{
left_safearea = regs.r[0];
right_safearea = regs.r[2];
bottom_safearea = regs.r[1];
top_safearea = regs.r[3];
}
}
/* Calculate the max/min x/y positions for the sprite */
static void calc_max_coords_for_current_mode_and_sprite(void)
{
set_up_safearea_values();
left_edge = left_safearea - LEFT_WASTE;
calc_to_nearest_even_number(left_edge);
right_edge = right_safearea + RIGHT_WASTE;
right_edge -= width;
calc_to_nearest_even_number(right_edge);
top_edge = top_safearea + TOP_WASTE;
top_edge -= height;
calc_to_nearest_even_number(top_edge);
bottom_edge = bottom_safearea - BOTTOM_WASTE;
calc_to_nearest_even_number(bottom_edge);
}
/***************************************************************************/
/* Read the current sprite size */
......@@ -237,27 +297,27 @@ static void calculate_next_position(void)
{
xpos += x_step;
ypos += y_step;
if (xpos < 0)
if (xpos < left_edge)
{
xpos = 0;
xpos = left_edge;
direction = 170 - direction + random(20);
calculate_step_distance();
}
if (xpos > (xscreenlimit - width))
if (xpos > right_edge)
{
xpos = (xscreenlimit - width);
xpos = right_edge;
direction = 170 - direction + random(20);
calculate_step_distance();
}
if (ypos < 0)
if (ypos < bottom_edge)
{
ypos = 0;
ypos = bottom_edge;
direction = 10 - direction - random(20);
calculate_step_distance();
}
if (ypos > (yscreenlimit - height))
if (ypos > top_edge)
{
ypos = (yscreenlimit - height);
ypos = top_edge;
direction = 10 - direction - random(20);
calculate_step_distance();
}
......@@ -324,6 +384,7 @@ static void plot_intro_animation(void)
}
}
read_sprite_size(current_image);
calc_max_coords_for_current_mode_and_sprite();
xpos += (old_width - width); /* The looping sprites are smaller */
intro_done = TRUE;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment