home *** CD-ROM | disk | FTP | other *** search
/ ticalc.org / ticalc_org_rev_b.iso / archives / 82 / asm / source / routines / drawsprite.asm
Encoding:
Assembly Source File  |  2001-07-01  |  2.9 KB  |  161 lines

  1. ;-------------------------------------------------| April 4,1999
  2. ;           "Drawsprite v1.2"                     |
  3. ;Description: Subroutine for fast sprite-graphics |
  4. ;             for use with TI-82, with ASH 3.0    |
  5. ;-------------------------------------------------|
  6. ;-----------------------------------------|
  7. ;Author: Jakob Selbing, JSS (C) 1997-1999 |
  8. ;  Comments, bugs, tips, anything on      |
  9. ;  your mind:                             |
  10. ;  jakob_selbing@hotmail.com              |
  11. ;-----------------------------------------|
  12. ;
  13. ;----------------------------------------------------|
  14. ;Credits: ASH-guys Dines and Mattias, Vikash R. Goel |
  15. ;----------------------------------------------------|                                                   
  16. ;
  17. ;How to use it 
  18. ;----------------------------------------------------------------
  19. ;Call drawspriteloop with the x-position (0...88) stored in b,
  20. ;the y-position stored in c, the address of the sprite stored in de,
  21. ;and the number of rows your sprite is stored in slength.
  22. ;
  23. ;So if you want to draw a sprite on the third row, 20 pixels to
  24. ;the rigth, and have defined a sprite with 6 rows at the label
  25. ;"sprite1" you should do something like this:
  26. ;
  27. ; ld b,20        ;x-position, zero is the left edge of LCD
  28. ; ld c,3        ;y-position, zero is top line of LCD
  29. ; ld de,sprite1        ;this is the address of the first
  30. ;            ;byte of the sprite
  31. ; ld a,6        ;this is the height of the sprite (i.e. rows)
  32. ; ld (slength),a        
  33. ; call drawsprite
  34. ; ROM_CALL(DISP_GRAPH)
  35. ;
  36. ;ENJOY!!!!
  37. ;-----------------------------------------------------------------------
  38.  
  39.  
  40. #include "ti82.h"
  41.  
  42. slength =TEXT_MEM+40
  43.  
  44.  
  45. drawsprite:             ;Version 1.2, July 23 1998
  46.  push de
  47.  ld hl,$88B8
  48.  ld de,12
  49.  inc c
  50. DS_Row:
  51.  dec c
  52.  jr z,DS_Donerow
  53.  add hl,de
  54.  jr DS_Row
  55. DS_Donerow:
  56.  ld a,b
  57. DS_Byte:
  58.  cp 8
  59.  jr c,DS_Donebyte
  60.  sub 8
  61.  inc hl
  62.  jr DS_Byte
  63. DS_Donebyte:
  64.  pop de
  65.  push af
  66. DS_Return:
  67.  pop af
  68.  ex de,hl
  69.  ld b,(hl)
  70.  ld c,0
  71.  push af
  72. DS_Shift:
  73.  or a
  74.  jr z,DS_Doneshift
  75.  dec a
  76.  srl b
  77.  rr c
  78.  jr DS_Shift
  79. DS_Doneshift:
  80.  ex de,hl
  81.  ld a,(hl)
  82.  or b
  83.  ld (hl),a
  84.  inc hl
  85.  ld a,(hl)
  86.  or c
  87.  ld (hl),a
  88.  pop af
  89.  inc de
  90.  push de
  91.  ld de,11
  92.  add hl,de
  93.  pop de
  94.  push af
  95.  ld a,(slength)
  96.  dec a
  97.  ld (slength),a
  98.  or a
  99.  jr nz,DS_Return
  100.  pop af
  101.  ret
  102.  
  103. removesprite:             ;Version 1.2, July 23 1998
  104.  push de
  105.  ld hl,$88B8
  106.  ld de,12
  107.  inc c
  108. RS_Row:
  109.  dec c
  110.  jr z,RS_Donerow
  111.  add hl,de
  112.  jr RS_Row
  113. RS_Donerow:
  114.  ld a,b
  115. RS_Byte:
  116.  cp 8
  117.  jr c,RS_Donebyte
  118.  sub 8
  119.  inc hl
  120.  jr RS_Byte
  121. RS_Donebyte:
  122.  pop de
  123.  push af
  124. RS_Return:
  125.  pop af
  126.  ex de,hl
  127.  ld b,(hl)
  128.  ld c,0
  129.  push af
  130. RS_Shift:
  131.  or a
  132.  jr z,RS_Doneshift
  133.  dec a
  134.  srl b
  135.  rr c
  136.  jr RS_Shift
  137. RS_Doneshift:
  138.  ex de,hl
  139.  ld a,b
  140.  cpl
  141.  and (hl)
  142.  ld (hl),a
  143.  inc hl
  144.  ld a,c
  145.  cpl
  146.  and (hl)
  147.  ld (hl),a
  148.  pop af
  149.  inc de
  150.  push de
  151.  ld de,11
  152.  add hl,de
  153.  pop de
  154.  push af
  155.  ld a,(slength)
  156.  dec a
  157.  ld (slength),a
  158.  or a
  159.  jr nz,RS_Return
  160.  pop af
  161.  ret