📄 geos-4.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><HTML><HEAD> <META NAME="GENERATOR" CONTENT="LinuxDoc-Tools 0.9.20"> <TITLE>GEOSLib docs: Library Structures</TITLE> <LINK HREF="geos-3.html" REL=previous> <LINK HREF="geos.html#toc4" REL=contents></HEAD><BODY>Next<A HREF="geos-3.html">Previous</A><A HREF="geos.html#toc4">Contents</A><HR><H2><A NAME="s4">4.</A> <A HREF="geos.html#toc4">Library Structures</A></H2><P>To simplify usage and optimize passing parameters to functions I have declared several structureswhich describe most common objects. Some of these structures are bound to static addresses inGEOS data space (<CODE>$8000-$8fff</CODE>), so you can use their fields directly in optimized way.Please see <CODE>gsym.h</CODE> and find them. All structures are defined in <CODE>gstruct.h</CODE> and you mayfind also some comments there.</P><H2><A NAME="ss4.1">4.1</A> <A HREF="geos.html#toc4.1">Graphics Structures</A></H2><H3>pixel</H3><P>One simple structure describing a point on the screen.</P><H3>fontdesc</H3><P>This structure describes a font in one pointsize. There is current font - <CODE>struct fontdesc</CODE>bound to <CODE>curFontDesc</CODE>. You can also force GEOS to use your own fonts by calling<CODE>LoadCharSet</CODE>. You just need to open a VLIR font file and load one record - one pointsize -somewhere. At the start of this area you already have all data for <CODE>fontdesc</CODE> so you canpass a pointer to the load adress of that pointsize to <CODE>LoadCharSet</CODE>. (Note that althoughit has 'Load' in the name, that function loads only GEOS internal data structures, not datafrom disk).</P><H3>window</H3><P>This widely used structure holds description of a region of the screen. It describes top-left andbottom-right corners of a window.</P><H3>iconpic</H3><P>Maybe the name isn't the best - it has nothing with <CODE>DoIcons</CODE> but with bitmap functions -<CODE>BitmapUp</CODE> for example. This structure holds parameters needed to properly decode and showa bitmap on the screen. Bitmap has to be encoded - if you have some non-GEOS bitmaps simplyconvert them to Photo Scraps - this is the format used by all GEOS bitmap functions - <CODE>DoIcons</CODE>too.</P><H2><A NAME="ss4.2">4.2</A> <A HREF="geos.html#toc4.2">Icons</A></H2><P>These structures describe click boxes (icons) that can be placed on screen or in a dialog box.</P><H3>icondef</H3><P>This is the definition of a single click box. Please see <CODE>gstruct.h</CODE> for description of its fields.</P><H3>icontab</H3><P>This is toplevel description of icons to be placed and enabled on the screen. This structurehas following fields:<UL><LI><CODE>char number</CODE> - total number of icons declared here</LI><LI><CODE>struct pixel mousepos</CODE> - after finishing <CODE>DoIcons</CODE> mouse pointer will be placed inthis point allowing you to have hint for user what is default action</LI><LI><CODE>struct icondef tab[]</CODE> - this table of size equal to <CODE>icontab.number</CODE> containsdescriptions for all icons</LI></UL></P><H2><A NAME="ss4.3">4.3</A> <A HREF="geos.html#toc4.3">File and Disk</A></H2><H3>tr_se</H3><P>This simple structure holds track and sector number of something. Do not expect the track to bein range 1-35, as GEOS can support many various and weird devices. For example my C128 256Kexpansion is utilized as RAMDisk with layout of 4 tracks 128 sectors each. However assuming thattrack number equal to 0 is illegal might be wise.</P><H3>f_date</H3><P>This is placeholder for file datestamp. This structure is also present in <CODE>struct filehandle</CODE>.GEOS is not Y2K compliant, so if current file has in <CODE>filehandle.date.year</CODE> value less than 86you can safely assume that it is e.g. 2004 and not 1904.</P><H3>filehandle</H3><P>This is main file descriptor. It is either entry in the directory (returned from file functions)or its copy in <CODE>dirEntryBuf</CODE>. This is optimized so you can safely get to the file's year e.g.by testing <CODE>dirEntryBuf.date.year</CODE> - it will be compiled to simple <CODE>LDA, STA</CODE>.</P><H3>fileheader</H3><P>This structure holds fileheader description. You can load file's header into <CODE>fileHeader</CODE>fixed area using <CODE>GetFHdrInfo</CODE>. (note that <CODE>fileHeader</CODE> is a place in memory while<CODE>fileheader</CODE> is a structure).You will also need own fileheader for <CODE>SaveFile</CODE>.</P><H2><A NAME="ss4.4">4.4</A> <A HREF="geos.html#toc4.4">System Structures</A></H2><H3>s_date</H3><P>This structure is defined only for <CODE>system_date</CODE>. It is slightly different from <CODE>f_date</CODE>so I prepared this one. You can e.g. get or set current time using <CODE>system_date.s_hour</CODE> and<CODE>system_date.s_minute</CODE>. Accesses to these will be optimized to simple <CODE>LDA</CODE> and <CODE>STA</CODE>pair.</P><H3>process</H3><P>You should declare a table of that type to prepare data for <CODE>InitProcesses</CODE>. The maximum numberof processes is 20, and the last entry has to be equal to <CODE>{NULL,NULL}</CODE>, so this table may holdonly 21 entries. The first member of this structure (<CODE>pointer</CODE>) holds the pointer to calledfunction (void returning void), you will probably have to cast that pointer into <CODE>unsigned int</CODE>.The second field <CODE>jiffies</CODE> holds the amount of time between calls to that function.On PAL systems there are 50 jiffies per second, while NTSC have 60 of them.</P><H2><A NAME="ss4.5">4.5</A> <A HREF="geos.html#toc4.5">Few thing in detail...</A></H2><P>GEOSLib uses cc65 non-ANSI extensions to easily initialize data in memory. This is done with akind of array of unspecified length and unspecified type. Here is how it goes:<BLOCKQUOTE><CODE><PRE>void example = { (char)3, (unsigned)3, (char)0 };</PRE></CODE></BLOCKQUOTE>Which will be compiled to following string of bytes:<BLOCKQUOTE><CODE><PRE>_example: .byte 3 .word 3 .byte 0</PRE></CODE></BLOCKQUOTE>As you see this way it is possible to define data of any type in any order. You must remember tocast each member to proper type.</P><H3>DoMenu structure</H3><P><CODE>DoMenu</CODE> is responsible for everything concerned with menu processing. Many, many GEOS programsare just initializing screen and menu and exit to <CODE>MainLoop</CODE>. In GEOSLib it is the same asreturning from <CODE>main</CODE> function without using <CODE>exit(0)</CODE>.</P><P>Menu is described by two types of data - menu descriptors and menu items. Descriptor containsinformation about following menu items, and items are containing names of entries and eitherpointers to functions to execute or, in case of nested menus, pointers to submenu descriptors.Note that submenu descriptor can be top-level descriptor, there's no difference in structure,just in the content.</P><P>Here is how single descriptor looks like:<BLOCKQUOTE><CODE><PRE>void myMenu = { (char)top, (char)bottom, // this is the size of the menubox (unsigned)left, (unsigned)right, // counting all items in current descriptor (char)number_of_items | type_of_menu, // number of following items ORed with // type of this menu, it can be either // HORIZONTAL or VERTICAL if you will have also bit 6 set then menu won't be closed // after moving mouse pointer outside the menubox. You can have at most 31 items.</PRE></CODE></BLOCKQUOTE>This is followed by <CODE>number_of_items</CODE> of following item description.<BLOCKQUOTE><CODE><PRE> ... "menuitemname", (char)item_type, (unsigned)pointer, "nextitemname", (char)item_type, (unsigned)pointer, ... "lastitemname", (char)item_type, (unsigned)pointer }; // Note that there isn't ending <tt/NULL/ or something like that.</PRE></CODE></BLOCKQUOTE><CODE>pointer</CODE> is a pointer to something, what it points for depends from <CODE>item_type</CODE>. This onecan have following values:</P><P><CODE>MENU_ACTION</CODE> - a function pointed by <CODE>pointer</CODE> will be called after clicking on menu item</P>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -