diff --git a/sw/bios/boot2.s b/sw/bios/boot2.s index a9d5482..5f6acf5 100644 --- a/sw/bios/boot2.s +++ b/sw/bios/boot2.s @@ -13,6 +13,14 @@ _start: ldx #>str jsr _cputs -str: .byte "This is a very long message which would otherwise" - .byte "take up a lot of space in the bootsector, where space" - .byte "is at quite a premium.", $00 \ No newline at end of file +str: .byte "This is a very long message which would otherwise " + .byte "take up a lot of space in the bootsector, where space " + .byte "is at quite a premium. In fact, this string is as " + .byte "long as all the rest of the bootloader code, presuming " + .byte "I stretch it out long enough. It is quite remarkable " + .byte "Just how much you can do with so few bytes. Only a couple " + .byte "hundred are required to start up a modern computer. " + .byte "This is, of course, not a modern computer, but I want it " + .byte "to act like it in a way. This means using a modern " + .byte "(well, in the sense that its from 1996 and not 1983)" + .byte "anyway, I've exceeded 512 bytes now so good luck.", $00 \ No newline at end of file diff --git a/sw/bios/bootloader.s b/sw/bios/bootloader.s index 13e1cae..f97acc8 100644 --- a/sw/bios/bootloader.s +++ b/sw/bios/bootloader.s @@ -90,26 +90,70 @@ _main: jsr _cputs - lda #<_cluster - ldx #>_cluster - jsr pushax - ldy #$15 - lda (ptr3),y - tax - dey - lda (ptr3),y - jsr pushax + ldy #$1b lda (ptr3),y tax dey lda (ptr3),y + sec + sbc #$02 ; don't handle carry, assume <256 + ; now a is the cluster num minus 2. We need to multiply this by + ; 8 and add it to 0x77f0 + ; multiply by 8 is asl3 + ldx #$77 + asl + asl + asl + clc + adc #$f0 + bcc @3 + inx +@3: pha + phx + + lda #$00 + sta sreg + lda #$00 + sta sreg+1 + plx + pla + phx + pha + jsr pusheax + lda #buf jsr pushax - ldy #$6 - jsr _cprintf + lda #ptr1 + jsr _SD_readSingleBlock + + lda #$00 + sta sreg + lda #$00 + sta sreg+1 + pla + plx + inc + jsr pusheax + lda #buf + inx + inx + jsr pushax + lda #ptr1 + jsr _SD_readSingleBlock + + + jmp buf + bra @end -; Now we have the cluster number of the bootloader +; Now we have the cluster number of the bootloader (3) +; this means we need to read from address 00ef_e000 + ((3 -2) * 8 * 512) + +; 00eff000 is the address we want, which is efe000 + 4096 @fail: lda #<_fail