how to crack a rom?

Page 5/8
1 | 2 | 3 | 4 | | 6 | 7 | 8

By NYYRIKKI

Enlighted (5396)

NYYRIKKI's picture

31-07-2010, 21:10

One thing that I can recommend is that download RuMSX emulator... The emulator it self is outdated and I don't recommend it, but the help files are VERY good... They cover for example all the MSX BASIC commands as well as BIOS routines and other stuff.

I think you should try to learn both Assembler (= more human friendly version of machine language) and BASIC... Good thing in BASIC is that you can get started fast and you can get results fast. How ever after some point it will limit you. You will end up problems with speed and if you only program BASIC you propably end up doing bad code. Good thing in assembler is that you will learn to do good code that runs fast and there is no limits, but it will take long time to get started and doing everything in assembler will take horribly much time.

If you use both languages at the same time you can select best things from both worlds... Usually only 5%-10% of the code is really speed critical... do that part on assembler... Rest of the stuff can be made on BASIC... If I would now make a game I would do things like loading screens, main menus, graphic initializations etc. on BASIC and things like screen split, music / SFX replayer and speed critical parts of game engine in assembler. Sure this is just one possibility... The fun thing is that when you learn assembler you also learn to write better and faster BASIC so that you don't need assembler anymore so much. Smile

About BASIC languages on MSX... MSX-BASIC is the one that you are already used to program a bit... It is good, but way too slow to do games or something like that... X-BASIC is very much faster and almost compatible language and you can mix it with MSX-BASIC so that the parts that are not compatible (ie. disk loading) can be done in MSX-BASIC and the actual game on X-BASIC... I use this a lot... The most advanced version is the NestorBASIC that is 100% X-BASIC compatible, but adds loads of usefull support routines such as SFX / music replayer, data crunch/decruch, direct file access, better memory access etc. Unfortunately using those support routines is not always walk in a park and you practically need to be manual in other hand all the time while coding. How ever if you are not really interested in assembler then this is the way to go. This makes it possible to do pretty damn cool games even without touching assembler at all!

By NYYRIKKI

Enlighted (5396)

NYYRIKKI's picture

31-07-2010, 21:30

Just show the guy some code so that he will understand.

Give him something easy in basic, then show him the same thing in assemler followed by a machine code dump.

Then explain to him that at best he will be able to read Konami games in assembler.

Hmm.... Not a bad idea...

I think this is good existing example:
http://www.msx.org/forumtopic10054p14.html

Here is how the assembler program (in the link) compiles to machine language.

The format on each line is: line number, memory address, machine code, assebler code.

001   0000             TIMI	  EQU	0FD9FH		;timer interrupt hook
002   0000             JPCODE    EQU	0C3H
003   0000             INTERVAL  EQU   20              ; 20 ON INTERVAL=20 GOSUB 100 ' (TEMPO)
004   0000             
005   0000             
006   0000             
007   0000 FE          	db $fe
008   0001             	dw beginProgram,end,startProgram
008   0001 00B081B006B0
009   0007             
010   0007             	org $B000
011   B000             beginProgram:
012   B000             
013   B000                     ; These "entry points" are used by BASIC loader
014   B000             
015   B000 C3 07 B0    	JP INTON  ; INTERVAL = ON  (Address #B000)
016   B003 C3 3B B0    	JP INTOFF ; INTERVAL = OFF (Address #B003)
017   B006             
018   B006             startProgram:
019   B006 C9                  RET  ; Don't do anything when BLOAD "",R
020   B007             
021   B007             ;----- interrupt on ----- Note:  restore the former hook
022   B007             				 ;when changing the hook
023   B007             
024   B007             INTON:
025   B007             
026   B007                     ;10 INTERVAL ON
027   B007             
028   B007 21 9F FD    	LD	HL,TIMI 	;OLD HOOK SAVE
029   B00A 11 36 B0    	LD	DE,HKSAVE
030   B00D 01 05 00    	LD	BC,5
031   B010 ED B0       	LDIR
032   B012             
033   B012 3E C3       	LD	A,JPCODE	;NEW HOOK SET
034   B014 F3          	DI
035   B015 32 9F FD    	LD	(TIMI),A
036   B018 21 23 B0    	LD	HL,INT
037   B01B 22 A0 FD    	LD	(TIMI+1),HL
038   B01E FB          	EI
039   B01F C9          	RET
040   B020             
041   B020             
042   B020             ;------ Some internal variables... look forward
043   B020             
044   B020 14          TEMP:    DB INTERVAL
045   B021 6E B0       POINTER: DW DATA
046   B023             
047   B023             ;----- interrupt routine -----
048   B023             
049   B023             
050   B023                     ;20 ON INTERVAL=20 GOSUB 100 ' (TEMPO)
051   B023             
052   B023             
053   B023 F5          INT:	PUSH	AF  ; This routine is called 50 or 60 times / sec
054   B024             
055   B024 3A 20 B0            LD A,(TEMP) ; ~=  TEMP=TEMP-1:IF TEMP=0 THEN GOSUB 100: TEMP=20
056   B027 3D                  DEC A
057   B028 32 20 B0            LD (TEMP),A
058   B02B 20 08               JR NZ,.EXIT ; Is it time to make "GOSUB" ? No -> continue what you were doing...
059   B02D CD 4C B0            CALL LINE100  ; Yes -> execute effect
060   B030 3E 14               LD A,INTERVAL ; How often the effect on "start" should be called (20 in this example)
061   B032 32 20 B0            LD (TEMP),A
062   B035             .EXIT
063   B035 F1           	POP	AF
064   B036             HKSAVE:
065   B036 00          	NOP			;old HOOK save area
066   B037 00          	NOP
067   B038 00          	NOP
068   B039 00          	NOP
069   B03A C9          	RET
070   B03B             	
071   B03B             	
072   B03B             
073   B03B             ;----- interrupt off ----- Note:  restore the reserved hook and exit
074   B03B             
075   B03B             INTOFF:
076   B03B                     ; 70 INTERVAL OFF:BEEP
077   B03B             
078   B03B 21 36 B0    	LD	HL,HKSAVE
079   B03E 11 9F FD    	LD	DE,TIMI
080   B041 01 05 00    	LD	BC,5
081   B044 F3          	DI
082   B045 ED B0       	LDIR
083   B047 FB          	EI  
084   B048 CD 90 00    	CALL $90 ; resetta canale audio
085   B04B C9          	RET
086   B04C             
087   B04C                     ; 90 ' Interrupt routine
088   B04C             
089   B04C             LINE100:
090   B04C 2A 21 B0            LD HL,(POINTER)
091   B04F 7E                  LD A,(HL)              ; 100 READ A
092   B050 23                  INC HL                 ; =~  A=PEEK(POINTER):POINTER=POINTER+1
093   B051 22 21 B0            LD (POINTER),HL
094   B054             
095   B054 FE FE               CP 254                 ;110 IF A=254 THEN RESTORE:GOTO 100
096   B056 20 09               JR NZ,.SKIP
097   B058 11 6E B0            LD DE,DATA
098   B05B ED 53 21 B0         LD (POINTER),DE
099   B05F 18 EB               JR LINE100
100   B061             
101   B061             .SKIP:                         ;120 IF A=255 THEN RETURN
102   B061 FE FF               CP 255
103   B063 C8                  RET Z
104   B064                     
105   B064 5E                  LD E,(HL)              ;130 READ E
106   B065 23                  INC HL
107   B066 22 21 B0            LD (POINTER),HL
108   B069                     
109   B069 CD 93 00            CALL 147               ;140 SOUND A,E
110   B06C                     
111   B06C 18 DE               JR LINE100             ;150 GOTO 100
112   B06E                     
113   B06E             DATA:                          ;160 ' Music data
114   B06E 00 00 01 01         DB 0,0, 1,1            ;170 DATA 0,0, 1,1
115   B072 08 0F FF            DB 8,15,255            ;180 DATA 8,15,255
116   B075                     DB 1,2, 8,11, 255,255  ;190 DATA 1,2, 8,11, 255,255
116   B075 0102080BFFFF
117   B07B 0800FFFFFF          DB 8,0, 255,255,255    ;200 DATA 8,0, 255,255,255
118   B080 FE                  DB 254                 ;210 DATA 254
119   B081                     
120   B081             end

So, the actual machine code when else is removed looks like this (In hexadesimal format) :

FE 00 B0 81 B0 06 B0 C3 07 B0 C3 3B B0 C9 21 9F
FD 11 36 B0 01 05 00 ED B0 3E C3 F3 32 9F FD 21
23 B0 22 A0 FD FB C9 14 6E B0 F5 3A 20 B0 3D 32
20 B0 20 08 CD 4C B0 3E 14 32 20 B0 F1 00 00 00
00 C9 21 36 B0 11 9F FD 01 05 00 F3 ED B0 FB CD
90 00 C9 2A 21 B0 7E 23 22 21 B0 FE FE 20 09 11
6E B0 ED 53 21 B0 18 EB FE FF C8 5E 23 22 21 B0
CD 93 00 18 DE 00 00 01 01 08 0F FF 01 02 08 0B
FF FF 08 00 FF FF FF FE

When we disassemble the code part of the data with Super-X it will look like this:

;B000H-B081H
	JP	XB007H
	JP	XB03BH
	RET
XB007H:	LD	HL,0FD9FH
	LD	DE,XB036H
	LD	BC,0005H
	LDIR
	LD	A,0C3H
	DI
	LD	(0FD9FH),A
	LD	HL,XB023H
	LD	(0FDA0H),HL
	EI
	RET
XB020H:	INC	D
XB021H:	LD	L,(HL)
	OR	B
XB023H:	PUSH	AF
	LD	A,(XB020H)
	DEC	A
	LD	(XB020H),A
	JR	NZ,XB035H
	CALL	XB04CH
	LD	A,14H
	LD	(XB020H),A
XB035H:	POP	AF
XB036H:	NOP
	NOP
	NOP
	NOP
	RET
XB03BH:	LD	HL,XB036H
	LD	DE,0FD9FH
	LD	BC,0005H
	DI
	LDIR
	EI
	CALL	0090H
	RET
XB04CH:	LD	HL,(XB021H)
	LD	A,(HL)
	INC	HL
	LD	(XB021H),HL
	CP	0FEH
	JR	NZ,XB061H
	LD	DE,XB06EH
	LD	(XB021H),DE
	JR	XB04CH
XB061H:	CP	0FFH
	RET	Z
	LD	E,(HL)
	INC	HL
	LD	(XB021H),HL
	CALL	0093H
	JR	XB04CH
XB06EH:

By Yukio

Paragon (1541)

Yukio's picture

31-07-2010, 21:38

CPU MSX is a Brazilian Magazine (also published as "Books") ... Their gave the magazine for FREE to contributors! I remember that I got numbers 21 and 22 for FREE (I sent some tips about Zanac and won two numbers, great contributors could receive a year of the magazine for FREE).

Another nice magazine/book is Input.
http://en.wikipedia.org/wiki/Input_Magazine
Try to have a look into some compilations around. It is nice to take some magazines into Book format.

By ZanacX

Expert (81)

ZanacX's picture

31-07-2010, 23:00

NYYRIKKI : thanks for your hard work and the example but you didnt understand me, i ment that you will give me an idea and i code them in my MSX, you know for training Smile

By NYYRIKKI

Enlighted (5396)

NYYRIKKI's picture

31-07-2010, 23:31

Well... I think you could start by cloning for example the legendary PONG game...

By ZanacX

Expert (81)

ZanacX's picture

01-08-2010, 01:34

ok thats cool i will try my best, thanx very much for your hard work and helpful ideas and super-x tools and your videos and your examples (is there some thing you didnt help me with?Tongue).thanx very much Smile

By Yukio

Paragon (1541)

Yukio's picture

01-08-2010, 21:06

Well... I think you could start by cloning for example the legendary PONG game...

Why are you telling the Guy to to this type of thing ???

For getting a "legendary" PONG lawsuit !? Why not a clone of others famous games !?
Lawsuits for anyone ? Maybe even worst the PAC-MAN lawsuit ...

By bore

Expert (115)

bore's picture

01-08-2010, 21:14

It is not illegal to clone famous games for personal use in any country on this planet as far as I know.
What could be illegal is to distribute the result but this may vary depending on your location.
Anyway, as long as you don't distribute anything other than to close friends you are legally safe.

By Yukio

Paragon (1541)

Yukio's picture

01-08-2010, 21:18

It is not illegal to clone famous games for personal use in any country on this planet as far as I know.
What could be illegal is to distribute the result but this may vary depending on your location.
Anyway, as long as you don't distribute anything other than to close friends you are legally safe.

It is the famous GREY Area ... and LAWS changes everytime almost at a heartbeat (like in Brazil)!!!

By ZanacX

Expert (81)

ZanacX's picture

01-08-2010, 21:49

PAC-MAN......well if you think so then i will start to make my own pac-man program "not cloning" then i will move on to the legendary PONG ,and its not like im using it or something...i will just simply:-make the program, write it in a paper, print it here, and see what will you say about it .

Page 5/8
1 | 2 | 3 | 4 | | 6 | 7 | 8