Skip to content

Instantly share code, notes, and snippets.

@tschak909

tschak909/blt.c

Created Aug 4, 2019
Embed
What would you like to do?
BLT COPY Example
/**
* BLT Copy example
*
* Author: Thomas Cherryhomes <thom.cherryhomes@gmail.com>
*/
#include <conio.h>
#include <i86.h>
#include <stdlib.h>
#include <string.h>
#include <libmindset_gfx.h>
#include "pacman.h"
unsigned short palette[16]={
0x0000, // Black
0x10C0, // Dark Blue
0x2018, // Dark Green
0x30D8, // Dark Cyan
0x4003, // Dark Red
0x5063, // Dark Magenta
0x601B, // Dark Yellow (brown?)
0x70DB, // Dark Grey
0x8049, // Light Black
0x91C0, // Light Blue
0xA038, // Light Green
0xB1F8, // Light Cyan
0xC007, // Light Red
0xD1C7, // Light Magenta
0xE03F, // Light Yellow
0xF1FF // White
};
unsigned short* blt_params; // blitter params
unsigned short* blitdata; // blit data;
int main(int argc, char* argv[])
{
union REGS regs;
struct SREGS sregs;
blitdata=malloc(2048);
blt_params=malloc(20);
mindset_gfx_set_mode(2);
mindset_gfx_set_palette(0,16,0,&palette);
memset(blitdata,0xFF,1024);
segread(&sregs);
blt_params[0]=FP_OFF(blitdata); // Source offset
blt_params[1]=FP_SEG(blitdata); // Source seg
blt_params[2]=8; // 16 bytes?
blt_params[3]=0; // X source offset
blt_params[4]=0; // Y source offset
blt_params[5]=128; // X dest offset
blt_params[6]=128; // Y dest offset
blt_params[8]=16; // X width in pixels
blt_params[9]=16; // Y width in pixels
blt_params[10]=0xFFFF; // Source mask (everything)
regs.h.ah=0x08;
regs.h.al=0; // BLT ID 0
regs.w.cx=1; // One blit op to do
regs.w.dx=0; // top/bottom, left/right, normal blit
regs.w.si=0; // X origin
regs.w.di=0; // Y origin
sregs.es=FP_SEG(blt_params);
regs.w.bx=FP_OFF(blt_params);
int86x(0xEF,&regs,&regs,&sregs);
while (!kbhit())
{
blt_params[5]=rand()&0xFF;
blt_params[6]=rand()&0x7F;
int86x(0xEF,&regs,&regs,&sregs); // Don't see anything... argh.
}
free(blitdata);
free(blt_params);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment