diff options
Diffstat (limited to 'docs/os12/mdfs.net/Docs/Comp/BBC/OS1-20/E20E')
-rw-r--r-- | docs/os12/mdfs.net/Docs/Comp/BBC/OS1-20/E20E | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/docs/os12/mdfs.net/Docs/Comp/BBC/OS1-20/E20E b/docs/os12/mdfs.net/Docs/Comp/BBC/OS1-20/E20E new file mode 100644 index 0000000..4f0b4b6 --- /dev/null +++ b/docs/os12/mdfs.net/Docs/Comp/BBC/OS1-20/E20E @@ -0,0 +1 @@ +OS SERIES VI
GEOFF COX
*************************************************************************
* *
* SAVE/LOAD ENTRY *
* *
* *
*************************************************************************
**************: clear osfile control block workspace ********************
E20E PHA ;push A
E20F LDA #&00 ;A=0
E211 STA &02EE,X ;clear osfile control block workspace
E214 STA &02EF,X ;
E217 STA &02F0,X ;
E21A STA &02F1,X ;
E21D PLA ;get back A
E21E RTS ;and exit
*********** shift through osfile control block **************************
E21F STY &E6 ;&E6=Y
E221 ROL ;A=A*2
E222 ROL ;*4
E223 ROL ;*8
E224 ROL ;*16
E225 LDY #&04 ;Y=4
E227 ROL ;A=A*32
E228 ROL &02EE,X ;shift bit 7 of A into shift register
E22B ROL &02EF,X ;and
E22E ROL &02F0,X ;shift
E231 ROL &02F1,X ;along
E234 BCS &E267 ;if carry set on exit then register has overflowed
;so bad address error
E236 DEY ;decrement Y
E237 BNE &E227 ;and if Y>0 then do another shift
E239 LDY &E6 ;get back original Y
E23B RTS ;and exit
*************************************************************************
* *
* *LOAD ENTRY *
* *
* *
*************************************************************************
E23C LDA #&FF ;signal that load is being performed
*************************************************************************
* *
* *SAVE ENTRY *
* *
* *
*************************************************************************
;on entry A=0 for save &ff for load
E23E STX &F2 ;store address of rest of command line
E240 STY &F3 ;
E242 STX &02EE ;x and Y are stored in OSfile control block
E245 STY &02EF ;
E248 PHA ;Push A
E249 LDX #&02 ;X=2
E24B JSR &E20E ;clear the shift register
E24E LDY #&FF ;Y=255
E250 STY &02F4 ;store im 2F4
E253 INY ;increment Y
E254 JSR &EA1D ;and call GSINIT to prepare for reading text line
E257 JSR &EA2F ;read a code from text line if OK read next
E25A BCC &E257 ;until end of line reached
E25C PLA ;get back A without stack changes
E25D PHA ;
E25E BEQ &E2C2 ;IF A=0 (SAVE) E2C2
E260 JSR &E2AD ;set up file block
E263 BCS &E2A0 ;if carry set do OSFILE
E265 BEQ &E2A5 ;else if A=0 goto OSFILE
E267 BRK ;
E268 DB &FC ;
E269 DB 'Bad Address' ;error
E274 BRK ;
*************************************************************************
* *
* OSBYTE 119 ENTRY *
* CLOSE SPOOL/ EXEC FILES *
* *
*************************************************************************
E275 LDX #&10 ;X=10 issue *SPOOL/EXEC files warning
E277 JSR &F168 ;and issue call
E27A BEQ &E29F ;if a rom accepts and issues a 0 then E29F to return
E27C JSR &F68B ;else close the current exec file
E27F LDA #&00 ;A=0
**************************************************************************
**************************************************************************
** **
** **
** *SPOOL **
** **
**************************************************************************
**************************************************************************
E281 PHP ;if A=0 file is closed so
E282 STY &E6 ;Store Y
E284 LDY &0257 ;get file handle
E287 STA &0257 ;store A as file handle
E28A BEQ &E28F ;if Y<>0 then E28F
E28C JSR OSFIND ;else close file via osfind
E28F LDY &E6 ;get back original Y
E291 PLP ;pull flags
E292 BEQ &E29F ;if A=0 on entry then exit
E294 LDA #&80 ;else A=&80
E296 JSR OSFIND ;to open file Y for output
E299 TAY ;Y=A
E29A BEQ &E310 ;and if this is =0 then E310 BAD COMMAND ERROR
E29C STA &0257 ;store file handle
E29F RTS ;and exit
E2A0 BNE &E310 ;if NE then BAD COMMAND error
E2A2 INC &02F4 ;increment 2F4 to 00
E2A5 LDX #&EE ;X=&EE
E2A7 LDY #&02 ;Y=&02
E2A9 PLA ;get back A
E2AA JMP OSFILE ;and JUMP to OSFILE
**** check for hex digit ************************************************
E2AD JSR &E03A ;look for NEWline
E2B0 JSR &E08F ;carry is set if it finds hex digit
E2B3 BCC &E2C1 ;so E2C1 exit
E2B5 JSR &E20E ;clear shift register
************** shift byte into control block ***************************
E2B8 JSR &E21F ;shift lower nybble of A into shift register
E2BB JSR &E08F ;then check for Hex digit
E2BE BCS &E2B8 ;if found then do it again
E2C0 SEC ;else set carry
E2C1 RTS ;and exit
**************; set up OSfile control block ****************************
E2C2 LDX #&0A ;X=0A
E2C4 JSR &E2AD ;
E2C7 BCC &E310 ;if no hex digit found EXIT via BAD Command error
E2C9 CLV ;clear bit 6
******************READ file length from text line************************
E2CA LDA (&F2),Y ;read next byte from text line
E2CC CMP #&2B ;is it '+'
E2CE BNE &E2D4 ;if not assume its a last byte address so e2d4
E2D0 BIT &D9B7 ;else set V and M flags
E2D3 INY ;increment Y to point to hex group
E2D4 LDX #&0E ;X=E
E2D6 JSR &E2AD ;
E2D9 BCC &E310 ;if carry clear no hex digit so exit via error
E2DB PHP ;save flags
E2DC BVC &E2ED ;if V set them E2ED explicit end address found
E2DE LDX #&FC ;else X=&FC
E2E0 CLC ;clear carry
E2E1 LDA &01FC,X ;and add length data to start address
E2E4 ADC &0200,X ;
E2E7 STA &0200,X ;
E2EA INX ;
E2EB BNE &E2E1 ;repeat until X=0
E2ED LDX #&03 ;X=3
E2EF LDA &02F8,X ;copy start adddress to load and execution addresses
E2F2 STA &02F4,X ;
E2F5 STA &02F0,X ;
E2F8 DEX ;
E2F9 BPL &E2EF ;
E2FB PLP ;get back flag
E2FC BEQ &E2A5 ;if end of command line reached then E2A5
; to do osfile
E2FE LDX #&06 ;else set up execution address
E300 JSR &E2AD ;
E303 BCC &E310 ;if error BAD COMMAND
E305 BEQ &E2A5 ;and if end of line reached do OSFILE
E307 LDX #&02 ;else set up load address
E309 JSR &E2AD ;
E30C BCC &E310 ;if error BAD command
E30E BEQ &E2A5 ;else on end of line do OSFILE
;anything else is an error!!!!
******** Bad command error ************************************
E310 BRK ;
E311 DB &FE ;error number
E312 DB 'Bad Command' ;
E31D BRK
E31E DB &FB ;
E31F DB 'Bad Key' ;
E326 BRK
*************************************************************************
* *
* *KEY ENTRY *
* *
*************************************************************************
E327 JSR &E04E ;set up key number in A
E32A BCC &E31D ;if not valid number give error
E32C CPX #&10 ;if key number greater than 15
E32E BCS &E31D ;if greater then give error
E330 JSR &E045 ;otherwise skip commas, and check for CR
E333 PHP ;save flags for later
E334 LDX &0B10 ;get pointer to top of existing key strings
E337 TYA ;save Y
E338 PHA ;to preserve text pointer
E339 JSR &E3D1 ;set up soft key definition
E33C PLA ;get back Y
E33D TAY ;
E33E PLP ;and flags
E33F BNE &E377 ;if CR found return else E377 to set up new string
E341 RTS ;else return to set null string
*************************************************************************
* *
* *FX OSBYTE *
* *
*************************************************************************
A=number
E342 JSR &E04E ;convert the number to binary
E345 BCC &E310 ;if bad number call bad command
E347 TXA ;save X
*************************************************************************
* *
* *CODE *MOTOR *OPT *ROM *TAPE *TV *
* *
*************************************************************************
;enter codes *CODE &88
*MOTOR &89
*OPT &8B
*TAPE &8C
*ROM &8D
*TV &90
E348 PHA ;save A
E349 LDA #&00 ;clear &E4/E5
E34B STA &E5 ;
E34D STA &E4 ;
E34F JSR &E043 ;skip commas and check for newline (CR)
E352 BEQ &E36C ;if CR found E36C
E354 JSR &E04E ;convert character to binary
E357 BCC &E310 ;if bad character bad command error
E359 STX &E5 ;else save it
E35B JSR &E045 ;skip comma and check CR
E35E BEQ &E36C ;if CR then E36C
E360 JSR &E04E ;get another parameter
E363 BCC &E310 ;if bad error
E365 STX &E4 ;else store in E4
E367 JSR &E03A ;now we must have a newline
E36A BNE &E310 ;if none then output an error
E36C LDY &E4 ;Y=third osbyte parameter
E36E LDX &E5 ;X=2nd
E370 PLA ;A=first
E371 JSR OSBYTE ;call osbyte
E374 BVS &E310 ;if V set on return then error
E376 RTS ;else RETURN
********* *KEY CONTINUED ************************************************
;X points to last byte of current key definitions
E377 SEC ;
E378 JSR &EA1E ;look for '"' on return bit 6 E4=1 bit 7=1 if '"'found
;this is a GSINIT call without initial CLC
E37B JSR &EA2F ;call GSREAD carry is set if end of line found
E37E BCS &E388 ;E388 to deal with end of line
E380 INX ;point to first byte of new key definition
E381 BEQ &E31D ;if X=0 buffer WILL overflow so exit with BAD KEY error
E383 STA &0B00,X ;store character
E386 BCC &E37B ;and loop to get next byte if end of line not found
E388 BNE &E31D ;if Z clear then no matching '"' found or for some
;other reason line doesn't terminate properly
E38A PHP ;else if all OK save flags
E38B SEI ;bar interrupts
E38C JSR &E3D1 ;and move string
E38F LDX #&10 ;set loop counter
E391 CPX &E6 ;if key being defined is found
E393 BEQ &E3A3 ;then skip rest of loop
E395 LDA &0B00,X ;else get start of string X
E398 CMP &0B00,Y ;compare with start of string Y
E39B BNE &E3A3 ;if not the same then skip rest of loop
E39D LDA &0B10 ;else store top of string definition
E3A0 STA &0B00,X ;in designated key pointer
E3A3 DEX ;decrement loop pointer X
E3A4 BPL &E391 ;and do it all again
E3A6 PLP ;get back flags
E3A7 RTS ;and exit
***********: set string lengths *****************************************
E3A8 PHP ;push flags
E3A9 SEI ;bar interrupts
E3AA LDA &0B10 ;get top of currently defined strings
E3AD SEC ;
E3AE SBC &0B00,Y ;subtract to get the number of bytes in strings
;above end of string Y
E3B1 STA &FB ;store this
E3B3 TXA ;save X
E3B4 PHA ;
E3B5 LDX #&10 ;and X=16
E3B7 LDA &0B00,X ;get start offset (from B00) of key string X
E3BA SEC ;
E3BB SBC &0B00,Y ;subtract offset of string we are working on
E3BE BCC &E3C8 ;if carry clear (B00+Y>B00+X) or
E3C0 BEQ &E3C8 ;result (in A)=0
E3C2 CMP &FB ;or greater or equal to number of bytes above
;string we are working on
E3C4 BCS &E3C8 ;then E3C8
E3C6 STA &FB ;else store A in &FB
E3C8 DEX ;point to next lower key offset
E3C9 BPL &E3B7 ;and if 0 or +ve go back and do it again
E3CB PLA ;else get back value of X
E3CC TAX ;
E3CD LDA &FB ;get back latest value of A
E3CF PLP ;pull flags
E3D0 RTS ;and return
***********: set up soft key definition *********************************
E3D1 PHP ;push P
E3D2 SEI ;bar interrupts
E3D3 TXA ;save X
E3D4 PHA ;push A
E3D5 LDY &E6 ;get key number
E3D7 JSR &E3A8 ;and set up &FB
E3DA LDA &0B00,Y ;get start of string
E3DD TAY ;put it in Y
E3DE CLC ;clear carry
E3DF ADC &FB ;add number of bytes above string
E3E1 TAX ;put this in X
E3E2 STA &FA ;and store it
E3E4 LDA &0268 ;check number of bytes left to remove from key buffer
;if not 0 key is being used (definition expanded so
;error. This stops *KEY 1 "*key1 FRED" etc.
E3E7 BEQ &E3F6 ;if not in use continue
E3E9 BRK ;
E3EA DB &FA ;error number
E3EB DB 'Key in use' ;
E3F5 BRK ;
E3F6 DEC &0284 ;decrement consistence flag to &FF to warn that key
;definitions are being changed
E3F9 PLA ;pull A
E3FA SEC ;
E3FB SBC &FA ;subtract &FA
E3FD STA &FA ;and re store it
E3FF BEQ &E40D ;if 0 then E40D
E401 LDA &0B01,X ;else move string
E404 STA &0B01,Y ;from X to Y
E407 INY ;
E408 INX ;
E409 DEC &FA ;for length of string
E40B BNE &E401 ;
E40D TYA ;store end of moved string(s)
E40E PHA ;
E40F LDY &E6 ;get back key number
E411 LDX #&10 ;point at top of last string
E413 LDA &0B00,X ;get this value
E416 CMP &0B00,Y ;compare it with start of new or re defined key
E419 BCC &E422 ;if less then E422
E41B BEQ &E422 ;if = then E422
E41D SBC &FB ;shift key definitions accordingly
E41F STA &0B00,X ;
E422 DEX ;point to next lowest string def
E423 BPL &E413 ;and if =>0 then loop and do it again
E425 LDA &0B10 ;else make top of key definitions
E428 STA &0B00,Y ;the start of our key def
E42B PLA ;get new end of strings
E42C STA &0B10 ;and store it
E42F TAX ;put A in X
E430 INC &0284 ;reset consistency flag
E433 PLP ;restore flags
E434 RTS ;and exit
\ No newline at end of file |