[A86] What's wrong w/ This?2


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

[A86] What's wrong w/ This?2



Sorry, I changed it, iy now draws the sprite, but to wierd places on screen 
$0000=topleft,$0100=16bytes down on left??? Help!!

Sprites now have the height 1st. Ex:
.db 8
.db %11111111
.db %11111111
.db %11111111
.db %11111111
.db %11111111
.db %11111111
.db %11111111
.db %11111111

ps_normal:
  call _findpixel
  ld   d,0
  ld   e,a
  ld   b,(ix)
  inc  ix
ps_draw:
  add  hl,de
  ld   a,(ix)
  or   (hl)
  ld   (hl),a
ps_shift:
  ld   a,16
  ld   d,0
  ld   e,a
  inc  ix
  djnz ps_draw
  ret

; =============================================================
; Input:   B,C = X,Y
; Output:  HL= address in video memory, A & E = bitmask in byte
; =============================================================
_findpixel:
  ld    hl,offsets   ; possible offsets
  ld    a,b          ; and deals with a, not b
  and   $07          ; a = bit offset
  add   a,l          ; simulated 16-bit addition (a + hl)
  ld    l,a
  adc   a,h          ; adc = add through carry
  sub   l
  ld    h,a
  ld    e,(hl)       ; e = bitmask for (hl)
  ld    hl,_rld      ; temp storage for Y
  ld    (hl),c  ; store Y
  ld    a,b          ; a = x/8 (byte offset within row)
  rrca               ; 1 byte
  rrca               ; 4 clock cycles
  rrca  ; rotates a right 1 bit
  rld
  or    $FC
  ld    l,(hl)
  ld    h,a          ; hl -> byte in vid mem
  ld    a,e        ; now a holds the bitmask
  ret
_rld:    .db $00
offsets: .db $80,$40,$20,$10,$08,$04,$02,$01


Josh Gentry
"Real programmers code in pen during math class."
http://www.freewebz.com/jdgentry