TS2068 ROM Bugs

See all articles from QZX v9 n6
Author(s): Alex Burr (K5XY)
Publication: QZX
Pub Details: QZX v9 n6 (Volume 9, Issue 6)
Date: May 1991
Pages: 3-7

6.5.2 GET_STATUS- Returns invalid memory selection status for the Home Bank, ROM Extension and Dock. This results in switching out of either the Home Bank or the Dock when status is “restored”. This affects use of the Function Dispatcher and GET_WORD routines, and any other code using GET_STATUS. Figure 6.5-1 shows the patches and additions necessary to correct this routine.

6.5.3 PUT_WORD- Write data passed in Reg. Pair DE is overwritten prior to use. Figure 6.5-2 shows corrections.

6.5.4 BANK_ENABLE and RESTORE_STATUS-

If the 17 ms. interruption occurs during update of the memory selection hardware, it can cause the system to hang and RAM to be overwritten. This occurs when the interruption happens in an interval when Port FF Bit 7 is zero (thus selecting the Dock Bank) and Port F4 Bit 0 is one (thus enabling Chunk 0 in the Dock Bank) and there is no memory in Chunk 0 of the Dock Bank. This can be true when there is no cartridge installed, or if the cartridge installed is an AROS. This problem is corrected by disabling or masking the interruption while updating the memory selection hardware. Figure 6.5-3 shows one implementation of this correction.

6.5.5 SAVE_STATUS and RESTORE_STATUS – The value of Port FFH which includes video mode and interruption inhibit as well as Ext. ROM/Dock Select is saved and restored as a full 8-bits. Therefore any modification of this port by code accessed between execution of SAVE_STATUS and subsequent execution of RESTORE_STATUS (e.g. via CALL_BANK or use of the Function Dispatcher) is “undone”. This is one reason the Video Mode Change Service and some of the bank switching routines such as BANK_ENABLE cannot be meaningfully accessed via the Function Dispatcher.

6.5.6 CALL_BANK- Does not correctly retrieve the stack entry designating the count of parameters being passed. Memory is overwritten in the case where this count is not zero. This is corrected by setting Location 6610H = 9 (POKE 26128,9). You only need to apply the correction once; it will be duplicated in Chunk 7 if the code is relocated.

FIGURE 6.5-1 GET_STATUS CORRECTIONS

  LOCATION  OBJ.CODE  SOURCE STATEMENT                COMMENTS
(HEX) (HEX)

Input: Bank # in B

Output: Bank # in B (Bank Status if Exp.Bank)
Memory Selection in C
(Low Active Format)

6405 F5 GET_STATUS PUSH AF Save Regs.
6406 D5 PUSH DE
6407 78 LD A,B Get Bank #
6408 FEFE CP 0FEH Test if Ext.(254)
* 640A 2824 JR Z,GS_EXT
640C FEFF CP 0FFH Test if Home(255)
* 640E 2837 JR Z,GS_HOME
6410 A7 AND A Test if Dock (0)
* 6411 2827 JR Z,GS_DOCK
6413 . .
. . . (Code for Expansion Banks
. . . not applicable)
. . .
. . .
* 6430 0EFF GS_EXT LD C,0FFH Assume none
* 6432 DBFF IN A,(0FFH) Test if selected
* 6434 E680 AND 80H
* 6436 2812 JR Z,GS_XT1 Not active
* 6438 1808 JR GETHS Get Hor.Select
* 643A 0EFF GS_DOCK LD C,0FFH Assume none
* 643C DBFF IN A,(0FFH) Test if selected
* 643E E680 AND 80H
* 6440 2008 JR NZ,GS_XT1 Not active
* 6442 DBF4 GETHS IN A,(0F4H) Get Hor.Select Reg.
* 6444 2F CPL Invert to Low Active
* 6445 1802 JR GS_XT0 Exit
* 6447 DBF4 GS_HOME IN A,0F4H All bits set are not
active in Home Bank
* 6449 4F GS_XT0 LD C,A Memory Select to C
644A D1 GS_XT1 POP DE Restore Regs.
644B F1 POP AF
644C C9 RET Return

The asterisks mark the locations modified. See next page for list of corresponding POKE’s for BASIC.

FIGURE 6.5-1 GET_STATUS CORRECTIONS (continued)

From BASIC:

POKE  25610,40     (Location 640AH)
POKE 25611,36
POKE 25614,40 (Location 640EH)
POKE 25615,55
POKE 25617,40 (Location 6411H)
POKE 25618,39
POKE 25648,14 (Location 6430H)
POKE 25649,255
POKE 25650,219
POKE 25651,255
POKE 25652,230
POKE 25653,128
POKE 25654,40
POKE 25655,18
POKE 25656,24
POKE 25657,8
POKE 25658,14
POKE 25659,255
POKE 25660,219
POKE 25661,255
POKE 25662,230
POKE 25663,128
POKE 25664,32
POKE 25665,8
POKE 25666,219
POKE 25667,244
POKE 25668,47
POKE 25669,24
POKE 25670,2
POKE 25671,219
POKE 25672,244
POKE 25673,79

FIGURE 6.5-2 PUT_WORD CORRECTIONS

  LOCATION  OBJ.CODE  SOURCE STATEMENT                COMMENTS
(HEX) (HEX)

Input: Data in DE, Address in HL, Bank # in B

633B F5 PUT_WORD PUSH AF Save Regs.
633C C5 PUSH BC
633D CD5E64 CALL GET_NUMBER Bank # of Owner
* 6340 D5 PUSH DE Save Data
6341 50 LD D,B Save Target Bank #
6342 47 LD B,A Bank # of Owner
6343 CD0564 CALL GET_STATUS Get Bank Status
6346 C5 PUSH BC Save It
6347 CD4D64 CALL GET_CHUNK Get Bit Map
634A 2F CPL Set High Active
634B 42 LD B,D Target Bank # to B
634C 4F LD C,A Memory Select Byte
634D CD9964 CALL BANK_ENABLE Enbl.Target Mem.
* 6350 C1 POP BC Saved Bank Status
* 6351 D1 POP DE Saved Data
* 6352 73 LD (HL),E Write LSB
* 6353 23 INC HL Increment Adrs.
* 6354 72 LD (HL),D Write MSB
* 6355 2B DEC HL Restore HL
6356 CD9964 CALL BANK_ENABLE Restore Bank St.
6359 C1 POP BC Restore Regs.
635A F1 POP AF
635B C9 RET Return

The asterisks mark the locations modified.

From BASIC:

POKE 25408,213
POKE 25424,193
POKE 25425,209
POKE 25426,115
POKE 25427,35
POKE 25428,114
POKE 25429,43

NOTE: The corrections to GET_STATUS and BANK_ENABLE are also required.

FIGURE 6.5-3 BANK_ENABLE AND RESTORE_STATUS CORRECTIONS

                                                 From BASIC
BANK_ENABLE:     Location    Object Code     POKE Address   Value

                 6499H        00    NOP         25753          0
                 649DH        F3    DI          25757        243
                 651CH        FB    EI          25884        251

RESTORE_STATUS:

                 654AH        F3    DI          25930        243
                 6570H        FB    EI          25968        251

In both cases, the Disable Interrupt and Enable Interrupt are being done by deleting the preservation of the AF Registers (PUSH AF/POP AF). If your code requires AF to be saved, you must do it prior to calling either of these routines or any other system routines that use them. Note also that if you already have the interruption masked when these routines are entered, it will be enabled when they are exitted. If this proves to be a problem, replace the Enable Interruption (EI) instruction with a NOP and do the enable at a more appropriate place in your own code.

Source: TS2068 Technical Manual