Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 14:54 02 Jul 2025 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 : dim var as byte

     Page 12 of 16    
Author Message
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 4299
Posted: 09:02pm 11 Aug 2022
Copy link to clipboard 
Print this post

ROFLOL, use the god-damn [Preview Post] button, this has to be a put-up job.



Best wishes,

Tom
MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 7820
Posted: 09:10pm 11 Aug 2022
Copy link to clipboard 
Print this post

You didn't use the CODE brackets properly again. lol
Try this:
Click on the 7th button along, the one with "code" on it.
You'll get
[C0DE][/C0DE]
(the 0 will be a O in both cases. I did this to fool the software)
Put the cursor between them and press Enter. Then put your code between those lines. e.g.

[C0DE]
'This is my code
[/C0DE]

Once again, I've fooled the forum software to show you this. It will actually come out like this when your post is displayed:

'This is my code


--------------------------------------

frame% is a 0 or a 1 depending on which frame is to be displayed.
if it=0 then then it deletes the sprite at the last position and replaces it with sprite 1
if it#s a 1 then it deletes the sprite at the last position and replaces it with sprite 2.

The actual copying of the data is done by the BLIT WRITE commands.

It's just a normal IF - THEN - ELSE command.


TBH it's starting to look as if you have done very little programming, Stan, not in BASIC anyway. I realise that MMBasic isn't the same as other BASICs, but it is similar to a lot of them as most have GWBASIC somewhere in their history. It just has additions for some things - same as all of them do.
Edited 2022-08-12 07:14 by Mixtel90
Mick

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

Guru

Joined: 24/12/2017
Location: Australia
Posts: 1638
Posted: 09:11pm 11 Aug 2022
Copy link to clipboard 
Print this post

stanleyella, Please. If you click on the code button above the box where you enter your post it will put the code begin and end markers in your post for you as shown. Just paste your code between the two markers. Thank you.



You can even get MMEdit to format the code for you but leave that for another day
  Quote  IF frame%=0 THEN'which sprite to draw
 BLIT WRITE 3,oldspx%(temp%),oldspy%(temp%), 16, 16 'erase sprite at last position
 BLIT WRITE 1,spx%(temp%),spy%(temp%), 16, 16 'draw sprite1 at new position
ELSE
 
BLIT WRITE 3,oldspx%(temp%),oldspy%(temp%), 16, 16 'erase sprite at last position
 BLIT WRITE 2,spx%(temp%),spy%(temp%), 16, 16 'draw sprite2 at new position
END IF



Bill
Keep safe. Live long and prosper.
 
stanleyella

Guru

Joined: 25/06/2022
Location: United Kingdom
Posts: 2523
Posted: 10:56pm 11 Aug 2022
Copy link to clipboard 
Print this post

@mixtel90
"TBH it's starting to look as if you have done very little programming, Stan, not in BASIC anyway."

I could resort to sarcasm sir and I just had a beer but

My view is mmbasic and rpipico is a nice system but not for stupid people like me who don't listen to the folk on the forum who have helped me and I don't read the manual.
how did I get those udgs moving as I've
"done very little programming, not in BASIC anyway."
must be mmbasic is so easy to use, even stupid people can use it.
 
stanleyella

Guru

Joined: 25/06/2022
Location: United Kingdom
Posts: 2523
Posted: 11:21pm 11 Aug 2022
Copy link to clipboard 
Print this post

@Turbo46// aka bill? my dads name.
sir not sure what posting code involves.
IF frame%=0 THEN'which sprite to draw
 BLIT WRITE 3,oldspx%(temp%),oldspy%(temp%), 16, 16 'erase sprite at last position
 BLIT WRITE 1,spx%(temp%),spy%(temp%), 16, 16 'draw sprite1 at new position
ELSE
 BLIT WRITE 3,oldspx%(temp%),oldspy%(temp%), 16, 16 'erase sprite at last position
 BLIT WRITE 2,spx%(temp%),spy%(temp%), 16, 16 'draw sprite2 at new position
END IF

if I messed this up shoot me and ban stupid people from using mmbasic... a test before you can download it but if you can unzip it and flash it to rpipico then...
does this matter? no one wants to see a stupid users code anyway
 
stanleyella

Guru

Joined: 25/06/2022
Location: United Kingdom
Posts: 2523
Posted: 11:27pm 11 Aug 2022
Copy link to clipboard 
Print this post

I used code button and pasted between [code][/code]... er what's different to pasting?
I got used to a style of basic... quick consensus, who thinks my basic is carp?
 
Turbo46

Guru

Joined: 24/12/2017
Location: Australia
Posts: 1638
Posted: 11:58pm 11 Aug 2022
Copy link to clipboard 
Print this post

  Quote  er what's different to pasting?

Well it puts the code in a separate box as you can see. There is no confusion on what is code and what is the rest of your post.

If you put:
I tried
OPTION BASE 0        ' 0 based arrays
OPTION EXPLICIT
dim dx%(7),dy%(7),spx%(7),spy%(7)....
and then some other comment, it is harder to separate the wheat from the chaff.

You do want others to read your code so it helps to make it as easy to read as possible.

You can use the Preview Post button below the box where you are entering you code to check if it is formatted as you want.

Your dad has a good name, there are a few of us on the forum.

Bill
Keep safe. Live long and prosper.
 
stanleyella

Guru

Joined: 25/06/2022
Location: United Kingdom
Posts: 2523
Posted: 11:59pm 11 Aug 2022
Copy link to clipboard 
Print this post

As a new user
It's different.
There's some helpful people on the official forum to help you.. CHEERS GUYS  
It's a nice fast free basic that runs on a board that costs £5 free p&p
It's got lots of advanced graphics built in for dials,gauges,etc.
It got touch and lots of features.
this is ili9341 lcd and it's got read the sd card.
it got stupid people can use it.
it got just use usb to load/run from mmedit or directly from a terminal  
it's fun to use imho
 
stanleyella

Guru

Joined: 25/06/2022
Location: United Kingdom
Posts: 2523
Posted: 12:34am 12 Aug 2022
Copy link to clipboard 
Print this post

Having got blit to work...not load sd card files as I no bitmab gen or files yet,.... the world is my oyster er coding.
I am going to try testing my memory and a path for a sprite and delay then next sprite follows 1st sprite and so on until 8 sprites following each other.
lots of other stuff I could redo for mmbasic if there was any interest.
the reason is I think mmbasic and rpipico will be fast. I hope I'm not disappointed.
if all I want is integers and my code didn't do that then please tell me but % after every variable seems to work but I got a telling off for not understanding the excellent manual.
I got to admit the vga stuff looks interesting but then think I got rpi 1,2,3.400 and hdmi to vga or composite adaptors and more vga monitors than you could wave a stick at.
the ili glcd features are what I'm learning cos it's well supported.
 
Turbo46

Guru

Joined: 24/12/2017
Location: Australia
Posts: 1638
Posted: 12:40am 12 Aug 2022
Copy link to clipboard 
Print this post

If you use:
OPTION DEFAULT INTEGER

then, unless you specify otherwise every variable will be an integer. No need for the %.

Bill
Keep safe. Live long and prosper.
 
stanleyella

Guru

Joined: 25/06/2022
Location: United Kingdom
Posts: 2523
Posted: 02:15am 12 Aug 2022
Copy link to clipboard 
Print this post

your right bill
OPTION BASE 0        ' 0 based arrays
option DEFAULT INTEGER
OPTION EXPLICIT
dim dx(7),dy(7),spx(7),spy(7)
dim cannon(119),missile(15),oldspx(7),oldspy(7)
dim ptr,hiscore,spw,spht,temp,frame,frame_count,spdata,sp1

no var% needed. all that dim var as integer stuff was a waste of frustration.
program works
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 7820
Posted: 08:14am 12 Aug 2022
Copy link to clipboard 
Print this post

  stanleyella said  @mixtel90
"TBH it's starting to look as if you have done very little programming, Stan, not in BASIC anyway."

I could resort to sarcasm sir and I just had a beer but

My view is mmbasic and rpipico is a nice system but not for stupid people like me who don't listen to the folk on the forum who have helped me and I don't read the manual.
how did I get those udgs moving as I've
"done very little programming, not in BASIC anyway."
must be mmbasic is so easy to use, even stupid people can use it.


Asking what's happening in a well commented If-Then-Else-Endif construction didn't illustrate your programming skills, I'm afraid. One minute with the manual would have shown you If-Then-Else (which is used in every BASIC I've ever seen except, possibly a version of Tiny BASIC that may not have supported ELSE). Another two minutes would have shown you BLIT WRITE (which, admittedly, is MMBasic specific).

You aren't stupid, I don't believe that for one minute, but you *appear* to ask questions that have their answers in the manual. It may be that, for example, it was a specific part of that question about the If-Then-Else-Endif that you were having difficulty with, but you simply weren't specific enough about *which* part, you just showed the full construction and asked what was going on. That was rather vague information to work from when trying to help.

I could understand the difficulty with [C0DE] as the forum automatically displays commands like that so it's not easy to show how they work. As a new user it takes a little experimentation to see how things work. It may not apply to you, but eventually you may find that the forum can't display non-standard ASCII characters such as the UKP sign. That's just experience.

I would suggest that, if you are having trouble in getting a piece of code to work, you save your program to flash (it's easy to reload it then). Then start again and write a much shorter routine to test out that idea - nothing else in memory. Instead of using, say 256 DATA statements, use 5. Keep it short. Write little test routines if necessary to display information to the console. Then, if you are really stuck, post that short program to the forum for us to look at. Some comments in it might help. Note that this is only a suggestion, but you'll probably get faster results by not asking people to plough through 80 lines of code when 12 would have done.
Mick

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

Guru

Joined: 25/06/2022
Location: United Kingdom
Posts: 2523
Posted: 02:24pm 12 Aug 2022
Copy link to clipboard 
Print this post

@Mixtel90
I didn't have a problem with if-then-else it was adding% to all variables and using
that code for testing [code][/code]. In another basic it's
~
code
~
to post on their forum otherwise it's all giant bold text.
I now realise there's just strings,integers and floats and they don't need dim var as.
I have tried simple code to test using option integer default but also using dim var1,var2,var3 as integer and it gave not defined errors.
The other cause of frustration was mmedit giving errors if I used pixel or cls.
How I was connected to someones server I don't know. Selecting serial and port 13 and suggested baud rate and it worked. So in 2 months use I haven't done much coding that worked. Having sorted my problems it took minutes to get blit working although there must be another way to load the blit buffers than pixel them from data to screen then blit read them. I'll experiment now I can run code without errors.. sigh of relief.
It feels great when something finally works.
I first used basic on a zx81.
I don't use if a=5 and b=6 then as it's 2 tests
I'd use if a=5 then if b=6 then so if 1st test fails it skips 2nd test.
As you pointed out previously rpipico is a 32bit ucntrl NOT an 8bit pic so I got to change my thoughts about using bytes and words and longs.
I've managed for years without floats. Am I right that they are much slower than integers? ok I could write a test but someone probably already has.
 
lizby
Guru

Joined: 17/05/2016
Location: United States
Posts: 3348
Posted: 03:00pm 12 Aug 2022
Copy link to clipboard 
Print this post

  stanleyella said  I have tried simple code to test using option integer default but also using dim var1,var2,var3 as integer and it gave not defined errors.

The order of keywords is critical:

> option integer default
Error : Invalid Option
> option default integer
>

  Quote   . . . using dim var1,var2,var3 as integer and it gave not defined errors.

Not sure how that would have gotten "not defined", but it doesn't make var1, var2 integers:
> dim var1,var2,var3 as integer
> var1=4
> var1=var1/3
> var3=var1
> ?var3,var1
1       1.333333333


  Quote  there must be another way to load the blit buffers than pixel them from data to screen then blit read them.

VegiPete showed you several examples: find or create a BMP file with the appropriate images in the appropriate resolution, LOAD IMAGE fn$, BLIT READ a section of the screen for as many BLIT buffers as you need (up to 8).

BREAKING!: Just posted by matherp: "Max number of BLIT buffers now 32 (memory dependent)" (in latest firmware).

~
Edited 2022-08-13 01:06 by lizby
PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed
 
stanleyella

Guru

Joined: 25/06/2022
Location: United Kingdom
Posts: 2523
Posted: 03:51pm 12 Aug 2022
Copy link to clipboard 
Print this post

vegipetes posts have been helpful as have yours and other folks, ta
BREAKING!: Just posted by matherp: "Max number of BLIT buffers now 32 (memory dependent)" (in latest firmware).
what's memory dependent mean and what is the latest firmware please?
 
stanleyella

Guru

Joined: 25/06/2022
Location: United Kingdom
Posts: 2523
Posted: 04:02pm 12 Aug 2022
Copy link to clipboard 
Print this post

I used blit read 30,x,y,h,w and blit write 30,x,y,h,w
and it works
 
lizby
Guru

Joined: 17/05/2016
Location: United States
Posts: 3348
Posted: 04:17pm 12 Aug 2022
Copy link to clipboard 
Print this post

"memory dependent" means you might be able to have 32 small sprites, but there's not enough memory on the Picomite to have 32 large ones.

Latest is in the PicoMite/PicoMiteVGA V5.07.05 betas thread.
PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed
 
stanleyella

Guru

Joined: 25/06/2022
Location: United Kingdom
Posts: 2523
Posted: 04:26pm 12 Aug 2022
Copy link to clipboard 
Print this post

the blit function is great. it makes moving lots of user defined images easy and fast.
it really is excellent.
 
stanleyella

Guru

Joined: 25/06/2022
Location: United Kingdom
Posts: 2523
Posted: 08:33pm 12 Aug 2022
Copy link to clipboard 
Print this post

16 16x16 udgs demo. not bad, pushing it https://www.youtube.com/watch?v=_zsNK4mZpf8
 
lizby
Guru

Joined: 17/05/2016
Location: United States
Posts: 3348
Posted: 09:45pm 12 Aug 2022
Copy link to clipboard 
Print this post

Nice. Can you post code?
PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed
 
     Page 12 of 16    
Print this page
The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025