XLNT GUI - Porting Blitz Basic GUI to PlayBASIC (Is it possible?)

Started by kevin, January 20, 2022, 07:03:28 PM

Previous topic - Next topic

kevin

   XLNT GUI - Porting Blitz Basic GUI to PlayBASIC (Is it possible?)

         There's any number of ways to build GUI's in PlayBASIC and every other language, but one I've used in the past was called XLNT GUI by Yappy way back in the BlitzBASIC days.  XLNT was a custom GUI (none windows) that provides an emulation of a windows style interface interface within your BB program.  



 
The IDEA & Objective:

 
           I bring this up after running into the XLNT source code again, which made me wonder if that'd port to PlayBASIC ?.   My initial assessment of the code was yeah, but it'll need some wrapping and way to emulate the way blitz works,  which at times can be a very different animal.  

           The goal here is to port the code the best I can and release the various "as is" builds of it during the work in progress.  

           But there's NO guarantees of completeness or accuracy..  I'll test it the best I can, but beyond that your on your own!



   
Related Projects:


        - BlitzBASIC 2 PlayBASIC - Source Code Conversion WIP




 
PlayBASIC LIVE: Porting XLnt GUI To PlayBASIC  Series -  Episode #01


       



  PlayBASIC LIVE: Porting XLnt GUI To PlayBASIC  Series -  Episode #02

       




  Other PlayBASIC GUI Links:

           - FlexiGUI For Newcomers (login required)
           - Flexi GUI Windows Library    
           - Action GUI
           - Simple Text Menus



  Download:

kevin

PlayBASIC LIVE : Emulating Blitz BASIC Linked Lists For a XLNT GUI port to PlayBASIC (2022-01-21)

 In this video we take a look at mimicking the LInked List behaviors of BlitzBASIC while porting a GUI library called XLNT GUI.    





kevin

   XLNT GUI - Porting Blitz Basic GUI to PlayBASIC - V003 & V004

         Here's the 3rd and 4th revisions of the XLNT port..  This is about five hours in and were only just getting some interaction between the user and the window.


        Note: The plan is to edit up the footage and make a series out it, but that'll take a while..  I might cut them down, since who's going to watch em ?  ..  



 
PlayBASIC LIVE: Porting XLnt GUI To PlayBASIC  Series -  Episode #03


       




 
PlayBASIC LIVE: Porting XLnt GUI To PlayBASIC Series - Episode 04


       





 
Downloads:


stevmjon

cool kev, 2 seperate windows.

i haven't broken down the code yet, but is this mimicking a window using graphics, rather than using windows itself? so this would look the same on different windows systems?
i am interested in learning more about a GUI.
It's easy to start a program, but harder to finish it...

I think that means i am getting old and get side tracked too easy.

kevin

Quotecool kev, 2 seperate windows.

    Getting there, but still a ways to go with it


Quotei haven't broken down the code yet, but is this mimicking a window using graphics, rather than using windows itself? so this would look the same on different windows systems?
i am interested in learning more about a GUI.

    The current versions are about a 1/4 of the code base,  but basically this and other libraries (FlexiGUI / PlayGUI) are graphical GUI's with their own built in default style, meaning the GUI code handles the visuals of everything you want to work with it.   So it creates the sandbox and you play within it.  

     Today it'd be nice to have something that supported some type of style sheet to customize the visuals.   So same core gui library that could be tweaked display wise.   This can't really do that.



kevin

   XLNT GUI - Porting Blitz Basic GUI to PlayBASIC - V005

         Here's the 5th revision of the XLNT port..  This is another couple of hours into navigating my way through the Event processing code,  so far it's not working, but I think we can get there.  Once it does,  that'll make user interaction possible.   Then it's more a matter of cleaning up he behaviors then porting the long list of gadgets it supports.


 
PlayBASIC LIVE: Porting XLnt GUI To PlayBASIC  Series -  Episode #05


   




 
PlayBASIC LIVE: Porting XLnt GUI To PlayBASIC  Series -  Episode #05b


   





  Download:

kevin

  Releases


    Just a quick heads up that I'm working on the videos for XLnt GUI port which i've scheduled for release across the next few weeks.    This keeps regular content appearing on the PB channel and gives me time to catch up/get ahead.


     So back to your regular broadcasts !


      NOTE: As a result of some videos be scheduled, they may appear in this thread as PRIVATE.  I've done that so I don't was to keep coming back and editing posts etc..   

kevin



Finally have caught up producing the first block of port XLnt GUI videos, then life kicks in again and I soon get behind ..   But i'm hoping to get the next few sessions done in the next few days...  The initial hope was we'd have something running in  couple of weeks..  but we all know how those plans go around here these days.. ;(



kevin

   XLNT GUI - Porting Blitz Basic GUI to PlayBASIC - V006

         Here's the 6th revision of the XLNT port..  Today we start to unlock the mystery of window event processing in the XLnt,  adding MIN and MAX controls and finally DRAGGING  starts to work...



 
PlayBASIC LIVE: Porting XLnt GUI To PlayBASIC  Series -  Episode #06



        




  Download:

kevin

    XLNT GUI - Porting Blitz Basic GUI to PlayBASIC - V007

          Here's the 7th revision of the XLNT port..  Today we tackle window scaling / resizing and trying unpick how the GUI() function actually works.


   
PlayBASIC LIVE: Porting XLnt GUI To PlayBASIC  Series -  Episode #07



         




    Download:

kevin

   XLNT GUI - Porting Blitz Basic GUI to PlayBASIC - V008

         This session was focused on the cleaning up the original Blitz code ready for mass translation.   This entails lots of search / replacements on the original code to replace common blitz calls with what will be PlayBASIC wrapped command/functions mowing into some now commonly used conventions in the code.   So the PB version of the program is really no different, use the input code is little ready than it was.      



 
PlayBASIC LIVE: Porting XLnt GUI To PlayBASIC  Series -  Episode #08


       Here's session 8 on the road to porting XLnt GUI across to PlayBASIC.  In this session we attempt to convert the blitz command names to our wrapped form.   Process is pretty limited and it soon back obvious that we need to build a tool to such jobs..      

          So feel free to follow along with my adventure porting this huge BlitzBASIC code across to PlayBASIC..   SLOWLY..   :)

         





    Script:

   

hello welcome back here we are with

episode 8 of our adventures of porting

excellent guy

if you feel like giving us a like and

subscribe then you know what the buttons

are in the bottom

as for the gy i think we're going to

change tact a little bit

what we might do is we might

jump to the original source and

do a bunch of replacement style things

to that to

since we've got a concept now of how

these things are going to work

i'll keep two copies of the original

the

modified version and the

the original code

let's load that up

reopen thank you and that's

the original code there

what i might do is i might

add a uh

add a new file to it we'll call this the

original code

original

excellent gui

code

hit close

go here and just go select all

select all

copy that

and drag it over here

it doesn't mean i've got to be careful

now when we use replace for example

we're going to

make sure we're not going to not going

to be replacing that main document

uh

we'll do things like

since we've got a since our wrapper uh

handles things like

well i look for them

i i know draw image is one that we've

already wrapped so we could do

and then while end is another one that

we've already

already doing so we might do a

catch of that one there as well

we might not do a replace might just do

a search

update like that

and my reason for that is is that

sometimes you can catch things inside

other things where you don't want them

there's a lot of drawing images in there

probably a lot more than what i was

anticipating

this is going to be the order of this

session is going to be try and modify

this code

up front and then drop it drop in some

gadget code

and

try and start piecing this thing

together

draw image

and move back to the start

good

i might put a note at the top of this

code uh

this code

has

some bb wrapper replacements

just in case i somehow forget that i

probably won't but

you never know

just never know these things

all right what's some other ones that we

wrapped in our main library

our blitz wrappers back here so we'll

have a look at it

load font was one of them so we'll do a

load font

replace milliseconds with timer

uh

back to here

i don't think there'll be too many large

fonts actually

didn't seem like a function that would

be used that frequently in this code

base load of font

we've got one usage of it

that was swapped to bb load font

and it's just one so that's good

another one though was milliseconds

wasn't it

so we'll go search

find

really sex

and this one's a function with a very

distinct pattern so we can actually do a

bit of a

maybe milliseconds

but that's right across the timer

replace all will be brave enough yeah

and we're

brave that was pretty good it was not

that many in there so

quick save i thought there'd be lots of

those but there's not

wait timer there's a while in statement

there

this one we better be careful doing that

because um

wind might pop up in other words what i

mean is that the word

you might have a variable called you

know

yes

yeah s wend or something like that

and the search replace would find this

keyword inside another word

how annoying would that be pretty

annoying i would say

it was weird wasn't it

forward thanks

and

in a while

some of these white mouse things i i did

actually change those into a function

but

i kind of want to get away with changing

the least amount of code possible

if that makes any sense to people

then i'm

more

i'm more sure that we're not

corrupting the logic and behaviour of

the whole thing

you don't know like you don't know these

things

these is just waiting till the mouse is

not pressed

so that

just had a function that does the same

thing

mm-hmm

there's a lot of them

i'm sure you've just done

a global

a global replace

felt good about ourselves

let's comment it out but still

make that change

there's one there too color

all right

wow so we replaced uh

i might notice those uh

replaced wind sorry

wind

with uh

meanwhile

replaced load font

bb

load font

[Music]

did save the draw image simulink

control image

bb draw image

that doesn't mean that work just means

that we'll

have in our wrapper library why these

functions that do the equivalent of what

blitz was doing

color was one wasn't it

let's have a look for that

is it

color or is it color

cls color

oh that's a thing is it

so cls you use this cls color

didn't know that

okay

so perhaps we should

wrap all of these classes with with this

and then use this cls color what does

that just do black by default

i have no idea

i'm glad i searched for that so we'll go

same thing there so just say we know cls

color

uh cls

color

is a

cls color

this one with an o or u

no no

and we'll wrap cls as well

vbs

that's actually something i didn't

wasn't aware of that

i just thought you could just put the

color after the cls statement so

no

right so that was a cls

color

we want to find

here bb

and this will be bb cls

bb cls color

oh wow it's only you use the sum total

twice so it's not really

worth doing actually

so cls must be

oh geez

cls

jealous color

and that pops up more than there so

that's good

back buffer cls

bbc

another one there creating images

so it must be black by default and then

that special currents they must have

been changing the color to do something

else

yeah

i'll leave that there for a second

and i'll work when i pull that across

i'll worry about

what this thing is doing so light image

pretty much is

doing its own thing but i know i did

wrap load image to make it try and

emulate this thing better

so we'll go

with my image with bb

load image thank you

not very exciting to look at is it

sorry about that but

the tactic here is to try and

get more of this working um

in one hit

and it kind of means focusing then on

the structure of the rest of it

the actual structure so the type access

stuff

hmm all right so we've got the light

image good

the other one was uh

it was so i have lighting in strong

image and it was create image

create image it's all replacement with

this

let's find it

so it kind of means that when i drag the

functions across i'm not looking so much

what functions are

in the block of code that

blitz commands

i'm more interested in just converting

this straight logic across

so any type structure stuff or anything

like that

create

it should just help us reduce that sort

of over

a constant tedious going you know

back and forth about what's a function

what's not a function where is this

thing

so we do have a lot of these ones

a lot more than i thought there was

going to be

i probably could have done this up front

then she's showing you the results but

um

if you're a blitz person and you need to

yeah if your background is in blitz

basic and not in play basic

this is a approach you can use to

maybe not

be comfortable with the way pb works but

certainly you can

you can move some old code across and

without too much trouble

i didn't say without too much trouble

from their copy image as well

wow there's a lot of those i didn't

think there's only that many

bb create

so they're global surprise

global image handles

um

right we finally made it all the way

through so that's a lot more than was

anticipating

uh

what was another one that was resize

image that was definitely one we saw

um

image

just

call it the same thing

find resize image

that one's not a known known pv command

so we

don't

know that

there are more of these and

that's good

so we are

getting through some hidden these are

all inside the gadgets

who knows what that's doing

all right so there's a few of those in

there there

resizing resizing resizing

cool

um

all right

what are some other ones that i've

already wrapped

um

one mouse button mouse down is

key state

these have been wrapped uh to keep the

commands the same as what they were in

blitz

so you don't even have to modify those

bits of code they pop up and then just

i'll just compile as is

all right copy image was another one

image height was another one

and draw block toll block color

let's do

copy image

feel good about ourselves

resize image

copy image

search form

oh i didn't think this would be that

common that this might actually be very

common

copy image baby copy image

so it's cloning some of the okay so it

makes a bunch of these skin

elements

like images that are to do with

probably the gadgets and the windows all

that kind of stuff

oh no smaller

just when you think there's not going to

be

let's say for this one we'll do a

replace

we'll do

a copy image bracket

just insert the bb the front bb

copy image put the bracket on the end of

that replace all thanks

dude it's a lot isn't it

so we can probably do a wrapper of the

mouse state just pull the mouse position

up front gets coordinates the scroll

wheel the button state you know

compare it to previous frames so we can

check whether the button's been held or

whatever

the assumption is is that yeah if the

button's still down from last frame it's

still being held that kind of stuff

and then we can just have those as

variables and a lot of those function

calls inside everything that is in

it's calling a mouse function

could be replaced with just the

variables

as you know

[Music]

that will help us reduce logic errors

when things are being dragged and

clicked and moved because you can move

the mouse very quickly if you've got a

fast mouse it can be

moving while it's being read and being

read the next frame

so in pb it's asking the system all the

time where the mouse is

it might have moved since the last time

you called the function

crazy i know

image height draw a block there's a

color function

we don't really need to do that string

height plot wrecked

right pixel fast mask image that's

definitely a thing

um grab image

um

free image

i might actually

yeah

i might preface those with the bb staff

actually

so we had

we had free we had mask images

it's all put free

i've got a free image i'm going to do as

a mask image

this is going to be

i don't think that we use that that

frequently but we will soon find out

all right so free image let's have a

look

actually it probably is freeing a lot of

resources as it goes through isn't it

so i could leave that there because free

image is not actually a pv command but i

want to have a bb a blitz basic wrapper

of general commands that you can kind of

take blip's code from in the future and

drop it across and insert this you know

the bb

underscore in front of the command names

and kind of get stuff working

you know to a degree

and i guess the nice thing about having

a wrapper is you can do some sort of

checking inside the function to see if

stuff is

existing

i mean one of the most

common sort of errors that you find in

old code is that

there's logic pathways that just don't

make sense

yeah so

it's doing something and you discover oh

well you can get through here and then

delete something that you shouldn't be

able to delete

that's not really what you want

wow we have lots of those

i was not expecting that

what the hell is that doing if temp grow

than this

it's

it's terrifying and the amount of stuff

that's going on in this library

i should have expected that really

there's more

and off chances

i thought let's just try and try and

import it see how we go

and i've been confronted with a bunch of

changes that i wasn't expecting i think

not changes but just differences in the

way things work

so you can see why people would have

have trouble moving between the two

their mindset was is very different

you know if you

if you're not used to the idea of using

an array all the time

then you'd be like

what the hell

what's going on you know

oh i just missed one i think

um because the majority of code that

i've seen from blitz

has you know

particularly game examples

is

built around lists

so you need a way of emulating what

these list functions do and how they set

up and

and as i said before i've written code

that does that

but i was just surprised by the way

i'm not sure if all versions of blitz

work like this but they

seem to work

with the links or with a global

collection of these things and you kind

of step through them and stuff

i just wasn't expecting it

i thought i could just have a list and

that's my private list of stuff and then

up to me to keep this thing

uh okay give it all

but what i made

a pairing with

they just seem to have the same data in

them

which freaked me out a bit

and just made me think well how am i

going to convert this

point uh

gee i wasn't expecting

that many occurrences of that that's not

must be making it temp

let's just check we've got

if we're going to do it we might as well

do a decent job of it up front

to save ourselves time when we're moving

the functions across

ideally i want to move bigger blobs of

code and then

work my way through and do

replacements of

the rest of it

as in the type control code free image

that's what let's miss that one

three inch free image

cool

if you port get wrecked

sorry get color

hmm

we're definitely going to need

versions of those

uh rectus the pv function but now it's

wrapped in here the viewport's changed

draw image wow

more mouse control stuff we don't need

or shouldn't need

um

uh one before was

was color wasn't it

all right oh sorry we didn't do masking

image we only didn't free image so let's

do mask

uh

uh maybe we did

no we just did that one

baby mouse image

which is the

what is color red color green color blue

are they gui functions or blitz

functions

if they are where are we getting that

from

hmm

that's a good question

no

would be my simple answer

right so i think mask image is done this

color red what the hell is that

so i wonder if that grabs the red

component from the current color

current in color

because i don't think that's a function

in the library

just do a bit of a check see if

it is

i don't think it is

try that again

color red

color red color red color red

hmm okay

now

we call it ink and play basic i think

they just call it color

i'm sure that's got a conversion of that

over here somewhere

sure i've seen that function before

wrecked string color

hmm

so

yeah bb color red

now i'm gonna

just get going on a limb here and go

that's gonna go

so color equals

rgb

r

from get ink

from the current ink color

whatever again so this is going to grab

the current in color and then grab the r

component from it

so we

i've got green uh

we got blue

blue

and color blue

so we've added those to a little

conversion space

go back to here

and we'll just do replacement to those

functions

where's this

with bb

this green

blue and green

search replies

every time i do this stuff i'm always

going oh geez i wish i had a tool to do

this thing for me

to run through and do a bunch of this

preliminary conversion stuff

wouldn't that be neat

um

and it's a neat idea

and you you do if you do a lot of

translation it's definitely worth your

time to to write a tool for yourself to

convert

into to do rough conversions between one

source dialect

another

you know so if you've got

you might have a wrapper that wraps uh

in this case uh blitz basic very

well some of the blue spacing

just whatever's using this library here

we might do another one for you know

dark basic or a dark base professional

or igk you know whatever

you you affect your fancy yeah you know

and to accelerate the translation of

code between one and the other you might

have

writes up a little program that that

simply loads the source code in and does

a bunch of brute force replacements on

it

you know not pretty but

can speed up your life dramatically

this is what we're doing here so color

green sorry

let's do a replace of that thing

all right do you want to get this wrong

green

color green flysol

do all of them

cool

color blue is the last one

applies

buy soul

go for it

not as many of those

is that correct or not color red

find

color blue

now we probably should do color as well

actually shouldn't we

um

even though i've already done this in

the other port i've

called this allowed to be called

just color

so

this will still this will stop the code

from in here from working but

it'll help us be more consistent across

the whole thing

so anytime you see something with with

the prefix of

bb underscore it's a function that was a

blitz basic function so even if we have

functions that are the same name

they won't collide with functions in

playbase

internal logical stuff can cause

problems you know

like what string functions blitz has i

don't really know

we have all the general basic stuff like

the left strings and right strings and

mids and all that stuff you see in every

version of basic but

there's always variance between

languages

sometimes it's subtle sometimes they're

quite large

let's go do it

uh refine color effects

no not you are just i think it's got

space

still this color no so that would have

been a situation where if i had a color

replacement i would have replaced that

we don't want that

bb color

bb erect

color

get keller so you don't want that

that's nice that's actually nice

there means we can do some optimizations

for these functions when we translate we

can do our direct translation here

rather than calling a wrapped function

there's going to be a lot of this in it

yeah

it's going to be a lot of it that's cool

there

we go

hmm

so

it's not exactly what you thought i'd be

watching today is it

i just want to get more of this

converted across and then we can drop it

across easier and

um

i was actually planning on doing mostly

the window control stuff and the gadget

control stuff

i thought i could find functions that

accept gadgets

passed in i can do

at least stuff like

the

declaration of it

um sorry bb color

this is where actually you know writing

a alexa

would be

a great idea

for this very purpose

the amos thing i did before and the

other ones i've done in the past i've

generally had rules about where the

replacement occurs

so if i found a word i've gone back and

looked at the previous letter to check

it if it's not alphanumeric

in other words is it part of another

word

if it is don't skip it

it's a bit ugly but get the job done and

it's just a lot less jo sorry a lot less

work than riding a

full lexa

but if you do write alexa out

it saves

there's no real uh

things can't hide that way

you know you

another problem is if you do a

replacement and the code runs through

if

it will find words inside string

literals

yeah so you can get things broken like

that and

i'm just going to be careful all the

time

so some of these red colors here they

don't really need to do that

we've got um

pb rex command

has a color version so you can give it

the color at the end of this

i just wanted to keep that in line

with that

what's good color doing i reckon it's

that point

must be

it's a bunch of them

get color

geez

somehow we've we've put like an almost

an hour into doing this

sorry about that

i wasn't expecting it to take this long

and listening to me

waffle on about nothing is not what you

you were signing up for

[Music]

uh

if you are a blitz corridor and you have

uh some ideas about how to

that would help out

translating the stuff or

across or you want to

use the wrapper and improve the wrapper

then feel free

you know go for it

i tend to think it's kind of crazy that

all languages disappear and

and old code bases just

vanish

people's work disappears and they can't

do anything with it and

at least if you translate to another

language you've got two possible you

know ways for this off right

oh wow that was it was exciting that

wasn't

how many functions have we done

a fair few

also more that we've already done before

um

that will modify this other code

free image mask image

should be updated grab images one there

you go

hmm

gram image

copy image which i think is

um

just hey you make an image from an

existing

section of an image

that makes any sense

let's find this

thing grab the inch go for it

and there we go

when we set this thing up we when it's

being set up it's gonna have to do a lot

of grabbing images

it's not 100 about sure sure about what

those buffer commands are doing but you

know

yeah

let's not worry about it

i think in retrospect there

it makes sense to actually have a grab

image

i know in pv when you grab the image

from a surface it inherits the mask

color

so once it's set on the first

buffer

i'm gonna see if you're drawing to the

screen though i guess

there's probably old versions of people

that don't work like that you know

that's what normally happens is you you

say something then go oh my god one

doesn't do that

well

it does now

i mean changes over time can be very

subtle but it can can actually

really

uh improve the feel of something over

time

uh for our preliminary pass we might to

leave that there and we'll just jump

across into

our functions here

just jump across to the other the pv

port code

and uh

we'll do a compile then we use compiler

to

catching each each time we've got a

broken bit

mask image

let's change those you know so update

them grab

grab

the mask

i only have a section of this

stuff poured across so

free image

bb free image thank you

nice

i probably should have done this upfront

i was concerned about damaging the code

i even looked at it

which is a real thing

maybe calendar

uh when i use compile to do that

it's using the lecture so actually we're

hitting the function name that doesn't

exist so it's a very accurate way of

picking up where the next thing

is

um

slightly slower than doing like a search

replace but yeah

so we can just fire them in order

as it uses stuff

it's color function there

how far are we getting

let's draw a block there do we change

that or not

um

one downside of creating wrappers like

this is that you you are actually

adding some extra weight

on top of your application

and

generally speaking pb is pretty good at

that

generally

you know it's

it is uh compiled to buy code in front

of a virtual machine so

you won't have too much extra bloat in

what you're doing great

so we're working as well as what we did

before which is

not saying much

but we are back to that same

let's try and minimize maximize works

again

whatever that button there does that's

the push to back button

yeah

when you do a push-to-back stuff doesn't

work

how dare it not work

how dare that not work

blitzwrapper thank you

so this controls

we're not we're not really using those

at the moment

graphics width i don't really use much

of that in here but for completeness

we'll make those bb and

preface with those

graphics buffer we've got to do those as

well

bb

um

front buffer back buffer

see how frequently they they come up

i think they just use the whites in the

whole program which is probably good

good

i could probably make that just one

function could not set a front buffer as

one thing

intentionally trying to catch at the

moment we've got two function calls for

no real reason

just saying

don't get ahead of yourself just keep

doing what you're doing

one of the biggest problems in in

writing software is you often think oh

maybe i should add this thing up this

other thing to this or implement

something else or change it somehow

and before you know it you've

your to-do list is huge

and

all the responsibilities you have in

your code you can't really maintain them

or match them

well we do actually have

that one there so that's good

yes

it's not just once

well that would be just once

and just change both the eyes so that

would be

hmm

the least productive bit of pawning

we've done so far

um

it does make you want to make a little

function that

loads in the source code and just

absolutely watches it

i did think about doing a blitz

converter a while ago

um sort of

actually more than thought about it

start

start a bit of work on it

all right

so those ones there we've got graphics

buffer front buffer and back buffer so

i'll do replacements of those

so we're going to replace front buffer

back buffer with that

and let's just do it

just do a complete replacement of it

place all

go for it

the temptation is to make that

replacement there but i want to want to

use search replace to do that properly

um

if i go changing it myself it'll insert

bb underscore bb underscore bb into it

if you know what i'm talking about

if you don't then try it yourself and

see what happens

you probably won't like your response

applies all

yeah

there's a lot of those throughout the

whole

the original code base anyway so

so we've done a bunch of command

replacements we might just do a quick

quick test about

replaced wind dot window

look at the functions with this pattern

if you

if you're passing in

uh this in particular

and we want to output this

when as

window

pointer so we're going to save ourselves

a little bit

if any of those exist

they may not

we might actually have to go and look

for these things on a closer level so if

we go win dot sorry we want to look for

this win dot

window

okay search for it

find

status

now i think that's

popping up

frequently here sorry

with enough frequency to make it worse

than a replacement there

but i didn't replace those by the way so

i'm gonna go win

win dot window

close bracket so it's a function call

or assuming it's a function header

actually

win as window

pointer

here

replies to all things

are we brave enough yeah let's do it

the same and go for gadgets

functions that accept gadgets as uh

as parameters

that'd be handy

just trying to find one

no there's lots of lots of stuff on that

isn't it

wow

frames and stuff it's a file requested

number

no wonder it doesn't look simple

gui file type

it's gui file

no don't start doing those

sort files

repeat until the stuff is done

hmm

now

those patterns there wind.window are

still inside the code but they're

something else there are other other

locations let's have a search for them

so we'll find

there'll be internal

declarations

there's a

don't want to replace that until we

replace that

without translation of this we use an

array we saw the when we link the

of cells to each other

to emulate the

linked list behavior of what blitz does

so thinking maybe i can actually do

maybe i can have a wrapped function

called a new window

that does the behavior and just returns

a pointer back to window here

so if that showed up more than once

listen see there's another pattern there

look at that

yeah we'll tackle that one there first

actually

i've got a comma at the end there so

these are functions they're expecting

a window passed to them

make a note of what we did

just in case of

so we're replaced

so i replaced

this pattern

as

i'll put a space there as window

pointer

comma

so any function that has that header we

should catch those

are we nervous ah

no we're not nervous let's just do it

so we want win dot window pointer then

we want a collar at the end of that we

want this last bracket to be replaced

with a comma

place all

yeah let's do it

just catches a bunch more of these cases

that we we hope are unique

that we're otherwise having to do so

that's good

passing in win is this thing here it's

all good

we probably could catch a great deal of

these

particular patterns globally

now i'm more comfortable with how blitz

is operating

but i might do those as we do the

replacements as we move across but the

declarations i want to catch those up

front

uh this for each loop here

sorry there's another one too dot gadget

so

these have to be updated as well gadgets

have to be updated

in these declaration spaces up here so

look for this pattern

it's going to end up

gad.gadget.pointer sorry as pointer

look for gad.gadget first of all

use the same one as we do with windows

yeah we've got some of that stuff

and a lot of them that's good

means that we're not

it's not gonna

um

because we are gonna save ourselves some

time

and it is worth doing

so here

again a reminder about what we did

replaced

this thing

as this time it's going to be gad

do it up guys get as

gadget pointer

the bracket on the end

uh

where are we replies

that's what i have to do for today

actually god got gadget

oh geez that's all

right a couple of elections in that

gathers gadget pointer again all right

replace all

it just means that our declarations will

be cleaned up for us by the time we even

drag the code across

um

we'll try and tackle the other one there

too so

we'll do gadget with brac

the opening bracket and then we'll do

a

comma at the end there

so we just search for that

the reason i'm

happy with doing the pattern

of having brackets around things is

they can only really occur

as far as i'm aware in a function

declaration

that's just within this bit of code so

search for it

should be pretty pretty what

it is function

declarations and it's going to save us a

bunch of time so

let's press ahead and do it

grab that thing

oh don't do that you're sleeping

slice

comma thing

here with a

comma get it replaced let's go

all of them

thinking about it

cool

that is good i like that

i don't know what any of those functions

they

do i've not a clue i haven't looked at

much of the code that's that's the

reason why for that

uh um

this is the return type here

i would probably need a bit of code to

run through and do the function headers

so you could you could do your search

replace thing as i say before

if you

treated this as a big blob of text

did

you just look for a function

well the trick i normally use actually

is is i

the function is going to be hard up

against the the last end of line

character so you have um

character 10 character 13 at the end of

the line so you can use that as a search

um

as part of your search

which means that uh you'll be getting

these there's two invisible characters

at the end of a line

which you can't normally see of course

but if you just search for function in

those characters with a space after it

or a tab

that gets you to here

you search across you look for

a bracket

and that gives you these characters here

and you go well is there any

uh period characters in there or dark

characters and that's how you grab that

that from it

pull it out

reinsert it you know

and just keep searching

but you would use that as the

you know

the return here

so you probably

you wouldn't get you know nice clean

clean result but you you put this on the

end of your end function as

just have preface it with you know as

whatever

whatever the type name is

and

a pointer or something

and that would you know okay

a small

bit of code could do a lot of the brute

force

rubbishy work

up front

for small code biases it's not really

warranted but for big things like this

yeah probably that probably is the way

to go

to do large ports

all right

i think we'll leave this here and we'll

try and tackle some more of this um

tonight because we are actually

probably

you know an hour and 20 minutes where

it's going to be which is too long for

an episode

they take ages to add these things down

but i want this to be

pretty much live

the whole thing

maybe at the end we might shorten up the

episodes a bit and we might do

i might do a session and then show you

the results rather than doing because

we're going to be doing a lot of the

same stuff over and over again from here

on in i would think

i would think

um

i do want to convert

these globals to a type structure and

have them all just at the top of the

program

and

primarily get to work

with explicit mode enabled

which means making sure all the

variables are declared up front so

having those places where there's

variables that are not used and

other places where i think there might

be typos

in the in the code

i'm not sure

you know we all make mistake i mean

everything i've ever written is full of

bugs so

all right thanks for

for watching

thanks for hanging out and um we'll see

you soon after

just check the that one's still working

and well

by working i mean

has it blown up

it's pretty good

so if i

if i use the back button which is the

button next to here

if i

sorry i keep using the wrong button

now i think it's the push to back button

here

once that's been pushed to back

all bets are off with selection so

pretty weird

pretty weird

i might find myself rewriting that

selection code

to something i'm more comfortable either

i'm thinking about having if i can get

the gadgets to work and i should work if

i can get the windows to work

um

i think actually some of that stuff will

be easier than my

what you might be thinking

just once we have our logic in place and

all of the

the data types and so the types match up

should work fine

i didn't say should didn't say it will

should work fine you know anyway

until next time thanks for watching and

i'll see you then bye

[Music]

[Music]

to

[Music]

you


   




  Download:

         NOTE: No notable differences to V007 code of PB conversion


kevin

   Porting BlitzBASIC 2 PlayBASIC - First Look - (2022-02-20)


  During the process of porting XLnt GUI episode #8,  I talked a lot about the repetitive processes of code conversion.   In the context of our XLnt GUI conversion there's a bunch of common changes we're making that could better done with a tool.

 So here's our first look a our tool to convert BlitzBASIC to PLayBASIC..

 




 Script:

 
hi welcome back

very quick uh recording here we're

outside

and it's very noisy so

episode 8 of this conversion of

excellent GUI was all about doing

replacements of the original code

i'll give you a quick look at the the

result of that

so we went through and did replacements

of all of these

known functions

replace certain common syntaxes that

occur within the code

trouble is if we have to do multiple

multiple ports of this code in the

future

um we're going to end up having to do

this crap over and over again so i bit

the bullet yesterday

nice big truck driving pass

i bit the bullet and went

i'll convert one of the lexus to do this

job

to well at least have a framework for

doing this this kind of conversion job

from blitz to player basic so it'll

handle

at the moment it doesn't really handle

any of the translation at all it just

loads the document and splits it out

in a tokenized form for us to make the

modifications too so if we just run it

for example

so i can load the gui source code the

9000 lines in about a third of a second

which is pretty good

if we write in debug mode

we can investigate some of the stuff

that's happening it spits out a bunch of

garbage to the console

and it's working through you know

so into variables up here

we look at sort of the stats we've got

thirty thousand searches hash collisions

collisions are about ten percent of that

in other words keywords that have the

same hash

or has to do a second search

um

we're just using using play basics

internal

find array stuff to do that sort of

stuff in this one

sorry the keywords are split up into

a bunch of different blocks they can

have constants

uh

directives and command names

the code i grabbed before was the one i

posted the other day just sort of

butchered it up to do to do

rather than convert pb to html was just

kind of import some blitz and do some

modifications to it

i mean the goal is really to get a few

simple passes that would do a lot of the

annoying grant work for us so if you

ever have to convert more blips code

across which is probably going to happen

at some point

i've got a bunch of things i wouldn't

mind converting

that i wrote in blitz to pb for example

and i'm sure others have the same thing

the objective is not to make this thing

work

as in spit out working code i mean for

some programs it probably will

simple programs but our objectives to

make a lot of the

annoying

you know sort of

crappy work that you have to do all the

time

like uh certain replacements etc

if you go up to here

back to the original code here with

things like you know word replacements

for while loops and um

i think there's ones there for

even types of different keywords

so

our translator will do things like it'll

merge this into one word it'll pull out

the field stuff

it'll look at the fields themselves and

give us an indication of what this

should be

um

well i think the conversion should be to

emulate what blips are doing

you'll have to probably fix those up

yourself but you know

so a lot of this would just be import

spit out and then then you start to your

yeah you start your hands on work from

there

because a lot of this stuff it needs to

get done

that you'd be constantly doing every

time you import something my initial

theory was well i might just uh

as i was talking about in episode 8

which i'll cut that together at some

point and put that up i was talking

about

making a translator that just looked

through this particular input code

found the common things that i'm

interested in and then re you know laid

them out in such a way that that's going

to be

comfortable for pv

the more i thought about that the more i

thought well

what we really really need to do is have

something that will

be more generalized and do roughly the

same thing so if we tokenize it first

and sweep through it and clear it up

that's how we'll do it

that's enough enough for now i'll give

you

some more updates on this as we go

through

um

i'd say that by probably the next day or

so it'll be doing most of the

translations we're doing already

any blitz functions they'll be they'll

end up as wrapped codes i'll have this

this uh

they'll be prefaced with where are we

here

oh no that's the original code sorry

um

i kept two versions so yeah they'll have

they'll end up with bb underscore

wrapper under them so you would have to

make

a function in pb code that emulates what

that function does

uh over time we'll build a list of these

emulated functions and this will make

more programs work they won't be optimal

but they'll kind of work you know

that's the goal you know i'll spend a

bit of time on it and see if we can get

to a point where it where it saves time

not just for this project for other

products down the road

little different amp thanks for

listening and i'll see you next time bye


 


  -- Script On PasteBin


stevmjon

It's easy to start a program, but harder to finish it...

I think that means i am getting old and get side tracked too easy.

kevin


 Finally got around to editing and uploading the Episode #8..  even though it's pretty out of date now..  


 




    Links:

         -- Convert BlitzBASIC Source Code To PlayBASIC (WIP THREAD)



   Video Script:


hello welcome back here we are with

episode 8 of our adventures of porting

excellent GUI

if you feel like giving us a like and

subscribe then you know what the buttons

are in the bottom

as for the gy i think we're going to

change tact a little bit

what we might do is we might

jump to the original source and

do a bunch of replacement style things

to that to

since we've got a concept now of how

these things are going to work

i'll keep two copies of the original

the

modified version and the

the original code

let's load that up

reopen thank you and that's

the original code there

what i might do is i might

add a uh

add a new file to it we'll call this the

original code

original

excellent gui

code

hit close

go here and just go select all

select all

copy that

and drag it over here

it doesn't mean i've got to be careful

now when we use replace for example

we're going to

make sure we're not going to not going

to be replacing that main document

uh

we'll do things like

since we've got a since our wrapper uh

handles things like

well i look for them

i i know draw image is one that we've

already wrapped so we could do

and then while end is another one that

we've already

already doing so we might do a

catch of that one there as well

we might not do a replace might just do

a search

update like that

and my reason for that is is that

sometimes you can catch things inside

other things where you don't want them

there's a lot of drawing images in there

probably a lot more than what i was

anticipating

this is going to be the order of this

session is going to be try and modify

this code

up front and then drop it drop in some

gadget code

and

try and start piecing this thing

together

draw image

and move back to the start

good

i might put a note at the top of this

code uh

this code

has

some bb wrapper replacements

just in case i somehow forget that i

probably won't but

you never know

just never know these things

all right what's some other ones that we

wrapped in our main library

our blitz wrappers back here so we'll

have a look at it

load font was one of them so we'll do a

load font

replace milliseconds with timer

uh

back to here

i don't think there'll be too many large

fonts actually

didn't seem like a function that would

be used that frequently in this code

base load of font

we've got one usage of it

that was swapped to bb load font

and it's just one so that's good

another one though was milliseconds

wasn't it

so we'll go search

find

really sex

and this one's a function with a very

distinct pattern so we can actually do a

bit of a

maybe milliseconds

but that's right across the timer

replace all will be brave enough yeah

and we're

brave that was pretty good it was not

that many in there so

quick save i thought there'd be lots of

those but there's not

wait timer there's a while in statement

there

this one we better be careful doing that

because um

wind might pop up in other words what i

mean is that the word

you might have a variable called you

know

yes

yeah s wend or something like that

and the search replace would find this

keyword inside another word

how annoying would that be pretty

annoying i would say

it was weird wasn't it

forward thanks

and

in a while

some of these white mouse things i i did

actually change those into a function

but

i kind of want to get away with changing

the least amount of code possible

if that makes any sense to people

then i'm

more

i'm more sure that we're not

corrupting the logic and behaviour of

the whole thing

you don't know like you don't know these

things

these is just waiting till the mouse is

not pressed

so that

just had a function that does the same

thing

mm-hmm

there's a lot of them

i'm sure you've just done

a global

a global replace

felt good about ourselves

let's comment it out but still

make that change

there's one there too color

all right

wow so we replaced uh

i might notice those uh

replaced wind sorry

wind

with uh

meanwhile

replaced load font

bb

load font

[Music]

did save the draw image simulink

control image

bb draw image

that doesn't mean that work just means

that we'll

have in our wrapper library why these

functions that do the equivalent of what

blitz was doing

color was one wasn't it

let's have a look for that

is it

color or is it color

cls color

oh that's a thing is it

so cls you use this cls color

didn't know that

okay

so perhaps we should

wrap all of these classes with with this

and then use this cls color what does

that just do black by default

i have no idea

i'm glad i searched for that so we'll go

same thing there so just say we know cls

color

uh cls

color

is a

cls color

this one with an o or u

no no

and we'll wrap cls as well

vbs

that's actually something i didn't

wasn't aware of that

i just thought you could just put the

color after the cls statement so

no

right so that was a cls

color

we want to find

here bb

and this will be bb cls

bb cls color

oh wow it's only you use the sum total

twice so it's not really

worth doing actually

so cls must be

oh geez

cls

jealous color

and that pops up more than there so

that's good

back buffer cls

bbc

another one there creating images

so it must be black by default and then

that special currents they must have

been changing the color to do something

else

yeah

i'll leave that there for a second

and i'll work when i pull that across

i'll worry about

what this thing is doing so light image

pretty much is

doing its own thing but i know i did

wrap load image to make it try and

emulate this thing better

so we'll go

with my image with bb

load image thank you

not very exciting to look at is it

sorry about that but

the tactic here is to try and

get more of this working um

in one hit

and it kind of means focusing then on

the structure of the rest of it

the actual structure so the type access

stuff

hmm all right so we've got the light

image good

the other one was uh

it was so i have lighting in strong

image and it was create image

create image it's all replacement with

this

let's find it

so it kind of means that when i drag the

functions across i'm not looking so much

what functions are

in the block of code that

blitz commands

i'm more interested in just converting

this straight logic across

so any type structure stuff or anything

like that

create

it should just help us reduce that sort

of over

a constant tedious going you know

back and forth about what's a function

what's not a function where is this

thing

so we do have a lot of these ones

a lot more than i thought there was

going to be

i probably could have done this up front

then she's showing you the results but

um

if you're a blitz person and you need to

yeah if your background is in blitz

basic and not in play basic

this is a approach you can use to

maybe not

be comfortable with the way pb works but

certainly you can

you can move some old code across and

without too much trouble

i didn't say without too much trouble

from their copy image as well

wow there's a lot of those i didn't

think there's only that many

bb create

so they're global surprise

global image handles

um

right we finally made it all the way

through so that's a lot more than was

anticipating

uh

what was another one that was resize

image that was definitely one we saw

um

image

just

call it the same thing

find resize image

that one's not a known known pv command

so we

don't

know that

there are more of these and

that's good

so we are

getting through some hidden these are

all inside the gadgets

who knows what that's doing

all right so there's a few of those in

there there

resizing resizing resizing

cool

um

all right

what are some other ones that i've

already wrapped

um

one mouse button mouse down is

key state

these have been wrapped uh to keep the

commands the same as what they were in

blitz

so you don't even have to modify those

bits of code they pop up and then just

i'll just compile as is

all right copy image was another one

image height was another one

and draw block toll block color

let's do

copy image

feel good about ourselves

resize image

copy image

search form

oh i didn't think this would be that

common that this might actually be very

common

copy image baby copy image

so it's cloning some of the okay so it

makes a bunch of these skin

elements

like images that are to do with

probably the gadgets and the windows all

that kind of stuff

oh no smaller

just when you think there's not going to

be

let's say for this one we'll do a

replace

we'll do

a copy image bracket

just insert the bb the front bb

copy image put the bracket on the end of

that replace all thanks

dude it's a lot isn't it

so we can probably do a wrapper of the

mouse state just pull the mouse position

up front gets coordinates the scroll

wheel the button state you know

compare it to previous frames so we can

check whether the button's been held or

whatever

the assumption is is that yeah if the

button's still down from last frame it's

still being held that kind of stuff

and then we can just have those as

variables and a lot of those function

calls inside everything that is in

it's calling a mouse function

could be replaced with just the

variables

as you know

[Music]

that will help us reduce logic errors

when things are being dragged and

clicked and moved because you can move

the mouse very quickly if you've got a

fast mouse it can be

moving while it's being read and being

read the next frame

so in pb it's asking the system all the

time where the mouse is

it might have moved since the last time

you called the function

crazy i know

image height draw a block there's a

color function

we don't really need to do that string

height plot wrecked

right pixel fast mask image that's

definitely a thing

um grab image

um

free image

i might actually

yeah

i might preface those with the bb staff

actually

so we had

we had free we had mask images

it's all put free

i've got a free image i'm going to do as

a mask image

this is going to be

i don't think that we use that that

frequently but we will soon find out

all right so free image let's have a

look

actually it probably is freeing a lot of

resources as it goes through isn't it

so i could leave that there because free

image is not actually a pv command but i

want to have a bb a blitz basic wrapper

of general commands that you can kind of

take blip's code from in the future and

drop it across and insert this you know

the bb

underscore in front of the command names

and kind of get stuff working

you know to a degree

and i guess the nice thing about having

a wrapper is you can do some sort of

checking inside the function to see if

stuff is

existing

i mean one of the most

common sort of errors that you find in

old code is that

there's logic pathways that just don't

make sense

yeah so

it's doing something and you discover oh

well you can get through here and then

delete something that you shouldn't be

able to delete

that's not really what you want

wow we have lots of those

i was not expecting that

what the hell is that doing if temp grow

than this

it's

it's terrifying and the amount of stuff

that's going on in this library

i should have expected that really

there's more

and off chances

i thought let's just try and try and

import it see how we go

and i've been confronted with a bunch of

changes that i wasn't expecting i think

not changes but just differences in the

way things work

so you can see why people would have

have trouble moving between the two

their mindset was is very different

you know if you

if you're not used to the idea of using

an array all the time

then you'd be like

what the hell

what's going on you know

oh i just missed one i think

um because the majority of code that

i've seen from blitz

has you know

particularly game examples

is

built around lists

so you need a way of emulating what

these list functions do and how they set

up and

and as i said before i've written code

that does that

but i was just surprised by the way

i'm not sure if all versions of blitz

work like this but they

seem to work

with the links or with a global

collection of these things and you kind

of step through them and stuff

i just wasn't expecting it

i thought i could just have a list and

that's my private list of stuff and then

up to me to keep this thing

uh okay give it all

but what i made

a pairing with

they just seem to have the same data in

them

which freaked me out a bit

and just made me think well how am i

going to convert this

point uh

gee i wasn't expecting

that many occurrences of that that's not

must be making it temp

let's just check we've got

if we're going to do it we might as well

do a decent job of it up front

to save ourselves time when we're moving

the functions across

ideally i want to move bigger blobs of

code and then

work my way through and do

replacements of

the rest of it

as in the type control code free image

that's what let's miss that one

three inch free image

cool

if you port get wrecked

sorry get color

hmm

we're definitely going to need

versions of those

uh rectus the pv function but now it's

wrapped in here the viewport's changed

draw image wow

more mouse control stuff we don't need

or shouldn't need

um

uh one before was

was color wasn't it

all right oh sorry we didn't do masking

image we only didn't free image so let's

do mask

uh

uh maybe we did

no we just did that one

baby mouse image

which is the

what is color red color green color blue

are they gui functions or blitz

functions

if they are where are we getting that

from

hmm

that's a good question

no

would be my simple answer

right so i think mask image is done this

color red what the hell is that

so i wonder if that grabs the red

component from the current color

current in color

because i don't think that's a function

in the library

just do a bit of a check see if

it is

i don't think it is

try that again

color red

color red color red color red

hmm okay

now

we call it ink and play basic i think

they just call it color

i'm sure that's got a conversion of that

over here somewhere

sure i've seen that function before

wrecked string color

hmm

so

yeah bb color red

now i'm gonna

just get going on a limb here and go

that's gonna go

so color equals

rgb

r

from get ink

from the current ink color

whatever again so this is going to grab

the current in color and then grab the r

component from it

so we

i've got green uh

we got blue

blue

and color blue

so we've added those to a little

conversion space

go back to here

and we'll just do replacement to those

functions

where's this

with bb

this green

blue and green

search replies

every time i do this stuff i'm always

going oh geez i wish i had a tool to do

this thing for me

to run through and do a bunch of this

preliminary conversion stuff

wouldn't that be neat

um

and it's a neat idea

and you you do if you do a lot of

translation it's definitely worth your

time to to write a tool for yourself to

convert

into to do rough conversions between one

source dialect

another

you know so if you've got

you might have a wrapper that wraps uh

in this case uh blitz basic very

well some of the blue spacing

just whatever's using this library here

we might do another one for you know

dark basic or a dark base professional

or igk you know whatever

you you affect your fancy yeah you know

and to accelerate the translation of

code between one and the other you might

have

writes up a little program that that

simply loads the source code in and does

a bunch of brute force replacements on

it

you know not pretty but

can speed up your life dramatically

this is what we're doing here so color

green sorry

let's do a replace of that thing

all right do you want to get this wrong

green

color green flysol

do all of them

cool

color blue is the last one

applies

buy soul

go for it

not as many of those

is that correct or not color red

find

color blue

now we probably should do color as well

actually shouldn't we

um

even though i've already done this in

the other port i've

called this allowed to be called

just color

so

this will still this will stop the code

from in here from working but

it'll help us be more consistent across

the whole thing

so anytime you see something with with

the prefix of

bb underscore it's a function that was a

blitz basic function so even if we have

functions that are the same name

they won't collide with functions in

playbase

internal logical stuff can cause

problems you know

like what string functions blitz has i

don't really know

we have all the general basic stuff like

the left strings and right strings and

mids and all that stuff you see in every

version of basic but

there's always variance between

languages

sometimes it's subtle sometimes they're

quite large

let's go do it

uh refine color effects

no not you are just i think it's got

space

still this color no so that would have

been a situation where if i had a color

replacement i would have replaced that

we don't want that

bb color

bb erect

color

get keller so you don't want that

that's nice that's actually nice

there means we can do some optimizations

for these functions when we translate we

can do our direct translation here

rather than calling a wrapped function

there's going to be a lot of this in it

yeah

it's going to be a lot of it that's cool

there

we go

hmm

so

it's not exactly what you thought i'd be

watching today is it

i just want to get more of this

converted across and then we can drop it

across easier and

um

i was actually planning on doing mostly

the window control stuff and the gadget

control stuff

i thought i could find functions that

accept gadgets

passed in i can do

at least stuff like

the

declaration of it

um sorry bb color

this is where actually you know writing

a alexa

would be

a great idea

for this very purpose

the amos thing i did before and the

other ones i've done in the past i've

generally had rules about where the

replacement occurs

so if i found a word i've gone back and

looked at the previous letter to check

it if it's not alphanumeric

in other words is it part of another

word

if it is don't skip it

it's a bit ugly but get the job done and

it's just a lot less jo sorry a lot less

work than riding a

full lexa

but if you do write alexa out

it saves

there's no real uh

things can't hide that way

you know you

another problem is if you do a

replacement and the code runs through

if

it will find words inside string

literals

yeah so you can get things broken like

that and

i'm just going to be careful all the

time

so some of these red colors here they

don't really need to do that

we've got um

pb rex command

has a color version so you can give it

the color at the end of this

i just wanted to keep that in line

with that

what's good color doing i reckon it's

that point

must be

it's a bunch of them

get color

geez

somehow we've we've put like an almost

an hour into doing this

sorry about that

i wasn't expecting it to take this long

and listening to me

waffle on about nothing is not what you

you were signing up for

[Music]

uh

if you are a blitz corridor and you have

uh some ideas about how to

that would help out

translating the stuff or

across or you want to

use the wrapper and improve the wrapper

then feel free

you know go for it

i tend to think it's kind of crazy that

all languages disappear and

and old code bases just

vanish

people's work disappears and they can't

do anything with it and

at least if you translate to another

language you've got two possible you

know ways for this off right

oh wow that was it was exciting that

wasn't

how many functions have we done

a fair few

also more that we've already done before

um

that will modify this other code

free image mask image

should be updated grab images one there

you go

hmm

gram image

copy image which i think is

um

just hey you make an image from an

existing

section of an image

that makes any sense

let's find this

thing grab the inch go for it

and there we go

when we set this thing up we when it's

being set up it's gonna have to do a lot

of grabbing images

it's not 100 about sure sure about what

those buffer commands are doing but you

know

yeah

let's not worry about it

i think in retrospect there

it makes sense to actually have a grab

image

i know in pv when you grab the image

from a surface it inherits the mask

color

so once it's set on the first

buffer

i'm gonna see if you're drawing to the

screen though i guess

there's probably old versions of people

that don't work like that you know

that's what normally happens is you you

say something then go oh my god one

doesn't do that

well

it does now

i mean changes over time can be very

subtle but it can can actually

really

uh improve the feel of something over

time

uh for our preliminary pass we might to

leave that there and we'll just jump

across into

our functions here

just jump across to the other the pv

port code

and uh

we'll do a compile then we use compiler

to

catching each each time we've got a

broken bit

mask image

let's change those you know so update

them grab

grab

the mask

i only have a section of this

stuff poured across so

free image

bb free image thank you

nice

i probably should have done this upfront

i was concerned about damaging the code

i even looked at it

which is a real thing

maybe calendar

uh when i use compile to do that

it's using the lecture so actually we're

hitting the function name that doesn't

exist so it's a very accurate way of

picking up where the next thing

is

um

slightly slower than doing like a search

replace but yeah

so we can just fire them in order

as it uses stuff

it's color function there

how far are we getting

let's draw a block there do we change

that or not

um

one downside of creating wrappers like

this is that you you are actually

adding some extra weight

on top of your application

and

generally speaking pb is pretty good at

that

generally

you know it's

it is uh compiled to buy code in front

of a virtual machine so

you won't have too much extra bloat in

what you're doing great

so we're working as well as what we did

before which is

not saying much

but we are back to that same

let's try and minimize maximize works

again

whatever that button there does that's

the push to back button

yeah

when you do a push-to-back stuff doesn't

work

how dare it not work

how dare that not work

blitzwrapper thank you

so this controls

we're not we're not really using those

at the moment

graphics width i don't really use much

of that in here but for completeness

we'll make those bb and

preface with those

graphics buffer we've got to do those as

well

bb

um

front buffer back buffer

see how frequently they they come up

i think they just use the whites in the

whole program which is probably good

good

i could probably make that just one

function could not set a front buffer as

one thing

intentionally trying to catch at the

moment we've got two function calls for

no real reason

just saying

don't get ahead of yourself just keep

doing what you're doing

one of the biggest problems in in

writing software is you often think oh

maybe i should add this thing up this

other thing to this or implement

something else or change it somehow

and before you know it you've

your to-do list is huge

and

all the responsibilities you have in

your code you can't really maintain them

or match them

well we do actually have

that one there so that's good

yes

it's not just once

well that would be just once

and just change both the eyes so that

would be

hmm

the least productive bit of pawning

we've done so far

um

it does make you want to make a little

function that

loads in the source code and just

absolutely watches it

i did think about doing a blitz

converter a while ago

um sort of

actually more than thought about it

start

start a bit of work on it

all right

so those ones there we've got graphics

buffer front buffer and back buffer so

i'll do replacements of those

so we're going to replace front buffer

back buffer with that

and let's just do it

just do a complete replacement of it

place all

go for it

the temptation is to make that

replacement there but i want to want to

use search replace to do that properly

um

if i go changing it myself it'll insert

bb underscore bb underscore bb into it

if you know what i'm talking about

if you don't then try it yourself and

see what happens

you probably won't like your response

applies all

yeah

there's a lot of those throughout the

whole

the original code base anyway so

so we've done a bunch of command

replacements we might just do a quick

quick test about

replaced wind dot window

look at the functions with this pattern

if you

if you're passing in

uh this in particular

and we want to output this

when as

window

pointer so we're going to save ourselves

a little bit

if any of those exist

they may not

we might actually have to go and look

for these things on a closer level so if

we go win dot sorry we want to look for

this win dot

window

okay search for it

find

status

now i think that's

popping up

frequently here sorry

with enough frequency to make it worse

than a replacement there

but i didn't replace those by the way so

i'm gonna go win

win dot window

close bracket so it's a function call

or assuming it's a function header

actually

win as window

pointer

here

replies to all things

are we brave enough yeah let's do it

the same and go for gadgets

functions that accept gadgets as uh

as parameters

that'd be handy

just trying to find one

no there's lots of lots of stuff on that

isn't it

wow

frames and stuff it's a file requested

number

no wonder it doesn't look simple

gui file type

it's gui file

no don't start doing those

sort files

repeat until the stuff is done

hmm

now

those patterns there wind.window are

still inside the code but they're

something else there are other other

locations let's have a search for them

so we'll find

there'll be internal

declarations

there's a

don't want to replace that until we

replace that

without translation of this we use an

array we saw the when we link the

of cells to each other

to emulate the

linked list behavior of what blitz does

so thinking maybe i can actually do

maybe i can have a wrapped function

called a new window

that does the behavior and just returns

a pointer back to window here

so if that showed up more than once

listen see there's another pattern there

look at that

yeah we'll tackle that one there first

actually

i've got a comma at the end there so

these are functions they're expecting

a window passed to them

make a note of what we did

just in case of

so we're replaced

so i replaced

this pattern

as

i'll put a space there as window

pointer

comma

so any function that has that header we

should catch those

are we nervous ah

no we're not nervous let's just do it

so we want win dot window pointer then

we want a collar at the end of that we

want this last bracket to be replaced

with a comma

place all

yeah let's do it

just catches a bunch more of these cases

that we we hope are unique

that we're otherwise having to do so

that's good

passing in win is this thing here it's

all good

we probably could catch a great deal of

these

particular patterns globally

now i'm more comfortable with how blitz

is operating

but i might do those as we do the

replacements as we move across but the

declarations i want to catch those up

front

uh this for each loop here

sorry there's another one too dot gadget

so

these have to be updated as well gadgets

have to be updated

in these declaration spaces up here so

look for this pattern

it's going to end up

gad.gadget.pointer sorry as pointer

look for gad.gadget first of all

use the same one as we do with windows

yeah we've got some of that stuff

and a lot of them that's good

means that we're not

it's not gonna

um

because we are gonna save ourselves some

time

and it is worth doing

so here

again a reminder about what we did

replaced

this thing

as this time it's going to be gad

do it up guys get as

gadget pointer

the bracket on the end

uh

where are we replies

that's what i have to do for today

actually god got gadget

oh geez that's all

right a couple of elections in that

gathers gadget pointer again all right

replace all

it just means that our declarations will

be cleaned up for us by the time we even

drag the code across

um

we'll try and tackle the other one there

too so

we'll do gadget with brac

the opening bracket and then we'll do

a

comma at the end there

so we just search for that

the reason i'm

happy with doing the pattern

of having brackets around things is

they can only really occur

as far as i'm aware in a function

declaration

that's just within this bit of code so

search for it

should be pretty pretty what

it is function

declarations and it's going to save us a

bunch of time so

let's press ahead and do it

grab that thing

oh don't do that you're sleeping

slice

comma thing

here with a

comma get it replaced let's go

all of them

thinking about it

cool

that is good i like that

i don't know what any of those functions

they

do i've not a clue i haven't looked at

much of the code that's that's the

reason why for that

uh um

this is the return type here

i would probably need a bit of code to

run through and do the function headers

so you could you could do your search

replace thing as i say before

if you

treated this as a big blob of text

did

you just look for a function

well the trick i normally use actually

is is i

the function is going to be hard up

against the the last end of line

character so you have um

character 10 character 13 at the end of

the line so you can use that as a search

um

as part of your search

which means that uh you'll be getting

these there's two invisible characters

at the end of a line

which you can't normally see of course

but if you just search for function in

those characters with a space after it

or a tab

that gets you to here

you search across you look for

a bracket

and that gives you these characters here

and you go well is there any

uh period characters in there or dark

characters and that's how you grab that

that from it

pull it out

reinsert it you know

and just keep searching

but you would use that as the

you know

the return here

so you probably

you wouldn't get you know nice clean

clean result but you you put this on the

end of your end function as

just have preface it with you know as

whatever

whatever the type name is

and

a pointer or something

and that would you know okay

a small

bit of code could do a lot of the brute

force

rubbishy work

up front

for small code biases it's not really

warranted but for big things like this

yeah probably that probably is the way

to go

to do large ports

all right

i think we'll leave this here and we'll

try and tackle some more of this um

tonight because we are actually

probably

you know an hour and 20 minutes where

it's going to be which is too long for

an episode

they take ages to add these things down

but i want this to be

pretty much live

the whole thing

maybe at the end we might shorten up the

episodes a bit and we might do

i might do a session and then show you

the results rather than doing because

we're going to be doing a lot of the

same stuff over and over again from here

on in i would think

i would think

um

i do want to convert

these globals to a type structure and

have them all just at the top of the

program

and

primarily get to work

with explicit mode enabled

which means making sure all the

variables are declared up front so

having those places where there's

variables that are not used and

other places where i think there might

be typos

in the in the code

i'm not sure

you know we all make mistake i mean

everything i've ever written is full of

bugs so

all right thanks for

for watching

thanks for hanging out and um we'll see

you soon after

just check the that one's still working

and well

by working i mean

has it blown up

it's pretty good

so if i

if i use the back button which is the

button next to here

if i

sorry i keep using the wrong button

now i think it's the push to back button

here

once that's been pushed to back

all bets are off with selection so

pretty weird

pretty weird

i might find myself rewriting that

selection code

to something i'm more comfortable either

i'm thinking about having if i can get

the gadgets to work and i should work if

i can get the windows to work

um

i think actually some of that stuff will

be easier than my

what you might be thinking

just once we have our logic in place and

all of the

the data types and so the types match up

should work fine

i didn't say should didn't say it will

should work fine you know anyway

until next time thanks for watching and

i'll see you then bye