Re: [cc65] Graphics library

Date view Thread view Subject view

From: Ullrich von Bassewitz (uz_at_musoftware.de)
Date: 2001-08-13 15:58:15


On Mon, Aug 13, 2001 at 03:31:56PM +0200, daniel pralle wrote:
> I could help you porting the C64-lib to the atari.

There is currently no library to port. But your input would be valuable for
the design of the API. My current idea is to use something similar to the old
borland graphics interface for DOS:

    unsigned char initgraph (unsigned char mode);
    /* Initialize the graphics screen to the given mode, return the new mode.
     * Not all modes are available on all systems, check the returned mode
     * to see if the initialization was successful.
     */

    void closegraph (void);
    /* End graphics mode, switch back to text mode */
	
    void cleargraphscreen (void);
    /* Clear the screen */

    unsigned char getgraphmode (void);
    /* Return the current graphics mode */

    void setcolor (unsigned char color);
    /* Set the current drawing color */

    unsigned char getcolor (void);
    /* Return the current drawing color */

    unsigned char getmaxcolor (void);
    /* Return the maximum supported color number (the number of colors would
     * then be getmaxcolor()+1).
     */

    unsigned getmaxx (void);
    /* Return the maximum x coordinate. The resolution in x direction is
     * getmaxx() + 1
     */

    unsigned getmaxy (void);
    /* Return the maximum y coordinate. The resolution in y direction is
     * getmaxy() + 1
     */

    unsigned char getpixel (int x, int y);
    /* Get the color value of a pixel */

    void putpixel (int x, int y);
    /* Plot a point in the current drawing color */

    void line (int x1, int y1, int x2, int y2);
    /* Draw a line in the current drawing color */

    void circle (int x, int y, unsigned radius);
    /* Draw a circle in the current drawing color */

    void outtext (int x, int y, const char* text);
    /* Print a text in graphics mode */

...and maybe some more routines like ellipse, arc, settextstyle and so on.

Having different line styles would be nice, but the implementation is rather
complex and makes the whole library larger, so I think it's ok to support just
lines without patterns in a first step. Other optional functions that may be
added later:

    void setwritemode (unsigned char mode);
    /* Set a plot mode (PUT, XOR, OR, AND, ...) */

    void setfillpattern (unsigned char pattern);
    /* Set a pattern for area fills */

    void bar (unsigned x1, unsigned y1, unsigned x2, unsigned y2);
    /* Draw a bar (a filled rectangle) using the current fill pattern */

    ....

Which colors are supported depends on the machine and the graphics mode. The
getmax..() functions are used to query the mode settings at runtime.

Using zero as the default text mode will make it easy to check for errors and
switch back to text mode without knowing which grahpics mode is active. Having
loadable drivers may be an idea for machines with lots of different graphics
modes, but the implementation is complex, and I would prefer a simple but
working solution to a high tech one fits all approach that will never get
done, because it's too complex.

Regards
			  

        Uz


--
Ullrich von Bassewitz                                  uz_at_musoftware.de
----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo_at_musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.


Date view Thread view Subject view

This archive was generated by hypermail 2.1.3 : 2001-12-14 22:05:41 CET