Updates for Sharp MZ Series emulator
This commit is contained in:
63
include/bitmaps.h
Executable file
63
include/bitmaps.h
Executable file
@@ -0,0 +1,63 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Name: bitmaps.h
|
||||
// Created: May 2021
|
||||
// Version: v1.0
|
||||
// Author(s): Williams, Philip Smart
|
||||
// Description: The Bitmap Library.
|
||||
// This is a bitmap definition and manipulation library.
|
||||
// for use with the Sharp MZ Series OSD./
|
||||
// Credits:
|
||||
// Copyright: (c) 2019-2021 Philip Smart <philip.smart@net2net.org>
|
||||
//
|
||||
// History: May 2021 - Initial write of the OSD software.
|
||||
//
|
||||
// Notes: See Makefile to enable/disable conditional components
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// This source file is free software: you can redistribute it and#or modify
|
||||
// it under the terms of the GNU General Public License as published
|
||||
// by the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This source file is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
#ifndef BITMAPS_H
|
||||
#define BITMAPS_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// Supported bitmaps.
|
||||
enum BITMAPS {
|
||||
BITMAP_ARGO = 0x00, // Large Argo logo.
|
||||
BITMAP_ARGO_MEDIUM = 0x01, // Medium Argo logo.
|
||||
BITMAP_ARGO_SMALL = 0x02 // Small Argo logo.
|
||||
};
|
||||
|
||||
|
||||
typedef struct {
|
||||
uint8_t *bitmap; // The bitmap data to represent the image
|
||||
uint16_t width; // The width of the font in pixels
|
||||
uint16_t height; // The height of the font in pixels
|
||||
} bitmapStruct;
|
||||
|
||||
extern const bitmapStruct argo256x128;
|
||||
extern const bitmapStruct argo128x64;
|
||||
extern const bitmapStruct argo64x32;
|
||||
|
||||
|
||||
// Prototypes.
|
||||
//
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif // BITMAPS_H
|
||||
601
include/emumz.h
Executable file
601
include/emumz.h
Executable file
@@ -0,0 +1,601 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Name: emumz.h
|
||||
// Created: May 2021
|
||||
// Version: v1.0
|
||||
// Author(s): Philip Smart
|
||||
// Description: The MZ Emulator Control Logic
|
||||
// This source file contains the logic to present an on screen display menu, interact
|
||||
// with the user to set the config or perform machine actions (tape load) and provide
|
||||
// overall control functionality in order to service the running Sharp MZ Series
|
||||
// emulation.
|
||||
// Credits:
|
||||
// Copyright: (c) 2019-2020 Philip Smart <philip.smart@net2net.org>
|
||||
//
|
||||
// History: May 2020 - Initial write of the OSD software.
|
||||
//
|
||||
// Notes: See Makefile to enable/disable conditional components
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// This source file is free software: you can redistribute it and#or modify
|
||||
// it under the terms of the GNU General Public License as published
|
||||
// by the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This source file is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
#ifndef EMUMZ_H
|
||||
#define EMUMZ_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// Macros.
|
||||
//
|
||||
#define NUMELEM(a) (sizeof(a)/sizeof(a[0]))
|
||||
|
||||
// Constants.
|
||||
//
|
||||
#define MAX_MENU_ROWS 25 // Maximum number of menu rows using smallest font.
|
||||
#define MENU_ROW_WIDTH 80 // Maximum width of a menu row.
|
||||
#define MENU_CHOICE_WIDTH 20 // Maximum width of a choice item.
|
||||
#define MAX_MENU_DEPTH 5 // Maximum depth of menus.
|
||||
#define MAX_MACHINE_TITLE_LEN 15 // Maximum length of the side bar machine name title.
|
||||
#define MAX_DIRENTRY 512 // Maximum number of read and stored directory entries from the SD card per directory.
|
||||
#define MAX_DIR_DEPTH 4 // Maximum depth of sub-directories to enter.
|
||||
#define MAX_FILENAME_LEN 256 // Maximum supported length of a filename.
|
||||
#define MAX_FILTER_LEN 8 // Maximum length of a file filter.
|
||||
#define TOPLEVEL_DIR "0:\\" // Top level directory for file list and select.
|
||||
#define MAX_TAPE_QUEUE 5 // Maximum number of files which can be queued in the virtual tape drive.
|
||||
#define CONFIG_FILENAME "0:\\EMZ.CFG" // Configuration file for persisting the configuration.
|
||||
#define MAX_EMU_REGISTERS 16 // Number of programmable registers in the emulator.
|
||||
|
||||
// Maximum number of machines currently supported by the emulation.
|
||||
//
|
||||
#define MAX_MZMACHINES 8
|
||||
|
||||
// Numeric index of each machine.
|
||||
//
|
||||
#define MZ80K_IDX 0 // 000
|
||||
#define MZ80C_IDX 1 // 001
|
||||
#define MZ1200_IDX 2 // 010
|
||||
#define MZ80A_IDX 3 // 011
|
||||
#define MZ700_IDX 4 // 100
|
||||
#define MZ800_IDX 5 // 101
|
||||
#define MZ80B_IDX 6 // 110
|
||||
#define MZ2000_IDX 7 // 111
|
||||
|
||||
// Keyboard control bits.
|
||||
//
|
||||
#define KEY_BREAK_BIT 0x80 // Break key is being pressed when set to 1
|
||||
#define KEY_CTRL_BIT 0x40 // CTRL key is being pressed when set to 1
|
||||
#define KEY_SHIFT_BIT 0x20 // SHIFT key is being pressed when set to 1
|
||||
#define KEY_DOWN_BIT 0x02 // DATA key has been pressed when set to 1
|
||||
#define KEY_UP_BIT 0x01 // DATA key has been released when set to 1
|
||||
|
||||
// Sharp MZ Series Emulator constants.
|
||||
//
|
||||
#define MZ_EMU_ROM_ADDR 0x100000 // Sharp MZ Series Emulation ROM address.
|
||||
#define MZ_EMU_RAM_ADDR 0x120000 // Sharp MZ Series Emulation RAM address.
|
||||
#define MZ_EMU_REG_BASE_ADDR 0x300000 // Base address, in the FPGA address domain, of the emulator registers.
|
||||
#define MZ_EMU_REG_INTR_ADDR 0x300020 // Base address of the interrupt generator.
|
||||
#define MZ_EMU_REG_KEYB_ADDR 0x300200 // Base address of the keyboard register and map table.
|
||||
#define MZ_EMU_CMT_HDR_ADDR 0x340000 // Header RAM - 128 bytes 0x340000:0x34FFFF
|
||||
#define MZ_EMU_CMT_DATA_ADDR 0x350000 // Data RAM - 64KBytes. 0x350000:0x35FFFF
|
||||
#define MZ_EMU_CMT_MAP_ADDR 0x360000 // ASCII MAP RAM - 512 bytes 0x360000:0x36FFFF
|
||||
#define MZ_EMU_REG_MODEL 0 // Machine MODEL configuration register.
|
||||
#define MZ_EMU_REG_DISPLAY 1 // DISPLAY configuration register 1.
|
||||
#define MZ_EMU_REG_DISPLAY2 2 // DISPLAY configuration register 2.
|
||||
#define MZ_EMU_REG_DISPLAY3 3 // DISPLAY configuration register 3.
|
||||
#define MZ_EMU_REG_CPU 4 // CPU configuration register.
|
||||
#define MZ_EMU_REG_AUDIO 5 // AUDIO configuration register.
|
||||
#define MZ_EMU_REG_CMT 6 // CMT (tape drive) configuration register.
|
||||
#define MZ_EMU_REG_CMT2 7 // CMT (tape drive) apss status register.
|
||||
#define MZ_EMU_REG_CMT3 8 // CMT (tape drive) status register.
|
||||
#define MZ_EMU_REG_USERROM 9 // USER ROM selection register (not currently used.)
|
||||
#define MZ_EMU_REG_FDCROM 10 // Floppy Disk ROM selection register.
|
||||
#define MZ_EMU_REG_SETUP 13 // Emulator current setup (configuration) register.
|
||||
#define MZ_EMU_MAX_REGISTERS 16 // Maximum number of registers on the emulator.
|
||||
#define MZ_EMU_ADDR_REG_MODEL MZ_EMU_REG_BASE_ADDR + 0 // Address of the machine MODEL configuration register.
|
||||
#define MZ_EMU_ADDR_REG_DISPLAY MZ_EMU_REG_BASE_ADDR + 1 // Address of the DISPLAY configuration register 1.
|
||||
#define MZ_EMU_ADDR_REG_DISPLAY2 MZ_EMU_REG_BASE_ADDR + 2 // Address of the DISPLAY configuration register 2.
|
||||
#define MZ_EMU_ADDR_REG_DISPLAY3 MZ_EMU_REG_BASE_ADDR + 3 // Address of the DISPLAY configuration register 3.
|
||||
#define MZ_EMU_ADDR_REG_CPU MZ_EMU_REG_BASE_ADDR + 4 // Address of the CPU configuration register.
|
||||
#define MZ_EMU_ADDR_REG_AUDIO MZ_EMU_REG_BASE_ADDR + 5 // Address of the AUDIO configuration register.
|
||||
#define MZ_EMU_ADDR_REG_CMT MZ_EMU_REG_BASE_ADDR + 6 // Address of the CMT (tape drive) configuration register.
|
||||
#define MZ_EMU_ADDR_REG_CMT2 MZ_EMU_REG_BASE_ADDR + 7 // Address of the CMT (tape drive) apss register.
|
||||
#define MZ_EMU_ADDR_REG_CMT3 MZ_EMU_REG_BASE_ADDR + 8 // Address of the CMT (tape drive) status register.
|
||||
#define MZ_EMU_ADDR_REG_USERROM MZ_EMU_REG_BASE_ADDR + 9 // Address of the USER ROM selection register (not currently used.).
|
||||
#define MZ_EMU_ADDR_REG_FDCROM MZ_EMU_REG_BASE_ADDR + 10 // Address of the Floppy Disk ROM selection register.
|
||||
#define MZ_EMU_ADDR_REG_SETUP MZ_EMU_REG_BASE_ADDR + 13 // Address of the emulator current setup (configuration) register.
|
||||
#define MZ_EMU_INTR_ISR 0x00 // Interupt service reason register, define what caused the interupt.
|
||||
#define MZ_EMU_INTR_MAX_REGISTERS 1 // Maximum number of registers in the interrupt generator.
|
||||
#define MZ_EMU_KEYB_MAX_REGISTERS 37 // Maximum number of registers in the keyboard interface.
|
||||
#define MZ_EMU_KEYB_KEY_MATRIX 0x00 // Key matrix array current scan.
|
||||
#define MZ_EMU_KEYB_KEY_MATRIX_LAST 0x10 // Key matrix array previous scan.
|
||||
#define MZ_EMU_KEYB_CTRL_REG 0x20 // Keyboard control register.
|
||||
#define MZ_EMU_KEYB_KEYD_REG 0x21 // Keyboard key data register.
|
||||
#define MZ_EMU_KEYB_KEYC_REG 0x22 // Keyboard control data register.
|
||||
#define MZ_EMU_KEYB_KEY_POS_REG 0x23 // Keyboard mapped character mapping position.
|
||||
#define MZ_EMU_KEYB_KEY_POS_LAST_REG 0x24 // Keyboard mapped character previous mapping position.
|
||||
#define MZ_EMU_KEYB_MAP_ADDR 0x100 // Address offset to the scan code:key map array.
|
||||
#define MZ_EMU_KEYB_DISABLE_EMU 0x01 // Disable keyboard scan codes being sent to the emulation.
|
||||
#define MZ_EMU_KEYB_ENABLE_INTR 0x02 // Enable interrupt on every key press.
|
||||
|
||||
#define MZ_EMU_DISPLAY_MONO 0x00 // Monochrome display.
|
||||
#define MZ_EMU_DISPLAY_MONO80 0x01 // Monochrome 80 column display.
|
||||
#define MZ_EMU_DISPLAY_COLOUR 0x02 // Colour display.
|
||||
#define MZ_EMU_DISPLAY_COLOUR80 0x03 // Colour 80 column display.
|
||||
#define MZ_EMU_DISPLAY_VRAM_ON 0x00 // Video RAM enable.
|
||||
#define MZ_EMU_DISPLAY_VRAM_OFF 0x04 // Video RAM disable.
|
||||
#define MZ_EMU_DISPLAY_GRAM_ON 0x00 // Graphics RAM enable.
|
||||
#define MZ_EMU_DISPLAY_GRAM_OFF 0x08 // Graphics RAM disable.
|
||||
#define MZ_EMU_DISPLAY_VIDWAIT_ON 0x10 // Enable Video Wait States
|
||||
#define MZ_EMU_DISPLAY_VIDWAIT_OFF 0x00 // Disable Video Wait States
|
||||
#define MZ_EMU_DISPLAY_PCG_ON 0x80 // Enable the Programmable Character Generator.
|
||||
#define MZ_EMU_DISPLAY_PCG_OFF 0x00 // Disable the Programmable Character Generator.
|
||||
#define MZ_EMU_B_CPU_SPEED_4M 0x00 // CPU Freq for the MZ80B group machines.
|
||||
#define MZ_EMU_B_CPU_SPEED_8M 0x01 // CPU Freq for the MZ80B group machines.
|
||||
#define MZ_EMU_B_CPU_SPEED_16M 0x02 // CPU Freq for the MZ80B group machines.
|
||||
#define MZ_EMU_B_CPU_SPEED_32M 0x03 // CPU Freq for the MZ80B group machines.
|
||||
#define MZ_EMU_B_CPU_SPEED_64M 0x04 // CPU Freq for the MZ80B group machines.
|
||||
#define MZ_EMU_C_CPU_SPEED_2M 0x00 // CPU Freq for the MZ80C group machines.
|
||||
#define MZ_EMU_C_CPU_SPEED_4M 0x01 // CPU Freq for the MZ80C group machines.
|
||||
#define MZ_EMU_C_CPU_SPEED_8M 0x02 // CPU Freq for the MZ80C group machines.
|
||||
#define MZ_EMU_C_CPU_SPEED_16M 0x03 // CPU Freq for the MZ80C group machines.
|
||||
#define MZ_EMU_C_CPU_SPEED_32M 0x04 // CPU Freq for the MZ80C group machines.
|
||||
#define MZ_EMU_C_CPU_SPEED_64M 0x05 // CPU Freq for the MZ80C group machines.
|
||||
#define MZ_EMU_78_CPU_SPEED_3M5 0x00 // CPU Freq for the MZ80/700/800 group machines.
|
||||
#define MZ_EMU_78_CPU_SPEED_7M 0x01 // CPU Freq for the MZ80/700/800 group machines.
|
||||
#define MZ_EMU_78_CPU_SPEED_14M 0x02 // CPU Freq for the MZ80/700/800 group machines.
|
||||
#define MZ_EMU_78_CPU_SPEED_28M 0x03 // CPU Freq for the MZ80/700/800 group machines.
|
||||
#define MZ_EMU_78_CPU_SPEED_56M 0x04 // CPU Freq for the MZ80/700/800 group machines.
|
||||
#define MZ_EMU_78_CPU_SPEED_112M 0x05 // CPU Freq for the MZ80/700/800 group machines.
|
||||
#define MZ_EMU_CMT_SPEED_NORMAL 0x00 // CMT runs at normal speed for the selected model.
|
||||
#define MZ_EMU_CMT_SPEED_2X 0x01 // CMT runs at 2x speed.
|
||||
#define MZ_EMU_CMT_SPEED_4X 0x02 // CMT runs at 4x speed.
|
||||
#define MZ_EMU_CMT_SPEED_8X 0x03 // CMT runs at 8x speed.
|
||||
#define MZ_EMU_CMT_SPEED_16X 0x04 // CMT runs at 16x speed.
|
||||
#define MZ_EMU_CMT_SPEED_32X 0x05 // CMT runs at 32x speed.
|
||||
#define MZ_EMU_CMT_BUTTON_OFF 0x00 // CMT keys are off.
|
||||
#define MZ_EMU_CMT_BUTTON_PLAY 0x08 // CMT PLAY button is pressed.
|
||||
#define MZ_EMU_CMT_BUTTON_RECORD 0x10 // CMT RECORD button is pressed.
|
||||
#define MZ_EMU_CMT_BUTTON_AUTO 0x18 // CMT auto logic enabled to select button according to state.
|
||||
#define MZ_EMU_CMT_ASCIIIN 0x20 // Enable ASCII translation of filenames going into the CMT.
|
||||
#define MZ_EMU_CMT_ASCIIOUT 0x40 // Enable ASCII translation of filenames output by the CMT.
|
||||
#define MZ_EMU_CMT_HARDWARE 0x80 // Enable use of the physical host cassette drive instead of the CMT emulation.
|
||||
// Tape(CMT) Register bits.
|
||||
//
|
||||
#define MZ_EMU_CMT_PLAY_READY 0x01 // Tape drive ready for playback.
|
||||
#define MZ_EMU_CMT_PLAYING 0x02 // Tape drive playing tape.
|
||||
#define MZ_EMU_CMT_RECORD_READY 0x04 // Tape drive ready for record.
|
||||
#define MZ_EMU_CMT_RECORDING 0x08 // Tape drive recording.
|
||||
#define MZ_EMU_CMT_ACTIVE 0x10 // Tape drive is active and ready.
|
||||
#define MZ_EMU_CMT_SENSE 0x20 // Tape drive SENSE, indicates if buttons depressed and motor on.
|
||||
#define MZ_EMU_CMT_WRITEBIT 0x40 // CMT unit write head bit. Data on this bit reflects what is sent to the tape write head.
|
||||
#define MZ_EMU_CMT2_APSS 0x01 // APSS CMT APSS select.
|
||||
#define MZ_EMU_CMT2_DIRECTION 0x02 // APSS CMT APSS direction.
|
||||
#define MZ_EMU_CMT2_EJECT 0x04 // APSS CMT EJECT tape.
|
||||
#define MZ_EMU_CMT2_PLAY 0x08 // APSS CMT PLAY tape.
|
||||
#define MZ_EMU_CMT2_STOP 0x10 // APSS CMT STOP tape.
|
||||
|
||||
|
||||
// Menu selection types.
|
||||
enum MENUTYPES {
|
||||
MENUTYPE_SUBMENU = 0x01, // Item selects a sub-menu.
|
||||
MENUTYPE_CHOICE = 0x02, // Item selects a choice.
|
||||
MENUTYPE_ACTION = 0x04, // Item directly select a function/action.
|
||||
MENUTYPE_BLANK = 0x08, // Blank filler menu line.
|
||||
MENUTYPE_TEXT = 0x10 // Static text line.
|
||||
};
|
||||
|
||||
// Menu item states.
|
||||
enum MENUSTATE {
|
||||
MENUSTATE_ACTIVE = 0x00, // Menu item is active and visible.
|
||||
MENUSTATE_HIDDEN = 0x01, // Menu item is active but not visible on the menu.
|
||||
MENUSTATE_GREYED = 0x02, // Menu item is inactive, visible but greyed out.
|
||||
MENUSTATE_BLANK = 0x03, // Menu item is visible but has no content.
|
||||
MENUSTATE_TEXT = 0x04 // Menu item is visible text for display only
|
||||
};
|
||||
|
||||
// Modes of menu display interaction.
|
||||
//
|
||||
enum MENUMODE {
|
||||
MENU_NORMAL = 0x00, // Menu type is normal, stops at item 0 and last item.
|
||||
MENU_WRAP = 0x01 // Menu wraps, first item wraps to last, last to first.
|
||||
};
|
||||
|
||||
enum MENUACTIVE {
|
||||
MENU_DISABLED = 0x00, // Menu is disabled and not being displayed.
|
||||
MENU_MAIN = 0x01, // Main menu is active.
|
||||
MENU_STORAGE = 0x02, // Storage menu is active.
|
||||
MENU_MACHINE = 0x03, // Machine menu is active.
|
||||
MENU_DISPLAY = 0x04, // Display menu is active.
|
||||
MENU_SYSTEM = 0x05, // System menu is active.
|
||||
MENU_ROMMANAGEMENT = 0x06 // Rom Management menu is active.
|
||||
};
|
||||
|
||||
enum MENUCALLBACK {
|
||||
MENUCB_DONOTHING = 0x00, // After callback return continue, no additional processing.
|
||||
MENUCB_REFRESH = 0x01, // After callback, refresh OSD.
|
||||
};
|
||||
|
||||
enum DIALOGTYPE {
|
||||
DIALOG_MENU = 0x00, // OSD is displaying the Menu system.
|
||||
DIALOG_FILELIST = 0x01, // OSD is displaying a file list selection screen.
|
||||
};
|
||||
|
||||
enum ACTIONMODE {
|
||||
ACTION_DEFAULT = 0x00, // Action callback executes default actions.
|
||||
ACTION_SELECT = 0x01, // Action callback executes the selection action.
|
||||
ACTION_TOGGLECHOICE = 0x02, // Action callback implements toggle feature.
|
||||
};
|
||||
|
||||
|
||||
// Declare the menu callback as a type. This callback is used when a menu item such as submenu is activated.
|
||||
typedef void (*t_menuCallback)(uint8_t);
|
||||
|
||||
// Declare the choice callback as a type. This callback is used when rendering the menu and the choice value needs to be realised from the config settings.
|
||||
typedef const char * (*t_choiceCallback)(void);
|
||||
|
||||
// Declare the return from dialog callback which is required to process data from a non-menu dialog such as a file list.
|
||||
typedef void (*t_dialogCallback)(char *param);
|
||||
|
||||
// Structure to contain a menu item and its properties.
|
||||
//
|
||||
typedef struct {
|
||||
char text[MENU_ROW_WIDTH]; // Buffers to store menu item text.
|
||||
enum MENUTYPES type; // Type of menu option, sub-menu select or choice.
|
||||
enum MENUSTATE state; // State of the menu item, ie. hidden, greyed, active.
|
||||
t_menuCallback menuCallback; // Function to call when a line is activated, by CR or toggle.
|
||||
t_choiceCallback choiceCallback; // Function to call when a choice value is required.
|
||||
enum MENUCALLBACK cbAction; // Action to take after callback completed.
|
||||
} t_menuItem;
|
||||
|
||||
// Structure to maintain menu control and data elements.
|
||||
//
|
||||
typedef struct {
|
||||
uint16_t rowPixelStart; // Y pixel where row output commences.
|
||||
uint16_t colPixelStart; // X pixel where column output commences.
|
||||
uint16_t rowPixelDepth; // Depth of Y pixels for each row element.
|
||||
uint16_t colPixelsEnd; // X pixels from screen end where column output ends.
|
||||
uint8_t padding; // Inter row padding.
|
||||
enum COLOUR inactiveFgColour; // Foreground colour of an inactive (not selected) row item.
|
||||
enum COLOUR inactiveBgColour; // Background colour of an inactive (not selected) row item.
|
||||
enum COLOUR greyedFgColour; // Foreground colour of an inactive (not selected) row item.
|
||||
enum COLOUR greyedBgColour; // Background colour of an inactive (not selected) row item.
|
||||
enum COLOUR textFgColour; // Foreground colour of read only text on a row.
|
||||
enum COLOUR textBgColour; // Background colour of read only text on a row.
|
||||
enum COLOUR activeFgColour; // Active (selected) foreground colour of row item.
|
||||
enum COLOUR activeBgColour; // Active (selected) background colour of row item.
|
||||
enum FONTS font; // Font as a type, used in OSD calls.
|
||||
const fontStruct *rowFontptr; // General font used by menu row items.
|
||||
int16_t activeRow; // Active (selected) row. -1 = no selection.
|
||||
t_menuItem *data[MAX_MENU_ROWS]; // Details of a row's data to be displayed such as text.
|
||||
} t_menu;
|
||||
|
||||
typedef struct {
|
||||
char *name;
|
||||
uint8_t isDir;
|
||||
} t_dirEntry;
|
||||
|
||||
// Structure to hold and manipulate a list of files and directories which are required when the user is requested to select a file.
|
||||
//
|
||||
typedef struct {
|
||||
uint16_t rowPixelStart; // Y pixel where row output commences.
|
||||
uint16_t colPixelStart; // X pixel where column output commences.
|
||||
uint16_t rowPixelDepth; // Depth of Y pixels for each row element.
|
||||
uint16_t colPixelsEnd; // X pixels from screen end where column output ends.
|
||||
uint8_t padding; // Inter row padding.
|
||||
enum COLOUR inactiveFgColour; // Foreground colour of an inactive (not selected) row item.
|
||||
enum COLOUR inactiveBgColour; // Background colour of an inactive (not selected) row item.
|
||||
enum COLOUR activeFgColour; // Active (selected) foreground colour of row item.
|
||||
enum COLOUR activeBgColour; // Active (selected) background colour of row item.
|
||||
enum FONTS font; // Font as a type, used in OSD calls.
|
||||
const fontStruct *rowFontptr; // General font used by file list row items.
|
||||
int16_t activeRow; // Active (selected) row. -1 = no selection.
|
||||
t_dirEntry dirEntries[MAX_DIRENTRY]; // Scanned directory entries and their properties.
|
||||
uint8_t selectDir; // Flag to indicate if selection is on a path rather than file.
|
||||
t_dialogCallback returnCallback; // A callback activated when a file is selected and control is returned to the Menu state.
|
||||
char fileFilter[MAX_FILTER_LEN]; // Active filter applied to a directory contents read.
|
||||
} t_fileList;
|
||||
|
||||
// Structure to store the name, load address and the size of a given rom.
|
||||
//
|
||||
typedef struct
|
||||
{
|
||||
char romFileName[MAX_FILENAME_LEN];
|
||||
uint8_t romEnabled;
|
||||
uint32_t loadAddr;
|
||||
uint32_t loadSize;
|
||||
} romData_t;
|
||||
|
||||
// MZ Series Tape header structure - 128 bytes.
|
||||
//
|
||||
typedef struct
|
||||
{
|
||||
unsigned char dataType; // 01 = machine code program.
|
||||
// 02 MZ-80 Basic program.
|
||||
// 03 MZ-80 data file.
|
||||
// 04 MZ-700 data file.
|
||||
// 05 MZ-700 Basic program.
|
||||
char fileName[17]; // File name.
|
||||
unsigned short fileSize; // Size of data partition.
|
||||
unsigned short loadAddress; // Load address of the program/data.
|
||||
unsigned short execAddress; // Execution address of program.
|
||||
unsigned char comment[104]; // Free text or code area.
|
||||
} t_tapeHeader;
|
||||
|
||||
// Structures to store the tape file queue.
|
||||
//
|
||||
typedef struct
|
||||
{
|
||||
char *queue[MAX_TAPE_QUEUE];
|
||||
char fileName[MAX_FILENAME_LEN];
|
||||
uint16_t tapePos;
|
||||
uint16_t elements;
|
||||
} t_tapeQueue;
|
||||
|
||||
// Structure to maintain individual emulation configuration parameters.
|
||||
typedef struct {
|
||||
uint8_t cpuSpeed;
|
||||
uint8_t audioSource;
|
||||
uint8_t audioVolume;
|
||||
uint8_t audioMute;
|
||||
uint8_t displayType;
|
||||
uint8_t displayOutput;
|
||||
uint8_t vramMode;
|
||||
uint8_t gramMode;
|
||||
uint8_t vramWaitMode;
|
||||
uint8_t pcgMode;
|
||||
uint8_t aspectRatio;
|
||||
uint8_t scanDoublerFX;
|
||||
uint8_t loadDirectFilter;
|
||||
uint8_t queueTapeFilter;
|
||||
uint8_t cmtMode; // CMT Mode, physical CMT = 0, FPGA CMT = 1
|
||||
uint8_t tapeAutoSave;
|
||||
uint8_t tapeButtons;
|
||||
uint8_t fastTapeLoad;
|
||||
uint8_t cmtAsciiMapping; // Enable Sharp<->ASCII name conversion during Record/Play operations.
|
||||
char tapeSavePath[MAX_FILENAME_LEN]; // Path where saved files should be stored.
|
||||
romData_t romMonitor40; // Details of 40x25 rom monitor image to upload.
|
||||
romData_t romMonitor80; // Details of 80x25 rom monitor image to upload.
|
||||
romData_t romCG; // Details of rom character generator images to upload.
|
||||
romData_t romKeyMap; // Details of rom Key mapping images to upload.
|
||||
romData_t romUser; // Details of User ROM images to upload.
|
||||
romData_t romFDC; // Details of FDC ROM images to upload.
|
||||
} t_emuMachineConfig;
|
||||
|
||||
// Structure to maintain the emulator configuration which is intended to mirror the physical hardware configuration.
|
||||
typedef struct {
|
||||
uint8_t machineModel; // Current emulated model.
|
||||
uint8_t machineChanged; // Flag to indicate the base machine has changed.
|
||||
t_emuMachineConfig *resetParams; // Copy of the default parameters.
|
||||
t_emuMachineConfig params[MAX_MZMACHINES]; // Working set of parameters.
|
||||
uint8_t emuRegisters[MZ_EMU_MAX_REGISTERS]; // Mirror of the emulator register contents for local manipulation prior to sync.
|
||||
} t_emuConfig;
|
||||
|
||||
// Structure for traversing and maintaining a set of active windows as selected by a user.
|
||||
typedef struct {
|
||||
enum MENUACTIVE menu[MAX_MENU_DEPTH]; // Flag and menu state to indicate the OSD Menu is being displayed, the active menu and history.
|
||||
uint8_t activeRow[MAX_MENU_DEPTH]; // Last active row in a given menu.
|
||||
uint8_t menuIdx; // Menu ptr to current menu.
|
||||
} t_activeMenu;
|
||||
|
||||
// Structure for traversing and maintaining as set of directory/sub-directories.
|
||||
typedef struct {
|
||||
char *dir[MAX_DIR_DEPTH]; // Entered directory list during user file selection.
|
||||
uint8_t activeRow[MAX_DIR_DEPTH]; // Last active row in a given directory.
|
||||
uint8_t dirIdx; // Ptr to current active directory in file selection.
|
||||
} t_activeDir;
|
||||
|
||||
// Structure to maintain Sharp MZ Series Emulation control and data.
|
||||
//
|
||||
typedef struct {
|
||||
uint8_t active; // An emulation is active in the FPGA.
|
||||
enum DIALOGTYPE activeDialog; // Active dialog on the OSD.
|
||||
t_activeMenu activeMenu; // Active menu tree.
|
||||
t_activeDir activeDir; // Active directory tree.
|
||||
uint8_t debug; // Debug the emuMZ module by outputting log information if set.
|
||||
t_menu menu; // Menu control and data.
|
||||
t_fileList fileList; // List of files for perusal and selection during OSD interaction.
|
||||
t_tapeQueue tapeQueue; // Linked list of files which together form a virtual tape.
|
||||
} t_emuControl;
|
||||
|
||||
// Application execution constants.
|
||||
//
|
||||
|
||||
// Lookup tables for menu entries.
|
||||
//
|
||||
const char *MZMACHINES[MAX_MZMACHINES] = { "MZ-80K", "MZ-80C", "MZ1200", "MZ-80A", "MZ-700", "MZ-800", "MZ-80B", "MZ2000" };
|
||||
const char *SHARPMZ_FAST_TAPE[] = { "Off", "2x", "4x", "8x", "16x", "32x", "Off", "Off",
|
||||
"Off", "2x", "4x", "8x", "16x", "32x", "Off", "Off",
|
||||
"Off", "2x", "4x", "8x", "16x", "Off", "Off", "Off"
|
||||
};
|
||||
const char *SHARPMZ_CPU_SPEED[] = { "2MHz", "4MHz", "8MHz", "16MHz", "32MHz", "64MHz", "2MHz", "2MHz",
|
||||
"3.5MHz", "7MHz", "14MHz", "28MHz", "56MHz", "3.5MHz", "3.5MHz", "3.5MHz",
|
||||
"4MHz", "8MHz", "16MHz", "32MHz", "64MHz", "4MHz", "4MHz", "4MHz"
|
||||
};
|
||||
const char *SHARPMZ_TAPE_MODE[] = { "FPGA", "MZ-700" };
|
||||
const char *SHARPMZ_TAPE_BUTTONS[] = { "Off", "Play", "Record", "Auto" };
|
||||
const char *SHARPMZ_ASCII_MAPPING[] = { "Off", "Record", "Play", "Both" };
|
||||
const char *SHARPMZ_AUDIO_SOURCE[] = { "Sound", "Tape" };
|
||||
const char *SHARPMZ_AUDIO_VOLUME[] = { "Max", "14", "13", "12", "11", "10", "9", "8", "7", "6", "5", "4", "3", "2", "1", "Min" };
|
||||
const char *SHARPMZ_AUDIO_MUTE[] = { "Off", "Mute" };
|
||||
const char *SHARPMZ_USERROM_ENABLED[] = { "Disabled", "Enabled" };
|
||||
const char *SHARPMZ_FDCROM_ENABLED[] = { "Disabled", "Enabled" };
|
||||
const char *SHARPMZ_ROM_ENABLED[] = { "Disabled", "Enabled" };
|
||||
const char *SHARPMZ_DISPLAY_TYPE[] = { "Mono 40x25", "Mono 80x25 ", "Colour 40x25", "Colour 80x25" };
|
||||
const char *SHARPMZ_DISPLAY_OUTPUT[] = { "Original", "640x480@60Hz", "1024x768@60Hz", "800x600@60Hz" };
|
||||
|
||||
const char *SHARPMZ_ASPECT_RATIO[] = { "4:3", "16:9" };
|
||||
const char *SHARPMZ_SCANDOUBLER_FX[] = { "None", "HQ2x", "CRT 25%", "CRT 50%", "CRT 75%" };
|
||||
const char *SHARPMZ_VRAMWAIT_MODE[] = { "Off", "On" };
|
||||
const char *SHARPMZ_VRAMDISABLE_MODE[] = { "Enabled", "Disabled" };
|
||||
const char *SHARPMZ_GRAMDISABLE_MODE[] = { "Enabled", "Disabled" };
|
||||
const char *SHARPMZ_GRAM_BASEADDR[] = { "0x00", "0x08", "0x10", "0x18", "0x20", "0x28", "0x30", "0x38", "0x40", "0x48", "0x50", "0x58", "0x60", "0x68", "0x70", "0x78",
|
||||
"0x80", "0x88", "0x90", "0x98", "0xA0", "0xA8", "0xB0", "0xB8", "0xC0", "0xC8", "0xD0", "0xD8", "0xE0", "0xE8", "0xF0", "0xF8" };
|
||||
const char *SHARPMZ_PCG_MODE[] = { "Off", "ROM", "RAM" };
|
||||
const char *SHARPMZ_TAPE_AUTO_SAVE[] = { "Disabled", "Enabled" };
|
||||
const char *SHARPMZ_DEBUG_ENABLE[] = { "Off", "On" };
|
||||
const char *SHARPMZ_DEBUG_LEDS[] = { "Off", "On" };
|
||||
const char *SHARPMZ_DEBUG_LEDS_BANK[] = { "T80", "I/O", "IOCTL", "Config", "MZ80C I", "MZ80C II", "MZ80B I", "MZ80B II" };
|
||||
const char *SHARPMZ_DEBUG_LEDS_SUBBANK[] = { "Auto", "A7-0", "A15-8", "DI", "Signals", "", "", "",
|
||||
"Auto", "Video", "PS2Key", "Signals", "CMT 1", "CMT 2", "CMT 3", "CMT 4",
|
||||
"Auto", "A23-16", "A15-8", "A7-0", "Signals", "", "", "",
|
||||
"Auto", "Config 1", "Config 2", "Config 3", "Config 4", "Config 5", "", "",
|
||||
"Auto", "CS 1", "CS 2", "CS 3", "INT/RE", "Clk", "", "",
|
||||
"Auto", "", "", "", "", "", "", "",
|
||||
"Auto", "CS 1", "CS 2", "MEM EN", "INT", "KEYB", "PPIA", "PPIB",
|
||||
"Auto", "PPIC", "", "", "", "", "", "",
|
||||
};
|
||||
const char *SHARPMZ_DEBUG_CPUFREQ[] = { "Normal", "1MHz", "100KHz", "10KHz", "5KHz", "1KHz", "500Hz", "100Hz", "50Hz", "10Hz", "5Hz", "2Hz", "1Hz", "0.5Hz", "0.2Hz", "0.1Hz" };
|
||||
const char *SHARPMZ_DEBUG_LEDS_SMPFREQ[] = { "CPU", "1MHz", "100KHz", "10KHz", "5KHz", "1KHz", "500Hz", "100Hz", "50Hz", "10Hz", "5Hz", "2Hz", "1Hz", "0.5Hz", "0.2Hz", "0.1Hz" };
|
||||
const char *SHARPMZ_MEMORY_BANK[] = { "SysROM", "SysRAM", "KeyMap", "VRAM", "CMTHDR", "CMTDATA", "CGROM", "CGRAM", "All" };
|
||||
const char *SHARPMZ_MEMORY_BANK_FILE[] = { "sysrom.dump", "sysram.dump", "keymap.dump", "vram.dump", "cmt_hdr.dump", "cmt_data.dump", "cgrom.dump", "cgram.dump", "all_memory.dump" };
|
||||
const char *SHARPMZ_TAPE_TYPE[] = { "N/A", "M/code", "MZ80 Basic", "MZ80 Data", "MZ700 Data", "MZ700 Basic", "N/A" };
|
||||
const char *SHARPMZ_HELPTEXT[] = { "Welcome to the Sharp MZ Series! Use the cursor keys to navigate the menus. Use space bar or enter to select an item. Press Esc or F12 to exit the menus. ",
|
||||
0
|
||||
};
|
||||
const char *SHARPMZ_FILE_FILTERS[] = { "*.MZF", "*.MTI", "*.MZT", "*.*" };
|
||||
|
||||
|
||||
// Prototypes.
|
||||
//
|
||||
void EMZReleaseMenuMemory(void);
|
||||
void EMZReleaseDirMemory(void);
|
||||
void EMZSetupMenu(char *, char *, enum FONTS);
|
||||
void EMZSetupDirList(char *, char *, enum FONTS);
|
||||
void EMZAddToMenu(uint8_t, uint8_t, char *, enum MENUTYPES, enum MENUSTATE, t_menuCallback, enum MENUCALLBACK, t_choiceCallback);
|
||||
int16_t EMZDrawMenu(int16_t, uint8_t, enum MENUMODE);
|
||||
void EMZRefreshMenu(void);
|
||||
void EMZRefreshFileList(void);
|
||||
void EMZMainMenu(void);
|
||||
void EMZTapeStorageMenu(enum ACTIONMODE);
|
||||
void EMZMachineMenu(enum ACTIONMODE);
|
||||
void EMZDisplayMenu(enum ACTIONMODE);
|
||||
void EMZSystemMenu(enum ACTIONMODE);
|
||||
void EMZAbout(enum ACTIONMODE);
|
||||
void EMZRomManagementMenu(enum ACTIONMODE);
|
||||
void EMZSwitchToMenu(int8_t);
|
||||
void EMZProcessMenuKey(uint8_t, uint8_t);
|
||||
void EMZservice(uint8_t);
|
||||
int EMZFileSave(const char *, void *, int);
|
||||
int EMZFileLoad(const char *, void *, int);
|
||||
void EMZReadConfig(enum ACTIONMODE);
|
||||
void EMZWriteConfig(enum ACTIONMODE);
|
||||
void EMZResetConfig(enum ACTIONMODE);
|
||||
void EMZLoadConfig(void);
|
||||
void EMZSaveConfig(void);
|
||||
void EMZSwitchToMachine(uint8_t, uint8_t);
|
||||
void EMZGetFileListBoundaries(int16_t *, int16_t *, int16_t *);
|
||||
uint16_t EMZGetFileListColumnWidth(void);
|
||||
int16_t EMZDrawFileList(int16_t, uint8_t);
|
||||
uint8_t EMZReadDirectory(const char *, const char *);
|
||||
void EMZGetFile(void);
|
||||
void EMZReset(unsigned long, unsigned long);
|
||||
uint8_t EMZInit(uint8_t);
|
||||
|
||||
void EMZLoadDirectToRAM(enum ACTIONMODE);
|
||||
void EMZLoadDirectToRAMSet(char *);
|
||||
void EMZQueueTape(enum ACTIONMODE);
|
||||
void EMZQueueTapeSet(char *);
|
||||
void EMZTapeSave(enum ACTIONMODE);
|
||||
void EMZTapeSaveSet(char *);
|
||||
void EMZMonitorROM40(enum ACTIONMODE);
|
||||
void EMZMonitorROM40Set(char *);
|
||||
void EMZMonitorROM80(enum ACTIONMODE);
|
||||
void EMZMonitorROM80Set(char *);
|
||||
void EMZCGROM(enum ACTIONMODE);
|
||||
void EMZCGROMSet(char *);
|
||||
void EMZKeyMappingROM(enum ACTIONMODE);
|
||||
void EMZKeyMappingROMSet(char *);
|
||||
void EMZUserROM(enum ACTIONMODE);
|
||||
void EMZUserROMSet(char *);
|
||||
void EMZFloppyDiskROM(enum ACTIONMODE);
|
||||
void EMZFloppyDiskROMSet(char *);
|
||||
|
||||
void EMZTapeQueuePushFile(char *);
|
||||
char *EMZTapeQueuePopFile(void);
|
||||
char *EMZTapeQueueAPSSSearch(char);
|
||||
char *EMZNextTapeQueueFilename(char);
|
||||
void EMZClearTapeQueue(void);
|
||||
void EMZChangeCMTMode(enum ACTIONMODE);
|
||||
short EMZLoadTapeToRAM(const char *, unsigned char);
|
||||
short EMZSaveTapeFromCMT(const char *);
|
||||
|
||||
// Menu choice helper functions, increment to next choice.
|
||||
void EMZNextMachineModel(enum ACTIONMODE);
|
||||
void EMZNextCPUSpeed(enum ACTIONMODE);
|
||||
void EMZNextAudioSource(enum ACTIONMODE);
|
||||
void EMZNextAudioVolume(enum ACTIONMODE);
|
||||
void EMZNextAudioMute(enum ACTIONMODE);
|
||||
|
||||
// Getter/Setter methods!
|
||||
void EMZSetMenuRowPadding(uint8_t);
|
||||
void EMZSetMenuFont(enum FONTS);
|
||||
void EMZSetRowColours(enum COLOUR, enum COLOUR, enum COLOUR, enum COLOUR, enum COLOUR, enum COLOUR, enum COLOUR, enum COLOUR);
|
||||
void EMZGetMenuBoundaries(int16_t *, int16_t *, int16_t *, int16_t *, int16_t *);
|
||||
uint16_t EMZGetMenuColumnWidth(void);
|
||||
|
||||
const char *EMZGetMachineModelChoice(void);
|
||||
char *EMZGetMachineTitle(void);
|
||||
short EMZGetMachineGroup(void);
|
||||
const char *EMZGetMachineModelChoice(void);
|
||||
const char *EMZGetCPUSpeedChoice(void);
|
||||
const char *EMZGetAudioSourceChoice(void);
|
||||
const char *EMZGetAudioVolumeChoice(void);
|
||||
const char *EMZGetAudioMuteChoice(void);
|
||||
const char *EMZGetCMTModeChoice(void);
|
||||
const char *EMZGetDisplayTypeChoice(void);
|
||||
const char *EMZGetDisplayOutputChoice(void);
|
||||
const char *EMZGetVRAMModeChoice(void);
|
||||
const char *EMZGetGRAMModeChoice(void);
|
||||
const char *EMZGetVRAMWaitModeChoice(void);
|
||||
const char *EMZGetPCGModeChoice(void);
|
||||
const char *EMZGetAspectRatioChoice(void);
|
||||
const char *EMZGetScanDoublerFXChoice(void);
|
||||
const char *EMZGetLoadDirectFileFilterChoice(void);
|
||||
const char *EMZGetQueueTapeFileFilterChoice(void);
|
||||
const char *EMZGetTapeAutoSaveChoice(void);
|
||||
const char *EMZGetTapeSaveFilePathChoice(void);
|
||||
const char *EMZGetMonitorROM40Choice(void);
|
||||
const char *EMZGetMonitorROM80Choice(void);
|
||||
const char *EMZGetCGROMChoice(void);
|
||||
const char *EMZGetKeyMappingROMChoice(void);
|
||||
const char *EMZGetUserROMChoice(void);
|
||||
const char *EMZGetFloppyDiskROMChoice(void);
|
||||
|
||||
void EMZNextCMTMode(enum ACTIONMODE);
|
||||
void EMZNextDisplayType(enum ACTIONMODE);
|
||||
void EMZNextDisplayOutput(enum ACTIONMODE);
|
||||
void EMZNextVRAMMode(enum ACTIONMODE);
|
||||
void EMZNextGRAMMode(enum ACTIONMODE);
|
||||
void EMZNextVRAMWaitMode(enum ACTIONMODE);
|
||||
void EMZNextPCGMode(enum ACTIONMODE);
|
||||
void EMZNextAspectRatio(enum ACTIONMODE);
|
||||
void EMZNextScanDoublerFX(enum ACTIONMODE);
|
||||
void EMZNextLoadDirectFileFilter(enum ACTIONMODE);
|
||||
void EMZNextQueueTapeFileFilter(enum ACTIONMODE);
|
||||
void EMZNextTapeAutoSave(enum ACTIONMODE);
|
||||
void EMZNextMonitorROM40(enum ACTIONMODE);
|
||||
void EMZNextMonitorROM80(enum ACTIONMODE);
|
||||
void EMZNextCGROM(enum ACTIONMODE);
|
||||
void EMZNextKeyMappingROM(enum ACTIONMODE);
|
||||
void EMZNextUserROM(enum ACTIONMODE);
|
||||
void EMZNextFloppyDiskROM(enum ACTIONMODE);
|
||||
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif // EMUMZ_H
|
||||
78
include/fonts.h
Executable file
78
include/fonts.h
Executable file
@@ -0,0 +1,78 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Name: fonts.h
|
||||
// Created: May 2021
|
||||
// Version: v1.0
|
||||
// Author(s): Baron Williams, Philip Smart
|
||||
// Description: The Font Library.
|
||||
// This is a font definition and manipulation library, the fonts being based on
|
||||
// Baron Williams (https://github.com/BaronWilliams) font definitions and modified
|
||||
// for use with the Sharp MZ Series OSD./
|
||||
// Credits:
|
||||
// Copyright: (c) 2015 Baron Williams, (c) 2019-2021 Philip Smart <philip.smart@net2net.org>
|
||||
//
|
||||
// History: May 2021 - Initial write of the OSD software.
|
||||
//
|
||||
// Notes: See Makefile to enable/disable conditional components
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// This source file is free software: you can redistribute it and#or modify
|
||||
// it under the terms of the GNU General Public License as published
|
||||
// by the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This source file is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
#ifndef FONTS_H
|
||||
#define FONTS_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// Supported fonts.
|
||||
enum FONTS {
|
||||
FONT_3X6 = 0x00, // 3x6 small font.
|
||||
FONT_5X7 = 0x01, // 5x7 default font.
|
||||
FONT_7X8 = 0x02, // 7X8 large default font.
|
||||
FONT_9X16 = 0x03, // 9X16 large font for titles.
|
||||
FONT_11X16 = 0x04 // 11X16 large font for titles.
|
||||
};
|
||||
|
||||
|
||||
typedef struct fontStruct {
|
||||
uint8_t *bitmap; // The bitmap data to represent the font
|
||||
uint16_t characters; // The number of valid characters in a font
|
||||
uint8_t start; // The first valid character in a font
|
||||
uint8_t end; // The last valid character in a font
|
||||
uint8_t width; // The width of the font in pixels
|
||||
uint8_t height; // The height of the font in pixels
|
||||
uint8_t spacing; // The horizontal spacing required for a font
|
||||
bool bitAlignVertical; // True if the data is stored vertically
|
||||
} fontStruct;
|
||||
|
||||
extern const fontStruct font11x16;
|
||||
extern const fontStruct font3x6;
|
||||
extern const fontStruct font3x6limited;
|
||||
extern const fontStruct font5x7extended;
|
||||
extern const fontStruct font5x7;
|
||||
extern const fontStruct font7x8;
|
||||
extern const fontStruct font7x8extended;
|
||||
extern const fontStruct font9x16;
|
||||
|
||||
|
||||
|
||||
|
||||
// Prototypes.
|
||||
//
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif // FONTS_H
|
||||
543
include/osd.h
Executable file
543
include/osd.h
Executable file
@@ -0,0 +1,543 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Name: osd.h
|
||||
// Created: May 2021
|
||||
// Version: v1.0
|
||||
// Author(s): Philip Smart
|
||||
// Description: The On Screen Display library.
|
||||
// This source file contains the On Screen Display Class definitions and methods.
|
||||
// The OSD is a popup area on the video controller which can be used to display
|
||||
// text/menus and accept user input. Notably this class is intended to be instantiated
|
||||
// inside an I/O processor onboard the FPGA hosting the Sharp MZ Series emulation
|
||||
// and provide a user interface in order to configure/interact with the emulation.
|
||||
// Credits:
|
||||
// Copyright: (c) 2019-2020 Philip Smart <philip.smart@net2net.org>
|
||||
//
|
||||
// History: May 2020 - Initial write of the OSD software.
|
||||
//
|
||||
// Notes: See Makefile to enable/disable conditional components
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// This source file is free software: you can redistribute it and#or modify
|
||||
// it under the terms of the GNU General Public License as published
|
||||
// by the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This source file is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
#ifndef OSD_H
|
||||
#define OSD_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// Video display constants.
|
||||
#define VC_STATUS_MAX_X_PIXELS 640 // Maximum number of X pixels in the Status window.
|
||||
#define VC_STATUS_MAX_Y_PIXELS 80 // Maximum number of Y pixels in the Status window.
|
||||
#define VC_STATUS_RGB_BITS 3 // Number of colour bits in the Status window. (/3 per colour).
|
||||
#define VC_MENU_MAX_X_PIXELS 512 // Maximum number of X pixels in the Menu window.
|
||||
#define VC_MENU_MAX_Y_PIXELS 128 // Maximum number of Y pixels in the Menu window.
|
||||
#define VC_MENU_RGB_BITS 3 // Number of colour bits in the Menu window. (/3 per colour).
|
||||
#define VC_STATUS_BUFFER_SIZE (VC_STATUS_MAX_X_PIXELS * VC_STATUS_MAX_Y_PIXELS) / 8
|
||||
#define VC_MENU_BUFFER_SIZE (VC_MENU_MAX_X_PIXELS * VC_MENU_MAX_Y_PIXELS) / 8
|
||||
#define VC_OSD_X_CORRECTION 1 // Correction factor to be applied to horizontal to compensate for pixel multiplication.
|
||||
#define VC_OSD_Y_CORRECTION 2 // Correction factor to be applied to vertical to compensate for pixel multiplication.
|
||||
|
||||
// Base addresses and sizes within the FPGA/Video Controller.
|
||||
#define VIDEO_BASE_ADDR 0x200000 // Base address of the Video Controller.
|
||||
#define VIDEO_VRAM_BASE_ADDR VIDEO_BASE_ADDR + 0x01D000 // Base address of the character video RAM using direct addressing.
|
||||
#define VIDEO_VRAM_SIZE 0x800 // Size of the video RAM.
|
||||
#define VIDEO_ARAM_BASE_ADDR VIDEO_BASE_ADDR + 0x01D800 // Base address of the character attribute RAM using direct addressing.
|
||||
#define VIDEO_ARAM_SIZE 0x800 // Size of the attribute RAM.
|
||||
#define VIDEO_IO_BASE_ADDR VIDEO_BASE_ADDR + 0x000000
|
||||
#define MZ_EMU_BASE_ADDR 0x300000 // Base address of the Sharp MZ Series Emulator control registers/memory.
|
||||
#define VIDEO_OSD_BLUE_ADDR 0x270000 // Base address of the OSD Menu/Status buffer, Blue colour.
|
||||
#define VIDEO_OSD_RED_ADDR 0x280000 // Base address of the OSD Menu/Status buffer, Red colour.
|
||||
#define VIDEO_OSD_GREEN_ADDR 0x290000 // Base address of the OSD Menu/Status buffer, Green colour.
|
||||
#define VIDEO_OSD_WHITE_ADDR 0x2a0000 // Base address of the OSD Menu/Status buffer, all colours (White).
|
||||
|
||||
// Memory addresses of I/O and Memory mapped I/O in the Video Controller which are mapped to direct memory accessed addresses.
|
||||
//
|
||||
#define VC_8BIT_BASE_ADDR VIDEO_BASE_ADDR + 0x000000
|
||||
#define VC_32BIT_BASE_ADDR VIDEO_BASE_ADDR + 0x000000
|
||||
// 8 Bit access addresses - used for writing, read can only be on a 32bit boundary with lower address lines set to 00. Writing can write upto 4 consecutive addresses if desired.
|
||||
#define VCADDR_8BIT_PALSLCTOFF VC_8BIT_BASE_ADDR + 0xD3 // Set the palette slot Off position to be adjusted.
|
||||
#define VCADDR_8BIT_PALSLCTON VC_8BIT_BASE_ADDR + 0xD4 // Set the palette slot On position to be adjusted.
|
||||
#define VCADDR_8BIT_PALSETRED VC_8BIT_BASE_ADDR + 0xD5 // Set the red palette value according to the PALETTE_PARAM_SEL address.
|
||||
#define VCADDR_8BIT_PALSETGREEN VC_8BIT_BASE_ADDR + 0xD6 // Set the green palette value according to the PALETTE_PARAM_SEL address.
|
||||
#define VCADDR_8BIT_PALSETBLUE VC_8BIT_BASE_ADDR + 0xD7 // Set the blue palette value according to the PALETTE_PARAM_SEL address.
|
||||
#define VCADDR_8BIT_SYSCTRL VC_8BIT_BASE_ADDR + 0xF0 // System board control register. [2:0] - 000 MZ80A Mode, 2MHz CPU/Bus, 001 MZ80B Mode, 4MHz CPU/Bus, 010 MZ700 Mode, 3.54MHz CPU/Bus.
|
||||
#define VCADDR_8BIT_VMBORDER VC_8BIT_BASE_ADDR + 0xF3 // Select VGA Border colour attributes. Bit 2 = Red, 1 = Green, 0 = Blue.
|
||||
#define VCADDR_8BIT_GRAMMODE VC_8BIT_BASE_ADDR + 0xF4 // MZ80B Graphics mode. Bit 0 = 0, Write to Graphics RAM I, Bit 0 = 1, Write to Graphics RAM II. Bit 1 = 1, blend Graphics RAM I output on display, Bit 2 = 1, blend Graphics RAM II output on display.
|
||||
#define VCADDR_8BIT_VMPALETTE VC_8BIT_BASE_ADDR + 0xF5 // Select Palette:
|
||||
// 0xF5 sets the palette. The Video Module supports 4 bit per colour output but there is only enough RAM for 1 bit per colour so the pallette is used to change the colours output.
|
||||
// Bits [7:0] defines the pallete number. This indexes a lookup table which contains the required 4bit output per 1bit input.
|
||||
// GPU:
|
||||
#define VCADDR_8BIT_GPUPARAM VC_8BIT_BASE_ADDR + 0xF6 // 0xF6 set parameters. Store parameters in a long word to be used by the graphics command processor.
|
||||
// The parameter word is 128 bit and each write to the parameter word shifts left by 8 bits and adds the new byte at bits 7:0.
|
||||
#define VCADDR_8BIT_GPUCMD VC_8BIT_BASE_ADDR + 0xF7 // 0xF7 set the graphics processor unit commands.
|
||||
#define VCADDR_8BIT_GPUSTATUS VC_8BIT_BASE_ADDR + 0xF7 // [7;1] - FSM state, [0] - 1 = busy, 0 = idle
|
||||
// Bits [5:0] - 0 = Reset parameters.
|
||||
// 1 = Clear to val. Start Location (16 bit), End Location (16 bit), Red Filter, Green Filter, Blue Filter
|
||||
//
|
||||
#define VCADDR_8BIT_VMCTRL VC_8BIT_BASE_ADDR + 0xF8 // Video Module control register. [2:0] - 000 (default) = MZ80A, 001 = MZ-700, 010 = MZ800, 011 = MZ80B, 100 = MZ80K, 101 = MZ80C, 110 = MZ1200, 111 = MZ2000. [3] = 0 - 40 col, 1 - 80 col.
|
||||
#define VCADDR_8BIT_VMGRMODE VC_8BIT_BASE_ADDR + 0xF9 // Video Module graphics mode. 7/6 = Operator (00=OR,01=AND,10=NAND,11=XOR), 5=GRAM Output Enable, 4 = VRAM Output Enable, 3/2 = Write mode (00=Page 1:Red, 01=Page 2:Green, 10=Page 3:Blue, 11=Indirect), 1/0=Read mode (00=Page 1:Red, 01=Page2:Green, 10=Page 3:Blue, 11=Not used).
|
||||
#define VCADDR_8BIT_VMREDMASK VC_8BIT_BASE_ADDR + 0xFA // Video Module Red bit mask (1 bit = 1 pixel, 8 pixels per byte).
|
||||
#define VCADDR_8BIT_VMGREENMASK VC_8BIT_BASE_ADDR + 0xFB // Video Module Green bit mask (1 bit = 1 pixel, 8 pixels per byte).
|
||||
#define VCADDR_8BIT_VMBLUEMASK VC_8BIT_BASE_ADDR + 0xFC // Video Module Blue bit mask (1 bit = 1 pixel, 8 pixels per byte).
|
||||
#define VCADDR_8BIT_VMPAGE VC_8BIT_BASE_ADDR + 0xFD // Video Module memory page register. [1:0] switches in 1 16Kb page (3 pages) of graphics ram to C000 - FFFF. Bits [1:0] = page, 00 = off, 01 = Red, 10 = Green, 11 = Blue. This overrides all MZ700/MZ80B page switching functions. [7] 0 - normal, 1 - switches in CGROM for upload at D000:DFFF.
|
||||
#define VCADDR_8BIT_KEYPA VC_8BIT_BASE_ADDR + 0xE000 // VideoModule 8255 Port A
|
||||
#define VCADDR_8BIT_KEYPB VC_8BIT_BASE_ADDR + 0xE001 // VideoModule 8255 Port B
|
||||
#define VCADDR_8BIT_KEYPC VC_8BIT_BASE_ADDR + 0xE002 // VideoModule 8255 Port C
|
||||
#define VCADDR_8BIT_KEYPF VC_8BIT_BASE_ADDR + 0xE003 // VideoModule 8255 Mode Control
|
||||
#define VCADDR_8BIT_CSTR VC_8BIT_BASE_ADDR + 0xE002 // VideoModule 8255 Port C
|
||||
#define VCADDR_8BIT_CSTPT VC_8BIT_BASE_ADDR + 0xE003 // VideoModule 8255 Mode Control
|
||||
#define VCADDR_8BIT_CONT0 VC_8BIT_BASE_ADDR + 0xE004 // VideoModule 8253 Counter 0
|
||||
#define VCADDR_8BIT_CONT1 VC_8BIT_BASE_ADDR + 0xE005 // VideoModule 8253 Counter 1
|
||||
#define VCADDR_8BIT_CONT2 VC_8BIT_BASE_ADDR + 0xE006 // VideoModule 8253 Counter 1
|
||||
#define VCADDR_8BIT_CONTF VC_8BIT_BASE_ADDR + 0xE007 // VideoModule 8253 Mode Control
|
||||
#define VCADDR_8BIT_SUNDG VC_8BIT_BASE_ADDR + 0xE008 // Register for reading the tempo timer status (cursor flash). horizontal blank and switching sound on/off.
|
||||
#define VCADDR_8BIT_TEMP VC_8BIT_BASE_ADDR + 0xE008 // As above, different name used in original source when writing.
|
||||
#define VCADDR_8BIT_MEMSW VC_8BIT_BASE_ADDR + 0xE00C // Memory swap, 0000->C000, C000->0000
|
||||
#define VCADDR_8BIT_MEMSWR VC_8BIT_BASE_ADDR + 0xE010 // Reset memory swap.
|
||||
#define VCADDR_8BIT_INVDSP VC_8BIT_BASE_ADDR + 0xE014 // Invert display.
|
||||
#define VCADDR_8BIT_NRMDSP VC_8BIT_BASE_ADDR + 0xE015 // Return display to normal.
|
||||
#define VCADDR_8BIT_SCLDSP VC_8BIT_BASE_ADDR + 0xE200 // Hardware scroll, a read to each location adds 8 to the start of the video access address therefore creating hardware scroll. 00 - reset to power up
|
||||
#define VCADDR_8BIT_SCLBASE VC_8BIT_BASE_ADDR + 0xE2 // High byte scroll base.
|
||||
|
||||
// Memory addresses of Sharp MZ Series emulator registers and memory.
|
||||
//
|
||||
#define MZ_EMU_REG_INTR_ADDR MZ_EMU_BASE_ADDR + 0x020 // Base address of the interrupt generator.
|
||||
#define MZ_EMU_REG_KEYB_ADDR MZ_EMU_BASE_ADDR + 0x200 // Base address of the keyboard register and map table.
|
||||
#define MZ_EMU_ADDR_REG_MODEL MZ_EMU_BASE_ADDR + 0 // Address of the machine MODEL configuration register.
|
||||
#define MZ_EMU_ADDR_REG_DISPLAY MZ_EMU_BASE_ADDR + 1 // Address of the DISPLAY configuration register 1.
|
||||
#define MZ_EMU_ADDR_REG_DISPLAY2 MZ_EMU_BASE_ADDR + 2 // Address of the DISPLAY configuration register 2.
|
||||
#define MZ_EMU_ADDR_REG_DISPLAY3 MZ_EMU_BASE_ADDR + 3 // Address of the DISPLAY configuration register 3.
|
||||
#define MZ_EMU_ADDR_REG_CPU MZ_EMU_BASE_ADDR + 4 // Address of the CPU configuration register.
|
||||
#define MZ_EMU_ADDR_REG_AUDIO MZ_EMU_BASE_ADDR + 5 // Address of the AUDIO configuration register.
|
||||
#define MZ_EMU_ADDR_REG_CMT MZ_EMU_BASE_ADDR + 6 // Address of the CMT (tape drive) configuration register 1.
|
||||
#define MZ_EMU_ADDR_REG_CMT2 MZ_EMU_BASE_ADDR + 7 // Address of the CMT (tape drive) configuration register 2.
|
||||
#define MZ_EMU_ADDR_REG_USERROM MZ_EMU_BASE_ADDR + 8 // Address of the USER ROM selection register (not currently used.).
|
||||
#define MZ_EMU_ADDR_REG_FDCROM MZ_EMU_BASE_ADDR + 9 // Address of the Floppy Disk ROM selection register.
|
||||
#define MZ_EMU_ADDR_REG_SETUP MZ_EMU_BASE_ADDR + 13 // Address of the emulator current setup (configuration) register.
|
||||
#define MZ_EMU_INTR_ISR 0x00 // Interupt service reason register, define what caused the interupt.
|
||||
#define MZ_EMU_KEYB_KEY_MATRIX 0x00 // Key matrix array current scan.
|
||||
#define MZ_EMU_KEYB_KEY_MATRIX_LAST 0x10 // Key matrix array previous scan.
|
||||
#define MZ_EMU_KEYB_CTRL_REG 0x20 // Keyboard control register.
|
||||
#define MZ_EMU_KEYB_KEYD_REG 0x21 // Keyboard key data register.
|
||||
#define MZ_EMU_KEYB_KEYC_REG 0x22 // Keyboard control data register.
|
||||
#define MZ_EMU_KEYB_KEY_POS_REG 0x23 // Keyboard mapped character mapping position.
|
||||
#define MZ_EMU_KEYB_KEY_POS_LAST_REG 0x24 // Keyboard mapped character previous mapping position.
|
||||
|
||||
#define MZ_EMU_INTR_MAX_REGISTERS 1 // Maximum number of registers in the interrupt generator.
|
||||
#define MZ_EMU_KEYB_MAX_REGISTERS 37 // Maximum number of registers in the keyboard interface.
|
||||
|
||||
#define MZ_EMU_REG_MODEL 0 // Machine MODEL configuration register.
|
||||
#define MZ_EMU_REG_DISPLAY 1 // DISPLAY configuration register 1.
|
||||
#define MZ_EMU_REG_DISPLAY2 2 // DISPLAY configuration register 2.
|
||||
#define MZ_EMU_REG_DISPLAY3 3 // DISPLAY configuration register 3.
|
||||
#define MZ_EMU_REG_CPU 4 // CPU configuration register.
|
||||
#define MZ_EMU_REG_AUDIO 5 // AUDIO configuration register.
|
||||
#define MZ_EMU_REG_CMT 6 // CMT (tape drive) configuration register 1.
|
||||
#define MZ_EMU_REG_CMT2 7 // CMT (tape drive) configuration register 2.
|
||||
#define MZ_EMU_REG_USERROM 8 // USER ROM selection register (not currently used.)
|
||||
#define MZ_EMU_REG_FDCROM 9 // Floppy Disk ROM selection register.
|
||||
#define MZ_EMU_REG_SETUP 13 // Emulator current setup (configuration) register.
|
||||
#define MZ_EMU_MAX_REGISTERS 16 // Maximum number of registers on the emulator.
|
||||
#define MZ_EMU_KEYB_DISABLE_EMU 0x01 // Disable keyboard scan codes being sent to the emulation.
|
||||
#define MZ_EMU_KEYB_ENABLE_INTR 0x02 // Enable interrupt on every key press.
|
||||
|
||||
#define MZ_EMU_DISPLAY_MONO 0x00 // Monochrome display.
|
||||
#define MZ_EMU_DISPLAY_MONO80 0x01 // Monochrome 80 column display.
|
||||
#define MZ_EMU_DISPLAY_COLOUR 0x02 // Colour display.
|
||||
#define MZ_EMU_DISPLAY_COLOUR80 0x03 // Colour 80 column display.
|
||||
#define MZ_EMU_DISPLAY_VRAM_ON 0x00 // Video RAM enable.
|
||||
#define MZ_EMU_DISPLAY_VRAM_OFF 0x04 // Video RAM disable.
|
||||
#define MZ_EMU_DISPLAY_GRAM_ON 0x00 // Graphics RAM enable.
|
||||
#define MZ_EMU_DISPLAY_GRAM_OFF 0x08 // Graphics RAM disable.
|
||||
#define MZ_EMU_DISPLAY_VIDWAIT_ON 0x10 // Enable Video Wait States
|
||||
#define MZ_EMU_DISPLAY_VIDWAIT_OFF 0x00 // Disable Video Wait States
|
||||
#define MZ_EMU_DISPLAY_PCG_ON 0x80 // Enable the Programmable Character Generator.
|
||||
#define MZ_EMU_DISPLAY_PCG_OFF 0x00 // Disable the Programmable Character Generator.
|
||||
#define MZ_EMU_B_CPU_SPEED_4M 0x00 // CPU Freq for the MZ80B group machines.
|
||||
#define MZ_EMU_B_CPU_SPEED_8M 0x01 // CPU Freq for the MZ80B group machines.
|
||||
#define MZ_EMU_B_CPU_SPEED_16M 0x02 // CPU Freq for the MZ80B group machines.
|
||||
#define MZ_EMU_B_CPU_SPEED_32M 0x03 // CPU Freq for the MZ80B group machines.
|
||||
#define MZ_EMU_B_CPU_SPEED_64M 0x04 // CPU Freq for the MZ80B group machines.
|
||||
#define MZ_EMU_C_CPU_SPEED_2M 0x00 // CPU Freq for the MZ80C group machines.
|
||||
#define MZ_EMU_C_CPU_SPEED_4M 0x01 // CPU Freq for the MZ80C group machines.
|
||||
#define MZ_EMU_C_CPU_SPEED_8M 0x02 // CPU Freq for the MZ80C group machines.
|
||||
#define MZ_EMU_C_CPU_SPEED_16M 0x03 // CPU Freq for the MZ80C group machines.
|
||||
#define MZ_EMU_C_CPU_SPEED_32M 0x04 // CPU Freq for the MZ80C group machines.
|
||||
#define MZ_EMU_C_CPU_SPEED_64M 0x05 // CPU Freq for the MZ80C group machines.
|
||||
#define MZ_EMU_78_CPU_SPEED_3M5 0x00 // CPU Freq for the MZ80/700/800 group machines.
|
||||
#define MZ_EMU_78_CPU_SPEED_7M 0x01 // CPU Freq for the MZ80/700/800 group machines.
|
||||
#define MZ_EMU_78_CPU_SPEED_14M 0x02 // CPU Freq for the MZ80/700/800 group machines.
|
||||
#define MZ_EMU_78_CPU_SPEED_28M 0x03 // CPU Freq for the MZ80/700/800 group machines.
|
||||
#define MZ_EMU_78_CPU_SPEED_56M 0x04 // CPU Freq for the MZ80/700/800 group machines.
|
||||
#define MZ_EMU_78_CPU_SPEED_112M 0x05 // CPU Freq for the MZ80/700/800 group machines.
|
||||
#define MZ_EMU_CMT_SPEED_NORMAL 0x00 // CMT runs at normal speed for the selected model.
|
||||
#define MZ_EMU_CMT_SPEED_2X 0x01 // CMT runs at 2x speed.
|
||||
#define MZ_EMU_CMT_SPEED_4X 0x02 // CMT runs at 4x speed.
|
||||
#define MZ_EMU_CMT_SPEED_8X 0x03 // CMT runs at 8x speed.
|
||||
#define MZ_EMU_CMT_SPEED_16X 0x04 // CMT runs at 16x speed.
|
||||
#define MZ_EMU_CMT_SPEED_32X 0x05 // CMT runs at 32x speed.
|
||||
#define MZ_EMU_CMT_BUTTON_OFF 0x00 // CMT keys are off.
|
||||
#define MZ_EMU_CMT_BUTTON_PLAY 0x08 // CMT PLAY button is pressed.
|
||||
#define MZ_EMU_CMT_BUTTON_RECORD 0x10 // CMT RECORD button is pressed.
|
||||
#define MZ_EMU_CMT_BUTTON_AUTO 0x18 // CMT auto logic enabled to select button according to state.
|
||||
#define MZ_EMU_CMT_ASCIIIN 0x20 // Enable ASCII translation of filenames going into the CMT.
|
||||
#define MZ_EMU_CMT_ASCIIOUT 0x40 // Enable ASCII translation of filenames output by the CMT.
|
||||
#define MZ_EMU_CMT_HARDWARE 0x80 // Enable use of the physical host cassette drive instead of the CMT emulation.
|
||||
|
||||
// IO addresses on the tranZPUter or mainboard.
|
||||
//
|
||||
#define IO_TZ_CTRLLATCH 0x60 // Control latch which specifies the Memory Model/mode.
|
||||
#define IO_TZ_SETXMHZ 0x62 // Switch to alternate CPU frequency provided by K64F.
|
||||
#define IO_TZ_SET2MHZ 0x64 // Switch to system CPU frequency.
|
||||
#define IO_TZ_CLKSELRD 0x66 // Read the status of the clock select, ie. which clock is connected to the CPU.
|
||||
#define IO_TZ_SVCREQ 0x68 // Service request from the Z80 to be provided by the K64F.
|
||||
#define IO_TZ_SYSREQ 0x6A // System request from the Z80 to be provided by the K64F.
|
||||
#define IO_TZ_CPUCFG 0x6C // Version 2.2 CPU configuration register.
|
||||
#define IO_TZ_CPUSTATUS 0x6C // Version 2.2 CPU runtime status register.
|
||||
#define IO_TZ_CPUINFO 0x6D // Version 2.2 CPU information register.
|
||||
#define IO_TZ_CPLDCFG 0x6E // Version 2.1 CPLD configuration register.
|
||||
#define IO_TZ_CPLDSTATUS 0x6E // Version 2.1 CPLD status register.
|
||||
#define IO_TZ_CPLDINFO 0x6F // Version 2.1 CPLD version information register.
|
||||
#define IO_TZ_SYSCTRL 0xF0 // System board control register. [2:0] - 000 MZ80A Mode, 2MHz CPU/Bus, 001 MZ80B Mode, 4MHz CPU/Bus, 010 MZ700 Mode, 3.54MHz CPU/Bus.
|
||||
#define IO_TZ_GRAMMODE 0xF4 // MZ80B Graphics mode. Bit 0 = 0, Write to Graphics RAM I, Bit 0 = 1, Write to Graphics RAM II. Bit 1 = 1, blend Graphics RAM I output on display, Bit 2 = 1, blend Graphics RAM II output on display.
|
||||
#define IO_TZ_VMCTRL 0xF8 // Video Module control register. [2:0] - 000 (default) = MZ80A, 001 = MZ-700, 010 = MZ800, 011 = MZ80B, 100 = MZ80K, 101 = MZ80C, 110 = MZ1200, 111 = MZ2000. [3] = 0 - 40 col, 1 - 80 col.
|
||||
#define IO_TZ_VMGRMODE 0xF9 // Video Module graphics mode. 7/6 = Operator (00=OR,01=AND,10=NAND,11=XOR), 5=GRAM Output Enable, 4 = VRAM Output Enable, 3/2 = Write mode (00=Page 1:Red, 01=Page 2:Green, 10=Page 3:Blue, 11=Indirect), 1/0=Read mode (00=Page 1:Red, 01=Page2:Green, 10=Page 3:Blue, 11=Not used).
|
||||
#define IO_TZ_VMREDMASK 0xFA // Video Module Red bit mask (1 bit = 1 pixel, 8 pixels per byte).
|
||||
#define IO_TZ_VMGREENMASK 0xFB // Video Module Green bit mask (1 bit = 1 pixel, 8 pixels per byte).
|
||||
#define IO_TZ_VMBLUEMASK 0xFC // Video Module Blue bit mask (1 bit = 1 pixel, 8 pixels per byte).
|
||||
#define IO_TZ_VMPAGE 0xFD // Video Module memory page register. [1:0] switches in 1 16Kb page (3 pages) of graphics ram to C000 - FFFF. Bits [1:0] = page, 00 = off, 01 = Red, 10 = Green, 11 = Blue. This overrides all MZ700/MZ80B page switching functions. [7] 0 - normal, 1 - switches in CGROM for upload at D000:DFFF.
|
||||
|
||||
// IO register constants.
|
||||
//
|
||||
#define CPUMODE_SET_Z80 0x00 // Set the CPU to the hard Z80.
|
||||
#define CPUMODE_SET_T80 0x01 // Set the CPU to the soft T80.
|
||||
#define CPUMODE_SET_ZPU_EVO 0x02 // Set the CPU to the soft ZPU Evolution.
|
||||
#define CPUMODE_SET_AAA 0x04 // Place holder for a future soft CPU.
|
||||
#define CPUMODE_SET_BBB 0x08 // Place holder for a future soft CPU.
|
||||
#define CPUMODE_SET_CCC 0x10 // Place holder for a future soft CPU.
|
||||
#define CPUMODE_SET_DDD 0x20 // Place holder for a future soft CPU.
|
||||
#define CPUMODE_IS_Z80 0x00 // Status value to indicate if the hard Z80 available.
|
||||
#define CPUMODE_IS_T80 0x01 // Status value to indicate if the soft T80 available.
|
||||
#define CPUMODE_IS_ZPU_EVOL 0x02 // Status value to indicate if the soft ZPU Evolution available.
|
||||
#define CPUMODE_IS_AAA 0x04 // Place holder to indicate if a future soft CPU is available.
|
||||
#define CPUMODE_IS_BBB 0x08 // Place holder to indicate if a future soft CPU is available.
|
||||
#define CPUMODE_IS_CCC 0x10 // Place holder to indicate if a future soft CPU is available.
|
||||
#define CPUMODE_IS_DDD 0x20 // Place holder to indicate if a future soft CPU is available.
|
||||
#define CPUMODE_RESET_CPU 0x80 // Reset the soft CPU. Active high, when high the CPU is held in RESET, when low the CPU runs.
|
||||
#define CPUMODE_IS_SOFT_AVAIL 0x040 // Marker to indicate if the underlying FPGA can support soft CPU's.
|
||||
#define CPUMODE_IS_SOFT_MASK 0x0C0 // Mask to filter out the Soft CPU availability flags.
|
||||
|
||||
// Video Module control bits.
|
||||
#define SYSMODE_MZ80A 0x00 // System board mode MZ80A, 2MHz CPU/Bus.
|
||||
#define SYSMODE_MZ80B 0x01 // System board mode MZ80B, 4MHz CPU/Bus.
|
||||
#define SYSMODE_MZ700 0x02 // System board mode MZ700, 3.54MHz CPU/Bus.
|
||||
#define VMMODE_MASK 0xF8 // Mask to mask out video mode.
|
||||
#define VMMODE_MZ80K 0x00 // Video mode = MZ80K
|
||||
#define VMMODE_MZ80C 0x01 // Video mode = MZ80C
|
||||
#define VMMODE_MZ1200 0x02 // Video mode = MZ1200
|
||||
#define VMMODE_MZ80A 0x03 // Video mode = MZ80A
|
||||
#define VMMODE_MZ700 0x04 // Video mode = MZ700
|
||||
#define VMMODE_MZ800 0x05 // Video mode = MZ800
|
||||
#define VMMODE_MZ80B 0x06 // Video mode = MZ80B
|
||||
#define VMMODE_MZ2000 0x07 // Video mode = MZ2000
|
||||
#define VMMODE_80CHAR 0x08 // Enable 80 character display.
|
||||
#define VMMODE_80CHAR_MASK 0xF7 // Mask to filter out display width control bit.
|
||||
#define VMMODE_COLOUR 0x10 // Enable colour display.
|
||||
#define VMMODE_COLOUR_MASK 0xEF // Mask to filter out colour control bit.
|
||||
#define VMMODE_PCGRAM 0x20 // Enable PCG RAM.
|
||||
#define VMMODE_VGA_MASK 0x3F // Mask to filter out the VGA mode bits.
|
||||
#define VMMODE_VGA_OFF 0x00 // Set VGA mode off, external monitor is driven by standard internal signals.
|
||||
#define VMMODE_VGA_640x480 0x40 // Set external monitor to VGA 640x480 @ 60Hz mode.
|
||||
#define VMMODE_VGA_1024x768 0x80 // Set external monitor to VGA 1024x768 @ 60Hz mode.
|
||||
#define VMMODE_VGA_800x600 0xC0 // Set external monitor to VGA 800x600 @ 60Hz mode.
|
||||
|
||||
// VGA mode border control constants.
|
||||
//
|
||||
#define VMBORDER_BLACK 0x00 // VGA has a black border.
|
||||
#define VMBORDER_BLUE 0x01 // VGA has a blue border.
|
||||
#define VMBORDER_RED 0x02 // VGA has a red border.
|
||||
#define VMBORDER_PURPLE 0x03 // VGA has a purple border.
|
||||
#define VMBORDER_GREEN 0x04 // VGA has a green border.
|
||||
#define VMBORDER_CYAN 0x05 // VGA has a cyan border.
|
||||
#define VMBORDER_YELLOW 0x06 // VGA has a yellow border.
|
||||
#define VMBORDER_WHITE 0x07 // VGA has a white border.
|
||||
#define VMBORDER_MASK 0xF8 // Mask to filter out current border setting.
|
||||
|
||||
// Sharp MZ colour attributes.
|
||||
#define VMATTR_FG_BLACK 0x00 // Foreground black character attribute.
|
||||
#define VMATTR_FG_BLUE 0x10 // Foreground blue character attribute.
|
||||
#define VMATTR_FG_RED 0x20 // Foreground red character attribute.
|
||||
#define VMATTR_FG_PURPLE 0x30 // Foreground purple character attribute.
|
||||
#define VMATTR_FG_GREEN 0x40 // Foreground green character attribute.
|
||||
#define VMATTR_FG_CYAN 0x50 // Foreground cyan character attribute.
|
||||
#define VMATTR_FG_YELLOW 0x60 // Foreground yellow character attribute.
|
||||
#define VMATTR_FG_WHITE 0x70 // Foreground white character attribute.
|
||||
#define VMATTR_FG_MASKOUT 0x8F // Mask to filter out foreground attribute.
|
||||
#define VMATTR_FG_MASKIN 0x70 // Mask to filter out foreground attribute.
|
||||
#define VMATTR_BG_BLACK 0x00 // Background black character attribute.
|
||||
#define VMATTR_BG_BLUE 0x01 // Background blue character attribute.
|
||||
#define VMATTR_BG_RED 0x02 // Background red character attribute.
|
||||
#define VMATTR_BG_PURPLE 0x03 // Background purple character attribute.
|
||||
#define VMATTR_BG_GREEN 0x04 // Background green character attribute.
|
||||
#define VMATTR_BG_CYAN 0x05 // Background cyan character attribute.
|
||||
#define VMATTR_BG_YELLOW 0x06 // Background yellow character attribute.
|
||||
#define VMATTR_BG_WHITE 0x07 // Background white character attribute.
|
||||
#define VMATTR_BG_MASKOUT 0xF8 // Mask to filter out background attribute.
|
||||
#define VMATTR_BG_MASKIN 0x07 // Mask to filter out background attribute.
|
||||
|
||||
// Sharp MZ constants.
|
||||
//
|
||||
#define MZ_MROM_ADDR 0x0000 // Monitor ROM start address.
|
||||
#define MZ_MROM_STACK_ADDR 0x1000 // Monitor ROM start stack address.
|
||||
#define MZ_MROM_STACK_SIZE 0x0200 // Monitor ROM stack size.
|
||||
#define MZ_UROM_ADDR 0xE800 // User ROM start address.
|
||||
#define MZ_BANKRAM_ADDR 0xF000 // Floppy API address which is used in TZFS as the paged RAM for additional functionality.
|
||||
#define MZ_CMT_ADDR 0x10F0 // Address of the CMT (tape) header record.
|
||||
#define MZ_CMT_DEFAULT_LOAD_ADDR 0x1200 // The default load address for a CMT, anything below this is normally illegal.
|
||||
#define MZ_VID_RAM_ADDR 0xD000 // Start of Video RAM
|
||||
#define MZ_VID_RAM_SIZE 2048 // Size of Video RAM.
|
||||
#define MZ_VID_DFLT_BYTE 0x00 // Default character (SPACE) for video RAM.
|
||||
#define MZ_ATTR_RAM_ADDR 0xD800 // On machines with the upgrade, the start of the Attribute RAM.
|
||||
#define MZ_ATTR_RAM_SIZE 2048 // Size of the attribute RAM.
|
||||
#define MZ_ATTR_DFLT_BYTE 0x07 // Default colour (White on Black) for the attribute.
|
||||
#define MZ_SCROL_BASE 0xE200 // Base address of the hardware scroll registers.
|
||||
#define MZ_SCROL_END 0xE2FF // End address of the hardware scroll registers.
|
||||
#define MZ_MEMORY_SWAP 0xE00C // Address when read swaps the memory from 0000-0FFF -> C000-CFFF
|
||||
#define MZ_MEMORY_RESET 0xE010 // Address when read resets the memory to the default location 0000-0FFF.
|
||||
#define MZ_CRT_NORMAL 0xE014 // Address when read sets the CRT to normal display mode.
|
||||
#define MZ_CRT_INVERSE 0xE018 // Address when read sets the CRT to inverted display mode.
|
||||
#define MZ_80A_CPU_FREQ 2000000 // CPU Speed of the Sharp MZ-80A
|
||||
#define MZ_700_CPU_FREQ 3580000 // CPU Speed of the Sharp MZ-700
|
||||
#define MZ_80B_CPU_FREQ 4000000 // CPU Speed of the Sharp MZ-80B
|
||||
|
||||
// Constants for the Sharp MZ80A MZF file format.
|
||||
#define MZF_HEADER_SIZE 128 // Size of the MZF header.
|
||||
#define MZF_ATTRIBUTE 0x00 // Code Type, 01 = Machine Code.
|
||||
#define MZF_FILENAME 0x01 // Title/Name (17 bytes).
|
||||
#define MZF_FILENAME_LEN 17 // Length of the filename, it is not NULL terminated, generally a CR can be taken as terminator but not guaranteed.
|
||||
#define MZF_FILESIZE 0x12 // Size of program.
|
||||
#define MZF_LOADADDR 0x14 // Load address of program.
|
||||
#define MZF_EXECADDR 0x16 // Exec address of program.
|
||||
#define MZF_COMMENT 0x18 // Comment, used for details of the file or startup code.
|
||||
#define MZF_COMMENT_LEN 104 // Length of the comment field.
|
||||
|
||||
|
||||
//Common character definitions.
|
||||
#define SCROLL 0x01 // Set scroll direction UP.
|
||||
#define BELL 0x07
|
||||
#define SPACE 0x20
|
||||
#define TAB 0x09 // TAB ACROSS (8 SPACES FOR SD-BOARD)
|
||||
#define CR 0x0D
|
||||
#define LF 0x0A
|
||||
#define FF 0x0C
|
||||
#define DELETE 0x7F
|
||||
#define BACKS 0x08
|
||||
#define SOH 0x01 // For XModem etc.
|
||||
#define EOT 0x04
|
||||
#define ACK 0x06
|
||||
#define NAK 0x15
|
||||
#define NUL 0x00
|
||||
//#define NULL 0x00
|
||||
#define CTRL_A 0x01
|
||||
#define CTRL_B 0x02
|
||||
#define CTRL_C 0x03
|
||||
#define CTRL_D 0x04
|
||||
#define CTRL_E 0x05
|
||||
#define CTRL_F 0x06
|
||||
#define CTRL_G 0x07
|
||||
#define CTRL_H 0x08
|
||||
#define CTRL_I 0x09
|
||||
#define CTRL_J 0x0A
|
||||
#define CTRL_K 0x0B
|
||||
#define CTRL_L 0x0C
|
||||
#define CTRL_M 0x0D
|
||||
#define CTRL_N 0x0E
|
||||
#define CTRL_O 0x0F
|
||||
#define CTRL_P 0x10
|
||||
#define CTRL_Q 0x11
|
||||
#define CTRL_R 0x12
|
||||
#define CTRL_S 0x13
|
||||
#define CTRL_T 0x14
|
||||
#define CTRL_U 0x15
|
||||
#define CTRL_V 0x16
|
||||
#define CTRL_W 0x17
|
||||
#define CTRL_X 0x18
|
||||
#define CTRL_Y 0x19
|
||||
#define CTRL_Z 0x1A
|
||||
#define ESC 0x1B
|
||||
#define CTRL_SLASH 0x1C
|
||||
#define CTRL_LB 0x1B
|
||||
#define CTRL_RB 0x1D
|
||||
#define CTRL_CAPPA 0x1E
|
||||
#define CTRL_UNDSCR 0x1F
|
||||
#define CTRL_AT 0x00
|
||||
#define FUNC1 0x80
|
||||
#define FUNC2 0x81
|
||||
#define FUNC3 0x82
|
||||
#define FUNC4 0x83
|
||||
#define FUNC5 0x84
|
||||
#define FUNC6 0x85
|
||||
#define FUNC7 0x86
|
||||
#define FUNC8 0x87
|
||||
#define FUNC9 0x88
|
||||
#define FUNC10 0x89
|
||||
#define PAGEUP 0xE0
|
||||
#define PAGEDOWN 0xE1
|
||||
#define CURHOMEKEY 0xE2
|
||||
#define NOKEY 0xF0
|
||||
#define CURSRIGHT 0xF1
|
||||
#define CURSLEFT 0xF2
|
||||
#define CURSUP 0xF3
|
||||
#define CURSDOWN 0xF4
|
||||
#define DBLZERO 0xF5
|
||||
#define INSERT 0xF6
|
||||
#define CLRKEY 0xF7
|
||||
#define HOMEKEY 0xF8
|
||||
#define ENDKEY 0xF9
|
||||
#define ANSITGLKEY 0xFA
|
||||
#define BREAKKEY 0xFB
|
||||
#define GRAPHKEY 0xFC
|
||||
#define ALPHAKEY 0xFD
|
||||
#define DEBUGKEY 0xFE // Special key to enable debug features such as the ANSI emulation.
|
||||
|
||||
// Macros.
|
||||
//
|
||||
// Convert big endiam to little endian.
|
||||
#define convBigToLittleEndian(num) ((num>>24)&0xff) | ((num<<8)&0xff0000) | ((num>>8)&0xff00) | ((num<<24)&0xff000000)
|
||||
#define setPixel(x,y,colour) if(y >= 0 && y < osdWindow.params[osdWindow.mode].maxY && x >= 0 && x < osdWindow.params[osdWindow.mode].maxX) \
|
||||
{ \
|
||||
for(uint8_t c=0; c < (VC_MENU_RGB_BITS > VC_STATUS_RGB_BITS ? VC_MENU_RGB_BITS : VC_STATUS_RGB_BITS); c++) \
|
||||
{ \
|
||||
if(colour & (1 << c)) \
|
||||
{ \
|
||||
osdWindow.display[c][((y * osdWindow.params[osdWindow.mode].maxX) + x)/8] |= 0x80 >> x%8; \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
#define clearPixel(x,y,colour) if(y >= 0 && y < osdWindow.params[osdWindow.mode].maxY && x >= 0 && x < osdWindow.params[osdWindow.mode].maxX) \
|
||||
{ \
|
||||
for(uint8_t c=0; c < (VC_MENU_RGB_BITS > VC_STATUS_RGB_BITS ? VC_MENU_RGB_BITS : VC_STATUS_RGB_BITS); c++) \
|
||||
{ \
|
||||
if(colour & (1 << c)) \
|
||||
{ \
|
||||
osdWindow.display[c][((y * osdWindow.params[osdWindow.mode].maxX) + x)/8] &= ~(0x80 >> x%8); \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
|
||||
// Supported windows.
|
||||
enum WINDOWS {
|
||||
STATUS = 0x00, // Status Window
|
||||
MENU = 0x01 // Menu Window
|
||||
};
|
||||
|
||||
// Supported orientation.
|
||||
enum ORIENTATION {
|
||||
NORMAL = 0x00, // Normal character orientation.
|
||||
DEG90 = 0x01, // 90 degree rotation
|
||||
DEG180 = 0x02, // 180 degree rotation
|
||||
DEG270 = 0x03 // 270 degree rotation
|
||||
};
|
||||
|
||||
// Supported colours.
|
||||
enum COLOUR {
|
||||
BLACK = 0x00, // No pixels active.
|
||||
BLUE = 0x01, // Blue pixel active.
|
||||
RED = 0x02, // Red pixel active.
|
||||
PURPLE = 0x03, // Red and Blue pixels active.
|
||||
GREEN = 0x04, // Green pixel active.
|
||||
CYAN = 0x05, // Green and Blue pixels active.
|
||||
YELLOW = 0x06, // Green and Red pixels active.
|
||||
WHITE = 0x07 // Green, Red and Blue pixels active.
|
||||
};
|
||||
|
||||
// Public settings, accessed via enumerated value.
|
||||
enum OSDPARAMS {
|
||||
ACTIVE_MAX_X = 0x00, // Width in pixels of the active framebuffer.
|
||||
ACTIVE_MAX_Y = 0x01 // Depth in pixels of the active framebuffer.
|
||||
};
|
||||
|
||||
// Structure to maintain the OSD Menu and Status display output parameters and data.
|
||||
//
|
||||
typedef struct {
|
||||
// Attributes for output data.
|
||||
uint8_t attr;
|
||||
|
||||
// Location in the framebuffer to output data.
|
||||
uint8_t row;
|
||||
uint8_t col;
|
||||
|
||||
// Maxims, dynamic to allow for changes due to selected font.
|
||||
uint8_t maxCol;
|
||||
uint8_t maxRow;
|
||||
|
||||
// Window Features.
|
||||
uint8_t lineWrap; // Wrap line at status window edge (1) else stop printing at status window edge.
|
||||
uint16_t maxX; // Maximum X plane pixels.
|
||||
uint16_t maxY; // Maximum Y plane pixels.
|
||||
|
||||
} t_WindowParams;
|
||||
typedef struct {
|
||||
// Mode in which the OSD is operating.
|
||||
enum WINDOWS mode;
|
||||
|
||||
// Per window parameters, currently a MENU and STATUS window exist.
|
||||
t_WindowParams params[sizeof(enum WINDOWS)+1];
|
||||
|
||||
// Global features.
|
||||
uint8_t debug; // Enable debugging features.
|
||||
uint8_t inDebug; // Prevent recursion when outputting debug information.
|
||||
|
||||
// Framebuffer backing store. Data for display is assembled in this buffer prior to bulk copy into the FPGA memory.
|
||||
uint8_t (*display)[VC_MENU_BUFFER_SIZE > VC_STATUS_BUFFER_SIZE ? VC_MENU_BUFFER_SIZE : VC_STATUS_BUFFER_SIZE];
|
||||
} t_OSDWindow;
|
||||
|
||||
// Application execution constants.
|
||||
//
|
||||
|
||||
// Prototypes.
|
||||
//
|
||||
|
||||
uint32_t OSDGet(enum OSDPARAMS);
|
||||
fontStruct *OSDGetFont(enum FONTS);
|
||||
bitmapStruct *OSDGetBitmap(enum BITMAPS);
|
||||
void OSDSetPixel(uint16_t, uint16_t, enum COLOUR);
|
||||
void OSDClearPixel(uint16_t, uint16_t, enum COLOUR);
|
||||
void OSDChangePixelColour(uint16_t, uint16_t, enum COLOUR, enum COLOUR);
|
||||
void _OSDwrite(uint8_t, uint8_t, int8_t, int8_t, uint8_t, uint8_t, enum ORIENTATION, uint8_t, enum COLOUR, enum COLOUR, fontStruct *);
|
||||
void OSDWriteBitmap(uint16_t, uint16_t, enum BITMAPS, enum COLOUR, enum COLOUR);
|
||||
void OSDWriteChar(uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, enum FONTS, enum ORIENTATION, char, enum COLOUR, enum COLOUR);
|
||||
void OSDWriteString(uint8_t, uint8_t, int8_t, int8_t, uint8_t, uint8_t, enum FONTS, enum ORIENTATION, char *, enum COLOUR, enum COLOUR);
|
||||
void OSDRefreshScreen(void);
|
||||
void OSDClearScreen(enum COLOUR);
|
||||
void OSDClearArea(int16_t, int16_t, int16_t, int16_t, enum COLOUR);
|
||||
void OSDDrawLine(int16_t, int16_t, int16_t, int16_t, enum COLOUR);
|
||||
void OSDDrawCircle(int16_t, int16_t, int16_t, enum COLOUR);
|
||||
void OSDDrawFilledCircle(int16_t, int16_t, int16_t, enum COLOUR);
|
||||
void OSDDrawEllipse(int16_t, int16_t, int16_t, int16_t, enum COLOUR);
|
||||
void OSDSetActiveWindow(enum WINDOWS);
|
||||
uint8_t OSDInit(enum WINDOWS);
|
||||
|
||||
// Getter/Setter methods!
|
||||
|
||||
|
||||
// Prototypes.
|
||||
//
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif // OSD_H
|
||||
@@ -43,7 +43,7 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
uint8_t *readline (uint8_t *, int, const char *);
|
||||
uint8_t *readline (uint8_t *, int, int, const char *, void (*)());
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -163,8 +163,8 @@
|
||||
//
|
||||
|
||||
// Base addresses and sizes within the FPGA/Video Controller.
|
||||
#define VIDEO_BASE_ADDR 0xC80000
|
||||
#define Z80_BUS_BASE_ADDR 0xD00000
|
||||
#define VIDEO_BASE_ADDR 0xD00000 // Base address of the Video Controller.
|
||||
#define Z80_BUS_BASE_ADDR 0xE00000 // Base address of the Z80 FSM
|
||||
#define VIDEO_VRAM_BASE_ADDR VIDEO_BASE_ADDR + 0x01D000 // Base address of the character video RAM using direct addressing.
|
||||
#define VIDEO_VRAM_SIZE 0x800 // Size of the video RAM.
|
||||
#define VIDEO_ARAM_BASE_ADDR VIDEO_BASE_ADDR + 0x01D800 // Base address of the character attribute RAM using direct addressing.
|
||||
@@ -266,11 +266,11 @@
|
||||
#define VCADDR_32BIT_SCLDSP VC_32BIT_BASE_ADDR + (4*0xE200) // Hardware scroll, a read to each location adds 8 to the start of the video access address therefore creating hardware scroll. 00 - reset to power up
|
||||
#define VCADDR_32BIT_SCLBASE VC_32BIT_BASE_ADDR + (4*0xE2) // High byte scroll base.
|
||||
|
||||
// Memory mapped I/O on the mainboard. These addresses are processed by the Z80BUS FSM which converts a 32bit ZPU cycle into several 8bi Z80 cycles.
|
||||
// Memory mapped I/O on the mainboard. These addresses are processed by the Z80BUS FSM which converts a 32bit ZPU cycle into several 8bit Z80 cycles.
|
||||
//
|
||||
#define MB_8BIT_BASE_ADDR Z80_BUS_BASE_ADDR + 0x100000
|
||||
#define MB_32BIT_BASE_ADDR Z80_BUS_BASE_ADDR + 0x180000
|
||||
#define MB_32BIT_IO_ADDR Z80_BUS_BASE_ADDR + 0x140000
|
||||
#define MB_8BIT_BASE_ADDR Z80_BUS_BASE_ADDR + 0x000000
|
||||
#define MB_32BIT_BASE_ADDR Z80_BUS_BASE_ADDR + 0x080000
|
||||
#define MB_32BIT_IO_ADDR Z80_BUS_BASE_ADDR + 0x040000
|
||||
|
||||
// 8 Bit access addresses - used for writing and reading on a 32bit boundary with lower address lines set to 00. Writing is 1 byte only.
|
||||
#define MBADDR_8BIT_KEYPA MB_8BIT_BASE_ADDR + (4*0xE000) // Mainboard 8255 Port A
|
||||
|
||||
@@ -125,14 +125,14 @@
|
||||
#define CPUMODE_SET_Z80 0x00 // Set the CPU to the hard Z80.
|
||||
#define CPUMODE_SET_T80 0x01 // Set the CPU to the soft T80.
|
||||
#define CPUMODE_SET_ZPU_EVO 0x02 // Set the CPU to the soft ZPU Evolution.
|
||||
#define CPUMODE_SET_AAA 0x04 // Place holder for a future soft CPU.
|
||||
#define CPUMODE_SET_EMU_MZ 0x04 //
|
||||
#define CPUMODE_SET_BBB 0x08 // Place holder for a future soft CPU.
|
||||
#define CPUMODE_SET_CCC 0x10 // Place holder for a future soft CPU.
|
||||
#define CPUMODE_SET_DDD 0x20 // Place holder for a future soft CPU.
|
||||
#define CPUMODE_IS_Z80 0x00 // Status value to indicate if the hard Z80 available.
|
||||
#define CPUMODE_IS_T80 0x01 // Status value to indicate if the soft T80 available.
|
||||
#define CPUMODE_IS_ZPU_EVO 0x02 // Status value to indicate if the soft ZPU Evolution available.
|
||||
#define CPUMODE_IS_AAA 0x04 // Place holder to indicate if a future soft CPU is available.
|
||||
#define CPUMODE_IS_EMU_MZ 0x04 // Status value to indicate if the Sharp MZ Series Emulation is available.
|
||||
#define CPUMODE_IS_BBB 0x08 // Place holder to indicate if a future soft CPU is available.
|
||||
#define CPUMODE_IS_CCC 0x10 // Place holder to indicate if a future soft CPU is available.
|
||||
#define CPUMODE_IS_DDD 0x20 // Place holder to indicate if a future soft CPU is available.
|
||||
@@ -240,27 +240,31 @@
|
||||
#define MZ_80A_CPU_FREQ 2000000 // CPU Speed of the Sharp MZ-80A
|
||||
#define MZ_700_CPU_FREQ 3580000 // CPU Speed of the Sharp MZ-700
|
||||
#define MZ_80B_CPU_FREQ 4000000 // CPU Speed of the Sharp MZ-80B
|
||||
#define MZ_2000_CPU_FREQ 4000000 // CPU Speed of the Sharp MZ-2000
|
||||
#define MZ_800_CPU_FREQ 3580000 // CPU Speed of the Sharp MZ-800
|
||||
#define MZ_ROM_SA1510_40C "0:\\TZFS\\SA1510.ROM" // Original 40 character Monitor ROM.
|
||||
#define MZ_ROM_SA1510_80C "0:\\TZFS\\SA1510-8.ROM" // Original Monitor ROM patched for 80 character screen mode.
|
||||
#define MZ_ROM_1Z_013A_40C "0:\\TZFS\\1Z-013A.ROM" // Original 40 character Monitor ROM for the Sharp MZ700.
|
||||
#define MZ_ROM_1Z_013A_80C "0:\\TZFS\\1Z-013A-8.ROM" // Original Monitor ROM patched for the Sharp MZ700 patched for 80 column mode.
|
||||
#define MZ_ROM_1Z_013A_KM_40C "0:\\TZFS\\1Z-013A-KM.ROM" // Original 40 character Monitor ROM for the Sharp MZ700 with keyboard remapped for the MZ80A.
|
||||
#define MZ_ROM_1Z_013A_KM_80C "0:\\TZFS\\1Z-013A-KM-8.ROM" // Original Monitor ROM patched for the Sharp MZ700 with keyboard remapped for the MZ80A and patched for 80 column mode.
|
||||
#define MZ_ROM_9Z_504M_COMBINED "0:\\TZFS\\MZ800_IPL.rom" // Original MZ-800 BIOS which comprises the 1Z_013B BIOS, 9Z_504M IPL, CGROM and IOCS.
|
||||
#define MZ_ROM_9Z_504M "0:\\TZFS\\MZ800_9Z_504M.rom" // Modified MZ-800 9Z_504M IPL to contain a select TZFS option.
|
||||
#define MZ_ROM_1Z_013B "0:\\TZFS\\MZ800_1Z_013B.rom" // Original MZ-800 1Z_013B MZ-700 compatible BIOS.
|
||||
#define MZ_ROM_800_CGROM "0:\\TZFS\\MZ800_CGROM.ORI" // Original MZ-800 Character Generator ROM.
|
||||
#define MZ_ROM_800_IOCS "0:\\TZFS\\MZ800_IOCS.rom" // Original MZ-800 common IOCS bios.
|
||||
#define MZ_ROM_MZ80B_IPL "0:\\TZFS\\MZ80B_IPL.ROM" // Original IPL ROM for the Sharp MZ-80B.
|
||||
#define MZ_ROM_TZFS "0:\\TZFS\\TZFS.ROM" // tranZPUter Filing System ROM.
|
||||
#define MZ_ROM_ZPU_ZOS "0:\\ZOS\\ZOS.ROM" // zOS for the ZPU running on the tranZPUter SW-700 board.
|
||||
|
||||
#define MZ_ROM_SP1002 "0:\\TZFS\\sp1002.rom" // Original MZ-80K ROM
|
||||
#define MZ_ROM_SA1510_40C "0:\\TZFS\\sa1510.rom" // Original 40 character Monitor ROM.
|
||||
#define MZ_ROM_SA1510_80C "0:\\TZFS\\sa1510-8.rom" // Original Monitor ROM patched for 80 character screen mode.
|
||||
#define MZ_ROM_1Z_013A_40C "0:\\TZFS\\1z-013a.rom" // Original 40 character Monitor ROM for the Sharp MZ700.
|
||||
#define MZ_ROM_1Z_013A_80C "0:\\TZFS\\1z-013a-8.rom" // Original Monitor ROM patched for the Sharp MZ700 patched for 80 column mode.
|
||||
#define MZ_ROM_1Z_013A_KM_40C "0:\\TZFS\\1z-013a-km.rom" // Original 40 character Monitor ROM for the Sharp MZ700 with keyboard remapped for the MZ80A.
|
||||
#define MZ_ROM_1Z_013A_KM_80C "0:\\TZFS\\1z-013a-km-8.rom" // Original Monitor ROM patched for the Sharp MZ700 with keyboard remapped for the MZ80A and patched for 80 column mode.
|
||||
#define MZ_ROM_9Z_504M_COMBINED "0:\\TZFS\\mz800_ipl.rom" // Original MZ-800 BIOS which comprises the 1Z_013B BIOS, 9Z_504M IPL, CGROM and IOCS.
|
||||
#define MZ_ROM_9Z_504M "0:\\TZFS\\mz800_9z_504m.rom" // Modified MZ-800 9Z_504M IPL to contain a select TZFS option.
|
||||
#define MZ_ROM_1Z_013B "0:\\TZFS\\mz800_1z_013b.rom" // Original MZ-800 1Z_013B MZ-700 compatible BIOS.
|
||||
#define MZ_ROM_800_CGROM "0:\\TZFS\\mz800_cgrom.ori" // Original MZ-800 Character Generator ROM.
|
||||
#define MZ_ROM_800_IOCS "0:\\TZFS\\mz800_iocs.rom" // Original MZ-800 common IOCS bios.
|
||||
#define MZ_ROM_MZ80B_IPL "0:\\TZFS\\mz80b_ipl.rom" // Original IPL ROM for the Sharp MZ-80B.
|
||||
#define MZ_ROM_MZ2000_IPL "0:\\TZFS\\mz2000_ipl.rom" // Original IPL ROM for the Sharp MZ-2000.
|
||||
#define MZ_ROM_TZFS "0:\\TZFS\\tzfs.rom" // tranZPUter Filing System ROM.
|
||||
#define MZ_ROM_ZPU_ZOS "0:\\ZOS\\zos.rom" // zOS for the ZPU running on the tranZPUter SW-700 board.
|
||||
|
||||
// CP/M constants.
|
||||
//
|
||||
#define CPM_MAX_DRIVES 16 // Maximum number of drives in CP/M.
|
||||
#define CPM_FILE_CCPBDOS "0:\\CPM\\CPM22.BIN" // CP/M CCP and BDOS for warm start reloads.
|
||||
#define CPM_DRIVE_TMPL "0:\\CPM\\CPMDSK%02u.RAW" // Template for CPM disk drives stored on the SD card.
|
||||
#define CPM_FILE_CCPBDOS "0:\\CPM\\cpm22.bin" // CP/M CCP and BDOS for warm start reloads.
|
||||
#define CPM_DRIVE_TMPL "0:\\CPM\\cpmdsk%02u.raw" // Template for CPM disk drives stored on the SD card.
|
||||
#define CPM_SECTORS_PER_TRACK 32 // Number of sectors in a track on the virtual CPM disk.
|
||||
#define CPM_TRACKS_PER_DISK 1024 // Number of tracks on a disk.
|
||||
|
||||
@@ -294,6 +298,7 @@
|
||||
#define TZSVC_CMD_LOAD700BIOS80 0x23 // Service command requesting that the MZ700 1Z-013A 80 column patched BIOS is loaded.
|
||||
#define TZSVC_CMD_LOAD80BIPL 0x24 // Service command requesting the MZ-80B IPL is loaded.
|
||||
#define TZSVC_CMD_LOAD800BIOS 0x25 // Service command requesting that the MZ800 9Z-504M BIOS is loaded.
|
||||
#define TZSVC_CMD_LOAD2000IPL 0x26 // Service command requesting the MZ-2000 IPL is loaded.
|
||||
#define TZSVC_CMD_LOADBDOS 0x30 // Service command to reload CPM BDOS+CCP.
|
||||
#define TZSVC_CMD_ADDSDDRIVE 0x31 // Service command to attach a CPM disk to a drive number.
|
||||
#define TZSVC_CMD_READSDDRIVE 0x32 // Service command to read an attached SD file as a CPM disk drive.
|
||||
@@ -304,6 +309,14 @@
|
||||
#define TZSVC_CMD_CPU_SETZ80 0x50 // Service command to switch to the external Z80 hard cpu.
|
||||
#define TZSVC_CMD_CPU_SETT80 0x51 // Service command to switch to the internal T80 soft cpu.
|
||||
#define TZSVC_CMD_CPU_SETZPUEVO 0x52 // Service command to switch to the internal ZPU Evolution cpu.
|
||||
#define TZSVC_CMD_EMU_SETMZ80K 0x53 // Service command to switch to the internal Sharp MZ Series Emulation of the MZ80K.
|
||||
#define TZSVC_CMD_EMU_SETMZ80C 0x54 // "" "" "" MZ80C.
|
||||
#define TZSVC_CMD_EMU_SETMZ1200 0x55 // "" "" "" MZ1200.
|
||||
#define TZSVC_CMD_EMU_SETMZ80A 0x56 // "" "" "" MZ80A.
|
||||
#define TZSVC_CMD_EMU_SETMZ700 0x57 // "" "" "" MZ700.
|
||||
#define TZSVC_CMD_EMU_SETMZ800 0x58 // "" "" "" MZ800.
|
||||
#define TZSVC_CMD_EMU_SETMZ80B 0x59 // "" "" "" MZ80B.
|
||||
#define TZSVC_CMD_EMU_SETMZ2000 0x5A // "" "" "" MZ2000.
|
||||
#define TZSVC_CMD_SD_DISKINIT 0x60 // Service command to initialise and provide raw access to the underlying SD card.
|
||||
#define TZSVC_CMD_SD_READSECTOR 0x61 // Service command to provide raw read access to the underlying SD card.
|
||||
#define TZSVC_CMD_SD_WRITESECTOR 0x62 // Service command to provide raw write access to the underlying SD card.
|
||||
@@ -343,6 +356,17 @@
|
||||
#define MZF_EXECADDR 0x16 // Exec address of program.
|
||||
#define MZF_COMMENT 0x18 // Comment, used for details of the file or startup code.
|
||||
#define MZF_COMMENT_LEN 104 // Length of the comment field.
|
||||
#define CMT_TYPE_OBJCD 0x001 // MZF contains a binary object.
|
||||
#define CMT_TYPE_BTX1CD 0x002 // MZF contains a BASIC program.
|
||||
#define CMT_TYPE_BTX2CD 0x005 // MZF contains a BASIC program.
|
||||
#define CMT_TYPE_TZOBJCD0 0x0F8 // MZF contains a TZFS binary object for page 0.
|
||||
#define CMT_TYPE_TZOBJCD1 0x0F9
|
||||
#define CMT_TYPE_TZOBJCD2 0x0FA
|
||||
#define CMT_TYPE_TZOBJCD3 0x0FB
|
||||
#define CMT_TYPE_TZOBJCD4 0x0FC
|
||||
#define CMT_TYPE_TZOBJCD5 0x0FD
|
||||
#define CMT_TYPE_TZOBJCD6 0x0FE
|
||||
#define CMT_TYPE_TZOBJCD7 0x0FF // MZF contains a TZFS binary object for page 7.
|
||||
|
||||
// Constants for other handled file formats.
|
||||
//
|
||||
@@ -681,7 +705,7 @@ typedef struct {
|
||||
//uint8_t bD000; // Block D000:FFFF mode.
|
||||
} t_mz700;
|
||||
|
||||
// Structure to maintain all MZ-80B hardware control information in oder to emulate the machine as near as possible.
|
||||
// Structure to maintain all MZ-80B hardware control information in order to emulate the machine as near as possible.
|
||||
typedef struct {
|
||||
uint32_t config; // Compacted control register, 31:19 = reserved, 18 = Inhibit mode, 17 = Upper D000:FFFF is RAM (=1), 16 = Lower 0000:0FFF is RAM (=1), 15:8 = old memory mode, 7:0 = current memory mode.
|
||||
} t_mz80b;
|
||||
@@ -696,13 +720,14 @@ typedef struct {
|
||||
uint8_t runCtrlLatch; // Latch value the Z80 is running with.
|
||||
uint8_t curCtrlLatch; // Latch value set during tranZPUter access of the Z80 bus.
|
||||
uint8_t holdZ80; // A flag to hold the Z80 bus when multiple transactions need to take place.
|
||||
uint8_t emuMZactive; // An emulation is active in the FPGA.
|
||||
uint8_t videoRAM[2][2048]; // Two video memory buffer frames, allows for storage of original frame in [0] and working frame in [1].
|
||||
uint8_t attributeRAM[2][2048]; // Two attribute memory buffer frames, allows for storage of original frame in [0] and working frame in [1].
|
||||
|
||||
enum CTRL_MODE ctrlMode; // Mode of control, ie normal Z80 Running, controlling mainboard, controlling tranZPUter.
|
||||
enum BUS_DIRECTION busDir; // Direction the bus has been configured for.
|
||||
enum MACHINE_TYPES hostType; // The underlying host machine, 0 = Sharp MZ-80A, 1 = MZ-700, 2 = MZ-80B
|
||||
enum MACHINE_TYPES machineMode; // Machine compatibility, 0 = Sharp MZ-80A, 1 = MZ-700, 2 = MZ-80B
|
||||
enum MACHINE_TYPES machineMode; // Machine compatibility, 0 = Sharp MZ-80K, 1 = MZ-80C, 2 = MZ-1200, 3 = MZ-80A, 4 = MZ-700, 5 = MZ-800, 6 = MZ-80B, 7 = MZ-2000
|
||||
t_mz700 mz700; // MZ700 emulation control to detect IO commands and adjust the memory map accordingly.
|
||||
t_mz80b mz80b; // MZ-80B emulation control to detect IO commands and adjust the memory map and I/O forwarding accordingly.
|
||||
|
||||
@@ -831,6 +856,8 @@ uint8_t copyFromZ80(uint8_t *, uint32_t, uint32_t,
|
||||
uint8_t copyToZ80(uint32_t, uint8_t *, uint32_t, enum TARGETS);
|
||||
uint8_t writeZ80Memory(uint32_t, uint8_t, enum TARGETS);
|
||||
uint8_t readZ80Memory(uint32_t);
|
||||
uint8_t writeZ80Array(uint32_t, uint8_t *, uint32_t, enum TARGETS);
|
||||
uint8_t readZ80Array(uint32_t, uint8_t *, uint32_t, enum TARGETS);
|
||||
uint8_t outZ80IO(uint32_t, uint8_t);
|
||||
uint8_t inZ80IO(uint32_t);
|
||||
uint8_t writeZ80IO(uint32_t, uint8_t, enum TARGETS);
|
||||
@@ -873,6 +900,7 @@ uint8_t svcReadCPMDrive(void);
|
||||
uint8_t svcWriteCPMDrive(void);
|
||||
uint32_t getServiceAddr(void);
|
||||
void processServiceRequest(void);
|
||||
void TZPUservice(void);
|
||||
uint8_t loadBIOS(const char *biosFileName, uint8_t machineMode, uint32_t loadAddr);
|
||||
void hardResetTranZPUter(void);
|
||||
void loadTranZPUterDefaultROMS(uint8_t);
|
||||
@@ -882,6 +910,9 @@ void setHost(void);
|
||||
void setupTranZPUter(void);
|
||||
void testRoutine(void);
|
||||
|
||||
// Sharp MZ Series emulation methods.
|
||||
void emuMZ(uint8_t);
|
||||
|
||||
#if defined __APP__
|
||||
int memoryDumpZ80(uint32_t, uint32_t, uint32_t, uint8_t, uint8_t, enum TARGETS);
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user