Wikia

ROM Hack City

Comments0

I want Foret to use labels

Kernigh October 21, 2009 User blog:Kernigh

To disassemble Mario Paint, I use my own program, which is Foret, the Free Ordinary Rom Examination Tool. This program is not complete, and has not all features that I want to use.

Consider the current disassembly of jsr subroutine $0084af.

		;;; jsr subroutine
		;;; 
		;;; A mystery... if I patch STP to ROM $0084af, then the game
		;;; stops before the title screen; but if I patch RTS to ROM
		;;; $0084af, then the game continues as normal.
/*0084af c2 30*/	rep	#PM | PX
/*0084b1 a9 fe 3d*/	lda	#$3dfe
/*0084b4 22 24 e0 01*/	jsl	$01e024
/*0084b8 a9 ff 3f*/	lda	#$3fff
/*0084bb 22 33 e0 01*/	jsl	$01e033
/*0084bf a9 fe 03*/	lda	#$03fe
/*0084c2 22 42 e0 01*/	jsl	$01e042
/*0084c6 e2 30*/	sep	#PM | PX
/*0084c8 22 97 de 01*/	jsl	$01de97
/*0084cc 22 b2 de 01*/	jsl	$01deb2
/*0084d0 22 cd de 01*/	jsl	$01decd
/*0084d4 60*/		rts

If I knew the purpose of jsl subroutines $01e024, $01e033 and so on, then subroutine $0084af would be less mysterious. In fact, I have disassembled some of those subroutines.

		;;; jsl subroutine
		;;; takes A = 16-bit value to store
		fill_7e2000_7e27ff:
/*01e024 08*/		php
/*01e025 c2 30*/	rep	#PM | PX
/*01e027 a2 00 20*/	ldx	#$2000
/*01e02a a0 00 08*/	ldy	#$0800		; Fill RAM $7e2000..$7e27ff
/*01e02d 22 60 e0 01*/	jsl	$01e060		;   with the word from A.
/*01e031 28*/		plp
/*01e032 6b*/		rtl

		;;; jsl subroutine
		;;; takes A = 16-bit value to store
		fill_7e2800_7e2fff:
/*01e033 08*/		php
/*01e034 c2 30*/	rep	#PM | PX
/*01e036 a2 00 28*/	ldx	#$2800
/*01e039 a0 00 08*/	ldy	#$0800		; Fill RAM $7e2800..$7e2fff
/*01e03c 22 60 e0 01*/	jsl	$01e060		;   with the word from A.
/*01e040 28*/		plp
/*01e041 6b*/		rtl

Foret has the ability insert the labels fill_7e2000_7e27ff and fill_7e2800_7e2fff into the disassembly, but Foret does not replace jsl $01e024 with jsl fill_7e2000_7e27ff, or replace jsl $01e033 with jsl fill_7e2800_7e2fff. Thus I can see the labels at starts of subroutines, but I cannot see labels in calls to subroutine.

I need to teach Foret to replace jsl $01e024 with jsl fill_7e2000_7e27ff. With such replacement, I would more easily read subroutine $0084af.

To add this feature, I need to program Foret to maintain a sorted mapping of addresses to labels. Then I need to teach Foret to identify instruction operands that are addresses, and replace such addresses with labels. For example, jsl takes a 24-bit address, jsr takes a 16-bit address in the current program bank, and lda.w takes a 16-bit address in the current data bank. For the last case, Foret must somehow track the current data bank of the 65816 processor.

These improvements to Foret will delay my progress for disassembling Mario Paint, but the improvements will eventually help me as I continue to disassemble Mario Paint, and begin to disassemble Donkey Kong Country 2.

Advertisement | Your ad here

Photos

Add a Photo
10photos on this wiki
See all photos >

No recent blog posts. Write one now!


What are Wikia Blogs?

Wikia community blogs allow you to contribute a blog post to any wiki's Community Blog.

Blogs are used by wiki communities for fan fiction or original work, news and announcements, questions or recommendations to the community, or reviews or op-eds. Check out Fallout Wiki's News Blog and Lostpedia's Theories Blog to see two examples.

Around Wikia's network

Random Wiki