Forums

Sega Master System / Mark III / Game Gear
SG-1000 / SC-3000 / SF-7000 / OMV
Home - Forums - Games - Scans - Maps - Cheats - Credits
Music - Videos - Development - Hacks - Translations - Homebrew

View topic - devkitSMS - develop your homebrew in C

Reply to topic Goto page Previous  1, 2, 3, 4, 5, 6, 7, 8, 9, 10
Author Message
  • Joined: 18 Jul 2020
  • Posts: 214
Reply with quote
Post Posted: Sun Jun 19, 2022 8:43 pm
sverx wrote
yeah you can use the sdcc4.2 branch of devkitSMS only with SDCC 4.2.0 or the master branch with SDCC 4.1.0 -> 4.1.11.

If you were using SDCC 4.2.0 and the sdcc4.2 branch of devkitSMS it should have worked, or it means I've got a bug somewhere, but I've not experienced it.


Could have been a mix up, looks like I installed 4.1 first at some point, then installed 4.2. Since the SDCC folder isn't removed on uninstall, it must have been using the wrong files from devkit sms. I made sure to delete the directory when I reinstalled 4.1.

In conclusion, this seems more my error than anything else.

For clearing VRAM, is there a recommended method?
  View user's profile Send private message
  • Joined: 05 Sep 2013
  • Posts: 3217
  • Location: Torino, then London, now Stockholm
Reply with quote
Post Posted: Sun Jun 19, 2022 8:48 pm
You usually don't need to clear VRAM because you load tiles and tilemap there, but in case you need to fill a tile with zeroes (to create an empty tile) or you want to set all the tilemap to use tile number zero you could use either of these:

void SMS_VRAMmemset (unsigned int dst, unsigned char value, unsigned int size);    /* memset (bytes) to VRAM */
void SMS_VRAMmemsetW (unsigned int dst, unsigned int value, unsigned int size);    /* memset (words) to VRAM */


note that the first fills the VRAM area with a byte value and the second with a word value (short int) - the specified size must always be bytes anyway, even in the case of SMS_VRAMmemsetW.

To calculate dst you can either use TILEtoADDR(x) that converts a VRAM tile number to a VRAM address or XYtoADDR(x,y) to convert a tilemap location to a VRAM address.
  View user's profile Send private message Visit poster's website
  • Joined: 18 Jul 2020
  • Posts: 214
Reply with quote
Post Posted: Sun Jun 19, 2022 9:03 pm
sverx wrote
You usually don't need to clear VRAM because you load tiles and tilemap there, but in case you need to fill a tile with zeroes (to create an empty tile) or you want to set all the tilemap to use tile number zero you could use either of these:

void SMS_VRAMmemset (unsigned int dst, unsigned char value, unsigned int size);    /* memset (bytes) to VRAM */
void SMS_VRAMmemsetW (unsigned int dst, unsigned int value, unsigned int size);    /* memset (words) to VRAM */


note that the first fills the VRAM area with a byte value and the second with a word value (short int) - the specified size must always be bytes anyway, even in the case of SMS_VRAMmemsetW.

To calculate dst you can either use TILEtoADDR(x) that converts a VRAM tile number to a VRAM address or XYtoADDR(x,y) to convert a tilemap location to a VRAM address.


Actually, I guess this is more of a tile map issue, as it carries over the previous screens tile map entries, to the next screen I'm piecing in portions of the tile map of using SMS_loadTileMapArea. Since that screen has multiple sub states. (Vertical scroll one portion, lock top, horizontal scroll another section, then pop in the final section)

Thank you for all your help. I'm very happy everything is working now.
  View user's profile Send private message
  • Joined: 05 Sep 2013
  • Posts: 3217
  • Location: Torino, then London, now Stockholm
Reply with quote
Post Posted: Mon Jun 20, 2022 12:04 pm
you probably want to turn off the display instead of blanking the map, but of course it depends on the effect you want to achieve, if you want the player to see part of the background appear at different times, etc...
  View user's profile Send private message Visit poster's website
  • Joined: 18 Jul 2020
  • Posts: 214
Reply with quote
Post Posted: Mon Jun 20, 2022 6:26 pm
sverx wrote
you probably want to turn off the display instead of blanking the map, but of course it depends on the effect you want to achieve, if you want the player to see part of the background appear at different times, etc...


Thank you, I will keep that in mind. I didn't get to play around much after I got the right versions together, but I did manage to get most of what I wanted done. I just got to feed the "Turtles" tiles to the left covered column, while horizontally scrolling it in.

The results (My apologies, the gif capture is not as smooth as the actual game play):

https://www.pyxosoft.com/projects/sms_tmnt/gifs/sms_tmnt_title.gif

I found by using your library, that I could put the vertically scrolling title in the hidden screen part after the 24th row, and just scroll in that way, from the top. Very cool. Each chunk of screen was utilizing SMS_loadTileMapArea, so thanks for the help.
  View user's profile Send private message
  • Joined: 05 Sep 2013
  • Posts: 3217
  • Location: Torino, then London, now Stockholm
Reply with quote
Post Posted: Tue Jun 21, 2022 7:07 am
yes, the BG tilemap is 28 tiles tall on the SMS, so you can have up to 4 rows outside the screen and scroll them in vertically quite easily :)
  View user's profile Send private message Visit poster's website
  • Joined: 23 Jan 2010
  • Posts: 185
Reply with quote
Post Posted: Wed Jul 06, 2022 6:30 pm
Tutorial and examples in portuguese:
  View user's profile Send private message
  • Joined: 03 Apr 2022
  • Posts: 8
Reply with quote
Text Color
Post Posted: Sat Jul 23, 2022 3:16 am
@segarule
Hi, I believe me question is a lot trivial, but i cannot know how to do ^^.
how change color from text on a list or make a line highlights. When i try change the color, all text on screen change, not only the line i want.

Thankyou for you attention and time.
  View user's profile Send private message
  • Site Admin
  • Joined: 19 Oct 1999
  • Posts: 14190
  • Location: London
Reply with quote
Post Posted: Sat Jul 23, 2022 7:20 am
Option 1: use the sprite palette
Option 2: load a second font in new colours
Option 3: use line interrupts to change colours dynamically (difficult)
Option 4: find another way to show what’s selected, eg add a cursor
  View user's profile Send private message Visit poster's website
  • Joined: 03 Apr 2022
  • Posts: 8
Reply with quote
Post Posted: Mon Jul 25, 2022 10:17 pm
Maxim wrote
Option 1: use the sprite palette
Option 2: load a second font in new colours
Option 3: use line interrupts to change colours dynamically (difficult)
Option 4: find another way to show what’s selected, eg add a cursor


Tried

SMS_load1bppTiles(devkitSMS_font__tiles__1bpp,0,sizeof(devkitSMS_font__tiles__1bpp),1,7);
SMS_setBGPaletteColor(1,RGB(1,1,1));
SMS_setBGPaletteColor(7,RGB(3,3,3));

without success.
if it's not too much to ask, can someone show a small example?

I alread implemented the cursor using sprite, but want see changing color(from text, not for cursor ^^)
  View user's profile Send private message
  • Joined: 23 Jan 2010
  • Posts: 185
Reply with quote
Post Posted: Tue Jul 26, 2022 10:50 am
squall926 wrote
Maxim wrote
Option 1: use the sprite palette
Option 2: load a second font in new colours
Option 3: use line interrupts to change colours dynamically (difficult)
Option 4: find another way to show what’s selected, eg add a cursor


Tried

SMS_load1bppTiles(devkitSMS_font__tiles__1bpp,0,sizeof(devkitSMS_font__tiles__1bpp),1,7);
SMS_setBGPaletteColor(1,RGB(1,1,1));
SMS_setBGPaletteColor(7,RGB(3,3,3));

without success.
if it's not too much to ask, can someone show a small example?

I alread implemented the cursor using sprite, but want see changing color(from text, not for cursor ^^)


Quote
@segarule
Hi, I believe me question is a lot trivial, but i cannot know how to do ^^.
how change color from text on a list or make a line highlights. When i try change the color, all text on screen change, not only the line i want.

Thankyou for you attention and time.

I know nothing about C. I posted the video for help any interested and mainly portuguese speakers.
Maxim is an expert in programming. And here you can ask to @sverx that created these tools. My advice? Wait and you will have in time the necessary help.
  View user's profile Send private message
  • Joined: 03 Apr 2022
  • Posts: 8
Reply with quote
Post Posted: Tue Jul 26, 2022 4:18 pm
squall926 wrote
Maxim wrote
Option 1: use the sprite palette
Option 2: load a second font in new colours
Option 3: use line interrupts to change colours dynamically (difficult)
Option 4: find another way to show what’s selected, eg add a cursor


Tried

SMS_load1bppTiles(devkitSMS_font__tiles__1bpp,0,sizeof(devkitSMS_font__tiles__1bpp),1,7);
SMS_setBGPaletteColor(1,RGB(1,1,1));
SMS_setBGPaletteColor(7,RGB(3,3,3));

without success.
if it's not too much to ask, can someone show a small example?

I alread implemented the cursor using sprite, but want see changing color(from text, not for cursor ^^)



I realized why when i tried, that not worked. rsrs, Without the
SMS_autoSetUpTextRenderer();
i need call
SMS_displayOn();

Only after open the source and look inside i undertood.
Missing know what the arg tileForm on SMS_load1bppTiles is.

Now, mosaic and fade_in/out time to learn;
  View user's profile Send private message
  • Joined: 03 Apr 2022
  • Posts: 8
Reply with quote
Post Posted: Tue Aug 09, 2022 3:20 pm
Hi!!!

This new branch works on real hardware? Tested at master system 2 from tectoy but just got " software error" https://github.com/sverx/devkitSMS/tree/sdcc4.2

Yes, Installed the sdcc4.2.
  View user's profile Send private message
  • Joined: 05 Sep 2013
  • Posts: 3217
  • Location: Torino, then London, now Stockholm
Reply with quote
Post Posted: Tue Aug 09, 2022 3:58 pm
make sure you use
SMS_EMBED_SEGA_ROM_HEADER_16KB(productCode,revision);
when using banked code
  View user's profile Send private message Visit poster's website
  • Joined: 03 Apr 2022
  • Posts: 8
Reply with quote
Post Posted: Wed Aug 17, 2022 8:34 pm
sverx wrote
make sure you use
SMS_EMBED_SEGA_ROM_HEADER_16KB(productCode,revision);
when using banked code


Thankyou, this solves.
But i have another,.. maybe problem ^^.

I used the released devkit from site together sdcc 4.1, that's works nicelly.
Now i jumped to new "test devkit" with sdcc 4.2, but some functions broke. simple functions like:


u8 SD_readSingleBlock(u8 *inputbuffer, u32 startBlock) {
  u8 response;
  u16 retry = 0, bc = 0x200;

  response = SD_sendCommand(READ_SINGLE_BLOCK, startBlock); //read a Block command

  if (response != 0x00)
  {
    return response; //check for SD status: 0x00 - OK (No flags set)
  }

  SPI_EnableChipSelect();

  retry = 0;
  while (SPI_Read() != 0xfe) //wait for start block token 0xfe (0x11111110)
  {
    if (retry++ > 0xfffe)
    {
      SPI_DisableChipSelect();
      return 1; //return if time-out
    }
  }
 
  // Replace SPI_Read_Buffer, with code below.
  while(bc--){
    SPI_WAIT_READY
      *inputbuffer++ = SPI_DATA;      
  }
  //SPI_Read_Buffer(inputbuffer, 512);

  SPI_Read(); //receive incoming CRC (16-bit), CRC is ignored here
  SPI_Read();

  SPI_Read(); //extra 8 clock pulses
  SPI_DisableChipSelect();

  return 0;
}


When call the code below inside code above, the loops interact only 256 instead from 512.

void SPI_Read_Buffer(u8 *buff, u16 bc) {
   do{
      SPI_WAIT_READY
      *buff++ = SPI_DATA;      
   }while(--bc);
}


You have some ideia from what can causing this?
  View user's profile Send private message
  • Joined: 03 Apr 2022
  • Posts: 8
Reply with quote
Post Posted: Wed Aug 17, 2022 8:47 pm
Other question.
Wich is the correct way to increase the heap?
On old release, i tried

#ifndef HEAP_SIZE
#define HEAP_SIZE 2048
#endif

__xdata char __sdcc_heap[HEAP_SIZE];
const unsigned int __sdcc_heap_size = HEAP_SIZE;

but this code no compile.
  View user's profile Send private message
  • Joined: 05 Sep 2013
  • Posts: 3217
  • Location: Torino, then London, now Stockholm
Reply with quote
Post Posted: Thu Aug 18, 2022 7:11 am
squall926 wrote
You have some idea from what can causing this?


Honestly, I have really no idea. If your code was working with SDCC 4.1 and the stable devkitSMS using that, I would simply keep on using those, unless you really need to switch to the new calling convention for any reason.

As for the heap, did you check the SDCC manual? I never used the heap on SDCC so I can't help.
  View user's profile Send private message Visit poster's website
  • Joined: 28 Jan 2017
  • Posts: 427
  • Location: Málaga, Spain
Reply with quote
Post Posted: Fri Aug 26, 2022 4:56 pm
Heap? what is a heap? xD

Now seriously, i never needed to think about the heap, simply, I suppose I don't use so much ram in defined variables to get to the (in ram) heap space...
  View user's profile Send private message
  • Joined: 05 Sep 2013
  • Posts: 3217
  • Location: Torino, then London, now Stockholm
Reply with quote
Post Posted: Fri Aug 26, 2022 7:43 pm
squall926 wrote
Now i jumped to new "test devkit" with sdcc 4.2, but some functions broke.


I recently switched the 'official' devkitSMS to require SDCC 4.2 and even more recently lots of bugs were found and removed (mostly thanks to Raphnet!) so you might want to try again. Please do use the latest SDCC release available and in case some of your code isn't working as expected, try to isolate it in a short source and submit it to SDCC bug tracker so they could fix it.

Let me know if you need help anyway.
  View user's profile Send private message Visit poster's website
  • Joined: 28 Jan 2017
  • Posts: 427
  • Location: Málaga, Spain
Reply with quote
Post Posted: Sat Aug 27, 2022 9:21 pm
In fact, I have changed today my old sdcc 4.1 for the latest 4.2 and downloaded the github smsdevkit zip, without a single error compiling and running the same code of the new game i am doing.

INow the compilation (with the same config) is a bit slower.... But the rom size for the same code has decreased fron 80% of the available space on banks 0+1 to 78%.. have not checked the profiler but i guess the performance should be a bit better too.

So.... Well done PKK!!!! (Edit: and you too, sverx)
  View user's profile Send private message
Reply to topic Goto page Previous  1, 2, 3, 4, 5, 6, 7, 8, 9, 10



Back to the top of this page

Back to SMS Power!