Protect Uthernet with HAVE_TFE and Printer with HAVE_PARALLEL

This commit is contained in:
David Schmidt 2010-04-12 14:23:37 +00:00
parent e78127fcbe
commit 4a3949112f
14 changed files with 208 additions and 155 deletions

View File

@ -42,6 +42,7 @@ gsportmac: $(OBJECTS) compile_time.o
# Linux for X builds:
gsportx: $(OBJECTS) compile_time.o
$(CC) $(CCOPTS) $(LDOPTS) $(OBJECTS) compile_time.o $(LDFLAGS) -o $(NAME)$(SUFFIX) $(XLIBS) $(EXTRA_LIBS) -lX11
echo $(OBJECTS)
mv gsportx ..
cp -f ../config.template ../config.txt
@ -92,6 +93,9 @@ engine_s.o: 8inst_s.h 16inst_s.h 8size_s.h 16size_s.h size_s.h
.c.o:
$(CC) $(CCOPTS) $(XOPTS) -c $(OPTS) -I. $*.c
.cpp.O:
$(CC) $(CCOPTS) $(XOPTS) -c $(OPTS) -I. $*.c
partls: partls.c
cc $(CCOPTS) $(XOPTS) $(OPTS) -o partls partls.c
@ -119,10 +123,13 @@ iwm.o: iwm.c defc.h defcomm.h iwm.h protos.h iwm_35_525.h
joystick_driver.o: joystick_driver.c defc.h defcomm.h iwm.h protos.h
moremem.o: moremem.c defc.h defcomm.h iwm.h protos.h
paddles.o: paddles.c defc.h defcomm.h iwm.h protos.h
parallel.o: parallel.c defc.h
printer.o: printer.cpp
sim65816.o: sim65816.c defc.h defcomm.h iwm.h protos.h
smartport.o: smartport.c defc.h defcomm.h iwm.h protos.h
sound.o: sound.c defc.h defcomm.h iwm.h protos.h sound.h
sound_driver.o: sound_driver.c defc.h defcomm.h iwm.h protos.h sound.h
tfe.o: tfe/tfe.c
video.o: video.c defc.h defcomm.h iwm.h protos.h superhires.h kegsfont.h
macdriver.o: macdriver.c defc.h defcomm.h iwm.h protos.h protos_macdriver.h
macsnd_driver.o: macsnd_driver.c defc.h defcomm.h iwm.h protos.h sound.h

View File

@ -519,6 +519,7 @@ cfg_text_screen_dump()
fclose(ofile);
}
#ifdef HAVE_TFE
void
cfg_get_tfe_name()
{
@ -549,6 +550,7 @@ cfg_get_tfe_name()
}
return;
}
#endif
void
config_vbl_update(int doit_3_persec)
@ -2020,7 +2022,9 @@ cfg_parse_menu(Cfg_menu *menuptr, int menu_pos, int highlight_pos, int change)
char *curstr, *defstr;
char *str;
char *outstr;
#ifdef HAVE_TFE
char *strval;
#endif
int *iptr;
int val;
int num_opts;
@ -3147,6 +3151,8 @@ config_control_panel()
if(g_cfg_slotdrive >= 0) {
cfg_file_draw();
}
#ifdef HAVE_TFE
/*HACK eh, at least I think it is. Display the available ethernet interfaces
when in the ethernet control panel. This is the only way one can customize a menu pane.
Kent did it with the directory browser, so why not.*/
@ -3154,6 +3160,7 @@ config_control_panel()
{
cfg_get_tfe_name();
}
#endif
key = -1;
while(g_config_control_panel) {

View File

@ -279,7 +279,7 @@ fixup_intcx()
int start_k;
word32 mask;
int j, k;
int test1;
rom10000 = &(g_rom_fc_ff_ptr[0x30000]);
no_io_shadow = (g_c035_shadow_reg & 0x40);
@ -1464,6 +1464,7 @@ io_read(word32 loc, double *cyc_ptr)
case 0x94: case 0x95: case 0x96: case 0x97:
case 0x98: case 0x99: case 0x9a: case 0x9b:
case 0x9c: case 0x9d: case 0x9e: case 0x9f:
#ifdef HAVE_PARALLEL
if (g_parallel)
{
return parallel_read((word16)loc & 0xf);
@ -1472,7 +1473,9 @@ io_read(word32 loc, double *cyc_ptr)
{
UNIMPL_READ;
}
#else
UNIMPL_READ;
#endif
/* 0xc0a0 - 0xc0af */
case 0xa0: case 0xa1: case 0xa2: case 0xa3:
@ -1496,6 +1499,7 @@ io_read(word32 loc, double *cyc_ptr)
//case 0xb8:
// return 0;
// break;
#ifdef HAVE_TFE
/*Uthernet read access on slot 3*/
case 0xb0:
case 0xb1:
@ -1518,6 +1522,7 @@ io_read(word32 loc, double *cyc_ptr)
}
else
{return 0;}
#endif
/* 0xc0c0 - 0xc0cf */
case 0xc0: case 0xc1: case 0xc2: case 0xc3:
@ -2156,6 +2161,7 @@ io_write(word32 loc, int val, double *cyc_ptr)
case 0x94: case 0x95: case 0x96: case 0x97:
case 0x98: case 0x99: case 0x9a: case 0x9b:
case 0x9c: case 0x9d: case 0x9e: case 0x9f:
#ifdef HAVE_PARALLEL
if (g_parallel)
{
return parallel_write((word16)loc & 0xf, (byte)val);
@ -2164,6 +2170,9 @@ io_write(word32 loc, int val, double *cyc_ptr)
{
UNIMPL_WRITE;
}
#else
UNIMPL_WRITE;
#endif
/* 0xc0a0 - 0xc0af */
case 0xa0: case 0xa1: case 0xa3:
@ -2186,6 +2195,7 @@ io_write(word32 loc, int val, double *cyc_ptr)
//case 0xb8: case 0xb9: case 0xba: case 0xbb:
//case 0xbc: case 0xbd: case 0xbe: case 0xbf:
// UNIMPL_WRITE;
#ifdef HAVE_TFE
/*Uthernet write access on slot 3*/
case 0xb0:
case 0xb1:
@ -2211,6 +2221,7 @@ io_write(word32 loc, int val, double *cyc_ptr)
{
UNIMPL_WRITE;
}
#endif
/* 0xc0c0 - 0xc0cf */
case 0xc0: case 0xc1: case 0xc2: case 0xc3:

View File

@ -1,76 +1,76 @@
/*
GSport - an Apple //gs Emulator
Copyright (C) 2010 by GSport contributors
Based on the KEGS emulator written by and Copyright (C) 2003 Kent Dickey
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/*
parallel.c
This file handles the Apple II Parallel Card emulation in slot 1. Its very
basic, but allows for future support of redirecting the output to a real
parallel port, files, and additional types of emulated printers.
*/
#include "defc.h"
#include "printer.h"
extern int g_parallel_out_masking;
extern int g_vbl_count;
extern int g_printer_timeout;
int printer_vbl_count = 0;
int port_block = 0;
byte parallel_read(word16 io_address)
{
printf("parallel card status called at %x\n", io_address);
//since we only have a virtual printer, always return state as "Ready"
return 0xff;
}
void parallel_write(word16 io_address, byte val)
{
//Mask MSB if user has it set.
if(g_parallel_out_masking) {
val = val & 0xfe;
}
printf("parallel card called at %x\n", io_address);
//send a byte to the virtual printer
//By default all output to $C090 gets sent to the printer
if (io_address == 0x00)
{
port_block = 1;
printer_loop(val);
printer_vbl_count = g_vbl_count+(g_printer_timeout*60);
port_block = 0;
}
return;
}
//This function handles the automatic timeout of the virtual printer if an
//application doesn't send a form feed at the end of the page. It also
//allows multipage mode Postscript and native printer documents to
//print somewhat how a regular application would.
void printer_update()
{
if (port_block != 1 && printer_vbl_count != 0 && g_vbl_count >= printer_vbl_count)
{
printf("Calling printer_update and flushing!\n");
printer_feed();
printer_vbl_count = 0;
}
return;
}
/*
GSport - an Apple //gs Emulator
Copyright (C) 2010 by GSport contributors
Based on the KEGS emulator written by and Copyright (C) 2003 Kent Dickey
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/*
parallel.c
This file handles the Apple II Parallel Card emulation in slot 1. Its very
basic, but allows for future support of redirecting the output to a real
parallel port, files, and additional types of emulated printers.
*/
#include "defc.h"
#include "printer.h"
extern int g_parallel_out_masking;
extern int g_vbl_count;
extern int g_printer_timeout;
int printer_vbl_count = 0;
int port_block = 0;
byte parallel_read(word16 io_address)
{
printf("parallel card status called at %x\n", io_address);
//since we only have a virtual printer, always return state as "Ready"
return 0xff;
}
void parallel_write(word16 io_address, byte val)
{
//Mask MSB if user has it set.
if(g_parallel_out_masking) {
val = val & 0xfe;
}
printf("parallel card called at %x\n", io_address);
//send a byte to the virtual printer
//By default all output to $C090 gets sent to the printer
if (io_address == 0x00)
{
port_block = 1;
printer_loop(val);
printer_vbl_count = g_vbl_count+(g_printer_timeout*60);
port_block = 0;
}
return;
}
//This function handles the automatic timeout of the virtual printer if an
//application doesn't send a form feed at the end of the page. It also
//allows multipage mode Postscript and native printer documents to
//print somewhat how a regular application would.
void printer_update()
{
if (port_block != 1 && printer_vbl_count != 0 && g_vbl_count >= printer_vbl_count)
{
printf("Calling printer_update and flushing!\n");
printer_feed();
printer_vbl_count = 0;
}
return;
}

View File

@ -544,76 +544,3 @@ word32 float_bus(double dcycs);
byte parallel_read(word16 paddr);
void parallel_write(word16 paddr, byte pvar);
void printer_update();
/*tfc.c*/
int tfe_enabled;
void tfe_init(void);
int tfe_resources_init(void);
int tfe_cmdline_options_init(void);
int set_tfe_interface(const char* name);
void get_disabled_state(int * param);
void tfe_reset(void);
void tfe_shutdown(void);
byte tfe_read(word16 addr);
void tfe_store(word16 addr, byte var);
int tfe_read_snapshot_module(struct snapshot_s *s);
int tfe_write_snapshot_module(struct snapshot_s *s);
int tfe_enumadapter_open(void);
int tfe_enumadapter(char **ppname, char **ppdescription);
int tfe_enumadapter_close(void);
/*tfearch.c*/
int tfe_arch_init(void);
void tfe_arch_pre_reset(void);
void tfe_arch_post_reset(void);
int tfe_arch_activate(const char *interface_name);
void tfe_arch_deactivate(void);
void tfe_arch_set_mac(const byte mac[6]);
void tfe_arch_set_hashfilter(const int hash_mask[2]);
void tfe_arch_recv_ctl( int bBroadcast, /* broadcast */
int bIA, /* individual address (IA) */
int bMulticast, /* multicast if address passes the hash filter */
int bCorrect, /* accept correct frames */
int bPromiscuous, /* promiscuous mode */
int bIAHash /* accept if IA passes the hash filter */
);
void tfe_arch_line_ctl(int bEnableTransmitter, int bEnableReceiver);
void tfe_arch_transmit(int force, /* FORCE: Delete waiting frames in transmit buffer */
int onecoll, /* ONECOLL: Terminate after just one collision */
int inhibit_crc, /* INHIBITCRC: Do not append CRC to the transmission */
int tx_pad_dis, /* TXPADDIS: Disable padding to 60 Bytes */
int txlength, /* Frame length */
byte *txframe /* Pointer to the frame to be transmitted */
);
int tfe_arch_receive(byte *pbuffer , /* where to store a frame */
int *plen, /* IN: maximum length of frame to copy;
OUT: length of received frame
OUT can be bigger than IN if received frame was
longer than supplied buffer */
int *phashed, /* set if the dest. address is accepted by the hash filter */
int *phash_index, /* hash table index if hashed == TRUE */
int *prx_ok, /* set if good CRC and valid length */
int *pcorrect_mac, /* set if dest. address is exactly our IA */
int *pbroadcast, /* set if dest. address is a broadcast address */
int *pcrc_error /* set if received frame had a CRC error */
);
/*
This is a helper for tfe_receive() to determine if the received frame should be accepted
according to the settings.
This function is even allowed to be called in tfearch.c from tfe_arch_receive() if
necessary, which is the reason why its prototype is included here in tfearch.h.
*/
int tfe_should_accept(unsigned char *buffer, int length, int *phashed, int *phash_index,
int *pcorrect_mac, int *pbroadcast, int *pmulticast);
int tfe_arch_enumadapter_open(void);
int tfe_arch_enumadapter(char **ppname, char **ppdescription);
int tfe_arch_enumadapter_close(void);

93
src/protos_tfe.h Normal file
View File

@ -0,0 +1,93 @@
/*
GSport - an Apple //gs Emulator
Copyright (C) 2010 by GSport contributors
Based on the KEGS emulator written by and Copyright (C) 2003 Kent Dickey
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/*tfc.c*/
int tfe_enabled;
void tfe_init(void);
int tfe_resources_init(void);
int tfe_cmdline_options_init(void);
int set_tfe_interface(const char* name);
void get_disabled_state(int * param);
void tfe_reset(void);
void tfe_shutdown(void);
byte tfe_read(word16 addr);
void tfe_store(word16 addr, byte var);
int tfe_read_snapshot_module(struct snapshot_s *s);
int tfe_write_snapshot_module(struct snapshot_s *s);
int tfe_enumadapter_open(void);
int tfe_enumadapter(char **ppname, char **ppdescription);
int tfe_enumadapter_close(void);
/*tfearch.c*/
int tfe_arch_init(void);
void tfe_arch_pre_reset(void);
void tfe_arch_post_reset(void);
int tfe_arch_activate(const char *interface_name);
void tfe_arch_deactivate(void);
void tfe_arch_set_mac(const byte mac[6]);
void tfe_arch_set_hashfilter(const int hash_mask[2]);
void tfe_arch_recv_ctl( int bBroadcast, /* broadcast */
int bIA, /* individual address (IA) */
int bMulticast, /* multicast if address passes the hash filter */
int bCorrect, /* accept correct frames */
int bPromiscuous, /* promiscuous mode */
int bIAHash /* accept if IA passes the hash filter */
);
void tfe_arch_line_ctl(int bEnableTransmitter, int bEnableReceiver);
void tfe_arch_transmit(int force, /* FORCE: Delete waiting frames in transmit buffer */
int onecoll, /* ONECOLL: Terminate after just one collision */
int inhibit_crc, /* INHIBITCRC: Do not append CRC to the transmission */
int tx_pad_dis, /* TXPADDIS: Disable padding to 60 Bytes */
int txlength, /* Frame length */
byte *txframe /* Pointer to the frame to be transmitted */
);
int tfe_arch_receive(byte *pbuffer , /* where to store a frame */
int *plen, /* IN: maximum length of frame to copy;
OUT: length of received frame
OUT can be bigger than IN if received frame was
longer than supplied buffer */
int *phashed, /* set if the dest. address is accepted by the hash filter */
int *phash_index, /* hash table index if hashed == TRUE */
int *prx_ok, /* set if good CRC and valid length */
int *pcorrect_mac, /* set if dest. address is exactly our IA */
int *pbroadcast, /* set if dest. address is a broadcast address */
int *pcrc_error /* set if received frame had a CRC error */
);
/*
This is a helper for tfe_receive() to determine if the received frame should be accepted
according to the settings.
This function is even allowed to be called in tfearch.c from tfe_arch_receive() if
necessary, which is the reason why its prototype is included here in tfearch.h.
*/
int tfe_should_accept(unsigned char *buffer, int length, int *phashed, int *phash_index,
int *pcorrect_mac, int *pbroadcast, int *pmulticast);
int tfe_arch_enumadapter_open(void);
int tfe_arch_enumadapter(char **ppname, char **ppdescription);
int tfe_arch_enumadapter_close(void);

View File

@ -26,7 +26,9 @@ const char rcsid_sim65816_c[] = "@(#)$KmKId: sim65816.c,v 1.367 2004-11-22 02:39
#define INCLUDE_RCSID_C
#include "defc.h"
#undef INCLUDE_RCSID_C
#include "printer.h"
#ifdef HAVE_PARALLEL
#include "printer.h"
#endif
#define PC_LOG_LEN (8*1024)
@ -622,7 +624,9 @@ void
my_exit(int ret)
{
end_screen();
#ifdef HAVE_PARALLEL
printer_close();
#endif
printf("exiting\n");
exit(ret);
}
@ -921,8 +925,11 @@ kegsmain(int argc, char **argv)
iwm_init();
config_init();
#ifdef HAVE_PARALLEL
printer_init(g_printer_dpi,85,110,g_printer_output,g_printer_multipage);
#endif
//If ethernet is enabled in config.kegs, lets initialize it
#ifdef HAVE_TFE
if (g_ethernet == 1)
{
int i = 0;
@ -948,6 +955,7 @@ kegsmain(int argc, char **argv)
lib_free(ppdes);
tfe_init();
}
#endif
load_roms_init_memory();

View File

@ -36,7 +36,7 @@
#include <pcap.h>
#endif
#include "..\defc.h"
#include "../defc.h"
#include "tfesupp.h"

View File

@ -1,7 +1,7 @@
TARGET = gsportwin.exe
OBJECTS = $(OBJECTS1) win32snd_driver.o windriver.o
CCOPTS = -O2 -DKEGS_LITTLE_ENDIAN
OBJECTS = $(OBJECTS1) tfe.o win32snd_driver.o windriver.o
CCOPTS = -O2 -DKEGS_LITTLE_ENDIAN -DHAVE_TFE
SUFFIX = ".exe"
NAME = gsportwin