-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCore.lua
More file actions
246 lines (205 loc) · 7.16 KB
/
Copy pathCore.lua
File metadata and controls
246 lines (205 loc) · 7.16 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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
---@meta
---@alias GameKey
---| C.GB_KEY
---| C.GBA_KEY
---@class Core
---An instance of an emulator core.
local Core = {
---Add a single key to the currently active key list
---@param self Core
---@param key GameKey
addKey = function(self, key) end,
---Add a bitmask of keys to the currently active key list
---@param self Core
---@param keys integer
addKeys = function(self, keys) end,
---Load the save data associated with the currently loaded ROM file
---@param self Core
---@return boolean success
autoloadSave = function(self) end,
---Get the checksum of the loaded ROM
---@param self Core
---@param type? integer
---@return string checksum
checksum = function(self, type) end,
---Remove a single key from the currently active key list
---@param self Core
---@param key GameKey
clearKey = function(self, key) end,
---Remove a bitmask of keys from the currently active key list
---@param self Core
---@param keys integer
clearKeys = function(self, keys) end,
---Get the number of the current frame
---@param self Core
---@return integer frame
currentFrame = function(self) end,
---Get the number of cycles per frame
---@param self Core
---@return integer cycles
frameCycles = function(self) end,
---Get the number of cycles per second
---@param self Core
---@return integer frequency
frequency = function(self) end,
---Get internal product code for the game from the ROM header, if available
---@param self Core
---@return string code
getGameCode = function(self) end,
---Get internal title of the game from the ROM header
---@param self Core
---@return string title
getGameTitle = function(self) end,
---Get the active state of a given key
---@param self Core
---@param key GameKey
---@return 0 | 1 key
getKey = function(self, key) end,
---Get the currently active keys as a bitmask
---@param self Core
---@return integer keys
getKeys = function(self) end,
---Load a ROM file into the current state of this core
---@param self Core
---@param path string
---@return boolean success
loadFile = function(self, path) end,
---Load save data from the given path.
---If the `temporary` flag is set,
---the given save data will not be written back to disk
---@param self Core
---@param path string
---@param temporary boolean
---@return boolean success
loadSaveFile = function(self, path, temporary) end,
---Load state from a buffer
---@param self Core
---@param buffer string
---@param flags? integer
---@return boolean success
---@see C.SAVESTATE for possible values for `flags`
loadStateBuffer = function(self, buffer, flags) end,
---Load state from the given path
---@param self Core
---@param path string
---@param flags? integer
---@return boolean success
---@see C.SAVESTATE for possible values for `flags`
loadStateFile = function(self, path, flags) end,
---Load state from the slot number
---@param self Core
---@param slot integer
---@param flags? integer
---@return boolean success
---@see C.SAVESTATE for possible values for `flags`
loadStateSlot = function(self, slot, flags) end,
---Get which platform is being emulated
---@param self Core
---@return C.PLATFORM platform
---@see C.PLATFORM for possible values
platform = function(self) end,
---Read a 16-bit value from the given bus address
---@param self Core
---@param address integer
---@return integer value
read16 = function(self, address) end,
---Read a 32-bit value from the given bus address
---@param self Core
---@param address integer
---@return integer value
read32 = function(self, address) end,
---Read an 8-bit value from the given bus address
---@param self Core
---@param address integer
---@return integer value
read8 = function(self, address) end,
---Read byte range from the given offset
---@param self Core
---@param address integer
---@param length integer
---@return string range
readRange = function(self, address, length) end,
---Read the value of the register with the given name
---@param self Core
---@param regName RegisterName
---@return integer value
readRegister = function(self, regName) end,
---Reset the emulation.
---This does not invoke the `reset` callback
---@param self Core
reset = function(self) end,
---Get the size of the loaded ROM
---@param self Core
---@return integer size
romSize = function(self) end,
---Run until the next frame
---@param self Core
runFrame = function(self) end,
---Save state and return as a buffer
---@param self Core
---@param flags? integer
---@return string success
---@see C.SAVESTATE for possible values for `flags`
saveStateBuffer = function(self, flags) end,
---Save state to the given path
---@param self Core
---@param path string
---@param flags? integer
---@return boolean success
---@see C.SAVESTATE for possible values for `flags`
saveStateFile = function(self, path, flags) end,
---Save state to the slot number
---@param self Core
---@param slot integer
---@param flags? integer
---@return boolean success
---@see C.SAVESTATE for possible values for `flags`
saveStateSlot = function(self, slot, flags) end,
---Save a screenshot
---@param self Core
---@param filename? string
screenshot = function(self, filename) end,
---Set the currently active key list
---@param self Core
---@param keys integer
setKeys = function(self, keys) end,
---Run a single instruction
---@param self Core
step = function(self) end,
---Write a 16-bit value from the given bus address
---@param self Core
---@param address integer
---@param value integer
write16 = function(self, address, value) end,
---Write a 32-bit value from the given bus address
---@param self Core
---@param address integer
---@param value integer
write32 = function(self, address, value) end,
---Write an 8-bit value from the given bus address
---@param self Core
---@param address integer
---@param value integer
write8 = function(self, address, value) end,
---Write the value of the register with the given name
---@param self Core
---@param regName RegisterName
---@param value integer
writeRegister = function(self, regName, value) end
}
---@class CoreAdapter: Core
---A wrapper around a [`Core`](lua://Core) object that exposes more functionality.
---It can be implicity cast to a [`Core`](lua://Core) object,
---and exposes the same methods.
---@see Core
emu = {
---Reset the emulation.
---As opposed to [`Core.reset`](lua://Core.reset),
---this version calls the [`reset`](lua://callback) callback
---@param self CoreAdapter
reset = function(self) end,
---A table containing a platform-specific set of
---[`MemoryDomain`](lua://MemoryDomain) objects
---@type table<GBAMemoryDomain | GBMemoryDomain, MemoryDomain>
memory = nil
}