Skip to content

Instantly share code, notes, and snippets.

@jacobly0
Last active September 1, 2016 22:47
Show Gist options
  • Save jacobly0/a9f0830735433659d69ebedeca8c3567 to your computer and use it in GitHub Desktop.
Save jacobly0/a9f0830735433659d69ebedeca8c3567 to your computer and use it in GitHub Desktop.
Shifts
;-------------------------------------------------------------------------------
_ShiftLeft:
; Shifts whatever is in the clip left by some pixels
; Arguments:
; arg0 : Amount to shift by
; Returns:
; None
.db $F6
;-------------------------------------------------------------------------------
_ShiftUp:
; Shifts whatever is in the clip up by some pixels
; Arguments:
; arg0 : Amount to shift by
; Returns:
; None
scf
ld a,$B0
call _ShiftCalculate_ASM \.r
ld (ShiftAmtOff_SMC),hl \.r
jr z,_
sbc hl,hl
_: ex de,hl
ld hl,(_xmax) \.r
ld bc,(_xmin) \.r
sbc hl,bc
sbc hl,de
ld (ShiftCpyAmt_SMC),hl \.r
ex de,hl
ld hl,lcdWidth
sbc hl,de
ld (ShiftLineOff_SMC),hl \.r
ld hl,_ymax \.r
sub a,(hl)
ld hl,_ymin \.r
ld e,(hl)
add a,e
jr _Shift_ASM
;-------------------------------------------------------------------------------
_ShiftRight:
; Shifts whatever is in the clip right by some pixels
; Arguments:
; arg0 : Amount to shift by
; Returns:
; None
.db $F6
;-------------------------------------------------------------------------------
_ShiftDown:
; Shifts whatever is in the clip down by some pixels
; Arguments:
; arg0 : Amount to shift by
; Returns:
; None
scf
ld a,$B8
call _ShiftCalculate_ASM \.r
ex de,hl
sbc hl,hl
sbc hl,de
ld (ShiftAmtOff_SMC),hl \.r
or a,a
jr z,_
sbc hl,hl
_: ld bc,(_xmax) \.r
add hl,bc
dec bc
ld e,a
ld a,(_ymin) \.r
add a,e
ld de,(_xmin) \.r
sbc hl,de
ld (ShiftCpyAmt_SMC),hl \.r
ld de,-lcdWidth
add hl,de
ld (ShiftLineOff_SMC),hl \.r
ld hl,_ymax \.r
ld e,(hl)
sub a,e
dec e
_Shift_ASM:
ld d,lcdWidth/2
mlt de
ld hl,(currDrawBuffer)
add hl,de
add hl,de
add hl,bc
ShiftCpyAmt_SMC =$+1
_: ld bc,0
ex de,hl
ShiftAmtOff_SMC =$+1
ld hl,0
add hl,de
ShiftCpyDir_SMC =$+1
ldir
ShiftLineOff_SMC =$+1
ld hl,0
add hl,de
inc a
jr nz,-_
ret
_ShiftCalculate_ASM:
ld (ShiftCpyDir_SMC),a \.r
sbc a,a
ld hl,6
add hl,sp
ld hl,(hl)
and a,l
ret z
ld h,lcdWidth/2
mlt hl
add hl,hl
ret
@mateoconlechuga
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment