0001 7A28 .org $7A28 0002 7A28 ;TI-73 Replacement Boot Code BCALLs 0003 7A28 ;---------------------------------- 0004 7A28 ;To replace a boot code BCALL routine, add a label at the start 0005 7A28 ; of the code for it in the form "x_[NAME OF ENTRY POINT]:". 0006 7A28 ;The list of names is in the source for Do73Patch.exe and should 0007 7A28 ; match ti83plus.inc. 0008 7A28 ;Do not create any other labels in this format. 0009 7A28 ;This code will run from bank 1 (4000h-7FFFh) and you cannot 0010 7A28 ; reference memory here (ex. same as _PutS in Flash applications). 0011 7A28 ; Copy these things to RAM first if necessary. 0012 7A28 ;The code here should never do more than the equivalent boot code 0013 7A28 ; routine. The OS and other programs will expect you to abide by this. 0014 7A28 ;Do not include ".org" statements in this file; the process will 0015 7A28 ; add one at the beginning of this file. 0018 7A28 .list 0019 7A28 0020 7A28 x_00WriteFlash: 0021 7A28 E6 1F and 1Fh 0022 7A2A DD 21 C9 40 ld ix,_WriteFlash-4000h 0023 7A2E 18 66 jr ExecBootEP 0024 7A30 0025 7A30 x_WriteAByteSafe: 0026 7A30 E6 1F and 1Fh 0027 7A32 DD 21 C6 40 ld ix,_WriteAByteSafe-4000h 0028 7A36 18 5E jr ExecBootEP 0029 7A38 0030 7A38 x_FindGroup: 0031 7A38 E6 1F and 1Fh 0032 7A3A DD 21 B4 40 ld ix,_FindGroup-4000h 0033 7A3E 18 56 jr ExecBootEP 0034 7A40 0035 7A40 x_FindAppHeaderSubField: 0036 7A40 E6 1F and 1Fh 0037 7A42 DD 21 AB 40 ld ix,_FindAppHeaderSubField-4000h 0038 7A46 18 4E jr ExecBootEP 0039 7A48 0040 7A48 x_WriteFlashUnsafe: 0041 7A48 E6 1F and 1Fh 0042 7A4A DD 21 87 40 ld ix,_WriteFlashUnsafe-4000h 0043 7A4E 18 46 jr ExecBootEP 0044 7A50 0045 7A50 x_EraseFlashPage: 0046 7A50 E6 1F and 1Fh 0047 7A52 DD 21 84 40 ld ix,_EraseFlashPage-4000h 0048 7A56 18 3E jr ExecBootEP 0049 7A58 0050 7A58 x_FindOSHeaderSubField: 0051 7A58 E6 1F and 1Fh 0052 7A5A DD 21 75 40 ld ix,_FindOSHeaderSubField-4000h 0053 7A5E 18 36 jr ExecBootEP 0054 7A60 0055 7A60 x_FindSubField: 0056 7A60 E6 1F and 1Fh 0057 7A62 DD 21 5D 40 ld ix,_FindSubField-4000h 0058 7A66 18 2E jr ExecBootEP 0059 7A68 0060 7A68 x_GetFieldSize: 0061 7A68 E6 1F and 1Fh 0062 7A6A DD 21 5A 40 ld ix,_GetFieldSize-4000h 0063 7A6E 18 26 jr ExecBootEP 0064 7A70 0065 7A70 x_FlashToRam2: 0066 7A70 E6 1F and 1Fh 0067 7A72 DD 21 54 40 ld ix,_FlashToRam2-4000h 0068 7A76 18 1E jr ExecBootEP 0069 7A78 0070 7A78 x_LoadAIndPaged: 0071 7A78 E6 1F and 1Fh 0072 7A7A DD 21 51 40 ld ix,_LoadAIndPaged-4000h 0073 7A7E 18 16 jr ExecBootEP 0074 7A80 0075 7A80 x_FindGroupedField: 0076 7A80 E6 1F and 1Fh 0077 7A82 DD 21 30 40 ld ix,_FindGroupedField-4000h 0078 7A86 18 0E jr ExecBootEP 0079 7A88 0080 7A88 x_EraseFlash: 0081 7A88 E6 1F and 1Fh 0082 7A8A DD 21 24 40 ld ix,_EraseFlash-4000h 0083 7A8E 18 06 jr ExecBootEP 0084 7A90 0085 7A90 x_WriteAByte: 0086 7A90 E6 1F and 1Fh 0087 7A92 DD 21 21 40 ld ix,_WriteAByte-4000h 0088 7A96 ; call ExecBootEP 0089 7A96 ; ret 0090 7A96 0091 7A96 ExecBootEP: 0092 7A96 E5 push hl 0093 7A97 D5 push de 0094 7A98 C5 push bc 0095 7A99 21 B3 7A ld hl,_ExecBootEP 0096 7A9C 11 61 81 ld de,ramCode+1+60h 0097 7A9F 01 22 00 ld bc,_ExecBootEPEnd-_ExecBootEP 0098 7AA2 ED B0 ldir 0099 7AA4 C1 pop bc 0100 7AA5 D1 pop de 0101 7AA6 E1 pop hl 0102 7AA7 32 60 81 ld (ramCode+60h),a 0103 7AAA DB 06 in a,(6) 0104 7AAC F5 push af 0105 7AAD 3E 1F ld a,1Fh 0106 7AAF E5 push hl 0107 7AB0 C3 61 81 jp ramCode+1+60h 0108 7AB3 _ExecBootEP: 0109 7AB3 D3 06 out (6),a 0110 7AB5 DD 6E 00 ld l,(ix+0) 0111 7AB8 DD 66 01 ld h,(ix+1) 0112 7ABB E5 push hl 0113 7ABC DD E1 pop ix 0114 7ABE E1 pop hl 0115 7ABF 3A 60 81 ld a,(ramCode+60h) 0116 7AC2 CD 81 81 call jpIX-_ExecBootEP+ramCode+1+60h 0117 7AC5 32 60 81 ld (ramCode+60h),a 0118 7AC8 E3 ex (sp),hl 0119 7AC9 7D ld a,l 0120 7ACA D3 06 out (6),a 0121 7ACC 3A 60 81 ld a,(ramCode+60h) 0122 7ACF E3 ex (sp),hl 0123 7AD0 DD E1 pop ix 0124 7AD2 C9 ret 0125 7AD3 DD E9 jpIX: jp (ix) 0126 7AD5 _ExecBootEPEnd: 0127 7AD5 0128 7AD5 x_ProdNrPart1: 0129 7AD5 11 04 00 ld de,0004h 0130 7AD8 C9 ret 0131 7AD9 0132 7AD9 x_cmpStr: 0133 7AD9 AF xor a 0134 7ADA C9 ret 0135 7ADB 0136 7ADB x_GetBootVer: 0137 7ADB AF xor a 0138 7ADC 06 01 ld b,1 0139 7ADE C9 ret 0140 7ADF 0141 7ADF x_DispBootVer: 0142 7ADF 21 00 00 ld hl,0 0143 7AE2 22 4B 84 ld (curRow),hl 0144 7AE5 21 F1 7A ld hl,sBootCodeText 0145 7AE8 7E PutS: ld a,(hl) 0146 7AE9 B7 or a 0147 7AEA C8 ret z 0148 7AEB EF bcall(_PutC) 0148 7AEC 04 45 0149 7AEE 23 inc hl 0150 7AEF 18 F7 jr PutS 0151 7AF1 sBootCodeText: 0152 7AF1 424F4F542043 .db "BOOT Code 0.02b",0 0152 7AF7 6F646520302E30326200 0153 7B01 0154 7B01 x_Div16By8: 0155 7B01 16 00 ld d,0 0156 7B03 x_Div16By16: 0157 7B03 7A ld a,d 0158 7B04 B3 or e 0159 7B05 C8 ret z 0160 7B06 AF xor a 0161 7B07 DD 21 51 82 ld ix,8251h 0162 7B0B DD 75 00 ld (ix+0),l 0163 7B0E DD 74 01 ld (ix+1),h 0164 7B11 67 ld h,a 0165 7B12 6F ld l,a 0166 7B13 DD 77 02 ld (ix+2),a 0167 7B16 06 10 ld b,16 0168 7B18 div16By8Loop: 0169 7B18 DD CB 00 26 sla (ix+0) 0170 7B1C DD CB 01 16 rl (ix+1) 0171 7B20 CB 15 rl l 0172 7B22 CB 14 rl h 0173 7B24 DD CB 02 16 rl (ix+2) 0174 7B28 B7 or a 0175 7B29 ED 52 sbc hl,de 0176 7B2B DD 7E 02 ld a,(ix+2) 0177 7B2E DE 00 sbc a,0 0178 7B30 DD 77 02 ld (ix+2),a 0179 7B33 F2 41 7B jp p,div16By8_1 0180 7B36 19 add hl,de 0181 7B37 DD 7E 02 ld a,(ix+2) 0182 7B3A CE 00 adc a,0 0183 7B3C DD 77 02 ld (ix+2),a 0184 7B3F 18 04 jr div16By8_2 0185 7B41 div16By8_1: 0186 7B41 DD CB 00 C6 set 0,(ix+0) 0187 7B45 div16By8_2: 0188 7B45 10 D1 djnz div16By8Loop 0189 7B47 DD 5E 00 ld e,(ix+0) 0190 7B4A DD 56 01 ld d,(ix+1) 0191 7B4D C9 ret 0192 7B4E 0193 7B4E x_Div32By16: 0194 7B4E 7A ld a,d 0195 7B4F B3 or e 0196 7B50 C8 ret z 0197 7B51 DD 21 51 82 ld ix,8251h 0198 7B55 3A 78 84 ld a,(OP1) 0199 7B58 DD 77 03 ld (ix+3),a 0200 7B5B 3A 79 84 ld a,(OP1+1) 0201 7B5E DD 77 02 ld (ix+2),a 0202 7B61 3A 7A 84 ld a,(OP1+2) 0203 7B64 DD 77 01 ld (ix+1),a 0204 7B67 3A 7B 84 ld a,(OP1+3) 0205 7B6A DD 77 00 ld (ix+0),a 0206 7B6D AF xor a 0207 7B6E 32 78 84 ld (OP1),a 0208 7B71 32 79 84 ld (OP1+1),a 0209 7B74 32 7A 84 ld (OP1+2),a 0210 7B77 32 7B 84 ld (OP1+3),a 0211 7B7A 06 20 ld b,32 0212 7B7C div32Loop: 0213 7B7C DD CB 00 26 sla (ix+0) 0214 7B80 DD CB 01 16 rl (ix+1) 0215 7B84 DD CB 02 16 rl (ix+2) 0216 7B88 DD CB 03 16 rl (ix+3) 0217 7B8C DD 21 78 84 ld ix,OP1 0218 7B90 DD CB 00 16 rl (ix+0) 0219 7B94 DD CB 01 16 rl (ix+1) 0220 7B98 DD CB 02 16 rl (ix+2) 0221 7B9C DD CB 03 16 rl (ix+3) 0222 7BA0 DD 21 51 82 ld ix,8251h 0223 7BA4 B7 or a 0224 7BA5 2A 78 84 ld hl,(OP1) 0225 7BA8 ED 52 sbc hl,de 0226 7BAA 22 78 84 ld (OP1),hl 0227 7BAD 2A 7A 84 ld hl,(OP1+2) 0228 7BB0 C5 push bc 0229 7BB1 01 00 00 ld bc,0 0230 7BB4 ED 42 sbc hl,bc 0231 7BB6 C1 pop bc 0232 7BB7 22 7A 84 ld (OP1+2),hl 0233 7BBA 30 18 jr nc,div32_1 0234 7BBC B7 or a 0235 7BBD 2A 78 84 ld hl,(OP1) 0236 7BC0 ED 5A adc hl,de 0237 7BC2 22 78 84 ld (OP1),hl 0238 7BC5 2A 7A 84 ld hl,(OP1+2) 0239 7BC8 C5 push bc 0240 7BC9 01 00 00 ld bc,0 0241 7BCC ED 4A adc hl,bc 0242 7BCE 22 7A 84 ld (OP1+2),hl 0243 7BD1 C1 pop bc 0244 7BD2 18 04 jr div32_2 0245 7BD4 DD CB 00 C6 div32_1:set 0,(ix+0) 0246 7BD8 10 A2 div32_2:djnz div32Loop 0247 7BDA DD 21 78 84 ld ix,OP1 0248 7BDE DD 66 02 ld h,(ix+2) 0249 7BE1 DD 6E 03 ld l,(ix+3) 0250 7BE4 22 83 84 ld (OP2),hl 0251 7BE7 DD 66 00 ld h,(ix+0) 0252 7BEA DD 6E 01 ld l,(ix+1) 0253 7BED 22 85 84 ld (OP2+2),hl 0254 7BF0 DD 21 51 82 ld ix,8251h 0255 7BF4 DD 66 02 ld h,(ix+2) 0256 7BF7 DD 6E 03 ld l,(ix+3) 0257 7BFA 22 78 84 ld (OP1),hl 0258 7BFD DD 66 00 ld h,(ix+0) 0259 7C00 DD 6E 01 ld l,(ix+1) 0260 7C03 22 7A 84 ld (OP1+2),hl 0261 7C06 C9 ret 0262 7C07 0263 7C07 .end 0264 7C07 end 0265 7C07 tasm: Number of errors = 0