Close

Debugging

A project log for Wolf

Use a Jaguar or SNES controller as a joystick and a keypad in Atari 2600 and 7800

danjovicdanjovic 03/20/2022 at 22:580 Comments

Started to debug the code. So far the SNES controller reading is fine, operating mode selection is fine, Left port driving is fine.

For this project I have used variables to store the state of the input controls and for the output data to interface with the videogame, thus isolating the sampling functions from the logic funcions and from the driving functions. That makes the code development way more easier than some of my previous projects.

/// Input reports

unsigned long  snesScan;
// bit     31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 09 08 07 06 05 04 03 02 01 00
// Gamepad Lo Lo Lo Lo Lo Lo Lo Lo Lo Lo Lo Lo Lo Lo Lo Lo Hi Hi Hi Hi  R  L  X  A RG LF DW UP St Sl  Y  B
// NTT-pad Ec Hi  C  .  #  *  9  8  7  6  5  4  3  2  1  0 Hi Hi Lo Hi  R  L  X  A RG LF DW UP Nx Pr  Y  B

volatile uint8_t jaguarKeypadRow[4] = {255, 255, 255, 255};
//   row   /   bit   7   6   5   4   3   2   1   0
//    0              Hi  Hi  Ps  A   U   D   L   R
//    1              Hi  Hi  C1  B   *   7   4   1
//    2              Hi  Hi  C2  C   0   8   5   2
//    3              Hi  Hi  C3  Op  #   9   6   3

/// Output reports

volatile uint8_t atariKeypad[4]     = {255, 255, 255, 255};
//   row   /   bit   7   6   5   4   3   2   1   0
//    0              Hi  Hi  Hi  Hi  Hi  3   2   1
//    1              Hi  Hi  Hi  Hi  Hi  6   5   4
//    2              Hi  Hi  Hi  Hi  Hi  9   8   7
//    3              Hi  Hi  Hi  Hi  Hi  #   0   *

//   7    6    5    4    3    2    1    0
//   0    0   POT2 POT1 FIRE COL3 COL2 COL1
volatile uint8_t atariKeypadColsFirebuttons;

//   7    6    5    4     3    2    1    0
//  J3/4 J2/5 J1/6 J0/7 RIGHT LEFT DOWN UP
volatile uint8_t atariDirectionalsJaguarRows;

 To help me to debug I have also wrote a function that prints the state of such variables whenever they change, 


Discussions