Skip to content

Commit

Permalink
Fix body-less posts, replace load indicators
Browse files Browse the repository at this point in the history
  • Loading branch information
colinleroy committed Nov 12, 2024
1 parent c5a7c3b commit d01460e
Show file tree
Hide file tree
Showing 12 changed files with 67 additions and 73 deletions.
40 changes: 36 additions & 4 deletions src/lib/serial/asm/simple_serial_io.s
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
.export _simple_serial_write
.export _simple_serial_flush
.export simple_serial_compute_ptr_end
.export throbber_on, throbber_off, _serial_throbber_set

.ifdef SIMPLE_SERIAL_DUMP
.export _simple_serial_dump
Expand All @@ -39,6 +40,8 @@
.segment "LOWCODE"
.endif

SCRN_THROB = $0427

;void __fastcall__ simple_serial_puts(const char *buf) {
.proc _simple_serial_puts: near
jsr pushax
Expand Down Expand Up @@ -96,21 +99,23 @@
; void __fastcall__ simple_serial_write(const char *ptr, size_t nmemb) {
.proc _simple_serial_write: near
jsr simple_serial_compute_ptr_end
jsr throbber_on
bne write_check ; A not 0 there (throbber)
write_again:
ldy #$00
lda (ptr4),y
jsr _serial_putc_direct

inc ptr4
bne :+
bne write_check
inc ptr4+1
: lda ptr4
write_check:
lda ptr4
cmp ptr3
bne write_again
ldx ptr4+1
cpx ptr3+1
bne write_again
rts
jmp throbber_off
.endproc

.proc _simple_serial_flush: near
Expand All @@ -119,3 +124,30 @@ write_again:
bne _simple_serial_flush
rts
.endproc

_serial_throbber_set:
sta throbber_store+1
sta throbber_on+1
stx throbber_store+2
stx throbber_on+2
rts

.code
; Patched functions
throbber_on:
lda SCRN_THROB
sta SCREEN_CONTENTS
.ifdef __APPLE2ENH__
lda #'C'
.else
lda #('*'|$80)
.endif
bne throbber_store
throbber_off:
lda SCREEN_CONTENTS
throbber_store:
sta SCRN_THROB
rts

.bss
SCREEN_CONTENTS: .byte $00
4 changes: 3 additions & 1 deletion src/lib/serial/asm/simple_serial_read.s
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
.export _simple_serial_read

.import simple_serial_compute_ptr_end
.import throbber_on, throbber_off
.import _ser_get

.importzp ptr3, ptr4
Expand All @@ -33,6 +34,7 @@
;void __fastcall__ simple_serial_read(char *ptr, size_t nmemb) {
.proc _simple_serial_read: near
jsr simple_serial_compute_ptr_end
jsr throbber_on

lda #$00
beq check_bound
Expand All @@ -57,5 +59,5 @@ check_bound:
cpx ptr3+1
bne read_again_axok

rts
jmp throbber_off
.endproc
3 changes: 3 additions & 0 deletions src/lib/simple_serial.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ void __fastcall__ simple_serial_setup_no_irq_regs(void);
unsigned char __fastcall__ serial_read_byte_no_irq(void);
void __fastcall__ serial_putc_direct(unsigned char c);
void __fastcall__ simple_serial_read(char *ptr, size_t nmemb);
void __fastcall__ serial_throbber_set(void *addr);

#define tty_speed_to_str(speed) \
((speed == SER_BAUD_2400) ? "2400": \
Expand All @@ -84,6 +85,8 @@ void simple_serial_flush_fd(int fd);
#define simple_serial_configure()
#define simple_serial_setup_no_irq_regs()
#define simple_serial_set_irq(i)
#define serial_throbber_set(i)

unsigned char __fastcall__ simple_serial_putc(char c);
char *tty_speed_to_str(int speed);
void __fastcall__ simple_serial_read(char *ptr, size_t nmemb);
Expand Down
6 changes: 5 additions & 1 deletion src/lib/surl/asm/surl_read_with_barrier.s
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

.import _serial_putc_direct
.import _simple_serial_set_irq
.import throbber_on, throbber_off

.import popax
.importzp ptr3, ptr4
Expand All @@ -29,6 +30,8 @@
sta ptr4 ; Store buffer
stx ptr4+1

jsr throbber_on

ldy #0 ; Inner loop counter

lda #0
Expand All @@ -46,6 +49,7 @@
bne :- ; next byte

inc ptr4+1

dex
bne :- ; next page

Expand All @@ -64,5 +68,5 @@ done:
jsr _simple_serial_set_irq

plp
rts
jmp throbber_off
.endproc
3 changes: 3 additions & 0 deletions src/lib/surl/c/surl_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ char surl_connect_proxy(void) {
if (proxy_opened) {
return 0;
}
#ifndef __CC65__
simple_serial_read_opts();
#endif
r = simple_serial_open();
//DEBUG("connected proxy: %d\n", r);
proxy_opened = (r == 0);
Expand Down
27 changes: 10 additions & 17 deletions src/lib/vsdrive.s
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
.import _serial_read_byte_no_irq
.import serial_read_byte_no_irq_timeout
.import _serial_putc_direct
.import throbber_on, throbber_off

.export _vsdrive_install, _vsdrive_uninstall
.destructor _vsdrive_uninstall, 9

Expand Down Expand Up @@ -30,8 +32,6 @@ WPERR = $2B
DATE = $BF90 ; Date storage
TIME = $BF92 ; Time storage

SCRN_THROB = $0427

.segment "RT_ONCE"

_vsdrive_install:
Expand Down Expand Up @@ -182,8 +182,7 @@ CALC_CHECKSUM:
rts

READFAIL:
lda SCREEN_CONTENTS ; Restore screen contents
sta SCRN_THROB
jsr throbber_off
lda #IOERR
sec
rts
Expand All @@ -195,9 +194,7 @@ READBLK:
sta CURCMD
; SEND COMMAND TO PC
jsr COMMAND_ENVELOPE
; Grab the screen contents, remember it
lda SCRN_THROB
sta SCREEN_CONTENTS
jsr throbber_on
; Pull and verify command envelope from host
jsr serial_read_byte_no_irq_timeout ; Command envelope begin
bcs READFAIL
Expand Down Expand Up @@ -242,7 +239,6 @@ READBLK:
; READ BLOCK AND VERIFY
ldx #$00
ldy #$00
stx SCRN_THROB
RDLOOP:
jsr _serial_read_byte_no_irq
sta (BUFLO),Y
Expand All @@ -251,16 +247,13 @@ RDLOOP:

inc BUFHI
inx
stx SCRN_THROB
cpx #$02
bne RDLOOP

dec BUFHI
dec BUFHI ; Bring BUFHI back down to where it belongs

lda SCREEN_CONTENTS ; Restore screen contents
sta SCRN_THROB

jsr throbber_off
jsr _serial_read_byte_no_irq ; Checksum
pha ; Push checksum for now
ldx #$00
Expand All @@ -274,8 +267,7 @@ RDLOOP:
rts

WRITEFAIL:
lda SCREEN_CONTENTS ; Restore screen contents
sta SCRN_THROB
jsr throbber_off
lda #IOERR
sec
rts
Expand All @@ -289,15 +281,15 @@ WRITEBLK:
sta CURCMD
jsr COMMAND_ENVELOPE

jsr throbber_on

; WRITE BLOCK AND CHECKSUM
ldx #$00
stx CHECKSUM
WRBKLOOP:
ldy #$00
WRLOOP:
lda (BUFLO),Y
; Write screen throbber
sta SCRN_THROB
jsr _serial_putc_direct
iny
bne WRLOOP
Expand Down Expand Up @@ -331,6 +323,8 @@ WRLOOP:
jsr _serial_read_byte_no_irq ; Checksum of block - not the command envelope
cmp CHECKSUM
bne WRITEFAIL

jsr throbber_off
lda #$00
clc
rts
Expand Down Expand Up @@ -364,7 +358,6 @@ VS_SLOT_DEV1: .byte $00
VS_SLOT_DEV2: .byte $00
UNIT2: .byte $00
CHECKSUM: .byte $00
SCREEN_CONTENTS: .byte $00
TEMPDT: .byte $00,$00,$00,$00
CURCMD: .byte $00
original_driver: .byte $00,$00
Expand Down
2 changes: 1 addition & 1 deletion src/mastodon/api/api.c
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ char api_interact(char *id, char type, char *action) {
get_surl_for_endpoint(SURL_METHOD_POST, endpoint_buf);

surl_send_data_params((uint32)0, SURL_DATA_X_WWW_FORM_URLENCODED_RAW);
/* No need to send data */
surl_send_data_chunk(NULL, 0);
surl_read_response_header();

if (surl_response_ok())
Expand Down
17 changes: 1 addition & 16 deletions src/mastodon/cli/tl.c
Original file line number Diff line number Diff line change
Expand Up @@ -393,12 +393,6 @@ static int show_search(void) {
return 0;
}

static void __fastcall__ load_indicator(char on) {
#if NUMCOLS == 80
gotoxy(LEFT_COL_WIDTH - 4, scrh - 1);
dputs(on ? "...":" ");
#endif
}
/* root is either an account or status id, depending on kind.
* leaf_root is a reblogged status id
*/
Expand All @@ -407,8 +401,6 @@ static list *build_list(char *root, char *leaf_root, char kind) {
char i, found_root;
char n_posts;

load_indicator(1);

l = malloc0(sizeof(list));

if (kind == SHOW_PROFILE) {
Expand Down Expand Up @@ -445,8 +437,6 @@ static list *build_list(char *root, char *leaf_root, char kind) {
}
l->n_posts = n_posts;

load_indicator(0);

return l;
}

Expand Down Expand Up @@ -938,11 +928,7 @@ static char background_load(list *l) {
char i;
for (i = 0; i < l->n_posts; i++) {
if (l->displayed_posts[i] == NULL) {
load_indicator(1);

l->displayed_posts[i] = item_get(l, i, 0);

load_indicator(0);
return 0; /* background load one by one to check kb */
}
}
Expand Down Expand Up @@ -1017,10 +1003,8 @@ static void show_list(list *l) {

print_header(l, root_status, root_notif);

load_indicator(1);
print_list(l, limit);
limit = 0;
load_indicator(0);

while (!kbhit() && background_load(l) == 0) {
/* keep loading */
Expand Down Expand Up @@ -1377,6 +1361,7 @@ int main(int argc, char **argv) {
register_start_device();

#ifdef __APPLE2ENH__
serial_throbber_set((void *)0x07D8);
videomode(VIDEOMODE_80COL);
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/surl-server/surl_protocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

/* Update in .inc too! */
#define SURL_PROTOCOL_VERSION 22
#define VERSION "22.0.0"
#define VERSION "22.0.1"

#define SURL_CLIENT_READY 0x2F
#define HGR_LEN 8192U
Expand Down
1 change: 1 addition & 0 deletions src/wozamp/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -722,6 +722,7 @@ void main(void) {
#ifdef __APPLE2ENH__
videomode(VIDEOMODE_80COL);
#endif
serial_throbber_set((void *)0x07F7);

clrscr();
init_hgr(1);
Expand Down
11 changes: 0 additions & 11 deletions src/wozamp/radio-browser.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,15 +129,6 @@ void show_radio_metadata (char *data) {
cputs(value);
}

static void load_indicator(char on) {
#ifdef __APPLE2ENH__
gotoxy(77, 0);
#else
gotoxy(37, 0);
#endif
cputs(on ? "...":" ");
}

static char do_server_screen = 0;
static char cmd_cb(char c) {
char prev_cursor = cursor(0);
Expand Down Expand Up @@ -300,7 +291,6 @@ static void show_results(void) {
bzero((char *)HGR_PAGE, HGR_LEN);

if (lines[cur_line+IDX_FAVICON][0] != '\0') {
load_indicator(1);
surl_start_request(NULL, 0, lines[cur_line+IDX_FAVICON], SURL_METHOD_GET);
if (surl_response_ok()) {
simple_serial_putc(SURL_CMD_HGR);
Expand All @@ -317,7 +307,6 @@ static void show_results(void) {
}
}
}
load_indicator(0);
} else {
backup_restore_logo("r");
}
Expand Down
Loading

0 comments on commit d01460e

Please sign in to comment.