Previous 199869 Revisions Next

r17390 Wednesday 22nd August, 2012 at 02:48:44 UTC by Angelo Salese
Brave man does brave things ... (nw)
[src/mame/includes]snes.h
[src/mame/video]snes.c

trunk/src/mame/includes/snes.h
r17389r17390
494494   DECLARE_DRIVER_INIT(snes_hirom);
495495   DECLARE_DRIVER_INIT(snes_mess);
496496   DECLARE_DRIVER_INIT(snesst);
497
498   inline UINT16 snes_get_bgcolor( UINT8 direct_colors, UINT16 palette, UINT8 color );
499   inline void snes_set_scanline_pixel( int screen, INT16 x, UINT16 color, UINT8 priority, UINT8 layer, int blend );
500   inline void snes_draw_bgtile_lores( UINT8 layer, INT16 ii, UINT8 colour, UINT16 pal, UINT8 direct_colors, UINT8 priority );
501   inline void snes_draw_bgtile_hires( UINT8 layer, INT16 ii, UINT8 colour, UINT16 pal, UINT8 direct_colors, UINT8 priority );
502   inline void snes_draw_oamtile( INT16 ii, UINT8 colour, UINT16 pal, UINT8 priority );
503   inline void snes_draw_tile( UINT8 planes, UINT8 layer, UINT32 tileaddr, INT16 x, UINT8 priority, UINT8 flip, UINT8 direct_colors, UINT16 pal, UINT8 hires );
504   inline UINT32 snes_get_tmap_addr( UINT8 layer, UINT8 tile_size, UINT32 base, UINT32 x, UINT32 y );
505   inline void snes_update_line( UINT16 curline, UINT8 layer, UINT8 priority_b, UINT8 priority_a, UINT8 color_depth, UINT8 hires, UINT8 offset_per_tile, UINT8 direct_colors );
506   void snes_update_line_mode7( UINT16 curline, UINT8 layer, UINT8 priority_b, UINT8 priority_a );
507   void snes_update_obsel( void );
508   void snes_oam_list_build( void );
509   int is_sprite_on_scanline( UINT16 curline, UINT8 sprite );
510   void snes_update_objects_rto( UINT16 curline );
511   void snes_update_objects( UINT8 priority_oam0, UINT8 priority_oam1, UINT8 priority_oam2, UINT8 priority_oam3 );
512   void snes_update_mode_0( UINT16 curline );
513   void snes_update_mode_1( UINT16 curline );
514   void snes_update_mode_2( UINT16 curline );
515   void snes_update_mode_3( UINT16 curline );
516   void snes_update_mode_4( UINT16 curline );
517   void snes_update_mode_5( UINT16 curline );
518   void snes_update_mode_6( UINT16 curline );
519   void snes_update_mode_7( UINT16 curline );
520   void snes_draw_screens( UINT16 curline );
521   void snes_update_windowmasks( void );
522   void snes_update_offsets( void );
523   inline void snes_draw_blend( UINT16 offset, UINT16 *colour, UINT8 prevent_color_math, UINT8 black_pen_clip, int switch_screens );
524   void snes_refresh_scanline( running_machine &machine, bitmap_rgb32 &bitmap, UINT16 curline );
525
497526};
498527
499528/* Special chips, checked at init and used in memory handlers */
trunk/src/mame/video/snes.c
r17389r17390
140140 * Get the proper color (direct or from cgram)
141141 *****************************************/
142142
143INLINE UINT16 snes_get_bgcolor( UINT8 direct_colors, UINT16 palette, UINT8 color )
143inline UINT16 snes_state::snes_get_bgcolor( UINT8 direct_colors, UINT16 palette, UINT8 color )
144144{
145145   UINT16 c = 0;
146146
r17389r17390
164164 * proper scanline
165165 *****************************************/
166166
167INLINE void snes_set_scanline_pixel( int screen, INT16 x, UINT16 color, UINT8 priority, UINT8 layer, int blend )
167inline void snes_state::snes_set_scanline_pixel( int screen, INT16 x, UINT16 color, UINT8 priority, UINT8 layer, int blend )
168168{
169169   scanlines[screen].buffer[x] = color;
170170   scanlines[screen].priority[x] = priority;
r17389r17390
195195 * or lores)
196196 *****************************************/
197197
198INLINE void snes_draw_bgtile_lores( UINT8 layer, INT16 ii, UINT8 colour, UINT16 pal, UINT8 direct_colors, UINT8 priority )
198inline void snes_state::snes_draw_bgtile_lores( UINT8 layer, INT16 ii, UINT8 colour, UINT16 pal, UINT8 direct_colors, UINT8 priority )
199199{
200200   int screen;
201201   UINT16 c;
r17389r17390
229229   }
230230}
231231
232INLINE void snes_draw_bgtile_hires( UINT8 layer, INT16 ii, UINT8 colour, UINT16 pal, UINT8 direct_colors, UINT8 priority )
232inline void snes_state::snes_draw_bgtile_hires( UINT8 layer, INT16 ii, UINT8 colour, UINT16 pal, UINT8 direct_colors, UINT8 priority )
233233{
234234   int screen;
235235   UINT16 c;
r17389r17390
264264   }
265265}
266266
267INLINE void snes_draw_oamtile( INT16 ii, UINT8 colour, UINT16 pal, UINT8 priority )
267inline void snes_state::snes_draw_oamtile( INT16 ii, UINT8 colour, UINT16 pal, UINT8 priority )
268268{
269269   int screen;
270270   int blend;
r17389r17390
307307 * (depending on layer and resolution)
308308 *****************************************/
309309
310INLINE void snes_draw_tile( UINT8 planes, UINT8 layer, UINT32 tileaddr, INT16 x, UINT8 priority, UINT8 flip, UINT8 direct_colors, UINT16 pal, UINT8 hires )
310inline void snes_state::snes_draw_tile( UINT8 planes, UINT8 layer, UINT32 tileaddr, INT16 x, UINT8 priority, UINT8 flip, UINT8 direct_colors, UINT16 pal, UINT8 hires )
311311{
312312   UINT8 plane[8];
313313   INT16 ii, jj;
r17389r17390
390390 * Find the address in VRAM of the tile (x,y)
391391 *********************************************/
392392
393INLINE UINT32 snes_get_tmap_addr( UINT8 layer, UINT8 tile_size, UINT32 base, UINT32 x, UINT32 y )
393inline UINT32 snes_state::snes_get_tmap_addr( UINT8 layer, UINT8 tile_size, UINT32 base, UINT32 x, UINT32 y )
394394{
395395   UINT32 res = base;
396396   x  >>= (3 + tile_size);
r17389r17390
413413 * Update an entire line of tiles.
414414 *********************************************/
415415
416INLINE void snes_update_line( UINT16 curline, UINT8 layer, UINT8 priority_b, UINT8 priority_a, UINT8 color_depth, UINT8 hires, UINT8 offset_per_tile, UINT8 direct_colors )
416inline void snes_state::snes_update_line( UINT16 curline, UINT8 layer, UINT8 priority_b, UINT8 priority_a, UINT8 color_depth, UINT8 hires, UINT8 offset_per_tile, UINT8 direct_colors )
417417{
418418   UINT32 tmap, tile, xoff, yoff, charaddr, addr;
419419   UINT16 ii = 0, vflip, hflip, pal, pal_direct, tilemap;
r17389r17390
598598
599599#define MODE7_CLIP(x) (((x) & 0x2000) ? ((x) | ~0x03ff) : ((x) & 0x03ff))
600600
601static void snes_update_line_mode7( UINT16 curline, UINT8 layer, UINT8 priority_b, UINT8 priority_a )
601void snes_state::snes_update_line_mode7( UINT16 curline, UINT8 layer, UINT8 priority_b, UINT8 priority_a )
602602{
603603   UINT32 tiled;
604604   INT16 ma, mb, mc, md;
r17389r17390
823823 * Update sprite settings for next line.
824824 *********************************************/
825825
826static void snes_update_obsel( void )
826void snes_state::snes_update_obsel( void )
827827{
828828   snes_ppu.layer[SNES_OAM].charmap = snes_ppu.oam.next_charmap;
829829   snes_ppu.oam.name_select = snes_ppu.oam.next_name_select;
r17389r17390
841841 * Build a list of the available obj in OAM ram.
842842 *********************************************/
843843
844static void snes_oam_list_build( void )
844void snes_state::snes_oam_list_build( void )
845845{
846846   UINT8 *oamram = (UINT8 *)snes_oam;
847847   INT16 oam = 0x1ff;
r17389r17390
928928 * scanline
929929 *********************************************/
930930
931static int is_sprite_on_scanline( UINT16 curline, UINT8 sprite )
931int snes_state::is_sprite_on_scanline( UINT16 curline, UINT8 sprite )
932932{
933933   //if sprite is entirely offscreen and doesn't wrap around to the left side of the screen,
934934   //then it is not counted. this *should* be 256, and not 255, even though dot 256 is offscreen.
r17389r17390
953953 * scanline.
954954 *********************************************/
955955
956static void snes_update_objects_rto( UINT16 curline )
956void snes_state::snes_update_objects_rto( UINT16 curline )
957957{
958958   int ii, jj, active_sprite;
959959   UINT8 range_over, time_over;
r17389r17390
10671067 * Update an entire line of sprites.
10681068 *********************************************/
10691069
1070static void snes_update_objects( UINT8 priority_oam0, UINT8 priority_oam1, UINT8 priority_oam2, UINT8 priority_oam3 )
1070void snes_state::snes_update_objects( UINT8 priority_oam0, UINT8 priority_oam1, UINT8 priority_oam2, UINT8 priority_oam3 )
10711071{
10721072   UINT8 pri, priority[4];
10731073   UINT32 charaddr;
r17389r17390
11281128 * Update Mode X line.
11291129 *********************************************/
11301130
1131static void snes_update_mode_0( UINT16 curline )
1131void snes_state::snes_update_mode_0( UINT16 curline )
11321132{
11331133#if SNES_LAYER_DEBUG
11341134   if (debug_options.mode_disabled[0])
r17389r17390
11421142   snes_update_line(curline, SNES_BG4, 1, 4,  SNES_COLOR_DEPTH_2BPP, 0, SNES_OPT_NONE, 0);
11431143}
11441144
1145static void snes_update_mode_1( UINT16 curline )
1145void snes_state::snes_update_mode_1( UINT16 curline )
11461146{
11471147#if SNES_LAYER_DEBUG
11481148   if (debug_options.mode_disabled[1])
r17389r17390
11651165   }
11661166}
11671167
1168static void snes_update_mode_2( UINT16 curline )
1168void snes_state::snes_update_mode_2( UINT16 curline )
11691169{
11701170#if SNES_LAYER_DEBUG
11711171   if (debug_options.mode_disabled[2])
r17389r17390
11771177   snes_update_line(curline, SNES_BG2, 1, 5, SNES_COLOR_DEPTH_4BPP, 0, SNES_OPT_MODE2, 0);
11781178}
11791179
1180static void snes_update_mode_3( UINT16 curline )
1180void snes_state::snes_update_mode_3( UINT16 curline )
11811181{
11821182#if SNES_LAYER_DEBUG
11831183   if (debug_options.mode_disabled[3])
r17389r17390
11891189   snes_update_line(curline, SNES_BG2, 1, 5, SNES_COLOR_DEPTH_4BPP, 0, SNES_OPT_NONE, 0);
11901190}
11911191
1192static void snes_update_mode_4( UINT16 curline )
1192void snes_state::snes_update_mode_4( UINT16 curline )
11931193{
11941194#if SNES_LAYER_DEBUG
11951195   if (debug_options.mode_disabled[4])
r17389r17390
12011201   snes_update_line(curline, SNES_BG2, 1, 5, SNES_COLOR_DEPTH_2BPP, 0, SNES_OPT_MODE4, 0);
12021202}
12031203
1204static void snes_update_mode_5( UINT16 curline )
1204void snes_state::snes_update_mode_5( UINT16 curline )
12051205{
12061206#if SNES_LAYER_DEBUG
12071207   if (debug_options.mode_disabled[5])
r17389r17390
12131213   snes_update_line(curline, SNES_BG2, 1, 5, SNES_COLOR_DEPTH_2BPP, 1, SNES_OPT_NONE, 0);
12141214}
12151215
1216static void snes_update_mode_6( UINT16 curline )
1216void snes_state::snes_update_mode_6( UINT16 curline )
12171217{
12181218#if SNES_LAYER_DEBUG
12191219   if (debug_options.mode_disabled[6])
r17389r17390
12241224   snes_update_line(curline, SNES_BG1, 2, 5, SNES_COLOR_DEPTH_4BPP, 1, SNES_OPT_MODE6, 0);
12251225}
12261226
1227static void snes_update_mode_7( UINT16 curline )
1227void snes_state::snes_update_mode_7( UINT16 curline )
12281228{
12291229#if SNES_LAYER_DEBUG
12301230   if (debug_options.mode_disabled[7])
r17389r17390
12501250 * Draw the whole screen (Mode 0 -> 7).
12511251 *********************************************/
12521252
1253static void snes_draw_screens( UINT16 curline )
1253void snes_state::snes_draw_screens( UINT16 curline )
12541254{
12551255   switch (snes_ppu.mode)
12561256   {
r17389r17390
12781278 * XNOR: ###...##...###     ...###..###...
12791279 *********************************************/
12801280
1281static void snes_update_windowmasks( void )
1281void snes_state::snes_update_windowmasks( void )
12821282{
12831283   UINT16 ii, jj;
12841284   INT8 w1, w2;
r17389r17390
13521352 * possibly be handy for some minor optimization
13531353 *********************************************/
13541354
1355static void snes_update_offsets( void )
1355void snes_state::snes_update_offsets( void )
13561356{
13571357   int ii;
13581358   for (ii = 0; ii < 4; ii++)
r17389r17390
13691369 * color math.
13701370 *****************************************/
13711371
1372INLINE void snes_draw_blend( UINT16 offset, UINT16 *colour, UINT8 prevent_color_math, UINT8 black_pen_clip, int switch_screens )
1372inline void snes_state::snes_draw_blend( UINT16 offset, UINT16 *colour, UINT8 prevent_color_math, UINT8 black_pen_clip, int switch_screens )
13731373{
13741374#if SNES_LAYER_DEBUG
13751375   if (debug_options.colormath_disabled)
r17389r17390
14971497 * the optimized averaging algorithm.
14981498 *********************************************/
14991499
1500static void snes_refresh_scanline( running_machine &machine, bitmap_rgb32 &bitmap, UINT16 curline )
1500void snes_state::snes_refresh_scanline( running_machine &machine, bitmap_rgb32 &bitmap, UINT16 curline )
15011501{
15021502   UINT16 ii;
15031503   int x;
r17389r17390
17901790
17911791SCREEN_UPDATE_RGB32( snes )
17921792{
1793   snes_state *state = screen.machine().driver_data<snes_state>();
17931794   int y;
17941795
17951796   /*NTSC SNES draw range is 1-225. */
17961797   for (y = cliprect.min_y; y <= cliprect.max_y; y++)
17971798   {
1798      snes_refresh_scanline(screen.machine(), bitmap, y + 1);
1799      state->snes_refresh_scanline(screen.machine(), bitmap, y + 1);
17991800   }
18001801   return 0;
18011802}
r17389r17390
18661867 when interlace is active.
18671868*************************************************/
18681869
1869INLINE UINT32 snes_get_vram_address( running_machine &machine )
1870inline UINT32 snes_get_vram_address( running_machine &machine )
18701871{
18711872   snes_state *state = machine.driver_data<snes_state>();
18721873   UINT32 addr = state->m_vmadd;
r17389r17390
19911992         offset = 0x010c;
19921993   }
19931994
1994   return (snes_oam[offset] >> (snes_ram[OAMDATA] << 3)) & 0xff;;
1995   return (snes_oam[offset] >> (snes_ram[OAMDATA] << 3)) & 0xff;
19951996}
19961997
19971998static WRITE8_HANDLER( snes_oam_write )

Previous 199869 Revisions Next


© 1997-2024 The MAME Team