GithubHelp home page GithubHelp logo

bazz1tv / mednafen-graffiti Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 3.0 23.84 MB

Bazz's Graffiti Netplay Enhancement for Mednafen

License: GNU General Public License v2.0

Makefile 0.17% Shell 1.24% C 7.48% C++ 89.74% Yacc 0.03% Assembly 0.21% SourcePawn 0.04% PHP 0.30% CMake 0.01% HTML 0.01% M4 0.77% sed 0.01% NASL 0.01% Pawn 0.01%
graffiti graffiti-netplay mednafen emulation netplay

mednafen-graffiti's Introduction

Graffiti Netplay Enhancement

Graffiti allows you to draw on the surface of your game. It can be used locally or during netplay. It is intended to be a fun addition to the netplay experience.

graffiti gameplay example

Trying it out

First you'll need a binary of this software. That likely means you'll have to build it yourself. See the Building section below.

Once you've opened a ROM up (eg. mednafen mario.smc), you can immediately begin testing the graffiti feature! Now, it's most fun with a friend online, but you can run it locally too.

Testing locally

First, press 't' to get a console prompt, then type /g on to enable graffiti mode. Now, when your mouse is over the game screen, you see a black square. You can now do the following:

  • Left-Click and Drag: Draw
  • Mouse Wheel: Change brush size
  • Right-Click and Drag: Erase

Playing Online

Make sure that both you and your buddy have Graffiti, and an identical copy of the game you're gonna play. Once you open the rom up, press 't' to get a console prompt, then type /connect to connect to mednafen's server. Once connected, the graffiti feature will automatically become activated. Once your friend joins the game, you can use 't' to chat with each other, and also have fun playing with graffiti together!

Building

When building directly from git, run the following commands from the project directory:

aclocal -I .; autoconf; automake --add-missing -c
./configure
make
sudo make install

About The Implementation

When I aspired to create the graffiti feature, I knew for it to be successful, it had to simply work with the pre-existing netplay servers. This meant opting for an implementation that takes place completely over the client. By having it done this way, there was no need to require a custom server. It just worked.

mednafen-graffiti's People

Contributors

bazz1tv avatar

Stargazers

 avatar

Watchers

 avatar

mednafen-graffiti's Issues

[graffiti] F9 screenshot weirdness

lazias can capture graffiti in his F9 screenshots, but I can't. I even tried using his mednafen config file, which did not help at all. But did the config file load properly, I'm not even sure!

cursor idea

default icon is the line tool, when u start drawing it disappears.. when u release it comes back.

eraser tool will be back to being 1x scale of linetool. when you right-click, the eraser icon will reveal, and when u release, it should go back to the former icon (line tool).

resize eraser while it's active

while right-click button is held, be able to resize the eraser via the scrollwheel

problem: as of now, if you try do the the above actions, the tool reverts back to (an inactive) line_tool

"color changing pen"

what you draw with this pen will cycle through a (predefined | random) set of colors

[netplay] Graffiti

<zeromus> you know what would be fun is if you could draw graffiti on a netplay session

This is a contribution that should be made to the latest official mednafen release (not this repo) - but it's here for posterity.

Impl Notes

looking at the following functions to assist this impl:

MDFNI_NetplayText
SendCommand(MDFNNPCMD_TEXT, len, text);

This is the command that is used to send chat messages back and forth between the clients.

These commands are received in netplay.cpp case MDFNNPCMD_TEXT, and add some processing to them.... The draw commands should be prefixed with a non-printable ASCII byte or short sequence to decipher them from normal chat commands and/or allow room for other commands to be reserved. draw commands must not be printed to screen.

Sending commands will be done from input.cpp void Input_Event(const SDL_Event *event) I believe.

One could have a layer specifically for the graffiti that would be drawn last upon other layers that mednafen draws to.

Respond to mouse click and drag events such that pixels are plotted to the screen with random colors (see https://github.com/amatus/sdl-examples/blob/master/paint/paint.c)

  • Clear your drawings
  • Clear opponent's drawings
  • Clear all drawings

Unhandled Conflicts

  • a game that uses the "mouse as a controller"

Later Features

/grafitti [on/off] - a command to turn the mode on and off.. this basically enables the SDL surfaces and mouse event handling / msg sending.

  • no unhandled conflicts
  • thickness specifier (which implies a "graffiti GUI"
  • "MS-Paint" features? (eg. spray paint)

Commands

/g toggles on/off (impl'd)
/g [on/off] (impl'd)
/g clear (impl'd LOCALLY ONLY)


/g color [random | red | green | blue]
/g color #000fff
/g text wow!
/g textsize 12

Other Todo

  • proper mouse alignment โœ…
    • but it doesn't use the mouse scale/offset variables (not sure it's necessary, don't know how to test it!)
  • don't interfere with games that use the mouse~

Iterate through PIDC, iterate through BIC of PIDC, iterate through BC of BIC of PIDC looking at the butt type to see if it's BUTTC_MOUSE

when its enabled, graffiti takes the mouse instead of the zapper

  • sync surfaces when netplay client(s) connect. __ How can I express surface data over the network? Try upscaling surface data to highest surface bit-width .. send over network, downgrade as necessary
  • clear the surface when the session ends (or not..?)
  • clean up "dirty init" (I thought i saw some doodle processing at bootup)
  • refactor "static global" deps (OurNick)
  • fullscreen support
  • show up on video recordings (-qtrecord)

    Notes

    Rypecha is the only mednafen coder

[graffiti] sync on join

Goal

Implement the sync without a need to alter server code

Notes

YOUJOINED / PLAYERJOINED messages can arrive in either order when you join the server.

This sequence of operations maybe is reliable.

REQUEST_STATE
PLAYER JOINED
LOADSTATE

while non-request clients see

PLAYER JOINED
LOADSTATE

tested on local machine.. it is possible that the events could arrive in different orders. I have not verified it, and am not sure how to.

Impl

When a client joins the game, ONE of the other clients is (decided by server) asked to supply state information in the case MDFNNPCMD_REQUEST_STATE:

Then ALL clients receive a MDFNNPCMD_LOADSTATE

There must be a way to add logic into these case processors to have the client whose state has been requested also be the client to broadcast the current graffiti surface. We may also be able to use the same compression function that is used on the state!

Pseudo code (doesn't include pre-existing case handler code

case MDFNNPCMD_REQUEST_STATE:
  ...
  // set boolean in Graffiti that this client will broadcast graffiti surface on next LOADSTATE event


case MDFNNPCMD_LOADSTATE:
  ...
  // broadcast compressed graffiti surface in an impl-agnostic format.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.