5
* Tibor Biczo <crown@mail.matav.hu>
6
* Andreas Boose <viceteam@t-online.de>
8
* This file is part of VICE, the Versatile Commodore Emulator.
9
* See README for copyright notice.
11
* This program is free software; you can redistribute it and/or modify
12
* it under the terms of the GNU General Public License as published by
13
* the Free Software Foundation; either version 2 of the License, or
14
* (at your option) any later version.
16
* This program is distributed in the hope that it will be useful,
17
* but WITHOUT ANY WARRANTY; without even the implied warranty of
18
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
* GNU General Public License for more details.
21
* You should have received a copy of the GNU General Public License
22
* along with this program; if not, write to the Free Software
23
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
35
#include "interrupt.h"
40
#include "uiquicksnapshot.h"
50
static snapfiles files[10];
52
static int snapcounter;
55
static void scan_files(void)
57
WIN32_FIND_DATA file_info;
63
dirname = util_concat(archdep_boot_path(), "\\", machine_name,
64
"\\quicksnap?.vsf", NULL);
65
st_dirname = system_mbstowcs_alloc(dirname);
66
search_handle = FindFirstFile(st_dirname, &file_info);
67
system_mbstowcs_free(st_dirname);
70
for (i = 0; i < 10; i++) {
73
if (search_handle != INVALID_HANDLE_VALUE) {
76
c = file_info.cFileName[_tcslen(file_info.cFileName) - 5];
77
if ((c >= '0') && (c <= '9')) {
78
strcpy(files[c - '0'].name, file_info.cFileName);
79
files[c - '0'].valid = 1;
80
if ((c - '0') > lastindex) {
85
} while (FindNextFile(search_handle, &file_info));
86
FindClose(search_handle);
91
static void save_quicksnapshot_trap(WORD unused_addr, void *unused_data)
94
char *fullname, *fullname2;
95
TCHAR *st_fullname, *st_fullname2;
97
if (lastindex == -1) {
99
strcpy(files[lastindex].name, "quicksnap0.vsf");
101
if (lastindex == 9) {
102
if (snapcounter == 10) {
103
fullname = util_concat(archdep_boot_path(), "\\", machine_name,
104
"\\", files[0].name, NULL);
105
st_fullname = system_mbstowcs_alloc(fullname);
106
DeleteFile(st_fullname);
107
system_mbstowcs_free(st_fullname);
109
for (i = 1; i < 10; i++) {
110
fullname = util_concat(archdep_boot_path(), "\\",
112
"\\", files[i].name, NULL);
113
fullname2 = util_concat(archdep_boot_path(), "\\",
115
"\\", files[i-1].name, NULL);
116
st_fullname = system_mbstowcs_alloc(fullname);
117
st_fullname2 = system_mbstowcs_alloc(fullname2);
118
MoveFile(st_fullname, st_fullname2);
119
system_mbstowcs_free(st_fullname);
120
system_mbstowcs_free(st_fullname2);
125
for (i = 0; i < 10; i++) {
126
if (files[i].valid == 0) break;
128
for (j = i + 1; j < 10; j++) {
129
if (files[j].valid) {
130
strcpy(files[i].name,files[j].name);
131
files[i].name[strlen(files[i].name) - 5] = '0' + i;
132
fullname = util_concat(archdep_boot_path(), "\\",
134
files[j].name, NULL);
135
fullname2 = util_concat(archdep_boot_path(), "\\",
137
files[i].name, NULL);
138
st_fullname = system_mbstowcs_alloc(fullname);
139
st_fullname2 = system_mbstowcs_alloc(fullname2);
140
MoveFile(st_fullname, st_fullname2);
141
system_mbstowcs_free(st_fullname);
142
system_mbstowcs_free(st_fullname2);
148
strcpy(files[i].name,files[0].name);
149
files[i].name[strlen(files[i].name) - 5]= '0' + i;
153
strcpy(files[lastindex + 1].name,files[lastindex].name);
155
files[lastindex].name[strlen(files[lastindex].name) - 5]
160
fullname = util_concat(archdep_boot_path(), "\\", machine_name, "\\",
161
files[lastindex].name, NULL);
162
if (machine_write_snapshot(fullname, 0, 0, 0) < 0) {
163
ui_error("Can't write snapshot file.");
168
static void load_quicksnapshot_trap(WORD unused_addr, void *unused_data)
172
fullname = util_concat(archdep_boot_path(), "\\", machine_name, "\\",
173
files[lastindex].name, NULL);
174
if (machine_read_snapshot(fullname, 0) < 0) {
175
ui_error("Cannot read snapshot image");
180
void ui_quicksnapshot_load(HWND hwnd)
183
if (snapcounter > 0) {
184
interrupt_maincpu_trigger_trap(load_quicksnapshot_trap, (void *)0);
188
void ui_quicksnapshot_save(HWND hwnd)
191
interrupt_maincpu_trigger_trap(save_quicksnapshot_trap, (void *)0);