home *** CD-ROM | disk | FTP | other *** search
/ Compute! Gazette 1994 October / 1994-10b.d64 / months.src (.txt) < prev    next >
Commodore BASIC  |  2022-09-20  |  3KB  |  144 lines

  1. 100  *=$2000
  2. 110 ; send prompt message
  3. 120 start ldx #0
  4. 130 prlp lda prompt,x
  5. 140  beq inpt
  6. 150  jsr $ffd2
  7. 160  inx
  8. 170  bne prlp
  9. 180 ; accept only the first three (NULL)s
  10. 190 inpt ldy #0
  11. 200 inlp sty ysave
  12. 210  jsr $ffcf
  13. 220  ldy ysave
  14. 230  cmp #$0d
  15. 240  beq exit  ; less than 3 saves
  16. 250  sta inbuff,y
  17. 260  iny
  18. 270  cpy #3
  19. 280  bcc inlp
  20. 290 ; input received.  check it
  21. 300 scan lda #$0d
  22. 310  jsr $ffd2
  23. 320 ; set up first structure
  24. 330  lda #<table
  25. 340  sta $fd
  26. 350  lda #>table
  27. 360  sta $fe
  28. 370  ldx #0   ; count number of structs
  29. 380 scnlp ldy #10
  30. 390 scchr lda inbuff-10,y
  31. 400  ora #$80 ; change to upper case
  32. 410  cmp ($fd),y
  33. 420  bne nope ; no match, try next
  34. 430  iny
  35. 440  cpy #13  ; test 3 (NULL)s matched
  36. 450  bne scchr
  37. 460  beq yup
  38. 470 ; no match.  try next structure.
  39. 480 nope clc
  40. 490  lda $fd
  41. 500  adc #14    ; size of structure
  42. 510  sta $fd
  43. 520  bcc ninc
  44. 530  inc $fe
  45. 540 ninc inx
  46. 550  cpx #12
  47. 560  bcc scnlp
  48. 570 exit rts
  49. 580 ; found match.  print full month.
  50. 590 yup ldy #0  ; position in structure
  51. 600 mlp lda ($fd),y
  52. 610  beq hprn
  53. 620  jsr $ffd2
  54. 630  iny
  55. 640  bne mlp
  56. 650 ; now we print fixed string 'has'
  57. 660 hprn ldx #0
  58. 670 hplp lda has,x
  59. 680  jsr $ffd2
  60. 690  inx
  61. 700  cpx #5
  62. 710  bne hplp
  63. 720 ; extract number-of-days (bcd)
  64. 730  ldy #13   ; position in structure
  65. 740  lda ($fd),y
  66. 750  pha
  67. 760  lsr a
  68. 770  lsr a
  69. 780  lsr a
  70. 790  lsr a
  71. 800  ora #$30
  72. 810  jsr $ffd2 ; first digit
  73. 820  pla
  74. 830  and #$0f
  75. 840  ora #$30
  76. 850  jsr $ffd2 ; second digit
  77. 860 ; print string 'days.'
  78. 870  ldx #0
  79. 880 dylp lda days,x
  80. 890  jsr $ffd2
  81. 900  inx
  82. 910  cpx #7
  83. 920  bne dylp
  84. 930 ; print finished.  (NULL) it again.
  85. 940  jmp start
  86. 1000 ; here comes the table structure
  87. 1010 table .asc  "[202]anuary"
  88. 1011  .byte 0,0,0
  89. 1020  .asc  "[202][193][206]"
  90. 1030  .byte $31
  91. 1040  .asc  "[198]ebruary"
  92. 1041  .byte 0,0
  93. 1050  .asc  "[198][197][194]"
  94. 1060  .byte $28
  95. 1070  .asc  "[205]arch"
  96. 1071  .byte 0,0,0,0,0
  97. 1080  .asc  "[205][193][210]"
  98. 1090  .byte $31
  99. 1100  .asc  "[193]pril"
  100. 1101  .byte 0,0,0,0,0
  101. 1110  .asc  "[193][208][210]"
  102. 1120  .byte $30
  103. 1130  .asc  "[205]ay"
  104. 1131  .byte 0,0,0,0,0,0,0
  105. 1140  .asc  "[205][193][217]"
  106. 1150  .byte $31
  107. 1160  .asc  "[202]une"
  108. 1161  .byte 0,0,0,0,0,0
  109. 1170  .asc  "[202][213][206]"
  110. 1180  .byte $30
  111. 1190  .asc  "[202]uly"
  112. 1191  .byte 0,0,0,0,0,0
  113. 1200  .asc  "[202][213][204]"
  114. 1210  .byte $31
  115. 1220  .asc  "[193]ugust"
  116. 1221  .byte 0,0,0,0
  117. 1230  .asc  "[193][213][199]"
  118. 1240  .byte $31
  119. 1250  .asc  "[211]eptember"
  120. 1251  .byte 0
  121. 1260  .asc  "[211][197][208]"
  122. 1270  .byte $30
  123. 1280  .asc  "[207]ctober"
  124. 1281  .byte 0,0,0
  125. 1290  .asc  "[207][195][212]"
  126. 1300  .byte $31
  127. 1310  .asc  "[206]ovember"
  128. 1311  .byte 0,0
  129. 1320  .asc  "[206][207][214]"
  130. 1330  .byte $30
  131. 1340  .asc  "[196]ecember"
  132. 1341  .byte 0,0
  133. 1350  .asc  "[196][197][195]"
  134. 1360  .byte $31
  135. 1370 ; here come the fixed strings
  136. 1380 prompt .asc "[197]nter month : ",0
  137. 1385  .byte 0
  138. 1390 has .asc " has "
  139. 1400 days .asc " days.",$0d
  140. 1405  .byte $0d
  141. 1410 ; here comes the variable area
  142. 1420 ysave  *=*+1
  143. 1430 inbuff *=*+10
  144.