~ubuntu-branches/ubuntu/maverick/vice/maverick

« back to all changes in this revision

Viewing changes to src/interrupt.c

  • Committer: Bazaar Package Importer
  • Author(s): Zed Pobre
  • Date: 2005-02-01 11:30:26 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20050201113026-3eyakzsmmheclvjg
Tags: 1.16-1
* New upstream version
* Fixes crash on 64-bit architectures (closes: #287640)
* x128 working again (closes: #286767)
* Works fine with /dev/dsp in use (not in the main changelog, but tested
  on my local machine as working).  Presumably, this also takes care of
  the issue with dsp being held.  I'm not sure if this is because I'm
  testing it on a 2.6 kernel now -- if you are still having problems
  with /dev/dsp, please reopen the bugs. (closes: #152952, #207942)
* Don't kill Makefile.in on clean

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
#include <stdlib.h>
33
33
#include <string.h>
34
34
 
 
35
#include "6510core.h"
35
36
#include "interrupt.h"
36
37
#include "lib.h"
37
38
#include "log.h"
 
39
#include "maincpu.h"
38
40
#include "snapshot.h"
39
41
#include "types.h"
40
42
 
68
70
 
69
71
    cs->num_last_stolen_cycles = 0;
70
72
    cs->last_stolen_cycles_clk = (CLOCK)0;
 
73
    cs->num_dma_per_opcode = 0;
71
74
    cs->global_pending_int = IK_NONE;
72
75
    cs->nmi_trap_func = NULL;
73
76
    cs->reset_trap_func = NULL;
83
86
    cs->pending_int[cs->num_ints - 1] = 0;
84
87
 
85
88
    cs->int_name = (char **)lib_realloc(cs->int_name, cs->num_ints
86
 
                                        * /*sizeof(*(cs->int_name))*/ 4);
 
89
                                        * sizeof(char *));
87
90
    cs->int_name[cs->num_ints - 1] = lib_stralloc(name);
88
91
 
89
92
    return cs->num_ints - 1;
236
239
    return cs->pending_int[int_num] & IK_NMI;
237
240
}
238
241
 
239
 
enum cpu_int get_int(interrupt_cpu_status_t *cs, int int_num)
 
242
void interrupt_fixup_int_clk(interrupt_cpu_status_t *cs, CLOCK cpu_clk,
 
243
                             CLOCK *int_clk)
240
244
{
241
 
    return cs->pending_int[int_num];
 
245
    unsigned int num_cycles_left = 0, last_num_cycles_left = 0, num_dma;
 
246
    unsigned int cycles_left_to_trigger_irq = 
 
247
        (OPINFO_DELAYS_INTERRUPT(*cs->last_opcode_info_ptr) ? 2 : 1);
 
248
    CLOCK last_start_clk = CLOCK_MAX;
 
249
/*
 
250
    {
 
251
        unsigned int i;
 
252
        log_debug("INTREQ %ld NUMWR %i", (long)cpu_clk,
 
253
                  maincpu_num_write_cycles());
 
254
        for (i = 0; i < cs->num_dma_per_opcode; i++)
 
255
            log_debug("%iCYLEFT %i STCLK %i", i, cs->num_cycles_left[i],
 
256
                      cs->dma_start_clk[i]);
 
257
    }
 
258
*/
 
259
 
 
260
    num_dma = cs->num_dma_per_opcode;
 
261
    while (num_dma != 0) {
 
262
        num_dma--;
 
263
        num_cycles_left = cs->num_cycles_left[num_dma];
 
264
        if ((cs->dma_start_clk[num_dma] - 1) <= cpu_clk)
 
265
            break;
 
266
        last_num_cycles_left = num_cycles_left;
 
267
        last_start_clk = cs->dma_start_clk[num_dma];
 
268
    }
 
269
    /* if the INTREQ happens between two CPU cycles, we have to interpolate */
 
270
    if (num_cycles_left - last_num_cycles_left > last_start_clk - cpu_clk - 1)
 
271
        num_cycles_left = last_num_cycles_left + last_start_clk - cpu_clk - 1;
 
272
 
 
273
    /*log_debug("TAKENLEFT %i", num_cycles_left);*/
 
274
 
 
275
    *int_clk = cs->last_stolen_cycles_clk;
 
276
    if (num_cycles_left >= cycles_left_to_trigger_irq)
 
277
        *int_clk -= (cycles_left_to_trigger_irq + 1);
 
278
 
 
279
    /*log_debug("INTCLK %i", *int_clk);*/
242
280
}
243
281
 
244
282
/* ------------------------------------------------------------------------- */
320
358
    return 0;
321
359
}
322
360
 
323
 
int interrupt_write_new_snapshot(interrupt_cpu_status_t *cs, snapshot_module_t *m)
 
361
int interrupt_write_new_snapshot(interrupt_cpu_status_t *cs,
 
362
                                 snapshot_module_t *m)
324
363
{
 
364
/*
 
365
    unsigned int i;
 
366
*/
325
367
    if (SMW_DW(m, cs->nirq) < 0
326
368
        || SMW_DW(m, cs->nnmi) < 0
327
369
        || SMW_DW(m, cs->global_pending_int) < 0)
328
370
        return -1;
 
371
/*
 
372
    if (SMW_DW(m, cs->num_dma_per_opcode) < 0)
 
373
        return -1;
329
374
 
 
375
    for (i = 0; i < cs->num_dma_per_opcode; i++) {
 
376
        if (SMW_DW(m, cs->dma_start_clk[i]) < 0)
 
377
            return -1;
 
378
        if (SMW_DW(m, cs->num_cycles_left[i]) < 0)
 
379
            return -1;
 
380
    }
 
381
*/
330
382
    return 0;
331
383
}
332
384