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 - Beginners question [C and SMSDevKit]

Reply to topic Goto page Previous  1, 2, 3
Author Message
  • Site Admin
  • Joined: 19 Oct 1999
  • Posts: 12866
  • Location: London
Reply with quote
Post Posted: Thu Jul 25, 2019 8:46 am
The VDP memory has to be accessed by sending data one byte at a time, mostly. Technically, this is because it is mapped to the Z80 as an IO device, not memory mapped, so you can't just "memcpy" the data to where you want it, and random access is much slower than sequential access.

To write two bytes to memory at location 0x1234 you have to write two bytes to set the write address and mode (using the upper bits of the two bytes to set the mode), followed by those 32 bytes. If the screen is on then you also have to do this slower than the Z80 is capable of because the screen rendering is competing for access to the RAM.

Doing this "raw" from C is probably possible but you don't have good control of the timing (although maybe the optimiser is never good enough to make it too fast...).

The answer is perhaps to make some custom assembly to deal with specific cases - for example, setting the tilemap in a 25 bytes column or a 32 bytes row, from a contiguous source buffer. You pay the cost to fill that buffer in C during the screen time and then do the fast "unsafe" load during the VBlank. Maybe this already exists?
  View user's profile Send private message Visit poster's website
  • Joined: 24 Jun 2019
  • Posts: 44
Reply with quote
Post Posted: Thu Jul 25, 2019 12:43 pm
I see and understand :o

So using SMS_setTile for setting multiple values is acceptable?
  View user's profile Send private message
  • Site Admin
  • Joined: 19 Oct 1999
  • Posts: 12866
  • Location: London
Reply with quote
Post Posted: Thu Jul 25, 2019 1:35 pm
I suspect it's not much slower than the assembly routine.
  View user's profile Send private message Visit poster's website
  • Joined: 05 Sep 2013
  • Posts: 2484
Reply with quote
Post Posted: Tue Aug 06, 2019 5:23 pm
I think you should first of all see how quick (slow) it is to update a column of tile using this:

- calculate address of first tile to set (XYtoADDR macro)
- while (column not complete)
--- SMS_setNextTileatAddr (address)
--- setTile (tile)
--- add 64 to your address and loop

(I would say approx 24*100 cycles)
  View user's profile Send private message Visit poster's website
Reply to topic Goto page Previous  1, 2, 3



Back to the top of this page

Back to SMS Power!