Created
June 28, 2020 17:04
-
-
Save nihirash/40e02ccd32e808dcb57946b05ada2775 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| REAL_ORG = #3c51 | |
| DICT_BEGIN = #3c49 | |
| DATA_REG = 129 | |
| CONTROL_REG = 128 | |
| RTS_LOW = #16 | |
| RTS_HIGH = #56 | |
| MACRO CHECKSUM start | |
| fin = $ | |
| chk = 0 | |
| chk_cnt = 0 | |
| dup fin - start | |
| chk = chk ^ ({b start + chk_cnt}) | |
| chk_cnt = chk_cnt + 1 | |
| edup | |
| db chk | |
| ENDM | |
| MACRO MakeAceTap filename, lastLink | |
| org REAL_ORG - 30 ; Space for header | |
| tapBegin: | |
| dw .headerEnd - .headerblock ; TAP chunk size | |
| .headerblock | |
| db 0 ; type 0 - dict, FF - bytes | |
| .name | |
| name_org = $ | |
| ds 10, 32 ; 10 bytes! | |
| org name_org + 10 | |
| dw dataBlockEnd - dataBlock | |
| dw REAL_ORG | |
| dw lastLink ; Last word link | |
| dw #3c4c | |
| dw #3c4c | |
| dw #3c4f | |
| dw dataBlockEnd | |
| ; Data chunk! | |
| CHECKSUM .headerblock | |
| .headerEnd | |
| dw tapEnd - dataBlock | |
| back_org = $ | |
| org name_org | |
| db filename | |
| org back_org | |
| ENDM | |
| device zxspectrum48 | |
| MakeAceTap "test", uwrite.link | |
| dataBlock: | |
| uinit: | |
| .name | |
| db "UINI", 'T' + #80 ; Name | |
| .size | |
| dw (.end - $) ; Size | |
| dw DICT_BEGIN ; Link | |
| .link | |
| db .size - .name | |
| dw $ + 2 | |
| ld a, 3, c, CONTROL_REG : out (c), a | |
| ld a, RTS_HIGH : out (c), a | |
| jp (iy) | |
| .end | |
| uread: | |
| .name | |
| db "UREA", 'D' + #80 | |
| .size dw (.end - $) | |
| dw uinit.link ; PrevLink | |
| .link | |
| db .size - .name | |
| dw $ + 2 | |
| ld de, #FFFF, a, RTS_LOW : ld c, CONTROL_REG : out (c), a | |
| in a, (c) : and 1 : jr z, .exit | |
| in a, (DATA_REG) | |
| ld d, 0, e, a | |
| .exit | |
| ld c, CONTROL_REG | |
| ld a, RTS_HIGH : out (c), a | |
| rst #10 | |
| jp (iy) | |
| .end | |
| ureadsync: | |
| .name | |
| db "UREAD", 'S' + #80 | |
| .size | |
| dw (.end - $) | |
| dw uread.link | |
| .link | |
| db .size - .name | |
| dw $ + 2 | |
| ld a, RTS_LOW : ld c, CONTROL_REG : out (c), a | |
| .waitByte | |
| in a, (c) : and 1 : jr z, .waitByte | |
| ld a, RTS_HIGH : out (c), a | |
| inc c | |
| in a, (c) | |
| ld e, a, d, 0 | |
| rst #10 | |
| jp (iy) | |
| .end | |
| uwrite: | |
| .name | |
| db "UWRIT", 'E' + #80 | |
| .size | |
| dw (.end - $) | |
| dw ureadsync.link | |
| .link | |
| db .size - .name | |
| dw $ + 2 | |
| rst #18 | |
| .loop | |
| in a, (CONTROL_REG) : and 2 : jr z, .loop | |
| ld c, DATA_REG, a, e : out (c), a | |
| jp (iy) | |
| .end | |
| dataBlockEnd: | |
| CHECKSUM dataBlock | |
| tapEnd = $ | |
| savebin "test.tap", tapBegin, tapEnd - tapBegin |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment