Basic code to make a module themable
You first let Drupal's theme system know about your "theme" functions. You just create a function called mymodule_theme and that should return an array with your theme functions defined. See hook_theme for more details. 

Example:

function mymodule_theme() {
  return array(
    'funstuff_output' =&gt; array(
      'variables' =&gt; array('node' =&gt; NULL),
    ),
  );
}


Now the 'funstuff_output' function does not exist... so create it!

function theme_funstuff_output($variables) {
  $node = $variables['node'];
  $output = '&lt;h1&gt;' . $node-&gt;title . ' is fun stuff&lt;/h1&gt;';
  return $output;
}


Now you can call taht theme function anywhere like so: print theme('funstuff_output', array('node' =&gt; $node));

In Drupal 6, I think variables is called arguments and there are some other differences. But that's the basics.