Skip to content

Commit

Permalink
Updated for VDP 1.04
Browse files Browse the repository at this point in the history
  • Loading branch information
breakintoprogram committed Oct 3, 2023
1 parent 51a77f5 commit 3f9bff0
Show file tree
Hide file tree
Showing 15 changed files with 151 additions and 86 deletions.
2 changes: 1 addition & 1 deletion tests/circle_2.bas
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
30 CLS
40 GCOL 0,16+RND(64)
50 MOVE RND(1280),RND(1024)
60 PLOT &94,RND(1280),RND(1024)
60 PLOT 149,RND(1280),RND(1024)
70 GOTO 40
139 changes: 72 additions & 67 deletions tests/cube.bas
Original file line number Diff line number Diff line change
Expand Up @@ -4,70 +4,75 @@
40 MODE 1
50 PRINT "3D Cube Demo"
60 PRINT
70 INPUT "SOLID (S) OR WIREFRAME (W)";F$: FILLED%=F$="S"
80 INPUT "MODE (0 TO 2)";M%
110 MODE M%
115 VDU 29,640;512;:OD=128
120 :
130 REM Initialise the data
140 READ CN%
150 DIM X%(CN%),Y%(CN%),Z%(CN%),A%(CN%),B%(CN%)
160 FOR I%=1 TO CN%: READ X%(I%),Y%(I%),Z%(I%):NEXT
170 READ TS%
180 DIM S%(TS%,5)
190 FOR I%=1 TO TS%: READ S%(I%,1),S%(I%,2),S%(I%,3),S%(I%,4),S%(I%,5):NEXT
200 REM Variables
210 THETA=0:PSI=0:PHI=0
220 XD=0:YD=0
230 SD=1024
240 REM Transform
250 FOR I%=1 TO CN%
260 REM Rotate
270 XX=X%(I%):YY=Y%(I%):ZZ=Z%(I%)
280 Y=YY*COS(PHI/180*PI)-ZZ*SIN(PHI/180*PI)
290 ZZ=YY*SIN(PHI/180*PI)+ZZ*COS(PHI/180*PI)
300 X=XX*COS(THETA/180*PI)-ZZ*SIN(THETA/180*PI)
310 ZZ=XX*SIN(THETA/180*PI)+ZZ*COS(THETA/180*PI)
320 XX=X*COS(PSI/180*PI)-Y*SIN(PSI/180*PI)
330 YY=X*SIN(PSI/180*PI)+Y*COS(PSI/180*PI)
340 REM Transform
350 XX=XX+XD:YY=YY+YD
360 REM Perspective
370 A%(I%)=XX*SD/(OD-ZZ)
380 B%(I%)=YY*SD/(OD-ZZ)
390 NEXT
400 REM Draw
410 CLS
415 I%=RND(-55)
420 FOR I%=1 TO TS%
425 GCOL 0,S%(I%,5)
430 C1%=S%(I%,1):C2%=S%(I%,2):C3%=S%(I%,3):C4%=S%(I%,4)
440 X1=A%(C1%):X2=A%(C2%):X3=A%(C3%):X4=A%(C4%)
450 Y1=B%(C1%):Y2=B%(C2%):Y3=B%(C3%):Y4=B%(C4%)
460 IF X1*(Y2-Y3)+X2*(Y3-Y1)+X3*(Y1-Y2) > 0 THEN GOTO 530
480 IF FILLED%=0 THEN GOTO 520
490 MOVE X1,Y1:MOVE X2,Y2:PLOT 85,X3,Y3
500 MOVE X3,Y3:MOVE X4,Y4:PLOT 85,X1,Y1
510 GOTO 530
520 MOVE X1,Y1:PLOT 5,X2,Y2:PLOT 5,X3,Y3:PLOT 5,X4,Y4:PLOT 5,X1,Y1
530 NEXT
540 PHI=PHI+4
550 THETA=THETA-1
560 GOTO 250
570 REM DATA
580 DATA 8
590 DATA -20,20,20
600 DATA 20,20,20
610 DATA -20,-20,20
620 DATA 20,-20,20
630 DATA -20,20,-20
640 DATA 20,20,-20
650 DATA -20,-20,-20
660 DATA 20,-20,-20
670 DATA 6
680 DATA 1,2,4,3,9
690 DATA 7,8,6,5,10
700 DATA 2,6,8,4,11
710 DATA 3,7,5,1,12
720 DATA 3,4,8,7,13
730 DATA 1,5,6,2,14
70 PRINT "Valid video modes:"
80 PRINT "0-6, 8-18, 129, 130, 132-134, 136-143"
90 PRINT "Modes greater than 128 are double-buffered"
100 PRINT
110 INPUT "SOLID (S) OR WIREFRAME (W)";F$: FILLED%=F$="S"
120 INPUT "MODE";M%
130 MODE M%
140 VDU 29,640;512;:OD=128
150 :
160 REM Initialise the data
170 READ CN%
180 DIM X%(CN%),Y%(CN%),Z%(CN%),A%(CN%),B%(CN%)
190 FOR I%=1 TO CN%: READ X%(I%),Y%(I%),Z%(I%):NEXT
200 READ TS%
210 DIM S%(TS%,5)
220 FOR I%=1 TO TS%: READ S%(I%,1),S%(I%,2),S%(I%,3),S%(I%,4),S%(I%,5):NEXT
230 REM Variables
240 THETA=0:PSI=0:PHI=0
250 XD=0:YD=0
260 SD=1024
270 REM Transform
280 FOR I%=1 TO CN%
290 REM Rotate
300 XX=X%(I%):YY=Y%(I%):ZZ=Z%(I%)
310 Y=YY*COS(PHI/180*PI)-ZZ*SIN(PHI/180*PI)
320 ZZ=YY*SIN(PHI/180*PI)+ZZ*COS(PHI/180*PI)
330 X=XX*COS(THETA/180*PI)-ZZ*SIN(THETA/180*PI)
340 ZZ=XX*SIN(THETA/180*PI)+ZZ*COS(THETA/180*PI)
350 XX=X*COS(PSI/180*PI)-Y*SIN(PSI/180*PI)
360 YY=X*SIN(PSI/180*PI)+Y*COS(PSI/180*PI)
370 REM Transform
380 XX=XX+XD:YY=YY+YD
390 REM Perspective
400 A%(I%)=XX*SD/(OD-ZZ)
410 B%(I%)=YY*SD/(OD-ZZ)
420 NEXT
430 REM Draw
440 CLS
450 I%=RND(-55)
460 FOR I%=1 TO TS%
470 GCOL 0,S%(I%,5)
480 C1%=S%(I%,1):C2%=S%(I%,2):C3%=S%(I%,3):C4%=S%(I%,4)
490 X1=A%(C1%):X2=A%(C2%):X3=A%(C3%):X4=A%(C4%)
500 Y1=B%(C1%):Y2=B%(C2%):Y3=B%(C3%):Y4=B%(C4%)
510 IF X1*(Y2-Y3)+X2*(Y3-Y1)+X3*(Y1-Y2) > 0 THEN GOTO 570
520 IF FILLED%=0 THEN GOTO 560
530 MOVE X1,Y1:MOVE X2,Y2:PLOT 85,X3,Y3
540 MOVE X3,Y3:MOVE X4,Y4:PLOT 85,X1,Y1
550 GOTO 570
560 MOVE X1,Y1:PLOT 5,X2,Y2:PLOT 5,X3,Y3:PLOT 5,X4,Y4:PLOT 5,X1,Y1
570 NEXT
580 PHI=PHI+4
590 THETA=THETA-1
600 VDU 23,0,&C3
610 GOTO 280
620 REM DATA
630 DATA 8
640 DATA -20,20,20
650 DATA 20,20,20
660 DATA -20,-20,20
670 DATA 20,-20,20
680 DATA -20,20,-20
690 DATA 20,20,-20
700 DATA -20,-20,-20
710 DATA 20,-20,-20
720 DATA 6
730 DATA 1,2,4,3,9
740 DATA 7,8,6,5,10
750 DATA 2,6,8,4,11
760 DATA 3,7,5,1,12
770 DATA 3,4,8,7,13
780 DATA 1,5,6,2,14
2 changes: 1 addition & 1 deletion tests/fireworks.bas
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
10 REM Palette Animation Example
20 :
30 MODE 1
30 MODE 0
40 C=1:Y=-1
50 FOR I=0 TO 2000
60 IF Y<0 X=640:Y=10:VX=COS(RND(1)*PI)*9:VY=20+RND(1)*30:MOVE X,Y
Expand Down
7 changes: 7 additions & 0 deletions tests/keyboard_3.bas
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
10 CLS
20 PRINT TAB(0,0);
30 PRINT "UP ";INKEY(-58);" "
40 PRINT "DOWN ";INKEY(-42);" "
50 PRINT "LEFT ";INKEY(-26);" "
60 PRINT "RIGHT ";INKEY(-122);" "
70 GOTO 20
53 changes: 53 additions & 0 deletions tests/life.bas
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
10 REM Conway's Game of Life
20 :
30 ON ERROR GOTO 510
40 W%=38
50 H%=26
60 DIM L%(W%,H%), N%(W%,H%)
70 MODE 8
80 VDU 23,1,0
90 FOR I%=1 TO W%
100 FOR J%=1 TO H%
110 IF RND(1)>=.7 N%(I%,J%)=1 ELSE N%(I%,J%)=0
120 NEXT
130 NEXT
140 :
150 COLOUR 13
160 FOR I%=0 TO W%+1
170 PRINT TAB(I%,0);"+"
180 PRINT TAB(I%,H%+1);"+"
190 NEXT
200 FOR I%=0 TO H%+1
210 PRINT TAB(0,I%);"+"
220 PRINT TAB(W%+1,I%);"+"
230 NEXT
240 G%=0
250 COLOUR 14
260 PRINT TAB(0,H%+3);"Generation: ";G%;
270 COLOUR 15
280 FOR J%=1 TO H%
290 PRINT TAB(1,J%);
300 FOR I%=1 TO W%
310 C%=N%(I%,J%): L%(I%,J%)=C%
320 IF C% VDU 42 ELSE VDU 32
330 NEXT
340 NEXT
350 FOR I%=1 TO W%
360 FOR J%=1 TO H%
370 C%=0
380 FOR K%=I%-1 TO I%+1
390 IF K%=0 OR K%>W% THEN 440
400 FOR M%=J%-1 TO J%+1
410 IF M%=0 OR M%>H% OR (K%=I% AND M%=J%) GOTO 430
420 C%=C%+L%(K%,M%)
430 NEXT
440 NEXT
450 IF C%=2 THEN N%(I%,J%)=L%(I%,J%) ELSE N%(I%,J%)=-(C%=3)
460 NEXT
470 NEXT
480 G%=G%+1
490 GOTO 250
500 :
510 ON ERROR OFF
520 VDU 23,1,1
530 PRINT TAB(0,0);
6 changes: 3 additions & 3 deletions tests/mandlebrot_1.bas
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
10 REM PROGRAM TO DRAW MANDLEBROT SET
20 REM P.MAINWARING, MARCH 19TH 1990
30 :
40 MODE 2
40 MODE 8
50 ITERS=32
60 SCALE=1
70 XRANGE=-2.5
Expand All @@ -15,7 +15,7 @@
150 DATA 0,0,1,1,0,1,1,0
160 :
170 XSTP=1280/320
180 YSTP=1024/200
180 YSTP=1024/240
190 COLS=64
200 MAXX=1280
210 MAXY=1024
Expand All @@ -37,7 +37,7 @@
370 IT=IT+1
380 UNTIL IT=ITERS OR ZM>=4
390 C%=COLS-1-INT(IT/(ITERS/(COLS-1)))
430 GCOL 0,C%+16
430 GCOL 0,C%
440 PLOT 69,K%,J%
450 NEXT
460 NEXT
Expand Down
2 changes: 1 addition & 1 deletion tests/palette_1.bas
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
10 REM Palette Test
20 :
30 MODE 2
30 MODE 8
40 FOR A%=128 TO 143
50 COLOUR A%
60 PRINT " ";
Expand Down
4 changes: 2 additions & 2 deletions tests/scroll_1.bas
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
10 REM Scrolling Stars Demo
15 :
20 MODE 2
20 MODE 8
30 VDU 23,1,0
40 *FX 19
50 GCOL 0,RND(16)
60 PLOT &40,1279,RND(1024)
60 PLOT 69,1279,RND(1024)
70 VDU 23,7,0,1,1
80 GOTO 40
4 changes: 2 additions & 2 deletions tests/scroll_2.bas
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
10 REM Scramble
20 :
30 MODE 2
30 MODE 8
40 VDU 23,1,0
50 LET Y%=512
60 *FX 19
70 GCOL 0,5
80 DRAW 1279,0,1279,Y%
90 GCOL 0,15
100 PLOT &40,1279,Y%
100 PLOT 69,1279,Y%
110 VDU 23,7,0,1,1
120 Y%=Y%+4*(RND(3)-2)
130 GOTO 60
Binary file modified tests/shadows.bas
Binary file not shown.
2 changes: 1 addition & 1 deletion tests/sprites_1.bas
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
10 REM Sprite Demo
20 :
30 MODE 2
30 MODE 8
40 SW%=320
50 SH%=200
60 C%=16
Expand Down
4 changes: 2 additions & 2 deletions tests/sprites_2.bas
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
10 REM Sprite Demo
20 :
30 MODE 2
30 MODE 8
40 SW%=320
50 SH%=200
60 C%=16
Expand All @@ -12,7 +12,7 @@
120 VDU 23,27,1,W%;H%;
130 FOR I%=1 TO W%*H%
140 READ B%
150 VDU B%,B%,B%,B%
150 VDU 255,B%,B%,B%
160 NEXT
170 :
180 REM Set up some sprites
Expand Down
4 changes: 2 additions & 2 deletions tests/sprites_3.bas
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
10 REM Sprite Demo
20 :
30 MODE 1
30 MODE 0
40 SW%=320
50 SH%=200
60 C%=64
Expand Down Expand Up @@ -81,7 +81,7 @@
810 ]
820 NEXT
830 :
840 MODE 2
840 MODE 8
850 :
860 REM Create a simple bitmap
870 :
Expand Down
4 changes: 2 additions & 2 deletions tests/sprites_4.bas
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
10 REM Sprite Demo
20 :
30 MODE 1
30 MODE 0
40 SW%=320
50 SH%=200
60 C%=32
Expand Down Expand Up @@ -93,7 +93,7 @@
930 PROCloadSprite("../resources/pacman1.rgb",0,16,16)
940 PROCloadSprite("../resources/pacman2.rgb",1,16,16)
950 :
960 MODE 2
960 MODE 8
970 :
980 REM Set up some sprites
990 :
Expand Down
4 changes: 2 additions & 2 deletions tests/sprites_5.bas
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
10 REM Sprite Demo
20 :
30 MODE 1
30 MODE 0
40 SW%=320
50 SH%=200
60 C%=32
Expand Down Expand Up @@ -93,7 +93,7 @@
930 PROCloadSprite("../resources/pacman1.rgb",0,16,16)
940 PROCloadSprite("../resources/pacman2.rgb",1,16,16)
950 :
960 MODE 2
960 MODE 8
970 :
980 REM Set up some sprites
990 :
Expand Down

0 comments on commit 3f9bff0

Please sign in to comment.