English Amiga Board


Go Back   English Amiga Board > Coders > Coders. Language > Coders. C/C++

 
 
Thread Tools
Old 26 January 2020, 15:45   #1
Hurrican
Registered User
 
Hurrican's Avatar
 
Join Date: Feb 2017
Location: Germany
Age: 46
Posts: 19
Question Help needed: Starting Amiga 500 game programming in C

Hello everybody,

I want to learn to write games for the Amiga 500 in C.

I've been writing games in AMOS for years and am fed up with its limits.
I had thought about using Assembler, but that seems to be too complex for the available time budget I have.

I know basic C syntax and have already written an Amiga program that opens its own screen and window and uses the timer.device for synching.
However, I fail at meaningfully bringing graphics on the screen.

In the mid term I want to be able to to the following:
  • show text and ILBM images
  • show and move bobs and/or sprites
  • react to joystick and keyboard input
  • play ProTracker mods and sound fx

The following conditions should also be met:
  • game runs on an Amiga 500 with 1 MB RAM, but is compatible with the A1200
  • the game is system-friendly and uses system librarys where possible
  • planned genres: puzzle game, adventure, simple jump 'n' run
  • development is done on a Windows PC, either via emulation or cross-compilation
  • usage of Assembler sub routines is possible

I feel like I have already dug through tons of tutorials and examples, yet I found nothing I was able to adapt.
In my impression the descriptions either concentrate to much on programming basics or they imply too much.

Hence, I turn to you, hoping to find some clues how to proceed.

I have the following specific questions for now:
  • Which compiler should I use? I have tried VBCC already and thought about GNUC.
  • How can I load and display ILBM pictures? Should I use the iff.library (had no success in displaying pictures with it, yet), forget Kickstart 1.3 and use the iffparse.library or is there a better way?

I'm looking forward to any hint you might have.

Kind regards,
Dennis
Hurrican is offline  
Old 26 January 2020, 19:32   #2
redblade
Zone Friend
 
redblade's Avatar
 
Join Date: Mar 2004
Location: Middle Earth
Age: 40
Posts: 2,127
on amr.abime.net. Amiga Format coverdisk 21 has some source code in C by Paul Overaa. This source code displays a backdrop and you can move a sprite with the joystick. I can't remember if it reads an IFF or if the IFF was converted to RAW format. The code is not NTSC friendly.

I don't think the sprite displays on AGA screen modes (DOUBLENTSC, EURO36). Some one coded a demo in 100% C and released the source to that as well.
redblade is offline  
Old 31 January 2020, 18:23   #3
activist
Registered User
 
Join Date: May 2017
Location: Dublin Ireland
Posts: 46
Quote:
Originally Posted by redblade View Post
on amr.abime.net. Amiga Format coverdisk 21 has some source code in C by Paul Overaa
thanks for that. Nice example, easy to follow.

These kind of ones are very good for beginner imo. At least you go off then and reference the RKRM if interested and need more info.

If know any more like this maybe, kindly, link then here.
activist is offline  
Old 31 January 2020, 19:37   #4
Ami
Registered User
 
Ami's Avatar
 
Join Date: Sep 2014
Location: Poland
Posts: 175
I might be wrong, but I recall iffparse compatible with 1.3, search in Amiga Developer CD 2.1. Does it really has to be IFF? I choosed RAW, it was easier and faster for me, something like: Open()->Read()->CopyMem(to chip ram!!!)->BltBitMapRastPort() and done!

I did some game-wannabe coding in C, unfortunately, I don't have access for my sources right now. But here are some resources from which I've taken samples:

https://github.com/Zalewa/snekorama (Snake clone)
https://github.com/68kPoker/Magazyn (Sokoban clone)
http://aminet.net/search?query=amiganitzu (Paganitzu clone)
http://aminet.net/package/game/jump/JetSetBilly (this one is using GELs system from graphics.library, IIRC)
http://aminet.net/package/dev/c/GameX (gameport.device - joystick handling code)

As for the compiler choice, stick to the one you are used to.

Last edited by Ami; 31 January 2020 at 19:50.
Ami is offline  
Old 03 February 2020, 22:21   #5
balrogsoft
Registered User
 
Join Date: May 2006
Location: Spain
Age: 42
Posts: 71
Quote:
Originally Posted by Hurrican View Post
In the mid term I want to be able to to the following:
  • show text and ILBM images
  • show and move bobs and/or sprites
  • react to joystick and keyboard input
  • play ProTracker mods and sound fx

The following conditions should also be met:
  • game runs on an Amiga 500 with 1 MB RAM, but is compatible with the A1200
  • the game is system-friendly and uses system librarys where possible
  • planned genres: puzzle game, adventure, simple jump 'n' run
  • development is done on a Windows PC, either via emulation or cross-compilation
  • usage of Assembler sub routines is possible

This is just what I was doing. My goal is to have a small game engine in C code, which is capable of running on Amiga 500 with kickstart 1.3 using system functions.

The first problem was to find how to configure a double buffer system that will work on an A500 with KS 1.3 using system functions. After doing a lot of research, I found a couple of solutions to be able to change the buffer at 50hz.

Shortly after, I found the problem that the blitter was drowning, showing flickering graphics on screen when using graphics.library. After many tests, I concluded that the system functions to use the blitter are terribly slow, a lot. And after many tests, the solution was to access the blitter directly. This greatly improved the performance,

Unfortunately, you can't configure interleaved graphics on Amiga 500 with KS 1.3 and graphics.library, I have not found a way to do it using system functions. All I have been able to do is program all the hardware directly, using C, but accessing directly the blitter, copper, etc. So you can configure the screen to use an interleaved bitmap, load your graphics bitmaps interleaved, and drawn each sprite with a single blitter operation.

My code actually is advancing in this line, but I have a small example using C code using system functions except for blitter.

You can find it in my github repository:

https://github.com/balrogsoft/amiga500-game-engine

It works on Amiga 500 with KS 1.3
It uses ptplayer routine by Frank Wille, which can be used in C, and it allows to reserve one channel for FX.
It handle basic tile rendering, and blitter sprites rendering (using hardware directly, no graphics.library involved)
Basic support for joystick.
But it doesn't handle iff files, because iffparse.library is not included on wb 1.3, my code use raw graphics, you can export from IFF with PPaint, PicCon, or any other pic converter.

For other tasks like using iff pictures, keyboard, ... you can adapt the code from my other engine, which require a faster machine, but it include a lot more than a basic A500 game engine. Both projects were compiled with SAS/C.

https://github.com/balrogsoft/amiga-game-engine

Last edited by balrogsoft; 03 February 2020 at 22:56.
balrogsoft is offline  
Old 04 February 2020, 02:50   #6
Pyromania
Moderator
 
Pyromania's Avatar
 
Join Date: Jan 2002
Location: Chicago, IL
Posts: 3,375
Nice helpful hints guys.
Pyromania is offline  
Old 04 February 2020, 14:16   #7
activist
Registered User
 
Join Date: May 2017
Location: Dublin Ireland
Posts: 46
Quote:
Originally Posted by balrogsoft View Post
Both projects were compiled with SAS/C.
Nice work.
Just wondering if you tried any of the cross compiler solutions with this ?
activist is offline  
Old 05 February 2020, 11:17   #8
balrogsoft
Registered User
 
Join Date: May 2006
Location: Spain
Age: 42
Posts: 71
Quote:
Originally Posted by activist View Post
Nice work.
Just wondering if you tried any of the cross compiler solutions with this ?
Yes, I got it working on VBCC some time ago, but the current code requires some changes to make it working on VBCC. Anyway, I did some tests and SAS/C was a little faster with my code, maybe some compiler options make it better under VBCC, but that is what i remember.
balrogsoft is offline  
Old 05 February 2020, 18:59   #9
Franchute13
Registered User
 
Franchute13's Avatar
 
Join Date: Feb 2013
Location: Argentina
Posts: 281
Quote:
Originally Posted by balrogsoft View Post
This is just what I was doing. My goal is to have a small game engine in C code, which is capable of running on Amiga 500 with kickstart 1.3 using system functions.

The first problem was to find how to configure a double buffer system that will work on an A500 with KS 1.3 using system functions. After doing a lot of research, I found a couple of solutions to be able to change the buffer at 50hz.

Shortly after, I found the problem that the blitter was drowning, showing flickering graphics on screen when using graphics.library. After many tests, I concluded that the system functions to use the blitter are terribly slow, a lot. And after many tests, the solution was to access the blitter directly. This greatly improved the performance,

Unfortunately, you can't configure interleaved graphics on Amiga 500 with KS 1.3 and graphics.library, I have not found a way to do it using system functions. All I have been able to do is program all the hardware directly, using C, but accessing directly the blitter, copper, etc. So you can configure the screen to use an interleaved bitmap, load your graphics bitmaps interleaved, and drawn each sprite with a single blitter operation.

My code actually is advancing in this line, but I have a small example using C code using system functions except for blitter.

You can find it in my github repository:

https://github.com/balrogsoft/amiga500-game-engine

It works on Amiga 500 with KS 1.3
It uses ptplayer routine by Frank Wille, which can be used in C, and it allows to reserve one channel for FX.
It handle basic tile rendering, and blitter sprites rendering (using hardware directly, no graphics.library involved)
Basic support for joystick.
But it doesn't handle iff files, because iffparse.library is not included on wb 1.3, my code use raw graphics, you can export from IFF with PPaint, PicCon, or any other pic converter.

For other tasks like using iff pictures, keyboard, ... you can adapt the code from my other engine, which require a faster machine, but it include a lot more than a basic A500 game engine. Both projects were compiled with SAS/C.

https://github.com/balrogsoft/amiga-game-engine



Thanks for sharing!,
Franchute13 is offline  
Old 05 February 2020, 19:28   #10
redblade
Zone Friend
 
redblade's Avatar
 
Join Date: Mar 2004
Location: Middle Earth
Age: 40
Posts: 2,127
Quote:
Originally Posted by activist View Post
thanks for that. Nice example, easy to follow.

These kind of ones are very good for beginner imo. At least you go off then and reference the RKRM if interested and need more info.

If know any more like this maybe, kindly, link then here.
Yes Paul Overaa released a lot of excellent C source in the early magazines before doing just AREXX and assembler in the later issues.

@balrogsoft any reason why you chose kick 13 over kick 12? Also I read in the cd32 developer docs that the blotter functions were fixed and optimised in kick 30+?
redblade is offline  
Old 05 February 2020, 21:46   #11
balrogsoft
Registered User
 
Join Date: May 2006
Location: Spain
Age: 42
Posts: 71
Quote:
Originally Posted by redblade View Post
@balrogsoft any reason why you chose kick 13 over kick 12?

My Amiga 500 machine has kickstart 1.3, it is the minimum real configuration that I can test, but I have tested it with FS-UAE with KS 1.2 and it works perfectly.


Quote:
Originally Posted by redblade View Post
Also I read in the cd32 developer docs that the blotter functions were fixed and optimised in kick 30+?

They probably did, I have no reason to doubt it, but these functions are slow, FBlit exists for that reason. You should think that a system function like BltMaskBitMapRastPort should work in many scenarios. Calling the blitter directly is a more direct and faster solution, and if you use interleaved bit planes, it is wonderful to paint all the bit planes of a blitter sprite in one operation.


CD 32 developer docs says this also:


Quote:
Things the System Cannot Do:

Scrolling individual scan lines of a ViewPort
Using a copper list to fade a AA color register
Dynamic updating of user copper lists.

So, if you need these things for your game, forget about being 100% compatible with the system.

Last edited by balrogsoft; 05 February 2020 at 21:55.
balrogsoft is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
Newbie with Amiga 500 plus - help needed mike support.Hardware 3 02 March 2017 09:50
Starting Again: Amiga 500 kit kept in storage for 22 years. robmeister New to Emulation or Amiga scene 10 02 November 2015 09:34
Amiga 3D game programming Steve Coders. General 37 17 June 2013 22:15
Help needed with programming Amiga development forum Cammy Amiga scene 18 06 February 2011 17:37
c programming help needed! jonssonj Coders. General 2 25 February 2006 20:00

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 17:07.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.21209 seconds with 13 queries