A86: FindPixel Routine
[Prev][Next][Index][Thread]
A86: FindPixel Routine
Could somebody please tell me what is wrong with this? I am trying to put
a pixel at (1,1) but it comes up around (5,0)
- Thanks
Ricci Adams
#include "ti86asm.inc"
.org _asm_exec_ram
ld e, 1
ld d, 1
call FindPixel
ld a,1
ld (hl),a
;--------------------------------------------------------------------
; The Eble-Yopp-Yopp-Eble-Eble-Eble-Yopp Fast FindPixel Routine :)
; 36 bytes / 121 t-states not counting ret or possible push/pop of BC
;--------------------------------------------------------------------
; Input: D = y
; E = x
; Output: HL= address of byte in video memory
; A = bitmask (bit corresponding to pixel is set)
; C is modified
;
; +-----------+
; |(0,0) | <- Screen layout
; | |
; | (127,63)|
; +-----------+
;
;--------------------------------------------------------------------
FindPixel:
ld hl,FP_Bits
ld a,e
and $07 ; a = bit offset
add a,l
ld l,a
adc a,h
sub l
ld h,a
ld c,(hl) ; c = bitmask for (hl)
;48 t-states up to this point
ld hl,FP_RLD
ld (hl),d
ld a,e ; a = x/8 (byte offset within row)
rrca
rrca
rrca
rld
or $FC
ld l,(hl)
ld h,a ; hl -> byte in vid mem
ld a,c ; now a = bitmask for (hl)
;121 t-states up to this point
ret
FP_RLD: .db $00
FP_Bits: .db $80,$40,$20,$10,$08,$04,$02,$01
.end
Follow-Ups: