From f8e6ed06f2c047a316c7afb91cc797b16204afe3 Mon Sep 17 00:00:00 2001 From: CaH4e3 Date: Sun, 26 Jul 2015 08:23:10 +0000 Subject: [PATCH] UNIF COOLBOY - more fixes [ClusteR] ppuview: 8x16 sprite display mode --- trunk/src/boards/coolboy.cpp | 31 ++++++---- trunk/src/drivers/win/config.cpp | 2 + trunk/src/drivers/win/ppuview.cpp | 98 ++++++++++++++++++------------- trunk/src/drivers/win/res.rc | 15 +++-- trunk/src/drivers/win/resource.h | 2 + 5 files changed, 86 insertions(+), 62 deletions(-) diff --git a/trunk/src/boards/coolboy.cpp b/trunk/src/boards/coolboy.cpp index 65cf65cd..3224919a 100644 --- a/trunk/src/boards/coolboy.cpp +++ b/trunk/src/boards/coolboy.cpp @@ -42,8 +42,8 @@ static void COOLBOYCW(uint32 A, uint8 V) { } } // Highest bit goes from MMC3 registers when EXPREGS[3]&0x80==0 or from EXPREGS[0]&0x08 otherwise - setchr1(A, - (V & 0x80 & mask) | ((((EXPREGS[0] & 0x08) << 4) & (mask ^ 0xff))) // 7th bit + setchr1(A, + (V & 0x80 & mask) | ((((EXPREGS[0] & 0x08) << 4) & ~mask)) // 7th bit | ((EXPREGS[2] & 0x0F) << 3) // 6-3 bits | ((A >> 10) & 7) // 2-0 bits ); @@ -57,7 +57,9 @@ static void COOLBOYCW(uint32 A, uint8 V) { case 0x0C00: V = 0; break; } } - setchr1(A, (V & mask) | (((EXPREGS[0] & 0x08) << 4) & (mask ^ 0xff))); + // Simple MMC3 mode + // Highest bit goes from MMC3 registers when EXPREGS[3]&0x80==0 or from EXPREGS[0]&0x08 otherwise + setchr1(A, (V & mask) | (((EXPREGS[0] & 0x08) << 4) & ~mask)); } } @@ -70,10 +72,10 @@ static void COOLBOYPW(uint32 A, uint8 V) { if ((EXPREGS[3] & 0x40) && (V >= 0xFE) && !((MMC3_cmd & 0x40) != 0)) { switch (A & 0xE000) { case 0xA000: - if ((MMC3_cmd & 0x40) != 0) V = 0; + if ((MMC3_cmd & 0x40)) V = 0; break; case 0xC000: - if ((MMC3_cmd & 0x40) == 0) V = 0; + if (!(MMC3_cmd & 0x40)) V = 0; break; case 0xE000: V = 0; @@ -81,18 +83,20 @@ static void COOLBOYPW(uint32 A, uint8 V) { } } - // Regular MMC3 mode, internal ROM size can be up to 2048kb! Minimal is 64kb + // Regular MMC3 mode, internal ROM size can be up to 2048kb! if (!(EXPREGS[3] & 0x10)) setprg8(A, (((base << 4) & ~mask)) | (V & mask)); else { // NROM mode mask &= 0xF0; uint8 emask; - if (!(EXPREGS[1] & 2)) // 16kb mode, 0xC000-0xFFFF is same as 0x8000-0xBFFF + if ((((EXPREGS[1] & 2) != 0))) // 32kb mode + emask = (EXPREGS[3] & 0x0C) | ((A & 0x4000) >> 13); + else // 16kb mode emask = EXPREGS[3] & 0x0E; - else // 32kb mode, using second-last bank - emask = (EXPREGS[3] & 0x0C) | ((A >= 0xC000) ? 2 : 0); - emask |= (A >> 13) & 1; // does not depends on MMC3_cmd&0x40 - setprg8(A, (((base << 4) & ~mask) | (V & mask) | emask)); + setprg8(A, ((base << 4) & ~mask) // 7-4 bits are from base (see below) + | (V & mask) // ... or from MM3 internal regs, depends on mask + | emask // 3-1 (or 3-2 when (EXPREGS[3]&0x0C is set) from EXPREGS[3] + | ((A & 0x2000) >> 13)); // 0th just as is } } @@ -100,7 +104,8 @@ static DECLFW(COOLBOYWrite) { if(A001B & 0x80) CartBW(A,V); - if((EXPREGS[3] & 0x80) == 0) { + // Deny any further writes when 7th bit is 1 AND 4th is 0 + if ((EXPREGS[3] & 0x90) != 0x80) { EXPREGS[A & 3] = V; FixMMC3PRG(MMC3_cmd); FixMMC3CHR(MMC3_cmd); @@ -128,7 +133,7 @@ static void COOLBOYPower(void) { FixMMC3PRG(MMC3_cmd); FixMMC3CHR(MMC3_cmd); SetWriteHandler(0x5000, 0x5fff, CartBW); // some games access random unmapped areas and crashes because of KT-008 PCB hack in MMC3 source lol - SetWriteHandler(0x6000, 0x6fff, COOLBOYWrite); + SetWriteHandler(0x6000, 0x7fff, COOLBOYWrite); } void COOLBOY_Init(CartInfo *info) { diff --git a/trunk/src/drivers/win/config.cpp b/trunk/src/drivers/win/config.cpp index 4ec3d277..fc371848 100644 --- a/trunk/src/drivers/win/config.cpp +++ b/trunk/src/drivers/win/config.cpp @@ -88,6 +88,7 @@ extern int NTViewPosX,NTViewPosY; extern int PPUViewPosX, PPUViewPosY; extern bool PPUView_maskUnusedGraphics; extern bool PPUView_invertTheMask; +extern int PPUView_sprite16Mode; extern int MainWindow_wndx, MainWindow_wndy; extern int MemWatch_wndx, MemWatch_wndy; extern int Monitor_wndx, Monitor_wndy; @@ -308,6 +309,7 @@ static CFGSTRUCT fceuconfig[] = AC(PPUViewPosY), AC(PPUView_maskUnusedGraphics), AC(PPUView_invertTheMask), + AC(PPUView_sprite16Mode), AC(MainWindow_wndx), AC(MainWindow_wndy), AC(MemWatch_wndx), diff --git a/trunk/src/drivers/win/ppuview.cpp b/trunk/src/drivers/win/ppuview.cpp index c3119215..ed308e70 100644 --- a/trunk/src/drivers/win/ppuview.cpp +++ b/trunk/src/drivers/win/ppuview.cpp @@ -32,6 +32,7 @@ extern uint8 PALRAM[0x20]; int PPUViewPosX, PPUViewPosY; bool PPUView_maskUnusedGraphics = true; bool PPUView_invertTheMask = false; +int PPUView_sprite16Mode = 0; uint8 palcache[32] = { 0xFF }; //palette cache uint8 chrcache0[0x1000], chrcache1[0x1000], logcache0[0x1000], logcache1[0x1000]; //cache CHR, fixes a refresh problem when right-clicking @@ -98,58 +99,44 @@ extern unsigned int cdloggerVideoDataSize; void DrawPatternTable(uint8 *bitmap, uint8 *table, uint8 *log, uint8 pal) { - int i,j,x,y,index=0; + int i,j,k,x,y,index=0; int p=0,tmp; - uint8 chr0,chr1,logs; + uint8 chr0,chr1,logs,shift; uint8 *pbitmap = bitmap; pal <<= 2; - for (i = 0; i < 16; i++) //Columns - { - for (j = 0; j < 16; j++) //Rows - { + for (i = 0; i < (16 >> PPUView_sprite16Mode); i++) //Columns + { + for (j = 0; j < 16; j++) //Rows + { //----------------------------------------------- - // 8x8 sprite - for (y = 0; y < 8; y++) - { - chr0 = table[index]; - chr1 = table[index + 8]; - logs = log[index] & log[index + 8]; - tmp = 7; - if (PPUView_maskUnusedGraphics && cdloggerVideoDataSize && (((logs & 3) != 0) == PPUView_invertTheMask)) + for (k = 0; k < (PPUView_sprite16Mode + 1); k++) { + for (y = 0; y < 8; y++) { - // draw pixel ~8x darker - for (x = 0; x < 8; x++) + chr0 = table[index]; + chr1 = table[index + 8]; + logs = log[index] & log[index + 8]; + tmp = 7; + shift=(PPUView_maskUnusedGraphics && cdloggerVideoDataSize && (((logs & 3) != 0) == PPUView_invertTheMask))?3:0; + for (x = 0; x < 8; x++) { p = (chr0 >> tmp) & 1; p |= ((chr1 >> tmp) & 1) << 1; p = palcache[p | pal]; tmp--; - *(uint8*)(pbitmap++) = palo[p].b >> 3; - *(uint8*)(pbitmap++) = palo[p].g >> 3; - *(uint8*)(pbitmap++) = palo[p].r >> 3; + *(uint8*)(pbitmap++) = palo[p].b >> shift; + *(uint8*)(pbitmap++) = palo[p].g >> shift; + *(uint8*)(pbitmap++) = palo[p].r >> shift; } - } else - { - for (x = 0; x < 8; x++) - { - p = (chr0 >> tmp) & 1; - p |= ((chr1 >> tmp) & 1) << 1; - p = palcache[p | pal]; - tmp--; - *(uint8*)(pbitmap++) = palo[p].b; - *(uint8*)(pbitmap++) = palo[p].g; - *(uint8*)(pbitmap++) = palo[p].r; - } + index++; + pbitmap += (PATTERNBITWIDTH-24); } - index++; - pbitmap += ((PALETTEBITWIDTH>>2)-24); + index+=8; } + pbitmap -= ((PATTERNBITWIDTH<<(3+PPUView_sprite16Mode))-24); //------------------------------------------------ - index+=8; - pbitmap -= (((PALETTEBITWIDTH>>2)<<3)-24); } - pbitmap += ((PALETTEBITWIDTH>>2)*7); + pbitmap += (PATTERNBITWIDTH*((8<= patternDestX) && (mouse_x < (patternDestX + (PATTERNWIDTH * ZOOM)))) && (mouse_y >= patternDestY) && (mouse_y < (patternDestY + (PATTERNHEIGHT * ZOOM)))) { - mouse_x = (mouse_x - patternDestX) / (8 * ZOOM); - mouse_y = (mouse_y - patternDestY) / (8 * ZOOM); + int A = (mouse_x - patternDestX) / (8 * ZOOM); + int B = (mouse_y - patternDestY) / (8 * ZOOM); + if(PPUView_sprite16Mode) { + A *= 2; + mouse_x = (A & 0xE) + (B & 1); + mouse_y = (B & 0xE) + ((A >> 4) & 1); + } else { + mouse_x = A; + mouse_y = B; + } sprintf(str,"Tile: $%X%X",mouse_y,mouse_x); SetDlgItemText(hwndDlg,LBL_PPUVIEW_TILE1,str); SetDlgItemText(hwndDlg,LBL_PPUVIEW_TILE2,"Tile:"); SetDlgItemText(hwndDlg,LBL_PPUVIEW_PALETTES,"Palettes"); } else if (((mouse_x >= patternDestX + (PATTERNWIDTH * ZOOM) + 1) && (mouse_x < (patternDestX + (PATTERNWIDTH * ZOOM) * 2 + 1))) && (mouse_y >= patternDestY) && (mouse_y < (patternDestY + (PATTERNHEIGHT * ZOOM)))) { - mouse_x = (mouse_x - (patternDestX + (PATTERNWIDTH * ZOOM) + 1)) / (8 * ZOOM); - mouse_y = (mouse_y - patternDestY) / (8 * ZOOM); + int A = (mouse_x - (patternDestX + (PATTERNWIDTH * ZOOM) + 1)) / (8 * ZOOM); + int B = (mouse_y - patternDestY) / (8 * ZOOM); + if(PPUView_sprite16Mode) { + A *= 2; + mouse_x = (A & 0xE) + (B & 1); + mouse_y = (B & 0xE) + ((A >> 4) & 1); + } else { + mouse_x = A; + mouse_y = B; + } sprintf(str,"Tile: $%X%X",mouse_y,mouse_x); SetDlgItemText(hwndDlg,LBL_PPUVIEW_TILE2,str); SetDlgItemText(hwndDlg,LBL_PPUVIEW_TILE1,"Tile:"); @@ -472,6 +478,16 @@ BOOL CALLBACK PPUViewCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam PPUViewDoBlit(); break; } + case IDC_SPRITE16_MODE: + { + PPUView_sprite16Mode ^= 1; + CheckDlgButton(hwndDlg, IDC_SPRITE16_MODE, PPUView_sprite16Mode ? BST_CHECKED : BST_UNCHECKED); + // redraw now + PPUViewSkip = PPUViewRefresh; + FCEUD_UpdatePPUView(-1, 0); + PPUViewDoBlit(); + break; + } } } } diff --git a/trunk/src/drivers/win/res.rc b/trunk/src/drivers/win/res.rc index b2f74bac..d0a49b1c 100644 --- a/trunk/src/drivers/win/res.rc +++ b/trunk/src/drivers/win/res.rc @@ -7,8 +7,7 @@ // // Generated from the TEXTINCLUDE 2 resource. // -#include "afxres.h" - +#include "afxres.h" ///////////////////////////////////////////////////////////////////////////// #undef APSTUDIO_READONLY_SYMBOLS @@ -568,10 +567,10 @@ BEGIN CONTROL "Disable speed throttling used when sound is disabled.",CB_DISABLE_SPEED_THROTTLING, "Button",BS_AUTOCHECKBOX | WS_TABSTOP,10,8,183,12 CONTROL "Set high-priority thread.",CB_SET_HIGH_PRIORITY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,10,24,102,12 - CONTROL "Overclocking (old PPU only).",CB_OVERCLOCKING,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,10,42,101,10 - EDITTEXT IDC_EXTRA_SCANLINES,122,38,61,14,ES_AUTOHSCROLL - LTEXT "Extra scanlines:",IDC_STATIC,127,26,51,8 - CONTROL "Don't overclock 7-bit samples.",CB_SKIP_7BIT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,10,58,111,10 + CONTROL "Overclocking (old PPU only).",CB_OVERCLOCKING,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,10,42,101,10 + EDITTEXT IDC_EXTRA_SCANLINES,122,38,61,14,ES_AUTOHSCROLL + LTEXT "Extra scanlines:",IDC_STATIC,127,26,51,8 + CONTROL "Don't overclock 7-bit samples.",CB_SKIP_7BIT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,10,58,111,10 END MOVIEOPTIONS DIALOGEX 65520, 76, 147, 222 @@ -1254,6 +1253,7 @@ BEGIN CONTROL "Mask unused graphics (needs Code/Data Logger)",IDC_MASK_UNUSED_GRAPHICS, "Button",BS_AUTOCHECKBOX | WS_TABSTOP,6,190,169,10 CONTROL "Invert the mask",IDC_INVERT_THE_MASK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,177,190,61,10 + CONTROL "Sprites 8x16 mode",IDC_SPRITE16_MODE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,279,190,75,10 END ARCHIVECHOOSERDIALOG DIALOGEX 0, 0, 265, 159 @@ -2531,8 +2531,7 @@ IDB_BRANCH_SPRITESHEET BITMAP "res\\branch_spritesheet.bmp" // // Generated from the TEXTINCLUDE 3 resource. // - - + ///////////////////////////////////////////////////////////////////////////// #endif // not APSTUDIO_INVOKED diff --git a/trunk/src/drivers/win/resource.h b/trunk/src/drivers/win/resource.h index 89225574..e6b9f492 100644 --- a/trunk/src/drivers/win/resource.h +++ b/trunk/src/drivers/win/resource.h @@ -655,6 +655,8 @@ #define IDC_SUPERIMPOSE2 1205 #define IDC_RUN_AUTO 1205 #define IDC_AUTOLOADCDL 1205 +#define IDC_INVERT_THE_MASK2 1205 +#define IDC_SPRITE16_MODE 1205 #define IDC_C_SEARCH 1206 #define IDC_CHECK5 1206 #define IDC_CHECK_GREENZONE 1206