Skip to content

Code Re Org Handling Different Systems

Thomas Cherryhomes edited this page Oct 14, 2021 · 1 revision

Thanks to the tireless work of @idolpx, the FujiNet codebase took a major step towards handling more than Atari hosts.

@tschak909 has taken this, and extended it. This page will be the landing for changes to facilitate this major milestone.

New Directory Structures

Devices, media types, and other things have been moved out of lib/sio, and now been separated by platform.

lib/bus

This contains the low level functions for code in lib/devices to talk to the various system buses, such as lib/bus/sio/sio.cpp to talk Atari SIO protocol, and lib/bus/adamnet/adamnet.cpp to talk to the AdamNet bus present on the Coleco Adam, and lib/bus/iec/iec.cpp to talk the Commodore IEC bus protocol for Commodore 8-bit systems.

lib/devices

This contains devices for a given platform, and follow the convention previously used in libsio. For example lib/devices/adamnet/disk.cpp provides the disk drive for Coleco Adam systems.

lib/media

This contains code to abstract the manipulation of various types of media for the different protocols. This is currently split up via platform, so lib/media/atari for Atari 8-bit based media formats, lib/media/adam for Coleco Adam based media formats, and so on.

New Defines

The following defines have been added to support platform differentiation:

  • BUILD_ATARI - Build for Atari 8-bit
  • BUILD_CBM - Build for Commodore 8-bit systems with serial bus (IEC) such as Commodore VIC-20/C64/PLUS4/C128 (Hopefully we'll do IEEE-488 someday!)
  • BUILD_ADAM - Build for Coleco Adam, and the AdamNet

Using the defines to conditionally compile code

Since all code under src/ and lib/ is compiled, you should use the above macros to ensure that code will only compile for a particular host, such as:

  • lib/device/adamnet/disk.cpp
#ifdef BUILD_ADAM

#include <memory.h>
#include <string.h>

#include "../../include/debug.h"
#include "../utils/utils.h"

#include "../device/adamnet/disk.h"
#include "media.h"

adamDisk::adamDisk()
{

}

mediatype_t adamDisk::mount(FILE *f, const char *filename, uint32_t disksize, mediatype_t disk_type)
{
    return MEDIATYPE_UNKNOWN;
}

void adamDisk::unmount()
{

}

bool adamDisk::write_blank(FILE *f, uint16_t sectorSize, uint16_t numSectors)
{
    return false;
}


void adamDisk::adamnet_read()
{

}

void adamDisk::adamnet_write()
{

}

void adamDisk::adamnet_format()
{

}

void adamDisk::adamnet_status()
{

}

void adamDisk::adamnet_process(uint8_t b)
{

}

#endif /* BUILD_ADAM */

or to selectively enable functionality within shared code, such as:

  • lib/http/libHttpServiceConfigurator.cpp
// ...
#ifdef BUILD_ATARI
void fnHttpServiceConfigurator::config_cassette(std::string play_record, std::string resistor, bool rew)
{
    // call the cassette buttons function passing play_record.c_str()
    // find cassette via thefuji object?
    Debug_printf("New play/record button value: %s\n", play_record.c_str());
    if (!play_record.empty())
    {
        theFuji.cassette()->set_buttons(util_string_value_is_true(play_record));
        Config.store_cassette_buttons(util_string_value_is_true(play_record));
    }
    if (!resistor.empty())
    {
        theFuji.cassette()->set_pulldown(util_string_value_is_true(resistor));
        Config.store_cassette_pulldown(util_string_value_is_true(resistor));
    }
    else if (rew == true)
    {
        Debug_printf("Rewinding cassette.\n");
        SIO.getCassette()->rewind();
    }
    Config.save();
}

void fnHttpServiceConfigurator::config_midimaze(std::string hostname)
{
    Debug_printf("Set MIDIMaze host: %s\n", hostname.c_str());

    // Update the host ip variable
    SIO.setMIDIHost(hostname.c_str());
    // Save change
    Config.store_midimaze_host(hostname.c_str());
    Config.save();
}

#endif /* ATARI */
// ...
Clone this wiki locally