snippets using sprites on cga - help needed
-
- Posts: 57
- Joined: Dec 08, 2010 14:55
- Location: Portugal
- Contact:
snippets using sprites on cga - help needed
Do someone can share some small snippet (20 lines max.) can show some sprites (using get and put) around the screen, on CGA display, which can run on Dosbox? (please, CGA only - for now, my only interest is using FreeBasic from FreeDOS, not on Linux or ReactOS - and doing code i can run in really old x86 hardware, like those 8088-based ones) - i'm strugling a lot on start some code on that! :) - thanks a lot! :)
-
- Posts: 57
- Joined: Dec 08, 2010 14:55
- Location: Portugal
- Contact:
Re: snippets using sprites on cga - help needed
i tried this one, using vga mode instead - only getting errors
any help on ajust this code into a working one, and using cga instead (4 colours, 320x200), is very welcome! thanks! :)
Code: Select all
dim as integer i,sprite
screen 13
dim sprite((32 * 32 * 2) + 4)
line (0,0)-(31,31), 1, bf
line (0,0)-(31,31), 2, b
line (8,8)-(23,23), 4, bf
line (1,1)-(30,30), 8
line (30,1)-(1,30),16
get (0,0)-(31,31), sprite
cls
for i = 0 to 63
line (0,i)-(319,i), rgb(i * 4, i * 4, i * 4)
next i
put (19, 16), sprite, pset
put (69, 16), sprite, preset
put (119, 16), sprite, and
put (169, 16), sprite, or
put (219, 16), sprite, xor
put (269, 16), sprite, trans
sleep
Re: snippets using sprites on cga - help needed
nitrofurano wrote: and doing code i can run in really old x86 hardware, like those 8088-based ones)
That will be interesting, since FB is afaik 386+
Re: snippets using sprites on cga - help needed
Starting points:
Code: Select all
dim as integer i
screen 13
dim sprite as any ptr = imagecreate(32, 32)
line (0,0)-(31,31), 1, bf
line (0,0)-(31,31), 2, b
line (8,8)-(23,23), 4, bf
line (1,1)-(30,30), 8
line (30,1)-(1,30),16
get (0,0)-(31,31), sprite
cls
for i = 0 to 63
line (0,i)-(319,i), rgb(i * 4, i * 4, i * 4)
next i
put (19, 16), sprite, pset
put (69, 16), sprite, preset
put (119, 16), sprite, and
put (169, 16), sprite, or
put (219, 16), sprite, xor
put (269, 16), sprite, trans
sleep
imagedestroy sprite
Code: Select all
dim as integer i
screen 1
dim sprite as any ptr = imagecreate(32, 32)
line (0,0)-(31,31), 1, bf
line (1,1)-(30,30), 2, b
line (8,8)-(23,23), 3, bf
line (1,1)-(30,30), 1
line (30,1)-(1,30), 2
get (0,0)-(31,31), sprite
cls
for i = 0 to 63
line (0,i)-(319,i), i mod 4
next i
put (19, 16), sprite, pset
put (69, 16), sprite, preset
put (119, 16), sprite, and
put (169, 16), sprite, or
put (219, 16), sprite, xor
put (269, 16), sprite, trans
sleep
imagedestroy sprite
-
- Posts: 57
- Joined: Dec 08, 2010 14:55
- Location: Portugal
- Contact:
Re: snippets using sprites on cga - help needed
would be great if there is some kind of code forcing to 8088! :)marcov wrote:nitrofurano wrote: and doing code i can run in really old x86 hardware, like those 8088-based ones)
That will be interesting, since FB is afaik 386+
would be really awesome! :)
-
- Posts: 57
- Joined: Dec 08, 2010 14:55
- Location: Portugal
- Contact:
Re: snippets using sprites on cga - help needed
brilliant, worked perfectly! thanks a lot! :)fxm wrote:Starting points:
Code: Select all
dim as integer i screen 13 dim sprite as any ptr = imagecreate(32, 32) line (0,0)-(31,31), 1, bf line (0,0)-(31,31), 2, b line (8,8)-(23,23), 4, bf line (1,1)-(30,30), 8 line (30,1)-(1,30),16 get (0,0)-(31,31), sprite cls for i = 0 to 63 line (0,i)-(319,i), rgb(i * 4, i * 4, i * 4) next i put (19, 16), sprite, pset put (69, 16), sprite, preset put (119, 16), sprite, and put (169, 16), sprite, or put (219, 16), sprite, xor put (269, 16), sprite, trans sleep imagedestroy sprite
Code: Select all
dim as integer i screen 1 dim sprite as any ptr = imagecreate(32, 32) line (0,0)-(31,31), 1, bf line (1,1)-(30,30), 2, b line (8,8)-(23,23), 3, bf line (1,1)-(30,30), 1 line (30,1)-(1,30), 2 get (0,0)-(31,31), sprite cls for i = 0 to 63 line (0,i)-(319,i), i mod 4 next i put (19, 16), sprite, pset put (69, 16), sprite, preset put (119, 16), sprite, and put (169, 16), sprite, or put (219, 16), sprite, xor put (269, 16), sprite, trans sleep imagedestroy sprite
-
- Posts: 57
- Joined: Dec 08, 2010 14:55
- Location: Portugal
- Contact:
Re: snippets using sprites on cga - help needed
a question: instead of using "dim sprite as any ptr = imagecreate(32, 32)" for having a sprite just on one variable, can i have sprites stored into arrays instead of just one variable, like using "put (19, 16), sprite(35), pset" instead of "put (19, 16), sprite, pset" ?
Re: snippets using sprites on cga - help needed
Yes:nitrofurano wrote:a question: instead of using "dim sprite as any ptr = imagecreate(32, 32)" for having a sprite just on one variable, can i have sprites stored into arrays instead of just one variable, like using "put (19, 16), sprite(35), pset" instead of "put (19, 16), sprite, pset" ?
dim sprite(100) as any ptr = imagecreate(32, 32)
..........
get (0,0)-(31,31), sprite(35)
..........
put (19, 16), sprite(35), pset
Re: snippets using sprites on cga - help needed
@fxm:
Be carreful!
doesn't compile:
Be carreful!
Code: Select all
dim sprite(100) as any ptr = imagecreate(32, 32)
And when you add the {} you'll get only one image. You've to initialize each element in sprite(0 TO 100) and destroy each element when done.....bas(4) error 60: Expected '{', found 'imagecreate' in 'dim sprite(100) as any ptr = imagecreate(32, 32)'
Code: Select all
VAR nsprite = 100
DIM AS ANY PTR sprite(nsprite)
FOR i AS INTEGER = 0 TO nsprite
sprite(i) = IMAGECREATE(32, 32)
NEXT
GET (0,0)-(31,31), sprite(35)
PUT (19, 16), sprite(35), PSET
FOR i AS INTEGER = 0 TO nsprite
IMAGEDESTROY (sprite(i))
NEXT
Re: snippets using sprites on cga - help needed
Yes, thank you TJF.TJF wrote:@fxm:
Be carreful!
On this one, I was a little too fast and offhand!
-
- Posts: 57
- Joined: Dec 08, 2010 14:55
- Location: Portugal
- Contact:
Re: snippets using sprites on cga - help needed
No way: FreeBasic emits 32 bit assembly, so a 32 bit processor is required (and an 8088 is a 16 bit processor)nitrofurano wrote: would be great if there is some kind of code forcing to 8088! :)
would be really awesome! :)
-
- Posts: 57
- Joined: Dec 08, 2010 14:55
- Location: Portugal
- Contact:
Re: snippets using sprites on cga - help needed
but i think there is a catch... - that's why i pointed this situation - someone (or some kind of converter) could be skilled to adapt this temporary 32bit .asm file during compiling, and convert it to a 16bit compatible - i think the main difference between 16bit and 32bit opcodes are related to the ram memory addressing, and the most usual ones (related to usual registers and simple calculations) are just exactly the same? - the fact is i think you really don't need 32bit for the most code you may use CGA/EGA stuff and some "light" codeangros47 wrote:No way: FreeBasic emits 32 bit assembly, so a 32 bit processor is required (and an 8088 is a 16 bit processor)nitrofurano wrote: would be great if there is some kind of code forcing to 8088! :)
would be really awesome! :)
Re: snippets using sprites on cga - help needed
Converting 32 bit asm to 16 bit is not an easy task, since many features are not available in 16 bit; otherwise, almost ever 32 bit program would have a port to 16 bit... and there would be no reason to upgrade processor.
If you want an open source basic compiler (like freebasic) that emits 16 bit assembly, you can try BASM:
http://www.bcxgurus.com/basm286.zip
Or you can have a look at this: http://exmortis.narod.ru/src_compilers_eng.html (note, anyway, that the creator of this site abandoned it when he found freebasic: http://www.freebasic.net/forum/viewtopi ... 18#p125018)
If you want an open source basic compiler (like freebasic) that emits 16 bit assembly, you can try BASM:
http://www.bcxgurus.com/basm286.zip
Or you can have a look at this: http://exmortis.narod.ru/src_compilers_eng.html (note, anyway, that the creator of this site abandoned it when he found freebasic: http://www.freebasic.net/forum/viewtopi ... 18#p125018)