Loading another BASIC in RAM (MAP1)

Hardware Hacking, Programming and Game Solutions/Cheats
Post Reply
pser1
Posts: 1655
Joined: Sun Mar 25, 2012 7:32 pm
Location: Barcelona (SPAIN)

Loading another BASIC in RAM (MAP1)

Post by pser1 »

hello,
I wanted to make some tests in a real Dragon but using the last updated enhanced version of BASIC (S.Woolham's 3.1 exp 6)
Despite changing the D.O.S is easy, just copy it and JMP $C002, all atempts with the new Basic copied at $8000 in MAP1 have failed
I have tried JMP $B3B4, JMP $B44F without success.
I used a Bas and a BIN program
This is the Basic program

Code: Select all

110 PCLEAR1
120 CLEAR50,&H17FF
130 LOAD"MBUP1.BIN",&H1800
140 LOAD"D64316R.BIN",&H2000
150 LOAD"DDOS11C.BIN",&H6000
160 EXEC&H1800
and one of the tried bins (dream-like)

Code: Select all

       ORG   $1800
       PUT   $1800
*
       ORCC  #$50
       STA   $FFDF
       LDX   #$2000
       LDU   #$8000
LOOP1  LDD   ,X++
       STD   ,U++
       CMPX  #$7FFF
       BLO   LOOP1
       JMP   $B3B4
*
Anyone has ever tried this with best luck?
I would welcome your advices
thanks in advance
best wishes
pere
zephyr
Posts: 1474
Joined: Mon Jul 21, 2008 1:18 am

Re: Loading another BASIC in RAM (MAP1)

Post by zephyr »

Try the following code.

Code: Select all

      ORG      $1800
      PUT      $1800
*
      ORCC     #$50
      STA      $FFDF
      LDX      #$2000
      LDU      #$8000
LOOP1 LDD      ,X++
      STD      ,U++
      CMPX     #$7FFF
      BLO      LOOP1
      LDA      #$0E
      STA      $BB72
      LDX      #$B3CA
      LDD      #$120C
LOOP2 STA      ,X+
      DECB
      BNE      LOOP2
      LDA      #$8E
      STA      ,X+
      LDD      #$7FFE
      STD      ,X
      CLR      <$71
      JMP      $B3B4
pser1
Posts: 1655
Joined: Sun Mar 25, 2012 7:32 pm
Location: Barcelona (SPAIN)

Re: Loading another BASIC in RAM (MAP1)

Post by pser1 »

I did it as fast as possible, and of course it works alright :D
I have no words to thank this helpful solution!!
I will try to understand it tomorrow ...
as always, you are very kind, Steve
regards
pere
User avatar
tormod
Posts: 416
Joined: Sat Apr 27, 2013 12:06 pm
Location: Switzerland
Contact:

Re: Loading another BASIC in RAM (MAP1)

Post by tormod »

To those who are not satisfied with black magic: Writing #$0E to $BB72 prevents the BASIC hardware initialisation routine from resetting all registers of the SAM, which otherwise would reset it back to ROM mode. At $B3CA is the probing for end of RAM, which is here being replaced with 12 x NOP and a LDX #$7FFF.
pser1
Posts: 1655
Joined: Sun Mar 25, 2012 7:32 pm
Location: Barcelona (SPAIN)

Re: Loading another BASIC in RAM (MAP1)

Post by pser1 »

hello tormod,
thanks a lot for the explanation.
I knew about $B3CA because I used it, after an Steve's advice to go back to ROM mode from RAM where another different D.O.S. had been installed.
But I didn't know that trick on $BB72.
On enhanced Basic, this change produces JMP <$A7 to the charget routine, but in my standard Basic it produces JMP <$26 wich shows garbage on the screen and hangs the computer. Maybe in this version I should change $BB73 to $A7 as well, shouldn't I?
regards
pere
zephyr
Posts: 1474
Joined: Mon Jul 21, 2008 1:18 am

Re: Loading another BASIC in RAM (MAP1)

Post by zephyr »

pser1 wrote: I will try to understand it tomorrow ...
pser1 wrote: I knew about $B3CA because I used it, after an Steve's advice to go back to ROM mode from RAM where another different D.O.S. had been installed.
But I didn't know that trick on $BB72.
On enhanced Basic, this change produces JMP <$A7 to the charget routine, but in my standard Basic it produces JMP <$26 wich shows garbage on the screen and hangs the computer. Maybe in this version I should change $BB73 to $A7 as well, shouldn't I?

This part of the routine patches part of the hardware init routine to prevent it doing a STA $FFDE.

Code: Select all

          LDA      #$0E
          STA      $BB72
Standard HW init code.

Code: Select all

BB6E 8EFFC0   LDX   #$FFC0
BB71 C610     LDB   #$10
BB73 A781     STA   ,X++
BB75 5A       DECB
BB76 26FB     BNE   $BB73
Patched HW init code.

Code: Select all

BB6E 8EFFC0   LDX   #$FFC0
BB71 C60E     LDB   #$0E
BB73 A781     STA   ,X++
BB75 5A       DECB
BB76 26FB     BNE   $BB73

This part of the routine patches out the RAM count routine with NOPs and a LDX #$7FFE to prevent the BASIC ROM in RAM code from being overwritten.

Code: Select all

          LDX      #$B3CA
          LDD      #$120C
    LOOP2 STA      ,X+
          DECB
          BNE      LOOP2
          LDA      #$8E
          STA      ,X+
          LDD      #$7FFE
          STD      ,X
Standard code with RAM test.

Code: Select all

B3C3 BDBA77   JSR   $BA77
B3C6 6F80     CLR   ,X+
B3C8 9F19     STX   <$19
B3CA A602     LDA   2,X
B3CC 43       COMA
B3CD A702     STA   2,X
B3CF A102     CMPA  2,X
B3D1 2606     BNE   $B3D9
B3D3 3001     LEAX  1,X
B3D5 6301     COM   1,X
B3D7 20F1     BRA   $B3CA
B3D9 9F74     STX   <$74
Patched code.

Code: Select all

 B3C3 BDBA77   JSR   $BA77
 B3C6 6F80     CLR   ,X+
 B3C8 9F19     STX   <$19
 B3CA 12       NOP
 B3CB 12       NOP
 B3CC 12       NOP
 B3CD 12       NOP
 B3CE 12       NOP
 B3CF 12       NOP
 B3D0 12       NOP
 B3D1 12       NOP
 B3D2 12       NOP
 B3D3 12       NOP
 B3D4 12       NOP
 B3D5 12       NOP
 B3D6 8E7FFE   LDX   #$7FFE
 B3D9 9F74     STX   <$74
Last edited by zephyr on Sat Jun 07, 2014 11:21 am, edited 4 times in total.
User avatar
tormod
Posts: 416
Joined: Sat Apr 27, 2013 12:06 pm
Location: Switzerland
Contact:

Re: Loading another BASIC in RAM (MAP1)

Post by tormod »

pser1 wrote:hello tormod,
thanks a lot for the explanation.
I knew about $B3CA because I used it, after an Steve's advice to go back to ROM mode from RAM where another different D.O.S. had been installed.
But I didn't know that trick on $BB72.
On enhanced Basic, this change produces JMP <$A7 to the charget routine, but in my standard Basic it produces JMP <$26 wich shows garbage on the screen and hangs the computer. Maybe in this version I should change $BB73 to $A7 as well, shouldn't I?
regards
pere
Not sure I follow you there. There is no JMP instruction at $BB71, but LDB #$10. This change makes it LDB #$0E instead, and B is the loop counter for resetting registers from $FFC0 and on, so it will stop at $FFDC and won't touch $FFDE. Maybe the Woolham's enhanced BASIC has other code at this location, but I don't know anything about that. What is your "standard BASIC"?
zephyr
Posts: 1474
Joined: Mon Jul 21, 2008 1:18 am

Re: Loading another BASIC in RAM (MAP1)

Post by zephyr »

tormod wrote:Maybe the Woolham's enhanced BASIC has other code at this location, but I don't know anything about that.
Its exactly the same code.
pser1
Posts: 1655
Joined: Sun Mar 25, 2012 7:32 pm
Location: Barcelona (SPAIN)

Re: Loading another BASIC in RAM (MAP1)

Post by pser1 »

yep! you both are right :oops:
When talking about Basic, I use to read the book: Das Dragon Lexikon and there is ... the Dragon 32 Basic ROM.
At the end of the book there are the Dragon 64 differences and this is an affected area. :(
Just to show you what has fooled me, this is the D32 code I first saw:

Code: Select all

>U $BB65,$BB79
BB65 6F84       CLR   ,X
BB67 6F02       CLR   2,X
BB69 A602       LDA   2,X
BB6B 8EFFC0     LDX   #$FFC0
BB6E C610       LDB   #$10
BB70 A781       STA   ,X++
BB72 5A         DECB
BB73 26FB       BNE   $BB70
BB75 F7FFC9     STB   $FFC9
BB78 8504       BITA  #$04
I am sorry, my friends ...
Thanks a lot for every explanation you have given about this point.
regards
pere
pser1
Posts: 1655
Joined: Sun Mar 25, 2012 7:32 pm
Location: Barcelona (SPAIN)

Re: Loading another BASIC in RAM (MAP1)

Post by pser1 »

well, once (Steve) solved the problems I had to test a different basic in a real Dragon64, just to see the enhancements added by Steve Woolham, I thought it could be of interest for people that has not a lot of time but would like to test these versions so that they could decide if it is worth burning some Eproms.
I have made a little basic program that let's the user choose between three BASIC versions and three DOS versions, then it does:
Load them to RAM and put them at their right place after changing to MAP1.
You could add as many versions as you need, in both parts (Basic - DOS)
Attached is a zip containing the basic loader and the binary in CAS and WAV formats, besides I have added the basic in text format and the binary in DRM format, there is also a VDK disk image.
Special thanks to Steve Evans for his help!
regards
pere
Attachments
_Testing Basic & DOS for D64.zip
Testing enhanced ROMS on a real Dragon 64
(56.86 KiB) Downloaded 290 times
Post Reply