~ubuntu-branches/ubuntu/utopic/vice/utopic-proposed

« back to all changes in this revision

Viewing changes to src/c64dtv/c64dtvflash.c

  • Committer: Package Import Robot
  • Author(s): Logan Rosen
  • Date: 2014-05-10 21:08:23 UTC
  • mfrom: (17.1.1 sid)
  • Revision ID: package-import@ubuntu.com-20140510210823-v5aojvy1pv1sg132
Tags: 2.4.dfsg+2.4.6-1ubuntu1
Use autotools-dev to update config.{sub,guess} for new arches.

Show diffs side-by-side

added added

removed removed

Lines of Context:
57
57
BYTE c64dtvflash_mem[C64_ROM_SIZE];
58
58
 
59
59
/* (Flash)ROM state */
60
 
enum { 
 
60
enum {
61
61
    FLASH_IDLE=0,
62
62
    FLASH_CMD1, FLASH_CMD2, FLASH_CMD3, FLASH_CMD4, FLASH_CMD5,
63
63
    FLASH_PRODUCTID,
75
75
 
76
76
static int paddr_to_sector(int paddr)
77
77
{
78
 
    if ((paddr>>16)==0x1f) {
79
 
        return (((paddr>>13)&7)+31);
 
78
    if ((paddr >> 16) == 0x1f) {
 
79
        return (((paddr >> 13) & 7) + 31);
80
80
    } else {
81
 
        return (paddr>>16);
 
81
        return (paddr >> 16);
82
82
    }
83
83
}
84
84
 
94
94
 
95
95
void c64dtvflash_store(int addr, BYTE value)
96
96
{
97
 
    int i,j,k;
98
 
    if (flash_log_enabled) log_message(c64dtvflash_log, "flash_store: addr %x, value %x, mode %i\n",addr,value,c64dtvflash_state);
99
 
    switch(c64dtvflash_state) {
 
97
    int i, j, k;
 
98
    if (flash_log_enabled) {
 
99
        log_message(c64dtvflash_log, "flash_store: addr %x, value %x, mode %i\n", addr, value, c64dtvflash_state);
 
100
    }
 
101
    switch (c64dtvflash_state) {
100
102
        case FLASH_IDLE:
101
 
            if (((addr&0xffe)==0xaaa)&&(value==0xaa)) c64dtvflash_state=FLASH_CMD1;
 
103
            if (((addr & 0xffe) == 0xaaa) && (value == 0xaa)) {
 
104
                c64dtvflash_state = FLASH_CMD1;
 
105
            }
102
106
            return;
103
107
        case FLASH_CMD1:
104
 
            if (((addr&0xffe)==0x554)&&(value==0x55))
105
 
                c64dtvflash_state=FLASH_CMD2;
106
 
            else
107
 
                c64dtvflash_state=FLASH_IDLE;
 
108
            if (((addr & 0xffe) == 0x554) && (value == 0x55)) {
 
109
                c64dtvflash_state = FLASH_CMD2;
 
110
            } else {
 
111
                c64dtvflash_state = FLASH_IDLE;
 
112
            }
108
113
            return;
109
114
        case FLASH_CMD2:
110
 
            if ((addr&0xffe)==0xaaa) {
111
 
                switch(value) {
112
 
                    case 0x90: c64dtvflash_state=FLASH_PRODUCTID; return; /* Product ID Entry */
113
 
                    case 0xf0: c64dtvflash_state=FLASH_IDLE; return; /* Product ID Exit */
114
 
                    case 0x80: c64dtvflash_state=FLASH_CMD3; return; /* Erase/Single Pulse Program/Lockdown */
115
 
                    case 0xa0: c64dtvflash_state=FLASH_PROGRAM; return; /* Byte/Word Program */
116
 
                    case 0xd0: c64dtvflash_state=FLASH_SETCONF; return; /* Set Configuration Register */
117
 
                    case 0xc0: c64dtvflash_state=FLASH_PROGPROT; return; /* Program/Lock Protection Register */
118
 
                    default: c64dtvflash_state=FLASH_IDLE; return;
 
115
            if ((addr & 0xffe) == 0xaaa) {
 
116
                switch (value) {
 
117
                    case 0x90: c64dtvflash_state = FLASH_PRODUCTID; return; /* Product ID Entry */
 
118
                    case 0xf0: c64dtvflash_state = FLASH_IDLE; return; /* Product ID Exit */
 
119
                    case 0x80: c64dtvflash_state = FLASH_CMD3; return; /* Erase/Single Pulse Program/Lockdown */
 
120
                    case 0xa0: c64dtvflash_state = FLASH_PROGRAM; return; /* Byte/Word Program */
 
121
                    case 0xd0: c64dtvflash_state = FLASH_SETCONF; return; /* Set Configuration Register */
 
122
                    case 0xc0: c64dtvflash_state = FLASH_PROGPROT; return; /* Program/Lock Protection Register */
 
123
                    default: c64dtvflash_state = FLASH_IDLE; return;
119
124
                }
120
 
            } else c64dtvflash_state=FLASH_IDLE;
 
125
            } else {
 
126
                c64dtvflash_state = FLASH_IDLE;
 
127
            }
121
128
            return;
122
129
        case FLASH_PRODUCTID: /* Product ID Mode */
123
 
            if (value==0xf0) c64dtvflash_state=FLASH_IDLE;        /* Product ID Exit */
 
130
            if (value == 0xf0) {
 
131
                c64dtvflash_state = FLASH_IDLE;                   /* Product ID Exit */
 
132
            }
124
133
            return;
125
134
        case FLASH_CMD3: /* Erase/Single Pulse Program/Lockdown */
126
 
            if (((addr&0xffe)==0xaaa)&&(value==0xaa))
127
 
                c64dtvflash_state=FLASH_CMD4;
128
 
            else
129
 
                c64dtvflash_state=FLASH_IDLE;
 
135
            if (((addr & 0xffe) == 0xaaa) && (value == 0xaa)) {
 
136
                c64dtvflash_state = FLASH_CMD4;
 
137
            } else {
 
138
                c64dtvflash_state = FLASH_IDLE;
 
139
            }
130
140
            return;
131
141
        case FLASH_CMD4: /* Erase/Single Pulse Program/Lockdown */
132
 
            if (((addr&0xffe)==0x554)&&(value==0x55))
133
 
                c64dtvflash_state=FLASH_CMD5;
134
 
            else
135
 
                c64dtvflash_state=FLASH_IDLE;
 
142
            if (((addr & 0xffe) == 0x554) && (value == 0x55)) {
 
143
                c64dtvflash_state = FLASH_CMD5;
 
144
            } else {
 
145
                c64dtvflash_state = FLASH_IDLE;
 
146
            }
136
147
            return;
137
148
        case FLASH_CMD5: /* Erase/Single Pulse Program/Lockdown */
138
 
            switch(value) {
 
149
            switch (value) {
139
150
                case 0x30: /* Sector Erase */
140
 
                    if ((addr>>16)==0x1f) {
141
 
                        j=(addr&0x1fe000);
142
 
                        k=j+0x2000;
 
151
                    if ((addr >> 16) == 0x1f) {
 
152
                        j = (addr & 0x1fe000);
 
153
                        k = j + 0x2000;
143
154
                    } else {
144
 
                        j=(addr&0x1f0000);
145
 
                        k=j+0x10000;
 
155
                        j = (addr & 0x1f0000);
 
156
                        k = j + 0x10000;
146
157
                    }
147
158
                    if (c64dtvflash_mem_lock[paddr_to_sector(addr)]) {
148
 
                    if (flash_log_enabled) log_message(c64dtvflash_log, "flash: ignoring erase (locked) %06x-%06x\n",j,k);
 
159
                        if (flash_log_enabled) {
 
160
                            log_message(c64dtvflash_log, "flash: ignoring erase (locked) %06x-%06x\n", j, k);
 
161
                        }
149
162
                    } else {
150
 
                        for (i=j;i<k;i++) c64dtvflash_mem[i]=0xff;
151
 
                        if (flash_log_enabled) log_message(c64dtvflash_log, "flash: erased %06x-%06x\n",j,k);
 
163
                        for (i = j; i < k; i++) {
 
164
                            c64dtvflash_mem[i] = 0xff;
 
165
                        }
 
166
                        if (flash_log_enabled) {
 
167
                            log_message(c64dtvflash_log, "flash: erased %06x-%06x\n", j, k);
 
168
                        }
152
169
                    }
153
170
                    break;
154
171
                case 0x10: /* Chip Erase */
155
 
                    for (i=0;i<0x200000;i++) {
156
 
                        if (!(c64dtvflash_mem_lock[paddr_to_sector(addr)])) c64dtvflash_mem[i]=0xff;
157
 
                    }
158
 
                    if (flash_log_enabled) log_message(c64dtvflash_log, "flash: chip erased\n");
 
172
                    for (i = 0; i < 0x200000; i++) {
 
173
                        if (!(c64dtvflash_mem_lock[paddr_to_sector(addr)])) {
 
174
                            c64dtvflash_mem[i] = 0xff;
 
175
                        }
 
176
                    }
 
177
                    if (flash_log_enabled) {
 
178
                        log_message(c64dtvflash_log, "flash: chip erased\n");
 
179
                    }
159
180
                    break;
160
181
                case 0x60: /* Sector Lockdown */
161
 
                    c64dtvflash_mem_lock[paddr_to_sector(addr)]=0xff;
162
 
                    if (flash_log_enabled) log_message(c64dtvflash_log, "flash: sector %i lockdown\n",paddr_to_sector(addr));
 
182
                    c64dtvflash_mem_lock[paddr_to_sector(addr)] = 0xff;
 
183
                    if (flash_log_enabled) {
 
184
                        log_message(c64dtvflash_log, "flash: sector %i lockdown\n", paddr_to_sector(addr));
 
185
                    }
163
186
                    break;
164
187
                case 0xa0: /* Single Pulse Program Mode */
165
 
                    c64dtvflash_state=FLASH_SPPROGRAM;
166
 
                    if (flash_log_enabled) log_message(c64dtvflash_log, "flash: entering single pulse program mode\n");
 
188
                    c64dtvflash_state = FLASH_SPPROGRAM;
 
189
                    if (flash_log_enabled) {
 
190
                        log_message(c64dtvflash_log, "flash: entering single pulse program mode\n");
 
191
                    }
167
192
                    return;
168
193
            }
169
 
            c64dtvflash_state=FLASH_IDLE;
 
194
            c64dtvflash_state = FLASH_IDLE;
170
195
            return;
171
196
        case FLASH_PROGRAM: /* Byte/Word Program */
172
197
            if (c64dtvflash_mem_lock[paddr_to_sector(addr)]) {
173
 
                if (flash_log_enabled) log_message(c64dtvflash_log, "flash: ignoring byte program (locked) %02x to %06x\n",value,addr);
 
198
                if (flash_log_enabled) {
 
199
                    log_message(c64dtvflash_log, "flash: ignoring byte program (locked) %02x to %06x\n", value, addr);
 
200
                }
174
201
            } else {
175
 
                c64dtvflash_mem[addr]&=value;
176
 
                if (flash_log_enabled) log_message(c64dtvflash_log, "flash: written %02x to %06x\n", c64dtvflash_mem[addr], addr); /* DEBUG */
 
202
                c64dtvflash_mem[addr] &= value;
 
203
                if (flash_log_enabled) {
 
204
                    log_message(c64dtvflash_log, "flash: written %02x to %06x\n", c64dtvflash_mem[addr], addr);                    /* DEBUG */
 
205
                }
177
206
            }
178
 
            c64dtvflash_state=FLASH_IDLE;
 
207
            c64dtvflash_state = FLASH_IDLE;
179
208
            return;
180
209
        case FLASH_SETCONF: /* Set Configuration Register */
181
 
            c64dtvflash_state=FLASH_IDLE;
182
 
            if (flash_log_enabled) log_message(c64dtvflash_log, "flash: set configuration register %02x (unimplemented)\n",value);
 
210
            c64dtvflash_state = FLASH_IDLE;
 
211
            if (flash_log_enabled) {
 
212
                log_message(c64dtvflash_log, "flash: set configuration register %02x (unimplemented)\n", value);
 
213
            }
183
214
            return;
184
215
        case FLASH_PROGPROT: /* Program/Lock Protection Register */
185
 
            if ((addr==0x100)&&((value&0xf)==0)) {
186
 
                if (flash_log_enabled) log_message(c64dtvflash_log, "flash: lock protection register (unimplemented)\n");
 
216
            if ((addr == 0x100) && ((value & 0xf) == 0)) {
 
217
                if (flash_log_enabled) {
 
218
                    log_message(c64dtvflash_log, "flash: lock protection register (unimplemented)\n");
 
219
                }
187
220
            } else {
188
 
                if (flash_log_enabled) log_message(c64dtvflash_log, "flash: program protection register %x = %02x (unimplemented)\n",addr,value);
 
221
                if (flash_log_enabled) {
 
222
                    log_message(c64dtvflash_log, "flash: program protection register %x = %02x (unimplemented)\n", addr, value);
 
223
                }
189
224
            }
190
 
            c64dtvflash_state=FLASH_IDLE;
 
225
            c64dtvflash_state = FLASH_IDLE;
191
226
            return;
192
227
        case FLASH_SPPROGRAM: /* Single Pulse Program Mode */
193
 
            if (!(c64dtvflash_mem_lock[paddr_to_sector(addr)])) c64dtvflash_mem[addr]&=value;
 
228
            if (!(c64dtvflash_mem_lock[paddr_to_sector(addr)])) {
 
229
                c64dtvflash_mem[addr] &= value;
 
230
            }
194
231
            return;
195
232
        default:
196
233
            log_message(c64dtvflash_log, "BUG: Unknown flash chip emulation state.");
200
237
BYTE c64dtvflash_read(int addr)
201
238
{
202
239
    if (c64dtvflash_state != FLASH_IDLE) {
203
 
        if (flash_log_enabled) log_message(c64dtvflash_log, "flash_read: addr %x, mode %i\n",addr,c64dtvflash_state);
 
240
        if (flash_log_enabled) {
 
241
            log_message(c64dtvflash_log, "flash_read: addr %x, mode %i\n", addr, c64dtvflash_state);
 
242
        }
204
243
    }
205
244
    if (c64dtvflash_state == FLASH_PRODUCTID) { /* Product ID Mode */
206
245
        switch (addr) {
207
246
            /* Product ID: AT4XBV16XT */
208
247
            case 0:
209
248
            case 1:
210
 
                return 0x1f; /* Manufacturer */
 
249
                return 0x1f; /* Manufacturer */
211
250
            case 2:
212
251
            case 3:
213
 
                return 0xc2; /* Device */
 
252
                return 0xc2; /* Device */
214
253
            case 6:
215
254
            case 7:
216
 
                return 0x08; /* Additional Device */
 
255
                return 0x08; /* Additional Device */
217
256
            case 0x100:
218
257
            case 0x101:
219
 
                return 0xfe; /* Protection Register Lock (unlocked) TODO: configurable */
 
258
                return 0xfe; /* Protection Register Lock (unlocked) TODO: configurable */
220
259
            /* Protection Register Block A (unique ID) */
221
 
            case 0x102: return 'x'; 
 
260
            case 0x102: return 'x';
222
261
            case 0x103: return '6';
223
262
            case 0x104: return '4';
224
263
            case 0x105: return 'd';
227
266
            case 0x108: return '-';
228
267
            case 0x109: return 0x10;
229
268
            /* Protection Register Block B TODO: configurable */
230
 
            case 0x10a: return 0xff; 
 
269
            case 0x10a: return 0xff;
231
270
            case 0x10b: return 0xff;
232
271
            case 0x10c: return 0xff;
233
272
            case 0x10d: return 0xff;
236
275
            case 0x110: return 0xff;
237
276
            case 0x111: return 0xff;
238
277
            default:
239
 
                if ((addr&((addr>>16)==0x1f?0x1fff:0xffff))==4)
 
278
                if ((addr & ((addr >> 16) == 0x1f ? 0x1fff : 0xffff)) == 4) {
240
279
                    return c64dtvflash_mem_lock[paddr_to_sector(addr)]; /* Sector Lockdown */
241
 
                else
 
280
                } else {
242
281
                    return 0xff;
243
 
            }
244
 
    } else return c64dtvflash_mem[addr];
 
282
                }
 
283
        }
 
284
    } else {
 
285
        return c64dtvflash_mem[addr];
 
286
    }
245
287
}
246
288
 
247
289
/* ------------------------------------------------------------------------- */
254
296
    FILE *fd;
255
297
    size_t r;
256
298
    int i, max = 0x20;
257
 
    
 
299
 
258
300
    if (util_check_null_string(filename)) {
259
301
        log_message(c64dtvflash_log, "No file name given for create_blank_image.");
260
302
        ui_error(translate_text(IDGS_NO_FILENAME));
261
303
        return;
262
304
    }
263
 
    
 
305
 
264
306
    if (util_check_filename_access(filename) < 0) {
265
307
        log_message(c64dtvflash_log, "Illegal filename in create_blank_image.");
266
308
        ui_error(translate_text(IDGS_ILLEGAL_FILENAME));
267
309
        return;
268
310
    }
269
 
    
 
311
 
270
312
    memset(buf, 0xff, (size_t)0x10000);
271
 
    
 
313
 
272
314
    if (copyroms) {
273
315
        memcpy(buf + 0xe000, c64dtvflash_mem + 0xe000, C64_KERNAL_ROM_SIZE);
274
316
        memcpy(buf + 0xa000, c64dtvflash_mem + 0xa000, C64_BASIC_ROM_SIZE);
276
318
        memcpy(buf + 0x9000, c64dtvflash_mem + 0x9000, C64_CHARGEN_ROM_SIZE);
277
319
        memcpy(buf + 0xd000, c64dtvflash_mem + 0xd000, C64_CHARGEN_ROM_SIZE);
278
320
    }
279
 
    
 
321
 
280
322
    fd = fopen(filename, MODE_WRITE);
281
323
 
282
324
    if (fd == NULL) {
293
335
            fclose(fd);
294
336
            return;
295
337
        }
296
 
        if ((i==1) && copyroms) memset(buf, 0xff, (size_t)0x10000);
 
338
        if ((i == 1) && copyroms) {
 
339
            memset(buf, 0xff, (size_t)0x10000);
 
340
        }
297
341
    }
298
 
    
 
342
 
299
343
    ui_message(translate_text(IDGS_DTV_ROM_CREATED));
300
344
 
301
345
    fclose(fd);
305
349
 
306
350
/* ------------------------------------------------------------------------- */
307
351
 
308
 
unsigned int c64dtvflash_rom_loaded=0;
 
352
unsigned int c64dtvflash_rom_loaded = 0;
309
353
 
310
354
static int c64dtvflash_load_rom(void)
311
355
{
312
 
  int retval=0;         /* need to change this when ui gets changed for error indication */
313
 
  if (flash_log_enabled) log_message(c64dtvflash_log, "loading ROM");
314
 
  if (!util_check_null_string(c64dtvflash_filename))
315
 
  {
316
 
    if ((retval = util_file_load(c64dtvflash_filename, c64dtvflash_mem, (size_t)0x200000, UTIL_FILE_LOAD_RAW)) < 0)
317
 
    {
318
 
      log_message(c64dtvflash_log, "Reading C64DTV ROM image %s failed.", c64dtvflash_filename);
319
 
      retval = -1;
 
356
    int retval = 0;     /* need to change this when ui gets changed for error indication */
 
357
    if (flash_log_enabled) {
 
358
        log_message(c64dtvflash_log, "loading ROM");
 
359
    }
 
360
    if (!util_check_null_string(c64dtvflash_filename)) {
 
361
        if ((retval = util_file_load(c64dtvflash_filename, c64dtvflash_mem, (size_t)0x200000, UTIL_FILE_LOAD_RAW)) < 0) {
 
362
            log_message(c64dtvflash_log, "Reading C64DTV ROM image %s failed.", c64dtvflash_filename);
 
363
            retval = -1;
 
364
        } else {
 
365
            log_message(c64dtvflash_log, "Read C64DTV ROM image %s.", c64dtvflash_filename);
 
366
        }
320
367
    } else {
321
 
      log_message(c64dtvflash_log, "Read C64DTV ROM image %s.", c64dtvflash_filename);
322
 
    }
323
 
  } else {
324
 
      log_message(c64dtvflash_log, "No C64DTV ROM image filename specified.");
325
 
      retval = -2;
326
 
  }
327
 
 
328
 
 
329
 
  /* copy ROMs to Flash ROM emulation if no image file specified */
330
 
  if (retval) {
331
 
    if (flash_log_enabled) log_message(c64dtvflash_log, "copy ROMs to Flash");
332
 
    memcpy(c64dtvflash_mem + 0xe000, c64memrom_kernal64_rom,
333
 
           C64_KERNAL_ROM_SIZE);
334
 
    memcpy(c64dtvflash_mem + 0xa000, c64memrom_basic64_rom,
335
 
           C64_BASIC_ROM_SIZE);
336
 
    memcpy(c64dtvflash_mem + 0x1000, mem_chargen_rom,
337
 
           C64_CHARGEN_ROM_SIZE);
338
 
    memcpy(c64dtvflash_mem + 0x9000, mem_chargen_rom,
339
 
           C64_CHARGEN_ROM_SIZE);
340
 
    memcpy(c64dtvflash_mem + 0xd000, mem_chargen_rom,
341
 
           C64_CHARGEN_ROM_SIZE);
342
 
  }
343
 
  c64dtvflash_rom_loaded = retval;
344
 
 
345
 
  return retval;
 
368
        log_message(c64dtvflash_log, "No C64DTV ROM image filename specified.");
 
369
        retval = -2;
 
370
    }
 
371
 
 
372
 
 
373
    /* copy ROMs to Flash ROM emulation if no image file specified */
 
374
    if (retval) {
 
375
        if (flash_log_enabled) {
 
376
            log_message(c64dtvflash_log, "copy ROMs to Flash");
 
377
        }
 
378
        memcpy(c64dtvflash_mem + 0xe000, c64memrom_kernal64_rom,
 
379
               C64_KERNAL_ROM_SIZE);
 
380
        memcpy(c64dtvflash_mem + 0xa000, c64memrom_basic64_rom,
 
381
               C64_BASIC_ROM_SIZE);
 
382
        memcpy(c64dtvflash_mem + 0x1000, mem_chargen_rom,
 
383
               C64_CHARGEN_ROM_SIZE);
 
384
        memcpy(c64dtvflash_mem + 0x9000, mem_chargen_rom,
 
385
               C64_CHARGEN_ROM_SIZE);
 
386
        memcpy(c64dtvflash_mem + 0xd000, mem_chargen_rom,
 
387
               C64_CHARGEN_ROM_SIZE);
 
388
    }
 
389
    c64dtvflash_rom_loaded = retval;
 
390
 
 
391
    return retval;
346
392
}
347
393
 
348
394
void c64dtvflash_init(void)
349
395
{
350
 
  if (c64dtvflash_log == LOG_ERR)
351
 
    c64dtvflash_log = log_open("C64DTVFLASH");
352
 
 
353
 
  c64dtvflash_load_rom();
354
 
 
355
 
  if (flash_log_enabled) log_message(c64dtvflash_log, "END init");
 
396
    if (c64dtvflash_log == LOG_ERR) {
 
397
        c64dtvflash_log = log_open("C64DTVFLASH");
 
398
    }
 
399
 
 
400
    c64dtvflash_load_rom();
 
401
 
 
402
    if (flash_log_enabled) {
 
403
        log_message(c64dtvflash_log, "END init");
 
404
    }
356
405
}
357
406
 
358
407
void c64dtvflash_shutdown(void)
359
408
{
360
 
  if (!util_check_null_string(c64dtvflash_filename))
361
 
  {
362
 
    if (c64dtvflash_mem_rw) {
363
 
        if (util_file_save(c64dtvflash_filename, c64dtvflash_mem, 0x200000) < 0)
364
 
          log_message(c64dtvflash_log, "Writing C64DTV ROM image %s failed.", c64dtvflash_filename);
365
 
        else
366
 
          log_message(c64dtvflash_log, "Wrote C64DTV ROM image %s.", c64dtvflash_filename);
367
 
    }
368
 
  }
369
 
  if (flash_log_enabled) log_message(c64dtvflash_log, "END shutdown");
370
 
  return;
 
409
    if (!util_check_null_string(c64dtvflash_filename)) {
 
410
        if (c64dtvflash_mem_rw) {
 
411
            if (util_file_save(c64dtvflash_filename, c64dtvflash_mem, 0x200000) < 0) {
 
412
                log_message(c64dtvflash_log, "Writing C64DTV ROM image %s failed.", c64dtvflash_filename);
 
413
            } else {
 
414
                log_message(c64dtvflash_log, "Wrote C64DTV ROM image %s.", c64dtvflash_filename);
 
415
            }
 
416
        }
 
417
    }
 
418
    if (flash_log_enabled) {
 
419
        log_message(c64dtvflash_log, "END shutdown");
 
420
    }
 
421
    return;
371
422
}
372
423
 
373
424
void c64dtvflash_reset(void)
374
425
{
375
 
  int i;
376
 
  c64dtvflash_state = FLASH_IDLE;
377
 
  for (i=0;i<39;i++) c64dtvflash_mem_lock[i] = 0;
 
426
    int i;
 
427
    c64dtvflash_state = FLASH_IDLE;
 
428
    for (i = 0; i < 39; i++) {
 
429
        c64dtvflash_mem_lock[i] = 0;
 
430
    }
378
431
}
379
432
 
380
433
/* ------------------------------------------------------------------------- */
388
441
#endif
389
442
 
390
443
    if (c64dtvflash_filename != NULL && name != NULL && strcmp(name, c64dtvflash_filename) == 0) {
391
 
       return 0;
 
444
        return 0;
392
445
    }
393
446
 
394
447
    if (c64dtvflash_mem_rw && c64dtvflash_filename != NULL && *c64dtvflash_filename != '\0') {
395
448
        if (util_file_save(c64dtvflash_filename, c64dtvflash_mem, 0x200000) < 0) {
396
 
          log_message(c64dtvflash_log, "Writing C64DTV ROM image %s failed.", c64dtvflash_filename);
 
449
            log_message(c64dtvflash_log, "Writing C64DTV ROM image %s failed.", c64dtvflash_filename);
397
450
        } else {
398
 
          log_message(c64dtvflash_log, "Wrote C64DTV ROM image %s.", c64dtvflash_filename);
 
451
            log_message(c64dtvflash_log, "Wrote C64DTV ROM image %s.", c64dtvflash_filename);
399
452
        }
400
453
    }
401
454
 
408
461
        }
409
462
    }
410
463
#endif
411
 
    
 
464
 
412
465
    util_string_set(&c64dtvflash_filename, name);
413
466
 
414
467
#ifndef AMIGA_SUPPORT
470
523
 
471
524
int c64dtvflash_resources_init(void)
472
525
{
473
 
    if (resources_register_string(resources_string) < 0)
 
526
    if (resources_register_string(resources_string) < 0) {
474
527
        return -1;
 
528
    }
475
529
 
476
530
    return resources_register_int(resources_int);
477
531
}
478
532
 
479
533
void c64dtvflash_resources_shutdown(void)
480
534
{
481
 
  lib_free(c64dtvflash_filename);
 
535
    lib_free(c64dtvflash_filename);
482
536
}
483
537
 
484
538
static const cmdline_option_t cmdline_options[] =
513
567
 
514
568
int c64dtvflash_cmdline_options_init(void)
515
569
{
516
 
  return cmdline_register_options(cmdline_options);
 
570
    return cmdline_register_options(cmdline_options);
517
571
}