FAQ  •  Register  •  Login

CHR or CHR$ crashing running Spectrum

<<

Luzie

Posts: 32

Joined: Thu Nov 05, 2015 9:11 pm

Post Thu Nov 05, 2015 9:32 pm

CHR or CHR$ crashing running Spectrum

Hi,

I do my first steps into ZX Basic and found this crashing
e.g. X128 Spectrum Emulator when I compile this an run it:

FOR A=0 TO 255
PRINT CHR$ (PEEK(A));
NEXT A

Seems printing some CHR$ is like sending some control codes ...
Can work around this when I just use "printable" Characters above e.g. > CHR$ 32 and < CHR$ 127

And just le me say: I love your ZX Basic !
<<

boriel

Site Admin

Posts: 1463

Joined: Wed Nov 01, 2006 6:18 pm

Location: Santa Cruz de Tenerife, Spain

Post Sun Nov 22, 2015 12:38 pm

Re: CHR or CHR$ crashing running Spectrum

Yes, it crash the print routine. Thanks, will check for it. :roll:
Also, using basic returns an K Invalid Colour error.
You can use control color codes as with normal PRINT, since it saves memory and can, sometimes, be faster than INK, FLASH, etc.
So color codes can be useful.
<<

Luzie

Posts: 32

Joined: Thu Nov 05, 2015 9:11 pm

Post Mon Jan 09, 2017 9:37 pm

Re: CHR or CHR$ crashing running Spectrum

Can I please come back to this and ask if you can have a look at it?

Trying further I discover strangely that running the resulting code on different Spectrum-Emulators (SpecEmu, Fuse)
displays different results on crashing. But this maybe have to do with different Hardware-Addons selected in Emulators.

Which emulator do you use for testing?

Also, PRINT not seems to be very fast. Do you know of a way to maybe speed this up?
E.g. with a PRINT function that prints "without colours or so"?
Update: I will give the printing routine from:
https://wos.meulie.net/pub/sinclair/boo ... nguage.pdf
a try, if this can speed something further up for me.

On the WIKI http://www.boriel.com/wiki/en/index.php ... rint42.bas
I maybe find a typo: I think the example should read "print42(STRING)" instead of "printat42(STRING)".
There maybe also the same typo on the Print64-Wiki-Page: http://www.boriel.com/wiki/en/index.php ... rint64.bas
<<

britlion

Posts: 766

Joined: Mon Apr 27, 2009 7:26 pm

Location: Slough, Berkshire, UK

Post Sun Jan 15, 2017 10:54 am

Re: CHR or CHR$ crashing running Spectrum

The library ( http://www.boriel.com/wiki/en/index.php ... ng_Library ) has putchars ( http://www.boriel.com/wiki/en/index.php ... tchars.bas ), which can drop a single character to the screen as well. It doesn't deal with attributes, which would require a separate function ( like, say http://www.boriel.com/wiki/en/index.php ... indowPaint ) to do that.

The downside is you have to point it at the data to print on the screen - though there's no reason this can't come from the ROM character table, based on the character set system variable address. You could make a wrapper function that calculates all the numbers and uses puchars at the core.

Or of course write a new fastprint function, perhaps using screen tables ( how-to-tutorials/topic493.html ) , and add it to the library?

By the way the fastest you are going to get is a method like http://www.boriel.com/wiki/en/index.php ... IC:PutTile
- but this does require a 2 character wide set of data to drop the screen as it uses push and pop to pull 16 bits at a time.
<<

Luzie

Posts: 32

Joined: Thu Nov 05, 2015 9:11 pm

Post Sun Jan 15, 2017 11:20 am

Re: CHR or CHR$ crashing running Spectrum

britlion wrote:The library ( http://www.boriel.com/wiki/en/index.php ... ng_Library ) has putchars ( http://www.boriel.com/wiki/en/index.php ... tchars.bas ), which can drop a single character to the screen as well. It doesn't deal with attributes, which would require a separate function ( like, say http://www.boriel.com/wiki/en/index.php ... indowPaint ) to do that.
...

Thanks for your suggestions, I´ll have a try with putchars as my next attempts!

Return to Bug Reports

Who is online

Users browsing this forum: No registered users and 2 guests

cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by Vjacheslav Trushkin for Free Forums/DivisionCore.

phpBB SEO