chickendude wrote:
lirtosiast: I believe your routine should work for unsigned numbers as is as well.
You mean signed numbers?
_FillRectangle_NoClip:
Draws an unclipped rectangle with the global color index
Arguments:
arg0 : X Coord
arg1 : Y Coord
arg2 : Width
arg3 : Height
Returns:
None
ld iy,0
add iy,sp
ld a,(iy+12) ; height
or a
ret z
ld bc,(iy+9) ; width
sbc hl,hl
adc hl,bc
ret z
ld hl,(iy+3) ; hl = x coordinate
ld e,(iy+6) ; e = y coordinate
_FillRectangle_NoClip_ASM:
ld d,lcdWidth/2
mlt de
add hl,de
add hl,de
ld de,(currDrawBuffer)
add hl,de
ex de,hl
push de
ld (_RectangleWidth1_SMC),bc \.r
ld (_RectangleWidth2_SMC),bc \.r
ld hl,color1
ldi ; check if we only need to draw 1 pixel
pop hl
jp po,_Rectangle_NoClip_Skip \.r
ldir
_Rectangle_NoClip_Skip:
dec a
ret z
inc b
ld c,$40 ; = fast "ld bc,lcdWidth"
_Rectangle_Loop_NoClip:
add hl,bc
dec de
ex de,hl
_RectangleWidth1_SMC =$+1
ld bc,0
lddr
dec a
ret z
ld bc,2*lcdWidth+1
add hl,bc
inc de
ex de,hl
_RectangleWidth2_SMC =$+1
ld bc,0
ldir
ld bc,2*lcdWidth-1
dec a
jr nz,_Rectangle_Loop_NoClip
ret
;-------------------------------------------------------------------------------
;_FillRectangle_NoClip:
; Draws an unclipped rectangle with the global color index
; Arguments:
; arg0 : X Coord
; arg1 : Y Coord
; arg2 : Width
; arg3 : Height
; Returns:
; None
;
; ld iy,0
; add iy,sp
; ld bc,(iy+9) ; bc = width
; sbc hl,hl
; adc hl,bc
; ret z ; make sure width is not 0
; ld a,(iy+12) ; a = height
; or a,a
; ret z ; make sure height is not 0
; ld hl,(iy+3) ; hl = x coordinate
; ld e,(iy+6) ; e = y coordinate
;_FillRectangle_NoClip_ASM:
; ld d,lcdWidth/2
; mlt de
; add hl,de
; add hl,de
; ld iy,(currDrawBuffer)
; ex de,hl ; de -> place to begin drawing
; ld (_RectangleWidth_SMC),bc \.r
;_Rectangle_Loop_NoClip:
; add iy,de
; lea de,iy
;_RectangleWidth_SMC =$+1
; ld bc,0
; ld hl,color1 \.r
; ldi ; check if we only need to draw 1 pixel
; jp po,_Rectangle_NoClip_Skip \.r
; scf
; sbc hl,hl
; add hl,de
; ldir ; draw the current line
;_Rectangle_NoClip_Skip:
; ld de,lcdWidth ; move to next line
; dec a
; jr nz,_Rectangle_Loop_NoClip
; ret
;----------------------------------------------------------------------
atan8:
;returns H=256*arctan(E/256)
;48cc if ADL mode
;takes 164cc to call this on the TI-84+CE
ld c,201
ld b,e
mlt bc ;x*201
xor a
sub e
ld d,a
mlt de ;x(256-x)
ld l,e
ld h,70
ld e,h
mlt de ;upper bytes
mlt hl ;lower bytes
ld a,e
add a,h
ld l,a
ld h,d
jr nc,$+3
inc h
add hl,bc
ret
Advertisement