Public feed #602389

Stuff

public text v1 · immutable
Raw Edit
·published 2007-07-04 01:31 UTC
rendered paste body
;-----> Changes Pixel state
; Input:	e=y coordinate
;			a=x coordinate
; Output:	Pixel is changed in buffer
pixelchange:
	ld	d,$00
	ld	h,d
	ld	l,e
	add	hl,de
	add	hl,de
	add	hl,hl
	add	hl,hl
	ld	de,plotsscreen
	add	hl,de
	push hl
	ld h,0
	ld l,a
	ld d,8
Div_HL_D:            ; HL = HL ÷ D, A = remainder
    XOR    A         ; Clear upper eight bits of AHL
    LD     B, 16      ; Sixteen bits in dividend
_loop:
    ADD    HL, HL     ; Do a SLA HL
    RLA              ; This moves the upper bits of the dividend into A
    JR     C, _overflow
    CP     D         ; Check if we can subtract the divisor
    JR     C, _skip   ; Carry means D > A
_overflow:
    SUB    D         ; Do subtraction for real this time
    INC    L         ; Set bit 0 of quotient
_skip:
    DJNZ   _loop
    ld e,l
    ld d,h
	pop hl
    add hl,de
    ld c,a
    or a
    jr z,pixel0
    ld a,c
	ld b,a
	ld a,%10000000
pcLoop:
	scf
	ccf
	rra
	djnz pcLoop
	ld e,a
	ld a,(hl)
	xor e	
	ld (hl),a
	ret
pixel0:
	ld a,(hl)
	xor %10000000
	ld (hl),a
	ret