0001 0000 ;TI-73 Replacement Boot Code BCALLs 0002 0000 ;---------------------------------- 0003 0000 ;To replace a boot code BCALL routine, add a label at the start 0004 0000 ; of the code for it in the form "x_[NAME OF ENTRY POINT]:". 0005 0000 ;The list of names is in the source for Do73Patch.exe and should 0006 0000 ; match ti83plus.inc. 0007 0000 ;Do not create any other labels in this format. 0008 0000 ;This code will run from bank 1 (4000h-7FFFh) and you cannot 0009 0000 ; reference memory here (ex. same as _PutS in Flash applications). 0010 0000 ; Copy these things to RAM first if necessary. 0011 0000 ;The code here should never do more than the equivalent boot code 0012 0000 ; routine. The OS and other programs will expect you to abide by this. 0013 0000 ;Do not include ".org" statements in this file; the process will 0014 0000 ; add one at the beginning of this file. 0017 0000 .list 0018 0000 0019 0000 x_00WriteFlash: 0020 0000 E6 1F and 1Fh 0021 0002 DD 21 C9 40 ld ix,_WriteFlash-4000h 0022 0006 18 66 jr ExecBootEP 0023 0008 0024 0008 x_WriteAByteSafe: 0025 0008 E6 1F and 1Fh 0026 000A DD 21 C6 40 ld ix,_WriteAByteSafe-4000h 0027 000E 18 5E jr ExecBootEP 0028 0010 0029 0010 x_FindGroup: 0030 0010 E6 1F and 1Fh 0031 0012 DD 21 B4 40 ld ix,_FindGroup-4000h 0032 0016 18 56 jr ExecBootEP 0033 0018 0034 0018 x_FindAppHeaderSubField: 0035 0018 E6 1F and 1Fh 0036 001A DD 21 AB 40 ld ix,_FindAppHeaderSubField-4000h 0037 001E 18 4E jr ExecBootEP 0038 0020 0039 0020 x_WriteFlashUnsafe: 0040 0020 E6 1F and 1Fh 0041 0022 DD 21 87 40 ld ix,_WriteFlashUnsafe-4000h 0042 0026 18 46 jr ExecBootEP 0043 0028 0044 0028 x_EraseFlashPage: 0045 0028 E6 1F and 1Fh 0046 002A DD 21 84 40 ld ix,_EraseFlashPage-4000h 0047 002E 18 3E jr ExecBootEP 0048 0030 0049 0030 x_FindOSHeaderSubField: 0050 0030 E6 1F and 1Fh 0051 0032 DD 21 75 40 ld ix,_FindOSHeaderSubField-4000h 0052 0036 18 36 jr ExecBootEP 0053 0038 0054 0038 x_FindSubField: 0055 0038 E6 1F and 1Fh 0056 003A DD 21 5D 40 ld ix,_FindSubField-4000h 0057 003E 18 2E jr ExecBootEP 0058 0040 0059 0040 x_GetFieldSize: 0060 0040 E6 1F and 1Fh 0061 0042 DD 21 5A 40 ld ix,_GetFieldSize-4000h 0062 0046 18 26 jr ExecBootEP 0063 0048 0064 0048 x_FlashToRam2: 0065 0048 E6 1F and 1Fh 0066 004A DD 21 54 40 ld ix,_FlashToRam2-4000h 0067 004E 18 1E jr ExecBootEP 0068 0050 0069 0050 x_LoadAIndPaged: 0070 0050 E6 1F and 1Fh 0071 0052 DD 21 51 40 ld ix,_LoadAIndPaged-4000h 0072 0056 18 16 jr ExecBootEP 0073 0058 0074 0058 x_FindGroupedField: 0075 0058 E6 1F and 1Fh 0076 005A DD 21 30 40 ld ix,_FindGroupedField-4000h 0077 005E 18 0E jr ExecBootEP 0078 0060 0079 0060 x_EraseFlash: 0080 0060 E6 1F and 1Fh 0081 0062 DD 21 24 40 ld ix,_EraseFlash-4000h 0082 0066 18 06 jr ExecBootEP 0083 0068 0084 0068 x_WriteAByte: 0085 0068 E6 1F and 1Fh 0086 006A DD 21 21 40 ld ix,_WriteAByte-4000h 0087 006E ; call ExecBootEP 0088 006E ; ret 0089 006E 0090 006E ExecBootEP: 0091 006E E5 push hl 0092 006F D5 push de 0093 0070 C5 push bc 0094 0071 21 8B 00 ld hl,_ExecBootEP 0095 0074 11 61 81 ld de,ramCode+1+60h 0096 0077 01 22 00 ld bc,_ExecBootEPEnd-_ExecBootEP 0097 007A ED B0 ldir 0098 007C C1 pop bc 0099 007D D1 pop de 0100 007E E1 pop hl 0101 007F 32 60 81 ld (ramCode+60h),a 0102 0082 DB 06 in a,(6) 0103 0084 F5 push af 0104 0085 3E 1F ld a,1Fh 0105 0087 E5 push hl 0106 0088 C3 61 81 jp ramCode+1+60h 0107 008B _ExecBootEP: 0108 008B D3 06 out (6),a 0109 008D DD 6E 00 ld l,(ix+0) 0110 0090 DD 66 01 ld h,(ix+1) 0111 0093 E5 push hl 0112 0094 DD E1 pop ix 0113 0096 E1 pop hl 0114 0097 3A 60 81 ld a,(ramCode+60h) 0115 009A CD 81 81 call jpIX-_ExecBootEP+ramCode+1+60h 0116 009D 32 60 81 ld (ramCode+60h),a 0117 00A0 E3 ex (sp),hl 0118 00A1 7D ld a,l 0119 00A2 D3 06 out (6),a 0120 00A4 3A 60 81 ld a,(ramCode+60h) 0121 00A7 E3 ex (sp),hl 0122 00A8 DD E1 pop ix 0123 00AA C9 ret 0124 00AB DD E9 jpIX: jp (ix) 0125 00AD _ExecBootEPEnd: 0126 00AD 0127 00AD x_ProdNrPart1: 0128 00AD 11 04 00 ld de,0004h 0129 00B0 C9 ret 0130 00B1 0131 00B1 x_cmpStr: 0132 00B1 AF xor a 0133 00B2 C9 ret 0134 00B3 0135 00B3 x_GetBootVer: 0136 00B3 AF xor a 0137 00B4 06 01 ld b,1 0138 00B6 C9 ret 0139 00B7 0140 00B7 x_DispBootVer: 0141 00B7 21 00 00 ld hl,0 0142 00BA 22 4B 84 ld (curRow),hl 0143 00BD 21 C9 00 ld hl,sBootCodeText 0144 00C0 7E PutS: ld a,(hl) 0145 00C1 B7 or a 0146 00C2 C8 ret z 0147 00C3 EF bcall(_PutC) 0147 00C4 04 45 0148 00C6 23 inc hl 0149 00C7 18 F7 jr PutS 0150 00C9 sBootCodeText: 0151 00C9 424F4F542043 .db "BOOT Code 0.02b",0 0151 00CF 6F646520302E30326200 0152 00D9 0153 00D9 x_Div16By8: 0154 00D9 16 00 ld d,0 0155 00DB x_Div16By16: 0156 00DB 7A ld a,d 0157 00DC B3 or e 0158 00DD C8 ret z 0159 00DE AF xor a 0160 00DF DD 21 51 82 ld ix,8251h 0161 00E3 DD 75 00 ld (ix+0),l 0162 00E6 DD 74 01 ld (ix+1),h 0163 00E9 67 ld h,a 0164 00EA 6F ld l,a 0165 00EB DD 77 02 ld (ix+2),a 0166 00EE 06 10 ld b,16 0167 00F0 div16By8Loop: 0168 00F0 DD CB 00 26 sla (ix+0) 0169 00F4 DD CB 01 16 rl (ix+1) 0170 00F8 CB 15 rl l 0171 00FA CB 14 rl h 0172 00FC DD CB 02 16 rl (ix+2) 0173 0100 B7 or a 0174 0101 ED 52 sbc hl,de 0175 0103 DD 7E 02 ld a,(ix+2) 0176 0106 DE 00 sbc a,0 0177 0108 DD 77 02 ld (ix+2),a 0178 010B F2 19 01 jp p,div16By8_1 0179 010E 19 add hl,de 0180 010F DD 7E 02 ld a,(ix+2) 0181 0112 CE 00 adc a,0 0182 0114 DD 77 02 ld (ix+2),a 0183 0117 18 04 jr div16By8_2 0184 0119 div16By8_1: 0185 0119 DD CB 00 C6 set 0,(ix+0) 0186 011D div16By8_2: 0187 011D 10 D1 djnz div16By8Loop 0188 011F DD 5E 00 ld e,(ix+0) 0189 0122 DD 56 01 ld d,(ix+1) 0190 0125 C9 ret 0191 0126 0192 0126 x_Div32By16: 0193 0126 7A ld a,d 0194 0127 B3 or e 0195 0128 C8 ret z 0196 0129 DD 21 51 82 ld ix,8251h 0197 012D 3A 78 84 ld a,(OP1) 0198 0130 DD 77 03 ld (ix+3),a 0199 0133 3A 79 84 ld a,(OP1+1) 0200 0136 DD 77 02 ld (ix+2),a 0201 0139 3A 7A 84 ld a,(OP1+2) 0202 013C DD 77 01 ld (ix+1),a 0203 013F 3A 7B 84 ld a,(OP1+3) 0204 0142 DD 77 00 ld (ix+0),a 0205 0145 AF xor a 0206 0146 32 78 84 ld (OP1),a 0207 0149 32 79 84 ld (OP1+1),a 0208 014C 32 7A 84 ld (OP1+2),a 0209 014F 32 7B 84 ld (OP1+3),a 0210 0152 06 20 ld b,32 0211 0154 div32Loop: 0212 0154 DD CB 00 26 sla (ix+0) 0213 0158 DD CB 01 16 rl (ix+1) 0214 015C DD CB 02 16 rl (ix+2) 0215 0160 DD CB 03 16 rl (ix+3) 0216 0164 DD 21 78 84 ld ix,OP1 0217 0168 DD CB 00 16 rl (ix+0) 0218 016C DD CB 01 16 rl (ix+1) 0219 0170 DD CB 02 16 rl (ix+2) 0220 0174 DD CB 03 16 rl (ix+3) 0221 0178 DD 21 51 82 ld ix,8251h 0222 017C B7 or a 0223 017D 2A 78 84 ld hl,(OP1) 0224 0180 ED 52 sbc hl,de 0225 0182 22 78 84 ld (OP1),hl 0226 0185 2A 7A 84 ld hl,(OP1+2) 0227 0188 C5 push bc 0228 0189 01 00 00 ld bc,0 0229 018C ED 42 sbc hl,bc 0230 018E C1 pop bc 0231 018F 22 7A 84 ld (OP1+2),hl 0232 0192 30 18 jr nc,div32_1 0233 0194 B7 or a 0234 0195 2A 78 84 ld hl,(OP1) 0235 0198 ED 5A adc hl,de 0236 019A 22 78 84 ld (OP1),hl 0237 019D 2A 7A 84 ld hl,(OP1+2) 0238 01A0 C5 push bc 0239 01A1 01 00 00 ld bc,0 0240 01A4 ED 4A adc hl,bc 0241 01A6 22 7A 84 ld (OP1+2),hl 0242 01A9 C1 pop bc 0243 01AA 18 04 jr div32_2 0244 01AC DD CB 00 C6 div32_1:set 0,(ix+0) 0245 01B0 10 A2 div32_2:djnz div32Loop 0246 01B2 DD 21 78 84 ld ix,OP1 0247 01B6 DD 66 02 ld h,(ix+2) 0248 01B9 DD 6E 03 ld l,(ix+3) 0249 01BC 22 83 84 ld (OP2),hl 0250 01BF DD 66 00 ld h,(ix+0) 0251 01C2 DD 6E 01 ld l,(ix+1) 0252 01C5 22 85 84 ld (OP2+2),hl 0253 01C8 DD 21 51 82 ld ix,8251h 0254 01CC DD 66 02 ld h,(ix+2) 0255 01CF DD 6E 03 ld l,(ix+3) 0256 01D2 22 78 84 ld (OP1),hl 0257 01D5 DD 66 00 ld h,(ix+0) 0258 01D8 DD 6E 01 ld l,(ix+1) 0259 01DB 22 7A 84 ld (OP1+2),hl 0260 01DE C9 ret 0261 01DF 0262 01DF .end 0263 01DF end 0264 01DF tasm: Number of errors = 0