mirror of
https://github.com/dschmenk/PLASMA.git
synced 2026-03-13 08:41:53 +00:00
Compare commits
673 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
470f679b5f | ||
|
|
2ca4ac6691 | ||
|
|
852a5733d8 | ||
|
|
a62e2d9b2d | ||
|
|
9c07d155ad | ||
|
|
7a6af7f897 | ||
|
|
b69be5e492 | ||
|
|
6d36cf7e45 | ||
|
|
137a22abf3 | ||
|
|
dd4eb8010c | ||
|
|
074b61cf18 | ||
|
|
5ab524983b | ||
|
|
898df9b7be | ||
|
|
8e20f4b5b9 | ||
|
|
f36c954edb | ||
|
|
bc6df05324 | ||
|
|
cb59cb28a9 | ||
|
|
76955b8a37 | ||
|
|
d43cce3390 | ||
|
|
5999009ac3 | ||
|
|
d24b22f327 | ||
|
|
81a824176c | ||
|
|
2ef28818e0 | ||
|
|
1ac6ad3d4e | ||
|
|
3eca528cb8 | ||
|
|
8f69630955 | ||
|
|
b5fdebfe7d | ||
|
|
557a5bb0b9 | ||
|
|
04786851e7 | ||
|
|
2abd31bbbd | ||
|
|
a1e58c0634 | ||
|
|
7b98e310e8 | ||
|
|
b63b8c5cd0 | ||
|
|
3ae9404419 | ||
|
|
a59b9b02e4 | ||
|
|
1c8e2c28d7 | ||
|
|
736c29687a | ||
|
|
364a8f0925 | ||
|
|
7106d8f826 | ||
|
|
d0079088d3 | ||
|
|
3d359f0a0e | ||
|
|
6839f068ab | ||
|
|
2db2129806 | ||
|
|
a4fa5a162a | ||
|
|
680a1c032b | ||
|
|
9555036473 | ||
|
|
3103d44635 | ||
|
|
e2ef600dd2 | ||
|
|
e22ad3e3c1 | ||
|
|
3a03bbd5f8 | ||
|
|
51a33d5750 | ||
|
|
a9befc3b37 | ||
|
|
e968a5911f | ||
|
|
2522d1faab | ||
|
|
2239b6de9e | ||
|
|
0424867ead | ||
|
|
0d4b0f9607 | ||
|
|
6bc88b8f7d | ||
|
|
ff175b5d1e | ||
|
|
dd545c7aa5 | ||
|
|
102b1ef652 | ||
|
|
c143596032 | ||
|
|
e3550d4a83 | ||
|
|
d6a51f4656 | ||
|
|
5830f8b34e | ||
|
|
eafd2df444 | ||
|
|
fffb06b8b3 | ||
|
|
34bc475d16 | ||
|
|
b9c84db58e | ||
|
|
2d419672e0 | ||
|
|
ca6bad1068 | ||
|
|
b3f980b330 | ||
|
|
8da58ce734 | ||
|
|
9c76ea92c3 | ||
|
|
d35774eac4 | ||
|
|
f987458a15 | ||
|
|
1286daff45 | ||
|
|
9891eec8cd | ||
|
|
2955e07d93 | ||
|
|
786bb692f6 | ||
|
|
c4b98f1866 | ||
|
|
6b4017abb1 | ||
|
|
1413ddd30a | ||
|
|
73bf667236 | ||
|
|
1dd707dcee | ||
|
|
43c5ed5839 | ||
|
|
ca87c5b678 | ||
|
|
af2e3143f6 | ||
|
|
15488e61c7 | ||
|
|
4172c2c5e4 | ||
|
|
77b94b0339 | ||
|
|
35dd0f0eb5 | ||
|
|
d4d8fab650 | ||
|
|
4bc43ab965 | ||
|
|
8f0e8089e2 | ||
|
|
2a1f9abb25 | ||
|
|
a24ff6cc10 | ||
|
|
1647a06a21 | ||
|
|
997ab30f44 | ||
|
|
3271c85306 | ||
|
|
7db41d7c38 | ||
|
|
76f5915a98 | ||
|
|
98f45b33dc | ||
|
|
9c706b0bbd | ||
|
|
53f159748f | ||
|
|
3cf329a41e | ||
|
|
a9a346b3b6 | ||
|
|
a2e892e806 | ||
|
|
f1bff1e05d | ||
|
|
3d9ac64b21 | ||
|
|
7d090a92f6 | ||
|
|
98c721fecf | ||
|
|
d19f95f879 | ||
|
|
8e3a1bcdfe | ||
|
|
dd0987643f | ||
|
|
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 |
19
.gitignore
vendored
Normal file
19
.gitignore
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
# Compiled object files
|
||||
*.o
|
||||
|
||||
# Archive/library files
|
||||
*.a
|
||||
|
||||
# Symbol files
|
||||
*.sym
|
||||
|
||||
# Executables
|
||||
plvm
|
||||
xplasm
|
||||
run6502
|
||||
|
||||
# Build output directories
|
||||
src/rel/
|
||||
|
||||
# macOS
|
||||
.DS_Store
|
||||
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 #
|
||||
|
||||
163
doc/MEGAFLASH_FPU.md
Normal file
163
doc/MEGAFLASH_FPU.md
Normal file
@@ -0,0 +1,163 @@
|
||||
# MegaFlash Hardware FPU Support for PLASMA
|
||||
|
||||
## Overview
|
||||
|
||||
This pull request adds hardware-accelerated floating-point support for PLASMA programs running on Apple IIc/IIc+ systems equipped with the MegaFlash storage device.
|
||||
|
||||
## What is MegaFlash?
|
||||
|
||||
MegaFlash is an internal storage device for Apple IIc/IIc+ computers featuring:
|
||||
- 128/256MB flash storage
|
||||
- Raspberry Pi Pico W microcontroller
|
||||
- Hardware-accelerated floating-point unit (FPU)
|
||||
- Real-time clock, WiFi, and other features
|
||||
|
||||
The FPU acceleration uses the Pico's ARM Cortex-M0+ processor to perform IEEE 754 double-precision calculations, providing significant speedup over the 6502's software floating-point routines.
|
||||
|
||||
## Changes in This PR
|
||||
|
||||
### New Files
|
||||
|
||||
1. **`src/inc/megaflash.plh`**: Header file defining MegaFlash constants and I/O registers
|
||||
2. **`src/libsrc/fpu_mf.pla`**: Drop-in replacement FPU library with hardware acceleration
|
||||
3. **`src/libsrc/README_fpu_mf.md`**: Documentation for the MegaFlash FPU library
|
||||
4. **`src/samplesrc/fptest_mf.pla`**: Test program demonstrating the library
|
||||
|
||||
### API Compatibility
|
||||
|
||||
The `fpu_mf.pla` library maintains **100% API compatibility** with the existing `fpu.pla` library. Users can switch between implementations by simply changing:
|
||||
|
||||
```plasma
|
||||
import fpu // Old: SANE software FPU
|
||||
```
|
||||
|
||||
to:
|
||||
|
||||
```plasma
|
||||
import fpu_mf // New: MegaFlash hardware FPU
|
||||
```
|
||||
|
||||
All function calls remain identical.
|
||||
|
||||
## Technical Implementation
|
||||
|
||||
### Format Conversion
|
||||
|
||||
The library handles automatic conversion between:
|
||||
- **SANE Extended Format** (80-bit): Used by PLASMA for maximum precision
|
||||
- **MBF Format** (40-bit Microsoft Binary Format): Used by MegaFlash for hardware calculations
|
||||
|
||||
### Hardware Detection
|
||||
|
||||
On initialization (`reset`), the library:
|
||||
1. Attempts to detect MegaFlash hardware via ID register
|
||||
2. If found: Enables hardware acceleration for supported operations
|
||||
3. If not found: Falls back transparently to SANE software implementation
|
||||
|
||||
This ensures programs work on any Apple II system, whether or not MegaFlash is present.
|
||||
|
||||
### Accelerated Operations
|
||||
|
||||
The library provides **31 hardware-accelerated functions** out of 40 total SANE operations (78% coverage):
|
||||
|
||||
- **Direct Hardware FPU** (9 functions): `mul`, `div`, `sqrt`, `sin`, `cos`, `tan`, `atan`, `lnX`, `powEX`
|
||||
- **Via Mathematical Identities** (22 functions): `neg`, `abs`, `log2X`, `log21X`, `ln1X`, `pow2X`, `pow21X`, `powE1X`, `powE21X`, `powXInt`, `powXY`, `asin`, `acos`, `sinh`, `cosh`, `tanh`, `sec`, `csc`, `cot`, `scalb`, `compXY`, `annuityXY`
|
||||
|
||||
The remaining 9 operations (add, sub, rem, type, cmp, trunc, round, logb, randNum) use SANE fallback.
|
||||
|
||||
### Performance
|
||||
|
||||
Expected speedups with hardware acceleration:
|
||||
- Transcendental functions (sin, cos, tan, log, exp): **10-100x faster**
|
||||
- Multiplication/Division: **3-5x faster**
|
||||
- Operations using SANE fallback: Same performance as `fpu.pla`
|
||||
|
||||
## Usage Example
|
||||
|
||||
```plasma
|
||||
include "inc/cmdsys.plh"
|
||||
import fpu_mf
|
||||
import console
|
||||
|
||||
byte[80] result
|
||||
|
||||
// Initialize FPU
|
||||
fpu_mf:reset
|
||||
|
||||
// Calculate sin(PI/2)
|
||||
fpu_mf:constPi
|
||||
fpu_mf:pushStr("2.0")
|
||||
fpu_mf:div
|
||||
fpu_mf:sin
|
||||
|
||||
// Print result
|
||||
fpu_mf:pullStr(@result, 1, 6, FPSTR_FIXED)
|
||||
puts(@result) // Prints: 1.000000
|
||||
```
|
||||
|
||||
## Testing
|
||||
|
||||
A comprehensive test program is provided in `src/samplesrc/fptest_mf.pla` that exercises:
|
||||
- Basic arithmetic (mul, div, sqrt, squared)
|
||||
- Trigonometric functions (sin, cos, tan, atan)
|
||||
- Logarithmic/exponential (ln, exp)
|
||||
- Constants (PI, E)
|
||||
- Performance benchmark
|
||||
|
||||
## Backwards Compatibility
|
||||
|
||||
This PR:
|
||||
- **Adds** new optional functionality
|
||||
- **Does not modify** any existing PLASMA code
|
||||
- **Does not break** any existing programs
|
||||
- **Requires** no changes to existing programs unless users opt-in
|
||||
|
||||
## Hardware Requirements
|
||||
|
||||
To use hardware acceleration:
|
||||
- Apple IIc or IIc+ computer
|
||||
- MegaFlash storage device installed
|
||||
- MegaFlash firmware v1.0 or later with FPU support enabled
|
||||
|
||||
Programs using `fpu_mf` will run on systems without MegaFlash (using SANE fallback).
|
||||
|
||||
## Future Enhancements
|
||||
|
||||
Possible future improvements:
|
||||
- Optimize format conversion routines
|
||||
- Add direct MBF mode for programs that don't need full SANE precision
|
||||
- Support for other slots (currently hardcoded to slot 4)
|
||||
- Assembly optimization of hot paths
|
||||
|
||||
## Documentation
|
||||
|
||||
Complete documentation is provided in:
|
||||
- `src/libsrc/README_fpu_mf.md`: Library documentation
|
||||
- Inline code comments: Implementation details
|
||||
- `src/samplesrc/fptest_mf.pla`: Working examples
|
||||
|
||||
## Building
|
||||
|
||||
The library builds as part of the standard PLASMA build process:
|
||||
|
||||
```bash
|
||||
cd PLASMA/src
|
||||
make
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
This code follows the PLASMA project's existing license.
|
||||
|
||||
## Credits
|
||||
|
||||
- MegaFlash hardware/firmware: Thomas Fok
|
||||
- PLASMA language: David Schmenk
|
||||
- MegaFlash FPU integration: Brendan Robert
|
||||
|
||||
## Questions?
|
||||
|
||||
For questions about:
|
||||
- **MegaFlash hardware**: See [MegaFlash repository](https://github.com/ThomasFok/MegaFlash)
|
||||
- **PLASMA integration**: Open an issue in this repository
|
||||
- **Usage examples**: See `fptest_mf.pla` test program
|
||||
1330
doc/PLASMA.md
Executable file
1330
doc/PLASMA.md
Executable file
File diff suppressed because it is too large
Load Diff
@@ -13,7 +13,20 @@ There are quite a few missing word that a standard FORTH would have. Mostly due
|
||||
|
||||
## 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 OK
|
||||
|
||||
## PLFORTH specific words
|
||||
|
||||
@@ -73,15 +86,27 @@ While running code, `<CTRL-C>` will break out and return to the interpreter.
|
||||
|
||||
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.
|
||||
PLFORTH defaults to compiling using PLASMA byte code (PBC) to greatly improve performance, but most of the debugging tools are lost. However, the compiler can easily switch to ITC (Indirect Threaded Code). ITC can be set as the initial mode by passing a `-D` flag on the command line. This supports a list of inspection and debugging features while developing programs and scripts. 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.
|
||||
@@ -110,7 +135,7 @@ There are a few useful scripts located in the `scripts` directory. By far the mo
|
||||
|
||||
## Command line options
|
||||
|
||||
`-F`: Fast flag (like `PCB` as first command)
|
||||
`-D`: Debug flag (like `ITC` as first command)
|
||||
|
||||
`-T`: Trace flag (like `TRON` as first command)
|
||||
|
||||
@@ -120,4 +145,4 @@ There are a few useful scripts located in the `scripts` directory. By far the mo
|
||||
|
||||
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
|
||||
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
|
||||
|
||||
Binary file not shown.
@@ -2,29 +2,37 @@
|
||||
|
||||
Welcome to PLASMA: the Grand Unifying Platform for the Apple 1, ][, and ///.
|
||||
|
||||
Download the disk images:
|
||||
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.
|
||||
|
||||
[PLASMA 2.11 800K Full System](https://github.com/dschmenk/PLASMA/blob/master/images/apple/PLASMA-2.1.2mg?raw=true)
|
||||
If you already have 2.1 installed, here are the updated files:
|
||||
|
||||
[PLASMA 2.11 ProDOS Boot & Install](https://github.com/dschmenk/PLASMA/blob/master/images/apple/PLASMA-2.1-INST.po?raw=true)
|
||||
[PLASMA 2.11 Update](https://github.com/dschmenk/PLASMA/raw/master/images/apple/PLASMA-2.11-UPD.po)
|
||||
|
||||
[PLASMA 2.1 System Libraries](https://github.com/dschmenk/PLASMA/blob/master/images/apple/PLASMA-2.1-SYS.po?raw=true)
|
||||
Download the full 2.11 disk image set:
|
||||
|
||||
[PLASMA 2.11 Build Tools](https://github.com/dschmenk/PLASMA/blob/master/images/apple/PLASMA-2.1-BLD.po?raw=true)
|
||||
[PLASMA 2.11 HD Full System](https://github.com/dschmenk/PLASMA/raw/master/images/apple/PLASMA2.2mg)
|
||||
|
||||
[PLASMA 2.1 Demos](https://github.com/dschmenk/PLASMA/blob/master/images/apple/PLASMA-2.1-DEMOS.po?raw=true)
|
||||
[PLASMA 2.11 800K Full System](https://github.com/dschmenk/PLASMA/raw/master/images/apple/PLASMA-2.1.po)
|
||||
|
||||
[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.11 ProDOS Boot & Install](https://github.com/dschmenk/PLASMA/raw/master/images/apple/PLASMA-2.1-INST.po)
|
||||
|
||||
[PLASMA 2.11 Apple /// SOS and SANE floating point modules](https://github.com/dschmenk/PLASMA/blob/master/images/apple/PLASMA-2.1-FPSOS.po?raw=true)
|
||||
[PLASMA 2.1 System Libraries](https://github.com/dschmenk/PLASMA/raw/master/images/apple/PLASMA-2.1-SYS.po)
|
||||
|
||||
[PLASMA 2.11 Apple /// SOS Mame Boot](https://github.com/dschmenk/PLASMA/blob/master/images/apple/PLASMA2-A3MAME.PO?raw=true)
|
||||
[PLASMA 2.11 Build Tools](https://github.com/dschmenk/PLASMA/raw/master/images/apple/PLASMA-2.1-BLD.po)
|
||||
|
||||
[PLASMA 2.11 Apple /// Mame hard disk image](https://github.com/dschmenk/PLASMA/blob/master/images/apple/apple3.hd?raw=true)
|
||||
[PLASMA 2.1 Demos](https://github.com/dschmenk/PLASMA/raw/master/images/apple/PLASMA-2.1-DEMOS.po)
|
||||
|
||||
[PLASMA 2.11 PLFORTH stand-alone boot](https://github.com/dschmenk/PLASMA/blob/master/images/apple/PLFORTH.PO?raw=true)
|
||||
[PLASMA 2.1 TCP/IP network modules](https://github.com/dschmenk/PLASMA/raw/master/images/apple/PLASMA-2.1-INET.po)
|
||||
|
||||
[PLASMA 2.11 Assembly Language Toolkit](https://github.com/dschmenk/PLASMA/blob/master/images/apple/ASM-TK.po?raw=true)
|
||||
[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:
|
||||
|
||||
@@ -104,6 +112,14 @@ The build disk includes sample source, include files for the system modules, and
|
||||
```
|
||||
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
|
||||
|
||||
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 |
Binary file not shown.
Binary file not shown.
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.
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/MAZERUNR.po
Normal file
BIN
images/apple/MAZERUNR.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.21.po
Normal file
BIN
images/apple/PLEIADES-2.21.po
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
images/apple/UPDATE-2.21.po
Executable file
BIN
images/apple/UPDATE-2.21.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/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"
|
||||
musicPlay(musicRead("imperial.seq"), FALSE)
|
||||
dcgrFont(fontRead("trade54.fon")) // This font exceeds the available memory so gets truncated
|
||||
strWidth, strHeight = dcgrStrExtents(@darthstr)
|
||||
dhgrMode(DHGR_COLOR_MODE)
|
||||
screenRead("darth.dhgr")
|
||||
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.
184
src/dhgr.tk/demos/startrek/fillshape.pla
Normal file
184
src/dhgr.tk/demos/startrek/fillshape.pla
Normal file
@@ -0,0 +1,184 @@
|
||||
include "inc/cmdsys.plh"
|
||||
include "inc/lines.plh"
|
||||
include "inc/vblank.plh"
|
||||
include "inc/sincos.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
|
||||
//
|
||||
// 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 = (mulcos(128, angle) * width) >> 8
|
||||
y = (mulsin(128, angle) * 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 = (mulcos(128, angle) * width) >> 8
|
||||
y = (mulsin(128, angle) * 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
|
||||
|
||||
343
src/dhgr.tk/demos/startrek/startrek.pla
Normal file
343
src/dhgr.tk/demos/startrek/startrek.pla
Normal file
@@ -0,0 +1,343 @@
|
||||
include "inc/cmdsys.plh"
|
||||
include "inc/conio.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
|
||||
//
|
||||
// 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 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 - (conio:rnd() & 31), 15 - (conio:rnd() & 31), conio:rnd() & 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 conio: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 conio: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
|
||||
2716
src/dhgr.tk/libs/dhgrlib.pla
Normal file
2716
src/dhgr.tk/libs/dhgrlib.pla
Normal file
File diff suppressed because it is too large
Load Diff
436
src/dhgr.tk/libs/dhgrutils.pla
Normal file
436
src/dhgr.tk/libs/dhgrutils.pla
Normal file
@@ -0,0 +1,436 @@
|
||||
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
|
||||
memset(gly_ptr, num * 2, NULL)
|
||||
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
|
||||
font_header->fnt_last = i + font_header->fnt_first - 1 // Truncate font glyphs
|
||||
//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 = 0; /* 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.
553
src/dhgr.tk/utils/dhgrrgb.pla
Normal file
553
src/dhgr.tk/utils/dhgrrgb.pla
Normal file
@@ -0,0 +1,553 @@
|
||||
include "inc/cmdsys.plh"
|
||||
include "inc/args.plh"
|
||||
include "inc/fileio.plh"
|
||||
include "inc/int32.plh"
|
||||
include "inc/sincos.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
|
||||
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 = 0
|
||||
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 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 = saturation + mulcos(255, angle - phase[RED])
|
||||
g = saturation + mulcos(255, angle - phase[GRN])
|
||||
b = saturation + mulcos(255, angle - phase[BLU])
|
||||
ntscChroma[i*3 + RED] = min(255, max(0, (r + 2) / 4))
|
||||
ntscChroma[i*3 + GRN] = min(255, max(0, (g + 2) / 4))
|
||||
ntscChroma[i*3 + BLU] = min(255, max(0, (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.2\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] [-P#] <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
|
||||
165
src/dhgr.tk/utils/dlgrconv.pla
Normal file
165
src/dhgr.tk/utils/dlgrconv.pla
Normal file
@@ -0,0 +1,165 @@
|
||||
include "inc/cmdsys.plh"
|
||||
include "inc/args.plh"
|
||||
include "inc/fileio.plh"
|
||||
include "inc/matchfiles.plh"
|
||||
include "dhgr.tk/inc/dhgrlib.plh"
|
||||
include "dhgr.tk/inc/dhgrutils.plh"
|
||||
|
||||
sysflags restxt1|resxtxt1|reshgr1|resxhgr1 // Reserve all the pages
|
||||
|
||||
const FRAME_WIDTH = 80
|
||||
const FRAME_HEIGHT = 48
|
||||
const FRAME_SIZE = FRAME_WIDTH * FRAME_HEIGHT / 2
|
||||
const DLGRFRAME_SIZE = 2047
|
||||
const PAUSE = 1
|
||||
const HEIGHT_X2 = 2
|
||||
const WRITE_DHGR = 4
|
||||
|
||||
var arg, srcfilelist, srcpath, srcexp, srccnt
|
||||
var entrylist, entrycnt
|
||||
byte[FRAME_SIZE*2] frame
|
||||
byte flags
|
||||
|
||||
//
|
||||
// Screen row address arrays.
|
||||
//
|
||||
word rowofst = $0000,$0080,$0100,$0180,$0200,$0280,$0300,$0380
|
||||
word = $0028,$00A8,$0128,$01A8,$0228,$02A8,$0328,$03A8
|
||||
word = $0050,$00D0,$0150,$01D0,$0250,$02D0,$0350,$03D0
|
||||
byte rotclr = $00,$22,$44,$66,$888,$AA,$CC,$EE
|
||||
byte = $11,$33,$55,$77,$99,$BB,$DD,$FF
|
||||
|
||||
def dlgr2dcgr(dlgrptr)#0
|
||||
byte i, j, cl, ch
|
||||
var pixptr, rowptr
|
||||
|
||||
pixptr = @frame
|
||||
for j = 0 to 47 step 2
|
||||
rowptr = dlgrptr + rowofst[j / 2]
|
||||
for i = 0 to 39
|
||||
cl = ^(rowptr + i + 1024)
|
||||
cl = (rotclr[cl & $0F] & $0F) | (rotclr[cl >> 4] & $F0)
|
||||
ch = ^(rowptr + i)
|
||||
^(pixptr + i) = (cl & $0F) | (ch << 4)
|
||||
if flags & HEIGHT_X2
|
||||
^(pixptr + i + 40) = (cl & $0F) | (ch << 4)
|
||||
^(pixptr + i + 80) = (cl >> 4) | (ch & $F0)
|
||||
^(pixptr + i + 120) = (cl >> 4) | (ch & $F0)
|
||||
else
|
||||
^(pixptr + i + 40) = (cl >> 4) | (ch & $F0)
|
||||
fin
|
||||
next
|
||||
if flags & HEIGHT_X2
|
||||
pixptr = pixptr + 160
|
||||
else
|
||||
pixptr = pixptr + 80
|
||||
fin
|
||||
next
|
||||
end
|
||||
|
||||
def dlgrRead(filestr)#1
|
||||
var frameptr
|
||||
byte refnum
|
||||
|
||||
frameptr = 0
|
||||
refnum = fileio:open(filestr)
|
||||
if refnum
|
||||
frameptr = heapalloc(DLGRFRAME_SIZE)
|
||||
if frameptr and fileio:read(refnum, frameptr, DLGRFRAME_SIZE) <> DLGRFRAME_SIZE
|
||||
heaprelease(frameptr)
|
||||
frameptr = NULL
|
||||
dhgrMode(DHGR_TEXT_MODE)
|
||||
puts("Error reading: "); puts(filestr); putln
|
||||
fin
|
||||
fileio:close(refnum)
|
||||
fin
|
||||
return frameptr
|
||||
end
|
||||
|
||||
def dhgrWrite(filename)#1
|
||||
char[64] screenfile
|
||||
|
||||
strcpy(@screenfile, filename)
|
||||
strcat(@screenfile, ".DHGR")
|
||||
if screenWrite(@screenfile)
|
||||
dhgrMode(DHGR_TEXT_MODE)
|
||||
puts("Error writing: "); puts(@screenfile); putln
|
||||
return FALSE
|
||||
fin
|
||||
return TRUE
|
||||
end
|
||||
|
||||
def dlgrConvert(filename)#1
|
||||
var dlgrptr
|
||||
byte i, j, numrows
|
||||
|
||||
dcgrColor(CLR_GREY1)
|
||||
dhgrClearBl7(0, 0, SCR_WIDTH7, SCR_HEIGHT)
|
||||
dlgrptr = dlgrRead(filename)
|
||||
if dlgrptr
|
||||
dlgr2dcgr(dlgrptr)
|
||||
heaprelease(dlgrptr)
|
||||
if flags & HEIGHT_X2
|
||||
dcgrPixMap(30, 48, FRAME_WIDTH, FRAME_HEIGHT*2, @frame)
|
||||
else
|
||||
dcgrPixMap(30, 72, FRAME_WIDTH, FRAME_HEIGHT, @frame)
|
||||
fin
|
||||
if flags & WRITE_DHGR
|
||||
return dhgrWrite(filename)
|
||||
fin
|
||||
return TRUE
|
||||
fin
|
||||
return FALSE
|
||||
end
|
||||
|
||||
arg = argNext(argFirst)
|
||||
while arg and ^(arg + 1) == '-'
|
||||
when toupper(^(arg + 2))
|
||||
is 'P'
|
||||
flags = flags | PAUSE
|
||||
break
|
||||
is '2'
|
||||
flags = flags | HEIGHT_X2
|
||||
break
|
||||
is 'W'
|
||||
flags = flags | WRITE_DHGR
|
||||
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)
|
||||
while srccnt and dlgrConvert(srcfilelist)
|
||||
if flags & PAUSE; getc; fin
|
||||
srcfilelist = srcfilelist + t_fileentry
|
||||
srccnt--
|
||||
loop
|
||||
dhgrMode(DHGR_TEXT_MODE)
|
||||
return 0
|
||||
fin
|
||||
puts("Usage: DHGRGREASY [-P] [-2] [W] FRAMEFILE\n")
|
||||
done
|
||||
BIN
src/dhgr.tk/utils/fonts/A2SLIM8.FON.BIN
Normal file
BIN
src/dhgr.tk/utils/fonts/A2SLIM8.FON.BIN
Normal file
Binary file not shown.
BIN
src/dhgr.tk/utils/fonts/ANTRIPA.24#c80000
Normal file
BIN
src/dhgr.tk/utils/fonts/ANTRIPA.24#c80000
Normal file
Binary file not shown.
BIN
src/dhgr.tk/utils/fonts/ANTRIPA.48#c80000
Normal file
BIN
src/dhgr.tk/utils/fonts/ANTRIPA.48#c80000
Normal file
Binary file not shown.
BIN
src/dhgr.tk/utils/fonts/APPLE.II.18#c80000
Normal file
BIN
src/dhgr.tk/utils/fonts/APPLE.II.18#c80000
Normal file
Binary file not shown.
BIN
src/dhgr.tk/utils/fonts/APPLE.II.36#c80000
Normal file
BIN
src/dhgr.tk/utils/fonts/APPLE.II.36#c80000
Normal file
Binary file not shown.
BIN
src/dhgr.tk/utils/fonts/APPLE.II.9#c80000
Normal file
BIN
src/dhgr.tk/utils/fonts/APPLE.II.9#c80000
Normal file
Binary file not shown.
BIN
src/dhgr.tk/utils/fonts/APPLE2.FON.BIN
Normal file
BIN
src/dhgr.tk/utils/fonts/APPLE2.FON.BIN
Normal file
Binary file not shown.
BIN
src/dhgr.tk/utils/fonts/APPLE2THIN.FON.BIN
Normal file
BIN
src/dhgr.tk/utils/fonts/APPLE2THIN.FON.BIN
Normal file
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user