@@ -130,6 +130,7 @@ class specnext_state : public spectrum_128_state
130130 , m_sprites(*this , " sprites" )
131131 , m_io_issue(*this , " ISSUE" )
132132 , m_io_video(*this , " VIDEO" )
133+ , m_io_layers(*this , " LYRS" )
133134 , m_io_mouse(*this , " mouse_input%u" , 1U )
134135 {}
135136
@@ -351,6 +352,7 @@ class specnext_state : public spectrum_128_state
351352 required_device<specnext_sprites_device> m_sprites;
352353 required_ioport m_io_issue;
353354 optional_ioport m_io_video;
355+ optional_ioport m_io_layers;
354356 required_ioport_array<3 > m_io_mouse;
355357
356358 video_timings_info m_video_timings;
@@ -934,16 +936,22 @@ u32 specnext_state::screen_update(screen_device &screen, bitmap_rgb32 &bitmap, c
934936 rectangle clip320x256 = m_clip320x256;
935937 clip320x256 &= cliprect;
936938
937- screen.priority ().fill (0 , cliprect);
939+ const u8 layers_dev = ~m_io_layers->read ();
940+ const bool tiles_en = m_nr_6b_tm_en && BIT (layers_dev, 0 );
941+ const bool ula_en = m_nr_68_ula_en && BIT (layers_dev, 1 );
942+ const bool layer2_en = m_port_123b_layer2_en && BIT (layers_dev, 2 );
943+ const bool sprites_en = m_nr_15_sprite_en && BIT (layers_dev, 3 );
944+
938945 const bool flash = u64 (screen.frame_number () / m_frame_invert_count) & 1 ;
946+ screen.priority ().fill (0 , cliprect);
947+ // background
948+ if (ula_en)
949+ m_ula_scr->draw_border (bitmap, cliprect, m_port_fe_data & 0x07 );
950+ else
951+ bitmap.fill (m_palette->pen_color (UTM_FALLBACK_PEN), cliprect);
952+
939953 if (m_nr_15_layer_priority < 0b110 )
940954 {
941- // background
942- if (m_nr_68_ula_en)
943- m_ula_scr->draw_border (bitmap, cliprect, m_port_fe_data & 0x07 );
944- else
945- bitmap.fill (m_palette->pen_color (UTM_FALLBACK_PEN), cliprect);
946-
947955 static const u8 lcfg[][3 ] =
948956 {
949957 // tiles+ula priority; l2 prioryty; l2 mask
@@ -957,65 +965,62 @@ u32 specnext_state::screen_update(screen_device &screen, bitmap_rgb32 &bitmap, c
957965 };
958966
959967 const u8 (&l)[3 ] = lcfg[m_nr_15_layer_priority];
960- if (m_nr_6b_tm_en ) m_tiles->draw (screen, bitmap, clip320x256, TILEMAP_DRAW_CATEGORY (1 ), l[0 ]);
961- if (m_nr_68_ula_en && BIT (~m_nr_6b_tm_control, 3 ))
968+ if (tiles_en ) m_tiles->draw (screen, bitmap, clip320x256, TILEMAP_DRAW_CATEGORY (1 ), l[0 ]);
969+ if (ula_en && BIT (~m_nr_6b_tm_control, 3 ))
962970 {
963971 if (m_nr_15_lores_en) m_lores->draw (screen, bitmap, clip256x192, l[0 ]);
964972 else m_ula_scr->draw (screen, bitmap, clip256x192, flash, l[0 ]);
965973 }
966- if (m_nr_6b_tm_en ) m_tiles->draw (screen, bitmap, clip320x256, TILEMAP_DRAW_CATEGORY (2 ), l[0 ]);
967- m_layer2->draw (screen, bitmap, clip320x256, l[1 ], l[2 ]);
974+ if (tiles_en ) m_tiles->draw (screen, bitmap, clip320x256, TILEMAP_DRAW_CATEGORY (2 ), l[0 ]);
975+ if (layer2_en) m_layer2->draw (screen, bitmap, clip320x256, l[1 ], l[2 ]);
968976 }
969977 else // colors mixing case
970978 {
971- bitmap.fill (m_palette->pen_color (UTM_FALLBACK_PEN), cliprect);
972-
973- const bool is_textmode = BIT (m_nr_6b_tm_control, 3 );
974979 if (m_nr_68_blend_mode == 0b00 ) // Use ULA as blend layer
975980 {
976- if (m_nr_6b_tm_en ) m_tiles->draw (screen, bitmap, clip320x256, TILEMAP_DRAW_CATEGORY (1 ), is_textmode ? 1 : 0xff );
977- if (m_nr_68_ula_en && !is_textmode )
981+ if (tiles_en ) m_tiles->draw (screen, bitmap, clip320x256, TILEMAP_DRAW_CATEGORY (1 ), 1 );
982+ if (ula_en && BIT (~m_nr_6b_tm_control, 3 ) )
978983 {
979984 if (m_nr_15_lores_en) m_lores->draw (screen, bitmap, clip256x192, 1 );
980985 else m_ula_scr->draw (screen, bitmap, clip256x192, flash, 1 );
981986 }
982- if (m_nr_6b_tm_en ) m_tiles->draw (screen, bitmap, clip320x256, TILEMAP_DRAW_CATEGORY (2 ), is_textmode ? 1 : 2 );
987+ if (tiles_en ) m_tiles->draw (screen, bitmap, clip320x256, TILEMAP_DRAW_CATEGORY (2 ), 1 );
983988 }
984989 else if (m_nr_68_blend_mode == 0b10 ) // Use result of ULA + Tilemap
985990 {
986- if (m_nr_6b_tm_en ) m_tiles->draw (screen, bitmap, clip320x256, TILEMAP_DRAW_CATEGORY (1 ), 1 );
987- if (m_nr_68_ula_en && !is_textmode )
991+ if (tiles_en ) m_tiles->draw (screen, bitmap, clip320x256, TILEMAP_DRAW_CATEGORY (1 ), 1 );
992+ if (ula_en && BIT (~m_nr_6b_tm_control, 3 ) )
988993 {
989994 if (m_nr_15_lores_en) m_lores->draw (screen, bitmap, clip256x192, 1 );
990995 else m_ula_scr->draw (screen, bitmap, clip256x192, flash, 1 );
991996 }
992- if (m_nr_6b_tm_en ) m_tiles->draw (screen, bitmap, clip320x256, TILEMAP_DRAW_CATEGORY (2 ), 1 );
997+ if (tiles_en ) m_tiles->draw (screen, bitmap, clip320x256, TILEMAP_DRAW_CATEGORY (2 ), 1 );
993998 }
994999 else if (m_nr_68_blend_mode == 0b11 ) // Use Tilemap as blend layer
9951000 {
996- if (m_nr_6b_tm_en ) m_tiles->draw (screen, bitmap, clip320x256, TILEMAP_DRAW_CATEGORY (1 ), 1 );
997- if (m_nr_68_ula_en && !is_textmode )
1001+ if (tiles_en ) m_tiles->draw (screen, bitmap, clip320x256, TILEMAP_DRAW_CATEGORY (1 ), 1 );
1002+ if (ula_en && BIT (~m_nr_6b_tm_control, 3 ) )
9981003 {
9991004 if (m_nr_15_lores_en) m_lores->draw (screen, bitmap, clip256x192, 2 );
10001005 else m_ula_scr->draw (screen, bitmap, clip256x192, flash, 2 );
10011006 }
1002- if (m_nr_6b_tm_en ) m_tiles->draw (screen, bitmap, clip320x256, TILEMAP_DRAW_CATEGORY (2 ), 1 );
1007+ if (tiles_en ) m_tiles->draw (screen, bitmap, clip320x256, TILEMAP_DRAW_CATEGORY (2 ), 1 );
10031008 }
10041009 else // No blending (disable blend)
10051010 {
1006- if (m_nr_6b_tm_en ) m_tiles->draw (screen, bitmap, clip320x256, TILEMAP_DRAW_CATEGORY (1 ), 2 );
1007- if (m_nr_68_ula_en && !is_textmode )
1011+ if (tiles_en ) m_tiles->draw (screen, bitmap, clip320x256, TILEMAP_DRAW_CATEGORY (1 ), 2 );
1012+ if (ula_en && BIT (~m_nr_6b_tm_control, 3 ) )
10081013 {
10091014 if (m_nr_15_lores_en) m_lores->draw (screen, bitmap, clip256x192, 2 );
10101015 else m_ula_scr->draw (screen, bitmap, clip256x192, flash, 2 );
10111016 }
1012- if (m_nr_6b_tm_en ) m_tiles->draw (screen, bitmap, clip320x256, TILEMAP_DRAW_CATEGORY (2 ), 2 );
1017+ if (tiles_en ) m_tiles->draw (screen, bitmap, clip320x256, TILEMAP_DRAW_CATEGORY (2 ), 2 );
10131018 }
10141019 // mixes only to 1
1015- m_layer2->draw_mix (screen, bitmap, clip320x256, m_nr_15_layer_priority & 1 );
1020+ if (layer2_en) m_layer2->draw_mix (screen, bitmap, clip320x256, m_nr_15_layer_priority & 1 );
10161021 }
10171022 // sprites below foreground
1018- if (m_nr_15_sprite_en ) m_sprites->draw (screen, bitmap, clip320x256, GFX_PMASK_8);
1023+ if (sprites_en ) m_sprites->draw (screen, bitmap, clip320x256, GFX_PMASK_8);
10191024
10201025 return 0 ;
10211026}
@@ -2987,6 +2992,21 @@ INPUT_PORTS_START(specnext)
29872992 PORT_MODIFY (" NMI" )
29882993 PORT_BIT (0x01 , IP_ACTIVE_HIGH, IPT_OTHER) PORT_NAME(" NMI MF" ) PORT_CODE(KEYCODE_F12) PORT_CHANGED_MEMBER(DEVICE_SELF, FUNC(specnext_state::on_mf_nmi), 0 )
29892994 PORT_BIT (0x02 , IP_ACTIVE_HIGH, IPT_OTHER) PORT_NAME(" NMI DivMMC" ) PORT_CODE(KEYCODE_F11) PORT_CHANGED_MEMBER(DEVICE_SELF, FUNC(specnext_state::on_divmmc_nmi), 0 )
2995+
2996+ PORT_START (" LYRS" )
2997+ PORT_DIPNAME ( 0x08 , 0x00 , " No Sprites" ) PORT_DIPLOCATION(" LYRS:4" )
2998+ PORT_DIPSETTING ( 0x00 , DEF_STR(Off))
2999+ PORT_DIPSETTING ( 0x08 , DEF_STR(On))
3000+ PORT_DIPNAME ( 0x04 , 0x00 , " No Layer2" ) PORT_DIPLOCATION(" LYRS:5" )
3001+ PORT_DIPSETTING ( 0x00 , DEF_STR(Off))
3002+ PORT_DIPSETTING ( 0x04 , DEF_STR(On))
3003+ PORT_DIPNAME ( 0x02 , 0x00 , " No ULA/LoRes" ) PORT_DIPLOCATION(" LYRS:6" )
3004+ PORT_DIPSETTING ( 0x00 , DEF_STR(Off))
3005+ PORT_DIPSETTING ( 0x02 , DEF_STR(On))
3006+ PORT_DIPNAME ( 0x01 , 0x00 , " No Tiles" ) PORT_DIPLOCATION(" LYRS:7" )
3007+ PORT_DIPSETTING ( 0x00 , DEF_STR(Off))
3008+ PORT_DIPSETTING ( 0x01 , DEF_STR(On))
3009+
29903010INPUT_PORTS_END
29913011
29923012void specnext_state::machine_start ()
0 commit comments