It is currently Sat Jun 24, 2017 7:01 pm

All times are UTC - 7 hours



Forum rules


Related:



Post new topic Reply to topic  [ 33 posts ]  Go to page Previous  1, 2, 3  Next
Author Message
PostPosted: Fri Apr 28, 2017 10:57 am 
Offline

Joined: Sun Mar 27, 2016 7:56 pm
Posts: 124
You forgot a # before JOYH_LEFT and JOYH_RIGHT.


Top
 Profile  
 
PostPosted: Fri Apr 28, 2017 11:27 am 
Offline

Joined: Mon Nov 14, 2016 3:12 pm
Posts: 16
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.


Attachments:
File comment: Change background color with D-Pad. Source and binaries files included
20170428.zip [6.76 KiB]
Downloaded 18 times
Top
 Profile  
 
PostPosted: Sat Apr 29, 2017 12:54 am 
Online
User avatar

Joined: Mon Mar 02, 2015 1:11 am
Posts: 75
Location: Australia (PAL)
Peperocket wrote:
I attached the source and the binary files for those interested by.

Nice, It's great to see another person try their hand at programming a Super Nintendo.


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:
    lda #RDNMI

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



Peperocket 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?

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


---
EDIT: Removed clear decimal flag code from NMI ISR. The 65816 clears the decimal flag when an interrupt is triggered.


Top
 Profile  
 
PostPosted: Sat Apr 29, 2017 5:40 am 
Offline

Joined: Mon Nov 14, 2016 3:12 pm
Posts: 16
Hello,

Thank you for your answer.

Quote:
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.


What a stupid error!

Quote:
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


You right. I don't understand the second point however. Could you explain?

Quote:
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


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?

Quote:
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


Ohhh ... I understand now ...

Quote:
EDIT: Removed clear decimal flag code from NMI ISR. The 65816 clears the decimal flag when an interrupt is triggered.


Right, I read this yesterday.


Top
 Profile  
 
PostPosted: Sat Apr 29, 2017 10:45 am 
Online
User avatar

Joined: Mon Mar 02, 2015 1:11 am
Posts: 75
Location: Australia (PAL)
Peperocket wrote:
I don't understand the second point however. Could you explain?
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).

To fix this you need to add an exit branch to each direction test after setting CGDATA. To demonstrate:
Code:
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:


Peperocket wrote:
Great, thank you! What is the assembler/linker you use?
No problem. I've used both ca65/ld65 and byuu's bass assembler for my SNESdev projects.

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?
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.


Top
 Profile  
 
PostPosted: Sat Apr 29, 2017 3:09 pm 
Offline

Joined: Mon Nov 14, 2016 3:12 pm
Posts: 16
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?


Attachments:
20170429.zip [7.63 KiB]
Downloaded 17 times
Top
 Profile  
 
PostPosted: Sat Apr 29, 2017 5:05 pm 
Offline

Joined: Sun Mar 27, 2016 7:56 pm
Posts: 124
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.


Top
 Profile  
 
PostPosted: Sat Apr 29, 2017 6:37 pm 
Offline
User avatar

Joined: Sat Jul 04, 2009 2:28 pm
Posts: 140
Location: Wunstorf, Germany
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
Code:
      db      MODE_21                                         ; D5 - map mode

to
Code:
      db      MODE_20                                         ; D5 - map mode

in HEAD.S.

Edit: still doesn't work, it gets stuck at the white screen... I shall take a closer look.


Top
 Profile  
 
PostPosted: Sat Apr 29, 2017 11:08 pm 
Online
User avatar

Joined: Mon Mar 02, 2015 1:11 am
Posts: 75
Location: Australia (PAL)
Peperocket wrote:
I attached the updated code and ISX/ROM files. Could you confirm it works on your QUICKDEV?
The updated PROG.ROM works perfectly on my Quickdev16.


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 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.

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.


Top
 Profile  
 
PostPosted: Sat Apr 29, 2017 11:30 pm 
Offline
User avatar

Joined: Sat Jul 04, 2009 2:28 pm
Posts: 140
Location: Wunstorf, Germany
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.


Top
 Profile  
 
PostPosted: Sun Apr 30, 2017 10:54 am 
Offline

Joined: Mon Nov 14, 2016 3:12 pm
Posts: 16
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 ...


Top
 Profile  
 
PostPosted: Mon May 29, 2017 1:28 pm 
Offline

Joined: Mon May 29, 2017 1:17 pm
Posts: 3
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...)


Top
 Profile  
 
PostPosted: Thu Jun 01, 2017 2:09 am 
Offline

Joined: Mon Nov 14, 2016 3:12 pm
Posts: 16
Hello,

Because Nintendo legal issue, I don't know if I can attached the manual here.

Is it possible?


Top
 Profile  
 
PostPosted: Thu Jun 01, 2017 9:22 am 
Offline

Joined: Mon May 29, 2017 1:17 pm
Posts: 3
Peperocket wrote:
Hello,

Because Nintendo legal issue, I don't know if I can attached the manual here.

Is it possible?


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.

If you feel uncomfortable about this, I completely understand!


Top
 Profile  
 
PostPosted: Thu Jun 01, 2017 10:22 am 
Offline

Joined: Sun Apr 13, 2008 11:12 am
Posts: 5839
Location: Seattle
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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 33 posts ]  Go to page Previous  1, 2, 3  Next

All times are UTC - 7 hours


Who is online

Users browsing this forum: AWJ, UnDisbeliever and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group