-
Notifications
You must be signed in to change notification settings - Fork 0
/
Z80IO.h
76 lines (68 loc) · 3.12 KB
/
Z80IO.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/*** Z80Em: Portable Z80 emulator *******************************************/
/*** ***/
/*** Z80IO.h ***/
/*** ***/
/*** This file contains the prototypes for the functions accessing memory ***/
/*** and I/O ***/
/*** ***/
/*** Copyright (C) Marcel de Kogel 1996,1997,1998 ***/
/*** You are not allowed to distribute this software commercially ***/
/*** Please, notify me, if you make any changes to this file ***/
/****************************************************************************/
#define INLINE_OP /* Inline Z80_RDOP() */
#define INLINE_MEM /* Inline Z80_RDMEM() and Z80_WRMEM() */
#if defined(__GNUC__) && !defined(PSP) && !defined(MSDOS) && !defined(__APPLE__)
#define FASTCALL __attribute__ ((fastcall))
// #ifdef INLINE_MEM
// #define INLINE_MEM_GNU
// #endif
#else
#define FASTCALL
#endif
/****************************************************************************/
/* Input a byte from given I/O port */
/****************************************************************************/
byte FASTCALL Z80_In (unsigned Port);
/****************************************************************************/
/* Output a byte to given I/O port */
/****************************************************************************/
void FASTCALL Z80_Out (unsigned Port,byte Value);
#ifndef INLINE_MEM_GNU
/***************************************************************************/
/* Read a byte from given memory location */
/***************************************************************************/
unsigned FASTCALL Z80_RDMEM(dword a);
/***************************************************************************/
/* Write a byte to given memory location */
/***************************************************************************/
void FASTCALL Z80_WRMEM(dword a,byte v);
#else
extern byte *AddrTabl[256];
extern byte *WriteAddrTabl[256];
extern byte PCBTable[65536];
void ReadPCB (dword a);
void WritePCB (dword a);
extern unsigned Z80_RDMEM (dword a)
{
int retval=AddrTabl[a>>8][a&0xFF];
if (PCBTable[a]) ReadPCB (a);
return retval;
}
extern void Z80_WRMEM (dword a,byte v)
{
WriteAddrTabl[a>>8][a&0xFF]=v;
if (PCBTable[a]) WritePCB (a);
}
#endif
#ifdef INLINE_OP
extern byte *AddrTabl[256];
extern byte *WriteAddrTabl[256];
#define Z80_RDOP(a) AddrTabl[(a)>>8][(a)&0xFF]
#define Z80_RDSTACK(a) AddrTabl[(a)>>8][(a)&0xFF]
#define Z80_WRSTACK(a,v) WriteAddrTabl[(a)>>8][(a)&0xFF]=v
#else
#define Z80_RDOP(a) Z80_RDMEM(a)
#define Z80_RDSTACK(a) Z80_RDMEM(a)
#define Z80_WRSTACK(a,v) Z80_WRMEM(a,v)
#endif
#define Z80_RDOP_ARG(a) Z80_RDOP(a)