diff --git a/YAIL.XEX b/YAIL.XEX index 6b5b8cd..5209bed 100644 Binary files a/YAIL.XEX and b/YAIL.XEX differ diff --git a/src/console.c b/src/console.c index 2ab244a..8b2cb38 100644 --- a/src/console.c +++ b/src/console.c @@ -28,6 +28,7 @@ extern void* ORG_SDLIST; extern void graphics_8_console_dl[]; extern void graphics_9_console_dl[]; extern Settings settings; +extern byte CURRENT_MODE; // Globals bool console_state = false; @@ -101,11 +102,20 @@ void process_command(byte ntokens) "quit - Exit this utility\n\r" "cls - Clear the image display\n\r" "gfx - [0,8,9] Set the graphics mode\n\r" + "set - Saved settings\n\r" + " server [url] (N:TCP://blah.duh/)\n\r" + #ifdef YAIL_BUILD_FILE_LOADER "load - [filename] Load and display file\n\r" "save - [filename] Save memory to YAI\n\r"; + #else + "stream - [arg0...argN] Stream images\n\r"; + #endif + byte SAVED_MODE = CURRENT_MODE; + setGraphicsMode(GRAPHICS_0); cputs(help); // Show the help text cgetc(); // Wait + setGraphicsMode(SAVED_MODE); // Restore the graphics mode } if(strncmp(tokens[0], "quit", 4) == 0) @@ -151,6 +161,7 @@ void process_command(byte ntokens) if(strncmp(tokens[0], "load", 4) == 0) { + #ifdef YAIL_BUILD_FILE_LOADER if(ntokens > 1) { //internal_to_atascii(tokens[1], 40); @@ -163,10 +174,17 @@ void process_command(byte ntokens) cputs("ERROR: File not specified"); cgetc(); } + #else + gotoxy(0,0); + clrscr(); + cputs("ERROR: File loading not supported"); + cgetc(); + #endif } if(strncmp(tokens[0], "save", 4) == 0) { + #ifdef YAIL_BUILD_FILE_LOADER if(ntokens > 1) saveFile(tokens[1]); @@ -176,6 +194,12 @@ void process_command(byte ntokens) cprintf("ERROR: File not specified"); cgetc(); } + #else + gotoxy(0,0); + clrscr(); + cputs("ERROR: File saving not supported"); + cgetc(); + #endif } if(strncmp(tokens[0], "set", 3) == 0) @@ -263,7 +287,7 @@ void start_console(char first_char) byte ntokens = 0; memcpy(buff, CONSOLE_BUFF, WORKING_BUFF_SIZE); - internal_to_atascii(buff, WORKING_BUFF_SIZE); + internal_to_atascii((char*)buff, WORKING_BUFF_SIZE); #ifdef DEBUG_CONSOLE gotoxy(0,1); diff --git a/src/files.c b/src/files.c index d905a42..9e630fa 100644 --- a/src/files.c +++ b/src/files.c @@ -1,3 +1,4 @@ +#ifdef YAIL_BUILD_FILE_LOADER // Copyright (C) 2021 Brad Colbert #include "files.h" #include "console.h" @@ -233,3 +234,4 @@ byte load_image_file(const char filename[]) return 0; } +#endif \ No newline at end of file diff --git a/src/files.h b/src/files.h index 18a0297..01fac21 100644 --- a/src/files.h +++ b/src/files.h @@ -3,6 +3,8 @@ #ifndef FILES_H #define FILES_H +#ifdef YAIL_BUILD_FILE_LOADER + #include "types.h" #define FILETYPE_PBM 0x01 @@ -49,4 +51,6 @@ byte imageFileType(const char filename[]); byte load_image_file(const char filename[]); void saveFile(const char filename[]); +#endif // FILES_H + #endif // FILES_H \ No newline at end of file diff --git a/src/imgload.c b/src/imgload.c index 129b9c9..54f2d81 100644 --- a/src/imgload.c +++ b/src/imgload.c @@ -5,6 +5,8 @@ #include "netimage.h" #include "app_key.h" #include "settings.h" +#include "version.h" +#include "utility.h" #include #include @@ -15,8 +17,8 @@ #include // -//char version[] = "YAIL (Yet Another Image Loader) v1.2.2"; -const byte version[] = "\x00\x39\x21\x29\x2C\x00\x08\x39\x65\x74\x00\x21\x6E\x6F\x74\x68\x65\x72\x00\x29\x6D\x61\x67\x65\x00\x2C\x6F\x61\x64\x65\x72\x09\x00\x76\x11\x0E\x12\x0E\x18\x00"; +char version[] = "YAIL (Yet Another Image Loader) v" TOSTR(MAJOR_VERSION) "." TOSTR(MINOR_VERSION) "." TOSTR(BUILD_VERSION); + char buff[256]; // A block of memory to be used by all. bool done = false; Settings settings; @@ -24,23 +26,27 @@ Settings settings; void help() { cputs("Usage: yail [OPTIONS]\r\n"); - cputs(" -h this message\r\n"); - cputs(" -l load image file\r\n"); - cputs(" -u use this server address\r\n"); - cputs(" -s search terms\r\n"); + " -h this message\r\n" + #ifdef YAIL_BUILD_FILE_LOADER + " -l load image file\r\n" + #endif + " -u use this server address\r\n" + " -s search terms\r\n"; } -void process_command_line(int argc, char* argv[]) +void process_command_line(char* argv[]) { switch(argv[1][1]) { case 'h': help(); break; + #ifdef YAIL_BUILD_FILE_LOADER case 'l': internal_to_atascii(argv[2], 40); load_image_file(argv[2]); break; + #endif case 'u': strcpy(settings.url, argv[2]); break; @@ -53,13 +59,16 @@ void process_command_line(int argc, char* argv[]) // int main(int argc, char* argv[]) { + // Convert the version string to internal code format + atascii_to_internal(version, 40); + // Initialize the settings get_settings(); // if(argc > 1) { - process_command_line(argc, argv); + process_command_line(argv); return 0; } else diff --git a/src/netimage.c b/src/netimage.c index 107849f..b6f0e0a 100644 --- a/src/netimage.c +++ b/src/netimage.c @@ -19,9 +19,6 @@ extern ImageData image; extern byte CURRENT_MODE; extern Settings settings; -// globals -//char server[80] = { "\0" }; - void stream_image(char* args[]) { const ushort bytes_per_line = 40; diff --git a/src/readNetPBM.c b/src/readNetPBM.c index 3c7b261..b746b25 100644 --- a/src/readNetPBM.c +++ b/src/readNetPBM.c @@ -1,5 +1,5 @@ // Copyright (C) 2021 Brad Colbert - +#ifdef YAIL_BUILD_FILE_LOADER #define USE_ORIGINAL #ifndef USE_ORIGINAL #else @@ -129,7 +129,7 @@ void readPBM(int fd) readHeader(fd); - buffer_start = framebuffer; + buffer_start = (ushort)framebuffer; block_size = DISPLAYLIST_BLOCK_SIZE; lines_per_block = (ushort)(block_size/bytes_per_line); dl_block_size = lines_per_block * bytes_per_line; @@ -141,7 +141,7 @@ void readPBM(int fd) if(read_size > ttl_buff_size) read_size = ttl_buff_size; - if(read(fd, buffer_start, read_size) < 0) + if(read((void*)fd, buffer_start, read_size) < 0) { show_console(); cprintf("Error reading\n\r"); @@ -267,4 +267,6 @@ void readPGM(int fd) #endif } +#endif // YAIL_BUILD_FILE_LOADER + #endif \ No newline at end of file diff --git a/src/utility.h b/src/utility.h index 62da900..c88a87a 100644 --- a/src/utility.h +++ b/src/utility.h @@ -5,38 +5,11 @@ #include "types.h" +#define TOSTR_(x) #x +#define TOSTR(x) TOSTR_(x) + void pause(const char* message); void internal_to_atascii(char* buff, byte len); void atascii_to_internal(char* buff, byte len); -#if 0 -#include - -typedef struct _MemSeg -{ - void* addr; - size_t size; - size_t block_size; // the size of the blocks in the segment -} MemSeg; - -typedef MemSeg** MemSegParray; - -#define MAX_NUM_SEGS 8 -typedef struct _MemSegs -{ - byte num; - void* start; - void* end; - size_t size; - MemSeg segs[MAX_NUM_SEGS]; -} MemSegs; - -void pause(const char* message); -void* nextBoundary(void* start, unsigned bound); -void* malloc_constrianed(size_t size, size_t fence); -size_t allocSegmentedMemory(size_t block_size, size_t num_blocks, size_t boundary, MemSegs* memsegs); -void freeSegmentedMemory(MemSegs* memsegs); -void printMemSegs(const MemSegs* memsegs); -#endif - #endif \ No newline at end of file diff --git a/src/version.h b/src/version.h index f2416b7..0999c53 100644 --- a/src/version.h +++ b/src/version.h @@ -5,6 +5,6 @@ #define MAJOR_VERSION 1 #define MINOR_VERSION 2 -#define BUILD_VERSION 8 +#define BUILD_VERSION 9 #endif // YAIL_VERSION_H