Advertisement
NovaYoshi

CHR decompression

Jan 30th, 2015
327
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. .macro ChrFile File, Address
  2.   .word Address
  3.   .local Start
  4.   .local End
  5.   .byt (End-Start)/128+1
  6. Start:
  7.   .incbin File
  8. End:
  9. .endmacro
  10.  
  11. .proc DecompressCHR
  12. ChunksLeft = 3
  13.   ; write pointer to info
  14.   sta 0
  15.   sty 1
  16.  
  17.   ldy #2
  18.   lda (0),y
  19.   sta ChunksLeft
  20.   .repeat 2 ; write both parts of address
  21.     dey
  22.     lda (0),y
  23.     sta PPUADDR
  24.   .endrep
  25.  
  26.   ; move pointer to the actual data
  27.   lda 0
  28.   add #3
  29.   sta ciSrc+0
  30.   lda 1
  31.   adc #0
  32.   sta ciSrc+1
  33.  
  34.   lda #0
  35.   sta ciBufStart
  36.   lda #128
  37.   sta ciBufEnd
  38. ChunksLoop:
  39.   jsr unpb53_some
  40.   ldx #0
  41. : lda PB53_outbuf,x
  42.   sta PPUDATA
  43.   inx
  44.   cpx #128
  45.   bne :-
  46.   dec ChunksLeft
  47.   bne ChunksLoop
  48.   rts
  49. .endproc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement