home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Compute! Gazette 1994 October
/
1994-10b.d64
/
months.src
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2022-09-20
|
3KB
|
144 lines
100 *=$2000
110 ; send prompt message
120 start ldx #0
130 prlp lda prompt,x
140 beq inpt
150 jsr $ffd2
160 inx
170 bne prlp
180 ; accept only the first three (NULL)s
190 inpt ldy #0
200 inlp sty ysave
210 jsr $ffcf
220 ldy ysave
230 cmp #$0d
240 beq exit ; less than 3 saves
250 sta inbuff,y
260 iny
270 cpy #3
280 bcc inlp
290 ; input received. check it
300 scan lda #$0d
310 jsr $ffd2
320 ; set up first structure
330 lda #<table
340 sta $fd
350 lda #>table
360 sta $fe
370 ldx #0 ; count number of structs
380 scnlp ldy #10
390 scchr lda inbuff-10,y
400 ora #$80 ; change to upper case
410 cmp ($fd),y
420 bne nope ; no match, try next
430 iny
440 cpy #13 ; test 3 (NULL)s matched
450 bne scchr
460 beq yup
470 ; no match. try next structure.
480 nope clc
490 lda $fd
500 adc #14 ; size of structure
510 sta $fd
520 bcc ninc
530 inc $fe
540 ninc inx
550 cpx #12
560 bcc scnlp
570 exit rts
580 ; found match. print full month.
590 yup ldy #0 ; position in structure
600 mlp lda ($fd),y
610 beq hprn
620 jsr $ffd2
630 iny
640 bne mlp
650 ; now we print fixed string 'has'
660 hprn ldx #0
670 hplp lda has,x
680 jsr $ffd2
690 inx
700 cpx #5
710 bne hplp
720 ; extract number-of-days (bcd)
730 ldy #13 ; position in structure
740 lda ($fd),y
750 pha
760 lsr a
770 lsr a
780 lsr a
790 lsr a
800 ora #$30
810 jsr $ffd2 ; first digit
820 pla
830 and #$0f
840 ora #$30
850 jsr $ffd2 ; second digit
860 ; print string 'days.'
870 ldx #0
880 dylp lda days,x
890 jsr $ffd2
900 inx
910 cpx #7
920 bne dylp
930 ; print finished. (NULL) it again.
940 jmp start
1000 ; here comes the table structure
1010 table .asc "[202]anuary"
1011 .byte 0,0,0
1020 .asc "[202][193][206]"
1030 .byte $31
1040 .asc "[198]ebruary"
1041 .byte 0,0
1050 .asc "[198][197][194]"
1060 .byte $28
1070 .asc "[205]arch"
1071 .byte 0,0,0,0,0
1080 .asc "[205][193][210]"
1090 .byte $31
1100 .asc "[193]pril"
1101 .byte 0,0,0,0,0
1110 .asc "[193][208][210]"
1120 .byte $30
1130 .asc "[205]ay"
1131 .byte 0,0,0,0,0,0,0
1140 .asc "[205][193][217]"
1150 .byte $31
1160 .asc "[202]une"
1161 .byte 0,0,0,0,0,0
1170 .asc "[202][213][206]"
1180 .byte $30
1190 .asc "[202]uly"
1191 .byte 0,0,0,0,0,0
1200 .asc "[202][213][204]"
1210 .byte $31
1220 .asc "[193]ugust"
1221 .byte 0,0,0,0
1230 .asc "[193][213][199]"
1240 .byte $31
1250 .asc "[211]eptember"
1251 .byte 0
1260 .asc "[211][197][208]"
1270 .byte $30
1280 .asc "[207]ctober"
1281 .byte 0,0,0
1290 .asc "[207][195][212]"
1300 .byte $31
1310 .asc "[206]ovember"
1311 .byte 0,0
1320 .asc "[206][207][214]"
1330 .byte $30
1340 .asc "[196]ecember"
1341 .byte 0,0
1350 .asc "[196][197][195]"
1360 .byte $31
1370 ; here come the fixed strings
1380 prompt .asc "[197]nter month : ",0
1385 .byte 0
1390 has .asc " has "
1400 days .asc " days.",$0d
1405 .byte $0d
1410 ; here comes the variable area
1420 ysave *=*+1
1430 inbuff *=*+10