]> 4ch.mooo.com Git - plz.git/blob - PLZPART/asmyt.c
wwww
[plz.git] / PLZPART / asmyt.c
1 /*
2  * Written by Nick Kovac with minor changes by Claudio Matsuoka
3  */
4
5 #include "common.h"
6
7 static uint16_t selfmod[5][84];
8 extern char *psini;
9
10 #define PSINI_OFFSET    0
11 #define LSINI4_OFFSET   16384
12 #define LSINI16_OFFSET  (16384 + 2 * 8192)
13
14
15 int plzline(int y, int vseg)
16 {
17         // vseg represented a segment, so multiply by sixteen (shift left by 4)
18         // to convert into an offset.
19         int nVgaYOffset = vseg << 4;
20
21         int cccTable[] = {
22                 3, 2, 1, 0, 7, 6, 5, 4, 11, 10, 9, 8, 15, 14, 13, 12, 19, 18,
23                 17, 16, 23, 22, 21, 20, 27, 26, 25, 24, 31, 30, 29, 28, 35,
24                 34, 33, 32, 39, 38, 37, 36, 43, 42, 41, 40, 47, 46, 45, 44,
25                 51, 50, 49, 48, 55, 54, 53, 52, 59, 58, 57, 56, 63, 62, 61,
26                 60, 67, 66, 65, 64, 71, 70, 69, 68, 75, 74, 73, 72, 79, 78,
27                 77, 76, 83, 82, 81, 80
28         };
29         uint8_t ah = 0;
30         uint8_t al = 0;
31         uint32_t eax = 0;
32         int i;
33
34         for (i = 0; i < 84; i++) {
35                 int ccc = cccTable[i];
36                 uint16_t offs;
37                 int bx;
38
39                 if ((ccc & 1) == 1) {
40                         // within lsini16
41                         offs = (y * 2) + selfmod[2][ccc];
42                         bx = *(short *)&psini[offs];
43
44                         // within psini
45                         offs = bx + selfmod[1][ccc];
46                         ah = psini[offs];
47
48                         // within lsini4
49                         offs = (y * 2) + selfmod[4][ccc];
50                         bx = *(short *)&psini[offs];
51
52                         // within psini
53                         offs = bx + (y * 2) + selfmod[3][ccc];
54                         ah += psini[offs];
55                 } else {
56                         offs = (y * 2) + selfmod[2][ccc];
57                         bx = *(short *)&psini[offs];
58
59                         offs = bx + selfmod[1][ccc];
60                         al = psini[offs];
61
62                         offs = (y * 2) + selfmod[4][ccc];
63                         bx = *(short *)&psini[offs];
64
65                         offs = bx + (y * 2) + selfmod[3][ccc];
66                         al += psini[offs];
67                 }
68
69                 if ((ccc & 3) == 2) {
70                         eax = (ah << 8) | al;
71                         eax <<= 16;
72                 }
73
74                 if ((ccc & 3) == 0) {
75                         eax |= (ah << 8) | al;
76                         vga_write32(nVgaYOffset + ccc, eax);
77                 }
78         }
79
80         return 0;
81 }
82
83 int setplzparas(int c1, int c2, int c3, int c4)
84 {
85         int ccc;
86
87         for (ccc = 0; ccc < 84; ccc++) {
88                 uint16_t lc1, lc2, lc3, lc4;
89
90                 lc1 = c1 + PSINI_OFFSET + (ccc * 8);
91                 selfmod[1][ccc] = lc1;
92
93                 lc2 = (c2 * 2) + LSINI16_OFFSET - (ccc * 8) + (80 * 8);
94                 selfmod[2][ccc] = lc2;
95
96                 lc3 = c3 + PSINI_OFFSET - (ccc * 4) + (80 * 4);
97                 selfmod[3][ccc] = lc3;
98
99                 lc4 = (c4 * 2) + LSINI4_OFFSET + (ccc * 32);
100                 selfmod[4][ccc] = lc4;
101         }
102
103         return 0;
104 }
105
106 int set_plzstart(int y)
107 {
108         vga_set_line_compare(y);
109
110         return 0;
111 }