14 September 2018, 12:03 | #1 |
Registered User
Join Date: Apr 2018
Location: Wales, UK
Age: 41
Posts: 102
|
Amiga Development using Nim
Hello all,
This is some work to allow Nim nim-lang.org programs being run on the Amiga. This isn't a port of Nim compiler to the Amiga, but more of a port the Amiga libraries and architecture being used in Nim, which then can be used on the Amiga. Nim is one of the newer emerging languages, it can 'transpile' into C really efficiently and well. So I like to think of it as C but with a lot of cool stuff on top. It supports multiple architectures, and claims to support Amiga - although it's a little wrong in some parts, and some code is missing. I've added in the missing bits for it to compile, and have a semi-manual tool chain working. It has garbage collection built in, but I'm using one of the simpler garbage collectors than the standard one. Anyway, once compiled to C, then I use VBCC (on Windows) to turn it into an Amiga executable. For example: Code:
echo "Hello EAB from Nim!" I've started to port some of the Amiga NDK over. Nim comes with a c2nim converter for headers, and for the most part it works really well. I only have exec in, but you can do cool things like this. Code:
import "amiga/exec" Alert(0x12345678) Once I've got more of a complete system, I'll be happy to publish to github. |
14 September 2018, 14:53 | #2 |
Registered User
Join Date: Sep 2007
Location: Stockholm
Posts: 4,332
|
I suddenly became a lot more interested in Nim.
|
14 September 2018, 14:59 | #3 |
Registered User
Join Date: Jul 2014
Location: Finland
Posts: 1,176
|
Oh thats superdupercool.
|
15 September 2018, 13:23 | #4 |
Registered User
Join Date: Apr 2018
Location: Wales, UK
Age: 41
Posts: 102
|
I ported over 'hardware' part of the 3.9 NDK yesterday. It's just one NIM file with a load of constants and struct definitions.
So I had a go at rewriting 'moveline' by Wei-ju Wu, to see if I could play with some hardware stuff. Turns out you can. It's a bit messy with the register part. I need to turn those into Macros, but it works really well. No assembly required! Preview (Click for video!) The Code Code:
import "amiga/exec" import "amiga/hardware" {.emit: "volatile NU8 *ciaa_pra = (volatile NU8 *) 0xbfe001;".} var ciaa_pra {.nodecl, importc.}: ptr UBYTE {.emit: "volatile NU8 *custom_vhposr = (volatile NU8 *) 0xdff006;".} var custom_vhposr {.nodecl, importc.}: ptr UBYTE const PRA_FIR0_BIT : uint8 = 1 shl 6 const COLOR_WHITE : UWORD = (0x0fff) const COLOR_WBENCH_BG : UWORD = (0xAAA) var pos : int = 0xac var incr : int = 1 while( (ciaa_pra[] and PRA_FIR0_BIT ) != 0): # while lmb is not down while( custom_vhposr[] != 0xff ): discard # wait for vblank while( cast[int](custom_vhposr[]) != pos): discard # wait until position reached custom.color[0] = COLOR_WHITE while( cast[int](custom_vhposr[]) == pos): discard # wait while on the target position custom.color[0] = COLOR_WBENCH_BG if (pos >= 0xf0): incr = -incr elif (pos <= 0x40): incr = -incr pos += incr |
15 September 2018, 13:29 | #5 |
Registered User
Join Date: Jul 2014
Location: Finland
Posts: 1,176
|
Do you have a repo somewhere i can clone? I'd like to play with Nim :-)
|
15 September 2018, 13:43 | #6 |
Registered User
Join Date: Apr 2018
Location: Wales, UK
Age: 41
Posts: 102
|
Nothing official yet. But I'll upload what I have here.
Just install nim normally. I actually installed it to C:nim/ You'll need the Windows version of VBCC to compile, otherwise you'll have to transfer the contents of nimcache over to an Amiga (which then needs VBCC to compile). You build via 'build.bat', and then if your using VBCC on windows, there is a build.bat in nimcache as well. It needs a special nimbase.h file, with some changes (just to fool the preprocessor and help VBCC compile it). The Amiga module is a separate folder, and needs to go somewhere else. If you install nim properly, the nimble package manager should be okay with it, but for the nim programs to see it you need to go into the directory, and do; 'nimble develop' which it should see it, as it isn't in the official package manger system. Apart from that, have a look at 'beamline'. It contains the source and what I showed up above. Only exec and hardware are in. It also contains the important build scripts (making sure it uses the regions garbage collector, big endian, etc.) and patches for it to compile (os_alloc, ansi_c and panicoverride in particular). I'm really really new to nim and to C programming on the Amiga (although I'm pretty good at Blitz/AMOS now). So some questions, I probably won't be able to answer. I'll put up an official repo soon though. Have fun! |
08 November 2018, 03:50 | #7 |
The Grim-Button
Join Date: Jan 2008
Location: Melbourne Australia
Age: 43
Posts: 414
|
Did you ever get further with this?
Seems like a cool little scripting language. |
20 November 2018, 14:49 | #8 |
Registered User
Join Date: Nov 2018
Location: Oldenburg (Germany)
Posts: 2
|
This is really very cool!
I've found a package of "nim bindings to OS 3 API" on GitHub: https://github.com/Nadrin/nim-amigaos But I don't know if there is any connection to betajaen and I haven't tried it yet. |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Amiga Development on AmigaOS 3.1... | Panthros | Amiga scene | 3 | 08 January 2017 21:52 |
Amiga development | freehand | Retrogaming General Discussion | 4 | 18 April 2010 17:53 |
Amiga software development | tootoid | Amiga scene | 22 | 21 March 2007 18:12 |
Next-gen Amiga development | LaundroMat | Coders. General | 3 | 05 October 2002 00:30 |
Amiga - future development? | LUKas007 | Amiga scene | 244 | 21 September 2002 12:55 |
|
|