User Tools

Site Tools


commodore:tapes:loaders:bleepload

This is an old revision of the document!


Bleepload F1

  • Mastering tool: Not found
  • Loader A.K.A.: Bleepload
  • Available mastering program versions: None
  • Threshold variants used/configurable: 1/Unknown
  • Mastering tool discovered by: Not discovered yet
  • Loader disassembled from: Bubble Bobble

Disassembled loader

loader.asm
; From: Bubble Bobble
; Note: Assemble with 64tass
 
; ***************
; * CBM Data #1 *
; ***************
 
*=$02A7
START   LDA #$0E      
        STA $D021     ; VIC-II Background Color 0
 
        LDA #$40      
        JSR $FF90     ; SETMSG: set Kernal message control flag
 
        LDA #$01      
        TAX           
        TAY           
        JSR $FFBA     ; SETLFS: set logical file parameters
 
        LDA #$00      
        JSR $FFBD     ; SETNAM: set filename parameters
 
        JSR $FFD5     ; LOAD  : load from a device (via $0330)
 
        LDA #$93      ; {CLR+HOME}
        JSR $FFD2     ; CHROUT: output a character (via $0326)
 
        LDX #$00      
        STX $D021     ; VIC-II Background Color 0
 
        LDA #$01      
        STA $D900,X   
        INX           
        BNE *-4       
 
        JMP $1C00     ; Execute code in the second CBM file
 
        .cerror * > $0300, "The CBM Data #1 code is too long to fit in front of the BASIC vector table!"
 
; --------------------------------
 
; Overwrite BASIC vectors in RAM for autostarting
 
        .align $0300, $00 ; Padding
 
        .word $E38B ; Leave IERROR unchanged
        .word START ; Autostart the turbo loader, once loaded, by overwriting IMAIN
 
 
 
; ***************
; * CBM Data #2 *
; ***************
 
*=$1C00
        SEI           
 
        LDA #<B1D12   ; Point the BRK vector
        STA $0316     
        LDA #>B1D12   
        STA $0317     
 
        LDA #<$FEC1   ; Point the NMI vector to an RTI instruction
        STA $0318     
        LDA #>$FEC1   
        STA $0319     
 
        LDA $01       
        AND #$DE      ; Turn datassette motor on, BASIC ROM out
        STA $01       
 
        LDA #$02      
        STA $DD05     ; CIA #2 Timer A (MSB)
        LDA #$32      
        STA $DD04     ; CIA #2 Timer A (LSB)
 
        LDA #$19      
        STA $DD0E     ; CIA #2 Control Register A
        LDA #$7F      
        STA $DC0D     ; CIA #1 Interrupt Control Register
 
        LDA #$91      ; Enable Timer A and flag line interrupts
        STA $DC0D     ; CIA #1 Interrupt Control Register
 
        LDY #$00      
        STY $AF       
        STY $AB       ; Block number starts at 0
 
        LDA #$0F      
        STA $A3       ; Initial pilot byte
 
        JSR S1C9A     
 
J1C41   LDY $AA       
        LDA ($A8),Y   
        STA $AC       
        INY           
        LDA ($A8),Y   
        STA $AD       
 
        JSR S1D31     ; Sync with the stream
        JSR S1D5A     ; Read and store block header
 
        LDA $A5       ; Block number being read
        CMP $AB       ; Expected block number
        BEQ *+8       ; Branch if they match
 
        JSR S1CA8     ; Missed block
        JMP J1C41     ; Retry
 
        JSR S1CC3     ; Reset message to "LOADING"
        JSR S1D7A     ; Load block data
        BEQ *+8       ; Success
 
        JSR S1CA8     ; Load error
        JMP J1C41     ; Retry
 
        LDA $A4       
        STA $A3       ; Next pilot byte
        INC $AB       ; Expected block number++
 
        INC $D020     ; Signal block complete
 
        JSR S1DA6     ; Read byte (execution address LSB)
        STA $AC       
        JSR S1DA6     ; Read byte (execution address MSB)
        STA $AD       
 
        JMP ($00AC)   
 
; --------------------------------
 
; Print hex number in A at offset Y
 
J1C82   PHA           
        LSR           
        LSR           
        LSR           
        LSR           
        JSR S1C8E     ; Do high nybble
        PLA           
        INY           ; Do low nybble
        AND #$0F      
S1C8E   ORA #$30      
        CMP #$3A      
        BCC *+4       
        SBC #$39      
        STA $059E,Y   
        RTS           
 
; --------------------------------
 
S1C9A   LDX #$00      ; Point to "SEARCHING"
        LDY #$50      ; Set offset for two lines below
        JSR B1CD3     ; Print string
 
        LDA $AB       ; Expected block number
        LDY #$5A      
        JMP J1C82     ; Print hex number in A at offset Y
 
; --------------------------------
 
S1CA8   LDX #$12      ; Point to "BLOCK"
        LDY #$00      ; Set offset
        JSR B1CD3     ; Print string
 
        LDA $A5       ; Block number being read
        CMP $AB       ; Expected block number
        BCC S1C9A     
 
        LDX #$1A      ; Point to "REWIND"
        LDY #$50      ; Set offset for two lines below
        JSR B1CD3     ; Print string
 
        LDA $AB       
        LDY #$5A      
        JMP J1C82     ; Print hex number in A at offset Y
 
; --------------------------------
 
; Reset message to "LOADING"
 
S1CC3   LDY #$50      
        LDA #$20      
        STA $059E,Y   
        INY           
        CPY #$5C      
        BNE *-6       
 
        LDX #$0A      ; Point to "LOADING"
        LDY #$00      ; Set offset
 
; Fall through the print string subroutine
 
; --------------------------------
 
; Print string
 
B1CD3   LDA T1DD1,X   
        STA $059E,Y   
        INY           
        INX           
        CMP #$20      ; End at the first occurrence of 0x20
        BNE B1CD3     
        RTS           
 
; --------------------------------
 
; IRQ #1
 
V1CE0   SEI           
 
        JSR S1D15     ; Read bit
 
        LDA $BD       
        CMP $A3       ; First occurrence of the pilot byte?
        BNE B1D12     ; Return from IRQ
 
        LDA #$01      
        STA $BD       
 
        LDA #<V1CFB   ; Attach IRQ #2
        STA $0314     
        LDA #>V1CFB   
        STA $0315     
 
        JMP B1D12     ; Return from IRQ
 
; --------------------------------
 
; IRQ #2
 
V1CFB   SEI           
 
        JSR S1D15     ; Read bit
 
        BCC B1D12     ; Return from IRQ
 
        LDY $72       
        LDA $BD       
        STA $033C,Y   
        LDA #$01      
        STA $BD       
        INY           
        TYA           
        AND #$1F      
        STA $72       
 
B1D12   JMP $FEBC     ; Return from IRQ
 
; --------------------------------
 
; Read bit
;
; Returns: the read bit in the Carry flag
;          partial byte (MSbF) in $BD
 
S1D15   LDA $DC0D     ; CIA #1 Interrupt Control Register
        PHA           
        AND #$01      
        ORA $AF       
        STA $AF       
        PLA           
        CLC           
        AND #$10      
        BEQ B1D30     
        LDA #$19      
        STA $DD0E     ; CIA #2 Control Register A
        LDA $DD0D     ; CIA #2 Interrupt Control Register
        LSR           
        ROL $BD       
B1D30   RTS           
 
; --------------------------------
 
; Read pilot train and 2 sync bytes (pilot byte XOR 0xFF, pilot byte again)
 
S1D31   SEI           
 
        LDA #$00      
        STA $72       
        STA $71       
        STA $BD       
 
        LDA #<V1CE0   
        STA $0314     
        LDA #>V1CE0   
        STA $0315     
 
        CLI           
 
        JSR S1DA6     ; Read byte
        CMP $A3       ; Is it another pilot byte?
        BEQ *-5       ; Loop until a non pilot byte is read
 
        EOR #$FF      
        CMP $A3       ; Is it pilot byte XOR 0xFF?
        BNE S1D31     ; Start over if not
 
        JSR S1DA6     ; Read byte
        CMP $A3       ; Is it a pilot byte again?
        BNE S1D31     ; Start over if not
 
        RTS           
 
; --------------------------------
 
; Read and store block header
;
; Header structure:
; 1 byte : next pilot value
; 1 byte : block number
; 2 bytes: load address
 
S1D5A   LDY #$00      
        STY $A8       
B1D5E   JSR S1DA6     ; Read byte
        STA $00A4,Y   
        INY           
        CPY #$04      
        BNE B1D5E     
 
        PLA           ; Save return address from the stack
        STA $AC       
        PLA           
        STA $A9       
        PHA           
        LDA $AC       
        PHA           
 
        LDA $A5       ; Block number being read
        LDY #$0A      
        JMP J1C82     ; Print hex number in A at offset Y
 
; --------------------------------
 
; Load block data
;
; Returns: Z=1 success
 
S1D7A   LDY #$00      
        STY $AA       ; Zero XOR checkbyte
        STY $AE       ; Prepare to receive 256 bytes
 
        LDA $A5       ; However, if the block being read is #0
        BNE B1D88     
        LDA #$40      ; Prepare to receive 64 bytes instead
        STA $AE       
 
B1D88   JSR S1DA6     ; Read byte
        STA ($A6),Y   
        EOR $AA       ; Update XOR checkbyte
        STA $AA       
        INY           
        CPY $AE       ; End of block yet?
        BNE B1D88     
 
        JSR S1DA6     ; Read byte (post-data count)
        TAY           
        JSR S1DA6     ; Read byte (post-data)
        DEY           
        BNE *-4       
 
        JSR S1DA6     ; Read byte (XOR checkbyte)
        CMP $AA       ; Compare with calculated value
 
        RTS           
 
; --------------------------------
 
; Read byte
 
S1DA6   STY $B0       ; Backup Y
 
B1DA8   LDA $0312     
        CMP #$B2      
        BEQ B1DBA     
 
        LDA $AF       
        BEQ B1DBA     
 
        LDA #$00      
        STA $AF       
        JSR S1DCE     
 
B1DBA   LDX $71       
        CPX $72       
        BEQ B1DA8     
 
        LDA $033C,X   
        PHA           
        INX           
        TXA           
        AND #$1F      
        STA $71       
        PLA           
 
        LDY $B0       ; Restore Y
        RTS           
 
; --------------------------------
 
S1DCE   JMP ($0311)   
 
; --------------------------------
 
; Space-terminated strings
 
.enc screen
 
T1DD1   .text "SEARCHING " ; Offset = 0x00
 
        .text "LOADING "   ; Offset = 0x0A
 
        .text "BLOCK"      ; Offset = 0x12
        .byte $60,$3F
        .text " "
 
        .text "REWIND"     ; Offset = 0x1A
        .byte $60
        .text "TO "
 
.enc none
 
; --------------------------------
 
; Leftovers
 
        .byte $49,$00,$04,$1E,$28,$0F,$4A,$53,$52,$20,$A1
commodore/tapes/loaders/bleepload.1538515179.txt.gz · Last modified: 2018/10/02 23:19 by Luigi Di Fraia