Hires Graphics

Basic and Machine Language

Moderator: Moderators

User avatar
GreyGhost
Vic 20 Nerd
Posts: 525
Joined: Wed Oct 05, 2005 11:10 pm

Post by GreyGhost »

You have to put a space between the DATA and the -1 or you get a syntax error. Or add it to the end of line 35.
nice little demo.
Rob
User avatar
Mike
Herr VC
Posts: 4816
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Post by Mike »

Strange. My program works without the space. Maybe your tokeniser doesn't translate the '-' sign correctly. Try re-entering the line within the BASIC editor, without the space.

I transferred the program as SEQ file on a *.d64 image, and then ran the following small tool to 'type' it in:

Code: Select all

63995 POKE812,238:OPEN2,8,2,"<program name>,S,R" 
63996 IFST<>0THENPOKE812,239:CLOSE2:END 
63997 PRINT"{CLR}"; 
63998 GET#2,A$:PRINTA$;:IFA$<>CHR$(13)THEN63998 
63999 PRINT"GOTO63996":POKE631,19:POKE632,13:POKE633,13:POKE198,3
This way I'm using BASIC's built-in tokenizer, and that's guaranteed to work. ;)

Michael

P.S.: Thanks for the praise. :)
User avatar
GreyGhost
Vic 20 Nerd
Posts: 525
Joined: Wed Oct 05, 2005 11:10 pm

Post by GreyGhost »

I thought it was odd. I knew I'd seen it done before(-1 by itself in data). I did what you said and just cursored over the line and hit return. It worked fine after that. I copy/pasted the text file with BaseEdit and saved it. So, there might be a little error in BaseEdit. Or might have been me screwing things up again.
Rob
User avatar
Schlowski
NoMess!
Posts: 892
Joined: Tue Jun 08, 2004 12:20 pm

Post by Schlowski »

Error in BasEdit? Never! :roll:

Just tested a simple Basic porgram

Code: Select all

10 DATA-1
and guess what: My BasEdit screwed up the - sign , made $AB instead of $2D out of it.

(Some minutes later)
What the... If used in calculations as A=A-1 the minus is treated as an operator and codes as $AB, but, if used in Data lines it is coded as $2D, i.e. pure ASCII.
Think I have to investigate this further if some other operators like + behave the same way...

Björg

PS: And such an error even after I had coded the complete Videopoker Basic version in BasEdit...
carlsson
Class of '6502
Posts: 5516
Joined: Wed Mar 10, 2004 1:41 am

Post by carlsson »

I encountered a couple of bugs in bastext too. I mailed my friend Peter about it, but while waiting for someone to fix them, I switched to petcat. Can you borrow some tokenizer code from that application in case your own isn't complete?
Anders Carlsson

Image Image Image Image Image
User avatar
Schlowski
NoMess!
Posts: 892
Joined: Tue Jun 08, 2004 12:20 pm

Post by Schlowski »

I could but I won't :-)

I will look into this and try to fix it, this is part of the fun for me... at least I want to be able to say that all bugs belong to me 8)

Björg
carlsson
Class of '6502
Posts: 5516
Joined: Wed Mar 10, 2004 1:41 am

Post by carlsson »

I didn't mean you neccessarily should copy code, only have a look in case there are situations where a different tokenization than you'd expect should be used. For example, dos BasEdit properly handle a colon after a DATA statement, allowing other instructions on the same row?

10 DATA 20,7,-1:A=2:POKE36879,8
Anders Carlsson

Image Image Image Image Image
User avatar
Schlowski
NoMess!
Posts: 892
Joined: Tue Jun 08, 2004 12:20 pm

Post by Schlowski »

Just tested, worked fine beside the known 'minus-bug'. Hex dump of program saved in vice and saved from BasEdit are identical :-)
That's simply because I have no special handling for data lines, which is good for appended commands, but bad for the minus sign...

I'm always astonished to learn such specialities of a very old and (basically) very simple Basic. I think these anomalities are because the interpreter was hand-coded and optimized and not designed by Niklaus Wirth :wink:

More anomalies you want me to check?

Björg

Edit: Just had an idea and proved it: After a DATA statement the tokenizer is off until the next colon (or new line).

Code: Select all

10 DATAPOKE36876,8:POKE36876,8
will not tokenize the first POKE after DATA, but of course the POKE after the colon. Same is valid for my precious '-'. Now I have an idea how to solve this in BasEdit, of course!
carlsson
Class of '6502
Posts: 5516
Joined: Wed Mar 10, 2004 1:41 am

Post by carlsson »

Same goes for +, * and any Basic keyword (like you just figured out). In this manner, DATA and REM operate differently:

DATA does not tokenize any keywords, and graphic symbols outside quotes will be dropped straight away. The part about dropping graphic symbols is true for all other cases of tokenization too.

REM also does not tokenize keywords, but graphic symbols are listed as the Basic keyword their code represents, i.e. REM SHIFT+N lists as REM NEXT.

It is however possible to POKE graphic symbols/keywords into DATA statements afterwards:

10 DATA1
POKE4102,206
LIST
10 DATANEXT
READB$
PRINTB$
(shift+N)
Anders Carlsson

Image Image Image Image Image
User avatar
Mike
Herr VC
Posts: 4816
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Post by Mike »

Schlowski wrote:Edit: Just had an idea and proved it: After a DATA statement the tokenizer is off until the next colon (or new line).

Code: Select all

10 DATAPOKE36876,8:POKE36876,8
will not tokenize the first POKE after DATA, but of course the POKE after the colon. Same is valid for my precious '-'. Now I have an idea how to solve this in BasEdit, of course!
It gets even better, the colon is ignored, i.e. the DATA statement is continued, when it is enclosed in quotes:

Code: Select all

10 DATA"POKE36876,8:POKE36876,8"
...will retain the complete string as plain text.

But a long way from hires graphics... maybe we should continue this discussion in another thread (what a simple DATA-1 statement can do ;) ).

Michael
User avatar
Schlowski
NoMess!
Posts: 892
Joined: Tue Jun 08, 2004 12:20 pm

Post by Schlowski »

Just to finish this:
If I'm not totally wrong, strings in quotes will never be tokenized. What I always find odd is that you can have strings constants in data lines without quotes, for me this is another anomaly.

Björg

PS: Maybe some admin can move these parts covering Basic internals over to "Programming"?
carlsson
Class of '6502
Posts: 5516
Joined: Wed Mar 10, 2004 1:41 am

Post by carlsson »

Ok, so Minigrafik (2) can set up screen, plot points, test points and has custom commands in 326 bytes? The 512 bytes program I posted needs POKEs and SYS, but has a - perhaps poor - routine to draw lines in ML. A fast line drawing algorithm is very useful in a graphic expansion. Flood fill can also be useful, but to a lesser extent. I wonder if it is possible to add a line drawing routine to Minigrafik within 512 bytes?
Anders Carlsson

Image Image Image Image Image
User avatar
Mike
Herr VC
Posts: 4816
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Post by Mike »

Regards speed: I immediately could supply a working 'POKE and SYS' line-routine which does 30000 pixels/second. But I couldn't fit this into <200 Bytes, this routine is more like 1K long. Its speed also rather - uhhm - wasted in a BASIC extension, as the surrounding overhead slows down the apparent speed anyway. More or less any not-so-bad line-routine, Bresenham-style, will do. I think I can pack it into the 186 remaining bytes.

The proposed syntax then would be: @<colour>,<x1>,<y1>TO<x2>,<y2>

Michael
User avatar
Mike
Herr VC
Posts: 4816
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Post by Mike »

I went ahead and added a line-routine. MINIGRAFIK now is 484 Bytes long. The syntax:

Code: Select all

@<colour>,<x1>,<y1>TO<x2>,<y2>: draw line in <colour> between <x1>,<y1> and <x2>,<y2>
Note it is still possible to draw a single point leaving out the 'TO' part, i.e. V3 is fully downwards compatible.

Both endpoints must lie within the screen.

In 'MINIGRAFIK DEMO' the lines 39-44 are now fully redundant, and line 3 can be replaced thus:

Code: Select all

3 READX:IFX<>-1THENREADA,B:@1,X+31,113-ATOX+31,113-B:GOTO3
with a noticeable speed-up.

Here's the loader:

Code: Select all

[BASIC DATA loader deleted]
Edit: MINIGRAFIK V3 is obsolete. Please use V4.02 instead.
Last edited by Mike on Thu Mar 15, 2012 10:11 am, edited 1 time in total.
User avatar
Schlowski
NoMess!
Posts: 892
Joined: Tue Jun 08, 2004 12:20 pm

Post by Schlowski »

For our all conveniance I Cut&Paste'd all sources in BasEdit, saved them and made them available for download:

Minigrafik Version3:
http://www.stojalowski.de/files/minigrafikv3

demo 1 ('Hat')
http://www.stojalowski.de/files/mgrafdemo1

demo 2 ('Mandelbrot')
http://www.stojalowski.de/files/mgrafdemo2

demo 3 ('Minigrafik')
http://www.stojalowski.de/files/mgrafdemo3

Hope this is ok, Mike?

Björg
Post Reply