A Documenting of the Breakout CHIP-8 Game This is documentation for the breakout game provided in the sixth edition of VIPER magazine. Firstly, follows is a view of the program when it is first loaded into the tool: 200-201 0512-0513 #_^ __^ A2CC 41676 I <- 0716 202-203 0514-0515 ^^ ^_# 6A06 27142 VA <- 006 204-205 0516-0517 ^^ _# 6103 24835 V1 <- 003 206-207 0518-0519 ^^ # ^^ 6B08 27400 VB <- 008 208-209 0520-0521 ^^ 6000 24576 V0 <- 000 20A-20B 0522-0523 ^^ # _ D011 53265 Draw 08x01 at V0,V1; VF <- XOR 20C-20D 0524-0525 ^^^_ 7008 28680 V0 <- V0 + 008 20E-20F 0526-0527 _####_## 7BFF 31743 VB <- VB + 255 210-211 0528-0529 ^^^ ^^ 3B00 15104 Skip next if VB = 000 212-213 0530-0531 ^_ # 120A 04618 Jump to 0522 214-215 0532-0533 ^^^ _^ 7102 28930 V1 <- V1 + 002 216-217 0534-0535 _####_#_ 7AFF 31487 VA <- VA + 255 218-219 0536-0537 ^^^ ^ 3A00 14848 Skip next if VA = 000 21A-21B 0538-0539 ^ _# 1206 04614 Jump to 0518 21C-21D 0540-0541 ^^ ^^ 6600 26112 V6 <- 000 21E-21F 0542-0543 ^^_ #^^ 6714 26388 V7 <- 020 220-221 0544-0545 #_^ __^_ A2CD 41677 I <- 0717 222-223 0546-0547 ^# 6020 24608 V0 <- 032 224-225 0548-0549 ^^____^ 611E 24862 V1 <- 030 226-227 0550-0551 ^^ # _ D011 53265 Draw 08x01 at V0,V1; VF <- XOR 228-229 0552-0553 ^^___^# 631D 25373 V3 <- 029 22A-22B 0554-0555 ^#___#_ 623F 25151 V2 <- 063 22C-22D 0556-0557 ^ # 8202 33282 V2 <- V2 AND V0 22E-22F 0558-0559 _###_### 77FF 30719 V7 <- V7 + 255 230-231 0560-0561 ^ ^^^ 4700 18176 Skip next if V7 <> 000 232-233 0562-0563 _ _^_ # 12AA 04778 Jump to 0682 234-235 0564-0565 ^^^^#^#^ FF0A 65290 VF <- key 236-237 0566-0567 #_^ _ #_ A2CB 41675 I <- 0715 238-239 0568-0569 ^^_# ^_ D231 53809 Draw 08x01 at V2,V3; VF <- XOR 23A-23B 0570-0571 _##__#_# 65FF 26111 V5 <- 255 23C-23D 0572-0573 ^^ ^ _ C401 50177 V4 <- ??? AND 001 23E-23F 0574-0575 ^^ ^ _ 3401 13313 Skip next if V4 = 001 240-241 0576-0577 _##__#__ 64FF 25855 V4 <- 255 242-243 0578-0579 #_^ __^_ A2CD 41677 I <- 0717 244-245 0580-0581 ^^ ^^ 6C00 27648 VC <- 000 246-247 0582-0583 ^^ ^#^ 6E04 28164 VE <- 004 248-249 0584-0585 #^# ^^^_ EEA1 61089 Skip next if VE <> key 24A-24B 0586-0587 _##_##_ 6CFE 27902 VC <- 254 24C-24D 0588-0589 ^^ ^## 6E06 28166 VE <- 006 24E-24F 0590-0591 #^# ^^^_ EEA1 61089 Skip next if VE <> key 250-251 0592-0593 ^^ ^^_ 6C02 27650 VC <- 002 252-253 0594-0595 ^^ # _ D011 53265 Draw 08x01 at V0,V1; VF <- XOR 254-255 0596-0597 #_ _ 80C4 32964 V0 <- V0 + VC; VF <- overflow 256-257 0598-0599 ^^ # _ D011 53265 Draw 08x01 at V0,V1; VF <- XOR 258-259 0600-0601 ^ ^^^# 4F01 20225 Skip next if VF <> 001 25A-25B 0602-0603 _ #_ ^ 1298 04760 Jump to 0664 25C-25D 0604-0605 ^ ^ 4200 16896 Skip next if V2 <> 000 25E-25F 0606-0607 ^^ ^ _ 6401 25601 V4 <- 001 260-261 0608-0609 ^____#_ 423F 16959 Skip next if V2 <> 063 262-263 0610-0611 _##__#__ 64FF 25855 V4 <- 255 264-265 0612-0613 ^ ^^ 4300 17152 Skip next if V3 <> 000 266-267 0614-0615 __ ^__# 12CE 04814 Jump to 0718 268-269 0616-0617 ^ ___## 431F 17183 Skip next if V3 <> 031 26A-26B 0618-0619 _ _^ _^ 12A4 04772 Jump to 0676 26C-26D 0620-0621 #_^ _ #_ A2CB 41675 I <- 0715 26E-26F 0622-0623 ^^_# ^_ D231 53809 Draw 08x01 at V2,V3; VF <- XOR 270-271 0624-0625 ^_ _^ 8244 33348 V2 <- V2 + V4; VF <- overflow 272-273 0626-0627 ^_ _ _^^ 8354 33620 V3 <- V3 + V5; VF <- overflow 274-275 0628-0629 ^^_# ^_ D231 53809 Draw 08x01 at V2,V3; VF <- XOR 276-277 0630-0631 ^^^^^# 3F01 16129 Skip next if VF = 001 278-279 0632-0633 _ ^ # 1242 04674 Jump to 0578 27A-27B 0634-0635 ^ ___#^ 431E 17182 Skip next if V3 <> 030 27C-27D 0636-0637 _ #_ ^ 1298 04760 Jump to 0664 27E-27F 0638-0639 ^^ ^ # 6A02 27138 VA <- 002 280-281 0640-0641 ^^^## ^ FA18 64024 sound <- VA 282-283 0642-0643 ^^^ ^^_ 7601 30209 V6 <- V6 + 001 284-285 0644-0645 #_^ _ # A2CA 41674 I <- 0714 286-287 0646-0647 _ ^_ ^ 1288 04744 Jump to 0648 288-289 0648-0649 ^^_# ^_ D231 53809 Draw 08x01 at V2,V3; VF <- XOR 28A-28B 0650-0651 ^^ ^ _ C401 50177 V4 <- ??? AND 001 28C-28D 0652-0653 ^^ ^ _ 3401 13313 Skip next if V4 = 001 28E-28F 0654-0655 _##__#__ 64FF 25855 V4 <- 255 290-291 0656-0657 ^^ ^ # C501 50433 V5 <- ??? AND 001 292-293 0658-0659 ^^ ^ # 3501 13569 Skip next if V5 = 001 294-295 0660-0661 ^^ ^ # 6501 25857 V5 <- 001 296-297 0662-0663 _ ^ # 1242 04674 Jump to 0578 298-299 0664-0665 ^^ ^ #_ 6A03 27139 VA <- 003 29A-29B 0666-0667 ^^^## ^ FA18 64024 sound <- VA 29C-29D 0668-0669 #_^ _ #_ A2CB 41675 I <- 0715 29E-29F 0670-0671 ^^_# ^_ D231 53809 Draw 08x01 at V2,V3; VF <- XOR 2A0-2A1 0672-0673 _###__## 73FF 29695 V3 <- V3 + 255 2A2-2A3 0674-0675 _# _# 1236 04662 Jump to 0566 2A4-2A5 0676-0677 #_^ _ #_ A2CB 41675 I <- 0715 2A6-2A7 0678-0679 ^^_# ^_ D231 53809 Draw 08x01 at V2,V3; VF <- XOR 2A8-2A9 0680-0681 _^_ ^ 1228 04648 Jump to 0552 2AA-2AB 0682-0683 #_^ __^_ A2CD 41677 I <- 0717 2AC-2AD 0684-0685 ^^ # _ D011 53265 Draw 08x01 at V0,V1; VF <- XOR 2AE-2AF 0686-0687 #_#_ ^ A2F0 41712 I <- 0752 2B0-2B1 0688-0689 ^^## ^#_ F633 63027 V6 as BCD stored from I 2B2-2B3 0690-0691 ^##^ _^_ F265 62053 Load V0->V2; I <- I + 03 2B4-2B5 0692-0693 ^^__ ^^ 6318 25368 V3 <- 024 2B6-2B7 0694-0695 ^^__^__ 641B 25627 V4 <- 027 2B8-2B9 0696-0697 ^^#^_ _ F029 61481 I <- digit sprite of V0 2BA-2BB 0698-0699 ^# ^ _^# D345 54085 Draw 08x05 at V3,V4; VF <- XOR 2BC-2BD 0700-0701 ^^^ _^# 7305 29445 V3 <- V3 + 005 2BE-2BF 0702-0703 ^^#^_ # F129 61737 I <- digit sprite of V1 2C0-2C1 0704-0705 ^# ^ _^# D345 54085 Draw 08x05 at V3,V4; VF <- XOR 2C2-2C3 0706-0707 ^^^ _^# 7305 29445 V3 <- V3 + 005 2C4-2C5 0708-0709 ^^#^_ ^_ F229 61993 I <- digit sprite of V2 2C6-2C7 0710-0711 ^# ^ _^# D345 54085 Draw 08x05 at V3,V4; VF <- XOR 2C8-2C9 0712-0713 __ ^_ ^ 12C8 04808 Jump to 0712 2CA-2CB 0714-0715 #^^^ F080 61568 2CC-2CD 0716-0717 ######## FFFF 65535 2CE-2CF 0718-0719 #_^___# A2DE 41694 I <- 0734 2D0-2D1 0720-0721 ^^_ _^# 6315 25365 V3 <- 021 2D2-2D3 0722-0723 ^^_ ^ 6210 25104 V2 <- 016 2D4-2D5 0724-0725 ^^_^ _^# D325 54053 Draw 08x05 at V3,V2; VF <- XOR 2D6-2D7 0726-0727 #_# #_ A2E3 41699 I <- 0739 2D8-2D9 0728-0729 ^^___^# 631D 25373 V3 <- 029 2DA-2DB 0730-0731 ^^_^ _^# D325 54053 Draw 08x05 at V3,V2; VF <- XOR 2DC-2DD 0732-0733 _ _^_ # 12AA 04778 Jump to 0682 2DE-2DF 0734-0735 #^^ #^# EE8A 61066 2E0-2E1 0736-0737 #^ ##^ CE8C 52876 VE <- ??? AND 140 2E2-2E3 0738-0739 #__ #_# 8AEE 35566 VA <- VE x 2; VF <- MSB 2E4-2E5 0740-0741 #_ #_ 88CC 35020 2E6-2E7 0742-0743 #__ #__ 88EE 35054 V8 <- VE x 2; VF <- MSB Follows now is the fully annotated view of the program when it is loaded into the tool: 200-201 0512-0513 #_^ __^ A2CC 41676 I <- wall 202-203 0514-0515 ^^ ^_# 6A06 27142 VA <- 006 204-205 0516-0517 ^^ _# 6103 24835 V1 <- 003 206-207 0518-0519 ^^ # ^^ 6B08 27400 start row VB <- 008 208-209 0520-0521 ^^ 6000 24576 V0 <- 000 20A-20B 0522-0523 ^^ # _ D011 53265 draw row Draw 08x01 at V0,V1; VF <- XOR 20C-20D 0524-0525 ^^^_ 7008 28680 V0 <- V0 + 008 20E-20F 0526-0527 _####_## 7BFF 31743 VB <- VB + 255 210-211 0528-0529 ^^^ ^^ 3B00 15104 Skip next if VB = 000 212-213 0530-0531 ^_ # 120A 04618 Jump to draw row 214-215 0532-0533 ^^^ _^ 7102 28930 V1 <- V1 + 002 216-217 0534-0535 _####_#_ 7AFF 31487 VA <- VA + 255 218-219 0536-0537 ^^^ ^ 3A00 14848 Skip next if VA = 000 21A-21B 0538-0539 ^ _# 1206 04614 Jump to start row 21C-21D 0540-0541 ^^ ^^ 6600 26112 V6 <- 000 21E-21F 0542-0543 ^^_ #^^ 6714 26388 V7 <- 020 220-221 0544-0545 #_^ __^_ A2CD 41677 I <- paddle 222-223 0546-0547 ^# 6020 24608 V0 <- 032 224-225 0548-0549 ^^____^ 611E 24862 V1 <- 030 226-227 0550-0551 ^^ # _ D011 53265 Draw 08x01 at V0,V1; VF <- XOR 228-229 0552-0553 ^^___^# 631D 25373 serve V3 <- 029 22A-22B 0554-0555 ^#___#_ 623F 25151 V2 <- 063 22C-22D 0556-0557 ^ # 8202 33282 V2 <- V2 AND V0 22E-22F 0558-0559 _###_### 77FF 30719 V7 <- V7 + 255 230-231 0560-0561 ^ ^^^ 4700 18176 Skip next if V7 <> 000 232-233 0562-0563 _ _^_ # 12AA 04778 Jump to end 234-235 0564-0565 ^^^^#^#^ FF0A 65290 VF <- key 236-237 0566-0567 #_^ _ #_ A2CB 41675 play I <- ball 238-239 0568-0569 ^^_# ^_ D231 53809 Draw 08x01 at V2,V3; VF <- XOR 23A-23B 0570-0571 _##__#_# 65FF 26111 V5 <- 255 23C-23D 0572-0573 ^^ ^ _ C401 50177 V4 <- ??? AND 001 23E-23F 0574-0575 ^^ ^ _ 3401 13313 Skip next if V4 = 001 240-241 0576-0577 _##__#__ 64FF 25855 V4 <- 255 242-243 0578-0579 #_^ __^_ A2CD 41677 move I <- paddle 244-245 0580-0581 ^^ ^^ 6C00 27648 VC <- 000 246-247 0582-0583 ^^ ^#^ 6E04 28164 VE <- 004 248-249 0584-0585 #^# ^^^_ EEA1 61089 Skip next if VE <> key 24A-24B 0586-0587 _##_##_ 6CFE 27902 VC <- 254 24C-24D 0588-0589 ^^ ^## 6E06 28166 VE <- 006 24E-24F 0590-0591 #^# ^^^_ EEA1 61089 Skip next if VE <> key 250-251 0592-0593 ^^ ^^_ 6C02 27650 VC <- 002 252-253 0594-0595 ^^ # _ D011 53265 Draw 08x01 at V0,V1; VF <- XOR 254-255 0596-0597 #_ _ 80C4 32964 V0 <- V0 + VC; VF <- overflow 256-257 0598-0599 ^^ # _ D011 53265 Draw 08x01 at V0,V1; VF <- XOR 258-259 0600-0601 ^ ^^^# 4F01 20225 Skip next if VF <> 001 25A-25B 0602-0603 _ #_ ^ 1298 04760 Jump to hit 25C-25D 0604-0605 ^ ^ 4200 16896 Skip next if V2 <> 000 25E-25F 0606-0607 ^^ ^ _ 6401 25601 V4 <- 001 260-261 0608-0609 ^____#_ 423F 16959 Skip next if V2 <> 063 262-263 0610-0611 _##__#__ 64FF 25855 V4 <- 255 264-265 0612-0613 ^ ^^ 4300 17152 Skip next if V3 <> 000 266-267 0614-0615 __ ^__# 12CE 04814 Jump to draw free 268-269 0616-0617 ^ ___## 431F 17183 Skip next if V3 <> 031 26A-26B 0618-0619 _ _^ _^ 12A4 04772 Jump to dropped 26C-26D 0620-0621 #_^ _ #_ A2CB 41675 I <- ball 26E-26F 0622-0623 ^^_# ^_ D231 53809 Draw 08x01 at V2,V3; VF <- XOR 270-271 0624-0625 ^_ _^ 8244 33348 V2 <- V2 + V4; VF <- overflow 272-273 0626-0627 ^_ _ _^^ 8354 33620 V3 <- V3 + V5; VF <- overflow 274-275 0628-0629 ^^_# ^_ D231 53809 Draw 08x01 at V2,V3; VF <- XOR 276-277 0630-0631 ^^^^^# 3F01 16129 Skip next if VF = 001 278-279 0632-0633 _ ^ # 1242 04674 Jump to move 27A-27B 0634-0635 ^ ___#^ 431E 17182 Skip next if V3 <> 030 27C-27D 0636-0637 _ #_ ^ 1298 04760 Jump to hit 27E-27F 0638-0639 ^^ ^ # 6A02 27138 VA <- 002 280-281 0640-0641 ^^^## ^ FA18 64024 sound <- VA 282-283 0642-0643 ^^^ ^^_ 7601 30209 V6 <- V6 + 001 284-285 0644-0645 #_^ _ # A2CA 41674 I <- damage 286-287 0646-0647 _ ^_ ^ 1288 04744 Jump to next 288-289 0648-0649 ^^_# ^_ D231 53809 next Draw 08x01 at V2,V3; VF <- XOR 28A-28B 0650-0651 ^^ ^ _ C401 50177 V4 <- ??? AND 001 28C-28D 0652-0653 ^^ ^ _ 3401 13313 Skip next if V4 = 001 28E-28F 0654-0655 _##__#__ 64FF 25855 V4 <- 255 290-291 0656-0657 ^^ ^ # C501 50433 V5 <- ??? AND 001 292-293 0658-0659 ^^ ^ # 3501 13569 Skip next if V5 = 001 294-295 0660-0661 ^^ ^ # 6501 25857 V5 <- 001 296-297 0662-0663 _ ^ # 1242 04674 Jump to move 298-299 0664-0665 ^^ ^ #_ 6A03 27139 hit VA <- 003 29A-29B 0666-0667 ^^^## ^ FA18 64024 sound <- VA 29C-29D 0668-0669 #_^ _ #_ A2CB 41675 I <- ball 29E-29F 0670-0671 ^^_# ^_ D231 53809 Draw 08x01 at V2,V3; VF <- XOR 2A0-2A1 0672-0673 _###__## 73FF 29695 V3 <- V3 + 255 2A2-2A3 0674-0675 _# _# 1236 04662 Jump to play 2A4-2A5 0676-0677 #_^ _ #_ A2CB 41675 dropped I <- ball 2A6-2A7 0678-0679 ^^_# ^_ D231 53809 Draw 08x01 at V2,V3; VF <- XOR 2A8-2A9 0680-0681 _^_ ^ 1228 04648 Jump to serve 2AA-2AB 0682-0683 #_^ __^_ A2CD 41677 end I <- paddle 2AC-2AD 0684-0685 ^^ # _ D011 53265 Draw 08x01 at V0,V1; VF <- XOR 2AE-2AF 0686-0687 #_#_ ^ A2F0 41712 I <- 0752 2B0-2B1 0688-0689 ^^## ^#_ F633 63027 V6 as BCD stored from I 2B2-2B3 0690-0691 ^##^ _^_ F265 62053 Load V0->V2; I <- I + 03 2B4-2B5 0692-0693 ^^__ ^^ 6318 25368 V3 <- 024 2B6-2B7 0694-0695 ^^__^__ 641B 25627 V4 <- 027 2B8-2B9 0696-0697 ^^#^_ _ F029 61481 I <- digit sprite of V0 2BA-2BB 0698-0699 ^# ^ _^# D345 54085 Draw 08x05 at V3,V4; VF <- XOR 2BC-2BD 0700-0701 ^^^ _^# 7305 29445 V3 <- V3 + 005 2BE-2BF 0702-0703 ^^#^_ # F129 61737 I <- digit sprite of V1 2C0-2C1 0704-0705 ^# ^ _^# D345 54085 Draw 08x05 at V3,V4; VF <- XOR 2C2-2C3 0706-0707 ^^^ _^# 7305 29445 V3 <- V3 + 005 2C4-2C5 0708-0709 ^^#^_ ^_ F229 61993 I <- digit sprite of V2 2C6-2C7 0710-0711 ^# ^ _^# D345 54085 Draw 08x05 at V3,V4; VF <- XOR 2C8-2C9 0712-0713 __ ^_ ^ 12C8 04808 self Jump to self 2CA 0714 #### F0 240 damage 2CB 0715 # 80 128 ball 2CC 0716 ######## FF 255 wall 2CD 0717 ######## FF 255 paddle 2CE-2CF 0718-0719 #_^___# A2DE 41694 draw free I <- fr 2D0-2D1 0720-0721 ^^_ _^# 6315 25365 V3 <- 021 2D2-2D3 0722-0723 ^^_ ^ 6210 25104 V2 <- 016 2D4-2D5 0724-0725 ^^_^ _^# D325 54053 Draw 08x05 at V3,V2; VF <- XOR 2D6-2D7 0726-0727 #_# #_ A2E3 41699 I <- ee 2D8-2D9 0728-0729 ^^___^# 631D 25373 V3 <- 029 2DA-2DB 0730-0731 ^^_^ _^# D325 54053 Draw 08x05 at V3,V2; VF <- XOR 2DC-2DD 0732-0733 _ _^_ # 12AA 04778 Jump to end 2DE 0734 ### ### EE 238 fr 2DF 0735 # # # 8A 138 2E0 0736 ## ### CE 206 2E1 0737 # ## 8C 140 2E2 0738 # # # 8A 138 2E3 0739 ### ### EE 238 ee 2E4 0740 # # 88 136 2E5 0741 ## ## CC 204 2E6 0742 # # 88 136 2E7 0743 ### ### EE 238 The register usage is as follows: V0 Contain horizontal coordinates to draw a row across the screen; contain the horizontal position of the paddle. V1 Contain vertical coordinates to draw a row on the screen; contain the vertical position of the paddle. V2 Contain the horizontal position of the ball; contain the vertical position of the free message. V3 Contain the vertical position of the ball; contain the horizontal position of the score and the free message. V4 Contain the horizontal movement of the ball; contain the vertical position of the score. V5 Contain the vertical movement of the ball. V6 Contain the score. V7 Contain the number of permitted tries. V8 Unused. V9 Unused. VA Contain the number of breakable rows; manipulating the sound register. VB Contain a count used to draw a row across the screen. VC Contain horizontal movement information for the paddle. VD Unused. VE Contain key codes for input. VF Contain unused input; collision detection. The game begins by drawing the walls; it does so by initializing registers one and ten and then begins a loop to draw each individual row by initializing registers zero and eleven: 200-201 0512-0513 #_^ __^ A2CC 41676 I <- wall 202-203 0514-0515 ^^ ^_# 6A06 27142 VA <- 006 204-205 0516-0517 ^^ _# 6103 24835 V1 <- 003 206-207 0518-0519 ^^ # ^^ 6B08 27400 start row VB <- 008 208-209 0520-0521 ^^ 6000 24576 V0 <- 000 This loop draws a single row of the walls: 20A-20B 0522-0523 ^^ # _ D011 53265 draw row Draw 08x01 at V0,V1; VF <- XOR 20C-20D 0524-0525 ^^^_ 7008 28680 V0 <- V0 + 008 20E-20F 0526-0527 _####_## 7BFF 31743 VB <- VB + 255 210-211 0528-0529 ^^^ ^^ 3B00 15104 Skip next if VB = 000 212-213 0530-0531 ^_ # 120A 04618 Jump to draw row Walls have space between them and this outer loop draws any remaining rows: 214-215 0532-0533 ^^^ _^ 7102 28930 V1 <- V1 + 002 216-217 0534-0535 _####_#_ 7AFF 31487 VA <- VA + 255 218-219 0536-0537 ^^^ ^ 3A00 14848 Skip next if VA = 000 21A-21B 0538-0539 ^ _# 1206 04614 Jump to start row The score and remaining tries are initialized and the paddle is put in place appropriately: 21C-21D 0540-0541 ^^ ^^ 6600 26112 V6 <- 000 21E-21F 0542-0543 ^^_ #^^ 6714 26388 V7 <- 020 220-221 0544-0545 #_^ __^_ A2CD 41677 I <- paddle 222-223 0546-0547 ^# 6020 24608 V0 <- 032 224-225 0548-0549 ^^____^ 611E 24862 V1 <- 030 226-227 0550-0551 ^^ # _ D011 53265 Draw 08x01 at V0,V1; VF <- XOR The ball's coordinates are initialized; note that the ball is always placed with horizontal coordinates equal to those of the paddle. A try is lost and a test is then done to determine if the game is finished. Lastly, the game hangs waiting for any key press, to begin: 228-229 0552-0553 ^^___^# 631D 25373 serve V3 <- 029 22A-22B 0554-0555 ^#___#_ 623F 25151 V2 <- 063 22C-22D 0556-0557 ^ # 8202 33282 V2 <- V2 AND V0 22E-22F 0558-0559 _###_### 77FF 30719 V7 <- V7 + 255 230-231 0560-0561 ^ ^^^ 4700 18176 Skip next if V7 <> 000 232-233 0562-0563 _ _^_ # 12AA 04778 Jump to end 234-235 0564-0565 ^^^^#^#^ FF0A 65290 VF <- key The ball is then drawn and set to go upwards, but left or right by chance. The ball moves in units of one: 236-237 0566-0567 #_^ _ #_ A2CB 41675 play I <- ball 238-239 0568-0569 ^^_# ^_ D231 53809 Draw 08x01 at V2,V3; VF <- XOR 23A-23B 0570-0571 _##__#_# 65FF 26111 V5 <- 255 23C-23D 0572-0573 ^^ ^ _ C401 50177 V4 <- ??? AND 001 23E-23F 0574-0575 ^^ ^ _ 3401 13313 Skip next if V4 = 001 240-241 0576-0577 _##__#__ 64FF 25855 V4 <- 255 Next, the paddle's horizontal delta is obtained by testing for keys four and six to move left and right, respectively. The paddle moves in units of two, meaning it moves twice as fast as the ball. In the case of neither key, there is no movement: 242-243 0578-0579 #_^ __^_ A2CD 41677 move I <- paddle 244-245 0580-0581 ^^ ^^ 6C00 27648 VC <- 000 246-247 0582-0583 ^^ ^#^ 6E04 28164 VE <- 004 248-249 0584-0585 #^# ^^^_ EEA1 61089 Skip next if VE <> key 24A-24B 0586-0587 _##_##_ 6CFE 27902 VC <- 254 24C-24D 0588-0589 ^^ ^## 6E06 28166 VE <- 006 24E-24F 0590-0591 #^# ^^^_ EEA1 61089 Skip next if VE <> key 250-251 0592-0593 ^^ ^^_ 6C02 27650 VC <- 002 The paddle is then drawn to erase it, the horizontal delta is added, and it is drawn in its new position: 252-253 0594-0595 ^^ # _ D011 53265 Draw 08x01 at V0,V1; VF <- XOR 254-255 0596-0597 #_ _ 80C4 32964 V0 <- V0 + VC; VF <- overflow 256-257 0598-0599 ^^ # _ D011 53265 Draw 08x01 at V0,V1; VF <- XOR If the paddle hit the ball, the hit routine is entered. It's noteworthy that 3F00, and so skipping if register fifteen was zero, would have been the better instruction to use here, as some CHIP-8 implementations don't necessarily return one under collision: 258-259 0600-0601 ^ ^^^# 4F01 20225 Skip next if VF <> 001 25A-25B 0602-0603 _ #_ ^ 1298 04760 Jump to hit The horizontal bounds of the ball are then checked and the horizontal delta is adjusted accordingly to send it towards the other: 25C-25D 0604-0605 ^ ^ 4200 16896 Skip next if V2 <> 000 25E-25F 0606-0607 ^^ ^ _ 6401 25601 V4 <- 001 260-261 0608-0609 ^____#_ 423F 16959 Skip next if V2 <> 063 262-263 0610-0611 _##__#__ 64FF 25855 V4 <- 255 The vertical bounds of the ball are then checked; if the ball titularly breaks out, the draw free routine is entered; if the ball goes to the sole row below the paddle, the dropped routine is entered, instead: 264-265 0612-0613 ^ ^^ 4300 17152 Skip next if V3 <> 000 266-267 0614-0615 __ ^__# 12CE 04814 Jump to draw free 268-269 0616-0617 ^ ___## 431F 17183 Skip next if V3 <> 031 26A-26B 0618-0619 _ _^ _^ 12A4 04772 Jump to dropped If neither case applies, the ball is then drawn to erase it, the deltas are added, and it is drawn in its new position: 26C-26D 0620-0621 #_^ _ #_ A2CB 41675 I <- ball 26E-26F 0622-0623 ^^_# ^_ D231 53809 Draw 08x01 at V2,V3; VF <- XOR 270-271 0624-0625 ^_ _^ 8244 33348 V2 <- V2 + V4; VF <- overflow 272-273 0626-0627 ^_ _ _^^ 8354 33620 V3 <- V3 + V5; VF <- overflow 274-275 0628-0629 ^^_# ^_ D231 53809 Draw 08x01 at V2,V3; VF <- XOR The ball is then checked for collision with the paddle, the game again checking for equivalence with one instead of unequality with zero. If there's no collision, the move routine is re-entered. If the vertical position of the ball is thirty, that means it hit the paddle and so the hit routine is entered: 276-277 0630-0631 ^^^^^# 3F01 16129 Skip next if VF = 001 278-279 0632-0633 _ ^ # 1242 04674 Jump to move 27A-27B 0634-0635 ^ ___#^ 431E 17182 Skip next if V3 <> 030 27C-27D 0636-0637 _ #_ ^ 1298 04760 Jump to hit If neither case applies, the ball hit a wall. A sound lasting 1/30 of a second is used, the score is incremented, and the game wastes space by jumping to the following instruction: 27E-27F 0638-0639 ^^ ^ # 6A02 27138 VA <- 002 280-281 0640-0641 ^^^## ^ FA18 64024 sound <- VA 282-283 0642-0643 ^^^ ^^_ 7601 30209 V6 <- V6 + 001 284-285 0644-0645 #_^ _ # A2CA 41674 I <- damage 286-287 0646-0647 _ ^_ ^ 1288 04744 Jump to next The damage to the wall is drawn where the ball is located. The horizontal delta of the ball is again randomly selected in the same manner; space could be saved by having this as a routine or arranging it where only one copy need exist: 288-289 0648-0649 ^^_# ^_ D231 53809 next Draw 08x01 at V2,V3; VF <- XOR 28A-28B 0650-0651 ^^ ^ _ C401 50177 V4 <- ??? AND 001 28C-28D 0652-0653 ^^ ^ _ 3401 13313 Skip next if V4 = 001 28E-28F 0654-0655 _##__#__ 64FF 25855 V4 <- 255 Register five is then wastefully set to one and the move routine is re-entered; unconditional flow would have made this easier to understand as being wastful: 290-291 0656-0657 ^^ ^ # C501 50433 V5 <- ??? AND 001 292-293 0658-0659 ^^ ^ # 3501 13569 Skip next if V5 = 001 294-295 0660-0661 ^^ ^ # 6501 25857 V5 <- 001 296-297 0662-0663 _ ^ # 1242 04674 Jump to move The hit routine sounds for 1/20 of a second, draws the ball to erase it, and adjusts the ball to be one higher before re-entering the play routine: 298-299 0664-0665 ^^ ^ #_ 6A03 27139 hit VA <- 003 29A-29B 0666-0667 ^^^## ^ FA18 64024 sound <- VA 29C-29D 0668-0669 #_^ _ #_ A2CB 41675 I <- ball 29E-29F 0670-0671 ^^_# ^_ D231 53809 Draw 08x01 at V2,V3; VF <- XOR 2A0-2A1 0672-0673 _###__## 73FF 29695 V3 <- V3 + 255 2A2-2A3 0674-0675 _# _# 1236 04662 Jump to play The dropped routine erases the ball and re-enters the serve routine to begin anew: 2A4-2A5 0676-0677 #_^ _ #_ A2CB 41675 dropped I <- ball 2A6-2A7 0678-0679 ^^_# ^_ D231 53809 Draw 08x01 at V2,V3; VF <- XOR 2A8-2A9 0680-0681 _^_ ^ 1228 04648 Jump to serve The end routine erases the paddle, uses an area a small ways beyond the program as scratch space, and displays the score in the middle of the screen before entering an infinite loop to finish: 2AA-2AB 0682-0683 #_^ __^_ A2CD 41677 end I <- paddle 2AC-2AD 0684-0685 ^^ # _ D011 53265 Draw 08x01 at V0,V1; VF <- XOR 2AE-2AF 0686-0687 #_#_ ^ A2F0 41712 I <- 0752 2B0-2B1 0688-0689 ^^## ^#_ F633 63027 V6 as BCD stored from I 2B2-2B3 0690-0691 ^##^ _^_ F265 62053 Load V0->V2; I <- I + 03 2B4-2B5 0692-0693 ^^__ ^^ 6318 25368 V3 <- 024 2B6-2B7 0694-0695 ^^__^__ 641B 25627 V4 <- 027 2B8-2B9 0696-0697 ^^#^_ _ F029 61481 I <- digit sprite of V0 2BA-2BB 0698-0699 ^# ^ _^# D345 54085 Draw 08x05 at V3,V4; VF <- XOR 2BC-2BD 0700-0701 ^^^ _^# 7305 29445 V3 <- V3 + 005 2BE-2BF 0702-0703 ^^#^_ # F129 61737 I <- digit sprite of V1 2C0-2C1 0704-0705 ^# ^ _^# D345 54085 Draw 08x05 at V3,V4; VF <- XOR 2C2-2C3 0706-0707 ^^^ _^# 7305 29445 V3 <- V3 + 005 2C4-2C5 0708-0709 ^^#^_ ^_ F229 61993 I <- digit sprite of V2 2C6-2C7 0710-0711 ^# ^ _^# D345 54085 Draw 08x05 at V3,V4; VF <- XOR 2C8-2C9 0712-0713 __ ^_ ^ 12C8 04808 self Jump to self The game is followed by the sprite data for damage, the ball, the wall, and the paddle. It is figured that the wall and paddle were made distinct to permit easy customization. It is noteworthy that space could be saved by drawing the entirety of the wall in one loop, with a repetitive and taller wall sprite, rather than two loops with the single high that is used; this would also permit easy customization of the wall pattern: 2CA 0714 #### F0 240 damage 2CB 0715 # 80 128 ball 2CC 0716 ######## FF 255 wall 2CD 0717 ######## FF 255 paddle The draw free routine is only entered if the player has won by freeing the ball. The word free is drawn to be placed above the score when the routine jumps to the end routine. It is noteworthy that the program could be made smaller by simply moving draw free to fall into end, instead: 2CE-2CF 0718-0719 #_^___# A2DE 41694 draw free I <- fr 2D0-2D1 0720-0721 ^^_ _^# 6315 25365 V3 <- 021 2D2-2D3 0722-0723 ^^_ ^ 6210 25104 V2 <- 016 2D4-2D5 0724-0725 ^^_^ _^# D325 54053 Draw 08x05 at V3,V2; VF <- XOR 2D6-2D7 0726-0727 #_# #_ A2E3 41699 I <- ee 2D8-2D9 0728-0729 ^^___^# 631D 25373 V3 <- 029 2DA-2DB 0730-0731 ^^_^ _^# D325 54053 Draw 08x05 at V3,V2; VF <- XOR 2DC-2DD 0732-0733 _ _^_ # 12AA 04778 Jump to end The game ends with the fr and ee sprites: 2DE 0734 ### ### EE 238 fr 2DF 0735 # # # 8A 138 2E0 0736 ## ### CE 206 2E1 0737 # ## 8C 140 2E2 0738 # # # 8A 138 2E3 0739 ### ### EE 238 ee 2E4 0740 # # 88 136 2E5 0741 ## ## CC 204 2E6 0742 # # 88 136 2E7 0743 ### ### EE 238 .