; ; Disk PRG Bootloader ROM v1.0 ; ; Compile with: ; cl65 -t none -o boot.prg boot.asm .FEATURE STRING_ESCAPES ; ; I/O Page Addresses ; CONS_IO = $FF00 DISK_ADDR_L = $FF01 DISK_ADDR_H = $FF02 DISK_VAL = $FF03 DISK_STAT = $FF04 ; Zero-Page Variables START_L = $20 ; Start address low START_H = $21 ; Start address high CURR_L = $22 ; Current write address low CURR_H = $23 ; Current write address high .WORD $FF40 .ORG $FF40 ; Setup & Print Boot Text RESET: CLD ; Clear decimal mode CLI ; Clear interrupt disable LDX #STRLEN-1 ; Load starting string index print: LDA s_waiting,X ; Get char from string STA CONS_IO ; Put char to screen DEX ; Decrement index BPL print ; Continue until X < 0 wait: LDA DISK_STAT ; Read disk status BEQ wait ; Repeat until disk status is not zero LDA #$00 ; Set disk head to start STA DISK_ADDR_L STA DISK_ADDR_H ; Loading From Disk r_addr: LDA DISK_VAL ; Read start address low byte STA START_L STA CURR_L INC DISK_ADDR_L ; Increment Disk LDA DISK_VAL ; Read start address high byte STA START_H STA CURR_H INC DISK_ADDR_L ; Increment Disk LDY #$00 ; Set Y to 0 read: LDA DISK_VAL ; Read byte from disk STA (CURR_L),Y ; Write to current position INC CURR_L ; 16-Bit Increment write pointer BNE disk_inc INC CURR_H disk_inc: INC DISK_ADDR_L ; 16-Bit Increment disk address BNE loop INC CURR_H loop: LDA DISK_STAT ; Check if we've reached the end of the disk AND #%00000010 ; Mask EOF bit BEQ read ; Loop if not at the end ; Boot loaded code boot: LDA #$FF ; Send clear-screen to console STA CONS_IO JMP (START_L) ; Jump to new code ; String reversed for slightly more compact storage/printing ;s_waiting: .BYTE "# PRG BOOTLOADER V1.0 #\nWaiting for Disk..." s_waiting: .BYTE "...ksiD rof gnitiaW\n# 0.1V REDAOLTOOB GRP #" STRLEN = 44