;************************************************************************************ ; ; bit correct disassembly of spectra IV ROM V1.09 Lee Davison 18th April 2012 ; battery backed RAM is enabled from $0000 to $00FF. when the output drivers are ; written to so is the RAM but when those same addresses are read only the RAM ; responds. This means that all addresses from $0000 to $00FF not actually used ; for outputs may be used purely as RAM ; BCD digit drivers ; digits are from $x0, leftmost, to $x05, rightmost ; the decimal point is b4, the digit is encoded on b3-b0 ; player score displays. the right side LED, digit 5, shows how many players are playing ; while the left side LED, digit 0, shows which player is up ; player 4 digits LAB_00 = $00 ; player 4 up ;LAB_05 = $05 ; 4 player LAB_06 = $06 ; game in play flag LAB_07 = $07 ; Tilt Flag (wrk001 120419) ; player 3 digits LAB_08 = $08 ; player 3 up ;LAB_0D = $0D ; 3 player LAB_0E = $0E ; ball in play LAB_0F = $0F ; number of players ; player 2 digits LAB_10 = $10 ; player 2 up ;LAB_15 = $15 ; 2 player LAB_16 = $16 ; credits LAB_17 = $17 ; player number ; player 1 digits LAB_18 = $18 ; player 1 up LAB_1D = $1D ; 1 player LAB_1E = $1E ; lit thumper lamp LAB_1F = $1F ; match award random digit ; status digits. during gameplay these digits show in order credits, blank, the number ; of players, blank, ball in play ; ; in attract mode the status display will alternately show, the high score, the average ; score for the last 10 games, the number of credits and match point if set in option ; 16 LAB_20 = $20 ; status digit 0, high score credits 10s LAB_21 = $21 ; status digit 1, average score credits 1s LAB_22 = $22 ; status digit 2, credits blank LAB_23 = $23 ; status digit 3, player number of players LAB_24 = $24 ; status digit 4, ball blank LAB_25 = $25 ; status digit 5, match ball in play LAB_26 = $26 ; player 1-4 ?? LAB_2A = $2A ; player 1-4 special and gate lamps LAB_2E = $2E ; feature lane animation step ?? LAB_2F = $2F ;. LAB_30 = $30 ; gate lane sound ?? LAB_31 = $31 ; score pointer LAB_33 = $33 ; option pointer ; U6, DM9334 LAB_40 = $40 ; lamp 31, feature lane ;LAB_41 = $41 ; lamp 32, feature lane ;LAB_42 = $42 ; lamp 33, feature lane ;LAB_43 = $43 ; lamp 34, feature lane ;LAB_44 = $44 ; lamp 35, feature lane ;LAB_45 = $45 ; lamp 36, feature lane - free ball ;LAB_46 = $46 ; lamp 37, feature lane LAB_47 = $47 ; lamp 38, feature lane kicker ; U5, DM9334 LAB_48 = $48 ; lamp 19, 2x bonus LAB_49 = $49 ; lamp 15, 3x bonus LAB_4A = $4A ; lamp 12, shoot again LAB_4B = $4B ; lamp 1, 1 thousand ;LAB_4C = $4C ; lamp 2, 2 thousand ;LAB_4D = $4D ; lamp 3, 3 thousand ;LAB_4E = $4E ; lamp 4, 4 thousand ;LAB_4F = $4F ; lamp 5, 5 thousand ; U4, DM9334 ;LAB_50 = $50 ; lamp 6, 6 thousand ;LAB_51 = $51 ; lamp 7, 7 thousand ;LAB_52 = $52 ; lamp 8, 8 thousand ;LAB_53 = $53 ; lamp 9, 9 thousand LAB_54 = $54 ; lamp 10, 10 thousand LAB_55 = $55 ; lamp 11, 20 thousand LAB_56 = $56 ; lamp 14, tilt LAB_57 = $57 ; lamp 13, game over ; U1, DM9334 LAB_58 = $58 ; lamp 25, spinner lane lamp LAB_59 = $59 ; lamp 26, refeed lane LAB_5A = $5A ; lamp 27, special mid lane LAB_5B = $5B ; lamp 28, special right lane ;LAB_5C = $5C ; unused ;LAB_5D = $5D ; unused ;LAB_5E = $5E ; unused ;LAB_5F = $5F ; unused ; U2, DM9334 LAB_60 = $60 ; lamp 20, top right rollover LAB_61 = $61 ; lamp 21, top left rollover LAB_62 = $62 ; lamp 22, right thumper ;LAB_63 = $63 ; lamp 23, upper right thumper ;LAB_64 = $64 ; lamp 24, upper left thumper LAB_65 = $65 ; lamp 30, top right outhole kicker ;LAB_66 = $66 ; unused ;LAB_67 = $67 ; unused ; U3, DM9334 LAB_68 = $68 ; lamp 18, centre trap left target LAB_69 = $69 ; lamp 17, centre trap mid target LAB_6A = $6A ; lamp 16, centre trap right target LAB_6B = $6B ; lamp 29, open gate ;LAB_6C = $6C ; unused ;LAB_6D = $6D ; unused ;LAB_6E = $6E ; unused ;LAB_6F = $6F ; unused ; solenoid drivers LAB_70 = $70 ; solenoid 1, ball feed ;LAB_71 = $71 ; solenoid 2, refeed ;LAB_72 = $72 ; solenoid 3, feature lane ;LAB_73 = $73 ; solenoid 4, outhole ;LAB_74 = $74 ; solenoid 5, thumper ;LAB_75 = $75 ; solenoid 6, thumper ;LAB_76 = $76 ; solenoid 7, thumper ;LAB_77 = $77 ; solenoid 8, right side band ;LAB_78 = $78 ; solenoid 9, left side band LAB_79 = $79 ; solenoid 10, gate LAB_7A = $7A ; solenoid 11, playfield LAB_7B = $7B ; solenoid 12, crem LAB_7C = $7C ; solenoid 13, unused - could be a rotation locking solenoid (wrk001 120419) ;LAB_7D = $7D ; unused ;LAB_7E = $7E ; unused ;LAB_7F = $7F ; unused ; options LAB_80 = $80 ; option 01, coin position ;LAB_86 = $86 ; option 02, games played ;LAB_8C = $8C ; option 03, free credits awarded ;LAB_92 = $92 ; option 04, times high score beaten ;LAB_98 = $98 ; option 05, number of times tilted LAB_9E = $9E ; option 06, award limit one LAB_A4 = $A4 ; option 07, award limit two LAB_AA = $AA ; option 08, award limit three LAB_B0 = $B0 ; option 09, high score to date LAB_B6 = $B6 ; option 10, average score LAB_BC = $BC ; option 11, game price LAB_BD = $BD ; option 12, discount bonus credit LAB_BE = $BE ; option 13, balls per game LAB_BF = $BF ; option 14, feature lane options LAB_C0 = $C0 ; option 15, special award option LAB_C1 = $C1 ; option 16, match option LAB_C2 = $C2 ; current coin count LAB_C3 = $C3 ; bonus credits count LAB_C4 = $C4 ; current player number LAB_C5 = $C5 ; 1000s, 100s and bonus count LAB_C6 = $C6 ; special award tune index LAB_C7 = $C7 ; high score player LAB_C8 = $C8 ; player award flag byte ; bits 3 to 0 are set for players winning awards LAB_C9 = $C9 ; endgame ?? flag LAB_CA = $CA ; switch $01, playfield exit ;LAB_CB = $CB ; switch $02, refeed lane ;LAB_CC = $CC ; switch $03, feature lane ;LAB_CD = $CD ; switch $04, top right outhole kicker ;LAB_CE = $CE ; switch $05, right thumper ;LAB_CF = $CF ; switch $06, upper right thumper ;LAB_D0 = $D0 ; switch $07, upper left thumper ;LAB_D1 = $D1 ; switch $08, lower right side band ;LAB_D2 = $D2 ; switch $09, lower left side band ;LAB_D3 = $D3 ; switch $0A, right gate lane ;LAB_D4 = $D4 ; switch $0B, top right rollover ;LAB_D5 = $D5 ; switch $0C, top left rollover ;LAB_D6 = $D6 ; switch $0D, centre trap left target ;LAB_D7 = $D7 ; switch $0E, centre trap mid target ;LAB_D8 = $D8 ; switch $0F, centre trap right target ;LAB_D9 = $D9 ; switch $10, light spinner ;LAB_DA = $DA ; switch $11, spinner ;LAB_DB = $DB ; switch $12, spinner lane top exit ;LAB_DC = $DC ; switch $13, open gate target ;LAB_DD = $DD ; switch $14, special mid lane ;LAB_DE = $DE ; switch $15, special right lane ;LAB_DF = $DF ; switch $16, right centre side band ;LAB_E0 = $E0 ; switch $17, left centre side band ;LAB_E1 = $E1 ; switch $18, upper left side band ;LAB_E2 = $E2 ; switch $19, top left side band ;LAB_E3 = $E3 ; switch $1A, top right side band ;LAB_E4 = $E4 ; switch $1B, playfield entry LAB_E5 = $E5 ; switch $1C, coin set LAB_E6 = $E6 ; switch $1D, demand (start game) LAB_E7 = $E7 ; switch $1E, test ;LAB_E8 = $E8 ; switch $1F, set LAB_E9 = $E9 ; switch $20, rotate LAB_EA = $EA ; temporary digit store ; bonus total ; set option step LAB_EB = $EB ; feature lane lamp number ; test item number when in test mode ; temporary byte for compare functions LAB_EC = $EC ; bonus multiplier sound on delay LAB_ED = $ED ; bonus multiplier sound off delay LAB_EE = $EE ; high score and award limits compare result LAB_EF = $EF ; feature lane animation delay LAB_F0 = $F0 ; temporary store for the value to add LAB_F1 = $F1 ; solenoid to fire number LAB_F2 = $F2 ; solenoid delay LAB_F3 = $F3 ; sound delay LAB_F4 = $F4 ; delay to the next step LAB_F5 = $F5 ; game over count LAB_F6 = $F6 ; tilt lamp count LAB_F7 = $F7 ; quater second counter LAB_FF = $FF ; ball in play flag ; $00 = no ball in play ; $01 = ball in play ;************************************************************************************ ; ; RIOT RAM, used for the stack LAB_0100 = $0100 ; quater second timer ; RIOT I/O ports LAB_0180 = $0180 ; RIOT DRA ; bit function ; --- -------- ; 7 tilt switch ; 6 CD4051 data ; 5 watchdog negative trigger ; 4 CD4051 chip address 1 ; 3 CD4051 chip address 0 ; 2 CD4051 bit address 2 ; 1 CD4051 bit address 1 ; 0 CD4051 bit address 0 ; chip 00, U18 ; bit function ; --- -------- ; 7 lower right side band ; 6 upper left thumper ; 5 upper right thumper ; 4 right thumper ; 3 top right outhole kicker ; 2 feature lane ; 1 refeed lane ; 0 playfield exit ; chip 01, U19 ; bit function ; --- -------- ; 7 light spinner ; 6 centre trap right target ; 5 centre trap mid target ; 4 centre trap left target ; 3 top left rollover ; 2 top right rollover ; 1 right gate lane ; 0 lower left side band ; chip 10, U20 ; bit function ; --- -------- ; 7 upper left side band ; 6 left centre side band ; 5 right centre side band ; 4 special right lane ; 3 special mid lane ; 2 open gate target ; 1 spinner lane top exit ; 0 spinner ; chip 11, U21 ; bit function ; --- -------- ; 7 demand ; 6 set ; 5 rotate ; 4 test ; 3 coin set ; 2 playfield entry ; 1 top right side band ; 0 top left side band LAB_0181 = $0181 ; RIOT DDRA, 0 = input LAB_0182 = $0182 ; RIOT DRB ; bit function ; --- -------- ; 7 pulse ; 6 phaser ; 5 decay ; 4 strobe ; 3 tone 8 ; 2 tone 4 ; 1 tone 2 ; 0 tone 1 LAB_0183 = $0183 ; RIOT DDRB, 0 = input ; RIOT timer and PA7 edge detect LAB_0184 = $0184 ; disable PA7, negative edge ; read timer LAB_0185 = $0185 ; read interrupt flag LAB_0186 = $0186 ; enable PA7, negative edge LAB_019E = $019E ; write timer, /64, enable timer ;************************************************************************************ ; ; filler. the first 1K of the ROM is not mapped and is filled with $FF .ORG $0000 .dcb $0400,$FF ; fill with 1024 $FFs ;************************************************************************************ ; ; start of the code .ORG $0400 ; switch $01, playfield exit - continued LAB_0400 JSR LAB_0C1D ; set all the switches, wait for them to open LDA LAB_06 ; get the game in play flag BEQ LAB_041D ; if no game in play return to the main program loop ; check to see if the ball is in the out hole (wrk001 120419) LDA LAB_07 ;get Tilt Flag (wrk001 120419) BEQ LAB_0413 ;not on then turn off lamp & allow game to restart STA LAB_2F ; get unknown flag (wrk001 120419) STA LAB_7C ; save solenoid 13, unused LSR LAB_07 ; Clear Tilt flag (wrk001 120419) BEQ LAB_041D ; return to the main program loop, branch always LAB_0413 STA LAB_56 ; clear lamp 14, tilt ; set solenoid 1, ball feed to fire LAB_0415 LDX #$01 ; set solenoid 1, ball feed ;************************************************************************************ ; ; save the solenoid to fire and continue LAB_0417 STX LAB_F1 ; save the solenoid to fire number LAB_0419 LDA #$18 ; set the solenoid delay, 24 * 8.3ms = 200ms STA LAB_F2 ; save the solenoid delay LAB_041D JMP LAB_089A ; return to the main program loop ;************************************************************************************ ; ; switch $02, refeed lane LAB_0420 STX LAB_F1 ; save the solenoid to fire number LSR LAB_59 ; get and clear lamp 26, refeed lane BCC LAB_0428 ; if the lamp was out skip setting the 5000 bonus LDY #$04 ; set the bonus to 5,000 LAB_0428 JSR LAB_0BDE ; increment the bonus value DEY ; decrement the bonus count BPL LAB_0428 ; loop if more to do LDA #$C0 ; set the sound STA LAB_0182 ; save the RIOT DRB, the sound port LDA #$40 ; set the sound delay STA LAB_F3 ; save the sound delay BNE LAB_0419 ; go set the solenoid delay and return to the main loop, ; branch always ;************************************************************************************ ; ; switch $03, feature lane LAB_0439 INY ; Y = $01 STY LAB_47 ; light lamp 38, feature lane kicker LDX LAB_C4 ; get the current player number LDA LAB_26-1,X ; get the player feature lane value CMP #$07 ; compare it with the max + 1 BCS LAB_0450 ; if > max skip the feature lane increment INC LAB_26-1,X ; increment the player feature lane value LDA LAB_26-1,X ; get the player feature lane value LAB_0448 STA LAB_2E ; save the feature lane animation step ?? LDA #$20 ; set the delay, 32 * 8.3ms = 266ms STA LAB_EF ; save the feature lane animation delay BNE LAB_041D ; return to the main program loop, branch always ; ?? LAB_0450 ROL LAB_26-1,X ; ?? the player feature lane value LDA #$07 ; set the feature lane animation step ?? BNE LAB_0448 ; go save the step and set the delay, branch always ;************************************************************************************ ; ; switch $04, top right outhole kicker LAB_0456 STX LAB_F1 ; save the solenoid to fire number STX LAB_C5 ; save the lit lamp 1000s score LDA LAB_65 ; get lamp 30, top right outhole kicker, ghost register BNE LAB_0472 ; if the lamp was lit go score 5 x 1000 ; the lamp was not lit, score 500 LDA #$53 ; set 5 x 10^(5-3) = 500 JSR LAB_0A82 ; add a value to the score and check for awards LAB_0463 LDA #$C0 ; set the sound STA LAB_0182 ; save the RIOT DRB, the sound port LSR LAB_65 ; clear lamp 30, top right outhole kicker LDA #$20 ; set the soundand solenoid delay, 32 * 8.3ms = 267ms STA LAB_F2 ; save the solenoid delay STA LAB_F3 ; save the sound delay BNE LAB_041D ; return to the main program loop, branch always ; the lamp was lit, score 5 x 1000 LAB_0472 LDA #$06 ; set the sound STA LAB_0182 ; save the RIOT DRB, the sound port LDA #$18 ; set the delay time, 24 * 8.3ms = 200ms JSR LAB_0BF4 ; save the delay time and wait until it is complete LDA #$12 ; set 1 x 10^(5-2) = 1000 JSR LAB_0A82 ; add a value to the score and check for awards JSR LAB_0BFB ; clear the sound and wait for 50ms DEC LAB_C5 ; decrement the lit lamp 1000s score BPL LAB_0472 ; loop if more to do BMI LAB_0463 ; go clear the lamp and exit, branch always ;************************************************************************************ ; ; switch $05, right thumper ; switch $06, upper right thumper ; switch $07, upper left thumper LAB_048A STX LAB_F1 ; save the solenoid to fire number LDA #$08 ; set the solenoid delay, 8 * 8.3ms = 66ms STA LAB_F2 ; save the solenoid delay LDA LAB_62-5,X ; get the lamp ghost register for the thumper LSR ; shift the lamp bit to the carry LDA #$13 ; set 1 x 10^(5-3) = 100 LDX #$A8 ; set the 100 scored sound BCC LAB_04A0 ; if the lamp was out skip adding 1000 JSR LAB_0C8F ; sequence the thumper lamps upper left, upper right, right LDA #$12 ; set 1 x 10^(5-2) = 1000 LDX #$85 ; set the 1000 scored sound LAB_04A0 STX LAB_0182 ; save the RIOT DRB, the sound port LDY #$20 ; set the sound delay STY LAB_F3 ; save the sound delay JSR LAB_0A82 ; add a value to the score and check for awards JMP LAB_089A ; return to the main program loop ;************************************************************************************ ; ; switch $0B, top right rollover ; switch $0C, top left rollover LAB_04AD LDA LAB_48 ; get lamp 19, 2x bonus LSR ; shift the flag bit to Cb BCS LAB_04D4 ; if lamp 19, 2x bonus was lit go score 500 ; 2x bonus was not lit LSR LAB_60-$0B,X ; get and clear the lamp bit for the channel LDX #$A5 ; set the 500 scored sound LDA #$53 ; set 5 x 10^(5-3) = 500 BCC LAB_04BE ; if the lamp was out skip ; the lamp for this channel was on LDX #$8D ; set the 1000 scored sound LDA #$12 ; set 1 x 10^(5-2) = 1000 LAB_04BE STX LAB_0182 ; save the RIOT DRB, the sound port JSR LAB_0A82 ; add a value to the score and check for awards LDA #$40 ; set the sound delay STA LAB_F3 ; save the sound delay LDA LAB_60 ; get the top right rollover lamp ORA LAB_61 ; Or it with the top left rollover lamp LSR ; shift the lamp bit into Cb BCS LAB_0528 ; if either lamp was lit return to the main program loop SEC ; set carry to light the lamp ROL LAB_48 ; light lamp 19, 2x bonus BNE LAB_0528 ; return to the main program loop, branch always ; lamp 19, 2x bonus was lit LAB_04D4 LDA #$A5 ; set the sound STA LAB_0182 ; save the RIOT DRB, the sound port JSR LAB_0BEE ; delay for 250ms LDA #$53 ; set 5 x 10^(5-3) = 500 JSR LAB_0A82 ; add a value to the score and check for awards JSR LAB_0BFB ; clear the sound and wait for 50ms JSR LAB_0BDE ; increment the bonus value LDA #$8F ; set the sound STA LAB_0182 ; save the RIOT DRB, the sound port LDA #$20 ; set the sound delay STA LAB_F3 ; save the sound delay BNE LAB_0528 ; return to the main program loop, branch always ;************************************************************************************ ; ; switch $0E, centre trap mid target LAB_04F2 INY ; set to light lamp STY LAB_59 ; save lamp 26, refeed lane ;************************************************************************************ ; ; switch $0D, centre trap left target ; switch $0F, centre trap right target LAB_04F5 LSR LAB_68-$0D,X ; get and clear the switch lamp bit BCS LAB_052B ; if the lamp was on go score 2000 ; the lamp was off LDA #$A7 ; set the 1000 scored sound STA LAB_0182 ; save the RIOT DRB, the sound port JSR LAB_0BEE ; delay for 250ms LDA #$12 ; set 1 x 10^(5-2) = 1000 JSR LAB_0A82 ; add a value to the score and check for awards LDA LAB_49 ; get lamp 15, 3x bonus LSR ; shift the lamp bit to Cb BCC LAB_051D ; if the lamp is out skip the bonus set JSR LAB_0BFB ; clear the sound and wait for 50ms JSR LAB_0BDE ; increment the bonus value JSR LAB_0BDE ; increment the bonus value LDA #$8F ; set the sound LAB_0516 STA LAB_0182 ; save the RIOT DRB, the sound port LDA #$1E ; set the sound delay STA LAB_F3 ; save the sound delay LAB_051D LDA LAB_6A ; get lamp 16, centre trap right target ORA LAB_69 ; OR with lamp 17, centre trap mid target ORA LAB_68 ; OR with lamp 18, centre trap left target BNE LAB_0528 ; if any lamps are lit return to the main program loop ; none of the centre trap target lamps are lit SEC ; set carry to light lamp ROL LAB_49 ; light lamp 15, 3x bonus LAB_0528 JMP LAB_089A ; return to the main program loop ; the lamp was on LAB_052B LDA #$22 ; set 2 x 10^(5-2) = 2000 JSR LAB_0A82 ; add a value to the score and check for awards LDA #$84 ; set the 2000 scored sound BNE LAB_0516 ; go save the sound and continue, branch always ;************************************************************************************ ; ; switch $10, light spinner LAB_0534 LDA #$2F ; set the sound STA LAB_0182 ; save the RIOT DRB, the sound port LDA #$64 ; set the sound delay STA LAB_F3 ; save the sound delay JSR LAB_0BDE ; increment the bonus value LDA #$01 ; set light lamp STA LAB_58 ; save lamp 25, spinner lane lamp BNE LAB_0528 ; return to the main program loop, branch always ;************************************************************************************ ; ; switch $11, spinner LAB_0546 LDA LAB_58 ; get lamp 25, spinner lane lamp EOR #$02 ; toggle ..X. ...., the spinner lane sound bit STA LAB_58 ; save lamp 25, spinner lane lamp LDX #$0B ; set the spinner lane sound 0 LSR ; shift the spinner lane lamp bit to Cb BCC LAB_0564 ; if the lamp was out go score 100 ; the spinner lane lamp was lit LSR ; shift the spinner lane sound bit to Cb BCC LAB_0556 ; if the sound bit was clear use the set sound LDX #$04 ; set the spinner lane sound 1 LAB_0556 LDA #$12 ; set 1 x 10^(5-2) = 1000 LAB_0558 JSR LAB_0A82 ; add a value to the score and check for awards STX LAB_0182 ; save the RIOT DRB, the sound port LDA #$10 ; set the sound delay STA LAB_F3 ; save the sound delay BNE LAB_0528 ; return to the main program loop, branch always ; the spinner lane lamp was out LAB_0564 LDA #$13 ; set 1 x 10^(5-3) = 100 BNE LAB_0558 ; go add the score, branch always ;************************************************************************************ ; ; switch $12, spinner lane top exit LAB_0568 SEC ; set carry to turn on lamp ROL LAB_65 ; set lamp 30, top right outhole kicker JSR LAB_0BDE ; increment the bonus value LDA #$8F ; set the sound BNE LAB_057F ; go save the sound and continue, branch always ;************************************************************************************ ; ; switch $13, open gate target LAB_0572 LDA #$01 ; solenoid on STA LAB_79 ; save solenoid 10, gate STA LAB_6B ; save lamp 29, open gate LDA #$12 ; set 1 x 10^(5-2) = 1000 JSR LAB_0A82 ; add a value to the score and check for awards LDA #$A5 ; set the sound LAB_057F STA LAB_0182 ; save the RIOT DRB, the sound port LDA #$3C ; set the sound delay STA LAB_F3 ; save the sound delay BNE LAB_05A5 ; return to the main program loop, branch always ;************************************************************************************ ; ; switch $14, special mid lane LAB_0588 LDX #$03 ; set 3000 bonus STX LAB_C5 ; save the bonus LAB_058C LDA #$0F ; set the sound STA LAB_0182 ; save the RIOT DRB, the sound port JSR LAB_0BEE ; delay for 250ms JSR LAB_0BDE ; increment the bonus value JSR LAB_0BFB ; clear the sound and wait for 50ms DEC LAB_C5 ; decrement the bonus BNE LAB_058C ; loop if more to do LSR LAB_5A ; get and clear lamp 27, special mid lane BCC LAB_05EB ; if the lamp was out go make the sound JSR LAB_0B61 ; award a free ball or free game LAB_05A5 JMP LAB_089A ; return to the main program loop ;************************************************************************************ ; ; switch $15, special right lane LAB_05A8 LDA LAB_5B ; get lamp 28, special right lane LSR ; shift the lamp bit to the carry BCC LAB_05B8 ; if the lamp is out skip the bonus increment LDA #$2F ; set the sound STA LAB_0182 ; save the RIOT DRB, the sound port JSR LAB_0BEA ; delay for 500ms JSR LAB_0BDE ; increment the bonus value LAB_05B8 LDX #$05 ; set the 100 score count STX LAB_C5 ; save the 100 score count LAB_05BC JSR LAB_0BFB ; clear the sound and wait for 50ms LDA #$03 ; set the sound STA LAB_0182 ; save the RIOT DRB, the sound port JSR LAB_0BEE ; delay for 250ms LDA #$13 ; set 1 x 10^(5-3) = 100 JSR LAB_0A82 ; add a value to the score and check for awards DEC LAB_C5 ; decrement the 100 score count BNE LAB_05BC ; loop if more to do BEQ LAB_05A5 ; return to the main program loop, branch always ;************************************************************************************ ; ; switch $0A, right gate lane LAB_05D2 LDA #$53 ; set 5 x 10^(5-3) = 500 JSR LAB_0A82 ; add a value to the score and check for awards LSR LAB_6B ; get and clear lamp 29, open gate LDX #$01 ; this value is never used ?? BCC LAB_05EB ; if the lamp was not lit go set the gate lane sound ; the lamp was lit JSR LAB_0BDE ; increment the bonus value LDX #$BC ; set the sound STX LAB_0182 ; save the RIOT DRB, the sound port LDA #$80 ; set the sound delay STA LAB_F3 ; save the sound delay BNE LAB_05A5 ; return to the main program loop, branch always ; the lamp was not lit LAB_05EB LDA #$05 ; set the gate lane sound STA LAB_30 ; save the gate lane sound BNE LAB_05A5 ; return to the main program loop, branch always ;************************************************************************************ ; ; switch $08, lower right side band ; switch $09, lower left side band LAB_05F1 STX LAB_F1 ; save the solenoid to fire number LDA #$09 ; set the solenoid delay, 9 * 8.3ms = 75ms STA LAB_F2 ; save the solenoid delay LDA #$AB ; set the sound STA LAB_0182 ; save the RIOT DRB, the sound port LDA #$20 ; set the sound delay BNE LAB_0608 ; go add 90 to the score and return to the main loop, ; branch always ;************************************************************************************ ; ; switch $16, right centre side band ; switch $17, left centre side band ; switch $18, upper left side band ; switch $19, top left side band ; switch $1A, top right side band LAB_0600 LDA LAB_0B5C-$16,X ; get the sound byte for the rubber STA LAB_0182 ; save the RIOT DRB, the sound port LDA #$78 ; set the sound delay LAB_0608 STA LAB_F3 ; save the sound delay LDA #$94 ; set 9 x 10^(5-4) = 90 JSR LAB_0A82 ; add a value to the score and check for awards JMP LAB_089A ; return to the main program loop ;************************************************************************************ ; ; switch $1B, playfield entry - continued LAB_0612 LDA #$0A ; set the sound STA LAB_0182 ; save the RIOT DRB, the sound port LDA #$0C ; set the sound delay BNE LAB_0608 ; go add 90 to the score and return to the main loop, ; branch always ;************************************************************************************ ; ; count the bonus with any multipliers LAB_061B JSR LAB_0BA9 ; get the bonus value and clear the bonus lamps BEQ LAB_0666 ; if zero just go check the shoot again lamp ; there is some bonus score DEX ; decrement the bonus score JSR LAB_0BC5 ; set the bonus lamps from X, returns X in the range $00 ; to $09 LDY #$01 ; set the increment to 1000 CLC ; clear the 3x flag LDA LAB_49 ; get lamp 15, 3x bonus BEQ LAB_062E ; if the lamp is out skip the 3x increment set INY ; set the increment to 2000 INY ; set the increment to 3000 SEC ; set the 3x flag LAB_062E LDA LAB_48 ; get lamp 19, 2x bonus BEQ LAB_0636 ; if the lamp is out skip the 2x increment set INY ; set the increment to 2000 or 4000 BCC LAB_0636 ; if the 3x increment is not set skip the 5000 set INY ; set the increment to 5000 LAB_0636 LDA LAB_0B9F-1,Y ; get the bonus multiplier sound on delay STA LAB_EC ; save the bonus multiplier sound on delay LDA LAB_0BA4-1,Y ; get the bonus multiplier sound off delay STA LAB_ED ; save the bonus multiplier sound off delay STY LAB_C5 ; save the bonus increment LAB_0642 LDA LAB_0B52-1,X ; get the bonus counting sound STA LAB_0182 ; save the RIOT DRB, the sound port LDA LAB_EC ; get the delay time JSR LAB_0BF4 ; save the delay time and wait until it is complete LDA #$12 ; set 1 x 10^(5-2) = 1000 JSR LAB_0A82 ; add a value to the score and check for awards LDA #$00 ; clear the sound STA LAB_0182 ; save the RIOT DRB, the sound port LDA LAB_ED ; get the delay time JSR LAB_0BF4 ; save the delay time and wait until it is complete DEC LAB_C5 ; decrement the bonus increment BNE LAB_0642 ; loop if more to do JSR LAB_0BF2 ; delay for 1167ms JMP LAB_089A ; return to the main program loop ; there is no bonus score LAB_0666 STA LAB_2F ; clear ?? LDA LAB_4A ; get lamp 12, shoot again BNE LAB_0683 ; if shoot again was lit go restart this player ; shoot again wasn't lit so advance to the next player LDA LAB_C4 ; get the current player number CMP LAB_0F ; compare it with the number of players BEQ LAB_0676 ; if it's the last player go see if it's the last ball INC LAB_17 ; increment the player number BCC LAB_0683 ; go sound off for the player number, branch always ; it was the last player so see if it's the last ball LAB_0676 LDA LAB_0E ; get the ball in play SEC ; set carry for subtract SBC LAB_BE ; subtract option 13, balls per game BEQ LAB_068C ; if zero go end the game ; not done yet, so increment the ball in play and reset to player 1 INC LAB_0E ; increment the ball in play LDA #$01 ; set player 1 STA LAB_17 ; save the player number LAB_0683 JSR LAB_0A65 ; sound off for the player number JSR LAB_0C33 ; reset the table for another player JMP LAB_0415 ; set solenoid 1, ball feed to fire and return to the ; main program loop ; it was the last ball so game over LAB_068C STA LAB_06 ; clear the game in play flag STA LAB_7A ; clear solenoid 11, playfield STA LAB_F7 ; clear the quater second counter STA LAB_0184 ; disable the tilt switch - PA7, negative edge SEC ; set the carry to flag game over ROL LAB_57 ; set lamp 13, game over LDA #$FF ; set the game over count, 255 quater seconds STA LAB_F5 ; save the game over count LAB_069C JSR LAB_0C04 ; set digit 0 dp for the current player LDX LAB_C4 ; get the current player number BNE LAB_06A6 ; if there is a current player continue JMP LAB_0737 ; else go check for a high score ; there is a current player LAB_06A6 JSR LAB_0B0A ; set the LAB_31 pointer to player LAB_17 LDY #$01 ; set the compare values count to the high score JSR LAB_0B30 ; compare the score with the high score LSR LAB_EE ; shift the result back into Cb BCC LAB_06C2 ; if the score is less than the high score skip the copy STX LAB_C7 ; save the current player as the high score player ; copy the score to the high score LDY #$05 ; set the digit count LAB_06B6 LDA (LAB_31),Y ; get a score digit STA (LAB_33),Y ; save a high score digit DEY ; decrement the digit count BPL LAB_06B6 ; loop if more to do ; increment the high score beaten count LDX #$04 ; set option 04, times high score beaten JSR LAB_0AC6 ; add 1 to option X ; compute the new average score for the last 10 games ; ; first subtract 1/10th of the average value from itself to leave 9/10ths LAB_06C2 LDY #$05 ; set the digit count/index SEC ; set carry for subtract LAB_06C5 LDA LAB_B6-1,Y ; get a next most significant digit JSR LAB_0AE8 ; convert a digit drive pattern to binary LAB_06CB STA LAB_EA ; save the next most significant digit LDA LAB_B6,Y ; get a digit JSR LAB_0AE8 ; convert a digit drive pattern to binary SED ; set decimal mode SBC LAB_EA ; subtract the next most significant digit, -1/10th STA LAB_B6,Y ; save a digit LDA #$00 ; clear A for the most significant difit DEY ; decrement the digit count/index BEQ LAB_06CB ; if it's the last digit go subtract the $00 BPL LAB_06C5 ; loop if more to do ; now add 1/10th of the score at (LAB_31) to the average score at LAB_B6 LDY #$04 ; set the digit count/index CLC ; clear carry for add LAB_06E3 JSR LAB_0AE6 ; get and convert a digit drive pattern from (LAB_31),Y STA LAB_EA ; save the converted digit LDA LAB_B6+1,Y ; get the less significant digit from the average score AND #$0F ; mask 0000 xxxx, clear any previous saved carry ADC LAB_EA ; add the converted digit STA LAB_B6+1,Y ; save the less significant digit to the average score LSR ; shift .. LSR ; .. the .. LSR ; .. carry .. LSR ; .. from b4 .. LSR ; .. to Cb DEY ; decrement the digit count/index BPL LAB_06E3 ; loop if more to do INY ; increment the index to digit 0 ADC LAB_B6,Y ; add the digit to the carry STA LAB_B6,Y ; save the digit CLD ; clear decimal mode ; now find the first non zero digit LAB_0702 LDA LAB_B6,Y ; get an average score digit BNE LAB_070C ; if not zero continue INY ; else increment the digit index, next less significant CPY #$06 ; compare the digit index with the max + 1 BNE LAB_0702 ; loop if more to do ; now blank any leading zeroes LAB_070C TYA ; copy the digit index BEQ LAB_0717 ; if zero skip blanking any (more) digits DEY ; else decrement the digit index LDA #$0F ; set all digit segments off STA LAB_B6,Y ; save the digit BNE LAB_070C ; go do another digit, branch always LAB_0717 LDA LAB_C1 ; get option 16, match option BEQ LAB_0735 ; if the match option is not set skip possibly awarding ; a free game LDY #$04 ; set the index to digit 4 LDA (LAB_31),Y ; get the score digit 4 EOR LAB_1F ; compare it with the match award random digit AND #$0F ; mask 0000 xxxx, the digit bits BNE LAB_0735 ; if no match skip giving the match award ; the player's score has won a match award JSR LAB_0B61 ; award a free ball or free game LDX LAB_C4 ; get the current player number LDA #$00 ; clear the player byte SEC ; set the bit for the player LAB_072D ROL ; shift the player bit in the byte DEX ; decrement the player number BNE LAB_072D ; loop if more to do ; now one bit in A, .... 4321, is set for the current player ORA LAB_C8 ; OR it with the player award flag byte STA LAB_C8 ; save the player award flag byte LAB_0735 DEC LAB_17 ; decrement the player number LAB_0737 LDY LAB_C7 ; get the high score player BEQ LAB_0763 ; if no player won the high score skip flashing the score JSR LAB_0B0C ; set the LAB_31 pointer to player Y LAB_073E LDY #$05 ; set the digit index LDA LAB_F7 ; get the quater second counter AND #$03 ; mask 0000 00xx, quater seconds BNE LAB_074F ; if not zero quater seconds go ?? ; else zero quater seconds, blank the digits LDA #$0F ; set all digit segments off LAB_0748 STA (LAB_31),Y ; save the digit DEY ; decrement the digit index BPL LAB_0748 ; loop if more to do BMI LAB_073E ; go check the quater second timer again, branch always ; it wasn't zero quater seconds LAB_074F CMP #$01 ; compare the quater seconds with $01 BNE LAB_0763 ; if not one quater second skip ?? ; else one quater second, copy the high score to the digits LAB_0753 LDA LAB_B0,Y ; option 09, high score to date AND #$0F ; mask 0000 xxxx, the digit bits CPY #$05 ; compare the digit index with 5 BNE LAB_075E ; if not 5 skip the dp set ORA #$10 ; else set the decimal point LAB_075E STA (LAB_31),Y ; save the digit DEY ; decrement the digit index BPL LAB_0753 ; loop if more to do ; Match award display here (wrk001 120419) LAB_0763 LDA LAB_C1 ; get option 16, match option BEQ LAB_079B ; if no match award skip displaying the awards ; display awards for players LDX #$00 ; set for player 1 LDA LAB_C8 ; get the player award flag byte PHA ; save it LAB_076C PLA ; restore the player award flag byte BEQ LAB_079B ; if all done skip the awards display LAB_076F LSR ; shift the player bit to Cb INX ; increment the player number BCC LAB_076F ; if not this player go try the next player ; this player has won an award PHA ; save the player award flag byte TXA ; copy the player .. TAY ; .. number to Y JSR LAB_0B0C ; set the LAB_31 pointer to player Y LDY #$04 ; set the digit index to digit four LDA LAB_F7 ; get the quater second counter AND #$03 ; mask 0000 00xx, quater seconds CMP #$02 ; compare the quater seconds with $02 BNE LAB_078C ; if it is not two quater seconds continue ; else blank digits 4 and five, the match digits LDA #$0F ; set all digit segments off STA (LAB_31),Y ; blank digit four INY ; increment the digit index to digit five STA (LAB_31),Y ; blank digit five BNE LAB_076C ; go see if any other players won an award, branch always LAB_078C CMP #$03 ; compare the quater seconds with $03 BNE LAB_076C ; if it is not three quater seconds go see if any other ; players won an award ; display the match digits LDA LAB_1F ; get the match award random digit STA (LAB_31),Y ; save digit four INY ; increment the digit index to digit five LDA #$10 ; set for "0." STA (LAB_31),Y ; save digit five BNE LAB_076C ; go see if any other players won an award, branch always ; there were no match awards LAB_079B LDX #$06 ; set the index to digit 5 LDA LAB_F7 ; get the quater second counter AND #$18 ; mask 000x x000, 24 quater seconds CLC ; clear Cb to flag show the high score BEQ LAB_07CD ; if zero quater seconds go show the high score CMP #$08 ; compare it with 8 quater seconds BEQ LAB_07E5 ; if 8 quater seconds go display the match award CMP #$10 ; compare it with 10 quater seconds BEQ LAB_07CD ; if 10 quater seconds go show the average score, the ; carry will be set to flag show the average score ; otherwise LAB_07AC LDA LAB_16 ; get the credits BEQ LAB_07BF ; if no credits skip the credits display ; display the credits LDA #$0F ; set all digit segments off STA LAB_25 ; save status digit 5 STA LAB_24 ; save status digit 4 STA LAB_23 ; save status digit 3 LDA #$1F ; set A for " ." STA LAB_22 ; save status digit 2, credits dp JSR LAB_0B84 ; display the credit in status digits 0/1 ; check the game over count and possibly enter attract mode LAB_07BF LDA LAB_F5 ; get the game over count BNE LAB_07CA ; if in not counted out return to the main program loop ; the game over count has expired so do attract mode LDA LAB_F4 ; get the delay to the next step BNE LAB_079B ; if not done go do this step display JMP LAB_0E26 ; else go do the lamp test (attract mode) LAB_07CA JMP LAB_089A ; return to the main program loop ; show the high score, Cb = 0, or the average score, Cb = 1 LAB_07CD LDA LAB_B0-1,X ; read option 09, high score to date BCC LAB_07D3 ; if carry clear go use the high score LDA LAB_B6-1,X ; read option 10, average score LAB_07D3 AND #$0F ; mask 0000 xxxx, clear the dp bit STA LAB_20-1,X ; save it to the status display DEX ; decrement the count/index BNE LAB_07CD ; loop if more to do ; now set the high score or average score LEDs TXA ; clear A ROL ; shift the carry into A TAX ; set X = $00 for high score, X = $01 for average score LDA LAB_20,X ; read status digit X ORA #$10 ; mask xxx1 xxxx, set the dp bit STA LAB_20,X ; save status digit X BNE LAB_07BF ; go return to attract mode or the main program loop, ; branch always ; display the match award LAB_07E5 LDA LAB_C1 ; get option 16, match option BEQ LAB_07AC ; if zero skip showing the match score, go do credits ; display the match award setting. to win the match award the players last two score ; digits must match the two digits displayed which will be "x0." where x is any of 0 ; to 9 LDA #$10 ; set for "0." STA LAB_25 ; save status digit 5, match dp LDX #$05 ; set the remaining digit count/index LDA LAB_1F ; get the match award random digit AND #$0F ; mask 0000 xxxx, the digit bits LAB_07F3 STA LAB_20-1,X ; save the digit LDA #$0F ; set all digit segments off DEX ; decrement the digit count/index BNE LAB_07F3 ; loop if more to do BEQ LAB_07BF ; go return to attract mode or the main program loop, ; branch always ; test the feature lane lamps and ?? LAB_07FC LDX #$07 ; set the lamp count/index LAB_07FE STX LAB_EB ; save the feature lane lamp number LDA LAB_40-1,X ; get the feature lane lamp BNE LAB_0807 ; if the lamp is on exit the loop DEX ; decrement the lamp count/index BNE LAB_07FE ; loop if more to do LAB_0807 LDX LAB_C4 ; get the current player number LDA LAB_26-1,X ; get the player feature lane value AND #$07 ; mask 0000 0xxx, the feature index CMP LAB_EB ; compare it with the feature lane lamp number BNE LAB_0825 ; if not there go increment the feature lane lamp index DEC LAB_2E ; decrement the feature lane animation step BEQ LAB_0846 ; if the animation is complete go ?? ; on each step the delay gets shorter until it reaches 8 * 8.3ms = 66ms LDA LAB_EF ; get the feature lane animation delay LSR LAB_EF ; / 2 LSR LAB_EF ; / 4 SBC LAB_EF ; subtract 1/4 to make it shorter CLC ; clear carry for add ADC #$02 ; + 2 so it never gets too short STA LAB_EF ; save the feature lane animation delay JSR LAB_0BDE ; increment the bonus value LAB_0825 LDX LAB_EB ; get the feature lane lamp index LSR LAB_40-1,X ; clear a feature lane lamp LDA #$01 ; set light lamp INX ; increment X to the next feature lamp CPX #$08 ; compare X with max + 1 BNE LAB_0831 ; if not there yet go use it TAX ; else reset to the first lamp LAB_0831 STA LAB_40-1,X ; light a feature lane lamp LDA LAB_0B54-1,X ; get the feature lane sound STA LAB_0182 ; save the RIOT DRB, the sound port LDA LAB_EF ; get the delay time JSR LAB_0BF4 ; save the delay time and wait until it is complete LDA #$33 ; set 3 x 10^(5-3) = 300 JSR LAB_0A82 ; add a value to the score and check for awards JMP LAB_089A ; return to the main program loop ; the feature lane animation is complete LAB_0846 TAY ; copy the feature index LDA LAB_26-1,X ; get the player feature lane value LDX LAB_0B4C-2,Y ; get the feature lamp index TAY ; copy the feature index LDA #$01 ; set light lamp STA LAB_00,X ; light the lamp CPY #$04 ; compare the feature index with open gate BNE LAB_0857 ; if not open gate skip the solenoid set STA LAB_79 ; save solenoid 10, gate LAB_0857 LDA #$C0 ; set the sound CPY #$07 ; compare the feature index with free ball BNE LAB_0862 ; if not free ball skip the award JSR LAB_0B61 ; award a free ball or free game BEQ LAB_0868 ; if no game in play skip the sound set LAB_0862 STA LAB_0182 ; save the RIOT DRB, the sound port JSR LAB_0BEA ; delay for 500ms ; now kick the ball out of the lane and continue the game LAB_0868 STA LAB_47 ; clear lamp 38, feature lane kicker LDX #$03 ; set solenoid 3, feature lane JMP LAB_0417 ; save the solenoid to fire and continue ;************************************************************************************ ; ; reset enters here LAB_086F LDA LAB_0100 ; get the quater second timer LDX #$7F ; set the initial stack pointer TXS ; save the initial stack pointer LDY #$00 ; clear Y STY LAB_0183 ; save RIOT DDRB, 0 = input EOR LAB_0100 ; EOR with the previous quater second timer value BEQ LAB_086F ; if it hasn't changed go wait some more ; this must be part of the "special technique" for resetting the first five set position ; values. somehow $5A must be put onto the RIOT port B and this will cause all of page ; zero to be reset ; ; this can probably be done with four smallish, 220 to 330 ohm, resistors being used to ; pull down PB7, PB6, PB3 and PB0 LDA LAB_0182 ; read the RIOT DRB, the sound port CMP #$5A ; compare it with the "special technique" key BNE LAB_0890 ; if not a match go do the standard RAM to latches copy ; the "special technique" code is just a blanket clearing of page zero ; clear page zero LDX #$00 ; set the count/index LAB_0888 STY LAB_00,X ; clear a page zero byte DEX ; decrement the count/index BNE LAB_0888 ; loop if more to do JSR LAB_0C1D ; set all the switches, wait for them to open ; X is either $00 or $7F here. if the "special technique" code was executed then X will ; be $00 and only that address will be copied before it is decremented to $FF and the ; loop exits ; read the ghost registers into the real latches LAB_0890 LDA LAB_00,X ; read the RAM STA LAB_00,X ; save it to the latches DEX ; decrement the index BPL LAB_0890 ; loop if more to do LDA LAB_0185 ; read and clear the RIOT interrupt flag ;************************************************************************************ ; ; resetting all done now time for the main program loop LAB_089A LDX #$FF ; set all outputs STX LAB_0183 ; save RIOT DDRB, 0 = input CLD ; clear decimal mode CLI ; disable interrupts LDA #$3F ; set IIOO OOOO STA LAB_0181 ; save RIOT DDRA, 0 = input ; kick the dog LDA LAB_0180 ; read the RIOT DRA ORA #$20 ; mask xx1x xxxx, set the watchdog bit STA LAB_0180 ; save the RIOT DRA AND #$DF ; mask xx0x xxxx, clear the watchdog bit STA LAB_0180 ; save the RIOT DRA ; "Secondly, the machine tends to 'get lost' and freaks out. I really don't know ; how better to explain it. I am thinking it might have something to do with the ; rotational tilt switch but I can not be certain. Unfortunately, trying to recall ; exactly what happened when it 'freaks out' hasn't been possible. Right not the ; machine is 'locked up' and even after a power cycle the scores are all mixed up ; with numbers, it acts as if it's in the middle of a game and there's lots of ; sounds being made." ; ; test the test and set switches LDY #$01 ; set the index to the set switch LAB_08B5 LDA LAB_E7,Y ; get the switch state BPL LAB_08BD ; if the switch is not active go try the next one JMP LAB_0D78 ; go handle an active test or set switch LAB_08BD DEY ; decrement the switch index BPL LAB_08B5 ; loop if more to do ; neither the test or set switches were active LSR LAB_C9 ; get and clear the endgame flag BCC LAB_08C8 ; if not set skip clearing the game in play flag LDA #$00 ; clear A STA LAB_06 ; clear the game in play flag ; check the credits and energise the crem solenoid if they are less than 15. if the crem ; solenoid is not energised then coins are sinply returned, so the machine has to be on ; and have less than 15 credits for coins to be accepted LAB_08C8 LDA LAB_16 ; get the credits CMP #$0F ; compare the credits with 15, set carry if >= ROL ; set b0 = credits >= 15 EOR #$01 ; toggle the bit STA LAB_7B ; save solenoid 12, crem LDA LAB_E5 ; get switch $1C, coin set BNE LAB_0905 ; if the coin set switch is not active just continue ; the coin switch is active LDA LAB_0CBD ; get the coin set input low reset state STA LAB_E5 ; save switch $1C, coin set INC LAB_C2 ; increment the current coin count LDX #$01 ; set option 1, coin position JSR LAB_0AC6 ; add 1 to option X LDA LAB_C2 ; get the current coin count CMP LAB_BC ; compare it with option 11, game price BCC LAB_0905 ; if less just continue ; the price of a game has been entered INC LAB_C3 ; increment the bonus credits count STX LAB_C2 ; clear the current coin count LAB_08EB JSR LAB_0B7C ; increment the credits if < 15 LDA #$55 ; set the sound STA LAB_0182 ; save the RIOT DRB, the sound port JSR LAB_0BEE ; delay for 250ms JSR LAB_0BFB ; clear the sound and wait for 50ms LDA LAB_BD ; get option 12, discount bonus credit BEQ LAB_0905 ; if zero just continue ; now check for and award any bonus credits EOR LAB_C3 ; compare it with the bonus credits count BNE LAB_0905 ; if not the same just continue STA LAB_C3 ; else clear the bonus credits count BEQ LAB_08EB ; go award a credit, branch always ; done the credits now do ?? LAB_0905 LDA LAB_17 ; get the player number STA LAB_C4 ; save the current player number LDX LAB_C6 ; get the special award tune index BNE LAB_091C ; if not zero go play a tune note LDA LAB_06 ; get the game in play flag BNE LAB_0936 ; if in play go ?? JSR LAB_0A31 ; test the demand (start game) switch BCS LAB_0961 ; if a game is started or player added go start a new game JMP LAB_069C ; else go continue the game over ; END OF MAIN PROGRAM LOOP (wrk001 120419) LAB_0919 JMP LAB_07FC ; go test the feature lane lamps and ?? ; play a special award tune note LAB_091C LDA LAB_0D12-1,X ; get the special award tune note STA LAB_0182 ; save the RIOT DRB, the sound port DEC LAB_C6 ; decrement the special award tune index BEQ LAB_0930 ; if it is the last note go set a $3C delay LDA #$10 ; set the delay time, 16 * 8.3ms = 133ms JSR LAB_0BF4 ; save the delay time and wait until it is complete JSR LAB_0BFB ; clear the sound and wait for 50ms BEQ LAB_0933 ; skip setting the delay, branch always LAB_0930 JSR LAB_0BEA ; delay for 500ms LAB_0933 JMP LAB_089A ; return to the main program loop ; GAME PLAY PROCESS (wrk001 120419) LAB_0936 LDA LAB_2E ; get the feature lane animation step ?? BNE LAB_0919 ; if animation active go ?? LDA LAB_30 ; get the gate lane sound BEQ LAB_094B ; if zero skip making the gate lane sound ; make the gate lane sound STA LAB_0182 ; save the RIOT DRB, the sound port LDA #$30 ; set the delay time, 48 * 8.3ms = 400ms JSR LAB_0BF4 ; save the delay time and wait until it is complete JSR LAB_0BFB ; clear the sound and wait for 50ms DEC LAB_30 ; decrement the gate lane sound LAB_094B LDA LAB_2F ;. BEQ LAB_0952 ;skip bonus count (wrk001 120419) JMP LAB_061B ; go count the bonus with any multipliers LAB_0952 JSR LAB_0A31 ; test the demand (start game) switch BCC LAB_09A2 ; if no game started or player added go display the status ; a game was started or a player was added LDA #$04 ; set 4 SEC ; set carry for subtract SBC LAB_0F ; subtract the number of players TAX ; copy 4-player to X INC LAB_0F ; increment the number of players BCS LAB_0977 ;., branch always ; start a new game LAB_0961 LDA LAB_B6+5 ; get the least significant digit of the average score STA LAB_1F ; save it as the match award random digit JSR LAB_0C28 ; clear all the playfield switches, wait for them to close JSR LAB_0C33 ; reset the table for another player STY LAB_C7 ; save the high score player STY LAB_C8 ; save the player award flag byte STA LAB_0F ; save the number of players STA LAB_17 ; save the player number STA LAB_06 ; save the game in play flag LDX #$04 ; set the player count LAB_0977 LDA #$00 ; clear A STA LAB_31 ; clear the digits ponter low byte STA LAB_31+1 ; clear the digits ponter high byte LAB_097D LDA #$00 ; set for "0" LDY #$05 ; set the index to digit 5 CPX #$01 ;. BNE LAB_0987 ;. LDA #$10 ; set for "0." LAB_0987 STA (LAB_31),Y ; save the digit DEY ; decrement the index to digit 4 CPX #$01 ;. BEQ LAB_0990 ;. LAB_098E LDA #$0F ; set all digit segments off LAB_0990 STA (LAB_31),Y ; save the digit DEY ; decrement the digit index BPL LAB_098E ; loop if more to do LDA LAB_31 ; get the digits pointer low byte CLC ; clear carry for add ADC #$08 ; add the offset to the next player digits STA LAB_31 ; save the digits pointer low byte DEX ; decrement the player count BNE LAB_097D ; loop if more to do JSR LAB_0A68 ; sound off for the number of players ; display the game status LAB_09A2 JSR LAB_0C04 ; set digit 0 dp for the current player LDA LAB_0E ; get the ball in play STA LAB_25 ; save status digit 5 LDA #$1F ; set A for " ." STA LAB_24 ; save status digit 4, ball dp STA LAB_22 ; save status digit 2, credits dp LDA LAB_0F ; get the number of players ORA #$10 ; set the dp bit STA LAB_23 ; save status digit 3, player dp JSR LAB_0B84 ; display the credit in status digits 0/1 LDA LAB_56 ; get lamp 14, tilt AND #$06 ; mask 0000 0xx0, the tilt count BEQ LAB_09E4 ; if the count was 0 go possibly clear the tilt lamp ; the tilt count is 2, 4 or 6 AND #$04 ; mask 0000 0x00, only set if 4 or 6 BEQ LAB_09C9 ; if the count was 2 skip ?? LSR LAB_56 ; clear lamp 14, tilt LDX #$05 ; set option 05, number of times tilted JSR LAB_0AC6 ; add 1 to option X LAB_09C9 LSR LAB_7A ; clear solenoid 11, playfield ; check the trap switches and fire the corresponding solenoid if needed LDX #$03 ; set the input index LAB_09CD LDA LAB_CA,X ; get the input state BNE LAB_09DA ; if the input is not active go do the next input LDA LAB_0CA2,X ; get the input low reset state STA LAB_CA,X ; save the input state INX ; convert the input index to the solenoid number JMP LAB_0417 ; save the solenoid to fire and continue LAB_09DA DEX ; decrement the input index BNE LAB_09CD ; loop if more to do ; test tilt LDA LAB_F6 ; get the tilt lamp count BNE LAB_09FA ; if tilt return to the main program loop ; ?? INX ; make X = $01, playfield exit switch only BPL LAB_09F3 ; go look for switch activity, branch always ; check the rotate switch and possibly clear the tilt lamp LAB_09E4 LDY LAB_E9 ; get switch $20, rotate BPL LAB_09EF ; if open just go clear the tilt lamp ; the rotate switch is closed LDA #$03 ;. LDY LAB_07 ;TILT FLAG (WRK001 120419) BNE LAB_09EF ;. LSR ;. LAB_09EF STA LAB_56 ; save lamp 14, tilt ; look for playfield switch activity LDX #$1B ; set the switch index to the playfield entry switch LAB_09F3 LDA LAB_CA-1,X ; get the switch state BEQ LAB_09FD ; if the switch is active go handle it DEX ; decrement the switch index BNE LAB_09F3 ; loop if more to do ; no switches were active so just .. LAB_09FA JMP LAB_089A ; return to the main program loop ; an active switch was found LAB_09FD LDA LAB_0CA2-1,X ; get the switch low reset state STA LAB_CA-1,X ; save the switch state CPX #$01 ; compare the switch index with playfield exit BEQ LAB_0A17 ; if it is the playfield exit go ?? LDA LAB_0E ; get the ball in play STA LAB_06 ; save the game in play flag LDY LAB_07 ; Tilt Flag (WRK001 120419) BNE LAB_0A12 ;. LSR LAB_4A ; clear lamp 12, shoot again INC LAB_07 ;. LAB_0A12 STA LAB_0186 ; enable the tilt switch - PA7, negative edge LSR LAB_7C ; clear solenoid 13, ?? LAB_0A17 LDY #$00 ; clear Y CPX #$0A ; compare the switch index with right gate lane BEQ LAB_0A24 ; if it is the right gate lane skip moving the gate ; it's not the gate lane switch LDA LAB_6B ; get lamp 29, open gate LSR ; shift the lamp bit into Cb BCS LAB_0A24 ; if the lamp is lit skip clearing the gate solenoid STY LAB_79 ; clear solenoid 10, gate LAB_0A24 LDA LAB_0CF7-1,X ; get the input vector low byte STA LAB_31 ; save the vector low byte LDA LAB_0CDC-1,X ; get the input vector high byte STA LAB_31+1 ; save the vector high byte JMP (LAB_31) ; go do the code ;************************************************************************************ ; ; test the demand (start game) switch LAB_0A31 LDA LAB_E6 ; get switch $1D, demand (start game) BNE LAB_0A63 ; if the demand switch is not active just exit ; the demand (start game) switch is active DEC LAB_E6 ; decrement switch $1D, demand, make it $FF LDA LAB_06 ; get the game in play flag BEQ LAB_0A45 ; if no game in play go start a game ; else there is a game in play so make sure it's still on the first ball CMP #$02 ; compare the ball with ball 2 BCS LAB_0A63 ; if >= ball 2 just exit ; still on the first ball so a new player may be added LDX LAB_0F ; get the number of players CPX #$04 ; compare it with 4 BCS LAB_0A63 ; if >= 4 just exit ; a game can be started or a player added to a current game LAB_0A45 LDA LAB_16 ; get the credits BEQ LAB_0A63 ; if no credits just exit DEC LAB_16 ; decrement the credits LDA LAB_0E ; get the ball in play CMP #$02 ; compare it with ball 2 LDA #$01 ; set ball 1 STA LAB_0E ; save the ball in play BCC LAB_0A58 ; if < ball 2 ?? skip incrementing the number of players INX ; increment the number of players STX LAB_17 ; save the player number LAB_0A58 LDA #$00 ; clear A STA LAB_C3 ; clear the bonus credits count LDX #$02 ; set option 02, games played JSR LAB_0AC6 ; add 1 to option X SEC ; flag a game is started or player added RTS LAB_0A63 CLC ; flag a game is not started RTS ;************************************************************************************ ; ; sound off for the player number LAB_0A65 LDA LAB_17 ; get the player number .byte $2C ; makes the next line BIT $xxxx ;************************************************************************************ ; ; sound off for the number of players LAB_0A68 LDA LAB_0F ; get the number of players TAX ; save the count TAY ; save the sound index LAB_0A6C STY LAB_0182 ; save the RIOT DRB, the sound port LDA LAB_0B9F-1,Y ; get the delay time JSR LAB_0BF4 ; save the delay time and wait until it is complete STA LAB_0182 ; save the RIOT DRB, the sound port LDA LAB_0BA4-1,Y ; get the delay time JSR LAB_0BF4 ; save the delay time and wait until it is complete DEX ; decrement the count BNE LAB_0A6C ; loop if more to do RTS ;************************************************************************************ ; ; add a value to the score and check for awards ; ; A contains the value to add in the high nibble and the multiplier in the low nibble LAB_0A82 PHA ; save the value and multiplier byte LSR ; shift the high .. LSR ; .. nibble to .. LSR ; .. the low .. LSR ; .. nibble STA LAB_F0 ; save the value to add JSR LAB_0B0A ; set the LAB_31 pointer to player LAB_17 JSR LAB_0B2E ; compare the score with the high score and award limits PLA ; restore the value and multiplier byte AND #$0F ; mask 0000 xxxx, the multiplier TAY ; copy it to the digit index LAB_0A93 JSR LAB_0AE6 ; get and convert a digit drive pattern from (LAB_31),Y CLC ; clear carry for add ADC LAB_F0 ; add the add value CMP #$0A ; compare the result with 10 BCC LAB_0A9F ; if < 10 continue SBC #$0A ; else subtract 10 LAB_0A9F STA (LAB_31),Y ; save the new digit BCC LAB_0AAC ; if no carry continue ; else there is a carry to the next digit DEY ; decrement the digit index BMI LAB_0AAC ; if rolled out of the value just continue LDA #$01 ; else set the add value to 1 STA LAB_F0 ; save the add value BNE LAB_0A93 ; go add the value, branch always LAB_0AAC CPY #$03 ; compare the digit index with x00s BCS LAB_0AB7 ; if not x00s or less skip ?? ; else that add rolled past the x000 mark so ... ; ; "First problem is that when in multiplayer mode and either the 2nd or 3rd player ; is in process, anytime 1,000 points are scored (either all at once or cumulative) ; something odd happens. For player 2, the Tilt sound is activated but the game ; doesn't tilt and continues to play. For player 3, the 'Credit Won' sound is ; activated AND a credit is awarded (if it hasn't exceeded the credit limit yet) ; and continues to play." ;## BCC LAB_0AB7 ; this patches past the bug, comment out the next line ## LDY #$03 ; ?? ## I have no idea what was supposed to go on here. LDY #$E6 ; ?? ## I guess it should make some noise or other but ASL ; ?? ## the code as is just craps over the top end of STA (LAB_31),Y ; ?? ## page zero $E6/7/8, $EE/F/F0, $F6/7/8, $FE/F/0100 ; the value written is one of $02,$04,$06,$08,$0A,$0C,$0E,$10 ; ; suggested correct code ;## LDY #$03 ; set the index to the x00s digit ;## JSR LAB_0AE6 ; get and convert a digit drive pattern from (LAB_31),Y ;## STA (LAB_31),Y ; save the digit drive pattern back to the digit LAB_0AB7 LDA LAB_EE ; get the high score and award limits result PHA ; save it JSR LAB_0B2E ; compare the score with the high score and award limits PLA ; restore the old high score and award limits result EOR LAB_EE ; compare it with the previous score and award result BEQ LAB_0AC5 ; if no change just exit JSR LAB_0B61 ; else award a free ball or free game LAB_0AC5 RTS ;************************************************************************************ ; ; add 1 to option X LAB_0AC6 JSR LAB_0B1E ; set the LAB_33 pointer to option X LDY #$05 ; set digit 5 LAB_0ACB LDA #$01 ; set the increment to 1 ;************************************************************************************ ; ; add A to (LAB_33) digit Y LAB_0ACD CLC ; clear carry for add STA LAB_F0 ; save the add value LDA (LAB_33),Y ; get the score digit JSR LAB_0AE8 ; convert a digit drive pattern to binary ADC LAB_F0 ; add the add value CMP #$0A ; compare the result with 10 BCC LAB_0ADD ; if less than 10 continue SBC #$0A ; else subtract 10 LAB_0ADD STA (LAB_33),Y ; save the score digit BCC LAB_0B1D ; if no carry just exit ; there is a carry to the next digit DEY ; decrement the index to the next most significant digit BMI LAB_0B1D ; if the digit index rolled over just exit BCS LAB_0ACB ; go add 1 to the next most significant digit, branch ; always ;************************************************************************************ ; ; get and convert a digit drive pattern from (LAB_31),Y LAB_0AE6 LDA (LAB_31),Y ; get a digit drive pattern ;************************************************************************************ ; ; convert a digit drive pattern to binary ; ; digit drive patterns are $00 to $09 but $0F is also used for a blanked leading zero ; so this is converted to $00. patterns also have b4 set if the decimal point is lit ; so this is masked LAB_0AE8 PHP ; save the status byte AND #$0F ; mask 0000 xxxx, clear the dp bit CMP #$0F ; compare it with the all segments off pattern BNE LAB_0AF1 ; if not all segments off just return it LDA #$00 ; else return zero LAB_0AF1 PLP ; restore the status byte RTS ;************************************************************************************ ; ; compare the scores at (LAB_31) and (LAB_33) ; ; the compare done is (LAB_31) - (LAB_33) and the result returned is the carry bit ; as for a single byte compare ; ; Cb = 1 if (LAB_31) > (LAB_33) ; Cb = 1 if (LAB_31) = (LAB_33) ; Cb = 0 if (LAB_31) < (LAB_33) LAB_0AF3 LDY #$00 ; clear the index/digit count, start with the most ; significant digit LAB_0AF5 LDA (LAB_33),Y ; get a (LAB_33) digit pattern JSR LAB_0AE8 ; convert a digit drive pattern to binary STA LAB_EB ; save it to the temporaty store JSR LAB_0AE6 ; get and convert a digit drive pattern from (LAB_31),Y CMP LAB_EB ; compare it with the (LAB_33) digit BEQ LAB_0B04 ; if equal go do the next digit ; else return the result RTS LAB_0B04 INY ; increment the index/digit count CPY #$05 ; compare it with the maximum + 1 BCC LAB_0AF5 ; loop if more to do RTS ;************************************************************************************ ; ; set the LAB_31 pointer to player LAB_17 LAB_0B0A LDY LAB_17 ; get the player number ;************************************************************************************ ; ; set the LAB_31 pointer to player Y ; ; LAB_00 is score 4 ; LAB_08 is score 3 ; LAB_10 is score 2 ; LAB_18 is score 1 ; ; this could be better done with a lookup table ## LAB_0B0C LDA #$00 ; clear A STA LAB_31 ; clear the score pointer low byte STA LAB_31+1 ; clear the score pointer high byte LAB_0B12 CPY #$04 ; compare with max + 1 BCS LAB_0B1D ; exit if done ADC #$08 ; add the offset to the next player digits STA LAB_31 ; save the score pointer low byte INY ; increment the player number BNE LAB_0B12 ; go see if we're done, branch always LAB_0B1D RTS ;************************************************************************************ ; ; set the LAB_33 pointer to option X LAB_0B1E LDA #$00 ; clear A STA LAB_33+1 ; clear the option X pointer high byte LDA #= 15 skip the increment INC LAB_16 ; else increment the credits ;************************************************************************************ ; ; display the credit in status digits 0/1 LAB_0B84 LDA LAB_16 ; get the credits JSR LAB_0B93 ; return A MOD 10 in A and A DIV 10 in AX STA LAB_21 ; save status digit 1 TXA ; copy the 10s count BNE LAB_0B90 ; if it is not zero go use it LDX #$0F ; else clear the digit LAB_0B90 STX LAB_20 ; save status digit 0 RTS ;************************************************************************************ ; ; return A MOD 10 in A and A DIV 10 in AX LAB_0B93 LDX #$00 ; clear the 10s count LAB_0B95 CMP #$0A ; compare A with 10 BCC LAB_0B9E ; if less return the count SBC #$0A ; - 10 INX ; increment the 10s count BPL LAB_0B95 ; go try again, branch always LAB_0B9E RTS ;************************************************************************************ ; ; bonus multiplier sound delays ; sound on delays LAB_0B9F .byte $16 ; 1000, 22 * 8.3ms = 183ms .byte $13 ; 2000, 19 * 8.3ms = 158ms .byte $11 ; 3000, 17 * 8.3ms = 141ms .byte $10 ; 4000, 16 * 8.3ms = 133ms .byte $0F ; 5000, 15 * 8.3ms = 125ms ; sound off delays LAB_0BA4 .byte $09 ; 1000, 9 * 8.3ms = 75ms .byte $07 ; 2000, 7 * 8.3ms = 58ms .byte $06 ; 3000, 6 * 8.3ms = 50ms .byte $05 ; 4000, 5 * 8.3ms = 42ms .byte $04 ; 5000, 4 * 8.3ms = 33ms ;************************************************************************************ ; ; get the bonus value and clear the bonus lamps LAB_0BA9 LDX #$0B ; set the thousands lamp index to the 20 thousand lamp LDA #$00 ; clear A STA LAB_EA ; clear the temp total (wrk001 120419) LAB_0BAF LSR LAB_4B-1,X ; clear and get the x000x lamp BCC LAB_0BBF ; if not lit go try the next lamp LDA #$14 ; set 20,000 CPX #$0B ; compare the index with the 20 thousand lamp BEQ LAB_0BBA ; if it is the 20 thousand lamp go use it TXA ; else use X thousand LAB_0BBA CLC ; clear carry for add ADC LAB_EA ; add the total to the value STA LAB_EA ; save the new total LAB_0BBF DEX ; decrement the thousands lamp index BNE LAB_0BAF ; loop if more to do LDX LAB_EA ; return the bonus value RTS ;************************************************************************************ ; ; set the bonus lamps from X, returns X in the range $00 to $09 LAB_0BC5 TXA ; copy the bonus value CMP #$14 ; compare the bonus value with 20,000 BCC LAB_0BCE ; if < 20,000 continue SBC #$14 ; else subtract 20,000 and .. ROL LAB_55 ; .. set lamp 11, 20 thousand LAB_0BCE CMP #$0A ; compare the bonus value with 10,000 BCC LAB_0BD6 ; if < 10,000 continue SBC #$0A ; else subtract 10,000 and .. ROL LAB_54 ; .. set lamp 10, 10 thousand LAB_0BD6 CMP #$00 ; compare it with $00 BEQ LAB_0BDD ; if zero just exit TAX ; copy the remaining x000s to X ROL LAB_4B-1,X ; set the x thousand lamp LAB_0BDD RTS ;************************************************************************************ ; ; increment the bonus value LAB_0BDE JSR LAB_0BA9 ; get the bonus value and clear the bonus lamps CPX #$27 ; compare the bonus with 39,000 BEQ LAB_0BE6 ; if at 39,000 don't increment the bonus INX ; else increment the bonus LAB_0BE6 JSR LAB_0BC5 ; set the bonus lamps from X RTS ;************************************************************************************ ; ; delay for 500ms LAB_0BEA LDA #$3C ; set the delay time, 60 * 8.3ms BNE LAB_0BF4 ; save the delay time and wait until it is complete, ; branch always ;************************************************************************************ ; ; delay for 250ms LAB_0BEE LDA #$1E ; set the delay time, 30 * 8.3ms BNE LAB_0BF4 ; save the delay time and wait until it is complete, ; branch always ;************************************************************************************ ; ; delay for 1167ms LAB_0BF2 LDA #$8C ; set the delay time, 140 * 8.3ms ;************************************************************************************ ; ; save the delay time and wait until it is complete LAB_0BF4 STA LAB_F3 ; save the sound delay time LAB_0BF6 LDA LAB_F3 ; get the delay time BNE LAB_0BF6 ; loop if it's not done RTS ;************************************************************************************ ; ; clear the sound and wait for 50ms LAB_0BFB LDA #$00 ; clear the sound STA LAB_0182 ; save the RIOT DRB, the sound port LDA #$06 ; set the delay time, 6 * 8.3ms BNE LAB_0BF4 ; save the delay time and wait until it is complete, ; branch always ;************************************************************************************ ; ; set digit 0 dp for the current player LAB_0C04 LDY #$04 ; set the player count LDX #$00 ; set the index to player 4 LAB_0C08 LDA LAB_00,X ; get digit 0 AND #$0F ; mask 0000 xxxx, clear the non digit bits CPY LAB_C4 ; compare it with the current player number BNE LAB_0C12 ; if not this player skip the dp set ORA #$10 ; mask xxx1 xxxx, set the dp bit LAB_0C12 STA LAB_00,X ; save digit 0 CLC ; clear carry for add TXA ; copy the digit index ADC #$08 ; add the offset to the next player digits TAX ; copy it back to the digit index DEY ; decrement the player count BNE LAB_0C08 ; loop if more to do RTS ;************************************************************************************ ; ; set all the switches, wait for them to open LAB_0C1D LDX #$1D ; set the switch index LAB_0C1F LDA LAB_0CA2-1,X ; get the switch low reset state STA LAB_CA-1,X ; save the switch state DEX ; decrement the index BNE LAB_0C1F ; loop if more to do RTS ;************************************************************************************ ; ; clear all the playfield switches, wait for them to close LAB_0C28 LDX #$1B ; set the switch index to playfield entry ;************************************************************************************ ; ; clear X switches, wait for them to close LAB_0C2A LDA LAB_0CBF-1,X ; get the switch high reset state STA LAB_CA-1,X ; save the switch state DEX ; decrement the switch index BNE LAB_0C2A ; loop if more to do RTS ;************************************************************************************ ; ; reset the table for another player ; I think this is a reset per ball regardless if new game or new player (WRK001 120419) LAB_0C33 LDY #$00 ; clear Y LSR LAB_59 ; get and clear lamp 26, refeed lane ROL ; shift it into A LSR LAB_5A ; get and clear lamp 27, special mid lane ROL ; shift it into A LSR LAB_5B ; get and clear lamp 28, special right lane ROL ; shift it into A LSR LAB_6B ; get and clear lamp 29, open gate ROL ; shift it into A LSR LAB_4A ; get and clear lamp 12, shoot again ; clear all the lamps LDX #$2B ; set the lamp count/index LAB_0C45 STY LAB_40-1,X ; clear a lamp DEX ; decrement the lamp count/index BNE LAB_0C45 ; loop if more to do STY LAB_79 ; clear solenoid 10, gate LDX LAB_06 ; get the game in play flag BEQ LAB_0C5A ; if no game in play go start a game ROL LAB_4A ; restore lamp 12, shoot again LDX LAB_C4 ; get the current player number STA LAB_2A-1,X ; save the player special and gate lamps LDX LAB_BF ; get option 14, feature lane options BNE LAB_0C68 ; if the option is set go restore the feature lane options ; clear all the player lamps, gate solenoid and feature lane level LAB_0C5A LDX #$04 ; set the player count/index LDA #$01 ; set the player feature lane level LAB_0C5E STY LAB_2A-1,X ; clear the player special and gate lamps STA LAB_26-1,X ; save the player feature lane value DEX ; decrement the player count/index BNE LAB_0C5E ; loop if more to do INX ; set player 1 BNE LAB_0C7A ; go start a game, branch always ; set the player lamps and gate and continue the game LAB_0C68 LDX LAB_17 ; get the player number LDA LAB_2A-1,X ; get the player special and gate lamps STA LAB_79 ; save solenoid 10, gate LSR ; shift the next bit to b0 ROL LAB_6B ; save lamp 29, open gate LSR ; shift the next bit to b0 ROL LAB_5B ; save lamp 28, special right lane LSR ; shift the next bit to b0 ROL LAB_5A ; save lamp 27, special mid lane LSR ; shift the next bit to b0 ROL LAB_59 ; save lamp 26, refeed lane ; start or continue a game LAB_0C7A LDA LAB_26-1,X ; get the player feature lane value AND #$07 ; mask 0000 0xxx, feature lane lamp TAX ; copy it to the index LDA #$01 ; set lamp/solenoid on STA LAB_40-1,X ; light the feature lane lamp STA LAB_7A ; save solenoid 11, playfield ; reset the targets and rollovers STA LAB_6A ; save lamp 16, centre trap right target STA LAB_69 ; save lamp 17, centre trap mid target STA LAB_68 ; save lamp 18, centre trap left target STA LAB_60 ; save lamp 20, top right rollover STA LAB_61 ; save lamp 21, top left rollover ;************************************************************************************ ; ; sequence the thumper lamps upper left, upper right, right LAB_0C8F LDX #$02 ; set the thumper index/count DEC LAB_1E ; decrement the lit thumper lamp BPL LAB_0C97 ; if not rolled over go use it STX LAB_1E ; else reset to the upper left thumper LAB_0C97 CPX LAB_1E ; compare this index with the lit thumper BEQ LAB_0C9C ; if it is lit go set it CLC ; else clear the carry and extinguish the lamp LAB_0C9C ROL LAB_62,X ; save the thumper lamp DEX ; decrement the thumper index/count BPL LAB_0C97 ; loop if more to do RTS ;************************************************************************************ ; ; input low reset state. an input must stay open for this number - $7F * 4.16ms before ; it is considered to have opened LAB_0CA2 .byte $81 ; switch $01, playfield exit .byte $81 ; switch $02, refeed lane .byte $8F ; switch $03, feature lane .byte $8F ; switch $04, top right outhole kicker .byte $8F ; switch $05, right thumper .byte $8F ; switch $06, upper right thumper .byte $8F ; switch $07, upper left thumper .byte $8F ; switch $08, lower right side band .byte $8F ; switch $09, lower left side band .byte $8F ; switch $0A, right gate lane .byte $8F ; switch $0B, top right rollover .byte $8F ; switch $0C, top left rollover .byte $81 ; switch $0D, centre trap left target .byte $81 ; switch $0E, centre trap mid target .byte $81 ; switch $0F, centre trap right target .byte $8F ; switch $10, light spinner .byte $82 ; switch $11, spinner .byte $8F ; switch $12, spinner lane top exit .byte $8F ; switch $13, open gate target .byte $8F ; switch $14, special mid lane .byte $8F ; switch $15, special right lane .byte $8F ; switch $16, right centre side band .byte $8F ; switch $17, left centre side band .byte $8F ; switch $18, upper left side band .byte $8F ; switch $19, top left side band .byte $8F ; switch $1A, top right side band .byte $8F ; switch $1B, playfield entry LAB_0CBD .byte $8F ; switch $1C, coin set .byte $C0 ; switch $1D, test ; input high reset state. an input must stay closed for this number of counts * 4.16ms ; before it is flagged as closed LAB_0CBF .byte $7F ; switch $01, playfield exit .byte $7F ; switch $02, refeed lane .byte $3F ; switch $03, feature lane .byte $3F ; switch $04, top right outhole kicker .byte $01 ; switch $05, right thumper .byte $01 ; switch $06, upper right thumper .byte $01 ; switch $07, upper left thumper .byte $01 ; switch $08, lower right side band .byte $01 ; switch $09, lower left side band .byte $01 ; switch $0A, right gate lane .byte $04 ; switch $0B, top right rollover .byte $04 ; switch $0C, top left rollover .byte $01 ; switch $0D, centre trap left target .byte $01 ; switch $0E, centre trap mid target .byte $01 ; switch $0F, centre trap right target .byte $01 ; switch $10, light spinner .byte $02 ; switch $11, spinner .byte $01 ; switch $12, spinner lane top exit .byte $01 ; switch $13, open gate target .byte $02 ; switch $14, special mid lane .byte $02 ; switch $15, special right lane .byte $01 ; switch $16, right centre side band .byte $01 ; switch $17, left centre side band .byte $01 ; switch $18, upper left side band .byte $01 ; switch $19, top left side band .byte $01 ; switch $1A, top right side band .byte $01 ; switch $1B, playfield entry .byte $03 ; switch $1C, coin set .byte $08 ; switch $1D, test ;************************************************************************************ ; ; input vectors high bytes LAB_0CDC .byte >LAB_0FE6 ; switch $01, playfield exit .byte >LAB_0420 ; switch $02, refeed lane .byte >LAB_0439 ; switch $03, feature lane .byte >LAB_0456 ; switch $04, top right outhole kicker .byte >LAB_048A ; switch $05, right thumper .byte >LAB_048A ; switch $06, upper right thumper .byte >LAB_048A ; switch $07, upper left thumper .byte >LAB_05F1 ; switch $08, lower right side band .byte >LAB_05F1 ; switch $09, lower left side band .byte >LAB_05D2 ; switch $0A, right gate lane .byte >LAB_04AD ; switch $0B, top right rollover .byte >LAB_04AD ; switch $0C, top left rollover .byte >LAB_04F5 ; switch $0D, centre trap left target .byte >LAB_04F2 ; switch $0E, centre trap mid target .byte >LAB_04F5 ; switch $0F, centre trap right target .byte >LAB_0534 ; switch $10, light spinner .byte >LAB_0546 ; switch $11, spinner .byte >LAB_0568 ; switch $12, spinner lane top exit .byte >LAB_0572 ; switch $13, open gate target .byte >LAB_0588 ; switch $14, special mid lane .byte >LAB_05A8 ; switch $15, special right lane .byte >LAB_0600 ; switch $16, right centre side band .byte >LAB_0600 ; switch $17, left centre side band .byte >LAB_0600 ; switch $18, upper left side band .byte >LAB_0600 ; switch $19, top left side band .byte >LAB_0600 ; switch $1A, top right side band .byte >LAB_0FF2 ; switch $1B, playfield entry ; input vectors low bytes LAB_0CF7 .byte = 10 go fire solenoids 10 to 13 ; fire solenoids 1 to 9 STX LAB_F1 ; save the solenoid to fire number LDA #$0E ; set the solenoid delay, 14 * 8.3ms = 117ms STA LAB_F2 ; save the solenoid delay DEC LAB_EB ; decrement the solenoid number LDA #$78 ; set the delay to the next step, 120 * 8.3ms = 1000ms BNE LAB_0D4D ; go save the delay and return to the main program loop, ; branch always ; fire solenoids 10 to 13 LAB_0D3B LDA LAB_70-1,X ; read a solenoid bit EOR #$01 ; toggle it AND #$01 ; mask 0000 000x, the solenoid bit BNE LAB_0D49 ; if the bit is set just go save it DEC LAB_EB ; decrement the solenoid number CPX #$0B ; compare the solenoid number with the playfield solenoid BEQ LAB_0D4B ; if it is the playfield skip clearing the bit LAB_0D49 STA LAB_70-1,X ; save a solenoid bit LAB_0D4B LDA #$3C ; set the delay to the next step, 60 * 8.3ms = 500ms LAB_0D4D STA LAB_F4 ; save the delay to the next step JMP LAB_089A ; return to the main program loop ;************************************************************************************ ; ; test $03, display test LAB_0D52 TYA ; copy the test switch status BNE LAB_0D5E ; if the switch is not active go display the next number LAB_0D55 LDA #$09 ; set the display number to 9 STA LAB_EB ; save the display number JSR LAB_0EBE ; display LAB_EA as decimal in status digits 1/0 BNE LAB_0D6B ; go set the delay and exit, branch always LAB_0D5E LDA LAB_EB ; get the display number BMI LAB_0D6F ; if less than zero go blank the displays ; the display number is 0 to 9 ORA #$10 ; mask xxx1 xxxx, turn the dp on PHA ; save the display pattern - why?? JSR LAB_0ED4 ; set all the display digits to A PLA ; restore the display pattern - why?? DEC LAB_EB ; decrement the display number LAB_0D6B LDA #$50 ; set the delay to the next step, 80 * 8.3ms = 667ms BNE LAB_0D4D ; go save the delay and continue, branch always LAB_0D6F LDA #$0F ; set all digit segments off JSR LAB_0ED4 ; set all the display digits to A BMI LAB_0D55 ; go reset the next number to 9, branch always ;************************************************************************************ ; ; partway branch LAB_0D76 BEQ LAB_0D19 ; go do the solenoid test, branch always ;************************************************************************************ ; ; the test or set switches are active LAB_0D78 LSR LAB_C9 ; get and clear the endgame flag BCS LAB_0D83 ; if it was set go restore it LDA #$00 ; clear A STA LAB_EA ; clear the option step STA LAB_EB ; clear the test number SEC ; set the endgame flag LAB_0D83 ROL LAB_C9 ; save the endgame flag TYA ; copy the switch index BEQ LAB_0D8B ; if the switch was test go do a test ; the switch was set JMP LAB_0E3E ; else go display and possibly change an option ; the switch was test so do a test LAB_0D8B LDA LAB_F4 ; get the delay to the next step BNE LAB_0D9C ; if not done just return to the main program loop LDA LAB_F3 ; get the sound delay BNE LAB_0D9C ; if not done just return to the main program loop JSR LAB_0EE4 ; check the demand switch and display the test number CPX #$06 ; compare the test number with the max + 1 BCC LAB_0D9F ; if it is a valid test number go handle it LSR LAB_C9 ; get and clear the endgame flag LAB_0D9C JMP LAB_089A ; return to the main program loop ; X is a valid test number LAB_0D9F CPX #$03 ; compare the test number with the display test BEQ LAB_0D52 ; if it is the display test go do it JSR LAB_0EEE ; display the test number in status digits 1/0 CPX #$01 ; compare the test number with the solenoid test BEQ LAB_0D76 ; if it is the solenoid test go do it ; it's not a display or solenoid test LDA #$00 ; clear A STA LAB_F2 ; clear the solenoid delay ; clear all the solenoids and lamps LDX #$3C ; set the count/index LAB_0DB0 STA LAB_40-1,X ; clear a solenoid/lamp DEX ; decrement the count/index BNE LAB_0DB0 ; loop if more to do LDX LAB_EA ; get the test number BEQ LAB_0D4B ; if the test number is zero go set the delay to the next ; test step and return to the main program loop CPX #$02 ; compare the test number with the lamp test BEQ LAB_0E26 ; if it is the lamp test go do it CPX #$04 ; compare the test number with the switch test BEQ LAB_0DE9 ; if it is the switch test go do it ; else it must be test $05, sound test ; I'm guessing this start address is LAB_0DC0 to be used in flow chart (wrk001 120519) TYA ; copy the test switch status BEQ LAB_0DC8 ; if the switch is active go set the start sound LDY LAB_EB ; get the sound number BPL LAB_0DCA ; if it's positive go do it ; else reset the number to the start LAB_0DC8 LDY #$16 ; set the sound number LAB_0DCA STY LAB_EB ; save the sound number JSR LAB_0ECA ; display LAB_EB as decimal in status digits 5/4 CPY #$10 ; compare the sound number with the last table sound BCS LAB_0DDA ; if it is a table sound go get it ; else the number is the sound so use that STY LAB_0182 ; save the RIOT DRB, the sound port LDA #$3C ; set the sound delay BNE LAB_0DE3 ; go save the delay and continue, branch always ; the sound is a table sound LAB_0DDA LDA LAB_0EFB-$10,Y ; get the test sound STA LAB_0182 ; save the RIOT DRB, the sound port LDA LAB_0F02-$10,Y ; get the test sound delay LAB_0DE3 DEC LAB_EB ; decrement the sound number STA LAB_F3 ; save the sound delay BNE LAB_0D9C ; return to the main program loop, branch always ;************************************************************************************ ; ; test $04, switch test LAB_0DE9 TYA ; copy the test switch status BNE LAB_0DF3 ; if the switch is not active skip the switch test reset LDX #$1C ; set the switch index to coin set JSR LAB_0C2A ; clear X switches, wait for them to close BEQ LAB_0DFA ; go reset the switch test, branch always ; the test switch is not active LAB_0DF3 CLC ; flag don't clear digits 4/5 LDX LAB_EB ; get the switch number BEQ LAB_0E08 ; if it's zero just go sset a 250ms delay and exit BPL LAB_0DFD ; if it's a switch go use the number ; else the number is negative so reset the switch number to the start LAB_0DFA SEC ; flag clear digits 4/5 LDX #$1C ; set the switch number to coin set LAB_0DFD STX LAB_EB ; save the switch number LDA LAB_CA-1,X ; get the switch state BEQ LAB_0E0C ; if the switch is active go display the switch number DEX ; decrement the switch number BNE LAB_0DFD ; loop if more to do ; no switches were active so blank the number for 250ms STX LAB_EB ; clear the switch number LAB_0E08 LDA #$1E ; set the delay to the next step, 30 * 8.3ms = 250ms BNE LAB_0E17 ; go save the delay, branch always ; a switch is active so display the switch number for 1000ms LAB_0E0C LDA LAB_0CBF ; get the switch $01 high reset state STA LAB_CA-1,X ; save the switch state JSR LAB_0ECA ; display LAB_EB as decimal in status digits 5/4 CLC ; flag don't clear digits 4/5 LDA #$78 ; set the delay to the next step, 120 * 8.3ms = 1000ms LAB_0E17 STA LAB_F4 ; save the delay to the next step DEC LAB_EB ; decrement the switch number LDA #$0D ; set A for "-" BCC LAB_0E23 ; if Cb not set skip the digit saves STA LAB_24 ; save status digit 4 STA LAB_25 ; save status digit 5 LAB_0E23 JMP LAB_089A ; return to the main program loop ;************************************************************************************ ; ; test $02, lamp test ; ; this code generates a walking pattern of six off and two on lamps. each time this ; routine is called the next step in the pattern is generated and saved to the lamp ; drivers ; ; this routine is also used in attract mode LAB_0E26 LDX #$30 ; set the count/index to the last lamp INC LAB_EB ; increment the sequence number LAB_0E2A LDA LAB_EB ; get the sequence number AND #$07 ; mask 0000 0xxx STA LAB_EB ; save the sequence number LSR ; >> 1 AND LAB_EB ; AND it with the sequence number LSR ; >> 1 STA LAB_40-1,X ; save a lamp INC LAB_EB ; increment the sequence number DEX ; decrement the count/index BNE LAB_0E2A ; loop if more to do JMP LAB_0D4B ; set the delay to the next test step and return to the ; main program loop ;************************************************************************************ ; ; display and possibly change an option LAB_0E3E JSR LAB_0EE4 ; check the demand switch and display the test number CPX #$0B ; compare the set position with 11 BCS LAB_0E85 ; if 11 or more go handle them ; the option is 1 to 10 JSR LAB_0B1E ; set the LAB_33 pointer to option X ; display the option value on the player 1 score display LDY #$05 ; set the digit count/index LAB_0E4A LDA (LAB_33),Y ; get an option byte STA LAB_18,Y ; save a player 1 digit DEY ; decrement the digit count/index BPL LAB_0E4A ; loop if more to do LDA LAB_E5 ; get switch $1C, coin set BNE LAB_0E82 ; if the switch is not active return to the main program ; loop ; the coin switch is active LDA LAB_0CBD ; get the coin set input low reset state STA LAB_E5 ; save switch $1C, coin set LDX LAB_EA ; get the set position CPX #$06 ; compare it with position 6, the first that can be altered BCC LAB_0E82 ; if less than position 6 return to the main program loop ; set positions 6 onwards can be altered LDA LAB_EB ; get the set position step BNE LAB_0E7B ; if it's not zero go increment the value INC LAB_EB ; increment the set position step ; set the score to " 00000" LDY #$05 ; set the digit index to digit 5 LAB_0E69 LDA #$00 ; set the digit to "0" LAB_0E6B STA (LAB_33),Y ; save the digit LDA #$0F ; set all digit segments off DEY ; decrement the digit index BEQ LAB_0E6B ; if digit zero go save the blank BPL LAB_0E69 ; loop if more digits to do LDA #$01 ; set 1 TAY ; set the digit index to digit 1 STA (LAB_33),Y ; set the score to " 10000" BNE LAB_0E82 ; return to the main program loop, branch always ; increment the score value by 5000 LAB_0E7B LDY #$02 ; set digit 2, x000 LDA #$05 ; set 5000 JSR LAB_0ACD ; add A to (LAB_33) digit Y LAB_0E82 JMP LAB_089A ; return to the main program loop ; set positions 11 onwards LAB_0E85 CPX #$10 ; compare the set position with 16, match option BCC LAB_0E94 ; if less go do 11 to 15 ; do match option BNE LAB_0E8F ; if not set position 16 just return to the main loop LDA LAB_C0 ; get option 15, special award option BNE LAB_0E94 ; if free game award set allow set position 16 to be set LAB_0E8F LSR LAB_C9 ; get and clear the endgame ?? flag JMP LAB_089A ; return to the main program loop ; set positions 11 to 15 and 16 if option 15 is set LAB_0E94 LDA LAB_BC-$0B,X ; get the option value STA LAB_1D ; save the option value in player 1 digit 5 LDA LAB_E5 ; get switch $1C, coin set BNE LAB_0E82 ; if the switch is not active return to the main program ; loop ; the coin switch is active so increment the option value ; ; the coin switch in this case is the reset switch, S-28B, on the coin door. this switch ; only works when the test-play-set switch is in the set position DEC LAB_E5 ; decrement switch $1C, coin set INC LAB_BC-$0B,X ; increment the option value LDA LAB_BC-$0B,X ; get the option value CMP LAB_0F09-$0B,X ; compare it with the option value max + 1 BCC LAB_0E82 ; if lexx than the max + 1 return to the main program loop ; else reset the option value ; ; options 11 and 13 are reset to one, all the others are reset to zero. in addition ; resetting the special award option also clears the match option LDY #$00 ; clear Y LDA #$01 ; set A CPX #$0D ; compare the option with balls per game BEQ LAB_0EBA ; if balls per game just go save the option CPX #$0B ; compare the option with game price BEQ LAB_0EBA ; if game price just go save the option CPX #$0F ; compare the option with special award BNE LAB_0EB9 ; if not special award skip the match option clear STY LAB_C1 ; clear option 16, match option LAB_0EB9 TYA ; clear the reset value LAB_0EBA STA LAB_BC-$0B,X ; save the reset option value BEQ LAB_0E82 ; return to the main program loop, branch always ;************************************************************************************ ; ; display LAB_EA as decimal in status digits 1/0 LAB_0EBE PHA ; save A LDA LAB_EA ; get the value JSR LAB_0B93 ; return A MOD 10 in A and A DIV 10 in AX STA LAB_21 ; save status digit 1 STX LAB_20 ; save status digit 0 PLA ; restore A RTS ;************************************************************************************ ; ; display LAB_EB as decimal in status digits 5/4 LAB_0ECA LDA LAB_EB ; get the value to display JSR LAB_0B93 ; return A MOD 10 in A and A DIV 10 in AX STA LAB_25 ; save status digit 5 STX LAB_24 ; save status digit 4 RTS ;************************************************************************************ ; ; set all the display digits to A LAB_0ED4 LDX #$05 ; set the count/index LAB_0ED6 STA LAB_20,X ; save the status digit STA LAB_18,X ; save the player 1 digit STA LAB_10,X ; save the player 2 digit STA LAB_08,X ; save the player 3 digit STA LAB_00,X ; save the player 4 digit DEX ; decrement the count/index BPL LAB_0ED6 ; loop if more to do RTS ;************************************************************************************ ; ; check the demand switch and display the test number ; ; if the demand switch is active advance to the next test LAB_0EE4 LDY LAB_E6 ; get switch $1D, demand BNE LAB_0EF3 ; if the switch is not active go display the test number STY LAB_EB ; clear the test step number DEC LAB_E6 ; decrement switch $1D, demand. make it $FF LAB_0EEC INC LAB_EA ; increment the test number ;************************************************************************************ ; ; display the test number in status digits 1/0 LAB_0EEE LDA #$0F ; set all digit segments off JSR LAB_0ED4 ; set all the display digits to A LAB_0EF3 JSR LAB_0EBE ; display LAB_EA as decimal in status digits 1/0 LDX LAB_EA ; get the test number BEQ LAB_0EEC ; if the test number is $00 go increment it RTS ;************************************************************************************ ; ; test sounds LAB_0EFB .byte $28,$48,$68,$88,$A8,$C8,$E8 ; test sound delays LAB_0F02 .byte $FF ; 255 * 8.3ms = 2117ms .byte $60 ; 96 * 8.3ms = 800ms .byte $A0 ; 160 * 8.3ms = 1333ms .byte $60 ; 96 * 8.3ms = 800ms .byte $A0 ; 160 * 8.3ms = 1333ms .byte $60 ; 96 * 8.3ms = 800ms .byte $A0 ; 160 * 8.3ms = 1333ms ;************************************************************************************ ; ; option max + 1 values LAB_0F09 .byte $07 ; option 11, game price .byte $06 ; option 12, discount bonus credit .byte $06 ; option 13, balls per game .byte $02 ; option 14, feature lane options .byte $02 ; option 15, special award option .byte $02 ; option 16, match option ;************************************************************************************ ; ; NMI enters here ; ; NMI is triggered at twice the line rate (120Hz), roughly every 8.3ms LAB_0F0F PHA ; save A TXA ; copy X PHA ; save X LDA LAB_F2 ; get the solenoid delay BEQ LAB_0F2B ; if no solenoids to do go do the sound ; there are solenoids to do DEC LAB_F2 ; decrement the solenoid delay BNE LAB_0F25 ; if not decremented out go set the solenoid ; clear the solenoid drivers LDX #$09 ; set the count/index LDA #$00 ; clear A LAB_0F1E STA LAB_70-1,X ; clear a solenoid bit DEX ; decrement the count/index BNE LAB_0F1E ; loop if more to do BEQ LAB_0F2B ; go handle the sound, branch always ; fire a solenoid LAB_0F25 LDX LAB_F1 ; get the solenoid to fire number LDA #$01 ; set A STA LAB_70-1,X ; set a solenoid bit ; handle the sound delay LAB_0F2B LDA LAB_0182 ; read the RIOT DRB, the sound port LDX LAB_F3 ; get the sound delay BEQ LAB_0F3C ; if the delay is finished continue DEC LAB_F3 ; else decrement the sound delay ; ?? ## is this right? if the sound port byte was $00 the code goes and clears the ; ?? ## strobe bit CMP #$00 ; compare the sound port with zero BEQ LAB_0F3C ; if it's zero go clear the strobe bit ORA #$10 ; else mask xxx1 xxxx, set the strobe bit BNE LAB_0F3E ; go save the strobe bit, branch always LAB_0F3C AND #$EF ; mask xxx0 xxxx, clear the strobe bit LAB_0F3E LDX LAB_F6 ; get the tilt lamp count BEQ LAB_0F44 ; if no tilt go save the sound LDA #$D2 ; else set the tilt sound LAB_0F44 STA LAB_0182 ; save the RIOT DRB, the sound port ; decrement the next step delay LDA LAB_F4 ; get the delay to the next step BEQ LAB_0F4D ; if done skip the decrement DEC LAB_F4 ; decrement the delay to the next step ; do the quater second timer LAB_0F4D DEC LAB_0100 ; decrement the quater second timer BNE LAB_0F64 ; if not counted out continue LDA #$1E ; reset the quater second timer count STA LAB_0100 ; save the quater second timer ; decrement the game over and the tilt lamp counts LDX #$02 ; set the count/index LAB_0F59 LDA LAB_F5-1,X ; get a count BEQ LAB_0F5F ; if counted out skip the decrement DEC LAB_F5-1,X ; decrement a count LAB_0F5F DEX ; decrement the count/index BNE LAB_0F59 ; loop if more to do INC LAB_F7 ; increment the quater second counter ; something something tilt lamp something ?? LAB_0F64 LDA LAB_F6 ; get the tilt lamp count AND #$03 ; mask 0000 00xx BEQ LAB_0F7A ; if zero skip the tilt section ; clear the tilt lamp on 11 and 01, set it on 10 TAX ; copy the masked bits LDA LAB_56 ; get lamp 14, tilt LSR ; shift a lamp bit out CPX #$03 ; compare the masked bits with 11 CLC ; clear the lamp bit BEQ LAB_0F77 ; if 11 go clear the tilt lamp CPX #$01 ; compare the masked bits with 01 BNE LAB_0F7A ; if not 01 skip the lamp set LAB_0F77 ROL ; shift in the new lamp bit STA LAB_56 ; save lamp 14, tilt ; reset the timer. doing this will cause an interrupt ~4ms after the NMI interrupt. ; this is the only place a timer interrupt is initiated. this is done so that the ; switches are read every ~4ms, twice as often as the 8.3ms NMI routine alone would ; read them LAB_0F7A LDA #$40 ; set 64us*64 ~4ms STA LAB_019E ; write and enable the timer BNE LAB_0FA2 ; go test the switch inputs, branch always ;************************************************************************************ ; ; IRQ enters here ; ; IRQ is triggered by an interrupt from the 6532 RIOT and is either a timer or PA7 ; interrupt LAB_0F81 PHA ; save A TXA ; copy X PHA ; save X LDA LAB_0185 ; read the RIOT interrupt flag BMI LAB_0F9F ; if the timer interrupt bit is set go handle it ; else it must be a PA7 interrupt, the tilt switch STA LAB_0184 ; disable the tilt switch - PA7, negative edge LDA #$07 ; set the tilt count STA LAB_56 ; save lamp 14, tilt LDA #$18 ; set the tilt lamp count, 24 quater seconds STA LAB_F6 ; save the tilt lamp count ; clear all the bonus lamps LDX #$0C ; set the count/index LAB_0F96 LSR LAB_4A-1,X ; clear a bonus lamp DEX ; decrement the count/index BNE LAB_0F96 ; loop if more to do STX LAB_7A ; clear solenoid 11, playfield BEQ LAB_0FE2 ; restore the registers and exit, branch always ; the interrupt was a timer interrupt LAB_0F9F LDA LAB_0184 ; read the timer, clear the interrupt flag ; common exit code for both IRQ and NMI LAB_0FA2 LDA #$1F ; set IIIO OOOO STA LAB_0181 ; save RIOT DDRA, 0 = input ; test all the switch inputs. in this part of the code the switches are indexed from ; $00 for the playfield exit switch to $1F for the demand switch, elsewhere they are ; indexed starting from $01 for the playfield exit switch LDX #$1F ; set the input count/index LAB_0FA9 CPX #$1D ; compare the input count/index with the rotate switch BCC LAB_0FBE ; if less go handle the debounced inputs ; do inputs $1F to $1D ; ; $1F = demand ; $1E = set ; $1D = rotate ; ; these inputs respond to the immediate state and read as $80 if closed and $00 if open STX LAB_0180 ; save the input count/index, address the input LDA #$00 ; clear A BIT LAB_0180 ; test the 4051 data bit, b6 BVS LAB_0FB9 ; if the bit is set use the $00 LDA #$80 ; else set $80 LAB_0FB9 STA LAB_CA,X ; save the input state DEX ; decrement the input count/index BNE LAB_0FA9 ; loop if more to do, branch always ; do inputs $1C to $00, the debounced inputs ; ; $1C = test ; ... ; $00 = playfield exit ; ; when a switch closes (the input goes low) it must stay closed for the number of counts ; loaded from the input high reset state table before it reaches zero and is flagged as ; an active switch ; ; once a switch is closed and has been reset it must open for the number of counts - $7F ; loaded from the input low reset state table before it reaches $7F, is once more ; considered open and is checked for it closing again LAB_0FBE STX LAB_0180 ; save the input count/index, address the input LDA LAB_CA,X ; get the input state BEQ LAB_0FDF ; if the input is active go do the next input BMI LAB_0FD1 ; if the state is negative go reset a low input ; reset a high input, count down on a low input BIT LAB_0180 ; test the 4051 data bit, b6 BVC LAB_0FDD ; if the input is low go decrement the state LDA LAB_0CBF,X ; get the input high reset state BNE LAB_0FD9 ; go save the input state, branch always ; reset a low input, count down on a high input LAB_0FD1 BIT LAB_0180 ; test the 4051 data bit, b6 BVS LAB_0FDD ; if the input is high go decrement the state LDA LAB_0CA2,X ; get the input low reset state LAB_0FD9 STA LAB_CA,X ; save the input state BNE LAB_0FDF ; go do the next input, branch always LAB_0FDD DEC LAB_CA,X ; decrement the input state ; do the next input LAB_0FDF DEX ; decrement the input count/index BPL LAB_0FBE ; loop if more to do LAB_0FE2 PLA ; pull X TAX ; restore X PLA ; restore A RTI ;************************************************************************************ ; ; switch $01, playfield exit LAB_0FE6 LDA #$00 ; flag no ball in play STA LAB_FF ; save the ball in play flag JMP LAB_0400 ; continue ;************************************************************************************ ; ; spare bytes, not referenced ;LAB_0FED .byte $00,$00,$00,$00 ; unused .byte $00 ; unused ;************************************************************************************ ; ; switch $1B, playfield entry LAB_0FF2 LDA #$01 ; flag ball in play STA LAB_FF ; save the ball in play flag JMP LAB_0612 ; continue ;************************************************************************************ ; ; spare byte, not referenced ;LAB_0FF9 .byte $00 ; unused ;************************************************************************************ ; ; system vectors ;LAB_0FFA .word LAB_0F0F ; NMI vector .word LAB_086F ; RESET vector .word LAB_0F81 ; IRQ vector .END ;************************************************************************************ ; ; 30 out of 3500 lines to do ; ;************************************************************************************