Super NES EMULATOR SE dev question
Moderator: Moderators
Forum rules
- For making cartridges of your Super NES games, see Reproduction.
Re: Super NES EMULATOR SE dev question
You forgot a # before JOYH_LEFT and JOYH_RIGHT.
-
- Posts: 20
- Joined: Mon Nov 14, 2016 3:12 pm
- Location: France
Re: Super NES EMULATOR SE dev question
Well seen !!! Thank you very much Nicole, It's working without problem now!
Thank you ALL for the help!
I attached the source and the binary files for those interested by.
Thank you ALL for the help!
I attached the source and the binary files for those interested by.
- Attachments
-
- 20170428.zip
- Change background color with D-Pad. Source and binaries files included
- (6.76 KiB) Downloaded 171 times
-
- Posts: 123
- Joined: Mon Mar 02, 2015 1:11 am
- Location: Australia (PAL)
- Contact:
Re: Super NES EMULATOR SE dev question
Nice, It's great to see another person try their hand at programming a Super Nintendo.Peperocket wrote:I attached the source and the binary files for those interested by.
I've tried running your ROM on my PAL SNES and it only showed a white screen.
Tracing the code through bsnes-plus I discovered your NMI routine is broken. The two and NMITIMEN_JOY_ENABLE lines should be and #NMITIMEN_JOY_ENABLE. The code worked on your system because memory address $000001 had bits 7, 6 or 0 set. If all those bits were clear then NMI would never end.
Besides that bug, I have the following observations about your code. I apologise in advance for my tone, but I believe these sort of issues should be caught early.
1) Your storing and retrieving JOYH from JoypadLo, not JoypadHi.
2) The mainloop is setting CGRAM colour 1 to Blue when down is pressed.
3) You should remove the # from the following line:
Code: Select all
lda #RDNMI
The following code correctly saves the CPU state, resets DB/DP to 0, and restores the CPU state for an Interrupt Service Routine. We do not need to push/pop the P register, as the 65816 will push P to the stack when an interrupt is triggered.
Code: Select all
NMI:
; save CPU state
rep #$30
on16i
on16a
pha
phx
phy
phd
phb
; set DB to 0
phk
plb
; set DP to 0
lda #0
tcd
; set a/x size
; code goes here
; restore CPU state
rep #$30
on16i
on16a
plb
pld
ply
plx
pla
rti
Only bits 0, 6, 7 of register $4212 are set/cleared, the unmaped bits will contain the previous value of the data bus. See https://wiki.superfamicom.org/snes/show/Open+Bus for more detailsPeperocket wrote:$4212 register never return $01 but $?2. How is possible to return 2 value when only bit 0, 6 an 7 can be set?
---
EDIT: Removed clear decimal flag code from NMI ISR. The 65816 clears the decimal flag when an interrupt is triggered.
-
- Posts: 20
- Joined: Mon Nov 14, 2016 3:12 pm
- Location: France
Re: Super NES EMULATOR SE dev question
Hello,
Thank you for your answer.
Thank you for your answer.
What a stupid error!Tracing the code through bsnes-plus I discovered your NMI routine is broken. The two and NMITIMEN_JOY_ENABLE lines should be and #NMITIMEN_JOY_ENABLE. The code worked on your system because memory address $000001 had bits 7, 6 or 0 set. If all those bits were clear then NMI would never end.
You right. I don't understand the second point however. Could you explain?1) Your storing and retrieving JOYH from JoypadLo, not JoypadHi.
2) The mainloop is setting CGRAM colour 1 to Blue when down is pressed.
3) You should remove the # from the following line:
Code:
lda #RDNMI
Great, thank you! What is the assembler/linker you use? If you use Intelligent System stuff, how do you generate a usable snes rom because I would like put my works on a flash card because I only output ISX files from Linker?4) Your register push/pop code for NMI is incomplete. It only works because your used an 8 bit accumulator and never touched bits 8-15 of A in the program.
The following code correctly saves the CPU state, resets DB/DP to 0, and restores the CPU state for an Interrupt Service Routine. We do not need to push/pop the P register, as the 65816 will push P to the stack when an interrupt is triggered.
Code:
NMI:
; save CPU state
rep #$30
on16i
on16a
pha
phx
phy
phd
phb
; set DB to 0
phk
plb
; set DP to 0
lda #0
tcd
; set a/x size
; code goes here
; restore CPU state
rep #$30
on16i
on16a
plb
pld
ply
plx
pla
rti
Ohhh ... I understand now ...Only bits 0, 6, 7 of register $4212 are set/cleared, the unmaped bits will contain the previous value of the data bus. See https://wiki.superfamicom.org/snes/show/Open+Bus for more details
Right, I read this yesterday.EDIT: Removed clear decimal flag code from NMI ISR. The 65816 clears the decimal flag when an interrupt is triggered.
-
- Posts: 123
- Joined: Mon Mar 02, 2015 1:11 am
- Location: Australia (PAL)
- Contact:
Re: Super NES EMULATOR SE dev question
When down is pressed it loads green into CGDATA (at color 0) and the Accumulator is set to 3. The Accumulator (3) is then bit tested with JOYH_LEFT (2), which always passes, so blue is also loaded into CGDATA (at colour 1).Peperocket wrote:I don't understand the second point however. Could you explain?
To fix this you need to add an exit branch to each direction test after setting CGDATA. To demonstrate:
Code: Select all
Up:
bit #JOYH_UP ; on compare bit a bit avec haut
beq Down ; si non egal, passe au prochain boutton
; Set color 0 of palette 0 to red
lda #%00011111
sta CGDATA
lda #%00000000
sta CGDATA
bra EndJoypadTest
Down:
; ...
; Add `bra EndJoypadTest` to Down and Left tests
; ...
NotRight:
EndJoypadTest:
No problem. I've used both ca65/ld65 and byuu's bass assembler for my SNESdev projects.Peperocket wrote:Great, thank you! What is the assembler/linker you use?
I just used iscv.exe to convert PROG.ISX to PROG.ROM, renamed PROG.ROM to PROG.SFC and it worked fine on my Quickdev16. I don't see why it shouldn't work on a flash cart.Peperocket wrote:If you use Intelligent System stuff, how do you generate a usable snes rom because I would like put my works on a flash card because I only output ISX files from Linker?
-
- Posts: 20
- Joined: Mon Nov 14, 2016 3:12 pm
- Location: France
Re: Super NES EMULATOR SE dev question
Thank you for these clear explanation. I tried to convert once again ISX file to ROM/SFC but it always fail running on my SD2SNES.
I attached the updated code and ISX/ROM files. Could you confirm it works on your QUICKDEV?
I attached the updated code and ISX/ROM files. Could you confirm it works on your QUICKDEV?
- Attachments
-
- 20170429.zip
- (7.63 KiB) Downloaded 174 times
Re: Super NES EMULATOR SE dev question
Your ROM file does seem fine, though the header claims the ROM is 256 KB when it's actually 32 KB, and the checksums haven't been set.
My guess is that the ROM size is the problem, and it should be zero-padded out to 256 KB. I don't own a SD2SNES, but at least on the Super EverDrive, I've had problems with ROMs that were too small in the past.
Correct checksums would also be nice, but I can't imagine it's the problem here. So many ROM hacks and homebrew games don't bother, so I doubt the SD2SNES would check them, and the SNES itself doesn't care about the header at all besides the vectors.
My guess is that the ROM size is the problem, and it should be zero-padded out to 256 KB. I don't own a SD2SNES, but at least on the Super EverDrive, I've had problems with ROMs that were too small in the past.
Correct checksums would also be nice, but I can't imagine it's the problem here. So many ROM hacks and homebrew games don't bother, so I doubt the SD2SNES would check them, and the SNES itself doesn't care about the header at all besides the vectors.
Re: Super NES EMULATOR SE dev question
HEAD.S specifies Mode 21 (HiROM) but the ROM is only half a bank in size and expects to be loaded from $8000. Try changing
to
in HEAD.S.
Edit: still doesn't work, it gets stuck at the white screen... I shall take a closer look.
Code: Select all
db MODE_21 ; D5 - map mode
Code: Select all
db MODE_20 ; D5 - map mode
Edit: still doesn't work, it gets stuck at the white screen... I shall take a closer look.
-
- Posts: 123
- Joined: Mon Mar 02, 2015 1:11 am
- Location: Australia (PAL)
- Contact:
Re: Super NES EMULATOR SE dev question
The updated PROG.ROM works perfectly on my Quickdev16.Peperocket wrote:I attached the updated code and ISX/ROM files. Could you confirm it works on your QUICKDEV?
I looked at the SD2SNES source code and discovered that SD2SNES uses the map mode byte from the ROM Header to determine which memory map to use.ikari_01 wrote:HEAD.S specifies Mode 21 (HiROM) but the ROM is only half a bank in size and expects to be loaded from $8000....
I did not notice the incorrect header because bsnes/higan/snes9x uses the location of the header in the ROM file to determine the memory map.
Re: Super NES EMULATOR SE dev question
True, I only fall back to the header location if the header data is found to be unusable (invalid map mode byte). I guess I could add in another little plausibility check to match the map byte against the header location.
-
- Posts: 20
- Joined: Mon Nov 14, 2016 3:12 pm
- Location: France
Re: Super NES EMULATOR SE dev question
Hello all!
After changing header adress to $7FB0 and mode 20, rom works on my sd2snes.
I don't understand why mode 21 doesn't work however ...
After changing header adress to $7FB0 and mode 20, rom works on my sd2snes.
I don't understand why mode 21 doesn't work however ...
Re: Super NES EMULATOR SE dev question
I've been trying to setup the tool chain for SNES programming, and I'd love the manuals in English! (Also a manual for VUCC would be nice, if possible...)
-
- Posts: 20
- Joined: Mon Nov 14, 2016 3:12 pm
- Location: France
Re: Super NES EMULATOR SE dev question
Hello,
Because Nintendo legal issue, I don't know if I can attached the manual here.
Is it possible?
Because Nintendo legal issue, I don't know if I can attached the manual here.
Is it possible?
Re: Super NES EMULATOR SE dev question
I honestly don't know myself. All I know, is that Nintendo doesn't seem to have bothered about all the other VUE Debugger floppies that have been released in the past.Peperocket wrote:Hello,
Because Nintendo legal issue, I don't know if I can attached the manual here.
Is it possible?
If you feel uncomfortable about this, I completely understand!
Re: Super NES EMULATOR SE dev question
At least, in the past, there was one takedown request for the SNES dev manuals, and Koitsu has been justifiably jumpy ever since.
If that's what you're talking about. They're really east to search google for.
If that's what you're talking about. They're really east to search google for.