; ; **** Note **** to use this code you need to patch the floating point rom ; ;============================= ;Floating Point Patch (#Dxxx): ;============================= ; ;Original Patch ;------------------------- ------------------------- ;D4AF: Ad 04 E0 LDA #E004 D4AF: AD 20 EB LDA #EB20 ;D4B2: C9 BF CMP @#BF D4B2: C9 40 CMP @#40 ;D4B4: F0 0A BEQ #D4C0 D4B4: F0 0A BEQ #D4C0 ;D4B6: AD 00 A0 LDA #A000 D4B6: AD 01 A0 LDA #A001 ;D4B9: C9 40 CMP @#40 D4B9: C9 BF CMP @#BF ;D4BB: D0 83 BNE #D440 D4BB: D0 83 BNE #D440 ;D4BD: 4C 01 A0 JMP #A002 D4BD: 4C 02 A0 JMP #A002 ;D4C0: 4C 05 E0 JMP #E005 D4C3: 4C 22 EB JMP #EB22 ; *** Options *** LATCH = $BFFF SHADOW = $FD ; If $BFFF is write only otherwise SHADOW =$BFFF MAX = $8 ZPBASE = $90 ZPLENGTH = $10 ; *** Workarea *** BASE = $400 BRKLOW = BASE BRKHIGH = BRKLOW+1 BRKROM = BRKHIGH+1 STARTROM = BRKROM+1 TEMP = STARTROM+1 VECTOR = TEMP DUMP = TEMP+1 VECT = MAX*ZPLENGTH VECTAB = VECT+DUMP+1 SUB_ACCU = VECTAB+1+15*3 SUB_STATUS = SUB_ACCU+1 SUB_Y = SUB_STATUS+1 SUB_X = SUB_Y+1 STACKPOINTER = SUB_X SUBVECTOR = SUB_X+1 INTVECTOR = SUBVECTOR+2 INT_ACCU = INTVECTOR+2 INT_STATUS1 = INT_ACCU+1 INT_STATUS2 = INT_STATUS1+1 INT_X = INT_STATUS2+1 INT_Y = INT_X+1 OPT_PCHARME = INT_Y+1 FREE = OPT_PCHARME+1 ; *** Constants *** BRKVEC = $202 TEXT = $F7D1 CR = $D LF = $A DELIM = $EA .SEGMENT "BRAN" ; *** Start of assembly *** .BYTE $40,$bf ; ROM entry ; *** Entry in system *** ENTRY: LDA 6 ; Test directmode CMP #1 BNE LABEL8 BIT $B001 ; Test SHIFT BMI LABEL8 LDX #0 ; Test RETURN LDA (5,X) CMP #CR BNE LABEL8 JMP UNLOCK+3 ; If SHIFT-RETURN, unlock ROMs LABEL8: BIT SHADOW ; ROM locked? BVC NOT_LOCKED JMP LOCKED ; *** Not locked search *** NOT_LOCKED: LDA SHADOW ; Save current ROM nr STA STARTROM JSR UPDATE_VECTORS ; Save current vectors JSR SWITCH_CONTEXT_OUT ; Store zeropage LDA BRKVEC+1 ; Check if breakvector is changed CMP #>HANDLER BEQ LABEL1 ; If not, change it STA BRKHIGH LDA BRKVEC STA BRKLOW LDA SHADOW ; Save lastrom STA BRKROM LABEL1: JMP SWITCH ; *** Try next box *** NEXT_BOX: INC SHADOW ; Switch to next ROM LDA SHADOW STA LATCH CMP #MAX ; If last reached, switch to ROM 0 BNE LABEL2 LDA #0 STA SHADOW STA LATCH LABEL2: JSR SWITCH_CONTEXT_IN ; Restore zeropage LDA SHADOW ; Check if all ROMs entered CMP STARTROM BNE SWITCH JMP NOT_FOUND ; Command not found in ROMs, try table ; *** Replace break vector and enter ROM *** SWITCH: LDA #>HANDLER ; Replace breakvector STA BRKVEC+1 LDA #(SWITCH_BACK-1) STA $100,X LDA #<(SWITCH_BACK-1) DEX STA $100,X NOT_INSTALL: JSR SWITCH_CONTEXT_OUT ; Store zeropage JSR UPDATE_VECTORS ; Save vectors LDA BRKROM ; Set start ROM nr STA SHADOW STA LATCH JSR SWITCH_CONTEXT_IN ; Restore zeropage ; *** Terminate search *** LDA 0 ; Get LB return address PHA ; Push on stack LDA TEMP ; Get HB return address PHA ; Push on stack JMP (BRKVEC) ; Return ; *** ERROR with ROM locked *** LOCKED_ERROR: LDA SHADOW ; Set start ROM nr STA BRKROM LDA 0 ; Get ERROR nr CMP #94 ; ERROR 94? BEQ LABEL3 JMP NOT_ERROR_94 LABEL3: LDX #$FF ; Reset stackpointer TXS JMP NOT_FOUND ; Command not found in ROMs, try table ; *** Store zeropage (always #91-#98) *** SWITCH_CONTEXT_OUT: LDA SHADOW ; Get ROM nr AND #$F ; Filter to 0-15 TAX INX LDA #0 LABEL4: CLC ; DUMP pointer = ROMnr * ZPLENGTH-1 ADC #ZPLENGTH DEX BNE LABEL4 LDX #(ZPLENGTH-1) ; Set ZPBASE pointer TAY DEY LABEL5: LDA ZPBASE,X ; Save zeropage STA DUMP,Y DEY DEX BPL LABEL5 RTS ; *** Restore zeropage (always #91-#98) *** SWITCH_CONTEXT_IN: LDA SHADOW ; Get ROM nr AND #$F ; Filter to 0-15 TAX INX LDA #0 LABEL6: CLC ; DUMP pointer = ROMnr * ZPLENGTH-1 ADC #ZPLENGTH DEX BNE LABEL6 LDX #(ZPLENGTH-1) ; Set ZPBASE pointer TAY DEY LABEL7: LDA DUMP,Y ; Restore zeropage STA ZPBASE,X DEY DEX BPL LABEL7 RTS ; *** Start search locked *** LOCKED: LDA BRKVEC+1 ; Check if break handler switched CMP #>HANDLER BEQ LABEL21 STA BRKHIGH ; If not, save break handler LDA BRKVEC STA BRKLOW LDA #>HANDLER ; Replace break handler STA BRKVEC+1 LDA #ROM,UNLOCK,VECENTRY ADC #0 STA $201,X LABEL31: INX ; Point to next vector INX INY INY INY CPX #$1C ; Check end of vectors BNE LABEL30 LDA $3FF ; Check if plot vector points at #Axxx (SCREEN ROM) AND #$F0 CMP #$A0 BNE LABEL32 LDA $3FF ; Save plot vector STA VECTAB,Y LDA $3FE STA VECTAB+1,Y LDA #>(VECENTRY+14*8) ; Replace plot vector STA $3FF LDA #<(VECENTRY+14*8) STA $3FE LDA SHADOW ; Save ROM nr STA VECTAB+2,Y LABEL32: PLP RTS ; *** Entry vector pathways *** VECENTRY: JSR ISAVE ; $200, NMI vector LDX #0 JMP IJOB NOP ; $202, BRK vector NOP NOP NOP NOP JMP $C558 JSR ISAVE ; $204, IRQ vector LDX #6 JMP IJOB JSR SAVE ; $206, *COM vector LDX #9 JMP JOB JSR SAVE ; $208, Write vector LDX #12 JMP JOB JSR SAVE ; $20A, Read vector LDX #15 JMP JOB JSR SAVE ; $20C, Load vector LDX #18 JMP JOB JSR SAVE ; $20E, Save vector LDX #21 JMP JOB JSR SAVE ; $210, vector LDX #24 JMP JOB JSR SAVE ; $212, vector LDX #27 JMP JOB JSR SAVE ; $214, Get byte vector LDX #30 JMP JOB JSR SAVE ; $216, Put byte vector LDX #33 JMP JOB JSR SAVE ; $218, Print message vector LDX #36 JMP JOB JSR SAVE ; $21A, Shut vector LDX #39 JMP JOB JSR SAVE ; $3FF, Plot vector LDX #42 JMP JOB ; *** Save normal processor/registers *** SAVE: PHP ; Save processor status STA SUB_ACCU ; Save accu PLA STA SUB_STATUS ; Save status STX SUB_X ; Save X-reg STY SUB_Y ; Save Y-reg RTS ; *** Save interrupt processor/registers *** ISAVE: PHP ; Save processor status STA INT_ACCU ; Save accu PLA STA INT_STATUS1 ; Save status STX INT_X ; Save X-reg STY INT_Y ; Save Y-reg RTS ; *** Reset normal processor/registers *** LOAD: LDY SUB_Y ; Reset Y-reg LDX SUB_X ; Reset X-reg LDA SUB_STATUS ; Reset status PHA LDA SUB_ACCU ; Reset accu PLP ; Reset processor status RTS ; *** Reset interrupt processor/registers *** ILOAD: LDX INT_X ; Reset Y-reg LDY INT_Y ; Reset X-reg LDA INT_STATUS1 ; Reset status PHA LDA INT_ACCU ; Reset accu PLP ; Reset processor status RTS ; *** Interrupt switching pathway *** IJOB: PLA STA INT_ACCU PLA PHA STA INT_STATUS2 LDA SHADOW ; Save ROM nr PHA LDA VECTAB+2,X ; Reset ROM nr STA SHADOW STA LATCH LDA VECTAB,X ; Reset NMI/IRQ vector STA INTVECTOR+1 LDA VECTAB+1,X STA INTVECTOR LDA #>IENTRY ; Replace NMI/IRQ vector PHA LDA #HANDLER ; Reinit break handler STA BRKVEC+1 LDA #