Re: [cc65] interrupt routine hooking in c

From: Groepaz <groepaz1gmx.net>
Date: 2009-01-04 01:43:23
On Samstag 03 Januar 2009, Tachdaun wrote:
> Hi, I may be trying to do something impossible, but, is it ok if I try
> to do this?
>
> unsigned char a;
> void func()
> {
>     ++a;
> }
> void main()
> {
>     a = 0;
>      //*( (unsigned char*) 0xFFFA ) = (unsigned char*) func;
>     asm( "lda %v", func );
>     asm( "sta $FFFA" );
> }
> //--------------------
> $FFFA is the memory address in NES with a pointer to a routine that will
> be called on each vertical blank.
> ( I'm aware of the existance of waitvblank(), I just want to know if I
> can do this with interrupts.)
> I'm trying to hook my func() there, I tried to do it with the commented
> line in pure c and didn't work.
> The asm code doesn't do it either. am I doing something wrong from the
> point of view of the 6502?
> ( If my error is just of NES architecture understanding, as it's not the
> main subject of this list, I may find out elsewhere,
> but if the error is of 6502 or cc65/ca665 understanding, please let me
> know.)

first of all, the function pointer is 16bit and goes into two adresses, fffa 
and fffb...

then you probably have to enable vblank interupts in some control register of 
the videochip, check nes docs :)

-- 

http://www.hitmen-console.org    http://magicdisk.untergrund.net
http://www.pokefinder.org        http://ftp.pokefinder.org

Der Vorteil der Klugheit besteht darin, dass man sich dumm stellen kann. Das 
Gegenteil is schon schwieriger. 
<Kurt Tucholsky>

----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Sun Jan 4 01:43:24 2009

This archive was generated by hypermail 2.1.8 : 2009-01-04 01:43:26 CET