# PureBasic Forum

 It is currently Sat Jan 23, 2021 9:40 am

 All times are UTC + 1 hour

 Page 1 of 1 [ 1 post ]
 Print view Previous topic | Next topic
Author Message
 Post subject: JavaScript to PureBasicPosted: Sat Nov 23, 2019 4:51 pm
 Enthusiast

Joined: Mon Mar 17, 2014 1:42 pm
Posts: 118
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) {

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)

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

 Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending
 Page 1 of 1 [ 1 post ]

 All times are UTC + 1 hour

#### Who is online

Users browsing this forum: No registered users and 26 guests

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

Search for:
 Jump to:  Select a forum ------------------ PureBasic    Coding Questions    Game Programming    3D Programming    Assembly Programming    The PureBasic Editor    The PureBasic Form Designer    General Discussion    Feature Requests and Wishlists    Tricks 'n' Tips Bug Reports    Bugs - Windows    Bugs - Linux    Bugs - Mac OSX    Bugs - IDE    Bugs - Documentation OS Specific    AmigaOS    Linux    Windows    Mac OSX Miscellaneous    Announcement    Off Topic Showcase    Applications - Feedback and Discussion    PureFORM & JaPBe    TailBite