[Coco] GFX2("DEFBUFF"
Gene Heskett
gheskett at shentel.net
Sat Feb 27 19:49:47 EST 2021
On Saturday 27 February 2021 18:33:37 coco at jechar.ca wrote:
> The error I get the second time I run the program.
>
> Error #194 - Bad/Undefined buffer number.
>
> On 2021-02-27 17:53, coco at jechar.ca wrote:
> > I dont get what that URL part is about so I tried this
> > It compiles but gives the wrong answer the first time it is run
> > and produces an error the second time it is run. Maybe you can
> > see what I am doing wrong.
> >
> > PROCEDURE buffy
> >
> > (* Test Program for
> > (* BASIC09 to get group 4, buffer 1 as an example.
> > (*
> >
> > DIM gpptr,gpsize:INTEGER
> >
> > gpptr = 0
> > gpsize = 0
> >
> > RUN GFX2("DEFBUFF",4,1,128)
> > RUN GetGPAddress(gpptr,gpsize)
> > PRINT "The ADDRESS of group 4, buffer 1 is:";
> > PRINT gpptr
> > PRINT "The SIZE of group 4, buffer 1 is:";
> > PRINT gpsize
> >
> > END
> > PROCEDURE GetGPAddress
> > PARAM gpptr,gpsize:INTEGER
> > TYPE registers=cc,a,b,dp:BYTE;x,y,u:INTEGER
> > DIM regs:registers
> > (* Std Out
> > regs.a=1
> > regs.b=$84
> > (* group & buffer #’s
> > regs.x=$0401
> > (* Map it in (regs.y=0 to map it back out again)
> > regs.y=1
> > RUN SYSCALL($8d,regs)
> > gpptr=regs.x
> > gpsize=regs.y
> >
> > END
> >
> > On 2021-02-25 21:43, L. Curtis Boyle wrote:
> >> On Feb 25, 2021, at 8:25 PM, coco at jechar.ca wrote:
> >>> If you have defined a graphics buffer with DEFBUFF is there some
> >>> way to determine it's actual address in your process space
> >>> so that you can poke values directly to the buffer.
> >>>
> >>> Charlie.
> >>
> >> Defbuff doesn’t map the buffer in; it merely allocates it from the
> >> computer's memory and lets you define the group/buffer #’s, and the
> >> size of the buffer itself. To map it in (and map it out), use the
> >> GetStat call SS.MpGPB.
> >>
> >> An example in BASIC09 to get group 4, buffer 1 as an example (set
> >> up as a callable module: Call with RUN
> >> GetGPAddress(buffptr,buffsize): PROCEDURE GetGPAddress
> >> PARAM gpptr,gpsize:INTEGER
> >> TYPE registers=cc,a,b,dp:BYTE;x,y,u:INTEGER
> >> DIM regs:registers
> >> (* Std Out
> >> regs.a=1
> >> regs.b=$84
> >> (* group & buffer #’s
> >> regs.x+$0401
> >> (* Map it in (regs.y=0 to map it back out again)
> >> regs.y=1
> >> RUN SYSCALL($8d,regs)
> >> IF LAND(regs.cc <http://regs.cc/>,1)=1 THEN
> >> PRINT “ERROR #”;regs.b
> >> gpptr=0
> >> gpsize=0
> >> ELSE
> >>
> >> gpptr=regs.x
> >> gpsize=regs.y
> >> ENDIF
> >> END
> >>
> >>
> >>
> >> L. Curtis Boyle
> >> curtisboyle at sasktel.net
> >>
> >> TRS-80 Color Computer Games website
> >> http://www.lcurtisboyle.com/nitros9/coco_game_list.html
> >>
> >> NitrOS-9 Ease of Use (EOU) Project
> >> http://www.lcurtisboyle.com/nitros9/nitros9.html
You are trying to do in basic09, what I did a lot of when I wrote myram
15 or 20 years ago. Except I did it in assembly allocating and mapping in
memory for a ramdisk in the gime's 8k blocks. Your error is in not
keeping an array of allocations so you can walk thru memory obtaining
these buffers and incrementing or decrementing without errors up to as
much memory as the machine has.
What you are getting the 2nd time you run it is telling you that the
memory you asked for has been claimed already by the first time you ran
it. You need to keep a record and increment your request to the next
available bit of free memory.
My version formatted itself at up to about 1.7 megs of ram for a ramdisk
in a 2 meg machine just by asking for a directory listing of /r0 in a
few milliseconds. It also gave that memory back to the system, every
last byte by the deiniz /r0 command. myram is part of the nitros9
download, so if you want to see how that was done, get nitros9 and study
that src. Be my guest.
Cheers, Gene Heskett
--
"There are four boxes to be used in defense of liberty:
soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author)
If we desire respect for the law, we must first make the law respectable.
- Louis D. Brandeis
Genes Web page <http://geneslinuxbox.net:6309/gene>
More information about the Coco
mailing list