c2e.convert_special: 0
e2c.convert_num: 0
-openfiles: /dos/z/16/16/dos_gfx.cpp:10521:10066:1:
-openfiles: /dos/z/16/16/dos_gfx.h:764:0:0:
+openfiles: /dos/z/16/16/dos_gfx.cpp:17694:17368:1:
+openfiles: /dos/z/16/16/dos_gfx.h:1182:0:0:
openfiles: /dos/z/16/16/dos_kb.c:892:395:0:
openfiles: /dos/z/16/16/dos_kb.h:60:0:0:
openfiles: /dos/z/16/16/lib/lib_com.cpp:0:0:0:
-openfiles: /dos/z/16/16/lib/lib_com.h:2523:1479:0:
+openfiles: /dos/z/16/16/lib/lib_com.h:2553:1914:0:
openfiles: /dos/z/16/16/scroll.txt:5307:5103:0:
-openfiles: /dos/z/16/16/project16.txt:1675:0:0:
+openfiles: /dos/z/16/16/project16.txt:1675:950:0:
openfiles: /dos/z/16/16/16.txt:0:0:0:
-openfiles: /dos/z/16/16/lib/x/MXSM.ASM:12781:12781:0:
-openfiles: /dos/z/16/16/lib/x/MODEX.H:1768:1601:0:
-openfiles: /dos/z/16/16/lib/x/MXPN.ASM:652:649:0:
+openfiles: /dos/z/16/16/w_modex/MODEX.CPP:474:0:0:
+openfiles: /dos/z/16/16/w_modex/MODEX.HPP:777:246:0:
+openfiles: /dos/z/16/16/w_modex/TEST.CPP:12070:11735:0:
+openfiles: /dos/z/16/16/w_modex/XPRIM.CPP:0:0:0:
+openfiles: /dos/z/16/16/w_modex/XPRIM.HPP:83:0:0:
snr_recursion_level: 0
convertcolumn_horizontally: 0
adv_open_matchname: 0
default_mime_type: text/plain
e2c.convert_xml: 1
c2e.convert_iso: 0
-opendir: file:///dos/z/16/16/lib/x
+opendir: file:///dos/z/16/16/w_modex
wrap_text_default: 0
bookmarks_filename_mode: 1
-ssearch_text: mxWaitDisplay
+ssearch_text: waiyt
snr_casesens: 0
view_blocks: 1
name: project 16
recent_files: file:///dos/z/16/16/lib/x/MODEX.H
recent_files: file:///dos/z/16/16/16.txt
recent_files: file:///dos/z/16/16/lib/x/MXSM.ASM
+recent_files: file:///dos/z/16/16/lib/x/MODEX.DEF
+recent_files: file:///dos/z/16/16/lib/x/MXVS.ASM
+recent_files: file:///dos/z/16/16/w_modex/MODEX.HPP
+recent_files: file:///dos/z/16/16/w_modex/MODEX.CPP
+recent_files: file:///dos/z/16/16/w_modex/TEST.CPP
+recent_files: file:///dos/z/16/16/w_modex/XPRIM.HPP
+recent_files: file:///dos/z/16/16/w_modex/XPRIM.CPP
snr_replacetype: 0
savedir: file:///dos/z/16/16
spell_check_default: 1
htmlbar_view: 0
spell_lang: en
ssearch_dotmatchall: 0
-searchlist: unsigned
-searchlist: word
-searchlist: play
-searchlist: rand
-searchlist: x6
-searchlist: x86
-searchlist: 86
-searchlist: asm
-searchlist: size
-searchlist: SIZE
-searchlist: 80
-searchlist: size
-searchlist: widthBytes
-searchlist: size
-searchlist: mxWaitDisplay
+searchlist: addr
+searchlist: 0x3DA
+searchlist: wait
+searchlist: loadfontX(
+searchlist: font
+searchlist: text
+searchlist: putstringX
+searchlist: putchX
+searchlist: Xfont,
+searchlist: // Waits for vertical retrace
+searchlist: wait
+searchlist: ding
+searchlist: font
+searchlist: wi
+searchlist: waiyt
autocomplete: 1
outputb_show_all_output: 0
bookmarks_show_mode: 0
//code from old library!\r
/*src\lib\*/\r
#include "dos_gfx.h"\r
-#include "lib\x\modex.h"\r
+//#include "lib\x\modex.h"\r
+//#include "XPRIM.HPP"\r
\r
int old_mode;\r
//color \82Ä\82·\82Æ\r
//\82Ä\82·\82Æ\r
int q = 0;\r
int bakax = 0, bakay = 0;\r
-int xx = rand()&0%320, yy = rand()&0%240, sx = 0, sy = 0;\r
+cord xx = rand()&0%320, yy = rand()&0%240, sx = 0, sy = 0;\r
byte coor;\r
\r
/*\r
\r
#define SEQU_ADDR 0x3c4 /* Base port of the Sequencer */\r
#define GRAC_ADDR 0x3ce /* Base port of the Graphics Controller */\r
+#define STATUS_ADDR 0x3DA\r
+\r
+unsigned char *RowsX[600];\r
+unsigned char write_plane, read_plane;\r
+unsigned short text_mask[16] = { 0x0002, 0x0102, 0x0202, 0x0302,\r
+ 0x0402, 0x0502, 0x0602, 0x0702,\r
+ 0x0802, 0x0902, 0x0A02, 0x0B02,\r
+ 0x0C02, 0x0D02, 0x0E02, 0x0F02 };\r
\r
\r
/*\r
*/\r
byte *vga = (byte *) MK_FP(0xA000, 0);\r
\r
-//fontAddr = getFont();\r
\r
/*\r
* width and height should specify the mode dimensions. widthBytes\r
number of pixels to offset)\r
-----------------------------------------------\r
*/\r
-//\r
-// inp(0x3DA);\r
-// outp(0x3C0, 0x13);\r
\r
+//mxSetVirtualScreen(480,360);\r
}\r
\r
/*\r
}\r
\r
\r
-/*-----------XXXX-------------*/
-
+/*-----------XXXX-------------*/\r
+\r
/////////////////////////////////////////////////////////////////////////////\r
// //\r
// WaitRetrace() - This waits until you are in a Verticle Retrace. //\r
// //\r
/////////////////////////////////////////////////////////////////////////////\r
+void wait_for_retrace(void)\r
+{\r
+ while (!(inp(STATUS_ADDR) & 0x08));\r
+}\r
\r
-void WaitRetrace() {\r
-\r
-// register char qy;\r
-\r
- in.h.dx = 0x03DA;\r
- in.h.al = in.h.dx;\r
- \r
- in.h.al &= 0x08;\r
- int86(0x10, &in, &out);\r
-\r
-\r
- /*l1: asm {\r
- in al,0x03DA;\r
- and al,0x08;\r
- jnz l2;\r
- }*/\r
-}
-
/////////////////////////////////////////////////////////////////////////////\r
// //\r
// MoveTo() - This moves to position X*4 on a chain 4 screen. //\r
// will be better documented. - Snowman //\r
// //\r
/////////////////////////////////////////////////////////////////////////////\r
-\r
+/*\r
void MoveTo (word X, word Y) {\r
\r
-// word O = Y*SIZE*2+X;
+// word O = Y*SIZE*2+X;\r
word O = Y*widthBytes*2+X;\r
\r
asm {\r
mov al, 0x0D\r
mov dx, 0x3D4\r
out dx, ax\r
- }
-
+ }\r
+\r
;-----------------------------------------------------------\r
;\r
; MXPN.ASM - Panning function\r
\r
MX_TEXT ENDS\r
END\r
-
\r
-}
-
+\r
+}\r
+\r
//Procedure Play;\r
void Play()\r
{\r
\r
moveto(0,0,Size); // { This moves the view to the top left hand corner }\r
\r
-/* for(loop1=0;loop1<=3;loop1++)\r
- for(loop2=0;loop2<=5;loop2++)\r
- Putpic (loop1*160,loop2*66); // { This places the picture all over the\r
+// for(loop1=0;loop1<=3;loop1++)\r
+// for(loop2=0;loop2<=5;loop2++)\r
+// Putpic (loop1*160,loop2*66); // { This places the picture all over the\r
// chain-4 screen }\r
- getch();\r
- ch=0x0;*/\r
+// getch();\r
+// ch=0x0;\r
// xpos=rand (78)+1;\r
-// ypos=rand (198)+1; // { Random start positions for the view }
- xpos=0;
+// ypos=rand (198)+1; // { Random start positions for the view }\r
+ xpos=0;\r
ypos=0;\r
xdir=1;\r
ydir=1;\r
// if(ch==0x71)break; // 'q'\r
// if(ch==0x1b)break; // 'ESC'\r
// }\r
-}
-\r
+}\r
+*/\r
/*tile*/\r
//king_crimson's code\r
void putColorBox_X(int x, int y, int w, int h, byte color) {\r
\r
//king_crimson's code\r
void hScroll(int Cols) {\r
- inp(0x3DA);\r
+ wait_for_retrace();\r
outp(0x3C0, 0x13);\r
outp(0x3C0, Cols & 3);\r
outp(0x3D4, 0x13);\r
- outp(0x3D5, Cols/* >> 2*/);\r
+ outp(0x3D5, Cols >> 2);\r
+ outp(0x3D4, Cols);\r
//setVisibleStart(visStart + (Cols * height));\r
setVisibleStart(visStart + (Cols * width));\r
}\r
\r
\r
*/\r
-//---------------------------------------------------\r
-//\r
-// Use the bios to get the address of the 8x8 font\r
-//\r
-// You need a font if you are going to draw text.\r
-//\r
-/*\r
-int far *\r
-getFont()\r
+int loadfontX(char *fname)\r
{\r
- union REGPACK rg;\r
- int seg;\r
- int off;\r
- memset(&rg, 0, sizeof(rg));\r
-\r
- rg.w.ax = 0x1130;\r
- rg.h.bh = 0x03;\r
- intr(0x10, &rg);\r
- seg = rg.w.es;\r
- off = rg.w.bp;\r
- \r
-\r
- return (int far *)MK_FP(seg, off);\r
+ FILE *fp;\r
+\r
+ fp = fopen(fname, "rb");\r
+\r
+ if (fp == NULL) {\r
+ return 0;\r
+ } else {\r
+ fread(Xfont, 8, 256, fp);\r
+ fclose(fp);\r
+ return 1;\r
+ }\r
}\r
\r
-void drawChar(int x, int y, int color, byte c)\r
+void putchX(cord x, cord y, char c, byte color)\r
{\r
- int i, j;\r
- int mask;\r
- int far *font = getFont() + (c * 8);\r
-\r
- for (i = 0; i < 8; i++)\r
- {\r
- mask = *font;\r
- for (j = 0; j < 8; j++)\r
- {\r
- if (mask & 0x80)\r
- {\r
- //pixel(x + j, y + i, color);\r
- putPixel_X(x + j, y + i, color);\r
- }\r
- mask <<= 1;\r
- }\r
- font++;\r
- }\r
+ int i;\r
+ byte *vga_ptr;\r
+ byte *font_ptr;\r
+ byte temp;\r
+\r
+ // 8x8 font\r
+ vga_ptr = RowsX[y << 3] + (x << 1) + actStart;\r
+ write_plane = -1;\r
+\r
+ font_ptr = Xfont + (c << 3);\r
+\r
+ i=8;\r
+ while (i--) {\r
+ temp = *font_ptr++;\r
+ outpw(SEQU_ADDR, text_mask[temp & 0x0F]);\r
+ *vga_ptr++ = color;\r
+\r
+ outpw(SEQU_ADDR, text_mask[temp >> 4]);\r
+ *vga_ptr-- = color;\r
+ vga_ptr += widthBytes;\r
+ }\r
}\r
\r
-void drawText(int x, int y, int color, byte string)\r
+void putstringX(cord x, cord y, char *str, byte color)\r
{\r
- while (string)\r
- {\r
- drawChar(x, y, color, string);\r
- x += 8;\r
- string++;\r
+ int i, skip;\r
+ byte *vga_ptr;\r
+ byte *font_ptr;\r
+ byte c, temp;\r
+\r
+ // 8x8 font\r
+ vga_ptr = RowsX[y << 3] + (x << 1) + actStart;\r
+ write_plane = -1;\r
+\r
+ skip = 2 - (widthBytes << 3);\r
+\r
+ while (c = *str++) {\r
+ font_ptr = Xfont + (c << 3);\r
+\r
+ i=8;\r
+ while (i--) {\r
+ temp = *font_ptr++;\r
+ outpw(SEQU_ADDR, text_mask[temp & 0x0F]);\r
+ *vga_ptr++ = color;\r
+\r
+ outpw(SEQU_ADDR, text_mask[temp >> 4]);\r
+ *vga_ptr-- = color;\r
+ vga_ptr += widthBytes;\r
}\r
+\r
+ vga_ptr += skip;\r
+ }\r
}\r
-*/\r
+\r
/////////////////////////////////////////////////////////////////////////////\r
// //\r
// setvideo() - This function Manages the video modes //\r
int main(void)\r
{\r
int key,d;\r
+ //short int temp;\r
// main variables\r
d=1; // switch variable\r
key=4; // default screensaver number\r
\r
//++++0000\r
setvideo(1);\r
-//mxInit();\r
+ /*temp = loadfontX("vga8x8.fnt");\r
+\r
+ if (temp) {\r
+ putstringX(0, 0, "bakapi!", 2);\r
+ }\r
+ getch();*/\r
// screen savers\r
\r
/*while(d!=0){ // on!\r
}\r
}*/ // else off\r
while(!kbhit()){ // conditions of screen saver\r
- ding(4);\r
+ ding(2);\r
}\r
//end of screen savers\r
// doTest();\r
\r
while(!kbhit()){ // conditions of screen saver\r
// hScroll(1);\r
-// scrolly(1);\r
-// delay(100);
- Play();\r
+ scrolly(1);\r
+ delay(100);\r
+// Play();\r
}\r
//++++0000\r
setvideo(0);\r
// Size = 80 = 2 across, 2 down\r
// Size = 160 = 4 across, 1 down*/\r
//#define VMEM 0xA000 // = vga\r
-//int width = 320;\r
-//int height = 240;\r
+byte Xfont[2048];\r
\r
void drawChar(int x, int y, int color, byte c);\r
void drawText(int x, int y, int color, byte string);\r
void putPixel_X(int x, int y, byte color);\r
void putColorBox_X(int x, int y, int w, int h, byte color);
void vScroll(int rows);
-void scrolly(int bong);\r
+void scrolly(int bong);
+void wait_for_retrace(void); // Waits for vertical retrace\r
//void BlockMove();\r
//void eraseplayer(int x, int y);\r
//void drawplayer(int x, int y, int color);\r
\r
\r
typedef unsigned char byte;
-typedef unsigned int word;\r
+typedef unsigned int word;
+typedef unsigned short cord;\r
\r
void wait(clock_t wait);\r
\r
+++ /dev/null
-#\r
-# MODEX library makefile (for Borland MAKE)\r
-# Copyright (c) 1993,1994 by Alessandro Scotti\r
-#\r
-LIBINCS = MODEX.DEF\r
-\r
-LIBOBJS = MXBB.OBJ \r
- MXCC.OBJ \r
- MXCG.OBJ \r
- MXCL.OBJ \r
- MXCR.OBJ \r
- MXFB.OBJ \r
- MXFP.OBJ \r
- MXGC.OBJ \r
- MXGI.OBJ \r
- MXGM.OBJ \r
- MXGP.OBJ \r
- MXGV.OBJ \r
- MXHL.OBJ \r
- MXIT.OBJ \r
- MXLL.OBJ \r
- MXLN.OBJ \r
- MXOT.OBJ \r
- MXPB.OBJ \r
- MXPF.OBJ \r
- MXPG.OBJ \r
- MXPI.OBJ \r
- MXPN.OBJ \r
- MXPP.OBJ \r
- MXPT.OBJ \r
- MXRA.OBJ \r
- MXRP.OBJ \r
- MXSA.OBJ \r
- MXSC.OBJ \r
- MXSI.OBJ
- MXSL.OBJ \r
- MXSM.OBJ \r
- MXSP.OBJ \r
- MXSS.OBJ \r
- MXTL.OBJ \r
- MXVS.OBJ \r
- MXWD.OBJ \r
- MXWM.OBJ \r
- MXWP.OBJ \r
- MXWR.OBJ\r
-\r
-#\r
-# ASM compiler\r
-#\r
-ASMC = JWASMR\r
-ASMO = -Zm -0\r
-\r
-#\r
-# PAS compiler\r
-#\r
-#PASC = bpc\r
-#PASO = /m -$D- -$L- -$S-\r
-\r
-#\r
-# LIB maker, uses response file\r
-#\r
-LIBC = JWlibd\r
-\r
-.asm.obj:\r
- $(ASMC) $(ASMO) $<\r
-\r
-target: modex.lib\r
-#modex.tpu modex.tpp \r
-\r
-#modex.tpu: $(LIBOBJS) modex.pas\r
-# $(PASC) $(PASO) modex\r
-# copy modex.tpu ..\r
-# copy modex.pas ..\r
-\r
-#modex.tpp: $(LIBOBJS) modex.pas\r
-# $(PASC) /cp $(PASO) modex\r
-# copy modex.tpp ..\r
-\r
-modex.lib: modex.lib $(LIBOBJS)\r
- $(LIBC) modex.lib# @modex.lbr\r
-\r
-$(LIBOBJS): modex.def\r
--- /dev/null
+#include <stdio.h>\r
+\r
+#include "fixed32.hpp"\r
+\r
+Fixed32 SinTab[256];\r
+Fixed32 CosTab[256];\r
+\r
+\r
+void\r
+initFixed32(void)\r
+{\r
+ FILE *fp;\r
+\r
+ fp = fopen("sintab.dat", "rb");\r
+ fread(SinTab, 4, 256, fp);\r
+ fread(CosTab, 4, 256, fp);\r
+ fclose(fp);\r
+}\r
+\r
+\r
+Fixed32\r
+FixedMul(Fixed32 num1, Fixed32 num2)\r
+{\r
+ long Mm1, Mm2;\r
+ short int MM, mm;\r
+ short int hi1, hi2, lo1, lo2;\r
+\r
+ hi1 = (num1 >> 16);\r
+ hi2 = (num2 >> 16);\r
+ lo1 = (num1 & 0xFFFF);\r
+ lo2 = (num2 & 0xFFFF);\r
+\r
+ MM = (hi1 * hi2);\r
+ Mm1 = (lo2 * hi1);\r
+ Mm2 = (lo1 * hi2);\r
+ mm = (lo1 * lo2);\r
+\r
+ return (Mm1 + Mm2 + mm + (((long)MM) << 16));\r
+}\r
+\r
+\r
+Fixed32\r
+FixedDiv(Fixed32 numer, Fixed32 denom)\r
+{\r
+ return (numer / ROUND_FIXED_TO_INT(denom));\r
+}\r
+\r
+\r
+void\r
+CosSin(Iangle theta, Fixed32 *Cos, Fixed32 *Sin)\r
+{\r
+ *Sin = SinTab[theta];\r
+ *Cos = CosTab[theta];\r
+}\r
+\r
+\r
+/* ASM fixedpoint math routines\r
+;--------------------------------------------------\r
+; Sqrt - Fixed Point Square Root (High/Normal Precision)\r
+; IN : ecx\r
+; OUT : eax\r
+; Modified : ebx,ecx,edx\r
+Sqrt PROC\r
+\r
+;This is the High Precision version for the sqrt.\r
+;It gives the optimal 8.16 precision but takes\r
+;a little longer (24 iterations, 48 bits intead of\r
+;16 iterations and 32 bits)\r
+\r
+ xor eax,eax ;eax is root\r
+ mov ebx,40000000h\r
+sqrt1:\r
+ mov edx,ecx ;edx = val\r
+ sub edx,ebx ;val - bitsqr\r
+ jb sqrt2\r
+ sub edx,eax ;val - root\r
+ jb sqrt2\r
+ mov ecx,edx ;val >= (root+bitsqr) -> accept subs\r
+ shr eax,1 ;root >> 1\r
+ or eax,ebx ;root | bitsqr\r
+ shr ebx,2 ;bitsqr>>2\r
+ jnz sqrt1\r
+ jz sqrt5\r
+sqrt2:\r
+ shr eax,1 ;val < (root+bitsqr) -> dont change val\r
+ shr ebx,2 ;bitsqr>>2\r
+ jnz sqrt1\r
+; we now have the 8.8 precision\r
+\r
+sqrt5:\r
+ mov ebx,00004000h\r
+ shl eax,16\r
+ shl ecx,16\r
+sqrt3:\r
+ mov edx,ecx ;edx = val\r
+ sub edx,ebx ;val - bitsqr\r
+ jb sqrt4\r
+ sub edx,eax ;val - root\r
+ jb sqrt4\r
+ mov ecx,edx ;val >= (root+bitsqr) -> accept subs\r
+ shr eax,1 ;root >> 1\r
+ or eax,ebx ;root | bitsqr\r
+ shr ebx,2 ;bitsqr>>2\r
+ jnz sqrt3\r
+ ret\r
+sqrt4:\r
+ shr eax,1 ;val < (root+bitsqr) -> dont change val\r
+ shr ebx,2 ;bitsqr>>2\r
+ jnz sqrt3\r
+ ret\r
+\r
+Sqrt ENDP\r
+*/\r
+\r
--- /dev/null
+#ifndef FIXEDPOINT_HPP\r
+ #define FIXEDPOINT_HPP\r
+\r
+typedef long Fixed32; // 16.16 FixedPoint\r
+typedef unsigned char Iangle; // Integer angle (0..255)\r
+\r
+/* Macros for Type Conversion */\r
+#define INT_TO_FIXED(x) ((x) << 16)\r
+#define FIXED_TO_INT(x) ((x) >> 16)\r
+#define ROUND_FIXED_TO_INT(x) (((x) + 0x8000) >> 16)\r
+\r
+// Loads Fixed32 datafiles\r
+void initFixed32(void);\r
+\r
+// Common math functions\r
+Fixed32 FixedMul(Fixed32 num1, Fixed32 num2);\r
+Fixed32 FixedDiv(Fixed32 numer, Fixed32 denom);\r
+void CosSin(Iangle theta, Fixed32 *Cos, Fixed32 *Sin);\r
+\r
+Fixed32 FixedMulASM(Fixed32 num1, Fixed32 num2);\r
+#pragma aux FixedMulASM = \\r
+ "imul edx" \\r
+ "add eax, 8000h" \\r
+ "adc edx, 0" \\r
+ "shrd eax, edx, 16" \\r
+ parm caller [eax] [edx] \\r
+ value [eax] \\r
+ modify [eax edx];\r
+\r
+Fixed32 FixedDivASM(Fixed32 numer, Fixed32 denom); // No rounding!\r
+#pragma aux FixedDivASM = \\r
+ "xor eax, eax" \\r
+ "shrd eax, edx, 16" \\r
+ "sar edx, 16" \\r
+ "idiv ebx" \\r
+ parm caller [edx] [ebx] \\r
+ value [eax] \\r
+ modify [eax ebx edx];\r
+\r
+#endif\r
+\r
--- /dev/null
+wcl386 test modex xprim xpal xblitbuf fixed32\r
+erase *.obj\r
--- /dev/null
+#include <conio.h>\r
+#include <dos.h>\r
+#include <mem.h>\r
+\r
+#include "modex.hpp"\r
+\r
+#define ATTRCON_ADDR 0x3C0\r
+#define MISC_ADDR 0x3C2\r
+#define VGAENABLE_ADDR 0x3C3\r
+#define SEQU_ADDR 0x3C4\r
+#define GRACON_ADDR 0x3CE\r
+#define CRTC_ADDR 0x3D4\r
+#define STATUS_ADDR 0x3DA\r
+\r
+unsigned short width, height, widthBytes, num_pages;\r
+unsigned short pageSize, activeStart, visibleStart;\r
+unsigned char write_plane, read_plane;\r
+unsigned char *RowsX[600];\r
+unsigned char line_head[4] = { 0xFF, 0x0E, 0x0C, 0x08 };\r
+unsigned char line_tail[4] = { 0x00, 0x01, 0x03, 0x07 };\r
+unsigned short plane_mask[4] = { PLANE_0, PLANE_1, PLANE_2, PLANE_3 };\r
+unsigned short read_mask[4] = { READ_PLANE_0, READ_PLANE_1,\r
+ READ_PLANE_2, READ_PLANE_3 };\r
+unsigned short text_mask[16] = { 0x0002, 0x0102, 0x0202, 0x0302,\r
+ 0x0402, 0x0502, 0x0602, 0x0702,\r
+ 0x0802, 0x0902, 0x0A02, 0x0B02,\r
+ 0x0C02, 0x0D02, 0x0E02, 0x0F02 };\r
+unsigned short page_offset[5];\r
+unsigned short page_mask_high[5];\r
+unsigned short page_mask_low[5];\r
+\r
+\r
+unsig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x63,\r
+ 0x3d4, 0x02, 0x64,\r
+ 0x3d4, 0x03, 0x92,\r
+ 0x3d4, 0x04, 0x65,\r
+ 0x3d4, 0x05, 0x82,\r
+ 0x3d4, 0x06, 0x70,\r
+ 0x3d4, 0x07, 0xf0,\r
+ 0x3d4, 0x08, 0x00,\r
+ 0x3d4, 0x09, 0x60,\r
+ 0x3d4, 0x10, 0x5b,\r
+ 0x3d4, 0x11, 0x8c,\r
+ 0x3d4, 0x12, 0x57,\r
+ 0x3d4, 0x13, 0x32,\r
+ 0x3d4, 0x14, 0x00,\r
+ 0x3d4, 0x15, 0x58,\r
+ 0x3d4, 0x16, 0x70,\r
+ 0x3d4, 0x17, 0xe3,\r
+ 0x3c4, 0x01, 0x01,\r
+ 0x3c4, 0x02, 0x0f,\r
+ 0x3c4, 0x04, 0x06,\r
+ 0x3ce, 0x05, 0x40,\r
+ 0x3ce, 0x06, 0x05,\r
+ 0x3c0, 0x10, 0x41,\r
+ 0x3c0, 0x13, 0x00\r
+};\r
+\r
+\r
+void\r
+calc_rows(void)\r
+{\r
+ int i;\r
+\r
+ // Each byte addresses four pixels, so the width of a scan line\r
+ // in *bytes* is one fourth of the number of pixels on a line.\r
+ widthBytes = width / 4;\r
+\r
+ pageSize = (widthBytes * height);\r
+\r
+ for (i=0; i < height; i++) {\r
+ RowsX[i] = (unsigned char *)((0xA000 << 4) + (widthBytes * i));\r
+ }\r
+\r
+ // Clear entire video memory, by selecting all four planes, then\r
+ // writing 0 to entire segment.\r
+ outpw(SEQU_ADDR, ALL_PLANES);\r
+ memset((unsigned char *)(0xA000 << 4), 0x00, 0x00010000);\r
+\r
+ // By default we want screen refreshing and drawing operations\r
+ // to be based at offset 0 in the video segment.\r
+ activeStart = visibleStart = 0;\r
+\r
+ // Set current plane to invalid value\r
+ write_plane = -1;\r
+ read_plane = -1;\r
+\r
+ // How many pages fit in 256K VGA Card?\r
+ num_pages = ((64 * 1024) / pageSize);\r
+\r
+ for (i=0; i < num_pages; i++) {\r
+ page_offset[i] = (pageSize * i);\r
+ page_mask_high[i] = (0x0C | (page_offset[i] & 0xFF00));\r
+ page_mask_low[i] = (0x0D | ((page_offset[i] & 0x00FF) << 8));\r
+ }\r
+}\r
+\r
+\r
+// setBaseXMode() does the initialization to make the VGA ready to\r
+// accept any combination of configuration register settings. This\r
+// involves enabling writes to index 0 to 7 of the CRT controller (port\r
+// 0x3D4), by clearing the most significant bit (bit 7) of index 0x11.\r
+void\r
+setBaseXMode(void)\r
+{\r
+ int temp;\r
+ union REGS r;\r
+\r
+ r.x.eax = 0x0013;\r
+ int386(0x10, &r, &r);\r
+\r
+ outp(0x3D4, 0x11);\r
+ temp = inp(0x3D5) & 0x7F;\r
+ outp(0x3D4, 0x11);\r
+ outp(0x3D5, temp);\r
+}\r
+\r
+\r
+void\r
+outReg(unsigned short *r)\r
+{\r
+ switch (r[0]) {\r
+ // First handle special cases:\r
+\r
+ case ATTRCON_ADDR:\r
+ // reset read/write flip-flop\r
+ inp(STATUS_ADDR);\r
+ outp(ATTRCON_ADDR, r[1] | 0x20);\r
+ // ensure VGA output is enabled\r
+ outp(ATTRCON_ADDR, r[2]);\r
+ break;\r
+\r
+ case MISC_ADDR:\r
+ case VGAENABLE_ADDR:\r
+ // Copy directly to port\r
+ outp(r[0], r[2]);\r
+ break;\r
+\r
+ case SEQU_ADDR:\r
+ case GRACON_ADDR:\r
+ case CRTC_ADDR:\r
+ default:\r
+ // Index to port\r
+ outp(r[0], r[1]);\r
+ // Value to port+1\r
+ outp(r[0] + 1, r[2]);\r
+ break;\r
+ }\r
+}\r
+\r
+void\r
+outRegArray(unsigned short *r, int n)\r
+{\r
+ while (n--) {\r
+ outReg(r);\r
+ r += 3;\r
+ }\r
+}\r
+\r
+\r
+void\r
+set80x25(void)\r
+{\r
+ union REGS r;\r
+ r.x.eax = 0x0003;\r
+\r
+ int386(0x10, &r, &r);\r
+}\r
+\r
+void\r
+set256x224x256_X(void)\r
+{\r
+ setBaseXMode();\r
+ outRegArray(ModeX_256x224regs, 25);\r
+\r
+ width = 256;\r
+ height = 224;\r
+\r
+ calc_rows();\r
+}\r
+\r
+void\r
+set256x240x256_X(void)\r
+{\r
+ setBaseXMode();\r
+ outRegArray(ModeX_256x240regs, 25);\r
+\r
+ width = 256;\r
+ height = 240;\r
+\r
+ calc_rows();\r
+}\r
+\r
+void\r
+set256x256x256_X(void)\r
+{\r
+ setBaseXMode();\r
+ outRegArray(ModeX_256x256regs, 25);\r
+\r
+ width = 256;\r
+ height = 256;\r
+\r
+ calc_rows();\r
+}\r
+\r
+void\r
+set256x480x256_X(void)\r
+{\r
+ setBaseXMode();\r
+ outRegArray(ModeX_256x480regs, 25);\r
+\r
+ width = 256;\r
+ height = 480;\r
+\r
+ calc_rows();\r
+}\r
+\r
+void\r
+set320x200x256_X(void)\r
+{\r
+ setBaseXMode();\r
+ outRegArray(ModeX_320x200regs, 25);\r
+\r
+ width = 320;\r
+ height = 200;\r
+\r
+ calc_rows();\r
+}\r
+\r
+void\r
+set320x240x256_X(void)\r
+{\r
+ setBaseXMode();\r
+ outRegArray(ModeX_320x240regs, 25);\r
+\r
+ width = 320;\r
+ height = 240;\r
+\r
+ calc_rows();\r
+}\r
+\r
+void\r
+set320x400x256_X(void)\r
+{\r
+ setBaseXMode();\r
+ outRegArray(ModeX_320x400regs, 25);\r
+\r
+ width = 320;\r
+ height = 400;\r
+\r
+ calc_rows();\r
+}\r
+\r
+void\r
+set320x480x256_X(void)\r
+{\r
+ setBaseXMode();\r
+ outRegArray(ModeX_320x480regs, 25);\r
+\r
+ width = 320;\r
+ height = 480;\r
+\r
+ calc_rows();\r
+}\r
+\r
+void\r
+set360x200x256_X(void)\r
+{\r
+ setBaseXMode();\r
+ outRegArray(ModeX_360x200regs, 25);\r
+\r
+ width = 360;\r
+ height = 200;\r
+\r
+ calc_rows();\r
+}\r
+\r
+void\r
+set360x240x256_X(void)\r
+{\r
+ setBaseXMode();\r
+ outRegArray(ModeX_360x240regs, 25);\r
+\r
+ width = 360;\r
+ height = 240;\r
+\r
+ calc_rows();\r
+}\r
+\r
+void\r
+set360x270x256_X(void)\r
+{\r
+ setBaseXMode();\r
+ outRegArray(ModeX_360x270regs, 25);\r
+\r
+ width = 360;\r
+ height = 270;\r
+\r
+ calc_rows();\r
+}\r
+\r
+void\r
+set360x360x256_X(void)\r
+{\r
+ setBaseXMode();\r
+ outRegArray(ModeX_360x360regs, 25);\r
+\r
+ width = 360;\r
+ height = 360;\r
+\r
+ calc_rows();\r
+}\r
+\r
+void\r
+set360x400x256_X(void)\r
+{\r
+ setBaseXMode();\r
+ outRegArray(ModeX_360x400regs, 25);\r
+\r
+ width = 360;\r
+ height = 400;\r
+\r
+ calc_rows();\r
+}\r
+\r
+void\r
+set360x480x256_X(void)\r
+{\r
+ setBaseXMode();\r
+ outRegArray(ModeX_360x480regs, 25);\r
+\r
+ width = 360;\r
+ height = 480;\r
+\r
+ calc_rows();\r
+}\r
+\r
+void\r
+set376x282x256_X(void)\r
+{\r
+ setBaseXMode();\r
+ outRegArray(ModeX_376x282regs, 25);\r
+\r
+ width = 376;\r
+ height = 282;\r
+\r
+ calc_rows();\r
+}\r
+\r
+void\r
+set376x564x256_X(void)\r
+{\r
+ setBaseXMode();\r
+ outRegArray(ModeX_376x564regs, 25);\r
+\r
+ width = 376;\r
+ height = 564;\r
+\r
+ calc_rows();\r
+}\r
+\r
+void\r
+set400x300x256_X(void)\r
+{\r
+ setBaseXMode();\r
+ outRegArray(ModeX_400x300regs, 26);\r
+\r
+ width = 400;\r
+ height = 300;\r
+\r
+ calc_rows();\r
+}\r
+\r
+void\r
+set400x600x256_X(void)\r
+{\r
+ setBaseXMode();\r
+ outRegArray(ModeX_400x600regs, 26);\r
+\r
+ width = 400;\r
+ height = 600;\r
+\r
+ calc_rows();\r
+}\r
+\r
+\r
+COORD\r
+get_xres(void)\r
+{\r
+ return width;\r
+}\r
+\r
+\r
+COORD\r
+get_yres(void)\r
+{\r
+ return height;\r
+}\r
+\r
+\r
+void\r
+set_write_plane(unsigned short int plane_mask)\r
+{\r
+ write_plane = -1;\r
+ outpw(SEQU_ADDR, plane_mask);\r
+}\r
+\r
+\r
+void\r
+set_read_plane(unsigned short int plane_mask)\r
+{\r
+ read_plane = -1;\r
+ outpw(GRACON_ADDR, plane_mask);\r
+}\r
+\r
--- /dev/null
+#ifndef MODEX_HPP\r
+ #define MODEX_HPP\r
+\r
+#include "xtypes.hpp"\r
+\r
+// Some defines\r
+#define PLANE_0 0x0102\r
+#define PLANE_1 0x0202\r
+#define PLANE_2 0x0402\r
+#define PLANE_3 0x0802\r
+#define ALL_PLANES 0x0F02\r
+#define READ_PLANE_0 0x0004\r
+#define READ_PLANE_1 0x0104\r
+#define READ_PLANE_2 0x0204\r
+#define READ_PLANE_3 0x0304\r
+\r
+\r
+// External Variables needed by graphics routines\r
+extern unsigned short width, height, widthBytes, num_pages;\r
+extern unsigned short activeStart, visibleStart, pageSize;\r
+extern unsigned char write_plane, read_plane;\r
+extern unsigned char *RowsX[600];\r
+extern unsigned char line_head[4];\r
+extern unsigned char line_tail[4];\r
+extern unsigned short plane_mask[4];\r
+extern unsigned short read_mask[4];\r
+extern unsigned short text_mask[16];\r
+extern unsigned short page_offset[5];\r
+extern unsigned short page_mask_high[5];\r
+extern unsigned short page_mask_low[5];\r
+\r
+\r
+// Return to text mode\r
+void set80x25(void);\r
+\r
+// Set various ModeX resolutions\r
+void set256x224x256_X(void);\r
+void set256x240x256_X(void);\r
+void set256x256x256_X(void);\r
+void set256x480x256_X(void);\r
+void set320x200x256_X(void);\r
+void set320x240x256_X(void);\r
+void set320x400x256_X(void);\r
+void set320x480x256_X(void);\r
+void set360x200x256_X(void);\r
+void set360x240x256_X(void);\r
+void set360x270x256_X(void);\r
+void set360x360x256_X(void);\r
+void set360x400x256_X(void);\r
+void set360x480x256_X(void);\r
+void set376x282x256_X(void);\r
+void set376x564x256_X(void);\r
+void set400x300x256_X(void);\r
+void set400x600x256_X(void);\r
+\r
+COORD get_xres(void);\r
+COORD get_yres(void);\r
+\r
+void set_write_plane(unsigned short int plane_mask);\r
+void set_read_plane(unsigned short int plane_mask);\r
+\r
+#endif\r
+\r
--- /dev/null
+#include <conio.h>\r
+#include <dos.h>\r
+#include <mem.h>\r
+#include <stdio.h>\r
+#include <stdlib.h>\r
+#include <time.h>\r
+\r
+#include "fixed32.hpp"\r
+#include "modex.hpp"\r
+#include "xprim.hpp"\r
+#include "xpal.hpp"\r
+#include "xblitbuf.hpp"\r
+\r
+#define FIRE_DEMO 1\r
+#define ROTATE_DEMO 1\r
+#define MONSTER_DEMO_ONE 1\r
+#define MONSTER_DEMO_TWO 1\r
+#define MATH_DEMO 0\r
+\r
+int\r
+monster_demo1(void)\r
+{\r
+ clock_t begin, end;\r
+ short int i;\r
+ blitbuf sprite_image, blit_image;\r
+\r
+ clearX(0);\r
+\r
+ load_blitbufPCX("monster.pcx", &sprite_image);\r
+ aligned_bitblitX(0, 20, &sprite_image);\r
+ getch();\r
+\r
+ blit_image.image = NULL;\r
+\r
+ i=99;\r
+\r
+ begin = clock();\r
+\r
+ while (i > 0) {\r
+ scale_blitbuf(120 + (i << 1), (i << 1), &sprite_image, &blit_image);\r
+ boxX((99 - i), (119 - i), (220 + i), (120 + i), 0);\r
+ vanilla_bitblitX(100 - i, 120 - i, &blit_image);\r
+ i--;\r
+ }\r
+\r
+ end = clock();\r
+\r
+ i=120;\r
+ while (i > 0) {\r
+ scale_blitbuf(i, 2, &sprite_image, &blit_image);\r
+\r
+ putpixelX(159 - (i >> 1), 119, 0);\r
+ putpixelX(159 - (i >> 1), 120, 0);\r
+ putpixelX(160 + (i >> 1), 119, 0);\r
+ putpixelX(160 + (i >> 1), 120, 0);\r
+\r
+ vanilla_bitblitX(160 - (i >> 1), 119, &blit_image);\r
+ delay(10);\r
+ i -= 2;\r
+ }\r
+\r
+ filledboxX(156, 119, 163, 120, 0);\r
+ putpixelX(159, 120, 1);\r
+ delay(250);\r
+ putpixelX(159, 120, 0);\r
+\r
+ filledboxX(156, 119, 163, 120, 0);\r
+ clear_blitbuf(&sprite_image);\r
+ clear_blitbuf(&blit_image);\r
+\r
+ getch();\r
+\r
+ return (end - begin);\r
+}\r
+\r
+\r
+void\r
+monster_demo2(void)\r
+{\r
+ short int i;\r
+ blitbuf sprite_image, blit_image;\r
+\r
+ clearX(0);\r
+\r
+ load_blitbufPCX("monster.pcx", &sprite_image);\r
+ aligned_bitblitX(0, 20, &sprite_image);\r
+ getch();\r
+\r
+ blit_image.image = NULL;\r
+\r
+ i=99;\r
+ while (i) {\r
+ vertical_scale_blitbuf((i << 1), &sprite_image, &blit_image);\r
+ boxX(0, (119 - i), 319, (120 + i), 0);\r
+ aligned_bitblitX(0, 120 - i, &blit_image);\r
+ i--;\r
+ }\r
+\r
+ filledboxX(0, 120, 319, 120, 0);\r
+\r
+ i=318;\r
+ while (i > 0) {\r
+ scale_blitbuf(i, 1, &blit_image, &sprite_image);\r
+\r
+ putpixelX(159 - (i >> 1), 119, 0);\r
+ putpixelX(159 - (i >> 1), 120, 0);\r
+ putpixelX(160 + (i >> 1), 119, 0);\r
+ putpixelX(160 + (i >> 1), 120, 0);\r
+\r
+ vanilla_bitblitX(160 - (i >> 1), 119, &sprite_image);\r
+ delay(5);\r
+ i -= 2;\r
+ }\r
+\r
+ filledboxX(156, 119, 163, 120, 0);\r
+ putpixelX(159, 120, 1);\r
+ delay(250);\r
+ putpixelX(159, 120, 0);\r
+ filledboxX(156, 119, 163, 120, 0);\r
+ clear_blitbuf(&sprite_image);\r
+ clear_blitbuf(&blit_image);\r
+\r
+ getch();\r
+}\r
+\r
+\r
+void\r
+fire_demo(void)\r
+{\r
+ #define V_WIDTH 80\r
+ #define V_HEIGHT 50\r
+ #define BUF_WIDTH 80\r
+ #define BUF_HEIGHT 56\r
+ #define REWIND (V_WIDTH * 3)\r
+ #define BUF_SIZE (BUF_WIDTH * BUF_HEIGHT)\r
+\r
+unsigned char fire_pal[768] = {\r
+ 0, 0, 0, 0, 0, 24, 0, 0, 24, 0, 0, 28,\r
+ 0, 0, 32, 0, 0, 32, 0, 0, 36, 0, 0, 40,\r
+ 8, 0, 40, 16, 0, 36, 24, 0, 36, 32, 0, 32,\r
+ 40, 0, 28, 48, 0, 28, 56, 0, 24, 64, 0, 20,\r
+ 72, 0, 20, 80, 0, 16, 88, 0, 16, 96, 0, 12,\r
+ 104, 0, 8, 112, 0, 8, 120, 0, 4, 128, 0, 0,\r
+ 128, 0, 0, 132, 0, 0, 136, 0, 0, 140, 0, 0,\r
+ 144, 0, 0, 144, 0, 0, 148, 0, 0, 152, 0, 0,\r
+ 156, 0, 0, 160, 0, 0, 160, 0, 0, 164, 0, 0,\r
+ 168, 0, 0, 172, 0, 0, 176, 0, 0, 180, 0, 0,\r
+ 184, 4, 0, 188, 4, 0, 192, 8, 0, 196, 8, 0,\r
+ 200, 12, 0, 204, 12, 0, 208, 16, 0, 212, 16, 0,\r
+ 216, 20, 0, 220, 20, 0, 224, 24, 0, 228, 24, 0,\r
+ 232, 28, 0, 236, 28, 0, 240, 32, 0, 244, 32, 0,\r
+ 252, 36, 0, 252, 36, 0, 252, 40, 0, 252, 40, 0,\r
+ 252, 44, 0, 252, 44, 0, 252, 48, 0, 252, 48, 0,\r
+ 252, 52, 0, 252, 52, 0, 252, 56, 0, 252, 56, 0,\r
+ 252, 60, 0, 252, 60, 0, 252, 64, 0, 252, 64, 0,\r
+ 252, 68, 0, 252, 68, 0, 252, 72, 0, 252, 72, 0,\r
+ 252, 76, 0, 252, 76, 0, 252, 80, 0, 252, 80, 0,\r
+ 252, 84, 0, 252, 84, 0, 252, 88, 0, 252, 88, 0,\r
+ 252, 92, 0, 252, 96, 0, 252, 96, 0, 252, 100, 0,\r
+ 252, 100, 0, 252, 104, 0, 252, 104, 0, 252, 108, 0,\r
+ 252, 108, 0, 252, 112, 0, 252, 112, 0, 252, 116, 0,\r
+ 252, 116, 0, 252, 120, 0, 252, 120, 0, 252, 124, 0,\r
+ 252, 124, 0, 252, 128, 0, 252, 128, 0, 252, 132, 0,\r
+ 252, 132, 0, 252, 136, 0, 252, 136, 0, 252, 140, 0,\r
+ 252, 140, 0, 252, 144, 0, 252, 144, 0, 252, 148, 0,\r
+ 252, 152, 0, 252, 152, 0, 252, 156, 0, 252, 156, 0,\r
+ 252, 160, 0, 252, 160, 0, 252, 164, 0, 252, 164, 0,\r
+ 252, 168, 0, 252, 168, 0, 252, 172, 0, 252, 172, 0,\r
+ 252, 176, 0, 252, 176, 0, 252, 180, 0, 252, 180, 0,\r
+ 252, 184, 0, 252, 184, 0, 252, 188, 0, 252, 188, 0,\r
+ 252, 192, 0, 252, 192, 0, 252, 196, 0, 252, 196, 0,\r
+ 252, 200, 0, 252, 200, 0, 252, 204, 0, 252, 208, 0,\r
+ 252, 208, 0, 252, 208, 0, 252, 208, 0, 252, 208, 0,\r
+ 252, 212, 0, 252, 212, 0, 252, 212, 0, 252, 212, 0,\r
+ 252, 216, 0, 252, 216, 0, 252, 216, 0, 252, 216, 0,\r
+ 252, 216, 0, 252, 220, 0, 252, 220, 0, 252, 220, 0,\r
+ 252, 220, 0, 252, 224, 0, 252, 224, 0, 252, 224, 0,\r
+ 252, 224, 0, 252, 228, 0, 252, 228, 0, 252, 228, 0,\r
+ 252, 228, 0, 252, 228, 0, 252, 232, 0, 252, 232, 0,\r
+ 252, 232, 0, 252, 232, 0, 252, 236, 0, 252, 236, 0,\r
+ 252, 236, 0, 252, 236, 0, 252, 240, 0, 252, 240, 0,\r
+ 252, 240, 0, 252, 240, 0, 252, 240, 0, 252, 244, 0,\r
+ 252, 244, 0, 252, 244, 0, 252, 244, 0, 252, 248, 0,\r
+ 252, 248, 0, 252, 248, 0, 252, 248, 0, 252, 252, 0,\r
+ 252, 252, 4, 252, 252, 8, 252, 252, 12, 252, 252, 16,\r
+ 252, 252, 20, 252, 252, 24, 252, 252, 28, 252, 252, 32,\r
+ 252, 252, 36, 252, 252, 40, 252, 252, 40, 252, 252, 44,\r
+ 252, 252, 48, 252, 252, 52, 252, 252, 56, 252, 252, 60,\r
+ 252, 252, 64, 252, 252, 68, 252, 252, 72, 252, 252, 76,\r
+ 252, 252, 80, 252, 252, 84, 252, 252, 84, 252, 252, 88,\r
+ 252, 252, 92, 252, 252, 96, 252, 252, 100, 252, 252, 104,\r
+ 252, 252, 108, 252, 252, 112, 252, 252, 116, 252, 252, 120,\r
+ 252, 252, 124, 252, 252, 124, 252, 252, 128, 252, 252, 132,\r
+ 252, 252, 136, 252, 252, 140, 252, 252, 144, 252, 252, 148,\r
+ 252, 252, 152, 252, 252, 156, 252, 252, 160, 252, 252, 164,\r
+ 252, 252, 168, 252, 252, 168, 252, 252, 172, 252, 252, 176,\r
+ 252, 252, 180, 252, 252, 184, 252, 252, 188, 252, 252, 192,\r
+ 252, 252, 196, 252, 252, 200, 252, 252, 204, 252, 252, 208,\r
+ 252, 252, 208, 252, 252, 212, 252, 252, 216, 252, 252, 220,\r
+ 252, 252, 224, 252, 252, 228, 252, 252, 232, 252, 252, 236,\r
+ 252, 252, 240, 252, 252, 244, 252, 252, 248, 252, 252, 252\r
+};\r
+\r
+ unsigned char *screen;\r
+ unsigned char *flamebuf_ptr;\r
+ unsigned char *flamebuf;\r
+ unsigned char temp;\r
+ unsigned short int i, j, skip;\r
+ unsigned char temp_byte;\r
+\r
+ set_paletteX(fire_pal);\r
+ set_write_plane(ALL_PLANES);\r
+ flamebuf = new unsigned char[BUF_SIZE];\r
+ skip = V_WIDTH;\r
+\r
+ // Initialize the video buffer to 0's\r
+ memset(flamebuf, 0, BUF_SIZE);\r
+\r
+ while (!kbhit()) {\r
+ // Transform current buffer\r
+ flamebuf_ptr = flamebuf;\r
+ i = (BUF_HEIGHT - 2);\r
+ while (i--) {\r
+ *flamebuf_ptr = (*(flamebuf_ptr + BUF_WIDTH) +\r
+ *(flamebuf_ptr + (BUF_WIDTH - 1)) +\r
+ *(flamebuf_ptr + (BUF_WIDTH + 1)) +\r
+ *(flamebuf_ptr + (BUF_WIDTH * 2))) >> 2;\r
+\r
+ flamebuf_ptr += BUF_WIDTH;\r
+ temp = *flamebuf_ptr;\r
+ if (temp > 11) {\r
+ *flamebuf_ptr -= 12;\r
+ } else if (temp > 3) {\r
+ *flamebuf_ptr -= 4;\r
+ } else {\r
+ *flamebuf_ptr = 0;\r
+ }\r
+ flamebuf_ptr += (1 - BUF_WIDTH);\r
+\r
+ j = (BUF_WIDTH - 2);\r
+ while (j--) {\r
+ *flamebuf_ptr = (*(flamebuf_ptr + BUF_WIDTH) +\r
+ *(flamebuf_ptr + (BUF_WIDTH - 1)) +\r
+ *(flamebuf_ptr + (BUF_WIDTH + 1)) +\r
+ *(flamebuf_ptr + (BUF_WIDTH * 2))) >> 2;\r
+\r
+ flamebuf_ptr += BUF_WIDTH;\r
+ temp = *flamebuf_ptr;\r
+ if (temp > 11) {\r
+ *flamebuf_ptr -= 12;\r
+ } else if (temp > 3) {\r
+ *flamebuf_ptr -= 4;\r
+ } else {\r
+ *flamebuf_ptr = 0;\r
+ }\r
+ flamebuf_ptr += (1 - BUF_WIDTH);\r
+ }\r
+\r
+ *flamebuf_ptr = (*(flamebuf_ptr + BUF_WIDTH) +\r
+ *(flamebuf_ptr + (BUF_WIDTH - 1)) +\r
+ *(flamebuf_ptr + (BUF_WIDTH * 2)) +\r
+ *(flamebuf_ptr + (BUF_WIDTH * 2) +\r
+ (BUF_WIDTH - 1))) >> 2;\r
+\r
+ flamebuf_ptr += BUF_WIDTH;\r
+ temp = *flamebuf_ptr;\r
+ if (temp > 11) {\r
+ *flamebuf_ptr -= 12;\r
+ } else if (temp > 3) {\r
+ *flamebuf_ptr -= 4;\r
+ } else {\r
+ *flamebuf_ptr = 0;\r
+ }\r
+ flamebuf_ptr += (1 - BUF_WIDTH);\r
+ }\r
+\r
+ // Set new bottom line with random white or black\r
+ temp = 0;\r
+ flamebuf_ptr = flamebuf + (BUF_WIDTH * (BUF_HEIGHT - 2));\r
+\r
+ j = BUF_WIDTH;\r
+ temp = 0;\r
+ while (j--) {\r
+ // We change the value 1/4 of the time\r
+ if ((rand() & 0x03) == 3) {\r
+ temp = (255 - temp);\r
+ }\r
+\r
+ *(flamebuf_ptr + BUF_WIDTH) = temp;\r
+ *flamebuf_ptr++ = temp;\r
+ }\r
+\r
+ // Write the buffer to the screen\r
+// wait_for_retrace();\r
+ screen = RowsX[40];\r
+ flamebuf_ptr = flamebuf;\r
+ i = V_HEIGHT;\r
+ while (i--) {\r
+ j = V_WIDTH;\r
+ while (j--) {\r
+ temp_byte = *flamebuf_ptr++;\r
+ *screen = temp_byte;\r
+ screen += skip;\r
+ *screen = temp_byte;\r
+ screen += skip;\r
+ *screen = temp_byte;\r
+ screen += skip;\r
+ *screen++ = temp_byte;\r
+ screen -= REWIND;\r
+ }\r
+ screen += REWIND;\r
+ }\r
+ }\r
+\r
+ getch();\r
+\r
+ delete flamebuf;\r
+}\r
+\r
+\r
+void\r
+main(void)\r
+{\r
+ FILE *fp;\r
+ char ch;\r
+ unsigned char pal[768];\r
+ COORD x1, y1, x2, y2;\r
+ Iangle theta1, theta2;\r
+ Fixed32 trigSin, trigCos;\r
+ blitbuf blit_image, sprite_image;\r
+ clock_t begin, end;\r
+ short int x, y, temp, done;\r
+ long i, time1, time2, time3, count, mtime;\r
+ BYTE *ptr1;\r
+ BYTE *ptr2;\r
+\r
+ set320x240x256_X();\r
+ clearX(0);\r
+\r
+ getch();\r
+\r
+ temp = loadfontX("vga8x8.fnt");\r
+\r
+ if (temp) {\r
+ putstringX(0, 0, "Hello!", 2);\r
+ } else {\r
+ return;\r
+ }\r
+\r
+ getch();\r
+\r
+#if ROTATE_DEMO\r
+ get_BIOSpaletteX(pal, 0);\r
+ set_paletteX(pal, 0);\r
+\r
+ clearX(0);\r
+ for (x=0; x < 320; x++) {\r
+ for (y=0; y < 240; y++) {\r
+ putpixelX(x, y, (x & 0xFF));\r
+ }\r
+ }\r
+\r
+ getch();\r
+\r
+ while (!kbhit()) {\r
+ wait_for_retrace();\r
+ rot_palette(-1);\r
+ }\r
+\r
+ getch();\r
+#endif\r
+\r
+ load_blitbufPCX("spock.pcx", &blit_image);\r
+ scale_blitbuf(160, 100, &blit_image);\r
+ aligned_bitblitX(0, 0, &blit_image);\r
+\r
+ getch();\r
+\r
+ clearX(0);\r
+\r
+ getch();\r
+\r
+ scale_blitbuf(224, 140, &blit_image);\r
+ aligned_bitblitX(0, 0, &blit_image);\r
+\r
+ getch();\r
+\r
+ greyscale_blitbuf(&blit_image);\r
+ grey_paletteX();\r
+ aligned_bitblitX(0, 0, &blit_image);\r
+\r
+ getch();\r
+\r
+ clearX(0);\r
+\r
+ getch();\r
+\r
+ scale_blitbuf(160, 100, &blit_image);\r
+ aligned_bitblitX(0, 0, &blit_image);\r
+\r
+ getch();\r
+\r
+ clear_blitbuf(&blit_image);\r
+ load_blitbufPCX("spock.pcx", &blit_image);\r
+ greyscale_blitbuf(&blit_image);\r
+ smooth64_paletteX(1, 0, 1);\r
+ aligned_bitblitX(0, 0, &blit_image);\r
+\r
+ getch();\r
+\r
+ flip_vertical_blitbuf(&blit_image);\r
+ aligned_bitblitX(0, 0, &blit_image);\r
+\r
+ getch();\r
+\r
+ clear_blitbuf(&blit_image);\r
+ load_blitbufPCX("spock.pcx", &blit_image);\r
+ aligned_bitblitX(0, 0, &blit_image);\r
+\r
+ done = 0;\r
+ while (!done) {\r
+ ch = getch();\r
+ switch (ch) {\r
+ case 'q':\r
+ case 'Q':\r
+ done = 1;\r
+ break;\r
+\r
+ case '+':\r
+ brighten_paletteX(1, 1, 1);\r
+ break;\r
+\r
+ case '-':\r
+ brighten_paletteX(-1, -1, -1);\r
+ break;\r
+\r
+ case '<':\r
+ stretch_paletteX(11, 11, 11);\r
+ break;\r
+\r
+ case '>':\r
+ stretch_paletteX(24, 24, 24);\r
+ break;\r
+\r
+ case 'S':\r
+ case 's':\r
+ save_blitbufPCX("dump.pcx", &blit_image);\r
+ break;\r
+\r
+ case 'L':\r
+ case 'l':\r
+ load_blitbufPCX("spock.pcx", &blit_image);\r
+ break;\r
+\r
+ case 'R':\r
+ brighten_paletteX(1, 0, 0);\r
+ break;\r
+\r
+ case 'G':\r
+ brighten_paletteX(0, 1, 0);\r
+ break;\r
+\r
+ case 'B':\r
+ brighten_paletteX(0, 0, 1);\r
+ break;\r
+\r
+ case 'r':\r
+ brighten_paletteX(-1, 0, 0);\r
+ break;\r
+\r
+ case 'g':\r
+ brighten_paletteX(0, -1, 0);\r
+ break;\r
+\r
+ case 'b':\r
+ brighten_paletteX(0, 0, -1);\r
+ break;\r
+\r
+ }\r
+ }\r
+\r
+ clearX(0);\r
+ srand(0);\r
+ grey_paletteX();\r
+\r
+ begin = clock();\r
+\r
+ for (i=0; i < 10000; i++) {\r
+ x1 = rand() % 320;\r
+ y1 = rand() % 200;\r
+ x2 = rand() % 320;\r
+ y2 = rand() % 200;\r
+\r
+ lineX(x1, y1, x2, y2, (i & 0x3F));\r
+ }\r
+\r
+ end = clock();\r
+\r
+ time1 = (end - begin);\r
+\r
+ begin = end;\r
+\r
+ for (i=0; i < 10000; i++) {\r
+ x1 = rand() % 320;\r
+ y1 = rand() % 200;\r
+ x2 = rand() % 320;\r
+ y2 = rand() % 200;\r
+\r
+ temp = ((x1 + x2 + y1 + y2) & 0x3F);\r
+ }\r
+\r
+ end = clock();\r
+\r
+ time2 = (end - begin);\r
+\r
+ getch();\r
+\r
+ for (i=0; i < 120; i++) {\r
+ filledboxX(i, i, (319-i), (239-i), (i & 0x3F));\r
+ }\r
+\r
+ getch();\r
+\r
+ load_blitbufPCX("buddha.pcx", &sprite_image);\r
+ transparent_bitblitX(100, 100, &sprite_image);\r
+\r
+ getch();\r
+\r
+ clearX(0);\r
+ clear_blitbuf(&blit_image);\r
+ scale_blitbuf(152, 168, &sprite_image);\r
+ alloc_blitbuf(&blit_image, 152, 168);\r
+\r
+ // 152x168 image\r
+ aligned_bitblitX(84, 36, &sprite_image);\r
+ getch();\r
+\r
+ initFixed32();\r
+\r
+ theta1=0;\r
+ count=0;\r
+\r
+ begin = clock();\r
+\r
+ while (!kbhit()) {\r
+ ptr1 = sprite_image.image;\r
+ ptr2 = blit_image.image;\r
+ theta2 = theta1;\r
+\r
+ y=168;\r
+ while (y--) {\r
+ CosSin(theta2, &trigCos, &trigSin);\r
+ scale_scanline(ptr1, ptr2, 152, 152, (trigCos >> 10) + 88);\r
+#if 0\r
+ memcpy(ptr2+152, ptr2, 152);\r
+ ptr1 += 304;\r
+ ptr2 += 304;\r
+ theta2 += 4;\r
+ y--;\r
+#else\r
+ ptr1 += 152;\r
+ ptr2 += 152;\r
+ theta2 += 2;\r
+#endif\r
+ }\r
+\r
+ theta1 += 2;\r
+\r
+ aligned_bitblitX(84, 36, &blit_image);\r
+ count++;\r
+ }\r
+\r
+ end = clock();\r
+\r
+ getch();\r
+ getch();\r
+\r
+ clear_blitbuf(&blit_image);\r
+ clear_blitbuf(&sprite_image);\r
+\r
+#if FIRE_DEMO\r
+ clearX(0);\r
+ fire_demo();\r
+#endif\r
+\r
+#if MONSTER_DEMO_ONE\r
+ mtime = monster_demo1();\r
+#endif\r
+\r
+#if MONSTER_DEMO_TWO\r
+ monster_demo2();\r
+#endif\r
+\r
+ set80x25();\r
+\r
+#if MATH_DEMO\r
+ Fixed32 c1, c2, c3, a1, a2, a3;\r
+\r
+ c1 = INT_TO_FIXED(50);\r
+ c2 = INT_TO_FIXED(70);\r
+ c3 = INT_TO_FIXED(50 * 70);\r
+\r
+ a1 = FixedMul(c1, c2);\r
+ a2 = FixedMulASM(c1, c2);\r
+\r
+ printf("MUL C version = %d\n", FIXED_TO_INT(a1));\r
+ printf("MUL ASM version = %d\n", FIXED_TO_INT(a2));\r
+\r
+ getch();\r
+\r
+ a1 = FixedDiv(c3, c1);\r
+ a2 = FixedDivASM(c3, c1);\r
+\r
+ printf("DIV C version = %d\n", FIXED_TO_INT(a1));\r
+ printf("DIV ASM version = %d\n", FIXED_TO_INT(a2));\r
+\r
+ getch();\r
+#endif\r
+\r
+ temp = (time1 - time2);\r
+ printf("10000 lines took %4d ticks\n", time1);\r
+ printf("rand() overhead = %4d ticks\n", time2);\r
+ printf("Time in lineX = %4d ticks\n", temp);\r
+ printf("%d lines per second!\n\n", (10000 * 1000) / (55 * temp));\r
+\r
+ temp = (end-begin);\r
+ printf("Buddha = %4d blits\n", count);\r
+ printf(" = %4d per second\n", (count * 1000) / (55 * temp));\r
+ printf("Buddha = %4d scanline stretches\n", (count * 168));\r
+ printf(" = %4d per second!\n\n", (count * 168000) / (55 * temp));\r
+\r
+ printf("Monster took %d ticks for 99 frames\n", mtime);\r
+}\r
+\r
--- /dev/null
+#include <conio.h>\r
+#include <mem.h>\r
+#include <stdio.h>\r
+\r
+#include "xtypes.hpp"\r
+#include "modex.hpp"\r
+#include "xpal.hpp"\r
+#include "xblitbuf.hpp"\r
+\r
+#define SEQU_ADDR 0x3C4\r
+#define GRACON_ADDR 0x3CE\r
+\r
+\r
+void\r
+clear_blitbuf(blitbuf *buf)\r
+{\r
+ buf->xsize = 0;\r
+ buf->ysize = 0;\r
+\r
+ delete buf->image;\r
+}\r
+\r
+\r
+void\r
+fill_blitbuf(BYTE color, blitbuf *buf)\r
+{\r
+ memset(buf->image, color, buf->xsize * buf->ysize);\r
+}\r
+\r
+\r
+void\r
+alloc_blitbuf(blitbuf *buf, DIST xsize, DIST ysize)\r
+{\r
+ buf->xsize = xsize;\r
+ buf->ysize = ysize;\r
+ buf->image = new BYTE[xsize * ysize];\r
+}\r
+\r
+\r
+void\r
+lin_2_pln_blitbuf(blitbuf *buf)\r
+{\r
+ int i, j, size;\r
+ BYTE *oldbuf;\r
+ BYTE *newbuf;\r
+ BYTE *src_ptr;\r
+ BYTE *dest_ptr;\r
+\r
+ oldbuf = buf->image;\r
+\r
+ size = (buf->xsize * buf->ysize);\r
+ newbuf = new BYTE[size];\r
+ size = (size >> 2);\r
+\r
+ dest_ptr = newbuf;\r
+\r
+ for (i=0; i < 4; i++) {\r
+ src_ptr = oldbuf + i;\r
+\r
+ j=size;\r
+ while (j--) {\r
+ *dest_ptr++ = *src_ptr;\r
+ src_ptr += 4;\r
+ }\r
+ }\r
+\r
+ buf->image = newbuf;\r
+ delete oldbuf;\r
+}\r
+\r
+\r
+void\r
+pln_2_lin_blitbuf(blitbuf *buf)\r
+{\r
+ int i, j, size;\r
+ BYTE *oldbuf;\r
+ BYTE *newbuf;\r
+ BYTE *src_ptr;\r
+ BYTE *dest_ptr;\r
+\r
+ oldbuf = buf->image;\r
+\r
+ size = (buf->xsize * buf->ysize);\r
+ newbuf = new BYTE[size];\r
+ size = (size >> 2);\r
+\r
+ src_ptr = oldbuf;\r
+ for (i=0; i < 4; i++) {\r
+ dest_ptr = newbuf + i;\r
+\r
+ j=size;\r
+ while (j--) {\r
+ *dest_ptr = *src_ptr++;\r
+ dest_ptr += 4;\r
+ }\r
+ }\r
+\r
+ buf->image = newbuf;\r
+ delete oldbuf;\r
+}\r
+\r
+\r
+void\r
+vanilla_bitblitX(COORD x, COORD y, blitbuf *buf)\r
+{\r
+ short int ysize, plane, i, j, loop, skip, rewind, len;\r
+ short int xsize[4];\r
+ BYTE *base_vga;\r
+ BYTE *vga_ptr;\r
+ BYTE *buf_ptr;\r
+\r
+ // Length of bitmap in each plane\r
+ plane = (x & 3);\r
+ i = buf->xsize + plane - 1;\r
+ xsize[0] = ((i--) >> 2);\r
+ xsize[1] = ((i--) >> 2);\r
+ xsize[2] = ((i--) >> 2);\r
+ xsize[3] = (i >> 2) + 1;\r
+\r
+ for (i=plane; i < 3; i++) {\r
+ xsize[i]++;\r
+ }\r
+\r
+ ysize = buf->ysize;\r
+ base_vga = RowsX[y] + (x >> 2) + activeStart;\r
+ write_plane = -1;\r
+\r
+ for (loop = 0; loop < 4; loop++) {\r
+ len = xsize[plane];\r
+ rewind = buf->xsize - (len << 2);\r
+ skip = widthBytes - len;\r
+ buf_ptr = buf->image + loop;\r
+ vga_ptr = base_vga;\r
+\r
+ outpw(SEQU_ADDR, plane_mask[plane++]);\r
+ if (plane == 4) {\r
+ plane = 0;\r
+ base_vga++;\r
+ }\r
+\r
+ i=ysize;\r
+ while (i--) {\r
+ j=len;\r
+ while (j--) {\r
+ *vga_ptr++ = *buf_ptr;\r
+ buf_ptr += 4;\r
+ }\r
+\r
+ buf_ptr += rewind;\r
+ vga_ptr += skip;\r
+ }\r
+ }\r
+}\r
+\r
+\r
+void\r
+vanilla_getblitX(COORD x, COORD y, blitbuf *buf)\r
+{\r
+ // Do nothing\r
+}\r
+\r
+\r
+void\r
+aligned_bitblitX(COORD x, COORD y, blitbuf *buf)\r
+{\r
+ short int i, j, plane, skip, xsize, ysize;\r
+ BYTE *base_vga;\r
+ BYTE *vga_ptr;\r
+ BYTE *buf_ptr;\r
+\r
+ xsize = (buf->xsize >> 2);\r
+ ysize = buf->ysize;\r
+ skip = widthBytes - xsize;\r
+ base_vga = RowsX[y] + (x >> 2) + activeStart;\r
+\r
+ for (plane=0; plane < 4; plane++) {\r
+ buf_ptr = buf->image + plane;\r
+ vga_ptr = base_vga;\r
+\r
+ outpw(SEQU_ADDR, plane_mask[plane]);\r
+\r
+ i=ysize;\r
+ while (i--) {\r
+ j=xsize;\r
+ while (j--) {\r
+ *vga_ptr++ = *buf_ptr;\r
+ buf_ptr += 4;\r
+ }\r
+ vga_ptr += skip;\r
+ }\r
+ }\r
+\r
+ write_plane = 3;\r
+}\r
+\r
+\r
+void\r
+aligned_getblitX(COORD x, COORD y, blitbuf *buf)\r
+{\r
+ short int i, j, plane, skip, xsize, ysize;\r
+ BYTE *base_vga;\r
+ BYTE *vga_ptr;\r
+ BYTE *buf_ptr;\r
+\r
+ xsize = (buf->xsize >> 2);\r
+ ysize = buf->ysize;\r
+ skip = widthBytes - xsize;\r
+ base_vga = RowsX[y] + (x >> 2) + activeStart;\r
+\r
+ for (plane=0; plane < 4; plane++) {\r
+ buf_ptr = buf->image + plane;\r
+ vga_ptr = base_vga;\r
+\r
+ outpw(GRACON_ADDR, read_mask[plane]);\r
+\r
+ i=ysize;\r
+ while (i--) {\r
+ j=xsize;\r
+ while (j--) {\r
+ *buf_ptr = *vga_ptr++;\r
+ buf_ptr += 4;\r
+ }\r
+ vga_ptr += skip;\r
+ }\r
+ }\r
+\r
+ read_plane = 3;\r
+}\r
+\r
+\r
+void\r
+transparent_bitblitX(COORD x, COORD y, blitbuf *buf)\r
+{\r
+ short int i, j, plane, skip, xsize, ysize;\r
+ BYTE *base_vga;\r
+ BYTE *vga_ptr;\r
+ BYTE *buf_ptr;\r
+\r
+ xsize = (buf->xsize >> 2);\r
+ ysize = buf->ysize;\r
+ skip = widthBytes - xsize;\r
+ base_vga = RowsX[y] + (x >> 2) + activeStart;\r
+\r
+ for (plane=0; plane < 4; plane++) {\r
+ buf_ptr = buf->image + plane;\r
+ vga_ptr = base_vga;\r
+\r
+ outpw(SEQU_ADDR, plane_mask[plane]);\r
+\r
+ i=ysize;\r
+ while (i--) {\r
+ j=xsize;\r
+ while (j--) {\r
+ if (*buf_ptr) {\r
+ *vga_ptr = *buf_ptr;\r
+ }\r
+ vga_ptr++;\r
+ buf_ptr += 4;\r
+ }\r
+ vga_ptr += skip;\r
+ }\r
+ }\r
+\r
+ write_plane = 3;\r
+}\r
+\r
+\r
+void\r
+planar_bitblitX(COORD x, COORD y, blitbuf *buf)\r
+{\r
+ short int i, plane, xsize, ysize;\r
+ BYTE *base_vga;\r
+ BYTE *vga_ptr;\r
+ BYTE *buf_ptr;\r
+\r
+ xsize = (buf->xsize >> 2);\r
+ ysize = buf->ysize;\r
+ base_vga = RowsX[y] + (x >> 2) + activeStart;\r
+ buf_ptr = buf->image;\r
+\r
+ for (plane=0; plane < 4; plane++) {\r
+ vga_ptr = base_vga;\r
+\r
+ outpw(SEQU_ADDR, plane_mask[plane]);\r
+\r
+ i=ysize;\r
+ while (i--) {\r
+ memcpy(vga_ptr, buf_ptr, xsize);\r
+ vga_ptr += widthBytes;\r
+ buf_ptr += xsize;\r
+ }\r
+ }\r
+\r
+ write_plane = 3;\r
+}\r
+\r
+\r
+void\r
+planar_getblitX(COORD x, COORD y, blitbuf *buf)\r
+{\r
+ short int i, plane, xsize, ysize;\r
+ BYTE *base_vga;\r
+ BYTE *vga_ptr;\r
+ BYTE *buf_ptr;\r
+\r
+ xsize = (buf->xsize >> 2);\r
+ ysize = buf->ysize;\r
+ base_vga = RowsX[y] + (x >> 2) + activeStart;\r
+ buf_ptr = buf->image;\r
+\r
+ for (plane=0; plane < 4; plane++) {\r
+ vga_ptr = base_vga;\r
+\r
+ outpw(GRACON_ADDR, read_mask[plane]);\r
+\r
+ i=ysize;\r
+ while (i--) {\r
+ memcpy(buf_ptr, vga_ptr, xsize);\r
+ vga_ptr += widthBytes;\r
+ buf_ptr += xsize;\r
+ }\r
+ }\r
+\r
+ read_plane = 3;\r
+}\r
+\r
+\r
+void\r
+wide_bitblitX(COORD y, blitbuf *buf)\r
+{\r
+ short int bufsize;\r
+ BYTE *vga_ptr;\r
+ BYTE *buf_ptr;\r
+\r
+ write_plane = 3;\r
+ buf_ptr = buf->image;\r
+ vga_ptr = RowsX[y] + activeStart;\r
+ bufsize = (buf->ysize * widthBytes);\r
+\r
+ outpw(SEQU_ADDR, PLANE_0);\r
+ memcpy(vga_ptr, buf_ptr, bufsize);\r
+ buf_ptr += bufsize;\r
+\r
+ outpw(SEQU_ADDR, PLANE_1);\r
+ memcpy(vga_ptr, buf_ptr, bufsize);\r
+ buf_ptr += bufsize;\r
+\r
+ outpw(SEQU_ADDR, PLANE_2);\r
+ memcpy(vga_ptr, buf_ptr, bufsize);\r
+ buf_ptr += bufsize;\r
+\r
+ outpw(SEQU_ADDR, PLANE_3);\r
+ memcpy(vga_ptr, buf_ptr, bufsize);\r
+}\r
+\r
+\r
+void\r
+wide_getblitX(COORD y, blitbuf *buf)\r
+{\r
+ short int bufsize;\r
+ BYTE *vga_ptr;\r
+ BYTE *buf_ptr;\r
+\r
+ read_plane = 3;\r
+ buf_ptr = buf->image;\r
+ vga_ptr = RowsX[y] + activeStart;\r
+ bufsize = (buf->ysize * widthBytes);\r
+\r
+ outpw(GRACON_ADDR, READ_PLANE_0);\r
+ memcpy(buf_ptr, vga_ptr, bufsize);\r
+ buf_ptr += bufsize;\r
+\r
+ outpw(GRACON_ADDR, READ_PLANE_1);\r
+ memcpy(buf_ptr, vga_ptr, bufsize);\r
+ buf_ptr += bufsize;\r
+\r
+ outpw(GRACON_ADDR, READ_PLANE_2);\r
+ memcpy(buf_ptr, vga_ptr, bufsize);\r
+ buf_ptr += bufsize;\r
+\r
+ outpw(GRACON_ADDR, READ_PLANE_3);\r
+ memcpy(buf_ptr, vga_ptr, bufsize);\r
+}\r
+\r
+\r
+void\r
+save_blitbufPCX(char *fname, blitbuf *buf)\r
+{\r
+ FILE *fp;\r
+ unsigned int i, size, temp_int;\r
+ BYTE VGA_pal[768];\r
+ BYTE *buf_ptr;\r
+ BYTE temp_char, match, count;\r
+\r
+ fp = fopen(fname, "wb");\r
+\r
+ if (fp != NULL) {\r
+ // Write manufacturer's byte\r
+ temp_char = 10;\r
+ fwrite(&temp_char, 1, 1, fp);\r
+\r
+ // Write version of PCX. 5 = 256 color (PCX Version 5.0)\r
+ temp_char = 5;\r
+ fwrite(&temp_char, 1, 1, fp);\r
+\r
+ // Write encoding type, always 1 for RLE.\r
+ temp_char = 1;\r
+ fwrite(&temp_char, 1, 1, fp);\r
+\r
+ // Write bits_per_pixel = 8.\r
+ temp_char = 8;\r
+ fwrite(&temp_char, 1, 1, fp);\r
+\r
+ // Write starting X and Y coords\r
+ temp_int = 0;\r
+ fwrite(&temp_int, 2, 1, fp);\r
+ fwrite(&temp_int, 2, 1, fp);\r
+\r
+ // Write X size\r
+ temp_int = (buf->xsize - 1);\r
+ fwrite(&temp_int, 2, 1, fp);\r
+\r
+ // Write Y size\r
+ temp_int = (buf->ysize - 1);\r
+ fwrite(&temp_int, 2, 1, fp);\r
+\r
+ // Do HRES and VRES **\r
+ temp_int = buf->xsize;\r
+ fwrite(&temp_int, 2, 1, fp);\r
+ temp_int = buf->ysize;\r
+ fwrite(&temp_int, 2, 1, fp);\r
+\r
+ // Write 16 color palette, not used.\r
+ temp_int = 0;\r
+ i=24;\r
+ while (i--) {\r
+ fwrite(&temp_int, 2, 1, fp);\r
+ }\r
+\r
+ // Write vmode byte.\r
+ temp_char = 0;\r
+ fwrite(&temp_char, 1, 1, fp);\r
+\r
+ // Write bit_planes\r
+ temp_char = 1;\r
+ fwrite(&temp_char, 1, 1, fp);\r
+\r
+ // Write bytes_per_line\r
+ temp_int = buf->xsize;\r
+ fwrite(&temp_int, 2, 1, fp);\r
+\r
+ // Write palette type\r
+ temp_int = 1;\r
+ fwrite(&temp_int, 2, 1, fp);\r
+\r
+ // Write junk filler\r
+ temp_int = 0;\r
+ i=29;\r
+ while (i--) {\r
+ fwrite(&temp_int, 2, 1, fp);\r
+ }\r
+\r
+ // Write the actual image\r
+ buf_ptr = buf->image;\r
+ size = (buf->xsize * buf->ysize);\r
+\r
+ count = 0;\r
+ match = *buf_ptr;\r
+\r
+ i=size;\r
+ while (i--) {\r
+ temp_char = *buf_ptr++;\r
+\r
+ if ((temp_char == match) && (count < 63)) {\r
+ count++;\r
+ } else {\r
+ if ((count == 1) && (match < 192)) {\r
+ // Write single byte\r
+ fwrite(&match,1,1,fp);\r
+ } else {\r
+ // Write run of pixels\r
+ count += 192;\r
+ fwrite(&count, 1, 1, fp);\r
+ fwrite(&match, 1, 1, fp);\r
+ }\r
+ count = 1;\r
+ match = temp_char;\r
+ }\r
+ }\r
+\r
+ if ((count == 1) && (match < 192)) {\r
+ // Write single byte\r
+ fwrite(&match,1,1,fp);\r
+ } else {\r
+ // Write run of pixels\r
+ count += 192;\r
+ fwrite(&count, 1, 1, fp);\r
+ fwrite(&match, 1, 1, fp);\r
+ }\r
+\r
+ // Write palette verification byte\r
+ temp_char = 12;\r
+ fwrite(&temp_char, 1, 1, fp);\r
+\r
+ get_paletteX(VGA_pal);\r
+\r
+ // Write 256 color palette\r
+ fwrite(VGA_pal, 1, 768, fp);\r
+\r
+ fclose(fp);\r
+ }\r
+}\r
+\r
+\r
+int\r
+load_blitbufPCX(char *fname, blitbuf *buf)\r
+{\r
+ FILE *fp;\r
+ int size;\r
+ BYTE VGA_pal[768];\r
+ BYTE PCX_byte, RLE_byte;\r
+ BYTE *buf_ptr;\r
+ BYTE *end_of_buf;\r
+\r
+ fp = fopen(fname, "rb");\r
+\r
+ if (fp == NULL) {\r
+ buf->xsize = 0;\r
+ buf->ysize = 0;\r
+ buf->image = NULL;\r
+ return 0;\r
+ } else {\r
+ fseek(fp, 8, SEEK_SET);\r
+ fread(&buf->xsize, 2, 1, fp);\r
+ fread(&buf->ysize, 2, 1, fp);\r
+\r
+ buf->xsize++;\r
+ buf->ysize++;\r
+\r
+ size = (buf->xsize * buf->ysize);\r
+\r
+ buf->image = new BYTE[size];\r
+ buf_ptr = buf->image;\r
+ end_of_buf = buf_ptr + size;\r
+\r
+ // Load 256 color PCX palette\r
+ fseek(fp, -768, SEEK_END);\r
+ fread(VGA_pal, 1, 768, fp);\r
+\r
+ set_paletteX(VGA_pal);\r
+\r
+ fseek(fp, 128, SEEK_SET);\r
+\r
+ while (buf_ptr < end_of_buf) {\r
+ // Read next packet\r
+ fread(&PCX_byte, 1, 1, fp);\r
+\r
+ if (PCX_byte < 192) {\r
+ // Raw Pixel\r
+ *buf_ptr++ = PCX_byte;\r
+ } else {\r
+ // RLE Pixels\r
+ PCX_byte = PCX_byte & 0x3F;\r
+ fread(&RLE_byte, 1, 1, fp);\r
+ memset(buf_ptr, RLE_byte, PCX_byte);\r
+ buf_ptr += PCX_byte;\r
+ }\r
+ }\r
+\r
+ fclose(fp);\r
+ return 1;\r
+ }\r
+}\r
+\r
+\r
+void\r
+scale_blitbuf(DIST dest_x, DIST dest_y, blitbuf *buf1, blitbuf *buf2)\r
+{\r
+ unsigned long ErrorAccX, ErrorAccY, ErrorAdjX, ErrorAdjY;\r
+ DIST oldx, oldy, newx, newy;\r
+ short int i, j, count;\r
+ BYTE *src_base;\r
+ BYTE *src_ptr;\r
+ BYTE *dest_ptr;\r
+ BYTE *newbuf;\r
+\r
+ oldx = buf1->xsize;\r
+ oldy = buf1->ysize;\r
+ newx = dest_x;\r
+ newy = dest_y;\r
+\r
+ newbuf = new BYTE[newx * newy];\r
+\r
+ src_base = buf1->image;\r
+ dest_ptr = newbuf;\r
+\r
+ // My bitmap scaling routine. As you probably noticed, it's\r
+ // pretty Bresenhammy!\r
+\r
+ ErrorAccY = 0x8000;\r
+\r
+ if (newx > oldx) {\r
+ // Biggering\r
+ ErrorAdjX = ((((unsigned long)newx) << 16) /\r
+ (((unsigned long)oldx)));\r
+\r
+ ErrorAdjY = ((((unsigned long)newy) << 16) /\r
+ (((unsigned long)oldy)));\r
+\r
+ i=oldy;\r
+ while (i--) {\r
+ ErrorAccX = 0x8000;\r
+ src_ptr = src_base;\r
+\r
+ j=oldx;\r
+ while (j--) {\r
+ ErrorAccX += ErrorAdjX;\r
+ if (count = (ErrorAccX >> 16)) {\r
+ ErrorAccX &= 0xFFFFL;\r
+ while (count--) {\r
+ *dest_ptr++ = *src_ptr;\r
+ }\r
+ }\r
+ src_ptr++;\r
+ }\r
+\r
+ ErrorAccY += ErrorAdjY;\r
+ count = (ErrorAccY >> 16) - 1;\r
+ while (count--) {\r
+ memcpy(dest_ptr, dest_ptr - newx, newx);\r
+ dest_ptr += newx;\r
+ }\r
+ ErrorAccY &= 0xFFFFL;\r
+ src_base += oldx;\r
+ }\r
+ } else {\r
+ // Smallering\r
+ ErrorAdjX = ((((unsigned long)oldx) << 16) /\r
+ (((unsigned long)newx)));\r
+\r
+ ErrorAdjY = ((((unsigned long)oldy) << 16) /\r
+ (((unsigned long)newy)));\r
+\r
+ i=newy;\r
+ while (i--) {\r
+ ErrorAccX = 0x8000;\r
+ src_ptr = src_base;\r
+\r
+ j=newx;\r
+ while (j--) {\r
+ *dest_ptr++ = *src_ptr;\r
+ ErrorAccX += ErrorAdjX;\r
+ src_ptr += (ErrorAccX >> 16);\r
+ ErrorAccX &= 0xFFFFL;\r
+ }\r
+\r
+ ErrorAccY += ErrorAdjY;\r
+ src_base += (oldx * (ErrorAccY >> 16));\r
+ ErrorAccY &= 0xFFFFL;\r
+ }\r
+ }\r
+\r
+ if (buf2 == NULL) {\r
+ delete buf1->image;\r
+ buf1->xsize = newx;\r
+ buf1->ysize = newy;\r
+ buf1->image = newbuf;\r
+ } else {\r
+ if (buf2->image != NULL) {\r
+ delete buf2->image;\r
+ }\r
+ buf2->xsize = newx;\r
+ buf2->ysize = newy;\r
+ buf2->image = newbuf;\r
+ }\r
+}\r
+\r
+\r
+void\r
+vertical_scale_blitbuf(DIST dest_y, blitbuf *buf1, blitbuf *buf2)\r
+{\r
+ unsigned long ErrorAccY, ErrorAdjY;\r
+ DIST xsize, oldy, newy;\r
+ short int i, count;\r
+ BYTE *src_ptr;\r
+ BYTE *dest_ptr;\r
+ BYTE *newbuf;\r
+\r
+ xsize = buf1->xsize;\r
+ oldy = buf1->ysize;\r
+ newy = dest_y;\r
+\r
+ newbuf = new BYTE[xsize * newy];\r
+\r
+ src_ptr = buf1->image;\r
+ dest_ptr = newbuf;\r
+\r
+ // My bitmap scaling routine. As you probably noticed, it's\r
+ // pretty Bresenhammy!\r
+\r
+ ErrorAccY = 0x8000;\r
+ ErrorAdjY = ((((unsigned long)newy) << 16) /\r
+ (((unsigned long)oldy)));\r
+\r
+ if (newy >= oldy) {\r
+ // Biggering\r
+ i=oldy;\r
+ while (i--) {\r
+ ErrorAccY += ErrorAdjY;\r
+ if (count = (ErrorAccY >> 16)) {\r
+ ErrorAccY &= 0xFFFFL;\r
+\r
+ while (count--) {\r
+ memcpy(dest_ptr, src_ptr, xsize);\r
+ dest_ptr += xsize;\r
+ }\r
+ }\r
+\r
+ src_ptr += xsize;\r
+ }\r
+ } else {\r
+ // Smallering\r
+ i=oldy;\r
+ while (i--) {\r
+ ErrorAccY += ErrorAdjY;\r
+ if (ErrorAccY & ~0xFFFFL) {\r
+ ErrorAccY &= 0xFFFFL;\r
+ memcpy(dest_ptr, src_ptr, xsize);\r
+ dest_ptr += xsize;\r
+ }\r
+\r
+ src_ptr += xsize;\r
+ }\r
+ }\r
+\r
+ if (buf2 == NULL) {\r
+ delete buf1->image;\r
+ buf1->ysize = newy;\r
+ buf1->image = newbuf;\r
+ } else {\r
+ if (buf2->image != NULL) {\r
+ delete buf2->image;\r
+ }\r
+ buf2->xsize = xsize;\r
+ buf2->ysize = newy;\r
+ buf2->image = newbuf;\r
+ }\r
+}\r
+\r
+\r
+void\r
+greyscale_blitbuf(blitbuf *buf)\r
+{\r
+ BYTE temp_pal[768];\r
+ BYTE *buf_ptr;\r
+ BYTE *temp;\r
+ BYTE r, g;\r
+ unsigned int i;\r
+\r
+ buf_ptr = buf->image;\r
+\r
+ get_paletteX(temp_pal, 0);\r
+\r
+ for (i = (buf->xsize * buf->ysize); i; i--) {\r
+ temp = temp_pal + ((*buf_ptr) * 3);\r
+ r = *temp++;\r
+ g = *temp++;\r
+\r
+ *buf_ptr++ = ((r * 19) + (g * 37) + (*temp << 3)) >> 6;\r
+ }\r
+}\r
+\r
+\r
+void\r
+RGB_blitbuf(blitbuf *buf)\r
+{\r
+ BYTE temp_pal[768];\r
+ BYTE *buf_ptr;\r
+ BYTE *temp;\r
+ BYTE r, g, b;\r
+ unsigned int i;\r
+\r
+ buf_ptr = buf->image;\r
+\r
+ get_paletteX(temp_pal, 0);\r
+\r
+ for (i = (buf->xsize * buf->ysize); i; i--) {\r
+ temp = temp_pal + ((*buf_ptr) * 3);\r
+ r = (*temp) + 4;\r
+ temp++;\r
+ g = (*temp) + 4;\r
+ temp++;\r
+ b = (*temp) + 8;\r
+\r
+ *buf_ptr++ = ((r >> 3) << 5) + ((g >> 3) << 2) + (b >> 4);\r
+ }\r
+}\r
+\r
+\r
+void\r
+flip_vertical_blitbuf(blitbuf *buf)\r
+{\r
+ BYTE *top;\r
+ BYTE *bottom;\r
+ BYTE *temp;\r
+ DIST i, x, y;;\r
+\r
+ x = buf->xsize;\r
+ y = buf->ysize;\r
+\r
+ temp = new BYTE[x];\r
+\r
+ top = buf->image;\r
+ bottom = buf->image + (x * (y-1));\r
+\r
+ i = (y >> 1);\r
+ while (i--) {\r
+ memcpy(temp, top, x);\r
+ memcpy(top, bottom, x);\r
+ memcpy(bottom, temp, x);\r
+ top += x;\r
+ bottom -= x;\r
+ }\r
+\r
+ delete temp;\r
+}\r
+\r
+\r
+void\r
+flip_horizontal_blitbuf(blitbuf *buf)\r
+{\r
+ BYTE *buf_ptr;\r
+ BYTE *temp_ptr;\r
+ BYTE *temp;\r
+ DIST i, j, x;\r
+\r
+ x = buf->xsize;\r
+\r
+ temp = new BYTE[x];\r
+\r
+ buf_ptr = buf->image;\r
+\r
+ i = buf->ysize;\r
+ while (i--) {\r
+ memcpy(temp, buf_ptr, x);\r
+ temp_ptr = temp + (x - 1);\r
+ j=x;\r
+ while (j--) {\r
+ *buf_ptr++ = *temp_ptr--;\r
+ }\r
+ }\r
+\r
+ delete temp;\r
+}\r
+\r
+\r
+void\r
+brighten_blitbuf(SBYTE factor, blitbuf *buf)\r
+{\r
+ BYTE *buf_ptr;\r
+ short int scratch;\r
+ unsigned int i;\r
+\r
+ buf_ptr = buf->image;\r
+\r
+ for (i = (buf->xsize * buf->ysize); i; i--) {\r
+ scratch = (*buf_ptr + factor);\r
+ if (scratch <= 0) {\r
+ *buf_ptr++ = 0;\r
+ } else if (scratch >= 63) {\r
+ *buf_ptr++ = 63;\r
+ } else {\r
+ *buf_ptr++ = scratch;\r
+ }\r
+ }\r
+}\r
+\r
+\r
+void\r
+stretch_blitbuf(BYTE factor, blitbuf *buf)\r
+{\r
+ BYTE *buf_ptr;\r
+ short int scratch;\r
+ unsigned int i;\r
+\r
+ buf_ptr = buf->image;\r
+\r
+ for (i = (buf->xsize * buf->ysize); i; i--) {\r
+ scratch = ((((*buf_ptr - 32) * factor) + 8) >> 4) + 32;\r
+ if (scratch <= 0) {\r
+ *buf_ptr++ = 0;\r
+ } else if (scratch >= 63) {\r
+ *buf_ptr++ = 63;\r
+ } else {\r
+ *buf_ptr++ = scratch;\r
+ }\r
+ }\r
+}\r
+\r
+\r
+void\r
+pixelize(DIST pixfactor, blitbuf *buf)\r
+{\r
+ // Do nothing\r
+}\r
+\r
+\r
+void\r
+GREYconvolve_blitbuf(BYTE *kernel, blitbuf *buf)\r
+{\r
+ // Do nothing\r
+}\r
+\r
+\r
+void\r
+RGBconvolve_blitbuf(BYTE *kernel, blitbuf *buf)\r
+{\r
+ // Do nothing\r
+}\r
+\r
+\r
+void\r
+scale_scanline(BYTE *source, BYTE *dest, DIST smap_size, DIST dmap_size,\r
+ DIST dline_size)\r
+{\r
+ unsigned long ErrorAcc, ErrorAdj;\r
+ short int i, temp, invert;\r
+\r
+ ErrorAcc = 0x8000;\r
+\r
+ // Prepare for backwards scanlines\r
+ if (dline_size >= 0) {\r
+ invert = 0;\r
+ } else {\r
+ invert = 1;\r
+ dline_size = -dline_size;\r
+ }\r
+\r
+ if (dline_size > smap_size) {\r
+ // Biggering\r
+ if (smap_size == 0) {\r
+ return;\r
+ }\r
+ ErrorAdj = ((((unsigned long)dline_size) << 16) /\r
+ (((unsigned long)smap_size)));\r
+\r
+ i=smap_size;\r
+ while (i--) {\r
+ ErrorAcc += ErrorAdj;\r
+ temp = (ErrorAcc >> 16);\r
+ ErrorAcc &= 0xFFFFL;\r
+ while (temp--) {\r
+ *dest++ = *source;\r
+ }\r
+ source++;\r
+ }\r
+ } else {\r
+ // Smallering\r
+ if (dline_size == 0) {\r
+ memset(dest, 0, dmap_size);\r
+ } else {\r
+ temp = dmap_size - dline_size;\r
+ i = temp >> 1;\r
+ temp -= i;\r
+ while (i--) {\r
+ *dest++ = 0;\r
+ }\r
+\r
+ ErrorAdj = ((((unsigned long)smap_size) << 16) /\r
+ (((unsigned long)dline_size)));\r
+\r
+ i=dline_size;\r
+\r
+ while (i--) {\r
+ *dest++ = *source;\r
+ ErrorAcc += ErrorAdj;\r
+ source += (ErrorAcc >> 16);\r
+ ErrorAcc &= 0xFFFFL;\r
+ }\r
+\r
+ while (temp--) {\r
+ *dest++ = 0;\r
+ }\r
+ }\r
+ }\r
+}\r
+\r
+\r
+int\r
+load_blitbufRAW(char *rawname, char *palname, blitbuf *buf)\r
+{\r
+ FILE *fp;\r
+ BYTE VGA_pal[768];\r
+\r
+ fp = fopen(rawname, "rb");\r
+\r
+ if (fp == NULL) {\r
+ buf->xsize = 0;\r
+ buf->ysize = 0;\r
+ buf->image = NULL;\r
+ return 0;\r
+ } else {\r
+ buf->xsize = 320;\r
+ buf->ysize = 200;\r
+ buf->image = new BYTE[64000L];\r
+\r
+ // Load image\r
+ fread(buf->image, 64000L, 1, fp);\r
+\r
+ if (palname == NULL) {\r
+ fread(VGA_pal, 1, 768, fp);\r
+ set_paletteX(VGA_pal);\r
+ fclose(fp);\r
+ } else {\r
+ fclose(fp);\r
+ fp = fopen(palname, "rb");\r
+ if (fp != NULL) {\r
+ fread(VGA_pal, 1, 768, fp);\r
+ set_paletteX(VGA_pal);\r
+ fclose(fp);\r
+ }\r
+ }\r
+\r
+ return 1;\r
+ }\r
+}\r
+\r
--- /dev/null
+#ifndef X_BLITBUF_HPP\r
+ #define X_BLITBUF_HPP\r
+\r
+// Basic BlitBuf functions\r
+void clear_blitbuf(blitbuf *buf);\r
+void fill_blitbuf(BYTE color, blitbuf *buf);\r
+void alloc_blitbuf(blitbuf *buf, DIST xsize, DIST ysize);\r
+void lin_2_pln_blitbuf(blitbuf *buf);\r
+void pln_2_lin_blitbuf(blitbuf *buf);\r
+\r
+// Adjust color in blitbuf\r
+void greyscale_blitbuf(blitbuf *buf);\r
+void RGB_blitbuf(blitbuf *buf);\r
+void brighten_blitbuf(SBYTE factor, blitbuf *buf);\r
+void stretch_blitbuf(BYTE factor, blitbuf *buf); // factor = 1/16 units\r
+\r
+// Image processing: These expect a linear blitbuf\r
+void scale_blitbuf(DIST dest_x, DIST dest_y,\r
+ blitbuf *buf1, blitbuf *buf2 = NULL);\r
+void vertical_scale_blitbuf(DIST dest_y, blitbuf *buf1, blitbuf *buf2 = NULL);\r
+void flip_vertical_blitbuf(blitbuf *buf);\r
+void flip_horizontal_blitbuf(blitbuf *buf);\r
+void pixelize(DIST pixfactor, blitbuf *buf); // Not written yet\r
+void scale_scanline(BYTE *source, BYTE *dest, DIST smap_size,\r
+ DIST dmap_size, DIST dline_size);\r
+\r
+// Image Convolution by a 3x3 kernel (linear)\r
+void GREYconvolve_blitbuf(BYTE *kernel, blitbuf *buf); // Not written yet\r
+void RGBconvolve_blitbuf(BYTE *kernel, blitbuf *buf); // Not written yet\r
+\r
+// Vanilla blits can be any size, anywhere\r
+void vanilla_bitblitX(COORD x, COORD y, blitbuf *buf);\r
+void vanilla_getblitX(COORD x, COORD y, blitbuf *buf);\r
+\r
+// Transparent blits must be aligned and 0 is the "transparent" value\r
+void transparent_bitblitX(COORD x, COORD y, blitbuf *buf);\r
+\r
+// Aligned blits must have X and XSIZE evenly divisible by 4\r
+void aligned_bitblitX(COORD x, COORD y, blitbuf *buf);\r
+void aligned_getblitX(COORD x, COORD y, blitbuf *buf);\r
+\r
+// Planar blits must be aligned and also be ordered in 4-planar fashion\r
+void planar_bitblitX(COORD x, COORD y, blitbuf *buf);\r
+void planar_getblitX(COORD x, COORD y, blitbuf *buf);\r
+\r
+// Wide blits must be planar and are assumed to be as wide as the screen\r
+void wide_bitblitX(COORD y, blitbuf *buf);\r
+void wide_getblitX(COORD y, blitbuf *buf);\r
+\r
+// PCX functions\r
+void save_blitbufPCX(char *fname, blitbuf *buf);\r
+int load_blitbufPCX(char *fname, blitbuf *buf);\r
+\r
+// RAW file functions (320x200 only)\r
+int load_blitbufRAW(char *rawname, char *palname, blitbuf *buf);\r
+\r
+#endif\r
+\r
--- /dev/null
+#include <conio.h>\r
+#include <dos.h>\r
+#include <mem.h>\r
+\r
+#include "modex.hpp"\r
+#include "xpal.hpp"\r
+\r
+BYTE Xpal[768];\r
+\r
+void\r
+set_paletteX(BYTE *pal, FLAG downgrade)\r
+{\r
+ short int i;\r
+ BYTE *buf;\r
+\r
+ memcpy(Xpal, pal, 768);\r
+\r
+ buf = Xpal;\r
+ if (downgrade) {\r
+ i=768;\r
+ while (i--) {\r
+ *buf++ = (*buf >> 2);\r
+ }\r
+ }\r
+\r
+ outp(0x03c8, 0); // Start with color 0\r
+ buf = Xpal;\r
+ i=256;\r
+ while (i--) {\r
+ outp(0x03c9, *buf++);\r
+ outp(0x03c9, *buf++);\r
+ outp(0x03c9, *buf++);\r
+ }\r
+}\r
+\r
+\r
+void\r
+get_paletteX(BYTE *pal, FLAG upgrade)\r
+{\r
+ int i;\r
+\r
+ memcpy(pal, Xpal, 768);\r
+\r
+ if (upgrade) {\r
+ i=768;\r
+ while (i--) {\r
+ *pal++ = (*pal << 2);\r
+ }\r
+ }\r
+}\r
+\r
+\r
+void\r
+get_BIOSpaletteX(BYTE *pal, FLAG upgrade)\r
+{\r
+ int i;\r
+ union REGS r;\r
+\r
+ r.x.eax = 0x1017;\r
+ r.x.ebx = 0;\r
+ r.x.ecx = 256;\r
+ r.x.edx = (unsigned long) pal;\r
+\r
+ int386(0x10, &r, &r);\r
+\r
+ if (upgrade) {\r
+ i=768;\r
+ while (i--) {\r
+ *pal++ = (*pal << 2);\r
+ }\r
+ }\r
+}\r
+\r
+\r
+void\r
+photo_negativeX(void)\r
+{\r
+ short int i;\r
+ BYTE temp_pal[768];\r
+ BYTE *temp;\r
+\r
+ get_paletteX(temp_pal, 0);\r
+ temp = temp_pal;\r
+\r
+ for (i=0; i < 256; i++) {\r
+ *temp++ = (64 - (*temp));\r
+ *temp++ = (64 - (*temp));\r
+ *temp++ = (64 - (*temp));\r
+ }\r
+\r
+ set_paletteX(temp_pal, 0);\r
+}\r
+\r
+\r
+void\r
+grey_paletteX(void)\r
+{\r
+ smooth64_paletteX(1, 1, 1);\r
+}\r
+\r
+\r
+void\r
+RGB_paletteX(void)\r
+{\r
+ BYTE r, g, b;\r
+ BYTE temp_pal[768];\r
+ BYTE *temp;\r
+\r
+ temp = temp_pal;\r
+\r
+ for (r=0; r < 8; r++) {\r
+ for (g=0; g < 8; g++) {\r
+ for (b=0; b < 4; b++) {\r
+ *temp++ = (r << 3);\r
+ *temp++ = (g << 3);\r
+ *temp++ = (b << 4);\r
+ }\r
+ }\r
+ }\r
+\r
+ set_paletteX(temp_pal, 0);\r
+}\r
+\r
+\r
+void\r
+smooth64_paletteX(BYTE r, BYTE g, BYTE b)\r
+{\r
+ short int i;\r
+ BYTE temp_pal[768];\r
+ BYTE *temp;\r
+\r
+ memset(temp_pal, 0, 768);\r
+\r
+\r
+ if (r) {\r
+ temp = temp_pal;\r
+ for (i=0; i < 64; i++) {\r
+ *temp = i;\r
+ temp += 3;\r
+ }\r
+ }\r
+\r
+ if (g) {\r
+ temp = temp_pal + 1;\r
+ for (i=0; i < 64; i++) {\r
+ *temp = i;\r
+ temp += 3;\r
+ }\r
+ }\r
+\r
+ if (b) {\r
+ temp = temp_pal + 2;\r
+ for (i=0; i < 64; i++) {\r
+ *temp = i;\r
+ temp += 3;\r
+ }\r
+ }\r
+\r
+ set_paletteX(temp_pal, 0);\r
+}\r
+\r
+\r
+void\r
+brighten_paletteX(SBYTE r, SBYTE g, SBYTE b)\r
+{\r
+ short int i, j, scratch;\r
+ BYTE temp_pal[768];\r
+ BYTE *temp;\r
+ SBYTE dummy[3];\r
+\r
+ get_paletteX(temp_pal, 0);\r
+ temp = temp_pal;\r
+\r
+ dummy[0] = r;\r
+ dummy[1] = g;\r
+ dummy[2] = b;\r
+\r
+ for (i=0; i < 256; i++) {\r
+ for (j=0; j < 3; j++) {\r
+ scratch = *temp + dummy[j];\r
+ if (scratch <= 0) {\r
+ *temp++ = 0;\r
+ } else if (scratch >= 63) {\r
+ *temp++ = 63;\r
+ } else {\r
+ *temp++ = scratch;\r
+ }\r
+ }\r
+ }\r
+\r
+ set_paletteX(temp_pal, 0);\r
+}\r
+\r
+\r
+void\r
+stretch_paletteX(BYTE r, BYTE g, BYTE b)\r
+{\r
+ short int i, j, scratch;\r
+ BYTE temp_pal[768];\r
+ BYTE *temp;\r
+ BYTE dummy[3];\r
+\r
+ get_paletteX(temp_pal, 0);\r
+ temp = temp_pal;\r
+\r
+ dummy[0] = r;\r
+ dummy[1] = g;\r
+ dummy[2] = b;\r
+\r
+ for (i=0; i < 256; i++) {\r
+ for (j=0; j < 3; j++) {\r
+ scratch = ((((*temp - 32) * dummy[j]) + 8) >> 4) + 32;\r
+ if (scratch <= 0) {\r
+ *temp++ = 0;\r
+ } else if (scratch >= 63) {\r
+ *temp++ = 63;\r
+ } else {\r
+ *temp++ = scratch;\r
+ }\r
+ }\r
+ }\r
+\r
+ set_paletteX(temp_pal, 0);\r
+}\r
+\r
+\r
+void\r
+rot_palette(BYTE dist)\r
+{\r
+ int shift, i;\r
+ BYTE temp_pal[768];\r
+\r
+ shift = (dist * 3);\r
+ memcpy(temp_pal, Xpal + shift, 768 - shift);\r
+ memcpy(temp_pal + (768 - shift), Xpal, shift);\r
+\r
+ set_paletteX(temp_pal, 0);\r
+}\r
+\r
+\r
+BYTE\r
+find_RGB(BYTE r, BYTE g, BYTE b)\r
+{\r
+ long shortest_dist, temp_dist;\r
+ short int i, shortest_pal;\r
+\r
+ shortest_pal = 0;\r
+ shortest_dist = (r - Xpal[0]) * (r - Xpal[0]) +\r
+ (g - Xpal[1]) * (g - Xpal[1]) +\r
+ (b - Xpal[2]) * (b - Xpal[2]);\r
+\r
+ for (i=1; i < 256; i++) {\r
+ temp_dist = (r - Xpal[(i * 3) + 0]) * (r - Xpal[(i * 3) + 0]) +\r
+ (g - Xpal[(i * 3) + 1]) * (g - Xpal[(i * 3) + 1]) +\r
+ (b - Xpal[(i * 3) + 2]) * (b - Xpal[(i * 3) + 2]);\r
+\r
+ if (temp_dist < shortest_dist) {\r
+ shortest_dist = temp_dist;\r
+ shortest_pal = i;\r
+ }\r
+ }\r
+\r
+ return i;\r
+}\r
+\r
--- /dev/null
+#ifndef X_PALETTE_HPP\r
+ #define X_PALETTE_HPP\r
+\r
+#include "xtypes.hpp"\r
+\r
+// Palette setting/getting functions\r
+void set_paletteX(BYTE *pal, FLAG downgrade = 1);\r
+void get_paletteX(BYTE *pal, FLAG upgrade = 1);\r
+void get_BIOSpaletteX(BYTE *pal, FLAG upgrade = 1);\r
+\r
+// Palette adjusting functions\r
+void photo_negativeX(void);\r
+void grey_paletteX(void);\r
+void RGB_paletteX(void);\r
+void smooth64_paletteX(BYTE r, BYTE g, BYTE b);\r
+void brighten_paletteX(SBYTE r, SBYTE g, SBYTE b);\r
+void stretch_paletteX(BYTE r, BYTE g, BYTE b); // 1/16 units\r
+\r
+// Misc palette functions\r
+void rot_palette(BYTE distance);\r
+BYTE find_RGB(BYTE r, BYTE g, BYTE b);\r
+\r
+#endif\r
+\r
--- /dev/null
+#include <conio.h>\r
+#include <dos.h>\r
+#include <mem.h>\r
+#include <stdio.h>\r
+\r
+#include "modex.hpp"\r
+#include "xprim.hpp"\r
+\r
+#define SEQU_ADDR 0x3C4\r
+#define GRACON_ADDR 0x3CE\r
+#define CRTC_ADDR 0x3D4\r
+#define STATUS_ADDR 0x3DA\r
+\r
+BYTE Xfont[2048];\r
+\r
+\r
+void\r
+wait_for_retrace(void)\r
+{\r
+ while (!(inp(STATUS_ADDR) & 0x08));\r
+}\r
+\r
+\r
+void\r
+setDrawPage(unsigned int page)\r
+{\r
+ activeStart = page_offset[page];\r
+}\r
+\r
+\r
+void\r
+setVisiblePage(unsigned int page)\r
+{\r
+ // setVisibleStart() tells the VGA from which byte to fetch the first\r
+ // pixel when starting refresh at the top of the screen.\r
+ visibleStart = page_offset[page];\r
+\r
+ // set high byte\r
+ outpw(CRTC_ADDR, page_mask_high[page]);\r
+\r
+ // set low byte\r
+ outpw(CRTC_ADDR, page_mask_low[page]);\r
+}\r
+\r
+\r
+void\r
+clearX(BYTE color)\r
+{\r
+ outpw(SEQU_ADDR, 0x0F02);\r
+ memset((unsigned char *)(0xA000 << 4) + activeStart, color, 0x00010000);\r
+}\r
+\r
+\r
+void\r
+putpixelX(COORD x, COORD y, BYTE color)\r
+{\r
+ BYTE temp;\r
+\r
+ if (write_plane != (temp = (x & 3))) {\r
+ write_plane = temp;\r
+ outpw(SEQU_ADDR, plane_mask[temp]);\r
+ }\r
+\r
+ *(RowsX[y] + (x >> 2) + activeStart) = color;\r
+}\r
+\r
+\r
+BYTE\r
+getpixelX(COORD x, COORD y)\r
+{\r
+ BYTE temp;\r
+\r
+ if (read_plane != (temp = (x & 3))) {\r
+ read_plane = temp;\r
+ outpw(GRACON_ADDR, read_mask[temp]);\r
+ }\r
+\r
+ return (*(RowsX[y] + (x >> 2) + activeStart));\r
+}\r
+\r
+\r
+void\r
+internal_vert_lineX(COORD x, COORD top_y, int len, BYTE color)\r
+{\r
+ BYTE *ptr;\r
+ BYTE temp;\r
+\r
+ if (write_plane != (temp = (x & 3))) {\r
+ write_plane = temp;\r
+ outpw(SEQU_ADDR, plane_mask[temp]);\r
+ }\r
+\r
+ ptr = RowsX[top_y] + (x >> 2) + activeStart;\r
+\r
+ while (len--) {\r
+ *ptr = color;\r
+ ptr += widthBytes;\r
+ }\r
+}\r
+\r
+\r
+void\r
+internal_horiz_lineX(COORD left_x, COORD y, int len, BYTE color)\r
+{\r
+ BYTE *ptr;\r
+ BYTE temp;\r
+\r
+ ptr = RowsX[y] + (left_x >> 2) + activeStart;\r
+\r
+ // Set current plane to invalid value\r
+ write_plane = -1;\r
+\r
+ if (temp = (left_x & 3)) {\r
+ outp(SEQU_ADDR, 0x02);\r
+ outp(0x3C5, line_head[temp]);\r
+ *ptr++ = color;\r
+ len -= (4 - temp);\r
+ }\r
+\r
+ if (temp = (len >> 2)) {\r
+ outpw(SEQU_ADDR, 0x0F02);\r
+\r
+ len &= 3;\r
+\r
+ memset(ptr, color, temp);\r
+ ptr += temp;\r
+ }\r
+\r
+ if (len) {\r
+ outp(SEQU_ADDR, 0x02);\r
+ outp(0x3C5, line_tail[len]);\r
+ *ptr = color;\r
+ }\r
+}\r
+\r
+\r
+void\r
+boxX(COORD x1, COORD y1, COORD x2, COORD y2, BYTE color)\r
+{\r
+ int xsize, ysize;\r
+\r
+ xsize = (x2 - x1) + 1;\r
+ internal_horiz_lineX(x1, y1, xsize, color);\r
+ internal_horiz_lineX(x1, y2, xsize, color);\r
+\r
+ y1++;\r
+ ysize = (y2 - y1);\r
+\r
+ internal_vert_lineX(x1, y1, ysize, color);\r
+ internal_vert_lineX(x2, y1, ysize, color);\r
+}\r
+\r
+\r
+void\r
+filledboxX(COORD x1, COORD y1, COORD x2, COORD y2, BYTE color)\r
+{\r
+ BYTE *base_ptr;\r
+ BYTE *ptr;\r
+ BYTE temp;\r
+ short int i, xsize, ysize;\r
+\r
+ // Set current plane to invalid value\r
+ write_plane = -1;\r
+\r
+ xsize = (x2 - x1) + 1;\r
+ ysize = (y2 - y1) + 1;\r
+\r
+ if (ysize == 1) {\r
+ internal_horiz_lineX(x1, y1, xsize, color);\r
+ return;\r
+ }\r
+\r
+ base_ptr = RowsX[y1] + (x1 >> 2) + activeStart;\r
+\r
+ if (temp = (x1 & 3)) {\r
+ outp(SEQU_ADDR, 0x02);\r
+ outp(0x3C5, line_head[temp]);\r
+ ptr = base_ptr;\r
+ i=ysize;\r
+ while (i--) {\r
+ *ptr = color;\r
+ ptr += widthBytes;\r
+ }\r
+ xsize -= (4 - temp);\r
+ base_ptr++;\r
+ }\r
+\r
+ if (temp = (xsize >> 2)) {\r
+ outpw(SEQU_ADDR, 0x0F02);\r
+\r
+ xsize &= 3;\r
+ ptr = base_ptr;\r
+ i=ysize;\r
+ while (i--) {\r
+ memset(ptr, color, temp);\r
+ ptr += widthBytes;\r
+ }\r
+ base_ptr += temp;\r
+ }\r
+\r
+ if (xsize) {\r
+ outp(SEQU_ADDR, 0x02);\r
+ outp(0x3C5, line_tail[xsize]);\r
+ while (ysize--) {\r
+ *base_ptr = color;\r
+ base_ptr += widthBytes;\r
+ }\r
+ }\r
+}\r
+\r
+\r
+void\r
+circleX(COORD x, COORD y, DIST r, BYTE color)\r
+{\r
+ int ix, iy, d, deltaE, deltaSE;\r
+\r
+ ix = 0;\r
+ iy = r;\r
+ d = 1 - r;\r
+ deltaE = 3;\r
+ deltaSE = (-2 * r) + 5;\r
+\r
+ putpixelX(x + ix, y + iy, color);\r
+ putpixelX(x + ix, y - iy, color);\r
+ putpixelX(x + iy, y + ix, color);\r
+ putpixelX(x + iy, y - ix, color);\r
+ putpixelX(x - ix, y + iy, color);\r
+ putpixelX(x - ix, y - iy, color);\r
+ putpixelX(x - iy, y + ix, color);\r
+ putpixelX(x - iy, y - ix, color);\r
+\r
+ while (iy > ix++) {\r
+ if (d < 0) {\r
+ d += deltaE;\r
+ deltaE += 2;\r
+ deltaSE += 2;\r
+ } else {\r
+ d += deltaSE;\r
+ deltaE += 2;\r
+ deltaSE += 4;\r
+ iy--;\r
+ }\r
+\r
+ putpixelX(x + ix, y + iy, color);\r
+ putpixelX(x + ix, y - iy, color);\r
+ putpixelX(x + iy, y + ix, color);\r
+ putpixelX(x + iy, y - ix, color);\r
+ putpixelX(x - ix, y + iy, color);\r
+ putpixelX(x - ix, y - iy, color);\r
+ putpixelX(x - iy, y + ix, color);\r
+ putpixelX(x - iy, y - ix, color);\r
+ }\r
+}\r
+\r
+\r
+void\r
+filledcircleX(COORD x, COORD y, DIST r, BYTE color)\r
+{\r
+ int ix, iy, d, deltaE, deltaSE;\r
+\r
+ ix = 0;\r
+ iy = r;\r
+ d = 1 - r;\r
+ deltaE = 3;\r
+ deltaSE = (-2 * r) + 5;\r
+\r
+ internal_horiz_lineX(x - ix, y + iy, (ix << 1) + 1, color);\r
+ internal_horiz_lineX(x - ix, y - iy, (ix << 1) + 1, color);\r
+ internal_horiz_lineX(x - iy, y + ix, (iy << 1) + 1, color);\r
+ internal_horiz_lineX(x - iy, y - ix, (iy << 1) + 1, color);\r
+\r
+ while (iy > ix++) {\r
+ if (d < 0) {\r
+ d += deltaE;\r
+ deltaE += 2;\r
+ deltaSE += 2;\r
+ } else {\r
+ d += deltaSE;\r
+ deltaE += 2;\r
+ deltaSE += 4;\r
+ iy--;\r
+ }\r
+\r
+ internal_horiz_lineX(x - ix, y + iy, (ix << 1) + 1, color);\r
+ internal_horiz_lineX(x - ix, y - iy, (ix << 1) + 1, color);\r
+ internal_horiz_lineX(x - iy, y + ix, (iy << 1) + 1, color);\r
+ internal_horiz_lineX(x - iy, y - ix, (iy << 1) + 1, color);\r
+ }\r
+}\r
+\r
+\r
+void\r
+internal_xmajor(BYTE *vga_ptr, short int len, short int yskip,\r
+ unsigned long ErrorAcc, unsigned long ErrorAdj, BYTE color)\r
+{\r
+ if (len) {\r
+ len--;\r
+ while (len--) {\r
+ *vga_ptr++ = color;\r
+ ErrorAcc += ErrorAdj;\r
+\r
+ if (ErrorAcc & ~0xFFFFL) {\r
+ ErrorAcc &= 0xFFFFL;\r
+ vga_ptr += yskip;\r
+ }\r
+ }\r
+ *vga_ptr = color;\r
+ }\r
+}\r
+\r
+\r
+void\r
+internal_middle(BYTE *vga_ptr, short int len, short int yskip,\r
+ unsigned long ErrorAcc, unsigned long ErrorAdj, BYTE color)\r
+{\r
+ if (len) {\r
+ len--;\r
+ while (len--) {\r
+ *vga_ptr++ = color;\r
+ ErrorAcc += ErrorAdj;\r
+ vga_ptr += (yskip * (ErrorAcc >> 16));\r
+ ErrorAcc &= 0xFFFFL;\r
+ }\r
+ *vga_ptr = color;\r
+ }\r
+}\r
+\r
+\r
+void\r
+internal_ymajor(BYTE *vga_ptr, short int len, short int yskip,\r
+ unsigned long ErrorAcc, unsigned long ErrorAdj, BYTE color)\r
+{\r
+ unsigned long TinyAdj;\r
+ short int i;\r
+\r
+ if (len) {\r
+ TinyAdj = (ErrorAdj >> 2);\r
+ ErrorAdj -= TinyAdj;\r
+\r
+ len--;\r
+ while (len--) {\r
+ ErrorAcc += TinyAdj;\r
+ i = (ErrorAcc >> 16);\r
+ ErrorAcc &= 0xFFFFL;\r
+\r
+ while (i--) {\r
+ *vga_ptr = color;\r
+ vga_ptr += yskip;\r
+ }\r
+\r
+ ErrorAcc += ErrorAdj;\r
+ vga_ptr += (yskip * (ErrorAcc >> 16)) + 1;\r
+ ErrorAcc &= 0xFFFFL;\r
+ }\r
+ ErrorAcc += TinyAdj;\r
+ i = (ErrorAcc >> 16);\r
+ while (i--) {\r
+ *vga_ptr = color;\r
+ vga_ptr += yskip;\r
+ }\r
+ }\r
+}\r
+\r
+\r
+void\r
+lineX(COORD x1, COORD y1, COORD x2, COORD y2, BYTE color)\r
+{\r
+ unsigned long ErrorAcc, ErrorAdj, TinyAdj;\r
+ short int i, DeltaX, DeltaY, yskip;\r
+ short int len[4];\r
+ BYTE *vga_ptr;\r
+ COORD temp;\r
+\r
+ // Mode X 4-way folded Bresenham line function - by David Boeren\r
+\r
+ // Set invalid plane, because we're screwing with the plane mask\r
+ write_plane = -1;\r
+\r
+ // Make sure the line runs left to right\r
+ if (x1 > x2) {\r
+ temp = x1; x1 = x2; x2 = temp;\r
+ temp = y1; y1 = y2; y2 = temp;\r
+ }\r
+\r
+ DeltaX = (x2 - x1);\r
+ DeltaY = (y2 - y1);\r
+\r
+ if (DeltaY >= 0) {\r
+ yskip = widthBytes;\r
+ } else {\r
+ DeltaY = -DeltaY; // Make DeltaY positive\r
+ yskip = -widthBytes;\r
+ }\r
+\r
+ if (DeltaX == 0) {\r
+ // Vertical Line (and one pixel lines)\r
+ if (yskip > 0) {\r
+ internal_vert_lineX(x1, y1, (DeltaY + 1), color);\r
+ } else {\r
+ internal_vert_lineX(x1, y2, (DeltaY + 1), color);\r
+ }\r
+ return;\r
+ }\r
+\r
+ if (DeltaY == 0) {\r
+ // Horizontal Line\r
+ internal_horiz_lineX(x1, y1, (DeltaX + 1), color);\r
+ return;\r
+ }\r
+\r
+ vga_ptr = RowsX[y1] + (x1 >> 2) + activeStart;\r
+ ErrorAcc = 0x8000;\r
+\r
+ // Length of sub-line in each plane\r
+ temp = (x1 & 3);\r
+ i = DeltaX + temp;\r
+ len[0] = ((i--) >> 2);\r
+ len[1] = ((i--) >> 2);\r
+ len[2] = ((i--) >> 2);\r
+ len[3] = (i >> 2) + 1;\r
+\r
+ for (i=temp; i < 3; i++) {\r
+ len[i]++;\r
+ }\r
+\r
+ if ((DeltaX >> 2) >= DeltaY) {\r
+ // X-Major line (0.00 < slope <= 0.25)\r
+ ErrorAdj = ((((unsigned long)DeltaY << 18) / (unsigned long)DeltaX));\r
+ TinyAdj = (ErrorAdj >> 2);\r
+ while (i--) {\r
+ outpw(SEQU_ADDR, plane_mask[temp]);\r
+ internal_xmajor(vga_ptr, len[temp++], yskip, ErrorAcc, ErrorAdj, color);\r
+ if (temp == 4) {\r
+ temp = 0;\r
+ vga_ptr++;\r
+ }\r
+ ErrorAcc += TinyAdj;\r
+ if (ErrorAcc & ~0xFFFFL) {\r
+ ErrorAcc &= 0xFFFFL;\r
+ vga_ptr += yskip;\r
+ }\r
+ }\r
+ outpw(SEQU_ADDR, plane_mask[temp]);\r
+ internal_xmajor(vga_ptr, len[temp], yskip, ErrorAcc, ErrorAdj, color);\r
+ } else if (DeltaX >= DeltaY) {\r
+ // Middle line (0.25 < slope <= 1.00)\r
+ ErrorAdj = ((((unsigned long)DeltaY << 18) / (unsigned long)DeltaX));\r
+ TinyAdj = (ErrorAdj >> 2);\r
+ while (i--) {\r
+ outpw(SEQU_ADDR, plane_mask[temp]);\r
+ internal_middle(vga_ptr, len[temp++], yskip, ErrorAcc, ErrorAdj, color);\r
+ if (temp == 4) {\r
+ temp = 0;\r
+ vga_ptr++;\r
+ }\r
+ ErrorAcc += TinyAdj;\r
+ if (ErrorAcc & ~0xFFFFL) {\r
+ vga_ptr += yskip;\r
+ ErrorAcc &= 0xFFFFL;\r
+ }\r
+ }\r
+ outpw(SEQU_ADDR, plane_mask[temp]);\r
+ internal_middle(vga_ptr, len[temp], yskip, ErrorAcc, ErrorAdj, color);\r
+ } else {\r
+ // Y-Major line (slope > 1)\r
+ ErrorAdj = ((((unsigned long)(DeltaY+1) << 18) /\r
+ (unsigned long)(DeltaX+1)));\r
+ TinyAdj = (ErrorAdj >> 2);\r
+ while (i--) {\r
+ outpw(SEQU_ADDR, plane_mask[temp]);\r
+ internal_ymajor(vga_ptr, len[temp++], yskip, ErrorAcc, ErrorAdj, color);\r
+ if (temp == 4) {\r
+ temp = 0;\r
+ vga_ptr++;\r
+ }\r
+ ErrorAcc += TinyAdj;\r
+ vga_ptr += (yskip * (ErrorAcc >> 16));\r
+ ErrorAcc &= 0xFFFFL;\r
+ }\r
+ outpw(SEQU_ADDR, plane_mask[temp]);\r
+ internal_ymajor(vga_ptr, len[temp], yskip, ErrorAcc, ErrorAdj, color);\r
+ }\r
+}\r
+\r
+\r
+int\r
+loadfontX(char *fname)\r
+{\r
+ FILE *fp;\r
+\r
+ fp = fopen(fname, "rb");\r
+\r
+ if (fp == NULL) {\r
+ return 0;\r
+ } else {\r
+ fread(Xfont, 8, 256, fp);\r
+ fclose(fp);\r
+ return 1;\r
+ }\r
+}\r
+\r
+\r
+void\r
+putchX(COORD x, COORD y, char c, BYTE color)\r
+{\r
+ int i;\r
+ BYTE *vga_ptr;\r
+ BYTE *font_ptr;\r
+ BYTE temp;\r
+\r
+ // 8x8 font\r
+ vga_ptr = RowsX[y << 3] + (x << 1) + activeStart;\r
+ write_plane = -1;\r
+\r
+ font_ptr = Xfont + (c << 3);\r
+\r
+ i=8;\r
+ while (i--) {\r
+ temp = *font_ptr++;\r
+ outpw(SEQU_ADDR, text_mask[temp & 0x0F]);\r
+ *vga_ptr++ = color;\r
+\r
+ outpw(SEQU_ADDR, text_mask[temp >> 4]);\r
+ *vga_ptr-- = color;\r
+ vga_ptr += widthBytes;\r
+ }\r
+}\r
+\r
+\r
+void\r
+putstringX(COORD x, COORD y, char *str, BYTE color)\r
+{\r
+ int i, skip;\r
+ BYTE *vga_ptr;\r
+ BYTE *font_ptr;\r
+ BYTE c, temp;\r
+\r
+ // 8x8 font\r
+ vga_ptr = RowsX[y << 3] + (x << 1) + activeStart;\r
+ write_plane = -1;\r
+\r
+ skip = 2 - (widthBytes << 3);\r
+\r
+ while (c = *str++) {\r
+ font_ptr = Xfont + (c << 3);\r
+\r
+ i=8;\r
+ while (i--) {\r
+ temp = *font_ptr++;\r
+ outpw(SEQU_ADDR, text_mask[temp & 0x0F]);\r
+ *vga_ptr++ = color;\r
+\r
+ outpw(SEQU_ADDR, text_mask[temp >> 4]);\r
+ *vga_ptr-- = color;\r
+ vga_ptr += widthBytes;\r
+ }\r
+\r
+ vga_ptr += skip;\r
+ }\r
+}\r
+\r
--- /dev/null
+#ifndef X_PRIMITIVES_HPP\r
+ #define X_PRIMITIVES_HPP\r
+\r
+#include "xtypes.hpp"\r
+\r
+// Waits for vertical retrace\r
+void wait_for_retrace(void);\r
+\r
+// Page setting functions\r
+void setDrawPage(unsigned int page);\r
+void setVisiblePage(unsigned int page);\r
+\r
+// Screen clearing functions\r
+void clearX(BYTE color);\r
+\r
+// Drawing functions\r
+void putpixelX(COORD x, COORD y, BYTE color);\r
+BYTE getpixelX(COORD x, COORD y);\r
+void boxX(COORD x1, COORD y1, COORD x2, COORD y2, BYTE color);\r
+void filledboxX(COORD x1, COORD y1, COORD x2, COORD y2, BYTE color);\r
+void circleX(COORD x, COORD y, DIST r, BYTE color);\r
+void filledcircleX(COORD x, COORD y, DIST r, BYTE color);\r
+void lineX(COORD lx1, COORD ly1, COORD lx2, COORD ly2, BYTE color);\r
+\r
+// Text output functions\r
+int loadfontX(char *fname);\r
+void putchX(COORD x, COORD y, char c, BYTE color);\r
+void putstringX(COORD x, COORD y, char *str, BYTE color);\r
+\r
+#endif\r
+\r
--- /dev/null
+#ifndef XTYPES_HPP\r
+ #define XTYPES_HPP\r
+\r
+typedef unsigned char BYTE;\r
+typedef signed char SBYTE;\r
+typedef unsigned char FLAG;\r
+typedef unsigned short COORD;\r
+typedef unsigned short DIST;\r
+\r
+struct blitbuf {\r
+ DIST xsize;\r
+ DIST ysize;\r
+ BYTE *image;\r
+};\r
+\r
+#endif\r
+\r