Skip to content

Commit

Permalink
Display version and keys help in bottom
Browse files Browse the repository at this point in the history
  • Loading branch information
nihirash committed May 12, 2019
1 parent 419980f commit a402650
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 36 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ libs = lib/esxdos.c lib/fileDialog.c lib/textUtils.c

all: scl2trd.tap

scl2trd.tap: scl2trd.c
scl2trd.tap: scl2trd.c $(libs)
zcc +zx -lndos -lmzx $(libs) scl2trd.c -o scl2trd -create-app

clean:
Expand Down
43 changes: 12 additions & 31 deletions lib/fileDialog.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*
* @author yomboprime
*
* @author nihirash
*
* File dialog using ESXDOS
*/

Expand All @@ -18,7 +19,7 @@ void fileDialogCallBackSelectEntry( uint16_t numEntry, uint8_t *entryPtr, uint8_
void fileDialogBrightSelection( uint16_t selectedEntry, bool bright );
void updateVerticalBar( uint16_t xPos, uint16_t pos, uint16_t total, uint8_t attrs1, uint8_t attrs2 );

#define OPENDIALOG_MAX_DIR_ENTRIES 20
#define OPENDIALOG_MAX_DIR_ENTRIES 18
#define OPENDIALOG_MAX_DIR_ENTRIES_2 400

/*
Expand All @@ -33,8 +34,10 @@ void updateVerticalBar( uint16_t xPos, uint16_t pos, uint16_t total, uint8_t att
* appended to this string.
* maxPathLength: If the total path exceeds this length, the function will return false (error)
* attrs1, attrs2: Different colour attributes for the dialog.
*
* Modified: 64 char mode
*/
bool openFileDialog( uint8_t *message, uint8_t *path, int16_t maxPathLength, uint8_t attrs1, uint8_t attrs2 ) {
bool openFileDialog( uint8_t *message, uint8_t *bottomMessage, uint8_t *path, int16_t maxPathLength, uint8_t attrs1, uint8_t attrs2 ) {

uint8_t fileName[ 13 + 1 ];

Expand All @@ -48,7 +51,7 @@ bool openFileDialog( uint8_t *message, uint8_t *path, int16_t maxPathLength, uin

uint16_t totalEntries = 0;

uint16_t titleX = 16 - ( strlen( message ) >> 1 );
uint16_t titleX = 32 - ( strlen( message ) >> 1 );

bool refreshDirectory = true;

Expand All @@ -61,6 +64,10 @@ bool openFileDialog( uint8_t *message, uint8_t *path, int16_t maxPathLength, uin
textUtils_printAt( titleX, 1 );
textUtils_print( message );

textUtils_setAttributes ( attrs1 );
textUtils_printAt(0, 22);
textUtils_print( bottomMessage );

while ( 1 ) {

if ( refreshDirectory == true ) {
Expand Down Expand Up @@ -168,9 +175,6 @@ bool openFileDialog( uint8_t *message, uint8_t *path, int16_t maxPathLength, uin

break;
}

//textUtils_print( "Key: " );
//textUtils_println_l( key );
}

return false;
Expand Down Expand Up @@ -248,9 +252,7 @@ uint16_t fileDialogIterateSDDirectory( uint8_t *dirPath, uint16_t firstEntry, ui
}

void fileDialogBrightSelection( uint16_t selectedEntry, bool bright ) {

textUtils_paintSegmentWithBright( 2, 29, 3 + selectedEntry, bright );

}

void filedialogCallBackPrintEntry( uint16_t numEntry, uint8_t *entryPtr, uint8_t *userData ) {
Expand Down Expand Up @@ -284,27 +286,6 @@ void filedialogCallBackPrintEntry( uint16_t numEntry, uint8_t *entryPtr, uint8_t
textUtils_print( " " );
nChars++;
}

/*
entryPtr++;
// Skip date
entryPtr+= 4;
if ( isDir == false ) {
// File size
fileSize = *entryPtr++;
fileSize += ( (uint32_t)( *entryPtr++ ) ) << 8;
fileSize += ( (uint32_t)( *entryPtr++ ) ) << 16;
fileSize += ( (uint32_t)( *entryPtr++ ) ) << 24;
sprintf( strNumber, "10%lu", fileSize );
textUtils_print( strNumber );
}
*/
}

void fileDialogCallBackSelectEntry( uint16_t numEntry, uint8_t *entryPtr, uint8_t *userData ) {
Expand Down Expand Up @@ -408,7 +389,7 @@ void updateVerticalBar( uint16_t xPos, uint16_t pos, uint16_t total, uint8_t att

// Print bar background
textUtils_setAttributes( attrs1 );
for ( i = 3; i < 23; i++ ) {
for ( i = 3; i < OPENDIALOG_MAX_DIR_ENTRIES + 3; i++ ) {
textUtils_printAt( xPos, i );
fputc_cons( '|' );
}
Expand Down
2 changes: 1 addition & 1 deletion lib/fileDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

#include "integerTypes.h"

extern bool openFileDialog( uint8_t *message, uint8_t *path, int16_t maxPathLength, uint8_t attrs1, uint8_t attrs2 );
extern bool openFileDialog( uint8_t *message, uint8_t *bottomMessage, uint8_t *path, int16_t maxPathLength, uint8_t attrs1, uint8_t attrs2 );

extern bool fileDialogConcatPath( uint8_t *string1, uint8_t *string2, uint16_t maxSize, bool appendBar );
extern void fileDialogpathUpOneDir( uint8_t *path );
Expand Down
15 changes: 12 additions & 3 deletions scl2trd.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,18 @@ void selectFile()
textUtils_cls();
textUtils_setAttributes( INK_BLUE | PAPER_BLACK );
fileDialogpathUpOneDir( filePath );

while ( openFileDialog( "Open SCL file", filePath, PATH_SIZE, INK_BLUE | PAPER_WHITE, INK_WHITE | PAPER_BLACK ) == false ) {
showMessage("Didn't select a file.");
while (
openFileDialog(
"SCL2TRD by Nihirash v. 0.3.0 ",
" <Cursor> - movement <Enter> - select file <Space> - exit ",
filePath,
PATH_SIZE,
INK_BLUE | PAPER_WHITE,
INK_WHITE | PAPER_BLACK
) == false ) {
__asm
rst 0
__endasm;
}
textUtils_cls();
textUtils_println("");
Expand Down

0 comments on commit a402650

Please sign in to comment.