├── demo ├── src │ ├── autoexec.bas │ ├── xbasic.bin │ ├── animtile.bas │ ├── select.bas │ ├── ddungeon.bas │ ├── scroll_t.bas │ ├── sshooter.bas │ └── tdungeon.bas ├── output │ ├── demo.dsk │ └── demo.rom └── README.md ├── Preface.pdf ├── examples ├── src │ ├── play.bas │ ├── sound.bas │ ├── animtile.bas │ ├── s_sprite.bas │ ├── font.bas │ ├── ddungeon.bas │ ├── colision.bas │ ├── scroll_t.bas │ ├── sshooter.bas │ └── tdungeon.bas ├── output │ ├── examples.dsk │ └── examples.rom └── README.md ├── scripts ├── MSX-BASIC-KUN.MX1 ├── README.md ├── runMSX.sh ├── runMSXTurbo.sh ├── runMSXProgram.sh └── createRelease.sh ├── README.md └── LICENSE /demo/src/autoexec.bas: -------------------------------------------------------------------------------- 1 | 10 BLOAD "xbasic.bin",R 2 | 20 RUN "select.bas" 3 | -------------------------------------------------------------------------------- /Preface.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/plattysoft/Modern-MSX-BASIC-Game-Dev/HEAD/Preface.pdf -------------------------------------------------------------------------------- /examples/src/play.bas: -------------------------------------------------------------------------------- 1 | 10 TIME=0 2 | 20 PLAY "L4T120O4V8 S13M128 CCGGAAG2 R64 FFEEDDC2" 3 | 30 PRINT TIME 4 | -------------------------------------------------------------------------------- /demo/output/demo.dsk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/plattysoft/Modern-MSX-BASIC-Game-Dev/HEAD/demo/output/demo.dsk -------------------------------------------------------------------------------- /demo/output/demo.rom: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/plattysoft/Modern-MSX-BASIC-Game-Dev/HEAD/demo/output/demo.rom -------------------------------------------------------------------------------- /demo/src/xbasic.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/plattysoft/Modern-MSX-BASIC-Game-Dev/HEAD/demo/src/xbasic.bin -------------------------------------------------------------------------------- /scripts/MSX-BASIC-KUN.MX1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/plattysoft/Modern-MSX-BASIC-Game-Dev/HEAD/scripts/MSX-BASIC-KUN.MX1 -------------------------------------------------------------------------------- /examples/output/examples.dsk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/plattysoft/Modern-MSX-BASIC-Game-Dev/HEAD/examples/output/examples.dsk -------------------------------------------------------------------------------- /examples/output/examples.rom: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/plattysoft/Modern-MSX-BASIC-Game-Dev/HEAD/examples/output/examples.rom -------------------------------------------------------------------------------- /scripts/README.md: -------------------------------------------------------------------------------- 1 | 2 | This scripts rely on an environment variable OPENMSX_PATH, if it is not found it defaults to the standard path on MacOS, if you are using Linux or Windows, you might want to set the environment variable yourself 3 | -------------------------------------------------------------------------------- /scripts/runMSX.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | if [[ -z "${OPENMSX_PATH}" ]]; then 3 | OPENMSX_PATH=/Applications/openMSX.app/Contents/MacOS 4 | fi 5 | PROGRAM_NAME=$1 6 | killall openmsx 7 | rm -Rf /tmp/tmpdsk 2>/dev/null 8 | mkdir /tmp/tmpdsk 9 | cp $PROGRAM_NAME /tmp/tmpdsk/autoexec.bas 10 | $OPENMSX_PATH/openmsx -diska /tmp/tmpdsk 11 | -------------------------------------------------------------------------------- /scripts/runMSXTurbo.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | if [[ -z "${OPENMSX_PATH}" ]]; then 3 | OPENMSX_PATH=/Applications/openMSX.app/Contents/MacOS 4 | fi 5 | PROGRAM_NAME=$1 6 | killall openmsx 7 | rm -Rf /tmp/tmpdsk 2>/dev/null 8 | mkdir /tmp/tmpdsk 9 | cp $PROGRAM_NAME /tmp/tmpdsk/autoexec.bas 10 | $OPENMSX_PATH/openmsx -diska /tmp/tmpdsk -cart MSX-BASIC-KUN.MX1 11 | -------------------------------------------------------------------------------- /examples/src/sound.bas: -------------------------------------------------------------------------------- 1 | 100 SOUND 8,&B11000 2 | 110 SOUND 7,&B10111110 3 | 120 SOUND 12,&H0: SOUND 11, &H80 4 | 5 | 200 READ R1, R0, L 6 | 210 SOUND 0, R0:SOUND 1, R1 7 | 220 SOUND 13, 13 8 | 230 IF R1=0 AND R0=0 THEN END 9 | 240 TIME=0 10 | 250 IF TIME<25*L GOTO 250 11 | 260 GOTO 200 12 | 13 | 1000 DATA &H1,&HAC,1, &H1,&HAC,1, &H1,&H1D,1, &H1,&H1D,1 14 | 1010 DATA &H0,&HFE,1, &H0,&HFE,1, &H1,&H1D, 2 15 | 1020 DATA &H0, &H0, &H0 16 | -------------------------------------------------------------------------------- /demo/README.md: -------------------------------------------------------------------------------- 1 | This is the demo for the book. It includes selected examples with slight modifications and a launcher. 2 | 3 | ![Screen Shot 2021-07-29 at 19 26 44](https://user-images.githubusercontent.com/1717361/127546119-cbf73854-1f4d-4dfb-bf84-b5635eb17232.png) 4 | 5 | The way the demo is structured is an example of how to use multiple BASIC files in one project to separate functionality. 6 | 7 | [Try the example on WebMSX (dsk)](https://webmsx.org/?MACHINE=MSX1E&DISKA=https://github.com/plattysoft/Modern-MSX-BASIC-Game-Dev/raw/main/demo/output/demo.dsk) 8 | 9 | [Try the example on WebMSX (rom)](https://webmsx.org/?MACHINE=MSX1E&DISKA=https://github.com/plattysoft/Modern-MSX-BASIC-Game-Dev/raw/main/demo/output/demo.dsk) 10 | -------------------------------------------------------------------------------- /examples/src/animtile.bas: -------------------------------------------------------------------------------- 1 | 100 COLOR 15,1,1 2 | 110 SCREEN 2 3 | 4 | 120 ' LOAD PATTERNS AND COLORS 5 | 120 FOR I=0 TO &H1F 6 | 130 READ R 7 | 140 VPOKE I,R 8 | 150 VPOKE &H2000+I, &H20 9 | 160 NEXT I 10 | 11 | 200 ' POPULATE THE SCREEN 12 | 200 FOR I=&H1800 TO &H18FF 13 | 210 VPOKE I, I MOD 2 14 | 220 NEXT I 15 | 16 | 300 ' MAIN LOOP 17 | 300 IF CF=1 THEN CF=0 ELSE CF=1 18 | 310 S=16+CF*8 19 | 320 FOR I=0 TO 7 20 | 330 VPOKE 8+I, VPEEK(S+I) 21 | 340 VPOKE &H2000+8+I, VPEEK(&H2000+S+I) 22 | 350 NEXT I 23 | 360 IF TIME<20 THEN 360 ELSE TIME=0 24 | 370 GOTO 300 25 | 26 | 1000 DATA &H00,&H00,&H00,&H00,&H00,&H00,&H00,&H00 27 | 1010 DATA &H18,&H3C,&H7E,&HDB,&HFF,&H24,&H5A,&HA5 28 | 1020 DATA &H18,&H3C,&H7E,&HDB,&HFF,&H24,&H5A,&HA5 29 | 1030 DATA &H18,&H3C,&H7E,&HDB,&HFF,&H5A,&H81,&H42 30 | -------------------------------------------------------------------------------- /scripts/runMSXProgram.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | if [[ -z "${OPENMSX_PATH}" ]]; then 3 | OPENMSX_PATH=/Applications/openMSX.app/Contents/MacOS 4 | fi 5 | PROGRAM_NAME=$1 6 | EXTENSION=${PROGRAM_NAME##*\.} 7 | ACTUAL_NAME=${PROGRAM_NAME%\.*} 8 | MSX_FILE_NAME="${ACTUAL_NAME::8}.${EXTENSION::3}" 9 | 10 | WORKING_DIR=$2 11 | killall openmsx 12 | ( 13 | echo "set renderer SDLGL-PP"; 14 | echo "set power on"; 15 | echo "debug set_watchpoint write_mem 0xfffe {[debug read \"memory\" 0xfffe] == 0} {diska insert $WORKING_DIR}"; 16 | echo "type_via_keybuf \\r\\r" 17 | echo "type_via_keybuf poke-2,0\\r"; 18 | echo "type_via_keybuf run\"$MSX_FILE_NAME\r"; 19 | ) | $OPENMSX_PATH/openmsx -control stdio 20 | -------------------------------------------------------------------------------- /examples/src/s_sprite.bas: -------------------------------------------------------------------------------- 1 | 100 COLOR 15,1,1 2 | 110 SCREEN 2,2,0 3 | 4 | 120 DEFINT A-Z 5 | 130 X=96 6 | 7 | 140 FOR I=0 TO 31 8 | 150 READ A$:A=VAL("&H"+A$) 9 | 160 VPOKE I,A 10 | 170 VPOKE &H2000+I,&HF0 11 | 180 VPOKE &H3800+I,A 12 | 190 NEXT I 13 | 14 | 200 S=STICK(0) 15 | 230 IF S=3 THEN X=X+8 16 | 270 IF S=7 THEN X=X-8 17 | 18 | 290 TIME=0 19 | 300 IF TIME<3 GOTO 300 20 | 21 | 310 PUT SPRITE 0,(X,48),14,0 22 | 23 | 320 C=X\8 24 | 25 | 330 VPOKE &H1860+C ,0 26 | 331 VPOKE &H1860+C+1,2 27 | 332 VPOKE &H1880+C ,1 28 | 333 VPOKE &H1880+C+1,3 29 | 30 | 340 VPOKE &H1860+C-1,4 31 | 341 VPOKE &H1860+C+2,4 32 | 342 VPOKE &H1880+C-1,4 33 | 343 VPOKE &H1880+C+2,4 34 | 35 | 390 GOTO 200 36 | 37 | 1060 ' SPACESHIP 38 | 1070 DATA 01,01,01,03,03,02,06,07,0F,0E,1C,3C,7E,F7,E3,C1 39 | 1080 DATA 00,00,00,80,80,80,C0,C0,E0,E0,70,78,FC,DE,8E,06 40 | -------------------------------------------------------------------------------- /demo/src/animtile.bas: -------------------------------------------------------------------------------- 1 | 100 COLOR 15,1,1 2 | 110 SCREEN 2 3 | 4 | 120 ' LOAD PATTERNS AND COLORS 5 | 120 FOR I=0 TO &H1F 6 | 130 READ R 7 | 140 VPOKE I,R 8 | 150 VPOKE &H2000+I, &H20 9 | 160 NEXT I 10 | 11 | 170 STRIG(0) ON: ON STRIG GOSUB 400 12 | 13 | 200 ' POPULATE THE SCREEN 14 | 200 FOR I=&H1800 TO &H18FF 15 | 210 VPOKE I, I MOD 2 16 | 220 NEXT I 17 | 18 | 300 ' MAIN LOOP 19 | 300 IF CF=1 THEN CF=0 ELSE CF=1 20 | 310 S=16+CF*8 21 | 320 FOR I=0 TO 7 22 | 330 VPOKE 8+I, VPEEK(S+I) 23 | 340 VPOKE &H2000+8+I, VPEEK(&H2000+S+I) 24 | 350 NEXT I 25 | 360 IF TIME<20 THEN 360 ELSE TIME=0 26 | 370 GOTO 300 27 | 28 | 400 run"select.bas" 29 | 30 | 1000 DATA &H00,&H00,&H00,&H00,&H00,&H00,&H00,&H00 31 | 1010 DATA &H18,&H3C,&H7E,&HDB,&HFF,&H24,&H5A,&HA5 32 | 1020 DATA &H18,&H3C,&H7E,&HDB,&HFF,&H24,&H5A,&HA5 33 | 1030 DATA &H18,&H3C,&H7E,&HDB,&HFF,&H5A,&H81,&H42 34 | -------------------------------------------------------------------------------- /examples/src/font.bas: -------------------------------------------------------------------------------- 1 | 10 SCREEN 1 2 | 20 LOCATE 0,10:PRINT "ABCDEFGHIJKLMNOPQRSTUVWXYZ" 3 | 30 ST=ASC("A")*8 4 | 40 FOR I=0 TO 207 5 | 50 READ R$ 6 | 60 VPOKE ST+I, VAL("&H"+R$) 7 | 70 NEXT I 8 | 80 GOTO 80 9 | 10 | 1000 DATA 02,06,0E,1E,3E,76,E6,76,FE,CC,D8,FE,CC,D8,F0,E0 11 | 1010 DATA 7E,FC,C0,C0,C0,C0,FC,7E,FE,FE,CC,D8,F0,E0,C0,80 12 | 1020 DATA FE,FE,00,FE,FE,00,FE,FE,FF,FE,C0,FC,F8,C0,C0,80 13 | 1030 DATA 7E,FC,C0,C0,C2,C6,FE,7F,C6,C6,C6,FE,FE,C6,C6,84 14 | 1040 DATA 38,38,38,38,38,38,30,20,02,06,06,06,06,06,7E,FE 15 | 1050 DATA CE,DC,F8,F0,F8,DC,CE,86,40,C0,C0,C0,C0,C0,FE,FC 16 | 1060 DATA 82,C6,EE,FE,FE,D6,C6,C6,C6,E6,F6,FE,DE,CE,C6,42 17 | 1070 DATA 7C,FE,C6,C6,C6,C6,FE,7C,FC,FE,06,FE,FC,C0,C0,80 18 | 1080 DATA 7C,FE,C6,C6,D6,FE,7C,10,C8,DC,CE,DC,F8,DC,CE,86 19 | 1090 DATA FE,FE,80,FE,FE,02,FE,FE,FE,FC,30,30,30,30,30,20 20 | 1100 DATA 82,C6,C6,C6,C6,C6,FE,7C,03,06,CC,D8,F0,E0,C0,80 21 | 1110 DATA C6,C6,D6,FE,FE,EE,C6,82,86,CE,FC,78,3C,7E,E6,C2 22 | 1120 DATA 87,CE,FC,78,30,30,30,20,7E,FE,1C,38,70,E0,FE,FC 23 | -------------------------------------------------------------------------------- /demo/src/select.bas: -------------------------------------------------------------------------------- 1 | 10 SCREEN 1,0,0: KEY OFF: COLOR 2,1,1 2 | 20 LOCATE 0,0:PRINT "Modern MSX BASIC game dev." 3 | 30 LOCATE 2,6:PRINT "Space shooter" 4 | 40 LOCATE 2,8:PRINT "Dungeon crawler (draw)" 5 | 50 LOCATE 2,10:PRINT "Dungeon crawler (tiles)" 6 | 60 LOCATE 2,12:PRINT "Scroll tiles" 7 | 70 LOCATE 2,14:PRINT "Animating tiles" 8 | 80 LOCATE 0,20:PRINT "By Raul Portales (2021)" 9 | 10 | 90 FOR I=0 TO 7 11 | 91 READ R: A$=A$+CHR$(R) 12 | 92 NEXT I 13 | 93 SPRITE$(0)=A$ 14 | 15 | 95 Y=48 16 | 17 | 100 PUT SPRITE 0,(16,Y),15,0 18 | 110 IF STRIG(0) THEN GOTO 300 19 | 120 S=STICK(0) 20 | 130 IF S=0 THEN 100 21 | 210 IF S=1 THEN Y=Y-16: IF Y<48 THEN Y=112 22 | 220 IF S=5 THEN Y=Y+16: IF Y>112 THEN Y=48 23 | 230 PUT SPRITE 0,(16,Y),15,0 24 | 240 TIME=0 25 | 250 IF TIME<10 THEN 250 ELSE 100 26 | 27 | 300 IF Y=48 THEN RUN"sshooter.bas" 28 | 310 IF Y=64 THEN RUN"ddungeon.bas" 29 | 320 IF Y=80 THEN RUN"tdungeon.bas" 30 | 330 IF Y=96 THEN RUN"scroll_t.bas" 31 | 340 IF Y=112 THEN RUN"animtile.bas" 32 | 350 END 33 | 34 | 1010 DATA &H08,&H0C,&HFE,&HFF,&HFE,&H0C,&H08,&H00 35 | -------------------------------------------------------------------------------- /examples/src/ddungeon.bas: -------------------------------------------------------------------------------- 1 | 100 COLOR 15,4,4:SCREEN 2,0,0 2 | 110 GOSUB 2000 3 | 4 | 200 X=9: Y=9 5 | 210 LINE (8,8)-(128,128),15,B 6 | 220 LINE (8,32)-(80,40),15,BF 7 | 230 LINE -(72,64),15,BF 8 | 240 LINE (128,80)-STEP(-80,8),15,BF 9 | 250 LINE -STEP(8,-36),15,BF 10 | 260 LINE (127,127)-(120,120),5,BF 11 | 270 LINE (24,87)-(47,111),8,BF 12 | 13 | 300 ON STICK(0) GOTO 310,400,330,400,350,400,370,400 14 | 301 GOTO 400 15 | 16 | 310 P1=POINT(X,Y-1):P2=POINT(X+6,Y-1) 17 | 311 IF P1=4 AND P2=4 THEN Y=Y-1 18 | 312 GOTO 400 19 | 330 P1=POINT(X+7,Y):P2=POINT(X+7,Y+6) 20 | 331 IF P1=4 AND P2=4 THEN X=X+1 21 | 332 GOTO 400 22 | 350 P1=POINT(X,Y+7):P2=POINT(X+6,Y+7) 23 | 351 IF P1=4 AND P2=4 THEN Y=Y+1 24 | 352 GOTO 400 25 | 370 P1=POINT(X-1,Y):P2=POINT(X-1,Y+6) 26 | 371 IF P1=4 AND P2=4 THEN X=X-1 27 | 372 GOTO 400 28 | 29 | 400 IF P1=8 OR P2=8 THEN GOSUB 900 30 | 410 IF P1=5 OR P2=5 THEN GOSUB 950 31 | 32 | 700 PUT SPRITE 0,(X,Y-1),8,0 33 | 34 | 800 GOTO 300 35 | 36 | 900 END 37 | 38 | 950 END 39 | 40 | 1000 DATA 38,7C,FE,FE,FE,7C,38 41 | 1010 DATA * 42 | 43 | 2000 S=BASE(9) 44 | 2010 READ R$ 45 | 2020 IF R$="*" THEN RETURN ELSE VPOKE S,VAL("&H"+R$):S=S+1 46 | 2030 GOTO 2010 47 | -------------------------------------------------------------------------------- /demo/src/ddungeon.bas: -------------------------------------------------------------------------------- 1 | 100 SCREEN 2,0,0 2 | 110 GOSUB 2000 3 | 4 | 200 X=9: Y=9 5 | 210 LINE (8,8)-(128,128),15,B 6 | 220 LINE (8,32)-(80,40),15,BF 7 | 230 LINE -(72,64),15,BF 8 | 240 LINE (128,80)-STEP(-80,8),15,BF 9 | 250 LINE -STEP(8,-36),15,BF 10 | 260 LINE (127,127)-(120,120),5,BF 11 | 270 LINE (24,87)-(47,111),8,BF 12 | 13 | 300 ON STICK(0) GOTO 310,400,330,400,350,400,370,400 14 | 301 GOTO 400 15 | 16 | 310 P1=POINT(X,Y-1):P2=POINT(X+6,Y-1) 17 | 311 IF P1<5 AND P2<5 THEN Y=Y-1 18 | 312 GOTO 400 19 | 330 P1=POINT(X+7,Y):P2=POINT(X+7,Y+6) 20 | 331 IF P1<5 AND P2<5 THEN X=X+1 21 | 332 GOTO 400 22 | 350 P1=POINT(X,Y+7):P2=POINT(X+6,Y+7) 23 | 351 IF P1<5 AND P2<5 THEN Y=Y+1 24 | 352 GOTO 400 25 | 370 P1=POINT(X-1,Y):P2=POINT(X-1,Y+6) 26 | 371 IF P1<5 AND P2<5 THEN X=X-1 27 | 372 GOTO 400 28 | 29 | 400 IF P1=8 OR P2=8 THEN GOSUB 900 30 | 410 IF P1=5 OR P2=5 THEN GOSUB 950 31 | 420 IF STRIG(0) THEN GOSUB 900 32 | 33 | 700 PUT SPRITE 0,(X,Y-1),2,0 34 | 35 | 800 GOTO 300 36 | 37 | 900 run"select.bas" 38 | 39 | 950 run"select.bas" 40 | 41 | 1000 DATA 38,7C,FE,FE,FE,7C,38 42 | 1010 DATA * 43 | 44 | 2000 S=BASE(9) 45 | 2010 READ R$ 46 | 2020 IF R$="*" THEN RETURN ELSE VPOKE S,VAL("&H"+R$):S=S+1 47 | 2030 GOTO 2010 48 | -------------------------------------------------------------------------------- /examples/src/colision.bas: -------------------------------------------------------------------------------- 1 | 100 COLOR 2,1,1: SCREEN 2,2,0 2 | 110 GOSUB 2000 3 | 120 X1=32:Y1=32:X2=64:Y2=32 4 | 130 SC=4:BC=4 5 | 6 | 200 PUT SPRITE 0,(X1,Y1),11,0 7 | 210 PUT SPRITE 1,(X2,Y2),2,1 8 | 220 PUT SPRITE 2,(0,0),BC,2 9 | 230 PUT SPRITE 3,(16,0),SC,2 10 | 11 | 250 SC=4:SPRITE ON: ON SPRITE GOSUB 600 12 | 300 S=STICK(0) 13 | 310 IF S=1 THEN Y1=Y1-1 14 | 320 IF S=3 THEN X1=X1+1 15 | 330 IF S=5 THEN Y1=Y1+1 16 | 340 IF S=7 THEN X1=X1-1 17 | 350 A$=INKEY$ 18 | 360 IF A$="w" THEN Y2=Y2-1 19 | 370 IF A$="d" THEN X2=X2+1 20 | 380 IF A$="s" THEN Y2=Y2+1 21 | 390 IF A$="a" THEN X2=X2-1 22 | 400 IF ABS(X1-X2)<16 AND ABS(Y1-Y2)<16 THEN BC=8 ELSE BC=4 23 | 500 GOTO 200 24 | 25 | 600 SPRITE OFF: SC=8 26 | 610 RETURN 27 | 28 | 1000 DATA 00,00,3F,3F,30,30,30,30,30,30,30,30,3F,3F,00,00 29 | 1010 DATA 00,00,FC,FC,00,00,00,00,00,00,00,00,FC,FC,00,00 30 | 1020 DATA 00,00,3F,3F,00,00,00,00,00,00,00,00,3F,3F,00,00 31 | 1030 DATA 00,00,FC,FC,0C,0C,0C,0C,0C,0C,0C,0C,FC,FC,00,00 32 | 1040 DATA 00,07,0F,1F,3F,7F,7F,7F,7F,7F,3F,1F,0F,07,00,00 33 | 1050 DATA 00,C0,E0,F0,F8,FC,FC,FC,FC,FC,F8,F0,E0,C0,00,00 34 | 1060 DATA * 35 | 36 | 2000 ' LOAD SPRITES 37 | 2010 S=BASE(9) 38 | 2020 READ R$: IF R$="*" THEN RETURN ELSE VPOKE S,VAL("&H"+R$):S=S+1:GOTO 2020 39 | -------------------------------------------------------------------------------- /scripts/createRelease.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | if [[ -z "${OPENMSX_PATH}" ]]; then 3 | OPENMSX_PATH=/Applications/openMSX.app/Contents/MacOS 4 | fi 5 | PROJECT_DIR=$1 6 | 7 | cd $PROJECT_DIR 8 | PWD=${PWD} 9 | GAME_NAME=`basename $PWD` 10 | 11 | echo "Building release for $GAME_NAME" 12 | ( 13 | echo "set throttle off"; 14 | echo "diskmanipulator create $GAME_NAME.dsk 720"; 15 | echo "virtual_drive $GAME_NAME.dsk"; 16 | echo "diskmanipulator import virtual_drive src/"; 17 | 18 | echo "debug set_watchpoint write_mem 0xfffe {[debug read \"memory\" 0xfffe] == 0} {diska insert $GAME_NAME.dsk}"; 19 | 20 | echo "set power on"; 21 | echo "type_via_keybuf \\r\\r" 22 | echo "type_via_keybuf poke-2,0\\r"; 23 | 24 | echo "debug set_watchpoint write_mem 0xfffe {[debug read \"memory\" 0xfffe] == 1} {quit}"; 25 | for filename in src/*.bas 26 | do 27 | # Remove the path 28 | PROGRAM_NAME=${filename##*/} 29 | # Take the extension 30 | EXTENSION=${PROGRAM_NAME##*\.} 31 | # Take the first 8 characters 32 | ACTUAL_NAME=${PROGRAM_NAME%\.*} 33 | # Put them back together 34 | FILE="${ACTUAL_NAME::8}.${EXTENSION::3}" 35 | echo "type_via_keybuf load\"$FILE\r"; 36 | echo "type_via_keybuf save\"$FILE\r"; 37 | done 38 | 39 | echo "type_via_keybuf poke-2,1\\r"; 40 | ) | $OPENMSX_PATH/openmsx -control stdio 41 | 42 | mkdir output 2>/dev/null 43 | rm output/* 2>/dev/null 44 | 45 | mv $GAME_NAME.dsk output/ 46 | 47 | dsk2rom -fac 1 output/$GAME_NAME.dsk output/$GAME_NAME.rom 48 | -------------------------------------------------------------------------------- /examples/src/scroll_t.bas: -------------------------------------------------------------------------------- 1 | 10 COLOR 2, 1, 1 2 | 20 SCREEN 2,2,0 3 | 30 CALL TURBO ON 4 | 40 DEFINT A-Z 5 | 6 | 100 FOR J=0 TO 63 7 | 110 READ R 8 | 120 VPOKE J, R 9 | 121 VPOKE &H800+J, R 10 | 122 VPOKE &H1000+J, R 11 | 140 NEXT J 12 | 13 | 160 FOR I=0 TO 7 14 | 165 READ R 15 | 170 FOR J=0 TO 7 16 | 180 VPOKE &H2000+I*8+J, R 17 | 181 VPOKE &H2800+I*8+J, R 18 | 182 VPOKE &H3000+I*8+J, R 19 | 190 NEXT J 20 | 195 NEXT I 21 | 22 | 500 ' MAKE A MAP 23 | 510 FOR Y=0 TO 23 24 | 520 FOR X=0 TO 31 25 | 530 VPOKE &H1800+X+Y*&H20, RND(1)*8 26 | 540 NEXT X 27 | 550 NEXT Y 28 | 29 | 600 S=STICK(0) 30 | 610 IF S=1 THEN GOSUB 700 31 | 620 IF S=3 THEN GOSUB 750 32 | 630 IF S=5 THEN GOSUB 800 33 | 640 IF S=7 THEN GOSUB 850 34 | 690 GOTO 600 35 | 36 | 700 ' MOVING UP 37 | 701 FOR Y=0 TO 22 38 | 702 FOR X=0 TO 31 39 | 703 T=VPEEK (&H1800+X+(Y+1)*&H20) 40 | 704 VPOKE &H1800+X+Y*&H20, T 41 | 705 NEXT X 42 | 706 NEXT Y 43 | 708 FOR X=0 TO 31 44 | 710 VPOKE &H1800+X+23*&H20, RND(1)*8 45 | 711 NEXT X 46 | 749 RETURN 47 | 48 | 750 ' MOVING RIGHT 49 | 751 FOR Y=0 TO 23 50 | 752 FOR X=31 TO 1 STEP -1 51 | 753 T=VPEEK (&H17FF+X+Y*&H20) 52 | 754 VPOKE &H1800+X+Y*&H20, T 53 | 755 NEXT X 54 | 756 NEXT Y 55 | 757 FOR Y=0 TO 23 56 | 758 VPOKE &H1800+Y*&H20, RND(1)*8 57 | 759 NEXT Y 58 | 761 RETURN 59 | 60 | 800 ' MOVING DOWN 61 | 801 FOR Y=23 TO 1 STEP -1 62 | 802 FOR X=0 TO 31 63 | 803 T=VPEEK (&H1800+X+(Y-1)*&H20) 64 | 804 VPOKE &H1800+X+Y*&H20, T 65 | 805 NEXT X 66 | 806 NEXT Y 67 | 808 FOR X=0 TO 31 68 | 810 VPOKE &H1800+X, RND(1)*8 69 | 811 NEXT X 70 | 849 RETURN 71 | 72 | 850 ' MOVING LEFT 73 | 851 FOR Y=0 TO 23 74 | 852 FOR X=0 TO 30 75 | 853 T=VPEEK (&H1801+X+Y*&H20) 76 | 854 VPOKE &H1800+X+Y*&H20, T 77 | 855 NEXT X 78 | 856 NEXT Y 79 | 857 FOR Y=0 TO 23 80 | 858 VPOKE &H181F+Y*&H20, RND(1)*8 81 | 859 NEXT Y 82 | 83 | 860 RETURN 84 | 85 | 1000 DATA &HFF, &HFF, &HBF, &H9F, &H8F, &H87, &H83, &H81 86 | 1010 DATA &HFF, &HFF, &HFD, &HF9, &HF1, &HE1, &HC1, &H81 87 | 1020 DATA &H81, &H83, &H87, &H8F, &H9F, &HBF, &HFF, &HFF 88 | 1030 DATA &H81, &HC1, &HE1, &HF1, &HF9, &HFD, &HFF, &HFF 89 | 1040 DATA &H90, &H40, &H00, &H40, &H00, &H10, &H00, &H82 90 | 1050 DATA &H90, &H40, &H00, &H40, &H00, &H10, &H00, &H82 91 | 1060 DATA &H50, &H20, &H00, &H48, &H20, &H90, &H40, &H40 92 | 1070 DATA &H80, &H20, &H80, &H00, &H41, &H00, &H84, &H10 93 | 94 | 2040 DATA &H45, &H45, &H45, &H45, &H23, &H23, &HAB, &HAB 95 | -------------------------------------------------------------------------------- /examples/README.md: -------------------------------------------------------------------------------- 1 | # Examples 2 | 3 | ## animtile.bas 4 | 5 | Example of animating all instances of a tile by changing the pattern on the VRAM using VPOKE. 6 | 7 | Part of Chapter 7 8 | 9 | ## colision.bas 10 | 11 | Comparison between hardware sprite colision and bounding boxes. 12 | 13 | One sprite moves with cursors, the other with WASD. One circle lights with sprite collision, the other with box colision. 14 | 15 | ![Screen Shot 2021-02-22 at 21 23 27](https://user-images.githubusercontent.com/1717361/124996078-42e89680-e040-11eb-86cc-795ef49976eb.png) 16 | 17 | Part of Chapter 5 18 | 19 | ## ddungeon.bas 20 | 21 | Dungeon Crawler using drawing commands (mostly LINE) 22 | 23 | ![Screen Shot 2021-04-20 at 23 52 26](https://user-images.githubusercontent.com/1717361/124996513-f487c780-e040-11eb-8d1d-b0a3cdbab8d8.png) 24 | 25 | Part of chapter Chapter 6 26 | 27 | ## font.bas 28 | 29 | How to remap the font of an MSX 30 | 31 | ![Screen Shot 2021-05-09 at 23 10 48](https://user-images.githubusercontent.com/1717361/124996147-5eec3800-e040-11eb-9f93-45507d870500.png) 32 | 33 | Part of chapter Chapter 7 34 | 35 | ## play.bas 36 | 37 | Playing "Twinkle twinkle little star" using PLAY. 38 | 39 | Part of Chapter 8 40 | 41 | ## s_sprite.bas 42 | 43 | Comparison between software and hardware sprites (white ship is software, gray ship is hardware) 44 | 45 | ![Screen Shot 2021-05-23 at 13 07 55](https://user-images.githubusercontent.com/1717361/124996187-70354480-e040-11eb-8524-721c4a27c86a.png) 46 | 47 | Part of Chatper 5 48 | 49 | ## scroll_t.bas 50 | 51 | Scrolling tiles on the 4 directions using the cursors. Full screen. Requires MSX-BASIC-KUN 52 | 53 | ![Screen Shot 2021-05-23 at 13 03 21](https://user-images.githubusercontent.com/1717361/124996271-91963080-e040-11eb-83b5-a7edabc15a27.png) 54 | 55 | Part of Chapter 7 56 | 57 | ## sound.bas 58 | 59 | Plays "Twinkle twinkle little star" using SOUND 60 | 61 | Part of Chapter 8 62 | 63 | ## sshooter.bas 64 | 65 | Space Shooter game build over chapters 4 and 5. Move with the cursors, fire with space. Requires MSX-BASIC-KUN 66 | 67 | ![yass](https://user-images.githubusercontent.com/1717361/124996601-1e40ee80-e041-11eb-9938-f71f49f5aeb1.png) 68 | 69 | ## tdungeon.bas 70 | 71 | Dungeon Crawler, equivalent to ddungeon, but built using tiles. 72 | 73 | ![Screen Shot 2021-05-11 at 23 48 02](https://user-images.githubusercontent.com/1717361/124996431-d4f09f00-e040-11eb-87cb-424bb9099bf1.png) 74 | 75 | 76 | Part of Chapter 7 77 | -------------------------------------------------------------------------------- /demo/src/scroll_t.bas: -------------------------------------------------------------------------------- 1 | 10 COLOR 2, 1, 1 2 | 20 SCREEN 2,2,0 3 | 30 CALL TURBO ON 4 | 40 DEFINT A-Z 5 | 6 | 100 FOR J=0 TO 63 7 | 110 READ R 8 | 120 VPOKE J, R 9 | 121 VPOKE &H800+J, R 10 | 122 VPOKE &H1000+J, R 11 | 140 NEXT J 12 | 13 | 160 FOR I=0 TO 7 14 | 165 READ R 15 | 170 FOR J=0 TO 7 16 | 180 VPOKE &H2000+I*8+J, R 17 | 181 VPOKE &H2800+I*8+J, R 18 | 182 VPOKE &H3000+I*8+J, R 19 | 190 NEXT J 20 | 195 NEXT I 21 | 22 | 500 ' MAKE A MAP 23 | 510 FOR Y=0 TO 23 24 | 520 FOR X=0 TO 31 25 | 530 VPOKE &H1800+X+Y*&H20, RND(1)*8 26 | 540 NEXT X 27 | 550 NEXT Y 28 | 29 | 600 S=STICK(0) 30 | 610 IF S=1 THEN GOSUB 700 31 | 620 IF S=3 THEN GOSUB 750 32 | 630 IF S=5 THEN GOSUB 800 33 | 640 IF S=7 THEN GOSUB 850 34 | 650 if STRIG(0) THEN GOTO 900 35 | 690 GOTO 600 36 | 37 | 700 ' MOVING UP 38 | 701 FOR Y=0 TO 22 39 | 702 FOR X=0 TO 31 40 | 703 T=VPEEK (&H1800+X+(Y+1)*&H20) 41 | 704 VPOKE &H1800+X+Y*&H20, T 42 | 705 NEXT X 43 | 706 NEXT Y 44 | 708 FOR X=0 TO 31 45 | 710 VPOKE &H1800+X+23*&H20, RND(1)*8 46 | 711 NEXT X 47 | 749 RETURN 48 | 49 | 750 ' MOVING RIGHT 50 | 751 FOR Y=0 TO 23 51 | 752 FOR X=31 TO 1 STEP -1 52 | 753 T=VPEEK (&H17FF+X+Y*&H20) 53 | 754 VPOKE &H1800+X+Y*&H20, T 54 | 755 NEXT X 55 | 756 NEXT Y 56 | 757 FOR Y=0 TO 23 57 | 758 VPOKE &H1800+Y*&H20, RND(1)*8 58 | 759 NEXT Y 59 | 761 RETURN 60 | 61 | 800 ' MOVING DOWN 62 | 801 FOR Y=23 TO 1 STEP -1 63 | 802 FOR X=0 TO 31 64 | 803 T=VPEEK (&H1800+X+(Y-1)*&H20) 65 | 804 VPOKE &H1800+X+Y*&H20, T 66 | 805 NEXT X 67 | 806 NEXT Y 68 | 808 FOR X=0 TO 31 69 | 810 VPOKE &H1800+X, RND(1)*8 70 | 811 NEXT X 71 | 849 RETURN 72 | 73 | 850 ' MOVING LEFT 74 | 851 FOR Y=0 TO 23 75 | 852 FOR X=0 TO 30 76 | 853 T=VPEEK (&H1801+X+Y*&H20) 77 | 854 VPOKE &H1800+X+Y*&H20, T 78 | 855 NEXT X 79 | 856 NEXT Y 80 | 857 FOR Y=0 TO 23 81 | 858 VPOKE &H181F+Y*&H20, RND(1)*8 82 | 859 NEXT Y 83 | 84 | 860 RETURN 85 | 86 | 900 CALL TURBO OFF 87 | 910 run "select.bas" 88 | 89 | 1000 DATA &HFF, &HFF, &HBF, &H9F, &H8F, &H87, &H83, &H81 90 | 1010 DATA &HFF, &HFF, &HFD, &HF9, &HF1, &HE1, &HC1, &H81 91 | 1020 DATA &H81, &H83, &H87, &H8F, &H9F, &HBF, &HFF, &HFF 92 | 1030 DATA &H81, &HC1, &HE1, &HF1, &HF9, &HFD, &HFF, &HFF 93 | 1040 DATA &H90, &H40, &H00, &H40, &H00, &H10, &H00, &H82 94 | 1050 DATA &H90, &H40, &H00, &H40, &H00, &H10, &H00, &H82 95 | 1060 DATA &H50, &H20, &H00, &H48, &H20, &H90, &H40, &H40 96 | 1070 DATA &H80, &H20, &H80, &H00, &H41, &H00, &H84, &H10 97 | 98 | 2000 DATA &H45, &H45, &H45, &H45, &H23, &H23, &HAB, &HAB 99 | -------------------------------------------------------------------------------- /examples/src/sshooter.bas: -------------------------------------------------------------------------------- 1 | 100 COLOR 15,1,1 2 | 110 SCREEN 2,2,0 3 | 120 DEFINT A-Z 4 | 130 GOSUB 2000 5 | 6 | 199 CALL TURBO ON 7 | 200 DIM EX(3),EY(3),EV(3),EW(3) 8 | 210 FOR I=0 TO 2 9 | 220 EX(I)=EX(I)=I*16 10 | 230 EY(I)=-16 11 | 240 EV(I)=0:EW(I)=0 12 | 250 NEXT I 13 | 260 T=0:ES=0 14 | 270 X=50:Y=100 15 | 16 | 290 ON SPRITE GOSUB 800 17 | 18 | 300 ON STICK(0) GOTO 310,320,330,340,350,360,370,380 19 | 305 GOTO 400 20 | 310 Y=Y-2:GOTO 400 21 | 320 Y=Y-2:X=X+2:GOTO 400 22 | 330 X=X+2:GOTO 400 23 | 340 Y=Y+2:X=X+2:GOTO 400 24 | 350 Y=Y+2:GOTO 400 25 | 360 Y=Y+2:X=X-2:GOTO 400 26 | 370 X=X-2:GOTO 400 27 | 380 Y=Y-2:X=X-2:GOTO 400 28 | 400 IF X<0 THEN X=0 29 | 410 IF X>120 THEN X=120 30 | 420 IF Y<0 THEN Y=0 31 | 430 IF Y>160 THEN Y=160 32 | 33 | 500 IF STRIG(0) AND BC<>15 THEN BX=X+7:BY=Y-3:BC=15 34 | 510 IF BC=15 THEN BY=BY-2: IF BY<0 THEN BX=160:BC=0 35 | 36 | 600 T=T+1:IF T=90 THEN T=0 37 | 610 IF (T MOD 10)=0 THEN IF ES=0 THEN ES=1 ELSE ES=0 38 | 620 IF (T MOD 30)=0 THEN SP=T\30:EW(SP)=2:EV(SP)=RND(1)*4-2:EY(SP)=0:EX(SP)=RND(1)*120 39 | 630 FOR I=0 TO 2 40 | 640 EX(I)=EX(I)+EV(I):EY(I)=EY(I)+EW(I) 41 | 650 IF EX(I)<0 THEN EX(I)=0:EV(I)=-EV(I) 42 | 660 IF EX(I)>120 THEN EX(I)=120:EV(I)=-EV(I) 43 | 670 IF EY(I)>160 THEN EY(I)=-16:EX(I)=I*16:EV(I)=0:EW(I)=0 44 | 680 NEXT I 45 | 46 | 700 SPRITE OFF 47 | 710 PUT SPRITE 0,(X,Y),15,2 48 | 720 PUT SPRITE 1,(X,Y),4,3 49 | 730 PUT SPRITE 2,(BX,BY),BC,4 50 | 740 FOR I=0 TO 2 51 | 750 PUT SPRITE I+3,(EX(I),EY(I)),2,ES 52 | 760 NEXT I 53 | 770 SPRITE ON 54 | 780 IF TIME<2 GOTO 780 ELSE TIME=0 55 | 790 GOTO 300 56 | 57 | 800 SPRITE OFF 58 | 810 FOR I=0 TO 2 59 | 820 'Check between enemy and spaceship 60 | 820 IF EX(I)+8>=X AND X+16>=EX(I) AND EY(I)+8>=Y AND Y+16>=EY(I) THEN GOSUB 900 61 | 830 'Check between enemy and bullet 62 | 830 IF EX(I)+8>=BX AND BX+1>=EX(I) AND EY(I)+8>=BY AND BY+3>=EY(I) THEN BX=160:BC=0:EY(I)=-16:EX(I)=I*16:EV(I)=0:EW(I)=0 63 | 840 NEXT I 64 | 850 RETURN 65 | 66 | 900 END 67 | 68 | 1000 ' Enemy sprite 1 69 | 1010 DATA 20,91,BF,EE,FF,3F,20,40,00,00,00,00,00,00,00,00 70 | 1020 DATA 80,20,A0,E0,E0,80,80,40,00,00,00,00,00,00,00,00 71 | 1030 ' Enemy sprite 2 72 | 1040 DATA 20,11,3F,6E,FF,BF,A0,1B,00,00,00,00,00,00,00,00 73 | 1050 DATA 80,00,80,C0,E0,A0,A0,00,00,00,00,00,00,00,00,00 74 | 1060 ' Spaceship 75 | 1070 DATA 01,01,01,03,03,02,06,07,0F,0E,1C,3C,7E,F7,E3,C1 76 | 1080 DATA 00,00,00,80,80,80,C0,C0,E0,E0,70,78,FC,DE,8E,06 77 | 1090 ' Spaceship color detail 78 | 1100 DATA 00,00,00,00,00,01,01,00,00,01,03,03,01,00,00,00 79 | 1110 DATA 00,00,00,00,00,00,00,00,00,00,80,80,00,00,00,00 80 | 1120 ' Bullet 81 | 1130 DATA 80,80,80,00,00,00,00,00,00,00,00,00,00,00,00,00 82 | 1140 DATA 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00 83 | 1150 DATA * 84 | 85 | 2000 'LOAD SPRITES 86 | 2010 S=&H3800 87 | 2020 READ R$: IF R$="*" THEN RETURN 88 | 2030 VPOKE S,VAL("&H"+R$) 89 | 2040 S=S+1:GOTO 2020 90 | -------------------------------------------------------------------------------- /demo/src/sshooter.bas: -------------------------------------------------------------------------------- 1 | 100 COLOR 15,1,1 2 | 110 SCREEN 2,2,0 3 | 120 DEFINT A-Z 4 | 130 GOSUB 2000 5 | 6 | 199 CALL TURBO ON 7 | 200 DIM EX(4),EY(4),EV(4),EW(4) 8 | 210 FOR I=0 TO 3 9 | 220 EX(I)=EX(I)=I*16 10 | 230 EY(I)=-16 11 | 240 EV(I)=0:EW(I)=0 12 | 250 NEXT I 13 | 260 T=0:ES=0 14 | 270 X=50:Y=100 15 | 16 | 280 LINE (0,0)-(136,176),15,B 17 | 281 FOR I=0 TO 25 18 | 282 PSET(RND(1)*132+2, RND(1)*172+2) 19 | 283 NEXT I 20 | 21 | 290 ON SPRITE GOSUB 800 22 | 23 | 300 ON STICK(0) GOTO 310,320,330,340,350,360,370,380 24 | 305 GOTO 400 25 | 310 Y=Y-2:GOTO 400 26 | 320 Y=Y-2:X=X+2:GOTO 400 27 | 330 X=X+2:GOTO 400 28 | 340 Y=Y+2:X=X+2:GOTO 400 29 | 350 Y=Y+2:GOTO 400 30 | 360 Y=Y+2:X=X-2:GOTO 400 31 | 370 X=X-2:GOTO 400 32 | 380 Y=Y-2:X=X-2:GOTO 400 33 | 400 IF X<0 THEN X=0 34 | 410 IF X>120 THEN X=120 35 | 420 IF Y<0 THEN Y=0 36 | 430 IF Y>160 THEN Y=160 37 | 38 | 500 IF STRIG(0) AND BC<>15 THEN BX=X+7:BY=Y-3:BC=15 39 | 510 IF BC=15 THEN BY=BY-2: IF BY<0 THEN BX=160:BC=0 40 | 41 | 600 T=T+1:IF T=120 THEN T=0 42 | 610 IF (T MOD 10)=0 THEN IF ES=0 THEN ES=1 ELSE ES=0 43 | 620 IF (T MOD 30)=0 THEN SP=T\30:EW(SP)=2:EV(SP)=RND(1)*4-2:EY(SP)=0:EX(SP)=RND(1)*120 44 | 630 FOR I=0 TO 3 45 | 640 EX(I)=EX(I)+EV(I):EY(I)=EY(I)+EW(I) 46 | 650 IF EX(I)<0 THEN EX(I)=0:EV(I)=-EV(I) 47 | 660 IF EX(I)>126 THEN EX(I)=126:EV(I)=-EV(I) 48 | 670 IF EY(I)>160 THEN EY(I)=-16:EX(I)=I*16:EV(I)=0:EW(I)=0 49 | 680 NEXT I 50 | 51 | 700 SPRITE OFF 52 | 710 PUT SPRITE 0,(X,Y),15,2 53 | 720 PUT SPRITE 1,(X,Y),4,3 54 | 730 PUT SPRITE 2,(BX,BY),BC,4 55 | 740 FOR I=0 TO 3 56 | 750 PUT SPRITE I+3,(EX(I),EY(I)),2,ES 57 | 760 NEXT I 58 | 770 SPRITE ON 59 | 780 IF TIME<2 GOTO 780 ELSE TIME=0 60 | 790 GOTO 300 61 | 62 | 800 SPRITE OFF 63 | 810 FOR I=0 TO 3 64 | 820 IF EX(I)+8>=X AND X+16>=EX(I) AND EY(I)+8>=Y AND Y+16>=EY(I) THEN GOSUB 900 65 | 830 IF EX(I)+8>=BX AND BX+1>=EX(I) AND EY(I)+8>=BY AND BY+3>=EY(I) THEN BX=160:BC=0:EY(I)=-16:EX(I)=I*16:EV(I)=0:EW(I)=0 66 | 840 NEXT I 67 | 850 RETURN 68 | 69 | 900 CALL TURBO OFF 70 | 910 run "select.bas" 71 | 72 | 1000 ' Enemy sprite 1 73 | 1010 DATA 20,91,BF,EE,FF,3F,20,40,00,00,00,00,00,00,00,00 74 | 1020 DATA 80,20,A0,E0,E0,80,80,40,00,00,00,00,00,00,00,00 75 | 1030 ' Enemy sprite 2 76 | 1040 DATA 20,11,3F,6E,FF,BF,A0,1B,00,00,00,00,00,00,00,00 77 | 1050 DATA 80,00,80,C0,E0,A0,A0,00,00,00,00,00,00,00,00,00 78 | 1060 ' Spaceship 79 | 1070 DATA 01,01,01,03,03,02,06,07,0F,0E,1C,3C,7E,F7,E3,C1 80 | 1080 DATA 00,00,00,80,80,80,C0,C0,E0,E0,70,78,FC,DE,8E,06 81 | 1090 ' Spaceship color detail 82 | 1100 DATA 00,00,00,00,00,01,01,00,00,01,03,03,01,00,00,00 83 | 1110 DATA 00,00,00,00,00,00,00,00,00,00,80,80,00,00,00,00 84 | 1120 ' Bullet 85 | 1130 DATA 80,80,80,00,00,00,00,00,00,00,00,00,00,00,00,00 86 | 1140 DATA 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00 87 | 1150 DATA * 88 | 89 | 2000 'LOAD SPRITES 90 | 2010 S=&H3800 91 | 2020 READ R$: IF R$="*" THEN RETURN 92 | 2030 VPOKE S,VAL("&H"+R$) 93 | 2040 S=S+1:GOTO 2020 94 | -------------------------------------------------------------------------------- /examples/src/tdungeon.bas: -------------------------------------------------------------------------------- 1 | 100 COLOR 15,1,1 2 | 110 DEFINT A-Z 3 | 120 SCREEN 2,2,0 4 | 130 GOSUB 10000 5 | 140 X=8:Y=8 6 | 7 | 200 PUT SPRITE 0,(X,Y-1),2,0 8 | 9 | 300 ON STICK(0) GOTO 310,301,330,301,350,301,370,301 10 | 301 P1=VPEEK(&H1800+X\8+(Y\8)*32):P2=P1 11 | 309 GOTO 400 12 | 310 P1=VPEEK(&H1800+X\8+((Y-1)\8)*32) 13 | 311 P2=VPEEK(&H1800+(X+6)\8+((Y-1)\8)*32) 14 | 312 IF P1<1 AND P2<1 THEN Y=Y-1 15 | 313 GOTO 400 16 | 330 P1=VPEEK(&H1800+(X+7)\8+((Y)\8)*32) 17 | 331 P2=VPEEK(&H1800+(X+7)\8+((Y+6)\8)*32) 18 | 332 IF P1<1 AND P2<1 THEN X=X+1 19 | 333 GOTO 400 20 | 350 P1=VPEEK(&H1800+(X)\8+((Y+7)\8)*32) 21 | 351 P2=VPEEK(&H1800+(X+6)\8+((Y+7)\8)*32) 22 | 352 IF P1<1 AND P2<1 THEN Y=Y+1 23 | 353 GOTO 400 24 | 370 P1=VPEEK(&H1800+(X-1)\8+((Y)\8)*32) 25 | 371 P2=VPEEK(&H1800+(X-1)\8+((Y+6)\8)*32) 26 | 372 IF P1<1 AND P2<1 THEN X=X-1 27 | 373 GOTO 400 28 | 29 | 400 IF P1=2 OR P2=2 THEN GOSUB 600 30 | 410 IF P1=3 OR P2=3 THEN GOSUB 700 31 | 500 GOTO 200 32 | 33 | 600 END 34 | 35 | 700 END 36 | 37 | 1000 DATA 00,00,00,00,00,00,00,00 38 | 1010 DATA 00,7F,7F,7F,00,F7,F7,F7 39 | 1020 DATA FD,EE,DF,33,FD,EE,DF,33 40 | 1030 DATA 3C,7F,DB,FF,FF,DB,7E,3C 41 | 1040 DATA * 42 | 1100 DATA 00,00,00,00,00,00,00,00 43 | 1110 DATA E0,E0,E0,E0,E0,E0,E0,E0 44 | 1120 DATA 68,68,68,68,68,68,68,68 45 | 1130 DATA D0,D0,D0,D0,D0,D0,D0,D0 46 | 1140 DATA * 47 | 1200 DATA 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 48 | 1210 DATA 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 49 | 1220 DATA 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 50 | 1230 DATA 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 51 | 1240 DATA 1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 52 | 1250 DATA 1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 53 | 1260 DATA 1,0,0,0,0,0,1,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 54 | 1270 DATA 1,0,0,0,0,0,1,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 55 | 1280 DATA 1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 56 | 1290 DATA 1,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 57 | 1300 DATA 1,0,0,2,2,2,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 58 | 1310 DATA 1,0,0,2,2,2,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 59 | 1320 DATA 1,0,0,2,2,2,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 60 | 1330 DATA 1,0,0,0,0,0,0,0,0,0,0,0,0,0,3,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 61 | 1340 DATA 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 62 | 1350 DATA * 63 | 64 | 1400 DATA 38,7C,FE,FE,FE,7C,38 65 | 1410 DATA * 66 | 67 | 10000 GOSUB 10100 68 | 10010 GOSUB 10200 69 | 10020 GOSUB 10300 70 | 10030 GOSUB 10400 71 | 10050 RETURN 72 | 73 | 10100 'LOAD PATTERNS 74 | 10110 S=0 75 | 10120 READ R$ 76 | 10130 IF R$="*" THEN RETURN ELSE R=VAL("&H"+R$) 77 | 10140 VPOKE S,R 78 | 10150 VPOKE 2048+S,R 79 | 10160 VPOKE 4096+S,R 80 | 10170 S=S+1:GOTO 10120 81 | 82 | 10200 'LOAD COLORS 83 | 10210 S=0 84 | 10220 READ R$ 85 | 10230 IF R$="*" THEN RETURN ELSE R=VAL("&H"+R$) 86 | 10240 VPOKE &H2000+S,R 87 | 10250 VPOKE &H2800+S,R 88 | 10260 VPOKE &H3000+S,R 89 | 10270 S=S+1:GOTO 10220 90 | 91 | 10300 'LOAD NAMES 92 | 10310 S=&H1800 93 | 10320 READ R$ 94 | 10330 IF R$="*" THEN RETURN 95 | 10340 VPOKE S,VAL("&H"+R$) 96 | 10350 S=S+1:GOTO 10320 97 | 98 | 10400 'LOAD SPRITES 99 | 10410 S=&H3800 100 | 10420 READ R$ 101 | 10430 IF R$="*" THEN RETURN ELSE VPOKE S,VAL("&H"+R$):S=S+1 102 | 10440 GOTO 10420 103 | -------------------------------------------------------------------------------- /demo/src/tdungeon.bas: -------------------------------------------------------------------------------- 1 | 100 COLOR 15,1,1 2 | 110 DEFINT A-Z 3 | 120 SCREEN 2,0,0 4 | 130 GOSUB 10000 5 | 140 X=8:Y=8 6 | 7 | 200 PUT SPRITE 0,(X,Y-1),2,0 8 | 9 | 300 ON STICK(0) GOTO 310,301,330,301,350,301,370,301 10 | 301 P1=VPEEK(&H1800+X\8+(Y\8)*32):P2=P1 11 | 309 GOTO 400 12 | 310 P1=VPEEK(&H1800+X\8+((Y-1)\8)*32) 13 | 311 P2=VPEEK(&H1800+(X+6)\8+((Y-1)\8)*32) 14 | 312 IF P1<1 AND P2<1 THEN Y=Y-1 15 | 313 GOTO 400 16 | 330 P1=VPEEK(&H1800+(X+7)\8+((Y)\8)*32) 17 | 331 P2=VPEEK(&H1800+(X+7)\8+((Y+6)\8)*32) 18 | 332 IF P1<1 AND P2<1 THEN X=X+1 19 | 333 GOTO 400 20 | 350 P1=VPEEK(&H1800+(X)\8+((Y+7)\8)*32) 21 | 351 P2=VPEEK(&H1800+(X+6)\8+((Y+7)\8)*32) 22 | 352 IF P1<1 AND P2<1 THEN Y=Y+1 23 | 353 GOTO 400 24 | 370 P1=VPEEK(&H1800+(X-1)\8+((Y)\8)*32) 25 | 371 P2=VPEEK(&H1800+(X-1)\8+((Y+6)\8)*32) 26 | 372 IF P1<1 AND P2<1 THEN X=X-1 27 | 373 GOTO 400 28 | 29 | 400 IF P1=2 OR P2=2 THEN GOSUB 600 30 | 410 IF P1=3 OR P2=3 THEN GOSUB 700 31 | 420 IF STRIG(0) THEN GOSUB 600 32 | 33 | 500 GOTO 200 34 | 35 | 600 run"select.bas" 36 | 37 | 700 run"select.bas" 38 | 39 | 1000 DATA 00,00,00,00,00,00,00,00 40 | 1010 DATA 00,7F,7F,7F,00,F7,F7,F7 41 | 1020 DATA FD,EE,DF,33,FD,EE,DF,33 42 | 1030 DATA 3C,7F,DB,FF,FF,DB,7E,3C 43 | 1040 DATA * 44 | 1100 DATA 00,00,00,00,00,00,00,00 45 | 1110 DATA E0,E0,E0,E0,E0,E0,E0,E0 46 | 1120 DATA 68,68,68,68,68,68,68,68 47 | 1130 DATA D0,D0,D0,D0,D0,D0,D0,D0 48 | 1140 DATA * 49 | 1200 DATA 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 50 | 1210 DATA 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 51 | 1220 DATA 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 52 | 1230 DATA 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 53 | 1240 DATA 1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 54 | 1250 DATA 1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 55 | 1260 DATA 1,0,0,0,0,0,1,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 56 | 1270 DATA 1,0,0,0,0,0,1,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 57 | 1280 DATA 1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 58 | 1290 DATA 1,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 59 | 1300 DATA 1,0,0,2,2,2,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 60 | 1310 DATA 1,0,0,2,2,2,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 61 | 1320 DATA 1,0,0,2,2,2,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 62 | 1330 DATA 1,0,0,0,0,0,0,0,0,0,0,0,0,0,3,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 63 | 1340 DATA 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 64 | 1350 DATA * 65 | 66 | 1400 DATA 38,7C,FE,FE,FE,7C,38 67 | 1410 DATA * 68 | 69 | 10000 GOSUB 10100 70 | 10010 GOSUB 10200 71 | 10020 GOSUB 10300 72 | 10030 GOSUB 10400 73 | 10050 RETURN 74 | 75 | 10100 'LOAD PATTERNS 76 | 10110 S=0 77 | 10120 READ R$ 78 | 10130 IF R$="*" THEN RETURN ELSE R=VAL("&H"+R$) 79 | 10140 VPOKE S,R 80 | 10150 VPOKE 2048+S,R 81 | 10160 VPOKE 4096+S,R 82 | 10170 S=S+1:GOTO 10120 83 | 84 | 10200 'LOAD COLORS 85 | 10210 S=0 86 | 10220 READ R$ 87 | 10230 IF R$="*" THEN RETURN ELSE R=VAL("&H"+R$) 88 | 10240 VPOKE &H2000+S,R 89 | 10250 VPOKE &H2800+S,R 90 | 10260 VPOKE &H3000+S,R 91 | 10270 S=S+1:GOTO 10220 92 | 93 | 10300 'LOAD NAMES 94 | 10310 S=&H1800 95 | 10320 READ R$ 96 | 10330 IF R$="*" THEN RETURN 97 | 10340 VPOKE S,VAL("&H"+R$) 98 | 10350 S=S+1:GOTO 10320 99 | 100 | 10400 'LOAD SPRITES 101 | 10410 S=&H3800 102 | 10420 READ R$ 103 | 10430 IF R$="*" THEN RETURN ELSE VPOKE S,VAL("&H"+R$):S=S+1 104 | 10440 GOTO 10420 105 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Modern MSX BASIC Game Development 2 | 3 | This repository contains examples, demos and scripts from the book ["Modern MSX-BASIC Game Development"](https://www.amazon.com/Modern-MSX-BASIC-Game-Development/dp/1527298094/) 4 | 5 | ![51nVbm22NBS _SX331_BO1,204,203,200_](https://user-images.githubusercontent.com/1717361/126006613-48c47e3b-922a-4d7c-9840-cf3410a226ab.jpg) 6 | 7 | You can read the preface [here](https://github.com/plattysoft/Modern-MSX-BASIC-Game-Dev/blob/main/Preface.pdf) 8 | 9 | You can play around with the examples of the book [here](https://webmsx.org/?MACHINE=MSX1E&ROM=https://github.com/plattysoft/Modern-MSX-BASIC-Game-Dev/raw/main/demo/output/demo.rom) 10 | 11 | ## About the book 12 | 13 | MSX is a 1983’s 8-bit architecture standard for home computers. It includes a Z80 microprocessor and dedicated chips for graphics and sound. 14 | 15 | MSX BASIC is the default language of MSX computers. It is simple, yet reasonably powerful. You can use sprites, joysticks, and even access to the graphic and sound chips directly. That makes MSX BASIC a great entry point for making games and learning all the important concepts of MSX. 16 | 17 | Back in the 80s, then there was no Internet. The books available were few and often not very helpful. Most contained simply a list of all the BASIC instructions and some program listings without any explanation. It was unnecessarily hard. 18 | 19 | Nowadays there are vastly more resources available, but I still missed an all in one solution with all the details on how to write good games using MSX BASIC with the tools we have available today. That is what this book aims to be. 20 | 21 | Welcome to Modern MSX BASIC Game Development. 22 | 23 | ## Book structure 24 | The book is structured following a progressive approach in which we will cover the basics in the first chapters and will be building on top of the knowledge of previous chapters. 25 | 26 | - In the first chapter we talk about the development environment and the different options with their pros and cons. 27 | - In the second chapter, we cover the particularities of MSX BASIC as well as the different types of variables, some particularities of the language and a few recommendations on how to write programs. 28 | - In chapter 3 we get further into MSX BASIC structure and flow as well as commands for managing input and output. 29 | - In chapter 4, we start to build games, we will see how to define and use sprites and how to handle joysticks; and we will build a space shooter along the way. 30 | - In chapter 5 we explore the different ways to add collision detection to our space shooter, from hardware sprite collision to hitboxes and a combination of both. 31 | - In chapter 6, we look into the basic drawing commands available and we will build a simple dungeon game to highlight how they can be used. 32 | - Chapter 7 is when we get deep into the MSX graphics and dive into how to program the VDP to define tiles for more colorful and efficient graphics. This 33 | chapter is all about VPOKE and VPEEK. 34 | - In chapter 8 we explore how we can add sound effects to our games, both using the high level command PLAY and also accessing the PSG directly with SOUND. 35 | - Finally, in chapter 9 we will see some advanced techniques of MSX BASIC, including making it run blazing fast by compiling it with MSX-BASIC-KUN, splitting the program into many files to make the game more versatile, how to publish it, and we’ll close with a brief glimpse of other more advanced ways to make games for the MSX family. 36 | 37 | ## Links 38 | 39 | ### Emulators 40 | * openMSX: https://openmsx.org/ 41 | * webMSX: https://github.com/ppeccin/webmsx 42 | * fMSX: https://fms.komkon.org/fMSX/ 43 | * blueMSX: http://bluemsx.msxblue.com/download.html 44 | 45 | ### Editors 46 | * MSXPen: https://msxpen.com/ 47 | * Kate: https://kate-editor.org/ 48 | * Sublime tools: https://github.com/farique1/MSX-Sublime-Tools 49 | * Atom plugin: https://github.com/plainspooky/language-msxbasic 50 | 51 | ### Music tools 52 | * Arkos Tracker 2: https://www.julien-nevo.com/arkostracker/ 53 | * WYZTracker: https://github.com/AugustoRuiz/WYZTracker 54 | * WYZPlayer: https://sites.google.com/site/wyzplayer/ 55 | 56 | ### Design tools 57 | * tinySprite: http://msx.jannone.org/tinysprite/ 58 | * nMSXTiles: https://github.com/pipagerardo/nMSXtiles 59 | 60 | ### Other tools 61 | * dsk2rom: https://github.com/joyrex2001/dsk2rom 62 | * hexFiend: https://hexfiend.com/ 63 | * MSX-BASIC-KUN: https://konamiman.github.io/MSX2-Technical-Handbook/md/KunBASIC.html 64 | 65 | ### Useful websites 66 | * MSX Resource Center: https://www.msx.org/ 67 | * MSXdev Context: https://www.msxdev.org/ 68 | 69 | ### Beyond MSX BASIC 70 | * RetroDeluxe: https://github.com/retrodeluxe/rlengine-msx 71 | * Fusion C: https://github.com/ericb59/Fusion-C-v1.2 72 | * UBOX: https://github.com/reidrac/ubox-msx-lib 73 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | --------------------------------------------------------------------------------