Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; ======================================================================
- ; Compression subroutine that can be used to deompress colours that use
- ; two palette entries. Used in Flicky for ASCII and TODO.
- ; INPUT
- ; d0 - Palette entry IDs. Each nybble represents a palette entry.
- ; d1 - Size of compressed art, divided by 8.
- ; a0 - Source of compressed art.
- ;
- ; OUTPUT
- ; a4 - Source of decompressed graphics if the write to RAM mode was used.
- ; ======================================================================
- loc_cc0:
- movem.l d0-d6/a0/a4,-(sp) ; Push register values onto the stack.
- moveq #0,d4 ; Clear d4 (Set address increment to 0).
- lea ($C00000).l,a4 ; Load the VDP data port into a4.
- bra.s loc_cd4 ; Jump to the actual handling subroutine.
- ; ----------------------------------------------------------------------
- loc_cce: ; Unused. Used to write to RAM. Note that this means that a RAN
- ; address is expected to be written to a4.
- movem.l d0-d6/a0/a4,-(sp) ; Push register values onto the stack.
- moveq #4,d4 ; Set as address increment (for longwords).
- loc_cd4:
- asl.w #3,d1 ; Multiply by 8 (each pass decompresses a longword, and 8 longwords make a tile).
- subq.w #1,d1 ; Subtract 1 for the dbf loop.
- move.b d0,d2 ; Load the palette entries into d2.
- move.b d2,d3 ; Copy to d3.
- lsr.b #4,d2 ; Get upper nybble of the byte, in this case entry 1.
- andi.b #$F,d3 ; Get lower nybble of the byte, in this case entry 2.
- loc_CE2:
- moveq #7,d6 ; Set bit counter value as 7.
- move.b (a0)+,d0 ; Move the first byte of the compressed art into d0.
- loc_ce6:
- lsl.l #4,d5 ; Clear the first nybble.
- btst d6,d0 ; Is it set to a 0 or 1?
- beq.s loc_cf0 ; If it is set to a 0, branch.
- or.b d2,d5 ; Set the pixel as using palette entry 1.
- bra.s loc_cf2 ; Branch to check the rest of the bits.
- loc_cf0:
- or.b d3,d5 ; Set the pixel as using palette entry 2.
- loc_cf2:
- dbf d6,loc_ce6 ; Repeat for the rest of the bits.
- move.l d5,(a4) ; Move 8 pixels into VRAM.
- adda.l d4,a4 ; Add address increment. Useful only for RAM.
- dbf d1,loc_ce2 ; Repeat for the rest of the compressed art source.
- movem.l (sp)+,d0-d6/a0/a4 ; Restore register values.
- rts ; Return.
Advertisement
Add Comment
Please, Sign In to add comment