![]() |
![]() |
#1 |
Registered User
Join Date: Mar 2020
Location: Hamburg
Posts: 20
|
Hacking the SDL API
OK, so hear me out... All SDL implementations on Amiga seem to be done to be able to port games TO Amiga, from another platform. What about making an SDL implementation for porting FROM Amiga? This way, the SDL API could be hacked to really take advantage of the Amiga hardware, like sprites and playfields. The point of doing this would be to make a new Amiga game compile on other platforms, like Linux and PC, and could increase the business incentive. Thoughts?
|
![]() |
![]() |
#2 |
Registered User
Join Date: Mar 2020
Location: Hamburg
Posts: 20
|
Wrong subforum. Can mods move it to general coding, please?
|
![]() |
![]() |
#3 |
This cat is no more
Join Date: Dec 2004
Location: FRANCE
Age: 52
Posts: 8,381
|
check my bagman remake: https://github.com/jotd666/bagman. It is C++ but SDL level is C.
For graphics, it respects SDL interface 99% of the time but bitmaps are loaded using a native planar format, and SDL blit function uses the blitter. No c2p shit and all. This allows the game to run 50 fps on a 68060 and 25fps on 68030/68020. The trick is to pre-process images (png) using python to create a custom RAW format with bitplanes (and header to provide dimensions, etc...). Now SDL implementation is able to load this format and create the bitplanes internally in memory in SDL _Image structure. I'm in the process of supporting sprites too (not only BOBs) but I lost interest in the way. I'll probably start again, though. But it started from a Windows/Linux SDL compliant project. Now 95% of the code is the same. Only on amiga, the pseudo-implementation of SDL is embedded, and images & sounds asset files are different (raw vs png/wav in real SDL) Last edited by jotd; 05 April 2020 at 18:16. |
![]() |
![]() |
#4 |
Total Chaos forever!
Join Date: Aug 2007
Location: Waterville, MN, USA
Age: 49
Posts: 2,200
|
With regards to porting from Amiga, I think a little thicker emulation layer than SDL would be preferable. For example, the copper horizontal sprite muxing would be accomplished using a textured quad with texture wrapping would accomplish the same thing on a conventional graphics core.
The point I'm making is that Amiga does things differently to accomplish the graphical effects than what a PC style graphics core does. We need a higher level wrapper for the Amiga effects to accomplish what you are suggesting. |
![]() |
![]() |
#5 |
Banned
Join Date: Aug 2005
Location: London / Sydney
Age: 47
Posts: 20,420
|
|
![]() |
![]() |
#6 |
This cat is no more
Join Date: Dec 2004
Location: FRANCE
Age: 52
Posts: 8,381
|
one thing is sure: I'll design my new SDL based game with Amiga in mind.
|
![]() |
![]() |
#7 | |
Registered User
Join Date: Mar 2020
Location: Hamburg
Posts: 20
|
Quote:
Nice, I will! Sprites I'm a big believer in. What do you think about wrapping e.g. SDL_BlitSurface around a C macro and add an extra argument for sprite channel? Then if __AMIGA__ is def, the sprite channel will be used, and if not, that argument will be ignored. Next level after that: Sprite reuse. |
|
![]() |
![]() |
#8 | |
Registered User
Join Date: Mar 2020
Location: Hamburg
Posts: 20
|
Quote:
Not sure I agree. Most clever things you do on Amiga can be done with brute-force on literary all other platforms, so mostly you'd have to do a #ifdef __AMIGA__ to setup a copper list etc and just ignore it otherwise (that is, just fallback to standard SDL). |
|
![]() |
![]() |
#9 |
This cat is no more
Join Date: Dec 2004
Location: FRANCE
Age: 52
Posts: 8,381
|
the way SDL handles sound play with mixers and all is completely incompatible with Amiga hardware too. In that case, a higher level API is okay (anyway, unless you're doing very elaborate sfx system, you can use phx ptreplay to play modules & sound effects)
|
![]() |
![]() |
#10 |
Registered User
Join Date: Mar 2020
Location: Hamburg
Posts: 20
|
What about this?
#ifdef __AMIGA__ #define SPRITE SimpleSprite #else #define SPRITE SDL_Surface #endif /** Similar logic with rcSprite */ #ifdef __AMIGA__ /** MoveSprite can be the standard AmigaOS function, or a custom ASM routine */ #define MOVE_SPRITE(sprite, rcSprite) MoveSprite(NULL, sprite, rcSprite.x, rcSprite.y) #else /** Assumes screen is defined */ #define MOVE_SPRITE(sprite, rcSprite) SDL_BlitSurface(sprite, NULL, screen, rcSprite) #endif |
![]() |
![]() |
#11 |
Total Chaos forever!
Join Date: Aug 2007
Location: Waterville, MN, USA
Age: 49
Posts: 2,200
|
Or just put the SDL version in a separate library or link lib would work better.
|
![]() |
![]() |
#12 |
This cat is no more
Join Date: Dec 2004
Location: FRANCE
Age: 52
Posts: 8,381
|
with sprites, it's even trickier, specially if you reuse the same sprite image over and over.
while you can blit a pattern any number of times, moving a sprite means changing the control word at the start of SPRDAT. So if you want to display the same sprite more than once (example: enemies) you have to duplicate the sprite. It would work with main character for instance, when there's only 1 instance of the sprite. If you want to do multiplexing or such, you can't have a unified interface. For BOBs it works well. I kept SDL_BlitSurface and derived the SDL_Surface structure as "SDL_Amiga_Surface". There I could add number of planes, cookie cut or not, etc... One could add bitmap type (sprite, bitmap), with still this non-reuse constraint I talked about at the beginning of my post. |
![]() |
![]() |
#13 |
Registered User
Join Date: Mar 2020
Location: Hamburg
Posts: 20
|
One "solution" could be to make macros with variadic arguments, and then simply drop the extra arguments (used for clever sprite reuse etc) ifndef __AMIGA__. Still, might end up pretty crazy code-base.
|
![]() |
![]() |
#14 |
Registered User
Join Date: Mar 2020
Location: Hamburg
Posts: 20
|
|
![]() |
![]() |
#15 |
Total Chaos forever!
Join Date: Aug 2007
Location: Waterville, MN, USA
Age: 49
Posts: 2,200
|
@olleharstedt
I found a download link to WarpSDL (not TurboSDL after all) on the Aminet: http://aminet.net/package/util/libs/WarpSDL_0_4usr It's incomplete and doesn't come with usable headers to use the library. It's binary only. |
![]() |
![]() |
#16 | |
son of 68k
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,358
|
Quote:
We need some kind of hardware abstraction layer for the Amiga, that makes as little assumptions about the underlying hardware as possible, but still uses the machine at its best. And i seriously doubt SDL is the right base for this, it's too much PC oriented. |
|
![]() |
![]() |
#17 |
Inviyya Dude!
Join Date: Sep 2016
Location: Amiga Island
Posts: 2,798
|
Interesting idea, anyway..
![]() |
![]() |
![]() |
#18 | |
Registered User
Join Date: Mar 2020
Location: Hamburg
Posts: 20
|
Quote:
SDL can never be this since it doesn't distinguish between sprites and bobs; it assumes no hardware support for sprites (and other things). But yeah, as I argue you can make an Amiga SDL which fallbacks to bobs for everything (SDL_BlitSurface). |
|
![]() |
![]() |
#19 | |
son of 68k
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,358
|
Quote:
Therefore the idea is to design something more or less from scratch, with same goal as SDL - but made for Amiga hardware rather than PC. I have something like that for my programs actually - but i just can't port it to PC. |
|
![]() |
![]() |
#20 | |
Registered User
Join Date: Mar 2020
Location: Hamburg
Posts: 20
|
Quote:
Depends on how much hardware you want to bang, no? What about doing something system friendly? |
|
![]() |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
OpenRetro Games Database API | DanielAllsopp | support.FS-UAE | 4 | 17 May 2019 14:39 |
Do we have a 3D API? | TEG | Coders. General | 5 | 21 January 2019 09:48 |
Best Anti-virus (with API) | tygre | support.Apps | 11 | 05 November 2018 10:09 |
Programmer API for WinUAE | AmireX | support.WinUAE | 6 | 12 October 2005 17:36 |
Windows API for Amiga OS? | Pyromania | Amiga scene | 3 | 11 April 2002 13:02 |
|
|