Foenix A2650 OS/f Library
 
Loading...
Searching...
No Matches
a2560k.h
1/*
2 * a2560_platform.h
3 *
4 * Created on: Feb 19, 2022
5 * Author: micahbly
6 */
7
8#ifndef A2560_PLATFORM_H_
9#define A2560_PLATFORM_H_
10
11
12/* about this class
13 *
14 *
15 *
16 *** things this class needs to be able to do
17 * nothing - this is not a functional class, but a set of useful headers providing structs and defines useful for developing on the A2560 platform
18 *
19 *** things objects of this class have
20 *
21 *
22 */
23
24
25/*****************************************************************************/
26/* Includes */
27/*****************************************************************************/
28
29#include <stdint.h>
30
31
32/*****************************************************************************/
33/* Macro Definitions */
34/*****************************************************************************/
35
36//
37// // eliminate __huge extension keyword unless we are building with Calypsi for 65816
38// #if defined(__VBCC__)
39// #define __huge
40// #endif
41
42#define ID_CHANNEL_A 0 // for use in text() calls, etc.
43#define ID_CHANNEL_B 1 // for use in text() calls, etc.
44
45// A2560 OTHER
46#define EA_MCP (char*)0x010000 // start of MCP kernel
47#define EA_USER (char*)0x020000 // start of user space. ie, put your program here.
48
49
50// adapted from vinz67
51#define R8(x) *((volatile __far uint8_t* const)(x)) // make sure we read an 8 bit byte; for VICKY registers, etc.
52#define P8(x) (volatile __far uint8_t* const)(x) // make sure we read an 8 bit byte; for VICKY registers, etc.
53#define R16(x) *((volatile __far uint16_t* const)(x)) // make sure we read an 16 bit byte; for RNG etc.
54#define P16(x) (volatile __far uint16_t* const)(x) // make sure we read an 16 bit short; for VICKY registers, etc.
55#define R32(x) *((volatile __far uint32_t* const)(x)) // make sure we read an 32 bit byte;
56#define P32(x) (volatile __far uint32_t* const)(x) // make sure we read a 32 bit long; for VICKY registers, etc.
57// and near variants. keeping far variants as regular "R8", etc, for backwards compatibility with other 6502 code of mine
58#define NR8(x) *((volatile uint8_t* const)(x)) // make sure we read an 8 bit byte; for VICKY registers, etc.
59#define NP8(x) (volatile uint8_t* const)(x) // make sure we read an 8 bit byte; for VICKY registers, etc.
60#define NR16(x) *((volatile uint16_t* const)(x)) // make sure we read an 16 bit byte; for RNG etc.
61#define NP16(x) (volatile uint16_t* const)(x) // make sure we read an 16 bit byte; for VICKY registers, etc.
62#define NR32(x) *((volatile uint32_t* const)(x)) // make sure we read an 32 bit byte; for RNG etc.
63#define NP32(x) (volatile uint32_t* const)(x) // make sure we read an 32 bit byte; for VICKY registers, etc.
64
65#define TEXT_COL_COUNT_FOR_PLOTTING_A2560K 100 // regardless of visible cols (between borders), VRAM seems to be fixed at 80 cols across.
66#define TEXT_ROW_COUNT_FOR_PLOTTING_A2560K 75 // regardless of visible rows (between borders), VRAM seems to be fixed at 60 rows up/down.
67#define TEXT_COL_COUNT_FOR_PLOTTING TEXT_COL_COUNT_FOR_PLOTTING_A2560K // regardless of visible cols (between borders), VRAM seems to be fixed at 80 cols across.
68#define TEXT_ROW_COUNT_FOR_PLOTTING TEXT_ROW_COUNT_FOR_PLOTTING_A2560K // regardless of visible rows (between borders), VRAM seems to be fixed at 60 rows up/down.
69
70#define TEXT_ROW_COUNT_60HZ 60
71#define TEXT_ROW_COUNT_70HZ 50
72#define TEXT_ROW_COUNT_DEBUG_SCREEN 75 // for A2560K only, the "debug" screen that runs text-only at 800x600
73
74#define TEXT_FONT_WIDTH 8 // for text mode, the width of the fixed-sized font chars
75#define TEXT_FONT_HEIGHT 8 // for text mode, the height of the fixed-sized font chars.
76#define TEXT_FONT_BYTE_SIZE (8*256)
77
78// general
79#define MAX_STRING_COMP_LEN 256
80
81// word-wrap and string measurement related
82#define GEN_NO_STRLEN_CAP -1
83#define WORD_WRAP_MAX_LEN 12800
84
85// file-related
86#define FILE_MAX_PATHNAME_SIZE 260 // https://www.keil.com/pack/doc/mw/FileSystem/html/fat_fs.html
87
88
89#define VIDEO_MODE_BYTE 0x01
90#define VIDEO_MODE_BIT1 0x01
91// from Stefany on 2022/03/06 discord:
92// Channel B bit 8 and 9 are the bit that select the video mode. 640x480, 800x600 and 640x400. No 1024x768
93// Channel A bit 8 and 9 are ignored
94// It is bit 11 that gives you the choice between 800x600 or 1024x768.
95#define VIDEO_MODE_BIT2 0x02
96#define GAMMA_MODE_ONOFF_BITS 0x03
97
98 #define BORDER_X_MASK 0xFFFF00FF
99 #define BORDER_Y_MASK 0xFF00FFFF
100 #define BORDER_CTRL_OFFSET_L 0x01
101 #define BORDER_COLOR_OFFSET_L 0x02
102 #define BACKGROUND_COLOR_OFFSET_L 0x03
103 #define CURSOR_CTRL_OFFSET_L 0x04
104 #define CURSOR_POS_OFFSET_L 0x04
105 #define LN_INTERRUPT_01_OFFSET_L 0x05
106 #define BITMAP_L0_CTRL_L 0x40
107 #define BITMAP_L0_VRAM_ADDR_OFFSET_L 0x41
108 #define BITMAP_L1_CTRL_L 0x42
109 #define BITMAP_L1_VRAM_ADDR_OFFSET_L 0x43
110 #define CLUT0_OFFSET 8192 // 0x2000 //!> the offset from the VICKY control register to the first CLUT RAM space
111 #define CLUT1_OFFSET (CLUT0_OFFSET + 1024)
112 #define CLUT2_OFFSET (CLUT1_OFFSET + 1024)
113 #define CLUT3_OFFSET (CLUT2_OFFSET + 1024)
114 #define CLUT4_OFFSET (CLUT3_OFFSET + 1024)
115 #define CLUT5_OFFSET (CLUT4_OFFSET + 1024)
116 #define CLUT6_OFFSET (CLUT5_OFFSET + 1024)
117 #define CLUT7_OFFSET (CLUT6_OFFSET + 1024)
118
119
120 // ** C256 (VICKY II)
121
122 // byte swapper: 68000 is big endian; 65816 is little endian
123 #define BSWAP(word) ( (((word) >> 8) & 0x00FF) | (((word) << 8) & 0xFF00) )
124
125 #define VICKY_C256 0x00af0000 // Vicky II offset/first register
126 #define VICKY_II_MASTER_CTRL_REG_L 0x00af0000 // Vicky II Master Control Register - low - graphic mode/text mode/etc.
127 #define VICKY_II_MASTER_CTRL_REG_H 0x00af0001 // Vicky II Master Control Register - high - screen res, etc.
128 #define VICKY_II_GAMMA_CTRL_REG 0x00af0002 // Vicky II Gamma Control Register
129 #define VICKY_II_BORDER_CTRL_REG 0x00af0004 // Vicky II Border Control Register
130 #define VICKY_II_BORDER_COLOR_B 0x00af0005 // Vicky II Border Color Blue
131 #define VICKY_II_BORDER_COLOR_G 0x00af0006 // Vicky II Border Color Green
132 #define VICKY_II_BORDER_COLOR_R 0x00af0007 // Vicky II Border Color Red
133 #define VICKY_II_BORDER_X_SIZE 0x00af0008 // Vicky II Border X size in pixels
134 #define VICKY_II_BORDER_Y_SIZE 0x00af0009 // Vicky II Border Y size in pixels
135
136 #define VICKY_II_BACKGROUND_COLOR_B 0x00af000D // Vicky II background color Blue
137 #define VICKY_II_BACKGROUND_COLOR_G 0x00af000E // Vicky II background color Green
138 #define VICKY_II_BACKGROUND_COLOR_R 0x00af000F // Vicky II background color Red
139
140 #define BITMAP_L0_CTRL 0x00af0100
141 #define BITMAP_L0_VRAM_ADDR_L 0x00af0101
142 #define BITMAP_L0_VRAM_ADDR_M 0x00af0102
143 #define BITMAP_L0_VRAM_ADDR_H 0x00af0103
144 #define BITMAP_L1_CTRL 0x00af0108
145 #define BITMAP_L1_VRAM_ADDR_L 0x00af0109
146 #define BITMAP_L1_VRAM_ADDR_M 0x00af010A
147 #define BITMAP_L1_VRAM_ADDR_H 0x00af010B
148
149 #define TEXT_RAM_C256 (char*)0xafa000 // CS_TEXT_MEM_PTR Text Memory Block
150 #define TEXT_ATTR_C256 (char*)0xafc000 // CS_COLOR_MEM_PTR Color Text Memory Block
151 #define TEXT_FORE_LUT_C256 (char*)0xaf1f40 // FG_CHAR_LUT_PTR Text Foreground Look-Up Table
152 #define TEXT_BACK_LUT_C256 (char*)0xaf1f80 // BG_CHAR_LUT_PTR Text Background Look-Up Table
153 #define FONT_MEMORY_BANK_C256 (char*)0xaf8000 // FONT_MEMORY_BANK0 FONT Character Graphic Mem
154 #define VICKY_II_CLUT0 0xaf2000 // each addition LUT is 400 offset from here
155 #define VICKY_II_CLUT1 (VICKY_II_CLUT0 + 0x400) // each addition LUT is 400 offset from here
156 #define VICKY_II_CLUT2 (VICKY_II_CLUT1 + 0x400) // each addition LUT is 400 offset from here
157 #define VICKY_II_CLUT3 (VICKY_II_CLUT2 + 0x400) // each addition LUT is 400 offset from here
158 #define VICKY_II_CLUT4 (VICKY_II_CLUT3 + 0x400) // each addition LUT is 400 offset from here
159 #define VICKY_II_CLUT5 (VICKY_II_CLUT4 + 0x400) // each addition LUT is 400 offset from here
160 #define VICKY_II_CLUT6 (VICKY_II_CLUT5 + 0x400) // each addition LUT is 400 offset from here
161 #define VICKY_II_CLUT7 (VICKY_II_CLUT6 + 0x400) // each addition LUT is 400 offset from here
162
163
164 #define GABE_SYS_STAT 0x00AFE887
165
166 #define VIDEO_MODE_REG_OFFSET_B 0x01
167 #define GAMMA_CTRL_REG_OFFSET_B 0x02
168 #define VICKY_RESERVED_OFFSET_B 0x03
169 #define BORDER_CTRL_OFFSET_B 0x04
170 #define BORDER_COLOR_OFFSET_B_B 0x05
171 #define BORDER_COLOR_OFFSET_G_B 0x06
172 #define BORDER_COLOR_OFFSET_R_B 0x07
173 #define BORDER_X_SIZE_B 0x08
174 #define BORDER_Y_SIZE_B 0x09
175 #define BACKGROUND_COLOR_OFFSET_B_B 0x0D
176 #define BACKGROUND_COLOR_OFFSET_G_B 0x0E
177 #define BACKGROUND_COLOR_OFFSET_R_B 0x0F
178 #define CURSOR_CTRL_OFFSET_B 0x10
179 #define START_ADDR_OFFSET_B 0x11
180 #define CURSOR_CHAR_OFFSET_B 0x12
181 #define CURSOR_COLOR_OFFSET_B 0x13
182 #define LN_INTERRUPT_01_OFFSET_B 0x1B
183 #define BITMAP_L0_CTRL_B 0x100
184 #define BITMAP_L0_VRAM_ADDR_L_B 0x101
185 #define BITMAP_L0_VRAM_ADDR_M_B 0x102
186 #define BITMAP_L0_VRAM_ADDR_H_B 0x103
187 #define BITMAP_L1_CTRL_B 0x108
188 #define BITMAP_L1_VRAM_ADDR_L_B 0x109
189 #define BITMAP_L1_VRAM_ADDR_M_B 0x10A
190 #define BITMAP_L1_VRAM_ADDR_H_B 0x10B
191 #define CLUT0_OFFSET_B 0x2000
192 #define CLUT1_OFFSET_B 0x2400
193 #define CLUT2_OFFSET_B 0x2800
194 #define CLUT3_OFFSET_B 0x2C00
195 #define CLUT4_OFFSET_B 0x3000
196 #define CLUT5_OFFSET_B 0x3400
197 #define CLUT6_OFFSET_B 0x3800
198 #define CLUT7_OFFSET_B 0x3C00
199 #define FONT_MEMORY_BANK0_OFFSET_B 0x8000
200
201
202
203
204// ** A2560K GAVIN
205
206#define GAVIN_CONTROL_REG 0xfec00000 // GAVIN Control Register - 4b - RW
207 // flags for byte 0 (000000FF)
208 #define FLAG_SYS0_REG_POWER_LED 0b00000001 // power LED on (1) or off (0)
209 #define FLAG_SYS0_REG_SD_LED 0b00000010 // disk (SD) LED on (1) or off (0)
210 #define FLAG_SYS0_REG_RES_2 0b00000100 // reserved
211 #define FLAG_SYS0_REG_RES_3 0b00001000 // reserved
212 #define FLAG_SYS0_REG_R_BUZZER 0b00010000 // allows programmer to generate buzzer sounds by toggling on/off.
213 #define FLAG_SYS0_REG_RES_5 0b00100000 // reserved
214 #define FLAG_SYS0_REG_RES_6 0b01000000 // reserved
215 #define FLAG_SYS0_REG_RES_7 0b10000000 // reserved
216 // flags for byte 1 (0000FF00)
217 #define FLAG_SYS1_REG_RES_0 0b00000001 // reserved
218 #define FLAG_SYS1_REG_RES_1 0b00000010 // reserved
219 #define FLAG_SYS1_REG_RES_2 0b00000100 // reserved
220 #define FLAG_SYS1_REG_RES_3 0b00001000 // reserved
221 #define FLAG_SYS1_REG_RES_4 0b00010000 // reserved
222 #define FLAG_SYS1_REG_RES_5 0b00100000 // reserved
223 #define FLAG_SYS1_REG_RES_6 0b01000000 // reserved
224 #define FLAG_SYS1_REG_W_RESET 0b10000000 // set, then unset to trigger. See also bytes 2 and 3 for more requirements.
225 // bytes 2 and 3 enable system reset and protect against accidental reset. to reset, fill them with 0xDEAD, then set and unset FLAG_SYS1_REG_W_RESET
226
227// note: A linear feedback shift register (LFSR) is a device that generates a variety of bit patterns, including pseudo-random sequences, by connecting some of its outputs back to its input. To enable the random number generator, set bit 1 of the first byte to enable the LFSR, write a Value to setup the LFSR Seed (bytes 2-3), then set bit#1 of LFSR Control Register. Then, clear the bit. This will latch the value of the Seed in the LFSR.
228#define GAVIN_LFSR_CONTROL 0xfec00004 // LFSR Control Register - 4b - RW
229 // flags for byte 0 (000000FF)
230 #define FLAG_LFSR0_LFSR_ENABLE 0b00000001 // enables/disables LFSR
231 #define FLAG_LFSR0_SEED_WRITE 0b00000010 // after putting in a seed value in bytes 2-3, set this and unset this bit to set the seed.
232 #define FLAG_LFSR0_REG_RES_2 0b00000100 // reserved
233 #define FLAG_LFSR0_REG_RES_3 0b00001000 // reserved
234 #define FLAG_LFSR0_REG_RES_4 0b00010000 // reserved
235 #define FLAG_LFSR0_REG_RES_5 0b00100000 // reserved
236 #define FLAG_LFSR0_REG_RES_6 0b01000000 // reserved
237 #define FLAG_LFSR0_REG_RES_7 0b10000000 // reserved
238 // flags for byte 1 (0000FF00)
239 #define FLAG_LFSR1_REG_RES_0 0b00000001 // reserved
240 #define FLAG_LFSR1_REG_RES_1 0b00000010 // reserved
241 #define FLAG_LFSR1_REG_RES_2 0b00000100 // reserved
242 #define FLAG_LFSR1_REG_RES_3 0b00001000 // reserved
243 #define FLAG_LFSR1_REG_RES_4 0b00010000 // reserved
244 #define FLAG_LFSR1_REG_RES_5 0b00100000 // reserved
245 #define FLAG_LFSR1_REG_RES_6 0b01000000 // reserved
246 #define FLAG_LFSR1_REG_RES_7 0b10000000 // reserved
247 // bytes 2 and 3 are the seed value for the random number generator. set this once, then set and unset FLAG_LFSR0_SEED_WRITE
248
249#define RANDOM_NUM_GEN_ENABLE (GAVIN_LFSR_CONTROL) // for compatibility with other Foenix code
250#define GAVIN_LFSR_OUTPUT 0xfec00008 // LFSR Output Value - 4b - RO
251 // bytes 0 and 1 are the generated random number - regenerated every time you read the register
252 // flags for byte 2 (00FF0000)
253 #define FLAG_LFSR_STATUS_CTRL0 0b00000001 // status bit
254 #define FLAG_LFSR_STATUS_CTRL1 0b00000010 // status bit
255 #define FLAG_LFSR_STATUS_CTRL2 0b00000100 // status bit
256 #define FLAG_LFSR_STATUS_CTRL3 0b00001000 // status bit
257 #define FLAG_LFSR_STATUS_CTRL4 0b00010000 // status bit
258 #define FLAG_LFSR_STATUS_CTRL5 0b00100000 // status bit
259 #define FLAG_LFSR_STATUS_CTRL6 0b01000000 // status bit
260 // byte 3 will always read 0
261
262#define RANDOM_NUM_GEN (GAVIN_LFSR_OUTPUT) // for compatibility with other Foenix code
263
264#define GAVIN_POWER_LED_RGB 0xfec00008 // RGB Power LED - 4b - WO
265 // byte 0 is the blue
266 // byte 1 is the green
267 // byte 2 is the red
268 // byte 3 is ignored
269
270#define GAVIN_MACHINE_ID 0xfec0000c // Machine ID - 4b - RO
271 // MB: not clear from 0.0.2 manual vs subsequent changes to other machines, if this will stay same in future.
272 // byte 0 appears to be a speed ID
273 // byte 1 appears to be for CPU ID
274#define MACHINE_ID_REGISTER (GAVIN_MACHINE_ID)
275
276#define GAVIN_KEYBOARD_LED_RGB 0xfec0000c // Keyboard Status LEDs - 4b - WO
277 // The Value of the status led are simply on or off, so only 7 basic colors can be programmed.
278 // bits 0-2 are RGB for the top right LED
279 // bits 3-5 are RGB for the middle right LED
280 // bits 6-8 are RGB for the bottom right LED
281 // bits 9-11 are RGB for the middle left LED
282
283#define GAVIN_CHIP_VERSION 0xfec00010 // Chip version and number - 4b - RO
284 // bytes 0-1 are the chip version in hex
285 // bytes 2-3 are the chip number in hex
286
287#define GAVIN_FIRMWARE_DATE 0xfec00014 // Firmware date - 4b - RO
288 // byte 0 is the year in decimal
289 // byte 1 is the month in decimal
290 // byte 2 is the day in decimal
291 // byte 3 is reserved
292
293#define GAVIN_HARDWARE_DATE_A 0xfec00018 // Hardware date - 4b - RO
294 // byte 0 EOS
295 // byte 1 Rev digit 2 in ASCII
296 // byte 2 Rev digit 1 in ASCII
297 // byte 3 Rev digit 0 in ASCII
298
299#define GAVIN_HARDWARE_DATE_B 0xfec0001C // Firmware date - 4b - RO
300 // byte 0 is the year in decimal
301 // byte 1 is the month in decimal
302 // byte 2 is the day in decimal
303 // byte 3 is reserved
304
305
306
307// ** A2560K Keyboard Register
308// TODO
309
310#define GAVIN_KEYBOARD_INPUT_REG 0xfec00040 // Keyboard input register - 4b - RO
311
312
313// ** A2560K Real Time Clock
314
315#define GAVIN_RTC 0xfec00080 // start of RTC registers -- all are 1 byte RW
316#define RTC_SECONDS (GAVIN_RTC) // 654: second digit, 3210: 1st digit
317#define RTC_SECONDS_ALARM (RTC_SECONDS + 1) // 654: second digit, 3210: 1st digit
318#define RTC_MINUTES (RTC_SECONDS_ALARM + 1) // 654: second digit, 3210: 1st digit
319#define RTC_MINUTES_ALARM (RTC_MINUTES + 1) // 654: second digit, 3210: 1st digit
320#define RTC_HOURS (RTC_MINUTES_ALARM + 1) // 54: second digit, 3210: 1st digit
321#define RTC_HOURS_ALARM (RTC_HOURS + 1) // 54: second digit, 3210: 1st digit
322#define RTC_DAY (RTC_HOURS_ALARM + 1) // 54: second digit, 3210: 1st digit
323#define RTC_DAY_ALARM (RTC_DAY + 1) // 54: second digit, 3210: 1st digit
324#define RTC_DAY_OF_WEEK (RTC_DAY_ALARM + 1) // 210: day of week digit
325#define RTC_MONTH (RTC_DAY_OF_WEEK + 1) // 4: second digit, 3210: 1st digit
326#define RTC_YEAR (RTC_MONTH + 1) // 7654: second digit, 3210: 1st digit
327#define RTC_RATES (RTC_YEAR + 1) // 654: WD (watchdog, not really relevant to F256); 3210: RS
328 #define FLAG_RTC_RATE_NONE 0b00000000 // applies to bits 3210 of RTC_RATES
329 #define FLAG_RTC_RATE_31NS 0b00000001 // applies to bits 3210 of RTC_RATES. See manual for values between 0001 and 1101
330 #define FLAG_RTC_RATE_125MS 0b00001101 // applies to bits 3210 of RTC_RATES
331 #define FLAG_RTC_RATE_63MS 0b00001100 // applies to bits 3210 of RTC_RATES - 62.5ms
332 #define FLAG_RTC_RATE_250MS 0b00001110 // applies to bits 3210 of RTC_RATES
333 #define FLAG_RTC_RATE_500MS 0b00001111 // applies to bits 3210 of RTC_RATES
334#define RTC_ENABLES (RTC_RATES + 1) // Controls various interrupt enables, only some of which apply to an F256
335 #define FLAG_RTC_PERIODIC_INT_EN 0b00000100 // set PIE (bit 2) to raise interrupt based on RTC_RATES
336 #define FLAG_RTC_ALARM_INT_EN 0b00001000 // Set AEI (bit 3) to raise interrupt based on RTC_SECONDS_ALARM, etc.
337#define RTC_FLAGS (RTC_ENABLES + 1) // check to see why an RTC interrupt was raised
338 #define FLAG_RTC_PERIODIC_INT 0b00000100 // will be set if interrupt was raised based on RTC_RATES
339 #define FLAG_RTC_ALARM_INT 0b00001000 // will be set if interrupt was raised based on alarm clock
340#define RTC_CONTROL (RTC_FLAGS + 1) // set UTI (bit 3) to disable update of reg, to read secs.
341 #define MASK_RTC_CTRL_DSE 0b00000001 // if set (1), daylight savings is in effect.
342 #define MASK_RTC_CTRL_12_24 0b00000010 // sets whether the RTC is using 12 or 24 hour accounting (1 = 24 Hr, 0 = 12 Hr)
343 #define MASK_RTC_CTRL_STOP 0b00000100 // If it is clear (0) before the system is powered down, it will avoid draining the battery and may stop tracking the time. If it is set (1), it will keep using the battery as long as possible.
344 #define MASK_RTC_CTRL_UTI 0b00001000 // if set (1), the update of the externally facing registers by the internal timers is inhibited. In order to read or write those registers, the program must first set UTI and then clear it when done.
345 #define MASK_RTC_CTRL_UNUSED 0b11110000 // the upper 4 bits are not used.
346#define RTC_CENTURY (RTC_CONTROL + 1) // 7654: century 10s digit, 3210: centurys 1s digit
347
348
349// ** A2560K Interrupt control registers
350// TODO
351
352#define GAVIN_INTERRUPT_CONTROL 0xfec00100 // start of interrupt control registers -- all are 2 byte RW
353
354
355// ** A2560K Timer control registers
356// TODO
357
358#define GAVIN_TIMER_CONTROL 0xfec00200 // start of interrupt control registers -- all are 4 byte RW
359
360
361// ** A2560K SD card control registers
362// TODO
363
364#define GAVIN_SD_CONTROL 0xfec00300 // start of SD card control registers -- all are 1 byte, mix of RW and RO
365
366
367// ** A2560K IDE control registers
368// TODO
369
370#define GAVIN_IDE_CONTROL 0xfec00400 // start of IDE drive control registers -- mix of 1-2 bytes, all are RW
371
372
373// ** A2560K Joystick control registers
374// TODO
375
376#define GAVIN_JOY_CONTROL 0xfec00500 // start of joystick control registers -- all are 2 byte, mix of RW and RO
377
378
379// ** A2560K Ethernet control registers
380// TODO
381
382#define GAVIN_ETHERNET_CONTROL 0xfec00500 // start of Ethernet control registers -- all are 4 byte, mix of RW and RO
383
384
385// ** A2560K Serial control registers
386
387// common to both serial ports -- from LPC47M107 datasheet
388#define UART_BAUD_DIV_300 384 // divisor for 300 baud
389#define UART_BAUD_DIV_600 192 // divisor for 600 baud
390#define UART_BAUD_DIV_1200 96 // divisor for 1200 baud
391#define UART_BAUD_DIV_1800 64 // divisor for 1800 baud
392#define UART_BAUD_DIV_2000 58 // divisor for 2000 baud
393#define UART_BAUD_DIV_2400 48 // divisor for 2400 baud
394#define UART_BAUD_DIV_3600 32 // divisor for 3600 baud
395#define UART_BAUD_DIV_4800 24 // divisor for 4800 baud
396#define UART_BAUD_DIV_9600 12 // divisor for 9600 baud
397#define UART_BAUD_DIV_19200 6 // divisor for 19200 baud
398#define UART_BAUD_DIV_38400 3 // divisor for 38400 baud
399#define UART_BAUD_DIV_57600 2 // divisor for 57600 baud
400#define UART_BAUD_DIV_115200 1 // divisor for 115200 baud
401
402// common to LCR register for both ports
403#define UART_DATA_BITS 0b00000011 // 0/0: 5 bit word len. 0/1=6b. 1/0=7b. 1/1=8b.
404#define UART_STOP_BITS 0b00000100 // stop bits. clear to have stop bits at 1.
405#define UART_PARITY_ENABLE 0b00001000 // when 1 a parity bit is generated (transmit) or checked (receive)
406#define UART_PARITY_EVEN 0b00010000 // even parity: this and b3 are 1s. odd parity: this is 1, b3 is 0.
407#define UART_PARITY_STICK 0b00100000 // clear this if doing no parity
408#define UART_BRK_SIG 0b01000000 // when 1, TXD is forced to Spacing. don't use.
409#define UART_DLAB_MASK 0b10000000 // Divisor Latch Access bit DLAB. set to 1 to access baud rate generator. must be at 0 to access receiver buffer reg, transmitter reg, and IER.
410
411// common to LSR register for both ports
412#define UART_DATA_AVAILABLE 0b00000001 // Data Ready (DR). set to 1 whenever an incoming char is available. reset to 0 by reading all of the data in the receive buffer register or the FIFO.
413#define UART_OVERRUN_ERROR 0b00000010 // Overrun Error (OE). When set, indicates the receiver buffer register was not read before the next char was transferred. In FIFO mode an overrun error will occur only when the FIFO is full.
414#define UART_PARITY_ERROR 0b00000100 // Parity Error (PE). When set, indicates the received data char does not have the correct even or odd parity.
415#define UART_FRAMING_ERROR 0b00001000 // Framing Error (FE). When set, indicates received char did not have a valid stop bit
416#define UART_BREAK_INT 0b00010000 // Break Interrupt (BI). see datasheet.
417#define UART_THR_IS_EMPTY 0b00100000 // Transmitter Holding Register Empty (THRE). When 1, serial port is ready to accept a new char for transmission. RO.
418#define UART_THR_EMPTY_IDLE 0b01000000 // Transmitter Empty (TEMT). When 1, serial both THR and TSR are empty. RO.
419#define UART_ERROR 0b10000000 // In non-FIFO mode, will be 0. In FIFO mode, will be 1 when there is any of the following: parity error, framing error, or break indication. Cleared when LSR is read.
420#define UART_ERROR_MASK 0b10011110
421
422// MCP has these #s:
423// #define UART1_BASE 0xFEC023F8 /* Base address for UART 1 (COM1) */
424// #define UART2_BASE 0xFEC022F8 /* Base address for UART 2 (COM2) */
425// Manual version 0.0.2 has fec02278 and 0xfec023f8
426
427// serial port 2
428// #define GAVIN_SERIAL_2_BASE 0xfec02278 // start of Serial Port 2 registers -- all are 1 byte, RW except as noted
429#define GAVIN_SERIAL_2_BASE 0xfec022F8 // start of Serial Port 2 registers -- all are 1 byte, RW except as noted
430#define UART2_BASE (GAVIN_SERIAL_2_BASE)
431#define UART2_RBR (UART2_BASE + 0) // F256 naming compatibility
432#define UART2_RHR (UART2_BASE + 0) // When DLAB=0 (RHR) Receiver Holding Register (R)
433#define UART2_THR (UART2_BASE + 0) // When DLAB=0 (THR) Transmitter Holding Register (W)
434#define UART2_DLL (UART2_BASE + 0) // When DLAB=1 (DLL) Baud rate Divisor’s Constant LSB
435#define UART2_IER (UART2_BASE + 1) // When DLAB=0 (IER) Interrupt Enable Register
436#define UART2_DLM (UART2_BASE + 1) // When DLAB=1 (DLM) Baud rate Divisor’s Constant MSB
437#define UART2_IIR (UART2_BASE + 2) // F256 naming compatibility
438#define UART2_ISR (UART2_BASE + 2) // When DLAB=0 (ISR) Interrupt Status Register (R)
439#define UART2_FCR (UART2_BASE + 2) // When DLAB=1 (FCR) FIFO Control Register (FIFO is 16 Bytes Deep) (W)
440#define UART2_LCR (UART2_BASE + 3) // (LCR) Line Control Register
441#define UART2_MCR (UART2_BASE + 4) // (MCR) Modem Control Register
442#define UART2_LSR (UART2_BASE + 5) // (LSR) Line Status Register
443#define UART2_MSR (UART2_BASE + 6) // (MSR) Modem Status Register
444#define UART2_SCR (UART2_BASE + 7) // F256 naming compatibility
445#define UART2_SCR (UART2_BASE + 7) // (SPR) Scratch Pad Register
446
447// serial port 1
448#define GAVIN_SERIAL_1_BASE 0xfec023F8 // start of Serial Port 1 registers -- all are 1 byte, RW except as noted
449#define UART_BASE (GAVIN_SERIAL_1_BASE)
450#define UART_RBR (UART_BASE + 0) // F256 naming compatibility
451#define UART_RHR (UART_BASE + 0) // When DLAB=0 (RHR) Receiver Holding Register (R)
452#define UART_THR (UART_BASE + 0) // When DLAB=0 (THR) Transmitter Holding Register (W)
453#define UART_DLL (UART_BASE + 0) // When DLAB=1 (DLL) Baud rate Divisor’s Constant LSB
454#define UART_IER (UART_BASE + 1) // When DLAB=0 (IER) Interrupt Enable Register
455#define UART_DLM (UART_BASE + 1) // When DLAB=1 (DLM) Baud rate Divisor’s Constant MSB
456#define UART_IIR (UART_BASE + 2) // F256 naming compatibility
457#define UART_ISR (UART_BASE + 2) // When DLAB=0 (ISR) Interrupt Status Register (R)
458#define UART_FCR (UART_BASE + 2) // When DLAB=1 (FCR) FIFO Control Register (FIFO is 16 Bytes Deep) (W)
459#define UART_LCR (UART_BASE + 3) // (LCR) Line Control Register
460#define UART_MCR (UART_BASE + 4) // (MCR) Modem Control Register
461#define UART_LSR (UART_BASE + 5) // (LSR) Line Status Register
462#define UART_MSR (UART_BASE + 6) // (MSR) Modem Status Register
463#define UART_SCR (UART_BASE + 7) // F256 naming compatibility
464#define UART_SCR (UART_BASE + 7) // (SPR) Scratch Pad Register
465
466
467// ** A2560K VICKY - COMMON
468// NOTE: A2560K has 2 VICKY controls, and 2 outputs. Channel A is text only and higher res.
469
470// Cursor control flags
471#define CURSOR_ONOFF_BITS 0b00000001
472#define CURSOR_FLASH_RATE_BITS 0b00000110
473#define CURSOR_FLASH_RATE_12S 0b00000010
474#define CURSOR_FLASH_RATE_14S 0b00000100
475#define CURSOR_FLASH_RATE_15S 0b00000110
476
477// VICKY FONT FLAGS - maybe only apply to later machines like F256??
478#define VICKY_RES_FON_OVLY 0x10 // 0b00010000 -- if clear(0), only the text foreground color will be displayed when text overlays graphics (all background colors will be completely transparent). If set (1), both foreground and background colors will be displayed, except that background color 0 will be transparent.
479#define VICKY_RES_FON_SET 0x20 // 0b00100000 -- if set (1), the text font displayed will be font set 1. If clear (0), the text font displayed will be font set 0.
480
481// Common offsets from Vicky A/B base to desired reg.
482#define VICKY_AB_OFFSET_BORDER_CTRL_REG 4 // Border Control Register
483#define VICKY_AB_OFFSET_BORDER_COLOR_REG 8 // Border Color Register
484#define VICKY_AB_OFFSET_BACK_COLOR_REG 12 // Background Color Register
485#define VICKY_AB_OFFSET_CURSOR_CTRL_REG 16 // Cursor Control Register
486#define VICKY_AB_OFFSET_CURSOR_POS_REG 20 // Cursor Position Register
487
488// VICKY RESOLUTION FLAGS Per A2560K_UM_Rev0.0.1.pdf and A2560U_UM_Rev0.0.2.pdf
489// VICKY II / VICKY III Chan B
490// 640x480 @ 60FPS > 0 0
491// 800x600 @ 60FPS > 0 1
492// reserved > 1 0
493// 640x400 @ 70FPS > 1 1
494
495// VICKY III Chan A
496// 800x600 @ 60FPS > 0 0
497// 1024x768 @ 60FPS > 0 1
498// reserved > 1 0
499// reserved > 1 1
500
501#define VICKY_II_RES_640X480_FLAGS 0x00 // 0b00000000
502#define VICKY_II_RES_800X600_FLAGS 0x01 // 0b00000001
503#define VICKY_II_PIX_DOUBLER_FLAGS 0x02 // 0b00000001
504#define VICKY_II_RES_640X400_FLAGS 0x03 // 0b00000011
505
506#define VICKY_IIIB_RES_640X480_FLAGS 0x00 // 0b00000000
507#define VICKY_IIIB_RES_800X600_FLAGS 0x01 // 0b00000001
508#define VICKY_IIIB_RES_RESERVED_FLAGS 0x02 // 0b00000010 // a2560K 0.0.2 manual says reserved, but this is what I see in the register when MCP sets 800x600
509#define VICKY_IIIB_RES_640X400_FLAGS 0x03 // 0b00000011
510
511#define VICKY_IIIA_RES_800X600_FLAGS 0x00 // 0b00000000
512#define VICKY_IIIA_RES_1024X768_FLAGS 0x08 // 0b00000100
513
514#define VICKY_AB_RES_FLAG_MASK_8BIT 0x03 // 0b00000011 // when masking 2nd byte of VICKY, these are the bits related to resolution.
515#define VICKY_AB_RES_FLAG_MASK_32BIT 0x00000300 // when masking 2nd byte of VICKY, these are the bits related to resolution.
516
517
518
519
520// ** A2560K VICKY - CHANNEL A
521// NOTE: channel A is text only, no graphic modes
522
523#define VICKY_A_BASE_ADDRESS 0xfec40000 // start of VICKY channel A registers -- all are 4 byte, RW (some bits RO)
524#define VICKY_A_MASTER_CONTROL (VICKY_A_BASE_ADDRESS) // VICKY Channel A master control register
525 // VICKY A byte 0 bits (reserved except as noted below)
526 #define VICKY_AB_TEXT_MODE_EN_FLAG 0x00000001 // 0b00000001 Enable the Text Mode
527 #define VICKY_AB_DISABLE_VID_OUTPUT 0x00000080 // 0b10000000 This will disable the Scanning of the Video information in the 4Meg of Video RAM hence giving 100% bandwidth to the CPU
528 // VICKY A byte 1 bits (reserved except as noted below)
529 #define VICKY_A_MC_RES_FLAG 0x00000800 // 0b00001000 - 1=1024x768, 0=800x600
530 // VICKY A byte 2 bits (reserved except as noted below)
531 #define VICKY_A_MC_GAMMA_SRC_FLAG 0x00010000 // 0b00000001 0: respect dip switch. 1: respect bit 1 of this byte
532 #define VICKY_A_MC_GAMMA_SW_CHOICE 0x00020000 // 0b00000010 0: gamma off. 1: gamma on (only effective if bit 0 set)
533 #define VICKY_A_MC_SYNC_DISABLE 0x00040000 // 0b00000100 0: normal. 1: sync off (put display to sleep)
534 // VICKY A byte 3 bits (reserved except as noted below)
535 #define VICKY_A_MC_GAMMA_DIP 0x00200000 // 0b00100000 - RO - position of gamma dipswitch
536 #define VICKY_A_MC_HIRES_DIP 0x00400000 // 0b01000000 - RO - position of hi-res dispswitch
537 #define VICKY_A_MC_CLK_SPD_FLAG 0x00800000 // 0b10000000 - RO - PLL clock speed - 0=40mhz, 1=65mhz
538
539#define VICKY_A_BORDER_CONTROL (VICKY_A_MASTER_CONTROL + 4) // VICKY Channel A border control register
540
541//#define VICKYA_CURSOR_CTRL_A2560K (VICKY_A_BASE_ADDRESS + 0x10) // vicky III channel A cursor control register
542#define VICKYA_CURSOR_CTRL_A2560K (0xfec40010) // vicky III channel A cursor control register
543 #define VICKY_AB_CCR_CHAR_MASK 0xFF00FFFF
544#define VICKYA_CURSOR_POS_A2560K (VICKY_A_BASE_ADDRESS + 0x14) // vicky III channel A cursor position register (x pos is lower word, y pos is upper word)
545#define VICKYA_MOUSE_GRAPHIC_A2560K 0xfec40400 // vicky III channel A mouse pointer graphic stored here (16x16 ARGB) - 4byte, WO
546#define VICKYA_MOUSE_CTRL_A2560K 0xfec40c00 // vicky III channel A mouse pointer control register. set to 1 to enable mouse. +2 to do whatever "pointer choice" does. W16, R32
547#define VICKYA_MOUSE_PTR_POS 0xfec40c04 // vicky III channel B mouse pointer position (Y pos in upper 16 bits, x in lower)
548
549#define VICKYA_PS2_MOUSE_BYTE_0 0xfec40c0a // PS/2 mouse movement byte 0 for VICKY to interpret. W16.
550#define VICKYA_PS2_MOUSE_BYTE_1 0xfec40c0c // PS/2 mouse movement byte 1 for VICKY to interpret. W16.
551#define VICKYA_PS2_MOUSE_BYTE_2 0xfec40c0e // PS/2 mouse movement byte 2 for VICKY to interpret. W16.
552
553// VICKY III - Channel B - Text and Graphics
554#define VICKY_BITMAP_MAX_H_RES 800 // VICKY in A2560K supports a max resolution of 800x600 for graphics
555#define VICKY_BITMAP_MAX_V_RES 600 // VICKY in A2560K supports a max resolution of 800x600 for graphics
556#define GRAPHICS_MODE_MASK 0xFFFFFF00
557#define VIDEO_MODE_MASK 0xFFFF00FF
558#define GAMMA_MODE_MASK 0xFF00FFFF
559
560#define VICKY_B_BASE_ADDRESS 0xfec80000 // start of VICKY channel B registers -- all are 4 byte, RW (some bits RO)
561
562#define VICKY_B_MASTER_CONTROL (VICKY_B_BASE_ADDRESS) // vicky III channel B control register
563
564 // VICKY B byte 0 bits (reserved except as noted below)
565 #define VICKY_AB_TEXT_MODE_EN_FLAG 0x00000001 // 0b00000001 Enable the Text Mode
566 #define VICKY_AB_DISABLE_VID_OUTPUT 0x00000080 // 0b10000000 This will disable the Scanning of the Video information in the 4Meg of Video RAM hence giving 100% bandwidth to the CPU
567
568 #define GRAPHICS_MODE_TEXT 0x01 // 0b00000001 Enable the Text Mode
569 #define GRAPHICS_MODE_TEXT_OVER 0x02 // 0b00000010 Enable the Overlay of the text mode on top of Graphic Mode (the Background Color is ignored)
570 #define GRAPHICS_MODE_GRAPHICS 0x04 // 0b00000100 Enable the Graphic Mode
571 #define GRAPHICS_MODE_EN_BITMAP 0x08 // 0b00001000 Enable the Bitmap Module In Vicky
572 #define GRAPHICS_MODE_EN_TILE 0x10 // 0b00010000 Enable the Tile Module in Vicky
573 #define GRAPHICS_MODE_EN_SPRITE 0x20 // 0b00100000 Enable the Sprite Module in Vicky
574 #define GRAPHICS_MODE_RESERVED 0x40 // 0b01000000 Reserved on A2560K
575 #define GRAPHICS_MODE_DIS_VIDEO 0x80 // 0b10000000 This will disable the Scanning of the Video information in the 4Meg of VideoRAM hence giving 100% bandwidth to the CPU
576
577
578 // VICKY B byte 1 bits
579 #define VICKY_B_MC_RES_FLAG_1 0x00000100 // 0b00000001
580 #define VICKY_B_MC_RES_FLAG_2 0x00000200 // 0b00000010
581 // note: apparently 640x400 is not yet configured on A2560K
582 // bits 0-1 @ 0/0: 640x480 @ 60FPS
583 // bits 0-1 @ 0/1: 800x600 @ 60FPS
584 // bits 0-1 @ 1/1: 640x400 @ 70FPS
585 #define VICKY_B_MC_PIX_DBL_FLAG 0x00000400 // 0b00000100 - doubles pixel size in both X and Y directions.
586 #define VICKY_B_MC_RESERVED_1 0x00000800 // 0b00001000 - reserved
587 #define VICKY_B_MC_RESERVED_2 0x00001000 // 0b00010000 - reserved
588 #define VICKY_B_MC_GAMMA_DIP 0x00002000 // 0b00100000 - RO - position of gamma dipswitch
589 #define VICKY_B_MC_HIRES_DIP 0x00004000 // 0b01000000 - RO - position of hi-res dispswitch
590 #define VICKY_B_MC_CLK_SPD_FLAG 0x00008000 // 0b10000000 - RO - clock speed - 0=25mhz, 1=40mhz
591 // VICKY B byte 2 bits (reserved except as noted below)
592 #define VICKY_B_MC_GAMMA_SRC_FLAG 0x00010000 // 0b00000001 0: respect dip switch. 1: respect bit 1 of this byte
593 #define VICKY_B_MC_GAMMA_SW_CHOICE 0x00020000 // 0b00000010 0: gamma off. 1: gamma on (only effective if bit 0 set)
594 #define VICKY_B_MC_SYNC_DISABLE 0x00040000 // 0b00000100 0: normal. 1: sync off (put display to sleep)
595 // VICKY B byte 3 bits are all reserved
596
597#define VICKYB_BORDER_CTRL_A2560K (VICKY_B_BASE_ADDRESS + 4) // vicky III channel B border control register
598#define VICKYB_BORDER_COLOR_A2560K 0xfec80008 // vicky III channel B border color register
599#define VICKYB_BACK_COLOR_A2560K 0xfec8000C // vicky III channel B background color register
600#define VICKYB_CURSOR_CTRL_A2560K (VICKY_B_BASE_ADDRESS + 16) // vicky III channel B cursor control register
601#define VICKYB_CURSOR_POS_A2560K (VICKY_B_BASE_ADDRESS + 20) // vicky III channel B cursor position register
602#define VICKYB_BITMAP_L0_CTRL 0xfec80100 // vicky III channel B bitmap layer 0 control register (1=enable, +2=LUT0, +4=LUT1, +8=LUT2
603#define VICKYB_MOUSE_GRAPHIC_A2560K 0xfec80400 // vicky III channel B mouse pointer graphic stored here (16x16 ARGB) - 4byte, WO
604#define VICKYB_MOUSE_CTRL_A2560K 0xfec80c00 // vicky III channel B mouse pointer control register. set to 1 to enable mouse. +2 to do whatever "pointer choice" does. W16, R32
605#define VICKYB_MOUSE_PTR_POS 0xfec80c04 // vicky III channel B mouse pointer position (Y pos in upper 16 bits, x in lower)
606#define VICKYB_PS2_MOUSE_BYTE_0 0xfec80c0a // PS/2 mouse movement byte 0 for VICKY to interpret. W16.
607#define VICKYB_PS2_MOUSE_BYTE_1 0xfec80c0c // PS/2 mouse movement byte 1 for VICKY to interpret. W16.
608#define VICKYB_PS2_MOUSE_BYTE_2 0xfec80c0e // PS/2 mouse movement byte 2 for VICKY to interpret. W16.
609#define TEXTA_RAM_A2560K (char*)0xfec60000 // channel A text
610#define TEXTA_ATTR_A2560K (char*)0xfec68000 // channel A attr
611#define TEXTA_FORE_LUT_A2560K (char*)0xfec6c400 // FG_CHAR_LUT_PTR Text Foreground Look-Up Table
612#define TEXTA_BACK_LUT_A2560K (char*)0xfec6c440 // BG_CHAR_LUT_PTR Text Background Look-Up Table
613#define TEXTB_RAM_A2560K (char*)0xfeca0000 // channel B text
614#define TEXTB_ATTR_A2560K (char*)0xfeca8000 // channel B attr
615#define TEXTB_FORE_LUT_A2560K (char*)0xfecac400 // FG_CHAR_LUT_PTR Text Foreground Look-Up Table
616#define TEXTB_BACK_LUT_A2560K (char*)0xfecac440 // BG_CHAR_LUT_PTR Text Background Look-Up Table
617#define FONT_MEMORY_BANKA_A2560K (char*)0xfec48000 // chan A
618#define FONT_MEMORY_BANKB_A2560K (char*)0xfec88000 // chan B
619#define VICKY_IIIB_CLUT0 0xfec82000 // each addition LUT is 400 offset from here
620#define VICKY_IIIB_CLUT1 (VICKY_IIIB_CLUT0 + 1024) // each addition LUT is 400 offset from here
621#define VICKY_IIIB_CLUT2 (VICKY_IIIB_CLUT1 + 1024) // each addition LUT is 400 offset from here
622#define VICKY_IIIB_CLUT3 (VICKY_IIIB_CLUT2 + 1024) // each addition LUT is 400 offset from here
623#define VICKY_IIIB_CLUT4 (VICKY_IIIB_CLUT3 + 1024) // each addition LUT is 400 offset from here
624#define VICKY_IIIB_CLUT5 (VICKY_IIIB_CLUT4 + 1024) // each addition LUT is 400 offset from here
625#define VICKY_IIIB_CLUT6 (VICKY_IIIB_CLUT5 + 1024) // each addition LUT is 400 offset from here
626#define VICKY_IIIB_CLUT7 (VICKY_IIIB_CLUT6 + 1024) // each addition LUT is 400 offset from here
627
628#define default_start_a2560k_vram 0x00011000 // offset against vicky I think though. add to VICKY_B_BASE_ADDRESS? based on doing peek32 in f68.
629#define BITMAP_CTRL_REG_A2560_0 0xfec80100
630#define BITMAP_VRAM_ADDR_A2560_0 0xfec80104
631#define BITMAP_CTRL_REG_A2560_1 0xfec80108
632#define BITMAP_VRAM_ADDR_A2560_1 0xfec8010C
633
634
635// ** A2560U and A2560U+
636#define VICKY_A2560U 0xb40000 // Vicky II offset/first register
637#define VICKY_CURSOR_CTRL_A2560U (VICKY_A2560U + 0x10) // vicky II channel A cursor control register
638#define VICKY_CURSOR_POS_A2560U (VICKY_A2560U + 0x14) // vicky II channel A cursor position register (x pos is lower word, y pos is upper word)
639#define TEXT_RAM_A2560U (char*)0xb60000 // text (A2560U only has one video channel)
640#define TEXT_ATTR_A2560U (char*)0xb68000 // attr (A2560U only has one video channel)
641#define TEXT_FORE_LUT_A2560U (char*)0xb6c400 // FG_CHAR_LUT_PTR Text Foreground Look-Up Table
642#define TEXT_BACK_LUT_A2560U (char*)0xb6c440 // BG_CHAR_LUT_PTR Text Background Look-Up Table
643#define FONT_MEMORY_BANK_A2560U (char*)0xb48000 // only 1 channel
644
645
646// ** VRAM locations per machine
647
648// NOTE: VRAM is currently only available in VRAM Buffer A on A2560K, Buffer B is not implemented (2022/03/21)
649
650#if defined _C256_FMX_
651 #define VRAM_START 0x00B00000
652 #define VRAM_LEN 0x00200000
653#elif defined _A2560U_
654 #define VRAM_START 0x00C00000
655 #define VRAM_LEN 0x00200000
656#elif defined _A2560K_
657 #define VRAM_START 0x00800000
658 #define VRAM_LEN 0x00400000
659#endif
660
661#define VRAM_OFFSET_TO_NEXT_SCREEN 0x75300 // 800x600 - 480,000 -- number of bytes needed to cover maximum screen resolution for one bitmap layer
662
663
664// subtract 0xfe000000 from the UM map for Vicky (to get the old/morfe addresses)
665// size of some areas changed too:
666// channel-A text went 0xc6:0000 -> 0xFEC6:0000, but channel-A color went 0xc6:8000 -> 0xFEC6:4000
667// channel-B text went 0xca:0000-> 0xFECA:0000, channel-B color went 0xca:8000 -> 0xFECA:4000
668// btw, one thing to keep in mind is device-mem access granularity -- while in morfe you can do 8-32bit accesses, on the actual hw you will need to adhere to the area access granularity
669// see user manual, the "SIZE" columns
670
671// c256foenix on 2/27:
672// I will have to look into that. Suffice to say that Channel A, has 2 Video Modes, 800x600 and 1024x768 with no doubling. Channel B has 6 modes, 640x480@60, 800x600@60 and 640x400@70 and with the equivalent Pixel Doubling, 320x240, 400x300 and 320x200.
673// Now, in the K, for Channel A, to not be confusing (although I might have created what I was trying to avoid) and to not have competing Regiters bit with different function (from Channel B and A), I moved the Resolution selection bit to bit# (Something I have to check), but it is farther down the Control Register.
674// the Video mode bit for Channel A (that I call Auxiliary) would be bit 11 of the Control Register
675// assign Mstr_Ctrl_Video_Mode_PLL_Aux_o = VICKY_MASTER_REG1_RESYNC_AUX[2][11];
676// So, that is the bit that selects either 800x600 or 1024x768 and bit[9:8] are ignored.
677
678// so: 1024x768 = 128x96
679// 800x600 = 100x75
680// 640x480 = 80x60
681// 640x400 = 80x50
682// 400x300 = 50x37.5
683// 320x240 = 40x30
684// 320x200 = 40x25
685// (these are all maximums, as borders can be configured, which reduces the number of usable rows/cols.)
686//
687// c256 foenix on 2/27:
688// To answer, in the traditional Text Mode (Channel B). When you are double pixel mode, everything is reajusted automatically. The Channel A doesn't have a text doubling mode (anymore). And the text matrix and FONT dimension are all manual (needs to be programmed). This is to allow the usage of different sizes of FONT.
689
690// fonts
691// gadget:
692// If it's the same as on the C256 line, each character consists of 8 bytes. Upper left hand corner is the high-bit of byte zero, upper right is the low bit of byte zero, lower left is the high bit of byte 7, lower right is the low bit of byte 7. The bytes are placed in memory from character zero to character 255, 0..7, 0..7, 0..7, etc.
693
694// pjw:
695// Yeah, C256 and A2560U fonts are the same layout. The A2560K is a little different. The mostly-text-mode screen supports an 8x16 font layout, where the structure is essentially the same, but each character is 16 bytes rather than 8.
696
697// beethead:
698// The 2nd font was removed when the U line came in since it was not being used. Atleast on the C256's.
699
700// PJW — 2022/03/06 at 9:10 AM
701// The A2560K has two DVI ports: one is channel A (which is a text only channel), and channel B is a text and graphics channel equivalent to the main screen on the A2560U. The boot up image on the K shows up on channel B. Currently, the MCP uses channel A as the main interaction channel, but I think I'm going to change that soon, since some people may have just the one screen. The "CTX Switch" key on the A2560K was originally intended as a way to switch which screen you were using for text input, and I may finally implement that.
702
703#define SYS_TICKS_PER_SEC 60 // per syscalls.h in MCP, "a jiffie is 1/60 of a second."
704
705// C256 FPGA Version. not the machine model.
706//C256F_MODEL_MAJOR - $AF:070B
707//C256F_MODEL_MINOR - $AF:070C
708
709// machine model numbers - for decoding s_sys_info.model - value read from MACHINE_ID_REGISTER (see above)
710#define MACHINE_C256FMX 0x00
711#define MACHINE_C256U 0x01
712#define MACHINE_F256JR 0x02
713#define MACHINE_F256JRE 0x03
714#define MACHINE_GENX 0x04
715#define MACHINE_C256_UPLUS 0x05
716#define MACHINE_UNDEFINED_1 0x06
717#define MACHINE_UNDEFINED_2 0x07
718#define MACHINE_A2560X 0x08
719#define MACHINE_A2560U_PLUS 0x09
720#define MACHINE_A2560M 0x0a
721#define MACHINE_A2560K 0x0b
722#define MACHINE_A2560K40 0x0c
723#define MACHINE_A2560K60 0x0d
724#define MACHINE_UNDEFINED_3 0x0e
725#define MACHINE_UNDEFINED_4 0x0f
726#define MACHINE_F256P 0x10
727#define MACHINE_F256K2 0x11
728#define MACHINE_F256K 0x12
729#define MACHINE_F256KE 0x13
730#define MACHINE_F256K2E 0x14
731
732#define MACHINE_MODEL_MASK 0x1F
733
734// GABE_SYS_STAT = $AFE887 ;
735// GABE_SYS_STAT_MID0 = $01 ; Machine ID -- LSB
736// GABE_SYS_STAT_MID1 = $02 ; Machine ID --
737// GABE_SYS_STAT_MID2 = $04 ; Machine ID -- MSB
738// Bit 3, Bit 2, Bit 1, Bit 0
739// 0000: C256 FMX
740// 0001: C256 U 2Meg
741// 0010: TBD (Reserved)
742// 0011: A2560 Dev
743// 0100: C256 GenX
744// 0101: C256 U+ 4Meg
745// 0110: A2560U+
746// 0111: A2560X
747// 1001: A2560U
748// 1101: A2560K
749// ergo, $0F is the mask for the bits we care about (the lower 4).
750//#define MACHINE_MODEL_MASK 0x0F
751
752
753
754// amiga rawkey codes
755#define KEYCODE_CURSOR_LEFT 79
756#define KEYCODE_CURSOR_RIGHT 78
757#define KEYCODE_CURSOR_UP 76
758#define KEYCODE_CURSOR_DOWN 77
759
760#define KEYCODE_RETURN 0x44 // rawkey code
761#define KEYCODE_RETURN_UP KEY_RAW_RETURN & 0x80
762#define KEY_RETURN 13 // vanilla key
763#define KEY_ESC 27 // vanilla key
764
765#define CHAR_UMLAUT 0xA8 // ¨ char -- will use in place of ellipsis when truncating strings
766#define CHAR_ELLIPSIS CHAR_UMLAUT
767
768#define KEY_BUFFER_SIZE 16 // unlikely anyone would ever want to type 15 chars to select a file
769
770#define ALERT_MAX_MESSAGE_LEN 256 // 255 chars + terminator. seems long, but with formatting chars, not crazy.
771
772#define ALERT_DIALOG_SHOW_AS_ERROR true // parameter for General_ShowAlert()
773#define ALERT_DIALOG_SHOW_AS_INFO false // parameter for General_ShowAlert()
774
775#define ALERT_DIALOG_INCLUDE_CANCEL true // parameter for General_ShowAlert()
776#define ALERT_DIALOG_NO_CANCEL_BTN false // parameter for General_ShowAlert()
777
778#define ALERT_DIALOG_1ST_BUTTON 0 // return value for General_ShowAlert()
779#define ALERT_DIALOG_2ND_BUTTON 1 // return value for General_ShowAlert()
780#define ALERT_DIALOG_3RD_BUTTON 2 // return value for General_ShowAlert()
781// NOTE: can't define "OK" as 1 or 0, because it depends on passing ok, then cancel (eg). Buttons appear to be numbered from RIGHT to LEFT!
782
783
784// System Default Colors - correspond to the CLUT loaded by sys lib
785
786#define SYS_COLOR_WHITE 244 // = 0xF4
787#define SYS_COLOR_GRAY1 (SYS_COLOR_WHITE + 1)
788#define SYS_COLOR_GRAY2 (SYS_COLOR_WHITE + 2)
789#define SYS_COLOR_GRAY3 (SYS_COLOR_WHITE + 3)
790#define SYS_COLOR_GRAY4 (SYS_COLOR_WHITE + 4)
791#define SYS_COLOR_GRAY5 (SYS_COLOR_WHITE + 5)
792#define SYS_COLOR_GRAY6 (SYS_COLOR_WHITE + 6)
793#define SYS_COLOR_GRAY7 (SYS_COLOR_WHITE + 7)
794#define SYS_COLOR_GRAY8 (SYS_COLOR_WHITE + 8)
795#define SYS_COLOR_GRAY9 (SYS_COLOR_WHITE + 9)
796#define SYS_COLOR_GRAY10 (SYS_COLOR_WHITE + 10)
797#define SYS_COLOR_BLACK 255
798
799#define SYS_COLOR_RED1 35 // = 0x23
800#define SYS_COLOR_RED2 (SYS_COLOR_RED1 + 36*5+1) // 3rd lightest red
801#define SYS_COLOR_RED3 (SYS_COLOR_RED2 + 3)
802
803#define SYS_COLOR_GREEN1 23*8+1
804#define SYS_COLOR_GREEN2 (SYS_COLOR_GREEN1 + 2)
805#define SYS_COLOR_GREEN3 (SYS_COLOR_GREEN2 + 2)
806
807#define SYS_COLOR_BLUE1 26*8+3 // = 211 = 0xd3
808#define SYS_COLOR_BLUE2 (SYS_COLOR_BLUE1 + 2)
809#define SYS_COLOR_BLUE3 (SYS_COLOR_BLUE2 + 2)
810
811#define SYS_COLOR_PURPLEBLUE (15*8+7) // purplish blue = 127 = 0x7F
812#define SYS_COLOR_PURPLEBLUEINACT SYS_COLOR_GRAY3 // light gray inactive accent color for purplish blue = 85 = 0x55
813#define SYS_COLOR_PURPLEBLUEHL (6*7+1) // light active accent color for purplish blue = 37 = 0x2B
814#define SYS_COLOR_TETRA_1 (14 * 4 + 0) // wine color (CC6699) that is tetradic for SYS_COLOR_PURPLEBLUE = 56 = 0x38
815#define SYS_COLOR_TETRA_2 (11 * 4 + 1) // yellowish (CCCC66) color that is tetradic for SYS_COLOR_PURPLEBLUE = 44 = 0x2C
816#define SYS_COLOR_TETRA_3 (29 * 4 + 0) // teal/greenish color (66CC99) that is tetradic for SYS_COLOR_PURPLEBLUE = 116 = 0x74
817
818#define SYS_DEF_COLOR_WINFRAME SYS_COLOR_BLACK
819#define SYS_DEF_COLOR_WINTITLE_BACK SYS_COLOR_PURPLEBLUE
820#define SYS_DEF_COLOR_WINTITLE_TEXT SYS_COLOR_WHITE
821#define SYS_DEF_COLOR_ICONBAR_BACK SYS_COLOR_PURPLEBLUE
822#define SYS_DEF_COLOR_CONTENT_BACK SYS_COLOR_WHITE
823#define SYS_DEF_COLOR_BUTTON_BACK SYS_COLOR_GRAY7
824#define SYS_DEF_COLOR_BUTTON_PUSH SYS_COLOR_PURPLEBLUE
825#define SYS_DEF_COLOR_BUTTON_TEXT SYS_COLOR_WHITE
826#define SYS_DEF_COLOR_BUTTON_TEXT_DIS SYS_COLOR_GRAY3
827#define SYS_DEF_COLOR_DESKTOP SYS_COLOR_GRAY4
828
829
830
831typedef uint8_t ColorIdx;
832
833
834// "character" definitions for each key. Might be how it gets rendered, but can also just be an ID#
835
836#define CH_ALT_OFFSET 96 // this is amount that will be added to key press if ALT is held down.
837// #define CH_LSHIFT 0x00
838// #define CH_RSHIFT 0x01
839// #define CH_LCTRL 0x02
840// #define CH_RCTRL 0x03
841// #define CH_LALT 0x04
842// #define CH_RALT 0x05
843// #define CH_LMETA 0x06
844// #define CH_RMETA 0x07
845// #define CH_CAPS 0x08
846//
847// #define CH_CURS_UP 0x10
848// #define CH_CURS_DOWN 0x0e
849// #define CH_CURS_LEFT 0x02
850// #define CH_CURS_RIGHT 0x06
851// #define CH_DEL 0x04
852#define CH_LF 10
853#define CH_FF 12
854#define CH_ENTER 13
855#define CH_ESC 27
856#define CH_TAB 9
857#define CH_COPYRIGHT 215
858#define CH_BKSP 0x08
859#define CH_DEL 0x7F // 127
860#define CH_MENU 0xFF // no particular reason for selecting FF.
861
862#define CH_K0 '0'
863#define CH_K1 '1'
864#define CH_K2 '2'
865#define CH_K3 '3'
866#define CH_K4 '4'
867#define CH_K5 '5'
868#define CH_K6 '6'
869#define CH_K7 '7'
870#define CH_K8 '8'
871#define CH_K9 '9'
872#define CH_KENTER (CH_ENTER)
873#define CH_KPLUS '+'
874#define CH_KMINUS '-'
875#define CH_KTIMES '*'
876#define CH_KDIV '/'
877#define CH_KPOINT '.'
878// #define CH_NUM 0x81
879// #define CH_SCROLL 0x81
880// #define CH_SYSREQ 0x81
881// #define CH_HOME 0x01
882// #define CH_END 0x05
883// #define CH_INS KEY_INS
884// #define CH_PGUP 0x1A
885// #define CH_PGDN 0x16
886
887
888/*****************************************************************************/
889/* Standard Foenix Character Points */
890/*****************************************************************************/
891
892// Standard alpha-numeric characters
893#define CH_SPACE 32
894#define CH_BANG 33
895#define CH_DQUOTE 34
896#define CH_HASH 35
897#define CH_DOLLAR 36
898#define CH_PERCENT 37
899#define CH_AMP 38
900#define CH_SQUOTE 39
901#define CH_LPAREN 40
902#define CH_RPAREN 41
903#define CH_AST 42
904#define CH_PLUS 43
905#define CH_COMMA 44
906#define CH_MINUS 45
907#define CH_PERIOD 46
908#define CH_FSLASH 47
909#define CH_0 48
910#define CH_1 49
911#define CH_2 50
912#define CH_3 51
913#define CH_4 52
914#define CH_5 53
915#define CH_6 54
916#define CH_7 55
917#define CH_8 56
918#define CH_9 57
919#define CH_COLON 58
920#define CH_SEMIC 59
921#define CH_LESS 60
922#define CH_EQUAL 61
923#define CH_GREATER 62
924#define CH_QUESTION 63
925#define CH_AT 64
926#define CH_UC_A 65
927#define CH_UC_B (CH_UC_A + 1)
928#define CH_UC_C (CH_UC_B + 1)
929#define CH_UC_D (CH_UC_C + 1)
930#define CH_UC_E (CH_UC_D + 1)
931#define CH_UC_F (CH_UC_E + 1)
932#define CH_UC_G (CH_UC_F + 1)
933#define CH_UC_H (CH_UC_G + 1)
934#define CH_UC_I (CH_UC_H + 1)
935#define CH_UC_J (CH_UC_I + 1)
936#define CH_UC_K (CH_UC_J + 1)
937#define CH_UC_L (CH_UC_K + 1)
938#define CH_UC_M (CH_UC_L + 1)
939#define CH_UC_N (CH_UC_M + 1)
940#define CH_UC_O (CH_UC_N + 1)
941#define CH_UC_P (CH_UC_O + 1)
942#define CH_UC_Q (CH_UC_P + 1)
943#define CH_UC_R (CH_UC_Q + 1)
944#define CH_UC_S (CH_UC_R + 1)
945#define CH_UC_T (CH_UC_S + 1)
946#define CH_UC_U (CH_UC_T + 1)
947#define CH_UC_V (CH_UC_U + 1)
948#define CH_UC_W (CH_UC_V + 1)
949#define CH_UC_X (CH_UC_W + 1)
950#define CH_UC_Y (CH_UC_X + 1)
951#define CH_UC_Z (CH_UC_Y + 1)
952#define CH_LBRACKET 91
953#define CH_BSLASH 92
954#define CH_RBRACKET 93
955#define CH_CARET 94
956#define CH_UNDER 95
957#define CH_LSQUOTE 96
958#define CH_LC_A (CH_UC_A + 32)
959#define CH_LC_B (CH_LC_A + 1)
960#define CH_LC_C (CH_LC_B + 1)
961#define CH_LC_D (CH_LC_C + 1)
962#define CH_LC_E (CH_LC_D + 1)
963#define CH_LC_F (CH_LC_E + 1)
964#define CH_LC_G (CH_LC_F + 1)
965#define CH_LC_H (CH_LC_G + 1)
966#define CH_LC_I (CH_LC_H + 1)
967#define CH_LC_J (CH_LC_I + 1)
968#define CH_LC_K (CH_LC_J + 1)
969#define CH_LC_L (CH_LC_K + 1)
970#define CH_LC_M (CH_LC_L + 1)
971#define CH_LC_N (CH_LC_M + 1)
972#define CH_LC_O (CH_LC_N + 1)
973#define CH_LC_P (CH_LC_O + 1)
974#define CH_LC_Q (CH_LC_P + 1)
975#define CH_LC_R (CH_LC_Q + 1)
976#define CH_LC_S (CH_LC_R + 1)
977#define CH_LC_T (CH_LC_S + 1)
978#define CH_LC_U (CH_LC_T + 1)
979#define CH_LC_V (CH_LC_U + 1)
980#define CH_LC_W (CH_LC_V + 1)
981#define CH_LC_X (CH_LC_W + 1)
982#define CH_LC_Y (CH_LC_X + 1)
983#define CH_LC_Z (CH_LC_Y + 1)
984#define CH_LCBRACKET 123
985#define CH_PIPE 124
986#define CH_RCBRACKET 125
987#define CH_TILDE 126
988
989
990// FOENSCII graphic characters
991#define CH_VFILL_UP_1 95 // underscore
992#define CH_VFILL_UP_2 1
993#define CH_VFILL_UP_3 2
994#define CH_VFILL_UP_4 3
995#define CH_VFILL_UP_5 4
996#define CH_VFILL_UP_6 5
997#define CH_VFILL_UP_7 6
998#define CH_VFILL_UP_8 7 // solid inverse space
999#define CH_VFILL_DN_8 7 // solid inverse space
1000#define CH_VFILL_DN_7 8
1001#define CH_VFILL_DN_6 9
1002#define CH_VFILL_DN_5 10
1003#define CH_VFILL_DN_4 11
1004#define CH_VFILL_DN_3 12
1005#define CH_VFILL_DN_2 13
1006#define CH_VFILL_DN_1 14
1007
1008#define CH_VFILLC_UP_1 192 // same as solid fill up/down, but checkered
1009#define CH_VFILLC_UP_2 193
1010#define CH_VFILLC_UP_3 194
1011#define CH_VFILLC_UP_4 195
1012#define CH_VFILLC_UP_5 196
1013#define CH_VFILLC_UP_6 197
1014#define CH_VFILLC_UP_7 198
1015#define CH_VFILLC_UP_8 199 // full checkered block
1016#define CH_VFILLC_DN_8 199 // full checkered block
1017#define CH_VFILLC_DN_7 200
1018#define CH_VFILLC_DN_6 201
1019#define CH_VFILLC_DN_5 202
1020#define CH_VFILLC_DN_4 203
1021#define CH_VFILLC_DN_3 204
1022#define CH_VFILLC_DN_2 205
1023#define CH_VFILLC_DN_1 206
1024
1025#define CH_HFILL_UP_1 134
1026#define CH_HFILL_UP_2 135
1027#define CH_HFILL_UP_3 136
1028#define CH_HFILL_UP_4 137
1029#define CH_HFILL_UP_5 138
1030#define CH_HFILL_UP_6 139
1031#define CH_HFILL_UP_7 140
1032#define CH_HFILL_UP_8 7 // solid inverse space
1033#define CH_HFILL_DN_8 7 // solid inverse space
1034#define CH_HFILL_DN_7 141
1035#define CH_HFILL_DN_6 142
1036#define CH_HFILL_DN_5 143
1037#define CH_HFILL_DN_4 144
1038#define CH_HFILL_DN_3 145
1039#define CH_HFILL_DN_2 146
1040#define CH_HFILL_DN_1 147
1041
1042#define CH_HFILLC_UP_1 207
1043#define CH_HFILLC_UP_2 208
1044#define CH_HFILLC_UP_3 209
1045#define CH_HFILLC_UP_4 210
1046#define CH_HFILLC_UP_5 211
1047#define CH_HFILLC_UP_6 212
1048#define CH_HFILLC_UP_7 213
1049#define CH_HFILLC_UP_8 199 // full checkered block
1050#define CH_HFILLC_DN_8 199 // full checkered block
1051#define CH_HFILLC_DN_7 214
1052#define CH_HFILLC_DN_6 216
1053#define CH_HFILLC_DN_5 217
1054#define CH_HFILLC_DN_4 218
1055#define CH_HFILLC_DN_3 219
1056#define CH_HFILLC_DN_2 220
1057#define CH_HFILLC_DN_1 221
1058
1059#define CH_HDITH_1 15 // horizontal dither patterns...
1060#define CH_HDITH_2 16
1061#define CH_HDITH_3 17
1062#define CH_HDITH_4 18
1063#define CH_HDITH_5 19
1064#define CH_HDITH_6 20
1065#define CH_HDITH_7 21
1066#define CH_HDITH_8 22
1067#define CH_HDITH_9 23
1068#define CH_HDITH_10 24
1069
1070#define CH_DITH_L1 16 // full-block dither patterns
1071#define CH_DITH_L2 18
1072#define CH_DITH_L3 199
1073#define CH_DITH_L4 21
1074#define CH_DITH_L5 23
1075
1076#define CH_VDITH_1 25 // vertical dither patterns...
1077#define CH_VDITH_2 26
1078#define CH_VDITH_3 27
1079#define CH_VDITH_4 28
1080#define CH_VDITH_5 29
1081
1082#define CH_DIAG_R1 186 // diagonal patterns and lines...
1083#define CH_DIAG_R2 30
1084
1085#define CH_DIAG_R3 184
1086#define CH_DIAG_R4 230
1087#define CH_DIAG_R5 234
1088#define CH_DIAG_R6 238
1089
1090#define CH_DIAG_R7 229
1091#define CH_DIAG_R8 233
1092#define CH_DIAG_R9 237
1093#define CH_DIAG_R10 241
1094
1095#define CH_DIAG_L1 187
1096#define CH_DIAG_L2 31
1097
1098#define CH_DIAG_L3 228
1099#define CH_DIAG_L4 232
1100#define CH_DIAG_L5 236
1101#define CH_DIAG_L6 240
1102
1103#define CH_DIAG_L7 185
1104#define CH_DIAG_L8 231
1105#define CH_DIAG_L9 235
1106#define CH_DIAG_L10 239
1107
1108#define CH_DIAG_X 159
1109
1110#define CH_HLINE_UP_1 95 // underscore
1111#define CH_HLINE_UP_2 148
1112#define CH_HLINE_UP_3 149
1113#define CH_HLINE_UP_4 150
1114#define CH_HLINE_UP_5 151
1115#define CH_HLINE_UP_6 152
1116#define CH_HLINE_UP_7 153
1117#define CH_HLINE_UP_8 14
1118#define CH_HLINE_DN_8 CH_HLINE_UP_8
1119#define CH_HLINE_DN_7 CH_HLINE_UP_7
1120#define CH_HLINE_DN_6 CH_HLINE_UP_6
1121#define CH_HLINE_DN_5 CH_HLINE_UP_5
1122#define CH_HLINE_DN_4 CH_HLINE_UP_4
1123#define CH_HLINE_DN_3 CH_HLINE_UP_3
1124#define CH_HLINE_DN_2 CH_HLINE_UP_2
1125#define CH_HLINE_DN_1 CH_HLINE_UP_1
1126
1127#define CH_VLINE_UP_1 134
1128#define CH_VLINE_UP_2 133
1129#define CH_VLINE_UP_3 132
1130#define CH_VLINE_UP_4 131
1131#define CH_VLINE_UP_5 130
1132#define CH_VLINE_UP_6 129
1133#define CH_VLINE_UP_7 128
1134#define CH_VLINE_UP_8 147
1135#define CH_VLINE_DN_8 CH_VLINE_UP_8
1136#define CH_VLINE_DN_7 CH_VLINE_UP_7
1137#define CH_VLINE_DN_6 CH_VLINE_UP_6
1138#define CH_VLINE_DN_5 CH_VLINE_UP_5
1139#define CH_VLINE_DN_4 CH_VLINE_UP_4
1140#define CH_VLINE_DN_3 CH_VLINE_UP_3
1141#define CH_VLINE_DN_2 CH_VLINE_UP_2
1142#define CH_VLINE_DN_1 CH_VLINE_UP_1
1143
1144#define CH_LINE_WE 150 // box-drawing lines. read clockwise from west. N=up-facing line, E=right-facing line, etc.
1145#define CH_LINE_NS 130
1146#define CH_LINE_NES 154
1147#define CH_LINE_WES 155
1148#define CH_LINE_WNES 156
1149#define CH_LINE_WNE 157
1150#define CH_LINE_WNS 158
1151#define CH_LINE_ES 160 // square edge corners
1152#define CH_LINE_WS 161
1153#define CH_LINE_NE 162
1154#define CH_LINE_WN 163
1155#define CH_LINE_RND_ES 188 // rounded edge corners
1156#define CH_LINE_RND_WS 189
1157#define CH_LINE_RND_NE 190
1158#define CH_LINE_RND_WN 191
1159
1160#define CH_LINE_BLD_WE 173 // thick box-drawing lines. read clockwise from west. N=up-facing line, E=right-facing line, etc.
1161#define CH_LINE_BLD_NS 174
1162#define CH_LINE_BLD_NES 164
1163#define CH_LINE_BLD_WES 165
1164#define CH_LINE_BLD_WNES 166
1165#define CH_LINE_BLD_WNE 167
1166#define CH_LINE_BLD_WNS 168
1167#define CH_LINE_BLD_ES 169 // square edge corners
1168#define CH_LINE_BLD_WS 170
1169#define CH_LINE_BLD_NE 171
1170#define CH_LINE_BLD_WN 172
1171#define CH_LINE_BLD_RND_ES 175 // rounded edge corners
1172#define CH_LINE_BLD_RND_WS 176
1173#define CH_LINE_BLD_RND_NE 177
1174#define CH_LINE_BLD_RND_WN 178
1175
1176#define CH_BLOCK_N 11 // half-width/height block characters. read clockwise from west. N=upper, E=right-side, etc.
1177#define CH_BLOCK_S 3
1178#define CH_BLOCK_W 137
1179#define CH_BLOCK_E 144
1180#define CH_BLOCK_SE 242
1181#define CH_BLOCK_SW 243
1182#define CH_BLOCK_NE 244
1183#define CH_BLOCK_NW 245
1184#define CH_BLOCK_NWSE 246
1185#define CH_BLOCK_SWNE 247
1186
1187#define CH_MISC_GBP 0
1188#define CH_MISC_VTILDE 127
1189#define CH_MISC_COPY 215
1190#define CH_MISC_FOENIX 223
1191#define CH_MISC_CHECKMARK 222
1192#define CH_MISC_HEART 252
1193#define CH_MISC_DIA 253
1194#define CH_MISC_SPADE 254
1195#define CH_MISC_CLUB 255
1196
1197#define CH_ARROW_DN 248
1198#define CH_ARROW_LEFT 249
1199#define CH_ARROW_RIGHT 250
1200#define CH_ARROW_UP 251
1201// circular shapes, from larger to smaller
1202#define CH_CIRCLE_1 180 // full-size filled circle
1203#define CH_CIRCLE_2 225 // full-size selected radio button circle
1204#define CH_CIRCLE_3 179 // full-size empty circle
1205#define CH_CIRCLE_4 226 // medium-size filled circle
1206#define CH_CIRCLE_5 182 // small circle (square tho)
1207#define CH_CIRCLE_6 183 // tiny circle (1 pixel)
1208// square shapes, from larger to smaller
1209#define CH_RECT_1 7 // full-size filled square
1210#define CH_RECT_2 227 // full-size empty square
1211#define CH_RECT_3 181 // almost-full size filled square
1212#define CH_RECT_4 224 // medium-size filled square
1213#define CH_RECT_5 182 // small square
1214#define CH_RECT_6 183 // tiny square (1 pixel)
1215
1216
1217// Japanese JIS characters plus 6 custom from PC-8001
1218#define CH_JA_HOUR 24
1219#define CH_JA_MIN 25
1220#define CH_JA_SEC 26
1221#define CH_JA_YEAR 28
1222#define CH_JA_MONTH 29
1223#define CH_JA_DAY 192
1224
1225#define CH_JIS_FIRST 193
1226#define CH_JIS_KUTEN 193
1227#define CH_JIS_OPEN 194
1228#define CH_JIS_CLOSE 195
1229#define CH_JIS_DOKUTEN 196
1230#define CH_JIS_MID 197
1231#define CH_JIS_WO 198
1232#define CH_JIS_L_A 199
1233#define CH_JIS_L_I 200
1234#define CH_JIS_L_U 201
1235#define CH_JIS_L_E 202
1236#define CH_JIS_L_O 203
1237#define CH_JIS_L_YA 204
1238#define CH_JIS_L_YU 205
1239#define CH_JIS_L_YO 206
1240#define CH_JIS_L_TU 207
1241#define CH_JIS_BOU 208
1242#define CH_JIS_A 209
1243#define CH_JIS_I 210
1244#define CH_JIS_U 211
1245#define CH_JIS_E 212
1246#define CH_JIS_O 213
1247#define CH_JIS_KA 214
1248#define CH_JIS_KI 215
1249#define CH_JIS_KU 216
1250#define CH_JIS_KE 217
1251#define CH_JIS_KO 218
1252#define CH_JIS_SA 219
1253#define CH_JIS_SHI 220
1254#define CH_JIS_SU 221
1255#define CH_JIS_SE 222
1256#define CH_JIS_SO 223
1257#define CH_JIS_TA 224
1258#define CH_JIS_TI 225
1259#define CH_JIS_TSU 226
1260#define CH_JIS_TE 227
1261#define CH_JIS_TO 228
1262#define CH_JIS_NA 229
1263#define CH_JIS_NI 230
1264#define CH_JIS_NU 231
1265#define CH_JIS_NE 232
1266#define CH_JIS_NO 233
1267#define CH_JIS_HA 234
1268#define CH_JIS_HI 235
1269#define CH_JIS_HU 236
1270#define CH_JIS_HE 237
1271#define CH_JIS_HO 238
1272#define CH_JIS_MA 239
1273#define CH_JIS_MI 240
1274#define CH_JIS_MU 241
1275#define CH_JIS_ME 242
1276#define CH_JIS_MO 243
1277#define CH_JIS_YA 244
1278#define CH_JIS_YU 245
1279#define CH_JIS_YO 246
1280#define CH_JIS_RA 247
1281#define CH_JIS_RI 248
1282#define CH_JIS_RU 249
1283#define CH_JIS_RE 250
1284#define CH_JIS_RO 251
1285#define CH_JIS_WA 252
1286#define CH_JIS_N 253
1287#define CH_JIS_B 254
1288#define CH_JIS_P 255
1289#define CH_JIS_LAST 255
1290
1291
1292/*****************************************************************************/
1293/* Named Characters for Box Drawing */
1294/*****************************************************************************/
1295
1296#define SC_HLINE 150
1297#define SC_VLINE 130
1298#define SC_ULCORNER 160
1299#define SC_URCORNER 161
1300#define SC_LLCORNER 162
1301#define SC_LRCORNER 163
1302#define SC_ULCORNER_RND 188
1303#define SC_URCORNER_RND 189
1304#define SC_LLCORNER_RND 190
1305#define SC_LRCORNER_RND 191
1306#define SC_CHECKERED 199
1307#define SC_T_DOWN 155 // T-shape pointing down
1308#define SC_T_UP 157 // T-shape pointing up
1309#define SC_T_LEFT 158 // T-shape pointing left
1310#define SC_T_RIGHT 154 // T-shape pointing right
1311#define SC_T_JUNCTION 156 // + shape meeting of 4 lines
1312
1313/*****************************************************************************/
1314/* Enumerations */
1315/*****************************************************************************/
1316
1317typedef enum
1318{
1319 back_layer = 0,
1320 fore_layer = 1,
1321} bitmap_layer;
1322
1323// device-independent resolution flags
1324typedef enum
1325{
1326 RES_640X400 = 0,
1327 RES_640X480,
1328 RES_800X600,
1329 RES_1024X768,
1330} screen_resolution;
1331
1332/*****************************************************************************/
1333/* Structs */
1334/*****************************************************************************/
1335
1336// forward declarations
1337typedef struct Font Font; // defined in font.h
1338typedef struct Window Window; // defined in window.h
1339typedef struct ClipRect ClipRect; // defined in window.h
1340typedef struct NewWinTemplate NewWinTemplate; // defined in window.h
1341typedef struct Theme Theme; // defined in theme.h
1342typedef struct ControlBackdrop ControlBackdrop; // defined in theme.h
1343typedef struct Control Control; // defined in control.h
1344typedef struct ControlTemplate ControlTemplate; // defined in control.h
1345typedef struct System System; // defined in lib_sys.h
1346typedef struct Bitmap Bitmap; // defined in bitmap.h
1347typedef struct List List; // defined in list.h
1348typedef struct EventRecord EventRecord; // defined in event.h
1349typedef struct EventKeyboard EventKeyboard; // defined in event.h
1350typedef struct EventMenu EventMenu; // defined in event.h
1351typedef struct EventMouse EventMouse; // defined in event.h
1352typedef struct EventWindow EventWindow; // defined in event.h
1353typedef struct EventManager EventManager; // defined in event.h
1354typedef struct MouseTracker MouseTracker; // defined in mouse.h
1355typedef struct MenuItem MenuItem; // defined in menu.h
1356typedef struct MenuGroup MenuGroup; // defined in menu.h
1357typedef struct Menu Menu; // defined in menu.h
1358
1359//typedef enum event_modifiers event_modifiers; // defined in event.h
1360
1361
1362// typedef struct Coordinate
1363// {
1364// int16_t x;
1365// int16_t y;
1366// } Coordinate;
1367
1368typedef struct Rectangle
1369{
1370 int16_t MinX, MinY;
1371 int16_t MaxX, MaxY;
1372} Rectangle;
1373
1374typedef struct Screen
1375{
1376 int16_t id_; // 0 for channel A, 1 for channel B. not all foenix's have 2 channels.
1377 volatile uint32_t* vicky_; // VICKY primary register RAM loc. See VICKY_A_BASE_ADDRESS, VICKY_B_BASE_ADDRESS, VICKY_A2560U, etc.
1378 Rectangle rect_; // the x1, y1, > x2, y2 coordinates of the screen, taking into account any borders.
1379 int16_t width_; // for the current resolution, the max horizontal pixel count
1380 int16_t height_; // for the current resolution, the max vertical pixel count
1381 int16_t text_cols_vis_; // accounting for borders, the number of visible columns on screen
1382 int16_t text_rows_vis_; // accounting for borders, the number of visible rows on screen
1383 int16_t text_mem_cols_; // for the current resolution, the total number of columns per row in VRAM. Use for plotting x,y
1384 int16_t text_mem_rows_; // for the current resolution, the total number of rows per row in VRAM. Use for plotting x,y
1385 char* text_ram_;
1386 char* text_attr_ram_;
1387 char* text_font_ram_; // 2K of memory holding font definitions.
1388 uint32_t* text_color_fore_ram_; // 64b of memory holding foreground color LUTs for text mode, in BGRA order
1389 uint32_t* text_color_back_ram_; // 64b of memory holding background color LUTs for text mode, in BGRA order
1390 int16_t text_font_height_; // in text mode, the height in pixels for the fixed width font. Should be either 8 or 16, depending on which Foenix. used for calculating text fit.
1391 int16_t text_font_width_; // in text mode, the width in pixels for the fixed width font. Unlikely to be other than '8' with Foenix machines. used for calculating text fit.
1392// char text_temp_buffer_1_[TEXT_COL_COUNT_FOR_PLOTTING_A2560K * TEXT_ROW_COUNT_FOR_PLOTTING_A2560K + 1]; // todo: replace with pointer, and allocate space on resolution switch. general use temp buffer - do NOT use for real storage - any utility function clobber it
1393// char text_temp_buffer_2_[TEXT_COL_COUNT_FOR_PLOTTING_A2560K * TEXT_ROW_COUNT_FOR_PLOTTING_A2560K + 1]; // todo: replace with pointer, and allocate space on resolution switch. general use temp buffer - do NOT use for real storage - any utility function clobber it
1394 Bitmap* bitmap_[2];
1395} Screen;
1396
1397
1398
1399/*****************************************************************************/
1400/* Global Variables */
1401/*****************************************************************************/
1402
1403
1404/*****************************************************************************/
1405/* Public Function Prototypes */
1406/*****************************************************************************/
1407
1408
1409
1410
1411
1412#endif /* A2560_PLATFORM_H_ */
Definition: bitmap.h:97
Definition: window.h:127
Definition: theme.h:95
This structure describes an instantiated control on a window.
Definition: control.h:130
A structure that can be used to instantiate a ControlTemplate object instance in a window The Control...
Definition: control_template.h:69
Definition: event.h:181
Definition: event.h:225
Definition: event.h:189
Definition: event.h:195
Definition: event.h:211
Definition: event.h:202
This Font object is essentially the Mac "fontRecord" struct, with added pointers for the data tables.
Definition: font.h:71
Definition: list.h:67
Definition: menu.h:110
Definition: menu.h:120
Definition: menu.h:100
Definition: mouse.h:85
Definition: window.h:217
Definition: a2560k.h:1369
Definition: a2560k.h:1375
Definition: sys.h:91
Definition: theme.h:106
Definition: window.h:135