Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 03:08 26 Apr 2024 Privacy Policy
Jump to

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 : Two-Line Bouncing Ball Pico VGA

Author Message
Martin H.

Guru

Joined: 04/06/2022
Location: Germany
Posts: 892
Posted: 05:59am 22 May 2023
Copy link to clipboard 
Print this post

Good Morning,
After watching the Video One-Line Bouncing Ball: Commodore 64 BASIC I just tried to run this on PicoMite VGA
It runs in Mode 1.

Do :D=12*A(78):E=8*A(158):Text F,G," ":Text E,D,"0":F=E:G=D:Inc T:Pause 20:Loop
Function A(B):A=Abs(T-Int(T/B)*B-B/2):End Function

Maybe someone can shorten it to one line

Cheers
 Mart!n
'no comment
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 3519
Posted: 06:14am 22 May 2023
Copy link to clipboard 
Print this post

Remove the pause… or beter even, get rid of f and g

Write ball, pause, erase ball Again, recalculate.
As long as pause exceeds calculation time the ball will appear to be visible.

Use gosub and return(shorter words)

Volhout
Edited 2023-05-22 16:20 by Volhout
PicomiteVGA PETSCII ROBOTS
 
Martin H.

Guru

Joined: 04/06/2022
Location: Germany
Posts: 892
Posted: 06:27am 22 May 2023
Copy link to clipboard 
Print this post

  Volhout said  Remove the pause… or beter even, get rid of f and g

Write ball, pause, erase ball Again, recalculate.
As long as pause exceeds calculation time the ball will appear to be visible.

Use gosub and return(shorter words)

Volhout
You're talking in riddles, my friend  
The pause is there to keep the movement smooth. Without the Pause you'll see just flashing Dots on the Screen. Gosub and Return would not do the same as the Function.
and I would have to use GoSub twice...
But getting rid of f and g shortes the Program to 109 Bytes  

Do :D=12*A(78):E=8*A(158):Text E,D,"0":Inc T:Pause 20:Text E,D," ":Loop
Function A(B):A=Abs(T-Int(T/B)*B-B/2):End Function


Edited 2023-05-22 16:37 by Martin H.
'no comment
 
JohnS
Guru

Joined: 18/11/2011
Location: United Kingdom
Posts: 3655
Posted: 09:20am 22 May 2023
Copy link to clipboard 
Print this post

Inline the function?

Does it make the line too long?

John
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 3519
Posted: 12:54pm 22 May 2023
Copy link to clipboard 
Print this post

Hi Martin..

replace "TEXT d,e," with "?@(d,e)"

Do :D=12*A(76):E=8*A(158):?@(E,D)"0":Inc T:Pause 20:?@(E,D)" ":Loop
Function A(B):A=Abs(T-Int(T/B)*B-B/2):End Function


4 characters shorter again. tested at MMB4W

another idea:
you move in steps of 8/12 (1 char size). But always inc. or dec.
Maybe you can omit the function with inlines inc. and de. where the value to inc/dec changes from +8 to -8 at boundaries, even so 12/-12...

Volhout

This is the idea, but 3 lines because you omit the "end if"

f=12:d=20:g=8:e=d:Do:if e>620 or e<10 then f=-f
if d>460 or d<10 then g=-g
inc d,g:inc e,f:?@(E,D)"0":Pause 20:?@(E,D)" ":Loop

Edited 2023-05-22 23:28 by Volhout
PicomiteVGA PETSCII ROBOTS
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 3519
Posted: 08:16pm 22 May 2023
Copy link to clipboard 
Print this post

Oneliner....

Do :d=12*Abs(t Mod 78-39):e=8*Abs(t Mod 158-79):Text e,d,"0":Inc t:Pause 20:CLS :Loop


Volhout

edit: bouncing ball fun...
Do :d=12*Abs(t Mod 78-39):e=8*Abs(t Mod 158-79):Text e,d,"0"
b=12*Abs(t Mod 76-38):c=8*Abs(t Mod 156-78):Text c,b,"0":Inc t
f=12*Abs(t Mod 74-37):g=8*Abs(t Mod 154-77):Text g,f,"0":Pause 25:CLS :Loop

Edited 2023-05-23 06:47 by Volhout
PicomiteVGA PETSCII ROBOTS
 
Martin H.

Guru

Joined: 04/06/2022
Location: Germany
Posts: 892
Posted: 04:58am 23 May 2023
Copy link to clipboard 
Print this post

  Volhout said  Oneliner....

Do :d=12*Abs(t Mod 78-39):e=8*Abs(t Mod 158-79):Text e,d,"0":Inc t:Pause 20:CLS :Loop


Volhout

edit: bouncing ball fun...
Do :d=12*Abs(t Mod 78-39):e=8*Abs(t Mod 158-79):Text e,d,"0"
b=12*Abs(t Mod 76-38):c=8*Abs(t Mod 156-78):Text c,b,"0":Inc t
f=12*Abs(t Mod 74-37):g=8*Abs(t Mod 154-77):Text g,f,"0":Pause 25:CLS :Loop

  Awesome, very impressive.
You actually managed to get into one line.  
'no comment
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 3519
Posted: 06:52am 23 May 2023
Copy link to clipboard 
Print this post

HI Martin

Looking at the video I realized how much more efficient the early 8 bitters where with basic code.
How much more you could put in one line of code. Shorter commands,that could be abbreviated. Separators that could be omitted.
I wrote a snake program including highscore, different levels,music,even created an apple by converting a character Q(putting it upside down in the font)In 28x40 characters. On an Oric-1.
In MMbasic that might not fit in 80x40…


Volhout
Edited 2023-05-23 16:54 by Volhout
PicomiteVGA PETSCII ROBOTS
 
Martin H.

Guru

Joined: 04/06/2022
Location: Germany
Posts: 892
Posted: 07:13am 23 May 2023
Copy link to clipboard 
Print this post

The listing was more intended as a puzzle, than a real application.
I found it amazing that one can do something like this with a single line of code.
'no comment
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 5720
Posted: 07:26am 23 May 2023
Copy link to clipboard 
Print this post

Now do it in seven APL characters. :)

"There are three things a man must do before his time is done
Write two lines of APL and make the bu&&ers run."

(Devil's DP dictonary)

--------

Very nice, Volhout!
The old 8-bitters had the advantage of a true memory-mapped display. You could do anything with it that you could do with conventional RAM. On the old Nascom one of the tricks was to put what looked like meaningless characters on the screen then jump to the resulting code and run it. :).

Have you tried putting a Q character on screen then manipulating the frame buffer contents directly? Now there's a challenge. :)
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 3519
Posted: 08:18am 23 May 2023
Copy link to clipboard 
Print this post

I was still puzzling if it could be done more efficient.

Different approach, but 1 character larger code...

Do :x=x+a:y=y+b:a=a+(x=0)-(x=79):b=b+(y=0)-(y=38):Text 8*x,12*y,"0":Pause 20:CLS :Loop


Technically the (y=38) should be (y=39) but that would bounce infinitely from corner to corner. Not very exciting.

Volhout
Edited 2023-05-23 18:19 by Volhout
PicomiteVGA PETSCII ROBOTS
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 3519
Posted: 08:25am 23 May 2023
Copy link to clipboard 
Print this post

  Mixtel90 said  On the old Nascom one of the tricks was to put what looked like meaningless characters on the screen then jump to the resulting code and run it. :).


I tried that also once, but it was a huge puzzle to write assembly code that translated into valid characters. So you could "CLS:print"abcdxyz":call address.
Where address was the start of video RAM. The 6502 was not very friendly on that since everything that did something with the accumulator started with 0xAn which does not type nicely in a print statement (if I remember correctly).

I think that is how they crammed chess in a ZX81 (1k).
Edited 2023-05-23 18:30 by Volhout
PicomiteVGA PETSCII ROBOTS
 
Martin H.

Guru

Joined: 04/06/2022
Location: Germany
Posts: 892
Posted: 08:58am 23 May 2023
Copy link to clipboard 
Print this post

  Volhout said   type nicely in a print statement (if I remember correctly).

I think that is how they crammed chess in a ZX81 (1k).

that could be the next challange ;-)

Full ZX81 Chess in 1K
'no comment
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 5720
Posted: 09:17am 23 May 2023
Copy link to clipboard 
Print this post

The Nascom was interesting in its screen memory. The display was 48 characters wide (to fit a TV screen) but took up 64 characters of screen RAM on each line. The "hidden" 16 characters were 9 on the left and 7 on the right of each line. As they were subject to CLS and scrolling they were effectively lost. However, someone did manage to write a program that displayed a digital clock in one corner of the screen. It automatically repaired itself during scrolling but didn't withstand CLS. :)

Another interesting thing is that the display was hardware generated with line one as the second text line, line 15 at the bottom and line 16 at the top. Lines 1-15 could be scrolled, leaving headings fixed on the top line.

IIRC the video circuit wasn't far off a copy of one of Don Lancaster's Cheap Video Cookbook designs.

Oh, and if you changed the character generator chip you could get a nice board for playing Sargon on an expanded Nascom. :)
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
Print this page


To reply to this topic, you need to log in.

© JAQ Software 2024