Skip to content

4. Understand the MiSTer core

sy2002 edited this page Jul 9, 2022 · 21 revisions

Before you start porting, you should first understand how the MiSTer core works. In the optimal case, you own a MiSTer and can actually experiment and play with the core. But this is not mandatory. There are also a lot of YouTube videos about many cores. It is important that you get an overall "feeling" for the core and how it behaves. And even more important: About the disk mounting, ROM loading and configuration options that are available to the end user, because this helps you to understand a lot of things, including MiSTer's core configuration string (CONF_STR).

So you have played enough with the core and/or watched some YouTube videos and you feel you have understood the "end user view" of the MiSTer core you want to port to MEGA65? Great - then let's start to dive in at the deep end.

Understand MiSTer and the MiSTer framework

MiSTer has a great documentation for developers where you can learn how to port a core TO MiSTer. What we want to achieve here is learn how to port a core FROM MiSTer. Nevertheless for MiSTer2MEGA65 porting experience will be much smoother if you start from first principles. Please read the following chapters of the MiSTer documentation before you proceeed:

  1. Porting Cores
  2. Core Configuration String
  3. Overview of emu module
  4. sys - hps_io
  5. sys - video_freak
  6. sys - video_mixer
  7. sys - arcade_video

Don't worry if you are not understanding everything written in these seven chapters. It is more important that you have a high-level overview of the concepts and that you have seen most of them now at least once and that you know where to look in case you get stuck at a later stage of your porting adventure.

Step #1 - Examine the structure of the core

Now it is time to examine the structure of the actual core you want to port. As an easy start, we suggest to go to the core's GitHub repository and browse the source code there. You might use the MiSTer Wiki as a starting point to find the repository of the core: Scroll down a bit and you will find the list of cores on the right side.

MiSTer is a very structured project, so we can rely on certain files and folders to be always present:

  • rtl folder: Contains the actual core. Many MiSTer cores are enhanced versions of MiST cores or other cores. Therefore the MiSTer team encapsulates everything related to the core itself inside the rtl folder.

  • sys folder: This is the MiSTer framework that provides similar services than the MiSTer2MEGA65 framework.

  • *.sv file on the root folder that is named like the core: This is your starting point for any porting effort, because you will be able to study the "wiring" of the MiSTer core: How does MiSTer actually connect different parts of the core with its own framework? Which kind of glue logic is necessary? What options does MiSTer offer to the users? ROMs? Drives? (Hint: The *.sv file is actually not the top-file used to synthesize a MiSTer core. Instead, sys/sys_top.v is used. But this does not matter for our porting purposes.)

Step #2 - Learn more about the environment the core needs to run

Clock speed Video output Keyboard Other peripherals RAM ROM