![]() |
How to create and draw graphics - Printable Version +- Forum (https://www.boriel.com/forum) +-- Forum: Compilers and Computer Languages (https://www.boriel.com/forum/forumdisplay.php?fid=12) +--- Forum: ZX Basic Compiler (https://www.boriel.com/forum/forumdisplay.php?fid=11) +---- Forum: Help & Support (https://www.boriel.com/forum/forumdisplay.php?fid=16) +---- Thread: How to create and draw graphics (/showthread.php?tid=297) Pages:
1
2
|
How to create and draw graphics - slenkar - 02-13-2011 What is the best way to draw graphics to the screen e.g. UDG or other method How do you get sprites from the sprite editor into the basic program? How to create and draw graphics - slenkar - 02-13-2011 how do you draw graphics to the screen? Re: How to create and draw graphics - boriel - 02-13-2011 UDG creation is slightly different than in Sinclair BASIC. For compatibility's sake you can use POKE USR "a" and so on to create UDG, but there is a better way: You can create a big array with your UDG data a then poke 23675 to the array address using the @ operator. E.g.: Code: 10 UDGData => {0,255,0,255,0,255,0,255,0}: REM 8 bytes More info on PRINTing UDG and Graphics here: <!-- m --><a class="postlink" href="http://www.boriel.com/wiki/en/index.php/ZX_BASIC:Syntax">http://www.boriel.com/wiki/en/index.php/ZX_BASIC:Syntax</a><!-- m --> Re: How to create and draw graphics - slenkar - 02-13-2011 thanks for the help how would I convert the information from the sprite editor into an array? I downloaded the latest stable version, but when I click on the EXE files none of them open the IDE, I had to install the boriel program to c: because I dont have privileges to install to program files Re: How to create and draw graphics - boriel - 02-13-2011 slenkar Wrote:thanks for the helpThis is quite hard (to do it by hand). There are people that does this in several ways:
Quote:I downloaded the latest stable version, but when I click on the EXE files none of them open the IDE,Since version 1.2.7 another .zip files with just the .exe files will also be released. Also, there is no IDE with the ZX Basic. It's all command line. However there are IDEs you can use with ZX Basic:
Re: How to create and draw graphics - slenkar - 02-13-2011 thanks, ill check out tommy gun Re: How to create and draw graphics - slenkar - 02-14-2011 ok I got tommy gun working, this is the code to put the fruit into memory: POKE UINTEGER 23675, @udg(0, 0): what if I wanted to create a second UDG Would I change the 23675 number to something different? Also, do you know of a speccy emulator that accepts commandline arguments and can load a tzx file in quickly?(not spectacular) Ive found 2 emulators but they only do one of the above each :x Re: How to create and draw graphics - boriel - 02-14-2011 slenkar Wrote:ok I got tommy gun working,For a 2nd UDG, just put the data following the first one; that is: 16 bytes together Code: DIM udg(16) as ubyte => { nn, nn, nn, nn, nn, _' Line break allowed using the "_" character Code: DIM udg(1, 7) as ubyte => { { 01, 02, 03, 04, 05, 06, 07, 08}, _ ' Line break with character '_' slenkar Wrote:Also, do you know of a speccy emulator that accepts commandline arguments and can load a tzx file in quickly?(not spectacular)I use EmuZWin: https://www.zophar.net/sinclair/emuzwin.html Unfortunately, it seems abandoned since 2008. It runs ok in Windows XP. If you want to test it under Vista or Win7 you might want to enable "compatibility mode". Re: How to create and draw graphics - LCD - 02-14-2011 slenkar Wrote:what if I wanted to create a second UDG23675 is the Spectrums system variable address which holds the address of the UDG set. Changing this number will result in a high crash probability or strange bevaviour. You can define another set of UDGs called e.g. secondudg() and use their name in place of udg() slenkar Wrote:Also, do you know of a speccy emulator that accepts commandline arguments and can load a tzx file in quickly?(not spectacular)I use ZX Spin, it is not Spectacular but loads TZX generazed by ZXBC instantly. In other emulators maybe you can set the loading options to fast/flashload too. And I think, almost all Emulators support commandline arguments. Re: How to create and draw graphics - slenkar - 02-14-2011 Quote:70 REM UDG Is CHR(144) the first user defined graphic ? what is the last one you can have? CHR(?) 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? also, is there a script or library that replaces the spectrum font with something nicer? Re: How to create and draw graphics - boriel - 02-14-2011 slenkar Wrote: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?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" 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). Re: How to create and draw graphics - slenkar - 02-14-2011 ok thanks, that makes things clearer Re: How to create and draw graphics - slenkar - 02-15-2011 how would I use an image that was included as a bin e.g. ASM #incbin "factory.bin" END ASM then how would i poke it and draw it? Re: How to create and draw graphics - boriel - 02-15-2011 slenkar Wrote:how would I use an image that was included as a binYou can use labels, so put a label immediately *before* the asm block: Code: POKE Uinteger 23675, @MyUdgBlock Re: How to create and draw graphics - slenkar - 02-16-2011 thanks Quote:POKE Uinteger 23675, @MyUdgBlock How would i poke more than one image? and then how would I draw more than one? |