A82: Re: Blockbuster v4.0


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

A82: Re: Blockbuster v4.0




Hey Doug, for this section of code, I think it could be optimized a little
more:

DrawRowOfBlocks:
 bit 0,(hl)
 call DrawBlock
 bit 1,(hl)
 call DrawBlock
 bit 2,(hl)
 call DrawBlock
 bit 3,(hl)
 call DrawBlock
 bit 4,(hl)
 call DrawBlock
 bit 5,(hl)
 call DrawBlock
 bit 6,(hl)
 call DrawBlock
 bit 7,(hl)
 call DrawBlock
 inc hl
 ld d,0
 inc e
 ld a,e
 cp 12
 jr nz,DrawRowOfBlocks

DrawBlock:
 jr z,NoBlock
 push hl
 ld hl,Block
 call ZoomSprite
 pop hl
 ret

NoBlock:
 ld a,d
 add a,8
 ld d,a
 ret

To this:

DrawRowOfBlocks:
 ld a,(hl)
 ld b,8
 push af
DrawRowLoop:
 pop af
 rra
 push af
 jr c,DrawBlock
NoBlock:
 ld a,d
 add a,8
 ld d,a
 jr DrawRowLoop
DrawBlock:
 push bc
 push hl
 ld hl,Block
 call ZoomSprite
 pop hl
 pop bc
 djnz DrawRowLoop
 pop af
 inc hl
 ld d,b
 inc e
 ld a,e
 cp 12 \ jr nz,DrawRowOfBlocks

Well, I'm sure that can be optimized further, but you get what I'm saying,
right?



References: