Atomic Machine Code by Ecce Productions 1982
Atomic Machine Code by Ecce Productions 1982
ON ERROR 9
SEARCH LINES 12
DELETE LINES 19
RENUMBER 23
REALTIME CLOCK 29
READ/DATA/RESTORE 32
*CAT STORE 36
DIRECT HEX 39
1-<EV SCAN 43
TRANSFER: TEXT 44
FLASH I t..JG L I NEB 45
LONG STRINGS 47
ALF'HABETA SORT 49
DESIGN LETTERS 52
MENU 59
FRUIT MACHINE 65
PONTOON 72
POOLS PREDICATION 86
SCREENCHASE 99
What are the advantages of machine code over BASIC, only one
really and that is speed. You will see as you read this book
that many of the programmes have delays written in to make
them perform at a more human rate. On the other hand a
machine code programm can take an enormous time to de-bug
but the BRK & PAGE 0 programme does help!
Many o-f the programmes in this book are tool kit type but
the manipulation of BASIC lines with the comparisons, the
movement of data and the large areas of text are an ideal
starting point for demonstrating machine code programmes.
The book assumes the reader has a good working knowledge of
BASIC and therefore there are no notes to the BASIC sections
of the following programmes.
All the programmes work and at the time of writing would not
seem to have any bugs in them, but they are not guaranteed
bug free!. Somebody will find a way to make them crash.
PART N0:1
PART NO: :2
lOIN."START NUMBER"R
20'#80=R
30IN."STEP"R
40?#82=R
50LI.#2863
LINES:-
510-660 Set up address of new BASIC statement and jump
to interpreter. Restore original address on return.
670-780 Store Line Number in Buffer and display in
decimal on VDU.
790-850 Get character from keyboard, look for ESC and
e>:it if found.
860-910 Look for start of machine code character {[}.
Check every input to allow for multi-statement lines.
920-930 Jump over next if not 1st keyboard character.
940-1020 Check if M/C entry being made, if not check for
label, if no label then olltput space to buffer.
1030-1100 Output character to VDU, check for DELETE. If
found adjust X. Suroutine #FE52 will have deleted character
on VDU. Do not allow X to point to Line Number.
1110-1170 Check for end of M/C entry and for end of line.
1190-1340 Transfer contents of Buffer to current Text area
and add End of Text Marker.
1350-1410 Adjust Line Number by addin°;J Step and then loop
for next line or exit.
10
1260LDA@#9E :pointed ta by contents of #82
1270STA#817F,X
1280.JSR#FFED :Output CR/LF
1290JSR#C9D8 :GOTO standard ERROR handler
2000); R.
LINES:-
510-560 Set #80,#81 to address of text space where error
occured.
580-690 Find and store address of Nth line.
700-750 Check H.B of each line with #2 which contains H.
B of 1 ine where error occured.
760-790 Do same for L.B Llntil line number is found.
800-855 Calculate position of offending character and
store.
860-900 Print top line of display.
910-970 Reset cursor position.
980-1020 Print line number.
1030-1090 Print line.
1100-1180. Print 2nd line of display.
1250-1290 Print arrow then exit to standard error routine.
11
Search Lines
A programme which will search any text area for a character
or series of characters. If found the full line containing
the character<s> will be printed out. It will return with a
message if no occurrence or no text in specified area.
5REM SEARCHLINES
lODIM WW1B,B32,C32,D5,E12
20F.N=OT01B;DIMP-1;WWN=P;N.
30F.N=1T02;P=#2800;GOS.a;N.
35P.$6$12
40$C="NONE FOUND"
45$E="NO TEXT IN#"
50IN."TEXT AREA"A
60?#81=A;?#80=0
70IN. "DATA TO BE FOUND"$B
BOLI.#2800
90IN."MORE DATA IN SAME
AREA $D
11
100IFCH$D=CH"Y" 6.60
llOIN."NEW TEXT AREA"$D
120IFCH$D=CH"Y"6.50
130E.
500a[
510:WWOLDX@O
520STX#B2 :Set page O locations to O
530STX#83
540STX#43
550STX#34
560LDYG>O
570LDA<#SO>,Y :See if there is text in area
580CMPG>#D
590BNEWW13 :If not GOTO WW13
600INY :Move Y past line number
605INY
610STY#82 :Y now points to 1st character
12
620:WW1LDA#82 :Add Y to #80,#81. On 1st pass
630CLC :#80,#81 will contain address
640ADC#80 :of 1st character, on
650STA#80 :subsequent loops #B0,#81 will
660BCCWW2 :contain address of first
670INC#81 :location after #D character
680:WW2LDY@O
690LDA{#80>,Y :Look for End of Text Marker
700CMP@#FF
710BEQWW10 :If found GOTO WW10
720INY
730:WW3INY :Move Y past line number
740LDA<#80>,Y
750CMPG>#D :Look for #D
760BNEWW3 :Loop until found
770INY :Point Y at following location
780STY#82 :and store Y in #82
790LDY@1 :Point Y to start of line
800:WW4LDX'1>0 :statement
810:WW5INY :Compare each character of line
820CPY#82 :with 1st character of $B, If =
830BEQWW1 :try next characters until #D
840LDAB,X :is found in $B then GOTO WW6.
850CMP@#D :If not found or characters<>
860BEQWW6 :reset $B pointer (X) to O and
870CMP(#BO>,Y :try all characters in line
880BNEWW4 :until Y=?#82 then loop for
890INX :next line
900JMPWW5
910:WW6LDY@O :Set Y to point to H.B of line
920LDA<#BO>,Y :number, get H.B then L.B and
930STA#25 :store in page 0 locations used
940INY :by #C589 then GOSUB #C589 to
950LDA <#80) , "!' :print line numbe~ in decimal
960STA#16
970JSR#C589
980INC#83 :Set #83 > 0 to indicate data
985INY :found
990: W&<J7 I NY
1000LDA{#80),Y :Print line to VDU
1010CMP@#D
1020BEQWW8
1030JSR#FE52
1040JMPWW7
1050:WW8JSRWW9 :GOSUB WW9 <Delay)
1060JSR#FFED
1070JMPWW1 :Loop for next line
1080:WW9LDX@#60 :Delay
1090JSR#FB83
1100RTS
1110: WW10LDA#83 :Has data been found
1120BNEWW12 :If <>O data found
:1. 3
1130LDXG>O :
1140:WW11LDAC,X :Print $C routine
1150CMP@#D
1160BEQWW12
1170JSR#FE52
1180INX
1190JMPWW11
1200:WW12JSR#FFED :Output CR/LF
1210RTS :and exit
1220:WW13LDAE,X :Print $E routine
1230CMP@#D
1240BEQWW14
1250JSR#FE52
1260INX
1270JMPWW13
1280:WW14LDA#B1 :Print contents of #81
1290JSR#F802 :as 2 ASCII numerals
1295JSR#FFED
1300JMPWW12
1500J;R.
LINES:-
510-610 Checks for text in area specified.
620-670 Adjusts contents of #80,#81 so they contain
address of line being investigated.
680-780 Finds length of current line, points at next
location and stores result in #82.
790-900 Comparison routine.
910-1040 Prints line number and line.
1050-1100 Subroutine which delays and the prints CR/LF.
1110-1300 Prints message strings.
COMPARISON ROUTINE:
14
Brl( 8 Page 0 Routine
An essential machine code de-bugging tool. On BRK the
processor jumps to address in #202,#203 so store address of
this programme in !#202. All registers are preserved but the
VDU is cleared so beware of using during graphic programmes.
The display consists of the programme counter, the status
register displayed as flags, the X register, the Y register
and the accumulator. This programme will return
automatically after a short wait unless CTRL is pressed, if
so it will display contents of page 0 locations #80 - #9F
inclusive and will then wait for any key to be pressed
before returning.
16
1180:QQ5JSR#F7FD :Output a space, get X,Y and A
1190LDA#28FC, Y :from store, output to VDU as
1200JSR#FB02 :2 ASCII numerals
1210DEY
1220BNEQQ5
1230JSR#FFED
1240LDX@#20 :Wait
1250JSR#FB83
1260BIT#B001 :See if Bit 6 of #8001 is clear
1270BVCQQB :If so CTRL is pressed GOTO QQ8
1280:QQ12LDX#28FF :Restore X
1290LDY#2BFE :Restore Y
1300LDA@#80 :Switch on cursor
1310STA#E1
1320LDA#28FD :Restore Accum
1330RTI :Return from interrupt
1340:QQ8 LDA@#BO :Store display data
1350STA#28FA
1360JSR#FFED
1370LDX@O
1380STX#2BFB :Clear pointer to page 0 store
1390LDX@4 :Load X with No of lines to
1400:QQ9STX#28FC :print
1410LDY@8 :Load Y with No of columns to
1420STY#EO :print and set column start
1430:QQ10LDA#2BFA :position
1440JSR#F802 :Output page 0 location names
1450JSR#F7FD :with space between each
1460INC#28FA
1470DEY
1480BNEQQ10
1490LDY@8 :Reset column position
1500STY#EO
1510LDX#28FB :Load X with pointer to page O,
1520:QQ11LDA#BO,X :get contents of page 0 and
1530JSR#F802 :output as 2 ASCII numerals to
1540JSR#F7FD :VDU. Do for 8 locations with
1550INX :space between each
1560DEY
1570BNEQQ11
1580STX#28FB :Save pointer
1590JSR#FFED
1600LDX#28FC :Set number of lines
1610DEX : and loop for
1620BNEQQ9 :4 lines
1630JSR#FFE3 :Wait for key to be pressed
1640JMPQQ12 :before returning
1650J;R.
LINES:-
510-580 A method of storing strings.
620-740 Save registers ~nd adjust return address.
17
750-910 Prints string.
930-1050 Prints programme counter.
1060-1160 Prints status register.
1170-1230 Prints X,Y and Accum.
1240-1270 Delay and see if CTRL pressed.
1280-1330 Restores registers and returns from interrupt.
1340-1640 Prints contents of #80 to #9F.
Accum now holds #31 which is the ASCII code for "1", this
code is output to t.he VDU and programme loops until all
eights bits are done.
18
Delete Lines
This programme will delete any line or number of lines in
any te}:t area. Once assembled in text area, say #39, it can
be called by LINK#3900 or via the Menu programme later in
this book.
20
1110CLC
1120ADC#82
1130STA#82
1140BCCKK10 :Loop until finish line number
1150INC#83 :or end of text is found
1160:KK10JMPKK7
1164:KK17JMPKK25 :Stepping stones to KK25
1168:KK18JMPKK26 :and KK26
1170: KK11 INV
1180LDA<#B2>,Y :Adjust #82,#83 so that they
1190CMP@#D :contain address of line
1200BNEKK11 :following finish line
1210INY
1220TYA
1230CLC
1240ADC#82
1250STA#82
1260BCCKK12
1270INC#83
1280:KK12LDY'1>0 :Move memory from address in
1290:KK13LDA(#82>,Y :#82,#83 to address in #80,#81.
1300STA(#80>,Y :Do for each line until #D is
1310CMP@#D :found then check for end of
1320BEQKK15 :text, if found exit otherwise
1330:KK14INY :continue until Y increments to
1340BNEKK13 :O then increment H.Bs in #81
1350INC#83 :and #83, then loop until end
1360INC#81 :of text
1370JMPKK13
1380:KK15INY
1390BNEKK16
1400INC#83
1410INC#B1
1420:KK16LDA<#B2>,Y
1430STA<#BO>,Y
1440CMP@#FF
1450BNEKK14
1460RTS
1470:KK25LDA@#BO :Store $C address L.B in #85
1480STA#85
1490INC#87 :Set #87 > 0
1500JMPKK21
1510:KK26LDA@#AO :Store $8 address L.B in #85
1520STA#85
1530JMPKK20
1540:KK19LDA@#CO :Store $E address L.B in #85
1550STA#S5
1560:KK20LDY@O
1570STY#87 :Clear #87
15SO:KK21LDA'1>#3A :Store strings H.B address in
1590STA#86 :#86
1600:KK22LDA(#85>,Y :Print message string routine
21
1610CMP:i>#D
1620BEQKK23
1625JSR#FE52
1630INY
1640JMPKK22
1650:KK23LDA#87 : I f ?#87=0
1660BEQKK24 :SOTO KK24
1670LDA#81 :Print contents of
1680JSR#F802 :#81 as 2 numerals
1690:KK24JSR#FFED
1700RTS
1710J;R.
1790b[
1800:WWO LDY@O :String store routine
1810:WW1 LDAC,Y
1820STA#3A80,Y
1830CMP@#D
1840BEQWW2
1850INY
1860JMPWW1
1870:WW2LDY@O
1880:WW3LDAS,Y
1890STA#3AAO,Y
1900CMP@#D
1910BEQWW4
1920INY
1930JMPWW3
1940:WW4LDY@O
1950:WW5LDAE,Y
1960STA#3ACO,Y
1970CMP@#D
1980BEQWW6
1990INY
2000JMPWW5
2010:WW6RTS
3000J;R.
LINES:-
510-590 Check for text in area specified.
600-1270 Look for start and finish lines, if found stores
addresses.
1280-1460 Deletes text by moving remaining text up.
1470-1640 Prints message strings.
1650-1700 Prints # number after $C.
1800-2010 Stores message strings.
22
Renumber
A programme that will renumber any line or number of lines
and sort them into the correct numerical order.
5REM RENUMBER
10DIMZZ29
20F.N=OT029;DIMP-1;ZZN=P;N.
30F.N=1T02;P=#3200;GOS.a;N.
40R=#9200
50$R="START NUMBER NOT FOUND"
60!#85=0
70 1 #89=0
BOIN."START LINE"R
90!#85=R
100IN."END LINE"R
110!#87=R
120IN."NEW START NO"R
130!#89=R
140IN."STEP"R
150?#8B=R
160IN."TEXT AREA"R
170?#BC=R
180L I. #3200
200E.
500a[
520:ZZOLDA#SC :Load #80,#81 with address of
540STA#81 :1st line
560LDA@1
570STA#BO
580:ZZ1LDY@O :Look for start line number
23
600:ZZ2LDA<#BO>,Y :routine. Note that this
620CPV@2 :routine also looks for end of
640BCCZZ3 :text marker and end of line
660Cl'IP@#D :marker. A saving in size
6BOBEQZZ5 :compared to previous
700:ZZ3CMN>#FF :programmes
720BEQZZ6
740CMP#86
760BEQZZ7
820:ZZ4INY
840JMPZZ2
860:ZZ5JSRZZ15 :Also note this subroutine
BBOJMPZZl
900:ZZ6JMPZZ13 :Stepping stone
920:ZZ7INY
940LDAC#BO>,Y :Compare L.B of line number
960CMP#B5 :with L.B of start number
9BOBNEZZ4
1000:ZZBLDA#B9 :Get L.B of new number and
1020STAC#SO>,Y :store
1040DEY :Point Y at H.B
1060LDA#BA :Get new H.B and store
10BOSTA<#BO>,Y
1100INY :Move Y past
1120:ZZ9INY :line number and
1140LDA C#80), Y :loop until #D is found
1160CMP@#D
11BOBNEZZ9
1200JSRZ Z15 :Adjust address in #80,#81
1220LDA#89 :Add step to new line number
1240CLC
1260ADC#BB
1280STA#89
1300BCCZZ10
1320INC#8A
1340:ZZ10LDY@O :Look for end of text
1360LDAC#BO>,Y :Look for finish line
1370INY
1380CMP@#FF
1400BEQZZ12
1420CMP#88
1430BNEZZ8 :If not found loop for new
1440LDAC#BO>,Y :number and continue until
1460CMP#87 :finish line or end of text is
1480BNEZZ8 :found
1540: ZZ 11 LDA#89 :Store final new number
1560STA <ttBO > , Y
1580DEY
1600LDA#BA
1620STAC#80>,Y
1640:ZZ12JSRZZ17 :GOSUB Sort routine
1660RTS
24
1680:ZZ13LDY@O :Print $#9200 routine
1700:ZZ14LDA#9200,Y
1720CMP@#D
1740BEQZZ12 :
1760JSR#FE52
17BOINY :
1800JMPZZ14
1820:ZZ15INY :Subroutine to add Y register
1840TYA :to contents of #B0,#81
1860CLC :
1BBOADC#BO
1900STA#80 :
1920BCCZZ16
1940INC#81
1960:ZZ16RTS
1980:ZZ17LDA#BC :Sort subroutine
2000STA#B1 :Reset #80,#81 to contain start
2020LDA@1 :address of text
2040STA#80
2060LDX@O :
2070LDY@#FF
20BOSTX#B4 :Clear change flag
2090:ZZ1BINY
2100:ZZ19LDA<#80>,Y
2110CPY4>0 :Look for end of text marker
2120BNEZZ20 :only when Y=O
2130CMPG>#FF
2140BNEZZ18
2160LDA#B4 :If end of text check #84 to
21BOBNEZZ17 :see if changes have been made,
2200RTS :loop until no changes made
2220:ZZ20CPY@2 :Do not check for #D in line
2230BCCZZ18 :number
2240CMP'1>#D :Find end of line, point Y at
2250BNEZZ18 :next location
2260LDA#81 :Transfer H.B to #83
22BOSTA#B3
2290INY :Add Y to #80 and store in #82
2300TYA :On exit #80,#81 will contain
2320CLC :address of line N and #82,#83
2340ADC#80 :will contain address of line
2360STA#82 :N+1
2380BCCZZ21
2400INC#B3
2420:ZZ21LDY'1>0 :Compare H.B of line N with H.B
2440LDA<#BO>,Y :of line N+1. If >= GOTO ZZ23
2460CMPC#B2>,Y :otherwise transfer address in
2480BCSZZ23 :#82,#83 to #80,#81 and loop to
2500:ZZ22LDA#83 :check next line
2520STA#B1
2540LDA#82
2560STA#80
25
2580LDY@O
2600JMPZZ19
2620:ZZ23BNEZZ24 :If H.Bs <>GOTO ZZ24
2640INY :Point Y at L.Bs
2660LDAC#82>,Y :Compare L.Bs, if >= loop to
2680CMPC#80>,Y :check next line
2700BCSZZ22
2720:ZZ24JSRZZ25 :GOSUB Change routine
2760LDY@#FF
2770JHPZZ18
2780:ZZ25INC#84 :Set #84<>0 to show change
2800LDY@#FF
2820:ZZ26INY
2840LDAC#80>,Y :Store line N in temporary
2860STA#140,Y :store
2880CPY@2
2900BCCZZ26
2920CHP@#D
2940BNEZZ26
2960LDY@#FF
2980:ZZ27INY
3000LDAC#B2>,V :Store line N+1 at address of
3020STAC#BO>,V :line N
3040CPY@2
3060BCCZZ27
30BOCHPG.>#D
3100BNEZZ27
3120INY :Adjust #80,#81 to contain
3140TYA :address of 1st location after
3160CLC :line N+1's #D character
3180ADC#80
3200STA#80
3220BCCZZ28
3240INC#81
3260:ZZ28LDY@#FF
3280:ZZ29INY
3300LDA#140,Y :Get line N from temporary
3320STA<#BO>,Y :store and store at new address
3340CPY@2 :contained in #80,#81
3360BCCZZ29
3380CMP@#D
3400BNEZZ29
3420LDY@O
3440RTS
5000J;R.
LINES:-
520-980 Find start line.
1000-1080 Store new line number.
1100-1620 Look for finish line while continuing to
renumber. If finish line not found exit on end of text
marker.
26
1680-1800 Print $#9200.
1820-1960 Subroutine for adding Y to #80,#81.
1980-2770 Comparison routine.
2780-3440 Change routine.
COMPARISON ROUTINE:
The H.B of line N is compared with the H.B of line N+l.
Lines are in correct order if it is less than. Lines are in
incorrect order if it is greater than, and need changing. If
there is equality the L.B of N+l is compared to the L.B of N.
They are in incorrect order if it is less than and a change
is necessary. If result is greater than or equal no change
is necessary. This allows for two lines with the same number,
a not uncommon occurrence during renumbering of sections!
Note that the accumulator is loaded with the H.B of line N
then with the L.B of line N+1. This allows a single branch
instruction as BCS after CMP recognizes greater than and
equal to.
CHANGE ROUTINE:
Line N is moved to a temporary store.
Line N+l is moved to original address of line N.
The address of 1st location after line N+l is found.
Line N is moved from temporary store to this address.
INDIRECT Y ADDRESSING:
There are 8 Indirect Y instructions which may be used with
any page 0 reference and these are:
27
And End of Data
This programme will find an End of Data Marker and return
with its address. Also included is a small subroutine which
clears page O locations. Normally these routines would be
used in larger programmes.
28
Realtime Clod(
This programme uses Timer 1 of the 6522 VIA chip to generate
interrupts. On interrupt the processor will update a digital
clock which is displayed at the top right hand corner of the
VDU. This clock will continue to run until BREAK is pressed
and there is no noticeable increase in execution times. No
page O locations are used, nor any subroutines.
5REM CLOCK
10DIMPP8
20R=#28F7
30F.N=OT08;P=#2800;PPN=P;N.
40F.N=1T02;P=#2800;605.a;N.
50P.$12"ENTER 0 BEFORE SINGLE
NOS"'
60IN."HOUR"$R :Store start time as a string
70R=R+LENR :of ASCII codes at address R
80IN."MINS"$R
90R=R+LENR
100IN."SECS"$R
120?#28FD=20 :Set 1/20th sec counter
130?#B80B=#40 :Set Timer 1 to free run
140?#B80E=#CO :Enable Timer 1 interrupts
150?#B806=#50 :Load Timer 1 low latch
160?#B805=#C3 :Load Timer 1 high counter
170?#204=0 :Set IRQ address
180?#205=#28
190P.$12
200E.
500a[
510:PPOPHP :Push status register an stack
520STY#28FF :Save Y and X
530STX#28FE
540LDA@#40 :Clear interrupt flag
550STA#B80D
590DEC#28FD :Decrement 1/20th counter
600BNEPP1 :If <>O SOTO PP1
610LDA@20 :Reset counter to 20
620STA#28FD
630LDX@6 :Load X with pointer to Secs*1
640JSRPP5 :Add 1 to Secs*!
650CMP@#3A :If <ASCII code for 9+1
660BNEPP1 :SOTO PP1
29
670JSRPP6 :Set Secs*l to 0
680DEX :Point to Secs*10
690JSRPP5 :Add 1 to Secs*lO
700CMPQ)#36 :If <>ASCII code for 6
710BNEPP1 :GOTO PP1
720JSRPP6 :Set Secs*lO to 0
730DEX :Point to Mins*1
740JSRPP5 :Add 1 to Mins*1
750CMP@#3A : I f <> #3A
760BNEPP1 :GOTO PPl
770JSRPP6 :Set Mins*l to 0
780DEX :Point tc Mins*10
790JSRPP5 :Add 1 to Mins•10
800CMP@#36 : If <> #3!:>
810BNEPP1 :GOTO PP1
820·JSRPP6 :Set Mins*10 to O
830DEX :Point to Hours*!
840JSRPP5 :Add 1 to Hours*1
850JSRPP7 :GOSUB Che~k Hours
860BNEPP1 : I f <> GOTO PP 1
950JSRPP6 :Set Hou~s*1 to 0
960DEX :Point to HoursllO
970JSRPP5 :Add 1 to Hours*10
980CMPG>#32 :If <> #32
990BNEPP1 :GOTO PP1
1000JSRPP6 :Set Hours*10 to 0
1010INX :Point to Hours*1
1020JSRPP5 :Add 1 to Hours*l
1030:PP1LDX<i>6 :Print display routine, Y
1040LDY:1>8 :points to VDU RAM locations, X
1050:PP2LDA#28F6,X :points to clock data locations
1060STA#8017,Y
1070DEX
1080DEY
1090CPY@6
1100BNEPP2
1110LDA@CH":" :Separate secs and mins with {:
1120STA#8017,Y : } symbol
1130DEY
1140:PP3LDA#28F6,X
1150STA#8017,Y
1160DEX
1170DEY
1180CPY<i>3
1190BNEPP3
1200LDA<i>CH":" :Separate hours and mins
1210STA#8017,Y
1220:PP4LDA#28F6,X :As all calculations use ASCII
1230STA#8017,X :codes it is possible to store
1240DEX :results directly in VDU RAM
1250BNEPP4
1280LDY#28FF :Restore Y register
30
1290LDX#28FE :Restore X register
1300PLP :Restore Status register
1310PLA :Restore Accum
1320CLI :Clear Interrupt flag
1330RTI :Return from interrupt
1340:PP5LDA#28F6,X :Add 1 to contents of location
1350CLC :pointed to by X
1360ADC@1
1370STA#28F6,X
1380RTS
1390:PP6LDA@#30 :Store ASCII code for 0 in
1400STA#28F6,X :location pointed to by X
1410RTS
1420:PP7PHA :Push Hours*! data on stack
1430LDA#28F7 :Look at Hours*10 data
1440CMP@#30 : I f = ASCII 0
1450BEQPP8 :GOTO PPB
1460PLA :Restore Hours*1 to Accum and
1470CMP@#33 :compare to #33, return with Z
1480RTS :flag set or clear
1490:PPBPLA :Restore Hours*1 to Accum and
1500CMP@#3A :compare to #3A, return with Z
1510RTS :flag set or clear
2000J;R.
LINES:-
510-530 Save X,Y and Status registers.
540-620 Clear 6522 interrupt flags and decrement 1/20th
sec counter. Reset counter on reaching O.
630-1020 Increment Secs, Mins and Hours as required.
1030-1250 Display time.
1280-1330 Restore all registers and return.
1340-1380 Add 1 to contents of location pointed to by X.
1390-1410 Store ASCII code for 0 in location pointed to by
x.
1420-1510 Allow Hours*! to increment to 10 if Hours*10 = 0
or increment to 3 if Hours*10 = 1. This provides for a 12
hour clock.
Note also the use of a string to hold the clock start time
and the necessity to enter O's before single numbers.
31
Rczad/Data/Restore
This p~ogramme adds the useful instructions READ, DATA and
RESTORE to ATOM BASIC. To execute !#202 must be set to
contain address of this programme.
5REM READ/DATA/RESTORE
10DIMCC27,S15
20F.N=OT027;P=#3900;CCN=P;N.
30F.N=1T02;P=#3900;GOS.a;
S=P+1; N.
50$S="RESTOREDATAREAD" :Store $5 immediately after MIC
60E.
500a[
520:CCC)
540LDX@#FF
560JSRCC2 :See if word being interpreted
580CPX@7 :is RESTORE, if X=7 it is so
600BEQCC5 :GOTO CC5
620LDX@6 : Point X to ne}:t word
640JSRCC2 :Is word DATA
660CPX@#B :If X=#B it is so
680BEQCC6 :GOTO CC6
700LDX@:ftA :Point X at next word
720JSRCC2 :Is word READ
740CPX@#F :If X=#F it is so
760BEQCC10 :GOTO CC10
780:CC1JMP#C9DS :Jump to standard ERROR routine
800:CC2LDY@O :Comparison subroutine
820:CC3INX
840:CC4INY
850LDA(#5>,Y
860CMP@#20
870BEQCC4
880CMP S,X
900BEQCC3 :Returns with X pointing at the
920RTS :1st unequal character
32:
940:CC5.JSRCC23
960:CC6.JSRCCB
980:CC?TSX :Transfer Stack pointer to X
1000INX :Point X at
1020INX :L.B return address
1040LDA@#F6 :Store new L.B
1060STA#100,X
10BOINX :Point X at H.B
11 OOLDA@#C4 :Store new H.B
1140STA#100,X
1160LDA(#5},Y
1 lBORTI
1200:CC8LDY@1 :Subroutine which returns with
1220:CC9INY :Y pointing at #D
1240LDA<#S>,Y
1260CMP@#D
1280BNECC9
1300RTS
1320:CC10CMP@CH"$" :Look for "$" after READ
1340BNECC1
1360INY :Point Y at next character
1380LDA(#5),Y :Get character
1400SEC :Subtract #40 to give
14 20SBC:l>#40 :1 to 26 offset
1440TAX :Transfer result to X
1460LDA#321,X :Get L.B of string variable
1480STA#82 : Store in #82
1500LDA#33C,X :Get H.B of string variable
1520STA#83 :Store in #83
i540LDA#84 :See if DATA has been found
1560BNECC11 : I f so GOTO CC11
1580JSRCC24 :GOSUB Find DATA
16~)(1: CC11LDY~~#FF :Store DATA statement at string
162G~: CC12INY :variable address
1640LDA\#80),Y :Loop until DATA delimiter {,}
1660CMF;iJCH u 3. n :or end of line found
1680BEQCC13
170GCMP@#D
1720BEQCCi4
1740S TA <:#"82; , Y
176C"1MPCC12
1 780: CC 13LDA;j)#D :Store #D at end of DATA, set
1800STA \#82), Y : #80 • #8 i as address of ne>: t
1820JSRCC17 :DATA
1840JMPCC6
1860:CC14LDA;;J#D :Store #D at end of DATA, see
18805TA\#82),Y :if next line is DATA and reset
1900INY :address in #80,#81, if not
1920INY :find 1st DATA line and reset
1940JSRCC21 :#80,#81 to that address
1'7'60CPX@#B
1980BNECC15
33
2000JSRCC18
2020JMPCC6
2040:CC15JSRCC24
2060JMPCC6
2080:CC16INY :Add Y to #8C,#81 routine
2100:CC17INY :Note varioue entry points
2120:CC18TYA
2140CLC
2160ADC#80
2i80STA#80
2200BCCCC19
2220INC#B1
2240:CC19RTS
2260:CC20LDY@#FF
22BO:CC21LDX@6 :Check if statement is DATA
2300:CC22INX
2320:CC23INY
2340LDAC#SO>,Y
2360CMP@#20
2380BEQCC23
2400CMP S,X
2420BEQCC22
2440RTS
2460:CC24INC#84 :Set #84 >O to indicate DATA
24BOLDA#12 :found
2500STA#81 :Load #80,#81 with address of
2520LDA@O :Text area
254(1STA#80
2580: CC25LDY;i)#FF
2600:CC26INY :Find start of Nth line
2620LDA(#80),Y
2640CMP;i>#D
2660BNECC26
2680INY
2700LDA(#BO>,Y :Check for end of text
2720BPLCC27
2740JMPCC1 :If found exit to ERROR
2760:CC27.JSRCC16 :Move Y past line number~
2780JSRCC20 :adjust #80,#81, see if 1st
2800CPX;i)#B :statement in line is DATA
2840BNECC26 :If not loop for next line and
2860JSRCC18 : do unti 1 DATA or end of te;{t
2900RTS :is found
5000J;R.
LINES:-
520-780 Check statement to see if RESTORE,DATA or READ.
If not jump to standard error routine.
800-920 Comparison subroutine. Returns with X containing
number of valid comparisons plus 1.
980-1180 Store new return address in stack and return to
that address.
34
1200-1300 Find end of line subroutine.
1320-1340 Check for "$" character after READ.
1360-1520 Find which string variable, get string address
and transfer address to #82,#83.
1540-1580 See if line containing DATA statement has been
found. Find if not.
1600-2020 Read data into address in #82,#83. When
delimiter character or end of line found, store #D after
read string and adjust data address.
2080-2240 Adds V to #80,#81.
2260-2440 Returns with X=#B if DATA statement found.
2460-2860 Looks through programme lines for the first
occurrence of DATA statement. Returns with #80,#81 containing
address of first character after DATA statement. If DATA
statement not found in programme standard error rountine is
used.
The new return address #C4F6 ensures that BASIC FOR ••• NEXT
and DO ••• UNTIL loops are kept intact. On entry to CC7 V
always points to the last character in the line, so Line
1160 always loads the accumulator with #D before returning.
35
CatStorcz
If you use long audio cassettes it can be a chore to
catalogue the full tape, especially as the *CAT routine
prints out all the blocks. This routine will catalogue a
full tape and o~ly display one name for each programme. It
also stores those names at #9000 onwards so that they can be
accessed after the tape has finished. The bell is rung
whenever a net-1 name is encountered.
36
780BNEPP6 :SOTO PP6
840LDXG>2
850:PP3JSR#FBEE :Get byte from tape
860CMPG>#2A :Is it #2A
880BNEPP2 :If not GOTO PP2
900DEX :Loop until 2 #2A codes are
920BNEPP3 :obtained from tape
950LDY@O
960:PP4JSR#FBEE :Get next byte from tape
980CMP@#2A :Loop until not #2A
1000BEQPP4
1020STA#21C,Y :Store in buffer
1040INY :and loop
1060CMP@#D :until #D
1080BNEPP4 : is found
11 OOLDY@#FF
1120:PP5INY
1140LDA#21C,Y :Compare name in buffer with
1160CMP (#80), Y :current name
1180BNEPP7 :If new name GOTO PP7
1200CMP@#D :If same GOSUB PP17
1220BNEPP5
1230JSRPP17 :
1240JMPPP2 :and then loop
1280:PP6RTS
1290:PP7LDA#86 :If ?#86=0 then 1st name
1300BEQPP8 :GOTO PPB
1320LDA#82 :Load #80,#81 with
1340STA#80 :next free space address
1360LDA#83
1380STA#81
1400:PP8LDY@#FF
1410INC#86 :Increment No of names counter
1420:PP9INY :Store
1440LDA#21C,Y :name in buffer
1460STA(#BO>,Y : in main store
1480CMP@#D
1500BNEPP9
1520INY :Adjust #82,#83 to contain
1660TYA :address of 1st free space
1680CLC
1700ADC#80
1720STA#82
1740BCCPP10
1760INC#83 :
1770:PP10LDV:i>O :Store end of text marker
1780LDAG>#FF :
1790STA<#B2>,Y
1800LDAG>5 :Sound
1810JSR#FD1C :bell
1820LDY:li>-O
1B40:PP11LDA@12 :Clear screen
37
1860JS.R#FE52
1880:PP12LDY:i>O :Print data in name store to
1900LDAC#84),Y :VDU
1920CMP@#FF
1940BEQPP16
1960:PP13LDA(#84),V
1980CMP4>#D
2000BEQPP14
2020JSR#FE52
2040INY
206(1JMPPP 13
2070:PP14INY
2380TYA
2400CLC
2420ADC#84
2440STA#84
2460BCCPP15
2480INC#85
2500:PP15JSR#FFED
2520JMPPP12
2530:PP16LDAG>O :Reset #84,#85 to start address
2540STA#84 :of main name store
2560LDA4>#90
2580STA#85
2590JSRPP17
2600JMPPP2
2800:PP17JSR#FBEE :Wait for end of data marker
2820CMP;i>#D :from tape
2840BNEPP17
2860JSR#FBEE
2880CMP~#FF
2900BNEPP17
2920RTS
5000J;R.
LINES:-
500-580 Clear page 0 locations ana start o+ main store.
620-650 Set up high bytes.
660-740 Clear VDU, print PLAY TAPE and delay.
760-780 Scan keyboard.
840-920 Get bytes from tape until 2 #2A codes have been
obtained.
1:;>50-1080 Store subsequent bytes in buffer.
1100-1280 Compare current name with name in buffer.
1290-1380 Checks for 1st name,transfers free space ·address.
38
Directl-ffzx
This programme allows the entry of hexadecimal numbers
without the prefh: "#". 8 numbers are entered and the bi ts
set or reset are displayed in an 8 x 8 matrix. This
programme is used to enter known character codes for
eventual use with MODE4. It can be used for the design of
new characters but it is tedious!
39
690INX :Point X at next column
700INX :position
710INX
720LDA@#80 :Set VDU line
73C>STA#DE
740LDA{#80),Y :Output # number as 2 ASCII
750.JSR#FB02 :numerals
760LDA@O :Reset VDU line
770STA#DE
780STA#EO :Reset cursor position
790DEY :Loop for 8 times
800BNEQQ2
808STY#EO :Reset cursor position
810LDAi)#ES :Set new VDU line position
820STA#DE
830LDYG)8 :Point Y at start of codes
840:QQ3 LDAC#SOl,Y :Get 1st code
850STY#82 :Save Y
860LDY@8 :Print codes as graphic blocks
870:QQ4CLC :in 8 x 8 matrix.
BBORORA :Rotate low bit into Carry
890PHA :Save remainder
900BCSQQ5 :If Carry set print white block
910LDA4>#20 ;{#?F} to VDU, if Carry clear
920JMPQQ6 :print black block {#20} to VDU
930:QQ5LDAi)#7F
940:QQ6STA<#DE>,Y
950PLA :Reload remainder and loop fo~
960DEY :all a bits
970BNEQQ4
990STY#EO :Adjust VDU line and column
1000LDA#DE
1010CLC
1020ADCi)#20
1030STA#DE :
1040BCCQQ7
1050INC#DF
1060:QQ7LDY#82 :Get Y pointer to data and loop
1.070DEY :for 8 codes
1080BNEQQ3
1090LDA;.J)0 :Adjust VDU line and column
1100STA#DE
1110STA#EO
1120LDA:i>#80
1130STA#DF
1140:QQ8LDAR,Y :Print $R
1150CMP@#D
1160BEOOQ9
1170JSR#FE52
1180INY
1190BNEQQ8
1200:QQ9.JSR#FE94 :Get character from K/B
40
1210CMPG>#59 :Is it "Y"
1220BNEQQ11 :If not GOTO QQ11
1230LDYG>O
1240JSR#FD69 :Clear VDU
1250:QQ10LDAS,Y :Print $5
1260CMPG>#D
1265BEQQQ13
1270JSR#FE52
1280INY
1290BNEQQ10
1300:QQ13JSR#FE94 :Bet character from K/B
1310CMPG>#59 :Is it "Y"
1320BEQQQ12 : I f so GOTO QQ12
1330LDA#BO :Adjust #80,#81
1340CLC :to contain
1350ADCG>8 :address of
1360STA#80 :next free location
1370BCCQQ11
1380INC#81
1390:QQ11JMPQQO :Loop for next input
1400:QQ12RTS :
1500:QQ14LDAG>#60 :Print VDU display
1510STA#DE :Set cursor to 4th VDU line
1520LDAG>1 :Reset VDU column
1530STA#EO
1540LDAG>#30 :Load Accum with code for 0
1550LDYG)8
1560:QQ15PHA
1570JSR#FE52 :Output ASCII code to VDU
15BOINC#EO :Move cursor
1590INC#EO
1600PLA
1610CLC :Add 1 to ASCII code
1622ADCG>1
1630DEY :Loop for 8 times
1640BNEQQ15
1645TYA
1646TAX
1647STY#EO :Reset cursor
1650STY#E1 :Turn cursor off
1650LDAG>#E5 :Set cursor position Line 8
1660STA#DE :Column 6 on VDU
1670LDYG>8
1680LDAG>#30 :Load Accum with ASCII code for
1690:QQ16PHA :0
1700JSR#FE52 :Print ASCII code
1705STX#EO :Reset cursor
1710LDA#DE :Move cursor down 1 line
1720CLC
1730ADCG>#20
1740STA#DE
1750BCCQQ17
41
1760INC#DF
1770:QQ17PLA
1780CLC
1790ADC@l :Add 1 to ASCII code
.1800DEY :Loop for
1810BNEQQ16 :8 times
1820LDA@30 :Home cursor
1830JSR#FE52
1840RTS
3000J; R.
LINES:-
510-551) Clear VDU and print display.
560-670 Get two keyboard entries, convert to hexadecimal
and store.
680-780 Output # number to specific VDU location.
790-800 Loop for 8 entries.
808-830 Adjust cursor position.
840-1080 Print 8 bit }: 8 byte display.
1090-1130 Adjust cursor position.
1140-1190 Print $R.
1200-1240 Wait for key to be pressed and see if "Y".
1250-1290 Print $5.
1300-1320 Wait for key to be pressed and see if "Y".
1330-1390 Adjust #BO, #81 to contain address of ne>:t free
location.
1500-1840 Print VDU disolay.
Lines 560 to 670 convert two ASCII codes received from the
keyboard into one hexadecimal number.
If keys F and 4 are pressed then:
--------------------Accum-76543210------Carry--------------
42
l~yScan
This programme allows specific keys to be scanned. It must
have some uses!
43
TransferText
A simple BASIC programme which transfers specific lines from
one te>:t area to another.
44
Flashing Lines
This programme will flash a VDU line or part of that line.
PAGE 0 LOCATIONS:-
#80,#81 Address of 1st position to be flashed.
#82 VDU line position number.
#83 VDU column position number.
#84 Pointer to number of columns.
#85 Duration of flash.
SUBROUTINES USED:-
#FB83
45
6BOCLC
690ADC4>#20
700STA#BO
710BCCFF3
72•)INC#B1
730: FF3,JMPFF2
740:FF4LDY#B3 :Calculate column position O'f
750DEY :1st character
760TYA
770CLC
7BOADC#BO
790STA#80
800LDY;i)0
810:FF5LDA(#BO>,Y :Store characters in temporary
820STA#2880,Y :store
830INY
840CPY#84 :Check for no of columns to be
850BNEFF5 :stored
860:FF6LDX#85 :Delay by ?#85/60 secs
870JSR#FB83
880LDY;i>O
890:FF7LDA@#20 :Store spaces in place of
900STA<#BO>,Y :characters
910INY
920CPY#84
930BNEFF7
940BIT#B001 :See if CTRL pressed
950BVCFF9
960LDX#85 :Del av
970JSR#FB83
980LDY<ii0
990:FF8LDA#2880,Y :Restore characters to VDU
1000STA<#BO>,Y
1010INY
1020CPY#84
1030BNEFFB
1040BIT#B001 :See if CTRL pressed
1050BVSFF6 : I f not loop
1060:FF9RTS
2000l;R.
LINES:-
510-636 Set up page 0 locations.
640-720 Calculate VDU line and store.
740-790 Calculate VDU column and store.
800-870 Store characters temporarily and delay.
880-930 Store spaces at character positions.
940-970 See if CTRL pressed and delay.
980-1050 Restore characters to VDU and see if CTRL
pressed.
46
Long Strings
A programme whichs allows strings o-f up to 256 characters
to be entered directly into memory.
LINES:-
510-520 Output "?" to VDU.
540-590 Get character from keyboard, output to VDU and
recognize DELETE. Do not allow Y to decrement past O.
600-680 Store characters at address in #80,#81 until #D
is input or 256 characters have been input. When 256
characters have been input cause exit by sending #D to
output.
690-750 Adjust #BO, #81.
760-790 Store end of te>:t marker.
48
Alfabeta Sort
This programme alphabetically sorts strings to the Nth
character, where N is the length of the shortest of the two
strings being compared. The temporary storage during the
change routine is VDU memory, it can of course be any area.
5REM ALPHABETASORT
10DIMDD14
20F.N=OT014;P=#2800;DDN=P;N.
30F.N=1T02;P=#2800;60S.a;N.
40E.
500a[
510:DDOLDA#90 :Transfer address
520STA#80 :of strings
530LDA#91 :to #80,#81
540STA#81
550LDA@O :Clear change flag
560STA#84
570:DD1LDY@O
580:DD2LDAC#80>,Y :Find length of Nth string
590CMP@#D
600BEQDD3
610INY
650JMPDD2
660:DD3STY#85 :Store length of string
670LDA#81 :Set #82,#83 to contain address
680STA#83 :of Nth+l string
690INY
700CLC
710TYA
720ADC#SO
730STA#82
740BCCDD4
750INC#83
760:DD4LDYG>O
770LDA(#82>,Y :Check for end of text
49
780CMP@#FF
790BNEDD6
800LDA#84 :See if any changes have been
810BNEDDO :made
820:DD5RTS
830:DD6INY :Find length of Nth+1 string
840LDA<#82>,V
850CMP@#D :
860BNEDD6
870CPV#85 :Compare to length of Nth
880BCSDD7 : If less
8905TV#85 : store in #85
900:DD7LDV@O
910:DD8LDA<#80>,Y :Comparison routine
920CMP<#82),V
930BNEDD10 :If not equal SOTO DD10
940INV :If equal compare each
950CPV#85 :character until all characters
960BCCDD8 :in shortest string compared
965BEQDD8
970:DD9LDA#82 :Transfer address in #82,#83 to
9805TA#80 :#80,#81
990LDA#83
10005TA#81
1010JMPDD1
1020:DD10BCCDD9 :If less than SOTO DD9
1030INC#84 :Set change flag
1040LDV@#FF
1050:DD11INV :Store Nth
1060LDAC#80>,V :string in temporary
10705TA#8100,V :store
1080CMP@#D
1090BNEDD11
1100LDY@#FF
1110:DD12INV :Move Nth+1 string to address
1120LDA(#82>,Y :of Nth string
11305TA (#80), V
1140CMPG>#D
1150BNEDD12
1160LDXG>#FF
1170:DD13INX
1180INV :Set Nth string from temporary
1190LDA#8100,X :store and store at address v
1200STAC#80>,V :points to
1210CMPG>#D
1220BNEDD13
1240JMPDD1 :Loop for next
1500l;R.
LINES:-
510-540 Set up #80, #81.
550-560 Clear change flag.
50
570-660 Find length of Nth string and store.
670-750 Adjust #82,#83 to contain address of Nth+1
string.
760-820 Look for end of text marker and when found check
change flag.
830-890 Check for shortest string.
900-965 Compare each ·character of strings until all
characters in shortest string have been compared.
970-1010 Transfer address.
1020-1030 Check for less than.
1040-1240 Change routine.
51
This programme allows the user to design characters for use
with 6raphics Mode 4. A 8 x 8 box is displayed with a
flashing cursor, this cursor can be moved around the box by
using the keyboard. F moves the cursor forward one space, B
moves it back one space, U moves it up one line, D moves it
down one line. COPY sets the cursor position and stops it
flashing, DELETE clears a set position and T transfers the
set positions into an 8 bit x 8 byte set of codes, stores
those codes and displays the result at the top of the screen.
E escapes from the programme.
52
700:MM1STA#97,X
720DEX
740BNEMM1
760:MM2LDY@O :Flash cursor routine
770JSR#FB8A
800JSRMM17
840JSR#FB8A
860JSRMM1B
940JSR#FE71 :Sc:an keyboard
960CPY@#FF :if no key pressed
980BEQMM2 :GOTO MM2
1000:MM3CPY@#35 :Has LI been pressed
1020BEQMM4
1040CPY@#34 :Has T been pressed
1060BEQMM6
1080CPY@#26 :Has F been pressed
1100BEQMM7
1120CPY@#22 :Has B been pressed
1140BEQMM9
1160CPY@#24 :Has D been pressed
11BOBEQMM11
1200CPY@#F :Has DELETE been pressed
1220BEQMM13
1240CPY@#E :Has COPY been pressed
1260BEQMM15
1280CPY@#25 :Has E been pressed
1300BNEMM2
1320RTS
1340:MM4JSRMM16 :Move cursor up routine, checks
1360BNEMM5 :if cursor set, if not clears
1380JSRMM17 :cursor, gets new cursor
1400:MM5JSRMM21 :position and prints cursor
1420JSRMM18
1440JMPMM2
1460:MM6JSRMM23 :Transfer routine
1480JMPMMO
1500: MM?.JSRMM16 :Move cursor forward routine,
1520BNEMM8 :checks if cursor set, if not
1540JSRMM17 :clears cursor, gets new
1560:MMBJSRMM27 :address and prints cursor
1580JSRMM18
1600JMPMM2
1620:MM9JSRMM16 :Move cursor backwards routine,
1640BNEMM10 :actions as forwards routine
1644JSRMM17
1680:MM10JSRMM30
1700JSRMM18
1720JMPMM2
1740:MM11JSRMM16 :Move cursor down routine,
1760BNEMM12 :actions as up routine
1780JSRMM17
1800:MM12JSRMM33
53
1820JSRMM18
1840JMPMM2
1850:MM13JSRMM35 :Clear set cursor
1890JMPMM2
1900:MM15JSRMM36 :Set cursor and
1910:MM14JSR#FE71 :stop flashing cursor
1920CPY@#FF
1930BEQMM14
1940JMPMM3
19BO:MM16LDY#B3 :Check if cursor set routine
2000LDX#84 :See notes
2020LDA#97,Y
2040AND#BF,X
2060RTS
2080:MM17LDA@O :Clear cursor pixel data
2100STA#82
2120JSRMM19
2140RTS
2160:MM18LDA@#FF :Set cursor pixel data
21BOSTA#82
2200JSRMM19
2220RTS
2240:MM19LDA#83 :Add line number to #BE to give
2260CLC :cursor address H.B
22BOADC@#BE
2300STA#B1 :Store in #81
2320LDA#84 :Add column number to #15 to
2340CLC :give cursor address L.B
2360ADC@#15
2380STA#80 :Store in #80
2400LDX@8
2420LDY@O
2440:MM20LDA#B2 : Load cursor pi >:el data and
2460STAC#801,Y :print cursor. Cursor consists
2480LDA#BO : of block 8 bi ts >: 8 bytes.
2500CLC :Each byte has a #20 separation
2520ADC@#20 :which is 1 Mode 4 VDU line.
2540STA#BO
2560DEX
2580BNEMM20
2600RTS
2620;MM21LDA#83 :Subtract 1 from current line
26405EC :number, if this leaves 0
2660SBC@1 :return, #83 is never equal to
26BOBEQMM22 :O, otherwise store new line
2700STA#83 :number and return
2720:MM22RTS
2740:MM23LDY@O :Display character routine, Y
2760LDX&\O :always equals 0 as character
2780:MM24LDA#98,X :is made up the same way as the
2790STA-.#88},Y :cursor
2800JSRMM47 :GOSUB Store codes routine
54
2810LDY<i>O :
2820LDA#B8 :Adjust #88,#89 to contain
2840CLC :address of next VDU line
2860ADCG>#20
28BOSTA#B8 :
2890INX
2900CPX<i>8 :Loop for 8 codes
2920BNEMM24
2940LDA#88 :Adjust #88,#89 to contain
2960CLC :address of next VDU display
29BOADC<i>1 :position
.3000CMP4>#1F :Check for end of line
3020BEQMM26
3040:MM25STA:itBB :
3060RTS
3080:MM26INC#B9 :Set new line address
3100LDA<i>2
3120JMPMM25
3140:MH27LDA#84 :Add 1 to cursor column number,
3160CLC :if result >S GOTO MM 28 to
31BOADCG>1 :move.cursor down by 1 line,
3190CMPG>9 :otherwise store new position
·3200BCSMM2B :and return
3220STA#84
3240RTS
3260:MM28JSRMM33 :SOSUB Move down 1 line
3280CMPG>9 :If Accum returns with 9,
3300BEQMM29 :cursor is extreme bottom left
3320LDA4>1 :of box so no movement possible,
3340STA#84 :otherwise set column to 1 and
3360:MM29RTS :return
33BO:MM30LDA#84 :Move cursor backwards, same
3400SEC :actions as MM27 except cursor
3420SBC4>1 :will be moved up 1 line when
3440BEQMM31 :column number =O
3460STA#84
34BORTS
3500:MM31JSRMM21 :Move cursor up 1 line unless
-3520BEQMM32 :in extreme top left position
3540LDA4>8
3560STA#84
3580:MM32RTS
3600:MM33LDA#83 :Move cursor down 1 line, if =
3620CLC :9 cursor on bottom line so
3640ADCG>1 :return without further action
3660CMPG>9
3680BCSMM34 :
3700STA=lt83
3720:MM34RTS :
3740:MM35LDY=lt83 :Clear set cursor
3760LDX#84 :
3780LDA#97,Y :See notes
55
3SC•OEOR#SF ~ X
3920STA#97,Y
3B40RTS
3860:MM36LDY#83 :Set cursor - see notes
3880LDX#94
3900LDA#97,Y
39200RA#BF,X
3940STA#97,Y
.3960RTS
4000:MM37JSRMM42 : Draw bo>: routine
4010JSRMM43 :Clear bo;:
4020LDY@#B :Print top line:• of bo}:
4040:MM3BLDA@#FF :Set pixel data
4060STA!#86),Y
4080DEY :Print for 8 successive bytes
4100BNEMM38
4110LDA#87 :Calculate address of bottom
4120CLC :line and store in #86,#87
4130ADC4.l#9
4140STA#87
4150LDA#86
4160CLC :The L.B calculation will set
4170ADC@#20 :the carry bit but it is
4180STA#86 : ignored
4200LDY@#S
4220LDA@#FF
4240:MM39STA\#86l,Y :Print bottom line
4260DEY
4280BNEMM39
4300JSRMM42 :Reset #86,#87 to box start
4320LDX@#42 :address
4340:MM40LDY@O :Print left side of box by
4360LDA@1 :setting extreme right pixel of
4380STA\#86>.Y .:VDU column 22
4400LDY@#9
4420LDA@#80 :Prirt right side of box by
4440STA(#86i,Y :setting extreme left pixel of
4460LDA#86 :VDU column 31
4430CLC :Calculate address of next VDU
4500ADC@#20 :line
4520STA#B6
4540BCCMM41
4560INC#87
4580:MM41DEX :Loop for 66 lines
4600BNEMM40
4620RTS
4640:MM42LDA;;J#8E :Set #86,#87 to contain start
4660STA#87 :address of box
4680LDA@#F5
4700STA#86
4720RTS
4740: MM43LDX;J.l#42 :Clear box routine
56
4760:!"!M44LI!Y4'8 :Set every pixel within box to
47BO:MM45LDA;YO :0
4800STA<#B6>,Y
4820DEY
4840BNEMl'l45
4860LDA#86
4880CLC
4900Al)CG>#20
4920STA#86
4940BCCMM46
4960INC#B7
49BO:MM46DEX
5000BNEMl'l44
5020JSRMM42
5040RTS
5060:1'1M47LDY#BC :Store codes in memory routine
5070STA<#BA>,Y
5080INY
5090BNEMM48
5100INC#8B
5120:MM48STY#SC
5140RTS
bOOOJ;R.
LINES:-
510-740 Clear bo>: and print outline, clear page 0
locations.
760-860 Flash cursor.
940-1320 Scan keyboard and interpret any key pressed.
1340-2060 Execute key press.
2080-2220 Cursor on/off execution.
2240-2380 Calculate address of current cursor position.
2400-2600 Print cursor.
2620-2720 Move cursor position up 1 line, if possible.
2740-2920 Display 8 codes as one character.
2940-3120 Adjust character display position, move address
to next line if necessary.
3140-3360 Move cursor position 1 column forwards, move to
next line if necessary or take no action if bottom line
extreme right.
3380-3580 Move cursor position 1 column backwards, move to
next line if possible or take no action if top line extreme
left.
3600-3720 Move cursor 1 line down, if possible.
3740-3840 Delete cursor setting.
3860-3960 Set cursor and stop flashing.
4000-5040 Draw box.
5060-5140 Store codes at address in #8A,#8B.
57
Mode 4 graphics produce a VDU display of 32 bytes x 192
line:, the separation between lines being #20. While
characters can be displayed at any VDU address, it is
advisable to use an address which has a low byte equal to
zero as 7 additions of #20 will not set the Carry flag and
therefore no instructions are needed to increment .the high
byte.
The actions taken to set the cursor, to reset the cursor and
to check whether the cursor is set are as follows. The
cursor position is line 1, column B and columns 2 and 3 are
already set.
Line:
3860 Load Y with contents of #83, Y=1.
3880 Load X with contents of #84, X=8.
3900 Load Accum with contents of #98 {#97,Y}, (#98
contains line 1 data> Accum = #60.
3920 OR Accum with contents of #97 {#SF,X}, #01.
3940 Store result (#61) in #98 {#97,Y}.
The OR sets the bit, EOR clears the bit and AND checks the
bit. e.g.
OR Action. Bits 76543210
Ac cum 01100000
Memory 00000001
Result 01100001
EOR Action.
Ac cum 01100001
Memory 00000001
Result 01100000
AND action.
Ac cum i f bit set 01100001
Memory 00000001
Result <>O 00000001
Note that #98 - #9F contain the data for each line and that
each bit is equivalent to the column, bit 7 being column 1.
SB
menu Program
This programme which is assembled into the last 1K of
graphics mode 4 RAM stores up to 12 programme titles and
their execution addresses. New entries can be made when this
programme is called or the stored list of titles can be
printed out. Any programme can then be executed by direct
entry of its title, assuming it is in memory. Machine code
and BASIC programmes are recognized and appropriate action
taken.
61
1740:LLBJSR#FD69 :Clear VDU
1760LDY@O :Clear page 0 locations used by
1780STY#25 :#C589
1790STY#34
1800STY#43
1820LDA@TTS&#FF :Print message string 6
1840STA#80
1860.JSRKKO
1870JSR#FFED
1880LDY@#6F :Point Y at title store
1900LDA@1
1920STA#B5
1930:LL9LDA#B5 :Output title number
1960STA#16
1970STY#B2
1980JSR#C589
1990JSR.ftF7FD
2000INC#B5
2030LDY#B2 :Y is saved as #CS89 uses Y
2040:LL10LDA#9600,Y :Output title
2060CMP@#D
20BOBEQLL11
2100JSR#FE52
2120DEY
2140.JMPLLlO
2160:LL11JSR#FFED
2180DEY :Move Y past #D, address and
2200DEY :end of address marker
2220DEY
2230DEY
2240LDA#9600,Y :Check for end of data
2260ct1Pi>#FF
22BOBEQLL12
2300LDA#B5
2320JMPLL9
2420:LL12LDA@TT2~#FF :Print message string 3
2440STA#BO
2460JSRKKO
2470LDYi>O
2480JSR#CD14 :Get title from keyboard
2500JMPLL13
SOOO:KKOJSR#FFED :Print message string
S010:KK1LDY4l0 :subroutine
5020:KK2LDA<#SO>,Y
5030CMP@#D
5040BEQKK3 :
SOSOJSR#FE52
S060INY
5070JMPKK2
50BO:KK3RTS :
6020:LL13LDY@#6F :See if entered title is in
6040:LL14LDXOO :store
62
60b0:LL15LDA#9600,Y :
6070CMPG>#D :Note that if you have two
60BOBEQLL18 :titles with similar characters
6090CMP#100,X :this routine will always find
6100BNELL16 :the shorter one e.g MOON and
6120DEY :MOONS, MOON will be returned
6140INX
6160JMPLL15
6170CMPG>#D :
61BO:LL16
6220:LL17DEY :Hove Y past end of address
6240LDA#9600,Y :marker
6260CMP@#7F
62BOBNELL17
6300DEY :
6320LDA#9600,Y :Check for end of data marker
6340CMP@#FF
6360BNELL14 :If not found loop
63BOLDAG>TT63c#FF :Print message string 7
6400STA#BO
6420JSRKK1 :
6430LDX@#40 :Delay
6440JSR#FB83
6450JMPLLB
6460:LL18STY#82
6470JSR#FD69 :Clear VDU
64BOLDY#82
6490DEY
6500LDA#9600,Y :Store H.B of address
6510STA#81 :in #81
6520DEY
6540LDA#9600,Y :Store L.B of address
6560STA#SO : in #80
6580DEY
"6600LDYG>O
6620LDA<#80>,Y :Check for BASIC programme
6640CMP@#D
6660BEQLL19 :If it is SOTO LL19
6740Jl1P<#BO> :Jump to machine code
6760:LL19LDA#80 :Transfer address to #5,#6
6780STA#5
6790LDA#81
6SOOSTA#6
6810LDY@1 :Store 0 at 2nd text area
6820LDA@O : location
6830STA<#5>,Y :Equivalent to BASIC's OLD
6840Jl1P#C2F2 :Jump to BASIC
6860:KK4LDA#9600,X :Routine for finding end of
6870CMP@#D :data
6880BNEKK5 :Also sets #85 to number of
6890INC#85 :current titles
6900:KK5CMPG>#FF :Returns with Y pointing to end
6910BEQl<K6 :of data marker
6920DEX
6930JMPKK4
6940:KK6LDA#85 :Checks fo..- numbe;- of titles
695(>CMF@#C :If less th~n 12 return
6960BCCK~-'.7
6970PLA :Discard return address and
6980PLA :jump ta LL3
6990JMPLL3
7000: Kl<7RTS
8000J;R.
LINES:-
520-580 Set up registers and page 0 locations.
600-760 Print message a.nd interpret answers.
780-840 Get new prag.-amme title.
850-910 Store title.
940-990 P""int message.
1040-1700 Get address of programme from keyboard as 4
ASCII codes, convert to he>:adec:i mal and store after title.
Store end of address marker and end of data marker. Check
number of titles in store.
1705-1735 Print message and interpret a.nswer.
1740-2460 Print message, print list of titles.
2480-2500 Get title from keyboard.
5000-5070 Print message to VDU subroutine.
6020-6440 See if title is in store.
6460-6600 I f found load address into #80,#81.
6620-6660 See if BASIC programme.
6740 Jump to machine code programme.
6760-6840 Set #5,#6 to address of BASIC programme, set 2nd
te>;t space location to 0 and jump to interpreter.
6860-7000 Find end of data, check for number of titles in
store.
Note also the use of arrays for holding the various message
string addresses. Only the low bytes are accessed as all
strings are stored in page #96.
64
Fruit machine
This is a simple Fruit Machine type game with a good
spinning effect. There is no scoring system but as the
machine code jumps back to Line 40 after each spin a
suitable routine could easily be inserted. Note that no
extra spaces should be entered before Line 40.
66
1760LDAH29 :Load return BASIC address into
17BOSTA#6 :*5,#6
1800LDA4Mt5A
1820STA4t5
1840LDYil1 :
1860STA#3 :
1BBOJl1Ptte2F2 :Jump to BASIC
2700:BB14RTS
2720:BB24LDA#BE :Store H.B and L.B of start
2740STA#B4,X :address for each reel, X
2760LDA#SE,X :points to reel
27BOSTA#81,X :
2BOOLDAH41 :Set line counter
2820STA#BB
2840LDA#B7,X :Increment symbol pointer for
2860CLC :each reel
28BOADCil1
2900CHP4l9 :If result >8 reset to 1
.2920BCCBB27 :
2960LI>Ai)1
29BO:BB27STA#87,X
3000RTS
3020:BB2BLDA#B1,X :Transfer current reel line
3040STA#BO :address to #80,#81
3060LDA#B4,X :
3080STA#B1
3100STX#SC :Save X
3120TXA :Load X with pointer to symbol
3140TAY
3160LDX#87,Y
31BOLDYil6
3200:BB29LDA#97,X :Print 1 line of- reel display
.3220STA (#80>, Y
3240DEY
3260BNEBB29
32BOLDA#BO :Adjust #80,#81 to contain
3300CLC :address of next line
3320ADC4l#20
3340STA#80
3360BCCBB30
33BOINC#B1
3400:BB30LDX#8C :Restore X
3420LDA#BO :Store new line address
3440STA#B1,X :X points to reel
3460LDA#81
3480STA#B4,X
3500RTS
5000l;R.
LINES:-
520-780 Set up page 0 locations and display reels.
B00-920 Set spins left flags.
67
950-1220 Check for spins left, print 1 line if found and
loop for all lines.
1240-1540 Decrement spins left counter, set/reset flags
and check if all reset.
1560-1880 Set uo BASIC return address and jump to
interpreter.
2720-3000 Subroutine to set reel start addresses, set line
counter and adjust symbol pointers.
3020-3200 Transfers CLlrrent reel addresses to #80,#81 and
gets reel symbol data.
3220-3380 Prints 1 line of specified reel.
3400-3500 Stores ne}'. t 1 i ne address before returning.
68
String Write'ffiode 4
This programme replaces the normal write character routine
address and allows strings to be written to the screen when
using graphics mode 4. It is necessary to have the Word Pack
ROM installed as this programme uses the 8 byte character
codes stored in the· ROM. If you do not have this ROM you
will have to design your own characters using DESIGNLETTERS
or enter known codes using HEX DIRECT. Codes should be
entered in standard ASCII order, #20-#3F in the 1st page,
#40-#SF in next and #60-#7F in 3rd page. Lines 1000,1070 and
1130 should be changed to reflect the new storage areas. On
entry #82,#83 should contain address of VDU line.
69
970SBCi>#20
980JSRl<Y9
990STA#80
100')LDA;]}#AD :Load H.B address of codes
1010STA#81
1020JHPK1<4
1030:Kl<2SBC@#60 :calculate offset
1040JSRl<K9
1050STA#80
1 O?OLDA.ii#AF :Load H.B
1080STA#81
:i.090JMPl<K4
1100:i<K3SBC@#40 :Calculate offset
1110JSRKK9
1120STA#80
1130LDA~#AE :Load H.B
1140STA#B1
1150:KK4LDX@O ;Print character routine
1160LDY;i'iO
1170:KK5LDA<#BO>,Y :#80,#81 contain address of
1180STA\#82,X> :codes
1190LDA#82
1200CLC
1210ADC;j)#20 :Move VDU address down 1 line
1220STA#82
1230INY
1240CPY;:L•B :Loop until all 8 codes have
1250BNEKl<5 :been printed
1260LDA#B2 :Adjust VDU address to ne>:t
1270CLC :free location
128')ADC@1
1290'..:!'1'."''@#20 : Check for end of line
1300Bt\JEl<l<6
1310JSRt<1<7
1320:1<1<6STA#82 :Restore registers
1330LDV#90
1340LDX#91
1350RTS
1360:KK7LDA#83 :AdjL:st #82,#83 to next line of
1370CLC :VDU
1380ADC@1
1390CMP@#98 :Checi< if bottom line, if so
1400BNE!<KS :reset to start of bottom line,
1410LDA@#97 :VDU does not scroll
1420:1<K8STA#83
1430LDA@'O
1440RTS
1640:1<!<9TAX :Subroutine to find L.B of
1650LDA;iJO :codes for specified character
1660: K~< 1 OCLC
1670ADC;Jt8
1680DEX
70
1690BNEKK10
1700RTS
3000J;R. :
LINES:-
520-640 Save registers, check for end of text output and
if found restore standard write character address and jump
to that address.
900-1140 Check character to see which page its codes lie
in, calculates position of codes and stores L.B in #80, H.B
in #81.
1150-1250 Displays code, moves display address down by 1
line, gets next code and loops until all 8 codes displayed.
1260-1310 Moves display address 1 column forward and
checks for end of line.
1320-1350 Restores registers and returns.
1360-1440 Moves display address down by 8 lines, checks
{or bottom of display and if found resets address to start
of bottom line.
1640-1700 Calculates L.B address of codes.
Note that CTRL characters are not recognized and should not
be input to this routine.
71
Pontoon
The computer plays you at pontoon. Cards are displayed in
Mode 4 and all standard pontoon rules are observed. It uses
character codes stored in the Word Pack ROM so cannot be
used unless this ROM is fitted or you have your own codes.
The programme is in 4 parts as it is too long for the
standard ATOM.
PART NO: 1
110S=S+LENS+1
120$S="I WIN"
130S=S+LENS+1
140$S="YOU WIN"
150S=S+LENS+1
160$S="PONTOON"
7:2
t70S=S+LENS+l
1so•S="BUST! !"
t90S=S+LENS+l
20o•S="FIVE CARD TRICK"
210S=S+LENS+l :
220$S="ANOTHER SO?"
230S=S+LENS+l
240$S="CARDS BEING SHUFFLED"
250S=S+LENS+l
260$S="CURRENT SCORE POSITION
IS:"
270S=S+LENS+1
280$S="YOUR WINS:"
290S=S+LENS+l
300$S="MY WINS:"
310E.
PART NO: 2
ENTER IN TEXT AREA: #2F
TEXT: .lK
VDU: -
l'l/C: -
EXECUTION: -
10X=O
20V=#3000
30K=#3040
4000
50b W=ABSRND'Y.52
60IFW?Y=O G.b
70X?K=W?V
BOW?Y=O
90.X=X+l
100U.X=52
110LI. <Z+l>
PART NO: 3
ENTER IN TEXT AREA: #82
TEXT: 5.2K
VDU: -
MIC: l.1K
EXECUTION: -
5REM PONTOON
10DIM NN63,l'lt119
20F.N=OT063;P=#29BO;MMN=P;
73
NNN=F;N.
30F.N=1TD2;P=#29BO;GOS.a;N.
40E.
500a[
52(': NNOL DA#5 :Save BASIC address
540STA#30FO
560LDA#6
580STA#30F1
600JMPMMO
620:NN1LDA#80 :Increment VDU address by 1
640CLC :line routine
660ADC~#20
680STA#80
700RTS
720:NN2LDX@7 :Print card subroutine
740:NN3LDY@4 :4 columns x 56 line matrix
760:NN4LDA#8D
780STA(#80>,Y
BOO DEY
820BPLNN4
840JSRNN1 :Note loop using Carry flag and
860BCCNN3 :JSR NN1
880INC#81
900DEX
920BPLNN3
940RTS
960:NN5PLA :Store return address in
980STA#33B :integer variable Z
1000PLA
1020STA#356
1040JSF:NN39 :Clear text lines subroutine
1090LDX@11 :Print string 11
1100JSRNN53
1110LDY@#FF :Set up pack
1120LDA@O :Set card pointer to 0
1140STA#8A
1150LDA@#80 :Set bit 7 of Accum
1160STA#21C :Store in #21C, top 4 bits
1170:NN6LDX@13 :indicate suit, set up number
1180:NN7INY :of cards per suit
1190TXA :Add card number to suit
1200CLC
1210ADC#21C
1220STA#3000,Y :Store at #3000,Y, Y points to
1240DEX :free location, do for 13 cards
1250BNENN7
1260LSR#21C :Shift set bit to indicate next
1280LDA#21C :suit
1300EOR@#08 :Check if all suits done
1320BNENN6
1420LDA@#2F :Load address of BASIC card
1440STA#6 : shuffle
74-
1460LDA@03
14SOSTA#5
1500JMP#C2F2 :.Jump to BASIC
1520:NN8LDX@4 :Find suit routine
1540AND@#FO :Clear low 4 bits
i560CLC :Shift Accum left until set bit
1580:NN9DEX :falls into carry, X points to
1600ASLA :suit, get ASCII code for suit
1620BCCNN9
1640LDA#21D,X
1660:NN10STA#225 :Save in temporary
16BOLDA@#AD :Store H.B of codes address in
1700STA#83 :#83
1720ASL#225 :Move Accum bits left, check
1740LDA#225 :for bit 7 set, if set code is
1760BPLNN11 :upper case character so
1780INC#83 :increment H.B
· 1BOO:NN11ASL#225 :Shift Accum left another 2
1BBO:NN12LDA#225 :times, this gives L.B address
1900ASLA :of character codes, #82,#83
1920STA#82 :now contain address of codes
1940LDY:ii)0 :Print character routine
1960LDX@O
19BO:NN13LDAC#82),Y
2000EOR@#FF :Invert character
2020STAUtao. X>
2040INY
2060JSRNN1
2080BCCNN13
2100RTS
2120:NN14LDY@5 :Clear page 0 locations used by
2140LDA@O :score calculation routine
2160:NN1SSTA#226,Y
2180DEY
2200BNENN15
2220RTS
2240:NN16CLC :Adjust Accum to contain ASCII
2260ADC@#30 :code for numeral
2280JMPNN10
2300:NN17JSRNN26 :Score calculation routine
2320AND@#OF :Bet current card value and
2340CMP@#A :clear suit bits
2360BCCNN18 :Compare to 10, if >10 card =10
2380LDA@#A
2400JMPNN19
2420:NN18CMP@1 :Check for ACE, if ACE change
2440BNENN19 :value to 11 and store in
2460LDA@11 :temporary score table, X
24BO:NN19LDX#84 :points to which player, Y
2SOOLDV#85,X :points to card
2520STA#226,Y
2540:NN20LDY@5 :Calculate score by adding
75
2560LDA@(l :contents of temporary table
2580STA#87,X :Clear last score
26005TA#89 :Clear ACE pointer
2620:NN21LDA#225,Y
2640CMP;i' 11 :Check for ACE
2660BNENN22
2680STY#89 : I f found store pointer
2700:NN22CLC
2720ADC:l!=87.X
27405TA#87,X
2760DEY :Loop until all 5 locations
2780BNENN21 :have been added
2800CMP@22 :Compare to 22
2820BCSNN24 :If >==GOTO NN24
2840:NN23JMPNN27
2860:NN24LDA#89 :See if ACE found
2980BEQNN23
2900TAY :If found store 1 in place of
2920LDA@1 :11 and do calculation again
2940STA#225,Y
2960JMPNN20
2980:NN25LDX#84 :Get pointer to computer's or
3000LDA#9A,X :player's card, get H.B of
3C1 20STA#81 :address and store in #81, get
3040LDY#B5,X :pointer to card, get L.B
3060LDA#90,Y :address and store in #80
3080STA#80
3100JMPNN2
3120:NN26LDY#8A :Get value of next card from
3140LDA#3040,Y :pack, return with value in
3160RTS :Accum
3180:NN27LDY#BA :Update pointer to pack
3200INY
3220CPY:l)52 :If all 52 cards used GOTO
3240BCCNN28 :shuffle routine
3300JMPNN5
3320:NN28STY#BA
3340RTS
3360:NN30LDY@O :Print string routine
3380LDA(#8C),Y
3400CMP@#D :Do net output #D
3420BEQNN32
3440JSRNN10
3460LDA#8C
3480CLC
3500ADC@1
3520STA#BC
3540BCCNN31
3560INC#8D
3580: NN31 I NC#SC>
3600JMPNN30
3620:NN32RTS
76
3640:NN33LDA:i>O :Print score routine
3660STA#25 :Subroutine #C589 is used to
3680STA#34 :convert score from hexadecimal
3720STA#43 :to decimal. However this
3740LDX#84 :routine outputs via address
3760LDA#B7,X :held in #208,#209. This
37BOSTA#16 :address is #FE52 which will
3800:NN34INC#80 :not print to VDU in mode4, it
3820JSRNN37 :is necessary to store a new
3840JSR#C589 :routine address, routine NN37
3860RTS :does this by calculating
3880:NN35STX#219 :address of NN35 <NN35 could be
3900STY#21A :obtained direct>
3920CMP:ii>#20 :NN35 is subroutine to print
3940BEQNN36 :score after conversion. #C589
3960JSRNN10 :will not return to correct
3980INC#80 :address when X=O so when X
4000LDY#21A :reaches 0 the 1st return
4020LDX#219 :address on stack is discarded,
4040BNENN36 :it will now return correctly
4060PLA
4080PLA
4100LDA@#FE
4120STA#209
4140LDA:.i>#52
4160STA#208
4180:NN36RTS
4200:NN37TSX :Works out address of NN35 by
4230INX :taking its own return address
4240INX :and adding S, it then stores
4260LDA#100, X :this address at #208,#209
4280STA#209
4300DEX :
4320LDAtt100, X
4340CLC
4350ADC4>5
4360STA#208
4370BCCNN29
4380INC#209
4390:NN29RTS :
4400:NN38STX#219 :Wait subroutine, delay of
4440LDXG>#40 : appro>: 1 sec
4460JSR#FBB3
4500LDX#219
4520RTS
4540:NN39LDX@3 :Routine to clear text lines,
4560LDA4>#8A :As each character needs B
45BOSTA#81 :lines, two text lines would be
4600LJ;>A:ii>#CO :16 VDU lines however as
4620STA#BO :characters are inverted it is
4640:NN40LDY:ii>#1F :necessary to add 1 extra VDU
. 4660:NN41LDA»#FF :line to top to avoid visual
77
4 ~80STiH #80> ,Y :problems
4700DEY
4720BFLNN41
4740JSRNN1
4760BCCNN4Ci
4780INC#81
l!-8':)0DEX
4820BNENN40
4840RTS
4860:NN42LDX#84 :Load #80,#81 with address of
4880LDA#9A,X :card just displayed
4900STA#81
4920LDY#85,X
4940LDA#90,Y
4960STA#80
4970STA#SE
49BOJSRNN44 :Print card number top lt
5000LDX#84 :Get L.B of card address top rt
5020LDY#B5,X
5040LDA#95,Y
5060STA#BO
5080JSRNN43 :Print suit top rt
5100LDX#84 :Get H.E bot lf
5120LDA#9C,X
5140STA#81
5160LDY#85,X : Get L. B bot 1 f
5180LDA#90,Y :Print suit bot lf
5200STA#80
5220JSRNN43 :Print suit bot lf
5240LDX#84 : Get L. B bot rt
5260LDY#85,X
5280LDA#95,V
5300STA#80
5320JSRNN44 :Print number bot rt
5340RTS
5360:NN43JSRNN26 :Get current card and print
5380JMPNN8
5400:NN44JSRNN26 :Get card value
5420AND;i/#OF :Clear suit
5440CMP@#A :See if 10 or less
5460BCCNN46 : I f less GOTO NN46
54BOBEQNN48 :If equal GOTO NN48
5500SEC :Otherwise calculate ASCII code
5520SBCil#A :for J,Q,K
5540TAX :#221,X contain codes, return
5640LDA#221,X :with Gode in Accum
5660JMPNN10
5680:NN46CMP@1 :See if ACE
5700BEQNN47 : I f so GOTO NN47
5720J~PNN16 :Must be 2 to 9 so GOTO NN47
5740:NN47LDA#221 :Get code for ACE
5760JMPNN10
78
57ao:NN48LDA#8E :If 10, it is necessary to
saooBPLNN49 :print 2 numerals on top If and
ss20DEC#BO :bot rt, bit 7 of #BE is set
ssso:NN49LDA@CH"1" :for bot rt, clear for top If
5900JSRNN10
5920INC#80
5940LDA'1>CH"O"
5960JSRNN10
5980LDA@#FF :Set bit 7 of #SE
6000STA#8E
6020RTS
6040:NN50LDA@#2E :Load address of string table
6060STA#8D :into #BC,#BD
60BOLDA@#20
6100STA#BC
6120LDYG>#FF
6140:NN51INY :Loop until #D is found
61bOLDAC#SC>,Y
61BOCMP@#D
6200BNENN51
6220INY :Adjust #BC so that #BC,#BD
6240TYA :contain address of next string
6260CLC
62BOADC#8C
6300STA#BC
6320LDY@O :Loop until
6340DEX :X=O
6360BNENN51
63BORTS
6400:NN52JSRNN50 :Print string on text line 1
6420LDA@#BB :routine
6440STA#B1
6460LDA@1
64BOSTA#BO
6500JMPNN30
6520:NN53JSRNN50 :Print string on text line 2
6540LDAG>#BC :routine
6560STA#B1
65BOLDAG>1
6600STA#BO
6620JMPNN30
6640:NN54LDX#B4 :Check score for PONTOON,BUST
6660LDA:lt87,X :or FIVE CARD TRICK
66BOCMP@22 :If over 21
6700BCCNN56
6720INC#80 :Print BUST message
6730INC#BO
6740LDX4i>B
6750JSRNN50
6760JSRNN30
6'7BOLDA#84 :Check if player or computer
6BOOBNENN55 :BUST
79
6810JMPNN61
6820:NN55JMPNN63
6850:NN56CMP4>21 :See if 21
6860BNENN58
6880LDf'-t#85, X :See if 21 in twc cards
6900CM?@1
6920BNENN59
6930INC#90 :If it is then print PONTOON
6940INC#80 :message
6950LDX;l}7
6960JSF:NN:::O
6970JSRNN30
6980:NN45LDA#84 :See if computer or player
6990BNENN57
7000JMPNN63
7010:NN57PLA
7020PLA
7030JMPMM4
7070:NN58LDA#85,X :See if FIVE CARD TRICK
7080: NN59CMP;i)4 :If it is BOTO NN60
7090BEQNN60
7100RTS
7110:NN60LDX;i>1 :Clear 2nd text line
7120LDA@#SC
7130STA#81
7140LDA@O
7150STA#BO
7160JSRNN40
7180LDX;i)9 :Print FIVE CARD TRICK mess3ge
7190JSRNN53
7200JMPNN45
7260:NN61JSRNN38 :YOU \.'iIN routine
7270JSRNN39 :Clear text lines
7290JSRMM17 :Update current wins store
7310LDX@6 :Print string 6
7320:NN62JSRNN5'.2
7340PLA :Discard return add-ess
7360PLA
7380JMPMM11
7400:NN63JSRNN38 : IlfJIN routine
7410JSR#FD1A :Sound bell
7420JSRNN39
7430JSRMM12
7440LDX@5 :P~int string 5
7460JMPNN62
8020:MMOJSRNN39 :Clear text lines
8030JSRNN5 :Set up pack
8040:MM1JSRNN14 :Clear score st3res
8050LDA;])0
8060STA#84
8080STA#85
8100STA#86
SC>
S110STA#87
S120STA#B8
S140LDA@#AA :Store card display data, #AA
81605TA#BD :for face down #FF for face up
81BOJSRNN25 :Print 1st card
8200LDAG>#FF
S2205TA#8D
B240INC#84 :Indicate players card
B260JSRNN25 :Print card
82BOJSRNN42 :Print suit and number
B300JSRNN17 :GOSUB score routine
8320INC#B5 :Increment computers card
S340DEC#84 :Indicate computers card
B360LDA@#AA :Print computers 2nd card
83BOSTA#BD
B400JSRNN25
B420INC#B4 :Indicate players card
B440:MM3INC#86
B460LDAG>#FF
B4805TA#BD
8500JSRNN25 :Print card
B520JSRNN42 :Print suit and number
8540JSRNN17 :SOSUB score routine
B560JSRNN39 :Clear text lines
8580LDX4>1
B600JSRNN52 :Print string 1
8620JSRNN33 :Output score
8630JSRNN54 :GOSUB score check routine
9640LDX4>2
B660JSRNN53 :Print string 2
8680JSR#FE94 :Wait for key to be pressed
8700CMP@CH"Y" :Is it Y
8720BNEMM4 :
8740JMPMM3 :If so loop for next card
8750:MM4JSRNN14 :Clear score table
8780LDA@O
BBOOSTA#84 :Set #84 to point to computers
88205TA#85 :1st card, indicate computers
B840JSRNN38 :card
8860JSRNN39 :Clear text lines
8880LDX@3 :Print string 3
8900JSRNN52
8920:MMSJSRNN38 :Wait
8940LDA@#FF :Print cards, suit and numbers,
8960STA#BD :GOSUB score routine and print
8980J!;)RNN25 :string until computer's score
9000JSRNN42 :is greater than 16
9020JSRNN17
9040JSRNN39
0
:
9060LDX @4
9080JSRNN52
9100JSRNN33
a :i.
9120JSRNN54
9140INC#B5
9160LDA#B7
9170CMP<i>16
9180BCSMM6
9190JMPMM5
9200:MM6CMP#88 :If you don't understand what
9210BCSMM7 :lines 9200 - 9340 do, pl&y
9220LDA#89 :game first then look at back
9230BNEMM19 :of book~
9240JSRNN26
9250AND;j)#OF
9260CLC
9280ADC#87
9300CMP;V22
9320BCSMM7
9340:MM19JMPMM5
9360:MM7LDA#B6 :Checks for player's pontoon,
9380CMP@1 :if found jump to YOU WIN
9400BNEMM8 :routine
9420LDA#88
9440CMP@21
9460BNEMM9
94BOJSRNN61
9500:MMBCMP@4 :Checks for player's five card
9520BNEMM9 :trick, if found jumps to YOU
9530LDA#89 :WIN routine
9540BNEMM19
9550JSRNN61
9560:MM9LDA#87 :Checks player's score against
9580CMP#88 :computer's
9600BCSMM10 :If less jump to I WIN routine
9620JSRNN61 :otherwise jump to YOU WIN
9640:MM10JSRNN63 :routine
9660:MM11JSRNN38
9680JSRNN39
9690JSF:MM16 :Print string 1(1
9700LDX;V10
9720JSRNN52
9740JSR#FE94 :Wait for key to be pressed
9760CMP@CH"Y"
9780BNEMM15
9800LDA@#82 :Clear VDU and jump to MM1
9820STA#81
9840LDA;i)Q
9860STA#80
9880:MM13LDY@#1F
9900:MM14L:::>A@O
99205TA<#BO>,Y
9940DEY
9960BPLMM14
9980JSRNN1
8:2
10060BCCMM13
100BOINC#Bl :
10100LDA#Bl
10120CMP@#98
10140BCCMM13
10160JMPMM1
10500:MM15LDA#30FO :Restore original BASIC address
10520STA#5 :and exit
10540LDA.tt30F1 :
10560STA#6
10580RTS
10600:MM16JSRNN39 :Print current score and wait
!0620LDX@12 :approx 3 secs
10640JSRNN52
10680LDX;&)13
10700JSRNN53
10720LDA#230
10740STA#16
107bOLDA*231
10780STA#24
10800.JSRNN34
10820INC#BO
10840INC.ttSO
10860LDX@14
10880.JSRNNSO
10890.JSRNN30
10900LDA#232
10910STA#16
10920LDA#233
10930STA#24
10940JSRNN34
10950JSRNN3S
10960.JSRNN38 :
10970.JSRNN3S
10980.JSRNN39 :
10990RTS
11000:MM17LDA#230 :Add 1 to players total wins
11010CLC
11020ADC;&)1
11040STA#230
11060BCCMM18
110SOINC#231
11100:MM1SRTS
11120:MM12LDA#232 :Add 1 to computers total wins
11140CLC
11160ADC@ 1
111SOSTA4t232 :
11200BCCMM2
11220INC#233
11240:MM2RTS
11300]
11340R.
83
PART NO: 4
5F;EM PONTOON
10 '#90=#130D07!)1
20 1 #94=#110B0519
30!#9B=#BE821D17
40!#9C=#BCBB9589
50!#21C=#53484443
60:#221=#4B514A41
70!#230=0
BOCLEAR 4
90LI.#29BO
100E.
84
pONTOON and FIVE CARD TRICKS.
9020-8420 Set up pack and data locations, print
computer's 1st card face down, adjust pointers, print
player's 1st card face up, go score routine, adjust pointers,
print computer's 2nd card face down, adjust pointers.
8440~8740 Print player's 2nd card, go score routine,
print score, prompt for another card, adjust pointers, loop
until no more cards required or five cards dealt or BUST.
8750-9340 Computer's routine to print cards, calculate
score and adjust pointers.
9360-9620 Final score check routine. Looks for player's
pontoon or five card trick, if not found compares player's
score with computer's score and takes appropriate action.
This routine will only be entered if computer does not bust
or achieve a pontoon or a five card trick.
9640-9780 Prompts for another go and interprets answer.
9800-10160 Clears screen.
10500-10580 Restore BASIC address and exit.
10600-10990 Display current wins position.
11000-11100 Increment player's win.
11120-11300 Increment computer's wins.
If you do not have the Word Pack ROM fitted create your own
codes using pages #31 and #32, numerals and upper case. Line
1680 would need changing to LDA@#31.
as
Pools Prediction
This programme will store a pools data base, add to that
data base, update the data and predict draws. The prediction
algorithm creates a probajility factor of +127 to -128 by
the addition and subtraction of previous results. This
algorithm could easily be replaced by one of your owr.
choosing. The data base is stored in Mode 4 graphir~ RAM.
F·Ai=;.::T NO: 1.
EXECUTION:
86
2soE. :
270a[
290:LL38LDA:ii>#81 :Set up VDU line and column
310STY#EO :
330STA#DF
350LDA@#40
370STA#DE
390JSR#F7D1 :Print string following until
410J;R. :character found with bit 7 set
430b[
470:LL40LDA@#80 :Home cursor
490STA#DF
510LDA@O
530STA#DE
550RTS
570:LL39LDY@O :Set up VDU line and column
590STY#EO
610LDA@#81
630STA#DF
650LDA@#80
670STA#DE
690JSR#F7D1 :Print string
710J;R.
730c[
750NOP :Note this instruction to exit
770JMPLL40 :from #FD71
790:LLOLDA@#20
810:LL1STA(#90>,Y
B30:LL2JSR#FE94 :Get character from keyboard
850CMP@#7F :and recognize DELETE
870BNELL5
890DEY
910BPLLLO
930:LL3LDY@O
950:LL4LDA@#3F :Load Accum with ASCII "?"
970JMPLL1
990:LL5RTS
1010:LL6LDA@#83 :Compare name whose address is
1030STA#83 :held in #80,#81 with data bank
1050LDA:ii>O :whose address is held in #82,
1070STA#82 :#83, if not equal find start
1090:LL7LDY@#FF :of next string, store in #82,
1110: LL8INY :#83 and loop until valid
1130LDA<#B2>, Y :comparison or end of data
1150CMP@#FF :found, if end of data found
1170BEQLL 10 :discard return address and
1190CMP (#80), Y :output "TEAM NAME NOT FOUND"
1210BNELL9
1230CMP@#D
1250BNELL8
1270RTS
1290:LL9INY
87
1310LDA(#82>,Y
1330CMP@#D
1350BNELL9
1370TYA
1390CLC
1410ADC@13
1430ADC#B2
1450STA#82
1470BCCLL7
1490INC#83
1510JMPLL7
1530:LL10PLA
1550PLA
1570JSR#FFED
1590JSR#F7D1
1610J;R.
1630d[
1650NOP
1670JSRLL11 :Set #90,#91 to VDU start
1690LDA@#BO :address
1710STA#91
1730LDA@#20
1750STA#90
1770JSRLL11 :Delay
1790JMP(#84) :Jump to address stored by LL36
1810:LL11LCX@#30 :Delay
1830JSR#FB83
1850LDY@#17 :Clear line whose address is in
1870LDA@#20 :#90,#91
1890:LL12STAC#90>,Y
1910DEY
1930BPLLL12
1950RTS
1 970: LL13J SRBB 1 :Set up current match storage
1990LDA@O :area
2010STA#E1
2030LDA@#FF
2050STA#SF
2070LDA#33B :Store number of matches in #9F
2090STA#9F
2110:LL14LDY@O : Cl ear draw prediction worl{
2130STY#9A : space
2150STY#9B
2170STY#9D
2190STY#9E
2230JSRLL38 :Print HOME TEAM
2250JSRLL36 :Save return address
2270JSRBB2 :Store H.B VDU line address
2310LDA;i1#4B :Store L.E VDU line address in
2330STA#90 :#90
2350JSRLL11 :Clear line
2370JSRLL3 : Get chare.cter
BB
2 390:LL15STA<#SO>,Y :Store character
z410CMPG>#D
z430BEQLL16
z450ANDG>#3F :Convert to ATOM VDU code
z470STA<#90l,Y :Output to VDU
z490INY
2510JSRLL2
2530JMPLL15 :Loop until #D is input
2550:LL16JSRLL6 :Find address of HOME TEAM in
2570JSRLL33 :data bank, on return Y points
2590DEY :ta #D, adjust #80,#81 ta
2610LDX@4 :contain 1st free location
2630:LL17INY :address in current match
2650LDA<#B2>,Y :storage area
2670CLC :Get HOME team data routine
2690ADC#9A :On exit #9A will hold number
2710STA#9A :of HOME wins over past seasons
2730INY :and #9B will hold number of
2750INY :draws
2770LDA<#B2>,Y
2790CLC
2810ADC#9B
2830STA#9B
2850DEX :Loop far all years stored, X =
2870BNELL1 7 :number of years
2890LDA#9A :Calculate probability and
2910SEC :store in #9C
2930SBC#9B
2950STA#9C
2970LDA#90 :Move VDU address dawn 1 line
2990CLC
3010ADC4>#20
3030STA#90
3050LDYG>O
3070LDA<i>22 :Output "V" ta VDU
3090STAC#90>,Y
3110JSRLL39 :Print AWAY TEAM
3130JSRLL36 :Save return address
3150JSRBB2 :Set #90,#91 ta VDU line
3190LDA<i>#SB :address
3210STA#90
3230JSRLL3
3250:LL1BSTAC#BO>,Y :Set characters from keyboard,
3270CMPG>#D :store in current match storage
3290BEQLL1 9 :area and loop until #D input
3310AND4>#3F
3330STAC#90J,Y
3350INY
3370JSRLL2
3390JMPLL1B
34 10:LL19JSRLL6 :Find address of AWAY team in
3430JSRLL33 :data bank
89
3450DEY
3470LDX;li4
3490:LL20INY :Get AWAY data routine, on exit
3510INY :#qD holds AWAY wins and
3530LDA(#821,Y :#9E holds draws
3550CLC
3570ADC#9D
359•)STA#9D
3610INY
3630LDA(#82),Y
:~650CLC
3670ADC#9E
3690STA#9E
3710DEX
3730BNELL20
3750LDA#9D : Cal c~tI ate AWF~Y probabi 1 it}-'
3770SEC : fa::tor
3790SBC#9E
3810CLC :Add to HOME probability factor
3830ADC#9C
3850BPLLL21 :If +ve numbe~ GOTO LL21
Z870CMP#8F :See if highest -ve number, if
3890BCSLL21 :so store in #8F
3910STA#8F
393(>: LL21LDY@O :Store probability factor in
3950STA<#Bo;,v :currsnt match store
3970INY :Point V at next location
::;99r)LDA;l\#8t) :Set bit 7 of location to
4C,iOSTA (#8()}, --{ :indicate end of factor
4 ;)30JS~.~LL33 :Adjust address in #80,#81
11
-'105~)JSRLL :Delay
4070DEC#9F :Loop until all matches entered
4G90BEQLL22
4i 1()JMPLL14
4130~LL22JMF'WW4 :Store end of data marker
4210:LL23LDX:i>O :Clear page 0 locations used by
4230STX#25 :#C589
4250STX#34
4270STX#43
:Set field width to 0
431CLDA#8F :Store highest probability
4330STA#2!C :factor in #21C
4350:LL24JSRBB1 :Reset #80,#81
4370:LL25LDY@#FF
4390INX
4410:LL26INY
4430LDAC#BO>,Y :Find location with bit 7 set
4450EOR@#80
4470BNELL26
4490DEY :Point Y at probability factor
4510LDA<#801,f :and check to see if factor is
4530CMP#8F :equal to contents of #SF
9C>
4550BNELL31
45605TX#99 :Save X, X points to match
45705TX#lb :number
4590JSR#C589 :Output match number
4600LDX#99
4610JSR#F7FD
4630LDY@O
4650:LL27LDA<#BO>,Y :Output HOME team name
4670CMP@#D
4690BEQLL28
4710JSR#FE52
4730INY
4750JMPLL27
4770:LL28JSR#F7FD :Output space
4790LDA@CH"V" :Output "V"
4810JSR#FE52
4830JSR#F7FD :Output space
4B50:LL29INY :Output AWAY team name
4870LDAC#80>,Y :
4890JSR#FE52
4910CMP@#D
4930BNELL29
4950INY
4990JSR#FFED
5010DEC#9F :Loop until number
5030BNELL31 :of matches = 0
5070:LL30RTS
5090:LL31INY :Check for end of data
'5110INY
5130LDAC#80),Y
5150CMP@#FF
5170BEQLL32
5190JSRLL34 :Adjust #80,#81 and loop
5210JMPLL25
5230:LL32INC#BF :Increment #BF, when #BF #21C
5240LDA#8F :256 increments have been
5250CMP#21C :completed so exit
5270BEQLL30
5290LDX@O :Otherwise set match number to
5310JMPLL24 :O and loop
53SO:LL33INY :Subroutine to add Y to
S370:LL34TYA :contents of #80,#81
S390CLC
5410ADC#80
S430STA#80
54SOBCCLL35
S470INC#B1
S490:LL3SRTS
SS 10 :' LL36PLA :Save return address +1 in #84,
S530STA#B4 :#85
SSSOPLA :
SS70STA#85
91
5590PHA
5610LDA#84
5630PHA
565CCLC
5670ADC;i>1
5690STA#84
5710BCCLL37
5730INC#85
5750:LL37RTS
5770:SSOLDA£i#65 :Fl=tshing and moving cursor
5790STA-#90 :~oLttine
5810LDX@4 :tt90,#91 contain address of
5830STX#9F :cursor
5850JSRBB2
58'7'0: SS 1 LDA@B
5910STA#9E
!:;674:SS2LDY@O
5c;;50LDA;i>#AO
5970STA <#90> • 'f
5"1'90BIT#B001 :Checks at each cursor position
6010BPLSS4 :for depression of SHIFT
6030LD X;i)#5
6050JSR#FB83
6070LDA;i>#20
6090STAt#90),Y
6110BIT#B001
6130BPLSS4
6150LDX@#5
6170JSR#FB83
6190DEC#9E
6210BNESS2
6230LDXa>#10
6250JSR#FB83
627~)LDA#90
6290CLC
6310ADC;J>7
6330STA#90
6350DEC#9F
6370BNESS1
6390JMPSSO :On exit #9F will contain
6410:SS4LDA@#34 :pointer to year
6430STA#81 :Store address of string in #80,
6440STA#98 :#81, #98 is used as error flag
6450LDA@#20
6470STA#80
6490JSRBBO
6510JSRLL6 :Find name in data bank
6530INY
6550LDX;i)4
6560STX#98 :Clear error flag
6:'::70:SS5CPX#9F :Move Y to point at data for
6590BEQSS6 :year indicated
92
00 !0INV
0030INV
0050INY
0 670DEX
6690JMPSS5
6710:.SS6TYA :Adjust #82,#83 so that they
0 730CLC :contain address of data for
0 7SOADC#B2 :year indicated
6770STA#B2
6790BCCSS7
6B10INC•B3
6830:SS7RTS
6850:5S8LCY~2 :Store new data routine
6870:5S9LDA#339,Y :#339,#33A,#33B are_the L.Bs of
6890STA (-#82>, Y :integer--variables X,Y,Z
6910DEY
6930BPLSS9
6950RTS
6970:WWOJSRWW12
6990LDVi>O :Load #82,#83 with address of
7000LDAG>#20 :string
7010STA#82
7030LDAG>#34
7050STA#B3
7070:WW1LDA(#82>,Y :Store string in data bank
7090STA<#80>,V
7110INY
7130CMPG>#D
7150BNEWW1
7170LDXG>4 :Load X with number of seasons
7190STX#9C
7210LDAG>#B1 :set VDU address
7230STA#DF
7250LDAG>#20
7270:WW2STA#DE
7290LDXG>3 :Load X with pointer to Home
7310STX#9B :wins, Away wins and draws
7330LDAG>#D :Set column
73SO:WW3STA#EO
7370STY#9F :Routine which prompts for data
7390LDAG>O :input under each heading for
7410STA#9E :each season
7430JSR#FBBA
7450JSRWW5 :WWS returns with data in #9D
7470LDY#9F
7490LDA#9D :Store data in data bank
7510STA<#SO>,V
7530I!'IV
7550LDA#EO :Move prompt
7570CLC
7590ADCi>5
7610DEC#9B
93
7630BNEWW3 :Loop
7650LDA#DE :Change VDU line
7670CLC
7690ADC@#40
7710DEC#9C :Loop until all seasons done
7730BNEWW2
7750JSRLL34 :Adjust #80,#81
7770:WW4LDA@#FF :Store end of text marker
7790LDX<1i0
7810STA(#80,X>
7830RTS
7850:WW5LDY#EO :Display "?''·
7870LDA'1>#3F
7890STA<#DE>,Y
7910:WW6JSR#FE94 :Wait for key to be pressed
7930CMP'1>#7F
7950BNEWW7
7970DEC#EO
7990DEC#9E
8010JMPWW5
8030:WW7CMP@#D
8050BEQWW8
8070JSR#FE52 : Output chat-act er
8090AND@#OF :Clear top 4 bits
8110LDX#9E :Load X with pointer to work
8130STA#90,X :space, store low 4 bits
8150INX
8170STX#9E
8190CPX;i>3
8210BCCWW6
8230DEC#9E
8290:WWSLDX#9E :Convert input bits to 1 #
8310DEX :~umber held in #9D
8330LDA#90,X
8350STA#9D
8370DEX
8390BMIWW11
8410LDY#90,X
8430:WW9LDA#9D
8450CLC
8470ADC@#A
8490STA#9D
8510DEY
8530BNEWW9
8550:WWiORTS
8570:WW11INC#EO
8590JMPWW10
8610:WW12LDA@#2A :Reset cursor position and
8630STA#DE :clear VDU, X points to number
8650LDA;i>#81 ;of lines, Y points ta number
8670STA#DF :of columns
94-
9690LDX<i>4
9710:WW13LDY<i>#15
9730:WW14LDA<i>#20
9750STA<#DE>,Y
S770DEY
S790BPLWW14
SB10LDA#DE
S830CLC
8850ADC@#40
S870STA#DE
S890DEX
8910BNEWW13
8930RTS
8950:WW15JSR#FFED :Save data to tape routine
S960CLC :Print RECORD TAPE and wait for
S970JSR#FC38 :key to be pressed
S990LDA<i>#83 :Set #80,#81 to contain start
90fOSTA#B1 :address of data bank
9030LDY<i>O
9050STY#BO
9070:WW16LDA<#BO>,Y :Send byte to tape until end of
9080STA#B020 :text found, send visual
9090CHP<i>#FF :display
9110BEQWW17
9130JSR#FC7C
9150INY
9170BNEWW16
8934INC#B1
9210JHPWW16
9230:WW17LDA<i>#FF
9250JSR#FC7C
9270RTS
9290:KKOSEC :Load data routine, print PLAY
9310JSR#FC38 :TAPE and wait for key to be
9330LDY@O :pressed
9350LDA@#83
9362STA#81
9390STY#BO
9410:KK1JSR#FBEE :Get byte from tape until end
9430STA<#BO>,Y :of data found, store in data
9450STA#B040 :bank, send visual display
9470CMP@#FF
9490BEQKK2
9510INY
9530BNEKK1
9550INC#81
9570JHPKK1
9S90:KK2RTS
9610:EEOLDY@O :Find end of data routine
9630LDA@#83
96SOSTA#81
9670STY#OO
95
9690:EE1LDA<#80>,Y
9710CMP@#FF
9730BEQEE2
9750INY
9770BNEEE1
9790INC#81
9B10JMPEE1
9830:EE2JSRLL34 :E;;it with #80,lt81 containing
9850RTS :address of 1st free location
9860:BBOLDA@#C2 :Load #84,#85 with return
9950STA#85 :address, #C278 contains RTS
9960LDA@#78
9970STA#84
9980RTS
10040:BB1LDA@#35 :Load #80,#81 with address of
10050STA#B1 :current match storage area
10060LDA@O
10070STA#BO
10080RTS
10100:BB2LDA@#81 :Load #81 with H.B of VDU
10110STA#91 :address
10120RTS
12000]; R.
PART NO: 2
96
140W=.15
150IF Z<14 W=Z :
1b()LI.#30BD :REM LL13
t70P.$12"HATCHES HOST
1...IKELY TO DRAW ARE" •
1S0?#9F=W
190LI.#3193 :REM LL23
200L.I.=ltFE94
210P.$12
220IN."DO YOU WISH TO :
CHANGE DATA BASE"SR
230IFCHSR<>CH"V" E.
240IN."ADD EXTRA DATA"$R
250IFCHSR<>CH"Y" G.310
260L.I.=lt33AD :REM EEO
2706.a :
280P.$12"SAVE DATA"''
290LI.=lt3363 :REM WW15
300P.'"DATA SAVED"'
3056.110
310IN."CHANGE DATA"SR
320IFCHSR< >CH"Y"E.
330P.$12
340P.''" UPDATE DATA
11
350P.''
360IN."TEAM "$=13420
370P.''" SEASON TO BE
UPDATED"'
380P.'" 82/83 81/82
80/81 79/80""'''
390P.'""PRESS SHIFT ON
INDICATION"
400LI.=lt322C :REM SSO
410IF?=lt98<>4 G.485
420P.S12$=1t3420" FOUND""
430X=7B+?=lt9F
440P."SEASON
19•X 11 /19"X+1''
450IN."DRAWS"Z
460IN."AWAYS"Y
470IN."HOMES"X
4BOLI.=lt329B :REM SSS
48SP.••
490.IN. "MORE"SR
500IFCH$R=CH"Y" 6.330
s1os.200
520!ftBO==lt8300
530aP.$12" DATA BASE
ENTRY 11 •
S40IN."ENTER NO OF TEAMS"X
sso
97
560F.N=1 TD X
570?#E1=#00
580P.'''''"<11SPACES>
HOMES AWAYS DRAWS"
590P.'"--(28 -ve SIGNS>--"
6COP. "1982/1983"""
"1981/1982"''"1980/1981"''
"1979/1980"
610P.$30
620?#DE=#60
630P."<22 SPACESj"$13
640?#E1=#80
650P."TEAM NO"N
660IN." NAME"$#3420
670LI.#32A6 :REM WWO
680?#DF=#80
690?#DE=#40
700?#EO=O
710N.
7206.280
LINES:-
290-430 Set up VDU and print HOME TEAM.
470-730 Home cursor, set up VDU and print AWAY TEAM.
790-990 Get character from keyboard, recognize delete.
1010-1590 Find team in data bank, return with Y pointing
to #D, if not found print TEAM NAME NOT FOUND.
1650-1950 Clear line, delay befor returning.
1970-3090 Set up current match storage area, get HOME TEAM
name, find in data bank, store in current match area,
calculate probability.
3110-4130 Get AWAY TEAM, find in data bank, store in
current match area, calculate probability of match, store
fa~tor in current match area,set bit 7 of next location,
store end of text marker before returning. ·
4210-5310 Print matches in order of probability.
5350-5490 Add Y to #80,#81 subroutine.
5510-5750 Calculate return addr2ss subroutine.
5770-6390 Flash and move cursor until SHIFT pressed.
6410-6830 Find name in data bank, adjust #82,#83 to
contain address of data for year indicated.
6850-6950 Store new d.ata.
6970-8590 Set up data base routine. Store name in data
bank, get data as ASCII code, convert to # number and store,
store end of te>:t marker on e>:it.
8610-8930 Clear VDU for next data input.
8950-9270 Save data to tape.
9290-9590 Load data from tape.
9610-G850 Find end of data routine.
9860-9980 Load #84, #85 wi t'i address to fetch FnS.
10040-10080 Load #80,#81 with address of data bank.
10100-10120 Load #91 with H.B VDU address.
98
Screenchase
The computer guides a cursor, you guide a cursor. If you hit
your own trail or the computer's trail you will have to sit
back and watch the computer cover as many stars as possible.
you gain points for every star covered, you lose points for
every star the computer covers. You move your cursor with
keys 1,2,3 and 4 which will move your cursor Up, Forwards,
Down and Backwards respectively.
10:2
z370ASLA :bit 7 clear
z3SoBCCZZ37
z390DEX
z400BNEZZ30
..,410RTS
Z650:ZZ37JMPZZ15
zaoo:ZZ39LDA#80 :Transfer current cursor
zatOSTA#90 :address to #90,#91
2B20LDA#81
28305TA#91
2840LDY@O
2850LDX@O
2860RTS
3010:ZZ40LDX@8 :Print player's cursor at
3030LDY@O :address in #9A,#9B
3050:ZZ41LDA@#AA
3070STA(#9A>,Y
3090LDA#9A
3110CLC
3130ADC@#20
3150STA#9A
3170DEX
3190BNEZZ41
3200JSR#FB8A
3210RTS
3230:ZZ42LDA#9A :Move player's cursor forward 1
3250CLC :block
3270ADC@1
3290CMP@#20
3310BNEZZ43
3330LDA@O
3350:ZZ435TA#9A
3370JMPZZ50
3390:ZZ44LDA#9A :Move player's cursor backwards
3410SEC :1 block
3430SBC@1
3450CMP@#FF
3470BNEZZ45
3490LDA@#1F
3510:ZZ45STA#9A
3530JMPZZ50
3SSO:ZZ46LDA#9B :Move player's cursor up 1
3570SEC :block
3590SBC@1
3610CMP@#7F
3630BNEZZ47
36SOLDA@#97
3 670:ZZ47STA#9B
3 690JMPZZ50
37 10:ZZ48LDA#9B :Move player's cursor down by 1
3730CLC :block
37SOADC@1
103
37?0CMP@#93
37'=f.:JBNEzz.:49
38 ~ ~)LDA:i/#90
4540:ZZ57RTS
4560:ZZ58LDA#2!C :Player's score decrease
4580SEC : roLtti ne
46 ~)(iSBC@25
4.:S20STA#21C
4640BCSZZ59
4660DEC#2 i I:'
1. C>4
Subroutines Used
#C2F2 Interpreter entry point.
A Accumulator
#2800 AbsoiLite
#9':) Zero page
$'#FF Imme,jiate
#2800,X Absolute,:<
#2800,Y Absolut:,Y
(#80,XI Ind1r-ect, :<
\#80),Y Indir·ect, Y
#9G, X Zero page,/
#90,Y Zero p.::lge" Y
(#'1'F ! Indirect
ADC#2800
ADC#9•)
ADC@#FF
?tDC#2800 ¥ X
ADC#2800,Y
ADC(#80,X)
ADC<"t80/,Y
{~DC'#90, ~<
AND#2800
AND#9')
AND:il#FF
?<ND#2800, X
AND#28(l(i, v
r~ND <f*BO, Xi
AND(#80i,Y
Al,i0#90,X
f.';SLA
AS!...#2800
ASL#qt)
ASL#2SC·O ~ X
ASL#90,X
1C>6
13EQ BRANCH IF EQUAL TO ZERO
BRI< BREAK
CMP#2800
CMP#90
CMP@#FF
CMP#2800,X
CMP#2800,Y
CMP<#BO,X>
CMPC#SO>,Y
CMP#90,X
CPX COMPARE TO X
CPX#2800
CPX#90
CPXG>#FF
C:PV COMPARE TO Y
CPV#2SOO
CPV#90
CPV<il#FF
DEC#2BOO
DEC#90
DEC#2BOO,X
· DEC#90, X
107
DEX DECREMENT X
DEV DECREMENT V
EOR EXCLUSIVE-OR
EOR#2800
EOR#90
EOR@#FF
EOR#2800,X
EOR#2800,Y
EDR<#BO,X)
EOR<#SO>, Y
EOR#90,X
INC#2800
INC#90
INC#2800,X
INC#90,X
INX INCREMENT X
INV INCREMENT Y
JMP#2800
JMP(#9F>
LDA#2800
LDA#90
LDA4>#FF
LDA#2800,X
LDA#2800,Y
LDAC#BO,X>
LDA<#SO>,Y
LDA#90,X
LDX LOAD X
LDX#2800
LDX#90
LDX<i>#FF
LDX#2800,Y
LDX#90,Y
:1. OS
,_ov LOAD V
t...DV#2800
t.J>V#90
t...DV:G>#FF
t...DV#2800,X
t...DV#90,X
LSRA
LSR#2800
LSR#90
LSR#2800,X
LSR#90,X
NOP NO OPERATION
ORA INCLUSIVE-OR
ORA#2800
ORA#90
ORA:G>#FF
ORA#2800,X
ORA#2800,Y
ORA<#BO,X>
ORA<#BO>, Y
ORA#90,X
PHA PUSH ACCUMULATOR ON STACK
PHP PUSH PROCESSOR STATUS ON STACK
PLA PULL ACCUMULATOR FROM STACK
P ..... P PULL PROCESSOR STATUS FROM STACK
ROL ROTATE LEFT
ROLA
ROL#2800
ROL#90
R0L#2800,X
ROL#90,X
R:OR ROTATE RIGHT
RORA
ROR•2aoo
ROR•9o
ROR•2aoo x
ROR•9o,x'
109
RTI RETUR~i FROM INTERRUPT
SBC#2800
SBC#90
SBCi>#FF
SBC#280'.i. X
SBC#280(•, Y
SBC<#80,X)
SBC \#80), Y
SE•C#9C, X
STA#2EOO
STA#l70
STA#230·0, X
STA#2800.Y
STA<#BO,Xi
STA!#8G}.Y
ST?-1#9':•. X
E:TX#2800
STX#90
STX#9C1, Y
STOR~ V IN MEMORJ
STf#2800
ST\/#9:)
ETY#9(;; X
------------------------------
F"ONTDDN.
THE COMPUTER CHEATS!!
It looks at your score, if greater or equal it exits as it
has won, if 1 ess it 1 oaks at the ne:<t card, adds that to
it's score and as long as this score is less than 22 it
displays the card. Only if the next card will bust will the
computer. allow vou to win.
111