Commit MetaInfo

Revision436d05c0510c7fe21d1f36b628e3648d25d15fce (tree)
Time2022-08-06 09:45:23
Authorsparky4 <sparky4@cock...>
Commitersparky4

Log Message

checking concistancy and fade.exe remade!

Change Summary

Incremental Difference

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