CPCWiki forum

General Category => Programming => Topic started by: the777 on 17:40, 02 September 25

Title: is pixel exact printing possible on the cpc 464 in basic?
Post by: the777 on 17:40, 02 September 25
ive had a look at google but cant find anything. i know it was possible on the zx spectrum but difficult. any ideas?

thanks for all your help btw
Title: Re: is pixel exact printing possible on the cpc 464 in basic?
Post by: andycadley on 17:57, 02 September 25
Yes, use TAG to enable "Text at Graphics Cursor" mode and then MOVE to move the graphics cursor to the relevant pixel position. 
Title: Re: is pixel exact printing possible on the cpc 464 in basic?
Post by: eto on 18:56, 02 September 25
Keep in mind that it's slower than the normal PRINT command. 

Btw: Locomotive BASIC is quite powerful but you will not find a lot of great examples with Google unfortunately. I would strongly suggest to read the Amstrad CPCs manual to get an overview of all its commands. It's really a great resource. 

https://www.cpcwiki.eu/manuals/AmstradCPC6128-hypertext-en-Sinewalker.pdf
Title: Re: is pixel exact printing possible on the cpc 464 in basic?
Post by: MoteroV4 on 19:01, 02 September 25
This is a modified example from the CPC6128 manual, to explain interruptions (DI command), but now (besides works in 464), moves a little sprite to the pixel. Hope it help you.
10 MODE 1:TAG
20 EVERY 50 GOSUB 140
30 x1=RND*320: x2=RND*320
40 y=200+RND*200
50 FOR x=320-x1 TO 320+x2 STEP 1
60 DI:'*** disable IRQs to print char
70 MOVE x,y
80 c$=CHR$(ROUND(RND(251)+248))
90 PRINT " ";c$;
100 CALL &BD19:'MC WAIT FLYBACK
110 EI:'*** enable IRQs
120 NEXT
130 GOTO 30
140 '******* sub print shoot
150 MOVE 320,0
160 DRAW x+8,y-16
170 RETURN
Title: Re: is pixel exact printing possible on the cpc 464 in basic?
Post by: the777 on 19:03, 02 September 25
deleted
Title: Re: is pixel exact printing possible on the cpc 464 in basic?
Post by: the777 on 19:05, 02 September 25
Quote from: andycadley on Yesterday at 17:57Yes, use TAG to enable "Text at Graphics Cursor" mode and then MOVE to move the graphics cursor to the relevant pixel position.
this works but it leaves a couple of weird characters next to it
Title: Re: is pixel exact printing possible on the cpc 464 in basic?
Post by: eto on 19:17, 02 September 25
Quote from: the777 on Yesterday at 19:05this works but it leaves a couple of weird characters next to it
add a semicolon at the end of the print statement

10 TAG
20 MOVE 325,202
30 PRINT "x";
Title: Re: is pixel exact printing possible on the cpc 464 in basic?
Post by: the777 on 19:22, 02 September 25
Quote from: eto on Yesterday at 19:17
Quote from: the777 on Yesterday at 19:05this works but it leaves a couple of weird characters next to it
add a semicolon at the end of the print statement

10 TAG
20 MOVE 325,202
30 PRI
i did, it still does it

https://postimg.cc/YvMQVqWf/56eb58d0

https://postimg.cc/WFzLTkdG/e93e9dd3

even if i use print "A"; at line 260

i think it may have something to do with the inkey command because depending on what 1 or 2 arrow key(s) i press, it changes the amount of characters
Title: Re: is pixel exact printing possible on the cpc 464 in basic?
Post by: andycadley on 21:59, 02 September 25
Because line 280 is doing PRINT INKEY(0) without a semicolon, so it is printing new line characters (because TAG mode always prints the character) 
Title: Re: is pixel exact printing possible on the cpc 464 in basic?
Post by: ZorrO on 03:39, 03 September 25
@the777 - Will be little bit faster if you put more command in 1 line, for example:
250 MOVE x,y:TAG:?CHR$(255);  <- to print as sprite after TAG
280 TAGOFF:? INKEY(0)  <-  to print as sign after TAGOFF
or
280 PRINT INKEY(0);  <-  if you want one more sign as sprite, but sign ; is nesesery to disappeare arrows.

I also recommend increasing number of pixels by which sprite moves to speed up its movement.
i.e. x=x+2 and y=y-2 etc. instead of x=x+1 and y=y-1 etc.  or even try 4 instead of 2.

If you don't want sprite to leave a trail, you need to delete it in its old position before displaying it in new one. Unfortunately, a side effect is that sprite blinks.

Download this DSK below, and try GUI.BAS with sprite arrow pointer 100% Basic.
Or GUI2.BAS if you don't have joystick (move pointer by F1,F2,F3,F5). 
Pretty fast for Basic, is it? :)
Powered by SMFPacks Menu Editor Mod