Advertisement
shenshendrax

testx

Apr 15th, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. AppFilename             equ "testx"                     ; What we're called (for file generation)
  2. AppFirst                equ $8000                       ; First byte of code (uncontended memory)
  3.                         zeusemulate "48K","ULA+"        ; Set the model and enable ULA+
  4.                         org AppFirst                    ; Start of application
  5. AppEntry                ld ix, dir                      ; load in the varibles in IX reg
  6.                         ld a,7                          ; white ink (7) black paper (0),
  7.                         ld (23693),a                    ; set our screen colours.
  8.                         call 3503                       ; ROM routine - clears screen, opens channel#2.
  9. mainloop                call delay                      ;    loop start
  10.                         call enemy_xy                   ;
  11.                         jp moveenemy                    ;
  12. cont                    call whitespace                 ;
  13.                         call enemy_xy                   ;
  14.                         call enemy1                     ;
  15.                         jp mainloop                     ;    loop end
  16.  
  17. enemy_xy                ld a,22                         ; AT code.
  18.                         rst 16                          ;
  19.                         ld a,(ix+1 )                    ; player Y.
  20.                         rst 16                          ;
  21.                         ld a,(ix+2)                     ; player X (static)
  22.                         rst 16                          ;
  23.                         ret                             ;
  24. moveenemy:              ld a,32                         ;
  25.                         rst 16                          ;
  26.                         ld a,(ix+0)                     ; direction, binary choice, =0 goes up, =1 goes down.
  27.                         or a                            ;
  28.                         jr nz, moveenemydown            ;
  29.                         jp moveenemyup                  ;
  30. moveenemyup:            dec (ix+1)                      ; move up
  31.                         LD a, (ix+1)                    ; store new pos val                         ;
  32.                         cp 1                            ; at top?
  33.                         jr nz, switchdown               ;
  34.                         jp cont                         ;
  35. moveenemydown:          inc (ix+1)                      ;  move down
  36.                         ld a, (ix+1)                    ; Store new co-ordinate                           ;
  37.                         cp 21                           ; at bottom?
  38.                         jr nz, switchup                 ;
  39.                         jp cont                         ;
  40. switchup:               ld (ix+0), 0                    ;   possible to combine into single
  41.                         jp cont                         ;   routine that NOT's the value
  42. switchdown:             ld (ix+0), 1                    ;
  43.                         jp cont                         ;
  44. enemy1:                 ld a,7                          ; white colour on black.
  45.                         ld (23695),a                    ; set our temporary screen colours.
  46.                         ld a,143                        ; ASCII code for UDG block.
  47.                         rst 16                          ; draw player.
  48.                         ret                             ;
  49. whitespace:             ld a,0                          ; black on black paper (0)
  50.                         ld (23675),a                    ; set our temporary screen colours.
  51.                         ld a,32                         ; SPACE character.
  52.                         rst 16                          ; display space.
  53.                         ret                             ;
  54. delay:                  ld b,12                         ; Delay length
  55. delayloop:              halt                            ;
  56.                         djnz delayloop                  ; Decrease B by one and repeat until B is zero
  57.                         ret                             ;
  58. ; vars
  59. dir                     defb 01                         ;
  60. enemyY                  defb 10                         ;
  61. enemyX                  defb 16                         ;
  62.  
  63.  
  64. ; Stop planting code after this. (When generating a tape file we save bytes below here)
  65. AppLast                 equ *-1                         ; The last used byte's address
  66.  
  67. ; Generate some useful debugging commands
  68.  
  69.                         profile AppFirst,AppLast-AppFirst+1 ; Enable profiling for all the code
  70.  
  71. ; Setup the emulation registers, so Zeus can emulate this code correctly
  72.  
  73. Zeus_PC                 equ AppEntry                    ; Tell the emulator where to start
  74. Zeus_SP                 equ $FF40                       ; Tell the emulator where to put the stack
  75.  
  76. ; These generate some output files
  77.  
  78.                         ; Generate a SZX file
  79.                         output_szx AppFilename+".szx",$0000,AppEntry ; The szx file
  80.  
  81.                         ; If we want a fancy loader we need to load a loading screen
  82. ;                        import_bin AppFilename+".scr",$4000            ; Load a loading screen
  83.  
  84.                         ; Now, also generate a tzx file using the loader
  85.                         output_tzx AppFilename+".tzx",AppFilename,"",AppFirst,AppLast-AppFirst,1,AppEntry ; A tzx file using the loader
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement