Fabrizio Caruso Posted August 21, 2018 Share Posted August 21, 2018 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 Quote Link to comment Share on other sites More sharing options...
sanny Posted August 21, 2018 Share Posted August 21, 2018 How do you do it on the 800? (Small code excerpt...) Quote Link to comment Share on other sites More sharing options...
Wrathchild Posted August 21, 2018 Share Posted August 21, 2018 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 1 Quote Link to comment Share on other sites More sharing options...
Fabrizio Caruso Posted August 21, 2018 Author Share Posted August 21, 2018 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? Quote Link to comment Share on other sites More sharing options...
MaPa Posted August 21, 2018 Share Posted August 21, 2018 AFAIK Atari 5200 does not have shadow copy of CHBAS so you have to set the ANTIC $D409 register directly. Quote Link to comment Share on other sites More sharing options...
Fabrizio Caruso Posted August 21, 2018 Author Share Posted August 21, 2018 @MaPa should all the rest work?Are there fonts in rom at the same location?Is there a character rom at all? Quote Link to comment Share on other sites More sharing options...
sanny Posted August 21, 2018 Share Posted August 21, 2018 @MaPa should all the rest work? More or less... Are there fonts in rom at the same location? No. They are at $F800. Is there a character rom at all? Yes. regards, chris Quote Link to comment Share on other sites More sharing options...
Fabrizio Caruso Posted August 21, 2018 Author Share Posted August 21, 2018 Is the screen mapped in the same locations starting at 0xBD80? Quote Link to comment Share on other sites More sharing options...
sanny Posted August 21, 2018 Share Posted August 21, 2018 Is the screen mapped in the same locations starting at 0xBD80? You mean 0xBC80? No, it's at the address SAVMSC is pointing to. regards, chris Quote Link to comment Share on other sites More sharing options...
Fabrizio Caruso Posted August 21, 2018 Author Share Posted August 21, 2018 I fear I won't be able to port my C code for the Atari 800 easily to the Atari 5200 because CC65 does not provide the same high level functions.How do I set the 5 color in mode? I fear I will have to write straight into the corresponding registers... Quote Link to comment Share on other sites More sharing options...
sanny Posted August 21, 2018 Share Posted August 21, 2018 Which high-level functions would you need? Quote Link to comment Share on other sites More sharing options...
Fabrizio Caruso Posted August 21, 2018 Author Share Posted August 21, 2018 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? Quote Link to comment Share on other sites More sharing options...
Fabrizio Caruso Posted August 21, 2018 Author Share Posted August 21, 2018 (edited) 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 August 21, 2018 by Fabrizio Caruso Quote Link to comment Share on other sites More sharing options...
Wrathchild Posted August 21, 2018 Share Posted August 21, 2018 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 1 Quote Link to comment Share on other sites More sharing options...
Fabrizio Caruso Posted August 22, 2018 Author Share Posted August 22, 2018 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. Quote Link to comment Share on other sites More sharing options...
MaPa Posted August 22, 2018 Share Posted August 22, 2018 For the Atari 8-bit I only used $0200 bytes for the FONTS, so I assumed a 512-byte boundary. Am I wrong? Yes, you are wrong The charset needs to be at 1k boundary. Quote Link to comment Share on other sites More sharing options...
Fabrizio Caruso Posted August 22, 2018 Author Share Posted August 22, 2018 THANKS!I understand that the memory address is not fixed and it is the adress pointed to by SAVMSC ($1B).What causes SAVMSC to change?For the Atari 8-bit computer series I used the fixed address $BD80 instead of variable one.A fix address is better for me because I can keep the same code for all my (many) targets. Quote Link to comment Share on other sites More sharing options...
Fabrizio Caruso Posted August 22, 2018 Author Share Posted August 22, 2018 I have used the fixed screen memory address $3E20 (pointed by SAVMSC by default?) and it works!!Which registers do I need to write to, in order to set the four foreground colors? (I want to keep black as background). Quote Link to comment Share on other sites More sharing options...
Wrathchild Posted August 22, 2018 Share Posted August 22, 2018 From the porting guide: $08-$10 Shadows for COLPMO through COLBK Quote Link to comment Share on other sites More sharing options...
Fabrizio Caruso Posted August 22, 2018 Author Share Posted August 22, 2018 I have managed to find the registers! I am writing on $0C-$10 and it works!My game now has nice graphics on the Atari 5200! Quote Link to comment Share on other sites More sharing options...
Fabrizio Caruso Posted August 22, 2018 Author Share Posted August 22, 2018 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 portPOKE(53775u,3);to the Atari 5200 Quote Link to comment Share on other sites More sharing options...
Wrathchild Posted August 22, 2018 Share Posted August 22, 2018 POKEY_WRITE.skctl = 2 Quote Link to comment Share on other sites More sharing options...
Fabrizio Caruso Posted August 22, 2018 Author Share Posted August 22, 2018 (edited) Thanks! It works on the Atari 8-bit AND on the Atari 5200! Edited August 22, 2018 by Fabrizio Caruso Quote Link to comment Share on other sites More sharing options...
Fabrizio Caruso Posted August 22, 2018 Author Share Posted August 22, 2018 How can I prevent to trigger the sleep mode on the Atari 5200?Would POKE(77,0) work as on the Atari 8-bit computers? Quote Link to comment Share on other sites More sharing options...
Wrathchild Posted August 22, 2018 Share Posted August 22, 2018 Please take a look through the porting guide... "$04 - Attract mode timer/flag" With SKCTL, the "Bit 0 of SKCTL, the debounce enable bit, need not be set in the 5200" (when comparing a same title's A8 & 5200 code, the A8 uses 3 and 5200 uses 2) 2 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.