Index wersja polskawersja polska

Space Invaders for CASIO FX-8000G

Written by dr. Samir Ribić, Sarajevo, Bosnia and Herzegovina, 10. Jul 2014

Casio fx-8000G was my first pocket programmable device, that I received in 1988 and I still love it. For Casio fx-8000g I wrote many logical games (including chess and reversi), adventures, lot of mathematical and painting programs, electrical engineering software, but no one ever wrote an arcade game during 28 years of its existence. There was no read key command, screen can be displayed only statically, and the language is very slow. Machine code was not published as alternative until 2011.

But, when hacker wishes to do something, it is never late. And now, we have first published arcade game: Space Invaders (with shields) for Casio fx-8000g. There is no need to speak more about this game.

Use left and right arrow keys to move the cannon, up key to shoot. After three lives are lost, program returns to home screen.

ALIEN screen shot


To enter Space invaders follow the procedure:

Entering unprotected mode


  1. Press the reset button.
  2. Mode 2
    Should give 1446 bytes free
  3. Mode 1
  4. Press Range
        Xmin -10
          max 10
         scl 1
         Ymin -10
          max 10
         scl 1
     
  5. Press G↔T
  6. Press Range
        Xmin -10
          max 10
         scl 0
         Ymin -10
          max 10
         scl 0
     
  7. Press G↔T
  8. Now press AC, then Shift and Alpha and type
    SAVE "A"G
    There should be a space between SAVE and the quote sign, but not between the second quote sign and G.
  9. Press EXE
    You will get SYS error
  10. Press left arrow and EXE to repeat the last command
    Now the message will be Save executing I/O error
  11. Again left arrow and EXE to repeat the last command
    Now the message will be again SYS error
  12. Now press AC and go to mode 3 (PCL). You will see two occupied programs (4 and 5). Delete the program 4 using AC. Now all programs are occupied. Press SHIFT DEL to delete all the programs.
    Free memory is now 1654 bytes. The array indexes are no longer controlled.

    Entering hex loader


    The easiest way to enter machine code is to plot it in video memory
  13. Switch to Comp mode (Mode +)
  14. Switch to WRT mode (Mode 2)
  15. Select Prog 0
  16. Enter the following program
      Ans→B
      S<2⇒Goto 0
      0→M
      0.3594→A[42]
      1.00419048E41→A[43]~A[44]
      1.00419848E41→A[45]
      1.0007705E41→A[46]
      Lbl 0
      S=0⇒Goto 1
      Range 1,95,0,1,63,0
      Cls
      8→C
      Lbl 3
      " "
      Dsz C
      Goto 3
      11→A
      Lbl 1
      53→C
      32→D
      B<0⇒B+2xy32→B
      Lbl 2
      Frac .5B=0⇒Plot A,C
      Frac .5B≠0⇒Isz M
      Int .5B→B
      Isz C
      C=57⇒49→C
      Frac ((D-1)÷8)=0⇒Dsz A
      Dsz D
      Goto 2
      A+8→A
      0→S
      Plot 0,0
     
  17. Exit from editor switching to WRT mode (Mode 2)
  18. Select Prog 2
  19. Enter the following program
            (˗5÷9)×(1E˗44)→Z[356]~Z[358]
     
  20. Exit from editor switching to RUN mode (Mode 1)

    Entering the program itself


    Video memory is only temporary place for the program, due to limited size and screen garble.
    The program is normally executed from address &h44F0. We need to split it to multiple chunks stored to video memory together with routines that will transfer them to their final place in file editor.
  21. Switch to Base-N (Mode -)
  22. Switch to WRT mode (Mode 2)
  23. Select Prog 1
  24. Enter the following program, part 1
    2→S
    Hex
    4244EF40:Prog 0
    5AF7415B:Prog 0
    37600008:Prog 0
    70000000:Prog 0
    FF57A820:Prog 0
    F0205EA6:Prog 0
    035795F0:Prog 0
    5ED00040:Prog 0
    5A805EB3:Prog 0
    035EB200:Prog 0
    80201BBA:Prog 0
    61744508:Prog 0
    405A805E:Prog 0
    B5005EB0:Prog 0
    045EB110:Prog 0
    56A20F56:Prog 0
    A50056A4:Prog 0
    2C80200B:Prog 0
    B1017445:Prog 0
    255EB108:Prog 0
    Dec
    M◿
    
  25. Exit from editor switching to RUN mode (Mode 1)
  26. Start Prog 1 and wait until plotting stops
  27. If displayed number is not 238 edit again Prog 1 and check the hex codes carefully, repair the error, and start it again.
  28. Start Prog 2 to transfer chunk no 1 into the file editor.
  29. Switch to WRT mode (Mode 2)
  30. Select Prog 1
  31. Enter the following program, part 2
    2→S
    Hex
    42452F40:Prog 0
    5AF7415B:Prog 0
    37600008:Prog 0
    70000000:Prog 0
    C8DEC89C:Prog 0
    C87AC870:Prog 0
    C87AC89C:Prog 0
    C8DE8020:Prog 0
    0BB10174:Prog 0
    45305EB1:Prog 0
    200BB001:Prog 0
    74452540:Prog 0
    5CD05EA7:Prog 0
    045EB008:Prog 0
    C8000BB0:Prog 0
    01744558:Prog 0
    480A0BA7:Prog 0
    01744555:Prog 0
    5E920A2B:Prog 0
    D0017445:Prog 0
    Dec
    M◿
    
  32. Exit from editor switching to RUN mode (Mode 1)
  33. Start Prog 1 and wait until plotting stops
  34. If displayed number is not 237 edit again Prog 1 and check the hex codes carefully, repair the error, and start it again.
  35. Start Prog 2 to transfer chunk no 2 into the file editor.
  36. Switch to WRT mode (Mode 2)
  37. Select Prog 1
  38. Enter the following program, part 3
    2→S
    Hex
    42456F40:Prog 0
    5AF7415B:Prog 0
    37600008:Prog 0
    70000000:Prog 0
    8C60474C:Prog 0
    4C018020:Prog 0
    4C606047:Prog 0
    4C23F05A:Prog 0
    74458C2B:Prog 0
    F0807F45:Prog 0
    8C5ED000:Prog 0
    56A3105E:Prog 0
    A704F623:Prog 0
    04A30F5B:Prog 0
    92627445:Prog 0
    B7415A80:Prog 0
    425A2140:Prog 0
    5A216047:Prog 0
    30AE422B:Prog 0
    42027445:Prog 0
    Dec
    M◿
    
  39. Exit from editor switching to RUN mode (Mode 1)
  40. Start Prog 1 and wait until plotting stops
  41. If displayed number is not 237 edit again Prog 1 and check the hex codes carefully, repair the error, and start it again.
  42. Start Prog 2 to transfer chunk no 3 into the file editor.
  43. Switch to WRT mode (Mode 2)
  44. Select Prog 1
  45. Enter the following program, part 4
    2→S
    Hex
    4245AF40:Prog 0
    5AF7415B:Prog 0
    37600008:Prog 0
    70000000:Prog 0
    D1600008:Prog 0
    7045D441:Prog 0
    5A20425A:Prog 0
    7E405A7E:Prog 0
    604730AA:Prog 0
    422B4202:Prog 0
    7445D160:Prog 0
    000A7045:Prog 0
    D40F1262:Prog 0
    0BA70174:Prog 0
    45925EA5:Prog 0
    04F02207:Prog 0
    A160405C:Prog 0
    000A7082:Prog 0
    80B5020A:Prog 0
    35227F46:Prog 0
    Dec
    M◿
    
  46. Exit from editor switching to RUN mode (Mode 1)
  47. Start Prog 1 and wait until plotting stops
  48. If displayed number is not 223 edit again Prog 1 and check the hex codes carefully, repair the error, and start it again.
  49. Start Prog 2 to transfer chunk no 4 into the file editor.
  50. Switch to WRT mode (Mode 2)
  51. Select Prog 1
  52. Enter the following program, part 5
    2→S
    Hex
    4245EF40:Prog 0
    5AF7415B:Prog 0
    37600008:Prog 0
    70000000:Prog 0
    635EB500:Prog 0
    80B50256:Prog 0
    F15D5CF1:Prog 0
    820AF120:Prog 0
    A9322B32:Prog 0
    027C4617:Prog 0
    0BA6017C:Prog 0
    0000405D:Prog 0
    20604740:Prog 0
    56A50056:Prog 0
    F15B5CF1:Prog 0
    820AF1A0:Prog 0
    A9322BB2:Prog 0
    707C465A:Prog 0
    2B710274:Prog 0
    46205EF1:Prog 0
    Dec
    M◿
    
  53. Exit from editor switching to RUN mode (Mode 1)
  54. Start Prog 1 and wait until plotting stops
  55. If displayed number is not 249 edit again Prog 1 and check the hex codes carefully, repair the error, and start it again.
  56. Start Prog 2 to transfer chunk no 5 into the file editor.
  57. Switch to WRT mode (Mode 2)
  58. Select Prog 1
  59. Enter the following program, part 6
    2→S
    Hex
    42462F40:Prog 0
    5AF7415B:Prog 0
    37600008:Prog 0
    70000000:Prog 0
    A0A9322B:Prog 0
    B2707C46:Prog 0
    5A2B7102:Prog 0
    74463140:Prog 0
    5BA0415A:Prog 0
    80425C00:Prog 0
    60000A40:Prog 0
    5A806047:Prog 0
    400BA501:Prog 0
    7C44FC70:Prog 0
    461754F1:Prog 0
    8203A4A0:Prog 0
    704675A0:Prog 0
    B50180B5:Prog 0
    42239000:Prog 0
    74467580:Prog 0
    Dec
    M◿
    
  60. Exit from editor switching to RUN mode (Mode 1)
  61. Start Prog 1 and wait until plotting stops
  62. If displayed number is not 222 edit again Prog 1 and check the hex codes carefully, repair the error, and start it again.
  63. Start Prog 2 to transfer chunk no 6 into the file editor.
  64. Switch to WRT mode (Mode 2)
  65. Select Prog 1
  66. Enter the following program, part 7
    2→S
    Hex
    42466F40:Prog 0
    5AF7415B:Prog 0
    37600008:Prog 0
    70000000:Prog 0
    B5025EB5:Prog 0
    00C00051:Prog 0
    90239010:Prog 0
    7C468E23:Prog 0
    90087C46:Prog 0
    9A239020:Prog 0
    7C46A670:Prog 0
    46BE23A5:Prog 0
    567C46BE:Prog 0
    02A50170:Prog 0
    46BE23A5:Prog 0
    007C46BE:Prog 0
    03A50170:Prog 0
    46BE2BD0:Prog 0
    017C46BE:Prog 0
    5ED00140:Prog 0
    Dec
    M◿
    
  67. Exit from editor switching to RUN mode (Mode 1)
  68. Start Prog 1 and wait until plotting stops
  69. If displayed number is not 245 edit again Prog 1 and check the hex codes carefully, repair the error, and start it again.
  70. Start Prog 2 to transfer chunk no 7 into the file editor.
  71. Switch to WRT mode (Mode 2)
  72. Select Prog 1
  73. Enter the following program, part 8
    2→S
    Hex
    4246AF40:Prog 0
    5AF7415B:Prog 0
    37600008:Prog 0
    70000000:Prog 0
    5CC40A70:Prog 0
    A27F46BB:Prog 0
    02F00160:Prog 0
    474C405D:Prog 0
    200A70A2:Prog 0
    8020C80F:Prog 0
    C80FC808:Prog 0
    C80FC80F:Prog 0
    80202BD0:Prog 0
    01744712:Prog 0
    54D1075C:Prog 0
    F084A8C2:Prog 0
    002B4202:Prog 0
    7C47105E:Prog 0
    D000AC42:Prog 0
    2B420274:Prog 0
    Dec
    M◿
    
  74. Exit from editor switching to RUN mode (Mode 1)
  75. Start Prog 1 and wait until plotting stops
  76. If displayed number is not 224 edit again Prog 1 and check the hex codes carefully, repair the error, and start it again.
  77. Start Prog 2 to transfer chunk no 8 into the file editor.
  78. Switch to WRT mode (Mode 2)
  79. Select Prog 1
  80. Enter the following program, part 9
    2→S
    Hex
    4246EF40:Prog 0
    5AF7415B:Prog 0
    37600008:Prog 0
    70000000:Prog 0
    46E75EB2:Prog 0
    08604743:Prog 0
    0095017E:Prog 0
    47125695:Prog 0
    30009601:Prog 0
    7E471256:Prog 0
    96300297:Prog 0
    01704712:Prog 0
    D0700CD2:Prog 0
    3F600620:Prog 0
    57908057:Prog 0
    80E05EE7:Prog 0
    7D600100:Prog 0
    5EB3031B:Prog 0
    BA617447:Prog 0
    2770456B:Prog 0
    Dec
    M◿
    
  81. Exit from editor switching to RUN mode (Mode 1)
  82. Start Prog 1 and wait until plotting stops
  83. If displayed number is not 247 edit again Prog 1 and check the hex codes carefully, repair the error, and start it again.
  84. Start Prog 2 to transfer chunk no 9 into the file editor.
  85. Switch to WRT mode (Mode 2)
  86. Select Prog 1
  87. Enter the following program, part 10
    2→S
    Hex
    42472F40:Prog 0
    5AF7415B:Prog 0
    37600008:Prog 0
    70000000:Prog 0
    54A7A448:Prog 0
    6049604A:Prog 0
    6003C501:Prog 0
    74473358:Prog 0
    5EB26080:Prog 0
    200BB201:Prog 0
    74474358:Prog 0
    1CD1071C:Prog 0
    F0845800:Prog 0
    007044F1:Prog 0
    47554755:Prog 0
    47554755:Prog 0
    47203A30:Prog 0
    EC3A5D38:Prog 0
    35335B5A:Prog 0
    0E5D3033:Prog 0
    Dec
    M◿
    
  88. Exit from editor switching to RUN mode (Mode 1)
  89. Start Prog 1 and wait until plotting stops
  90. If displayed number is not 246 edit again Prog 1 and check the hex codes carefully, repair the error, and start it again.
  91. Start Prog 2 to transfer chunk no 10 into the file editor.
  92. Switch to WRT mode (Mode 2)
  93. Select Prog 1
  94. Enter the following program, part 11
    2→S
    Hex
    42476F40:Prog 0
    5AF7415B:Prog 0
    04600008:Prog 0
    70000000:Prog 0
    34875B5A:Prog 0
    01434D00:Prog 0
    4E45494C:Prog 0
    41000000:Prog 0
    Dec
    M◿
    
  95. Exit from editor switching to RUN mode (Mode 1)
  96. Start Prog 1 and wait until plotting stops
  97. If displayed number is not 77 edit again Prog 1 and check the hex codes carefully, repair the error, and start it again.
  98. Start Prog 2 to transfer chunk no 11 into the file editor.

    Testing the game and cleaning up unnecessary programs


  99. Go to File editor (Mode 0). You should notice a new password protected program ALIEN there.
  100. Go to RUN mode (Mode 1)
  101. Execute Prog "ALIEN"
  102. If the program is started, congratulations!
  103. If the program is not started, it seems that you skipped some chunk, or that some entry errror was undetected by checksum. Enter the programs again
  104. Go to Mode PCL (Mode 3)
  105. Press Shift Del to clear program editor area, because hex loader is no longer required.

Source-object listing


This is commented assembly listing along with instruction opcodes that are entered into Prog 1
0000:              ORG &h44F0
44F0:           ; Put Prog "ALIEN" to the file editor area
44F0:           ; Registers
44F0:           ; R24 alien lines counter
44F0:           ; R25 empty lines
44F0:           ; R120,R56 - index register IX
44F0:           ; R121,R57 - index register IY
44F0:           ; R122,R58 - index register IZ
44F0:           ; R10 - coded direction of every alien line
44F0:           ; R23 - ROWMOVE loop counter
44F0:           ; R101 - help register, to calculate ROWMOVE position
44F0:           ; R83 - Test bit during row move
44F0:           ; R82 - bomb shape
44F0:           ; R34 - check if edge is empty
44F0:           ; R26, R27 delay loop counter
44F0:           ; R29 - relative bomb position
44F0:           ; R81 - Bomb position increment
44F0:           ; R80 - empty vertical strip of 8 pixels
44F0:           ; R31 - relative cannon position
44F0:           ; R42 - required by ROM
44F0:           ; R84 - Bomb column
44F0:           ; R85 - Cannon position
44F0:           ; R22 - Lives
44F0:           ; R21 - Unclean rows
44F0:           ; R100,R41 bullet pos
44F0:           ; R40 - bullet is flying
44F0: FF         db &hFF  ; EOF marker
44F1:           STARTPROG
44F1:           LIFE: 
44F1: 57A820      LDM R80..R81,0
44F4: F020        INV R80  ; Avoid code FF in binary in order not to damage file editor
44F6: 5EA603      LD R22,3
44F9: 5795F0      ldm   r77..r79,&h30       ;'0', three ASCII digits of the score
44FC:           
44FC:           
44FC:           LEVEL:
44FC: 5ED000      LD R40,0 ; Bullet is not fired
44FF: 405A80      LDW IX,&h5A80 ; Start of video memory
4502: 5EB303      LD R27,3    ; CLSLOOP 3*256 bytes
4505: 5EB200      LD R26,0
4508:           CLS:
4508: 8020        ST +(IX),R80 ; R80 contains &hFF, which is empty verical strip of 8 pixels
450A: 1BBA61      SBM R26..R27,1
450D: 744508      JMP NZ,CLS
4510:             
4510:           TOP:
4510: 405A80       LDW IX,&h5A80  ; Start of video memory
4513: 5EB500       LD R29,0 ; Bomb position
4516: 5EB004       LD R24,4 ; 4 rows of aliens
4519: 5EB110       LD R25,16 ; aliens start from the 16 column
451C: 56A20F       LD R82,&h0F ; Bomb is four pixels
451F: 56A500       LD R85,0   ; cannon is on the left of the screen
4522: 56A42C       LD R84,44 ; bomb starts from the 44 column
4525:           LPSCENE1:
4525: 8020         ST +(IX),R80  ; &hFF is space at the begin of aliens
4527: 0BB101       SB R25,1 
452A: 744525       JMP NZ,LPSCENE1
452D: 5EB108       LD R25,08 ; Now plot 8 aliens in loop
4530:           LPSCENE2:
4530: C8DE         ST +(IX),&hDE ; this is shape of the alien
4532: C89C         ST +(IX),&h9c
4534: C87A         ST +(IX),&h7A
4536: C870         ST +(IX),&h70
4538: C87A         ST +(IX),&h7A
453A: C89C         ST +(IX),&h9C
453C: C8DE         ST +(IX),&hDE
453E: 8020         ST +(IX),R80 ; space between aliens
4540: 0BB101       SB R25,1 
4543: 744530       JMP NZ,LPSCENE2
4546: 5EB120       LD R25,32 ; in the remaining rows the space is 32 pixels, 16 to the right edge and 16 from the left edge
4549: 0BB001       SB R24,1 
454C: 744525       JMP NZ,LPSCENE1 ; after this loop all four rows (total 32 aliens) are displayed
454F: 405CD0       LDW IX,&h5CD0  ; IX points to the row with shields in the video memory
4552: 5EA704       LD R23,4 ; four shields
4555:           SHIELDLOOP:
4555: 5EB008       LD R24,8  ; shield is a simple block of 8x8 pixels
4558:           SHIELDPLOT:
4558: C800         ST +(IX),&h00
455A: 0BB001       SB R24,1 
455D: 744558       JMP NZ,SHIELDPLOT ; at the end of the loop shield is plotted
4560: 480A         ADW IX,10 ; space between shields
4562: 0BA701       SB R23,1 
4565: 744555       JMP NZ,SHIELDLOOP ; and repeat until all four are plotted
4568:           GAMELOOP:
4568: 5E920A       LD R10,&h0A ; Lower nibble of R10 contains code where to move row of aliens. Each row has one bit, value 0 moves the row left, value 1 right
456B:           ROWMOVEOOP:
456B:           
456B: 2BD001       TSB R40,1 ; If the bullet is flying, R40 will be 1
456E: 74458C       JMP NZ,MOVEALIENS ; If not, just skip deleting the bullet
4571:           
4571: 60474C       CAL XCGIXRP ; get bullet position
4574: 4C01         SBW IX,1 ; put the empty vertical strip of 8 pixels at bullet position
4576: 8020         ST +(IX),R80 ; Due to instruction set and requirement that byte with &hFF is forbiden it is a few bytes longer than should be
4578: 4C60         SBW IX,96 ; Put the bullet position one row above (8 pixels)
457A: 60474C       CAL XCGIXRP ; store bullet position
457D: 23F05A       TSB R120,&h5A ; Check if IX is below 5A80 (video memory)
4580: 74458C       JMP NZ,MOVEALIENS
4583: 2BF080       TSB R56,&h80
4586: 7F458C       JMP NC,MOVEALIENS
4589: 5ED000       LD R40,0 ; bullet is out of screen, so it is no longer active
458C:           MOVEALIENS:
458C: 56A310       LD R83,&h10 ; This is bit mask used for testing R19
458F: 5EA704       LD R23,4  ; Four rows
4592:           MULTIROWMOVE:
4592: F623         ROD R83  ; Move mask, it will be 00001000 00000100 00000010 or 00000001
4594: 04A30F       AN R83,&hF  ; after setting upper bits to 0
4597: 5B9262       BIT R10,R83 ; Binary test for this row
459A: 7445B7       JMP NZ,TORIGHT
459D:           TOLEFT: ; Move the row to left
459D: 415A80       LDW IY,&h5A80  ; Set up registers for moving the row
45A0: 425A21       LDW IZ,&h5A21
45A3: 405A21       LDW IX,&h5A21
45A6: 604730       CAL OTHERROW  ; add 96*R23 to all three index registers
45A9: AE42         LD R34,(IZ)- ; Test if there is space on the screen 
45AB: 2B4202       TSB R34,R80  
45AE: 7445D1       JMP NZ,NOROWMOVE ; if not, change direction
45B1: 600008       CAL &h0008 ; bup instruction will move the alien row one pixel left
45B4: 7045D4       JMP ENDROWMOVE
45B7:           TORIGHT: ; Move the row to the right
45B7: 415A20       LDW IY,&h5A20 ; Set up registers for moving the row
45BA: 425A7E       LDW IZ,&h5A7E
45BD: 405A7E       LDW IX,&h5A7E
45C0: 604730       CAL OTHERROW ; add 96*R23 to all three index registers
45C3: AA42         LD R34,(IZ)+  ; Test if there is space on the screen 
45C5: 2B4202       TSB R34,R80 ; &hFF
45C8: 7445D1       JMP NZ,NOROWMOVE ; if not, change direction
45CB: 60000A       CAL &h000A ; bdn instruction will move the alien row one pixel right
45CE: 7045D4       JMP ENDROWMOVE
45D1:           NOROWMOVE:
45D1: 0F1262       XR R10,R83 ; XOR with mask will flip the direction bit
45D4:           ENDROWMOVE:
45D4: 0BA701       SB R23,1
45D7: 744592       JMP NZ,MULTIROWMOVE ; Repeat until all four rows of aliens are moved
45DA: 5EA504       LD R21,4 ; We will check four rows if they are empty
45DD: F022         INV R82 ; negate bomb shape from upper four pixel line to lower four pixel line
45DF: 07A160       XR R81,&h60; Bomb position is changed by 96 or 0 every two passes
45E2: 405C00       LDW IX,&h5C00 ; calculate video memory area where bomb appears
45E5: 0A7082       AD R56,R84 ; lower byte of IX
45E8: 80B502       ST (IX+R29),R80 ; put the bomb
45EB: 0A3522       AD R29,R81  ; increment bomb position
45EE: 7F4663       JMP NC,MOVEBOMB ; if bomb did not reach the end
45F1:           
45F1:           
45F1:           
45F1: 5EB500       LD R29,0 ; erase the bomb
45F4: 80B502       ST (IX+R29),R80
45F7:           TESTKILL:
45F7: 56F15D       LD R121,&h5D ; take cannon row in video memory
45FA: 5CF182       LD R57,R84
45FD: 0AF120       AD R57,&h20
4600: A932         LD R26,(IY)+ ; check position in cannon row, bomb column
4602: 2B3202       TSB R26,R80; &hFF if not empty skip
4605: 7C4617       JMP Z,NOTKILLED
4608: 0BA601       SB R22,1 ; Reduce life counter
460B: 7C0000       JMP Z,0  ; exit from program if life=0
460E:           NEWLIFE:
460E: 405D20       LDW IX,&h5D20  ; delete cannon row
4611: 604740       CAL CLLINE
4614: 56A500       LD R85,0  ; cannon to the left
4617:           
4617:           NOTKILLED:
4617: 56F15B       LD R121,&h5B  ; We need to fire new bomb, because previous one reached ground
461A: 5CF182       LD R57,R84
461D: 0AF1A0       AD R57,&hA0 ; It is in row which starts in video memory at 5BA0
4620:           
4620:           FINDBOMBERRT:
4620: A932         LD R26,(IY)+ ; Now search for byte &h70 (middle of alien) starting from the current position
4622: 2BB270       TSB R26,&h70
4625: 7C465A       JMP Z,BOMBERPOS
4628: 2B7102       TSB R57,R80  ; &hFF at 5BFF is end of the row of the bombing aliens
462B: 744620       JMP NZ,FINDBOMBERRT
462E: 5EF1A0       LD R57,&hA0
4631:           FINDBOMBERLT:
4631: A932         LD R26,(IY)+ ; search again, but now from the start of the bottom aliens row
4633: 2BB270       TSB R26,&h70
4636: 7C465A       JMP Z,BOMBERPOS
4639: 2B7102       TSB R57,R80 ;&hFF
463C: 744631       JMP NZ,FINDBOMBERLT
463F:           ; All aliens in bottom row are killed, move them down
463F: 405BA0       LDW IX,&h5BA0
4642: 415A80       LDW IY,&h5A80
4645: 425C00       LDW IZ,&h5C00
4648: 60000A       CAL &h000A
464B: 405A80       LDW IX,&h5A80 ; delete the top row
464E: 604740       CAL CLLINE
4651:           
4651: 0BA501       SB R21,1
4654: 7C44FC       JMP Z,LEVEL ; after four aliens rows moved, down restart the level
4657: 704617       JMP NOTKILLED
465A:           ; Row killed!
465A:           BOMBERPOS:
465A: 54F182       LD R84,R57
465D: 03A4A0       SB R84,&hA0 ; Now we have relative bomb position
4660:           
4660: 704675       JMP TESTKBD
4663:           
4663:           MOVEBOMB:
4663: A0B501       LD R72,(IX+R29) ; get the byte from the bomb position
4666: 80B542       ST (IX+R29),R82 ; put the bomb shape
4669: 239000       TSB R72,0 ; Is it part of shield?
466C: 744675       JMP NZ,TESTKBD ; if not skip shield damaging
466F: 80B502       ST (IX+R29),R80  ; erase one strip of the shield
4672: 5EB500       LD R29,0  ; move bomb to the top
4675:           TESTKBD:
4675: C000         PST KO,&h00 ; Enable all test kbd lines
4677: 5190         GST R72,KI   ; Read keyboard
4679: 239010       TSB R72,&h10  ; Check if right key is pressed
467C: 7C468E       JMP Z,RIGHTKEY
467F: 239008       TSB R72,&h08 ; Check if left key is pressed
4682: 7C469A       JMP Z,LEFTKEY
4685: 239020       TSB R72,&h20  ; Check if up key is pressed
4688: 7C46A6       JMP Z,FIREROCKET
468B: 7046BE       JMP DRAWCANON
468E:           
468E:           RIGHTKEY:
468E: 23A556       TSB R85,86 ; Check for right border of the screen
4691: 7C46BE       JMP Z,DRAWCANON
4694: 02A501       AD R85,1 ; Move cannon position
4697: 7046BE       JMP DRAWCANON
469A:           LEFTKEY:
469A: 23A500       TSB R85,0 ; Check for left border of the screen
469D: 7C46BE       JMP Z,DRAWCANON
46A0: 03A501       SB R85,1 ; Move cannon position
46A3: 7046BE       JMP DRAWCANON
46A6:           FIREROCKET:
46A6: 2BD001       TSB R40,1 ; If the bullet is currently flying you can not fire the new one
46A9: 7C46BE       JMP Z,DRAWCANON
46AC: 5ED001       LD R40,1
46AF: 405CC4       LDW IX,&h5CC4; Bullet position, one row above cannon
46B2: 0A70A2       AD R56,R85 ; lower IX
46B5: 7F46BB       JMP NC,STOREROCKETPOS
46B8: 02F001       AD R120,1 ; 8 bit arithmetic is used
46BB:           STOREROCKETPOS:
46BB:           
46BB: 60474C      CAL XCGIXRP ; Remember IX
46BE:           DRAWCANON:
46BE: 405D20       LDW IX,&h5D20 ; Now find cannon position
46C1: 0A70A2       AD R56,R85 ; lower IX
46C4: 8020         ST +(IX),R80 ; Cannon shape
46C6: C80F         ST +(IX),&h0f
46C8: C80F         ST +(IX),&h0f
46CA: C808         ST +(IX),&h08
46CC: C80F         ST +(IX),&h0f
46CE: C80F         ST +(IX),&h0f
46D0: 8020         ST +(IX),R80
46D2:           
46D2: 2BD001       TSB R40,1 ; If bullet is not flying skip plotting
46D5: 744712       JMP NZ,REFRESH
46D8:           
46D8: 54D107       LD R120,R41  ; restore bullet position
46DB: 5CF084       LD R56,R100
46DE: A8C200       LD R34,(IX+0) ; check what it is there
46E1: 2B4202       TSB R34,R80 ; if empty space &hFF 
46E4: 7C4710       JMP Z,PLOTROCKET ; jump to plot the bullet
46E7:           
46E7:           FINDHOLE: 
46E7: 5ED000       LD R40,0 ; Bump into alien or shield
46EA: AC42         LD R34,(IX)- ; find the beginning of the shape
46EC: 2B4202       TSB R34,R80 ;&hFF
46EF: 7446E7       JMP NZ,FINDHOLE
46F2:           
46F2: 5EB208       LD R26,8 ; delete alien or shield
46F5: 604743       CAL CLLINE1
46F8: 009501       ADB R77,1 ; increase score lowest digit
46FB: 7E4712       JMP NH,REFRESH ; BCD arithmetic, after '9' the H flag will be set
46FE: 569530       LD   R77,&h30    ; reset lowest digit to '0'
4701: 009601       ADB R78,1 ; increase tens
4704: 7E4712       JMP NH,REFRESH
4707: 569630       LD   R78,&h30    ;'0'
470A: 029701       AD R79,1 ; increase hundreds, after 999 killed aliens, score will look strange
470D: 704712       JMP REFRESH
4710:           PLOTROCKET:
4710:           ; Plot the bullet
4710: D070         ST (IX),&h70
4712:           
4712:           REFRESH:
4712: 0CD23F       AN R42,&h3F  ; PARAMETER DO REFRESH
4715: 600620       CAL &h0620   ; Call ROM routine to show changes in video memory
4718: 579080       ldm  r72..r76,&h20
471B: 5780E0       ldm  r64..r71,&h20
471E: 5EE77D       ld r55,&h7D   ; screen position is stored in R55
4721: 600100       cal  &h0100              ;display the string R79..R64
4724:           
4724: 5EB303      LD R27,3  ; delay loop 768 times to make game not too fast
4727:           DELAY1:
4727: 1BBA61      SBM R26..R27,1 ; Machine code is amazing, even at 900kHz
472A: 744727      JMP NZ,DELAY1 
472D:           
472D: 70456B       JMP ROWMOVEOOP ; Go to inner loop
4730:           OTHERROW: ; adjust index registers to point to the correct row of the aliens
4730: 54A7A4       LD R101,R23
4733:           OTHER1:
4733: 4860         ADW IX,96
4735: 4960         ADW IY,96
4737: 4A60         ADW IZ,96
4739: 03C501       SB R101,1 
473C: 744733       JMP NZ,OTHER1
473F: 58           RTN
4740:           CLLINE:  ; delete row of the screen
4740: 5EB260       LD R26,96
4743:           CLLINE1:  ; delete part of the screen
4743: 8020         ST +(IX),R80
4745: 0BB201       SB R26,1
4748: 744743       JMP NZ,CLLINE1
474B: 58           RTN
474C:           
474C:           XCGIXRP:  ; store and restore bullet position
474C: 1CD107       XC R41,R120
474F: 1CF084       XC R100,R56
4752: 58           RTN
4753:             ORG &h4755
4755: 7044F1      JMP STARTPROG
4758: 4755475547554755
                  db 'GUGUGUGU' ; This sequence is also 4755475547554755
4760: 47203A30EC3A5D3835335B5A0E5D303334875B5A01
                  DB 'G :0',&hEC,':]853[Z',&h0E,']034',&h87,'[Z',01
4775: 434D00      DB 'CM',00  ; PASSWORD 2 LETTERS
4778: 4E45494C41
                  DB 'NEILA'  ; Name 5 letters
477D:           

Source listing of relocators


This is commented assembly listing of the routines executed inside video memory which transfer programs from video memory to the file editor memory.
5AE8: 424514 LDW IZ,&H4514 ; destination address-1
5AEB: 405AF7 LDW IX,&H5AF7 ; source address in video memory-1
5AEE: 415B37 LDW IY,&H5B37 ; end of source in video memory
5AF1: 600008 CAL 8 ; transfer block
5AF4: 700000 JMP 0 ; home screen
5AF7: 00 DB 0 ; address needs to be divisible by 4
5AF8: 57A820 db &h57,&hA8,&h20 ; LDM R80..R81,0 etc.
...

Files to download

downloadinvaders.zip

List of files in the archive: