Skip to content

Commit

Permalink
+ bug-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
DnCraptor committed Mar 20, 2024
1 parent 7bc4010 commit 1e60ff1
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 38 deletions.
29 changes: 14 additions & 15 deletions src/fileman.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,12 @@ inline static void m_add_file(FILINFO* fi) {

int16_t fileman(uint8_t type, const char *text)
{
int i, j;
int n = 0, prev = 0;
DIR dir;
reread:
files_count = 0;
// Собираем каталог файлов
if (f_opendir(&dir, BASE_DIR) != FR_OK) return -1;
if (f_opendir(&dir, BASE_DIR) != FR_OK)
return -1;
FILINFO fileInfo;
while(f_readdir(&dir, &fileInfo) == FR_OK && fileInfo.fname[0] != '\0') {
m_add_file(&fileInfo);
Expand All @@ -91,8 +91,8 @@ int16_t fileman(uint8_t type, const char *text)
return -1;
}
ui_draw_text(10, 9, text);
ui_draw_text(10, 32, "ENTER - select SPACE - rename");
ui_draw_text(10, 33, "ESC - cancel DELETE - remove");
ui_draw_text(10, 28, "ENTER - select SPACE - rename");
ui_draw_text(10, 29, "ESC - cancel DELETE - remove");
// Для красивых рамок
screen.underline_y = 4;
#define PX 8
Expand All @@ -116,27 +116,26 @@ int16_t fileman(uint8_t type, const char *text)
// ui_scr[PY +21][PX + 0] = 0xC8;
// ui_scr[PY + 0][PX +60] = 0xC4;
// ui_scr[PY +21][PX +60] = 0xCC;

char str[16];
// Рисуем список файлов
for (i = 0; i < files_count; i++) {
int x = PX + 1 + (i / 18) * 17;
int y = PY + 1 + (i % 18);
for (size_t i = 0; i < files_count; i++) {
int x = PX + 1 + (i / 17) * 17;
int y = PY + 1 + (i % 17);
// Имя файла
ui_draw_text(x + 1, y, files_info[i].name);
// Размер
char str[16];
xsprintf(str, "%5d", files_info[i].fsize);
ui_draw_text(x + 10, y, str);
}

int n = 0, prev = 0;
// Выбор файла
if (n >= files_count)
n = files_count - 1;
while (1) {
if (n >= files_count)
n = files_count - 1;
// Стираем курсор с предыдущего файла
ui_scr[PY + 1 + (prev % 18)][PX + (prev / 18) * 17 + 1] = 0x80;
ui_scr[PY + 1 + (prev % 17)][PX + (prev / 17) * 17 + 1] = 0x80;
// Рисуем курсор на новом месте
ui_scr[PY + 1 + (n % 18)][PX + (n / 18) * 17 + 1] = 0x90;
ui_scr[PY + 1 + (n % 17)][PX + (n / 17) * 17 + 1] = 0x90;
// Запоминаем текущую позицию
prev = n;
// Обрабатываем нажатия кнопок
Expand Down
15 changes: 9 additions & 6 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ extern "C" uint16_t rk_by_at(uint16_t at) {
}

static const uint32_t freq = 366 * KHZ;
static uint8_t i8080_takts_in_ms = 2;
static int i8080_takts_in_ms = 1;

int main() {
hw_set_bits(&vreg_and_chip_reset_hw->vreg, VREG_AND_CHIP_RESET_VREG_VSEL_BITS);
Expand Down Expand Up @@ -229,7 +229,7 @@ int main() {
uint32_t prev_T = getCycleCount();
uint32_t sec_T = prev_T;
uint32_t sec_cycles = 0;
bool turbo = false, win = false;
bool win = false;
graphics_set_textbuffer(screen.vram);
graphics_set_mode(TEXTMODE_DEFAULT);
while(true) {
Expand All @@ -241,12 +241,14 @@ int main() {
do {
T = getCycleCount();
dT = T - prev_T;
} while(!turbo && dT < takts / i8080_takts_in_ms);
} while(i8080_takts_in_ms && dT < takts / i8080_takts_in_ms);
prev_T = T;
sec_cycles += takts;
if ( (T - sec_T) >= 1000000) {
// Прошла секунда
printf("Speed: %d; screen.vram: %04Xh; turbo: %d", sec_cycles, screen.vram - RAM, turbo);
// printf("Speed: %d; screen.vram: %04Xh; turbo: %d", sec_cycles, screen.vram - RAM, turbo);
if (i8080_takts_in_ms != 1)
snprintf((char*)screen.vram, 10, "%d", sec_cycles);
//kbd_dump();
sec_cycles = 0;
sec_T = T;
Expand Down Expand Up @@ -297,7 +299,7 @@ int main() {
// Win не нажата
uint16_t c;
bool rst=false;
ps2_leds(kbd_rus(), true, turbo);
ps2_leds(kbd_rus(), true, !i8080_takts_in_ms);
c = keymap_periodic();
switch (c) {
case 0:
Expand Down Expand Up @@ -356,7 +358,8 @@ int main() {
break;
case PS2_SCROLL:
// Переключатель турбо
turbo = !turbo;
i8080_takts_in_ms--;
if (i8080_takts_in_ms < 0) i8080_takts_in_ms = 3;
break;
case PS2_L_WIN:
case PS2_R_WIN:
Expand Down
17 changes: 8 additions & 9 deletions src/menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
bool menu_fileman(void)
{
uint8_t type;
int16_t n;

again:
ui_clear();
ui_header("RADIO-86RK -->");
Expand All @@ -37,7 +35,8 @@ bool menu_fileman(void)
}
// Выбираем файл
again2:
n = fileman(type, "Select file to load:");
ui_clear();
int16_t n = fileman(type, "Select file to load:");
if (n < 0) goto again;
// Загружаем файл
if (type != TYPE_TAPE) {
Expand Down Expand Up @@ -71,22 +70,22 @@ void menu(void) {
ui_clear();
ui_header("RADIO-86RK -->");
ui_draw_list(
"1.( F11 ) Return to the monitor (no cleanup)\n"
"2.( F12 ) File manager\n"
"3.(PrnScr) Full reset\n"
"4.(Pause ) Switch to USB mode\n"
"1. ( F11 ) Return to the monitor (no cleanup)\n"
"2. ( F12 ) File manager\n"
"3. (PrnScr) Full reset\n"
"4. (Pause ) Switch to USB mode\n"
);
ui_draw_text(10, 16,
"Keyboard mapping:\n"
"F1-F4 - F1-F4 BK - Enter\n"
"AR2 - Alt PC - Доп. Enter\n"
"AR2 - Alt PC - Right Enter\n"
"RUS/LAT - Caps Lock 3B - Backspace\n"
"YC - CTRL \\ - Home\n"
"CC - Shift CTP - End/Delete\n"
"\n"
"\n"
"Emulation Management:\n"
"F5-F10 - Call ROM E000+n*4\n"
"F5 - F10 - Call ROM E000 + n*4\n"
"Scroll Lock - Turbo mode ON/OFF\n"
"WIN+Cursor - Shift screen\n"
"MENU - Help about Radio-86RK\n"
Expand Down
10 changes: 2 additions & 8 deletions src/ui.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,16 @@
#include "align4.h"
#include "ffs.h"
#include "timer0.h"

#include "menu.h"


char ui_scr[38][80];


void ui_clear(void)
{
void ui_clear(void) {
ets_memset(ui_scr, 0x00, sizeof(ui_scr));
}


#define HEADER_Y 4
void ui_header(const char *s)
{
void ui_header(const char *s) {
static const uint8_t syms[]=
{
0, 4, 16, 20, 2, 6, 18, 22,
Expand Down

0 comments on commit 1e60ff1

Please sign in to comment.