diff --git a/.gitignore b/.gitignore index 2808db5..df47f73 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,8 @@ .tmp/ *.tap *.sna -*.sld \ No newline at end of file +*.sld +*.tzx +*.block +*.zx0 +*.bin \ No newline at end of file diff --git a/Makefile b/Makefile index ceeae1c..fb3b07d 100644 --- a/Makefile +++ b/Makefile @@ -1,10 +1,32 @@ -myprog.sna myprog.tap myprog.sld: main.asm loader.asm print.asm - sjasmplus --sld=myprog.sld --fullpath main.asm +speccydev.tzx: speccydev.tap + tapeconv speccydev.tap speccydev.tzx + +speccydev.tap: sjasm.tap loader.tap boriel.zx0.block + cat loader.tap sjasm.tap boriel.zx0.block > speccydev.tap + +myprog.sna sjasm.tap myprog.sld: speccydev.asm dzx0_standard.asm boriel.zx0 + sjasmplus --sld=myprog.sld --fullpath speccydev.asm + +loader.tap: loader.bas + zmakebas -a 30 -n SpeccyDev -o loader.tap loader.bas + +boriel.bin: boriel.zxb + zxbc -S 40000 -o boriel.bin boriel.zxb + +boriel.zx0: boriel.bin + zx0 -f boriel.bin boriel.zx0 + +boriel.zx0.block: boriel.zx0 + ttttt boriel.zx0 data clean: rm -f *.tap rm -f *.sna rm -f *.sld + rm -f *.block + rm -f *.tzx + rm -f *.bin + rm -f *.zx0 rm -rf .tmp/ start_new_project: diff --git a/boriel.zxb b/boriel.zxb new file mode 100644 index 0000000..1e500f2 --- /dev/null +++ b/boriel.zxb @@ -0,0 +1,5 @@ +10 CLS +20 FOR i = 0 TO 23 +30 PRINT "ZX Spectrum Rules OK!" +40 NEXT i +50 PAUSE 0 \ No newline at end of file diff --git a/dzx0_standard.asm b/dzx0_standard.asm new file mode 100644 index 0000000..ec8d3dc --- /dev/null +++ b/dzx0_standard.asm @@ -0,0 +1,61 @@ +; ----------------------------------------------------------------------------- +; ZX0 decoder by Einar Saukas & Urusergi +; "Standard" version (68 bytes only) +; ----------------------------------------------------------------------------- +; Parameters: +; HL: source address (compressed data) +; DE: destination address (decompressing) +; ----------------------------------------------------------------------------- + +dzx0_standard: + ld bc, $ffff ; preserve default offset 1 + push bc + inc bc + ld a, $80 +dzx0s_literals: + call dzx0s_elias ; obtain length + ldir ; copy literals + add a, a ; copy from last offset or new offset? + jr c, dzx0s_new_offset + call dzx0s_elias ; obtain length +dzx0s_copy: + ex (sp), hl ; preserve source, restore offset + push hl ; preserve offset + add hl, de ; calculate destination - offset + ldir ; copy from offset + pop hl ; restore offset + ex (sp), hl ; preserve offset, restore source + add a, a ; copy from literals or new offset? + jr nc, dzx0s_literals +dzx0s_new_offset: + pop bc ; discard last offset + ld c, $fe ; prepare negative offset + call dzx0s_elias_loop ; obtain offset MSB + inc c + ret z ; check end marker + ld b, c + ld c, (hl) ; obtain offset LSB + inc hl + rr b ; last offset bit becomes first length bit + rr c + push bc ; preserve new offset + ld bc, 1 ; obtain length + call nc, dzx0s_elias_backtrack + inc bc + jr dzx0s_copy +dzx0s_elias: + inc c ; interlaced Elias gamma coding +dzx0s_elias_loop: + add a, a + jr nz, dzx0s_elias_skip + ld a, (hl) ; load another group of 8 bits + inc hl + rla +dzx0s_elias_skip: + ret c +dzx0s_elias_backtrack: + add a, a + rl c + rl b + jr dzx0s_elias_loop +; ----------------------------------------------------------------------------- diff --git a/loader.bas b/loader.bas new file mode 100644 index 0000000..e12f3c3 --- /dev/null +++ b/loader.bas @@ -0,0 +1,5 @@ +10 REM This file was created +20 REM using zmakebas +30 CLEAR 32767 +40 LOAD ""CODE +50 RANDOMIZE USR 32768 \ No newline at end of file diff --git a/speccydev.asm b/speccydev.asm new file mode 100644 index 0000000..5fde72a --- /dev/null +++ b/speccydev.asm @@ -0,0 +1,36 @@ +code_start_addr EQU #8000 + org code_start_addr + + ; headerless load + scf + ld a, #ff + ld de, boriel_size + ld ix, compressed_boriel + call #0556 + +decompress: + ld hl, compressed_boriel + ld de, uncompressed_boriel + call dzx0.dzx0_standard + + call uncompressed_boriel + ret + + MODULE dzx0 + INCLUDE "dzx0_standard.asm" + ENDMODULE + +code_length EQU $ - code_start_addr + +compressed_boriel: + INCBIN "boriel.zx0" +boriel_size EQU $ - compressed_boriel + +uncompressed_boriel EQU 40000 + + + DEVICE ZXSPECTRUM48 + SLDOPT COMMENT WPMEM, LOGPOINT, ASSERTION + SAVESNA "myprog.sna", decompress + EMPTYTAP "sjasm.tap" + SAVETAP "sjasm.tap", CODE, "sjasm", code_start_addr, code_length \ No newline at end of file