1 /*****************************************************************************/
5 /* STDIO plugin for the sim65 6502 simulator */
9 /* (C) 2002-2003 Ullrich von Bassewitz */
10 /* Römerstrasse 52 */
11 /* D-70794 Filderstadt */
12 /* EMail: uz@cc65.org */
15 /* This software is provided 'as-is', without any expressed or implied */
16 /* warranty. In no event will the authors be held liable for any damages */
17 /* arising from the use of this software. */
19 /* Permission is granted to anyone to use this software for any purpose, */
20 /* including commercial applications, and to alter it and redistribute it */
21 /* freely, subject to the following restrictions: */
23 /* 1. The origin of this software must not be misrepresented; you must not */
24 /* claim that you wrote the original software. If you use this software */
25 /* in a product, an acknowledgment in the product documentation would be */
26 /* appreciated but is not required. */
27 /* 2. Altered source versions must be plainly marked as such, and must not */
28 /* be misrepresented as being the original software. */
29 /* 3. This notice may not be removed or altered from any source */
32 /*****************************************************************************/
48 /*****************************************************************************/
50 /*****************************************************************************/
54 static int InitChip (const struct SimData* Data);
55 /* Initialize the chip, return an error code */
57 static void* CreateInstance (unsigned Addr, unsigned Range, void* CfgInfo);
58 /* Create a new chip instance */
60 static void DestroyInstance (void* Data);
61 /* Destroy a chip instance */
63 static void Write (void* Data, unsigned Offs, unsigned char Val);
66 static unsigned char Read (void* Data, unsigned Offs);
71 /*****************************************************************************/
73 /*****************************************************************************/
77 /* Control data passed to the main program */
78 static const struct ChipData CData[1] = {
80 "STDIO", /* Name of the chip */
81 CHIPDATA_TYPE_CHIP, /* Type of the chip */
82 CHIPDATA_VER_MAJOR, /* Version information */
85 /* -- Exported functions -- */
96 /* The SimData pointer we get when InitChip is called */
97 static const SimData* Sim;
101 /*****************************************************************************/
102 /* Exported function */
103 /*****************************************************************************/
107 int GetChipData (const ChipData** Data, unsigned* Count)
109 /* Pass the control structure to the caller */
111 *Count = sizeof (CData) / sizeof (CData[0]);
113 /* Call was successful */
119 /*****************************************************************************/
121 /*****************************************************************************/
125 static int InitChip (const struct SimData* Data)
126 /* Initialize the chip, return an error code */
128 /* Remember the pointer */
131 /* Always successful */
137 static void* CreateInstance (unsigned Addr, unsigned Range, void* CfgInfo)
138 /* Initialize a new chip instance */
140 /* We don't need any instance data */
146 static void DestroyInstance (void* Data)
147 /* Destroy a chip instance */
153 static void Write (void* Data attribute ((unused)),
154 unsigned Offs attribute ((unused)),
156 /* Write user data */
163 static unsigned char Read (void* Data attribute ((unused)),
164 unsigned Offs attribute ((unused)))
167 /* Read a character and return the value */