Last active
          July 26, 2020 01:41 
        
      - 
      
- 
        Save JettMonstersGoBoom/4eaf83f00ee1a760e2baade0d9c530ee to your computer and use it in GitHub Desktop. 
    6309 RLE decompressor
  
        
  
    
      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
    
  
  
    
  | ; packer from C64 | |
| ; https://csdb.dk/release/?id=34685 | |
| ; ldx #source_address | |
| ; ldy #dest_address | |
| ; jsr unrle6309 | |
| SUBROUTINE unrle6309 | |
| ldb #$00 | |
| ; get byte | |
| lda ,x+ | |
| ; if we're done then exit | |
| beq .derle_end | |
| ; if top bit is set then we're a run of data | |
| bpl .derle_copy | |
| ; else we're a run of a single byte | |
| ; mask top bit | |
| anda #$7f | |
| ; add 2 to include 0 and length + 1 | |
| adda #2 | |
| ; copy a+b (d) into w | |
| tfr d,w | |
| ; copy contents of X to Y and inc Y | |
| tfm x,y+ | |
| ; step to next byte | |
| leax 1,x | |
| bra unrle6309 | |
| .derle_copy: | |
| ; store run of data | |
| tfr d,w | |
| ; copy contents of X to Y and inc X & Y | |
| tfm x+,y+ | |
| bra unrle6309 | |
| .derle_end: | |
| rts | |
| ENDSUB | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment