Sokol Wonkey tests

Started by iWasAdam, October 25, 2021, 08:20:38

Previous topic - Next topic

iWasAdam

OK. for anyone interested in something more low level. Sokol is an interface library built for minimal low level access to hardware - graphics, sound, timers, etc. It is built primarily for writing emulators for 8 and 16 bit systems.

Here are the current online samples
https://floooh.github.io/sokol-html5/index.html

and also some of the emulators built with it
https://floooh.github.io/tiny8bit/

Wonkey has the base sokol interface along with some of the basic tests. they are a bit strange as you are ditching virtually all the modules which makes wonkey (mojo being the main one) and using Sokol instead. So all of the class systems for windows events etc are gone.

But I have started a tiny project to put back the general use from mojo into a wrapper that has handling for windows, events, color, etc. The good news is it is bearing some fruit with graphics and windows. There is no 2d component, just the bare 3d hardware, but what is really interesting is support for both windows gl and macos metal!!!!!!

Here's a shot of the basic rotating cube:


file sizes are tiny 500k. I've been tinkering and found out how to add images and also how to reference them via spritefonts. So this means basic 2d sprites with color can be done. E.G. This is me writing pitfall from scratch - adding needed method to the core and debugging as I go
First the code just using the main onrender method showing it's power:

method OnRender() Override
OnUpdate60()

' BGColor( 0.2,0.2,0.2, 1 )
BGColor( Color.PicoBlack, 1 )

' Print Height
sprites.Begin( state, 160,192 )'Width, Height )


sprites.Draw( 0,  0,0, 160, 48,  Color.UILeaf )
sprites.Draw( 0,  0,48, 160, 64,  Color.UILime * 0.8 )
sprites.Draw( 0,  0,112, 160, 16,  Color.UIYellow )
sprites.Draw( 0,  0,128, 160, 16,  Color.VicKhaki )
sprites.Draw( 0,  0,176, 160, 6,  Color.VicKhaki )

sprites.Draw( 38,  32,48, 8, 8,  Color.XamBrown )
sprites.Draw( 0,  34,56, 4, 56,  Color.XamBrown )

sprites.DrawWH( 36,  2,1,  0,48, 80, 16,  Color.UILeaf )
sprites.DrawWH( 36,  2,1,  80,48, 80, 16,  Color.UILeaf )

sprites.DrawWH( 96,  2,2,  38,111, 84, 18,  Color.UICyan )

and now and image:


Sokol does have sound via miniaudio - but I have noticed pops and clicks, so may do something else via a different threaded system.


Baggey

#1
Interesting. The code on Sokol is C-type but your example is Blitzmax like.

Im up for BETA testing! Especially if i can write Emulators with it  8).  Maybe i could Re-Write SpecBlitz for "WONKEY"  :P

Kind Regards Baggey
Running a PC that just Aint fast enough!? i7 Quad core 16GB ram 1TB SSD and NVIDIA Quadro K620 . DID Technology stop! Or have we been assimulated!

ZX Spectrum 48k, C64, ORIC Atmos 48K, Enterprise 128K, The SID chip. Im Misunderstood!

iWasAdam

#2
No problem. I can guide you through everything and dev along with you to fill in the gaps as and where you need them. you'll have the core wonkey language stuff and the wrapper with provide you with a framework that you'll be more at home with.

First you'll need to get wonkey set up. Pop along here, download and get it working...
https://github.com/wonkey-coders

the install and instructions are found here - scroll down and read the install instructions first - it's a bit like blitzmaxNG to begin with (find work out how to install, etc):
https://github.com/wonkey-coders/wonkey

Once you've got the core installed we'll take it from there \o/

Baggey

Quote from: iWasAdam on October 26, 2021, 07:40:39
Once you've got the core installed we'll take it from there \o/

An install .ExE would be good so i can just run it.  :-[ :-X :-\ :'( :o

Kind Regards BAGGEY
Running a PC that just Aint fast enough!? i7 Quad core 16GB ram 1TB SSD and NVIDIA Quadro K620 . DID Technology stop! Or have we been assimulated!

ZX Spectrum 48k, C64, ORIC Atmos 48K, Enterprise 128K, The SID chip. Im Misunderstood!

iWasAdam

just follow the instructions it's reasonably simple

Baggey

Quote from: iWasAdam on October 30, 2021, 08:04:57
just follow the instructions it's reasonably simple

So brushed up on DOS commands and have got this far!  :-X

Running a PC that just Aint fast enough!? i7 Quad core 16GB ram 1TB SSD and NVIDIA Quadro K620 . DID Technology stop! Or have we been assimulated!

ZX Spectrum 48k, C64, ORIC Atmos 48K, Enterprise 128K, The SID chip. Im Misunderstood!

iWasAdam

I'll get this forwarded to the compile devs  ;D

Baggey

Quote from: iWasAdam on October 30, 2021, 13:59:21
I'll get this forwarded to the compile devs  ;D

Waiting!  ;D

Kind Regards Baggey
Running a PC that just Aint fast enough!? i7 Quad core 16GB ram 1TB SSD and NVIDIA Quadro K620 . DID Technology stop! Or have we been assimulated!

ZX Spectrum 48k, C64, ORIC Atmos 48K, Enterprise 128K, The SID chip. Im Misunderstood!

iWasAdam

reply:
Looks like the Microsoft command-line compiler is not found correctly or is not in PATH
I would try to edit wonkey/bin/windows/env_windows.txt and set the correct MSVC (Microsoft VisualC++) path, instead of using auto-detection
@Baggey: Can you follow this or do something similar if you already installed Microsoft VC++? => https://discord.com/channels/796336780302876683/796360815061762088/798538051239411762
Verify the paths on your system are correct and exist
abakobo — Yesterday at 08:34
Yes the linker is not in PATH

iWasAdam

Now trying something different - writing Demon Attack from scratch

so far so good - offscreen bitmap rendering sorted plus new sprite animation system \o/

iWasAdam

a big boss approaches... all in 548k  :o

iWasAdam

now for something completely different  ;D

It's not much to look at. but it is interesting for the following reasons:
1. lines are drawn by recreating them as quads with correct width - so they can be different widths with no hit
2. they are actually being drawn through an offscreen bitmap
3. they rely on a bitmap for their texture
4. they can be different colors, but just not done here
5. this is the same principal that all the blitz/monkey products use
psst very low res being used 160x192

iWasAdam

#12
lines - sorted
triangles - sorted
spritefonts - sorted
now rotating sizable quads to offscreen buffer.  and still only 511k 8)
maybe I'll look at blend modes next...


After loads of wrangling out and simplifying. Here's the code that produces the above (all of the nasty back end sorted and hidden)

namespace sokol.samples

#Import "sokol-core"

#Import "assets/demon8x8_font.png"


function Main()
local myApp:MySokolApp = New MySokolApp( 800,600, "Offscreen" )
End function


class MySokolApp Extends SokolCore
field sprites:Sprites = New Sprites()

field angle:float = 0


method New( width:int, height:int, title:string )
StartWindow( width, height, title )
End method


method OnInit() Override
sprites.Load( "asset::demon8x8_font.png" )
' sprites.BGColor( Color.Pine, 0 )
sprites.Resolution( 256, 192 )
sprites.Filter( True )

sprites.Init( Width, Height )
End Method


method OnRender() Override
sprites.BeginOffScreen( 256, 192 )

'bg fire line
sprites.Draw( 0,  0,100, 256,48,  Color.PicoBlue * 0.4 )

If _gameFrame Mod 60 < 30 Then
sprites.Quad( 65,  50,50,  angle,60 )
Else
sprites.Quad( 65,  50,50,  angle,70, Color.Blue )
End If
sprites.Quad( 91,  150,100-Abs(Sin(angle)*50),  angle+1,30 )
sprites.Quad( 94,  50,150,  -angle,40+Sin(angle)*30 )
sprites.Quad( 68,  150,150,  angle*2,50 )
angle += 0.02

sprites.FlushOffScreen()

sprites.FlushQuad( 0,0, 400,192 )
End method

End Class


iWasAdam

#13
using the new line command I recreated the vine instead of faking it with a bitmap :)


plus new demon attack look:

Baggey

Quote from: iWasAdam on November 12, 2021, 12:12:26
using the new line command I recreated the vine instead of faking it with a bitmap :)


plus new demon attack look:


Love the Demon Attack / PHEONIX LOOK!

Baggey
Running a PC that just Aint fast enough!? i7 Quad core 16GB ram 1TB SSD and NVIDIA Quadro K620 . DID Technology stop! Or have we been assimulated!

ZX Spectrum 48k, C64, ORIC Atmos 48K, Enterprise 128K, The SID chip. Im Misunderstood!