Оберон-клуб «ВЄДАsoft» https://zx.oberon.org/forum/ |
|
[Solved] Proper initialization of Oberon modules https://zx.oberon.org/forum/viewtopic.php?f=10&t=135 |
Страница 1 из 3 |
Автор: | slenkar [ 08 авг 2013, 06:30 ] |
Заголовок сообщения: | Re: Roguelike with strategy |
When the game loads it doesnt start The code is 17KB it starts at 25000 the data is at 51000 in hi.list it says: 000061A8 _main hi 000061A8 _main_start hi so it should start, as 61A8 is 25000 DATA is 7kb HOME is 4kb I think its because I have 2 modules that import each other I think they keep caling each others init function |
Автор: | Zorko [ 08 авг 2013, 11:28 ] |
Заголовок сообщения: | Re: Roguelike with strategy |
slenkar писал(а): I think they keep caling each others init function It is a probable problem.Код: "OBERON"
Код: "C" export void *GrConsole__init(void) Код: "C" # define __DEFMOD static char m; if(m!=0)return I recommend that you update SYSTEM.h where I've fixed this bug (but now SYSTEM.h is adapted for modified Ofront, therefore maybe just update the macros __DEFMOD). |
Автор: | slenkar [ 08 авг 2013, 19:16 ] |
Заголовок сообщения: | Re: Roguelike with strategy |
I put the new system.h and system_cfg.h in there and now get this error: 'auto' variable 'Basic' may be used before initialization on this line: __IMPORT(Basic); and when linking: ?ASlink-Warning-Undefined Global '_Basic' referenced by module 'hi' for all modules These errors are only in the main file which is hi.c |
Автор: | Zorko [ 08 авг 2013, 21:44 ] |
Заголовок сообщения: | Re: Roguelike with strategy |
You must know that I've modified Ofront to generate __IMPORT(Basic__init) instead of __IMPORT(Basic). It's done for supporting C compilers that do not accept identifiers concatenation ## (like Turbo C). And I think your Linux version of Ofront isn't compatible with the modified SYSTEM.h I regret that hasty advise you to update SYSTEM.h Probably will be a good idea to roll back to the old macros. Was (new variant for modified Ofront): Код: "C" #define __IMPORT(name__init) SYSTEM_INCREF(name__init()) Код: "C" #define __IMPORT(name) SYSTEM_INCREF(name##__init()) |
Автор: | slenkar [ 09 авг 2013, 03:41 ] |
Заголовок сообщения: | Re: Roguelike with strategy |
ok thanks, can ofront be compiled for linux? (if it is a command line utility it shouldnt need many changes) (Its still doing the same problem where it calls the init functions forever) I looked in GitHub at ofront but I didnt see any C++ code to compile |
Автор: | Zorko [ 09 авг 2013, 11:33 ] |
Заголовок сообщения: | Re: Roguelike with strategy |
slenkar писал(а): can ofront be compiled for linux? (if it is a command line utility it shouldnt need many changes) Hmm... maybe first I understand your "forever init" not so correctly. The idea was that each module can be initialized more than once due to the fact that modules that import the module would call its initializer several times. And the initializer must check is it called first time, or not, and return if it was already called.(Its still doing the same problem where it calls the init functions forever) Try to understand where is looped code, by printing control characters to screen. Try to emulate native module initializers by just Init procedures that may be called manually from main module only. In general, I guess that's not a problem of Ofront, SYSTEM.h or SDCC, and a problem of your code. slenkar писал(а): I looked in GitHub at ofront but I didnt see any C++ code to compile All right. Ofront is written in Oberon and need to be translated to C by itself.I have not tried to build Linux version of Ofront (and haven't experience with it), but I have a desire to make the console version for Linux and Windows, maybe I'll try to do it soon. |
Автор: | slenkar [ 09 авг 2013, 16:46 ] |
Заголовок сообщения: | Re: Roguelike with strategy |
what do you use to compile ofront for windows? I have the oxford oberon compiler, would that work? I noticed that REGCMD is only used for some procedures but not others would this cause a problem? here is what my System_cfg.h looks like Код: "C" /* Ofront 1.2 SYSTEM config */ is it ok? |
Автор: | Zorko [ 09 авг 2013, 18:23 ] |
Заголовок сообщения: | Re: Roguelike with strategy |
slenkar писал(а): what do you use to compile ofront for windows? Ofront for Windows is implemented as a subsystem of BlackBox Component Builder, and I use BlackBox as compiler and as IDE. I.e. Open -> Ofront -> Mod -> *.odc -> Dev -> Compile.slenkar писал(а): I have the oxford oberon compiler, would that work? I don't know. But I think would be better to use Ofront and GCC for this work.slenkar писал(а): I noticed that REGCMD is only used for some procedures but not others would this cause a problem? The macros REGCMD needed for Oberon system to register procedures without parameters as Oberon commands. I didn't use this feature, it's not needed for static compiled stand-alone code.slenkar писал(а): here is what my System_cfg.h looks like - is it ok? Yes.
|
Автор: | slenkar [ 09 авг 2013, 21:44 ] |
Заголовок сообщения: | Re: Roguelike with strategy |
the problem is definitely in the init function I printed the name of the module to the screen when it is done with its init function, only 2 of them appeared, them the spectrum resets there is nothing strange or new going on in the init functions All I did was add a new module then these strange things started happening this seems to be the only module that imports a module that imports it |
Автор: | Zorko [ 10 авг 2013, 00:33 ] | ||
Заголовок сообщения: | Re: Roguelike with strategy | ||
How do I solve similar problems? First need to look aren't there serious warnings after compiling by SDCC. Second I run EmuZWin - it has step-by-step debugger. I press F7/F8 to do a step and look at the asm code - where is breaking of a program logic? Also there is possibility to change any registers and look at memory. SDCC-generated *.asm sources can help you to establish a correspondence between C and asm source.
|
Страница 1 из 3 | Часовой пояс: UTC + 2 часа |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |