mirror of
https://github.com/cc65/cc65.git
synced 2025-01-13 09:31:53 +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:
parent
2cad9e701b
commit
404855226c
@ -5,6 +5,15 @@
|
|||||||
by Maciej 'YTM/Elysium' Witkowiak
|
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
|
#ifndef _GSTRUCT_H
|
||||||
#define _GSTRUCT_H
|
#define _GSTRUCT_H
|
||||||
|
|
||||||
@ -110,33 +119,26 @@ struct icondef { /* icon definition for DoIcons */
|
|||||||
struct icontab {
|
struct icontab {
|
||||||
char number; /* number of declared icons */
|
char number; /* number of declared icons */
|
||||||
struct pixel mousepos; /* position of mouse after DoIcons */
|
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 {
|
struct menuitem {
|
||||||
char *name;
|
char *name;
|
||||||
char type;
|
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 menu {
|
||||||
struct window size;
|
struct window size;
|
||||||
char number;
|
char number;
|
||||||
struct menuitem *items;
|
struct menuitem items[];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct inittab { /* use struct inittab mytab[n] for initram */
|
struct inittab { /* use struct inittab mytab[n] for initram */
|
||||||
int ptr; /* ptr to 1st byte */
|
int ptr; /* ptr to 1st byte */
|
||||||
char number; /* number of following bytes */
|
char number; /* number of following bytes */
|
||||||
char *values; /* actual string of bytes */
|
char values[]; /* actual string of bytes */
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -15,6 +15,8 @@ void smenu3 (void);
|
|||||||
|
|
||||||
typedef void menuString;
|
typedef void menuString;
|
||||||
|
|
||||||
|
/* you can declare a menu using cc65 non-ANSI extensions */
|
||||||
|
|
||||||
static const menuString subMenu1 = {
|
static const menuString subMenu1 = {
|
||||||
(char)0, (char)(3*15),
|
(char)0, (char)(3*15),
|
||||||
(unsigned)0, (unsigned)50,
|
(unsigned)0, (unsigned)50,
|
||||||
@ -24,7 +26,22 @@ static const menuString subMenu1 = {
|
|||||||
"subitem3", (char)MENU_ACTION, (unsigned)smenu3
|
"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)
|
void main (void)
|
||||||
{
|
{
|
||||||
|
|
||||||
DoMenu(&subMenu1);
|
DoMenu(&subMenu1);
|
||||||
|
DoMenu(&subMenu2);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user