home *** CD-ROM | disk | FTP | other *** search
- u
- T H E G E N I U S O F
- [S H P 2 F O N T]
- A N D [D O T B A S I C]
-
- by Dave Moorman
-
-
- This utility took about two days
- to complete -- partly because of a
- certain madness on the part of the
- creator, but mostly because it was
- created with DotBASIC. DotBASIC
- requires a lot of overhead (everything
- below Page 64, plus the visually
- designed MED screen file). But the
- efficiency of the code and speed of
- development makes up for it. At least
- at this end!
-
- Since DotBASIC uses so much
- memory, I had to hunt down UNPACKER
- 2000, by Dennis Hildreth, to allow
- loading and unpacking of SHP bitmaps
- in a single go. This is why the bitmap
- has to reload when you choose 3. or 4.
-
- Drag-and-drop did not work
- well in this situation; the squares
- had to not exceed the given area of
- the block. So I used a "tag-along"
- technique:
-
- sp _ sprite number of square
- .do:.ma
- jx = cx%*8+24
- jy = cy%*8+50
- hx = int(jx/256)
- jx = jx and 255
- poke 53264,(peek(53264) and not 2^sp)
- or (hx * 2^sp)
- poke 53248 + sp*2,jx
- poke 53249 + sp*2,jy
- .un l2%
-
- CX% and CY% are generated by .MA
- -- the cell location of the mouse
- arrow. The business with HX handles
- moving the square to the right side of
- the screen. The squares are a little
- sluggish, but then again, I wrote this
- at two in the morning, so I was quite
- sluggish myself.
-
-
- Several times, I wanted to use a
- <BACK ARROW> keypress to escape the
- current action. I tried:
-
- .do:.ma:.wb
- -
- -
- -
- .un e% or l2%:ifl2%=0then<escape>
-
- But using e% caused some confusion
- in the main loop. So I found a better
- way:
-
- .do:.ma:.kp,"_"
- -
- -
- -
- .un i% or l2%:ifl2%=0then <escape>
-
- .KP,STRING looks for a keypress in
- the following string. If it is there,
- I% holds the position of that
- character in the string.
-
- For the SHP file requester, I used
- methods outlined in the Cookbook
- elsewhere on this issue.
-
- For the creation of an FTS screen,
- I needed to compare 8-byte chunks of
- bitmap memory with 8-byte chunks of
- font memory. This would be painfully
- slow if we could not bring string
- variables into play.
-
- Early in the program, I create two
- string variables:
-
- a$=str$(peek(71)+256*peek(72))
- a = val(a$)
- b$=str$(peek(71)+256*peek(72))
- b = val(b$)
-
- With this code, A holds the first
- location of the three byte string
- pointer for A$. B holds the pointer
- location for B$. The pointer bytes are
-
- LENGTH / LO ADDRESS / HI ADDRESS.
-
- So the first thing is to make both A$
- and B$ 8-bytes long:
-
- poke a,8:poke b,8
-
- I also created two FuNctions to
- separate low and high bytes of
- addresses.
-
- deffnh(x)=int(x/256)
- deffnl(x)=x-fnh(x)*256
-
- So, as I flipped through memory
- (with FOR-NEXT loops with STEP 8), I
- plugged the locations into the string
- pointers:
-
- poke a+1, fnl(x):poke a+2, fnh(x)
- poke b+1, fnl(y):poke b+2, fnh(x)
-
- Now, A$ and B$ each "hold" eight
- bytes, one from the bitmap, the other
- from the font. All that is needed is
-
- if a$ = b$ then ....
-
- The code is still BASIC, so it
- gets bogged down toward the end. But
- it is about as fast as I needed for
- this special purpose utility.
-
-
- Several times during design, I had
- to call up B.VDOT, the visual design
- program, to modify the screen. For
- instance, only as I began to write the
- documentation did I realize I needed a
- disk function. So VDOT let me easily
- change the items on the menu and add
- the extra Region. While this means
- jumping between programs, having the
- visual presentation right there on the
- screen makes corrections easy.
-
-
- DotBASIC makes complex BASIC
- programs easy, clean, and efficient.
- Take a look at the DotBASIC/Mr.Mouse
- documentation elsewhere in this issue
- for command-by-command explanations.
- If you are an "almost intermediate"
- BASIC 2.0 programmer, DotBASIC will
- propel you into the realm of Wizard!
- Much of the monkeying with memory
- management is already done for you.
- You can lay out your screens and Event
- Regions quickly with VDOT. And the
- two-character commands are crisp and
- readable.
-
- DotBASIC has all the good stuff of
- BASIC 2.0 -- plus everything you need
- to create excellent programs.
-
- DMM
-
- [LATER:] As I was editing this, I
- realized that DotBASIC HAS a command
- for punching two-byte values into two
- bytes of memory. Where I
-
- poke(a+1),fnl(x):pO(a+2),fnh(x)
-
- I could have:
-
- .p2,a+1,x
-
- and a+1/a+2 would hold the lo/hi data
- of x.
-
- I might go back and change it, if I
- have time. You should take a look
- yourself and see if I "improved" the
- code!
-
- DMM
-
-
-