mirror of
https://github.com/a2-4am/4sports.git
synced 2024-12-27 16:31:21 +00:00
clean up bootloader and consolidate duplicate code
This commit is contained in:
parent
1778382119
commit
d27658d23f
@ -3,41 +3,22 @@
|
|||||||
;
|
;
|
||||||
|
|
||||||
PrintBranding
|
PrintBranding
|
||||||
ldy #14
|
; in: text screen is showing
|
||||||
- lda II,y
|
; out: Y = 0 (important! some callers rely on this!)
|
||||||
ora #$80
|
ldy #15
|
||||||
+FORCE_UPPERCASE_IF_REQUIRED
|
- lda II-1, y
|
||||||
sta $070C,y
|
sta $070C-1, y
|
||||||
|
lda INSTANT-1, y
|
||||||
|
sta $04B4-1, y
|
||||||
|
lda REPLAY-1, y
|
||||||
|
sta $0534-1, y
|
||||||
dey
|
dey
|
||||||
bpl -
|
bne -
|
||||||
ldy #12
|
|
||||||
- lda INSTANT,y
|
|
||||||
ora #$80
|
|
||||||
sta $04B5,y
|
|
||||||
dey
|
|
||||||
bpl -
|
|
||||||
ldy #10
|
|
||||||
- lda REPLAY,y
|
|
||||||
ora #$80
|
|
||||||
sta $0536,y
|
|
||||||
dey
|
|
||||||
bpl -
|
|
||||||
rts
|
rts
|
||||||
|
|
||||||
II
|
II
|
||||||
!text "Total Replay II"
|
!scrxor $80,"TOTAL REPLAY II"
|
||||||
INSTANT
|
INSTANT
|
||||||
!text "I N S T A N T"
|
!scrxor $80," I N S T A N T "
|
||||||
REPLAY
|
REPLAY
|
||||||
!text "R E P L A Y"
|
!scrxor $80," R E P L A Y "
|
||||||
!ifndef RELEASE {
|
|
||||||
LoadingVersion
|
|
||||||
!byte 9
|
|
||||||
!text " build 0"
|
|
||||||
LoadingBuild
|
|
||||||
!word BUILDNUMBER
|
|
||||||
} else {
|
|
||||||
LoadingVersion
|
|
||||||
!byte 12
|
|
||||||
!text "v1.0-alpha.3"
|
|
||||||
}
|
|
||||||
|
@ -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
15
src/4cade.init.machine.a
Normal 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
14
src/4cade.init.screen.a
Normal 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
15
src/4cade.version.a
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
;license:MIT
|
||||||
|
;(c) 2023 by 4am
|
||||||
|
;
|
||||||
|
|
||||||
|
!ifndef RELEASE {
|
||||||
|
LoadingVersion
|
||||||
|
!byte 9
|
||||||
|
!text " build 0"
|
||||||
|
LoadingBuild
|
||||||
|
!word BUILDNUMBER
|
||||||
|
} else {
|
||||||
|
LoadingVersion
|
||||||
|
!byte 12
|
||||||
|
!text "v1.0-alpha.3"
|
||||||
|
}
|
@ -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
|
||||||
|
@ -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,46 +27,20 @@
|
|||||||
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
|
bne +
|
||||||
sta $c002
|
@s
|
||||||
sta $c004
|
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
|
||||||
lda $fbb3
|
jsr PrintBranding
|
||||||
cmp #$A0
|
|
||||||
beq + ; Spectrum ED
|
|
||||||
cmp #$06
|
|
||||||
beq +
|
|
||||||
lda #$DF
|
|
||||||
!byte $2C
|
|
||||||
+ lda #$FF
|
|
||||||
sta $F1
|
|
||||||
ldy #15
|
|
||||||
- lda II-1,y
|
|
||||||
cmp #$E1
|
|
||||||
bcc +
|
|
||||||
and $F1
|
|
||||||
+ sta $070C-1,y
|
|
||||||
dey
|
|
||||||
bne -
|
|
||||||
ldy #13
|
|
||||||
- lda INSTANT-1,y
|
|
||||||
sta $04B5-1,y
|
|
||||||
lda REPLAY-1,y
|
|
||||||
sta $0535-1,y
|
|
||||||
dey
|
|
||||||
bne -
|
|
||||||
|
|
||||||
pla
|
pla
|
||||||
sta unit
|
sta unit
|
||||||
@ -164,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
|
||||||
@ -193,17 +169,201 @@ retcall pla
|
|||||||
- rts
|
- rts
|
||||||
fakeMLI_e
|
fakeMLI_e
|
||||||
|
|
||||||
|
; Interactive Seasons demo
|
||||||
|
; based on Apple II Seasons -=DESiRE=- 128B Demo for Outline 2020
|
||||||
|
; based on the code in Hellmood's 64B x86 demo 'Autumn'
|
||||||
|
; by deater (Vince Weaver)
|
||||||
|
; adapted by 4am for use within this bootloader
|
||||||
|
; /!\ While demo is running, press 1-4 to change color palettes
|
||||||
|
; or Esc to quit demo and continue the boot
|
||||||
|
|
||||||
|
HGR2 = $F3D8 ; Set full-screen hi-res mode using page 2 ($4000)
|
||||||
|
HPLOT0 = $F457 ; Plot point, (Y,X) = Horizontal, (A=Vertical)
|
||||||
|
HCOLOR = $F6EC ; Set color in X, must be 0..7
|
||||||
|
|
||||||
|
seasons:
|
||||||
|
bit $c010
|
||||||
|
jsr HGR2
|
||||||
|
ldx #(copy_seasons_e-copy_seasons)
|
||||||
|
- lda copy_seasons-1, x
|
||||||
|
sta $30, x
|
||||||
|
dex
|
||||||
|
bne -
|
||||||
|
jmp seasons_forever
|
||||||
|
|
||||||
|
copy_seasons:
|
||||||
|
; HGR ROM routines use
|
||||||
|
; $1C mask for color
|
||||||
|
; $26/$27 address for plot
|
||||||
|
; $30 color value * 17
|
||||||
|
; $E0/$E1 X coord of last hplot
|
||||||
|
; so code starts at $31 and must end before $E0
|
||||||
|
!pseudopc $31 {
|
||||||
|
EBP1 !byte 0
|
||||||
|
EBP2 !byte 0
|
||||||
|
EBP3 !byte 0
|
||||||
|
EBP4 !byte 0
|
||||||
|
|
||||||
|
color_lookup_lookup:
|
||||||
|
!byte <color_lookup
|
||||||
|
!byte <color_lookup2
|
||||||
|
!byte <color_lookup3
|
||||||
|
!byte <color_lookup4
|
||||||
|
|
||||||
|
color_lookup:
|
||||||
|
; qkumba ora2 white/blue/purple
|
||||||
|
!byte $02,$03,$02,$03, $06,$07,$06,$07
|
||||||
|
|
||||||
|
color_lookup2:
|
||||||
|
; better mixed orange/green/white
|
||||||
|
!byte $01,$03,$03,$03, $05,$05,$07,$07
|
||||||
|
|
||||||
|
color_lookup3:
|
||||||
|
; blue and purple palette
|
||||||
|
!byte $02,$02,$03,$06, $06,$06,$02,$07
|
||||||
|
|
||||||
|
color_lookup4:
|
||||||
|
; colorful palette
|
||||||
|
!byte $01,$01,$02,$03, $05,$05,$06,$07
|
||||||
|
|
||||||
|
seasons_forever:
|
||||||
|
|
||||||
|
; save old Xcoord value to X/Y for later
|
||||||
|
XCOORDL=*+1
|
||||||
|
ldx #0 ; 2
|
||||||
|
XCOORDH=*+1
|
||||||
|
ldy #0 ; 2
|
||||||
|
|
||||||
|
; 16-bit subtraction x=x-y
|
||||||
|
; need to set carry before subtraction on 6502
|
||||||
|
txa ; 1 (xcoordl in X)
|
||||||
|
sec ; 1
|
||||||
|
sbc <YCOORDL ; 2
|
||||||
|
sta <XCOORDL ; 2
|
||||||
|
tya ; 1 (xcoordh in Y)
|
||||||
|
YCOORDH=*+1
|
||||||
|
sbc #0 ; 2
|
||||||
|
|
||||||
|
; 16-bit arithmetic shift right of X
|
||||||
|
; 6502 has no asr instruction
|
||||||
|
; cmp #$80 sets carry if high bit set
|
||||||
|
cmp #$80 ; 2 ; XCOORDH still in A from before
|
||||||
|
ror ; 1
|
||||||
|
sta <XCOORDH ; 2
|
||||||
|
ror <XCOORDL ; 2
|
||||||
|
|
||||||
|
; 16-bit add, ycoord=ycoord+oldx
|
||||||
|
clc ; 1
|
||||||
|
txa ; 1
|
||||||
|
YCOORDL=*+1
|
||||||
|
adc #0 ; 2
|
||||||
|
sta <YCOORDL ; 2
|
||||||
|
tya ; 1
|
||||||
|
adc <YCOORDH ; 2
|
||||||
|
|
||||||
|
; 16-bit arithmetic shift right of y-coord
|
||||||
|
cmp #$80 ; 2 ; YCOORDH still in A from before
|
||||||
|
ror ; 1
|
||||||
|
sta <YCOORDH ; 2
|
||||||
|
ror <YCOORDL ; 2
|
||||||
|
|
||||||
|
; 32 bit rotate of low bit shifted out of Y-coordinate
|
||||||
|
ror <EBP1 ; 2
|
||||||
|
ror <EBP2 ; 2
|
||||||
|
ror <EBP3 ; 2
|
||||||
|
ror <EBP4 ; 2
|
||||||
|
|
||||||
|
; branch if carry set
|
||||||
|
bcs label_11f ; 2
|
||||||
|
|
||||||
|
; 16-bit increment of color
|
||||||
|
inc <COLORL ; 2
|
||||||
|
bne no_oflo ; 2
|
||||||
|
inc <COLORH ; 2
|
||||||
|
no_oflo:
|
||||||
|
|
||||||
|
; 16-bit add of X-coord by 0x80
|
||||||
|
; this keeps the drawing roughly to the 280x192 screen
|
||||||
|
; carry should still be clear (inc doesn't set it)
|
||||||
|
lda <XCOORDL ; 2
|
||||||
|
adc #$80 ; 2
|
||||||
|
sta <XCOORDL ; 2
|
||||||
|
bcc no_oflo2 ; 2
|
||||||
|
inc <XCOORDH ; 2
|
||||||
|
no_oflo2:
|
||||||
|
|
||||||
|
; 16-bit negate of Y-coord
|
||||||
|
sec ; 1
|
||||||
|
lda #0 ; 2
|
||||||
|
sbc <YCOORDL ; 2
|
||||||
|
sta <YCOORDL ; 2
|
||||||
|
lda #0 ; 2
|
||||||
|
sbc <YCOORDH ; 2
|
||||||
|
sta <YCOORDH ; 2
|
||||||
|
|
||||||
|
label_11f:
|
||||||
|
|
||||||
|
; 16-bit shift of color
|
||||||
|
; 2nd is a rotate as asl doesn't shift in carry
|
||||||
|
|
||||||
|
COLORL=*+1
|
||||||
|
lda #0 ; 2
|
||||||
|
asl ; 1 ; shl %ax
|
||||||
|
rol <COLORH ; 2
|
||||||
|
COLORH=*+1
|
||||||
|
eor #0 ; 2
|
||||||
|
sta <COLORL ; 2
|
||||||
|
|
||||||
|
; get color mapping
|
||||||
|
and #7 ; 2
|
||||||
|
tay ; 1
|
||||||
|
color_addr=*+1
|
||||||
|
ldx <color_lookup, y ; 2
|
||||||
|
|
||||||
|
; if ycoord negative, loop
|
||||||
|
lda <YCOORDH ; 2
|
||||||
|
bmi seasons_forever ; 2
|
||||||
|
|
||||||
|
; if top bits of xcoord, loop
|
||||||
|
lda <XCOORDH ; 2
|
||||||
|
and #$f0 ; 2
|
||||||
|
bne seasons_forever ; 2
|
||||||
|
|
||||||
|
put_pixel:
|
||||||
|
|
||||||
|
; actually set the color
|
||||||
|
jsr HCOLOR ; 3 ; color is in X
|
||||||
|
|
||||||
|
; set up parameters for HPLOT ROM call
|
||||||
|
ldx <XCOORDL ; 2 ; x coord in (y:x)
|
||||||
|
ldy <XCOORDH ; 2
|
||||||
|
lda <YCOORDL ; 2 ; y coord in A
|
||||||
|
jsr HPLOT0 ; 3
|
||||||
|
|
||||||
|
lda $c000
|
||||||
|
- bpl seasons_forever
|
||||||
|
cmp #$9b
|
||||||
|
beq +
|
||||||
|
and #3
|
||||||
|
tax
|
||||||
|
lda <color_lookup_lookup, x
|
||||||
|
sta <color_addr
|
||||||
|
bpl - ; always branches
|
||||||
|
+ rts
|
||||||
|
}
|
||||||
|
copy_seasons_e
|
||||||
|
|
||||||
filename
|
filename
|
||||||
!byte filename_e - filename_b
|
!byte filename_e - filename_b
|
||||||
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
|
||||||
II
|
|
||||||
!byte $D4,$EF,$F4,$E1,$EC,$A0,$D2,$E5,$F0,$EC,$E1,$F9,$A0,$C9,$C9
|
!src "src/4cade.branding.a"
|
||||||
INSTANT
|
|
||||||
!byte $C9,$A0,$CE,$A0,$D3,$A0,$D4,$A0,$C1,$A0,$CE,$A0,$D4
|
!if (* > $9f7) {
|
||||||
REPLAY
|
!serious "Bootloader is too large"
|
||||||
!byte $A0,$D2,$A0,$C5,$A0,$D0,$A0,$CC,$A0,$C1,$A0,$D9,$A0
|
}
|
||||||
|
|
||||||
*=$9f8
|
*=$9f8
|
||||||
!byte $D3,$C1,$CE,$A0,$C9,$CE,$C3,$AE
|
!byte $D3,$C1,$CE,$A0,$C9,$CE,$C3,$AE
|
||||||
|
Loading…
Reference in New Issue
Block a user