jorotroid
Member
Hey. If you're anything like me, then you too have also not quite figured out how to make use of FCEUX's debugger, but sometimes you just want to know what the value of something was at a given moment. Just put this code either in the Marco.asm file or create your own file of macros and include it. Then set up a hud element that displays a number with a max value of 8. When you want a value printed to the screen just call DebugPrint -name of value- and it will print the value to the hud element in binary. I went with binary because it seem easier to implement and most of what I want to know is whether or not my ANDs, ORs, or CMPs are getting the values I'm expecting. Just be careful when you call it so you don't interrupt the same process you are trying to observe. I am relative inexperienced with this assembly stuff, so I welcome anyone who has an idea on how to do this more efficiently, or why this might be a bad idea in general. Before you finish your game, you'll want probably to remove this code. (Edited post with much leaner code)
UPDATE: If this is relevant to you, check out Kasumi's posts. Kasumi provided both an alternative to observing values in FCEUX, and wrote a much more impressive version of the macro.
You don't have to name the variable Debug_0 like I did, just make sure that the name matches in the User Variables and in the code.
Lastly, here is an example screenshot. I have it DebugPrint gamepad in any of the scripts I have where you press a button. In this image, I am jumping and moving to the right, and the DebugPrint is showing that the bits for the Right and A buttons are set to 1.
I guess that image is a pseudo update on my game, but this past week has ended up being more about learning NESMaker and 6502 assembly than making show-able progress.
UPDATE: If this is relevant to you, check out Kasumi's posts. Kasumi provided both an alternative to observing values in FCEUX, and wrote a much more impressive version of the macro.
Code:
;;;;; Note: Somewhere else define a DebugPrintMask variable. Don't put it in the UserVariables.asm file!
;;;;; That file gets rewritten every time you export, so it will erase that variable. For me, I just created
;;;;; a MyVariables.asm file and included it after the UserVariables.asm include at the end of ZP_and_vars.asm.
MACRO DebugPrint arg0
PHA ; Save A and X on the stack
TXA
PHA
LDX #$0 ; initialize x for iteration
LDA #%00000001
STA DebugPrintMask ; set up mask for comparison
DebugPrintLoop:
LDA arg0
AND DebugPrintMask
BNE DebugPrintSet ; break if bit at x is 1
LDA #$0 ; otherwise, were going to get ready to set digit x to 0
JMP DebugPrintNext
DebugPrintSet:
LDA #$1 ; getting ready to set digit x to 1
DebugPrintNext:
STA Debug_0,X ; setting digit x
INX
CPX #$08
BEQ DebugPrintEnd ; branch if we've gone through the whole
ASL DebugPrintMask ; shift the mask for next digit to test
JMP DebugPrintLoop ; loop
DebugPrintEnd:
LDA DrawHudBytes ; Refresh hud
ORA #HUD_Debug_0
STA DrawHudBytes
PLA ; Restore original A and X values
TAX
PLA
ENDM
You don't have to name the variable Debug_0 like I did, just make sure that the name matches in the User Variables and in the code.
Lastly, here is an example screenshot. I have it DebugPrint gamepad in any of the scripts I have where you press a button. In this image, I am jumping and moving to the right, and the DebugPrint is showing that the bits for the Right and A buttons are set to 1.
I guess that image is a pseudo update on my game, but this past week has ended up being more about learning NESMaker and 6502 assembly than making show-able progress.