Skip to content

Commit

Permalink
Another fix for Vertical and Horizontal offsets.
Browse files Browse the repository at this point in the history
  • Loading branch information
wavemotion-dave committed Oct 11, 2021
1 parent ea90738 commit 85e48f1
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 26 deletions.
Binary file modified NINTV-DS.nds
Binary file not shown.
4 changes: 2 additions & 2 deletions arm9/source/ds_tools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1114,8 +1114,8 @@ ITCM_CODE void Run(char *initial_file)
}


unsigned int customTiles[24*1024];
unsigned short *customMap = (unsigned short *)0x068A0000; //16K of video memory
unsigned int *customTiles = (unsigned int *) 0x06860000; //128K of video memory
unsigned short *customMap = (unsigned short *)0x068A0000; //16K of video memory
unsigned short customPal[512];
char line[256];

Expand Down
33 changes: 12 additions & 21 deletions arm9/source/emucore/AY38900.ITCM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -853,36 +853,27 @@ ITCM_CODE void AY38900::copyBackgroundBufferToStagingArea()
}
else // This is the worst case... offsets!
{
int sourceWidthX = blockLeft ? 152 : 160;
int sourceHeightY = blockTop ? 88 : 96;
int nextSourcePixel = (blockLeft ? (8 - horizontalOffset) : -horizontalOffset) + ((blockTop ? (8 - verticalOffset) : -verticalOffset) * 160);

for (int y = 0; y<verticalOffset; y++)
{
UINT8* nextPixelStore0 = (UINT8*)pixelBuffer;
nextPixelStore0 += (y*PIXEL_BUFFER_ROW_SIZE*2);
if (blockTop) nextPixelStore0 += (PIXEL_BUFFER_ROW_SIZE*8);
if (blockLeft) nextPixelStore0 += 4;
UINT8* nextPixelStore1 = nextPixelStore0 + PIXEL_BUFFER_ROW_SIZE;
for (int x = 0; x < sourceWidthX; x++)
{
UINT8 nextColor = 0x00;
*nextPixelStore0++ = nextColor;
*nextPixelStore1++ = nextColor;
}
nextSourcePixel += 160;
}
short int sourceWidthX = blockLeft ? 152 : (160-horizontalOffset);
short int sourceHeightY = blockTop ? 88 : (96-verticalOffset);
short int myHoriz = (blockLeft ? (8 - horizontalOffset) : 0);
short int myVert = (blockTop ? (8 - verticalOffset) : 0);
short int nextSourcePixel = myHoriz + (myVert * 160);

for (int y = verticalOffset; y < sourceHeightY; y++)
for (int y = 0; y < sourceHeightY; y++)
{
UINT8* nextPixelStore0 = (UINT8*)pixelBuffer;
nextPixelStore0 += (y*PIXEL_BUFFER_ROW_SIZE*2);

if (blockTop) nextPixelStore0 += (PIXEL_BUFFER_ROW_SIZE*8);
else if (verticalOffset) nextPixelStore0 += (PIXEL_BUFFER_ROW_SIZE*(verticalOffset*2));

if (blockLeft) nextPixelStore0 += 4;
else if (horizontalOffset) nextPixelStore0 += horizontalOffset;

UINT8* nextPixelStore1 = nextPixelStore0 + PIXEL_BUFFER_ROW_SIZE;
for (int x = 0; x < sourceWidthX; x++)
{
UINT8 nextColor = ((x < horizontalOffset) ? 0x00: backgroundBuffer[nextSourcePixel+x]);
UINT8 nextColor = backgroundBuffer[nextSourcePixel+x];
*nextPixelStore0++ = nextColor;
*nextPixelStore1++ = nextColor;
}
Expand Down
4 changes: 1 addition & 3 deletions arm9/source/emucore/Rip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#define ROM_TAG_COMPATIBILITY 0x06

UINT8 bin_image_buf[128 * 1024];
UINT16 *bin_image_buf16 = (UINT16 *) 0x06860000;
UINT16 *bin_image_buf16 = (UINT16 *)bin_image_buf; //(UINT16 *) 0x06860000;

Rip::Rip(UINT32 systemID)
: Peripheral("", ""),
Expand Down Expand Up @@ -116,9 +116,7 @@ Rip* Rip::LoadBin(const CHAR* filename)

UINT32 count = 0;
while (count < size)
{
bin_image_buf[count++] = (UINT8)fgetc(file);
}
fclose(file);

//parse the file bin_image_buf[] into the rip
Expand Down

0 comments on commit 85e48f1

Please sign in to comment.