OK this is not working at all its supposed to put the letter "m" on the screen using the dcs font. But it doesn't instead it displays gibberish
Code: Start:
ld a,1
ld (bitflag1),a ; set it to always be a wide char for lazyness and since we know thats what we want
ld a,"m"
call dgetcharwidthlocfroma
ld a,d
out (6),a
inc hl
push hl
pop ix
ld e,1
ld a,1
ld bc,gbuf
call putsprite8xb
call ifastcopy
haltt:
halt
jp haltt
putsprite8xb:
; inputs | A = X | E = Y | IX + sprite pointer | BC = Buffer | XxNTemp = width | XnNtemp2 = Hight
; draws a B' x C' sprite onto the screen at A E
push bc
push af ;LD A,(bitflag2)
xor a
ld (bitflag2),a
pop af
ld h,$00 ; zero h
ld d,h ;zero D
sla e ;y*2
sla e ;y*4
ld l,e ;ld l with Y
add hl,de ;faster:y*8
add hl,de ;faster:y*12
ld e,a ;ld e with x
srl e ; x/2
srl e ;x/4
srl e ;x/8
add hl,de
pop de ; restore buffer into DE
ld B,5 ; load b with hight which will always be 5
add hl,de
and 7 ;if alinged skip to put sprite
ld c,a ;save ^ to C
_4:
ld a,(bitflag1) ; checks for 4 or 5 bit sprite
or a ;
jr nz,_incix ; if set jp to inc ix always
ld a,(bitflag2) ; check if we need to shift of just mask
or a ; if 1 rotate
jr z,_rotate4
xor 1
ld (bitflag2),a ; toggle flag
ld a,(ix) ; else mask second nibble
and %11110000
ld d,a
jr putspriteloop1
_incix:
inc ix
ld d,(ix)
jr putspriteloop1
_rotate4:
xor 1
ld (bitflag2),a
ld a,(ix)
sla a
sla a
sla a
sla a
ld d,a
inc ix
putSpriteLoop1:
;ld d,(ix) ; load D with first byte of sprite ; commented out handled below
ld e,$00 ; zero E incase of alignment
ld a,c ; load a with IF aligned value
or a ; if zero skip aligner
jr z,putSpriteSkip1 ; blaaaahhhh
putSpriteLoop2:
srl d ; move d to the right one throw bit 0 in cary
rr e ; rotate carry into E
dec a ;dec a and repeat till alinged
jr nz,putSpriteLoop2
putSpriteSkip1:
ld a,(hl) ;load a with byte of buffer
or d ; or a with the value of D
ld (hl),a ; load buffer with or'd value
inc hl ;in location on buffer
ld a,(hl) ; load a with byte on buffer
or e ; or buffer with E
ld (hl),a ; put back on buffer
ld de,$0B ;load b with 12
add hl,de ; move to next row on buffer
djnz _4
ret
Problem is most likely in the sprite routine but I cant figure out where if at all :/