#include <stdlib.h>\r
#include "src/lib/16_vl.h"\r
\r
+static word far* clockw= (word far*) 0x046C; /* 18.2hz clock */\r
+\r
+//===========================================================================\r
+\r
+//==============\r
+//\r
+// VL_SetScreen\r
+//\r
+//==============\r
+\r
+void VL_SetScreen (unsigned int crtc, int pelpan)\r
+{\r
+// PROC VL_SetScreen crtc:WORD, pel:WORD\r
+// PUBLIC VL_SetScreen\r
+ word TimeCount = *clockw;\r
+ __asm {\r
+ mov cx,[TimeCount] // if TimeCount goes up by two, the retrace\r
+ add cx,2 // period was missed (an interrupt covered it)\r
+\r
+ mov dx,STATUS_REGISTER_1\r
+\r
+ // wait for a display signal to make sure the raster isn't in the middle\r
+ // of a sync\r
+\r
+#ifdef __BORLANDC__\r
+ }\r
+#endif\r
+SetScreen_waitdisplay:\r
+#ifdef __BORLANDC__\r
+ __asm {\r
+#endif\r
+ in al,dx\r
+ test al,1 //1 = display is disabled (HBL / VBL)\r
+ jnz SetScreen_waitdisplay\r
+\r
+#ifdef __BORLANDC__\r
+ }\r
+#endif\r
+SetScreen_loop:\r
+#ifdef __BORLANDC__\r
+ __asm {\r
+#endif\r
+ sti\r
+ jmp SetScreen_skip1\r
+ cli\r
+#ifdef __BORLANDC__\r
+ }\r
+#endif\r
+SetScreen_skip1:\r
+#ifdef __BORLANDC__\r
+ __asm {\r
+#endif\r
+ cmp [TimeCount],cx // will only happen if an interrupt is\r
+ jae SetScreen_setcrtc // straddling the entire retrace period\r
+\r
+ // when several succesive display not enableds occur,\r
+ // the bottom of the screen has been hit\r
+\r
+ in al,dx\r
+ test al,8\r
+ jnz SetScreen_waitdisplay\r
+ test al,1\r
+ jz SetScreen_loop\r
+\r
+ in al,dx\r
+ test al,8\r
+ jnz SetScreen_waitdisplay\r
+ test al,1\r
+ jz SetScreen_loop\r
+\r
+ in al,dx\r
+ test al,8\r
+ jnz SetScreen_waitdisplay\r
+ test al,1\r
+ jz SetScreen_loop\r
+\r
+ in al,dx\r
+ test al,8\r
+ jnz SetScreen_waitdisplay\r
+ test al,1\r
+ jz SetScreen_loop\r
+\r
+ in al,dx\r
+ test al,8\r
+ jnz SetScreen_waitdisplay\r
+ test al,1\r
+ jz SetScreen_loop\r
+\r
+#ifdef __BORLANDC__\r
+ }\r
+#endif\r
+SetScreen_setcrtc:\r
+#ifdef __BORLANDC__\r
+ __asm {\r
+#endif\r
+ // set CRTC start\r
+ // for some reason, my XT's EGA card doesn't like word outs to the CRTC index...\r
+\r
+ mov cx,[crtc]\r
+ mov dx,CRTC_INDEX\r
+ mov al,0ch //start address high register\r
+ out dx,al\r
+ inc dx\r
+ mov al,ch\r
+ out dx,al\r
+ dec dx\r
+ mov al,0dh //start address low register\r
+ out dx,al\r
+ mov al,cl\r
+ inc dx\r
+ out dx,al\r
+\r
+\r
+ // set horizontal panning\r
+\r
+ mov dx,ATR_INDEX\r
+// mov al,ATR_PELPAN or 20h\r
+ out dx,al\r
+ jmp SetScreen_done\r
+ mov al,[BYTE PTR pelpan] //pel pan value\r
+ out dx,al\r
+#ifdef __BORLANDC__\r
+ }\r
+#endif\r
+SetScreen_done:\r
+#ifdef __BORLANDC__\r
+ __asm {\r
+#endif\r
+// sti\r
+\r
+// ret\r
+ }\r
+}\r
+\r
+/*\r
+====================\r
+=\r
+= VL_SetLineWidth\r
+=\r
+= Line witdh is in WORDS, 40 words is normal width for vgaplanegr\r
+=\r
+====================\r
+*/\r
+\r
+void VL_SetLineWidth (unsigned width, ofs_t *ofs)\r
+{\r
+ int i,offset;\r
+\r
+//\r
+// set wide virtual screen\r
+//\r
+ outport (CRTC_INDEX,CRTC_OFFSET+width*256);\r
+\r
+//\r
+// set up lookup tables\r
+//\r
+ ofs->linewidth = width*2;\r
+\r
+ offset = 0;\r
+\r
+ for (i=0;i<MAXSCANLINES;i++)\r
+ {\r
+ ofs->ylookup[i]=offset;\r
+ offset += ofs->linewidth;\r
+ }\r
+}\r
+\r
/*\r
=============================================================================\r
\r