LZ: Random Screen


[Prev][Next][Index][Thread]

LZ: Random Screen



I've been trying to make a program to put random dots on the screen. 
I've figured out how to completely fill the screen, but when I try to add
the Chris Busch's random number function, my calc hangs!  I can't figure
out what's wrong, so I'm giving my problem to the wisdom at List-ZShell. 
Thanks in advance!




;RANDSCR.ASM


; By Christopher Nice                                            
11-14-96


;   This program was designed for one purpose in mind.  It's for that
; ZShell Life program.  It's made to randomize the graph screen.  I
; suppose it could be used for other purposes, but I'm not quite sure
; what.


#include "ti-85.h"        ; normal stuff
#include "rand.h"         ; random number functions




.org 0
.db "Rnd Screen v.05", 0


;+------------+
;| Variables: |
;+------------+


randvar = $80DF   ;needed for C. Busch's random number routine


;+-------------------+
;| Start of program: |
;+-------------------+


     ROM_CALL(CLEARLCD)


     ld a, 4
     out (5), a           ; switch to TI-85 graphics mode


     ld b, $7F            ; load 127 into b  (b=x axis)
     ld c, $3F            ; load 63 into c   (c=y axis)
loopstart:
     
loop2start:
     push bc
     CALL_(rand)          ; get a random number in a
     pop bc
     
     ld d, a              ; load a into d
     ld a, $3F            ; load 63 (half of 127) into a
     cp d                 ; compare d with 63 (a)
     jr c, didntplotpixel ; if 63 is greater than d, goto didntplotpixel


     push bc              ; save bc
     CALL_(PutPixel)      ; put a pixel at the current loop location
     pop bc               ; restore bc
     
didntplotpixel:
     djnz loop2start      ; decrement b, and if b!=0, goto loop2start


     ld b, $7F            ; if b=0, put 127 back in b


     ld a, $0
     cp c                 ; check to see if c=0 (a)
     jr z, loopsdone      ; if so, exit


     dec c                ; if not, decrement c
     JUMP_(loopstart)     ; go to the start of loop one




loopsdone:
     
keyloop:
     call GET_KEY
     cp K_EXIT
     ret z
     JUMP_(keyloop)




     ret                  ; exit to ZShell




;+--------------+
;| Subroutines: |
;+--------------+




; Puts a pixel at b,c
PutPixel:
    ROM_CALL(FIND_PIXEL)
    ld de, $FC00
    add hl, de
    or (hl)
    ld (hl), a
    ret




.end




<pre>
--
C:\Nice (Christopher Nice)
cn3612@aol.com   cenice@juno.com
http://members.aol.com/cn3612    (temporary)
My software doesn't have bugs, it just develops random features.
</pre>