A Documenting of the Submarine CHIP-8 Game This is documentation for the submarine 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 █▄▀ ▄▄▀▄ A2CD 41677 I ← 0717 202-203 0514-0515 ▀█▄█ ▀ 6938 26936 V9 ← 056 204-205 0516-0517 ▀▀▄█▄█ 6A1E 27166 VA ← 030 206-207 0518-0519 █▀▄▀▀ ▄▀ D9A2 55714 Draw 08×02 at V9,VA; VF ← XOR 208-209 0520-0521 █▄▀▄ ▀ A2D0 41680 I ← 0720 20A-20B 0522-0523 ▀▀ ▀ ▀▀ 6B00 27392 VB ← 000 20C-20D 0524-0525 ▀▀▄█▀▄ 6C1A 27674 VC ← 026 20E-20F 0526-0527 ██ ▀▀ █▀ DBC2 56258 Draw 08×02 at VB,VC; VF ← XOR 210-211 0528-0529 █▄▀▄ ▄▀ A2D4 41684 I ← 0724 212-213 0530-0531 ▀█▄▄█ 643C 25660 V4 ← 060 214-215 0532-0533 ▀▀ ██ 6606 26118 V6 ← 006 216-217 0534-0535 ▀█▄▀ ▀▄▄ D463 54371 Draw 08×03 at V4,V6; VF ← XOR 218-219 0536-0537 ▀▀ ▀▀▀ 6700 26368 V7 ← 000 21A-21B 0538-0539 ▀▀▄█ ▄ 6819 26649 V8 ← 025 21C-21D 0540-0541 ▄ █ █ 22A2 08866 Call 0674 21E-21F 0542-0543 ▄ █ ▄▄▀ 22AC 08876 Call 0684 220-221 0544-0545 ▀ ▀ 4800 18432 Skip next if V8 <> 000 222-223 0546-0547 ▄▄ █▄ ▀ 12D8 04824 Jump to 0728 224-225 0548-0549 ▀▀ ▄▀ █ 6509 25865 V5 ← 009 226-227 0550-0551 █▄▀▄ ▄█▄ A2D7 41687 I ← 0727 228-229 0552-0553 ▀▀ ▀▀ 6300 25344 V3 ← 000 22A-22B 0554-0555 ▀▀ ▀█ █ 6D05 27909 VD ← 005 22C-22D 0556-0557 █▀█ ▀▀ █ EDA1 60833 Skip next if VD <> key 22E-22F 0558-0559 ▀▀ ▀█ 6301 25345 V3 ← 001 230-231 0560-0561 ▀▄ ▀▀▀ 8E40 36416 VE ← V4 232-233 0562-0563 █▀█ ▀▀ █ EDA1 60833 Skip next if VD <> key 234-235 0564-0565 ▀█ █▀▀▀▄ DE51 56913 Draw 08×01 at VE,V5; VF ← XOR 236-237 0566-0567 ▄█▄▄▀ 123C 04668 Jump to 0572 238-239 0568-0569 █▀█ ▀▀ █ EDA1 60833 Skip next if VD <> key 23A-23B 0570-0571 ▄▄▀▄▄ ▀ 22D8 08920 Call 0728 23C-23D 0572-0573 █▄▀▄ ▄▀ A2D4 41684 I ← 0724 23E-23F 0574-0575 ▀█▄▀ ▀▄▄ D463 54371 Draw 08×03 at V4,V6; VF ← XOR 240-241 0576-0577 ▄ ▀ █ 1242 04674 Jump to 0578 242-243 0578-0579 ▄███▄█▄▄ 74FF 29951 V4 ← V4 + 255 244-245 0580-0581 ▀█▄▀ ▀▄▄ D463 54371 Draw 08×03 at V4,V6; VF ← XOR 246-247 0582-0583 █▄▀▄ ▀ A2D0 41680 I ← 0720 248-249 0584-0585 ██ ▀▀ █▀ DBC2 56258 Draw 08×02 at VB,VC; VF ← XOR 24A-24B 0586-0587 ▀▀ ▀█ ▀ CD04 52484 VD ← ??? AND 004 24C-24D 0588-0589 █▄ ▄▀▄▀▀ 8BD4 35796 VB ← VB + VD; VF ← overflow 24E-24F 0590-0591 ██ ▀▀ █▀ DBC2 56258 Draw 08×02 at VB,VC; VF ← XOR 250-251 0592-0593 ▀▀▀▀▀▀ 3F00 16128 Skip next if VF = 000 252-253 0594-0595 ▄ █ █ 1292 04754 Jump to 0658 254-255 0596-0597 █▄▀ ▄▄▀▄ A2CD 41677 I ← 0717 256-257 0598-0599 █▀▄▀▀ ▄▀ D9A2 55714 Draw 08×02 at V9,VA; VF ← XOR 258-259 0600-0601 ▀▀ ▀█▄█ CD07 52487 VD ← ??? AND 007 25A-25B 0602-0603 ▀ ▀▀ ▀ 4D00 19712 Skip next if VD <> 000 25C-25D 0604-0605 ▀▀▀▀ ▄█ 7903 30979 V9 ← V9 + 003 25E-25F 0606-0607 ▄████▄ █ 79FD 31229 V9 ← V9 + 253 260-261 0608-0609 █▀▄▀▀ ▄▀ D9A2 55714 Draw 08×02 at V9,VA; VF ← XOR 262-263 0610-0611 ▀▀▀▀▀▀ 3F00 16128 Skip next if VF = 000 264-265 0612-0613 ▄ ▀▄▄▀ 128C 04748 Jump to 0652 266-267 0614-0615 ▀ ▀▀ 4300 17152 Skip next if V3 <> 000 268-269 0616-0617 ▄▀▄ █ 122A 04650 Jump to 0554 26A-26B 0618-0619 █▄▀▄ ▄█▄ A2D7 41687 I ← 0727 26C-26D 0620-0621 ▀█ █▀▀▀▄ DE51 56913 Draw 08×01 at VE,V5; VF ← XOR 26E-26F 0622-0623 ▀ ▄▄█▄█ 451F 17695 Skip next if V5 <> 031 270-271 0624-0625 ▄ ▀ ▄█ 1286 04742 Jump to 0646 272-273 0626-0627 ▀▀▀ ▀▄▀ 7502 29954 V5 ← V5 + 002 274-275 0628-0629 ▀▀▀█▄ ▀▀ F318 62232 sound ← V3 276-277 0630-0631 ▀█ █▀▀▀▄ DE51 56913 Draw 08×01 at VE,V5; VF ← XOR 278-279 0632-0633 ▀▀▀▀▀█ 3F01 16129 Skip next if VF = 001 27A-27B 0634-0635 ▄█▄▄▀ 123C 04668 Jump to 0572 27C-27D 0636-0637 ▀▀▄██▄█ 6D1F 27935 VD ← 031 27E-27F 0638-0639 ▀▄ ▄▀▀▄▀ 8D52 36178 VD ← VD AND V5 280-281 0640-0641 ▀ ▄██▄█ 4D1F 19743 Skip next if VD <> 031 282-283 0642-0643 ▄ ▀▄▄▀ 128C 04748 Jump to 0652 284-285 0644-0645 ▄ █ █ 1292 04754 Jump to 0658 286-287 0646-0647 ▄ █ ▄▄▀ 22AC 08876 Call 0684 288-289 0648-0649 ▄████▄▄▄ 78FF 30975 V8 ← V8 + 255 28A-28B 0650-0651 █▄▄█ 121E 04638 Jump to 0542 28C-28D 0652-0653 ▄ █ █ 22A2 08866 Call 0674 28E-28F 0654-0655 ▀▀▀ █▀█ 7705 30469 V7 ← V7 + 005 290-291 0656-0657 ▄ █ ▄█ 1296 04758 Jump to 0662 292-293 0658-0659 ▄ █ █ 22A2 08866 Call 0674 294-295 0660-0661 ▀▀▀▄▀█▀ 770A 30474 V7 ← V7 + 010 296-297 0662-0663 ▄ █ █ 22A2 08866 Call 0674 298-299 0664-0665 ▀▀ ▀▀▄█ 6D03 27907 VD ← 003 29A-29B 0666-0667 ▀▀▀██▀ ▀ FD18 64792 sound ← VD 29C-29D 0668-0669 █▄▀▄ ▄█▄ A2D7 41687 I ← 0727 29E-29F 0670-0671 ▀█ █▀▀▀▄ DE51 56913 Draw 08×01 at VE,V5; VF ← XOR 2A0-2A1 0672-0673 ▄ ▀ ▄█ 1286 04742 Jump to 0646 2A2-2A3 0674-0675 █▄█▄▄ ▀ A2F8 41720 I ← 0760 2A4-2A5 0676-0677 ▀▀██ ▀██ F733 63283 V7 as BCD stored from I 2A6-2A7 0678-0679 ▀▀ ▀▀ 6300 25344 V3 ← 000 2A8-2A9 0680-0681 ▄ █▄ ▄█ 22B6 08886 Call 0694 2AA-2AB 0682-0683 ▄▄▄ ▄▄▄ 00EE 00238 Return 2AC-2AD 0684-0685 █▄█▄▄ ▀ A2F8 41720 I ← 0760 2AE-2AF 0686-0687 ▀▀██▀ ▄▄ F833 63539 V8 as BCD stored from I 2B0-2B1 0688-0689 ▀█▄ █▀ 6332 25394 V3 ← 050 2B2-2B3 0690-0691 ▄ █▄ ▄█ 22B6 08886 Call 0694 2B4-2B5 0692-0693 ▄▄▄ ▄▄▄ 00EE 00238 Return 2B6-2B7 0694-0695 ▀▀ ▀▀ ▀ 6D00 27904 VD ← 000 2B8-2B9 0696-0697 ▀██▀ ▄▀▄ F265 62053 Load V0→V2; I ← I + 03 2BA-2BB 0698-0699 ▀▀█▀▄ ▄ F029 61481 I ← digit sprite of V0 2BC-2BD 0700-0701 ██ █ ▄▀█ D3D5 54229 Draw 08×05 at V3,VD; VF ← XOR 2BE-2BF 0702-0703 ▀▀▀ ▄▀█ 7305 29445 V3 ← V3 + 005 2C0-2C1 0704-0705 ▀▀█▀▄ █ F129 61737 I ← digit sprite of V1 2C2-2C3 0706-0707 ██ █ ▄▀█ D3D5 54229 Draw 08×05 at V3,VD; VF ← XOR 2C4-2C5 0708-0709 ▀▀▀ ▄▀█ 7305 29445 V3 ← V3 + 005 2C6-2C7 0710-0711 ▀▀█▀▄ ▀▄ F229 61993 I ← digit sprite of V2 2C8-2C9 0712-0713 ██ █ ▄▀█ D3D5 54229 Draw 08×05 at V3,VD; VF ← XOR 2CA-2CB 0714-0715 ▄▄▄ ▄▄▄ 00EE 00238 Return 2CC-2CD 0716-0717 ▄ ▀ 0108 00264 Jump to COSMAC VIP 0264 2CE-2CF 0718-0719 █████▀▀ 7F7C 32636 VF ← VF + 124 2D0-2D1 0720-0721 ▄▄█▄▄ 083E 02110 Jump to COSMAC VIP 2110 2D2-2D3 0722-0723 ▀▀ ▄ 6008 24584 V0 ← 008 2D4-2D5 0724-0725 ▄██▄ 183C 06204 Jump to 2108 2D6-2D7 0726-0727 ▀▀▀▀█▀▀▀ FF08 65288 2D8-2D9 0728-0729 ▀ ▀ ▀▀ A300 41728 I ← 0768 2DA-2DB 0730-0731 ▀▀▄ ▀█ 6311 25361 V3 ← 017 2DC-2DD 0732-0733 ▀▀ █▀▄█ 6D0B 27915 VD ← 011 2DE-2DF 0734-0735 ██ █ ▄▀█ D3D5 54229 Draw 08×05 at V3,VD; VF ← XOR 2E0-2E1 0736-0737 ▀ ▀ ▄▀█ A305 41733 I ← 0773 2E2-2E3 0738-0739 ▀▀▄▄ ▀█ 6319 25369 V3 ← 025 2E4-2E5 0740-0741 ██ █ ▄▀█ D3D5 54229 Draw 08×05 at V3,VD; VF ← XOR 2E6-2E7 0742-0743 ▀ ▀ ▄ █▀ A30A 41738 I ← 0778 2E8-2E9 0744-0745 ▀█ ██ 6323 25379 V3 ← 035 2EA-2EB 0746-0747 ██ █ ▄▀█ D3D5 54229 Draw 08×05 at V3,VD; VF ← XOR 2EC-2ED 0748-0749 ▀ ▀ ▄▄██ A30F 41743 I ← 0783 2EE-2EF 0750-0751 ▀█ ▄ ██ 632B 25387 V3 ← 043 2F0-2F1 0752-0753 ██ █ ▄▀█ D3D5 54229 Draw 08×05 at V3,VD; VF ← XOR 2F2-2F3 0754-0755 ▀▀ ▀▀ 6300 25344 V3 ← 000 2F4-2F5 0756-0757 ▄▄▄█ ▄▀ 12F4 04852 Jump to 0756 2F6-2F7 0758-0759 ▀▀ █▀▄█ 6D0B 27915 VD ← 011 2F8-2F9 0760-0761 ▄ 0001 00001 Jump to COSMAC VIP 0001 2FA-2FB 0762-0763 ▀ 0400 01024 Jump to COSMAC VIP 1024 2FC-2FD 0764-0765 ▄▄▄ ▄▄▄ 00EE 00238 Return 2FE-2FF 0766-0767 ▄ 0001 00001 Jump to COSMAC VIP 0001 300-301 0768-0769 █▀▀ █▀█ EE8A 61066 302-303 0770-0771 █ ▄ █ █ 8AAA 35498 304-305 0772-0773 ███ ███▄ EEEF 61167 306-307 0774-0775 █ █ █ █ A5A5 42405 I ← 1445 308-309 0776-0777 █▄█ ▄█▄█ A5EF 42479 I ← 1519 30A-30B 0778-0779 ▀█▀█ █ 7A2A 31274 VA ← VA + 042 30C-30D 0780-0781 █▀█ ▀█ 3B29 15145 Skip next if VB = 041 30E-30F 0782-0783 ▄▀███ ▄▀ 79BA 31162 V9 ← V9 + 186 310-311 0784-0785 █ █▄ █ A2B2 41650 I ← 0690 312-313 0786-0787 █▄▄ ▄ 203A 08250 Call 0058 314-315 0788-0789 ██▄▀▄ 343A 13370 Skip next if V4 = 058 316-317 0790-0791 ▄▄▀█▀█▄ 3CD6 15574 Skip next if VC = 214 318-319 0792-0793 ▀ █▄█ 541C 21532 31A-31B 0794-0795 ▄ ▀▀ 0C40 03136 Jump to COSMAC VIP 3136 31C-31D 0796-0797 ▀ ▄▀▀█▀▄ 9E25 40485 31E-31F 0798-0799 ▀▀ █▄ 680C 26636 V8 ← 012 Follows now is the fully annotated view of the program when it is loaded into the tool: 200-201 0512-0513 █▄▀ ▄▄▀▄ A2CD 41677 I ← big enemy 202-203 0514-0515 ▀█▄█ ▀ 6938 26936 V9 ← 056 204-205 0516-0517 ▀▀▄█▄█ 6A1E 27166 VA ← 030 206-207 0518-0519 █▀▄▀▀ ▄▀ D9A2 55714 Draw 08×02 at V9,VA; VF ← XOR 208-209 0520-0521 █▄▀▄ ▀ A2D0 41680 I ← small enemy 20A-20B 0522-0523 ▀▀ ▀ ▀▀ 6B00 27392 VB ← 000 20C-20D 0524-0525 ▀▀▄█▀▄ 6C1A 27674 VC ← 026 20E-20F 0526-0527 ██ ▀▀ █▀ DBC2 56258 Draw 08×02 at VB,VC; VF ← XOR 210-211 0528-0529 █▄▀▄ ▄▀ A2D4 41684 I ← you 212-213 0530-0531 ▀█▄▄█ 643C 25660 V4 ← 060 214-215 0532-0533 ▀▀ ██ 6606 26118 V6 ← 006 216-217 0534-0535 ▀█▄▀ ▀▄▄ D463 54371 Draw 08×03 at V4,V6; VF ← XOR 218-219 0536-0537 ▀▀ ▀▀▀ 6700 26368 V7 ← 000 21A-21B 0538-0539 ▀▀▄█ ▄ 6819 26649 V8 ← 025 21C-21D 0540-0541 ▄ █ █ 22A2 08866 Call show score 21E-21F 0542-0543 ▄ █ ▄▄▀ 22AC 08876 start Call show count 220-221 0544-0545 ▀ ▀ 4800 18432 Skip next if V8 <> 000 222-223 0546-0547 ▄▄ █▄ ▀ 12D8 04824 Jump to end 224-225 0548-0549 ▀▀ ▄▀ █ 6509 25865 V5 ← 009 226-227 0550-0551 █▄▀▄ ▄█▄ A2D7 41687 I ← bomb 228-229 0552-0553 ▀▀ ▀▀ 6300 25344 V3 ← 000 22A-22B 0554-0555 ▀▀ ▀█ █ 6D05 27909 control VD ← 005 22C-22D 0556-0557 █▀█ ▀▀ █ EDA1 60833 Skip next if VD <> key 22E-22F 0558-0559 ▀▀ ▀█ 6301 25345 V3 ← 001 230-231 0560-0561 ▀▄ ▀▀▀ 8E40 36416 VE ← V4 232-233 0562-0563 █▀█ ▀▀ █ EDA1 60833 Skip next if VD <> key 234-235 0564-0565 ▀█ █▀▀▀▄ DE51 56913 Draw 08×01 at VE,V5; VF ← XOR 236-237 0566-0567 ▄█▄▄▀ 123C 04668 Jump to prime 238-239 0568-0569 █▀█ ▀▀ █ EDA1 60833 skipped Skip next if VD <> key 23A-23B 0570-0571 ▄▄▀▄▄ ▀ 22D8 08920 also skipped Call end 23C-23D 0572-0573 █▄▀▄ ▄▀ A2D4 41684 prime I ← you 23E-23F 0574-0575 ▀█▄▀ ▀▄▄ D463 54371 Draw 08×03 at V4,V6; VF ← XOR 240-241 0576-0577 ▄ ▀ █ 1242 04674 Jump to next 242-243 0578-0579 ▄███▄█▄▄ 74FF 29951 next V4 ← V4 + 255 244-245 0580-0581 ▀█▄▀ ▀▄▄ D463 54371 Draw 08×03 at V4,V6; VF ← XOR 246-247 0582-0583 █▄▀▄ ▀ A2D0 41680 I ← small enemy 248-249 0584-0585 ██ ▀▀ █▀ DBC2 56258 Draw 08×02 at VB,VC; VF ← XOR 24A-24B 0586-0587 ▀▀ ▀█ ▀ CD04 52484 VD ← ??? AND 004 24C-24D 0588-0589 █▄ ▄▀▄▀▀ 8BD4 35796 VB ← VB + VD; VF ← overflow 24E-24F 0590-0591 ██ ▀▀ █▀ DBC2 56258 Draw 08×02 at VB,VC; VF ← XOR 250-251 0592-0593 ▀▀▀▀▀▀ 3F00 16128 Skip next if VF = 000 252-253 0594-0595 ▄ █ █ 1292 04754 Jump to small hit 254-255 0596-0597 █▄▀ ▄▄▀▄ A2CD 41677 I ← big enemy 256-257 0598-0599 █▀▄▀▀ ▄▀ D9A2 55714 Draw 08×02 at V9,VA; VF ← XOR 258-259 0600-0601 ▀▀ ▀█▄█ CD07 52487 VD ← ??? AND 007 25A-25B 0602-0603 ▀ ▀▀ ▀ 4D00 19712 Skip next if VD <> 000 25C-25D 0604-0605 ▀▀▀▀ ▄█ 7903 30979 V9 ← V9 + 003 25E-25F 0606-0607 ▄████▄ █ 79FD 31229 V9 ← V9 + 253 260-261 0608-0609 █▀▄▀▀ ▄▀ D9A2 55714 Draw 08×02 at V9,VA; VF ← XOR 262-263 0610-0611 ▀▀▀▀▀▀ 3F00 16128 Skip next if VF = 000 264-265 0612-0613 ▄ ▀▄▄▀ 128C 04748 Jump to big hit 266-267 0614-0615 ▀ ▀▀ 4300 17152 Skip next if V3 <> 000 268-269 0616-0617 ▄▀▄ █ 122A 04650 Jump to control 26A-26B 0618-0619 █▄▀▄ ▄█▄ A2D7 41687 I ← bomb 26C-26D 0620-0621 ▀█ █▀▀▀▄ DE51 56913 Draw 08×01 at VE,V5; VF ← XOR 26E-26F 0622-0623 ▀ ▄▄█▄█ 451F 17695 Skip next if V5 <> 031 270-271 0624-0625 ▄ ▀ ▄█ 1286 04742 Jump to decrease 272-273 0626-0627 ▀▀▀ ▀▄▀ 7502 29954 V5 ← V5 + 002 274-275 0628-0629 ▀▀▀█▄ ▀▀ F318 62232 sound ← V3 276-277 0630-0631 ▀█ █▀▀▀▄ DE51 56913 Draw 08×01 at VE,V5; VF ← XOR 278-279 0632-0633 ▀▀▀▀▀█ 3F01 16129 Skip next if VF = 001 27A-27B 0634-0635 ▄█▄▄▀ 123C 04668 Jump to prime 27C-27D 0636-0637 ▀▀▄██▄█ 6D1F 27935 VD ← 031 27E-27F 0638-0639 ▀▄ ▄▀▀▄▀ 8D52 36178 VD ← VD AND V5 280-281 0640-0641 ▀ ▄██▄█ 4D1F 19743 Skip next if VD <> 031 282-283 0642-0643 ▄ ▀▄▄▀ 128C 04748 Jump to big hit 284-285 0644-0645 ▄ █ █ 1292 04754 Jump to small hit 286-287 0646-0647 ▄ █ ▄▄▀ 22AC 08876 decrease Call show count 288-289 0648-0649 ▄████▄▄▄ 78FF 30975 V8 ← V8 + 255 28A-28B 0650-0651 █▄▄█ 121E 04638 Jump to start 28C-28D 0652-0653 ▄ █ █ 22A2 08866 big hit Call show score 28E-28F 0654-0655 ▀▀▀ █▀█ 7705 30469 V7 ← V7 + 005 290-291 0656-0657 ▄ █ ▄█ 1296 04758 Jump to shared 292-293 0658-0659 ▄ █ █ 22A2 08866 small hit Call show score 294-295 0660-0661 ▀▀▀▄▀█▀ 770A 30474 V7 ← V7 + 010 296-297 0662-0663 ▄ █ █ 22A2 08866 shared Call show score 298-299 0664-0665 ▀▀ ▀▀▄█ 6D03 27907 VD ← 003 29A-29B 0666-0667 ▀▀▀██▀ ▀ FD18 64792 sound ← VD 29C-29D 0668-0669 █▄▀▄ ▄█▄ A2D7 41687 I ← bomb 29E-29F 0670-0671 ▀█ █▀▀▀▄ DE51 56913 Draw 08×01 at VE,V5; VF ← XOR 2A0-2A1 0672-0673 ▄ ▀ ▄█ 1286 04742 Jump to decrease 2A2-2A3 0674-0675 █▄█▄▄ ▀ A2F8 41720 show score I ← scratch 2A4-2A5 0676-0677 ▀▀██ ▀██ F733 63283 V7 as BCD stored from I 2A6-2A7 0678-0679 ▀▀ ▀▀ 6300 25344 V3 ← 000 2A8-2A9 0680-0681 ▄ █▄ ▄█ 22B6 08886 Call show 2AA-2AB 0682-0683 ▄▄▄ ▄▄▄ 00EE 00238 Return 2AC-2AD 0684-0685 █▄█▄▄ ▀ A2F8 41720 show count I ← scratch 2AE-2AF 0686-0687 ▀▀██▀ ▄▄ F833 63539 V8 as BCD stored from I 2B0-2B1 0688-0689 ▀█▄ █▀ 6332 25394 V3 ← 050 2B2-2B3 0690-0691 ▄ █▄ ▄█ 22B6 08886 Call show 2B4-2B5 0692-0693 ▄▄▄ ▄▄▄ 00EE 00238 Return 2B6-2B7 0694-0695 ▀▀ ▀▀ ▀ 6D00 27904 show VD ← 000 2B8-2B9 0696-0697 ▀██▀ ▄▀▄ F265 62053 Load V0→V2; I ← I + 03 2BA-2BB 0698-0699 ▀▀█▀▄ ▄ F029 61481 I ← digit sprite of V0 2BC-2BD 0700-0701 ██ █ ▄▀█ D3D5 54229 Draw 08×05 at V3,VD; VF ← XOR 2BE-2BF 0702-0703 ▀▀▀ ▄▀█ 7305 29445 V3 ← V3 + 005 2C0-2C1 0704-0705 ▀▀█▀▄ █ F129 61737 I ← digit sprite of V1 2C2-2C3 0706-0707 ██ █ ▄▀█ D3D5 54229 Draw 08×05 at V3,VD; VF ← XOR 2C4-2C5 0708-0709 ▀▀▀ ▄▀█ 7305 29445 V3 ← V3 + 005 2C6-2C7 0710-0711 ▀▀█▀▄ ▀▄ F229 61993 I ← digit sprite of V2 2C8-2C9 0712-0713 ██ █ ▄▀█ D3D5 54229 Draw 08×05 at V3,VD; VF ← XOR 2CA-2CB 0714-0715 ▄▄▄ ▄▄▄ 00EE 00238 Return 2CC 0716 █ 01 001 2CD 0717 █ 08 008 big enemy 2CE 0718 ███████ 7F 127 2CF 0719 █████ 7C 124 2D0 0720 █ 08 008 small enemy 2D1 0721 █████ 3E 062 2D2 0722 ██ 60 096 2D3 0723 █ 08 008 2D4 0724 ██ 18 024 you 2D5 0725 ████ 3C 060 2D6 0726 ████████ FF 255 2D7 0727 █ 08 008 bomb 2D8-2D9 0728-0729 ▀ ▀ ▀▀ A300 41728 end I ← go 2DA-2DB 0730-0731 ▀▀▄ ▀█ 6311 25361 V3 ← 017 2DC-2DD 0732-0733 ▀▀ █▀▄█ 6D0B 27915 VD ← 011 2DE-2DF 0734-0735 ██ █ ▄▀█ D3D5 54229 Draw 08×05 at V3,VD; VF ← XOR 2E0-2E1 0736-0737 ▀ ▀ ▄▀█ A305 41733 I ← od 2E2-2E3 0738-0739 ▀▀▄▄ ▀█ 6319 25369 V3 ← 025 2E4-2E5 0740-0741 ██ █ ▄▀█ D3D5 54229 Draw 08×05 at V3,VD; VF ← XOR 2E6-2E7 0742-0743 ▀ ▀ ▄ █▀ A30A 41738 I ← by 2E8-2E9 0744-0745 ▀█ ██ 6323 25379 V3 ← 035 2EA-2EB 0746-0747 ██ █ ▄▀█ D3D5 54229 Draw 08×05 at V3,VD; VF ← XOR 2EC-2ED 0748-0749 ▀ ▀ ▄▄██ A30F 41743 I ← e! 2EE-2EF 0750-0751 ▀█ ▄ ██ 632B 25387 V3 ← 043 2F0-2F1 0752-0753 ██ █ ▄▀█ D3D5 54229 Draw 08×05 at V3,VD; VF ← XOR 2F2-2F3 0754-0755 ▀▀ ▀▀ 6300 25344 V3 ← 000 2F4-2F5 0756-0757 ▄▄▄█ ▄▀ 12F4 04852 self Jump to self 2F6 0758 ██ ██ █ 6D 109 2F7 0759 █ ██ 0B 011 2F8 0760 00 000 scratch 2F9 0761 █ 01 001 2FA 0762 █ 04 004 2FB 0763 00 000 2FC 0764 00 000 2FD 0765 ███ ███ EE 238 2FE 0766 00 000 2FF 0767 █ 01 001 300 0768 ███ ███ EE 238 go 301 0769 █ █ █ 8A 138 302 0770 █ █ █ 8A 138 303 0771 █ █ █ █ AA 170 304 0772 ███ ███ EE 238 305 0773 ███ ████ EF 239 od 306 0774 █ █ █ █ A5 165 307 0775 █ █ █ █ A5 165 308 0776 █ █ █ █ A5 165 309 0777 ███ ████ EF 239 30A 0778 ████ █ 7A 122 by 30B 0779 █ █ █ 2A 042 30C 0780 ███ ██ 3B 059 30D 0781 █ █ █ 29 041 30E 0782 ████ █ 79 121 30F 0783 █ ███ █ BA 186 e! 310 0784 █ █ █ A2 162 311 0785 █ ██ █ B2 178 312 0786 █ 20 032 313 0787 ███ █ 3A 058 314 0788 ██ █ 34 052 315 0789 ███ █ 3A 058 316 0790 ████ 3C 060 317 0791 ██ █ ██ D6 214 318 0792 █ █ █ 54 084 319 0793 ███ 1C 028 31A 0794 ██ 0C 012 31B 0795 █ 40 064 31C 0796 █ ████ 9E 158 31D 0797 █ █ █ 25 037 31E 0798 ██ █ 68 104 31F 0799 ██ 0C 012 The register usage is as follows: V0 Load from I and then BCD display. V1 Load from I and then BCD display. V2 Load from I and then BCD display. V3 Flag to indicate key press; horizontal positioning of BCD and ending sprites. Manipulate the sound register. V4 Horizontal positioning of you sprite. V5 Vertical positioning of bomb sprite. V6 Vertical positioning of you sprite. V7 Store the score. V8 Store the bomb count. V9 Horizontal positioning of big enemy sprite. VA Vertical positioning of big enemy sprite. VB Horizontal positioning of small enemy sprite. VC Vertical positioning of big enemy sprite. VD Store a key and the enemy movement delta. VE Horizontal positioning of bomb sprite. VF Collision detection. The game begins by drawing the big enemy sprite in the lower right corner of the screen: 200-201 0512-0513 █▄▀ ▄▄▀▄ A2CD 41677 I ← big enemy 202-203 0514-0515 ▀█▄█ ▀ 6938 26936 V9 ← 056 204-205 0516-0517 ▀▀▄█▄█ 6A1E 27166 VA ← 030 206-207 0518-0519 █▀▄▀▀ ▄▀ D9A2 55714 Draw 08×02 at V9,VA; VF ← XOR Then the small enemy sprite is drawn in the lower left corner. Note that these sprites are drawn at different heights; this is to simplify collision detection: 208-209 0520-0521 █▄▀▄ ▀ A2D0 41680 I ← small enemy 20A-20B 0522-0523 ▀▀ ▀ ▀▀ 6B00 27392 VB ← 000 20C-20D 0524-0525 ▀▀▄█▀▄ 6C1A 27674 VC ← 026 20E-20F 0526-0527 ██ ▀▀ █▀ DBC2 56258 Draw 08×02 at VB,VC; VF ← XOR Following that, the you sprite, representing the player's submarine, is drawn at the top right corner of the screen, clipped by the right edge: 210-211 0528-0529 █▄▀▄ ▄▀ A2D4 41684 I ← you 212-213 0530-0531 ▀█▄▄█ 643C 25660 V4 ← 060 214-215 0532-0533 ▀▀ ██ 6606 26118 V6 ← 006 216-217 0534-0535 ▀█▄▀ ▀▄▄ D463 54371 Draw 08×03 at V4,V6; VF ← XOR The score and bomb counts are then initialized and the score is displayed: 218-219 0536-0537 ▀▀ ▀▀▀ 6700 26368 V7 ← 000 21A-21B 0538-0539 ▀▀▄█ ▄ 6819 26649 V8 ← 025 21C-21D 0540-0541 ▄ █ █ 22A2 08866 Call show score Now is the starting loop of the game, which starts by showing the bomb count and ends the game if this is zero by calling the end routine: 21E-21F 0542-0543 ▄ █ ▄▄▀ 22AC 08876 start Call show count 220-221 0544-0545 ▀ ▀ 4800 18432 Skip next if V8 <> 000 222-223 0546-0547 ▄▄ █▄ ▀ 12D8 04824 Jump to end Registers are initialized for displaying the bomb sprite below the submarine and storing the input flag: 224-225 0548-0549 ▀▀ ▄▀ █ 6509 25865 V5 ← 009 226-227 0550-0551 █▄▀▄ ▄█▄ A2D7 41687 I ← bomb 228-229 0552-0553 ▀▀ ▀▀ 6300 25344 V3 ← 000 Then the input is tested for, setting a flag and displaying the bomb if so. It's noteworthy that this depends on both tests triggering for a single key press; a better way would have used only one test and collected the conditional code into a single segment: 22A-22B 0554-0555 ▀▀ ▀█ █ 6D05 27909 control VD ← 005 22C-22D 0556-0557 █▀█ ▀▀ █ EDA1 60833 Skip next if VD <> key 22E-22F 0558-0559 ▀▀ ▀█ 6301 25345 V3 ← 001 230-231 0560-0561 ▀▄ ▀▀▀ 8E40 36416 VE ← V4 232-233 0562-0563 █▀█ ▀▀ █ EDA1 60833 Skip next if VD <> key 234-235 0564-0565 ▀█ █▀▀▀▄ DE51 56913 Draw 08×01 at VE,V5; VF ← XOR 236-237 0566-0567 ▄█▄▄▀ 123C 04668 Jump to prime These instructions are superfluous: 238-239 0568-0569 █▀█ ▀▀ █ EDA1 60833 skipped Skip next if VD <> key 23A-23B 0570-0571 ▄▄▀▄▄ ▀ 22D8 08920 also skipped Call end Now is the prime loop of the game, moving the player's submarine along first, with a superfluous jump instruction: 23C-23D 0572-0573 █▄▀▄ ▄▀ A2D4 41684 prime I ← you 23E-23F 0574-0575 ▀█▄▀ ▀▄▄ D463 54371 Draw 08×03 at V4,V6; VF ← XOR 240-241 0576-0577 ▄ ▀ █ 1242 04674 Jump to next 242-243 0578-0579 ▄███▄█▄▄ 74FF 29951 next V4 ← V4 + 255 244-245 0580-0581 ▀█▄▀ ▀▄▄ D463 54371 Draw 08×03 at V4,V6; VF ← XOR Next the small enemy is moved a small and random amount to the right: 246-247 0582-0583 █▄▀▄ ▀ A2D0 41680 I ← small enemy 248-249 0584-0585 ██ ▀▀ █▀ DBC2 56258 Draw 08×02 at VB,VC; VF ← XOR 24A-24B 0586-0587 ▀▀ ▀█ ▀ CD04 52484 VD ← ??? AND 004 24C-24D 0588-0589 █▄ ▄▀▄▀▀ 8BD4 35796 VB ← VB + VD; VF ← overflow 24E-24F 0590-0591 ██ ▀▀ █▀ DBC2 56258 Draw 08×02 at VB,VC; VF ← XOR If the bomb has now struck the small enemy, the small hit routine is entered to adjust the score and whatnot. Note this is a simple check because of the differing verticals used for the enemies: 250-251 0592-0593 ▀▀▀▀▀▀ 3F00 16128 Skip next if VF = 000 252-253 0594-0595 ▄ █ █ 1292 04754 Jump to small hit Next the big enemy is moved a small and random amount, with a 1/8 chance of moving to the right and a 7/8 chance of moving to the left a larger amount: 254-255 0596-0597 █▄▀ ▄▄▀▄ A2CD 41677 I ← big enemy 256-257 0598-0599 █▀▄▀▀ ▄▀ D9A2 55714 Draw 08×02 at V9,VA; VF ← XOR 258-259 0600-0601 ▀▀ ▀█▄█ CD07 52487 VD ← ??? AND 007 25A-25B 0602-0603 ▀ ▀▀ ▀ 4D00 19712 Skip next if VD <> 000 25C-25D 0604-0605 ▀▀▀▀ ▄█ 7903 30979 V9 ← V9 + 003 25E-25F 0606-0607 ▄████▄ █ 79FD 31229 V9 ← V9 + 253 260-261 0608-0609 █▀▄▀▀ ▄▀ D9A2 55714 Draw 08×02 at V9,VA; VF ← XOR The collision detection is the same as for the small enemy, but transferring to a different hit routine: 262-263 0610-0611 ▀▀▀▀▀▀ 3F00 16128 Skip next if VF = 000 264-265 0612-0613 ▄ ▀▄▄▀ 128C 04748 Jump to big hit If a bomb has not yet been dropped, then the player may still give a command to do so: 266-267 0614-0615 ▀ ▀▀ 4300 17152 Skip next if V3 <> 000 268-269 0616-0617 ▄▀▄ █ 122A 04650 Jump to control If a bomb is active, then its position is now adjusted at a constant rate and with sound lasting 1/60 of a second. When a bomb reaches the bottom of the screen, that means it's failed to hit any enemies and the count is then decreased: 26A-26B 0618-0619 █▄▀▄ ▄█▄ A2D7 41687 I ← bomb 26C-26D 0620-0621 ▀█ █▀▀▀▄ DE51 56913 Draw 08×01 at VE,V5; VF ← XOR 26E-26F 0622-0623 ▀ ▄▄█▄█ 451F 17695 Skip next if V5 <> 031 270-271 0624-0625 ▄ ▀ ▄█ 1286 04742 Jump to decrease 272-273 0626-0627 ▀▀▀ ▀▄▀ 7502 29954 V5 ← V5 + 002 274-275 0628-0629 ▀▀▀█▄ ▀▀ F318 62232 sound ← V3 276-277 0630-0631 ▀█ █▀▀▀▄ DE51 56913 Draw 08×01 at VE,V5; VF ← XOR If the bomb collides with an enemy now, then the prime routine is not entered. It's noteworthy that a test if not zero would be better here: 278-279 0632-0633 ▀▀▀▀▀█ 3F01 16129 Skip next if VF = 001 27A-27B 0634-0635 ▄█▄▄▀ 123C 04668 Jump to prime A collision has occured, and the vertical position is used to determine which enemy was struck: 27C-27D 0636-0637 ▀▀▄██▄█ 6D1F 27935 VD ← 031 27E-27F 0638-0639 ▀▄ ▄▀▀▄▀ 8D52 36178 VD ← VD AND V5 280-281 0640-0641 ▀ ▄██▄█ 4D1F 19743 Skip next if VD <> 031 282-283 0642-0643 ▄ ▀▄▄▀ 128C 04748 Jump to big hit 284-285 0644-0645 ▄ █ █ 1292 04754 Jump to small hit The decrease routine erases the bomb count and decrements it before jumping to the starting loop: 286-287 0646-0647 ▄ █ ▄▄▀ 22AC 08876 decrease Call show count 288-289 0648-0649 ▄████▄▄▄ 78FF 30975 V8 ← V8 + 255 28A-28B 0650-0651 █▄▄█ 121E 04638 Jump to start The big hit routine erases the score and increases it by five, before jumping to the shared routine: 28C-28D 0652-0653 ▄ █ █ 22A2 08866 big hit Call show score 28E-28F 0654-0655 ▀▀▀ █▀█ 7705 30469 V7 ← V7 + 005 290-291 0656-0657 ▄ █ ▄█ 1296 04758 Jump to shared The small hit routine erases the score and increases it by ten, falling into the shared routine. The shared routine shows the updated score, plays a sound lasting 1/20 of a second, erases the bomb, and then jumps to the decrease routine: 292-293 0658-0659 ▄ █ █ 22A2 08866 small hit Call show score 294-295 0660-0661 ▀▀▀▄▀█▀ 770A 30474 V7 ← V7 + 010 296-297 0662-0663 ▄ █ █ 22A2 08866 shared Call show score 298-299 0664-0665 ▀▀ ▀▀▄█ 6D03 27907 VD ← 003 29A-29B 0666-0667 ▀▀▀██▀ ▀ FD18 64792 sound ← VD 29C-29D 0668-0669 █▄▀▄ ▄█▄ A2D7 41687 I ← bomb 29E-29F 0670-0671 ▀█ █▀▀▀▄ DE51 56913 Draw 08×01 at VE,V5; VF ← XOR 2A0-2A1 0672-0673 ▄ ▀ ▄█ 1286 04742 Jump to decrease The show score routine writes the score to the scratch location, adjusts register three, and calls the show routine before returning: 2A2-2A3 0674-0675 █▄█▄▄ ▀ A2F8 41720 show score I ← scratch 2A4-2A5 0676-0677 ▀▀██ ▀██ F733 63283 V7 as BCD stored from I 2A6-2A7 0678-0679 ▀▀ ▀▀ 6300 25344 V3 ← 000 2A8-2A9 0680-0681 ▄ █▄ ▄█ 22B6 08886 Call show 2AA-2AB 0682-0683 ▄▄▄ ▄▄▄ 00EE 00238 Return The show count routine writes the count to the scratch location, adjusts register three, and calls the show routine before returning: 2AC-2AD 0684-0685 █▄█▄▄ ▀ A2F8 41720 show count I ← scratch 2AE-2AF 0686-0687 ▀▀██▀ ▄▄ F833 63539 V8 as BCD stored from I 2B0-2B1 0688-0689 ▀█▄ █▀ 6332 25394 V3 ← 050 2B2-2B3 0690-0691 ▄ █▄ ▄█ 22B6 08886 Call show 2B4-2B5 0692-0693 ▄▄▄ ▄▄▄ 00EE 00238 Return The show routine draws a basic three digit number at a constant vertical with a variable horizontal position before returning: 2B6-2B7 0694-0695 ▀▀ ▀▀ ▀ 6D00 27904 show VD ← 000 2B8-2B9 0696-0697 ▀██▀ ▄▀▄ F265 62053 Load V0→V2; I ← I + 03 2BA-2BB 0698-0699 ▀▀█▀▄ ▄ F029 61481 I ← digit sprite of V0 2BC-2BD 0700-0701 ██ █ ▄▀█ D3D5 54229 Draw 08×05 at V3,VD; VF ← XOR 2BE-2BF 0702-0703 ▀▀▀ ▄▀█ 7305 29445 V3 ← V3 + 005 2C0-2C1 0704-0705 ▀▀█▀▄ █ F129 61737 I ← digit sprite of V1 2C2-2C3 0706-0707 ██ █ ▄▀█ D3D5 54229 Draw 08×05 at V3,VD; VF ← XOR 2C4-2C5 0708-0709 ▀▀▀ ▄▀█ 7305 29445 V3 ← V3 + 005 2C6-2C7 0710-0711 ▀▀█▀▄ ▀▄ F229 61993 I ← digit sprite of V2 2C8-2C9 0712-0713 ██ █ ▄▀█ D3D5 54229 Draw 08×05 at V3,VD; VF ← XOR 2CA-2CB 0714-0715 ▄▄▄ ▄▄▄ 00EE 00238 Return Following that are the sprites used by the game and some waste: 2CC 0716 █ 01 001 2CD 0717 █ 08 008 big enemy 2CE 0718 ███████ 7F 127 2CF 0719 █████ 7C 124 2D0 0720 █ 08 008 small enemy 2D1 0721 █████ 3E 062 2D2 0722 ██ 60 096 2D3 0723 █ 08 008 2D4 0724 ██ 18 024 you 2D5 0725 ████ 3C 060 2D6 0726 ████████ FF 255 2D7 0727 █ 08 008 bomb The end routine displays the go, od, by, and e! sprites before entering an infinite loop to end the game: 2D8-2D9 0728-0729 ▀ ▀ ▀▀ A300 41728 end I ← go 2DA-2DB 0730-0731 ▀▀▄ ▀█ 6311 25361 V3 ← 017 2DC-2DD 0732-0733 ▀▀ █▀▄█ 6D0B 27915 VD ← 011 2DE-2DF 0734-0735 ██ █ ▄▀█ D3D5 54229 Draw 08×05 at V3,VD; VF ← XOR 2E0-2E1 0736-0737 ▀ ▀ ▄▀█ A305 41733 I ← od 2E2-2E3 0738-0739 ▀▀▄▄ ▀█ 6319 25369 V3 ← 025 2E4-2E5 0740-0741 ██ █ ▄▀█ D3D5 54229 Draw 08×05 at V3,VD; VF ← XOR 2E6-2E7 0742-0743 ▀ ▀ ▄ █▀ A30A 41738 I ← by 2E8-2E9 0744-0745 ▀█ ██ 6323 25379 V3 ← 035 2EA-2EB 0746-0747 ██ █ ▄▀█ D3D5 54229 Draw 08×05 at V3,VD; VF ← XOR 2EC-2ED 0748-0749 ▀ ▀ ▄▄██ A30F 41743 I ← e! 2EE-2EF 0750-0751 ▀█ ▄ ██ 632B 25387 V3 ← 043 2F0-2F1 0752-0753 ██ █ ▄▀█ D3D5 54229 Draw 08×05 at V3,VD; VF ← XOR 2F2-2F3 0754-0755 ▀▀ ▀▀ 6300 25344 V3 ← 000 2F4-2F5 0756-0757 ▄▄▄█ ▄▀ 12F4 04852 self Jump to self Following that is the scratch location and waste: 2F6 0758 ██ ██ █ 6D 109 2F7 0759 █ ██ 0B 011 2F8 0760 00 000 scratch 2F9 0761 █ 01 001 2FA 0762 █ 04 004 2FB 0763 00 000 2FC 0764 00 000 2FD 0765 ███ ███ EE 238 2FE 0766 00 000 2FF 0767 █ 01 001 Following yet that are the sprites used for displaying the ending message: 300 0768 ███ ███ EE 238 go 301 0769 █ █ █ 8A 138 302 0770 █ █ █ 8A 138 303 0771 █ █ █ █ AA 170 304 0772 ███ ███ EE 238 305 0773 ███ ████ EF 239 od 306 0774 █ █ █ █ A5 165 307 0775 █ █ █ █ A5 165 308 0776 █ █ █ █ A5 165 309 0777 ███ ████ EF 239 30A 0778 ████ █ 7A 122 by 30B 0779 █ █ █ 2A 042 30C 0780 ███ ██ 3B 059 30D 0781 █ █ █ 29 041 30E 0782 ████ █ 79 121 30F 0783 █ ███ █ BA 186 e! 310 0784 █ █ █ A2 162 311 0785 █ ██ █ B2 178 312 0786 █ 20 032 313 0787 ███ █ 3A 058 The game ends with more waste: 314 0788 ██ █ 34 052 315 0789 ███ █ 3A 058 316 0790 ████ 3C 060 317 0791 ██ █ ██ D6 214 318 0792 █ █ █ 54 084 319 0793 ███ 1C 028 31A 0794 ██ 0C 012 31B 0795 █ 40 064 31C 0796 █ ████ 9E 158 31D 0797 █ █ █ 25 037 31E 0798 ██ █ 68 104 31F 0799 ██ 0C 012 .