Skip to content

Commit

Permalink
Make some interface changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
lleoha committed Jul 1, 2014
1 parent 635988c commit 206390d
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 34 deletions.
11 changes: 9 additions & 2 deletions src/WinUAE/newcpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,14 @@ static void Exception_normal (int nr)
// address = format $2 stack frame address field
static void ExceptionX (int nr, uaecptr address)
{
if (uaecore11::handlers->exceptions[nr]) {
bool handled = static_cast<bool>(uaecore11::handlers->exceptions[nr](nr, address));
if (handled) {
doint();
return;
}
}

regs.exception = nr;

Exception_normal (nr);
Expand All @@ -328,7 +336,6 @@ static void do_interrupt (int nr)
assert (nr < 8 && nr >= 0);

Exception (nr + 24);
uaecore11::interrupt_level &= ~(1 << nr);

regs.intmask = nr;
doint ();
Expand Down Expand Up @@ -473,9 +480,9 @@ void m68k_run_1 (void)

uae_u16 opcode = r->ir;

do_cycles (cpu_cycles);
r->instruction_pc = m68k_getpc ();
cpu_cycles = (*cpufunctbl[opcode])(opcode);
do_cycles (cpu_cycles);
if (r->spcflags) {
if (do_specialties (cpu_cycles)) {
regs.ipl = regs.ipl_pin;
Expand Down
15 changes: 4 additions & 11 deletions src/core/core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,13 @@ UAECORE11API void uaecore11_reset() {
m68k_reset(true);
}

UAECORE11API void uaecore11_execute() {
UAECORE11API void uaecore11_emulate() {
m68k_run_1();
}

UAECORE11API void uaecore11_raise_irq(int level) {
if (level >= 0 && level <= 7) {
interrupt_level |= (1 << level);
doint();
}
}

UAECORE11API void uaecore11_lower_irq(int level) {
if (level >= 0 && level <= 7) {
interrupt_level &= ~(1 << level);
UAECORE11API void uaecore11_set_interrupt(int level) {
if (level != interrupt_level) {
interrupt_level = level;
doint();
}
}
Expand Down
17 changes: 7 additions & 10 deletions src/core/core_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,12 @@
extern "C" {
#endif

typedef unsigned int (*uaecore11_interrupt_ack_handler_t)(unsigned int level);
typedef unsigned int (*uaecore11_read_handler_t)(unsigned int address);
typedef void (*uaecore11_write_handler_t)(unsigned int address, unsigned int value);
typedef void (*uaecore11_ticks_handler_t)(unsigned long ticks);
typedef void (*uaecore11_reset_handler_t)(void);
typedef int (*uaecore11_interrupt_ack_handler_t)(unsigned int level);
typedef int (*uaecore11_exception_handler_t)(int vector, unsigned int address);

typedef struct {
uaecore11_read_handler_t get_byte;
Expand All @@ -41,6 +42,7 @@ typedef struct {
uaecore11_ticks_handler_t ticks;
uaecore11_interrupt_ack_handler_t interrupt_ack;
uaecore11_reset_handler_t reset;
uaecore11_exception_handler_t exceptions[256];
} uaecore11_handlers_t;

typedef enum {
Expand Down Expand Up @@ -80,19 +82,14 @@ UAECORE11API void uaecore11_init(uaecore11_handlers_t *handlers);
UAECORE11API void uaecore11_reset();

/**
* Execute one instruction.
* Emulate one instruction.
*/
UAECORE11API void uaecore11_execute();
UAECORE11API void uaecore11_emulate();

/**
* Request interrupt.
* Set interrupt priority level (IPL).
*/
UAECORE11API void uaecore11_raise_irq(int level);

/**
* Lower interrupt request.
*/
UAECORE11API void uaecore11_lower_irq(int level);
UAECORE11API void uaecore11_set_interrupt(int level);

/**
* Get register value.
Expand Down
13 changes: 3 additions & 10 deletions src/core/core_glue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,12 @@
#include "sysdeps.h"
#include "core_glue.h"


uaecore11_handlers_t *uaecore11::handlers = 0;
int uaecore11::interrupt_level = -1;
int uaecore11::interrupt_level = 0;

int uaecore11::intlev() {
if (interrupt_level == -1) {
return -1;
}

for (int i = 7; i >= 0; --i) {
if ((interrupt_level & (1 << i)) != 0) return i;
}

return -1;
return interrupt_level;
}

void uaecore11::do_cycles_slow(unsigned long t) {
Expand Down
1 change: 0 additions & 1 deletion src/core/core_glue.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

#include "core_api.h"


namespace uaecore11 {

extern uaecore11_handlers_t *handlers;
Expand Down

0 comments on commit 206390d

Please sign in to comment.