-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathnosdl_compat.h
More file actions
159 lines (126 loc) · 3.22 KB
/
nosdl_compat.h
File metadata and controls
159 lines (126 loc) · 3.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
#ifndef NOSDL_COMPAT_H
#define NOSDL_COMPAT_H
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <stdio.h>
// Only define stub functions if not using full implementation
#ifndef USE_FULL_COMPAT_IMPL
// DOS compatibility macros
#define MK_FP(seg, off) ((void*)((seg << 4) + off))
#define farmalloc(size) malloc(size)
#define farfree(ptr) free(ptr)
#define _fmemcpy(dest, src, size) memcpy(dest, src, size)
#define halloc(nitems, size) malloc((nitems) * (size))
#define hfree(ptr) free(ptr)
// Video memory emulation
static uint8_t *vga_memory_buffer = NULL;
// DOS interrupt stubs
#define disable()
#define enable()
#define _disable()
#define _enable()
// Port I/O stubs
static inline uint8_t inp(uint16_t port) {
return 0;
}
static inline void outp(uint16_t port, uint8_t value) {
(void)port;
(void)value;
}
static inline uint8_t inportb(uint16_t port) {
return inp(port);
}
static inline void outportb(uint16_t port, uint8_t value) {
outp(port, value);
}
// Interrupt function declaration stub
#define _interrupt
#define interrupt
// DOS interrupt vector functions
typedef void (*interrupt_handler)(void);
static inline interrupt_handler _dos_getvect(int intno) {
(void)intno;
return NULL; // Return null handler
}
static inline void _dos_setvect(int intno, interrupt_handler handler) {
(void)intno;
(void)handler;
// No operation for stub
}
// File mode constants
#ifndef O_BINARY
#define O_BINARY 0
#endif
// Video mode functions
static inline void setmode(int mode) {
if (mode == 0x13) {
if (!vga_memory_buffer) {
vga_memory_buffer = (uint8_t*)malloc(320 * 200);
memset(vga_memory_buffer, 0, 320 * 200);
}
}
}
static inline void cls(char *screen) {
memset(screen, 0, 320 * 200);
}
static inline void screenswap(char *screen) {
// In real implementation, this would update the display
(void)screen;
}
static inline void setpalette(char *colorlist) {
(void)colorlist;
}
static inline void clearscreen(char *vscreen) {
memset(vscreen, 0, 64000);
}
// Mouse functions
static inline uint16_t initmouse(void) {
return 1; // Mouse available
}
static inline uint16_t readmbutton(void) {
return 0; // No buttons pressed
}
static inline void relpos(int *x, int *y) {
*x = 0;
*y = 0;
}
// Keyboard functions
static inline void setkb(void) {
}
static inline void resetkb(void) {
}
static inline int kbhit(void) {
return 0;
}
static inline int getch(void) {
return getchar();
}
static inline int get_next_keypress(void) {
return 0; // No keypress in stub mode
}
// Timer functions
static inline uint32_t get_ticks(void) {
return 0;
}
static inline void delay(uint32_t ms) {
(void)ms;
}
// Initialize compatibility layer
static inline int init_sdl_compat(void) {
vga_memory_buffer = (uint8_t*)malloc(320 * 200);
if (!vga_memory_buffer) {
return -1;
}
memset(vga_memory_buffer, 0, 320 * 200);
return 0;
}
static inline void cleanup_sdl_compat(void) {
if (vga_memory_buffer) {
free(vga_memory_buffer);
vga_memory_buffer = NULL;
}
}
// Sound stubs - typedefs moved to OLDSOUND.H to avoid duplication
#endif // USE_FULL_COMPAT_IMPL
#endif // NOSDL_COMPAT_H