development:csdk:1.0:debugging
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | |||
development:csdk:1.0:debugging [2024/11/08 01:57] – removed - external edit (Unknown date) 127.0.0.1 | development:csdk:1.0:debugging [2024/11/08 01:57] (current) – ↷ Page moved from development:csdk:debugging to development:csdk:1.0:debugging clyde | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== Debugging your Program ====== | ||
+ | |||
+ | The GameTank emulator contains a few tools to debug your program: | ||
+ | |||
+ | * The VRAM Viewer allows to check what is actually loaded in VRAM | ||
+ | * The Memory Browser allows to look at the RAM. Its Variables tab allows to see the value of any global variable defined in C | ||
+ | * The Code Stepper allows to set breakpoints and execute your program instruction by instruction | ||
+ | * The Profiler allows to see how much time is being spent by the blitter and the CPU for each screen refresh. In order to keep a 60 FPS animation, the bar shown in the screen should stay well below 1 | ||
+ | |||
+ | ===== Setting Breakpoints ===== | ||
+ | |||
+ | Setting breakpoints in Code Stepper isn't always easy when the program was written in C. Here is a tip to create breakpoints: | ||
+ | |||
+ | * Define an empty '' | ||
+ | * Call that function in the areas of your code that need debugging | ||
+ | |||
+ | void breakpoint() {} | ||
+ | | ||
+ | int main () { | ||
+ | ... | ||
+ | | ||
+ | // Doing some stuff that needs to be debugged | ||
+ | ... | ||
+ | } | ||
+ | |||
+ | * In the Code Stepper, set a breakpoint on '' | ||
+ | * Step out of the '' | ||
+ | * Step out of the interrupt handler function | ||
+ | * You should now be right where you want to be | ||
+ | |||
+ | ===== Assembly to C ===== | ||
+ | |||
+ | In order to better understand how the assembly code shown in the Code Stepper relates to the original C code: | ||
+ | |||
+ | * Update the '' | ||
+ | * Run '' | ||
+ | * Open '' | ||
+ | |||
+ | ; | ||
+ | ; if (tile_val & 0x20) { | ||
+ | ; | ||
+ | L000D: | ||
+ | and #$20 | ||
+ | beq L000E | ||
+ | ; | ||
+ | ; tmp = 1; | ||
+ | ; | ||
+ | lda #$01 | ||
+ | sta _tmp | ||