struct BlitDrawLineSetup { int dx, dy; int sud, sul, aul, accumulator, sign; int bltapt; int bltamod; int bltbmod; unsigned char *target; }; void BlitDrawLine( struct ScreenSetup *screenSetup, struct BlitDrawLineSetup *setup, uint16_t sx, uint16_t sy, uint16_t ex, uint16_t ey, uint8_t color ) { unsigned char *target = screenSetup->memoryStart + (((screenSetup->width * sy + sx) >> 3) & 0xfffe); int i; setup->dx = ex - sx; setup->dy = ey - sy; if (setup->dx == 0 && setup->dy == 0) return; setup->sud = abs(setup->dy) < abs(setup->dx); if (!setup->sud) { i = setup->dx; setup->dx = setup->dy; setup->dy = i; } setup->sul = setup->dy < 0; setup->dy = abs(setup->dy); setup->aul = setup->dx < 0; setup->dx = abs(setup->dx); setup->accumulator = 4 * setup->dy - 2 * setup->dx; setup->sign = setup->accumulator < 0; for (i = 0; i < screenSetup->bitplanes; ++i) { custom.bltadat = 0x8000; custom.bltbdat = color & 1 == 1 ? 0xffff : 0; custom.bltafwm = 0xffff; custom.bltalwm = 0xffff; custom.bltamod = 4 * (setup->dy - setup->dx); custom.bltbmod = 4 * setup->dy; custom.bltcmod = screenSetup->width / 8; custom.bltdmod = screenSetup->width / 8; custom.bltapt = setup->accumulator; custom.bltcpt = target + screenSetup->nextBitplaneAdvance * i; custom.bltdpt = target + screenSetup->nextBitplaneAdvance * i; custom.bltcon0 = ((sx % 16) << 12) + (11 << 8) + 0xca; custom.bltcon1 = 1 + (setup->aul << 2) + (setup->sul << 3) + (setup->sud << 4) + (setup->sign << 6); custom.bltsize = 0x02 + ((setup->dx + 1) << 6); WaitBlit(); color >>= 1; } }