diff --git a/Makefile.mak b/Makefile.mak index 6202de8..c74b5b7 100644 --- a/Makefile.mak +++ b/Makefile.mak @@ -7,6 +7,8 @@ PRODUCT=YAIL TARGET=atari SRC_DIR=src CFLAGS=-Or +LINKFLAGS= +#LINKFLAGS=--debug-info -Wl --dbgfile,"myapp.dbg" # -D__SYSTEM_CHECK__=1 LIBRARIES=fujinet-lib/fujinet-atari-2.2.1.lib @@ -24,7 +26,7 @@ s_files: $(SRC_DIR)\*.s @$(MAKE) -nologo /f Makefile.mak $(**:.s=.o) link_files: $(SRC_DIR)\*.o - $(CL65) -t $(TARGET) $(CFLAGS) -o $(PRODUCT).XEX --config $(SRC_DIR)\$(PRODUCT).$(TARGET)-xex.cfg --mapfile $(PRODUCT).map -Ln $(PRODUCT).lbl $(**) $(TARGET).lib $(LIBRARIES) + $(CL65) -t $(TARGET) $(CFLAGS) $(LINKFLAGS) -o $(PRODUCT).XEX --config $(SRC_DIR)\$(PRODUCT).$(TARGET)-xex.cfg --mapfile $(PRODUCT).map -Ln $(PRODUCT).lbl $(**) $(TARGET).lib $(LIBRARIES) .s.o: $(CA65) -t $(TARGET) $< diff --git a/YAIL.XEX b/YAIL.XEX index 033a7d2..0fa31d4 100644 Binary files a/YAIL.XEX and b/YAIL.XEX differ diff --git a/server/testclient.py b/server/testclient.py index e399bd8..c31da6d 100755 --- a/server/testclient.py +++ b/server/testclient.py @@ -8,22 +8,23 @@ client = socket.socket(socket.AF_INET, socket.SOCK_STREAM) # connect the client -client.connect(('127.0.0.1', 5556)) +client.connect(('192.168.1.126', 5556)) client.send(b'search funny\n') IMAGE_SIZE = 8807 -while True: - numbytes = 0 - # receive the response data (4096 is recommended buffer size) - while numbytes < IMAGE_SIZE: - response = client.recv(4096) - numbytes += len(response) - if numbytes == 0: - break +numbytes = 0 +# receive the response data (4096 is recommended buffer size) +while numbytes < IMAGE_SIZE: + response = client.recv(4096) + numbytes += len(response) - print('\trecv\'d %d bytes (%d)\n' % (len(response), numbytes)) - print('\trecv\'d %d bytes (%d)\n' % (len(response), numbytes)) + if numbytes == 0: + break + + print('\trecv\'d %d bytes (%d)\n' % (len(response), numbytes)) + +input("Press Enter to continue...") +client.send(b'quit\n') +client.close() - input("Press Enter to continue...") - client.send(b'stop\n') diff --git a/server/yailsrv.py b/server/yailsrv.py index d93784c..2f365b6 100644 --- a/server/yailsrv.py +++ b/server/yailsrv.py @@ -4,10 +4,10 @@ import requests import re -import json +#import json import time import logging -import urllib +#import urllib import os from tqdm import tqdm import socket @@ -18,7 +18,7 @@ from pprint import pprint from PIL import Image import numpy as np -import asyncio +#import asyncio GRAPHICS_8 = 2 GRAPHICS_9 = 4 @@ -65,7 +65,6 @@ def search_images(term, max_images=1000): def hash_string(s): import hashlib import binascii - #hsh = bytearray(hashlib.md5(s.encode(encoding="ascii")).digest()) hsh = bytearray(hashlib.shake_256(s.encode(encoding="ascii")).digest(2)) assert len(hsh) == 2 output = \ @@ -284,12 +283,11 @@ def stream_YAI(url, client, gfx_mode): print('Exception:', e) return False -# new asyncio loop - +# For now this function is not async. It may be in the future. def handle_client_connection(client_socket): # Set up a new event loop for this thread - loop = asyncio.new_event_loop() - asyncio.set_event_loop(loop) + #loop = asyncio.new_event_loop() + #asyncio.set_event_loop(loop) gfx_mode = GRAPHICS_9 try: @@ -339,7 +337,7 @@ def handle_client_connection(client_socket): finally: client_socket.close() - loop.close() # Close the loop when done + #loop.close() # Close the loop when done def main(): while True: diff --git a/src/console.c b/src/console.c index 42a93c8..c8f9f10 100644 --- a/src/console.c +++ b/src/console.c @@ -6,6 +6,7 @@ #include "files.h" #include "consts.h" #include "types.h" +#include "utility.h" #include #include @@ -32,8 +33,8 @@ char CONSOLE_BUFF[GFX_0_MEM_LINE * CONSOLE_LINES]; #else #define CONSOLE_BUFF ((byte*)((ushort*)ORG_SDLIST)[2]) #endif -char* tokens[] = { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 }; // Maximum of 8 tokens -char server[80] = { "N:TCP://192.168.1.205:9999/\"\0" }; +char* tokens[8]; // = { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 }; // Maximum of 8 tokens +char server[80] = { "N:TCP://192.168.1.126:5556/\"\0" }; void reset_console(void) { @@ -70,7 +71,7 @@ byte get_tokens(byte* buff, byte endx) } } - // Fix last token. For some strange reason, the last token is ending with 0x80 + // Fix last token. For some strange reason, the last token is ending with 0x80 (ENTER key?) i = strlen(tokens[count-1]); tokens[count-1][i-1] = 0x0; @@ -86,17 +87,6 @@ byte get_tokens(byte* buff, byte endx) return count; } -void fix_chars(char* buff) -{ - byte i; - for(i=0;i 1) { - fix_chars(tokens[1]); + //internal_to_atascii(tokens[1], 40); load_image_file(tokens[1]); } else @@ -196,9 +186,7 @@ void process_command(byte ntokens) else { if(strncmp(tokens[1], "server", 3) == 0) - { strncpy(server, tokens[2], 79); - } } } @@ -264,10 +252,11 @@ void start_console(char first_char) { // process the tokens #define WORKING_BUFF_SIZE 80 - byte buff[80]; // two lines of data + byte buff[WORKING_BUFF_SIZE]; // two lines of data byte ntokens = 0; memcpy(buff, CONSOLE_BUFF, WORKING_BUFF_SIZE); + internal_to_atascii(buff, WORKING_BUFF_SIZE); #ifdef DEBUG_CONSOLE gotoxy(0,1); @@ -312,8 +301,13 @@ void start_console(char first_char) if(ntokens > 0) { + byte i; reset_console(); process_command(ntokens); + + // Clear the tokens for the next command + for(i = 0; i < 7; ++i) + tokens[i] = 0x0; } reset_console(); diff --git a/src/imgload.c b/src/imgload.c index cb544e7..1d0eb33 100644 --- a/src/imgload.c +++ b/src/imgload.c @@ -18,7 +18,7 @@ extern char server[]; // //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\x16\x00"; +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\x17\x00"; char buff[256]; // A block of memory to be used by all. bool done = false; @@ -39,7 +39,7 @@ void process_command_line(int argc, char* argv[]) help(); break; case 'l': - fix_chars(argv[2]); + internal_to_atascii(argv[2], 40); load_image_file(argv[2]); break; case 'u': diff --git a/src/netimage.c b/src/netimage.c index bedd691..96adf54 100644 --- a/src/netimage.c +++ b/src/netimage.c @@ -42,7 +42,7 @@ void stream_image(char* url, char* args[]) if(FN_ERR_OK != network_init()) { show_console(); - cprintf("Failed to initialize network\n\r"); + cputs("Failed to initialize network\n\r"); network_close(url); return; } @@ -50,18 +50,18 @@ void stream_image(char* url, char* args[]) if(FN_ERR_OK != network_open(url, 12, 0)) { show_console(); - cprintf("Failed to open network\n\r"); + cprintf("Failed to open %s\n\r", url); network_close(url); return; } // Send which graphics mode we are in memset(buff, 0, 256); - sprintf(buff, "gfx %d", CURRENT_MODE &= ~GRAPHICS_CONSOLE_EN); - if(FN_ERR_OK != network_write(url, buff, 5)) + sprintf(buff, "gfx %d ", CURRENT_MODE &= ~GRAPHICS_CONSOLE_EN); + if(FN_ERR_OK != network_write(url, buff, 6)) { show_console(); - cprintf("Unable to write graphics mode\n\r"); + cprintf("Unable to write graphics mode \"%s\"\n\r", buff); network_close(url); return; } @@ -71,7 +71,7 @@ void stream_image(char* url, char* args[]) memcpy(buff, "search \"", 8); for(i = 0; i < 8; ++i) { - if(args[i] == 0x0) + if(0x0 == args[i]) break; if(i > 0) diff --git a/src/utility.c b/src/utility.c index 48046f1..5dde2cd 100644 --- a/src/utility.c +++ b/src/utility.c @@ -19,4 +19,32 @@ void pause(const char* message) break; } } -} \ No newline at end of file +} + +void internal_to_atascii(char* buff, byte len) +{ + byte i; + for(i=0;i typedef struct _MemSeg @@ -32,5 +37,6 @@ 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