1
0
mirror of https://github.com/cc65/cc65.git synced 2024-05-31 22:41:32 +00:00

fixes for GEOS structures, initialized menu/icontabs finally are possible

git-svn-id: svn://svn.cc65.org/cc65/trunk@2022 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
izydorst 2003-03-15 22:39:16 +00:00
parent 2cad9e701b
commit 404855226c
2 changed files with 32 additions and 13 deletions

View File

@ -5,6 +5,15 @@
by Maciej 'YTM/Elysium' Witkowiak
*/
/*
apart from initializing data, structures below can be used to
speed up access to data and let cc65 to generate better code
e.g. if you have menu defined as TopMenu and you want to change the number of
menu items use:
((struct menu*)&TopMenu)->number=newNumber;
This will translate into single lda/sta pair
*/
#ifndef _GSTRUCT_H
#define _GSTRUCT_H
@ -110,33 +119,26 @@ struct icondef { /* icon definition for DoIcons */
struct icontab {
char number; /* number of declared icons */
struct pixel mousepos; /* position of mouse after DoIcons */
struct icondef *tab; /* table of size declared by icontab.number */
struct icondef tab[]; /* table of size declared by icontab.number */
};
/*
structures below might be used to speed up access to own menus
e.g. if you have menu defined as TopMenu and you want to change the number of
menu items use:
((struct menu*)&TopMenu)->number=newNumber;
This will allow cc65 to emit better code.
*/
struct menuitem {
char *name;
char type;
int rest; /* may be ptr to function, or if submenu ptr to struct menu */
void *rest; /* may be ptr to function, or ptr to struct menu (submenu) */
};
struct menu {
struct window size;
char number;
struct menuitem *items;
struct menuitem items[];
};
struct inittab { /* use struct inittab mytab[n] for initram */
int ptr; /* ptr to 1st byte */
char number; /* number of following bytes */
char *values; /* actual string of bytes */
char values[]; /* actual string of bytes */
};
#endif

View File

@ -15,6 +15,8 @@ void smenu3 (void);
typedef void menuString;
/* you can declare a menu using cc65 non-ANSI extensions */
static const menuString subMenu1 = {
(char)0, (char)(3*15),
(unsigned)0, (unsigned)50,
@ -22,9 +24,24 @@ static const menuString subMenu1 = {
"subitem1", (char)MENU_ACTION, (unsigned)smenu1,
"subitem2", (char)MENU_ACTION, (unsigned)smenu2,
"subitem3", (char)MENU_ACTION, (unsigned)smenu3
};
};
/* or by using initialized structures */
static struct menu subMenu2 = {
{ 0, 3*15, 0, 50 },
3 | VERTICAL,
{
{ "subitem1", MENU_ACTION, smenu1 },
{ "subitem2", MENU_ACTION, smenu2 },
{ "subitem3", MENU_ACTION, smenu3 },
}
};
void main (void)
{
DoMenu(&subMenu1);
}
DoMenu(&subMenu2);
}