Skip to content

Commit

Permalink
Merge pull request #17 from T-Tudor/file_explorer
Browse files Browse the repository at this point in the history
Improved input responsiveness
  • Loading branch information
Gericom committed May 22, 2017
2 parents 4b83e97 + f70e83d commit 17694d4
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 14 deletions.
50 changes: 36 additions & 14 deletions arm9/source/sd_access.cpp
Expand Up @@ -206,7 +206,7 @@ PUT_IN_VRAM void get_folder_contents(vector& entries_names, uint32_t cur_dir_clu
//skip VOLUME_ID, HIDDEN or SYSTEM entry
for(int j = 0; j < 256/2; j++)
{
*(uint16_t*)(name_buffer + j*2) = 0x2020;
*(uint16_t*)(name_buffer + j*2) = 0x0000;
}
continue;
}
Expand Down Expand Up @@ -276,9 +276,9 @@ PUT_IN_VRAM void get_folder_contents(vector& entries_names, uint32_t cur_dir_clu
vector_add(&entries_names, file);
}

for(int j = 0; j < 16; j++)
for(int j = 0; j < 256/2; j++)
{
*(uint16_t*)(name_buffer + j*2) = 0x2020;
*(uint16_t*)(name_buffer + j*2) = 0x0000;
}

found_long_name = false;
Expand Down Expand Up @@ -323,6 +323,10 @@ PUT_IN_VRAM void get_game_first_cluster(uint32_t& cur_dir_cluster, dir_entry_t*
{
uint16_t keys = 0;
uint16_t old_keys = 0;
uint16_t new_keys = 0;
uint16_t held_keys = 0;
int countdown = KEY_REPEAT_FREQ;
int delay = KEY_HOLD_DELAY;
int start_at_position = 0;
int cursor_position = 0;
vector entries_names;
Expand All @@ -334,18 +338,36 @@ PUT_IN_VRAM void get_game_first_cluster(uint32_t& cur_dir_cluster, dir_entry_t*
while(1) {
//show cursor
MI_WriteByte((void*)0x06202000 + 32*(cursor_position - start_at_position + ENTRIES_START_ROW), 0x1A);

for (int i = 0; i < 8; i++)
{

do {
old_keys = new_keys;
new_keys = ~*((vu16*)0x04000130);

if(new_keys != old_keys)
{
countdown = KEY_REPEAT_FREQ;
delay = KEY_HOLD_DELAY;
held_keys = new_keys & ~old_keys;
}
if(--countdown == 0)
{
countdown = KEY_REPEAT_FREQ;
if(delay > 0)
{
delay--;
}
else
{
held_keys = new_keys;
}
}

keys = held_keys;
held_keys = 0;

while (*((vu16*)0x04000006) != 192);
while (*((vu16*)0x04000006) == 192);
}

//do {
old_keys = keys;
keys = ~*((vu16*)0x04000130);
// while (*((vu16*)0x04000006) != 192);
//} while (keys == old_keys);
} while (!keys);

//hide cursor
if(keys & (KEY_UP | KEY_DOWN | KEY_LEFT | KEY_RIGHT))
Expand Down Expand Up @@ -439,7 +461,7 @@ PUT_IN_VRAM void get_game_first_cluster(uint32_t& cur_dir_cluster, dir_entry_t*
find_dir_entry(cur_dir_cluster, ".. ", &prev_dir_entry, SHORT_NAME);
if(prev_dir_entry.regular_entry.short_name[0] == 0x00)
{
*((vu32*)0x06202000) = 0x544f4f52; //DNFN Directory not found
continue;
}
cur_dir_cluster = get_entrys_first_cluster(&prev_dir_entry);

Expand Down
2 changes: 2 additions & 0 deletions arm9/source/sd_access.h
Expand Up @@ -14,6 +14,8 @@
#define ENTRIES_START_ROW 2
#define ENTRIES_PER_SCREEN (SCREEN_ROWS - ENTRIES_START_ROW)
#define SKIP_ENTRIES (ENTRIES_PER_SCREEN/2 - 1)
#define KEY_HOLD_DELAY 4
#define KEY_REPEAT_FREQ 6

extern uint8_t _io_dldi;

Expand Down

0 comments on commit 17694d4

Please sign in to comment.