Skip to content

Instantly share code, notes, and snippets.

@tschak909
Created August 17, 2019 06:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tschak909/c52840360372373157259d4eae210440 to your computer and use it in GitHub Desktop.
Save tschak909/c52840360372373157259d4eae210440 to your computer and use it in GitHub Desktop.
plot maze data for mindset pac-man to offscreen buffer.
/**
* mazeplot - use BLT string
* to plot a copy of the maze
* into a buffer, which is then
* dumped to disk, and can be
* reconstituted with xxd -i
* to produce a 224x240 bitmap
*/
#include <i86.h>
#include <stdlib.h>
#include <stdio.h>
#include "chars.h"
// Maze string data. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
const char* m00="\xd1\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xfb\xfa\xda\xda\xda\xda\xda\xda\xda\xda\xda\xda\xda\xda\xd0";
const char* m01="\xd3\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xe9\xe8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xd2";
const char* m02="\xd3\x00\xe7\xdf\xdf\xe6\x00\xe7\xdf\xdf\xdf\xe6\x00\xe9\xe8\x00\xe7\xde\xde\xde\xe6\x00\xe7\xde\xde\xe6\x00\xd2";
const char* m03="\xd3\x00\xe9\xfd\xfd\xe8\x00\xe9\xfd\xfd\xfd\xe8\x00\xe9\xe8\x00\xe9\xfc\xfc\xfc\xe8\x00\xe9\xfc\xfc\xe8\x00\xd2";
const char* m04="\xd3\x00\xeb\xe5\xe5\xea\x00\xf9\xe5\xe5\xe5\xea\x00\xeb\xea\x00\xeb\xe4\xe4\xe4\xf8\x00\xeb\xe4\xe4\xea\x00\xd2";
const char* m05="\xd3\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xd2";
const char* m06="\xd3\x00\xe7\xdf\xdf\xe6\x00\xf7\xf6\x00\xe7\xdf\xdf\xdf\xde\xde\xde\xe6\x00\xf7\xf6\x00\xe7\xde\xde\xe6\x00\xd2";
const char* m07="\xd3\x00\xeb\xe5\xe5\xea\x00\xe9\xe8\x00\xeb\xe5\xe5\xf3\xf2\xe4\xe4\xea\x00\xe9\xe8\x00\xeb\xe4\xe4\xea\x00\xd2";
const char* m08="\xd3\x00\x00\x00\x00\x00\x00\xe9\xe8\x00\x00\x00\x00\xe9\xe8\x00\x00\x00\x00\xe9\xe8\x00\x00\x00\x00\x00\x00\xd2";
const char* m09="\xd5\xdd\xdd\xdd\xdd\xe6\x00\xe9\xf4\xdf\xdf\xe6\x00\xe9\xe8\x00\xe7\xde\xde\xf5\xe8\x00\xe7\xdc\xdc\xdc\xdc\xd4";
const char* m10="\xfd\xfd\xfd\xfd\xfd\xd3\x00\xe9\xf2\xe5\xe5\xea\x00\xeb\xea\x00\xeb\xe4\xe4\xf3\xe8\x00\xd2\xfc\xfc\xfc\xfc\xfc";
const char* m11="\xfd\xfd\xfd\xfd\xfd\xd3\x00\xe9\xe8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xe9\xe8\x00\xd2\xfc\xfc\xfc\xfc\xfc";
const char* m12="\xfd\xfd\xfd\xfd\xfd\xd3\x00\xe9\xe8\x00\xed\xdd\xf1\xcf\xce\xf0\xdc\xec\x00\xe9\xe8\x00\xd2\xfc\xfc\xfc\xfc\xfc";
const char* m13="\xdb\xdb\xdb\xdb\xdb\xea\x00\xf9\xf8\x00\xd2\xfd\xfd\xfd\xfc\xfc\xfc\xd3\x00\xf9\xf8\x00\xeb\xda\xda\xda\xda\xda";
const char* m14="\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xd2\xfd\xfd\xfd\xfc\xfc\xfc\xd3\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00";
const char* m15="\xdd\xdd\xdd\xdd\xdd\xe6\x00\xf7\xf6\x00\xd2\xfd\xfd\xfd\xfc\xfc\xfc\xd3\x00\xf7\xf6\x00\xe7\xdc\xdc\xdc\xdc\xdc";
const char* m16="\xfd\xfd\xfd\xfd\xfd\xd3\x00\xe9\xe8\x00\xef\xdb\xdb\xdb\xda\xda\xda\xee\x00\xe9\xe8\x00\xd2\xfc\xfc\xfc\xfc\xfc";
const char* m17="\xfd\xfd\xfd\xfd\xfd\xd3\x00\xe9\xe8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xe9\xe8\x00\xd2\xfc\xfc\xfc\xfc\xfc";
const char* m18="\xfd\xfd\xfd\xfd\xfd\xd3\x00\xe9\xe8\x00\xe7\xdf\xdf\xdf\xde\xde\xde\xe6\x00\xe9\xe8\x00\xd2\xfc\xfc\xfc\xfc\xfc";
const char* m19="\xd1\xdb\xdb\xdb\xdb\xea\x00\xeb\xea\x00\xeb\xe5\xe5\xf3\xf2\xe4\xe4\xea\x00\xeb\xea\x00\xeb\xda\xda\xda\xda\xd0";
const char* m20="\xd3\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xe9\xe8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xd2";
const char* m21="\xd3\x00\xe7\xdf\xdf\xe6\x00\xe7\xdf\xdf\xdf\xe6\x00\xe9\xe8\x00\xe7\xde\xde\xde\xe6\x00\xe7\xde\xde\xe6\x00\xd2";
const char* m22="\xd3\x00\xeb\xe5\xf3\xe8\x00\xf9\xe5\xe5\xe5\xea\x00\xeb\xea\x00\xeb\xe4\xe4\xe4\xf8\x00\xe9\xf2\xe4\xea\x00\xd2";
const char* m23="\xd3\x00\x00\x00\xe9\xe8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xe9\xe8\x00\x00\x00\xd2";
const char* m24="\xd7\xdf\xe6\x00\xe9\xe8\x00\xf7\xf6\x00\xe7\xdf\xdf\xdf\xde\xde\xde\xe6\x00\xf7\xf6\x00\xe9\xe8\x00\xe7\xde\xd6";
const char* m25="\xd9\xe5\xea\x00\xeb\xea\x00\xe9\xe8\x00\xeb\xe5\xe5\xf3\xf2\xe4\xe4\xea\x00\xe9\xe8\x00\xeb\xea\x00\xeb\xe4\xd8";
const char* m26="\xd3\x00\x00\x00\x00\x00\x00\xe9\xe8\x00\x00\x00\x00\xe9\xe8\x00\x00\x00\x00\xe9\xe8\x00\x00\x00\x00\x00\x00\xd2";
const char* m27="\xd3\x00\xe7\xdf\xdf\xdf\xdf\xf5\xf4\xdf\xdf\xe6\x00\xe9\xe8\x00\xe7\xde\xde\xf5\xf4\xde\xde\xde\xde\xe6\x00\xd2";
const char* m28="\xd3\x00\xeb\xe5\xe5\xe5\xe5\xe5\xe5\xe5\xe5\xea\x00\xeb\xea\x00\xeb\xe4\xe4\xe4\xe4\xe4\xe4\xe4\xe4\xea\x00\xd2";
const char* m29="\xd3\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xd2";
const char* m30="\xd5\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdc\xdc\xdc\xdc\xdc\xdc\xdc\xdc\xdc\xdc\xdc\xdc\xdc\xd4";
unsigned short tpm[155]; // 31 lines of output.
unsigned char __far* destbuff;
typedef struct _font {
unsigned char type;
unsigned char excess;
unsigned short nominal_width;
unsigned short nominal_height;
unsigned short byte_width;
unsigned short __far *addr;
unsigned char first;
unsigned char last;
} Font;
Font f;
FILE* fp;
void mindset_gfx_set_font_pointer(Font __far* fontp)
{
union REGS regs;
struct SREGS sregs;
segread(&sregs);
regs.h.ah=0x1F;
regs.w.bx=FP_OFF(fontp);
sregs.es=FP_SEG(fontp);
int86x(0xEF,&regs,&regs,&sregs);
}
int main(int argc, char* argv[])
{
union REGPACK regs;
printf("mazeplot 0.1\n\n");
destbuff=malloc(26880); // 112*240 (224*240)
printf("allocated 26880 bytes for dest buffer.\n");
regs.h.ah=0x04; // Set dest buffer
regs.w.cx=112; // 112 bytes per scanline (224 pixels at 4bpp)
regs.w.dx=240; // 240 scanlines
regs.w.es=FP_SEG(destbuff); // dest buffer
regs.w.bx=FP_OFF(destbuff); // "" ""
intr(0xEF,&regs);
printf("Set dest buffer to: %04x:%04x\n",FP_SEG(destbuff),FP_OFF(destbuff));
regs.h.ah=0x14; // Set clip rectangle
regs.w.si=0; // left: 0
regs.w.di=223; // right: 223
regs.w.cx=0; // top: 0
regs.w.dx=239; // bottom: 239
intr(0xEF,&regs);
printf("Set clip rect to: l:%d r:%d t:%d b:%d\n",regs.w.si,regs.w.di,regs.w.cx,regs.w.dx);
f.type=0; // Fixed font
f.excess=0; // no excess space
f.nominal_width=8; // 8 px wide
f.nominal_height=8; // 8 px high
f.byte_width=1024; // stride length 1024 bytes
f.addr=MK_FP(FP_SEG(fontdata),FP_OFF(fontdata)); // location of font data in memory.
f.first=0x00; // first available char
f.last=0xFF; // last available char
mindset_gfx_set_font_pointer(&f);
printf("Set font pointer.\n");
tpm[ 0]=0;
tpm[ 1]=0;
tpm[ 2]=28;
tpm[ 3]=FP_OFF(m00);
tpm[ 4]=FP_SEG(m00);
tpm[ 5]=0;
tpm[ 6]=8;
tpm[ 7]=28;
tpm[ 8]=FP_OFF(m01);
tpm[ 9]=FP_SEG(m01);
tpm[ 10]=0;
tpm[ 11]=16;
tpm[ 12]=28;
tpm[ 13]=FP_OFF(m02);
tpm[ 14]=FP_SEG(m02);
tpm[ 15]=0;
tpm[ 16]=24;
tpm[ 17]=28;
tpm[ 18]=FP_OFF(m03);
tpm[ 19]=FP_SEG(m03);
tpm[ 20]=0;
tpm[ 21]=32;
tpm[ 22]=28;
tpm[ 23]=FP_OFF(m04);
tpm[ 24]=FP_SEG(m04);
tpm[ 25]=0;
tpm[ 26]=40;
tpm[ 27]=28;
tpm[ 28]=FP_OFF(m05);
tpm[ 29]=FP_SEG(m05);
tpm[ 30]=0;
tpm[ 31]=48;
tpm[ 32]=28;
tpm[ 33]=FP_OFF(m06);
tpm[ 34]=FP_S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
tpm[103]=FP_OFF(m20);
tpm[104]=FP_SEG(m20);
tpm[105]=0;
tpm[106]=168;
tpm[107]=28;
tpm[108]=FP_OFF(m21);
tpm[109]=FP_SEG(m21);
tpm[110]=0;
tpm[111]=176;
tpm[112]=28;
tpm[113]=FP_OFF(m22);
tpm[114]=FP_SEG(m22);
tpm[115]=0;
tpm[116]=184;
tpm[117]=28;
tpm[118]=FP_OFF(m23);
tpm[119]=FP_SEG(m23);
tpm[120]=0;
tpm[121]=192;
tpm[122]=28;
tpm[123]=FP_OFF(m24);
tpm[124]=FP_SEG(m24);
tpm[125]=0;
tpm[126]=200;
tpm[127]=28;
tpm[128]=FP_OFF(m25);
tpm[129]=FP_SEG(m25);
tpm[130]=0;
tpm[131]=208;
tpm[132]=28;
tpm[133]=FP_OFF(m26);
tpm[134]=FP_SEG(m26);
tpm[135]=0;
tpm[136]=216;
tpm[137]=28;
tpm[138]=FP_OFF(m27);
tpm[139]=FP_SEG(m27);
tpm[140]=0;
tpm[141]=224;
tpm[142]=28;
tpm[143]=FP_OFF(m28);
tpm[144]=FP_SEG(m28);
tpm[145]=0;
tpm[146]=232;
tpm[147]=28;
tpm[148]=FP_OFF(m29);
tpm[149]=FP_SEG(m29);
tpm[150]=0;
tpm[151]=240;
tpm[152]=28;
tpm[153]=FP_OFF(m30);
tpm[154]=FP_SEG(m30);
printf("Loaded 31 lines of maze data\n");
printf("Starting BLT String\n");
// Set up text string call
regs.h.ah=0x21; // BLT STRING
regs.h.al=33; // BLT ID 1
regs.h.ch=31; // # of text pointer structs
regs.h.cl=0; // # of text chars to ignore at beginning of string (none)
regs.h.dh=0; // draw left to right
regs.h.dl=0x44; // blue
regs.w.si=0; // X origin
regs.w.di=0; // Y origin
regs.w.es=FP_SEG(tpm); // Text pointer (seg)
regs.w.bx=FP_OFF(tpm); // Text pointer (off)
intr(0xEF,&regs);
printf("BLT STRING Complete.\n");
fp=fopen("maze.dat","wb");
fwrite(destbuff,1,26880,fp);
fclose(fp);
printf("Wrote MAZE.DAT\n");
free(destbuff);
printf("freed 26880 bytes.\n");
printf("done.\n");
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment