mirror of
https://github.com/A2osX/A2osX.git
synced 2024-11-25 20:33:13 +00:00
483 lines
9.9 KiB
Plaintext
483 lines
9.9 KiB
Plaintext
PR#3
|
||
PREFIX /A2OSX.BOOT
|
||
DELETE A2OSX.SYSTEM
|
||
PREFIX /A2OSX.SRC
|
||
NEW
|
||
INC 1
|
||
AUTO 6
|
||
.LIST OFF
|
||
.OP 65C02
|
||
.OR $2000
|
||
.TF /A2OSX.BOOT/A2OSX.SYSTEM,TSYS
|
||
*--------------------------------------
|
||
.INB INC/MACROS.I
|
||
.INB INC/A2OSX.I
|
||
.INB INC/IO.I
|
||
.INB INC/MONITOR.I
|
||
.INB INC/PRODOS.I
|
||
*--------------------------------------
|
||
TmpPtr1 .EQ $0 main & aux ZP
|
||
TmpPtr2 .EQ $2 main & aux ZP
|
||
*--------------------------------------
|
||
A2osX.RelocAddr .EQ $1000
|
||
A2osX.KMLOAD .EQ $2000
|
||
A2osX.KMMAXLEN .EQ $4000
|
||
A2osX.OpenBuff1 .EQ $6000 1024 Buffer for MLIOPEN01
|
||
A2osX.OpenBuff2 .EQ $6400 1024 Buffer for MLIOPEN02
|
||
A2osX.ReadBuff .EQ $6800 512 Buffer for MLIREAD01
|
||
Boot.Prefix .EQ $6A00 MLI.MAXPATH
|
||
KM.Filename .EQ $6A80 MLI.MAXPATH
|
||
*--------------------------------------
|
||
A2osX.Start .EQ *
|
||
.PH A2osX.RelocAddr
|
||
A2osX.Init0
|
||
|
||
ldx #$FF init 6502 stack to highest
|
||
txs
|
||
|
||
>LDYAI A2osX.Start
|
||
>STYA TmpPtr1
|
||
>LDYAI A2osX.RelocAddr
|
||
>STYA TmpPtr2
|
||
|
||
ldx #$10 reloc $2000-$2FFF to $1000-$1FFF
|
||
ldy #0
|
||
|
||
.1 lda (TmpPtr1),y
|
||
sta (TmpPtr2),y
|
||
iny
|
||
bne .1
|
||
|
||
inc TmpPtr1+1
|
||
inc TmpPtr2+1
|
||
dex
|
||
bne .1
|
||
|
||
jmp A2osX.Init1
|
||
*--------------------------------------
|
||
A2osX.Init1 bit RROMBNK1
|
||
jsr HOME
|
||
>LDAXI MSG.STAGE0
|
||
jsr PrintCStrAX
|
||
|
||
>LDAXI MSG.SYSMEM
|
||
jsr PrintCStrAX
|
||
|
||
lda MACHID
|
||
and #MACHID.RAM
|
||
cmp #MACHID.RAM.128
|
||
beq .1
|
||
|
||
>LDAXI MSG.SYSMEM.KO
|
||
jsr PrintCStrAX
|
||
bra *
|
||
|
||
.1 lda #$8C Reset 80 col screen ($0C=FF=HOME)
|
||
jsr $C300
|
||
|
||
>LDAXI MSG.STAGE0
|
||
jsr PrintCStrAX
|
||
|
||
>LDAXI MSG.SYSMEM
|
||
jsr PrintCStrAX
|
||
|
||
>LDAXI MSG.SYSMEM.OK
|
||
jsr PrintCStrAX
|
||
*--------------------------------------
|
||
A2osX.SetHZ lda #6
|
||
sta A2osX.HZ
|
||
pha push HZ
|
||
>LDAXI MSG.HZ
|
||
jsr PrintCStrAX
|
||
*--------------------------------------
|
||
>LDAXI MSG.CPU
|
||
jsr PrintCStrAX
|
||
jsr Init6502 Y = CPU type
|
||
tya
|
||
ora #$60
|
||
sta A2osX.CPUTYPE
|
||
|
||
lda MSG.CPUTYPEH,y
|
||
tax
|
||
lda MSG.CPUTYPEL,y
|
||
jsr PrintCStrAX
|
||
|
||
lda A2osX.CPUTYPE
|
||
bne .1
|
||
>LDAXI MSG.CPU.KO
|
||
jsr PrintCStrAX
|
||
bra *
|
||
*--------------------------------------
|
||
.1 lda MACHID
|
||
and #MACHID.TYPE
|
||
cmp #MACHID.TYPE.IIc
|
||
beq A2osX.Prefix
|
||
|
||
>LDAXI MSG.CPU.SPEED
|
||
jsr PrintCStrAX
|
||
|
||
stz A2osX.RANDOM16
|
||
stz A2osX.RANDOM16+1
|
||
|
||
php
|
||
sei
|
||
|
||
.2 bit VBL
|
||
bpl .2
|
||
|
||
.21 bit VBL
|
||
bmi .21
|
||
|
||
ldx #0 Count LO
|
||
lda #0 Count HI
|
||
|
||
.3 ldy #3 (2)
|
||
|
||
.4 nop (2)
|
||
dey (2)
|
||
bne .4 (2*)
|
||
|
||
inc A2osX.RANDOM16 (6)
|
||
bne .5 (2*)
|
||
|
||
inc A2osX.RANDOM16+1 (6)
|
||
bit VBL (4)
|
||
bpl .3 (2*)
|
||
bmi .6
|
||
|
||
.5 nop (2)
|
||
nop (2)
|
||
nop (2)
|
||
bit VBL (4)
|
||
bpl .3 (2*)
|
||
|
||
.6 plp
|
||
|
||
stz A2osX.CPUSPEED
|
||
|
||
.7 sec
|
||
lda A2osX.RANDOM16
|
||
sbc #100
|
||
tax
|
||
lda A2osX.RANDOM16+1
|
||
sbc /100
|
||
bcc .8
|
||
|
||
stx A2osX.RANDOM16
|
||
sta A2osX.RANDOM16+1
|
||
inc A2osX.CPUSPEED
|
||
bra .7
|
||
|
||
.8 lda A2osX.RANDOM16
|
||
sta A2osX.CPUSPEED+1
|
||
pha push CPU speed LO
|
||
lda A2osX.CPUSPEED
|
||
pha push CPU speed HI
|
||
>LDAXI MSG.CPU.SPEEDOK
|
||
jsr PrintCStrAX
|
||
*--------------------------------------
|
||
A2osX.Prefix >LDAXI MSG.BOOTPREFIX
|
||
jsr PrintCStrAX
|
||
jsr MLI
|
||
.DA #MLIGETPREFIX
|
||
.DA MLIGETPREFIX01
|
||
bcs *
|
||
ldx Boot.Prefix
|
||
stx A2osX.QC.B.Start+4
|
||
ldy #1
|
||
.1 lda Boot.Prefix,y
|
||
sta A2osX.QC.B.Start+4,y
|
||
ora #$80
|
||
jsr COUT
|
||
iny
|
||
dex
|
||
bne .1
|
||
jsr CROUT
|
||
*--------------------------------------
|
||
A2osX.RamDrv >LDAXI MSG.RAMDRV
|
||
jsr PrintCStrAX
|
||
|
||
jsr DisableRamDRV
|
||
bcc .2
|
||
|
||
tax
|
||
bne .1
|
||
>LDAXI MSG.RAMDRV.KO0
|
||
jsr PrintCStrAX
|
||
bra A2osX.Z80
|
||
|
||
.1 >LDAXI MSG.RAMDRV.KO1
|
||
jsr PrintCStrAX
|
||
bra A2osX.Z80
|
||
|
||
.2 >LDAXI MSG.RAMDRV.OK
|
||
jsr PrintCStrAX
|
||
*--------------------------------------
|
||
A2osX.Z80 >LDAXI MSG.Z80
|
||
jsr PrintCStrAX
|
||
jsr InitZ80
|
||
bcs .1
|
||
pha Push Z80Slot
|
||
|
||
>LDAXI MSG.Z80.OK
|
||
jsr PrintCStrAX
|
||
bra A2osX.SetupQC
|
||
|
||
.1 >LDAXI MSG.Z80.KO
|
||
jsr PrintCStrAX
|
||
*--------------------------------------
|
||
A2osX.SetupQC lda RRAMWRAMBNK2
|
||
lda RRAMWRAMBNK2
|
||
|
||
ldx #0
|
||
.1 lda A2osX.QC.B.Start,x
|
||
sta $D100,x
|
||
lda A2osX.QC.B.Start+$100,x
|
||
sta $D200,x
|
||
inx
|
||
bne .1
|
||
|
||
ldx #$C0
|
||
.2 lda A2osX.GP.B.start-1,x
|
||
sta $D300-1,x
|
||
dex
|
||
bne .2
|
||
|
||
ldx #$20
|
||
.3 lda $BEE0-1,x
|
||
sta $D3E0-1,x
|
||
dex
|
||
bne .3
|
||
|
||
lda RROMBNK1
|
||
*--------------------------------------
|
||
A2osX.EnumKM >LDAXI MSG.KMENUM
|
||
jsr PrintCStrAX
|
||
jsr EnumKM
|
||
*--------------------------------------
|
||
A2osX.MLIQuit >LDAXI MSG.STAGE0OK
|
||
jsr PrintCStrAX
|
||
|
||
>DEBUGOA
|
||
|
||
jsr MLI
|
||
.DA #MLIQUIT
|
||
.DA MLIQUIT01
|
||
bra *
|
||
*--------------------------------------
|
||
* Out:
|
||
* Y = 0, 6502
|
||
* Y = 1, 65C02
|
||
* Y = 2, R65C02
|
||
* Y = 3, 65C816
|
||
*--------------------------------------
|
||
Init6502 ldy #0 Test 6502 BCD bug
|
||
sed
|
||
lda #$99
|
||
clc
|
||
adc #$01
|
||
cld
|
||
bmi .9 BUG!, we have 6502
|
||
|
||
ldy #3 test 65C816 TYX Instruction
|
||
ldx #0
|
||
.OP 65816
|
||
tyx TYX: if 65C816, x becomes non-zero
|
||
.OP 65C02
|
||
bne .9 worked! 65C816
|
||
|
||
dey y=2 -> R65C02
|
||
ldx $EA save zp $EA
|
||
stz $EA store 0 in $EA
|
||
* .OP 65R02
|
||
.HS F7EA For compatibility with A2osX.ASM
|
||
* smb 7,$EA if not Rockwell, assemble as nop nop
|
||
* .OP 65C02
|
||
asl $EA cs if Rockwell
|
||
stx $EA restore zp $EA
|
||
bcs .9
|
||
|
||
dey y=1 -> 65C02
|
||
|
||
.9 rts
|
||
*--------------------------------------
|
||
DisableRamDRV php
|
||
sei
|
||
lda DEVPTRS3D2
|
||
cmp DEVPTRS0D1
|
||
bne .1
|
||
lda DEVPTRS3D2+1
|
||
cmp DEVPTRS0D1+1
|
||
beq .9 S3D2=NODEV, nothing to do
|
||
|
||
.1 ldx DEVCNT
|
||
|
||
.2 lda DEVLST,x LOOKING FOR $BF, $BB, $B7, $B3
|
||
and #$F3
|
||
cmp #$B3
|
||
beq .3
|
||
|
||
dex
|
||
bpl .2
|
||
|
||
plp
|
||
lda #1 No device found, exit with error
|
||
sec
|
||
rts
|
||
|
||
.3 cpx DEVCNT
|
||
beq .5
|
||
|
||
.4 lda DEVLST+1,x
|
||
sta DEVLST,x
|
||
inx
|
||
cpx DEVCNT
|
||
bne .4
|
||
|
||
.5 ldx DEVCNT
|
||
stz DEVLST,x
|
||
dec DEVCNT
|
||
|
||
lda DEVPTRS0D1
|
||
sta DEVPTRS3D2
|
||
lda DEVPTRS0D1+1
|
||
sta DEVPTRS3D2+1
|
||
plp
|
||
|
||
jsr MLI
|
||
.DA #MLIONLINE
|
||
.DA MLIONLINE01
|
||
clc Success!!
|
||
rts
|
||
|
||
.9 plp
|
||
lda #0 Not detected
|
||
sec
|
||
rts
|
||
*--------------------------------------
|
||
InitZ80 ldx #Z80Code.Size
|
||
.1 lda Z80Code.Start-1,x
|
||
sta $1000-1,x 00000H for Z80
|
||
dex
|
||
bne .1
|
||
|
||
stz TmpPtr1
|
||
lda #$C1
|
||
sta TmpPtr1+1
|
||
|
||
.2 sta (TmpPtr1)
|
||
lda $100D
|
||
bmi .8
|
||
inc TmpPtr1+1
|
||
lda TmpPtr1+1
|
||
cmp #$C8
|
||
beq .9
|
||
clc
|
||
adc #$20
|
||
sta $100A
|
||
bra .2
|
||
|
||
.8 lda TmpPtr1+1
|
||
and #$0F
|
||
sta A2osX.Z80Slot
|
||
clc
|
||
rts
|
||
|
||
.9 stz A2osX.Z80Slot
|
||
sec
|
||
rts
|
||
*--------------------------------------
|
||
.INB A2OSX.S.KM
|
||
.INB A2OSX.S.TOOLS
|
||
*--------------------------------------
|
||
MSG.STAGE0 >CSTRING "A2osX[Stage0]:Init\n"
|
||
MSG.SYSMEM >CSTRING "Checking System Memory..."
|
||
MSG.SYSMEM.OK >CSTRING "128k Detected.\n"
|
||
MSG.SYSMEM.KO >CSTRING "A2osX Requires At Least 128k Memory.\n"
|
||
MSG.HZ >CSTRING "Kernel SYS Timer Setup For %d0 hz.\n"
|
||
MSG.CPU >CSTRING "Checking CPU..."
|
||
MSG.CPU.KO >CSTRING "A2osX Requires At Least A 65C02 CPU.\n"
|
||
MSG.CPU.SPEED >CSTRING "Detecting CPU Speed..."
|
||
MSG.CPU.SPEEDOK >CSTRING "%d.%02d Mhz.\n"
|
||
MSG.BOOTPREFIX >CSTRING "Boot Prefix:"
|
||
MSG.RAMDRV >CSTRING "Checking ProDOS RamDrive..."
|
||
MSG.RAMDRV.OK >CSTRING "Successfully Disabled.\n"
|
||
MSG.RAMDRV.KO0 >CSTRING "Not Detected.\n"
|
||
MSG.RAMDRV.KO1 >CSTRING "Uninstall Failed !!!\n"
|
||
MSG.Z80 >CSTRING "Detecting Z80 CPU..."
|
||
MSG.Z80.OK >CSTRING "Detected In Slot %d.\n"
|
||
MSG.Z80.KO >CSTRING "Not Detected.\n"
|
||
MSG.KMENUM >CSTRING "Looking For Kernel Modules...\n"
|
||
MSG.KMLOAD >CSTRING "***Loading KM : "
|
||
MSG.STAGE0OK >CSTRING "A2osX[Stage0]:Complete.\n"
|
||
MSG.CPUTYPEL .DA #MSG.6502
|
||
.DA #MSG.65C02
|
||
.DA #MSG.65R02
|
||
.DA #MSG.65816
|
||
MSG.CPUTYPEH .DA /MSG.6502
|
||
.DA /MSG.65C02
|
||
.DA /MSG.65R02
|
||
.DA /MSG.65816
|
||
MSG.6502 >CSTRING "6502.\n"
|
||
MSG.65C02 >CSTRING "65C02.\n"
|
||
MSG.65R02 >CSTRING "65R02.\n"
|
||
MSG.65816 >CSTRING "65816.\n"
|
||
*--------------------------------------
|
||
MLIGETPREFIX01 .DA #1
|
||
.DA Boot.Prefix
|
||
MLIONLINE01 .DA #2
|
||
.DA #0
|
||
.DA MLIONLINE01BUF
|
||
MLIONLINE01BUF .BS 256
|
||
MLIOPEN01 .DA #3 For DIR listing
|
||
.DA Boot.Prefix
|
||
.DA A2osX.OpenBuff1
|
||
.BS 1
|
||
MLIREAD01 .DA #4
|
||
.BS 1
|
||
.DA A2osX.ReadBuff Load address Dir Blocks
|
||
.DA $200 Maxlen of Dir Blocks (512)
|
||
.BS 2
|
||
MLICLOSE01 .DA #1
|
||
.BS 1
|
||
MLIOPEN02 .DA #3
|
||
.DA KM.Filename
|
||
.DA A2osX.OpenBuff2
|
||
.BS 1
|
||
MLIREAD02 .DA #4
|
||
.BS 1
|
||
.DA A2osX.KMLOAD Load address for KMs
|
||
.DA A2osX.KMMAXLEN Maxlen of KM
|
||
.BS 2
|
||
MLICLOSE02 .DA #1
|
||
.BS 1
|
||
MLIQUIT01 .DA #4
|
||
.DA #0
|
||
.DA 0
|
||
.DA #0
|
||
.DA 0
|
||
*--------------------------------------
|
||
SYS >PSTRING "SYS/"
|
||
KM.PREFIX >PSTRING "KM."
|
||
*--------------------------------------
|
||
Z80Code.Start .HS 31FFFF START: LD SP,0FFFFH Init Stack
|
||
.HS 3EFF LD A,0FFH Set Flag
|
||
.HS 320D00 LD (FLAG),A
|
||
.HS 3200E1 LD (0E100H),A Back to 6502
|
||
.HS 18F3 JR START Loop
|
||
.HS 00 FLAG: .DB 0
|
||
Z80Code.End .EQ *
|
||
Z80Code.Size .EQ Z80Code.End-Z80Code.Start
|
||
*--------------------------------------
|
||
.EP
|
||
A2osX.End .EQ *
|
||
A2osX.SIZE .EQ A2osX.End-A2osX.Start
|
||
.BS $1000-A2osX.SIZE
|
||
*--------------------------------------
|
||
.INB A2OSX.S.QC
|
||
.INB A2OSX.S.GP
|
||
*--------------------------------------
|
||
MAN
|
||
SAVE A2OSX.S
|
||
ASM
|