Re: Super NES EMULATOR SE dev question
Posted: Fri Apr 28, 2017 10:57 am
You forgot a # before JOYH_LEFT and JOYH_RIGHT.
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.
Code: Select all
lda #RDNMICode: 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?
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.
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?
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?
Code: Select all
db MODE_21 ; D5 - map mode
Code: Select all
db MODE_20 ; D5 - map mode
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 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?