Subversion Repositories eduke32

Rev

Rev 4758 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4758 Rev 5037
1
// Assembly-language function wrappers for a.asm functions
1
// Assembly-language function wrappers for a.asm functions
2
// for the Build Engine
2
// for the Build Engine
3
// by Jonathon Fowler (jf@jonof.id.au)
3
// by Jonathon Fowler (jf@jonof.id.au)
4
4
5
5
6
#ifndef a_h_
6
#ifndef a_h_
7
#define a_h_
7
#define a_h_
8
8
9
#include "compat.h"
9
#include "compat.h"
10
10
11
#define CLASSIC_SLICE_BY_4
11
#define CLASSIC_SLICE_BY_4
12
#define A_C_RESTRICT __restrict
12
#define A_C_RESTRICT __restrict
13
13
14
#define CLASSIC_NONPOW2_YSIZE_SPRITES
14
#define CLASSIC_NONPOW2_YSIZE_SPRITES
15
#ifdef LUNATIC
15
#ifdef LUNATIC
16
# define CLASSIC_NONPOW2_YSIZE_WALLS
16
# define CLASSIC_NONPOW2_YSIZE_WALLS
17
#endif
17
#endif
18
18
19
/** Definitions of high-precision integer types. **/
19
/** Definitions of high-precision integer types. **/
20
// Should be used for values that represent coordinates with which calculations
20
// Should be used for values that represent coordinates with which calculations
21
// like dot product are carried out. Substituting 32-bit ints for these will
21
// like dot product are carried out. Substituting 32-bit ints for these will
22
// very likely yield issues in border cases:
22
// very likely yield issues in border cases:
23
typedef int64_t coord_t;
23
typedef int64_t coord_t;
24
// Should be used for values that may overflow if 32-bit arithmetic were used,
24
// Should be used for values that may overflow if 32-bit arithmetic were used,
25
// but where no other adverse effect (except being undefined behavior,
25
// but where no other adverse effect (except being undefined behavior,
26
// obviously) is expected to result:
26
// obviously) is expected to result:
27
typedef int64_t inthi_t;
27
typedef int64_t inthi_t;
28
28
29
#if !defined(NOASM) && (defined(_MSC_VER) || (defined(__GNUC__) && defined(__i386__)))
29
#if !defined(NOASM) && (defined(_MSC_VER) || (defined(__GNUC__) && defined(__i386__)))
30
30
31
#if defined(__linux) || defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__SYLLABLE__)
31
#if defined __linux || defined __APPLE__ || defined EDUKE32_BSD || defined __SYLLABLE__
32
#define __cdecl
32
#define __cdecl
33
#endif
33
#endif
34
34
35
#ifdef __cplusplus
35
#ifdef __cplusplus
36
extern "C"
36
extern "C"
37
{
37
{
38
#endif
38
#endif
39
39
40
extern int32_t __cdecl mmxoverlay();
40
extern int32_t __cdecl mmxoverlay();
41
extern int32_t __cdecl sethlinesizes(int32_t,int32_t,int32_t);
41
extern int32_t __cdecl sethlinesizes(int32_t,int32_t,int32_t);
42
extern int32_t __cdecl setpalookupaddress(char *);
42
extern int32_t __cdecl setpalookupaddress(char *);
43
extern int32_t __cdecl setuphlineasm4(int32_t,int32_t);
43
extern int32_t __cdecl setuphlineasm4(int32_t,int32_t);
44
extern int32_t __cdecl hlineasm4(int32_t,int32_t,int32_t,int32_t,int32_t,int32_t);
44
extern int32_t __cdecl hlineasm4(int32_t,int32_t,int32_t,int32_t,int32_t,int32_t);
45
extern int32_t __cdecl setuprhlineasm4(int32_t,int32_t,int32_t,int32_t,int32_t,int32_t);
45
extern int32_t __cdecl setuprhlineasm4(int32_t,int32_t,int32_t,int32_t,int32_t,int32_t);
46
extern int32_t __cdecl rhlineasm4(int32_t,int32_t,int32_t,int32_t,int32_t,int32_t);
46
extern int32_t __cdecl rhlineasm4(int32_t,int32_t,int32_t,int32_t,int32_t,int32_t);
47
extern int32_t __cdecl setuprmhlineasm4(int32_t,int32_t,int32_t,int32_t,int32_t,int32_t);
47
extern int32_t __cdecl setuprmhlineasm4(int32_t,int32_t,int32_t,int32_t,int32_t,int32_t);
48
extern int32_t __cdecl rmhlineasm4(int32_t,int32_t,int32_t,int32_t,int32_t,int32_t);
48
extern int32_t __cdecl rmhlineasm4(int32_t,int32_t,int32_t,int32_t,int32_t,int32_t);
49
extern int32_t __cdecl setupqrhlineasm4(int32_t,int32_t,int32_t,int32_t,int32_t,int32_t);
49
extern int32_t __cdecl setupqrhlineasm4(int32_t,int32_t,int32_t,int32_t,int32_t,int32_t);
50
extern int32_t __cdecl qrhlineasm4(int32_t,int32_t,int32_t,int32_t,int32_t,int32_t);
50
extern int32_t __cdecl qrhlineasm4(int32_t,int32_t,int32_t,int32_t,int32_t,int32_t);
51
extern int32_t __cdecl setvlinebpl(int32_t);
51
extern int32_t __cdecl setvlinebpl(int32_t);
52
extern int32_t __cdecl fixtransluscence(int32_t);
52
extern int32_t __cdecl fixtransluscence(int32_t);
53
extern int32_t __cdecl prevlineasm1(int32_t,int32_t,int32_t,int32_t,int32_t,int32_t);
53
extern int32_t __cdecl prevlineasm1(int32_t,int32_t,int32_t,int32_t,int32_t,int32_t);
54
extern int32_t __cdecl vlineasm1(int32_t,int32_t,int32_t,int32_t,int32_t,int32_t);
54
extern int32_t __cdecl vlineasm1(int32_t,int32_t,int32_t,int32_t,int32_t,int32_t);
55
extern int32_t __cdecl vlineasm1nonpow2(int32_t,int32_t,int32_t,int32_t,int32_t,int32_t);
55
extern int32_t __cdecl vlineasm1nonpow2(int32_t,int32_t,int32_t,int32_t,int32_t,int32_t);
56
extern int32_t __cdecl setuptvlineasm(int32_t,int32_t);
56
extern int32_t __cdecl setuptvlineasm(int32_t,int32_t);
57
extern int32_t __cdecl tvlineasm1(int32_t,int32_t,int32_t,int32_t,int32_t,int32_t);
57
extern int32_t __cdecl tvlineasm1(int32_t,int32_t,int32_t,int32_t,int32_t,int32_t);
58
extern int32_t __cdecl tvlineasm1nonpow2(int32_t,int32_t,int32_t,int32_t,int32_t,int32_t);
58
extern int32_t __cdecl tvlineasm1nonpow2(int32_t,int32_t,int32_t,int32_t,int32_t,int32_t);
59
extern int32_t __cdecl setuptvlineasm2(int32_t,int32_t,int32_t);
59
extern int32_t __cdecl setuptvlineasm2(int32_t,int32_t,int32_t);
60
extern int32_t __cdecl tvlineasm2(int32_t,int32_t,int32_t,int32_t,int32_t,int32_t);
60
extern int32_t __cdecl tvlineasm2(int32_t,int32_t,int32_t,int32_t,int32_t,int32_t);
61
extern int32_t __cdecl mvlineasm1(int32_t,int32_t,int32_t,int32_t,int32_t,int32_t);
61
extern int32_t __cdecl mvlineasm1(int32_t,int32_t,int32_t,int32_t,int32_t,int32_t);
62
extern int32_t __cdecl mvlineasm1nonpow2(int32_t,int32_t,int32_t,int32_t,int32_t,int32_t);
62
extern int32_t __cdecl mvlineasm1nonpow2(int32_t,int32_t,int32_t,int32_t,int32_t,int32_t);
63
extern int32_t __cdecl setupvlineasm(int32_t);
63
extern int32_t __cdecl setupvlineasm(int32_t);
64
extern int32_t __cdecl vlineasm4(int32_t,char *);
64
extern int32_t __cdecl vlineasm4(int32_t,char *);
65
extern int32_t __cdecl setupmvlineasm(int32_t,int32_t);
65
extern int32_t __cdecl setupmvlineasm(int32_t,int32_t);
66
extern int32_t __cdecl mvlineasm4(int32_t,char *);
66
extern int32_t __cdecl mvlineasm4(int32_t,char *);
67
extern int32_t __cdecl setupspritevline(int32_t,int32_t,int32_t,int32_t,int32_t,int32_t);
67
extern int32_t __cdecl setupspritevline(int32_t,int32_t,int32_t,int32_t,int32_t,int32_t);
68
extern int32_t __cdecl spritevline(int32_t,int32_t,int32_t,int32_t,int32_t,int32_t);
68
extern int32_t __cdecl spritevline(int32_t,int32_t,int32_t,int32_t,int32_t,int32_t);
69
extern int32_t __cdecl msetupspritevline(int32_t,int32_t,int32_t,int32_t,int32_t,int32_t);
69
extern int32_t __cdecl msetupspritevline(int32_t,int32_t,int32_t,int32_t,int32_t,int32_t);
70
extern int32_t __cdecl mspritevline(int32_t,int32_t,int32_t,int32_t,int32_t,int32_t);
70
extern int32_t __cdecl mspritevline(int32_t,int32_t,int32_t,int32_t,int32_t,int32_t);
71
extern int32_t __cdecl tsetupspritevline(int32_t,int32_t,int32_t,int32_t,int32_t,int32_t);
71
extern int32_t __cdecl tsetupspritevline(int32_t,int32_t,int32_t,int32_t,int32_t,int32_t);
72
extern int32_t __cdecl tspritevline(int32_t,int32_t,int32_t,int32_t,int32_t,int32_t);
72
extern int32_t __cdecl tspritevline(int32_t,int32_t,int32_t,int32_t,int32_t,int32_t);
73
extern int32_t __cdecl mhline(int32_t,int32_t,int32_t,int32_t,int32_t,int32_t);
73
extern int32_t __cdecl mhline(int32_t,int32_t,int32_t,int32_t,int32_t,int32_t);
74
extern int32_t __cdecl mhlineskipmodify(int32_t,int32_t,int32_t,int32_t,int32_t,int32_t);
74
extern int32_t __cdecl mhlineskipmodify(int32_t,int32_t,int32_t,int32_t,int32_t,int32_t);
75
extern int32_t __cdecl msethlineshift(int32_t,int32_t);
75
extern int32_t __cdecl msethlineshift(int32_t,int32_t);
76
extern int32_t __cdecl thline(int32_t,int32_t,int32_t,int32_t,int32_t,int32_t);
76
extern int32_t __cdecl thline(int32_t,int32_t,int32_t,int32_t,int32_t,int32_t);
77
extern int32_t __cdecl thlineskipmodify(int32_t,int32_t,int32_t,int32_t,int32_t,int32_t);
77
extern int32_t __cdecl thlineskipmodify(int32_t,int32_t,int32_t,int32_t,int32_t,int32_t);
78
extern int32_t __cdecl tsethlineshift(int32_t,int32_t);
78
extern int32_t __cdecl tsethlineshift(int32_t,int32_t);
79
extern int32_t __cdecl setupslopevlin(int32_t,int32_t,int32_t);
79
extern int32_t __cdecl setupslopevlin(int32_t,int32_t,int32_t);
80
extern int32_t __cdecl slopevlin(int32_t,int32_t,int32_t,int32_t,int32_t,int32_t);
80
extern int32_t __cdecl slopevlin(int32_t,int32_t,int32_t,int32_t,int32_t,int32_t);
81
extern int32_t __cdecl settransnormal();
81
extern int32_t __cdecl settransnormal();
82
extern int32_t __cdecl settransreverse();
82
extern int32_t __cdecl settransreverse();
83
extern int32_t __cdecl setupdrawslab(int32_t,int32_t);
83
extern int32_t __cdecl setupdrawslab(int32_t,int32_t);
84
extern int32_t __cdecl drawslab(int32_t,int32_t,int32_t,int32_t,int32_t,int32_t);
84
extern int32_t __cdecl drawslab(int32_t,int32_t,int32_t,int32_t,int32_t,int32_t);
85
extern void __cdecl stretchhline(int32_t,int32_t,int32_t,int32_t,int32_t,int32_t);
85
extern void __cdecl stretchhline(int32_t,int32_t,int32_t,int32_t,int32_t,int32_t);
86
86
87
#ifdef __cplusplus
87
#ifdef __cplusplus
88
}
88
}
89
#endif
89
#endif
90
90
91
#else // !defined(NOASM) && (defined(_MSC_VER) || (defined(__GNUC__) && defined(__i386__)))
91
#else // !defined(NOASM) && (defined(_MSC_VER) || (defined(__GNUC__) && defined(__i386__)))
92
92
93
#define ENGINE_USING_A_C
93
#define ENGINE_USING_A_C
94
#include <stdint.h>
94
#include <stdint.h>
95
95
96
#define prevlineasm1 vlineasm1
96
#define prevlineasm1 vlineasm1
97
97
98
void setvlinebpl(int32_t dabpl);
98
void setvlinebpl(int32_t dabpl);
99
void fixtransluscence(intptr_t datransoff);
99
void fixtransluscence(intptr_t datransoff);
100
void settransnormal(void);
100
void settransnormal(void);
101
void settransreverse(void);
101
void settransreverse(void);
102
102
103
void sethlinesizes(int32_t logx, int32_t logy, intptr_t bufplc);
103
void sethlinesizes(int32_t logx, int32_t logy, intptr_t bufplc);
104
void setpalookupaddress(char *paladdr);
104
void setpalookupaddress(char *paladdr);
105
void setuphlineasm4(int32_t bxinc, int32_t byinc);
105
void setuphlineasm4(int32_t bxinc, int32_t byinc);
106
void hlineasm4(int32_t cnt, int32_t skiploadincs, int32_t paloffs, uint32_t by, uint32_t bx, intptr_t p);
106
void hlineasm4(int32_t cnt, int32_t skiploadincs, int32_t paloffs, uint32_t by, uint32_t bx, intptr_t p);
107
107
108
void setupslopevlin(int32_t logylogx, intptr_t bufplc, int32_t pinc);
108
void setupslopevlin(int32_t logylogx, intptr_t bufplc, int32_t pinc);
109
void slopevlin(intptr_t p, int32_t i, intptr_t slopaloffs, int32_t cnt, int32_t bx, int32_t by);
109
void slopevlin(intptr_t p, int32_t i, intptr_t slopaloffs, int32_t cnt, int32_t bx, int32_t by);
110
110
111
void setupvlineasm(int32_t neglogy);
111
void setupvlineasm(int32_t neglogy);
112
int32_t vlineasm1(int32_t vinc, intptr_t paloffs, int32_t cnt, uint32_t vplc, intptr_t bufplc, intptr_t p);
112
int32_t vlineasm1(int32_t vinc, intptr_t paloffs, int32_t cnt, uint32_t vplc, intptr_t bufplc, intptr_t p);
113
void vlineasm4(int32_t cnt, char *p);
113
void vlineasm4(int32_t cnt, char *p);
114
114
115
void setupmvlineasm(int32_t neglogy, int32_t dosaturate);
115
void setupmvlineasm(int32_t neglogy, int32_t dosaturate);
116
int32_t mvlineasm1(int32_t vinc, intptr_t paloffs, int32_t cnt, uint32_t vplc, intptr_t bufplc, intptr_t p);
116
int32_t mvlineasm1(int32_t vinc, intptr_t paloffs, int32_t cnt, uint32_t vplc, intptr_t bufplc, intptr_t p);
117
void mvlineasm4(int32_t cnt, char *p);
117
void mvlineasm4(int32_t cnt, char *p);
118
118
119
void setuptvlineasm(int32_t neglogy, int32_t dosaturate);
119
void setuptvlineasm(int32_t neglogy, int32_t dosaturate);
120
int32_t tvlineasm1(int32_t vinc, intptr_t paloffs, int32_t cnt, uint32_t vplc, intptr_t bufplc, intptr_t p);
120
int32_t tvlineasm1(int32_t vinc, intptr_t paloffs, int32_t cnt, uint32_t vplc, intptr_t bufplc, intptr_t p);
121
121
122
void setuptvlineasm2(int32_t neglogy, intptr_t paloffs1, intptr_t paloffs2);
122
void setuptvlineasm2(int32_t neglogy, intptr_t paloffs1, intptr_t paloffs2);
123
void tvlineasm2(uint32_t vplc2, int32_t vinc1, intptr_t bufplc1, intptr_t bufplc2, uint32_t vplc1, intptr_t p);
123
void tvlineasm2(uint32_t vplc2, int32_t vinc1, intptr_t bufplc1, intptr_t bufplc2, uint32_t vplc1, intptr_t p);
124
124
125
void msethlineshift(int32_t logx, int32_t logy);
125
void msethlineshift(int32_t logx, int32_t logy);
126
void mhline(intptr_t bufplc, uint32_t bx, int32_t cntup16, int32_t junk, uint32_t by, intptr_t p);
126
void mhline(intptr_t bufplc, uint32_t bx, int32_t cntup16, int32_t junk, uint32_t by, intptr_t p);
127
127
128
void tsethlineshift(int32_t logx, int32_t logy);
128
void tsethlineshift(int32_t logx, int32_t logy);
129
void thline(intptr_t bufplc, uint32_t bx, int32_t cntup16, int32_t junk, uint32_t by, intptr_t p);
129
void thline(intptr_t bufplc, uint32_t bx, int32_t cntup16, int32_t junk, uint32_t by, intptr_t p);
130
130
131
void setupspritevline(intptr_t paloffs, int32_t bxinc, int32_t byinc, int32_t ysiz);
131
void setupspritevline(intptr_t paloffs, int32_t bxinc, int32_t byinc, int32_t ysiz);
132
void spritevline(int32_t bx, int32_t by, int32_t cnt, intptr_t bufplc, intptr_t p);
132
void spritevline(int32_t bx, int32_t by, int32_t cnt, intptr_t bufplc, intptr_t p);
133
133
134
void msetupspritevline(intptr_t paloffs, int32_t bxinc, int32_t byinc, int32_t ysiz);
134
void msetupspritevline(intptr_t paloffs, int32_t bxinc, int32_t byinc, int32_t ysiz);
135
void mspritevline(int32_t bx, int32_t by, int32_t cnt, intptr_t bufplc, intptr_t p);
135
void mspritevline(int32_t bx, int32_t by, int32_t cnt, intptr_t bufplc, intptr_t p);
136
136
137
void tsetupspritevline(intptr_t paloffs, int32_t bxinc, int32_t byinc, int32_t ysiz);
137
void tsetupspritevline(intptr_t paloffs, int32_t bxinc, int32_t byinc, int32_t ysiz);
138
void tspritevline(int32_t bx, int32_t by, int32_t cnt, intptr_t bufplc, intptr_t p);
138
void tspritevline(int32_t bx, int32_t by, int32_t cnt, intptr_t bufplc, intptr_t p);
139
139
140
void setupdrawslab (int32_t dabpl, intptr_t pal);
140
void setupdrawslab (int32_t dabpl, intptr_t pal);
141
void drawslab (int32_t dx, int32_t v, int32_t dy, int32_t vi, intptr_t vptr, intptr_t p);
141
void drawslab (int32_t dx, int32_t v, int32_t dy, int32_t vi, intptr_t vptr, intptr_t p);
142
void stretchhline (intptr_t p0, int32_t u, int32_t cnt, int32_t uinc, intptr_t rptr, intptr_t p);
142
void stretchhline (intptr_t p0, int32_t u, int32_t cnt, int32_t uinc, intptr_t rptr, intptr_t p);
143
143
144
void mmxoverlay();
144
void mmxoverlay();
145
145
146
#endif  // else
146
#endif  // else
147
147
148
#endif // a_h_
148
#endif // a_h_
149
 
149