MCPcopy Create free account
hub / github.com/TASEmulators/fceux / InstructionUp

Function InstructionUp

src/drivers/Qt/ConsoleDebugger.cpp:3786–3814  ·  view source on GitHub ↗

---------------------------------------------------------------------------- This function is for "smart" scrolling... it attempts to scroll up one line by a whole instruction

Source from the content-addressed store, hash-verified

3784// This function is for "smart" scrolling...
3785// it attempts to scroll up one line by a whole instruction
3786static int InstructionUp(int from)
3787{
3788 int i = std::min(16, from), j;
3789
3790 while (i > 0)
3791 {
3792 j = i;
3793 while (j > 0)
3794 {
3795 if (GetMem(from - j) == 0x00)
3796 break; // BRK usually signifies data
3797 if (opsize[GetMem(from - j)] == 0)
3798 break; // invalid instruction!
3799 if (opsize[GetMem(from - j)] > j)
3800 break; // instruction is too long!
3801 if (opsize[GetMem(from - j)] == j)
3802 return (from - j); // instruction is just right! :D
3803 j -= opsize[GetMem(from - j)];
3804 }
3805 i--;
3806 }
3807
3808 // if we get here, no suitable instruction was found
3809 if ((from >= 2) && (GetMem(from - 2) == 0x00))
3810 return (from - 2); // if a BRK instruction is possible, use that
3811 if (from)
3812 return (from - 1); // else, scroll up one byte
3813 return 0; // of course, if we can't scroll up, just return 0!
3814}
3815//static int InstructionDown(int from)
3816//{
3817// int tmp = opsize[GetMem(from)];

Callers 1

updateAssemblyViewMethod · 0.70

Calls 1

GetMemFunction · 0.85

Tested by

no test coverage detected