Given an Address, and Line to display it on Calculate the address of the top and bottom lines @param bUpdateCur true = Update Cur based on Top false = Update Top & Bot based on Cur ===========================================================================
| 728 | // false = Update Top & Bot based on Cur |
| 729 | //=========================================================================== |
| 730 | void DisasmCalcTopFromCurAddress(bool bUpdateTop) |
| 731 | { |
| 732 | int nLen = g_nDisasmCurLine * 3; // max 3 opcodes/instruction, is our search window |
| 733 | |
| 734 | // Look for a start address that when disassembled, |
| 735 | // will have the cursor on the specified line and address |
| 736 | int iTop = g_nDisasmCurAddress - nLen; |
| 737 | int iCur = g_nDisasmCurAddress; |
| 738 | |
| 739 | g_bDisasmCurBad = false; |
| 740 | |
| 741 | bool bFound = false; |
| 742 | while (iTop <= iCur) |
| 743 | { |
| 744 | WORD iAddress = iTop; |
| 745 | // int iOpcode; |
| 746 | int iOpmode; |
| 747 | int nOpbytes; |
| 748 | |
| 749 | for (int iLine = 0; iLine <= nLen; iLine++) // min 1 opcode/instruction |
| 750 | { |
| 751 | // a. |
| 752 | _6502_GetOpmodeOpbyte(iAddress, iOpmode, nOpbytes); |
| 753 | // b. |
| 754 | // _6502_GetOpcodeOpmodeOpbyte( iOpcode, iOpmode, nOpbytes ); |
| 755 | |
| 756 | if (iLine == g_nDisasmCurLine) // && (iAddress == g_nDisasmCurAddress)) |
| 757 | { |
| 758 | if (iAddress == g_nDisasmCurAddress) |
| 759 | // b. |
| 760 | // && (iOpmode != AM_1) && |
| 761 | // && (iOpmode != AM_2) && |
| 762 | // && (iOpmode != AM_3) && |
| 763 | // && _6502_IsOpcodeValid( iOpcode)) |
| 764 | { |
| 765 | g_nDisasmTopAddress = iTop; |
| 766 | bFound = true; |
| 767 | break; |
| 768 | } |
| 769 | } |
| 770 | |
| 771 | // .20 Fixed: DisasmCalcTopFromCurAddress() |
| 772 | //if ((eMode >= AM_1) && (eMode <= AM_3)) |
| 773 | #if 0 // _DEBUG |
| 774 | LogOutput("%04X : %d bytes\n", iAddress, nOpbytes); |
| 775 | #endif |
| 776 | iAddress += nOpbytes; |
| 777 | } |
| 778 | if (bFound) |
| 779 | { |
| 780 | break; |
| 781 | } |
| 782 | iTop++; |
| 783 | } |
| 784 | |
| 785 | if (!bFound) |
| 786 | { |
| 787 | // Well, we're up the creek. |
no test coverage detected