Skip to content

Commit ef382b8

Browse files
Recompiled with AghDev 2.0.x; case insensitive sorting/compare; no path on commandline (com files can execute with zinc); clear some messages after they are done
1 parent 4e9a80a commit ef382b8

File tree

9 files changed

+61
-23
lines changed

9 files changed

+61
-23
lines changed

Makefile

+3
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,6 @@ bin/mc.bin: mc/launcher.bin mc/mc.asm
4242

4343
mc/launcher.bin: mc/launcher.asm mos_api.inc
4444
cd mc;$(ASM) launcher.asm
45+
46+
clean:
47+
cd mc;make clean;cd ../recode;make clean;cd ../loadfont;make clean;cd ..; rm -f bin/*.ovl bin/*.bin mos/*.bin

bin/12amc.hlp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
12AM COMMANDER
22

33
A Midnight Commander look-alike for Agon Light.
4-
v0.02 (c) 2024 L.C. Benschop.
4+
v0.03 (c) 2024 L.C. Benschop.
55

66
Keys used:
77

bin/12amc.ovl

304 Bytes
Binary file not shown.

bin/loadfont.bin

-25 Bytes
Binary file not shown.

bin/recode.bin

-24 Bytes
Binary file not shown.

mc/src/dirlist.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ static int entry_compare(const void *a, const void *b)
3535
const dirinfo_t *e1 = a;
3636
const dirinfo_t *e2 = b;
3737
if (e1->is_dir == e2->is_dir) {
38-
return strcmp(e1->name,e2->name);
38+
return my_strcasecmp(e1->name,e2->name);
3939
}
4040
else if (e1->is_dir) {
4141
return -1;
@@ -169,7 +169,7 @@ void dirlist_show(uint8_t which, struct dirlist *dir)
169169
for (row = 0; row<dirwin_height; row++) {
170170
if (idx >= dir->n_entries)
171171
break;
172-
vdp_cursor_tab(row,0);
172+
vdp_cursor_tab(0,row);
173173
dirlist_show_entry(&dir->entries[idx], row == (dir->sel_idx - dir->top_idx));
174174
idx++;
175175
}
@@ -188,7 +188,7 @@ void dirlist_move_cursor(uint8_t which, struct dirlist *dir, int direction)
188188
return;
189189
}
190190
old_row = dir->sel_idx - dir->top_idx;
191-
vdp_cursor_tab(old_row,0);
191+
vdp_cursor_tab(0,old_row);
192192
dirlist_show_entry(&dir->entries[dir->sel_idx], false);
193193
new_idx = (signed)dir->sel_idx + direction;
194194
if (new_idx < 0) {
@@ -206,7 +206,7 @@ void dirlist_move_cursor(uint8_t which, struct dirlist *dir, int direction)
206206
}
207207
dirlist_show(which,dir);
208208
} else {
209-
vdp_cursor_tab(new_row,0);
209+
vdp_cursor_tab(0,new_row);
210210
dirlist_show_entry(&dir->entries[dir->sel_idx], true);
211211
display_curfile(which,dir->entries[dir->sel_idx].name);
212212
}

mc/src/display.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ void display_frame(void)
139139
vdp_move_to(scr_cols*font_width/2+font_width-1,font_height+4);
140140
vdp_line_to(scr_cols*font_width/2+font_width-1,font_height*(4+dirwin_height)+4);
141141

142-
vdp_cursor_tab(scr_rows-1,0);
142+
vdp_cursor_tab(0,scr_rows-1);
143143
for (i=0;i<10;i++ ) {
144144
display_setattr(false,true);
145145
printf("%2d",i+1);
@@ -183,7 +183,7 @@ void display_setwin(uint8_t w)
183183
void display_curdir(uint8_t which, char *s, bool hilight)
184184
{
185185
putch(26);
186-
vdp_cursor_tab(0,(scr_cols/2)*(which-1)+1);
186+
vdp_cursor_tab((scr_cols/2)*(which-1)+1,0);
187187
display_setattr(hilight,false);
188188
printf("%-38.38s",s);
189189
display_setattr(false,false);
@@ -195,7 +195,7 @@ void display_curdir(uint8_t which, char *s, bool hilight)
195195
void display_curfile(uint8_t which, char *s)
196196
{
197197
putch(26);
198-
vdp_cursor_tab(dirwin_height+3,(scr_cols/2)*(which-1)+1);
198+
vdp_cursor_tab((scr_cols/2)*(which-1)+1,dirwin_height+3);
199199
display_setattr(false,false);
200200
printf("%-38.38s",s);
201201
}

mc/src/main.c

+45-15
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
/* 12AM COmmander, a Midnight Commander Lookalike for Agon Light.
22
11/05/2024
33
23/06/2024: added mode/font/video mode config
4+
21/07/2024: do case-insensitive compare. do not add path to filename in
5+
commands.
46
*/
57
#include <stdio.h>
68
#include <string.h>
@@ -13,6 +15,19 @@
1315
#include "mc.h"
1416

1517

18+
int my_strcasecmp(char *p,char *q)
19+
{
20+
char c1,c2;
21+
for(;;) {
22+
c1 = *p++;
23+
c2 = *q++;
24+
if (c1 >= 'a' && c1 <= 'z') c1-=0x20;
25+
if (c2 >= 'a' && c2 <= 'z') c2-=0x20;
26+
if (c1 != c2) return c1-c2;
27+
if ((c1 | c2 ) == 0) return 0;
28+
}
29+
}
30+
1631
char dirname_left[256];
1732
char dirname_right[256];
1833
struct dirlist * dirlist_left;
@@ -94,11 +109,15 @@ void execute_command(char *cmdline,bool fWait)
94109
char cmdbuf[256];
95110
char pathbuf[256];
96111

97-
void set_pathbuf(void)
112+
void set_pathbuf(bool fFullPath)
98113
{
99-
strcpy(pathbuf,which_dir==1?dirname_left:dirname_right);
100-
if (strcmp(pathbuf,"/")!=0) {
101-
strcat(pathbuf,"/");
114+
if (fFullPath) {
115+
strcpy(pathbuf,which_dir==1?dirname_left:dirname_right);
116+
if (strcmp(pathbuf,"/")!=0) {
117+
strcat(pathbuf,"/");
118+
}
119+
} else {
120+
pathbuf[0]=0;
102121
}
103122
strcat(pathbuf,dirlist_get_name(which_dir==1?dirlist_left:dirlist_right));
104123
}
@@ -183,7 +202,6 @@ char * scan_word(char*dest, char *src)
183202
return p;
184203
}
185204

186-
187205
/* Replacement for fgets as the one in AgDev appears to be broken,
188206
does not detect EOF on real machine */
189207
static char * my_fgets(char *s, unsigned int maxlen, FILE *f)
@@ -215,12 +233,12 @@ void read_cfg_file(void)
215233
cmdbuf[strlen(cmdbuf)-1] = 0; /* Get rid of trailing newline */
216234
p = cmdbuf;
217235
p = scan_word(pathbuf,p);
218-
if (strcmp(pathbuf,"view") == 0) {
236+
if (my_strcasecmp(pathbuf,"view") == 0) {
219237
strcpy(viewer_cmd,p);
220-
} else if (strcmp(pathbuf,"edit") == 0) {
238+
} else if (my_strcasecmp(pathbuf,"edit") == 0) {
221239
strcpy(editor_cmd,p);
222-
} else if (strcmp(pathbuf,"exec") == 0 || strcmp(pathbuf,"execp") == 0) {
223-
do_pause = strcmp(pathbuf,"execp") == 0;
240+
} else if (my_strcasecmp(pathbuf,"exec") == 0 || my_strcasecmp(pathbuf,"execp") == 0) {
241+
do_pause = my_strcasecmp(pathbuf,"execp") == 0;
224242
p = scan_word(pathbuf,p);
225243
while (*p++==' ')
226244
;
@@ -232,9 +250,9 @@ void read_cfg_file(void)
232250

233251
n_extensions++;
234252
}
235-
} else if (strcmp(pathbuf,"mode") == 0) {
253+
} else if (my_strcasecmp(pathbuf,"mode") == 0) {
236254
video_mode = strtol(p,&p,10);
237-
} else if (strcmp(pathbuf,"font") == 0) {
255+
} else if (my_strcasecmp(pathbuf,"font") == 0) {
238256
while (*p++ == ' ')
239257
;
240258
p--;
@@ -243,7 +261,7 @@ void read_cfg_file(void)
243261
}else {
244262
font_nr = strtol(p,&p,10);
245263
}
246-
} else if (strcmp(pathbuf,"color") == 0 || strcmp(pathbuf,"colour") == 0) {
264+
} else if (my_strcasecmp(pathbuf,"color") == 0 || my_strcasecmp(pathbuf,"colour") == 0) {
247265
fgcol = strtol(p,&p,10);
248266
bgcol = strtol(p,&p,10);
249267
hlcol = strtol(p,&p,10);
@@ -335,8 +353,9 @@ main(int argc, char *argv[])
335353
which_dir==1?dirname_left:dirname_right);
336354
} else {
337355
mos_cd(which_dir==1?dirname_left:dirname_right);
338-
set_pathbuf();
356+
set_pathbuf(false);
339357
if (has_ext(pathbuf,"bin")) {
358+
set_pathbuf(true);
340359
execute_command(pathbuf,false);
341360
} else {
342361
unsigned int i;
@@ -362,12 +381,14 @@ main(int argc, char *argv[])
362381
execute_command(cmdbuf,true);
363382
break;
364383
case 161: /* F3 view */
365-
set_pathbuf();
384+
set_pathbuf(false);
385+
mos_cd(which_dir==1?dirname_left:dirname_right);
366386
sprintf(cmdbuf,viewer_cmd,pathbuf);
367387
execute_command(cmdbuf,false);
368388
break;
369389
case 162: /* F4 Edit */
370-
set_pathbuf();
390+
set_pathbuf(false);
391+
mos_cd(which_dir==1?dirname_left:dirname_right);
371392
sprintf(cmdbuf,editor_cmd,pathbuf);
372393
execute_command(cmdbuf,false);
373394
break;
@@ -384,10 +405,12 @@ main(int argc, char *argv[])
384405
vdp_cursor_enable(true);
385406
mos_editline(pathbuf,256,true);
386407
vdp_cursor_enable(false);
408+
putch(12);
387409
mos_copy(cmdbuf,pathbuf);
388410
} else {
389411
printf("Copy %d selected files to %s? (Y/N)\n",n_selected,which_dir==1?dirname_right:dirname_left);
390412
ch = getch();
413+
putch(12);
391414
if (ch=='y' || ch=='Y') {
392415
nm = dirlist_first_selected(which_dir==1?dirlist_left:dirlist_right);
393416
while (nm != NULL) {
@@ -416,10 +439,12 @@ main(int argc, char *argv[])
416439
vdp_cursor_enable(true);
417440
mos_editline(pathbuf,256,true);
418441
vdp_cursor_enable(false);
442+
putch(12);
419443
mos_ren(cmdbuf,pathbuf);
420444
} else {
421445
printf("Move %d selected files to %s? (Y/N)\n",n_selected,which_dir==1?dirname_right:dirname_left);
422446
ch = getch();
447+
putch(12);
423448
if (ch=='y' || ch=='Y') {
424449
nm = dirlist_first_selected(which_dir==1?dirlist_left:dirlist_right);
425450
while (nm != NULL) {
@@ -443,6 +468,7 @@ main(int argc, char *argv[])
443468
vdp_cursor_enable(true);
444469
mos_editline(cmdbuf,256,true);
445470
vdp_cursor_enable(false);
471+
putch(12);
446472
mos_mkdir(cmdbuf);
447473
cmd_reload_dir();
448474
break;
@@ -457,12 +483,14 @@ main(int argc, char *argv[])
457483
strcpy(cmdbuf,dirlist_get_name(which_dir==1?dirlist_left:dirlist_right));
458484
printf("Delete file: %s? (Y/N)\n",cmdbuf);
459485
ch = getch();
486+
putch(12);
460487
if (ch=='y' || ch=='Y') {
461488
mos_del(cmdbuf);
462489
}
463490
} else {
464491
printf("Delete %d selected files? (Y/N)\n",n_selected);
465492
ch = getch();
493+
putch(12);
466494
if (ch=='y' || ch=='Y') {
467495
nm = dirlist_first_selected(which_dir==1?dirlist_left:dirlist_right);
468496
while (nm != NULL) {
@@ -503,6 +531,7 @@ main(int argc, char *argv[])
503531
vdp_cursor_enable(true);
504532
mos_editline(cmdbuf,256,true);
505533
vdp_cursor_enable(false);
534+
putch(12);
506535
dirlist_select_pattern(which_dir,which_dir==1?dirlist_left:dirlist_right,cmdbuf);
507536
break;
508537
case '\\':
@@ -513,6 +542,7 @@ main(int argc, char *argv[])
513542
vdp_cursor_enable(true);
514543
mos_editline(cmdbuf,256,true);
515544
vdp_cursor_enable(false);
545+
putch(12);
516546
dirlist_deselect_pattern(which_dir,which_dir==1?dirlist_left:dirlist_right,cmdbuf);
517547
break;
518548
case 12: /* Ctrl-L, reload directories */

mc/src/mc.h

+5
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ extern uint8_t fgcol; /* Foreground colour */
1919
extern uint8_t bgcol; /* Background colour */
2020
extern uint8_t hlcol; /* Hilite colour */
2121

22+
23+
/* Replancement for strcasecmp */
24+
int my_strcasecmp(char *p,char *q);
25+
26+
2227
/* Number of bytes fitting into a single directory window*/
2328
extern uint8_t dirwin_height;
2429

0 commit comments

Comments
 (0)