Strange behaviour in BASIC

Basic and Machine Language

Moderator: Moderators

Post Reply
User avatar
ForgottenGrove
Vic 20 Newbie
Posts: 17
Joined: Sat Jul 30, 2016 10:58 pm
Website: https://t.co/NL8jQVrD8B
Location: Basingstoke, UK
Occupation: CRT gazer & gardener

Strange behaviour in BASIC

Post by ForgottenGrove »

Hello all!

I'm new to the VIC20, so I've been learning the ropes with some basic programming. I've started to write a game and it's got quite lengthy; I haven't quite reached an Out of Memory error, but I have had some strange behaviour...

'Q' has started to appear randomly within my listing; each time I run it a new one appears and replaces a character in a line somewhere!

Could this mean I am approaching the memory limit?

In an effort to save memory, can I do things like remove spaces, combine lines with : etc.?

Finally, is there a way to display the remaining available memory in BASIC?

I understand that I could help my case by learning ML, but I'm stubborn like that :twisted:
the moons of Saturn do bOuNcE and roll relentlessly! (A global ocean beneath the ice encrusted surface of icy moon Enceladus powers them)
Boray
Musical Smurf
Posts: 4064
Joined: Mon May 03, 2004 10:47 am

Re: Strange behaviour in BASIC

Post by Boray »

Maybe you have a poke that accedently pokes into the program space.

Print fre() shows available memory. If you do that after running your program, all variables will still be in memory and you will get the number of bytes you have left to work with. If you want to know the free memory with no variables assigned, then use the clr command to get rid of them first.
PRG Starter - a VICE helper / Vic Software (Boray Gammon, SD2IEC music player, Vic Disk Menu, Tribbles, Mega Omega, How Many 8K etc.)
Boray
Musical Smurf
Posts: 4064
Joined: Mon May 03, 2004 10:47 am

Re: Strange behaviour in BASIC

Post by Boray »

Also read here under out of memory
http://www.boray.se/commodore/optim.html
PRG Starter - a VICE helper / Vic Software (Boray Gammon, SD2IEC music player, Vic Disk Menu, Tribbles, Mega Omega, How Many 8K etc.)
User avatar
ForgottenGrove
Vic 20 Newbie
Posts: 17
Joined: Sat Jul 30, 2016 10:58 pm
Website: https://t.co/NL8jQVrD8B
Location: Basingstoke, UK
Occupation: CRT gazer & gardener

Re: Strange behaviour in BASIC

Post by ForgottenGrove »

Thank you! I have to say, the basic on the vic is really nice to work with.. I'm used to BBC basic and there's some nice things I'm coming across. I do miss PROCedures though!
the moons of Saturn do bOuNcE and roll relentlessly! (A global ocean beneath the ice encrusted surface of icy moon Enceladus powers them)
User avatar
ForgottenGrove
Vic 20 Newbie
Posts: 17
Joined: Sat Jul 30, 2016 10:58 pm
Website: https://t.co/NL8jQVrD8B
Location: Basingstoke, UK
Occupation: CRT gazer & gardener

Re: Strange behaviour in BASIC

Post by ForgottenGrove »

Got it sorted! Here's a YouTube video I did of it https://youtu.be/cDP7vjxpeD4

The game is called bOuNcE and it's a 'collect these things in this time' type...

I've saved it to my SD2IEC; when I can find my USB dongle I'll upload a PRG to the pure basic proggies thread on here ;-)
the moons of Saturn do bOuNcE and roll relentlessly! (A global ocean beneath the ice encrusted surface of icy moon Enceladus powers them)
User avatar
Mayhem
High Bidder
Posts: 3026
Joined: Mon May 24, 2004 7:03 am
Website: http://www.mayhem64.co.uk
Location: London

Re: Strange behaviour in BASIC

Post by Mayhem »

Looks decent :)

Next steps, if you have the space for them, a couple of user defined graphics to replace the ASCII characters used, and alter the refresh on the user ship so that it only re-POKEs back to the screen with an update when the user moves.
Lie with passion and be forever damned...
User avatar
ForgottenGrove
Vic 20 Newbie
Posts: 17
Joined: Sat Jul 30, 2016 10:58 pm
Website: https://t.co/NL8jQVrD8B
Location: Basingstoke, UK
Occupation: CRT gazer & gardener

Re: Strange behaviour in BASIC

Post by ForgottenGrove »

Mayhem wrote:Looks decent :)

Next steps, if you have the space for them, a couple of user defined graphics to replace the ASCII characters used, and alter the refresh on the user ship so that it only re-POKEs back to the screen with an update when the user moves.
Thank you! Those are good next steps.. I need to investigate user defined graphics; on the Electron I simply use a VDU statement to replace one of the empty redifinable chars - not sure about the VIC20!

Yeah, that ship flicker was bugging the hell out of me too ;-)
the moons of Saturn do bOuNcE and roll relentlessly! (A global ocean beneath the ice encrusted surface of icy moon Enceladus powers them)
User avatar
Mike
Herr VC
Posts: 4816
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Re: Strange behaviour in BASIC

Post by Mike »

ForgottenGrove wrote:I need to investigate user defined graphics; [...] - not sure about the VIC20!
You should take a look at my game collection for the unexpanded VIC-20 - at TRON (the 2004 release) in particular.

On the unexpanded VIC-20, UDGs are most often done by reserving the memory of 7168 to 7679 for the screen codes 0..63. The new charset is activated with POKE36869,255. Unfortunately, the codes 64 .. 127 overlap with the text screen and can't be used that easily (you'd have to move the screen base address for that), but you have access to the non-inverted standard ROM characters by PRINTing them with RVS ON.

In TRON, the memory is reserved by POKE55,200:POKE56,29:CLR in line 1. The game only needs 7 UDGs from 57 to 63, the addresses 55 and 56 contain the 16-bit value of RAMTOP: 7168 + 57*8 = 7624 = 200 + 256*29

The UDGs are POKEd into memory in line 31, from DATA contained in the lines 43 to 45 (part of the DATAs in line 45 and the following DATA lines contain POKE values to play the intro tune). POKEV+5,255 (with V=36864) activates the UDGs as mentioned above.
User avatar
ForgottenGrove
Vic 20 Newbie
Posts: 17
Joined: Sat Jul 30, 2016 10:58 pm
Website: https://t.co/NL8jQVrD8B
Location: Basingstoke, UK
Occupation: CRT gazer & gardener

Re: Strange behaviour in BASIC

Post by ForgottenGrove »

^thank you Mike, I will grab the download and have a look!
the moons of Saturn do bOuNcE and roll relentlessly! (A global ocean beneath the ice encrusted surface of icy moon Enceladus powers them)
Post Reply