BlitzMaxNG
BlitzMax Forums/BlitzMax Programming/BlitzMaxNG
| ||
| I really want to use this for Leadwerks 4. Timeline is Christmas 2016. What remains to be done to get this 100% compatible wit stock BlitzMax? |
| ||
| It's close, but never going to be 100% since NG requires to be in strict mode. It also won't work with 3rd party mods in 64-bit mode that use ints for pointers. |
| ||
| What exactly would be the advantage? 32 bit binaries are more compatible (they run on ALL desktops), smaller and and often faster. |
| ||
| More memory. I am actually getting to the point where I hit the limits of 32-bit apps. It also would make the install process on Linux a lot simpler. |
| ||
| FWIW: 32-bit applications are limited to 2GB RAM. Also, IIRC Brucey updated all the pointers etc. in the file routines as well in NG, so you can natively load&write data and such from files >2GB in length, which can be a big deal. |
| ||
| and and often faster Performance is actually one reason for many people to switch - more important for many developers than memory. Yes your app suffers a bit more cache pressure (although not so much if you still use 32-bit datatypes where possible), but having twice as many (twice as big) registers should make the code absolutely fly if you have a smart compiler (leaf-function support is particularly cool). 64-bit code started out slow because compilers weren't as good at the new code gen, but there's not so much excuse for that now. (32-bit code also still assumes no SSE/AVX by default on most systems, but you can usually turn that on as there's no good reason not to. Note however that the BRL-bcc codegen has no way to do this, whereas in NG it can be implicit; this is a completely separate limitation) |
| ||
Here's a very basic Windows window class for BMX NG. This will not compile in regular BMX.SuperStrict
Framework pub.win32
Import brl.map
Import brl.standardio
Local window:TWindow=TWindow.Create("BlitzMaxNG Window",200,200,1024,768,Null)
Repeat
window.Update()
Forever
'---------------------------------------------------------------------------------------------------
Private
Type TPointerWrapper
Field pointer:Byte Ptr
Method Sort:Int(pointerwrapper:TPointerWrapper)
If pointerwrapper.pointer>Self.pointer Return 1
If pointerwrapper.pointer<Self.pointer Return -1
Return 0
EndMethod
Function Create:TPointerWrapper(pointer:Byte Ptr)
Local pointerwrapper:TPointerWrapper=New TPointerWrapper
pointerwrapper.pointer=pointer
Return pointerwrapper
EndFunction
EndType
Public
Type TWindow
Const classname:String="FRAMEWERK_WINDOW_CLASS"
Global wc:WNDCLASS
Global map:TMap=New TMap
Field hwnd:Byte Ptr
Field style:Int
Method Delete()
If hwnd
map.remove(TPointerWrapper.Create(hwnd))
hwnd=Null
EndIf
EndMethod
Method Update()
Local _msg:MSG=New MSG
While (PeekMessageA(_msg,hwnd,0,0,PM_NOREMOVE))
If (GetMessageA(_msg,hwnd,0,0))
TranslateMessage(_msg );
DispatchMessageA(_msg );
EndIf
Wend
EndMethod
Function Find:TWindow(hwnd:Byte Ptr)
Return TWindow(map.valueforkey(TPointerWrapper.Create(hwnd)))
EndFunction
Function ClassWndProc:Byte Ptr(hwnd:Byte Ptr,msg_:MSG,wparam:Byte Ptr,lparam:Byte Ptr) "win32"
Local window:TWindow=Find(hwnd)
Select msg_
Case WM_CLOSE
Print "WINDOW CLOSED"
End
EndSelect
Return DefWindowProcW(hwnd, msg_, wparam, lparam)
EndFunction
Function Create:TWindow(title:String,x:Int,y:Int,width:Int,height:Int,parent:TWindow=Null,style:Int=0)
If Not wc
'Create shared window class
wc=New WNDCLASS
wc.style=CS_OWNDC|CS_HREDRAW|CS_VREDRAW
wc.lpfnWndProc=ClassWndProc
wc.hInstance=GetModuleHandleW(Null)
wc.hbrBackground=COLOR_BTNSHADOW
wc.hCursor=LoadCursorW( 0,Short Ptr( IDC_ARROW ) )
wc.lpszMenuName=Null
wc.lpszClassName=classname.ToWString()
wc.cbWndExtra=DLGWINDOWEXTRA
RegisterClassW(wc)
EndIf
'Create window
Local wstyle:Int=WS_VISIBLE | WS_CAPTION | WS_SYSMENU | WS_MAXIMIZEBOX | WS_MINIMIZEBOX | WS_THICKFRAME
Local xstyle:Int=WS_EX_DLGMODALFRAME
Local wc:WNDCLASS=New WNDCLASS
Local hwnd:Byte Ptr
Local parenthwnd:Byte Ptr
If parent parenthwnd=parent.hwnd
hwnd=CreateWindowExA(0,classname,title,wstyle,x,y,width,height,Null,Null,Null,Null)
If Not hwnd Return Null
'Create window object
Local window:TWindow=New TWindow
window.hwnd=hwnd
window.style=style
'Insert HWND into map
Local pointerwrapper:TPointerWrapper=TPointerWrapper.Create(hwnd)
map.insert pointerwrapper,window
Return window
EndFunction
EndType |
| ||
| So it is diverged from BlitzMax already then? .. I will look at this project too later :) |
| ||
| BMX has some functions declared as integers that should not be, and it can't convert between the two. Otherwise it would compile in both just fine. |
| ||
| This should be hidden from the "end-user|coder" so this will be handled similar to all other things. For "maxmods" this could be done via "?bmxng"-switch, for "bmx-ng" this is done "for all scenarios". -> once maxgui works, it should be indifferent whether you use vanilla or ng. Except of course if you modify the "maxgui-backend". I did not check MaxGUI, so I do not know wether that "sort"-method is called at all. But I thought the better approach should be to override "compare". bye Ron |
| ||
| I think these changes would be better served by going into the main dist now that it is open sourced. Just my thought. Because once you begin creating threads of releases, it quickly becomes a nightmare. |
| ||
| There is no reason to have ng-specific changes ("?bmxng") done in a vanilla source. Not talking about general fixes, as this is a different subject. bye Ron |
| ||
| I haven't looked at this project, so I don't know how much is changed. Not that it matters. |
| ||
| I'd really want to pay for a WebAsm(HTML5) output for BMaxNG if possible. Currently I'm using Monkey however it seems Brucey has done the BMaxNG the right way. |