Previous 15994 Revisions Next

r1903 Tuesday 11th March, 2008 at 17:30:56 UTC by Wilbert Pol
[WSWAN] Updates to pass running_machine around.
[src/mess/includes]wswan.h
[src/mess/machine]wswan.c
[src/mess/video]wswan.c

src/mess/includes/wswan.h
r1902r1903
103103
104104/*----------- defined in video/wswan.c -----------*/
105105
106extern void wswan_refresh_scanline(void);
106extern void wswan_refresh_scanline( running_machine *machine );
107107
108108
109109/*----------- defined in audio/wswan.c -----------*/
src/mess/video/wswan.c
r1902r1903
99
1010***************************************************************************/
1111#include "driver.h"
12#include "deprecat.h"
1312#include "includes/wswan.h"
1413
1514static int pal[16][16];
r1902r1903
6766   }
6867}
6968
70static void wswan_draw_background(void) {
69static void wswan_draw_background( running_machine *machine ) {
7170   UINT16   map_addr;
7271   UINT8   start_column;
7372   int   column;
r1902r1903
137136            if ( vdp.colors_16 ) {
138137               if ( col ) {
139138                  if ( vdp.color_mode ) {
140                     wswan_plot_pixel( x_offset, vdp.current_line, Machine->pens[pal[tile_palette][col]] );
139                     wswan_plot_pixel( x_offset, vdp.current_line, machine->pens[pal[tile_palette][col]] );
141140                  } else {
142141                     /* Hmmmm, what should we do here... Is this correct?? */
143                     wswan_plot_pixel( x_offset, vdp.current_line, Machine->pens[pal[tile_palette][col]] );
142                     wswan_plot_pixel( x_offset, vdp.current_line, machine->pens[pal[tile_palette][col]] );
144143                  }
145144               }
146145            } else {
147146               if ( col || !(tile_palette & 4 ) ) {
148147                  if ( vdp.color_mode ) {
149                     wswan_plot_pixel( x_offset, vdp.current_line, Machine->pens[pal[tile_palette][col]] );
148                     wswan_plot_pixel( x_offset, vdp.current_line, machine->pens[pal[tile_palette][col]] );
150149                  } else {
151                     wswan_plot_pixel( x_offset, vdp.current_line, Machine->pens[vdp.main_palette[pal[tile_palette][col]]] );
150                     wswan_plot_pixel( x_offset, vdp.current_line, machine->pens[vdp.main_palette[pal[tile_palette][col]]] );
152151                  }
153152               }
154153            }
r1902r1903
157156   }
158157}
159158
160static void wswan_draw_foreground_0( void ) {
159static void wswan_draw_foreground_0( running_machine *machine ) {
161160   UINT16   map_addr;
162161   UINT8   start_column;
163162   int   column;
r1902r1903
224223            if ( vdp.colors_16 ) {
225224               if ( col ) {
226225//                  if ( vdp.color_mode ) {
227                     wswan_plot_pixel( x_offset, vdp.current_line, Machine->pens[pal[tile_palette][col]] );
226                     wswan_plot_pixel( x_offset, vdp.current_line, machine->pens[pal[tile_palette][col]] );
228227//                  } else {
229228//                     /* Hmmmm, what should we do here... Is this correct?? */
230//                     wswan_plot_pixel( x_offset, vdp.current_line, Machine->pens[pal[tile_palette][col]] );
229//                     wswan_plot_pixel( x_offset, vdp.current_line, machine->pens[pal[tile_palette][col]] );
231230//                  }
232231               }
233232            } else {
234233               if ( col || !(tile_palette & 4 ) ) {
235234                  if ( vdp.color_mode ) {
236                     wswan_plot_pixel( x_offset, vdp.current_line, Machine->pens[pal[tile_palette][col]] );
235                     wswan_plot_pixel( x_offset, vdp.current_line, machine->pens[pal[tile_palette][col]] );
237236                  } else {
238                     wswan_plot_pixel( x_offset, vdp.current_line, Machine->pens[vdp.main_palette[pal[tile_palette][col]]] );
237                     wswan_plot_pixel( x_offset, vdp.current_line, machine->pens[vdp.main_palette[pal[tile_palette][col]]] );
239238                  }
240239               }
241240            }
r1902r1903
244243   }
245244}
246245
247static void wswan_draw_foreground_2( void ) {
246static void wswan_draw_foreground_2( running_machine *machine ) {
248247   UINT16   map_addr;
249248   UINT8   start_column;
250249   int   column;
r1902r1903
311310            if ( vdp.colors_16 ) {
312311               if ( col ) {
313312                  if ( vdp.color_mode ) {
314                     wswan_plot_pixel( x_offset, vdp.current_line, Machine->pens[pal[tile_palette][col]] );
313                     wswan_plot_pixel( x_offset, vdp.current_line, machine->pens[pal[tile_palette][col]] );
315314                  } else {
316315                     /* Hmmmm, what should we do here... Is this correct?? */
317                     wswan_plot_pixel( x_offset, vdp.current_line, Machine->pens[pal[tile_palette][col]] );
316                     wswan_plot_pixel( x_offset, vdp.current_line, machine->pens[pal[tile_palette][col]] );
318317                  }
319318               }
320319            } else {
321320               if ( col || !(tile_palette & 4 ) ) {
322321                  if ( vdp.color_mode ) {
323                     wswan_plot_pixel( x_offset, vdp.current_line, Machine->pens[pal[tile_palette][col]] );
322                     wswan_plot_pixel( x_offset, vdp.current_line, machine->pens[pal[tile_palette][col]] );
324323                  } else {
325                     wswan_plot_pixel( x_offset, vdp.current_line, Machine->pens[vdp.main_palette[pal[tile_palette][col]]] );
324                     wswan_plot_pixel( x_offset, vdp.current_line, machine->pens[vdp.main_palette[pal[tile_palette][col]]] );
326325                  }
327326               }
328327            }
r1902r1903
331330   }
332331}
333332
334static void wswan_draw_foreground_3( void ) {
333static void wswan_draw_foreground_3( running_machine *machine ) {
335334   UINT16   map_addr;
336335   UINT8   start_column;
337336   int   column;
r1902r1903
398397            if ( vdp.colors_16 ) {
399398               if ( col ) {
400399                  if ( vdp.color_mode ) {
401                     wswan_plot_pixel( x_offset, vdp.current_line, Machine->pens[pal[tile_palette][col]] );
400                     wswan_plot_pixel( x_offset, vdp.current_line, machine->pens[pal[tile_palette][col]] );
402401                  } else {
403402                     /* Hmmmm, what should we do here... Is this correct?? */
404                     wswan_plot_pixel( x_offset, vdp.current_line, Machine->pens[pal[tile_palette][col]] );
403                     wswan_plot_pixel( x_offset, vdp.current_line, machine->pens[pal[tile_palette][col]] );
405404                  }
406405               }
407406            } else {
408407               if ( col || !(tile_palette & 4 ) ) {
409408                  if ( vdp.color_mode ) {
410                     wswan_plot_pixel( x_offset, vdp.current_line, Machine->pens[pal[tile_palette][col]] );
409                     wswan_plot_pixel( x_offset, vdp.current_line, machine->pens[pal[tile_palette][col]] );
411410                  } else {
412                     wswan_plot_pixel( x_offset, vdp.current_line, Machine->pens[vdp.main_palette[pal[tile_palette][col]]] );
411                     wswan_plot_pixel( x_offset, vdp.current_line, machine->pens[vdp.main_palette[pal[tile_palette][col]]] );
413412                  }
414413               }
415414            }
r1902r1903
418417   }
419418}
420419
421static void wswan_handle_sprites( int mask ) {
420static void wswan_handle_sprites( running_machine *machine, int mask ) {
422421   int   i;
423422   if ( vdp.sprite_count == 0 )
424423      return;
r1902r1903
515514               if ( vdp.colors_16 ) {
516515                  if ( col ) {
517516                     if ( vdp.color_mode ) {
518                        wswan_plot_pixel( x_offset, vdp.current_line, Machine->pens[pal[tile_palette][col]] );
517                        wswan_plot_pixel( x_offset, vdp.current_line, machine->pens[pal[tile_palette][col]] );
519518                     } else {
520519                        /* Hmmmm, what should we do here... Is this correct?? */
521                        wswan_plot_pixel( x_offset, vdp.current_line, Machine->pens[pal[tile_palette][col]] );
520                        wswan_plot_pixel( x_offset, vdp.current_line, machine->pens[pal[tile_palette][col]] );
522521                     }
523522                  }
524523               } else {
525524                  if ( col || !(tile_palette & 4 ) ) {
526525                     if ( vdp.color_mode ) {
527                        wswan_plot_pixel( x_offset, vdp.current_line, Machine->pens[pal[tile_palette][col]] );
526                        wswan_plot_pixel( x_offset, vdp.current_line, machine->pens[pal[tile_palette][col]] );
528527                     } else {
529                        wswan_plot_pixel( x_offset, vdp.current_line, Machine->pens[vdp.main_palette[pal[tile_palette][col]]] );
528                        wswan_plot_pixel( x_offset, vdp.current_line, machine->pens[vdp.main_palette[pal[tile_palette][col]]] );
530529                     }
531530                  }
532531               }
r1902r1903
536535   }
537536}
538537
539void wswan_refresh_scanline(void)
538void wswan_refresh_scanline( running_machine *machine )
540539{
541540   rectangle rec;
542541
r1902r1903
548547   if ( ws_portram[0x14] ) {
549548      /* Not sure if these background color checks and settings are correct */
550549      if ( vdp.color_mode && vdp.colors_16 ) {
551         wswan_fillbitmap( Machine->pens[ pal[ws_portram[0x01]>>4][ws_portram[0x01]&0x0F] ], &rec );
550         wswan_fillbitmap( machine->pens[ pal[ws_portram[0x01]>>4][ws_portram[0x01]&0x0F] ], &rec );
552551      } else {
553         wswan_fillbitmap( Machine->pens[ vdp.main_palette[ws_portram[0x01]&0x07] ], &rec );
552         wswan_fillbitmap( machine->pens[ vdp.main_palette[ws_portram[0x01]&0x07] ], &rec );
554553      }
555554   } else {
556      wswan_fillbitmap( Machine->pens[ 0 ], &rec );
555      wswan_fillbitmap( machine->pens[ 0 ], &rec );
557556      return;
558557   }
559558
r1902r1903
561560    * Draw background layer
562561    */
563562   if ( vdp.layer_bg_enable ) {
564      wswan_draw_background();
563      wswan_draw_background( machine );
565564   }
566565
567566   /*
568567    * Draw sprites between background and foreground layers
569568    */
570569   if ( vdp.sprites_enable ) {
571      wswan_handle_sprites( 0 );
570      wswan_handle_sprites( machine, 0 );
572571   }
573572
574573   /*
r1902r1903
577576   if ( vdp.layer_fg_enable ) {
578577      switch( vdp.window_fg_mode ) {
579578      case 0:   /* FG inside & outside window area */
580         wswan_draw_foreground_0();
579         wswan_draw_foreground_0( machine );
581580         break;
582581      case 1:   /* ??? */
583582         logerror( "Unknown foreground mode 1 set\n" );
584583         break;
585584      case 2:   /* FG only inside window area */
586585         if ( vdp.current_line >= vdp.window_fg_top && vdp.current_line <= vdp.window_fg_bottom ) {
587            wswan_draw_foreground_2();
586            wswan_draw_foreground_2( machine );
588587         }
589588         break;
590589      case 3:   /* FG only outside window area */
591590         if ( vdp.current_line < vdp.window_fg_top || vdp.current_line > vdp.window_fg_bottom ) {
592            wswan_draw_foreground_0();
591            wswan_draw_foreground_0( machine );
593592         } else {
594            wswan_draw_foreground_3();
593            wswan_draw_foreground_3( machine );
595594         }
596595         break;
597596      }
r1902r1903
601600    * Draw sprites in front of foreground layer
602601    */
603602   if ( vdp.sprites_enable ) {
604      wswan_handle_sprites( 0x2000 );
603      wswan_handle_sprites( machine, 0x2000 );
605604   }
606605}
607606
src/mess/machine/wswan.c
r1902r1903
1616***************************************************************************/
1717
1818#include "driver.h"
19#include "deprecat.h"
2019#include "includes/wswan.h"
2120#include "image.h"
2221
r1902r1903
125124   0xea, 0xc0, 0xff, 0x00, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
126125};
127126
128static void wswan_handle_irqs( void ) {
127static void wswan_handle_irqs( running_machine *machine ) {
129128   if ( ws_portram[0xb2] & ws_portram[0xb6] & WSWAN_IFLAG_HBLTMR ) {
130      cpunum_set_input_line_and_vector( Machine, 0, 0, HOLD_LINE, ws_portram[0xb0] + WSWAN_INT_HBLTMR );
129      cpunum_set_input_line_and_vector( machine, 0, 0, HOLD_LINE, ws_portram[0xb0] + WSWAN_INT_HBLTMR );
131130   } else if ( ws_portram[0xb2] & ws_portram[0xb6] & WSWAN_IFLAG_VBL ) {
132      cpunum_set_input_line_and_vector( Machine, 0, 0, HOLD_LINE, ws_portram[0xb0] + WSWAN_INT_VBL );
131      cpunum_set_input_line_and_vector( machine, 0, 0, HOLD_LINE, ws_portram[0xb0] + WSWAN_INT_VBL );
133132   } else if ( ws_portram[0xb2] & ws_portram[0xb6] & WSWAN_IFLAG_VBLTMR ) {
134      cpunum_set_input_line_and_vector( Machine, 0, 0, HOLD_LINE, ws_portram[0xb0] + WSWAN_INT_VBLTMR );
133      cpunum_set_input_line_and_vector( machine, 0, 0, HOLD_LINE, ws_portram[0xb0] + WSWAN_INT_VBLTMR );
135134   } else if ( ws_portram[0xb2] & ws_portram[0xb6] & WSWAN_IFLAG_LCMP ) {
136      cpunum_set_input_line_and_vector( Machine, 0, 0, HOLD_LINE, ws_portram[0xb0] + WSWAN_INT_LCMP );
135      cpunum_set_input_line_and_vector( machine, 0, 0, HOLD_LINE, ws_portram[0xb0] + WSWAN_INT_LCMP );
137136   } else if ( ws_portram[0xb2] & ws_portram[0xb6] & WSWAN_IFLAG_SRX ) {
138      cpunum_set_input_line_and_vector( Machine, 0, 0, HOLD_LINE, ws_portram[0xb0] + WSWAN_INT_SRX );
137      cpunum_set_input_line_and_vector( machine, 0, 0, HOLD_LINE, ws_portram[0xb0] + WSWAN_INT_SRX );
139138   } else if ( ws_portram[0xb2] & ws_portram[0xb6] & WSWAN_IFLAG_RTC ) {
140      cpunum_set_input_line_and_vector( Machine, 0, 0, HOLD_LINE, ws_portram[0xb0] + WSWAN_INT_RTC );
139      cpunum_set_input_line_and_vector( machine, 0, 0, HOLD_LINE, ws_portram[0xb0] + WSWAN_INT_RTC );
141140   } else if ( ws_portram[0xb2] & ws_portram[0xb6] & WSWAN_IFLAG_KEY ) {
142      cpunum_set_input_line_and_vector( Machine, 0, 0, HOLD_LINE, ws_portram[0xb0] + WSWAN_INT_KEY );
141      cpunum_set_input_line_and_vector( machine, 0, 0, HOLD_LINE, ws_portram[0xb0] + WSWAN_INT_KEY );
143142   } else if ( ws_portram[0xb2] & ws_portram[0xb6] & WSWAN_IFLAG_STX ) {
144      cpunum_set_input_line_and_vector( Machine, 0, 0, HOLD_LINE, ws_portram[0xb0] + WSWAN_INT_STX );
143      cpunum_set_input_line_and_vector( machine, 0, 0, HOLD_LINE, ws_portram[0xb0] + WSWAN_INT_STX );
145144   } else {
146      cpunum_set_input_line(Machine, 0, 0, CLEAR_LINE );
145      cpunum_set_input_line(machine, 0, 0, CLEAR_LINE );
147146   }
148147}
149148
150static void wswan_set_irq_line(int irq) {
149static void wswan_set_irq_line( running_machine *machine, int irq) {
151150   if ( ws_portram[0xb2] & irq ) {
152151      ws_portram[0xb6] |= irq;
153      wswan_handle_irqs();
152      wswan_handle_irqs( machine );
154153   }
155154}
156155
157static void wswan_clear_irq_line(int irq) {
156static void wswan_clear_irq_line( running_machine *machine, int irq) {
158157   ws_portram[0xb6] &= ~irq;
159   wswan_handle_irqs();
158   wswan_handle_irqs( machine );
160159}
161160
162161static TIMER_CALLBACK(wswan_rtc_callback)
r1902r1903
963962               Bit 6   - VBlank interrupt acknowledge
964963               Bit 7   - HBlank timer interrupt acknowledge
965964            */
966         wswan_clear_irq_line( data );
965         wswan_clear_irq_line( machine, data );
967966         data = ws_portram[0xB6];
968967         break;
969968      case 0xba:   /* Internal EEPROM data (low)
r1902r1903
13571356INTERRUPT_GEN(wswan_scanline_interrupt)
13581357{
13591358   if( vdp.current_line < 144 ) {
1360      wswan_refresh_scanline();
1359      wswan_refresh_scanline( machine );
13611360   }
13621361
13631362   /* Decrement 12kHz (HBlank) counter */
r1902r1903
13711370            vdp.timer_hblank_reload = 0;
13721371         }
13731372         logerror( "trigerring hbltmr interrupt\n" );
1374         wswan_set_irq_line( WSWAN_IFLAG_HBLTMR );
1373         wswan_set_irq_line( machine, WSWAN_IFLAG_HBLTMR );
13751374      }
13761375   }
13771376
r1902r1903
13891388//   vdp.current_line = (vdp.current_line + 1) % 159;
13901389
13911390   if( vdp.current_line == 144 ) {
1392      wswan_set_irq_line( WSWAN_IFLAG_VBL );
1391      wswan_set_irq_line( machine, WSWAN_IFLAG_VBL );
13931392      /* Decrement 75Hz (VBlank) counter */
13941393      if ( vdp.timer_vblank_enable && vdp.timer_vblank_reload != 0 ) {
13951394         vdp.timer_vblank_count--;
r1902r1903
14011400               vdp.timer_vblank_reload = 0;
14021401            }
14031402            logerror( "triggering vbltmr interrupt\n" );
1404            wswan_set_irq_line( WSWAN_IFLAG_VBLTMR );
1403            wswan_set_irq_line( machine, WSWAN_IFLAG_VBLTMR );
14051404         }
14061405      }
14071406   }
r1902r1903
14091408//   vdp.current_line = (vdp.current_line + 1) % 159;
14101409
14111410   if ( vdp.current_line == vdp.line_compare ) {
1412      wswan_set_irq_line( WSWAN_IFLAG_LCMP );
1411      wswan_set_irq_line( machine, WSWAN_IFLAG_LCMP );
14131412   }
14141413
14151414   vdp.current_line = (vdp.current_line + 1) % 159;

Previous 15994 Revisions Next


© 1998-2018 The MESS Team