More autoload opts, some code cleanup

This commit is contained in:
simon.kagstrom 2009-01-14 19:59:14 +00:00
parent 2f46611363
commit 647f2b9f1f
4 changed files with 53 additions and 21 deletions

View File

@ -1,10 +1,18 @@
version 4:
* TODO: load .zip?
* TODO: Add more autoload, e.g., LOAD "$",8,1, RUN, POKE
* TODO: Add cursor keys, more load options
* Some more "auto load" options, and rearranged the top menu order to help
with this
* Store preferences together with save games and reload those when the
saved state is restored again
* Corrected file extension matching
* Show current key binding in the menu
* Added ability to turn on 1541 CPU emulation in the "other options" menu
(hint from Vermeylen Schoonakker)

View File

@ -186,7 +186,7 @@ public:
TTF_Font *menu_font;
bool fake_key_sequence;
int fake_key_type;
const char *fake_key_str;
int fake_key_index;
int fake_key_keytime;
@ -194,6 +194,7 @@ public:
char save_game_name[256];
void select_disc(Prefs *np);
void run_fake_key_sequence(Prefs *np);
char * bind_one_key(Prefs *np, int which);
void bind_keys(Prefs *np);
void other_options(Prefs *np);

View File

@ -27,8 +27,8 @@
static struct timeval tv_start;
static int MENU_SIZE_X, MENU_SIZE_Y;
static const char *main_menu_messages[] = {
"Insert disc or tape", /* 0 */
"Load disc or tape", /* 1 */
"Invoke key sequence", /* 0 */
"Insert disc or tape", /* 1 */
"Reset C64", /* 2 */
"Bind key to joystick",/* 3 */
"Other options", /* 4 */
@ -72,7 +72,7 @@ void C64::c64_ctor1(void)
this->fake_key_sequence = false;
this->fake_key_index = 0;
this->fake_key_keytime = 5;
this->fake_key_type = 0;
this->fake_key_str = "\nLOAD \"*\",8,1\nRUN\n";
this->prefs_changed = false;
memset(this->save_game_name, 0, sizeof(this->save_game_name));
@ -363,7 +363,7 @@ void C64::other_options(Prefs *np)
int submenus[3] = { np->DisplayOption, 0, !np->Emul1541Proc };
#define SPEED_95 40
#define SPEED_100 38
#define SPEED_100 20
#define SPEED_110 34
switch (np->MsPerFrame)
@ -399,6 +399,34 @@ void C64::other_options(Prefs *np)
menu_fini(&display_menu);
}
void C64::run_fake_key_sequence(Prefs *np)
{
static const char *fake_key_sequences[] = {
"\nLOAD \"*\",8,1\nRUN\n",
"\nLOAD \"?\",8,1\n",
"\nLIST\n",
"\n10 PRINT \"HELLO WORLD\"\n20 GOTO 10\nRUN\n",
NULL};
const char *fake_key_messages[] = {
"LOAD \"*\",8,1 and RUN",
"LOAD \"?\",8,1",
"LIST",
"10 PRINT \"HELLO WORLD\" and 20 GOTO 10",
NULL};
menu_t fake_key_menu;
int opt;
menu_init(&fake_key_menu, this->menu_font, fake_key_messages,
32, 32, MENU_SIZE_X, MENU_SIZE_Y);
opt = menu_select(real_screen, &fake_key_menu, NULL);
if (opt < 0)
return;
this->fake_key_str = fake_key_sequences[opt];
this->fake_key_sequence = true;
}
void C64::save_load_state(Prefs *np)
{
menu_t save_load_menu;
@ -485,14 +513,6 @@ void C64::Run(void)
thread_func();
}
/* From dreamcast port */
static const char *auto_seq[4] =
{
"\nLOAD \"*\",8,1\nRUN\n",
"\nLOAD \"*\",9,1\nRUN\n",
"\nLOAD \"*\",10,1\nRUN\n",
"\nLOAD \"*\",11,1\nRUN\n",
};
extern "C" int get_kc_from_char(char c_in, int *shifted);
/*
@ -514,10 +534,11 @@ void C64::VBlank(bool draw_frame)
if (TheDisplay->quit_requested)
quit_thyself = true;
/* From dreamcast port */
if (this->fake_key_sequence)
{
int shifted;
int kc = get_kc_from_char(auto_seq[this->fake_key_type][this->fake_key_index], &shifted);
int kc = get_kc_from_char(this->fake_key_str[this->fake_key_index], &shifted);
TheDisplay->FakeKeyPress(kc, shifted, TheCIA1->KeyMatrix,
TheCIA1->RevMatrix);
@ -528,7 +549,7 @@ void C64::VBlank(bool draw_frame)
this->fake_key_keytime = 1;
this->fake_key_index ++;
if (auto_seq[this->fake_key_type][this->fake_key_index] == '\0')
if (this->fake_key_str[this->fake_key_index] == '\0')
{
this->fake_key_sequence = false;
this->fake_key_index = 0;
@ -588,11 +609,11 @@ void C64::VBlank(bool draw_frame)
switch(opt)
{
case 0: /* Insert disc/tape */
this->select_disc(&np);
case 0: /* Load disc/tape */
this->run_fake_key_sequence(&np);
break;
case 1: /* Load disc/tape */
this->fake_key_sequence = true;
case 1: /* Insert disc/tape */
this->select_disc(&np);
break;
case 2: /* Reset */
Reset();

View File

@ -19,6 +19,8 @@ static uint8_t char_to_kc[] =
{
/* Some shifted stuff */
['\"'] = MATRIX(7, 3) | SHIFT,
['\?'] = MATRIX(1, 3) | SHIFT,
['\!'] = MATRIX(7, 0) | SHIFT,
/* CUD */
/* F5 */