PowerBASIC examples
  • Start
    RUN"V9990.LDR"


  • Print default PowerBASIC fonts
    10 '--- PBFONT.BAS
    20 COLOR15,0,0:SCREEN2
    30 _TURBOON
    40 '--- draw all fonts
    50 SETPAGE1,1:CLS
    60 AD=PEEK(4)+PEEK(5)*256
    70 FORI=0TO64:FORJ=0TO7
    80 A=128:D=PEEK(256+AD)
    90 D=(DAND&HF0)OR((DAND&B1110)*2)
    100 V=128*(8*INT(I/32)+J)+(IAND31)*4
    110 FORK=0TO3
    120 IFDANDATHENH=&HF0 ELSEH=&H0
    130 A=A/2
    140 IFDANDATHENH=HOR&HF
    150 VPOKEV,H:V=V+1
    160 NEXTK
    170 AD=AD+1
    180 NEXTJ,I
    190 '--- init screen
    200 SETPAGE0,0
    210 A$="HELLO POWER BASIC"
    220 SX=4:SY=4:GOSUB290
    230 A$="PUSH SPACE KEY TO QUIT!"
    240 SX=4:SY=32:GOSUB290
    250 '--- loop
    260 IFSTRIG(0)THENEND
    270 GOTO 260
    280 '--- print
    290 FORI=0TOLEN(A$)-1
    300 A=ASC(MID$(A$,I+1,1))-32:COPY(INT(AAND31)*8,INT(A/32)*8)-STEP(7,7),1TO(SX,SY)
    310 SX=SX+8:NEXTI:RETURN




  • Sprite balls
    1 '--- PBBALLS.BAS
    2 _TURBOON
    3 DIM TX(100),TY(100),TC(100),RX(100),RY(100),HX(100),HY(100)
    4 TM=100
    5 WX=240+8+8:WY=176+8+8
    6 FOR I=0 TO TM:TX(I)=INT(RND(1)*WX):TY(I)=INT(RND(1)*WY)
    7 GOSUB55
    8 NEXTI
    9 COLOR15,0,0:SCREEN2
    10 '--- init sprites
    11 VDP(25)=2
    12 FORI=0TO3:FORJ=0TO15:READ A$:FORK=0TO7
    13 VPOKE&H8000+I*8+J*128+K,VAL("&h"+MID$(A$,K*2+1,2))
    14 NEXT K,J,I
    15 '--- graphic data
    16 DATA AAAAAAAADDDDDDDD,AAAAAAAADDDDDDDD,AAAAAAAADDDDDDDD,AAAAAAAADDDDDDDD
    17 DATA AAAAAAAADDDDDDDD,AAAAAAAADDDDDDDD,AAAAAAAADDDDDDDD,AAAAAAAADDDDDDDD
    18 DATA DDDDDDDDAAAAAAAA,DDDDDDDDAAAAAAAA,DDDDDDDDAAAAAAAA,DDDDDDDDAAAAAAAA
    19 DATA DDDDDDDDAAAAAAAA,DDDDDDDDAAAAAAAA,DDDDDDDDAAAAAAAA,DDDDDDDDAAAAAAAA
    20 DATA 0000077775700000,0007777777575000,00777FF777757500,0757FFF777575550
    21 DATA 0577FF7777757550,5757777777575545,5575777775755554,5557577757555544
    22 DATA 5575757575555454,5557575755554544,4555555555545444,0455555555454440
    23 DATA 0444545454544440,0044454545444400,0004444444444000,0000044444400000
    24 DATA 0000033332300000,0003333333232000,00333FF333323200,0323FFF333232220
    25 DATA 0233FF3333323220,23233333332322C2,223233333232222C,22232333232222CC
    26 DATA 2232323232222C2C,222323232222C2CC,C2222222222C2CCC,0C22222222C2CCC0
    27 DATA 0CCC2C2C2C2CCCC0,00CCC2C2C2CCCC00,000CCCCCCCCCC000,00000CCCCCC00000
    28 DATA 0000099998900000,0009999999898000,00999FF999989800,0989FFF999898880
    29 DATA 0899FF9999989880,8989999999898868,8898999998988886,8889899989888866
    30 DATA 8898989898888666,8889898988886866,6888888888868666,0688888888686660
    31 DATA 0666868686866660,0066686868666600,0006666666666000,0000066666600000
    32 '--- draw back
    33 FORI=0TO11:FORJ=0TO15
    34 COPY(0,0)-STEP(15,15),1TO(J*16,I*16)
    35 NEXTJ,I
    36 '--- loop
    37 FORI=0TOTM
    38 IFINT(RND(1)*30)=0THENGOSUB55
    39 SX=TX(I):SY=TY(I)
    40 IFHX(I)>SXTHENRX(I)=RX(I)+.5ELSEIFHX(I)<SXTHENRX(I)=RX(I)-.5
    41 IFHY(I)>SYTHENRY(I)=RY(I)+.5ELSEIFHY(I)<SYTHENRY(I)=RY(I)-.5
    42 SX=SX+RX(I)
    43 SY=SY+RY(I)
    44 BD=8
    45 IF SX<BD THEN SX=BD
    46 IF SX>WX-1-BD THEN SX=WX-1-BD
    47 IF SY<BD THEN SY=BD
    48 IF SY>WY-1-BD THEN SY=WY-1-BD
    49 PUTSPRITEI,(SX-8,SY-8),,TC(I)+1
    50 TX(I)=SX:TY(I)=SY
    51 NEXTI
    52 IFSTRIG(0)THENEND
    53 GOTO 37
    54 '--- change property
    55 HX(I)=RND(1)*(WX-80)+40
    56 HY(I)=RND(1)*(WY-60)+30
    57 TC(I)=INT(RND(1)*3)
    58 RETURN

  • PowerBASIC demos 2021

    8 demos made with PowerBASIC.
    It runs on MSX turboR with GFX9000(V9990). It also runs with openMSX.
    Download

    Back