Jump to content
IGNORED

Aquarius Sprite demo complied using the z88dk devkit


barnieg

Recommended Posts

I've been slowly reactivating brain cells and have got to the point where I've been able to combine some of the z88dk c cross complier samples to create a working sprite demo for the Aquarius. Some of the code and comments are lifted from the examples I referenced and as I haven't coded properly for years I'm still on a large relearning curve.

 

I'm not sure how to create rom images at the moment so running the resulting code is a bit of a pain. Attached are the BASIC loader _bezerk.caq, and the binary block bezerk.caq. They should be loaded in sequence; type CLOAD, play the loader, then type RUN and play the binary block.

 

Development done on Ubuntu Linux, note Virtual Aquarius runs with no problems under wine :)

 

Barnie

 

 


/* Simple sample code using Ansi escape codes & putsprite with zd88k. To compile on Aquarius use 
"zcc +aquansi -create-app -o bezerk bezerk.c" from the command line. Based on spritest and ansitest 
examples that are part of the z88dk devkit. Mask is drawn AFTER the sprite, so we reduce the flicker, 
and being the mask just "a border", it is put faster. Sprites and Masks created using the Gimp then imported 
into the Z88DK Sprite Editor By Daniel McKinnon which was used to generate the Sprite code. 
Code may compile with little or no change on other targets. 

Barnie Giltrap 16/10/10 http://www.blue-horse.org.uk/ */



#include "stdio.h"

#include "games.h"

#include <stdlib.h>

#include <graphics.h>

#define UP       'k'  /* arrow up     */

#define DOWN     'm' /* arrow down   */

#define LEFT     'z'  /* arrow left   */

#define RIGHT    'x'  /* arrow right  */



char bezman[] = { 10, 14, 0x00 , 0x00 , 0x0C , 0x00 , 0x0C , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x3F 
, 0x00 , 0x4C , 0x80 , 0x4C , 0x80 , 0x4C , 0x80 , 0x0C , 0x00 , 0x0C , 0x00 
, 0x0C , 0x00 , 0x0F , 0x00 , 0x00 , 0x00  };

char maskman[] = { 10, 14, 0x0C , 0x00 , 0x12 , 0x00 , 0x12 , 0x00 , 0x0C , 0x00 , 0x3F , 0x00 , 0x40 
, 0x80 , 0xB3 , 0x40 , 0xB3 , 0x40 , 0xB3 , 0x40 , 0x52 , 0x80 , 0x33 , 0x00 
, 0x13 , 0x00 , 0x10 , 0x80 , 0x0F , 0x00  };



char bezbot[] = { 10, 10, 0x00 , 0x00 , 0x1E , 0x00 , 0x33 , 0x00 , 0x7F , 0x80 , 0x5E , 0x80 , 0x5E 

, 0x80 , 0x12 , 0x00 , 0x12 , 0x00 , 0x33 , 0x00 , 0x00 , 0x00  };





char maskbot[] = { 10, 10, 0x1E , 0x00 , 0x21 , 0x00 , 0x4C , 0x80 , 0x80 , 0x40 , 0xA1 , 0x40 , 0xA1 

, 0x40 , 0x6D , 0x80 , 0x2D , 0x00 , 0x4C , 0x80 , 0x33 , 0x00  };





main()

{

int x,y,z;

int flag=1;

int speed=1;

char *ptr;


printf ("%c2J",155);

 	printf ("%c[7mMove the Man with the Z X K M keys.\n",27);
printf ("%c[1mcolor attributes are not overwritten\n",27);


 for (x=37; x>29; x--)

 {

   printf ("%c[%umFore text colour %u.\n",27,x,x);

 }



 for (x=40; x<48; x++)

 {

   printf ("%c[%umBack text color %u.\n",27,x,x);

 }



/*

       Restore default text attributes

*/

   printf ("%c[m",27);

/*printf ("%c[7mcolor attributes are not overwritten\n",27); */


for (x=40; x<70; x=x+10)	//bots bots everywhere!

 {



putsprite(spr_or,x-10,x,bezbot);

putsprite(spr_or,x+10,x,maskbot);

 }

 



 x=40;

 y=20;

 



 

 while (flag!=2)

{

        switch( getk() ) {

                case UP:

                	y=y-speed;

                	flag=1;

                        break;

                case DOWN:

                	y=y+speed;

                	flag=1;

                        break;

                case RIGHT:

                	x++;

                	flag=1;

                        break;

                case LEFT:

                	x--;

                	flag=1;

                        break;

                case 13:

                        flag=2;

                        break;

                default:

                	speed=1;

        }

        

        if (flag==1)

        {

           if (speed<4) speed=speed+1;

	putsprite(spr_or,x,y,bezman);

  	putsprite(spr_mask,x,y,maskman); 

	   flag=0;

	}

}

}

bezerkspritdemo.zip

Link to comment
Share on other sites

Not bad for a starting demo!

 

Early next year, I'm going to begin experimenting with doing my own development for the Aquarius in C. I like working in assembly language, but I think using C would be the better option for larger projects. There are some routines that will still need to be done in assembly (programming the sound chip, interrogating the hand controllers, and using bankswitching on my new cartridge boards), but the bulk of the game logic can be implemented in C.

 

The first thing I'll really need to do with Z88DK is to find out if it can support output to a straight binary, without the cassette loader, so I can use it to compile new cartridge software. I guess there haven't been too many other people interested in making new Aquarius cartridges before now. :)

Link to comment
Share on other sites

I'm taking my coding 1 step at a time, I'm actually more likely to try some ZX-81 games to start with which can then be colorised and enhanced slightly. There are also some older spectrum titles which seem they would be realively straight forward.

 

Barnie

 

Nice demo... Are you writing berzerk for the aquarius?!?

Link to comment
Share on other sites

  • 3 years later...

Hey Barnie you still out there somewhere?

If you have a bunch of work files for all the experimenting with z88dk you were doing, I would love if you posted them.

 

What does the data in your sprite code represent? {Columns, Rows, Character, Color, Character, Color, etc}?

 

I couldn't get that sprite app you used to compile on Windows.

There is a couple of other tile painting programs that export C 'stuff' . and I could maybe hack my own
solution to writing sprites, once I figure out this z88dk workflow while trying to learn C and TileStudios scripting

and adapt the lua out put from Tiled or more likely use the C output from SPEDITO

which outputs an 8x8 sprite file like this

 

char sprite[] = { 8, 8,
  0x18 /* ...##... */,
  0x24 /* ..#..#.. */,
  0x42 /* .#....#. */,
  0x42 /* .#....#. */,
  0x7e /* .######. */,
  0x42 /* .#....#. */,
  0x42 /* .#....#. */,
  0x00 /* ........ */
};
Link to comment
Share on other sites

The curves in the graphics come from how Aquarius draws.

 

I think that's whats happening is that it has to use the character ROM and gets the best approximation for things.

Since I'm moving only one pixel at a time the sprite has be regenerated from the possible graphics characters every step.

So I'm getting character 215 shoved in my little sprites shoulder area every so many steps.

I'll post the code and binary here later.

 

post-3819-0-43088800-1383710695.png

Edited by Pset
Link to comment
Share on other sites

Not bad for a starting demo!

 

Early next year, I'm going to begin experimenting with doing my own development for the Aquarius in C. I like working in assembly language, but I think using C would be the better option for larger projects. There are some routines that will still need to be done in assembly (programming the sound chip, interrogating the hand controllers, and using bankswitching on my new cartridge boards), but the bulk of the game logic can be implemented in C.

 

The first thing I'll really need to do with Z88DK is to find out if it can support output to a straight binary, without the cassette loader, so I can use it to compile new cartridge software. I guess there haven't been too many other people interested in making new Aquarius cartridges before now. icon_smile.gif

The C compiler generates an object file.

What is generated after that just depends on the scripts and make files.

I haven't looked at the Aquarius related files but you just need to change the link files.

You'll probably need a new startup module that sets up everything needed for the C compiler.

 

Link to comment
Share on other sites

The C compiler generates an object file.

What is generated after that just depends on the scripts and make files.

I haven't looked at the Aquarius related files but you just need to change the link files.

You'll probably need a new startup module that sets up everything needed for the C compiler.

 

 

Looks like we need to put the cartridge loader into aquarius.c, I think.

Here's some chatter over the z88dk grapvine by

alvin albrecht

 

I looked at the emulator pset linked and there does appear to be a snapshot function under FILE->SAVE RAM. Despite the name, this creates a 64k binary but it is exactly 64k so there appears to be no information except a raw memory dump. Under UTIL->LoadBinaryFIle you should be able to load that binary back but I assume you have to manually set up the memory configuration to match otherwise the load won't take. Anyway, this is more of a development tool than a way to create aquarius programs.
What is really useful is the emulator’s configure memory option which shows the various normal aquarius memory maps. Every machine comes with 4k RAM and then RAM expansion modules started upward from $4000, 16k RAM being the max typical (up to address $7fff). Then at the top, either an 8k ROM cartridge at $e000 can exist or a 16k one at $c000. The catch with the cartridges is that a special signature has to be placed at $e000 to be recognized as a cart, after which is the cart start address.
Some links:
memory map
cartridge signature + signature generator
The basic thing pset linked is an example of a 16k ROM cartridge. His asm source starts at $c000, then adds padding to get to $e000, then adds the signature and continues.
I think there should be two ways to create aquarius programs:
1 - What is done now (I think!). Load from tape into RAM and hope there is enough.
2 - A 16k cartridge option. The question is how to get around the fixed signature and place ram variables elsewhere. An idea might be to place a subset of the z88dk library in the first 8k, then add the signature, then either an 8k program or more z88dk library + a tape loader. The built in tape loader could load the z88dk program proper into ram. To place variables into ram, I think all globals would have to be declared extern and then manually assigned to addresses. I have an example of that in a recent post in the BugReports subforum.
Anyway, I’m just thinking out loud here
Edited by Pset
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...