It is currently Thu Jan 28, 2021 3:12 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: JavaScript to PureBasic
PostPosted: Sat Nov 23, 2019 4:51 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Mon Mar 17, 2014 1:42 pm
Posts: 119
Location: Brasil - S.P
Can someone give a look at my conversion, please? My code is working, but not everything is correct...

Code:
function aystep() {

  if( ++envc >= (ayr[11]<<1 | ayr[12]<<9) )

    envc= 0,

    envv= estep();

  if( ++noic >= ayr[6]<<1 )

    noic= 0,

    noiv= noir & 1,

    noir= (noir^noiv*0x24000)>>1;

  return (cstep(0) + cstep(1) + cstep(2)) / 3;

}


Code:
function aymute() {

  if( ++envc >= (ayr[11]<<1 | ayr[12]<<9) ){

    envc= 0;

    if( envx >> 4 && ~ay13 & 1 )

      envx= 0,

      ay13^= ay13<<1 & 4;

  }

  if( ++noic >= ayr[6]<<1 )

    noic= 0,

    noiv= noir & 1,

    noir= (noir^noiv*0x24000)>>1;

  if( ++ayr[16] >= (ayr[0] | ayr[1]<<8) )

    ayr[16]= 0,

    tons^= 1;

  if( ++ayr[17] >= (ayr[2] | ayr[3]<<8) )

    ayr[17]= 0,

    tons^= 2;

  if( ++ayr[18] >= (ayr[4] | ayr[5]<<8) )

    ayr[18]= 0,

    tons^= 4;

}

Code:
function cstep(ch) {

  if( ++ayr[ch+16] >= (ayr[ch<<1] | ayr[1|ch<<1]<<8) )

    ayr[ch+16]= 0,

    tons^= 1 << ch;

  return  ( ( ayr[7] >> ch   | tons >> ch )

          & ( ayr[7] >> ch+3 | noiv       )

          & 1 )  * amp[ ayr[8+ch] & 0x10

                   ? envv

                   : ayr[8+ch] & 0x0f ];

}

Code:
function estep() {

  if( envx >> 4 ){

    if( ay13 & 1 )

      return 7.5*((ay13>>1 ^ ay13) & 2);

    envx= 0;

    ay13^= ay13<<1 & 4;

  }

  return  ay13 & 4

          ? envx++

          : 15 - envx++;

}

Code:
function ayw(val) {

  ayr[ay]= val & rmask[ay];

  if( ay==13 )

    envx= 0,

    ay13= val & 8

          ? 1 | val>>1 & 2 | val & 4

          : val;

}


PB code:

Code:
Procedure.f aystep()
 
  envc+1
  If envc  >= (ayr(11)<<1 | ayr(12)<<9)
    envc=0
    envv=estep()
  EndIf
 
  noic+1
  If noic >= (ayr(6)<<1)
    noic=0
    noiv=noir & 1
    noir=(noir!(noiv*$24000))>>1
  EndIf
 
  ProcedureReturn (cstep(0)+cstep(1)+cstep(2))/3
 
EndProcedure

Procedure aymute()
 
  envc+1
  If envc >= (ayr(11)<<1 | ayr(12)<<9)
    envc= 0
    If (envx >> 4) And  (~ay13 & 1)
      envx= 0
      ay13=ay13 ! (ay13<<1) & 4
    EndIf
  EndIf
 
  noic+1
  If noic >= (ayr(6)<<1)
    noic= 0
    noiv= noir & 1
    noir= (noir!(noiv*$24000))>>1
  EndIf
 
  ayr(16) + 1
  If ayr(16) >= (ayr(0) | ayr(1)<<8)
    ayr(16)= 0
    tons= tons ! 1
  EndIf
 
  ayr(17) + 1
  If ayr(17) >= (ayr(2) | ayr(3)<<8)
    ayr(17)= 0
    tons=tons ! 2
  EndIf
 
  ayr(18) + 1
  If ayr(18) >= (ayr(4) | ayr(5)<<8)
    ayr(18)= 0
    tons=tons ! 4
  EndIf
 
EndProcedure

Procedure.f cstep(ch)
 
  ayr(ch+16)=ayr(ch+16)+1
  If ayr(ch+16) >= ((ayr(ch<<1) | ayr(1|ch<<1))<<8)
    ayr(ch+16)= 0
    tons= tons ! (1 << ch)
  EndIf
 
  If ayr(8+ch) & $10
     
    t0=((ayr(7) >> ch   | tons >> ch)  &  (ayr(7) >> (ch+3) | noiv))  & 1
     ProcedureReturn t0 * amp(envv)
    
   Else

     t0=((ayr(7) >> ch   | tons >> ch)  &  (ayr(7) >> (ch+3) | noiv))   & 1
     ProcedureReturn t0 * amp(ayr(8+ch) & $0F)
    
   EndIf
 
EndProcedure

Procedure.f estep()
 
  If envx >> 4
    If  ay13 & 1
      t1=((ay13>>1) ! ay13) & 2
      ProcedureReturn 7.5 * t1
    EndIf
    envx= 0
    ay13=(ay13 ! (ay13<<1)) & 4
  EndIf
 
  If ay13 & 4
    envx+1
    ProcedureReturn  (envx-1)
  Else
    envx+1
    ProcedureReturn  15-(envx-1)
  EndIf
 
EndProcedure

Procedure ayw(val)
 

  ayr(ay)= (val & rmask(ay))
  If  ay=13
    envx= 0
    If val & 8
      ay13 = 1 | (val>>1 & 2) | (val & 4)
    Else
      ay13=val
    EndIf
  EndIf
EndProcedure




Thanks,
Otrebor

_________________
ZX Spectrum emulator (PureBasic)


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 32 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye