]> 4ch.mooo.com Git - plz.git/blob - asmyt.c
dots for a simple port but damn it!
[plz.git] / 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         uint16_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 <<= 8;
72                 }
73
74                 if ((ccc & 3) == 0) {
75                         eax |= (ah << 8) | al;
76 //                      vga_write32(nVgaYOffset + ccc, eax);
77                         __asm {
78                                 mov     [es:ccc], ax
79                         }
80                 }
81         }
82
83         return 0;
84 }
85
86 int setplzparas(int c1, int c2, int c3, int c4)
87 {
88         int ccc;
89
90         for (ccc = 0; ccc < 84; ccc++) {
91                 uint16_t lc1, lc2, lc3, lc4;
92
93                 lc1 = c1 + PSINI_OFFSET + (ccc * 8);
94                 selfmod[1][ccc] = lc1;
95
96                 lc2 = (c2 * 2) + LSINI16_OFFSET - (ccc * 8) + (80 * 8);
97                 selfmod[2][ccc] = lc2;
98
99                 lc3 = c3 + PSINI_OFFSET - (ccc * 4) + (80 * 4);
100                 selfmod[3][ccc] = lc3;
101
102                 lc4 = (c4 * 2) + LSINI4_OFFSET + (ccc * 32);
103                 selfmod[4][ccc] = lc4;
104         }
105
106         return 0;
107 }
108
109 word set_plzstart(word start)
110 {
111 __asm{
112         mov     dx, 3d4h
113         mov     al, 18h         ; linecompare
114         mov     ah, [Byte PTR start]
115         out     dx, ax
116         mov     al, 07h
117         mov     ah, [Byte PTR start+1]
118         shl     ah, 1d
119         shl     ah, 1d
120         shl     ah, 1d
121         shl     ah, 1d
122         and     ah, 10h
123         or      ah, 0fh
124         out     dx, ax                  ; 8th bit
125 }
126         return start;
127 }