Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
TCLib issues
#1
Jark:

1.- I have been tweaking with the mandelbrot Set drawer. The first thing I have made is a keyboard control, as I am a poor W2000 user and the mouse does'nt work for me..

I have stumbled on the following line
Code:
Hmdb = 60 + LOG(MdbVar# + eps ^ 100) * 120
being
Code:
CONST eps = 1.401298E-45             ' Avoids logarithm overflow

If I'm not wrong, 1.4E45 ^100 = 1.whatever ^4500
and the minimum double QBcan handle is 4.9e-324, so your eps^100 is simply 0.....


2.- Here is a small suggestion to make Tclib faster
Just change the present PSet24 and Point24 by the following ones. No arrays to precalculate, or VESA line lengthts to change, just rename or erase present Point24 and Pset24 and add next two subs.
Code:
DEFINT A-Z
SUB Point24 (x%, y%)
' Returns the current RGB combination of the selected pixel
'just an idea...
CONST windw = 65536
'Point needs a safety need or it could try to set an unexistant bank
IF x% < xPlotMin% OR x% > xPlotMax% OR y% < yPlotMin% OR y% > yPlotMax% THEN
  Red% = -1
  Green% = -1
  Blue% = -1
  EXIT SUB
END IF
Offset& = Bpl * y% + Bpp * x%
bank = Offset& \ windw
Offset& = Offset& AND 65535
DEF SEG = &HA000
IF bank <> CurBank THEN
  CurBank = bank
  Regs.ax = &H4F05
  Regs.bx = 0
  Regs.dx = CurBank
  CALL INTERRUPT(&H10, Regs, Regs)
END IF
Blue% = PEEK(Offset&)

Offset& = Offset& + 1
IF Offset& = windw THEN
  Offset& = 0
  CurBank = CurBank + 1
  Regs.ax = &H4F05
  Regs.bx = 0
  Regs.dx = CurBank
  CALL INTERRUPT(&H10, Regs, Regs)
END IF
Green% = PEEK(Offset&)

Offset& = Offset& + 1
IF Offset& = windw THEN
  Offset& = 0
  CurBank = CurBank + 1
  Regs.ax = &H4F05
  Regs.bx = 0
  Regs.dx = CurBank
  CALL INTERRUPT(&H10, Regs, Regs)
END IF
Red% = PEEK(Offset&)

END SUB

and

Code:
DEFINT A-Z
SUB Pset24 (x%, y%)
' Plots a pixel using the current RGB combination
CONST windw = 65536
DEF SEG = &HA000
IF x% < xPlotMin% OR x% > xPlotMax% OR y% < yPlotMin% OR y% > yPlotMax% THEN EXIT SUB

Offset& = Bpl * y% + Bpp * x%
bank = Offset& \ windw
Offset& = Offset& AND 65535

IF bank <> CurBank THEN
  CurBank = bank
  Regs.ax = &H4F05
  Regs.bx = 0
  Regs.dx = CurBank
  CALL INTERRUPT(&H10, Regs, Regs)
END IF
POKE Offset&, Blue%

Offset& = Offset& + 1&
IF Offset& >= windw THEN
   Offset& = 0
   CurBank = CurBank + 1
   Regs.ax = &H4F05
   Regs.bx = 0
   Regs.dx = CurBank
   CALL INTERRUPT(&H10, Regs, Regs)
END IF
POKE Offset&, Green%

Offset& = Offset& + 1&
IF Offset& >= windw THEN
  Offset& = 0
  CurBank = CurBank + 1
  Regs.ax = &H4F05
  Regs.bx = 0
  Regs.dx = CurBank
  CALL INTERRUPT(&H10, Regs, Regs)
END IF
POKE Offset&, Red%

END SUB

This must be combinded with SetVGA ending by
Code:
Curbank=-1
(this makes a bank to be set before the first pixel is drawn)
Antoni
Reply
#2
Well, the 1.401298E-45 value is just what QB accepts as the smallest constant when you type it manually. I really don't know why!

As for the eps^100, you're right : I changed it to eps^7 in TC-Mdb and also TC-Ray that uses this constant...

I will update the Pset24 and Point24 routines. I'm still tweaking the Line24 routine that had a couple of bugs: it seemed easy, but I had a lot of trouble with it!
hink Global, Make Symp' All ! ®
[Image: Banner.gif]
Reply
#3
I have found the answer about the
Code:
CONST eps = 1.401298E-45  
Hmdb = 60 + LOG(MdbVar# + eps ^ 100) * 120
thing. It seems eps^100 is not zero inside the calculation but it's zero if you assign it to a variable. It's curious!
You are using in your help the kind of "feature" that puzzled Moneo....
http://forum.qbasicnews.com/viewtopic.php?t=3364

However if you set up
Code:
const eps100=1D323
(note the D as exponent indicator)
you can avoid the repeated calculation of eps^100
Antoni
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)