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

From: Payton Byrd <plbyrd1gmail.com>
Date: 2010-04-23 00:30:06
On Thu, Apr 22, 2010 at 5:16 PM, Payton Byrd <plbyrd@gmail.com> wrote:

> OK, I got Uz's example working and now I'm trying to push the envelope a
> big.  The SCRORG routine sets the X and Y registers with the dimensions of
> the screen in addition to setting the width in the Accumulator.  So, I've
> updated my method signature to:
>
> unsigned char getScreenSize(
> unsigned char* x,
> unsigned char* y)
>
> After calling the kernel routine, what is the preferred method for reading
> the values of the registers into variables (in this case the x and y
> parameters)?  I found the *regs* struct but it doesn't seem to be used in
> any of the examples, so I'm not quite sure what's the best way to use it.
>  My initial attempts have failed (I'll save posting the code to avoid
> massive embarrassment at the complete fail).
>

I've managed to figure this out using the _sys function.  Just for
posterity's sake, here's my solution:

#if defined(__C128__)
unsigned char getScreenSize(
 unsigned char* x,
unsigned char* y)
{
 struct regs r;
r.pc = SCRORG;

_sys(&r);
 (*x) = r.x + 1;
(*y) = r.y + 1;

return r.a;
}
#endif

-- 
Payton Byrd
<http://www.paytonbyrd.com>
<http://it.toolbox.com/blogs/paytonbyrd>

----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Fri Apr 23 00:30:51 2010

This archive was generated by hypermail 2.1.8 : 2010-04-23 00:30:53 CEST