Skip to content

Instantly share code, notes, and snippets.

@ephesus
Created October 12, 2010 15:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ephesus/622326 to your computer and use it in GitHub Desktop.
Save ephesus/622326 to your computer and use it in GitHub Desktop.
; Black and white Sprite drawing to $FC00 4x4 wide
; For ti-85 or ti-86 calculators. (mmapped black white display at $fc00, 16 byte wide rows)
; IX = pointer to Sprite Data
; B = X coordinate
; C = Y coordinate top left corner is 0,0
;by James Rubingh 2000
.include asm86.h
.include ti86asm.inc
.org _asm_exec_ram
Draw4x4:
ld h,%00111111 ;calculate Offset
ld a,c
add a,a
add a,a
ld l,a
ld a,b
rra ;interlaced add instructions to clear zero flag for rra
add hl,hl ;x8
rra ;\4
add hl,hl ;x16
rra ;\8
or l
ld l,a
ld a,b
and 7
ld bc,D4bits
add a,c
ld c,a
adc a,b
sub c
ld b,a
ld a,(bc) ;HL = offset IX=ssprite data
ld b,4
Vert:
push bc
push af
push hl
ld d,(ix)
ld b,4
Horiz:
ld e,a
rl d
jr c,Setpixel
cpl
and (hl)
ld (hl),a
jr incbyte
Setpixel:
or (hl)
ld (hl),a
incbyte:
ld a,e
rrca
jr nc,SkipI
inc hl
SkipI:
djnz Horiz
pop hl
ld a,16 ;simulated 16 bit addition (HL + (A+carry))
add a,l
ld l,a
adc a,h ;use carry flag as 9th bit of A
sub l
ld h,a
inc ix
pop af
pop bc
djnz Vert
ret
D4bits:
.db 128,64,32,16,8,4,2,1 ;bitmasks
.end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment