MSX to Master System port

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

By segarules

Resident (37)

segarules's picture

07-11-2015, 16:11

You is right NYYRIKKI, thanks for all help. but i got a z80 disassembler for Windows(dz80). i did it with arkanoid-MSX for begin understand how Works. I did the process in disassembly. Now im modifying line by line Crazy until i can cut the sound code (msx soundchip different?) after i will try compile to SMS, see the errors and fix it and again and again.
I saw i homebrew made by nitrofurano and original version made by Manuel Gomez. Knights and Demons. What original version? MSX, ZX or Amstrad?
Thanks to all members here in msx fórum.

By NYYRIKKI

Enlighted (5356)

NYYRIKKI's picture

08-11-2015, 01:44

Disassembler can be a correct way to go, if the data structures are clear, but it very heavily depends of the game you are trying to work with. If the code is full of little tables in between, it contains self relocating code etc. disassembling can be next to impossible. Also if you have made critical mistake, there is no much else to do that do the disassembly again and do the changes again. Usually everything looks good and you can compile the code, but as soon as you add or remove one byte the whole program explodes and you end up looking for problems that you would not have if you would have taken the binary patching route. Worst part is that you can't really tell if you got it right or not until you find out that you didn't.

If you then try to go writing byte aligned code you are practically back to binary patching and you soon realize that Super-X would have been much better, since you could follow the code without constant usage of find & scrollbar in text editor and you could not accidentally misalign the code causing it to explode. How ever if you need to write big amount of notes, then it is great that you can do it to assembly program instead of having just list of addresses in Excel or similar.

Let's break down the binary patching problem a bit more:
When you try to get a picture of what the code is doing and how it works, using Super-X is way more easy than trying to read a mile long disassembly and trying to keep track of it. Adding memos is not that good in Super-X, so having some way of doing memos outside emulator is better. The point is how ever that you can follow all the subroutines and jumps with cursor keys and Super-X will keep track where you came from. When you do the actual support routines, a good text editor and assembler is a good tool. Patching it all up together... Yes, you guessed it... Super-X.

By segarules

Resident (37)

segarules's picture

08-11-2015, 17:00

You can be right, but first i would like try my method. And after i will see your suggestion because your knowledge is very more larger than me.
Anyway, thanks for all suport.

By giangiacomo.zaffini

Champion (267)

giangiacomo.zaffini's picture

11-11-2015, 13:55

mdz80, disassembler that I previously linked, has special mapper for the following platforms:
memargstr *mapcom[MAX_MAPPERNUMS+1] = {
mapper_sms, // 00 SEGA Master System
mapper_msx, // 01 MSX
mapper_pc88, // 02 PC-8801 mkII SR
mapper_coleco, // 03 Coleco Vision

rururutan/mdz80 - GitHub

By segarules

Resident (37)

segarules's picture

11-11-2015, 16:10

I saw the link but i was confused with all japanese text.

By segarules

Resident (37)

segarules's picture

05-12-2015, 16:01

ok. I need change strategy because after of to disassemble a game i noted that i can re-compile it to SMS. The assembler that i use is WLA DX and maybe it don't recognize any commands ported. Any member have a better idea?

By giangiacomo.zaffini

Champion (267)

giangiacomo.zaffini's picture

07-12-2015, 21:54

@segarules : do You have compiling errors? Do You have an emulator with debugging capability to try to figure out problems? Do You face hard times in porting some platform specific code parts? I guess You started an hard path.

By segarules

Resident (37)

segarules's picture

08-12-2015, 00:41

Very very errors. I will try meka but WLA DX neither generated a .sms valid.

By giangiacomo.zaffini

Champion (267)

giangiacomo.zaffini's picture

08-12-2015, 16:23

In my very short experience I noticed that different assembler can have different ways to express indirect addressing, immediate variable evaluation and also branch to label. Doing de-assembly and assembly again with a specific assembler, extra care must go into all these subtle points just to avoid syntax errors.
Again, You starded a very hard path, I guess this is just the beginning.

An example of different assembly syntax, the following is the same code with different syntax :

1. code for SDCC sdasz80 and ASxxxx asz80

.module singload
.z80

; BLOAD MODULE FOR SINGLE FILE MODE (FOR CASLINK2 PROJECT)
; COPYRIGHT (C) 1999-2008 ALEXEY PODREZOV

; CREATE ENVIRONMENT COMMANDS
; set path_back=%PATH%
; set PATH="C:\Program Files\SDCC\bin"
; ASSEMBLY COMMAND
; sdasz80 -l -o .module
; LINK COMMAND
; sdldz80 -b _CODE=0x9000 -i .module -m
; CLEAN ENVIRONMENT COMMAND
; set PATH=%path_back%

.area _CODE

START: jp START1

STARTA: .dw 00
ENDA: .dw 00
EXECA: .dw 00
CRC: .db 00

CASERR: .strz "[CasLink2] Loading failed: CRC ERROR!"

START1: di
ld HL,(STARTA)
ld DE,(ENDA)
ex DE,HL ; Exchange the HL and DE registers
sbc HL,DE ; Subtract with borrow HL and register pair ss. HL<-HL-ss-C
push HL ; ROMCODE length
pop BC ; ROMCODE length
ld HL,#ROMCODE
xor A ; A XOR A -> accumulator register A zeroed
push AF
START2: pop AF
add A,(HL) ; update CRC algorithm: sum of (HL)
inc HL
dec BC
push AF
ld A,C
or A
jp NZ,START2 ; if LSB of pair BC is NOT ZERO
ld A,B
or A
jp NZ,START2 ; if MSB of pair BC is NOT ZERO
pop AF ; retrieve CRC algorithm: sum of (HL)
ld B,A
ld HL,#CRC
ld A,(HL) ; retrieve CRC found value
cp B ; Compare operand s to accumulator. A - s
jp Z,START5

CRCERR: ei
call #0x006C ; 006CH INITXT 050EH Initialize VDP to 40x24 Text Mode

ld A,#0x0F ; 0FH White colour
ld HL,#0xF3E9 ; F3E9H FORCLR: This variable contains the current foreground colour
ld (HL),A ; F3E9H FORCLR: This variable contains the current foreground colour
ld A,#0x08 ; 08H Medium red colour
inc HL ; F3EAH BAKCLR: This variable contains the current background colour
ld (HL),A ; F3EAH BAKCLR: This variable contains the current background colour
inc HL ; F3EBH BDRCLR: This variable contains the current border colour
ld (HL),A ; F3EBH BDRCLR: This variable contains the current border colour
call #0x0062 ; 0062H CHGCLR 07F7H Change VDP colours
xor A ; A XOR A -> accumulator register A zeroed
call #0x00C3 ; 00C3H CLS 0848H Clear screen
call #0x00CC ; 00CCH ERAFNK 0B15H Erase function key display
ld HL,#0x0101
call #0x00C6 ; 00C6H POSIT 088EH Set cursor position
ld DE,#CASERR
START3: ld A,(DE)
or A ; A OR A tests if A is zero -> Z flag set
jp Z,START4
inc DE
call #0x00A2 ; 00A2H CHPUT 08BCH Screen character output
inc H
call #0x00C6 ; 00C6H POSIT 088EH Set cursor position
jp START3

START4: ld HL,#0x0103
call #0x00C6 ; 00C6H POSIT 088EH Set cursor position
call #0x00C0 ; 00C0H BEEP 1113H Go beep
call #0x0156 ; 0156H KILBUF 0468H Clear keyboard buffer
ei
ret

START5: di
ld HL,#START6
ld DE,#ROMCODE + 1
ex DE,HL ; Exchange the HL and DE registers
sbc HL,DE ; Subtract with borrow HL and register pair ss. HL<-HL-ss-C
ld B,H
ld C,L
ld HL,#START6
ld DE,#0xF560 ; F55EH BUF: DEFS 259 This buffer contains the text collected from the console by the INLIN standard routine
push DE
ldir ; LDIR Repeating block load with Increment. Function: (DE)<-(HL); DE<-DE+1; HL<-HL+1; BC<-BC-1; Repeat until BC = 0
ret

START6: ld HL,(EXECA)
push HL
ld HL,(STARTA)
ld DE,(ENDA)
ex DE,HL ; Exchange the HL and DE registers
sbc HL,DE ; Subtract with borrow HL and register pair ss. HL<-HL-ss-C
ld B,H
ld C,L
ld HL,#ROMCODE
ld DE,(STARTA)
ldir ; LDIR Repeating block load with Increment. Function: (DE)<-(HL); DE<-DE+1; HL<-HL+1; BC<-BC-1; Repeat until BC = 0
ei
ret
nop

ROMCODE:

2. code for pasmo and I think also for M80

.Z80

; BLOAD MODULE FOR SINGLE FILE MODE (FOR CASLINK2 PROJECT)
; COPYRIGHT (C) 1999-2008 ALEXEY PODREZOV

ASEG
ORG 9000h

START: JP START1

STARTA: DW 00
ENDA: DW 00
EXECA: DW 00
CRC: DB 00

CASERR: DB "[CasLink2] Loading failed: CRC ERROR!",0

START1: DI
LD HL,(STARTA)
LD DE,(ENDA)
EX DE,HL
SBC HL,DE
PUSH HL
POP BC
LD HL,ROMCODE
XOR A
PUSH AF
START2: POP AF
ADD A,(HL)
INC HL
DEC BC
PUSH AF
LD A,C
OR A
JP NZ,START2
LD A,B
OR A
JP NZ,START2
POP AF
LD B,A
LD HL,CRC
LD A,(HL)
CP B
JP Z,START5

CRCERR: EI
CALL 006CH ; set screen 0
LD A,0FH
LD HL,0F3E9H
LD (HL),A
LD A,8
INC HL
LD (HL),A
INC HL
LD (HL),A
CALL 0062H ; set color 15,8,8
XOR A
CALL 00C3H ; clear screen
CALL 00CFH ; unhide functional keys
LD HL,0101H
CALL 00C6H ; set cursor position to 1:1
LD DE,CASERR
START3: LD A,(DE)
OR A
JP Z,START4
INC DE
CALL 00A2H ; display character
INC H
CALL 00C6H ; set next position
JP START3

START4: LD HL,0103H
CALL 00C6H ; set cursor position to 1:3
CALL 00C0H ; beep
CALL 0156H ; clears keyboard buffer
EI
RET

START5: DI
LD HL,START6
LD DE,ROMCODE+1
EX DE,HL
SBC HL,DE
LD B,H
LD C,L
LD HL,START6
LD DE,0F560H
PUSH DE
LDIR
RET

START6: LD HL,(EXECA)
PUSH HL
LD HL,(STARTA)
LD DE,(ENDA)
EX DE,HL
SBC HL,DE
LD B,H
LD C,L
LD HL,ROMCODE
LD DE,(STARTA)
LDIR
EI
RET
NOP

ROMCODE:

END

By segarules

Resident (37)

segarules's picture

09-12-2015, 00:18

Quote:

In my very short experience I noticed that different assembler can have different ways to express indirect addressing, immediate variable evaluation and also branch to label.

Exactly my friend. And i only noted when i consulted a assembly tutorial to Sega Master System. I were a fool in to think that port a msx game to SMS would be easy just taking code with disassembler and re-compiling it. Maybe to be better start all from zero.

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