Skip to content

Commit

Permalink
Fixes a few things:
Browse files Browse the repository at this point in the history
1. Added a VBI that sets ATRACT (0x4D) to 0.  Disables the screen saver color rotation.
2. Added some more checks to the get_settings code that, if sio_openkey returns 0, we just set defaults.  This can happen if there is no FN or (I'm assuming) the FN has no SD card.
3. The server did not have a timeout set for the request call.  This could cause the server to hang, waiting for a response from the URL.  Timeout is now 30 but probably could make it shorter.
  • Loading branch information
colbertb committed Mar 18, 2024
1 parent 6f17f4b commit e6b16fd
Show file tree
Hide file tree
Showing 7 changed files with 83 additions and 34 deletions.
Binary file modified YAIL.XEX
Binary file not shown.
2 changes: 1 addition & 1 deletion server/yailsrv.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ def stream_YAI(url, client, gfx_mode):
print('Loading', url, url.encode())
file_size = 0

response = requests.get(url, stream=True)
response = requests.get(url, stream=True, timeout=30)

# get the total file size
file_size = int(response.headers.get("Content-Length", 0))
Expand Down
33 changes: 33 additions & 0 deletions src/disable_atract_vbi.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
;; Simple VBI routine to disable the attract mode

.export _add_attract_disable_vbi
.export disable_atract

.segment "DATA"

.segment "CODE"

;; An interupt routine for the VBI
SETVBV = $E45C
XITVBV = $E462
SYSVBV = $E45F
ATRACT = $4D

; Disable ATRACT mode by setting the "register" to zero
.PROC disable_atract
pha
lda #0
sta ATRACT
pla
jmp SYSVBV
.ENDPROC

_add_attract_disable_vbi:

lda #6 ; Immediate mode
ldy #<disable_atract ; hight byte of address
ldx #>disable_atract ; low byte of address
jsr SETVBV

rts

3 changes: 3 additions & 0 deletions src/imgload.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ int main(int argc, char* argv[])
get_settings();
clearFrameBuffer();

// Stop the attract mode
add_attract_disable_vbi();

// Show console on startup
show_console();
start_console(0x00);
Expand Down
76 changes: 44 additions & 32 deletions src/settings.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,46 +41,56 @@ uint8_t get_settings()
// Get/Create the URL setting
memset(&data, 0, sizeof(AppKeyDataBlock));

sio_openkey(&data, 0, FN_URL_KEY_ID);
r = fn_io_appkey_read(&data.read); // Try to read the key

if (1 == r) // key doesn't exist. write the default.
r = sio_openkey(&data, 0, FN_URL_KEY_ID);
if (0 == r)
{
byte keylen = strlen(DEFAULT_URL);

strncpy(settings.url, DEFAULT_URL, MAX_APPKEY_LEN);
sio_openkey(&data, 1, FN_URL_KEY_ID);
strncpy((char *)data.write.value, settings.url, MAX_APPKEY_LEN);
r = fn_io_appkey_write(keylen, &data.write);

if(1 == r)
return r;
}
else
{
memset(settings.url, 0, SERVER_URL_SIZE);
strncpy(settings.url, (char*)data.read.value, data.read.length);
r = fn_io_appkey_read(&data.read); // Try to read the key

if (1 == r) // key doesn't exist. write the default.
{
byte keylen = strlen(DEFAULT_URL);

strncpy(settings.url, DEFAULT_URL, MAX_APPKEY_LEN);
sio_openkey(&data, 1, FN_URL_KEY_ID);
strncpy((char *)data.write.value, settings.url, MAX_APPKEY_LEN);
r = fn_io_appkey_write(keylen, &data.write);

if(1 == r)
return r;
}
else
{
memset(settings.url, 0, SERVER_URL_SIZE);
strncpy(settings.url, (char*)data.read.value, data.read.length);
}
}
else // use default
strncpy(settings.url, DEFAULT_URL, MAX_APPKEY_LEN);

// Get/Create the gfx mode setting
memset(&data, 0, sizeof(AppKeyDataBlock));

sio_openkey(&data, 0, FN_GFX_KEY_ID);
r = fn_io_appkey_read(&data.read); // Try to read the key

if (1 == r) // key doesn't exist. write the default.
r = sio_openkey(&data, 0, FN_GFX_KEY_ID);
if (0 == r)
{
sio_openkey(&data, 1, FN_GFX_KEY_ID);
data.write.value[0] = DEFAULT_GFX_MODE;
r = fn_io_appkey_write(1, &data.write);
r = fn_io_appkey_read(&data.read); // Try to read the key

if (1 == r) // key doesn't exist. write the default.
{
sio_openkey(&data, 1, FN_GFX_KEY_ID);
data.write.value[0] = DEFAULT_GFX_MODE;
r = fn_io_appkey_write(1, &data.write);

if(1 == r)
return r;
if(1 == r)
return r;

setGraphicsMode(DEFAULT_GFX_MODE);
setGraphicsMode(DEFAULT_GFX_MODE);
}
else
setGraphicsMode(((byte*)data.read.value)[0]);
}
else
setGraphicsMode(((byte*)data.read.value)[0]);
else // use default
setGraphicsMode(DEFAULT_GFX_MODE);

// Add more settings below...

Expand All @@ -100,7 +110,8 @@ uint8_t put_settings(byte select)
{
byte keylen = strlen(settings.url);

sio_openkey(&data, 1, FN_URL_KEY_ID);
if (0 == sio_openkey(&data, 1, FN_URL_KEY_ID))
return 1;
strncpy((char *)data.write.value, settings.url, MAX_APPKEY_LEN);
r = fn_io_appkey_write(keylen, &data.write);

Expand All @@ -110,7 +121,8 @@ uint8_t put_settings(byte select)
break;
case SETTINGS_GFX:
{
sio_openkey(&data, 1, FN_GFX_KEY_ID);
if (0 == sio_openkey(&data, 1, FN_GFX_KEY_ID))
return 1;
data.write.value[0] = settings.gfx_mode & ~GRAPHICS_CONSOLE_EN; // Don't capture the console bit
r = fn_io_appkey_write(1, &data.write);

Expand Down
1 change: 1 addition & 0 deletions src/utility.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ void pause(const char* message);
void internal_to_atascii(char* buff, byte len);
void atascii_to_internal(char* buff, byte len);
void show_error(const char* message);
extern void add_attract_disable_vbi();

#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 15
#define BUILD_VERSION 16

#endif // YAIL_VERSION_H

0 comments on commit e6b16fd

Please sign in to comment.