Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to create and draw graphics
#11
slenkar Wrote:
Code:
70   REM UDG
71   DIM udg(1, 7) AS uByte => { {60, 66, 129, 129, 129, 129, 66, 60}, _
                                 {24, 60, 60, 60, 126, 251, 247, 126}}
73     POKE UINTEGER 23675, @udg(0, 0): REM Sets UDG variable to first element
74   LET S$ = CHR$(144): LET F$ = CHR$(145)

Is CHR(144) the first user defined graphic ?
what is the last one you can have? CHR(?)
The above listing is right. You can CHR(144) up to... ???. Honestrly, not sure, but at least you should be able to use up to UDG "Z" (not existing in the original BASIC).
Remeber you can use "\A" instead of CHR$(144) for your commodity, so "\A"..."\Z". I'm currently a bit busy, but if I recall correctly, I wanted the user to use upper ASCII codes as UDG (e.g. PRINTing CHR$(210) won't print a token, but probably rubbish). I will update this info later.
slenkar Wrote:and talking of graphics should I investigate the 4sprite library?

also, if I create an image and import it as a BIN, does the sprite go into UDG memory or general memory?
Al the sprites and UDG go into general memory. In fact, there is no "UDG memory" in ZX BASIC: This is because you are now in machine code (not in real BASIC). Classic UDG graphics were located beyond RAMTOP. Now the RAMTOP is by default 32767 (see CLEAR 32767 in the generated basic listing upon your program exit. Type LIST<enter> after your program return). By doing the above or using incbin and POKEing 23675 you are reserving memory for your UDG the right way.
slenkar Wrote:also, is there a script or library that replaces the spectrum font with something nicer?
By default, PRINT already has some features. Try
Code:
PRINT BOLD 1; ITALIC 1; "HELLO WORLD"
You can use your fonts the same way you defined UDG: Create an array or use incbin, but this time you have to do POKE Uinteger 23606, @Mychars(0,0) - 256. This is the way it was done in basic, and so did I, to maintain compatibility.

Expanding UDG and graphics:
Needless to say you can have several arrays in your program, and POKE them (UDG, or CHARS) during runtime to have several UDG tables. This is very fast (and even more in ASM).
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 2 Guest(s)