Onwards and upwards?

Discussions related to graphics (2D and 3D), animation and games programming
David Williams

Onwards and upwards?

Post by David Williams »

Code: Select all

      REM Requires full version of BB4W v6.14a or later,
      REM and an active internet connection.
      *ESC OFF
      HIMEM=PAGE+3*&100000
      MODE 8:PRINT'"  Please wait a mo..";
      ON ERROR PROCerror(REPORT$+" at line "+STR$ERL)
      urlstem$="http://www.proggies.uk/files/temp/toodlepip/"
      PROCnetload(urlstem$+"GFXLIB2.BBC",@tmp$+"GFXLIB2.BBC")
      PROCnetload(urlstem$+"BPlotScale.BBC",@tmp$+"BPlotScale.BBC")
      PROCnetload(urlstem$+"PlotScaleShape.BBC",@tmp$+"PlotScaleShape.BBC")
      PROCnetload(urlstem$+"PlotRotateScale2.BBC",@tmp$+"PlotRotateScale2.BBC")
      PROCnetload(urlstem$+"GaussianBlur3x3.BBC",@tmp$+"GaussianBlur3x3.BBC")
      PROCnetload(urlstem$+"gifimage_480x66.gif",@tmp$+"gifimage_480x66.gif")
      INSTALL @tmp$+"GFXLIB2":PROCInitGFXLIB(gfx{},0)
      ON ERROR PROCerror(REPORT$+" at line "+STR$ERL)
      INSTALL @tmp$+"BPlotScale.BBC":PROCInitModule(0)
      INSTALL @tmp$+"PlotScaleShape.BBC":PROCInitModule(0)
      INSTALL @tmp$+"PlotRotateScale2.BBC":PROCInitModule(0)
      INSTALL @tmp$+"GaussianBlur3x3.BBC":PROCInitModule(0)
      `GetTickCount64`=SYS("GetTickCount64")
      winW%=@vdu%!208 : winH%=@vdu%!212
      cx%=winW%/2 : cy%=winH%/2
      DIM bm{a%,w%,h%}:bm.w%=480:bm.h%=66
      bm.a%=FNLoadImg(@tmp$+"gifimage_480x66.gif", 0)
      S%=2*SQR((0.5*bm.w%)^2+(0.5*bm.h%)^2)
      buf%=FNmalloc(4*S%^2) : buf2%=FNmalloc(4*winW%*winH%)
      DIM p(S%-1,2), q(S%-1,2), m(2,2)
      FOR Y%=0 TO S%-1:p(Y%,0)=-0.5*S%:p(Y%,1)=Y%-S%/2:NEXT Y%
      DIM C%(7):C%()=&FF0000,&FF8000,&FFFF00,&FF00,&8080FF,&FFFF,&FF00FF
      D%=8000
      bmAngle=0
      SYS `GetTickCount64` TO time0%%
      OSCLI "REFRESH OFF" : OFF
      REPEAT
        SYS `GetTickCount64` TO time1%%
        time%% = time1%% - time0%%
        SYS GFXLIB_SaveAndSetDispVars%,gfx{},buf%,S%,S%
        SYS GFXLIB_Clr%,gfx{},0
        IF time%% >= D% THEN
          IF bmAngle=0 timeAngle0%%=time%%+1
          bmAngle = 0.0075*(time%%-timeAngle0%%)
        ENDIF
        SYS GFXLIB_PlotRotateScale2%,gfx{},bm.a%,bm.w%,bm.h%, \
        \ S%/2,S%/2,&10000*bmAngle,&10000
        SYS GFXLIB_RestoreDispVars%,gfx{}
        SYS GFXLIB_SaveAndSetDispVars%,gfx{},buf2%,winW%,winH%
        theta=0.001*time%%
        m()=1,0,0, 0,COStheta,-SINtheta, 0,SINtheta,COStheta
        q()=p().m()
        B%=buf%
        G%=gfx{}
        P%=GFXLIB_PlotScaleShape%
        U%=cx%
        V%=cy%
        t=3.5*(1+SIN(0.0005*time%%))
        I%=(INTt) MOD 7 : J%=(INT(t+1)) MOD 7
        SYS GFXLIB_LerpRGB%, C%(I%), C%(J%), 256*(t-INTt) TO K%
        FOR I%=0 TO S%-1
          z=S%/(q(I%,2)+S%+150)
          rowLen=S%*z
          X%=U%-0.5*rowLen
          Y%=V%+q(I%,1)*z
          SYS P%,G%,B%+4*S%*I%,S%,1,rowLen,1,X%,Y%,K%
        NEXT
        SYS GFXLIB_GaussianBlur3x3%, gfx.bmBuffAddr%, winW%, winH%
        SYS GFXLIB_RestoreDispVars%,gfx{}
        scale=2+SIN(0.0005*time%%)*SIN(0.0006525*time%%+1.2)
        SYS GFXLIB_BPlotScale%,gfx{},buf2%,winW%,winH%,scale*winW%,scale*winH%, \
        \ 0.5*(winW%-scale*winW%),0.5*(winH%-scale*winH%)
        PROCdisplay
      UNTIL FALSE
      DEFPROCnetload(url$,file$)
      LOCAL F% : PRIVATE urlmon%, UDTF%
      IF urlmon%=FALSE THEN
        SYS "LoadLibrary", "URLMON.DLL" TO urlmon%
        SYS "GetProcAddress", urlmon%, "URLDownloadToFileA" TO UDTF%
      ENDIF
      SYS UDTF%, 0, url$, file$, 0, 0 TO F%
      IF F% PROCerror("PROCnetload: Can't download resource '"+url$+"'")
      ENDPROC
      DEFPROCerror(s$)
      OSCLI"REFRESH ON":CLS:ON:VDU 7:PRINT'"  "+s$;:REPEATUNTILINKEY(1)=0
      ENDPROC
https://pastebin.com/JZg2pDmb
Hated Moron

Re: Onwards and upwards?

Post by Hated Moron »

This is a BBCSDL conversion of David Williams's 'farewell' program (I thought I'd already posted it, but I can't find it so here it is again). You can also run it in a suitable browser (most desktop browsers are) here.

Code: Select all

      REM Requires 'BBC BASIC for SDL2.0', converted by RTR from DW's BB4W version.
      *ESC OFF
      MODE 8:PRINT'"  Please wait a mo..";
      ON ERROR PROCerror(REPORT$+" at line "+STR$ERL)
      INSTALL @lib$+"gfxlib":PROC_gfxInit
      INSTALL @lib$+"socklib":PROC_initsockets
      SYS "SDL_SetHint", "SDL_RENDER_SCALE_QUALITY", "linear"
      OSCLI "FONT """+@lib$+"DejaVuSans"",64"
      OSCLI "REFRESH OFF" : OFF
      VDU 5:MOVE 0,160:GCOL 15:@vdu.w.d&=3:PRINT "FAREWELL";
      OSCLI "GSAVE """+@tmp$+"bmpimage_480x66.bmp"" 0,0,960,132"
      IF SYS("SDL_GetTicks64") THEN
        `GetTickCount64`=SYS("SDL_GetTicks64")
      ELSE
        `GetTickCount64`=SYS("SDL_GetTicks")
      ENDIF
      winW%=640 : winH%=512
      cx%=winW%/2 : cy%=winH%/2
      DIM bm{a%%,w%,h%}:bm.w%=480:bm.h%=66
      bm.a%%=FN_gfxLoadWhiteTexture(@tmp$+"bmpimage_480x66.bmp", &FF000000)
      S%=2*SQR((0.5*bm.w%)^2+(0.5*bm.h%)^2)
      buf%%=FN_gfxCreateTexture(S%,S%) : buf2%%=FN_gfxCreateTexture(winW%,winH%)
      DIM p(S%-1,2), q(S%-1,2), m(2,2), i%(S%-1), x%(S%-1), y%(S%-1), w%(S%-1)
      FOR Y%=0 TO S%-1:p(Y%,0)=-0.5*S%:p(Y%,1)=Y%-S%/2:NEXT Y%
      DIM R%(7),G%(7),B%(7)
      R%()=&FF,&FF,&FF,&00,&80,&00,&FF
      G%()=&00,&80,&FF,&FF,&80,&FF,&00
      B%()=&00,&00,&00,&00,&FF,&FF,&FF
      D%=8000
      bmAngle=0
      SYS `GetTickCount64` TO time0%%
      REPEAT
        SYS `GetTickCount64` TO time1%%
        time%% = time1%% - time0%%
        PROC_gfxSaveAndSetDispVars(gfx{},buf%%)
        PROC_gfxClrX(0,0,0,1)
        IF time%% >= D% THEN
          IF bmAngle=0 timeAngle0%%=time%%+1
          bmAngle = 0.0075*(time%%-timeAngle0%%)
        ENDIF
        PROC_gfxPlotRotateScale(bm.a%%,bm.w%,bm.h%,S%/2,S%/2,bmAngle)
        PROC_gfxRestoreDispVars(gfx{})
        PROC_gfxSaveAndSetDispVars(gfx{},buf2%%)
        theta=0.001*time%%
        m()=1,0,0, 0,COStheta,-SINtheta, 0,SINtheta,COStheta
        q()=p().m()
        t=3.5*(1+SIN(0.0005*time%%))
        I%=(INTt) MOD 7 : J%=(INT(t+1)) MOD 7 : b=t-INTt : a = 1-b
        SYS `SDL_SetTextureColorMod`,buf%%,INT(a*R%(I%)+b*R%(J%)),\
        \           INT(a*G%(I%)+b*G%(J%)),INT(a*B%(I%)+b*B%(J%))
        FOR I%=0 TO S%-1
          z=S%/(q(I%,2)+S%+150)
          w%(I%)=S%*z
          x%(I%)=cx%-0.5*S%*z
          y%(I%)=cy%-q(I%,1)*z
          i%(I%)=S%-1-I%
        NEXT
        PROC_gfxPlotRowListScale(buf%%,S%,S%,S%,i%(),x%(),y%(),w%())
        PROC_gfxGaussianBlur3x3(winW%,winH%,0,0)
        PROC_gfxRestoreDispVars(gfx{})
        scale=2+SIN(0.0005*time%%)*SIN(0.0006525*time%%+1.2)
        PROC_gfxPlotScale(buf2%%,scale*winW%,scale*winH%,\
        \ 0.5*(winW%-scale*winW%),0.5*(winH%-scale*winH%))
        *REFRESH
      UNTIL FALSE

      DEFPROCerror(s$)
      OSCLI"REFRESH ON":CLS:ON:VDU 7:PRINT'"  "+s$;:REPEATUNTILINKEY(1)=0
      ENDPROC
Hated Moron

Re: Onwards and upwards?

Post by Hated Moron »

On 24/05/2023 18:16, Maksim AbuAjamieh wrote (cross-posted from the Discussion Group):
Re graphics and games,

Is there any good clone of Pac-Man for BBC4W or the SDL version ?
I think I have a version somewhere (not written by me) but I've never wanted to risk making it available because of IPR issues. My understanding is that the rights owners jealously protect their property, even now. I've had a fair amount of unwanted 'feedback' about lemmings.bbc (which was translated from Liberty BASIC) for similar reasons.
Hated Moron

Re: Onwards and upwards?

Post by Hated Moron »

On 24/05/2023 20:29, Maksim AbuAjamieh wrote (cross-posted from the Discussion Group):
Is there any way sharing that temporarily or pointing to its location without breaking IPR ?
I've put a browser version here for you to try. I think it's fairly primitive, the entire program is less than 7K! I don't have any way of contacting the author.
Also, if you have a library of games other than this, how can we check it (is it available?)
The only "library" of BBC BASIC games I have is the existing BBCSDL/examples/games/ directory.
Hated Moron

Re: Onwards and upwards?

Post by Hated Moron »

On 24/05/2023 21:51, Maksim AbuAjamieh wrote (cross-posted from the Discussion Group):
Not too bad..

But what confuses me, there are couple of fantastic versions for risk os and if memory serves me, it was on the BBC Micro (was it called PuckMan?)..

So why the licensing thing pops up only with BBC4W ?
If they were commercial (e.g. Acornsoft) games then they had lawyers to give advice (and fend off claims) and millions of pounds available should they be on the losing side. A private individual who does not have lots of money, and doesn't want to go to prison, can't take that kind of risk.