Previous 199869 Revisions Next

r41769 Wednesday 18th November, 2015 at 18:30:36 UTC by Miodrag Milanović
Revert "No need for simple_list_wrapper (nw)"

This reverts commit 9cf26a0f698b9c6b17ed24e27199f50b8be1514a.
[src/emu]ioport.cpp ioport.h
[src/lib/util]coretmpl.h

trunk/src/emu/ioport.cpp
r250280r250281
744744digital_joystick::direction_t digital_joystick::add_axis(ioport_field &field)
745745{
746746   direction_t direction = direction_t((field.type() - (IPT_DIGITAL_JOYSTICK_FIRST + 1)) % 4);
747   m_field[direction].append(field);
747   m_field[direction].append(*global_alloc(simple_list_wrapper<ioport_field>(&field)));
748748   return direction;
749749}
750750
r250280r250281
764764   // read all the associated ports
765765   running_machine *machine = NULL;
766766   for (direction_t direction = JOYDIR_UP; direction < JOYDIR_COUNT; ++direction)
767      for (const ioport_field *i = m_field[direction].first(); i != NULL; i = i->next())
767      for (const simple_list_wrapper<ioport_field> *i = m_field[direction].first(); i != NULL; i = i->next())
768768      {
769         machine = &i->machine();
770         if (machine->input().seq_pressed(i->seq(SEQ_TYPE_STANDARD)))
769         machine = &i->object()->machine();
770         if (machine->input().seq_pressed(i->object()->seq(SEQ_TYPE_STANDARD)))
771771            m_current |= 1 << direction;
772772      }
773773
trunk/src/emu/ioport.h
r250280r250281
792792   digital_joystick *          m_next;                                         // next joystick in the list
793793   int                         m_player;                                       // player number represented
794794   int                         m_number;                                       // joystick number represented
795   simple_list<ioport_field> m_field[JOYDIR_COUNT];  // potential input fields for each direction
795   simple_list<simple_list_wrapper<ioport_field> > m_field[JOYDIR_COUNT];  // potential input fields for each direction
796796   UINT8                       m_current;                                      // current value
797797   UINT8                       m_current4way;                                  // current 4-way value
798798   UINT8                       m_previous;                                     // previous value
trunk/src/lib/util/coretmpl.h
r250280r250281
277277   int             m_count;        // number of objects in the list
278278};
279279
280
281// ======================> simple_list_wrapper
282
283// a simple_list_wrapper wraps an existing object with a next pointer so it
284// can live in a simple_list without requiring the object to have a next
285// pointer
286template<class _ObjectType>
287class simple_list_wrapper
288{
289public:
290   template<class U> friend class simple_list;
291
292   // construction/destruction
293   simple_list_wrapper(_ObjectType *object)
294      : m_next(NULL),
295         m_object(object) { }
296
297   // operators
298   operator _ObjectType *() { return m_object; }
299   operator _ObjectType *() const { return m_object; }
300   _ObjectType *operator *() { return m_object; }
301   _ObjectType *operator *() const { return m_object; }
302
303   // getters
304   simple_list_wrapper *next() const { return m_next; }
305   _ObjectType *object() const { return m_object; }
306
307private:
308   // internal state
309   simple_list_wrapper *   m_next;
310   _ObjectType *           m_object;
311};
312
313
280314// ======================> fixed_allocator
281315
282316// a fixed_allocator is a simple class that maintains a free pool of objects


Previous 199869 Revisions Next


© 1997-2024 The MAME Team