Jump to content

Photo

4K Short'n'Sweet game contest


403 replies to this topic

#401 Tursi OFFLINE  

Tursi

    Quadrunner

  • 5,664 posts
  • HarmlessLion
  • Location:BUR

Posted Thu Jan 10, 2019 12:56 PM

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).

#402 PeteE OFFLINE  

PeteE

    Chopper Commander

  • 228 posts
  • Location:Beaverton, OR

Posted Thu Jan 10, 2019 2:21 PM

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.



#403 Asmusr OFFLINE  

Asmusr

    River Patroller

  • Topic Starter
  • 3,144 posts
  • Location:Denmark

Posted Thu Jan 10, 2019 2:40 PM

 

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.  :)



#404 PeteE OFFLINE  

PeteE

    Chopper Commander

  • 228 posts
  • Location:Beaverton, OR

Posted Fri Jan 11, 2019 12:13 PM

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





0 user(s) are browsing this forum

0 members, 0 guests, 0 anonymous users