cool-bun-demo/other_blitter.c

125 lines
3.3 KiB
C
Raw Normal View History

2024-05-02 16:52:06 +00:00
void BlitFirstPlaneFirstRowToSecondRow(struct ScreenSetup *screenSetup) {
unsigned char *source = screenSetup->memoryStart;
unsigned char *target = (screenSetup->memoryStart + SCREEN_WIDTH * 2 / 8);
custom.bltcon0 = 0x09f0;
custom.bltcon1 = 0;
custom.bltapt = source;
custom.bltdpt = target;
custom.bltamod = 0;
custom.bltdmod = 0;
custom.bltafwm = 0xffff;
custom.bltalwm = 0xffff;
custom.bltsize = 0x0041;
}
void BlitShiftFirstPlaneFirstRowToThirdRow(struct ScreenSetup *screenSetup) {
unsigned char *source = screenSetup->memoryStart;
unsigned char *target = (screenSetup->memoryStart + SCREEN_WIDTH * 4 / 8);
custom.bltcon0 = 0x49f0;
custom.bltcon1 = 0;
custom.bltapt = source;
custom.bltdpt = target;
custom.bltamod = 0;
custom.bltdmod = 0;
custom.bltafwm = 0xffff;
custom.bltalwm = 0xffff;
custom.bltsize = 0x0041;
}
void BlitWithMaskInBChannel(struct ScreenSetup *screenSetup) {
unsigned char *source = screenSetup->memoryStart;
unsigned char *target = (screenSetup->memoryStart + SCREEN_WIDTH * 6 / 8);
unsigned char *mask = (screenSetup->memoryStart + 8);
// a is source
// b is mask
// d is destination
// so I want AB
custom.bltcon0 = 0x0dc0;
custom.bltcon1 = 0;
custom.bltapt = mask;
custom.bltbpt = source;
custom.bltdpt = target;
custom.bltamod = 0;
custom.bltdmod = 0;
custom.bltafwm = 0xffff;
custom.bltalwm = 0xffff;
custom.bltsize = 0x0041;
}
void BlitWithMaskInBDataInCChannel(struct ScreenSetup *screenSetup) {
unsigned char *source = screenSetup->memoryStart;
unsigned char *target = (screenSetup->memoryStart + SCREEN_WIDTH * 8 / 8);
unsigned char *mask = (screenSetup->memoryStart + 8);
unsigned char *background = (screenSetup->memoryStart + 16);
// a is source
// b is mask
// c is background
// d is destination
// so I want AB+`AC
custom.bltcon0 = 0x0fca;
custom.bltcon1 = 0;
custom.bltapt = mask;
custom.bltbpt = source;
custom.bltcpt = background;
custom.bltdpt = target;
custom.bltamod = 0;
custom.bltbmod = 0;
custom.bltcmod = SCREEN_WIDTH / 8;
custom.bltdmod = SCREEN_WIDTH / 8;
custom.bltafwm = 0xffff;
custom.bltalwm = 0xffff;
custom.bltsize = 0x0041;
}
void BlitDrawHorizontalLine(struct ScreenSetup *screenSetup) {
// i want to draw a line from 20,20 to 50,80
// i need to get dx and dy
// dx is 30, dy is 60
// the shift value is 20 mod 15 = 5
// a data register gets $8000
// b data register gets $ffff
// text shift is 0
// c and d pointers get the word containing the first pixel, so
// screenSetup->memoryStart + 320 * 20 / 8 + 2
// module registers get width of bitplane in bytes
// blit height is dx + 1 so 31
// blit width = 2
// logic is ab+'a, so 6, 7, 2, 3, 1, 0
char *target = screenSetup->memoryStart + (320 * 20 + 20) / 8;
int dx = 10;
int dy = 60;
int tmp;
if (dx < dy) {
tmp = dx;
dx = dy;
dy = tmp;
}
custom.bltcon0 = (5 << 12) + (11 << 8) + 0xca;
custom.bltcon1 = 1;
custom.bltapt = 4 * dy - 2 * dx;
custom.bltadat = 0x8000;
custom.bltbdat = 0xffff;
custom.bltcpt = target;
custom.bltdpt = target;
custom.bltamod = 4 * (dy - dx);
custom.bltbmod = 4 * dy;
custom.bltcmod = 320 / 8;
custom.bltdmod = 320 / 8;
custom.bltafwm = 0xffff;
custom.bltalwm = 0xffff;
custom.bltsize = 0x02 + (dx + 1 << 7);
}