krocki / gb

A minimal C implementation of Nintendo Gameboy - An fast research environment for Reinforcement Learning
Apache License 2.0
170 stars 15 forks source link

debug=1 command-line parameter has no effect #5

Open ghost opened 5 years ago

ghost commented 5 years ago

The usage suggests appending debug=1 to the command-line:

$ LD_LIBRARY_PATH=. ./gameboy 
usage: ./gameboy <rom> [bootrom=0] [speed_limit=0] [debug=1] [stdout=0]

However, the emulator still reports that DEBUG=0:

$ LD_LIBRARY_PATH=. ./gameboy wario_walking.gb debug=1
BOOTROM=0
DEBUG=0
SPEED_LIMIT=1
STDOUT=0
    0.000, GB starting...
    0.000, reset ok, waiting for GL...
krocki commented 5 years ago

when DEBUG is set to TRUE, it sets the internal global variable gl_debug to 1, which may be used to print some debugging information. See main_lcd.c lines 182-186:

while (gl_ok) {
         if (gl_debug) { /* put any debugging stuff here */ }
         next_frame();
         if (serial) check_stdout();
    }
ghost commented 5 years ago

The code:

printf("usage: ./gameboy <rom> [bootrom=%d] [speed_limit=%d] [debug=%d] [stdout=%d]\n",
               BOOTROM, gl_debug, limit_speed, serial);

has gl_debug and limit_speed in the wrong position.