A86: Where's my bug?


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

A86: Where's my bug?




Okay, well I almost had this program working and now it doesn't work at all,
at least as far as I'm concerned.  The program is supposed to draw a
bifurcation tree and in earlier versions it worked.  However, I have lost
the old code and now the program simply draws a line across the top of the
screen.  Why won't it work any more.  I'll include the old TI-BASIC version
so that you can see what is supposed to happen since it is probably a math
error.  Thanks!

Basic version:
:ClDrw:FnOff
:PlOff :AxesOff
:Goto start
:Lbl plot
:PxOn(iPart (64-Y*64),x)
:Goto A
:Lbl start
:For(x,0,127)
:2.5+(x/84)->X
:0.5->Y
:For(N,0,150)
:X*Y(1-Y)->Y
:If N>100
:Goto plot
:Lbl A
:End
:End

Asm version:
#include "ti86asm.inc"
#include "Ti86math.inc"
#include "TI86ops.inc"
.org _asm_exec_ram
  call _clrLCD
  xor a
  ld (Xcounter),a
XLOOP:
  ld a,(Xcounter)	;2.5+(x/84), OP1=Xcounter
  call _SetXXOP1
  ld a,$54			;OP2=84
  call _SetXXOP2
  call _FPDIV		;OP1=x/84
  ld hl, TWOPT5
  call _MOV10TOOP2	;OP2=2.5
  call _FPADD		;OP1=2.5+(x/84)
  call _OP1TOOP5	;OP5=OP1, OP5 will store X for calculations
  ld hl, PT5		;y = .5
  call _MOV10TOOP2	;OP2=y
  call _OP2TOOP6	;OP6=y
  ld b,150			;reset iteration counter
CALC:
  push bc
  call _OP6TOOP2	;OP2=y
  call _op1set1		;OP1=1
  call _FPSUB		;OP1=1-y
  call _FPMULT		;OP1=y(1-y)
  call _OP5TOOP2	;OP2=x
  call _FPMULT		;OP1=x*y(y-1)
  call _OP1TOOP6	;y now equals new value
  pop bc
  ld a,50
  cp b				;if Iterations>100 goto Plot
  call nc, Plot
  djnz CALC
  ld hl,Xcounter
  inc (hl)			;increment x counter
  ld a,127
  cp (hl)
  jr nz, XLOOP
  call _getkey
  call _clrLCD
  ret
TWOPT5: .db $00, $00, $FC, $25, $00, $00, $00, $00, $00, $00
PT5: .db $00, $FE, $FB, $50, $00, $00, $00, $00, $00, $00
Xcounter: .db 0
Plot:
  push bc
  call _OP6TOOP1	;OP1=y
  ld a,$40
  push af
  call _SetXXOP2	;OP2=64
  call _FPMULT		;OP1=y*64
  call _OP1TOOP2	;OP2=OP1
  pop af
  call _SetXXOP1	;OP1=64
  call _FPSUB		;OP1=64-y*64
  call _INTGR		;get integer value of OP1
  call _CONVOP1
  ld d,e			;does this put the value I want into d?
  ld a,(Xcounter)
  ld e,a
  call FindPixel
  or (hl)
  ld (hl), a
  pop bc
  ret

; Input: D = y; E = x
; Output: HL= address of byte in video memory
; A = bitmask (bit corresponding to pixel is set)
; C is modified
FindPixel:
  ld hl,FP_Bits
  ld a,e
  and %00000111
  add a,l
  ld l,a
  adc a,h
  sub l
  ld h,a
  ld c,(hl)
  ld hl,FP_RLD
  ld (hl),d
  ld a,e
  rrca
  rrca
  rrca
  rld
  or $FC
  ld l,(hl)
  ld h,a
  ld a,c
  ret
FP_RLD: .db $00
FP_Bits: .db $80,$40,$20,$10,$08,$04,$02,$01
.end




Follow-Ups: