fork of PCE focusing on macplus, supporting DaynaPort SCSI network emulation
1/*****************************************************************************
2 * pce *
3 *****************************************************************************/
4
5/*****************************************************************************
6 * File name: src/arch/macplus/hook.c *
7 * Created: 2007-12-04 by Hampa Hug <hampa@hampa.ch> *
8 * Copyright: (C) 2007-2013 Hampa Hug <hampa@hampa.ch> *
9 *****************************************************************************/
10
11/*****************************************************************************
12 * This program is free software. You can redistribute it and / or modify it *
13 * under the terms of the GNU General Public License version 2 as published *
14 * by the Free Software Foundation. *
15 * *
16 * This program is distributed in the hope that it will be useful, but *
17 * WITHOUT ANY WARRANTY, without even the implied warranty of *
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General *
19 * Public License for more details. *
20 *****************************************************************************/
21
22
23#include "main.h"
24#include "macplus.h"
25#include "msg.h"
26
27#include <cpu/e68000/e68000.h>
28
29#include <lib/log.h>
30
31
32#define MAC_HOOK_NOP 0
33#define MAC_HOOK_STOP 1
34#define MAC_HOOK_EXIT 2
35#define MAC_HOOK_INSERT 3
36#define MAC_HOOK_MARK 4
37
38
39int mac_hook (void *ext, unsigned val)
40{
41 unsigned i;
42 macplus_t *sim = ext;
43
44 switch (val) {
45 case MAC_HOOK_NOP:
46 return (0);
47
48 case MAC_HOOK_STOP:
49 mac_set_msg (sim, "emu.stop", "1");
50 return (0);
51
52 case MAC_HOOK_EXIT:
53 mac_set_msg (sim, "emu.exit", "1");
54 return (0);
55
56 case MAC_HOOK_INSERT:
57 for (i = 0; i < 4; i++) {
58 mac_sony_insert (&sim->sony, i + 1);
59 }
60 return (0);
61
62 case MAC_HOOK_MARK:
63 pce_log (MSG_INF, "mark: PC=%06lX\n",
64 (unsigned long) e68_get_pc (sim->cpu)
65 );
66 return (0);
67
68 default:
69 sim->sony.d0 = e68_get_dreg32 (sim->cpu, 0);
70 sim->sony.a0 = e68_get_areg32 (sim->cpu, 0);
71 sim->sony.a1 = e68_get_areg32 (sim->cpu, 1);
72 sim->sony.pc = e68_get_pc (sim->cpu);
73
74 if (mac_sony_hook (&sim->sony, val) == 0) {
75 e68_set_dreg32 (sim->cpu, 0, sim->sony.d0);
76 e68_set_areg32 (sim->cpu, 0, sim->sony.a0);
77 e68_set_areg32 (sim->cpu, 1, sim->sony.a1);
78 e68_set_pc_prefetch (sim->cpu, sim->sony.pc);
79
80 return (0);
81 }
82 break;
83 }
84
85 mac_log_deb ("unhandled hook (%04X)\n", val);
86
87 return (1);
88}