Skip to content

Commit

Permalink
Finish surl_stream_av asm, allow 'C' to mention people in Mastodon
Browse files Browse the repository at this point in the history
  • Loading branch information
colinleroy committed Oct 14, 2024
1 parent d2d0147 commit 0e3d9b9
Show file tree
Hide file tree
Showing 38 changed files with 534 additions and 310 deletions.
Binary file modified doc/mastodon-user-guide.odt
Binary file not shown.
3 changes: 2 additions & 1 deletion src/image-viewer/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ imgview_SOURCES := \
imageview.c \
../lib/file_select.c \
../lib/progress_bar.c \
../lib/hgr.c \
../lib/hgr_addrs.c \
../lib/realloc_safe.c \

Expand All @@ -38,6 +37,7 @@ imgview_CC65SOURCES := \
../lib/asm/path_helper.s \
../lib/asm/clrzone.s \
../lib/asm/malloc0.s \
../lib/asm/hgr.s \
../lib/dputc.s \
../lib/scroll.s \
../lib/FVTABZ.s \
Expand All @@ -53,6 +53,7 @@ imgview_GCCSOURCES := \
../lib/c/path_helper.c \
../lib/c/clrzone.c \
../lib/c/malloc0.c \
../lib/c/hgr.c \
../lib/tgi_sdl.c \
../lib/tgi_fastline.c \
../lib/strtrim.c
Expand Down
85 changes: 85 additions & 0 deletions src/lib/asm/hgr.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
;
; Copyright (C) 2022-2024 Colin Leroy-Mira <[email protected]>
;
; This program is free software; you can redistribute it and/or modify
; it under the terms of the GNU General Public License as published by
; the Free Software Foundation; either version 3 of the License, or
; (at your option) any later version.
;
; This program is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; GNU General Public License for more details.
;
; You should have received a copy of the GNU General Public License
; along with this program. If not, see <http://www.gnu.org/licenses/>.
;
.export _init_hgr
.export _init_text
.export _hgr_mixon
.export _hgr_mixoff
.export _hgr_init_done
.export _hgr_mix_is_on

.data

_hgr_init_done: .byte 0
_hgr_mix_is_on: .byte 0

.segment "LOWCODE"

_init_hgr:
.ifdef IIGS
cmp #$00
bne @color_set

lda #$80
sta $C021 ; MONOCOLOR
lda $C029 ; NEWVIDEO
ora #$20 ; set bit 5
sta $C029
bne @color_set

lda #$00
sta $C021 ; MONOCOLOR
lda $C029 ; NEWVIDEO
and #$DF ; clear bit 5
sta $C029
.endif
@color_set:

lda #$20
sta $E6 ; HGRPAGE

; Set HGR mode
bit $C000 ; 80STORE
bit $C050 ; TXTCLR
bit $C052 ; MIXCLR
bit $C057 ; HIRES
bit $C054 ; LOWSCR

ldx #1
stx _hgr_init_done
dex
stx _hgr_mix_is_on
rts

_init_text:
bit $C054 ; LOWSCR
bit $C051 ; TXTSET
bit $C056 ; LORES
lda #0
sta _hgr_init_done
rts

_hgr_mixon:
bit $C053
lda #1
sta _hgr_mix_is_on
rts

_hgr_mixoff:
bit $C052
lda #0
sta _hgr_mix_is_on
rts
16 changes: 16 additions & 0 deletions src/lib/c/hgr.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#include "hgr.h"

char hgr_init_done = 0;
char hgr_mix_is_on = 0;

#ifndef __CC65__
#include "tgi_compat.h"

void init_hgr(uint8 mono) {
tgi_init();
}
void init_text(void) {
tgi_done();
}

#endif
74 changes: 0 additions & 74 deletions src/lib/hgr.c

This file was deleted.

27 changes: 9 additions & 18 deletions src/lib/hgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,21 @@
#define HGR_WIDTH 280U
#define HGR_HEIGHT 192U

void __fastcall__ init_hgr(uint8 mono);
void __fastcall__ init_text(void);
extern char hgr_mix_is_on;
extern char hgr_init_done;

#ifdef __CC65__
#define HGR_PAGE 0x2000
#define HGR_PAGE2 0x4000
#else
extern char HGR_PAGE[HGR_LEN];
#endif

extern char hgr_init_done;
extern char hgr_mix_is_on;
void init_hgr(uint8 mono);
void init_text(void);

#ifdef __CC65__
#define hgr_mixon() do { __asm__("bit $C053"); hgr_mix_is_on = 1; } while (0)
#define hgr_mixoff() do { __asm__("bit $C052"); hgr_mix_is_on = 0; } while (0)
#define switch_text() do { \
__asm__("bit $C054"); /* LOWSCR */ \
__asm__("bit $C051"); /* TXTSET */ \
__asm__("bit $C056"); /* LORES */ \
} while (0)
#define hgr_mix_is_on() hgr_mix_is_on
void __fastcall__ hgr_mixon(void);
void __fastcall__ hgr_mixoff(void);
#else
extern char HGR_PAGE[HGR_LEN];
#define hgr_mixon()
#define hgr_mixoff()
#define hgr_mix_is_on() 0
#endif

#endif
3 changes: 2 additions & 1 deletion src/lib/surl.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ int __fastcall__ surl_get_json(char *buffer, const char *selector, const char *t
int surl_wait_for_stream(void);
int __fastcall__ surl_stream_video(void);
int __fastcall__ surl_stream_audio(char numcols, char title_y, char vu_x, char vu_y);
int __fastcall__ surl_stream_av(void);
int __fastcall__ surl_stream_av(char *subtitles_url, char *url);

void __fastcall__ simple_serial_dump(char id, char *ptr, int nmemb);
#else
#define surl_stream_video()
Expand Down
18 changes: 17 additions & 1 deletion src/lib/surl/surl_stream_av/6502.s
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@ next = _zp10 ; word - next cycle
JUMP_NEXT_DUTY ; 9 jump to next duty cycle
.endmacro
.bss
got_art: .res 1
.segment "CODE"
; Align each duty cycle function
Expand All @@ -139,18 +142,31 @@ SAMPLE_MULT = 1
.align $100
.assert * = _SAMPLES_BASE + $100, error
.include "duty-cycles/1.s"
; Add some setup function to fill in the gaps
.include "update_load_progress.s"
.include "surl_stream_av_send_request.s"
.include "surl_stream_av_setup_ui.s"
.include "surl_stream_av_get_art.s"
.align $100
.assert * = _SAMPLES_BASE + $200, error
.include "duty-cycles/2.s"
; Add some setup function to fill in the gaps
.include "surl_stream_av_prepare_start.s"
.include "surl_stream_av_handle_preload.s"
.include "surl_stream_av.s"
.align $100
.assert * = _SAMPLES_BASE + $300, error
.include "duty-cycles/3.s"
; Add some strings to fill in the gaps
.include "strings-a.inc"
.align $100
.assert * = _SAMPLES_BASE + $400, error
.include "duty-cycles/4.s"
; Add some strings to fill in the gaps
.include "strings-b.inc"
.align $100
.assert * = _SAMPLES_BASE + $500, error
Expand Down Expand Up @@ -258,7 +274,7 @@ SAMPLE_MULT = 1
.include "duty-cycles/26.s"
; Stuff code between duty cycles to optimize size
.include "surl_stream_av.s"
.include "surl_start_stream_av.s"
.include "calc_bases.s"
.include "calc_text_bases.s"
.include "../surl_stream_common/patch_addresses.s"
Expand Down
17 changes: 15 additions & 2 deletions src/lib/surl/surl_stream_av/65c02.s
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@
.include "constants.inc"
.include "zp-variables.inc"
.include "cycle-wasters.inc"
; -----------------------------------------------------------------------------
; CPU-specific constant and macros
Expand Down Expand Up @@ -112,6 +111,10 @@ SAMPLE_MULT = 2
JUMP_NEXT_DUTY ; 9 jump to next duty cycle
.endmacro
.bss
got_art: .res 1
.segment "CODE"
; The AVCODE segment location is non-important (apart of course it must not be
Expand Down Expand Up @@ -190,7 +193,7 @@ _SAMPLES_BASE = *
; The rest of the functions don't need to be aligned.
.include "surl_stream_av.s"
.include "surl_start_stream_av.s"
.include "../surl_stream_common/patch_addresses.s"
.include "../surl_stream_common/patch_audio_registers.s"
.include "patch_video_registers.s"
Expand All @@ -199,7 +202,17 @@ _SAMPLES_BASE = *
.include "video-data-data.inc"
.include "audio-data.inc"
; Setup functions
.include "setup.s"
.include "strings-a.inc"
.include "strings-b.inc"
.include "update_load_progress.s"
.include "surl_stream_av_send_request.s"
.include "surl_stream_av_setup_ui.s"
.include "surl_stream_av_get_art.s"
.include "surl_stream_av_prepare_start.s"
.include "surl_stream_av_handle_preload.s"
.include "surl_stream_av.s"
; -----------------------------------------------------------------------------
; CPU-specific data (duty cycles handlers table)
Expand Down
3 changes: 3 additions & 0 deletions src/lib/surl/surl_stream_av/constants.inc
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,6 @@ PAGE1_HB = PAGE0_HB
.endif

SPKR := $C030

VIDEOMODE_40COL = $11
VIDEOMODE_80COL = $12
25 changes: 24 additions & 1 deletion src/lib/surl/surl_stream_av/imports.inc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.export _surl_start_stream_av
.export _surl_stream_av
.export _SAMPLES_BASE

Expand All @@ -8,14 +9,36 @@
.import _simple_serial_get_cmd_reg
.import _simple_serial_get_ctrl_reg

.import _enable_subtitles
.import _video_size
.import _translit_charset
.import _scrh
.import _hgr_mixon, _hgr_mixoff
.import _hgr_mix_is_on

.import _serial_putc_direct
.import _simple_serial_getc
.import _simple_serial_puts_nl
.import _serial_read_byte_no_irq
.import _simple_serial_set_irq
.import _simple_serial_flush
.import _sleep, _init_text, _clrscr

.import _surl_start_request
.import _surl_read_with_barrier

.import _ser_params

.import acia_status_reg_r, acia_data_reg_r

.import _init_text, _init_hgr, _set_scrollwindow
.import _gotoxy, _cprintf, _videomode, _clrscr
.import _bzero, _memset, _sleep, _cputs
.import pusha, pusha0, push0, pushax, shlax3, popptr1

.importzp ptr1

.include "apple2.inc"
.include "../../simple_serial.inc"
.include "../../../surl-server/surl_protocol.inc"
.include "../../surl.inc"
.include "stdio.inc"
Loading

0 comments on commit 0e3d9b9

Please sign in to comment.