src/osd/sdl/sdl.mak
| r13305 | r13306 | |
| 134 | 134 | ifeq ($(TARGETOS),linux) |
| 135 | 135 | BASE_TARGETOS = unix |
| 136 | 136 | SYNC_IMPLEMENTATION = tc |
| 137 | | SDL_NETWORK = on |
| 137 | SDL_NETWORK = taptun |
| 138 | 138 | endif |
| 139 | 139 | |
| 140 | 140 | ifeq ($(TARGETOS),freebsd) |
| r13305 | r13306 | |
| 175 | 175 | SYNC_IMPLEMENTATION = ntc |
| 176 | 176 | SDLMAIN = $(SDLOBJ)/SDLMain_tmpl.o |
| 177 | 177 | SDLUTILMAIN = $(SDLOBJ)/SDLMain_tmpl.o |
| 178 | SDL_NETWORK = pcap |
| 178 | 179 | MAINLDFLAGS = -Xlinker -all_load |
| 179 | 180 | NO_X11 = 1 |
| 180 | 181 | ifdef BIGENDIAN |
| r13305 | r13306 | |
| 209 | 210 | SDLMAIN = $(SDLOBJ)/main.o |
| 210 | 211 | # needed for unidasm |
| 211 | 212 | LDFLAGS += -Wl,--allow-multiple-definition |
| 213 | SDL_NETWORK = pcap |
| 212 | 214 | |
| 213 | 215 | # do we have GTK ? |
| 214 | 216 | ifndef GTK_INSTALL_ROOT |
| r13305 | r13306 | |
| 502 | 504 | #------------------------------------------------- |
| 503 | 505 | |
| 504 | 506 | ifdef USE_NETWORK |
| 505 | | ifeq ($(SDL_NETWORK),on) |
| 507 | ifeq ($(SDL_NETWORK),taptun) |
| 506 | 508 | OSDOBJS += \ |
| 507 | 509 | $(SDLOBJ)/netdev.o \ |
| 508 | 510 | $(SDLOBJ)/netdev_tap.o |
| 509 | 511 | |
| 510 | | DEFS += -DSDLMAME_NETWORK |
| 512 | DEFS += -DSDLMAME_NETWORK -DSDLMAME_NET_TAPTUN |
| 511 | 513 | endif |
| 514 | |
| 515 | ifeq ($(SDL_NETWORK),pcap) |
| 516 | OSDOBJS += \ |
| 517 | $(SDLOBJ)/netdev.o \ |
| 518 | $(SDLOBJ)/netdev_pcap.o |
| 519 | |
| 520 | DEFS += -DSDLMAME_NETWORK -DSDLMAME_NET_PCAP |
| 521 | LIBS += -lpcap |
| 512 | 522 | endif |
| 523 | endif |
| 513 | 524 | |
| 514 | 525 | #------------------------------------------------- |
| 515 | 526 | # Dependencies |
src/osd/sdl/netdev_pcap.c
| r0 | r13306 | |
| 1 | #ifdef SDLMAME_WIN32 |
| 2 | #include "../windows/netdev_pcap.c" |
| 3 | #else |
| 4 | |
| 5 | #include <pcap.h> |
| 6 | #include "emu.h" |
| 7 | #include "osdnet.h" |
| 8 | |
| 9 | class netdev_pcap : public netdev |
| 10 | { |
| 11 | public: |
| 12 | netdev_pcap(const char *name, class device_network_interface *ifdev, int rate); |
| 13 | ~netdev_pcap(); |
| 14 | |
| 15 | int send(UINT8 *buf, int len); |
| 16 | void set_mac(const char *mac); |
| 17 | protected: |
| 18 | int recv_dev(UINT8 **buf); |
| 19 | private: |
| 20 | pcap_t *m_p; |
| 21 | }; |
| 22 | |
| 23 | netdev_pcap::netdev_pcap(const char *name, class device_network_interface *ifdev, int rate) |
| 24 | : netdev(ifdev, rate) |
| 25 | { |
| 26 | char errbuf[PCAP_ERRBUF_SIZE]; |
| 27 | m_p = pcap_open_live(name, 65535, 1, 1, errbuf); |
| 28 | if(!m_p) |
| 29 | { |
| 30 | mame_print_verbose("Unable to open %s: %s\n", name, errbuf); |
| 31 | return; |
| 32 | } |
| 33 | if(pcap_set_datalink(m_p, DLT_EN10MB) == -1) |
| 34 | { |
| 35 | mame_print_verbose("Unable to set %s to ethernet", name); |
| 36 | pcap_close(m_p); |
| 37 | m_p = NULL; |
| 38 | return; |
| 39 | } |
| 40 | set_mac(get_mac()); |
| 41 | } |
| 42 | |
| 43 | void netdev_pcap::set_mac(const char *mac) |
| 44 | { |
| 45 | char filter[256]; |
| 46 | struct bpf_program fp; |
| 47 | if(!m_p) return; |
| 48 | smame_print_verbose(filter, "ether dst %.2X:%.2X:%.2X:%.2X:%.2X:%.2X or ether multicast or ether broadcast", (unsigned char)mac[0], (unsigned char)mac[1], (unsigned char)mac[2],(unsigned char)mac[3], (unsigned char)mac[4], (unsigned char)mac[5]); |
| 49 | pcap_compile(m_p, &fp, filter, 1, 0); |
| 50 | pcap_setfilter(m_p, &fp); |
| 51 | } |
| 52 | |
| 53 | int netdev_pcap::send(UINT8 *buf, int len) |
| 54 | { |
| 55 | if(!m_p) return 0; |
| 56 | return (!pcap_sendpacket(m_p, buf, len))?len:0; |
| 57 | } |
| 58 | |
| 59 | int netdev_pcap::recv_dev(UINT8 **buf) |
| 60 | { |
| 61 | struct pcap_pkthdr *header; |
| 62 | if(!m_p) return 0; |
| 63 | return (pcap_next_ex(m_p, &header, (const u_char **)buf) == 1)?header->len:0; |
| 64 | } |
| 65 | |
| 66 | netdev_pcap::~netdev_pcap() |
| 67 | { |
| 68 | if(m_p) pcap_close(m_p); |
| 69 | } |
| 70 | |
| 71 | static CREATE_NETDEV(create_pcap) |
| 72 | { |
| 73 | class netdev_pcap *dev = new netdev_pcap(ifname, ifdev, rate); |
| 74 | return dynamic_cast<netdev *>(dev); |
| 75 | } |
| 76 | |
| 77 | void init_pcap() |
| 78 | { |
| 79 | pcap_if_t *devs; |
| 80 | char errbuf[PCAP_ERRBUF_SIZE]; |
| 81 | if(pcap_findalldevs(&devs, errbuf) == -1) |
| 82 | { |
| 83 | mame_print_verbose("Unable to get network devices: %s\n", errbuf); |
| 84 | return; |
| 85 | } |
| 86 | while(devs->next) |
| 87 | { |
| 88 | add_netdev(devs->name, create_pcap); |
| 89 | devs = devs->next; |
| 90 | } |
| 91 | } |
| 92 | |
| 93 | #endif // SDLMAME_WIN32 |
src/osd/sdl/netdev_tap.c
| r13305 | r13306 | |
| 38 | 38 | |
| 39 | 39 | m_fd = -1; |
| 40 | 40 | if((m_fd = open("/dev/net/tun", O_RDWR)) == -1) { |
| 41 | | logerror("tap: open failed %d\n", errno); |
| 41 | mame_printf_verbose("tap: open failed %d\n", errno); |
| 42 | 42 | return; |
| 43 | 43 | } |
| 44 | 44 | |
| r13305 | r13306 | |
| 46 | 46 | ifr.ifr_flags = IFF_TAP | IFF_NO_PI; |
| 47 | 47 | sprintf(ifr.ifr_name, "tap-mess-%d-0", getuid()); |
| 48 | 48 | if(ioctl(m_fd, TUNSETIFF, (void *)&ifr) == -1) { |
| 49 | | logerror("tap: ioctl failed %d\n", errno); |
| 49 | mame_printf_verbose("tap: ioctl failed %d\n", errno); |
| 50 | 50 | close(m_fd); |
| 51 | 51 | m_fd = -1; |
| 52 | 52 | return; |
| 53 | 53 | } |
| 54 | mame_printf_verbose("netdev_tap: network up!\n"); |
| 54 | 55 | strncpy(m_ifname, ifr.ifr_name, 10); |
| 55 | 56 | fcntl(m_fd, F_SETFL, O_NONBLOCK); |
| 56 | 57 | |
src/osd/sdl/drawogl.c
| r13305 | r13306 | |
| 2018 | 2018 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); |
| 2019 | 2019 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
| 2020 | 2020 | |
| 2021 | | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); |
| 2022 | | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); |
| 2021 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER); |
| 2022 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER); |
| 2023 | 2023 | |
| 2024 | 2024 | pfn_glFramebufferTexture2D(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, |
| 2025 | 2025 | GL_TEXTURE_2D, text_name, 0); |
| r13305 | r13306 | |
| 2304 | 2304 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); |
| 2305 | 2305 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
| 2306 | 2306 | |
| 2307 | | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); |
| 2308 | | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); |
| 2307 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER); |
| 2308 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER); |
| 2309 | 2309 | |
| 2310 | 2310 | assert ( texture->lut_texture ); |
| 2311 | 2311 | } |
| r13305 | r13306 | |
| 2369 | 2369 | } |
| 2370 | 2370 | else |
| 2371 | 2371 | { |
| 2372 | | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); |
| 2373 | | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); |
| 2372 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER); |
| 2373 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER); |
| 2374 | 2374 | } |
| 2375 | 2375 | } else { |
| 2376 | 2376 | UINT32 * dummy = NULL; |
| r13305 | r13306 | |
| 2400 | 2400 | } |
| 2401 | 2401 | else |
| 2402 | 2402 | { |
| 2403 | | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); |
| 2404 | | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); |
| 2403 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER); |
| 2404 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER); |
| 2405 | 2405 | } |
| 2406 | 2406 | } |
| 2407 | 2407 | |
| r13305 | r13306 | |
| 2534 | 2534 | if( texture->texTarget==GL_TEXTURE_RECTANGLE_ARB ) |
| 2535 | 2535 | { |
| 2536 | 2536 | // texture rectangles can't wrap |
| 2537 | | glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_S, GL_CLAMP); |
| 2538 | | glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_T, GL_CLAMP); |
| 2537 | glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER); |
| 2538 | glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER); |
| 2539 | 2539 | } else { |
| 2540 | 2540 | // set wrapping mode appropriately |
| 2541 | 2541 | if (texture->flags & PRIMFLAG_TEXWRAP_MASK) |
| r13305 | r13306 | |
| 2545 | 2545 | } |
| 2546 | 2546 | else |
| 2547 | 2547 | { |
| 2548 | | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); |
| 2549 | | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); |
| 2548 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER); |
| 2549 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER); |
| 2550 | 2550 | } |
| 2551 | 2551 | } |
| 2552 | 2552 | } |