Skip to content

Instantly share code, notes, and snippets.

@mateoconlechuga
Forked from jacobly0/shift.asm
Created September 1, 2016 00:25
Show Gist options
  • Save mateoconlechuga/3219472a1b715451bf6edec2b3ab6dbb to your computer and use it in GitHub Desktop.
Save mateoconlechuga/3219472a1b715451bf6edec2b3ab6dbb to your computer and use it in GitHub Desktop.
ShiftDown
;-------------------------------------------------------------------------------
_ShiftDown:
; Shifts whatever is in the clip down by some pixels
; Arguments:
; arg0 : Amount to shift by
; Returns:
; None
ld hl,3
add hl,sp
ld c,(hl)
ld hl,(_xmax) \.r
push hl
ld de,(_xmin) \.r
sbc hl,de
ld (DownCpyAmt_SMC),hl \.r
ex de,hl
ld hl,lcdWidth
sbc hl,de
ld (DownLineOff_SMC),hl \.r
ld a,(_ymin) \.r
add a,c
ld e,a
ld b,lcdWidth/2
mlt bc
sbc hl,hl
sbc hl,bc
add hl,hl
ld (DownAmtOff_SMC),hl \.r
ld a,(_ymax) \.r
ld l,a
dec l
ld h,lcdWidth/2
mlt hl
add hl,hl
pop bc
dec bc
add hl,bc
ld bc,(currDrawBuff)
add hl,bc
sub a,e
DownCpyAmt_SMC =$+1
_: ld bc,0
ex de,hl
DownAmtOff_SMC =$+1
ld hl,0
add hl,de
lddr
DownLineOff_SMC =$+1
ld hl,0
add hl,de
dec a
jr nz,-_
ret
;-------------------------------------------------------------------------------
_ShiftUp:
; Shifts whatever is in the clip up by some pixels
; Arguments:
; arg0 : Amount to shift by
; Returns:
; None
ld hl,3
add hl,sp
ld l,(hl)
ld a,(_ymax) \.r
sub a,l
ld c,a
ld h,lcdWidth/2
mlt hl
add hl,hl
ld (UpAmtOff_SMC),hl \.r
ld hl,(_xmax) \.r
ld de,(_xmin) \.r
sbc hl,de
ld (UpCpyAmt_SMC),hl \.r
ex de,hl
push hl
ld hl,lcdWidth
sbc hl,de
ld (UpLineOff_SMC),hl \.r
ld a,(_ymin) \.r
ld l,a
ld h,lcdWidth/2
mlt hl
add hl,hl
neg
add a,c
pop bc
add hl,bc
ld bc,(currDrawBuffer)
add hl,bc
UpCpyAmt_SMC =$+1
_: ld bc,0
ex de,hl
UpAmtOff_SMC =$+1
ld hl,0
add hl,de
ldir
UpLineOff_SMC =$+1
ld hl,0
add hl,de
dec a
jr nz,-_
ret
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment