Previous 15994 Revisions Next

r9180 Saturday 18th September, 2010 at 17:38:16 UTC by Robbbert
[SUPER80] Moved a few variables to the driver state.
[src/mess/drivers]super80.c
[src/mess/includes]super80.h
[src/mess/machine]super80.c
[src/mess/video]super80.c

src/mess/machine/super80.c
r9179r9180
88#include "machine/ctronics.h"
99#include "includes/super80.h"
1010
11/* Bits in shared variable:
12    d5 cassette LED
13    d4 super80v rom or pcg bankswitch (1=pcg ram, 0=char gen rom)
14    d2 super80v video or colour bankswitch (1=video ram, 0=colour ram)
15    d2 super80 screen off (=2mhz) or on (bursts of 2mhz at 50hz = 1mhz) */
16
17UINT8 super80_shared=0xff;
18UINT8 *super80_colorram;
1911static running_device *super80_z80pio;
2012static running_device *super80_speaker;
2113static running_device *super80_cassette;
r9179r9180
129121{
130122   static UINT8 int_sw=0;
131123   UINT8 go_fast = 0;
132   if (!(super80_shared & 4) || (!(input_port_read(machine, "CONFIG") & 2)))   /* bit 2 of port F0 is low, OR user turned on config switch */
124   super80_state *state = machine->driver_data<super80_state>();
125   if (!(state->super80_shared & 4) || (!(input_port_read(machine, "CONFIG") & 2)))   /* bit 2 of port F0 is low, OR user turned on config switch */
133126      go_fast++;
134127
135128   /* code to slow down computer to 1 MHz by halting cpu on every second frame */
r9179r9180
200193
201194WRITE8_HANDLER( super80_f0_w )
202195{
196   super80_state *state = space->machine->driver_data<super80_state>();
203197   UINT8 bits = data ^ last_data;
204   super80_shared = data;
198   state->super80_shared = data;
205199   speaker_level_w(super80_speaker, (data & 8) ? 0 : 1);            /* bit 3 - speaker */
206200   if (bits & 2) super80_cassette_motor(space->machine, data & 2 ? 1 : 0);   /* bit 1 - cassette motor */
207201   cassette_output(super80_cassette, (data & 1) ? -1.0 : +1.0);   /* bit 0 - cass out */
r9179r9180
211205
212206WRITE8_HANDLER( super80r_f0_w )
213207{
208   super80_state *state = space->machine->driver_data<super80_state>();
214209   super80_f0_w(space, 0, data);
215   super80_shared |= 0x14;
210   state->super80_shared |= 0x14;
216211}
217212
218213/**************************** BASIC MACHINE CONSTRUCTION ***********************************************************/
219214
220215MACHINE_RESET( super80 )
221216{
222   super80_shared=0xff;
217   super80_state *state = machine->driver_data<super80_state>();
218   state->super80_shared=0xff;
223219   timer_set(machine, ATTOTIME_IN_USEC(10), NULL, 0, super80_reset);
224220   memory_set_bank(machine, "bank1", 1);
225221   super80_z80pio = machine->device("z80pio");
r9179r9180
244240DRIVER_INIT( super80v )
245241{
246242   super80_state *state = machine->driver_data<super80_state>();
247   super80_pcgram = memory_region(machine, "maincpu")+0xf000;
243   state->pcgram = memory_region(machine, "maincpu")+0xf000;
248244   state->videoram = memory_region(machine, "maincpu")+0x18000;
249   super80_colorram = memory_region(machine, "maincpu")+0x1C000;
245   state->colorram = memory_region(machine, "maincpu")+0x1C000;
250246   driver_init_common(machine);
251247}
252248
src/mess/video/super80.c
r9179r9180
1717
1818static const UINT8 *FNT;
1919static UINT8 s_options;
20extern UINT8 *super80_colorram;
2120
21
2222/**************************** PALETTES for super80m and super80v ******************************************/
2323
2424static const UINT8 super80_rgb_palette[16*3] =
r9179r9180
9999   UINT8 y,ra,chr=32,gfx,screen_on=0;
100100   UINT16 sy=0,ma=vidpg,x;
101101   UINT8 *RAM = memory_region(screen->machine, "maincpu");
102   super80_state *state = screen->machine->driver_data<super80_state>();
102103
103   output_set_value("cass_led",(super80_shared & 0x20) ? 1 : 0);
104   output_set_value("cass_led",(state->super80_shared & 0x20) ? 1 : 0);
104105
105   if ((super80_shared & 4) || (!(input_port_read(screen->machine, "CONFIG") & 4)))   /* bit 2 of port F0 is high, OR user turned on config switch */
106   if ((state->super80_shared & 4) || (!(input_port_read(screen->machine, "CONFIG") & 4)))   /* bit 2 of port F0 is high, OR user turned on config switch */
106107      screen_on++;
107108
108109   for (y = 0; y < 16; y++)
r9179r9180
140141   UINT8 y,ra,chr=32,gfx,screen_on=0;
141142   UINT16 sy=0,ma=vidpg,x;
142143   UINT8 *RAM = memory_region(screen->machine, "maincpu");
144   super80_state *state = screen->machine->driver_data<super80_state>();
143145
144   output_set_value("cass_led",(super80_shared & 0x20) ? 1 : 0);
146   output_set_value("cass_led",(state->super80_shared & 0x20) ? 1 : 0);
145147
146   if ((super80_shared & 4) || (!(input_port_read(screen->machine, "CONFIG") & 4)))   /* bit 2 of port F0 is high, OR user turned on config switch */
148   if ((state->super80_shared & 4) || (!(input_port_read(screen->machine, "CONFIG") & 4)))   /* bit 2 of port F0 is high, OR user turned on config switch */
147149      screen_on++;
148150
149151   for (y = 0; y < 16; y++)
r9179r9180
181183   UINT8 y,ra,chr=32,gfx,screen_on=0;
182184   UINT16 sy=0,ma=vidpg,x;
183185   UINT8 *RAM = memory_region(screen->machine, "maincpu");
186   super80_state *state = screen->machine->driver_data<super80_state>();
184187
185   output_set_value("cass_led",(super80_shared & 0x20) ? 1 : 0);
188   output_set_value("cass_led",(state->super80_shared & 0x20) ? 1 : 0);
186189
187   if ((super80_shared & 4) || (!(input_port_read(screen->machine, "CONFIG") & 4)))   /* bit 2 of port F0 is high, OR user turned on config switch */
190   if ((state->super80_shared & 4) || (!(input_port_read(screen->machine, "CONFIG") & 4)))   /* bit 2 of port F0 is high, OR user turned on config switch */
188191      screen_on++;
189192
190193   for (y = 0; y < 16; y++)
r9179r9180
223226   UINT16 sy=0,ma=vidpg,x;
224227   UINT8 col, bg=0, fg=0, options=input_port_read(screen->machine, "CONFIG");
225228   UINT8 *RAM = memory_region(screen->machine, "maincpu");
229   super80_state *state = screen->machine->driver_data<super80_state>();
226230
227231   /* get selected character generator */
228232   UINT8 cgen = current_charset ^ ((options & 0x10)>>4);   /* bit 0 of port F1 and cgen config switch */
229233
230   output_set_value("cass_led",(super80_shared & 0x20) ? 1 : 0);
234   output_set_value("cass_led",(state->super80_shared & 0x20) ? 1 : 0);
231235
232   if ((super80_shared & 4) || (!(options & 4)))   /* bit 2 of port F0 is high, OR user turned on config switch */
236   if ((state->super80_shared & 4) || (!(options & 4)))   /* bit 2 of port F0 is high, OR user turned on config switch */
233237      screen_on++;
234238
235239   if (screen_on)
r9179r9180
303307READ8_HANDLER( super80v_low_r )
304308{
305309   super80_state *state = space->machine->driver_data<super80_state>();
306   UINT8 *videoram = state->videoram;
307   if (super80_shared & 4)
310
311   if (state->super80_shared & 4)
312   {
313      UINT8 *videoram = state->videoram;
308314      return videoram[offset];
315   }
309316   else
310      return super80_colorram[offset];
317   {
318      UINT8 *colorram = state->colorram;
319      return colorram[offset];
320   }
311321}
312322
313323WRITE8_HANDLER( super80v_low_w )
314324{
315325   super80_state *state = space->machine->driver_data<super80_state>();
316   UINT8 *videoram = state->videoram;
317   if (super80_shared & 4)
326   
327   if (state->super80_shared & 4)
328   {
329      UINT8 *videoram = state->videoram;
318330      videoram[offset] = data;
331   }
319332   else
320      super80_colorram[offset] = data;
333   {
334      UINT8 *colorram = state->colorram;
335      colorram[offset] = data;
336   }
321337}
322338
323339READ8_HANDLER( super80v_high_r )
324340{
325   if (~super80_shared & 4)
326      return super80_colorram[0x800+offset];
341   super80_state *state = space->machine->driver_data<super80_state>();
327342
328   if (super80_shared & 0x10)
329      return super80_pcgram[0x800+offset];
343   if (~state->super80_shared & 4)
344   {
345      UINT8 *colorram = state->colorram;
346      return colorram[0x800+offset];
347   }
330348   else
331      return super80_pcgram[offset];
349   {
350      UINT8 *pcgram = state->pcgram;
351      if (state->super80_shared & 0x10)
352         return pcgram[0x800+offset];
353      else
354         return pcgram[offset];
355   }
332356}
333357
334358WRITE8_HANDLER( super80v_high_w )
335359{
336360   super80_state *state = space->machine->driver_data<super80_state>();
337   UINT8 *videoram = state->videoram;
338   if (~super80_shared & 4)
339      super80_colorram[offset+0x800] = data;
361
362   if (~state->super80_shared & 4)
363   {
364      UINT8 *colorram = state->colorram;
365      colorram[offset+0x800] = data;
366   }
340367   else
341368   {
369      UINT8 *videoram = state->videoram;
342370      videoram[offset+0x800] = data;
343371
344      if (super80_shared & 0x10)
345         super80_pcgram[0x800+offset] = data;
372      if (state->super80_shared & 0x10)
373      {
374         UINT8 *pcgram = state->pcgram;
375         pcgram[0x800+offset] = data;
376      }
346377   }
347378}
348379
r9179r9180
407438
408439VIDEO_UPDATE( super80v )
409440{
441   super80_state *state = screen->machine->driver_data<super80_state>();
410442   framecnt++;
411443   speed = mc6845_reg[10]&0x20, flash = mc6845_reg[10]&0x40;         // cursor modes
412444   cursor = (mc6845_reg[14]<<8) | mc6845_reg[15];               // get cursor position
413445   s_options=input_port_read(screen->machine, "CONFIG");
414   output_set_value("cass_led",(super80_shared & 0x20) ? 1 : 0);
446   output_set_value("cass_led",(state->super80_shared & 0x20) ? 1 : 0);
415447   mc6845_update(mc6845, bitmap, cliprect);
416448   return 0;
417449}
r9179r9180
420452{
421453   super80_state *state = device->machine->driver_data<super80_state>();
422454   UINT8 *videoram = state->videoram;
455   UINT8 *pcgram = state->pcgram;
456   UINT8 *colorram = state->colorram;
423457   UINT8 chr,col,gfx,fg,bg=0;
424458   UINT16 mem,x;
425459   UINT16  *p = BITMAP_ADDR16(bitmap, y, 0);
r9179r9180
437471
438472      if (~s_options & 0x40)
439473      {
440         col = super80_colorram[mem];               /* byte of colour to display */
474         col = colorram[mem];               /* byte of colour to display */
441475         fg = col & 0x0f;
442476         bg = (col & 0xf0) >> 4;
443477      }
444478
445479      /* if inverse mode, replace any pcgram chrs with inverse chrs */
446      if ((~super80_shared & 0x10) && (chr & 0x80))         // is it a high chr in inverse mode
480      if ((~state->super80_shared & 0x10) && (chr & 0x80))         // is it a high chr in inverse mode
447481      {
448482         inv ^= 0xff;                  // invert the chr
449483         chr &= 0x7f;                  // and drop bit 7
r9179r9180
457491            inv ^= mc6845_cursor[ra];
458492
459493      /* get pattern of pixels for that character scanline */
460      gfx = super80_pcgram[(chr<<4) | ra] ^ inv;
494      gfx = pcgram[(chr<<4) | ra] ^ inv;
461495
462496      /* Display a scanline of a character (7 pixels) */
463497      *p++ = ( gfx & 0x80 ) ? fg : bg;
src/mess/includes/super80.h
r9179r9180
11#include "video/mc6845.h"
22#include "machine/z80pio.h"
33
4/* Bits in shared variable:
5    d5 cassette LED
6    d4 super80v rom or pcg bankswitch (1=pcg ram, 0=char gen rom)
7    d2 super80v video or colour bankswitch (1=video ram, 0=colour ram)
8    d2 super80 screen off (=2mhz) or on (bursts of 2mhz at 50hz = 1mhz) */
9
10
11
412class super80_state : public driver_device
513{
614public:
715   super80_state(running_machine &machine, const driver_device_config_base &config)
816      : driver_device(machine, config) { }
917
18   UINT8 super80_shared;
1019   UINT8 *videoram;
20   UINT8 *pcgram;
21   UINT8 *colorram;
1122};
1223
1324
14/*----------- defined in drivers/super80.c -----------*/
15
16extern UINT8 *super80_pcgram;
17
1825/*----------- defined in video/super80.c -----------*/
1926
2027PALETTE_INIT( super80m );
r9179r9180
4754DRIVER_INIT( super80 );
4855DRIVER_INIT( super80v );
4956
50extern UINT8 super80_shared;
5157extern const z80pio_interface super80_pio_intf;
5258
src/mess/drivers/super80.c
r9179r9180
188188#include "super80.lh"
189189#include "includes/super80.h"
190190
191UINT8 *super80_pcgram;
192
193191#define MASTER_CLOCK         (XTAL_12MHz)
194192#define PIXEL_CLOCK         (MASTER_CLOCK/2)
195193#define HTOTAL            (384)
r9179r9180
228226   AM_RANGE(0x0000, 0x3fff) AM_RAMBANK("bank1")
229227   AM_RANGE(0x4000, 0xbfff) AM_RAM
230228   AM_RANGE(0xc000, 0xefff) AM_ROM
231   AM_RANGE(0xf000, 0xf7ff) AM_READWRITE(super80v_low_r, super80v_low_w) AM_BASE(&super80_pcgram)
229   AM_RANGE(0xf000, 0xf7ff) AM_READWRITE(super80v_low_r, super80v_low_w) AM_BASE_MEMBER(super80_state, pcgram)
232230   AM_RANGE(0xf800, 0xffff) AM_READWRITE(super80v_high_r, super80v_high_w)
233231ADDRESS_MAP_END
234232

Previous 15994 Revisions Next


© 1998-2018 The MESS Team