align 256
distbuf;=#BA00 ;#300 ;ID,texx,dist
ds 0x300
IF atm
MACRO setpgfast pg
LD A,pg
setpgafast
ENDM
MACRO setpgafast
;LD (curpg),A
;LD BC,#FFF7
;OUT (C),A
SETPGC000
ENDM
ELSE ;~atm
MACRO setpg pg
LD A,pg
setpgA
ENDM
MACRO setpgA
CALL SETPGA
ENDM
MACRO setpgfast pg
LD A,pg
setpgafast
ENDM
MACRO setpgafast
LD (curpg),A
LD BC,#7FFD
OUT (C),A
ENDM
ENDIF ;~atm
wascorrlogd
INCBIN "corlogd_"
ORG $-256
DUP 256
DB {$+(scrtopx*8)}&0xff
EDUP
IF lores
ORG $-256
_=$
DUP 128
DB {_}&0xff
_=_+2
EDUP
DS 128
ENDIF
wasda
INCBIN "da"
ORG $-256
DUP 256
DB 0xff&({$}+128)
EDUP
ORG $-256
DUP 256
DB 0xff&({$+(scrtopx*8)})
EDUP
IF lores
ORG $-256
_=$
DUP 128
DB {_}&0xff
_=_+2
EDUP
DS 128
ENDIF
TEXCODEGO
IF atm == 0
LD HL,0;-2
ADD HL,SP
LD (clscrbufsp),HL
LD (eorfillsp),HL
endif
IF atm
call setpgmap4000
ENDIF
LD BC,#FBDF
IN A,(C)
LD (mouseoldx),A
CALL RECMAP
if 0
LD HL,tcos
REtcos0
DUP 2;4
SRA (HL)
EDUP
INC L
jr NZ,REtcos0
endif
INCLUDE "zxloop.asm"
INCLUDE "WSCAN10.asm"
INCLUDE "WREND.asm"
INCLUDE "WCTRL.asm"
;переменные рендера (обновляются в начале рендера)
curXx
curx DB #80
curX DB #0
curYy
cury DB #80
curY DB #0
curxy DW 0
curyx DW 0
curYX DW 0
curangle
DW tsin
demobegin
IF demoplay
INCBIN "demorec9"
ELSE
DB %00111111 ;all keys released
ENDIF
;DISPLAY "PROG END=",$
align 256 ;DS .(-$)
tables
wastables
shift=tables-$
tlogd2sca=$+shift
IF scale64
IF scale64 == 3
INCBIN "logd2sc3"
ELSE
INCBIN "logd2sc2"
ENDIF
ELSE
INCBIN "logd2sc_"
ENDIF
tsqr2=$+shift
INCBIN "sqr2int"
tlogd=$+shift
INCBIN "logd"
tcorrlogd=$+shift
DUP 256
DB {wascorrlogd+$-tcorrlogd}&0xff
EDUP
tcos=$+shift
INCBIN "cos"
tlogcos=$+shift
INCBIN "pluslcos"
tda=$+shift
DUP 256
DB {wasda+$-tda}&0xff
EDUP
tctg=$+shift
INCBIN "plusctg"
tsin=$+shift
INCBIN "sin"
if 1
; z=0:255; sprintf('%d,',fix(atan(2.^(z/32))*128/pi))
;;;;;;;; atan(2^(x/32))*128/pi ;;;;;;;;
atan_tab=$+shift
db 020h,020h,020h,021h,021h,022h,022h,023h,023h,023h,024h,024h,025h,025h,026h,026h
db 026h,027h,027h,028h,028h,028h,029h,029h,02Ah,02Ah,02Ah,02Bh,02Bh,02Ch,02Ch,02Ch
db 02Dh,02Dh,02Dh,02Eh,02Eh,02Eh,02Fh,02Fh,02Fh,030h,030h,030h,031h,031h,031h,031h
db 032h,032h,032h,032h,033h,033h,033h,033h,034h,034h,034h,034h,035h,035h,035h,035h
db 036h,036h,036h,036h,036h,037h,037h,037h,037h,037h,037h,038h,038h,038h,038h,038h
db 038h,039h,039h,039h,039h,039h,039h,039h,039h,03Ah,03Ah,03Ah,03Ah,03Ah,03Ah,03Ah
db 03Ah,03Bh,03Bh,03Bh,03Bh,03Bh,03Bh,03Bh,03Bh,03Bh,03Bh,03Bh,03Ch,03Ch,03Ch,03Ch
db 03Ch,03Ch,03Ch,03Ch,03Ch,03Ch,03Ch,03Ch,03Ch,03Dh,03Dh,03Dh,03Dh,03Dh,03Dh,03Dh
db 03Dh,03Dh,03Dh,03Dh,03Dh,03Dh,03Dh,03Dh,03Dh,03Dh,03Dh,03Dh,03Eh,03Eh,03Eh,03Eh
db 03Eh,03Eh,03Eh,03Eh,03Eh,03Eh,03Eh,03Eh,03Eh,03Eh,03Eh,03Eh,03Eh,03Eh,03Eh,03Eh
db 03Eh,03Eh,03Eh,03Eh,03E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0D5h,0D6h,0D6h,0D7h,0D7h,0D8h,0D8h,0D9h,0D9h
db 0D9h,0DAh,0DAh,0DBh,0DBh,0DBh,0DCh,0DCh,0DDh,0DDh,0DDh,0DEh,0DEh,0DEh,0DFh,0DFh
db 0DFh,0E0h,0E0h,0E1h,0E1h,0E1h,0E2h,0E2h,0E2h,0E3h,0E3h,0E3h,0E4h,0E4h,0E4h,0E5h
db 0E5h,0E5h,0E6h,0E6h,0E6h,0E7h,0E7h,0E7h,0E7h,0E8h,0E8h,0E8h,0E9h,0E9h,0E9h,0EAh
db 0EAh,0EAh,0EAh,0EBh,0EBh,0EBh,0ECh,0ECh,0ECh,0ECh,0EDh,0EDh,0EDh,0EDh,0EEh,0EEh
db 0EEh,0EEh,0EFh,0EFh,0EFh,0EFh,0F0h,0F0h,0F0h,0F1h,0F1h,0F1h,0F1h,0F1h,0F2h,0F2h
db 0F2h,0F2h,0F3h,0F3h,0F3h,0F3h,0F4h,0F4h,0F4h,0F4h,0F5h,0F5h,0F5h,0F5h,0F5h,0F6h
db 0F6h,0F6h,0F6h,0F7h,0F7h,0F7h,0F7h,0F7h,0F8h,0F8h,0F8h,0F8h,0F9h,0F9h,0F9h,0F9h
db 0F9h,0FAh,0FAh,0FAh,0FAh,0FAh,0FBh,0FBh,0FBh,0FBh,0FBh,0FCh,0FCh,0FCh,0FCh,0FCh
db 0FDh,0FDh,0FDh,0FDh,0FDh,0FDh,0FEh,0FEh,0FEh,0FEh,0FEh,0FFh,0FFh,0FFh,0FFh,0FFh
endif
tscaljps=$+shift
ds 256;INCBIN "scaljps"
tID=$+shift
MACRO WALL pgnum,num2
DB pgnum,num2;-pgnum,num2
ENDM
DUP 64+16 ;skip and 0..15 ;в примере используются стены 16..35
WALL 0,#02
EDUP
MACRO PGWALL pgnum
WALL pgnum,#02
WALL pgnum,#42
WALL pgnum,#82
WALL pgnum,#C2
ENDM
PGWALL 0
PGWALL 1
PGWALL 2
PGWALL 3
PGWALL 4
DUP 64-20-16 ;?..63
WALL 0,#02
EDUP
cursprites=$+shift
DS 256
ltables=$-wastables
include "recmap.asm"