Triggering interrupts in Hatari

A forum about the Hatari ST/STE/Falcon emulator - the current version is v2.1.0

Moderators: simonsunnyboy, thothy, Moderator Team

User avatar
Foxie
Captain Atari
Captain Atari
Posts: 354
Joined: Wed Feb 03, 2016 7:12 pm

Triggering interrupts in Hatari

Postby Foxie » Thu Jan 25, 2018 12:34 am

I'm reverse-engineering the driver for a printer port device, and as such I want to generate acknowledgement interrupts on the busy pin in response to data written.

So far, I've added the following line to PSG_Set_DataRegister() in psg.c:

MFP_GPIP_Set_Line_Input(0, ((val & 0x20) >> 5) ^ 1 );

This loops the strobe pin back to the busy pin with inversion.

This isn't working 100% correctly with the driver - the driver does not expect an interrupt for every byte. Instead, I need to generate an interrupt 0.32ms after the byte is written. Or alternatively, generate periodic 0.32ms interrupts constantly (I'm not sure which the driver needs).

What's the best way to go about this? I'm not familiar with the Hatari source and its interrupt handling. Is there a function I can call to set an interrupt n cycles away in the future?

Thanks for any help ^.^

User avatar
Eero Tamminen
Atari God
Atari God
Posts: 1746
Joined: Sun Jul 31, 2011 1:11 pm

Re: Triggering interrupts in Hatari

Postby Eero Tamminen » Thu Jan 25, 2018 8:30 pm

See CycInt_AddRelativeInterruptWithOffset() in cycInt.c.

User avatar
Foxie
Captain Atari
Captain Atari
Posts: 354
Joined: Wed Feb 03, 2016 7:12 pm

Re: Triggering interrupts in Hatari

Postby Foxie » Fri Jan 26, 2018 3:38 am

Eero Tamminen wrote:See CycInt_AddRelativeInterruptWithOffset() in cycInt.c.


Thanks, but I'm having some difficulty figuring out how to use that. It needs a "handler" passed to it, but none of the defined values in cycint.h are suitable. It has an ACIA_IKBD interrupt, but not a busy pin interrupt.

Is there a function somewhere in Hatari which gets called every scanline? Or a loop which goes through emulating each scanline? I could hook into that and dispatch interrupts after n scanlines. I just need to know where to look. I imagine it must be the same place where the INTERRUPT_VIDEO_HBL gets dispatched.

User avatar
Eero Tamminen
Atari God
Atari God
Posts: 1746
Joined: Sun Jul 31, 2011 1:11 pm

Re: Triggering interrupts in Hatari

Postby Eero Tamminen » Fri Jan 26, 2018 8:34 pm

It's the HBL interrupt handler "Video_InterruptHandler_HBL" in video.c.

User avatar
Foxie
Captain Atari
Captain Atari
Posts: 354
Joined: Wed Feb 03, 2016 7:12 pm

Re: Triggering interrupts in Hatari

Postby Foxie » Sat Jan 27, 2018 4:05 am

Eero Tamminen wrote:It's the HBL interrupt handler "Video_InterruptHandler_HBL" in video.c.


This is exactly what I need. Thanks ^.^


Social Media

     

Return to “Hatari”

Who is online

Users browsing this forum: No registered users and 3 guests