home *** CD-ROM | disk | FTP | other *** search
- ;------------------------------------------------------;
- ; Userlib library, 89 & 92+ ;
- ; Copyright 1998-1999 The Doors Team: ;
- ; Xavier VASSOR ;
- ; Cedric Couffignal ;
- ; All Right Reserved ;
- ; ;
- ; Commented by Xavier VASSOR ;
- ; ;
- ; Look at the file "sources.txt" to know what you're ;
- ; allowed to do with it ;
- ;------------------------------------------------------;
-
- include "doorsos.h"
- include "Graphlib.h"
- include "filelib.h"
- include "ziplib.h"
- xdef _library
- xdef _ti89
- xdef _ti92plus
- xdef userlib@0000 ;idle_loop ;OK
- xdef userlib@0001 ;random ;OK
- xdef userlib@0002 ;rand_seed ;OK
- xdef userlib@0003 ;exec ;OK
- xdef userlib@0004 ;FindSymEntry ;OK
- xdef userlib@0005 ;DrawCharXY ;OK
- xdef userlib@0006 ;inputstr ;OK
- xdef userlib@0007 ;getpassword ;OK
- xdef userlib@0008 ;changepass ;OK
- xdef userlib@0009 ;lockcalc ;OK
- xdef userlib@000A ;idle_hot ;OK
- xdef userlib@000B ;getfreeRAM ;OK
- xdef userlib@000C ;smallmenu ;OK
- xdef userlib@000D ;getfreearchive ;OK
- xdef userlib@000E ;set_APD ;OK
- xdef userlib@000F ;get_APD ;OK
- xdef userlib@0010 ;runprog ;OK
-
- userlib@0010:
- runprog:
- link.w a6,#-64
- move.l a2,-(sp)
- move.l d3,-(sp)
- move.l doorsos::top_estack,a2
- clr.w -62(a6)
- pea -60(a6)
- jsr doorsos::ER_catch
- move.w d0,d3
- addq.l #4,sp
- beq .L2
- move.w d3,-(a7)
- jsr doorsos::ERD_dialog
- move.l a2,doorsos::top_estack
- move.w -62(a6),d0
- beq .L3
- move.w -62(a6),-(sp)
- jsr doorsos::HeapFree
- .L3:
- move.w d3,d0
- bra .L5
- .L2:
- move.w #233,-(sp)
- jsr doorsos::push_quantum
- move.l 8(a6),-(sp)
- jsr doorsos::push_parse_text
- addq.l #6,sp
- tst.w d0
- bne .L4
- dc.w $A38E
- .L4:
- move.w doorsos::top_estack+2,d3
- sub.w a2,d3
- addq.w #2,d3
- move.w d3,-(sp)
- clr.w -(sp)
- subq.w #2,d3
- jsr doorsos::HeapAllocHigh
- move.w d0,-62(a6)
- move.w -62(a6),-(sp)
- jsr doorsos::HLock
- move.w d3,(a0)+
- move.w d3,-(sp)
- clr.w -(sp)
- pea 1(a2)
- move.l a0,-(sp)
- jsr doorsos::memcpy
- move.w -62(a6),-(sp)
- jsr doorsos::HeapUnlock
- clr.w -(sp)
- move.w -62(a6),-(sp)
- jsr doorsos::NG_execute
- move.w -62(a6),-(sp)
- jsr doorsos::HeapFree
- jsr doorsos::ER_success
- clr.w d0
- .L5:
- move.l -72(a6),d3
- move.l -68(a6),a2
- unlk a6
- rts
-
- userlib@000C
- smallmenu:
- ;params:
- ;d0 = x
- ;d1 = y
- ;d2 = nbitems
- ;a0 = liste
- ;renvoie d0-d1-d2
- movem.l d3-d7/a0-a6,-(a7)
- mainfunc:
- lea handle,a5
- lea temp,a6
- ; gets the width & height of the menu
- movem.l d2/a0,-(a7) ; saves d2/a0
- subq.w #1,d2 ; nbitem --
- clr.w d5 ; d5 = width of the menu
- \get jsr graphlib::getlength ; returns d3 = length & d4 = height
- cmp.w d3,d5 ; if (d3 <= d5)
- bge \test ; test again
- move.w d3,d5 ; else d3 = width
- \test tst.b (a0)+ ; increments a0 to make it point to the next item
- bne \test
- tst.b (a0) ; if there is a 0 char for a line separator
- bne \OK
- addq.l #1,a0 ; skip it
- \OK dbra d2,\get
- movem.l (a7)+,d2/a0 ; restores d2/a0
-
- ;**
- ; d5 = width of the text
- ; d4 = height of the text
- ; d0-d1-d2 = x-y-nbitems
- ;
- ; we calculate
- ; d6 = height of the menu
- ; d7 = width of the menu
- move.w d5,d7 ; d7 = width
- clr.l d6 ;
- move.w d4,d6 ; d6 = height
- addq.w #5,d6 ; +3 up, +2 down for each item
- addq.w #5,d7 ; +3 left, +2 right
- \small mulu d2,d6 ; item height * nbitems
-
- ; now save the background
- movem.w d0-d2,-(a7)
- lsr.w #3,d0 ; x/8 = x in bytes
- move.w d6,d3 ; d3 = d6 = menu height
- addq.w #1,d3
- move.w d7,d2 ; d2 = d7 = menu width
- lsr.w #3,d2 ; d2/8 -> width in bytes
- addq.w #2,d2 ; +2 to make sure we save all at the right&left of the menu..
- jsr graphlib::scrtomem ; save the background
- tst.w d4 ; could it be created ?
- beq created ; no -> created
-
- movem.w d0-d4,(a5) ; save d0-d4 in the array handle ( = (a5) )
- movem.w (a7),d0-d2 ; restores d0-d2
- divu d2,d6 ; d6 = height/nbitems = height of one item
- move.w d7,d2 ; d2 = width
- subq.w #2,d3 ; adjust d3
- moveq.w #1,d4 ; color = white
- bsr fill ; clear the background
- move.w d2,d4 ; d4 = d2 = width
- move.w d3,d5 ; d5 = height for graphlib::frame
- addq.w #1,d5
-
- bigcad:
- jsr graphlib::frame ; draws the frame
- movem.w (a7),d0-d2 ; restores d0-d2
- subq.w #1,d2 ; -1 for dbra
-
- debut:
- tst.b (a0) ; do we have to display a separation line
- beq line ; yes -> line
- retline:
- movem.w d0-d1/a1,-(a7)
- addq.w #2,d0 ; x += 2
- addq.w #3,d1 ; y += 3
- move.l a0,a1
- bsr Write ; display the item (a1)
- movem.w (a7)+,d0-d1/a1
-
- \test tst.b (a0)+ ; make a0 point to the next item
- bne \test
- add.w d6,d1 ; y += item height
- deb: dbra d2,debut ; display d2 items
-
- defil:
- move.w d6,d3 ; d3 = d6 = item height
- subq.w #2,d3 ; d3 -= 2
- move.w d7,(a6) ; temp = d7 = item width
- retbas:
- movem.w (a7),d0-d2 ; restore d0-d2
- move.w d2,d5 ; d5 = nbitems
- move.w (a6),d2 ; d2 = width
- subq.w #2,d2 ; width -= 2
- addq.w #1,d1 ; y += 1
- addq.w #1,d0 ; x += 1
- move.w #1,nblim ; currently selected item = 1
- inver:
- clr.w d4 ; color = video inversion
- bsr fill ; video inversion on the currently selected item
-
- Waitkey:
- move.l d0,d7 ; d7 = d0
- bsr idle_hot ; waits for a key
- exg.w d0,d7 ; d7 = d0 = keycode, d0 = d7 = old d0
- bsr fill ; video inversion on the current item
- cmp.w #KEY_UP,d7 ; UP
- beq padup
- cmp.w #KEY_DOWN,d7 ; DOWN
- beq paddown
- cmp.w #13,d7 ; Enter
- beq fin
- move.w d7,d4 ; d4 = keycode, we will see if the the user pressed [1..9] or [A..Z]
- cmp.w #$7A,d4 ; d4 > 'z' keycode value ?
- bgt esc ; yes -> esc
- cmp.w #$30,d4 ; d4 <= '0' keycode value ?
- ble esc ; yes -> esc
- cmp.w #$39,d4 ; d4 <= '9' keycode value ?
- ble \underten ; yes -> \underten
- cmp.w #10,d5 ; item < 10 ?
- blt \underten ; yes -> don't test if [A..Z] was pressed
- sub.w #$27,d4 ; keycode - $27
- \underten subi.w #$30,d4 ; keycode - '0'
- \loop cmp.w d4,d5 ; item == item corresponding to the pressed key
- beq raccourci ; yes -> raccourci
- dbra d5,\loop ; else try again for each item
- bra esc ; else -> esc
-
- padup:
- subq.w #1,nblim ; selected item --
- beq rethaut ; = 0 ? -> get down
- sub.w d6,d1 ; y -= item height
- bra inver ; video inversion on the new selected item
-
- paddown:
- cmp nblim,d5 ; nbitems == selected item ?
- beq retbas ; yes -> retbas : get back up
- addq #1,nblim ; selected item ++
- add.w d6,d1 ; y += item height
- bra inver ; video inversion on the new selected item
-
- rethaut:
- move.w d5,nblim ; current item = nbitems
- sub.w d6,d1 ; d1 -= item height
- mulu d6,d5 ; d5 = nbitems * item height = last item y
- add.w d5,d1 ; d1 += d5
- divu d6,d5 ; restores d5
- bra inver ; video inversion on the new selected item
-
- raccourci:
- move.w d4,nblim ; currently selected item = item corresponding to the pressed key
- bra esc2 ; quits
-
- moveq.w #3,d7 ; d7 = 4-1 for dbra
- fin: bsr fill ; video inversion
- move.w #2500,d5
- \losetime
- dbra d5,\losetime ; lose some time..
- dbra d7,fin ; repeats 4 times
- esc2: clr.l d6 ; -> An item has been selected
- esc: addq.l #6,a7 ; because 3 regs had been saved onto the stack
- movem.w (a5),d0-d4 ; restores d0-d4 previously saved
- jsr graphlib::memtoscr ; restores the screen
- move.w nblim,d0 ; d0 = selected item
- bye: move.w d7,d1 ; d1 = last pressed key
- move.w d6,d2 ; d2 = item selection flag
- movem.l (a7)+,d3-d7/a0-a6
- rts ; quits
-
- created: ; not enough mem to save the background
- move.w #264,d7 ; last key pressed = ESC
- moveq.l #-1,d6 ; no item was selected
- bra bye ; quits..
-
- line: move.w d2,-(a7)
- move.w d0,d2 ; x2 = x
- add.w d7,d2 ; x2 = x + item width
- jsr graphlib::horiz ; display the line
- move.w (a7)+,d2
- addq.l #1,a0 ; increment the pointer
- bra retline ; back to the main display loop
-
- fill:
- jmp graphlib::fill
-
- userlib@0000:
- ; returns d0 = keycode
-
- idle_loop:
-
- pushm.l a0-a6/d1-d7
- move.w #2,-(a7)
- jsr doorsos::OSTimerRestart
- clr.w -(a7)
- clr.l -(a7)
- jsr doorsos::GKeyIn
- addq.l #8,a7
- popm.l a0-a6/d1-d7
- rts
-
- userlib@000A:
- idle_hot:
- \again bsr idle_loop ; waits for a key press, d0 = keycode
- tst.b CALCULATOR ; are we running a 89 or a 92+ ?
- beq \hot89 ; 89 -> test the 89 hot keys
- cmp.w #274,d0 ;F7 ==> lock ; else 92+
- bne \275
- bsr lockcalc ; shuts down, asks for the password
- bra \again ; waits for a key again
- \275 cmp.w #275,d0 ; F8 ==> shut
- bne \fin
- trap #4 ; shuts down
- bra \again ; waits for a key again
- \fin rts
- \hot89 cmp.w #277,d0 ;Home ==> lock calc
- bne \266
- bsr lockcalc
- bra \again
- \266 cmp.w #266,d0 ;Mode ==> shut down
- bne \fin
- trap #4
- bra \again
-
- userlib@0009
- lockcalc:
- ; shuts down and asks for the doors pass
-
- ; Save the screen
- movem.l d0-d7/a0-a6,-(a7)
- clr.w d0 ; x = 0
- clr.w d1 ; y = 0
- move.w #LCD_LINE_BYTES,d2 ; width
- move.w #LCD_HEIGHT,d3 ; height
- jsr graphlib::scrtomem ; save the screen in a created handle, d4
-
-
- ; DISABLE AUTO INT 6
- lea $600001,a6
- bclr.b #2,(a6) ; mem protection off
- move.l $78,d5 ; saves the old AUTO INT 6 adress
- move.l #ONKEY,$78 ; installs a new handler, which just returns
- bset.b #2,(a6) ; mem protection on
-
-
- shut: movem.l d0-d2/d4-d7/a0-a6,-(a7)
- lea LCD_MEM,a0 ; a0 = $4C00
- move.w #1919,d2 ; 1919 = 1920 - 1 = screen size/2 - 1
- move.w d3,rand_seed ;
- \copy move.w #$FFFF,d0 ; rand max
- bsr random ; d0 = random()
- move.w d0,(a0)+ ; writes random() to the screen
- dbra d2,\copy ; 1920 times
- movem.l (a7)+,d0-d2/d4-d7/a0-a6
-
- trap #4 ; shut down
- bsr getpassword ; asks for the doors pass
- tst.l d1 ; correct pass entered ?
- bne shut ; no -> shut down again
- clr.w d1 ; y = 0
- tst.w d4 ; could the screen be saved ?
- beq \fin ; no -> \fin
- move.w #LCD_HEIGHT,d3 ; height
- jsr graphlib::memtoscr ; restores the screen
- \fin
-
- ; RE-ENABLE AUTO INT 6
- bclr.b #2,(a6) ; mem prot off
- move.l d5,$78 ; restores the old auto int 6 handler
- bset.b #2,(a6) ; mem prot on
-
- movem.l (a7)+,d0-d7/a0-a6
- rts
-
- userlib@0001:
- random:
- move.l d1,-(sp) ; saves d1
- move.w rand_seed(pc),d1 ; d1 = rand_seed
- mulu.w #31421,d1 ; rand_seed * 31421
- add.w #6927,d1 ; + 6927
- mulu.w d1,d0 ; * rand _ max
- move.w d1,rand_seed ; new rand_seed = d1
- clr.w d0 ; d0.w = 0
- swap d0 ; swap
- move.l (sp)+,d1 ; restores d1
- rts
-
- userlib@000B
- getfreeRAM:
- ; returns : d0.l = free RAM
-
- movem.l d1-d7/a0-a6,-(a7)
- jsr doorsos::HeapAvail
- movem.l (a7)+,d1-d7/a0-a6
- rts
-
- userlib@000E:
- set_APD:
- ; input: d0.w : nb of seconds
-
- pushm.l d0-d7/a0-a6
- clr.l d3
- move.w d0,d3
- move.w #2,-(a7)
- jsr doorsos::OSFreeTimer
- mulu #20,d3
- move.l d3,-(a7)
- move.w #2,-(a7)
- jsr doorsos::OSRegisterTimer
- addq.l #8,a7
- popm.l d0-d7/a0-a6
- rts
-
- userlib@000F:
- get_APD:
- ; output: d0.w : nb of seconds
-
- pushm.l d1-d7/a0-a6
- move.w #$700,d0
- trap #1
- push.w #2
- jsr doorsos::OSTimerRestart
- move.w #2,(a7)
- jsr doorsos::OSTimerCurVal
- addq.l #2,a7
- move.w d0,d1
- divu #20,d1
- clr.w d0
- trap #1
- move.w d1,d0
- popm.l d1-d7/a0-a6
- rts
-
- userlib@000D:
- getfreearchive:
- ; returns : d0.l = free Archive memory
- ; this function is the same as getfreeRAM except that it counts the Archive mem and not the RAM mem
- movem.l d1-d7/a0-a6,-(a7)
- clr.l -(a7)
- clr.l -(a7)
- pea free(pc)
- pea to_gc(pc)
- clr.l -(a7)
- jsr doorsos::EM_survey
- lea 5*4(a7),a7
- move.l free,d0
- add.l to_gc,d0
- popm.l d1-d7/a0-a6
- rts
-
- free dc.l 0
- to_gc dc.l 0
-
- userlib@0002:
- rand_seed dc.w 0
-
- userlib@0003:
- exec:
- move.w 4(a7),d0
- DEREF d0,a3
- clr.l d1
- move.w (a3),d1
- lea 1(a3,d1.l),a2
-
- cmp.b #$F8,(a2) ; is it 'OTHER' ?
- bne \testASM ; no then check if it's ASM
- tst.b 2(a3) ; type = ASM ?
- bne \Fail
-
- move.w 4(a7),d2
- jsr filelib::hdltoindex ; gets the file index and folder handle
- tst.l d0 ; if compressed and file isn't in VAT
- beq \Fail
-
- DEREF d0,a0
- mulu #14,d1
- addq.w #4,d1
- add.l d1,a0 ; VAT address of the file
- moveq.w #1,d0 ; semi-comment mode
-
- cmp.l #$200000,a3
- bge \ziparch
-
- ; ici : compressÈ / non archivÈ
- jsr ziplib::zipfile ; unzips file / semi-comment mode
- tst.b d0 ; couldn't unzip
- bne \Fail
- move.w 12(a0),d0
- clr.w -(a7) ; there's no handle to be freed later
- move.l d0,-(a7) ; means the file is to be zipped back
- bra \endcomp
- \ziparch
- ; ici : compressÈ / archivÈ
- jsr ziplib::tempfile
- tst.b d0
- bne \Fail
- move.w d1,d0
- move.w d0,-(a7) ; pushes the handle of the temp block for future use
- move.l #1,-(a7) ; means the handle is to be freed at the end
-
- \endcomp
- DEREF d0,a0
- bra \rel
-
- \testASM
- cmp.b #$F3,(a2) ; is it an ASM ?
- bne \Fail ; no -> bye !
-
- cmp.l #$200000,a3
- blt \notarchived
-
- ;temporary unarchive an unarchived prog
- clr.l d3
- move.w (a3),d3
- addq.l #3,d3
- move.l d3,-(a7)
- jsr doorsos::HeapAlloc ; allocates a block to copy from Archive memory
- addq.l #4,a7
-
- tst.w d0
- beq \Fail
-
- move.w d0,-(a7) ; pushes the handle of the temp block for future use
- move.l #1,-(a7) ; means the handle is to be freed at the end
-
- DEREF d0,a0
- move.l a0,a5 ; a5 : destination
-
- subq.l #1,d3
- \cpy
- move.b (a3)+,(a5)+ ; copy to RAM
- dbra d3,\cpy
- bra \rel
-
- \notarchived
- move.l a3,a0
- clr.w -(a7)
- clr.l -(a7) ; means that there is nothing to do at the end :)
-
- \testcomp
-
- ; a0 : adresse du debut du prog
- \rel
- move.l a0,a5
- addq.l #2,a5
- cmp.l #"68kP",4(a5)
- bne \format
- tst.w 8(a5)
- bne \inuse
- clr.l d1
- move.w (a0),d1
- lea 1(a0,d1.l),a0
-
- \rloop
- clr.l d0
- move.w -(a0),d0
- tst.w d0
- beq \endr
- clr.l d1
- move.w -(a0),d1
- add.l a5,d1
- move.l d1,0(a5,d0.l)
- bra \rloop
- \endr
- jsr (a5)
- \afterexec
- ; a partir d'ici, sauver d0
-
- move.l (a7)+,d1 ; what is to do now ?
- move.w (a7)+,d2 ; get the saved handle
- tst.l d1
- beq \Fail ; nothing -> end
- cmp.l #1,d1 ;
- bne \zipback
- move.l d0,-(a7)
- move.w d2,-(a7)
- jsr doorsos::HeapFree
- add.l #2,a7
- move.l (a7)+,d0
- \Fail rts
-
- \zipback ; have to zip the file back
-
- move.l d0,d4
-
- move.l d1,d2
- jsr filelib::hdltoindex ; gets the file index and folder handle
- tst.l d0 ; if compressed and file isn't in VAT
- beq \notfnd
-
- DEREF d0,a0
- mulu #14,d1
- addq.w #4,d1
- add.l d1,a0 ; VAT address of the file
- moveq.w #1,d0 ; semi-comment mode
- jsr ziplib::zipfile ; zip it back
- \notfnd
- move.L d4,d0
- rts
- \inuse
- moveq.w #5,d0
- bra \afterexec
- \format
- moveq.w #4,d0
- bra \afterexec
-
- userlib@0004:
- FindSymEntry:
- jmp filelib::FindSymEntry
-
- userlib@0005
- DrawCharXY:
- ; Note: this function is slowwwwww :(
-
- move.w 4(a7),d0 ; d0.b = char to display
- lea char(pc),a0 ; puts it into a 2-byte string
- move.b d0,char
- move.w 10(a7),-(a7) ; color
- move.l a0,-(a7) ; string
- move.w 14(a7),-(a7) ; y
- move.w 14(a7),-(a7) ; x
- jsr doorsos::DrawStrXY ; display the character/string
- lea 10(a7),a7
- rts
-
- userlib@0006
- InputStr:
- ; d1.w : X
- ; d2.w : Y
- ; d3.w : Maxchar
- ;output: d0 = nbchars or 0 if no char pressed/ESC pressed
- move.l d6,-(a7) ; save d6
- moveq.l #1,d6 ; it is NOT a password input
- bsr Input ; main Input function
- move.l (a7)+,d6 ; restore d6
- rts
-
-
- Input:
- ; d1.w : X
- ; d2.w : Y
- ; d3.w : Maxchar
- ; d6.w : = 0 if it is a password input, else it is a normal input
- ;
- ;output: d0 = nbchars or 0 if no char pressed/ESC pressed
-
- movem.l d1-d7/a1,-(a7) ; saves all regs
- ; TO CHANGE FOR FUTURE ROMs
- move.b doorsos::MaxHandles+$24+$11,d7 ; d7 = old alphanum mode
- move.b #1,doorsos::MaxHandles+$24+$11 ; set to ALPHA LOCK
-
- \OK lea temp1,a0 ; a0 points to the temporary string
- move.w d3,d5 ; d5 = max char
- subq.w #1,d5 ; d5 --
- lsl.w #3,d5 ; (max char - 1) * 8
- move.l a0,a1 ; a1 = a0
- \retclear
- clr.w d4 ; nb char entered = 0
- \retour
- move.b #124,(a0) ; the '|' char
- clr.b 1(a0) ; terminates the string
- \WaitKey
- bsr Print_Txt ; display the string
- tst.w d6 ; are we in a password input ?
- beq \@1 ; yes -> @1
- bsr idle_hot ; no -> idle_hot
- bra \@2 ; go on..
- \@1 bsr idle_loop ; pass input -> idle_loop
- \@2 cmp.w #13,d0 ; Enter pressed ?
- beq \enter
- cmp.w #263,d0 ; CLEAR pressed ?
- beq \clear
- cmp.w #257,d0 ; Backspace ?
- beq \BackSp
- cmp.w #264,d0 ; ESC ?
- beq \ESC
- cmp.w #255,d0 ; is it a valid character ?
- bhi \WaitKey ; no -> loop
- cmp.w d3,d4 ; nbchar == max char ?
- beq \WaitKey ; yes -> loop
- move.b d0,(a0)+ ; else store the type character
- addq.w #1,d4 ; nbchar ++
- bra \retour ; display the string and loop
- \clear ; CLEAR pressed
- move.l a1,a0 ; restore the string pointer
- bra \retclear ; reinitialize the string
- \BackSp ; <- pressed ? (Backspace)
- tst.w d4 ; nb char == 0 ?
- beq \WaitKey ; yes -> wa can't 'backspace' anything
- subq.w #1,d4 ; nbchar --
- subq.l #1,a0 ; string pointer --
- bra \retour ; display the string and loop
- \enter ; ENTER pressed
- clr.b (a0) ; terminate the string
- bsr Print_Txt ; Display it again (without the '|' char)
- move.w d4,d0 ; d0 = nbchar
- bra \end ; finish ..
- \ESC clr.w d0 ; ESC pressed -> nbchar = 0
- \end lea temp1,a0 ; a0 points to the typed string
-
- ; TO CHANGE
- move.b d7,doorsos::MaxHandles+$24+$11 ; restore the alphanum mode
- movem.l (a7)+,d1-d7/a1 ; restores regs
- rts ; quit
-
- Print_Txt: ; Display the typed string
- movem.l d0-d7/a0-a6,-(a7)
- move.w d1,d0 ; x
- move.w d2,d1 ; y
- move.w d5,d2 ; d2 = (maxchars - 1) * 8 = width
- moveq.w #7,d3 ; d3 = height
- moveq.w #1,d4 ; color: white
- jsr graphlib::fill ; clear the background
- tst.w d6 ; are we in a password input ?
- beq dispstars ; yes -> display only stars '*'
- bra Write2 ; else display the real string
-
- Write: movem.l d0-d7/a0-a6,-(a7)
- Write2:
- move.w #4,-(a7) ; Color
- move.l a1,-(a7) ; address of the sting
- move.w d1,-(a7) ; Y
- move.w d0,-(a7) ; X
- jsr doorsos::DrawStrXY ; display the string
- lea 10(a7),a7
- movem.l (a7)+,d0-d7/a0-a6
- rts
-
- printf:
- movem.l d0-d7/a0-a6,-(a7)
- clr.w d0
- clr.w d1
- move.b (a1)+,d0 ; d0.b = x
- move.b (a1)+,d1 ; d0.b = y
- bra Write2 ; display
-
- dispstars:
- move.l 16(a7),d4 ; restores d4 = nbchar
- lea stars(pc),a1 ; loads the string "*"
- \affstar
- tst.w d4 ; still any stars to display ?
- beq \disped ; no -> all done !
- bsr Write ; display a star..
- addq.w #6,d0 ; x += 6
- dbra d4,\affstar ; display d4 stars
- \disped
- movem.l (a7)+,d0-d7/a0-a6
- rts
-
- userlib@0007
- getpassword:
- movem.l d0/d2-d7/a0-a6,-(a7)
- lea mespass(pc),a0 ; title of the box
- jsr graphlib::smallbox ; display the box
-
- clr.w -(a7)
- jsr doorsos::FontSetSys ; Font #0
- addq.l #2,a7
-
- move.w d0,a5 ; save d0 ( = old font) into a5
- lea tit1pass(pc),a1 ; a1 = 92+ string
- tst.b CALCULATOR ; 89 or 92+ ?
- bne \OK92 ; -> 92+
- lea s89_tit1pass(pc),a1 ; a1 = 89 string
- \OK92 bsr printf ; display the string (a1)
- getpword:
- bclr.b #2,$600001 ; mem protection off
- move.l $78,d5 ; saves the old auto int 6 handler
- move.l #ONKEY,$78 ; installs my auto int 6 handler
- bsr get_APD
- move.w d0,d7 ; saves the APD counter
- moveq.w #5,d0
- bsr set_APD ; set the APD value to 5 seconds
- moveq.w #63,d1 ; x (for 92+)
- moveq.w #59,d2 ; y (for 92+)
- moveq.w #10,d3 ; max char
- tst.b CALCULATOR ; 89 or 92+ ?
- bne \OK92 ; 92+
- moveq.w #50,d1 ; x (for 89)
- moveq.w #48,d2 ; y (for 89)
- \OK92 clr.w d6 ; it is a password input
- bsr Input ; Input the password
-
- move.l d5,$78 ; restores the auto int 6 handler
- bset.b #2,$600001 ; mem protection off
- move.w d7,d0
- bsr set_APD ; restores the APD counter value
-
- movem.L d0-d2/a0-a1,-(a7) ; saves some regs
- move.w a5,-(a7) ; a5.w = old font
- jsr doorsos::FontSetSys ; restores the old font
- addq.l #2,a7
- movem.l (a7)+,d0-d2/a0-a1
-
- tst.w d0 ; any password entered ?
- beq wrong ; no -> pass is wrong
- lea pword(pc),a1 ; a1 points to the correct password
- bsr strcomp ; compares (a0) and (a1) strings, result in d1.w
- wrong: movem.l (a7)+,d0/d2-d7/a0-a6
- rts
-
- ; AUTO INT 6 handler for the password input functions
- ONKEY: rte ; just returns =)
-
- userlib@0008
- changepass:
- ; Changes the Doors password
- movem.l d0-d7/a0-a6,-(a7)
- \debut
- bsr getpassword ; gets the old pass
- tst d1 ; correct pass entered ?
- bne \exit ; no -> exit
- ; get the new password
- lea (npword+2)(pc),a0 ; a0 points to the title string
- jsr graphlib::smallbox ; display the box
-
- clr.w -(a7)
- jsr doorsos::FontSetSys ; Font #0
- addq.l #2,a7
-
- lea npword(pc),a1 ; a1 points to a 92+ string
- moveq.w #59,d2 ; y (92+)
- moveq.w #63,d1 ; x (92+)
- tst.b CALCULATOR ; 89 or 92+ ?
- bne \OK92 ; -> 92+
- lea s89_npword(pc),a1 ; a1 points to a 89 string
- moveq.w #48,d2 ; y (89)
- moveq.w #50,d1 ; x (89)
- \OK92 bsr \smallbsr ; go & asks for the new pass
-
- lea temppass,a2 ; temp string
- move.l a2,a3 ; a3 = a2
- \cpy move.b (a0)+,(a3)+ ; copies the new pass
- dbra d0,\cpy ; remember d0 = nb char typed
-
- ; Now asks for a confirmation
- lea confirm(pc),a1 ; 92+ string
- moveq.w #84,d2 ; y
- moveq.w #63,d1 ; x
- tst.b CALCULATOR ; 89 or 92+
- bne \OK92i ; -> 92+
- lea s89_confirm(pc),a1 ; 89 string
- moveq.w #70,d2 ; y
- moveq.w #50,d1 ; x
- \OK92i bsr \smallbsr ; asks for the confirmation pass
- move.l a2,a1 ; a1 = firstly entered pass
- bsr strcomp ; compares a1 & a0 (the password & its confirmation)
- tst.w d1 ; are they the same ?
- beq \okconfirm ; yes -> confirmation is ok
- ; if confirmation is NOT ok
- pea badconf(pc) ; pushes the adress of an error msg
- jsr doorsos::ST_showHelp ; display it in the status bar
- addq.l #4,a7
- bra \debut ; asks for the pass again
- \okconfirm ; else save the new password
- lea pword(pc),a1 ; a1 points to the Doors pass
- \copy move.b (a0)+,(a1)+ ; save the pass..
- dbra d0,\copy
- \exit movem.l (a7)+,d0-d7/a0-a6
- rts
-
- \smallbsr
- bsr printf ; display the string (a1)
- moveq.w #10,d3 ; max char = 10
- clr.w d6 ; it is a password inpout
- bsr Input ; get the input
- tst.w d0 ; any chars entered ?
- bne \OK ; yes -> OK
- addq.l #4,a7 ; directly exit the function
- bra \exit
- \OK rts
-
-
- strcomp:
- ; compares the strings (a0) & (a1)
- ; d1.w = result
-
- movem.l d0/d2/a0-a1,-(a7)
- movem.l a0/a1,-(a7)
- jsr doorsos::strcmp ; TIOS string comparison function
- addq.l #8,a7
- move.w d0,d1 ; d1 = result
- movem.l (a7)+,d0/d2/a0-a1
- rts
-
-
-
- ;*****************************************************
- ; Program variables & strings
- ;*****************************************************
-
- char dc.b 0,0 ; used by WriteChar
- stars dc.b "*",0 ; used to display stars in the password protection
- pword dc.b "doors",0,0,0,0,0,0 ; 10 char password
-
- npword dc.b 53,44,"Enter the new Doorspass:",0
- tit1pass dc.b 53,44,"Enter the current Doorspass:",0
- mespass dc.b "Doors Password Protection",0
- confirm dc.b 53,71,"Confirm the Doorspass:",0
- badconf dc.b "Password confirmation failed",0
-
- s89_npword dc.b 40,38,"Enter the new Doorspass:",0
- s89_tit1pass dc.b 32,38,"Enter the current Doorspass:",0
- s89_confirm dc.b 40,60,"Confirm the Doorspass:",0
-
- BSS
- temppass ds.b 11
- temp1 dc.b 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
- nblim dc.w 0
- handle ds.b 10
- temp dc.w 0
-
- end
-