<< Home | About Forth | About TurboForth | Download | Language Reference | Resources | Tutorials | YouTube >>
; _____ _ _ _ _ _ _ _ ; |_ _| (_) | (_) | (_) | | (_) ; | | _ __ _| |_ _ __ _| |_ ___ __ _| |_ _ ___ _ __ ; | | | '_ \| | __| |/ _` | | / __|/ _` | __| |/ _ \| '_ \ ; _| |_| | | | | |_| | (_| | | \__ \ (_| | |_| | (_) | | | | ; |_____|_| |_|_|\__|_|\__,_|_|_|___/\__,_|\__|_|\___/|_| |_| ; this code runs at startup to bring TurboForth to life ; general initialisation of RAM variables etc init mov @sumode,r3 ; save graphics startup mode value li r0,>0190 ; turn the screen off while we set things up bl @_vwtr ; initialise SAMS card if fitted li r12,>1e00 ; sams CRU base sbo 0 ; enable access to mapper registers sbz 1 ; disable mapping while we set it up li r0,>4004 ; register for >2000 li r1,>f8f8 ; map bank >f8 into >2000 mov r1,*r0+ ; do it li r1,>f9f9 ; map bank >f9... mov r1,*r0+ ; ...into >3000 ; now set up the banks for high memory... li r0,>4014 ; register address li r1,>fafa ; register value li r2,6 ; loop count sams mov r1,*r0+ ; write to the register ai r1,>0101 ; next register value dec r2 ; finished? jne sams ; loop if not sbo 1 ; enable mapping sbz 0 ; lock the mapper registers ; clear variables area cva li r0,>a000 ; start address li r1,prgtop ; end address clrlop clr *r0+ ; clear a word c r0,r1 ; finished? jne clrlop ; repeat if not mov r3,@sumode ; restore start up graphics mode mov @>83c0,@seed ; initialise random number seed ; set up boot file name (DSK1.BLOCKS) li r0,bootfn ; address of boot filename li r1,pabnln ; destination li r2,12 ; 12 bytes to copy bootlp movb *r0+,*r1+ ; copy a byte dec r2 ; finished? jne bootlp ; repeat if not ; initialise console stuff li r0,cursrd ; address of cursor delay clr *r0+ ; initialise cursor delay seto *r0+ ; enable screen scrolling clr *r0+ ; zero current x coordinate clr *r0+ ; zero current y coordinate ; initialise vdp environment ; disable interrupts, sound and sprites... li r0,>8000 ; no sprite motion ; no auto sound ; no quit key mov r0,@>83c2 ; see page 4 smart programmer ; oct 86-vol 2 issue 5 ; load character sets... chrset ; initialise control characters to something visible ; we do this by writing the TF logo to ALL 256 characters ; later we define the capital and lower case character sets. cclop li r0,>800 ; address of ascii 0 li r7,123 ; number of characters to write cclop1 li r1,logo ; source (TF logo character) li r2,8 ; bytes to copy bl @_vmbw0 ; write them ai r0,8 ; next character dec r7 ; decrement count jne cclop1 ; loop if not finished ; load small ascii character set li r0,>08ff ; vdp address of upper case A mov r0,@fac ; vdp address for small capitals blwp @gpllnk ; load small capitals character set data >0018 ; gpl command code ; load true lower case characters li r0,>b08 ; vdp address of lower case a li r1,lowcas ; source li r2,26*8 ; count bl @_vmbw0 ; write true lower case char set ; load miscellaneous characters from data list li r1,lbrace ; address of list lmiscl clr r0 movb *r1+,r0 ; get ascii code jeq doinv ; exit if end of list srl r0,5 ; move to low byte and multiply by 8 ai r0,>800 ; add pattern table base address li r2,8 ; number of bytes to write bl @_vmbw0 ; write to vdp jmp lmiscl ; initialise inverse characters ; ascii codes 144 to 218 are inverse of 48 to 122 doinv li r13,>900 ; vdp source li r6,>c00 ; vdp destination li r14,728 ; count invlop mov r13,r0 ; get source address in r0 for VDP ops bl @_vsbr ; go read the vdp data (result in R1) inv r1 ; invert it mov r6,r0 ; load destination address bl @_vsbw0 ; write r1 to destination address inc r13 ; advance source address inc r6 ; advance destination address dec r14 ; decrement counter jne invlop ; loop until finished bl @csrdef ; define cursor and edge characters ; (see 1-11-Editor.a99) ; Copy PAD routines into PAD RAM cpypad bl @rstsp ; use the restore routine in 1-06-Blocks.a99 ; general initialisation - initialised from an address/data list li r0,adrlst ; pointer to address/data table li r2,40 ; number of items to load ( was 33) nxtdat mov *r0+,r1 ; get address to load mov *r0+,*r1 ; load the address with data dec r2 ; finished? jne nxtdat ; loop if not ; set up data and return stacks... li stack,dstack ; data stack pointer li rstack,retstk ; return stack pointer clr @spcsvc ; clear speech service routine pointer li r12,afteri ; force return point in bank 0 b @retB0 ; return to caller in bank 0 ; initialisation data adrlst data base, 10 ; default number base data keydev, 50 ; default keyboard scan code data ymax, 24 ; 24 rows data latest, lastwd ; last word in the dictionary data here, prgtop ; start of compiled code area data s0, dstack ; start of data stack data rs0, retstk ; start of return stack data ffailm, >2000 ; first free address in low memory data ffaihm, himem ; first free address in high memory data >fffc, wkspc ; pointer to workspace for load-interrupt data >fffe, startB0 ; pointer to start of code for load-interrupt data retbnk, >6002 ; return to bank 1 data tibsiz, 80 ; 80 characters input buffer length data tibadr, tib ; location of input buffer ; (defined in 0-23-System.a99) data doboot, 1 ; booting flag (default:on) data sdelim, '"'*256 ; default string delimiter character data totblk, blocks ; default number of block buffers available data intvec, intgo ; default vector for interpret data blkvec, block2 ; default vector for block data numvec, numbr1 ; default vector for number data fndvec, vfind ; default vector for find data falloc, f1pab ; address of pab for 1st file data falloc+2, f2pab ; address of pab for 2nd file data falloc+4, f3pab ; address of pab for 3rd file data gplvec, gpllnk ; pointer to gpllnk data padvec, rstsp ; pointer to scratchpad code in bank 1 data _WARN, -1 ; default value for warn data isr, runisr ; pointer to isr launcher in pad data wp, >8300 ; initial workspace pointer data pnext, _next ; address of next data dsrvec, dsrlnk ; load pointer to DSRLNK vector data pdocon, docon ; load pointer to DOCON's executable code data pcreate, crtime ; load pointer to CREATE's executable code data kdel, >ed1e ; auto-repeat delay for block editor ; VDP block buffer addresses for disk block IO... data blk0+2, bufadd+>1400 ; vdp address of buffer 0 data blk0+6, bufadd+>1000 ; vdp address of buffer 1 data blk0+10, bufadd+>c00 ; vdp address of buffer 2