c057413e4cedbb72c1016edaf2064deca354a64d
[reactos.git] / subsystems / ntvdm / ntvdm.h
1 /*
2 * COPYRIGHT: GPL - See COPYING in the top level directory
3 * PROJECT: ReactOS Virtual DOS Machine
4 * FILE: ntvdm.h
5 * PURPOSE: Header file to define commonly used stuff
6 * PROGRAMMERS: Aleksandar Andrejevic <theflash AT sdf DOT lonestar DOT org>
7 */
8
9 #ifndef _NTVDM_H_
10 #define _NTVDM_H_
11
12 /* INCLUDES *******************************************************************/
13
14 #include <stdio.h>
15 #include <stdarg.h>
16 #include <conio.h>
17
18 #define WIN32_NO_STATUS
19 #include <windef.h>
20 #include <winbase.h>
21 #include <wingdi.h>
22 #include <wincon.h>
23 #include <winnls.h>
24 #include <winuser.h>
25
26 #include <debug.h>
27
28 /* DEFINES ********************************************************************/
29
30 /* Basic Memory Management */
31 #define TO_LINEAR(seg, off) (((seg) << 4) + (off))
32 #define MAX_SEGMENT 0xFFFF
33 #define MAX_OFFSET 0xFFFF
34 #define MAX_ADDRESS 0x1000000 // 16 MB of RAM
35
36 #define FAR_POINTER(x) \
37 (PVOID)((ULONG_PTR)BaseAddress + TO_LINEAR(HIWORD(x), LOWORD(x)))
38
39 #define SEG_OFF_TO_PTR(seg, off) \
40 (PVOID)((ULONG_PTR)BaseAddress + TO_LINEAR((seg), (off)))
41
42 /* BCD-Binary conversion */
43 #define BINARY_TO_BCD(x) ((((x) / 1000) << 12) + (((x) / 100) << 8) + (((x) / 10) << 4) + ((x) % 10))
44 #define BCD_TO_BINARY(x) (((x) >> 12) * 1000 + ((x) >> 8) * 100 + ((x) >> 4) * 10 + ((x) & 0x0F))
45
46 /* Processor speed */
47 #define STEPS_PER_CYCLE 256
48
49 /* FUNCTIONS ******************************************************************/
50
51 extern LPVOID BaseAddress;
52 extern BOOLEAN VdmRunning;
53
54 VOID DisplayMessage(LPCWSTR Format, ...);
55
56 #endif // _NTVDM_H_
57
58 /* EOF */