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 : Fast and Durty PicoMiteVGA Demo
Author | Message | ||||
Martin H. Guru Joined: 04/06/2022 Location: GermanyPosts: 890 |
A little Demo I coded 35 years ago in 6809Assembler on the Dragon32. Just 4 fun to test the BLIT - Function in MMBasic VGA Save both Pictures as Ball1.bmp and Ball2.bmp in the same Folder as the .Bas file 'Bouncing Ball Demo by Martin Herhaus 2022 'litle BLIT Demo for MM Basic Pico-VGA MODE 2 Colour RGB(black),RGB(white) BL=1:H=86:W=84 CLS x=0:y=0 Load image "Ball1.bmp" For f=1 To 4 Blit read #f,x,y,w,h x=x+w:If f=2 Then x=0:y=y+h Next f Load image "Ball2.bmp" x=0:y=0 For f=5 To 8 Blit read #f,x,y,w,h x=x+w:If f=6 Then x=0:y=y+h Next f an=1:SN=1:rot=-1 BX=0: BY=0: BDir=1 CLS Do by=Int(Sin(sn*Pi/128)*160):SN=SN+1 SN=SN And 255 If by<0 Then BY=-BY BY=160-by Blit write #an,bx,by,W,H an=an+rot:If an=9 Then an=1 If AN=0 Then an=8 bx=bx+bdir:If BX>=232 Or BX<1 Then bdir=-bdir:rot=-rot Pause 20 Loop Sub free For f=1 To 8:Blit close #f:Next f End Sub as it uses a lot of memory, I added the "free" function to get the memory back after the Program has ended. Save this as Ball1.bmp: Save this as Ball2.bmp or just use the Zip File: ball.zip if it runs to slow, you can decrease the Pause Value at the end of the Loop have fun. Edited 2022-06-07 04:05 by Martin H. 'no comment |
||||
Volhout Guru Joined: 05/03/2018 Location: NetherlandsPosts: 3490 |
Hi Martin, I get a syntax error at this line. Sprite write #an,bx,by,W,H Running the latest MMBasic 5.07.05b1 When I replace the line with Sprite show #an,bx,by,1 The ball bounces, but leaves painting artefacts behind. I didn't change anything else in your program. Maybe I have to use a framebuffer ? Edited 2022-06-08 05:26 by Volhout PicomiteVGA PETSCII ROBOTS |
||||
Bleep Guru Joined: 09/01/2022 Location: United KingdomPosts: 409 |
Hi, Yes I did get this going myself, from memory, all it needed was Sprite write #an,bx,by,1 So replace the W,H with 1, I'll check & confirm when I'm able. Regards Kevin |
||||
Martin H. Guru Joined: 04/06/2022 Location: GermanyPosts: 890 |
ähm ?! ... as I wrote this Demo on the latest final Version of PicoMiteVGA V5.07.04, there is no Sprite command in it. Edited 2022-06-08 14:07 by Martin H. 'no comment |
||||
Volhout Guru Joined: 05/03/2018 Location: NetherlandsPosts: 3490 |
Blit and Sprite are now the same as I read in the 5.07.05 notes. In fact if you run your program in 5.07.05 it translates the word BLIT in SPRITE. With the effect that you get the error. Even if I type the line new in the editor, it translates BLIT in SPRITE. I am not sure if that is correct. With the BLIT you could move arbitrary blocks of video memory (i.e. determine width and height yourself). Sprite does not support that. Anyway. I will need to revert back to 5.07.04 to test your program as it originally was.... Volhout P.S. I do not see a way to leave the DO LOOP that moves the balls (no EXIT, no call to that sub). That means that the sub that frees up memory is never called. Correct ? Edited 2022-06-08 16:08 by Volhout PicomiteVGA PETSCII ROBOTS |
||||
Martin H. Guru Joined: 04/06/2022 Location: GermanyPosts: 890 |
sorry, I had no Time to test the new Functions from the Beta b4/B5 jet. So this little demo was made with the functions in mmbasic 5.07.04. (which i allready havent tested all) .. it was fast and durty, which means dirty^2 And yes, ther is no call for the "free" sub, so after the PAUSE command, one can add the "anykey" to call "free" and exit the loop if inkey$<>"" then free:mode 1:exit Do Edited 2022-06-08 20:31 by Martin H. 'no comment |
||||
Martin H. Guru Joined: 04/06/2022 Location: GermanyPosts: 890 |
ok, for Testing, i now have installed the Beta (5.07.05b5) looks like the Sprite Routine has no opaque Mode, which was default in the Blit So from this, the Image looses all its Black parts and so it does not overwrite the older Image on the Screen. Also the original Black parts are White / Transperent. This little fix does overwrite the old image before it draws the new sprite... (Flickers like hell) 'Bouncing Ball Demo by Martin Herhaus 2022 'litle BLIT Demo for MM Basic Pico-VGA 'version for Sprite / Beta MODE 2 Colour RGB(black),RGB(white) BL=1:H=85:W=85 CLS x=0:y=0 Load image "Ball1.bmp" For f=1 To 4 Sprite read #f,x,y,w,h x=x+w:If f=2 Then x=0:y=y+h Next f Load image "Ball2.bmp" x=0:y=0 For f=5 To 8 Sprite read #f,x,y,w,h x=x+w:If f=6 Then x=0:y=y+h Next f an=1:SN=1:rot=-1 BX=0: BY=0: BDir=1:bx1=0:by1=0 CLS Do by=Int(Sin(sn*Pi/128)*160):SN=SN+1 SN=SN And 255 If by<0 Then BY=-BY BY=160-by Box bx,by,h+1,w+1,,RGB(white),RGB(white) Sprite show #an,bx,by,2:bx1=by:by1=by an=an+rot:If an=9 Then an=1 If AN=0 Then an=8 bx=bx+bdir:If BX>=232 Or BX<1 Then bdir=-bdir:rot=-rot Pause 20 Loop Edited 2022-06-25 03:14 by Martin H. 'no comment |
||||
Print this page |