-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce BlitterOr operation (backported from b23d3a3)
- Loading branch information
Showing
4 changed files
with
75 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#include <blitter.h> | ||
|
||
void BitmapOr(const BitmapT *dst, u_short x, u_short y, const BitmapT *src) { | ||
short i, n = min(dst->depth, src->depth); | ||
|
||
BlitterOrSetup(dst, x, y, src); | ||
for (i = 0; i < n; i++) | ||
BlitterOrStart(i, i); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#include <blitter.h> | ||
|
||
typedef struct { | ||
const BitmapT *src; | ||
const BitmapT *dst; | ||
u_int start; | ||
u_short size; | ||
} StateT; | ||
|
||
static StateT state[1]; | ||
|
||
/* Supports any (x, y) and any source bitmap width. */ | ||
void BlitterOrSetup(const BitmapT *dst, u_short x, u_short y, | ||
const BitmapT *src) | ||
{ | ||
/* Calculate real blit width. It can be greater than src->bytesPerRow! */ | ||
u_short width = (x & 15) + src->width; | ||
u_short bytesPerRow = ((width + 15) & ~15) >> 3; | ||
u_short srcmod = src->bytesPerRow - bytesPerRow; | ||
u_short dstmod = dst->bytesPerRow - bytesPerRow; | ||
u_short bltafwm = FirstWordMask[x & 15]; | ||
u_short bltalwm = LastWordMask[width & 15]; | ||
u_short bltshift = rorw(x & 15, 4); | ||
|
||
state->src = src; | ||
state->dst = dst; | ||
state->start = ((x & ~15) >> 3) + y * dst->bytesPerRow; | ||
state->size = (src->height << 6) | (bytesPerRow >> 1); | ||
|
||
WaitBlitter(); | ||
|
||
custom->bltcon0 = A_OR_B | (SRCA | SRCB | DEST) | bltshift; | ||
custom->bltcon1 = 0; | ||
custom->bltafwm = bltafwm; | ||
custom->bltalwm = bltalwm; | ||
custom->bltamod = srcmod; | ||
custom->bltbmod = dstmod; | ||
custom->bltdmod = dstmod; | ||
} | ||
|
||
void BlitterOrStart(short dstbpl, short srcbpl) { | ||
void *srcbpt = state->src->planes[srcbpl]; | ||
void *dstbpt = state->dst->planes[dstbpl] + state->start; | ||
u_short bltsize = state->size; | ||
|
||
WaitBlitter(); | ||
|
||
custom->bltapt = srcbpt; | ||
custom->bltbpt = dstbpt; | ||
custom->bltdpt = dstbpt; | ||
custom->bltsize = bltsize; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters