Fix warnings in snes (and it still works)

This commit is contained in:
tmaul 2011-12-20 22:23:28 +00:00
parent a5b5935906
commit 65d27edb5b
6 changed files with 83 additions and 86 deletions

View File

@ -127,7 +127,7 @@ typedef union
} b; } b;
} reg; } reg;
extern reg a,x,y,s;
extern unsigned long pbr,dbr; extern unsigned long pbr,dbr;
extern UINT16 pc,dp; extern UINT16 pc,dp;
@ -147,7 +147,7 @@ extern void (*opcodes[256][5])();
extern INT32 cpumode; extern INT32 cpumode;
/*Current opcode*/ /*Current opcode*/
extern UINT8 opcode; extern UINT8 global_opcode;
/*Global cycles count*/ /*Global cycles count*/
extern INT32 cycles; extern INT32 cycles;
@ -199,7 +199,7 @@ extern INT32 lines;
extern int pal; extern int global_pal;
/*DMA registers*/ /*DMA registers*/
extern unsigned short dmadest[8],dmasrc[8],dmalen[8]; extern unsigned short dmadest[8],dmasrc[8],dmalen[8];

View File

@ -18,7 +18,7 @@ void (*opcodes[256][5])();
int cpumode; int cpumode;
/*Current opcode*/ /*Current opcode*/
unsigned char opcode; unsigned char global_opcode;
/*Global cycles count*/ /*Global cycles count*/
int cycles; int cycles;

View File

@ -73,13 +73,15 @@ void writeio(unsigned short addr, unsigned char val)
{ {
int c,d=0,offset=0,speed; int c,d=0,offset=0,speed;
unsigned char temp; unsigned char temp;
int delay=0;
switch (addr&0x1FF) switch (addr&0x1FF)
{ {
case 0x00: case 0x00:
nmienable=val&0x80; nmienable=val&0x80;
irqenable=(val>>4)&3; irqenable=(val>>4)&3;
if (!irqenable) irq=0; if (!irqenable)
{
irq=0;
}
break; break;
case 0x02: /*Multiplicand A*/ case 0x02: /*Multiplicand A*/
mula=val; mula=val;
@ -167,13 +169,11 @@ void writeio(unsigned short addr, unsigned char val)
snemlog(L"Bad DMA mode %i\n",dmactrl[d]&7); snemlog(L"Bad DMA mode %i\n",dmactrl[d]&7);
} }
dmalen[d]--; dmalen[d]--;
// delay+=16;
} while (dmalen[d]!=0); } while (dmalen[d]!=0);
} }
d++; d++;
} }
// cycles-=delay;
// clockspc(delay);
break; break;
case 0x0C: /*HDMA enable*/ case 0x0C: /*HDMA enable*/
hdmaena=val; hdmaena=val;

View File

@ -80,11 +80,11 @@ INT32 SnesInit()
if (readmem(0xFFD9)>1) if (readmem(0xFFD9)>1)
{ {
pal=1; global_pal=1;
} }
else else
{ {
pal=0; global_pal=0;
} }
if (srammask) if (srammask)
@ -123,7 +123,7 @@ INT32 SnesFrame()
spctotal2=0.0f; spctotal2=0.0f;
spctotal3=0.0f; spctotal3=0.0f;
} }
for (lines=0;lines<((pal)?312:262);lines++) for (lines=0;lines<((global_pal)?312:262);lines++)
{ {
// snemlog("%i %02X:%04X %i %i %i\n",lines,pbr>>16,pc,irqenable,xirq,yirq); // snemlog("%i %02X:%04X %i %i %i\n",lines,pbr>>16,pc,irqenable,xirq,yirq);
if ((irqenable==2/* || irqenable==1*/) && (lines==yirq)) if ((irqenable==2/* || irqenable==1*/) && (lines==yirq))
@ -139,9 +139,9 @@ INT32 SnesFrame()
intthisline=0; intthisline=0;
while (cycles>0) while (cycles>0)
{ {
opcode=readmem(pbr|pc); global_opcode=readmem(pbr|pc);
pc++; pc++;
opcodes[opcode][cpumode](); opcodes[global_opcode ][cpumode]();
if ((((irqenable==3) && (lines==yirq)) || (irqenable==1)) && !intthisline) if ((((irqenable==3) && (lines==yirq)) || (irqenable==1)) && !intthisline)
{ {
if (((1364-cycles)>>2)>=xirq) if (((1364-cycles)>>2)>=xirq)
@ -179,7 +179,7 @@ INT32 SnesFrame()
return 0; return 0;
} }
INT32 SnesScan(INT32 nAction,INT32 *pnMin) INT32 SnesScan(INT32,INT32 *)
{ {
return 0; return 0;
} }

View File

@ -1,11 +1,7 @@
/*Writes to VRAM at FC80 from 7E0000,x (x=3000ish) /*
Writes to 7E0000,x at FA8A - reads from 7F0D50,x Snem 0.1 by Tom Walker
8Da9?*/ PPU emulation
/*Writes to VRAM at FCFC from 7E0000,x (x=5000ish) */
Writes to 7E0000,x at FB55
8DA9?*/
/*Snem 0.1 by Tom Walker
PPU emulation*/
#include <stdio.h> #include <stdio.h>
#include "snes.h" #include "snes.h"
@ -24,7 +20,7 @@ int yirq,xirq,irqenable,irq;
int lines; int lines;
int pal; int global_pal;
/*DMA registers*/ /*DMA registers*/
unsigned short dmadest[8],dmasrc[8],dmalen[8]; unsigned short dmadest[8],dmasrc[8],dmalen[8];
@ -164,7 +160,7 @@ struct SNES_PPU_STRUCT /* once all the regs are saved in this structure, it woul
static UINT16 cgram_address =0; /* CGRAM address */ static UINT16 cgram_address =0; /* CGRAM address */
static UINT8 vram_read_offset=2; /* VRAM read offset */ static UINT8 vram_read_offset=2; /* VRAM read offset */
static UINT16 OAM_DATA_O =0;
static UINT16 vram_fgr_high, vram_fgr_increment, vram_fgr_count, vram_fgr_mask, vram_fgr_shift, vram_read_buffer; static UINT16 vram_fgr_high, vram_fgr_increment, vram_fgr_count, vram_fgr_mask, vram_fgr_shift, vram_read_buffer;
static const UINT16 vram_fgr_inctab[4] = { 1, 32, 128, 128 }; static const UINT16 vram_fgr_inctab[4] = { 1, 32, 128, 128 };
@ -343,7 +339,7 @@ SNES_INLINE void snes_draw_blend( UINT16 offset, UINT16 *colour, UINT8 prevent_c
* Draw tiles with variable bit planes * Draw tiles with variable bit planes
*****************************************/ *****************************************/
SNES_INLINE void snes_draw_tile( UINT8 planes, UINT8 layer, UINT16 tileaddr, INT16 x, UINT8 priority, UINT8 flip, UINT8 direct_colors, UINT16 pal, UINT8 hires ) SNES_INLINE void snes_draw_tile( UINT8 planes, UINT8 layer, UINT16 tileaddr, INT16 xpos, UINT8 priority, UINT8 flip, UINT8 direct_colors, UINT16 palNo, UINT8 hires )
{ {
UINT8 mask, plane[8]; UINT8 mask, plane[8];
UINT16 c; UINT16 c;
@ -360,7 +356,7 @@ SNES_INLINE void snes_draw_tile( UINT8 planes, UINT8 layer, UINT16 tileaddr, INT
else else
mask = 0x80; mask = 0x80;
for (ii = x; ii < (x + 8); ii++) for (ii = xpos; ii < (xpos + 8); ii++)
{ {
UINT8 colour = 0; UINT8 colour = 0;
if (flip) if (flip)
@ -401,10 +397,10 @@ SNES_INLINE void snes_draw_tile( UINT8 planes, UINT8 layer, UINT16 tileaddr, INT
{ {
/* format is 0 | BBb00 | GGGg0 | RRRr0, HW confirms that the data is zero padded. */ /* format is 0 | BBb00 | GGGg0 | RRRr0, HW confirms that the data is zero padded. */
c = ((clr & 0x07) << 2) | ((clr & 0x38) << 4) | ((clr & 0xc0) << 7); c = ((clr & 0x07) << 2) | ((clr & 0x38) << 4) | ((clr & 0xc0) << 7);
c |= ((pal & 0x04) >> 1) | ((pal & 0x08) << 3) | ((pal & 0x10) << 8); c |= ((palNo & 0x04) >> 1) | ((palNo & 0x08) << 3) | ((palNo & 0x10) << 8);
} }
else else
c = snes_cgram[(pal + clr) % FIXED_COLOUR]; c = snes_cgram[(palNo + clr) % FIXED_COLOUR];
if (snes_ppu.layer[SNES_MAINSCREEN].mosaic_enabled) // handle horizontal mosaic if (snes_ppu.layer[SNES_MAINSCREEN].mosaic_enabled) // handle horizontal mosaic
{ {
@ -450,10 +446,10 @@ SNES_INLINE void snes_draw_tile( UINT8 planes, UINT8 layer, UINT16 tileaddr, INT
{ {
/* format is 0 | BBb00 | GGGg0 | RRRr0, HW confirms that the data is zero padded. */ /* format is 0 | BBb00 | GGGg0 | RRRr0, HW confirms that the data is zero padded. */
c = ((clr & 0x07) << 2) | ((clr & 0x38) << 4) | ((clr & 0xc0) << 7); c = ((clr & 0x07) << 2) | ((clr & 0x38) << 4) | ((clr & 0xc0) << 7);
c |= ((pal & 0x04) >> 1) | ((pal & 0x08) << 3) | ((pal & 0x10) << 8); c |= ((palNo & 0x04) >> 1) | ((palNo & 0x08) << 3) | ((palNo & 0x10) << 8);
} }
else else
c = snes_cgram[(pal + clr) % FIXED_COLOUR]; c = snes_cgram[(palNo + clr) % FIXED_COLOUR];
if (snes_ppu.layer[SNES_SUBSCREEN].mosaic_enabled) // handle horizontal mosaic if (snes_ppu.layer[SNES_SUBSCREEN].mosaic_enabled) // handle horizontal mosaic
{ {
@ -501,10 +497,10 @@ SNES_INLINE void snes_draw_tile( UINT8 planes, UINT8 layer, UINT16 tileaddr, INT
{ {
/* format is 0 | BBb00 | GGGg0 | RRRr0, HW confirms that the data is zero padded. */ /* format is 0 | BBb00 | GGGg0 | RRRr0, HW confirms that the data is zero padded. */
c = ((clr & 0x07) << 2) | ((clr & 0x38) << 4) | ((clr & 0xc0) << 7); c = ((clr & 0x07) << 2) | ((clr & 0x38) << 4) | ((clr & 0xc0) << 7);
c |= ((pal & 0x04) >> 1) | ((pal & 0x08) << 3) | ((pal & 0x10) << 8); c |= ((palNo & 0x04) >> 1) | ((palNo & 0x08) << 3) | ((palNo & 0x10) << 8);
} }
else else
c = snes_cgram[(pal + clr) % FIXED_COLOUR]; c = snes_cgram[(palNo + clr) % FIXED_COLOUR];
if (snes_ppu.layer[layer].mosaic_enabled) // handle horizontal mosaic if (snes_ppu.layer[layer].mosaic_enabled) // handle horizontal mosaic
{ {
@ -549,10 +545,10 @@ SNES_INLINE void snes_draw_tile( UINT8 planes, UINT8 layer, UINT16 tileaddr, INT
{ {
/* format is 0 | BBb00 | GGGg0 | RRRr0, HW confirms that the data is zero padded. */ /* format is 0 | BBb00 | GGGg0 | RRRr0, HW confirms that the data is zero padded. */
c = ((clr & 0x07) << 2) | ((clr & 0x38) << 4) | ((clr & 0xc0) << 7); c = ((clr & 0x07) << 2) | ((clr & 0x38) << 4) | ((clr & 0xc0) << 7);
c |= ((pal & 0x04) >> 1) | ((pal & 0x08) << 3) | ((pal & 0x10) << 8); c |= ((palNo & 0x04) >> 1) | ((palNo & 0x08) << 3) | ((palNo & 0x10) << 8);
} }
else else
c = snes_cgram[(pal + clr) % FIXED_COLOUR]; c = snes_cgram[(palNo + clr) % FIXED_COLOUR];
if (snes_ppu.layer[layer].mosaic_enabled) // handle horizontal mosaic if (snes_ppu.layer[layer].mosaic_enabled) // handle horizontal mosaic
{ {
@ -586,17 +582,17 @@ SNES_INLINE void snes_draw_tile( UINT8 planes, UINT8 layer, UINT16 tileaddr, INT
* Draw 2 tiles with variable bit planes * Draw 2 tiles with variable bit planes
*****************************************/ *****************************************/
SNES_INLINE void snes_draw_tile_x2( UINT8 planes, UINT8 layer, UINT16 tileaddr, INT16 x, UINT8 priority, UINT8 flip, UINT8 direct_colors, UINT16 pal, UINT8 hires ) SNES_INLINE void snes_draw_tile_x2( UINT8 planes, UINT8 layer, UINT16 tileaddr, INT16 xpos, UINT8 priority, UINT8 flip, UINT8 direct_colors, UINT16 palNo, UINT8 hires )
{ {
if (flip) if (flip)
{ {
snes_draw_tile(planes, layer, tileaddr + (8 * planes), x, priority, flip, direct_colors, pal, hires); snes_draw_tile(planes, layer, tileaddr + (8 * planes), xpos, priority, flip, direct_colors, palNo, hires);
snes_draw_tile(planes, layer, tileaddr, x + 8, priority, flip, direct_colors, pal, hires); snes_draw_tile(planes, layer, tileaddr, xpos + 8, priority, flip, direct_colors, palNo, hires);
} }
else else
{ {
snes_draw_tile(planes, layer, tileaddr, x, priority, flip, direct_colors, pal, hires); snes_draw_tile(planes, layer, tileaddr, xpos, priority, flip, direct_colors, palNo, hires);
snes_draw_tile(planes, layer, tileaddr + (8 * planes), x + 8, priority, flip, direct_colors, pal, hires); snes_draw_tile(planes, layer, tileaddr + (8 * planes), xpos + 8, priority, flip, direct_colors, palNo, hires);
} }
} }
@ -608,7 +604,7 @@ SNES_INLINE void snes_draw_tile_x2( UINT8 planes, UINT8 layer, UINT16 tileaddr,
* that it takes a blend parameter. * that it takes a blend parameter.
*****************************************/ *****************************************/
SNES_INLINE void snes_draw_tile_object( UINT16 tileaddr, INT16 x, UINT8 priority, UINT8 flip, UINT16 pal, UINT8 blend ) SNES_INLINE void snes_draw_tile_object( UINT16 tileaddr, INT16 xpos, UINT8 priority, UINT8 flip, UINT16 palNo, UINT8 blend )
{ {
UINT8 mask, plane[4]; UINT8 mask, plane[4];
UINT16 c; UINT16 c;
@ -624,7 +620,7 @@ SNES_INLINE void snes_draw_tile_object( UINT16 tileaddr, INT16 x, UINT8 priority
else else
mask = 0x80; mask = 0x80;
for (ii = x; ii < (x + 8); ii++) for (ii = xpos; ii < (xpos + 8); ii++)
{ {
UINT8 colour = 0; UINT8 colour = 0;
if (flip) if (flip)
@ -658,7 +654,7 @@ SNES_INLINE void snes_draw_tile_object( UINT16 tileaddr, INT16 x, UINT8 priority
/* Only draw if we have a colour (0 == transparent) */ /* Only draw if we have a colour (0 == transparent) */
if (clr) if (clr)
{ {
c = snes_cgram[(pal + clr) % FIXED_COLOUR]; c = snes_cgram[(palNo + clr) % FIXED_COLOUR];
scanlines[SNES_MAINSCREEN].buffer[ii] = c; scanlines[SNES_MAINSCREEN].buffer[ii] = c;
scanlines[SNES_MAINSCREEN].priority[ii] = priority; scanlines[SNES_MAINSCREEN].priority[ii] = priority;
@ -684,7 +680,7 @@ SNES_INLINE void snes_draw_tile_object( UINT16 tileaddr, INT16 x, UINT8 priority
/* Only draw if we have a colour (0 == transparent) */ /* Only draw if we have a colour (0 == transparent) */
if (clr) if (clr)
{ {
c = snes_cgram[(pal + clr) % FIXED_COLOUR]; c = snes_cgram[(palNo + clr) % FIXED_COLOUR];
scanlines[SNES_SUBSCREEN].buffer[ii] = c; scanlines[SNES_SUBSCREEN].buffer[ii] = c;
scanlines[SNES_SUBSCREEN].priority[ii] = priority; scanlines[SNES_SUBSCREEN].priority[ii] = priority;
@ -705,19 +701,19 @@ SNES_INLINE void snes_draw_tile_object( UINT16 tileaddr, INT16 x, UINT8 priority
* Find the address in VRAM of the tile (x,y) * Find the address in VRAM of the tile (x,y)
*********************************************/ *********************************************/
SNES_INLINE UINT32 snes_get_tmap_addr( UINT8 layer, UINT8 tile_size, UINT32 base, UINT32 x, UINT32 y ) SNES_INLINE UINT32 snes_get_tmap_addr( UINT8 layer, UINT8 tile_size, UINT32 base, UINT32 xpos, UINT32 ypos )
{ {
UINT32 res = base; UINT32 res = base;
x >>= (3 + tile_size); xpos >>= (3 + tile_size);
y >>= (3 + tile_size); ypos >>= (3 + tile_size);
res += (snes_ppu.layer[layer].tilemap_size & 2) ? ((y & 0x20) << ((snes_ppu.layer[layer].tilemap_size & 1) ? 7 : 6)) : 0; res += (snes_ppu.layer[layer].tilemap_size & 2) ? ((ypos & 0x20) << ((snes_ppu.layer[layer].tilemap_size & 1) ? 7 : 6)) : 0;
/* Scroll vertically */ /* Scroll vertically */
res += (y & 0x1f) << 6; res += (ypos & 0x1f) << 6;
/* Offset horizontally */ /* Offset horizontally */
res += (snes_ppu.layer[layer].tilemap_size & 1) ? ((x & 0x20) << 6) : 0; res += (snes_ppu.layer[layer].tilemap_size & 1) ? ((xpos & 0x20) << 6) : 0;
/* Scroll horizontally */ /* Scroll horizontally */
res += (x & 0x1f) << 1; res += (xpos & 0x1f) << 1;
return res; return res;
} }
@ -733,7 +729,7 @@ SNES_INLINE void snes_update_line( UINT8 color_depth, UINT8 hires, UINT8 priorit
{ {
UINT32 tmap, tile, xoff, yoff; UINT32 tmap, tile, xoff, yoff;
UINT32 charaddr; UINT32 charaddr;
UINT16 ii = 0, vflip, hflip, pal, pal_direct; UINT16 ii = 0, vflip, hflip, pal_col, pal_direct;
INT8 yscroll; INT8 yscroll;
UINT8 xscroll; UINT8 xscroll;
UINT8 priority; UINT8 priority;
@ -841,12 +837,12 @@ SNES_INLINE void snes_update_line( UINT8 color_depth, UINT8 hires, UINT8 priorit
pal_direct = ((tilemap & 0x1c00) >> 8); pal_direct = ((tilemap & 0x1c00) >> 8);
tile = tilemap & 0x03ff; tile = tilemap & 0x03ff;
pal = ((pal_direct >> 2) << color_shift); pal_col = ((pal_direct >> 2) << color_shift);
/* Mode 0 palettes are layer specific */ /* Mode 0 palettes are layer specific */
if (snes_ppu.mode == 0) if (snes_ppu.mode == 0)
{ {
pal += (layer << 5); pal_col += (layer << 5);
} }
/* figure out which line to draw */ /* figure out which line to draw */
@ -883,19 +879,19 @@ SNES_INLINE void snes_update_line( UINT8 color_depth, UINT8 hires, UINT8 priorit
/* below, only color_planes depends on color_depth */ /* below, only color_planes depends on color_depth */
if (hires) /* Hi-Res: 2bpp & 4bpp */ if (hires) /* Hi-Res: 2bpp & 4bpp */
{ {
snes_draw_tile_x2(color_planes, layer, charaddr + (tile * 8 * color_planes) + yscroll, (ii - xscroll) * 2, priority, hflip, direct_colors, direct_colors ? pal_direct : pal, hires); snes_draw_tile_x2(color_planes, layer, charaddr + (tile * 8 * color_planes) + yscroll, (ii - xscroll) * 2, priority, hflip, direct_colors, direct_colors ? pal_direct : pal_col, hires);
ii += 8; ii += 8;
} }
else /* tile_size = 0 */ else /* tile_size = 0 */
{ {
if (tile_size) if (tile_size)
{ {
snes_draw_tile_x2(color_planes, layer, charaddr + (tile * 8 * color_planes) + yscroll, ii - xscroll, priority, hflip, direct_colors, direct_colors ? pal_direct : pal, hires); snes_draw_tile_x2(color_planes, layer, charaddr + (tile * 8 * color_planes) + yscroll, ii - xscroll, priority, hflip, direct_colors, direct_colors ? pal_direct : pal_col, hires);
ii += 16; ii += 16;
} }
else /* No Hi-Res: 2bpp, 4bpp & 8bpp */ else /* No Hi-Res: 2bpp, 4bpp & 8bpp */
{ {
snes_draw_tile(color_planes, layer, charaddr + (tile * 8 * color_planes) + yscroll, ii - xscroll, priority, hflip, direct_colors, direct_colors ? pal_direct : pal, hires); snes_draw_tile(color_planes, layer, charaddr + (tile * 8 * color_planes) + yscroll, ii - xscroll, priority, hflip, direct_colors, direct_colors ? pal_direct : pal_col, hires);
ii += 8; ii += 8;
} }
} }
@ -1207,9 +1203,9 @@ static void snes_update_objects( UINT8 priority_tbl, UINT16 curline )
INT8 xs, ys; INT8 xs, ys;
UINT8 line; UINT8 line;
UINT8 range_over = 0, time_over = 0; UINT8 range_over = 0, time_over = 0;
UINT8 height, width, vflip, hflip, priority, pal, blend; UINT8 height, width, vflip, hflip, priority, palNo, blend;
UINT16 tile; UINT16 tile;
INT16 i, x, y; INT16 i, xpos, ypos;
UINT32 name_sel = 0, charaddr; UINT32 name_sel = 0, charaddr;
static const UINT8 table_obj_priority[10][4] = { static const UINT8 table_obj_priority[10][4] = {
{2, 5, 8, 11}, // mode 0 {2, 5, 8, 11}, // mode 0
@ -1271,26 +1267,26 @@ static void snes_update_objects( UINT8 priority_tbl, UINT16 curline )
if (oam_list[i].x > 255) if (oam_list[i].x > 255)
oam_list[i].x -= 512; oam_list[i].x -= 512;
tile = oam_list[i].tile; tile = oam_list[i].tile;
x = oam_list[i].x; xpos = oam_list[i].x;
y = oam_list[i].y; ypos = oam_list[i].y;
height = oam_list[i].height; height = oam_list[i].height;
width = oam_list[i].width; width = oam_list[i].width;
vflip = oam_list[i].vflip; vflip = oam_list[i].vflip;
hflip = oam_list[i].hflip; hflip = oam_list[i].hflip;
priority = table_obj_priority[priority_tbl][oam_list[i].priority_bits]; priority = table_obj_priority[priority_tbl][oam_list[i].priority_bits];
pal = oam_list[i].pal; palNo = oam_list[i].pal;
/* Draw sprite if it intersects the current line */ /* Draw sprite if it intersects the current line */
if (curline >= y && curline < (y + (snes_ppu.oam.size[oam_list[i].size] << 3))) if (curline >= ypos && curline < (ypos + (snes_ppu.oam.size[oam_list[i].size] << 3)))
{ {
/* Only objects using palettes 4-7 can be transparent */ /* Only objects using palettes 4-7 can be transparent */
blend = (pal < 192) ? 1 : 0; blend = (palNo < 192) ? 1 : 0;
/* Only objects using tiles over 255 use name select */ /* Only objects using tiles over 255 use name select */
name_sel = (tile < 256) ? 0 : snes_ppu.oam.next_name_select; name_sel = (tile < 256) ? 0 : snes_ppu.oam.next_name_select;
ys = (curline - y) >> 3; ys = (curline - ypos) >> 3;
line = (curline - y) % 8; line = (curline - ypos) % 8;
if (vflip) if (vflip)
{ {
ys = snes_ppu.oam.size[oam_list[i].size] - ys - 1; ys = snes_ppu.oam.size[oam_list[i].size] - ys - 1;
@ -1303,9 +1299,9 @@ static void snes_update_objects( UINT8 priority_tbl, UINT16 curline )
UINT8 count = 0; UINT8 count = 0;
for (xs = (snes_ppu.oam.size[oam_list[i].size] - 1); xs >= 0; xs--) for (xs = (snes_ppu.oam.size[oam_list[i].size] - 1); xs >= 0; xs--)
{ {
if ((x + (count << 3) < SNES_SCR_WIDTH)) if ((xpos + (count << 3) < SNES_SCR_WIDTH))
{ {
snes_draw_tile_object(charaddr + name_sel + tile + table_obj_offset[ys][xs] + line, x + (count++ << 3), priority, hflip, pal, blend); snes_draw_tile_object(charaddr + name_sel + tile + table_obj_offset[ys][xs] + line, xpos + (count++ << 3), priority, hflip, palNo, blend);
} }
time_over++; /* Increase time_over. Should we stop drawing if exceeded 34 tiles? */ time_over++; /* Increase time_over. Should we stop drawing if exceeded 34 tiles? */
} }
@ -1314,9 +1310,9 @@ static void snes_update_objects( UINT8 priority_tbl, UINT16 curline )
{ {
for (xs = 0; xs < snes_ppu.oam.size[oam_list[i].size]; xs++) for (xs = 0; xs < snes_ppu.oam.size[oam_list[i].size]; xs++)
{ {
if ((x + (xs << 3) < SNES_SCR_WIDTH)) if ((xpos + (xs << 3) < SNES_SCR_WIDTH))
{ {
snes_draw_tile_object(charaddr + name_sel + tile + table_obj_offset[ys][xs] + line, x + (xs << 3), priority, hflip, pal, blend); snes_draw_tile_object(charaddr + name_sel + tile + table_obj_offset[ys][xs] + line, xpos + (xs << 3), priority, hflip, palNo, blend);
} }
time_over++; /* Increase time_over. Should we stop drawing if exceeded 34 tiles? */ time_over++; /* Increase time_over. Should we stop drawing if exceeded 34 tiles? */
} }
@ -1619,18 +1615,18 @@ SNES_INLINE static unsigned int CalcCol(unsigned short nColour)
static void snes_refresh_scanline(UINT16 curline ) static void snes_refresh_scanline(UINT16 curline )
{ {
UINT16 ii; UINT16 ii;
int x; int xpos;
int fade; int fade;
struct SCANLINE *scanline1, *scanline2; struct SCANLINE *scanline1, *scanline2;
UINT16 c; UINT16 c;
unsigned short * dstbitmap = (unsigned short * )pBurnDraw; unsigned short * dstbitmap = (unsigned short * )pBurnDraw;
if (snes_ppu.screen_disabled) /* screen is forced blank */ if (snes_ppu.screen_disabled) /* screen is forced blank */
for (x = 0; x < SNES_SCR_WIDTH * 2; x++) for (xpos = 0; xpos < SNES_SCR_WIDTH * 2; xpos++)
{ {
if (pBurnDraw) if (pBurnDraw)
{ {
dstbitmap[(curline*(nBurnPitch>>1))+x]= RGB_BLACK; dstbitmap[(curline*(nBurnPitch>>1))+xpos]= RGB_BLACK;
} }
} }
else else
@ -1691,15 +1687,15 @@ static void snes_refresh_scanline(UINT16 curline )
/* Phew! Draw the line to screen */ /* Phew! Draw the line to screen */
fade = snes_ppu.screen_brightness; fade = snes_ppu.screen_brightness;
for (x = 0; x < SNES_SCR_WIDTH; x++) for (xpos = 0; xpos < SNES_SCR_WIDTH; xpos++)
{ {
int r, g, b, hires; int r, g, b, hires;
hires = (snes_ppu.mode != 5 && snes_ppu.mode != 6) ? 0 : 1; hires = (snes_ppu.mode != 5 && snes_ppu.mode != 6) ? 0 : 1;
c = scanline1->buffer[x]; c = scanline1->buffer[xpos];
/* perform color math if the layer wants it (except if it's an object > 192) */ /* perform color math if the layer wants it (except if it's an object > 192) */
if (!scanline1->blend_exception[x] && snes_ppu.layer[scanline1->layer[x]].color_math) if (!scanline1->blend_exception[xpos] && snes_ppu.layer[scanline1->layer[xpos]].color_math)
snes_draw_blend(x, &c, snes_ppu.prevent_color_math, snes_ppu.clip_to_black, 0); snes_draw_blend(xpos, &c, snes_ppu.prevent_color_math, snes_ppu.clip_to_black, 0);
r = ((c & 0x1f) * fade) >> 4; r = ((c & 0x1f) * fade) >> 4;
g = (((c & 0x3e0) >> 5) * fade) >> 4; g = (((c & 0x3e0) >> 5) * fade) >> 4;
@ -1707,7 +1703,7 @@ static void snes_refresh_scanline(UINT16 curline )
if (pBurnDraw) if (pBurnDraw)
{ {
dstbitmap[(curline * (nBurnPitch>>1))+ (x<<1) + 1] =BurnHighCol(pal5bit(r),pal5bit(g),pal5bit(b),0); //BurnHighCol(pal5bit(r),pal5bit(g),pal5bit(b),0); dstbitmap[(curline * (nBurnPitch>>1))+ (xpos<<1) + 1] =BurnHighCol(pal5bit(r),pal5bit(g),pal5bit(b),0); //BurnHighCol(pal5bit(r),pal5bit(g),pal5bit(b),0);
} }
/* in hires, the first pixel (of 512) is subscreen pixel, then the first mainscreen pixel follows, and so on... */ /* in hires, the first pixel (of 512) is subscreen pixel, then the first mainscreen pixel follows, and so on... */
@ -1715,22 +1711,22 @@ static void snes_refresh_scanline(UINT16 curline )
{ {
if (pBurnDraw) if (pBurnDraw)
{ {
dstbitmap[(curline * (nBurnPitch>>1))+(x<<1) + 0] =BurnHighCol(pal5bit(r),pal5bit(g),pal5bit(b),0); //BurnHighCol(pal5bit(r), pal5bit(g), pal5bit(b),0); dstbitmap[(curline * (nBurnPitch>>1))+(xpos<<1) + 0] =BurnHighCol(pal5bit(r),pal5bit(g),pal5bit(b),0); //BurnHighCol(pal5bit(r), pal5bit(g), pal5bit(b),0);
} }
} }
else else
{ {
c = scanline2->buffer[x]; c = scanline2->buffer[xpos];
/* in hires, subscreen pixels are blended as well: for each subscreen pixel, color math is applied if /* in hires, subscreen pixels are blended as well: for each subscreen pixel, color math is applied if
it had been applied to the previous mainscreen pixel. What happens at subscreen pixel 0 (which has no it had been applied to the previous mainscreen pixel. What happens at subscreen pixel 0 (which has no
previous mainscreen pixel) is undocumented. Until more info are discovered, we (arbitrarily) apply to it previous mainscreen pixel) is undocumented. Until more info are discovered, we (arbitrarily) apply to it
the same color math as the *next* mainscreen pixel (i.e. mainscreen pixel 0) */ the same color math as the *next* mainscreen pixel (i.e. mainscreen pixel 0) */
if (x == 0 && !scanline1->blend_exception[0] && snes_ppu.layer[scanline1->layer[0]].color_math) if (xpos == 0 && !scanline1->blend_exception[0] && snes_ppu.layer[scanline1->layer[0]].color_math)
snes_draw_blend(0, &c, snes_ppu.prevent_color_math, snes_ppu.clip_to_black, 1); snes_draw_blend(0, &c, snes_ppu.prevent_color_math, snes_ppu.clip_to_black, 1);
else if (x > 0 && !scanline1->blend_exception[x - 1] && snes_ppu.layer[scanline1->layer[x - 1]].color_math) else if (xpos > 0 && !scanline1->blend_exception[xpos - 1] && snes_ppu.layer[scanline1->layer[xpos - 1]].color_math)
snes_draw_blend(x, &c, snes_ppu.prevent_color_math, snes_ppu.clip_to_black, 1); snes_draw_blend(xpos, &c, snes_ppu.prevent_color_math, snes_ppu.clip_to_black, 1);
r = ((c & 0x1f) * fade) >> 4; r = ((c & 0x1f) * fade) >> 4;
@ -1738,7 +1734,7 @@ static void snes_refresh_scanline(UINT16 curline )
b = (((c & 0x7c00) >> 10) * fade) >> 4; b = (((c & 0x7c00) >> 10) * fade) >> 4;
if (pBurnDraw) if (pBurnDraw)
{ {
dstbitmap[(curline * (nBurnPitch>>1))+ (x<<1) + 0] = BurnHighCol(pal5bit(r),pal5bit(g),pal5bit(b),0);//BurnHighCol(pal5bit(r), pal5bit(g), pal5bit(b),0); dstbitmap[(curline * (nBurnPitch>>1))+ (xpos<<1) + 0] = BurnHighCol(pal5bit(r),pal5bit(g),pal5bit(b),0);//BurnHighCol(pal5bit(r), pal5bit(g), pal5bit(b),0);
} }
} }
} }

View File

@ -9,7 +9,7 @@ double spccycles;
double spctotal2; double spctotal2;
double spctotal3; double spctotal3;
struct struct SPC_Struct
{ {
union union
{ {
@ -28,6 +28,7 @@ struct
} p; } p;
} spc; } spc;
unsigned char *spcram; unsigned char *spcram;
unsigned char spcrom[64]= unsigned char spcrom[64]=
{ {
@ -1862,7 +1863,7 @@ void execspc()
//snemlog(L"Bad SPC opcode %02X at %04X\n",opcode,spc.pc); //snemlog(L"Bad SPC opcode %02X at %04X\n",opcode,spc.pc);
} }
if (pal) spccycles-=(spccount*20.7796875f);//20.36383f); if (global_pal) spccycles-=(spccount*20.7796875f);//20.36383f);
else spccycles-=(spccount*20.9395313f); else spccycles-=(spccount*20.9395313f);
// spctotal2+=(spccount*20.78f);//20.36383f); // spctotal2+=(spccount*20.78f);//20.36383f);
// spctotal3+=spccount; // spctotal3+=spccount;