-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathatari.h
135 lines (105 loc) · 4.52 KB
/
atari.h
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
#ifndef ATARI_H_
#define ATARI_H_
#include "config.h"
#include <stdio.h> /* FILENAME_MAX */
#ifdef WIN32
#include <windows.h>
#endif
/* Fundamental declarations ---------------------------------------------- */
#define Atari800_TITLE "Atari 800 Emulator, Version 2.1.0"
#ifndef FALSE
#define FALSE 0
#endif
#ifndef TRUE
#define TRUE 1
#endif
/* SBYTE and UBYTE must be exactly 1 byte long. */
/* SWORD and UWORD must be exactly 2 bytes long. */
/* SLONG and ULONG must be exactly 4 bytes long. */
#define SBYTE signed char
#define SWORD signed short
#define SLONG signed int
#define UBYTE unsigned char
#define UWORD unsigned short
#ifndef WIN32
/* Windows headers typedef ULONG */
#define ULONG unsigned int
#endif
/* Note: in various parts of the emulator we assume that char is 1 byte
and int is 4 bytes. */
/* Public interface ------------------------------------------------------ */
/* Machine type. */
#define Atari800_MACHINE_OSA 0
#define Atari800_MACHINE_OSB 1
#define Atari800_MACHINE_XLXE 2
#define Atari800_MACHINE_5200 3
extern int Atari800_machine_type;
/* Always call Atari800_InitialiseMachine() after changing Atari800_machine_type
or MEMORY_ram_size! */
/* Video system. */
#define Atari800_TV_UNSET 0
#define Atari800_TV_PAL 312
#define Atari800_TV_NTSC 262
/* Video system / Number of scanlines per frame. */
extern int Atari800_tv_mode;
/* TRUE to disable Atari BASIC when booting Atari (hold Option in XL/XE). */
extern int Atari800_disable_basic;
/* If Atari800_Frame() sets it to TRUE, then the current contents
of Screen_atari should be displayed. */
extern int Atari800_display_screen;
/* Simply incremented by Atari800_Frame(). */
extern int Atari800_nframes;
/* How often the screen is updated (1 = every Atari frame). */
extern int Atari800_refresh_rate;
/* Set to TRUE for faster emulation with Atari800_refresh_rate > 1.
Set to FALSE for accurate emulation with Atari800_refresh_rate > 1. */
extern int Atari800_collisions_in_skipped_frames;
/* Initializes Atari800 emulation core. */
int Atari800_Initialise(int *argc, char *argv[]);
/* Emulates one frame (1/50sec for PAL, 1/60sec for NTSC). */
void Atari800_Frame(void);
/* Reboots the emulated Atari. */
void Atari800_Coldstart(void);
/* Presses the Reset key in the emulated Atari. */
void Atari800_Warmstart(void);
/* Reinitializes after Atari800_machine_type or ram_size change.
You should call Atari800_Coldstart() after it. */
int Atari800_InitialiseMachine(void);
/* Shuts down Atari800 emulation core. */
int Atari800_Exit(int run_monitor);
/* Private interface ----------------------------------------------------- */
/* Don't use outside the emulation core! */
/* STAT_UNALIGNED_WORDS is solely for benchmarking purposes.
8-element arrays (stat_arr) represent number of accesses with the given
value of 3 least significant bits of address. This gives us information
about the ratio of aligned vs unaligned accesses. */
#ifdef STAT_UNALIGNED_WORDS
#define UNALIGNED_STAT_DEF(stat_arr) unsigned int stat_arr[8];
#define UNALIGNED_STAT_DECL(stat_arr) extern unsigned int stat_arr[8];
#define UNALIGNED_GET_WORD(ptr, stat_arr) (stat_arr[(unsigned int) (ptr) & 7]++, *(const UWORD *) (ptr))
#define UNALIGNED_PUT_WORD(ptr, value, stat_arr) (stat_arr[(unsigned int) (ptr) & 7]++, *(UWORD *) (ptr) = (value))
#define UNALIGNED_GET_LONG(ptr, stat_arr) (stat_arr[(unsigned int) (ptr) & 7]++, *(const ULONG *) (ptr))
#define UNALIGNED_PUT_LONG(ptr, value, stat_arr) (stat_arr[(unsigned int) (ptr) & 7]++, *(ULONG *) (ptr) = (value))
UNALIGNED_STAT_DECL(Screen_atari_write_long_stat)
UNALIGNED_STAT_DECL(pm_scanline_read_long_stat)
UNALIGNED_STAT_DECL(memory_read_word_stat)
UNALIGNED_STAT_DECL(memory_write_word_stat)
UNALIGNED_STAT_DECL(memory_read_aligned_word_stat)
UNALIGNED_STAT_DECL(memory_write_aligned_word_stat)
#else
#define UNALIGNED_STAT_DEF(stat_arr)
#define UNALIGNED_STAT_DECL(stat_arr)
#define UNALIGNED_GET_WORD(ptr, stat_arr) (*(const UWORD *) (ptr))
#define UNALIGNED_PUT_WORD(ptr, value, stat_arr) (*(UWORD *) (ptr) = (value))
#define UNALIGNED_GET_LONG(ptr, stat_arr) (*(const ULONG *) (ptr))
#define UNALIGNED_PUT_LONG(ptr, value, stat_arr) (*(ULONG *) (ptr) = (value))
#endif
/* Sleeps until it's time to emulate next Atari frame. */
void Atari800_Sync(void);
/* Load a ROM image filename of size nbytes into buffer */
int Atari800_LoadImage(const char *filename, UBYTE *buffer, int nbytes);
/* Save State */
void Atari800_StateSave(void);
/* Read State */
void Atari800_StateRead(void);
#endif /* ATARI_H_ */