~ubuntu-branches/ubuntu/quantal/vice/quantal

« back to all changes in this revision

Viewing changes to src/pet/pet-snapshot.c

  • Committer: Bazaar Package Importer
  • Author(s): Zed Pobre
  • Date: 2005-03-27 13:06:04 UTC
  • mfrom: (4 hoary)
  • mto: This revision was merged to the branch mainline in revision 5.
  • Revision ID: james.westby@ubuntu.com-20050327130604-zodmv0i60dbbmcik
Tags: 1.16-3
Apply patch from Andreas Jochens <aj@andaco.de> to correct building on
AMD64 and GCC 4.x (closes: #300936)

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
 * Written by
5
5
 *  Ettore Perazzoli <ettore@comm2000.it>
6
6
 *  Andr� Fachat <fachat@physik.tu-chemnitz.de>
7
 
 *  Andreas Boose <boose@linux.rz.fh-hannover.de>
 
7
 *  Andreas Boose <viceteam@t-online.de>
8
8
 *
9
9
 * This file is part of VICE, the Versatile Commodore Emulator.
10
10
 * See README for copyright notice.
26
26
 *
27
27
 */
28
28
 
29
 
/*
30
 
 * FIXME: the rom_*_loaded flag stuff is not clear enough.
31
 
 *
32
 
 */
33
 
 
34
29
#include "vice.h"
35
30
 
36
31
#include <stdio.h>
37
32
 
38
 
#include "autostart.h"
39
 
#include "kbdbuf.h"
 
33
#include "crtc.h"
 
34
#include "drive-snapshot.h"
 
35
#include "event.h"
 
36
#include "ioutil.h"
 
37
#include "joystick.h"
 
38
#include "keyboard.h"
40
39
#include "log.h"
41
 
#include "mem.h"
 
40
#include "machine.h"
 
41
#include "maincpu.h"
 
42
#include "pet-snapshot.h"
42
43
#include "pet.h"
43
 
#include "petmem.h"
 
44
#include "petacia.h"
 
45
#include "petmemsnapshot.h"
 
46
#include "petpia.h"
44
47
#include "pets.h"
45
 
#include "resources.h"
46
48
#include "snapshot.h"
47
 
#include "tape.h"
 
49
#include "sound.h"
 
50
#include "tape-snapshot.h"
48
51
#include "types.h"
49
 
 
50
 
 
51
 
static log_t pet_snapshot_log = LOG_ERR;
52
 
 
53
 
/*
54
 
 * PET memory dump should be 4-32k or 128k, depending on the config, as RAM.
55
 
 * Plus 64k expansion RAM (8096 or SuperPET) if necessary. Also there
56
 
 * is the 1/2k video RAM as "VRAM".
57
 
 * In this prototype we save the full ram......
58
 
 */
59
 
 
60
 
static const char module_ram_name[] = "PETMEM";
61
 
#define PETMEM_DUMP_VER_MAJOR   1
62
 
#define PETMEM_DUMP_VER_MINOR   2
63
 
 
64
 
/*
65
 
 * UBYTE        CONFIG          Bits 0-3: 0 = 40 col PET without CRTC
66
 
 *                                        1 = 40 col PET with CRTC
67
 
 *                                        2 = 80 col PET (with CRTC)
68
 
 *                                        3 = SuperPET
69
 
 *                                        4 = 8096
70
 
 *                                        5 = 8296
71
 
 *                              Bit 6: 1= RAM at $9***
72
 
 *                              Bit 7: 1= RAM at $A***
73
 
 *
74
 
 * UBYTE        KEYBOARD        0 = UK business
75
 
 *                              1 = graphics
76
 
 *
77
 
 * UBYTE        MEMSIZE         memory size of low 32k in k (4,8,16,32)
78
 
 *
79
 
 * UBYTE        CONF8X96        8x96 configuration register
80
 
 * UBYTE        SUPERPET        SuperPET config:
81
 
 *                              Bit 0: spet_ramen,  1= RAM enabled
82
 
 *                                  1: spet_ramwp,  1= RAM write protected
83
 
 *                                  2: spet_ctrlwp, 1= CTRL reg write prot.
84
 
 *                                  3: spet_diag,   0= diag active
85
 
 *                                  4-7: spet_bank, RAM block in use
86
 
 *
87
 
 * ARRAY        RAM             4-32k RAM (not 8296, dep. on MEMSIZE)
88
 
 * ARRAY        VRAM            2/4k RAM (not 8296, dep in CONFIG)
89
 
 * ARRAY        EXTRAM          64k (SuperPET and 8096 only)
90
 
 * ARRAY        RAM             128k RAM (8296 only)
91
 
 *
92
 
 *                              Added in format V1.1, should be part of
93
 
 *                              KEYBOARD in later versions.
94
 
 *
95
 
 * BYTE         POSITIONAL      bit 0=0 = symbolic keyboard mapping
96
 
 *                                   =1 = positional keyboard mapping
97
 
 *
98
 
 *                              Added in format V1.2
99
 
 * BYTE         EOIBLANK        bit 0=0: EOI does not blank screen
100
 
 *                                   =1: EOI does blank screen
101
 
 */
102
 
 
103
 
static int mem_write_ram_snapshot_module(snapshot_t *p)
104
 
{
105
 
    snapshot_module_t *m;
106
 
    BYTE config, rconf, memsize, conf8x96, superpet;
107
 
    int kbdindex;
108
 
 
109
 
    memsize = petres.ramSize;
110
 
    if (memsize > 32) {
111
 
        memsize = 32;
112
 
    }
113
 
 
114
 
    if (!petres.crtc) {
115
 
        config = 0;
116
 
    } else {
117
 
        config = petres.videoSize == 0x400 ? 1 : 2;
118
 
    }
119
 
 
120
 
    if (petres.map) {
121
 
        config = petres.map + 3;
122
 
    } else {
123
 
    if (petres.superpet)
124
 
        config = 3;
125
 
    }
126
 
 
127
 
    rconf = (petres.mem9 ? 0x40 : 0)
128
 
                | (petres.memA ? 0x80 : 0) ;
129
 
 
130
 
    conf8x96 = map_reg;
131
 
 
132
 
    superpet = (spet_ramen ? 1 : 0)
133
 
                | (spet_ramwp ? 2 : 0)
134
 
                | (spet_ctrlwp ? 4 : 0)
135
 
                | (spet_diag ? 8 : 0)
136
 
                | ((spet_bank << 4) & 0xf0) ;
137
 
 
138
 
    m = snapshot_module_create(p, module_ram_name,
139
 
                               PETMEM_DUMP_VER_MAJOR, PETMEM_DUMP_VER_MINOR);
140
 
    if (m == NULL)
141
 
        return -1;
142
 
    snapshot_module_write_byte(m, (BYTE)(config | rconf));
143
 
 
144
 
    resources_get_value("KeymapIndex", (resource_value_t*) &kbdindex);
145
 
    snapshot_module_write_byte(m, (BYTE)(kbdindex >> 1));
146
 
 
147
 
    snapshot_module_write_byte(m, memsize);
148
 
    snapshot_module_write_byte(m, conf8x96);
149
 
    snapshot_module_write_byte(m, superpet);
150
 
 
151
 
    if (config != 5) {
152
 
        snapshot_module_write_byte_array(m, ram, memsize << 10);
153
 
 
154
 
        snapshot_module_write_byte_array(m, ram + 0x8000,
155
 
                                         (config < 2) ? 0x400 : 0x800);
156
 
 
157
 
        if (config == 3 || config == 4) {
158
 
            snapshot_module_write_byte_array(m, ram + 0x10000, 0x10000);
159
 
        }
160
 
    } else {    /* 8296 */
161
 
        snapshot_module_write_byte_array(m, ram, 0x20000);
162
 
    }
163
 
 
164
 
    snapshot_module_write_byte(m, (BYTE)(kbdindex & 1));
165
 
    snapshot_module_write_byte(m, (BYTE)(petres.eoiblank ? 1 : 0));
166
 
 
167
 
    snapshot_module_close(m);
168
 
 
169
 
    return 0;
170
 
}
171
 
 
172
 
static int mem_read_ram_snapshot_module(snapshot_t *p)
173
 
{
174
 
    BYTE vmajor, vminor;
175
 
    snapshot_module_t *m;
176
 
    BYTE config, rconf, byte, memsize, conf8x96, superpet;
177
 
    petinfo_t peti = { 32, 0x0800, 1, 80, 0, 0, 0, 0, 0, 0, 0,
178
 
                       NULL, NULL, NULL, NULL, NULL, NULL };
179
 
 
180
 
    m = snapshot_module_open(p, module_ram_name, &vmajor, &vminor);
181
 
    if (m == NULL)
182
 
        return -1;
183
 
 
184
 
    if (vmajor != PETMEM_DUMP_VER_MAJOR) {
185
 
        log_error(pet_snapshot_log,
186
 
                  "Cannot load PET RAM module with major version %d",
187
 
                  vmajor);
188
 
        snapshot_module_close(m);
189
 
        return -1;
190
 
    }
191
 
 
192
 
    snapshot_module_read_byte(m, &config);
193
 
 
194
 
    snapshot_module_read_byte(m, &byte);
195
 
    peti.kbd_type = byte;
196
 
 
197
 
    snapshot_module_read_byte(m, &memsize);
198
 
    snapshot_module_read_byte(m, &conf8x96);
199
 
    snapshot_module_read_byte(m, &superpet);
200
 
 
201
 
    rconf = config & 0xc0;
202
 
    config &= 0x0f;
203
 
 
204
 
    peti.ramSize = memsize;
205
 
    peti.crtc = 1;
206
 
    peti.IOSize = 0x800;
207
 
    peti.video = 80;
208
 
    peti.superpet = 0;
209
 
 
210
 
    switch (config) {
211
 
      case 0:           /* 40 cols w/o CRTC */
212
 
        peti.crtc = 0;
213
 
        peti.video = 40;
214
 
        break;
215
 
      case 1:           /* 40 cols w/ CRTC */
216
 
        peti.video = 40;
217
 
        break;
218
 
      case 2:           /* 80 cols (w/ CRTC) */
219
 
        break;
220
 
      case 3:           /* SuperPET */
221
 
        spet_ramen = superpet & 1;
222
 
        spet_ramwp = superpet & 2;
223
 
        spet_ctrlwp= superpet & 4;
224
 
        spet_diag  = superpet & 8;
225
 
        spet_bank  = (superpet >> 4) & 0x0f;
226
 
        peti.superpet = 1;
227
 
        break;
228
 
      case 4:           /* 8096 */
229
 
        peti.ramSize = 96;
230
 
        break;
231
 
      case 5:           /* 8296 */
232
 
        peti.ramSize = 128;
233
 
        break;
234
 
    };
235
 
 
236
 
    peti.mem9 = (rconf & 0x40) ? 1 : 0;
237
 
    peti.memA = (rconf & 0x80) ? 1 : 0;
238
 
 
239
 
    pet_set_conf_info(&peti);  /* set resources and config accordingly */
240
 
    map_reg = conf8x96;
241
 
 
242
 
    mem_initialize_memory();
243
 
 
244
 
    pet_crtc_set_screen();
245
 
 
246
 
    if (config != 5) {
247
 
        snapshot_module_read_byte_array(m, ram, memsize << 10);
248
 
 
249
 
        snapshot_module_read_byte_array(m, ram + 0x8000,
250
 
                                        (config < 2) ? 0x400 : 0x800);
251
 
 
252
 
        if (config == 3 || config == 4) {
253
 
            snapshot_module_read_byte_array(m, ram + 0x10000, 0x10000);
254
 
        }
255
 
    } else {    /* 8296 */
256
 
        snapshot_module_read_byte_array(m, ram, 0x20000);
257
 
    }
258
 
 
259
 
    if (vminor > 0) {
260
 
        int kindex;
261
 
        snapshot_module_read_byte(m, &byte);
262
 
        resources_get_value("KeymapIndex",
263
 
                            (resource_value_t *)&kindex);
264
 
        resources_set_value("KeymapIndex",
265
 
                            (resource_value_t)((kindex & ~1) | (byte & 1)));
266
 
    }
267
 
    if (vminor > 1) {
268
 
        snapshot_module_read_byte(m, &byte);
269
 
        resources_set_value("EoiBlank",
270
 
                            (resource_value_t)(byte & 1));
271
 
    }
272
 
 
273
 
    snapshot_module_close(m);
274
 
 
275
 
    return 0;
276
 
}
277
 
 
278
 
static const char module_rom_name[] = "PETROM";
279
 
#define PETROM_DUMP_VER_MAJOR   1
280
 
#define PETROM_DUMP_VER_MINOR   0
281
 
 
282
 
/*
283
 
 * UBYTE        CONFIG          Bit 0: 1= $9*** ROM included
284
 
 *                                  1: 1= $a*** ROM included
285
 
 *                                  2: 1= $b*** ROM included
286
 
 *                                  3: 1= $e900-$efff ROM included
287
 
 *
288
 
 * ARRAY        KERNAL          4k KERNAL ROM image $f000-$ffff
289
 
 * ARRAY        EDITOR          2k EDITOR ROM image $e000-$e800
290
 
 * ARRAY        CHARGEN         2k CHARGEN ROM image
291
 
 * ARRAY        ROM9            4k $9*** ROM (if CONFIG & 1)
292
 
 * ARRAY        ROMA            4k $A*** ROM (if CONFIG & 2)
293
 
 * ARRAY        ROMB            4k $B*** ROM (if CONFIG & 4)
294
 
 * ARRAY        ROMC            4k $C*** ROM
295
 
 * ARRAY        ROMD            4k $D*** ROM
296
 
 * ARRAY        ROME9           7 blocks $e900-$efff ROM (if CONFIG & 8)
297
 
 *
298
 
 */
299
 
 
300
 
static int mem_write_rom_snapshot_module(snapshot_t *p, int save_roms)
301
 
{
302
 
    snapshot_module_t *m;
303
 
    BYTE config;
304
 
    int i, trapfl;
305
 
 
306
 
    if (!save_roms)
307
 
        return 0;
308
 
 
309
 
    m = snapshot_module_create(p, module_rom_name,
310
 
                               PETROM_DUMP_VER_MAJOR, PETROM_DUMP_VER_MINOR);
311
 
    if (m == NULL)
312
 
        return -1;
313
 
 
314
 
    /* disable traps before saving the ROM */
315
 
    resources_get_value("VirtualDevices", (resource_value_t*) &trapfl);
316
 
    resources_set_value("VirtualDevices", (resource_value_t) 1);
317
 
    petmem_unpatch_2001();
318
 
 
319
 
    config = (rom_9_loaded ? 1 : 0)
320
 
             | (rom_A_loaded ? 2 : 0)
321
 
             | (rom_B_loaded ? 4 : 0)
322
 
             | ((petres.ramSize == 128) ? 8 : 0);
323
 
 
324
 
    snapshot_module_write_byte(m, config);
325
 
 
326
 
    {
327
 
        snapshot_module_write_byte_array(m, rom + 0x7000, 0x1000);
328
 
        snapshot_module_write_byte_array(m, rom + 0x6000, 0x0800);
329
 
 
330
 
        /* pick relevant data from chargen ROM */
331
 
        for (i = 0; i < 128; i++) {
332
 
            snapshot_module_write_byte_array(m, chargen_rom + i * 16, 8);
333
 
        }
334
 
        for (i = 0; i < 128; i++) {
335
 
            snapshot_module_write_byte_array(m, chargen_rom + 0x1000 + i * 16,
336
 
                                             8);
337
 
        }
338
 
 
339
 
        if (config & 1) {
340
 
            snapshot_module_write_byte_array(m, rom + 0x1000, 0x1000);
341
 
        }
342
 
        if (config & 2) {
343
 
            snapshot_module_write_byte_array(m, rom + 0x2000, 0x1000);
344
 
        }
345
 
        if (config & 4) {
346
 
            snapshot_module_write_byte_array(m, rom + 0x3000, 0x1000);
347
 
        }
348
 
 
349
 
        snapshot_module_write_byte_array(m, rom + 0x4000, 0x2000);
350
 
 
351
 
        if (config & 8) {
352
 
           snapshot_module_write_byte_array(m, rom + 0x6900, 0x0700);
353
 
        }
354
 
    }
355
 
 
356
 
    /* enable traps again when necessary */
357
 
    resources_set_value("VirtualDevices", (resource_value_t) trapfl);
358
 
    petmem_patch_2001();
359
 
 
360
 
    snapshot_module_close(m);
361
 
 
362
 
    return 0;
363
 
}
364
 
 
365
 
static int mem_read_rom_snapshot_module(snapshot_t *p)
366
 
{
367
 
    BYTE vmajor, vminor;
368
 
    snapshot_module_t *m;
369
 
    BYTE config;
370
 
    int trapfl, new_iosize;
371
 
 
372
 
    m = snapshot_module_open(p, module_rom_name, &vmajor, &vminor);
373
 
    if (m == NULL)
374
 
        return 0;       /* optional */
375
 
 
376
 
    if (vmajor != PETROM_DUMP_VER_MAJOR) {
377
 
        log_error(pet_snapshot_log,
378
 
                "Cannot load PET ROM module with major version %d",
379
 
                vmajor);
380
 
        snapshot_module_close(m);
381
 
        return -1;
382
 
    }
383
 
 
384
 
    /* disable traps before loading the ROM */
385
 
    resources_get_value("VirtualDevices", (resource_value_t*)&trapfl);
386
 
    resources_set_value("VirtualDevices", (resource_value_t)1);
387
 
    petmem_unpatch_2001();
388
 
 
389
 
    config = (rom_9_loaded ? 1 : 0)
390
 
             | (rom_A_loaded ? 2 : 0)
391
 
             | (rom_B_loaded ? 4 : 0)
392
 
             | ((petres.pet2k || petres.ramSize == 128) ? 8 : 0);
393
 
 
394
 
    snapshot_module_read_byte(m, &config);
395
 
 
396
 
    /* De-initialize kbd-buf, autostart and tape stuff here before
397
 
       loading the new ROMs. These depend on addresses defined in the
398
 
       rom - they might be different in the loaded ROM. */
399
 
    kbd_buf_init(0, 0, 0, 0);
400
 
    autostart_init(0, 0, 0, 0, 0, 0);
401
 
    tape_deinstall();
402
 
 
403
 
    rom_9_loaded = config & 1;
404
 
    rom_A_loaded = config & 2;
405
 
    rom_B_loaded = config & 4;
406
 
 
407
 
    if (config & 8) {
408
 
        new_iosize = 0x100;
409
 
    } else {
410
 
        new_iosize = 0x800;
411
 
    }
412
 
    if (new_iosize != petres.IOSize) {
413
 
        petres.IOSize = new_iosize;
414
 
        mem_initialize_memory();
415
 
    }
416
 
 
417
 
    {
418
 
        /* kernal $f000-$ffff */
419
 
        snapshot_module_read_byte_array(m, rom + 0x7000, 0x1000);
420
 
        /* editor $e000-$e7ff */
421
 
        snapshot_module_read_byte_array(m, rom + 0x6000, 0x0800);
422
 
 
423
 
        /* chargen ROM */
424
 
        resources_set_value("Basic1Chars", (resource_value_t) 0);
425
 
        snapshot_module_read_byte_array(m, chargen_rom, 0x0800);
426
 
        petmem_convert_chargen(chargen_rom);
427
 
 
428
 
        /* $9000-$9fff */
429
 
        if (config & 1) {
430
 
            snapshot_module_read_byte_array(m, rom + 0x1000, 0x1000);
431
 
        }
432
 
        /* $a000-$afff */
433
 
        if (config & 2) {
434
 
            snapshot_module_read_byte_array(m, rom + 0x2000, 0x1000);
435
 
        }
436
 
        /* $b000-$bfff */
437
 
        if (config & 4) {
438
 
            snapshot_module_read_byte_array(m, rom + 0x3000, 0x1000);
439
 
        }
440
 
 
441
 
        /* $c000-$dfff */
442
 
        snapshot_module_read_byte_array(m, rom + 0x4000, 0x2000);
443
 
 
444
 
        /* $e900-$efff editor extension */
445
 
        if (config & 8) {
446
 
            snapshot_module_read_byte_array(m, rom + 0x6900, 0x0700);
447
 
        }
448
 
    }
449
 
 
450
 
    log_warning(pet_snapshot_log,"Dumped Romset files and saved settings will "
451
 
                "represent\nthe state before loading the snapshot!");
452
 
 
453
 
    petres.rompatch = 0;
454
 
 
455
 
    petmem_get_kernal_checksum();
456
 
    petmem_get_editor_checksum();
457
 
    petmem_checksum();
458
 
 
459
 
    petmem_patch_2001();
460
 
 
461
 
    /* enable traps again when necessary */
462
 
    resources_set_value("VirtualDevices", (resource_value_t) trapfl);
463
 
 
464
 
    snapshot_module_close(m);
465
 
 
466
 
    return 0;
467
 
}
468
 
 
469
 
int pet_snapshot_write_module(snapshot_t *m, int save_roms) {
470
 
    if (mem_write_ram_snapshot_module(m) < 0
471
 
        || mem_write_rom_snapshot_module(m, save_roms) < 0 )
472
 
        return -1;
473
 
    return 0;
474
 
}
475
 
 
476
 
int pet_snapshot_read_module(snapshot_t *m) {
477
 
    if (mem_read_ram_snapshot_module(m) < 0
478
 
        || mem_read_rom_snapshot_module(m) < 0 )
479
 
        return -1;
480
 
    return 0;
 
52
#include "via.h"
 
53
 
 
54
 
 
55
#define SNAP_MAJOR 0
 
56
#define SNAP_MINOR 0
 
57
 
 
58
 
 
59
int pet_snapshot_write(const char *name, int save_roms, int save_disks,
 
60
                       int event_mode)
 
61
{
 
62
    snapshot_t *s;
 
63
    int ef = 0;
 
64
 
 
65
    s = snapshot_create(name, SNAP_MAJOR, SNAP_MINOR, machine_name);
 
66
 
 
67
    if (s == NULL)
 
68
        return -1;
 
69
 
 
70
    sound_snapshot_prepare();
 
71
 
 
72
    if (maincpu_snapshot_write_module(s) < 0
 
73
        || pet_snapshot_write_module(s, save_roms) < 0
 
74
        || crtc_snapshot_write_module(s) < 0
 
75
        || pia1_snapshot_write_module(s) < 0
 
76
        || pia2_snapshot_write_module(s) < 0
 
77
        || viacore_snapshot_write_module(machine_context.via, s) < 0
 
78
        || drive_snapshot_write_module(s, save_disks, save_roms) < 0
 
79
        || event_snapshot_write_module(s, event_mode) < 0
 
80
        || tape_snapshot_write_module(s, save_disks) < 0
 
81
        || keyboard_snapshot_write_module(s)
 
82
        || joystick_snapshot_write_module(s)) {
 
83
        ef = -1;
 
84
    }
 
85
 
 
86
    if ((!ef) && petres.superpet)
 
87
        ef = acia1_snapshot_write_module(s);
 
88
 
 
89
    snapshot_close(s);
 
90
 
 
91
    if (ef)
 
92
        ioutil_remove(name);
 
93
 
 
94
    return ef;
 
95
}
 
96
 
 
97
int pet_snapshot_read(const char *name, int event_mode)
 
98
{
 
99
    snapshot_t *s;
 
100
    BYTE minor, major;
 
101
    int ef = 0;
 
102
 
 
103
    s = snapshot_open(name, &major, &minor, machine_name);
 
104
 
 
105
    if (s == NULL)
 
106
        return -1;
 
107
 
 
108
    if (major != SNAP_MAJOR || minor != SNAP_MINOR) {
 
109
        log_error(LOG_DEFAULT,
 
110
                  "Snapshot version (%d.%d) not valid: expecting %d.%d.",
 
111
                  major, minor, SNAP_MAJOR, SNAP_MINOR);
 
112
        ef = -1;
 
113
    }
 
114
 
 
115
    if (ef
 
116
        || maincpu_snapshot_read_module(s) < 0
 
117
        || pet_snapshot_read_module(s) < 0
 
118
        || crtc_snapshot_read_module(s) < 0
 
119
        || pia1_snapshot_read_module(s) < 0
 
120
        || pia2_snapshot_read_module(s) < 0
 
121
        || viacore_snapshot_read_module(machine_context.via, s) < 0
 
122
        || drive_snapshot_read_module(s) < 0
 
123
        || event_snapshot_read_module(s, event_mode) < 0
 
124
        || tape_snapshot_read_module(s) < 0
 
125
        || keyboard_snapshot_read_module(s) < 0
 
126
        || joystick_snapshot_read_module(s) < 0) {
 
127
        ef = -1;
 
128
    }
 
129
 
 
130
    if (!ef) {
 
131
        acia1_snapshot_read_module(s);  /* optional, so no error check */
 
132
    }
 
133
 
 
134
    snapshot_close(s);
 
135
 
 
136
    if (ef) {
 
137
        machine_trigger_reset(MACHINE_RESET_MODE_SOFT);
 
138
    }
 
139
 
 
140
    sound_snapshot_finish();
 
141
 
 
142
    return ef;
481
143
}
482
144