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 - Writing to bank N and speed reading ram or rom

Reply to topic
Author Message
  • Joined: 28 Jan 2017
  • Posts: 556
  • Location: Málaga, Spain
Reply with quote
Writing to bank N and speed reading ram or rom
Post Posted: Sun Mar 18, 2018 3:12 pm
Two questions i have made myself while finding Bugs

1.What happens if i write to ROM memory. I Suppose It does not happens nothing. Or it produces some Sort of exception debuggeable in emulicious?

2. Have changed the enemy allocation algorithm from reading directly from ROM bank, to make a copy to RAM (as i want to change It in Game) and read from RAM. Now the Game It seems faster! Maybe is faster the RAM reading than the ROM one? I am not doing bankswitching so this would not be the difference.

Regards.
  View user's profile Send private message
  • Joined: 01 Feb 2014
  • Posts: 877
Reply with quote
Post Posted: Sun Mar 18, 2018 4:29 pm
1. Why do you want to write to ROM?

2. The CPU reads from adresses. It doesn‘t care whether these are in RAM or in ROM. It takes the exact same number of cycles either way.
Even if there was a difference due to the physical differences in memory types, you‘d have to do a lot of data reading to make a difference noticeable. What are you doing exactly? Maybe knowing more details can shed some light on the issue.
  View user's profile Send private message
  • Joined: 28 Jan 2017
  • Posts: 556
  • Location: Málaga, Spain
Reply with quote
Post Posted: Sun Mar 18, 2018 5:22 pm
It was a bug.I was writing to an array on ROM. When changed the write to the copy on RAM everything go faster. It is a massively used function. Noticeably faster. Its strange.
  View user's profile Send private message
  • Joined: 05 Sep 2013
  • Posts: 3827
  • Location: Stockholm, Sweden
Reply with quote
Post Posted: Mon Mar 19, 2018 2:01 pm
does the generated asm code was the same in both cases? I would say the speed shouldn't change...
  View user's profile Send private message Visit poster's website
  • Joined: 31 Oct 2007
  • Posts: 853
  • Location: Estonia, Rapla city
Reply with quote
Post Posted: Mon Mar 19, 2018 7:47 pm
Writes to ROM don't do anything, unless Flash is used and it's !WE is wired up, then the memory will switch to programming mode if right stuff is written in it (and if code is running from the ROM it it'll crash).
  View user's profile Send private message Visit poster's website
  • Joined: 14 Aug 2000
  • Posts: 742
  • Location: Adelaide, Australia
Reply with quote
Writing to bank N and speed reading ram or rom
Post Posted: Wed Mar 21, 2018 3:07 am
That's not entirely true. It depends on the hardware inserted into the cart or card slot.

For example, if a cart does not take into account the /RD line and uses the cart slot /CE for the chip /CE and the /EXM for chip /OE, then it will output data onto the data bus for any memory access, read or write, in the CPU address space 0x000 to 0x7FFF where the ROM is located.
  View user's profile Send private message
  • Joined: 31 Oct 2007
  • Posts: 853
  • Location: Estonia, Rapla city
Reply with quote
Post Posted: Wed Mar 21, 2018 9:45 am
Right, all the 32 and 48KB things like SG-1000, SC-3000 and MyCard games. On those writes to ROM are harmful and can lead to damaged hardware.
  View user's profile Send private message Visit poster's website
  • Joined: 05 Sep 2013
  • Posts: 3827
  • Location: Stockholm, Sweden
Reply with quote
Post Posted: Wed Mar 21, 2018 1:11 pm
from a programmer's perspective, writing to ROM will silently fail (*) and will take the same CPU cycles than writing to RAM.

(*) CodeMaster's mapper writes to some ROM addresses to bankswitch.
  View user's profile Send private message Visit poster's website
Reply to topic



Back to the top of this page

Back to SMS Power!