;LAST UPDATE: 06.03.2020 savelij
TITLE "addon1.a80 ROM_RST81"
PHASE CPU0
JP $
DUPL 0X0008-$,0XFF
JP $
DUPL 0X0010-$,0XFF
JP $
DUPL ADR_SEL_ROM-$,0XFF
OUT (C),A ;0014
NOP
RET
DUPL 0X0018-$,0XFF
JP $
DUPL 0X0020-$,0XFF
JP $
DUPL 0X0028-$,0XFF
JP $
DUPL 0X0030-$,0XFF
JP CALL2PAGE
DUPL ADR_PERFECT-$,0XFF
DW PERFECTCOM
DUPL 0X0038-$,0XFF ;0038
EI
RET
DUPL 0X003E-$,0XFF
EI
RET
DUPL 0X0040-$,0XFF
JP INSTALL_NMIRST ;УСТАНОВКА ОБРАБОТЧИКОВ NMI И RST
DUPL 0X0080-$,0XFF
binclude ../../dec40.bin
DUPL 0X00FF-$,0XFF
DW 0X0038
PHASE $+0X4000
include rst8_data.a80
PHASE $ & 0X3FFF
DUPL (HIGH ($)+1)*0X100-$,0XFF
BUF_CRC16_TABL DB 0X00,0X10,0X20,0X30,0X40,0X50,0X60,0X70,0X81,0X91,0XA1,0XB1,0XC1,0XD1,0XE1,0XF1
DB 0X12,0X02,0X32,0X22,0X52,0X42,0X72,0X62,0X93,0X83,0XB3,0XA3,0XD3,0XC3,0XF3,0XE3
DB 0X24,0X34,0X04,0X14,0X64,0X74,0X44,0X54,0XA5,0XB5,0X85,0X95,0XE5,0XF5,0XC5,0XD5
DB 0X36,0X26,0X16,0X06,0X76,0X66,0X56,0X46,0XB7,0XA7,0X97,0X87,0XF7,0XE7,0XD7,0XC7
DB 0X48,0X58,0X68,0X78,0X08,0X18,0X28,0X38,0XC9,0XD9,0XE9,0XF9,0X89,0X99,0XA9,0XB9
DB 0X5A,0X4A,0X7A,0X6A,0X1A,0X0A,0X3A,0X2A,0XDB,0XCB,0XFB,0XEB,0X9B,0X8B,0XBB,0XAB
DB 0X6C,0X7C,0X4C,0X5C,0X2C,0X3C,0X0C,0X1C,0XED,0XFD,0XCD,0XDD,0XAD,0X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5,0X86,0XA7,0X40,0X61,0X02,0X23,0XCC,0XED,0X8E,0XAF,0X48,0X69,0X0A,0X2B
DB 0XF5,0XD4,0XB7,0X96,0X71,0X50,0X33,0X12,0XFD,0XDC,0XBF,0X9E,0X79,0X58,0X3B,0X1A
DB 0XA6,0X87,0XE4,0XC5,0X22,0X03,0X60,0X41,0XAE,0X8F,0XEC,0XCD,0X2A,0X0B,0X68,0X49
DB 0X97,0XB6,0XD5,0XF4,0X13,0X32,0X51,0X70,0X9F,0XBE,0XDD,0XFC,0X1B,0X3A,0X59,0X78
DB 0X88,0XA9,0XCA,0XEB,0X0C,0X2D,0X4E,0X6F,0X80,0XA1,0XC2,0XE3,0X04,0X25,0X46,0X67
DB 0XB9,0X98,0XFB,0XDA,0X3D,0X1C,0X7F,0X5E,0XB1,0X90,0XF3,0XD2,0X35,0X14,0X77,0X56
DB 0XEA,0XCB,0XA8,0X89,0X6E,0X4F,0X2C,0X0D,0XE2,0XC3,0XA0,0X81,0X66,0X47,0X24,0X05
DB 0XDB,0XFA,0X99,0XB8,0X5F,0X7E,0X1D,0X3C,0XD3,0XF2,0X91,0XB0,0X57,0X76,0X15,0X34
DB 0X4C,0X6D,0X0E,0X2F,0XC8,0XE9,0X8A,0XAB,0X44,0X65,0X06,0X27,0XC0,0XE1,0X82,0XA3
DB 0X7D,0X5C,0X3F,0X1E,0XF9,0XD8,0XBB,0X9A,0X75,0X54,0X37,0X16,0XF1,0XD0,0XB3,0X92
DB 0X2E,0X0F,0X6C,0X4D,0XAA,0X8B,0XE8,0XC9,0X26,0X07,0X64,0X45,0XA2,0X83,0XE0,0XC1
DB 0X1F,0X3E,0X5D,0X7C,0X9B,0XBA,0XD9,0XF8,0X17,0X36,0X55,0X74,0X93,0XB2,0XD1,0XF0
; БЫСТРАЯ (ТАБЛИЧНАЯ) ФУНКЦИЯ ПОДСЧЁТА CRC-16,
; IX=*DATA, HL=SIZE
; НА ВЫХОДЕ -> HL=ПОДСЧИТАННОЕ ЗНАЧЕНИЕ
CRC16_FAST LD B,H
LD C,L
LD HL,0XFFFF
EXX
PUSH HL
LD DE,BUF_CRC16_TABL
LD C,0
EXX
CRC16F0 LD A,(IX)
XOR H
INC IX
EXX
LD L,A
LD H,C
ADD HL,DE
LD A,(HL)
INC H
EXX
XOR L
LD H,A
EXX
LD A,(HL)
EXX
LD L,A
DEC BC
LD A,B
OR C
JP NZ,CRC16F0
EXX
POP HL
EXX
RET
;УСТАНОВКА ОБРАБОТЧИКОВ RST 8 И NMI, ИНИЦИАЛИЗАЦИЯ ПЕРЕМЕННЫХ
INSTALL_NMIRST ATMPORT WIN_A3,0X40 ;СНЯЛИ ЗАВИСИМОСТЬ ОТ ПОРТА 7FFD
EVOPORT WIN_P6,0 ;ВКЛЮЧИЛИ СТРАНИЦУ ПЕРЕМЕННЫХ
LD A,0XEF
IN A,(0XFE)
RRCA
JR NC,INSTALLNMIRST2
LD IX,CPU2+STACK_NMI
LD HL,0X40
CALL CRC16_FAST ;СЧИТАЕМ CRC НА МЕСТЕ ОБРАБОТЧИКА
PUSH HL ;СОХРАНИЛИ CRC
LD IX,CODE_NMIRST+STACK_NMI
LD HL,0X40
CALL CRC16_FAST
POP BC ;ВЕРНУЛИ РАНЕЕ ПОСЧИТАННОЕ CRC
XOR A
SBC HL,BC ;СРАВНИЛИ
JR Z,INSTALLNMIRST1 ;ЕСЛИ СОВПАЛО БОЛЬШЕ НИЧЕГО НЕ ДЕЛАЕМ
EVOPORT WIN_P3,RAM_PROFROM
LD HL,CPU0
CALL FILL_MEM ;ОЧИСТКА СТРАНИЦЫ ОЗУ PROFROM
IFDEF DOS_FE
; сброс виртуальных дисководов после включиения и при полном ините
LD BC,FDD_EMU_PORT
XOR A
OUT (C),A
ENDIF
;НЕ СОВПАЛО, ПЕРВЫЙ ЗАПУСК ПОСЛЕ ВКЛЮЧЕНИЯ ПИТАНИЯ ИЛИ ОБРАБОТЧИКИ БЫЛИ ИСПОРЧЕНЫ
INSTALLNMIRST2 LD HL,CPU3
CALL FILL_MEM ;ОЧИСТКА ПОСЛЕДНЕЙ СТРАНИЦЫ RAM
LD HL,CODE_NMIRST
LD DE,CPU6
LD BC,ENMI_SERVICE-ADR_SEL_ROM-CPU6
LDIR ;УСТАНОВИЛИ ОБРАБОТЧИКИ
LD (BUF_TABLVOL+0XFE),BC ;СБРОС CRC ТАБЛИЦЫ НАЙДЕННЫХ РАЗДЕЛОВ
EVOPORT WIN_P3,RAM_MOUNTER ;ВКЛЮЧИЛИ СТРАНИЦУ МОНТИРОВЩИКА ОБРАЗОВ
LD HL,CPU0
CALL FILL_MEM ;ОЧИСТКА СТРАНИЦЫ МОНТИРОВЩИКА ОБРАЗОВ
XOR A
LD (CPU6+DEBUG_ONOFF),A ;0-DEBUGGER OFF
LD (FLAGS_DRV),A ;СБРОС ФЛАГОВ ДРАЙВЕРОВ
; IF BUILD_DEBUG=1
; ROMCALL UNPACK_STS,ROM_RST80
; ENDIF
LD A,CMOS_BYTE_00
LD BC,CMOSD_SET_ADR
OUT (C),A
LD BC,CMOSD_RD_WR
IN A,(C)
CALL LD_SET_FONT
LD A,VIRT_REAL_DRIVE
LD BC,CMOSD_SET_ADR
OUT (C),A
LD BC,CMOSD_RD_WR
IN A,(C)
LD (CPU2+VIRT_BITS),A ;ПРИ ИНИТЕ МОНТИРУЕМ ТОЛЬКО РАМДИСК
INSTALLNMIRST1 ROMCALL INIT_CMOS,ROM_RST82 ;ПРОВЕРКА И ИНИЦИАЛИЗАЦИЯ CMOS ПРИ ОШИБКЕ CRC
CALL SET4RESETFONT
IF 0;USB_ENABLE
EVOPORT WIN_P3,RAM_SCR_FONT ;СТРАНИЦЫ ДЛЯ ДРАЙВЕРА
EVOPORT WIN_A2,ROM_RST83
LD HL,USB_DRV+CPU2 ;АДРЕС ДРАЙВЕР
LD DE,OFFSET_USBDRV+CPU3 ;АДРЕС РАБОТЫ
LD BC,ECOMUSBF-COMUSBF
LDIR
EVOPORT WIN_P6,0
ENDIF
LD BC,0XFF<<8+PN_1F7
IN A,(C)
CP 0X50
LD A,1
JR Z,INSTALLNMIRST3
LD H,HDD_TIMEOUT
ROMCALL READCMOS,ROM_RST82
AND A
LD A,1
JR Z,INSTALLNMIRST3
XOR A
INSTALLNMIRST4 ADD A,25
DEC L
JR NZ,INSTALLNMIRST4
INSTALLNMIRST3 LD (HDDTIMEOUT),A
LD HL,STEK_PAGES
LD (TEKPAGE),HL
LD HL,READ_KEYS
LD (ADR_INT),HL
LD BC,WIN_A0
XOR A
LD (CPU6+FOR_RET),A
JP ADR_SEL_ROM
FILL_MEM EX DE,HL
LD HL,0
ADD HL,SP
EX DE,HL
LD SP,HL
LD HL,0
LD B,L
FILL_MEM1 REPT 0X20
PUSH HL
ENDM
DJNZ FILL_MEM1
EX DE,HL
LD SP,HL
RET
SETUP_FONT LD A,(RREG_A)
AND A
LD HL,ATM_FONT
JR Z,SET_FONT1
DEC A
LD HL,CP866_FONT
JR Z,SET_FONT1
DEC A
RET NZ
LD HL,(RREG_L)
JR SET_FONT1
SET4RESETFONT LD A,CMOS_BYTE_00
LD BC,CMOSD_SET_ADR
OUT (C),A
LD BC,CMOSD_RD_WR
IN A,(C)
LD L,A
AND M_RELOAD_FONT
RET NZ ;ЕСЛИ 1, ТО ШРИФТ НЕ ПЕРЕЗАГРУЖАЕМ
LD A,L
LD_SET_FONT AND M_TYPE_FONT ;ОПРЕДЕЛЕНИЕ ВЫБРАННОГО ШРИФТА
LD HL,ATM_FONT ;0=ШРИФТ ATM
JR Z,SET_FONT1
LD HL,CP866_FONT ;1=ШРИФТ CP866
SET_FONT1 LD DE,CPU3+OFFSET_BUFSYM
EVOPORT WIN_P3,RAM_SCR_FONT
PUSH DE
ROMCALL UNPACK,ROM_RST80
POP HL
LD BC,0X0800
LD D,C
LD E,C
PEC_ON M_SHADOW_BF+M_FONT_BF
LDIR
PEC_OFF M_FONT_BF
RET
CurrAdr := $
include nmi_service.a80
PHASE $ + CurrAdr
PERFECTCOM binclude perfpack_pack.bin
FREE_ADDON1 EQU 0X3FF6-$
DUPL FREE_ADDON1,0XFF
DW FREE_ADDON1 ;РАЗМЕР СВОБОДНОГО МЕСТА
DB "ADDON1"
DW DATA_VERS