mirror of
https://github.com/dschmenk/PLASMA.git
synced 2025-08-07 18:25:03 +00:00
Compare commits
863 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
3bfdbd1910 | ||
|
f4c58afec2 | ||
|
21cdc64434 | ||
|
aeda1f8ce7 | ||
|
5b3417387a | ||
|
9baf4dc120 | ||
|
194aa4d7f2 | ||
|
2266407598 | ||
|
725646e68e | ||
|
890c43f8dc | ||
|
d1fabd4538 | ||
|
02345e68fe | ||
|
9a7fedabc2 | ||
|
5d9ff1c492 | ||
|
6f64bcecdf | ||
|
257f814cd3 | ||
|
7175f5f6e7 | ||
|
11d5b42cf3 | ||
|
cfced6a64a | ||
|
8c61098fdc | ||
|
4fcb9e2769 | ||
|
119bc00b49 | ||
|
be0e7a7427 | ||
|
1fb08214b8 | ||
|
e2ea8af616 | ||
|
22a411c098 | ||
|
a4f9d6455f | ||
|
af3fbd5edf | ||
|
4f2174c8f1 | ||
|
a1c1c6498f | ||
|
fda3ec6960 | ||
|
f4510b0d3f | ||
|
acd25e476f | ||
|
919058b039 | ||
|
f3c15e7d3d | ||
|
568a02df50 | ||
|
152e491506 | ||
|
acd5d01d7e | ||
|
4a371e1620 | ||
|
180db77474 | ||
|
ce0b5c1757 | ||
|
6524063c66 | ||
|
063ea4c888 | ||
|
4e27c38cca | ||
|
8ac82548f4 | ||
|
5a9e17c645 | ||
|
fa20432ef3 | ||
|
152249690d | ||
|
21008ec08d | ||
|
13c9779d0d | ||
|
b126e15272 | ||
|
72e72ebf0c | ||
|
e98ee57e6c | ||
|
1829b73b60 | ||
|
3fb399deeb | ||
|
8493c14ee6 | ||
|
ecb19d8580 | ||
|
5f4f6a32e2 | ||
|
0f484aff27 | ||
|
52c59eba07 | ||
|
56658cf49d | ||
|
c5f950ff24 | ||
|
1ea090b08e | ||
|
75eb25b67c | ||
|
87bdb7882e | ||
|
4df8bfc66d | ||
|
a5bdac2973 | ||
|
e1ac8f4da4 | ||
|
4157f0235e | ||
|
0fe84a9bdb | ||
|
257815f9fc | ||
|
da22dfd526 | ||
|
cbae6efa78 | ||
|
03e562bc88 | ||
|
0dae68e86d | ||
|
8491f221e5 | ||
|
2aadc82154 | ||
|
41180672a0 | ||
|
a080ff02b1 | ||
|
6cba91005c | ||
|
0f2c495425 | ||
|
e73c623a52 | ||
|
93debf7de0 | ||
|
751cb5acf7 | ||
|
5402b7c44c | ||
|
e2601361ef | ||
|
d8d8489fd6 | ||
|
8fe9e802cc | ||
|
12a3071652 | ||
|
ef37709a2d | ||
|
756ea5b4bc | ||
|
222457911c | ||
|
4742c2d490 | ||
|
204e2e57ba | ||
|
14ee367e56 | ||
|
4c4e9a4e4f | ||
|
7df77e19f1 | ||
|
ed5bdc314d | ||
|
1f62957e36 | ||
|
23f9fdaa46 | ||
|
ebaa7b25be | ||
|
4321eec00f | ||
|
10cd4969f4 | ||
|
16d848e784 | ||
|
559c44624d | ||
|
bc500851cd | ||
|
8909d0b933 | ||
|
c1bfeae763 | ||
|
ae762e6f0b | ||
|
dc28a5490b | ||
|
aa0db454e1 | ||
|
ac0c605325 | ||
|
3db001ee79 | ||
|
d1f7ed7e6f | ||
|
5707d5357e | ||
|
81e6092a30 | ||
|
3c9212de9b | ||
|
8bb1efcf95 | ||
|
bd5f97c91d | ||
|
b00e764971 | ||
|
b729ceabc7 | ||
|
9430f28df0 | ||
|
31c9fae21f | ||
|
7228eb8309 | ||
|
c19a40843d | ||
|
9c9d78bd60 | ||
|
75927fcf6b | ||
|
8e404df8d8 | ||
|
32b29f44a2 | ||
|
84cd9bf413 | ||
|
bde32b9c39 | ||
|
6b691dcdc5 | ||
|
e9a75048ef | ||
|
574c6e5964 | ||
|
74e669a23c | ||
|
121e415b4b | ||
|
67d5c2525f | ||
|
22f11a089c | ||
|
93af94055d | ||
|
f56784b275 | ||
|
348b45a7d8 | ||
|
e2334444f1 | ||
|
87ef9a9a2d | ||
|
27785e8513 | ||
|
9425c69b39 | ||
|
279123fd68 | ||
|
82d4633d28 | ||
|
83315b492d | ||
|
82411e5e49 | ||
|
cb2b28e3a5 | ||
|
2b79be476d | ||
|
b0846eac5f | ||
|
b135504044 | ||
|
024a1c01c6 | ||
|
bb3730f943 | ||
|
413284a09f | ||
|
318eb58a13 | ||
|
cae889cffd | ||
|
99dffac141 | ||
|
eb0ed22c2a | ||
|
95833a5d4a | ||
|
1436bbd2e8 | ||
|
c42797d544 | ||
|
a9f90b3db0 | ||
|
2940da149e | ||
|
c37ab7058a | ||
|
5efa958bc9 | ||
|
9117737e27 | ||
|
f74c11947e | ||
|
b85234b910 | ||
|
0f179defd3 | ||
|
9fc2f1769e | ||
|
98440eef79 | ||
|
fa0fe76533 | ||
|
db921c7545 | ||
|
bb4cb253fb | ||
|
8f706f387c | ||
|
f697f502cf | ||
|
6117c69d08 | ||
|
8d7d9ce6b4 | ||
|
b4d8f463a1 | ||
|
4c4924a34b | ||
|
18812f9b67 | ||
|
434871d0c2 | ||
|
dcf1d9cba5 | ||
|
2a01a25278 | ||
|
ef4efa5052 | ||
|
bde5af00b7 | ||
|
e3671ea831 | ||
|
794802c2b1 | ||
|
95a30fb13a | ||
|
218eb6fcb1 | ||
|
8d8f831e3d | ||
|
8bc6108313 | ||
|
53dd1ec6aa | ||
|
18cf6aea8b | ||
|
08db20753b | ||
|
ea39e71ed9 | ||
|
b7a7d60019 | ||
|
6b8d7fa38b | ||
|
affba20a20 | ||
|
5c68a9c6ea | ||
|
abbb32de5c | ||
|
a32b82dcd7 | ||
|
9477cd1413 | ||
|
1527273bcc | ||
|
e21a8fff60 | ||
|
1b19b48de9 | ||
|
7dfafd2d93 | ||
|
4bb8d7b1cc | ||
|
bfa2a58993 | ||
|
1667161d1c | ||
|
4769f3fb82 | ||
|
b30d61f834 | ||
|
6a4362c970 | ||
|
dc7a32077b | ||
|
d47956443c | ||
|
c3e24be56c | ||
|
de57f5e19b | ||
|
5883fc8fae | ||
|
e1f0cf9164 | ||
|
ca0250f500 | ||
|
20eaf2a74a | ||
|
d188d75a19 | ||
|
516752c285 | ||
|
08fcd3a986 | ||
|
9e7f26407c | ||
|
2c1a243311 | ||
|
15ba3b9553 | ||
|
fe783e5038 | ||
|
a7328da9b3 | ||
|
692cf84712 | ||
|
ad03eff0eb | ||
|
b776452157 | ||
|
f6a1dcf256 | ||
|
75353621c1 | ||
|
af23f7cf71 | ||
|
550931305b | ||
|
2da1388a5e | ||
|
6678772a06 | ||
|
8673659267 | ||
|
d7df8f04c6 | ||
|
71e04a3cdc | ||
|
44e4e835e5 | ||
|
2310fba421 | ||
|
4232ef839a | ||
|
376feacbf5 | ||
|
512c307531 | ||
|
f3089caba6 | ||
|
331c5c2dea | ||
|
480b98e817 | ||
|
e51753e512 | ||
|
af7988a71b | ||
|
bbe09b035d | ||
|
d90e3c797e | ||
|
8f4b05ef31 | ||
|
318c893b32 | ||
|
ce34adc3e9 | ||
|
616096fb53 | ||
|
6f6c41943a | ||
|
efa87a5473 | ||
|
60baf4ce5f | ||
|
4a40412236 | ||
|
d73a2a9007 | ||
|
99bbca0264 | ||
|
2a9e506fa2 | ||
|
010b57e99c | ||
|
c3243f491e | ||
|
70fd56a93c | ||
|
0b31397eb6 | ||
|
e6c1aa35bf | ||
|
742c8b9d77 | ||
|
e87ae469bb | ||
|
8ded05fcfb | ||
|
6ae6a343b2 | ||
|
0df3fe544c | ||
|
fbafc4abd9 | ||
|
480ea58026 | ||
|
d9466112a8 | ||
|
8d289856fd | ||
|
3c38943141 | ||
|
ccf8893367 | ||
|
b7d8baa9de | ||
|
c5914ab2b2 | ||
|
a26e856057 | ||
|
54c14a6112 | ||
|
2c884102bb | ||
|
f9dd7b5417 | ||
|
f592edeb8a | ||
|
1211991144 | ||
|
8ddc1ef8aa | ||
|
0a1e2363ab | ||
|
e731908136 | ||
|
3033b4b125 | ||
|
6279a82064 | ||
|
325e74c4ba | ||
|
e1425ac97a | ||
|
f5107dc6e5 | ||
|
9d5c45f3c5 | ||
|
2ac3304a68 | ||
|
d3a418a09f | ||
|
593585d2ed | ||
|
66c57287d6 | ||
|
dd8e38a692 | ||
|
995ea5f1cf | ||
|
5d90bd94b2 | ||
|
4fb7fe3e40 | ||
|
47b8e18cf7 | ||
|
3e2bdd4803 | ||
|
7f3b1823dd | ||
|
8ac23f05dd | ||
|
ee397da178 | ||
|
32dc3095aa | ||
|
514da5b967 | ||
|
3dd43e7992 | ||
|
c2c0b0633e | ||
|
9b26f74771 | ||
|
730360b786 | ||
|
50a4fbc230 | ||
|
27da5dca92 | ||
|
6593a32253 | ||
|
94d47f031a | ||
|
75b1441574 | ||
|
6d7465377e | ||
|
d91816019e | ||
|
7675708a27 | ||
|
71011e644f | ||
|
6931813a50 | ||
|
b32be1d955 | ||
|
e23419e0c0 | ||
|
96a7553ee3 | ||
|
224592679a | ||
|
eb43eb4e14 | ||
|
8fc9175555 | ||
|
91d889bbb8 | ||
|
297c0ab493 | ||
|
bab302ebc1 | ||
|
ff14bbb35c | ||
|
f63456d941 | ||
|
12c9e07826 | ||
|
a2d8d22c3d | ||
|
57f6e85d3c | ||
|
2fa5207496 | ||
|
75fad76b85 | ||
|
48da6f197a | ||
|
ba0f11e3a5 | ||
|
b671d73a22 | ||
|
1ae700960b | ||
|
13a5c0bdc3 | ||
|
5464f1a52c | ||
|
5ceb7bd6b9 | ||
|
39a5d98f93 | ||
|
aa03e5bdab | ||
|
bec33a2e88 | ||
|
7da4ff8713 | ||
|
00d0956a19 | ||
|
fee8eabd36 | ||
|
ff89556104 | ||
|
70a067d134 | ||
|
5b792798ac | ||
|
f9cd6cac29 | ||
|
2a9eb9c55d | ||
|
0b531e7f3e | ||
|
d70ae2ec1e | ||
|
b19f7d6d60 | ||
|
c8e3173348 | ||
|
d79695270e | ||
|
ecab8dac1b | ||
|
fef7d5ce90 | ||
|
246af31891 | ||
|
90e4f21dc0 | ||
|
5abdeef09a | ||
|
5242148ef6 | ||
|
83c70b14b6 | ||
|
1c39679540 | ||
|
fdcf4fc557 | ||
|
9f578db33f | ||
|
8f6211c087 | ||
|
6b3b9cf10f | ||
|
748eaa342d | ||
|
d979f0ffed | ||
|
22f17edcce | ||
|
493715fe1d | ||
|
fab8d498a0 | ||
|
22b65573a3 | ||
|
a061833ef8 | ||
|
0cdcb66888 | ||
|
2cb60895b8 | ||
|
d767418eff | ||
|
4ee3a2140b | ||
|
88981cfd4f | ||
|
93fc68b736 | ||
|
5aabb8b13e | ||
|
b9e9fa2397 | ||
|
2315282ec9 | ||
|
f46a65eb28 | ||
|
1e1bbcd857 | ||
|
c6353355c4 | ||
|
dfb6afc5f0 | ||
|
bde74778b0 | ||
|
3783e20220 | ||
|
867e282a36 | ||
|
c5824ed632 | ||
|
3e258bf622 | ||
|
31a716062e | ||
|
7fc9c946ce | ||
|
d13269fc52 | ||
|
3d149b668c | ||
|
f77c0e9a9e | ||
|
44aab3e3ba | ||
|
3b323c76ee | ||
|
4a7a1a69bb | ||
|
ea1af9f40b | ||
|
7936b189e1 | ||
|
2c814d8829 | ||
|
9f0289b5d6 | ||
|
340b5b4b04 | ||
|
3c8bf7b1e5 | ||
|
bfffd6e567 | ||
|
082f1061d0 | ||
|
7a1dc790f2 | ||
|
e818da7339 | ||
|
ccc13a0a6f | ||
|
2f9bd7d26c | ||
|
485aba5542 | ||
|
320bfbef81 | ||
|
b834f4dc05 | ||
|
7dd569b809 | ||
|
5207c0ba05 | ||
|
551a50ece9 | ||
|
c1326814ea | ||
|
c3ea787808 | ||
|
478ddfcfcb | ||
|
54b36f9ef7 | ||
|
1e43899f97 | ||
|
6ef1e26249 | ||
|
f404affcd0 | ||
|
12cab55271 | ||
|
60b526bcb0 | ||
|
e77ff928ca | ||
|
bbfa59ccc7 | ||
|
daed69e113 | ||
|
ef3b3eb1b1 | ||
|
0fd3afdd7a | ||
|
ec3b9de737 | ||
|
9592ac3f2c | ||
|
e9bde21346 | ||
|
a5d2fdc17b | ||
|
23aae45787 | ||
|
64de8140d3 | ||
|
d8f21f1f65 | ||
|
9df7eeb28e | ||
|
d9bc53d5d0 | ||
|
843d0a85e7 | ||
|
604497c8b8 | ||
|
d019030e78 | ||
|
27b11725d0 | ||
|
85295c5515 | ||
|
4c4ec7c985 | ||
|
f9b7c51b3d | ||
|
b243bf9c51 | ||
|
afc7da3746 | ||
|
3dd9bd8d0f | ||
|
bbfb61f736 | ||
|
22046c55ae | ||
|
7ee1c2f524 | ||
|
01a5f0d75b | ||
|
58fc3a3025 | ||
|
68e2cec638 | ||
|
5b4050d1d2 | ||
|
cae5cd110e | ||
|
86669849d9 | ||
|
82130cb2e8 | ||
|
713b6ea7fa | ||
|
d8ec9f9709 | ||
|
f0678795de | ||
|
77dd8d0d0b | ||
|
5e7dc428e5 | ||
|
45a7a44b69 | ||
|
b0c5f1c2e9 | ||
|
2814843331 | ||
|
257b31aa56 | ||
|
439216d437 | ||
|
0ddec876ac | ||
|
b4536f98ba | ||
|
c29ab9bd82 | ||
|
de72884699 | ||
|
c2cac963b6 | ||
|
52d4c08f36 | ||
|
2a21428a54 | ||
|
7f9a47e77e | ||
|
4e1c6a5963 | ||
|
52b47c571e | ||
|
c76124c4cb | ||
|
9b576d75c8 | ||
|
254928624f | ||
|
e48ce3d2dd | ||
|
abb1738c06 | ||
|
43bdb61043 | ||
|
d920a14c8f | ||
|
e4a5b1a5a5 | ||
|
6a67577a9b | ||
|
ab2239753c | ||
|
6f58db9b92 | ||
|
5e00ed6a4d | ||
|
0004ec0cd0 | ||
|
06a3bd55e1 | ||
|
50d72dd386 | ||
|
c5e56c7d63 | ||
|
5e3baa70fb | ||
|
5ad6b0733c | ||
|
4b4b7e0683 | ||
|
66c2104b76 | ||
|
3a488a5854 | ||
|
a63fed59c9 | ||
|
2fecde9a7a | ||
|
4e876b7a64 | ||
|
d481bfaad1 | ||
|
45cf817bd1 | ||
|
d60c6a46ae | ||
|
04146f954a | ||
|
cf8d13f067 | ||
|
86f2140b80 | ||
|
5396298b50 | ||
|
e5f1790da6 | ||
|
7e53d66c64 | ||
|
fe27016df0 | ||
|
7cf622999d | ||
|
e439ca5ba7 | ||
|
0baad05c04 | ||
|
b8d300f9f9 | ||
|
3ceba530a5 | ||
|
ec14660f87 | ||
|
3fd11ca0d4 | ||
|
31d5b8a5ec | ||
|
82a1632bfd | ||
|
db424e9fc7 | ||
|
8344f18612 | ||
|
2b9eb6a5fc | ||
|
c23cb6d239 | ||
|
1d099df299 | ||
|
7aeda2d98b | ||
|
d90b7ba69d | ||
|
2eea9e585c | ||
|
0ab16d4877 | ||
|
7d669e97b8 | ||
|
a1c49d2705 | ||
|
578d002b8c | ||
|
7527a5a7d3 | ||
|
b3d1dfed7d | ||
|
0190c2c3cd | ||
|
6f61b4ae8a | ||
|
e02c068706 | ||
|
e7ce06fe62 | ||
|
90cfcd2840 | ||
|
1e368ced63 | ||
|
6e45185cfd | ||
|
db2f9eecc3 | ||
|
5eefe74c6b | ||
|
15b14899f4 | ||
|
d5803ceba9 | ||
|
34624f3162 | ||
|
b1d463f4e4 | ||
|
d3b9fe14a0 | ||
|
6efc2b1a98 | ||
|
a89b1b9b40 | ||
|
9038c7e649 | ||
|
f5c562eafb | ||
|
2f7c1b3e59 | ||
|
631034034c | ||
|
c64843b1e1 | ||
|
88960e6745 | ||
|
b4ab21f80c | ||
|
9e0f0ecd0f | ||
|
a8584753e0 | ||
|
3e91616666 | ||
|
ca95dd356d | ||
|
6211cb31a3 | ||
|
260ea6fe6b | ||
|
a6c94440a2 | ||
|
c6220f389d | ||
|
0743eba40c | ||
|
2e4364f9c6 | ||
|
ab57909099 | ||
|
b4c9c93c2e | ||
|
dbd1f336f4 | ||
|
51daf7e8ff | ||
|
2476b85fa8 | ||
|
974a7d63f6 | ||
|
fbcfae86e0 | ||
|
a818dec4aa | ||
|
29498dc6e7 | ||
|
a587aa477f | ||
|
5d5f60c2d5 | ||
|
1fb7960a1b | ||
|
a08bc126a2 | ||
|
ab3b91ad78 | ||
|
a9b4492504 | ||
|
66d674d494 | ||
|
8c2e3eaa5c | ||
|
e2f29ffb2a | ||
|
a717f15e02 | ||
|
42be6c6f80 | ||
|
7c9e24d332 | ||
|
80c8cd4e6a | ||
|
9b749d6f99 | ||
|
87c261bf3d | ||
|
67960518b0 | ||
|
211ce933b2 | ||
|
13f88a8ad3 | ||
|
f25f4c6dc7 | ||
|
969277f8ae | ||
|
a840f2b2ac | ||
|
cdfb59846f | ||
|
ee5c66e710 | ||
|
c9f081e1b3 | ||
|
b3b92b39c6 | ||
|
734d9a50c6 | ||
|
1a7f7bec62 | ||
|
7cb4534efb | ||
|
30437ce21a | ||
|
016b31a01c | ||
|
350ab5b783 | ||
|
96bac30316 | ||
|
1a3e8eb3da | ||
|
23a5e7840a | ||
|
81fa548f52 | ||
|
153e6f6f8b | ||
|
3dd07beaf8 | ||
|
ed295b0599 | ||
|
ff7c35deb9 | ||
|
b93b4d7c75 | ||
|
c2773d208c | ||
|
a9cadd9fda | ||
|
8d92e854ae | ||
|
f3ac3035ba | ||
|
bfb3eb4672 | ||
|
2434d262c5 | ||
|
547bdcc2ad | ||
|
6c6d6e664d | ||
|
76c85e350c | ||
|
e2163c856e | ||
|
96d4e3eb02 | ||
|
12de12b0b4 | ||
|
d0fc4120c9 | ||
|
3fcbf48665 | ||
|
92be9cd631 | ||
|
2a475a01e2 | ||
|
2578b1a3fb | ||
|
4364319176 | ||
|
da404a8dfa | ||
|
68e31ccc30 | ||
|
da0bf22b2e | ||
|
e14eda8617 | ||
|
3166341e96 | ||
|
c61a787271 | ||
|
637b1d8248 | ||
|
9ff1695012 | ||
|
86ef49cc5e | ||
|
8f3780617b | ||
|
912a865a25 | ||
|
12216fcab5 | ||
|
1d88369ae0 | ||
|
f2846bdaf3 | ||
|
3b3fc24246 | ||
|
232ced8fe3 | ||
|
c3cc7cb139 | ||
|
0515117d52 | ||
|
751799352c | ||
|
1be159e3ed | ||
|
7fe51aaf56 | ||
|
eaa0e3c7d4 | ||
|
9f45afe3d0 | ||
|
85710bbfdf | ||
|
ef9fc81ece | ||
|
2eacd75b69 | ||
|
d5c22b1ff0 | ||
|
dff6c2bd9b | ||
|
cefb8128c6 | ||
|
6e03017d25 | ||
|
8985011207 | ||
|
1548a63a9f | ||
|
1f1376c467 | ||
|
5832883da9 | ||
|
ea114c4350 | ||
|
2770a6f774 | ||
|
a755df496c | ||
|
de4d6fb104 | ||
|
3f9f56be74 | ||
|
fa94f4c8d8 | ||
|
b3f6c7970a | ||
|
bc1cf8368d | ||
|
7aed4d4d4a | ||
|
d9d57f383d | ||
|
3424b085cf | ||
|
eefd9ba2dd | ||
|
9587423c46 | ||
|
d4dee597dc | ||
|
919339041a | ||
|
d1f99e1142 | ||
|
5114ab48dd | ||
|
7bd13f1bcb | ||
|
8999c3286f | ||
|
bb4e0ee773 | ||
|
38832640e7 | ||
|
ca4cebf394 | ||
|
93c72c98ed | ||
|
82bc7ebb1f | ||
|
2e36d0f52f | ||
|
64ef4cca70 | ||
|
b54ba1fdaf | ||
|
41d56cdefa | ||
|
b481804a4d | ||
|
9e42e3d640 | ||
|
a067c3e804 | ||
|
1c3505a196 | ||
|
0d552c5e51 | ||
|
41ad4e9778 | ||
|
a3dc055897 | ||
|
420af77a96 | ||
|
1db7cd16ee | ||
|
2d4417c698 | ||
|
68cc31993f | ||
|
54a256cd60 | ||
|
1bf6c41be5 | ||
|
75ef74b3ba | ||
|
9aba6b71f1 | ||
|
8dd03a3413 | ||
|
3b8bad0abd | ||
|
b466a48a16 | ||
|
1dd792e87c | ||
|
6bb7a9dca9 | ||
|
a15658a714 | ||
|
b2ddb0434d | ||
|
965ccecf2a | ||
|
3455286a48 | ||
|
7ce2ab726c | ||
|
64b516f810 | ||
|
f7c37de60a | ||
|
3cb1d97a6c | ||
|
5d6b9b1f7e | ||
|
9aa0ab68ee | ||
|
677869ed4c | ||
|
a7c7cf9e19 | ||
|
99d584f45f | ||
|
7a73d2b621 | ||
|
e22e8f472f | ||
|
1ab3657f36 | ||
|
5dabd1dbb7 | ||
|
645278604f | ||
|
e953458e76 | ||
|
07e0397ba4 | ||
|
64b0e0ca80 | ||
|
4876ddea60 | ||
|
2fba961f14 | ||
|
4d2ab77740 | ||
|
8d0dad15b3 | ||
|
4e77f83bed | ||
|
59dbef75f1 | ||
|
5de565ebb1 | ||
|
bf13409d16 | ||
|
c874426091 | ||
|
ec9718de53 | ||
|
ec16b9cc78 | ||
|
27fc9a0fea | ||
|
3ddb448775 | ||
|
097bde5257 | ||
|
92078abec1 | ||
|
312bd349fc | ||
|
2242a02075 | ||
|
eab0727c71 | ||
|
9337e5f20f | ||
|
35b2aa3080 | ||
|
9a7593fafe | ||
|
929678269f | ||
|
21ac8cc402 | ||
|
7433b52e28 | ||
|
2e19e9f6b1 | ||
|
dad996203d | ||
|
4f9f58ba29 | ||
|
4cfadf3ec8 | ||
|
e47ca69101 | ||
|
37f906d5a6 | ||
|
550fde7f1e | ||
|
1fcc4c3735 | ||
|
2c11ce4e96 | ||
|
4854baec5a | ||
|
82a4a252a3 | ||
|
0e0ba23d7a | ||
|
b865004d7b | ||
|
9932639b1b | ||
|
655e410a1d | ||
|
ee14a3bdf4 | ||
|
60c1b4f6e9 | ||
|
094ddd31e8 | ||
|
6fc53c4c21 | ||
|
0d585d7110 | ||
|
bc68776f93 | ||
|
9e7a774972 | ||
|
17d1e1eb89 | ||
|
976581b1c1 | ||
|
3d1c3e9407 | ||
|
4ca1ba9c04 | ||
|
af57dfdeeb | ||
|
267fdebdef | ||
|
66c51a2ab5 | ||
|
64a722f1e2 | ||
|
75c2847cf1 | ||
|
f5efc5641e | ||
|
c39fd20746 | ||
|
79287f2c51 | ||
|
cd0126477b | ||
|
1c35a7ae0a | ||
|
ffce999045 | ||
|
9e62379b46 | ||
|
9125b7bfd4 | ||
|
cdb734d1ba | ||
|
f78f2827dc | ||
|
ef268697b5 | ||
|
6665199e55 | ||
|
f4ce23a3cf | ||
|
177c621364 | ||
|
54fba4e12f | ||
|
0d41deb7ec | ||
|
7a3debfd0c | ||
|
1713c71505 | ||
|
abd9d35cae | ||
|
1d3de982d6 | ||
|
9cb7d29bfa | ||
|
374d2465b6 | ||
|
156bca2413 | ||
|
f5b2db78a3 | ||
|
ca5f81530c | ||
|
76b3905a60 | ||
|
4613584099 | ||
|
0d76b322f1 | ||
|
f0d89f6b5c | ||
|
f8a6589f34 | ||
|
ec629745f9 | ||
|
a0cc6662d5 | ||
|
bba4570a93 | ||
|
fe86c7e3f1 | ||
|
602fd75509 | ||
|
62c55eb4ea | ||
|
970d692592 | ||
|
c4551c2c59 | ||
|
bb41023498 | ||
|
c3111a63be | ||
|
726609a573 | ||
|
d48ccdf979 | ||
|
a64afe5486 | ||
|
691c3851f0 | ||
|
28f06edf9c | ||
|
6b20c4da10 | ||
|
2ff4c9d842 | ||
|
c7234e2d04 | ||
|
bf9c61892c | ||
|
7d66c27ecf | ||
|
0fdc319481 | ||
|
fbb50a9127 | ||
|
f0b18db6c2 | ||
|
c05c0789da | ||
|
112d5f4639 |
170
LICENSE.md
170
LICENSE.md
@@ -1,157 +1,21 @@
|
||||
### GNU LESSER GENERAL PUBLIC LICENSE
|
||||
MIT License
|
||||
|
||||
Version 3, 29 June 2007
|
||||
Copyright (c) 2010-2022 David Schmenk
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc.
|
||||
<https://fsf.org/>
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
Everyone is permitted to copy and distribute verbatim copies of this
|
||||
license document, but changing it is not allowed.
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
This version of the GNU Lesser General Public License incorporates the
|
||||
terms and conditions of version 3 of the GNU General Public License,
|
||||
supplemented by the additional permissions listed below.
|
||||
|
||||
#### 0. Additional Definitions.
|
||||
|
||||
As used herein, "this License" refers to version 3 of the GNU Lesser
|
||||
General Public License, and the "GNU GPL" refers to version 3 of the
|
||||
GNU General Public License.
|
||||
|
||||
"The Library" refers to a covered work governed by this License, other
|
||||
than an Application or a Combined Work as defined below.
|
||||
|
||||
An "Application" is any work that makes use of an interface provided
|
||||
by the Library, but which is not otherwise based on the Library.
|
||||
Defining a subclass of a class defined by the Library is deemed a mode
|
||||
of using an interface provided by the Library.
|
||||
|
||||
A "Combined Work" is a work produced by combining or linking an
|
||||
Application with the Library. The particular version of the Library
|
||||
with which the Combined Work was made is also called the "Linked
|
||||
Version".
|
||||
|
||||
The "Minimal Corresponding Source" for a Combined Work means the
|
||||
Corresponding Source for the Combined Work, excluding any source code
|
||||
for portions of the Combined Work that, considered in isolation, are
|
||||
based on the Application, and not on the Linked Version.
|
||||
|
||||
The "Corresponding Application Code" for a Combined Work means the
|
||||
object code and/or source code for the Application, including any data
|
||||
and utility programs needed for reproducing the Combined Work from the
|
||||
Application, but excluding the System Libraries of the Combined Work.
|
||||
|
||||
#### 1. Exception to Section 3 of the GNU GPL.
|
||||
|
||||
You may convey a covered work under sections 3 and 4 of this License
|
||||
without being bound by section 3 of the GNU GPL.
|
||||
|
||||
#### 2. Conveying Modified Versions.
|
||||
|
||||
If you modify a copy of the Library, and, in your modifications, a
|
||||
facility refers to a function or data to be supplied by an Application
|
||||
that uses the facility (other than as an argument passed when the
|
||||
facility is invoked), then you may convey a copy of the modified
|
||||
version:
|
||||
|
||||
- a) under this License, provided that you make a good faith effort
|
||||
to ensure that, in the event an Application does not supply the
|
||||
function or data, the facility still operates, and performs
|
||||
whatever part of its purpose remains meaningful, or
|
||||
- b) under the GNU GPL, with none of the additional permissions of
|
||||
this License applicable to that copy.
|
||||
|
||||
#### 3. Object Code Incorporating Material from Library Header Files.
|
||||
|
||||
The object code form of an Application may incorporate material from a
|
||||
header file that is part of the Library. You may convey such object
|
||||
code under terms of your choice, provided that, if the incorporated
|
||||
material is not limited to numerical parameters, data structure
|
||||
layouts and accessors, or small macros, inline functions and templates
|
||||
(ten or fewer lines in length), you do both of the following:
|
||||
|
||||
- a) Give prominent notice with each copy of the object code that
|
||||
the Library is used in it and that the Library and its use are
|
||||
covered by this License.
|
||||
- b) Accompany the object code with a copy of the GNU GPL and this
|
||||
license document.
|
||||
|
||||
#### 4. Combined Works.
|
||||
|
||||
You may convey a Combined Work under terms of your choice that, taken
|
||||
together, effectively do not restrict modification of the portions of
|
||||
the Library contained in the Combined Work and reverse engineering for
|
||||
debugging such modifications, if you also do each of the following:
|
||||
|
||||
- a) Give prominent notice with each copy of the Combined Work that
|
||||
the Library is used in it and that the Library and its use are
|
||||
covered by this License.
|
||||
- b) Accompany the Combined Work with a copy of the GNU GPL and this
|
||||
license document.
|
||||
- c) For a Combined Work that displays copyright notices during
|
||||
execution, include the copyright notice for the Library among
|
||||
these notices, as well as a reference directing the user to the
|
||||
copies of the GNU GPL and this license document.
|
||||
- d) Do one of the following:
|
||||
- 0) Convey the Minimal Corresponding Source under the terms of
|
||||
this License, and the Corresponding Application Code in a form
|
||||
suitable for, and under terms that permit, the user to
|
||||
recombine or relink the Application with a modified version of
|
||||
the Linked Version to produce a modified Combined Work, in the
|
||||
manner specified by section 6 of the GNU GPL for conveying
|
||||
Corresponding Source.
|
||||
- 1) Use a suitable shared library mechanism for linking with
|
||||
the Library. A suitable mechanism is one that (a) uses at run
|
||||
time a copy of the Library already present on the user's
|
||||
computer system, and (b) will operate properly with a modified
|
||||
version of the Library that is interface-compatible with the
|
||||
Linked Version.
|
||||
- e) Provide Installation Information, but only if you would
|
||||
otherwise be required to provide such information under section 6
|
||||
of the GNU GPL, and only to the extent that such information is
|
||||
necessary to install and execute a modified version of the
|
||||
Combined Work produced by recombining or relinking the Application
|
||||
with a modified version of the Linked Version. (If you use option
|
||||
4d0, the Installation Information must accompany the Minimal
|
||||
Corresponding Source and Corresponding Application Code. If you
|
||||
use option 4d1, you must provide the Installation Information in
|
||||
the manner specified by section 6 of the GNU GPL for conveying
|
||||
Corresponding Source.)
|
||||
|
||||
#### 5. Combined Libraries.
|
||||
|
||||
You may place library facilities that are a work based on the Library
|
||||
side by side in a single library together with other library
|
||||
facilities that are not Applications and are not covered by this
|
||||
License, and convey such a combined library under terms of your
|
||||
choice, if you do both of the following:
|
||||
|
||||
- a) Accompany the combined library with a copy of the same work
|
||||
based on the Library, uncombined with any other library
|
||||
facilities, conveyed under the terms of this License.
|
||||
- b) Give prominent notice with the combined library that part of it
|
||||
is a work based on the Library, and explaining where to find the
|
||||
accompanying uncombined form of the same work.
|
||||
|
||||
#### 6. Revised Versions of the GNU Lesser General Public License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions
|
||||
of the GNU Lesser General Public License from time to time. Such new
|
||||
versions will be similar in spirit to the present version, but may
|
||||
differ in detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Library
|
||||
as you received it specifies that a certain numbered version of the
|
||||
GNU Lesser General Public License "or any later version" applies to
|
||||
it, you have the option of following the terms and conditions either
|
||||
of that published version or of any later version published by the
|
||||
Free Software Foundation. If the Library as you received it does not
|
||||
specify a version number of the GNU Lesser General Public License, you
|
||||
may choose any version of the GNU Lesser General Public License ever
|
||||
published by the Free Software Foundation.
|
||||
|
||||
If the Library as you received it specifies that a proxy can decide
|
||||
whether future versions of the GNU Lesser General Public License shall
|
||||
apply, that proxy's public statement of acceptance of any version is
|
||||
permanent authorization for you to choose that version for the
|
||||
Library.
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
222
doc/DRAWL.md
Normal file
222
doc/DRAWL.md
Normal file
@@ -0,0 +1,222 @@
|
||||
# LISP 1.5 implemented in PLASMA
|
||||
|
||||
LISP interpreted on a bytecode VM running on a 1 MHz 6502 is going to be sssllllooooowwwww. So I called this implementation DRAWL in keeping with the speech theme. DRAWL represents an exploration REPL language for the PLASMA environment. It isn't meant to be a full-blown programming language, more of an interactive sandbox for playing with S-expressions.
|
||||
|
||||
## Missing features of LISP 1.5 in DRAWL
|
||||
|
||||
- Minimal I/O facilities
|
||||
- Property lists. Only DEFINE() and CSETQ()/CSET() property functions supported
|
||||
- General recursion. The 6502 architecture limits recursion (but see tail recursion below), so don't expect too much here
|
||||
- Many of the built-in functions from the LISP 1.5 manual. Most can be coded in LISP and loaded at startup
|
||||
|
||||
However, the code is partitioned to allow for easy extension so some of these missing features could be implemented.
|
||||
|
||||
## Features of DRAWL
|
||||
|
||||
- 32 bit integers and 80 bit floating point with transcendental math operators by way of the SANE library
|
||||
- Tail recursion handles deep recursion. Check out [loop.lisp](https://github.com/dschmenk/PLASMA/blob/master/src/lisp/loop.lisp)
|
||||
- Fully garbage collected behind the scenes
|
||||
- Optionally read LISP source file at startup
|
||||
- Arrays of up to four dimensions
|
||||
- Bit-wise logic operations on 32 bit integers
|
||||
- FUNCTION operation with bound variables
|
||||
- The PROG Alogol-like programming construct
|
||||
- Additional testing/looping constructs: IF and FOR
|
||||
- Hexadecimal input/output
|
||||
- LoRes Apple II graphics
|
||||
- Ctrl-C break into running program
|
||||
- MACROs for meta-programming. See [defun.lisp](https://github.com/dschmenk/PLASMA/blob/master/src/lisp/defun.lisp)
|
||||
- End-of-line comment using ';'
|
||||
- String handling functions
|
||||
|
||||
The DRAWL implementation comes with the following built-in functions:
|
||||
|
||||
### Constants
|
||||
|
||||
- T = True
|
||||
- F = False
|
||||
- NIL = NULL
|
||||
- CSET() = Set constant value
|
||||
- CSETQ() = Set constant value
|
||||
- :=() = Alias got CSETQ()
|
||||
- DEFINE() = Define function
|
||||
|
||||
### Function types
|
||||
|
||||
- LAMBDA(...)
|
||||
- FUNARG() = List constructed by FUNCTION()
|
||||
- FUNCTION()
|
||||
- MACRO(...) = Operate on non-evaluated argument list
|
||||
|
||||
### Predicates
|
||||
|
||||
- ATOM()
|
||||
- EQ()
|
||||
- NOT()
|
||||
- AND(...)
|
||||
- OR(...)
|
||||
- NULL()
|
||||
- NUMBER?()
|
||||
- STRING?()
|
||||
|
||||
### Misc
|
||||
|
||||
- SET = Used in array access to set element value
|
||||
- QUOTE()
|
||||
- ARRAY() = Arrays up to four dimensions
|
||||
- EVAL() = Evaluate S-expression
|
||||
- TRACE() = Turn tracing on/off
|
||||
- GC() = Run garbage collector and return free memory amount
|
||||
- QUIT() = Exit REPL
|
||||
|
||||
### List manipulation
|
||||
|
||||
- CAR()
|
||||
- CDR()
|
||||
- CONS()
|
||||
- LIST(...)
|
||||
|
||||
### Conditionals
|
||||
|
||||
- COND(...)
|
||||
- IF() = IF THEN w/ optional ELSE
|
||||
|
||||
### Output
|
||||
|
||||
- PRHEX() = Turn hexadecimal output on/off
|
||||
- PRI(...) = Print without newline
|
||||
- PRINT(...) = Print with newline
|
||||
- FMTFPI() = Floating point format integer digits
|
||||
- FMTFPF() = Floating point format fractional digits
|
||||
- PRINTER() = Turn printer echo on/off on slot#
|
||||
|
||||
### Looping
|
||||
|
||||
- FOR(...)
|
||||
|
||||
### Associations
|
||||
|
||||
- LABEL()
|
||||
- SET()
|
||||
- SETQ()
|
||||
- =() = Alias got SETQ()
|
||||
|
||||
### Program feature
|
||||
|
||||
- PROG(...) = Algol like programming in LISP
|
||||
- SET() = Update variable value
|
||||
- SETQ() = Update variable value
|
||||
- = = Alias for SETQ
|
||||
- COND(...) = Fall-through COND()
|
||||
- IF() = Fall-through IF THEN w/ optional ELSE
|
||||
- GO() = Goto label inside PROG
|
||||
- RETURN() = Return from PROG with value
|
||||
|
||||
### Numbers
|
||||
|
||||
- +(...)
|
||||
- -()
|
||||
- \*(...)
|
||||
- /()
|
||||
- REM()
|
||||
- NEG()
|
||||
- ABS()
|
||||
- \>()
|
||||
- <()
|
||||
- MIN(...)
|
||||
- MAX(...)
|
||||
- NUMBER?()
|
||||
|
||||
### Integers
|
||||
|
||||
- BITNOT() = Bit-wise NOT
|
||||
- ~() = Alias for BITNOT()
|
||||
- BITAND() = Bit-wise AND
|
||||
- &() = Alias for BITAND()
|
||||
- BITOR() = Bit-wise OR
|
||||
- |() = Alias for BITOR()
|
||||
- BITXOR = Bit-wise XOR
|
||||
- ^() = Alias for BITXOR()
|
||||
- ARITHSHIFT() = Bit-wise arithmetic SHIFT (positive = left, negative = right)
|
||||
- <<-() = Alias for ARITHSHIFT()
|
||||
- LOGICSHIFT() = Bit-wise logicalal SHIFT (positive = left, negative = right)
|
||||
- <<() = Alias for LOGICSHIFT()
|
||||
- ROTATE() = Bit-wise ROTATE (positive = left, negative = right)
|
||||
- <<<() = Alias for ROTATE()
|
||||
|
||||
### Floating Point (from the SANE library)
|
||||
|
||||
- *PI* = Constant value of pi
|
||||
- *E* = Constant value of e
|
||||
- NUMBER() = Convert atom to number (symbol and array return NIL)
|
||||
- INTEGER() = Convert number to integer
|
||||
- LOGB()
|
||||
- SCALEB()
|
||||
- TRUNCATE()
|
||||
- ROUND()
|
||||
- SQRT()
|
||||
- COS()
|
||||
- SIN()
|
||||
- TAN()
|
||||
- ATAN()
|
||||
- LOG2()
|
||||
- LOG2_1()
|
||||
- LN()
|
||||
- LN_1()
|
||||
- POW2()
|
||||
- POW2_1()
|
||||
- POWE()
|
||||
- POWE_1()
|
||||
- POW_I()
|
||||
- POW()
|
||||
- COMP()
|
||||
- ANNUITY()
|
||||
|
||||
### Strings
|
||||
|
||||
- STRING() = Convert atom to string
|
||||
- SUBS() = SUB String offset length
|
||||
- CATS(...) = conCATenate Strings
|
||||
- LENS() = LENgth String
|
||||
- CHARS(...) = CHARacter String from integer values
|
||||
- ASCII() = ASCII value of first character in string
|
||||
|
||||
### I/O functions
|
||||
|
||||
- HOME()
|
||||
- GOTOXY()
|
||||
- KEYPRESSED?()
|
||||
- READKEY()
|
||||
- READ()
|
||||
- READFILE()
|
||||
- READSTRING()
|
||||
|
||||
### Lo-Res Graphics
|
||||
|
||||
- GR() = Turn lo-res graphics mode on/off
|
||||
- COLOR() = Set plotting color
|
||||
- PLOT() = Plot pixel at X,Y coordinate
|
||||
|
||||
LISP is one of the earliest computer languages. As such, it holds a special place in the anals of computer science. I've always wanted to learn why LISP is held in such high regard by so many, so I went about learning LISP by actually implementing a LISP interpreter in PLASMA. PLASMA is well suited to implement other languages due to its rich syntax, performance and libraries.
|
||||
|
||||
## Links
|
||||
|
||||
Here are some links to get you started.
|
||||
|
||||
LISP 1.5 Manual: https://archive.org/details/bitsavers_mitrlelisprammersManual2ed1985_9279667
|
||||
|
||||
LISP 1.5 Primer: https://www.softwarepreservation.org/projects/LISP/book/Weismann_LISP1.5_Primer_1967.pdf
|
||||
|
||||
Personal LISP on Apple II Manual (PDF): https://archive.org/details/gLISP/gnosisLISPManual
|
||||
|
||||
Personal LISP on Apple II Manual (web archive): https://web.archive.org/web/20190603120105/http://jeffshrager.org/llisp/
|
||||
|
||||
Apple Numerics Manual (SANE): https://vintageapple.org/inside_o/pdf/Apple_Numerics_Manual_Second_Edition_1988.pdf
|
||||
|
||||
Part 1 of DRAWL in action (S-expressions): https://youtu.be/wBMivg6xfSg
|
||||
|
||||
Part 2 of DRAWL in action (The rest of LISP 1.5): https://youtu.be/MdKZIrfPN7s
|
||||
|
||||
Preconfigured PLASMA ProDOS boot floppy for DRAWL: https://github.com/dschmenk/PLASMA/blob/master/images/apple/DRAWL.po
|
||||
|
||||
My blog post about LISP 1.5 and DRAWL: http://schmenk.is-a-geek.com/wordpress/?p=365
|
@@ -1,9 +1,10 @@
|
||||
WELCOME TO THE PLASMA EDITOR!
|
||||
=============================
|
||||
WELCOME TO THE PLEIADES EDITOR!
|
||||
===============================
|
||||
|
||||
FIRST THINGS FIRST:
|
||||
TO NAVIGATE, USE THE ARROW KEYS. ON
|
||||
THE APPLE ][:
|
||||
TO NAVIGATE, USE THE ARROW KEYS.
|
||||
|
||||
ON THE APPLE ][:
|
||||
|
||||
CTRL-K = UP
|
||||
CTRL-J = DOWN.
|
||||
@@ -24,17 +25,13 @@ EXIT BY ENTERING 'Q' AND 'RETURN'.
|
||||
YOU CAN ALSO RETURN TO THE EDITOR BY
|
||||
JUST PRESSING 'RETURN'.
|
||||
|
||||
-------
|
||||
-------------------------------------------------------------------------
|
||||
|
||||
THE PLASMA EDITOR IS A SIMPLE TEXT
|
||||
EDITOR FOR ENTERING AND MANIPULATING
|
||||
TEXT AND SOURCE CODE FILES. THE
|
||||
EDITOR ONLY SUPPORTS 40 COLUMN TEXT
|
||||
ALTHOUGH LINES CAN BE UP TO 79
|
||||
CHARACTERS LONG. THE SCREEN WILL
|
||||
SCROLL HORIZONTALLY AS THE CURSOR
|
||||
MOVES. THERE IS 16K OF MEMORY FOR
|
||||
THE TEXT BUFFER.
|
||||
THE PLEIADES EDITOR IS A SIMPLE TEXT EDITOR FOR ENTERING AND MANIPULATING
|
||||
TEXT AND SOURCE CODE FILES. THE EDITOR SUPPORTS FROM 40 TO 128 COLUMN MODE
|
||||
WITH LINES THAT CAN BE UP TO 127 CHARACTERS LONG. THE SCREEN WILL SCROLL
|
||||
HORIZONTALLY AS THE CURSOR MOVES, IF NEDED. THERE IS ABOUT 16K TO 30K OF
|
||||
MEMORY FOR THE TEXT BUFFER, DEPENDING ON YOUR CONFIGURATION.
|
||||
|
||||
IT HAS TWO MODES, COMMAND AND EDIT.
|
||||
|
||||
@@ -59,8 +56,8 @@ EDIT COMMANDS:
|
||||
CTRL-V = PASTE CLIPBOARD
|
||||
CTRL-O = OPEN NEW LINE
|
||||
CTRL-F = OPEN A FOLLOWING NEW LINE
|
||||
CTRL-T = JOIN LINES
|
||||
CTRL-Y = TOGGLE INSERT/OVERWRITE
|
||||
CTRL-Y = JOIN LINES
|
||||
CTRL-T = TOGGLE INSERT/OVERWRITE
|
||||
TAB/CTRL-I = INSERT SPACES TO NEXT TAB
|
||||
= INDENT SELECTION IF INSERT MODE
|
||||
= UNDENT SELECTION IF OVERWITE MODE
|
||||
@@ -79,24 +76,19 @@ EDIT COMMANDS:
|
||||
CTRL-L = SHIFT LOCK
|
||||
SHIFT-LEFT ARROW = DELETE (SHIFT-MOD)
|
||||
|
||||
WITH THE SHIFT-KEY MOD ON AN
|
||||
APPLE ][, UPPER AND LOWER CASE
|
||||
ENTRY WORKS AS EXPECTED.
|
||||
WITH THE SHIFT-KEY MOD ON AN APPLE ][, UPPER AND LOWER CASE ENTRY WORKS
|
||||
AS EXPECTED.
|
||||
|
||||
ESC T C = FORCE LOWER-CASE CHARS
|
||||
|
||||
If you have a lower-case character
|
||||
generator installed, you can force
|
||||
lower-case display. Otherwise,
|
||||
upper case will be displayed normally
|
||||
but lower-case will be displayed in
|
||||
inverse. This is the default.
|
||||
If you have a lower-case character generator installed, you can force
|
||||
lower-case display. Otherwise, upper case will be displayed normally
|
||||
but lower-case will be displayed in inverse. This is the default.
|
||||
|
||||
Apple //e AND //c FEATURES:
|
||||
---------------------------
|
||||
|
||||
The 'SOLID-APPLE' key will modify
|
||||
theese keys:
|
||||
The 'SOLID-APPLE' key will modify these keys:
|
||||
|
||||
SA-RETURN = OPEN FOLLOWING LINE
|
||||
SA-LEFT ARROW = JUMP LEFT
|
||||
@@ -108,8 +100,7 @@ EDIT COMMANDS:
|
||||
Apple /// FEATURES:
|
||||
-------------------
|
||||
|
||||
The 'OPEN-APPLE' key will modify
|
||||
these keys:
|
||||
The 'OPEN-APPLE' key will modify these keys:
|
||||
|
||||
OA-\ = DELETE CHAR LEFT
|
||||
OA-RETURN = OPEN FOLLOWING LINE
|
||||
@@ -119,8 +110,12 @@ EDIT COMMANDS:
|
||||
OA-DOWN ARROW = JUMP DOWN
|
||||
OA-TAB = DETAB
|
||||
|
||||
On the keypad, 'OPEN-APPLE' allows
|
||||
the keys for navigation and misc:
|
||||
Apple //e Platinum IIGS & /// FEATURES:
|
||||
---------------------------------------
|
||||
|
||||
On the keypad, 'OPTION' on //e Platinum & IIGS
|
||||
or 'OPEN-APPLE' on the /// allows the keys for
|
||||
navigation and misc operations:
|
||||
|
||||
OA-4 = MOVE CHAR LEFT
|
||||
OA-6 = MOVE CHAR RIGHT
|
||||
@@ -130,11 +125,15 @@ EDIT COMMANDS:
|
||||
OA-3 = JUMP DOWN
|
||||
OA-7 = JUMP BEGIN
|
||||
OA-1 = JUMP END
|
||||
OA-5 = DELETE CHAR
|
||||
OA-- = CUT SELECTION INTO CLIPBOARD
|
||||
OA-0 = PASTE CLIPBOARD
|
||||
OA-ENTER = OPEN FOLLOWING LINE
|
||||
OA-. = TOGGLE INSERT/OVERWRITE
|
||||
OA-5 = SELECT/DESELECT
|
||||
OA-- = CUT SELECTION INTO CLIPBOARD
|
||||
OA-+ = COPY SELECTION INTO CLIPBOARD
|
||||
OA-0 = DELETE CHARACTER
|
||||
OA-/ = INSERT/OVERWRITE
|
||||
OA-* = OPEN CURRENT LINE
|
||||
OA-ENTER = OPEN NEXT LINE
|
||||
OA-. = PASTE CLIPBOARD
|
||||
OA-= = NUMLOCK (NUMBER KEYS ACT LIKE OA/OPTION PRESSED)
|
||||
|
||||
COMMAND MODE:
|
||||
|
||||
@@ -151,7 +150,8 @@ COMMAND MODE:
|
||||
N = CLEAR TEXT IN MEMORY
|
||||
T G = TOGGLE GUTTER VIEW
|
||||
T C = TOGGLE LOWER-CASE SUPPORT (APPLE ][)
|
||||
G <LINE> = GO TO LINE #
|
||||
F [STRING] = FIND STRING
|
||||
E = EDIT MODE
|
||||
'RETURN' = EDIT MODE
|
||||
1..999 = GO TO LINE #
|
||||
|
1330
doc/PLASMA.md
Executable file
1330
doc/PLASMA.md
Executable file
File diff suppressed because it is too large
Load Diff
158
doc/PLFORTH.md
Normal file
158
doc/PLFORTH.md
Normal file
@@ -0,0 +1,158 @@
|
||||
# FORTH PLASMA + PLFORTH !
|
||||
|
||||
PLFORTH represents a REPL and scripting language for the PLASMA environment. Or, what I did over the Holiday break.
|
||||
|
||||
The goals of PLFORTH are pretty straight forward:
|
||||
**Interactivity** and **debugging**.
|
||||
|
||||
PLFORTH is a PLASMA module written in PLASMA itself. As a first class citizen of the PLASMA environment, it has instant access to all the PLASMA modules, from floating point to high-res graphics libraries and everything in between.
|
||||
|
||||
## Missing words in PLFORTH
|
||||
|
||||
There are quite a few missing word that a standard FORTH would have. Mostly due to deliberately keeping PLFORTH as minimal as possible to reduce the memory footpring and load time. Most of the missing words can be synthesized using existing PLASMA modules and some glue words. The double word have mostly been made avialable through PLASMA's 32 bit integer module, `INT32` by way of the `int32.4th` script. You can always petition to get your favorite FORTH word included in the default vocabulary. Speaking of `VOCABULARY`, PLFORTH only has one.
|
||||
|
||||
## PLFORTH built-in words
|
||||
|
||||
Compile only: LITERAL ; EXIT POSTPONE
|
||||
COMPILE, [ DOES> REPEAT WHILE UNTIL
|
||||
AGAIN BEGIN J I +LOOP LOOP UNLOOP LEAVE
|
||||
DO ENDCASE ENDOF OF CASE THEN ELSE IF
|
||||
RECURSE
|
||||
|
||||
Interpret only: PBC ITC BRKOFF BRKON
|
||||
SEE CONT ] IS DEFER :NONAME : FORGET
|
||||
CONSTANT VARIABLE PLASMA
|
||||
|
||||
Both: WORDS BRK STEPOFF STEPON TROFF
|
||||
TRON .RS .S BYE ( COLD ?ABORT"
|
||||
(?ABORT") ?ABORT QUIT ENDSRC ?ENDSRC
|
||||
SRC" SRC .( ." (.") " CHAR BL TYPE
|
||||
SPACES SPACE CR EMIT C%. %. C$. $. . ?
|
||||
COMPARE -TRAILING NUM? WORD ACCEPT KEY
|
||||
KEY? ' FIND COUNT IMMEDIATE INTERPONLY
|
||||
COMPONLY STATE C, , CREATE ALLOT PAD
|
||||
HERE LATEST FILL CMOVE LOOKUP R@ R> >R
|
||||
EXECUTE @ C@ +! ! C! MAX MIN ABS 0<> 0=
|
||||
0> 0< U< U> < > <> = RSHIFT LSHIFT NOT
|
||||
COMPLEMENT XOR OR AND NEGATE MOD /MOD /
|
||||
* - 2- 1- 2+ 1+ + ROT OVER ?DUP DUP2
|
||||
DUP SWAP DROP2 DROP
|
||||
|
||||
## PLFORTH specific words
|
||||
|
||||
### Words for looking at internal structures:
|
||||
|
||||
`.RS`: Displays the return stack. Note: PLFORTH uses a software defined return stack, this is not the hardware stack
|
||||
|
||||
### Words for tracing and single stepping execution:
|
||||
|
||||
`TRON`: Turn tracing on
|
||||
|
||||
`TROFF`: Turn tracing off (will also turn off single stepping if enabled)
|
||||
|
||||
`STEPON`: Turn single stepping on
|
||||
|
||||
`STEPOFF`: Turn single stepping off
|
||||
|
||||
While running code, `<CTRL-T>` will toggle tracing on and off as well
|
||||
|
||||
### Words for breakpoints:
|
||||
|
||||
`BRK`: Used inside compiled word to effect a runtime break
|
||||
|
||||
`BRKON xxxx`: Enable breakpoint whenever word `xxxx` is executed
|
||||
|
||||
`BRKOFF`: Disable the breakpoint. Note: only one breakpoint is currently supported
|
||||
|
||||
While running code, `<CTRL-C>` will break out and return to the interpreter.
|
||||
|
||||
`CONT`: Continue running from the last break point
|
||||
|
||||
### Words for PLASMA linkage:
|
||||
|
||||
`LOOKUP yyyy`: Lookup symbol `yyyy` in PLASMA symbol table and return its address
|
||||
|
||||
`PLASMA zzzz`: Create word `zzzz` with code address from `LOOKUP`
|
||||
|
||||
### Words to run a script:
|
||||
|
||||
`SRC`: Source filename on stack as input. Can be nested
|
||||
|
||||
`SRC" ssss"`: Source file `ssss` as input. Can be nested
|
||||
|
||||
`?ENDSRC`: End sourcing file as input if stack flag non-zero
|
||||
|
||||
`ENDSRC`: End sourcing file as input
|
||||
|
||||
### Words for compiler modes:
|
||||
|
||||
`PBC`: Compile into PLASMA Byte Code
|
||||
|
||||
`ITC`: Compile into Indirect Threaded Code
|
||||
|
||||
### Word for converting string to number:
|
||||
|
||||
`NUM?`: Convert string and length to number, returning number and valid flag
|
||||
|
||||
Numbers entered with a preceeding `$` will be interpreted as hex values
|
||||
|
||||
Numbers entered with a preceeding `%` will be interpreted as binary values
|
||||
|
||||
### Words for displaying hex numbers
|
||||
|
||||
`$.`: Display TOS word in hex with leading `$`
|
||||
|
||||
`C$.`: Display TOS byte in hex with leading `$`
|
||||
|
||||
Hex numbers can be entered when preceded by `$`
|
||||
|
||||
### Words for displaying binary numbers
|
||||
|
||||
`%.`: Display TOS word in binary with leading `%`
|
||||
|
||||
`C%.`: Display TOS byte in binary with leading `%`
|
||||
|
||||
Binary numbers can be entered when preceded by `%`
|
||||
|
||||
## Debugging vs Performance
|
||||
|
||||
PLFORTH defaults to compiling using ITC (Indirect Threaded Code). This supports a list of inspection and debugging features while developing programs and scripts. However, the compiler can easily switch to PBC (PLASMA Byte Code) to greatly improve performance, but most of the debugging tools are lost. ITC compiled words and PBC compiled words can be intermingled and call each other seemlessly. PLASMA Byte Code is a direct match to many low-level FORTH constructs.
|
||||
|
||||
## Graphics
|
||||
Due to the way the Apple II implements Hi-Res, Lo-Res and Double Lo-Res graphics, a stub loader is required to reserve the pages used.
|
||||
|
||||
`HRFORTH`: Reserve HGR page 1 before launching PLFORTH
|
||||
|
||||
`HR2FORTH`: Reserve HGR pages 1 and 2 before launching PLFORTH
|
||||
|
||||
`TX2FORTH`: Reserve GR and DGR pages 1 and 2 before launching PLFORTH
|
||||
|
||||
## Scripts
|
||||
|
||||
There are a few useful scripts located in the `scripts` directory. By far the most useful is `plasma.4th`
|
||||
|
||||
### plasma.4th useful words
|
||||
|
||||
`CAT`: Display files in current ProDOS directory
|
||||
|
||||
`CAT" pppp"`: Display files in `pppp` ProDOS directory
|
||||
|
||||
`PFX" pppp"`: Set current ProDOS prefix to `pppp`
|
||||
|
||||
`PFX.`: Display current ProDOS prefix
|
||||
|
||||
`EDIT" ssss"`: Edit file `ssss`
|
||||
|
||||
## Command line options
|
||||
|
||||
`-F`: Fast flag (like `PCB` as first command)
|
||||
|
||||
`-T`: Trace flag (like `TRON` as first command)
|
||||
|
||||
`SCRIPT NAME`: Soure filename to execute
|
||||
|
||||
## Links
|
||||
|
||||
Here is a (worse than usual) video running through some examples. This was a preliminary release so the final is a bit different: https://youtu.be/picPyXAk77I?si=Td2En5Z3oxVTzh0z
|
||||
|
||||
A pre-configured ProDOS floppy image able to run and a few utilities is available here: https://github.com/dschmenk/PLASMA/blob/master/images/apple/PLFORTH.po
|
BIN
doc/ROGUE.LZ4.BIN
Normal file
BIN
doc/ROGUE.LZ4.BIN
Normal file
Binary file not shown.
94
doc/ROGUE.TXT
Normal file
94
doc/ROGUE.TXT
Normal file
@@ -0,0 +1,94 @@
|
||||
PLASMA goes ROGUE
|
||||
=================
|
||||
|
||||
Introduction
|
||||
------------
|
||||
|
||||
This version of ROGUE is somewhat different than others. It is very simple in most ways, but I have developed a (I think) unique visibility algorithm that runs extremely fast. Fast enough to run interpreted by the PLASMA VM on a 1 MHz 6502, and space efficient enough to allow for large (in the future) dungeons. The unique feature of this ROGUE is that lighting becomes critical and strategic. You are in dark catacombs, after all. You enter with a lit lamp, throwing off a circle of light. There are also torches throughout the catacombs that light up a small surrounding circle of light. Other items in the catacombs are mana (health+energy increase), a key, a raft, and gold. You will also encounter a number of enemies that will track you down to try and kill you. You will also encounter doors, locked doors, windows, water, and crevasses.
|
||||
|
||||
Strategy
|
||||
--------
|
||||
|
||||
As you travel through the catacombs, you must watch your health, energy, and lamp oil levels. Once health reaches zero, you are dead. As energy reaches zero, your vision will narrow and you will no longer be able to run. When the lamp oil runs out, you will be cast into darkness. If you see any torches in your field of vision, you can navigate to them. Taking the torch will extinguish the torch and replenish some of your lamp oil. Note that as you travel through the catacombs, your map of what you have seen will automatically fill in. But, if you are in the dark, you cannot read your map. You must turn on your lamp or get next to a torch before you can read the map again. If you are in the dark and can’t see any torches in your field of vision, you are in complete darkness. It is easy to lose your bearings. As such, the absolute direction movements no longer work (NSEW) - you will end up in a random direction if you try. However, the relative turns, left/right and forward/backward controls continue to work (that you can do in the dark).
|
||||
|
||||
Being in the dark can be advantageous, however. All the enemies in the catacombs can see you if you are in light, just as you can see them. If you are in darkness, they can't see you, and you can move around without being tracked. Don't run into them! Also, don't fall off a crevasse. You will hear certain noises giving you feedback on what is going on. A simple beep when you run into walls. A groan when an enemy moves towards you. A bleep when you pick an item up. Other noises when you fall over an edge or win a battle. These can be used strategically when moving in the dark.
|
||||
|
||||
Health will slowly improve as you move around. However, energy is depleted as you move. Mana will increase both health and energy. If health is already at 100, it won’t go any higher. Same for energy, but it is important to keep both high. When energy goes low, you can no longer move quickly and your field-of-vision narrows. When health goes to zero, you are dead.
|
||||
|
||||
Tile Description
|
||||
----------------
|
||||
|
||||
As ROGUE uses the text screen for display, a little creativity is required to interpret the map. These are the characters you will see and what the represent. Once you get the hang of it, it will be just like looking at the unencoded Matrix.
|
||||
|
||||
Screen Character Represents
|
||||
# Wall
|
||||
. Floor
|
||||
: Window (barred opening)
|
||||
+ Door
|
||||
% Locked Door (need key to open)
|
||||
' ' space Crevasse (pit - don't fall in)
|
||||
= Exit
|
||||
- Entrance
|
||||
*,X Torch
|
||||
& Mana
|
||||
, Key (yep, hard to spot)
|
||||
@ Raft (need to cross water)
|
||||
((( Water
|
||||
))) Water (you will drown without raft)
|
||||
$ Gold
|
||||
|
||||
Flashing Entity
|
||||
T Thief
|
||||
O Ogre
|
||||
Z Zombie
|
||||
R Rogue
|
||||
|
||||
Player Facing Direction
|
||||
^ North
|
||||
\ NE
|
||||
> East
|
||||
/ SE
|
||||
v South
|
||||
\ SW
|
||||
< West
|
||||
/ NW
|
||||
Tiles in light are inverse. Entities are displayed only when lit and in field of view. The map is only visible when lit, i.e lamp is on or standing next to a torch.
|
||||
|
||||
Interaction
|
||||
-----------
|
||||
|
||||
Keyboard commands Action
|
||||
Q Run (Quick)
|
||||
W up-arrow Forward
|
||||
S down-arrow Backward
|
||||
A left-arrow Turn left
|
||||
D right-arrow Turn right
|
||||
I Move N
|
||||
J Move W
|
||||
K Move E
|
||||
M Move S
|
||||
< , Turn lamp down
|
||||
> . Turn lamp up/on
|
||||
O Turn lamp off
|
||||
Space-bar Open door
|
||||
Return Pick up item
|
||||
X Exit (die)
|
||||
Whenever you and an enemy end up on the same tile, battle commences. As you win fights, your skill increases, improving your attack effectiveness. As you advance through the catacombs, the enemies become more powerful. You will need to replenish health and energy with mana. Don't forget, the alternative to fighting is stealth in the darkness. During battle, you have the option to run. If you have low energy, you won't get very far. Also, when fighting, you get turned around so you can't depend on the direction you were facing before fighting. Running ('Q'uick) will get you away from enemies but will use much more energy.
|
||||
|
||||
If you should die, restart the game by typing:
|
||||
|
||||
+rogue
|
||||
|
||||
Map Levels
|
||||
----------
|
||||
Level maps are up to 62x62 in size (plus a wall boundary for an effective 64x64 map size). They can be smaller than this. The game will end when it tries to load an non-existent level. Levels start at file name “LEVEL0“ and can go all the way to “LEVEL9“, but must be sequential.
|
||||
|
||||
There are two levels included on the disk, and an empty level for you to use as a template. You can edit the map levels, and add your own. They are simple ASCII text files. The included editor can edit the maps right on the disk. type:
|
||||
|
||||
+ed level.empty
|
||||
|
||||
after exiting from ROGUE. Make your changes and save it as LEVEL0" to "LEVEL9". The next free level is currently "LEVEL2". You may also edit an existing level:
|
||||
|
||||
+ed level0
|
||||
|
||||
for instance.
|
@@ -81,13 +81,13 @@ If you should die, restart the game by typing:
|
||||
|
||||
Level maps are up to 62x62 in size (plus a wall boundary for an effective 64x64 map size). They can be smaller than this. The game will end when it tries to load an non-existent level. Levels start at file name “LEVEL0“ and can go all the way to “LEVEL9“, but must be sequential.
|
||||
|
||||
There are two levels included on the disk, and an empty level for you to use as a template. You can edit the map levels, and add your own. They are simple ASCII text files. The included sandbox editor can edit the maps right on the disk. type:
|
||||
There are two levels included on the disk, and an empty level for you to use as a template. You can edit the map levels, and add your own. They are simple ASCII text files. The included editor can edit the maps right on the disk. type:
|
||||
```
|
||||
-sandbox level.empty
|
||||
+ed level.empty
|
||||
```
|
||||
after exiting from ROGUE. Make your changes and save it as LEVEL0" to "LEVEL9". The next free level is currently "LEVEL2". You may also edit an existing level:
|
||||
```
|
||||
-sandbox level0
|
||||
+ed level0
|
||||
```
|
||||
for instance.
|
||||
|
||||
|
@@ -1,34 +1,40 @@
|
||||
# PLASMA Version 2.0 Alpha 1
|
||||
# PLASMA Version 2.1
|
||||
|
||||
Welcome to PLASMA: the Grand Unifying Platform for the Apple 1, ][, and ///.
|
||||
|
||||
Download the five disk images:
|
||||
|
||||
[PLASMA 2.0 Alpha1 800K Full System](https://github.com/dschmenk/PLASMA/blob/master/images/apple/PLASMA2.2mg?raw=true)
|
||||
[PLASMA 2.1 800K Full System](https://github.com/dschmenk/PLASMA/blob/master/images/apple/PLASMA-2.1.2mg?raw=true)
|
||||
|
||||
[PLASMA 2.0 Alpha1 System and ProDOS Boot](https://github.com/dschmenk/PLASMA/blob/master/images/apple/PLASMA2-SYS.PO?raw=true)
|
||||
[PLASMA 2.1 ProDOS Boot & Install](https://github.com/dschmenk/PLASMA/blob/master/images/apple/PLASMA-2.1-INST.po?raw=true)
|
||||
|
||||
[PLASMA 2.0 Alpha1 Build Tools](https://github.com/dschmenk/PLASMA/blob/master/images/apple/PLASMA2-BLD.PO?raw=true)
|
||||
[PLASMA 2.1 System Libraries](https://github.com/dschmenk/PLASMA/blob/master/images/apple/PLASMA-2.1-SYS.po?raw=true)
|
||||
|
||||
[PLASMA 2.0 Alpha1 Demos](https://github.com/dschmenk/PLASMA/blob/master/images/apple/PLASMA2-DEM.PO?raw=true)
|
||||
[PLASMA 2.1 Build Tools](https://github.com/dschmenk/PLASMA/blob/master/images/apple/PLASMA-2.1-BLD.po?raw=true)
|
||||
|
||||
[PLASMA 2.0 Alpha1 TCP/IP network modules](https://github.com/dschmenk/PLASMA/blob/master/images/apple/PLASMA2-INET.PO?raw=true)
|
||||
[PLASMA 2.1 Demos](https://github.com/dschmenk/PLASMA/blob/master/images/apple/PLASMA-2.1-DEMOS.po?raw=true)
|
||||
|
||||
[PLASMA 2.0 Alpha1 Apple /// SOS Mame Boot and SANE floating point modules](https://github.com/dschmenk/PLASMA/blob/master/images/apple/PLASMA2-FPSOS.PO?raw=true)
|
||||
[PLASMA 2.1 TCP/IP network modules](https://github.com/dschmenk/PLASMA/blob/master/images/apple/PLASMA-2.1-INET.po?raw=true)
|
||||
|
||||
[PLASMA 2.0 Alpha1 Apple /// Mame hard disk image](https://github.com/dschmenk/PLASMA/blob/master/images/apple/apple3.hd?raw=true)
|
||||
[PLASMA 2.1 Apple /// SOS Mame Boot and SANE floating point modules](https://github.com/dschmenk/PLASMA/blob/master/images/apple/PLASMA-2.1-FPSOS.po?raw=true)
|
||||
|
||||
PLASMA can be run from floppies, System in Drive 1, and Build or Demos in Drive 2. Mass storage is the recommended installation that looks like (replacing HARDISK with your volume name of choice):
|
||||
[PLASMA 2.1 Apple /// SOS Mame Boot](https://github.com/dschmenk/PLASMA/blob/master/images/apple/PLASMA2-A3MAME.PO?raw=true)
|
||||
|
||||
System Files => /HARDISK/PLASMA/
|
||||
[PLASMA 2.1 Apple /// Mame hard disk image](https://github.com/dschmenk/PLASMA/blob/master/images/apple/apple3.hd?raw=true)
|
||||
|
||||
[PLASMA 2.1 PLFORTH stand-alone boot](https://github.com/dschmenk/PLASMA/blob/master/images/apple/PLFORTH.PO?raw=true)
|
||||
|
||||
PLASMA now has a ProDOS hard disk install script. Mass storage is the recommended installation that looks like (replacing HARDISK with your volume name of choice) if you want to copy files yourself:
|
||||
|
||||
Boot & System Files => /HARDISK/PLASMA/
|
||||
|
||||
Build Files => /HARDISK/PLASMA/BLD/
|
||||
|
||||
Demo Files => /HARDISK/PLASMA/DEMOS/
|
||||
|
||||
SANE files => /HARDISK/PLASMA/SYS
|
||||
Floating Point SANE Files => /HARDISK/PLASMA/SYS
|
||||
|
||||
INET files => /HARDDISK/PLASMA/SYS
|
||||
INET Files => /HARDDISK/PLASMA/SYS
|
||||
|
||||
Use the System Utilities to copy the floppy images into the above mentioned directories.
|
||||
|
||||
@@ -46,7 +52,7 @@ PLASMA can utilize the 16 bit features of the 65802 and 65816 processors to impr
|
||||
|
||||
## Apple ///
|
||||
|
||||
The Apple /// gets the environment it always wanted: The ability to navigate the filesystem with a command line interface. The Apple /// always boots from the floppy drive, even if a hard disk is installed. The PLASMA.SOS floppy should be updated with the SOS.DRIVER configured for your machine. It contains the SOS.DRIVER configured for the Apple 3 Ready-To-Run Mame environment. Once booted, type `S /HARDISK/PLASMA` (or your install directory of choice) to change to, and set, the system directory. This can be automated by creating an `AUTORUN` file on the boot floppy with the above command in it.
|
||||
The Apple /// gets the environment it always wanted: The ability to navigate the filesystem with a command line interface. The Apple /// always boots from the floppy drive, even if a hard disk is installed. `PLASMA2-A3MAME.PO` is an Apple 3 bootable disk containing the SOS.DRIVER configured for the [Apple 3 Ready-To-Run Mame environment](https://github.com/datajerk/apple3rtr). `apple3.hd` is the pre-installed PLASMA hard disk image set up for [Apple 3 Ready-to-Run](https://github.com/datajerk/apple3rtr). For a physical Apple 3, the PLASMA2-FPSOS.PO floppy should be updated with the SOS.DRIVER configured for the machine. Once booted, type `S /HARDISK/PLASMA` (or your install directory of choice) to change to, and set, the system directory. This can be automated by creating an `AUTORUN` file on the boot floppy with the above command in it.
|
||||
|
||||
## PLASMA Command Line Shell
|
||||
|
||||
@@ -75,7 +81,7 @@ The shell is very brief with error messages. It is meant solely as a way to run
|
||||
|
||||
PLASMA comes with many library modules used by the tools, demos and sample code. The PLASMA system volume must remain in place for the duration of PLASMAs run otherwise it won't be able to find CMD or the system libraries. Probably the most useful included module is the editor. It is used for editing PLASMA source file, assembly source files, or any text file. Execute it with:
|
||||
```
|
||||
+ED [TEXT FILE]
|
||||
+ED [TEXT FILE] [GOTO LINE NUMBER]
|
||||
```
|
||||
The file manipulation utilities to copy, delete, rename, create directories, and change file type and aux type remove the need for external programs to do the same. PLASMA can now be installed with the tools included on the PLASMA2-SYS boot floppy. They are:
|
||||
```
|
||||
@@ -86,7 +92,7 @@ The file manipulation utilities to copy, delete, rename, create directories, and
|
||||
+TYPE <FILENAME> [NEWTYPE [NEWAUX]]
|
||||
+CAT [-R] <FILEPATH]
|
||||
```
|
||||
The ```-R``` option will operate on the directories recursively. Wildcard filenames can be specified with ```'*'``` matching zero or more characters, and ```'?'``` matching any character.
|
||||
The ```-R``` option will operate on the directories recursively. Wildcard filenames can be specified with ```'*'``` matching zero or more characters, and ```'?'``` matching any character. When copying files to the current directory, ```=``` can be used as a shortcut.
|
||||
|
||||
## Compiler Modules
|
||||
|
||||
@@ -118,6 +124,34 @@ There is a [YouTube playlist](https://www.youtube.com/playlist?list=PLlPKgUMQbJ7
|
||||
|
||||
- The documentation is sparse and incomplete. Yep, could use your help...
|
||||
|
||||
# Changes in PLASMA for 2.0 Release
|
||||
|
||||
1. Fix command line buffer overflow
|
||||
|
||||
2. Use VBlank to blink editor cursor so not CPU speed dependent
|
||||
|
||||
3. Add ```=``` for ```+COPY``` current destination
|
||||
|
||||
4. Add //c support for DGRLIB and GRLIB wait-for-VBlank routines
|
||||
|
||||
# Changes in PLASMA for 2.0 Beta
|
||||
|
||||
1. Compilers allows for including self imported defines
|
||||
|
||||
2. Compilers fixed for local constants
|
||||
|
||||
3. Floating point string formatting fixes and improvements
|
||||
|
||||
4. Fiber library exports number of active fibers
|
||||
|
||||
# Changes in PLASMA for 2.0 Alpha 2
|
||||
|
||||
1. Self hosted compiler fixes for invalid array size constants
|
||||
|
||||
2. Ensure IDs in self hosted compiler are 31 characters significant
|
||||
|
||||
3. Fix bug COPY file parsing and move common routine into MATCHFILES
|
||||
|
||||
# Changes in PLASMA for 2.0 Alpha 1
|
||||
|
||||
1. Improved entry/exit for 128K Apple IIe //c
|
||||
|
352
doc/Version 2.1.md
Normal file
352
doc/Version 2.1.md
Normal file
@@ -0,0 +1,352 @@
|
||||
# PLASMA Version 2.11
|
||||
|
||||
Welcome to PLASMA: the Grand Unifying Platform for the Apple 1, ][, and ///.
|
||||
|
||||
Version 2.11 is a minor update to address the relocating loader for EDASM generated modules with 8 bit fixups. All modules up to now have been generated by PLASM and only use 16 bit fixups. Mostly usefull for future modules built with EDASM. Check out the Assembly Language Toolkit below.
|
||||
|
||||
If you already have 2.1 installed, here are the updated files:
|
||||
|
||||
[PLASMA 2.11 Update](https://github.com/dschmenk/PLASMA/raw/master/images/apple/PLASMA-2.11-UPD.po)
|
||||
|
||||
Download the full 2.11 disk image set:
|
||||
|
||||
[PLASMA 2.11 HD Full System](https://github.com/dschmenk/PLASMA/raw/master/images/apple/PLASMA2.2mg)
|
||||
|
||||
[PLASMA 2.11 800K Full System](https://github.com/dschmenk/PLASMA/raw/master/images/apple/PLASMA-2.1.po)
|
||||
|
||||
[PLASMA 2.11 ProDOS Boot & Install](https://github.com/dschmenk/PLASMA/raw/master/images/apple/PLASMA-2.1-INST.po)
|
||||
|
||||
[PLASMA 2.1 System Libraries](https://github.com/dschmenk/PLASMA/raw/master/images/apple/PLASMA-2.1-SYS.po)
|
||||
|
||||
[PLASMA 2.11 Build Tools](https://github.com/dschmenk/PLASMA/raw/master/images/apple/PLASMA-2.1-BLD.po)
|
||||
|
||||
[PLASMA 2.1 Demos](https://github.com/dschmenk/PLASMA/raw/master/images/apple/PLASMA-2.1-DEMOS.po)
|
||||
|
||||
[PLASMA 2.1 TCP/IP network modules](https://github.com/dschmenk/PLASMA/raw/master/images/apple/PLASMA-2.1-INET.po)
|
||||
|
||||
[PLASMA 2.11 Apple /// SOS and SANE floating point modules](https://github.com/dschmenk/PLASMA/raw/master/images/apple/PLASMA-2.1-FPSOS.po)
|
||||
|
||||
[PLASMA 2.11 Apple /// SOS Mame Boot](https://github.com/dschmenk/PLASMA/raw/master/images/apple/PLASMA2-A3MAME.PO)
|
||||
|
||||
[PLASMA 2.11 Apple /// Mame hard disk image](https://github.com/dschmenk/PLASMA/raw/master/images/apple/apple3.hd)
|
||||
|
||||
[PLASMA 2.11 PLFORTH stand-alone boot](https://github.com/dschmenk/PLASMA/raw/master/images/apple/PLFORTH.PO)
|
||||
|
||||
[PLASMA 2.11 Assembly Language Toolkit](https://github.com/dschmenk/PLASMA/raw/master/images/apple/ASM-TK.po)
|
||||
|
||||
PLASMA now has a ProDOS hard disk install script. Mass storage is the recommended installation that looks like (replacing HARDISK with your volume name of choice) if you want to copy files yourself:
|
||||
|
||||
Boot & System Files => /HARDISK/PLASMA/
|
||||
|
||||
Build Files => /HARDISK/PLASMA/BLD/
|
||||
|
||||
Demo Files => /HARDISK/PLASMA/DEMOS/
|
||||
|
||||
Floating Point SANE Files => /HARDISK/PLASMA/SYS
|
||||
|
||||
INET Files => /HARDDISK/PLASMA/SYS
|
||||
|
||||
Use the System Utilities to copy the floppy images into the above mentioned directories.
|
||||
|
||||
## Apple 1
|
||||
|
||||
The Apple 1 is a very constrained system compared to the ][ and ///. It is required to have the CFFA1 disk adapter installed to provide file storage and a full 32K od RAM. To get the files onto the CF card required the use of [CiderPress](http://a2ciderpress.com) and they must be placed in one directory. Most PLASMA programs won't work on the Apple 1 due to limited filesystem support, video/graphics capabilities, and lack of audio output. It does, however, make a good place to start when porting PLASMA to a new platform.
|
||||
|
||||
## Apple ][
|
||||
|
||||
To boot directly into PLASMA, you will need to put the system files in the root prefix of the boot device and make sure PLASMA.SYSTEM is the first SYSTEM file in the directory. Otherwise, start PLASMA.SYSTEM from your program launcher of choice. All Apple ][ models with 64K and two floppy drives are supported up to a maxed out IIGS with accelerator and hard drive.
|
||||
|
||||
#### 65802/65816 Support
|
||||
|
||||
PLASMA can utilize the 16 bit features of the 65802 and 65816 processors to improve performance of the PLASMA VM operation. This is transparent to the programmer/user and doesn't make any additional memory or capabilities available to PLASMA. PLASMA will automatically run the most optimal VM for your configuration.
|
||||
|
||||
## Apple ///
|
||||
|
||||
The Apple /// gets the environment it always wanted: The ability to navigate the filesystem with a command line interface. The Apple /// always boots from the floppy drive, even if a hard disk is installed. `PLASMA2-A3MAME.PO` is an Apple 3 bootable disk containing the SOS.DRIVER configured for the [Apple 3 Ready-To-Run Mame environment](https://github.com/datajerk/apple3rtr). `apple3.hd` is the pre-installed PLASMA hard disk image set up for [Apple 3 Ready-to-Run](https://github.com/datajerk/apple3rtr). For a physical Apple 3, the PLASMA2-FPSOS.PO floppy should be updated with the SOS.DRIVER configured for the machine. Once booted, type `S /HARDISK/PLASMA` (or your install directory of choice) to change to, and set, the system directory. This can be automated by creating an `AUTORUN` file on the boot floppy with the above command in it.
|
||||
|
||||
## PLASMA Command Line Shell
|
||||
|
||||
PLASMA incorporates a very basic command line shell to facilitate navigating the filesystem and executing both SYSTEM/SOS programs and PLASMA modules. It has a few built-in commands:
|
||||
|
||||
| Command | Operation |
|
||||
|:----------------------------:|-------------------------|
|
||||
| C [PREFIX] | Catalog prefix
|
||||
| P \<PREFIX\> | change to Prefix
|
||||
| / | change to parent prefix
|
||||
| V | show online Volumes
|
||||
| S \<PREFIX\> | set System prefix*
|
||||
| +SOS \<SOS.INTERP\> [PREFIX] | launch SOS interpreter*
|
||||
| -\<SYSTEM PROGRAM\> [PARAMS] | launch SYSTEM program**
|
||||
| +\<PLASMA MODULE\> [PARAMS] | exec PLASMA module
|
||||
```
|
||||
[Optional parameters]
|
||||
<Required parameters>
|
||||
* Apple /// only
|
||||
** Apple ][ only
|
||||
```
|
||||
|
||||
The shell is very brief with error messages. It is meant solely as a way to run programs that accept command line parameters and take up as little memory as possible. It does, however, provide a rich runtime for PLASMA modules.
|
||||
|
||||
## Included Modules
|
||||
|
||||
PLASMA comes with many library modules used by the tools, demos and sample code. The PLASMA system volume must remain in place for the duration of PLASMAs run otherwise it won't be able to find CMD or the system libraries. Probably the most useful included module is the editor. It is used for editing PLASMA source file, assembly source files, or any text file. Execute it with:
|
||||
```
|
||||
+ED [TEXT FILE] [GOTO LINE NUMBER]
|
||||
```
|
||||
The file manipulation utilities to copy, delete, rename, create directories, and change file type and aux type remove the need for external programs to do the same. PLASMA can now be installed with the tools included on the PLASMA2-SYS boot floppy. They are:
|
||||
```
|
||||
+COPY [-R] <SRCPATH>+ <DSTPATH>
|
||||
+DEL [-R] <FILEPATH>
|
||||
+REN <FILENAME> <NEWNAME>
|
||||
+NEWDIR <NEWDIRECTORY>
|
||||
+TYPE <FILENAME> [NEWTYPE [NEWAUX]]
|
||||
+CAT [-R] <FILEPATH]
|
||||
```
|
||||
The ```-R``` option will operate on the directories recursively. Wildcard filenames can be specified with ```'*'``` matching zero or more characters, and ```'?'``` matching any character. When copying files to the current directory, ```=``` can be used as a shortcut.
|
||||
|
||||
## Compiler Modules
|
||||
|
||||
The build disk includes sample source, include files for the system modules, and the PLASMA compiler+optimizer modules. The compiler is invoked with:
|
||||
```
|
||||
+PLASM [-[W][O[2]] <SOURCE FILE> [OUTPUT FILE]
|
||||
```
|
||||
Compiler warnings are enabled with `-W`. The optional optimizer is enabled with `-O` and extra optimizations are enabled with `-O2`. The source code for a few sample programs are included. The big one, `RPNCALC.PLA`, is the sample RPN calculator that uses many of PLASMA's advanced features. The self-hosted compiler is the same compiler as the cross-compiler, just transcribed from C to PLASMA (yes, the self-hosted PLASMA compiler is written in PLASMA). It requires patience when compiling: it is a fairly large and extensive program.
|
||||
|
||||
## Assembly Toolkit
|
||||
|
||||
New for 2.11 is the assembly language toolkit. The PLASMA module was originally architected around the REL file generated by the ProDOS toolkit assembler, EDASM. This minor update fixes the PLASMA relocating loader to handle 8 bit fixups. PLASM generated modules only use 16 bit fixups, so not an issue for existing modules. Download the toolkit that includes the ProDOS EDASM assembler and sample code. Also the 2.11 updates (if you have 2.1 already installed) here:
|
||||
|
||||
[PLASMA 2.11 Assembly Language Toolkit](https://github.com/dschmenk/PLASMA/raw/master/images/apple/ASM-TK.po)
|
||||
|
||||
[PLASMA 2.11 Update](https://github.com/dschmenk/PLASMA/raw/master/images/apple/PLASMA-2.11-UPD.po)
|
||||
|
||||
## FORTH Module
|
||||
|
||||
New for version 2.1 is a FORTH language module capable of interpreting script files and interactive programming. Further documentation here: https://github.com/dschmenk/PLASMA/blob/master/doc/PLFORTH.md. Samples scripts are in /HARDISK/BLD/SCRIPTS
|
||||
|
||||
## Demos
|
||||
|
||||
There are some demo programs included for your perusal. Check out `ROGUE` for some diversion. You can find the documentation here: https://github.com/dschmenk/PLASMA/blob/master/doc/Rogue%20Instructions.md. A music sequencer to play through a MockingBoard if it is detected, or the built-in speaker if not. A minimal Web server if you have an Uthernet2 card (required). Try `SPIDERS`for some hires shoot'em-up action. Bug reports appreciated.
|
||||
|
||||
## Source Code
|
||||
|
||||
Most sample source code is included from the project. They build without alteration and should be a good starting point for further explorations. The header files for the included library modules are in the INC directory.
|
||||
|
||||
## Video Playlist
|
||||
|
||||
There is a [YouTube playlist](https://www.youtube.com/playlist?list=PLlPKgUMQbJ79VJvZRfv1CJQf4SP2Gw3yU) created for learning PLASMA.
|
||||
|
||||
## Issues
|
||||
|
||||
- All the modules and runtime are written mostly in PLASMA; the compiler and editor as well. This means that there may be some startup delay as the PLASMA module loader reads in the module dependencies and performs dynamic linking. But a 1 MHz, 8 bit CPU interpreting bytecodes is never going to match a modern computer. As noted earlier, an accelerator and mass storage are your (and PLASMA's) friend.
|
||||
|
||||
- All the project modules are included. They have been lightly tested.
|
||||
|
||||
- The Apple /// may not always report errors properly or at all.
|
||||
|
||||
- The documentation is sparse and incomplete. Yep, could use your help...
|
||||
|
||||
# Changes in PLASMA for 2.11 Release
|
||||
|
||||
1. Minor update to load modules generated by EDASM with 8 bit fixups
|
||||
|
||||
# Changes in PLASMA for 2.1 Release
|
||||
|
||||
1. Lots of small bug fixes in floating point, file copy and graphics libraries
|
||||
|
||||
2. MULT opcode speedup improvements
|
||||
|
||||
3. Overhaul 65802/65814 VM for better speed and compatibility with PLFORTH compilation
|
||||
|
||||
4. Many Apple /// improvements and bug fixes
|
||||
|
||||
5. Low memory fixes and tests
|
||||
|
||||
6. FORTH language support as a PLASMA module. Full accessabilit to PLASMA modules and libraries
|
||||
|
||||
7. Install script for ProDOS mass storage
|
||||
|
||||
# Changes in PLASMA for 2.0 Release
|
||||
|
||||
1. Fix command line buffer overflow
|
||||
|
||||
2. Use VBlank to blink editor cursor so not CPU speed dependent
|
||||
|
||||
3. Add ```=``` for ```+COPY``` current destination
|
||||
|
||||
4. Add //c support for DGRLIB and GRLIB wait-for-VBlank routines
|
||||
|
||||
# Changes in PLASMA for 2.0 Beta
|
||||
|
||||
1. Compilers allows for including self imported defines
|
||||
|
||||
2. Compilers fixed for local constants
|
||||
|
||||
3. Floating point string formatting fixes and improvements
|
||||
|
||||
4. Fiber library exports number of active fibers
|
||||
|
||||
# Changes in PLASMA for 2.0 Alpha 2
|
||||
|
||||
1. Self hosted compiler fixes for invalid array size constants
|
||||
|
||||
2. Ensure IDs in self hosted compiler are 31 characters significant
|
||||
|
||||
3. Fix bug COPY file parsing and move common routine into MATCHFILES
|
||||
|
||||
# Changes in PLASMA for 2.0 Alpha 1
|
||||
|
||||
1. Improved entry/exit for 128K Apple IIe //c
|
||||
|
||||
2. Improved entry for Apple ///
|
||||
|
||||
3. Improved entry and function calls for 16 bit VM
|
||||
|
||||
# Changes in PLASMA for 2.0 DP 4
|
||||
|
||||
1. Improved editor auto-indenting
|
||||
|
||||
2. Compiler fix for terneray operator precedence
|
||||
|
||||
3. Machine check for HGR library
|
||||
|
||||
# Changes in PLASMA for 2.0 DP 3
|
||||
|
||||
1. File manipulation utilities fixed for Apple /// SOS vs ProDOS differences
|
||||
|
||||
2. More optimizations for HiRes graphics libraries
|
||||
|
||||
3. Spiders From Mars hires demo game
|
||||
|
||||
# Changes in PLASMA for 2.0 DP 2
|
||||
|
||||
1. Many file manipulaition utilities (COPY, REName, NEWDIRectory, DELete, CATalog, TYPE)
|
||||
|
||||
2. New and updated libraries for lo-res. double lo-res and hi-res graphics w/ sprites
|
||||
|
||||
3. 32 bit integer library for those times when 16 bits just isn't enough
|
||||
|
||||
4. Apple /// improvements to other SOS.INTERP launching with SOS utility
|
||||
|
||||
5. Apple /// JIT VM for speed and non JIT version to free up global memory
|
||||
|
||||
6. Editor improvements
|
||||
|
||||
7. A couple small compiler optimizations
|
||||
|
||||
8. Needed to break out TCP/IP modules into seperate floppy image
|
||||
|
||||
9. Library changes require full install
|
||||
|
||||
# Changes in PLASMA for 2.0 DP 1z
|
||||
|
||||
1. Many fixes for the value zero - especially in 65802/65816 divide routine
|
||||
|
||||
# Changes in PLASMA for 2.0 DP 1 E+C
|
||||
|
||||
1. Greatly improved code editor and additional compiler stats
|
||||
|
||||
# Changes in PLASMA for 2.0 DP 1a
|
||||
|
||||
1. Fix interaction with JIT compiler and module load/unload
|
||||
|
||||
# Changes in PLASMA for 2.0 DP 1
|
||||
|
||||
1. Expanded bytecode for more efficient size/performance of programs
|
||||
|
||||
2. Just-In-Time Compiler for native code performance (6502 and 65816) for frequently called routines
|
||||
|
||||
3. Automatically identify and run most optimal VM for configuration
|
||||
|
||||
# Changes in PLASMA for 1.2
|
||||
|
||||
1. Add TFTPD TFTP server
|
||||
|
||||
2. Fix Uthernet 1 driver
|
||||
|
||||
3. Add mouse module
|
||||
|
||||
4. Fix IRQ issues for interrupt driven mouse driver
|
||||
|
||||
# Changes in PLASMA for 1.1
|
||||
|
||||
1. All known bugs are fixed
|
||||
|
||||
2. PLASM compiler received a little performance boost with an assembly language helper for ID/keyword lexical scanner
|
||||
|
||||
# Changes in PLASMA for 1.0
|
||||
|
||||
If you have been programming in PLASMA before, the 1.0 version has some major and minor changes that you should be aware of:
|
||||
|
||||
1. Case is no longer significant. Imported symbols were always upper case. Now, all symbols are treated as if they were upper case. You may find that some symbols clash with previously defined symbols of different case. Hey, we didn't need lower case in 1977 and we don't need it now. You kids, get off my lawn!
|
||||
|
||||
2. Modules are now first class citizens. Translation: importing a module adds a symbol with the module name. You can simply refer to a module's address with it's name. This is how a module's API table is accessed (instead of adding a variable of the same name in the IMPORT section).
|
||||
|
||||
3. Bytecode changes means previously compiled modules will crash. Rebuild.
|
||||
|
||||
4. `BYTE` and `WORD` have aliases that may improve readability of the code. `CHAR` (character) and `RES` (reserve) are synonyms for `BYTE`. `VAR` (variable) is a synonym for `WORD`. These aliases add no functionality. They are simply syntactic sugar to add context to the source code, but may cause problems if you've previously used the same names for identifiers.
|
||||
|
||||
5. When declaring variables, a base size can come after the type, and an array size can folllow the identifier. For instance:
|
||||
```
|
||||
res[10] a, b, c
|
||||
```
|
||||
will reserve three variables of 10 bytes each. Additionally:
|
||||
```
|
||||
res[10] v[5], w[3]
|
||||
```
|
||||
will reserve a total of 80 bytes (10 * 5 + 10 * 3). This would be useful when combined with a structure definition. One could:
|
||||
```
|
||||
res[t_record] patients[20]
|
||||
```
|
||||
to reserve an array of 20 patient records.
|
||||
|
||||
6. Ternary operator. Just like C and descendants, `??` and `::` allow for an if-then-else inside an expression:
|
||||
```
|
||||
puts(truth == TRUE ?? "TRUE" :: "FALSE")
|
||||
```
|
||||
|
||||
7. Multiple value assignements. Multiple values can be returned from functions and listed on variable assignments:
|
||||
```
|
||||
def func#3 // Return 3 values
|
||||
return 10, 20, 30
|
||||
end
|
||||
|
||||
a, b, c = 1, 2, 3
|
||||
c, d, f = func()
|
||||
x, y = y, x // Swap x and y
|
||||
```
|
||||
|
||||
8. `DROP` allows for explicit dropping of values. In the above `func()` example, if the middle value was the only one desired, the others can be ignored with:
|
||||
```
|
||||
drop, h, drop = func()
|
||||
```
|
||||
|
||||
9. The compiler tracks parameter and return counts for functions. If the above `func()` were used without assigning all the return values, they would be dropped:
|
||||
```
|
||||
a = func() // Two values silently dropped
|
||||
```
|
||||
To generate compiler warning for this issue, and a few others, use the `-W` option when compiling.
|
||||
|
||||
10. Lambda (Anonymous) Functions. The ability to code a quick function in-line can be very powerful when used properly. Look here, https://en.wikipedia.org/wiki/Anonymous_function, for more information.
|
||||
|
||||
11. SANE (Standard Apple Numerics Environment) Floating Point Library. An extensive library (two, actually) of extended floating point (80 bit IEEE precision) functionality is suported. A wrapper library has been written to greatly simplify the interface to SANE. Look at the `RPNCALC.PLA` source code as an example.
|
||||
|
||||
12. Library Documentation. Preliminary documentation is available on the Wiki: https://github.com/dschmenk/PLASMA/wiki
|
||||
|
||||
13. Significant effort has gone into VM tuning and speeding up module loading/dynamic linking.
|
||||
|
||||
14. The VM zero page usage has changed. If you write assembly language routines, you will need to rebuild.
|
||||
|
||||
# Thanks
|
||||
|
||||
I wish to thank the people who have contributed the the PLASMA project. They have greatly improved the development of the language and documentation:
|
||||
|
||||
- Martin Haye: PLASMA programmer extraordinaire. Mr. Lawless Legends has requested many of the crucial features that set PLASMA apart.
|
||||
- Steve F (ZornsLemma): Has taken the optimizer to new levels and his work on porting PLASMA to the Beeb are amazing: http://stardot.org.uk/forums/viewtopic.php?f=55&t=12306&sid=5a503c593f0698ebc31e590ac61b09fc
|
||||
- Peter Ferrie: Assembly optimizer extraordinaire. He has made significant improvements into the code footprint in PLASMA so all the functionality can exist in just a few bytes.
|
||||
- David Schmidt (DaveX): His help in documentation have made it much more accessible and professional. Of course any errors are all his. Just kidding, they're mine ;-)
|
||||
- Andy Werner (6502.org): Catching the grammatical errors that I ain't no good at.
|
||||
- John Brooks: Apple II Guru par excellence. His insights got 10% performance increase out of the VM.
|
||||
|
||||
Dave Schmenk
|
||||
http://schmenk.is-a-geek.com
|
BIN
doc/forthwords.png
Normal file
BIN
doc/forthwords.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 19 KiB |
BIN
doc/racecar-scaled.JPG
Normal file
BIN
doc/racecar-scaled.JPG
Normal file
Binary file not shown.
After Width: | Height: | Size: 33 KiB |
BIN
doc/rcg1-dhgr-ntsc.png
Normal file
BIN
doc/rcg1-dhgr-ntsc.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 476 KiB |
BIN
doc/rcg1-dhgr.png
Normal file
BIN
doc/rcg1-dhgr.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 48 KiB |
BIN
doc/rcg2-dhgr.png
Normal file
BIN
doc/rcg2-dhgr.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 42 KiB |
BIN
images/apple/A1PLASMA.po
Executable file
BIN
images/apple/A1PLASMA.po
Executable file
Binary file not shown.
BIN
images/apple/ASM-TK.po
Executable file
BIN
images/apple/ASM-TK.po
Executable file
Binary file not shown.
BIN
images/apple/DARTHGR.po
Executable file
BIN
images/apple/DARTHGR.po
Executable file
Binary file not shown.
BIN
images/apple/DCGR-RGB.PO
Executable file
BIN
images/apple/DCGR-RGB.PO
Executable file
Binary file not shown.
BIN
images/apple/DHGR-BIGSHOW.PO
Normal file
BIN
images/apple/DHGR-BIGSHOW.PO
Normal file
Binary file not shown.
BIN
images/apple/DHGR-TK.po
Executable file
BIN
images/apple/DHGR-TK.po
Executable file
Binary file not shown.
BIN
images/apple/DRAWL.po
Normal file
BIN
images/apple/DRAWL.po
Normal file
Binary file not shown.
BIN
images/apple/PLASMA-2.1-BLD.po
Normal file
BIN
images/apple/PLASMA-2.1-BLD.po
Normal file
Binary file not shown.
BIN
images/apple/PLASMA-2.1-DEMOS.po
Normal file
BIN
images/apple/PLASMA-2.1-DEMOS.po
Normal file
Binary file not shown.
BIN
images/apple/PLASMA-2.1-FPSOS.po
Normal file
BIN
images/apple/PLASMA-2.1-FPSOS.po
Normal file
Binary file not shown.
BIN
images/apple/PLASMA-2.1-INET.po
Normal file
BIN
images/apple/PLASMA-2.1-INET.po
Normal file
Binary file not shown.
BIN
images/apple/PLASMA-2.1-INST.po
Normal file
BIN
images/apple/PLASMA-2.1-INST.po
Normal file
Binary file not shown.
BIN
images/apple/PLASMA-2.1-SYS.po
Normal file
BIN
images/apple/PLASMA-2.1-SYS.po
Normal file
Binary file not shown.
BIN
images/apple/PLASMA-2.1.po
Normal file
BIN
images/apple/PLASMA-2.1.po
Normal file
Binary file not shown.
BIN
images/apple/PLASMA-2.11-UPD.po
Normal file
BIN
images/apple/PLASMA-2.11-UPD.po
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
images/apple/PLEIADES-2.20-BLD.po
Normal file
BIN
images/apple/PLEIADES-2.20-BLD.po
Normal file
Binary file not shown.
BIN
images/apple/PLEIADES-2.20-DEMOS.po
Normal file
BIN
images/apple/PLEIADES-2.20-DEMOS.po
Normal file
Binary file not shown.
BIN
images/apple/PLEIADES-2.20-FPSOS.po
Normal file
BIN
images/apple/PLEIADES-2.20-FPSOS.po
Normal file
Binary file not shown.
BIN
images/apple/PLEIADES-2.20-INET.po
Normal file
BIN
images/apple/PLEIADES-2.20-INET.po
Normal file
Binary file not shown.
BIN
images/apple/PLEIADES-2.20-INST.po
Normal file
BIN
images/apple/PLEIADES-2.20-INST.po
Normal file
Binary file not shown.
BIN
images/apple/PLEIADES-2.20-SYS.po
Normal file
BIN
images/apple/PLEIADES-2.20-SYS.po
Normal file
Binary file not shown.
BIN
images/apple/PLEIADES-2.20.po
Normal file
BIN
images/apple/PLEIADES-2.20.po
Normal file
Binary file not shown.
BIN
images/apple/PLEIADES-A3MAME.po
Normal file
BIN
images/apple/PLEIADES-A3MAME.po
Normal file
Binary file not shown.
BIN
images/apple/PLFORTH.po
Normal file
BIN
images/apple/PLFORTH.po
Normal file
Binary file not shown.
BIN
images/apple/ROGUE.PO
Executable file
BIN
images/apple/ROGUE.PO
Executable file
Binary file not shown.
Binary file not shown.
BIN
src/dhgr.tk/demos/darthgr/DARTH.DHGR.BIN
Normal file
BIN
src/dhgr.tk/demos/darthgr/DARTH.DHGR.BIN
Normal file
Binary file not shown.
BIN
src/dhgr.tk/demos/darthgr/DARTHGR.REL
Normal file
BIN
src/dhgr.tk/demos/darthgr/DARTHGR.REL
Normal file
Binary file not shown.
BIN
src/dhgr.tk/demos/darthgr/IMPERIAL.SEQ.BIN
Normal file
BIN
src/dhgr.tk/demos/darthgr/IMPERIAL.SEQ.BIN
Normal file
Binary file not shown.
BIN
src/dhgr.tk/demos/darthgr/TRADE54.FON.BIN
Normal file
BIN
src/dhgr.tk/demos/darthgr/TRADE54.FON.BIN
Normal file
Binary file not shown.
20
src/dhgr.tk/demos/darthgr/darthgr.pla
Normal file
20
src/dhgr.tk/demos/darthgr/darthgr.pla
Normal file
@@ -0,0 +1,20 @@
|
||||
include "inc/cmdsys.plh"
|
||||
include "dhgr.tk/inc/dhgrlib.plh"
|
||||
include "dhgr.tk/inc/dhgrutils.plh"
|
||||
include "inc/sndseq.plh"
|
||||
|
||||
sysflags resxtxt1|reshgr1|resxhgr1
|
||||
|
||||
var strWidth, strHeight
|
||||
char darthstr = "DartH GRaphics"
|
||||
dcgrFont(fontRead("trade54.fon"))
|
||||
strWidth, strHeight = dcgrStrExtents(@darthstr)
|
||||
dhgrMode(DHGR_COLOR_MODE)
|
||||
screenRead("darth.dhgr")
|
||||
musicPlay(musicRead("imperial.seq"), FALSE)
|
||||
musicGetKey(0, NULL)
|
||||
dcgrColor(CLR_WHITE)
|
||||
dcgrStr((140 - strWidth) / 2, (strHeight * 7) / 8, @darthstr)
|
||||
getc
|
||||
dhgrMode(DHGR_TEXT_MODE)
|
||||
done
|
BIN
src/dhgr.tk/demos/penguins/PEN1.BIN
Normal file
BIN
src/dhgr.tk/demos/penguins/PEN1.BIN
Normal file
Binary file not shown.
BIN
src/dhgr.tk/demos/penguins/PEN10.BIN
Normal file
BIN
src/dhgr.tk/demos/penguins/PEN10.BIN
Normal file
Binary file not shown.
BIN
src/dhgr.tk/demos/penguins/PEN2.BIN
Normal file
BIN
src/dhgr.tk/demos/penguins/PEN2.BIN
Normal file
Binary file not shown.
BIN
src/dhgr.tk/demos/penguins/PEN3.BIN
Normal file
BIN
src/dhgr.tk/demos/penguins/PEN3.BIN
Normal file
Binary file not shown.
BIN
src/dhgr.tk/demos/penguins/PEN4.BIN
Normal file
BIN
src/dhgr.tk/demos/penguins/PEN4.BIN
Normal file
Binary file not shown.
BIN
src/dhgr.tk/demos/penguins/PEN5.BIN
Normal file
BIN
src/dhgr.tk/demos/penguins/PEN5.BIN
Normal file
Binary file not shown.
BIN
src/dhgr.tk/demos/penguins/PEN6.BIN
Normal file
BIN
src/dhgr.tk/demos/penguins/PEN6.BIN
Normal file
Binary file not shown.
BIN
src/dhgr.tk/demos/penguins/PEN7.BIN
Normal file
BIN
src/dhgr.tk/demos/penguins/PEN7.BIN
Normal file
Binary file not shown.
1
src/dhgr.tk/demos/penguins/PEN8.BIN
Normal file
1
src/dhgr.tk/demos/penguins/PEN8.BIN
Normal file
File diff suppressed because one or more lines are too long
BIN
src/dhgr.tk/demos/penguins/PEN9.BIN
Normal file
BIN
src/dhgr.tk/demos/penguins/PEN9.BIN
Normal file
Binary file not shown.
BIN
src/dhgr.tk/demos/penguins/PENGUIN.DHGR.BIN
Normal file
BIN
src/dhgr.tk/demos/penguins/PENGUIN.DHGR.BIN
Normal file
Binary file not shown.
134
src/dhgr.tk/demos/penguins/penguins.pla
Normal file
134
src/dhgr.tk/demos/penguins/penguins.pla
Normal file
@@ -0,0 +1,134 @@
|
||||
include "inc/cmdsys.plh"
|
||||
include "inc/args.plh"
|
||||
include "inc/fileio.plh"
|
||||
include "dhgr.tk/inc/dhgrlib.plh"
|
||||
include "dhgr.tk/inc/dhgrutils.plh"
|
||||
|
||||
sysflags resxtxt1|reshgr1|resxhgr1
|
||||
|
||||
const FRAME_WIDTH = 40
|
||||
const FRAME_HEIGHT = 40
|
||||
const FRAME_SIZE = FRAME_WIDTH * FRAME_HEIGHT / 2
|
||||
var arg
|
||||
byte xTV = 3
|
||||
byte yTV = 100
|
||||
|
||||
def greasy2dcgr(pixptr, grptr)#0
|
||||
byte i, j, cl, ch
|
||||
|
||||
for j = 0 to 39 step 2
|
||||
for i = 0 to 39 step 2
|
||||
cl = ^(grptr + i)
|
||||
ch = ^(grptr + i + 1)
|
||||
^(pixptr + i / 2) = (cl & $0F) | (ch << 4)
|
||||
^(pixptr + i / 2 + 20) = (cl >> 4) | (ch & $F0)
|
||||
next
|
||||
pixptr = pixptr + 40
|
||||
grptr = grptr + 40
|
||||
next
|
||||
end
|
||||
|
||||
def greasyImport(filename)#2
|
||||
var pixmapbase, pixmapptr, frameptr
|
||||
byte refnum, numframes, i
|
||||
|
||||
pixmapbase = NULL
|
||||
numframes = 0
|
||||
refnum = fileio:open(filename)
|
||||
if refnum
|
||||
fileio:read(refnum, @numframes, 1)
|
||||
pixmapbase = heapalloc(FRAME_SIZE * numframes)
|
||||
if pixmapbase
|
||||
frameptr = heapalloc(FRAME_SIZE)
|
||||
pixmapptr = pixmapbase
|
||||
for i = 1 to numframes
|
||||
fileio:read(refnum, frameptr, FRAME_SIZE)
|
||||
greasy2dcgr(pixmapptr, frameptr)
|
||||
pixmapptr = pixmapptr + FRAME_SIZE
|
||||
next
|
||||
fin
|
||||
fileio:close(refnum)
|
||||
heaprelease(frameptr)
|
||||
fin
|
||||
return pixmapbase, numframes
|
||||
end
|
||||
|
||||
def delay_getkey#0
|
||||
var busywait
|
||||
|
||||
for busywait = 0 to 3000
|
||||
if ^$C000 > 127
|
||||
break
|
||||
fin
|
||||
next
|
||||
end
|
||||
|
||||
def dblHeight(w, h, pixptr)#0
|
||||
byte i, span
|
||||
|
||||
span = (w + 1) / 2
|
||||
h = (h - 1) * 2
|
||||
for i = 0 to h step 2
|
||||
dcgrPixMap(0, i, w, 1, pixptr)
|
||||
dcgrPixMap(0, i + 1, w, 1, pixptr)
|
||||
pixptr = pixptr + span
|
||||
next
|
||||
end
|
||||
|
||||
def frameAnimate(filename)#0
|
||||
var frames, frameptr, framesize
|
||||
var frame7ptr, frame7span
|
||||
byte numframes, i
|
||||
|
||||
frames, numframes = greasyImport(filename)
|
||||
if frames == NULL; return; fin
|
||||
frame7ptr, frame7span = dhgrAllocBl7Mem(FRAME_WIDTH, FRAME_HEIGHT*2)
|
||||
dhgrSurfMem(OP_SRC, FRAME_HEIGHT, frame7ptr, frame7span)
|
||||
dhgrScrBl7(xTV, yTV, frame7span >> 2, FRAME_HEIGHT*2)
|
||||
dhgrSurfScr(OP_SRC)
|
||||
while ^$C000 < 128
|
||||
frameptr = frames
|
||||
for i = 1 to numframes
|
||||
dhgrSurfMem(OP_SRC, FRAME_HEIGHT*2, frame7ptr, frame7span)
|
||||
//dcgrPixMap(0, 0, FRAME_WIDTH, FRAME_HEIGHT, frameptr)
|
||||
dblHeight(FRAME_WIDTH, FRAME_HEIGHT, frameptr)
|
||||
dhgrSurfScr(OP_SRC)
|
||||
dhgrMemBl7(xTV,yTV,frame7span>>2,FRAME_HEIGHT*2,frame7ptr,frame7span)
|
||||
frameptr = frameptr + FRAME_SIZE
|
||||
//delay_getkey
|
||||
next
|
||||
loop
|
||||
^$C010
|
||||
end
|
||||
|
||||
arg = argNext(argFirst)
|
||||
if ^arg
|
||||
while ^(arg + 1) == '-'
|
||||
when toupper(^(arg + 2))
|
||||
is 'X' // Set X coord
|
||||
if ^arg > 2
|
||||
xTV = ^(arg + 3) - '0'
|
||||
if ^arg > 3
|
||||
xTV = xTV * 10 + ^(arg + 4) - '0'
|
||||
fin
|
||||
fin
|
||||
break
|
||||
is 'Y' // Set Y coord
|
||||
if ^arg > 2
|
||||
yTV = ^(arg + 3) - '0'
|
||||
if ^arg > 3
|
||||
yTV = yTV * 10 + ^(arg + 4) - '0'
|
||||
fin
|
||||
fin
|
||||
break
|
||||
wend
|
||||
arg = argNext(arg)
|
||||
loop
|
||||
dhgrMode(DHGR_COLOR_MODE)
|
||||
screenRead("PENGUIN.DHGR")
|
||||
frameAnimate(arg)
|
||||
dhgrMode(DHGR_TEXT_MODE)
|
||||
return 0
|
||||
fin
|
||||
puts("Usage: DCGRDEMO <GREASYFILE>\n")
|
||||
done
|
BIN
src/dhgr.tk/demos/startrek/ENT.DL.SPR.BIN
Normal file
BIN
src/dhgr.tk/demos/startrek/ENT.DL.SPR.BIN
Normal file
Binary file not shown.
BIN
src/dhgr.tk/demos/startrek/ENT.DN.SPR.BIN
Normal file
BIN
src/dhgr.tk/demos/startrek/ENT.DN.SPR.BIN
Normal file
Binary file not shown.
BIN
src/dhgr.tk/demos/startrek/ENT.DR.SPR.BIN
Normal file
BIN
src/dhgr.tk/demos/startrek/ENT.DR.SPR.BIN
Normal file
Binary file not shown.
BIN
src/dhgr.tk/demos/startrek/ENT.LT.SPR.BIN
Normal file
BIN
src/dhgr.tk/demos/startrek/ENT.LT.SPR.BIN
Normal file
Binary file not shown.
BIN
src/dhgr.tk/demos/startrek/ENT.RT.SPR.BIN
Normal file
BIN
src/dhgr.tk/demos/startrek/ENT.RT.SPR.BIN
Normal file
Binary file not shown.
BIN
src/dhgr.tk/demos/startrek/ENT.UL.SPR.BIN
Normal file
BIN
src/dhgr.tk/demos/startrek/ENT.UL.SPR.BIN
Normal file
Binary file not shown.
BIN
src/dhgr.tk/demos/startrek/ENT.UP.SPR.BIN
Normal file
BIN
src/dhgr.tk/demos/startrek/ENT.UP.SPR.BIN
Normal file
Binary file not shown.
BIN
src/dhgr.tk/demos/startrek/ENT.UR.SPR.BIN
Normal file
BIN
src/dhgr.tk/demos/startrek/ENT.UR.SPR.BIN
Normal file
Binary file not shown.
217
src/dhgr.tk/demos/startrek/fillshape.pla
Normal file
217
src/dhgr.tk/demos/startrek/fillshape.pla
Normal file
@@ -0,0 +1,217 @@
|
||||
include "inc/cmdsys.plh"
|
||||
include "inc/lines.plh"
|
||||
include "inc/vblank.plh"
|
||||
include "dhgr.tk/inc/dhgrlib.plh"
|
||||
include "dhgr.tk/inc/dhgrutils.plh"
|
||||
//
|
||||
// Pattern fill
|
||||
//
|
||||
const PAT_WIDTH = SCR_WIDTH
|
||||
const PAT_HEIGHT = 2
|
||||
word pattern
|
||||
//
|
||||
// Polygon variables
|
||||
//
|
||||
word leftedge, rightedge // Edge arrays
|
||||
byte polytop, polybottom // Poly top and bottom extents
|
||||
byte startvx, startvy // Starting poly vertex
|
||||
byte polyvx, polyvy // Current poly vertex
|
||||
byte sin90[] // first 90 degrees of sin in fixed s.15 format
|
||||
byte = 0>>7, 571>>7, 1143>>7, 1714>>7, 2285>>7, 2855>>7, 3425>>7, 3993>>7
|
||||
byte = 4560>>7, 5126>>7, 5690>>7, 6252>>7, 6812>>7, 7371>>7, 7927>>7, 8480>>7
|
||||
byte = 9032>>7, 9580>>7, 10125>>7, 10668>>7, 11207>>7, 11743>>7, 12275>>7, 12803>>7
|
||||
byte = 13327>>7, 13848>>7, 14364>>7, 14876>>7, 15383>>7, 15886>>7, 16383>>7, 16876>>7
|
||||
byte = 17364>>7, 17846>>7, 18323>>7, 18794>>7, 19260>>7, 19720>>7, 20173>>7, 20621>>7
|
||||
byte = 21062>>7, 21497>>7, 21926>>7, 22347>>7, 22762>>7, 23170>>7, 23571>>7, 23964>>7
|
||||
byte = 24351>>7, 24730>>7, 25101>>7, 25465>>7, 25821>>7, 26169>>7, 26509>>7, 26841>>7
|
||||
byte = 27165>>7, 27481>>7, 27788>>7, 28087>>7, 28377>>7, 28659>>7, 28932>>7, 29196>>7
|
||||
byte = 29451>>7, 29697>>7, 29935>>7, 30163>>7, 30381>>7, 30591>>7, 30791>>7, 30982>>7
|
||||
byte = 31164>>7, 31336>>7, 31498>>7, 31651>>7, 31794>>7, 31928>>7, 32051>>7, 32165>>7
|
||||
byte = 32270>>7, 32364>>7, 32449>>7, 32523>>7, 32588>>7, 32643>>7, 32688>>7, 32723>>7
|
||||
byte = 32748>>7, 32763>>7, 32767>>7
|
||||
//
|
||||
// Sin and Cos
|
||||
//
|
||||
def sinext(deg)#1
|
||||
return (sin90[deg] << 7) | (sin90[deg] >> 1)
|
||||
end
|
||||
def sin(deg)#1
|
||||
while deg > 360; deg = deg - 360; loop
|
||||
while deg < 0; deg = deg + 360; loop
|
||||
if deg <= 90
|
||||
return sinext(deg)
|
||||
elsif deg <= 180
|
||||
return sinext(180 - deg)
|
||||
elsif deg <= 270
|
||||
return -sinext(deg - 180)
|
||||
fin
|
||||
return -sinext(360 - deg)
|
||||
end
|
||||
def cos(deg)#1
|
||||
return sin(deg + 90)
|
||||
end
|
||||
//
|
||||
// Create pattern pixmap for filling
|
||||
//
|
||||
export def setPattern(clr1, clr2, dither)#0
|
||||
word patfill, clr
|
||||
|
||||
if not pattern
|
||||
pattern = heapalloc(SCR_WIDTH * PAT_HEIGHT)
|
||||
fin
|
||||
//
|
||||
// Even scanlines
|
||||
//
|
||||
clr = dither & 1 ?? clr2 :: clr1
|
||||
patfill = clr | (clr << 8)
|
||||
clr = dither & 2 ?? clr2 :: clr1
|
||||
patfill = patfill | (clr << 4) | (clr << 12)
|
||||
memset(pattern, patfill, SCR_WIDTH/2)
|
||||
patfill = (patfill << 4) | clr // Rotate pattern for odd pixel
|
||||
memset(pattern + SCR_WIDTH, patfill, SCR_WIDTH/2)
|
||||
//
|
||||
// Odd scanlines
|
||||
//
|
||||
clr = dither & 4 ?? clr2 :: clr1
|
||||
patfill = clr | (clr << 8)
|
||||
clr = dither & 8 ?? clr2 :: clr1
|
||||
patfill = patfill | (clr << 4) | (clr << 12)
|
||||
memset(pattern + SCR_WIDTH/2, patfill, SCR_WIDTH/2)
|
||||
patfill = (patfill << 4) | clr // Rotate pattern for odd pixel
|
||||
memset(pattern + SCR_WIDTH + SCR_WIDTH/2, patfill, SCR_WIDTH/2)
|
||||
end
|
||||
export def patrnRect(left, top, right, bottom)#0
|
||||
word patscan
|
||||
byte width, y
|
||||
|
||||
width = right - left + 1
|
||||
patscan = pattern + (left & 1 ?? SCR_WIDTH :: 0)
|
||||
for y = top to bottom
|
||||
dcgrPixMap(left, y, width, 1, patscan + (y & 1 ?? (SCR_WIDTH/2) :: 0))
|
||||
next
|
||||
end
|
||||
export def solidRect(left, top, right, bottom)#0
|
||||
byte l7, r7, x
|
||||
|
||||
l7 = (left | 7) / 7
|
||||
r7 = right / 7
|
||||
if l7 < r7
|
||||
dhgrClearBl7(l7, top, r7 - l7, bottom - top + 1)
|
||||
fin
|
||||
l7 = l7 * 7
|
||||
if l7 > left
|
||||
for x = l7-1 downto left
|
||||
dcgrVLin(top, bottom, x)
|
||||
next
|
||||
fin
|
||||
r7 = r7 * 7
|
||||
if r7 < right
|
||||
for x = r7 to right
|
||||
dcgrVLin(top, bottom, x)
|
||||
next
|
||||
fin
|
||||
end
|
||||
//
|
||||
// Convex polygon
|
||||
//
|
||||
def setEdge(x, y)#0
|
||||
if x < leftedge->[y]; leftedge->[y] = x; fin
|
||||
if x > rightedge->[y]; rightedge->[y] = x; fin
|
||||
end
|
||||
export def startPoly(x, y)#0
|
||||
setlineplot(@setEdge)
|
||||
leftedge = heapalloc(SCR_HEIGHT)
|
||||
rightedge = heapalloc(SCR_HEIGHT)
|
||||
memset(leftedge, $FFFF, SCR_HEIGHT)
|
||||
memset(rightedge, $0000, SCR_HEIGHT)
|
||||
polytop = y
|
||||
polybottom = y
|
||||
startvx = x
|
||||
startvy = y
|
||||
polyvx = x
|
||||
polyvy = y
|
||||
end
|
||||
export def addVertex(x, y)#0
|
||||
if y < polytop; polytop = y; fin
|
||||
if y > polybottom; polybottom = y; fin
|
||||
line(polyvx, polyvy, x, y)
|
||||
polyvx = x
|
||||
polyvy = y
|
||||
end
|
||||
export def patrnPoly(x, y)#0
|
||||
var width
|
||||
byte left
|
||||
|
||||
if y < polytop; polytop = y; fin
|
||||
if y > polybottom; polybottom = y; fin
|
||||
line(polyvx, polyvy, x, y)
|
||||
line(x, y, startvx, startvy)
|
||||
for y = polytop to polybottom
|
||||
left = leftedge->[y]
|
||||
width = rightedge->[y] - left + 1
|
||||
if width > 0
|
||||
dcgrPixMap(left, y, width, 1, \
|
||||
pattern + (left & 1 ?? SCR_WIDTH :: 0) \
|
||||
+ (y & 1 ?? (SCR_WIDTH/2) :: 0))
|
||||
fin
|
||||
next
|
||||
heaprelease(leftedge)
|
||||
end
|
||||
export def solidPoly(x, y)#0
|
||||
byte left, right
|
||||
|
||||
if y < polytop; polytop = y; fin
|
||||
if y > polybottom; polybottom = y; fin
|
||||
line(polyvx, polyvy, x, y)
|
||||
line(x, y, startvx, startvy)
|
||||
for y = polytop to polybottom
|
||||
left = leftedge->[y]
|
||||
right = rightedge->[y]
|
||||
if right >= left
|
||||
dcgrHLin(left, right, y)
|
||||
fin
|
||||
next
|
||||
heaprelease(leftedge)
|
||||
end
|
||||
//
|
||||
// Ellipse
|
||||
//
|
||||
export def solidEllip(xorg, yorg, width, height)#0
|
||||
var x, y, angle
|
||||
|
||||
for angle = 0 to 90 step 90 / height
|
||||
x = ((cos(angle) >> 8) * width) >> 8
|
||||
y = ((sin(angle) >> 8) * height) >> 8
|
||||
dcgrHLin(xorg - x, xorg + x, yorg + y)
|
||||
dcgrHLin(xorg - x, xorg + x, yorg - y)
|
||||
next
|
||||
end
|
||||
export def patrnEllip(xorg, yorg, width, height)#0
|
||||
var x, y, angle, left, len, scan
|
||||
|
||||
for angle = 0 to 90 step 90 / height
|
||||
x = ((cos(angle) >> 8) * width) >> 8
|
||||
y = ((sin(angle) >> 8) * height) >> 8
|
||||
left = xorg - x
|
||||
len = x * 2
|
||||
if len == 0; len = 1; fin
|
||||
scan = yorg + y
|
||||
dcgrPixMap(left, scan, len, 1, \
|
||||
pattern + (left & 1 ?? SCR_WIDTH :: 0) \
|
||||
+ (scan & 1 ?? (SCR_WIDTH/2) :: 0))
|
||||
scan = yorg - y
|
||||
dcgrPixMap(left, scan, len, 1, \
|
||||
pattern + (left & 1 ?? SCR_WIDTH :: 0) \
|
||||
+ (scan & 1 ?? (SCR_WIDTH/2) :: 0))
|
||||
next
|
||||
end
|
||||
export def frame(left, top, right, bottom, thickness)#0
|
||||
while thickness
|
||||
thickness--
|
||||
dcgrHLin(left + thickness, right - thickness, top + thickness)
|
||||
dcgrHLin(left + thickness, right - thickness, bottom - thickness)
|
||||
dcgrVLin(top + thickness, bottom - thickness, left + thickness)
|
||||
dcgrVLin(top + thickness, bottom - thickness, right - thickness)
|
||||
loop
|
||||
end
|
||||
|
353
src/dhgr.tk/demos/startrek/startrek.pla
Normal file
353
src/dhgr.tk/demos/startrek/startrek.pla
Normal file
@@ -0,0 +1,353 @@
|
||||
include "inc/cmdsys.plh"
|
||||
//include "inc/lines.plh"
|
||||
include "inc/vblank.plh"
|
||||
include "dhgr.tk/inc/dhgrlib.plh"
|
||||
include "dhgr.tk/inc/dhgrutils.plh"
|
||||
import fillshape
|
||||
//
|
||||
// Dither matrices
|
||||
//
|
||||
const DITHER0 = $00
|
||||
const DITHER25 = $04
|
||||
const DITHER50 = $06
|
||||
const DITHER75 = $07
|
||||
const DITHER100 = $0F
|
||||
predef setPattern(clr1, clr2, dither)#0
|
||||
predef patrnRect(left, top, right, bottom)#0
|
||||
predef solidRect(left, top, right, bottom)#0
|
||||
predef startPoly(x, y)#0
|
||||
predef addVertex(x, y)#0
|
||||
predef patrnPoly(x, y)#0
|
||||
predef solidPoly(x, y)#0
|
||||
predef solidEllip(xorg, yorg, width, height)#0
|
||||
predef patrnEllip(xorg, yorg, width, height)#0
|
||||
predef frame(left, top, right, bottom, thickness)#0
|
||||
end
|
||||
|
||||
sysflags resxtxt1|reshgr1|resxhgr1
|
||||
//
|
||||
// ViewScreen coordinates
|
||||
//
|
||||
const VIEW_LEFT7 = 3
|
||||
const VIEW_RIGHT7 = 17
|
||||
const VIEW_WIDTH7 = VIEW_RIGHT7 - VIEW_LEFT7
|
||||
const VIEW_LEFT = VIEW_LEFT7 * 7 // 21
|
||||
const VIEW_RIGHT = VIEW_RIGHT7 * 7 // 119
|
||||
const VIEW_WIDTH = VIEW_RIGHT - VIEW_LEFT
|
||||
const VIEW_TOP = 24
|
||||
const VIEW_BOTTOM = 122
|
||||
const VIEW_HEIGHT = VIEW_BOTTOM - VIEW_TOP
|
||||
const VIEW_ORGX = (VIEW_LEFT+VIEW_RIGHT)/2
|
||||
const VIEW_ORGY = (VIEW_TOP+VIEW_BOTTOM)/2
|
||||
//
|
||||
// Enterprise sprites
|
||||
//
|
||||
struc t_sprite
|
||||
var spr_xorg
|
||||
var spr_yorg
|
||||
var spr_width
|
||||
var spr_height
|
||||
var spr_pixmap
|
||||
var spr_bl7
|
||||
end
|
||||
res[t_sprite * 8] ncc1701
|
||||
char[12] sprFile = "ENT.UP.SPR"
|
||||
char[12] = "ENT.UR.SPR"
|
||||
char[12] = "ENT.RT.SPR"
|
||||
char[12] = "ENT.DR.SPR"
|
||||
char[12] = "ENT.DN.SPR"
|
||||
char[12] = "ENT.DL.SPR"
|
||||
char[12] = "ENT.LT.SPR"
|
||||
char[12] = "ENT.UL.SPR"
|
||||
const ENT_W7 = 5
|
||||
const ENT_H = 43
|
||||
const ENT_SZ = ENT_W7*4*ENT_H
|
||||
//
|
||||
// Random seed
|
||||
//
|
||||
var rndseed = $A64D
|
||||
def random#1
|
||||
rndseed = (rndseed << 8) ^ ((rndseed & $7FFF) >> 7) + $62B3
|
||||
return rndseed
|
||||
end
|
||||
//
|
||||
// Draw components
|
||||
//
|
||||
def drawSurround#0
|
||||
//
|
||||
// Viewscreen surround
|
||||
//
|
||||
dcgrColor(CLR_GREY)
|
||||
dhgrClearBl7(0, 0, SCR_WIDTH7, VIEW_TOP)
|
||||
dhgrClearBl7(0, VIEW_BOTTOM, SCR_WIDTH7, VIEW_TOP)
|
||||
dhgrClearBl7(0, VIEW_TOP, VIEW_LEFT7, VIEW_HEIGHT)
|
||||
dhgrClearBl7(VIEW_RIGHT7, VIEW_TOP, VIEW_LEFT7, VIEW_HEIGHT)
|
||||
setPattern(CLR_BLACK, CLR_GREY, DITHER50)
|
||||
patrnRect(0, VIEW_BOTTOM+VIEW_TOP, SCR_WIDTH-1, SCR_HEIGHT-1)
|
||||
//
|
||||
// Above viewscreen ceiling
|
||||
//
|
||||
setPattern(CLR_BLACK, CLR_GREY, DITHER50)
|
||||
startPoly(0, 0)
|
||||
addVertex(SCR_WIDTH-1, 0)
|
||||
addVertex(VIEW_RIGHT+3-1, VIEW_TOP-6)
|
||||
patrnPoly(VIEW_LEFT-3, VIEW_TOP-6)
|
||||
//
|
||||
// Below viewscreen bump-out
|
||||
//
|
||||
setPattern(CLR_GREY, CLR_WHITE, DITHER50)
|
||||
startPoly(VIEW_LEFT-3, VIEW_BOTTOM+5)
|
||||
addVertex(VIEW_RIGHT+3-1, VIEW_BOTTOM+5)
|
||||
addVertex(SCR_WIDTH-1, VIEW_BOTTOM+VIEW_TOP-1)
|
||||
patrnPoly(0, VIEW_BOTTOM+VIEW_TOP-1)
|
||||
//
|
||||
// Viewscreen frame
|
||||
//
|
||||
dcgrColor(CLR_DRKBLUE)
|
||||
frame(VIEW_LEFT-3, VIEW_TOP-3, VIEW_RIGHT+3-1, VIEW_BOTTOM+3-1, 3)
|
||||
dcgrColor(CLR_MEDBLUE)
|
||||
frame(VIEW_LEFT-2, VIEW_TOP-2, VIEW_RIGHT+2-1, VIEW_BOTTOM+2-1, 1)
|
||||
end
|
||||
def drawRails#0
|
||||
dcgrColor(CLR_ORANGE)
|
||||
dhgrClearBl7(0, 132, 40/7, 1)
|
||||
dhgrClearBl7(107/7, 132, 40/7, 1)
|
||||
dcgrColor(CLR_MAGENTA)
|
||||
dhgrClearBl7(0, 133, 40/7, 7)
|
||||
dhgrClearBl7(107/7, 133, 40/7, 7)
|
||||
dcgrColor(CLR_BLACK)
|
||||
solidRect( 20, 140, 24, 191)
|
||||
solidRect(115, 140, 119, 191)
|
||||
end
|
||||
def drawAlerts#0
|
||||
dcgrColor(CLR_ORANGE)
|
||||
frame( 1*7-2, 40-2, 2*7+2-1, 80+2-1, 2)
|
||||
frame(18*7-2, 40-2, 19*7+2-1, 80+2-1, 2)
|
||||
dcgrColor(CLR_BLACK)
|
||||
dhgrClearBl7( 1, 40, 1, 40)
|
||||
dhgrClearBl7(18, 40, 1, 40)
|
||||
end
|
||||
def drawConsoles#0
|
||||
dcgrColor(CLR_MAGENTA)
|
||||
startPoly(70-30, 160)
|
||||
addVertex(70-30, SCR_HEIGHT-1)
|
||||
solidPoly(70-40, SCR_HEIGHT-1)
|
||||
startPoly(70+30-1, 160)
|
||||
addVertex(70+30-1, SCR_HEIGHT-1)
|
||||
solidPoly(70+40-1, SCR_HEIGHT-1)
|
||||
setPattern(CLR_BLACK, CLR_BROWN, DITHER50)
|
||||
startPoly(0, 160)
|
||||
addVertex(70-30, 160)
|
||||
addVertex(70-40, SCR_HEIGHT-1)
|
||||
patrnPoly(0, SCR_HEIGHT-1)
|
||||
startPoly(70+30-1, 160)
|
||||
addVertex(SCR_WIDTH-1, 160)
|
||||
addVertex(SCR_WIDTH-1, SCR_HEIGHT-1)
|
||||
patrnPoly(70+40-1, SCR_HEIGHT-1)
|
||||
dcgrColor(CLR_BLACK)
|
||||
startPoly(0, 170)
|
||||
addVertex(70-40, 170)
|
||||
addVertex(70-51, SCR_HEIGHT-1)
|
||||
solidPoly(0, SCR_HEIGHT-1)
|
||||
startPoly(70+40-1, 170)
|
||||
addVertex(SCR_WIDTH-1, 170)
|
||||
addVertex(SCR_WIDTH-1, SCR_HEIGHT-1)
|
||||
solidPoly(70+51-1, SCR_HEIGHT-1)
|
||||
end
|
||||
def drawNavigation#0
|
||||
dcgrColor(CLR_WHITE)
|
||||
startPoly(70-20, 150)
|
||||
addVertex(70+20-1, 150)
|
||||
addVertex(70+30-1, SCR_HEIGHT-1)
|
||||
solidPoly(70-30, SCR_HEIGHT-1)
|
||||
setPattern(CLR_GREY, CLR_BROWN, DITHER50)
|
||||
patrnEllip(70, 170, 40, 35)
|
||||
end
|
||||
//
|
||||
// Read Enterprise sprites
|
||||
//
|
||||
def readEnterprise#0
|
||||
var xorg, yorg, width, height, pixptr, t_ptr, f_ptr
|
||||
byte i
|
||||
|
||||
t_ptr = @ncc1701
|
||||
f_ptr = @sprFile
|
||||
for i = 0 to 7
|
||||
xorg, yorg, width, height, pixptr = spriteRead(f_ptr)
|
||||
t_ptr=>spr_xorg = xorg
|
||||
t_ptr=>spr_yorg = yorg
|
||||
t_ptr=>spr_width = width
|
||||
t_ptr=>spr_height = height
|
||||
t_ptr=>spr_pixmap = pixptr
|
||||
t_ptr=>spr_bl7 = heapalloc(ENT_SZ)
|
||||
dhgrSurfMem(OP_SRC, ENT_H, t_ptr=>spr_bl7, ENT_W7*4)
|
||||
dcgrColor(CLR_BLACK)
|
||||
dhgrClearBl7(0, 0, ENT_W7, ENT_H)
|
||||
dcgrPixmap(ENT_W7*7/2 - xorg,ENT_H/2 - yorg, width, height, pixptr)
|
||||
t_ptr = t_ptr + t_sprite
|
||||
f_ptr = f_ptr + 12
|
||||
next
|
||||
end
|
||||
//
|
||||
// Animate stuff
|
||||
//
|
||||
def keypressed#1
|
||||
return ^$C000 & $80
|
||||
end
|
||||
def idleViewPlot(x)#0
|
||||
x = (x&63)+70-32
|
||||
dcgrHLin(x - 1, x + 1, VIEW_BOTTOM+3)
|
||||
dcgrHlin(x - 1, x + 1, VIEW_BOTTOM+4)
|
||||
end
|
||||
def newStar#3
|
||||
return 15 - (random & 30), 15 - (random & 30), random & 15
|
||||
end
|
||||
def idleStars#0
|
||||
byte xpos, star, nstars
|
||||
var starx, stary, starincx, starincy, starclr
|
||||
var x, y, incx, incy
|
||||
|
||||
waitVBL; nstars = waitVBL / 50
|
||||
starx = heapalloc(nstars*2)
|
||||
stary = heapalloc(nstars*2)
|
||||
starincx = heapalloc(nstars*2)
|
||||
starincy = heapalloc(nstars*2)
|
||||
starclr = heapalloc(nstars)
|
||||
nstars--
|
||||
for star = 0 to nstars
|
||||
repeat
|
||||
incx, incy, starclr->[star] = newstar
|
||||
until incx <> 0 and incy <> 0
|
||||
if starclr->[star] == 0; starclr->[star] = 15; fin
|
||||
starx=>[star] = incx * (VIEW_WIDTH-1)/2
|
||||
stary=>[star] = incy * (VIEW_HEIGHT-1)/2
|
||||
starincx=>[star] = incx
|
||||
starincy=>[star] = incy
|
||||
next
|
||||
xpos = 8
|
||||
star = 0
|
||||
while not keypressed
|
||||
dcgrColor(CLR_WHITE)
|
||||
idleViewPlot(xpos)
|
||||
dcgrColor(CLR_YELLOW)
|
||||
idleViewPlot(xpos-4)
|
||||
dcgrColor(CLR_ORANGE)
|
||||
idleViewPlot(xpos-8)
|
||||
dcgrColor(CLR_GREY)
|
||||
idleViewPlot(xpos-12)
|
||||
xpos = xpos + 4
|
||||
for star = 0 to nstars
|
||||
x = starx=>[star]
|
||||
y = stary=>[star]
|
||||
incx = x + starincx=>[star]
|
||||
incy = y + starincy=>[star]
|
||||
if incx > (VIEW_WIDTH-1)*8 or incx < -VIEW_WIDTH*8 \
|
||||
or incy > (VIEW_HEIGHT-1)*8 or incy < -VIEW_HEIGHT*8
|
||||
repeat
|
||||
incx, incy, starclr->[star] = newStar
|
||||
until incx <> 0 and incy <> 0
|
||||
if starclr->[star] == 0; starclr->[star] = 15; fin
|
||||
starx=>[star] = incx << 5
|
||||
stary=>[star] = incy << 5
|
||||
starincx=>[star] = incx
|
||||
starincy=>[star] = incy
|
||||
else
|
||||
starx=>[star] = incx
|
||||
stary=>[star] = incy
|
||||
incx = starincx=>[star]
|
||||
incy = starincy=>[star]
|
||||
starincx=>[star] = incx + ((incx > 0 ?? incx + 7 :: incx - 7) >> 3)
|
||||
starincy=>[star] = incy + ((incy > 0 ?? incy + 7 :: incy - 7) >> 3)
|
||||
fin
|
||||
dcgrColor(CLR_BLACK)
|
||||
dcgrPixel((x >> 4) + VIEW_ORGX, (y >> 4) + VIEW_ORGY)
|
||||
dcgrColor(starclr->[star])
|
||||
dcgrPixel((starx=>[star] >> 4) + VIEW_ORGX, (stary=>[star] >> 4) + VIEW_ORGY)
|
||||
next
|
||||
loop
|
||||
getc
|
||||
heaprelease(starx)
|
||||
end
|
||||
def idleSpin#0
|
||||
var viewbuf, viewspan
|
||||
var i, k, oi, oj
|
||||
byte xpos
|
||||
|
||||
//
|
||||
// Use back buffer
|
||||
//
|
||||
viewbuf, viewspan = dhgrAllocBl7Mem(VIEW_WIDTH, VIEW_HEIGHT)
|
||||
i = @ncc1701
|
||||
k = 0
|
||||
xpos = 0
|
||||
while not keypressed
|
||||
//
|
||||
// Rotate Enterprise
|
||||
//
|
||||
dhgrSurfMem(OP_SRC, VIEW_HEIGHT, viewbuf, viewspan)
|
||||
dcgrColor(CLR_DRKBLUE)
|
||||
dhgrClearBl7(0, 0, VIEW_WIDTH7, VIEW_HEIGHT)
|
||||
dcgrColor(CLR_GREEN)
|
||||
for oi = (xpos/4)&31 to VIEW_WIDTH-1 step 32
|
||||
dcgrVLin(0, VIEW_HEIGHT-1, oi)
|
||||
next
|
||||
for oi = (xpos/4)&63 to VIEW_HEIGHT-1 step 64
|
||||
dcgrHLin(0, VIEW_WIDTH-1, oi)
|
||||
next
|
||||
dhgrOp(OP_OR)
|
||||
dhgrMemBl7((VIEW_WIDTH7 - ENT_W7 + 1)/2, (VIEW_HEIGHT-ENT_H + 1)/2, \
|
||||
ENT_W7, ENT_H, \
|
||||
i=>spr_bl7, ENT_W7*4)
|
||||
dhgrSurfScr(OP_SRC)
|
||||
//waitVBL
|
||||
dhgrMemBl7(VIEW_LEFT7, VIEW_TOP, \
|
||||
VIEW_WIDTH7, VIEW_HEIGHT, \
|
||||
viewbuf, viewspan)
|
||||
i = i + t_sprite
|
||||
k++
|
||||
if k > 7
|
||||
k = 0
|
||||
i = @ncc1701
|
||||
fin
|
||||
//
|
||||
// Animate useless view screen lights
|
||||
//
|
||||
dcgrColor(CLR_WHITE)
|
||||
idleViewPlot(xpos)
|
||||
dcgrColor(CLR_YELLOW)
|
||||
idleViewPlot(xpos-4)
|
||||
dcgrColor(CLR_ORANGE)
|
||||
idleViewPlot(xpos-8)
|
||||
dcgrColor(CLR_GREY)
|
||||
idleViewPlot(xpos-12)
|
||||
xpos = xpos + 4
|
||||
loop
|
||||
heaprelease(viewbuf)
|
||||
getc
|
||||
end
|
||||
//
|
||||
// Read sprites
|
||||
//
|
||||
readEnterprise
|
||||
//
|
||||
// Initialize
|
||||
//
|
||||
dhgrMode(DHGR_COLOR_MODE)
|
||||
//
|
||||
// Draw bridge
|
||||
//
|
||||
drawSurround
|
||||
drawRails
|
||||
drawAlerts
|
||||
drawConsoles
|
||||
drawNavigation
|
||||
//
|
||||
// Animate stars waiting for keypress
|
||||
//
|
||||
idleStars
|
||||
idleSpin
|
||||
//
|
||||
// All done
|
||||
//
|
||||
dhgrMode(DHGR_TEXT_MODE)
|
||||
done
|
54
src/dhgr.tk/inc/dhgrlib.plh
Normal file
54
src/dhgr.tk/inc/dhgrlib.plh
Normal file
@@ -0,0 +1,54 @@
|
||||
import dhgrlib
|
||||
const DST_SCREEN = 0
|
||||
const DST_MEMORY = 1
|
||||
const SCR_WIDTH7 = 20
|
||||
const SCR_WIDTH = 140
|
||||
const SCR_HEIGHT = 192
|
||||
const OP_SRC = 0
|
||||
const OP_XOR = 1
|
||||
const OP_AND = 2
|
||||
const OP_OR = 3
|
||||
const CLR_BLACK = 0
|
||||
const CLR_MAGENTA = 1
|
||||
const CLR_DRKBLUE = 2
|
||||
const CLR_PURPLE = 3
|
||||
const CLR_DRKGREEN = 4
|
||||
const CLR_GREY1 = 5
|
||||
const CLR_XPARENT = 5
|
||||
const CLR_MEDBLUE = 6
|
||||
const CLR_LTBLUE = 7
|
||||
const CLR_BROWN = 8
|
||||
const CLR_ORANGE = 9
|
||||
const CLR_GREY2 = 10
|
||||
const CLR_GREY = 10
|
||||
const CLR_PINK = 11
|
||||
const CLR_GREEN = 12
|
||||
const CLR_YELLOW = 13
|
||||
const CLR_AQUA = 14
|
||||
const CLR_WHITE = 15
|
||||
|
||||
const DHGR_MONO_MODE = 2
|
||||
const DHGR_COLOR_MODE = 0
|
||||
const DHGR_MIXED_MODE = 1
|
||||
const DHGR_TEXT_MODE = -1
|
||||
|
||||
predef dcgrColor(c)#0
|
||||
predef dcgrPixel(x, y)#0
|
||||
predef dcgrGetPixel(x, y)#1
|
||||
predef dcgrHLin(x1, x2, y)#0
|
||||
predef dcgrVLin(y1, y2, x)#0
|
||||
predef dcgrBitMap(x, y, bitw, bith, bitptr)#0
|
||||
predef dcgrPixMap(x, y, pixw, pixh, pixptr)#0
|
||||
predef dcgrRleMap(x, y, pixw, pixh, pixptr)#0
|
||||
predef dhgrScrBl7(x7, y, w7, h)#0
|
||||
predef dhgrMemBl7(x7, y, w7, h, memptr, memspan)#0
|
||||
predef dhgrClearBl7(x7, y, w7, h)#0
|
||||
predef dhgrTiles(x7, y8, strptr, strlen, tileset)#0
|
||||
predef dhgrMemBl7Tile(x7, y, memptr, memspan, tileptr)#0
|
||||
predef dhgrSet(dhx, y)#0
|
||||
predef dhgrUnset(dhx, y)#0
|
||||
predef dhgrOp(op)#0
|
||||
predef dhgrSurfScr(op)#0
|
||||
predef dhgrSurfMem(op, memh, memptr, memspan)#0
|
||||
predef dhgrMode(mode)#1
|
||||
end
|
32
src/dhgr.tk/inc/dhgrutils.plh
Normal file
32
src/dhgr.tk/inc/dhgrutils.plh
Normal file
@@ -0,0 +1,32 @@
|
||||
import dhgrutils
|
||||
//
|
||||
// Font type bits
|
||||
//
|
||||
const FONT_MONO = $00
|
||||
const FONT_PROP = $80
|
||||
const FONT_AA = $40
|
||||
//
|
||||
// Default fonts
|
||||
//
|
||||
const FONT_DEFAULT = 0
|
||||
const FONT_DEF_THIN = 1
|
||||
const FONT_DEF_SLIM = 2
|
||||
//
|
||||
// Exported functions
|
||||
//
|
||||
predef dhgrAllocBl7Mem(w, h)#2
|
||||
predef dcgrStr(x, y, strptr)#2
|
||||
predef dcgrStrExtents(strptr)#2
|
||||
predef dcgrBoldStr(clr, x, y, strptr)#2
|
||||
predef dcgrFont(font)#1
|
||||
predef fontRead(filename)#1
|
||||
predef fontGlyphDim(ch)#2
|
||||
predef fontType#1
|
||||
predef dcgrRect(x, y, w, h)#0
|
||||
predef dcgrGetPixMap(x, y, w, h)#1
|
||||
predef dcgrEncPixMap(w, h, pixmap, rlemap)#1
|
||||
predef spriteRead(filestr)#5
|
||||
predef spriteWrite(filestr, xorg, yorg, width, height, sprptr)#1
|
||||
predef screenRead(filestr)#1
|
||||
predef screenWrite(filestr)#1
|
||||
end
|
2687
src/dhgr.tk/libs/dhgrlib.pla
Normal file
2687
src/dhgr.tk/libs/dhgrlib.pla
Normal file
File diff suppressed because it is too large
Load Diff
434
src/dhgr.tk/libs/dhgrutils.pla
Normal file
434
src/dhgr.tk/libs/dhgrutils.pla
Normal file
@@ -0,0 +1,434 @@
|
||||
include "inc/cmdsys.plh"
|
||||
include "inc/fileio.plh"
|
||||
include "dhgr.tk/inc/dhgrlib.plh"
|
||||
include "dhgr.tk/inc/dhgrutils.plh"
|
||||
|
||||
const page1m = $C054
|
||||
const page1x = $C055
|
||||
//
|
||||
// Font header
|
||||
//
|
||||
struc t_font
|
||||
byte[] fnt_typelen
|
||||
char fnt_name[16]
|
||||
byte fnt_first
|
||||
byte fnt_last
|
||||
byte fnt_width
|
||||
byte fnt_height
|
||||
var fnt_glyptrs[]
|
||||
end
|
||||
//
|
||||
// Variable pitch glyphs
|
||||
//
|
||||
struc t_glyph
|
||||
var gly_left
|
||||
var gly_top
|
||||
byte gly_width
|
||||
byte gly_height
|
||||
byte gly_adv
|
||||
byte gly_strike[]
|
||||
end
|
||||
//
|
||||
// Current and default font pointers
|
||||
//
|
||||
var fontPtr, fontDefault, fontDefThin, fontDefSlim
|
||||
//
|
||||
// Function pointers
|
||||
//
|
||||
export asm dcgrStr(x, y, strptr)#2
|
||||
JMP $2000
|
||||
end
|
||||
//
|
||||
// Utility functions
|
||||
//
|
||||
export def dhgrAllocBl7Mem(w, h)#2
|
||||
word memblk, span
|
||||
|
||||
span = (w+13)/14 << 3
|
||||
memblk = heapalloc(span * h)
|
||||
return memblk, span
|
||||
end
|
||||
def bitMonoGlyphStr(x, y, strptr)#2
|
||||
byte first, last, width, height, size, i, ch
|
||||
var strikes
|
||||
|
||||
first = fontPtr->fnt_first
|
||||
last = fontPtr->fnt_last
|
||||
width = fontPtr->fnt_width
|
||||
height = fontPtr->fnt_height
|
||||
strikes = fontPtr + fnt_glyptrs
|
||||
size = (width + 7) / 8 * height
|
||||
for i = 1 to ^strptr
|
||||
ch = ^(strptr + i)
|
||||
if ch >= first and ch <= last
|
||||
dcgrBitmap(x, y - height, width, height, \
|
||||
strikes + (^(strptr + i) - first) * size)
|
||||
x = x + width
|
||||
fin
|
||||
next
|
||||
return x, y
|
||||
end
|
||||
def pixPropGlyphStr(x, y, strptr)#2
|
||||
var glyptrs, glyph
|
||||
byte first, last, i, ch
|
||||
|
||||
first = fontPtr->fnt_first
|
||||
last = fontPtr->fnt_last
|
||||
glyptrs = fontPtr + fnt_glyptrs
|
||||
x = x * 4
|
||||
for i = 1 to ^strptr
|
||||
ch = ^(strptr + i)
|
||||
if ch >= first and ch <= last
|
||||
glyph = glyptrs=>[ch - first]
|
||||
dcgrPixmap((x + glyph=>gly_left) / 4, \
|
||||
y + glyph=>gly_top, \
|
||||
glyph->gly_width, \
|
||||
glyph->gly_height, \
|
||||
glyph + gly_strike)
|
||||
x = x + glyph->gly_adv
|
||||
fin
|
||||
next
|
||||
return x / 4, y
|
||||
end
|
||||
def bitPropGlyphStr(x, y, strptr)#2
|
||||
var glyptrs, glyph
|
||||
byte first, last, i, ch
|
||||
|
||||
first = fontPtr->fnt_first
|
||||
last = fontPtr->fnt_last
|
||||
glyptrs = fontPtr + fnt_glyptrs
|
||||
for i = 1 to ^strptr
|
||||
ch = ^(strptr + i)
|
||||
if ch >= first and ch <= last
|
||||
glyph = glyptrs=>[ch - first]
|
||||
dcgrBitmap(x + glyph=>gly_left, \
|
||||
y + glyph=>gly_top, \
|
||||
glyph->gly_width, \
|
||||
glyph->gly_height, \
|
||||
glyph + gly_strike)
|
||||
x = x + glyph->gly_adv
|
||||
fin
|
||||
next
|
||||
return x, y
|
||||
end
|
||||
export def dcgrStrExtents(strptr)#2
|
||||
var glyptrs, xext, yext
|
||||
byte first, last, width, i, ch
|
||||
|
||||
first = fontPtr->fnt_first
|
||||
last = fontPtr->fnt_last
|
||||
if ^fontPtr & FONT_PROP
|
||||
glyptrs = fontPtr + fnt_glyptrs
|
||||
xext = -glyptrs=>[^(strptr + 1) - first]=>gly_left
|
||||
if ^strptr > 1
|
||||
for i = 1 to ^strptr-1
|
||||
ch = ^(strptr + i)
|
||||
if ch >= first and ch <= last
|
||||
xext = xext + glyptrs=>[ch - first]->gly_adv
|
||||
fin
|
||||
next
|
||||
fin
|
||||
xext = xext + glyptrs=>[^(strptr + ^strptr) - first]->gly_width
|
||||
if ^fontPtr & FONT_AA
|
||||
xext = xext / 4
|
||||
fin
|
||||
else
|
||||
xext = fontPtr->fnt_width * ^strptr
|
||||
fin
|
||||
return xext, fontPtr->fnt_height
|
||||
end
|
||||
export def dcgrBoldStr(clr, x, y, strptr)#2
|
||||
byte h, v
|
||||
|
||||
for v = y - 1 to y + 1
|
||||
for h = x - 1 to x + 1
|
||||
dcgrStr(h, v, strptr)
|
||||
next
|
||||
next
|
||||
dcgrColor(clr)
|
||||
return dcgrStr(x, y, strptr)
|
||||
end
|
||||
export def fontRead(filename)#1
|
||||
var glyph, strksize, left, top
|
||||
byte refnum, num, i, width, height, adv
|
||||
byte roundup, pixbyte
|
||||
var font_header, gly_ptr
|
||||
byte[64] sysfont
|
||||
|
||||
font_header = NULL
|
||||
if filename and ^filename
|
||||
refnum = fileio:open(filename)
|
||||
if not refnum // Look for system font
|
||||
strcpy(@sysfont, cmdsys:syspath)
|
||||
strcat(@sysfont, "fonts/")
|
||||
strcat(@sysfont, filename)
|
||||
refnum = fileio:open(@sysfont)
|
||||
if not refnum
|
||||
strcpy(@sysfont, cmdsys:syspath)
|
||||
strcat(@sysfont, "fonts/apple2.fon")
|
||||
refnum = fileio:open(@sysfont)
|
||||
fin
|
||||
fin
|
||||
if refnum
|
||||
font_header = heapalloc(t_font)
|
||||
fileio:read(refnum, font_header, t_font)
|
||||
num = font_header->fnt_last - font_header->fnt_first
|
||||
if font_header->fnt_typelen & FONT_PROP
|
||||
gly_ptr = heapalloc(num * 2) // Allocate glyph ptrs right after
|
||||
if font_header->fnt_typelen & FONT_AA
|
||||
roundup = 1
|
||||
pixbyte = 2
|
||||
else
|
||||
roundup = 7
|
||||
pixbyte = 8
|
||||
fin
|
||||
for i = 1 to num
|
||||
fileio:read(refnum, @left, 1); left = sext(left)
|
||||
fileio:read(refnum, @top, 1); top = sext(top)
|
||||
fileio:read(refnum, @width, 1)
|
||||
fileio:read(refnum, @height, 1)
|
||||
fileio:read(refnum, @adv, 1)
|
||||
strksize = (width + roundup) / pixbyte * height
|
||||
if strksize
|
||||
*gly_ptr = heapalloc(strksize + t_glyph)
|
||||
glyph = *gly_ptr
|
||||
if glyph and fileio:read(refnum, glyph + gly_strike, strksize) == strksize
|
||||
glyph=>gly_left = left
|
||||
glyph=>gly_top = top
|
||||
glyph->gly_width = width
|
||||
glyph->gly_height = height
|
||||
glyph->gly_adv = adv
|
||||
else
|
||||
heaprelease(font_header)
|
||||
font_header = NULL
|
||||
break
|
||||
fin
|
||||
else
|
||||
*gly_ptr = NULL
|
||||
fin
|
||||
gly_ptr = gly_ptr + 2
|
||||
next
|
||||
else // FONT_MONO
|
||||
strksize = (font_header->fnt_width + 7) / 8 * font_header->fnt_height * num
|
||||
glyph = heapalloc(strksize) // Allocate glyphs right after
|
||||
if not glyph or fileio:read(refnum, glyph, strksize) <> strksize
|
||||
heaprelease(font_header)
|
||||
font_header = NULL
|
||||
fin
|
||||
fin
|
||||
fileio:close(refnum)
|
||||
fin
|
||||
fin
|
||||
return font_header
|
||||
end
|
||||
export def dcgrFont(font)#1
|
||||
var rows, pWide, pThin, prevFont
|
||||
|
||||
if font == FONT_DEFAULT // Will also capture NULL font pointers
|
||||
if not fontDefault
|
||||
fontDefault = fontRead("apple2.fon")
|
||||
if not fontDefault
|
||||
return fontPtr
|
||||
fin
|
||||
fin
|
||||
font = fontDefault
|
||||
elsif font == FONT_DEF_THIN // Thin version of Apple2 font
|
||||
if not fontDefThin
|
||||
fontDefThin = fontRead("apple2thin.fon")
|
||||
if not fontDefThin
|
||||
return fontPtr
|
||||
fin
|
||||
fin
|
||||
font = fontDefThin
|
||||
elsif font == FONT_DEF_SLIM // Proportional version of thin font
|
||||
if not fontDefSlim
|
||||
fontDefSlim = fontRead("a2slim8.fon")
|
||||
if not fontDefSlim
|
||||
return fontPtr
|
||||
fin
|
||||
fin
|
||||
font = fontDefSlim
|
||||
fin
|
||||
prevFont = fontPtr
|
||||
fontPtr = font
|
||||
if fontPtr->fnt_typelen & FONT_PROP
|
||||
if fontPtr->fnt_typelen & FONT_AA
|
||||
dcgrStr:1 = @pixPropGlyphStr
|
||||
else
|
||||
dcgrStr:1 = @bitPropGlyphStr
|
||||
fin
|
||||
else // FONT_MONO
|
||||
dcgrStr:1 = @bitMonoGlyphStr
|
||||
fin
|
||||
return prevFont
|
||||
end
|
||||
def dcgrLoadDefFont(x, y, strptr)#2 // Default if no font selected
|
||||
dcgrFont(FONT_DEFAULT)
|
||||
if fontDefault // Ensure it got loaded
|
||||
return dcgrStr(x, y, strptr)
|
||||
fin
|
||||
return 0, 0
|
||||
end
|
||||
export def fontGlyphDim(ch)#2
|
||||
byte width, height, first
|
||||
|
||||
width = fontPtr->fnt_width
|
||||
height = fontPtr->fnt_height
|
||||
if fontPtr->fnt_typelen & FONT_PROP
|
||||
first = fontPtr->fnt_first
|
||||
if ch >= first and ch <= fontPtr->fnt_last
|
||||
width = fontPtr=>fnt_glyptrs=>[ch - first]->gly_adv / 4
|
||||
fin
|
||||
fin
|
||||
return width, height
|
||||
end
|
||||
export def fontType#1
|
||||
return ^fontPtr & $F0
|
||||
end
|
||||
export def dcgrRect(x, y, w, h)#0
|
||||
byte x2, y2, v
|
||||
|
||||
x2 = x + w - 1
|
||||
y2 = y + h - 1
|
||||
for v = y to y2
|
||||
dcgrHLin(x, x2, v)
|
||||
next
|
||||
end
|
||||
export def dcgrGetPixMap(x, y, w, h)#1
|
||||
var pixmap, pixptr
|
||||
byte i, j
|
||||
|
||||
pixmap = heapalloc((w + 1)/2 * h)
|
||||
pixptr = pixmap
|
||||
w--; h--
|
||||
for j = 0 to h
|
||||
for i = 0 to w step 2
|
||||
^pixptr = dcgrGetPixel(i+x,j+y)|(dcgrGetPixel(i+x+1,j+y)<<4)
|
||||
pixptr++
|
||||
next
|
||||
next
|
||||
return pixmap
|
||||
end
|
||||
export def dcgrEncPixMap(w, h, pixmap, rlemap)#1
|
||||
var rleptr
|
||||
byte i, j, run, pixrun
|
||||
|
||||
rleptr = rlemap
|
||||
w--; h--
|
||||
for j = 0 to h
|
||||
run = 0
|
||||
for i = 0 to w step 2
|
||||
if run and ^pixmap == pixrun
|
||||
run++
|
||||
else
|
||||
if run
|
||||
*rleptr = run*2 | (pixrun << 8)
|
||||
//puth(*rleptr); putc(',')
|
||||
rleptr = rleptr + 2
|
||||
fin
|
||||
run = 1
|
||||
pixrun = ^pixmap
|
||||
fin
|
||||
pixmap++
|
||||
next
|
||||
*rleptr = run*2 | (pixrun << 8)
|
||||
//puth(*rleptr); putln
|
||||
rleptr = rleptr + 2
|
||||
next
|
||||
return rleptr - rlemap
|
||||
end
|
||||
export def spriteRead(filestr)#5
|
||||
var sprptr, sprsize, xorg, yorg
|
||||
byte refnum, width, height
|
||||
|
||||
width = 0
|
||||
height = 0
|
||||
sprptr = 0
|
||||
refnum = fileio:open(filestr)
|
||||
if refnum
|
||||
fileio:read(refnum, @xorg, 1); xorg = sext(xorg)
|
||||
fileio:read(refnum, @yorg, 1); yorg = sext(yorg)
|
||||
fileio:read(refnum, @width, 1)
|
||||
fileio:read(refnum, @height, 1)
|
||||
if width <= 40 and height <= 48
|
||||
sprsize = (width + 1) / 2 * height
|
||||
sprptr = heapalloc(sprsize)
|
||||
if sprptr
|
||||
if fileio:read(refnum, sprptr, sprsize) <> sprsize
|
||||
heaprelease(sprptr)
|
||||
sprptr = NULL
|
||||
fin
|
||||
fin
|
||||
fin
|
||||
fileio:close(refnum)
|
||||
fin
|
||||
return xorg, yorg, width, height, sprptr
|
||||
end
|
||||
export def spriteWrite(filestr, xorg, yorg, width, height, sprptr)#1
|
||||
var sprsize
|
||||
byte refnum, i, result
|
||||
|
||||
sprsize = (width + 1) / 2 * height
|
||||
fileio:destroy(filestr)
|
||||
result = fileio:create(filestr, $06, $0000)
|
||||
if result == FILE_ERR_OK
|
||||
refnum = fileio:open(filestr)
|
||||
if refnum
|
||||
fileio:write(refnum, @xorg, 1)
|
||||
fileio:write(refnum, @yorg, 1)
|
||||
fileio:write(refnum, @width, 1)
|
||||
fileio:write(refnum, @height, 1)
|
||||
sprsize = (width + 1) / 2 * height
|
||||
fileio:write(refnum, sprptr, sprsize)
|
||||
result = perr
|
||||
fileio:close(refnum)
|
||||
else
|
||||
result = perr
|
||||
fin
|
||||
fin
|
||||
return result
|
||||
end
|
||||
export def screenRead(filestr)#1
|
||||
byte refnum
|
||||
|
||||
refnum = fileio:open(filestr)
|
||||
if refnum
|
||||
^page1x // Read AUX bytes
|
||||
fileio:read(refnum, $2000, $2000)
|
||||
^page1m // Read MAIN bytes
|
||||
fileio:read(refnum, $2000, $2000)
|
||||
fileio:close(refnum)
|
||||
fin
|
||||
return perr
|
||||
end
|
||||
export def screenWrite(filestr)#1
|
||||
byte refnum, result
|
||||
|
||||
fileio:destroy(filestr)
|
||||
result = fileio:create(filestr, $06, $2000)
|
||||
if result == FILE_ERR_OK
|
||||
refnum = fileio:open(filestr)
|
||||
if refnum
|
||||
^page1x // Write AUX bytes
|
||||
if fileio:write(refnum, $2000, $2000) == $2000
|
||||
^page1m // Write MAIN bytes
|
||||
fileio:write(refnum, $2000, $2000)
|
||||
fin
|
||||
result = perr
|
||||
fileio:close(refnum)
|
||||
else
|
||||
result = perr
|
||||
fin
|
||||
fin
|
||||
return result
|
||||
end
|
||||
|
||||
//
|
||||
// Fixups
|
||||
//
|
||||
dcgrStr:1 = @dcgrLoadDefFont
|
||||
//
|
||||
// Keep module in memory
|
||||
//
|
||||
return modkeep
|
||||
done
|
177
src/dhgr.tk/makefile
Normal file
177
src/dhgr.tk/makefile
Normal file
@@ -0,0 +1,177 @@
|
||||
.SUFFIXES =
|
||||
AFLAGS = -o $@
|
||||
|
||||
DHGRLIB = dhgr.tk/libs/DHGRLIB.REL
|
||||
DHGRUTILS = dhgr.tk/libs//DHGRUTILS.REL
|
||||
DHGRTEST = dhgr.tk/test/DHGRTEST.REL
|
||||
FONTTEST = dhgr.tk/test/FONTTEST.REL
|
||||
DHGRSPRED = dhgr.tk/utils/DHGRSPRED.REL
|
||||
DHGREASY = dhgr.tk/utils/DHGREASY.REL
|
||||
DHGRRGB = dhgr.tk/utils/DHGRRGB.REL
|
||||
DHGRSHOW = dhgr.tk/utils/DHGRSHOW.REL
|
||||
DLGRCONV = dhgr.tk/utils/DLGRCONV.REL
|
||||
DHGRRGB_C = dhgr.tk/utils/dhgrrgb
|
||||
TTFCONV = dhgr.tk/utils/ttfconv
|
||||
IIGSCONV = dhgr.tk/utils/gsfonconv
|
||||
A2CONV = dhgr.tk/utils/a2fonconv
|
||||
A2DEFAULT = dhgr.tk/utils/a2fondef
|
||||
DDCONV = dhgr.tk/utils/ddfonconv
|
||||
PENGUINS = dhgr.tk/demos/penguins/PENGUINS.REL
|
||||
DARTHGR = dhgr.tk/demos/darthgr/DARTHGR.REL
|
||||
STARTREK = dhgr.tk/demos/startrek/STARTREK.REL
|
||||
FILLSHAPE = dhgr.tk/demos/startrek/FILLSHAPE.REL
|
||||
DROGUE = dhgr.tk/drogue/DROGUE.REL
|
||||
DROGUE.MAP = dhgr.tk/drogue/DROGUE.MAP.REL
|
||||
DROGUE.COMBAT = dhgr.tk/drogue/DROGUE.COMBAT.REL
|
||||
|
||||
|
||||
libs: $(DHGRLIB) $(DHGRUTILS)
|
||||
cp $(DHGRLIB) prodos/sys
|
||||
cp $(DHGRUTILS) prodos/sys
|
||||
-mkdir prodos/sys/fonts
|
||||
cp dhgr.tk/utils/fonts/APPLE2.FON.BIN prodos/sys/fonts
|
||||
cp dhgr.tk/utils/fonts/APPLE2THIN.FON.BIN prodos/sys/fonts
|
||||
cp dhgr.tk/utils/fonts/A2SLIM8.FON.BIN prodos/sys/fonts
|
||||
|
||||
test: $(DHGRTEST) $(FONTTEST)
|
||||
-mkdir prodos/dhgr.tk/
|
||||
-mkdir prodos/dhgr.tk/test
|
||||
cp dhgr.tk/test/*.REL prodos/dhgr.tk/test
|
||||
cp dhgr.tk/test/*.BIN prodos/dhgr.tk/test
|
||||
|
||||
utils: $(DHGRSPRED) $(DHGREASY) $(DHGRRGB) $(DHGRRGB_C) $(DHGRSHOW) $(DLGRCONV)
|
||||
-mkdir prodos/dhgr.tk/
|
||||
-mkdir prodos/dhgr.tk/utils
|
||||
-mkdir prodos/dhgr.tk/utils/samples
|
||||
cp dhgr.tk/utils/*.REL prodos/dhgr.tk/utils
|
||||
cp dhgr.tk/utils/samples/* prodos/dhgr.tk/utils/samples
|
||||
|
||||
demos: $(PENGUINS) $(DARTHGR) $(STARTREK) $(FILLSHAPE)
|
||||
-mkdir prodos/dhgr.tk/
|
||||
-mkdir prodos/dhgr.tk/demos/
|
||||
-mkdir prodos/dhgr.tk/demos/penguins/
|
||||
-mkdir prodos/dhgr.tk/demos/darthgr/
|
||||
-mkdir prodos/dhgr.tk/demos/startrek/
|
||||
cp $(PENGUINS) prodos/dhgr.tk/demos/penguins/
|
||||
cp dhgr.tk/demos/penguins/*.BIN prodos/dhgr.tk/demos/penguins/
|
||||
cp $(DARTHGR) prodos/dhgr.tk/demos/darthgr/
|
||||
cp dhgr.tk/demos/darthgr/*.BIN prodos/dhgr.tk/demos/darthgr/
|
||||
cp $(STARTREK) prodos/dhgr.tk/demos/startrek/
|
||||
cp $(FILLSHAPE) prodos/dhgr.tk/demos/startrek/
|
||||
cp dhgr.tk/demos/startrek/*.BIN prodos/dhgr.tk/demos/startrek/
|
||||
|
||||
drogue: $(DROGUE) $(DROGUE.MAP) $(DROGUE.COMBAT)
|
||||
-mkdir prodos/dhgr.tk/demos
|
||||
-mkdir prodos/dhgr.tk/demos/drogue
|
||||
cp dhgr.tk/drogue/DROGUE.REL prodos/dhgr.tk/demos/drogue
|
||||
cp dhgr.tk/drogue/DROGUE.MAP.REL prodos/dhgr.tk/demos/drogue/DROGUEMAP.REL
|
||||
cp dhgr.tk/drogue/DROGUE.COMBAT.REL prodos/dhgr.tk/demos/drogue/DROGUECOMBAT.REL
|
||||
cp samplesrc/LEVEL0#040000 prodos/dhgr.tk/demos/drogue/LEVEL0.TXT
|
||||
cp samplesrc/LEVEL1#040000 prodos/dhgr.tk/demos/drogue/LEVEL1.TXT
|
||||
|
||||
bld: $(DHGRLIB) $(DHGRUTILS) $(DHGRTEST) $(DHGRRGB) $(DHGRSHOW) $(STARTREK)
|
||||
-mkdir prodos/bld/dhgr.tk/
|
||||
-mkdir prodos/bld/dhgr.tk/inc/
|
||||
cp dhgr.tk/inc/dhgrlib.plh prodos/bld/dhgr.tk/inc/DHGRLIB.PLH.TXT
|
||||
cp dhgr.tk/inc/dhgrutils.plh prodos/bld/dhgr.tk/inc/DHGRUTILS.PLH.TXT
|
||||
cp dhgr.tk/test/dhgrtest.pla prodos/bld/dhgr.tk/DHGRTEST.PLA.TXT
|
||||
cp dhgr.tk/test/fonttest.pla prodos/bld/dhgr.tk/FONTTEST.PLA.TXT
|
||||
cp dhgr.tk/demos/darthgr/darthgr.pla prodos/bld/dhgr.tk/DARTHGR.PLA.TXT
|
||||
cp dhgr.tk/demos/startrek/startrek.pla prodos/bld/dhgr.tk/STARTREK.PLA.TXT
|
||||
cp dhgr.tk/demos/startrek/fillshape.pla prodos/bld/dhgr.tk/FILLSHAPE.PLA.TXT
|
||||
cp dhgr.tk/utils/dhgrrgb.pla prodos/bld/dhgr.tk/DHGRRGB.PLA.TXT
|
||||
cp dhgr.tk/utils/dhgrshow.pla prodos/bld/dhgr.tk/DHGRSHOW.PLA.TXT
|
||||
|
||||
fontconv: $(TTFCONV) $(IIGSCONV) $(A2CONV) $(A2DEFAULT) $(DDCONV)
|
||||
|
||||
all: libs test utils demos bld
|
||||
|
||||
clean:
|
||||
-rm dhgr.tk/demos/pengiuns/*.o dhgr.tk/demos/pengiuns/*.REL dhgr.tk/demos/pengiuns/*.a
|
||||
-rm dhgr.tk/demos/darthgr/*.o dhgr.tk/demos/darthgr/*.REL dhgr.tk/demos/darthgr/*.a
|
||||
-rm dhgr.tk/demos/startrek/*.o dhgr.tk/demos/startrek/*.REL dhgr.tk/demos/startrek/*.a
|
||||
-rm dhgr.tk/test/*.o dhgr.tk/test/*.REL dhgr.tk/test/*.a
|
||||
-rm dhgr.tk/utils/*.o dhgr.tk/utils/*.REL dhgr.tk/utils/*.a
|
||||
|
||||
|
||||
$(TTFCONV): dhgr.tk/utils/ttfconv.c
|
||||
cc `pkg-config --cflags freetype2` dhgr.tk/utils/ttfconv.c -o dhgr.tk/utils/ttfconv -lfreetype
|
||||
|
||||
$(IIGSCONV): dhgr.tk/utils/gsfonconv.c
|
||||
cc dhgr.tk/utils/gsfonconv.c -o dhgr.tk/utils/gsfonconv
|
||||
|
||||
$(A2CONV): dhgr.tk/utils/a2fonconv.c
|
||||
cc dhgr.tk/utils/a2fonconv.c -o dhgr.tk/utils/a2fonconv
|
||||
|
||||
$(A2DEFAULT): dhgr.tk/utils/a2fondef.c
|
||||
cc dhgr.tk/utils/a2fondef.c -o dhgr.tk/utils/a2fondef
|
||||
|
||||
$(DDCONV): dhgr.tk/utils/ddfonconv.c
|
||||
cc dhgr.tk/utils/ddfonconv.c -o dhgr.tk/utils/ddfonconv
|
||||
|
||||
$(DHGRLIB): dhgr.tk/libs/dhgrlib.pla dhgr.tk/inc/dhgrlib.plh
|
||||
./xplasm -AMOW dhgr.tk/libs/dhgrlib.pla
|
||||
acme --setpc 4094 -o $(DHGRLIB) dhgr.tk/libs/dhgrlib.a
|
||||
|
||||
$(DHGRUTILS): dhgr.tk/libs/dhgrutils.pla $(DHGRLIB) dhgr.tk/inc/dhgrlib.plh dhgr.tk/inc/dhgrutils.plh
|
||||
./xplasm -AMOW dhgr.tk/libs/dhgrutils.pla
|
||||
acme --setpc 4094 -o $(DHGRUTILS) dhgr.tk/libs/dhgrutils.a
|
||||
|
||||
$(DHGRTEST): dhgr.tk/test/dhgrtest.pla $(DHGRLIB) $(DHGRUTILS) dhgr.tk/inc/dhgrlib.plh dhgr.tk/inc/dhgrutils.plh
|
||||
./xplasm -AMOW dhgr.tk/test/dhgrtest.pla
|
||||
acme --setpc 4094 -o $(DHGRTEST) dhgr.tk/test/dhgrtest.a
|
||||
|
||||
$(FONTTEST): dhgr.tk/test/fonttest.pla $(DHGRLIB) $(DHGRUTILS) dhgr.tk/inc/dhgrlib.plh dhgr.tk/inc/dhgrutils.plh
|
||||
./xplasm -AMOW dhgr.tk/test/fonttest.pla
|
||||
acme --setpc 4094 -o $(FONTTEST) dhgr.tk/test/fonttest.a
|
||||
|
||||
$(DHGRSPRED): dhgr.tk/utils/dhgrspred.pla $(DHGRLIB) $(DHGRUTILS) dhgr.tk/inc/dhgrlib.plh dhgr.tk/inc/dhgrutils.plh
|
||||
./xplasm -AMOW dhgr.tk/utils/dhgrspred.pla
|
||||
acme --setpc 4094 -o $(DHGRSPRED) dhgr.tk/utils/dhgrspred.a
|
||||
|
||||
$(DHGREASY): dhgr.tk/utils/dhgreasy.pla $(DHGRLIB) $(DHGRUTILS) dhgr.tk/inc/dhgrlib.plh dhgr.tk/inc/dhgrutils.plh
|
||||
./xplasm -AMOW dhgr.tk/utils/dhgreasy.pla
|
||||
acme --setpc 4094 -o $(DHGREASY) dhgr.tk/utils/dhgreasy.a
|
||||
|
||||
$(DHGRSHOW): dhgr.tk/utils/dhgrshow.pla $(DHGRLIB) $(DHGRUTILS) dhgr.tk/inc/dhgrlib.plh dhgr.tk/inc/dhgrutils.plh
|
||||
./xplasm -AMOW dhgr.tk/utils/dhgrshow.pla
|
||||
acme --setpc 4094 -o $(DHGRSHOW) dhgr.tk/utils/dhgrshow.a
|
||||
|
||||
$(DLGRCONV): dhgr.tk/utils/dlgrconv.pla $(DHGRLIB) $(DHGRUTILS) dhgr.tk/inc/dhgrlib.plh dhgr.tk/inc/dhgrutils.plh
|
||||
./xplasm -AMOW dhgr.tk/utils/dlgrconv.pla
|
||||
acme --setpc 4094 -o $(DLGRCONV) dhgr.tk/utils/dlgrconv.a
|
||||
|
||||
$(DHGRRGB): dhgr.tk/utils/dhgrrgb.pla $(DHGRLIB) $(DHGRUTILS) dhgr.tk/inc/dhgrlib.plh dhgr.tk/inc/dhgrutils.plh
|
||||
./xplasm -AMOW dhgr.tk/utils/dhgrrgb.pla
|
||||
acme --setpc 4094 -o $(DHGRRGB) dhgr.tk/utils/dhgrrgb.a
|
||||
|
||||
$(DHGRRGB_C): dhgr.tk/utils/dhgrrgb.c
|
||||
cc dhgr.tk/utils/dhgrrgb.c -o dhgr.tk/utils/dhgrrgb -lm
|
||||
|
||||
$(PENGUINS): dhgr.tk/demos/penguins/penguins.pla dhgr.tk/inc/dhgrlib.plh dhgr.tk/inc/dhgrutils.plh
|
||||
./xplasm -AMOW dhgr.tk/demos/penguins/penguins.pla
|
||||
acme --setpc 4094 -o $(PENGUINS) dhgr.tk/demos/penguins/penguins.a
|
||||
|
||||
$(DARTHGR): dhgr.tk/demos/darthgr/darthgr.pla dhgr.tk/inc/dhgrlib.plh dhgr.tk/inc/dhgrutils.plh
|
||||
./xplasm -AMOW dhgr.tk/demos/darthgr/darthgr.pla
|
||||
acme --setpc 4094 -o $(DARTHGR) dhgr.tk/demos/darthgr/darthgr.a
|
||||
|
||||
$(STARTREK): dhgr.tk/demos/startrek/startrek.pla dhgr.tk/inc/dhgrlib.plh dhgr.tk/inc/dhgrutils.plh
|
||||
./xplasm -AMOW dhgr.tk/demos/startrek/startrek.pla
|
||||
acme --setpc 4094 -o $(STARTREK) dhgr.tk/demos/startrek/startrek.a
|
||||
|
||||
$(FILLSHAPE): dhgr.tk/demos/startrek/fillshape.pla dhgr.tk/inc/dhgrlib.plh dhgr.tk/inc/dhgrutils.plh
|
||||
./xplasm -AMOW dhgr.tk/demos/startrek/fillshape.pla
|
||||
acme --setpc 4094 -o $(FILLSHAPE) dhgr.tk/demos/startrek/fillshape.a
|
||||
|
||||
$(DROGUE): dhgr.tk/drogue/drogue.pla dhgr.tk/inc/dhgrlib.plh dhgr.tk/inc/dhgrutils.plh
|
||||
./xplasm -AMOW dhgr.tk/drogue/drogue.pla
|
||||
acme --setpc 4094 -o $(DROGUE) dhgr.tk/drogue/drogue.a
|
||||
|
||||
$(DROGUE.MAP): dhgr.tk/drogue/drogue.map.pla dhgr.tk/inc/dhgrlib.plh dhgr.tk/inc/dhgrutils.plh
|
||||
./xplasm -AMOW dhgr.tk/drogue/drogue.map.pla
|
||||
acme --setpc 4094 -o $(DROGUE.MAP) dhgr.tk/drogue/drogue.map.a
|
||||
|
||||
$(DROGUE.COMBAT): dhgr.tk/drogue/drogue.combat.pla dhgr.tk/inc/dhgrlib.plh dhgr.tk/inc/dhgrutils.plh
|
||||
./xplasm -AMOW dhgr.tk/drogue/drogue.combat.pla
|
||||
acme --setpc 4094 -o $(DROGUE.COMBAT) dhgr.tk/drogue/drogue.combat.a
|
BIN
src/dhgr.tk/test/ENT.DL.SPR.BIN
Normal file
BIN
src/dhgr.tk/test/ENT.DL.SPR.BIN
Normal file
Binary file not shown.
BIN
src/dhgr.tk/test/ENT.DN.SPR.BIN
Normal file
BIN
src/dhgr.tk/test/ENT.DN.SPR.BIN
Normal file
Binary file not shown.
BIN
src/dhgr.tk/test/ENT.DR.SPR.BIN
Normal file
BIN
src/dhgr.tk/test/ENT.DR.SPR.BIN
Normal file
Binary file not shown.
BIN
src/dhgr.tk/test/ENT.LT.SPR.BIN
Normal file
BIN
src/dhgr.tk/test/ENT.LT.SPR.BIN
Normal file
Binary file not shown.
BIN
src/dhgr.tk/test/ENT.RT.SPR.BIN
Normal file
BIN
src/dhgr.tk/test/ENT.RT.SPR.BIN
Normal file
Binary file not shown.
BIN
src/dhgr.tk/test/ENT.UL.SPR.BIN
Normal file
BIN
src/dhgr.tk/test/ENT.UL.SPR.BIN
Normal file
Binary file not shown.
BIN
src/dhgr.tk/test/ENT.UP.SPR.BIN
Normal file
BIN
src/dhgr.tk/test/ENT.UP.SPR.BIN
Normal file
Binary file not shown.
BIN
src/dhgr.tk/test/ENT.UR.SPR.BIN
Normal file
BIN
src/dhgr.tk/test/ENT.UR.SPR.BIN
Normal file
Binary file not shown.
BIN
src/dhgr.tk/test/SPLASH.DHGR.BIN
Normal file
BIN
src/dhgr.tk/test/SPLASH.DHGR.BIN
Normal file
Binary file not shown.
458
src/dhgr.tk/test/dhgrtest.pla
Normal file
458
src/dhgr.tk/test/dhgrtest.pla
Normal file
@@ -0,0 +1,458 @@
|
||||
include "inc/cmdsys.plh"
|
||||
include "inc/lines.plh"
|
||||
include "dhgr.tk/inc/dhgrlib.plh"
|
||||
include "dhgr.tk/inc/dhgrutils.plh"
|
||||
|
||||
sysflags resxtxt1|reshgr1|resxhgr1
|
||||
//
|
||||
// Test sprite
|
||||
//
|
||||
const SPR_W = 16
|
||||
const SPR_H = 16
|
||||
byte[] sprite = $55,$55,$55,$05,$50,$55,$55,$55
|
||||
byte[] = $55,$55,$00,$00,$00,$00,$55,$55
|
||||
byte[] = $55,$00,$00,$AA,$AA,$00,$00,$55
|
||||
byte[] = $05,$00,$AA,$AA,$AA,$AA,$00,$50
|
||||
byte[] = $00,$A0,$AA,$FF,$FF,$AA,$0A,$00
|
||||
byte[] = $00,$AA,$FF,$FF,$FF,$FF,$AA,$00
|
||||
byte[] = $00,$AA,$1F,$12,$12,$F2,$AA,$00
|
||||
byte[] = $00,$AA,$2F,$21,$21,$F1,$AA,$00
|
||||
byte[] = $00,$AA,$1F,$12,$12,$F2,$AA,$00
|
||||
byte[] = $00,$AA,$2F,$21,$21,$F1,$AA,$00
|
||||
byte[] = $00,$AA,$FF,$FF,$FF,$FF,$AA,$00
|
||||
byte[] = $00,$A0,$AA,$FF,$FF,$AA,$0A,$00
|
||||
byte[] = $05,$00,$AA,$AA,$AA,$AA,$00,$50
|
||||
byte[] = $55,$00,$00,$AA,$AA,$00,$00,$55
|
||||
byte[] = $55,$55,$00,$00,$00,$00,$55,$55
|
||||
byte[] = $55,$55,$55,$05,$50,$55,$55,$55
|
||||
byte[] rlesprt = 7,$55,2,$00,7,$55
|
||||
byte[] = 4,$55,8,$00,4,$55
|
||||
byte[] = 2,$55,4,$00,4,$AA,4,$00,2,$55
|
||||
byte[] = 1,$05,3,$00,8,$AA,3,$00,1,$55
|
||||
byte[] = 3,$00,3,$AA,4,$FF,3,$AA,3,$00
|
||||
byte[] = 2,$00,2,$AA,8,$FF,2,$AA,2,$00
|
||||
byte[] = 2,$00,2,$AA,2,$1F,4,$12,2,$F2,2,$AA,2,$00
|
||||
byte[] = 2,$00,2,$AA,2,$2F,4,$21,2,$F1,2,$AA,2,$00
|
||||
byte[] = 2,$00,2,$AA,2,$1F,4,$12,2,$F2,2,$AA,2,$00
|
||||
byte[] = 2,$00,2,$AA,2,$2F,4,$21,2,$F1,2,$AA,2,$00
|
||||
byte[] = 2,$00,2,$AA,8,$FF,2,$AA,2,$00
|
||||
byte[] = 3,$00,3,$AA,4,$FF,3,$AA,3,$00
|
||||
byte[] = 1,$05,3,$00,8,$AA,3,$00,1,$55
|
||||
byte[] = 2,$55,4,$00,4,$AA,4,$00,2,$55
|
||||
byte[] = 4,$55,8,$00,4,$55
|
||||
byte[] = 7,$55,2,$00,7,$55
|
||||
|
||||
word rlesprptr
|
||||
word sprite7msk[7]
|
||||
word sprite7[7]
|
||||
word sprite7span,sprite7w
|
||||
//
|
||||
// Dither matrices
|
||||
//
|
||||
byte[] dither25 = $55,$55,$00,$00,$AA,$AA,$00,$00
|
||||
byte[] = $55,$55,$00,$00,$AA,$AA,$00,$00
|
||||
byte[] = $55,$55,$00,$00,$AA,$AA,$00,$00
|
||||
byte[] = $55,$55,$00,$00,$AA,$AA,$00,$00
|
||||
byte[] dither50 = $55,$55,$AA,$AA,$55,$55,$AA,$AA
|
||||
byte[] = $55,$55,$AA,$AA,$55,$55,$AA,$AA
|
||||
byte[] = $55,$55,$AA,$AA,$55,$55,$AA,$AA
|
||||
byte[] = $55,$55,$AA,$AA,$55,$55,$AA,$AA
|
||||
byte[] dither75 = $55,$55,$FF,$FF,$AA,$AA,$FF,$FF
|
||||
byte[] = $55,$55,$FF,$FF,$AA,$AA,$FF,$FF
|
||||
byte[] = $55,$55,$FF,$FF,$AA,$AA,$FF,$FF
|
||||
byte[] = $55,$55,$FF,$FF,$AA,$AA,$FF,$FF
|
||||
word[] dither = @dither25,@dither50,@dither75
|
||||
//
|
||||
// Sliding sprite Y coordinate
|
||||
//
|
||||
const SLIDE_Y = 170
|
||||
//
|
||||
// Enterprise sprites
|
||||
//
|
||||
struc t_sprite
|
||||
var spr_xorg
|
||||
var spr_yorg
|
||||
var spr_width
|
||||
var spr_height
|
||||
var spr_pixmap
|
||||
var spr_bl7
|
||||
end
|
||||
res[t_sprite * 8] ncc1701
|
||||
char[12] sprFile = "ENT.UP.SPR"
|
||||
char[12] = "ENT.UR.SPR"
|
||||
char[12] = "ENT.RT.SPR"
|
||||
char[12] = "ENT.DR.SPR"
|
||||
char[12] = "ENT.DN.SPR"
|
||||
char[12] = "ENT.DL.SPR"
|
||||
char[12] = "ENT.LT.SPR"
|
||||
char[12] = "ENT.UL.SPR"
|
||||
const ENT_W7 = 5
|
||||
const ENT_H = 43
|
||||
const ENT_SZ = ENT_W7*4*ENT_H
|
||||
|
||||
def dcgrCompSprite(offset)#0
|
||||
byte i
|
||||
|
||||
for i = 0 to 6
|
||||
sprite7[i],sprite7span = dhgrAllocBl7Mem(SPR_W+offset,SPR_H)
|
||||
sprite7w = sprite7span >> 2
|
||||
dhgrSurfMem(OP_SRC,SPR_H,sprite7[i],sprite7span)
|
||||
dcgrColor(CLR_BLACK)
|
||||
dhgrClearBl7(0,0,sprite7w,SPR_H)
|
||||
//dcgrPixMap(i + offset,0,SPR_W,SPR_H,@sprite)
|
||||
//dcgrRleMap(i + offset,0,SPR_W,SPR_H,@rlesprt)
|
||||
dcgrRleMap(i + offset,0,SPR_W,SPR_H,rlesprptr)
|
||||
dhgrSurfScr(OP_SRC)
|
||||
dhgrMemBl7(0,i*SPR_H,sprite7w,SPR_H,sprite7[i],sprite7span)
|
||||
next
|
||||
end
|
||||
def dcgrCompMask(offset)#0
|
||||
byte i
|
||||
|
||||
for i = 0 to 6
|
||||
sprite7msk[i],sprite7span = dhgrAllocBl7Mem(SPR_W + offset,SPR_H)
|
||||
sprite7w = sprite7span >> 2
|
||||
dhgrSurfMem(OP_SRC,SPR_H,sprite7msk[i],sprite7span)
|
||||
dcgrColor(CLR_WHITE)
|
||||
dhgrClearBl7(0,0,sprite7w,SPR_H)
|
||||
//dcgrPixMap(i + offset,0,SPR_W,SPR_H,@sprite)
|
||||
dcgrRleMap(i + offset,0,SPR_W,SPR_H,@rlesprt)
|
||||
dhgrOp(OP_XOR)
|
||||
//dcgrPixMap(i + offset,0,SPR_W,SPR_H,@sprite)
|
||||
dcgrRleMap(i + offset,0,SPR_W,SPR_H,@rlesprt)
|
||||
dhgrSurfScr(OP_SRC)
|
||||
dhgrMemBl7(sprite7w,i * SPR_H,sprite7w,SPR_H,sprite7msk[i],sprite7span)
|
||||
next
|
||||
end
|
||||
def readEnterprise#0
|
||||
var xorg,yorg,width,height,pixptr,t_ptr,f_ptr
|
||||
byte i
|
||||
|
||||
t_ptr = @ncc1701
|
||||
f_ptr = @sprFile
|
||||
for i = 0 to 7
|
||||
xorg,yorg,width,height,pixptr = spriteRead(f_ptr)
|
||||
t_ptr=>spr_xorg = xorg
|
||||
t_ptr=>spr_yorg = yorg
|
||||
t_ptr=>spr_width = width
|
||||
t_ptr=>spr_height = height
|
||||
t_ptr=>spr_pixmap = pixptr
|
||||
t_ptr=>spr_bl7 = heapalloc(ENT_SZ)
|
||||
dhgrSurfMem(OP_SRC,ENT_H,t_ptr=>spr_bl7,ENT_W7*4)
|
||||
dcgrColor(CLR_BLACK)
|
||||
dhgrClearBl7(0,0,ENT_W7,ENT_H)
|
||||
dcgrPixmap(ENT_W7*7/2 - xorg,ENT_H/2 - yorg,width,height,pixptr)
|
||||
t_ptr = t_ptr + t_sprite
|
||||
f_ptr = f_ptr + 12
|
||||
next
|
||||
end
|
||||
//////////////////////////////////////////
|
||||
// //
|
||||
// Test Harness //
|
||||
// //
|
||||
//////////////////////////////////////////
|
||||
def dhgrTest#0
|
||||
word i
|
||||
|
||||
//
|
||||
// Double Hires Lines
|
||||
//
|
||||
dhgrSurfScr(OP_OR)
|
||||
setlineplot(@dhgrSet)
|
||||
for i = 559 downto 0 step 20
|
||||
line(0,0,i,191)
|
||||
next
|
||||
getc
|
||||
end
|
||||
def dcgrTest#0
|
||||
word i,j,k,oi,oj,i7,im7,k7,km7,s7w,inci,incj,inck
|
||||
word backblk,backspan
|
||||
word restrblk,restrspan,restr7w,restrw
|
||||
byte mode
|
||||
byte[40] tilestr
|
||||
|
||||
//
|
||||
// Use back buffer for tile set buffer
|
||||
//
|
||||
backblk,backspan = dhgrAllocBl7Mem(SCR_WIDTH,SPR_H)
|
||||
j = 0
|
||||
while ^$C000 < 128
|
||||
//
|
||||
// Convert compiled sprite into tile set
|
||||
//
|
||||
dhgrMemBl7Tile(0,0,sprite7[j],sprite7span,backblk)
|
||||
dhgrMemBl7Tile(1,0,sprite7[j],sprite7span,backblk + 32)
|
||||
dhgrMemBl7Tile(2,0,sprite7[j],sprite7span,backblk + 64)
|
||||
dhgrMemBl7Tile(3,0,sprite7[j],sprite7span,backblk + 96)
|
||||
dhgrMemBl7Tile(0,8,sprite7[j],sprite7span,backblk + 128)
|
||||
dhgrMemBl7Tile(1,8,sprite7[j],sprite7span,backblk + 160)
|
||||
dhgrMemBl7Tile(2,8,sprite7[j],sprite7span,backblk + 192)
|
||||
dhgrMemBl7Tile(3,8,sprite7[j],sprite7span,backblk + 224)
|
||||
//
|
||||
// Fill screen wil tiles matching compiled sprite
|
||||
//
|
||||
for i = 0 to 19
|
||||
tilestr[i] = i & $03
|
||||
next
|
||||
for i = 0 to 19
|
||||
tilestr[i + 20] = (i & $03) + 4
|
||||
next
|
||||
dhgrSurfScr(OP_SRC)
|
||||
for i = 0 to 12 step 2
|
||||
dhgrTiles(10,i, @tilestr, 10,backblk)
|
||||
dhgrTiles(10,i + 1,@tilestr + 20,10,backblk)
|
||||
next
|
||||
j++
|
||||
if j == 7; j = 0; fin
|
||||
loop
|
||||
getc
|
||||
//
|
||||
// Lines
|
||||
//
|
||||
dhgrSurfScr(OP_SRC)
|
||||
setlineplot(@dcgrPixel)
|
||||
setlinespans(@dcgrHLin,@dcgrVLin)
|
||||
for i = 0 to 191 step 2
|
||||
dcgrColor(i)
|
||||
linespans(0,0,139,i)
|
||||
next
|
||||
for i = 139 downto 0 step 2
|
||||
dcgrColor(i)
|
||||
linespans(0,0,i,191)
|
||||
next
|
||||
dcgrColor(CLR_BLACK)
|
||||
dhgrClearBl7(21/7,30,100/7,132)
|
||||
dcgrColor(CLR_WHITE)
|
||||
dcgrHLin((21/7)*7-1,(21/7)*7+(100/7)*7,29)
|
||||
dcgrHLin((21/7)*7-1,(21/7)*7+(100/7)*7,29+133)
|
||||
dcgrVLin(29,29+133,(21/7)*7-1)
|
||||
dcgrVLin(29,29+133,(21/7)*7+(100/7)*7)
|
||||
dcgrColor(CLR_BLACK) // Outline color
|
||||
dcgrBoldStr(CLR_WHITE,48,14,"Hello!")
|
||||
dcgrFont(FONT_DEF_THIN)
|
||||
dcgrColor(CLR_WHITE) // Outline color
|
||||
dcgrBoldStr(CLR_BLACK,42,24,"from DCGRTEST")
|
||||
i = 64; j = 64; k = 86
|
||||
k7 = k/7
|
||||
inci = 1; incj = 1; inck = 2
|
||||
dhgrSurfMem(OP_SRC,SPR_H,backblk,backspan)
|
||||
dhgrScrBl7(0,SLIDE_Y,backspan >> 2,SPR_H)
|
||||
dhgrSurfScr(OP_SRC)
|
||||
dcgrColor(CLR_WHITE)
|
||||
dcgrHLin(0,139,SLIDE_Y)
|
||||
dcgrHLin(0,139,SLIDE_Y+SPR_H-1)
|
||||
dcgrVLin(SLIDE_Y,SLIDE_Y+SPR_H-1,0)
|
||||
dcgrVLin(SLIDE_Y,SLIDE_Y+SPR_H-1,139)
|
||||
getc
|
||||
dhgrMemBl7(0,SLIDE_Y,backspan >> 2,SPR_H,backblk,backspan)
|
||||
restrblk,restrspan = dhgrAllocBl7Mem(SPR_W,SPR_H)
|
||||
restr7w = restrspan >> 2
|
||||
restrw = restr7w * 7
|
||||
mode = 1
|
||||
while mode
|
||||
if ^$C000 >= 128
|
||||
mode = (^$C010 & $7F) - '0'
|
||||
fin
|
||||
k7,km7 = divmod(k,7)
|
||||
i7,im7 = divmod(i,7)
|
||||
if i7 + sprite7w < (21/7)+(100/7)
|
||||
s7w = sprite7w
|
||||
else
|
||||
s7w = (21/7)+(100/7) - i7
|
||||
fin
|
||||
when mode
|
||||
is 1
|
||||
dhgrSurfScr(OP_SRC)
|
||||
dhgrMemBl7(i7,j,s7w,SPR_H,sprite7[im7],sprite7span)
|
||||
is 2
|
||||
if k < 0 and km7 // Handle off left edge special case
|
||||
k7--
|
||||
km7 = 7 + km7
|
||||
fin
|
||||
dhgrSurfMem(OP_SRC,SPR_H,restrblk,restrspan)
|
||||
dhgrMemBl7(0,0,restr7w,SPR_H,backblk + (k7 << 1),backspan)
|
||||
dhgrOp(OP_AND)
|
||||
dhgrMemBl7(0,0,sprite7w,SPR_H,sprite7msk[km7],sprite7span)
|
||||
dhgrOp(OP_XOR)
|
||||
dhgrMemBl7(0,0,sprite7w,SPR_H,sprite7[km7],sprite7span)
|
||||
dhgrSurfScr(OP_SRC)
|
||||
dhgrMemBl7(k7,SLIDE_Y,restr7w,SPR_H,restrblk,restrspan)
|
||||
break
|
||||
is 3
|
||||
dhgrSurfScr(OP_SRC)
|
||||
dcgrPixMap(i,j,SPR_W,SPR_H,@sprite)
|
||||
is 4
|
||||
dhgrSurfMem(OP_SRC,SPR_H,restrblk,restrspan)
|
||||
dhgrMemBl7(0,0,restr7w,SPR_H,backblk + (k7 << 1),backspan)
|
||||
dcgrPixMap(km7 + 2,0,SPR_W,SPR_H,@sprite)
|
||||
dhgrSurfScr(OP_SRC)
|
||||
dhgrMemBl7(k7,SLIDE_Y,restr7w,SPR_H,restrblk,restrspan)
|
||||
break
|
||||
is 5
|
||||
dhgrSurfScr(OP_SRC)
|
||||
dcgrPixMap(i,j,SPR_W,SPR_H,@sprite)
|
||||
is 6
|
||||
dhgrSurfMem(OP_SRC,SPR_H,restrblk,restrspan)
|
||||
dhgrMemBl7(0,0,restr7w,SPR_H,backblk + (k7 << 1),backspan)
|
||||
dcgrColor(CLR_BLACK)
|
||||
dcgrRect(km7 + 2,3,16 + 2,10)
|
||||
dcgrColor(CLR_WHITE)
|
||||
dcgrStr(km7 + 3,13,"DCGR")
|
||||
dhgrSurfScr(OP_SRC)
|
||||
dhgrMemBl7(k7,SLIDE_Y,restr7w,SPR_H,restrblk,restrspan)
|
||||
break
|
||||
is 7
|
||||
dhgrSurfScr(OP_SRC)
|
||||
dhgrMemBl7(i7,j,s7w,SPR_H,sprite7[im7],sprite7span)
|
||||
break
|
||||
is 8
|
||||
dhgrSurfScr(OP_SRC)
|
||||
dcgrPixMap(i,j,SPR_W,SPR_H,@sprite)
|
||||
break
|
||||
is 9
|
||||
dhgrSurfScr(OP_XOR)
|
||||
dcgrPixMap(i,j,SPR_W,SPR_H,@sprite)
|
||||
dcgrPixMap(oi,oj,SPR_W,SPR_H,@sprite)
|
||||
break
|
||||
wend
|
||||
if k > 136 or k < -16; inck = -inck; fin
|
||||
k = k + inck
|
||||
oi = i; oj = j
|
||||
if i > 102 or i < 22; inci = -inci; fin
|
||||
i = i + inci
|
||||
if j > 145 or j < 32; incj = -incj; fin
|
||||
j = j + incj
|
||||
loop
|
||||
//
|
||||
// Rotate Enterprise
|
||||
//
|
||||
dhgrSurfScr(OP_SRC)
|
||||
dcgrColor(CLR_BLACK)
|
||||
dhgrClearBl7(21/7,30,100/7,132)
|
||||
dhgrOp(OP_XOR)
|
||||
k = 0
|
||||
i = @ncc1701
|
||||
oi = 73-i=>spr_xorg
|
||||
oj = 96-i=>spr_yorg
|
||||
dcgrPixMap(oi,oj,i=>spr_width,i=>spr_height,i=>spr_pixmap)
|
||||
while ^$C000 < 128
|
||||
dcgrPixMap(oi,oj,i=>spr_width,i=>spr_height,i=>spr_pixmap)
|
||||
i = i + t_sprite
|
||||
k++
|
||||
if k > 7
|
||||
k = 0
|
||||
i = @ncc1701
|
||||
fin
|
||||
oi = 73-i=>spr_xorg
|
||||
oj = 96-i=>spr_yorg
|
||||
dcgrPixMap(oi,oj,i=>spr_width,i=>spr_height,i=>spr_pixmap)
|
||||
loop
|
||||
getc
|
||||
dhgrOp(OP_SRC)
|
||||
while ^$C000 < 128
|
||||
dcgrColor(CLR_BLACK)
|
||||
dhgrClearBl7(60/7,75,5,43)
|
||||
oi = 73-i=>spr_xorg
|
||||
oj = 96-i=>spr_yorg
|
||||
dcgrPixMap(oi,oj,i=>spr_width,i=>spr_height,i=>spr_pixmap)
|
||||
i = i + t_sprite
|
||||
k++
|
||||
if k > 7
|
||||
k = 0
|
||||
i = @ncc1701
|
||||
fin
|
||||
loop
|
||||
getc
|
||||
while ^$C000 < 128
|
||||
dhgrMemBl7(60/7,75,ENT_W7,ENT_H,i=>spr_bl7,ENT_W7*4)
|
||||
i = i + t_sprite
|
||||
k++
|
||||
if k > 7
|
||||
k = 0
|
||||
i = @ncc1701
|
||||
fin
|
||||
loop
|
||||
getc
|
||||
//
|
||||
// Re-use the back buffer for a stipple pattern to mask the screen
|
||||
//
|
||||
for k = 0 to 2
|
||||
dhgrSurfMem(OP_SRC,SPR_H,backblk,backspan)
|
||||
dcgrColor(CLR_WHITE)
|
||||
dhgrClearBl7(0,0,SCR_WIDTH7,SPR_H)
|
||||
dcgrColor(CLR_BLACK)
|
||||
for i = 0 to 139 step 16
|
||||
dcgrBitMap(i,0,16,16,dither[k])
|
||||
next
|
||||
dhgrSurfScr(OP_AND)
|
||||
for j = 0 to 95 step 16
|
||||
dhgrMemBl7(0,j,SCR_WIDTH7,16,backblk,backspan)
|
||||
dhgrMemBl7(0,175 - j,SCR_WIDTH7,16,backblk,backspan)
|
||||
next
|
||||
next
|
||||
dhgrSurfScr(OP_SRC)
|
||||
dhgrClearBl7(0,0,SCR_WIDTH7,SCR_HEIGHT)
|
||||
//
|
||||
// Create color patterns
|
||||
//
|
||||
for i = 0 to 15
|
||||
dcgrColor(i)
|
||||
dhgrClearBl7(i,0,1,SCR_HEIGHT)
|
||||
next
|
||||
oj = 0
|
||||
for j = 0 to 191 step 12
|
||||
dcgrColor(oj)
|
||||
oi = 0
|
||||
for i = 0 to 111 step 14
|
||||
dcgrBitMap(i,j,14,12,@dither25)
|
||||
oi++
|
||||
next
|
||||
oj++
|
||||
next
|
||||
getc
|
||||
for i = 0 to 15
|
||||
dcgrColor(i)
|
||||
dhgrClearBl7(i,0,1,SCR_HEIGHT)
|
||||
next
|
||||
oj = 0
|
||||
for j = 0 to 191 step 12
|
||||
dcgrColor(oj)
|
||||
oi = 0
|
||||
for i = 0 to 111 step 14
|
||||
dcgrBitMap(i,j,14,12,@dither50)
|
||||
oi++
|
||||
next
|
||||
oj++
|
||||
next
|
||||
getc
|
||||
for i = 0 to 15
|
||||
dcgrColor(i)
|
||||
dhgrClearBl7(i,0,1,SCR_HEIGHT)
|
||||
next
|
||||
oj = 0
|
||||
for j = 0 to 191 step 12
|
||||
dcgrColor(oj)
|
||||
oi = 0
|
||||
for i = 0 to 111 step 14
|
||||
dcgrBitMap(i,j,14,12,@dither75)
|
||||
oi++
|
||||
next
|
||||
oj++
|
||||
next
|
||||
getc
|
||||
end
|
||||
|
||||
rlesprptr = heapmark
|
||||
heapalloc(dcgrEncPixMap(SPR_W,SPR_H,@sprite,rlesprptr))
|
||||
dhgrMode(DHGR_COLOR_MODE)
|
||||
dhgrTest
|
||||
screenRead("splash.dhgr")
|
||||
dhgrOp(OP_SRC)
|
||||
dcgrPixMap(10,10,20,20,dcgrGetPixMap(60,66,20,20))
|
||||
getc
|
||||
readEnterprise
|
||||
dcgrCompSprite(2)
|
||||
dcgrCompMask(2)
|
||||
dcgrTest
|
||||
dhgrMode(DHGR_TEXT_MODE)
|
||||
done
|
36
src/dhgr.tk/test/fonttest.pla
Normal file
36
src/dhgr.tk/test/fonttest.pla
Normal file
@@ -0,0 +1,36 @@
|
||||
include "inc/cmdsys.plh"
|
||||
include "inc/lines.plh"
|
||||
include "inc/args.plh"
|
||||
include "inc/fileio.plh"
|
||||
include "dhgr.tk/inc/dhgrlib.plh"
|
||||
include "dhgr.tk/inc/dhgrutils.plh"
|
||||
|
||||
sysflags resxtxt1|reshgr1|resxhgr1
|
||||
|
||||
var arg
|
||||
var xPen = 60
|
||||
var yPen = 30
|
||||
var fontWidth, fontHeight
|
||||
char hello = "Hello, world"
|
||||
var msg = @hello
|
||||
|
||||
arg = argNext(argFirst)
|
||||
dhgrMode(DHGR_COLOR_MODE)
|
||||
screenRead("scroll.dhgr")
|
||||
while arg and ^arg
|
||||
if ^(arg + 1) == '-'
|
||||
msg = arg + 1
|
||||
^msg = ^arg - 1
|
||||
else
|
||||
dcgrFont(fontRead(arg))
|
||||
fontWidth, fontHeight = fontGlyphDim('a')
|
||||
fontHeight++
|
||||
dcgrColor(CLR_BLACK)
|
||||
dcgrStr(xPen, yPen + (fontHeight * 7) / 8, msg)
|
||||
yPen = yPen + fontHeight
|
||||
fin
|
||||
arg = argNext(arg)
|
||||
loop
|
||||
getc
|
||||
dhgrMode(DHGR_TEXT_MODE)
|
||||
done
|
189
src/dhgr.tk/utils/a2fonconv.c
Normal file
189
src/dhgr.tk/utils/a2fonconv.c
Normal file
@@ -0,0 +1,189 @@
|
||||
/*
|
||||
* Apple 2 font converter
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
//#include <stdbit.h>
|
||||
#include <stdint.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#define FONT_WIDTH 32
|
||||
#define FONT_HEIGHT 12
|
||||
#define GLYPH_FIRST 32
|
||||
#define GLYPH_LAST 127
|
||||
#define GLYPH_COUNT (GLYPH_LAST-GLYPH_FIRST+1)
|
||||
#define FONT_BITMAP 0
|
||||
#define FONT_PIXMAP 1
|
||||
int fontFormat = FONT_BITMAP;
|
||||
//
|
||||
// Apple //e hires character font
|
||||
//
|
||||
uint8_t Apple2Glyphs[] = {
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x08,0x08,0x08,0x08,0x00,0x08,0x00,
|
||||
0x14,0x14,0x14,0x00,0x00,0x00,0x00,0x00,0x14,0x14,0x3E,0x14,0x3E,0x14,0x14,0x00,
|
||||
0x08,0x3C,0x0A,0x1C,0x28,0x1E,0x08,0x00,0x06,0x26,0x10,0x08,0x04,0x32,0x30,0x00,
|
||||
0x04,0x0A,0x0A,0x04,0x2A,0x12,0x2C,0x00,0x08,0x08,0x08,0x00,0x00,0x00,0x00,0x00,
|
||||
0x08,0x04,0x02,0x02,0x02,0x04,0x08,0x00,0x08,0x10,0x20,0x20,0x20,0x10,0x08,0x00,
|
||||
0x08,0x2A,0x1C,0x08,0x1C,0x2A,0x08,0x00,0x00,0x08,0x08,0x3E,0x08,0x08,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x08,0x08,0x04,0x00,0x00,0x00,0x00,0x3E,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x00,0x20,0x10,0x08,0x04,0x02,0x00,0x00,
|
||||
0x1C,0x22,0x32,0x2A,0x26,0x22,0x1C,0x00,0x08,0x0C,0x08,0x08,0x08,0x08,0x1C,0x00,
|
||||
0x1C,0x22,0x20,0x18,0x04,0x02,0x3E,0x00,0x3E,0x20,0x10,0x18,0x20,0x22,0x1C,0x00,
|
||||
0x10,0x18,0x14,0x12,0x3E,0x10,0x10,0x00,0x3E,0x02,0x1E,0x20,0x20,0x22,0x1C,0x00,
|
||||
0x38,0x04,0x02,0x1E,0x22,0x22,0x1C,0x00,0x3E,0x20,0x10,0x08,0x04,0x04,0x04,0x00,
|
||||
0x1C,0x22,0x22,0x1C,0x22,0x22,0x1C,0x00,0x1C,0x22,0x22,0x3C,0x20,0x10,0x0E,0x00,
|
||||
0x00,0x00,0x08,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x08,0x08,0x04,0x00,
|
||||
0x10,0x08,0x04,0x02,0x04,0x08,0x10,0x00,0x00,0x00,0x3E,0x00,0x3E,0x00,0x00,0x00,
|
||||
0x04,0x08,0x10,0x20,0x10,0x08,0x04,0x00,0x1C,0x22,0x10,0x08,0x08,0x00,0x08,0x00,
|
||||
0x1C,0x22,0x2A,0x3A,0x1A,0x02,0x3C,0x00,0x08,0x14,0x22,0x22,0x3E,0x22,0x22,0x00,
|
||||
0x1E,0x22,0x22,0x1E,0x22,0x22,0x1E,0x00,0x1C,0x22,0x02,0x02,0x02,0x22,0x1C,0x00,
|
||||
0x1E,0x22,0x22,0x22,0x22,0x22,0x1E,0x00,0x3E,0x02,0x02,0x1E,0x02,0x02,0x3E,0x00,
|
||||
0x3E,0x02,0x02,0x1E,0x02,0x02,0x02,0x00,0x3C,0x02,0x02,0x02,0x32,0x22,0x3C,0x00,
|
||||
0x22,0x22,0x22,0x3E,0x22,0x22,0x22,0x00,0x1C,0x08,0x08,0x08,0x08,0x08,0x1C,0x00,
|
||||
0x20,0x20,0x20,0x20,0x20,0x22,0x1C,0x00,0x22,0x12,0x0A,0x06,0x0A,0x12,0x22,0x00,
|
||||
0x02,0x02,0x02,0x02,0x02,0x02,0x3E,0x00,0x22,0x36,0x2A,0x2A,0x22,0x22,0x22,0x00,
|
||||
0x22,0x22,0x26,0x2A,0x32,0x22,0x22,0x00,0x1C,0x22,0x22,0x22,0x22,0x22,0x1C,0x00,
|
||||
0x1E,0x22,0x22,0x1E,0x02,0x02,0x02,0x00,0x1C,0x22,0x22,0x22,0x2A,0x12,0x2C,0x00,
|
||||
0x1E,0x22,0x22,0x1E,0x0A,0x12,0x22,0x00,0x1C,0x22,0x02,0x1C,0x20,0x22,0x1C,0x00,
|
||||
0x3E,0x08,0x08,0x08,0x08,0x08,0x08,0x00,0x22,0x22,0x22,0x22,0x22,0x22,0x1C,0x00,
|
||||
0x22,0x22,0x22,0x22,0x22,0x14,0x08,0x00,0x22,0x22,0x22,0x2A,0x2A,0x36,0x22,0x00,
|
||||
0x22,0x22,0x14,0x08,0x14,0x22,0x22,0x00,0x22,0x22,0x14,0x08,0x08,0x08,0x08,0x00,
|
||||
0x3E,0x20,0x10,0x08,0x04,0x02,0x3E,0x00,0x3E,0x06,0x06,0x06,0x06,0x06,0x3E,0x00,
|
||||
0x00,0x02,0x04,0x08,0x10,0x20,0x00,0x00,0x3E,0x30,0x30,0x30,0x30,0x30,0x3E,0x00,
|
||||
0x00,0x00,0x08,0x14,0x22,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,
|
||||
0x04,0x08,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1C,0x20,0x3C,0x22,0x3C,0x00,
|
||||
0x02,0x02,0x1E,0x22,0x22,0x22,0x1E,0x00,0x00,0x00,0x3C,0x02,0x02,0x02,0x3C,0x00,
|
||||
0x20,0x20,0x3C,0x22,0x22,0x22,0x3C,0x00,0x00,0x00,0x1C,0x22,0x3E,0x02,0x3C,0x00,
|
||||
0x18,0x24,0x04,0x1E,0x04,0x04,0x04,0x00,0x00,0x00,0x1C,0x22,0x22,0x3C,0x20,0x1C,
|
||||
0x02,0x02,0x1E,0x22,0x22,0x22,0x22,0x00,0x08,0x00,0x0C,0x08,0x08,0x08,0x1C,0x00,
|
||||
0x10,0x00,0x18,0x10,0x10,0x10,0x12,0x0C,0x02,0x02,0x22,0x12,0x0E,0x12,0x22,0x00,
|
||||
0x0C,0x08,0x08,0x08,0x08,0x08,0x1C,0x00,0x00,0x00,0x36,0x2A,0x2A,0x22,0x22,0x00,
|
||||
0x00,0x00,0x1E,0x22,0x22,0x22,0x22,0x00,0x00,0x00,0x1C,0x22,0x22,0x22,0x1C,0x00,
|
||||
0x00,0x00,0x1E,0x22,0x22,0x1E,0x02,0x02,0x00,0x00,0x3C,0x22,0x22,0x3C,0x20,0x20,
|
||||
0x00,0x00,0x3A,0x06,0x02,0x02,0x02,0x00,0x00,0x00,0x3C,0x02,0x1C,0x20,0x1E,0x00,
|
||||
0x04,0x04,0x1E,0x04,0x04,0x24,0x18,0x00,0x00,0x00,0x22,0x22,0x22,0x32,0x2C,0x00,
|
||||
0x00,0x00,0x22,0x22,0x22,0x14,0x08,0x00,0x00,0x00,0x22,0x22,0x2A,0x2A,0x36,0x00,
|
||||
0x00,0x00,0x22,0x14,0x08,0x14,0x22,0x00,0x00,0x00,0x22,0x22,0x22,0x3C,0x20,0x1C,
|
||||
0x00,0x00,0x3E,0x10,0x08,0x04,0x3E,0x00,0x38,0x0C,0x0C,0x06,0x0C,0x0C,0x38,0x00,
|
||||
0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x0E,0x18,0x18,0x30,0x18,0x18,0x0E,0x00,
|
||||
0x00,0x2C,0x1A,0x00,0x00,0x00,0x00,0x00,0x00,0x2A,0x14,0x2A,0x14,0x2A,0x00,0x00,
|
||||
};
|
||||
void write_glyph(FILE *fp, int c)
|
||||
{
|
||||
uint8_t glyphdef[5], *glyphBits;
|
||||
uint8_t strike[9];
|
||||
int i, left, top, width, height, rowOR;
|
||||
|
||||
glyphBits = (uint8_t *)Apple2Glyphs + (c - GLYPH_FIRST) * 8;
|
||||
height = 8;
|
||||
width = 4;
|
||||
left = 0;
|
||||
top = 7;
|
||||
rowOR = 0;
|
||||
for (i = 0; i < 8; i++)
|
||||
{
|
||||
strike[i] = ((*glyphBits ) & 0x02)
|
||||
| ((*glyphBits | *glyphBits >> 1 | *glyphBits >> 2) & 0x04)
|
||||
| (( *glyphBits >> 2) & 0x08);
|
||||
glyphBits++;
|
||||
rowOR |= strike[i];
|
||||
}
|
||||
if ((rowOR & 0x08) == 0)
|
||||
width--;
|
||||
if ((rowOR & 0x02) == 0)
|
||||
{
|
||||
for (i = 0; i < 8; i++)
|
||||
strike[i] >>= 1;
|
||||
width--;
|
||||
}
|
||||
for (i = 7; i >= 0; i--)
|
||||
{
|
||||
if (strike[i] == 0)
|
||||
{
|
||||
height--;
|
||||
if (i < top)
|
||||
top--;
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
while ((height > 0) && (strike[0] == 0))
|
||||
{
|
||||
height--;
|
||||
top--;
|
||||
for (i = 0; i < height; i++)
|
||||
strike[i] = strike[i + 1];
|
||||
}
|
||||
if (height <= 0)
|
||||
height = 1;
|
||||
if (top <= 0)
|
||||
top = 1;
|
||||
glyphdef[0] = left;
|
||||
glyphdef[1] = -top;
|
||||
glyphdef[2] = width;
|
||||
glyphdef[3] = height;
|
||||
glyphdef[4] = width + left;
|
||||
fwrite(glyphdef, 1, 5, fp);
|
||||
fwrite(strike, 1, height, fp);
|
||||
}
|
||||
void write_font_file(char *filename, char *fontname)
|
||||
{
|
||||
FILE *fp;
|
||||
unsigned char ch;
|
||||
char font_header[16];
|
||||
int glyph_width, glyph_height, c;
|
||||
|
||||
if ((fp = fopen(filename, "wb")))
|
||||
{
|
||||
memset(font_header, 0, 16);
|
||||
strncpy(&font_header[1], fontname, 15);
|
||||
ch = strlen(fontname);
|
||||
font_header[0] = (ch < 16 ? ch : 15) | 0x80; // FONT_PROP
|
||||
fwrite(font_header, 1, 16, fp);
|
||||
glyph_width = 4;
|
||||
glyph_height = 8;
|
||||
ch = GLYPH_FIRST;
|
||||
fwrite(&ch, 1, 1, fp);
|
||||
ch = GLYPH_LAST;
|
||||
fwrite(&ch, 1, 1, fp);
|
||||
ch = fontFormat == glyph_width;
|
||||
fwrite(&ch, 1, 1, fp);
|
||||
ch = glyph_height;
|
||||
fwrite(&ch, 1, 1, fp);
|
||||
for (c = GLYPH_FIRST; c <= GLYPH_LAST; c++)
|
||||
write_glyph(fp, c);
|
||||
fclose(fp);
|
||||
}
|
||||
}
|
||||
void die(char *str)
|
||||
{
|
||||
fprintf(stderr,"error: %s\n", str);
|
||||
exit(-1);
|
||||
}
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
char *font_file;
|
||||
int i;
|
||||
|
||||
font_file = NULL;
|
||||
while (*++argv)
|
||||
{
|
||||
if (argv[0][0] == '-')
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!font_file)
|
||||
font_file = *argv;
|
||||
else
|
||||
fprintf(stderr, "? %s\n", *argv);
|
||||
}
|
||||
}
|
||||
if (!font_file)
|
||||
die( "Missing font file");
|
||||
write_font_file(font_file, "Apple2");
|
||||
return 0;
|
||||
}
|
||||
|
272
src/dhgr.tk/utils/ddfonconv.c
Normal file
272
src/dhgr.tk/utils/ddfonconv.c
Normal file
@@ -0,0 +1,272 @@
|
||||
/*
|
||||
* GS font converter
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
//#include <stdbit.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#define FONT_WIDTH 32
|
||||
#define FONT_HEIGHT 12
|
||||
#define GLYPH_FIRST 32
|
||||
#define GLYPH_LAST 127
|
||||
#define GLYPH_COUNT (GLYPH_LAST-GLYPH_FIRST+1)
|
||||
struct macfont {
|
||||
uint16_t fontType;
|
||||
uint16_t firstChar;
|
||||
uint16_t lastChar;
|
||||
uint16_t widMax;
|
||||
uint16_t kernMax;
|
||||
uint16_t nDescent;
|
||||
uint16_t rectWidth;
|
||||
uint16_t rectHeight;
|
||||
uint16_t owTLoc;
|
||||
uint16_t ascent;
|
||||
uint16_t descent;
|
||||
uint16_t leading;
|
||||
uint16_t rowWords;
|
||||
uint16_t bitImage; // [rowWords * rectHeight] (fonstStrike)
|
||||
//uint16_t rlocTable; // lastChar - firstChar + 3 : pixel offset of glyph in bitImage
|
||||
//uint16_t owTable; lastChar - firstChar + 3 : offset/width table
|
||||
};
|
||||
struct gsfont *gsf;
|
||||
struct macfont *macf;
|
||||
int16_t *locTable;
|
||||
uint16_t *owTable;
|
||||
/*
|
||||
* Bit reversals
|
||||
*/
|
||||
unsigned char bitReverse[256];
|
||||
unsigned char clrSwap[256];
|
||||
unsigned char clrRot[] = {0x00,0x02,0x04,0x06,0x08,0x0A,0x0C,0x0E,
|
||||
0x01,0x03,0x05,0x07,0x09,0x0B,0x0D,0x0F};
|
||||
void write_glyph(FILE *fp, int c)
|
||||
{
|
||||
uint8_t glyphdef[5], *swapbuf, *glyphBits;
|
||||
uint32_t rowbits;
|
||||
int pixOffset, pixWidth, byteWidth, byteOffset, bitShift, bitWidth, glyphSpan, i;
|
||||
int left, top, width, height;
|
||||
|
||||
if (c < macf->firstChar || c > macf->lastChar)
|
||||
{
|
||||
memset(glyphdef, 0, 5);
|
||||
fwrite(&glyphdef, 1, 5, fp);
|
||||
return;
|
||||
}
|
||||
c -= macf->firstChar;
|
||||
glyphBits = (uint8_t *)&(macf->bitImage),
|
||||
glyphSpan = macf->rowWords * 2;
|
||||
height = macf->rectHeight;
|
||||
width = owTable[c] & 0xFF;
|
||||
left = owTable[c] >> 8;
|
||||
top = macf->ascent;
|
||||
|
||||
glyphdef[0] = left;
|
||||
glyphdef[1] = -top;
|
||||
#if PIXFONT
|
||||
glyphdef[2] = (width + 3) / 4;
|
||||
#else
|
||||
glyphdef[2] = width;
|
||||
#endif
|
||||
glyphdef[3] = height;
|
||||
glyphdef[4] = width + left;
|
||||
fwrite(&glyphdef, 1, 5, fp);
|
||||
|
||||
pixOffset = locTable[c];
|
||||
pixWidth = locTable[c+1] - locTable[c];
|
||||
byteOffset = pixOffset / 8;
|
||||
bitShift = pixOffset & 7;
|
||||
bitWidth = bitShift + pixWidth;
|
||||
byteWidth = (width + 7) / 8;
|
||||
rowbits = 0;
|
||||
while (height--)
|
||||
{
|
||||
if (pixWidth > 0)
|
||||
{
|
||||
rowbits = bitReverse[glyphBits[byteOffset]];
|
||||
if (bitWidth > 8)
|
||||
{
|
||||
rowbits |= bitReverse[glyphBits[byteOffset + 1]] << 8;
|
||||
if (bitWidth > 16)
|
||||
{
|
||||
rowbits |= bitReverse[glyphBits[byteOffset + 2]] << 16;
|
||||
if (bitWidth > 24)
|
||||
rowbits |= bitReverse[glyphBits[byteOffset + 3]] << 24;
|
||||
}
|
||||
}
|
||||
rowbits >>= bitShift;
|
||||
rowbits &= 0xFFFFFFFF >> (32 - pixWidth);
|
||||
}
|
||||
#if PIXFONT
|
||||
glyphdef[0] = clrSwap[rowbits & 0xFF];
|
||||
glyphdef[1] = clrSwap[(rowbits >> 8) & 0xFF];
|
||||
glyphdef[2] = clrSwap[(rowbits >> 16) & 0xFF];
|
||||
glyphdef[3] = clrSwap[(rowbits >> 24) & 0xFF];
|
||||
#else
|
||||
glyphdef[0] = rowbits;
|
||||
glyphdef[1] = rowbits >> 8;
|
||||
glyphdef[2] = rowbits >> 16;
|
||||
glyphdef[3] = rowbits >> 24;
|
||||
#endif
|
||||
fwrite(&glyphdef, 1, byteWidth, fp);
|
||||
glyphBits += glyphSpan;
|
||||
}
|
||||
}
|
||||
void write_font_file(char *filename, char *fontfile)
|
||||
{
|
||||
FILE *fp;
|
||||
unsigned char ch;
|
||||
char *fontname, *scanname, font_header[16];
|
||||
int glyph_width, glyph_height, c;
|
||||
|
||||
if ((fp = fopen(filename, "wb")))
|
||||
{
|
||||
fontname = scanname = fontfile;
|
||||
while (*scanname) // Strip leading directory names
|
||||
{
|
||||
if (*scanname == '/')
|
||||
fontname = scanname + 1;
|
||||
scanname++;
|
||||
}
|
||||
while (scanname > fontfile)
|
||||
{
|
||||
if (*scanname == '.')
|
||||
{
|
||||
*scanname = '\0';
|
||||
}
|
||||
scanname--;
|
||||
}
|
||||
memset(font_header, 0, 16);
|
||||
strncpy(&font_header[1], fontname, 15);
|
||||
ch = strlen(fontname);
|
||||
font_header[0] = ch < 16 ? ch : 15;
|
||||
#if PIXFONT
|
||||
font_header[0] |= 0x80 | 0x40; // FONT_PROP | FONT_PIXMAP
|
||||
#else
|
||||
font_header[0] |= 0x80; // FONT_PROP
|
||||
#endif
|
||||
fwrite(font_header, 1, 16, fp);
|
||||
glyph_width = macf->rectWidth;
|
||||
glyph_height = macf->rectHeight;
|
||||
ch = GLYPH_FIRST;
|
||||
fwrite(&ch, 1, 1, fp);
|
||||
ch = GLYPH_LAST;
|
||||
fwrite(&ch, 1, 1, fp);
|
||||
#if PIXFONT
|
||||
ch = (glyph_width + 3) / 4;
|
||||
#else
|
||||
ch = glyph_width;
|
||||
#endif
|
||||
fwrite(&ch, 1, 1, fp);
|
||||
ch = glyph_height;
|
||||
fwrite(&ch, 1, 1, fp);
|
||||
for (c = GLYPH_FIRST; c <= GLYPH_LAST; c++)
|
||||
write_glyph(fp, c);
|
||||
fclose(fp);
|
||||
}
|
||||
}
|
||||
void die(char *str)
|
||||
{
|
||||
fprintf(stderr,"error: %s\n", str);
|
||||
exit(-1);
|
||||
}
|
||||
void dispGlyph(uint8_t *glyphBits, int glyphSpan, int width, int height)
|
||||
{
|
||||
uint32_t rowbits;
|
||||
int byteOffset, bitShift, bitWidth, i;
|
||||
|
||||
while (height--)
|
||||
{
|
||||
rowbits = glyphBits[0];
|
||||
if (width > 8)
|
||||
{
|
||||
rowbits |= glyphBits[1] << 8;
|
||||
if (width > 16)
|
||||
{
|
||||
rowbits |= glyphBits[2] << 16;
|
||||
if (width > 24)
|
||||
rowbits |= glyphBits[3] << 24;
|
||||
}
|
||||
}
|
||||
for (i = 0; i < width; i++)
|
||||
{
|
||||
putchar(rowbits & 1 ? '*' : ' ');
|
||||
rowbits >>= 1;
|
||||
}
|
||||
puts("");
|
||||
glyphBits += glyphSpan;
|
||||
}
|
||||
}
|
||||
void load_dazzledraw_file(char *filename)
|
||||
{
|
||||
FILE *fp;
|
||||
uint8_t *fontdef;
|
||||
int fontdefsize, c, i, s;
|
||||
char msg[] = "Hello, world";
|
||||
|
||||
if ((fp = fopen(filename, "rb")))
|
||||
{
|
||||
fontdef = malloc(65536);
|
||||
fontdefsize = fread(fontdef, 1, 65536, fp);
|
||||
fclose(fp);
|
||||
}
|
||||
else
|
||||
die("Unable to open DazzleDraw font file");
|
||||
locTable = (int16_t *)fontdef;
|
||||
for (c = 32; c < 127; c++)
|
||||
{
|
||||
i = locTable[c] - 0x1000 + 0x100;
|
||||
printf("%c[%3d]: $%04X - $%04X (%d)\n", c, c, i, locTable[c + 1] - 1, locTable[c + 1] - locTable[c]);
|
||||
printf("\t$%02X, %d, %d [%d]\n", fontdef[i], fontdef[i + 1], fontdef[i + 2], (fontdef[i] & 0x0F) * fontdef[i + 1] + 3);
|
||||
dispGlyph(fontdef + i + 4, fontdef[i + 1], fontdef[i + 2], fontdef[i] & 0x0F);
|
||||
}
|
||||
}
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
char *dd_file, *font_file;
|
||||
int glyph_width, glyph_height;
|
||||
int i;
|
||||
|
||||
font_file = NULL;
|
||||
if (argc > 1)
|
||||
{
|
||||
dd_file = argv[1];
|
||||
if (argc > 2)
|
||||
font_file = argv[2];
|
||||
if (argc > 3)
|
||||
glyph_width = atoi(argv[3]);
|
||||
else
|
||||
glyph_width = FONT_WIDTH;
|
||||
if (argc > 4)
|
||||
glyph_height = atoi(argv[4]);
|
||||
else
|
||||
glyph_height = FONT_HEIGHT;
|
||||
}
|
||||
else
|
||||
die( "Missing font file");
|
||||
/*
|
||||
* Bit/color reversal
|
||||
*/
|
||||
for (i = 0; i < 256; i++)
|
||||
{
|
||||
bitReverse[i] = ((i & 0x01) << 7)
|
||||
| ((i & 0x02) << 5)
|
||||
| ((i & 0x04) << 3)
|
||||
| ((i & 0x08) << 1)
|
||||
| ((i & 0x10) >> 1)
|
||||
| ((i & 0x20) >> 3)
|
||||
| ((i & 0x40) >> 5)
|
||||
| ((i & 0x80) >> 7);
|
||||
clrSwap[i] = clrRot[i & 0x0F]
|
||||
| (clrRot[i >> 4] << 4);
|
||||
}
|
||||
/*
|
||||
* Load IIGS font file header.
|
||||
*/
|
||||
load_dazzledraw_file(dd_file);
|
||||
//write_font_file(font_file, "DazzleDraw");
|
||||
return 0;
|
||||
}
|
||||
|
148
src/dhgr.tk/utils/dhgreasy.pla
Normal file
148
src/dhgr.tk/utils/dhgreasy.pla
Normal file
@@ -0,0 +1,148 @@
|
||||
include "inc/cmdsys.plh"
|
||||
include "inc/args.plh"
|
||||
include "inc/fileio.plh"
|
||||
include "dhgr.tk/inc/dhgrlib.plh"
|
||||
include "dhgr.tk/inc/dhgrutils.plh"
|
||||
|
||||
sysflags restxt1|resxtxt1|reshgr1|resxhgr1 // Reserve all the pages
|
||||
|
||||
const PAUSE = 1
|
||||
const HEIGHT_X2 = 2
|
||||
|
||||
char[64] greasyfile = ""
|
||||
byte[40*96/2] frame
|
||||
byte flags
|
||||
byte frameHeight = 40
|
||||
|
||||
var arg
|
||||
|
||||
def greasy2dcgr(pGreasy)#0
|
||||
byte i, j, cl, ch
|
||||
var pPixmap
|
||||
|
||||
pPixmap = @frame
|
||||
for j = 0 to frameHeight-1 step 2
|
||||
for i = 0 to 39 step 2
|
||||
cl = ^(pGreasy + i)
|
||||
ch = ^(pGreasy + i + 1)
|
||||
^(pPixmap + i / 2) = (cl & $0F) | (ch << 4)
|
||||
if flags & HEIGHT_X2
|
||||
^(pPixmap + i / 2 + 20) = (cl & $0F) | (ch << 4)
|
||||
^(pPixmap + i / 2 + 40) = (cl >> 4) | (ch & $F0)
|
||||
^(pPixmap + i / 2 + 60) = (cl >> 4) | (ch & $F0)
|
||||
else
|
||||
^(pPixmap + i / 2 + 20) = (cl >> 4) | (ch & $F0)
|
||||
fin
|
||||
next
|
||||
if flags & HEIGHT_X2
|
||||
pPixmap = pPixmap + 80
|
||||
else
|
||||
pPixmap = pPixmap + 40
|
||||
fin
|
||||
pGreasy = pGreasy + 40
|
||||
next
|
||||
end
|
||||
|
||||
def greasyRead(filestr, frame)#1
|
||||
var sprptr, sprsize
|
||||
byte refnum, numframes
|
||||
|
||||
sprptr = 0
|
||||
refnum = fileio:open(filestr)
|
||||
if refnum
|
||||
sprsize = 40 * frameHeight / 2
|
||||
sprptr = heapalloc(sprsize)
|
||||
if sprptr and fileio:read(refnum, @numframes, 1)
|
||||
if numframes < frame
|
||||
heaprelease(sprptr)
|
||||
sprptr = NULL
|
||||
fin
|
||||
fin
|
||||
if sprptr
|
||||
if fileio:setmark(refnum, (frame - 1) * sprsize + 1, 0)
|
||||
heaprelease(sprptr)
|
||||
sprptr = NULL
|
||||
elsif fileio:read(refnum, sprptr, sprsize) <> sprsize
|
||||
heaprelease(sprptr)
|
||||
sprptr = NULL
|
||||
fin
|
||||
fin
|
||||
fileio:close(refnum)
|
||||
fin
|
||||
return sprptr
|
||||
end
|
||||
|
||||
def importGreasy#0
|
||||
var grptr
|
||||
byte screennum, framenum, i, j, numrows
|
||||
char[64] screenfile
|
||||
|
||||
screennum = 1
|
||||
framenum = 1
|
||||
dhgrMode(DHGR_COLOR_MODE)
|
||||
numrows = 192 / frameHeight
|
||||
if flags & HEIGHT_X2
|
||||
numrows = numrows / 2
|
||||
fin
|
||||
numrows--
|
||||
while framenum
|
||||
dcgrColor(CLR_GREY1)
|
||||
dhgrClearBl7(0, 0, SCR_WIDTH7, SCR_HEIGHT)
|
||||
for j = 0 to numrows
|
||||
for i = 0 to 2
|
||||
grptr = greasyRead(@greasyfile, framenum)
|
||||
if grptr
|
||||
greasy2dcgr(grptr)
|
||||
heaprelease(grptr)
|
||||
if flags & HEIGHT_X2
|
||||
dcgrPixMap(i*42+8, j*(frameHeight+1)*2+2, 40, frameHeight*2, @frame)
|
||||
else
|
||||
dcgrPixMap(i*42+8, j*(frameHeight+2)+2, 40, frameHeight, @frame)
|
||||
fin
|
||||
framenum++
|
||||
else
|
||||
framenum = 0
|
||||
break
|
||||
fin
|
||||
next
|
||||
if framenum == 0; break; fin
|
||||
next
|
||||
strcpy(@screenfile, @greasyfile)
|
||||
strcat(@screenfile, ".SCR")
|
||||
screenfile++
|
||||
screenfile[screenfile] = '0' + screennum
|
||||
screennum++
|
||||
if screenWrite(@screenfile)
|
||||
dhgrMode(DHGR_TEXT_MODE)
|
||||
puts("Error writing: "); puts(@screenfile); putln
|
||||
return
|
||||
fin
|
||||
if flags & PAUSE; getc; fin
|
||||
loop
|
||||
dhgrMode(DHGR_TEXT_MODE)
|
||||
end
|
||||
|
||||
arg = argNext(argFirst)
|
||||
if ^arg
|
||||
while arg and ^(arg + 1) == '-'
|
||||
when toupper(^(arg + 2))
|
||||
is 'P'
|
||||
flags = flags | PAUSE
|
||||
break
|
||||
is '2'
|
||||
flags = flags | HEIGHT_X2
|
||||
break
|
||||
is 'T'
|
||||
frameHeight = 48
|
||||
break
|
||||
wend
|
||||
arg = argNext(arg)
|
||||
loop
|
||||
if ^arg
|
||||
strcpy(@greasyfile, arg)
|
||||
importGreasy
|
||||
return 0
|
||||
fin
|
||||
fin
|
||||
puts("Usage: DHGRGREASY [-P] [-2] [-T] FRAMEFILE\n")
|
||||
done
|
843
src/dhgr.tk/utils/dhgrrgb-full.pla
Normal file
843
src/dhgr.tk/utils/dhgrrgb-full.pla
Normal file
@@ -0,0 +1,843 @@
|
||||
include "inc/cmdsys.plh"
|
||||
include "inc/args.plh"
|
||||
include "inc/fileio.plh"
|
||||
include "inc/int32.plh"
|
||||
include "dhgr.tk/inc/dhgrlib.plh"
|
||||
include "dhgr.tk/inc/dhgrutils.plh"
|
||||
|
||||
sysflags resxtxt1|reshgr1|resxhgr1
|
||||
|
||||
// Bit patterns and associated default NTSC colors
|
||||
// NTSC_BLACK = 0000
|
||||
// NTSC_DRKBLUE = 0001 73, 14, 116
|
||||
// NTSC_DRKGREEN = 0010 0, 104, 100
|
||||
// NTSC_BROWN = 0100 55, 113, 11
|
||||
// NTSC_MAGENTA = 1000 127, 23, 27
|
||||
// NTSC_PURPLE = 1001
|
||||
// NTSC_MEDBLUE = 0011
|
||||
// NTSC_LTBLUE = 1011
|
||||
// NTSC_AQUA = 0111
|
||||
// NTSC_GREEN = 0110
|
||||
// NTSC_ORANGE = 1100
|
||||
// NTSC_PINK = 1101
|
||||
// NTSC_YELLOW = 1110
|
||||
// NTSC_WHITE = 1111
|
||||
|
||||
const RED = 0
|
||||
const GRN = 1
|
||||
const BLU = 2
|
||||
// According to what I could find out about the NTSC color wheel:
|
||||
// Red maxes at 103.5 degrees
|
||||
// Green maxes at 240.7 degrees
|
||||
// Blue maxes at 347.1 degrees
|
||||
const RED_PHASE_NTSC = 104
|
||||
const GREEN_PHASE_NTSC = 241
|
||||
const BLUE_PHASE_NTSC = 347
|
||||
// Ideal phase angles for 4 phase
|
||||
const RED_PHASE_IDEAL = 90
|
||||
const GREEN_PHASE_IDEAL = 270
|
||||
const BLUE_PHASE_IDEAL = 360
|
||||
// Equal 120 deg phase angles
|
||||
const RED_PHASE_EQUAL = 120
|
||||
const GREEN_PHASE_EQUAL = 240
|
||||
const BLUE_PHASE_EQUAL = 360
|
||||
// Simplified phase angles: 90 deg between R and B, 135 between RG and BG
|
||||
const RED_PHASE_SIMPLE = 90
|
||||
const GREEN_PHASE_SIMPLE = 225
|
||||
const BLUE_PHASE_SIMPLE = 360
|
||||
const GREY_CHROMA = 32 * 4 / 3
|
||||
// Flags
|
||||
const GREY_HACK = $01 // Remap GREY1->GREY2 hack
|
||||
const MEM_MODE = $02 // Render to memory surface
|
||||
const DUMP_STATE = $04 // Dump internal state
|
||||
const RAW_INFILE = $08 // Raw 560x192 24BPP RGB values
|
||||
const MATCH_PREV = $00 // Match previous RGB
|
||||
const MATCH_NEXT = $10 // Match next pixel
|
||||
const MATCH_CYCLE = $20 // Match current cycle
|
||||
const MATCH_ONE = 8
|
||||
const MATCH_ZERO = 0
|
||||
byte clrRot = $00,$02,$04,$06,$08,$0A,$0C,$0E
|
||||
byte = $01,$03,$05,$07,$09,$0B,$0D,$0F
|
||||
var sin90[] // first 90 degrees of sin in fixed s.15 format
|
||||
var = 0, 571, 1143, 1714, 2285, 2855, 3425, 3993
|
||||
var = 4560, 5126, 5690, 6252, 6812, 7371, 7927, 8480
|
||||
var = 9032, 9580, 10125, 10668, 11207, 11743, 12275, 12803
|
||||
var = 13327, 13848, 14364, 14876, 15383, 15886, 16383, 16876
|
||||
var = 17364, 17846, 18323, 18794, 19260, 19720, 20173, 20621
|
||||
var = 21062, 21497, 21926, 22347, 22762, 23170, 23571, 23964
|
||||
var = 24351, 24730, 25101, 25465, 25821, 26169, 26509, 26841
|
||||
var = 27165, 27481, 27788, 28087, 28377, 28659, 28932, 29196
|
||||
var = 29451, 29697, 29935, 30163, 30381, 30591, 30791, 30982
|
||||
var = 31164, 31336, 31498, 31651, 31794, 31928, 32051, 32165
|
||||
var = 32270, 32364, 32449, 32523, 32588, 32643, 32688, 32723
|
||||
var = 32748, 32763, 32767
|
||||
word hgrScan[] // HGR scanline order for saving memory buffer as DHGR
|
||||
word = $0000,$0400,$0800,$0C00,$1000,$1400,$1800,$1C00
|
||||
word = $0080,$0480,$0880,$0C80,$1080,$1480,$1880,$1C80
|
||||
word = $0100,$0500,$0900,$0D00,$1100,$1500,$1900,$1D00
|
||||
word = $0180,$0580,$0980,$0D80,$1180,$1580,$1980,$1D80
|
||||
word = $0200,$0600,$0A00,$0E00,$1200,$1600,$1A00,$1E00
|
||||
word = $0280,$0680,$0A80,$0E80,$1280,$1680,$1A80,$1E80
|
||||
word = $0300,$0700,$0B00,$0F00,$1300,$1700,$1B00,$1F00
|
||||
word = $0380,$0780,$0B80,$0F80,$1380,$1780,$1B80,$1F80
|
||||
word = $0028,$0428,$0828,$0C28,$1028,$1428,$1828,$1C28
|
||||
word = $00A8,$04A8,$08A8,$0CA8,$10A8,$14A8,$18A8,$1CA8
|
||||
word = $0128,$0528,$0928,$0D28,$1128,$1528,$1928,$1D28
|
||||
word = $01A8,$05A8,$09A8,$0DA8,$11A8,$15A8,$19A8,$1DA8
|
||||
word = $0228,$0628,$0A28,$0E28,$1228,$1628,$1A28,$1E28
|
||||
word = $02A8,$06A8,$0AA8,$0EA8,$12A8,$16A8,$1AA8,$1EA8
|
||||
word = $0328,$0728,$0B28,$0F28,$1328,$1728,$1B28,$1F28
|
||||
word = $03A8,$07A8,$0BA8,$0FA8,$13A8,$17A8,$1BA8,$1FA8
|
||||
word = $0050,$0450,$0850,$0C50,$1050,$1450,$1850,$1C50
|
||||
word = $00D0,$04D0,$08D0,$0CD0,$10D0,$14D0,$18D0,$1CD0
|
||||
word = $0150,$0550,$0950,$0D50,$1150,$1550,$1950,$1D50
|
||||
word = $01D0,$05D0,$09D0,$0DD0,$11D0,$15D0,$19D0,$1DD0
|
||||
word = $0250,$0650,$0A50,$0E50,$1250,$1650,$1A50,$1E50
|
||||
word = $02D0,$06D0,$0AD0,$0ED0,$12D0,$16D0,$1AD0,$1ED0
|
||||
word = $0350,$0750,$0B50,$0F50,$1350,$1750,$1B50,$1F50
|
||||
word = $03D0,$07D0,$0BD0,$0FD0,$13D0,$17D0,$1BD0,$1FD0
|
||||
var surfMem, surfSpan
|
||||
var rgbMatch
|
||||
var[12] ntscChroma
|
||||
var[12] ntscCycle
|
||||
var[16] pixRed, pixGrn, pixBlu
|
||||
var prevRed, prevBlu, prevGrn
|
||||
byte[256] gammaRed // RED gamma correction
|
||||
byte[256] gammaGrn // GREEN gamma correction
|
||||
byte[256] gammaBlu // BLUE gamma correction
|
||||
var[3] phase = RED_PHASE_NTSC, GREEN_PHASE_NTSC, BLUE_PHASE_NTSC
|
||||
byte[3] gamut = 128, 128, 128 // Gamut
|
||||
byte gamma = 1 // Gamma correction
|
||||
var brightness = 0
|
||||
var saturation = 255 // 1.0
|
||||
var tint = 22 // = 45/2 deg
|
||||
byte errDiv = 4
|
||||
byte flags = GREY_HACK
|
||||
var rgbErr // Running color error array
|
||||
var arg
|
||||
|
||||
// Handy numeric functions
|
||||
|
||||
def min(a, b)#1
|
||||
return a < b ?? a :: b
|
||||
end
|
||||
|
||||
def max(a, b)#1
|
||||
return a > b ?? a :: b
|
||||
end
|
||||
|
||||
def sin(deg)#1
|
||||
while deg > 360; deg = deg - 360; loop
|
||||
while deg < 0; deg = deg + 360; loop
|
||||
if deg <= 90
|
||||
return sin90[deg]
|
||||
elsif deg <= 180
|
||||
return sin90[180 - deg]
|
||||
elsif deg <= 270
|
||||
return -sin90[deg - 180]
|
||||
fin
|
||||
return -sin90[360 - deg]
|
||||
end
|
||||
|
||||
def cos(deg)#1
|
||||
return sin(deg + 90)
|
||||
end
|
||||
|
||||
def dist(dr, dg, db)#2 // Linear distance
|
||||
res[t_i32] rr, gg
|
||||
|
||||
loadi16(dr)
|
||||
muli16(dr)
|
||||
store32(@rr)
|
||||
loadi16(dg)
|
||||
muli16(dg)
|
||||
store32(@gg)
|
||||
loadi16(db)
|
||||
muli16(db)
|
||||
add32(@gg)
|
||||
add32(@rr)
|
||||
store32(@rr)
|
||||
return rr:[0], rr:[1]
|
||||
end
|
||||
|
||||
def atoi(strptr)#1
|
||||
var num, len, sign
|
||||
|
||||
sign = 1
|
||||
num = 0
|
||||
len = ^strptr
|
||||
strptr++
|
||||
if ^strptr == '-'
|
||||
sign = -1
|
||||
strptr++
|
||||
len--
|
||||
elsif ^strptr == '+'
|
||||
strptr++
|
||||
len--
|
||||
fin
|
||||
while len and ^strptr >= '0' and ^strptr <= '9'
|
||||
num = num * 10 + ^strptr - '0'
|
||||
strptr++
|
||||
len--
|
||||
loop
|
||||
return num * sign
|
||||
end
|
||||
|
||||
def calcChroma(angle)#0
|
||||
var r, g, b
|
||||
byte i
|
||||
|
||||
for i = 0 to 3
|
||||
// Calculate RGB for this DHGR pixel
|
||||
//r = max(0, (saturation + (cos(angle - phase[RED]) >> 7)))
|
||||
//g = max(0, (saturation + (cos(angle - phase[GRN]) >> 7)))
|
||||
//b = max(0, (saturation + (cos(angle - phase[BLU]) >> 7)))
|
||||
r = saturation + (cos(angle - phase[RED]) >> 7)
|
||||
g = saturation + (cos(angle - phase[GRN]) >> 7)
|
||||
b = saturation + (cos(angle - phase[BLU]) >> 7)
|
||||
// Make chroma add up to white
|
||||
ntscChroma[i*3 + RED] = (r + 2) / 4
|
||||
ntscChroma[i*3 + GRN] = (g + 2) / 4
|
||||
ntscChroma[i*3 + BLU] = (b + 2) / 4
|
||||
// Next NTSC chroma pixel
|
||||
angle = angle - 90
|
||||
next
|
||||
end
|
||||
|
||||
def errProp(er, eg, eb, errptr)#0
|
||||
// Propogate error down and forward
|
||||
errptr=>[RED] = er
|
||||
errptr=>[GRN] = eg
|
||||
errptr=>[BLU] = eb
|
||||
errptr = errptr + 6
|
||||
errptr=>[RED] = er + errptr=>[RED]
|
||||
errptr=>[GRN] = eg + errptr=>[GRN]
|
||||
errptr=>[BLU] = eb + errptr=>[BLU]
|
||||
end
|
||||
|
||||
def rgbMatchCycle(r, g, b, errptr, cx)#1
|
||||
var pr1, pg1, pb1
|
||||
var pr2, pg2, pb2
|
||||
var pr3, pg3, pb3
|
||||
var nr, ng, nb
|
||||
var pr, pg, pb
|
||||
var cr, cg, cb
|
||||
var er, eg, eb
|
||||
byte i, match
|
||||
res[t_i32] pd, d0, nd, cd
|
||||
|
||||
// Previous 1/4 chroma cycle
|
||||
i = ((cx - 1) & 3) * 3
|
||||
pr1 = ntscCycle[i+RED]
|
||||
pg1 = ntscCycle[i+GRN]
|
||||
pb1 = ntscCycle[i+BLU]
|
||||
// Previous 2/4 chroma cycle
|
||||
i = ((cx - 2) & 3) * 3
|
||||
pr2 = ntscCycle[i+RED] + pr1
|
||||
pg2 = ntscCycle[i+GRN] + pg1
|
||||
pb2 = ntscCycle[i+BLU] + pb1
|
||||
// Previous 3/4 chroma cycle
|
||||
i = ((cx - 3) & 3) * 3
|
||||
pr3 = ntscCycle[i+RED] + pr2
|
||||
pg3 = ntscCycle[i+GRN] + pg2
|
||||
pb3 = ntscCycle[i+BLU] + pb2
|
||||
// Previous chroma cycle
|
||||
i = cx * 3 // ((cx - 4) & 3) * 3
|
||||
pr = (pr1 + pr2 + pr3 + ntscCycle[i+RED] / 2) / 4
|
||||
pg = (pg1 + pg2 + pg3 + ntscCycle[i+GRN] / 2) / 4
|
||||
pb = (pb1 + pb2 + pb3 + ntscCycle[i+BLU] / 2) / 4
|
||||
// Current potential chroma cycle
|
||||
//i = cx * 3
|
||||
cr = pr + ntscChroma[i+RED]
|
||||
cg = pg + ntscChroma[i+GRN]
|
||||
cb = pb + ntscChroma[i+BLU]
|
||||
// Match next chroma subcycle
|
||||
pd:[0], pd:[1] = dist(r - pr, g - pg, b - pb)
|
||||
dist(r - cr, g - cg, b - cb)
|
||||
if islt32(@pd)
|
||||
// RGB better matched with next chroma color
|
||||
er = r - cr
|
||||
eg = g - cg
|
||||
eb = b - cb
|
||||
ntscCycle[i+RED] = ntscChroma[i+RED]
|
||||
ntscCycle[i+GRN] = ntscChroma[i+GRN]
|
||||
ntscCycle[i+BLU] = ntscChroma[i+BLU]
|
||||
i = MATCH_ONE
|
||||
else
|
||||
// RGB closer to previous chroma color
|
||||
er = r - pr
|
||||
eg = g - pg
|
||||
eb = b - pb
|
||||
ntscCycle[i+RED] = 0
|
||||
ntscCycle[i+GRN] = 0
|
||||
ntscCycle[i+BLU] = 0
|
||||
i = MATCH_ZERO
|
||||
fin
|
||||
errProp(er, eg, eb, errptr)
|
||||
return i
|
||||
end
|
||||
|
||||
def rgbMatchNext(r, g, b, errptr, cx)#1
|
||||
var pr1, pg1, pb1
|
||||
var pr2, pg2, pb2
|
||||
var pr3, pg3, pb3
|
||||
var pr, pg, pb
|
||||
var cr, cg, cb
|
||||
var er, eg, eb
|
||||
byte i, match
|
||||
res[t_i32] nd, cd
|
||||
|
||||
// Previous 1/4 chroma cycle
|
||||
i = ((cx - 1) & 3) * 3
|
||||
pr1 = ntscCycle[i+RED]
|
||||
pg1 = ntscCycle[i+GRN]
|
||||
pb1 = ntscCycle[i+BLU]
|
||||
// Previous 2/4 chroma cycle
|
||||
i = ((cx - 2) & 3) * 3
|
||||
pr2 = ntscCycle[i+RED]
|
||||
pg2 = ntscCycle[i+GRN]
|
||||
pb2 = ntscCycle[i+BLU]
|
||||
// Previous 3/4 chroma cycle
|
||||
i = ((cx - 3) & 3) * 3
|
||||
pr3 = ntscCycle[i+RED]
|
||||
pg3 = ntscCycle[i+GRN]
|
||||
pb3 = ntscCycle[i+BLU]
|
||||
// Previous chroma cycle
|
||||
i = cx * 3 // ((cx - 4) & 3) * 3
|
||||
pr = pr1 + pr2 + pr3
|
||||
pg = pg1 + pg2 + pg3
|
||||
pb = pb1 + pb2 + pb3
|
||||
// Current potential chroma cycle
|
||||
//i = cx * 3
|
||||
cr = pr + ntscChroma[i+RED]
|
||||
cg = pg + ntscChroma[i+GRN]
|
||||
cb = pb + ntscChroma[i+BLU]
|
||||
// Match next full chroma cycle (pixel)
|
||||
cd:[0], cd:[1] = $FFFF, $7FFF
|
||||
for i = 0 to 15
|
||||
nd:[0], nd:[1] = dist(r - pixRed[i], g - pixGrn[i], b - pixBlu[i])
|
||||
if islt32(@cd)
|
||||
cd:[0], cd:[1] = nd:[0], nd:[1]
|
||||
match = i
|
||||
fin
|
||||
next
|
||||
i = cx * 3
|
||||
if match & (1 << cx)
|
||||
// RGB better matched with next chroma color
|
||||
er = r - cr
|
||||
eg = g - cg
|
||||
eb = b - cb
|
||||
ntscCycle[i+RED] = ntscChroma[i+RED]
|
||||
ntscCycle[i+GRN] = ntscChroma[i+GRN]
|
||||
ntscCycle[i+BLU] = ntscChroma[i+BLU]
|
||||
i = MATCH_ONE
|
||||
else
|
||||
// RGB closer to previous chroma color
|
||||
er = r - pr
|
||||
eg = g - pg
|
||||
eb = b - pb
|
||||
ntscCycle[i+RED] = 0
|
||||
ntscCycle[i+GRN] = 0
|
||||
ntscCycle[i+BLU] = 0
|
||||
i = MATCH_ZERO
|
||||
fin
|
||||
errProp(er, eg, eb, errptr)
|
||||
return i
|
||||
end
|
||||
|
||||
def rgbMatchPrev(r, g, b, errptr, cx)#1
|
||||
var cr, cg, cb
|
||||
var er, eg, eb
|
||||
byte i,
|
||||
res[t_i32] pd
|
||||
|
||||
// Previous RGB minus current chroma cycle
|
||||
prevRed = (prevRed * 3) / 4
|
||||
prevGrn = (prevGrn * 3) / 4
|
||||
prevBlu = (prevBlu * 3) / 4
|
||||
// Current potential RGB
|
||||
i = cx * 3
|
||||
cr = prevRed + ntscChroma[i+RED]
|
||||
cg = prevGrn + ntscChroma[i+GRN]
|
||||
cb = prevBlu + ntscChroma[i+BLU]
|
||||
// Match next chroma subcycle
|
||||
pd:[0], pd:[1] = dist(r - prevRed, g - prevGrn, b - prevBlu)
|
||||
dist(r - cr, g - cg, b - cb)
|
||||
if islt32(@pd)
|
||||
// RGB better matched with next chroma color
|
||||
prevRed = cr
|
||||
prevGrn = cg
|
||||
prevBlu = cb
|
||||
i = MATCH_ONE
|
||||
else
|
||||
i = MATCH_ZERO
|
||||
fin
|
||||
// Propogate error down and forward
|
||||
er = r - prevRed
|
||||
errptr=>[RED] = er
|
||||
eg = g - prevGrn
|
||||
errptr=>[GRN] = eg
|
||||
eb = b - prevBlu
|
||||
errptr=>[BLU] = eb
|
||||
errptr=>[RED+3] = er + errptr=>[RED+3]
|
||||
errptr=>[GRN+3] = eg + errptr=>[GRN+3]
|
||||
errptr=>[BLU+3] = eb + errptr=>[BLU+3]
|
||||
return i
|
||||
end
|
||||
|
||||
def rgbInit#0
|
||||
var i
|
||||
res[t_i32] g32
|
||||
|
||||
if flags & DUMP_STATE
|
||||
puts("Gamma = "); puti(sext(gamma)); putln
|
||||
fin
|
||||
when gamma
|
||||
is 255 // (i + 1 / i^2) / 2
|
||||
for i = 0 to 255
|
||||
loadi16(i)
|
||||
muli16(i)
|
||||
addi16(127)
|
||||
divi16(255)
|
||||
neg32
|
||||
addi16(255)
|
||||
addi16(255 - i)
|
||||
divi16(2)
|
||||
store32(@g32)
|
||||
gammaRed[255 - i] = g32
|
||||
gammaGrn[255 - i] = g32
|
||||
gammaBlu[255 - i] = g32
|
||||
next
|
||||
break
|
||||
is 254 // 1 - i^2
|
||||
for i = 0 to 255
|
||||
loadi16(i)
|
||||
muli16(i)
|
||||
addi16(127)
|
||||
divi16(255)
|
||||
neg32
|
||||
addi16(255)
|
||||
store32(@g32)
|
||||
gammaRed[255 - i] = g32
|
||||
gammaGrn[255 - i] = g32
|
||||
gammaBlu[255 - i] = g32
|
||||
next
|
||||
break
|
||||
is 2 // 1/(i^2)
|
||||
for i = 0 to 255
|
||||
loadi16(i)
|
||||
muli16(i)
|
||||
addi16(127)
|
||||
divi16(255)
|
||||
store32(@g32)
|
||||
gammaRed[i] = g32
|
||||
gammaGrn[i] = g32
|
||||
gammaBlu[i] = g32
|
||||
next
|
||||
break
|
||||
is 1 // (i + i^2) / 2
|
||||
for i = 0 to 255
|
||||
loadi16(i)
|
||||
muli16(i)
|
||||
addi16(127)
|
||||
divi16(255)
|
||||
addi16(i)
|
||||
divi16(2)
|
||||
store32(@g32)
|
||||
gammaRed[i] = g32
|
||||
gammaGrn[i] = g32
|
||||
gammaBlu[i] = g32
|
||||
next
|
||||
break
|
||||
otherwise // i
|
||||
for i = 0 to 255
|
||||
gammaRed[i] = i
|
||||
gammaGrn[i] = i
|
||||
gammaBlu[i] = i
|
||||
next
|
||||
wend
|
||||
if gamut[RED] <> 128
|
||||
for i = 0 to 255
|
||||
gammaRed[i] = max(0, min(255, (gammaRed[i] * 128) / gamut[RED]))
|
||||
next
|
||||
fin
|
||||
if gamut[GRN] <> 128
|
||||
for i = 0 to 255
|
||||
gammaGrn[i] = max(0, min(255, (gammaGrn[i] * 128) / gamut[GRN]))
|
||||
next
|
||||
fin
|
||||
if gamut[BLU] <> 128
|
||||
for i = 0 to 255
|
||||
gammaBlu[i] = max(0, min(255, (gammaBlu[i] * 128) / gamut[BLU]))
|
||||
next
|
||||
fin
|
||||
if brightness
|
||||
for i = 0 to 255
|
||||
gammaRed[i] = max(0, min(255, gammaRed[i] + brightness))
|
||||
gammaGrn[i] = max(0, min(255, gammaGrn[i] + brightness))
|
||||
gammaBlu[i] = max(0, min(255, gammaBlu[i] + brightness))
|
||||
next
|
||||
fin
|
||||
calcChroma(tint)
|
||||
if flags & DUMP_STATE
|
||||
puts("Err Div = "); puti(errDiv); putln
|
||||
puts("Brightness = "); puti(brightness); putln
|
||||
puts("Tint = "); puti(tint); putln
|
||||
puts("Saturation = "); puti(saturation); putln
|
||||
puts("Gamut = ["); puti(gamut[RED]); putc(',')
|
||||
puti(gamut[GRN]); putc(','); puti(gamut[BLU]); puts("]\n")
|
||||
puts("Match = ")
|
||||
if flags & MATCH_NEXT; puts("Next\n")
|
||||
elsif flags & MATCH_CYCLE; puts("Current\n")
|
||||
else; puts("Prev\n"); fin
|
||||
puts("Chroma cycle RGB =\n")
|
||||
for i = 0 to 3
|
||||
putc('[')
|
||||
puti(ntscChroma[i*3 + RED]); putc(',')
|
||||
puti(ntscChroma[i*3 + GRN]); putc(',')
|
||||
puti(ntscChroma[i*3 + BLU]); puts("]\n")
|
||||
next
|
||||
fin
|
||||
if flags & MATCH_NEXT
|
||||
rgbMatch = @rgbMatchNext
|
||||
// Calc pixel RGBs
|
||||
for i = 0 to 15
|
||||
if i & 1
|
||||
pixRed[i] = ntscChroma[RED]
|
||||
pixGrn[i] = ntscChroma[GRN]
|
||||
pixBlu[i] = ntscChroma[BLU]
|
||||
fin
|
||||
if i & 2
|
||||
pixRed[i] = pixRed[i] + ntscChroma[3+RED]
|
||||
pixGrn[i] = pixGrn[i] + ntscChroma[3+GRN]
|
||||
pixBlu[i] = pixBlu[i] + ntscChroma[3+BLU]
|
||||
fin
|
||||
if i & 4
|
||||
pixRed[i] = pixRed[i] + ntscChroma[6+RED]
|
||||
pixGrn[i] = pixGrn[i] + ntscChroma[6+GRN]
|
||||
pixBlu[i] = pixBlu[i] + ntscChroma[6+BLU]
|
||||
fin
|
||||
if i & 8
|
||||
pixRed[i] = pixRed[i] + ntscChroma[9+RED]
|
||||
pixGrn[i] = pixGrn[i] + ntscChroma[9+GRN]
|
||||
pixBlu[i] = pixBlu[i] + ntscChroma[9+BLU]
|
||||
fin
|
||||
next
|
||||
// Adjust error scalng for this strategy
|
||||
errDiv = errDiv * 2
|
||||
elsif flags & MATCH_CYCLE
|
||||
rgbMatch = @rgbMatchCycle
|
||||
// Make up for scaled chroma cycle color match
|
||||
for i = 0 to 11
|
||||
ntscChroma[i] = (ntscChroma[i] * 3) / 2 // * 1.5
|
||||
next
|
||||
else // MATCH_PREV
|
||||
rgbMatch = @rgbMatchPrev
|
||||
fin
|
||||
if flags & MEM_MODE
|
||||
surfMem, surfSpan = dhgrAllocBl7Mem(SCR_WIDTH, SCR_HEIGHT)
|
||||
dhgrSurfMem(OP_XOR, SCR_HEIGHT, surfMem, surfSpan)
|
||||
dhgrOp(OP_SRC) // Force op recalc
|
||||
dcgrColor(CLR_BLACK)
|
||||
dhgrClearBl7(0, 0, surfSpan >> 2, SCR_HEIGHT)
|
||||
else
|
||||
dhgrMode(DHGR_COLOR_MODE)
|
||||
fin
|
||||
end
|
||||
|
||||
def rgbExit#0
|
||||
heaprelease(rgbErr)
|
||||
if not (flags & MEM_MODE)
|
||||
dhgrMode(DHGR_TEXT_MODE)
|
||||
fin
|
||||
end
|
||||
|
||||
def pnmReadElement(refnum, bufptr)#1
|
||||
var lenptr
|
||||
|
||||
lenptr = bufptr
|
||||
repeat
|
||||
^lenptr = 0
|
||||
bufptr = lenptr + 1
|
||||
if fileio:read(refnum, bufptr, 1) == 1 and ^bufptr == '#' // Comment
|
||||
^lenptr++
|
||||
bufptr++
|
||||
while fileio:read(refnum, bufptr, 1) == 1 and ^bufptr >= ' '
|
||||
loop
|
||||
else
|
||||
repeat // Read white space seperated element
|
||||
^lenptr++
|
||||
bufptr++
|
||||
until fileio:read(refnum, bufptr, 1) <> 1 or ^bufptr <= ' ' or ^lenptr > 32
|
||||
fin
|
||||
until ^lenptr and ^(lenptr + 1) <> '#' // Repeat until not comment
|
||||
if flags & DUMP_STATE; puts(lenptr); putc(' '); fin
|
||||
return lenptr
|
||||
end
|
||||
|
||||
def pnmVerifyHeader(refnum)#1
|
||||
byte[128] buf
|
||||
if flags & DUMP_STATE; puts("PNM = "); fin
|
||||
pnmReadElement(refnum, @buf)
|
||||
if buf[0] <> 2 and buf[1] <> 'P' and buf[2] <> '6'
|
||||
puts("Invalid PNM magic #: "); putc(buf[1]); putc(buf[2]); putln
|
||||
return FALSE
|
||||
fin
|
||||
if atoi(pnmReadElement(refnum, @buf)) <> 560
|
||||
puts("Width not 560: "); puts(@buf); putln
|
||||
return FALSE
|
||||
fin
|
||||
if atoi(pnmReadElement(refnum, @buf)) <> 192
|
||||
puts("Height not 192: "); puts(@buf); putln
|
||||
return FALSE
|
||||
fin
|
||||
if atoi(pnmReadElement(refnum, @buf)) <> 255
|
||||
puts("Depth not 255: "); puts(@buf); putln
|
||||
return FALSE
|
||||
fin
|
||||
if flags & DUMP_STATE; putln; fin
|
||||
return TRUE
|
||||
end
|
||||
|
||||
def rgbImportExport(rgbfile, dhgrfile)#0
|
||||
byte refnum, chromaBits
|
||||
var i, j, c, r, g, b
|
||||
var rgbScanline, rgbptr, errptr
|
||||
|
||||
refnum = fileio:open(rgbfile)
|
||||
if refnum
|
||||
if not (flags & RAW_INFILE)
|
||||
if not pnmVerifyHeader(refnum)
|
||||
fileio:close(refnum)
|
||||
return
|
||||
fin
|
||||
fin
|
||||
rgbInit
|
||||
rgbScanline = heapalloc(560 * 3)
|
||||
rgbErr = heapalloc(561 * 3 * 2)
|
||||
if rgbErr and rgbScanline
|
||||
// Init error propogation array
|
||||
memset(rgbErr, 0, 560 * 3 * 2)
|
||||
memset(rgbScanline, 0, 560 * 3)
|
||||
for j = 0 to 191
|
||||
fileio:read(refnum, rgbScanline, 560 * 3)
|
||||
memset(@ntscCycle, GREY_CHROMA, 24) // Reset chroma cycle
|
||||
prevRed, prevGrn, prevBLu = 96, 96, 96 // Reset prev RGB
|
||||
rgbptr = rgbScanline
|
||||
errptr = rgbErr
|
||||
for i = 0 to 139
|
||||
chromaBits = 0
|
||||
for c = 0 to 3
|
||||
// Calc best match
|
||||
r = gammaRed[rgbptr->[RED]]
|
||||
g = gammaGrn[rgbptr->[GRN]]
|
||||
b = gammaBlu[rgbptr->[BLU]]
|
||||
if errDiv
|
||||
r = r + errptr=>[RED] / errDiv
|
||||
g = g + errptr=>[GRN] / errDiv
|
||||
b = b + errptr=>[BLU] / errDiv
|
||||
fin
|
||||
chromaBits = (chromaBits >> 1) | rgbMatch(r, g, b, errptr, c)
|
||||
rgbptr = rgbptr + 3
|
||||
errptr = errptr + 3 * 2
|
||||
next
|
||||
if flags & GREY_HACK
|
||||
// Map GREY1 -> GREY2
|
||||
if chromaBits == $0A // Bits are in reverse order from DCGR color value
|
||||
chromaBits = $05
|
||||
memset(@ntscCycle, GREY_CHROMA, 24) // Grey chroma cycle
|
||||
elsif chromaBits == $05
|
||||
memset(@ntscCycle, GREY_CHROMA, 24) // Grey chroma cycle
|
||||
fin
|
||||
fin
|
||||
dcgrColor(clrRot[chromaBits])
|
||||
dcgrPixel(i, j)
|
||||
next
|
||||
if flags & MEM_MODE; putc('.'); fin
|
||||
if ^$C000 == $83
|
||||
break
|
||||
fin
|
||||
next
|
||||
fileio:close(refnum)
|
||||
if ^dhgrfile
|
||||
if flags & MEM_MODE
|
||||
heaprelease(rgbScanline) // Free up some memory
|
||||
if MACHID & $F0 <> $B0
|
||||
// Use allocated buffer on non 128K //e
|
||||
rgbScanline = heapalloc($2000)
|
||||
else
|
||||
// Use HGR memory (already reserved) on 128K //e
|
||||
rgbScanline = $2000
|
||||
fin
|
||||
if rgbScanline
|
||||
memset(rgbScanline, 0, $2000)
|
||||
fileio:destroy(dhgrfile)
|
||||
fileio:create(dhgrfile, $06, $2000)
|
||||
refnum = fileio:open(dhgrfile)
|
||||
if refnum
|
||||
// Reorder scanlines into HGR format
|
||||
rgbptr = surfMem
|
||||
for i = 0 to SCR_HEIGHT-1
|
||||
memcpy(rgbScanline+hgrScan[i], rgbptr, 40)
|
||||
rgbptr = rgbptr + surfSpan
|
||||
next
|
||||
// Write AUX bytes
|
||||
fileio:write(refnum, rgbScanline, $2000)
|
||||
rgbptr = surfMem + surfSpan / 2
|
||||
for i = 0 to SCR_HEIGHT-1
|
||||
memcpy(rgbScanline+hgrScan[i], rgbptr, 40)
|
||||
rgbptr = rgbptr + surfSpan
|
||||
next
|
||||
// Write MAIN bytes
|
||||
fileio:write(refnum, rgbScanline, $2000)
|
||||
fileio:close(refnum)
|
||||
fin
|
||||
putln
|
||||
fin
|
||||
else
|
||||
screenWrite(dhgrfile)
|
||||
fin
|
||||
fin
|
||||
if not (flags & MEM_MODE); getc; fin
|
||||
rgbExit
|
||||
fin
|
||||
else
|
||||
puts("Unable to open "); puts(rgbfile); putln
|
||||
fin
|
||||
end
|
||||
|
||||
puts("DHGR RGB converter 1.1\n")
|
||||
arg = argNext(argFirst)
|
||||
if ^arg
|
||||
while ^(arg + 1) == '-'
|
||||
when toupper(^(arg + 2))
|
||||
is 'B' // Set brightness
|
||||
if ^arg > 2
|
||||
^(arg + 2) = ^arg - 2
|
||||
brightness = atoi(arg + 2)
|
||||
fin
|
||||
break
|
||||
is 'C' // Disable hack for GREY remapping
|
||||
flags = flags & ~GREY_HACK
|
||||
break
|
||||
is 'D' // Dump internal staet
|
||||
flags = flags | DUMP_STATE
|
||||
break
|
||||
is 'E' // Set error strength
|
||||
if ^arg > 2
|
||||
errDiv = ^(arg + 3) - '0'
|
||||
if ^arg > 3
|
||||
errDiv = errDiv * 10 + ^(arg + 4) - '0'
|
||||
fin
|
||||
fin
|
||||
break
|
||||
is 'G' // Set gamma amount
|
||||
if ^arg > 2
|
||||
^(arg + 2) = ^arg - 2
|
||||
gamma = atoi(arg + 2)
|
||||
fin
|
||||
break
|
||||
is 'M' // Match RGB strategy
|
||||
when toupper(^(arg + 3))
|
||||
is 'N' // Match to next pixel
|
||||
flags = flags | MATCH_NEXT
|
||||
tint = tint - 22
|
||||
break
|
||||
is 'C' // Match to current cycle
|
||||
flags = flags | MATCH_CYCLE
|
||||
break
|
||||
//is 'P' // Match to previous RGB
|
||||
otherwise
|
||||
break
|
||||
wend
|
||||
break
|
||||
is 'P' // RGB phase angle
|
||||
when toupper(^(arg + 3))
|
||||
is 'I' // Use ideal 4 sub-phase angles
|
||||
phase[RED] = RED_PHASE_IDEAL
|
||||
phase[GRN] = GREEN_PHASE_IDEAL
|
||||
phase[BLU] = BLUE_PHASE_IDEAL
|
||||
break
|
||||
is 'E' // Use equal 120 deg phase angles
|
||||
phase[RED] = RED_PHASE_EQUAL
|
||||
phase[GRN] = GREEN_PHASE_EQUAL
|
||||
phase[BLU] = BLUE_PHASE_EQUAL
|
||||
break
|
||||
is 'S' // Use simplified 90 degree and opposite phase angles
|
||||
phase[RED] = RED_PHASE_SIMPLE
|
||||
phase[GRN] = GREEN_PHASE_SIMPLE
|
||||
phase[BLU] = BLUE_PHASE_SIMPLE
|
||||
break
|
||||
//is 'N' // Use theoretical NTSC phase angles
|
||||
otherwise
|
||||
phase[RED] = RED_PHASE_NTSC
|
||||
phase[GRN] = GREEN_PHASE_NTSC
|
||||
phase[BLU] = BLUE_PHASE_NTSC
|
||||
break
|
||||
wend
|
||||
break
|
||||
is 'R' // Raw input mode - no PNM header
|
||||
flags = flags | RAW_INFILE
|
||||
break
|
||||
is 'S' // Adjust saturation
|
||||
if ^arg > 2
|
||||
^(arg + 2) = ^arg - 2
|
||||
saturation = saturation - atoi(arg + 2)
|
||||
fin
|
||||
break
|
||||
is 'T' // Adjust tint
|
||||
if ^arg > 2
|
||||
^(arg + 2) = ^arg - 2
|
||||
tint = tint + atoi(arg + 2)
|
||||
fin
|
||||
break
|
||||
is 'U' // Adjust gamut
|
||||
if ^arg > 3
|
||||
when toupper(^(arg + 3))
|
||||
is 'R'
|
||||
^(arg + 1) = RED
|
||||
break
|
||||
is 'G'
|
||||
^(arg + 1) = GRN
|
||||
break
|
||||
otherwise // B
|
||||
^(arg + 1) = BLU
|
||||
break
|
||||
wend
|
||||
^(arg + 3) = ^arg - 3
|
||||
gamut[^(arg + 1)] = gamut[^(arg + 1)] - atoi(arg + 3)
|
||||
fin
|
||||
break
|
||||
is 'V' // No video output, memory mode only (for portable VM)
|
||||
flags = flags | MEM_MODE
|
||||
break
|
||||
otherwise
|
||||
puts("? option:"); putc(^(arg + 2)); putln
|
||||
wend
|
||||
arg = argNext(arg)
|
||||
loop
|
||||
if ^arg
|
||||
rgbImportExport(arg, argNext(arg))
|
||||
fin
|
||||
return 0
|
||||
fin
|
||||
puts("Usage:\n")
|
||||
puts(" DHGRRGB\n")
|
||||
puts(" [-B#] = Brightness: -255..255\n")
|
||||
puts(" [-C] = Composite output\n")
|
||||
puts(" [-D] = Dump state\n")
|
||||
puts(" [-E#] = Error strength: 1..255\n")
|
||||
puts(" 0 = no err\n")
|
||||
puts(" [-G#] = Gamma: 2, 1, 0, -1, -2\n")
|
||||
puts(" [-M<N,C,P>] = Match: Next, Current\n")
|
||||
puts(" Previous\n")
|
||||
puts(" [-P<I,E,S,N>] = Phase: Ideal, Equal\n")
|
||||
puts(" Simple, NTSC\n")
|
||||
puts(" [-R] = Raw image file, no header\n")
|
||||
puts(" [-S#] = Saturation: -255..255\n")
|
||||
puts(" [-T#] = Tint: -360..360 (in degrees)\n")
|
||||
puts(" [-U<R,G,B>#] = gammUt: Red, Grn, Blu\n")
|
||||
puts(" -255..255\n")
|
||||
puts(" [-V] = no Video output, mem only\n")
|
||||
puts(" IMAGEFILE [DHGRFILE]\n")
|
||||
done
|
434
src/dhgr.tk/utils/dhgrrgb.c
Normal file
434
src/dhgr.tk/utils/dhgrrgb.c
Normal file
@@ -0,0 +1,434 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include <memory.h>
|
||||
#include <ctype.h>
|
||||
|
||||
/* CGA high resolution */
|
||||
#define X_RES 560
|
||||
#define Y_RES 192
|
||||
/* According to what I could find out about the NTSC color wheel:
|
||||
* Red maxes at 103.5 degrees
|
||||
* Green maxes at 240.7 degrees
|
||||
* Blue maxes at 347.1 degrees
|
||||
*/
|
||||
#define RED_PHASE_NTSC 104
|
||||
#define GREEN_PHASE_NTSC 241
|
||||
#define BLUE_PHASE_NTSC 347
|
||||
/* Ideal phase angles for 4 phase */
|
||||
#define RED_PHASE_IDEAL 90
|
||||
#define GREEN_PHASE_IDEAL 270
|
||||
#define BLUE_PHASE_IDEAL 360
|
||||
/* Equal 120 deg phase angles */
|
||||
#define RED_PHASE_EQUAL 120
|
||||
#define GREEN_PHASE_EQUAL 240
|
||||
#define BLUE_PHASE_EQUAL 360
|
||||
/* Simplified phase angles: 90 deg between R and B, 135 between RG and BG */
|
||||
#define RED_PHASE_SIMPLE 90
|
||||
#define GREEN_PHASE_SIMPLE 225
|
||||
#define BLUE_PHASE_SIMPLE 360
|
||||
/* Flags */
|
||||
#define GREY_HACK 1 /* Remap GREY1 to GREY2 */
|
||||
#define DUMP_STATE 2 /* Dump internal state */
|
||||
char flags = GREY_HACK;
|
||||
/* Handy macros */
|
||||
#ifndef min
|
||||
#define min(a,b) ((a)<(b)?(a):(b))
|
||||
#endif
|
||||
#ifndef max
|
||||
#define max(a,b) ((a)>(b)?(a):(b))
|
||||
#endif
|
||||
#define RED 0
|
||||
#define GRN 1
|
||||
#define BLU 2
|
||||
#define DEG_TO_RAD 0.0174533
|
||||
#define TRUE 1
|
||||
#define FALSE 0
|
||||
unsigned char ntscChroma[4][3];
|
||||
int prevRed, prevBlu, prevGrn;
|
||||
unsigned char gammaRed[256]; /* RED gamma correction */
|
||||
unsigned char gammaGrn[256]; /* GREEN gamma correction */
|
||||
unsigned char gammaBlu[256]; /* BLUE gamma correction */
|
||||
int phase[3] = {RED_PHASE_NTSC, GREEN_PHASE_NTSC, BLUE_PHASE_NTSC};
|
||||
int gammacorrect = 0; /* Gamma correction */
|
||||
int brightness = 0;
|
||||
int saturation = 255; /* 1.0 */
|
||||
int tint = 22; /* imperically determined tint */
|
||||
int orgmode;
|
||||
int errDiv = 4;
|
||||
unsigned char rgbScanline[X_RES * 3]; /* RGB scanline */
|
||||
int rgbErr[(X_RES + 1) * 3]; /* Running color error array */
|
||||
#define DHGR_SIZE 16384
|
||||
unsigned char dhgrScreen[DHGR_SIZE];
|
||||
int scanOffset[] = {0x0000,0x0400,0x0800,0x0C00,0x1000,0x1400,0x1800,0x1C00,
|
||||
0x0080,0x0480,0x0880,0x0C80,0x1080,0x1480,0x1880,0x1C80,
|
||||
0x0100,0x0500,0x0900,0x0D00,0x1100,0x1500,0x1900,0x1D00,
|
||||
0x0180,0x0580,0x0980,0x0D80,0x1180,0x1580,0x1980,0x1D80,
|
||||
0x0200,0x0600,0x0A00,0x0E00,0x1200,0x1600,0x1A00,0x1E00,
|
||||
0x0280,0x0680,0x0A80,0x0E80,0x1280,0x1680,0x1A80,0x1E80,
|
||||
0x0300,0x0700,0x0B00,0x0F00,0x1300,0x1700,0x1B00,0x1F00,
|
||||
0x0380,0x0780,0x0B80,0x0F80,0x1380,0x1780,0x1B80,0x1F80,
|
||||
0x0028,0x0428,0x0828,0x0C28,0x1028,0x1428,0x1828,0x1C28,
|
||||
0x00A8,0x04A8,0x08A8,0x0CA8,0x10A8,0x14A8,0x18A8,0x1CA8,
|
||||
0x0128,0x0528,0x0928,0x0D28,0x1128,0x1528,0x1928,0x1D28,
|
||||
0x01A8,0x05A8,0x09A8,0x0DA8,0x11A8,0x15A8,0x19A8,0x1DA8,
|
||||
0x0228,0x0628,0x0A28,0x0E28,0x1228,0x1628,0x1A28,0x1E28,
|
||||
0x02A8,0x06A8,0x0AA8,0x0EA8,0x12A8,0x16A8,0x1AA8,0x1EA8,
|
||||
0x0328,0x0728,0x0B28,0x0F28,0x1328,0x1728,0x1B28,0x1F28,
|
||||
0x03A8,0x07A8,0x0BA8,0x0FA8,0x13A8,0x17A8,0x1BA8,0x1FA8,
|
||||
0x0050,0x0450,0x0850,0x0C50,0x1050,0x1450,0x1850,0x1C50,
|
||||
0x00D0,0x04D0,0x08D0,0x0CD0,0x10D0,0x14D0,0x18D0,0x1CD0,
|
||||
0x0150,0x0550,0x0950,0x0D50,0x1150,0x1550,0x1950,0x1D50,
|
||||
0x01D0,0x05D0,0x09D0,0x0DD0,0x11D0,0x15D0,0x19D0,0x1DD0,
|
||||
0x0250,0x0650,0x0A50,0x0E50,0x1250,0x1650,0x1A50,0x1E50,
|
||||
0x02D0,0x06D0,0x0AD0,0x0ED0,0x12D0,0x16D0,0x1AD0,0x1ED0,
|
||||
0x0350,0x0750,0x0B50,0x0F50,0x1350,0x1750,0x1B50,0x1F50,
|
||||
0x03D0,0x07D0,0x0BD0,0x0FD0,0x13D0,0x17D0,0x1BD0,0x1FD0};
|
||||
|
||||
void dhgrSet(int x, int y)
|
||||
{
|
||||
int pixbit, pixofst;
|
||||
|
||||
pixbit = 1 << (x % 7);
|
||||
pixofst = x / 7;
|
||||
pixofst = (DHGR_SIZE/2) * (pixofst & 1) + (pixofst >> 1);
|
||||
dhgrScreen[scanOffset[y] + pixofst] |= pixbit;
|
||||
}
|
||||
void dhgrPlot(int x, int y, int clr)
|
||||
{
|
||||
int bit;
|
||||
for (bit = 0; bit < 4; bit++)
|
||||
{
|
||||
if ((1 << bit) & clr)
|
||||
dhgrSet(x + bit, y);
|
||||
}
|
||||
}
|
||||
long int dist(int dr, int dg, int db)
|
||||
{
|
||||
long int rr, gg, bb;
|
||||
|
||||
rr = (long int)dr * (long int)dr;
|
||||
gg = (long int)dg * (long int)dg;
|
||||
bb = (long int)db * (long int)db;
|
||||
return rr + gg + bb;
|
||||
}
|
||||
|
||||
void calcChroma(int angle)
|
||||
{
|
||||
int r, g, b, i;
|
||||
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
/* Calculate RGB for this NTSC subcycle pixel */
|
||||
r = saturation + (int)(cos((angle - phase[RED]) * DEG_TO_RAD) * 255);
|
||||
g = saturation + (int)(cos((angle - phase[GRN]) * DEG_TO_RAD) * 255);
|
||||
b = saturation + (int)(cos((angle - phase[BLU]) * DEG_TO_RAD) * 255);
|
||||
/* Make chroma add up to white */
|
||||
ntscChroma[i][RED] = min(255, max(0, (r + 2) / 4));
|
||||
ntscChroma[i][GRN] = min(255, max(0, (g + 2) / 4));
|
||||
ntscChroma[i][BLU] = min(255, max(0, (b + 2) / 4));
|
||||
/* Next NTSC chroma subcycle pixel */
|
||||
angle = angle - 90;
|
||||
}
|
||||
}
|
||||
|
||||
int rgbMatchChroma(int r, int g, int b, int *errptr, int cx)
|
||||
{
|
||||
int currRed, currGrn, currBlu;
|
||||
int errRed, errGrn, errBlu;
|
||||
int pix;
|
||||
|
||||
/* Apply error propogation */
|
||||
if (errDiv)
|
||||
{
|
||||
r += errptr[RED] / errDiv;
|
||||
g += errptr[GRN] / errDiv;
|
||||
b += errptr[BLU] / errDiv;
|
||||
}
|
||||
/* Previous RGB chroma subcycles */
|
||||
prevRed = (prevRed * 3) / 4;
|
||||
prevGrn = (prevGrn * 3) / 4;
|
||||
prevBlu = (prevBlu * 3) / 4;
|
||||
/* Current potential RGB subcycle */
|
||||
currRed = prevRed + ntscChroma[cx][RED];
|
||||
currGrn = prevGrn + ntscChroma[cx][GRN];
|
||||
currBlu = prevBlu + ntscChroma[cx][BLU];
|
||||
/* Match chroma subcycle */
|
||||
pix = 0;
|
||||
if (dist(r - currRed, g - currGrn, b - currBlu) < dist(r - prevRed, g - prevGrn, b - prevBlu))
|
||||
{
|
||||
/* RGB better matched with current chroma subcycle color */
|
||||
prevRed = currRed;
|
||||
prevGrn = currGrn;
|
||||
prevBlu = currBlu;
|
||||
pix = 1;
|
||||
}
|
||||
/* Propogate error down (overwrite error at this coordinate for next row) */
|
||||
errRed = r - prevRed;
|
||||
errGrn = g - prevGrn;
|
||||
errBlu = b - prevBlu;
|
||||
errptr[RED] = errRed;
|
||||
errptr[GRN] = errGrn;
|
||||
errptr[BLU] = errBlu;
|
||||
/* And forward (add to previous row error for next match) */
|
||||
errptr[RED + 3] += errRed;
|
||||
errptr[GRN + 3] += errGrn;
|
||||
errptr[BLU + 3] += errBlu;
|
||||
return pix;
|
||||
}
|
||||
|
||||
int rgbInit(void)
|
||||
{
|
||||
int i;
|
||||
long int g32;
|
||||
|
||||
switch (gammacorrect)
|
||||
{
|
||||
case -1:
|
||||
for (i = 0; i < 256; i++)
|
||||
{
|
||||
g32 = (255 - i + 255 - ((long int)i * (long int)i + 127)/255) / 2;
|
||||
gammaRed[255 - i] = g32;
|
||||
gammaGrn[255 - i] = g32;
|
||||
gammaBlu[255 - i] = g32;
|
||||
}
|
||||
break;
|
||||
case -2:
|
||||
for (i = 0; i < 256; i++)
|
||||
{
|
||||
g32 = 255 - ((long int)i * (long int)i + 127)/255;
|
||||
gammaRed[255 - i] = g32;
|
||||
gammaGrn[255 - i] = g32;
|
||||
gammaBlu[255 - i] = g32;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
for (i = 0; i < 256; i++)
|
||||
{
|
||||
g32 = ((long int)i * (long int)i + 127) / 255;
|
||||
gammaRed[i] = g32;
|
||||
gammaGrn[i] = g32;
|
||||
gammaBlu[i] = g32;
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
for (i = 0; i < 256; i++)
|
||||
{
|
||||
g32 = (i + ((long int)i * (long int)i + 127) / 255) / 2;
|
||||
gammaRed[i] = g32;
|
||||
gammaGrn[i] = g32;
|
||||
gammaBlu[i] = g32;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
for (i = 0; i < 256; i++)
|
||||
{
|
||||
gammaRed[i] = i;
|
||||
gammaGrn[i] = i;
|
||||
gammaBlu[i] = i;
|
||||
}
|
||||
}
|
||||
if (brightness)
|
||||
for (i = 0; i < 256; i++)
|
||||
{
|
||||
gammaRed[i] = max(0, min(255, gammaRed[i] + brightness));
|
||||
gammaGrn[i] = max(0, min(255, gammaGrn[i] + brightness));
|
||||
gammaBlu[i] = max(0, min(255, gammaBlu[i] + brightness));
|
||||
}
|
||||
calcChroma(tint);
|
||||
if (flags & DUMP_STATE)
|
||||
{
|
||||
printf("Err Div = %d\n", errDiv);
|
||||
printf("Gamma = %d\n", gammacorrect);
|
||||
printf("Brightness = %d\n", brightness);
|
||||
printf("Tint = %d\n", tint);
|
||||
printf("Saturation = %d\n", saturation);
|
||||
puts("Chroma cycle RGB =");
|
||||
for (i = 0; i < 4; i++)
|
||||
printf(" [%3d, %3d %3d]\n", ntscChroma[i][RED],
|
||||
ntscChroma[i][GRN],
|
||||
ntscChroma[i][BLU]);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
char *pnmReadElement(FILE *fp, char *bufptr)
|
||||
{
|
||||
char *endptr;
|
||||
|
||||
endptr = bufptr + 1;
|
||||
while (fread(bufptr, 1, 1, fp) == 1 && *bufptr == '#') /* Comment */
|
||||
while (fread(endptr, 1, 1, fp) == 1 && *endptr >= ' ');
|
||||
while (fread(endptr, 1, 1, fp) == 1 && *endptr > ' ' && (endptr - bufptr < 80))
|
||||
endptr++;
|
||||
*endptr = '\0';
|
||||
if (flags & DUMP_STATE)
|
||||
puts(bufptr);
|
||||
return bufptr;
|
||||
}
|
||||
|
||||
int pnmVerifyHeader(FILE *fp)
|
||||
{
|
||||
char buf[128];
|
||||
|
||||
if (flags & DUMP_STATE)
|
||||
printf("PNM = ");
|
||||
pnmReadElement(fp, buf);
|
||||
if (strcmp(buf, "P6"))
|
||||
{
|
||||
printf("Invalid PNM magic #: %c%c\n", buf[0], buf[1]);
|
||||
return FALSE;
|
||||
}
|
||||
if (atoi(pnmReadElement(fp, buf)) != X_RES)
|
||||
{
|
||||
printf("Width not 640: %s\n", buf);
|
||||
return FALSE;
|
||||
}
|
||||
if (atoi(pnmReadElement(fp, buf)) != Y_RES)
|
||||
{
|
||||
printf("Height not 192: %s\n", buf);
|
||||
return FALSE;
|
||||
}
|
||||
if (atoi(pnmReadElement(fp, buf)) != 255)
|
||||
{
|
||||
printf("Depth not 255: %s\n", buf);
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
int rgbImportExport(char *pnmfile, char *dhgrfile)
|
||||
{
|
||||
FILE *fp;
|
||||
unsigned char *scanptr;
|
||||
unsigned char chromaBits, *rgbptr;
|
||||
int scan, pix, chroma, r, g, b, *errptr;
|
||||
|
||||
if (flags & DUMP_STATE)
|
||||
printf("PNM file = %s\n", pnmfile);
|
||||
fp = fopen(pnmfile, "rb");
|
||||
if (fp)
|
||||
{
|
||||
if (pnmVerifyHeader(fp) && rgbInit())
|
||||
{
|
||||
/* Clear screen memory */
|
||||
memset(dhgrScreen, 0, DHGR_SIZE);
|
||||
/* Init error propogation array */
|
||||
memset(rgbScanline, 0, X_RES * 3);
|
||||
memset(rgbErr, 0, X_RES * 3 * sizeof(int));
|
||||
for (scan = 0; scan < Y_RES; scan++)
|
||||
{
|
||||
fread(rgbScanline, X_RES, 3, fp);
|
||||
/* Reset prev RGB to neutral color */
|
||||
prevRed = 96;
|
||||
prevGrn = 96;
|
||||
prevBlu = 96;
|
||||
/* Reset pointers */
|
||||
rgbptr = rgbScanline;
|
||||
errptr = rgbErr;
|
||||
for (pix = 0; pix < X_RES; pix += 4)
|
||||
{
|
||||
chromaBits = 0;
|
||||
for (chroma = 0; chroma < 4; chroma++)
|
||||
{
|
||||
/* Calc best match */
|
||||
r = gammaRed[rgbptr[RED]];
|
||||
g = gammaGrn[rgbptr[GRN]];
|
||||
b = gammaBlu[rgbptr[BLU]];
|
||||
chromaBits |= rgbMatchChroma(r, g, b, errptr, chroma) << chroma;
|
||||
rgbptr = rgbptr + 3;
|
||||
errptr = errptr + 3;
|
||||
}
|
||||
if (chromaBits == 0x0A && flags & GREY_HACK)
|
||||
chromaBits = 0x05;
|
||||
dhgrPlot(pix, scan, chromaBits);
|
||||
}
|
||||
}
|
||||
}
|
||||
fclose(fp);
|
||||
fp = fopen(dhgrfile, "wb");
|
||||
if (fp)
|
||||
{
|
||||
fwrite(dhgrScreen, DHGR_SIZE, 1, fp);
|
||||
fclose(fp);
|
||||
return 0;
|
||||
}
|
||||
printf("Unable to open %s\n", dhgrfile);
|
||||
}
|
||||
printf("Unable to open %s\n", pnmfile);
|
||||
return -1;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
puts("DHGR RGB converter 1.0");
|
||||
while (*++argv && (*argv)[0] == '-')
|
||||
{
|
||||
switch (toupper((*argv)[1]))
|
||||
{
|
||||
case 'B': /* Set brightness */
|
||||
brightness = atoi(*argv + 2);
|
||||
break;
|
||||
case 'C': /* No grey remapping*/
|
||||
flags &= ~GREY_HACK;
|
||||
case 'D': /* Dump internal state */
|
||||
flags |= DUMP_STATE;
|
||||
break;
|
||||
case 'E': /* Set error strength */
|
||||
errDiv = atoi(*argv + 2);
|
||||
break;
|
||||
case 'G': /* Set gamma amount */
|
||||
gammacorrect = atoi(*argv + 2);
|
||||
break;
|
||||
case 'P': /* RGB phase angle */
|
||||
switch (toupper((*argv)[2]))
|
||||
{
|
||||
case 'I': /* Use ideal 4 sub-phase angles */
|
||||
phase[RED] = RED_PHASE_IDEAL;
|
||||
phase[GRN] = GREEN_PHASE_IDEAL;
|
||||
phase[BLU] = BLUE_PHASE_IDEAL;
|
||||
break;
|
||||
case 'E': /* Use equal 120 deg phase angles */
|
||||
phase[RED] = RED_PHASE_EQUAL;
|
||||
phase[GRN] = GREEN_PHASE_EQUAL;
|
||||
phase[BLU] = BLUE_PHASE_EQUAL;
|
||||
break;
|
||||
case 'S': /* Use simplified 90 degree and opposite phase angles */
|
||||
phase[RED] = RED_PHASE_SIMPLE;
|
||||
phase[GRN] = GREEN_PHASE_SIMPLE;
|
||||
phase[BLU] = BLUE_PHASE_SIMPLE;
|
||||
break;
|
||||
/* case 'N': Use theoretical NTSC phase angles */
|
||||
default:
|
||||
phase[RED] = RED_PHASE_NTSC;
|
||||
phase[GRN] = GREEN_PHASE_NTSC;
|
||||
phase[BLU] = BLUE_PHASE_NTSC;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 'S': /* Adjust saturation */
|
||||
saturation -= atoi(*argv + 2);
|
||||
break;
|
||||
case 'T': /* Adjust tint */
|
||||
tint += atoi(*argv + 2);
|
||||
break;
|
||||
default:
|
||||
printf("? option: %c\n", (*argv)[1]);
|
||||
}
|
||||
}
|
||||
if (argv[0] && argv[1])
|
||||
return rgbImportExport(argv[0], argv[1]);
|
||||
puts("Usage:");
|
||||
puts(" dhgrrgb");
|
||||
puts(" [-b#] = Brightness: -255..255");
|
||||
puts(" [-c] = Composite output (no grey remapping)");
|
||||
puts(" [-d] = Dump state");
|
||||
puts(" [-e#] = Error strength: 1..255");
|
||||
puts(" 0 = no err");
|
||||
puts(" [-g#] = Gamma: 2, 1, 0, -1, -2");
|
||||
puts(" [-p<I,E,S,N>] = Phase: Ideal, Equal, Simple, NTSC");
|
||||
puts(" [-s#] = Saturation: -255..255");
|
||||
puts(" [-t#] = Tint: -360..360 (in degrees)");
|
||||
puts(" <PNM file> <DHGR file>");
|
||||
return 0;
|
||||
}
|
BIN
src/dhgr.tk/utils/dhgrrgb.exe
Executable file
BIN
src/dhgr.tk/utils/dhgrrgb.exe
Executable file
Binary file not shown.
586
src/dhgr.tk/utils/dhgrrgb.pla
Normal file
586
src/dhgr.tk/utils/dhgrrgb.pla
Normal file
@@ -0,0 +1,586 @@
|
||||
include "inc/cmdsys.plh"
|
||||
include "inc/args.plh"
|
||||
include "inc/fileio.plh"
|
||||
include "inc/int32.plh"
|
||||
include "dhgr.tk/inc/dhgrlib.plh"
|
||||
include "dhgr.tk/inc/dhgrutils.plh"
|
||||
|
||||
sysflags resxtxt1|reshgr1|resxhgr1
|
||||
|
||||
// Bit patterns and associated default NTSC colors
|
||||
// NTSC_BLACK = 0000
|
||||
// NTSC_DRKBLUE = 0001 73, 14, 116
|
||||
// NTSC_DRKGREEN = 0010 0, 104, 100
|
||||
// NTSC_BROWN = 0100 55, 113, 11
|
||||
// NTSC_MAGENTA = 1000 127, 23, 27
|
||||
// NTSC_PURPLE = 1001
|
||||
// NTSC_MEDBLUE = 0011
|
||||
// NTSC_LTBLUE = 1011
|
||||
// NTSC_AQUA = 0111
|
||||
// NTSC_GREEN = 0110
|
||||
// NTSC_ORANGE = 1100
|
||||
// NTSC_PINK = 1101
|
||||
// NTSC_YELLOW = 1110
|
||||
// NTSC_WHITE = 1111
|
||||
|
||||
const RED = 0
|
||||
const GRN = 1
|
||||
const BLU = 2
|
||||
// According to what I could find out about the NTSC color wheel:
|
||||
// Red maxes at 103.5 degrees
|
||||
// Green maxes at 240.7 degrees
|
||||
// Blue maxes at 347.1 degrees
|
||||
const RED_PHASE_NTSC = 104
|
||||
const GREEN_PHASE_NTSC = 241
|
||||
const BLUE_PHASE_NTSC = 347
|
||||
// Ideal phase angles for 4 phase
|
||||
const RED_PHASE_IDEAL = 90
|
||||
const GREEN_PHASE_IDEAL = 270
|
||||
const BLUE_PHASE_IDEAL = 360
|
||||
// Equal 120 deg phase angles
|
||||
const RED_PHASE_EQUAL = 120
|
||||
const GREEN_PHASE_EQUAL = 240
|
||||
const BLUE_PHASE_EQUAL = 360
|
||||
// Simplified phase angles: 90 deg between R and B, 135 between RG and BG
|
||||
const RED_PHASE_SIMPLE = 90
|
||||
const GREEN_PHASE_SIMPLE = 225
|
||||
const BLUE_PHASE_SIMPLE = 360
|
||||
const GREY_CHROMA = 32 * 4 / 3
|
||||
// Flags
|
||||
const GREY_HACK = $01 // Remap GREY1->GREY2 hack
|
||||
const MEM_MODE = $02 // Render to memory surface
|
||||
const DUMP_STATE = $04 // Dump internal state
|
||||
const RAW_INFILE = $08 // Raw 560x192 24BPP RGB values
|
||||
const MATCH_ONE = 8
|
||||
const MATCH_ZERO = 0
|
||||
byte clrRot = $00,$02,$04,$06,$08,$0A,$0C,$0E
|
||||
byte = $01,$03,$05,$07,$09,$0B,$0D,$0F
|
||||
var sin90[] // first 90 degrees of sin in fixed s.15 format
|
||||
var = 0, 571, 1143, 1714, 2285, 2855, 3425, 3993
|
||||
var = 4560, 5126, 5690, 6252, 6812, 7371, 7927, 8480
|
||||
var = 9032, 9580, 10125, 10668, 11207, 11743, 12275, 12803
|
||||
var = 13327, 13848, 14364, 14876, 15383, 15886, 16383, 16876
|
||||
var = 17364, 17846, 18323, 18794, 19260, 19720, 20173, 20621
|
||||
var = 21062, 21497, 21926, 22347, 22762, 23170, 23571, 23964
|
||||
var = 24351, 24730, 25101, 25465, 25821, 26169, 26509, 26841
|
||||
var = 27165, 27481, 27788, 28087, 28377, 28659, 28932, 29196
|
||||
var = 29451, 29697, 29935, 30163, 30381, 30591, 30791, 30982
|
||||
var = 31164, 31336, 31498, 31651, 31794, 31928, 32051, 32165
|
||||
var = 32270, 32364, 32449, 32523, 32588, 32643, 32688, 32723
|
||||
var = 32748, 32763, 32767
|
||||
word hgrScan[] // HGR scanline order for saving memory buffer as DHGR
|
||||
word = $0000,$0400,$0800,$0C00,$1000,$1400,$1800,$1C00
|
||||
word = $0080,$0480,$0880,$0C80,$1080,$1480,$1880,$1C80
|
||||
word = $0100,$0500,$0900,$0D00,$1100,$1500,$1900,$1D00
|
||||
word = $0180,$0580,$0980,$0D80,$1180,$1580,$1980,$1D80
|
||||
word = $0200,$0600,$0A00,$0E00,$1200,$1600,$1A00,$1E00
|
||||
word = $0280,$0680,$0A80,$0E80,$1280,$1680,$1A80,$1E80
|
||||
word = $0300,$0700,$0B00,$0F00,$1300,$1700,$1B00,$1F00
|
||||
word = $0380,$0780,$0B80,$0F80,$1380,$1780,$1B80,$1F80
|
||||
word = $0028,$0428,$0828,$0C28,$1028,$1428,$1828,$1C28
|
||||
word = $00A8,$04A8,$08A8,$0CA8,$10A8,$14A8,$18A8,$1CA8
|
||||
word = $0128,$0528,$0928,$0D28,$1128,$1528,$1928,$1D28
|
||||
word = $01A8,$05A8,$09A8,$0DA8,$11A8,$15A8,$19A8,$1DA8
|
||||
word = $0228,$0628,$0A28,$0E28,$1228,$1628,$1A28,$1E28
|
||||
word = $02A8,$06A8,$0AA8,$0EA8,$12A8,$16A8,$1AA8,$1EA8
|
||||
word = $0328,$0728,$0B28,$0F28,$1328,$1728,$1B28,$1F28
|
||||
word = $03A8,$07A8,$0BA8,$0FA8,$13A8,$17A8,$1BA8,$1FA8
|
||||
word = $0050,$0450,$0850,$0C50,$1050,$1450,$1850,$1C50
|
||||
word = $00D0,$04D0,$08D0,$0CD0,$10D0,$14D0,$18D0,$1CD0
|
||||
word = $0150,$0550,$0950,$0D50,$1150,$1550,$1950,$1D50
|
||||
word = $01D0,$05D0,$09D0,$0DD0,$11D0,$15D0,$19D0,$1DD0
|
||||
word = $0250,$0650,$0A50,$0E50,$1250,$1650,$1A50,$1E50
|
||||
word = $02D0,$06D0,$0AD0,$0ED0,$12D0,$16D0,$1AD0,$1ED0
|
||||
word = $0350,$0750,$0B50,$0F50,$1350,$1750,$1B50,$1F50
|
||||
word = $03D0,$07D0,$0BD0,$0FD0,$13D0,$17D0,$1BD0,$1FD0
|
||||
var surfMem, surfSpan
|
||||
var[12] ntscChroma
|
||||
var prevRed, prevBlu, prevGrn
|
||||
byte[256] gammaRGB // RGB gamma correction
|
||||
var[3] phase = RED_PHASE_NTSC, GREEN_PHASE_NTSC, BLUE_PHASE_NTSC
|
||||
byte gamma = 0 // Gamma correction
|
||||
var brightness = 0
|
||||
var saturation = 255 // 1.0
|
||||
var tint = 22 // = 45/2 deg
|
||||
byte errDiv = 4
|
||||
byte flags = GREY_HACK
|
||||
var rgbErr // Running color error array
|
||||
var arg
|
||||
|
||||
// Handy numeric functions
|
||||
|
||||
def min(a, b)#1
|
||||
return a < b ?? a :: b
|
||||
end
|
||||
|
||||
def max(a, b)#1
|
||||
return a > b ?? a :: b
|
||||
end
|
||||
|
||||
def sin(deg)#1
|
||||
while deg > 360; deg = deg - 360; loop
|
||||
while deg < 0; deg = deg + 360; loop
|
||||
if deg <= 90
|
||||
return sin90[deg]
|
||||
elsif deg <= 180
|
||||
return sin90[180 - deg]
|
||||
elsif deg <= 270
|
||||
return -sin90[deg - 180]
|
||||
fin
|
||||
return -sin90[360 - deg]
|
||||
end
|
||||
|
||||
def cos(deg)#1
|
||||
return sin(deg + 90)
|
||||
end
|
||||
|
||||
def dist(dr, dg, db)#2 // Linear distance
|
||||
res[t_i32] rr, gg
|
||||
|
||||
loadi16(dr)
|
||||
muli16(dr)
|
||||
store32(@rr)
|
||||
loadi16(dg)
|
||||
muli16(dg)
|
||||
store32(@gg)
|
||||
loadi16(db)
|
||||
muli16(db)
|
||||
add32(@gg)
|
||||
add32(@rr)
|
||||
store32(@rr)
|
||||
return rr:[0], rr:[1]
|
||||
end
|
||||
|
||||
def atoi(strptr)#1
|
||||
var num, len, sign
|
||||
|
||||
sign = 1
|
||||
num = 0
|
||||
len = ^strptr
|
||||
strptr++
|
||||
if ^strptr == '-'
|
||||
sign = -1
|
||||
strptr++
|
||||
len--
|
||||
elsif ^strptr == '+'
|
||||
strptr++
|
||||
len--
|
||||
fin
|
||||
while len and ^strptr >= '0' and ^strptr <= '9'
|
||||
num = num * 10 + ^strptr - '0'
|
||||
strptr++
|
||||
len--
|
||||
loop
|
||||
return num * sign
|
||||
end
|
||||
|
||||
def calcChroma(angle)#0
|
||||
var r, g, b
|
||||
byte i
|
||||
|
||||
for i = 0 to 3
|
||||
// Calculate RGB for this DHGR pixel
|
||||
//r = max(0, (saturation + (cos(angle - phase[RED]) >> 7)))
|
||||
//g = max(0, (saturation + (cos(angle - phase[GRN]) >> 7)))
|
||||
//b = max(0, (saturation + (cos(angle - phase[BLU]) >> 7)))
|
||||
r = saturation + (cos(angle - phase[RED]) >> 7)
|
||||
g = saturation + (cos(angle - phase[GRN]) >> 7)
|
||||
b = saturation + (cos(angle - phase[BLU]) >> 7)
|
||||
// Make chroma add up to white
|
||||
ntscChroma[i*3 + RED] = (r + 2) / 4
|
||||
ntscChroma[i*3 + GRN] = (g + 2) / 4
|
||||
ntscChroma[i*3 + BLU] = (b + 2) / 4
|
||||
// Next NTSC chroma pixel
|
||||
angle = angle - 90
|
||||
next
|
||||
end
|
||||
|
||||
def rgbMatch(r, g, b, errptr, cx)#1
|
||||
var currRed, currGrn, currBlu
|
||||
var er, eg, eb
|
||||
byte pix,
|
||||
res[t_i32] pd
|
||||
|
||||
// Previous RGB minus current chroma cycle
|
||||
prevRed = (prevRed * 3) / 4
|
||||
prevGrn = (prevGrn * 3) / 4
|
||||
prevBlu = (prevBlu * 3) / 4
|
||||
// Current potential RGB
|
||||
cx = cx * 3
|
||||
currRed = prevRed + ntscChroma[cx+RED]
|
||||
currGrn = prevGrn + ntscChroma[cx+GRN]
|
||||
currBlu = prevBlu + ntscChroma[cx+BLU]
|
||||
// Match next chroma subcycle
|
||||
pd:[0], pd:[1] = dist(r - prevRed, g - prevGrn, b - prevBlu)
|
||||
dist(r - currRed, g - currGrn, b - currBlu)
|
||||
if islt32(@pd)
|
||||
// RGB better matched with next chroma color
|
||||
prevRed = currRed
|
||||
prevGrn = currGrn
|
||||
prevBlu = currBlu
|
||||
pix = MATCH_ONE
|
||||
else
|
||||
pix = MATCH_ZERO
|
||||
fin
|
||||
// Propogate error down and forward
|
||||
er = r - prevRed
|
||||
errptr=>[RED] = er
|
||||
eg = g - prevGrn
|
||||
errptr=>[GRN] = eg
|
||||
eb = b - prevBlu
|
||||
errptr=>[BLU] = eb
|
||||
errptr=>[RED+3] = er + errptr=>[RED+3]
|
||||
errptr=>[GRN+3] = eg + errptr=>[GRN+3]
|
||||
errptr=>[BLU+3] = eb + errptr=>[BLU+3]
|
||||
return pix
|
||||
end
|
||||
|
||||
def rgbInit#0
|
||||
var i
|
||||
res[t_i32] g32
|
||||
|
||||
if flags & DUMP_STATE
|
||||
puts("Gamma = "); puti(sext(gamma)); putln
|
||||
fin
|
||||
when gamma
|
||||
is 255 // (i + 1 / i^2) / 2
|
||||
for i = 0 to 255
|
||||
loadi16(i)
|
||||
muli16(i)
|
||||
addi16(127)
|
||||
divi16(255)
|
||||
neg32
|
||||
addi16(255)
|
||||
addi16(255 - i)
|
||||
divi16(2)
|
||||
store32(@g32)
|
||||
gammaRGB[255 - i] = g32
|
||||
next
|
||||
break
|
||||
is 254 // 1 - i^2
|
||||
for i = 0 to 255
|
||||
loadi16(i)
|
||||
muli16(i)
|
||||
addi16(127)
|
||||
divi16(255)
|
||||
neg32
|
||||
addi16(255)
|
||||
store32(@g32)
|
||||
gammaRGB[255 - i] = g32
|
||||
next
|
||||
break
|
||||
is 2 // 1/(i^2)
|
||||
for i = 0 to 255
|
||||
loadi16(i)
|
||||
muli16(i)
|
||||
addi16(127)
|
||||
divi16(255)
|
||||
store32(@g32)
|
||||
gammaRGB[i] = g32
|
||||
next
|
||||
break
|
||||
is 1 // (i + i^2) / 2
|
||||
for i = 0 to 255
|
||||
loadi16(i)
|
||||
muli16(i)
|
||||
addi16(127)
|
||||
divi16(255)
|
||||
addi16(i)
|
||||
divi16(2)
|
||||
store32(@g32)
|
||||
gammaRGB[i] = g32
|
||||
next
|
||||
break
|
||||
otherwise // i
|
||||
for i = 0 to 255
|
||||
gammaRGB[i] = i
|
||||
next
|
||||
wend
|
||||
if brightness
|
||||
for i = 0 to 255
|
||||
gammaRGB[i] = max(0, min(255, gammaRGB[i] + brightness))
|
||||
next
|
||||
fin
|
||||
calcChroma(tint)
|
||||
if flags & DUMP_STATE
|
||||
puts("Err Div = "); puti(errDiv); putln
|
||||
puts("Brightness = "); puti(brightness); putln
|
||||
puts("Tint = "); puti(tint); putln
|
||||
puts("Saturation = "); puti(saturation); putln
|
||||
puts("Chroma cycle RGB =\n")
|
||||
for i = 0 to 3
|
||||
putc('[')
|
||||
puti(ntscChroma[i*3 + RED]); putc(',')
|
||||
puti(ntscChroma[i*3 + GRN]); putc(',')
|
||||
puti(ntscChroma[i*3 + BLU]); puts("]\n")
|
||||
next
|
||||
if not (flags & MEM_MODE); getc; fin
|
||||
fin
|
||||
if flags & MEM_MODE
|
||||
surfMem, surfSpan = dhgrAllocBl7Mem(SCR_WIDTH, SCR_HEIGHT)
|
||||
dhgrSurfMem(OP_XOR, SCR_HEIGHT, surfMem, surfSpan)
|
||||
dhgrOp(OP_SRC) // Force op recalc
|
||||
dcgrColor(CLR_BLACK)
|
||||
dhgrClearBl7(0, 0, surfSpan >> 2, SCR_HEIGHT)
|
||||
else
|
||||
dhgrMode(DHGR_COLOR_MODE)
|
||||
fin
|
||||
end
|
||||
|
||||
def rgbExit#0
|
||||
heaprelease(rgbErr)
|
||||
if not (flags & MEM_MODE)
|
||||
dhgrMode(DHGR_TEXT_MODE)
|
||||
fin
|
||||
end
|
||||
|
||||
def pnmReadElement(refnum, bufptr)#1
|
||||
var lenptr
|
||||
|
||||
lenptr = bufptr
|
||||
repeat
|
||||
^lenptr = 0
|
||||
bufptr = lenptr + 1
|
||||
if fileio:read(refnum, bufptr, 1) == 1 and ^bufptr == '#' // Comment
|
||||
^lenptr++
|
||||
bufptr++
|
||||
while fileio:read(refnum, bufptr, 1) == 1 and ^bufptr >= ' '
|
||||
loop
|
||||
else
|
||||
repeat // Read white space seperated element
|
||||
^lenptr++
|
||||
bufptr++
|
||||
until fileio:read(refnum, bufptr, 1) <> 1 \
|
||||
or ^bufptr <= ' ' \
|
||||
or ^lenptr > 32
|
||||
fin
|
||||
until ^lenptr and ^(lenptr + 1) <> '#' // Repeat until not comment
|
||||
if flags & DUMP_STATE; puts(lenptr); putc(' '); fin
|
||||
return lenptr
|
||||
end
|
||||
|
||||
def pnmVerifyHeader(refnum)#1
|
||||
byte[128] buf
|
||||
if flags & DUMP_STATE; puts("PNM = "); fin
|
||||
pnmReadElement(refnum, @buf)
|
||||
if buf[0] <> 2 and buf[1] <> 'P' and buf[2] <> '6'
|
||||
puts("Invalid PNM magic #: "); putc(buf[1]); putc(buf[2]); putln
|
||||
return FALSE
|
||||
fin
|
||||
if atoi(pnmReadElement(refnum, @buf)) <> 560
|
||||
puts("Width not 560: "); puts(@buf); putln
|
||||
return FALSE
|
||||
fin
|
||||
if atoi(pnmReadElement(refnum, @buf)) <> 192
|
||||
puts("Height not 192: "); puts(@buf); putln
|
||||
return FALSE
|
||||
fin
|
||||
if atoi(pnmReadElement(refnum, @buf)) <> 255
|
||||
puts("Depth not 255: "); puts(@buf); putln
|
||||
return FALSE
|
||||
fin
|
||||
if flags & DUMP_STATE; putln; fin
|
||||
return TRUE
|
||||
end
|
||||
|
||||
def rgbImportExport(rgbfile, dhgrfile)#0
|
||||
byte refnum, chromaBits
|
||||
var i, j, c, r, g, b
|
||||
var rgbScanline, rgbptr, errptr
|
||||
|
||||
refnum = fileio:open(rgbfile)
|
||||
if refnum
|
||||
if not (flags & RAW_INFILE)
|
||||
if not pnmVerifyHeader(refnum)
|
||||
fileio:close(refnum)
|
||||
return
|
||||
fin
|
||||
fin
|
||||
rgbInit
|
||||
rgbScanline = heapalloc(560 * 3)
|
||||
rgbErr = heapalloc(561 * 3 * 2)
|
||||
if rgbErr and rgbScanline
|
||||
// Init error propogation array
|
||||
memset(rgbErr, 0, 560 * 3 * 2)
|
||||
memset(rgbScanline, 0, 560 * 3)
|
||||
for j = 0 to 191
|
||||
fileio:read(refnum, rgbScanline, 560 * 3)
|
||||
prevRed, prevGrn, prevBLu = 96, 96, 96 // Reset prev RGB
|
||||
rgbptr = rgbScanline
|
||||
errptr = rgbErr
|
||||
for i = 0 to 139
|
||||
chromaBits = 0
|
||||
for c = 0 to 3
|
||||
// Calc best match
|
||||
r = gammaRGB[rgbptr->[RED]]
|
||||
g = gammaRGB[rgbptr->[GRN]]
|
||||
b = gammaRGB[rgbptr->[BLU]]
|
||||
if errDiv
|
||||
r = r + errptr=>[RED] / errDiv
|
||||
g = g + errptr=>[GRN] / errDiv
|
||||
b = b + errptr=>[BLU] / errDiv
|
||||
fin
|
||||
chromaBits = (chromaBits >> 1) | rgbMatch(r, g, b, errptr, c)
|
||||
rgbptr = rgbptr + 3
|
||||
errptr = errptr + 3 * 2
|
||||
next
|
||||
if flags & GREY_HACK and chromaBits == $0A // Bits are reversed
|
||||
// Map GREY1 -> GREY2
|
||||
chromaBits = $05
|
||||
fin
|
||||
dcgrColor(clrRot[chromaBits])
|
||||
dcgrPixel(i, j)
|
||||
next
|
||||
if flags & MEM_MODE; putc('.'); fin
|
||||
if ^$C000 == $83
|
||||
break
|
||||
fin
|
||||
next
|
||||
fileio:close(refnum)
|
||||
if ^dhgrfile
|
||||
if flags & MEM_MODE
|
||||
heaprelease(rgbScanline) // Free up some memory
|
||||
if MACHID & $F0 <> $B0
|
||||
// Use allocated buffer on non 128K //e
|
||||
rgbScanline = heapalloc($2000)
|
||||
else
|
||||
// Use HGR memory (already reserved) on 128K //e
|
||||
rgbScanline = $2000
|
||||
fin
|
||||
if rgbScanline
|
||||
memset(rgbScanline, 0, $2000)
|
||||
fileio:destroy(dhgrfile)
|
||||
fileio:create(dhgrfile, $06, $2000)
|
||||
refnum = fileio:open(dhgrfile)
|
||||
if refnum
|
||||
// Reorder scanlines into HGR format
|
||||
rgbptr = surfMem
|
||||
for i = 0 to SCR_HEIGHT-1
|
||||
memcpy(rgbScanline+hgrScan[i], rgbptr, 40)
|
||||
rgbptr = rgbptr + surfSpan
|
||||
next
|
||||
// Write AUX bytes
|
||||
fileio:write(refnum, rgbScanline, $2000)
|
||||
rgbptr = surfMem + surfSpan / 2
|
||||
for i = 0 to SCR_HEIGHT-1
|
||||
memcpy(rgbScanline+hgrScan[i], rgbptr, 40)
|
||||
rgbptr = rgbptr + surfSpan
|
||||
next
|
||||
// Write MAIN bytes
|
||||
fileio:write(refnum, rgbScanline, $2000)
|
||||
fileio:close(refnum)
|
||||
fin
|
||||
putln
|
||||
fin
|
||||
else
|
||||
screenWrite(dhgrfile)
|
||||
fin
|
||||
fin
|
||||
if not (flags & MEM_MODE); getc; fin
|
||||
rgbExit
|
||||
fin
|
||||
else
|
||||
puts("Unable to open "); puts(rgbfile); putln
|
||||
fin
|
||||
end
|
||||
|
||||
puts("DHGR RGB converter 1.1\n")
|
||||
arg = argNext(argFirst)
|
||||
if ^arg
|
||||
while ^(arg + 1) == '-'
|
||||
when toupper(^(arg + 2))
|
||||
is 'B' // Set brightness
|
||||
if ^arg > 2
|
||||
^(arg + 2) = ^arg - 2
|
||||
brightness = atoi(arg + 2)
|
||||
fin
|
||||
break
|
||||
is 'C' // Disable hack for GREY remapping
|
||||
flags = flags & ~GREY_HACK
|
||||
break
|
||||
is 'D' // Dump internal staet
|
||||
flags = flags | DUMP_STATE
|
||||
break
|
||||
is 'E' // Set error strength
|
||||
if ^arg > 2
|
||||
errDiv = ^(arg + 3) - '0'
|
||||
if ^arg > 3
|
||||
errDiv = errDiv * 10 + ^(arg + 4) - '0'
|
||||
fin
|
||||
fin
|
||||
break
|
||||
is 'G' // Set gamma amount
|
||||
if ^arg > 2
|
||||
^(arg + 2) = ^arg - 2
|
||||
gamma = atoi(arg + 2)
|
||||
fin
|
||||
break
|
||||
is 'P' // RGB phase angle
|
||||
when toupper(^(arg + 3))
|
||||
is 'I' // Use ideal 4 sub-phase angles
|
||||
phase[RED] = RED_PHASE_IDEAL
|
||||
phase[GRN] = GREEN_PHASE_IDEAL
|
||||
phase[BLU] = BLUE_PHASE_IDEAL
|
||||
break
|
||||
is 'E' // Use equal 120 deg phase angles
|
||||
phase[RED] = RED_PHASE_EQUAL
|
||||
phase[GRN] = GREEN_PHASE_EQUAL
|
||||
phase[BLU] = BLUE_PHASE_EQUAL
|
||||
break
|
||||
is 'S' // Use simplified 90 degree and opposite phase angles
|
||||
phase[RED] = RED_PHASE_SIMPLE
|
||||
phase[GRN] = GREEN_PHASE_SIMPLE
|
||||
phase[BLU] = BLUE_PHASE_SIMPLE
|
||||
break
|
||||
//is 'N' // Use theoretical NTSC phase angles
|
||||
otherwise
|
||||
phase[RED] = RED_PHASE_NTSC
|
||||
phase[GRN] = GREEN_PHASE_NTSC
|
||||
phase[BLU] = BLUE_PHASE_NTSC
|
||||
break
|
||||
wend
|
||||
break
|
||||
is 'R' // Raw input mode - no PNM header
|
||||
flags = flags | RAW_INFILE
|
||||
break
|
||||
is 'S' // Adjust saturation
|
||||
if ^arg > 2
|
||||
^(arg + 2) = ^arg - 2
|
||||
saturation = saturation - atoi(arg + 2)
|
||||
fin
|
||||
break
|
||||
is 'T' // Adjust tint
|
||||
if ^arg > 2
|
||||
^(arg + 2) = ^arg - 2
|
||||
tint = tint + atoi(arg + 2)
|
||||
fin
|
||||
break
|
||||
is 'V' // No video output, memory mode only (for portable VM)
|
||||
flags = flags | MEM_MODE
|
||||
break
|
||||
otherwise
|
||||
puts("? option:"); putc(^(arg + 2)); putln
|
||||
wend
|
||||
arg = argNext(arg)
|
||||
loop
|
||||
if ^arg
|
||||
rgbImportExport(arg, argNext(arg))
|
||||
fin
|
||||
return 0
|
||||
fin
|
||||
puts("Usage:\n")
|
||||
puts(" DHGRRGB\n")
|
||||
puts(" [-B#] = Brightness: -255..255\n")
|
||||
puts(" [-C] = Composite output\n")
|
||||
puts(" [-D] = Dump state\n")
|
||||
puts(" [-E#] = Error strength: 1..255\n")
|
||||
puts(" 0 = no err\n")
|
||||
puts(" [-G#] = Gamma: 2, 1, 0, -1, -2\n")
|
||||
puts(" [-P<I,E,S,N>] = Phase: Ideal, Equal\n")
|
||||
puts(" Simple, NTSC\n")
|
||||
puts(" [-R] = Raw image file, no header\n")
|
||||
puts(" [-S#] = Saturation: -255..255\n")
|
||||
puts(" [-T#] = Tint: -360..360 (in degrees)\n")
|
||||
puts(" [-V] = no Video output, mem only\n")
|
||||
puts(" IMAGEFILE [DHGRFILE]\n")
|
||||
done
|
162
src/dhgr.tk/utils/dhgrshow.pla
Normal file
162
src/dhgr.tk/utils/dhgrshow.pla
Normal file
@@ -0,0 +1,162 @@
|
||||
include "inc/cmdsys.plh"
|
||||
include "inc/args.plh"
|
||||
include "inc/fileio.plh"
|
||||
include "inc/matchfiles.plh"
|
||||
include "inc/lz4.plh"
|
||||
include "inc/longjmp.plh"
|
||||
include "dhgr.tk/inc/dhgrlib.plh"
|
||||
include "dhgr.tk/inc/dhgrutils.plh"
|
||||
include "inc/vblank.plh"
|
||||
|
||||
sysflags resxtxt1|reshgr1|resxhgr1|reshgr2|nojitc
|
||||
const page1m = $C054
|
||||
const page1x = $C055
|
||||
|
||||
byte dolz4, quit
|
||||
var arg, srcfilelist, srcpath, srcexp, srccnt
|
||||
var entrylist, entrycnt
|
||||
var retval
|
||||
var pause = 4
|
||||
res[t_except] exit
|
||||
//
|
||||
// Copy string with upper case conversion
|
||||
//
|
||||
def struprcpy(dst, src)#0
|
||||
byte i
|
||||
|
||||
if ^src
|
||||
for i = 1 to ^src
|
||||
dst->[i] = toupper(src->[i])
|
||||
next
|
||||
fin
|
||||
^dst = ^src
|
||||
end
|
||||
|
||||
def fail(msg)#0
|
||||
dhgrMode(DHGR_TEXT_MODE)
|
||||
puts(msg)
|
||||
putln
|
||||
throw(@exit, -1)
|
||||
end
|
||||
|
||||
def screenShow(filestr)#0
|
||||
if dolz4
|
||||
^page1x // Decompress into AUX screen bytes
|
||||
when lz4Read(filestr, $2000, $6000, $2000, $6000)
|
||||
is LZ4_INVALID
|
||||
fail("Not LZ4 file.\n")
|
||||
is LZ4_WRONG_VERSION
|
||||
fail("Wrong LZ4 version.\n")
|
||||
is LZ4_NOT_64K
|
||||
fail("Not 64K block size.\n")
|
||||
wend
|
||||
^page1m // Copy into MAIN screen bytes
|
||||
memcpy($2000, $4000, $2000)
|
||||
else
|
||||
screenRead(filestr)
|
||||
fin
|
||||
end
|
||||
|
||||
def delay_getkey#1
|
||||
var busywait, wastetime
|
||||
|
||||
for busywait = 0 to 60*pause
|
||||
waitVBL
|
||||
if ^$C000 > 127
|
||||
return (^$C010 & $7F) == $03
|
||||
fin
|
||||
next
|
||||
return FALSE
|
||||
end
|
||||
|
||||
def atoi(strptr)#1
|
||||
var num, len, sign
|
||||
|
||||
sign = 1
|
||||
num = 0
|
||||
len = ^strptr
|
||||
strptr++
|
||||
if ^strptr == '-'
|
||||
sign = -1
|
||||
strptr++
|
||||
len--
|
||||
elsif ^strptr == '+'
|
||||
strptr++
|
||||
len--
|
||||
fin
|
||||
while len and ^strptr >= '0' and ^strptr <= '9'
|
||||
num = num * 10 + ^strptr - '0'
|
||||
strptr++
|
||||
len--
|
||||
loop
|
||||
return num * sign
|
||||
end
|
||||
|
||||
arg = argNext(argFirst)
|
||||
while ^arg and ^(arg + 1) == '-'
|
||||
//
|
||||
// Process flags
|
||||
//
|
||||
when toupper(^(arg + 2))
|
||||
is 'Z' // decompress screens
|
||||
dolz4 = TRUE
|
||||
break
|
||||
is 'P' // pause between screens
|
||||
if ^arg > 2
|
||||
^(arg + 2) = ^arg - 2
|
||||
pause = atoi(arg + 2)
|
||||
fin
|
||||
break
|
||||
wend
|
||||
arg = argNext(arg)
|
||||
loop
|
||||
while ^arg
|
||||
//
|
||||
// Add to source list
|
||||
//
|
||||
srcpath, srcexp = splitPathFile(arg)
|
||||
entrylist, entrycnt = matchList(srcpath, srcexp)
|
||||
if not entrylist
|
||||
puts(arg); puts(" ???\n")
|
||||
else
|
||||
if not srcfilelist
|
||||
srcfilelist = entrylist
|
||||
fin
|
||||
srccnt = srccnt + entrycnt
|
||||
while entrycnt
|
||||
//
|
||||
// Prepend path to filename
|
||||
//
|
||||
strcpy(entrylist, strcat(strcpy(heapmark, srcpath), entrylist))
|
||||
entrylist = entrylist + t_fileentry
|
||||
entrycnt--
|
||||
loop
|
||||
fin
|
||||
arg = argNext(arg)
|
||||
loop
|
||||
if srccnt
|
||||
dhgrMode(DHGR_COLOR_MODE)
|
||||
retval = except(@exit)
|
||||
if retval == 0
|
||||
if srccnt == 1
|
||||
screenShow(srcfilelist)
|
||||
getc
|
||||
else
|
||||
repeat
|
||||
entrylist = srcfilelist
|
||||
entrycnt = srccnt
|
||||
while entrycnt
|
||||
screenShow(entrylist)
|
||||
entrylist = entrylist + t_fileentry
|
||||
entrycnt--
|
||||
quit = delay_getkey
|
||||
if quit; break; fin
|
||||
loop
|
||||
until quit
|
||||
fin
|
||||
dhgrMode(DHGR_TEXT_MODE)
|
||||
fin
|
||||
return retval
|
||||
fin
|
||||
puts("Usage: DHGRSHOW [-Z] <FILES>+\n")
|
||||
done
|
482
src/dhgr.tk/utils/dhgrspred.pla
Normal file
482
src/dhgr.tk/utils/dhgrspred.pla
Normal file
@@ -0,0 +1,482 @@
|
||||
include "inc/cmdsys.plh"
|
||||
include "inc/args.plh"
|
||||
include "inc/grlib.plh"
|
||||
include "inc/fileio.plh"
|
||||
include "dhgr.tk/inc/dhgrlib.plh"
|
||||
include "dhgr.tk/inc/dhgrutils.plh"
|
||||
|
||||
sysflags restxt1|restxt2|resxtxt1|reshgr1|resxhgr1 // Reserve all the pages
|
||||
|
||||
//byte sprinit = $55,$00,$00,$55
|
||||
//byte = $05,$AA,$AA,$50
|
||||
//byte = $A0,$FF,$FF,$0A
|
||||
//byte = $A0,$5F,$F5,$0A
|
||||
//byte = $A0,$5F,$F5,$0A
|
||||
//byte = $A0,$FF,$FF,$0A
|
||||
//byte = $05,$AA,$AA,$50
|
||||
//byte = $55,$00,$00,$55
|
||||
byte[40*48] grSprite
|
||||
byte[40*24] dcgrSprite
|
||||
char[64] filename = "Untitled"
|
||||
var arg
|
||||
byte quit = FALSE
|
||||
byte modified = TRUE
|
||||
byte xCursor = 20
|
||||
byte yCursor = 24
|
||||
byte clrCursor = 0
|
||||
byte bgTileOfst = 0
|
||||
|
||||
def dcgr2gr(width, height, pdcgrSpr)#0
|
||||
var pgrSpr
|
||||
byte i
|
||||
|
||||
memset(@grSprite, $0505, 40*48)
|
||||
pgrSpr = @grSprite + (24 - height / 2) * 40
|
||||
pgrSpr = pgrSpr + 20 - width / 2
|
||||
width--
|
||||
while height
|
||||
for i = 0 to width step 2
|
||||
*(pgrSpr + i) = (^pdcgrSpr & $0F) | ((^pdcgrSpr & $F0) << 4)
|
||||
pdcgrSpr++
|
||||
next
|
||||
pgrSpr = pgrSpr + 40
|
||||
height--
|
||||
loop
|
||||
end
|
||||
|
||||
def gr2dcgr#5
|
||||
word pgrSpr, pdcgrSpr
|
||||
byte xmin, xmax, width, ymin, ymax, height
|
||||
byte cl, ch, i, j
|
||||
|
||||
xmin = 39; xmax = 0
|
||||
ymin = 47; ymax = 0
|
||||
pgrSpr = @grSprite
|
||||
for j = 0 to 47
|
||||
for i = 0 to 39
|
||||
if ^(pgrSpr + i) <> $05
|
||||
if xmin > i; xmin = i; fin
|
||||
if xmax < i; xmax = i; fin
|
||||
if ymin > j; ymin = j; fin
|
||||
if ymax < j; ymax = j; fin
|
||||
fin
|
||||
next
|
||||
pgrSpr = pgrSpr + 40
|
||||
next
|
||||
pgrSpr = @grSprite + ymin * 40
|
||||
pdcgrSpr = @dcgrSprite
|
||||
for j = ymin to ymax
|
||||
for i = xmin to xmax step 2
|
||||
^pdcgrSpr = ^(pgrSpr + i) | (^(pgrSpr + i + 1) << 4)
|
||||
pdcgrSpr++
|
||||
next
|
||||
pgrSpr = pgrSpr + 40
|
||||
next
|
||||
width = xmax - xmin + 1
|
||||
height = ymax - ymin + 1
|
||||
pdcgrSpr = @dcgrSprite
|
||||
return xCursor - xmin, yCursor - ymin, width, height, pdcgrSpr
|
||||
end
|
||||
|
||||
def greasy2gr(pGreasy)#0
|
||||
var pgrSpr
|
||||
byte i, j
|
||||
|
||||
memset(@grSprite, $0505, 40*48)
|
||||
pgrSpr = @grSprite + (24 - 40 / 2) * 40
|
||||
pgrSpr = pgrSpr + 20 - 40 / 2
|
||||
for j = 0 to 39 step 2
|
||||
for i = 0 to 39
|
||||
^(pgrSpr + i) = ^(pGreasy + i) & $0F
|
||||
next
|
||||
pgrSpr = pgrSpr + 40
|
||||
for i = 0 to 39
|
||||
^(pgrSpr + i) = (^(pGreasy + i) & $F0) >> 4
|
||||
next
|
||||
pgrSpr = pgrSpr + 40
|
||||
pGreasy = pGreasy + 40
|
||||
next
|
||||
end
|
||||
|
||||
def frameRead(filestr, frame)#1
|
||||
var sprptr, sprsize
|
||||
byte refnum, numframes
|
||||
|
||||
sprptr = 0
|
||||
refnum = fileio:open(filestr)
|
||||
if refnum
|
||||
sprsize = 40 * 40 / 2
|
||||
sprptr = heapalloc(sprsize)
|
||||
if sprptr and fileio:read(refnum, @numframes, 1)
|
||||
if numframes < frame
|
||||
heaprelease(sprptr)
|
||||
sprptr = NULL
|
||||
fin
|
||||
fin
|
||||
if sprptr
|
||||
if fileio:setmark(refnum, (frame - 1) * sprsize + 1, 0)
|
||||
heaprelease(sprptr)
|
||||
sprptr = NULL
|
||||
elsif fileio:read(refnum, sprptr, sprsize) <> sprsize
|
||||
heaprelease(sprptr)
|
||||
sprptr = NULL
|
||||
fin
|
||||
fin
|
||||
fileio:close(refnum)
|
||||
fin
|
||||
return sprptr
|
||||
end
|
||||
|
||||
def importGreasy(frame)
|
||||
var sprptr
|
||||
|
||||
sprptr = frameRead(@filename, frame)
|
||||
if sprptr
|
||||
heaprelease(sprptr)
|
||||
greasy2gr(sprptr)
|
||||
else
|
||||
putc(7); puts("Error importing frame #")
|
||||
puti(frame); puts(" from "); puts(@filename); putln
|
||||
fin
|
||||
return sprptr == NULL
|
||||
end
|
||||
|
||||
def readFile#1
|
||||
var xorg, yorg, width, height, sprptr
|
||||
|
||||
xorg, yorg, width, height, sprptr = spriteRead(@filename)
|
||||
if sprptr
|
||||
heaprelease(sprptr)
|
||||
dcgr2gr(width, height, sprptr)
|
||||
fin
|
||||
return sprptr == NULL
|
||||
end
|
||||
|
||||
def writeFile#1
|
||||
var xorg, yorg, width, height, sprptr
|
||||
|
||||
xorg, yorg, width, height, sprptr = gr2dcgr
|
||||
return spriteWrite(@filename, xorg, yorg, width, height, sprptr)
|
||||
end
|
||||
|
||||
def strnum(strptr)
|
||||
var num
|
||||
|
||||
num = 0
|
||||
while ^strptr == ' '; strptr++; loop
|
||||
while ^strptr >= '0' and ^strptr <= '9'
|
||||
num = num * 10 + (^strptr - '0')
|
||||
strptr++
|
||||
loop
|
||||
return num
|
||||
end
|
||||
|
||||
def catalog(optpath)
|
||||
byte path[64]
|
||||
byte refnum
|
||||
byte firstblk
|
||||
byte entrylen, entriesblk
|
||||
byte i, type, len
|
||||
word databuff, entry
|
||||
|
||||
if ^optpath
|
||||
strcpy(@path, optpath)
|
||||
else
|
||||
fileio:getpfx(@path)
|
||||
puts(@path)
|
||||
putln
|
||||
fin
|
||||
databuff = heapalloc(512)
|
||||
refnum = fileio:open(@path)
|
||||
if perr
|
||||
return perr
|
||||
fin
|
||||
firstblk = 1
|
||||
while fileio:read(refnum, databuff, 512) == 512
|
||||
entry = databuff + 4
|
||||
if firstblk
|
||||
entrylen = databuff->$23
|
||||
entriesblk = databuff->$24
|
||||
entry = entry + entrylen
|
||||
fin
|
||||
for i = firstblk to entriesblk
|
||||
type = ^entry
|
||||
if type <> 0
|
||||
len = type & $0F
|
||||
^entry = len
|
||||
puts(entry)
|
||||
if type & $F0 == $D0 // Is it a directory?
|
||||
putc('/')
|
||||
len++
|
||||
fin
|
||||
for len = 20 - len downto 1
|
||||
putc(' ')
|
||||
next
|
||||
fin
|
||||
entry = entry + entrylen
|
||||
next
|
||||
firstblk = 0
|
||||
loop
|
||||
fileio:close(refnum)
|
||||
heaprelease(databuff)
|
||||
putln
|
||||
return 0
|
||||
end
|
||||
|
||||
def getCmd#1
|
||||
var cmdstr, xorg, yorg, width, height, sprptr, sprspan, grspr
|
||||
byte frame, i
|
||||
|
||||
while 1
|
||||
if modified; putc('*'); fin
|
||||
puts(@filename)
|
||||
cmdstr = gets(':'|$80)
|
||||
if ^cmdstr
|
||||
when toupper(^(cmdstr + 1))
|
||||
is 'G'
|
||||
if modified
|
||||
puts("Lose changes (Y/N)?")
|
||||
if toupper(getc) <> 'Y'
|
||||
break
|
||||
fin
|
||||
putln
|
||||
fin
|
||||
repeat // Skip to filename
|
||||
^cmdstr--
|
||||
memcpy(cmdstr + 1, cmdstr + 2, ^cmdstr)
|
||||
until ^cmdstr == 0 or ^(cmdstr + 1) <> ' '
|
||||
frame = 1
|
||||
if ^cmdstr
|
||||
for i = 1 to ^cmdstr
|
||||
if ^(cmdstr + i) == ','
|
||||
^(cmdstr + ^cmdstr + 1) = 0
|
||||
frame = strnum(cmdstr + i + 1)
|
||||
^cmdstr = i - 1
|
||||
break
|
||||
fin
|
||||
next
|
||||
if ^cmdstr
|
||||
memcpy(@filename, cmdstr, ^cmdstr + 1)
|
||||
elsif filename[filename - 2] == '.'
|
||||
filename = filename - 3
|
||||
fin
|
||||
fin
|
||||
if frame
|
||||
modified = importGreasy(frame)
|
||||
if not modified
|
||||
filename[filename + 1] = '.'
|
||||
filename[filename + 2] = '0' + frame / 10
|
||||
filename[filename + 3] = '0' + frame % 10
|
||||
filename = filename + 3
|
||||
fin
|
||||
fin
|
||||
break
|
||||
is 'R'
|
||||
if modified
|
||||
puts("Lose changes (Y/N)?")
|
||||
if toupper(getc) <> 'Y'
|
||||
break
|
||||
fin
|
||||
putln
|
||||
fin
|
||||
repeat // Skip to filename
|
||||
^cmdstr--
|
||||
memcpy(cmdstr + 1, cmdstr + 2, ^cmdstr)
|
||||
until ^cmdstr == 0 or ^(cmdstr + 1) <> ' '
|
||||
if ^cmdstr
|
||||
memcpy(@filename, cmdstr, ^cmdstr + 1)
|
||||
fin
|
||||
modified = readFile
|
||||
break
|
||||
is 'W'
|
||||
repeat // Skip to filename
|
||||
^cmdstr--
|
||||
memcpy(cmdstr + 1, cmdstr + 2, ^cmdstr)
|
||||
until ^cmdstr == 0 or ^(cmdstr + 1) <> ' '
|
||||
if ^cmdstr
|
||||
memcpy(@filename, cmdstr, ^cmdstr + 1)
|
||||
fin
|
||||
modified = writeFile
|
||||
break
|
||||
is 'C'
|
||||
repeat // Skip to pathname
|
||||
^cmdstr--
|
||||
memcpy(cmdstr + 1, cmdstr + 2, ^cmdstr)
|
||||
until ^cmdstr == 0 or ^(cmdstr + 1) <> ' '
|
||||
catalog(cmdstr)
|
||||
break
|
||||
is 'Q'
|
||||
if modified
|
||||
puts("Lose changes (Y/N)?")
|
||||
if toupper(getc) == 'Y'
|
||||
return TRUE
|
||||
fin
|
||||
putln
|
||||
else
|
||||
return TRUE
|
||||
fin
|
||||
break
|
||||
otherwise
|
||||
puts("?\n")
|
||||
wend
|
||||
else
|
||||
return FALSE
|
||||
fin
|
||||
loop
|
||||
return FALSE
|
||||
end
|
||||
|
||||
def flipV#0
|
||||
byte[40] tmpRow
|
||||
byte j
|
||||
|
||||
for j = 0 to 23
|
||||
memcpy(@tmpRow, @grSprite + j * 40, 40)
|
||||
memcpy(@grSprite + j * 40, @grSprite + (47 - j) * 40, 40)
|
||||
memcpy(@grSprite + (47 - j) * 40, @tmpRow, 40)
|
||||
next
|
||||
end
|
||||
|
||||
def flipH#0
|
||||
byte i, j, tmpPix
|
||||
|
||||
for i = 0 to 19
|
||||
for j = 0 to 47
|
||||
tmpPix = grSprite[j * 40 + i]
|
||||
grSprite[j * 40 + i] = grSprite[j * 40 + 39 - i]
|
||||
grSprite[j * 40 + 39 - i] = tmpPix
|
||||
next
|
||||
next
|
||||
end
|
||||
|
||||
def grView#0
|
||||
grClear(5)
|
||||
grBLT(0, 0, 40, 48, @grSprite)
|
||||
end
|
||||
|
||||
def grGetKey#1
|
||||
byte f, c
|
||||
|
||||
^$C010
|
||||
c = grSprite[yCursor * 40 + xCursor] & $0F
|
||||
f = 0
|
||||
while ^$C000 < 128
|
||||
when f
|
||||
is 0
|
||||
grColor(clrCursor)
|
||||
grPlot(xCursor, yCursor)
|
||||
break
|
||||
is 128
|
||||
grColor(c == clrCursor ?? c ^ $0F :: c)
|
||||
grPlot(xCursor, yCursor)
|
||||
break
|
||||
wend
|
||||
f++
|
||||
loop
|
||||
grColor(c)
|
||||
grPlot(xCursor, yCursor)
|
||||
return ^$C010 & $7F
|
||||
end
|
||||
|
||||
def dcgrTestView(bounce)#0
|
||||
var pgr, pdc
|
||||
byte i, j, inci, incj
|
||||
|
||||
pgr = @grSprite
|
||||
pdc = @dcgrSprite
|
||||
for j = 0 to 47
|
||||
for i = 0 to 39 step 2
|
||||
^pdc = ^(pgr + i) | (^(pgr + i + 1) << 4)
|
||||
pdc++
|
||||
next
|
||||
pgr = pgr + 40
|
||||
next
|
||||
i = 70-20; inci = bounce
|
||||
j = 96-24; incj = bounce
|
||||
grMode(grOff)
|
||||
dhgrMode(DHGR_COLOR_MODE)
|
||||
dcgrColor(clrCursor)
|
||||
dhgrClearBl7(0, 0, SCR_WIDTH7, SCR_HEIGHT)
|
||||
while ^$C000 < 128
|
||||
dcgrPixMap(i, j, 40, 48, @dcgrSprite)
|
||||
i = i + inci
|
||||
if i < 1 or i > 139-40; inci = -inci; fin
|
||||
j = j + incj
|
||||
if j < 1 or j > 191-48; incj = -incj; fin
|
||||
loop
|
||||
^$C010
|
||||
dhgrMode(DHGR_TEXT_MODE)
|
||||
grMode(grPage1)
|
||||
grDrawBuf(grPage1)
|
||||
grView
|
||||
end
|
||||
|
||||
arg = argNext(argFirst)
|
||||
if ^arg
|
||||
memcpy(@filename, arg, ^arg + 1)
|
||||
modified = readFile
|
||||
fin
|
||||
if modified
|
||||
memset(@grSprite, $0505, 40*48)
|
||||
modified = 0
|
||||
fin
|
||||
grMode(grPage1)
|
||||
grDrawBuf(grPage1)
|
||||
grView
|
||||
while not quit
|
||||
when toupper(grGetKey)
|
||||
is $0B // Up arrow
|
||||
if yCursor > 0; yCursor--; fin
|
||||
break
|
||||
is $0A // Down arrow
|
||||
if yCursor < 47; yCursor++; fin
|
||||
break
|
||||
is $08 // Left arrow
|
||||
if xCursor > 0; xCursor--; fin
|
||||
break
|
||||
is $15 // Right arrow
|
||||
if xCursor < 39; xCursor++; fin
|
||||
break
|
||||
is ' '
|
||||
modified = 1
|
||||
grSprite[yCursor*40 + xCursor] = clrCursor
|
||||
grColor(clrCursor)
|
||||
grPlot(xCursor, yCursor)
|
||||
//grView
|
||||
break
|
||||
is '+'
|
||||
is '='
|
||||
clrCursor = (clrCursor + 1) & $0F
|
||||
break
|
||||
is '-'
|
||||
clrCursor = (clrCursor - 1) & $0F
|
||||
break
|
||||
is 'T'
|
||||
dcgrTestView(0)
|
||||
break
|
||||
is 'B'
|
||||
dcgrTestView(1)
|
||||
break
|
||||
is 'V'
|
||||
modified = 1
|
||||
flipV
|
||||
grView
|
||||
break
|
||||
is 'H'
|
||||
modified = 1
|
||||
flipH
|
||||
grView
|
||||
break
|
||||
is $1B // Escape
|
||||
grMode(grOff)
|
||||
quit = getCmd
|
||||
if not quit
|
||||
grMode(grPage1)
|
||||
grDrawBuf(grPage1)
|
||||
grView
|
||||
fin
|
||||
break
|
||||
wend
|
||||
loop
|
||||
grMode(grOff)
|
||||
done
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user