home *** CD-ROM | disk | FTP | other *** search
/ ticalc.org / ticalc_org_rev_b.iso / archives / 86 / asm / source / sierp86.asm < prev    next >
Encoding:
Assembly Source File  |  2001-07-01  |  1.9 KB  |  88 lines

  1. ;**TI-86 Sierpinski's Triangle**    Version 1.1
  2. ;------------------------------------------------------------
  3. ;I have edited the code to use the system routines _IPoint
  4. ;and _RANDOM, so now it's smaller but not quite as fast as
  5. ;version 1.0.
  6. ;                       Dan Eble (eble@cis.ohio-state.edu)
  7. ;------------------------------------------------------------
  8. ; Version 1.0 by James Yopp (jyopp@pobox.com)
  9. ; "eMail me with comments, suggestions, or questions"
  10. ;------------------------------------------------------------
  11.  
  12. #Include "ti86asm.inc"
  13.  
  14. .org _asm_exec_ram
  15.  
  16.         call    _clrLCD
  17.  
  18.         ld hl,$FFF0     ; last line
  19.         ld de,$FFF1
  20.         ld bc,$0F
  21.         ld (hl),$FF
  22.         ldir
  23.  
  24.         ld bc,$0000    ; b = x, c = y
  25.         ld de,500      ; draw 7*500 dots
  26. Loop:
  27.         push de
  28.  
  29.         push bc
  30.         call _RANDOM
  31.         pop bc
  32.  
  33.         ld hl,_OP1M     ; hl -> OP1 mantissa, 7 bytes of random numbers
  34.         ld e,7          ; loop 7 times
  35. RandLoop:
  36.         push de
  37.         ld a,(hl)
  38.         inc hl
  39.         cp $33
  40.         jr c,HalveAndDraw
  41.         cp $66
  42.         jr nc,XPlus1
  43.  
  44. Yplus1andXplusHalf:
  45.         set     6,c       ;Same here, with 64.
  46.  
  47.         ld      a,64      ;But NOT here- We're only adding half the highest
  48.         add     a,b       ;Value, so the bit may already be set.
  49.         ld      b,a
  50.  
  51. HalveAndDraw:
  52.         srl b
  53.         srl c
  54.  
  55.         ld d,1
  56.         call _IPoint
  57.  
  58.         pop de
  59.         dec e
  60.         xor a
  61.         or e
  62.         jr nz,RandLoop
  63.  
  64.         pop de
  65.         dec de
  66.         ld a,d
  67.         or e
  68.         jr nz,Loop
  69.  
  70.         ld hl,0
  71.         ld (_penCol),hl
  72.         ld hl,DoneStr
  73.         call _vputs
  74.  
  75.         call _getkey
  76.         call _clrScrn
  77.         ret
  78.  
  79. XPlus1:
  80.         set 7,b ; Since bit 7 of B is never set, this is the same
  81.                 ; as adding 128.
  82.         jr HalveAndDraw
  83.         
  84. ;---------------
  85. DoneStr .db "Done",0
  86.  
  87. .end
  88.