Re: A82: Solytare


[Prev][Next][Index][Thread]

Re: A82: Solytare




Here's a fast FIND_PIXEL routine (it works!)

	ld l, e					;*** multiply E by 12
	ld h, 0					;*** used as a fast substitute for FIND_PIXEL
	add hl, hl				;*** added by Adamman
	add hl, hl				;*** |
	ld b, h					;*** |
	ld c, l					;*** |
	add hl, hl				;*** |
	add hl, bc				;*** |

;        sla     C				;*** removed by Adamman
;        rla					;*** |
;        ld      B, A				;*** |

        ld      BC, 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: d, e
Output: (BIT_MASK) - and the a register - the bit to change
            (DRAW_BYTE) - the byte to change in the GRAPH_MEM
of course, probably all normal registers are changed
It's the same as the one I posted a while ago but this one WORKS

~Adamman

In a message dated 98-05-30 22:14:01 EDT, you write:

> Hmm.. I don't know.. speaking of which, would this work for Find_pixel on
>  the 83?
>  Someone gave me this, and I don't know how Find_Pixel works.. so i
wonder...
>                                                                             
>                              -Ahmed
>  
>  ;--------------------------------------------------------------------
>  ; 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
>  ; |           |
>  ; |   (95,63)|
>  ; +-----------+
>  ;
>  ;--------------------------------------------------------------------
>  FIND_PIXEL:
>          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
>          ld l,(hl)
>          ld h,a          ; hl -> byte in vid mem
>          ld a,c          ; now a = bitmask for (hl)
>   ld de,plotsscreen  ; CHANGED FOR 83
>   add hl,de
>  ;121 t-states up to this point
>          ret
>  FP_RLD:  .db $00
>  FP_Bits: .db $80,$40,$20,$10,$08,$04,$02,$01
>  
>                                                                             
>                          -Ahmed