Thanks for your help!
Code: Select all
org 32768
Start:
call 0D6BH ; Calls BASIC CLS command
; Set BORDER colour to Black
ld a, 00
out ($fe),a
; Set PAPER colour to Black
ld a,7 ; Black PAPER white INK
ld (23693),a
call 3503 ; Calls routine to clear the screen
; init fire position
; y - starts from 0 (bottom of screen)
ld a,(vCount)
ld b,a
; x
ld a,(hCount)
ld c,a
; call PLOT
call $22DF
; clear last key pressed before game start
ld a,0
ld (23560),a
game:
displaySprite:
ld a,0
ld a,22 ; Set A with PRINT AT command
rst 10h ; Call
ld a,20 ; Set A with 7 (Y coord)
rst 10h
ld a,20 ; Set A with 8 (X coord)
rst 10h
ld a,0
ld a,(23560) ; get last key pressed
; Get key set for keys 1 - 4
;ld b,$f7
;ld c,$fe
;in a,(c)
;push af
ld bc,0
ld c,a
call 6683
;pop af
ld a,0
ld a,(23560) ; get last key pressed
;cp 190
;call z,fireLaser
;cp 30 ; cspect
;call z,fireLaser
cp 49
call z,preLaserLoop
call delay
jp game
; start call list section
delay:
ld b,3
delay0:
halt
djnz delay0
ret
preLaserLoop:
ld b,3
fireLaser:
push bc
call buildLaser
pop bc
djnz fireLaser
ret
buildLaser:
; drawStraight ($2477/9335)
; stacka ($2D28)
; stackbc ($2D2B/11563 or 5)
; unstacka ($1E94)
; Update PLOT as that is based on x,y for DRAW
; Remember that ZX Spectrum resolution is 256x192 pixels
; 175 for vertical
; 255 for horizontal
; Address for X 23677
; Address for Y 23678
;put x&y on calculator stack
;push af -- this could be causing looping issues with the code
; I may have to test the fact that different angles mean diff sides of screen hit
; so possible lookup table after testing??
; X start
;ld a,0
;ld a,(hCount)
ld a,(23677)
cp 254
jp z,skipV
jp nc,skipV
ld a,1
ld hl,1
ld de,0
ld de,(hCount)
add hl,de
ld (hCount),hl
call $2D28
; X end
; Y start
;ld a,0 ; init for vCount
;ld a,(vCount)
ld a, (23678)
cp 174
jp z,skipV
jp nc,skipV
ld a,0
ld hl,0
ld de,0
ld de,(vCount)
add hl,de
ld (vCount),hl
call $2D28
; Y end
ld a,0
ld a,22 ; Set A with PRINT AT command
rst 10h ; Call
ld a,20 ; Set A with 7 (Y coord)
rst 10h
ld a,20 ; Set A with 8 (X coord)
rst 10h
;ld a,(vCount)
ld a,(23677)
ld bc,0
ld c,a
call 6683
; call drawStraight
call $2477
skipV:
;pop af -- related to push af at line 110
ret
vCount db 50
hCount db 100
; end call list section
exit:
ret
;output_sna "draw-laser.sna"
end 32768