;LAST UPDATE: 01.03.2020 savelij
TITLE "addons.a80 ROM_RST82"
DRV_VAR EQU 0X4000
PHASE 0
JP $
; LD BC,WIN_A0
; LD A,ROM_RST83
; JR ADR_SEL_ROM
DUPL ADR_SEL_ROM-$,0XFF
OUT (C),A
NOP
RET
DUPL 0X0030-$,0XFF
JP CALL2PAGE
DUPL 0X0038-$,0XFF ;0038
PUSH HL
LD HL,(ADR_INT)
EX (SP),HL
RET
EI
RET
JP UNPACK_DOS_FE
JP INST_SONGLN
DUPL 0X0080-$,0XFF
binclude ../../dec40.bin
DUPL 0X00FF-$,0XFF
DW 0X0038
;============================SD КАРТА УДАЛЕНА============================
SDCARD_LOST DB 0X08,0X08,0X04,0X10,0X17,0,%00000000,0
DW 0,0
DW TXT_SDLOST,0,0,0
TXT_SDLOST DB 0X17,0XFF,0X0D,3,"SD card lost",0X0D,3,"Press RESET",0
;============================SD КАРТА УДАЛЕНА============================
;========================МЫШИНЫЙ КУРСОР В ДВУХ ВИДАХ=====================
SPRAR DB 0X3F,0X00,0X1F,0X40,0X0F,0X60,0X07,0X50,0X03,0X48,0X01,0X4C,0X01,0X70,0X07,0X00
SPRAR2 DB 0X3F,0X00,0X1F,0X40,0X0F,0X60,0X07,0X70,0X03,0X78,0X01,0X7C,0X01,0X70,0X07,0X00
;========================МЫШИНЫЙ КУРСОР В ДВУХ ВИДАХ=====================
DUPL 0X0200-$,0XFF
CHARS binclude altstd.bin
BUFTSC DW 0X4000,0X4100,0X4200,0X4300,0X4400,0X4500,0X4600,0X4700
DW 0X4020,0X4120,0X4220,0X4320,0X4420,0X4520,0X4620,0X4720
DW 0X4040,0X4140,0X4240,0X4340,0X4440,0X4540,0X4640,0X4740
DW 0X4060,0X4160,0X4260,0X4360,0X4460,0X4560,0X4660,0X4760
DW 0X4080,0X4180,0X4280,0X4380,0X4480,0X4580,0X4680,0X4780
DW 0X40A0,0X41A0,0X42A0,0X43A0,0X44A0,0X45A0,0X46A0,0X47A0
DW 0X40C0,0X41C0,0X42C0,0X43C0,0X44C0,0X45C0,0X46C0,0X47C0
DW 0X40E0,0X41E0,0X42E0,0X43E0,0X44E0,0X45E0,0X46E0,0X47E0
DW 0X4800,0X4900,0X4A00,0X4B00,0X4C00,0X4D00,0X4E00,0X4F00
DW 0X4820,0X4920,0X4A20,0X4B20,0X4C20,0X4D20,0X4E20,0X4F20
DW 0X4840,0X4940,0X4A40,0X4B40,0X4C40,0X4D40,0X4E40,0X4F40
DW 0X4860,0X4960,0X4A60,0X4B60,0X4C60,0X4D60,0X4E60,0X4F60
DW 0X4880,0X4980,0X4A80,0X4B80,0X4C80,0X4D80,0X4E80,0X4F80
DW 0X48A0,0X49A0,0X4AA0,0X4BA0,0X4CA0,0X4DA0,0X4EA0,0X4FA0
DW 0X48C0,0X49C0,0X4AC0,0X4BC0,0X4CC0,0X4DC0,0X4EC0,0X4FC0
DW 0X48E0,0X49E0,0X4AE0,0X4BE0,0X4CE0,0X4DE0,0X4EE0,0X4FE0
DW 0X5000,0X5100,0X5200,0X5300,0X5400,0X5500,0X5600,0X5700
DW 0X5020,0X5120,0X5220,0X5320,0X5420,0X5520,0X5620,0X5720
DW 0X5040,0X5140,0X5240,0X5340,0X5440,0X5540,0X5640,0X5740
DW 0X5060,0X5160,0X5260,0X5360,0X5460,0X5560,0X5660,0X5760
DW 0X5080,0X5180,0X5280,0X5380,0X5480,0X5580,0X5680,0X5780
DW 0X50A0,0X51A0,0X52A0,0X53A0,0X54A0,0X55A0,0X56A0,0X57A0
DW 0X50C0,0X51C0,0X52C0,0X53C0,0X54C0,0X55C0,0X56C0,0X57C0
DW 0X50E0,0X51E0,0X52E0,0X53E0,0X54E0,0X55E0,0X56E0,0X57E0
BUFTSC1 DW 0XC000,0XC100,0XC200,0XC300,0XC400,0XC500,0XC600,0XC700
DW 0XC020,0XC120,0XC220,0XC320,0XC420,0XC520,0XC620,0XC720
DW 0XC040,0XC140,0XC240,0XC340,0XC440,0XC540,0XC640,0XC740
DW 0XC060,0XC160,0XC260,0XC360,0XC460,0XC560,0XC660,0XC760
DW 0XC080,0XC180,0XC280,0XC380,0XC480,0XC580,0XC680,0XC780
DW 0XC0A0,0XC1A0,0XC2A0,0XC3A0,0XC4A0,0XC5A0,0XC6A0,0XC7A0
DW 0XC0C0,0XC1C0,0XC2C0,0XC3C0,0XC4C0,0XC5C0,0XC6C0,0XC7C0
DW 0XC0E0,0XC1E0,0XC2E0,0XC3E0,0XC4E0,0XC5E0,0XC6E0,0XC7E0
DW 0XC800,0XC900,0XCA00,0XCB00,0XCC00,0XCD00,0XCE00,0XCF00
DW 0XC820,0XC920,0XCA20,0XCB20,0XCC20,0XCD20,0XCE20,0XCF20
DW 0XC840,0XC940,0XCA40,0XCB40,0XCC40,0XCD40,0XCE40,0XCF40
DW 0XC860,0XC960,0XCA60,0XCB60,0XCC60,0XCD60,0XCE60,0XCF60
DW 0XC880,0XC980,0XCA80,0XCB80,0XCC80,0XCD80,0XCE80,0XCF80
DW 0XC8A0,0XC9A0,0XCAA0,0XCBA0,0XCCA0,0XCDA0,0XCEA0,0XCFA0
DW 0XC8C0,0XC9C0,0XCAC0,0XCBC0,0XCCC0,0XCDC0,0XCEC0,0XCFC0
DW 0XC8E0,0XC9E0,0XCAE0,0XCBE0,0XCCE0,0XCDE0,0XCEE0,0XCFE0
DW 0XD000,0XD100,0XD200,0XD300,0XD400,0XD500,0XD600,0XD700
DW 0XD020,0XD120,0XD220,0XD320,0XD420,0XD520,0XD620,0XD720
DW 0XD040,0XD140,0XD240,0XD340,0XD440,0XD540,0XD640,0XD740
DW 0XD060,0XD160,0XD260,0XD360,0XD460,0XD560,0XD660,0XD760
DW 0XD080,0XD180,0XD280,0XD380,0XD480,0XD580,0XD680,0XD780
DW 0XD0A0,0XD1A0,0XD2A0,0XD3A0,0XD4A0,0XD5A0,0XD6A0,0XD7A0
DW 0XD0C0,0XD1C0,0XD2C0,0XD3C0,0XD4C0,0XD5C0,0XD6C0,0XD7C0
DW 0XD0E0,0XD1E0,0XD2E0,0XD3E0,0XD4E0,0XD5E0,0XD6E0,0XD7E0
;АДРЕСА НАЧАЛ СТРОК МОНОХРОМА ТЕКСТМОДА (ЛЕВЫЙ, ПРАВЫЙ)
TBUFTSC DW 0XC1C0,0XD1C0 ;00
DW 0XC200,0XD200 ;01
DW 0XC240,0XD240 ;02
DW 0XC280,0XD280 ;03
DW 0XC2C0,0XD2C0 ;04
DW 0XC300,0XD300 ;05
DW 0XC340,0XD340 ;06
DW 0XC380,0XD380 ;07
DW 0XC3C0,0XD3C0 ;08
DW 0XC400,0XD400 ;09
DW 0XC440,0XD440 ;10
DW 0XC480,0XD480 ;11
DW 0XC4C0,0XD4C0 ;12
DW 0XC500,0XD500 ;13
DW 0XC540,0XD540 ;14
DW 0XC580,0XD580 ;15
DW 0XC5C0,0XD5C0 ;16
DW 0XC600,0XD600 ;17
DW 0XC640,0XD640 ;18
DW 0XC680,0XD680 ;19
DW 0XC6C0,0XD6C0 ;20
DW 0XC700,0XD700 ;21
DW 0XC740,0XD740 ;22
DW 0XC780,0XD780 ;23
DW 0XC7C0,0XD7C0 ;24
;АДРЕСА НАЧАЛ СТРОК ЦВЕТА ТЕКСТМОДА (ЛЕВЫЙ, ПРАВЫЙ)
TBUFTSC_C DW 0XF1C0,0XE1C1 ;00
DW 0XF200,0XE201 ;01
DW 0XF240,0XE241 ;02
DW 0XF280,0XE281 ;03
DW 0XF2C0,0XE2C1 ;04
DW 0XF300,0XE301 ;05
DW 0XF340,0XE341 ;06
DW 0XF380,0XE381 ;07
DW 0XF3C0,0XE3C1 ;08
DW 0XF400,0XE401 ;09
DW 0XF440,0XE441 ;10
DW 0XF480,0XE481 ;11
DW 0XF4C0,0XE4C1 ;12
DW 0XF500,0XE501 ;13
DW 0XF540,0XE541 ;14
DW 0XF580,0XE581 ;15
DW 0XF5C0,0XE5C1 ;16
DW 0XF600,0XE601 ;17
DW 0XF640,0XE641 ;18
DW 0XF680,0XE681 ;19
DW 0XF6C0,0XE6C1 ;20
DW 0XF700,0XE701 ;21
DW 0XF740,0XE741 ;22
DW 0XF780,0XE781 ;23
DW 0XF7C0,0XE7C1 ;24
RD_SET_PAL LD HL,(ADR_INT)
PUSH HL
LD HL,EI_RET
LD (ADR_INT),HL
LD DE,0XAF0F ;ДАЛЬШЕ СОХРАНЯЕМ ТЕКУЩУЮ ПАЛИТРУ
LD BC,0XBD77
OUT (C),D ;ВКЛЮЧЕНИЕ ТЕКСТМОДА
LD HL,(ADR_PALITRA)
LD BC,RD_PALITRA
EI
HALT
DI
NMISERV003 LD A,E
BIT 3,E
OUT (0XFE),A
JR Z,NMISERV004
OUT (0XF6),A
NMISERV004 IN A,(C)
LD (HL),A
INC HL
DEC E
JP P,NMISERV003 ;ПАЛИТРУ СОХРАНИЛИ
LD HL,MAGIC_PAL
LD E,0X0F
SETPAL1 LD A,E
BIT 3,E
OUT (0XFE),A
JR Z,$+4
OUT (0XF6),A
LD A,(HL)
INC HL
OR %00001100
OUT (0XFF),A
DEC E
JP P,SETPAL1
LD BC,0XFF77
OUT (C),D
POP HL
LD (ADR_INT),HL
RET
MAGIC_PAL DB 0X0C,0X2D,0X4E,0X6F,0X9C,0XBD,0XDE,0XFF
DB 0XEC,0XED,0XEE,0XEF,0XFC,0XFD,0XFE,0XFF
;ПАЛИТРА ДЛЯ SPECTRUM РЕЖИМА
TRSTPAL DB 0X00,0X21,0X42,0X63,0X90,0XB1,0XD2,0XF3
DB 0XE0,0XE1,0XE2,0XE3,0XF0,0XF1,0XF2,0XF3
SETUP_PAL1 LD HL,(RREG_L)
LD DE,EXTERN_PAL-CPU6
LD BC,0X10
ROMCALL LDIR_BYTES,ROM_RST83
LD HL,EXTERN_PAL
JR RESTOREPAL1
SETUP_PAL LD A,(RREG_A)
AND A
JR NZ,SETUP_PAL1
LD HL,TRSTPAL
RESTOREPAL1 LD (ADR_PALITRA),HL
RESTORE_PAL LD HL,(ADR_INT)
PUSH HL
LD HL,EI_RET
LD (ADR_INT),HL
LD HL,(ADR_PALITRA)
LD DE,0XAF0F
LD BC,0XBD77 ;ДОСТУП К ПАЛИТРЕ
OUT (C),D ;вкл.PAL
EI
HALT
DI
SETPAL0 LD A,E
BIT 3,E
OUT (0XFE),A
JR Z,$+4
OUT (0XF6),A
LD A,(HL)
INC HL
OR %00001100
OUT (0XFF),A
DEC E
JP P,SETPAL0
LD BC,0XFF77
OUT (C),D
POP HL
LD (ADR_INT),HL
RET
PRINT_REGS LD E,(IX)
INC IX
LD D,(IX)
INC IX
PRTT_HL_ LD A,H
CALL PRTT_A
LD A,L
PRTT_A PUSH AF
RRCA
RRCA
RRCA
RRCA
CALL PRTT_A_1
POP AF
PRTT_A_1 AND 0X0F
CP 0X0A
CCF
ADC A,"0"
DAA
AND 0X7F
JP PRTT_A_;ROMCALL PRTT_A_,P_ADDONS
; RET
PRINT_REG LD E,(IX)
INC IX
LD D,(IX)
INC IX
JR PRTT_A
COORDINAT_REGS DW Y_OFFSET+1+(X_OFFSET+3)*0X100 ;SP
DW Y_OFFSET+1+(X_OFFSET+3+9)*0X100 ;PC
DW Y_OFFSET+2+(X_OFFSET+3)*0X100 ;IR
DW Y_OFFSET+3+(X_OFFSET+3)*0X100 ;AF
DW Y_OFFSET+3+(X_OFFSET+3+9)*0X100 ;AF'
DW Y_OFFSET+4+(X_OFFSET+3)*0X100 ;BC
DW Y_OFFSET+4+(X_OFFSET+3+9)*0X100 ;BC'
DW Y_OFFSET+5+(X_OFFSET+3)*0X100 ;DE
DW Y_OFFSET+5+(X_OFFSET+3+9)*0X100 ;DE'
DW Y_OFFSET+6+(X_OFFSET+3)*0X100 ;HL
DW Y_OFFSET+6+(X_OFFSET+3+9)*0X100 ;HL'
DW Y_OFFSET+7+(X_OFFSET+3)*0X100 ;IX
DW Y_OFFSET+7+(X_OFFSET+3+9)*0X100 ;IY
DW Y_OFFSET+8+(X_OFFSET+5)*0X100 ;INT EI/DI
DW Y_OFFSET+8+(X_OFFSET+3+10)*0X100 ;INT IM 1/2
DW Y_OFFSET+0X0B+(X_OFFSET+6)*0X100 ;CPU3 MAP0
DW Y_OFFSET+0X0B+(X_OFFSET+6+3)*0X100 ;CPU3 MAP1
DW Y_OFFSET+0X0C+(X_OFFSET+6)*0X100 ;CPU6 MAP0
DW Y_OFFSET+0X0C+(X_OFFSET+6+3)*0X100 ;CPU6 MAP1
DW Y_OFFSET+0X0D+(X_OFFSET+6)*0X100 ;CPU5 MAP0
DW Y_OFFSET+0X0D+(X_OFFSET+6+3)*0X100 ;CPU5 MAP1
DW Y_OFFSET+0X0E+(X_OFFSET+6)*0X100 ;CPU0 MAP0
DW Y_OFFSET+0X0E+(X_OFFSET+6+3)*0X100 ;CPU0 MAP1
DW Y_OFFSET+0X10+(X_OFFSET+5)*0X100 ;PORT 7FFD
DW Y_OFFSET+0X11+(X_OFFSET+5)*0X100 ;PORT EFF7
DW Y_OFFSET+0X12+(X_OFFSET+0)*0X100 ;PORT XX77
DW Y_OFFSET+0X12+(X_OFFSET+0+5)*0X100 ;BYTE IN PORT XX77
DW Y_OFFSET+0X13+(X_OFFSET+5)*0X100 ;PORT BF
DW Y_OFFSET+0X15+(X_OFFSET+11)*0X100 ;BIT DOS ENABLE
PRT_PORTREGS LD A,MAGIC_COLOR
LD (TXT_COLOR),A
LD IX,COORDINAT_REGS
LD HL,(NMI_SAVE_SP)
CALL PRINT_REGS ;SP
LD HL,(NADRRET_L)
CALL PRINT_REGS ;PC
LD A,(NREG_I)
LD H,A
LD A,(NREG_R)
LD L,A
CALL PRINT_REGS ;IR
LD HL,(NREG_F)
CALL PRINT_REGS ;AF
LD HL,(NREG_FF)
CALL PRINT_REGS ;AF'
LD HL,(NREG_C)
CALL PRINT_REGS ;BC
LD HL,(NREG_CC)
CALL PRINT_REGS ;BC'
LD HL,(NREG_E)
CALL PRINT_REGS ;DE
LD HL,(NREG_EE)
CALL PRINT_REGS ;DE'
LD HL,(NREG_L)
CALL PRINT_REGS ;HL
LD HL,(NREG_LL)
CALL PRINT_REGS ;HL'
LD HL,(NREG_IXL)
CALL PRINT_REGS ;IX
LD HL,(NREG_IYL)
CALL PRINT_REGS ;IY
LD A,(INT_MODE)
ADD A,"0"
CALL PRINT_1NUM ;INT ON/OFF
LD A,(NUM_IM)
ADD A,"1"
CALL PRINT_1NUM ;IM 1/2
LD A,(B0_CPU3)
CALL PRINT_REG ;CPU3 MAP0
LD A,(B1_CPU3)
CALL PRINT_REG ;CPU3 MAP1
LD A,(B0_CPU2)
CALL PRINT_REG ;CPU6 MAP0
LD A,(B1_CPU2)
CALL PRINT_REG ;CPU6 MAP1
LD A,(B0_CPU1)
CALL PRINT_REG ;CPU5 MAP0
LD A,(B1_CPU1)
CALL PRINT_REG ;CPU5 MAP1
LD A,(B0_CPU0)
CALL PRINT_REG ;CPU0 MAP0
LD A,(B1_CPU0)
CALL PRINT_REG ;CPU0 MAP1
; LD A,(N_7FFD)
READ_7FFD
CALL PRINT_REG ;PORT 7FFD
LD A,(N_EFF7)
CALL PRINT_REG ;PORT EFF7
LD A,(N_77)
AND %11100000
RRCA
LD B,A
RRCA
RRCA
RRCA
RRCA
OR B
OR 0XBC
CALL PRINT_REG ;PORT XX77
LD A,(N_77)
AND 0X0F
CALL PRINT_REG ;BYTE IN PORT XX77
LD A,(N_BF)
CALL PRINT_REG ;PORT BF
LD A,(N_77)
AND 0X10
RRCA
RRCA
RRCA
RRCA
ADD A,"0"
PRINT_1NUM LD E,(IX)
INC IX
LD D,(IX)
INC IX
JP PRTT_A_;ROMCALL PRTT_A_,P_ADDONS ;BIT DOS ENABLE
; RET
;установка режимов
SET_MODE LD A,(RREG_A)
ISET_MODE AND A
JR Z,SET_MODE4
LD E,A
LD (TEK_MODES),A ;сохранили устанавливаемые режимы
AND A ;если 0 то получение режима
JR Z,SET_MODE4;2
BIT 3,A
JR Z,.L4
;установка номера экрана
AND %00000111
LD D,A
LD A,(B_PORT77)
AND %11111000
OR D
LD (B_PORT77),A ;установили видео режим в порту xx77
.L4 LD A,E
RRCA
RRCA
RRCA
RRCA
LD E,A ;сейчас биты 1-0 содержат турбо режим
RRCA
RRCA
AND 3 ;взяли биты турборежима
JR Z,.L3 ;если 0 то режим турбо не меняем
;смена турборежима
EXX
DEC A ;1
LD HL,0X0010 ;TURBO 3,5 MHZ
JR Z,.L2
DEC A ;2
LD HL,0X0000 ;TURBO 7,0 MHZ
JR Z,.L2
LD HL,0X0800 ;TURBO 14 MHZ
.L2 LD A,(R_EFF7)
AND %11101111
OR L
LD (R_EFF7),A ;установили турбо для порта EFF7
LD A,(B_PORT77)
AND %11110111
OR H
LD (B_PORT77),A ;установили турбо режим для порта xx77
; LD H,CMOS_BYTE_01
; CALL READCMOS
; AND %01111100
; OR E
; LD L,A
; CALL IWRITECMOS
; LD H,CMOS_BYTE_00
; CALL READCMOS
; OR D
; LD L,A
; CALL IWRITECMOS
EXX
.L3 LD A,E
AND 3 ;выделили биты режима памяти
JR Z,SET_MODE4 ;если 0 то режим памяти не меняем
;смена режима памяти
DEC A
LD HL,0X0000 ;память 1024К
JR Z,.L1
DEC A
LD HL,0X2004 ;память 48К
JR Z,.L1
LD HL,0X0004 ;память 128К
.L1 LD A,(R_7FFD)
AND %11011111
OR H
LD (R_7FFD),A
LD A,(R_EFF7)
AND %11111011
OR L
LD (R_EFF7),A
; LD H,CMOS_BYTE_01
; CALL READCMOS
; AND 0XFC
; OR D
; LD L,A
; JP IWRITECMOS
RET
SET_MODE4 LD A,(TEK_MODES)
LD (RREG_A),A
RET
;ДЕФОЛТНЫЕ ЗНАЧЕНИЯ ДЛЯ В КМОС
; ED EC EB EA E9 E8
CMOS_DEFAULT DB 0X04,0X02,0X00,0X00,0X00,0X00
ECMOS_DEFAULT
INST_SONGLN LD HL,SONGLNBIN
LD DE,0XC000
JP UNPACK
SONGLNBIN binclude songln_pack.bin
include tape.a80
include ay_printer.a80
include txtmode_proc.a80
include window.a80
include selector.a80
include input_keys.a80
include mouse.a80
include file_browser.a80
include call_trdos.a80
include call_cmos.a80
PHASE $+CPU3
UNPACK_DOS_FE LD HL,PACK_DOS_FE
LD DE,CPU2
JP UNPACK+CPU3
PACK_DOS_FE binclude ../../page1/dos_fe_pack.rom
DEPHASE
FREE_ADDONS EQU 0X3FF6-$
DUPL FREE_ADDONS,0XFF
DW FREE_ADDONS ;РАЗМЕР СВОБОДНОГО МЕСТА
DB "ADDONS"
DW DATA_VERS
DEPHASE