From d357e5263e621872ec782181aa6f8a6b9e6b9497 Mon Sep 17 00:00:00 2001 From: antoniovillena <> Date: Tue, 5 Sep 2023 22:46:52 +0200 Subject: [PATCH] adding BIT plugin --- SD/BIN/BPLUGINS/BIT | Bin 0 -> 146 bytes utils/bit.asm | 102 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 102 insertions(+) create mode 100644 SD/BIN/BPLUGINS/BIT create mode 100644 utils/bit.asm diff --git a/SD/BIN/BPLUGINS/BIT b/SD/BIN/BPLUGINS/BIT new file mode 100644 index 0000000000000000000000000000000000000000..45cab4b1601982b158301d4c629c2f1fb46255d1 GIT binary patch literal 146 zcmb18atdGo0w>Q9g@T;Y^vpa3T?NN51vLfV%;chcuf*hRhR;vepYK$h)NpMC3)WB4G#3jkRoGg|-v literal 0 HcmV?d00001 diff --git a/utils/bit.asm b/utils/bit.asm new file mode 100644 index 0000000..9d9042e --- /dev/null +++ b/utils/bit.asm @@ -0,0 +1,102 @@ +; multicore load any .BIT core with rp2040 board +; File must exists in current directory +; +; Copyright (C) 2023 Antonio Villena and MicroJack +; +; 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, version 3. +; +; 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 . +; +; Compatible compilers: +; SjAsmPlus, + +; output BIT + + include zxuno.def + include esxdos.def + + org $8000 + jr NoPrint + db 'BP', 0, 0, 0, 0, 'BIT plugin - AV & MicroJack', 0 + ; hl points to filename? +NoPrint di + push hl ; save pointer to filename + xor a ; set a to zero - current drive + rst $08 + db M_GETSETDRV + ld hl,sysex+4 ; point to end of sysex + rst $08 + db F_GETCWD ; get current working directory + ld bc, $064a ; $47 xor $0d - b = 5 (size of sysex + 1) + ld de, sysex+4 ; end of sysex + ld a, (de) ; get char +ChksumLoop inc de + inc b + xor c ; char ^ c -> c + ld c, a + ld a, (de) ; get char + or a ; compare + jr nz, ChksumLoop + pop hl ; retrieve filename + ld a, (hl) ; get first char of filename +Bucle inc hl ; increment pointer to filename + inc b ; increment b = 6 + ld (de), a ; BUG? Should store a to de? store a to filename and file pos + 1 ? + inc de ; first time de is at sysex end + xor c ; calculate checksum => a + ld c, a ; move back to c + ld a, (hl) ; get next byte + or a ; force compare + jr nz, Bucle ; jump if byte is not zero + ld a, c ; move checksum to a + ld (de), a ; store to next byte + inc de ; increment de + ld a, $f7 ; end of sysex message + ld (de), a ; store it + ld hl, sysex ; BUG - should be sysex? point to beginning of sysex - 1 + ld ixl, b ; move length to ixl + ld bc, $fffd ; bc = port of soundchip + ld e, 14 ; register 14 + out (c), e ; select register 14 - i/o port. + ld b, $bf +Sendbyte ld e, $fa ; set rs232 'rxd' transmit line to 0. (keep keypad 'cts' output line low to prevent the keypad resetting) + ld d, 9 ; there are 8 bits to send (+start bit) + ld a, (hl) + jr Startbit +Sendbit dec e ; (4) + jp nz, Sendbit ; (10) + rra ; (4) rotate the next bit to send into the carry. + ld e, $df ; (7) 11011111 + rl e ; (8) 1011111x + rlc e ; (8) 011111x1 + rlc e ; (8) 11111x10 +Startbit out (c), e ; (12) + ld e, 3 ; (7) introduce delays such that the next data bit is output 112 t-states from now. + dec d ; (4) decrement the bit counter. + jr nz, Sendbit ; (12/7) jump back if there are further bits to send. + ld e, 4 ; (7) introduce delays such that the next data bit is output 112 t-states from now. +Delay dec e ; (4) + jr nz, Delay ; (12/7) + dec e ; (4) + dec e ; (4) set rs232 'rxd' transmit line to 1. (keep keypad 'cts' output line low to prevent the keypad resetting) + nop ; (4) delay + nop ; (4) delay + out (c), e ; (12) send out the stop bit. + ld e, 6 ; (7) delay for 101 t-states (28.5us). +Delay2 dec e ; (4) + jr nz, Delay2 ; (12/7) + inc hl + dec ixl + jr nz, Sendbyte + + halt + +sysex db $00, $f0, $14, $0d