A86: 16x16 Vid Mem Shift (rotate)
[Prev][Next][Index][Thread]
A86: 16x16 Vid Mem Shift (rotate)
I'm trying to move a 16x16 section of vid mem 1 pixel to the side. I've
just started by trying to make it move the the right. This is supposed to
input DE as the top-left byte of the sprite, and then shift it all 1 pixel
over. It also has to work with grayscale ($FC00 and $CA00 layers). Any
ideas why it won't work?
Thx,
Dave
sr16:
ld hl,$FC00 ; Layer 1 vid mem
add hl,de ; add top-left-corner byte location
sr16b:
ld de,$000D ; DE = 13
ld b,16 ; BC = 16
push bc ; store BC for loop
sr16l1:
xor a ; reset carry for each row
ld b,3 ; BC = 3
sr16l2:
rrc (hl) ; rotate (HL) right 1 bit
inc hl ; point to next vid mem byte
djnz sr16l2 ; rotate 3 bytes
add hl,de ; add 13 to mem location (next row)
pop bc ; recover BC for loop
djnz sr16l1 ; 16 rows of vid mem to move
ld a,h ; A = H
cp $CD ; compare w/ CD
jp m, endsvr ; if it's positive, done
ld de,$3200 ; DE = $3200
xor a ; reset carry to avoid subtraction problems
sbc hl,de ; HL points to Layer 2 vid mem
jr sr16b ; shift Layer 2 vid mem
endsvr:
ret ; return
Follow-Ups: