Programing sega genesis games

does anyone know how people used to write games for genesis, sega master system, Nintendo and such?