diff --git a/apps/basic/basic.asm b/apps/basic/basic.asm index 807c265..158891c 100644 --- a/apps/basic/basic.asm +++ b/apps/basic/basic.asm @@ -4759,10 +4759,10 @@ CLPRINTHEADER: ; uses a,h,l ; ------------------------------------------------------- CLLOADBLOCKS: - ld a,b +1$: ld a,b or c ret z -1$: push bc + push bc push de call CLREADBLOCK inc hl ; skip block type diff --git a/bios.asm b/bios.asm index dd2ccf7..434c328 100644 --- a/bios.asm +++ b/bios.asm @@ -144,6 +144,8 @@ init: call ctc_uart_init ei + call tape_init + ; Print header message ld hl,msg_header call puts diff --git a/scripts/encode.py b/scripts/encode.py index be1cbe7..43a1363 100644 --- a/scripts/encode.py +++ b/scripts/encode.py @@ -46,7 +46,7 @@ class PulseWriter: self.space(0.1) def space(self, time: float) -> None: - self._level(0, int(time*self.sample_rate)) + self._level(self.low, int(time*self.sample_rate)) def _duration_samples(self, duration_us: float) -> int: sample_count = round(duration_us * self.sample_rate / 1_000_000) diff --git a/tape.asm b/tape.asm index 486c304..e440187 100644 --- a/tape.asm +++ b/tape.asm @@ -11,7 +11,9 @@ SHORT_MAX .equ TAPE_WORKSPACE + 002h ; byte LONG_AVG .equ TAPE_WORKSPACE + 003h ; byte LONG_MIN .equ TAPE_WORKSPACE + 004h ; byte LONG_MAX .equ TAPE_WORKSPACE + 005h ; byte -BLOCK_BUFFER .equ TAPE_WORKSPACE + 006h ; BLOCK_SIZE +SHORT_OUT .equ TAPE_WORKSPACE + 006h ; byte +LONG_OUT .equ TAPE_WORKSPACE + 007h ; byte +BLOCK_BUFFER .equ TAPE_WORKSPACE + 008h ; BLOCK_SIZE ; ------------------------------------------------------- ; Error return callback macro @@ -26,9 +28,17 @@ create_error_return MACRO &name, &code ENDM ; ------------------------------------------------------- +; ------------------------------------------------------- +tape_init: + ld a,18 + ld (SHORT_OUT),a + ld a,37 + ld (LONG_OUT),a + ret +; ------------------------------------------------------- ; Measure edge-to-edge pulse ; needs d (comparator state) -; returns b (loop count) +; returns b (loop count)80 ; carry is timeout ; uses a ; loop is 36T extra 22T (0.6 loops) @@ -567,14 +577,14 @@ get_buffer: ; needs d (output state) ; uses a ; before edge 20T -; after edge 402T +; after edge 408T ; ------------------------------------------------------- gen_short: ld a,d ; 4T xor 1 ; 7T out (TAPE_PORT),a ; 12T ld d,a ; 4T - ld a,18 ; 7T + ld a,(SHORT_OUT) ; 13T 1$: ; loop: 21*a dec a ; 4T cp 0 ; 7T @@ -586,14 +596,14 @@ gen_short: ; needs d (output state) ; uses a ; before edge 20T -; after edge 801T +; after edge 807T ; ------------------------------------------------------- gen_long: ld a,d ; 4T xor 1 ; 7T out (TAPE_PORT),a ; 12T ld d,a ; 4T - ld a,37 ; 7T + ld a,(LONG_OUT) ; 13T 1$: ; loop: 21*a dec a ; 4T cp 0 ; 7T diff --git a/tapes/test.wav b/tapes/test.wav index f050e80..4fc5820 100644 Binary files a/tapes/test.wav and b/tapes/test.wav differ