Previous 15994 Revisions Next

r2298 Sunday 6th April, 2008 at 10:28:18 UTC by Robbbert
[SUPER80] super80v - Auto-resize option is now always on. Cleaned up code.
[src/mess/drivers]super80.c

src/mess/drivers/super80.c
r2297r2298
1010#include "sound/speaker.h"
1111#include "deprecat.h"      /* "Machine" needed for z80pio interrupt */
1212
13#define video_screen_get_refresh(screen)   (((screen_config *)(screen)->inline_config)->refresh)
14
1513static UINT8 super80_mhz=2;   /* state of bit 2 of port F0 */
1614static UINT16 vidpg=0xfe00;   /* Home position of video page being displayed */
1715static UINT8 int_sw;      /* internal 1 mhz flipflop */
r2297r2298
2119
2220/* the rest are for super80v */
2321static UINT8 *pcgram;
24static int off_x = 0;
25static int off_y = 0;
2622static UINT8 framecnt = 0;
2723static UINT8 super80v_vid_col=1;         // 0 = color ram ; 1 = video ram
2824static UINT8 super80v_rom_pcg=1;         // 0 = prom ; 1 = pcg
2925static UINT8 mc6845_cursor[16];            // cursor shape
30static UINT8 mc6845[20];            /* registers */
31static UINT8 mc6845_reg;            /* register index */
26static UINT8 mc6845_reg[20];            /* registers */
27static UINT8 mc6845_ind;            /* register index */
3228static UINT8 mc6845_mask[]={0xff,0xff,0xff,0x0f,0x7f,0x1f,0x7f,0x7f,3,0x1f,0x7f,0x1f,0x3f,0xff,0x3f,0xff,0,0};
3329
3430#define MASTER_CLOCK         (XTAL_12MHz)
r2297r2298
171167
172168   for ( i = 0; i < ARRAY_LENGTH(mc6845_cursor); i++) mc6845_cursor[i] = 0;      // prepare cursor by erasing old one
173169
174   r9  = mc6845[9];               // number of scan lines - 1
175   r10 = mc6845[10] & 0x1f;            // cursor start line = last 5 bits
176   r11 = mc6845[11]+1;               // cursor end line incremented to suit for-loops below
170   r9  = mc6845_reg[9];               // number of scan lines - 1
171   r10 = mc6845_reg[10] & 0x1f;            // cursor start line = last 5 bits
172   r11 = mc6845_reg[11]+1;               // cursor end line incremented to suit for-loops below
177173
178174   /* decide the curs_type by examining the registers */
179175   if (r10 < r11) curs_type=1;            // start less than end, show start to end
r2297r2298
198194static void mc6845_screen_configure(running_machine *machine)
199195{
200196   rectangle visarea;
201   UINT16 width, height, bytes;   
202   UINT8 dyn = readinputportbytag("CONFIG") & 0x10;         // read dipswitch
203   visarea.min_x = 0;
204   visarea.max_x = SUPER80V_SCREEN_WIDTH-1;
205   visarea.min_y = 0;
206   visarea.max_y = SUPER80V_SCREEN_HEIGHT-1;
207197
208   /* calculate the effect of sync and vertical adjustments */
209   if ( mc6845[2] ) off_x = mc6845[0] - mc6845[2] - 23; else off_x = -24;
198   UINT16 width = mc6845_reg[1]*7-1;                     // width in pixels
199   UINT16 height = mc6845_reg[6]*(mc6845_reg[9]+1)-1;               // height in pixels
200   UINT16 bytes = mc6845_reg[1]*mc6845_reg[6]-1;                  // video ram needed -1
210201
211   off_y = (mc6845[4] - mc6845[7]) * (mc6845[9] + 1) + mc6845[5];
212
213   if( off_y < 0 ) off_y = 0;
214
215   if( off_y > 128 ) off_y = 128;
216
217   if (dyn)
218   {
219      off_x = 0;
220      off_y = 0;
221   }
222
223   width = mc6845[1]*7-1;                     // width in pixels
224   height = mc6845[6]*(mc6845[9]+1)-1;               // height in pixels
225   bytes = mc6845[1]*mc6845[6]-1;                  // video ram needed -1
226
227   /* Physically resize the screen now */
228   if (dyn)
229   {
230      visarea.min_x = 0;
231      visarea.max_x = width;
232      visarea.min_y = 0;
233      visarea.max_y = height;
234      if ((width < 610)
235      && (height < 460)         /* bounds checking to prevent an assert or violation */
236      && (bytes < 0x1000))
237         video_screen_configure(machine->primary_screen, width+1, height+1, &visarea, video_screen_get_refresh(machine->primary_screen));
238   }
239   else
240         video_screen_configure(machine->primary_screen, SUPER80V_SCREEN_WIDTH, SUPER80V_SCREEN_HEIGHT, &visarea, video_screen_get_refresh(machine->primary_screen));   // in case dipswitch was just turned to NO
202   /* Resize the screen */
203   visarea.min_x = 0;
204   visarea.max_x = width;
205   visarea.min_y = 0;
206   visarea.max_y = height;
207   if ((width < 610) && (height < 460) && (bytes < 0x1000))   /* bounds checking to prevent an assert or violation */
208      video_screen_set_visarea(machine->primary_screen, 0, width+1, 0, height+1);
241209}
242210
243211static VIDEO_EOF( super80m )
r2297r2298
319287
320288static VIDEO_UPDATE( super80v )
321289{
322   UINT16 i, bytes = mc6845[1]*mc6845[6];
323   UINT8 speed = mc6845[10]&0x20, flash = mc6845[10]&0x40;            // cursor modes
324   UINT16 cursor = (mc6845[14]<<8) | mc6845[15];               // get cursor position
325   UINT16 screen_home = (mc6845[12]<<8) | mc6845[13];            // screen home offset (usually zero)
290   UINT16 i, bytes = mc6845_reg[1]*mc6845_reg[6];
291   UINT8 speed = mc6845_reg[10]&0x20, flash = mc6845_reg[10]&0x40;            // cursor modes
292   UINT16 cursor = (mc6845_reg[14]<<8) | mc6845_reg[15];               // get cursor position
293   UINT16 screen_home = (mc6845_reg[12]<<8) | mc6845_reg[13];            // screen home offset (usually zero)
326294   UINT8 options=readinputportbytag("CONFIG");
327295   framecnt++;
328296
r2297r2298
340308   for( i = screen_home; (i < (bytes + screen_home)) & (i < 0x1000); i++ )
341309   {
342310      int sx, sy, chr, col;
343      sy = off_y + ((i - screen_home) / mc6845[1]) * (mc6845[9] + 1);
344      sx = (off_x + ((i - screen_home) % mc6845[1])) * 7;
311      sy = ((i - screen_home) / mc6845_reg[1]) * (mc6845_reg[9] + 1);
312      sx = ((i - screen_home) % mc6845_reg[1]) * 7;
345313      chr = videoram[i];
346314
347315      /* get colour or b&w */
r2297r2298
464432
465433static READ8_HANDLER( super80v_11_r )
466434{
467   if ((mc6845_reg > 13) && (mc6845_reg < 18))      /* determine readable registers */
468      return mc6845[mc6845_reg];
435   if ((mc6845_ind > 13) && (mc6845_ind < 18))      /* determine readable registers */
436      return mc6845_reg[mc6845_ind];
469437   else
470438      return 0;
471439}
r2297r2298
480448
481449static WRITE8_HANDLER( super80v_10_w )
482450{
483   if (data < 18) mc6845_reg = data; else mc6845_reg = 19;      /* make sure if you try using an invalid register your write will go nowhere */
451   if (data < 18) mc6845_ind = data; else mc6845_ind = 19;      /* make sure if you try using an invalid register your write will go nowhere */
484452}
485453
486454static WRITE8_HANDLER( super80v_11_w )
487455{
488   if (mc6845_reg < 16) mc6845[mc6845_reg] = data & mc6845_mask[mc6845_reg];   /* save data in register */
489   if (mc6845_reg < 10) mc6845_screen_configure(machine);            /* adjust screen size */
490   if ((mc6845_reg > 8) && (mc6845_reg < 12)) mc6845_cursor_configure();      /* adjust cursor shape */
456   if (mc6845_ind < 16) mc6845_reg[mc6845_ind] = data & mc6845_mask[mc6845_ind];   /* save data in register */
457   if ((mc6845_ind == 1) || (mc6845_ind == 6) || (mc6845_ind == 9)) mc6845_screen_configure(machine); /* adjust screen size */
458   if ((mc6845_ind > 8) && (mc6845_ind < 12)) mc6845_cursor_configure();      /* adjust cursor shape */
491459}
492460
493461static UINT8 last_data;
r2297r2298
713681   PORT_INCLUDE( super80m )
714682
715683   PORT_MODIFY("CONFIG")
716
717   /* Enhanced options not available on real hardware */
718   PORT_BIT( 0x6, 0x6, IPT_UNUSED )
719   PORT_CONFNAME( 0x10, 0x10, "Auto-Resize?")
720   PORT_CONFSETTING(    0x00, DEF_STR(No))
721   PORT_CONFSETTING(    0x10, DEF_STR(Yes))
684   PORT_BIT( 0x16, 0x16, IPT_UNUSED )
722685INPUT_PORTS_END
723686
724687/**************************** GRAPHICS DECODE *****************************************************************/

Previous 15994 Revisions Next


© 1998-2018 The MESS Team