MarcoSantos Posted May 20, 2021 Share Posted May 20, 2021 Sorry for warming up this old thread. I found this very fascinating and compiled this source yesterday. after some problems with visual studio 2019 I add the line: #include "stdafx.h" as first line in z80compiler and get the exe file finished. Now I´m wondering , which disassembly file I need to proceed ? How should the format going ? Label, opcode ? is there a sample Z80 disassembly for testing ? cheers Markus 1 Quote Link to comment Share on other sites More sharing options...
MarcoSantos Posted May 20, 2021 Share Posted May 20, 2021 I tied z80dasm disassembler - no luck I tried Dos DASMz80 - no luck which disassembler is producing a correct file for this compiler ? here some official z80 disassembly from win32 z80dasm... cheers Markus l0266h: ld b,010h ld hl,06000h xor a l026ch: ld c,a l026dh: ld (hl),a inc hl dec c jr nz,l026dh djnz l026ch ld b,004h ld hl,07000h l0279h: ld c,a l027ah: ld (hl),a inc hl dec c jr nz,l027ah djnz l0279h ld b,004h ld a,010h ld hl,07400h l0288h: ld c,000h l028ah: ld (hl),a inc hl dec c jr nz,l028ah djnz l0288h ld hl,060c0h ld b,040h ld a,0ffh l0298h: ld (hl),a inc hl djnz l0298h ld a,0c0h ld (060b0h),a ld (060b1h),a xor a ld (07d83h),a ld (07d86h),a ld (07d87h),a inc a ld (07d82h),a ld sp,06c00h call sub_011ch ld a,001h ld (07d84h),a l02bdh: Quote Link to comment Share on other sites More sharing options...
shanti77 Posted May 21, 2021 Share Posted May 21, 2021 On 1/26/2020 at 2:55 PM, mariuszw said: Published recompiler is quite picky about format of disassembly and actually accepts only the format produced by my own disassembly tool. With the time, I updated recompiler to accept different formats of disassembly. Chances are I skoolkit produced disassembly listings can work now. If they don't, I can update recompiler. Quote Link to comment Share on other sites More sharing options...
MarcoSantos Posted May 21, 2021 Share Posted May 21, 2021 (edited) ah thank you. I missed the line. ok I will check this skoolish. last night I tried to recompile the attached pg_disassembly and this will have trouble too. For instance a simple " LD reg, Val" creates an error... But slowly I get a feeling about that tool.... best willl be a sourcecode transformer to "mariuszdasm" format ;Start XOR A ;AF88: OUT (FE),A ;AF8A: LD HL,ScratchMem ;AF8D: LD BC,0726 ;AF90: CALL ClrMem ;LAF93 LD HL,LA70E ;AF96: LD BC,0721 ;AF99: CALL ClrMem ;AF9C: CALL ClrScr ;AF9F: LD A,43 ;AFA1: CALL FillAttr ;AFA4: CALL LB29A ;AFA7: LD A,05 ;AFA9: LD (LA721),A ;AFAC: LD A,R ÷G lda #$00 ; XOR A ; Syntax Error: OUT (FE),A lda #<SCRATCHMEM ; LD HL,SCRATCHMEM sta z80_l lda #>SCRATCHMEM sta z80_h lda #<L0726CHMEM ; LD BC,0726 sta z80_c lda #>L0726CHMEM sta z80_b jsr CLRMEM ; CALL CLRMEM ÷G lda #<LA70E ; LD HL,LA70E sta z80_l lda #>LA70E sta z80_h lda #<L0721 ; LD BC,0721 sta z80_c lda #>L0721 sta z80_b jsr CLRMEM ; CALL CLRMEM jsr CLRSCR ; CALL CLRSCR ; Syntax Error: LD A,43 jsr FILLATTR ; CALL FILLATTR jsr LB29A ; CALL LB29A ; Syntax Error: LD A,05 sta LA721 ; LD (LA721),A; Warning: A read but not set by previous instruction ld_a_r ; LD A,R Edited May 21, 2021 by MarcoSantos In the meantime I fixed some errors .... Quote Link to comment Share on other sites More sharing options...
ivop Posted May 21, 2021 Share Posted May 21, 2021 7 hours ago, MarcoSantos said: best willl be a sourcecode transformer to "mariuszdasm" format Why not just use mariuszdasm in the first place? Is it not available? Quote Link to comment Share on other sites More sharing options...
MarcoSantos Posted May 21, 2021 Share Posted May 21, 2021 do you know where to find ? Quote Link to comment Share on other sites More sharing options...
shanti77 Posted May 22, 2021 Share Posted May 22, 2021 I make (with mariuszw) conversion game Highway Encounter here you are zx spectrum dissassembly: highwayencounter.asm 1 Quote Link to comment Share on other sites More sharing options...
MarcoSantos Posted May 22, 2021 Share Posted May 22, 2021 thank you shanti ! I will check this and learn from it. Quote Link to comment Share on other sites More sharing options...
MarcoSantos Posted May 22, 2021 Share Posted May 22, 2021 Your Sourcecode differs from the original Pentagram. You have a newer Recompiler ? look: 9161 DJNZ @@9 9161 DJNZ @@9 B05A: DJNZ @@2 910E AND 11 B02B: AND A The whitespaces differs between Opcode and Parameters for example... Quote Link to comment Share on other sites More sharing options...
shanti77 Posted May 22, 2021 Share Posted May 22, 2021 I didn't use this tool, I got the target code (for 6502) from @Mariuszw. Talk to him, maybe he will help you. highwayencounter_6502.asm 1 Quote Link to comment Share on other sites More sharing options...
MarcoSantos Posted May 22, 2021 Share Posted May 22, 2021 (edited) thanx Shanti ! did you see that the recompiled code gets twice as big as the original one ? Does your project fit in the atari computer at all ? Edited May 23, 2021 by MarcoSantos Quote Link to comment Share on other sites More sharing options...
Yautja Posted July 3, 2021 Share Posted July 3, 2021 Would it be possible to use the recompiler to port this game? 2 Quote Link to comment Share on other sites More sharing options...
MarcoSantos Posted July 5, 2021 Share Posted July 5, 2021 if you have >128kb RAM for game, write the disk I/O routines for your atari target machine and have a 3-5x faster CPU than in the ZX Spectrum 128k it could work. Quote Link to comment Share on other sites More sharing options...
MarcoSantos Posted July 9, 2021 Share Posted July 9, 2021 if you have >128kb RAM for game, write the disk I/O routines for the target os and have a 3-5x faster CPU than in the ZX Spectrum 128k it could work. Quote Link to comment Share on other sites More sharing options...
Heaven/TQA Posted August 30, 2022 Share Posted August 30, 2022 On 1/6/2016 at 8:39 PM, mariuszw said: Hi, Some people were asking for recompiler I created for preparing Pentagram, so I decided to release it. z80compiler.zip is a compiler. It takes Pentagram disassembly as input and creates 6502 listing ready to be compiled by MADS. Recompiler is very simple, it just takes every single Z80 instruction and just creates equivalent 6502 code from it. Recompiler performs basic code analysis and issues warning, where it thinks code needs to be reviewed and eventually changed. Following checks are done: - usage of A register. Since 6502 uses A to emulate A of Z80 but also uses A to emulate many other instructions, a situation where Z80 instruction reads A register but previous Z80 instruction doesn't write the instruction is detected, as previous 6502 instruction may pollute A - usage of ZERO flag: on Z80, ZERO flag is affected by very few instructions, while no 6502 almost all instructions affect ZERO flag. Warning is issued while Z80 instructions read ZERO flag but previous Z80 instruction does not write it - usage of CARRY flag: check similar to ZERO flag is done. Also, since for CARRY for subtraction and comparison are reverted between Z80 and 6502, but the same for addition, recompiler inverts CARRY checks (because CMP/SBC are more common than ADD) and issues a warning when not CMP/SBC affects CARRY Recompiler does not detect self-modifying code (2 instances in Pentagram). Recompiler also issues a warning for SP (Stack Pointer) manipulation, but cannot compile code which makes tricks with the stack directly (in Pentagram, sprite drawing codes reads directly using stack pointer). Recompiler is not mean to be generic, so not all instructions are compiled. Basically it is prepared to work with Pentagram source only, while it should be expanded quite easily to support other games. It needs Z80 disassembly with code, data and pointers clearly recognized and identified in order to work. The other tool is z80run.zip. It takes binary image of Z80 code and 6502 code, and executes them, logging all accesses (reads and writes) to memory, apart from: - opcode fetching - reading/writing data on zero page on 6502 (ZP registers are used to hold Z80 registers) - stack reading/writing on both Z80 and 6502 Then, all accesses are compared to find errors. This turned out to be very effective tool to debug 6502 code. z80run uses 6502 and Z80 emulators Copyright © Marat Fayzullin. Both projects are written in C++ and compiled in Microsoft Visual Studio 2012. Mariusz. z80run.zip 97.72 kB · 564 downloads z80compiler.zip 11.58 kB · 631 downloads just got interested into it... is there a tool for the other way around probably? Does anybody know one? so my 6502 code to Z80? Quote Link to comment Share on other sites More sharing options...
mariuszw Posted August 30, 2022 Author Share Posted August 30, 2022 5 hours ago, Heaven/TQA said: just got interested into it... is there a tool for the other way around probably? Does anybody know one? so my 6502 code to Z80? Geoff Crammond managed to prepare one - see https://simonowen.com/articles/augmentinel/ Seriously speaking, I haven’t seen anybody preparing such tool. Mariusz 1 Quote Link to comment Share on other sites More sharing options...
ggn Posted August 30, 2022 Share Posted August 30, 2022 You could ask Pete Harrap of Teque to help . Back in the day he could convert a game from one CPU to another at a rate of "say 1300 lines a day at 90% bug free level" (https://www.c64.com/interviews/harrap_part_2.html) Quote Link to comment Share on other sites More sharing options...
Heaven/TQA Posted August 31, 2022 Share Posted August 31, 2022 13 hours ago, ggn said: You could ask Pete Harrap of Teque to help . Back in the day he could convert a game from one CPU to another at a rate of "say 1300 lines a day at 90% bug free level" (https://www.c64.com/interviews/harrap_part_2.html) thx. nice read. Quote Link to comment Share on other sites More sharing options...
johannesmutlu Posted October 7, 2023 Share Posted October 7, 2023 This Z80 to 6502 recompilor sounds really cool on paper,but how good is it? Could you for instance translate a source code from a master system game into a nes game ??? sure you may have to do some manual tweaking and debugging all unsupported features or find some alternative features to get around it,but how smooth and stable could it run? i can imagine that if recompilors already existed in the 1980’s that game developers might have used recompilors to translate one source code from a game from a certain system and recompile to them to other computer languanges with some manual tweaking and debugging to make them run on other systems,another option might be to use a similar game engine from a different game from a target system and adjust and moddify it to port that wanted game to that target platform, Considering how long it already takes to create a source code for a certain game,i just cannot imagine why you would ever want to do all stuff all over and over again for different platform systems if semi automatic convertor tools should already exist right, Sure you also need to take the amount of ram,ram and graphical as well as audio capabilities in mind from each system but there are semi automatic convertfor tools for that as well like shrunking down the resolution and color nut for the target system etc,, and with that in mind i just can’t instance imagine that those supermario advances series and supermariobros dx were rewritten from scratch by hand,why would you do that if it only takes more time and money to do so if semi automatic tool kits already exists,or if you do already have a similar game engine from another game for the target system to your disposal,i just cannot imagine how and why there could be otherwise be sooo many games on the market including ports. Quote Link to comment Share on other sites More sharing options...
+slx Posted October 8, 2023 Share Posted October 8, 2023 Programmers doing conversions in the 80s usually worked without any source code at all. The problem with recompilers is that most 80s home computer and console games only worked by tweaking everything to make optimum use of very limited and very machine-specific system resources. Using a recompilers would bloat the code and thus slow it down and you’d have to adapt it to the target system’s sound and graphics system anyway. When you have code that is tightly written around a specific system’s peculiarities, there isn’t much left to reuse. While not recompiled, some Apple II to Atari (and maybe C64) ports like Choplifter! reused the Apple code and just changed the video output code to work on a similar graphics mode on the target machine. Norbert Kehrer did some working binary code translation to JavaScript but that’s for much faster target machines. 1 Quote Link to comment Share on other sites More sharing options...
tebe Posted October 23, 2023 Share Posted October 23, 2023 (edited) Z80 to Motorola 68000 https://github.com/jotd666/amiga68ktools/blob/master/tools/z80268k.py This is a 1:1 arcade port of the game FROGGER by KONAMI from 1981 for the Amiga 500. The game is written in 68k assembler, based on the original Z80 code. https://rmjoejoe.itch.io/frogger500 p.s. https://www.msx.org/forum/msx-talk/development/z80-6502-recompiler-atariage-forum-seems-inspiring-for-porting-msx-stuff- Edited October 23, 2023 by tebe Quote Link to comment Share on other sites More sharing options...
ggn Posted October 24, 2023 Share Posted October 24, 2023 23 hours ago, tebe said: Z80 to Motorola 68000 https://github.com/jotd666/amiga68ktools/blob/master/tools/z80268k.py Already did that in 2019: http://beyondbrown.mooo.com/post/bugziacs/ 2 Quote Link to comment Share on other sites More sharing options...
+JAC! Posted March 31 Share Posted March 31 Hi @mariuszw and @Wrathchild. Is the version posted above the latest version ? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.