Jump to content
IGNORED

HLO projects - Coco 2 LINES in 8 color using Expanded BASIC


RSS Bot

Recommended Posts

‘LINES’ is a simple enough program. It draws random lines on the screen in a trailing pattern. I have posted several versions from multiple 8-bit computers on this site. I have even posted a version for the Color Computer 2 with four colors.
Today, I’m going to post another version of LINES for the CoCo2 but this time in eight colors!
“Eight colors! How,”, you say, “how can you get eight color on the screen with the CoCo2?!? That is impossible! That challenges the very laws of physics!!” First, calm down, it just a computer. Second, I use the CoCo’s semi-graphic mode and a program called ‘Expanded Color BASIC’.
The Wikipedia for the Color Computer 2 page says of the semi-graphic modes that it’s nothing more than a curiosity. I disagree. I think you can do some fairly interesting stuff with the semi-graphic mode.
What is the semi-graphic mode? Here’s where I talk a little bit about the semi-graphic mode in a previous blog:
http://atariage.com/forums/blog/528/entry-15524-color-computer-2-semi-graphics-mode-8/
I mention that with a little assembly trickery in semi-graphic mode 24 you could have 64x128 graphics with 8 colors on background. Well apparently from some warp in the time-space continuum Tino Delbuergo heard my request and wrote a Expanded BASIC, many years ago, that does that very thing (cleaver of me to arrange that).
I’ll do a more detailed description in a later post. But here is the short of it.
You first have to execute RUN”R” from the Expanded BASIC DISK to roll the OS back to the CoCo 1 OS (if you own a CoCo2). Apparently the programs only work in CoCo 1 OS environment. Then execute RUN”Q” to install the Q graphic commands which include the semi-graphics commands.
The actual point semi-graphic commands are very limited. In reality, there is only one: QSET(X,Y,color). Now the Q graphics can do a lot more than just point graphics but I do wish a LINE command had been added. Any rate, this does give you a point on the screen that is 4 pixels by 1 pixel in all the colors available to the CoCo 2.
A 4x1 pixel may seem a bit wide but the Atari 8-bit GITA modes have pixels 4x1 wide that give 16 colors. I have seen some incredible graphics and games done in the GITA mode on the Atari. So 4x1 pixel, doable.
How does the semi-graphic mode creates a 4x1 pixel? Well, it’s really an 8x8 character where only the top line is used. That line uses the character which is 4 pixels of color and 4 pixels of background. A bit of assembler code determines which side is color and which side is background depending on the X value. If it’s an odd number then the left 4 are lit. If it’s an even number the right four. If it’s a straight vertical line all both are lit.
This makes for a limitation. Say you wanted a blue line on the odd 4 of 8 and a yellow line on the even 4 of 8. Well, that can’t happen as you can only have 1 color specified per 8 pixel line. What will happen is all the color pixels will be whatever the last color set and you will have a line of 8 pixels of the same color.
This is fairly similar to the way the TI-99/4a does it’s hi-res graphics. It uses 8 pixels as a modified character that can have two colors. The difference is the TI-99 you can specify which one of the eight pixels are ‘on’ to color and which are ‘off’, another color or background. But if you try to add a second ‘on’ color in the line of 8 all the previous ‘on’ pixels will turn that color also.
Still, by and large, it works.
As I previously explained Expanded BASIC Q Graphics only has a point QSET(X,Y,color) command and no LINE command. Therefore I had to create my own LINE command from a modified C subroutine. The code to create the LINE starts at 100 and goes to 110.
QPRINT will print a line of text on the screen in the boring green on green text.
I will post a more robust explanation of Expanded BASIC in a later blog post. It’s a very powerful tool. For this post I just wanted to show that the semi-grpahic mode was useful.
Note: You must RUN”R” (if you have a CoCo2) and then RUN”Q” from the Expanded BASIC disk before you can run this programs .
The program is on the BASIC-PROJ.DSK. The name of the file is QLINES5/BAS
Here are the disk:
<files>
Now the code.
10 REM "QLINES5
12 POKE 65495,0 : REM SPEED UP POKE. MAY NOT WORK ON ALL COCO2S
14 PMODE 4,1 : REM THIS MODE GIVES YOU THE 4X1 PIXELS
20 QON : REM TURN ON Q GRAPHICS
25 QCLS(0,0) : REM CLRS Q SCREEN
32 X=RND(-TIMER) : REM VERY RANDOM SEED
40 X1=RND(0)*9+9 : X2=RND(0)*20+20 : Y1=RND(0)*18+9 : Y2=RND(0)*70+10 : Z=RND(0)*7+1 : REM SET RND LOCATION OF START
50 A=4:B=4:C=4:D=4
90 REM THIS IS THE LINE ROUTINE 100-110
100 X=ABS(X1):Y=Y1:DX=X2-X1:DY=Y2-Y1
103 IF ABS(DX)>ABS(DY) THEN S=ABS(DX) ELSE S=ABS(DY)
108 XI=DX/S:YI=DY/S
110 FOR I=1 TO S STEP 2:X=X+XI:Y=Y+YI:QSET(X,Y,Z):NEXT I : REM THIS DRAWS THE ACTUAL LINE
124 IF A>1 AND RND(0)<0.3 THEN A=(RND(0)*4)+1: D=-D : REM ADD SOME RANDOM TO LINE LENGTH
127 IF D>1 AND RND(0)<0.3 THEN D=(RND(0)*2)+2
130 X1=X1+A:Y1=Y1-B : REM INC LINE
132 REM PRINT LOC OF END POINTS
134 X1$=STR$(INT(X1)) : X2$=STR$(INT(X2)) : Y1$=STR$(INT(Y1)) : Y2$=STR$(INT(X2))
135 A$="Y1"+Y1$+" Y2"+Y2$+" X1"+X1$+" X2"+X2$:QPRINT@480,A$
140 X2=X2-C:Y2=Y2+D
145 REM CHK IF EXCEEDS END OF SCREEN
150 IF Y1<5 OR Y1>150 THEN B=-B
155 IF Y2<5 OR Y2>150 THEN D=-D
160 IF X1<5 OR X1>057 THEN A=-A
165 IF X2<5 OR X2>057 THEN C=-C
190 IF RND(0)<0.35 THEN Z=INT(RND(0)*7)+1:A=-A : REM REDIR THE LINE
200 T=T+1:IF T>040 THEN T=0:QCLS(0,0) : REM CHG THE COLOR
1200 GOTO 100

 

Another note, sometime the program errors out when the line gets too long to the right. Doesn’t happen often and I’m too lazy to fix it.
Well Wikipedia, here is a program in Semi-Graphics that is more than just a oddity. So huh.

Attached File(s)


http://atariage.com/forums/blog/528/entry-15915-coco-2-lines-in-8-color-using-expanded-basic/
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...