Skip to content

Instantly share code, notes, and snippets.

@lhz
Last active March 25, 2018 21:55
Show Gist options
  • Save lhz/9d1ac37b421b0adb74062cd6fbca1b57 to your computer and use it in GitHub Desktop.
Save lhz/9d1ac37b421b0adb74062cd6fbca1b57 to your computer and use it in GitHub Desktop.
; a0: Source 8-bit chunky data
; a1: Target bitplane memory
; d0: Bitplane height (or 1 for non-interleaved)
; d1: Bitplane width (or size for non-interleaved) in bytes
ChunkyToPlanar5:
move.l a1, a2
add.l d1, a2
move.l a2, a3
add.l d1, a3
move.l a3, a4
add.l d1, a4
move.l a4, a5
add.l d1, a5
subq.w #1, d0
move.l d1, d2
lsl.w #2, d2
subq.w #1, d1
move.w d1, C2PWidth
move.w d2, C2PStride
.row:
move.w C2PWidth(PC), d1
.byte:
rept 8
move.b (a0)+, d7
roxr.b #1, d7
roxl.b #1, d2
roxr.b #1, d7
roxl.b #1, d3
roxr.b #1, d7
roxl.b #1, d4
roxr.b #1, d7
roxl.b #1, d5
roxr.b #1, d7
roxl.b #1, d6
endr
move.b d2, (a1)+
move.b d3, (a2)+
move.b d4, (a3)+
move.b d5, (a4)+
move.b d6, (a5)+
dbf d1, .byte
move.w C2PStride(PC), d7
add.w d7, a1
add.w d7, a2
add.w d7, a3
add.w d7, a4
add.w d7, a5
dbf d0, .row
rts
C2PWidth:
dc.w 0
C2PStride:
dc.w 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment