Jump to content
IGNORED

TI Basic + sprite games


ramidavis

Recommended Posts

 

gallery_34177_1071_873629.gif

 

To see the demo, copy and paste the first program into TI BASIC, save if desired and then RUN. Then copy and paste the second program into TI BASIC, save if desired and RUN. You will see 3 sprites and 15 unused character sets in all 15 colors. These are available for graphics. When the program breaks you will see some colorful things going on as the sprite motion routine changes the color table. This is not a crash and you can type BYE with the expected results.
10 FOR I=1 TO 128

20 READ X

30 F$=F10 FOR I=1 TO 128 20 READ X 30 F$=F$&CHR$(X) 40 NEXT I 50 OPEN #1:F$ 100 DATA 0,0,0,0,0,0,0,0,227,0,131,150,216,32,131,82,131,212,200,32,131,84,131,196,16,40,0,0,0,0,0,0 110 DATA 0,0,0,0,0,0,55,215,158,128,0,0,0,0,0,0,0,0,0,0,0,0,33,111,0,0,0,0,0,0,0,0,0,0,0,0,0 120 DATA 0,0,0,0,0,0,0,136,32,131,36,131,190,22,11,16,1,0,0,215,224,1,40,215,224,0,0,216,32,0,144,131 130 DATA 122,4,224,131,196,4,91,0,0,0,0,0,0,0,0,7,216,0,0,0,0,131,86,0,0,0,0 amp;CHR$(X)

40 NEXT I

50 OPEN #1:F$

100 DATA 0,0,0,0,0,0,0,0,227,0,131,150,216,32,131,82,131,212,200,32,131,84,131,196,16,40,0,0,0,0,0,0

110 DATA 0,0,0,0,0,0,55,215,158,128,0,0,0,0,0,0,0,0,0,0,0,0,33,111,0,0,0,0,0,0,0,0,0,0,0,0,0

120 DATA 0,0,0,0,0,0,0,136,32,131,36,131,190,22,11,16,1,0,0,215,224,1,40,215,224,0,0,216,32,0,144,131

130 DATA 122,4,224,131,196,4,91,0,0,0,0,0,0,0,0,7,216,0,0,0,0,131,86,0,0,0,0

 

The sprite magnification can be changed in line 100 - the 227 can be a value from 224 to 227 for sprite magnifications 1-4.

90 REM 1ST SPRITE:row=44;col=44;pattern=A4-60=44;white(16)

100 CALL COLOR(1,5,5)

110 CALL COLOR(2,5,5)

120 CALL COLOR(3,11,5)

130 CALL COLOR(4,1,16)

140 REM 2nd Sprite: row=66;col=66;pattern=a8-60=48;Magenta(14)

150 CALL COLOR(5,7,7)

160 CALL COLOR(6,7,7)

170 CALL COLOR(7,11,9)

180 CALL COLOR(8,1,14)

190 REM 3rd Sprite:row=88;col=88;pattern=AC-60=4C;dark red(7)early clock on(9)

200 CALL COLOR(9,9,9)

210 CALL COLOR(10,9,9)

220 CALL COLOR(11,11,13)

230 CALL COLOR(12,9,7)

240 REM 4th Sprite: row=>D0 to hide higher sprites

250 CALL COLOR(13,14,1)

260 REM

270 CALL CHAR(144,"02000000F4")

280 CALL CHAR(145,"F5000000F6")

290 CALL CHAR(146,"0503000007F9")

300 CALL CHAR(147,"FCF4")

310 CALL CHAR(152,"1122334455667788")

320 CALL CHAR(153,"99AABBCCDDEEFF10")

330 CALL CHAR(154,"1010101010101010")

340 CALL CHAR(155,"1010101010101010")

350 CALL SOUND(600,110,30)

360 CALL SOUND(10,110,30)

365 CALL CHAR(144,"0")

370 CALL CHAR(145,"0")

380 FOR I=0 TO 255

390 PRINT CHR$(I);

400 NEXT I

410 GOTO 410

Here is a method that gives you up to 3 moving sprites using standard TI BASIC, using nothing but BASIC statements. It is similar to the earlier method that offers 32 sprites but no sprite motion. The challenge in making this work is that if you want to use automatic sprite motion the sprite attribute list must start at v0300. The only way TI BASIC can modify those memory locations is via CALL COLOR. In the color table, the first four sprite definitions cannot be accessed but sprites 5-8 can be. So there will be 8 sprites in all; the first 4 are invisible, the next 3 can move automatically, and the last one has its row set to >D0 to hide the remaining sprites.
Four character definitions from 144 to 147 are used for the sprite motion table. Since the program is using the color table for sprites then there has to be a new color table. I put it so it can be modified by changing the character definitions from 152 to 155.
As with the previous program that gives you 32 sprites, this one exploits a bug in OPEN that allows 128 bytes to be loaded into the scratchpad. Moving the color table by resetting VDP R3 to >1F is easy enough, but it reverts to the default value when you force a NEW. To get around that, the program sets up an interrupt routine that waits in the background. You can load a program and change it if desired. When you run the program it continues waiting until the program does a CALL CHAR(155,...) at which point it sets VDP R3 to use the new color table and enables motion for 7 sprites. This gives you a chance to set up the sprites and sprite motions in advance.
The second program above is an example showing how to set up the sprites and I will also give a short description below.
-----------------------------------------------------------------
CALL COLOR is used to define a sprite.
Sprite 1 is defined with COLOR 1-4
Sprite 2 is defined with COLOR 5-8
Sprite 3 is defined with COLOR 9-12
Sprite 4 is defined with COLOR 13-17 and should have a row of >D0 to hide all higher sprites
You have to think in hexadecimal for this. For row and column add 1 to each nybble. For Sprite #1
For a row of >83 it should be CALL COLOR(1,9,4)
For a row of >AB it should be CALL COLOR(1,11,12)
For a column of >83 it should be CALL COLOR(2,9,4)
To set the pattern to use, add 7 to the first nybble and 1 to the second.
To use the pattern for “A” (>41) it should be CALL COLOR(3,11,2)
To set the color of the sprite use the normal color value for BASIC. The first nybble should be 1 if you do not want to use the “early clock” or 9 if you want to set the early clock.
To set the color to white (16) it should be CALL COLOR(4,1,16)
To set the color to dark red with early clock on it should be (CALL COLOR(4,9,7)
-------------------------------------------------------------------
CALL CHAR 144 to 147 are used to set the sprite velocities.
I suggest using CALL CHAR(144,”02000000F4”) and CALL CHAR(145,”F4000000F6”)
Sprite motion is activated when you CALL CHAR(155,...) and you should follow that with CALL SOUND(600,110,30) and CALL CHAR(144,”0”) and CALL CHAR(145,”0”). This moves the 4 invisible sprites off the screen and stops them. This avoids having over 4 sprites on a line.
Now for the sprites we care about:
CALL CHAR(146,”0503000007F9”) sets sprite 1 to row velocity=5 and col velocity=3.
Sprite 2 has row velocity=7 and col velocity=-7
CALL CHAR(147,”FCF4”) sets sprite 3 row velocity=-4 and col velocity=-12
(If the row velocity is positive then motion is downward and if the column velocity is positive then motion is to the right.)
The new color table is set with CALL CHAR 152-155
I recommend using the values that are in the demo:
310 CALL CHAR(152,"1122334455667788")
320 CALL CHAR(153,"99AABBCCDDEEFF10")
330 CALL CHAR(154,"1010101010101010")
340 CALL CHAR(155,"1010101010101010")
The relocated color table lets you define the colors of all 256 characters. The unused characters from 0 to 23 and 160 to 255 can have their foreground and background colors set to the same color and that gives you an 8x8 block of all possible colors without using any of the normal characters. You can display these on the screen with HCHAR and VCHAR.
The first character of each character set is:
160 Black
168 Medium Green
176 Light Green
184 Dark Blue
192 Light Blue
200 Dark Red
208 Cyan
216 Medium Red
224 Light Red
232 Dark Yellow
240 Light Yellow
248 Dark Green
0 Magenta
8 Gray
16 White
When programming, do not use characters 144 - 147 or 152 – 155 for graphics because they are needed by the sprite routines.

 

 

This is a lot to wrap my head around. :-o

And i had just started to get the hang of the old-version you originally posted.

This is very, very impressive, senior_falcon.

I am not getting the negative hex numbers though.

How is FC and F4 equal to -4 and -12?

Hexadecimal FC = 252 decimal.

Hexadecimal F4 = 244 decimal.

Edited by notwhoyouthink
  • Like 1
Link to comment
Share on other sites

I'm not senior_falcon :) but is it 2's complement notation? Instead of going from 0-255, the values would go from -128 to +127, which allows us to have negative and positive numbers all in 1 byte. In 2's complement, you take the binary digits that make up the number, flip them, and then add 1, and that gives you the negative decimal equivalent.

 

FC in binary is: 11111100

2's complement: 00000011 + 1

-4

 

It really is an artifact of how integers are expressed (or can be) expressed in computers. Either from 0-255 in 8 bits, or using the first bit to indicate the sign, from -128 to +127. It's also why we have to use negative numbers in CALL LOAD statements.

 

I hope I explained that correctly - Computer Science classes were a long time ago! :)

Edited by Casey
  • Like 1
Link to comment
Share on other sites

 

This is a lot to wrap my head around. :-o

And i had just started to get the hang of the old-version you originally posted.

This is very, very impressive, senior_falcon.

I am not getting the negative hex numbers though.

How is FC and F4 equal to -4 and -12?

Hexadecimal FC = 252 decimal.

Hexadecimal F4 = 244 decimal.

 

The sprite motion table uses signed byte values for vertical (y) and horizontal (x) velocities— -128 – +127 (>80 – >7F This means that the leftmost bit of each velocity byte is a sign bit and that, when that bit is set, the byte value is the two's complement of its positive equivalent (alluded to by @Casey in post #78). >F4 is the two's complement of 12 and thus represents -12. Similarly, >FC represents -4 as the two's complement of 4.

 

...lee

  • Like 1
Link to comment
Share on other sites

Senior_falcon, am i correct in thinking there is not a easy way to do the equivalent of XB's CALL COINC with this technique?

If there is, i would love the details on it.

Sorry, but without the ability to peek the VDP ram you have no way of knowing where the sprites are when using auto sprite motion. Mainly I think of this as an interesting technique, but I sure can't see any way you could make a practical game out of this. (They developed XB for a reason!)

BTW, it looks like I have figured out how to do it all from within one program and bypass the need for the separate initializer program. If so this would allow 4 moving sprites. But it's late, I'm tired and will sign off for now.

  • Like 1
Link to comment
Share on other sites

BTW, it looks like I have figured out how to do it all from within one program and bypass the need for the separate initializer program. If so this would allow 4 moving sprites. But it's late, I'm tired and will sign off for now.

 

Very interesting!

Hope you can get somewhere with that idea!

 

I really think that useful programs can be developed with this technique using nothing but TI BASIC. Morphy is a good example.

 

For an encore, in the next day or so I will release a simple demo that has 3 moving sprites, using nothing but legal TI BASIC statements. (In theory you could use four if I could figure out a way to put a >DO at v0320.) Oh yes, also you can have 8x8 blocks in all 15 colors without using any character definitions!

 

I will expect to see a nice demo using this from "notwhoyouthink".

 

In the meantime though, i believe you wanted to see me use this new version, so "Let's a go!"

You should know the drill by now. Load the first listing and run it, then load the second listing and run it.

Setup program:

10 FOR I=1 TO 128
20 READ X
30 F$=F$&CHR$(X)
40 NEXT I
50 OPEN #1:F$
100 DATA 0,0,0,0,0,0,0,0,227,0,131,150,216,32,131,82,131,212,200,32,131,84,131,196,16,40,0,0,0,0,0,0
110 DATA 0,0,0,0,0,0,55,215,158,128,0,0,0,0,0,0,0,0,0,0,0,0,33,111,0,0,0,0,0,0,0,0,0,0,0,0,0
120 DATA 0,0,0,0,0,0,0,136,32,131,36,131,190,22,11,16,1,0,0,215,224,1,40,215,224,0,0,216,32,0,144,131
130 DATA 122,4,224,131,196,4,91,0,0,0,0,0,0,0,0,7,216,0,0,0,0,131,86,0,0,0,0

Main demo:

1 CALL CLEAR
2 CALL SCREEN(6)
3 FOR X = 68 TO 79
4 READ X$
5 CALL CHAR(X,X$)
6 NEXT X
100 CALL COLOR(1,5,5)
110 CALL COLOR(2,5,5)
120 CALL COLOR(3,11,5)
130 CALL COLOR(4,1,16)
150 CALL COLOR(5,5,5)
160 CALL COLOR(6,5,5)
170 CALL COLOR(7,11,9)
180 CALL COLOR(8,1,9)
200 CALL COLOR(9,5,5)
210 CALL COLOR(10,5,5)
220 CALL COLOR(11,11,13)
230 CALL COLOR(12,1,2)
250 CALL COLOR(13,14,1)
270 CALL CHAR(144,"02000000F4")
280 CALL CHAR(145,"F5000000F6")
290 CALL CHAR(146,"FCF40000FCF4")
300 CALL CHAR(147,"FCF4")
310 CALL CHAR(152,"1122334455667788")
320 CALL CHAR(153,"99AABBCCDDEEFF10")
330 CALL CHAR(154,"1010101010101010")
340 CALL CHAR(155,"1010101010101010")
350 CALL SOUND(600,110,30)
360 CALL SOUND(10,110,30)
365 CALL CHAR(144,"0")
370 CALL CHAR(145,"0")
380 FOR X = 1 TO 143
390 READ R,C,CHAR
400 CALL HCHAR(R,C,CHAR)
410 NEXT X
420 GOTO 420
900 DATA 000F1F3F2B6B7F55
901 DATA 4141202A1F030000
902 DATA 00C0F09868ECDCFC
903 DATA FEFEFEFCF0C00000
904 DATA 000000000000002A
905 DATA 3E3E1F1500000000
906 DATA 0000000000000000
907 DATA 0000000000000000
908 DATA 0F10204054948080
909 DATA 80804040201C0300
910 DATA C030086494122202
911 DATA 010101020C30C000
912 DATA 9,14,200
913 DATA 9,15,200
914 DATA 9,16,200
915 DATA 9,17,200
916 DATA 9,18,200
917 DATA 10,13,200
918 DATA 10,14,200
919 DATA 10,15,200
920 DATA 10,16,200
921 DATA 10,17,200
922 DATA 10,18,200
923 DATA 10,19,200
924 DATA 10,20,200
925 DATA 10,21,200
926 DATA 11,13,232
927 DATA 11,14,232
928 DATA 11,15,232
929 DATA 11,16,240
930 DATA 11,17,240
931 DATA 11,18,160
932 DATA 11,19,240
933 DATA 12,12,232
934 DATA 12,13,240
935 DATA 12,14,232
936 DATA 12,15,240
937 DATA 12,16,240
938 DATA 12,17,240
939 DATA 12,18,160
940 DATA 12,19,240
941 DATA 12,20,240
942 DATA 12,21,240
943 DATA 13,12,232
944 DATA 13,13,240
945 DATA 13,14,232
946 DATA 13,15,232
947 DATA 13,16,240
948 DATA 13,17,240
949 DATA 13,18,240
950 DATA 13,19,160
951 DATA 13,20,240
952 DATA 13,21,240
953 DATA 13,22,240
954 DATA 14,13,232
955 DATA 14,14,240
956 DATA 14,15,240
957 DATA 14,16,240
958 DATA 14,17,240
959 DATA 14,18,160
960 DATA 14,19,160
961 DATA 14,20,160
962 DATA 14,21,160
963 DATA 15,14,240
964 DATA 15,15,240
965 DATA 15,16,240
966 DATA 15,17,240
967 DATA 15,18,240
968 DATA 15,19,240
969 DATA 16,13,200
970 DATA 16,14,200
971 DATA 16,15,184
972 DATA 16,16,200
973 DATA 16,17,200
974 DATA 16,18,184
975 DATA 16,19,200
976 DATA 16,20,200
977 DATA 17,12,200
978 DATA 17,13,200
979 DATA 17,14,200
980 DATA 17,15,184
981 DATA 17,16,200
982 DATA 17,17,200
983 DATA 17,18,184
984 DATA 17,19,200
985 DATA 17,20,200
986 DATA 17,21,200
987 DATA 18,11,200
988 DATA 18,12,200
989 DATA 18,13,200
990 DATA 18,14,200
991 DATA 18,15,184
992 DATA 18,16,184
993 DATA 18,17,184
994 DATA 18,18,184
995 DATA 18,19,200
996 DATA 18,20,200
997 DATA 18,21,200
998 DATA 18,22,200
999 DATA 19,11,240
1000 DATA 19,12,240
1001 DATA 19,13,200
1002 DATA 19,14,184
1003 DATA 19,15,240
1004 DATA 19,16,184
1005 DATA 19,17,184
1006 DATA 19,18,240
1007 DATA 19,19,184
1008 DATA 19,20,200
1009 DATA 19,21,240
1010 DATA 19,22,240
1011 DATA 20,11,240
1012 DATA 20,12,240
1013 DATA 20,13,240
1014 DATA 20,14,184
1015 DATA 20,15,184
1016 DATA 20,16,184
1017 DATA 20,17,184
1018 DATA 20,18,184
1019 DATA 20,19,184
1020 DATA 20,20,240
1021 DATA 20,21,240
1022 DATA 20,22,240
1023 DATA 21,11,240
1024 DATA 21,12,240
1025 DATA 21,13,184
1026 DATA 21,14,184
1027 DATA 21,15,184
1028 DATA 21,16,184
1029 DATA 21,17,184
1030 DATA 21,18,184
1031 DATA 21,19,184
1032 DATA 21,20,184
1033 DATA 21,21,240
1034 DATA 21,22,240
1035 DATA 22,13,184
1036 DATA 22,14,184
1037 DATA 22,15,184
1038 DATA 22,18,184
1039 DATA 22,19,184
1040 DATA 22,20,184
1041 DATA 23,12,232
1042 DATA 23,13,232
1043 DATA 23,14,232
1044 DATA 23,19,232
1045 DATA 23,20,232
1046 DATA 23,21,232
1047 DATA 24,11,232
1048 DATA 24,12,232
1049 DATA 24,13,232
1050 DATA 24,14,232
1051 DATA 24,19,232
1052 DATA 24,20,232
1053 DATA 24,21,232
1054 DATA 24,22,232
Edited by notwhoyouthink
  • Like 9
Link to comment
Share on other sites

My real 99/4A doesn't like something about these programs but I'm not sure what it doesn't like. I pasted these into Classic99 and then transferred them to my nanoPEB and 99/4A locks up after running the setup program. TI BASIC restarts, but attempting to load the demo program locks up the TI. I can't imagine it makes a difference, but the programs from above that I used to make the video with, I typed in by hand. (Those only work from cassette, oddly).

Link to comment
Share on other sites

My real 99/4A doesn't like something about these programs but I'm not sure what it doesn't like. I pasted these into Classic99 and then transferred them to my nanoPEB and 99/4A locks up after running the setup program. TI BASIC restarts, but attempting to load the demo program locks up the TI. I can't imagine it makes a difference, but the programs from above that I used to make the video with, I typed in by hand. (Those only work from cassette, oddly).

I'm sorry to hear that.

I have been so busy playing with this in classic99 that i have totally forgotten to test any of these on real TI's.

Then again, i do not have a nanopeb, so it may be a specific problem to that particular configuration.

Hopefully senior_falcon can offer some advice?

Link to comment
Share on other sites

In Extended BASIC, CALL PEEK(-31888,A,B)::PRINT A;B

If A and B are not 55,215 then change the 55,215 in line 110 to match your values. And of course, report your results!

That did the trick. On my real 99/4A, it was 55,207. Changing line 110 to match worked. Thanks!

  • Like 1
Link to comment
Share on other sites

Automotion-sprites in basic, to me, do not seem to be of much use.

However, as Morphy and my own parsec sprite demo with moveable user controlled sprites (Post #60) has shown, useful things can still be accomplished.

I have a couple of ideas cooking for games using this.

For now, i will experiment with simple games like tower of hanoi, tic tac toe, hangman, and rock paper scissors.

Assuming they turn out decent, i will release them here on Atariage forum.

Of coarse there is always real life to suck my TI time away from me, but that's just the way it is.

Edited by notwhoyouthink
Link to comment
Share on other sites

gallery_34177_1071_94729.gif

 

I have been doing a considerable amount of fine tuning on my method for using moving sprites in plain TI BASIC. The program lines that enable the sprites and sprite motion are now located within the same program that uses the sprites. There is no longer a need to load and run one program to set up the sprites and then load and run another program to use the sprites. When it starts, the routine will automatically position the first four unused sprites off the screen, with their motions all set to zero so they stay off the screen. After the 4 usable sprites all the rest are automatically turned off. The only setup is that you must define character 159 before activating the sprites.
(Most of this post is updated from my earlier post.)
Below are two programs for you to try out. The first is my original demo program modified to show four sprites and 15 unused character sets in all 15 colors. The second is by “Notwhoyouthink” and is much more polished than mine. You can copy and paste them into into TI BASIC, save if desired and RUN.
1 FOR I=1 TO 128
2 READ X
3 F$=F$&CHR$(X)
4 NEXT I
5 DATA 0,0,0,0,227,0,215,224,1,40,215,204,216,32,131,78,131,212,215,224,131,212,215,224,1,245,4,224
6 DATA 131,196,2,12,67,0,16,17,7,248,55,215,158,142,0,0,0,64,0,21,8,159,212,0,0,3,33,111
7 DATA 0,0,0,0,0,0,0,0,25,202,81,5,77,0,215,224,131,249,215,204,143,60,212,224,0,5,2,140,67,16,17
8 DATA 247,215,224,0,51,215,204,16,0,212,224,0,166,215,224,0,63,215,224,1,153,115,12,212,204,6,12
9 DATA 22,253,4,91,53,103,0,0,131,80,2,4,5,255
100 REM           1ST SPRITE:row=44;col=44;pattern=A4-60=44;white(16)         
110 CALL COLOR(1,5,5)
120 CALL COLOR(2,5,5)
130 CALL COLOR(3,11,5)
140 CALL COLOR(4,1,16)
150 REM          2nd Sprite: row=66;col=66;pattern=a8-60=48;Magenta(14)         
160 CALL COLOR(5,7,7)
170 CALL COLOR(6,7,7)
180 CALL COLOR(7,11,9)
190 CALL COLOR(8,1,14)
200 REM           3rd Sprite:row=88;col=88;pattern=AC-60=4C;dark red(7)early clock on(9)            
210 CALL COLOR(9,9,9)
220 CALL COLOR(10,9,9)
230 CALL COLOR(11,11,13)
240 CALL COLOR(12,9,7)
250 REM         4th Sprite: row=>D0 to hide higher sprites            
260 CALL COLOR(13,3,11)
270 CALL COLOR(14,11,11)
280 CALL COLOR(15,12,1)
290 CALL COLOR(16,1,2)
300 REM                
330 CALL CHAR(146,"0503000007F9")
340 CALL CHAR(147,"FCF4000013E2")
350 CALL CHAR(152,"1122334455667788")
360 CALL CHAR(153,"99AABBCCDDEEFF10")
370 CALL CHAR(154,"1010101010101010")
380 CALL CHAR(155,"1010101010101010")
381 CALL CHAR(159,"0")
390 OPEN #1:F$
400 FOR I=1 TO 255
410 PRINT CHR$(I);
420 NEXT I
422 FOR I=1 TO 4
423 READ A$
424 PRINT A$
425 NEXT I
430 GOTO 430
1000 DATA THIS,IS,A,TEST
100 CALL CLEAR
110 CALL SCREEN(6)
120 FOR I=1 TO 128
122 READ X
130 F$=F$&CHR$(X)
140 NEXT I
150 DATA 0,0,0,0,227,0,215,224,1,40,215,204,216,32,131,78,131,212,215,224,131,212,215,224,1,245,4,224
160 DATA 131,196,2,12,67,0,16,17,7,248,55,215,158,142,0,0,0,64,0,21,8,159,212,0,0,3,33,111
170 DATA 0,0,0,0,0,0,0,0,25,202,81,5,77,0,215,224,131,249,215,204,143,60,212,224,0,5,2,140,67,16,17
180 DATA 247,215,224,0,51,215,204,16,0,212,224,0,166,215,224,0,63,215,224,1,153,115,12,212,204,6,12
190 DATA 22,253,4,91,53,103,0,0,131,80,2,4,5,255
200 FOR X=68 TO 79
210 READ X$
220 CALL CHAR(X,X$)
230 NEXT X
240 CALL COLOR(1,5,5)
250 CALL COLOR(2,5,5)
260 CALL COLOR(3,11,5)
270 CALL COLOR(4,1,16)
280 CALL COLOR(5,5,5)
290 CALL COLOR(6,5,5)
300 CALL COLOR(7,11,9)
310 CALL COLOR(8,1,9)
320 CALL COLOR(9,5,5)
330 CALL COLOR(10,5,5)
340 CALL COLOR(11,11,13)
350 CALL COLOR(12,1,2)
360 CALL COLOR(13,14,1)
370 CALL CHAR(146,"FCF40000FCF4")
380 CALL CHAR(147,"FCF4")
390 CALL CHAR(152,"1122334455667788")
400 CALL CHAR(153,"99AABBCCDDEEFF10")
410 CALL CHAR(154,"1010101010101010")
420 CALL CHAR(155,"1010101010101010")
430 CALL CHAR(159,"0")
440 OPEN #1:F$
450 FOR X=1 TO 143
460 READ R,C,CHAR
470 CALL HCHAR(R,C,CHAR)
480 NEXT X
490 GOTO 490
500 DATA 000F1F3F2B6B7F55
510 DATA 4141202A1F030000
520 DATA 00C0F09868ECDCFC
530 DATA FEFEFEFCF0C00000
540 DATA 000000000000002A
550 DATA 3E3E1F1500000000
560 DATA 0000000000000000
570 DATA 0000000000000000
580 DATA 0F10204054948080
590 DATA 80804040201C0300
600 DATA C030086494122202
610 DATA 010101020C30C000
620 DATA 9,14,200
630 DATA 9,15,200
640 DATA 9,16,200
650 DATA 9,17,200
660 DATA 9,18,200
670 DATA 10,13,200
680 DATA 10,14,200
690 DATA 10,15,200
700 DATA 10,16,200
710 DATA 10,17,200
720 DATA 10,18,200
730 DATA 10,19,200
740 DATA 10,20,200
750 DATA 10,21,200
760 DATA 11,13,232
770 DATA 11,14,232
780 DATA 11,15,232
790 DATA 11,16,240
800 DATA 11,17,240
810 DATA 11,18,160
820 DATA 11,19,240
830 DATA 12,12,232
840 DATA 12,13,240
850 DATA 12,14,232
860 DATA 12,15,240
870 DATA 12,16,240
880 DATA 12,17,240
890 DATA 12,18,160
900 DATA 12,19,240
910 DATA 12,20,240
920 DATA 12,21,240
930 DATA 13,12,232
940 DATA 13,13,240
950 DATA 13,14,232
960 DATA 13,15,232
970 DATA 13,16,240
980 DATA 13,17,240
990 DATA 13,18,240
1000 DATA 13,19,160
1010 DATA 13,20,240
1020 DATA 13,21,240
1030 DATA 13,22,240
1040 DATA 14,13,232
1050 DATA 14,14,240
1060 DATA 14,15,240
1070 DATA 14,16,240
1080 DATA 14,17,240
1090 DATA 14,18,160
1100 DATA 14,19,160
1110 DATA 14,20,160
1120 DATA 14,21,160
1130 DATA 15,14,240
1140 DATA 15,15,240
1150 DATA 15,16,240
1160 DATA 15,17,240
1170 DATA 15,18,240
1180 DATA 15,19,240
1190 DATA 16,13,200
1200 DATA 16,14,200
1210 DATA 16,15,184
1220 DATA 16,16,200
1230 DATA 16,17,200
1240 DATA 16,18,184
1250 DATA 16,19,200
1260 DATA 16,20,200
1270 DATA 17,12,200
1280 DATA 17,13,200
1290 DATA 17,14,200
1300 DATA 17,15,184
1310 DATA 17,16,200
1320 DATA 17,17,200
1330 DATA 17,18,184
1340 DATA 17,19,200
1350 DATA 17,20,200
1360 DATA 17,21,200
1370 DATA 18,11,200
1380 DATA 18,12,200
1390 DATA 18,13,200
1400 DATA 18,14,200
1410 DATA 18,15,184
1420 DATA 18,16,184
1430 DATA 18,17,184
1440 DATA 18,18,184
1450 DATA 18,19,200
1460 DATA 18,20,200
1470 DATA 18,21,200
1480 DATA 18,22,200
1490 DATA 19,11,240
1500 DATA 19,12,240
1510 DATA 19,13,200
1520 DATA 19,14,184
1530 DATA 19,15,240
1540 DATA 19,16,184
1550 DATA 19,17,184
1560 DATA 19,18,240
1570 DATA 19,19,184
1580 DATA 19,20,200
1590 DATA 19,21,240
1600 DATA 19,22,240
1610 DATA 20,11,240
1620 DATA 20,12,240
1630 DATA 20,13,240
1640 DATA 20,14,184
1650 DATA 20,15,184
1660 DATA 20,16,184
1670 DATA 20,17,184
1680 DATA 20,18,184
1690 DATA 20,19,184
1700 DATA 20,20,240
1710 DATA 20,21,240
1720 DATA 20,22,240
1730 DATA 21,11,240
1740 DATA 21,12,240
1750 DATA 21,13,184
1760 DATA 21,14,184
1770 DATA 21,15,184
1780 DATA 21,16,184
1790 DATA 21,17,184
1800 DATA 21,18,184
1810 DATA 21,19,184
1820 DATA 21,20,184
1830 DATA 21,21,240
1840 DATA 21,22,240
1850 DATA 22,13,184
1860 DATA 22,14,184
1870 DATA 22,15,184
1880 DATA 22,18,184
1890 DATA 22,19,184
1900 DATA 22,20,184
1910 DATA 23,12,232
1920 DATA 23,13,232
1930 DATA 23,14,232
1940 DATA 23,19,232
1950 DATA 23,20,232
1960 DATA 23,21,232
1970 DATA 24,11,232
1980 DATA 24,12,232
1990 DATA 24,13,232
2000 DATA 24,14,232
2010 DATA 24,19,232
2020 DATA 24,20,232
2030 DATA 24,21,232
2040 DATA 24,22,232
The sprite magnification can be changed in the first DATA line - the 227 can be a value from 224 to 227 for sprite magnifications 1-4.
These are the BASIC lines needed to create the string that does all the magic. Put these at the beginning of your program, then OPEN #1:F$ at the point where you want the sprites to be activated. Remember to CALL CHAR(159,...) before activating the sprites. In the videos I started with F$ already created which is faster, but it uses values that cannot be pasted.
1 FOR I=1 TO 128
2 READ X
3 F$=F$&CHR$(X)
4 NEXT I
5 DATA 0,0,0,0,227,0,215,224,1,40,215,204,216,32,131,78,131,212,215,224,131,212,215,224,1,245,4,224
6 DATA 131,196,2,12,67,0,16,17,7,248,55,215,158,142,0,0,0,64,0,21,8,159,212,0,0,3,33,111
7 DATA 0,0,0,0,0,0,0,0,25,202,81,5,77,0,215,224,131,249,215,204,143,60,212,224,0,5,2,140,67,16,17
8 DATA 247,215,224,0,51,215,204,16,0,212,224,0,166,215,224,0,63,215,224,1,153,115,12,212,204,6,12
9 DATA 22,253,4,91,53,103,0,0,131,80,2,4,5,255

390 OPEN #1:F$

Here is a method that gives you up to 4 moving sprites using standard TI BASIC, using nothing but BASIC statements. It is similar to the earlier method that offers 32 sprites but no sprite motion. The challenge in making this work is that if you want to use automatic sprite motion the sprite attribute list must start at v0300. The only way TI BASIC can modify those memory locations is via CALL COLOR. In the color table, the first four sprite definitions cannot be accessed but sprites 5-8 can be. So there will be 8 sprites in all; the first 4 are invisible, the next 4 can move automatically, and the ninth has its row set to >D0 to hide the remaining sprites.

Four character definitions from 144 to 147 are used for the sprite motion table. Since the program is using the color table for sprites then there has to be a new color table. I put it so it can be modified by changing the character definitions from 152 to 155.
As with the previous program that gives you 32 sprites, this one exploits a bug in OPEN that allows 128 bytes to be loaded into the scratchpad. This loads some assembly code that waits for an interrupt and then sets the appropriate registers and VDP memory.
The programs above give examples showing how to set up the sprites and I will also give a short description below.
-----------------------------------------------------------------
CALL COLOR is used to define a sprite.
Sprite 1 is defined with COLOR 1-4
Sprite 2 is defined with COLOR 5-8
Sprite 3 is defined with COLOR 9-12
Sprite 4 is defined with COLOR 13-16
It helps to think in hexadecimal for this. For row and column add 1 to each nybble. For Sprite #1
For a row of >83 it should be CALL COLOR(1,9,4)
For a row of >AB it should be CALL COLOR(1,11,12)
For a column of >83 it should be CALL COLOR(2,9,4)
To set the pattern to use, add 7 to the first nybble and 1 to the second.
To use the pattern for “A” (>41) it should be CALL COLOR(3,11,2)
To set the color of the sprite use the normal color value for BASIC. The first nybble should be 1 if you do not want to use the “early clock” or 9 if you want to set the early clock.
To set the color to white (16) it should be CALL COLOR(4,1,16)
To set the color to dark red with early clock on it should be (CALL COLOR(4,9,7)
If you do not wish to use all 4 sprites you can turn off the first unwanted sprite with a row of >D0 which will hide it and all higher sprites
-------------------------------------------------------------------
CALL CHAR 144 to 147 are used to set the sprite velocities.
144 and 145 are set to zero when “OPEN #1:F$ is executed.
For the sprites we care about:
CALL CHAR(146,”0503000007F9”) sets sprite 1 to row velocity=5 and col velocity=3.
Sprite 2 has row velocity=7 and col velocity=-7
CALL CHAR(147,”FCF4”) sets sprite 3 row velocity=-4 and col velocity=-12
(If the row velocity is positive then motion is downward and if the column velocity is positive then motion is to the right.)
---------------------------------------------------------------------
The new color table is set with CALL CHAR 152-155
I recommend using the values that are in the demo:
310 CALL CHAR(152,"1122334455667788")
320 CALL CHAR(153,"99AABBCCDDEEFF10")
330 CALL CHAR(154,"1010101010101010")
340 CALL CHAR(155,"1010101010101010")
The relocated color table lets you define the colors of all 256 characters. Characters 154 and 155 contain the colors of character sets 1 to 16. Above they are set to black on transparent. (You have to subtract 1 from the TI BASIC color codes.) In the example above the unused characters from 0 to 23 and 160 to 255 have their foreground and background colors set to the same color and that gives you an 8x8 block of all possible colors without using any of the normal characters. You can display these on the screen with HCHAR and VCHAR.
The first character of each character set is:
160 Black
168 Medium Green
176 Light Green
184 Dark Blue
192 Light Blue
200 Dark Red
208 Cyan
216 Medium Red
224 Light Red
232 Dark Yellow
240 Light Yellow
248 Dark Green
0 Magenta
8 Gray
16 White
When programming, do not use characters 144 - 147 or 152 – 155 for graphics because they are needed by the sprite routines and color table.
One thing that might cause some head scratching is that I use a scroll routine in the console ROM to kill some time until the TI comes to the interrupt routine. This happens when OPEN #1:F$ is performed. If you are printing a screen you can use a semicolon at the end of the second to last line, then OPEN #1:F$ and then print the last line

 

  • Like 8
Link to comment
Share on other sites

gallery_34177_1071_380354.gif

Earlier I had opined that being able to use auto sprite motion was probably not all that useful. Here's a demo that proves me wrong. The little marching man from Notwhoyouthink's demo has been set into motion by manually updating the sprite table. (CALL COLOR(1...) and CALL COLOR(2,...)) The subroutine that updates the column looks for a keypress and if it finds one it jumps the little guy ahead. He does not land exactly where he should but it is close enough, and you just need to update the row and column to get him exactly where he should be. You can see that here sprite motion is quite useful despite the inability to use CALL LOCATE from XB. (This should be used on the latest version of Classic99. Some earlier ones seem to be slow at handling interrupts, so that sound lists and sprite motions happen too slowly.)

 

I just tried this in Win994a and found that it simply exits Win99.. No colorful screen - it just closes the window. So either Win994a or Classic99 is not behaving properly. I will look into it a little more and maybe transfer it to my real TI to see what happens there. @Casey - if you want to test this you would need to change the 55,215 in line 12 to 55,207.

2 FOR I=1 TO 128
4 READ X
6 F$=F$&CHR$(X)
8 NEXT I
10 DATA 0,0,0,0,226,0,215,224,1,40,215,204,216,32,131,78,131,212,215,224,131,212,215,224,1,245,4,224
12 DATA 131,196,2,12,67,0,16,17,7,248,55,215,158,142,0,0,0,64,0,21,8,159,212,0,0,3,33,111
14 DATA 0,0,0,0,0,0,0,0,25,202,81,5,77,0,215,224,131,249,215,204,143,60,212,224,0,5,2,140,67,16,17
16 DATA 247,215,224,0,51,215,204,16,0,212,224,0,166,215,224,0,63,215,224,1,153,115,12,212,204,6,12
18 DATA 22,253,4,91,53,103,0,0,131,80,2,4,5,255
110 CALL CHAR(146,"0")
120 CALL CHAR(147,"0")
135 CALL CHAR(152,"1122334455667788")
136 CALL CHAR(153,"99AABBCCDDEEFF10")
140 CALL CHAR(154,"1010101010101010")
150 CALL CHAR(155,"1010101010101010")
155 CALL CHAR(159,"0")
160 CALL CHAR(96,"0F1F1C1C1E1F0F03")
170 CALL CHAR(97,"0303070702020203")
180 CALL CHAR(98,"84C4241424C4841F")
190 CALL CHAR(99,"C43C040480804070")
200 CALL CHAR(100,"0F1F1C1C1E1F0F03")
210 CALL CHAR(101,"0303070703030303")
220 CALL CHAR(102,"80C0201020C18204")
230 CALL CHAR(103,"A8502840000080E0")
240 CALL CHAR(104,"0F1F1C1C1E1F0F03")
250 CALL CHAR(105,"030307070305080E")
260 CALL CHAR(106,"80C0201020C08000")
270 CALL CHAR(107,"0040FF4080008070")
280 CALL CLEAR
290 CALL SCREEN(2)
292 OPEN #1:F$
294 CALL HCHAR(18,1,168,192)
300 CALL COLOR(1,8,
310 CALL COLOR(2,1,1)
320 CALL COLOR(4,1,16)
330 REM    sprite walking below            
340 MSB=1
350 LSB=1
360 CALL COLOR(2,MSB,LSB)
370 CALL COLOR(3,13,1)
380 GOSUB 490
390 CALL COLOR(2,MSB,LSB)
400 CALL COLOR(3,13,5)
410 GOSUB 490
420 CALL COLOR(2,MSB,LSB)
430 CALL COLOR(3,13,9)
440 GOSUB 490
450 CALL COLOR(2,MSB,LSB)
460 CALL COLOR(3,13,5)
470 GOSUB 490
480 GOTO 360
490 MSB=MSB-(LSB=16)
500 LSB=LSB+1+16*(LSB=16)
510 CALL KEY(0,K,S)
520 IF S=0 THEN 560
530 CALL CHAR(146,"F008")
531 CALL CHAR(146,"FA08")
532 CALL CHAR(146,"0608")
533 CALL CHAR(146,"1008")
534 CALL CHAR(146,"0")
535 CALL COLOR(1,8,
550 MSB=MSB+1
560 MSB=MSB+16*(MSB>16)
570 RETURN
Edited by senior_falcon
  • Like 6
Link to comment
Share on other sites

Such insanity, I love it! Who has a time machine so we can take these techniques back to 1981?

 

I tried talking to Doc Brown about this, but he mumbled some rubbish about altering the future and sanctity of the time-line and such.

  • Like 3
Link to comment
Share on other sites

gallery_34177_1071_167122.gif

Here is a simple demo using moving sprites with nothing but TI BASIC. Press any key to launch the missile. The animated GIF makes the motion somewhat jerky, but it is smooth on Classic99.

There is no CALL COINC, so how do you determine whether the missile hits the UFO? Actually it is not that hard. You set it up so the UFO always starts at the same location and with the same velocity.

The missile always starts from the same location and launches with the same velocity. Then by counting the number of loops before the key is pressed you can determine at the time of launch whether the

UFO will be intercepted. If it is a miss then you let the missile fly off the screen. If it is a hit you freeze the missile and UFO together, erase them and set off an explosion. The missile flight is just for visual effect.

Hardly a ground breaking game but it does show some of the possibilities for this technique. A bowling game might be possible using this.

I do not know if the timing would be right on real iron, and I think it would be off with a European TI running at 50 Hz.

100 CALL CHAR(159,"0")
110 FOR I=1 TO 128
120 READ X
130 F$=F$&CHR$(X)
140 NEXT I
150 DATA 0,0,0,0,226,0,215,224,1,40,215,204,216,32,131,78,131,212,215,224,131,212,215,224,1,245,4,224
160 DATA 131,196,2,12,67,0,16,17,7,248,55,215,158,142,0,0,0,64,0,21,8,159,212,0,0,3,33,111
170 DATA 0,0,0,0,0,0,0,0,25,202,81,5,77,0,215,224,131,249,215,204,143,60,212,224,0,5,2,140,67,16,17
180 DATA 247,215,224,0,51,215,204,16,0,212,224,0,166,215,224,0,63,215,224,1,153,115,12,212,204,6,12
190 DATA 22,253,4,91,53,103,0,0,131,80,2,4,5,255
200 CALL CHAR(146,"0")
210 CALL CHAR(147,"0")
220 REM  colors 
230 CALL CHAR(152,"1122334455667788")
240 CALL CHAR(153,"99AABBCCDDEEFF10")
250 CALL CHAR(154,"F0F0F0F0F0F0F0F0")
260 CALL CHAR(155,"F0F0F0F0F0F0F0F0")
270 REM  missile 
280 CALL CHAR(92,"0103030303030304")
290 CALL CHAR(93,"0")
300 CALL CHAR(94,"0080808080808040")
310 CALL CHAR(95,"0")
320 REM  saucer patterns 
330 CALL CHAR(96,"01033FFFDEFF3F07")
340 CALL CHAR(97,"0")
350 CALL CHAR(98,"0080F8FEF6FEF8C0")
360 CALL CHAR(99,"0")
370 REM  explosion 
380 CALL CHAR(100,"0041055000052189")
390 CALL CHAR(101,"2310060110044001")
400 CALL CHAR(102,"80220008806200A0")
410 CALL CHAR(103,"D580248008A00200")
420 OPEN #1:F$
430 REM  saucer 
440 CALL CLEAR
450 CALL SCREEN(2)
460 CALL CLEAR
470 PRINT "HITS:";HIT;"         MISSES:";MISS;
480 REM  missile
490 CALL COLOR(1,12,
500 CALL COLOR(2,8,12)
510 CALL COLOR(3,12,13)
520 CALL COLOR(4,1,9)
530 REM  saucer
540 CALL COLOR(5,2,1)
550 CALL COLOR(6,1,1)
560 CALL COLOR(7,13,1)
570 CALL COLOR(8,1,
580 X=0
590 N=0
600 CALL CHAR(146,"00000000000A")
610 CALL KEY(0,K,S)
620 X=X+1
630 IF X=73 THEN 840
640 IF S<1 THEN 610
650 CALL CHAR(146,"E0000000000A")
660 IF (X<19)+(X>25)THEN 690
670 TOP=106
680 GOTO 700
690 TOP=130
700 N=N+1
710 IF N<TOP THEN 700
720 IF TOP=130 THEN 810
730 CALL CHAR(146,"0")
740 HIT=HIT+1
750 CALL COLOR(3,13,5)
760 CALL COLOR(4,1,16)
770 CALL COLOR(8,1,1)
780 FOR I=1 TO 300
790 NEXT I
800 GOTO 850
810 CALL CHAR(146,"00000000000A")
815 CALL KEY(0,K,S)
820 X=X+1
830 IF X<55 THEN 815
840 MISS=MISS+1
850 GOTO 460
Edited by senior_falcon
  • Like 3
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

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