News:

Printed Amstrad Addict magazine announced, check it out here!

Main Menu
avatar_AMSDOS

Silly Programming Ideas - Turning Text into Graphics

Started by AMSDOS, 11:43, 23 November 10

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

AMSDOS

I remember posting this program on the CPCZone boards a few years ago, at the time I asked if anyone had tried anything simular, the reply I recall was Character Matrices is simular. Character Matrices indeed though has some function about it though and it's much faster because it's not redefining as many characters as well as offerening a multicoloured sprite.

In my example below, it's not really defining a true sprite, at least not in the sense of an object which is defined as a true character and it's not really designed to be moved around like a proper sprite. In short the program below is designed to draw up the 64 points of the Text Cursor and using Transparent Mode, plot each one of those points and use a colour to represent each of those points, thus creating what looks like a sprite!

Originally the main purpose to all of this was to see if it could be done, and now it's been done I've had nearly zero ideas for it. I was looking to covert it to Pascal though have various changes done with this original program to perhaps make it slightly faster, in a way it's kind of made it a programming game because I'm trying to incorporate more arrays into it!  :)
In some regards I thought it could make for a really crude way of making Sprites with it, by using an array as the editor for the object and then displaying and converting it back into another array as the sprite values!  :)  Otherwise it's a nice crude way of doing graphics which I guess could be larger than a typical sprite, though not worth capturing it as a screen. This example below is 8x8, though I made a larger version using the same principals!  :)

Anyway I'll comment more when I can about the program below, it kind of speaks for itself I guess!  ;D

10 SYMBOL AFTER 32: char=33
20 L=1:WHILE (L<>9)
30 GOSUB 1000
40 FOR m=1 to 8
50 SYMBOL char,v1,v2,v3,v4,v5,v6,v7,v8
60 char=char+1
70 GOSUB 1100
80 NEXT m
90 L=L+1
100 WEND
110 RUN 2000
1000 IF L=1 THEN v1=128:v2=0:v3=0:v4=0:v5=0:v6=0:v7=0:v8=0
1010 IF L=2 THEN v2=128:v1=0
1020 IF L=3 THEN v3=128:v2=0
1030 IF L=4 THEN v4=128:v3=0
1040 IF L=5 THEN v5=128:v4=0
1050 IF L=6 THEN v6=128:v5=0
1060 IF L=7 THEN v7=128:v6=0
1070 IF L=8 THEN v8=128:v7=0
1080 RETURN
1100 IF L=1 THEN v1=v1/2
1110 IF L=2 THEN v2=v2/2
1120 IF L=3 THEN v3=v3/2
1130 IF L=4 THEN v4=v4/2
1140 IF L=5 THEN v5=v5/2
1150 IF L=6 THEN v6=v6/2
1160 IF L=7 THEN v7=v7/2
1170 IF L=8 THEN v8=v8/2
1180 RETURN
2000 MODE 0:GOSUB 3000:x=10:y=10:GOSUB 2500
2010 GOSUB 2100
2020 x=11:y=10:GOSUB 2500
2030 GOSUB 2100
2040 SYMBOL AFTER 32:PEN 1:MODE 2:END
2100 WHILE INKEY$<>CHR$(13):WEND:RETURN
2500 BORDER 0:INK 1,26:INK 0,0:INK 2,2:INK 3,11:INK 4,25:num=33
2510 n2=1:WHILE n2<>65
2520 GOSUB 4000
2530 WEND
2540 RETURN
3000 DIM o(64):FOR n=1 to 64:READ o(n):NEXT n:RETURN
3010 DATA 1,0,0,0,0,0,0,1
3020 DATA 2,1,1,1,1,1,1,2
3030 DATA 2,3,3,4,4,4,3,2
3040 DATA 2,3,3,4,3,3,3,2
3050 DATA 2,3,4,4,4,3,3,2
3060 DATA 2,3,3,4,3,3,3,2
3070 DATA 2,3,4,4,4,4,3,2
3080 DATA 0,2,2,2,2,2,2,0
4000 PEN o(n2):LOCATE x,y:PRINT CHR$(22);CHR$(1)+CHR$(num):num=num+1:n2=n2+1:RETURN
* Using the old Amstrad Languages :D * And create my own ;)
* Incorporating the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

ervin

Hi there.

Interesting idea. Could this sort of thing come in handy for score panels or something like that?

By the way, copying the code from your post causes the carriage returns to be dropped, so getting it into notepad or winape etc. is problematic.

Anyway, here is the code pasted directly into my reply. This should be copyable with all carriage returns intact:

10 SYMBOL AFTER 32: char=33
20 L=1:WHILE (L<>9)
30 GOSUB 1000
40 FOR m=1 to 8
50 SYMBOL char,v1,v2,v3,v4,v5,v6,v7,v8
60 char=char+1
70 GOSUB 1100
80 NEXT m
90 L=L+1
100 WEND
110 RUN 2000
1000 IF L=1 THEN v1=128:v2=0:v3=0:v4=0:v5=0:v6=0:v7=0:v8=0
1010 IF L=2 THEN v2=128:v1=0
1020 IF L=3 THEN v3=128:v2=0
1030 IF L=4 THEN v4=128:v3=0
1040 IF L=5 THEN v5=128:v4=0
1050 IF L=6 THEN v6=128:v5=0
1060 IF L=7 THEN v7=128:v6=0
1070 IF L=8 THEN v8=128:v7=0
1080 RETURN
1100 IF L=1 THEN v1=v1/2
1110 IF L=2 THEN v2=v2/2
1120 IF L=3 THEN v3=v3/2
1130 IF L=4 THEN v4=v4/2
1140 IF L=5 THEN v5=v5/2
1150 IF L=6 THEN v6=v6/2
1160 IF L=7 THEN v7=v7/2
1170 IF L=8 THEN v8=v8/2
1180 RETURN
2000 MODE 0:GOSUB 3000:x=10:y=10:GOSUB 2500
2010 GOSUB 2100
2020 x=11:y=10:GOSUB 2500
2030 GOSUB 2100
2040 SYMBOL AFTER 32:PEN 1:MODE 2:END
2100 WHILE INKEY$<>CHR$(13):WEND:RETURN
2500 BORDER 0:INK 1,26:INK 0,0:INK 2,2:INK 3,11:INK 4,25:num=33
2510 n2=1:WHILE n2<>65
2520 GOSUB 4000
2530 WEND
2540 RETURN
3000 DIM o(64):FOR n=1 to 64:READ o(n):NEXT n:RETURN
3010 DATA 1,0,0,0,0,0,0,1
3020 DATA 2,1,1,1,1,1,1,2
3030 DATA 2,3,3,4,4,4,3,2
3040 DATA 2,3,3,4,3,3,3,2
3050 DATA 2,3,4,4,4,3,3,2
3060 DATA 2,3,3,4,3,3,3,2
3070 DATA 2,3,4,4,4,4,3,2
3080 DATA 0,2,2,2,2,2,2,0
4000 PEN o(n2):LOCATE x,y:PRINT CHR$(22);CHR$(1)+CHR$(num):num=num+1:n2=n2+1:RETURN

Gryzor


Devilmarkus

Quote from: ervin on 23:30, 23 November 10
By the way, copying the code from your post causes the carriage returns to be dropped, so getting it into notepad or winape etc. is problematic.

Hmmm I tried it in JavaCPC (copied the code and paste with F11 into JavaCPC screen).
There it worked good.
When you put your ear on a hot stove, you can smell how stupid you are ...

Amstrad CPC games in your webbrowser

JavaCPC Desktop Full Release

redbox

Quote from: Gryzor on 11:48, 24 November 10
Screenie? :)

Not much to look at, more a proof of (a weird!) concept.  Interesting to see though CP/M User!

Gryzor


AMSDOS

ervin wrote:

Hi there.

Interesting idea. Could this sort of thing come in handy for score panels or something like that?



There maybe a number of applications one could apply this in, even if you wanted to have it to simply draw something to screen and then grabbing that image for the purpose of making a sprite you could, I seem to recall something like that in Sean McManus' Easi-Sprite Driver program.

I think the only problem with this method (excluding execution speed), is once you start making larger images (and I'll be posting an example of that soon), you have to work out where everything goes. Naturally the array gets bigger and while it's straightfoward plotting the 64 points of the text cursor in one position, I found the best way to setup the array is to work in that 8x8 context, which means working out the position is relevant to which portion! (It'll all become clear when I post the second program  ;D ). In the end it's probably easier to have an larger array and plot the contents of that array to screen. That was the approach I applied in my original BOUNCY.PAS program which has an array with the information for the Ball in it and using a routine to plot that array to screen. As it demonstrates though it's not really designed for moving things around though. But for Graphical fixtures it would work quite well.

By the way, copying the code from your post causes the carriage returns to be dropped, so getting it into notepad or winape etc. is problematic.

Yes unfortunately I like to use Code to make it appear friendly and code like, the only way I know around this problem is to click Quote on the post with the Code in it, and in the Edit box, copy the program from that and paste that into whatever!
* Using the old Amstrad Languages :D * And create my own ;)
* Incorporating the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

AMSDOS

Gryzor wrote:

Ooh! Nice pound symbol :D

There should be two!  ;)

* Using the old Amstrad Languages :D * And create my own ;)
* Incorporating the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

AMSDOS

Okay so how does this program I posted work.

The seemly clever bit of the program is the initial setup phase, I've done the initial symbol after 32 and told where to start redefining which is "char" set to 33 - explanation mark(!)  ;D 

The second line (20) "L" represents the Line, this is set to 1 - I then setup a Loop ("WHILE L<>9") which checks to see if L has reached 9.

Line 30 simply goes to a Subroutine - this can be significantly improved with a statement like "ON L GOSUB 1000,1010,1020,etc" because the Subroutine represents what's in L.

Line 40 Starts another Loop - this one is used to represent the bit points in the symbol, in this part it becomes more confusing, so I'll explain further. Picture a 8x8 square grid, for each line there is 8 square boxes, this loop is here to address each of those boxes, as opposed to the While which works on each line, which ensures that all 64 squares are covered with a pixel!  ;D

Line 50 deals with defining all those pixels. earlier I set char to 33 which is where it starts redefining, all the "v" variables from 1 to 8 are there to represent the line - because I'm doing 1 line at a time, 7 of those variables must be set to 0, the subroutine from 1000 to 1080 deals with this by determining which line is being redefined the value for the left most pixel.

Line 60 Increments the character number so no overwriting is happening.

Line 70 goes a second subroutine, again like the first "ON L GOSUB ...." could have been used to speed up the process. This subroutine divides the value by half, so the theory here (which works) is Left Most Pixel Position is 128 as setup in the first subroutine, and second pixel position is 64, the 3rd is 32, 4th is 16, 5th is 8, 6th equals 4, 7th has 2 and the 8th has 1.

Line 80 Simply exits the FOR loop from Line 40 once the 8th position has been dealt with.

Line 90 Increments "L" so it's pointing to the next line

Line 100 Defines where the WHILE statement ends. To which it'll go back and check to see if "L" is not equal to 9 and to which it will run through the whole process again for redefining the next line.

Line 110 Simply takes it to the next phase of the program to draw the image!  ;D

The next parts of the program are two huge subroutines the first being defined from 1000-1080 and the second from 1100-1180, do they make sense cause I've sort of explained them, but anyway!  ;D

One line should be enough to explain:

Line 1000 being the most important cause it needs to tell 7 of the "v" variables to be 0, this is important because we only plotting one pixel in each character, this is done to ensure we get a sprite like image. The line which is worked on gets set to 128, this is because 128 equals the Left Most Pixel in the matrix, so Line 1, Row 1, Row 2, Row 3, etc, equals 128. Earlier I said the initial GOSUB 1000 in line 30 could be improved to read something like "ON L GOSUB 1000,1010,1020, etc" if that were the case then "IF" statements wouldn't be required because it's going straight to the relevant line, it would just need a RETURN at the end of each statement! 

Line 1100 takes the value which is being worked on and divides it by 2, so if v1 contains 128 as set in Line 1000 and is the variable being worked on, then Line 1100 will divide that so it becomes 64, this as I explained earlier is because the next pixel along equals 64 and then it will come back and do the 3rd, 4th, 5th, 6th, 7th & 8th spots. So that effectively completes the first line!  :)  Again like the first subroutine, if I'd used something like "ON L GOSUB" I wouldn't have required the "IF" statements!  :)

I call this bit the clever bit even though it can be improved on cause it's not doing this:


SYMBOL AFTER 32
SYMBOL 33,128,0,0,0,0,0,0,0
SYMBOL 34,64,0,0,0,0,0,0,0
SYMBOL 35,32,0,0,0,0,0,0,0
SYMBOL 36,16,0,0,0,0,0,0,0
SYMBOL 37,8,0,0,0,0,0,0,0
SYMBOL 38,4,0,0,0,0,0,0,0
SYMBOL 39,2,0,0,0,0,0,0,0
SYMBOL 40,1,0,0,0,0,0,0,0
* Using the old Amstrad Languages :D * And create my own ;)
* Incorporating the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

AMSDOS

So with all the pixels defined and ready to go, the next part of the program deals with using them and displaying an colourful image.

2000 - deals with going to another subroutine (line 3000) which sets up the data for the image into an array, followed by setting up some Text-Based Co-ordinates to display the image, then going to another routine at 2500 which works over those points.

2010 - Simply calls a routine at 2100 which waits for a "Enter" or "Return" .

2020 - Bit like 2000 in that it sets up another position to draw another set of characters and then going through the subroutine to go through the whole process.

2030 - Same as 2010.

2040 - This line Resets everything - the character table, pen, mode and finally exits.

2100 - Simply checks if "Enter" or "Return" has been pressed before continuing!  ;D

2500 - 2540 - Line 2500 is somewhat misleading because it's setting up screen inks and borders, this should have been in Line 2000!  ;D  The num equals 33 is important though as it represents the start of our first pixel.  :)  Another variable "n2" is setup and set as 1, a loop is then generated to check and see if this is not equal to 65, as long as it's not equal to 65, the loop will proceed, continuing to Line 4000 which is the line which does all the displaying and positioning of the character. It is there where num is incremented, and the loop number "n2" is also incremented before returning to the loop.

3000 - 3080 - Line 3000 simply sets up the data in the following 8 lines and puts them into an array called "o". The array "o" has 64 positions to cater of each position from that 8x8 grid found in the text cursor.

4000 - Starts by placing the colour from the position of the array into the pen, it then proceeds by placing the x and y variables (as given earlier in lines 2000 and 2020) into a text co-ordinate position, followed by print it out in transparent mode - transparent mode is obtained by initating it with "chr$(22);chr$(1)+chr$(num)" - transparent mode is important because here I'm writing over one spot continously, naturally if you changed this to "chr$(22);chr$(0)+chr$(num)" the pixels would overwrite themselves and you'd be left with the last pixel at the bottom on show!  :)  "chr$(1)" which proceeds "chr$(22)" enables the program to go into transparent mode and that way each pixel from the redefined routine will be on display. The last "chr$(num)" represents the character to show in this case it starts at 33, and gets incremented to follow the redefined symbols which have been created - as show with "num=num+1" and the program then increments the value for the loop from line 2510 by adding 1 to "n2".

Pretty much sums it up.  Unfortunately the followup program which allows larger images may take more explaining!  :-[
* Using the old Amstrad Languages :D * And create my own ;)
* Incorporating the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

AMSDOS

This is what happens in my followup code when you try to make things bigger when you try demonstrating redefined pixels to generate sprite like graphics!  ;D  Of course by this point I've taken what I knew was a silly idea and made it bigger by using bigger graphics, I think what encouraged me to do such a thing at the time was pure curiosity to see what the code would look like. Indeed though there are probably numerous ways one would achieve something like this and it dawned upon me when I posted the original program that there maybe a type-in out there which demonstrates the same sort of thing!  ;D  The result will look something like shown in my signature!  ;)

10 SYMBOL AFTER 32:char=33
20 l=1:WHILE (l<>9)
30 GOSUB 120
40 FOR m=1 TO 8
50 SYMBOL char,v1,v2,v3,v4,v5,v6,v7,v8
60 char=char+1
70 GOSUB 210
80 NEXT m
90 l=l+1
100 WEND
110 RUN 2000
120 IF l=1 THEN v1=128:v2=0:v3=0:v4=0:v5=0:v6=0:v7=0:v8=0
130 IF l=2 THEN v2=128:v1=0
140 IF l=3 THEN v3=128:v2=0
150 IF l=4 THEN v4=128:v3=0
160 IF l=5 THEN v5=128:v4=0
170 IF l=6 THEN v6=128:v5=0
180 IF l=7 THEN v7=128:v6=0
190 IF l=8 THEN v8=128:v7=0
200 RETURN
210 IF l=1 THEN v1=v1/2
220 IF l=2 THEN v2=v2/2
230 IF l=3 THEN v3=v3/2
240 IF l=4 THEN v4=v4/2
250 IF l=5 THEN v5=v5/2
260 IF l=6 THEN v6=v6/2
270 IF l=7 THEN v7=v7/2
280 IF l=8 THEN v8=v8/2
290 RETURN
2000 MODE 0:GOSUB 3000:x=10:y=10:n=193:n2=1:mv=65:GOSUB 2500
2010 x=10:y=11:n=257:n2=65:mv=129:GOSUB 2500
2020 x=10:y=12:n=321:n2=129:mv=193:GOSUB 2500
2030 GOSUB 2100
2040 SYMBOL AFTER 32:PEN 1:MODE 2:END
2100 WHILE INKEY$<>CHR$(13):WEND:RETURN
2500 BORDER 0:INK 1,26:INK 0,0:INK 7,2:INK 6,1:INK 4,3:INK 8,4:INK 9,16:num=33
2510 WHILE n2<>mv
2520 GOSUB 4000
2530 WEND
2540 RETURN
3000 DIM o(384):FOR n=1 TO 384:READ o(n):NEXT n:RETURN
3010 DATA 0,4,4,4,4,4,4,0
3020 DATA 0,4,4,4,4,4,4,4
3030 DATA 0,4,4,4,4,4,4,9
3040 DATA 4,4,4,4,4,4,4,9
3050 DATA 4,4,4,4,4,4,9,9
3060 DATA 4,4,4,4,1,0,9,0
3070 DATA 4,9,4,9,1,0,9,0
3080 DATA 0,9,4,9,1,0,9,0
3090 DATA 0,9,9,9,1,0,9,0
3100 DATA 0,4,9,9,1,1,9,1
3110 DATA 0,4,9,9,9,1,9,1
3120 DATA 0,4,9,9,9,9,9,9
3130 DATA 0,7,4,9,9,9,0,9
3140 DATA 7,7,7,9,9,9,9,9
3150 DATA 7,7,7,8,7,7,7,8
3160 DATA 7,7,9,8,7,7,7,8
3170 DATA 7,9,9,9,8,8,8,8
3180 DATA 0,9,9,8,6,1,6,1
3190 DATA 0,8,8,8,8,6,6,6
3200 DATA 0,8,8,8,8,8,8,8
3210 DATA 0,4,6,6,6,0,6,6
3220 DATA 0,4,4,4,4,0,4,4
3230 DATA 0,0,0,0,0,0,0,0
3240 DATA 0,0,0,0,0,0,0,0
3250 DATA 0,0,0,0,0,0,0,0
3260 DATA 4,4,0,0,0,0,0,0
3270 DATA 4,4,0,0,0,0,0,0
3280 DATA 4,4,0,0,0,0,0,0
3290 DATA 9,4,4,0,0,0,0,0
3300 DATA 1,4,4,0,0,0,0,0
3310 DATA 1,4,4,0,0,0,0,0
3320 DATA 1,4,4,0,0,0,0,0
3330 DATA 1,4,0,0,0,0,0,0
3340 DATA 9,9,0,0,0,0,0,0
3350 DATA 9,9,0,0,0,0,0,0
3360 DATA 9,9,0,0,0,0,0,0
3370 DATA 9,9,0,0,0,0,0,0
3380 DATA 9,8,0,0,0,0,0,0
3390 DATA 7,8,0,0,0,0,0,0
3400 DATA 9,9,0,0,0,0,0,0
3410 DATA 9,9,0,0,0,0,0,0
3420 DATA 8,9,0,0,0,0,0,0
3430 DATA 6,8,0,0,0,0,0,0
3440 DATA 8,8,8,0,0,0,0,0
3450 DATA 6,6,4,0,0,0,0,0
3460 DATA 4,4,4,0,0,0,0,0
3470 DATA 0,0,0,0,0,0,0,0
3480 DATA 0,0,0,0,0,0,0,0
4000 PEN o(n2):LOCATE x,y:PRINT CHR$(22);CHR$(1)+CHR$(num):PEN o(n): LOCATE x+1,y:PRINT CHR$(num):num=num+1:n2=n2+1:n=n+1:RETURN
* Using the old Amstrad Languages :D * And create my own ;)
* Incorporating the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

AMSDOS

Going back to what I did with the first program I posted in here, here's what it would look like when I use the plotting feature:

10 MODE 0:BORDER 0:INK 1,26:INK 0,0:INK 2,2:INK 3,11:INK 4,25
20 GOSUB 3000
30 x=100:y=100:p=1
40 WHILE p<>65
50 WHILE x<>132
60 PLOT x,y,o(p):p=p+1:x=x+4
70 WEND
80 x=100:y=y-2
90 WEND
100 WHILE INKEY$<>CHR$(13):WEND:MODE 2:END
3000 DIM o(64):FOR n=1 TO 64:READ o(n):NEXT n:RETURN
3010 DATA 1,0,0,0,0,0,0,1
3020 DATA 2,1,1,1,1,1,1,2
3030 DATA 2,3,3,4,4,4,3,2
3040 DATA 2,3,3,4,3,3,3,2
3050 DATA 2,3,4,4,4,3,3,2
3060 DATA 2,3,3,4,3,3,3,2
3070 DATA 2,3,4,4,4,4,3,2
3080 DATA 0,2,2,2,2,2,2,0


Naturally when dealing with Graphics you have to deal with plotting positions based on the mode being used - so with this example it's in MODE 0, so every pixel is 4 columns along, 2 rows down - well that's what I've got to get the effect right. Also I have a nested loop, in my Pascal BOUNCY.PAS I used one loop which dealt with the length of the array which is a bit like what I've got here, though have used a second loop based on X which resets once the loop is reached, and moves to the next row. Maybe somewhat faster than what I'm currently used in my Pascal example.

But it just shows how much easier or shorter when things are done graphically!  ;D
* Using the old Amstrad Languages :D * And create my own ;)
* Incorporating the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

AMSDOS

#12
INK Animation seems to be something the CPC is very good at (even in BASIC), in the past I've seen some interesting demos which simply alternate between colours to make it appear as if movement is happening, usually a whole series of drawing is first applied & usually it's done in MODE 0 so you get 16 colours (or 15 if you're not alternating ink 0), once the drawing is complete the ink animation begins, some of that can be found within the AA Type-ins section on CPC-Wiki and lots of 10-liners have also been made using this process.

What I've done though is a little bit different (has possibly been done before with better effect) though this is real bizarre idea of having two tiny objects with 2 colours animating between one and the other in mode 1. In this example there's a hint that BASIC maybe a tad slow and that using the Firmware and Assembly would eliminate that (can anyone see why?  :) ). Otherwise the Animation switch is pretty good.

So in this program below I can move between 2 objects which have 2 colours each, both of these images uses the same colour and yet to make it seem like their different I came up with this program  :-[ :

10 MODE 1:WHILE 1
20 GOSUB 100
30 FOR delay=1 TO 500:NEXT
40 GOSUB 130
50 FOR delay=1 TO 500:NEXT
60 WEND
100 INK 0,1:PAPER 0:CLS:INK 1,26:INK 2,2:INK 3,0
110 PLOT 100,100,1:PLOT 98,98,2:PLOT 100,98,2:PLOT 102,98,2
120 RETURN
130 INK 1,1:PAPER 1:CLS:INK 0,26:INK 3,6:INK 2,1
140 PLOT 200,200,0:PLOT 198,198,3:PLOT 200,198,3:PLOT 202,198,3
150 RETURN


To make this program seem useful in MODE 1, one simply doesn't have the resources to alternate between colours like one would in MODE 0, in MODE 0 flicking between animations to make it appear something is happening, multi-coloured objects can utilise the various inks and then do a swap by turning a bunch of inks off and turning another set on. In MODE 1 the process is similar with regard to certain inks (2 in this example are being turned on and off when required), though to make a 2 coloured object appear at different intervals some variation process needs to occur. My program above gets around this by changing what is the background, so for each object, the paper switches backward and forward, with that I need to change the ink so it appears the background appears in the same colour and unfortunately I need to clear the screen to retain it otherwise I'd give away how the thing works!  ;D  It's not much to look at, though using this approach it allows for simple two object animations to be done in two colours in MODE 1. The effect as well is quite smooth and with the aid of another languages, larger images could be applied!  ;D
* Using the old Amstrad Languages :D * And create my own ;)
* Incorporating the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

AMSDOS

This is perhaps the easiest way I can think of with regard to producing an scrolling effect and indeed it seems to work.
At the moment it's simply a bunch of screen addresses followed by LDIR - 15 of them which moves the line 15 lines down. Just to test the whole effect I'm plotting a series of dots near the top of the screen (not at the top cause the scroll routine will smear those pixels down), when this is appllied I can call the Scrolling routine which will move those dots down the screen, making it appear as if your moving through a starfield.
After having a few thoughts about this over the last couple of days, I'm wondering how effective that scrolling method would go in a loop with a couple of pointers pointing to the addresses of where the screen is and where it has to go. The third paramater (BC) which is the length across is basically a constant.
* Using the old Amstrad Languages :D * And create my own ;)
* Incorporating the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

MacDeath

QuoteTurning Text into Graphics
Good, you just re-invented ASCII art.
:D

AMSDOS

Quote from: MacDeath on 13:00, 01 May 11
Good, you just re-invented ASCII art.
:D

Just the kind of thing those Amstrad Magazines would have knocked back!  :laugh:  Though I can only imagine that since the ones I read were long gone when I wrote that program.
One has to wonder though what sort of Type-ins were being knocked back when they were at their peak though? Towards the closing of AA for example I heard they were getting a lot of Disc Utilities!  ;D 
On ESP I came across this huge Fleaz program which could perhaps go under this category (it's in English too!!)  ;D 
* Using the old Amstrad Languages :D * And create my own ;)
* Incorporating the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

AMSDOS

Quote from: CP/M User on 10:20, 28 November 10
Going back to what I did with the first program I posted in here, here's what it would look like when I use the plotting feature:

10 MODE 0:BORDER 0:INK 1,26:INK 0,0:INK 2,2:INK 3,11:INK 4,25
20 GOSUB 3000
30 x=100:y=100:p=1
40 WHILE p<>65
50 WHILE x<>132
60 PLOT x,y,o(p):p=p+1:x=x+4
70 WEND
80 x=100:y=y-2
90 WEND
100 WHILE INKEY$<>CHR$(13):WEND:MODE 2:END
3000 DIM o(64):FOR n=1 TO 64:READ o(n):NEXT n:RETURN
3010 DATA 1,0,0,0,0,0,0,1
3020 DATA 2,1,1,1,1,1,1,2
3030 DATA 2,3,3,4,4,4,3,2
3040 DATA 2,3,3,4,3,3,3,2
3050 DATA 2,3,4,4,4,3,3,2
3060 DATA 2,3,3,4,3,3,3,2
3070 DATA 2,3,4,4,4,4,3,2
3080 DATA 0,2,2,2,2,2,2,0

From this example I posted in November last year in BASIC, I've come up with some Assembly equivalents using the firmware, the first example is similar to this BASIC example above:

org &4000
ld a,1     
call &bc0e    ;; Set Screen Mode 1

ld hl,data_colour   ;; Address of Data Colour
ld (addrcolour),hl   ;; Place this into Address Colour

.loop
ld hl,(addrcolour)   ;; Place Contents of Address Colour into HL
ld a,(hl)    ;; Put Contents of HL into A
call do_colour

ld de,(xpos)    ;; XPOS data into DE
ld hl,(ypos)    ;; YPOS data into HL
call &bbea    ;; GRA ABSOLUTE PLOT

ld hl,(xpos)    ;; Obtain Contents of XPOS
inc hl     ;; Is 16bit Value so Increment 
inc hl     ;; Twice
ld (xpos),hl    ;; Place next value into XPOS

ld a,(fcount)    ;; First Counter Position into A
inc a     ;; Increment this 
ld (fcount),a    ;; Put New Value into First Count Position
ld b,a     ;; Put this value into B

ld a,(xlcount)    ;; Place First Counter Marker into A

cp b     ;; Has value of B reached A value
jr nz,loop    ;; If No Loop back, otherwise continue

ld a,(fcount)    ;; At this stage fcount equals 8
xor a     ;; This will make it 0 again
ld (fcount),a    ;; And put that value into fcount

ld hl,(ypos)    ;; YPOS of data can now be Incremented
inc hl     ;; Again 16bit Value means Incrementing
inc hl     ;; it Twice
ld (ypos),hl    ;; And put that value into YPOS.

ld a,(xpos)    ;; Value of XPOS needs to return back to where it was.
sub 16     ;; Subtracting 16 will resolve this.
ld (xpos),a    ;; New Value goes into XPOS.

ld a,(scount)    ;; Second counter goes into A
inc a     ;; Increase it.
ld (scount),a    ;; Place back into Second Counter
ld b,a     ;; Put value of Second counter into B

ld a,(ylcount)    ;; Place Y-counting position into A

cp b     ;; Compare A to value of B
jr nz,loop    ;; If reached exit, otherwise return

ld a,0     ;; \
ld hl,fcount    ;; \\
ld (hl),a    ;; Returns loop values back to 0
ld hl,scount    ;; //
ld (hl),a    ;; /

ld hl,100    ;; Return the value of ypos
ld (ypos),hl    ;; back to it's original place.

ret     ;; Program exits here.

.do_colour
   call &bbde    ;; GRA SET PEN - A = Pen Colour
   ld hl,(addrcolour)   ;; Take address of address colour
   inc hl     ;; Increment it by 1
   ld (addrcolour),hl   ;; Put this value into Address Colour
   ret     ;; Return to Main Loop Routine.

.fcount defb 0
.scount defb 0
.xlcount
defb 8     ;; Number of times to loop across.
.ylcount
defb 8     ;; Number of times to loop down
.xpos defw 100    ;; Left Position the image
.ypos defw 100    ;; Bottom Position of the image.
.data_colour
  defb 1,1,0,1,0,1,1,0
  defb 0,3,3,3,3,3,0,0
  defb 0,0,2,2,2,0,0,0
  defb 0,0,2,2,2,0,0,0
  defb 0,0,2,2,2,0,0,0
  defb 0,0,2,2,2,0,0,0
  defb 0,0,2,2,2,0,0,0
  defb 0,0,0,1,0,0,0,0

.addrcolour
  defw 0     ;; This points to the address position
      ;; within the data colour.


In the second and third examples though I've modified the assembly routine above, so it doesn't set the graphics ink or plot if a zero ink colour is found. Wasn't sure if this approach would enhance the time to plot the image, the following routine uses 8x8 sprite which is too difficult to tell if it's any faster, though the last example I've got here is displaying an image 15x23 in size and uses a lot of zero's, in that example it appears it takes less time to display the entire image because it's not processing all the zero colour points.


org &4000
; ld a,1     
; call &bc0e    ;; Set Screen Mode 1

ld hl,data_colour   ;; Address of Data Colour
ld (addrcolour),hl   ;; Place this into Address Colour
.loop
ld hl,(addrcolour)   ;; Place Contents of Address Colour into HL
ld a,(hl)    ;; Put Contents of HL into A
cp 0
jr z,iszero

call &bbde    ;; GRA SET PEN - A = Pen Colour

ld de,(xpos)    ;; XPOS data into DE
ld hl,(ypos)    ;; YPOS data into HL
call &bbea    ;; GRA ABSOLUTE PLOT

.iszero
ld hl,(addrcolour)   ;; Take address of address colour
inc hl     ;; Increment it by 1
ld (addrcolour),hl   ;; Put this value into Address Colour

ld hl,(xpos)    ;; Obtain Contents of XPOS
inc hl     ;; Is 16bit Value so Increment 
inc hl     ;; Twice
ld (xpos),hl    ;; Place next value into XPOS

ld a,(fcount)    ;; First Counter Position into A
inc a     ;; Increment this 
ld (fcount),a    ;; Put New Value into First Count Position
ld b,a     ;; Put this value into B

ld a,(xlcount)    ;; Place First Counter Marker into A

cp b     ;; Has value of B reached A value
jr nz,loop    ;; If No Loop back, otherwise continue

ld a,(fcount)    ;; At this stage fcount equals 8
xor a     ;; This will make it 0 again
ld (fcount),a    ;; And put that value into fcount

ld hl,(ypos)    ;; YPOS of data can now be Incremented
inc hl     ;; Again 16bit Value means Incrementing
inc hl     ;; it Twice
ld (ypos),hl    ;; And put that value into YPOS.

ld a,(xpos)    ;; Value of XPOS needs to return back to where it was.
sub 16     ;; Subtracting 16 will resolve this.
ld (xpos),a    ;; New Value goes into XPOS.

ld a,(scount)    ;; Second counter goes into A
inc a     ;; Increase it.
ld (scount),a    ;; Place back into Second Counter
ld b,a     ;; Put value of Second counter into B

ld a,(ylcount)    ;; Place Y-counting position into A

cp b     ;; Compare A to value of B
jr nz,loop    ;; If reached exit, otherwise return

ld a,0     ;; \
ld hl,fcount    ;; \\
ld (hl),a    ;; Returns loop values back to 0
ld hl,scount    ;; //
ld (hl),a    ;; /

ld hl,100    ;; Return the value of ypos
ld (ypos),hl    ;; back to it's original place.
ret     ;; Program exits here.

.fcount defb 0
.scount defb 0
.xlcount
defb 8     ;; Number of times to loop across.
.ylcount
defb 8     ;; Number of times to loop down
.xpos defw 100    ;; Left Position the image
.ypos defw 100    ;; Bottom Position of the image.
.data_colour
  defb 1,1,0,1,0,1,1,0
  defb 0,3,3,3,3,3,0,0
  defb 0,0,2,2,2,0,0,0
  defb 0,0,2,2,2,0,0,0
  defb 0,0,2,2,2,0,0,0
  defb 0,0,2,2,2,0,0,0
  defb 0,0,2,2,2,0,0,0
  defb 0,0,0,1,0,0,0,0

.addrcolour
  defw 0     ;; This points to the address position
      ;; within the data colour.



org &4000

xor a     ;; Setup data for Screen Mode
call &bc0e    ;; Set Screen Mode 0

call setup_inks    ;; Setup inks for image

ld hl,data_colour   ;; Address of Data Colour
ld (addrcolour),hl   ;; Place this into Address Colour
.loop
ld hl,(addrcolour)   ;; Place Contents of Address Colour into HL
ld a,(hl)    ;; Put Contents of HL into A
cp 0
jr z,iszero

call &bbde    ;; GRA SET PEN - A = Pen Colour

ld de,(xpos)    ;; XPOS data into DE
ld hl,(ypos)    ;; YPOS data into HL
call &bbea    ;; GRA ABSOLUTE PLOT

.iszero
ld hl,(addrcolour)   ;; Take address of address colour
inc hl     ;; Increment it by 1
ld (addrcolour),hl   ;; Put this value into Address Colour

ld hl,(xpos)    ;; Obtain Contents of XPOS
inc hl     ;; XPOS needs to be Incremented   
inc hl     ;; 4 times because this image
inc hl     ;; is done in mode 0
inc hl     ;; (e.g. 100..104..108..112..116..etc)
ld (xpos),hl    ;; Place next value into XPOS

ld a,(fcount)    ;; First Counter Position into A
inc a     ;; Increment this 
ld (fcount),a    ;; Put New Value into First Count Position
ld b,a     ;; Put this value into B

ld a,(xlcount)    ;; Place First Counter Marker into A

cp b     ;; Has value of B reached A value
jr nz,loop    ;; If No Loop back, otherwise continue

ld a,(fcount)    ;; At this stage fcount equals 8
xor a     ;; This will make it 0 again
ld (fcount),a    ;; And put that value into fcount

ld hl,(ypos)    ;; value of YPOS goes into HL
dec hl     ;; value of YPOS is decreased
dec hl     ;; Twice (100..98..96..94..etc)
ld (ypos),hl    ;; And put that value into YPOS.

ld a,(xpos)    ;; Value of XPOS needs to return back to where it was.
sub 60     ;; Subtracting 60 will resolve this.
ld (xpos),a    ;; New Value goes into XPOS.

ld a,(scount)    ;; Second counter goes into A
inc a     ;; Increase it.
ld (scount),a    ;; Place back into Second Counter
ld b,a     ;; Put value of Second counter into B

ld a,(ylcount)    ;; Place Y-counting position into A

cp b     ;; Compare A to value of B
jr nz,loop    ;; If reached exit, otherwise return

ld a,0     ;; \
ld hl,fcount    ;; \\
ld (hl),a    ;; Returns loop values back to 0
ld hl,scount    ;; //
ld (hl),a    ;; /

ld hl,100    ;; Return the value of ypos
ld (ypos),hl    ;; back to it's original place.

ret     ;; Program exits here.

.setup_inks
ld hl,colours
ld a,0
.inks_loop
ld c,(hl)
ld b,c
push af
push hl
call &bc32
pop hl
pop af
inc hl
inc a
cp 8
jr c,inks_loop
ret     ;; Return to Main Loop Routine.

.fcount defb 0
.scount defb 0
.xlcount
defb 15     ;; Number of times to loop across.
.ylcount
defb 23     ;; Number of times to loop down
.xpos defw 100    ;; Left Position the image
.ypos defw 100    ;; Bottom Position of the image.

.colours
defb 0,26,11,2,1,3,6,16

.data_colour
  defb 0,0,0,0,0,0,0,1,0,0,0,0,0,0,0
  defb 0,0,0,0,0,0,1,0,1,0,0,0,0,0,0
  defb 0,0,0,0,0,1,0,0,0,1,0,0,0,0,0
  defb 0,0,0,0,1,0,0,0,0,0,1,0,0,0,0
  defb 0,0,0,1,0,0,0,0,0,0,0,1,0,0,0
  defb 0,0,1,0,0,0,0,0,0,0,0,0,1,0,0
  defb 0,1,0,0,1,5,1,0,1,5,1,0,0,1,0
  defb 1,0,0,0,0,1,0,0,0,1,0,0,0,0,1
defb 1,0,0,0,0,0,0,0,0,0,0,0,0,0,1
  defb 0,1,0,0,0,0,0,0,0,0,0,0,0,1,0
  defb 0,0,1,4,4,4,4,4,4,4,4,4,1,0,0
  defb 0,1,4,4,1,4,4,4,4,4,1,4,4,1,0
  defb 0,1,4,4,1,4,4,4,4,4,1,4,4,1,0
  defb 1,4,4,1,7,1,4,4,4,1,7,1,4,4,1
  defb 0,1,4,3,1,3,4,4,4,3,1,3,4,1,0
  defb 0,1,4,4,3,4,4,4,4,4,3,4,4,1,0
  defb 0,0,1,4,4,4,4,4,4,4,4,4,1,0,0
defb 0,0,1,2,2,2,2,2,2,2,2,2,1,0,0
  defb 0,0,0,1,1,2,2,2,2,2,1,1,0,0,0
  defb 0,0,0,0,0,1,1,2,1,1,0,0,0,0,0
  defb 0,0,0,0,0,1,0,1,0,1,0,0,0,0,0
  defb 0,0,0,0,0,1,0,0,0,1,0,0,0,0,0
defb 0,0,0,0,1,1,1,0,1,1,1,0,0,0,0

.addrcolour
  defw 0     ;; This points to the address position
      ;; within the data colour.


I wouldn't say that these were silly in nature, I've only posted them here as a comparasion to the BASIC program and as examples of setting about drawing an image from minimal code. In terms of improving the assembly code, I'm thinking it's possible - the last program for instance has this bit:

ld hl,(xpos)
inc hl
inc hl
inc hl
inc hl
ld (xpos),hl


which I did have working with:

ld hl,(xpos)
ld bc,4
add hl,bc
ld (xpos),hl


though I'm guessing that it could be done with SLA which I think is faster again, though for this occassion SLA has be stumped.

Let me know if this would be a worthwhile article for the Wiki programming section.

EDIT: Unfortunately I forgot to attach those additional files, so there here now, in that process I found out I had Plot Image already been uploaded from a previous conversation!  :o  So it can be found here:)
* Using the old Amstrad Languages :D * And create my own ;)
* Incorporating the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

AMSDOS

Noticed there was some interest earlier in the year when it came to some Big Large Chunky Sprites, when I was a kid I made this Crude Text Graphical Program, which was replaced when AA had the BASIC Art program in AA73 (which was fantastic cause it worked on my 464 and featured a Fill Routine!  :) ), followed by GPAINT on the AA80 Covertape! One of the things I did on my own Graphical Editor was make some Blocky Images (using character 143) I could get some reasonible images out of it!

Anyway I was playing around in BASIC and came up with this which from DATA I already had and wrote the BASIC viewer to see how it would look (using Traditional character 143).

10 MODE 0: INK 0,0:INK 1,26:INK 4,3:INK 6,1:INK 7,2:INK 8,4:INK 9,16
20 DIM col(242):GOSUB 100:a=1
30 FOR y=1 TO 22
40 FOR x=1 TO 11
50 LOCATE x,y:PEN col(a):PRINT CHR$(143);
60 a=a+1
70 NEXT x:NEXT y
80 CALL &BB18:PEN 1:MODE 2:END
100 ' Set up Colours
110 FOR a=1 TO 241
120 READ c
130 col(a)=c
140 NEXT a:RETURN
150 DATA 0,4,4,4,4,4,4,0,0,0,0
160 DATA 0,4,4,4,4,4,4,4,4,4,0
170 DATA 0,4,4,4,4,4,4,9,4,4,0
180 DATA 4,4,4,4,4,4,4,9,4,4,0
190 DATA 4,4,4,4,4,4,9,9,9,4,4
200 DATA 4,4,4,4,1,0,9,0,1,4,4
210 DATA 4,9,4,9,1,0,9,0,1,4,4
220 DATA 0,9,4,9,1,0,9,0,1,4,4
230 DATA 0,9,9,9,1,0,9,0,1,4,0
240 DATA 0,4,9,9,1,1,9,1,9,9,0
250 DATA 0,4,9,9,9,1,9,1,9,9,0
260 DATA 0,4,9,9,9,9,9,9,9,9,0
270 DATA 0,7,4,9,9,9,0,9,9,9,0
280 DATA 7,7,7,9,9,9,9,9,9,8,0
290 DATA 7,7,7,8,7,7,7,8,7,8,0
300 DATA 7,7,9,8,7,7,7,8,9,9,0
310 DATA 7,9,9,9,8,8,8,8,9,9,0
320 DATA 0,9,9,8,6,1,6,1,8,9,0
330 DATA 0,8,8,8,8,6,6,6,6,8,0
340 DATA 0,8,8,8,8,8,8,8,8,8,8
350 DATA 0,4,6,6,6,0,6,6,6,6,4
360 DATA 0,4,4,4,4,0,4,4,4,4,4


Though the main reason I did that, was to trial this effect using SCR FILL BOX (&BC44). SCR FILL BOX is a funny Firmware instruction I reckon, it's described as a "Commonly used ROM subroutine" along with a number of other Firmware routines which are Commonly Used, though I haven't seen many people use SCR FILL BOX, except for one of the articles in an Early Australian Amstrad Magazine which has included it in their program which includes other Firmware Routines (not found as BASIC commands), and my Assembly Book has the wrong detail regarding one of the entry conditions for this SCR FILL BOX routine, specifying the INK number must be in the Accumulator which should be the Encoded INK Mask value, another reason I couldn't understand the funny stripes when I used to try and play around with it.

It wasn't easy coming up with a SCR FILL BOX routine which displays an image like the BASIC program does above and was making stupid mistakes until I realised what I had wrong, my main problem was in the way SCR FILL BOX has the registers setup for setting up the right entry of the registers which are as follows (from Kev Thacker's CPC Guide v1.2):


A = encoded ink to fill area with
H = left column of area-1
D = right column of area-1
L = top row-1
E = bottom row-1


On Exit:


AF,BC,DE,HL changed.


SCR FILL BOX is always a good one to do as a test to see what it does cause it's not as clear as it seems until you've thrown some values at it.


org &4000

ld a,&ff
ld h,0
ld d,0
ld l,0
ld e,0
call &bc44
ret


This for example will place a Red Square on the top left hand corner which is 8 pixels across and 8 pixels down. Try changing that to do something like this:


org &4000

ld a,&ff
ld h,0
ld d,2
ld l,0
ld e,0
call &bc44
ret


And it will draw across the screen 3 character lengths at 8 pixels doing 24 pixels in fairly reasonible time!  :)

Though this is what I ended up with which I haven't commented on yet, which is merely what I've got in BASIC form above, though a bit quicker using the SCR FILL BOX  :)  It's a funny routine this SCR FILL BOX for one thing it's using Text Based numbering to place the image on screen! Though could be useful for when dealing with Large Blocky Graphics to be shown on Screen, perhaps not in the same league as those who have written Blocky Graphics Routines for use in Games. I suspect it anyone knows of any AMSOFT games which feature large Blocky Graphics, then it will be using the SCR FILL BOX routine. At this time the only game I can thing of with a large Sprite onscreen is the opening screen in Mutant Monty, though I think that graphic has too much detail for it to be considered as a large blocky sprite using SCR FILL BOX.


;; Big BUB using SCR FILL BOX (&BC44)

org &4000

ld a,0
call &bc0e

call setupcols
call drawimg
call resval

call &bb18

ld a,2
call &bc0e

ret

.setupcols
ld hl,cols
ld a,0
.inkloop
ld c,(hl)
ld b,c
push af
push hl
call &bc32
pop hl
pop af
inc hl
inc a
cp 10
jr c,inkloop
ret

.drawimg
ld hl,(bubptr)
ld a,(hl)

push af

ld a,(lftcol)
ld h,a

ld a,(rftcol)
ld d,a

ld a,(toprow)
ld l,a

ld a,(botrow)
ld e,a

pop af

call &bc44

ld hl,(bubptr)
inc hl
ld (bubptr),hl

ld a,(lftcol)
inc a
ld (lftcol),a

ld a,(rftcol)
inc a
ld (rftcol),a

ld a,(fcount)
inc a
ld (fcount),a

ld b,a
ld a,(xval)
cp b
jr nz,drawimg

ld a,(fcount)
xor a
ld (fcount),a

ld a,(toprow)
inc a
ld (toprow),a

ld a,(botrow)
inc a
ld (botrow),a

ld a,(lftcol)
xor a
ld (lftcol),a

ld a,(rftcol)
xor a
ld (rftcol),a

ld a,(scount)
inc a
ld (scount),a
ld b,a
ld a,(yval)
cp b
jr nz,drawimg
ret

.resval
xor a
ld (fcount),a
ld (scount),a
ld (lftcol),a
ld (rftcol),a
ld (toprow),a
ld (botrow),a
ld hl,bub
ld (bubptr),hl
ret

.cols defb 0,26,0,0,3,0,1,2,4,16

.fcount defb 0
.scount defb 0

.lftcol defb 0
.rftcol defb 0

.toprow defb 0
.botrow defb 0

.yval   defb 22
.xval   defb 11

.bubptr defw bub

.bub
defb &00,&30,&30,&30,&30,&30,&30,&00,&00,&00,&00
defb &00,&30,&30,&30,&30,&30,&30,&30,&30,&30,&00
defb &00,&30,&30,&30,&30,&30,&30,&c3,&30,&30,&00
defb &00,&30,&30,&30,&30,&30,&30,&c3,&30,&30,&00
defb &30,&30,&30,&30,&30,&30,&c3,&c3,&c3,&30,&30
defb &30,&30,&30,&30,&c0,&00,&c3,&00,&c0,&30,&30
defb &30,&c3,&30,&c3,&c0,&00,&c3,&00,&c0,&30,&30
defb &00,&c3,&30,&c3,&c0,&00,&c3,&00,&c0,&30,&30
defb &00,&c3,&c3,&c3,&c0,&00,&c3,&00,&c0,&30,&00
defb &00,&30,&c3,&c3,&c0,&c0,&c3,&c0,&c3,&c3,&00
defb &00,&30,&c3,&c3,&c3,&c0,&c3,&c0,&c3,&c3,&00
defb &00,&30,&c3,&c3,&c3,&c3,&c3,&c3,&c3,&c3,&00
defb &00,&fc,&30,&c3,&c3,&c3,&00,&c3,&c3,&c3,&00
defb &fc,&fc,&fc,&c3,&c3,&c3,&c3,&c3,&c3,&03,&00
defb &fc,&fc,&fc,&03,&fc,&fc,&fc,&03,&fc,&03,&00
defb &fc,&fc,&c3,&03,&fc,&fc,&fc,&03,&c3,&c3,&00
defb &fc,&c3,&c3,&c3,&03,&03,&03,&03,&c3,&c3,&00
defb &00,&c3,&c3,&03,&3c,&c0,&3c,&c0,&03,&c3,&00
defb &00,&03,&03,&03,&03,&3c,&3c,&3c,&3c,&03,&00
defb &00,&03,&03,&03,&03,&03,&03,&03,&03,&03,&03
defb &00,&30,&3c,&3c,&3c,&00,&3c,&3c,&3c,&3c,&30
defb &00,&30,&30,&30,&30,&00,&30,&30,&30,&30,&30

;; Masks to be used in PENs

;; pen 0 = &00
;; pen 1 = &c0
;; pen 4 = &30
;; pen 6 = &3c
;; pen 7 = &FC
;; pen 8 = &03
;; pen 9 = &c3
* Using the old Amstrad Languages :D * And create my own ;)
* Incorporating the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

AMSDOS

Thanks for your support!  :)

I've attached a followup to the Assembly Routine I posted Yesterday with some comments added to the file which I hope will help people follow the process. The routine can probably be cut down in size with the number of variables it's using and the additional code cause it's mainly 4 variables with 2 only requiring different values at the same time, the second variable only really needs what's in the other for this to work, changing that would mess up the process.
* Using the old Amstrad Languages :D * And create my own ;)
* Incorporating the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

AMSDOS

This is the final version of the SCR FILL BOX routine which is more refined, compact & commented which does the same job! Too many variables (memory locations) were used!  :laugh:
* Using the old Amstrad Languages :D * And create my own ;)
* Incorporating the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

AMSDOS

Some more BASIC code, I don't really expect anyone to use it, though if curiosity gets the better of you, you can click "quote" alongside this post and extract the source code that way (with the Carriage Returns):

10 MODE 1:ORIGIN 0,0,100,200,200,100
20 CLG
30 WHILE INKEY$<>" "
40 a=INT(RND*3)+1:PLOT INT(RND*100)+100,INT(RND*100)+100,a
50 WEND


This program sets up a Graphics Window (as shown in ORIGIN), followed by a Clear of that Graphical Window which does nothing, setting up a GRAPHICS PAPER before that with any value apart from 0 would show the effect CLG has on it though which is interesting, apart from that move it inside the while loop with some CALL &BD19 or FRAMEs will definitely do something in there!  :)  As it is it will Enter the Loop (and continue until SPACE bar has been pressed) and just randomibly draw dots in that Graphics Window in various colours!  :)  Not ground breaking.  :laugh:

10 MODE 1
20 xc=2:yc=2:x=0:y=0
30 WHILE INKEY$=""
40 CALL &BD19:CALL &BD19:CALL &BD19:CALL &BD19:ORIGIN x,y:PLOT 100,100,1:DRAW 125,100:DRAW 125,125:DRAW 100,125:DRAW 100,100
50 ox=x:oy=y:x=x+xc:y=y+yc
60 CALL &BD19:CALL &BD19:CALL &BD19:CALL &BD19:ORIGIN ox,oy:PLOT 100,100,0:DRAW 125,100:DRAW 125,125:DRAW 100,125:DRAW 100,100
70 IF x=100 then xc=-2
80 if y=100 then yc=-2
90 if x=0 then xc=2
100 if y=0 then yc=2
110 wend


This code is perhaps the more interesting of the two. This program goes about drawing a box on screen and then rubs it out, looping backwards and fowards until someone presses a key!  :o  Though the co-ordinates of the box never changes, it's pretty obvious to see that the ORIGIN is responcible for making that box move because the origin co-ordinates x & y are changing which is making the rest of the screen appear to move. While I'd placed a number of Frame Flyback instructions in there (CALL &BD19), this example carries on blinking a lot. Perhaps it could be improved!  :laugh:  Applying this approach in Assembly though (even using standard Firmware instructions) will ultimately reduce that flicker though!  ;D
* Using the old Amstrad Languages :D * And create my own ;)
* Incorporating the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

AMSDOS

Going back to that first program in the previous post, I did some adjustments to it primarily line 30 (unfortunately it's a BASIC 1.1 program, firmware may have a routine for this though):

10 MODE 1:ORIGIN 0,0,100,200,200,100
20 WHILE INKEY$=""
30 FOR delay=1 TO a:CALL &BD19:CALL &BD19:GRAPHICS PAPER a:CLG:NEXT delay
40 a=INT(RND*3)+1:PLOT INT(RND*100)+100,INT(RND*100)+100,a
50 WEND


And got an interesting effect from it. To me it's tricking the eye cause it appears more than one pixel dot while the program is flashing through. I put a CALL &BB18 which halts until a keypress is made which suggested that it's only showing one, though perhaps with the program running faster it's generated this extra effect which won't show up on close examination.  :laugh:
* Using the old Amstrad Languages :D * And create my own ;)
* Incorporating the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

AMSDOS

This is quite a straightfoward effect, writing it up in BASIC I mean  :)  Though the effect is just that, another display effect for them demos or games or just for more ideas/possibilities which haven't been considered until now!  ;D

Below is only a demonstration of the effect (singular colour), though it wouldn't be hard to apply something like that image from that Array into this sort of thing.  :laugh:  Obviously though to apply the effect in MODE 0 or MODE 2, the key to generating that effect in those modes would be based on the STEP done in those FOR loops.

10 MODE 1:BORDER 0:INK 0,0:INK 1,13
20 FOR x=0 TO 638 STEP 4
30 FOR y=400 TO 0 STEP -4
40 PLOT x,y,1
50 NEXT y
60 NEXT x
70 CALL &BB18 ' KM WAIT KEY


* Using the old Amstrad Languages :D * And create my own ;)
* Incorporating the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

Bryce

How long do I have to stare at it with squinted eyes before I see the Mona Lisa in 3D?

Bryce.

AMSDOS

Quote from: Bryce on 13:25, 22 November 11
How long do I have to stare at it with squinted eyes before I see the Mona Lisa in 3D?

Bryce.

Er? Until you find the right pixel with the right painting in it (kind of like a Where's Wally book).  :laugh:

This program below produces a dotty image of Bub, is kind of tricky given it's an image with boundaries - one sort of has to apply where the image will finish along the x-position and y-position, perhaps "while..wend" is more suitable, and it simply counts along the array.

10 MODE 0:INK 0,0:INK 1,26:INK 4,3:INK 6,1:INK 7,2:INK 8,4:INK 9,16
20 DIM col(242):GOSUB 1000:a=1
30 FOR y=400 to 224 step -8
40 FOR x=0 to 88 step 8
50 plot x,y,col(a)
60 a=a+1
70 next x
80 next y
90 call &bb18
100 mode 2:call &bc02:end
1000 ' Set up Colours
1010 FOR a=1 TO 241
1020 READ c
1030 col(a)=c
1040 NEXT a:RETURN
1050 DATA 0,4,4,4,4,4,4,0,0,0,0
1060 DATA 0,4,4,4,4,4,4,4,4,4,0
1070 DATA 0,4,4,4,4,4,4,9,4,4,0
1080 DATA 4,4,4,4,4,4,4,9,4,4,0
1090 DATA 4,4,4,4,4,4,9,9,9,4,4
1100 DATA 4,4,4,4,1,0,9,0,1,4,4
1110 DATA 4,9,4,9,1,0,9,0,1,4,4
1120 DATA 0,9,4,9,1,0,9,0,1,4,4
1130 DATA 0,9,9,9,1,0,9,0,1,4,0
1140 DATA 0,4,9,9,1,1,9,1,9,9,0
1150 DATA 0,4,9,9,9,1,9,1,9,9,0
1160 DATA 0,4,9,9,9,9,9,9,9,9,0
1170 DATA 0,7,4,9,9,9,0,9,9,9,0
1180 DATA 7,7,7,9,9,9,9,9,9,8,0
1190 DATA 7,7,7,8,7,7,7,8,7,8,0
1200 DATA 7,7,9,8,7,7,7,8,9,9,0
1210 DATA 7,9,9,9,8,8,8,8,9,9,0
1220 DATA 0,9,9,8,6,1,6,1,8,9,0
1230 DATA 0,8,8,8,8,6,6,6,6,8,0
1240 DATA 0,8,8,8,8,8,8,8,8,8,8
1250 DATA 0,4,6,6,6,0,6,6,6,6,4
1260 DATA 0,4,4,4,4,0,4,4,4,4,4


The final result can be shown in the image!  :laugh:
* Using the old Amstrad Languages :D * And create my own ;)
* Incorporating the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

Powered by SMFPacks Menu Editor Mod