Previous 199869 Revisions Next

r34198 Monday 5th January, 2015 at 18:51:08 UTC by Couriersud
Merge branch 'master' of https://github.com/mamedev/mame.git
[src/emu]luaengine.c luaengine.h video.c
[src/mame]mame.mak
[src/mame/drivers]gts80a.c
[src/mame/layout]gts80a_caveman.lay*
[src/osd/windows]windows.mak

trunk/src/emu/luaengine.c
r242709r242710
1717#include "emuopts.h"
1818#include "osdepend.h"
1919#include "drivenum.h"
20#include "ui/ui.h"
2021#include "web/mongoose.h"
2122
2223//**************************************************************************
r242709r242710
336337   return 0;
337338}
338339
340int lua_engine::l_emu_set_hook(lua_State *L)
341{
342   luaThis->emu_set_hook(L);
343   return 0;
344}
345
346void lua_engine::emu_set_hook(lua_State *L)
347{
348   luaL_argcheck(L, lua_isfunction(L, 1) || lua_isnil(L, 1), 1, "callback function expected");
349   luaL_argcheck(L, lua_isstring(L, 2), 2, "message (string) expected");
350   const char *hookname = luaL_checkstring(L,2);
351
352   if (strcmp(hookname, "output") == 0) {
353      hook_output_cb.set(L, 1);
354      if (!output_notifier_set) {
355         output_set_notifier(NULL, s_output_notifier, this);
356         output_notifier_set = true;
357      }
358   } else if (strcmp(hookname, "frame") == 0) {
359      hook_frame_cb.set(L, 1);
360   } else {
361      luai_writestringerror("%s", "Unknown hook name, aborting.\n");
362   }
363}
364
339365//-------------------------------------------------
366//  machine_get_screens - return table of available screens userdata
367//  -> manager:machine().screens[":screen"]
368//-------------------------------------------------
369
370luabridge::LuaRef lua_engine::l_machine_get_screens(const running_machine *r)
371{
372   lua_State *L = luaThis->m_lua_state;
373   luabridge::LuaRef screens_table = luabridge::LuaRef::newTable(L);
374
375   for (device_t *dev = r->first_screen(); dev != NULL; dev = dev->next()) {
376      screen_device *sc = dynamic_cast<screen_device *>(dev);
377      if (sc && sc->configured() && sc->started() && sc->type()) {
378         screens_table[sc->tag()] = sc;
379      }
380   }
381
382   return screens_table;
383}
384
385//-------------------------------------------------
340386//  machine_get_devices - return table of available devices userdata
341387//  -> manager:machine().devices[":maincpu"]
342388//-------------------------------------------------
r242709r242710
438484
439485}
440486
487//-------------------------------------------------
488//  draw_box - draw a box on a screen container
489//  -> manager:machine().screens[":screen"]:draw_box(x1, y1, x2, y2, bgcolor, linecolor)
490//-------------------------------------------------
491
492int lua_engine::lua_screen::l_draw_box(lua_State *L)
493{
494   screen_device *sc = luabridge::Stack<screen_device *>::get(L, 1);
495   if(!sc) {
496      return 0;
497   }
498
499   // ensure that we got 6 numerical parameters
500   luaL_argcheck(L, lua_isnumber(L, 2), 2, "x1 (integer) expected");
501   luaL_argcheck(L, lua_isnumber(L, 3), 3, "y1 (integer) expected");
502   luaL_argcheck(L, lua_isnumber(L, 4), 4, "x2 (integer) expected");
503   luaL_argcheck(L, lua_isnumber(L, 5), 5, "y2 (integer) expected");
504   luaL_argcheck(L, lua_isnumber(L, 6), 6, "background color (integer) expected");
505   luaL_argcheck(L, lua_isnumber(L, 7), 7, "outline color (integer) expected");
506
507   // retrieve all parameters
508   float x1, y1, x2, y2;
509   x1 = MIN(lua_tounsigned(L, 2) / static_cast<float>(sc->width()) , 1.0f);
510   y1 = MIN(lua_tounsigned(L, 3) / static_cast<float>(sc->height()), 1.0f);
511   x2 = MIN(lua_tounsigned(L, 4) / static_cast<float>(sc->width()) , 1.0f);
512   y2 = MIN(lua_tounsigned(L, 5) / static_cast<float>(sc->height()), 1.0f);
513   UINT32 bgcolor = lua_tounsigned(L, 6);
514   UINT32 fgcolor = lua_tounsigned(L, 7);
515
516   // draw the box
517   render_container &rc = sc->container();
518   ui_manager &ui = sc->machine().ui();
519   ui.draw_outlined_box(&rc, x1, y1, x2, y2, fgcolor, bgcolor);
520
521   return 0;
522}
523
524//-------------------------------------------------
525//  draw_line - draw a line on a screen container
526//  -> manager:machine().screens[":screen"]:draw_line(x1, y1, x2, y2, linecolor)
527//-------------------------------------------------
528
529int lua_engine::lua_screen::l_draw_line(lua_State *L)
530{
531   screen_device *sc = luabridge::Stack<screen_device *>::get(L, 1);
532   if(!sc) {
533      return 0;
534   }
535
536   // ensure that we got 5 numerical parameters
537   luaL_argcheck(L, lua_isnumber(L, 2), 2, "x1 (integer) expected");
538   luaL_argcheck(L, lua_isnumber(L, 3), 3, "y1 (integer) expected");
539   luaL_argcheck(L, lua_isnumber(L, 4), 4, "x2 (integer) expected");
540   luaL_argcheck(L, lua_isnumber(L, 5), 5, "y2 (integer) expected");
541   luaL_argcheck(L, lua_isnumber(L, 6), 6, "color (integer) expected");
542
543   // retrieve all parameters
544   float x1, y1, x2, y2;
545   x1 = MIN(lua_tounsigned(L, 2) / static_cast<float>(sc->width()) , 1.0f);
546   y1 = MIN(lua_tounsigned(L, 3) / static_cast<float>(sc->height()), 1.0f);
547   x2 = MIN(lua_tounsigned(L, 4) / static_cast<float>(sc->width()) , 1.0f);
548   y2 = MIN(lua_tounsigned(L, 5) / static_cast<float>(sc->height()), 1.0f);
549   UINT32 color = lua_tounsigned(L, 6);
550
551   // draw the line
552   sc->container().add_line(x1, y1, x2, y2, UI_LINE_WIDTH, rgb_t(color), PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
553   return 0;
554}
555
556//-------------------------------------------------
557//  draw_text - draw text on a screen container
558//  -> manager:machine().screens[":screen"]:draw_text(x, y, message)
559//-------------------------------------------------
560
561int lua_engine::lua_screen::l_draw_text(lua_State *L)
562{
563   screen_device *sc = luabridge::Stack<screen_device *>::get(L, 1);
564   if(!sc) {
565      return 0;
566   }
567
568   // ensure that we got proper parameters
569   luaL_argcheck(L, lua_isnumber(L, 2), 2, "x (integer) expected");
570   luaL_argcheck(L, lua_isnumber(L, 3), 3, "y (integer) expected");
571   luaL_argcheck(L, lua_isstring(L, 4), 4, "message (string) expected");
572
573   // retrieve all parameters
574   float x = MIN(lua_tounsigned(L, 2) / static_cast<float>(sc->width()) , 1.0f);
575   float y = MIN(lua_tounsigned(L, 3) / static_cast<float>(sc->height()), 1.0f);
576   const char *msg = luaL_checkstring(L,4);
577   // TODO: add optional parameters (colors, etc.)
578
579   // draw the text
580   render_container &rc = sc->container();
581   ui_manager &ui = sc->machine().ui();
582   ui.draw_text_full(&rc, msg, x, y , (1.0f - x),
583                  JUSTIFY_LEFT, WRAP_WORD, DRAW_NORMAL, UI_TEXT_COLOR,
584                  UI_TEXT_BG_COLOR, NULL, NULL);
585
586   return 0;
587}
588
441589void *lua_engine::checkparam(lua_State *L, int idx, const char *tname)
442590{
443591   const char *name;
r242709r242710
650798         .addCFunction ("romname",     l_emu_romname )
651799         .addCFunction ("keypost",     l_emu_keypost )
652800         .addCFunction ("hook_output", l_emu_hook_output )
801         .addCFunction ("sethook",     l_emu_set_hook )
653802         .addCFunction ("time",        l_emu_time )
654803         .addCFunction ("wait",        l_emu_wait )
655804         .addCFunction ("after",       l_emu_after )
r242709r242710
667816            .addFunction ("soft_reset", &running_machine::schedule_soft_reset)
668817            .addFunction ("system", &running_machine::system)
669818            .addProperty <luabridge::LuaRef, void> ("devices", &lua_engine::l_machine_get_devices)
819            .addProperty <luabridge::LuaRef, void> ("screens", &lua_engine::l_machine_get_screens)
670820         .endClass ()
671821         .beginClass <game_driver> ("game_driver")
672822            .addData ("name", &game_driver::name)
r242709r242710
691841         .deriveClass <address_space, lua_addr_space> ("addr_space")
692842            .addFunction("name", &address_space::name)
693843         .endClass()
694      .endNamespace ();
844         .beginClass <lua_screen> ("lua_screen_dev")
845            .addCFunction ("draw_box",  &lua_screen::l_draw_box)
846            .addCFunction ("draw_line", &lua_screen::l_draw_line)
847            .addCFunction ("draw_text", &lua_screen::l_draw_text)
848         .endClass()
849         .deriveClass <screen_device, lua_screen> ("screen_dev")
850            .addFunction ("name", &screen_device::name)
851            .addFunction ("height", &screen_device::height)
852            .addFunction ("width", &screen_device::width)
853         .endClass()
854      .endNamespace();
695855
696856   luabridge::push (m_lua_state, machine_manager::instance());
697857   lua_setglobal(m_lua_state, "manager");
r242709r242710
702862   mg_start_thread(::serve_lua, this);
703863}
704864
865//-------------------------------------------------
866//  frame_hook - called at each frame refresh, used to draw a HUD
867//-------------------------------------------------
868bool lua_engine::frame_hook()
869{
870   bool is_cb_hooked = false;
871   if (m_machine != NULL) {
872      // invoke registered callback (if any)
873      is_cb_hooked = hook_frame_cb.active();
874      if (is_cb_hooked) {
875         lua_State *L = hook_frame_cb.precall();
876         hook_frame_cb.call(this, L, 0);
877      }
878   }
879   return is_cb_hooked;
880}
881
705882void lua_engine::periodic_check()
706883{
707884   osd_lock_acquire(lock);
trunk/src/emu/luaengine.h
r242709r242710
4444
4545   void serve_lua();
4646   void periodic_check();
47   bool frame_hook();
4748
4849   void resume(lua_State *L, int nparam = 0, lua_State *root = NULL);
4950   void set_machine(running_machine *machine) { m_machine = machine; update_machine(); }
r242709r242710
6869   hook hook_output_cb;
6970   bool output_notifier_set;
7071
72   hook hook_frame_cb;
73
7174   static lua_engine*  luaThis;
7275
7376   std::map<lua_State *, std::pair<lua_State *, int> > thread_registry;
r242709r242710
8285   int emu_after(lua_State *L);
8386   int emu_wait(lua_State *L);
8487   void emu_hook_output(lua_State *L);
88   void emu_set_hook(lua_State *L);
8589
8690   static int l_ioport_write(lua_State *L);
8791   static int l_emu_after(lua_State *L);
r242709r242710
97101   static int l_emu_start(lua_State *L);
98102   static int l_emu_pause(lua_State *L);
99103   static int l_emu_unpause(lua_State *L);
104   static int l_emu_set_hook(lua_State *L);
100105
101106   // "emu.machine" namespace
102107   static luabridge::LuaRef l_machine_get_devices(const running_machine *r);
r242709r242710
105110   struct lua_addr_space {
106111      template<typename T> int l_mem_read(lua_State *L);
107112   };
113   static luabridge::LuaRef l_machine_get_screens(const running_machine *r);
114   struct lua_screen {
115      int l_draw_box(lua_State *L);
116      int l_draw_line(lua_State *L);
117      int l_draw_text(lua_State *L);
118   };
108119
109120   void resume(void *L, INT32 param);
110121   void report_errors(int status);
trunk/src/emu/video.c
r242709r242710
655655      if (screen->update_quads())
656656         anything_changed = true;
657657
658   // draw HUD from LUA callback (if any)
659   anything_changed |= machine().manager().lua()->frame_hook();
660
658661   // update our movie recording and burn-in state
659662   if (!machine().paused())
660663   {
trunk/src/mame/drivers/gts80a.c
r242709r242710
1515#include "audio/gottlieb.h"
1616#include "cpu/i86/i86.h"
1717#include "gts80a.lh"
18#include "gts80a_caveman.lh"
1819
1920class gts80a_state : public genpin_class
2021{
r242709r242710
384385   caveman_state(const machine_config &mconfig, device_type type, const char *tag)
385386      : gts80a_state(mconfig, type, tag)
386387      , m_videocpu(*this, "video_cpu")
388      , m_vram(*this, "vram")
389
387390   { }
388391
392
393   UINT32 screen_update_caveman(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
394
389395private:
390396   required_device<cpu_device> m_videocpu;
397   required_shared_ptr<UINT8> m_vram;
391398};
392399
400UINT32 caveman_state::screen_update_caveman(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
401{
402   int count = 0;
403   for (int y = 0; y < 256; y++)
404   {
405      for (int x = 0; x < 256; x += 4)
406      {
407         UINT8 pix = m_vram[count];
408
409         bitmap.pix16(y, x+0) = (pix >> 6)&0x3;
410         bitmap.pix16(y, x+1) = (pix >> 4)&0x3;
411         bitmap.pix16(y, x+2) = (pix >> 2)&0x3;
412         bitmap.pix16(y, x+3) = (pix >> 0)&0x3;
413
414         count++;
415      }
416   }
417
418   return 0;
419}
420
421
393422static ADDRESS_MAP_START( video_map, AS_PROGRAM, 8, caveman_state )
394423   ADDRESS_MAP_GLOBAL_MASK(0xffff)
395   AM_RANGE(0x0000, 0x5fff) AM_RAM
424   AM_RANGE(0x0000, 0x07ff) AM_RAM
425   AM_RANGE(0x2000, 0x5fff) AM_RAM AM_SHARE("vram")
396426   AM_RANGE(0x8000, 0xffff) AM_ROM
397427ADDRESS_MAP_END
398428
399429static ADDRESS_MAP_START( video_io_map, AS_IO, 8, caveman_state )
430//   AM_RANGE(0x000, 0x002) AM_READWRITE() // 8259 irq controller
431//   AM_RANGE(0x100, 0x102) AM_READWRITE() // HD46505
432//   AM_RANGE(0x200, 0x200) AM_READWRITE() // 8212 in, ?? out
433//   AM_RANGE(0x300, 0x300) AM_READWRITE() // soundlatch (command?) in, ?? out
434
435//   AM_RANGE(0x400, 0x400) AM_READ() // joystick inputs
436//   AM_RANGE(0x500, 0x506) AM_WRITE() // palette
437
400438ADDRESS_MAP_END
401439
402static MACHINE_CONFIG_DERIVED( caveman, gts80a_ss )
440static MACHINE_CONFIG_DERIVED_CLASS( caveman, gts80a_ss, caveman_state )
403441   MCFG_CPU_ADD("video_cpu", I8088, 5000000)
404442   MCFG_CPU_PROGRAM_MAP(video_map)
405443   MCFG_CPU_IO_MAP(video_io_map)
444
445   MCFG_SCREEN_ADD("screen", RASTER)
446   MCFG_SCREEN_REFRESH_RATE(60)
447   MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0))
448   MCFG_SCREEN_SIZE(256, 256)
449   MCFG_SCREEN_VISIBLE_AREA(0, 256-1, 0, 248-1)
450   MCFG_SCREEN_UPDATE_DRIVER(caveman_state, screen_update_caveman)
451   MCFG_SCREEN_PALETTE("palette")
452
453   MCFG_PALETTE_ADD("palette", 16)
454
455   MCFG_DEFAULT_LAYOUT(layout_gts80a_caveman)
456
406457MACHINE_CONFIG_END
407458
408459static INPUT_PORTS_START( caveman )
trunk/src/mame/layout/gts80a_caveman.lay
r0r242710
1<!-- GTS80A copied from gts80.lay -->
2
3<!-- 2014-10-10: Initial version.  [Robbbert] -->
4
5<mamelayout version="2">
6
7   <element name="digit" defstate="0">
8      <led14seg>
9         <color red="0.0" green="0.75" blue="1.0" />
10      </led14seg>
11   </element>
12   <element name="digit7" defstate="0">
13      <led7seg>
14         <color red="0.0" green="0.75" blue="1.0" />
15      </led7seg>
16   </element>
17   <element name="red_led">
18      <disk><color red="1.0" green="0.0" blue="0.0" /></disk>
19   </element>
20   <element name="background">
21      <rect>
22         <bounds left="0" top="0" right="1" bottom="1" />
23         <color red="0.0" green="0.0" blue="0.0" />
24      </rect>
25   </element>
26   <element name="P0"><text string="Ball / Match"><color red="1.0" green="1.0" blue="1.0" /></text></element>
27   <element name="P1"><text string="Credits"><color red="1.0" green="1.0" blue="1.0" /></text></element>
28   <element name="P3"><text string="Player 1"><color red="1.0" green="1.0" blue="1.0" /></text></element>
29   <element name="P4"><text string="Player 2"><color red="1.0" green="1.0" blue="1.0" /></text></element>
30   <element name="P5"><text string="Player 3"><color red="1.0" green="1.0" blue="1.0" /></text></element>
31   <element name="P6"><text string="Player 4"><color red="1.0" green="1.0" blue="1.0" /></text></element>
32
33   <view name="Default Layout">
34
35      <!-- Background -->
36      <backdrop element="background">
37         <bounds left="0" top="20" right="318" bottom="394" />
38      </backdrop>
39
40      <!-- LEDs -->
41
42      <!-- Player 1 Score -->
43
44      <bezel name="digit15" element="digit">
45         <bounds left="10" top="45" right="44" bottom="84" />
46      </bezel>
47      <bezel name="digit5" element="digit">
48         <bounds left="54" top="45" right="88" bottom="84" />
49      </bezel>
50      <bezel name="digit4" element="digit">
51         <bounds left="98" top="45" right="132" bottom="84" />
52      </bezel>
53      <bezel name="digit3" element="digit">
54         <bounds left="142" top="45" right="176" bottom="84" />
55      </bezel>
56      <bezel name="digit2" element="digit">
57         <bounds left="186" top="45" right="220" bottom="84" />
58      </bezel>
59      <bezel name="digit1" element="digit">
60         <bounds left="230" top="45" right="264" bottom="84" />
61      </bezel>
62      <bezel name="digit0" element="digit">
63         <bounds left="274" top="45" right="308" bottom="84" />
64      </bezel>
65
66      <!-- Player 2 Score -->
67      <bezel name="digit12" element="digit">
68         <bounds left="10" top="105" right="44" bottom="144" />
69      </bezel>
70      <bezel name="digit11" element="digit">
71         <bounds left="54" top="105" right="88" bottom="144" />
72      </bezel>
73      <bezel name="digit10" element="digit">
74         <bounds left="98" top="105" right="132" bottom="144" />
75      </bezel>
76      <bezel name="digit9" element="digit">
77         <bounds left="142" top="105" right="176" bottom="144" />
78      </bezel>
79      <bezel name="digit8" element="digit">
80         <bounds left="186" top="105" right="220" bottom="144" />
81      </bezel>
82      <bezel name="digit7" element="digit">
83         <bounds left="230" top="105" right="264" bottom="144" />
84      </bezel>
85      <bezel name="digit6" element="digit">
86         <bounds left="274" top="105" right="308" bottom="144" />
87      </bezel>
88
89      <!-- Player 3 Score -->
90      <bezel name="digit35" element="digit">
91         <bounds left="10" top="165" right="44" bottom="204" />
92      </bezel>
93      <bezel name="digit25" element="digit">
94         <bounds left="54" top="165" right="88" bottom="204" />
95      </bezel>
96      <bezel name="digit24" element="digit">
97         <bounds left="98" top="165" right="132" bottom="204" />
98      </bezel>
99      <bezel name="digit23" element="digit">
100         <bounds left="142" top="165" right="176" bottom="204" />
101      </bezel>
102      <bezel name="digit22" element="digit">
103         <bounds left="186" top="165" right="220" bottom="204" />
104      </bezel>
105      <bezel name="digit21" element="digit">
106         <bounds left="230" top="165" right="264" bottom="204" />
107      </bezel>
108      <bezel name="digit20" element="digit">
109         <bounds left="274" top="165" right="308" bottom="204" />
110      </bezel>
111
112      <!-- Player 4 Score -->
113      <bezel name="digit32" element="digit">
114         <bounds left="10" top="225" right="44" bottom="264" />
115      </bezel>
116      <bezel name="digit31" element="digit">
117         <bounds left="54" top="225" right="88" bottom="264" />
118      </bezel>
119      <bezel name="digit30" element="digit">
120         <bounds left="98" top="225" right="132" bottom="264" />
121      </bezel>
122      <bezel name="digit29" element="digit">
123         <bounds left="142" top="225" right="176" bottom="264" />
124      </bezel>
125      <bezel name="digit28" element="digit">
126         <bounds left="186" top="225" right="220" bottom="264" />
127      </bezel>
128      <bezel name="digit27" element="digit">
129         <bounds left="230" top="225" right="264" bottom="264" />
130      </bezel>
131      <bezel name="digit26" element="digit">
132         <bounds left="274" top="225" right="308" bottom="264" />
133      </bezel>
134
135      <!-- Credits and Balls -->
136      <bezel name="digit55" element="digit7">
137         <bounds left="30" top="345" right="64" bottom="384" />
138      </bezel>
139      <bezel name="digit54" element="digit7">
140         <bounds left="69" top="345" right="103" bottom="384" />
141      </bezel>
142      <bezel name="digit53" element="digit7">
143         <bounds left="171" top="345" right="205" bottom="384" />
144      </bezel>
145      <bezel name="digit52" element="digit7">
146         <bounds left="210" top="345" right="244" bottom="384" />
147      </bezel>
148      <bezel element="P0"><bounds left="200" right="258" top="330" bottom="342" /></bezel>
149      <bezel element="P1"><bounds left="50" right="108" top="330" bottom="342" /></bezel>
150      <bezel name="text3" element="P3"><bounds left="100" right="180" top="30" bottom="42" /></bezel>
151      <bezel name="text2" element="P4"><bounds left="100" right="180" top="90" bottom="102" /></bezel>
152      <bezel name="text1" element="P5"><bounds left="100" right="180" top="150" bottom="162" /></bezel>
153      <bezel name="text0" element="P6"><bounds left="100" right="180" top="210" bottom="222" /></bezel>
154   
155      <screen index="0">
156         <bounds x="320" y="0" width="320" height="240" />
157      </screen>
158    </view>
159</mamelayout>
trunk/src/mame/mame.mak
r242709r242710
26612661$(DRIVERS)/gts1.o:      $(LAYOUT)/gts1.lh
26622662$(DRIVERS)/gts3.o:      $(LAYOUT)/gts3.lh
26632663$(DRIVERS)/gts80.o:     $(LAYOUT)/gts80.lh
2664$(DRIVERS)/gts80a.o:    $(LAYOUT)/gts80a.lh
2664$(DRIVERS)/gts80a.o:    $(LAYOUT)/gts80a.lh \
2665         $(LAYOUT)/gts80a_caveman.lh
26652666$(DRIVERS)/gts80b.o:    $(LAYOUT)/gts80b.lh
26662667
26672668$(DRIVERS)/lbeach.o:    $(LAYOUT)/lbeach.lh
trunk/src/osd/windows/windows.mak
r242709r242710
302302include $(SRC)/build/cc_detection.mak
303303
304304# ensure we statically link the gcc runtime lib
305LDFLAGS += -static-libgcc -static
305LDFLAGS += -static-libgcc
306306
307ifeq ($(CROSS_BUILD),1)
308   LDFLAGS += -static
309endif   
310
307311# TODO: needs to use $(CC)
308312TEST_GCC := $(shell gcc --version)
309313ifeq ($(findstring 4.4.,$(TEST_GCC)),)


Previous 199869 Revisions Next


© 1997-2024 The MAME Team