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

From: Ullrich von Bassewitz <uz1musoftware.de>
Date: 2010-04-22 22:05:20
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 ();

Regards


        Uz


-- 
Ullrich von Bassewitz                                  uz@musoftware.de
----------------------------------------------------------------------
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 22:05:27 2010

This archive was generated by hypermail 2.1.8 : 2010-04-22 22:05:29 CEST