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 - SMS Soft reset

Reply to topic
Author Message
  • Joined: 03 Apr 2022
  • Posts: 10
Reply with quote
SMS Soft reset
Post Posted: Sun Apr 03, 2022 6:00 am
Hello!!!

I'm trying do a soft reset on a cart with ram memory(where i'm loading games) but no working.
My mappe does slot0(1º 16k lock), slot 1 and 2. alread tested mapper on flash cart. works!
On cart with sram, only Golden Axe run after reset, but without graphics. my memory ram is 70ns, so i believe not is this the problem.
Above the reset code, my first asm code ^^. using sdcc devkitSMS
The write on 0x4001 make cart look like normal cart with mapper.

RESET_ADDR = 0xD000

.globl _soft_reset
_soft_reset:
    ; copy to ram and jump
    ld de, #RESET_ADDR   ; Carrega 0xD000 no registrador DE, esse endereço vai ter o soft reset
    ld hl, #SoftReset      ; inicio do soft de rest
    ld bc, #(SoftResetEnd - SoftReset)   ; tamanho do soft de reset
CopyToRamLoop:
    ld a, (hl)          ; pega um valor do softreset
    ld (de), a          ; manda pra ram em $D000
    inc de              ; inc endereço da memoria
    inc hl              ; inc endereço do codigo de soft reset
    dec bc              ; decrementa contador
    ld a, b             ; carrega A com B, e abaixo faz um OR com C, se BC for zero,
    or c                ; a flaf f é zerada, terminando o loop
    jp nz, CopyToRamLoop  ; Loop while the result is non-zero

    jp RESET_ADDR
SoftReset:
    di     ; disable interrupt
    ld hl,   #0xFFFE
    ld (hl), #0x01    ; reset slot1 mapper
    ld hl,   #0xFFFF
    ld (hl), #0x02    ; reset slot2 mapper
    ld hl,   #0x4001  ; endereço do CPLD q desativa as magic port
    ld (hl), #0x00    ; desativa tudo, deixa apenas rom no slot2
    jp 0              ; pula pro inicio da rom
SoftResetEnd:


Need do anything more on sms to soft reset work?
  View user's profile Send private message
  • Site Admin
  • Joined: 19 Oct 1999
  • Posts: 14683
  • Location: London
Reply with quote
Post Posted: Sun Apr 03, 2022 6:49 am
Opcode ldir can make the copy to RAM part much simpler.

The game might be expecting a value left at RAM address $c000 to tell it the last value written to port $3e. If this isn’t preserved then it may accidentally disable itself.
  View user's profile Send private message Visit poster's website
  • Joined: 28 Sep 1999
  • Posts: 1197
Reply with quote
Post Posted: Mon Apr 04, 2022 3:29 am
Some games expect that parts of the the system are set up by the BIOS. If you want to do a soft reset you may have to simulate this behavior.

I would add code to clear VRAM, CRAM, initialize the VDP registers, read the status register as the last interaction with the VDP, clear work RAM to zero, set SP to $DFF0, etc.

This way the state of the system after the BIOS runs, and the state after your soft reset runs are identical (or as close as managable)
  View user's profile Send private message Visit poster's website
  • Joined: 04 Jul 2010
  • Posts: 539
  • Location: Angers, France
Reply with quote
Post Posted: Mon Apr 04, 2022 6:23 am
How is done your bank offseting ?

because putting $02 in $FFFF will always result in loading $02 in $FFFF -by default- unless you send a value in your CPLD (like $20 for example, where is really the game rom) to make an offset at every slot writes.

if your menu is eating 3st banks, like
$00 - $01 - $02
1st rom wil start at $03, offset must be $03 for 1st game
every $FFFx writes in the 1st rom should add $03 to match the game calls (or hack every calls to pre add this offset, much harder as you can forget some... not always easy to see)
  View user's profile Send private message
  • Joined: 05 Sep 2013
  • Posts: 3757
  • Location: Stockholm, Sweden
Reply with quote
Post Posted: Mon Apr 04, 2022 1:10 pm
I don't get how this should work, apart from the fact that it's copying code to RAM and jumping back to $0000 at the end. Anyway...

Maxim wrote
The game might be expecting a value left at RAM address $c000 to tell it the last value written to port $3e. If this isn’t preserved then it may accidentally disable itself.


if you're using devkitSMS, you might want to add

ld a,(_SMS_Port3EBIOSvalue)
ld ($c000),a


before your

jp 0


to make sure the (next) game gets the correct value
  View user's profile Send private message Visit poster's website
  • Site Admin
  • Joined: 19 Oct 1999
  • Posts: 14683
  • Location: London
Reply with quote
Post Posted: Mon Apr 04, 2022 7:21 pm
For comparison, the Action Replay preserves the value at $c000 but then offers options to boot the game fast (jump to 0 as above) or slow (re-running BIOS). I don’t think it tries to manage the VDP state and doesn’t clear RAM or VRAM contents. However I think it does leave interrupts turned off.
  View user's profile Send private message Visit poster's website
  • Joined: 03 Apr 2022
  • Posts: 10
Reply with quote
Post Posted: Sun Apr 17, 2022 9:53 pm
Thankyou, after some mod, work nicelly.

.globl _soft_reset
_soft_reset:
    ; copy to ram and jump
    ld de, #RESET_ADDR   ; Carrega 0xD000 no registrador DE, esse endereço vai ter o soft reset
    ld hl, #SoftReset      ; inicio do soft de rest
    ld bc, #(SoftResetEnd - SoftReset)   ; tamanho do soft de reset
CopyToRamLoop:
    ld a, (hl)          ; pega um valor do softreset
    ld (de), a          ; manda pra ram em $D000
    inc de              ; inc endereço da memoria
    inc hl              ; inc endereço do codigo de soft reset
    dec bc              ; decrementa contador
    ld a, b             ; carrega A com B, e abaixo faz um OR com C, se BC for zero,
    or c                ; a flaf f é zerada, terminando o loop
    jp nz, CopyToRamLoop  ; Loop while the result is non-zero

    jp RESET_ADDR
SoftReset:
    di     ; disable interrupt
    ld hl,   #0xFFFE
    ld (hl),  #0x01    ; reset slot1 mapper
    ld hl,   #0xFFFF
    ld (hl),  #0x02    ; reset slot2 mapper

    ;Port bits
    ;Bit   Function   
    ;7       Expansion slot enable
    ;6*       Cartridge slot enable
    ;5       Card slot enable
    ;4*       RAM enable   
    ;3       BIOS ROM enable   
    ;2*       I/O enable
    ;1       Unknown   
    ;0       Unknown   
    ld a, #~(1 << 6  | 1 << 4 | 1 << 2)
    ld (0xC000), a
    out (0x3E), a

    ld hl,   #0x4004  ; endereço do CPLD q desativa as magic port
    ld (hl), #0x03    ; 0000-0011 = START 0(enable rom slot2), FlashCS 1, SDCS 1,... rom no slot2
    jp 0              ; pula pro inicio da rom
SoftResetEnd:


It's the first asm i write, so sorry about no using ldir.
Soon I will bring news.

  View user's profile Send private message
  • Joined: 03 Apr 2022
  • Posts: 10
Reply with quote
Post Posted: Thu Sep 07, 2023 11:13 pm
I want to bring here my 0.0001% contribution to the SMS development scenario.
https://squallsoftgames.com.br/blog/2022/09/26/cartucho-multi-jogo-com-sdcard-e-1mb-para-master-system/

I deleyed the project because i wanted to put FM sound on cart, but i stayed so much time without touch the project to finish pcb router.
  View user's profile Send private message
  • Joined: 06 Mar 2022
  • Posts: 593
  • Location: London, UK
Reply with quote
Post Posted: Fri Sep 08, 2023 8:18 am
Very nice @squall926!!

It's great of you to release this open source and I know the community will be grateful.

What is your CPLD device? I read your article (translated - my Português is still too basic for that but I'm working on it!) and looked in the repo and see Gerbers but no BOM.
  View user's profile Send private message Visit poster's website
  • Joined: 03 Apr 2022
  • Posts: 10
Reply with quote
Post Posted: Fri Sep 08, 2023 6:32 pm
willbritton wrote
Very nice @squall926!!

It's great of you to release this open source and I know the community will be grateful.

What is your CPLD device? I read your article (translated - my Português is still too basic for that but I'm working on it!) and looked in the repo and see Gerbers but no BOM.


Updated with BOM.
https://github.com/Alirio926/sd2sms/blob/main/BOM.txt
  View user's profile Send private message
Reply to topic



Back to the top of this page

Back to SMS Power!