Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AmigaOS4 support #10

Open
raziel- opened this issue Jun 14, 2020 · 13 comments
Open

AmigaOS4 support #10

raziel- opened this issue Jun 14, 2020 · 13 comments

Comments

@raziel-
Copy link

raziel- commented Jun 14, 2020

Hi Eric,

not sure if you want to, since it probably means some sort of adaptation/rewriting, but...

I tried to port your engine to AmigaOS4, but ran into some problems.

First there were compilation issues (since cmake doesn´t work on my platform, so i had to write my own makefile (attached). Luckily your cmake file is very clean and easy to adapt):

src/player.h:5:14: error: 'sint16' does not name a type; did you mean 'int'?
extern const sint16 player_x_offset_tbl[];
^~~~~~
int
src/player.h:6:14: error: 'sint16' does not name a type; did you mean 'int'?
extern const sint16 player_y_offset_tbl[];
^~~~~~
int
src/player.h:29:8: error: 'uint8' does not name a type; did you mean 'int'?
extern uint8 health;
^~~~~
int
src/player.h:30:8: error: 'uint8' does not name a type; did you mean 'int'?
extern uint8 num_health_bars;
^~~~~
int
src/player.h:32:8: error: 'uint16' does not name a type; did you mean 'int'?
extern uint16 num_bombs;
^~~~~~
int
src/player.h:33:8: error: 'uint16' does not name a type; did you mean 'int'?
extern uint16 has_had_bomb_flag;
^~~~~~
int
src/player.h:39:8: error: 'uint8' does not name a type; did you mean 'int'?
extern uint8 player_in_pneumatic_tube_flag;
^~~~~
int
src/player.h:46:8: error: 'uint8' does not name a type; did you mean 'int'?
extern uint8 show_monster_attack_hint;
^~~~~
int
src/player.h:48:8: error: 'uint8' does not name a type; did you mean 'int'?
extern uint8 word_28BEA;
^~~~~
int
src/player.h:73:28: error: variable or field 'display_player_sprite' declared void
void display_player_sprite(uint8 frame_num, int x_pos, int y_pos, int tile_display_func_index);
^~~~~
src/player.h:73:28: error: 'uint8' was not declared in this scope
src/player.h:73:28: note: suggested alternative: 'int'
void display_player_sprite(uint8 frame_num, int x_pos, int y_pos, int tile_display_func_index);
^~~~~
int
src/player.h:73:45: error: expected primary-expression before 'int'
void display_player_sprite(uint8 frame_num, int x_pos, int y_pos, int tile_display_func_index);
^~~
src/player.h:73:56: error: expected primary-expression before 'int'
void display_player_sprite(uint8 frame_num, int x_pos, int y_pos, int tile_display_func_index);
^~~
src/player.h:73:67: error: expected primary-expression before 'int'
void display_player_sprite(uint8 frame_num, int x_pos, int y_pos, int tile_display_func_index);
^~~
src/player.h:84:26: error: variable or field 'player_add_to_score' declared void
void player_add_to_score(uint32 amount_to_add_low);
^~~~~~
src/player.h:84:26: error: 'uint32' was not declared in this scope
src/player.h:84:26: note: suggested alternative: 'int'
void player_add_to_score(uint32 amount_to_add_low);
^~~~~~
int
src/player.h:88:110: error: 'uint8' has not been declared
void push_player_around(int push_direction, int push_anim_duration, int push_duration, int player_frame_num, uint8 dont_push_while_jumping_flag, int check_for_blocking_flag);

Those errors were was easily fixed by adding
#ifdef amigaos4
#include "files/defines.h"
#endif
to src/player.h, line 5

After the binary built i got more errors on start of the engine.
I cannot fix them by myself, too much of a noob i´m afraid, but i´d love to test anything you throw at me :-)

Here are the errors on start:

audio_init(): opened=1 times frequency=22050Hz format=S16MSB channel=1
ERROR: AUDIO_S16LSB or AUDIO_F32LSB required. found 0x9010
Failed opening: PROGDIR:/COSMO1.VOL
Error opening COSMO1.VOL
assertion "open_vol_file(vol_filename, &vol_file)" failed: file "src/files/vol.c", line 111
***Command 'cosmo_amigaos4' returned with unfreed signals 80000000!

I have to add that i´m using SDL2 on a Big Endian PPC-based machine

Makefile.amigaos4.txt

@yuv422
Copy link
Owner

yuv422 commented Jun 15, 2020

Hi @raziel-
Interesting. Ok so I think you have two issues here. First the audio isn't working. That's because we only support little endian for audio at the moment. The game should still be able to run. Just without audio.

The second issue seems to be related to opening the game data files.
Do you have a copy of COSMO1.VOL in the working directory while executing cosmo-engine?

It looks like PROGDIR: refers to the current directory. Also you might want to check the case of the data file names. Maybe the Amiga filesystem is case-sensitive?

@raziel-
Copy link
Author

raziel- commented Jun 15, 2020

Ah, ok.
I thought it might be because of endian issues.

PROGDIR: is used as default on this platform and points to the directory the program was started.
The problem seems to be the trailing slash, though.
After that it seems to try to load only the filename which fails because there is no path to it, or so I think.
I guess if I can get rid of the trailing slash it should work?

And yes, COSMO1.VOL is in the same dir as the engine binary.

AmigaOS is not case sensitive, it uses everything that is thrown at it, may it be upper or lower case.

I can't test anything in code for the next two weeks due to being tangled up in work, but I'll try when I get back home.

Thanks for helping out

@yuv422
Copy link
Owner

yuv422 commented Jun 15, 2020

Cool,
The logic that handles the slash is in this function

char *get_full_path(const char *base_dir, const char *filename)
{
    char *path = (char *)malloc(strlen(base_dir) + strlen(filename) + 2); //2 = path delimiter + \0
    sprintf(path, "%s%c%s", base_dir, '/', filename); //FIXME handle windows path separator
    return path;
}

It's in config.c

@raziel-
Copy link
Author

raziel- commented Jun 15, 2020

Ah, right.
I already looked at the code briefly but couldn't find it.

I'll try to remove it and see what happens next.

Thank you

@raziel-
Copy link
Author

raziel- commented Jun 27, 2020

So, i tried to change it to
char *get_full_path(const char *base_dir, const char *filename)
{
#ifdef amigaos4
char *path = (char *)malloc(strlen(base_dir) + strlen(filename)); //2 = path delimiter + \0
sprintf(path, "%s%c%s", base_dir, filename); //FIXME handle windows path separator
#else
char *path = (char *)malloc(strlen(base_dir) + strlen(filename) + 2); //2 = path delimiter + \0
sprintf(path, "%s%c%s", base_dir, '/', filename); //FIXME handle windows path separator
#endif
return path;
}
but all i got afterwards was
Failed opening 'PROGDIR:ì'
Error: Opening COSMO1.VOL
At least it prints something different this time, not sure if it caught the correct filemname.

I need to add that i'm a noob when it comes to coding.
I'll probably need more than just a little help to make this work...sorry

@yuv422
Copy link
Owner

yuv422 commented Jun 29, 2020

I think it needs to look more like this.

#ifdef amigaos4
char *path = (char *)malloc(strlen(base_dir) + strlen(filename) + 1); //1 =  \0
sprintf(path, "%s%s", base_dir, filename);
#else
...

@raziel-
Copy link
Author

raziel- commented Jun 29, 2020

That did it, thanks a lot :-)

Game runs fine (window)

Are you planning fullscreen support and BE sound/music?
I'll stand by for testing ;-)

@BeWorld2018
Copy link

Hi Raziel and yuv422

I try to built it to MorphOS and i just add to activate sound/music :

case AUDIO_S16MSB: 
format_str="S16MSB"; 
audioConfig.format = AUDIO_FLOAT32_SIGNED_LSB;
audioConfig.bytesPerSample = 4;
break;

And music and sound working fine on MorphOS, I think it's same on AmigaOS.

@raziel-
Copy link
Author

raziel- commented Jun 29, 2020

@BeWorld2018

I get a crash on starting the adventure with this change...
Crash log for task "cosmo_amigaos4"
Generated by GrimReaper 53.19
Crash occured in module cosmo_amigaos4 at address 0x7C5B6E20
Type of crash: DSI (Data Storage Interrupt) exception
Alert number: 0x80000003

Register dump:
GPR (General Purpose Registers):
0: 7C5B8888 3AB1FC50 00000006 00000000 00000038 39AA52E0 295D4000 000D1F8F
8: 00000001 00000000 00000008 000D35D7 000F4240 39A8DEB8 00000000 4DC5F680
16: 7C4D8CB0 00000000 4CF5D280 39A6E098 02B30000 02B30000 00000000 00000001
24: 6FF8C180 00000001 00003E68 3325FFB8 00000038 00000000 00000000 FFFFFFFF

FPR (Floating Point Registers, NaN = Not a Number):
0: nan -5.31401e+303 2.90111e+257 nan
4: -5.31401e+303 -5.31401e+303 400 200
8: 0 640 320 4.5036e+15
12: 4.5036e+15 2.14748e+09 0 0
16: 0 0 0 0
20: 0 0 0 0
24: 0 0 0 0
28: 0 0 0 0

FPSCR (Floating Point Status and Control Register): 0x82004000

SPRs (Special Purpose Registers):
Machine State (msr) : 0x0200B030
Condition (cr) : 0x4870E064
Instruction Pointer (ip) : 0x7C5B6E20
Xtended Exception (xer) : 0x34979018
Count (ctr) : 0x6FF494D0
Link (lr) : 0x7FAE9920
DSI Status (dsisr) : 0x34978DD0
Data Address (dar) : 0x021AD048

680x0 emulated registers:
DATA: 98F7A000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
ADDR: 6FFB8700 98B43100 00000000 00000000 00000000 00000000 00000000 3AB1F730
FPU0: 0 0 0 0
FPU4: 0 0 0 0

Symbol info:
Instruction pointer 0x7C5B6E20 belongs to module "cosmo_amigaos4" (PowerPC)
Symbol: _Mix_remove_all_effects + 0x24 in section 1 offset 0x000E6DFC

Stack trace:
cosmo_amigaos4:_Mix_remove_all_effects()+0x24 (section 1 @ 0xE6DFC)
cosmo_amigaos4:Mix_PlayChannelTimed()+0x1c4 (section 1 @ 0xE8864)
cosmo_amigaos4:_Z8play_sfxi()+0xd0 (section 1 @ 0x2C4FC)
cosmo_amigaos4:_Z9main_menuv()+0x238 (section 1 @ 0x12FC0)
cosmo_amigaos4:main()+0x84 (section 1 @ 0x8D10)
native kernel module newlib.library.kmod+0x000020a4
native kernel module newlib.library.kmod+0x00002d0c
native kernel module newlib.library.kmod+0x00002ee8
cosmo_amigaos4:_start()+0x170 (section 1 @ 0x1AB8)
native kernel module dos.library.kmod+0x000255c8
native kernel module kernel+0x000420ac
native kernel module kernel+0x000420f4

PPC disassembly:
7c5b6e18: 93e1001c stw r31,28(r1)
7c5b6e1c: 41820074 beq- 0x7C5B6E90
*7c5b6e20: 83dc0000 lwz r30,0(r28)
7c5b6e24: 7c7d1b78 mr r29,r3
7c5b6e28: 2f9e0000 cmpwi cr7,r30,0

@BeWorld2018
Copy link

arrfff no chance.... work fine here :-(
and i can't help you, i dont have any AmigaOS4 and dont know how work debug trace.

Missing somes features : joystick support, switch fullscreen/window, window resizable.
But this game is fun ;-) good job yuv422 for this port.

I pre-release version for MorphOS (with shareware version)

@raziel-
Copy link
Author

raziel- commented Jun 29, 2020

@BeWorld2018

Thank you for the help, will bother some AmigaOS4 devs :-D

@BeWorld2018
Copy link

You can find my source : https://github.com/BeWorld2018/cosmo-engine

I add somes features... (window resizable, F12 switch fwindow/fullscreen, very alpha support of SDL_GameController)

@javierdlr
Copy link

Hi, using BeWorld github-sources and some small changes I can compile it under amigaos4.

THXALOT BeWorld

https://www.amigans.net/modules/xforum/viewtopic.php?post_id=119743#forumpost119743

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants