Emuforums.com

Go Back   Emuforums.com > Handheld Emulation > DeSmuME Discussion
Register FAQ Members List Calendar Mark Forums Read

Login to remove all ads!
Reply
 
LinkBack Thread Tools Display Modes
Old May 12th, 2008   #301 (permalink)
Plugin author
 
NHervé's Avatar
 
Join Date: Jul 2007
Location: Nulle part
Posts: 367
After some debugging, I remarked that MarioKart calls SWI #3 in ARM9, which means "delay loop". This is not supported by DeSmuME that only returns the cycle count. Shash told me that the MarioKart failure was related to timing, maybe this's because of this opcode that's not implemented correctly.
__________________
Pcsx2 is great emulator and Megapad is great pad plugin !!!
NHervé is offline   Reply With Quote
Old May 12th, 2008   #302 (permalink)
PCSX2 Coder
 
refraction's Avatar
 
Join Date: Jan 2004
Location: Plymouth, UK
Posts: 9,583
quite possibly. Give it a go, find out
__________________

http://www.generalemu.net/
Intel Core 2 Quad Q6600 @ 3.4Ghz (425x8), eVGA 8800GTX 768mb, 996Gb HDs, 2Gb Corsair DDR2-800 @ DDR2-1020 5-5-5-18 Dual Channel, 14605 3dMark 06 Points
CPU-Z Link
3dMark06 Score Link
Dont PM me for help, use the forums, thats what its for!



refraction is offline   Reply With Quote
Old May 12th, 2008   #303 (permalink)
Emu author
 
shashClp's Avatar
 
Join Date: Sep 2006
Location: VisualC
Posts: 651
Quote:
Originally Posted by NHervé View Post
After some debugging, I remarked that MarioKart calls SWI #3 in ARM9, which means "delay loop". This is not supported by DeSmuME that only returns the cycle count. Shash told me that the MarioKart failure was related to timing, maybe this's because of this opcode that's not implemented correctly.
I'm not 100% sure if it's related to timing, but I know of the Zelda video Demo having the same bug (CP irq wait hangs the app), and it gets fixed with a bit of timing fixing.
__________________
Emulator development blog
shashClp is offline   Reply With Quote
Old May 12th, 2008   #304 (permalink)
Plugin author
 
NHervé's Avatar
 
Join Date: Jul 2007
Location: Nulle part
Posts: 367
I think the problem is this SWI #3 : some games call it, but R0 being always 1, this SWI becomes a dummy opcode. Whereas, MarioKart calls this SWI with different values than 1, so the game is executing delays for a special purpose, and it fails probably because DeSmuME doesn't support it. I'll try to implement it and tell you the results (if it works : some beautiful screenshots, else... nothing particular).
__________________
Pcsx2 is great emulator and Megapad is great pad plugin !!!
NHervé is offline   Reply With Quote
Old May 13th, 2008   #305 (permalink)
Plugin author
 
NHervé's Avatar
 
Join Date: Jul 2007
Location: Nulle part
Posts: 367
Here's what I could discover after more debugging :
The emu gets caught in a loop. R0 must be 1 for the emu to exit this loop. Each time, the game loads to R0 the content of [PC+0x24] (=0x215122A). R0 is 0x40000, and the game calls SWI #3, then loops to start point, where it first checks if R0 is 1.
__________________
Pcsx2 is great emulator and Megapad is great pad plugin !!!
NHervé is offline   Reply With Quote
Old May 13th, 2008   #306 (permalink)
PCSX2 Coder
 
refraction's Avatar
 
Join Date: Jan 2004
Location: Plymouth, UK
Posts: 9,583
isnt R0 suppose to be a constant?
__________________

http://www.generalemu.net/
Intel Core 2 Quad Q6600 @ 3.4Ghz (425x8), eVGA 8800GTX 768mb, 996Gb HDs, 2Gb Corsair DDR2-800 @ DDR2-1020 5-5-5-18 Dual Channel, 14605 3dMark 06 Points
CPU-Z Link
3dMark06 Score Link
Dont PM me for help, use the forums, thats what its for!



refraction is offline   Reply With Quote
Old May 13th, 2008   #307 (permalink)
Plugin author
 
NHervé's Avatar
 
Join Date: Jul 2007
Location: Nulle part
Posts: 367
Are you sure ?
__________________
Pcsx2 is great emulator and Megapad is great pad plugin !!!
NHervé is offline   Reply With Quote
Old May 13th, 2008   #308 (permalink)
PCSX2 Coder
 
refraction's Avatar
 
Join Date: Jan 2004
Location: Plymouth, UK
Posts: 9,583
im not sure no, but usually on a system there is a constant register which the value is always 1 in for multiplication/division purposes.
__________________

http://www.generalemu.net/
Intel Core 2 Quad Q6600 @ 3.4Ghz (425x8), eVGA 8800GTX 768mb, 996Gb HDs, 2Gb Corsair DDR2-800 @ DDR2-1020 5-5-5-18 Dual Channel, 14605 3dMark 06 Points
CPU-Z Link
3dMark06 Score Link
Dont PM me for help, use the forums, thats what its for!



refraction is offline   Reply With Quote
Old May 13th, 2008   #309 (permalink)
Plugin author
 
NHervé's Avatar
 
Join Date: Jul 2007
Location: Nulle part
Posts: 367
No, in the NDS, there is no constant register.
__________________
Pcsx2 is great emulator and Megapad is great pad plugin !!!
NHervé is offline   Reply With Quote
Old May 13th, 2008   #310 (permalink)
PCSX2 Coder
 
refraction's Avatar
 
Join Date: Jan 2004
Location: Plymouth, UK
Posts: 9,583
so there isnt.

btw if you dont have any proper ARM docs on the cpu's themselves (always better than a tech sheet like the no$gba ones etc) there seems to be some nice ones here

emu-docs: CPU ARM
__________________

http://www.generalemu.net/
Intel Core 2 Quad Q6600 @ 3.4Ghz (425x8), eVGA 8800GTX 768mb, 996Gb HDs, 2Gb Corsair DDR2-800 @ DDR2-1020 5-5-5-18 Dual Channel, 14605 3dMark 06 Points
CPU-Z Link
3dMark06 Score Link
Dont PM me for help, use the forums, thats what its for!



refraction is offline   Reply With Quote
Old May 14th, 2008   #311 (permalink)
Registered User
 
Join Date: Nov 2007
Location: NZ
Posts: 10
Quote:
SWI 03h (NDS7/NDS9) - WaitByLoop
Performs a "LOP: SUB R0,1 / BGT LOP" wait loop, the loop is executed in BIOS memory, which provides reliable timings (regardless of the memory waitstates & cache state of the calling procedure). Intended only for short delays (eg. flash memory programming cycles).

r0 Delay value (should be in range 1..7FFFFFFFh)

Execution Time: NDS7: R0*4 cycles, plus some overload on SWI handling.
Execution Time: NDS9: R0*2 (cache on), or R0*8 (cache off), plus overload.
Note: Both NDS7 and NDS9 timings are counted in 33.51MHz units.
Return: No return value.
The current desmume implementation of this software interrupt is incorrect, as in it only returns the arm7 cycles for both cpus.

so here is my fixed implementation (untested).

Code:
u32 delayLoop(armcpu_t * cpu)
{
	u32 cycles = 0;
	u32 delay = cpu->R[0] & 0x7FFFFFFF;
	
	if(cpu->proc_ID) 
	{
		cycles = delay * 4;
	}
	else
	{
	
		if((armcp15->ctrl>>12)&1)
		{
			cycles = delay * 2;
		}
		else
		{
			cycles = delay * 8;
		}
	}
	
    return cycles;
}
Normmatt is offline   Reply With Quote
Old May 14th, 2008   #312 (permalink)
Plugin author
 
NHervé's Avatar
 
Join Date: Jul 2007
Location: Nulle part
Posts: 367
Thanks. I'll test it and tell you the result.

EDIT : It doesn't make MarioKart work, but I'm currently debugging this game. I actually found that the ARM9 gets caught in a loop, and the game wants R0 to be 1 to jump out from this loop. I need more debugging to know why R0 is not 1. Maybe it's DMA fault, or timing problem (as Shash said), or even unsupported I/O port or unaligned 32-bit read.
__________________
Pcsx2 is great emulator and Megapad is great pad plugin !!!

Last edited by NHervé; May 14th, 2008 at 19:32. Reason: Automerged Doublepost
NHervé is offline   Reply With Quote
Old May 15th, 2008   #313 (permalink)
Slow, careful & precise
 
Low Lines's Avatar
 
Join Date: Jan 2006
Location: Australia
Posts: 33
I put the SDL in the root folder, load up SM64DS and...
Code:
Problem signature:
  Problem Event Name:	APPCRASH
  Application Name:	desmume.exe
  Application Version:	0.0.0.0
  Application Timestamp:	4825a806
  Fault Module Name:	desmume.exe
  Fault Module Version:	0.0.0.0
  Fault Module Timestamp:	4825a806
  Exception Code:	c0000005
  Exception Offset:	000471cb
  OS Version:	6.0.6000.2.0.0.768.3
  Locale ID:	3081
  Additional Information 1:	17ba
  Additional Information 2:	4443eb8d185bad98a0d9398208759c99
  Additional Information 3:	0998
  Additional Information 4:	17751bbd515f9fd87f0026eb0a3a9806
__________________
Is there something of mine you've heard of or like? visit my site and check out my projects and artwork.


Low Lines is offline   Reply With Quote
Old May 15th, 2008   #314 (permalink)
Registered User
 
Join Date: Nov 2007
Location: NZ
Posts: 10
Quote:
Originally Posted by NHervé View Post
Thanks. I'll test it and tell you the result.

EDIT : It doesn't make MarioKart work, but I'm currently debugging this game. I actually found that the ARM9 gets caught in a loop, and the game wants R0 to be 1 to jump out from this loop. I need more debugging to know why R0 is not 1. Maybe it's DMA fault, or timing problem (as Shash said), or even unsupported I/O port or unaligned 32-bit read.
I talked it over with shash and the asm that makes up the original formula for the swi 3 would itself stop looping when r0 = 1; so really that function should set r0 to 1 before returning;
Normmatt is offline   Reply With Quote
Old May 15th, 2008   #315 (permalink)
PCSX2 Coder
 
refraction's Avatar
 
Join Date: Jan 2004
Location: Plymouth, UK
Posts: 9,583
Quote:
Usage

The SWI instruction is used as an operating system service call. The method used to select which operating system service is required is specified by the operating system and the SWI exception handler for the operating system determines and provides the requested service. Two typical methods are:

* The 24-bit Immediate in the instruction specifies which service is required and any parameters needed by the selected service are passed in the general-purpose registers.

* The 24-bit immediate in the instruction is ignored, general-purpose register R0 is used to select which service is wanted and any parameters needed by the selected service are passed in other general-purpose registers.
Thats from one of them manuals. so from what i see the SWI needs one of 2 options.

1. the instruction calls the service and R0 gives the result (1 for pass, 0 for error etc)
2. R0 is actually the service that it wants to interrupt and the result is like that of 1.
__________________

http://www.generalemu.net/
Intel Core 2 Quad Q6600 @ 3.4Ghz (425x8), eVGA 8800GTX 768mb, 996Gb HDs, 2Gb Corsair DDR2-800 @ DDR2-1020 5-5-5-18 Dual Channel, 14605 3dMark 06 Points
CPU-Z Link
3dMark06 Score Link
Dont PM me for help, use the forums, thats what its for!



refraction is offline   Reply With Quote
Old May 15th, 2008   #316 (permalink)
Plugin author
 
NHervé's Avatar
 
Join Date: Jul 2007
Location: Nulle part
Posts: 367
Here is the routine in asm where MarioKart freezes :
Note : NeonDS seems to freeze on the same routine. The failure is because of a NDS feature not supported by both DeSmuME and NeonDS.
Code:
02151202 : ADD R0, R7
02151204 : ADD R1, R6
02151206 : ADD R2, R5
02151208 : ADD R3, R4
0215120A : long branch - set LR
0215120C : long branch - BL 02151288                 //A long routine that must presumably set R0 to 1
0215120E : CMP R0, 1
02151210 : BEQ 0215121A                                  //Exit routine
02151212 : LDR R0, [PC, 14]                               //Set R0 = 00040000
02151214 : long branch - set LR
02151216 : long branch - BL 02000664                  //Just SWI #3
02151218 : B 02151202                                      //Loop to start of routine
EDIT : this routine is executed in Thumb mode.
EDIT2 : it is on the ARM9, and before that routine, R7 is set to 2.
__________________
Pcsx2 is great emulator and Megapad is great pad plugin !!!

Last edited by NHervé; May 15th, 2008 at 16:07.
NHervé is offline   Reply With Quote
Old May 15th, 2008   #317 (permalink)
Big DBZ fan
 
ShadowPlayer's Avatar
 
Join Date: Dec 2007
Location: Kastel Stafilic,Croatia
Posts: 344
Is it possible to speed up this emu?I set frameskips to 9,can I do something else to speed it up?
__________________
DBZ FOREVER
ShadowPlayer is offline   Reply With Quote
Old May 15th, 2008   #318 (permalink)
Plugin author
 
NHervé's Avatar
 
Join Date: Jul 2007
Location: Nulle part
Posts: 367
ShadowPlayer : of which game are you talking ? If you're not happy of DeSmuME mods, download the sources of DeSmuME and release your mods, you'll see how it's hard.
__________________
Pcsx2 is great emulator and Megapad is great pad plugin !!!
NHervé is offline   Reply With Quote
Old May 15th, 2008   #319 (permalink)
Big DBZ fan
 
ShadowPlayer's Avatar
 
Join Date: Dec 2007
Location: Kastel Stafilic,Croatia
Posts: 344
I'm happy with DeSmuMe mods and I know how hard is to make emulator.
Sorry if I said something wrong I just wanted to know is it possible to speed it up because I love playing handheld games on bigger speeds.
__________________
DBZ FOREVER
ShadowPlayer is offline   Reply With Quote
Old May 15th, 2008   #320 (permalink)
Rockman fan
 
RockmanForte's Avatar
 
Join Date: May 2002
Location: Earth!
Posts: 3,387
Be patient and NHerve and Shash will have speed improvement in the future or go to other emulators or better yet, play them on a real DS. Be patient.
__________________


CASE: EagleTech Sidewinder Gaming Tower Case w/420W Power Supply Black
OS: Windows XP Professional X64
CPU: Intel core 2 Duo Processor E8400 (2x 3.0GHz/6MB L2 Cache/1333FSB)
Processor Cooling: Thermaltake V1 CPU Cooling Fan System Kit Silent & Overclocking Proof
Graphics Card: NVIDIA GeForce 8800GT 512MB w/DVI + TV Out Video
Memory: 2048GB [1024GB X2] DDR2-800 PC6400 Memory Module Corsair-Value or Major Brand
Sound Card: 3D Premium Surround Sound Onboard
RockmanForte is online now   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On