Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Blitting operations: blit Bob, store and restore background. */
- #include <hardware/blit.h>
- #include <hardware/custom.h>
- #include <graphics/gfx.h>
- #include <clib/graphics_protos.h>
- #include "Blit.h"
- extern __far struct Custom custom;
- /* Prepare Bob mask. Mask must be cleared. */
- void prepBobMask(struct BitMap *bob, UBYTE *mask)
- {
- /* Prepare variables */
- /* D = A + B */
- UWORD bltcon0 = SRCA | SRCB | DEST | ABC | ABNC | ANBC | ANBNC | NABC | NABNC;
- UWORD bltcon1 = 0;
- UWORD bpr = bob->BytesPerRow;
- UWORD bltawm = 0xffff;
- UWORD bltsizv = bob->Rows;
- UWORD bltsizh = bpr >> 1;
- UWORD depth = bob->Depth;
- UBYTE *bobplane;
- UWORD i;
- OwnBlitter();
- for (i = 0; i < depth; i++)
- {
- bobplane = bob->Planes[i];
- WaitBlit();
- custom.bltcon0 = bltcon0;
- custom.bltcon1 = bltcon1;
- custom.bltapt = bobplane;
- custom.bltbpt = mask;
- custom.bltdpt = mask;
- custom.bltamod = 0;
- custom.bltbmod = 0;
- custom.bltdmod = 0;
- custom.bltafwm = bltawm;
- custom.bltalwm = bltawm;
- custom.bltsize = (bltsizv << HSIZEBITS) | bltsizh;
- }
- DisownBlitter();
- }
- /* Blit Bob into background */
- void blitBob(struct BitMap *bob, UBYTE *mask, struct BitMap *back, WORD x, WORD y)
- {
- /* Prepare variables */
- UWORD shift = x & 15; /* Shift value */
- /* D = AB + aC */
- UWORD bltcon0 = SRCA | SRCB | SRCC | DEST | ABC | ABNC | NABC | NANBC | (shift << ASHIFTSHIFT);
- UWORD bltcon1 = (shift << BSHIFTSHIFT);
- UWORD bobbpr = bob->BytesPerRow;
- UWORD backbpr = back->BytesPerRow;
- UWORD backoffset = (y * backbpr) + ((x >> 4) << 1); /* Offset to destination place in bitplane */
- WORD bobmodulo = -2;
- WORD backmodulo = backbpr - bobbpr - 2;
- UWORD bltafwm = 0xffff;
- UWORD bltalwm = 0x0000;
- UWORD bltsizv = bob->Rows;
- UWORD bltsizh = (bobbpr >> 1) + 1;
- UWORD depth = bob->Depth;
- UBYTE *bobplane,
- *backplane;
- UWORD i;
- OwnBlitter();
- for (i = 0; i < depth; i++)
- {
- bobplane = bob->Planes[i];
- backplane = back->Planes[i] + backoffset;
- WaitBlit();
- custom.bltcon0 = bltcon0;
- custom.bltcon1 = bltcon1;
- custom.bltapt = mask;
- custom.bltbpt = bobplane;
- custom.bltcpt = backplane;
- custom.bltdpt = backplane;
- custom.bltamod = bobmodulo;
- custom.bltbmod = bobmodulo;
- custom.bltcmod = backmodulo;
- custom.bltdmod = backmodulo;
- custom.bltafwm = bltafwm;
- custom.bltalwm = bltalwm;
- custom.bltsize = (bltsizv << HSIZEBITS) | bltsizh;
- }
- DisownBlitter();
- }
- /* Store/Re-store Bob background */
- void storeBack(struct BitMap *back, WORD x, WORD y, struct BitMap *store, UBYTE op)
- {
- /* Prepare variables */
- /* D = A */
- UWORD bltcon0 = SRCA | DEST | ABC | ABNC | ANBC | ANBNC;
- UWORD bltcon1 = 0;
- UWORD backbpr = back->BytesPerRow;
- UWORD backoffset = (y * backbpr) + ((x >> 4) << 1);
- UWORD storeoff = 0;
- UWORD storebpr = store->BytesPerRow;
- WORD backmodulo = backbpr - storebpr;
- WORD storemod = 0;
- UWORD bltawm = 0xffff;
- UWORD bltsizv = store->Rows;
- UWORD bltsizh = storebpr >> 1;
- UWORD depth = store->Depth;
- UBYTE *backplane,
- *storeplane;
- UWORD i;
- if (op == RESTORE)
- {
- /* Re-storing: swap pointers and modulos */
- struct BitMap *auxbm;
- WORD auxmod;
- UWORD auxoff;
- auxbm = back;
- back = store;
- store = auxbm;
- auxmod = backmodulo;
- backmodulo = storemod;
- storemod = auxmod;
- auxoff = backoffset;
- backoffset = storeoff;
- storeoff = auxoff;
- }
- OwnBlitter();
- for (i = 0; i < depth; i++)
- {
- backplane = back->Planes[i] + backoffset;
- storeplane = store->Planes[i] + storeoff;
- WaitBlit();
- custom.bltcon0 = bltcon0;
- custom.bltcon1 = bltcon1;
- custom.bltapt = backplane;
- custom.bltdpt = storeplane;
- custom.bltamod = backmodulo;
- custom.bltdmod = storemod;
- custom.bltafwm = bltawm;
- custom.bltalwm = bltawm;
- custom.bltsize = (bltsizv << HSIZEBITS) | bltsizh;
- }
- DisownBlitter();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement