Kernel version 0.8 (In Progress)

This commit is contained in:
Rémy GIBERT 2016-08-28 22:48:01 +02:00
parent 92c1b3cb49
commit 399646b8aa
14 changed files with 816 additions and 728 deletions

View File

@ -49,67 +49,42 @@ CS.INIT >LDYA L.LIBSTR
>SYSCALL SYS.LoadLibYA >SYSCALL SYS.LoadLibYA
sta hLIBSTR sta hLIBSTR
stz TmpBuffer256
>SYSCALL SYS.GetArgC >SYSCALL SYS.GetArgC
cmp #1 cmp #1
bne .1 bne .1
jsr CS.INIT.GETPFX no arg, go get current prefix ldy #S.PS.hPREFIX
bra .3 lda (pPs),y
>SYSCALL SYS.GetMemPtrA
>SYSCALL SYS.NewPStrYA no arg, go get current prefix
stx hFullPath
bra .2
.1 lda #1 .1 lda #1
>SYSCALL SYS.GetArgA >SYSCALL SYS.GetArgA
>STYA ZPPtr1
ldy #1 >SYSCALL SYS.GetFullPathYA
lda (ZPPtr1),y stx hFullPath
cmp #'/' full path starting with '/'?
beq .2 yes, do not append to current prefix
jsr CS.INIT.GETPFX .2 >SYSCALL SYS.ListDirInitYA
bcs .99
.2 >PUSHW ZPPtr1
>PUSHWI TmpBuffer256
>SYSCALL SYS.PStrCat
.3 >LDYAI TmpBuffer256
>SYSCALL SYS.CheckPrefixYA is it a existing directory?
bcs .5 no, let ListDirInitYA extract pattern
lda TmpBuffer256
tay
lda #'/'
cmp TmpBuffer256,y
beq .4
iny
sta TmpBuffer256,y
.4 iny
lda #'*'
sta TmpBuffer256,y
.5 >LDYAI TmpBuffer256
>SYSCALL SYS.ListDirInitYA
bcs .9
ldy #hS.LISTDIR ldy #hS.LISTDIR
sta (pData),y sta (pData),y
jsr .99
lda (pPs) lda (pPs)
ora #S.PS.F.EVENT Now accept events ora #S.PS.F.EVENT Now accept events
sta (pPs) sta (pPs)
clc clc
rts rts
.9 sec .99 pha
rts lda hFullPath
*-------------------------------------- >SYSCALL SYS.FreeMemA
CS.INIT.GETPFX ldy #S.PS.hPREFIX pla
lda (pPs),y sec
>SYSCALL SYS.GetMemPtrA
>PUSHYA
>PUSHWI TmpBuffer256
>SYSCALL SYS.PStrCpy
rts rts
*-------------------------------------- *--------------------------------------
CS.RUN ldy #bCANCEL CS.RUN ldy #bCANCEL
@ -414,6 +389,7 @@ TFF >PSTRING "SYS"
PRODOS.FT.DFLT >PSTRING "$ " PRODOS.FT.DFLT >PSTRING "$ "
HEXDIGIT .AS '0123456789ABCDEF' HEXDIGIT .AS '0123456789ABCDEF'
hLIBSTR .BS 1 hLIBSTR .BS 1
hFullPath .BS 1
*-------------------------------------- *--------------------------------------
.DUMMY .DUMMY
.OR 0 .OR 0

View File

@ -34,53 +34,28 @@ CS.START cld
.DA CS.QUIT .DA CS.QUIT
.DA 0 .DA 0
*-------------------------------------- *--------------------------------------
CS.INIT stz hFullPath CS.INIT >SYSCALL SYS.GetArgC
ldy #S.PS.hARGS cmp #1
lda (pPs),y bne .99
beq .9
>SYSCALL SYS.GetMemPtrA lda #1
>STYA ZPPTR1 >SYSCALL SYS.GetArgA
lda (ZPPTR1) >SYSCALL SYS.GetFullPathYA
beq .9 stx hFullPath
ldy #1
lda (ZPPTR1),y
cmp #'/'
bne .1
ldy #S.PS.hARGS
lda (pPs),y
bra .2
.1 ldy #S.PS.hARGS
lda (pPs),y
>PUSHA
ldy #S.PS.hPREFIX
lda (pPs),y
>PUSHA
>SYSCALL SYS.PStrCat
sta hFullPath
.2 >SYSCALL SYS.GetMemPtrA
>SYSCALL SYS.MLICreateDirYA >SYSCALL SYS.MLICreateDirYA
php pha save error code
pha
jsr .98 jsr .98
pla pla
plp sec
rts rts
.98 lda hFullPath .98 lda hFullPath
beq .9
>SYSCALL SYS.FreeMemA >SYSCALL SYS.FreeMemA
.9 lda #SYSMGR.ERRSYN .99 lda #SYSMGR.ERRSYN
sec sec
rts rts
*-------------------------------------- *--------------------------------------
CS.RUN sec CS.RUN
rts
*--------------------------------------
CS.DOEVENT sec CS.DOEVENT sec
rts rts
*-------------------------------------- *--------------------------------------

View File

@ -38,49 +38,39 @@ L.MSG.ERR .DA MSG.ERR
L.FullPath .DA FullPath L.FullPath .DA FullPath
.DA 0 .DA 0
*-------------------------------------- *--------------------------------------
CS.INIT ldy #S.PS.hARGS CS.INIT >SYSCALL SYS.GetArgC
lda (pPs),y cmp #1
beq .98 bne .99
>SYSCALL SYS.GetMemPtrA lda #1
>STYA ZPPtr1 >SYSCALL SYS.GetArgA
lda (ZPPtr1) >SYSCALL SYS.GetFullPathYA
beq .98 stx hFullPath
ldy #1
lda (ZPPtr1),y
cmp #'/'
bne .10
ldy #S.PS.hARGS
lda (pPs),y
bra .3
.10 ldy #S.PS.hARGS
lda (pPs),y
>PUSHA
ldy #S.PS.hPREFIX
lda (pPs),y
>PUSHA
>SYSCALL SYS.PStrCat
ldy #hDirPath
sta (pData),y
.3 >SYSCALL SYS.GetMemPtrA
>SYSCALL SYS.ListDirInitYA >SYSCALL SYS.ListDirInitYA
bcs .99 bcs .98
ldy #hS.LISTDIR ldy #hS.LISTDIR
sta (pData),y sta (pData),y
jsr .98
lda (pPs) lda (pPs)
ora #S.PS.F.EVENT Now accept events ora #S.PS.F.EVENT Now accept events
sta (pPs) sta (pPs)
clc clc
rts rts
.98 >LDYA L.MSG.USAGE .98 pha
lda hFullPath
>SYSCALL SYS.FreeMemA
pla
sec
rts
.99 >LDYA L.MSG.USAGE
>SYSCALL SYS.PSTRoutYA >SYSCALL SYS.PSTRoutYA
lda #SYSMGR.ERRSYN lda #SYSMGR.ERRSYN
.99 sec sec
rts rts
*-------------------------------------- *--------------------------------------
CS.RUN ldy #bCANCEL CS.RUN ldy #bCANCEL
@ -222,6 +212,7 @@ CS.END
MSG.USAGE >PSTRING "Usage : RM [file/Dir, *,? wildcards allowed]\n" MSG.USAGE >PSTRING "Usage : RM [file/Dir, *,? wildcards allowed]\n"
MSG.OK >PSTRING " [Ok]\n" MSG.OK >PSTRING " [Ok]\n"
MSG.ERR >PSTRING " [%h]\n" MSG.ERR >PSTRING " [%h]\n"
hFullPath .BS 1
FullPath .BS 64 FullPath .BS 64
*-------------------------------------- *--------------------------------------
.DUMMY .DUMMY

View File

@ -1,200 +0,0 @@
PR#3
PREFIX /A2OSX.SRC
NEW
INC 1
AUTO 6
.LIST OFF
*--------------------------------------
CPU.Init >LDAXI MSG.CPU
jsr PrintCStrAX
jsr Detect6502 A = CPU type
sta A2osX.CPUTYPE
lda MSG.CPUTYPEH,y
tax
lda MSG.CPUTYPEL,y
jsr PrintCStrAX
CPU.Init.Speed lda MACHID
and #MACHID.TYPE
cmp #MACHID.TYPE.IIc
beq CPU.Init.Z80
>LDAXI MSG.CPU.SPEED
jsr PrintCStrAX
stz A2osX.RANDOM16
stz A2osX.RANDOM16+1
php
sei
.1 bit VBL
bpl .2
.2 bit VBL
bmi .2
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
CPU.Init.Z80 >LDAXI MSG.Z80
jsr PrintCStrAX
jsr DetectZ80
bcs .9
sta A2osX.Z80SLOT
pha Push Z80Slot
>LDAXI MSG.Z80.OK
jsr PrintCStrAX
rts
.9 >LDAXI MSG.Z80.KO
jsr PrintCStrAX
rts
*--------------------------------------
* Out:
* A = $60, 6502
* A = $61, 65C02
* A = $62, R65C02
* A = $63, 65C816
*--------------------------------------
Detect6502 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 tya
ora #$60
rts
*--------------------------------------
* Out:
* A = Z80 Slot
*--------------------------------------
DetectZ80 ldx #Z80Code.Size
.1 lda Z80Code.Start-1,x
sta $1000-1,x 00000H for Z80
dex
bne .1
stz ZPQuickPtr1
lda #$C1
sta ZPQuickPtr1+1
.2 sta (ZPQuickPtr1)
lda $100D
bmi .8
inc ZPQuickPtr1+1
lda ZPQuickPtr1+1
cmp #$C8
beq .9 CS
clc
adc #$20
sta $100A
bra .2
.8 lda ZPQuickPtr1+1
and #$0F
clc
.9 rts
*--------------------------------------
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
*--------------------------------------
MSG.CPU >CSTRING "Checking CPU..."
MSG.CPU.SPEED >CSTRING "Detecting CPU Speed..."
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"
MSG.CPU.SPEEDOK >CSTRING "%d.%02d Mhz.\n"
MSG.Z80 >CSTRING "Detecting Z80 CPU..."
MSG.Z80.OK >CSTRING "Detected In Slot %d.\n"
MSG.Z80.KO >CSTRING "Not Detected.\n"
*--------------------------------------
MAN
SAVE SYS/KERNEL.S.CPU
LOAD SYS/KERNEL.S
ASM

View File

@ -13,7 +13,8 @@ AUTO 6
* CS : A = EC * CS : A = EC
*-------------------------------------- *--------------------------------------
S.OPENDIRYA jsr S.PFTCHECKPATHYA S.OPENDIRYA jsr S.PFTCHECKPATHYA
* if * if we are here, we only have to deal with Local ProDOS path
clc clc
rts rts

View File

@ -5,6 +5,28 @@ INC 1
AUTO 6 AUTO 6
.LIST OFF .LIST OFF
*-------------------------------------- *--------------------------------------
S.ExpandPStrYA >STYA ZPQuickPtr3
lda (ZPQuickPtr3)
sta KrnBuffer256
tay
.1 lda (ZPQuickPtr3),y
sta KrnBuffer256,y
dey
bne .1
ldy #0
.2 stz S.ExpandPStr.Start
.3 tya
cmp KrnBuffer256 End of PSTR?
beq .80
iny
lda KrnBuffer256,y
*--------------------------------------
* S.ExpandPStrYA * S.ExpandPStrYA
* In: * In:
* Y,A = PTR to String to Expand (PSTRING) * Y,A = PTR to String to Expand (PSTRING)
@ -12,7 +34,8 @@ AUTO 6
* X = hMem to Expanded String (PSTRING) * X = hMem to Expanded String (PSTRING)
* Y,A = PTR to Expanded String * Y,A = PTR to Expanded String
*-------------------------------------- *--------------------------------------
S.ExpandPStrYA >STYA ZPQuickPtr3 S.ExpandPStrYA.OLD
>STYA ZPQuickPtr3
stz KrnBuffer256 init Expanded String len=0 stz KrnBuffer256 init Expanded String len=0

View File

@ -7,12 +7,19 @@ AUTO 6
*-------------------------------------- *--------------------------------------
* For All SYS.xxxx calls, X = #SYSCall * For All SYS.xxxx calls, X = #SYSCall
* Must be kept in X before calling * Must be kept in X before calling
* S.PFTCheckPathXX * S.PFTCheckXYZ
*-------------------------------------- *--------------------------------------
* S.FOPEN * S.FOPEN
* In : * In :
* PULLW = PATH (PSTR) * PULLW = PATH (PSTR)
* PULLB = MODE * PULLB = MODE
* SYS.FOPEN.R .EQ $01 //Ignored (No ProDOS equivalent)
* SYS.FOPEN.W .EQ $02 //Ignored (No ProDOS equivalent)
* SYS.FOPEN.A .EQ $04 Append
* SYS.FOPEN.T .EQ $08 Open/Append in Text mode
* SYS.FOPEN.X .EQ $80 Create if not exists
* PULLB = TYPE
* PULLW = AUXTYPE
* Out : * Out :
* CC : A = hFILE * CC : A = hFILE
* CS : A = EC * CS : A = EC
@ -20,11 +27,32 @@ AUTO 6
S.FOPEN jsr S.PFTCHECKPATHSTK S.FOPEN jsr S.PFTCHECKPATHSTK
>PULLW MLICALL.PARAMS+1 >PULLW MLICALL.PARAMS+1
>PULLB S.FOPEN.MODE >PULLB S.FOPEN.MODE
>PULLB S.FOPEN.TYPE
>PULLW S.FOPEN.AUXTYPE
>PUSHWI S.FILE.PRODOS >MLICALL MLIGETFILEINFO
bcc .10 Already Exists
bit S.FOPEN.MODE Create if not exists ?
bpl .9 No, return MLI error
lda #$C3 Yes, Create...
sta MLICALL.PARAMS+3 Access
lda S.FOPEN.TYPE
sta MLICALL.PARAMS+4 File type
>LDYA S.FOPEN.AUXTYPE
>STYA MLICALL.PARAMS+5 Aux type
lda #$01 Storage=Standard Files
sta MLICALL.PARAMS+7
>MLICALL MLICREATE
bcc .10
.9 rts
.10 >PUSHWI S.FILE.PRODOS
>PUSHBI S.MEM.F.INIT0 >PUSHBI S.MEM.F.INIT0
jsr S.GetMem jsr S.GetMem
bcs .99 bcs .99
>STYA ZPQuickPtr1 >STYA ZPQuickPtr1
stx hFILE stx hFILE
@ -39,24 +67,35 @@ S.FOPEN jsr S.PFTCHECKPATHSTK
sta (ZPQuickPtr1),y sta (ZPQuickPtr1),y
>MLICALL MLIOPEN >MLICALL MLIOPEN
bcc .1 Failed... bcs .98
bit S.FOPEN.MODE Create if not exists?
bpl .98 no....error
lda MLICALL.PARAMS+5 get ref_num
.1 lda MLICALL.PARAMS+5 get ref_num
ldy #S.FILE.PRODOS.REF ldy #S.FILE.PRODOS.REF
sta (ZPQuickPtr1),y sta (ZPQuickPtr1),y
sta MLICALL.PARAMS+1 Next MLI Calls are REF_NUM based
lda S.FOPEN.MODE lda S.FOPEN.MODE
bit #SYS.FOPEN.A and #SYS.FOPEN.A Append ?
beq .1 beq .20
>MLICALL MLIGETEOF
bcs .98
>MLICALL MLISETMARK
bcs .98
.20 lda S.FOPEN.MODE
and #SYS.FOPEN.T Text Mode ?
beq .30
.1 lda #$FF
lda hFILE sta MLICALL.PARAMS+2
lda #$0D
sta MLICALL.PARAMS+3
>MLICALL MLINEWLINE
.30 lda hFILE
clc clc
rts CC rts CC
@ -67,6 +106,8 @@ S.FOPEN jsr S.PFTCHECKPATHSTK
.99 rts .99 rts
*-------------------------------------- *--------------------------------------
S.FOPEN.MODE .BS 1 S.FOPEN.MODE .BS 1
S.FOPEN.TYPE .BS 1
S.FOPEN.AUXTYPE .BS 2
hFILE .BS 1 hFILE .BS 1
*-------------------------------------- *--------------------------------------
* S.FCLOSEA * S.FCLOSEA
@ -101,7 +142,12 @@ S.FCLOSEA.1 ldy #S.FILE.PRODOS.REF
* Y,A = Bytes Read * Y,A = Bytes Read
*-------------------------------------- *--------------------------------------
S.FREAD jsr S.PFTCHECKFILESTK S.FREAD jsr S.PFTCHECKFILESTK
>PULLB MLICALL.PARAMS+1 >PULLA
jsr S.GetMemPtrA
>STYA ZPQuickPtr1
ldy #S.FILE.PRODOS.REF
lda (ZPQuickPtr1),y
sta MLICALL.PARAMS+1
>PULLW MLICALL.PARAMS+4 >PULLW MLICALL.PARAMS+4
>PULLW MLICALL.PARAMS+2 >PULLW MLICALL.PARAMS+2
>MLICALL MLIREAD >MLICALL MLIREAD
@ -118,6 +164,12 @@ S.FREAD jsr S.PFTCHECKFILESTK
* Y,A = Bytes Written * Y,A = Bytes Written
*-------------------------------------- *--------------------------------------
S.FWRITE jsr S.PFTCHECKFILESTK S.FWRITE jsr S.PFTCHECKFILESTK
>PULLA
jsr S.GetMemPtrA
>STYA ZPQuickPtr1
ldy #S.FILE.PRODOS.REF
lda (ZPQuickPtr1),y
sta MLICALL.PARAMS+1
>PULLB MLICALL.PARAMS+1 >PULLB MLICALL.PARAMS+1
>PULLW MLICALL.PARAMS+4 >PULLW MLICALL.PARAMS+4
>PULLW MLICALL.PARAMS+2 >PULLW MLICALL.PARAMS+2
@ -131,6 +183,10 @@ S.FWRITE jsr S.PFTCHECKFILESTK
* A = hFILE * A = hFILE
*-------------------------------------- *--------------------------------------
S.FFLUSHA jsr S.PFTCHECKFILEA S.FFLUSHA jsr S.PFTCHECKFILEA
jsr S.GetMemPtrA
>STYA ZPQuickPtr1
ldy #S.FILE.PRODOS.REF
lda (ZPQuickPtr1),y
sta MLICALL.PARAMS+1 sta MLICALL.PARAMS+1
>MLICALL MLIFLUSH >MLICALL MLIFLUSH
rts rts

View File

@ -204,75 +204,65 @@ S.LoadFile.Len .BS 2
* out : * out :
* A = hMem of Dir Listing * A = hMem of Dir Listing
*-------------------------------------- *--------------------------------------
S.ListDirInitYA >STYA R.BX Store path S.ListDirInitYA >STYA ZPQuickPtr3 Store path
stz TmpFileName Reset File.Pattern lda (ZPQuickPtr3)
lda (R.BX)
tay tay
ldx #0 ldx #0
.1 lda (R.BX),y .1 lda (ZPQuickPtr3),y reverse read path until '/' found
cmp #'/' cmp #'/'
beq .2 beq .2
inx inx
dey dey
bne .1 bne .1
.2 stx TmpFileName .2 stx TmpFileName store file pattern len in buffer
txa txa
beq .4 beq .4 no pattern ?
lda (R.BX) lda (ZPQuickPtr3)
tay tay
.3 lda (R.BX),y .3 lda (ZPQuickPtr3),y
sta TmpFileName,x sta TmpFileName,x
dey dey
dex dex
bne .3 bne .3
tya tya
sta (R.BX) remove pattern from path sta (ZPQuickPtr3) remove pattern from path
.4 >PUSHWI S.LISTDIR.SIZE get LISTDIR Struct .4 >PUSHWI S.LISTDIR.SIZE get LISTDIR Struct
>PUSHBI S.MEM.F.INIT0 reset all bytes >PUSHBI S.MEM.F.INIT0 reset all bytes
jsr S.GetMem jsr S.GetMem
bcs .99 bcs .99
stx S.ListDirInitYA.hDir
>STYA R.CX Store LISTDIR Struct
>LDYA R.BX stx S.ListDirInitYA.hDir
>STYA ZPQuickPtr4 Store LISTDIR Struct
>LDYA ZPQuickPtr3
jsr S.NewPStrYA jsr S.NewPStrYA
bcs .99 bcs .99
txa txa
ldy #S.LISTDIR.hPATH ldy #S.LISTDIR.hPATH
sta (R.CX),y sta (ZPQuickPtr4),y
ldy TmpFileName lda TmpFileName
beq .5 beq .5
>LDYAI TmpFileName
lda #0 jsr S.NewPStrYA
>PUSHYA bcs .99
>PUSHBI 0
jsr S.GetMem
bcs .98
>STYA ZPQuickPtr1
txa txa
ldy #S.LISTDIR.hPATTERN ldy #S.LISTDIR.hPATTERN
sta (R.CX),y sta (ZPQuickPtr4),y
ldy TmpFileName .5 lda (ZPQuickPtr3)
.40 lda TmpFileName,y
sta (ZPQuickPtr1),y
dey
bpl .40
.5 lda (R.BX)
cmp #1 length = 1 ? ('/') cmp #1 length = 1 ? ('/')
bne .6 bne .6
jsr S.ListDirInitAV jsr S.ListDirInitAV
bcs .98 bcs .98
lda S.ListDirInitYA.hDir lda S.ListDirInitYA.hDir
@ -298,34 +288,35 @@ S.ListDirInitAV >PUSHWI 256
bcs .99 bcs .99
>PUSHYA push buffer for online call >PUSHYA push buffer for online call
txa txa
sta (R.CX) save hONLINE buffer sta (ZPQuickPtr4) save hONLINE buffer
>PUSHBI 0 All devices >PUSHBI 0 All devices
jsr S.MLIOnline jsr S.MLIOnline
bcs .98 bcs .98
ldy #S.LISTDIR.ONLINEPTR ldy #S.LISTDIR.ONLINEPTR
* lda #0 make index point first Entry * lda #0 make index point first Entry
* sta (R.CX),y * sta (ZPQuickPtr4),y
clc clc
rts rts
.98 lda (R.CX)
.98 lda (ZPQuickPtr4)
jsr S.FreeMemA jsr S.FreeMemA
.99 sec .99 sec
rts rts
*-------------------------------------- *--------------------------------------
S.ListDirInitAD S.ListDirInitAD
* lda #0 * lda #0
* sta (R.CX) reset hONLINE * sta (ZPQuickPtr4) reset hONLINE
>LDYA R.BX Open DIR >LDYA ZPQuickPtr3 Open DIR
jsr S.MLIOpenYA jsr S.MLIOpenYA
bcs .99 bcs .99
ldy #S.LISTDIR.REFNUM ldy #S.LISTDIR.REFNUM
sta (R.CX),y save ref_num sta (ZPQuickPtr4),y save ref_num
txa txa
ldy #S.LISTDIR.hIOBUF ldy #S.LISTDIR.hIOBUF
sta (R.CX),y save ProDOS IO buffer hMem sta (ZPQuickPtr4),y save ProDOS IO buffer hMem
>PUSHWI 512 get Read buffer >PUSHWI 512 get Read buffer
>PUSHBI 0 >PUSHBI 0
@ -333,7 +324,7 @@ S.ListDirInitAD
bcs .99 bcs .99
txa txa
ldy #S.LISTDIR.hREADBUF save Read Buffer hMem ldy #S.LISTDIR.hREADBUF save Read Buffer hMem
sta (R.CX),y sta (ZPQuickPtr4),y
jsr S.ListDirReadBlock jsr S.ListDirReadBlock
bcs .99 bcs .99
>STYA ZPQuickPtr1 >STYA ZPQuickPtr1
@ -341,31 +332,31 @@ S.ListDirInitAD
ldy #$23 get entry_length ldy #$23 get entry_length
lda (ZPQuickPtr1),y lda (ZPQuickPtr1),y
ldy #S.LISTDIR.EL ldy #S.LISTDIR.EL
sta (R.CX),y sta (ZPQuickPtr4),y
ldy #$24 get entry_per_block ldy #$24 get entry_per_block
lda (ZPQuickPtr1),y lda (ZPQuickPtr1),y
ldy #S.LISTDIR.EPB ldy #S.LISTDIR.EPB
sta (R.CX),y sta (ZPQuickPtr4),y
ldy #$25 get File_count LO ldy #$25 get File_count LO
lda (ZPQuickPtr1),y lda (ZPQuickPtr1),y
clc clc
adc #1 Add 1 for VOL/DIR Header adc #1 Add 1 for VOL/DIR Header
ldy #S.LISTDIR.FC ldy #S.LISTDIR.FC
sta (R.CX),y sta (ZPQuickPtr4),y
ldy #$26 get File_count HI ldy #$26 get File_count HI
lda (ZPQuickPtr1),y lda (ZPQuickPtr1),y
adc #0 adc #0
ldy #S.LISTDIR.FC+1 ldy #S.LISTDIR.FC+1
sta (R.CX),y sta (ZPQuickPtr4),y
* ldy #S.LISTDIR.FI * ldy #S.LISTDIR.FI
* lda #0 * lda #0
* sta (R.CX),y * sta (ZPQuickPtr4),y
* iny * iny
* sta (R.CX),y set FI to $0000 * sta (ZPQuickPtr4),y set FI to $0000
clc clc
.99 rts .99 rts
*-------------------------------------- *--------------------------------------

View File

@ -1,185 +0,0 @@
PR#3
PREFIX /A2OSX.SRC
NEW
INC 1
AUTO 6
.LIST OFF
*--------------------------------------
* Setup MainLC ($3FE)
*
*
* Setup AuxLC $FFFE->Kernel IRQ Handler
* if irq not handled, jmp (S.IrqMgrOldFFFE)
*--------------------------------------
S.IrqMgrInit php
sei
>LDYA $FFFE
cpy #S.IrqHandlerAuxLC
bne .1
cmp /S.IrqHandlerAuxLC
beq .2
.1 >STYA S.IrqMgrOldFFFE
>LDYAI S.IrqHandlerAuxLC
>STYA $FFFE
.2
* >LDYAI $BE0C
* >STYA $3F0
plp
clc
rts
*--------------------------------------
S.MemMgrInit >LDYAI MemMgr.MHiMem
>STYA MemMgr.HiMem
>STYA MemMgr.Free
>LDYAI MemMgr.MLoMem
>STYA MemMgr.LoMem
stz MemMgr.LastSlot Reserve Slot #0
sta SETWRITEAUX
>LDYAI MemMgr.XHiMem
>STYA MemMgr.HiMem
>STYA MemMgr.Free
>LDYAI MemMgr.XLoMem
>STYA MemMgr.LoMem
stz MemMgr.LastSlot Reserve Slot #0
sta CLRWRITEAUX
clc
rts
*--------------------------------------
* S.DevMgrInit
*--------------------------------------
S.DevMgrInit ldx #S.DEV.SIZE*DevMgr.Count
.1 lda DevMgr.NUL-1,x
sta DevMgr.Table-1,x
dex
bne .1
stz DevMgr.Table+S.DEV.SIZE*DevMgr.Count+1
lda #DevMgr.Count-1
sta DevMgr.LastDevID
>LDYAI DevMgr.End
>STYA DevMgr.Free
clc
rts
*--------------------------------------
* S.EvtMgrInit
*--------------------------------------
S.EvtMgrInit lda #10
sta EVTMGR.10TH.CNT
lda A2osX.HZ
sta EVTMGR.HZ.CNT
lda MACHID
and #MACHID.TYPE
cmp #MACHID.TYPE.IIc
bne .8
* sta CLRIOUDIS
* sta ENBVBLIIC
.8 lda /EvtMgr.Table
sta pEvent+1
clc
rts
*--------------------------------------
* S.TskMgrInit
*--------------------------------------
S.TskMgrInit stz TSKMGR.LASTID
lda #1
sta TSKMGR.SIZE One Slot Busy (Kernel PS=0)
>LDYAI TskMgr.Table Clear whole process table
>STYA pPs
ldx #K.PS.MAX
.1 lda #0
ldy #S.PS.SIZE-1
.2 sta (pPs),y
dey
bpl .2
lda pPs
clc
adc #S.PS.SIZE
sta pPs
bcc .3
inc pPs+1
.3 dex
bne .1
>LDYAI TskMgr.Table Select Process 0 (Kernel)
>STYA pPs
lda #1
ldy #S.PS.hINDEV
sta (pPs),y Make In DEV = SYS
ldy #S.PS.hOUTDEV
sta (pPs),y Make OUT DEV = SYS
ldy #S.PS.hERRDEV
sta (pPs),y Make ERR DEV = SYS
>SYSCALL SYS.GetDevByIDA
>STYA pDev
ldx #DEVMGR.OPEN
jsr pDevJmp
>PUSHWI K.ENV.SIZE get a buffer for ENV
>PUSHBI S.MEM.F.INIT0 make sure blank
>SYSCALL SYS.GetMem create it...
bcs .9
txa
ldy #S.PS.hENV
sta (pPs),y
>LDYAI TmpBuffer256
>SYSCALL SYS.MLIGetPrefixYA
bcs .9
>LDYAI TmpBuffer256
>SYSCALL SYS.NewPStrYA
bcs .9
txa
ldy #S.PS.hPREFIX
sta (pPs),y
>PUSHWI TmpBuffer256 push ENV value
>PUSHWI I.ENV.A2osX push ENV name
>SYSCALL SYS.SetEnv
bcs .9
>LDYAI I.ENV.PATH
>SYSCALL SYS.PutEnvYA
bcs .9
>LDYAI I.ENV.LIB
>SYSCALL SYS.PutEnvYA
bcs .9
>LDYAI I.ENV.DRV
>SYSCALL SYS.PutEnvYA
.9 rts
*--------------------------------------
I.ENV.A2osX >PSTRING "A2OSX"
I.ENV.PATH >PSTRING "PATH=${A2OSX}SBIN/;${A2OSX}BIN/"
I.ENV.LIB >PSTRING "LIB=${A2OSX}LIB/"
I.ENV.DRV >PSTRING "DRV=${A2OSX}DRV/"
*--------------------------------------
MAN
SAVE SYS/KERNEL.S.INIT
LOAD SYS/KERNEL.S
ASM

509
SYS/KERNEL.S.INIT2.txt Normal file
View File

@ -0,0 +1,509 @@
PR#3
PREFIX /A2OSX.SRC
NEW
INC 1
AUTO 6
.LIST OFF
*--------------------------------------
Kernel.Init2 >LDAXI MSG.Init2
jsr PrintCStrAX
sei
ldx #$FF init 6502 stack to highest
txs
sta SETALTZP
stx A2osX.SaveSM
stx A2osX.SaveSX
sta CLRALTZP Make MAIN ZP is enabled for X.PRINT.F
lda RROMBNK1 Make sure ROM is enabled for X.PRINT.F
cli
>LDAXI MSG.Relocate
jsr PrintCStrAX
sei
sta SETALTZP
>LDYAI A2osX.BE00
>STYA ZPQuickPtr1
>LDYAI $BE00
>STYA ZPQuickPtr2
>LDYAI A2osX.BE00.SIZE^$FFFF
>STYA ZPQuickPtr3
jsr Kernel.Move
lda RRAMWRAMBNK2
lda RRAMWRAMBNK2
>LDYAI A2osX.D002
>STYA ZPQuickPtr1
>LDYAI $D000
>STYA ZPQuickPtr2
>LDYAI A2osX.D002.SIZE^$FFFF
>STYA ZPQuickPtr3
jsr Kernel.Move
lda RRAMWRAMBNK1
lda RRAMWRAMBNK1
>LDYAI A2osX.D001
>STYA ZPQuickPtr1
>LDYAI $D000
>STYA ZPQuickPtr2
>LDYAI A2osX.D001.SIZE^$FFFF
>STYA ZPQuickPtr3
jsr Kernel.Move
>LDYAI A2osX.E000
>STYA ZPQuickPtr1
>LDYAI $E000
>STYA ZPQuickPtr2
>LDYAI A2osX.E000.SIZE^$FFFF
>STYA ZPQuickPtr3
jsr Kernel.Move
>LDYAI D.STACK.TOP
>STYA pStack init Soft Stack
sta CLRALTZP Make MAIN ZP is enabled for X.PRINT.F
lda RROMBNK1 Make sure ROM is enabled for X.PRINT.F
cli
lda #6
sta A2osX.HZ
pha push HZ
>LDAXI MSG.HZ
jsr PrintCStrAX
jsr CPU.Init
>LDAXI MSG.K.INIT
jsr PrintCStrAX
sta SETALTZP
lda RRAMWRAMBNK1
lda RRAMWRAMBNK1
jsr S.IrqMgrInit
bcs *
jsr S.MemMgrInit
bcs *
jsr S.DevMgrInit
bcs *
jsr S.EvtMgrInit
bcs *
jsr S.FltMgrInit
bcs *
jsr S.TskMgrInit
bcs *
sta CLRALTZP Make sure MAIN ZP...
lda RROMBNK1 ... & ROM is enabled for X.PRINT.F
>LDAXI MSG.Init2.OK
jsr PrintCStrAX
sta SETALTZP
lda RRAMWRAMBNK1
lda RRAMWRAMBNK1
rts
*--------------------------------------
MSG.Init2 >CSTRING "A2osX[Stage2]:Init\n"
MSG.Relocate >CSTRING "Relocating KERNEL...\n"
MSG.HZ >CSTRING "Kernel SYS Timer Set For %d0 hz Machine.\n"
MSG.K.INIT >CSTRING "Kernel Setup...\n"
MSG.Init2.OK >CSTRING "A2osX[Stage2]:Complete.\n"
*--------------------------------------
CPU.Init >LDAXI MSG.CPU
jsr PrintCStrAX
jsr Detect6502 A = CPU type
sta A2osX.CPUTYPE
lda MSG.CPUTYPEH,y
tax
lda MSG.CPUTYPEL,y
jsr PrintCStrAX
CPU.Init.Speed lda MACHID
and #MACHID.TYPE
cmp #MACHID.TYPE.IIc
beq CPU.Init.Z80
>LDAXI MSG.CPU.SPEED
jsr PrintCStrAX
stz A2osX.RANDOM16
stz A2osX.RANDOM16+1
php
sei
.1 bit VBL
bpl .2
.2 bit VBL
bmi .2
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
CPU.Init.Z80 >LDAXI MSG.Z80
jsr PrintCStrAX
jsr DetectZ80
bcs .9
sta A2osX.Z80SLOT
pha Push Z80Slot
>LDAXI MSG.Z80.OK
jsr PrintCStrAX
rts
.9 >LDAXI MSG.Z80.KO
jsr PrintCStrAX
rts
*--------------------------------------
* Out:
* A = $60, 6502
* A = $61, 65C02
* A = $62, R65C02
* A = $63, 65C816
*--------------------------------------
Detect6502 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 tya
ora #$60
rts
*--------------------------------------
* Out:
* A = Z80 Slot
*--------------------------------------
DetectZ80 ldx #Z80Code.Size
.1 lda Z80Code.Start-1,x
sta $1000-1,x 00000H for Z80
dex
bne .1
stz ZPQuickPtr1
lda #$C1
sta ZPQuickPtr1+1
.2 sta (ZPQuickPtr1)
lda $100D
bmi .8
inc ZPQuickPtr1+1
lda ZPQuickPtr1+1
cmp #$C8
beq .9 CS
clc
adc #$20
sta $100A
bra .2
.8 lda ZPQuickPtr1+1
and #$0F
clc
.9 rts
*--------------------------------------
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
*--------------------------------------
MSG.CPU >CSTRING "Checking CPU..."
MSG.CPU.SPEED >CSTRING "Detecting CPU Speed..."
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"
MSG.CPU.SPEEDOK >CSTRING "%d.%02d Mhz.\n"
MSG.Z80 >CSTRING "Detecting Z80 CPU..."
MSG.Z80.OK >CSTRING "Detected In Slot %d.\n"
MSG.Z80.KO >CSTRING "Not Detected.\n"
*--------------------------------------
Kernel.Move ldy #0
.1 inc ZPQuickPtr3
bne .2
inc ZPQuickPtr3+1
beq .9
.2 lda (ZPQuickPtr1),y
sta (ZPQuickPtr2),y
iny
bne .1
inc ZPQuickPtr1+1
inc ZPQuickPtr2+1
bne .1
.9 rts
*--------------------------------------
* Setup MainLC ($3FE)
*
*
* Setup AuxLC $FFFE->Kernel IRQ Handler
* if irq not handled, jmp (S.IrqMgrOldFFFE)
*--------------------------------------
S.IrqMgrInit php
sei
>LDYA $FFFE
cpy #S.IrqHandlerAuxLC
bne .1
cmp /S.IrqHandlerAuxLC
beq .2
.1 >STYA S.IrqMgrOldFFFE
>LDYAI S.IrqHandlerAuxLC
>STYA $FFFE
.2
* >LDYAI $BE0C
* >STYA $3F0
plp
clc
rts
*--------------------------------------
S.MemMgrInit >LDYAI MemMgr.MHiMem
>STYA MemMgr.HiMem
>STYA MemMgr.Free
>LDYAI MemMgr.MLoMem
>STYA MemMgr.LoMem
stz MemMgr.LastSlot Reserve Slot #0
sta SETWRITEAUX
>LDYAI MemMgr.XHiMem
>STYA MemMgr.HiMem
>STYA MemMgr.Free
>LDYAI MemMgr.XLoMem
>STYA MemMgr.LoMem
stz MemMgr.LastSlot Reserve Slot #0
sta CLRWRITEAUX
clc
rts
*--------------------------------------
* S.DevMgrInit
*--------------------------------------
S.DevMgrInit ldx #S.DEV.SIZE*DevMgr.Count
.1 lda DevMgr.NUL-1,x
sta DevMgr.Table-1,x
dex
bne .1
stz DevMgr.Table+S.DEV.SIZE*DevMgr.Count+1
lda #DevMgr.Count-1
sta DevMgr.LastDevID
>LDYAI DevMgr.End
>STYA DevMgr.Free
clc
rts
*--------------------------------------
* S.EvtMgrInit
*--------------------------------------
S.EvtMgrInit lda #10
sta EVTMGR.10TH.CNT
lda A2osX.HZ
sta EVTMGR.HZ.CNT
lda MACHID
and #MACHID.TYPE
cmp #MACHID.TYPE.IIc
bne .8
* sta CLRIOUDIS
* sta ENBVBLIIC
.8 lda /EvtMgr.Table
sta pEvent+1
clc
rts
*--------------------------------------
* S.TskMgrInit
*--------------------------------------
S.TskMgrInit stz TSKMGR.LASTID
lda #1
sta TSKMGR.SIZE One Slot Busy (Kernel PS=0)
>LDYAI TskMgr.Table Clear whole process table
>STYA pPs
ldx #K.PS.MAX
.1 lda #0
ldy #S.PS.SIZE-1
.2 sta (pPs),y
dey
bpl .2
lda pPs
clc
adc #S.PS.SIZE
sta pPs
bcc .3
inc pPs+1
.3 dex
bne .1
>LDYAI TskMgr.Table Select Process 0 (Kernel)
>STYA pPs
lda #1
ldy #S.PS.hINDEV
sta (pPs),y Make In DEV = SYS
ldy #S.PS.hOUTDEV
sta (pPs),y Make OUT DEV = SYS
ldy #S.PS.hERRDEV
sta (pPs),y Make ERR DEV = SYS
>SYSCALL SYS.GetDevByIDA
>STYA pDev
ldx #DEVMGR.OPEN
jsr pDevJmp
>PUSHWI K.ENV.SIZE get a buffer for ENV
>PUSHBI S.MEM.F.INIT0 make sure blank
>SYSCALL SYS.GetMem create it...
bcs .9
txa
ldy #S.PS.hENV
sta (pPs),y
>LDYAI TmpBuffer256
>SYSCALL SYS.MLIGetPrefixYA
bcs .9
>LDYAI TmpBuffer256
>SYSCALL SYS.NewPStrYA
bcs .9
txa
ldy #S.PS.hPREFIX
sta (pPs),y
>PUSHWI TmpBuffer256 push ENV value
>PUSHWI I.ENV.A2osX push ENV name
>SYSCALL SYS.SetEnv
bcs .9
>LDYAI I.ENV.PATH
>SYSCALL SYS.PutEnvYA
bcs .9
>LDYAI I.ENV.LIB
>SYSCALL SYS.PutEnvYA
bcs .9
>LDYAI I.ENV.DRV
>SYSCALL SYS.PutEnvYA
.9 rts
*--------------------------------------
S.FltMgrInit stz FltMgr.Table
clc
rts
*--------------------------------------
I.ENV.A2osX >PSTRING "A2OSX"
I.ENV.PATH >PSTRING "PATH=${A2OSX}SBIN/;${A2OSX}BIN/"
I.ENV.LIB >PSTRING "LIB=${A2OSX}LIB/"
I.ENV.DRV >PSTRING "DRV=${A2OSX}DRV/"
*--------------------------------------
MAN
SAVE SYS/KERNEL.S.INIT2
LOAD SYS/KERNEL.S
ASM

54
SYS/KERNEL.S.INIT3.txt Normal file
View File

@ -0,0 +1,54 @@
PR#3
PREFIX /A2OSX.SRC
NEW
INC 1
AUTO 6
.LIST OFF
*--------------------------------------
Kernel.Init3 ldx #DEVMGR.SELECT
jsr pDevJmp
>LDYAI MSG.Init3
>SYSCALL SYS.PSTROutYA
ldy #S.PS.hPREFIX
lda (pPs),y
>SYSCALL SYS.GetMemPtrA
>PUSHYA
>LDYAI MSG.Prefix
>SYSCALL SYS.PSTROutYA
>PUSHWI STARTUP.CMDLINE
>LDYAI MSG.Startup
>SYSCALL SYS.PSTROutYA
>LDYAI STARTUP.CMDLINE
>SYSCALL SYS.CreateProcessYA
bcs .9
>LDYAI MSG.Init3.OK
>SYSCALL SYS.PSTROutYA
>LDYAI TskMgr.Table
>STYA pPs
jmp S.KernelRun
.9 >PUSHA
>LDYAI MSG.StartupErr
>SYSCALL SYS.PSTROutYA
bra *
*--------------------------------------
MSG.Init3 >PSTRING "A2osX[Stage3]:Init\n"
MSG.Prefix >PSTRING "Prefix:%S\n"
MSG.Startup >PSTRING "Executing Kernel Startup Script...\nCmd:%S\n"
MSG.StartupErr >PSTRING "Failed : [$%h]\n"
MSG.Init3.OK >PSTRING "A2osX[Stage3]:Complete.\n"
*--------------------------------------
STARTUP.CMDLINE >PSTRING "${A2OSX}SBIN/SHELL ${A2OSX}A2osX.STARTUP"
*--------------------------------------
MAN
SAVE SYS/KERNEL.S.INIT3
LOAD SYS/KERNEL.S
ASM

View File

@ -37,7 +37,7 @@ S.PFTCHECKPATHYA
dey dey
bne .2 bne .2
ldy #S.S.PFT.HANDLER ldy #S.PFT.HANDLER
lda (ZPQuickPtr2),y get hLib lda (ZPQuickPtr2),y get hLib
jsr S.GetMemPtrA jsr S.GetMemPtrA
>STYA .3+1 >STYA .3+1
@ -63,6 +63,7 @@ S.PFTCHECKPATHYA
.9 >LDYA ZPQuickPtr1 restore passed params .9 >LDYA ZPQuickPtr1 restore passed params
ldx S.PFT.SYSCALL ldx S.PFT.SYSCALL
>LDYA ZPQuickPtr1
rts rts
*-------------------------------------- *--------------------------------------
* In : * In :
@ -74,7 +75,7 @@ S.PFTCHECKPATHYA
S.PFTCHECKFILESTK S.PFTCHECKFILESTK
lda (pStack) read hFILE on top of stack lda (pStack) read hFILE on top of stack
S.PFTCHECKFILEA S.PFTCHECKFILEA
jsr GetMemPtrA X = unmidified jsr S.GetMemPtrA X = unmidified
.8 clc .8 clc
rts rts

View File

@ -21,184 +21,17 @@ ZPQuickPtr4 .EQ ZPKERNEL+6
*-------------------------------------- *--------------------------------------
* Kernel Stage 2 * Kernel Stage 2
*-------------------------------------- *--------------------------------------
Kernel.Init2 >LDAXI MSG.Init2 jsr Kernel.Init2
jsr PrintCStrAX
sei
ldx #$FF init 6502 stack to highest
txs
sta SETALTZP
stx A2osX.SaveSM
stx A2osX.SaveSX
sta CLRALTZP Make MAIN ZP is enabled for X.PRINT.F
lda RROMBNK1 Make sure ROM is enabled for X.PRINT.F
cli
>LDAXI MSG.Relocate
jsr PrintCStrAX
sei
sta SETALTZP
>LDYAI A2osX.BE00
>STYA ZPQuickPtr1
>LDYAI $BE00
>STYA ZPQuickPtr2
>LDYAI A2osX.BE00.SIZE^$FFFF
>STYA ZPQuickPtr3
jsr Kernel.Move
lda RRAMWRAMBNK2
lda RRAMWRAMBNK2
>LDYAI A2osX.D002
>STYA ZPQuickPtr1
>LDYAI $D000
>STYA ZPQuickPtr2
>LDYAI A2osX.D002.SIZE^$FFFF
>STYA ZPQuickPtr3
jsr Kernel.Move
lda RRAMWRAMBNK1
lda RRAMWRAMBNK1
>LDYAI A2osX.D001
>STYA ZPQuickPtr1
>LDYAI $D000
>STYA ZPQuickPtr2
>LDYAI A2osX.D001.SIZE^$FFFF
>STYA ZPQuickPtr3
jsr Kernel.Move
>LDYAI A2osX.E000
>STYA ZPQuickPtr1
>LDYAI $E000
>STYA ZPQuickPtr2
>LDYAI A2osX.E000.SIZE^$FFFF
>STYA ZPQuickPtr3
jsr Kernel.Move
>LDYAI D.STACK.TOP
>STYA pStack init Soft Stack
sta CLRALTZP Make MAIN ZP is enabled for X.PRINT.F
lda RROMBNK1 Make sure ROM is enabled for X.PRINT.F
cli
lda #6
sta A2osX.HZ
pha push HZ
>LDAXI MSG.HZ
jsr PrintCStrAX
jsr CPU.Init
>LDAXI MSG.K.INIT
jsr PrintCStrAX
sta SETALTZP
lda RRAMWRAMBNK1
lda RRAMWRAMBNK1
jsr S.IrqMgrInit
bcs *
jsr S.MemMgrInit
bcs *
jsr S.DevMgrInit
bcs *
jsr S.EvtMgrInit
bcs *
jsr S.TskMgrInit
bcs *
sta CLRALTZP Make sure MAIN ZP...
lda RROMBNK1 ... & ROM is enabled for X.PRINT.F
>LDAXI MSG.Init2.OK
jsr PrintCStrAX
sta SETALTZP
lda RRAMWRAMBNK1
lda RRAMWRAMBNK1
>DEBUGOA >DEBUGOA
*-------------------------------------- *--------------------------------------
* Kernel Stage 3 * Kernel Stage 3
*-------------------------------------- *--------------------------------------
Kernel.Init3 ldx #DEVMGR.SELECT jsr Kernel.Init3
jsr pDevJmp >DEBUGOA
>LDYAI MSG.Init3
>SYSCALL SYS.PSTROutYA
ldy #S.PS.hPREFIX
lda (pPs),y
>SYSCALL SYS.GetMemPtrA
>PUSHYA
>LDYAI MSG.Prefix
>SYSCALL SYS.PSTROutYA
>PUSHWI STARTUP.CMDLINE
>LDYAI MSG.Startup
>SYSCALL SYS.PSTROutYA
>LDYAI STARTUP.CMDLINE
>SYSCALL SYS.CreateProcessYA
bcs .9
>LDYAI MSG.Init3.OK
>SYSCALL SYS.PSTROutYA
>LDYAI TskMgr.Table
>STYA pPs
jmp S.KernelRun
.9 >PUSHA
>LDYAI MSG.StartupErr
>SYSCALL SYS.PSTROutYA
bra *
*--------------------------------------
Kernel.Move ldy #0
.1 inc ZPQuickPtr3
bne .2
inc ZPQuickPtr3+1
beq .9
.2 lda (ZPQuickPtr1),y
sta (ZPQuickPtr2),y
iny
bne .1
inc ZPQuickPtr1+1
inc ZPQuickPtr2+1
bne .1
.9 rts
*-------------------------------------- *--------------------------------------
.INB X.PRINTF.S .INB X.PRINTF.S
.INB SYS/KERNEL.S.CPU .INB SYS/KERNEL.S.INIT2
.INB SYS/KERNEL.S.INIT .INB SYS/KERNEL.S.INIT3
*--------------------------------------
MSG.Init2 >CSTRING "A2osX[Stage2]:Init\n"
MSG.Relocate >CSTRING "Relocating KERNEL...\n"
MSG.HZ >CSTRING "Kernel SYS Timer Set For %d0 hz Machine.\n"
MSG.K.INIT >CSTRING "Kernel Setup...\n"
MSG.Init2.OK >CSTRING "A2osX[Stage2]:Complete.\n"
*--------------------------------------
MSG.Init3 >PSTRING "A2osX[Stage3]:Init\n"
MSG.Prefix >PSTRING "Prefix:%S\n"
MSG.Startup >PSTRING "Executing Kernel Startup Script...\nCmd:%S\n"
MSG.StartupErr >PSTRING "Failed : [$%h]\n"
MSG.Init3.OK >PSTRING "A2osX[Stage3]:Complete.\n"
*--------------------------------------
STARTUP.CMDLINE >PSTRING "${A2OSX}SBIN/SHELL ${A2OSX}A2osX.STARTUP"
*-------------------------------------- *--------------------------------------
* Global Page * Global Page
*-------------------------------------- *--------------------------------------
@ -243,6 +76,9 @@ A2osX.E000 .EQ *
.INB SYS/KERNEL.S.LIB .INB SYS/KERNEL.S.LIB
.INB SYS/KERNEL.S.TSK .INB SYS/KERNEL.S.TSK
.INB SYS/KERNEL.S.PS .INB SYS/KERNEL.S.PS
*--------------------------------------
.INB SYS/KERNEL.S.PFT
.INB SYS/KERNEL.S.FIL
*-------------------------------------- *--------------------------------------
* Make sure KERNEL.S.DEV is the last one * Make sure KERNEL.S.DEV is the last one
*-------------------------------------- *--------------------------------------

60
_/MidPoint.bas.txt Normal file
View File

@ -0,0 +1,60 @@
PR#3
NEW
1000 GR
1010 COLOR = 12 : X1% = 3 : Y1% = 0 : X2% = 39 : Y2% = 17
1020 GOSUB 2000
1030 COLOR = 13 : X1% = 2 : Y1% = 1 : X2% = 39 : Y2% = 32
1040 GOSUB 2000
1050 COLOR = 14 : X1% = 1 : Y1% = 2 : X2% = 29 : Y2% = 39
1060 GOSUB 2000
1070 COLOR = 15 : X1% = 0 : Y1% = 3 : X2% = 15 : Y2% = 39
1080 GOSUB 2000
1110 COLOR = 8 : X1% = 36 : Y1% = 0 : X2% = 0 : Y2% = 17
1120 GOSUB 2000
1130 COLOR = 9 : X1% = 37 : Y1% = 1 : X2% = 0 : Y2% = 32
1140 GOSUB 2000
1150 COLOR = 10 : X1% = 38 : Y1% = 2 : X2% = 26 : Y2% = 39
1160 GOSUB 2000
1170 COLOR = 11 : X1% = 39 : Y1% = 3 : X2% = 33 : Y2% = 39
1180 GOSUB 2000
1999 END
2000 VTAB 21 : PRINT "X1=";X1%;" Y1=";Y1%;" X2=";X2%;" Y2=";Y2%
2010 DX% = X2% - X1%
2020 IF DX% = 0 Then VLIN Y1%,Y2% At X1% : RETURN
2030 IF DX% < 0 Then T% = X1% : X1% = X2% : X2% = T% : T% = Y1% : Y1% = Y2% : Y2% = T% : DX% = -DX%
2040 DY% = Y2% - Y1%
2050 IF DY% = 0 Then HLIN X1%,X2% At Y1% : RETURN
2060 IF DY% < 0 Then IY% = -1 : DY% = - DY% : GOTO 2100
2070 IY% = 1
2100 PLOT X1%,Y1%
2110 IF DX% > DY% GOTO 3000
2120 IF DX% < DY% GOTO 4000
2200 IF X1% = X2% THEN RETURN
2210 X1% = X1% + 1
2220 Y1% = Y1% + IY%
2230 PLOT X1%,Y1%
2240 GOTO 2200
3000 IE% = 2 * DY% : D% = IE% - DX% : INE% = 2 * (DY% - DX%)
3010 IF X1% = X2% THEN RETURN
3020 IF D% > 0 THEN D% = D% + INE% : Y1% = Y1% + IY% : GOTO 3040
3030 D% = D% + IE%
3040 X1% = X1% + 1
3050 PLOT X1%,Y1%
3060 GOTO 3010
4000 IE% = 2 * DX% : D% = IE% - DY% : INE% = 2 * (DX% - DY%)
4010 IF Y1% = Y2% THEN RETURN
4020 IF D% > 0 THEN D% = D% + INE% : X1% = X1% + 1 : GOTO 4040
4030 D% = D% + IE%
4040 Y1% = Y1% + IY%
4050 PLOT X1%,Y1%
4060 GOTO 4010