Active Threads | Active Posts | Unanswered Today | Since Yesterday | This Week
MAME
04/21/19 09:41 AM
I wanted to see if I could control the ioports for the joystick and after much fiddling and adding some code to luaengine and ioports.h and ioports.cpp I think I've got it.

Yes, it's a bit of a hack, but it's pretty useful to be able to precisely control an anlog input.

So now I can draw spirals with the graphics tablet:

Code
function spiral()
for i=16384,16384+8192-1 do manager:machine().devices[":maincpu"].spaces["program"]:write_u8(i,0) end
for i=0,256*16,1 do 
x=math.cos(i/256.0*math.pi*2.0)*i/256.0*8.0*1024
y=math.sin(i/256.0*math.pi*2.0)*i/256.0*8.0*1024
ioports=manager:machine():ioport().ports ioports[":sl2:agraphtablet:joystick_3_x"].fields["P3 Joystick X"].live:set_analog_value(math.floor(x),math.floor(x),0)
ioports=manager:machine():ioport().ports ioports[":sl2:agraphtablet:joystick_3_y"].fields["P3 Joystick Y"].live:set_analog_value(math.floor(y),math.floor(y),0)
print (i,x,y,ioports[":sl2:agraphtablet:joystick_3_x"]:read(),ioports[":sl2:agraphtablet:joystick_3_y"]:read())
emu.wait(1/60+.001) 
print (i,x,y,ioports[":sl2:agraphtablet:joystick_3_x"]:read(),ioports[":sl2:agraphtablet:joystick_3_y"]:read())
end 
end
co1=coroutine.create(spiral) ok,err=coroutine.resume(co1) print(ok,err)



I wrote a function set_analog_value that just stuffs values into m_accum and m_previousvalue for the live ioport analog member. m_previousanalog doesn't seem to have any effect.

Code
       // live analog value tracking
        s32                 m_accum;                // accumulated value (including relative adjustments)
        s32                 m_previous;             // previous adjusted value
        s32                 m_previousanalog;       // previous analog value


In ioport.h

Code
struct ioport_field_live
{
        // construction/destruction
        ioport_field_live(ioport_field &field, analog_field *analog);

        void set_value(ioport_value newvalue) {value = newvalue;};
        void set_analog_value(s32 newaccumvalue, s32 newpreviousvalue, s32 newpreviousanalogvalue);




In ioport.cpp

Code
void ioport_field_live::set_analog_value(s32 newaccumvalue, s32 newpreviousvalue, s32 newpreviousanalogvalue)
   {analog->set_accum(newaccumvalue); analog->set_previous(newpreviousvalue); analog->set_previousanalog(newpreviousanalogvalue);}


Just added set_accum, set_previous and set_previousanalog to class analog field:

Code
// ======================> analog_field

// live analog field information
class analog_field
{
        friend class simple_list<analog_field>;
        friend class ioport_manager;
        friend void ioport_field::set_user_settings(const ioport_field::user_settings &settings);

public:
        // construction/destruction
        analog_field(ioport_field &field);

        // getters
        analog_field *next() const { return m_next; }
        ioport_manager &manager() const { return m_field.manager(); }
        ioport_field &field() const { return m_field; }
        s32 sensitivity() const { return m_sensitivity; }
        bool reverse() const { return m_reverse; }
        s32 delta() const { return m_delta; }
        s32 centerdelta() const { return m_centerdelta; }

        // readers
        void read(ioport_value &value);
        float crosshair_read();
        void frame_update(running_machine &machine);

        void set_accum(s32 newvalue){m_accum=newvalue;};
        void set_previous(s32 newvalue){m_previous=newvalue;};
        void set_previousanalog(s32 newvalue){m_previousanalog=newvalue;};



In luaengine.cpp

Code
/* field.live
 */

	sol().registry().new_usertype<ioport_field_live>("ioport_field_live", "new", sol::no_constructor,
                        "set_value", &ioport_field_live::set_value,
                        "set_analog_value", &ioport_field_live::set_analog_value,		
			"name", &ioport_field_live::name,
                        "value", &ioport_field_live::value);


It kinda looks like a fingerprint.


[Linked Image]
329 48,959 Read More
MAME
04/21/19 08:22 AM
It looks like a ROM. Are you in a position to dump it?
42 1,578 Read More
QMC2
04/20/19 11:36 PM
René, good to hear that your health is improving. Top priority should be to care for yourself now and to be patient.
Sounds helpless and boring and certainly it is. I had to pause MAME development for a long time to support my wife. Still fighting but when things calmed down I was able to return. Take your time and fight. All the best.
3 281 Read More
MAME
04/20/19 02:39 PM
BGFX on Windows will generally use D3D11 by default, which may be part of the difference. (It's why BGFX works on a clean Win10 install when default MAME will just die).
4 161 Read More
Who's Online Now
5 registered members (Vas Crabb, Pernod, shattered, Heihachi_73, 1 invisible), 130 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Shout Box
Forum Statistics
Forums9
Topics8,645
Posts113,200
Members4,842
Most Online324
Dec 20th, 2018
Powered by UBB.threads™ PHP Forum Software 7.6.1.1
(Release build 20180111)
Page Time: 0.018s Queries: 6 (0.007s) Memory: 5.0071 MB (Peak: 5.1058 MB) Zlib enabled. Server Time: 2019-04-21 12:36:00 UTC