ProDOS-8 / ProDOS8-Testing

QA and Testing for ProDOS-8 Releases
MIT License
29 stars 1 forks source link

Apple II/II+ reports 80-columns for any slot 3 ROM #75

Open xotmatrix opened 1 month ago

xotmatrix commented 1 month ago

Description

When an Apple II/II+ has a card with ROM in slot 3, it always sets the 80-column bit of MACHID.

Expected Behavior

If a terminal card is not identified in slot 3 of an Apple II/II+, the 80-column bit of MACHID should be cleared.

Actual Behavior

If there is any card with ROM in slot 3 of an Apple II/II+, the 80-column bit of MACHID is set. While ProDOS does not identify the card as a terminal card, the Aux RAM test that follows convinces ProDOS that an 80-column mode is available.

Possible Fix

If the MACHID indicates an Apple II/II+, the Aux RAM test should be skipped or qualified. However, could this be an issue for the VidHD? Does it pass the terminal card identification test? Or does it rely on passing the Aux RAM test?

Steps to Reproduce

Place any card with ROM in slot 3 of an Apple II+ and boot ProDOS 2.4.3. Check MACHID ($BF98) and observe that it is $62 instead of the expected $60 when the card is not an 80-column card.

This is the relevant section of code in ProDOS 2.4.3:

; PROLDR.S
isromin3:
;*
;* we've seen a rom in slot 3. is it an external, identifiable
;* 80-col card with interrupt routines? if so, enable it. if not,
;* switch in the internal $c300 firmware.
;*
    2208 : 8D 0B C0 : STA $C00B  SETC3ROM       ;switch in slot 3 rom
    220B : AD 05 C3 : LDA $C305                 ;1st generic terminal card id byte
    220E : C9 38    : CMP #$38                  
    2210 : D0 23    : BNE $2235  hitswtch       ;branch if not a terminal card.
    2212 : AD 07 C3 : LDA $C307                 ;2nd generic terminal card id byte
    2215 : C9 18    : CMP #$18                  
    2217 : D0 1C    : BNE $2235  hitswtch       ;branch if not a terminal card.
    2219 : AD 0B C3 : LDA $C30B                 ;3rd generic terminal card id byte
    221C : C9 01    : CMP #$01                  
    221E : D0 15    : BNE $2235  hitswtch       ;branch if not a terminal card.
    2220 : AD 0C C3 : LDA $C30C                 ;is it an apple 80-col card compatible?
    2223 : 29 F0    : AND #$F0                  ;mask off lo nibble
    2225 : C9 80    : CMP #$80                  ; and check for $8n
    2227 : D0 0C    : BNE $2235  hitswtch       ;branch if not an 80-col card.
    2229 : AD 98 BF : LDA $BF98  machid         ;get the machine id
    222C : 10 34    : BPL $2262  docard         ;branch if II/II+
    222E : AD FA C3 : LDA $C3FA                 ;check for interrupt handler routine
    2231 : C9 2C    : CMP #$2C                  ; in the magic $c3fa spot.
    2233 : F0 2D    : BEQ $2262  docard         ;branch if interrupt handler is there!
hitswtch:
;*
;* verify that the card in the aux slot is actually there.
;*
    2235 : 8D 0A C0 : STA $C00A  CLRC3ROM       ;internal $c300 rom
    2238 : 8D 01 C0 : STA $C001  SET80STOR      ;80-store
    223B : 8D 55 C0 : STA $C055  SETPAGE2       ;page2
    223E : A9 EE    : LDA #$EE                  
    2240 : 8D 78 04 : STA $0478                 
    2243 : 0A       : ASL A                     
    2244 : 0E 78 04 : ASL $0478                 
    2247 : CD 78 04 : CMP $0478                 
    224A : D0 07    : BNE $2253  maybe          ;branch if not there     
    224C : 4A       : LSR A                     
    224D : 4E 78 04 : LSR $0478                 
    2250 : CD 78 04 : CMP $0478                 
maybe:
    2253 : 8D 54 C0 : STA $C054  CLRPAGE2       ;main memory
    2256 : 8D 00 C0 : STA $C000  CLR80STOR      ;80-store off
    2259 : F0 07    : BEQ $2262  docard         ;branch if card is there
    225B : AD 98 BF : LDA $BF98                 ;get machine id byte
    225E : 29 FD    : AND #$FD                  ;mask off 80-col bit
    2260 : D0 05    : BNE $2267  docard1        ;always..
;*
;* ok, the card's good. leave it enabled and update the machid.
;*
docard:
    2262 : AD 98 BF : LDA $BF98                 ;get machine id byte
    2265 : 09 02    : ORA #$02                  ;turn bit 2 on to show 80-col card
docard1:
    2267 : 8D 98 BF : STA $BF98                 

This is the execution of the code. It appears to ProDOS that Aux RAM exists in an Apple II/II+ and it asserts the 80-column bit of MACHID.

;*
;* execution
;*
isromin3:
    2208 : 8D 0B C0 : STA $C00B     ; (4 cyc) A:08 X:FA Y:40 P:25 nv-bdIzC S:E1  
    220B : AD 05 C3 : LDA $C305     ; (4 cyc) A:03 X:FA Y:40 P:25 nv-bdIzC S:E1  
    220E : C9 38    : CMP #$38      ; (2 cyc) A:03 X:FA Y:40 P:A4 Nv-bdIzc S:E1      
    2210 : D0 23    : BNE $2235     ; (3 cyc) A:03 X:FA Y:40 P:A4 Nv-bdIzc S:E1  
hitswtch:
    2235 : 8D 0A C0 : STA $C00A     ; (4 cyc) A:03 X:FA Y:40 P:A4 Nv-bdIzc S:E1  
    2238 : 8D 01 C0 : STA $C001     ; (4 cyc) A:03 X:FA Y:40 P:A4 Nv-bdIzc S:E1  
    223B : 8D 55 C0 : STA $C055     ; (4 cyc) A:03 X:FA Y:40 P:A4 Nv-bdIzc S:E1  
    223E : A9 EE    : LDA #$EE      ; (2 cyc) A:EE X:FA Y:40 P:A4 Nv-bdIzc S:E1      
    2240 : 8D 78 04 : STA $0478     ; (4 cyc) A:EE X:FA Y:40 P:A4 Nv-bdIzc S:E1  
    2243 : 0A       : ASL A         ; (2 cyc) A:DC X:FA Y:40 P:A5 Nv-bdIzC S:E1  
    2244 : 0E 78 04 : ASL $0478     ; (6 cyc) A:DC X:FA Y:40 P:A5 Nv-bdIzC S:E1  
    2247 : CD 78 04 : CMP $0478     ; (4 cyc) A:DC X:FA Y:40 P:27 nv-bdIZC S:E1  
    224A : D0 07    : BNE $2253     ; (2 cyc) A:DC X:FA Y:40 P:27 nv-bdIZC S:E1  
    224C : 4A       : LSR A         ; (2 cyc) A:6E X:FA Y:40 P:24 nv-bdIzc S:E1  
    224D : 4E 78 04 : LSR $0478     ; (6 cyc) A:6E X:FA Y:40 P:24 nv-bdIzc S:E1  
    2250 : CD 78 04 : CMP $0478     ; (4 cyc) A:6E X:FA Y:40 P:27 nv-bdIZC S:E1  
    2253 : 8D 54 C0 : STA $C054     ; (4 cyc) A:6E X:FA Y:40 P:27 nv-bdIZC S:E1  
    2256 : 8D 00 C0 : STA $C000     ; (4 cyc) A:6E X:FA Y:40 P:27 nv-bdIZC S:E1  
    2259 : F0 07    : BEQ $2262     ; (3 cyc) A:6E X:FA Y:40 P:27 nv-bdIZC S:E1  
docard:
    2262 : AD 98 BF : LDA $BF98     ; (4 cyc) A:60 X:FA Y:40 P:25 nv-bdIzC S:E1  
    2265 : 09 02    : ORA #$02      ; (2 cyc) A:62 X:FA Y:40 P:25 nv-bdIzC S:E1      
docard1:
    2267 : 8D 98 BF : STA $BF98     ; (4 cyc) A:62 X:FA Y:40 P:25 nv-bdIzC S:E1  

Context

The initial MACHID 80-column reporting bug was discovered by Oliver Schmidt through AppleWin's emulated Uthernet II card. I produced the same bug with AppleWin's emulated VidHD card. I found and fixed the bug in AppleWin's Uthernet II emulation that exposed the problem. I confirmed the MACHID bug in another emulator with a Disk II FDC in slot 3. I later confirmed it in a real Apple II+ with a Super Serial Card in slot 3. AppleWin's VidHD issues are complicated and beyond the scope of this report.

Your Environment

Hardware:

  1. AppleWin 1.30.19 emulating an Apple II+ with either an Uthernet II or a VidHD installed in slot 3.
  2. Personal emulator emulating an Apple II+ with a Disk II FDC in slot 3.
  3. Real Apple II+ with Super Serial Card in slot 3.

ProDOS8 version:

P8 2.4.3

Non-Operating System release software being used:

xotmatrix commented 1 month ago

Original AppleWin bug report: https://github.com/AppleWin/AppleWin/issues/1321