Mercurial > hg > Members > kono > nitros9-code
changeset 1582:e19a38f50c3a
More commments added
author | boisy |
---|---|
date | Fri, 21 May 2004 12:50:04 +0000 |
parents | c35df03d98db |
children | 2d73cd04596b |
files | level1/modules/ccio.asm level1/modules/co32.asm level1/modules/co80.asm |
diffstat | 3 files changed, 165 insertions(+), 147 deletions(-) [+] |
line wrap: on
line diff
--- a/level1/modules/ccio.asm Fri May 21 03:18:56 2004 +0000 +++ b/level1/modules/ccio.asm Fri May 21 12:50:04 2004 +0000 @@ -54,7 +54,7 @@ u0050 rmb 1 u0051 rmb 1 WrChar rmb 1 -u0053 rmb 2 +CoInUse rmb 2 u0055 rmb 6 u005B rmb 2 u005D rmb 2 @@ -75,7 +75,8 @@ u006F rmb 1 u0070 rmb 1 trulocas rmb 1 -SubEntry rmb 6 +CoEnt equ . +GRFOEnt rmb 6 IBufHead rmb 1 IBufTail rmb 1 u007A rmb 128 @@ -103,10 +104,11 @@ * CC = carry set on error * B = error code * -Init stu >D.KbdSta store devmem ptr - clra - leax <u001D,u - ldb #$5D +Init stu >D.KbdSta store devmem ptr + clra clear A + leax V.SCF,u point to memory after V.SCF +* leax <u001D,u + ldb #$5D get counter L002E sta ,x+ clear mem decb bne L002E @@ -159,8 +161,8 @@ beq Put2Bed if so, buffer is empty, branch to sleep abx X now points to curr char lda ,x get char - bsr L009D - stb <IBufTail,u + bsr L009D check for tail wrap + stb <IBufTail,u store updated tail andcc #^(IRQMask+Carry) unmask IRQ rts @@ -177,6 +179,7 @@ bcc Read branch if so coma rts +* Check if we need to wrap around tail pointer to zero L009D incb cmpb #$7F bls L00A3 @@ -244,7 +247,7 @@ ldb <IBufHead,u leax <u007A,u abx - lbsr L009D + lbsr L009D check for tail wrap cmpb <IBufTail,u beq L012F stb <IBufHead,u @@ -529,21 +532,22 @@ * CC = carry set on error * B = error code * -Write ldb <u0025,u - bne L03A3 - sta <WrChar,u - cmpa #C$SPAC - bcc L038E - cmpa #$1E escape sequence - bcc L03B8 - cmpa #$0F - lbcc L063B - cmpa #C$BELL - lbeq Ding ring bell -L038E lda <u0053,u -L0391 ldb #$03 offset into subroutine -L0393 leax <SubEntry,u get subroutine entry pointer in X - ldx a,x +Write ldb <u0025,u are we in the process of getting parameters? + bne L03A3 yes, go process + sta <WrChar,u save character to write + cmpa #C$SPAC space or higher? + bcc GoCo yes, normal write + cmpa #$1E escape sequence $1E or $1F? + bcc L03B8 yes, go process + cmpa #$0F ?? + lbcc L063B branch if higher or same + cmpa #C$BELL bell? + lbeq Ding if so, ring bell +* Here we call the Co-module to write the character +GoCo lda <CoInUse,u get CO32/CO80 flag +CoWrite ldb #$03 we want to write +CallCo leax <CoEnt,u get base pointer to CO-entries + ldx a,x get pointer to CO32/CO80 beq NoIOMod branch if no module lda <WrChar,u get character to write L039D jmp b,x call i/o subroutine @@ -551,15 +555,17 @@ ldb #E$MNF rts -L03A3 cmpb #$02 - beq L03B0 - sta <u0029,u - clr <u0025,u +* Parameter handler +L03A3 cmpb #$02 two parameters left? + beq L03B0 branch if so + sta <u0029,u else store in VD.NChar + clr <u0025,u clear parameter counter (?) jmp [<u0026,u] -L03B0 sta <u0028,u - dec <u0025,u +L03B0 sta <u0028,u store in VD.NChr2 + dec <u0025,u decrement parameter counter (?) clrb rts + L03B8 beq L03C5 leax <L03C7,pcr L03BD ldb #$01 @@ -567,8 +573,10 @@ stb <u0025,u L03C5 clrb rts + L03C7 ldb #$03 lbra L055F + L03CC pshs x,a stb <u002F,u lda >PIA1Base+2 @@ -780,24 +788,25 @@ cmpa #SS.SLGBf beq SSSLGBF cmpa #SS.KySns - bne L055D + bne CoGetStt ldd R$X,x beq L0558 ldb #$FF L0558 stb <u006C,u L055B clrb L055C rts -L055D ldb #$09 + +CoGetStt ldb #$09 co-module setstat L055F pshs b - lda <u0053,u - lbsr L0393 + lda <CoInUse,u get Co-module in use + lbsr CallCo puls a bcc L055B - tst <SubEntry,u + tst <GRFOEnt,u GRFO linked? beq L055C tfr a,b - clra - lbra L0393 + clra GRFO address offset in statics + lbra CallCo call it * Reserve an additional graphics buffer (up to 2) SSAAGBF ldb <u0031,u @@ -852,25 +861,25 @@ bne GoCO32 branch if so clrb true lower case FALSE GoCO32 stb <trulocas,u save flag for later - lda #$02 + lda #$02 CO32 is loaded bit ldx #$2010 32x16 pshs u,y,x,a leax >CO32,pcr bra L05F4 -GoCO80 lda #$04 +GoCO80 lda #$04 'CO80 is loaded' bit ldx #$5018 80x24 pshs u,y,x,a leax >CO80,pcr -L05F4 bsr L0601 +L05F4 bsr L0601 load co-module if not already loaded puls u,y,x,a bcs L0600 stx <ScreenX,u save screen size - sta <u0053,u + sta <CoInUse,u current module in use? ($02=CO32, $04=C080) L0600 rts -L0601 bita <u0070,u - beq L0608 -L0606 clrb - rts +L0601 bita <u0070,u module loaded? + beq L0608 branch if not +L0606 clrb else clear carry + rts and return L0608 pshs y,x,a lbsr LinkSub bcc L061F branch if link was successful @@ -881,12 +890,12 @@ bcc L061F puls y,x,a lbra NoIOMod -L061F leax <SubEntry,u +L061F leax <CoEnt,u get base pointer to CO-entries lda ,s get A off stack - sty a,x + sty a,x save off CO32/CO80 entry point puls y,x,a - ldb #$00 - lbra L0393 + ldb #$00 co-module init offset + lbra CallCo call it * Link to subroutine LinkSub pshs u @@ -896,10 +905,10 @@ L0637 fdb $0055,$aaff -L063B cmpa #$15 - bcc L0664 - cmpa #$0F - beq L06B4 +L063B cmpa #$15 GRFO-handled code? + bcc GoGrfo branch if so + cmpa #$0F display graphics code? + beq Do0F branch if so suba #$10 bsr L065B bcs L0663 @@ -915,20 +924,22 @@ L0660 comb ldb #E$NotRdy L0663 rts -L0664 bsr L065B + +GoGrfo bsr L065B bcs L0663 - ldx <SubEntry,u - bne L0681 - pshs y,a + ldx <GRFOEnt,u get GRFO entry point + bne L0681 branch if not zero + pshs y,a else preserve regs bne L067F - leax >GRFO,pcr - bsr LinkSub - bcc L067B - puls pc,y,a -L067B sty <SubEntry,u -L067F puls y,a -L0681 clra - lbra L0391 + leax >GRFO,pcr get pointer to name string + bsr LinkSub link to GRFO + bcc L067B branch if ok + puls pc,y,a else exit with error +L067B sty <GRFOEnt,u save module entry pointer +L067F puls y,a restore regs +L0681 clra A = GRFO address offset in statics + lbra CoWrite + L0685 pshs u ldd #6144+256 os9 F$SRqMem @@ -952,11 +963,12 @@ bcs L06B3 clrb L06B3 rts -L06B4 leax <L06BC,pcr + +Do0F leax <DispGfx,pcr ldb #$02 lbra L03BF -L06BC ldb <u0031,u +DispGfx ldb <u0031,u bne L06D1 bsr L0685 bcs L06EF @@ -977,6 +989,7 @@ comb ldb #E$BMode L06EF rts + L06F0 tsta beq L0710 ldd #$C003 @@ -1014,6 +1027,8 @@ L0742 fcb $c0,$30,$0c,$03 L0746 fcb $80,$40,$20,$10,$08,$04,$02,$01 + +* I Think this is code fcb $30,$8C,$03,$16,$fC,$69,$6f,$C8,$28 fcb $A6,$C8,$24,$2B,$03,$6C,$C8,$28,$16 fcb $FF,$6F,$30,$C8,$35,$10,$8E,$00,$00 @@ -1058,7 +1073,9 @@ std <u0045,u rts +* * Ding - tickle CoCo's PIA to emit a sound +* Ding pshs b,a lda >PIA0Base+1 ldb >PIA0Base+3 @@ -1073,9 +1090,9 @@ sta >PIA1Base+3 ldb #$0A L07E6 lda #$FE - bsr L0800 + bsr DingDuration lda #$02 - bsr L0800 + bsr DingDuration decb bne L07E6 puls a @@ -1085,8 +1102,8 @@ stb >PIA0Base+3 puls pc,b,a -L0800 sta >PIA1Base -* some type of settle delay +DingDuration + sta >PIA1Base lda #128 L0805 inca bne L0805
--- a/level1/modules/co32.asm Fri May 21 03:18:56 2004 +0000 +++ b/level1/modules/co32.asm Fri May 21 12:50:04 2004 +0000 @@ -19,6 +19,7 @@ ifp1 use defsfile + use co32defs endc tylg set Systm+Objct @@ -43,7 +44,7 @@ Term pshs y,x pshs u save U ldd #$0200 32x16 VDG memory size - ldu <$1D,u get pointer to memory + ldu <VD.ScrnA,u $1D get pointer to memory os9 F$SRtMem return to system puls u restore U ldb <$70,u @@ -52,34 +53,34 @@ * Init Init pshs y,x save regs lda #$AF - sta <$2C,u save default color cursor + sta <VD.CColr,u $2C save default color cursor pshs u save static ptr - ldd #$0300 allocate 768 bytes for now + ldd #768 allocate 768 bytes for now os9 F$SRqMem get it tfr u,d put ptr in D tfr u,x and X bita #$01 odd page? beq L0052 branch if not - leax >$0100,x else move X up 256 bytes + leax >256,x else move X up 256 bytes bra L0056 and return first 256 bytes -L0052 leau >$0200,u else move X up 512 bytes -L0056 ldd #$0100 and return last 256 bytes +L0052 leau >512,u else move X up 512 bytes +L0056 ldd #256 and return last 256 bytes os9 F$SRtMem free it! puls u restore static ptr - stx <$1D,u save VDG screen memory + stx <VD.ScrnA,u $1D save VDG screen memory pshs y leay -$0E,y clra clrb jsr [<$5B,u] puls y - stx <$21,u - leax >$0200,x - stx <$1F,u - lda #$60 - sta <$23,u - sta <$2B,u - lbsr ClrScrn + stx <VD.CrsrA,u $21 save start cursor position + leax >512,x point to end of screen + stx <VD.ScrnE,u $1F save it + lda #$60 get default character + sta <VD.CChar,u $23 put character under the cursor + sta <VD.Chr1,u $2B only referenced here ?? + lbsr ClrScrn clear the screen ldb <$70,u orb #$02 set to CO32 found (?) L0086 stb <$70,u @@ -93,7 +94,7 @@ bmi L00D0 cmpa #$1F byte $1F? bls Dispatch branch if lower or same - ldb <$71,u + ldb <VD.CFlag,u $71 beq L00B0 cmpa #$5E bne L00A0 @@ -123,27 +124,27 @@ bcs L00CE suba #$40 L00CE eora #$40 -L00D0 ldx <$21,u +L00D0 ldx <VD.CrsrA,u $21 sta ,x+ - stx <$21,u - cmpx <$1F,u + stx <VD.CrsrA,u $21 + cmpx <VD.ScrnE,u $1F bcs L00DF - bsr SScrl -L00DF bsr ShowCrsr + bsr SScrl if at end of screen, scroll it +L00DF bsr ShowCrsr ends with a CLRB/RTS anyhow * no operation entry point NoOp clrb rts -SScrl ldx <$1D,u - leax <$20,x +SScrl ldx <VD.ScrnA,u $1D + leax <32,x L00E9 ldd ,x++ - std <-$22,x - cmpx <$1F,u + std <-34,x + cmpx <VD.ScrnE,u $1F bcs L00E9 - leax <-$20,x - stx <$21,u - lda #$20 + leax <-32,x + stx <VD.CrsrA,u $21 + lda #32 ldb #$60 L00FD stb ,x+ deca @@ -184,10 +185,10 @@ tfr x,d andb #$E0 stb <$22,u -ShowCrsr ldx <$21,u get cursor address +ShowCrsr ldx <VD.CrsrA,u $21 get cursor address lda ,x get char at cursor position - sta <$23,u save it - lda <$2C,u get cursor character + sta <VD.CChar,u $23 save it + lda <VD.CColr,u $2C get cursor character beq L014D branch if none L014B sta ,x else turn on cursor L014D clrb @@ -195,30 +196,30 @@ * $0A - cursor down (line feed) CurDown bsr HideCrsr hide cursor - leax <$20,x move X down one line - cmpx <$1F,u at end of screen? + leax <32,x move X down one line + cmpx <VD.ScrnE,u $1F at end of screen? bcs L0162 branch if not - leax <-$20,x else go back up one line + leax <-32,x else go back up one line pshs x save X bsr SScrl and scroll the screen puls x restore pointer -L0162 stx <$21,u save cursor pointer +L0162 stx <VD.CrsrA,u $21 save cursor pointer bra ShowCrsr show cursor * $08 - cursor left CurLeft bsr HideCrsr hide cursor - cmpx <$1D,u compare against start of screen + cmpx <VD.ScrnA,u $1D compare against start of screen bls L0173 ignore it if at the screen start leax -$01,x else back up one - stx <$21,u save updated pointer + stx <VD.CrsrA,u $21 save updated pointer L0173 bra ShowCrsr and show cursor * $06 - cursor right CurRght bsr HideCrsr hide cursor leax $01,x move to the right - cmpx <$1F,u compare against end of screen + cmpx <VD.ScrnE,u $1F compare against end of screen bcc L0181 if past end, ignore it - stx <$21,u else save updated pointer + stx <VD.CrsrA,u $21 else save updated pointer L0181 bra ShowCrsr and show cursor * $0B - erase to end of screen @@ -229,20 +230,20 @@ ClrScrn bsr CurHome home cursor L0189 lda #$60 get default char L018B sta ,x+ save at location - cmpx <$1F,u end of screen? + cmpx <VD.ScrnE,u $1F end of screen? bcs L018B branch if not bra ShowCrsr now show cursor * $01 - home cursor CurHome bsr HideCrsr hide cursor - ldx <$1D,u get pointer to screen - stx <$21,u save as new cursor position + ldx <VD.ScrnA,u $1D get pointer to screen + stx <VD.CrsrA,u $21 save as new cursor position bra ShowCrsr and show it * Hides the cursor from the screen * Exit: X = address of cursor -HideCrsr ldx <$21,u get address of cursor in X - lda <$23,u get value of char under cursor +HideCrsr ldx <VD.CrsrA,u $21 get address of cursor in X + lda <VD.CChar,u $23 get value of char under cursor sta ,x put char in place of cursor clrb must be here, in general, for [...] BRA HideCrsr rts @@ -252,10 +253,10 @@ leax <L01AF,pcr bra L01E5 -L01AF lda <$29,u get next char +L01AF lda <VD.NChar,u $29 get next char suba #C$SPAC take out ASCII space bne L01BB branch if not zero - sta <$2C,u else save cursor color zero (no cursor) + sta <VD.CColr,u $2C else save cursor color zero (no cursor) bra HideCrsr and hide cursor L01BB cmpa #$0B greater than $0B? bge L014D yep, just ignore byte @@ -274,8 +275,8 @@ lsla lsla ora #$8F -L01D7 sta <$2C,u save new cursor - ldx <$21,u get cursor address +L01D7 sta <VD.CColr,u $2C save new cursor + ldx <VD.CrsrA,u $21 get cursor address lbra L014B branch to save cursor in X * $02 XX YY - move cursor to col XX-32, row YY-32 @@ -287,17 +288,17 @@ rts DoCurXY bsr HideCrsr hide cursor - ldb <$29,u get ASCII Y-pos + ldb <VD.NChar,u $29 get ASCII Y-pos subb #C$SPAC take out ASCII space lda #32 go down mul multiply it - addb <$28,u add in X-pos + addb <VD.NChr2,u $28 add in X-pos adca #$00 subd #C$SPAC take out another ASCII space - addd <$1D,u add top of screen address - cmpd <$1F,u at end of the screen? + addd <VD.ScrnA,u $1D add top of screen address + cmpd <VD.ScrnE,u $1F at end of the screen? lbcc L014D exit if off the screen - std <$21,u otherwise save new cursor address + std <VD.CrsrA,u $21 otherwise save new cursor address lbra ShowCrsr and show cursor * $04 - erase to end of line @@ -313,7 +314,7 @@ DelLine lbsr Retrn do a CR ldb #32 line length L0223 lda #$60 get default character - ldx <$21,u get cursor address + ldx <VD.CrsrA,u $21 get cursor address L0228 sta ,x+ fill screen line with 'space' decb decrement bne L0228 and branch if not end @@ -321,10 +322,10 @@ * $09 - cursor up CurUp lbsr HideCrsr hide cursor - leax <-$20,x move X up one line - cmpx <$1D,u compare against start of screen + leax <-32,x move X up one line + cmpx <VD.ScrnA,u $1D compare against start of screen bcs L023E branch if we went beyond - stx <$21,u else store updated X + stx <VD.CrsrA,u $21 else store updated X L023E lbra ShowCrsr and show cursor * $0E - switch screen to alphanumeric mode @@ -345,16 +346,16 @@ rts * SS.AlfaS getstat -Rt.AlfaS ldd <$1D,u - std $04,x - ldd <$21,u - std $06,x - lda <$50,u +Rt.AlfaS ldd <VD.ScrnA,u $1D memory address of buffer + std R$X,x + ldd <VD.CrsrA,u $21 + std R$Y,x + lda <VD.Caps,u $50 save caps lock status in A and exit bra L02BA * SS.Cursr getstat -Rt.Cursr ldd <$21,u - subd <$1D,u +Rt.Cursr ldd <VD.CrsrA,u $21 + subd <VD.ScrnA,u $1D pshs b,a clra andb #$1F @@ -370,8 +371,8 @@ andb #$0F only 16 line to a screen addb #$20 std $06,x - ldb <$71,u - lda <$23,u + ldb <VD.CFlag,u $71 + lda <VD.CChar,u $23 bmi L02BA cmpa #$60 bcc L02A5
--- a/level1/modules/co80.asm Fri May 21 03:18:56 2004 +0000 +++ b/level1/modules/co80.asm Fri May 21 12:50:04 2004 +0000 @@ -36,14 +36,14 @@ fcb edition start equ * -Init lbra L0022 -Write lbra L0083 -GetStat lbra L0054 -SetStat lbra L007F -Term lbra L004A + lbra Init + lbra Write + lbra GetStat + lbra SetStat + lbra Term * Init -L0022 ldx #$FF78 +Init ldx #$FF78 lda #$06 sta $01,x sta ,x @@ -61,14 +61,14 @@ orb #$04 bra L004F * Term -L004A ldb <$70,u +Term ldb <$70,u andb #$FB L004F stb <$70,u clrb rts * GetStat -L0054 cmpa #$25 - bne L007F +GetStat cmpa #$25 + bne SetStat ldy $06,y clra ldb <$58,u @@ -89,11 +89,11 @@ L007D clrb rts * SetStat -L007F ldb #E$UnkSvc +SetStat ldb #E$UnkSvc coma rts * Write -L0083 ldx #$FF78 +Write ldx #$FF78 cmpa #$0E bcs L00B6 cmpa #$1E