clean up bootloader and consolidate duplicate code

This commit is contained in:
4am 2023-11-17 21:18:51 -05:00
parent 2f206dfc91
commit 60b1f68c9d
7 changed files with 89 additions and 72 deletions

View File

@ -3,32 +3,18 @@
; ;
PrintBranding PrintBranding
ldy #9 ; in: text screen is showing
- lda TOTAL-1,y ; out: Y = 0 (important! some callers rely on this!)
ora #$80
sta $04B7-1,y
dey
bne -
ldy #11 ldy #11
- lda REPLAY-1,y - lda TOTAL-1, y
ora #$80 sta $04B5-1, y
sta $0536-1,y lda REPLAY-1, y
sta $0535-1, y
dey dey
bne - bne -
rts rts
TOTAL TOTAL
!text "T O T A L" !scrxor $80," T O T A L "
REPLAY REPLAY
!text "R E P L A Y" !scrxor $80,"R E P L A Y"
!ifndef RELEASE {
LoadingVersion
!byte 8
!text " build "
LoadingBuild
!word BUILDNUMBER
} else {
LoadingVersion
!byte 12
!text " v5.0.1"
}

View File

@ -7,28 +7,8 @@
; .SYSTEM file is loaded ; .SYSTEM file is loaded
; ;
+READ_ROM_NO_WRITE !src "src/4cade.init.machine.a"
sta PRIMARYCHARSET !src "src/4cade.init.screen.a"
sta CLR80VID
sta STOREOFF
sta READMAINMEM
sta WRITEMAINMEM
jsr ROM_TEXT
jsr ROM_HOME
jsr ROM_NORMAL
jsr ROM_IN0
jsr ROM_PR0
; accommodate uppercase-only machines (64K ][ and ][+ are supported)
lda ROM_MACHINEID
cmp #$A0
beq + ; Spectrum ED
cmp #$06
beq +
lda #$DF
+HIDE_NEXT_2_BYTES
+ lda #$FF
sta zpCharMask
; print text title in same place as graphical title will appear ; print text title in same place as graphical title will appear
jsr PrintBranding jsr PrintBranding
@ -36,6 +16,9 @@
; proboothd duplicates the above code and jumps here, ; proboothd duplicates the above code and jumps here,
; so if you make any changes before this comment, you ; so if you make any changes before this comment, you
; MUST adjust the final JMP in src/proboothd/proboothd.a ; MUST adjust the final JMP in src/proboothd/proboothd.a
!if (* != ProBootEntry) {
!serious "ProBootEntry is wrong, should be ", *
}
jsr Has64K ; check for 64K (required) jsr Has64K ; check for 64K (required)
bcc + bcc +
@ -99,6 +82,17 @@
sta MONOCOLOR ; bit 7=1 disables color sta MONOCOLOR ; bit 7=1 disables color
+ +
; accommodate uppercase-only machines (64K ][ and ][+ are supported)
lda ROM_MACHINEID
cmp #$A0
beq + ; Spectrum ED
cmp #$06
beq +
lda #$DF
+HIDE_NEXT_2_BYTES
+ lda #$FF
sta zpCharMask
; increase text window width so we can print to the edge of the screen without scrolling ; increase text window width so we can print to the edge of the screen without scrolling
inc $21 inc $21
; print version or build number in lower right corner ; print version or build number in lower right corner
@ -288,6 +282,7 @@ FoundMockingboardCallback
jmp ROM_COUT jmp ROM_COUT
!src "src/4cade.branding.a" !src "src/4cade.branding.a"
!src "src/4cade.version.a"
Loading64K Loading64K
!byte 3 !byte 3

15
src/4cade.init.machine.a Normal file
View File

@ -0,0 +1,15 @@
;license:MIT
;(c) 2023 by 4am
;
; initialize machine from a cold boot
; assumes absolutely nothing about machine state
;
; note: this file is included by both the launcher and proboothd
cld
+READ_ROM_NO_WRITE
sta PRIMARYCHARSET
sta CLR80VID
sta STOREOFF
sta READMAINMEM
sta WRITEMAINMEM

14
src/4cade.init.screen.a Normal file
View File

@ -0,0 +1,14 @@
;license:MIT
;(c) 2023 by 4am
;
; initialize and clear screen
; assumes zero page is completely trashed other than |zpCharMask|
; assumes ROM is banked in on entry
;
; note: this file is included by both the launcher and proboothd
jsr ROM_TEXT
jsr ROM_HOME
jsr ROM_NORMAL
jsr ROM_IN0
jsr ROM_PR0

15
src/4cade.version.a Normal file
View File

@ -0,0 +1,15 @@
;license:MIT
;(c) 2023 by 4am
;
!ifndef RELEASE {
LoadingVersion
!byte 8
!text " build "
LoadingBuild
!word BUILDNUMBER
} else {
LoadingVersion
!byte 12
!text " v5.0.1"
}

View File

@ -161,6 +161,7 @@ gKey = $1F01
UILine1 = $1FB0 UILine1 = $1FB0
UILine2 = $1FD8 UILine2 = $1FD8
UI_ToPlay = $1FF7 UI_ToPlay = $1FF7
ProBootEntry = $2025
gValLen = $1F80 gValLen = $1F80
gVal = $1F81 gVal = $1F81

View File

@ -5,6 +5,8 @@
!to "build/proboothd",plain !to "build/proboothd",plain
*=$800 *=$800
!src "src/macros.a"
;zpage usage, arbitrary selection except for the "ProDOS constant" ones ;zpage usage, arbitrary selection except for the "ProDOS constant" ones
command = $42 ;ProDOS constant command = $42 ;ProDOS constant
unit = $43 ;ProDOS constant unit = $43 ;ProDOS constant
@ -25,34 +27,21 @@
txa txa
pha pha
; put machine in a known state, clear screen !src "src/4cade.init.machine.a"
cld lda KBD
bit $c082 cmp #$D3 ; 'S'
sta $c00e beq @s
sta $c00c cmp #$F3 ; 's'
sta $c000
sta $c002
sta $c004
lda $c000
cmp #$d3 ; Press "S" on bootup
bne + bne +
@s
jsr seasons jsr seasons
+ jsr $fb2f +
jsr $fc58 !src "src/4cade.init.screen.a"
jsr $fe84
jsr $fe89
jsr $fe93
; print title ; print text title in same place as graphical title will appear
jsr PrintBranding
ldy #11
- lda TOTAL-1, y
sta $04B6-1, y
lda REPLAY-1, y
sta $0536-1, y
dey
bne -
pla pla
sta unit sta unit
tax tax
@ -151,7 +140,7 @@ blockind ldy $ff
txa txa
bne readfile bne readfile
readdone jmp $2036 readdone jmp ProBootEntry
seekread stx bloklo seekread stx bloklo
sty blokhi sty blokhi
@ -369,10 +358,12 @@ filename
filename_b filename_b
!text "LAUNCHER.SYSTEM" ;your start-up file, file is max 40kb !text "LAUNCHER.SYSTEM" ;your start-up file, file is max 40kb
filename_e filename_e
TOTAL
!byte $A0,$D4,$A0,$CF,$A0,$D4,$A0,$C1,$A0,$CC,$A0 !src "src/4cade.branding.a"
REPLAY
!byte $D2,$A0,$C5,$A0,$D0,$A0,$CC,$A0,$C1,$A0,$D9 !if (* > $9f7) {
!serious "Bootloader is too large"
}
*=$9f8 *=$9f8
!byte $D3,$C1,$CE,$A0,$C9,$CE,$C3,$AE !byte $D3,$C1,$CE,$A0,$C9,$CE,$C3,$AE