| 1 | #pragma once |
| 2 | |
| 3 | #include <SDL2/SDL.h> |
| 4 | #include <stdint.h> |
| 5 | #include <stdbool.h> |
| 6 | #ifdef _DEBUG |
| 7 | #include <assert.h> |
| 8 | #endif |
| 9 | #ifdef _WIN32 |
| 10 | #define WIN32_MEAN_AND_LEAN |
| 11 | #include <windows.h> // MAX_PATH |
| 12 | #else |
| 13 | #include <limits.h> // PATH_MAX |
| 14 | #endif |
| 15 | #include <stdint.h> |
| 16 | #include "pt2_unicode.h" |
| 17 | #include "pt2_palette.h" |
| 18 | |
| 19 | #define PROG_VER_STR "1.90" |
| 20 | |
| 21 | #ifndef ASSERT |
| 22 | #ifdef _DEBUG |
| 23 | #define ASSERT(x) assert(x) |
| 24 | #else |
| 25 | #define ASSERT(x) |
| 26 | #endif |
| 27 | #endif |
| 28 | |
| 29 | #ifdef _WIN32 |
| 30 | #define DIR_DELIMITER '\\' |
| 31 | #define PATH_MAX MAX_PATH |
| 32 | #else |
| 33 | #define DIR_DELIMITER '/' |
| 34 | #define _stricmp strcasecmp |
| 35 | #define _strnicmp strncasecmp |
| 36 | #endif |
| 37 | |
| 38 | #define SAMPLE_VIEW_HEIGHT 64 |
| 39 | #define SAMPLE_AREA_WIDTH 314 |
| 40 | |
| 41 | #define SCREEN_W 320 |
| 42 | #define SCREEN_H 255 |
| 43 | |
| 44 | #define MIN_AUDIO_FREQUENCY 44100 |
| 45 | #define MAX_AUDIO_FREQUENCY 192000 |
| 46 | |
| 47 | // main crystal oscillator for PAL Amiga systems |
| 48 | #define AMIGA_PAL_XTAL_HZ 28375160 |
| 49 | #define AMIGA_PAL_CCK_HZ (AMIGA_PAL_XTAL_HZ/8.0) |
| 50 | #define CIA_PAL_CLK (AMIGA_PAL_CCK_HZ / 5.0) |
| 51 | |
| 52 | // nominal framerate in normal PAL videomodes (~49.92Hz) |
| 53 | #define AMIGA_PAL_VBLANK_HZ (AMIGA_PAL_CCK_HZ / (double)(313*227)) |
| 54 | |
| 55 | /* "60Hz" ranges everywhere from 59..61Hz depending on the monitor, so with |
| 56 | ** no vsync we will get stuttering because the rate is not perfect... |
| 57 | */ |
| 58 | #define VBLANK_HZ 60 |
| 59 | |
| 60 | /* Scopes are clocked at 64Hz instead of 60Hz to prevent the small +/- Hz |
| 61 | ** interference from monitors not being exactly 60Hz (and unstable non-vsync mode). |
| 62 | ** Sadly, the scopes might mildly flicker from this in some cases. |
| 63 | */ |
| 64 | #define SCOPE_HZ 64 |
| 65 | |
| 66 | #ifndef PI |
| 67 | #define PI 3.14159265358979323846264338327950288 |
| 68 | #endif |
| 69 | |
| 70 | #define FONT_CHAR_W 8 // actual data length is 7, includes right spacing (1px column) |
| 71 | #define FONT_CHAR_H 5 |
| 72 | |
| 73 | #define MOD_ROWS 64 |
| 74 | #define MOD_SAMPLES 31 |
| 75 | #define MAX_PATTERNS 100 |
| 76 | |
| 77 | #define SCOPE_WIDTH 40 |
| 78 | #define SCOPE_HEIGHT 33 |
| 79 | #define SPECTRUM_BAR_NUM 23 |
| 80 | #define SPECTRUM_BAR_HEIGHT 36 |
| 81 | #define SPECTRUM_BAR_WIDTH 6 |
| 82 | |
| 83 | // Amount of video frames. 14 (PT on Amiga) -> 17 (converted from 49.92Hz to 60Hz) |
| 84 | #define KEYB_REPEAT_DELAY 17 |
| 85 | |
| 86 | enum |
| 87 | { |
| 88 | FLAG_NOTE = 1, |
| 89 | FLAG_SAMPLE = 2, |
| 90 | FLAG_NEWSAMPLE = 4, |
| 91 | |
| 92 | TEMPFLAG_START = 1, |
| 93 | TEMPFLAG_DELAY = 2, |
| 94 | |
| 95 | NO_CARRY = 0, |
| 96 | DO_CARRY = 1, |
| 97 | |
| 98 | INCREMENT_SLOW = 0, |
| 99 | INCREMENT_FAST = 1, |
| 100 | |
| 101 | NO_SAMPLE_CUT = 0, |
| 102 | SAMPLE_CUT = 1, |
| 103 | |
| 104 | EDIT_SPECIAL = 0, |
| 105 | EDIT_NORMAL = 1, |
| 106 | |
| 107 | EDIT_TEXT_NO_UPDATE = 0, |
| 108 | EDIT_TEXT_UPDATE = 1, |
| 109 | |
| 110 | TRANSPOSE_ALL = 1, |
| 111 | |
| 112 | MOUSE_BUTTON_NOT_HELD = 0, |
| 113 | MOUSE_BUTTON_HELD = 1, |
| 114 | |
| 115 | DONT_SET_ORDER = -1, |
| 116 | DONT_SET_PATTERN = -1, |
| 117 | DONT_SET_ROW = -1, |
| 118 | |
| 119 | REMOVE_SAMPLE_MARKING = 0, |
| 120 | KEEP_SAMPLE_MARKING = 1, |
| 121 | |
| 122 | MOD_NOT_MODIFIED = 0, |
| 123 | MOD_IS_MODIFIED = 1, |
| 124 | |
| 125 | DONT_CHECK_IF_FILE_EXIST = 0, |
| 126 | CHECK_IF_FILE_EXIST = 1, |
| 127 | |
| 128 | DONT_GIVE_NEW_FILENAME = 0, |
| 129 | GIVE_NEW_FILENAME = 1, |
| 130 | |
| 131 | DONT_DOWNSAMPLE = 0, |
| 132 | DO_DOWNSAMPLE = 1, |
| 133 | |
| 134 | SCREEN_ALL = 0, |
| 135 | SCREEN_MAINSCREEN = 1, |
| 136 | SCREEN_DISKOP = 2, |
| 137 | SCREEN_SAMPLER = 4, |
| 138 | SCREEN_QUIT = 8, |
| 139 | SCREEN_CLEAR = 16, |
| 140 | |
| 141 | VISUAL_QUADRASCOPE = 0, |
| 142 | VISUAL_SPECTRUM = 1, |
| 143 | |
| 144 | MODE_IDLE = 0, |
| 145 | MODE_EDIT = 1, |
| 146 | MODE_PLAY = 2, |
| 147 | MODE_RECORD = 3, |
| 148 | |
| 149 | RECORD_PATT = 0, |
| 150 | RECORD_SONG = 1, |
| 151 | |
| 152 | CURSOR_NOTE = 0, |
| 153 | CURSOR_SAMPLE1 = 1, |
| 154 | CURSOR_SAMPLE2 = 2, |
| 155 | CURSOR_CMD = 3, |
| 156 | CURSOR_PARAM1 = 4, |
| 157 | CURSOR_PARAM2 = 5, |
| 158 | |
| 159 | PLAY_MODE_NORMAL = 0, |
| 160 | PLAY_MODE_PATTERN = 1, |
| 161 | |
| 162 | OCTAVE_HIGH = 0, |
| 163 | OCTAVE_LOW = 1, |
| 164 | |
| 165 | DISKOP_MODE_MOD = 0, |
| 166 | DISKOP_MODE_SMP = 1, |
| 167 | |
| 168 | DISKOP_SMP_WAV = 0, |
| 169 | DISKOP_SMP_IFF = 1, |
| 170 | DISKOP_SMP_RAW = 2, |
| 171 | |
| 172 | TEMPO_MODE_CIA = 0, |
| 173 | TEMPO_MODE_VBLANK = 1, |
| 174 | |
| 175 | TEXT_EDIT_STRING = 0, |
| 176 | TEXT_EDIT_DECIMAL = 1, |
| 177 | TEXT_EDIT_HEX = 2 |
| 178 | }; |