A Documenting of mine Even More Enhanced Enchantment CHIP-8 Game This is but a minor improvement of a previous game, made due to a lack of time for the ninth Octojam event. I wanted to make the field scroll and amusingly found this to be difficult purely due to the optimizations made in the previous version, as every register was used. For the next event I intend to entirely rewrite the game, and it will lead to something more efficient when extended in any way. I'll note the big changes and, as with last time, leave a deeper understanding to the prior article. Follows is a view of the complete game, when loaded into the MMC: 200-201 0512-0513 ________ 00FF 00255  Enable extended mode 202-203 0514-0515 #_^ #^ A3C2 41922  I <- from 204-205 0516-0517 ^##^^#^# FF65 65381  Load V0->VF; I <- I + 16 206-207 0518-0519 ^_^ _^ A244 41540  I <- ball 208-209 0520-0521 ^# # ^ _ D451 54353  Draw 08x01 at V4,V5; VF <- XOR 20A-20B 0522-0523 ^^ _##_ CC1E 52254  VC <- ??? AND 030 20C-20D 0524-0525 ^^ _##_^ CD1E 52510  VD <- ??? AND 030 20E-20F 0526-0527 ^^ _### CE1E 52766  VE <- ??? AND 030 210-211 0528-0529 ^^^# _^# F315 62229 movement delay <- V3 212-213 0530-0531  ^^ #### 6F0F 28431  VF <- 015 214-215 0532-0533 #^# ^^^# EFA1 61345  Skip next if VF <> key 216-217 0534-0535 ^^^^#^#^ FF0A 65290  VF <- key 218-219 0536-0537 ^# # ^ _ D451 54353  Draw 08x01 at V4,V5; VF <- XOR 21A-21B 0538-0539  ^ ^^^^ 4F00 20224  Skip next if VF <> 000 21C-21D 0540-0541 ___ 00E0 00224  Clear the screen 21E-21F 0542-0543  ^ ^^^^ 4F00 20224  Skip next if VF <> 000 220-221 0544-0545  ^ # 1202 04610  Jump to 0514 222-223 0546-0547 #^# _ E0A1 57505  Skip next if V0 <> key 224-225 0548-0549  ^^^ ^ _ 7401 29697  V4 <- V4 + 001 226-227 0550-0551 #^# # E1A1 57761  Skip next if V1 <> key 228-229 0552-0553 _###_#__ 74FF 29951  V4 <- V4 + 255 22A-22B 0554-0555 #^# ^_ E2A1 58017  Skip next if V2 <> key 22C-22D 0556-0557  ^^^ ^ # 7501 29953  V5 <- V5 + 001 22E-22F 0558-0559 #^# ^# E3A1 58273  Skip next if V3 <> key 230-231 0560-0561 _###_#_# 75FF 30207  V5 <- V5 + 255 232-233 0562-0563 _#___#__ 44FF 17663  Skip next if V4 <> 255 234-235 0564-0565  ^^ ^ 6400 25600  V4 <- 000 236-237 0566-0567 _^ ^ 4480 17536  Skip next if V4 <> 128 238-239 0568-0569  ##__#__ 647F 25727  V4 <- 127 23A-23B 0570-0571 _#___#_# 45FF 17919  Skip next if V5 <> 255 23C-23D 0572-0573  ^^ ^ ^ 6500 25856  V5 <- 000 23E-23F 0574-0575  # ^ ^ 4540 17728  Skip next if V5 <> 064 240-241 0576-0577  ^#__#_# 653F 25919  V5 <- 063 242-243 0578-0579 ^# # ^ _ D451 54353  Draw 08x01 at V4,V5; VF <- XOR 244-245 0580-0581 #_ 80C0 32960+ ball V0 <- VC 246-247 0582-0583  ^^ ^ 6100 24832  V1 <- 000 248-249 0584-0585 # ^ 8280 33408  V2 <- V8 24A-24B 0586-0587 # _ ^^ 8390 33680  V3 <- V9 24C-24D 0588-0589  ^ ^^^^ 4F00 20224  Skip next if VF <> 000 24E-24F 0590-0591 ^_#^_ ^ B268 45672  Jump to V0 + table 250-251 0592-0593 ___ 00E0 00224  Clear the screen 252-253 0594-0595  ^ # 1202 04610  Jump to 0514 254-255 0596-0597 #_ _ 80D0 32976 second V0 <- VD 256-257 0598-0599  ^^ # 6101 24833  V1 <- 001 258-259 0600-0601 # _ ^ 82A0 33440  V2 <- VA 25A-25B 0602-0603 # __ ^^ 83B0 33712  V3 <- VB 25C-25D 0604-0605 ^_#^_ ^ B268 45672  Jump to V0 + table 25E-25F 0606-0607 #__ 80E0 32992 third V0 <- VE 260-261 0608-0609  ^^ _^ 6102 24834  V1 <- 002 262-263 0610-0611 ^__ ^ 8260 33376  V2 <- V6 264-265 0612-0613 ^___ ^^ 8370 33648  V3 <- V7 266-267 0614-0615 ^_#^_ ^ B268 45672  Jump to V0 + table 268-269 0616-0617 _ # ^ 1290 04752 table Jump to up left 26A-26B 0618-0619 _ # _# 1296 04758  Jump to up right 26C-26D 0620-0621 _ #__^ 129C 04764  Jump to down left 26E-26F 0622-0623 _ _^ # 12A2 04770  Jump to down right 270-271 0624-0625 _ _^_ ^ 12A8 04776  Jump to left up 272-273 0626-0627 _ _^__# 12AE 04782  Jump to left down 274-275 0628-0629 _ _# _^ 12B4 04788  Jump to right up 276-277 0630-0631 _ _#_ # 12BA 04794  Jump to right down 278-279 0632-0633 __ ^ ^ 12C0 04800  Jump to two up left 27A-27B 0634-0635 __ ^_ ^ 12C8 04808  Jump to two up right 27C-27D 0636-0637 __ # ^ 12D0 04816  Jump to two down left 27E-27F 0638-0639 __ #_ ^ 12D8 04824  Jump to two down right 280-281 0640-0641 ___^ ^ 12E0 04832  Jump to two left up 282-283 0642-0643 ___^_ ^ 12E8 04840  Jump to two right down 284-285 0644-0645 ___# ^ 12F0 04848  Jump to left targeting 286-287 0646-0647 ___# _^ 12F4 04852  Jump to right targeting 288-289 0648-0649  ^__#^ 130E 04878  Jump to up targeting 28A-28B 0650-0651  # #^ 1312 04882  Jump to down targeting 28C-28D 0652-0653  _^__^^ 132C 04908  Jump to left 28E-28F 0654-0655  _^__#^ 132E 04910  Jump to right 290-291 0656-0657 _###__#_ 72FF 29439 up left V2 <- V2 + 255 292-293 0658-0659  ^^^ ^# 7301 29441  V3 <- V3 + 001 294-295 0660-0661  _# ^^ 1330 04912  Jump to integrate 296-297 0662-0663  ^^^ ^_ 7201 29185 up right V2 <- V2 + 001 298-299 0664-0665  ^^^ ^# 7301 29441  V3 <- V3 + 001 29A-29B 0666-0667  _# ^^ 1330 04912  Jump to integrate 29C-29D 0668-0669 _###__#_ 72FF 29439 down left V2 <- V2 + 255 29E-29F 0670-0671 _###__## 73FF 29695  V3 <- V3 + 255 2A0-2A1 0672-0673  _# ^^ 1330 04912  Jump to integrate 2A2-2A3 0674-0675  ^^^ ^_ 7201 29185 down right V2 <- V2 + 001 2A4-2A5 0676-0677 _###__## 73FF 29695  V3 <- V3 + 255 2A6-2A7 0678-0679  _# ^^ 1330 04912  Jump to integrate 2A8-2A9 0680-0681  ^^^ ^_ 7201 29185 left up V2 <- V2 + 001 2AA-2AB 0682-0683 _###__## 73FF 29695  V3 <- V3 + 255 2AC-2AD 0684-0685  _# ^^ 1330 04912  Jump to integrate 2AE-2AF 0686-0687  ^^^ ^_ 7201 29185 left down V2 <- V2 + 001 2B0-2B1 0688-0689  ^^^ ^# 7301 29441  V3 <- V3 + 001 2B2-2B3 0690-0691  _# ^^ 1330 04912  Jump to integrate 2B4-2B5 0692-0693 _###__#_ 72FF 29439 right up V2 <- V2 + 255 2B6-2B7 0694-0695 _###__## 73FF 29695  V3 <- V3 + 255 2B8-2B9 0696-0697  _# ^^ 1330 04912  Jump to integrate 2BA-2BB 0698-0699 _###__#_ 72FF 29439 right down V2 <- V2 + 255 2BC-2BD 0700-0701  ^^^ ^# 7301 29441  V3 <- V3 + 001 2BE-2BF 0702-0703  _# ^^ 1330 04912  Jump to integrate 2C0-2C1 0704-0705 _###__# 72FE 29438 two up left V2 <- V2 + 254 2C2-2C3 0706-0707  ^^^ ^# 7301 29441  V3 <- V3 + 001 2C4-2C5 0708-0709 ^_^ _^_ A245 41541  I <- two balls 2C6-2C7 0710-0711  _# ^^ 1330 04912  Jump to integrate 2C8-2C9 0712-0713  ^^^ # 7202 29186 two up right V2 <- V2 + 002 2CA-2CB 0714-0715  ^^^ ^# 7301 29441  V3 <- V3 + 001 2CC-2CD 0716-0717 ^_^ _^_ A245 41541  I <- two balls 2CE-2CF 0718-0719  _# ^^ 1330 04912  Jump to integrate 2D0-2D1 0720-0721 _###__# 72FE 29438 two down left V2 <- V2 + 254 2D2-2D3 0722-0723 _###__## 73FF 29695  V3 <- V3 + 255 2D4-2D5 0724-0725 ^_^ _^_ A245 41541  I <- two balls 2D6-2D7 0726-0727  _# ^^ 1330 04912  Jump to integrate 2D8-2D9 0728-0729  ^^^ # 7202 29186 two down right V2 <- V2 + 002 2DA-2DB 0730-0731 _###__## 73FF 29695  V3 <- V3 + 255 2DC-2DD 0732-0733 ^_^ _^_ A245 41541  I <- two balls 2DE-2DF 0734-0735  _# ^^ 1330 04912  Jump to integrate 2E0-2E1 0736-0737  ^^^ # 7202 29186 two left up V2 <- V2 + 002 2E2-2E3 0738-0739  ^^^ ^# 7301 29441  V3 <- V3 + 001 2E4-2E5 0740-0741 ^_^ _^_ A245 41541  I <- two balls 2E6-2E7 0742-0743  _# ^^ 1330 04912  Jump to integrate 2E8-2E9 0744-0745 _###__# 72FE 29438 two right down V2 <- V2 + 254 2EA-2EB 0746-0747 _###__## 73FF 29695  V3 <- V3 + 255 2EC-2ED 0748-0749 ^_^ _^_ A245 41541  I <- two balls 2EE-2EF 0750-0751  _# ^^ 1330 04912  Jump to integrate 2F0-2F1 0752-0753 _##_#### 6FFF 28671 left targeting VF <- 255 2F2-2F3 0754-0755  ^ ^ 5000 20480  Skip next if V0 = V0 2F4-2F5 0756-0757  ^^ ^^^# 6F01 28417 right targeting VF <- 001 2F6-2F7 0758-0759 ^_ ^ ^ 9240 37440  Skip next if V2 <> V4 2F8-2F9 0760-0761  ^ ^^ 1300 04864  Jump to vertical target 2FA-2FB 0762-0763 #___ _^ 82F4 33524  V2 <- V2 + VF; VF <- overflow 2FC-2FD 0764-0765  # ^ ^ 5240 21056  Skip next if V2 = V4 2FE-2FF 0766-0767  _# ^^ 1330 04912  Jump to integrate 300-301 0768-0769 ^ __ ^ 8230 33328 vertical target V2 <- V3 302-303 0770-0771 ^_ _ _^_ 8255 33365  V2 <- V2 - V5; VF <- borrow 304-305 0772-0773 ^_ ^ 8240 33344  V2 <- V4 306-307 0774-0775  ^# 6020 24608  V0 <- 032 308-309 0776-0777  ^ ^^^^ 4F00 20224  Skip next if VF <> 000 30A-30B 0778-0779  ^# _ 6022 24610  V0 <- 034 30C-30D 0780-0781  _# ^^ 1330 04912  Jump to integrate 30E-30F 0782-0783 _##_#### 6FFF 28671 up targeting VF <- 255 310-311 0784-0785  ^ ^ 5000 20480  Skip next if V0 = V0 312-313 0786-0787  ^^ ^^^# 6F01 28417 down targeting VF <- 001 314-315 0788-0789 ^_ # ^^ 9350 37712  Skip next if V3 <> V5 316-317 0790-0791  #__#^ 131E 04894  Jump to up down target 318-319 0792-0793 #___ _^^ 83F4 33780  V3 <- V3 + VF; VF <- overflow 31A-31B 0794-0795  # # ^^ 5350 21328  Skip next if V3 = V5 31C-31D 0796-0797  _# ^^ 1330 04912  Jump to integrate 31E-31F 0798-0799 ^ _ ^^ 8320 33568 up down target V3 <- V2 320-321 0800-0801 ^_ _ _^# 8355 33621  V3 <- V3 - V5; VF <- borrow 322-323 0802-0803 ^_ _ ^^ 8350 33616  V3 <- V5 324-325 0804-0805  ^# _ 6024 24612  V0 <- 036 326-327 0806-0807  ^ ^^^^ 4F00 20224  Skip next if VF <> 000 328-329 0808-0809  ^# __ 6026 24614  V0 <- 038 32A-32B 0810-0811  _# ^^ 1330 04912  Jump to integrate 32C-32D 0812-0813 _###__# 72FE 29438 left V2 <- V2 + 254 32E-32F 0814-0815  ^^^ ^_ 7201 29185 right V2 <- V2 + 001 330-331 0816-0817 _#____# 42FE 17150 integrate Skip next if V2 <> 254 332-333 0818-0819 _ _^_ ^^ 13A8 05032  Jump to new line 334-335 0820-0821 _#____#_ 42FF 17151  Skip next if V2 <> 255 336-337 0822-0823 _ _^_ ^^ 13A8 05032  Jump to new line 338-339 0824-0825 _#____## 43FF 17407  Skip next if V3 <> 255 33A-33B 0826-0827 _ _^_ ^^ 13A8 05032  Jump to new line 33C-33D 0828-0829 _^ ^_ 4281 17025  Skip next if V2 <> 129 33E-33F 0830-0831 _ _^_ ^^ 13A8 05032  Jump to new line 340-341 0832-0833 _^ ^ 4280 17024  Skip next if V2 <> 128 342-343 0834-0835 _ _^_ ^^ 13A8 05032  Jump to new line 344-345 0836-0837  # ^^ 4340 17216  Skip next if V3 <> 064 346-347 0838-0839 _ _^_ ^^ 13A8 05032  Jump to new line 348-349 0840-0841 ^^_# ^_ D231 53809  Draw 08x01 at V2,V3; VF <- XOR 34A-34B 0842-0843  ^ ^^ 4300 17152  Skip next if V3 <> 000 34C-34D 0844-0845 _ _^_ ^^ 13A8 05032  Jump to new line 34E-34F 0846-0847  ^____## 433F 17215  Skip next if V3 <> 063 350-351 0848-0849 _ _^_ ^^ 13A8 05032  Jump to new line 352-353 0850-0851  ^_ 4020 16416  Skip next if V0 <> 032 354-355 0852-0853  __^ #^ 1362 04962  Jump to dispatch 356-357 0854-0855  ^_ _ 4022 16418  Skip next if V0 <> 034 358-359 0856-0857  __^ #^ 1362 04962  Jump to dispatch 35A-35B 0858-0859  ^ ^ 4200 16896  Skip next if V2 <> 000 35C-35D 0860-0861 _ _^_ ^^ 13A8 05032  Jump to new line 35E-35F 0862-0863  #____#_ 427F 17023  Skip next if V2 <> 127 360-361 0864-0865 _ _^_ ^^ 13A8 05032  Jump to new line 362-363 0866-0867 ^_^ _^ A244 41540 dispatch I <- ball 364-365 0868-0869  ^ # 4101 16641  Skip next if V1 <> 001 366-367 0870-0871  __# _^^ 1374 04980  Jump to next 368-369 0872-0873  ^ _^ 4102 16642  Skip next if V1 <> 002 36A-36B 0874-0875  __#__^^ 137C 04988  Jump to last 36C-36D 0876-0877 ^ ^^ 8C00 35840  VC <- V0 36E-36F 0878-0879 ^ _ ^ 8820 34848  V8 <- V2 370-371 0880-0881 ^ __^ ^ 8930 35120  V9 <- V3 372-373 0882-0883  _ # _^ 1254 04692  Jump to second 374-375 0884-0885 ^ ^^ ^ 8D00 36096 next VD <- V0 376-377 0886-0887 ^ _ ^ ^ 8A20 35360  VA <- V2 378-379 0888-0889 ^ __^ ^^ 8B30 35632  VB <- V3 37A-37B 0890-0891  _ #__# 125E 04702  Jump to third 37C-37D 0892-0893 ^ ^^^ 8E00 36352 last VE <- V0 37E-37F 0894-0895 ^ _ ^^ 8620 34336  V6 <- V2 380-381 0896-0897 ^ __ ^^^ 8730 34608  V7 <- V3 382-383 0898-0899 #_^_ #^ A3D2 41938  I <- timer 384-385 0900-0901 ^##^ _ _ F065 61541  Load V0->V0; I <- I + 01 386-387 0902-0903 #_^_ #^ A3D2 41938  I <- timer 388-389 0904-0905  ^^^ _ 7001 28673  V0 <- V0 + 001 38A-38B 0906-0907  ^# 3010 12304  Skip next if V0 = 016 38C-38D 0908-0909 _ #_ ^^ 1398 05016  Jump to save timer 38E-38F 0910-0911 __ _ 00C1 00193  Scroll down by 01 390-391 0912-0913  ^^ 6000 24576  V0 <- 000 392-393 0914-0915  ^^^ ^ # 7501 29953  V5 <- V5 + 001 394-395 0916-0917  # ^ ^ 4540 17728  Skip next if V5 <> 064 396-397 0918-0919  ^#__#_# 653F 25919  V5 <- 063 398-399 0920-0921 ^#^# _ _ F055 61525 save timer Save V0->V0; I <- I + 01 39A-39B 0922-0923 ^^^^^### FF07 65287 exhaust delay VF <- delay 39C-39D 0924-0925  ^^^^^^ 3F00 16128  Skip next if VF = 000 39E-39F 0926-0927 _ #_ #^ 139A 05018  Jump to exhaust delay 3A0-3A1 0928-0929 #_^ #^ A3C2 41922  I <- from 3A2-3A3 0930-0931 ^##^ _^# F365 62309  Load V0->V3; I <- I + 04 3A4-3A5 0932-0933 ^_^ _^ A244 41540  I <- ball 3A6-3A7 0934-0935  # ^ 1210 04624  Jump to movement 3A8-3A9 0936-0937 ^^ ____ C01E 49182 new line V0 <- ??? AND 030 3AA-3AB 0938-0939 ^^ ^^## CF03 52995  VF <- ??? AND 003 3AC-3AD 0940-0941 ^#____#_ C27F 49791  V2 <- ??? AND 127 3AE-3AF 0942-0943 ^^____## C33F 49983  V3 <- ??? AND 063 3B0-3B1 0944-0945  ^ ^^^^ 4F00 20224  Skip next if VF <> 000 3B2-3B3 0946-0947  ^^ ^ 6200 25088  V2 <- 000 3B4-3B5 0948-0949  ^ ^^^# 4F01 20225  Skip next if VF <> 001 3B6-3B7 0950-0951  ^^ ^^ 6300 25344  V3 <- 000 3B8-3B9 0952-0953  ^ ^^#^ 4F02 20226  Skip next if VF <> 002 3BA-3BB 0954-0955  ##___#_ 627F 25215  V2 <- 127 3BC-3BD 0956-0957  ^ ^^## 4F03 20227  Skip next if VF <> 003 3BE-3BF 0958-0959  ^#___## 633F 25407  V3 <- 063 3C0-3C1 0960-0961  __^ #^ 1362 04962  Jump to dispatch 3C2 0962  ## 06 006 from  3C3 0963  # 04 004   3C4 0964  # 02 002   3C5 0965  # 08 008   3C6 0966  ###### 3F 063   3C7 0967  ##### 1F 031   3C8-3C9 0968-0969  0000 00000   3CA-3CB 0970-0971  0000 00000   3CC-3CD 0972-0973  0000 00000   3CE-3CF 0974-0975  0000 00000   3D0-3D1 0976-0977  0000 00000   3D2-3D3 0978-0979  0000 00000 timer  The register usage is as follows: V0 Right movement button, holding the identifier code, and holding the timer. V1 Left movement button and cardinal line information. V2 Down movement button, and line horizontal coordinate storage. V3 Up movement button, delay, and line vertical coordinate storage. V4 Horizontal coordinate of player. V5 Vertical coordinate of player. V6 Horizontal coordinate of third line. V7 Vertical coordinate of third line. V8 Horizontal coordinate of first line. V9 Vertical coordinate of first line. VA Horizontal coordinate of second line. VB Vertical coordinate of second line. VC Identifier code of first line. VD Identifier code of second line. VE Identifier code of third line. VF Collision detection and holding a key code. The registers were chosen for the following reasons: V0 Ease of access. V1 Ease of access. V2 Ease of access. V3 Ease of access. V4 Ease of access. V5 Ease of access. V6 It's available. V7 It follows V6. V8 It follows the V4 and V5 pattern. V9 It follows the V4 and V5 pattern. VA It follows the V4 and V5 pattern. VB It follows the V4 and V5 pattern. VC It's even. VD It follows VC. VE It's available and follows VC. VF Unimportance and necessity. The code I'd added is after the name last. As all available registers were used, I had to store the timer elsewhere. Each sixteenth iteration of the program loop has the screen scroll down by a line; when this is done, the player's position is adjusted and the timer reset. The code to restore those first four registers and change I to once again point at the ball have merely been moved. When this was written, I noticed the inadequacy of my previous design, and how inefficient it is to have those separate code segments for separate lines, as compared to a design which wouldn't use every register but would support more lines than can fit in the registers at once; I'm also dissatisfied with how I ran out of time to update the line positions alongside the player's; I'll fix such issues next time. .