Re: A82: Find Pixel Question
[Prev][Next][Index][Thread]
Re: A82: Find Pixel Question
In a message dated 98-05-17 13:49:49 EDT, you write:
> Hello,
> Would someone please tell me how exactly Find_Pixel works [the input,
> the output, etc.] because I am going to attempt to make a Find_Pixel
routine
> for the 83 so I can port some games... Any help would be appreciated.
>
> -Ahmed
instead of FIND_PIXEL, use this (from FLine):
xor A ;*** A is provided for overflows (ld a, 0)
ld C, E ;*** this section multiplies E by 16
sla C ;*** changed to multiply E by 12 by Adamman
sla C ;*** used as a fast substitute for FIND_PIXEL
rla
ld B, C ;*** added by Adamman
sla C
rla
push AF ;*** added by Adamman
ld A, B ;*** added by Adamman
add A, C ;*** added by Adamman
ld C, A ;*** added by Adamman
pop AF ;*** added by Adamman
; sla C ;*** removed by Adamman
; rla ;*** removed by Adamman
ld B, A
ld HL, GRAPH_MEM ;*** changed from ld hl, VIDEO_MEM by Adamman
add HL, BC
ld B, 0 ;*** this section divides D by 8
ld C, D
srl C
srl C
srl C
add HL, BC ;*** now we have the byte we are going to use
ld (DRAW_BYTE), HL ;*** but we still need the bit!
;*** this section removed:
; ld HL, (PROGRAM_ADDR) ;could be optimized w/ a substitution tbl
; ld BC, BIT_TABLE
; add HL, BC
;*** replaced with this:
ld HL, BIT_TABLE
;*** end replacement
ld A, D ;*** this section determines the bit to change
and 00000111b
ld C, A
ld B, 0
add HL, BC
ld A, (HL)
ld (BIT_MASK), A
BIT_TABLE:
.db 10000000b,01000000b,00100000b,00010000b
.db 00001000b,00000100b,00000010b,00000001b
Input is point (d,e) as a coordinate in pixels, (0,0) being the TOP LEFT HAND
corner of the screen (unlike FIND_PIXEL which uses the bottom left). Of
course change "ld hl, GRAPH_MEM" to whatever buffer you want it to record to.
output would be (BIT_MASK), one byte and the bit to change and (CHANGE_BYTE),
two bytes and the byte to change in the graph mem. in FIND_PIXEL, input is
(b,c), a is the bit to change, and hl is the byte to change, which must be
added to GRAPH_MEM to get the address in the graph mem.
Resident experts (Dines, Crash Man, Barubary), please make sure this is right!
~Adamman