forked from redcode/SpecEmu
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SpecEmu.Inc
375 lines (286 loc) · 13.2 KB
/
SpecEmu.Inc
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
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
; #########################################################################
; include files
; ~~~~~~~~~~~~~
include windows.inc
include mymacros.inc
include Resource.inc
include Strings.inc
include lists.inc
include \masm32\com\include\oaidl.inc
; include C:\masm32\com\include\colib.inc
include C:\masm32\com\include\component.inc
inclib masm32
inclib gdi32
inclib user32
inclib kernel32
inclib comctl32
inclib comdlg32
inclib shell32
inclib shlwapi
inclib ole32
inclib advapi32
inclib winmm
inclib ddraw
inclib woodylib
inclib csw
inclib fdc765
inclib szx
inclib cryptohash
inclib speccpp
include zlib1.inc
include filestream.inc
IFDEF WANTSOUND
inclib dsound
ENDIF
include z80core.inc
include RZX.inc
include DrawIcons.inc
include Joystick.inc
; #########################################################################
;==================
; Global prototypes
;==================
;=================
; Local prototypes
;=================
WinMain PROTO :DWORD,:DWORD,:DWORD,:DWORD
WndProc PROTO :DWORD,:DWORD,:DWORD,:DWORD
TopXY PROTO :DWORD,:DWORD
Paint_Proc PROTO :DWORD,:DWORD
GetFileName PROTO :DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD
SaveFileName PROTO :DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD
ReadProfileInt PROTO :DWORD,:DWORD
WriteProfileInt PROTO :DWORD,:DWORD
AttachMenu PROTO :DWORD
DetachMenu PROTO
EnableMultifaceOrSoftRom PROTO
SetTbrColorMap PROTO
PopulateMemoryDlg PROTO
Populate_Stack PROTO
Populate_Memory PROTO
SetMemoryViewAddr PROTO :WORD
SetSnowEffect PROTO
Set_Emulate_AY PROTO
ParseUserCondition PROTO :DWORD
DisassembleLine PROTO :PTR @@textstringptr
AddRecentFile PROTO
ReadQuickLoadPath PROTO
WriteQuickLoadPath PROTO
Timex_Write_FF PROTO :BYTE
Set_Timex_Border_Colour PROTO :BYTE
SwitchModel PROTO :BYTE
WipeSpeccyMem PROTO
LoadSnapshot PROTO :DWORD
LoadSnapshot_1 PROTO :DWORD
AttemptLoadSnapshot PROTO :DWORD
SaveSnapshot PROTO :DWORD
SaveSnapshotByExtension PROTO :DWORD
InsertTape PROTO
InsertTape_1 PROTO :DWORD
CloseTapeFile PROTO
OpenFileType PROTO
InsertDisk PROTO
InsertDisk_1 PROTO :DWORD
LoadPlus3Diskfile PROTO :DWORD
LoadTRDOSDiskfile PROTO :DWORD
LoadPLUSDDiskfile PROTO :DWORD
LoadCBIDiskfile PROTO :DWORD
LoadIF2_ROM PROTO :DWORD
LoadIF2ROM_1 PROTO :DWORD
Init_AY PROTO
FixSnapOnHalt PROTO
AddZ80MsgItem PROTO :DWORD, :DWORD
AddZ80MsgIgnoredItem PROTO :BYTE
SaveScreenFile PROTO
CheckRZXRecording PROTO
PopulateBrkListbox PROTO
RenderSpeccy PROTO :DWORD
FreeMemory PROTO :DWORD
ReadFileType PROTO :DWORD
ReadFileType_2 PROTO :DWORD
PauseResumeEmulation PROTO
Read_SCR PROTO :DWORD
LoadROMFile PROTO :DWORD,:DWORD,:DWORD
ShowMessageBox PROTO :DWORD,:DWORD,:DWORD,:DWORD
FuzzScreenMemory PROTO
Start_PC_Logging PROTO :PTR
Stop_PC_Logging PROTO
Log_PC PROTO
Log_Registers PROTO
SetDebuggerLogButtonState PROTO
PrtBase8 PROTO :DWORD,:BYTE
PrtBase16 PROTO :DWORD,:WORD,:BYTE
PrtBase32 PROTO :DWORD,:DWORD
OutBase8 PROTO :DWORD,:BYTE
OutBase16 PROTO :DWORD,:WORD,:BYTE
DRAM_Fade PROTO
GetZ80MemoryAddr PROTO :WORD
ReadZ80Byte PROTO :WORD
ReadZ80Word PROTO :WORD
WriteZ80Byte PROTO :WORD,:BYTE
WriteZ80Word PROTO :WORD,:WORD
GetBankAddr PROTO :BYTE
ReadBankByte PROTO :BYTE,:WORD
ReadBankWord PROTO :BYTE,:WORD
WriteBankByte PROTO :BYTE,:WORD,:BYTE
WriteBankWord PROTO :BYTE,:WORD,:WORD
GetBankAtAddr PROTO :WORD
GetBankConfig PROTO
Handle_Command_Line PROTO
cl_NextArgument PROTO
FilenameHas128K PROTO :DWORD
AddTaskQueue PROTO :DWORD,:DWORD,:DWORD
FreeTaskQueue PROTO
ExecTaskQueueTask PROTO
ExecTaskMemDump PROTO :DWORD
wsprintfA PROTO C :DWORD,:VARARG
wsprintf equ <wsprintfA>
.const
align 4
numStatusParts equ 4
statusdiffs dd -80, -140, -80, -1
statuspart_info equ 0
statuspart_rzx equ 1
statuspart_machine equ 2
statuspart_speed equ 3
szWindowName db "SpecEmu", 0
szApplicationName db "SpecEmu", 0
szClassName db "SpecEmuClass", 0
szLOGFilter db "LOG files (*.log)",0,"*.log",0, 0
; fonts
Courier_8 LOGFONT <-11,0,0,0,400,0,0,0,0,1,2,1,49,"Courier">
Courier_New_6 LOGFONT <-8,0,0,0,400,0,0,0,0,3,2,1,49,"Courier New">
Courier_New_9 LOGFONT <-12,0,0,0,400,0,0,0,0,3,2,1,49,"Courier New">
char_quote db 34, 0
char_space db " ", 0
chars_newline db 13, 10 ; sizeof chars_newline = 2 by having NULL on following source line
db 0
char_quote_space db 34, " ", 0
.data
DoLogging db FALSE
InitialLogOpcode db FALSE
.data?
align 4
PCLogFileStream DWORD ?
PCLog_Filesize DWORD ?
PCLog_Warnsize DWORD ?
CommandLine DWORD ?
hWnd DWORD ?
hInstance DWORD ?
hIcon DWORD ?
lastmousemovelParam DWORD ?
ProcessID DWORD ?
SoftRomDlg DWORD ?
Tools1Dlg DWORD ?
MW_MemViewDlg DWORD ?
AssemblerDlg DWORD ?
MessagesDlg DWORD ?
RemoteStepCounter DWORD ?
loadtime_minutes DWORD ? ; total loading time of mastered TAP image
loadtime_seconds DWORD ?
loadtime_tstates DWORD ?
hScintilla DWORD ?
UserPalette DWORD ? ; current Spectrum palette in use
ProcessInfo PROCESS_INFORMATION <>
StartupInfo STARTUPINFO <>
BytesMoved DWORD ?
BytesSaved DWORD ?
FDCCommandBytes BYTE 16 dup (?)
TbrColorMap BYTE 1 * sizeof COLORMAP dup(?)
szProcessID BYTE 9 dup (?) ; gets 8 char hex representation of this app's process ID + null terminator
snap_bordercol BYTE ? ; temp z80 file border colour because +2A/+3 machine initialisation set border to black
; Mapped Memory flags:
BITDEF MEMMAP, EXECUTE, 0
BITDEF MEMMAP, READ_BYTE, 1
BITDEF MEMMAP, READ_WORD, 2
BITDEF MEMMAP, WRITE_BYTE, 3
BITDEF MEMMAP, WRITE_WORD, 4
BITDEF MEMMAP, STACK_READ, 5
BITDEF MEMMAP, STACK_WRITE, 6
; HardwareMode definitions:-
; --------------------------
RESETENUM 0
ENUM HW_16, HW_48
ENUM HW_128, HW_PLUS2
ENUM HW_PLUS2A, HW_PLUS3
ENUM HW_PENTAGON128
ENUM HW_TC2048
ENUM HW_TK90X
ENUM HW_ENDLIST
HW_FIRSTMACHINE EQU HW_16
HW_LASTMACHINE EQU HW_ENDLIST - 1
IFDEF PACMAN
Enable_Pacmode PROTO :BYTE,:BYTE
Disable_Pacmode PROTO
Free_PacInputMem PROTO
LoadPacLevel_Input PROTO
ReadPacInputPair PROTO
ReadPacInputByte PROTO
ReadPacController PROTO
StreamPacDataOut PROTO :BYTE
StreamPacDataPair PROTO
StreamEndDataOut PROTO
Pac_Is_0123 PROTO
Set_Pacman_Patches PROTO
Is_Pacman_Trapped PROTO
Handle_Pac_Patches PROTO
Draw_Pacman_Level_Text PROTO
DrawPacScore PROTO :DWORD
DrawBCDByte PROTO :BYTE
FixupLevel255 PROTO
GetPacmanFilepath PROTO :DWORD
LoadPacmanROMs PROTO
PrepPacManEnviron PROTO
align 4
pac_strm_handle DWORD ?
pacinput_base DWORD ?
pacinput_ptr DWORD ?
pacinput_len DWORD ?
paclevel_loaded DWORD ?
pacdrawaddr DWORD ?
pac_input_pair WORD ? ; low = kempston data, high = count
pacromcrc_upper WORD ? ; crc16 of upper 8K of Pacman ROM (in bank 0)
HavePacmanROMs BYTE ?
pacmode BYTE ?
pacmanfilepath BYTE MAX_PATH dup (?)
; values for pacmode flag
RESETENUM 0
ENUM PACMODE_NONE
ENUM PACMODE_FREEPLAY
ENUM PACMODE_RECORD, PACMODE_PLAYBACK
ENDIF
; values for Debug Run To conditions
; enumerate Device Port Identifiers
RESETENUM
ENUM DEVICE_NONE
ENUM TRDOS_SYSTEM_REGISTER, TRDOS_STATUS_REGISTER, TRDOS_TRACK_REGISTER, TRDOS_SECTOR_REGISTER, TRDOS_DATA_REGISTER, TRDOS_COMMAND_REGISTER
ENUM ULA_FE, PAGING_7FFD, PAGING_1FFD
; enumerate RUN_TO condition types
RESETENUM
ENUM RUN_TO_PC
ENUM RUN_TO_INTERRUPT, RUN_TO_INTERRUPT_RETRIGGER
ENUM RUN_TO_CYCLE
ENUM RUN_TO_PORT_READ, RUN_TO_PORT_WRITE
ENUM RUN_TO_DEVICE_PORT_READ, RUN_TO_DEVICE_PORT_WRITE
ENUM RUN_TO_FLOATING_BUS_PORT_READ
ENUM RUN_TO_HALTED
ENUM RUN_TO_USER_CONDITION
ENUM RUN_TO_AUTOLOADTAPE
ENUM RUN_TO_TAPE_STARTS, RUN_TO_TAPE_STOPS
ENUM RUN_TO_DISK_MOTOR_ON, RUN_TO_DISK_MOTOR_OFF
ENUM RUN_TO_OPCODE
; values for task queue commands
RESETENUM 0
ENUM TASK_WAIT_SECONDS, TASK_WAIT_FRAMES
ENUM TASK_EXIT
ENUM TASK_DUMP
ENUM TASK_DEBUG
ENUM TASK_SAVESNAP
ENUM TASK_TRACE, TASK_STOP_TRACE
ENUM TASK_RUNTO_STOP_CMD
; some task queue commands, when run, can initialise and then change the task code to a second execution stage task code
ENUM TASK_WAIT_SECONDS_2, TASK_WAIT_FRAMES_2
; expected argument type per task queue command
TASKARG_NONE equ 0
TASKARG_NUMERIC equ 1
TASKARG_STRING equ 2