[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Quick question about AUXMOVE



"Steve Nickolas" <usotsuki@buric.co> asked:

> Is there anything special (e.g., regarding banking in the ROMs a certain 
> way) that I have to know before I "jsr $C311" ?

Not anything especially special (the usual things) except not to overwrite 
anything when you are moving your data around and to make sure that you are 
moving in the  desired direction... see my notes below... don't move AUX to 
MAIN when you  intended to move MAIN to AUX, etc. but I think you already 
know these cautionaries.  Anyway have a look at how I handle this in my 
Aztec C  programs from the ancient past... I list a couple of my library 
routines at  the end of this post. The Apple II memory map that I use for my 
ProDOS SYS  programs showing both main and aux memory on the Apple //e is 
illustrated at  the link below:

http://www.appleoldies.ca/apmap.gif

>I plan to fill auxmem with some data using my usual "page in the auxmem for 
>writing only, then use an internal routine to write it out" method, but 
>using AUXMOVE certainly looks like a less hairy way to get it back.

AUXMOVE is painless and efficient for sure. Here's my core routines from my 
Aztec C library... Source code, compiler, and working programs available in 
http://www.aztecmuseum.ca/Apple33.zip at the Aztec C website.

/* move a block of data from main to auxiliary memory */
/* do an absolute ml call */

#define A1L  0x3c
#define A1H  0x3d
#define A2L  0x3e
#define A2H  0x3f
#define A4L  0x42
#define A4H  0x43

maintoaux(src1,src2,dest)
unsigned int src1,src2,dest;
{

    /* load the registers and do the call */
    unsigned char *ptr=(unsigned char *)A1L;

    *ptr++=(unsigned char)(src1&0xff);
    *ptr++=(unsigned char)(src1>>8);
    *ptr++=(unsigned char)(src2&0xff);
    *ptr  =(unsigned char)(src2>>8);

     ptr=(unsigned char *)A4L;
     *ptr++=(unsigned char)(dest&0xff);
     *ptr  =(unsigned char)(dest>>8);
#asm
    sec
    jsr  $c311
#endasm

}

/* move a block of data from auxiliary to main memory */
/* do an absolute ml call */

#define A1L  0x3c
#define A1H  0x3d
#define A2L  0x3e
#define A2H  0x3f
#define A4L  0x42
#define A4H  0x43

auxtomain(src1,src2,dest)
unsigned int src1,src2,dest;
{

    /* load the registers and do the call */
    unsigned char *ptr=(unsigned char *)A1L;

    *ptr++=(unsigned char)(src1&0xff);
    *ptr++=(unsigned char)(src1>>8);
    *ptr++=(unsigned char)(src2&0xff);
    *ptr  =(unsigned char)(src2>>8);

     ptr=(unsigned char *)A4L;
     *ptr++=(unsigned char)(dest&0xff);
     *ptr  =(unsigned char)(dest>>8);
#asm
    clc
    jsr  $c311
#endasm

}

You will note from the code above in either case that the same registers are 
loaded with the addresses of the beginning and end of the memory block you 
are moving and the destination address before making the call. The direction 
of the move (from main to aux or from aux to main) is determined by  the 
set-up for the call noted in the asm blocks in the code above... sec moves 
from main to aux and clc moves from aux to main.

Nothing especially special like I said... also works great for storing 
graphics and paging them in and out of screen memory...

Bill