Dragon 64 Serial Port

Hardware Hacking, Programming and Game Solutions/Cheats
zephyr
Posts: 1474
Joined: Mon Jul 21, 2008 1:18 am

Dragon 64 Serial Port

Post by zephyr »

Can anyone explain why the following code is needed for the Dragon 64's serial port. Can the serial port be used in 32 mode without the IRQ secondary vector pointing to the start address of this code?

Code: Select all

BF20 F6FF05   LDB   $FF05
BF23 2A0D     BPL   $BF32
BF25 C408     ANDB  #$08
BF27 2708     BEQ   $BF31
BF29 B6FF06   LDA   $FF06
BF2C 84FE     ANDA  #$FE
BF2E B7FF06   STA   $FF06
BF31 3B       RTI
pser1
Posts: 1655
Joined: Sun Mar 25, 2012 7:32 pm
Location: Barcelona (SPAIN)

Re: Dragon 64 Serial Port

Post by pser1 »

Hello zephyr,
I have tried to put a comment to each line according to my rs232 dragon knowledge:
I have never used the serial port with interrupts, this part contains from $BF32 on (just for cases where not an IRQ) a series of code to clear the keyboard rollover table too and finally jumps to $9D3D

Code: Select all

* This is the IRQ-Routine called by ROM2
BF20 F6FF05   LDB   $FF05            this is ACIA Status register. bit4 ($10) equals Transmit Data Register Empty (0=No Empty, 1=Empty). Bit 7 = IRQ (minus sign)
BF23 2A0D     BPL   $BF32            if there is not an IRQ then goes out of here
BF25 C408     ANDB  #$08             to see Receive Data Register (bit3: 0=empty, 1=full)
BF27 2708     BEQ   $BF31            NO data in the buffer
BF29 B6FF06   LDA   $FF06            this is Command register
BF2C 84FE     ANDA  #$FE             mask for Data Terminal Ready (bit0: 0=Disable receiver, 1=Enable Receiver)
BF2E B7FF06   STA   $FF06            set DTR as disabled
BF31 3B       RTI                    end of interrupt
According to SY6551 documentation, these are the bits for the Status register:
0 - Parity Error
1 - Framing Error
2 - Overrun
3 - RECEIVE DATA REGISTER FULL
4 - Transmit Data Register Empty
5 - /DCD
6 - /DSR
7 - IRQ
Hope this could help
pere
zephyr
Posts: 1474
Joined: Mon Jul 21, 2008 1:18 am

Re: Dragon 64 Serial Port

Post by zephyr »

I have known since 1984 exactly how that code works, and what it does. What I still don't know is if/why the code is required for using the serial port.
pser1
Posts: 1655
Joined: Sun Mar 25, 2012 7:32 pm
Location: Barcelona (SPAIN)

Re: Dragon 64 Serial Port

Post by pser1 »

sorry,
I just wrote a lot.
In short: according to a BASIC dissasembly from the book "Das Dragon Lexicon", this code is only called from within the ROM2, the Basic ROM when in mode64, so it should not affect the Dragon in 32 mode.
pere
zephyr
Posts: 1474
Joined: Mon Jul 21, 2008 1:18 am

Re: Dragon 64 Serial Port

Post by zephyr »

pser1 wrote:sorry,
I just wrote a lot.
In short: according to a BASIC dissasembly from the book "Das Dragon Lexicon", this code is only called from within the ROM2, the Basic ROM when in mode64, so it should not affect the Dragon in 32 mode.
pere
That information in that book is wrong (as you can see from the address - $BF20). It is also called from within ROM1 (32K MODE) when you use the keyboard auto-repeat. But why has the code been put in there in the first place? What is it for? Can the serial port be used without that IRQ code being active?
Inside The Dragon wrote: 3. THE KEYBOARD AUTO-REPEAT FACILITY

This facility is provided in the 64K mode only and is
not implemented when the Dragon 64 is operating in 32K
mode. The reason for this is to maintain compatibility
with existing software, such as the DREAM assembler,
which provide their own auto-repeat facilities.

However, it is possible to incorporate this facility into the 32K
mode in the following way:
POKE &HFFO3,(PEEK(&HFFO3 )AND&HFE )
POKE &HlOD,&HBF
POKE &H1OE,&H2O
POKE &HFFO3,(PEEK(&HFFO3)OR1)
zephyr
Posts: 1474
Joined: Mon Jul 21, 2008 1:18 am

Re: Dragon 64 Serial Port

Post by zephyr »

I find it very strange that there doesn't seem to be any information about this routine anywhere on the internet. There is no information about the routine in the Dragon 64 Supplement or the book "Inside The Dragon" (Duncan Smeed and Ian Sommerville).
pser1
Posts: 1655
Joined: Sun Mar 25, 2012 7:32 pm
Location: Barcelona (SPAIN)

Re: Dragon 64 Serial Port

Post by pser1 »

back again,
you are right, if we use the Stephen Woolham enhanced basic rom1, then there is a call to $BF20 at $9FFC, but this code doesn't exist on an original Dragon64, in fact there are only zero values.
So it seems that these bytes are re-used to implement new functionality (I assume)
If this is right, then there should be no reason for using the serial port in 32 mode without interrupts.
I have never used the serial port with interrupts, because I made always programs that worked only to communicate via serial port all the time.
But if anyone wants to do other things, then interrupts are to be used and so this part will be called from $9FFC and if an ACIA IRQ is found, then it would return from interruption where it was first called.
Don't blame me if I am too wrong!
I have seen that the hook at $010C contains a JMP $C700 if disk is on or a simple JMP $9D3D when no disk is on
Inside Disk system the IRQ is used to poll for the motor to stop spinning and then goes to $9D3D as always
So it is just a matter of the code that was added in Stephen's enhancement, I will believe that if this code were converted to NOPs, everything would keep running ok
sorry for extending so much one more time!
pere
zephyr
Posts: 1474
Joined: Mon Jul 21, 2008 1:18 am

Re: Dragon 64 Serial Port

Post by zephyr »

pser1 wrote:back again,
you are right, if we use the Stephen Woolham enhanced basic rom1, then there is a call to $BF20 at $9FFC, but this code doesn't exist on an original Dragon64, in fact there are only zero values.
So it seems that these bytes are re-used to implement new functionality (I assume)
The reason for the extra code at $9FFC is clearly explained in the ReadMe.txt that is included with Steve's Enhanced ROMs.

Pere, Thank you for trying to help with this, but my questions about the code which is present in ALL ORIGINAL Dragon 64 ROMs are not being answered. :)
zephyr wrote: But why has the code been put in there in the first place? What is it for? Can the serial port be used without that IRQ code being active?
pser1
Posts: 1655
Joined: Sun Mar 25, 2012 7:32 pm
Location: Barcelona (SPAIN)

Re: Dragon 64 Serial Port

Post by pser1 »

hello zephyr,
probably I'm wrong, but as far as we have discussed here, the standard Dragon64 Basic ROM will never call this code in 32 mode, so the problem is only related to Stephen Woolham's enhanced version.
Maybe we could ask him what he thinks about your question . . . and please, don't take me wrong I will be very pleased to help in, for sure!
pere
zephyr
Posts: 1474
Joined: Mon Jul 21, 2008 1:18 am

Re: Dragon 64 Serial Port

Post by zephyr »

The code in question is also never called in Steve's Enhanced 32 mode ROM; unless you use the RKEYS command to enable the keyboard auto-repeat. So, as far as this code is concerned, its exactly the same scenario for both standard and enhanced ROMs.
Post Reply