Jump to content
IGNORED

[ATARI 5200] How do I redefine characters in mode 1 (5 color text mode)


Recommended Posts

Hi everyone,

 

I would like to redefine some characters in mode 1 (20x24 text 5-color mode).

 

I have managed to do this in C (with CC65) on the ATARI 800. How do I do this for the (very similar) Atari 5200?

I guess memory is not mapped the very same way.

Which locations/registers do I need to set to redefine the characters?
Which locations do I need to use to display the characters on the screen?

I know the foreground color is just an offset of the character (+0, +64, +128, +192)

Regards

 

Fabrizio

Link to comment
Share on other sites

To the most part, I should think that the 5200 target for CC65 should be protecting you from most of this (https://cc65.github.io/doc/atari5200.html)

 

The major different however is that the shadow registers (assuming the O/S Vblank is still used and so copies the values to the chips) commonly in page 2 of the A8 line are in page zero for the 5200.

 

The main 'go-to' document for this is here

  • Like 1
Link to comment
Share on other sites

For the Atari 8-bit line of computers, I do something like

void set_udg(void)
{
	extern char _FONT_START__[];
	unsigned char *CHBAS = (unsigned char *)0x2f4;

	memcpy(_FONT_START__, (void *)0xE000, 512);
	
	/* modify your font at _FONT_START__, etc, then set the new font: */		
	REDEFINE_AT(_FONT_START__);
	
	*CHBAS = ((int)_FONT_START__ >> ;  /* enable the new font */		
}

where REDEFINE_AT is a macro that writes at the right offsets of _FONT__START__ and so modifies just a few characters.


What do I need to change for the ATARI 5200?

Link to comment
Share on other sites

I need to choose the 5 colors of mode 1. I don't mind if it is just POKE at the right location/register or _set_color...

 

I also need to understand how to redefine characters.

For the Atari 800, I could do:

void set_udg(void)
{
	extern char _FONT_START__[];
	unsigned char *CHBAS = (unsigned char *)0x2f4;

	memcpy(_FONT_START__, (void *)0xE000, 512);
	
	/* modify your font at _FONT_START__, etc, then set the new font: */		
	REDEFINE_AT(_FONT_START__);
	
	*CHBAS = ((int)_FONT_START__ >> ;  /* enable the new font */		
}

where _FONT_START__ seems to be provided by the linker config and REFEFINE_AT is my macro that simply writes at the right offsets of _FONT_START__ so that some characters are modified.

I understand the *CHBAS has to be changed as well as 0xE000.

I was thinking of something like:

void set_udg(void)
{
	
	unsigned char *CHBASE = (unsigned char *)0xD409;

	memcpy(_FONT_START__, (void *)0xF800, 512);
	
	/* modify your font at _FONT_START__, etc, then set the new font: */		
	REDEFINE_AT(_FONT_START__);
	
	*CHBASE = ((int)_FONT_START__ >> ;  /* enable the new font */		
}

but what should I use instead of _FONT_START__, which location should I use for the new font definitions?

Link to comment
Share on other sites

I guess _FONT_START__ should point to any possible ram location that does not collide with my code.
I have no idea if and how it has to be aligned in memory and where the RAM is mapped on the Atari 5200.
By looking at the linker config, I guess it has to be within $0000-$3FFF.

Edited by Fabrizio Caruso
Link to comment
Share on other sites

fonts should align to a 1K boundary (i.e. a multiple of 0x400)

 

are you using the default linker config or rolling your own?

 

if you output a map file then you can see how much of the RAM space is being used.

Knowing that you should be able to get away with a fixed assignment, i.e.

#define FONT_AREA *(unsigned int *) 0x3800

  • Like 1
Link to comment
Share on other sites

For the Atari 8-bit I only used $0200 bytes for the FONTS, so I assumed a 512-byte boundary. Am I wrong?

I have slightly modified the default linker cfg by adding:

MEMORY
...

FONT: file = "", start = $3E00, size = $0200, define = yes;
...

SEGMENTS

...
FONT: load = FONT, type = rw, optional = yes;


So in my code _FONT_START__ should point to $3E00

I in my code I have:

void set_udg(void)
{
	extern char _FONT_START__[];
	
	unsigned char *CHBASE = (unsigned char *)0xD409;

	memcpy(_FONT_START__, (void *)0xF800, 512);
	
	/* modify your font at _FONT_START__, etc, then set the new font: */		
	REDEFINE_AT(_FONT_START__);
	
	*CHBASE = ((int)_FONT_START__ >> ;  /* enable the new font */		
}

Where REDEFINE_AT is writing at the right offsets startinf from _FONT_START__ in order to modify some characters.

Link to comment
Share on other sites

I now need to port the sound routines.
For example for the Atari 8-bit computer series I do:

	void _explosion_sound(unsigned char freq)
	{
		unsigned short i; 
		POKEY_WRITE.audctl = 0x00; 
		POKE(53775u,3); 
		POKEY_WRITE.audf1 = freq; 
		POKEY_WRITE.audc1 = 0x07; 
		for(i=150;i>0;--i) 
		{ 
			POKEY_WRITE.audc1 = i/10u; 
		} 
	}

CC65 provides POKEY_WRITE apis. I assume they are correctly implemented.
I need to figure out how to port
POKE(53775u,3);
to the Atari 5200

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...