Page 1 of 1

Keeping CC65 interrupts alive when calling MADS library

Posted: Wed Oct 04, 2017 12:50 pm
by 8bit-Dude
Hey Guyz, I have another problem for which I need a bit of advice:

(1) I compiled with MADS a routine to display interlaced graphics for ATARI (multiplegraphicsmode).

(2) I then merged the MADS binaries with my main CC65 compiled program (using merge-xex.exe).

(3) The CC65 program autoruns, loads the image in memory, and then calls the MADS routine with __asm__("jsr $8000");

(4) The image gets displayed, BUT in the process the CC65 interrupts are killed (keyboard, timers...).

Could someone kindly advise me on how I can setup the interlace interrupt without killing the CC65 interrupts?

(see attached code and ATR file demo)

In the following code, the second cgetc() is never executed.
If I remove that line, I can see the program progress to the next line and black out the screen.

Code: Select all

#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <conio.h>
#include <unistd.h>


void LoadBitmap(char *filename) 
{
	FILE* fp;
	
	// Open Map File
	fp = fopen(filename, "rb");	
    
    if (fp != 0) {
        printf("Loading...\n");
        fread((char*)(0x4100), 1, 0x1E00, fp);
        fclose(fp);
    } else {
        printf("File not found...\n");
    }
}

/*****************************************************************************/

int main (void)
{
    LoadBitmap("image.dat");
    printf("Ready to start MGM\n");
    cgetc (); 
    
    // Start MGM
    __asm__("jsr $8000"); 
    cgetc (); 
        
    // Black out the screen
    memset((char*)0x4100, 0, 0x1E00);
    cgetc (); 
        
    // Done
    return EXIT_SUCCESS;
}

Re: Keeping CC65 interrupts alive when calling MADS library

Posted: Wed Oct 04, 2017 2:22 pm
by EdwardianDuck
I'm not sure from reading your code, coupled with my relative inexperience (what you are doing is more sophisticated than anything I've tried), but I think because you are exiting the VBI with RTI rather than jumping to the documented OS entry points, you are bypassing the OS routines to scan the keyboard.

From De Re Atari, Chapter 8.
Quote:
Once you have decided whether your VBI routine should be immediate or deferred, you must place the routine in memory (page six is a good place), link it to the proper VBI routine, and modify the appropriate OS RAM vector to point to it. Terminate an immediate VBI routine with a JMP to $E45F. Terminate a deferred VBI routine with a JMP to $E462. If you want to bypass the OS VBI routine entirely (and thereby gain processing time), terminate your immediate VBI routine with a JMP to $E462.
Jeremy

[Edit]

The response on AtariAge to your question is more accurate than mine.

Re: Keeping CC65 interrupts alive when calling MADS library

Posted: Thu Oct 05, 2017 12:45 pm
by 8bit-Dude
Thx for the extra info Jeremy!
I also saw the reply on Atariage, this community is great for supporting new devs!