~ubuntu-branches/debian/sid/mame/sid

« back to all changes in this revision

Viewing changes to src/emu/rendlay.c

  • Committer: Package Import Robot
  • Author(s): Jordi Mallach, Emmanuel Kasper, Jordi Mallach
  • Date: 2012-06-05 20:02:23 UTC
  • mfrom: (0.3.1) (0.1.4)
  • Revision ID: package-import@ubuntu.com-20120605200223-gnlpogjrg6oqe9md
Tags: 0.146-1
[ Emmanuel Kasper ]
* New upstream release
* Drop patch to fix man pages section and patches to link with flac 
  and jpeg system lib: all this has been pushed upstream by Cesare Falco
* Add DM-Upload-Allowed: yes field.

[ Jordi Mallach ]
* Create a "gnu" TARGETOS stanza that defines NO_AFFINITY_NP.
* Stop setting TARGETOS to "unix" in d/rules. It should be autodetected,
  and set to the appropriate value.
* mame_manpage_section.patch: Change mame's manpage section to 6 (games),
  in the TH declaration.

Show diffs side-by-side

added added

removed removed

Lines of Context:
81
81
#include "rendfont.h"
82
82
#include "rendlay.h"
83
83
#include "rendutil.h"
84
 
#include "output.h"
85
84
#include "xmlfile.h"
86
85
#include "png.h"
87
86
 
483
482
                        m_maxstate = 262143;
484
483
                if (newcomp.m_type == component::CTYPE_DOTMATRIX)
485
484
                        m_maxstate = 255;
 
485
                if (newcomp.m_type == component::CTYPE_DOTMATRIX5DOT)
 
486
                        m_maxstate = 31;
 
487
                if (newcomp.m_type == component::CTYPE_DOTMATRIXDOT)
 
488
                        m_maxstate = 1;
 
489
                        if (newcomp.m_type == component::CTYPE_SIMPLECOUNTER)
 
490
                {
 
491
                        m_maxstate = xml_get_attribute_int_with_subst(machine, *compnode, "maxstate", 999);
 
492
                }
 
493
                if (newcomp.m_type == component::CTYPE_REEL)
 
494
                {
 
495
                        m_maxstate = 65536;
 
496
                }
486
497
        }
487
498
 
488
499
        // determine the scale/offset for normalization
602
613
layout_element::component::component(running_machine &machine, xml_data_node &compnode, const char *dirname)
603
614
        : m_next(NULL),
604
615
          m_type(CTYPE_INVALID),
605
 
          m_state(0),
606
 
          m_file(NULL),
607
 
          m_hasalpha(false)
 
616
          m_state(0)
608
617
{
 
618
        for (int i=0;i<MAX_BITMAPS;i++)
 
619
        {
 
620
                m_hasalpha[i] = false;
 
621
                m_file[i] = NULL;
 
622
        }
 
623
 
 
624
 
 
625
 
609
626
        // fetch common data
610
627
        m_state = xml_get_attribute_int_with_subst(machine, compnode, "state", -1);
611
628
        parse_bounds(machine, xml_get_sibling(compnode.child, "bounds"), m_bounds);
616
633
        {
617
634
                m_type = CTYPE_IMAGE;
618
635
                m_dirname = dirname;
619
 
                m_imagefile = xml_get_attribute_string_with_subst(machine, compnode, "file", "");
620
 
                m_alphafile = xml_get_attribute_string_with_subst(machine, compnode, "alphafile", "");
621
 
                m_file = global_alloc(emu_file(machine.options().art_path(), OPEN_FLAG_READ));
 
636
                m_imagefile[0] = xml_get_attribute_string_with_subst(machine, compnode, "file", "");
 
637
                m_alphafile[0] = xml_get_attribute_string_with_subst(machine, compnode, "alphafile", "");
 
638
                m_file[0] = global_alloc(emu_file(machine.options().art_path(), OPEN_FLAG_READ));
622
639
        }
623
640
 
624
641
        // text nodes
626
643
        {
627
644
                m_type = CTYPE_TEXT;
628
645
                m_string = xml_get_attribute_string_with_subst(machine, compnode, "string", "");
 
646
                m_textalign = xml_get_attribute_int_with_subst(machine, compnode, "align", 0);
629
647
        }
630
648
 
631
649
        // dotmatrix nodes
632
650
        else if (strcmp(compnode.name, "dotmatrix") == 0)
 
651
        {
633
652
                m_type = CTYPE_DOTMATRIX;
634
 
 
 
653
        }
 
654
        else if (strcmp(compnode.name, "dotmatrix5dot") == 0)
 
655
        {
 
656
                m_type = CTYPE_DOTMATRIX5DOT;
 
657
        }
 
658
        else if (strcmp(compnode.name, "dotmatrixdot") == 0)
 
659
        {
 
660
                m_type = CTYPE_DOTMATRIXDOT;
 
661
        }
 
662
        // simplecounter nodes
 
663
        else if (strcmp(compnode.name, "simplecounter") == 0)
 
664
        {
 
665
                m_type = CTYPE_SIMPLECOUNTER;
 
666
                m_digits = xml_get_attribute_int_with_subst(machine, compnode, "digits", 2);
 
667
        }
 
668
        // fruit machine reels
 
669
        else if (strcmp(compnode.name, "reel") == 0)
 
670
        {
 
671
                m_type = CTYPE_REEL;
 
672
 
 
673
                astring symbollist = xml_get_attribute_string_with_subst(machine, compnode, "symbollist", "0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15");
 
674
 
 
675
                // split out position names from string and figure out our number of symbols
 
676
                int location = -1;
 
677
                m_numstops = 0;
 
678
                location=symbollist.find(0,",");
 
679
                while (location!=-1)
 
680
                {
 
681
                        m_stopnames[m_numstops] = symbollist;
 
682
                        m_stopnames[m_numstops].substr(0, location);
 
683
                        symbollist.substr(location+1, symbollist.len()-(location-1));
 
684
                        m_numstops++;
 
685
                        location=symbollist.find(0,",");
 
686
                }
 
687
                m_stopnames[m_numstops++] = symbollist;
 
688
 
 
689
                // careful, dirname is NULL if we're coming from internal layout, and our string assignment doesn't like that
 
690
                if (dirname != NULL)
 
691
                        m_dirname = dirname;
 
692
 
 
693
                for (int i=0;i<m_numstops;i++)
 
694
                {
 
695
                        location=m_stopnames[i].find(0,":");
 
696
                        if (location!=-1)
 
697
                        {
 
698
                                m_imagefile[i] = m_stopnames[i];
 
699
                                m_stopnames[i].substr(0, location);
 
700
                                m_imagefile[i].substr(location+1, m_imagefile[i].len()-(location-1));
 
701
 
 
702
                                //m_alphafile[i] =
 
703
                                m_file[i] = global_alloc(emu_file(machine.options().art_path(), OPEN_FLAG_READ));
 
704
                        }
 
705
                        else
 
706
                        {
 
707
                                //m_imagefile[i] = 0;
 
708
                                //m_alphafile[i] = 0;
 
709
                                m_file[i] = 0;
 
710
                        }
 
711
                }
 
712
 
 
713
                m_stateoffset = xml_get_attribute_int_with_subst(machine, compnode, "stateoffset", 0);
 
714
                m_numsymbolsvisible = xml_get_attribute_int_with_subst(machine, compnode, "numsymbolsvisible", 3);
 
715
                m_reelreversed = xml_get_attribute_int_with_subst(machine, compnode, "reelreversed", 0);
 
716
        }
635
717
        // led7seg nodes
636
718
        else if (strcmp(compnode.name, "led7seg") == 0)
637
719
                m_type = CTYPE_LED7SEG;
672
754
 
673
755
layout_element::component::~component()
674
756
{
675
 
        global_free(m_file);
 
757
        for (int i=0;i<MAX_BITMAPS;i++)
 
758
        {
 
759
                global_free(m_file[i]);
 
760
        }
676
761
}
677
762
 
678
763
 
685
770
        switch (m_type)
686
771
        {
687
772
                case CTYPE_IMAGE:
688
 
                        if (!m_bitmap.valid())
 
773
                        if (!m_bitmap[0].valid())
689
774
                                load_bitmap();
690
775
                        {
691
776
                                bitmap_argb32 destsub(dest, bounds);
692
 
                                render_resample_argb_bitmap_hq(destsub, m_bitmap, m_color);
 
777
                                render_resample_argb_bitmap_hq(destsub, m_bitmap[0], m_color);
693
778
                        }
694
779
                        break;
695
780
 
726
811
                        break;
727
812
 
728
813
                case CTYPE_DOTMATRIX:
729
 
                        draw_dotmatrix(dest, bounds, state);
 
814
                        draw_dotmatrix(8, dest, bounds, state);
 
815
                        break;
 
816
 
 
817
                case CTYPE_DOTMATRIX5DOT:
 
818
                        draw_dotmatrix(5, dest, bounds, state);
 
819
                        break;
 
820
 
 
821
                case CTYPE_DOTMATRIXDOT:
 
822
                        draw_dotmatrix(1, dest, bounds, state);
 
823
                        break;
 
824
 
 
825
                case CTYPE_SIMPLECOUNTER:
 
826
                        draw_simplecounter(machine, dest, bounds, state);
 
827
                        break;
 
828
 
 
829
                case CTYPE_REEL:
 
830
 
 
831
                        draw_reel(machine, dest, bounds, state);
730
832
                        break;
731
833
 
732
834
                default:
840
942
        render_font *font = machine.render().font_alloc("default");
841
943
        float aspect = 1.0f;
842
944
        INT32 width;
 
945
 
 
946
 
843
947
        while (1)
844
948
        {
845
949
                width = font->string_width(bounds.height(), aspect, m_string);
847
951
                        break;
848
952
                aspect *= 0.9f;
849
953
        }
850
 
        INT32 curx = bounds.min_x + (bounds.width() - width) / 2;
 
954
 
 
955
 
 
956
        // get alignment
 
957
        INT32 curx;
 
958
        switch (m_textalign)
 
959
        {
 
960
                // left
 
961
                case 1:
 
962
                        curx = bounds.min_x;
 
963
                        break;
 
964
 
 
965
                // right
 
966
                case 2:
 
967
                        curx = bounds.max_x - width;
 
968
                        break;
 
969
 
 
970
                // default to center
 
971
                default:
 
972
                        curx = bounds.min_x + (bounds.width() - width) / 2;
 
973
                        break;
 
974
        }
851
975
 
852
976
        // allocate a temporary bitmap
853
977
        bitmap_argb32 tempbitmap(dest.width(), dest.height());
895
1019
        machine.render().font_free(font);
896
1020
}
897
1021
 
 
1022
void layout_element::component::draw_simplecounter(running_machine &machine, bitmap_argb32 &dest, const rectangle &bounds, int state)
 
1023
{
 
1024
        char temp[256];
 
1025
        sprintf(temp, "%0*d", m_digits, state);
 
1026
        m_string = astring(temp);
 
1027
        draw_text(machine, dest, bounds);
 
1028
}
 
1029
 
 
1030
/* state is a normalized value between 0 and 65536 so that we don't need to worry about how many motor steps here or in the .lay, only the number of symbols */
 
1031
void layout_element::component::draw_reel(running_machine &machine, bitmap_argb32 &dest, const rectangle &bounds, int state)
 
1032
{
 
1033
 
 
1034
 
 
1035
        const int max_state_used = 0x10000;
 
1036
 
 
1037
        // shift the reels a bit based on this param, allows fine tuning
 
1038
        int use_state = (state + m_stateoffset) % max_state_used;
 
1039
 
 
1040
        // compute premultiplied colors
 
1041
        UINT32 r = m_color.r * 255.0;
 
1042
        UINT32 g = m_color.g * 255.0;
 
1043
        UINT32 b = m_color.b * 255.0;
 
1044
        UINT32 a = m_color.a * 255.0;
 
1045
 
 
1046
        // get the width of the string
 
1047
        render_font *font = machine.render().font_alloc("default");
 
1048
        float aspect = 1.0f;
 
1049
        INT32 width;
 
1050
        int curry = 0;
 
1051
        int num_shown = m_numsymbolsvisible;
 
1052
 
 
1053
        int ourheight = bounds.height();
 
1054
 
 
1055
        for (int fruit = 0;fruit<m_numstops;fruit++)
 
1056
        {
 
1057
 
 
1058
 
 
1059
                int basey;
 
1060
 
 
1061
                if (m_reelreversed==1)
 
1062
                {
 
1063
                        basey = bounds.min_y + ((use_state)*(ourheight/num_shown)/(max_state_used/m_numstops)) + curry;
 
1064
                }
 
1065
                else
 
1066
                {
 
1067
                        basey = bounds.min_y - ((use_state)*(ourheight/num_shown)/(max_state_used/m_numstops)) + curry;
 
1068
                }
 
1069
 
 
1070
                // wrap around...
 
1071
                if (basey < bounds.min_y)
 
1072
                        basey += ((max_state_used)*(ourheight/num_shown)/(max_state_used/m_numstops));
 
1073
                if (basey > bounds.max_y)
 
1074
                        basey -= ((max_state_used)*(ourheight/num_shown)/(max_state_used/m_numstops));
 
1075
 
 
1076
                int endpos = basey+ourheight/num_shown;
 
1077
 
 
1078
                // only render the symbol / text if it's atually in view because the code is SLOW
 
1079
                if ((endpos >= bounds.min_y) && (basey <= bounds.max_y))
 
1080
                {
 
1081
 
 
1082
                        while (1)
 
1083
                        {
 
1084
                                width = font->string_width(ourheight/num_shown, aspect, m_stopnames[fruit]);
 
1085
                                if (width < bounds.width())
 
1086
                                        break;
 
1087
                                aspect *= 0.9f;
 
1088
                        }
 
1089
 
 
1090
                        INT32 curx;
 
1091
                        curx = bounds.min_x + (bounds.width() - width) / 2;
 
1092
 
 
1093
                        if (m_file[fruit])
 
1094
                                if (!m_bitmap[fruit].valid())
 
1095
                                        load_reel_bitmap(fruit);
 
1096
 
 
1097
                        if (m_file[fruit]) // render gfx
 
1098
                        {
 
1099
                                bitmap_argb32 tempbitmap2(dest.width(), ourheight/num_shown);
 
1100
 
 
1101
                                if (m_bitmap[fruit].valid())
 
1102
                                {
 
1103
                                        render_resample_argb_bitmap_hq(tempbitmap2, m_bitmap[fruit], m_color);
 
1104
 
 
1105
                                        for (int y = 0; y < ourheight/num_shown; y++)
 
1106
                                        {
 
1107
                                                int effy = basey + y;
 
1108
 
 
1109
                                                if (effy >= bounds.min_y && effy <= bounds.max_y)
 
1110
                                                {
 
1111
                                                        UINT32 *src = &tempbitmap2.pix32(y);
 
1112
                                                        UINT32 *d = &dest.pix32(effy);
 
1113
                                                        for (int x = 0; x < dest.width(); x++)
 
1114
                                                        {
 
1115
                                                                int effx = x;
 
1116
                                                                if (effx >= bounds.min_x && effx <= bounds.max_x)
 
1117
                                                                {
 
1118
 
 
1119
                                                                        UINT32 spix = RGB_ALPHA(src[x]);
 
1120
                                                                        if (spix != 0)
 
1121
                                                                        {
 
1122
                                                                                d[effx] = src[x];
 
1123
                                                                        }
 
1124
                                                                }
 
1125
                                                        }
 
1126
                                                }
 
1127
 
 
1128
                                        }
 
1129
                                }
 
1130
                        }
 
1131
                        else // render text (fallback)
 
1132
                        {
 
1133
                                // allocate a temporary bitmap
 
1134
                                bitmap_argb32 tempbitmap(dest.width(), dest.height());
 
1135
 
 
1136
                                // loop over characters
 
1137
                                for (const char *s = m_stopnames[fruit]; *s != 0; s++)
 
1138
                                {
 
1139
                                        // get the font bitmap
 
1140
                                        rectangle chbounds;
 
1141
                                        font->get_scaled_bitmap_and_bounds(tempbitmap, ourheight/num_shown, aspect, *s, chbounds);
 
1142
 
 
1143
                                        // copy the data into the target
 
1144
                                        for (int y = 0; y < chbounds.height(); y++)
 
1145
                                        {
 
1146
                                                int effy = basey + y;
 
1147
 
 
1148
                                                if (effy >= bounds.min_y && effy <= bounds.max_y)
 
1149
                                                {
 
1150
                                                        UINT32 *src = &tempbitmap.pix32(y);
 
1151
                                                        UINT32 *d = &dest.pix32(effy);
 
1152
                                                        for (int x = 0; x < chbounds.width(); x++)
 
1153
                                                        {
 
1154
                                                                int effx = curx + x + chbounds.min_x;
 
1155
                                                                if (effx >= bounds.min_x && effx <= bounds.max_x)
 
1156
                                                                {
 
1157
 
 
1158
                                                                        UINT32 spix = RGB_ALPHA(src[x]);
 
1159
                                                                        if (spix != 0)
 
1160
                                                                        {
 
1161
                                                                                UINT32 dpix = d[effx];
 
1162
                                                                                UINT32 ta = (a * (spix + 1)) >> 8;
 
1163
                                                                                UINT32 tr = (r * ta + RGB_RED(dpix) * (0x100 - ta)) >> 8;
 
1164
                                                                                UINT32 tg = (g * ta + RGB_GREEN(dpix) * (0x100 - ta)) >> 8;
 
1165
                                                                                UINT32 tb = (b * ta + RGB_BLUE(dpix) * (0x100 - ta)) >> 8;
 
1166
                                                                                d[effx] = MAKE_ARGB(0xff, tr, tg, tb);
 
1167
                                                                        }
 
1168
                                                                }
 
1169
                                                        }
 
1170
                                                }
 
1171
                                        }
 
1172
 
 
1173
                                        // advance in the X direction
 
1174
                                        curx += font->char_width(ourheight/num_shown, aspect, *s);
 
1175
 
 
1176
                                }
 
1177
 
 
1178
                        }
 
1179
                }
 
1180
 
 
1181
                curry += ourheight/num_shown;
 
1182
        }
 
1183
 
 
1184
        // free the temporary bitmap and font
 
1185
        machine.render().font_free(font);
 
1186
}
 
1187
 
 
1188
 
 
1189
 
898
1190
 
899
1191
//-------------------------------------------------
900
1192
//  load_bitmap - load a PNG file with artwork for
904
1196
void layout_element::component::load_bitmap()
905
1197
{
906
1198
        // load the basic bitmap
907
 
        assert(m_file != NULL);
908
 
        m_hasalpha = render_load_png(m_bitmap, *m_file, m_dirname, m_imagefile);
 
1199
        assert(m_file[0] != NULL);
 
1200
        m_hasalpha[0] = render_load_png(m_bitmap[0], *m_file[0], m_dirname, m_imagefile[0]);
909
1201
 
910
1202
        // load the alpha bitmap if specified
911
 
        if (m_bitmap.valid() && m_alphafile)
912
 
                render_load_png(m_bitmap, *m_file, m_dirname, m_alphafile, true);
 
1203
        if (m_bitmap[0].valid() && m_alphafile[0])
 
1204
                render_load_png(m_bitmap[0], *m_file[0], m_dirname, m_alphafile[0], true);
913
1205
 
914
1206
        // if we can't load the bitmap, allocate a dummy one and report an error
915
 
        if (!m_bitmap.valid())
 
1207
        if (!m_bitmap[0].valid())
916
1208
        {
917
1209
                // draw some stripes in the bitmap
918
 
                m_bitmap.allocate(100, 100);
919
 
                m_bitmap.fill(0);
 
1210
                m_bitmap[0].allocate(100, 100);
 
1211
                m_bitmap[0].fill(0);
920
1212
                for (int step = 0; step < 100; step += 25)
921
1213
                        for (int line = 0; line < 100; line++)
922
 
                                m_bitmap.pix32((step + line) % 100, line % 100) = MAKE_ARGB(0xff,0xff,0xff,0xff);
 
1214
                                m_bitmap[0].pix32((step + line) % 100, line % 100) = MAKE_ARGB(0xff,0xff,0xff,0xff);
923
1215
 
924
1216
                // log an error
925
 
                if (!m_alphafile)
926
 
                        mame_printf_warning("Unable to load component bitmap '%s'", m_imagefile.cstr());
 
1217
                if (!m_alphafile[0])
 
1218
                        mame_printf_warning("Unable to load component bitmap '%s'", m_imagefile[0].cstr());
927
1219
                else
928
 
                        mame_printf_warning("Unable to load component bitmap '%s'/'%s'", m_imagefile.cstr(), m_alphafile.cstr());
929
 
        }
930
 
}
 
1220
                        mame_printf_warning("Unable to load component bitmap '%s'/'%s'", m_imagefile[0].cstr(), m_alphafile[0].cstr());
 
1221
        }
 
1222
}
 
1223
 
 
1224
 
 
1225
void layout_element::component::load_reel_bitmap(int number)
 
1226
{
 
1227
 
 
1228
        // load the basic bitmap
 
1229
        assert(m_file != NULL);
 
1230
        /*m_hasalpha[number] = */ render_load_png(m_bitmap[number], *m_file[number], m_dirname, m_imagefile[number]);
 
1231
 
 
1232
        // load the alpha bitmap if specified
 
1233
        //if (m_bitmap[number].valid() && m_alphafile[number])
 
1234
        //  render_load_png(m_bitmap[number], *m_file[number], m_dirname, m_alphafile[number], true);
 
1235
 
 
1236
        // if we can't load the bitmap just use text rendering
 
1237
        if (!m_bitmap[number].valid())
 
1238
        {
 
1239
                // fallback to text rendering
 
1240
                global_free(m_file[number]);
 
1241
                m_file[number] = NULL;
 
1242
        }
 
1243
 
 
1244
}
 
1245
 
931
1246
 
932
1247
 
933
1248
//-------------------------------------------------
1426
1741
 
1427
1742
 
1428
1743
//-------------------------------------------------
1429
 
//  draw_dotmatrix - draw a row of 8 dots for a
 
1744
//  draw_dotmatrix - draw a row of dots for a
1430
1745
//  dotmatrix
1431
1746
//-------------------------------------------------
1432
1747
 
1433
 
void layout_element::component::draw_dotmatrix(bitmap_argb32 &dest, const rectangle &bounds, int pattern)
 
1748
void layout_element::component::draw_dotmatrix(int dots, bitmap_argb32 &dest, const rectangle &bounds, int pattern)
1434
1749
{
1435
1750
        const rgb_t onpen = MAKE_ARGB(0xff, 0xff, 0xff, 0xff);
1436
1751
        const rgb_t offpen = MAKE_ARGB(0xff, 0x20, 0x20, 0x20);
1437
1752
 
1438
1753
        // sizes for computation
1439
 
        int bmwidth = 2000;
1440
1754
        int bmheight = 300;
1441
1755
        int dotwidth = 250;
1442
1756
 
1443
1757
        // allocate a temporary bitmap for drawing
1444
 
        bitmap_argb32 tempbitmap(bmwidth, bmheight);
 
1758
        bitmap_argb32 tempbitmap(dotwidth*dots, bmheight);
1445
1759
        tempbitmap.fill(MAKE_ARGB(0xff, 0x00, 0x00, 0x00));
1446
1760
 
1447
 
        for (int i = 0; i < 8; i++)
 
1761
        for (int i = 0; i < dots; i++)
1448
1762
                draw_segment_decimal(tempbitmap, ((dotwidth/2 )+ (i * dotwidth)), bmheight/2, dotwidth, (pattern & (1 << i))?onpen:offpen);
1449
1763
 
1450
1764
        // resample to the target size
1520
1834
 
1521
1835
//-------------------------------------------------
1522
1836
//  draw_segment_diagonal_1 - draw a diagonal
1523
 
//  LED segment that looks like this: /
 
1837
//  LED segment that looks like a backslash
1524
1838
//-------------------------------------------------
1525
1839
 
1526
1840
void layout_element::component::draw_segment_diagonal_1(bitmap_argb32 &dest, int minx, int maxx, int miny, int maxy, int width, rgb_t color)
1545
1859
 
1546
1860
//-------------------------------------------------
1547
1861
//  draw_segment_diagonal_2 - draw a diagonal
1548
 
//  LED segment that looks like this:
 
1862
//  LED segment that looks like a forward slash
1549
1863
//-------------------------------------------------
1550
1864
 
1551
1865
void layout_element::component::draw_segment_diagonal_2(bitmap_argb32 &dest, int minx, int maxx, int miny, int maxy, int width, rgb_t color)
1914
2228
        // if configured to an input, fetch the input value
1915
2229
        else if (m_input_tag[0] != 0)
1916
2230
        {
1917
 
                const input_field_config *field = input_field_by_tag_and_mask(m_element->machine(), m_input_tag, m_input_mask);
1918
 
                if (field != NULL)
1919
 
                        state = ((input_port_read_safe(m_element->machine(), m_input_tag, 0) ^ field->defvalue) & m_input_mask) ? 1 : 0;
 
2231
                ioport_port *port = m_element->machine().root_device().ioport(m_input_tag);
 
2232
                if (port != NULL)
 
2233
                {
 
2234
                        ioport_field *field = port->field(m_input_mask);
 
2235
                        if (field != NULL)
 
2236
                                state = ((port->read() ^ field->defvalue()) & m_input_mask) ? 1 : 0;
 
2237
                }
1920
2238
        }
1921
2239
        return state;
1922
2240
}