home *** CD-ROM | disk | FTP | other *** search
/ Go64! / Go64_1999-04_1999_CSW_Side_A.d64 / src_ccass.pet < prev    next >
Text File  |  2023-02-26  |  12KB  |  612 lines

  1. ;Prog:  CarreraCount
  2. ;Version:       work 0.1 (28.6.98)
  3. ;Autor: Peter Steinmeyer
  4. ;
  5. ;       Rundenzehlprogramm fNr Carrera Universal (4 Fahrer)
  6. ;
  7.  
  8.  
  9.         .BA $C000
  10.  
  11. PB2     .DE 56577
  12. DRRB2   .DE 56579
  13. CHRGET  .DE $73
  14. CHRGOT  .DE $79
  15. GETBYTE .DE $B79E
  16. GETKOMMA        .DE $AEFD
  17. KOMMABYTE       .DE $B7F1
  18. ASCOUT  .DE $e716
  19. TIMER1A .DE 56324
  20. SCREEN  .DE 1024
  21.  
  22. count   .de 828   ;828-830
  23. bahnalt .de 831 ;831-842 jeweils 3 Byte
  24. bahnneu .de 843 ;843-854 pro Bahn (4 Bahnen)
  25. flag    .de 855   ;855-858 Flag fNr Runde gefahren
  26. limit   .de 859 ;859-861 minimal m%gliche Rundenzeit
  27. temp    .de 862
  28. event   .de 863 ;Flag fNr Runde gefahren
  29. rstactiv        .de 864
  30.  
  31.  
  32. count100l       .de 865 ;dezimalzehler Gesamtzeit!
  33. count100h       .de 866
  34. count60l        .de 867
  35. count60h        .de 868
  36. count1l .de 869
  37. count1h .de 870
  38. count1g .de 871
  39.  
  40. ib1     .de 874 ;Backup variablen fNr IRQ
  41. ib2     .de 875
  42. ib3     .de 876
  43. ib4     .de 877
  44.  
  45. stopflag        .de 879 ;unterbricht Zeit und Rundenzehlung
  46. timex   .de 880 ;X-Position Gesammtzeit
  47. timey   .de 881 ;Y-Position
  48.  
  49. lo1     .de 251
  50. hi1     .de 252
  51. lo2     .de 253
  52. hi2     .de 254
  53.  
  54.  
  55. ;Basiceinspring  +Offset auf Adresse 49152
  56.  
  57.  jmp initia     ;+0  Timer/IRQ aktivieren
  58.  jmp an         ;+3  Relais an = Bahnstrom aus
  59.  jmp aus                ;+6  Relais aus = Bahnstrom an
  60.  jmp resetan    ;+9  Relais zurNcksetzen
  61.  jmp resetaus   ;+12 Relais normal
  62.  jmp show               ;+15 liest Portzustand aus
  63.  jmp initoff    ;+18 Timer/IRQ auf normal
  64.  jmp out                ;+21 Gibt Rundenzahl (0-99) aus
  65.  jmp resetbahn  ;+24 Setzt Runden zeiten auf NULL
  66.  jmp color      ;+27 Hintergrundfarbe auf schwarz
  67.  jmp cursor     ;+30 setzt Cursor nach x,y
  68.  jmp scroll     ;+33 scrollt Bildschirmbereich
  69.  jmp outbasic   ;+36 Gibt Rundenzahl aus (0-99)
  70.  jmp resettime  ;+39 l%scht Gesammtzeit
  71.  
  72. ;-- daten
  73. mult40
  74. mult
  75.  .by 1024 1064 1104 1144 1184 1224 1264 1304
  76.  .by 1344 1384 1424 1464 1504 1544 1584 1624 1664
  77.  .by 1704 1744 1784 1824 1864 1904 1944 1984 2024
  78. ;
  79. pot2 .by 1 2 4 8 16 32 64 128
  80. ;
  81. mult3 .by 0 3 6 9 12
  82. ;
  83. ;
  84. ziff
  85.  .by 0 0 0 1 0 2 0 3 0 4 0 5 0 6 0 7 0 8 0 9
  86.  .by 1 0 1 1 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9
  87.  .by 2 0 2 1 2 2 2 3 2 4 2 5 2 6 2 7 2 8 2 9
  88.  .by 3 0 3 1 3 2 3 3 3 4 3 5 3 6 3 7 3 8 3 9
  89.  .by 4 0 4 1 4 2 4 3 4 4 4 5 4 6 4 7 4 8 4 9
  90.  .by 5 0 5 1 5 2 5 3 5 4 5 5 5 6 5 7 5 8 5 9
  91.  .by 6 0 6 1 6 2 6 3 6 4 6 5 6 6 6 7 6 8 6 9
  92.  .by 7 0 7 1 7 2 7 3 7 4 7 5 7 6 7 7 7 8 7 9
  93.  .by 8 0 8 1 8 2 8 3 8 4 8 5 8 6 8 7 8 8 8 9
  94.  .by 9 0 9 1 9 2 9 3 9 4 9 5 9 6 9 7 9 8 9 9
  95. ;
  96. ;
  97.  
  98. null    .by 233 160 223 160 32 160 160 32 160 160 32 160 95 160 105
  99. eins    .by 32 32 233 32 32 160 32 32 160 32 32 160 32 32 105
  100. zwei    .by 233 160 223 32 32 160 160 160 160 160 32 32 160 160 160
  101. drei    .by 233 160 223 32 32 160 32 160 160 32 32 160 95 160 105
  102. vier    .by 233 32 233 160 32 160 160 160 160 32 32 160 32 32 160
  103. fuenf   .by 160 160 160 160 32 32 160 160 223 32 32 160 95 160 105
  104. sechs   .by 233 160 223 160 32 32 160 160 223 160 32 160 95 160 105
  105. sieben  .by 95 160 160 32 32 160 32 32 160 32 32 160 32 32 105
  106. acht    .by 233 160 223 160 32 160 160 160 160 160 32 160 95 160 105
  107. neun    .by 233 160 223 160 32 160 95 160 160 32 32 160 95 160 160
  108.  
  109. zahl    .se null
  110.         .se eins
  111.         .se zwei
  112.         .se drei
  113.         .se vier
  114.         .se fuenf
  115.         .se sechs
  116.         .se sieben
  117.         .se acht
  118.         .se neun
  119.  
  120. timepos .by 1868 1877 1886 1895
  121.  
  122.  
  123. ;--- initia irq init
  124. initia
  125.         lda #0
  126.         sta 53280
  127.         sta 53281
  128.         lda #15
  129.         sta 646
  130.         lda #128+64
  131.         sta drrb2
  132.         lda #%11000000
  133.         sta PB2
  134.         lda #38       ;38
  135.         sta TIMER1A+1
  136.         lda #125
  137.         sta TIMER1A
  138.         sei
  139.         lda #<irq
  140.         sta 788
  141.         lda #>irq
  142.         sta 789
  143.         lda #0
  144.         sta limit
  145.         sta limit+2
  146.         lda #2
  147.         sta limit+1
  148.         lda #0
  149.         sta flag
  150.         sta flag+1
  151.         sta flag+2
  152.         sta flag+3
  153.         jsr resettime
  154.         jsr resetbahn
  155.         cli
  156.         rts
  157.  
  158. ;--- AN
  159. an      lda pb2
  160.         and #255-128
  161.         sta pb2
  162.         lda #12
  163.         sta 53280
  164.         rts
  165. ;
  166. ;--- aus
  167. aus     lda pb2
  168.         ora #128+64
  169.         sta pb2
  170.         lda #0
  171.         sta 53280
  172.         rts
  173. ;
  174. ;--- resetan
  175. ;       l%scht die RelayFlipflops auf der Hardware
  176.  
  177. resetan lda pb2
  178.         and #255-64
  179.         sta pb2
  180.         lda #10
  181.         sta 53281
  182.         rts
  183.  
  184. resetaus        lda pb2
  185.         ora #64
  186.         sta pb2
  187.         lda #0
  188.         sta 53281
  189.         rts
  190. ;
  191. ;--- show
  192. ;
  193.  
  194. show    ldx #0
  195. shloop  lda pot2,x
  196.         and pb2
  197.         bne shno
  198.         jsr test
  199. shno    inx
  200.         cpx #4  ;4 Bahnen abfragen
  201.         bne shloop
  202.  
  203.         lda event       ;Wagen durchgefahren?
  204.         cmp #1
  205.         bne endshow
  206.         jsr resetan
  207.         ldx #255
  208. w1      dex
  209.         bne w1
  210.         lda #0
  211.         sta event
  212.         jsr resetaus
  213. endshow         rts
  214.  
  215. ;
  216. ;--- irq
  217. ;       Interupt der 1/100s Takt zehlt
  218. ;       und die Runden Relays auf der Hardware abfragt
  219.  
  220. irq
  221.  
  222.         lda lo1
  223.         sta ib1
  224.         lda hi1
  225.         sta ib2
  226.         lda lo2
  227.         sta ib3
  228.         lda hi2
  229.         sta ib4
  230.  
  231.         lda stopflag
  232.         beq i3          ;Rennen nicht aktiv
  233.  
  234.         lda 653         ;Flag fNr Control Tasten
  235.         and #1
  236.         bne i2
  237.  
  238.         inc count
  239.         bne i1
  240.         inc count+1
  241.         bne i1
  242.         inc count+2
  243. i1
  244.         ldx #0
  245.         inc count100l   ;1/100 hochzehlen
  246.         lda #10
  247.         cmp count100l
  248.         bne i2
  249.         stx count100l
  250.         inc count100h   ;1/10 hochzehlen
  251.         lda #10
  252.         cmp count100h
  253.         bne i2
  254.         stx count100h
  255.         inc count60l    ;sekunden hochzehlen
  256.         lda #10
  257.         cmp count60l
  258.         bne i2
  259.         stx count60l
  260.         inc count60h    ;dezi sekunden hochzehlen
  261.         lda #6
  262.         cmp count60h
  263.         bne i2
  264.         stx count60h
  265.         inc count1l     ;min hochzehlen
  266.         lda #10
  267.         cmp count1l
  268.         bne i2
  269.         stx count1l
  270.         inc count1h     ;min hochzehlen
  271.         lda #10
  272.         cmp count1h
  273.         bne i2
  274.         stx count60h
  275.         inc count1g     ;min hochzehlen
  276. i2
  277.         ldx timex
  278.         ldy timey
  279.         jsr xytoprint
  280.         jsr printtime
  281.         jsr show
  282. i3
  283.         lda ib1
  284.         sta lo1
  285.         lda ib2
  286.         sta hi1
  287.         lda ib3
  288.         sta lo2
  289.         lda ib4
  290.         sta hi2
  291.         jsr $ffea ;Zeit erh%hen
  292.         lda #0
  293.         sta $91 ;stop Tasten Flag l%schen
  294.         jmp $ea34
  295.  
  296. irloop
  297. ;
  298. ;
  299. initoff lda #0
  300.         sta DRRB2
  301.         lda #62
  302.         sta TIMER1A+1
  303.         lda #$31
  304.         sta 788
  305.         lda #$ea
  306.         sta 789
  307.         rts
  308. ;
  309. ;--- OUT        gibt Rundenzahl 2stellig aus
  310. ;       1000 = Rundenzahl
  311. ;       1001 = x-pos
  312. ;       1002 = y-pos
  313.  
  314. out     lda 1002
  315.         asl
  316.         tay
  317.         lda mult,y
  318.         sta plot1+1
  319.         lda mult+1,y
  320.         sta plot1+2
  321.         lda 1001
  322.         clc
  323.         adc plot1+1
  324.         sta plot1+1
  325.         lda #0
  326.         adc plot1+2
  327.         sta plot1+2
  328.         lda 1000
  329.         asl
  330.         tay
  331.         lda ziff,y
  332.         asl
  333.         tay
  334.         lda zahl,y
  335.         sta lo2
  336.         lda zahl+1,y
  337.         sta hi2
  338.         ldy #0
  339. ou1     ldx #0
  340. ou2     lda (lo2),y
  341. plot1   sta 1024,x
  342.         inx
  343.         iny
  344.         cpx #3
  345.         bne ou2
  346.         lda plot1+1
  347.         clc
  348.         adc #40
  349.         sta plot1+1
  350.         lda plot1+2
  351.         adc #0
  352.         sta plot1+2
  353.         cpy #15
  354.         bne ou1
  355.         lda plot1+1
  356.         sec
  357.         sbc #196
  358.         sta plot2+1
  359.         lda plot1+2
  360.         sbc #0
  361.         sta plot2+2
  362.         lda 1000
  363.         asl
  364.         tay
  365.         lda ziff+1,y
  366.         asl
  367.         tay
  368.         lda zahl,y
  369.         sta lo2
  370.         lda zahl+1,y
  371.         sta hi2
  372.         ldy #0
  373. ou3     ldx #0
  374. ou4     lda (lo2),y
  375. plot2   sta 1024,x
  376.         inx
  377.         iny
  378.         cpx #3
  379.         bne ou4
  380.         lda plot2+1
  381.         clc
  382.         adc #40
  383.         sta plot2+1
  384.         lda plot2+2
  385.         adc #0
  386.         sta plot2+2
  387.         cpy #15
  388.         bne ou3
  389.         rts
  390. ;
  391. ;--- resetbahn
  392. ;
  393. ;       Rundenzeiten auf momentane Zeit setzen
  394. ;       Das hei{CBM-I}t Rundenzeit auf Startzeit!
  395.  
  396. resetbahn       ldx #0
  397.         nop
  398. res1    lda 828,x
  399.         sta 831,x
  400.         sta 834,x
  401.         sta 837,x
  402.         sta 840,x
  403.         inx
  404.         cpx #3
  405.         bne res1
  406.         rts
  407. ;
  408. ;--- test
  409. test    stx temp
  410.         lda flag,x
  411.         bne testend
  412.         lda mult3,x
  413.         tax
  414.         lda count
  415.         sec
  416.         sbc bahnalt,x
  417.         sta bahnneu,x
  418.         lda count+1
  419.         sbc bahnalt+1,x
  420.         sta bahnneu+1,x
  421.         lda count+2
  422.         sbc bahnalt+2,x
  423.         sta bahnneu+2,x
  424.         cmp limit+2
  425.         bcc testend
  426.         bne testok
  427.         lda bahnneu+1,x
  428.         cmp limit+1
  429.         bcc testend
  430.         bne testok
  431.         lda bahnneu,x
  432.         cmp limit
  433.         bcc testend
  434. testok  lda count
  435.         sta bahnalt,x
  436.         lda count+1
  437.         sta bahnalt+1,x
  438.         lda count+2
  439.         sta bahnalt+2,x
  440.         ldx temp
  441.         lda #1
  442.         sta flag,x
  443. testend ldx temp
  444.         lda #1
  445.         sta event
  446.         rts
  447.  
  448. color   lda #0
  449.         sta 53280
  450.         sta 53281
  451.         lda #1
  452.         sta 646
  453.         rts
  454.  
  455.         ;basiceinsprung: sys cursor,x,y
  456. cursor  jsr $b7f1
  457.         stx 211
  458.         jsr $b7f1
  459.         stx 214
  460.         jsr $e510
  461.         rts
  462.  
  463.  
  464. outbasic
  465.         ;basiceinsprung: sys outbasic,rundenzahl,x,y
  466.         jsr $b7f1
  467.         stx 1000
  468.         jsr $b7f1
  469.         stx 1001
  470.         jsr $b7f1
  471.         stx 1002
  472.         jmp out
  473.         rts
  474.  
  475.  
  476. ;--- scroll
  477. ;
  478.         ;basiceinsprung: sys scroll,bahnnummer
  479. scroll  jsr $b7f1
  480.         ;ass einsprung: x=bahnnummer
  481. ;       cpx #4
  482. ;       bcs endscroll
  483. scrollass       txa
  484.         asl
  485.         tax
  486.         lda timepos,x
  487.         sta lo2
  488.         lda timepos+1,x
  489.         sta hi2
  490.         ldx #7
  491. scroll1 clc
  492.         lda lo2
  493.         adc #40
  494.         sta lo1
  495.         lda hi2
  496.         adc #0
  497.         sta hi1
  498.         ldy #0
  499. scroll2 lda (lo2),y
  500.         sta (lo1),y
  501.         iny
  502.         cpy #8
  503.         bne scroll2
  504.         sec
  505.         lda lo2
  506.         sbc #40
  507.         sta lo2
  508.         lda hi2
  509.         sbc #0
  510.         sta hi2
  511.         dex
  512.         bne scroll1
  513. endscroll       rts
  514.  
  515. ;------------------------------------------------------------------------
  516. div100
  517.         ;teilt durch 100
  518.         ;a=hi ergebnis -> a
  519.         ;y=mi ergebnis -> y
  520.         ;x=lo ergebnis -> x
  521.  
  522.         stx $22
  523.         sty $23
  524.         sta $24
  525.         rts
  526.  
  527. ;------------------------------------------------------------------------
  528. printtime
  529.         ;gibt zeit an koordinate aus
  530.         ldy #0
  531.         lda count1g
  532.         clc
  533.         adc #48
  534.         sta (lo2),y
  535.         iny
  536.         lda count1h
  537.         adc #48
  538.         sta (lo2),y
  539.         iny
  540.         lda count1l
  541.         adc #48
  542.         sta (lo2),y
  543.         iny
  544.         lda #58
  545.         sta (lo2),y
  546.         iny
  547.         lda count60h
  548.         adc #48
  549.         sta (lo2),y
  550.         iny
  551.         lda count60l
  552.         adc #48
  553.         sta (lo2),y
  554.         iny
  555.         lda #39
  556.         sta (lo2),y
  557.         iny
  558.         lda count100h
  559.         adc #48
  560.         sta (lo2),y
  561.         iny
  562.         lda count100l
  563.         adc #48
  564.         sta (lo2),y
  565.         iny
  566.         rts
  567.  
  568.  
  569. ;------------------------------------------------------------------------
  570. xytoprint
  571.         ;rechnet x-y koordinate in bildschirmadresse um
  572.         ;x:= x-pos
  573.         ;y:= y-pos
  574.         ;adresse -> lo2,hi2
  575.  
  576.         tya
  577.         asl
  578.         tay
  579.         lda mult40,y
  580.         sta lo2
  581.         lda mult40+1,y
  582.         sta hi2
  583.         clc
  584.         txa
  585.         adc lo2
  586.         sta lo2
  587.         lda hi2
  588.         adc #0
  589.         sta hi2
  590.         rts
  591.  
  592. resettime
  593.         lda #0
  594.         sta count
  595.         sta count+1
  596.         sta count+2
  597.         sta count1l
  598.         sta count1h
  599.         sta count1g
  600.         sta count60l
  601.         sta count60h
  602.         sta count100l
  603.         sta count100h
  604.           sta count
  605.         sta count+1
  606.         sta count+2
  607.         sta flag
  608.         sta flag+1
  609.         sta flag+2
  610.         sta flag+3
  611.         rts
  612.