0 Members and 2 Guests are viewing this topic.
DrawTile:;Inputs:; A is the tile number (0 to 95, draws columns, then rows); DE points to the sprite data sub 96 ;this will set the c flag if the result is negative ret nc ;Exits if the sprite is out of range ld bc,96 ;there are 96 bytes in 8 rows ld hl,plotSScreen-96 ;the graph buffer minus 96 add hl,bc ;Next row down add a,12 ;We are eliminating rows jr nc,$-3 ; ld c,a ;b is already 0, so do not worry add hl,bc ;BC is the X offset;HL points to where to draw the sprite;DE points to the sprite data ld bc,080Ch ;sets C to 12 and B to 8 (the height of th spriteTileLoop: ld a,(de) ;gets the next byte of the sprite or (hl) ;performs OR logic witht he buffer ld (hl),a ;copies the data to the buffer inc de ;points to the next sprite byte ld a,b ;we are saving B ld b,0 ;now BC is 12 add hl,bc ;Now HL points tot he next row ld b,a ;restores b djnz TileLoop ;Decrements B, if it is not 0, loop again ret
The contents of reg8 are shifted right one bit position. The contents of bit 0 are copied to the carry flag and a zero is put into bit 7.
ld de,plotSScreen+2FFh ;DE points to the last byte of the graphscreen ld hl,plotSScreen+2FFh-12 ;HL now points to the last byte in the second to last row ld bc,300h-12 ;this is the size of 63 rows lddr ;copies BC bytes at HL to DE going backwards ret