PulkoMandy | 17fc759 | 2022-07-28 18:27:54 +0200 | [diff] [blame] | 1 | //; |
| 2 | //; sysdef.asm: This file contains definitions to simplify assembler programming |
| 3 | //; and for accessing the various hardware registers via MMIO |
| 4 | //; |
| 5 | // |
| 6 | //*************************************************************************************** |
| 7 | //* Assembler macros which make life much easier: |
| 8 | //*************************************************************************************** |
| 9 | // |
| 10 | |
| 11 | |
| 12 | // |
| 13 | // Some register short names: |
| 14 | // |
| 15 | |
| 16 | // |
| 17 | //*************************************************************************************** |
| 18 | //* IO-page addresses: Default: 8 registers per block |
| 19 | //*************************************************************************************** |
| 20 | // |
| 21 | #define IO_AREA_START 0xFF00 |
| 22 | // |
| 23 | //--------------------------------------------------------------------------------------- |
| 24 | // Block FF00: FUNDAMENTAL IO |
| 25 | //--------------------------------------------------------------------------------------- |
| 26 | // |
| 27 | // Switch-register: |
| 28 | // |
| 29 | #define IO_SWITCH_REG 0xFF00 // 16 binary keys |
| 30 | // |
| 31 | // Registers for TIL-display: |
| 32 | // |
| 33 | #define IO_TIL_DISPLAY 0xFF01 // Address of TIL-display |
| 34 | #define IO_TIL_MASK 0xFF02 // Mask register of TIL display |
| 35 | // |
| 36 | // USB-keyboard-registers: |
| 37 | // |
| 38 | #define IO_KBD_STATE 0xFF04 // Status register of USB keyboard |
| 39 | // Bit 0 (read only): New ASCII character avaiable for reading |
| 40 | // (bits 7 downto 0 of Read register) |
| 41 | // Bit 1 (read only): New special key available for reading |
| 42 | // (bits 15 downto 8 of Read register) |
| 43 | // Bits 2..4 (read/write): Locales: 000 = US English keyboard layout, |
| 44 | // 001 = German layout, others: reserved for more locales |
| 45 | // Bits 5..7 (read only): Modifiers: 5 = shift, 6 = alt, 7 = ctrl |
| 46 | // Only valid, when bits 0 and/or 1 are '1' |
| 47 | // |
| 48 | #define IO_KBD_DATA 0xFF05 // Data register of USB keyboard |
| 49 | // Contains the ASCII character in bits 7 downto 0 or the special key code |
| 50 | // in 15 downto 8. The "or" is meant exclusive, i.e. it cannot happen that |
| 51 | // one transmission contains an ASCII character PLUS a special character. |
| 52 | // |
| 53 | //--------------------------------------------------------------------------------------- |
| 54 | // Block FF08: SYSTEM COUNTERS |
| 55 | //--------------------------------------------------------------------------------------- |
| 56 | // |
| 57 | // CYCLE-COUNT-registers |
| 58 | // |
| 59 | #define IO_CYC_LO 0xFF08 // low word of 48-bit counter |
| 60 | #define IO_CYC_MID 0xFF09 // middle word of 48-bit counter |
| 61 | #define IO_CYC_HI 0xFF0A // high word of 48-bit counter |
| 62 | #define IO_CYC_STATE 0xFF0B // status register |
| 63 | // Bit 0 (write only): Reset counter to zero and start counting, i.e. |
| 64 | // bit 1 is automatically set to 1 when resetting |
| 65 | // Bit 1 (read/write): Start/stop counter |
| 66 | // |
| 67 | // INSTRUCTION-COUNT-registers |
| 68 | // |
| 69 | #define IO_INS_LO 0xFF0C // low word of 48-bit counter |
| 70 | #define IO_INS_MID 0xFF0D // middle word of 48-bit counter |
| 71 | #define IO_INS_HI 0xFF0E // high word of 48-bit counter |
| 72 | #define IO_INS_STATE 0xFF0F // status register |
| 73 | // Bit 0 (write only): Reset counter to zero and start counting, i.e. |
| 74 | // bit 1 is automatically set to 1 when resetting |
| 75 | // Bit 1 (read/write): Start/stop counter |
| 76 | // |
| 77 | //--------------------------------------------------------------------------------------- |
| 78 | // Block FF10: UART |
| 79 | //--------------------------------------------------------------------------------------- |
| 80 | // |
| 81 | // QNICE-FPGA supports: IO_UART_SRA, IO_UART_RHRA and IO_UART_THRA |
| 82 | // The other registers are mentioned for completeness to map real hardware (16550) |
| 83 | // |
| 84 | #define IO_UART_BASE_ADDRESS 0xFF10 |
| 85 | #define IO_UART_MR1A 0xFF10 // n/a |
| 86 | #define IO_UART_MR1B 0xFF10 // n/a |
| 87 | #define IO_UART_SRA 0xFF11 // Status register (relative to base address) |
| 88 | #define IO_UART_RHRA 0xFF12 // Receiving register (relative to base address) |
| 89 | #define IO_UART_THRA 0xFF13 // Transmitting register (relative to base address) |
| 90 | // |
| 91 | //--------------------------------------------------------------------------------------- |
| 92 | // Block FF18: EAE |
| 93 | //--------------------------------------------------------------------------------------- |
| 94 | // |
| 95 | // EAE (Extended Arithmetic Element) registers: |
| 96 | // |
| 97 | #define IO_EAE_OPERAND_0 0xFF18 |
| 98 | #define IO_EAE_OPERAND_1 0xFF19 |
| 99 | #define IO_EAE_RESULT_LO 0xFF1A |
| 100 | #define IO_EAE_RESULT_HI 0xFF1B |
| 101 | #define IO_EAE_CSR 0xFF1C // Command and Status Register |
| 102 | // |
| 103 | // EAE-Opcodes (CSR): 0x0000 MULU 32-bit result in LO HI |
| 104 | // 0x0001 MULS 32-bit result in LO HI |
| 105 | // 0x0002 DIVU result in LO, modulo in HI |
| 106 | // 0x0003 DIVS result in LO, modulo in HI |
| 107 | // Bit 15 of CSR is the busy bit. If it is set, the EAE is still busy crunching numbers. |
| 108 | // |
| 109 | //--------------------------------------------------------------------------------------- |
| 110 | // Block FF20: SD CARD |
| 111 | //--------------------------------------------------------------------------------------- |
| 112 | // |
| 113 | // SD CARD INTERFACE registers |
| 114 | // |
| 115 | #define IO_SD_BASE_ADDRESS 0xFF20 |
| 116 | #define IO_SD_ADDR_LO 0xFF20 // low word of 32bit linear SD card block address |
| 117 | #define IO_SD_ADDR_HI 0xFF21 // high word of 32bit linear SD card block address |
| 118 | #define IO_SD_DATA_POS 0xFF22 // "Cursor" to navigate the 512-byte data buffer |
| 119 | #define IO_SD_DATA 0xFF23 // read/write 1 byte from/to the 512-byte data buffer |
| 120 | #define IO_SD_ERROR 0xFF24 // error code of last operation (read only) |
| 121 | #define IO_SD_CSR 0xFF25 // Command and Status Register (write to execute command) |
| 122 | // |
| 123 | // SD-Opcodes (CSR): 0x0000 Reset SD card |
| 124 | // 0x0001 Read 512 bytes from the linear block address |
| 125 | // 0x0002 Write 512 bytes to the linear block address |
| 126 | // Bits 0 .. 2 are write-only (reading always returns 0) |
| 127 | // Bits 13 .. 12 return the card type: 00 = no card / unknown card |
| 128 | // 01 = SD V1 |
| 129 | // 10 = SD V2 |
| 130 | // 11 = SDHC |
| 131 | // Bit 14 of the CSR is the error bit: 1, if the last operation failed. In such |
| 132 | // a case, the error code is in IO_SD_ERROR and |
| 133 | // you need to reset the controller to go on |
| 134 | // Bit 15 of the CSR is the busy bit: 1, if current operation is still running |
| 135 | // |
| 136 | //--------------------------------------------------------------------------------------- |
| 137 | // Block FF28: TIMER 0 and 1 |
| 138 | //--------------------------------------------------------------------------------------- |
| 139 | // |
| 140 | // Interrupt timer: There are two timers capable of generating interrupts. |
| 141 | // Each timer is controlled by three 16 bit registers: |
| 142 | // |
| 143 | // IO_TIMER_x_PRE: The 100 kHz timer clock is divided by the value stored in |
| 144 | // this device register. 100 (which corresponds to 0x0064 in |
| 145 | // the prescaler register) yields a 1 millisecond pulse which |
| 146 | // in turn is fed to the actual counter. |
| 147 | // IO_TIMER_x_CNT: When the number of output pulses from the prescaler circuit |
| 148 | // equals the number stored in this register, an interrupt will |
| 149 | // be generated (if the interrupt address is 0x0000, the |
| 150 | // interrupt will be suppressed). |
| 151 | // IO_TIMER_x_INT: This register contains the address of the desired interrupt |
| 152 | // service routine. |
| 153 | // |
| 154 | #define IO_TIMER_BASE_ADDRESS 0xFF28 |
| 155 | #define IO_TIMER_0_PRE 0xFF28 |
| 156 | #define IO_TIMER_0_CNT 0xFF29 |
| 157 | #define IO_TIMER_0_INT 0xFF2A |
| 158 | #define IO_TIMER_1_PRE 0xFF2B |
| 159 | #define IO_TIMER_1_CNT 0xFF2C |
| 160 | #define IO_TIMER_1_INT 0xFF2D |
| 161 | // |
| 162 | //--------------------------------------------------------------------------------------- |
| 163 | // Block FF30: VGA (double block, 16 registers) |
| 164 | //--------------------------------------------------------------------------------------- |
| 165 | // |
| 166 | #define VGA_STATE 0xFF30 // VGA status register |
| 167 | // Bits 11-10: Hardware scrolling / offset enable: Bit #10 enables the use |
| 168 | // of the offset register #4 (display offset) and bit #11 |
| 169 | // enables the use of register #5 (read/write offset). |
| 170 | // Bit 9: Busy: VGA is currently busy, e.g. clearing the screen, |
| 171 | // printing, etc. While busy, commands will be ignored, but |
| 172 | // they can still be written into the registers, though |
| 173 | // Bit 8: Set bit to clear screen. Read bit to find out, if clear |
| 174 | // screen is still active |
| 175 | // Bit 7: VGA enable (1 = on; 0: no VGA signal is generated) |
| 176 | // Bit 6: Hardware cursor enable |
| 177 | // Bit 5: Hardware cursor blink enable |
| 178 | // Bit 4: Hardware cursor mode: 1 - small |
| 179 | // 0 - large |
| 180 | // Bits 2-0: Output color for the whole screen, bits (2, 1, 0) = RGB |
| 181 | #define VGA_CR_X 0xFF31 // VGA cursor X position |
| 182 | #define VGA_CR_Y 0xFF32 // VGA cursor Y position |
| 183 | #define VGA_CHAR 0xFF33 // write: VGA character to be displayed |
| 184 | // read: character "under" the cursor |
| 185 | #define VGA_OFFS_DISPLAY 0xFF34 // Offset in bytes that is used when displaying |
| 186 | // the video RAM. Scrolling forward one line |
| 187 | // means adding 0x50 to this register. |
| 188 | // Only works, if bit #10 in VGA_STATE is set. |
| 189 | #define VGA_OFFS_RW 0xFF35 // Offset in bytes that is used, when you read |
| 190 | // or write to the video RAM using VGA_CHAR. |
| 191 | // Works independently from VGA_OFFS_DISPLAY. |
| 192 | // Active, when bit #11 in VGA_STATE is set. |
| 193 | #define VGA_HDMI_H_MIN 0xFF36 // HDMI Data Enable: X: minimum valid column |
| 194 | #define VGA_HDMI_H_MAX 0xFF37 // HDMI Data Enable: X: maximum valid column |
| 195 | #define VGA_HDMI_V_MAX 0xFF38 // HDMI Data Enable: Y: maximum row (line) |
| 196 | // |
| 197 | //--------------------------------------------------------------------------------------- |
| 198 | // Block FFF0: MEGA65 (double block, 16 registers) |
| 199 | //--------------------------------------------------------------------------------------- |
| 200 | // |
| 201 | // HyperRAM |
| 202 | // |
| 203 | #define IO_M65HRAM_LO 0xFFF0 // Low word of address (15 downto 0) |
| 204 | #define IO_M65HRAM_HI 0xFFF1 // High word of address (26 downto 16) |
| 205 | #define IO_M65HRAM_DATA8 0xFFF2 // HyperRAM native 8-bit data in/out |
| 206 | #define IO_M65HRAM_DATA16 0xFFF3 // HyperRAM 16-bit data in/out |
| 207 | |
| 208 | // |
| 209 | //*************************************************************************************** |
| 210 | //* Constant definitions |
| 211 | //*************************************************************************************** |
| 212 | // |
| 213 | |
| 214 | // ========== VGA ========== |
| 215 | |
| 216 | #define VGA_MAX_X 79 // Max. X-coordinate in decimal! |
| 217 | #define VGA_MAX_Y 39 // Max. Y-coordinate in decimal! |
| 218 | #define VGA_MAX_CHARS 3200 // 80 * 40 chars |
| 219 | #define VGA_CHARS_PER_LINE 80 |
| 220 | |
| 221 | #define VGA_EN_HW_CURSOR 0x0040 // Show hardware cursor |
| 222 | #define VGA_EN_HW_SCRL 0x0C00 // Hardware scrolling enable |
| 223 | #define VGA_CLR_SCRN 0x0100 // Clear screen |
| 224 | #define VGA_BUSY 0x0200 // VGA is currently performing a task |
| 225 | |
| 226 | #define VGA_COLOR_RED 0x0004 |
| 227 | #define VGA_COLOR_GREEN 0x0002 |
| 228 | #define VGA_COLOR_BLUE 0x0001 |
| 229 | #define VGA_COLOR_WHITE 0x0007 |
| 230 | |
| 231 | // ========== CYCLE COUNTER ========== |
| 232 | |
| 233 | #define CYC_RESET 0x0001 // Reset cycle counter |
| 234 | #define CYC_RUN 0x0002 // Start/stop counter |
| 235 | |
| 236 | // ========== CYCLE COUNTER ========== |
| 237 | |
| 238 | #define INS_RESET 0x0001 // Reset instruction counter |
| 239 | #define INS_RUN 0x0002 // Start/stop counter |
| 240 | |
| 241 | // ========== EAE ========== |
| 242 | |
| 243 | #define EAE_MULU 0x0000 // Unsigned 16 bit multiplication |
| 244 | #define EAE_MULS 0x0001 // Signed 16 bit multiplication |
| 245 | #define EAE_DIVU 0x0002 // Unsigned 16 bit division with remainder |
| 246 | #define EAE_DIVS 0x0003 // Signed 16 bit division with remainder |
| 247 | #define EAE_BUSY 0x8000 // Busy flag (1 = operation still running) |
| 248 | |
| 249 | // ========== SD CARD ========== |
| 250 | |
| 251 | #define SD_CMD_RESET 0x0000 // Reset SD card |
| 252 | #define SD_CMD_READ 0x0001 // Read 512 bytes from SD to internal buffer |
| 253 | #define SD_CMD_WRITE 0x0002 // Write 512 bytes from int. buf. to SD |
| 254 | #define SD_BIT_ERROR 0x4000 // Error flag: 1, if last operation failed |
| 255 | #define SD_BIT_BUSY 0x8000 // Busy flag: 1, if current op. is still running |
| 256 | #define SD_TIMEOUT_MID 0x0479 // equals ~75.000.000 cycles, i.e. 1.5sec @ 50 MHz |
| 257 | |
| 258 | #define SD_ERR_MASK 0x00FF // AND mask for errors: HI byte = state machine info, so mask it for error checks |
| 259 | #define SD_ERR_R1_ERROR 0x0001 // SD Card R1 error (R1 bit 6-0) |
| 260 | #define SD_ERR_CRC_OR_TIMEOUT 0x0002 // Read CRC error or Write Timeout error |
| 261 | #define SD_ERR_RESPONSE_TOKEN 0x0003 // Data Response Token error (Token bit 3) |
| 262 | #define SD_ERR_ERROR_TOKEN 0x0004 // Data Error Token error (Token bit 3-0) |
| 263 | #define SD_ERR_WRITE_PROTECT 0x0005 // SD Card Write Protect switch |
| 264 | #define SD_ERR_CARD_UNUSABLE 0x0006 // Unusable SD card |
| 265 | #define SD_ERR_NO_CARD 0x0007 // No SD card (no response from CMD0) |
| 266 | #define SD_ERR_READ_TIMEOUT 0x0008 // Timeout while trying to receive the read start token "FE" |
| 267 | #define SD_ERR_TIMEOUT 0xEEFF // General timeout |
| 268 | |
| 269 | #define SD_CT_SD_V1 0x0001 // Card type: SD Version 1 |
| 270 | #define SD_CT_SD_V2 0x0002 // Card type: SD Version 2 |
| 271 | #define SD_CT_SDHC 0x0003 // Card type: SDHC (or SDXC) |
| 272 | |
| 273 | // ========== FAT32 ============= |
| 274 | |
| 275 | // FAT32 ERROR CODES |
| 276 | |
| 277 | #define FAT32_ERR_MBR 0xEE10 // no or illegal Master Boot Record (MBR) found |
| 278 | #define FAT32_ERR_PARTITION_NO 0xEE11 // the partition number needs to be in the range 1 .. 4 |
| 279 | #define FAT32_ERR_PARTTBL 0xEE12 // no or illegal partition table entry found (e.g. no FAT32 partition) |
| 280 | #define FAT32_ERR_NOTIMPL 0xEE13 // functionality is not implemented |
| 281 | #define FAT32_ERR_SIZE 0xEE14 // partition size or volume size too large (see doc/constraints.txt) |
| 282 | #define FAT32_ERR_NOFAT32 0xEE15 // illegal volume id (either not 512 bytes per sector, or not 2 FATs or wrong magic) |
| 283 | #define FAT32_ERR_ILLEGAL_SIC 0xEE16 // trying to read/write a sector within a cluster that is out of range |
| 284 | #define FAT32_ERR_ILLEGAL_CLUS 0xEE17 // trying to access an illegal cluster number |
| 285 | #define FAT32_ERR_CORRUPT_DH 0xEE18 // corrupt directory handle (e.g. because current to-be-read offs > sector size) |
| 286 | #define FAT32_ERR_DIRNOTFOUND 0xEE19 // directory not found (illegal path name passed to change directory command) |
| 287 | #define FAT32_ERR_FILENOTFOUND 0xEE20 // file not found |
| 288 | #define FAT23_ERR_SEEKTOOLARGE 0xEE21 // seek position > file size |
| 289 | |
| 290 | // FAT32 STATUS CODES |
| 291 | |
| 292 | #define FAT32_EOF 0xEEEE // end of file reached |
| 293 | |
| 294 | // LAYOUT OF THE MOUNT DATA STRUCTURE (DEVICE HANDLE) |
| 295 | |
| 296 | #define FAT32_DEV_RESET 0x0000 // pointer to device reset function |
| 297 | #define FAT32_DEV_BLOCK_READ 0x0001 // pointer to 512-byte block read function |
| 298 | #define FAT32_DEV_BLOCK_WRITE 0x0002 // pointer to 512-byte block write function |
| 299 | #define FAT32_DEV_BYTE_READ 0x0003 // pointer to 1-byte read function (within block buffer) |
| 300 | #define FAT32_DEV_BYTE_WRITE 0x0004 // pointer to 1-byte write function (within block buffer) |
| 301 | #define FAT32_DEV_PARTITION 0x0005 // number of partition to be mounted |
| 302 | #define FAT32_DEV_FS_LO 0x0006 // file system start address (LBA): low word |
| 303 | #define FAT32_DEV_FS_HI 0x0007 // file system start address (LBA): high word |
| 304 | #define FAT32_DEV_FAT_LO 0x0008 // fat start address (LBA): low word |
| 305 | #define FAT32_DEV_FAT_HI 0x0009 // fat start address (LBA): high word |
| 306 | #define FAT32_DEV_CLUSTER_LO 0x000A // cluster start address (LBA): low word |
| 307 | #define FAT32_DEV_CLUSTER_HI 0x000B // cluster start address (LBA): high word |
| 308 | #define FAT32_DEV_SECT_PER_CLUS 0x000C // sectors per cluster |
| 309 | #define FAT32_DEV_RD_1STCLUS_LO 0x000D // root directory first cluster: low word |
| 310 | #define FAT32_DEV_RD_1STCLUS_HI 0x000E // root directory first cluster: high word |
| 311 | #define FAT32_DEV_AD_1STCLUS_LO 0x000F // currently active directory first cluster: low word |
| 312 | #define FAT32_DEV_AD_1STCLUS_HI 0x0010 // currently active directory first cluster: high word |
| 313 | #define FAT32_DEV_BUFFERED_FDH 0x0011 // FDH which is responsible for the current 512 byte hardware buffer filling |
| 314 | |
| 315 | #define FAT32_DEV_STRUCT_SIZE 0x0012 // size (words) of the mount data structure (device handle) |
| 316 | |
| 317 | // LAYOUT OF THE FILE HANDLE AND DIRECTORY HANDLE (FDH) |
| 318 | |
| 319 | #define FAT32_FDH_DEVICE 0x0000 // pointer to the device handle |
| 320 | #define FAT32_FDH_CLUSTER_LO 0x0001 // current cluster (low word) |
| 321 | #define FAT32_FDH_CLUSTER_HI 0x0002 // current cluster (high word) |
| 322 | #define FAT32_FDH_SECTOR 0x0003 // current sector |
| 323 | #define FAT32_FDH_INDEX 0x0004 // current byte index within current sector |
| 324 | #define FAT32_FDH_SIZE_LO 0x0005 // only in case FDH is a file: low word of file size, otherwise undefined |
| 325 | #define FAT32_FDH_SIZE_HI 0x0006 // only in case FDH is a file: high word of file size, otherwise undefined |
| 326 | #define FAT32_FDH_READ_LO 0x0007 // only in case FDH is a file: low word of already read amount of bytes |
| 327 | #define FAT32_FDH_READ_HI 0x0008 // only in case FDH is a file: high word of already read amount of bytes |
| 328 | |
| 329 | #define FAT32_FDH_STRUCT_SIZE 0x0009 // size of the directory handle structure |
| 330 | |
| 331 | // FILE ATTRIBUTES |
| 332 | |
| 333 | #define FAT32_FA_READ_ONLY 0x0001 // read only file |
| 334 | #define FAT32_FA_HIDDEN 0x0002 // hidden file |
| 335 | #define FAT32_FA_SYSTEM 0x0004 // system file |
| 336 | #define FAT32_FA_VOLUME_ID 0x0008 // volume id (name of the volume) |
| 337 | #define FAT32_FA_DIR 0x0010 // directory |
| 338 | #define FAT32_FA_ARCHIVE 0x0020 // archive flag |
| 339 | |
| 340 | #define FAT32_FA_DEFAULT 0x0035 // browse for non hidden files and directories but not for the volume id |
| 341 | #define FAT32_FA_ALL 0x0037 // browse for all files, but not for the volume id |
| 342 | |
| 343 | // LAYOUT OF THE DIRECTORY ENTRY STRUCTURE |
| 344 | |
| 345 | #define FAT32_DE_NAME 0x0000 // volume, file or directory name, zero terminated (max 256 characters) |
| 346 | #define FAT32_DE_ATTRIB 0x0101 // file attributes (read-only, hidden, system, volume id, directory, archive) |
| 347 | #define FAT32_DE_SIZE_LO 0x0102 // file size: low word |
| 348 | #define FAT32_DE_SIZE_HI 0x0103 // file size: high word |
| 349 | #define FAT32_DE_YEAR 0x0104 // last file write: year (valid range 1980 .. 2107) |
| 350 | #define FAT32_DE_MONTH 0x0105 // last file write: month |
| 351 | #define FAT32_DE_DAY 0x0106 // last file write: day |
| 352 | #define FAT32_DE_HOUR 0x0107 // last file write: hour |
| 353 | #define FAT32_DE_MINUTE 0x0108 // last file write: minute |
| 354 | #define FAT32_DE_SECOND 0x0109 // last file write: second (in 2 second steps, valid range 0 .. 58) |
| 355 | #define FAT32_DE_CLUS_LO 0x010A // start cluster: low word |
| 356 | #define FAT32_DE_CLUS_HI 0x010B // start cluster: high word |
| 357 | |
| 358 | #define FAT32_DE_STRUCT_SIZE 0x010C // size (words) of the directory entry data structure of the |
| 359 | |
| 360 | // DISPLAY FLAGS FOR FILE ENTRY PRETTY PRINTER |
| 361 | |
| 362 | #define FAT32_PRINT_SHOW_DIR 0x0001 // show "<DIR>" indicator |
| 363 | #define FAT32_PRINT_SHOW_ATTRIB 0x0002 // show attributes as "HRSA" |
| 364 | #define FAT32_PRINT_SHOW_SIZE 0x0004 // show file size |
| 365 | #define FAT32_PRINT_SHOW_DATE 0x0008 // show file date as YYYY-MM-DD |
| 366 | #define FAT32_PRINT_SHOW_TIME 0x0010 // show file time as HH:MM |
| 367 | |
| 368 | #define FAT32_PRINT_DEFAULT 0x001D // print <DIR> indicator, size, date and time (no attributes) |
| 369 | #define FAT32_PRINT_ALL 0x001F // print all details |
| 370 | |
| 371 | // ========== KEYBOARD ========== |
| 372 | |
| 373 | // STATUS REGISTER |
| 374 | |
| 375 | #define KBD_NEW_ASCII 0x0001 // new ascii character available |
| 376 | #define KBD_NEW_SPECIAL 0x0002 // new special key available |
| 377 | #define KBD_NEW_ANY 0x0003 // any new key available |
| 378 | |
| 379 | #define KBD_ASCII 0x00FF // mask the special keys |
| 380 | #define KBD_SPECIAL 0xFF00 // mask the ascii keys |
| 381 | |
| 382 | #define KBD_LOCALE 0x001C // bit mask for checking locales |
| 383 | #define KBD_LOCALE_US 0x0000 // default: US keyboard layout |
| 384 | #define KBD_LOCALE_DE 0x0004 // DE: German keyboard layout |
| 385 | |
| 386 | #define KBD_MODIFIERS 0x00E0 // bit mask for checking modifiers |
| 387 | #define KBD_SHIFT 0x0020 // modifier "SHIFT" pressed |
| 388 | #define KBD_ALT 0x0040 // modifier "ALT" pressed |
| 389 | #define KBD_CTRL 0x0080 // modifier "CTRL" pressed |
| 390 | |
| 391 | // READ REGISTER: COMMON ASCII CODES |
| 392 | |
| 393 | #define KBD_SPACE 0x0020 |
| 394 | #define KBD_ENTER 0x000D |
| 395 | #define KBD_ESC 0x001B |
| 396 | #define KBD_TAB 0x0009 |
| 397 | #define KBD_BACKSPACE 0x0008 |
| 398 | |
| 399 | // READ REGISTER: SPECIAL KEYS |
| 400 | |
| 401 | #define KBD_F1 0x0100 |
| 402 | #define KBD_F2 0x0200 |
| 403 | #define KBD_F3 0x0300 |
| 404 | #define KBD_F4 0x0400 |
| 405 | #define KBD_F5 0x0500 |
| 406 | #define KBD_F6 0x0600 |
| 407 | #define KBD_F7 0x0700 |
| 408 | #define KBD_F8 0x0800 |
| 409 | #define KBD_F9 0x0900 |
| 410 | #define KBD_F10 0x0A00 |
| 411 | #define KBD_F11 0x0B00 |
| 412 | #define KBD_F12 0x0C00 |
| 413 | |
| 414 | #define KBD_CUR_UP 0x1000 |
| 415 | #define KBD_CUR_DOWN 0x1100 |
| 416 | #define KBD_CUR_LEFT 0x1200 |
| 417 | #define KBD_CUR_RIGHT 0x1300 |
| 418 | #define KBD_PG_UP 0x1400 |
| 419 | #define KBD_PG_DOWN 0x1500 |
| 420 | #define KBD_HOME 0x1600 |
| 421 | #define KBD_END 0x1700 |
| 422 | #define KBD_INS 0x1800 |
| 423 | #define KBD_DEL 0x1900 |
| 424 | |
| 425 | // READ REGISTER: CTRL + character is also mapped to an ASCII code |
| 426 | |
| 427 | #define KBD_CTRL_A 0x0001 |
| 428 | #define KBD_CTRL_B 0x0002 |
| 429 | #define KBD_CTRL_C 0x0003 |
| 430 | #define KBD_CTRL_D 0x0004 |
| 431 | #define KBD_CTRL_E 0x0005 |
| 432 | #define KBD_CTRL_F 0x0006 |
| 433 | #define KBD_CTRL_G 0x0007 |
| 434 | #define KBD_CTRL_H 0x0008 |
| 435 | #define KBD_CTRL_I 0x0009 |
| 436 | #define KBD_CTRL_J 0x000A |
| 437 | #define KBD_CTRL_K 0x000B |
| 438 | #define KBD_CTRL_L 0x000C |
| 439 | #define KBD_CTRL_M 0x000D |
| 440 | #define KBD_CTRL_N 0x000E |
| 441 | #define KBD_CTRL_O 0x000F |
| 442 | #define KBD_CTRL_P 0x0010 |
| 443 | #define KBD_CTRL_Q 0x0011 |
| 444 | #define KBD_CTRL_R 0x0012 |
| 445 | #define KBD_CTRL_S 0x0013 |
| 446 | #define KBD_CTRL_T 0x0014 |
| 447 | #define KBD_CTRL_U 0x0015 |
| 448 | #define KBD_CTRL_V 0x0016 |
| 449 | #define KBD_CTRL_W 0x0017 |
| 450 | #define KBD_CTRL_X 0x0018 |
| 451 | #define KBD_CTRL_Y 0x0019 |
| 452 | #define KBD_CTRL_Z 0x001A |
| 453 | |
| 454 | // |
| 455 | // Useful ASCII constants: |
| 456 | // |
| 457 | #define CHR_BELL 0x0007 // ASCII-BELL character |
| 458 | #define CHR_TAB 0x0009 // ASCII-TAB character |
| 459 | #define CHR_SPACE 0x0020 // ASCII-Space |
| 460 | #define CHR_CR 0x000d // Carriage return |
| 461 | #define CHR_LF 0x000a // Line feed |