MCPcopy Create free account
hub / github.com/AppleWin/AppleWin / CmdZeroPageAdd

Function CmdZeroPageAdd

source/Debugger/Debug.cpp:7876–7946  ·  view source on GitHub ↗

===========================================================================

Source from the content-addressed store, hash-verified

7874
7875//===========================================================================
7876Update_t CmdZeroPageAdd (int nArgs)
7877{
7878 // ZP [address]
7879 // ZP # address [address...]
7880 if (!nArgs)
7881 {
7882 return CmdZeroPageList(0);
7883 }
7884
7885 int iArg = 1;
7886 int iZP = NO_6502_TARGET;
7887
7888 if (nArgs > 1)
7889 {
7890 iZP = g_aArgs[1].nValue;
7891 if (iZP >= MAX_ZEROPAGE_POINTERS)
7892 {
7893 ConsoleDisplayPushFormat("Zero page pointer index too big. (Max: %d)", MAX_ZEROPAGE_POINTERS - 1);
7894 return ConsoleUpdate();
7895 }
7896
7897 iArg++;
7898 }
7899
7900 bool bAdded = false;
7901 for (; iArg <= nArgs; iArg++ )
7902 {
7903 WORD nAddress = g_aArgs[iArg].nValue;
7904
7905 // Make sure address is a ZP address
7906 if (nAddress > _6502_ZEROPAGE_END)
7907 {
7908 ConsoleDisplayPushFormat("Zero page pointer must be in the range: [00..%02X].", _6502_ZEROPAGE_END);
7909 return ConsoleUpdate();
7910 }
7911
7912 if (iZP == NO_6502_TARGET)
7913 {
7914 iZP = 0;
7915 while ((iZP < MAX_ZEROPAGE_POINTERS) && (g_aZeroPagePointers[iZP].bSet))
7916 {
7917 iZP++;
7918 }
7919 }
7920
7921 if ((iZP >= MAX_ZEROPAGE_POINTERS) && !bAdded)
7922 {
7923 ConsoleDisplayPushFormat("All zero page pointers are currently in use. (Max: %d)", MAX_ZEROPAGE_POINTERS);
7924 return ConsoleUpdate();
7925 }
7926
7927 if ((iZP < MAX_ZEROPAGE_POINTERS) && (g_nZeroPagePointers < MAX_ZEROPAGE_POINTERS))
7928 {
7929 g_aZeroPagePointers[iZP].bSet = true;
7930 g_aZeroPagePointers[iZP].bEnabled = true;
7931 g_aZeroPagePointers[iZP].nAddress = (BYTE) nAddress;
7932 bAdded = true;
7933 g_nZeroPagePointers++;

Callers

nothing calls this directly

Calls 4

CmdZeroPageListFunction · 0.85
ConsoleDisplayPushFormatFunction · 0.85
Help_Arg_1Function · 0.85
ConsoleUpdateFunction · 0.70

Tested by

no test coverage detected