Skip to content

Commit

Permalink
Merge pull request #28 from brad-colbert/deprecate_file_loading
Browse files Browse the repository at this point in the history
v1.2.9 Deprecate file loading
  • Loading branch information
brad-colbert authored Mar 1, 2024
2 parents 4f46e46 + 442ae7e commit 5d5f22e
Show file tree
Hide file tree
Showing 9 changed files with 57 additions and 46 deletions.
Binary file modified YAIL.XEX
Binary file not shown.
26 changes: 25 additions & 1 deletion src/console.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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);
Expand All @@ -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]);

Expand All @@ -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)
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions src/files.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#ifdef YAIL_BUILD_FILE_LOADER
// Copyright (C) 2021 Brad Colbert
#include "files.h"
#include "console.h"
Expand Down Expand Up @@ -233,3 +234,4 @@ byte load_image_file(const char filename[])

return 0;
}
#endif
4 changes: 4 additions & 0 deletions src/files.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
#ifndef FILES_H
#define FILES_H

#ifdef YAIL_BUILD_FILE_LOADER

#include "types.h"

#define FILETYPE_PBM 0x01
Expand Down Expand Up @@ -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
25 changes: 17 additions & 8 deletions src/imgload.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
#include "netimage.h"
#include "app_key.h"
#include "settings.h"
#include "version.h"
#include "utility.h"

#include <atari.h>
#include <conio.h>
Expand All @@ -15,32 +17,36 @@
#include <stdbool.h>

//
//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;

void help()
{
cputs("Usage: yail [OPTIONS]\r\n");
cputs(" -h this message\r\n");
cputs(" -l <filename> load image file\r\n");
cputs(" -u <url> use this server address\r\n");
cputs(" -s <tokens> search terms\r\n");
" -h this message\r\n"
#ifdef YAIL_BUILD_FILE_LOADER
" -l <filename> load image file\r\n"
#endif
" -u <url> use this server address\r\n"
" -s <tokens> 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;
Expand All @@ -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
Expand Down
3 changes: 0 additions & 3 deletions src/netimage.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 5 additions & 3 deletions src/readNetPBM.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright (C) 2021 Brad Colbert

#ifdef YAIL_BUILD_FILE_LOADER
#define USE_ORIGINAL
#ifndef USE_ORIGINAL
#else
Expand Down Expand Up @@ -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;
Expand All @@ -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");
Expand Down Expand Up @@ -267,4 +267,6 @@ void readPGM(int fd)

#endif
}
#endif // YAIL_BUILD_FILE_LOADER

#endif
33 changes: 3 additions & 30 deletions src/utility.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <stdlib.h>

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
2 changes: 1 addition & 1 deletion src/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@

#define MAJOR_VERSION 1
#define MINOR_VERSION 2
#define BUILD_VERSION 8
#define BUILD_VERSION 9

#endif // YAIL_VERSION_H

0 comments on commit 5d5f22e

Please sign in to comment.