Re: [cc65] Please be patient... More questions

From: Payton Byrd <plbyrd1gmail.com>
Date: 2010-04-22 23:16:02
On Thu, Apr 22, 2010 at 3:05 PM, Ullrich von Bassewitz <uz@musoftware.de>wrote:

>
> Oliver has answered most questions already, but let me add an example for
> your
> problem:
>
> On Wed, Apr 21, 2010 at 09:30:03PM -0500, Payton Byrd wrote:
> > So, after some digging in the C128 PRG, I found the SCRORG kernel routine
> > which does exactly what I want.  It takes the current mode and places it
> in
> > the accumulator.  Superb.  Now, I want to create a method to call the
> kernel
> > routine and return the value in the accumulator such as:
> >
> > unsigned char getScreenSize(void);
>
>     #define SCRORG 0xFFED
>
>    unsigned char getScreenSize (void)
>    {
>        __asm__ ("jsr %w", SCRORG);
>        __asm__ ("ldx #$00");
>        return __AX__;
>    }
>
> If you remember not to use the high byte when calling the function, you can
> even go without inline assembly:
>
>    #define SCRORG 0xFFED
>    #define getScreenSize   ((unsigned char (*)()) (SCRORG))
>
> then, use it as you would do with a function:
>
>    unsigned char foo = getScreenSize ();
>

Uz,

Thank you so much for the succinct response that exactly addresses what I
was trying to do.  I'm wondering if there already exists a library of C128
kernel routines that are created in such a manner as your second example?  I
know it's best to use the standard libraries where possible, but for
completeness for the individual platforms it seems that such libraries for
each target machine would be invaluable.  It would definitely aid those of
us who are not quite adept at assembler but have lots of experience with
c-based languages to get the most out of the cc65 stack.  If the answer is
that nobody has created such a library for the c128 then I'll volunteer to
do so as I think it'd be a great learning experience.

----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Thu Apr 22 23:16:29 2010

This archive was generated by hypermail 2.1.8 : 2010-04-22 23:16:32 CEST