It is currently Thu Sep 21, 2017 8:39 am

All times are UTC + 1 hour [ DST ]




Post new topic Reply to topic  [ 17 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: Thu Jan 12, 2006 2:26 am 
Offline
User avatar

Joined: Thu Jan 12, 2006 1:52 am
Posts: 203
Location: Denmark
A while back I got annoyed with the Turbo Assembler embedded in RR and wanted to see if I could exchange it for a macro edition. After some poking around together with Lotus, I came up with the following solution I just thought I'd share with you.


Turbo Macro Pro v1.1 mod for Retro Replay 3.8b

This text describes how to modify the Cyberpunx Retro Replay 3.8b cartridge
software to load a custom assembler when invoking the TASS BASIC command.
More specifically it shows how to replace the Turbo Assembler contained in the
cartridge with Turbo Macro Pro v1.1 from Style (http://turbo.style64.org).

Offsets refer to the Retro Replay 3.8b ROM Image and are also compatible with
the newly available 3.8P patched version by hannenz.


What TASS Does

The code loaded and started when entering TASS in BASIC is located at offset
$800F:
Code:
   Offset  OpCodes    Mnemonics
   ----------------------------
   $800F   4C 28 80   JMP $8028
   ---
   $8028   A9 0B      LDA #$0B
   $802a   8D 11 D0   STA $D011
   $802d   A2 6A      LDX #$6A
   $802f   BD 39 80   LDA $8039,X
   $8032   9D 00 04   STA $0400,X
   $8035   CA         DEX
   $8036   10 F7      BPL $802F
   $8038   60         RTS

This copies the code at offset $8039-$80A2 to memory address $0400 and jumps to
$0400 upon RTS (stack manipulation)

The code copied is:
Code:
   Offset  OpCodes    Mnemonics
   ----------------------------
   $8039   78         SEI
   $803a   A9 37      LDA #$37
   $803c   85 01      STA $01
   $803e   A9 90      LDA #$90
   $8040   85 AF      STA $AF
   $8042   A9 00      LDA #$00
   $8044   85 AE      STA $AE
   $8046   A9 88      LDA #$88    ;RR Bank 5
   $8048   8D 00 DE   STA $DE00
   $804b   A2 04      LDX #$04
   $804d   A0 00      LDY #$00
   $804f   B9 00 81   LDA $8100,Y
   $8052   91 AE      STA ($AE),Y
   $8054   C8         INY
   $8055   D0 F8      BNE $804F
   $8057   EE 18 04   INC $0418
   $805a   E6 AF      INC $AF
   $805c   CA         DEX
   $805d   10 F0      BPL $804F
   $805f   A9 90      LDA #$90    ;RR Bank 6
   $8061   8D 00 DE   STA $DE00
   $8064   A2 1C      LDX #$1C
   $8066   A0 00      LDY #$00
   $8068   B9 00 81   LDA $8100,Y
   $806b   91 AE      STA ($AE),Y
   $806d   C8         INY
   $806e   D0 F8      BNE $8068
   $8070   EE 31 04   INC $0431
   $8073   E6 AF      INC $AF
   $8075   CA         DEX
   $8076   10 F0      BPL $8068
   $8078   A9 98      LDA #$98    ;RR Bank 7
   $807a   8D 00 DE   STA $DE00
   $807d   A2 1C      LDX #$1C
   $807f   A0 00      LDY #$00
   $8081   B9 00 81   LDA $8100,Y
   $8084   91 AE      STA ($AE),Y
   $8086   C8         INY
   $8087   D0 F8      BNE $8081
   $8089   EE 4A 04   INC $044A
   $808c   E6 AF      INC $AF
   $808e   CA         DEX
   $808f   10 F0      BPL $8081
   $8091   A9 0A      LDA #$0A
   $8093   8D 00 DE   STA $DE00
   $8096   A9 37      LDA #$37
   $8098   85 01      STA $01
   $809a   A9 1B      LDA #$1B
   $809c   8D 11 D0   STA $D011
   $809f   58         CLI
   $80a0   4C 00 90   JMP $9000

Upon execution from address $0400 this code copies offsets:
    $A100-$A5FF (RR bank 5) to memory location $9000-$94FF
    $C100-$DDFF (RR bank 6) to memory location $9500-$B1FF
    $E100-$FDFF (RR bank 7) to memory location $B200-$CEFF
Finally it jumps to address $9000 to start TASS


How to Patch It

Turbo Macro Pro v1.1 comes in different versions and takes up a bit more space
than the old Turbo Assembler. The start address is $8000 instead of $9000 and
its end address depends on what version you choose. All current versions can be
contained within $8000-$CAFF though and it seems to store its variables at $CB00
so it should be OK to just modify the above code to copy the new Turbo Macro Pro
into $8000-$CAFF and then jump to $8000.

Fortunately there are still some free pages in the Retro Replay ROM image to
contain the extra code. A couple of these are at offsets $7800 and $B700

So we can place the new Turbo Macro Pro image at the following locations:
    $A100-$A7FF (RR bank 5) destination memory location $8000-$86FF
    $C100-$DDFF (RR bank 6) destination memory location $8700-$A3FF
    $E100-$FDFF (RR bank 7) destination memory location $A400-$C0FF
    $B700-$BDFF (RR bank 5) destination memory location $C100-$C7FF
    $7800-$7AFF (RR bank 3) destination memory location $C800-$CAFF

The following code copies the new data to the new memory location:
Code:
   Address OpCodes    Mnemonics
   ----------------------------
   $0400   78         SEI
   $0401   A9 37      LDA #$37
   $0403   85 01      STA $01
   $0405   A9 80      LDA #$80
   $0407   85 AF      STA $AF
   $0409   A9 00      LDA #$00
   $040b   85 AE      STA $AE
   $040d   A9 88      LDA #$88    ;RR Bank 5
   $040f   8D 00 DE   STA $DE00
   $0412   A2 06      LDX #$06
   $0414   A0 00      LDY #$00
   $0416   B9 00 81   LDA $8100,Y
   $0419   91 AE      STA ($AE),Y
   $041b   C8         INY
   $041c   D0 F8      BNE $0416
   $041e   EE 18 04   INC $0418
   $0421   E6 AF      INC $AF
   $0423   CA         DEX
   $0424   10 F0      BPL $0416
   $0426   A9 90      LDA #$90    ;RR Bank 6
   $0428   8D 00 DE   STA $DE00
   $042b   A2 1C      LDX #$1C
   $042d   A0 00      LDY #$00
   $042f   B9 00 81   LDA $8100,Y
   $0432   91 AE      STA ($AE),Y
   $0434   C8         INY
   $0435   D0 F8      BNE $042F
   $0437   EE 31 04   INC $0431
   $043a   E6 AF      INC $AF
   $043c   CA         DEX
   $043d   10 F0      BPL $042F
   $043f   A9 98      LDA #$98    ;RR Bank 7
   $0441   8D 00 DE   STA $DE00
   $0444   A2 1C      LDX #$1C
   $0446   A0 00      LDY #$00
   $0448   B9 00 81   LDA $8100,Y
   $044b   91 AE      STA ($AE),Y
   $044d   C8         INY
   $044e   D0 F8      BNE $0448
   $0450   EE 4A 04   INC $044A
   $0453   E6 AF      INC $AF
   $0455   CA         DEX
   $0456   10 F0      BPL $0448
   $0458   A9 88      LDA #$88    ;RR Bank 5
   $045a   8D 00 DE   STA $DE00
   $045d   A2 06      LDX #$06
   $045f   A0 00      LDY #$00
   $0461   B9 00 97   LDA $9700,Y
   $0464   91 AE      STA ($AE),Y
   $0466   C8         INY
   $0467   D0 F8      BNE $0461
   $0469   EE 63 04   INC $0463
   $046c   E6 AF      INC $AF
   $046e   CA         DEX
   $046f   10 F0      BPL $0461
   $0471   A9 18      LDA #$18    ;RR Bank 3
   $0473   8D 00 DE   STA $DE00
   $0476   A2 02      LDX #$02
   $0478   A0 00      LDY #$00
   $047a   B9 00 98   LDA $9800,Y
   $047d   91 AE      STA ($AE),Y
   $047f   C8         INY
   $0480   D0 F8      BNE $047A
   $0482   EE 7C 04   INC $047C
   $0485   E6 AF      INC $AF
   $0487   CA         DEX
   $0488   10 F0      BPL $047A
   $048a   A9 0A      LDA #$0A
   $048c   8D 00 DE   STA $DE00
   $048f   A9 37      LDA #$37
   $0491   85 01      STA $01
   $0493   A9 1B      LDA #$1B
   $0495   8D 11 D0   STA $D011
   $0498   58         CLI
   $0499   4C 00 80   JMP $8000

Note: The code is self-modifying and is here shown at its correct origin.

This new code takes up a bit more space than the old one so we cannot just
overwrite the old with the new. Instead we can place it somewhere else in the
same RR bank. Offset $8121 fulfills our requirements.

The code that copies the above code into address $0400 now needs to be changed
as well. This is located at offset $8028. The new code looks like this:
Code:
   Offset  OpCodes    Mnemonics
   ----------------------------
   $8028   A9 0B      LDA #$0B
   $802a   8D 11 D0   STA $D011
   $802d   A2 00      LDX #$00
   $802f   BD 21 81   LDA $8121,X   ;New location
   $8032   9D 00 04   STA $0400,X
   $8035   E8         INX
   $8036   D0 F7      BNE $802F
   $8038   60         RTS


Now all we need is to split the Turbo Macro Pro into 5 pieces. Use your favorite
HEX Editor like this:
    Part1: Take offset $0000-$06FF from TMP and put in $A100-$A7FF in RR ROM
    Part2: Take offset $0700-$23FF from TMP and put in $C100-$DDFF in RR ROM
    Part3: Take offset $2400-$40FF from TMP and put in $E100-$FDFF in RR ROM
    Part4: Take offset $4100-$47FF from TMP and put in $B700-$BDFF in RR ROM
    Part5: Take offset $4800-$4DFF from TMP and put in $7800-$7AFF in RR ROM


Changing the Default Colors of TMP 1.1

In the event you whish to customize the default colors for TMP 1.1, they are
located in the TMP binary at offset $0015 ($A115 in your newly patched ROM).
The order of the colors is: Border, Screen, Command Line, Status Line, Text,
Error Text, Marked Text.



Happy modding,
Devia/Ancients


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Thu Jan 12, 2006 7:57 am 
Offline

Joined: Thu Jan 12, 2006 1:37 am
Posts: 47
Can someone patch this in the NTSC version and compile it as a .bin for flashing? I suck at coding.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Thu Jan 12, 2006 9:12 am 
boy, that's great!!! I ever dreamed of having the TMP integrated in RR-ROM. I'll try immediately!
thanx a lot for this great info!
i start loving this board! it was a great idea to start this forum!


Top
  
Reply with quote  
 Post subject:
PostPosted: Thu Jan 12, 2006 10:20 am 
Offline

Joined: Thu Jan 12, 2006 9:04 am
Posts: 116
Location: Germany / 88471
tried it with TMP+REU/Style. It rocks!!! Great!


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Thu Jan 12, 2006 10:56 am 
Offline
Site Admin

Joined: Wed Jan 11, 2006 12:22 pm
Posts: 860
Big ups to Devia for this great Article!

Also, if you are hacking ROMs, please share the finished images for our less experienced members to enjoy :)

Keep it up!


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Thu Jan 12, 2006 11:47 am 
Offline
User avatar

Joined: Thu Jan 12, 2006 1:52 am
Posts: 203
Location: Denmark
Well.. the reason for not supplying any patched ROM binaries is because there're a lot of different versions of TMP and some people migth then start asking for ROMs with other versions in them.
I guess one could write a patcher for it tho.. so people could choose whatever they wanted put in the ROM.

I could upload the 3.8P ROM with the plain version of TMP if you guys want that?

I'm a PAL user and honestly don't give NTSC much thought ;-) ..is there an actual NTSC version of the RR ROM? I mean is it different from the PAL one?
If so, please upload that one here and I'll happily supply TMP patched versions of them both if that's what you guys want?

oh and thnx for the feedback btw ;-)

/Devia


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Thu Jan 12, 2006 12:07 pm 
Offline

Joined: Thu Jan 12, 2006 1:23 am
Posts: 6
Good work!

Perhaps Style are willing to create a special Retro Replay version of Turbo Macro Pro. It really is the best Turbo Assembler out there, and I think people without a REU would like the ability to backup the source code in the Retro Replay 32 kb RAM.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Thu Jan 12, 2006 1:27 pm 
Offline

Joined: Thu Jan 12, 2006 9:04 am
Posts: 116
Location: Germany / 88471
as far as i know the +REU mods of TMP backup almost the whole RAM ($08800-$FFFF), so the RAM-Contents before exiting TMP can easily be restored from the REU. So, to backup only the SRC in 32K would afford another concept.
But the idea is good! (Luckily i _have_ a REU...)
One should tell the guys at Style if they are interested in developping for the RR.

Oh, and yes: TMP is the far best assembler ever seen on C64!!


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Thu Jan 12, 2006 4:14 pm 
Offline

Joined: Thu Jan 12, 2006 10:10 am
Posts: 177
MMC64 could also be used for RAM backup. Accessing pre-allocated 64 KB file with 8.3 name in root dir is dead easy and doesn't take too much code.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Thu Jan 12, 2006 4:48 pm 
Offline

Joined: Thu Jan 12, 2006 3:13 pm
Posts: 12
Location: Hack'n'Trade
I suggested this to some involved Style-member a while ago, and if I remember correctly he said that he didn't own a RetroReplay.

...and by the way: If someone patches a rr38b rom with TMP+REU (and do not remove the SSGET-functionality or something like that) then please upload. :)


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Mon Jun 26, 2006 11:13 pm 
Offline

Joined: Thu Jan 12, 2006 9:04 am
Posts: 116
Location: Germany / 88471
i'll upload the RR38P-PAL+TMPREU in the upload section!
sorry for the late reply, just re-read this thread...


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Fri Oct 13, 2006 12:02 am 
Offline
User avatar

Joined: Thu Jan 12, 2006 1:52 am
Posts: 203
Location: Denmark
I just uploaded a 3.8P ROM including the newly released Turbo Macro Pro 1.2 along with an updated .txt version of this howto.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Fri Oct 13, 2006 8:32 pm 
Offline
Site Admin

Joined: Wed Jan 11, 2006 12:22 pm
Posts: 860
Cool! Don't forget to add a comment in the News section :D


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue Nov 13, 2007 10:50 am 
Offline

Joined: Tue May 29, 2007 1:28 pm
Posts: 2
Hello,

i want to change another TASS version for my RR ROM. I've checked your current RR+Turbo Macro Pro v1.2.BIN, it works - but i need for my work another TASS version in ROM.

..so i tried to understand what you are doing, but i don't know right what i have to do in detail:

First, i wan't to know how you patch it:
do you have used a real C64 with RR or do you have used a disassembler on PC and reassembled with new changes?

First i'd tried to reassemble RRRom3.8p on PC:
Ok i got my asm code from bin, but i can't reassemble back, because it's too much size...(acme tolds me that)
.. besides i really don't know, which code i've to put in which lines.

I would be glad, if you can give me a bit help, so that i can go further fo it step for step...

I'm really interessted to patch but i stagnated in some details..

Greets Rio.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Wed Nov 14, 2007 2:59 pm 
Offline
User avatar

Joined: Thu Jan 12, 2006 1:52 am
Posts: 203
Location: Denmark
The relevant code snippets were found and "disassembled" on the C64 using the Retro Replay ROM monitor. Then I simply wrote my own replacement code, assembled them to the correct addresses using some random assembler and patched them into the ROM file using a simple HEX editor.

So, the "How to do it"-spun version of this article would look something like this:

1. Assemble the following code and strip the eventual 2 byte load address from the resulting PRG file:
Code:
   *=$0400
start
   SEI
   LDA #$37
   STA $01
   LDA #$80      ;Destination start address hi
   STA $AF
   LDA #$00      ;Destination start address lo
   STA $AE
   LDA #$88      ;RR Bank 5
   STA $DE00
   LDX #$06
   LDY #$00
.re01            ;Part1
   LDA $8100,Y   ;Copy ROM file offset $A100-$A7FF
   STA ($AE),Y
   INY
   BNE .re01
   INC .re01+2
   INC $AF
   DEX
   BPL .re01
   LDA #$90      ;RR Bank 6
   STA $DE00
   LDX #$1C
   LDY #$00
.re02            ;Part2
   LDA $8100,Y   ;Copy ROM file offset $C100-$DDFF
   STA ($AE),Y
   INY
   BNE .re02
   INC .re02+2
   INC $AF
   DEX
   BPL .re02
   LDA #$98      ;RR Bank 7
   STA $DE00
   LDX #$1C
   LDY #$00
.re03            ;Part3
   LDA $8100,Y   ;Copy ROM file offset $E100-$FDFF
   STA ($AE),Y
   INY
   BNE .re03
   INC .re03+2
   INC $AF
   DEX
   BPL .re03
   
   LDA #$88      ;RR Bank 5
   STA $DE00
   LDX #$06
   LDY #$00
.re04            ;Part4
   LDA $9700,Y   ;Copy ROM file offset $B700-$BDFF
   STA ($AE),Y
   INY
   BNE .re04
   INC .re04+2
   INC $AF
   DEX
   BPL .re04
   
   LDA #$18      ;RR Bank 3
   STA $DE00
   LDX #$02
   LDY #$00
.re05            ;Part5
   LDA $9800,Y   ;Copy ROM file offset $7800-$7AFF
   STA ($AE),Y
   INY
   BNE .re05
   INC .re05+2
   INC $AF
   DEX
   BPL .re05
   
   LDA #$0A
   STA $DE00
   LDA #$37
   STA $01
   LDA #$1B
   STA $D011
   CLI
   JMP $8000      ;Jump to $8000 - duh!

2. Place the result in the RR ROM file at offset $8121 - If you modify this code, make sure the result does not take up more than 223 bytes of space. To modify it to match your own TASS version you might need to read and understand the code in order to change it to suit your needs.

3. Assemble the following code and strip the eventual 2 byte load address from the resulting PRG file:
Code:
   *=$1234 ;irrellevant
start
   lda   #$0b
   sta   $d011
   ldx   #$00
.re01
   lda   $8121,x
   sta   $0400,x
   inx
   bne   .re01
   rts

4. Place the result in the RR ROM file at offset $8028 - This code may not take up more than 17 bytes!!! - but you should not have any need to modify it in this case. (This is the code that copies the previous code to $0400 and executes it)

5. Strip any eventual load address from your TASS binary and split it up into separate files of sizes matching the "holes" in the ROM you're going to place them in. The "holes" in the ROM file that I use in the above code are at the following file offsets:

Part1 - $A100-$A7FF - 1792 bytes
Part2 - $C100-$DDFF - 7424 bytes
Part3 - $E100-$FDFF - 7424 bytes
Part4 - $B700-$BDFF - 1792 bytes
Part5 - $7800-$7AFF - 768 bytes

A total of 19200 bytes - if you need more, you'll have to find the free space yourself ;-)


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 17 posts ]  Go to page 1, 2  Next

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group