;Sierpinski Triangle Renderer by Martin Hock (oxymoron@bigsky.net) Feb 12 '98 ;Since every other TI-8x author seems to be releasing some source, I decided ;to hack up something that would actually be worthy of viewing. ;You may use stuff out of this if you give me credit. You may not sell ;anything using stuff you've gotten out of this. Have fun. Copyright 1998. ;Normally displays like this: |/ which looks pretty dumb, so I busted a hack. ;Register D = X, moved out a little horizontally for better display ;Register E = Y, inverted for better display ;Doesn't even use any RAM for temp storage, which you have to admit is cool. VIDEO_MEM = $FC00 GRAPH_MEM = $C9FA CLEARLCD = $4A7E ;I gleaned these from various sources, but Mardells' SQRXZ GET_KEY = $5371 ;had it all in one place. BUSY_OFF = $4AB1 .org $D748 call BUSY_OFF ;why in the hell didn't TI turn this off? oddly, the same call CLEARLCD ;thing happens when you run binary via the custom menu hack ;on the 85... is TI really so cheesy as to utilize that same ld d,63 ;method? ld e,63 ;The X and Y size must be the same when you use this or you just SierpLoop: ;see double. ld a,d and e ;This Sierpinski method does x AND y. Weird but it works. jr nz,LoopEnd PutDot: ld h,0 ld a,63 sub e ;Inverted so the flat part is on the bottom. ld l,a add a,a add a,a ld l,a add hl,hl ;x16, using one method that's faster and one that preserves all add hl,hl ld bc,VIDEO_MEM add hl,bc ld a,e srl a add a,d ;now a = super horizontal so the point is in the middle ld b,0 ld c,a srl c srl c ;/ 8 to find screen byte srl c inc c inc c ;Move it right a little so it's centered on the screen inc c inc c add hl,bc ;A is preserved throughout this for the pixel render thing and %00000111 ;strip off all but bit-location within byte PixelRender: ;input: a=fake bit number where 0=left and 7=right ld b,a or a ld a,%10000000 ;This basically rotates a bit to the position desired. jr z,EndRender ;I hate tables. Tables are for tards. PixelRendLoop: ;This routine is 10 bytes. Tables can't match srl a ;sheer wit. djnz PixelRendLoop EndRender: or (hl) ;Combine nondestructively with existing byte/screen contents ld (hl),a LoopEnd: dec d bit 7,d jr z,SierpLoop ;This method to determine if it wrapped is REALLY dumb, ld d,63 ;but no other method I tried would work, and it's not dec e ;all that bad. Just a jr nz would cut off the edge. bit 7,e jr z,SierpLoop ;GraphMemCopy: ; ld hl,VIDEO_MEM ; ld de,GRAPH_MEM ;Copy it to the graph mem for fun. ; ld bc,1024 ;Dumb because it renders instantly anyway. ; ldir WaitLoop: call GET_KEY nop nop nop ;Lots of wait because people will enjoy staring at it. nop ;See if it can get you some chicks! nop ;NOTE: If you are a chick and this fascinates you, e-mail me. nop or a jr z,WaitLoop call CLEARLCD ret .end ;Ends up being 104 bytes on the calculator. Ford 'n' Fun.