--- /dev/null
+{
+ "configurations": [
+ {
+ "name": "Linux",
+ "includePath": [
+ "${workspaceFolder}/**"
+ ],
+ "defines": [],
+ "compilerPath": "/usr/bin/gcc",
+ "cStandard": "gnu17",
+ "cppStandard": "gnu++14",
+ "intelliSenseMode": "linux-gcc-x64"
+ },
+ {
+ "name": "open watcom 2.0",
+ "includePath": [
+ "${workspaceFolder}/**",
+ "/dos/fdos/watcom2/h/**"
+ ],
+ "defines": [],
+ "compilerPath": "/dos/fdos/watcom2/binl/wcl",
+ "cStandard": "c89",
+ "cppStandard": "c++98",
+ "intelliSenseMode": "${default}",
+ "compilerArgs": [
+ "-0"
+ ]
+ }
+ ],
+ "version": 4
+}
\ No newline at end of file
-all: test.exe\r
+all: test.exe fade.exe\r
\r
-test.exe: test.obj palette.obj\r
- wcl test.obj palette.obj\r
+fade.exe: fade.o palette.o\r
+ wcl -l=dos -0 fade.o palette.o\r
\r
-test.obj: test.c\r
- wcl -c test.c\r
+test.exe: test.o palette.o\r
+ wcl -l=dos -0 test.o palette.o\r
\r
-palette.obj: palette.h palette.c constant.h\r
- wcl -c palette.c\r
+test.o: test.c\r
+ wcl -0 -c test.c\r
+\r
+fade.o: fade.c\r
+ wcl -0 -c fade.c\r
+\r
+palette.o: palette.h palette.c constant.h\r
+ wcl -0 -c palette.c\r
#include <stdio.h>\r
#include "palette.h"\r
\r
+\r
+\r
void main() {\r
byte *palette;\r
int i;\r
--- /dev/null
+#define PEL_READ_REG 0x03C7 /* Color register, read address */\r
+#define PEL_WRITE_REG 0x03C8 /* Color register, write address */\r
+#define PEL_DATA_REG 0x03C9 /* Color register, data port */\r
+#define PAL_SIZE 768 /* Size of palette in bytes */\r
+#define SC_INDEX 0x03C4 /* Sequence Controller Index */\r
+#define CRTC_INDEX 0x03D4 /* CRT Controller Index */\r
+#define MISC_OUTPUT 0x03C2 /* Miscellaneous Output register */\r
+#define SCREEN_SEG 0x0a000 /* segment of display memory in mode X */\r
+#define INPUT_STATUS_1 0x03DA /* Input Status 1 register */\r
+#define ATC_INDEX 0x03C0 /* Attribute Controller */\r
+#define START_ADDRESS_HIGH 0x0C /* bitmap start address high byte */\r
+#define START_ADDRESS_LOW 0x0D /* bitmap start address low byte */\r
+#define GC_INDEX 0x03CE\r
+#define BIT_MASK 0x08\r
+#define MAP_MASK 0x02\r
+\r
+#define ALL_COPY_BITS 0x00000+BIT_MASK\r
+#define ALL_DRAW_BITS 0x0FF00+BIT_MASK\r
+\r
+#define SQUARE_WIDTH 16\r
+#define SQUARE_HEIGHT 16\r
+#define SCREEN_WIDTH 320\r
+#define SCREEN_HEIGHT 200\r
+#define VIRTUAL_WIDTH 352\r
+#define VIRTUAL_HEIGHT 240\r
+\r
+#define PAGE_0 0\r
+#define PAGE_1 0x05540 /* 05470h ;5540h */\r
+#define PAGE_2 0x0AA80 /* 0A8E0h ;AA80h */\r
+\r
+#define SCROLL_SPEED 1 /* Don't let it go above 8! */\r
+#define MAGIC_NUM 100\r
+\r
+#define CPU8086 0\r
+#define CPU80286 1\r
+#define CPU80386 2\r
+#define CPU80486 3\r
+\r
+/* ====================================================================== */\r
+/* Key Assignments */\r
+/* ====================================================================== */\r
+#define kESC 2\r
+#define kONE 4\r
+#define kTWO 6\r
+#define kTHREE 8\r
+#define kFOUR 10\r
+#define kFIVE 12\r
+#define kSIX 14\r
+#define kSEVEN 16\r
+#define kEIGHT 18\r
+#define kNINE 20\r
+#define kZERO 22\r
+#define kMINUS 24\r
+#define kEQUAL 26\r
+#define kBACKSPACE 28\r
+#define kTAB 30\r
+#define kQ 32\r
+#define kW 34\r
+#define kE 36\r
+#define kR 38\r
+#define kT 40\r
+#define kY 42\r
+#define kU 44\r
+#define kI 46\r
+#define kO 48\r
+#define kP 50\r
+#define kL_BRACE 52\r
+#define kR_BRACE 54\r
+#define kENTER 56\r
+#define kCTRL 58\r
+#define kA 60\r
+#define kS 62\r
+#define kD 64\r
+#define kF 66\r
+#define kG 68\r
+#define kH 70\r
+#define kJ 72\r
+#define kK 74\r
+#define kL 76\r
+#define kSEMICOLON 78\r
+#define kQUOTE 80\r
+#define kBACKQUOTE 82\r
+#define kL_SHIFT 84\r
+#define kBACKSLASH 86\r
+#define kZ 88\r
+#define kX 90\r
+#define kC 92\r
+#define kV 94\r
+#define kB 96\r
+#define kN 98\r
+#define kM 100\r
+#define kCOMMA 102\r
+#define kPERIOD 104\r
+#define kSLASH 106\r
+#define kR_SHIFT 108\r
+#define kGREY_STAR 110\r
+#define kALT 112\r
+#define kSPACE 114\r
+#define kCAPSLOCK 116\r
+#define kF1 118\r
+#define kF2 120\r
+#define kF3 122\r
+#define kF4 124\r
+#define kF5 126\r
+#define kF6 128\r
+#define kF7 130\r
+#define kF8 132\r
+#define kF9 134\r
+#define kF10 136\r
+#define kNUMLOCK 138\r
+#define kSCRLLOCK 140\r
+#define kHOME 142\r
+#define kUP 144\r
+#define kPAGE_UP 146\r
+#define kGREY_MINUS 148\r
+#define kLEFT 150\r
+#define kPAD_FIVE 152\r
+#define kRIGHT 154\r
+#define kGREY_PLUS 156\r
+#define kEND 158\r
+#define kDOWN 160\r
+#define kPAGE_DOWN 162\r
+#define kINSERT 164\r
+#define kDELETE 166\r
+\r
+#define kF11 174\r
+#define kF12 176\r
+\r
+\r
+/* handy types */\r
+typedef char byte;\r
+typedef short word;\r
--- /dev/null
+#include <stdio.h>\r
+#include <conio.h>\r
+#include <string.h>\r
+#include <stdlib.h>\r
+#include "palette.h"\r
+\r
+void main() {\r
+ byte *palette;\r
+ int i;\r
+\r
+ /* get our starting point */\r
+ palette = newPal();\r
+ palSave(palette);\r
+\r
+ /* fade to black and back */\r
+ while (1)\r
+ {\r
+ fadeOff(1, palette);\r
+ palBlack();\r
+ fadeOn(1, palette);\r
+ palUpdate(palette);\r
+\r
+ if (kbhit)\r
+ {\r
+ // Terminates the loop\r
+ // when escape is pressed\r
+ if (getch() == 27)\r
+ break;\r
+ }\r
+ }\r
+\r
+ free(palette);\r
+ return;\r
+}\r
--- /dev/null
+all: test.exe fade.exe\r
+\r
+fade.exe: fade.o palette.o\r
+ wcl -l=dos -0 fade.o palette.o\r
+\r
+test.exe: test.o palette.o\r
+ wcl -l=dos -0 test.o palette.o\r
+\r
+test.o: test.c\r
+ wcl -0 -c test.c\r
+\r
+fade.o: fade.c\r
+ wcl -0 -c fade.c\r
+\r
+palette.o: palette.h palette.c constant.h\r
+ wcl -0 -c palette.c\r
--- /dev/null
+/*\r
+ * File: PALETTE.C\r
+ * Purpose: This file contains routines for manipulating the VGA palette.\r
+ */\r
+#include <stdio.h>\r
+#include <stdlib.h>\r
+#include <conio.h>\r
+#include "palette.h"\r
+\r
+static void fadePalette(byte fade, byte start, word iter, byte *palette);\r
+static byte tmppal[PAL_SIZE];\r
+\r
+/* fade and flash */\r
+void\r
+fadeOn(word fade, byte *palette) {\r
+ fadePalette(-fade, 64, 64/fade+1, palette);\r
+}\r
+\r
+\r
+void\r
+fadeOff(word fade, byte *palette) {\r
+ fadePalette(fade, 0, 64/fade+1, palette);\r
+}\r
+\r
+\r
+void\r
+flashOn(word fade, byte *palette) {\r
+ fadePalette(fade, -64, 64/fade+1, palette);\r
+}\r
+\r
+\r
+void\r
+flashOff(word fade, byte *palette) {\r
+ fadePalette(-fade, 0, 64/fade+1, palette);\r
+}\r
+\r
+\r
+static void\r
+fadePalette(byte fade, byte start, word iter, byte *palette) {\r
+ word i;\r
+ byte dim = start;\r
+\r
+ /* handle the case where we just update */\r
+ if(iter == 0) {\r
+ palUpdate(palette);\r
+ return;\r
+ }\r
+\r
+ while(iter > 0) { /* FadeLoop */\r
+ for(i=0; i<PAL_SIZE; i++) { /* loadpal_loop */\r
+ tmppal[i] = palette[i] - dim;\r
+ if(tmppal[i] > 127) {\r
+ tmppal[i] = 0;\r
+ } else if(tmppal[i] > 63) {\r
+ tmppal[i] = 63;\r
+ }\r
+ }\r
+ palUpdate(tmppal);\r
+ iter--;\r
+ dim += fade;\r
+ }\r
+}\r
+\r
+\r
+/* save and load */\r
+void\r
+palSave(byte *palette) {\r
+ int i;\r
+\r
+ outp(PEL_READ_REG, 0); /* start at palette entry 0 */\r
+ for(i=0; i<PAL_SIZE; i++) {\r
+ palette[i] = inp(PEL_DATA_REG); /* read the palette data */\r
+ }\r
+}\r
+\r
+\r
+byte *\r
+newPal() {\r
+ byte *ptr;\r
+ ptr = malloc(PAL_SIZE);\r
+\r
+ /* handle errors */\r
+ if(!ptr) {\r
+ printf("Could not allocate palette.\n");\r
+ exit(-1);\r
+ }\r
+\r
+ return ptr;\r
+}\r
+\r
+\r
+void\r
+loadPaletteFile(byte *filename, byte **palette) {\r
+ FILE *file;\r
+ byte *ptr;\r
+\r
+ /* free the palette if it exists */\r
+ if(*palette) {\r
+ free(*palette);\r
+ }\r
+\r
+ /* allocate the new palette */\r
+ *palette = newPal();\r
+\r
+ /* open the file */\r
+ file = fopen(filename, "rb");\r
+ if(!file) {\r
+ printf("Could not open palette file: %s\n", filename);\r
+ exit(-2);\r
+ }\r
+\r
+ /* read the file */\r
+ ptr = *palette;\r
+ while(!feof(file)) {\r
+ *ptr++ = fgetc(file);\r
+ }\r
+\r
+ fclose(file);\r
+}\r
+\r
+\r
+/* blanking */\r
+void\r
+palBlack() {\r
+ fadePalette(-1, 64, 1, tmppal);\r
+}\r
+\r
+\r
+void\r
+palWhite() {\r
+ fadePalette(-1, -64, 1, tmppal);\r
+}\r
+\r
+\r
+/* utility */\r
+void\r
+palUpdate(byte *p) {\r
+ int i;\r
+ waitborder();\r
+ outp(PEL_WRITE_REG, 0); /* start at the beginning of palette */\r
+ for(i=0; i<PAL_SIZE/2; i++) {\r
+ outp(PEL_DATA_REG, p[i]);\r
+ }\r
+ waitborder(); /* waits one retrace -- less flicker */\r
+ for(i=PAL_SIZE/2; i<PAL_SIZE; i++) {\r
+ outp(PEL_DATA_REG, p[i]);\r
+ }\r
+}\r
+\r
+\r
+void\r
+waitborder() {\r
+ while(inp(INPUT_STATUS_1) & 8) {\r
+ /* spin */\r
+ }\r
+\r
+ while(!(inp(INPUT_STATUS_1) & 8)) {\r
+ /* spin */\r
+ }\r
+}\r
--- /dev/null
+/*\r
+ * Headers and definitions for the palette routines.\r
+ */\r
+#include "constant.h"\r
+\r
+/* fade and flash */\r
+void fadeOn(word fade, byte *palette);\r
+void fadeOff(word fade, byte *palette);\r
+void flashOn(word fade, byte *palette);\r
+void flashOff(word fade, byte *palette);\r
+\r
+/* save and load */\r
+void palSave(byte *palette);\r
+byte *newPal();\r
+void loadPaletteFile(char *filename, byte **palette);\r
+\r
+/* blanking */\r
+void palBlack();\r
+void palWhite();\r
+\r
+/* utility */\r
+void palUpdate();\r
+void waitborder();\r
+\r
--- /dev/null
+#include <stdio.h>\r
+#include "palette.h"\r
+\r
+\r
+\r
+void main() {\r
+ byte *palette;\r
+ int i;\r
+\r
+ /* get our starting point */\r
+ palette = newPal();\r
+ palSave(palette);\r
+\r
+ /* fade to black and back */\r
+ fadeOff(1, palette);\r
+ palBlack();\r
+ fadeOn(1, palette);\r
+ palUpdate(palette);\r
+\r
+ /* fade to white and back */\r
+ flashOff(1, palette);\r
+ palWhite();\r
+ flashOn(1, palette);\r
+ palUpdate(palette);\r
+\r
+ free(palette);\r
+ return;\r
+}\r
-Subproject commit b12b1cb71f93e2844d6272b9ad77d05edca0eede
+Subproject commit 88c15e215fc1df044ab9647baa65a5826a1ac063
-Subproject commit 1aa2e8f80849c983466b165d53542da9b1bd1b32
+Subproject commit 25647e692c7906b96ffd2b05ca54c097948e879c