Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.
|
Forum Index : Microcontroller and PC projects : new vga moan
Page 2 of 3 | |||||
Author | Message | ||||
TassyJim Guru Joined: 07/08/2011 Location: AustraliaPosts: 5910 |
They are not 'primary' colours, they are the initial 8 colours defined in MMBasic (a long time ago) which is why they are in the lists. The highlighting of keywords in MMEdit is only a visual effect in MMEdit and has no significance to MMBasic. It only indicates that the word is listed in the keyword list. Because the colours are parameters, not commands or functions, they can sometimes be used as user variables. That results in a dilemma as to which words get listed. If you want them treated as keywords, you can add them to the list(s) Jim VK7JH MMedit MMBasic Help |
||||
stanleyella Guru Joined: 25/06/2022 Location: United KingdomPosts: 1647 |
Sprite problem or bug. I tried a glcd sprite program on vga but sprite read seems not to read a black background. cls rgb(black) sprite read 3,10,10,16,16 'reads 16x16 background to blit buffer3 udg1 'draws sprite1 on screen at 10,10 sprite READ 1,10,10,16,16 'reads sprite1 from screen to blit buffer1 pause 10000 sprite WRITE 3,10,10 'erase udg1 but doesn't pause 10000 udg1 'draws sprite2 on screen at 10,10 sprite read 2,10,10,16,16 'reads sprite2 from screen to blit buffer2 pause 10000 ------- This sprite reads the black back ground... or should, then it draws sprite1, which it does, then waits 10 secs, then it should erase the sprite but doesn't, it waits 20secs and draw sprite 2. How do I sprite read the background which is cls rgb(black) please? doin my head:) glad I'm not spock or data :) |
||||
phil99 Guru Joined: 11/02/2018 Location: AustraliaPosts: 1790 |
You will need to check the latest VGA manual on this point, my memory is a bit hazy. I think sprites use Black as Transparent so you can overlay a sprite that isn't a simple rectangle on a background image and have the background show through. So an all black sprite will be invisible on any background. Edited 2023-02-04 07:53 by phil99 |
||||
stanleyella Guru Joined: 25/06/2022 Location: United KingdomPosts: 1647 |
Yes Phil, it seems that sprite read does not read black or sprite write does not write black. I changed the cls to blue and the prog works even though the sprites are from data and have black pixels. They were drawn for a black back ground, how to use a black background? 16 16x16 animated sprites, to fast to see. mode 2 OPTION BASE 0 ' 0 based arrays option DEFAULT INTEGER OPTION EXPLICIT dim dx(15),dy(15),spx(15),spy(15) dim oldspx(15),oldspy(15) dim ptr,spw,spht,temp,frame,frame_count,spdata,sp1 CONST bk = RGB(BLack) const wh = rgb(white) const bl = rgb(blue) const gr = rgb(green) const cy = rgb(cyan) const re = rgb(red) const ma = rgb(magenta) const ye = rgb(yellow) const br = rgb(brown) ' COLOUR rgb(white),rgb(blue) restore cls rgb(blue) sprite read 3,10,10,16,16 'reads 16x16 background to blit buffer3 udg1 'draws sprite1 on screen at 10,10 sprite READ 1,10,10,16,16 'reads sprite1 from screen to blit buffer1 udg1 'draws sprite2 on screen at 10,10 sprite read 2,10,10,16,16 'reads sprite2 from screen to blit buffer2 cls rgb(blue) for temp=0 to 15 'set up start sprite positions and directions do dx(temp)=(int(rnd*4)+1)-(int(rnd*8)+1) loop until dx(temp)<>0 do dy(temp)=(int(rnd*4)+1)-(int(rnd*8)+1) loop until dy(temp)<>0 spx(temp)=104+((rnd*64)+1) spy(temp)=144+((rnd*64)+1) next temp ' do 'demo moving sprite for temp=0 to 15 ' if sprite_status(temp)=1 then 'is sprite active if spx(temp)> 300 then 'check right edge dx(temp)= 0-dx(temp) end if if spx(temp)<8 then 'check left edge dx(temp)= 0-dx(temp) end if if spy(temp)>220 then 'check bottom edge dy(temp)= 0-dy(temp) end if if spy(temp)<8 then 'check top edge dy(temp)= 0-dy(temp) end if ' oldspx(temp)=spx(temp):oldspy(temp)=spy(temp) 'get last position for erase spx(temp)=spx(temp)+dx(temp):spy(temp)=spy(temp)+dy(temp) 'get new position for draw ' if frame=0 then'which sprite to draw sprite WRITE 3,oldspx(temp),oldspy(temp) 'erase sprite at last position sprite WRITE 1,spx(temp),spy(temp) 'draw sprite1 at new position else sprite WRITE 3,oldspx(temp),oldspy(temp) 'erase sprite at last position sprite WRITE 2,spx(temp),spy(temp) 'draw sprite2 at new position end if next temp ' frame_count=frame_count+1 'when to change sprite if frame_count=10 then frame=not frame frame_count=0 end if loop ' sub udg1 'draws 16x16 data for blit to copy for spht=0 to 15 for spw=0 to 15 read sp1 pixel spw+10,spht+10,sp1 next spw next spht end sub ' 'sprite1 data wh,bl,bl,bl,bl,bk,bk,bk,bk,bk,bk,bl,bl,bl,bl,wh data bk,bl,re,re,re,bl,bl,bk,bk,bl,bl,re,re,re,bl,bk data bk,bk,bk,bl,re,wh,bl,bk,bk,bl,wh,re,bl,bk,bk,bk data bk,bk,bk,bl,re,wh,bl,bk,bk,bl,wh,re,bl,bk,bk,bk data bk,bk,bk,bk,bl,wh,bl,bk,bk,bl,wh,bl,bk,bk,bk,bk data bk,bk,bk,bk,bk,bl,bl,bk,bk,bl,bl,bk,bk,bk,bk,bk data bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk data bk,bk,bk,bk,ye,ye,ye,bk,bk,ye,ye,ye,bk,bk,bk,bk data bk,bk,bk,ye,bk,bk,bk,bk,bk,bk,bk,bk,ye,bk,bk,bk data bk,ye,ye,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,ye,ye,bk data bk,ye,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,ye,bk data ye,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bl,ye data ye,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,ye data ye,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,ye data bk,ye,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,ye,bk data bk,bk,ye,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,ye,bk,bk 'sprite2 data bl,bl,bl,bl,bl,bk,bk,bk,bk,bk,bk,bl,bl,bl,bl,bl data bk,bl,re,re,re,bl,bl,bk,bk,bl,bl,re,re,re,bl,bk data bk,bk,bl,wh,wh,re,bl,bk,bk,bl,re,wh,wh,bl,bk,bk data bk,bk,bk,bl,re,wh,bl,bk,bk,bl,wh,re,bl,bk,bk,bk data bk,bk,bk,bk,bl,wh,bl,bk,bk,bl,wh,bl,bk,bk,bk,bk data bk,bk,bk,bk,bk,bl,bl,bk,bk,bl,bl,bk,bk,bk,bk,bk data bk,bk,bk,bk,bk,bk,bk,ye,ye,bk,bk,bk,bk,bk,bk,bk data bk,bk,bk,bk,bk,ye,ye,bk,bk,ye,ye,bk,bk,bk,bk,bk data bk,bk,bk,bk,ye,ye,bk,bk,bk,bk,ye,ye,bk,bk,bk,bk data bk,bk,bk,bk,ye,bk,bk,bk,bk,bk,bk,ye,bk,bk,bk,bk data bk,bk,bk,ye,bk,bk,bk,bk,bk,bk,bk,bk,ye,bk,bk,bk data bk,bk,ye,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,ye,bk,bk data bk,bk,bk,ye,ye,bk,bk,bk,bk,bk,bk,ye,ye,bk,bk,bk data bk,bk,bk,bk,ye,ye,bk,bk,bk,bk,ye,ye,bk,bk,bk,bk data bk,bk,bk,bk,bk,ye,bk,bk,bk,bk,ye,bk,bk,bk,bk,bk data bk,bk,bk,bk,bk,bk,ye,bk,bk,ye,bk,bk,bk,bk,bk,bk Edited 2023-02-04 08:29 by stanleyella |
||||
phil99 Guru Joined: 11/02/2018 Location: AustraliaPosts: 1790 |
The darkest non-black colour is dark green, RGB(0,64,0). Edit. If that isn't dark enough you could put a 10k pot. in series with the Dark Green pin, GP19 then adjust it to suit. It will also affect any other colours that use dark green such as white so it will be a compromise. When you run other programs that need normal colours turn the pot back to 0R. Edited 2023-02-04 09:53 by phil99 |
||||
stanleyella Guru Joined: 25/06/2022 Location: United KingdomPosts: 1647 |
Phil- dark green is not black :) Using ili 480x320 and "sprites" worked but now don't. Maybe new mmbasic. doesn't work with any background colour... but says something about miso connected.. it is set up for touch.. but there's miso issues and I needed a 680R resistor. cls RGB(0, 0, 255) blit read 3,10,10,16,16 'reads 16x16 background to blit buffer3 udg1 'draws sprite1 on screen at 10,10 'pause 5000 BLIT READ 1,10,10,16,16 'reads sprite1 from screen to blit buffer1 udg1 'draws sprite2 on screen at 10,10 'pause 5000 blit read 2,10,10,16,16 'reads sprite2 from screen to blit buffer2 cls bl Having fun with vga and sorting a keyboard Think I'll restart with 640 bw graphics but what sprite will do or is it colour only...I'll read the manual cheers, stan I can't think of an alternative to use sprite to erase a sprite. a box or the code I used to draw the udg would be to slow. only got vga working 3 days and scratching head already. ps thanks for the 10K pot idea..10K?!? Edited 2023-02-05 06:30 by stanleyella |
||||
Mixtel90 Guru Joined: 05/10/2019 Location: United KingdomPosts: 5735 |
Sorry, you can't use a true black background with sprites. Black is always transparent. The frame buffer has space for 307,200 bits. Those are arranged as 640x480x1 (either on or off) or 320x240x4 colour bits. If you want a "transparant" flag then you have to lose one of the colour bits. Instead, Peter designed it so that 0000 is transparent (and is also black) so that you don't lose one of the other bits (Red, Lt Green, Green, Blue). Colour in Mode 1 is interesting. :) Read the section on Tiles. Font 3 is made for the Tiles in Mode 1. Edited 2023-02-05 08:13 by Mixtel90 Mick Zilog Inside! nascom.info for Nascom & Gemini Preliminary MMBasic docs & my PCB designs |
||||
phil99 Guru Joined: 11/02/2018 Location: AustraliaPosts: 1790 |
To erase a sprite overwrite the with background colour. eg:- const dg = rgb(0 , 64, 0) 'Dark Green BOX x, y, 16, 16 ,, dg, dg Or make a sprite that is the same colour as the background (not black as that will be transparent). Read latest VGA manual pages 88 to 90. All about sprites. . Edited 2023-02-05 08:29 by phil99 |
||||
stanleyella Guru Joined: 25/06/2022 Location: United KingdomPosts: 1647 |
I tried sprite in mode 1 and can't write black so how's sprite work in monochrome 640x480 please? mode 1 is b/w? where's colours? mode 1 cls sprite read 10,35,35,32,32 'read back ground circle 50,50,15,0,1,1,1 sprite read 1,35,35,32,32 'copy circle do sprite write 1,200,200 'draw circle pause 2000 sprite write 10,200,200 'erase circle... but doesn't pause 2000 loop |
||||
phil99 Guru Joined: 11/02/2018 Location: AustraliaPosts: 1790 |
Repeating - Black sprites are transparent therefore can't erase the background. try this:- > BOX 66, 77, 16, 16 ,, RGB(white), RGB(white) > sprite read 1,66,77,16,16 > sprite show 1,177,166,0 > BOX 177, 166, 16, 16 ,, 0, 0 > Edited 2023-02-05 08:53 by phil99 |
||||
Mixtel90 Guru Joined: 05/10/2019 Location: United KingdomPosts: 5735 |
In Mode 1, if you treat it as 640x480 pixels then each pixel can be on or off. "On" can be any colour, as can "off" depending omn the OPTION set. That's all you can have. You can also treat Mode 1 as 16x16 pixel "Tiles" (40x30 Tiles). In that mode each "Tile" can have its own foreground and background colours, but of course you can get "colour clash" like a Spectrum as you cross "tile" boundaries. :) Mick Zilog Inside! nascom.info for Nascom & Gemini Preliminary MMBasic docs & my PCB designs |
||||
stanleyella Guru Joined: 25/06/2022 Location: United KingdomPosts: 1647 |
I tried sprite hide but got error:not showing mode 1 cls circle 50,50,15,0,1,1,1 sprite read 1,35,35,32,32 cls do sprite write 1,200,200 pause 2000 sprite hide 1 'error : not showing pause 2000 loop using boxes to erase sprites would be too slow. Without blit or sprite, graphics are very slow, too slow, I've tried plotting sprites and it's unusable. |
||||
phil99 Guru Joined: 11/02/2018 Location: AustraliaPosts: 1790 |
Following the VGA manual this works just fine. >mode 1 > const wt = rgb(white) > circle 250,50,15,0,1,wt,wt > sprite read 3,235,35,32,32 > sprite show 3,200,200,0 > sprite hide 3 > sprite show 3,200,200,0 > sprite hide 3 > sprite show 3,200,200,0 > sprite hide 3 > sprite show 3,200,200,0 > sprite hide 3 >for y=1 to 450 step 9:for x=1 to 620 step 9:sprite show 3,x,y,0:pause 99:next:next Have you tried it on the VGA? It seems quick to me. The PicoMiteVGA isn't a Serial LCD panel, it uses the second RP2040 core and is quite fast. Try this:- >mode 1 > for x=1 to 620 : BOX x,11,16,16,,1,1 : next > > cls :for y=1 to 460 step 17:for x=1 to 610 step 17:BOX x,y,16,16,,1,1:next:next > Or this:- cls : circle 250,50,15,0,1,1,1 : sprite read 2,235,35,32,32 cls 1:for y=1 to 460 step 17:for x=1 to 610 step 17:BOX x,y,16,16,,0,0:next:next for y=1 to 450 step 30:for x=1 to 620 step 17:sprite show 2,x,y,0:pause 99:next:next ' Edited 2023-02-05 17:42 by phil99 |
||||
Mixtel90 Guru Joined: 05/10/2019 Location: United KingdomPosts: 5735 |
I think you need to treat the PicoMite VGA as a *completely* different display system, Stan. It doesn't work exactly like a LCD and you mustn't expect it to. You *may* be able to write software that will run on both, but it may not be straightforward and you shouldn't attempt it until you are fully conversant with the VGA system. I'm afraid it's back to serious VGA manual reading and experimenting. Forget what you did with the LCD displays for the moment. Mick Zilog Inside! nascom.info for Nascom & Gemini Preliminary MMBasic docs & my PCB designs |
||||
thwill Guru Joined: 16/09/2019 Location: United KingdomPosts: 3848 |
I'm not sure that's true. There are very few display related differences in the display code for my (sorry as yet unreleased) Lazer-Cycle game for CMM2, PicoMiteVGA and Bintendo Lameboy (PicoMite + LCD), it basically just worked - but then again it has simple graphics without sprites. I also got @Martin H's PicoVader's to run on the Bintendo with only a couple of lines changed, and I think that may use sprites - Martin ? Apologies for not being more specific Stan - I'm otherwise occupied - but I may be able to dig deeper in a couple of days if you want. Best wishes, Tom Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
thwill Guru Joined: 16/09/2019 Location: United KingdomPosts: 3848 |
Ah, it uses GUI BITMAP, I now see that the non-VGA PicoMite doesn't have sprites ... that may make porting games to the Bintendo less trivial - c'est la vie. Best wishes, Tom Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 8592 |
If you want to hide a sprite you must SHOW it not WRITE it Option explicit Option default none MODE 2 FRAMEBUFFER create FRAMEBUFFER write f CLS 'brownian motion demo using sprites Dim integer x(32),y(32),c(32) Dim float direction(32) Dim integer i,j,k, collision=0 Dim string q$ For i=1 To 32 direction(i)=Rnd*360 'establish the starting direction for each atom c(i)=RGB(Rnd*255,Rnd*255,Rnd*255) 'give each atom a colour Circle 9,9,9,1,,RGB(white),c(i) 'draw the atom Sprite read i,0,0,19,19 'read it in as a sprite Next i CLS RGB(myrtle) Box 1,1,MM.HRes-2,MM.VRes-2 k=1 For i=MM.HRes\9 To MM.HRes\9*8 Step MM.HRes\9 For j=MM.VRes\9 To MM.VRes\9*8 Step MM.VRes\5 Sprite show k,i,j,1 x(k)=i y(k)=j vector k,direction(k), 0, x(k), y(k) 'load up the vector move k=k+1 Next j Next i ' Do For i=1 To 32 vector i, direction(i), 1, x(i), y(i) Sprite show i,x(i),y(i),1 If sprite(S,i)<>-1 Then break_collision i EndIf Next i FRAMEBUFFER copy f,n,b Loop ' Sub vector(myobj As integer, angle As float, distance As float, x_new As integer, y_new As integer) Static float y_move(32), x_move(32) Static float x_last(32), y_last(32) Static float last_angle(32) If distance=0 Then x_last(myobj)=x_new y_last(myobj)=y_new EndIf If angle<>last_angle(myobj) Then y_move(myobj)=-Cos(Rad(angle)) x_move(myobj)=Sin(Rad(angle)) last_angle(myobj)=angle EndIf x_last(myobj) = x_last(myobj) + distance * x_move(myobj) y_last(myobj) = y_last(myobj) + distance * y_move(myobj) x_new=Cint(x_last(myobj)) y_new=Cint(y_last(myobj)) Return ' keep doing stuff until we break the collisions Sub break_collision(atom As integer) Local integer j=1 Local float current_angle=direction(atom) 'start by a simple bounce to break the collision If sprite(e,atom)=1 Then 'collision with left of screen current_angle=360-current_angle ElseIf sprite(e,atom)=2 Then 'collision with top of screen current_angle=((540-current_angle) Mod 360) ElseIf sprite(e,atom)=4 Then 'collision with right of screen current_angle=360-current_angle ElseIf sprite(e,atom)=8 Then 'collision with bottom of screen current_angle=((540-current_angle) Mod 360) Else 'collision with another sprite or with a corner current_angle = current_angle+180 EndIf direction(atom)=current_angle vector atom,direction(atom),j,x(atom),y(atom) 'break the collision Sprite show atom,x(atom),y(atom),1 'if the simple bounce didn't work try a random bounce Do While (sprite(t,atom) Or sprite(e,atom)) And j<10 Do direction(atom)= Rnd*360 vector atom,direction(atom),j,x(atom),y(atom) 'break the collision j=j+1 Loop Until x(atom)>=0 And x(atom)<=MM.HRes-sprite(w,atom) And y(atom)>=0 And y(atom)<=MM.VRes-sprite(h,atom) Sprite show atom,x(atom),y(atom),1 Loop ' if that didn't work then place the atom randomly Do While (sprite(t,atom) Or sprite(e,atom)) direction(atom)= Rnd*360 x(atom)=Rnd*(MM.HRes-sprite(w,atom)) y(atom)=Rnd*(MM.VRes-sprite(h,atom)) vector atom,direction(atom),0,x(atom),y(atom) 'break the collision Sprite show atom,x(atom),y(atom),1 Loop End Sub Edited 2023-02-06 00:09 by matherp |
||||
stanleyella Guru Joined: 25/06/2022 Location: United KingdomPosts: 1647 |
First, thank you all for helping me. It is much appreciated... the manual is a good manual but info spread about a bit and "disguised" or hidden imho. I treat the vga picomite as a separate entity to non vga picomite. Blit is not the same as sprite but similar. sprite write buffer number,x,y blit write buffer number,x,y,w,h. I think blit has change in firmware update in 6 months since started using mmbasic. Only just started using vga version so don't know what was previous versions. Sprite read and write work in 640x480 vga but not black. I use the old idea of erasing a graphic then redrawing it so erase must be fast to avoid flicker but if you used sprite write 100 times and box 100 times and timed each there would be a big difference. Just tried 640x480 vga mode 1 yesterday so re-reading the forum replies and studying the manual. Thanks again for the advice, stan "you shall go to the ball cinders" |
||||
stanleyella Guru Joined: 25/06/2022 Location: United KingdomPosts: 1647 |
@Matherp...any relation to Wyarrt? :) Tried your code and it worked and is very interesting and informative, luv it, brill! Should be in the manual! still running after 15 mins,no errors, nice one sir. Edited 2023-02-06 01:28 by stanleyella |
||||
stanleyella Guru Joined: 25/06/2022 Location: United KingdomPosts: 1647 |
I take back about box being too slow. It's as fast as sprite write for 16x16 sprite. Wow! if frame=0 then'which sprite to draw box oldspx(temp),oldspy(temp),16,16,0,bk,1 'erase sprite at last position sprite WRITE 1,spx(temp),spy(temp) 'draw sprite1 at new position else box oldspx(temp),oldspy(temp),16,16,0,bk,1 'erase sprite at last position sprite WRITE 2,spx(temp),spy(temp) 'draw sprite2 at new position end if This is interesting, I got my sprite demo to work on black background and the sprites look brighter. It's very fast. I'm amazed. It's simple but looks ok. |
||||
Page 2 of 3 |
Print this page |