diff --git a/source/NTSC.cpp b/source/NTSC.cpp index b97b5b6b..29dd332c 100644 --- a/source/NTSC.cpp +++ b/source/NTSC.cpp @@ -1886,7 +1886,7 @@ static void GenerateVideoTables( void ) g_uVideoMode = VF_HIRES; for (UINT i=0, cycle=VIDEO_SCANNER_HORZ_START; i= kVPresetLine) // check for previous vertical state preset { - nVState -= nScanLines; // compensate for preset + nVState -= kScanLines; // compensate for preset } int v_A = (nVState >> 0) & 1; // get vertical state bits int v_B = (nVState >> 1) & 1; @@ -835,9 +820,9 @@ WORD VideoGetScannerAddress(DWORD nCycles) // calculate scanning memory address // - if (nHires && SW_MIXED && v_4 && v_2) // HIRES TIME signal (UTAIIe:5-7,P3) + if (bHires && SW_MIXED && v_4 && v_2) // HIRES TIME signal (UTAIIe:5-7,P3) { - nHires = 0; // address is in text memory for mixed hires + bHires = false; // address is in text memory for mixed hires } int nAddend0 = 0x0D; // 1 1 0 1 @@ -845,54 +830,58 @@ WORD VideoGetScannerAddress(DWORD nCycles) int nAddend2 = (v_4 << 3) | (v_3 << 2) | (v_4 << 1) | (v_3 << 0); int nSum = (nAddend0 + nAddend1 + nAddend2) & 0x0F; // SUM (UTAIIe:5-9) - int nAddress = 0; // build address from video scanner equations (UTAIIe:5-8,T5.1) - nAddress |= h_0 << 0; // a0 - nAddress |= h_1 << 1; // a1 - nAddress |= h_2 << 2; // a2 - nAddress |= nSum << 3; // a3 - a6 - g_PartialH = nAddress; + WORD nAddressH = 0; // build address from video scanner equations (UTAIIe:5-8,T5.1) + nAddressH |= h_0 << 0; // a0 + nAddressH |= h_1 << 1; // a1 + nAddressH |= h_2 << 2; // a2 + nAddressH |= nSum << 3; // a3 - a6 + if (!bHires) + { + // Apple ][ (not //e) and HBL? + // + if (IS_APPLE2 && // Apple II only (UTAIIe:I-4,#5) + !h_5 && (!h_4 || !h_3)) // HBL (UTAIIe:8-10,F8.5) + { + nAddressH |= 1 << 12; // Y: a12 (add $1000 to address!) + } + } - nAddress |= v_0 << 7; // a7 - nAddress |= v_1 << 8; // a8 - nAddress |= v_2 << 9; // a9 + WORD nAddressV = 0; + nAddressV |= v_0 << 7; // a7 + nAddressV |= v_1 << 8; // a8 + nAddressV |= v_2 << 9; // a9 - int p2a = !(nPage2 && !n80Store); - int p2b = nPage2 && !n80Store; + int p2a = !(bPage2 && !b80Store) ? 1 : 0; + int p2b = (bPage2 && !b80Store) ? 1 : 0; - if (nHires) // hires? + WORD nAddressP = 0; // Page bits + if (bHires) // hires? { // Y: insert hires-only address bits // - nAddress |= v_A << 10; // a10 - nAddress |= v_B << 11; // a11 - nAddress |= v_C << 12; // a12 - g_PartialV = nAddress - g_PartialH; - - nAddress |= p2a << 13; // a13 - nAddress |= p2b << 14; // a14 + nAddressV |= v_A << 10; // a10 + nAddressV |= v_B << 11; // a11 + nAddressV |= v_C << 12; // a12 + nAddressP |= p2a << 13; // a13 + nAddressP |= p2b << 14; // a14 } else { // N: insert text-only address bits // - g_PartialV = nAddress - g_PartialH; - - // Apple ][ (not //e) and HBL? - // - if (IS_APPLE2 && // Apple II only (UTAIIe:I-4,#5) - !h_5 && (!h_4 || !h_3)) // HBL (UTAIIe:8-10,F8.5) - { - nAddress |= 1 << 12; // Y: a12 (add $1000 to address!) - g_PartialH |= 1 << 12; - } - - nAddress |= p2a << 10; // a10 - nAddress |= p2b << 11; // a11 + nAddressP |= p2a << 10; // a10 + nAddressP |= p2b << 11; // a11 } // VBL' = v_4' | v_3' = (v_4 & v_3)' (UTAIIe:5-10,#3) - return static_cast(nAddress); + if (videoScannerAddr == VS_PartialAddrH) + return nAddressH; + + if (videoScannerAddr == VS_PartialAddrV) + return nAddressV; + + return nAddressP | nAddressV | nAddressH; } //=========================================================================== @@ -903,7 +892,7 @@ bool VideoGetVblBar(const DWORD uExecutedCycles) int nCycles = CpuGetCyclesThisVideoFrame(uExecutedCycles); // calculate video parameters according to display standard - const int kScanLines = bVideoScannerNTSC ? kNTSCScanLines : kPALScanLines; + const int kScanLines = g_bVideoScannerNTSC ? kNTSCScanLines : kPALScanLines; const int kScanCycles = kScanLines * kHClocks; nCycles %= kScanCycles; diff --git a/source/Video.h b/source/Video.h index 3bacb655..bd064502 100644 --- a/source/Video.h +++ b/source/Video.h @@ -169,9 +169,8 @@ void VideoRedrawScreen (void); void VideoRefreshScreen (uint32_t uRedrawWholeScreenVideoMode = 0, bool bRedrawWholeScreen = false); void VideoReinitialize (); void VideoResetState (); -WORD VideoGetScannerAddressPartialV(DWORD nCycles); -WORD VideoGetScannerAddressPartialH(DWORD nCycles); -WORD VideoGetScannerAddress(DWORD nCycles); +enum VideoScanner_e {VS_FullAddr, VS_PartialAddrV, VS_PartialAddrH}; +WORD VideoGetScannerAddress(DWORD nCycles, VideoScanner_e videoScannerAddr = VS_FullAddr); bool VideoGetVblBar(DWORD uExecutedCycles); bool VideoGetSW80COL(void);