39
39
#include "pet/pets.h"
44
41
static const char Rsrc_PetCrt[] = "Crtc";
45
42
static const char Rsrc_PetRAM9[] = "Ram9";
46
43
static const char Rsrc_PetRAMA[] = "RamA";
47
44
static const char Rsrc_PetDiag[] = "DiagPin";
48
45
static const char Rsrc_PetSuper[] = "SuperPET";
51
47
/* Modified PET keymap */
52
48
static unsigned char PETnormBusiness[KEYMAP_ENTRIES] = {
53
0x60, 0x20, 0xff, 0x60, /* 0 */
54
0x20, 0xff, 0x66, 0x20, /* 4 */
55
0xff, 0xff, 0xff, 0xff, /* 8 */
56
0xff, 0xff, 0xff, 0xff, /* 12 */
57
0x50, 0x91, 0x11, 0x01, /* 16 */
58
0xff, 0x02, 0xff, 0x03, /* 20 */
59
0x92, 0x05, 0x37, 0x14, /* 24 */
60
0xff, 0xff, 0xff, 0xff, /* 28 */
61
0xff, 0x41, 0x51, 0x52, /* 32 */
62
0x12, 0x45, 0x93, 0x13, /* 36 */
63
0x03, 0x54, 0x04, 0x17, /* 40 */
64
0x94, 0x90, 0xff, 0x47, /* 44 */
65
0x10, 0x00, 0x31, 0x42, /* 48 */
66
0x92, 0x53, 0x55, 0x46, /* 52 */
67
0x36, 0x54, 0x26, 0x03, /* 56 */
68
0x34, 0x47, 0x84, 0xff, /* 60 */
69
0xff, 0x30, 0x81, 0x22, /* 64 */
70
0x43, 0x33, 0x25, 0x00, /* 68 */
71
0x26, 0x34, 0xff, 0xff, /* 72 */
72
0x64, 0xff, 0xff, 0x95, /* 76 */
73
0xff, 0x21, 0x61, 0x32, /* 80 */
74
0x23, 0x72, 0x35, 0x26, /* 84 */
75
0x95, 0x47, 0xff, 0x95, /* 88 */
76
0xff, 0x03, 0xff, 0xff, /* 92 */
77
0x40, 0x70, 0x82, 0x71, /* 96 */
78
0x62, 0x83, 0x73, 0x64, /* 100 */
79
0x86, 0xff, 0x74, 0x87, /* 104 */
80
0x67, 0xff, 0xff, 0xff, /* 108 */
81
0x94, 0xff, 0xff, 0xff, /* 112 */
82
0xff, 0xff, 0xff, 0xff, /* 116 */
83
0x15, 0x05, 0x57, 0x27, /* 120 */
84
0x77, 0xff, 0xff, 0xff /* 124 */
49
0x60, 0x20, 0xff, 0x60, /* 0 */
50
0x20, 0xff, 0x66, 0x20, /* 4 */
51
0xff, 0xff, 0xff, 0xff, /* 8 */
52
0xff, 0xff, 0xff, 0xff, /* 12 */
53
0x50, 0x91, 0x11, 0x01, /* 16 */
54
0xff, 0x02, 0xff, 0x03, /* 20 */
55
0x92, 0x05, 0x37, 0x14, /* 24 */
56
0xff, 0xff, 0xff, 0xff, /* 28 */
57
0xff, 0x41, 0x51, 0x52, /* 32 */
58
0x12, 0x45, 0x93, 0x13, /* 36 */
59
0x03, 0x54, 0x04, 0x17, /* 40 */
60
0x94, 0x90, 0xff, 0x47, /* 44 */
61
0x10, 0x00, 0x31, 0x42, /* 48 */
62
0x92, 0x53, 0x55, 0x46, /* 52 */
63
0x36, 0x54, 0x26, 0x03, /* 56 */
64
0x34, 0x47, 0x84, 0xff, /* 60 */
65
0xff, 0x30, 0x81, 0x22, /* 64 */
66
0x43, 0x33, 0x25, 0x00, /* 68 */
67
0x26, 0x34, 0xff, 0xff, /* 72 */
68
0x64, 0xff, 0xff, 0x95, /* 76 */
69
0xff, 0x21, 0x61, 0x32, /* 80 */
70
0x23, 0x72, 0x35, 0x26, /* 84 */
71
0x95, 0x47, 0xff, 0x95, /* 88 */
72
0xff, 0x03, 0xff, 0xff, /* 92 */
73
0x40, 0x70, 0x82, 0x71, /* 96 */
74
0x62, 0x83, 0x73, 0x64, /* 100 */
75
0x86, 0xff, 0x74, 0x87, /* 104 */
76
0x67, 0xff, 0xff, 0xff, /* 108 */
77
0x94, 0xff, 0xff, 0xff, /* 112 */
78
0xff, 0xff, 0xff, 0xff, /* 116 */
79
0x15, 0x05, 0x57, 0x27, /* 120 */
80
0x77, 0xff, 0xff, 0xff /* 124 */
87
83
static unsigned char PETshiftBusiness[KEYMAP_ENTRIES];
88
static unsigned char PETnormB_sflags[KEYMAP_ENTRIES/8];
89
static unsigned char PETshiftB_sflags[KEYMAP_ENTRIES/8];
84
static unsigned char PETnormB_sflags[KEYMAP_ENTRIES / 8];
85
static unsigned char PETshiftB_sflags[KEYMAP_ENTRIES / 8];
90
86
static const char IBarIconName[] = "!vicepet";
91
87
static const char PETnormfile[] = "Vice:PET.RObusi/vkm";
93
89
static kbd_keymap_t PETkeysBusiness = {
102
97
static unsigned char PETnormGraphic[KEYMAP_ENTRIES] = {
103
0x80, 0x94, 0xff, 0x80, /* 0 */
104
0x94, 0xff, 0x85, 0x94, /* 4 */
105
0xff, 0xff, 0xff, 0xff, /* 8 */
106
0xff, 0xff, 0xff, 0xff, /* 12 */
107
0x20, 0x67, 0x46, 0x56, /* 16 */
108
0xff, 0x36, 0xff, 0x87, /* 20 */
109
0x47, 0x07, 0x47, 0x26, /* 24 */
110
0xff, 0xff, 0xff, 0xff, /* 28 */
111
0xff, 0x30, 0x21, 0x22, /* 32 */
112
0x26, 0x33, 0x27, 0x86, /* 36 */
113
0x87, 0x16, 0x36, 0x27, /* 40 */
114
0x94, 0x81, 0x13, 0x17, /* 44 */
115
0x66, 0x76, 0x41, 0x31, /* 48 */
116
0x47, 0x23, 0x24, 0x34, /* 52 */
117
0x04, 0x16, 0x77, 0x87, /* 56 */
118
0x65, 0x17, 0x06, 0xff, /* 60 */
119
0xff, 0x40, 0x70, 0x51, /* 64 */
120
0x32, 0x43, 0x53, 0x76, /* 68 */
121
0x54, 0x65, 0xff, 0xff, /* 72 */
122
0xff, 0xff, 0xff, 0x64, /* 76 */
123
0xff, 0x50, 0x61, 0x42, /* 80 */
124
0x52, 0x72, 0x44, 0x54, /* 84 */
125
0x14, 0x17, 0xff, 0xff, /* 88 */
126
0xff, 0x97, 0xff, 0xff, /* 92 */
127
0x90, 0x60, 0x92, 0x71, /* 96 */
128
0x62, 0x63, 0x73, 0x96, /* 100 */
129
0x37, 0xff, 0xff, 0xff, /* 104 */
130
0xff, 0xff, 0xff, 0xff, /* 108 */
131
0x94, 0xff, 0xff, 0xff, /* 112 */
132
0xff, 0xff, 0xff, 0xff, /* 116 */
133
0x13, 0x07, 0xff, 0xff, /* 120 */
134
0xff, 0xff, 0xff, 0xff /* 124 */
98
0x80, 0x94, 0xff, 0x80, /* 0 */
99
0x94, 0xff, 0x85, 0x94, /* 4 */
100
0xff, 0xff, 0xff, 0xff, /* 8 */
101
0xff, 0xff, 0xff, 0xff, /* 12 */
102
0x20, 0x67, 0x46, 0x56, /* 16 */
103
0xff, 0x36, 0xff, 0x87, /* 20 */
104
0x47, 0x07, 0x47, 0x26, /* 24 */
105
0xff, 0xff, 0xff, 0xff, /* 28 */
106
0xff, 0x30, 0x21, 0x22, /* 32 */
107
0x26, 0x33, 0x27, 0x86, /* 36 */
108
0x87, 0x16, 0x36, 0x27, /* 40 */
109
0x94, 0x81, 0x13, 0x17, /* 44 */
110
0x66, 0x76, 0x41, 0x31, /* 48 */
111
0x47, 0x23, 0x24, 0x34, /* 52 */
112
0x04, 0x16, 0x77, 0x87, /* 56 */
113
0x65, 0x17, 0x06, 0xff, /* 60 */
114
0xff, 0x40, 0x70, 0x51, /* 64 */
115
0x32, 0x43, 0x53, 0x76, /* 68 */
116
0x54, 0x65, 0xff, 0xff, /* 72 */
117
0xff, 0xff, 0xff, 0x64, /* 76 */
118
0xff, 0x50, 0x61, 0x42, /* 80 */
119
0x52, 0x72, 0x44, 0x54, /* 84 */
120
0x14, 0x17, 0xff, 0xff, /* 88 */
121
0xff, 0x97, 0xff, 0xff, /* 92 */
122
0x90, 0x60, 0x92, 0x71, /* 96 */
123
0x62, 0x63, 0x73, 0x96, /* 100 */
124
0x37, 0xff, 0xff, 0xff, /* 104 */
125
0xff, 0xff, 0xff, 0xff, /* 108 */
126
0x94, 0xff, 0xff, 0xff, /* 112 */
127
0xff, 0xff, 0xff, 0xff, /* 116 */
128
0x13, 0x07, 0xff, 0xff, /* 120 */
129
0xff, 0xff, 0xff, 0xff /* 124 */
137
132
static unsigned char PETshiftGraphic[KEYMAP_ENTRIES];
138
static unsigned char PETnormG_sflags[KEYMAP_ENTRIES/8];
139
static unsigned char PETshiftG_sflags[KEYMAP_ENTRIES/8];
133
static unsigned char PETnormG_sflags[KEYMAP_ENTRIES / 8];
134
static unsigned char PETshiftG_sflags[KEYMAP_ENTRIES / 8];
140
135
static const char PETgrphfile[] = "Vice:PET.ROgrph/vkm";
142
137
static kbd_keymap_t PETkeysGraphic = {
150
145
static const conf_iconid_t conf_grey_xpet[] = {
161
155
static const char Rsrc_CrtcCache[] = "CrtcVideoCache";
163
157
static struct MenuVideoCache {
166
160
} MenuVideoCache = {
167
MENU_HEADER("\\MenVCaT", 200),
169
MENU_ITEM_LAST("\\MenVCaCrt")
161
MENU_HEADER("\\MenVCaT", 200),
163
MENU_ITEM_LAST("\\MenVCaCrt")
173
167
static struct MenuDisplayVideoCache {
175
const char *values[1];
169
const char *values[1];
176
170
} MenuDisplayVideoCache = {
177
{NULL, {CONF_WIN_VIDEO, 0},
178
(RO_MenuHead*)&MenuVideoCache, 1, DISP_DESC_BITFIELD, 0},
171
{ NULL, { CONF_WIN_VIDEO, 0 },
172
(RO_MenuHead*)&MenuVideoCache, 1, DISP_DESC_BITFIELD, 0 },
183
176
static config_item_t PETdependconf[] = {
184
{Rsrc_PetCrt, CONFIG_SELECT, {CONF_WIN_PET, Icon_ConfPET_PetCrt}},
185
{Rsrc_PetRAM9, CONFIG_SELECT, {CONF_WIN_PET, Icon_ConfPET_PetRAM9}},
186
{Rsrc_PetRAMA, CONFIG_SELECT, {CONF_WIN_PET, Icon_ConfPET_PetRAMA}},
187
{Rsrc_PetDiag, CONFIG_SELECT, {CONF_WIN_PET, Icon_ConfPET_PetDiagPin}},
188
{Rsrc_PetSuper, CONFIG_SELECT, {CONF_WIN_PET, Icon_ConfPET_PetSuper}},
177
{ Rsrc_PetCrt, CONFIG_SELECT, { CONF_WIN_PET, Icon_ConfPET_PetCrt } },
178
{ Rsrc_PetRAM9, CONFIG_SELECT, { CONF_WIN_PET, Icon_ConfPET_PetRAM9 } },
179
{ Rsrc_PetRAMA, CONFIG_SELECT, { CONF_WIN_PET, Icon_ConfPET_PetRAMA } },
180
{ Rsrc_PetDiag, CONFIG_SELECT, { CONF_WIN_PET, Icon_ConfPET_PetDiagPin } },
181
{ Rsrc_PetSuper, CONFIG_SELECT, { CONF_WIN_PET, Icon_ConfPET_PetSuper } },
182
{ NULL, 0, { 0, 0 } }
193
185
/* PET keyboard names */
194
186
static char PETkeyBusinessName[] = "Business";
195
187
static char PETkeyGraphicName[] = "Graphic";
196
188
static char *PetModelName = NULL;
199
190
static void petui_grey_out_machine_icons(void)
201
ui_set_icons_grey(NULL, conf_grey_xpet, 0);
192
ui_set_icons_grey(NULL, conf_grey_xpet, 0);
204
195
static void petui_bind_video_cache_menu(void)
206
ConfigMenus[CONF_MENU_VIDCACHE].menu = (RO_MenuHead*)&MenuVideoCache;
207
ConfigMenus[CONF_MENU_VIDCACHE].desc = (disp_desc_t*)&MenuDisplayVideoCache;
197
ConfigMenus[CONF_MENU_VIDCACHE].menu = (RO_MenuHead*)&MenuVideoCache;
198
ConfigMenus[CONF_MENU_VIDCACHE].desc = (disp_desc_t*)&MenuDisplayVideoCache;
210
201
static const char *petui_get_machine_ibar_icon(void)
215
206
static const char *pet_get_keyboard_name(void)
219
if (resources_get_int("KeymapIndex", &idx) != 0) idx = 0;
220
if ((idx & 2) == 0) return PETkeyBusinessName;
221
return PETkeyGraphicName;
210
if (resources_get_int("KeymapIndex", &idx) != 0) {
213
if ((idx & 2) == 0) {
214
return PETkeyBusinessName;
216
return PETkeyGraphicName;
224
219
static int set_pet_model_by_name(const char *name, const char *val)
226
util_string_set(&PetModelName, val);
227
return pet_set_model(PetModelName, NULL);
221
util_string_set(&PetModelName, val);
222
return pet_set_model(PetModelName, NULL);
231
226
static int petui_setup_config_window(int wnum)
233
if (wnum == CONF_WIN_PET)
235
wimp_window_write_icon_text(ConfWindows[CONF_WIN_PET], Icon_ConfPET_PetKbd, pet_get_keyboard_name());
228
if (wnum == CONF_WIN_PET) {
229
wimp_window_write_icon_text(ConfWindows[CONF_WIN_PET], Icon_ConfPET_PetKbd, pet_get_keyboard_name());
241
235
static int petui_menu_select_config(int *block, int wnum)
243
if (wnum == CONF_MENU_PETMODEL)
237
if (wnum == CONF_MENU_PETMODEL) {
247
ui_set_menu_display_core_string(ConfigMenus[CONF_MENU_PETMODEL].desc, set_pet_model_by_name, block[0]);
248
ui_setup_menu_display(ConfigMenus[CONF_MENU_PETMEM].desc);
249
ui_setup_menu_display(ConfigMenus[CONF_MENU_PETIO].desc);
250
ui_setup_menu_display(ConfigMenus[CONF_MENU_PETVIDEO].desc);
251
wimp_window_write_icon_text(ConfWindows[CONF_WIN_PET], Icon_ConfPET_PetKbd, pet_get_keyboard_name());
252
ui_update_rom_names();
253
for (i=0; PETdependconf[i].resource != NULL; i++)
255
ui_setup_config_item(PETdependconf + i);
240
ui_set_menu_display_core_string(ConfigMenus[CONF_MENU_PETMODEL].desc, set_pet_model_by_name, block[0]);
241
ui_setup_menu_display(ConfigMenus[CONF_MENU_PETMEM].desc);
242
ui_setup_menu_display(ConfigMenus[CONF_MENU_PETIO].desc);
243
ui_setup_menu_display(ConfigMenus[CONF_MENU_PETVIDEO].desc);
244
wimp_window_write_icon_text(ConfWindows[CONF_WIN_PET], Icon_ConfPET_PetKbd, pet_get_keyboard_name());
245
ui_update_rom_names();
246
for (i = 0; PETdependconf[i].resource != NULL; i++) {
247
ui_setup_config_item(PETdependconf + i);
262
254
static void petui_init_callbacks(void)
264
ViceMachineCallbacks.setup_config_window = petui_setup_config_window;
265
ViceMachineCallbacks.menu_select_config_main = petui_menu_select_config;
256
ViceMachineCallbacks.setup_config_window = petui_setup_config_window;
257
ViceMachineCallbacks.menu_select_config_main = petui_menu_select_config;
268
260
int petui_init(void)
272
WimpTaskName = "Vice PET";
273
petui_init_callbacks();
274
petui_bind_video_cache_menu();
275
msg = ui_emulator_init_prologue(petui_get_machine_ibar_icon());
278
util_string_set(&PetModelName, "8032");
279
ui_load_template("PetConfig", ConfWindows + CONF_WIN_PET, msg);
280
ui_emulator_init_epilogue(msg);
281
petui_grey_out_machine_icons();
264
WimpTaskName = "Vice PET";
265
petui_init_callbacks();
266
petui_bind_video_cache_menu();
267
msg = ui_emulator_init_prologue(petui_get_machine_ibar_icon());
269
util_string_set(&PetModelName, "8032");
270
ui_load_template("PetConfig", ConfWindows + CONF_WIN_PET, msg);
271
ui_emulator_init_epilogue(msg);
272
petui_grey_out_machine_icons();
287
278
void petui_shutdown(void)