;; ======================================================================== ;; ;; NAME ;; ;; IV_SAYNUM16 Say a 16-bit unsigned number using RESROM digits ;; ;; ;; ;; AUTHOR ;; ;; Joseph Zbiciak ;; ;; ;; ;; REVISION HISTORY ;; ;; 16-Sep-2002 Initial revision . . . . . . . . . . . J. Zbiciak ;; ;; ;; ;; INPUTS for IV_INIT ;; ;; R0 Number to "speak" ;; ;; R5 Return address ;; ;; ;; ;; OUTPUTS ;; ;; ;; ;; DESCRIPTION ;; ;; "Says" a 16-bit number using IV_PLAYW to queue up the phrase. ;; ;; Because the number may be built from several segments, it could ;; ;; easily eat up the queue. I believe the longest number will take ;; ;; 7 queue entries -- that is, fill the queue. Thus, this code ;; ;; could block, waiting for slots in the queue. ;; ;; ;; ;; ------------------------------------------------------------------------ ;; ;; Copyright (c) 2001, Joseph Zbiciak ;; ;; ======================================================================== ;; IV_SAYNUM16 PROC PSHR R5 TSTR R0 BEQ @@zero ; Special case: Just say "zero" ;; ------------------------------------------------------------ ;; ;; First, try to pull off 'thousands'. We call ourselves ;; ;; recursively to play the the number of thousands. ;; ;; ------------------------------------------------------------ ;; CLRR R1 @@thloop: INCR R1 SUBI #1000, R0 BC @@thloop ADDI #1000, R0 PSHR R0 DECR R1 BEQ @@no_thousand CALL IV_SAYNUM16.recurse CALL IV_PLAYW DECLE RESROM.thousand @@no_thousand PULR R1 ;; ------------------------------------------------------------ ;; ;; Now try to play hundreds. ;; ;; ------------------------------------------------------------ ;; MVII #RESROM.zero-1, R0 CMPI #100, R1 BNC @@no_hundred @@hloop: INCR R0 SUBI #100, R1 BC @@hloop ADDI #100, R1 PSHR R1 CALL IV_PLAYW.1 CALL IV_PLAYW DECLE RESROM.hundred PULR R1 B @@notrecurse ; skip "PSHR R5" @@recurse: PSHR R5 ; recursive entry point for 'thousand' @@no_hundred: @@notrecurse: MOVR R1, R0 BEQ @@leave SUBI #20, R1 BNC @@teens MVII #RESROM.twenty-1, R0 @@tyloop INCR R0 SUBI #10, R1 BC @@tyloop ADDI #10, R1 PSHR R1 CALL IV_PLAYW.1 PULR R0 TSTR R0 BEQ @@leave @@teens: @@zero: ADDI #RESROM.zero, R0 CALL IV_PLAYW.1 @@leave PULR PC ENDP ;; ======================================================================== ;; ;; LICENSE ;; ;; GNU General Public License, Version 2.0: ;; ;; ;; ;; This program is free software; you can redistribute it and/or ;; ;; modify it under the terms of the GNU General Public License as ;; ;; published by the Free Software Foundation; either version 2 of the ;; ;; License, or (at your option) any later version. ;; ;; ;; ;; This program is distributed in the hope that it will be useful, ;; ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; ;; General Public License for more details. ;; ;; ;; ;; You should have received a copy of the GNU General Public License ;; ;; along with this program; if not, write to the Free Software ;; ;; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ;; ;; ------------------------------------------------------------------------ ;; ;; Copyright (c) 2001, Joseph Zbiciak ;; ;; ======================================================================== ;;