Jump to content
IGNORED

4K Short'n'Sweet game contest


Asmusr

Recommended Posts

Ah, thanks... I never ended up using it myself, and the libti99 updates are still down my list so I haven't gone back to anything for a long time. :/ I want to replace the unzip code with this one (since it was a lot faster, and unzip was broken last time I updated my compiler).

Link to comment
Share on other sites

The vdp-to-vdp version *is* working after a bit of fiddling, and I'm posting the fixed code below. It's quite slow since it's setting up a read and write address for every byte. And it's not possible to improve the speed by having a buffer between reads and writes, because there is often an overlap between the data it reads and the data it writes within a single run.

 

The DAN2 compression I used suffers from the same speed limitation due to reading and writing one byte at a time, and potentially overlapping range of copied bytes. I wouldn't say it's impossible to use a buffer to improve the speed; there must be some way to handle overlapping. I'll see if I can come up with something.

Link to comment
Share on other sites

 

The DAN2 compression I used suffers from the same speed limitation due to reading and writing one byte at a time, and potentially overlapping range of copied bytes. I wouldn't say it's impossible to use a buffer to improve the speed; there must be some way to handle overlapping. I'll see if I can come up with something.

 

Even with the current limitations it's still a very useful tool that provides far better compression than what I have used before. :)

Link to comment
Share on other sites

Here's a VDP buffered copy function I've tested with the DAN2 decompression function. There are basically two code paths: one where the overlap is smaller or equal to the buffer size, and the the other where it is larger. When overlap is smaller or equal to the buffer size, the buffer can read in the bytes between source and dest, and repeatedly write out the buffer until done. This works well since you only need to set the VDP address register a couple of times. For the other case where the overlap is larger than the buffer size, the buffer can be filled and then written written back, repeating until all the bytes are copied. This assembly code was inlined in my larger decompression function so the register usage and flow may be inconvenient for your usage. I got a time savings of about 30%, when tested in Tilda.

* copy R3 bytes from VDP address R9(source) to VDP address R7(dest)
* R14=VDP address register
* R15=VDP write data register
* BUFFER equ buffer memory address
* BUFSIZ equ buffer size in bytes
* returns R7 += R3

D2_CP1
       ; calculate overlap R4 = dest - source  (assumes source < dest)
       MOV R7,R4
       S   R9,R4   ; R4 = overlap
       CI  R4,BUFSIZ
       JH  D2_CP2
       
       ; R4 (overlap) <= BUFSIZ
       C R3,R4
       JHE !
       MOV R3,R4     ; R4 = min(R3,R4)
!
       ; read R4 bytes from R9 (source)
       MOV R9,R0  ; VDP source address
       LI R1,BUFFER
       MOV R4,R2  ; count of bytes to read
       BL @VDPR

       ; write R4 bytes to R7 (dest)
       MOV R7,R0  ; VDP destination address
       ORI R0,VDPWM
       MOVB @R0LB,*R14
       MOVB R0,*R14
       A R3,R7
!
       LI R1,BUFFER
       MOV R4,R2 ; count of bytes to write
!      MOVB *R1+,*R15
       DEC R2
       JNE -!
       
       S R4,R3
       JEQ DONE    ; done when count=0
       C R3,R4
       JHE -!!
       MOV R3,R4   ; leftover bytes
       JMP -!!

D2_CP2
       LI R4,BUFSIZ
       C R3,R4
       JHE !!
!      MOV R3,R4
!
       ; read R4 bytes from R9 (source)
       MOV R9,R0  ; VDP source address
       LI R1,BUFFER
       MOV R4,R2  ; count of bytes to read
       BL @VDPR
       A R4,R9

       ; write R4 bytes to R7 (dest)
       MOV R7,R0  ; VDP destination address
       A R4,R7
       LI R1,BUFFER
       MOV R4,R2 ; count of bytes to write
       BL @VDPW

       S R4,R3
       JEQ DONE   ; done when count=0
       C R3,R4
       JL -!!
       JMP -!
DONE
  • Like 2
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...