home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ARM Club 3
/
TheARMClub_PDCD3.iso
/
hensa
/
colour
/
modesel_1
/
!ModeSel
/
c
/
Icon_Bar
< prev
next >
Wrap
Text File
|
1994-06-20
|
3KB
|
148 lines
#include "Icon_Bar.h"
#include "stdio.h"
#include "stdlib.h"
#include "string.h"
#include "osbyte.h"
#include "os.h"
void bar_sprite(osspriteop_area *sa, int *barMode);
void bar_icon(osspriteop_area *sa, wimp_i *barIc);
bool hiRes(int mode);
bool hiRes(int mode)
{
int var_val;
os_read_mode_variable ((os_mode) mode, 5, &var_val);
return(var_val ==1);
}
void bar_sprite(osspriteop_area *sa, int *barMode)
{
char SMode[4];
int r0, r1, r2, r3;
bool hi;
os_byte ( osbyte_SCREEN_CHAR,0,0,NULL,barMode);
sprintf(SMode,"%d",*barMode);
hi =hiRes(*barMode);
osspriteop_delete_sprite ( osspriteop_NAME,
sa,
(osspriteop_id) "bar2");
if(hi)
osspriteop_copy_sprite ( osspriteop_NAME,
sa,
(osspriteop_id) "b27",
"bar2");
else
osspriteop_copy_sprite ( osspriteop_NAME,
sa,
(osspriteop_id) "b12",
"bar2");
osspriteop_switch_output_to_sprite ( osspriteop_NAME,
sa,
(osspriteop_id) "bar2",
NULL,
&r0, &r1, &r2, &r3);
os_writec (5);
os_writec (18);
os_writec (0);
os_writec (0);
if(hi)
{
os_writec (23);
os_writec (17);
os_writec (7);
os_writec (2);
os_writec (8);
os_writec (0);
os_writec (16);
os_writec (0);
os_writec (0);
os_writec (0);
}
os_plot (4,(40-strlen(SMode)*8),55); /* move g cursor */
os_write0 (SMode);
os_writec (4);
osspriteop_unswitch_output (r0, r1, r2, r3);
}
void bar_icon(osspriteop_area *sa, wimp_i *barIc)
{
wimp_icon_create IcCre;
IcCre.icon.extent.y0 = 0;
IcCre.icon.extent.y1 = 80;
IcCre.icon.extent.x0 = 0;
IcCre.icon.extent.x1 = 80;
IcCre.icon.flags = 0x1700311a;
IcCre.w = wimp_ICON_BAR_RIGHT_LOW_PRIORITY;
IcCre.icon.data.indirected_sprite.id=(osspriteop_id) malloc(10);
sprintf((char *) IcCre.icon.data.indirected_sprite.id,"bar2");
IcCre.icon.data.indirected_sprite.area = sa;
IcCre.icon.data.indirected_sprite.size=5;
*barIc=0x20000000+1;
*barIc = wimp_create_icon_relative (*barIc,&IcCre);
}
void update_bar_icon(osspriteop_area *sa, wimp_i *barIc, int *barMode )
{
wimp_icon_state icon_state;
wimp_i ic=*barIc;
bar_sprite(sa, barMode);
bar_icon(sa,barIc);
icon_state.w = (wimp_w) wimp_ICON_BAR_RIGHT_LOW_PRIORITY;
icon_state.i = ic;
wimp_get_icon_state (&icon_state);
wimp_delete_icon ((wimp_w) wimp_ICON_BAR_RIGHT_LOW_PRIORITY, ic);
free((char *)icon_state.icon.data.indirected_sprite.id);
}
void init_sprites(osspriteop_area **sa, int *barMode, wimp_i *barIc)
{
/* Reserve memory for sprite */
*sa = (osspriteop_area*) malloc (5000);
(*sa)->size=5000;
(*sa)->first=16;
osspriteop_clear_sprites ( osspriteop_USER_AREA,
*sa);
osspriteop_load_sprite_file ( osspriteop_USER_AREA,
*sa,
"<ModeSel$Dir>.Sprites");
osspriteop_copy_sprite ( osspriteop_NAME,
*sa,
(osspriteop_id) "b12",
"bar2");
bar_sprite(*sa, barMode);
bar_icon(*sa, barIc);
}