12 June 2021, 12:14 | #1 |
Registered User
Join Date: May 2019
Location: Germany
Posts: 8
|
New on developing for the Amiga, too
cheers to dlsa, similar story slightly different goal.
My side quest ist to re-unite with the old coding skills that I once had and be able to compile old and new sourcecode (C asm maybe C++) I was thinking that it could be fun to start by tinkering around and have toolchain and code that would compile/run:
Maybe I start with "sytem-conform" Intuition Programms that have a screen / Window with some basic menu and there start some simple examples and demos and land safely back to the Workbench when quit. For a start: I find it difficult to try to have a linux Makefile for vbcc, and keep that in sync with the .uaem / icon / SMakefile for SAS C inside AmigaOS. I am feeling like reinventing everything from scratch - a very inefficient brute force manner like "inject_to_emulation" or "extract_sources_form_emulation" makefile targets that copy stuff from/to shared folders of the project. I really would be able to have ONE sourcecode basis that would build inside and outside emulation. But even any inlining / linking of some assembly code for the demos seem very non-compatible over the different tools. Since I am starting, feeling very clumsy, I hope for some simple 1st step hints so I can skill me up on the road. I feel like in need of best practices or howtos. Help! (Alone the old C-Style "all declararions first" vs modern C-Style, not even entered any C++ and assembly thoughts). |
12 June 2021, 13:44 | #2 | |||
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
|
Quote:
I'm not sure if smakefiles are compatible enough to standard makefiles, but you can probably also call SAS/C from a standard makefile. Then do a small main-makefile, which defines CC, COPTS, AS, LD, etc. for your development environment and use these variables in a common sub-makefile (which can be included). Although your makefiles shouldn't be very large, when using patterns like %.o: %.c, so you could also do it without. Quote:
Assembler inlines and register arguments are different though. I would recommend to have a look at http://aminet.net/dev/c/SDI_headers.lha which defines macros for compiler-independent register arguments, varargs, hooks, etc. For calling OS-functions always include <proto/xyz.h>, which makes sure you are using the best compiler-specific pragmas or inlines. Quote:
|
|||
12 June 2021, 14:18 | #3 |
Registered User
Join Date: May 2019
Location: Germany
Posts: 8
|
Compatible C best practices...
This is from my project header file:
Code:
/* Kickstart 1.2 */ #define EXEC_LIBRARY_MIN_VERSION (33L) #define GFX__LIBRARY_MIN_VERSION (33L) #define INTUITION_LIBRARY_MIN_VERSION (33L) /* Idea is to have ONE global thing to hold all Data - is this stupid? And: is xxx_ptr naming convention also dumb? */ typedef struct _demo_data { struct GfxBase *gfx_ptr; struct IntuitionBase *intuition_ptr; struct RastPort *rast_port_ptr; struct NewScreen *new_screen_ptr; struct Screen *screen_ptr; } demo_data_t; /* I think about holding this (singleton) data inside a function, accessible with get-function instead of global static extern... also stupid with Amiga SAS C compiller? */ demo_data_t *get_data(); demo_data_t *init_all(demo_data_t *data); void close_all(demo_data_t* data); Code:
/* Amiga system libs and headers from NDK3.9 So I shall prefer to use proto/xyz than exec/xyz ? So this is OK? */ #include <exec/types.h> #include <proto/exec.h> // OpenLibrary CloseLibrary #include <intuition/screens.h> // NewScreen Screen /* Project stuff */ #include "constants.h" static demo_data_t data; data.gfx_ptr = (struct GfxBase *) OpenLibrary("graphics.library", GFX__LIBRARY_MIN_VERSION); if (data.gfx_ptr == 0) { close_all(&data); return NULL; } /* this does *not* compile with vbcc on my linux: - WHY NOT? if (data.gfx_ptr = (struct GfxBase *) OpenLibrary("graphics.library",0) == 0) { close_all(&data); return NULL; } */ Please comment and help improve me...! |
12 June 2021, 19:30 | #4 | |||||
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
|
Quote:
Quote:
Quote:
Quote:
You will still need exec/xyz for specific Exec structures and definitions. Quote:
invalid types for assignment. The ==is handled before the assignment, so you will assign the boolean (int type) 0 or 1 to your gfx_ptr pointer. vbcc always warns when assigning integers to pointers and vice versa, which points you to a bug here. You need parentheses around the assignment to make it work as intended: Code:
if ((data.gfx_ptr = (struct GfxBase *) OpenLibrary("graphics.library",0)) == 0) |
|||||
23 June 2021, 15:27 | #5 |
Registered User
Join Date: May 2019
Location: Germany
Posts: 8
|
Best practices for simple logging in C
That was helpful! Thx! I now know, that the library structure pointers HAVE to be global (GfxBase, IntuitionBase etc...) so the calls actually can work. I would prefer to not use auto.linb and do init and cleanup stuff myself.
Here is a question to logging in C: (using vbcc + amiga KS1.3 target, SASC compatibility as final goal) I am still into the dumb style of tracing my guru meditaions down like: Code:
#define LOG_STRING(text) ( printf("file=%s:line=%u:%s\n",__FILE__, __LINE__, (text)) ) LOG_STRING("init_all() has nonnull data pointer"); printf("data=%lx", data"(unsigend long) data); Are there best practices for logging in C inside amiga? I remember that I was once able to print all this and more stuff neatly using some simple self written logger functions¯os but I don't remember... and I am sure there are best practices for this ...? only found http://eab.abime.net/showthread.php?t=80894 and http://eab.abime.net/showthread.php?t=82362 so faar (and the complexity is for ... later endeavors) Last edited by tverrbjelke; 23 June 2021 at 15:51. Reason: proper example of my LOG_TXT makro |
23 June 2021, 19:29 | #6 |
Amigan
Join Date: Feb 2012
Location: London
Posts: 1,309
|
kprintf() will log output to the serial port. You can use a tool like Sashimi to display this in a window (no good if you visit the Guru!).
kprintf is in debug.lib. Edit: I see your link already points to kprintf(). From C it's as easy as calling kprint("hello") and linking with debug.lib. Last edited by nogginthenog; 23 June 2021 at 19:30. Reason: Clarification |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
New on developing for the Amiga | dlsa | Coders. C/C++ | 23 | 17 April 2021 20:51 |
Double barrel Amiga Future article series: Demoscene + Developing Demo Effects | Photon | News | 3 | 29 December 2015 23:04 |
Dave Haynie Talks About Developing The Commodore Amiga | pandy71 | Nostalgia & memories | 2 | 23 April 2014 20:38 |
First doubts for game developing | nandius_c | Coders. Asm / Hardware | 21 | 25 October 2013 12:21 |
Who are developing games for Amiga platform at the moment? | oldpx | Amiga scene | 65 | 06 October 2002 17:41 |
|
|