Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; Function to convert 1bpp tiles to 4bpp for VRAM use
- ; --------------------------------------------------------------
- ; INPUTS:
- ; d0.w - Number of tiles to load (-1 for loop)
- ; d1.b - Color index
- ;
- ; a0.l - Pointer to tiles to load
- ; a1.l - Pointer to output buffer
- ;
- ; RETURNS:
- ; (none)
- ;
- ; DESTROYS:
- ; d0.w, d1.l, d2.l, d3.l, d4.l, d5.l
- ; a0.l, a1.l, a2.l
- ; --------------------------------------------------------------
- load_1bpp_tiles:
- movem.l d4-d5,-(sp)
- ; Lookup pixel mask
- ; for chosen color index
- ; ----------------------
- moveq #$0F,d2
- and.b d1,d2
- add.w d2,d2
- add.w d2,d2
- lea .index_masks(pc),a2
- move.l (a2,d2.w),d1
- lea .nybble_words-.index_masks(a2),a2
- move.l #$000F00F0,d2
- ; Convert 1-bit pixels
- ; to 4-bit
- ; ----------------------
- moveq #0,d3
- .loop:
- REPT 8
- move.b (a0)+,d3
- move.l d2,d4
- and.b d3,d4
- lsr.w #3,d4
- move.w (a2,d4.w),d5
- swap d4
- swap d5
- and.b d3,d4
- add.w d4,d4
- move.w (a2,d4.w),d5
- and.l d1,d5
- move.l d5,(a1)+
- ENDR
- dbra d0,.loop
- ; Return
- ; ----------------------
- movem.l (sp)+,d4-d5
- rts
- .index_masks:
- dc.l $00000000
- dc.l $11111111
- dc.l $22222222
- dc.l $33333333
- dc.l $44444444
- dc.l $55555555
- dc.l $66666666
- dc.l $77777777
- dc.l $88888888
- dc.l $99999999
- dc.l $AAAAAAAA
- dc.l $BBBBBBBB
- dc.l $CCCCCCCC
- dc.l $DDDDDDDD
- dc.l $EEEEEEEE
- dc.l $FFFFFFFF
- .nybble_words:
- dc.w $0000 ; %0000
- dc.w $000F ; %0001
- dc.w $00F0 ; %0010
- dc.w $00FF ; %0011
- dc.w $0F00 ; %0100
- dc.w $0F0F ; %0101
- dc.w $0FF0 ; %0110
- dc.w $0FFF ; %0111
- dc.w $F000 ; %1000
- dc.w $F00F ; %1001
- dc.w $F0F0 ; %1010
- dc.w $F0FF ; %1011
- dc.w $FF00 ; %1100
- dc.w $FF0F ; %1101
- dc.w $FFF0 ; %1110
- dc.w $FFFF ; %1111
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement