<< 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 ; initialise block file system clr @blknum ; clear current block number li r0,blkvdp ; address of data list li r1,blk0 ; destination li r2,6 ; loop count init1 clr *r1+ ; clear blk indicator (0=unassigned) mov *r0+,*r1+ ; load blk0 address dec r2 ; finished? jne init1 ; loop if not ; 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 li r0,>0500 ; keyboard device/scan mode movb r0,@keydev ; normal (upper/lower case) key scan mode ; 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... ; 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 r3,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 r3 ; 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 curly { | } ~ characters, which for some reason are not loaded by the ; console li r0,>bd8 ; vdp destination address li r1,lbrace ; source li r2,4*8 ; count bl @_vmbw0 ; load slashed 0 li r0,>981 li r1,zerochr li r2,6 bl @_vmbw0 ; initialise inverse characters ; ascii codes 144 to 218 are inverse of 48 to 122 doinv li r5,>900 ; vdp source li r6,>c00 ; vdp destination li r4,728 ; count invlop mov r5,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 r5 ; advance source address inc r6 ; advance destination address dec r4 ; 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 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,33 ; number of items to load 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 xmax, 40 ; 40 column line 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