; BITSY.BOOT ; Created: 2023-09-07 02:57:20 ; ; Stock BITSY.BOOT doesn't reliably work on my Franklin. ; ; Because the open-Apple key is wired into the game port, machines without ; that key will falsely report that O-A is pressed when RDBTN0 is read. That ; effectively prevents booting from any slot, as O-A was tested first and ; thus branches to the GS/OS exit logic. ; ; Re-ordering the command key logic so that valid slot boot attempts are ; processed before O-A is tested results in a working BITSY.BOOT. While I ; was there, I eliminated redundancy and use MACHID to skip the O-A check on ; machines that don't have it (][, ][+, and clones thereof) ; ; This doesn't fix all cases -- MACHID doesn't distinguish between a //e with ; clock card and a IIgs, so hitting O-A/Q on that //e will crash the machine. ; So it goes. ; ; -- Chris RYU, 07 September 2023 .macpack apple2 .setcpu "6502" .org $2000 MLI_ENTRY := $BF00 DEVNUM := $BF30 DEVCNT := $BF31 DEVLST := $BF32 MACHID := $BF98 KBD := $C000 CLR80VID := $C00C KBDSTRB := $C010 RDBTN0 := $C061 LCBANK1 := $C08B INIT := $FB2F BASCALC := $FBC1 ROM_BELL := $FBDD HOME := $FC58 RDKEY := $FD0C SETKBD := $FE89 SETVID := $FE93 sta CLR80VID sta KBD jsr SETVID jsr SETKBD jsr INIT jsr GET_SLOT and #$07 ora #$B0 sta BOOT_SLOT ; set up active slot display in splash screen data ldy DEVCNT ; count (-1) of active devices L201C: lda DEVLST,y beq L2036 php lsr a lsr a lsr a and #$0E tax lsr a ora #$B0 ; convert to screen code plp bmi L2033 sta D1_LIST,x bne L2036 L2033: sta D2_LIST,x L2036: dey bpl L201C ; display splash screen jsr HOME ldx #(END_SPLASH - SPLASH_SCREEN) L203E: lda SPLASH_SCREEN-1,x bmi L204A jsr BASCALC ldy SPLASH_SCREEN,x .byte $2C ; hide next opcode via BIT L204A: sta ($28),y dey dex bne L203E L2050: sta $0400,y sta ($28),y dey bpl L2050 ldx #$15 L205A: txa jsr BASCALC ldy #20 lda #$A1 ; screencode for "!" sta ($28),y dex bne L205A lda #$10 sta $29 sta KBDSTRB ; clear keyboard strobe bne MAIN_LOOP ; branch-always to MAIN_LOOP ; get keypress and process MAIN_LOOP_WITH_BEEP: jsr ROM_BELL MAIN_LOOP: jsr RDKEY cmp #$9B ; ESC? beq DO_MLI_BOOT cmp #$8D ; CR? beq BOOT_RECENT cmp #$A0 ; space? beq BOOT_RECENT cmp #$B8 ; >= 8? bcs GSOS_QUIT cmp #$B1 ; >= 1? bcs SET_SLOT_AND_BOOT GSOS_QUIT: ldx MACHID cpx #$b3 ; IIgs (or //e with clock card) bne MAIN_LOOP_WITH_BEEP bit RDBTN0 ; safe to check O-A now bpl MAIN_LOOP and #$DF cmp #$D1 ; Q? (GS/OS only) bne MAIN_LOOP_WITH_BEEP ; 65816 GS/OS gunk here ... .setcpu "65816" rep #$80 ; reset processor status bits bmi MAIN_LOOP_WITH_BEEP lda $E100BD ; OS_BOOT (byte) dec bne MAIN_LOOP_WITH_BEEP clc xce ; swap carry and emulation flags (clear E) lda LCBANK1 ; rw:LCBANK1 jmp $E0D000 .setcpu "6502" BOOT_RECENT: jsr GET_SLOT SET_SLOT_AND_BOOT: and #$07 ; mask to get raw slot number beq MAIN_LOOP ; if zero, restart ora #$C0 ; this becomes $C100-$C700 sta BOOTVEC+2 ; and put it into boot vector DO_MLI_BOOT: jsr HOME BOOTVEC: jsr MLI_ENTRY ; but overwritten to slot entry point .byte $65 .word * + 2 .byte $04 ; it's apparently okay to have garbage for $65 ; get last-accessed slot GET_SLOT: lda DEVNUM lsr a lsr a lsr a lsr a rts SPLASH_SCREEN: scrcode "-" .byte $16, $29 scrcode "BITSY BOOT" .byte $04, $23 scrcode "1.0a" .byte $15, $28 scrcode "BY" .byte $09, $1f scrcode "JOHN" .byte $0f, $20 scrcode "BROOKS" .byte $12 .byte "!" scrcode "ACTIVE SLOTS" D1_LIST: .byte $04, $10 scrcode ". . . . . . ." D2_LIST: .byte $08, $10 scrcode ". . . . . . ." .byte $0a, $10 scrcode "1-7:" scrcode "BOOT A SLOT" .byte $0f, $11 scrcode "RET:BOOT SLOT " BOOT_SLOT: scrcode "N" .byte $12, $11 scrcode "ESC:QUIT TO PRODOS" .byte $17, $12 scrcode "OA-Q:QUIT TO GS/OS" .byte $17, $28 END_SPLASH = *