In this section, you learn about creating windows and about stepping through the UFO program's source code, including the following:
To look at your program in a Source window, follow these steps:
<HTML><ol></HTML>
<HTML><li></HTML>Make sure the files UFO (executable), UFO.sym (symbols file), and UFO.spt (script file) are in the /remote folder.<HTML></li></HTML>
<HTML><li></HTML><HTML><p></HTML>Type into the Terminal window: <HTML></p></HTML>
debug ufo
<HTML><p></HTML>and press Enter.<HTML></p></HTML>
<HTML><p></HTML>The Debugger launches the program and stops at main()
.<HTML></p></HTML><HTML></li></HTML>
<HTML><li></HTML><HTML><p></HTML>Press Command-K to bring up a Source window (or choose New Window, then Source from the View menu).<HTML></p></HTML>
<HTML><p></HTML>When you use debug
prog_name to start a program (as in Step 2), the Debugger always puts a breakpoint at main()
. In the Source window shown in the figure below, the program is stopped at main()
.<HTML></p></HTML>
<HTML><p></HTML><HTML></p></HTML>
<HTML><p></HTML>Figure 1: Source window stopped at a breakpoint at main().<HTML></p></HTML><HTML></li></HTML>
<HTML><li></HTML><HTML><p></HTML>Press Command-G to release the program.<HTML></p></HTML>
<HTML><p></HTML>The startup screen should appear on the TV monitor after a short time.<HTML></p></HTML><HTML></li></HTML>
<HTML><li></HTML>In the Terminal window, watch the information about the program's progress. When the text “DoOptions called” appears, press the Start button on the control pad attached to the 3DO system to start the game.<HTML></li></HTML><HTML></ol></HTML>
If you know a program's flow, you can set a breakpoint in the Source window to stop execution and examine the program.
<HTML><ol></HTML>
<HTML><li></HTML><HTML><p></HTML>In the Source window, click on the cross-hatch (#) next to the line TargetAction(pcUFO)
as shown in the figure below.<HTML></p></HTML>
<HTML><p></HTML>The cross-hatch changes to a red bullet.<HTML></p></HTML>
<HTML><p></HTML><HTML></p></HTML>
<HTML><p></HTML>Figure 2: Location for setting a breakpoint.<HTML></p></HTML>
<HTML><p></HTML>When the program reaches the breakpoint in the while
loop the next time, it stops. You can now examine the program by stepping through it.<HTML></p></HTML><HTML></li></HTML>
<HTML><li></HTML>Use Command-, (comma)-Step Over-to move to UpdateDashboard()
.<HTML></li></HTML>
<HTML><li></HTML>Use Command-; (semicolon)-Step In-to move to the first line of UpdateDashboard()
.<HTML></li></HTML>
<HTML><li></HTML>Continue to examine the program for as long as you like.<HTML></li></HTML>
<HTML><li></HTML>To remove the breakpoint, click on it again and it changes back to the cross-hatch.<HTML></li></HTML><HTML></ol></HTML>
Note: Step Over goes to the first executing instruction of a function. Step In goes to the next executable line and makes it possible to look at local variables and other function-internal information. Usually, you use Step In only to look at a particular function in detail.
The 3DO Debugger lets you look at structures, evaluate variables, and dereference pointers in the Variables window. You can also change the value of a variable and see the effect of the change on your program.
<HTML><ol></HTML>
<HTML><li></HTML>Return to the main loop and press Command-, (Command-comma) to step into the TargetAction()
function.<HTML></li></HTML>
<HTML><li></HTML><HTML><p></HTML>With the PC (program counter) inside the TargetAction()
function, select pcTarget
, then press Command-D to bring up a Variables window.<HTML></p></HTML>
<HTML><p></HTML><HTML></p></HTML>
<HTML><p></HTML>Figure 3: Variables window invoked from a Source window.<HTML></p></HTML><HTML></li></HTML>
<HTML><li></HTML><HTML><p></HTML>Hold down the Command key and double-click on the structure in the Variables window to expand it.<HTML></p></HTML>
<HTML><p></HTML><HTML></p></HTML>
<HTML><p></HTML>Figure 4: Structure displayed in a Variables window.<HTML></p></HTML><HTML></li></HTML>
<HTML><li></HTML><HTML><p></HTML>To interactively change variable values, click on the ccb_Flags
line to make it appear in the edit region.<HTML></p></HTML>
<HTML><p></HTML><HTML></p></HTML>
<HTML><p></HTML>Figure 5: Variable value selected for interactive change.<HTML></p></HTML><HTML></li></HTML>
<HTML><li></HTML>Change 7F26… to FF26…, then press the Return key.<HTML></li></HTML>
<HTML><li></HTML><HTML><p></HTML>To see the change take effect, look at the TV screen and watch the UFO disappear as you press Command-G to release the breakpoint and continue program execution.<HTML></p></HTML>
<HTML><p></HTML>If you want to change the value back, set a breakpoint elsewhere and change the value, then release the breakpoint again.<HTML></p></HTML><HTML></li></HTML>
<HTML><li></HTML>To change the position of the UFO, double-click on the ccb_XPOS
line.<HTML></li></HTML>
<HTML><li></HTML><HTML><p></HTML>From the Options menu, select Frac16-16 to see the position's actual value.<HTML></p></HTML>
<HTML><p></HTML><HTML></p></HTML>
<HTML><p></HTML>Figure 6: Display options pull-down menu in the Variables window.<HTML></p></HTML><HTML></li></HTML>
<HTML><li></HTML>Change the value of the position in the ccb_XPOS
line, then press the Enter key.<HTML></li></HTML>
<HTML><li></HTML>Release the breakpoint by pressing Command-G to continue.<HTML></li></HTML><HTML></ol></HTML>