New plugin stdio
git-svn-id: svn://svn.cc65.org/cc65/trunk@1224 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
parent
77308fe20f
commit
569c0f451f
2 changed files with 178 additions and 5 deletions
|
@ -2,15 +2,19 @@
|
||||||
# gcc Makefile for the sim65 chip plugins
|
# gcc Makefile for the sim65 chip plugins
|
||||||
#
|
#
|
||||||
|
|
||||||
# Library dir
|
# Include directories
|
||||||
|
COMMON = ../../common
|
||||||
SIM65 = ..
|
SIM65 = ..
|
||||||
|
|
||||||
CFLAGS = -g -O2 -Wall -W -I$(SIM65) -fpic
|
CFLAGS = -g -O2 -Wall -W -I$(COMMON) -I$(SIM65) -fpic
|
||||||
CC = gcc
|
CC = gcc
|
||||||
EBIND = emxbind
|
EBIND = emxbind
|
||||||
LDFLAGS =
|
LDFLAGS =
|
||||||
|
|
||||||
CHIPS = ram.so
|
LIBS = $(COMMON)/common.a
|
||||||
|
|
||||||
|
CHIPS = ram.so \
|
||||||
|
stdio.so
|
||||||
|
|
||||||
OBJS = $(CHIPS:.so=.o)
|
OBJS = $(CHIPS:.so=.o)
|
||||||
|
|
||||||
|
@ -24,10 +28,18 @@ all: depend
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
||||||
|
# Rules to make chips
|
||||||
|
|
||||||
ram.so: ram.o
|
ram.so: ram.o
|
||||||
$(CC) $(CFLAGS) -shared -o $@ $^
|
$(CC) $(CFLAGS) -shared -o $@ $(LIBS) $^
|
||||||
@if [ $(OS2_SHELL) ] ; then $(EBIND) $@ ; fi
|
@if [ $(OS2_SHELL) ] ; then $(EBIND) $@ ; fi
|
||||||
|
|
||||||
|
stdio.so: stdio.o
|
||||||
|
$(CC) $(CFLAGS) -shared -o $@ $(LIBS) $^
|
||||||
|
@if [ $(OS2_SHELL) ] ; then $(EBIND) $@ ; fi
|
||||||
|
|
||||||
|
# Admin stuff
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f *~ core *.lst
|
rm -f *~ core *.lst
|
||||||
|
|
||||||
|
@ -40,6 +52,6 @@ zap: clean
|
||||||
.PHONY: depend dep
|
.PHONY: depend dep
|
||||||
depend dep: $(CHIPS:.so=.c)
|
depend dep: $(CHIPS:.so=.c)
|
||||||
@echo "Creating dependency information"
|
@echo "Creating dependency information"
|
||||||
$(CC) -I$(SIM65) -MM $^ > .depend
|
$(CC) -I$(COMMON) -I$(SIM65) -MM $^ > .depend
|
||||||
|
|
||||||
|
|
||||||
|
|
161
src/sim65/chips/stdio.c
Normal file
161
src/sim65/chips/stdio.c
Normal file
|
@ -0,0 +1,161 @@
|
||||||
|
/*****************************************************************************/
|
||||||
|
/* */
|
||||||
|
/* stdio.c */
|
||||||
|
/* */
|
||||||
|
/* STDIO plugin for the sim65 6502 simulator */
|
||||||
|
/* */
|
||||||
|
/* */
|
||||||
|
/* */
|
||||||
|
/* (C) 2002 Ullrich von Bassewitz */
|
||||||
|
/* Wacholderweg 14 */
|
||||||
|
/* D-70597 Stuttgart */
|
||||||
|
/* EMail: uz@musoftware.de */
|
||||||
|
/* */
|
||||||
|
/* */
|
||||||
|
/* This software is provided 'as-is', without any expressed or implied */
|
||||||
|
/* warranty. In no event will the authors be held liable for any damages */
|
||||||
|
/* arising from the use of this software. */
|
||||||
|
/* */
|
||||||
|
/* Permission is granted to anyone to use this software for any purpose, */
|
||||||
|
/* including commercial applications, and to alter it and redistribute it */
|
||||||
|
/* freely, subject to the following restrictions: */
|
||||||
|
/* */
|
||||||
|
/* 1. The origin of this software must not be misrepresented; you must not */
|
||||||
|
/* claim that you wrote the original software. If you use this software */
|
||||||
|
/* in a product, an acknowledgment in the product documentation would be */
|
||||||
|
/* appreciated but is not required. */
|
||||||
|
/* 2. Altered source versions must be plainly marked as such, and must not */
|
||||||
|
/* be misrepresented as being the original software. */
|
||||||
|
/* 3. This notice may not be removed or altered from any source */
|
||||||
|
/* distribution. */
|
||||||
|
/* */
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
/* common */
|
||||||
|
#include "attrib.h"
|
||||||
|
|
||||||
|
/* sim65 */
|
||||||
|
#include "chipif.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/* Forwards */
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int InitChip (const struct SimData* Data);
|
||||||
|
/* Initialize the chip, return an error code */
|
||||||
|
|
||||||
|
static void* InitInstance (unsigned Addr, unsigned Range);
|
||||||
|
/* Initialize a new chip instance */
|
||||||
|
|
||||||
|
static void Write (void* Data, unsigned Addr, unsigned char Val);
|
||||||
|
/* Write user data */
|
||||||
|
|
||||||
|
static unsigned char Read (void* Data, unsigned Addr);
|
||||||
|
/* Read user data */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/* Data */
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Control data passed to the main program */
|
||||||
|
static const struct ChipData RAMData[1] = {
|
||||||
|
{
|
||||||
|
"STDIO", /* Name of the chip */
|
||||||
|
CHIPDATA_VER_MAJOR, /* Version information */
|
||||||
|
CHIPDATA_VER_MINOR,
|
||||||
|
|
||||||
|
/* -- Exported functions -- */
|
||||||
|
InitChip,
|
||||||
|
InitInstance,
|
||||||
|
Write,
|
||||||
|
Write,
|
||||||
|
Read,
|
||||||
|
Read
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/* The SimData pointer we get when InitChip is called */
|
||||||
|
static const SimData* Sim;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/* Exported function */
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int GetChipData (const ChipData** Data, unsigned* Count)
|
||||||
|
{
|
||||||
|
/* Pass the control structure to the caller */
|
||||||
|
*Data = RAMData;
|
||||||
|
*Count = sizeof (Data) / sizeof (Data[0]);
|
||||||
|
|
||||||
|
/* Call was successful */
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/* Code */
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int InitChip (const struct SimData* Data)
|
||||||
|
/* Initialize the chip, return an error code */
|
||||||
|
{
|
||||||
|
/* Remember the pointer */
|
||||||
|
Sim = Data;
|
||||||
|
|
||||||
|
/* Always successful */
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static void* InitInstance (unsigned Addr attribute ((unused)),
|
||||||
|
unsigned Range attribute ((unused)))
|
||||||
|
/* Initialize a new chip instance */
|
||||||
|
{
|
||||||
|
/* We don't need any instance data */
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static void Write (void* Data attribute ((unused)),
|
||||||
|
unsigned Addr attribute ((unused)),
|
||||||
|
unsigned char Val)
|
||||||
|
/* Write user data */
|
||||||
|
{
|
||||||
|
putchar (Val);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static unsigned char Read (void* Data attribute ((unused)),
|
||||||
|
unsigned Addr attribute ((unused)))
|
||||||
|
/* Read user data */
|
||||||
|
{
|
||||||
|
/* Read a character and return the value */
|
||||||
|
return getchar ();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue