Custom ROM creation log.

Start a work log and update it occasionally with your projects progress
Post Reply
User avatar
sickle
Verified
C Programming Expert
C Programming Expert
Posts: 257
Joined: Jul 17, 2013
I am a: Chocolate-fueled pug fetish robot.
Location: Scotland

Custom ROM creation log.

Post by sickle » July 25th, 2013, 8:18 pm

Edit:
This sort of turned into a log, so instead of wasting a fresh forum post...
Scroll down?


Original Text:

Hey guys, I've been having a little bit of bother getting any useful code running on my XplorerFX cart as a custom .ROM.

I've studied the Multirom source pretty thoroughly and quite successfully patched various ROMs and EXEs together with bits of multirom, myAR and the romrunner ROM by hand in the hex editor - so I've got a fairly good idea of the layout at least, and that the code is at least attempting to run.

To some extent the code is working fine - for example Silpheed's InitGPU routines from the GreenTro get at least as far as visibly altering the screen size, and I've gotten a simple test program to navigate some jumps and gracefully return control to Caetla after preserving the ra register.

However, a few things just won't play ball:

The WaitGPU function from GreenTro (called from InitGPU, while it's setting things up) hangs.
-Compiled with Spasm as .EXE - Works perfectl.y
-Compiled with ASMPSX as .EXE - Hangs at the first WaitGPU call (visible change)
-Compiled with Spasm as .BIN (spasm -b whatever.s,whatever.rom) hangs (visible change)
-Compiled with ASMPSX as .BIN (asmpsx /p whatever.s,whatever.rom) hangs (visible change)

Or using a simple program running HitMOD (asm), with a 0x20000 cycle For-Loop simulating the v sync (so it's the only other code running):

-Spasm .EXE works perfectly
-ASMPSX .EXE works perfectly
-Spasm .BIN hangs immediately with a blank screen
-ASMPSX .BIN hangs immediately with a blank screen

Is there a specific reason certain calls just won't work when ran from the cart?

Here's my code if it helps any:

Code: Select all

;Attempt at getting Hitmod (with Greentro BGM) running on Xplorer FX cart.
;Hitmod init, poll and includes borrowed from Greentro.

	opt	c+


	org	$1F000000
	dw	entryPoint2
	db	"Licensed by Sony Computer Entertainment Inc."


	org	$1F000080
	dw	entryPoint1
	db	"Licensed by Sony Computer Entertainment Inc."

	org	$1F000100

;Compiles correctly to 0x80
entryPoint1:
	
	j initStuff
	nop;

;Compiles correctly to 0x00 with header
entryPoint2:


	j initStuff
	nop;
	

initStuff:

		;Store RA on the stack. 
                addiu     sp, sp, $FFF4
                sw        ra, $0(sp)
                sw        t1, $4(sp)
                sw        t2, $8(sp)

            
            	la a0, module
            	jal HM_Init                 ; init the mod player
           	 nop
		

mainLoop:

            	jal HM_Poll                 ; call mod player
            	nop	


		li t1,$00020000
innerLoop:
		bltz t1,innerLoopEnd;
		nop
		subiu t1,t1,$1
		j innerLoop
		nop		

innerLoopEnd:
	

		j mainLoop
		nop



exitCode:

		;Return RA to its former glory, and allow to bask once again in the sweet sunlight.
                lw        ra, $0(sp)
                lw        t1, $4(sp)
                lw        t2, $8(sp)
		addiu     sp, sp, $C
	
		nop
		jr ra
		nop


;;---------------- Includes n Stuff.



	nop
	
module incbin thesong.hit
	
	nop

	include hitmod.inc	

	cnop	0,1024


	end

WaitGPU / InitGPU snippet:

Code: Select all


; WaitGPU - waits until GPU ready to receive commands
            
WaitGPU                     
            lw t1, GP1(k1)             
            li t0, $10000000
            and t1, t1, t0
            beqz t1, WaitGPU
            nop
            jr ra
            nop  


;;And a bit further down:


; InitGPU - basic GPU init routine
; in:  a0 - display mode
            
InitGPU:     



	move t3,ra	

             sw zero, GP1(k1)            ; reset

            li t2, $03000001
            sw t2, GP1(k1)              ; disable display
  
            li t2, $06c40240            ; horizontal start/end
            sw t2, GP1(k1)
            nop
  
            li t2, $07049025            ; vertical start/end 
            sw t2, GP1(k1)              
            nop              
                        
            li t2, $e1000685            ; draw mode, texture page = (8bit,320,0)
            jal WaitGPU                  ;Causes the Hang
            nop

            sw t2, GP0(k1)
            nop                                    
	    jal WaitGPU
    	    nop


As you can see it's pretty basic, but the ORG statements are set up.
(Padded them out manually with nops in spasm 'cause it only supports a single org)
I was initially pretty convinced that it was something to do with T3 failing to store RA properly, but even pushing it onto the stack, or other random registers just in case didn't make much difference. The final BIN is quite small too as you'd imagine so it's not spanning a huge amount of memory.

I've only really been learning this over about 2 days, so I'm probably missing something very obvious here - so any help would be pretty awesome - even if it's just a link to an old obscure document.

Cheers :)
Last edited by sickle on August 3rd, 2013, 7:22 am, edited 1 time in total.

User avatar
inc^lightforce
Verified
Psy-Q Enthusiast
Psy-Q Enthusiast
Posts: 248
Joined: Mar 07, 2013
I am a: Programmer Windows+PS1, GFX Artist
PlayStation Model: Black
Location: Germany

Post by inc^lightforce » July 25th, 2013, 11:01 pm

I hope this will help you:
http://rapidshare.com/files/2701055793/GREEN.rar

read *.inc Files

User avatar
sickle
Verified
C Programming Expert
C Programming Expert
Posts: 257
Joined: Jul 17, 2013
I am a: Chocolate-fueled pug fetish robot.
Location: Scotland

Post by sickle » July 26th, 2013, 7:32 am

"; NOTE: register k1 is expected to contain $1f800000 (hardware base) " - Not sure how I missed that one...

Thanks for hunting that out man :)

Also, I hate to be an arse, but I just can't source out the Macros.inc and Equates.inc files. I'm pretty sure I remember reading through them for interesting memory locations and such a few years ago I just can't find them. Any ideas?

Type 79
Verified
Active PSXDEV User
Active PSXDEV User
Posts: 61
Joined: Sep 18, 2012
Location: Finland

Post by Type 79 » July 26th, 2013, 7:49 am

sicklebrick wrote:"... I just can't source out the Macros.inc and Equates.inc files. I'm pretty sure I remember reading through them for interesting memory locations and such a few years ago I just can't find them. Any ideas?
Found those from harddrive.
EquatesMacros.zip
You do not have the required permissions to view the files attached to this post.

User avatar
sickle
Verified
C Programming Expert
C Programming Expert
Posts: 257
Joined: Jul 17, 2013
I am a: Chocolate-fueled pug fetish robot.
Location: Scotland

Post by sickle » July 26th, 2013, 8:09 am

Thankyou muchly =) I was elbow deep in a pile of ancient CDRs!

User avatar
inc^lightforce
Verified
Psy-Q Enthusiast
Psy-Q Enthusiast
Posts: 248
Joined: Mar 07, 2013
I am a: Programmer Windows+PS1, GFX Artist
PlayStation Model: Black
Location: Germany

Post by inc^lightforce » July 26th, 2013, 9:58 am

now you have all files and information. let's see some creative WORK made by you :)
but why ASM? huaaaaaaaaaaaaa. hardcore. i only use a few lines of ASM when coding Cracks and Patches. But not for a whole demo :D thats too crazy ha ha

User avatar
sickle
Verified
C Programming Expert
C Programming Expert
Posts: 257
Joined: Jul 17, 2013
I am a: Chocolate-fueled pug fetish robot.
Location: Scotland

Post by sickle » July 26th, 2013, 12:23 pm

Heh, I've always had a fascination with ASM being so close to the machine. 10 years ago or so I would have been all over PsyQ if I could find it anywhere, but suddenly it seems like it's not what I was craving. I've found some pretty cool things already.

For example, did you know that a jumping to 0x1f000280 (well 0x1f009f88 if you adjust the gp) in caetla0.34 brings up a testcard style comm screen? I've never seen that, but it's handy even if just for visual confirmation.
(I compiled a quick .exe with org at 0x1f000000 and pasted some .ROMs into the .exe at 0x800 - r3kDis can disassemble it quite well after that. Few issues, but it's an insight into the ROMs' inner workings).

On the ROM side of things, I got sick of trashing my XP cart and figured I'd try and find a way to break to the system bios when the switch is off, so I don't need to plug/unplug it each time it needs an X-Flash. (Which is quite often right now).
That or I'll have to figure out which pin disables the cart completely and add a switch...
Some of the routines are working though - the GPUInit, WaitGPU and WaitIdle functions for example. Seems I have some figuring out to do for the WaitVSync function and the Hitmod Init but it's all good fun :)


Thanks again - I'll make a wee post if anything fruitful comes from this.

User avatar
Shadow
Verified
Admin / PSXDEV
Admin / PSXDEV
Posts: 2670
Joined: Dec 31, 2012
PlayStation Model: H2000/5502
Discord: Shadow^PSXDEV

Post by Shadow » July 26th, 2013, 3:48 pm

In theory, you should be able to disable the XP cart by adding a switch on the /EN line of the EEPROM :)
Development Console: SCPH-5502 with 8MB RAM, MM3 Modchip, PAL 60 Colour Modification (for NTSC), PSIO Switch Board, DB-9 breakout headers for both RGB and Serial output and an Xplorer with CAETLA 0.34.

PlayStation Development PC: Windows 98 SE, Pentium 3 at 400MHz, 128MB SDRAM, DTL-H2000, DTL-H2010, DTL-H201A, DTL-S2020 (with 4GB SCSI-2 HDD), 21" Sony G420, CD-R burner, 3.25" and 5.25" Floppy Diskette Drives, ZIP 100 Diskette Drive and an IBM Model M keyboard.

User avatar
sickle
Verified
C Programming Expert
C Programming Expert
Posts: 257
Joined: Jul 17, 2013
I am a: Chocolate-fueled pug fetish robot.
Location: Scotland

Post by sickle » July 26th, 2013, 5:08 pm

Hehe, yeah I found some old pinout diagrams, but uhmm... when they started producing the FX carts they cut a few corners.
The new EEPROM for example isn't a regular chip with .1 inch pin spacing, it's one of those little fellers, sort of smushed in the middle of where the old chip was, with extra lines etched to the old pin spaces. Quite clever really, but no part of me really wants to be desoldering that! Thanks though man :)

Anyway, project update:
-Figured out the return to bios from EP1 and EP2.
-Graphical mode change is working pretty spiffingly. (not doing anything yet though)
-Got most of RunRom disassembled and rewritten - focusing on other areas first.
-Intergrated the Comms routines by Foo (rudimentary parallel port support).
-Switch now lets you boot regular, embedded .EXE, or graphical portion of the rom.
(toggle mid-boot to trigger the embedded .EXE)

Todo:
Transfer a ton of variables to user RAM - VSync Routines, HitMod, etc.
Like, everything else.

Basically, getting the off switch to allow XFlash to boot normally saved so much time and development is speeding ahead :)
This is so much fun... I'll post the source tomorrow.

User avatar
sickle
Verified
C Programming Expert
C Programming Expert
Posts: 257
Joined: Jul 17, 2013
I am a: Chocolate-fueled pug fetish robot.
Location: Scotland

Post by sickle » July 27th, 2013, 7:53 pm

Excuse the double post, but this is feeling like a work log.

Just a little release - like RunRom, but you don't (always) need a disc to boot.
Some .EXE will work just fine off the bat, some need a little wiggle of the switch and some just take a bloody long time, but hey, it's coming together.

http://www.psxdev.net/forum/viewtopic.php?f=60&t=393

@Type97 - Already checked - it sorta works with the last preview of your CD player :)
(Start psx with cart off, toggle cart on and hit reset, then wait 10 seconds... yeah I'm working on it!)

Type 79
Verified
Active PSXDEV User
Active PSXDEV User
Posts: 61
Joined: Sep 18, 2012
Location: Finland

Post by Type 79 » July 27th, 2013, 8:41 pm

sicklebrick wrote:@Type97 - Already checked - it sorta works with the last preview of your CD player :)
(Start psx with cart off, toggle cart on and hit reset, then wait 10 seconds... yeah I'm working on it!)
:clap have to test this later

Type 79
Verified
Active PSXDEV User
Active PSXDEV User
Posts: 61
Joined: Sep 18, 2012
Location: Finland

Post by Type 79 » July 28th, 2013, 9:43 pm

Works nicely with Xplorer using reset/switch/reset.
With GameShark-cartridge you have to first start PSX without cartridge, plug cartridge in and then reset PSX.

Something in my cdplayer causes about 30s delay on start, as there is no delay with program that just clears screen.

Great work!

User avatar
Shadow
Verified
Admin / PSXDEV
Admin / PSXDEV
Posts: 2670
Joined: Dec 31, 2012
PlayStation Model: H2000/5502
Discord: Shadow^PSXDEV

Post by Shadow » July 29th, 2013, 3:53 pm

Development Console: SCPH-5502 with 8MB RAM, MM3 Modchip, PAL 60 Colour Modification (for NTSC), PSIO Switch Board, DB-9 breakout headers for both RGB and Serial output and an Xplorer with CAETLA 0.34.

PlayStation Development PC: Windows 98 SE, Pentium 3 at 400MHz, 128MB SDRAM, DTL-H2000, DTL-H2010, DTL-H201A, DTL-S2020 (with 4GB SCSI-2 HDD), 21" Sony G420, CD-R burner, 3.25" and 5.25" Floppy Diskette Drives, ZIP 100 Diskette Drive and an IBM Model M keyboard.

User avatar
sickle
Verified
C Programming Expert
C Programming Expert
Posts: 257
Joined: Jul 17, 2013
I am a: Chocolate-fueled pug fetish robot.
Location: Scotland

Post by sickle » July 29th, 2013, 7:03 pm

Hoot cheers again. At the risk of cross posting - I figured I'd update here.
(It feels like the right thing to do).

Fixed Booting:
http://www.psxdev.net/forum/viewtopic.php?f=60&t=393

Not sure what to fiddle with next.... converting hitmod, dual booting custom exe + XFlash (timesaver!), some basic PC comms... etc. Would be nice to write something fresh though, most of this is bodged together from other sources >.<

Type 79
Verified
Active PSXDEV User
Active PSXDEV User
Posts: 61
Joined: Sep 18, 2012
Location: Finland

Post by Type 79 » July 29th, 2013, 7:42 pm

Now, with 0.2, cd-player starts from GameShark without any tricks, just power on, wait about 15s and music starts playing. :dance

Type 79
Verified
Active PSXDEV User
Active PSXDEV User
Posts: 61
Joined: Sep 18, 2012
Location: Finland

Post by Type 79 » July 29th, 2013, 9:53 pm

Combine romloader + serial-loader, flash it to old AR/GS-cart = instaboot serial-loader, poorman's Xplorer :D
Unfortunately Shadow's serial-loader is too fat to fit in GameShark, but old Hitmen's loader is slim enough.

User avatar
sickle
Verified
C Programming Expert
C Programming Expert
Posts: 257
Joined: Jul 17, 2013
I am a: Chocolate-fueled pug fetish robot.
Location: Scotland

Post by sickle » July 30th, 2013, 4:48 am

Lol, might be a good way to get some use out of my pile of gameshark clones - I don't have a serial cable or anything though :( Guess I could just use an Arduino? I'll think of something amusing to do :D

User avatar
sickle
Verified
C Programming Expert
C Programming Expert
Posts: 257
Joined: Jul 17, 2013
I am a: Chocolate-fueled pug fetish robot.
Location: Scotland

Post by sickle » August 3rd, 2013, 7:21 am

Just a little project update:

-Got pad input working pretty nicely
-Menu options! Circle to return to BIOS for example, Triangle to boot xFlash or *.exe
-Got a bit of a gui up and running, just some lines and gouraud shaded quads
-Got some sprites working (as above, needs to be copied to RAM)
-Sprites' pixel and CLUT data are read directly from a TIM (no need for separate files)
-Added a sin table for some spinning sprites, helps track down freezes, looks cute.
-Switch off currently boots XFlash (basically to make coding the rom easier)

Todo:
-Do something with all those comms routines.
-Work out why linked ordering tables aren't working when copied to RAM.
-Clean up the graphics a bit
-Pack the spritesheet a bit better, could save 20kb or so

Here's a pic:

Image

And I've included the ROM with xFlash if someone wants to play - source needs a good cleanup before I release it, but having the bailout to XFlash has made it so much faster to work with - switch off, hit reset and reflash :D
You do not have the required permissions to view the files attached to this post.

Post Reply

Who is online

Users browsing this forum: No registered users and 7 guests