|
| 1 | +#include <blitter.h> |
| 2 | + |
| 3 | +typedef struct { |
| 4 | + const BitmapT *src; |
| 5 | + const BitmapT *dst; |
| 6 | + u_int start; |
| 7 | + u_short size; |
| 8 | +} StateT; |
| 9 | + |
| 10 | +static StateT state[1]; |
| 11 | + |
| 12 | +/* Supports any (x, y) and any source bitmap width. */ |
| 13 | +void BlitterOrSetup(const BitmapT *dst, u_short x, u_short y, |
| 14 | + const BitmapT *src) |
| 15 | +{ |
| 16 | + /* Calculate real blit width. It can be greater than src->bytesPerRow! */ |
| 17 | + u_short width = (x & 15) + src->width; |
| 18 | + u_short bytesPerRow = ((width + 15) & ~15) >> 3; |
| 19 | + u_short srcmod = src->bytesPerRow - bytesPerRow; |
| 20 | + u_short dstmod = dst->bytesPerRow - bytesPerRow; |
| 21 | + u_short bltafwm = FirstWordMask[x & 15]; |
| 22 | + u_short bltalwm = LastWordMask[width & 15]; |
| 23 | + u_short bltshift = rorw(x & 15, 4); |
| 24 | + |
| 25 | + state->src = src; |
| 26 | + state->dst = dst; |
| 27 | + state->start = ((x & ~15) >> 3) + y * dst->bytesPerRow; |
| 28 | + state->size = (src->height << 6) | (bytesPerRow >> 1); |
| 29 | + |
| 30 | + WaitBlitter(); |
| 31 | + |
| 32 | + custom->bltcon0 = A_OR_B | (SRCA | SRCB | DEST) | bltshift; |
| 33 | + custom->bltcon1 = 0; |
| 34 | + custom->bltafwm = bltafwm; |
| 35 | + custom->bltalwm = bltalwm; |
| 36 | + custom->bltamod = srcmod; |
| 37 | + custom->bltbmod = dstmod; |
| 38 | + custom->bltdmod = dstmod; |
| 39 | +} |
| 40 | + |
| 41 | +void BlitterOrStart(short dstbpl, short srcbpl) { |
| 42 | + void *srcbpt = state->src->planes[srcbpl]; |
| 43 | + void *dstbpt = state->dst->planes[dstbpl] + state->start; |
| 44 | + u_short bltsize = state->size; |
| 45 | + |
| 46 | + WaitBlitter(); |
| 47 | + |
| 48 | + custom->bltapt = srcbpt; |
| 49 | + custom->bltbpt = dstbpt; |
| 50 | + custom->bltdpt = dstbpt; |
| 51 | + custom->bltsize = bltsize; |
| 52 | +} |
0 commit comments