Previous 15994 Revisions Next

r9583 Sunday 14th November, 2010 at 18:25:58 UTC by Curt Coder
[ABC80] Refactored video to work like real hardware.
[docs]messnew.txt
[src/mess/drivers]abc80.c
[src/mess/includes]abc80.h
[src/mess/video]abc80.c

src/mess/video/abc80.c
r9582r9583
3636
3737
3838//-------------------------------------------------
39//  PALETTE_INIT( abc80 )
39//  TIMER_DEVICE_CALLBACK( blink_tick )
4040//-------------------------------------------------
4141
42static PALETTE_INIT( abc80 )
42static TIMER_DEVICE_CALLBACK( blink_tick )
4343{
44   palette_set_color(machine, 0, RGB_BLACK);
45   palette_set_color(machine, 1, RGB_WHITE);
46   palette_set_color(machine, 2, RGB_WHITE);
47   palette_set_color(machine, 3, RGB_BLACK);
44   abc80_state *state = timer.machine->driver_data<abc80_state>();
45
46   state->m_blink = !state->m_blink;
4847}
4948
5049
5150//-------------------------------------------------
52//  TILE_GET_INFO( abc80_get_tile_info )
51//  TIMER_DEVICE_CALLBACK( vsync_on_tick )
5352//-------------------------------------------------
5453
55static TILE_GET_INFO( abc80_get_tile_info )
54static TIMER_DEVICE_CALLBACK( vsync_on_tick )
5655{
57   abc80_state *state = machine->driver_data<abc80_state>();
56   abc80_state *state = timer.machine->driver_data<abc80_state>();
5857
59   int attr = state->m_video_ram[tile_index];
60   int code = attr & 0x7f;
61   int color = (state->m_blink && (attr & 0x80)) ? 1 : 0;
62   int r = (tile_index & 0x78) >> 3;
63   int l = (tile_index & 0x380) >> 7;
64   int row = l + ((r / 5) * 8);
65
66   if (row != state->m_char_row)
67   {
68      state->m_char_bank = 0;
69      state->m_char_row = row;
70   }
71
72   if (code == ABC80_MODE_TEXT)
73   {
74      state->m_char_bank = 0;
75   }
76
77   if (code == ABC80_MODE_GFX)
78   {
79      state->m_char_bank = 1;
80   }
81
82   SET_TILE_INFO(state->m_char_bank, code, color, 0);
58   cpu_set_input_line(state->m_maincpu, INPUT_LINE_NMI, ASSERT_LINE);
8359}
8460
8561
8662//-------------------------------------------------
87//  abc80_tilemap_scan - tilemap scanning
63//  TIMER_DEVICE_CALLBACK( vsync_off_tick )
8864//-------------------------------------------------
8965
90static UINT32 abc80_tilemap_scan( UINT32 col, UINT32 row, UINT32 num_cols, UINT32 num_rows )
66static TIMER_DEVICE_CALLBACK( vsync_off_tick )
9167{
92   /* logical (col,row) -> memory offset */
93   return ((row & 0x07) << 7) + (row >> 3) * num_cols + col;
94}
95
96
97//-------------------------------------------------
98//  TIMER_DEVICE_CALLBACK( blink_tick )
99//-------------------------------------------------
100
101static TIMER_DEVICE_CALLBACK( blink_tick )
102{
10368   abc80_state *state = timer.machine->driver_data<abc80_state>();
10469
105   state->m_blink = !state->m_blink;
70   cpu_set_input_line(state->m_maincpu, INPUT_LINE_NMI, CLEAR_LINE);
10671}
10772
10873
r9582r9583
11277
11378void abc80_state::update_screen(bitmap_t *bitmap, const rectangle *cliprect)
11479{
115   UINT16 videoram_addr;
116   int y, sx, c = 0, r = 0;
80   int c = 0;
81   int r = 0;
82   int mode = 0;
11783
118   for (y = 0; y < 312; y++)
84   for (int y = 0; y < 312; y++)
11985   {
12086      UINT8 vsync_data = m_vsync_prom[y];
12187      UINT8 l = m_line_prom[y];
12288      int dv = (vsync_data & ABC80_K2_DV) ? 1 : 0;
123      int mode = 1;
12489
125      if (vsync_data & ABC80_K2_FRAME_END)
90      if (!(vsync_data & ABC80_K2_FRAME_RESET))
91      {
92         // reset F2
12693         r = 0;
94      }
12795
128      if (vsync_data & ABC80_K2_FRAME_START)
129         r++;
130
131      for (sx = 0; sx < 64; sx++)
96      for (int sx = 0; sx < 64; sx++)
13297      {
13398         UINT8 hsync_data = m_hsync_prom[sx];
13499         int dh = (hsync_data & ABC80_K5_DH) ? 1 : 0;
135         UINT8 attr_addr;
136         UINT8 videoram_data, attr_data;
137100         UINT8 data = 0;
138         int cursor, blank, tecken, graf, versal;
139         int bit;
140101
141102         if (hsync_data & ABC80_K5_LINE_END)
103         {
104            // reset F4
142105            c = 0;
143106
144         if (hsync_data & ABC80_K5_ROW_START)
145            c++;
107            // reset J5
108            mode = 0;
109         }
146110
147111         /*
148112
r9582r9583
155119
156120            */
157121
158         videoram_addr = ((r & 0x07) << 7) | ((((c >> 3) & 0x07) + ((r >> 3) | (r >> 1))) & 0x0f) | (c & 0x07);
159         videoram_data = m_video_ram[videoram_addr];
160         attr_addr = ((dh & dv) << 7) & (data & 0x7f);
161         attr_data = m_attr_prom[attr_addr];
122         int a = (c >> 3) & 0x07;
123         int b = ((r >> 1) & 0x0c) | ((r >> 3) & 0x03);
124         int s = (a + b) & 0x0f;
125         UINT16 videoram_addr = ((r & 0x07) << 7) | (s << 3) | (c & 0x07);
126         UINT8 videoram_data = m_latch;
127         UINT8 attr_addr = ((dh & dv) << 7) | (videoram_data & 0x7f);
128         UINT8 attr_data = m_attr_prom[attr_addr];
162129
163         blank = (attr_data & ABC80_J3_BLANK) ? 1 : 0;
164         tecken = (attr_data & ABC80_J3_TEXT) ? 1 : 0;
165         graf = (attr_data & ABC80_J3_GRAPHICS) ? 1 : 0;
166         versal = (attr_data & ABC80_J3_VERSAL) ? 1 : 0;
167         cursor = (videoram_data & ABC80_CHAR_CURSOR) ? 1 : 0;
130         int blank = (attr_data & ABC80_J3_BLANK) ? 1 : 0;
131         int j = (attr_data & ABC80_J3_TEXT) ? 1 : 0;
132         int k = (attr_data & ABC80_J3_GRAPHICS) ? 1 : 0;
133         int versal = (attr_data & ABC80_J3_VERSAL) ? 1 : 0;
134         int cursor = (videoram_data & ABC80_CHAR_CURSOR) ? 1 : 0;
168135
169         if (tecken) mode = 1;
170         if (graf) mode = 0;
136         if (!j && k) mode = 0;
137         if (j && !k) mode = 1;
138         if (j && k) mode = !mode;
171139
172         if (mode || versal)
140         if (mode & versal)
173141         {
174            /* text mode */
142            // graphics mode
143            int r0 = 1, r1 = 1, r2 = 1;
175144
176            UINT16 chargen_addr = ((videoram_data & 0x7f) * 10) + l;
145            if (l < 3) r0 = 0; else if (l < 7) r1 = 0; else r2 = 0;
177146
178            data = m_char_rom[chargen_addr];
147            int c0 = BIT(videoram_data, 0) | r0;
148            int c1 = BIT(videoram_data, 1) | r0;
149            int c2 = BIT(videoram_data, 2) | r1;
150            int c3 = BIT(videoram_data, 3) | r1;
151            int c4 = BIT(videoram_data, 4) | r2;
152            int c5 = BIT(videoram_data, 6) | r2;
153
154            if (!(c0 & c2 & c4)) data |= 0xe0;
155            if (!(c1 & c3 & c5)) data |= 0x1c;
179156         }
180157         else
181158         {
182            /* graphics mode */
159            // text mode
160            UINT16 chargen_addr = ((videoram_data & 0x7f) * 10) + l;
183161
184            int c0, c1, c2, c3, c4, c5;
185            int r0 = 1, r1 = 1, r2 = 1;
186
187            switch (l)
188            {
189            case 0: case 1: case 2:
190               r0 = 0;
191               break;
192            case 3: case 4: case 5: case 6:
193               r1 = 0;
194               break;
195            case 7: case 8: case 9:
196               r2 = 0;
197               break;
198            }
199
200            c0 = BIT(videoram_data, 0) | r2;
201            c1 = BIT(videoram_data, 2) | r2;
202            c2 = BIT(videoram_data, 3) | r1;
203            c3 = BIT(videoram_data, 4) | r1;
204            c4 = BIT(videoram_data, 5) | r0;
205            c5 = BIT(videoram_data, 6) | r0;
206
207            if (c0 & c2 & c4) data |= 0x38;
208            if (c1 & c3 & c5) data |= 0x07;
162            data = m_char_rom[chargen_addr];
209163         }
210164
211         data <<= 2;
212
213         /* shift out pixels */
214         for (bit = 0; bit < 6; bit++)
165         // shift out pixels
166         for (int bit = 0; bit < 6; bit++)
215167         {
216168            int color = BIT(data, 7);
217169            int x = (sx * 6) + bit;
r9582r9583
223175
224176            data <<= 1;
225177         }
178
179         m_latch = m_video_ram[videoram_addr];
180
181         if (hsync_data & ABC80_K5_ROW_START)
182         {
183            // clock F4
184            c++;
185         }
226186      }
187
188      if (vsync_data & ABC80_K2_FRAME_END)
189      {
190         // clock F2
191         r++;
192      }
227193   }
228194}
229195
r9582r9583
234200
235201void abc80_state::video_start()
236202{
237   /* create tx_tilemap */
238   m_tx_tilemap = tilemap_create(machine, abc80_get_tile_info, abc80_tilemap_scan, 6, 10, 40, 24);
239
240   tilemap_set_scrolldx(m_tx_tilemap, ABC80_HDSTART, ABC80_HDSTART);
241   tilemap_set_scrolldy(m_tx_tilemap, ABC80_VDSTART, ABC80_VDSTART);
242
243   /* find memory regions */
203   // find memory regions
244204   m_char_rom = memory_region(machine, "chargen");
245205   m_hsync_prom = memory_region(machine, "hsync");
246206   m_vsync_prom = memory_region(machine, "vsync");
247207   m_line_prom = memory_region(machine, "line");
248208   m_attr_prom = memory_region(machine, "attr");
249209
250   /* register for state saving */
210   // register for state saving
251211   state_save_register_global(machine, m_blink);
252   state_save_register_global(machine, m_char_bank);
253   state_save_register_global(machine, m_char_row);
212   state_save_register_global(machine, m_latch);
254213}
255214
256215
r9582r9583
260219
261220bool abc80_state::video_update(screen_device &screen, bitmap_t &bitmap, const rectangle &cliprect)
262221{
263   rectangle rect;
222   update_screen(&bitmap, &cliprect);
264223
265   rect.min_x = ABC80_HDSTART;
266   rect.max_x = ABC80_HDSTART + 40 * 6 - 1;
267   rect.min_y = ABC80_VDSTART;
268   rect.max_y = ABC80_VDSTART + 240 - 1;
269
270   bitmap_fill(&bitmap, &cliprect, get_black_pen(machine));
271
272   tilemap_mark_all_tiles_dirty(m_tx_tilemap);
273   tilemap_draw(&bitmap, &rect, m_tx_tilemap, 0, 0);
274
275   //abc80_update(screen->machine, bitmap, cliprect);
276
277224   return 0;
278225}
279226
r9582r9583
284231
285232MACHINE_CONFIG_FRAGMENT( abc80_video )
286233   MDRV_TIMER_ADD_PERIODIC("blink", blink_tick, HZ(ABC80_XTAL/2/6/64/312/16))
234   MDRV_TIMER_ADD_SCANLINE("vsync_on", vsync_on_tick, SCREEN_TAG, 0, ABC80_VTOTAL)
235   MDRV_TIMER_ADD_SCANLINE("vsync_off", vsync_off_tick, SCREEN_TAG, 16, ABC80_VTOTAL)
287236
288237   MDRV_SCREEN_ADD(SCREEN_TAG, RASTER)
289238   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
290239
291240   MDRV_GFXDECODE(abc80)
292241   
293   MDRV_PALETTE_LENGTH(4)
294   MDRV_PALETTE_INIT(abc80)
242   MDRV_PALETTE_LENGTH(2)
243   MDRV_PALETTE_INIT(black_and_white)
295244
296245   MDRV_SCREEN_RAW_PARAMS(ABC80_XTAL/2, ABC80_HTOTAL, ABC80_HBEND, ABC80_HBSTART, ABC80_VTOTAL, ABC80_VBEND, ABC80_VBSTART)
297246MACHINE_CONFIG_END
src/mess/includes/abc80.h
r9582r9583
1010#define ABC80_XTAL      11980800.0
1111
1212#define ABC80_HTOTAL   384
13#define ABC80_HBEND      0
14#define ABC80_HBSTART   312
13#define ABC80_HBEND      35
14#define ABC80_HBSTART   384
1515#define ABC80_VTOTAL   312
16#define ABC80_VBEND      0
17#define ABC80_VBSTART   287
16#define ABC80_VBEND      15
17#define ABC80_VBSTART   312
1818
19#define ABC80_HDSTART   36 // unverified
20#define ABC80_VDSTART   23 // unverified
21
22#define ABC80_MODE_TEXT   0x07
23#define ABC80_MODE_GFX   0x17
24
2519#define ABC80_K5_HSYNC         0x01
2620#define ABC80_K5_DH            0x02
2721#define ABC80_K5_LINE_END      0x04
r9582r9583
3024#define ABC80_K2_VSYNC         0x01
3125#define ABC80_K2_DV            0x02
3226#define ABC80_K2_FRAME_END      0x04
33#define ABC80_K2_FRAME_START   0x08
27#define ABC80_K2_FRAME_RESET   0x08
3428
3529#define ABC80_J3_BLANK         0x01
3630#define ABC80_J3_TEXT         0x02
r9582r9583
8175   DECLARE_READ8_MEMBER( pio_pb_r );
8276   DECLARE_WRITE8_MEMBER( pio_pb_w );
8377
84   /* keyboard state */
78   // keyboard state
8579   int m_key_data;
8680   int m_key_strobe;
8781   int m_pio_astb;
8882
89   /* video state */
83   // video state
9084   UINT8 *m_video_ram;
9185   UINT8 *m_video_80_ram;
92   tilemap_t *m_tx_tilemap;
86   UINT8 m_latch;
9387   int m_blink;
94   int m_char_bank;
95   int m_char_row;
9688
97   /* memory regions */
98   const UINT8 *m_char_rom;      /* character generator ROM */
99   const UINT8 *m_hsync_prom;   /* horizontal sync PROM */
100   const UINT8 *m_vsync_prom;   /* horizontal sync PROM */
101   const UINT8 *m_line_prom;      /* line address PROM */
102   const UINT8 *m_attr_prom;      /* character attribute PROM */
89   // memory regions
90   const UINT8 *m_char_rom;      // character generator ROM
91   const UINT8 *m_hsync_prom;      // horizontal sync PROM
92   const UINT8 *m_vsync_prom;      // horizontal sync PROM
93   const UINT8 *m_line_prom;      // line address PROM
94   const UINT8 *m_attr_prom;      // character attribute PROM
10395};
10496
105/*----------- defined in video/abc80.c -----------*/
97//----------- defined in video/abc80.c -----------
10698
10799MACHINE_CONFIG_EXTERN( abc80_video );
108100
109#endif /* ABC80_H_ */
101#endif
src/mess/drivers/abc80.c
r9582r9583
501501
502502
503503//-------------------------------------------------
504//  INTERRUPT_GEN( abc80_nmi_interrupt )
505//-------------------------------------------------
506
507static INTERRUPT_GEN( abc80_nmi_interrupt )
508{
509   cputag_set_input_line(device->machine, Z80_TAG, INPUT_LINE_NMI, PULSE_LINE);
510}
511
512
513//-------------------------------------------------
514504//  Z80PIO_INTERFACE( pio_intf )
515505//-------------------------------------------------
516506
r9582r9583
713703   MDRV_CPU_PROGRAM_MAP(abc80_mem)
714704   MDRV_CPU_IO_MAP(abc80_io)
715705   MDRV_CPU_CONFIG(abc80_daisy_chain)
716   MDRV_CPU_VBLANK_INT(SCREEN_TAG, abc80_nmi_interrupt)
717706
718707   /* video hardware */
719708   MDRV_FRAGMENT_ADD(abc80_video)
docs/messnew.txt
r9582r9583
10.141
10.141
22
33New System Drivers Supported:
44-----------------------------
r9582r9583
2828
2929- [ABC80] Added graphics PROMs. [Ola Andersson]
3030
31- [ABC80] Refactored video to work like real hardware. [Curt Coder]
32
3133- [ABC800C] Added Color version ROMs. [Ola Andersson]
3234
3335- [SMS] Improved Light Phaser emulation and converted it to use timers

Previous 15994 Revisions Next


© 1998-2018 The MESS Team