
faster PSET for SCREEN 12 / memory layout of SCREEN 12
Quote:
> Hello BASIC experts,
> I'm working on a simple oscilloscope with a fast AD card (with DMA
> transfer of the measured data and QB library) and QB for a bicycle
> generator efficiency test bench. The results are shown graphically on a
> 500x400 pixel part of SCREEN12 the rest is used for displaying
> aggregated numerical results (voltage: rms, max/min, frequency; current:
> rms, max/min; mechanical input power, electrical output power,
> efficiency, ...) and status informations. The graphics are done with
> first clearing the area with
> LINE (0, 0)-(501, 439), 0, BF 'black rectangle
> and then generating the new plot with
> LINE (0, 0)-(0, 400), 1 'y axis blue
> LINE (0, 200)-(500, 200), 1 'x axis blue
> FOR i = 0 TO 499
> PSET (i + 1, 200! - wert(i, 1) * 200!), 4 'current red
> PSET (i + 1, 200! - wert(i, 0) * 20!) 'voltage white
> NEXT
> On the old 386DX33 PC this results in a distinct flicker of the graphics
> (you notice the time it takes to build up the new curves). It is no
> problem for me, that the graphics are only updated once per second, but
> a constant sine wave should not flicker!
> The way to go could be to use a faster version of PSET (by writing
> directly to the video memory). I didn't find a usenet posting about this
> in dejanews (searching for "PSET" and "SCREEN 12"). Can someone please
> point me to information about the memory layout of screen12 or existing
> routines for a faster PSET?
> Even smoother results might be possible with generating the coming video
> page somewhere else in memory and copying the complete page fast to the
> video memory. Has someone done this before and is willing to give some
> hints?
> An other question is, if there is a faster way to clear the area than
> my LINE ()-(),0,BF ?
> The problem is, that I don't have much experience with assembler and the
> details of memory layout of PC's...
> TIA
> Andreas Oehler - from the rainy south of Germany
I've got 2 things to say, First I'll explain how pset using video memory
is done, then I'll give another suggestion
sub vmpset (xpos%,ypos%,colorr%)
DEF SEG=&HA000 'define as memory segment, the video memory (address
&HA000)
pos%=(ypos%-1)*640 'total width of the screen times the x position minus one
pos%=pos% + xpos% 'plus the X position
poke pos%,colorr% 'att that offset, poke the color
def seg 'and back to the default segment
end sub
But I wouldn't suggest just plotting to the video memory,
you where right about the reason for the flicker, but not about he solution
the new curve IS built up to slow, while the screen stays empty antil the
curve is built,
so you could build the new curve into another part of the memory, then copy
that part of the memory to the video screen, so avoiding flicker, this takes
care
of the ACTUAL REASON FOR FLICKER, where every QB porgrammer is
looking for, I'll demonstrate:
rem dynamic$
do
dim buffer%(31999) 'here the screen will be built up temporarely
' now put in your statements wich will build jup the screen, but replace
evey PSET (use only pset's)
'with PBSET varseg(buffer%(0)), xposition,yposition,color
'ill define pbset later
for locat%=0 to 31999
def seg=varseg(buffer%(0)) 'define as segment: the buffer
peek locat%,dump% 'get dump%
def seg=&HA000 'define the video memory as segment
poke locat%,dump% 'and put it here, like this copy the buffer to the video
memory
DEF SEG
next locat%
redim buffer%(0) 'easy way to clear it
redim buffer%(0)'and we're ready to repeat
sub PBSET (segm%,xpos%,ypos%,colorr%)
def seg=segm%
offs%=(ypos%-1)*640
offs%=offs%+xpos%
poke offs%,colorr%
def seg
end sub
'that should do it, but don't forget, poking into memory can always crash
you computer when there's a bug in the prog, so save frequently !
http://qbmax.mypage.org
http://come.to/qbmax
Visit my site!